mirror of https://gitee.com/antv-l7/antv-l7
Chore lint update (#1600)
* chore: update lint config * fix: 移除空行 * fix: util export * chore: 优化lint 配置
This commit is contained in:
parent
13b9e3249d
commit
4db42a1814
|
@ -172,10 +172,10 @@
|
||||||
"build": " yarn worker && lerna run build",
|
"build": " yarn worker && lerna run build",
|
||||||
"postbuild": "yarn build:declarations",
|
"postbuild": "yarn build:declarations",
|
||||||
"build:declarations": "lerna run tsc --stream --no-bail",
|
"build:declarations": "lerna run tsc --stream --no-bail",
|
||||||
"tslint": "tslint packages/**/src/**/*.ts -c tslint.prod.json",
|
"lint:tslint": "tslint -p tsconfig.json -c tslint.prod.json",
|
||||||
"lint:tslint-fix": "tslint packages/**/src/**/*.ts -c tslint.prod.json --fix",
|
"lint-tslint-fix": "tslint -p tsconfig.json -c tslint.prod.json --fix",
|
||||||
"lint:fix": "prettier --write packages/**/src/**/*.ts packages/site/docs/api/**/*.md packages/site/docs/api/*.md dev-demos/**/**/*.tsx *.md",
|
"lint-fix": "prettier --write packages/**/src/**/*.ts packages/site/docs/api/**/*.md packages/site/docs/api/*.md dev-demos/**/**/*.tsx *.md",
|
||||||
"lint:src": "eslint packages/**/src/ dev-demos/ --ext .ts,.tsx",
|
"lint:src": "eslint dev-demos/ --ext .ts,.tsx",
|
||||||
"lint:examples": "eslint packages/site/examples --fix --ext .js",
|
"lint:examples": "eslint packages/site/examples --fix --ext .js",
|
||||||
"lint:css": "stylelint 'packages/**/src/**/*.js{,x}'",
|
"lint:css": "stylelint 'packages/**/src/**/*.js{,x}'",
|
||||||
"lint": "run-p -c lint:*",
|
"lint": "run-p -c lint:*",
|
||||||
|
|
|
@ -7,7 +7,9 @@ class TestControl extends Control {
|
||||||
public onAdd(): HTMLElement {
|
public onAdd(): HTMLElement {
|
||||||
return DOM.create('div');
|
return DOM.create('div');
|
||||||
}
|
}
|
||||||
public onRemove(): void {}
|
public onRemove(): void {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('control', () => {
|
describe('control', () => {
|
||||||
|
|
|
@ -27,11 +27,11 @@ describe('mapTheme', () => {
|
||||||
'mapbox://styles/mapbox/streets-v11',
|
'mapbox://styles/mapbox/streets-v11',
|
||||||
);
|
);
|
||||||
|
|
||||||
const optionList = ((control
|
const optionList = (
|
||||||
.getPopper()
|
control.getPopper().getContent() as HTMLDivElement
|
||||||
.getContent() as HTMLDivElement).querySelectorAll(
|
).querySelectorAll(
|
||||||
'.l7-select-control-item',
|
'.l7-select-control-item',
|
||||||
) as unknown) as HTMLDivElement[];
|
) as unknown as HTMLDivElement[];
|
||||||
optionList[1].click();
|
optionList[1].click();
|
||||||
|
|
||||||
// expect(control.getSelectValue()).toEqual(
|
// expect(control.getSelectValue()).toEqual(
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe('popup', () => {
|
||||||
it('life cycle', () => {
|
it('life cycle', () => {
|
||||||
const popup = new Popup({
|
const popup = new Popup({
|
||||||
html: '123456',
|
html: '123456',
|
||||||
className: className,
|
className,
|
||||||
lngLat: {
|
lngLat: {
|
||||||
lng: 120,
|
lng: 120,
|
||||||
lat: 30,
|
lat: 30,
|
||||||
|
|
|
@ -27,6 +27,7 @@ class SingleControl extends SelectControl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tslint:disable-next-line: max-classes-per-file
|
||||||
class MultiControl extends SelectControl {
|
class MultiControl extends SelectControl {
|
||||||
public getDefault(option: any): any {
|
public getDefault(option: any): any {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -36,7 +36,8 @@
|
||||||
"supercluster": "^7.0.0"
|
"supercluster": "^7.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@antv/l7-test-utils": "2.13.6",
|
"@antv/l7-layers": "^2.13.6",
|
||||||
|
"@antv/l7-test-utils": "^2.13.6",
|
||||||
"gcoord": "^0.3.2",
|
"gcoord": "^0.3.2",
|
||||||
"less": "^4.1.3"
|
"less": "^4.1.3"
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,7 +11,7 @@ export interface IButtonControlOption extends IControlOption {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ButtonControl<
|
export default class ButtonControl<
|
||||||
O extends IButtonControlOption = IButtonControlOption
|
O extends IButtonControlOption = IButtonControlOption,
|
||||||
> extends Control<O> {
|
> extends Control<O> {
|
||||||
/**
|
/**
|
||||||
* 当前按钮是否禁用
|
* 当前按钮是否禁用
|
||||||
|
|
|
@ -16,7 +16,6 @@ import { Container } from 'inversify';
|
||||||
import { ControlEvent } from '../../interface';
|
import { ControlEvent } from '../../interface';
|
||||||
|
|
||||||
export { PositionType } from '@antv/l7-core';
|
export { PositionType } from '@antv/l7-core';
|
||||||
|
|
||||||
export { Control };
|
export { Control };
|
||||||
|
|
||||||
export interface IControlOption {
|
export interface IControlOption {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export * from './control';
|
|
||||||
export * from './buttonControl';
|
export * from './buttonControl';
|
||||||
|
export * from './control';
|
||||||
export * from './popperControl';
|
export * from './popperControl';
|
||||||
export * from './selectControl';
|
export * from './selectControl';
|
||||||
|
|
|
@ -26,7 +26,7 @@ const PopperPlacementMap: Record<PositionName, PopperPlacement> = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default class PopperControl<
|
export default class PopperControl<
|
||||||
O extends IPopperControlOption = IPopperControlOption
|
O extends IPopperControlOption = IPopperControlOption,
|
||||||
> extends ButtonControl<O> {
|
> extends ButtonControl<O> {
|
||||||
/**
|
/**
|
||||||
* 气泡实例
|
* 气泡实例
|
||||||
|
@ -70,11 +70,8 @@ export default class PopperControl<
|
||||||
}
|
}
|
||||||
|
|
||||||
public initPopper() {
|
public initPopper() {
|
||||||
const {
|
const { popperClassName, popperPlacement, popperTrigger } =
|
||||||
popperClassName,
|
this.controlOption;
|
||||||
popperPlacement,
|
|
||||||
popperTrigger,
|
|
||||||
} = this.controlOption;
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
const popperContainer = this.mapsService.getMapContainer()!;
|
const popperContainer = this.mapsService.getMapContainer()!;
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ enum SelectControlConstant {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class SelectControl<
|
export default class SelectControl<
|
||||||
O extends ISelectControlOption = ISelectControlOption
|
O extends ISelectControlOption = ISelectControlOption,
|
||||||
> extends PopperControl<O> {
|
> extends PopperControl<O> {
|
||||||
/**
|
/**
|
||||||
* 当前选中的值
|
* 当前选中的值
|
||||||
|
|
|
@ -6,18 +6,16 @@ import './assets/iconfont/iconfont.js';
|
||||||
import './css/index.css';
|
import './css/index.css';
|
||||||
|
|
||||||
export * from './control/baseControl';
|
export * from './control/baseControl';
|
||||||
export * from './control/logo';
|
|
||||||
export * from './control/fullscreen';
|
|
||||||
export * from './control/exportImage';
|
export * from './control/exportImage';
|
||||||
|
export * from './control/fullscreen';
|
||||||
export * from './control/geoLocate';
|
export * from './control/geoLocate';
|
||||||
export * from './control/mapTheme';
|
|
||||||
export * from './control/layerSwitch';
|
export * from './control/layerSwitch';
|
||||||
|
export * from './control/logo';
|
||||||
|
export * from './control/mapTheme';
|
||||||
export * from './control/mouseLocation';
|
export * from './control/mouseLocation';
|
||||||
export * from './control/zoom';
|
|
||||||
export * from './control/scale';
|
export * from './control/scale';
|
||||||
export * from './popup/popup';
|
export * from './control/zoom';
|
||||||
export * from './popup/layerPopup';
|
|
||||||
|
|
||||||
export { Marker, MarkerLayer };
|
|
||||||
|
|
||||||
export * from './interface';
|
export * from './interface';
|
||||||
|
export * from './popup/layerPopup';
|
||||||
|
export * from './popup/popup';
|
||||||
|
export { Marker, MarkerLayer };
|
||||||
|
|
|
@ -83,7 +83,9 @@ export default class MarkerLayer extends EventEmitter {
|
||||||
|
|
||||||
// 设置容器大小
|
// 设置容器大小
|
||||||
private setContainerSize() {
|
private setContainerSize() {
|
||||||
if (!this.mapsService) return;
|
if (!this.mapsService) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const container = this.mapsService.getContainer();
|
const container = this.mapsService.getContainer();
|
||||||
this.containerSize = {
|
this.containerSize = {
|
||||||
containerWidth: container?.scrollWidth || 0,
|
containerWidth: container?.scrollWidth || 0,
|
||||||
|
@ -117,7 +119,6 @@ export default class MarkerLayer extends EventEmitter {
|
||||||
// if(this.inited) {
|
// if(this.inited) {
|
||||||
// marker.addTo(this.scene);
|
// marker.addTo(this.scene);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public removeMarker(marker: IMarker) {
|
public removeMarker(marker: IMarker) {
|
||||||
|
@ -274,9 +275,8 @@ export default class MarkerLayer extends EventEmitter {
|
||||||
private clusterMarker(feature: any) {
|
private clusterMarker(feature: any) {
|
||||||
const clusterOption = this.markerLayerOption.clusterOption;
|
const clusterOption = this.markerLayerOption.clusterOption;
|
||||||
|
|
||||||
const {
|
const { element = this.generateElement.bind(this) } =
|
||||||
element = this.generateElement.bind(this),
|
clusterOption as IMarkerStyleOption;
|
||||||
} = clusterOption as IMarkerStyleOption;
|
|
||||||
const marker = new Marker({
|
const marker = new Marker({
|
||||||
element: element(feature),
|
element: element(feature),
|
||||||
}).setLnglat({
|
}).setLnglat({
|
||||||
|
@ -292,9 +292,13 @@ export default class MarkerLayer extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private update() {
|
private update() {
|
||||||
if (!this.mapsService) return;
|
if (!this.mapsService) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 当图层中无marker时,无需更新
|
// 当图层中无marker时,无需更新
|
||||||
if (this.markers.length === 0) return;
|
if (this.markers.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const zoom = this.mapsService.getZoom();
|
const zoom = this.mapsService.getZoom();
|
||||||
const bbox = this.mapsService.getBounds();
|
const bbox = this.mapsService.getBounds();
|
||||||
|
|
|
@ -27,6 +27,7 @@ export default class Marker extends EventEmitter {
|
||||||
private lngLat: ILngLat;
|
private lngLat: ILngLat;
|
||||||
private scene: Container;
|
private scene: Container;
|
||||||
private added: boolean = false;
|
private added: boolean = false;
|
||||||
|
// tslint:disable-next-line: no-empty
|
||||||
public getMarkerLayerContainerSize(): IMarkerContainerAndBounds | void {}
|
public getMarkerLayerContainerSize(): IMarkerContainerAndBounds | void {}
|
||||||
|
|
||||||
constructor(option?: Partial<IMarkerOption>) {
|
constructor(option?: Partial<IMarkerOption>) {
|
||||||
|
@ -244,7 +245,9 @@ export default class Marker extends EventEmitter {
|
||||||
const { containerHeight, containerWidth, bounds } =
|
const { containerHeight, containerWidth, bounds } =
|
||||||
this.getMarkerLayerContainerSize() || this.getCurrentContainerSize();
|
this.getMarkerLayerContainerSize() || this.getCurrentContainerSize();
|
||||||
|
|
||||||
if (!bounds) return;
|
if (!bounds) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 当前可视区域包含跨日界线
|
// 当前可视区域包含跨日界线
|
||||||
if (Math.abs(bounds[0][0]) > 180 || Math.abs(bounds[1][0]) > 180) {
|
if (Math.abs(bounds[0][0]) > 180 || Math.abs(bounds[1][0]) > 180) {
|
||||||
if (pos.x > containerWidth) {
|
if (pos.x > containerWidth) {
|
||||||
|
@ -349,7 +352,7 @@ export default class Marker extends EventEmitter {
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
private addDragHandler(e: MouseEvent) {
|
private addDragHandler(e: MouseEvent) {
|
||||||
return null
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
|
|
@ -8,10 +8,38 @@ import BasePostProcessingPass from './services/renderer/passes/BasePostProcessin
|
||||||
import { TYPES } from './types';
|
import { TYPES } from './types';
|
||||||
import { packCircleVertex } from './utils/vertex-compression';
|
import { packCircleVertex } from './utils/vertex-compression';
|
||||||
|
|
||||||
|
export * from './services/asset/IFontService';
|
||||||
|
export * from './services/asset/IIconService';
|
||||||
|
export * from './services/asset/ITextureService';
|
||||||
|
export * from './services/camera/ICameraService';
|
||||||
|
export * from './services/component/IControlService';
|
||||||
|
export * from './services/component/IMarkerService';
|
||||||
|
export * from './services/component/IPopupService';
|
||||||
|
export * from './services/config/IConfigService';
|
||||||
|
export * from './services/coordinate/ICoordinateSystemService';
|
||||||
|
export * from './services/debug/IDebugService';
|
||||||
|
export * from './services/interaction/IInteractionService';
|
||||||
|
export * from './services/interaction/IPickingService';
|
||||||
|
/** 暴露服务接口供其他 packages 实现 */
|
||||||
|
export * from './services/layer/ILayerService';
|
||||||
|
export * from './services/layer/IStyleAttributeService';
|
||||||
|
export * from './services/map/IMapService';
|
||||||
|
export * from './services/renderer/gl';
|
||||||
|
/** 全部渲染服务接口 */
|
||||||
|
export * from './services/renderer/IAttribute';
|
||||||
|
export * from './services/renderer/IBuffer';
|
||||||
|
export * from './services/renderer/IElements';
|
||||||
|
export * from './services/renderer/IFramebuffer';
|
||||||
|
export * from './services/renderer/IModel';
|
||||||
|
export * from './services/renderer/IMultiPassRenderer';
|
||||||
|
export * from './services/renderer/IRenderbuffer';
|
||||||
|
export * from './services/renderer/IRendererService';
|
||||||
|
export * from './services/renderer/ITexture2D';
|
||||||
|
export * from './services/renderer/IUniform';
|
||||||
|
export * from './services/scene/ISceneService';
|
||||||
|
export * from './services/shader/IShaderModuleService';
|
||||||
|
export * from './services/source/ISourceService';
|
||||||
export {
|
export {
|
||||||
/**
|
|
||||||
* IoC 容器
|
|
||||||
*/
|
|
||||||
container,
|
container,
|
||||||
createSceneContainer,
|
createSceneContainer,
|
||||||
createLayerContainer,
|
createLayerContainer,
|
||||||
|
@ -27,36 +55,3 @@ export {
|
||||||
packCircleVertex,
|
packCircleVertex,
|
||||||
BasePostProcessingPass,
|
BasePostProcessingPass,
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 暴露服务接口供其他 packages 实现 */
|
|
||||||
export * from './services/layer/ILayerService';
|
|
||||||
export * from './services/debug/IDebugService';
|
|
||||||
export * from './services/layer/IStyleAttributeService';
|
|
||||||
export * from './services/source/ISourceService';
|
|
||||||
export * from './services/map/IMapService';
|
|
||||||
export * from './services/coordinate/ICoordinateSystemService';
|
|
||||||
export * from './services/renderer/IRendererService';
|
|
||||||
export * from './services/camera/ICameraService';
|
|
||||||
export * from './services/config/IConfigService';
|
|
||||||
export * from './services/scene/ISceneService';
|
|
||||||
export * from './services/shader/IShaderModuleService';
|
|
||||||
export * from './services/asset/IIconService';
|
|
||||||
export * from './services/asset/IFontService';
|
|
||||||
export * from './services/asset/ITextureService';
|
|
||||||
export * from './services/component/IControlService';
|
|
||||||
export * from './services/component/IMarkerService';
|
|
||||||
export * from './services/component/IPopupService';
|
|
||||||
export * from './services/interaction/IInteractionService';
|
|
||||||
export * from './services/interaction/IPickingService';
|
|
||||||
|
|
||||||
/** 全部渲染服务接口 */
|
|
||||||
export * from './services/renderer/IAttribute';
|
|
||||||
export * from './services/renderer/IBuffer';
|
|
||||||
export * from './services/renderer/IElements';
|
|
||||||
export * from './services/renderer/IFramebuffer';
|
|
||||||
export * from './services/renderer/IModel';
|
|
||||||
export * from './services/renderer/IMultiPassRenderer';
|
|
||||||
export * from './services/renderer/IRenderbuffer';
|
|
||||||
export * from './services/renderer/ITexture2D';
|
|
||||||
export * from './services/renderer/IUniform';
|
|
||||||
export * from './services/renderer/gl';
|
|
||||||
|
|
|
@ -16,10 +16,10 @@ import { ICameraService } from './services/camera/ICameraService';
|
||||||
import { IControlService } from './services/component/IControlService';
|
import { IControlService } from './services/component/IControlService';
|
||||||
import { IGlobalConfigService } from './services/config/IConfigService';
|
import { IGlobalConfigService } from './services/config/IConfigService';
|
||||||
import { ICoordinateSystemService } from './services/coordinate/ICoordinateSystemService';
|
import { ICoordinateSystemService } from './services/coordinate/ICoordinateSystemService';
|
||||||
|
import { IDebugService } from './services/debug/IDebugService';
|
||||||
import { IInteractionService } from './services/interaction/IInteractionService';
|
import { IInteractionService } from './services/interaction/IInteractionService';
|
||||||
import { IPickingService } from './services/interaction/IPickingService';
|
import { IPickingService } from './services/interaction/IPickingService';
|
||||||
import { ILayerService } from './services/layer/ILayerService';
|
import { ILayerService } from './services/layer/ILayerService';
|
||||||
import { IDebugService } from './services/debug/IDebugService';
|
|
||||||
import { IStyleAttributeService } from './services/layer/IStyleAttributeService';
|
import { IStyleAttributeService } from './services/layer/IStyleAttributeService';
|
||||||
import { ISceneService } from './services/scene/ISceneService';
|
import { ISceneService } from './services/scene/ISceneService';
|
||||||
import { IShaderModuleService } from './services/shader/IShaderModuleService';
|
import { IShaderModuleService } from './services/shader/IShaderModuleService';
|
||||||
|
@ -33,10 +33,10 @@ import MarkerService from './services/component/MarkerService';
|
||||||
import PopupService from './services/component/PopupService';
|
import PopupService from './services/component/PopupService';
|
||||||
import GlobalConfigService from './services/config/ConfigService';
|
import GlobalConfigService from './services/config/ConfigService';
|
||||||
import CoordinateSystemService from './services/coordinate/CoordinateSystemService';
|
import CoordinateSystemService from './services/coordinate/CoordinateSystemService';
|
||||||
|
import DebugService from './services/debug/DebugService';
|
||||||
import InteractionService from './services/interaction/InteractionService';
|
import InteractionService from './services/interaction/InteractionService';
|
||||||
import PickingService from './services/interaction/PickingService';
|
import PickingService from './services/interaction/PickingService';
|
||||||
import LayerService from './services/layer/LayerService';
|
import LayerService from './services/layer/LayerService';
|
||||||
import DebugService from './services/debug/DebugService';
|
|
||||||
import StyleAttributeService from './services/layer/StyleAttributeService';
|
import StyleAttributeService from './services/layer/StyleAttributeService';
|
||||||
import SceneService from './services/scene/SceneService';
|
import SceneService from './services/scene/SceneService';
|
||||||
import ShaderModuleService from './services/shader/ShaderModuleService';
|
import ShaderModuleService from './services/shader/ShaderModuleService';
|
||||||
|
@ -220,7 +220,8 @@ export function createSceneContainer() {
|
||||||
.whenTargetNamed('taa');
|
.whenTargetNamed('taa');
|
||||||
sceneContainer
|
sceneContainer
|
||||||
.bind<interfaces.Factory<IPass<unknown>>>(TYPES.IFactoryNormalPass)
|
.bind<interfaces.Factory<IPass<unknown>>>(TYPES.IFactoryNormalPass)
|
||||||
.toFactory<IPass<unknown>>((context) => (named: string) =>
|
.toFactory<IPass<unknown>>(
|
||||||
|
(context) => (named: string) =>
|
||||||
context.container.getNamed<IPass<unknown>>(TYPES.INormalPass, named),
|
context.container.getNamed<IPass<unknown>>(TYPES.INormalPass, named),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { $window, LRUCache } from '@antv/l7-utils';
|
import { $window, LRUCache } from '@antv/l7-utils';
|
||||||
import { injectable } from 'inversify';
|
|
||||||
import { EventEmitter } from 'eventemitter3';
|
import { EventEmitter } from 'eventemitter3';
|
||||||
|
import { injectable } from 'inversify';
|
||||||
import TinySDF from 'l7-tiny-sdf';
|
import TinySDF from 'l7-tiny-sdf';
|
||||||
import 'reflect-metadata';
|
import 'reflect-metadata';
|
||||||
import { buildMapping } from '../../utils/font_util';
|
import { buildMapping } from '../../utils/font_util';
|
||||||
|
@ -73,7 +73,7 @@ export default class FontService extends EventEmitter implements IFontService {
|
||||||
|
|
||||||
public get mapping(): IFontMapping {
|
public get mapping(): IFontMapping {
|
||||||
const data = this.cache.get(this.key);
|
const data = this.cache.get(this.key);
|
||||||
return data && data.mapping || {};
|
return (data && data.mapping) || {};
|
||||||
}
|
}
|
||||||
public fontAtlas: IFontAtlas;
|
public fontAtlas: IFontAtlas;
|
||||||
|
|
||||||
|
@ -179,21 +179,17 @@ export default class FontService extends EventEmitter implements IFontService {
|
||||||
document.fonts.load(`24px ${fontFamily}`, 'L7text');
|
document.fonts.load(`24px ${fontFamily}`, 'L7text');
|
||||||
document.fonts.ready.then(() => {
|
document.fonts.ready.then(() => {
|
||||||
this.emit('fontloaded', {
|
this.emit('fontloaded', {
|
||||||
fontFamily
|
fontFamily,
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('当前环境不支持 document.fonts !');
|
console.warn('当前环境不支持 document.fonts !');
|
||||||
console.warn('当前环境不支持 iconfont !');
|
console.warn('当前环境不支持 iconfont !');
|
||||||
console.warn(e);
|
console.warn(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
|
||||||
document.getElementsByTagName('head')[0].appendChild(style);
|
document.getElementsByTagName('head')[0].appendChild(style);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public destroy(): void {
|
public destroy(): void {
|
||||||
this.cache.clear();
|
this.cache.clear();
|
||||||
|
@ -220,7 +216,9 @@ export default class FontService extends EventEmitter implements IFontService {
|
||||||
canvas = $window.document.createElement('canvas');
|
canvas = $window.document.createElement('canvas');
|
||||||
canvas.width = MAX_CANVAS_WIDTH;
|
canvas.width = MAX_CANVAS_WIDTH;
|
||||||
}
|
}
|
||||||
const ctx = canvas.getContext('2d', { willReadFrequently: true }) as CanvasRenderingContext2D;
|
const ctx = canvas.getContext('2d', {
|
||||||
|
willReadFrequently: true,
|
||||||
|
}) as CanvasRenderingContext2D;
|
||||||
setTextStyle(ctx, fontFamily, fontSize, fontWeight);
|
setTextStyle(ctx, fontFamily, fontSize, fontWeight);
|
||||||
|
|
||||||
// 1. build mapping
|
// 1. build mapping
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
import { IColorRamp } from '@antv/l7-utils';
|
import { IColorRamp } from '@antv/l7-utils';
|
||||||
import { ITexture2D } from '../renderer/ITexture2D';
|
import { ITexture2D } from '../renderer/ITexture2D';
|
||||||
export interface ITextureService {
|
export interface ITextureService {
|
||||||
setColorTexture(texture: ITexture2D,colorRamp: IColorRamp,domain?:[number,number]):void;
|
setColorTexture(
|
||||||
getColorTexture(colorRamp: IColorRamp, domain?:[number,number]): ITexture2D
|
texture: ITexture2D,
|
||||||
|
colorRamp: IColorRamp,
|
||||||
|
domain?: [number, number],
|
||||||
|
): void;
|
||||||
|
getColorTexture(colorRamp: IColorRamp, domain?: [number, number]): ITexture2D;
|
||||||
destroy(): void;
|
destroy(): void;
|
||||||
|
|
||||||
}
|
}
|
|
@ -125,17 +125,17 @@ export default class CameraService implements ICameraService {
|
||||||
public jitterProjectionMatrix(x: number, y: number) {
|
public jitterProjectionMatrix(x: number, y: number) {
|
||||||
const translation = mat4.fromTranslation(mat4.create(), [x, y, 0]);
|
const translation = mat4.fromTranslation(mat4.create(), [x, y, 0]);
|
||||||
|
|
||||||
this.jitteredProjectionMatrix = (mat4.multiply(
|
this.jitteredProjectionMatrix = mat4.multiply(
|
||||||
mat4.create(),
|
mat4.create(),
|
||||||
translation,
|
translation,
|
||||||
(this.viewport.getProjectionMatrix() as unknown) as mat4,
|
this.viewport.getProjectionMatrix() as unknown as mat4,
|
||||||
) as unknown) as number[];
|
) as unknown as number[];
|
||||||
|
|
||||||
this.jitteredViewProjectionMatrix = (mat4.multiply(
|
this.jitteredViewProjectionMatrix = mat4.multiply(
|
||||||
mat4.create(),
|
mat4.create(),
|
||||||
(this.jitteredProjectionMatrix as unknown) as mat4,
|
this.jitteredProjectionMatrix as unknown as mat4,
|
||||||
(this.viewport.getViewMatrix() as unknown) as mat4,
|
this.viewport.getViewMatrix() as unknown as mat4,
|
||||||
) as unknown) as number[];
|
) as unknown as number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearJitterProjectionMatrix() {
|
public clearJitterProjectionMatrix() {
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
import { injectable } from 'inversify';
|
import { injectable } from 'inversify';
|
||||||
import { merge } from 'lodash';
|
import { merge } from 'lodash';
|
||||||
import 'reflect-metadata';
|
import 'reflect-metadata';
|
||||||
import { ILayerConfig,ILayerAttributesOption} from '../layer/ILayerService';
|
import { ILayerAttributesOption, ILayerConfig } from '../layer/ILayerService';
|
||||||
import { IRenderConfig } from '../renderer/IRendererService';
|
import { IRenderConfig } from '../renderer/IRendererService';
|
||||||
import { IGlobalConfigService, ISceneConfig, } from './IConfigService';
|
import { IGlobalConfigService, ISceneConfig } from './IConfigService';
|
||||||
import WarnInfo from './warnInfo';
|
import WarnInfo from './warnInfo';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -119,13 +119,12 @@ export default class GlobalConfigService implements IGlobalConfigService {
|
||||||
[layerId: string]: Partial<ILayerConfig & ISceneConfig>;
|
[layerId: string]: Partial<ILayerConfig & ISceneConfig>;
|
||||||
} = {};
|
} = {};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据映射缓存
|
* 数据映射缓存
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private layerAttributeConfigCache: {
|
private layerAttributeConfigCache: {
|
||||||
[layerId: string]: Partial<ILayerAttributesOption>
|
[layerId: string]: Partial<ILayerAttributesOption>;
|
||||||
} = {};
|
} = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -176,17 +175,19 @@ export default class GlobalConfigService implements IGlobalConfigService {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public getAttributeConfig(layerId: string,): Partial<ILayerAttributesOption> {
|
public getAttributeConfig(layerId: string): Partial<ILayerAttributesOption> {
|
||||||
return this.layerAttributeConfigCache[layerId]
|
return this.layerAttributeConfigCache[layerId];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public setAttributeConfig(layerId: string, attr: Partial<ILayerAttributesOption>) {
|
public setAttributeConfig(
|
||||||
|
layerId: string,
|
||||||
|
attr: Partial<ILayerAttributesOption>,
|
||||||
|
) {
|
||||||
// TODO
|
// TODO
|
||||||
this.layerAttributeConfigCache[layerId] = {
|
this.layerAttributeConfigCache[layerId] = {
|
||||||
...this.layerAttributeConfigCache[layerId],
|
...this.layerAttributeConfigCache[layerId],
|
||||||
...attr
|
...attr,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public clean() {
|
public clean() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// import Ajv from 'ajv';
|
// import Ajv from 'ajv';
|
||||||
import { PositionName } from '../component/IControlService';
|
import { PositionName } from '../component/IControlService';
|
||||||
import { ILayerConfig,ILayerAttributesOption } from '../layer/ILayerService';
|
import { ILayerAttributesOption, ILayerConfig } from '../layer/ILayerService';
|
||||||
import { IMapWrapper } from '../map/IMapService';
|
import { IMapWrapper } from '../map/IMapService';
|
||||||
import { IRenderConfig } from '../renderer/IRendererService';
|
import { IRenderConfig } from '../renderer/IRendererService';
|
||||||
export interface ISceneConfig extends IRenderConfig {
|
export interface ISceneConfig extends IRenderConfig {
|
||||||
|
@ -67,14 +67,17 @@ export interface IGlobalConfigService {
|
||||||
/**
|
/**
|
||||||
* 获取数据映射
|
* 获取数据映射
|
||||||
*/
|
*/
|
||||||
getAttributeConfig(layerId: string,): Partial<ILayerAttributesOption>
|
getAttributeConfig(layerId: string): Partial<ILayerAttributesOption>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置数据映射
|
* 设置数据映射
|
||||||
* @param layerId sh
|
* @param layerId sh
|
||||||
* @param attr
|
* @param attr
|
||||||
*/
|
*/
|
||||||
setAttributeConfig(layerId: string, attr: Partial<ILayerAttributesOption>):void
|
setAttributeConfig(
|
||||||
|
layerId: string,
|
||||||
|
attr: Partial<ILayerAttributesOption>,
|
||||||
|
): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清除场景和图层配置项 Cache,但是需要保留校验器
|
* 清除场景和图层配置项 Cache,但是需要保留校验器
|
||||||
|
|
|
@ -14,7 +14,8 @@ const VECTOR_TO_POINT_MATRIX = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0];
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export default class CoordinateSystemService
|
export default class CoordinateSystemService
|
||||||
implements ICoordinateSystemService {
|
implements ICoordinateSystemService
|
||||||
|
{
|
||||||
public needRefresh: boolean = true;
|
public needRefresh: boolean = true;
|
||||||
@inject(TYPES.ICameraService)
|
@inject(TYPES.ICameraService)
|
||||||
private readonly cameraService: ICameraService;
|
private readonly cameraService: ICameraService;
|
||||||
|
@ -152,9 +153,9 @@ export default class CoordinateSystemService
|
||||||
let viewMatrix = this.cameraService.getViewMatrix();
|
let viewMatrix = this.cameraService.getViewMatrix();
|
||||||
const projectionMatrix = this.cameraService.getProjectionMatrix();
|
const projectionMatrix = this.cameraService.getProjectionMatrix();
|
||||||
let viewProjectionMatrix = mat4.multiply(
|
let viewProjectionMatrix = mat4.multiply(
|
||||||
([] as unknown) as mat4,
|
[] as unknown as mat4,
|
||||||
(projectionMatrix as unknown) as mat4,
|
projectionMatrix as unknown as mat4,
|
||||||
(viewMatrix as unknown) as mat4,
|
viewMatrix as unknown as mat4,
|
||||||
);
|
);
|
||||||
|
|
||||||
// 经纬度投影到 Web 墨卡托坐标系
|
// 经纬度投影到 Web 墨卡托坐标系
|
||||||
|
@ -164,30 +165,30 @@ export default class CoordinateSystemService
|
||||||
);
|
);
|
||||||
|
|
||||||
// Web 墨卡托坐标系通过 VP 矩阵变换到世界坐标系
|
// Web 墨卡托坐标系通过 VP 矩阵变换到世界坐标系
|
||||||
this.viewportCenterProjection = (vec4.transformMat4(
|
this.viewportCenterProjection = vec4.transformMat4(
|
||||||
([] as unknown) as vec4,
|
[] as unknown as vec4,
|
||||||
[positionPixels[0], positionPixels[1], 0.0, 1.0],
|
[positionPixels[0], positionPixels[1], 0.0, 1.0],
|
||||||
(viewProjectionMatrix as unknown) as mat4,
|
viewProjectionMatrix as unknown as mat4,
|
||||||
) as unknown) as [number, number, number, number];
|
) as unknown as [number, number, number, number];
|
||||||
|
|
||||||
// Always apply uncentered projection matrix if available (shader adds center)
|
// Always apply uncentered projection matrix if available (shader adds center)
|
||||||
viewMatrix = this.cameraService.getViewMatrixUncentered() || viewMatrix;
|
viewMatrix = this.cameraService.getViewMatrixUncentered() || viewMatrix;
|
||||||
|
|
||||||
// Zero out 4th coordinate ("after" model matrix) - avoids further translations
|
// Zero out 4th coordinate ("after" model matrix) - avoids further translations
|
||||||
viewProjectionMatrix = mat4.multiply(
|
viewProjectionMatrix = mat4.multiply(
|
||||||
([] as unknown) as mat4,
|
[] as unknown as mat4,
|
||||||
(projectionMatrix as unknown) as mat4,
|
projectionMatrix as unknown as mat4,
|
||||||
(viewMatrix as unknown) as mat4,
|
viewMatrix as unknown as mat4,
|
||||||
);
|
);
|
||||||
viewProjectionMatrix = mat4.multiply(
|
viewProjectionMatrix = mat4.multiply(
|
||||||
([] as unknown) as mat4,
|
[] as unknown as mat4,
|
||||||
viewProjectionMatrix,
|
viewProjectionMatrix,
|
||||||
(VECTOR_TO_POINT_MATRIX as unknown) as mat4,
|
VECTOR_TO_POINT_MATRIX as unknown as mat4,
|
||||||
);
|
);
|
||||||
|
|
||||||
// 重新计算相机 VP 矩阵
|
// 重新计算相机 VP 矩阵
|
||||||
this.cameraService.setViewProjectionMatrix(
|
this.cameraService.setViewProjectionMatrix(
|
||||||
(viewProjectionMatrix as unknown) as number[],
|
viewProjectionMatrix as unknown as number[],
|
||||||
);
|
);
|
||||||
|
|
||||||
this.pixelsPerMeter = ppm;
|
this.pixelsPerMeter = ppm;
|
||||||
|
|
|
@ -79,23 +79,23 @@ export default class DebugService
|
||||||
this.renderEnable = enable;
|
this.renderEnable = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public renderStart(guid: string) {
|
public renderStart(id: string) {
|
||||||
if (!this.renderEnable || !this.enable) {
|
if (!this.renderEnable || !this.enable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const cacheRenderInfo = this.renderMap.get(guid) || {};
|
const cacheRenderInfo = this.renderMap.get(id) || {};
|
||||||
this.renderMap.set(guid, {
|
this.renderMap.set(id, {
|
||||||
...cacheRenderInfo,
|
...cacheRenderInfo,
|
||||||
renderUid: guid,
|
renderUid: id,
|
||||||
renderStart: Date.now(),
|
renderStart: Date.now(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public renderEnd(guid: string) {
|
public renderEnd(id: string) {
|
||||||
if (!this.renderEnable || !this.enable) {
|
if (!this.renderEnable || !this.enable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const cacheRenderInfo = this.renderMap.get(guid);
|
const cacheRenderInfo = this.renderMap.get(id);
|
||||||
if (cacheRenderInfo) {
|
if (cacheRenderInfo) {
|
||||||
const renderStart = cacheRenderInfo.renderStart as number;
|
const renderStart = cacheRenderInfo.renderStart as number;
|
||||||
const renderEnd = Date.now();
|
const renderEnd = Date.now();
|
||||||
|
@ -104,7 +104,7 @@ export default class DebugService
|
||||||
renderEnd,
|
renderEnd,
|
||||||
renderDuration: renderEnd - renderStart,
|
renderDuration: renderEnd - renderStart,
|
||||||
});
|
});
|
||||||
this.renderMap.delete(guid);
|
this.renderMap.delete(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@ export interface IPickingService {
|
||||||
init(id: string): void;
|
init(id: string): void;
|
||||||
pickFromPickingFBO(layer: ILayer, target: IInteractionTarget): boolean;
|
pickFromPickingFBO(layer: ILayer, target: IInteractionTarget): boolean;
|
||||||
pickBox(layer: ILayer, box: [number, number, number, number]): any[];
|
pickBox(layer: ILayer, box: [number, number, number, number]): any[];
|
||||||
triggerHoverOnLayer(layer: ILayer,
|
triggerHoverOnLayer(
|
||||||
|
layer: ILayer,
|
||||||
target: {
|
target: {
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
|
@ -15,7 +16,8 @@ export interface IPickingService {
|
||||||
lngLat: ILngLat;
|
lngLat: ILngLat;
|
||||||
feature?: unknown;
|
feature?: unknown;
|
||||||
featureId?: number | null;
|
featureId?: number | null;
|
||||||
}): void;
|
},
|
||||||
|
): void;
|
||||||
|
|
||||||
boxPickLayer(
|
boxPickLayer(
|
||||||
layer: ILayer,
|
layer: ILayer,
|
||||||
|
@ -26,7 +28,11 @@ export interface IPickingService {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ILayerPickService {
|
export interface ILayerPickService {
|
||||||
pickRasterLayer(layer: ILayer, target: IInteractionTarget, parent?: ILayer): boolean;
|
pickRasterLayer(
|
||||||
|
layer: ILayer,
|
||||||
|
target: IInteractionTarget,
|
||||||
|
parent?: ILayer,
|
||||||
|
): boolean;
|
||||||
pick(layer: ILayer, target: IInteractionTarget): boolean;
|
pick(layer: ILayer, target: IInteractionTarget): boolean;
|
||||||
/**
|
/**
|
||||||
* 绘制拾取图层
|
* 绘制拾取图层
|
||||||
|
@ -37,19 +43,17 @@ export interface ILayerPickService {
|
||||||
* 为图层设置选中对象
|
* 为图层设置选中对象
|
||||||
* @param pickedColors
|
* @param pickedColors
|
||||||
*/
|
*/
|
||||||
selectFeature(pickedColors: Uint8Array | undefined):void
|
selectFeature(pickedColors: Uint8Array | undefined): void;
|
||||||
/**
|
/**
|
||||||
* 为图层设置active对象
|
* 为图层设置active对象
|
||||||
* @param pickedColors
|
* @param pickedColors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
highlightPickedFeature(pickedColors: Uint8Array | undefined):void
|
highlightPickedFeature(pickedColors: Uint8Array | undefined): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取选中的要素
|
* 获取选中的要素
|
||||||
* @param id q
|
* @param id q
|
||||||
*/
|
*/
|
||||||
getFeatureById(id: number, lngLat?: ILngLat):any
|
getFeatureById(id: number, lngLat?: ILngLat): any;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,8 +18,10 @@ const DragEventMap: { [key: string]: string } = {
|
||||||
* 除此之外,后续如果支持非地图场景,事件监听就需要注册在 L7 canvas 上。
|
* 除此之外,后续如果支持非地图场景,事件监听就需要注册在 L7 canvas 上。
|
||||||
*/
|
*/
|
||||||
@injectable()
|
@injectable()
|
||||||
export default class InteractionService extends EventEmitter
|
export default class InteractionService
|
||||||
implements IInteractionService {
|
extends EventEmitter
|
||||||
|
implements IInteractionService
|
||||||
|
{
|
||||||
public indragging: boolean = false;
|
public indragging: boolean = false;
|
||||||
@inject(TYPES.IMapService)
|
@inject(TYPES.IMapService)
|
||||||
private readonly mapService: IMapService;
|
private readonly mapService: IMapService;
|
||||||
|
|
|
@ -303,8 +303,9 @@ export default class PickingService implements IPickingService {
|
||||||
}
|
}
|
||||||
private async pickingAllLayer(target: IInteractionTarget) {
|
private async pickingAllLayer(target: IInteractionTarget) {
|
||||||
// 判断是否进行拾取操作
|
// 判断是否进行拾取操作
|
||||||
if (!this.layerService.needPick(target.type) || !this.isPickingAllLayer())
|
if (!this.layerService.needPick(target.type) || !this.isPickingAllLayer()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
this.alreadyInPicking = true;
|
this.alreadyInPicking = true;
|
||||||
await this.pickingLayers(target);
|
await this.pickingLayers(target);
|
||||||
this.layerService.renderLayers();
|
this.layerService.renderLayers();
|
||||||
|
@ -313,13 +314,21 @@ export default class PickingService implements IPickingService {
|
||||||
|
|
||||||
private isPickingAllLayer() {
|
private isPickingAllLayer() {
|
||||||
// this.alreadyInPicking 避免多次重复拾取
|
// this.alreadyInPicking 避免多次重复拾取
|
||||||
if (this.alreadyInPicking) { return false; }
|
if (this.alreadyInPicking) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// this.layerService.alreadyInRendering 一个渲染序列中只进行一次拾取操作
|
// this.layerService.alreadyInRendering 一个渲染序列中只进行一次拾取操作
|
||||||
if (this.layerService.alreadyInRendering) { return false; }
|
if (this.layerService.alreadyInRendering) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// this.interactionService.dragging amap2 在点击操作的时候同时会触发 dragging 的情况(避免舍去)
|
// this.interactionService.dragging amap2 在点击操作的时候同时会触发 dragging 的情况(避免舍去)
|
||||||
if (this.interactionService.indragging) { return false; }
|
if (this.interactionService.indragging) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// 判断当前进行 shader pick 拾取判断
|
// 判断当前进行 shader pick 拾取判断
|
||||||
if (!this.layerService.getShaderPickStat()) { return false; }
|
if (!this.layerService.getShaderPickStat()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// 进行拾取
|
// 进行拾取
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,12 +1,20 @@
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { SyncBailHook, SyncHook, AsyncSeriesBailHook, AsyncWaterfallHook} from '@antv/async-hook';
|
import {
|
||||||
|
AsyncSeriesBailHook,
|
||||||
|
AsyncWaterfallHook,
|
||||||
|
SyncBailHook,
|
||||||
|
SyncHook,
|
||||||
|
} from '@antv/async-hook';
|
||||||
import { IColorRamp, SourceTile, TilesetManager } from '@antv/l7-utils';
|
import { IColorRamp, SourceTile, TilesetManager } from '@antv/l7-utils';
|
||||||
import { Container } from 'inversify';
|
import { Container } from 'inversify';
|
||||||
import Clock from '../../utils/clock';
|
import Clock from '../../utils/clock';
|
||||||
import { ITextureService } from '../asset/ITextureService';
|
import { ITextureService } from '../asset/ITextureService';
|
||||||
import { ISceneConfig } from '../config/IConfigService';
|
import { ISceneConfig } from '../config/IConfigService';
|
||||||
import { IInteractionTarget } from '../interaction/IInteractionService';
|
import { IInteractionTarget } from '../interaction/IInteractionService';
|
||||||
import { ILayerPickService, IPickingService } from '../interaction/IPickingService';
|
import {
|
||||||
|
ILayerPickService,
|
||||||
|
IPickingService,
|
||||||
|
} from '../interaction/IPickingService';
|
||||||
import { IMapService } from '../map/IMapService';
|
import { IMapService } from '../map/IMapService';
|
||||||
import { IAttribute } from '../renderer/IAttribute';
|
import { IAttribute } from '../renderer/IAttribute';
|
||||||
import {
|
import {
|
||||||
|
@ -22,7 +30,12 @@ import {
|
||||||
import { IRendererService } from '../renderer/IRendererService';
|
import { IRendererService } from '../renderer/IRendererService';
|
||||||
import { ITexture2D } from '../renderer/ITexture2D';
|
import { ITexture2D } from '../renderer/ITexture2D';
|
||||||
import { IUniform } from '../renderer/IUniform';
|
import { IUniform } from '../renderer/IUniform';
|
||||||
import { ISource, ISourceCFG, ITransform, IParseDataItem } from '../source/ISourceService';
|
import {
|
||||||
|
IParseDataItem,
|
||||||
|
ISource,
|
||||||
|
ISourceCFG,
|
||||||
|
ITransform,
|
||||||
|
} from '../source/ISourceService';
|
||||||
import {
|
import {
|
||||||
IAnimateOption,
|
IAnimateOption,
|
||||||
IEncodeFeature,
|
IEncodeFeature,
|
||||||
|
@ -80,7 +93,7 @@ export interface ILayerModel {
|
||||||
getAnimateUniforms(): IModelUniform;
|
getAnimateUniforms(): IModelUniform;
|
||||||
buildModels(): Promise<IModel[]>;
|
buildModels(): Promise<IModel[]>;
|
||||||
initModels(): Promise<IModel[]>;
|
initModels(): Promise<IModel[]>;
|
||||||
needUpdate():Promise<boolean>
|
needUpdate(): Promise<boolean>;
|
||||||
clearModels(refresh?: boolean): void;
|
clearModels(refresh?: boolean): void;
|
||||||
|
|
||||||
// canvasLayer
|
// canvasLayer
|
||||||
|
@ -92,13 +105,13 @@ export interface ILayerModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ILayerAttributesOption {
|
export interface ILayerAttributesOption {
|
||||||
shape: IAttrbuteOptions,
|
shape: IAttrbuteOptions;
|
||||||
color: IAttrbuteOptions,
|
color: IAttrbuteOptions;
|
||||||
texture:IAttrbuteOptions,
|
texture: IAttrbuteOptions;
|
||||||
rotate:IAttrbuteOptions,
|
rotate: IAttrbuteOptions;
|
||||||
size:IAttrbuteOptions,
|
size: IAttrbuteOptions;
|
||||||
filter:IAttrbuteOptions,
|
filter: IAttrbuteOptions;
|
||||||
label:IAttrbuteOptions,
|
label: IAttrbuteOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IModelUniform {
|
export interface IModelUniform {
|
||||||
|
@ -120,9 +133,9 @@ export interface IActiveOption {
|
||||||
type ILngLat = [number, number];
|
type ILngLat = [number, number];
|
||||||
|
|
||||||
export interface ILegend {
|
export interface ILegend {
|
||||||
type: ScaleTypeName | undefined
|
type: ScaleTypeName | undefined;
|
||||||
field: StyleAttributeField | undefined;
|
field: StyleAttributeField | undefined;
|
||||||
items:LegendItems
|
items: LegendItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 分段图例
|
// 分段图例
|
||||||
|
@ -149,8 +162,8 @@ export interface ISubLayerStyles {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IAttrbuteOptions {
|
export interface IAttrbuteOptions {
|
||||||
field: StyleAttrField,
|
field: StyleAttrField;
|
||||||
values:StyleAttributeOption
|
values: StyleAttributeOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,7 +173,7 @@ export interface ISubLayerInitOptions {
|
||||||
usage?: string | undefined;
|
usage?: string | undefined;
|
||||||
layerType: string;
|
layerType: string;
|
||||||
transforms?: ITransform[];
|
transforms?: ITransform[];
|
||||||
visible: boolean,
|
visible: boolean;
|
||||||
shape?: string | string[] | IScaleValue;
|
shape?: string | string[] | IScaleValue;
|
||||||
// options
|
// options
|
||||||
zIndex: number;
|
zIndex: number;
|
||||||
|
@ -203,7 +216,7 @@ export interface IBaseTileLayerManager {
|
||||||
parent: ILayer;
|
parent: ILayer;
|
||||||
children: ILayer[];
|
children: ILayer[];
|
||||||
|
|
||||||
addTile(tile: SourceTile):Promise<{ layers: ILayer[]; }>;
|
addTile(tile: SourceTile): Promise<{ layers: ILayer[] }>;
|
||||||
|
|
||||||
addChild(layer: ILayer): void;
|
addChild(layer: ILayer): void;
|
||||||
addChildren(layers: ILayer[]): void;
|
addChildren(layers: ILayer[]): void;
|
||||||
|
@ -232,10 +245,7 @@ export interface ITile {
|
||||||
getFeatureById(id: number): any;
|
getFeatureById(id: number): any;
|
||||||
styleUpdate(...args: any): void;
|
styleUpdate(...args: any): void;
|
||||||
initTileLayer(): Promise<void>;
|
initTileLayer(): Promise<void>;
|
||||||
lnglatInBounds(lnglat: {
|
lnglatInBounds(lnglat: { lng: number; lat: number }): boolean;
|
||||||
lng: number;
|
|
||||||
lat: number;
|
|
||||||
}): boolean;
|
|
||||||
updateVisible(value: boolean): void;
|
updateVisible(value: boolean): void;
|
||||||
updateOptions(key: string, value: any): void;
|
updateOptions(key: string, value: any): void;
|
||||||
destroy(): void;
|
destroy(): void;
|
||||||
|
@ -304,7 +314,7 @@ export type LayerEventType =
|
||||||
| any;
|
| any;
|
||||||
|
|
||||||
export interface ILayer {
|
export interface ILayer {
|
||||||
styleAttributeService: IStyleAttributeService,
|
styleAttributeService: IStyleAttributeService;
|
||||||
layerPickService: ILayerPickService;
|
layerPickService: ILayerPickService;
|
||||||
textureService: ITextureService;
|
textureService: ITextureService;
|
||||||
sourceLayer?: string;
|
sourceLayer?: string;
|
||||||
|
@ -314,7 +324,7 @@ export interface ILayer {
|
||||||
coordCenter: number[];
|
coordCenter: number[];
|
||||||
name: string; //
|
name: string; //
|
||||||
inited: boolean; // 是否初始化完成
|
inited: boolean; // 是否初始化完成
|
||||||
startInit: boolean // 是否开始初始化;
|
startInit: boolean; // 是否开始初始化;
|
||||||
zIndex: number;
|
zIndex: number;
|
||||||
clusterZoom: number;
|
clusterZoom: number;
|
||||||
plugins: ILayerPlugin[];
|
plugins: ILayerPlugin[];
|
||||||
|
@ -327,9 +337,9 @@ export interface ILayer {
|
||||||
sceneContainer: Container | undefined;
|
sceneContainer: Container | undefined;
|
||||||
dataState: IDataState; // 数据流状态
|
dataState: IDataState; // 数据流状态
|
||||||
defaultSourceConfig: {
|
defaultSourceConfig: {
|
||||||
data: any[],
|
data: any[];
|
||||||
options: ISourceCFG | undefined,
|
options: ISourceCFG | undefined;
|
||||||
},
|
};
|
||||||
encodeDataLength: number;
|
encodeDataLength: number;
|
||||||
pickedFeatureID: number | null;
|
pickedFeatureID: number | null;
|
||||||
hooks: {
|
hooks: {
|
||||||
|
@ -367,9 +377,7 @@ export interface ILayer {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
threeRenderService?: any;
|
threeRenderService?: any;
|
||||||
postProcessingPassFactory: (
|
postProcessingPassFactory: (name: string) => IPostProcessingPass<unknown>;
|
||||||
name: string,
|
|
||||||
) => IPostProcessingPass<unknown>;
|
|
||||||
normalPassFactory: (name: string) => IPass<unknown>;
|
normalPassFactory: (name: string) => IPass<unknown>;
|
||||||
getShaderPickStat: () => boolean;
|
getShaderPickStat: () => boolean;
|
||||||
updateModelData(data: IAttributeAndElements): void;
|
updateModelData(data: IAttributeAndElements): void;
|
||||||
|
@ -379,7 +387,7 @@ export interface ILayer {
|
||||||
needPick(type: string): boolean;
|
needPick(type: string): boolean;
|
||||||
getAttribute(name: string): IStyleAttribute | undefined;
|
getAttribute(name: string): IStyleAttribute | undefined;
|
||||||
getLayerConfig<T>(): Partial<ILayerConfig & ISceneConfig & T>;
|
getLayerConfig<T>(): Partial<ILayerConfig & ISceneConfig & T>;
|
||||||
getLayerAttributeConfig():Partial<ILayerAttributesOption>
|
getLayerAttributeConfig(): Partial<ILayerAttributesOption>;
|
||||||
getContainer(): Container;
|
getContainer(): Container;
|
||||||
setContainer(container: Container, sceneContainer: Container): void;
|
setContainer(container: Container, sceneContainer: Container): void;
|
||||||
setCurrentPickId(id: number | null): void;
|
setCurrentPickId(id: number | null): void;
|
||||||
|
@ -684,7 +692,7 @@ export interface ILayerService {
|
||||||
reRender(): void;
|
reRender(): void;
|
||||||
beforeRenderData(layer: ILayer): Promise<void>;
|
beforeRenderData(layer: ILayer): Promise<void>;
|
||||||
renderMask(masks: ILayer[]): void;
|
renderMask(masks: ILayer[]): void;
|
||||||
renderLayer(layer: ILayer): Promise<void>
|
renderLayer(layer: ILayer): Promise<void>;
|
||||||
needPick(type: string): boolean;
|
needPick(type: string): boolean;
|
||||||
throttleRenderLayers(): void;
|
throttleRenderLayers(): void;
|
||||||
renderLayers(): void;
|
renderLayers(): void;
|
||||||
|
|
|
@ -227,7 +227,7 @@ export interface IStyleAttributeService {
|
||||||
features: IEncodeFeature[],
|
features: IEncodeFeature[],
|
||||||
startFeatureIdx?: number,
|
startFeatureIdx?: number,
|
||||||
endFeatureIdx?: number,
|
endFeatureIdx?: number,
|
||||||
layer?: ILayer
|
layer?: ILayer,
|
||||||
): void;
|
): void;
|
||||||
/**
|
/**
|
||||||
* 清除当前管理的所有属性
|
* 清除当前管理的所有属性
|
||||||
|
|
|
@ -9,8 +9,8 @@ import { IRendererService } from '../renderer/IRendererService';
|
||||||
import { ILayer, IWorkerOption } from './ILayerService';
|
import { ILayer, IWorkerOption } from './ILayerService';
|
||||||
import {
|
import {
|
||||||
IAttributeScale,
|
IAttributeScale,
|
||||||
IScaleOptions,
|
|
||||||
IEncodeFeature,
|
IEncodeFeature,
|
||||||
|
IScaleOptions,
|
||||||
IStyleAttribute,
|
IStyleAttribute,
|
||||||
IStyleAttributeInitializationOptions,
|
IStyleAttributeInitializationOptions,
|
||||||
IStyleAttributeService,
|
IStyleAttributeService,
|
||||||
|
@ -75,13 +75,13 @@ export default class StyleAttributeService implements IStyleAttributeService {
|
||||||
this.attributes.forEach((attr: IStyleAttribute) => {
|
this.attributes.forEach((attr: IStyleAttribute) => {
|
||||||
const name = attr.name;
|
const name = attr.name;
|
||||||
const field = attr.scale?.field as string;
|
const field = attr.scale?.field as string;
|
||||||
if(scaleOption[name] || (field && scaleOption[field])) { // 字段类型和映射类型
|
if (scaleOption[name] || (field && scaleOption[field])) {
|
||||||
|
// 字段类型和映射类型
|
||||||
attr.needRescale = true;
|
attr.needRescale = true;
|
||||||
attr.needRemapping = true;
|
attr.needRemapping = true;
|
||||||
attr.needRegenerateVertices = true;
|
attr.needRegenerateVertices = true;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateStyleAttribute(
|
public updateStyleAttribute(
|
||||||
|
@ -136,7 +136,7 @@ export default class StyleAttributeService implements IStyleAttributeService {
|
||||||
features: IEncodeFeature[],
|
features: IEncodeFeature[],
|
||||||
startFeatureIdx: number = 0,
|
startFeatureIdx: number = 0,
|
||||||
endFeatureIdx?: number,
|
endFeatureIdx?: number,
|
||||||
layer?:ILayer
|
layer?: ILayer,
|
||||||
) {
|
) {
|
||||||
const attributeToUpdate = this.attributes.find(
|
const attributeToUpdate = this.attributes.find(
|
||||||
(attribute) => attribute.name === attributeName,
|
(attribute) => attribute.name === attributeName,
|
||||||
|
@ -167,8 +167,8 @@ export default class StyleAttributeService implements IStyleAttributeService {
|
||||||
vertexIdx++
|
vertexIdx++
|
||||||
) {
|
) {
|
||||||
const normal = normals
|
const normal = normals
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
? normals!.slice(vertexIdx * 3, vertexIdx * 3 + 3)
|
normals!.slice(vertexIdx * 3, vertexIdx * 3 + 3)
|
||||||
: [];
|
: [];
|
||||||
featureData.push(
|
featureData.push(
|
||||||
...update(
|
...update(
|
||||||
|
@ -198,8 +198,8 @@ export default class StyleAttributeService implements IStyleAttributeService {
|
||||||
// size color 触发更新事件
|
// size color 触发更新事件
|
||||||
layer?.emit(`legend:${attributeName}`, {
|
layer?.emit(`legend:${attributeName}`, {
|
||||||
type: attributeName,
|
type: attributeName,
|
||||||
attr:attributeToUpdate
|
attr: attributeToUpdate,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,11 +223,8 @@ export default class StyleAttributeService implements IStyleAttributeService {
|
||||||
.filter((d) => d);
|
.filter((d) => d);
|
||||||
const { modelType, ...restOptions } = workerOptions;
|
const { modelType, ...restOptions } = workerOptions;
|
||||||
|
|
||||||
const {
|
const { createAttribute, createBuffer, createElements } =
|
||||||
createAttribute,
|
this.rendererService;
|
||||||
createBuffer,
|
|
||||||
createElements,
|
|
||||||
} = this.rendererService;
|
|
||||||
const attributes: {
|
const attributes: {
|
||||||
[attributeName: string]: IAttribute;
|
[attributeName: string]: IAttribute;
|
||||||
} = {};
|
} = {};
|
||||||
|
@ -379,11 +376,8 @@ export default class StyleAttributeService implements IStyleAttributeService {
|
||||||
}); // end for each
|
}); // end for each
|
||||||
} // end for
|
} // end for
|
||||||
}); // end features for Each
|
}); // end features for Each
|
||||||
const {
|
const { createAttribute, createBuffer, createElements } =
|
||||||
createAttribute,
|
this.rendererService;
|
||||||
createBuffer,
|
|
||||||
createElements,
|
|
||||||
} = this.rendererService;
|
|
||||||
|
|
||||||
const attributes: {
|
const attributes: {
|
||||||
[attributeName: string]: IAttribute;
|
[attributeName: string]: IAttribute;
|
||||||
|
|
|
@ -14,7 +14,8 @@ import { IRendererService } from '../IRendererService';
|
||||||
*/
|
*/
|
||||||
@injectable()
|
@injectable()
|
||||||
export default class BaseNormalPass<InitializationOptions = {}>
|
export default class BaseNormalPass<InitializationOptions = {}>
|
||||||
implements IPass<InitializationOptions> {
|
implements IPass<InitializationOptions>
|
||||||
|
{
|
||||||
// @inject(TYPES.IShaderModuleService)
|
// @inject(TYPES.IShaderModuleService)
|
||||||
protected shaderModuleService: IShaderModuleService;
|
protected shaderModuleService: IShaderModuleService;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,8 @@ import { IUniform } from '../IUniform';
|
||||||
*/
|
*/
|
||||||
@injectable()
|
@injectable()
|
||||||
export default class BasePostProcessingPass<InitializationOptions = {}>
|
export default class BasePostProcessingPass<InitializationOptions = {}>
|
||||||
implements IPostProcessingPass<InitializationOptions> {
|
implements IPostProcessingPass<InitializationOptions>
|
||||||
|
{
|
||||||
@inject(TYPES.IShaderModuleService)
|
@inject(TYPES.IShaderModuleService)
|
||||||
protected shaderModuleService: IShaderModuleService;
|
protected shaderModuleService: IShaderModuleService;
|
||||||
|
|
||||||
|
@ -166,9 +167,7 @@ export default class BasePostProcessingPass<InitializationOptions = {}>
|
||||||
throw new Error('Method not implemented.');
|
throw new Error('Method not implemented.');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected convertOptionsToUniforms(
|
protected convertOptionsToUniforms(options: Partial<InitializationOptions>): {
|
||||||
options: Partial<InitializationOptions>,
|
|
||||||
): {
|
|
||||||
[uniformName: string]: IUniform;
|
[uniformName: string]: IUniform;
|
||||||
} | void {
|
} | void {
|
||||||
const uniforms: {
|
const uniforms: {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import BaseNormalPass from './BaseNormalPass';
|
||||||
*/
|
*/
|
||||||
@injectable()
|
@injectable()
|
||||||
export default class ClearPass<
|
export default class ClearPass<
|
||||||
InitializationOptions = {}
|
InitializationOptions = {},
|
||||||
> extends BaseNormalPass<InitializationOptions> {
|
> extends BaseNormalPass<InitializationOptions> {
|
||||||
public getName() {
|
public getName() {
|
||||||
return 'clear';
|
return 'clear';
|
||||||
|
|
|
@ -18,7 +18,7 @@ import BaseNormalPass from './BaseNormalPass';
|
||||||
*/
|
*/
|
||||||
@injectable()
|
@injectable()
|
||||||
export default class PixelPickingPass<
|
export default class PixelPickingPass<
|
||||||
InitializationOptions = {}
|
InitializationOptions = {},
|
||||||
> extends BaseNormalPass<InitializationOptions> {
|
> extends BaseNormalPass<InitializationOptions> {
|
||||||
/**
|
/**
|
||||||
* picking framebuffer,供 attributes 颜色编码后输出
|
* picking framebuffer,供 attributes 颜色编码后输出
|
||||||
|
@ -50,11 +50,8 @@ export default class PixelPickingPass<
|
||||||
public init(layer: ILayer, config?: Partial<InitializationOptions>) {
|
public init(layer: ILayer, config?: Partial<InitializationOptions>) {
|
||||||
super.init(layer, config);
|
super.init(layer, config);
|
||||||
this.layer = layer;
|
this.layer = layer;
|
||||||
const {
|
const { createTexture2D, createFramebuffer, getViewportSize } =
|
||||||
createTexture2D,
|
this.rendererService;
|
||||||
createFramebuffer,
|
|
||||||
getViewportSize,
|
|
||||||
} = this.rendererService;
|
|
||||||
const { width, height } = getViewportSize();
|
const { width, height } = getViewportSize();
|
||||||
// 创建 picking framebuffer,后续实时 resize
|
// 创建 picking framebuffer,后续实时 resize
|
||||||
this.pickingFBO = createFramebuffer({
|
this.pickingFBO = createFramebuffer({
|
||||||
|
@ -129,11 +126,8 @@ export default class PixelPickingPass<
|
||||||
if (!this.layer.isVisible() || !this.layer.needPick(type)) {
|
if (!this.layer.isVisible() || !this.layer.needPick(type)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const {
|
const { getViewportSize, readPixels, useFramebuffer } =
|
||||||
getViewportSize,
|
this.rendererService;
|
||||||
readPixels,
|
|
||||||
useFramebuffer,
|
|
||||||
} = this.rendererService;
|
|
||||||
const { width, height } = getViewportSize();
|
const { width, height } = getViewportSize();
|
||||||
const { enableHighlight, enableSelect } = this.layer.getLayerConfig();
|
const { enableHighlight, enableSelect } = this.layer.getLayerConfig();
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import BaseNormalPass from './BaseNormalPass';
|
||||||
*/
|
*/
|
||||||
@injectable()
|
@injectable()
|
||||||
export default class RenderPass<
|
export default class RenderPass<
|
||||||
InitializationOptions = {}
|
InitializationOptions = {},
|
||||||
> extends BaseNormalPass<InitializationOptions> {
|
> extends BaseNormalPass<InitializationOptions> {
|
||||||
public getType() {
|
public getType() {
|
||||||
return PassType.Normal;
|
return PassType.Normal;
|
||||||
|
|
|
@ -37,9 +37,9 @@ let accumulatingId = 1;
|
||||||
* @see https://yuque.antfin-inc.com/yuqi.pyq/fgetpa/ri52hv
|
* @see https://yuque.antfin-inc.com/yuqi.pyq/fgetpa/ri52hv
|
||||||
*/
|
*/
|
||||||
@injectable()
|
@injectable()
|
||||||
export default class TAAPass<InitializationOptions = {}> extends BaseNormalPass<
|
export default class TAAPass<
|
||||||
InitializationOptions
|
InitializationOptions = {},
|
||||||
> {
|
> extends BaseNormalPass<InitializationOptions> {
|
||||||
@inject(TYPES.IShaderModuleService)
|
@inject(TYPES.IShaderModuleService)
|
||||||
protected readonly shaderModuleService: IShaderModuleService;
|
protected readonly shaderModuleService: IShaderModuleService;
|
||||||
|
|
||||||
|
@ -305,9 +305,8 @@ export default class TAAPass<InitializationOptions = {}> extends BaseNormalPass<
|
||||||
fs: fragmentShader,
|
fs: fragmentShader,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { vs, fs, uniforms } = this.shaderModuleService.getModule(
|
const { vs, fs, uniforms } =
|
||||||
shaderModuleName,
|
this.shaderModuleService.getModule(shaderModuleName);
|
||||||
);
|
|
||||||
const { createAttribute, createBuffer, createModel } = this.rendererService;
|
const { createAttribute, createBuffer, createModel } = this.rendererService;
|
||||||
return createModel({
|
return createModel({
|
||||||
vs,
|
vs,
|
||||||
|
|
|
@ -13,18 +13,15 @@ export interface IBloomPassConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export default class BloomPass extends BasePostProcessingPass<
|
export default class BloomPass extends BasePostProcessingPass<IBloomPassConfig> {
|
||||||
IBloomPassConfig
|
|
||||||
> {
|
|
||||||
protected setupShaders() {
|
protected setupShaders() {
|
||||||
this.shaderModuleService.registerModule('blur-pass', {
|
this.shaderModuleService.registerModule('blur-pass', {
|
||||||
vs: quad,
|
vs: quad,
|
||||||
fs: blur,
|
fs: blur,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { vs, fs, uniforms } = this.shaderModuleService.getModule(
|
const { vs, fs, uniforms } =
|
||||||
'blur-pass',
|
this.shaderModuleService.getModule('blur-pass');
|
||||||
);
|
|
||||||
const { width, height } = this.rendererService.getViewportSize();
|
const { width, height } = this.rendererService.getViewportSize();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -37,9 +34,7 @@ export default class BloomPass extends BasePostProcessingPass<
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected convertOptionsToUniforms(
|
protected convertOptionsToUniforms(options: Partial<IBloomPassConfig>): {
|
||||||
options: Partial<IBloomPassConfig>,
|
|
||||||
): {
|
|
||||||
[uniformName: string]: IUniform;
|
[uniformName: string]: IUniform;
|
||||||
} | void {
|
} | void {
|
||||||
const uniforms: {
|
const uniforms: {
|
||||||
|
|
|
@ -11,18 +11,15 @@ export interface IBlurHPassConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export default class BlurHPass extends BasePostProcessingPass<
|
export default class BlurHPass extends BasePostProcessingPass<IBlurHPassConfig> {
|
||||||
IBlurHPassConfig
|
|
||||||
> {
|
|
||||||
protected setupShaders() {
|
protected setupShaders() {
|
||||||
this.shaderModuleService.registerModule('blur-pass', {
|
this.shaderModuleService.registerModule('blur-pass', {
|
||||||
vs: quad,
|
vs: quad,
|
||||||
fs: blur,
|
fs: blur,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { vs, fs, uniforms } = this.shaderModuleService.getModule(
|
const { vs, fs, uniforms } =
|
||||||
'blur-pass',
|
this.shaderModuleService.getModule('blur-pass');
|
||||||
);
|
|
||||||
const { width, height } = this.rendererService.getViewportSize();
|
const { width, height } = this.rendererService.getViewportSize();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -35,9 +32,7 @@ export default class BlurHPass extends BasePostProcessingPass<
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected convertOptionsToUniforms(
|
protected convertOptionsToUniforms(options: Partial<IBlurHPassConfig>): {
|
||||||
options: Partial<IBlurHPassConfig>,
|
|
||||||
): {
|
|
||||||
[uniformName: string]: IUniform;
|
[uniformName: string]: IUniform;
|
||||||
} | void {
|
} | void {
|
||||||
const uniforms: {
|
const uniforms: {
|
||||||
|
|
|
@ -10,18 +10,15 @@ export interface IBlurVPassConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export default class BlurVPass extends BasePostProcessingPass<
|
export default class BlurVPass extends BasePostProcessingPass<IBlurVPassConfig> {
|
||||||
IBlurVPassConfig
|
|
||||||
> {
|
|
||||||
public setupShaders() {
|
public setupShaders() {
|
||||||
this.shaderModuleService.registerModule('blur-pass', {
|
this.shaderModuleService.registerModule('blur-pass', {
|
||||||
vs: quad,
|
vs: quad,
|
||||||
fs: blur,
|
fs: blur,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { vs, fs, uniforms } = this.shaderModuleService.getModule(
|
const { vs, fs, uniforms } =
|
||||||
'blur-pass',
|
this.shaderModuleService.getModule('blur-pass');
|
||||||
);
|
|
||||||
const { width, height } = this.rendererService.getViewportSize();
|
const { width, height } = this.rendererService.getViewportSize();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -34,9 +31,7 @@ export default class BlurVPass extends BasePostProcessingPass<
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected convertOptionsToUniforms(
|
protected convertOptionsToUniforms(options: Partial<IBlurVPassConfig>): {
|
||||||
options: Partial<IBlurVPassConfig>,
|
|
||||||
): {
|
|
||||||
[uniformName: string]: IUniform;
|
[uniformName: string]: IUniform;
|
||||||
} | void {
|
} | void {
|
||||||
const uniforms: {
|
const uniforms: {
|
||||||
|
|
|
@ -11,18 +11,15 @@ export interface IColorHalftonePassConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export default class ColorHalftonePass extends BasePostProcessingPass<
|
export default class ColorHalftonePass extends BasePostProcessingPass<IColorHalftonePassConfig> {
|
||||||
IColorHalftonePassConfig
|
|
||||||
> {
|
|
||||||
protected setupShaders() {
|
protected setupShaders() {
|
||||||
this.shaderModuleService.registerModule('colorhalftone-pass', {
|
this.shaderModuleService.registerModule('colorhalftone-pass', {
|
||||||
vs: quad,
|
vs: quad,
|
||||||
fs: colorHalftone,
|
fs: colorHalftone,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { vs, fs, uniforms } = this.shaderModuleService.getModule(
|
const { vs, fs, uniforms } =
|
||||||
'colorhalftone-pass',
|
this.shaderModuleService.getModule('colorhalftone-pass');
|
||||||
);
|
|
||||||
const { width, height } = this.rendererService.getViewportSize();
|
const { width, height } = this.rendererService.getViewportSize();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -10,9 +10,7 @@ export interface IHexagonalPixelatePassConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export default class HexagonalPixelatePass extends BasePostProcessingPass<
|
export default class HexagonalPixelatePass extends BasePostProcessingPass<IHexagonalPixelatePassConfig> {
|
||||||
IHexagonalPixelatePassConfig
|
|
||||||
> {
|
|
||||||
protected setupShaders() {
|
protected setupShaders() {
|
||||||
this.shaderModuleService.registerModule('hexagonalpixelate-pass', {
|
this.shaderModuleService.registerModule('hexagonalpixelate-pass', {
|
||||||
vs: quad,
|
vs: quad,
|
||||||
|
|
|
@ -9,9 +9,7 @@ export interface INoisePassConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export default class NoisePass extends BasePostProcessingPass<
|
export default class NoisePass extends BasePostProcessingPass<INoisePassConfig> {
|
||||||
INoisePassConfig
|
|
||||||
> {
|
|
||||||
public setupShaders() {
|
public setupShaders() {
|
||||||
this.shaderModuleService.registerModule('noise-pass', {
|
this.shaderModuleService.registerModule('noise-pass', {
|
||||||
vs: quad,
|
vs: quad,
|
||||||
|
|
|
@ -9,9 +9,7 @@ export interface ISepiaPassConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export default class SepiaPass extends BasePostProcessingPass<
|
export default class SepiaPass extends BasePostProcessingPass<ISepiaPassConfig> {
|
||||||
ISepiaPassConfig
|
|
||||||
> {
|
|
||||||
public setupShaders() {
|
public setupShaders() {
|
||||||
this.shaderModuleService.registerModule('sepia-pass', {
|
this.shaderModuleService.registerModule('sepia-pass', {
|
||||||
vs: quad,
|
vs: quad,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
import EventEmitter from 'eventemitter3';
|
||||||
import { ISceneConfig } from '../config/IConfigService';
|
import { ISceneConfig } from '../config/IConfigService';
|
||||||
import { ILayer } from '../layer/ILayerService';
|
import { ILayer } from '../layer/ILayerService';
|
||||||
import EventEmitter from 'eventemitter3';
|
|
||||||
|
|
||||||
export interface ISceneService extends EventEmitter {
|
export interface ISceneService extends EventEmitter {
|
||||||
destroyed: boolean;
|
destroyed: boolean;
|
||||||
|
|
|
@ -15,6 +15,7 @@ import { IMarkerService } from '../component/IMarkerService';
|
||||||
import { IPopupService } from '../component/IPopupService';
|
import { IPopupService } from '../component/IPopupService';
|
||||||
import { IGlobalConfigService, ISceneConfig } from '../config/IConfigService';
|
import { IGlobalConfigService, ISceneConfig } from '../config/IConfigService';
|
||||||
import { ICoordinateSystemService } from '../coordinate/ICoordinateSystemService';
|
import { ICoordinateSystemService } from '../coordinate/ICoordinateSystemService';
|
||||||
|
import { IDebugService } from '../debug/IDebugService';
|
||||||
import {
|
import {
|
||||||
IInteractionService,
|
IInteractionService,
|
||||||
IInteractionTarget,
|
IInteractionTarget,
|
||||||
|
@ -26,7 +27,6 @@ import { IMapService } from '../map/IMapService';
|
||||||
import { IRenderConfig, IRendererService } from '../renderer/IRendererService';
|
import { IRenderConfig, IRendererService } from '../renderer/IRendererService';
|
||||||
import { IShaderModuleService } from '../shader/IShaderModuleService';
|
import { IShaderModuleService } from '../shader/IShaderModuleService';
|
||||||
import { ISceneService } from './ISceneService';
|
import { ISceneService } from './ISceneService';
|
||||||
import { IDebugService } from '../debug/IDebugService';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* will emit `loaded` `resize` `destroy` event panstart panmove panend
|
* will emit `loaded` `resize` `destroy` event panstart panmove panend
|
||||||
|
@ -139,15 +139,14 @@ export default class Scene extends EventEmitter implements ISceneService {
|
||||||
*/
|
*/
|
||||||
this.hooks.init.tapPromise('initMap', async () => {
|
this.hooks.init.tapPromise('initMap', async () => {
|
||||||
this.debugService.log('map.mapInitStart', {
|
this.debugService.log('map.mapInitStart', {
|
||||||
type: this.map.version
|
type: this.map.version,
|
||||||
})
|
});
|
||||||
// 等待首次相机同步
|
// 等待首次相机同步
|
||||||
await new Promise<void>((resolve) => {
|
await new Promise<void>((resolve) => {
|
||||||
this.map.onCameraChanged((viewport: IViewport) => {
|
this.map.onCameraChanged((viewport: IViewport) => {
|
||||||
this.cameraService.init();
|
this.cameraService.init();
|
||||||
this.cameraService.update(viewport);
|
this.cameraService.update(viewport);
|
||||||
resolve();
|
resolve();
|
||||||
|
|
||||||
});
|
});
|
||||||
this.map.init();
|
this.map.init();
|
||||||
});
|
});
|
||||||
|
@ -219,7 +218,9 @@ export default class Scene extends EventEmitter implements ISceneService {
|
||||||
private registerContextLost() {
|
private registerContextLost() {
|
||||||
const canvas = this.rendererService.getCanvas();
|
const canvas = this.rendererService.getCanvas();
|
||||||
if (canvas) {
|
if (canvas) {
|
||||||
canvas.addEventListener('webglcontextlost', () => this.emit('webglcontextlost'));
|
canvas.addEventListener('webglcontextlost', () =>
|
||||||
|
this.emit('webglcontextlost'),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,7 +402,6 @@ export default class Scene extends EventEmitter implements ISceneService {
|
||||||
?.removeListener(this.handleWindowResized);
|
?.removeListener(this.handleWindowResized);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this.pickingService.destroy();
|
this.pickingService.destroy();
|
||||||
this.layerService.destroy();
|
this.layerService.destroy();
|
||||||
|
|
||||||
|
@ -413,8 +413,6 @@ export default class Scene extends EventEmitter implements ISceneService {
|
||||||
this.fontService.destroy();
|
this.fontService.destroy();
|
||||||
this.iconService.destroy();
|
this.iconService.destroy();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.removeAllListeners();
|
this.removeAllListeners();
|
||||||
this.inited = false;
|
this.inited = false;
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,10 @@ export interface ITileParserCFG {
|
||||||
minZoom?: number;
|
minZoom?: number;
|
||||||
maxZoom?: number;
|
maxZoom?: number;
|
||||||
zoomOffset?: number;
|
zoomOffset?: number;
|
||||||
getCustomData: (tile: { x: number, y: number, z: number },cb:(err:any,data:any)=>void)=>void,
|
getCustomData: (
|
||||||
|
tile: { x: number; y: number; z: number },
|
||||||
|
cb: (err: any, data: any) => void,
|
||||||
|
) => void;
|
||||||
extent?: [number, number, number, number];
|
extent?: [number, number, number, number];
|
||||||
requestParameters: Partial<RequestParameters>;
|
requestParameters: Partial<RequestParameters>;
|
||||||
updateStrategy?: 'overlap' | 'replace';
|
updateStrategy?: 'overlap' | 'replace';
|
||||||
|
@ -50,9 +53,12 @@ export interface ITileParserCFG {
|
||||||
operation?: any;
|
operation?: any;
|
||||||
|
|
||||||
// 用户自定义请求url
|
// 用户自定义请求url
|
||||||
getURLFromTemplate?: (template: string, properties: { x: number; y: number; z: number }) => string;
|
getURLFromTemplate?: (
|
||||||
|
template: string,
|
||||||
|
properties: { x: number; y: number; z: number },
|
||||||
|
) => string;
|
||||||
// 用户自定义处理返回数据回调
|
// 用户自定义处理返回数据回调
|
||||||
transformResponse?: (response: Object) => any;
|
transformResponse?: (response: object) => any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IWMTSServiceOption {
|
export interface IWMTSServiceOption {
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import Source from '@antv/l7-source';
|
import Source from '@antv/l7-source';
|
||||||
|
|
||||||
export * from '@antv/l7-core';
|
|
||||||
export * from '@antv/l7-scene';
|
|
||||||
export * from '@antv/l7-maps';
|
|
||||||
export * from '@antv/l7-layers';
|
|
||||||
export * from '@antv/l7-component';
|
export * from '@antv/l7-component';
|
||||||
|
export * from '@antv/l7-core';
|
||||||
|
export * from '@antv/l7-layers';
|
||||||
|
export * from '@antv/l7-maps';
|
||||||
|
export * from '@antv/l7-scene';
|
||||||
export * from '@antv/l7-utils';
|
export * from '@antv/l7-utils';
|
||||||
export * from './version';
|
export * from './version';
|
||||||
|
|
||||||
export { Source };
|
export { Source };
|
||||||
|
|
|
@ -59,7 +59,8 @@
|
||||||
"@types/d3-scale": "^2.1.1",
|
"@types/d3-scale": "^2.1.1",
|
||||||
"@types/earcut": "^2.1.0",
|
"@types/earcut": "^2.1.0",
|
||||||
"@types/gl-matrix": "^2.4.5",
|
"@types/gl-matrix": "^2.4.5",
|
||||||
"@types/lodash": "^4.14.138"
|
"@types/lodash": "^4.14.138",
|
||||||
|
"@antv/l7-test-utils":"^2.13.4"
|
||||||
},
|
},
|
||||||
"gitHead": "684ba4eb806a798713496d3fc0b4d1e17517dc31",
|
"gitHead": "684ba4eb806a798713496d3fc0b4d1e17517dc31",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
|
|
|
@ -17,9 +17,8 @@ export default class BillBoardModel extends BaseModel {
|
||||||
private radian: number = 0; // 旋转的弧度
|
private radian: number = 0; // 旋转的弧度
|
||||||
|
|
||||||
public planeGeometryTriangulation = () => {
|
public planeGeometryTriangulation = () => {
|
||||||
const {
|
const { center = [120, 30] } =
|
||||||
center = [120, 30],
|
this.layer.getLayerConfig() as IGeometryLayerStyleOptions;
|
||||||
} = this.layer.getLayerConfig() as IGeometryLayerStyleOptions;
|
|
||||||
return {
|
return {
|
||||||
size: 4,
|
size: 4,
|
||||||
indices: [0, 1, 2, 2, 3, 0],
|
indices: [0, 1, 2, 2, 3, 0],
|
||||||
|
@ -98,8 +97,7 @@ export default class BillBoardModel extends BaseModel {
|
||||||
this.updateTexture(drawCanvas);
|
this.updateTexture(drawCanvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'geometryBillboard',
|
moduleName: 'geometryBillboard',
|
||||||
vertexShader: planeVert,
|
vertexShader: planeVert,
|
||||||
fragmentShader: planeFrag,
|
fragmentShader: planeFrag,
|
||||||
|
@ -108,21 +106,19 @@ export default class BillBoardModel extends BaseModel {
|
||||||
depth: { enable: true },
|
depth: { enable: true },
|
||||||
blend: this.getBlend(),
|
blend: this.getBlend(),
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
return await this.initModels();
|
return this.initModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateTexture(drawCanvas: (canvas: HTMLCanvasElement) => void): void {
|
public updateTexture(drawCanvas: (canvas: HTMLCanvasElement) => void): void {
|
||||||
const { createTexture2D } = this.rendererService;
|
const { createTexture2D } = this.rendererService;
|
||||||
|
|
||||||
const {
|
const { canvasWidth = 1, canvasHeight = 1 } =
|
||||||
canvasWidth = 1,
|
this.layer.getLayerConfig() as IGeometryLayerStyleOptions;
|
||||||
canvasHeight = 1,
|
|
||||||
} = this.layer.getLayerConfig() as IGeometryLayerStyleOptions;
|
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
canvas.width = canvasWidth;
|
canvas.width = canvasWidth;
|
||||||
canvas.height = canvasHeight;
|
canvas.height = canvasHeight;
|
||||||
|
|
|
@ -151,8 +151,7 @@ export default class PlaneModel extends BaseModel {
|
||||||
|
|
||||||
this.updateTexture(mapTexture);
|
this.updateTexture(mapTexture);
|
||||||
|
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'geometryPlane',
|
moduleName: 'geometryPlane',
|
||||||
vertexShader: planeVert,
|
vertexShader: planeVert,
|
||||||
fragmentShader: planeFrag,
|
fragmentShader: planeFrag,
|
||||||
|
@ -165,12 +164,12 @@ export default class PlaneModel extends BaseModel {
|
||||||
enable: true,
|
enable: true,
|
||||||
face: gl.BACK, // gl.FRONT | gl.BACK;
|
face: gl.BACK, // gl.FRONT | gl.BACK;
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
return await this.initModels();
|
return this.initModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public createModelData(options?: any) {
|
public createModelData(options?: any) {
|
||||||
|
@ -181,12 +180,8 @@ export default class PlaneModel extends BaseModel {
|
||||||
width: oldwidth,
|
width: oldwidth,
|
||||||
height: oldheight,
|
height: oldheight,
|
||||||
} = this.layer.getLayerConfig() as IGeometryLayerStyleOptions;
|
} = this.layer.getLayerConfig() as IGeometryLayerStyleOptions;
|
||||||
const {
|
const { widthSegments, heightSegments, width, height } =
|
||||||
widthSegments,
|
options as IGeometryLayerStyleOptions;
|
||||||
heightSegments,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
} = options as IGeometryLayerStyleOptions;
|
|
||||||
this.layer.style({
|
this.layer.style({
|
||||||
widthSegments:
|
widthSegments:
|
||||||
widthSegments !== undefined ? widthSegments : oldwidthSegments,
|
widthSegments !== undefined ? widthSegments : oldwidthSegments,
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
import {
|
import { gl, IModel, IModelUniform, ITexture2D } from '@antv/l7-core';
|
||||||
gl,
|
|
||||||
IModel,
|
|
||||||
IModelUniform,
|
|
||||||
ITexture2D,
|
|
||||||
} from '@antv/l7-core';
|
|
||||||
import { Version } from '@antv/l7-maps';
|
import { Version } from '@antv/l7-maps';
|
||||||
|
|
||||||
import BaseModel from '../../core/BaseModel';
|
import BaseModel from '../../core/BaseModel';
|
||||||
|
@ -63,9 +58,8 @@ export default class SpriteModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public planeGeometryUpdateTriangulation = () => {
|
public planeGeometryUpdateTriangulation = () => {
|
||||||
const {
|
const { spriteBottom = -100000 } =
|
||||||
spriteBottom = -100000,
|
this.layer.getLayerConfig() as IGeometryLayerStyleOptions;
|
||||||
} = this.layer.getLayerConfig() as IGeometryLayerStyleOptions;
|
|
||||||
const updateZ = this.spriteUpdate;
|
const updateZ = this.spriteUpdate;
|
||||||
const bottomZ = spriteBottom;
|
const bottomZ = spriteBottom;
|
||||||
const topZ = this.spriteTop;
|
const topZ = this.spriteTop;
|
||||||
|
@ -175,8 +169,7 @@ export default class SpriteModel extends BaseModel {
|
||||||
this.updateModel();
|
this.updateModel();
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'geometrySprite',
|
moduleName: 'geometrySprite',
|
||||||
vertexShader: spriteVert,
|
vertexShader: spriteVert,
|
||||||
fragmentShader: spriteFrag,
|
fragmentShader: spriteFrag,
|
||||||
|
@ -184,12 +177,12 @@ export default class SpriteModel extends BaseModel {
|
||||||
primitive: gl.POINTS,
|
primitive: gl.POINTS,
|
||||||
depth: { enable: false },
|
depth: { enable: false },
|
||||||
blend: this.getBlend(),
|
blend: this.getBlend(),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
return await this.initModels();
|
return this.initModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateTexture(mapTexture: string | undefined): void {
|
public updateTexture(mapTexture: string | undefined): void {
|
||||||
|
|
|
@ -61,9 +61,8 @@ export default class CanvaModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initModels() {
|
public async initModels() {
|
||||||
const {
|
const { update = CanvasUpdateType.ALWAYS } =
|
||||||
update = CanvasUpdateType.ALWAYS,
|
this.layer.getLayerConfig() as ICanvasLayerStyleOptions;
|
||||||
} = this.layer.getLayerConfig() as ICanvasLayerStyleOptions;
|
|
||||||
this.updateMode = update as CanvasUpdateType;
|
this.updateMode = update as CanvasUpdateType;
|
||||||
this.initCanvas();
|
this.initCanvas();
|
||||||
|
|
||||||
|
@ -79,10 +78,8 @@ export default class CanvaModel extends BaseModel {
|
||||||
const { zIndex } = this.layer.getLayerConfig() as ICanvasLayerStyleOptions;
|
const { zIndex } = this.layer.getLayerConfig() as ICanvasLayerStyleOptions;
|
||||||
const size = this.mapService.getSize();
|
const size = this.mapService.getSize();
|
||||||
const [width, height] = size;
|
const [width, height] = size;
|
||||||
const {
|
const { width: viewWidth, height: viewHeight } =
|
||||||
width: viewWidth,
|
this.rendererService.getViewportSize();
|
||||||
height: viewHeight,
|
|
||||||
} = this.rendererService.getViewportSize();
|
|
||||||
this.prevSize = [viewWidth, viewHeight];
|
this.prevSize = [viewWidth, viewHeight];
|
||||||
|
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
|
@ -110,10 +107,8 @@ export default class CanvaModel extends BaseModel {
|
||||||
};
|
};
|
||||||
|
|
||||||
public renderCanvas = () => {
|
public renderCanvas = () => {
|
||||||
const {
|
const { width: viewWidth, height: viewHeight } =
|
||||||
width: viewWidth,
|
this.rendererService.getViewportSize();
|
||||||
height: viewHeight,
|
|
||||||
} = this.rendererService.getViewportSize();
|
|
||||||
if (this.prevSize[0] !== viewWidth || this.prevSize[1] !== viewHeight) {
|
if (this.prevSize[0] !== viewWidth || this.prevSize[1] !== viewHeight) {
|
||||||
this.prevSize = [viewWidth, viewHeight];
|
this.prevSize = [viewWidth, viewHeight];
|
||||||
const size = this.mapService.getSize();
|
const size = this.mapService.getSize();
|
||||||
|
@ -124,9 +119,8 @@ export default class CanvaModel extends BaseModel {
|
||||||
this.canvas.style.height = height + 'px';
|
this.canvas.style.height = height + 'px';
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const { drawingOnCanvas } =
|
||||||
drawingOnCanvas,
|
this.layer.getLayerConfig() as ICanvasLayerStyleOptions;
|
||||||
} = this.layer.getLayerConfig() as ICanvasLayerStyleOptions;
|
|
||||||
|
|
||||||
if (this.ctx) {
|
if (this.ctx) {
|
||||||
drawingOnCanvas({
|
drawingOnCanvas({
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { AttributeType, gl, IEncodeFeature, IModel } from '@antv/l7-core';
|
import { AttributeType, gl, IEncodeFeature, IModel } from '@antv/l7-core';
|
||||||
import { rgb2arr } from '@antv/l7-utils';
|
import { rgb2arr } from '@antv/l7-utils';
|
||||||
import BaseModel from '../../core/BaseModel';
|
import BaseModel from '../../core/BaseModel';
|
||||||
|
import { ICityBuildLayerStyleOptions } from '../../core/interface';
|
||||||
import { PolygonExtrudeTriangulation } from '../../core/triangulation';
|
import { PolygonExtrudeTriangulation } from '../../core/triangulation';
|
||||||
import buildFrag from '../shaders/build_frag.glsl';
|
import buildFrag from '../shaders/build_frag.glsl';
|
||||||
import buildVert from '../shaders/build_vert.glsl';
|
import buildVert from '../shaders/build_vert.glsl';
|
||||||
import { ICityBuildLayerStyleOptions } from '../../core/interface';
|
|
||||||
export default class CityBuildModel extends BaseModel {
|
export default class CityBuildModel extends BaseModel {
|
||||||
private cityCenter: [number, number];
|
private cityCenter: [number, number];
|
||||||
private cityMinSize: number;
|
private cityMinSize: number;
|
||||||
|
@ -67,12 +67,11 @@ export default class CityBuildModel extends BaseModel {
|
||||||
|
|
||||||
this.startModelAnimate();
|
this.startModelAnimate();
|
||||||
|
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'cityBuilding',
|
moduleName: 'cityBuilding',
|
||||||
vertexShader: buildVert,
|
vertexShader: buildVert,
|
||||||
fragmentShader: buildFrag,
|
fragmentShader: buildFrag,
|
||||||
|
@ -82,8 +81,8 @@ export default class CityBuildModel extends BaseModel {
|
||||||
enable: true,
|
enable: true,
|
||||||
face: gl.BACK,
|
face: gl.BACK,
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected registerBuiltinAttributes() {
|
protected registerBuiltinAttributes() {
|
||||||
|
@ -124,9 +123,7 @@ export default class CityBuildModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 1,
|
size: 1,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const { size = 10 } = feature;
|
const { size = 10 } = feature;
|
||||||
return Array.isArray(size) ? [size[0]] : [size as number];
|
return Array.isArray(size) ? [size[0]] : [size as number];
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,16 +17,15 @@ interface IAtmoSphereLayerStyleOptions {
|
||||||
|
|
||||||
export default class EarthAtomSphereModel extends BaseModel {
|
export default class EarthAtomSphereModel extends BaseModel {
|
||||||
public getUninforms(): IModelUniform {
|
public getUninforms(): IModelUniform {
|
||||||
const {
|
const { opacity = 1 } =
|
||||||
opacity = 1,
|
this.layer.getLayerConfig() as IAtmoSphereLayerStyleOptions;
|
||||||
} = this.layer.getLayerConfig() as IAtmoSphereLayerStyleOptions;
|
|
||||||
return {
|
return {
|
||||||
u_opacity: isNumber(opacity) ? opacity : 1.0,
|
u_opacity: isNumber(opacity) ? opacity : 1.0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels() {
|
public clearModels() {
|
||||||
|
@ -36,16 +35,15 @@ export default class EarthAtomSphereModel extends BaseModel {
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
// TODO: 调整图层的绘制顺序 地球大气层
|
// TODO: 调整图层的绘制顺序 地球大气层
|
||||||
this.layer.zIndex = -997;
|
this.layer.zIndex = -997;
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'earthAtmoSphere',
|
moduleName: 'earthAtmoSphere',
|
||||||
vertexShader: atmoSphereVert,
|
vertexShader: atmoSphereVert,
|
||||||
fragmentShader: atmoSphereFrag,
|
fragmentShader: atmoSphereFrag,
|
||||||
triangulation: earthTriangulation,
|
triangulation: earthTriangulation,
|
||||||
depth: { enable: false },
|
depth: { enable: false },
|
||||||
blend: this.getBlend(),
|
blend: this.getBlend(),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected registerBuiltinAttributes() {
|
protected registerBuiltinAttributes() {
|
||||||
|
@ -61,9 +59,7 @@ export default class EarthAtomSphereModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 1,
|
size: 1,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const { size = 1 } = feature;
|
const { size = 1 } = feature;
|
||||||
return Array.isArray(size) ? [size[0]] : [size as number];
|
return Array.isArray(size) ? [size[0]] : [size as number];
|
||||||
},
|
},
|
||||||
|
|
|
@ -80,7 +80,7 @@ export default class BaseEarthModel extends BaseModel {
|
||||||
this.layerService.reRender();
|
this.layerService.reRender();
|
||||||
});
|
});
|
||||||
|
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels() {
|
public clearModels() {
|
||||||
|
@ -91,16 +91,15 @@ export default class BaseEarthModel extends BaseModel {
|
||||||
// Tip: 调整图层的绘制顺序 地球大气层
|
// Tip: 调整图层的绘制顺序 地球大气层
|
||||||
this.layer.zIndex = -998;
|
this.layer.zIndex = -998;
|
||||||
|
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'earthBase',
|
moduleName: 'earthBase',
|
||||||
vertexShader: baseVert,
|
vertexShader: baseVert,
|
||||||
fragmentShader: baseFrag,
|
fragmentShader: baseFrag,
|
||||||
triangulation: earthTriangulation,
|
triangulation: earthTriangulation,
|
||||||
depth: { enable: true },
|
depth: { enable: true },
|
||||||
blend: this.getBlend(),
|
blend: this.getBlend(),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected registerBuiltinAttributes() {
|
protected registerBuiltinAttributes() {
|
||||||
|
@ -115,9 +114,7 @@ export default class BaseEarthModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 1,
|
size: 1,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const { size = 1 } = feature;
|
const { size = 1 } = feature;
|
||||||
return Array.isArray(size) ? [size[0]] : [size as number];
|
return Array.isArray(size) ? [size[0]] : [size as number];
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,16 +17,15 @@ interface IBloomLayerStyleOptions {
|
||||||
|
|
||||||
export default class EarthBloomSphereModel extends BaseModel {
|
export default class EarthBloomSphereModel extends BaseModel {
|
||||||
public getUninforms(): IModelUniform {
|
public getUninforms(): IModelUniform {
|
||||||
const {
|
const { opacity = 1 } =
|
||||||
opacity = 1,
|
this.layer.getLayerConfig() as IBloomLayerStyleOptions;
|
||||||
} = this.layer.getLayerConfig() as IBloomLayerStyleOptions;
|
|
||||||
return {
|
return {
|
||||||
u_opacity: isNumber(opacity) ? opacity : 1.0,
|
u_opacity: isNumber(opacity) ? opacity : 1.0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels() {
|
public clearModels() {
|
||||||
|
@ -36,16 +35,15 @@ export default class EarthBloomSphereModel extends BaseModel {
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
// Tip: 调整图层的绘制顺序,让它保持在地球后面(减少锯齿现象)
|
// Tip: 调整图层的绘制顺序,让它保持在地球后面(减少锯齿现象)
|
||||||
this.layer.zIndex = -999;
|
this.layer.zIndex = -999;
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'earthBloom',
|
moduleName: 'earthBloom',
|
||||||
vertexShader: bloomSphereVert,
|
vertexShader: bloomSphereVert,
|
||||||
fragmentShader: bloomSphereFrag,
|
fragmentShader: bloomSphereFrag,
|
||||||
triangulation: earthOuterTriangulation,
|
triangulation: earthOuterTriangulation,
|
||||||
depth: { enable: false },
|
depth: { enable: false },
|
||||||
blend: this.getBlend(),
|
blend: this.getBlend(),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected registerBuiltinAttributes() {
|
protected registerBuiltinAttributes() {
|
||||||
|
@ -60,9 +58,7 @@ export default class EarthBloomSphereModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 1,
|
size: 1,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const { size = 1 } = feature;
|
const { size = 1 } = feature;
|
||||||
return Array.isArray(size) ? [size[0]] : [size as number];
|
return Array.isArray(size) ? [size[0]] : [size as number];
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,11 +13,8 @@ import heatmapGridVert from '../shaders/grid_vert.glsl';
|
||||||
import heatmapGridFrag from '../shaders/hexagon_frag.glsl';
|
import heatmapGridFrag from '../shaders/hexagon_frag.glsl';
|
||||||
export default class GridModel extends BaseModel {
|
export default class GridModel extends BaseModel {
|
||||||
public getUninforms(): IModelUniform {
|
public getUninforms(): IModelUniform {
|
||||||
const {
|
const { opacity, coverage, angle } =
|
||||||
opacity,
|
this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
||||||
coverage,
|
|
||||||
angle,
|
|
||||||
} = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
|
||||||
return {
|
return {
|
||||||
u_opacity: opacity || 1.0,
|
u_opacity: opacity || 1.0,
|
||||||
u_coverage: coverage || 0.9,
|
u_coverage: coverage || 0.9,
|
||||||
|
@ -30,16 +27,13 @@ export default class GridModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
const {
|
const { mask = false, maskInside = true } =
|
||||||
mask = false,
|
this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
||||||
maskInside = true,
|
const model = await this.layer.buildLayerModel({
|
||||||
} = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
|
||||||
const model = await this.layer
|
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'heatmapGrid',
|
moduleName: 'heatmapGrid',
|
||||||
vertexShader: heatmapGridVert,
|
vertexShader: heatmapGridVert,
|
||||||
fragmentShader: heatmapGridFrag,
|
fragmentShader: heatmapGridFrag,
|
||||||
|
@ -47,8 +41,8 @@ export default class GridModel extends BaseModel {
|
||||||
primitive: gl.TRIANGLES,
|
primitive: gl.TRIANGLES,
|
||||||
depth: { enable: false },
|
depth: { enable: false },
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
protected registerBuiltinAttributes() {
|
protected registerBuiltinAttributes() {
|
||||||
this.styleAttributeService.registerStyleAttribute({
|
this.styleAttributeService.registerStyleAttribute({
|
||||||
|
@ -63,9 +57,11 @@ export default class GridModel extends BaseModel {
|
||||||
},
|
},
|
||||||
size: 3,
|
size: 3,
|
||||||
update: (feature: IEncodeFeature) => {
|
update: (feature: IEncodeFeature) => {
|
||||||
const coordinates = (feature.version === 'GAODE2.x'
|
const coordinates = (
|
||||||
|
feature.version === 'GAODE2.x'
|
||||||
? feature.originCoordinates
|
? feature.originCoordinates
|
||||||
: feature.coordinates) as number[];
|
: feature.coordinates
|
||||||
|
) as number[];
|
||||||
return [coordinates[0], coordinates[1], 0];
|
return [coordinates[0], coordinates[1], 0];
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,11 +13,8 @@ import heatmapGrid3dVert from '../shaders/hexagon_3d_vert.glsl';
|
||||||
import heatmapGridFrag from '../shaders/hexagon_frag.glsl';
|
import heatmapGridFrag from '../shaders/hexagon_frag.glsl';
|
||||||
export default class Grid3DModel extends BaseModel {
|
export default class Grid3DModel extends BaseModel {
|
||||||
public getUninforms(): IModelUniform {
|
public getUninforms(): IModelUniform {
|
||||||
const {
|
const { opacity, coverage, angle } =
|
||||||
opacity,
|
this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
||||||
coverage,
|
|
||||||
angle,
|
|
||||||
} = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
|
||||||
return {
|
return {
|
||||||
u_opacity: opacity || 1.0,
|
u_opacity: opacity || 1.0,
|
||||||
u_coverage: coverage || 1.0,
|
u_coverage: coverage || 1.0,
|
||||||
|
@ -30,16 +27,13 @@ export default class Grid3DModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
const {
|
const { mask = false, maskInside = true } =
|
||||||
mask = false,
|
this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
||||||
maskInside = true,
|
const model = await this.layer.buildLayerModel({
|
||||||
} = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
|
||||||
const model = await this.layer
|
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'heatmapGrid3d',
|
moduleName: 'heatmapGrid3d',
|
||||||
vertexShader: heatmapGrid3dVert,
|
vertexShader: heatmapGrid3dVert,
|
||||||
fragmentShader: heatmapGridFrag,
|
fragmentShader: heatmapGridFrag,
|
||||||
|
@ -48,9 +42,8 @@ export default class Grid3DModel extends BaseModel {
|
||||||
depth: { enable: true },
|
depth: { enable: true },
|
||||||
blend: this.getBlend(),
|
blend: this.getBlend(),
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
|
|
||||||
}
|
}
|
||||||
protected registerBuiltinAttributes() {
|
protected registerBuiltinAttributes() {
|
||||||
this.styleAttributeService.registerStyleAttribute({
|
this.styleAttributeService.registerStyleAttribute({
|
||||||
|
@ -64,9 +57,7 @@ export default class Grid3DModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 1,
|
size: 1,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const { size } = feature;
|
const { size } = feature;
|
||||||
return Array.isArray(size) ? [size[0]] : [size as number];
|
return Array.isArray(size) ? [size[0]] : [size as number];
|
||||||
},
|
},
|
||||||
|
@ -107,9 +98,11 @@ export default class Grid3DModel extends BaseModel {
|
||||||
},
|
},
|
||||||
size: 3,
|
size: 3,
|
||||||
update: (feature: IEncodeFeature) => {
|
update: (feature: IEncodeFeature) => {
|
||||||
const coordinates = (feature.version === 'GAODE2.x'
|
const coordinates = (
|
||||||
|
feature.version === 'GAODE2.x'
|
||||||
? feature.originCoordinates
|
? feature.originCoordinates
|
||||||
: feature.coordinates) as number[];
|
: feature.coordinates
|
||||||
|
) as number[];
|
||||||
return [coordinates[0], coordinates[1], 0];
|
return [coordinates[0], coordinates[1], 0];
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -61,14 +61,10 @@ export default class HeatMapModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
const {
|
const { createFramebuffer, getViewportSize, createTexture2D } =
|
||||||
createFramebuffer,
|
this.rendererService;
|
||||||
getViewportSize,
|
const shapeAttr =
|
||||||
createTexture2D,
|
this.styleAttributeService.getLayerStyleAttribute('shape');
|
||||||
} = this.rendererService;
|
|
||||||
const shapeAttr = this.styleAttributeService.getLayerStyleAttribute(
|
|
||||||
'shape',
|
|
||||||
);
|
|
||||||
const shapeType = shapeAttr?.scale?.field || 'heatmap';
|
const shapeType = shapeAttr?.scale?.field || 'heatmap';
|
||||||
this.shapeType = shapeType as string;
|
this.shapeType = shapeType as string;
|
||||||
// 生成热力图密度图
|
// 生成热力图密度图
|
||||||
|
@ -95,12 +91,11 @@ export default class HeatMapModel extends BaseModel {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.updateColorTexture();
|
this.updateColorTexture();
|
||||||
return [this.intensityModel, this.colorModel]
|
return [this.intensityModel, this.colorModel];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
return await this.initModels();
|
return this.initModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected registerBuiltinAttributes() {
|
protected registerBuiltinAttributes() {
|
||||||
|
@ -137,9 +132,7 @@ export default class HeatMapModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 1,
|
size: 1,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const { size = 1 } = feature;
|
const { size = 1 } = feature;
|
||||||
return [size as number];
|
return [size as number];
|
||||||
},
|
},
|
||||||
|
@ -174,24 +167,17 @@ export default class HeatMapModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildHeatmapColor(): IModel {
|
private buildHeatmapColor(): IModel {
|
||||||
const {
|
const { mask = false, maskInside = true } =
|
||||||
mask = false,
|
this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
||||||
maskInside = true,
|
|
||||||
} = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
|
||||||
this.shaderModuleService.registerModule('heatmapColor', {
|
this.shaderModuleService.registerModule('heatmapColor', {
|
||||||
vs: heatmapColorVert,
|
vs: heatmapColorVert,
|
||||||
fs: heatmapColorFrag,
|
fs: heatmapColorFrag,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { vs, fs, uniforms } = this.shaderModuleService.getModule(
|
const { vs, fs, uniforms } =
|
||||||
'heatmapColor',
|
this.shaderModuleService.getModule('heatmapColor');
|
||||||
);
|
const { createAttribute, createElements, createBuffer, createModel } =
|
||||||
const {
|
this.rendererService;
|
||||||
createAttribute,
|
|
||||||
createElements,
|
|
||||||
createBuffer,
|
|
||||||
createModel,
|
|
||||||
} = this.rendererService;
|
|
||||||
return createModel({
|
return createModel({
|
||||||
vs,
|
vs,
|
||||||
fs,
|
fs,
|
||||||
|
@ -249,9 +235,8 @@ export default class HeatMapModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private drawColorMode() {
|
private drawColorMode() {
|
||||||
const {
|
const { opacity } =
|
||||||
opacity,
|
this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
||||||
} = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
|
||||||
this.colorModel?.draw({
|
this.colorModel?.draw({
|
||||||
uniforms: {
|
uniforms: {
|
||||||
u_opacity: opacity || 1.0,
|
u_opacity: opacity || 1.0,
|
||||||
|
@ -262,9 +247,8 @@ export default class HeatMapModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private draw3DHeatMap() {
|
private draw3DHeatMap() {
|
||||||
const {
|
const { opacity } =
|
||||||
opacity,
|
this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
||||||
} = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
|
||||||
|
|
||||||
// const invert = mat4.invert(
|
// const invert = mat4.invert(
|
||||||
// mat4.create(),
|
// mat4.create(),
|
||||||
|
@ -284,16 +268,15 @@ export default class HeatMapModel extends BaseModel {
|
||||||
u_opacity: opacity || 1.0,
|
u_opacity: opacity || 1.0,
|
||||||
u_colorTexture: this.colorTexture,
|
u_colorTexture: this.colorTexture,
|
||||||
u_texture: this.heatmapFramerBuffer,
|
u_texture: this.heatmapFramerBuffer,
|
||||||
u_ViewProjectionMatrixUncentered: this.cameraService.getViewProjectionMatrixUncentered(),
|
u_ViewProjectionMatrixUncentered:
|
||||||
|
this.cameraService.getViewProjectionMatrixUncentered(),
|
||||||
u_InverseViewProjectionMatrix: [...invert],
|
u_InverseViewProjectionMatrix: [...invert],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
private build3dHeatMap() {
|
private build3dHeatMap() {
|
||||||
const {
|
const { mask = false, maskInside = true } =
|
||||||
mask = false,
|
this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
||||||
maskInside = true,
|
|
||||||
} = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
|
||||||
const { getViewportSize } = this.rendererService;
|
const { getViewportSize } = this.rendererService;
|
||||||
const { width, height } = getViewportSize();
|
const { width, height } = getViewportSize();
|
||||||
const triangulation = heatMap3DTriangulation(width / 4.0, height / 4.0);
|
const triangulation = heatMap3DTriangulation(width / 4.0, height / 4.0);
|
||||||
|
@ -302,15 +285,10 @@ export default class HeatMapModel extends BaseModel {
|
||||||
fs: heatmap3DFrag,
|
fs: heatmap3DFrag,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { vs, fs, uniforms } = this.shaderModuleService.getModule(
|
const { vs, fs, uniforms } =
|
||||||
'heatmap3dColor',
|
this.shaderModuleService.getModule('heatmap3dColor');
|
||||||
);
|
const { createAttribute, createElements, createBuffer, createModel } =
|
||||||
const {
|
this.rendererService;
|
||||||
createAttribute,
|
|
||||||
createElements,
|
|
||||||
createBuffer,
|
|
||||||
createModel,
|
|
||||||
} = this.rendererService;
|
|
||||||
return createModel({
|
return createModel({
|
||||||
vs,
|
vs,
|
||||||
fs,
|
fs,
|
||||||
|
@ -364,9 +342,8 @@ export default class HeatMapModel extends BaseModel {
|
||||||
this.texture.destroy();
|
this.texture.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const { rampColors } =
|
||||||
rampColors,
|
this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
||||||
} = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
|
||||||
const imageData = generateColorRamp(rampColors as IColorRamp);
|
const imageData = generateColorRamp(rampColors as IColorRamp);
|
||||||
this.colorTexture = createTexture2D({
|
this.colorTexture = createTexture2D({
|
||||||
data: new Uint8Array(imageData.data),
|
data: new Uint8Array(imageData.data),
|
||||||
|
|
|
@ -14,11 +14,8 @@ import heatmapGridVert from '../shaders/hexagon_vert.glsl';
|
||||||
|
|
||||||
export default class HexagonModel extends BaseModel {
|
export default class HexagonModel extends BaseModel {
|
||||||
public getUninforms(): IModelUniform {
|
public getUninforms(): IModelUniform {
|
||||||
const {
|
const { opacity, coverage, angle } =
|
||||||
opacity,
|
this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
||||||
coverage,
|
|
||||||
angle,
|
|
||||||
} = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
|
||||||
return {
|
return {
|
||||||
u_opacity: opacity || 1.0,
|
u_opacity: opacity || 1.0,
|
||||||
u_coverage: coverage || 0.9,
|
u_coverage: coverage || 0.9,
|
||||||
|
@ -31,16 +28,13 @@ export default class HexagonModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
const {
|
const { mask = false, maskInside = true } =
|
||||||
mask = false,
|
this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
||||||
maskInside = true,
|
const model = await this.layer.buildLayerModel({
|
||||||
} = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;
|
|
||||||
const model = await this.layer
|
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'heatmapHexagon',
|
moduleName: 'heatmapHexagon',
|
||||||
vertexShader: heatmapGridVert,
|
vertexShader: heatmapGridVert,
|
||||||
fragmentShader: heatmapGridFrag,
|
fragmentShader: heatmapGridFrag,
|
||||||
|
@ -49,8 +43,8 @@ export default class HexagonModel extends BaseModel {
|
||||||
primitive: gl.TRIANGLES,
|
primitive: gl.TRIANGLES,
|
||||||
blend: this.getBlend(),
|
blend: this.getBlend(),
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
protected registerBuiltinAttributes() {
|
protected registerBuiltinAttributes() {
|
||||||
this.styleAttributeService.registerStyleAttribute({
|
this.styleAttributeService.registerStyleAttribute({
|
||||||
|
@ -65,9 +59,11 @@ export default class HexagonModel extends BaseModel {
|
||||||
},
|
},
|
||||||
size: 3,
|
size: 3,
|
||||||
update: (feature: IEncodeFeature) => {
|
update: (feature: IEncodeFeature) => {
|
||||||
const coordinates = (feature.version === 'GAODE2.x'
|
const coordinates = (
|
||||||
|
feature.version === 'GAODE2.x'
|
||||||
? feature.originCoordinates
|
? feature.originCoordinates
|
||||||
: feature.coordinates) as number[];
|
: feature.coordinates
|
||||||
|
) as number[];
|
||||||
return [coordinates[0], coordinates[1], 0];
|
return [coordinates[0], coordinates[1], 0];
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -24,10 +24,8 @@ export default class ImageModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
const {
|
const { mask = false, maskInside = true } =
|
||||||
mask = false,
|
this.layer.getLayerConfig() as IImageLayerStyleOptions;
|
||||||
maskInside = true,
|
|
||||||
} = this.layer.getLayerConfig() as IImageLayerStyleOptions;
|
|
||||||
|
|
||||||
const source = this.layer.getSource();
|
const source = this.layer.getSource();
|
||||||
const { createTexture2D } = this.rendererService;
|
const { createTexture2D } = this.rendererService;
|
||||||
|
@ -61,11 +59,9 @@ export default class ImageModel extends BaseModel {
|
||||||
mag: gl.LINEAR,
|
mag: gl.LINEAR,
|
||||||
min: gl.LINEAR,
|
min: gl.LINEAR,
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'rasterImage',
|
moduleName: 'rasterImage',
|
||||||
vertexShader: ImageVert,
|
vertexShader: ImageVert,
|
||||||
fragmentShader: ImageFrag,
|
fragmentShader: ImageFrag,
|
||||||
|
@ -77,8 +73,8 @@ export default class ImageModel extends BaseModel {
|
||||||
},
|
},
|
||||||
depth: { enable: false },
|
depth: { enable: false },
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels(): void {
|
public clearModels(): void {
|
||||||
|
@ -86,7 +82,7 @@ export default class ImageModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
return await this.initModels();
|
return this.initModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected registerBuiltinAttributes() {
|
protected registerBuiltinAttributes() {
|
||||||
|
|
|
@ -137,6 +137,7 @@ container
|
||||||
.to(LayerModelPlugin)
|
.to(LayerModelPlugin)
|
||||||
.inRequestScope();
|
.inRequestScope();
|
||||||
|
|
||||||
|
export * from './core/interface';
|
||||||
export {
|
export {
|
||||||
BaseLayer,
|
BaseLayer,
|
||||||
BaseModel,
|
BaseModel,
|
||||||
|
@ -154,5 +155,3 @@ export {
|
||||||
MaskLayer,
|
MaskLayer,
|
||||||
TileDebugLayer,
|
TileDebugLayer,
|
||||||
};
|
};
|
||||||
|
|
||||||
export * from './core/interface';
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ export default class ArcModel extends BaseModel {
|
||||||
this.updateTexture();
|
this.updateTexture();
|
||||||
this.iconService.on('imageUpdate', this.updateTexture);
|
this.iconService.on('imageUpdate', this.updateTexture);
|
||||||
|
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels() {
|
public clearModels() {
|
||||||
|
@ -143,11 +143,8 @@ export default class ArcModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getShaders(): { frag: string; vert: string; type: string } {
|
public getShaders(): { frag: string; vert: string; type: string } {
|
||||||
const {
|
const { sourceColor, targetColor, lineType } =
|
||||||
sourceColor,
|
this.layer.getLayerConfig() as ILineLayerStyleOptions;
|
||||||
targetColor,
|
|
||||||
lineType,
|
|
||||||
} = this.layer.getLayerConfig() as ILineLayerStyleOptions;
|
|
||||||
if (lineType === 'dash') {
|
if (lineType === 'dash') {
|
||||||
return {
|
return {
|
||||||
frag: arc_dash_frag,
|
frag: arc_dash_frag,
|
||||||
|
@ -180,8 +177,7 @@ export default class ArcModel extends BaseModel {
|
||||||
} = this.layer.getLayerConfig() as ILineLayerStyleOptions;
|
} = this.layer.getLayerConfig() as ILineLayerStyleOptions;
|
||||||
const { frag, vert, type } = this.getShaders();
|
const { frag, vert, type } = this.getShaders();
|
||||||
//
|
//
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'lineArc2d' + type,
|
moduleName: 'lineArc2d' + type,
|
||||||
vertexShader: vert,
|
vertexShader: vert,
|
||||||
fragmentShader: frag,
|
fragmentShader: frag,
|
||||||
|
@ -190,8 +186,8 @@ export default class ArcModel extends BaseModel {
|
||||||
blend: this.getBlend(),
|
blend: this.getBlend(),
|
||||||
segmentNumber,
|
segmentNumber,
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected registerBuiltinAttributes() {
|
protected registerBuiltinAttributes() {
|
||||||
|
@ -207,9 +203,7 @@ export default class ArcModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 1,
|
size: 1,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const { size = 1 } = feature;
|
const { size = 1 } = feature;
|
||||||
return Array.isArray(size) ? [size[0]] : [size as number];
|
return Array.isArray(size) ? [size[0]] : [size as number];
|
||||||
},
|
},
|
||||||
|
@ -249,9 +243,7 @@ export default class ArcModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 2,
|
size: 2,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const iconMap = this.iconService.getIconMap();
|
const iconMap = this.iconService.getIconMap();
|
||||||
const { texture } = feature;
|
const { texture } = feature;
|
||||||
const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };
|
const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };
|
||||||
|
|
|
@ -124,11 +124,10 @@ export default class Arc3DModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
|
|
||||||
this.updateTexture();
|
this.updateTexture();
|
||||||
this.iconService.on('imageUpdate', this.updateTexture);
|
this.iconService.on('imageUpdate', this.updateTexture);
|
||||||
|
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels() {
|
public clearModels() {
|
||||||
|
@ -138,10 +137,8 @@ export default class Arc3DModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getShaders(): { frag: string; vert: string; type: string } {
|
public getShaders(): { frag: string; vert: string; type: string } {
|
||||||
const {
|
const { sourceColor, targetColor } =
|
||||||
sourceColor,
|
this.layer.getLayerConfig() as ILineLayerStyleOptions;
|
||||||
targetColor,
|
|
||||||
} = this.layer.getLayerConfig() as ILineLayerStyleOptions;
|
|
||||||
|
|
||||||
if (sourceColor && targetColor) {
|
if (sourceColor && targetColor) {
|
||||||
// 分离 linear 功能
|
// 分离 linear 功能
|
||||||
|
@ -167,8 +164,7 @@ export default class Arc3DModel extends BaseModel {
|
||||||
} = this.layer.getLayerConfig() as ILineLayerStyleOptions;
|
} = this.layer.getLayerConfig() as ILineLayerStyleOptions;
|
||||||
const { frag, vert, type } = this.getShaders();
|
const { frag, vert, type } = this.getShaders();
|
||||||
|
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'lineArc3d' + type,
|
moduleName: 'lineArc3d' + type,
|
||||||
vertexShader: vert,
|
vertexShader: vert,
|
||||||
fragmentShader: frag,
|
fragmentShader: frag,
|
||||||
|
@ -176,8 +172,8 @@ export default class Arc3DModel extends BaseModel {
|
||||||
blend: this.getBlend(),
|
blend: this.getBlend(),
|
||||||
segmentNumber,
|
segmentNumber,
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
protected registerBuiltinAttributes() {
|
protected registerBuiltinAttributes() {
|
||||||
this.styleAttributeService.registerStyleAttribute({
|
this.styleAttributeService.registerStyleAttribute({
|
||||||
|
@ -192,9 +188,7 @@ export default class Arc3DModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 1,
|
size: 1,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const { size = 1 } = feature;
|
const { size = 1 } = feature;
|
||||||
return Array.isArray(size) ? [size[0]] : [size as number];
|
return Array.isArray(size) ? [size[0]] : [size as number];
|
||||||
},
|
},
|
||||||
|
@ -233,9 +227,7 @@ export default class Arc3DModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 2,
|
size: 2,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const iconMap = this.iconService.getIconMap();
|
const iconMap = this.iconService.getIconMap();
|
||||||
const { texture } = feature;
|
const { texture } = feature;
|
||||||
const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };
|
const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };
|
||||||
|
|
|
@ -127,7 +127,7 @@ export default class Arc3DModel extends BaseModel {
|
||||||
this.updateTexture();
|
this.updateTexture();
|
||||||
this.iconService.on('imageUpdate', this.updateTexture);
|
this.iconService.on('imageUpdate', this.updateTexture);
|
||||||
|
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels() {
|
public clearModels() {
|
||||||
|
@ -137,10 +137,8 @@ export default class Arc3DModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getShaders(): { frag: string; vert: string; type: string } {
|
public getShaders(): { frag: string; vert: string; type: string } {
|
||||||
const {
|
const { sourceColor, targetColor } =
|
||||||
sourceColor,
|
this.layer.getLayerConfig() as ILineLayerStyleOptions;
|
||||||
targetColor,
|
|
||||||
} = this.layer.getLayerConfig() as ILineLayerStyleOptions;
|
|
||||||
|
|
||||||
if (sourceColor && targetColor) {
|
if (sourceColor && targetColor) {
|
||||||
// 分离 linear 功能
|
// 分离 linear 功能
|
||||||
|
@ -165,8 +163,7 @@ export default class Arc3DModel extends BaseModel {
|
||||||
maskInside = true,
|
maskInside = true,
|
||||||
} = this.layer.getLayerConfig() as ILineLayerStyleOptions;
|
} = this.layer.getLayerConfig() as ILineLayerStyleOptions;
|
||||||
const { frag, vert, type } = this.getShaders();
|
const { frag, vert, type } = this.getShaders();
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'lineEarthArc3d' + type,
|
moduleName: 'lineEarthArc3d' + type,
|
||||||
vertexShader: vert,
|
vertexShader: vert,
|
||||||
fragmentShader: frag,
|
fragmentShader: frag,
|
||||||
|
@ -175,8 +172,8 @@ export default class Arc3DModel extends BaseModel {
|
||||||
blend: this.getBlend(),
|
blend: this.getBlend(),
|
||||||
segmentNumber,
|
segmentNumber,
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
protected registerBuiltinAttributes() {
|
protected registerBuiltinAttributes() {
|
||||||
this.styleAttributeService.registerStyleAttribute({
|
this.styleAttributeService.registerStyleAttribute({
|
||||||
|
@ -191,9 +188,7 @@ export default class Arc3DModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 1,
|
size: 1,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const { size = 1 } = feature;
|
const { size = 1 } = feature;
|
||||||
return Array.isArray(size) ? [size[0]] : [size as number];
|
return Array.isArray(size) ? [size[0]] : [size as number];
|
||||||
},
|
},
|
||||||
|
@ -232,9 +227,7 @@ export default class Arc3DModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 2,
|
size: 2,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const iconMap = this.iconService.getIconMap();
|
const iconMap = this.iconService.getIconMap();
|
||||||
const { texture } = feature;
|
const { texture } = feature;
|
||||||
const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };
|
const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };
|
||||||
|
|
|
@ -116,7 +116,7 @@ export default class GreatCircleModel extends BaseModel {
|
||||||
this.updateTexture();
|
this.updateTexture();
|
||||||
this.iconService.on('imageUpdate', this.updateTexture);
|
this.iconService.on('imageUpdate', this.updateTexture);
|
||||||
|
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels() {
|
public clearModels() {
|
||||||
|
@ -126,12 +126,9 @@ export default class GreatCircleModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
const {
|
const { mask = false, maskInside = true } =
|
||||||
mask = false,
|
this.layer.getLayerConfig() as ILineLayerStyleOptions;
|
||||||
maskInside = true,
|
const model = await this.layer.buildLayerModel({
|
||||||
} = this.layer.getLayerConfig() as ILineLayerStyleOptions;
|
|
||||||
const model = await this.layer
|
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'lineGreatCircle',
|
moduleName: 'lineGreatCircle',
|
||||||
vertexShader: line_arc2d_vert,
|
vertexShader: line_arc2d_vert,
|
||||||
fragmentShader: line_arc_frag,
|
fragmentShader: line_arc_frag,
|
||||||
|
@ -139,8 +136,8 @@ export default class GreatCircleModel extends BaseModel {
|
||||||
depth: { enable: false },
|
depth: { enable: false },
|
||||||
blend: this.getBlend(),
|
blend: this.getBlend(),
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
protected registerBuiltinAttributes() {
|
protected registerBuiltinAttributes() {
|
||||||
this.styleAttributeService.registerStyleAttribute({
|
this.styleAttributeService.registerStyleAttribute({
|
||||||
|
@ -155,9 +152,7 @@ export default class GreatCircleModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 1,
|
size: 1,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const { size = 1 } = feature;
|
const { size = 1 } = feature;
|
||||||
return Array.isArray(size) ? [size[0]] : [size as number];
|
return Array.isArray(size) ? [size[0]] : [size as number];
|
||||||
},
|
},
|
||||||
|
@ -197,9 +192,7 @@ export default class GreatCircleModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 2,
|
size: 2,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const iconMap = this.iconService.getIconMap();
|
const iconMap = this.iconService.getIconMap();
|
||||||
const { texture } = feature;
|
const { texture } = feature;
|
||||||
// console.log('icon feature', feature)
|
// console.log('icon feature', feature)
|
||||||
|
|
|
@ -85,7 +85,7 @@ export default class LineModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels() {
|
public clearModels() {
|
||||||
|
@ -101,8 +101,7 @@ export default class LineModel extends BaseModel {
|
||||||
const { frag, vert } = this.getShaders();
|
const { frag, vert } = this.getShaders();
|
||||||
this.layer.triangulation = LineTriangulation;
|
this.layer.triangulation = LineTriangulation;
|
||||||
|
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'lineHalf',
|
moduleName: 'lineHalf',
|
||||||
vertexShader: vert,
|
vertexShader: vert,
|
||||||
fragmentShader: frag,
|
fragmentShader: frag,
|
||||||
|
@ -110,8 +109,8 @@ export default class LineModel extends BaseModel {
|
||||||
depth: { enable: depth },
|
depth: { enable: depth },
|
||||||
blend: this.getBlend(),
|
blend: this.getBlend(),
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -165,9 +164,7 @@ export default class LineModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 4,
|
size: 4,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const startPoint = (feature.coordinates[0] || [0, 0]) as number[];
|
const startPoint = (feature.coordinates[0] || [0, 0]) as number[];
|
||||||
const endPoint = (feature.coordinates[3] || [0, 0]) as number[];
|
const endPoint = (feature.coordinates[3] || [0, 0]) as number[];
|
||||||
|
|
||||||
|
@ -188,9 +185,7 @@ export default class LineModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 2,
|
size: 2,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const { size = 1 } = feature;
|
const { size = 1 } = feature;
|
||||||
return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];
|
return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];
|
||||||
},
|
},
|
||||||
|
|
|
@ -68,8 +68,8 @@ export default class LineModel extends BaseModel {
|
||||||
dashArray.push(0, 0);
|
dashArray.push(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.rendererService.getDirty()) {
|
if (this.rendererService.getDirty() && this.texture) {
|
||||||
this.texture && this.texture.bind();
|
this.texture.bind();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 转化渐变色
|
// 转化渐变色
|
||||||
|
|
|
@ -78,7 +78,7 @@ export default class LinearLineModel extends BaseModel {
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
this.updateTexture();
|
this.updateTexture();
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels() {
|
public clearModels() {
|
||||||
|
@ -95,8 +95,7 @@ export default class LinearLineModel extends BaseModel {
|
||||||
|
|
||||||
this.layer.triangulation = LineTriangulation;
|
this.layer.triangulation = LineTriangulation;
|
||||||
|
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'lineRampColors',
|
moduleName: 'lineRampColors',
|
||||||
vertexShader: linear_line_vert,
|
vertexShader: linear_line_vert,
|
||||||
fragmentShader: linear_line_frag,
|
fragmentShader: linear_line_frag,
|
||||||
|
@ -104,8 +103,8 @@ export default class LinearLineModel extends BaseModel {
|
||||||
depth: { enable: depth },
|
depth: { enable: depth },
|
||||||
blend: this.getBlend(),
|
blend: this.getBlend(),
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected registerBuiltinAttributes() {
|
protected registerBuiltinAttributes() {
|
||||||
|
@ -169,9 +168,7 @@ export default class LinearLineModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 2,
|
size: 2,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const { size = 1 } = feature;
|
const { size = 1 } = feature;
|
||||||
return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];
|
return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];
|
||||||
},
|
},
|
||||||
|
@ -231,9 +228,8 @@ export default class LinearLineModel extends BaseModel {
|
||||||
if (this.colorTexture) {
|
if (this.colorTexture) {
|
||||||
this.colorTexture.destroy();
|
this.colorTexture.destroy();
|
||||||
}
|
}
|
||||||
const {
|
const { rampColors } =
|
||||||
rampColors,
|
this.layer.getLayerConfig() as ILineLayerStyleOptions;
|
||||||
} = this.layer.getLayerConfig() as ILineLayerStyleOptions;
|
|
||||||
const imageData = generateColorRamp(rampColors as IColorRamp);
|
const imageData = generateColorRamp(rampColors as IColorRamp);
|
||||||
this.colorTexture = createTexture2D({
|
this.colorTexture = createTexture2D({
|
||||||
data: new Uint8Array(imageData.data),
|
data: new Uint8Array(imageData.data),
|
||||||
|
|
|
@ -79,7 +79,7 @@ export default class SimpleLineModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels() {
|
public clearModels() {
|
||||||
|
@ -87,10 +87,8 @@ export default class SimpleLineModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getShaders(): { frag: string; vert: string; type: string } {
|
public getShaders(): { frag: string; vert: string; type: string } {
|
||||||
const {
|
const { sourceColor, targetColor } =
|
||||||
sourceColor,
|
this.layer.getLayerConfig() as ILineLayerStyleOptions;
|
||||||
targetColor,
|
|
||||||
} = this.layer.getLayerConfig() as ILineLayerStyleOptions;
|
|
||||||
if (sourceColor && targetColor) {
|
if (sourceColor && targetColor) {
|
||||||
// 分离 linear 功能
|
// 分离 linear 功能
|
||||||
return {
|
return {
|
||||||
|
@ -108,15 +106,12 @@ export default class SimpleLineModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
const {
|
const { mask = false, maskInside = true } =
|
||||||
mask = false,
|
this.layer.getLayerConfig() as ILineLayerStyleOptions;
|
||||||
maskInside = true,
|
|
||||||
} = this.layer.getLayerConfig() as ILineLayerStyleOptions;
|
|
||||||
|
|
||||||
const { frag, vert, type } = this.getShaders();
|
const { frag, vert, type } = this.getShaders();
|
||||||
|
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: type,
|
moduleName: type,
|
||||||
vertexShader: vert,
|
vertexShader: vert,
|
||||||
fragmentShader: frag,
|
fragmentShader: frag,
|
||||||
|
@ -126,8 +121,8 @@ export default class SimpleLineModel extends BaseModel {
|
||||||
blend: this.getBlend(),
|
blend: this.getBlend(),
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
pick: false,
|
pick: false,
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
protected registerBuiltinAttributes() {
|
protected registerBuiltinAttributes() {
|
||||||
this.styleAttributeService.registerStyleAttribute({
|
this.styleAttributeService.registerStyleAttribute({
|
||||||
|
@ -185,9 +180,7 @@ export default class SimpleLineModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 2,
|
size: 2,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const { size = 1 } = feature;
|
const { size = 1 } = feature;
|
||||||
return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];
|
return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];
|
||||||
},
|
},
|
||||||
|
|
|
@ -74,7 +74,7 @@ export default class LineWallModel extends BaseModel {
|
||||||
this.updateTexture();
|
this.updateTexture();
|
||||||
this.iconService.on('imageUpdate', this.updateTexture);
|
this.iconService.on('imageUpdate', this.updateTexture);
|
||||||
|
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels() {
|
public clearModels() {
|
||||||
|
@ -83,16 +83,15 @@ export default class LineWallModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'lineWall',
|
moduleName: 'lineWall',
|
||||||
vertexShader: line_vert,
|
vertexShader: line_vert,
|
||||||
fragmentShader: line_frag,
|
fragmentShader: line_frag,
|
||||||
triangulation: LineTriangulation,
|
triangulation: LineTriangulation,
|
||||||
depth: { enable: false },
|
depth: { enable: false },
|
||||||
blend: this.getBlend(),
|
blend: this.getBlend(),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
protected registerBuiltinAttributes() {
|
protected registerBuiltinAttributes() {
|
||||||
this.styleAttributeService.registerStyleAttribute({
|
this.styleAttributeService.registerStyleAttribute({
|
||||||
|
@ -150,9 +149,7 @@ export default class LineWallModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 2,
|
size: 2,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const { size = 1 } = feature;
|
const { size = 1 } = feature;
|
||||||
return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];
|
return Array.isArray(size) ? [size[0], size[1]] : [size as number, 0];
|
||||||
},
|
},
|
||||||
|
@ -219,9 +216,7 @@ export default class LineWallModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 2,
|
size: 2,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const iconMap = this.iconService.getIconMap();
|
const iconMap = this.iconService.getIconMap();
|
||||||
const { texture } = feature;
|
const { texture } = feature;
|
||||||
const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };
|
const { x, y } = iconMap[texture as string] || { x: 0, y: 0 };
|
||||||
|
|
|
@ -9,10 +9,8 @@ import mask_vert from '../shaders/mask_vert.glsl';
|
||||||
|
|
||||||
export default class MaskModel extends BaseModel {
|
export default class MaskModel extends BaseModel {
|
||||||
public getUninforms() {
|
public getUninforms() {
|
||||||
const {
|
const { opacity = 0, color = '#000' } =
|
||||||
opacity = 0,
|
this.layer.getLayerConfig() as IMaskLayerStyleOptions;
|
||||||
color = '#000'
|
|
||||||
} = this.layer.getLayerConfig() as IMaskLayerStyleOptions;
|
|
||||||
return {
|
return {
|
||||||
u_opacity: isNumber(opacity) ? opacity : 0.0,
|
u_opacity: isNumber(opacity) ? opacity : 0.0,
|
||||||
u_color: rgb2arr(color),
|
u_color: rgb2arr(color),
|
||||||
|
@ -20,12 +18,11 @@ export default class MaskModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'mask',
|
moduleName: 'mask',
|
||||||
vertexShader: mask_vert,
|
vertexShader: mask_vert,
|
||||||
fragmentShader: mask_frag,
|
fragmentShader: mask_frag,
|
||||||
|
@ -46,13 +43,15 @@ export default class MaskModel extends BaseModel {
|
||||||
zpass: gl.REPLACE,
|
zpass: gl.REPLACE,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
pick: false
|
pick: false,
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels(refresh = true) {
|
public clearModels(refresh = true) {
|
||||||
refresh && this.layerService.clear();
|
if (refresh) {
|
||||||
|
this.layerService.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected registerBuiltinAttributes() {
|
protected registerBuiltinAttributes() {
|
||||||
|
|
|
@ -19,81 +19,77 @@ describe('template', () => {
|
||||||
x: 112,
|
x: 112,
|
||||||
y: 32,
|
y: 32,
|
||||||
name: 'text2',
|
name: 'text2',
|
||||||
v:20
|
v: 20,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
it('scene layer fill', async () => {
|
it('scene layer fill', async () => {
|
||||||
const layer = new PointLayer().source(
|
const layer = new PointLayer()
|
||||||
testData,
|
.source(testData, {
|
||||||
{
|
|
||||||
parser: {
|
parser: {
|
||||||
type: 'json',
|
type: 'json',
|
||||||
x: 'x',
|
x: 'x',
|
||||||
y: 'y',
|
y: 'y',
|
||||||
},
|
},
|
||||||
},
|
|
||||||
).shape('circle')
|
|
||||||
.color('red')
|
|
||||||
.size(10)
|
|
||||||
scene.on('loaded', () =>{
|
|
||||||
scene.addLayer(layer)
|
|
||||||
})
|
})
|
||||||
|
.shape('circle')
|
||||||
|
.color('red')
|
||||||
|
.size(10);
|
||||||
|
scene.on('loaded', () => {
|
||||||
|
scene.addLayer(layer);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('scene layer text', async () => {
|
it('scene layer text', async () => {
|
||||||
const layer = new PointLayer({name:'text'}).source(
|
const layer = new PointLayer({ name: 'text' })
|
||||||
testData,
|
.source(testData, {
|
||||||
{
|
|
||||||
parser: {
|
parser: {
|
||||||
type: 'json',
|
type: 'json',
|
||||||
x: 'x',
|
x: 'x',
|
||||||
y: 'y',
|
y: 'y',
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
).shape('name','text')
|
.shape('name', 'text')
|
||||||
.color('name', ['red', 'blue'])
|
.color('name', ['red', 'blue'])
|
||||||
.size('v',[10,20])
|
.size('v', [10, 20]);
|
||||||
|
|
||||||
scene.on('loaded', () => {
|
scene.on('loaded', () => {
|
||||||
scene.addLayer(layer)
|
scene.addLayer(layer);
|
||||||
expect(layer.name).toEqual('text')
|
expect(layer.name).toEqual('text');
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('scene layer extrude', async () => {
|
it('scene layer extrude', async () => {
|
||||||
const layer = new PointLayer().source(
|
const layer = new PointLayer()
|
||||||
testData,
|
.source(testData, {
|
||||||
{
|
|
||||||
parser: {
|
parser: {
|
||||||
type: 'json',
|
type: 'json',
|
||||||
x: 'x',
|
x: 'x',
|
||||||
y: 'y',
|
y: 'y',
|
||||||
},
|
},
|
||||||
},
|
|
||||||
).shape('cloumn')
|
|
||||||
.color('red')
|
|
||||||
.size([5,5,10])
|
|
||||||
scene.on('loaded', () =>{
|
|
||||||
scene.addLayer(layer)
|
|
||||||
})
|
})
|
||||||
|
.shape('cloumn')
|
||||||
|
.color('red')
|
||||||
|
.size([5, 5, 10]);
|
||||||
|
scene.on('loaded', () => {
|
||||||
|
scene.addLayer(layer);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('scene layer simplePoint', async () => {
|
it('scene layer simplePoint', async () => {
|
||||||
const layer = new PointLayer().source(
|
const layer = new PointLayer()
|
||||||
testData,
|
.source(testData, {
|
||||||
{
|
|
||||||
parser: {
|
parser: {
|
||||||
type: 'json',
|
type: 'json',
|
||||||
x: 'x',
|
x: 'x',
|
||||||
y: 'y',
|
y: 'y',
|
||||||
},
|
},
|
||||||
},
|
|
||||||
).shape('simple')
|
|
||||||
.color('red')
|
|
||||||
.size(1)
|
|
||||||
scene.on('loaded', () =>{
|
|
||||||
scene.addLayer(layer)
|
|
||||||
})
|
})
|
||||||
|
.shape('simple')
|
||||||
|
.color('red')
|
||||||
|
.size(1);
|
||||||
|
scene.on('loaded', () => {
|
||||||
|
scene.addLayer(layer);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -130,7 +130,7 @@ export default class ExtrudeModel extends BaseModel {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
|
@ -140,8 +140,7 @@ export default class ExtrudeModel extends BaseModel {
|
||||||
} = this.layer.getLayerConfig() as ILayerConfig;
|
} = this.layer.getLayerConfig() as ILayerConfig;
|
||||||
this.raiseRepeat = repeat;
|
this.raiseRepeat = repeat;
|
||||||
|
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'pointEarthExtrude',
|
moduleName: 'pointEarthExtrude',
|
||||||
vertexShader: pointExtrudeVert,
|
vertexShader: pointExtrudeVert,
|
||||||
fragmentShader: pointExtrudeFrag,
|
fragmentShader: pointExtrudeFrag,
|
||||||
|
@ -153,7 +152,7 @@ export default class ExtrudeModel extends BaseModel {
|
||||||
},
|
},
|
||||||
blend: this.getBlend(),
|
blend: this.getBlend(),
|
||||||
});
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
public clearModels() {
|
public clearModels() {
|
||||||
this.dataTexture?.destroy();
|
this.dataTexture?.destroy();
|
||||||
|
@ -170,9 +169,7 @@ export default class ExtrudeModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 3,
|
size: 3,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const { size } = feature;
|
const { size } = feature;
|
||||||
if (size) {
|
if (size) {
|
||||||
let buffersize: number[] = [];
|
let buffersize: number[] = [];
|
||||||
|
|
|
@ -90,9 +90,8 @@ export default class FillModel extends BaseModel {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public getAnimateUniforms(): IModelUniform {
|
public getAnimateUniforms(): IModelUniform {
|
||||||
const {
|
const { animateOption = { enable: false } } =
|
||||||
animateOption = { enable: false },
|
this.layer.getLayerConfig() as ILayerConfig;
|
||||||
} = this.layer.getLayerConfig() as ILayerConfig;
|
|
||||||
return {
|
return {
|
||||||
u_animate: this.animateOption2Array(animateOption),
|
u_animate: this.animateOption2Array(animateOption),
|
||||||
u_time: this.layer.getLayerAnimateTime(),
|
u_time: this.layer.getLayerAnimateTime(),
|
||||||
|
@ -100,7 +99,7 @@ export default class FillModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
|
|
|
@ -128,7 +128,7 @@ export default class ExtrudeModel extends BaseModel {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
|
@ -139,8 +139,7 @@ export default class ExtrudeModel extends BaseModel {
|
||||||
} = this.layer.getLayerConfig() as ILayerConfig;
|
} = this.layer.getLayerConfig() as ILayerConfig;
|
||||||
this.raiseRepeat = repeat;
|
this.raiseRepeat = repeat;
|
||||||
|
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'pointExtrude',
|
moduleName: 'pointExtrude',
|
||||||
vertexShader: pointExtrudeVert,
|
vertexShader: pointExtrudeVert,
|
||||||
fragmentShader: pointExtrudeFrag,
|
fragmentShader: pointExtrudeFrag,
|
||||||
|
@ -153,9 +152,8 @@ export default class ExtrudeModel extends BaseModel {
|
||||||
depth: {
|
depth: {
|
||||||
enable: depth,
|
enable: depth,
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
|
|
||||||
}
|
}
|
||||||
public clearModels() {
|
public clearModels() {
|
||||||
this.dataTexture?.destroy();
|
this.dataTexture?.destroy();
|
||||||
|
@ -173,9 +171,7 @@ export default class ExtrudeModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 3,
|
size: 3,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const { size } = feature;
|
const { size } = feature;
|
||||||
if (size) {
|
if (size) {
|
||||||
let buffersize: number[] = [];
|
let buffersize: number[] = [];
|
||||||
|
|
|
@ -28,9 +28,8 @@ export default class NormalModel extends BaseModel {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public getUninforms(): IModelUniform {
|
public getUninforms(): IModelUniform {
|
||||||
const {
|
const { opacity = 1 } =
|
||||||
opacity = 1,
|
this.layer.getLayerConfig() as IPointLayerStyleOptions;
|
||||||
} = this.layer.getLayerConfig() as IPointLayerStyleOptions;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
u_opacity: isNumber(opacity) ? opacity : 1.0,
|
u_opacity: isNumber(opacity) ? opacity : 1.0,
|
||||||
|
@ -38,18 +37,15 @@ export default class NormalModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
const {
|
const { mask = false, maskInside = true } =
|
||||||
mask = false,
|
this.layer.getLayerConfig() as IPointLayerStyleOptions;
|
||||||
maskInside = true,
|
|
||||||
} = this.layer.getLayerConfig() as IPointLayerStyleOptions;
|
|
||||||
this.layer.triangulation = PointTriangulation;
|
this.layer.triangulation = PointTriangulation;
|
||||||
|
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'pointNormal',
|
moduleName: 'pointNormal',
|
||||||
vertexShader: normalVert,
|
vertexShader: normalVert,
|
||||||
fragmentShader: normalFrag,
|
fragmentShader: normalFrag,
|
||||||
|
@ -59,11 +55,12 @@ export default class NormalModel extends BaseModel {
|
||||||
blend: this.getBlend(),
|
blend: this.getBlend(),
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
pick: false,
|
pick: false,
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels() {
|
public clearModels() {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected registerBuiltinAttributes() {
|
protected registerBuiltinAttributes() {
|
||||||
|
@ -78,9 +75,7 @@ export default class NormalModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 1,
|
size: 1,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const { size = 1 } = feature;
|
const { size = 1 } = feature;
|
||||||
return Array.isArray(size) ? [size[0]] : [size as number];
|
return Array.isArray(size) ? [size[0]] : [size as number];
|
||||||
},
|
},
|
||||||
|
|
|
@ -12,12 +12,11 @@ import {
|
||||||
import { getMask } from '@antv/l7-utils';
|
import { getMask } from '@antv/l7-utils';
|
||||||
import { isNumber } from 'lodash';
|
import { isNumber } from 'lodash';
|
||||||
import BaseModel from '../../core/BaseModel';
|
import BaseModel from '../../core/BaseModel';
|
||||||
import { IPointLayerStyleOptions } from '../../core/interface';
|
import { IPointLayerStyleOptions, SizeUnitType } from '../../core/interface';
|
||||||
import { PointFillTriangulation } from '../../core/triangulation';
|
import { PointFillTriangulation } from '../../core/triangulation';
|
||||||
|
|
||||||
import pointFillFrag from '../shaders/radar/radar_frag.glsl';
|
import pointFillFrag from '../shaders/radar/radar_frag.glsl';
|
||||||
import pointFillVert from '../shaders/radar/radar_vert.glsl';
|
import pointFillVert from '../shaders/radar/radar_vert.glsl';
|
||||||
import { SizeUnitType } from '../../core/interface'
|
|
||||||
|
|
||||||
export default class RadarModel extends BaseModel {
|
export default class RadarModel extends BaseModel {
|
||||||
public getUninforms(): IModelUniform {
|
public getUninforms(): IModelUniform {
|
||||||
|
@ -25,7 +24,7 @@ export default class RadarModel extends BaseModel {
|
||||||
opacity = 1,
|
opacity = 1,
|
||||||
blend,
|
blend,
|
||||||
speed = 1,
|
speed = 1,
|
||||||
unit = 'pixel'
|
unit = 'pixel',
|
||||||
} = this.layer.getLayerConfig() as IPointLayerStyleOptions;
|
} = this.layer.getLayerConfig() as IPointLayerStyleOptions;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -36,9 +35,8 @@ export default class RadarModel extends BaseModel {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public getAnimateUniforms(): IModelUniform {
|
public getAnimateUniforms(): IModelUniform {
|
||||||
const {
|
const { animateOption = { enable: false } } =
|
||||||
animateOption = { enable: false },
|
this.layer.getLayerConfig() as ILayerConfig;
|
||||||
} = this.layer.getLayerConfig() as ILayerConfig;
|
|
||||||
return {
|
return {
|
||||||
u_animate: this.animateOption2Array(animateOption),
|
u_animate: this.animateOption2Array(animateOption),
|
||||||
u_time: this.layer.getLayerAnimateTime(),
|
u_time: this.layer.getLayerAnimateTime(),
|
||||||
|
@ -58,19 +56,14 @@ export default class RadarModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
const {
|
const { mask = false, maskInside = true } =
|
||||||
mask = false,
|
this.layer.getLayerConfig() as IPointLayerStyleOptions;
|
||||||
maskInside = true,
|
|
||||||
} = this.layer.getLayerConfig() as IPointLayerStyleOptions;
|
|
||||||
|
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'pointRadar',
|
moduleName: 'pointRadar',
|
||||||
vertexShader: pointFillVert,
|
vertexShader: pointFillVert,
|
||||||
fragmentShader: pointFillFrag,
|
fragmentShader: pointFillFrag,
|
||||||
|
@ -78,9 +71,8 @@ export default class RadarModel extends BaseModel {
|
||||||
depth: { enable: false },
|
depth: { enable: false },
|
||||||
blend: this.getBlend(),
|
blend: this.getBlend(),
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels() {
|
public clearModels() {
|
||||||
|
@ -134,13 +126,9 @@ export default class RadarModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 1,
|
size: 1,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const { size = 5 } = feature;
|
const { size = 5 } = feature;
|
||||||
return Array.isArray(size)
|
return Array.isArray(size) ? [size[0]] : [size as number];
|
||||||
? [size[0]]
|
|
||||||
: [(size as number)];
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -93,18 +93,15 @@ export default class SimplePointModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
const {
|
const { mask = false, maskInside = true } =
|
||||||
mask = false,
|
this.layer.getLayerConfig() as IPointLayerStyleOptions;
|
||||||
maskInside = true,
|
|
||||||
} = this.layer.getLayerConfig() as IPointLayerStyleOptions;
|
|
||||||
this.layer.triangulation = PointTriangulation;
|
this.layer.triangulation = PointTriangulation;
|
||||||
|
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'pointSimple',
|
moduleName: 'pointSimple',
|
||||||
vertexShader: simplePointVert,
|
vertexShader: simplePointVert,
|
||||||
fragmentShader: simplePointFrag,
|
fragmentShader: simplePointFrag,
|
||||||
|
@ -113,8 +110,8 @@ export default class SimplePointModel extends BaseModel {
|
||||||
primitive: gl.POINTS,
|
primitive: gl.POINTS,
|
||||||
blend: this.getBlend(),
|
blend: this.getBlend(),
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels() {
|
public clearModels() {
|
||||||
|
@ -133,9 +130,7 @@ export default class SimplePointModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 1,
|
size: 1,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const { size = 1 } = feature;
|
const { size = 1 } = feature;
|
||||||
return Array.isArray(size) ? [size[0]] : [size as number];
|
return Array.isArray(size) ? [size[0]] : [size as number];
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,8 +11,8 @@ import BaseModel from '../../core/BaseModel';
|
||||||
import { IPolygonLayerStyleOptions } from '../../core/interface';
|
import { IPolygonLayerStyleOptions } from '../../core/interface';
|
||||||
import { PolygonExtrudeTriangulation } from '../../core/triangulation';
|
import { PolygonExtrudeTriangulation } from '../../core/triangulation';
|
||||||
import polygonExtrudeFrag from '../shaders/extrude/polygon_extrude_frag.glsl';
|
import polygonExtrudeFrag from '../shaders/extrude/polygon_extrude_frag.glsl';
|
||||||
// extrude
|
|
||||||
import polygonExtrudeVert from '../shaders/extrude/polygon_extrude_vert.glsl';
|
import polygonExtrudeVert from '../shaders/extrude/polygon_extrude_vert.glsl';
|
||||||
|
// extrude
|
||||||
import polygonExtrudeTexFrag from '../shaders/extrude/polygon_extrudetex_frag.glsl';
|
import polygonExtrudeTexFrag from '../shaders/extrude/polygon_extrudetex_frag.glsl';
|
||||||
// texture
|
// texture
|
||||||
import polygonExtrudeTexVert from '../shaders/extrude/polygon_extrudetex_vert.glsl';
|
import polygonExtrudeTexVert from '../shaders/extrude/polygon_extrudetex_vert.glsl';
|
||||||
|
@ -95,32 +95,27 @@ export default class ExtrudeModel extends BaseModel {
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
this.loadTexture();
|
this.loadTexture();
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
const {
|
const { mask = false, maskInside = true } =
|
||||||
mask = false,
|
this.layer.getLayerConfig() as IPolygonLayerStyleOptions;
|
||||||
maskInside = true,
|
|
||||||
} = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;
|
|
||||||
|
|
||||||
const { frag, vert, type } = this.getShaders();
|
const { frag, vert, type } = this.getShaders();
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: type,
|
moduleName: type,
|
||||||
vertexShader: vert,
|
vertexShader: vert,
|
||||||
fragmentShader: frag,
|
fragmentShader: frag,
|
||||||
triangulation: PolygonExtrudeTriangulation,
|
triangulation: PolygonExtrudeTriangulation,
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
public getShaders() {
|
public getShaders() {
|
||||||
const {
|
const { pickLight, mapTexture } =
|
||||||
pickLight,
|
this.layer.getLayerConfig() as IPolygonLayerStyleOptions;
|
||||||
mapTexture,
|
|
||||||
} = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;
|
|
||||||
if (mapTexture) {
|
if (mapTexture) {
|
||||||
return {
|
return {
|
||||||
frag: polygonExtrudeTexFrag,
|
frag: polygonExtrudeTexFrag,
|
||||||
|
@ -212,9 +207,7 @@ export default class ExtrudeModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
},
|
},
|
||||||
size: 1,
|
size: 1,
|
||||||
update: (
|
update: (feature: IEncodeFeature) => {
|
||||||
feature: IEncodeFeature,
|
|
||||||
) => {
|
|
||||||
const { size = 10 } = feature;
|
const { size = 10 } = feature;
|
||||||
return Array.isArray(size) ? [size[0]] : [size as number];
|
return Array.isArray(size) ? [size[0]] : [size as number];
|
||||||
},
|
},
|
||||||
|
@ -223,9 +216,8 @@ export default class ExtrudeModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private loadTexture() {
|
private loadTexture() {
|
||||||
const {
|
const { mapTexture } =
|
||||||
mapTexture,
|
this.layer.getLayerConfig() as IPolygonLayerStyleOptions;
|
||||||
} = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;
|
|
||||||
|
|
||||||
const { createTexture2D } = this.rendererService;
|
const { createTexture2D } = this.rendererService;
|
||||||
this.texture = createTexture2D({
|
this.texture = createTexture2D({
|
||||||
|
|
|
@ -53,7 +53,6 @@ export default class FillModel extends BaseModel {
|
||||||
width: 1,
|
width: 1,
|
||||||
height: 1,
|
height: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -70,7 +69,7 @@ export default class FillModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
|
@ -84,8 +83,7 @@ export default class FillModel extends BaseModel {
|
||||||
ILayerConfig & IPolygonLayerStyleOptions
|
ILayerConfig & IPolygonLayerStyleOptions
|
||||||
>;
|
>;
|
||||||
this.layer.triangulation = triangulation;
|
this.layer.triangulation = triangulation;
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: type,
|
moduleName: type,
|
||||||
vertexShader: vert,
|
vertexShader: vert,
|
||||||
fragmentShader: frag,
|
fragmentShader: frag,
|
||||||
|
@ -99,8 +97,8 @@ export default class FillModel extends BaseModel {
|
||||||
modelType: type,
|
modelType: type,
|
||||||
enablePicking,
|
enablePicking,
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels() {
|
public clearModels() {
|
||||||
|
|
|
@ -19,7 +19,7 @@ export type PolygonModelType =
|
||||||
| 'point_extrude'
|
| 'point_extrude'
|
||||||
| 'text'
|
| 'text'
|
||||||
| 'water'
|
| 'water'
|
||||||
| 'ocean'
|
| 'ocean';
|
||||||
const PolygonModels: { [key in PolygonModelType]: any } = {
|
const PolygonModels: { [key in PolygonModelType]: any } = {
|
||||||
fill: FillModel,
|
fill: FillModel,
|
||||||
line: LineModel,
|
line: LineModel,
|
||||||
|
|
|
@ -43,16 +43,13 @@ export default class OceanModel extends BaseModel {
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
this.loadTexture();
|
this.loadTexture();
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
const {
|
const { mask = false, maskInside = true } =
|
||||||
mask = false,
|
this.layer.getLayerConfig() as IPolygonLayerStyleOptions;
|
||||||
maskInside = true,
|
const model = await this.layer.buildLayerModel({
|
||||||
} = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;
|
|
||||||
const model = await this.layer
|
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'polygonOcean',
|
moduleName: 'polygonOcean',
|
||||||
vertexShader: ocean_vert,
|
vertexShader: ocean_vert,
|
||||||
fragmentShader: ocean_frag,
|
fragmentShader: ocean_frag,
|
||||||
|
@ -60,8 +57,8 @@ export default class OceanModel extends BaseModel {
|
||||||
primitive: gl.TRIANGLES,
|
primitive: gl.TRIANGLES,
|
||||||
depth: { enable: false },
|
depth: { enable: false },
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels() {
|
public clearModels() {
|
||||||
|
@ -94,7 +91,10 @@ export default class OceanModel extends BaseModel {
|
||||||
vertex: number[],
|
vertex: number[],
|
||||||
attributeIdx: number,
|
attributeIdx: number,
|
||||||
) => {
|
) => {
|
||||||
const v = (feature.version === Version['GAODE2.x'] ? feature.originCoordinates[0][attributeIdx] : vertex)
|
const v =
|
||||||
|
feature.version === Version['GAODE2.x']
|
||||||
|
? feature.originCoordinates[0][attributeIdx]
|
||||||
|
: vertex;
|
||||||
const [lng, lat] = v;
|
const [lng, lat] = v;
|
||||||
return [(lng - minLng) / lngLen, (lat - minLat) / latLen];
|
return [(lng - minLng) / lngLen, (lat - minLat) / latLen];
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,10 +17,8 @@ import water_vert from '../shaders/water/polygon_water_vert.glsl';
|
||||||
export default class WaterModel extends BaseModel {
|
export default class WaterModel extends BaseModel {
|
||||||
private texture: ITexture2D;
|
private texture: ITexture2D;
|
||||||
public getUninforms() {
|
public getUninforms() {
|
||||||
const {
|
const { opacity = 1, speed = 0.5 } =
|
||||||
opacity = 1,
|
this.layer.getLayerConfig() as IPolygonLayerStyleOptions;
|
||||||
speed = 0.5,
|
|
||||||
} = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;
|
|
||||||
return {
|
return {
|
||||||
u_texture: this.texture,
|
u_texture: this.texture,
|
||||||
u_speed: speed,
|
u_speed: speed,
|
||||||
|
@ -36,16 +34,13 @@ export default class WaterModel extends BaseModel {
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
this.loadTexture();
|
this.loadTexture();
|
||||||
return await this.buildModels();
|
return this.buildModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
const {
|
const { mask = false, maskInside = true } =
|
||||||
mask = false,
|
this.layer.getLayerConfig() as IPolygonLayerStyleOptions;
|
||||||
maskInside = true,
|
const model = await this.layer.buildLayerModel({
|
||||||
} = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;
|
|
||||||
const model = await this.layer
|
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'polygonWater',
|
moduleName: 'polygonWater',
|
||||||
vertexShader: water_vert,
|
vertexShader: water_vert,
|
||||||
fragmentShader: water_frag,
|
fragmentShader: water_frag,
|
||||||
|
@ -53,8 +48,8 @@ export default class WaterModel extends BaseModel {
|
||||||
primitive: gl.TRIANGLES,
|
primitive: gl.TRIANGLES,
|
||||||
depth: { enable: false },
|
depth: { enable: false },
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels() {
|
public clearModels() {
|
||||||
|
@ -83,9 +78,12 @@ export default class WaterModel extends BaseModel {
|
||||||
feature: IEncodeFeature,
|
feature: IEncodeFeature,
|
||||||
featureIdx: number,
|
featureIdx: number,
|
||||||
vertex: number[],
|
vertex: number[],
|
||||||
attributeIdx: number
|
attributeIdx: number,
|
||||||
) => {
|
) => {
|
||||||
const v = (feature.version === Version['GAODE2.x'] ? feature.originCoordinates[0][attributeIdx] : vertex)
|
const v =
|
||||||
|
feature.version === Version['GAODE2.x']
|
||||||
|
? feature.originCoordinates[0][attributeIdx]
|
||||||
|
: vertex;
|
||||||
const [lng, lat] = v;
|
const [lng, lat] = v;
|
||||||
return [(lng - minLng) / lngLen, (lat - minLat) / latLen];
|
return [(lng - minLng) / lngLen, (lat - minLat) / latLen];
|
||||||
},
|
},
|
||||||
|
@ -94,9 +92,8 @@ export default class WaterModel extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private loadTexture() {
|
private loadTexture() {
|
||||||
const {
|
const { waterTexture } =
|
||||||
waterTexture,
|
this.layer.getLayerConfig() as IPolygonLayerStyleOptions;
|
||||||
} = this.layer.getLayerConfig() as IPolygonLayerStyleOptions;
|
|
||||||
|
|
||||||
const { createTexture2D } = this.rendererService;
|
const { createTexture2D } = this.rendererService;
|
||||||
this.texture = createTexture2D({
|
this.texture = createTexture2D({
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
import RasterModel from './raster';
|
import RasterModel from './raster';
|
||||||
import RasterRgbModel from './rasterRgb';
|
import RasterRgbModel from './rasterRgb';
|
||||||
import RasterTerrainRGB from './rasterTerrainRgb';
|
import RasterTerrainRGB from './rasterTerrainRgb';
|
||||||
export type RasterModelType = 'raster' | 'raster3d' | 'rasterRgb' | 'rasterTerrainRgb';
|
export type RasterModelType =
|
||||||
|
| 'raster'
|
||||||
|
| 'raster3d'
|
||||||
|
| 'rasterRgb'
|
||||||
|
| 'rasterTerrainRgb';
|
||||||
|
|
||||||
const RasterModels: { [key in RasterModelType]: any } = {
|
const RasterModels: { [key in RasterModelType]: any } = {
|
||||||
raster: RasterModel,
|
raster: RasterModel,
|
||||||
rasterRgb: RasterRgbModel,
|
rasterRgb: RasterRgbModel,
|
||||||
raster3d: RasterModel,
|
raster3d: RasterModel,
|
||||||
rasterTerrainRgb: RasterTerrainRGB
|
rasterTerrainRgb: RasterTerrainRGB,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default RasterModels;
|
export default RasterModels;
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {
|
||||||
IModel,
|
IModel,
|
||||||
ITexture2D,
|
ITexture2D,
|
||||||
} from '@antv/l7-core';
|
} from '@antv/l7-core';
|
||||||
import { getMask,getDefaultDomain } from '@antv/l7-utils';
|
import { getDefaultDomain, getMask } from '@antv/l7-utils';
|
||||||
import BaseModel from '../../core/BaseModel';
|
import BaseModel from '../../core/BaseModel';
|
||||||
import { IRasterLayerStyleOptions } from '../../core/interface';
|
import { IRasterLayerStyleOptions } from '../../core/interface';
|
||||||
import { RasterImageTriangulation } from '../../core/triangulation';
|
import { RasterImageTriangulation } from '../../core/triangulation';
|
||||||
|
@ -23,8 +23,11 @@ export default class RasterModel extends BaseModel {
|
||||||
domain,
|
domain,
|
||||||
rampColors,
|
rampColors,
|
||||||
} = this.layer.getLayerConfig() as IRasterLayerStyleOptions;
|
} = this.layer.getLayerConfig() as IRasterLayerStyleOptions;
|
||||||
const newdomain = domain ||getDefaultDomain(rampColors)
|
const newdomain = domain || getDefaultDomain(rampColors);
|
||||||
this.colorTexture = this.layer.textureService.getColorTexture(rampColors,newdomain);
|
this.colorTexture = this.layer.textureService.getColorTexture(
|
||||||
|
rampColors,
|
||||||
|
newdomain,
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
u_opacity: opacity || 1,
|
u_opacity: opacity || 1,
|
||||||
u_texture: this.texture,
|
u_texture: this.texture,
|
||||||
|
@ -43,23 +46,21 @@ export default class RasterModel extends BaseModel {
|
||||||
data: parserDataItem.data,
|
data: parserDataItem.data,
|
||||||
width: parserDataItem.width,
|
width: parserDataItem.width,
|
||||||
height: parserDataItem.height,
|
height: parserDataItem.height,
|
||||||
}
|
};
|
||||||
} else {
|
} else {
|
||||||
// 多波段形式、需要进行处理
|
// 多波段形式、需要进行处理
|
||||||
const { rasterData, width, height } = await parserDataItem.data;
|
const { rasterData, width, height } = await parserDataItem.data;
|
||||||
return {
|
return {
|
||||||
data: Array.from(rasterData),
|
data: Array.from(rasterData),
|
||||||
width,
|
width,
|
||||||
height
|
height,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
const {
|
const { mask = false, maskInside = true } =
|
||||||
mask = false,
|
this.layer.getLayerConfig() as IRasterLayerStyleOptions;
|
||||||
maskInside = true,
|
|
||||||
} = this.layer.getLayerConfig() as IRasterLayerStyleOptions;
|
|
||||||
const source = this.layer.getSource();
|
const source = this.layer.getSource();
|
||||||
const { createTexture2D } = this.rendererService;
|
const { createTexture2D } = this.rendererService;
|
||||||
const parserDataItem = source.data.dataArray[0];
|
const parserDataItem = source.data.dataArray[0];
|
||||||
|
@ -75,8 +76,7 @@ export default class RasterModel extends BaseModel {
|
||||||
// aniso: 4,
|
// aniso: 4,
|
||||||
});
|
});
|
||||||
|
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'rasterImageData',
|
moduleName: 'rasterImageData',
|
||||||
vertexShader: rasterVert,
|
vertexShader: rasterVert,
|
||||||
fragmentShader: rasterFrag,
|
fragmentShader: rasterFrag,
|
||||||
|
@ -84,12 +84,12 @@ export default class RasterModel extends BaseModel {
|
||||||
primitive: gl.TRIANGLES,
|
primitive: gl.TRIANGLES,
|
||||||
depth: { enable: false },
|
depth: { enable: false },
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
return await this.initModels();
|
return this.initModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels(): void {
|
public clearModels(): void {
|
||||||
|
@ -121,5 +121,4 @@ export default class RasterModel extends BaseModel {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,17 +9,15 @@ import { getMask } from '@antv/l7-utils';
|
||||||
import BaseModel from '../../core/BaseModel';
|
import BaseModel from '../../core/BaseModel';
|
||||||
import { IRasterLayerStyleOptions } from '../../core/interface';
|
import { IRasterLayerStyleOptions } from '../../core/interface';
|
||||||
import { RasterImageTriangulation } from '../../core/triangulation';
|
import { RasterImageTriangulation } from '../../core/triangulation';
|
||||||
import rasterFrag from '../shaders/raster_rgb_frag.glsl';
|
|
||||||
import rasterVert from '../shaders/raster_2d_vert.glsl';
|
import rasterVert from '../shaders/raster_2d_vert.glsl';
|
||||||
|
import rasterFrag from '../shaders/raster_rgb_frag.glsl';
|
||||||
export default class RasterModel extends BaseModel {
|
export default class RasterModel extends BaseModel {
|
||||||
protected texture: ITexture2D;
|
protected texture: ITexture2D;
|
||||||
protected dataOption: any = {};
|
protected dataOption: any = {};
|
||||||
|
|
||||||
public getUninforms() {
|
public getUninforms() {
|
||||||
const {
|
const { opacity = 1, noDataValue = 0 } =
|
||||||
opacity = 1,
|
this.layer.getLayerConfig() as IRasterLayerStyleOptions;
|
||||||
noDataValue = 0,
|
|
||||||
} = this.layer.getLayerConfig() as IRasterLayerStyleOptions;
|
|
||||||
const { rMinMax, gMinMax, bMinMax } = this.dataOption;
|
const { rMinMax, gMinMax, bMinMax } = this.dataOption;
|
||||||
return {
|
return {
|
||||||
u_opacity: opacity || 1,
|
u_opacity: opacity || 1,
|
||||||
|
@ -28,19 +26,17 @@ export default class RasterModel extends BaseModel {
|
||||||
u_rminmax: rMinMax,
|
u_rminmax: rMinMax,
|
||||||
u_gminmax: gMinMax,
|
u_gminmax: gMinMax,
|
||||||
u_bminmax: bMinMax,
|
u_bminmax: bMinMax,
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getRasterData(parserDataItem: any) {
|
private async getRasterData(parserDataItem: any) {
|
||||||
|
|
||||||
if (Array.isArray(parserDataItem.data)) {
|
if (Array.isArray(parserDataItem.data)) {
|
||||||
const { data, ...rescfg } = parserDataItem;
|
const { data, ...rescfg } = parserDataItem;
|
||||||
this.dataOption = rescfg;
|
this.dataOption = rescfg;
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
...rescfg
|
...rescfg,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const { rasterData, ...rest } = await parserDataItem.data;
|
const { rasterData, ...rest } = await parserDataItem.data;
|
||||||
|
@ -49,23 +45,21 @@ export default class RasterModel extends BaseModel {
|
||||||
// 直接传入波段数据
|
// 直接传入波段数据
|
||||||
return {
|
return {
|
||||||
data: rasterData,
|
data: rasterData,
|
||||||
...rest
|
...rest,
|
||||||
}
|
};
|
||||||
} else {
|
} else {
|
||||||
// 多波段形式、需要进行处理
|
// 多波段形式、需要进行处理
|
||||||
// 支持彩色栅格(多通道)
|
// 支持彩色栅格(多通道)
|
||||||
return {
|
return {
|
||||||
data: Array.from(rasterData),
|
data: Array.from(rasterData),
|
||||||
...rest
|
...rest,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
const {
|
const { mask = false, maskInside = true } =
|
||||||
mask = false,
|
this.layer.getLayerConfig() as IRasterLayerStyleOptions;
|
||||||
maskInside = true,
|
|
||||||
} = this.layer.getLayerConfig() as IRasterLayerStyleOptions;
|
|
||||||
const source = this.layer.getSource();
|
const source = this.layer.getSource();
|
||||||
const { createTexture2D } = this.rendererService;
|
const { createTexture2D } = this.rendererService;
|
||||||
const parserDataItem = source.data.dataArray[0];
|
const parserDataItem = source.data.dataArray[0];
|
||||||
|
@ -79,8 +73,7 @@ export default class RasterModel extends BaseModel {
|
||||||
type: gl.FLOAT,
|
type: gl.FLOAT,
|
||||||
});
|
});
|
||||||
|
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'rasterImageDataRGBA',
|
moduleName: 'rasterImageDataRGBA',
|
||||||
vertexShader: rasterVert,
|
vertexShader: rasterVert,
|
||||||
fragmentShader: rasterFrag,
|
fragmentShader: rasterFrag,
|
||||||
|
@ -88,12 +81,12 @@ export default class RasterModel extends BaseModel {
|
||||||
primitive: gl.TRIANGLES,
|
primitive: gl.TRIANGLES,
|
||||||
depth: { enable: false },
|
depth: { enable: false },
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
return await this.initModels();
|
return this.initModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels(): void {
|
public clearModels(): void {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {
|
||||||
IModelUniform,
|
IModelUniform,
|
||||||
ITexture2D,
|
ITexture2D,
|
||||||
} from '@antv/l7-core';
|
} from '@antv/l7-core';
|
||||||
import { getMask,getDefaultDomain } from '@antv/l7-utils';
|
import { getDefaultDomain, getMask } from '@antv/l7-utils';
|
||||||
import BaseModel from '../../core/BaseModel';
|
import BaseModel from '../../core/BaseModel';
|
||||||
import { IRasterLayerStyleOptions } from '../../core/interface';
|
import { IRasterLayerStyleOptions } from '../../core/interface';
|
||||||
import { RasterImageTriangulation } from '../../core/triangulation';
|
import { RasterImageTriangulation } from '../../core/triangulation';
|
||||||
|
@ -23,14 +23,21 @@ import {
|
||||||
noDataValue = -9999999,
|
noDataValue = -9999999,
|
||||||
domain,
|
domain,
|
||||||
rampColors,
|
rampColors,
|
||||||
colorTexture
|
colorTexture,
|
||||||
} = this.layer.getLayerConfig() as IRasterLayerStyleOptions;
|
} = this.layer.getLayerConfig() as IRasterLayerStyleOptions;
|
||||||
const newdomain = domain ||getDefaultDomain(rampColors)
|
const newdomain = domain || getDefaultDomain(rampColors);
|
||||||
let texture: ITexture2D | undefined = colorTexture;
|
let texture: ITexture2D | undefined = colorTexture;
|
||||||
if (!colorTexture) {
|
if (!colorTexture) {
|
||||||
texture = this.layer.textureService.getColorTexture(rampColors,newdomain) as ITexture2D;
|
texture = this.layer.textureService.getColorTexture(
|
||||||
|
rampColors,
|
||||||
|
newdomain,
|
||||||
|
) as ITexture2D;
|
||||||
} else {
|
} else {
|
||||||
this.layer.textureService.setColorTexture(colorTexture,rampColors,newdomain)
|
this.layer.textureService.setColorTexture(
|
||||||
|
colorTexture,
|
||||||
|
rampColors,
|
||||||
|
newdomain,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
u_opacity: opacity || 1,
|
u_opacity: opacity || 1,
|
||||||
|
@ -43,10 +50,8 @@ import {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public async initModels(): Promise<IModel[]> {
|
public async initModels(): Promise<IModel[]> {
|
||||||
const {
|
const { mask = false, maskInside = true } =
|
||||||
mask = false,
|
this.layer.getLayerConfig() as IRasterLayerStyleOptions;
|
||||||
maskInside = true,
|
|
||||||
} = this.layer.getLayerConfig() as IRasterLayerStyleOptions;
|
|
||||||
|
|
||||||
const source = this.layer.getSource();
|
const source = this.layer.getSource();
|
||||||
const { createTexture2D } = this.rendererService;
|
const { createTexture2D } = this.rendererService;
|
||||||
|
@ -57,8 +62,7 @@ import {
|
||||||
height: imageData[0].height,
|
height: imageData[0].height,
|
||||||
});
|
});
|
||||||
|
|
||||||
const model = await this.layer
|
const model = await this.layer.buildLayerModel({
|
||||||
.buildLayerModel({
|
|
||||||
moduleName: 'RasterTileDataImage',
|
moduleName: 'RasterTileDataImage',
|
||||||
vertexShader: Raster_terrainVert,
|
vertexShader: Raster_terrainVert,
|
||||||
fragmentShader: Raster_terrainFrag,
|
fragmentShader: Raster_terrainFrag,
|
||||||
|
@ -67,8 +71,8 @@ import {
|
||||||
depth: { enable: false },
|
depth: { enable: false },
|
||||||
blend: this.getBlend(),
|
blend: this.getBlend(),
|
||||||
stencil: getMask(mask, maskInside),
|
stencil: getMask(mask, maskInside),
|
||||||
})
|
});
|
||||||
return [model]
|
return [model];
|
||||||
}
|
}
|
||||||
|
|
||||||
public clearModels(): void {
|
public clearModels(): void {
|
||||||
|
@ -76,7 +80,7 @@ import {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async buildModels(): Promise<IModel[]> {
|
public async buildModels(): Promise<IModel[]> {
|
||||||
return await this.initModels();
|
return this.initModels();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected registerBuiltinAttributes() {
|
protected registerBuiltinAttributes() {
|
||||||
|
@ -102,4 +106,3 @@ import {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import {
|
import { IMapService, IRendererService } from '@antv/l7-core';
|
||||||
IMapService,
|
|
||||||
IRendererService
|
|
||||||
} from '@antv/l7-core';
|
|
||||||
import { DOM, SourceTile } from '@antv/l7-utils';
|
import { DOM, SourceTile } from '@antv/l7-utils';
|
||||||
|
|
||||||
export function readRasterValue(
|
export function readRasterValue(
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import {
|
import { ILayer } from '@antv/l7-core';
|
||||||
ILayer,
|
|
||||||
} from '@antv/l7-core';
|
|
||||||
import { decodePickingColor } from '@antv/l7-utils';
|
import { decodePickingColor } from '@antv/l7-utils';
|
||||||
|
|
||||||
export function clearPickState(layers: ILayer[]) {
|
export function clearPickState(layers: ILayer[]) {
|
||||||
|
@ -13,9 +11,13 @@ export function clearPickState(layers: ILayer[]) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setSelect(layers: ILayer[], pickedColors: any, renderList: ILayer[]) {
|
export function setSelect(
|
||||||
|
layers: ILayer[],
|
||||||
|
pickedColors: any,
|
||||||
|
renderList: ILayer[],
|
||||||
|
) {
|
||||||
const selectedId = decodePickingColor(pickedColors);
|
const selectedId = decodePickingColor(pickedColors);
|
||||||
let pickColor
|
let pickColor;
|
||||||
layers.map((layer) => {
|
layers.map((layer) => {
|
||||||
if (
|
if (
|
||||||
layer.getCurrentSelectedId() === null ||
|
layer.getCurrentSelectedId() === null ||
|
||||||
|
@ -33,10 +35,7 @@ export function setSelect(layers: ILayer[], pickedColors: any, renderList: ILaye
|
||||||
// unselect normal layer
|
// unselect normal layer
|
||||||
renderList
|
renderList
|
||||||
.filter(
|
.filter(
|
||||||
(layer) =>
|
(layer) => layer.inited && layer.isVisible() && layer.needPick('click'),
|
||||||
layer.inited &&
|
|
||||||
layer.isVisible() &&
|
|
||||||
layer.needPick('click'),
|
|
||||||
)
|
)
|
||||||
.filter((layer) => layer.getCurrentSelectedId() !== null)
|
.filter((layer) => layer.getCurrentSelectedId() !== null)
|
||||||
.map((layer) => {
|
.map((layer) => {
|
||||||
|
@ -48,7 +47,8 @@ export function setSelect(layers: ILayer[], pickedColors: any, renderList: ILaye
|
||||||
|
|
||||||
export function setHighlight(layers: ILayer[], pickedColors: any) {
|
export function setHighlight(layers: ILayer[], pickedColors: any) {
|
||||||
const pickId = decodePickingColor(pickedColors);
|
const pickId = decodePickingColor(pickedColors);
|
||||||
layers.filter((layer) => layer.inited && layer.isVisible())
|
layers
|
||||||
|
.filter((layer) => layer.inited && layer.isVisible())
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
.filter((layer) => layer.getPickID() !== pickId)
|
.filter((layer) => layer.getPickID() !== pickId)
|
||||||
.map((layer) => {
|
.map((layer) => {
|
||||||
|
@ -58,7 +58,10 @@ export function setHighlight(layers: ILayer[], pickedColors: any) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setPickState(layers: ILayer[], pickColors: { select: any, active: any }) {
|
export function setPickState(
|
||||||
|
layers: ILayer[],
|
||||||
|
pickColors: { select: any; active: any },
|
||||||
|
) {
|
||||||
if (pickColors.select) {
|
if (pickColors.select) {
|
||||||
layers.map((layer) => {
|
layers.map((layer) => {
|
||||||
selectFeature(layer, pickColors.select);
|
selectFeature(layer, pickColors.select);
|
||||||
|
@ -74,7 +77,10 @@ export function setPickState(layers: ILayer[], pickColors: { select: any, active
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function selectFeature(layer: ILayer, pickedColors: Uint8Array | undefined) {
|
export function selectFeature(
|
||||||
|
layer: ILayer,
|
||||||
|
pickedColors: Uint8Array | undefined,
|
||||||
|
) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const [r, g, b] = pickedColors;
|
const [r, g, b] = pickedColors;
|
||||||
layer.hooks.beforeSelect.call([r, g, b]);
|
layer.hooks.beforeSelect.call([r, g, b]);
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import {
|
import {
|
||||||
ILayer,
|
|
||||||
IRendererService,
|
|
||||||
IMapService,
|
|
||||||
ISubLayerInitOptions,
|
|
||||||
createLayerContainer,
|
createLayerContainer,
|
||||||
|
ILayer,
|
||||||
ILayerService,
|
ILayerService,
|
||||||
|
IMapService,
|
||||||
|
IRendererService,
|
||||||
|
ISubLayerInitOptions,
|
||||||
} from '@antv/l7-core';
|
} from '@antv/l7-core';
|
||||||
import { SourceTile } from '@antv/l7-utils';
|
import { SourceTile } from '@antv/l7-utils';
|
||||||
import { Container } from 'inversify';
|
import { Container } from 'inversify';
|
||||||
|
@ -22,7 +22,8 @@ export class Base {
|
||||||
private tileLayerCache: Map<string, ILayer[]> = new Map();
|
private tileLayerCache: Map<string, ILayer[]> = new Map();
|
||||||
|
|
||||||
private async initTileLayers(layers: ILayer[], tile: SourceTile) {
|
private async initTileLayers(layers: ILayer[], tile: SourceTile) {
|
||||||
return Promise.all(layers.map(async (layer) => {
|
return Promise.all(
|
||||||
|
layers.map(async (layer) => {
|
||||||
const container = createLayerContainer(
|
const container = createLayerContainer(
|
||||||
this.parent.sceneContainer as Container,
|
this.parent.sceneContainer as Container,
|
||||||
);
|
);
|
||||||
|
@ -30,8 +31,9 @@ export class Base {
|
||||||
await layer.init();
|
await layer.init();
|
||||||
this.addChild(layer);
|
this.addChild(layer);
|
||||||
tile.layerLoad();
|
tile.layerLoad();
|
||||||
this.render()
|
this.render();
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
|
@ -46,10 +48,11 @@ export class Base {
|
||||||
public async addTile(tile: SourceTile) {
|
public async addTile(tile: SourceTile) {
|
||||||
// oldTile 存在的时候暂时直接结束
|
// oldTile 存在的时候暂时直接结束
|
||||||
// TODO:合并不存在的时候
|
// TODO:合并不存在的时候
|
||||||
if (this.hasTile(tile))
|
if (this.hasTile(tile)) {
|
||||||
return {
|
return {
|
||||||
layers: [],
|
layers: [],
|
||||||
};
|
};
|
||||||
|
}
|
||||||
// 存储当前 tile
|
// 存储当前 tile
|
||||||
this.tileCache.set(tile.key, tile);
|
this.tileCache.set(tile.key, tile);
|
||||||
|
|
||||||
|
@ -68,7 +71,6 @@ export class Base {
|
||||||
// updateLayersConfig(this.getLayers(t),'visible',visible)
|
// updateLayersConfig(this.getLayers(t),'visible',visible)
|
||||||
// })
|
// })
|
||||||
|
|
||||||
|
|
||||||
return layerCollections;
|
return layerCollections;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +103,9 @@ export class Base {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getLayers(tile: SourceTile) {
|
public getLayers(tile: SourceTile) {
|
||||||
if (!tile) return [];
|
if (!tile) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
return this.tileLayerCache.get(tile.key) || [];
|
return this.tileLayerCache.get(tile.key) || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +125,6 @@ export class Base {
|
||||||
}
|
}
|
||||||
|
|
||||||
public initTileFactory() {
|
public initTileFactory() {
|
||||||
|
|
||||||
// this.tileFactory = new TileFactory({
|
// this.tileFactory = new TileFactory({
|
||||||
// parent: this.parent,
|
// parent: this.parent,
|
||||||
// mapService: this.mapService,
|
// mapService: this.mapService,
|
||||||
|
@ -144,13 +147,12 @@ export class Base {
|
||||||
|
|
||||||
public updateTileVisible(tile: SourceTile, layerService: ILayerService) {
|
public updateTileVisible(tile: SourceTile, layerService: ILayerService) {
|
||||||
const layers = this.getLayers(tile);
|
const layers = this.getLayers(tile);
|
||||||
if (layers.length === 0) return;
|
if (layers.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (tile.isVisible) {
|
if (tile.isVisible) {
|
||||||
// 如果可见直接进行渲染,父级发
|
// 如果可见直接进行渲染,父级发
|
||||||
updateLayersConfig(layers, 'visible', tile.isVisible);
|
updateLayersConfig(layers, 'visible', tile.isVisible);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// 如果不可见,放大,等到子瓦片渲染完成,缩小:父级渲染成功
|
// 如果不可见,放大,等到子瓦片渲染完成,缩小:父级渲染成功
|
||||||
// console.log('updateTileVisible',`${tile.x}_${tile.y}_${tile.z}`,tile.isVisible)
|
// console.log('updateTileVisible',`${tile.x}_${tile.y}_${tile.z}`,tile.isVisible)
|
||||||
|
@ -184,14 +186,18 @@ export class Base {
|
||||||
}
|
}
|
||||||
|
|
||||||
public isTileLoaded(tile: SourceTile) {
|
public isTileLoaded(tile: SourceTile) {
|
||||||
if (tile.isLoad) return true;
|
if (tile.isLoad) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
const isLoad = this.getLayers(tile).length === tile.loadedLayers;
|
const isLoad = this.getLayers(tile).length === tile.loadedLayers;
|
||||||
tile.isLoad = isLoad;
|
tile.isLoad = isLoad;
|
||||||
return isLoad;
|
return isLoad;
|
||||||
}
|
}
|
||||||
|
|
||||||
public isTileChildLoaded(tile: SourceTile) {
|
public isTileChildLoaded(tile: SourceTile) {
|
||||||
if (tile.isChildLoad) return true;
|
if (tile.isChildLoad) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
const children = tile.children;
|
const children = tile.children;
|
||||||
const isLoad =
|
const isLoad =
|
||||||
children.filter((child) => this.isTileLoaded(child)).length ===
|
children.filter((child) => this.isTileLoaded(child)).length ===
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
import { ILayer, ILayerService, ILngLat, IRendererService, ITile } from '@antv/l7-core';
|
import {
|
||||||
|
ILayer,
|
||||||
|
ILayerService,
|
||||||
|
ILngLat,
|
||||||
|
IRendererService,
|
||||||
|
ITile,
|
||||||
|
} from '@antv/l7-core';
|
||||||
import { SourceTile } from '@antv/l7-utils';
|
import { SourceTile } from '@antv/l7-utils';
|
||||||
import 'reflect-metadata';
|
import 'reflect-metadata';
|
||||||
|
|
||||||
interface TileLayerServiceOptions {
|
interface ITileLayerServiceOptions {
|
||||||
rendererService: IRendererService;
|
rendererService: IRendererService;
|
||||||
layerService: ILayerService
|
layerService: ILayerService;
|
||||||
parent: ILayer;
|
parent: ILayer;
|
||||||
}
|
}
|
||||||
export class TileLayerService {
|
export class TileLayerService {
|
||||||
|
@ -16,42 +22,47 @@ export class TileLayerService {
|
||||||
private layerService: ILayerService;
|
private layerService: ILayerService;
|
||||||
private parent: ILayer;
|
private parent: ILayer;
|
||||||
|
|
||||||
|
private layerTiles: ITile[] = [];
|
||||||
private _tiles: ITile[] = [];
|
constructor({
|
||||||
constructor({ rendererService,layerService, parent }: TileLayerServiceOptions) {
|
rendererService,
|
||||||
|
layerService,
|
||||||
|
parent,
|
||||||
|
}: ITileLayerServiceOptions) {
|
||||||
this.rendererService = rendererService;
|
this.rendererService = rendererService;
|
||||||
this.layerService = layerService;
|
this.layerService = layerService;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
get tiles(): ITile[] {
|
get tiles(): ITile[] {
|
||||||
return this._tiles;
|
return this.layerTiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasTile(tileKey: string): boolean {
|
public hasTile(tileKey: string): boolean {
|
||||||
return this._tiles.some((tile) => tile.key === tileKey);
|
return this.layerTiles.some((tile) => tile.key === tileKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
addTile(tile: ITile) {
|
public addTile(tile: ITile) {
|
||||||
this._tiles.push(tile);
|
this.layerTiles.push(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTile(tileKey: string): ITile | undefined {
|
public getTile(tileKey: string): ITile | undefined {
|
||||||
return this._tiles.find((tile) => tile.key === tileKey);
|
return this.layerTiles.find((tile) => tile.key === tileKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
getVisibleTileBylngLat(lngLat: ILngLat): ITile | undefined {
|
public getVisibleTileBylngLat(lngLat: ILngLat): ITile | undefined {
|
||||||
// 加载完成 & 可见 & 鼠标选中
|
// 加载完成 & 可见 & 鼠标选中
|
||||||
return this._tiles.find(
|
return this.layerTiles.find(
|
||||||
(tile) => tile.isLoaded && tile.visible && tile.lnglatInBounds(lngLat),
|
(tile) => tile.isLoaded && tile.visible && tile.lnglatInBounds(lngLat),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeTile(tileKey: string) {
|
public removeTile(tileKey: string) {
|
||||||
const index = this._tiles.findIndex((tile) => tile.key === tileKey);
|
const index = this.layerTiles.findIndex((t) => t.key === tileKey);
|
||||||
const tile = this._tiles.splice(index, 1);
|
const tile = this.layerTiles.splice(index, 1);
|
||||||
tile[0] && tile[0].destroy();
|
if (tile[0]) {
|
||||||
|
tile[0].destroy();
|
||||||
}
|
}
|
||||||
updateTileVisible(sourceTile: SourceTile) {
|
}
|
||||||
|
public updateTileVisible(sourceTile: SourceTile) {
|
||||||
const tile = this.getTile(sourceTile.key);
|
const tile = this.getTile(sourceTile.key);
|
||||||
// if(sourceTile.isVisible) {
|
// if(sourceTile.isVisible) {
|
||||||
// // 不可见 => 可见 兄弟节点加载完成
|
// // 不可见 => 可见 兄弟节点加载完成
|
||||||
|
@ -73,60 +84,60 @@ export class TileLayerService {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
tile?.updateVisible(sourceTile.isVisible);
|
tile?.updateVisible(sourceTile.isVisible);
|
||||||
|
|
||||||
}
|
}
|
||||||
public isParentLoaded(sourceTile: SourceTile): boolean {
|
public isParentLoaded(sourceTile: SourceTile): boolean {
|
||||||
const parentTile = sourceTile.parent;
|
const parentTile = sourceTile.parent;
|
||||||
if (!parentTile) {
|
if (!parentTile) {
|
||||||
return true
|
return true;
|
||||||
}
|
}
|
||||||
const tile = this.getTile(parentTile?.key)
|
const tile = this.getTile(parentTile?.key);
|
||||||
if(tile?.isLoaded) { // 递归父级
|
if (tile?.isLoaded) {
|
||||||
return true
|
// 递归父级
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public isChildrenLoaded(sourceTile: SourceTile): boolean {
|
public isChildrenLoaded(sourceTile: SourceTile): boolean {
|
||||||
const childrenTile = sourceTile?.children;
|
const childrenTile = sourceTile?.children;
|
||||||
if (childrenTile.length === 0) {
|
if (childrenTile.length === 0) {
|
||||||
return true
|
return true;
|
||||||
}
|
}
|
||||||
return childrenTile.some((tile: SourceTile) => {
|
return childrenTile.some((tile: SourceTile) => {
|
||||||
const tileLayer = this.getTile(tile?.key)
|
const tileLayer = this.getTile(tile?.key);
|
||||||
return tileLayer?.isLoaded === false
|
return tileLayer?.isLoaded === false;
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
async render() {
|
public async render() {
|
||||||
const layers = this.getRenderLayers();
|
const layers = this.getRenderLayers();
|
||||||
layers.map(async layer => {
|
layers.map(async (layer) => {
|
||||||
await this.layerService.renderLayer(layer);
|
await this.layerService.renderLayer(layer);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getRenderLayers() {
|
public getRenderLayers() {
|
||||||
const tileList = this._tiles.filter((t)=>t.visible && t.isLoaded);
|
const tileList = this.layerTiles.filter(
|
||||||
|
(t: ITile) => t.visible && t.isLoaded,
|
||||||
|
);
|
||||||
const layers: ILayer[] = [];
|
const layers: ILayer[] = [];
|
||||||
tileList.map(tile => layers.push(...tile.getLayers()))
|
tileList.map((tile: ITile) => layers.push(...tile.getLayers()));
|
||||||
return layers;
|
return layers;
|
||||||
}
|
}
|
||||||
|
|
||||||
getLayers(){
|
public getLayers() {
|
||||||
const tileList = this._tiles.filter((t)=>t.isLoaded);
|
const tileList = this.layerTiles.filter((t: ITile) => t.isLoaded);
|
||||||
const layers: ILayer[] = [];
|
const layers: ILayer[] = [];
|
||||||
tileList.map(tile => layers.push(...tile.getLayers()))
|
tileList.map((tile) => layers.push(...tile.getLayers()));
|
||||||
return layers;
|
return layers;
|
||||||
}
|
}
|
||||||
|
|
||||||
getTiles() {
|
public getTiles() {
|
||||||
return this._tiles;
|
return this.layerTiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public destroy() {
|
||||||
destroy() {
|
this.layerTiles.forEach((t: ITile) => t.destroy());
|
||||||
this._tiles.forEach((t) => t.destroy());
|
|
||||||
this.tileResource.clear();
|
this.tileResource.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,10 +124,10 @@ export class TilePickService implements ITilePickService {
|
||||||
// 提取当前可见瓦片
|
// 提取当前可见瓦片
|
||||||
const tiles = this.tileLayerService
|
const tiles = this.tileLayerService
|
||||||
.getTiles()
|
.getTiles()
|
||||||
.filter((tile) => tile.visible);
|
.filter((tile: ITile) => tile.visible);
|
||||||
// 提取当前可见瓦片中匹配 ID 的 feature 列表
|
// 提取当前可见瓦片中匹配 ID 的 feature 列表
|
||||||
const features: any[] = [];
|
const features: any[] = [];
|
||||||
tiles.forEach((tile) => {
|
tiles.forEach((tile: ITile) => {
|
||||||
features.push(...tile.getFeatureById(pickedFeatureIdx));
|
features.push(...tile.getFeatureById(pickedFeatureIdx));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ export class TileSourceService {
|
||||||
const properties = features[0];
|
const properties = features[0];
|
||||||
features.map((feature) => {
|
features.map((feature) => {
|
||||||
const polygon = turf.polygon(feature.coordinates);
|
const polygon = turf.polygon(feature.coordinates);
|
||||||
|
// tslint:disable-next-line: prefer-conditional-expression
|
||||||
if (p === null) {
|
if (p === null) {
|
||||||
p = polygon;
|
p = polygon;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -16,5 +16,4 @@ export const ProxyFuncs = [
|
||||||
'setBlend',
|
'setBlend',
|
||||||
'setSelect',
|
'setSelect',
|
||||||
'setActive',
|
'setActive',
|
||||||
]
|
];
|
||||||
|
|
||||||
|
|
|
@ -14,4 +14,3 @@ export function updateLayersConfig(layers: ILayer[], key: string, value: any) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import Tile from './Tile';
|
|
||||||
import PointLayer from '../../point';
|
|
||||||
import LineLayer from '../../line';
|
import LineLayer from '../../line';
|
||||||
|
import PointLayer from '../../point';
|
||||||
|
import Tile from './Tile';
|
||||||
|
|
||||||
export default class DebugTile extends Tile {
|
export default class DebugTile extends Tile {
|
||||||
public async initTileLayer(): Promise<void> {
|
public async initTileLayer(): Promise<void> {
|
||||||
|
@ -13,22 +13,21 @@ export default class DebugTile extends Tile {
|
||||||
.color('red');
|
.color('red');
|
||||||
const pointLayer = new PointLayer({
|
const pointLayer = new PointLayer({
|
||||||
minZoom: this.z - 1,
|
minZoom: this.z - 1,
|
||||||
maxZoom: this.z+1
|
maxZoom: this.z + 1,
|
||||||
})
|
})
|
||||||
.source([pointData], {
|
.source([pointData], {
|
||||||
parser: {
|
parser: {
|
||||||
type: 'json',
|
type: 'json',
|
||||||
x: 'textLng',
|
x: 'textLng',
|
||||||
y: 'textLat',
|
y: 'textLat',
|
||||||
}
|
},
|
||||||
|
|
||||||
})
|
})
|
||||||
.size(20)
|
.size(20)
|
||||||
.color('red')
|
.color('red')
|
||||||
.shape(this.key)
|
.shape(this.key)
|
||||||
.style({
|
.style({
|
||||||
stroke: '#fff',
|
stroke: '#fff',
|
||||||
strokeWidth: 2
|
strokeWidth: 2,
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.addLayer(lineLayer);
|
await this.addLayer(lineLayer);
|
||||||
|
@ -39,8 +38,7 @@ export default class DebugTile extends Tile {
|
||||||
|
|
||||||
protected getSourceOption() {
|
protected getSourceOption() {
|
||||||
const rawSource = this.parent.getSource();
|
const rawSource = this.parent.getSource();
|
||||||
const features = this.sourceTile.data.layers['testTile']
|
const features = this.sourceTile.data.layers.testTile.features;
|
||||||
.features;
|
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
type: 'FeatureCollection',
|
type: 'FeatureCollection',
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import { ILayerAttributesOption } from '@antv/l7-core';
|
import { ILayerAttributesOption } from '@antv/l7-core';
|
||||||
import ImageLayer from '../../image'
|
import ImageLayer from '../../image';
|
||||||
import Tile from './Tile';
|
import Tile from './Tile';
|
||||||
export default class ImageTile extends Tile {
|
export default class ImageTile extends Tile {
|
||||||
public async initTileLayer(): Promise<void> {
|
public async initTileLayer(): Promise<void> {
|
||||||
|
|
||||||
const attributes = this.parent.getLayerAttributeConfig();
|
const attributes = this.parent.getLayerAttributeConfig();
|
||||||
const layerOptions = this.getLayerOptions();
|
const layerOptions = this.getLayerOptions();
|
||||||
|
|
||||||
|
@ -14,7 +13,9 @@ export default class ImageTile extends Tile {
|
||||||
);
|
);
|
||||||
|
|
||||||
// 初始化数据映射
|
// 初始化数据映射
|
||||||
attributes && Object.keys(attributes).forEach((type) => {
|
// tslint:disable-next-line: no-unused-expression
|
||||||
|
attributes &&
|
||||||
|
Object.keys(attributes).forEach((type) => {
|
||||||
const attr = type as keyof ILayerAttributesOption;
|
const attr = type as keyof ILayerAttributesOption;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
layer[attr](attributes[attr]?.field, attributes[attr]?.values);
|
layer[attr](attributes[attr]?.field, attributes[attr]?.values);
|
||||||
|
|
|
@ -7,11 +7,15 @@ export default class MaskTile extends Tile {
|
||||||
const layerOptions = this.getLayerOptions();
|
const layerOptions = this.getLayerOptions();
|
||||||
|
|
||||||
const sourceOptions = this.getSourceOption();
|
const sourceOptions = this.getSourceOption();
|
||||||
const layer = new MaskLayer({ ...layerOptions})
|
const layer = new MaskLayer({ ...layerOptions }).source(
|
||||||
.source(sourceOptions.data, sourceOptions.options);
|
sourceOptions.data,
|
||||||
|
sourceOptions.options,
|
||||||
|
);
|
||||||
|
|
||||||
// 初始化数据映射
|
// 初始化数据映射
|
||||||
attributes && Object.keys(attributes).forEach((type) => {
|
// tslint:disable-next-line: no-unused-expression
|
||||||
|
attributes &&
|
||||||
|
Object.keys(attributes).forEach((type) => {
|
||||||
const attr = type as keyof ILayerAttributesOption;
|
const attr = type as keyof ILayerAttributesOption;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
layer[attr](attributes[attr]?.field, attributes[attr]?.values);
|
layer[attr](attributes[attr]?.field, attributes[attr]?.values);
|
||||||
|
@ -22,7 +26,9 @@ export default class MaskTile extends Tile {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getFeatures(sourceLayer: string | undefined) {
|
public getFeatures(sourceLayer: string | undefined) {
|
||||||
if(!sourceLayer) return [];
|
if (!sourceLayer) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
const source = this.sourceTile.data;
|
const source = this.sourceTile.data;
|
||||||
return source.getTileData(sourceLayer);
|
return source.getTileData(sourceLayer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { ILayerAttributesOption } from '@antv/l7-core';
|
import { ILayerAttributesOption } from '@antv/l7-core';
|
||||||
import RasterLayer from '../../raster'
|
import RasterLayer from '../../raster';
|
||||||
import Tile from './Tile';
|
import Tile from './Tile';
|
||||||
|
|
||||||
export default class RasterTile extends Tile {
|
export default class RasterTile extends Tile {
|
||||||
|
@ -9,14 +9,12 @@ export default class RasterTile extends Tile {
|
||||||
const sourceOptions = this.getSourceOption();
|
const sourceOptions = this.getSourceOption();
|
||||||
const layer = new RasterLayer({
|
const layer = new RasterLayer({
|
||||||
...layerOptions,
|
...layerOptions,
|
||||||
})
|
}).source(sourceOptions.data, sourceOptions.options);
|
||||||
.source(
|
|
||||||
sourceOptions.data,
|
|
||||||
sourceOptions.options,
|
|
||||||
);
|
|
||||||
|
|
||||||
// 初始化数据映射
|
// 初始化数据映射
|
||||||
attributes && Object.keys(attributes).forEach((type) => {
|
// tslint:disable-next-line: no-unused-expression
|
||||||
|
attributes &&
|
||||||
|
Object.keys(attributes).forEach((type) => {
|
||||||
const attr = type as keyof ILayerAttributesOption;
|
const attr = type as keyof ILayerAttributesOption;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
layer[attr](attributes[attr]?.field, attributes[attr]?.values);
|
layer[attr](attributes[attr]?.field, attributes[attr]?.values);
|
||||||
|
@ -35,7 +33,7 @@ export default class RasterTile extends Tile {
|
||||||
parser: {
|
parser: {
|
||||||
type: 'rasterRgb',
|
type: 'rasterRgb',
|
||||||
extent: this.sourceTile.bounds,
|
extent: this.sourceTile.bounds,
|
||||||
...res
|
...res,
|
||||||
},
|
},
|
||||||
transforms: rawSource.transforms,
|
transforms: rawSource.transforms,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { ILayerAttributesOption } from '@antv/l7-core';
|
import { ILayerAttributesOption } from '@antv/l7-core';
|
||||||
import RasterLayer from '../../raster'
|
import RasterLayer from '../../raster';
|
||||||
import Tile from './Tile';
|
import Tile from './Tile';
|
||||||
export default class RasterTerrainRGBTile extends Tile {
|
export default class RasterTerrainRGBTile extends Tile {
|
||||||
public async initTileLayer(): Promise<void> {
|
public async initTileLayer(): Promise<void> {
|
||||||
|
@ -13,7 +13,9 @@ export default class RasterTerrainRGBTile extends Tile {
|
||||||
);
|
);
|
||||||
|
|
||||||
// 初始化数据映射
|
// 初始化数据映射
|
||||||
attributes && Object.keys(attributes).forEach((type) => {
|
// tslint:disable-next-line: no-unused-expression
|
||||||
|
attributes &&
|
||||||
|
Object.keys(attributes).forEach((type) => {
|
||||||
const attr = type as keyof ILayerAttributesOption;
|
const attr = type as keyof ILayerAttributesOption;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
layer[attr](attributes[attr]?.field, attributes[attr]?.values);
|
layer[attr](attributes[attr]?.field, attributes[attr]?.values);
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue