@antv/l7-layers 2.7.20 → 2.7.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -105,7 +105,7 @@ var BaseModel = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = functi
105
105
 
106
106
  if (!this.dataTextureTest) {
107
107
  this.dataTexture = this.createTexture2D({
108
- data: new Uint8ClampedArray(4),
108
+ data: new Uint8Array(4),
109
109
  mag: gl.NEAREST,
110
110
  min: gl.NEAREST,
111
111
  width: 1,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/BaseModel.ts"],"names":["BlendType","gl","lazyInject","TYPES","rgb2arr","color","BlendTypes","BaseModel","IGlobalConfigService","layer","rendererService","getContainer","get","IRendererService","shaderModuleService","IShaderModuleService","styleAttributeService","IStyleAttributeService","mapService","IMapService","iconService","IIconService","fontService","IFontService","cameraService","ICameraService","layerService","ILayerService","registerBuiltinAttributes","startModelAnimate","createTexture2D","DATA_TEXTURE_WIDTH","rowCount","cellLength","cellProperties","cacheStyleProperties","thetaOffset","undefined","opacity","strokeOpacity","strokeWidth","stroke","offsets","stylePropertyesExist","hasThetaOffset","hasOpacity","hasStrokeOpacity","hasStrokeWidth","hasStroke","hasOffsets","dataTextureTest","getOESTextureFloat","dataTexture","data","Uint8ClampedArray","mag","NEAREST","min","width","height","options","isUpdate","clearLastCalRes","push","attr","count","isStaticColor","isOffsetStatic","strokeColor","length","d","i","cellData","cellPropertiesLayouts","layout","value","patchMod","encodeData","encodeDatalength","Math","ceil","totalLength","patchData","getLayerConfig","blend","Error","option","enable","duration","interval","trailLength","animateOption","setAnimateStartTime"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SACEA,SADF,EAEEC,EAFF,EAwBEC,UAxBF,EA0BEC,KA1BF,QA2BO,eA3BP;AA4BA,SAASC,OAAT,QAAwB,gBAAxB;AACA,SAASC,KAAT,QAAsB,UAAtB;AAEA,SAASC,UAAT,QAA2B,gBAA3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AjB;AACD;;;WACD,2BAAkC;AAChC,aAAO,EAAP;AACD;;;WACD,wBAAqC;AACnC,YAAM,IAAIC,KAAJ,CAAU,yBAAV,CAAN;AACD;;;WAED,8BAA2C;AACzC,aAAO,EAAP;AACD;;;WAED,sBAA6B;AAC3B,aAAO,KAAP;AACD;;;WACD,uBAA+B;AAC7B,YAAM,IAAIA,KAAJ,CAAU,yBAAV,CAAN;AACD;;;WACD,sBAA8B;AAC5B,YAAM,IAAIA,KAAJ,CAAU,yBAAV,CAAN;AACD;;;WACD,uBAAqB;AACnB;AACD;;;WACD,wBAKE;AACA,YAAM,IAAIA,KAAJ,CAAU,yBAAV,CAAN;AACD;;;WACD,kBAAgB;AACd,YAAM,IAAIA,KAAJ,CAAU,yBAAV,CAAN;AACD;;;WACD,qCAAsC;AACpC,YAAM,IAAIA,KAAJ,CAAU,yBAAV,CAAN;AACD;;;WACD,6BAA8BC,MAA9B,EAAgE;AAC9D,aAAO,CACLA,MAAM,CAACC,MAAP,GAAgB,CAAhB,GAAoB,GADf,EAELD,MAAM,CAACE,QAAP,IAAmB,GAFd,EAGLF,MAAM,CAACG,QAAP,IAAmB,GAHd,EAILH,MAAM,CAACI,WAAP,IAAsB,GAJjB,CAAP;AAMD;;;WACD,6BAA8B;AAC5B,iBAA0B,KAAKjF,KAAL,CAAW0E,cAAX,EAA1B;AAAA,UAAQQ,aAAR,QAAQA,aAAR;;AACA,UAAIA,aAAa,CAACJ,MAAlB,EAA0B;AACxB,aAAK9E,KAAL,CAAWmF,mBAAX;AACD;AACF;;;;;;;;;;SAtekBrF,S","sourcesContent":["import {\n BlendType,\n gl,\n IAnimateOption,\n IAttribute,\n IBlendOptions,\n ICameraService,\n IElements,\n IEncodeFeature,\n IFontService,\n IGlobalConfigService,\n IIconService,\n ILayer,\n ILayerConfig,\n ILayerModel,\n ILayerService,\n IMapService,\n IModel,\n IModelUniform,\n IRendererService,\n IShaderModuleService,\n IStyleAttributeService,\n ITexture2D,\n ITexture2DInitializationOptions,\n lazyInject,\n Triangulation,\n TYPES,\n} from '@antv/l7-core';\nimport { rgb2arr } from '@antv/l7-utils';\nimport { color } from 'd3-color';\nimport { isArray, isEqual, isFunction, isNumber, isString } from 'lodash';\nimport { BlendTypes } from '../utils/blend';\n\nexport type styleSingle =\n | number\n | string\n | [string, (single: any) => number]\n | [string, [number, number]];\nexport type styleOffset =\n | string\n | [number, number]\n | [string, (single: any) => number];\nexport type styleColor =\n | string\n | [string, (single: any) => string]\n | [string, [string, string]];\nexport interface IDataTextureFrame {\n data: number[];\n width: number;\n height: number;\n}\n\nexport interface ICellProperty {\n attr: string;\n count: number;\n}\n\nexport default class BaseModel<ChildLayerStyleOptions = {}>\n implements ILayerModel {\n public triangulation: Triangulation;\n\n // style texture data mapping\n public createTexture2D: (\n options: ITexture2DInitializationOptions,\n ) => ITexture2D;\n\n protected layer: ILayer;\n protected dataTexture: ITexture2D; // 用于数据传递的数据纹理\n protected DATA_TEXTURE_WIDTH: number; // 默认有多少列(宽度)\n protected rowCount: number; // 计算得到的当前数据纹理有多少行(高度)\n protected cacheStyleProperties: {\n // 记录存储上一次样式字段的值\n thetaOffset: styleSingle | undefined;\n opacity: styleSingle | undefined;\n strokeOpacity: styleSingle | undefined;\n strokeWidth: styleSingle | undefined;\n stroke: styleColor | undefined;\n offsets: styleOffset | undefined;\n };\n protected cellLength: number; // 单个 cell 的长度\n protected cellProperties: ICellProperty[]; // 需要进行数据映射的属性集合\n protected cellTypeLayout: number[];\n protected stylePropertyesExist: {\n // 记录 style 属性是否存在的中间变量\n hasThetaOffset: number;\n hasOpacity: number;\n hasStrokeOpacity: number;\n hasStrokeWidth: number;\n hasStroke: number;\n hasOffsets: number;\n };\n protected dataTextureTest: boolean;\n\n @lazyInject(TYPES.IGlobalConfigService)\n protected readonly configService: IGlobalConfigService;\n\n // @lazyInject(TYPES.IIconService)\n // protected readonly iconService: IIconService;\n\n // @lazyInject(TYPES.IFontService)\n // protected readonly fontService: IFontService;\n\n // @lazyInject(TYPES.IShaderModuleService)\n protected shaderModuleService: IShaderModuleService;\n\n protected rendererService: IRendererService;\n protected iconService: IIconService;\n protected fontService: IFontService;\n protected styleAttributeService: IStyleAttributeService;\n protected mapService: IMapService;\n protected cameraService: ICameraService;\n protected layerService: ILayerService;\n\n // style texture data mapping\n\n constructor(layer: ILayer) {\n this.layer = layer;\n this.rendererService = layer\n .getContainer()\n .get<IRendererService>(TYPES.IRendererService);\n this.shaderModuleService = layer\n .getContainer()\n .get<IShaderModuleService>(TYPES.IShaderModuleService);\n\n this.styleAttributeService = layer\n .getContainer()\n .get<IStyleAttributeService>(TYPES.IStyleAttributeService);\n this.mapService = layer.getContainer().get<IMapService>(TYPES.IMapService);\n this.iconService = layer\n .getContainer()\n .get<IIconService>(TYPES.IIconService);\n this.fontService = layer\n .getContainer()\n .get<IFontService>(TYPES.IFontService);\n this.cameraService = layer\n .getContainer()\n .get<ICameraService>(TYPES.ICameraService);\n this.layerService = layer\n .getContainer()\n .get<ILayerService>(TYPES.ILayerService);\n\n // 注册 Attribute\n this.registerBuiltinAttributes();\n // 开启动画\n this.startModelAnimate();\n\n const { createTexture2D } = this.rendererService;\n this.createTexture2D = createTexture2D;\n this.DATA_TEXTURE_WIDTH = 1024; // 数据纹理固定宽度\n this.rowCount = 1;\n this.cellLength = 0;\n this.cellProperties = [];\n this.cacheStyleProperties = {\n thetaOffset: undefined,\n opacity: undefined,\n strokeOpacity: undefined,\n strokeWidth: undefined,\n stroke: undefined,\n offsets: undefined,\n };\n this.stylePropertyesExist = {\n hasThetaOffset: 0,\n hasOpacity: 0,\n hasStrokeOpacity: 0,\n hasStrokeWidth: 0,\n hasStroke: 0,\n hasOffsets: 0,\n };\n this.dataTextureTest = this.layerService.getOESTextureFloat();\n // 只有在不支持数据纹理的情况下进行赋值\n if (!this.dataTextureTest) {\n this.dataTexture = this.createTexture2D({\n data: new Uint8ClampedArray(4),\n mag: gl.NEAREST,\n min: gl.NEAREST,\n width: 1,\n height: 1,\n });\n }\n }\n\n // style datatexture mapping\n\n /**\n * 清除上一次的计算结果 - 全量清除\n */\n public clearLastCalRes() {\n this.cellProperties = []; // 清空上一次计算的需要进行数据映射的属性集合\n this.cellLength = 0; // 清空上一次计算的 cell 的长度\n this.stylePropertyesExist = {\n // 全量清空上一次是否需要对 style 属性进行数据映射的判断\n hasThetaOffset: 0,\n hasOpacity: 0,\n hasStrokeOpacity: 0,\n hasStrokeWidth: 0,\n hasStroke: 0,\n hasOffsets: 0,\n };\n }\n\n public getCellTypeLayout() {\n if (this.dataTextureTest) {\n return [\n // 0\n this.rowCount, // 数据纹理有几行\n this.DATA_TEXTURE_WIDTH, // 数据纹理有几列\n 0.0,\n 0.0,\n // 1\n this.stylePropertyesExist.hasOpacity, // cell 中是否存在 opacity\n this.stylePropertyesExist.hasStrokeOpacity, // cell 中是否存在 strokeOpacity\n this.stylePropertyesExist.hasStrokeWidth, // cell 中是否存在 strokeWidth\n this.stylePropertyesExist.hasStroke, // cell 中是否存在 stroke\n // 2\n this.stylePropertyesExist.hasOffsets, // cell 中是否存在 offsets\n this.stylePropertyesExist.hasThetaOffset, // cell 中是否存在 thetaOffset\n 0.0,\n 0.0,\n // 3\n 0.0,\n 0.0,\n 0.0,\n 1.0,\n ];\n } else {\n return [\n 1.0, // 数据纹理有几行\n 1.0, // 数据纹理有几列\n 0.0,\n 0.0,\n 0.0, // cell 中是否存在 opacity\n 0.0, // cell 中是否存在 strokeOpacity\n 0.0, // cell 中是否存在 strokeWidth\n 0.0, // cell 中是否存在 stroke\n 0.0, // cell 中是否存在 offsets\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n -1.0,\n ];\n }\n }\n\n /**\n * 判断数据纹理是否需要重新计算 - 根据传入的值进行判断\n * @param options\n * @returns\n */\n public dataTextureNeedUpdate(options: {\n // TODO: thetaOffset 目前只有 lineLayer/arc 使用\n thetaOffset?: styleSingle;\n opacity?: styleSingle;\n strokeOpacity?: styleSingle;\n strokeWidth?: styleSingle;\n stroke?: styleColor;\n offsets?: styleOffset;\n textOffset?: styleOffset;\n }): boolean {\n let isUpdate = false;\n if (!isEqual(options.thetaOffset, this.cacheStyleProperties.thetaOffset)) {\n isUpdate = true;\n this.cacheStyleProperties.thetaOffset = options.thetaOffset;\n }\n if (!isEqual(options.opacity, this.cacheStyleProperties.opacity)) {\n isUpdate = true;\n this.cacheStyleProperties.opacity = options.opacity;\n }\n if (\n !isEqual(options.strokeOpacity, this.cacheStyleProperties.strokeOpacity)\n ) {\n isUpdate = true;\n this.cacheStyleProperties.strokeOpacity = options.strokeOpacity;\n }\n if (!isEqual(options.strokeWidth, this.cacheStyleProperties.strokeWidth)) {\n isUpdate = true;\n this.cacheStyleProperties.strokeWidth = options.strokeWidth;\n }\n if (!isEqual(options.stroke, this.cacheStyleProperties.stroke)) {\n isUpdate = true;\n this.cacheStyleProperties.stroke = options.stroke;\n }\n if (!isEqual(options.offsets, this.cacheStyleProperties.offsets)) {\n isUpdate = true;\n this.cacheStyleProperties.offsets = options.offsets;\n }\n if (this.dataTexture === undefined) {\n isUpdate = true;\n }\n return isUpdate;\n }\n /**\n * 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n * @param options\n */\n public judgeStyleAttributes(options: {\n // TODO: 目前 thetaOffset 只有 lineLayer/arc 使用\n thetaOffset?: styleSingle;\n opacity?: styleSingle;\n strokeOpacity?: styleSingle;\n strokeWidth?: styleSingle;\n stroke?: styleColor;\n offsets?: styleOffset;\n }) {\n this.clearLastCalRes(); // 清除上一次的计算结果 - 全量清除\n\n if (options.opacity !== undefined && !isNumber(options.opacity)) {\n // 数据映射\n this.cellProperties.push({ attr: 'opacity', count: 1 });\n this.stylePropertyesExist.hasOpacity = 1;\n this.cellLength += 1;\n }\n\n if (\n options.strokeOpacity !== undefined &&\n !isNumber(options.strokeOpacity)\n ) {\n // 数据映射\n this.cellProperties.push({ attr: 'strokeOpacity', count: 1 });\n this.stylePropertyesExist.hasStrokeOpacity = 1;\n this.cellLength += 1;\n }\n\n if (options.strokeWidth !== undefined && !isNumber(options.strokeWidth)) {\n // 数据映射\n this.cellProperties.push({ attr: 'strokeWidth', count: 1 });\n this.stylePropertyesExist.hasStrokeWidth = 1;\n this.cellLength += 1;\n }\n\n if (options.stroke !== undefined && !this.isStaticColor(options.stroke)) {\n // 数据映射\n this.cellProperties.push({ attr: 'stroke', count: 4 });\n this.stylePropertyesExist.hasStroke = 1;\n this.cellLength += 4;\n }\n\n if (\n options.offsets !== undefined &&\n !this.isOffsetStatic(options.offsets)\n ) {\n // 数据映射\n this.cellProperties.push({ attr: 'offsets', count: 2 });\n this.stylePropertyesExist.hasOffsets = 1;\n this.cellLength += 2;\n }\n\n if (options.thetaOffset !== undefined && !isNumber(options.thetaOffset)) {\n // 数据映射\n this.cellProperties.push({ attr: 'thetaOffset', count: 1 });\n this.stylePropertyesExist.hasThetaOffset = 1;\n this.cellLength += 1;\n }\n // console.log('this.cellLength', this.cellLength)\n }\n\n /**\n * 判断变量 stroke 是否是常量值\n * @param stroke\n * @returns\n */\n public isStaticColor(stroke: styleColor): boolean {\n if (isString(stroke)) {\n if (color(stroke)) {\n return true;\n } else {\n return false;\n }\n }\n return false;\n }\n /**\n * 获取 stroke 颜色并做兼容处理\n * @param stroke\n * @returns\n */\n public getStrokeColor(stroke: styleColor) {\n if (this.isStaticColor(stroke)) {\n const strokeColor = rgb2arr(stroke as string);\n strokeColor[0] = strokeColor[0] ? strokeColor[0] : 0;\n strokeColor[1] = strokeColor[1] ? strokeColor[1] : 0;\n strokeColor[2] = strokeColor[2] ? strokeColor[2] : 0;\n strokeColor[3] = strokeColor[3] ? strokeColor[3] : 0;\n return strokeColor;\n } else {\n return [0, 0, 0, 0];\n }\n }\n\n /**\n * 判断 offsets 是否是常量\n * @param offsets\n * @returns\n */\n public isOffsetStatic(offsets: styleOffset) {\n if (\n isArray(offsets) &&\n offsets.length === 2 &&\n isNumber(offsets[0]) &&\n isNumber(offsets[1])\n ) {\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * 补空位\n * @param d\n * @param count\n */\n public patchMod(d: number[], count: number) {\n for (let i = 0; i < count; i++) {\n d.push(-1);\n }\n }\n\n /**\n * 根据映射的数据字段往推入数据\n * @param d\n * @param cellData\n * @param cellPropertiesLayouts\n */\n public patchData(\n d: number[],\n cellData: IEncodeFeature,\n cellPropertiesLayouts: ICellProperty[],\n ) {\n for (const layout of cellPropertiesLayouts) {\n const { attr, count } = layout;\n\n const value = cellData[attr];\n if (value !== undefined) {\n // 数据中存在该属性\n if (attr === 'stroke') {\n d.push(...rgb2arr(value));\n } else if (attr === 'offsets') {\n if (this.isOffsetStatic(value)) {\n d.push(-value[0], value[1]);\n } else {\n d.push(0, 0);\n }\n } else {\n d.push(isNumber(value) ? value : 1.0);\n }\n } else {\n // 若不存在时则补位\n this.patchMod(d, count);\n }\n }\n }\n\n /**\n * 计算推入数据纹理的数据\n * @param cellLength\n * @param encodeData\n * @param cellPropertiesLayouts\n * @returns\n */\n public calDataFrame(\n cellLength: number,\n encodeData: IEncodeFeature[],\n cellPropertiesLayouts: ICellProperty[],\n ): IDataTextureFrame {\n const encodeDatalength = encodeData.length;\n const rowCount = Math.ceil(\n (encodeDatalength * cellLength) / this.DATA_TEXTURE_WIDTH,\n ); // 有多少行\n\n const totalLength = rowCount * this.DATA_TEXTURE_WIDTH;\n const d: number[] = [];\n for (let i = 0; i < encodeDatalength; i++) {\n // 根据 encodeData 数据推入数据\n const cellData = encodeData[i];\n this.patchData(d, cellData, cellPropertiesLayouts);\n }\n for (let i = d.length; i < totalLength; i++) {\n // 每行不足的部分用 -1 补足(数据纹理时 width * height 的矩形数据集合)\n d.push(-1);\n }\n // console.log('data', d)\n return { data: d, width: this.DATA_TEXTURE_WIDTH, height: rowCount };\n }\n\n // style datatexture mapping\n\n public getBlend(): IBlendOptions {\n const { blend = 'normal' } = this.layer.getLayerConfig();\n return BlendTypes[BlendType[blend]] as IBlendOptions;\n }\n public getDefaultStyle(): unknown {\n return {};\n }\n public getUninforms(): IModelUniform {\n throw new Error('Method not implemented.');\n }\n\n public getAnimateUniforms(): IModelUniform {\n return {};\n }\n\n public needUpdate(): boolean {\n return false;\n }\n public buildModels(): IModel[] {\n throw new Error('Method not implemented.');\n }\n public initModels(): IModel[] {\n throw new Error('Method not implemented.');\n }\n public clearModels() {\n return;\n }\n public getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n throw new Error('Method not implemented.');\n }\n public render() {\n throw new Error('Method not implemented.');\n }\n protected registerBuiltinAttributes() {\n throw new Error('Method not implemented.');\n }\n protected animateOption2Array(option: IAnimateOption): number[] {\n return [\n option.enable ? 0 : 1.0,\n option.duration || 4.0,\n option.interval || 0.2,\n option.trailLength || 0.1,\n ];\n }\n protected startModelAnimate() {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n if (animateOption.enable) {\n this.layer.setAnimateStartTime();\n }\n }\n}\n"],"file":"BaseModel.js"}
1
+ {"version":3,"sources":["../../src/core/BaseModel.ts"],"names":["BlendType","gl","lazyInject","TYPES","rgb2arr","color","BlendTypes","BaseModel","IGlobalConfigService","layer","rendererService","getContainer","get","IRendererService","shaderModuleService","IShaderModuleService","styleAttributeService","IStyleAttributeService","mapService","IMapService","iconService","IIconService","fontService","IFontService","cameraService","ICameraService","layerService","ILayerService","registerBuiltinAttributes","startModelAnimate","createTexture2D","DATA_TEXTURE_WIDTH","rowCount","cellLength","cellProperties","cacheStyleProperties","thetaOffset","undefined","opacity","strokeOpacity","strokeWidth","stroke","offsets","stylePropertyesExist","hasThetaOffset","hasOpacity","hasStrokeOpacity","hasStrokeWidth","hasStroke","hasOffsets","dataTextureTest","getOESTextureFloat","dataTexture","data","Uint8Array","mag","NEAREST","min","width","height","options","isUpdate","clearLastCalRes","push","attr","count","isStaticColor","isOffsetStatic","strokeColor","length","d","i","cellData","cellPropertiesLayouts","layout","value","patchMod","encodeData","encodeDatalength","Math","ceil","totalLength","patchData","getLayerConfig","blend","Error","option","enable","duration","interval","trailLength","animateOption","setAnimateStartTime"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SACEA,SADF,EAEEC,EAFF,EAwBEC,UAxBF,EA0BEC,KA1BF,QA2BO,eA3BP;AA4BA,SAASC,OAAT,QAAwB,gBAAxB;AACA,SAASC,KAAT,QAAsB,UAAtB;AAEA,SAASC,UAAT,QAA2B,gBAA3B;IA0BqBC,S,WAoClBL,UAAU,CAACC,KAAK,CAACK,oBAAP,C;AAsBX,qBAAYC,KAAZ,EAA2B;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AACzB,SAAKA,KAAL,GAAaA,KAAb;AACA,SAAKC,eAAL,GAAuBD,KAAK,CACzBE,YADoB,GAEpBC,GAFoB,CAEET,KAAK,CAACU,gBAFR,CAAvB;AAGA,SAAKC,mBAAL,GAA2BL,KAAK,CAC7BE,YADwB,GAExBC,GAFwB,CAEET,KAAK,CAACY,oBAFR,CAA3B;AAIA,SAAKC,qBAAL,GAA6BP,KAAK,CAC/BE,YAD0B,GAE1BC,GAF0B,CAEET,KAAK,CAACc,sBAFR,CAA7B;AAGA,SAAKC,UAAL,GAAkBT,KAAK,CAACE,YAAN,GAAqBC,GAArB,CAAsCT,KAAK,CAACgB,WAA5C,CAAlB;AACA,SAAKC,WAAL,GAAmBX,KAAK,CACrBE,YADgB,GAEhBC,GAFgB,CAEET,KAAK,CAACkB,YAFR,CAAnB;AAGA,SAAKC,WAAL,GAAmBb,KAAK,CACrBE,YADgB,GAEhBC,GAFgB,CAEET,KAAK,CAACoB,YAFR,CAAnB;AAGA,SAAKC,aAAL,GAAqBf,KAAK,CACvBE,YADkB,GAElBC,GAFkB,CAEET,KAAK,CAACsB,cAFR,CAArB;AAGA,SAAKC,YAAL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;;;SAzekBrF,S","sourcesContent":["import {\n BlendType,\n gl,\n IAnimateOption,\n IAttribute,\n IBlendOptions,\n ICameraService,\n IElements,\n IEncodeFeature,\n IFontService,\n IGlobalConfigService,\n IIconService,\n ILayer,\n ILayerConfig,\n ILayerModel,\n ILayerService,\n IMapService,\n IModel,\n IModelUniform,\n IRendererService,\n IShaderModuleService,\n IStyleAttributeService,\n ITexture2D,\n ITexture2DInitializationOptions,\n lazyInject,\n Triangulation,\n TYPES,\n} from '@antv/l7-core';\nimport { rgb2arr } from '@antv/l7-utils';\nimport { color } from 'd3-color';\nimport { isArray, isEqual, isFunction, isNumber, isString } from 'lodash';\nimport { BlendTypes } from '../utils/blend';\n\nexport type styleSingle =\n | number\n | string\n | [string, (single: any) => number]\n | [string, [number, number]];\nexport type styleOffset =\n | string\n | [number, number]\n | [string, (single: any) => number];\nexport type styleColor =\n | string\n | [string, (single: any) => string]\n | [string, [string, string]];\nexport interface IDataTextureFrame {\n data: number[];\n width: number;\n height: number;\n}\n\nexport interface ICellProperty {\n attr: string;\n count: number;\n}\n\nexport default class BaseModel<ChildLayerStyleOptions = {}>\n implements ILayerModel {\n public triangulation: Triangulation;\n\n // style texture data mapping\n public createTexture2D: (\n options: ITexture2DInitializationOptions,\n ) => ITexture2D;\n\n protected layer: ILayer;\n protected dataTexture: ITexture2D; // 用于数据传递的数据纹理\n protected DATA_TEXTURE_WIDTH: number; // 默认有多少列(宽度)\n protected rowCount: number; // 计算得到的当前数据纹理有多少行(高度)\n protected cacheStyleProperties: {\n // 记录存储上一次样式字段的值\n thetaOffset: styleSingle | undefined;\n opacity: styleSingle | undefined;\n strokeOpacity: styleSingle | undefined;\n strokeWidth: styleSingle | undefined;\n stroke: styleColor | undefined;\n offsets: styleOffset | undefined;\n };\n protected cellLength: number; // 单个 cell 的长度\n protected cellProperties: ICellProperty[]; // 需要进行数据映射的属性集合\n protected cellTypeLayout: number[];\n protected stylePropertyesExist: {\n // 记录 style 属性是否存在的中间变量\n hasThetaOffset: number;\n hasOpacity: number;\n hasStrokeOpacity: number;\n hasStrokeWidth: number;\n hasStroke: number;\n hasOffsets: number;\n };\n protected dataTextureTest: boolean;\n\n @lazyInject(TYPES.IGlobalConfigService)\n protected readonly configService: IGlobalConfigService;\n\n // @lazyInject(TYPES.IIconService)\n // protected readonly iconService: IIconService;\n\n // @lazyInject(TYPES.IFontService)\n // protected readonly fontService: IFontService;\n\n // @lazyInject(TYPES.IShaderModuleService)\n protected shaderModuleService: IShaderModuleService;\n\n protected rendererService: IRendererService;\n protected iconService: IIconService;\n protected fontService: IFontService;\n protected styleAttributeService: IStyleAttributeService;\n protected mapService: IMapService;\n protected cameraService: ICameraService;\n protected layerService: ILayerService;\n\n // style texture data mapping\n\n constructor(layer: ILayer) {\n this.layer = layer;\n this.rendererService = layer\n .getContainer()\n .get<IRendererService>(TYPES.IRendererService);\n this.shaderModuleService = layer\n .getContainer()\n .get<IShaderModuleService>(TYPES.IShaderModuleService);\n\n this.styleAttributeService = layer\n .getContainer()\n .get<IStyleAttributeService>(TYPES.IStyleAttributeService);\n this.mapService = layer.getContainer().get<IMapService>(TYPES.IMapService);\n this.iconService = layer\n .getContainer()\n .get<IIconService>(TYPES.IIconService);\n this.fontService = layer\n .getContainer()\n .get<IFontService>(TYPES.IFontService);\n this.cameraService = layer\n .getContainer()\n .get<ICameraService>(TYPES.ICameraService);\n this.layerService = layer\n .getContainer()\n .get<ILayerService>(TYPES.ILayerService);\n\n // 注册 Attribute\n this.registerBuiltinAttributes();\n // 开启动画\n this.startModelAnimate();\n\n const { createTexture2D } = this.rendererService;\n this.createTexture2D = createTexture2D;\n this.DATA_TEXTURE_WIDTH = 1024; // 数据纹理固定宽度\n this.rowCount = 1;\n this.cellLength = 0;\n this.cellProperties = [];\n this.cacheStyleProperties = {\n thetaOffset: undefined,\n opacity: undefined,\n strokeOpacity: undefined,\n strokeWidth: undefined,\n stroke: undefined,\n offsets: undefined,\n };\n this.stylePropertyesExist = {\n hasThetaOffset: 0,\n hasOpacity: 0,\n hasStrokeOpacity: 0,\n hasStrokeWidth: 0,\n hasStroke: 0,\n hasOffsets: 0,\n };\n this.dataTextureTest = this.layerService.getOESTextureFloat();\n // 只有在不支持数据纹理的情况下进行赋值\n if (!this.dataTextureTest) {\n this.dataTexture = this.createTexture2D({\n // data: new Uint8ClampedArray(4),\n // 使用 Uint8ClampedArray 在 支付宝 环境中可能存在问题 UC 内核对格式有要求 L7 v2.7.18 版本发现\n // Uint8ClampedArray 和 Uint8Array 没有实质性的区别\n data: new Uint8Array(4),\n mag: gl.NEAREST,\n min: gl.NEAREST,\n width: 1,\n height: 1,\n });\n }\n }\n\n // style datatexture mapping\n\n /**\n * 清除上一次的计算结果 - 全量清除\n */\n public clearLastCalRes() {\n this.cellProperties = []; // 清空上一次计算的需要进行数据映射的属性集合\n this.cellLength = 0; // 清空上一次计算的 cell 的长度\n this.stylePropertyesExist = {\n // 全量清空上一次是否需要对 style 属性进行数据映射的判断\n hasThetaOffset: 0,\n hasOpacity: 0,\n hasStrokeOpacity: 0,\n hasStrokeWidth: 0,\n hasStroke: 0,\n hasOffsets: 0,\n };\n }\n\n public getCellTypeLayout() {\n if (this.dataTextureTest) {\n return [\n // 0\n this.rowCount, // 数据纹理有几行\n this.DATA_TEXTURE_WIDTH, // 数据纹理有几列\n 0.0,\n 0.0,\n // 1\n this.stylePropertyesExist.hasOpacity, // cell 中是否存在 opacity\n this.stylePropertyesExist.hasStrokeOpacity, // cell 中是否存在 strokeOpacity\n this.stylePropertyesExist.hasStrokeWidth, // cell 中是否存在 strokeWidth\n this.stylePropertyesExist.hasStroke, // cell 中是否存在 stroke\n // 2\n this.stylePropertyesExist.hasOffsets, // cell 中是否存在 offsets\n this.stylePropertyesExist.hasThetaOffset, // cell 中是否存在 thetaOffset\n 0.0,\n 0.0,\n // 3\n 0.0,\n 0.0,\n 0.0,\n 1.0,\n ];\n } else {\n return [\n 1.0, // 数据纹理有几行\n 1.0, // 数据纹理有几列\n 0.0,\n 0.0,\n 0.0, // cell 中是否存在 opacity\n 0.0, // cell 中是否存在 strokeOpacity\n 0.0, // cell 中是否存在 strokeWidth\n 0.0, // cell 中是否存在 stroke\n 0.0, // cell 中是否存在 offsets\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n -1.0,\n ];\n }\n }\n\n /**\n * 判断数据纹理是否需要重新计算 - 根据传入的值进行判断\n * @param options\n * @returns\n */\n public dataTextureNeedUpdate(options: {\n // TODO: thetaOffset 目前只有 lineLayer/arc 使用\n thetaOffset?: styleSingle;\n opacity?: styleSingle;\n strokeOpacity?: styleSingle;\n strokeWidth?: styleSingle;\n stroke?: styleColor;\n offsets?: styleOffset;\n textOffset?: styleOffset;\n }): boolean {\n let isUpdate = false;\n if (!isEqual(options.thetaOffset, this.cacheStyleProperties.thetaOffset)) {\n isUpdate = true;\n this.cacheStyleProperties.thetaOffset = options.thetaOffset;\n }\n if (!isEqual(options.opacity, this.cacheStyleProperties.opacity)) {\n isUpdate = true;\n this.cacheStyleProperties.opacity = options.opacity;\n }\n if (\n !isEqual(options.strokeOpacity, this.cacheStyleProperties.strokeOpacity)\n ) {\n isUpdate = true;\n this.cacheStyleProperties.strokeOpacity = options.strokeOpacity;\n }\n if (!isEqual(options.strokeWidth, this.cacheStyleProperties.strokeWidth)) {\n isUpdate = true;\n this.cacheStyleProperties.strokeWidth = options.strokeWidth;\n }\n if (!isEqual(options.stroke, this.cacheStyleProperties.stroke)) {\n isUpdate = true;\n this.cacheStyleProperties.stroke = options.stroke;\n }\n if (!isEqual(options.offsets, this.cacheStyleProperties.offsets)) {\n isUpdate = true;\n this.cacheStyleProperties.offsets = options.offsets;\n }\n if (this.dataTexture === undefined) {\n isUpdate = true;\n }\n return isUpdate;\n }\n /**\n * 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n * @param options\n */\n public judgeStyleAttributes(options: {\n // TODO: 目前 thetaOffset 只有 lineLayer/arc 使用\n thetaOffset?: styleSingle;\n opacity?: styleSingle;\n strokeOpacity?: styleSingle;\n strokeWidth?: styleSingle;\n stroke?: styleColor;\n offsets?: styleOffset;\n }) {\n this.clearLastCalRes(); // 清除上一次的计算结果 - 全量清除\n\n if (options.opacity !== undefined && !isNumber(options.opacity)) {\n // 数据映射\n this.cellProperties.push({ attr: 'opacity', count: 1 });\n this.stylePropertyesExist.hasOpacity = 1;\n this.cellLength += 1;\n }\n\n if (\n options.strokeOpacity !== undefined &&\n !isNumber(options.strokeOpacity)\n ) {\n // 数据映射\n this.cellProperties.push({ attr: 'strokeOpacity', count: 1 });\n this.stylePropertyesExist.hasStrokeOpacity = 1;\n this.cellLength += 1;\n }\n\n if (options.strokeWidth !== undefined && !isNumber(options.strokeWidth)) {\n // 数据映射\n this.cellProperties.push({ attr: 'strokeWidth', count: 1 });\n this.stylePropertyesExist.hasStrokeWidth = 1;\n this.cellLength += 1;\n }\n\n if (options.stroke !== undefined && !this.isStaticColor(options.stroke)) {\n // 数据映射\n this.cellProperties.push({ attr: 'stroke', count: 4 });\n this.stylePropertyesExist.hasStroke = 1;\n this.cellLength += 4;\n }\n\n if (\n options.offsets !== undefined &&\n !this.isOffsetStatic(options.offsets)\n ) {\n // 数据映射\n this.cellProperties.push({ attr: 'offsets', count: 2 });\n this.stylePropertyesExist.hasOffsets = 1;\n this.cellLength += 2;\n }\n\n if (options.thetaOffset !== undefined && !isNumber(options.thetaOffset)) {\n // 数据映射\n this.cellProperties.push({ attr: 'thetaOffset', count: 1 });\n this.stylePropertyesExist.hasThetaOffset = 1;\n this.cellLength += 1;\n }\n // console.log('this.cellLength', this.cellLength)\n }\n\n /**\n * 判断变量 stroke 是否是常量值\n * @param stroke\n * @returns\n */\n public isStaticColor(stroke: styleColor): boolean {\n if (isString(stroke)) {\n if (color(stroke)) {\n return true;\n } else {\n return false;\n }\n }\n return false;\n }\n /**\n * 获取 stroke 颜色并做兼容处理\n * @param stroke\n * @returns\n */\n public getStrokeColor(stroke: styleColor) {\n if (this.isStaticColor(stroke)) {\n const strokeColor = rgb2arr(stroke as string);\n strokeColor[0] = strokeColor[0] ? strokeColor[0] : 0;\n strokeColor[1] = strokeColor[1] ? strokeColor[1] : 0;\n strokeColor[2] = strokeColor[2] ? strokeColor[2] : 0;\n strokeColor[3] = strokeColor[3] ? strokeColor[3] : 0;\n return strokeColor;\n } else {\n return [0, 0, 0, 0];\n }\n }\n\n /**\n * 判断 offsets 是否是常量\n * @param offsets\n * @returns\n */\n public isOffsetStatic(offsets: styleOffset) {\n if (\n isArray(offsets) &&\n offsets.length === 2 &&\n isNumber(offsets[0]) &&\n isNumber(offsets[1])\n ) {\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * 补空位\n * @param d\n * @param count\n */\n public patchMod(d: number[], count: number) {\n for (let i = 0; i < count; i++) {\n d.push(-1);\n }\n }\n\n /**\n * 根据映射的数据字段往推入数据\n * @param d\n * @param cellData\n * @param cellPropertiesLayouts\n */\n public patchData(\n d: number[],\n cellData: IEncodeFeature,\n cellPropertiesLayouts: ICellProperty[],\n ) {\n for (const layout of cellPropertiesLayouts) {\n const { attr, count } = layout;\n\n const value = cellData[attr];\n if (value !== undefined) {\n // 数据中存在该属性\n if (attr === 'stroke') {\n d.push(...rgb2arr(value));\n } else if (attr === 'offsets') {\n if (this.isOffsetStatic(value)) {\n d.push(-value[0], value[1]);\n } else {\n d.push(0, 0);\n }\n } else {\n d.push(isNumber(value) ? value : 1.0);\n }\n } else {\n // 若不存在时则补位\n this.patchMod(d, count);\n }\n }\n }\n\n /**\n * 计算推入数据纹理的数据\n * @param cellLength\n * @param encodeData\n * @param cellPropertiesLayouts\n * @returns\n */\n public calDataFrame(\n cellLength: number,\n encodeData: IEncodeFeature[],\n cellPropertiesLayouts: ICellProperty[],\n ): IDataTextureFrame {\n const encodeDatalength = encodeData.length;\n const rowCount = Math.ceil(\n (encodeDatalength * cellLength) / this.DATA_TEXTURE_WIDTH,\n ); // 有多少行\n\n const totalLength = rowCount * this.DATA_TEXTURE_WIDTH;\n const d: number[] = [];\n for (let i = 0; i < encodeDatalength; i++) {\n // 根据 encodeData 数据推入数据\n const cellData = encodeData[i];\n this.patchData(d, cellData, cellPropertiesLayouts);\n }\n for (let i = d.length; i < totalLength; i++) {\n // 每行不足的部分用 -1 补足(数据纹理时 width * height 的矩形数据集合)\n d.push(-1);\n }\n // console.log('data', d)\n return { data: d, width: this.DATA_TEXTURE_WIDTH, height: rowCount };\n }\n\n // style datatexture mapping\n\n public getBlend(): IBlendOptions {\n const { blend = 'normal' } = this.layer.getLayerConfig();\n return BlendTypes[BlendType[blend]] as IBlendOptions;\n }\n public getDefaultStyle(): unknown {\n return {};\n }\n public getUninforms(): IModelUniform {\n throw new Error('Method not implemented.');\n }\n\n public getAnimateUniforms(): IModelUniform {\n return {};\n }\n\n public needUpdate(): boolean {\n return false;\n }\n public buildModels(): IModel[] {\n throw new Error('Method not implemented.');\n }\n public initModels(): IModel[] {\n throw new Error('Method not implemented.');\n }\n public clearModels() {\n return;\n }\n public getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n throw new Error('Method not implemented.');\n }\n public render() {\n throw new Error('Method not implemented.');\n }\n protected registerBuiltinAttributes() {\n throw new Error('Method not implemented.');\n }\n protected animateOption2Array(option: IAnimateOption): number[] {\n return [\n option.enable ? 0 : 1.0,\n option.duration || 4.0,\n option.interval || 0.2,\n option.trailLength || 0.1,\n ];\n }\n protected startModelAnimate() {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n if (animateOption.enable) {\n this.layer.setAnimateStartTime();\n }\n }\n}\n"],"file":"BaseModel.js"}
@@ -106,7 +106,7 @@ var BaseModel = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
106
106
 
107
107
  if (!this.dataTextureTest) {
108
108
  this.dataTexture = this.createTexture2D({
109
- data: new Uint8ClampedArray(4),
109
+ data: new Uint8Array(4),
110
110
  mag: _l7Core.gl.NEAREST,
111
111
  min: _l7Core.gl.NEAREST,
112
112
  width: 1,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/BaseModel.ts"],"names":["BaseModel","TYPES","IGlobalConfigService","layer","rendererService","getContainer","get","IRendererService","shaderModuleService","IShaderModuleService","styleAttributeService","IStyleAttributeService","mapService","IMapService","iconService","IIconService","fontService","IFontService","cameraService","ICameraService","layerService","ILayerService","registerBuiltinAttributes","startModelAnimate","createTexture2D","DATA_TEXTURE_WIDTH","rowCount","cellLength","cellProperties","cacheStyleProperties","thetaOffset","undefined","opacity","strokeOpacity","strokeWidth","stroke","offsets","stylePropertyesExist","hasThetaOffset","hasOpacity","hasStrokeOpacity","hasStrokeWidth","hasStroke","hasOffsets","dataTextureTest","getOESTextureFloat","dataTexture","data","Uint8ClampedArray","mag","gl","NEAREST","min","width","height","options","isUpdate","clearLastCalRes","push","attr","count","isStaticColor","isOffsetStatic","strokeColor","length","d","i","cellData","cellPropertiesLayouts","layout","value","patchMod","encodeData","encodeDatalength","Math","ceil","totalLength","patchData","getLayerConfig","blend","BlendTypes","BlendType","Error","option","enable","duration","interval","trailLength","animateOption","setAnimateStartTime"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AA4BA;;AACA;;AAEA;;;;;;;;;;IA0BqBA,S,WAoClB,wBAAWC,cAAMC,oBAAjB,C;AAsBD,qBAAYC,KAAZ,EAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACzB,SAAKA,KAAL,GAAaA,KAAb;AACA,SAAKC,eAAL,GAAuBD,KAAK,CACzBE,YADoB,GAEpBC,GAFoB,CAEEL,cAAMM,gBAFR,CAAvB;AAGA,SAAKC,mBAAL,GAA2BL,KAAK,CAC7BE,YADwB,GAExBC,GAFwB,CAEEL,cAAMQ,oBAFR,CAA3B;AAIA,SAAK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,yBAAV,CAAN;AACD;;;WACD,6BAA8BC,MAA9B,EAAgE;AAC9D,aAAO,CACLA,MAAM,CAACC,MAAP,GAAgB,CAAhB,GAAoB,GADf,EAELD,MAAM,CAACE,QAAP,IAAmB,GAFd,EAGLF,MAAM,CAACG,QAAP,IAAmB,GAHd,EAILH,MAAM,CAACI,WAAP,IAAsB,GAJjB,CAAP;AAMD;;;WACD,6BAA8B;AAC5B,iBAA0B,KAAKpF,KAAL,CAAW2E,cAAX,EAA1B;AAAA,UAAQU,aAAR,QAAQA,aAAR;;AACA,UAAIA,aAAa,CAACJ,MAAlB,EAA0B;AACxB,aAAKjF,KAAL,CAAWsF,mBAAX;AACD;AACF","sourcesContent":["import {\n BlendType,\n gl,\n IAnimateOption,\n IAttribute,\n IBlendOptions,\n ICameraService,\n IElements,\n IEncodeFeature,\n IFontService,\n IGlobalConfigService,\n IIconService,\n ILayer,\n ILayerConfig,\n ILayerModel,\n ILayerService,\n IMapService,\n IModel,\n IModelUniform,\n IRendererService,\n IShaderModuleService,\n IStyleAttributeService,\n ITexture2D,\n ITexture2DInitializationOptions,\n lazyInject,\n Triangulation,\n TYPES,\n} from '@antv/l7-core';\nimport { rgb2arr } from '@antv/l7-utils';\nimport { color } from 'd3-color';\nimport { isArray, isEqual, isFunction, isNumber, isString } from 'lodash';\nimport { BlendTypes } from '../utils/blend';\n\nexport type styleSingle =\n | number\n | string\n | [string, (single: any) => number]\n | [string, [number, number]];\nexport type styleOffset =\n | string\n | [number, number]\n | [string, (single: any) => number];\nexport type styleColor =\n | string\n | [string, (single: any) => string]\n | [string, [string, string]];\nexport interface IDataTextureFrame {\n data: number[];\n width: number;\n height: number;\n}\n\nexport interface ICellProperty {\n attr: string;\n count: number;\n}\n\nexport default class BaseModel<ChildLayerStyleOptions = {}>\n implements ILayerModel {\n public triangulation: Triangulation;\n\n // style texture data mapping\n public createTexture2D: (\n options: ITexture2DInitializationOptions,\n ) => ITexture2D;\n\n protected layer: ILayer;\n protected dataTexture: ITexture2D; // 用于数据传递的数据纹理\n protected DATA_TEXTURE_WIDTH: number; // 默认有多少列(宽度)\n protected rowCount: number; // 计算得到的当前数据纹理有多少行(高度)\n protected cacheStyleProperties: {\n // 记录存储上一次样式字段的值\n thetaOffset: styleSingle | undefined;\n opacity: styleSingle | undefined;\n strokeOpacity: styleSingle | undefined;\n strokeWidth: styleSingle | undefined;\n stroke: styleColor | undefined;\n offsets: styleOffset | undefined;\n };\n protected cellLength: number; // 单个 cell 的长度\n protected cellProperties: ICellProperty[]; // 需要进行数据映射的属性集合\n protected cellTypeLayout: number[];\n protected stylePropertyesExist: {\n // 记录 style 属性是否存在的中间变量\n hasThetaOffset: number;\n hasOpacity: number;\n hasStrokeOpacity: number;\n hasStrokeWidth: number;\n hasStroke: number;\n hasOffsets: number;\n };\n protected dataTextureTest: boolean;\n\n @lazyInject(TYPES.IGlobalConfigService)\n protected readonly configService: IGlobalConfigService;\n\n // @lazyInject(TYPES.IIconService)\n // protected readonly iconService: IIconService;\n\n // @lazyInject(TYPES.IFontService)\n // protected readonly fontService: IFontService;\n\n // @lazyInject(TYPES.IShaderModuleService)\n protected shaderModuleService: IShaderModuleService;\n\n protected rendererService: IRendererService;\n protected iconService: IIconService;\n protected fontService: IFontService;\n protected styleAttributeService: IStyleAttributeService;\n protected mapService: IMapService;\n protected cameraService: ICameraService;\n protected layerService: ILayerService;\n\n // style texture data mapping\n\n constructor(layer: ILayer) {\n this.layer = layer;\n this.rendererService = layer\n .getContainer()\n .get<IRendererService>(TYPES.IRendererService);\n this.shaderModuleService = layer\n .getContainer()\n .get<IShaderModuleService>(TYPES.IShaderModuleService);\n\n this.styleAttributeService = layer\n .getContainer()\n .get<IStyleAttributeService>(TYPES.IStyleAttributeService);\n this.mapService = layer.getContainer().get<IMapService>(TYPES.IMapService);\n this.iconService = layer\n .getContainer()\n .get<IIconService>(TYPES.IIconService);\n this.fontService = layer\n .getContainer()\n .get<IFontService>(TYPES.IFontService);\n this.cameraService = layer\n .getContainer()\n .get<ICameraService>(TYPES.ICameraService);\n this.layerService = layer\n .getContainer()\n .get<ILayerService>(TYPES.ILayerService);\n\n // 注册 Attribute\n this.registerBuiltinAttributes();\n // 开启动画\n this.startModelAnimate();\n\n const { createTexture2D } = this.rendererService;\n this.createTexture2D = createTexture2D;\n this.DATA_TEXTURE_WIDTH = 1024; // 数据纹理固定宽度\n this.rowCount = 1;\n this.cellLength = 0;\n this.cellProperties = [];\n this.cacheStyleProperties = {\n thetaOffset: undefined,\n opacity: undefined,\n strokeOpacity: undefined,\n strokeWidth: undefined,\n stroke: undefined,\n offsets: undefined,\n };\n this.stylePropertyesExist = {\n hasThetaOffset: 0,\n hasOpacity: 0,\n hasStrokeOpacity: 0,\n hasStrokeWidth: 0,\n hasStroke: 0,\n hasOffsets: 0,\n };\n this.dataTextureTest = this.layerService.getOESTextureFloat();\n // 只有在不支持数据纹理的情况下进行赋值\n if (!this.dataTextureTest) {\n this.dataTexture = this.createTexture2D({\n data: new Uint8ClampedArray(4),\n mag: gl.NEAREST,\n min: gl.NEAREST,\n width: 1,\n height: 1,\n });\n }\n }\n\n // style datatexture mapping\n\n /**\n * 清除上一次的计算结果 - 全量清除\n */\n public clearLastCalRes() {\n this.cellProperties = []; // 清空上一次计算的需要进行数据映射的属性集合\n this.cellLength = 0; // 清空上一次计算的 cell 的长度\n this.stylePropertyesExist = {\n // 全量清空上一次是否需要对 style 属性进行数据映射的判断\n hasThetaOffset: 0,\n hasOpacity: 0,\n hasStrokeOpacity: 0,\n hasStrokeWidth: 0,\n hasStroke: 0,\n hasOffsets: 0,\n };\n }\n\n public getCellTypeLayout() {\n if (this.dataTextureTest) {\n return [\n // 0\n this.rowCount, // 数据纹理有几行\n this.DATA_TEXTURE_WIDTH, // 数据纹理有几列\n 0.0,\n 0.0,\n // 1\n this.stylePropertyesExist.hasOpacity, // cell 中是否存在 opacity\n this.stylePropertyesExist.hasStrokeOpacity, // cell 中是否存在 strokeOpacity\n this.stylePropertyesExist.hasStrokeWidth, // cell 中是否存在 strokeWidth\n this.stylePropertyesExist.hasStroke, // cell 中是否存在 stroke\n // 2\n this.stylePropertyesExist.hasOffsets, // cell 中是否存在 offsets\n this.stylePropertyesExist.hasThetaOffset, // cell 中是否存在 thetaOffset\n 0.0,\n 0.0,\n // 3\n 0.0,\n 0.0,\n 0.0,\n 1.0,\n ];\n } else {\n return [\n 1.0, // 数据纹理有几行\n 1.0, // 数据纹理有几列\n 0.0,\n 0.0,\n 0.0, // cell 中是否存在 opacity\n 0.0, // cell 中是否存在 strokeOpacity\n 0.0, // cell 中是否存在 strokeWidth\n 0.0, // cell 中是否存在 stroke\n 0.0, // cell 中是否存在 offsets\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n -1.0,\n ];\n }\n }\n\n /**\n * 判断数据纹理是否需要重新计算 - 根据传入的值进行判断\n * @param options\n * @returns\n */\n public dataTextureNeedUpdate(options: {\n // TODO: thetaOffset 目前只有 lineLayer/arc 使用\n thetaOffset?: styleSingle;\n opacity?: styleSingle;\n strokeOpacity?: styleSingle;\n strokeWidth?: styleSingle;\n stroke?: styleColor;\n offsets?: styleOffset;\n textOffset?: styleOffset;\n }): boolean {\n let isUpdate = false;\n if (!isEqual(options.thetaOffset, this.cacheStyleProperties.thetaOffset)) {\n isUpdate = true;\n this.cacheStyleProperties.thetaOffset = options.thetaOffset;\n }\n if (!isEqual(options.opacity, this.cacheStyleProperties.opacity)) {\n isUpdate = true;\n this.cacheStyleProperties.opacity = options.opacity;\n }\n if (\n !isEqual(options.strokeOpacity, this.cacheStyleProperties.strokeOpacity)\n ) {\n isUpdate = true;\n this.cacheStyleProperties.strokeOpacity = options.strokeOpacity;\n }\n if (!isEqual(options.strokeWidth, this.cacheStyleProperties.strokeWidth)) {\n isUpdate = true;\n this.cacheStyleProperties.strokeWidth = options.strokeWidth;\n }\n if (!isEqual(options.stroke, this.cacheStyleProperties.stroke)) {\n isUpdate = true;\n this.cacheStyleProperties.stroke = options.stroke;\n }\n if (!isEqual(options.offsets, this.cacheStyleProperties.offsets)) {\n isUpdate = true;\n this.cacheStyleProperties.offsets = options.offsets;\n }\n if (this.dataTexture === undefined) {\n isUpdate = true;\n }\n return isUpdate;\n }\n /**\n * 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n * @param options\n */\n public judgeStyleAttributes(options: {\n // TODO: 目前 thetaOffset 只有 lineLayer/arc 使用\n thetaOffset?: styleSingle;\n opacity?: styleSingle;\n strokeOpacity?: styleSingle;\n strokeWidth?: styleSingle;\n stroke?: styleColor;\n offsets?: styleOffset;\n }) {\n this.clearLastCalRes(); // 清除上一次的计算结果 - 全量清除\n\n if (options.opacity !== undefined && !isNumber(options.opacity)) {\n // 数据映射\n this.cellProperties.push({ attr: 'opacity', count: 1 });\n this.stylePropertyesExist.hasOpacity = 1;\n this.cellLength += 1;\n }\n\n if (\n options.strokeOpacity !== undefined &&\n !isNumber(options.strokeOpacity)\n ) {\n // 数据映射\n this.cellProperties.push({ attr: 'strokeOpacity', count: 1 });\n this.stylePropertyesExist.hasStrokeOpacity = 1;\n this.cellLength += 1;\n }\n\n if (options.strokeWidth !== undefined && !isNumber(options.strokeWidth)) {\n // 数据映射\n this.cellProperties.push({ attr: 'strokeWidth', count: 1 });\n this.stylePropertyesExist.hasStrokeWidth = 1;\n this.cellLength += 1;\n }\n\n if (options.stroke !== undefined && !this.isStaticColor(options.stroke)) {\n // 数据映射\n this.cellProperties.push({ attr: 'stroke', count: 4 });\n this.stylePropertyesExist.hasStroke = 1;\n this.cellLength += 4;\n }\n\n if (\n options.offsets !== undefined &&\n !this.isOffsetStatic(options.offsets)\n ) {\n // 数据映射\n this.cellProperties.push({ attr: 'offsets', count: 2 });\n this.stylePropertyesExist.hasOffsets = 1;\n this.cellLength += 2;\n }\n\n if (options.thetaOffset !== undefined && !isNumber(options.thetaOffset)) {\n // 数据映射\n this.cellProperties.push({ attr: 'thetaOffset', count: 1 });\n this.stylePropertyesExist.hasThetaOffset = 1;\n this.cellLength += 1;\n }\n // console.log('this.cellLength', this.cellLength)\n }\n\n /**\n * 判断变量 stroke 是否是常量值\n * @param stroke\n * @returns\n */\n public isStaticColor(stroke: styleColor): boolean {\n if (isString(stroke)) {\n if (color(stroke)) {\n return true;\n } else {\n return false;\n }\n }\n return false;\n }\n /**\n * 获取 stroke 颜色并做兼容处理\n * @param stroke\n * @returns\n */\n public getStrokeColor(stroke: styleColor) {\n if (this.isStaticColor(stroke)) {\n const strokeColor = rgb2arr(stroke as string);\n strokeColor[0] = strokeColor[0] ? strokeColor[0] : 0;\n strokeColor[1] = strokeColor[1] ? strokeColor[1] : 0;\n strokeColor[2] = strokeColor[2] ? strokeColor[2] : 0;\n strokeColor[3] = strokeColor[3] ? strokeColor[3] : 0;\n return strokeColor;\n } else {\n return [0, 0, 0, 0];\n }\n }\n\n /**\n * 判断 offsets 是否是常量\n * @param offsets\n * @returns\n */\n public isOffsetStatic(offsets: styleOffset) {\n if (\n isArray(offsets) &&\n offsets.length === 2 &&\n isNumber(offsets[0]) &&\n isNumber(offsets[1])\n ) {\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * 补空位\n * @param d\n * @param count\n */\n public patchMod(d: number[], count: number) {\n for (let i = 0; i < count; i++) {\n d.push(-1);\n }\n }\n\n /**\n * 根据映射的数据字段往推入数据\n * @param d\n * @param cellData\n * @param cellPropertiesLayouts\n */\n public patchData(\n d: number[],\n cellData: IEncodeFeature,\n cellPropertiesLayouts: ICellProperty[],\n ) {\n for (const layout of cellPropertiesLayouts) {\n const { attr, count } = layout;\n\n const value = cellData[attr];\n if (value !== undefined) {\n // 数据中存在该属性\n if (attr === 'stroke') {\n d.push(...rgb2arr(value));\n } else if (attr === 'offsets') {\n if (this.isOffsetStatic(value)) {\n d.push(-value[0], value[1]);\n } else {\n d.push(0, 0);\n }\n } else {\n d.push(isNumber(value) ? value : 1.0);\n }\n } else {\n // 若不存在时则补位\n this.patchMod(d, count);\n }\n }\n }\n\n /**\n * 计算推入数据纹理的数据\n * @param cellLength\n * @param encodeData\n * @param cellPropertiesLayouts\n * @returns\n */\n public calDataFrame(\n cellLength: number,\n encodeData: IEncodeFeature[],\n cellPropertiesLayouts: ICellProperty[],\n ): IDataTextureFrame {\n const encodeDatalength = encodeData.length;\n const rowCount = Math.ceil(\n (encodeDatalength * cellLength) / this.DATA_TEXTURE_WIDTH,\n ); // 有多少行\n\n const totalLength = rowCount * this.DATA_TEXTURE_WIDTH;\n const d: number[] = [];\n for (let i = 0; i < encodeDatalength; i++) {\n // 根据 encodeData 数据推入数据\n const cellData = encodeData[i];\n this.patchData(d, cellData, cellPropertiesLayouts);\n }\n for (let i = d.length; i < totalLength; i++) {\n // 每行不足的部分用 -1 补足(数据纹理时 width * height 的矩形数据集合)\n d.push(-1);\n }\n // console.log('data', d)\n return { data: d, width: this.DATA_TEXTURE_WIDTH, height: rowCount };\n }\n\n // style datatexture mapping\n\n public getBlend(): IBlendOptions {\n const { blend = 'normal' } = this.layer.getLayerConfig();\n return BlendTypes[BlendType[blend]] as IBlendOptions;\n }\n public getDefaultStyle(): unknown {\n return {};\n }\n public getUninforms(): IModelUniform {\n throw new Error('Method not implemented.');\n }\n\n public getAnimateUniforms(): IModelUniform {\n return {};\n }\n\n public needUpdate(): boolean {\n return false;\n }\n public buildModels(): IModel[] {\n throw new Error('Method not implemented.');\n }\n public initModels(): IModel[] {\n throw new Error('Method not implemented.');\n }\n public clearModels() {\n return;\n }\n public getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n throw new Error('Method not implemented.');\n }\n public render() {\n throw new Error('Method not implemented.');\n }\n protected registerBuiltinAttributes() {\n throw new Error('Method not implemented.');\n }\n protected animateOption2Array(option: IAnimateOption): number[] {\n return [\n option.enable ? 0 : 1.0,\n option.duration || 4.0,\n option.interval || 0.2,\n option.trailLength || 0.1,\n ];\n }\n protected startModelAnimate() {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n if (animateOption.enable) {\n this.layer.setAnimateStartTime();\n }\n }\n}\n"],"file":"BaseModel.js"}
1
+ {"version":3,"sources":["../../src/core/BaseModel.ts"],"names":["BaseModel","TYPES","IGlobalConfigService","layer","rendererService","getContainer","get","IRendererService","shaderModuleService","IShaderModuleService","styleAttributeService","IStyleAttributeService","mapService","IMapService","iconService","IIconService","fontService","IFontService","cameraService","ICameraService","layerService","ILayerService","registerBuiltinAttributes","startModelAnimate","createTexture2D","DATA_TEXTURE_WIDTH","rowCount","cellLength","cellProperties","cacheStyleProperties","thetaOffset","undefined","opacity","strokeOpacity","strokeWidth","stroke","offsets","stylePropertyesExist","hasThetaOffset","hasOpacity","hasStrokeOpacity","hasStrokeWidth","hasStroke","hasOffsets","dataTextureTest","getOESTextureFloat","dataTexture","data","Uint8Array","mag","gl","NEAREST","min","width","height","options","isUpdate","clearLastCalRes","push","attr","count","isStaticColor","isOffsetStatic","strokeColor","length","d","i","cellData","cellPropertiesLayouts","layout","value","patchMod","encodeData","encodeDatalength","Math","ceil","totalLength","patchData","getLayerConfig","blend","BlendTypes","BlendType","Error","option","enable","duration","interval","trailLength","animateOption","setAnimateStartTime"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AA4BA;;AACA;;AAEA;;;;;;;;;;IA0BqBA,S,WAoClB,wBAAWC,cAAMC,oBAAjB,C;AAsBD,qBAAYC,KAAZ,EAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACzB,SAAKA,KAAL,GAAaA,KAAb;AACA,SAAKC,eAAL,GAAuBD,KAAK,CACzBE,YADoB,GAEpBC,GAFoB,CAEEL,cAAMM,gBAFR,CAAvB;AAGA,SAAKC,mBAAL,GAA2BL,KAAK,CAC7BE,YADwB,GAExBC,GAFwB,CAEEL,cAAMQ,oBAFR,CAA3B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AJ,CAAU,yBAAV,CAAN;AACD;;;WACD,6BAA8BC,MAA9B,EAAgE;AAC9D,aAAO,CACLA,MAAM,CAACC,MAAP,GAAgB,CAAhB,GAAoB,GADf,EAELD,MAAM,CAACE,QAAP,IAAmB,GAFd,EAGLF,MAAM,CAACG,QAAP,IAAmB,GAHd,EAILH,MAAM,CAACI,WAAP,IAAsB,GAJjB,CAAP;AAMD;;;WACD,6BAA8B;AAC5B,iBAA0B,KAAKpF,KAAL,CAAW2E,cAAX,EAA1B;AAAA,UAAQU,aAAR,QAAQA,aAAR;;AACA,UAAIA,aAAa,CAACJ,MAAlB,EAA0B;AACxB,aAAKjF,KAAL,CAAWsF,mBAAX;AACD;AACF","sourcesContent":["import {\n BlendType,\n gl,\n IAnimateOption,\n IAttribute,\n IBlendOptions,\n ICameraService,\n IElements,\n IEncodeFeature,\n IFontService,\n IGlobalConfigService,\n IIconService,\n ILayer,\n ILayerConfig,\n ILayerModel,\n ILayerService,\n IMapService,\n IModel,\n IModelUniform,\n IRendererService,\n IShaderModuleService,\n IStyleAttributeService,\n ITexture2D,\n ITexture2DInitializationOptions,\n lazyInject,\n Triangulation,\n TYPES,\n} from '@antv/l7-core';\nimport { rgb2arr } from '@antv/l7-utils';\nimport { color } from 'd3-color';\nimport { isArray, isEqual, isFunction, isNumber, isString } from 'lodash';\nimport { BlendTypes } from '../utils/blend';\n\nexport type styleSingle =\n | number\n | string\n | [string, (single: any) => number]\n | [string, [number, number]];\nexport type styleOffset =\n | string\n | [number, number]\n | [string, (single: any) => number];\nexport type styleColor =\n | string\n | [string, (single: any) => string]\n | [string, [string, string]];\nexport interface IDataTextureFrame {\n data: number[];\n width: number;\n height: number;\n}\n\nexport interface ICellProperty {\n attr: string;\n count: number;\n}\n\nexport default class BaseModel<ChildLayerStyleOptions = {}>\n implements ILayerModel {\n public triangulation: Triangulation;\n\n // style texture data mapping\n public createTexture2D: (\n options: ITexture2DInitializationOptions,\n ) => ITexture2D;\n\n protected layer: ILayer;\n protected dataTexture: ITexture2D; // 用于数据传递的数据纹理\n protected DATA_TEXTURE_WIDTH: number; // 默认有多少列(宽度)\n protected rowCount: number; // 计算得到的当前数据纹理有多少行(高度)\n protected cacheStyleProperties: {\n // 记录存储上一次样式字段的值\n thetaOffset: styleSingle | undefined;\n opacity: styleSingle | undefined;\n strokeOpacity: styleSingle | undefined;\n strokeWidth: styleSingle | undefined;\n stroke: styleColor | undefined;\n offsets: styleOffset | undefined;\n };\n protected cellLength: number; // 单个 cell 的长度\n protected cellProperties: ICellProperty[]; // 需要进行数据映射的属性集合\n protected cellTypeLayout: number[];\n protected stylePropertyesExist: {\n // 记录 style 属性是否存在的中间变量\n hasThetaOffset: number;\n hasOpacity: number;\n hasStrokeOpacity: number;\n hasStrokeWidth: number;\n hasStroke: number;\n hasOffsets: number;\n };\n protected dataTextureTest: boolean;\n\n @lazyInject(TYPES.IGlobalConfigService)\n protected readonly configService: IGlobalConfigService;\n\n // @lazyInject(TYPES.IIconService)\n // protected readonly iconService: IIconService;\n\n // @lazyInject(TYPES.IFontService)\n // protected readonly fontService: IFontService;\n\n // @lazyInject(TYPES.IShaderModuleService)\n protected shaderModuleService: IShaderModuleService;\n\n protected rendererService: IRendererService;\n protected iconService: IIconService;\n protected fontService: IFontService;\n protected styleAttributeService: IStyleAttributeService;\n protected mapService: IMapService;\n protected cameraService: ICameraService;\n protected layerService: ILayerService;\n\n // style texture data mapping\n\n constructor(layer: ILayer) {\n this.layer = layer;\n this.rendererService = layer\n .getContainer()\n .get<IRendererService>(TYPES.IRendererService);\n this.shaderModuleService = layer\n .getContainer()\n .get<IShaderModuleService>(TYPES.IShaderModuleService);\n\n this.styleAttributeService = layer\n .getContainer()\n .get<IStyleAttributeService>(TYPES.IStyleAttributeService);\n this.mapService = layer.getContainer().get<IMapService>(TYPES.IMapService);\n this.iconService = layer\n .getContainer()\n .get<IIconService>(TYPES.IIconService);\n this.fontService = layer\n .getContainer()\n .get<IFontService>(TYPES.IFontService);\n this.cameraService = layer\n .getContainer()\n .get<ICameraService>(TYPES.ICameraService);\n this.layerService = layer\n .getContainer()\n .get<ILayerService>(TYPES.ILayerService);\n\n // 注册 Attribute\n this.registerBuiltinAttributes();\n // 开启动画\n this.startModelAnimate();\n\n const { createTexture2D } = this.rendererService;\n this.createTexture2D = createTexture2D;\n this.DATA_TEXTURE_WIDTH = 1024; // 数据纹理固定宽度\n this.rowCount = 1;\n this.cellLength = 0;\n this.cellProperties = [];\n this.cacheStyleProperties = {\n thetaOffset: undefined,\n opacity: undefined,\n strokeOpacity: undefined,\n strokeWidth: undefined,\n stroke: undefined,\n offsets: undefined,\n };\n this.stylePropertyesExist = {\n hasThetaOffset: 0,\n hasOpacity: 0,\n hasStrokeOpacity: 0,\n hasStrokeWidth: 0,\n hasStroke: 0,\n hasOffsets: 0,\n };\n this.dataTextureTest = this.layerService.getOESTextureFloat();\n // 只有在不支持数据纹理的情况下进行赋值\n if (!this.dataTextureTest) {\n this.dataTexture = this.createTexture2D({\n // data: new Uint8ClampedArray(4),\n // 使用 Uint8ClampedArray 在 支付宝 环境中可能存在问题 UC 内核对格式有要求 L7 v2.7.18 版本发现\n // Uint8ClampedArray 和 Uint8Array 没有实质性的区别\n data: new Uint8Array(4),\n mag: gl.NEAREST,\n min: gl.NEAREST,\n width: 1,\n height: 1,\n });\n }\n }\n\n // style datatexture mapping\n\n /**\n * 清除上一次的计算结果 - 全量清除\n */\n public clearLastCalRes() {\n this.cellProperties = []; // 清空上一次计算的需要进行数据映射的属性集合\n this.cellLength = 0; // 清空上一次计算的 cell 的长度\n this.stylePropertyesExist = {\n // 全量清空上一次是否需要对 style 属性进行数据映射的判断\n hasThetaOffset: 0,\n hasOpacity: 0,\n hasStrokeOpacity: 0,\n hasStrokeWidth: 0,\n hasStroke: 0,\n hasOffsets: 0,\n };\n }\n\n public getCellTypeLayout() {\n if (this.dataTextureTest) {\n return [\n // 0\n this.rowCount, // 数据纹理有几行\n this.DATA_TEXTURE_WIDTH, // 数据纹理有几列\n 0.0,\n 0.0,\n // 1\n this.stylePropertyesExist.hasOpacity, // cell 中是否存在 opacity\n this.stylePropertyesExist.hasStrokeOpacity, // cell 中是否存在 strokeOpacity\n this.stylePropertyesExist.hasStrokeWidth, // cell 中是否存在 strokeWidth\n this.stylePropertyesExist.hasStroke, // cell 中是否存在 stroke\n // 2\n this.stylePropertyesExist.hasOffsets, // cell 中是否存在 offsets\n this.stylePropertyesExist.hasThetaOffset, // cell 中是否存在 thetaOffset\n 0.0,\n 0.0,\n // 3\n 0.0,\n 0.0,\n 0.0,\n 1.0,\n ];\n } else {\n return [\n 1.0, // 数据纹理有几行\n 1.0, // 数据纹理有几列\n 0.0,\n 0.0,\n 0.0, // cell 中是否存在 opacity\n 0.0, // cell 中是否存在 strokeOpacity\n 0.0, // cell 中是否存在 strokeWidth\n 0.0, // cell 中是否存在 stroke\n 0.0, // cell 中是否存在 offsets\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n 0.0,\n -1.0,\n ];\n }\n }\n\n /**\n * 判断数据纹理是否需要重新计算 - 根据传入的值进行判断\n * @param options\n * @returns\n */\n public dataTextureNeedUpdate(options: {\n // TODO: thetaOffset 目前只有 lineLayer/arc 使用\n thetaOffset?: styleSingle;\n opacity?: styleSingle;\n strokeOpacity?: styleSingle;\n strokeWidth?: styleSingle;\n stroke?: styleColor;\n offsets?: styleOffset;\n textOffset?: styleOffset;\n }): boolean {\n let isUpdate = false;\n if (!isEqual(options.thetaOffset, this.cacheStyleProperties.thetaOffset)) {\n isUpdate = true;\n this.cacheStyleProperties.thetaOffset = options.thetaOffset;\n }\n if (!isEqual(options.opacity, this.cacheStyleProperties.opacity)) {\n isUpdate = true;\n this.cacheStyleProperties.opacity = options.opacity;\n }\n if (\n !isEqual(options.strokeOpacity, this.cacheStyleProperties.strokeOpacity)\n ) {\n isUpdate = true;\n this.cacheStyleProperties.strokeOpacity = options.strokeOpacity;\n }\n if (!isEqual(options.strokeWidth, this.cacheStyleProperties.strokeWidth)) {\n isUpdate = true;\n this.cacheStyleProperties.strokeWidth = options.strokeWidth;\n }\n if (!isEqual(options.stroke, this.cacheStyleProperties.stroke)) {\n isUpdate = true;\n this.cacheStyleProperties.stroke = options.stroke;\n }\n if (!isEqual(options.offsets, this.cacheStyleProperties.offsets)) {\n isUpdate = true;\n this.cacheStyleProperties.offsets = options.offsets;\n }\n if (this.dataTexture === undefined) {\n isUpdate = true;\n }\n return isUpdate;\n }\n /**\n * 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n * @param options\n */\n public judgeStyleAttributes(options: {\n // TODO: 目前 thetaOffset 只有 lineLayer/arc 使用\n thetaOffset?: styleSingle;\n opacity?: styleSingle;\n strokeOpacity?: styleSingle;\n strokeWidth?: styleSingle;\n stroke?: styleColor;\n offsets?: styleOffset;\n }) {\n this.clearLastCalRes(); // 清除上一次的计算结果 - 全量清除\n\n if (options.opacity !== undefined && !isNumber(options.opacity)) {\n // 数据映射\n this.cellProperties.push({ attr: 'opacity', count: 1 });\n this.stylePropertyesExist.hasOpacity = 1;\n this.cellLength += 1;\n }\n\n if (\n options.strokeOpacity !== undefined &&\n !isNumber(options.strokeOpacity)\n ) {\n // 数据映射\n this.cellProperties.push({ attr: 'strokeOpacity', count: 1 });\n this.stylePropertyesExist.hasStrokeOpacity = 1;\n this.cellLength += 1;\n }\n\n if (options.strokeWidth !== undefined && !isNumber(options.strokeWidth)) {\n // 数据映射\n this.cellProperties.push({ attr: 'strokeWidth', count: 1 });\n this.stylePropertyesExist.hasStrokeWidth = 1;\n this.cellLength += 1;\n }\n\n if (options.stroke !== undefined && !this.isStaticColor(options.stroke)) {\n // 数据映射\n this.cellProperties.push({ attr: 'stroke', count: 4 });\n this.stylePropertyesExist.hasStroke = 1;\n this.cellLength += 4;\n }\n\n if (\n options.offsets !== undefined &&\n !this.isOffsetStatic(options.offsets)\n ) {\n // 数据映射\n this.cellProperties.push({ attr: 'offsets', count: 2 });\n this.stylePropertyesExist.hasOffsets = 1;\n this.cellLength += 2;\n }\n\n if (options.thetaOffset !== undefined && !isNumber(options.thetaOffset)) {\n // 数据映射\n this.cellProperties.push({ attr: 'thetaOffset', count: 1 });\n this.stylePropertyesExist.hasThetaOffset = 1;\n this.cellLength += 1;\n }\n // console.log('this.cellLength', this.cellLength)\n }\n\n /**\n * 判断变量 stroke 是否是常量值\n * @param stroke\n * @returns\n */\n public isStaticColor(stroke: styleColor): boolean {\n if (isString(stroke)) {\n if (color(stroke)) {\n return true;\n } else {\n return false;\n }\n }\n return false;\n }\n /**\n * 获取 stroke 颜色并做兼容处理\n * @param stroke\n * @returns\n */\n public getStrokeColor(stroke: styleColor) {\n if (this.isStaticColor(stroke)) {\n const strokeColor = rgb2arr(stroke as string);\n strokeColor[0] = strokeColor[0] ? strokeColor[0] : 0;\n strokeColor[1] = strokeColor[1] ? strokeColor[1] : 0;\n strokeColor[2] = strokeColor[2] ? strokeColor[2] : 0;\n strokeColor[3] = strokeColor[3] ? strokeColor[3] : 0;\n return strokeColor;\n } else {\n return [0, 0, 0, 0];\n }\n }\n\n /**\n * 判断 offsets 是否是常量\n * @param offsets\n * @returns\n */\n public isOffsetStatic(offsets: styleOffset) {\n if (\n isArray(offsets) &&\n offsets.length === 2 &&\n isNumber(offsets[0]) &&\n isNumber(offsets[1])\n ) {\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * 补空位\n * @param d\n * @param count\n */\n public patchMod(d: number[], count: number) {\n for (let i = 0; i < count; i++) {\n d.push(-1);\n }\n }\n\n /**\n * 根据映射的数据字段往推入数据\n * @param d\n * @param cellData\n * @param cellPropertiesLayouts\n */\n public patchData(\n d: number[],\n cellData: IEncodeFeature,\n cellPropertiesLayouts: ICellProperty[],\n ) {\n for (const layout of cellPropertiesLayouts) {\n const { attr, count } = layout;\n\n const value = cellData[attr];\n if (value !== undefined) {\n // 数据中存在该属性\n if (attr === 'stroke') {\n d.push(...rgb2arr(value));\n } else if (attr === 'offsets') {\n if (this.isOffsetStatic(value)) {\n d.push(-value[0], value[1]);\n } else {\n d.push(0, 0);\n }\n } else {\n d.push(isNumber(value) ? value : 1.0);\n }\n } else {\n // 若不存在时则补位\n this.patchMod(d, count);\n }\n }\n }\n\n /**\n * 计算推入数据纹理的数据\n * @param cellLength\n * @param encodeData\n * @param cellPropertiesLayouts\n * @returns\n */\n public calDataFrame(\n cellLength: number,\n encodeData: IEncodeFeature[],\n cellPropertiesLayouts: ICellProperty[],\n ): IDataTextureFrame {\n const encodeDatalength = encodeData.length;\n const rowCount = Math.ceil(\n (encodeDatalength * cellLength) / this.DATA_TEXTURE_WIDTH,\n ); // 有多少行\n\n const totalLength = rowCount * this.DATA_TEXTURE_WIDTH;\n const d: number[] = [];\n for (let i = 0; i < encodeDatalength; i++) {\n // 根据 encodeData 数据推入数据\n const cellData = encodeData[i];\n this.patchData(d, cellData, cellPropertiesLayouts);\n }\n for (let i = d.length; i < totalLength; i++) {\n // 每行不足的部分用 -1 补足(数据纹理时 width * height 的矩形数据集合)\n d.push(-1);\n }\n // console.log('data', d)\n return { data: d, width: this.DATA_TEXTURE_WIDTH, height: rowCount };\n }\n\n // style datatexture mapping\n\n public getBlend(): IBlendOptions {\n const { blend = 'normal' } = this.layer.getLayerConfig();\n return BlendTypes[BlendType[blend]] as IBlendOptions;\n }\n public getDefaultStyle(): unknown {\n return {};\n }\n public getUninforms(): IModelUniform {\n throw new Error('Method not implemented.');\n }\n\n public getAnimateUniforms(): IModelUniform {\n return {};\n }\n\n public needUpdate(): boolean {\n return false;\n }\n public buildModels(): IModel[] {\n throw new Error('Method not implemented.');\n }\n public initModels(): IModel[] {\n throw new Error('Method not implemented.');\n }\n public clearModels() {\n return;\n }\n public getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n throw new Error('Method not implemented.');\n }\n public render() {\n throw new Error('Method not implemented.');\n }\n protected registerBuiltinAttributes() {\n throw new Error('Method not implemented.');\n }\n protected animateOption2Array(option: IAnimateOption): number[] {\n return [\n option.enable ? 0 : 1.0,\n option.duration || 4.0,\n option.interval || 0.2,\n option.trailLength || 0.1,\n ];\n }\n protected startModelAnimate() {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n if (animateOption.enable) {\n this.layer.setAnimateStartTime();\n }\n }\n}\n"],"file":"BaseModel.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-layers",
3
- "version": "2.7.20",
3
+ "version": "2.7.21",
4
4
  "description": "L7's collection of built-in layers",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -24,9 +24,9 @@
24
24
  "license": "ISC",
25
25
  "dependencies": {
26
26
  "@antv/geo-coord": "^1.0.8",
27
- "@antv/l7-core": "^2.7.20",
28
- "@antv/l7-source": "^2.7.20",
29
- "@antv/l7-utils": "^2.7.20",
27
+ "@antv/l7-core": "^2.7.21",
28
+ "@antv/l7-source": "^2.7.21",
29
+ "@antv/l7-utils": "^2.7.21",
30
30
  "@babel/runtime": "^7.7.7",
31
31
  "@mapbox/martini": "^0.2.0",
32
32
  "@turf/meta": "^6.0.2",
@@ -52,7 +52,7 @@
52
52
  "@types/gl-matrix": "^2.4.5",
53
53
  "@types/lodash": "^4.14.138"
54
54
  },
55
- "gitHead": "24fe361470bccba68bdedab2ddcaa6b8a4a663df",
55
+ "gitHead": "e38483289aca5bffbe6ff2bc435c7b98b09ac297",
56
56
  "publishConfig": {
57
57
  "access": "public"
58
58
  }