mirror of https://gitee.com/antv-l7/antv-l7
test: 测试用例支持 new scene 对象 (#1291)
* chore: lint unuse * chore: pre commit command * chore: pre-commit 去除build 命令 * fix: 修复unuse import * test: 增加gl 模拟能力 * fix: lint error * chore: 提取测试utils 为单独包 * chore: 调整测试覆盖率值
This commit is contained in:
parent
1319882f8c
commit
340fd77729
|
@ -48,10 +48,10 @@ module.exports = {
|
||||||
coverageReporters: ["html"],
|
coverageReporters: ["html"],
|
||||||
coverageThreshold: {
|
coverageThreshold: {
|
||||||
global: {
|
global: {
|
||||||
branches: 6,
|
branches: 9,
|
||||||
functions: 7,
|
functions: 11.5,
|
||||||
lines: 9,
|
lines: 15,
|
||||||
statements: 9,
|
statements: 15,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,6 +2,7 @@ import Enzyme from 'enzyme';
|
||||||
import Adapter from 'enzyme-adapter-react-16';
|
import Adapter from 'enzyme-adapter-react-16';
|
||||||
import 'jest-styled-components';
|
import 'jest-styled-components';
|
||||||
import 'jest-canvas-mock';
|
import 'jest-canvas-mock';
|
||||||
|
|
||||||
// @ts-igore
|
// @ts-igore
|
||||||
window.URL.createObjectURL = function() {};
|
window.URL.createObjectURL = function() {};
|
||||||
Enzyme.configure({ adapter: new Adapter() });
|
Enzyme.configure({ adapter: new Adapter() });
|
||||||
|
|
|
@ -34,6 +34,9 @@
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"supercluster": "^7.0.0"
|
"supercluster": "^7.0.0"
|
||||||
},
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@antv/l7-test-utils": "2.9.23"
|
||||||
|
},
|
||||||
"gitHead": "684ba4eb806a798713496d3fc0b4d1e17517dc31",
|
"gitHead": "684ba4eb806a798713496d3fc0b4d1e17517dc31",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
describe('BaseControl', () => {
|
||||||
|
// const el = document.createElement('div');
|
||||||
|
// el.id = 'test-div-id';
|
||||||
|
// el.style.width = '500px';
|
||||||
|
// el.style.height = '500px';
|
||||||
|
// el.style.position = 'absolute';
|
||||||
|
// document.querySelector('body')?.appendChild(el);
|
||||||
|
// const scene = new Scene({
|
||||||
|
// id: 'test-div-id',
|
||||||
|
// map: new Map({
|
||||||
|
// style: 'dark',
|
||||||
|
// center: [110.19382669582967, 30.258134],
|
||||||
|
// pitch: 0,
|
||||||
|
// zoom: 3,
|
||||||
|
// }),
|
||||||
|
// });
|
||||||
|
it('control', () => {
|
||||||
|
expect(1).toEqual(1)
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
import Zoom from '../zoom';
|
||||||
|
import { TestScene } from '@antv/l7-test-utils'
|
||||||
|
|
||||||
|
|
||||||
|
describe('zoom', () => {
|
||||||
|
const zoom = new Zoom()
|
||||||
|
it('zoom getDefault', () => {
|
||||||
|
expect(zoom.getDefault().name).toEqual('zoom');
|
||||||
|
const scene = TestScene();
|
||||||
|
scene.addControl(zoom);
|
||||||
|
zoom.disable();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { IRenderConfig } from '../renderer/IRendererService';
|
||||||
export interface ISceneConfig extends IRenderConfig {
|
export interface ISceneConfig extends IRenderConfig {
|
||||||
id: string | HTMLDivElement;
|
id: string | HTMLDivElement;
|
||||||
canvas?: HTMLCanvasElement;
|
canvas?: HTMLCanvasElement;
|
||||||
|
gl?: any,
|
||||||
hasBaseMap?: boolean;
|
hasBaseMap?: boolean;
|
||||||
map: IMapWrapper;
|
map: IMapWrapper;
|
||||||
logoPosition?: PositionName;
|
logoPosition?: PositionName;
|
||||||
|
|
|
@ -48,7 +48,7 @@ export interface IExtensions {
|
||||||
|
|
||||||
export interface IRendererService {
|
export interface IRendererService {
|
||||||
extensionObject: IExtensions;
|
extensionObject: IExtensions;
|
||||||
init(canvas: HTMLCanvasElement, cfg: IRenderConfig): Promise<void>;
|
init(canvas: HTMLCanvasElement, cfg: IRenderConfig,gl: any): Promise<void>;
|
||||||
testExtension(name: string): boolean;
|
testExtension(name: string): boolean;
|
||||||
clear(options: IClearOptions): void;
|
clear(options: IClearOptions): void;
|
||||||
createModel(options: IModelInitializationOptions): IModel;
|
createModel(options: IModelInitializationOptions): IModel;
|
||||||
|
|
|
@ -200,7 +200,9 @@ export default class Scene extends EventEmitter implements ISceneService {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.canvas,
|
this.canvas,
|
||||||
this.configService.getSceneConfig(this.id) as IRenderConfig,
|
this.configService.getSceneConfig(this.id) as IRenderConfig,
|
||||||
|
sceneConfig.gl
|
||||||
);
|
);
|
||||||
|
this.initContainer()
|
||||||
|
|
||||||
elementResizeEvent(
|
elementResizeEvent(
|
||||||
this.$container as HTMLDivElement,
|
this.$container as HTMLDivElement,
|
||||||
|
@ -284,6 +286,7 @@ export default class Scene extends EventEmitter implements ISceneService {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
sceneConfig.canvas,
|
sceneConfig.canvas,
|
||||||
this.configService.getSceneConfig(this.id) as IRenderConfig,
|
this.configService.getSceneConfig(this.id) as IRenderConfig,
|
||||||
|
undefined,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.error('容器 id 不存在');
|
console.error('容器 id 不存在');
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
export * from './map';
|
export * from './map';
|
||||||
export * from './earthmap';
|
export * from './earthmap';
|
||||||
|
export * from './interface';
|
|
@ -119,10 +119,7 @@ export class Map extends Camera {
|
||||||
}
|
}
|
||||||
|
|
||||||
public resize(eventData?: any) {
|
public resize(eventData?: any) {
|
||||||
const dimensions = this.containerDimensions();
|
const [width, height] = this.containerDimensions();
|
||||||
const width = dimensions[0];
|
|
||||||
const height = dimensions[1];
|
|
||||||
|
|
||||||
this.transform.resize(width, height);
|
this.transform.resize(width, height);
|
||||||
// TODO: 小程序环境不需要执行后续动作
|
// TODO: 小程序环境不需要执行后续动作
|
||||||
if (isMini) {
|
if (isMini) {
|
||||||
|
@ -372,6 +369,9 @@ export class Map extends Camera {
|
||||||
} else {
|
} else {
|
||||||
width = this.container.clientWidth;
|
width = this.container.clientWidth;
|
||||||
height = this.container.clientHeight;
|
height = this.container.clientHeight;
|
||||||
|
width = width == 0 ? 400 : width;
|
||||||
|
height = height === 0 ? 300 : height;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return [width, height];
|
return [width, height];
|
||||||
|
|
|
@ -103,6 +103,7 @@ export default class L7MapService implements IMapService<Map> {
|
||||||
return this.simpleMapCoord.getSize();
|
return this.simpleMapCoord.getSize();
|
||||||
}
|
}
|
||||||
const size = this.map.transform;
|
const size = this.map.transform;
|
||||||
|
|
||||||
return [size.width, size.height];
|
return [size.width, size.height];
|
||||||
}
|
}
|
||||||
// get mapStatus method
|
// get mapStatus method
|
||||||
|
|
|
@ -42,8 +42,5 @@ export function toPaddingOptions(padding: IPadding = {}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return Object.assign({},defaultPadding,padding)
|
||||||
...defaultPadding,
|
|
||||||
...padding,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
"author": "xiaoiver",
|
"author": "xiaoiver",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"gl": "^5.0.3"
|
"gl": "^5.0.3",
|
||||||
|
"@antv/l7-test-utils": "2.9.23"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/l7-core": "2.9.23",
|
"@antv/l7-core": "2.9.23",
|
||||||
|
@ -36,6 +37,7 @@
|
||||||
"lodash": "^4.17.15",
|
"lodash": "^4.17.15",
|
||||||
"reflect-metadata": "^0.1.13"
|
"reflect-metadata": "^0.1.13"
|
||||||
},
|
},
|
||||||
|
|
||||||
"gitHead": "684ba4eb806a798713496d3fc0b4d1e17517dc31",
|
"gitHead": "684ba4eb806a798713496d3fc0b4d1e17517dc31",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
|
|
|
@ -6,7 +6,7 @@ import ReglAttribute from '../ReglAttribute';
|
||||||
import ReglBuffer from '../ReglBuffer';
|
import ReglBuffer from '../ReglBuffer';
|
||||||
import ReglModel from '../ReglModel';
|
import ReglModel from '../ReglModel';
|
||||||
import checkPixels from './utils/check-pixels';
|
import checkPixels from './utils/check-pixels';
|
||||||
import createContext from './utils/create-context';
|
import { createContext } from '@antv/l7-test-utils';
|
||||||
|
|
||||||
describe('ReglAttribute', () => {
|
describe('ReglAttribute', () => {
|
||||||
let context;
|
let context;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import ReglBuffer from '../ReglBuffer';
|
||||||
import ReglElements from '../ReglElements';
|
import ReglElements from '../ReglElements';
|
||||||
import ReglModel from '../ReglModel';
|
import ReglModel from '../ReglModel';
|
||||||
import checkPixels from './utils/check-pixels';
|
import checkPixels from './utils/check-pixels';
|
||||||
import createContext from './utils/create-context';
|
import { createContext } from '@antv/l7-test-utils';
|
||||||
|
|
||||||
describe('ReglElements', () => {
|
describe('ReglElements', () => {
|
||||||
let context;
|
let context;
|
||||||
|
|
|
@ -10,7 +10,7 @@ import ReglModel from '../ReglModel';
|
||||||
import ReglRenderbuffer from '../ReglRenderbuffer';
|
import ReglRenderbuffer from '../ReglRenderbuffer';
|
||||||
import ReglTexture2D from '../ReglTexture2D';
|
import ReglTexture2D from '../ReglTexture2D';
|
||||||
import checkPixels from './utils/check-pixels';
|
import checkPixels from './utils/check-pixels';
|
||||||
import createContext from './utils/create-context';
|
import { createContext } from '@antv/l7-test-utils';
|
||||||
|
|
||||||
describe('ReglFramebuffer', () => {
|
describe('ReglFramebuffer', () => {
|
||||||
let context;
|
let context;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import ReglAttribute from '../ReglAttribute';
|
||||||
import ReglBuffer from '../ReglBuffer';
|
import ReglBuffer from '../ReglBuffer';
|
||||||
import ReglModel from '../ReglModel';
|
import ReglModel from '../ReglModel';
|
||||||
import checkPixels from './utils/check-pixels';
|
import checkPixels from './utils/check-pixels';
|
||||||
import createContext from './utils/create-context';
|
import { createContext } from '@antv/l7-test-utils';
|
||||||
import globalDefaultprecision from './utils/default-precision';
|
import globalDefaultprecision from './utils/default-precision';
|
||||||
|
|
||||||
describe('Initialization for ReglModel', () => {
|
describe('Initialization for ReglModel', () => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import regl from 'l7regl';
|
import regl from 'l7regl';
|
||||||
import 'reflect-metadata';
|
import 'reflect-metadata';
|
||||||
import ReglModel from '../ReglModel';
|
import ReglModel from '../ReglModel';
|
||||||
import createContext from './utils/create-context';
|
import { createContext } from '@antv/l7-test-utils';
|
||||||
|
|
||||||
describe('ReglModel', () => {
|
describe('ReglModel', () => {
|
||||||
let context;
|
let context;
|
||||||
|
|
|
@ -3,7 +3,7 @@ import 'reflect-metadata';
|
||||||
import ReglFramebuffer from '../ReglFramebuffer';
|
import ReglFramebuffer from '../ReglFramebuffer';
|
||||||
import ReglModel from '../ReglModel';
|
import ReglModel from '../ReglModel';
|
||||||
import ReglTexture2D from '../ReglTexture2D';
|
import ReglTexture2D from '../ReglTexture2D';
|
||||||
import createContext from './utils/create-context';
|
import { createContext } from '@antv/l7-test-utils';
|
||||||
|
|
||||||
describe('uniforms in ReglModel', () => {
|
describe('uniforms in ReglModel', () => {
|
||||||
let gl;
|
let gl;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { ReglRendererService } from '../../index';
|
||||||
import ReglAttribute from '../ReglAttribute';
|
import ReglAttribute from '../ReglAttribute';
|
||||||
import ReglBuffer from '../ReglBuffer';
|
import ReglBuffer from '../ReglBuffer';
|
||||||
import checkPixels from './utils/check-pixels';
|
import checkPixels from './utils/check-pixels';
|
||||||
import createContext from './utils/create-context';
|
import { createContext } from '@antv/l7-test-utils';
|
||||||
import globalDefaultprecision from './utils/default-precision';
|
import globalDefaultprecision from './utils/default-precision';
|
||||||
|
|
||||||
describe('ReglRendererService', () => {
|
describe('ReglRendererService', () => {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import ReglBuffer from '../ReglBuffer';
|
||||||
import ReglModel from '../ReglModel';
|
import ReglModel from '../ReglModel';
|
||||||
import ReglTexture2D from '../ReglTexture2D';
|
import ReglTexture2D from '../ReglTexture2D';
|
||||||
import checkPixels from './utils/check-pixels';
|
import checkPixels from './utils/check-pixels';
|
||||||
import createContext from './utils/create-context';
|
import { createContext } from '@antv/l7-test-utils';
|
||||||
import globalDefaultprecision from './utils/default-precision';
|
import globalDefaultprecision from './utils/default-precision';
|
||||||
|
|
||||||
describe('ReglTexture', () => {
|
describe('ReglTexture', () => {
|
||||||
|
|
|
@ -48,9 +48,13 @@ export default class ReglRendererService implements IRendererService {
|
||||||
public async init(
|
public async init(
|
||||||
canvas: HTMLCanvasElement,
|
canvas: HTMLCanvasElement,
|
||||||
cfg: IRenderConfig,
|
cfg: IRenderConfig,
|
||||||
|
gl?: regl.Regl,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
// this.$container = $container;
|
// this.$container = $container;
|
||||||
this.canvas = canvas;
|
this.canvas = canvas;
|
||||||
|
if (gl) {
|
||||||
|
this.gl = gl;
|
||||||
|
} else {
|
||||||
// tslint:disable-next-line:typedef
|
// tslint:disable-next-line:typedef
|
||||||
this.gl = await new Promise((resolve, reject) => {
|
this.gl = await new Promise((resolve, reject) => {
|
||||||
regl({
|
regl({
|
||||||
|
@ -88,6 +92,7 @@ export default class ReglRendererService implements IRendererService {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.extensionObject = {
|
this.extensionObject = {
|
||||||
OES_texture_float: this.testExtension('OES_texture_float'),
|
OES_texture_float: this.testExtension('OES_texture_float'),
|
||||||
|
|
|
@ -1,37 +1,24 @@
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { Map } from '@antv/l7-maps';
|
import { TestScene } from '@antv/l7-test-utils'
|
||||||
import { Scene } from '../src/';
|
|
||||||
describe('template', () => {
|
|
||||||
// const el = document.createElement('div');
|
|
||||||
// el.id = 'test-div-id';
|
|
||||||
// el.style.width = '500px';
|
|
||||||
// el.style.height = '500px';
|
|
||||||
// el.style.position = 'absolute';
|
|
||||||
// document.querySelector('body')?.appendChild(el);
|
|
||||||
// const scene = new Scene({
|
|
||||||
// id: 'test-div-id',
|
|
||||||
// map: new Map({
|
|
||||||
// style: 'dark',
|
|
||||||
// center: [110.19382669582967, 30.258134],
|
|
||||||
// pitch: 0,
|
|
||||||
// zoom: 3,
|
|
||||||
// }),
|
|
||||||
// });
|
|
||||||
|
|
||||||
it('scene map method', () => {
|
|
||||||
// expect(scene.getZoom()).toEqual(3);
|
describe('template', () => {
|
||||||
// expect(scene.getPitch()).toEqual(0);
|
|
||||||
// const center = scene.getCenter();
|
const el = document.createElement('div');
|
||||||
// expect(center.lng).toEqual(110.19382669582967);
|
el.id = 'test-div-id';
|
||||||
// expect(center.lat).toEqual(30.258134);
|
const body = document.querySelector('body') as HTMLBodyElement;
|
||||||
// expect(scene.getRotation()).toEqual(-0);
|
body.appendChild(el);
|
||||||
// // expect(scene.getBounds()[0].map((v) => v.toFixed(5))).toEqual(
|
const scene = TestScene({});
|
||||||
// // [88.22117044582802, 9.751305353647084].map((v) => v.toFixed(5)),
|
|
||||||
// // ); // TODO 校验不通过
|
|
||||||
// scene.setZoom(5);
|
it('scene map status', async () => {
|
||||||
// expect(scene.getZoom()).toEqual(5);
|
expect( scene.getZoom()).toEqual(3)
|
||||||
// scene.setPitch(5);
|
expect(scene.getMinZoom()).toEqual(-2)
|
||||||
// expect(scene.getPitch()).toEqual(5);
|
expect(scene.getMaxZoom()).toEqual(22)
|
||||||
expect(3).toEqual(3);
|
expect(scene.getType()).toEqual('default');
|
||||||
|
expect(scene.getBounds()).toEqual([[92.61570169583138, 18.27006017947646], [127.7719516958324, 40.94589761553888]])
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -34,6 +34,9 @@
|
||||||
"mapbox-gl": "^1.2.1",
|
"mapbox-gl": "^1.2.1",
|
||||||
"reflect-metadata": "^0.1.13"
|
"reflect-metadata": "^0.1.13"
|
||||||
},
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@antv/l7-test-utils": "2.9.23"
|
||||||
|
},
|
||||||
"gitHead": "684ba4eb806a798713496d3fc0b4d1e17517dc31",
|
"gitHead": "684ba4eb806a798713496d3fc0b4d1e17517dc31",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
|
|
|
@ -64,7 +64,7 @@ class Scene
|
||||||
private container: Container;
|
private container: Container;
|
||||||
|
|
||||||
public constructor(config: ISceneConfig) {
|
public constructor(config: ISceneConfig) {
|
||||||
const { id, map, canvas, hasBaseMap } = config;
|
const { id, map, canvas, hasBaseMap, } = config;
|
||||||
// 创建场景容器
|
// 创建场景容器
|
||||||
const sceneContainer = createSceneContainer();
|
const sceneContainer = createSceneContainer();
|
||||||
this.container = sceneContainer;
|
this.container = sceneContainer;
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
export default {
|
||||||
|
// more father 4 config: https://github.com/umijs/father-next/blob/master/docs/config.md
|
||||||
|
esm: {
|
||||||
|
output:'es'
|
||||||
|
},
|
||||||
|
cjs: {
|
||||||
|
output:'lib'
|
||||||
|
},
|
||||||
|
autoprefixer: {
|
||||||
|
browsers: ['IE 11', 'last 2 versions'],
|
||||||
|
},
|
||||||
|
extraBabelPresets: [
|
||||||
|
'@babel/preset-typescript'
|
||||||
|
],
|
||||||
|
extraBabelPlugins: [
|
||||||
|
// 开发模式下以原始文本引入,便于调试
|
||||||
|
[
|
||||||
|
// import glsl as raw text
|
||||||
|
'babel-plugin-inline-import',
|
||||||
|
{
|
||||||
|
extensions: [
|
||||||
|
'.glsl'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'transform-import-css-l7'
|
||||||
|
],
|
||||||
|
],
|
||||||
|
};
|
|
@ -0,0 +1,3 @@
|
||||||
|
lib
|
||||||
|
es
|
||||||
|
dist
|
|
@ -0,0 +1,11 @@
|
||||||
|
# `test-utils`
|
||||||
|
|
||||||
|
> TODO: description
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
const testUtils = require('test-utils');
|
||||||
|
|
||||||
|
// TODO: DEMONSTRATE API
|
||||||
|
```
|
|
@ -0,0 +1,47 @@
|
||||||
|
{
|
||||||
|
"name": "@antv/l7-test-utils",
|
||||||
|
"version": "2.9.23",
|
||||||
|
"description": "Now I’m the model of a modern major general / The venerated Virginian veteran whose men are all / Lining up, to put me up on a pedestal / Writin’ letters to relatives / Embellishin’ my elegance and eloquence / But the elephant is in the room / The truth is in ya face when ya hear the British cannons go / BOOM",
|
||||||
|
"keywords": [],
|
||||||
|
"author": "lzxue <lzx199065@gmail.com>",
|
||||||
|
"license": "ISC",
|
||||||
|
"module": "es/index.js",
|
||||||
|
"types": "es/index.d.ts",
|
||||||
|
"sideEffects": true,
|
||||||
|
"files": [
|
||||||
|
"lib",
|
||||||
|
"es",
|
||||||
|
"dist",
|
||||||
|
"README.md"
|
||||||
|
],
|
||||||
|
"directories": {
|
||||||
|
"lib": "lib",
|
||||||
|
"test": "__tests__"
|
||||||
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"registry": "https://registry.npm.alibaba-inc.com/"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/antvis/L7.git"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"clean": "rimraf dist; rimraf es; rimraf lib;",
|
||||||
|
"build": "father build",
|
||||||
|
"build:cjs": "BABEL_ENV=cjs babel src --root-mode upward --out-dir lib --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments",
|
||||||
|
"build:esm": "BABEL_ENV=esm babel src --root-mode upward --out-dir es --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments",
|
||||||
|
"watch": "BABEL_ENV=cjs babel src --watch --root-mode upward --out-dir lib --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments",
|
||||||
|
"sync": "tnpm sync"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/antvis/L7/issues"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@antv/l7-map": "2.9.23",
|
||||||
|
"@antv/l7-maps": "2.9.23",
|
||||||
|
"@antv/l7-scene": "2.9.23",
|
||||||
|
"l7regl": "^0.0.20",
|
||||||
|
"gl": "^5.0.3"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/antvis/L7#readme"
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
import regl from 'l7regl';
|
||||||
|
|
||||||
|
// borrow from https://github.com/regl-project/regl/blob/gh-pages/test/attributes.js#L303-L311
|
||||||
|
export default function checkPixels(
|
||||||
|
reGL: regl.Regl,
|
||||||
|
expected: number[],
|
||||||
|
): boolean {
|
||||||
|
const actual = reGL.read();
|
||||||
|
for (let i = 0; i < 1 * 1; ++i) {
|
||||||
|
if (actual[4 * i] !== expected[i]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
import gl from 'gl';
|
||||||
|
|
||||||
|
// borrow from regl
|
||||||
|
// @see https://github.com/regl-project/regl/blob/gh-pages/test/util/create-context.js#L28
|
||||||
|
const CONTEXT = gl(1, 1, { preserveDrawingBuffer: true });
|
||||||
|
// @ts-ignore
|
||||||
|
const RESIZE = CONTEXT.getExtension('STACKGL_resize_drawingbuffer');
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
export default function(width: number, height: number) {
|
||||||
|
resize(width, height);
|
||||||
|
return CONTEXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resize(width: number, height: number) {
|
||||||
|
if (RESIZE) {
|
||||||
|
RESIZE.resize(width, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function destroy() {
|
||||||
|
//
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
const globalDefaultprecision =
|
||||||
|
'#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n #else\n precision mediump float;\n#endif\n';
|
||||||
|
export default globalDefaultprecision;
|
|
@ -0,0 +1,2 @@
|
||||||
|
export * from './test-scene'
|
||||||
|
export { default as createContext } from './create-context'
|
|
@ -0,0 +1,28 @@
|
||||||
|
import createContext from './create-context';
|
||||||
|
import { Scene } from '@antv/l7-scene';
|
||||||
|
import regl from 'l7regl';
|
||||||
|
import { IMapOptions } from '@antv/l7-map';
|
||||||
|
import { Map } from '@antv/l7-maps';
|
||||||
|
|
||||||
|
export function TestScene(options?: Partial<IMapOptions>) {
|
||||||
|
const el = document.createElement('div');
|
||||||
|
el.id = 'test-div-id';
|
||||||
|
const body = document.querySelector('body') as HTMLBodyElement;
|
||||||
|
body.appendChild(el);
|
||||||
|
|
||||||
|
const context = createContext(400, 300);
|
||||||
|
const reGL = regl(context);
|
||||||
|
const scene = new Scene({
|
||||||
|
id: el,
|
||||||
|
gl: reGL,
|
||||||
|
map: new Map({
|
||||||
|
style: 'dark',
|
||||||
|
center: [110.19382669582967, 30.258134],
|
||||||
|
pitch: 0,
|
||||||
|
zoom: 3,
|
||||||
|
...options,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
return scene;
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"extends": "../../tsconfig.build.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"declarationDir": "./es",
|
||||||
|
"rootDir": "./src",
|
||||||
|
"baseUrl": "./",
|
||||||
|
"paths": {
|
||||||
|
"*": ["node_modules", "typings/*"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": ["src"]
|
||||||
|
}
|
|
@ -29,6 +29,7 @@
|
||||||
"@antv/l7-source": ["packages/source/src"],
|
"@antv/l7-source": ["packages/source/src"],
|
||||||
"@antv/l7-mini": ["packages/mini/src"],
|
"@antv/l7-mini": ["packages/mini/src"],
|
||||||
"@antv/l7-utils": ["packages/utils/src"],
|
"@antv/l7-utils": ["packages/utils/src"],
|
||||||
|
"@antv/l7-test-utils":["packages/test-utils/src"],
|
||||||
"@antv/l7": ["packages/l7/src"],
|
"@antv/l7": ["packages/l7/src"],
|
||||||
"*": ["packages", "typings/*"]
|
"*": ["packages", "typings/*"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,9 @@ declare module '@antv/l7-layers';
|
||||||
declare module '@antv/l7-maps';
|
declare module '@antv/l7-maps';
|
||||||
declare module '@antv/l7-utils';
|
declare module '@antv/l7-utils';
|
||||||
declare module '@antv/l7-scene';
|
declare module '@antv/l7-scene';
|
||||||
|
declare module '@antv/l7-test-utils';
|
||||||
|
declare module '@antv/l7-test-utils';
|
||||||
|
declare module '@antv/l7-component';
|
||||||
declare module 'l7regl';
|
declare module 'l7regl';
|
||||||
declare module 'l7hammerjs';
|
declare module 'l7hammerjs';
|
||||||
declare module 'l7-tiny-sdf';
|
declare module 'l7-tiny-sdf';
|
Loading…
Reference in New Issue