@antv/l7-layers 2.6.13 → 2.6.18
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.
- package/es/heatmap/models/heatmap.js +4 -4
- package/es/heatmap/models/heatmap.js.map +1 -1
- package/es/imagetile/models/imagetile.d.ts +1 -0
- package/es/imagetile/models/imagetile.js +11 -13
- package/es/imagetile/models/imagetile.js.map +1 -1
- package/es/point/models/fill.js +5 -3
- package/es/point/models/fill.js.map +1 -1
- package/es/point/shape/extrude.d.ts +1 -1
- package/es/point/shape/extrude.js.map +1 -1
- package/lib/heatmap/models/heatmap.js +4 -4
- package/lib/heatmap/models/heatmap.js.map +1 -1
- package/lib/imagetile/models/imagetile.js +10 -13
- package/lib/imagetile/models/imagetile.js.map +1 -1
- package/lib/point/models/fill.js +5 -3
- package/lib/point/models/fill.js.map +1 -1
- package/lib/point/shape/extrude.js.map +1 -1
- package/package.json +5 -5
- package/es/point/shape/Path.d.ts +0 -40
- package/es/point/shape/Path.js +0 -57
- package/es/point/shape/Path.js.map +0 -1
- package/lib/point/shape/Path.js +0 -82
- package/lib/point/shape/Path.js.map +0 -1
|
@@ -27,8 +27,8 @@ import { HeatmapTriangulation } from '../../core/triangulation';
|
|
|
27
27
|
var heatmap3DFrag = "uniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\nuniform float u_opacity;\nvarying vec2 v_texCoord;\nvarying float v_intensity;\n\nvoid main(){\n \n float intensity = texture2D(u_texture, v_texCoord).r;\n vec4 color = texture2D(u_colorTexture,vec2(intensity, 0));\n gl_FragColor = color;\n // gl_FragColor.a = color.a * smoothstep(0.1,0.2,intensity)* u_opacity;\n gl_FragColor.a = color.a * smoothstep(0.,0.1,intensity) * u_opacity;\n}\n";
|
|
28
28
|
var heatmap3DVert = "precision highp float;\nattribute vec3 a_Position;\nattribute vec2 a_Uv;\nuniform sampler2D u_texture;\nvarying vec2 v_texCoord;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_InverseViewProjectionMatrix;\nuniform mat4 u_ViewProjectionMatrixUncentered;\nvarying float v_intensity;\n\n\nvec2 toBezier(float t, vec2 P0, vec2 P1, vec2 P2, vec2 P3) {\n float t2 = t * t;\n float one_minus_t = 1.0 - t;\n float one_minus_t2 = one_minus_t * one_minus_t;\n return (P0 * one_minus_t2 * one_minus_t + P1 * 3.0 * t * one_minus_t2 + P2 * 3.0 * t2 * one_minus_t + P3 * t2 * t);\n}\nvec2 toBezier(float t, vec4 p){\n return toBezier(t, vec2(0.0, 0.0), vec2(p.x, p.y), vec2(p.z, p.w), vec2(1.0, 1.0));\n}\n#pragma include \"projection\"\nvoid main() {\n v_texCoord = a_Uv;\n\n vec2 pos = a_Uv * vec2(2.0) - vec2(1.0); // \u5C06\u539F\u672C 0 -> 1 \u7684 uv \u8F6C\u6362\u4E3A -1 -> 1 \u7684\u6807\u51C6\u5750\u6807\u7A7A\u95F4\uFF08NDC\uFF09\n\n vec4 p1 = vec4(pos, 0.0, 1.0); // x/y \u5E73\u9762\u4E0A\u7684\u70B9\uFF08z == 0\uFF09\u53EF\u4EE5\u8BA4\u4E3A\u662F\u4E09\u7EF4\u4E0A\u7684\u70B9\u88AB\u6295\u5F71\u5230\u5E73\u9762\u540E\u7684\u70B9\n\tvec4 p2 = vec4(pos, 1.0, 1.0); // \u5E73\u884C\u4E8Ex/y\u5E73\u9762\u3001z==1 \u7684\u5E73\u9762\u4E0A\u7684\u70B9\n\n\tvec4 inverseP1 = u_InverseViewProjectionMatrix * p1; // \u6839\u636E\u89C6\u56FE\u6295\u5F71\u77E9\u9635\u7684\u9006\u77E9\u9635\u5E73\u9762\u4E0A\u7684\u53CD\u7B97\u51FA\u4E09\u7EF4\u7A7A\u95F4\u4E2D\u7684\u70B9\uFF08p1\u5E73\u9762\u4E0A\u7684\u70B9\uFF09\n\tvec4 inverseP2 = u_InverseViewProjectionMatrix * p2;\n\n inverseP1 = inverseP1 / inverseP1.w; // \u5F52\u4E00\u5316\u64CD\u4F5C\uFF08\u5F52\u4E00\u5316\u540E\u4E3A\u4E16\u754C\u5750\u6807\uFF09\n\tinverseP2 = inverseP2 / inverseP2.w;\n\n\tfloat zPos = (0.0 - inverseP1.z) / (inverseP2.z - inverseP1.z); // ??\n\tvec4 position = inverseP1 + zPos * (inverseP2 - inverseP1);\n\n vec4 b= vec4(0.5000, 0.0, 1.0, 0.5000);\n float fh;\n\n v_intensity = texture2D(u_texture, v_texCoord).r;\n fh = toBezier(v_intensity, b).y;\n gl_Position = u_ViewProjectionMatrixUncentered * vec4(position.xy, fh * project_pixel(50.), 1.0);\n \n}\n";
|
|
29
29
|
var heatmapColorFrag = "uniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\nuniform float u_opacity;\nvarying vec2 v_texCoord;\nvarying float v_intensity;\n\nvoid main(){\n float intensity = texture2D(u_texture, v_texCoord).r;\n vec4 color = texture2D(u_colorTexture,vec2(intensity, 0));\n gl_FragColor =color;\n gl_FragColor.a = color.a * smoothstep(0.,0.1,intensity) * u_opacity;\n\n}\n";
|
|
30
|
-
var
|
|
31
|
-
var
|
|
30
|
+
var heatmapFramebufferFrag = "precision highp float;\nuniform float u_intensity;\nvarying float v_weight;\nvarying vec2 v_extrude;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(){\n float d = -0.5 * 3.0 * 3.0 * dot(v_extrude, v_extrude);\n float val = v_weight * u_intensity * GAUSS_COEF * exp(d);\n gl_FragColor = vec4(val, 1., 1., 1.);\n}\n";
|
|
31
|
+
var heatmapFramebufferVert = "precision highp float;\nattribute vec3 a_Position;\nattribute float a_Size;\nattribute vec2 a_Dir;\nuniform float u_intensity;\nuniform float u_radius;\nvarying vec2 v_extrude;\nvarying float v_weight;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\n#define GAUSS_COEF 0.3989422804014327\n\n#pragma include \"projection\"\n\nvoid main(){\n v_weight = a_Size;\n float ZERO = 1.0 / 255.0 / 16.0;\n float extrude_x = a_Dir.x * 2.0 -1.0;\n float extrude_y = a_Dir.y * 2.0 -1.0;\n vec2 extrude_dir = normalize(vec2(extrude_x,extrude_y));\n float S = sqrt(-2.0 * log(ZERO / a_Size / u_intensity / GAUSS_COEF)) / 2.5;\n v_extrude = extrude_dir * S;\n\n vec2 offset = project_pixel(v_extrude * u_radius);\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, 0.0, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n }\n}\n";
|
|
32
32
|
var heatmapColorVert = "precision highp float;\nattribute vec3 a_Position;\nattribute vec2 a_Uv;\nuniform sampler2D u_texture;\nvarying vec2 v_texCoord;\nvarying float v_intensity;\nvoid main() {\n v_texCoord = a_Uv;\n v_intensity = texture2D(u_texture, v_texCoord).r;\n gl_Position = vec4(a_Position.xy, 0, 1.);\n}\n";
|
|
33
33
|
import { heatMap3DTriangulation } from '../triangulation';
|
|
34
34
|
var HeatMapModel = (_dec = injectable(), _dec(_class = function (_BaseModel) {
|
|
@@ -175,8 +175,8 @@ var HeatMapModel = (_dec = injectable(), _dec(_class = function (_BaseModel) {
|
|
|
175
175
|
value: function buildHeatMapIntensity() {
|
|
176
176
|
return this.layer.buildLayerModel({
|
|
177
177
|
moduleName: 'heatmapintensity',
|
|
178
|
-
vertexShader:
|
|
179
|
-
fragmentShader:
|
|
178
|
+
vertexShader: heatmapFramebufferVert,
|
|
179
|
+
fragmentShader: heatmapFramebufferFrag,
|
|
180
180
|
triangulation: HeatmapTriangulation,
|
|
181
181
|
depth: {
|
|
182
182
|
enable: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/heatmap/models/heatmap.ts"],"names":["AttributeType","gl","generateColorRamp","mat4","injectable","BaseModel","HeatmapTriangulation","heatMap3DTriangulation","HeatMapModel","rendererService","clear","useFramebuffer","heatmapFramerBuffer","color","depth","stencil","framebuffer","drawIntensityMode","layer","styleNeedUpdate","updateColorTexture","shapeType","drawColorMode","draw3DHeatMap","Error","createFramebuffer","getViewportSize","createTexture2D","shapeAttr","styleAttributeService","getLayerStyleAttribute","scale","field","intensityModel","buildHeatMapIntensity","colorModel","buildHeatmapColor","build3dHeatMap","width","height","Math","floor","wrapS","CLAMP_TO_EDGE","wrapT","min","LINEAR","mag","initModels","registerStyleAttribute","name","type","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","data","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","buildLayerModel","moduleName","vertexShader","heatmapVert","fragmentShader","heatmapFrag","triangulation","enable","blend","func","srcRGB","ONE","srcAlpha","dstRGB","dstAlpha","shaderModuleService","registerModule","vs","heatmapColorVert","fs","heatmapColorFrag","getModule","uniforms","createAttribute","createElements","createBuffer","createModel","attributes","a_Position","a_Uv","getBlend","count","elements","UNSIGNED_INT","getLayerConfig","opacity","intensity","radius","draw","u_opacity","u_radius","u_intensity","u_colorTexture","colorTexture","u_texture","invert","create","cameraService","getViewProjectionMatrixUncentered","u_ViewProjectionMatrixUncentered","u_InverseViewProjectionMatrix","heatmap3DVert","heatmap3DFrag","vertices","uvs","primitive","TRIANGLES","SRC_ALPHA","ONE_MINUS_SRC_ALPHA","indices","length","texture","destroy","rampColors","imageData","Uint8Array","NEAREST","flipY"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAQO,eARP;AASA,SAASC,iBAAT,QAA8C,gBAA9C;AACA,SAASC,IAAT,QAAqB,WAArB;AACA,SAAiBC,UAAjB,QAAmC,WAAnC;AACA,OAAO,kBAAP;AACA,OAAOC,SAAP,MAAsB,sBAAtB;AACA,SAASC,oBAAT,QAAqC,0BAArC;;;;;;;AAOA,SAASC,sBAAT,QAAuC,kBAAvC;IASq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QAAQ,EAAE;AAJN;AAFD,SA1BU;AAmCjBkB,QAAAA,QAAQ,EAAER,cAAc,CAAC;AACvBhC,UAAAA,IAAI,EAAEc,aAAa,CAACqD,OADG;AAEvBzE,UAAAA,IAAI,EAAElD,EAAE,CAACiG,YAFc;AAGvBF,UAAAA,KAAK,EAAEzB,aAAa,CAACqD,OAAd,CAAsBC;AAHN,SAAD;AAnCP,OAAD,CAAlB;AAyCD;;;WACD,uBAAsB;AACpB,WAAKzG,kBAAL;AACD;;;WAED,8BAA6B;AAC3B,UAAQO,eAAR,GAA4B,KAAKlB,eAAjC,CAAQkB,eAAR;;AACA,UAAI,KAAKmG,OAAT,EAAkB;AAChB,aAAKA,OAAL,CAAaC,OAAb;AACD;;AAED,kBAEI,KAAK7G,KAAL,CAAWiF,cAAX,EAFJ;AAAA,UACE6B,UADF,SACEA,UADF;;AAGA,UAAMC,SAAS,GAAG/H,iBAAiB,CAAC8H,UAAD,CAAnC;AACA,WAAKpB,YAAL,GAAoBjF,eAAe,CAAC;AAClC8B,QAAAA,IAAI,EAAE,IAAIyE,UAAJ,CAAeD,SAAS,CAACxE,IAAzB,CAD4B;AAElCnB,QAAAA,KAAK,EAAE2F,SAAS,CAAC3F,KAFiB;AAGlCC,QAAAA,MAAM,EAAE0F,SAAS,CAAC1F,MAHgB;AAIlCG,QAAAA,KAAK,EAAEzC,EAAE,CAAC0C,aAJwB;AAKlCC,QAAAA,KAAK,EAAE3C,EAAE,CAAC0C,aALwB;AAMlCE,QAAAA,GAAG,EAAE5C,EAAE,CAACkI,OAN0B;AAOlCpF,QAAAA,GAAG,EAAE9C,EAAE,CAACkI,OAP0B;AAQlCC,QAAAA,KAAK,EAAE;AAR2B,OAAD,CAAnC;AAUD;;;;EA9UuC/H,S;SAArBG,Y","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IFramebuffer,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { generateColorRamp, IColorRamp } from '@antv/l7-utils';\nimport { mat4 } from 'gl-matrix';\nimport { inject, injectable } from 'inversify';\nimport 'reflect-metadata';\nimport BaseModel from '../../core/BaseModel';\nimport { HeatmapTriangulation } from '../../core/triangulation';\nimport heatmap3DFrag from '../shaders/heatmap_3d_frag.glsl';\nimport heatmap3DVert from '../shaders/heatmap_3d_vert.glsl';\nimport heatmapColorFrag from '../shaders/heatmap_frag.glsl';\nimport heatmapFrag from '../shaders/heatmap_framebuffer_frag.glsl';\nimport heatmapVert from '../shaders/heatmap_framebuffer_vert.glsl';\nimport heatmapColorVert from '../shaders/heatmap_vert.glsl';\nimport { heatMap3DTriangulation } from '../triangulation';\ninterface IHeatMapLayerStyleOptions {\n opacity: number;\n intensity: number;\n radius: number;\n angle: number;\n rampColors: IColorRamp;\n}\n@injectable()\nexport default class HeatMapModel extends BaseModel {\n protected texture: ITexture2D;\n protected colorTexture: ITexture2D;\n protected heatmapFramerBuffer: IFramebuffer;\n private intensityModel: IModel;\n private colorModel: IModel;\n private shapeType: string;\n\n public render() {\n const { clear, useFramebuffer } = this.rendererService;\n useFramebuffer(this.heatmapFramerBuffer, () => {\n clear({\n color: [0, 0, 0, 0],\n depth: 1,\n stencil: 0,\n framebuffer: this.heatmapFramerBuffer,\n });\n this.drawIntensityMode();\n });\n if (this.layer.styleNeedUpdate) {\n this.updateColorTexture();\n }\n this.shapeType === 'heatmap' ? this.drawColorMode() : this.draw3DHeatMap();\n }\n\n public getUninforms(): IModelUniform {\n throw new Error('Method not implemented.');\n }\n\n public initModels(): IModel[] {\n const {\n createFramebuffer,\n clear,\n getViewportSize,\n createTexture2D,\n useFramebuffer,\n } = this.rendererService;\n const shapeAttr = this.styleAttributeService.getLayerStyleAttribute(\n 'shape',\n );\n const shapeType = shapeAttr?.scale?.field || 'heatmap';\n this.shapeType = shapeType as string;\n // 生成热力图密度图\n this.intensityModel = this.buildHeatMapIntensity();\n // 渲染到屏幕\n this.colorModel =\n shapeType === 'heatmap'\n ? this.buildHeatmapColor() // 2D\n : this.build3dHeatMap(); // 3D\n\n const { width, height } = getViewportSize();\n\n // 初始化密度图纹理\n this.heatmapFramerBuffer = createFramebuffer({\n color: createTexture2D({\n width: Math.floor(width / 4),\n height: Math.floor(height / 4),\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.LINEAR,\n mag: gl.LINEAR,\n }),\n depth: false,\n });\n\n this.updateColorTexture();\n\n return [this.intensityModel, this.colorModel];\n }\n\n public buildModels(): IModel[] {\n return this.initModels();\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'dir',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Dir',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4]];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return [size as number];\n },\n },\n });\n }\n private buildHeatMapIntensity(): IModel {\n return this.layer.buildLayerModel({\n moduleName: 'heatmapintensity',\n vertexShader: heatmapVert,\n fragmentShader: heatmapFrag,\n triangulation: HeatmapTriangulation,\n depth: {\n enable: false,\n },\n blend: {\n enable: true,\n func: {\n srcRGB: gl.ONE,\n srcAlpha: 1,\n dstRGB: gl.ONE,\n dstAlpha: 1,\n },\n },\n });\n }\n\n private buildHeatmapColor(): IModel {\n this.shaderModuleService.registerModule('heatmapColor', {\n vs: heatmapColorVert,\n fs: heatmapColorFrag,\n });\n\n const { vs, fs, uniforms } = this.shaderModuleService.getModule(\n 'heatmapColor',\n );\n const {\n createAttribute,\n createElements,\n createBuffer,\n createModel,\n } = this.rendererService;\n return createModel({\n vs,\n fs,\n attributes: {\n a_Position: createAttribute({\n buffer: createBuffer({\n data: [-1, 1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0],\n type: gl.FLOAT,\n }),\n size: 3,\n }),\n a_Uv: createAttribute({\n buffer: createBuffer({\n data: [0, 1, 1, 1, 0, 0, 1, 0],\n type: gl.FLOAT,\n }),\n size: 2,\n }),\n },\n uniforms: {\n ...uniforms,\n },\n depth: {\n enable: false,\n },\n blend: this.getBlend(),\n count: 6,\n elements: createElements({\n data: [0, 2, 1, 2, 3, 1],\n type: gl.UNSIGNED_INT,\n count: 6,\n }),\n });\n }\n\n private drawIntensityMode() {\n const {\n opacity,\n intensity = 10,\n radius = 5,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n this.intensityModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_radius: radius,\n u_intensity: intensity,\n },\n });\n }\n\n private drawColorMode() {\n const {\n opacity,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n this.colorModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_colorTexture: this.colorTexture,\n u_texture: this.heatmapFramerBuffer,\n },\n });\n }\n\n private draw3DHeatMap() {\n const {\n opacity,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n\n // const invert = mat4.invert(\n // mat4.create(),\n // mat4.fromValues(\n // // @ts-ignore\n // ...this.cameraService.getViewProjectionMatrixUncentered(),\n // ),\n // ) as mat4;\n const invert = mat4.create();\n mat4.invert(\n invert,\n this.cameraService.getViewProjectionMatrixUncentered() as mat4,\n );\n\n this.colorModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_colorTexture: this.colorTexture,\n u_texture: this.heatmapFramerBuffer,\n u_ViewProjectionMatrixUncentered: this.cameraService.getViewProjectionMatrixUncentered(),\n u_InverseViewProjectionMatrix: [...invert],\n },\n });\n }\n private build3dHeatMap() {\n const { getViewportSize } = this.rendererService;\n const { width, height } = getViewportSize();\n const triangulation = heatMap3DTriangulation(width / 4.0, height / 4.0);\n this.shaderModuleService.registerModule('heatmap3dColor', {\n vs: heatmap3DVert,\n fs: heatmap3DFrag,\n });\n\n const { vs, fs, uniforms } = this.shaderModuleService.getModule(\n 'heatmap3dColor',\n );\n const {\n createAttribute,\n createElements,\n createBuffer,\n createModel,\n } = this.rendererService;\n return createModel({\n vs,\n fs,\n attributes: {\n a_Position: createAttribute({\n buffer: createBuffer({\n data: triangulation.vertices,\n type: gl.FLOAT,\n }),\n size: 3,\n }),\n a_Uv: createAttribute({\n buffer: createBuffer({\n data: triangulation.uvs,\n type: gl.FLOAT,\n }),\n size: 2,\n }),\n },\n primitive: gl.TRIANGLES,\n uniforms: {\n ...uniforms,\n },\n depth: {\n enable: true,\n },\n blend: {\n enable: true,\n func: {\n srcRGB: gl.SRC_ALPHA,\n srcAlpha: 1,\n dstRGB: gl.ONE_MINUS_SRC_ALPHA,\n dstAlpha: 1,\n },\n },\n elements: createElements({\n data: triangulation.indices,\n type: gl.UNSIGNED_INT,\n count: triangulation.indices.length,\n }),\n });\n }\n private updateStyle() {\n this.updateColorTexture();\n }\n\n private updateColorTexture() {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.destroy();\n }\n\n const {\n rampColors,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n const imageData = generateColorRamp(rampColors as IColorRamp);\n this.colorTexture = createTexture2D({\n data: new Uint8Array(imageData.data),\n width: imageData.width,\n height: imageData.height,\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.NEAREST,\n mag: gl.NEAREST,\n flipY: false,\n });\n }\n}\n"],"file":"heatmap.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/heatmap/models/heatmap.ts"],"names":["AttributeType","gl","generateColorRamp","mat4","injectable","BaseModel","HeatmapTriangulation","heatMap3DTriangulation","HeatMapModel","rendererService","clear","useFramebuffer","heatmapFramerBuffer","color","depth","stencil","framebuffer","drawIntensityMode","layer","styleNeedUpdate","updateColorTexture","shapeType","drawColorMode","draw3DHeatMap","Error","createFramebuffer","getViewportSize","createTexture2D","shapeAttr","styleAttributeService","getLayerStyleAttribute","scale","field","intensityModel","buildHeatMapIntensity","colorModel","buildHeatmapColor","build3dHeatMap","width","height","Math","floor","wrapS","CLAMP_TO_EDGE","wrapT","min","LINEAR","mag","initModels","registerStyleAttribute","name","type","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","data","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","buildLayerModel","moduleName","vertexShader","heatmapFramebufferVert","fragmentShader","heatmapFramebufferFrag","triangulation","enable","blend","func","srcRGB","ONE","srcAlpha","dstRGB","dstAlpha","shaderModuleService","registerModule","vs","heatmapColorVert","fs","heatmapColorFrag","getModule","uniforms","createAttribute","createElements","createBuffer","createModel","attributes","a_Position","a_Uv","getBlend","count","elements","UNSIGNED_INT","getLayerConfig","opacity","intensity","radius","draw","u_opacity","u_radius","u_intensity","u_colorTexture","colorTexture","u_texture","invert","create","cameraService","getViewProjectionMatrixUncentered","u_ViewProjectionMatrixUncentered","u_InverseViewProjectionMatrix","heatmap3DVert","heatmap3DFrag","vertices","uvs","primitive","TRIANGLES","SRC_ALPHA","ONE_MINUS_SRC_ALPHA","indices","length","texture","destroy","rampColors","imageData","Uint8Array","NEAREST","flipY"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAQO,eARP;AASA,SAASC,iBAAT,QAA8C,gBAA9C;AACA,SAASC,IAAT,QAAqB,WAArB;AACA,SAAiBC,UAAjB,QAAmC,WAAnC;AACA,OAAO,kBAAP;AACA,OAAOC,SAAP,MAAsB,sBAAtB;AACA,SAASC,oBAAT,QAAqC,0BAArC;;;;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from '@antv/l7-core';\nimport { generateColorRamp, IColorRamp } from '@antv/l7-utils';\nimport { mat4 } from 'gl-matrix';\nimport { inject, injectable } from 'inversify';\nimport 'reflect-metadata';\nimport BaseModel from '../../core/BaseModel';\nimport { HeatmapTriangulation } from '../../core/triangulation';\nimport heatmap3DFrag from '../shaders/heatmap_3d_frag.glsl';\nimport heatmap3DVert from '../shaders/heatmap_3d_vert.glsl';\nimport heatmapColorFrag from '../shaders/heatmap_frag.glsl';\nimport heatmapFramebufferFrag from '../shaders/heatmap_framebuffer_frag.glsl';\nimport heatmapFramebufferVert from '../shaders/heatmap_framebuffer_vert.glsl';\nimport heatmapColorVert from '../shaders/heatmap_vert.glsl';\nimport { heatMap3DTriangulation } from '../triangulation';\ninterface IHeatMapLayerStyleOptions {\n opacity: number;\n intensity: number;\n radius: number;\n angle: number;\n rampColors: IColorRamp;\n}\n@injectable()\nexport default class HeatMapModel extends BaseModel {\n protected texture: ITexture2D;\n protected colorTexture: ITexture2D;\n protected heatmapFramerBuffer: IFramebuffer;\n private intensityModel: IModel;\n private colorModel: IModel;\n private shapeType: string;\n\n public render() {\n const { clear, useFramebuffer } = this.rendererService;\n useFramebuffer(this.heatmapFramerBuffer, () => {\n clear({\n color: [0, 0, 0, 0],\n depth: 1,\n stencil: 0,\n framebuffer: this.heatmapFramerBuffer,\n });\n this.drawIntensityMode();\n });\n if (this.layer.styleNeedUpdate) {\n this.updateColorTexture();\n }\n this.shapeType === 'heatmap' ? this.drawColorMode() : this.draw3DHeatMap();\n }\n\n public getUninforms(): IModelUniform {\n throw new Error('Method not implemented.');\n }\n\n public initModels(): IModel[] {\n const {\n createFramebuffer,\n clear,\n getViewportSize,\n createTexture2D,\n useFramebuffer,\n } = this.rendererService;\n const shapeAttr = this.styleAttributeService.getLayerStyleAttribute(\n 'shape',\n );\n const shapeType = shapeAttr?.scale?.field || 'heatmap';\n this.shapeType = shapeType as string;\n // 生成热力图密度图\n this.intensityModel = this.buildHeatMapIntensity();\n // 渲染到屏幕\n this.colorModel =\n shapeType === 'heatmap'\n ? this.buildHeatmapColor() // 2D\n : this.build3dHeatMap(); // 3D\n\n const { width, height } = getViewportSize();\n\n // 初始化密度图纹理\n this.heatmapFramerBuffer = createFramebuffer({\n color: createTexture2D({\n width: Math.floor(width / 4),\n height: Math.floor(height / 4),\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.LINEAR,\n mag: gl.LINEAR,\n }),\n depth: false,\n });\n\n this.updateColorTexture();\n\n return [this.intensityModel, this.colorModel];\n }\n\n public buildModels(): IModel[] {\n return this.initModels();\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'dir',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Dir',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4]];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return [size as number];\n },\n },\n });\n }\n private buildHeatMapIntensity(): IModel {\n return this.layer.buildLayerModel({\n moduleName: 'heatmapintensity',\n vertexShader: heatmapFramebufferVert,\n fragmentShader: heatmapFramebufferFrag,\n triangulation: HeatmapTriangulation,\n depth: {\n enable: false,\n },\n blend: {\n enable: true,\n func: {\n srcRGB: gl.ONE,\n srcAlpha: 1,\n dstRGB: gl.ONE,\n dstAlpha: 1,\n },\n },\n });\n }\n\n private buildHeatmapColor(): IModel {\n this.shaderModuleService.registerModule('heatmapColor', {\n vs: heatmapColorVert,\n fs: heatmapColorFrag,\n });\n\n const { vs, fs, uniforms } = this.shaderModuleService.getModule(\n 'heatmapColor',\n );\n const {\n createAttribute,\n createElements,\n createBuffer,\n createModel,\n } = this.rendererService;\n return createModel({\n vs,\n fs,\n attributes: {\n a_Position: createAttribute({\n buffer: createBuffer({\n data: [-1, 1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0],\n type: gl.FLOAT,\n }),\n size: 3,\n }),\n a_Uv: createAttribute({\n buffer: createBuffer({\n data: [0, 1, 1, 1, 0, 0, 1, 0],\n type: gl.FLOAT,\n }),\n size: 2,\n }),\n },\n uniforms: {\n ...uniforms,\n },\n depth: {\n enable: false,\n },\n blend: this.getBlend(),\n count: 6,\n elements: createElements({\n data: [0, 2, 1, 2, 3, 1],\n type: gl.UNSIGNED_INT,\n count: 6,\n }),\n });\n }\n\n private drawIntensityMode() {\n const {\n opacity,\n intensity = 10,\n radius = 5,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n this.intensityModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_radius: radius,\n u_intensity: intensity,\n },\n });\n }\n\n private drawColorMode() {\n const {\n opacity,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n this.colorModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_colorTexture: this.colorTexture,\n u_texture: this.heatmapFramerBuffer,\n },\n });\n }\n\n private draw3DHeatMap() {\n const {\n opacity,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n\n // const invert = mat4.invert(\n // mat4.create(),\n // mat4.fromValues(\n // // @ts-ignore\n // ...this.cameraService.getViewProjectionMatrixUncentered(),\n // ),\n // ) as mat4;\n const invert = mat4.create();\n mat4.invert(\n invert,\n this.cameraService.getViewProjectionMatrixUncentered() as mat4,\n );\n\n this.colorModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_colorTexture: this.colorTexture,\n u_texture: this.heatmapFramerBuffer,\n u_ViewProjectionMatrixUncentered: this.cameraService.getViewProjectionMatrixUncentered(),\n u_InverseViewProjectionMatrix: [...invert],\n },\n });\n }\n private build3dHeatMap() {\n const { getViewportSize } = this.rendererService;\n const { width, height } = getViewportSize();\n const triangulation = heatMap3DTriangulation(width / 4.0, height / 4.0);\n this.shaderModuleService.registerModule('heatmap3dColor', {\n vs: heatmap3DVert,\n fs: heatmap3DFrag,\n });\n\n const { vs, fs, uniforms } = this.shaderModuleService.getModule(\n 'heatmap3dColor',\n );\n const {\n createAttribute,\n createElements,\n createBuffer,\n createModel,\n } = this.rendererService;\n return createModel({\n vs,\n fs,\n attributes: {\n a_Position: createAttribute({\n buffer: createBuffer({\n data: triangulation.vertices,\n type: gl.FLOAT,\n }),\n size: 3,\n }),\n a_Uv: createAttribute({\n buffer: createBuffer({\n data: triangulation.uvs,\n type: gl.FLOAT,\n }),\n size: 2,\n }),\n },\n primitive: gl.TRIANGLES,\n uniforms: {\n ...uniforms,\n },\n depth: {\n enable: true,\n },\n blend: {\n enable: true,\n func: {\n srcRGB: gl.SRC_ALPHA,\n srcAlpha: 1,\n dstRGB: gl.ONE_MINUS_SRC_ALPHA,\n dstAlpha: 1,\n },\n },\n elements: createElements({\n data: triangulation.indices,\n type: gl.UNSIGNED_INT,\n count: triangulation.indices.length,\n }),\n });\n }\n private updateStyle() {\n this.updateColorTexture();\n }\n\n private updateColorTexture() {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.destroy();\n }\n\n const {\n rampColors,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n const imageData = generateColorRamp(rampColors as IColorRamp);\n this.colorTexture = createTexture2D({\n data: new Uint8Array(imageData.data),\n width: imageData.width,\n height: imageData.height,\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.NEAREST,\n mag: gl.NEAREST,\n flipY: false,\n });\n }\n}\n"],"file":"heatmap.js"}
|
|
@@ -2,6 +2,7 @@ import { IModelUniform } from '@antv/l7-core';
|
|
|
2
2
|
import BaseModel from '../../core/BaseModel';
|
|
3
3
|
export default class ImageTileModel extends BaseModel {
|
|
4
4
|
tileLayer: any;
|
|
5
|
+
private timestamp;
|
|
5
6
|
getUninforms(): IModelUniform;
|
|
6
7
|
tile(): void;
|
|
7
8
|
initModels(): import("@antv/l7-core").IModel[];
|
|
@@ -36,6 +36,8 @@ var ImageTileModel = function (_BaseModel) {
|
|
|
36
36
|
|
|
37
37
|
_defineProperty(_assertThisInitialized(_this), "tileLayer", void 0);
|
|
38
38
|
|
|
39
|
+
_defineProperty(_assertThisInitialized(_this), "timestamp", void 0);
|
|
40
|
+
|
|
39
41
|
return _this;
|
|
40
42
|
}
|
|
41
43
|
|
|
@@ -95,21 +97,17 @@ var ImageTileModel = function (_BaseModel) {
|
|
|
95
97
|
crstype: 'epsg3857'
|
|
96
98
|
});
|
|
97
99
|
this.tile();
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
t = newT;
|
|
103
|
-
|
|
104
|
-
if (cutT < 16) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (_this2.mapService.getZoom() < 2.0) {
|
|
109
|
-
return;
|
|
100
|
+
this.mapService.on('mapchange', function (e) {
|
|
101
|
+
if (_this2.timestamp) {
|
|
102
|
+
clearTimeout(_this2.timestamp);
|
|
103
|
+
_this2.timestamp = null;
|
|
110
104
|
}
|
|
111
105
|
|
|
112
|
-
_this2.
|
|
106
|
+
_this2.timestamp = setTimeout(function () {
|
|
107
|
+
if (_this2.mapService.getZoom() >= 2.0) {
|
|
108
|
+
_this2.tile();
|
|
109
|
+
}
|
|
110
|
+
}, 500);
|
|
113
111
|
});
|
|
114
112
|
}
|
|
115
113
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/imagetile/models/imagetile.ts"],"names":["gl","BaseModel","RasterImageTriangulation","Tile","ImageTileModel","mapService","getBounds","WS","EN","NE","lng","lat","SW","tileLayer","calCurrentTiles","tileCenter","getCenter","currentZoom","getZoom","minSourceZoom","getMinZoom","minZoom","maxZoom","getMaxZoom","layer","zIndex","getLayerConfig","resolution","maxSourceZoom","source","getSource","data","tileurl","url","layerService","crstype","tile","
|
|
1
|
+
{"version":3,"sources":["../../../src/imagetile/models/imagetile.ts"],"names":["gl","BaseModel","RasterImageTriangulation","Tile","ImageTileModel","mapService","getBounds","WS","EN","NE","lng","lat","SW","tileLayer","calCurrentTiles","tileCenter","getCenter","currentZoom","getZoom","minSourceZoom","getMinZoom","minZoom","maxZoom","getMaxZoom","layer","zIndex","getLayerConfig","resolution","maxSourceZoom","source","getSource","data","tileurl","url","layerService","crstype","tile","on","e","timestamp","clearTimeout","setTimeout","buildLayerModel","moduleName","vertexShader","ImageTileVert","fragmentShader","ImageTileFrag","triangulation","primitive","TRIANGLES","depth","enable","blend","getBlend","removeTiles","initModels"],"mappings":";;;;;;;;;;;;;AAAA,SAASA,EAAT,QAAkC,eAAlC;AACA,OAAOC,SAAP,MAAsB,sBAAtB;AACA,SAASC,wBAAT,QAAyC,0BAAzC;;;AAIA,OAAOC,IAAP,MAAiB,eAAjB;;IAOqBC,c;;;;;;;;;;;;;;;;;;;;;;;;;WAGnB,wBAAqC;AACnC,aAAO,EAAP;AACD;;;WAGD,gBAAc;AACZ,kCAAiB,KAAKC,UAAL,CAAgBC,SAAhB,EAAjB;AAAA;AAAA,UAAOC,EAAP;AAAA,UAAWC,EAAX;;AACA,UAAMC,EAAE,GAAG;AAAEC,QAAAA,GAAG,EAAEF,EAAE,CAAC,CAAD,CAAT;AAAcG,QAAAA,GAAG,EAAEH,EAAE,CAAC,CAAD;AAArB,OAAX;AACA,UAAMI,EAAE,GAAG;AAAEF,QAAAA,GAAG,EAAEH,EAAE,CAAC,CAAD,CAAT;AAAcI,QAAAA,GAAG,EAAEJ,EAAE,CAA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AAoB;AAClBC,YAAAA,YAAY,CAAC,MAAI,CAACD,SAAN,CAAZ;AACA,YAAA,MAAI,CAACA,SAAL,GAAiB,IAAjB;AACD;;AAED,UAAA,MAAI,CAACA,SAAL,GAAiBE,UAAU,CAAC,YAAM;AAEhC,gBAAI,MAAI,CAACpC,UAAL,CAAgBa,OAAhB,MAA6B,GAAjC,EAAsC;AACpC,cAAA,MAAI,CAACkB,IAAL;AACD;AACF,WAL0B,EAKxB,GALwB,CAA3B;AAMD,SAZD;AAaD;;AAED,aAAO,CACL,KAAKZ,KAAL,CAAWkB,eAAX,CAA2B;AACzBC,QAAAA,UAAU,EAAE,gBADa;AAEzBC,QAAAA,YAAY,EAAEC,aAFW;AAGzBC,QAAAA,cAAc,EAAEC,aAHS;AAIzBC,QAAAA,aAAa,EAAE9C,wBAJU;AAKzB+C,QAAAA,SAAS,EAAEjD,EAAE,CAACkD,SALW;AAMzBC,QAAAA,KAAK,EAAE;AAAEC,UAAAA,MAAM,EAAE;AAAV,SANkB;AAOzBC,QAAAA,KAAK,EAAE,KAAKC,QAAL;AAPkB,OAA3B,CADK,CAAP;AAWD;;;WAED,uBAAqB;AACnB,WAAKzC,SAAL,CAAe0C,WAAf;AACD;;;WAED,uBAAqB;AACnB,aAAO,KAAKC,UAAL,EAAP;AACD;;;WAED,qCAAsC;AACpC;AACD;;;;EApFyCvD,S;;SAAvBG,c","sourcesContent":["import { gl, IModelUniform } from '@antv/l7-core';\nimport BaseModel from '../../core/BaseModel';\nimport { RasterImageTriangulation } from '../../core/triangulation';\nimport ImageTileFrag from './shaders/imagetile_frag.glsl';\nimport ImageTileVert from './shaders/imagetile_vert.glsl';\n\nimport Tile from '../utils/Tile';\n\ninterface IImageLayerStyleOptions {\n resolution: string;\n maxSourceZoom: number;\n}\n\nexport default class ImageTileModel extends BaseModel {\n public tileLayer: any;\n private timestamp: number | null;\n public getUninforms(): IModelUniform {\n return {};\n }\n\n // 瓦片方法\n public tile() {\n const [WS, EN] = this.mapService.getBounds();\n const NE = { lng: EN[0], lat: EN[1] };\n const SW = { lng: WS[0], lat: WS[1] };\n this.tileLayer.calCurrentTiles({\n NE,\n SW,\n tileCenter: this.mapService.getCenter(),\n currentZoom: this.mapService.getZoom(),\n minSourceZoom: this.mapService.getMinZoom(),\n minZoom: this.mapService.getMinZoom(),\n maxZoom: this.mapService.getMaxZoom(),\n });\n }\n\n public initModels() {\n // TODO: 瓦片组件默认在最下层\n this.layer.zIndex = -999;\n const {\n resolution = 'low',\n maxSourceZoom = 17,\n } = this.layer.getLayerConfig() as IImageLayerStyleOptions;\n const source = this.layer.getSource();\n // 当存在 url 的时候生效\n if (source.data.tileurl) {\n this.tileLayer = new Tile({\n url: source.data.tileurl,\n layerService: this.layerService,\n layer: this.layer,\n resolution,\n maxSourceZoom,\n // Tip: 当前为 default\n crstype: 'epsg3857',\n });\n\n // TODO: 首次加载的时候请求瓦片\n this.tile();\n\n this.mapService.on('mapchange', (e) => {\n if (this.timestamp) {\n clearTimeout(this.timestamp);\n this.timestamp = null;\n }\n // @ts-ignore 节流\n this.timestamp = setTimeout(() => {\n // TODO: 瓦片地图最大层级为 2\n if (this.mapService.getZoom() >= 2.0) {\n this.tile();\n }\n }, 500);\n });\n }\n\n return [\n this.layer.buildLayerModel({\n moduleName: 'ImageTileLayer',\n vertexShader: ImageTileVert,\n fragmentShader: ImageTileFrag,\n triangulation: RasterImageTriangulation,\n primitive: gl.TRIANGLES,\n depth: { enable: false },\n blend: this.getBlend(),\n }),\n ];\n }\n\n public clearModels() {\n this.tileLayer.removeTiles();\n }\n\n public buildModels() {\n return this.initModels();\n }\n\n protected registerBuiltinAttributes() {\n return;\n }\n}\n"],"file":"imagetile.js"}
|
package/es/point/models/fill.js
CHANGED
|
@@ -14,8 +14,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
14
14
|
import { AttributeType, gl } from '@antv/l7-core';
|
|
15
15
|
import BaseModel from '../../core/BaseModel';
|
|
16
16
|
import { GlobelPointFillTriangulation, PointFillTriangulation } from '../../core/triangulation';
|
|
17
|
-
var pointFillFrag = "#define Animate 0.0\n\nuniform float u_globel;\nuniform float
|
|
18
|
-
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute float a_Shape;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\nuniform float u_globel;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\n\nuniform float u_opacity : 1;\nuniform float u_stroke_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\nuniform vec2 u_offsets;\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\n\nvoid main() {\n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n float newSize = setPickingSize(a_Size);\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 strokeOpacityAndOffset = calStrokeOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][1] = strokeOpacityAndOffset.r;\n textureOffset = strokeOpacityAndOffset.g;\n\n vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][2] = strokeWidthAndOffset.r;\n textureOffset = strokeWidthAndOffset.g;\n\n vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);\n if(hasStroke()) {\n vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R\n textureOffset += 1.0;\n\n vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G\n textureOffset += 1.0;\n\n vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B\n textureOffset += 1.0;\n\n vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A\n textureOffset += 1.0;\n } else {\n if(u_stroke_color == vec4(0.0)) {\n styleMappingMat[1][0] = v_color.r;\n styleMappingMat[1][1] = v_color.g;\n styleMappingMat[1][2] = v_color.b;\n styleMappingMat[1][3] = v_color.a;\n } else {\n styleMappingMat[1][0] = u_stroke_color.r;\n styleMappingMat[1][1] = u_stroke_color.g;\n styleMappingMat[1][2] = u_stroke_color.b;\n styleMappingMat[1][3] = u_stroke_color.a;\n }\n }\n\n vec2 textrueOffsets = vec2(0.0, 0.0);\n if(hasOffsets()) {\n vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n\n vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n } else {\n textrueOffsets = u_offsets;\n }\n\n // cal style mapping\n\n // unpack color(vec2)\n v_color = a_Color;\n\n // radius(16-bit)\n v_radius = newSize;\n\n // TODO: billboard\n // anti-alias\n float antialiasblur = 1.0 / u_DevicePixelRatio / (newSize + u_stroke_width);\n\n // construct point coords\n // TODP: /abs(extrude.x) \u662F\u4E3A\u4E86\u517C\u5BB9\u5730\u7403\u6A21\u5F0F\n v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);\n\n // vec2 offset = project_pixel(extrude * (newSize + u_stroke_width) + u_offsets);\n vec2 offset = project_pixel(extrude.xy * (newSize + u_stroke_width) + textrueOffsets);\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, 0.0, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n }\n\n if(u_globel > 0.0) {\n gl_Position = u_ViewProjectionMatrix * vec4(a_Position + extrude * newSize * 0.1, 1.0);\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
17
|
+
var pointFillFrag = "#define Animate 0.0\n\nuniform float u_globel;\nuniform float u_additive;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\n\nvoid main() {\n int shape = int(floor(v_data.w + 0.5));\n\n \n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n float opacity = styleMappingMat[0][0];\n float stroke_opacity = styleMappingMat[0][1];\n float strokeWidth = styleMappingMat[0][2];\n vec4 strokeColor = textrueStroke == vec4(0) ? v_color : textrueStroke;\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius + strokeWidth);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n if (shape == 0) {\n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n } else if (shape == 1) {\n outer_df = sdEquilateralTriangle(1.1 * v_data.xy);\n inner_df = sdEquilateralTriangle(1.1 / r * v_data.xy);\n } else if (shape == 2) {\n outer_df = sdBox(v_data.xy, vec2(1.));\n inner_df = sdBox(v_data.xy, vec2(r));\n } else if (shape == 3) {\n outer_df = sdPentagon(v_data.xy, 0.8);\n inner_df = sdPentagon(v_data.xy, r * 0.8);\n } else if (shape == 4) {\n outer_df = sdHexagon(v_data.xy, 0.8);\n inner_df = sdHexagon(v_data.xy, r * 0.8);\n } else if (shape == 5) {\n outer_df = sdOctogon(v_data.xy, 1.0);\n inner_df = sdOctogon(v_data.xy, r);\n } else if (shape == 6) {\n outer_df = sdHexagram(v_data.xy, 0.52);\n inner_df = sdHexagram(v_data.xy, r * 0.52);\n } else if (shape == 7) {\n outer_df = sdRhombus(v_data.xy, vec2(1.0));\n inner_df = sdRhombus(v_data.xy, vec2(r));\n } else if (shape == 8) {\n outer_df = sdVesica(v_data.xy, 1.1, 0.8);\n inner_df = sdVesica(v_data.xy, r * 1.1, r * 0.8);\n }\n\n if(u_globel > 0.0) {\n // TODO: \u5730\u7403\u6A21\u5F0F\u4E0B\u907F\u514D\u591A\u4F59\u7247\u5143\u7ED8\u5236\uFF0C\u540C\u65F6\u4E5F\u80FD\u907F\u514D\u6709\u7528\u7247\u5143\u5728\u900F\u660E\u4E14\u91CD\u53E0\u7684\u60C5\u51B5\u4E0B\u65E0\u6CD5\u5199\u5165\n // \u4ED8\u51FA\u7684\u4EE3\u4EF7\u662F\u8FB9\u7F18\u4F1A\u6709\u4E00\u4E9B\u952F\u9F7F\n if(outer_df > antialiasblur + 0.018) discard;\n }\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df); \n\n float color_t = strokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n float PI = 3.14159;\n float N_RINGS = 3.0;\n float FREQ = 1.0;\n\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), strokeColor * stroke_opacity, color_t);\n\n if(u_aimate.x == Animate) {\n float d = length(v_data.xy);\n float intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_aimate.z - u_aimate.y * u_time)), 0.0, 1.0);\n \n // TODO: \u6839\u636E\u53E0\u52A0\u6A21\u5F0F\u9009\u62E9\u6548\u679C\n if(u_additive > 0.0) {\n gl_FragColor *= intensity;\n } else {\n gl_FragColor = vec4(gl_FragColor.xyz, intensity);\n }\n \n // TODO: \u4F18\u5316\u5728\u6C34\u6CE2\u7EB9\u60C5\u51B5\u4E0B\u7684\u62FE\u53D6\uFF08a == 0 \u65F6\u65E0\u6CD5\u62FE\u53D6\uFF09\n if(d < 0.7) {\n gl_FragColor.a = max(gl_FragColor.a, 0.001);\n }\n\n if(u_additive > 0.0) {\n gl_FragColor = filterColorAnimate(gl_FragColor);\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n\n gl_FragColor *= opacity_t;\n}\n";
|
|
18
|
+
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute float a_Shape;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\nuniform float u_globel;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\n\nuniform float u_opacity : 1;\nuniform float u_stroke_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\nuniform vec2 u_offsets;\n\nuniform float u_blur : 0.0;\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\n\nvoid main() {\n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n float newSize = setPickingSize(a_Size);\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 strokeOpacityAndOffset = calStrokeOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][1] = strokeOpacityAndOffset.r;\n textureOffset = strokeOpacityAndOffset.g;\n\n vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][2] = strokeWidthAndOffset.r;\n textureOffset = strokeWidthAndOffset.g;\n\n vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);\n if(hasStroke()) {\n vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R\n textureOffset += 1.0;\n\n vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G\n textureOffset += 1.0;\n\n vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B\n textureOffset += 1.0;\n\n vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A\n textureOffset += 1.0;\n } else {\n if(u_stroke_color == vec4(0.0)) {\n styleMappingMat[1][0] = v_color.r;\n styleMappingMat[1][1] = v_color.g;\n styleMappingMat[1][2] = v_color.b;\n styleMappingMat[1][3] = v_color.a;\n } else {\n styleMappingMat[1][0] = u_stroke_color.r;\n styleMappingMat[1][1] = u_stroke_color.g;\n styleMappingMat[1][2] = u_stroke_color.b;\n styleMappingMat[1][3] = u_stroke_color.a;\n }\n }\n\n vec2 textrueOffsets = vec2(0.0, 0.0);\n if(hasOffsets()) {\n vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n\n vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n } else {\n textrueOffsets = u_offsets;\n }\n\n // cal style mapping\n\n // unpack color(vec2)\n v_color = a_Color;\n\n // radius(16-bit)\n v_radius = newSize;\n\n // TODO: billboard\n // anti-alias\n // float antialiased_blur = -max(u_blur, antialiasblur);\n float antialiasblur = -max(1.0 / u_DevicePixelRatio / (newSize + u_stroke_width), u_blur);\n\n // construct point coords\n // TODP: /abs(extrude.x) \u662F\u4E3A\u4E86\u517C\u5BB9\u5730\u7403\u6A21\u5F0F\n v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);\n\n // vec2 offset = project_pixel(extrude * (newSize + u_stroke_width) + u_offsets);\n vec2 offset = project_pixel(extrude.xy * (newSize + u_stroke_width) + textrueOffsets);\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, 0.0, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n }\n\n if(u_globel > 0.0) {\n gl_Position = u_ViewProjectionMatrix * vec4(a_Position + extrude * newSize * 0.1, 1.0);\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
19
19
|
import { mat4, vec3 } from 'gl-matrix';
|
|
20
20
|
|
|
21
21
|
var FillModel = function (_BaseModel) {
|
|
@@ -42,7 +42,8 @@ var FillModel = function (_BaseModel) {
|
|
|
42
42
|
_ref$stroke = _ref.stroke,
|
|
43
43
|
stroke = _ref$stroke === void 0 ? 'rgba(0,0,0,0)' : _ref$stroke,
|
|
44
44
|
_ref$offsets = _ref.offsets,
|
|
45
|
-
offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets
|
|
45
|
+
offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets,
|
|
46
|
+
blend = _ref.blend;
|
|
46
47
|
|
|
47
48
|
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
48
49
|
opacity: opacity,
|
|
@@ -84,6 +85,7 @@ var FillModel = function (_BaseModel) {
|
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
return {
|
|
88
|
+
u_additive: blend === 'additive' ? 1.0 : 0.0,
|
|
87
89
|
u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,
|
|
88
90
|
u_dataTexture: this.dataTexture,
|
|
89
91
|
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/point/models/fill.ts"],"names":["AttributeType","gl","BaseModel","GlobelPointFillTriangulation","PointFillTriangulation","mat4","vec3","FillModel","layer","getLayerConfig","opacity","strokeOpacity","strokeWidth","stroke","offsets","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_globel","mapService","version","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_stroke_opacity","u_stroke_width","u_stroke_color","getStrokeColor","u_offsets","isOffsetStatic","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","styleAttributeService","createAttributesAndIndices","buildModels","isGlobel","buildLayerModel","moduleName","vertexShader","pointFillVert","fragmentShader","pointFillFrag","triangulation","depth","enable","blend","getBlend","destroy","option","speed","rings","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","extrude","x","y","z","n1","fromValues","n2","xzReg","angle","Math","PI","yReg","asin","m","create","rotateY","rotateX","v1","transformMat4","normalize","v2","v3","v4","extrudeIndex","Array","isArray","shape","shape2d","shapeIndex","indexOf"],"mappings":";;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAUO,eAVP;AAWA,OAAOC,SAAP,MAIO,sBAJP;AAKA,SACEC,4BADF,EAEEC,sBAFF,QAGO,0BAHP;;;AASA,SAASC,IAAT,EAAeC,IAAf,QAA2B,WAA3B;;IAUqBC,S;;;;;;;;;;;;;WACnB,wBAAqC;AACnC,iBAMI,KAAKC,KAAL,CAAWC,cAAX,EANJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,oCAEEC,aAFF;AAAA,UAEEA,aAFF,mCAEkB,CAFlB;AAAA,kCAGEC,WAHF;AAAA,UAGEA,WAHF,iCAGgB,CAHhB;AAAA,6BAIEC,MAJF;AAAA,UAIEA,MAJF,4BAIW,eAJX;AAAA,8BAKEC,OALF;AAAA,UAKEA,OALF,6BAKY,CAAC,CAAD,EAAI,CAAJ,CALZ;;AAQA,UACE,KAAKC,eAAL,IACA,KAAKC,qBAAL,CAA2B;AACzBN,QAAAA,OAAO,EAAPA,OADyB;AAEzBC,QAAAA,aAAa,EAAbA,aAFyB;AAGzBC,QAAAA,WAAW,EAAXA,WAHyB;AAIzBC,QAAAA,MAAM,EAANA,MAJyB;AAKzBC,QAAAA,OAAO,EAAPA;AALyB,OAA3B,CAFF,EASE;AAEA,aAAKG,oBAAL,CAA0B;AACxBP,UAAAA,OAAO,EAAPA,OADwB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AAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,gCAAqBH,OAArB,CAAQF,IAAR;AAAA,gBAAQA,IAAR,8BAAe,CAAf;AAEA,mBAAO8B,KAAK,CAACC,OAAN,CAAc/B,IAAd,IAAsB,CAACA,IAAI,CAAC,CAAD,CAAL,CAAtB,GAAkC,CAACA,IAAD,CAAzC;AACD;AAlBS;AAHoC,OAAlD;AA0BA,WAAK1B,qBAAL,CAA2BmB,sBAA3B,CAAkD;AAChDC,QAAAA,IAAI,EAAE,OAD0C;AAEhDxC,QAAAA,IAAI,EAAEjC,aAAa,CAAC0E,SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVF,UAAAA,IAAI,EAAE,SADI;AAEVG,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAE5E,EAAE,CAAC6E,YAFJ;AAGNvD,YAAAA,IAAI,EAAE,EAHA;AAINU,YAAAA,IAAI,EAAEhC,EAAE,CAACiC;AAJH,WAFE;AAQV6C,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,iCAAsBH,OAAtB,CAAQ8B,KAAR;AAAA,gBAAQA,KAAR,+BAAgB,CAAhB;;AACA,gBAAMC,OAAO,GAAG,KAAI,CAACxG,KAAL,CAAWC,cAAX,GAA4BuG,OAA5C;;AACA,gBAAMC,UAAU,GAAGD,OAAO,CAACE,OAAR,CAAgBH,KAAhB,CAAnB;AACA,mBAAO,CAACE,UAAD,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;;EAjPoC/G,S;;SAAlBK,S","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IAttribute,\n IElements,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport BaseModel, {\n styleColor,\n styleOffset,\n styleSingle,\n} from '../../core/BaseModel';\nimport {\n GlobelPointFillTriangulation,\n PointFillTriangulation,\n} from '../../core/triangulation';\nimport pointFillFrag from '../shaders/fill_frag.glsl';\nimport pointFillVert from '../shaders/fill_vert.glsl';\n\nimport { isNumber } from 'lodash';\n\nimport { mat4, vec3 } from 'gl-matrix';\n\ninterface IPointLayerStyleOptions {\n opacity: styleSingle;\n strokeWidth: styleSingle;\n stroke: styleColor;\n strokeOpacity: styleSingle;\n offsets: styleOffset;\n}\n// 判断当前使用的 style 中的变量属性是否需要进行数据映射\nexport default class FillModel extends BaseModel {\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = 'rgba(0,0,0,0)',\n offsets = [0, 0],\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n });\n\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_stroke_opacity: isNumber(strokeOpacity) ? strokeOpacity : 1.0,\n u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 0.0,\n u_stroke_color: this.getStrokeColor(stroke),\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n return this.styleAttributeService.createAttributesAndIndices(\n this.layer.getEncodedData(),\n PointFillTriangulation,\n );\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointfill',\n vertexShader: pointFillVert,\n fragmentShader: pointFillFrag,\n triangulation: isGlobel\n ? GlobelPointFillTriangulation\n : PointFillTriangulation,\n // depth: { enable: false },\n depth: { enable: isGlobel },\n blend: this.getBlend(),\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected animateOption2Array(option: IAnimateOption): number[] {\n return [option.enable ? 0 : 1.0, option.speed || 1, option.rings || 3, 0];\n }\n protected registerBuiltinAttributes() {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'extrude',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Extrude',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n let extrude;\n // 地球模式\n if (isGlobel) {\n const [x, y, z] = vertex;\n const n1 = vec3.fromValues(0, 0, 1);\n const n2 = vec3.fromValues(x, 0, z);\n\n const xzReg =\n x >= 0 ? vec3.angle(n1, n2) : Math.PI * 2 - vec3.angle(n1, n2);\n\n const yReg = Math.PI * 2 - Math.asin(y / 100);\n\n const m = mat4.create();\n mat4.rotateY(m, m, xzReg);\n mat4.rotateX(m, m, yReg);\n\n const v1 = vec3.fromValues(1, 1, 0);\n vec3.transformMat4(v1, v1, m);\n vec3.normalize(v1, v1);\n\n const v2 = vec3.fromValues(-1, 1, 0);\n vec3.transformMat4(v2, v2, m);\n vec3.normalize(v2, v2);\n\n const v3 = vec3.fromValues(-1, -1, 0);\n vec3.transformMat4(v3, v3, m);\n vec3.normalize(v3, v3);\n\n const v4 = vec3.fromValues(1, -1, 0);\n vec3.transformMat4(v4, v4, m);\n vec3.normalize(v4, v4);\n\n extrude = [...v1, ...v2, ...v3, ...v4];\n } else {\n // 平面模式\n extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n }\n\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 5 } = feature;\n // console.log('featureIdx', featureIdx, feature)\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'shape',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Shape',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { shape = 2 } = feature;\n const shape2d = this.layer.getLayerConfig().shape2d as string[];\n const shapeIndex = shape2d.indexOf(shape as string);\n return [shapeIndex];\n },\n },\n });\n }\n}\n"],"file":"fill.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/point/models/fill.ts"],"names":["AttributeType","gl","BaseModel","GlobelPointFillTriangulation","PointFillTriangulation","mat4","vec3","FillModel","layer","getLayerConfig","opacity","strokeOpacity","strokeWidth","stroke","offsets","blend","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","LUMINANCE","type","FLOAT","u_additive","u_globel","mapService","version","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_stroke_opacity","u_stroke_width","u_stroke_color","getStrokeColor","u_offsets","isOffsetStatic","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","styleAttributeService","createAttributesAndIndices","buildModels","isGlobel","buildLayerModel","moduleName","vertexShader","pointFillVert","fragmentShader","pointFillFrag","triangulation","depth","enable","getBlend","destroy","option","speed","rings","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","extrude","x","y","z","n1","fromValues","n2","xzReg","angle","Math","PI","yReg","asin","m","create","rotateY","rotateX","v1","transformMat4","normalize","v2","v3","v4","extrudeIndex","Array","isArray","shape","shape2d","shapeIndex","indexOf"],"mappings":";;;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAUO,eAVP;AAWA,OAAOC,SAAP,MAIO,sBAJP;AAKA,SACEC,4BADF,EAEEC,sBAFF,QAGO,0BAHP;;;AASA,SAASC,IAAT,EA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SAF4B;AAGhDC,QAAAA,UAAU,EAAE;AACVF,UAAAA,IAAI,EAAE,SADI;AAEVG,UAAAA,MAAM,EAAE;AAENC,YAAAA,KAAK,EAAE7E,EAAE,CAAC8E,YAFJ;AAGNvD,YAAAA,IAAI,EAAE,EAHA;AAINU,YAAAA,IAAI,EAAEjC,EAAE,CAACkC;AAJH,WAFE;AAQV6C,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,iCAAsBH,OAAtB,CAAQ8B,KAAR;AAAA,gBAAQA,KAAR,+BAAgB,CAAhB;;AACA,gBAAMC,OAAO,GAAG,KAAI,CAACzG,KAAL,CAAWC,cAAX,GAA4BwG,OAA5C;;AACA,gBAAMC,UAAU,GAAGD,OAAO,CAACE,OAAR,CAAgBH,KAAhB,CAAnB;AACA,mBAAO,CAACE,UAAD,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;;EAnPoChH,S;;SAAlBK,S","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IAttribute,\n IElements,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport BaseModel, {\n styleColor,\n styleOffset,\n styleSingle,\n} from '../../core/BaseModel';\nimport {\n GlobelPointFillTriangulation,\n PointFillTriangulation,\n} from '../../core/triangulation';\nimport pointFillFrag from '../shaders/fill_frag.glsl';\nimport pointFillVert from '../shaders/fill_vert.glsl';\n\nimport { isNumber } from 'lodash';\n\nimport { mat4, vec3 } from 'gl-matrix';\n\ninterface IPointLayerStyleOptions {\n opacity: styleSingle;\n strokeWidth: styleSingle;\n stroke: styleColor;\n strokeOpacity: styleSingle;\n offsets: styleOffset;\n blend: string;\n}\n// 判断当前使用的 style 中的变量属性是否需要进行数据映射\nexport default class FillModel extends BaseModel {\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = 'rgba(0,0,0,0)',\n offsets = [0, 0],\n blend,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n });\n\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_additive: blend === 'additive' ? 1.0 : 0.0,\n u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_stroke_opacity: isNumber(strokeOpacity) ? strokeOpacity : 1.0,\n u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 0.0,\n u_stroke_color: this.getStrokeColor(stroke),\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n return this.styleAttributeService.createAttributesAndIndices(\n this.layer.getEncodedData(),\n PointFillTriangulation,\n );\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointfill',\n vertexShader: pointFillVert,\n fragmentShader: pointFillFrag,\n triangulation: isGlobel\n ? GlobelPointFillTriangulation\n : PointFillTriangulation,\n // depth: { enable: false },\n depth: { enable: isGlobel },\n blend: this.getBlend(),\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected animateOption2Array(option: IAnimateOption): number[] {\n return [option.enable ? 0 : 1.0, option.speed || 1, option.rings || 3, 0];\n }\n protected registerBuiltinAttributes() {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'extrude',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Extrude',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n let extrude;\n // 地球模式\n if (isGlobel) {\n const [x, y, z] = vertex;\n const n1 = vec3.fromValues(0, 0, 1);\n const n2 = vec3.fromValues(x, 0, z);\n\n const xzReg =\n x >= 0 ? vec3.angle(n1, n2) : Math.PI * 2 - vec3.angle(n1, n2);\n\n const yReg = Math.PI * 2 - Math.asin(y / 100);\n\n const m = mat4.create();\n mat4.rotateY(m, m, xzReg);\n mat4.rotateX(m, m, yReg);\n\n const v1 = vec3.fromValues(1, 1, 0);\n vec3.transformMat4(v1, v1, m);\n vec3.normalize(v1, v1);\n\n const v2 = vec3.fromValues(-1, 1, 0);\n vec3.transformMat4(v2, v2, m);\n vec3.normalize(v2, v2);\n\n const v3 = vec3.fromValues(-1, -1, 0);\n vec3.transformMat4(v3, v3, m);\n vec3.normalize(v3, v3);\n\n const v4 = vec3.fromValues(1, -1, 0);\n vec3.transformMat4(v4, v4, m);\n vec3.normalize(v4, v4);\n\n extrude = [...v1, ...v2, ...v3, ...v4];\n } else {\n // 平面模式\n extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n }\n\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 5 } = feature;\n // console.log('featureIdx', featureIdx, feature)\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'shape',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Shape',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { shape = 2 } = feature;\n const shape2d = this.layer.getLayerConfig().shape2d as string[];\n const shapeIndex = shape2d.indexOf(shape as string);\n return [shapeIndex];\n },\n },\n });\n }\n}\n"],"file":"fill.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/point/shape/extrude.ts"],"names":["earcut","extrudePolygon","path","p1","p2","length","slice","n","flattengeo","flatten","positions","indexArray","normals","j","vertices","push","triangles","holes","dimensions","i","prePoint","nextPoint","indexOffset","map","v","index","fillPolygon","points"],"mappings":";AAAA,OAAOA,MAAP,MAAmB,QAAnB;AAWA,eAAe,SAASC,cAAT,CAAwBC,IAAxB,EAAwD;AACrE,MAAMC,EAAE,GAAGD,IAAI,CAAC,CAAD,CAAJ,CAAQ,CAAR,CAAX;AACA,MAAME,EAAE,GAAGF,IAAI,CAAC,CAAD,CAAJ,CAAQA,IAAI,CAAC,CAAD,CAAJ,CAAQG,MAAR,GAAiB,CAAzB,CAAX;;AACA,MAAIF,EAAE,CAAC,CAAD,CAAF,KAAUC,EAAE,CAAC,CAAD,CAAZ,IAAmBD,EAAE,CAAC,CAAD,CAAF,KAAUC,EAAE,CAAC,CAAD,CAAnC,EAAwC;AACtCF,IAAAA,IAAI,CAAC,CAAD,CAAJ,GAAUA,IAAI,CAAC,CAAD,CAAJ,CAAQI,KAAR,CAAc,CAAd,EAAiBJ,IAAI,CAAC,CAAD,CAAJ,CAAQG,MAAR,GAAiB,CAAlC,CAAV;AACD;;AACD,MAAME,CAAC,GAAGL,IAAI,CAAC,CAAD,CAAJ,CAAQG,MAAlB;AACA,MAAMG,UAAU,GAAGR,MAAM,CAACS,OAAP,CAAeP,IAAf,CAAnB;AACA,MAAMQ,SAAS,GAAG,EAAlB;AACA,MAAMC,UAAU,GAAG,EAAnB;AACA,MAAMC,OAAO,GAAG,EAAhB;;AAEA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGL,UAAU,CAACM,QAAX,CAAoBT,MAApB,GAA6B,CAAjD,EAAoDQ,CAAC,EAArD,EAAyD;AACvDL,IAAAA,UAAU,CAACM,QAAX,CAAoBD,CAAC,GAAG,CAAJ,GAAQ,CAA5B,IAAiC,CAAjC;AACAD,IAAAA,OAAO,CAACG,IAAR,CAAa,CAAb,EAAgB,CAAhB,EAAmB,CAAnB;AACD;;AACDL,EAAAA,SAAS,CAACK,I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Y,GAAnB,CAAuB,UAACC,CAAD;AAAA,aAAOA,CAAC,GAAGF,WAAX;AAAA,KAAvB,CAAT,EAAV;AA5CmE;;AAuBrE,OAAK,IAAIH,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGZ,CAApB,EAAuBY,CAAC,EAAxB,EAA4B;AAAA,UAAnBA,CAAmB;AAsB3B;;AACD,SAAO;AACLT,IAAAA,SAAS,EAATA,SADK;AAELe,IAAAA,KAAK,EAAEd;AAFF,GAAP;AAID;AACD,OAAO,SAASe,WAAT,CAAqBC,MAArB,EAAsC;AAC3C,MAAMnB,UAAU,GAAGR,MAAM,CAACS,OAAP,CAAekB,MAAf,CAAnB;AACA,MAAMX,SAAS,GAAGhB,MAAM,CACtBQ,UAAU,CAACM,QADW,EAEtBN,UAAU,CAACS,KAFW,EAGtBT,UAAU,CAACU,UAHW,CAAxB;AAKA,SAAO;AACLR,IAAAA,SAAS,EAAEF,UAAU,CAACM,QADjB;AAELW,IAAAA,KAAK,EAAET;AAFF,GAAP;AAID","sourcesContent":["import earcut from 'earcut';\nimport { IPath } from '
|
|
1
|
+
{"version":3,"sources":["../../../src/point/shape/extrude.ts"],"names":["earcut","extrudePolygon","path","p1","p2","length","slice","n","flattengeo","flatten","positions","indexArray","normals","j","vertices","push","triangles","holes","dimensions","i","prePoint","nextPoint","indexOffset","map","v","index","fillPolygon","points"],"mappings":";AAAA,OAAOA,MAAP,MAAmB,QAAnB;AAWA,eAAe,SAASC,cAAT,CAAwBC,IAAxB,EAAwD;AACrE,MAAMC,EAAE,GAAGD,IAAI,CAAC,CAAD,CAAJ,CAAQ,CAAR,CAAX;AACA,MAAME,EAAE,GAAGF,IAAI,CAAC,CAAD,CAAJ,CAAQA,IAAI,CAAC,CAAD,CAAJ,CAAQG,MAAR,GAAiB,CAAzB,CAAX;;AACA,MAAIF,EAAE,CAAC,CAAD,CAAF,KAAUC,EAAE,CAAC,CAAD,CAAZ,IAAmBD,EAAE,CAAC,CAAD,CAAF,KAAU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,QADW,EAEtBN,UAAU,CAACS,KAFW,EAGtBT,UAAU,CAACU,UAHW,CAAxB;AAKA,SAAO;AACLR,IAAAA,SAAS,EAAEF,UAAU,CAACM,QADjB;AAELW,IAAAA,KAAK,EAAET;AAFF,GAAP;AAID","sourcesContent":["import earcut from 'earcut';\nimport { IPath } from '../../core/shape/Path';\nexport interface IExtrudeGeomety {\n positions: number[];\n index: number[];\n}\n/**\n * 拉伸多边形顶点,返回拉伸后的顶点信息\n * @param paths 路径数据组\n * @param extrude 是否拉伸\n */\nexport default function extrudePolygon(path: IPath[]): IExtrudeGeomety {\n const p1 = path[0][0];\n const p2 = path[0][path[0].length - 1];\n if (p1[0] === p2[0] && p1[1] === p2[1]) {\n path[0] = path[0].slice(0, path[0].length - 1);\n }\n const n = path[0].length;\n const flattengeo = earcut.flatten(path);\n const positions = [];\n const indexArray = [];\n const normals = [];\n // 设置顶部z值\n for (let j = 0; j < flattengeo.vertices.length / 3; j++) {\n flattengeo.vertices[j * 3 + 2] = 1;\n normals.push(0, 0, 1);\n }\n positions.push(...flattengeo.vertices);\n const triangles = earcut(\n flattengeo.vertices,\n flattengeo.holes,\n flattengeo.dimensions,\n );\n indexArray.push(...triangles);\n for (let i = 0; i < n; i++) {\n const prePoint = flattengeo.vertices.slice(i * 3, i * 3 + 3);\n let nextPoint = flattengeo.vertices.slice(i * 3 + 3, i * 3 + 6);\n if (nextPoint.length === 0) {\n nextPoint = flattengeo.vertices.slice(0, 3);\n }\n const indexOffset = positions.length / 3;\n positions.push(\n prePoint[0],\n prePoint[1],\n 1,\n nextPoint[0],\n nextPoint[1],\n 1,\n prePoint[0],\n prePoint[1],\n 0,\n nextPoint[0],\n nextPoint[1],\n 0,\n );\n indexArray.push(...[1, 2, 0, 3, 2, 1].map((v) => v + indexOffset));\n }\n return {\n positions,\n index: indexArray,\n };\n}\nexport function fillPolygon(points: IPath[]) {\n const flattengeo = earcut.flatten(points);\n const triangles = earcut(\n flattengeo.vertices,\n flattengeo.holes,\n flattengeo.dimensions,\n );\n return {\n positions: flattengeo.vertices,\n index: triangles,\n };\n}\n"],"file":"extrude.js"}
|
|
@@ -52,8 +52,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
52
52
|
var heatmap3DFrag = "uniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\nuniform float u_opacity;\nvarying vec2 v_texCoord;\nvarying float v_intensity;\n\nvoid main(){\n \n float intensity = texture2D(u_texture, v_texCoord).r;\n vec4 color = texture2D(u_colorTexture,vec2(intensity, 0));\n gl_FragColor = color;\n // gl_FragColor.a = color.a * smoothstep(0.1,0.2,intensity)* u_opacity;\n gl_FragColor.a = color.a * smoothstep(0.,0.1,intensity) * u_opacity;\n}\n";
|
|
53
53
|
var heatmap3DVert = "precision highp float;\nattribute vec3 a_Position;\nattribute vec2 a_Uv;\nuniform sampler2D u_texture;\nvarying vec2 v_texCoord;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_InverseViewProjectionMatrix;\nuniform mat4 u_ViewProjectionMatrixUncentered;\nvarying float v_intensity;\n\n\nvec2 toBezier(float t, vec2 P0, vec2 P1, vec2 P2, vec2 P3) {\n float t2 = t * t;\n float one_minus_t = 1.0 - t;\n float one_minus_t2 = one_minus_t * one_minus_t;\n return (P0 * one_minus_t2 * one_minus_t + P1 * 3.0 * t * one_minus_t2 + P2 * 3.0 * t2 * one_minus_t + P3 * t2 * t);\n}\nvec2 toBezier(float t, vec4 p){\n return toBezier(t, vec2(0.0, 0.0), vec2(p.x, p.y), vec2(p.z, p.w), vec2(1.0, 1.0));\n}\n#pragma include \"projection\"\nvoid main() {\n v_texCoord = a_Uv;\n\n vec2 pos = a_Uv * vec2(2.0) - vec2(1.0); // \u5C06\u539F\u672C 0 -> 1 \u7684 uv \u8F6C\u6362\u4E3A -1 -> 1 \u7684\u6807\u51C6\u5750\u6807\u7A7A\u95F4\uFF08NDC\uFF09\n\n vec4 p1 = vec4(pos, 0.0, 1.0); // x/y \u5E73\u9762\u4E0A\u7684\u70B9\uFF08z == 0\uFF09\u53EF\u4EE5\u8BA4\u4E3A\u662F\u4E09\u7EF4\u4E0A\u7684\u70B9\u88AB\u6295\u5F71\u5230\u5E73\u9762\u540E\u7684\u70B9\n\tvec4 p2 = vec4(pos, 1.0, 1.0); // \u5E73\u884C\u4E8Ex/y\u5E73\u9762\u3001z==1 \u7684\u5E73\u9762\u4E0A\u7684\u70B9\n\n\tvec4 inverseP1 = u_InverseViewProjectionMatrix * p1; // \u6839\u636E\u89C6\u56FE\u6295\u5F71\u77E9\u9635\u7684\u9006\u77E9\u9635\u5E73\u9762\u4E0A\u7684\u53CD\u7B97\u51FA\u4E09\u7EF4\u7A7A\u95F4\u4E2D\u7684\u70B9\uFF08p1\u5E73\u9762\u4E0A\u7684\u70B9\uFF09\n\tvec4 inverseP2 = u_InverseViewProjectionMatrix * p2;\n\n inverseP1 = inverseP1 / inverseP1.w; // \u5F52\u4E00\u5316\u64CD\u4F5C\uFF08\u5F52\u4E00\u5316\u540E\u4E3A\u4E16\u754C\u5750\u6807\uFF09\n\tinverseP2 = inverseP2 / inverseP2.w;\n\n\tfloat zPos = (0.0 - inverseP1.z) / (inverseP2.z - inverseP1.z); // ??\n\tvec4 position = inverseP1 + zPos * (inverseP2 - inverseP1);\n\n vec4 b= vec4(0.5000, 0.0, 1.0, 0.5000);\n float fh;\n\n v_intensity = texture2D(u_texture, v_texCoord).r;\n fh = toBezier(v_intensity, b).y;\n gl_Position = u_ViewProjectionMatrixUncentered * vec4(position.xy, fh * project_pixel(50.), 1.0);\n \n}\n";
|
|
54
54
|
var heatmapColorFrag = "uniform sampler2D u_texture;\nuniform sampler2D u_colorTexture;\nuniform float u_opacity;\nvarying vec2 v_texCoord;\nvarying float v_intensity;\n\nvoid main(){\n float intensity = texture2D(u_texture, v_texCoord).r;\n vec4 color = texture2D(u_colorTexture,vec2(intensity, 0));\n gl_FragColor =color;\n gl_FragColor.a = color.a * smoothstep(0.,0.1,intensity) * u_opacity;\n\n}\n";
|
|
55
|
-
var
|
|
56
|
-
var
|
|
55
|
+
var heatmapFramebufferFrag = "precision highp float;\nuniform float u_intensity;\nvarying float v_weight;\nvarying vec2 v_extrude;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(){\n float d = -0.5 * 3.0 * 3.0 * dot(v_extrude, v_extrude);\n float val = v_weight * u_intensity * GAUSS_COEF * exp(d);\n gl_FragColor = vec4(val, 1., 1., 1.);\n}\n";
|
|
56
|
+
var heatmapFramebufferVert = "precision highp float;\nattribute vec3 a_Position;\nattribute float a_Size;\nattribute vec2 a_Dir;\nuniform float u_intensity;\nuniform float u_radius;\nvarying vec2 v_extrude;\nvarying float v_weight;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\n#define GAUSS_COEF 0.3989422804014327\n\n#pragma include \"projection\"\n\nvoid main(){\n v_weight = a_Size;\n float ZERO = 1.0 / 255.0 / 16.0;\n float extrude_x = a_Dir.x * 2.0 -1.0;\n float extrude_y = a_Dir.y * 2.0 -1.0;\n vec2 extrude_dir = normalize(vec2(extrude_x,extrude_y));\n float S = sqrt(-2.0 * log(ZERO / a_Size / u_intensity / GAUSS_COEF)) / 2.5;\n v_extrude = extrude_dir * S;\n\n vec2 offset = project_pixel(v_extrude * u_radius);\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy + offset, 0.0, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n }\n}\n";
|
|
57
57
|
var heatmapColorVert = "precision highp float;\nattribute vec3 a_Position;\nattribute vec2 a_Uv;\nuniform sampler2D u_texture;\nvarying vec2 v_texCoord;\nvarying float v_intensity;\nvoid main() {\n v_texCoord = a_Uv;\n v_intensity = texture2D(u_texture, v_texCoord).r;\n gl_Position = vec4(a_Position.xy, 0, 1.);\n}\n";
|
|
58
58
|
var HeatMapModel = (_dec = (0, _inversify.injectable)(), _dec(_class = function (_BaseModel) {
|
|
59
59
|
(0, _inherits2.default)(HeatMapModel, _BaseModel);
|
|
@@ -192,8 +192,8 @@ var HeatMapModel = (_dec = (0, _inversify.injectable)(), _dec(_class = function
|
|
|
192
192
|
value: function buildHeatMapIntensity() {
|
|
193
193
|
return this.layer.buildLayerModel({
|
|
194
194
|
moduleName: 'heatmapintensity',
|
|
195
|
-
vertexShader:
|
|
196
|
-
fragmentShader:
|
|
195
|
+
vertexShader: heatmapFramebufferVert,
|
|
196
|
+
fragmentShader: heatmapFramebufferFrag,
|
|
197
197
|
triangulation: _triangulation.HeatmapTriangulation,
|
|
198
198
|
depth: {
|
|
199
199
|
enable: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/heatmap/models/heatmap.ts"],"names":["HeatMapModel","rendererService","clear","useFramebuffer","heatmapFramerBuffer","color","depth","stencil","framebuffer","drawIntensityMode","layer","styleNeedUpdate","updateColorTexture","shapeType","drawColorMode","draw3DHeatMap","Error","createFramebuffer","getViewportSize","createTexture2D","shapeAttr","styleAttributeService","getLayerStyleAttribute","scale","field","intensityModel","buildHeatMapIntensity","colorModel","buildHeatmapColor","build3dHeatMap","width","height","Math","floor","wrapS","gl","CLAMP_TO_EDGE","wrapT","min","LINEAR","mag","initModels","registerStyleAttribute","name","type","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","data","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","buildLayerModel","moduleName","vertexShader","heatmapVert","fragmentShader","heatmapFrag","triangulation","HeatmapTriangulation","enable","blend","func","srcRGB","ONE","srcAlpha","dstRGB","dstAlpha","shaderModuleService","registerModule","vs","heatmapColorVert","fs","heatmapColorFrag","getModule","uniforms","createAttribute","createElements","createBuffer","createModel","attributes","a_Position","a_Uv","getBlend","count","elements","UNSIGNED_INT","getLayerConfig","opacity","intensity","radius","draw","u_opacity","u_radius","u_intensity","u_colorTexture","colorTexture","u_texture","invert","mat4","create","cameraService","getViewProjectionMatrixUncentered","u_ViewProjectionMatrixUncentered","u_InverseViewProjectionMatrix","heatmap3DVert","heatmap3DFrag","vertices","uvs","primitive","TRIANGLES","SRC_ALPHA","ONE_MINUS_SRC_ALPHA","indices","length","texture","destroy","rampColors","imageData","Uint8Array","NEAREST","flipY","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AASA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAOA;;;;;;;;;;;;;;;;;;IASqBA,Y,WADpB,4B;;;;;;;;;;;;;;;;;;;;;;;;;;WASC,kBAAgB;AAAA;;AACd,kCAAkC,KAAKC,eAAvC;AAAA,UAAQC,KAAR,yBAAQA,KAAR;AAAA,UAAeC,cAAf,yBAAeA,cAAf;AACAA,MAAAA,cAAc,CAAC,KAAKC,mBAAN,EAA2B,YAAM;AAC7CF,QAAAA,KAAK,CAAC;AACJG,UAAAA,KAAK,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CADH;AAEJC,UAAAA,KAAK,EAAE,CAFH;AAGJC,UAAAA,OAAO,EAAE,CAHL;AAIJC,UAAAA,WAAW,EAAE,MAAI,CAACJ;AAJd,SAAD,CAAL;;AAMA,QAAA,MAAI,CAACK,iBAAL;AACD,OARa,CAAd;;AASA,UAAI,KAAKC,KAAL,CAAWC,eAAf,EAAgC;AAC9B,aAAKC,kBAAL;AACD;;AACD,WAAKC,SAAL,KAAmB,SAAnB,GAA+B,KAAKC,aAAL,EAA/B,GAAsD,KAAKC,aAAL,EAAtD;AACD;;;WAED,wBAAqC;AACnC,YAAM,IAAIC,KAAJ,CAAU,yBAAV,CAAN;AACD;;;WAED,sBAA8B;AAAA;;AAC5B,mCAMI,KAAKf,eANT;AAAA,UACEgB,iBADF,0BACEA,iBADF;AAAA,UAEEf,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,KAAK,EAAE;AAR2B,OAAD,CAAnC;AAUD;;;EA9UuCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IFramebuffer,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { generateColorRamp, IColorRamp } from '@antv/l7-utils';\nimport { mat4 } from 'gl-matrix';\nimport { inject, injectable } from 'inversify';\nimport 'reflect-metadata';\nimport BaseModel from '../../core/BaseModel';\nimport { HeatmapTriangulation } from '../../core/triangulation';\nimport heatmap3DFrag from '../shaders/heatmap_3d_frag.glsl';\nimport heatmap3DVert from '../shaders/heatmap_3d_vert.glsl';\nimport heatmapColorFrag from '../shaders/heatmap_frag.glsl';\nimport heatmapFrag from '../shaders/heatmap_framebuffer_frag.glsl';\nimport heatmapVert from '../shaders/heatmap_framebuffer_vert.glsl';\nimport heatmapColorVert from '../shaders/heatmap_vert.glsl';\nimport { heatMap3DTriangulation } from '../triangulation';\ninterface IHeatMapLayerStyleOptions {\n opacity: number;\n intensity: number;\n radius: number;\n angle: number;\n rampColors: IColorRamp;\n}\n@injectable()\nexport default class HeatMapModel extends BaseModel {\n protected texture: ITexture2D;\n protected colorTexture: ITexture2D;\n protected heatmapFramerBuffer: IFramebuffer;\n private intensityModel: IModel;\n private colorModel: IModel;\n private shapeType: string;\n\n public render() {\n const { clear, useFramebuffer } = this.rendererService;\n useFramebuffer(this.heatmapFramerBuffer, () => {\n clear({\n color: [0, 0, 0, 0],\n depth: 1,\n stencil: 0,\n framebuffer: this.heatmapFramerBuffer,\n });\n this.drawIntensityMode();\n });\n if (this.layer.styleNeedUpdate) {\n this.updateColorTexture();\n }\n this.shapeType === 'heatmap' ? this.drawColorMode() : this.draw3DHeatMap();\n }\n\n public getUninforms(): IModelUniform {\n throw new Error('Method not implemented.');\n }\n\n public initModels(): IModel[] {\n const {\n createFramebuffer,\n clear,\n getViewportSize,\n createTexture2D,\n useFramebuffer,\n } = this.rendererService;\n const shapeAttr = this.styleAttributeService.getLayerStyleAttribute(\n 'shape',\n );\n const shapeType = shapeAttr?.scale?.field || 'heatmap';\n this.shapeType = shapeType as string;\n // 生成热力图密度图\n this.intensityModel = this.buildHeatMapIntensity();\n // 渲染到屏幕\n this.colorModel =\n shapeType === 'heatmap'\n ? this.buildHeatmapColor() // 2D\n : this.build3dHeatMap(); // 3D\n\n const { width, height } = getViewportSize();\n\n // 初始化密度图纹理\n this.heatmapFramerBuffer = createFramebuffer({\n color: createTexture2D({\n width: Math.floor(width / 4),\n height: Math.floor(height / 4),\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.LINEAR,\n mag: gl.LINEAR,\n }),\n depth: false,\n });\n\n this.updateColorTexture();\n\n return [this.intensityModel, this.colorModel];\n }\n\n public buildModels(): IModel[] {\n return this.initModels();\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'dir',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Dir',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4]];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return [size as number];\n },\n },\n });\n }\n private buildHeatMapIntensity(): IModel {\n return this.layer.buildLayerModel({\n moduleName: 'heatmapintensity',\n vertexShader: heatmapVert,\n fragmentShader: heatmapFrag,\n triangulation: HeatmapTriangulation,\n depth: {\n enable: false,\n },\n blend: {\n enable: true,\n func: {\n srcRGB: gl.ONE,\n srcAlpha: 1,\n dstRGB: gl.ONE,\n dstAlpha: 1,\n },\n },\n });\n }\n\n private buildHeatmapColor(): IModel {\n this.shaderModuleService.registerModule('heatmapColor', {\n vs: heatmapColorVert,\n fs: heatmapColorFrag,\n });\n\n const { vs, fs, uniforms } = this.shaderModuleService.getModule(\n 'heatmapColor',\n );\n const {\n createAttribute,\n createElements,\n createBuffer,\n createModel,\n } = this.rendererService;\n return createModel({\n vs,\n fs,\n attributes: {\n a_Position: createAttribute({\n buffer: createBuffer({\n data: [-1, 1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0],\n type: gl.FLOAT,\n }),\n size: 3,\n }),\n a_Uv: createAttribute({\n buffer: createBuffer({\n data: [0, 1, 1, 1, 0, 0, 1, 0],\n type: gl.FLOAT,\n }),\n size: 2,\n }),\n },\n uniforms: {\n ...uniforms,\n },\n depth: {\n enable: false,\n },\n blend: this.getBlend(),\n count: 6,\n elements: createElements({\n data: [0, 2, 1, 2, 3, 1],\n type: gl.UNSIGNED_INT,\n count: 6,\n }),\n });\n }\n\n private drawIntensityMode() {\n const {\n opacity,\n intensity = 10,\n radius = 5,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n this.intensityModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_radius: radius,\n u_intensity: intensity,\n },\n });\n }\n\n private drawColorMode() {\n const {\n opacity,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n this.colorModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_colorTexture: this.colorTexture,\n u_texture: this.heatmapFramerBuffer,\n },\n });\n }\n\n private draw3DHeatMap() {\n const {\n opacity,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n\n // const invert = mat4.invert(\n // mat4.create(),\n // mat4.fromValues(\n // // @ts-ignore\n // ...this.cameraService.getViewProjectionMatrixUncentered(),\n // ),\n // ) as mat4;\n const invert = mat4.create();\n mat4.invert(\n invert,\n this.cameraService.getViewProjectionMatrixUncentered() as mat4,\n );\n\n this.colorModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_colorTexture: this.colorTexture,\n u_texture: this.heatmapFramerBuffer,\n u_ViewProjectionMatrixUncentered: this.cameraService.getViewProjectionMatrixUncentered(),\n u_InverseViewProjectionMatrix: [...invert],\n },\n });\n }\n private build3dHeatMap() {\n const { getViewportSize } = this.rendererService;\n const { width, height } = getViewportSize();\n const triangulation = heatMap3DTriangulation(width / 4.0, height / 4.0);\n this.shaderModuleService.registerModule('heatmap3dColor', {\n vs: heatmap3DVert,\n fs: heatmap3DFrag,\n });\n\n const { vs, fs, uniforms } = this.shaderModuleService.getModule(\n 'heatmap3dColor',\n );\n const {\n createAttribute,\n createElements,\n createBuffer,\n createModel,\n } = this.rendererService;\n return createModel({\n vs,\n fs,\n attributes: {\n a_Position: createAttribute({\n buffer: createBuffer({\n data: triangulation.vertices,\n type: gl.FLOAT,\n }),\n size: 3,\n }),\n a_Uv: createAttribute({\n buffer: createBuffer({\n data: triangulation.uvs,\n type: gl.FLOAT,\n }),\n size: 2,\n }),\n },\n primitive: gl.TRIANGLES,\n uniforms: {\n ...uniforms,\n },\n depth: {\n enable: true,\n },\n blend: {\n enable: true,\n func: {\n srcRGB: gl.SRC_ALPHA,\n srcAlpha: 1,\n dstRGB: gl.ONE_MINUS_SRC_ALPHA,\n dstAlpha: 1,\n },\n },\n elements: createElements({\n data: triangulation.indices,\n type: gl.UNSIGNED_INT,\n count: triangulation.indices.length,\n }),\n });\n }\n private updateStyle() {\n this.updateColorTexture();\n }\n\n private updateColorTexture() {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.destroy();\n }\n\n const {\n rampColors,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n const imageData = generateColorRamp(rampColors as IColorRamp);\n this.colorTexture = createTexture2D({\n data: new Uint8Array(imageData.data),\n width: imageData.width,\n height: imageData.height,\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.NEAREST,\n mag: gl.NEAREST,\n flipY: false,\n });\n }\n}\n"],"file":"heatmap.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/heatmap/models/heatmap.ts"],"names":["HeatMapModel","rendererService","clear","useFramebuffer","heatmapFramerBuffer","color","depth","stencil","framebuffer","drawIntensityMode","layer","styleNeedUpdate","updateColorTexture","shapeType","drawColorMode","draw3DHeatMap","Error","createFramebuffer","getViewportSize","createTexture2D","shapeAttr","styleAttributeService","getLayerStyleAttribute","scale","field","intensityModel","buildHeatMapIntensity","colorModel","buildHeatmapColor","build3dHeatMap","width","height","Math","floor","wrapS","gl","CLAMP_TO_EDGE","wrapT","min","LINEAR","mag","initModels","registerStyleAttribute","name","type","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","data","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","buildLayerModel","moduleName","vertexShader","heatmapFramebufferVert","fragmentShader","heatmapFramebufferFrag","triangulation","HeatmapTriangulation","enable","blend","func","srcRGB","ONE","srcAlpha","dstRGB","dstAlpha","shaderModuleService","registerModule","vs","heatmapColorVert","fs","heatmapColorFrag","getModule","uniforms","createAttribute","createElements","createBuffer","createModel","attributes","a_Position","a_Uv","getBlend","count","elements","UNSIGNED_INT","getLayerConfig","opacity","intensity","radius","draw","u_opacity","u_radius","u_intensity","u_colorTexture","colorTexture","u_texture","invert","mat4","create","cameraService","getViewProjectionMatrixUncentered","u_ViewProjectionMatrixUncentered","u_InverseViewProjectionMatrix","heatmap3DVert","heatmap3DFrag","vertices","uvs","primitive","TRIANGLES","SRC_ALPHA","ONE_MINUS_SRC_ALPHA","indices","length","texture","destroy","rampColors","imageData","Uint8Array","NEAREST","flipY","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AASA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAOA;;;;;;;;;;;;;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YAFc;AAGvBF,UAAAA,KAAK,EAAE1B,aAAa,CAACuD,OAAd,CAAsBC;AAHN,SAAD;AAnCP,OAAD,CAAlB;AAyCD;;;WACD,uBAAsB;AACpB,WAAK7G,kBAAL;AACD;;;WAED,8BAA6B;AAC3B,UAAQO,eAAR,GAA4B,KAAKlB,eAAjC,CAAQkB,eAAR;;AACA,UAAI,KAAKuG,OAAT,EAAkB;AAChB,aAAKA,OAAL,CAAaC,OAAb;AACD;;AAED,kBAEI,KAAKjH,KAAL,CAAWoF,cAAX,EAFJ;AAAA,UACE8B,UADF,SACEA,UADF;;AAGA,UAAMC,SAAS,GAAG,gCAAkBD,UAAlB,CAAlB;AACA,WAAKrB,YAAL,GAAoBpF,eAAe,CAAC;AAClCgC,QAAAA,IAAI,EAAE,IAAI2E,UAAJ,CAAeD,SAAS,CAAC1E,IAAzB,CAD4B;AAElCrB,QAAAA,KAAK,EAAE+F,SAAS,CAAC/F,KAFiB;AAGlCC,QAAAA,MAAM,EAAE8F,SAAS,CAAC9F,MAHgB;AAIlCG,QAAAA,KAAK,EAAEC,WAAGC,aAJwB;AAKlCC,QAAAA,KAAK,EAAEF,WAAGC,aALwB;AAMlCE,QAAAA,GAAG,EAAEH,WAAG4F,OAN0B;AAOlCvF,QAAAA,GAAG,EAAEL,WAAG4F,OAP0B;AAQlCC,QAAAA,KAAK,EAAE;AAR2B,OAAD,CAAnC;AAUD;;;EA9UuCC,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IFramebuffer,\n IModel,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { generateColorRamp, IColorRamp } from '@antv/l7-utils';\nimport { mat4 } from 'gl-matrix';\nimport { inject, injectable } from 'inversify';\nimport 'reflect-metadata';\nimport BaseModel from '../../core/BaseModel';\nimport { HeatmapTriangulation } from '../../core/triangulation';\nimport heatmap3DFrag from '../shaders/heatmap_3d_frag.glsl';\nimport heatmap3DVert from '../shaders/heatmap_3d_vert.glsl';\nimport heatmapColorFrag from '../shaders/heatmap_frag.glsl';\nimport heatmapFramebufferFrag from '../shaders/heatmap_framebuffer_frag.glsl';\nimport heatmapFramebufferVert from '../shaders/heatmap_framebuffer_vert.glsl';\nimport heatmapColorVert from '../shaders/heatmap_vert.glsl';\nimport { heatMap3DTriangulation } from '../triangulation';\ninterface IHeatMapLayerStyleOptions {\n opacity: number;\n intensity: number;\n radius: number;\n angle: number;\n rampColors: IColorRamp;\n}\n@injectable()\nexport default class HeatMapModel extends BaseModel {\n protected texture: ITexture2D;\n protected colorTexture: ITexture2D;\n protected heatmapFramerBuffer: IFramebuffer;\n private intensityModel: IModel;\n private colorModel: IModel;\n private shapeType: string;\n\n public render() {\n const { clear, useFramebuffer } = this.rendererService;\n useFramebuffer(this.heatmapFramerBuffer, () => {\n clear({\n color: [0, 0, 0, 0],\n depth: 1,\n stencil: 0,\n framebuffer: this.heatmapFramerBuffer,\n });\n this.drawIntensityMode();\n });\n if (this.layer.styleNeedUpdate) {\n this.updateColorTexture();\n }\n this.shapeType === 'heatmap' ? this.drawColorMode() : this.draw3DHeatMap();\n }\n\n public getUninforms(): IModelUniform {\n throw new Error('Method not implemented.');\n }\n\n public initModels(): IModel[] {\n const {\n createFramebuffer,\n clear,\n getViewportSize,\n createTexture2D,\n useFramebuffer,\n } = this.rendererService;\n const shapeAttr = this.styleAttributeService.getLayerStyleAttribute(\n 'shape',\n );\n const shapeType = shapeAttr?.scale?.field || 'heatmap';\n this.shapeType = shapeType as string;\n // 生成热力图密度图\n this.intensityModel = this.buildHeatMapIntensity();\n // 渲染到屏幕\n this.colorModel =\n shapeType === 'heatmap'\n ? this.buildHeatmapColor() // 2D\n : this.build3dHeatMap(); // 3D\n\n const { width, height } = getViewportSize();\n\n // 初始化密度图纹理\n this.heatmapFramerBuffer = createFramebuffer({\n color: createTexture2D({\n width: Math.floor(width / 4),\n height: Math.floor(height / 4),\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.LINEAR,\n mag: gl.LINEAR,\n }),\n depth: false,\n });\n\n this.updateColorTexture();\n\n return [this.intensityModel, this.colorModel];\n }\n\n public buildModels(): IModel[] {\n return this.initModels();\n }\n\n protected registerBuiltinAttributes() {\n this.styleAttributeService.registerStyleAttribute({\n name: 'dir',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Dir',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 2,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n return [vertex[3], vertex[4]];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 1 } = feature;\n return [size as number];\n },\n },\n });\n }\n private buildHeatMapIntensity(): IModel {\n return this.layer.buildLayerModel({\n moduleName: 'heatmapintensity',\n vertexShader: heatmapFramebufferVert,\n fragmentShader: heatmapFramebufferFrag,\n triangulation: HeatmapTriangulation,\n depth: {\n enable: false,\n },\n blend: {\n enable: true,\n func: {\n srcRGB: gl.ONE,\n srcAlpha: 1,\n dstRGB: gl.ONE,\n dstAlpha: 1,\n },\n },\n });\n }\n\n private buildHeatmapColor(): IModel {\n this.shaderModuleService.registerModule('heatmapColor', {\n vs: heatmapColorVert,\n fs: heatmapColorFrag,\n });\n\n const { vs, fs, uniforms } = this.shaderModuleService.getModule(\n 'heatmapColor',\n );\n const {\n createAttribute,\n createElements,\n createBuffer,\n createModel,\n } = this.rendererService;\n return createModel({\n vs,\n fs,\n attributes: {\n a_Position: createAttribute({\n buffer: createBuffer({\n data: [-1, 1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0],\n type: gl.FLOAT,\n }),\n size: 3,\n }),\n a_Uv: createAttribute({\n buffer: createBuffer({\n data: [0, 1, 1, 1, 0, 0, 1, 0],\n type: gl.FLOAT,\n }),\n size: 2,\n }),\n },\n uniforms: {\n ...uniforms,\n },\n depth: {\n enable: false,\n },\n blend: this.getBlend(),\n count: 6,\n elements: createElements({\n data: [0, 2, 1, 2, 3, 1],\n type: gl.UNSIGNED_INT,\n count: 6,\n }),\n });\n }\n\n private drawIntensityMode() {\n const {\n opacity,\n intensity = 10,\n radius = 5,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n this.intensityModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_radius: radius,\n u_intensity: intensity,\n },\n });\n }\n\n private drawColorMode() {\n const {\n opacity,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n this.colorModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_colorTexture: this.colorTexture,\n u_texture: this.heatmapFramerBuffer,\n },\n });\n }\n\n private draw3DHeatMap() {\n const {\n opacity,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n\n // const invert = mat4.invert(\n // mat4.create(),\n // mat4.fromValues(\n // // @ts-ignore\n // ...this.cameraService.getViewProjectionMatrixUncentered(),\n // ),\n // ) as mat4;\n const invert = mat4.create();\n mat4.invert(\n invert,\n this.cameraService.getViewProjectionMatrixUncentered() as mat4,\n );\n\n this.colorModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_colorTexture: this.colorTexture,\n u_texture: this.heatmapFramerBuffer,\n u_ViewProjectionMatrixUncentered: this.cameraService.getViewProjectionMatrixUncentered(),\n u_InverseViewProjectionMatrix: [...invert],\n },\n });\n }\n private build3dHeatMap() {\n const { getViewportSize } = this.rendererService;\n const { width, height } = getViewportSize();\n const triangulation = heatMap3DTriangulation(width / 4.0, height / 4.0);\n this.shaderModuleService.registerModule('heatmap3dColor', {\n vs: heatmap3DVert,\n fs: heatmap3DFrag,\n });\n\n const { vs, fs, uniforms } = this.shaderModuleService.getModule(\n 'heatmap3dColor',\n );\n const {\n createAttribute,\n createElements,\n createBuffer,\n createModel,\n } = this.rendererService;\n return createModel({\n vs,\n fs,\n attributes: {\n a_Position: createAttribute({\n buffer: createBuffer({\n data: triangulation.vertices,\n type: gl.FLOAT,\n }),\n size: 3,\n }),\n a_Uv: createAttribute({\n buffer: createBuffer({\n data: triangulation.uvs,\n type: gl.FLOAT,\n }),\n size: 2,\n }),\n },\n primitive: gl.TRIANGLES,\n uniforms: {\n ...uniforms,\n },\n depth: {\n enable: true,\n },\n blend: {\n enable: true,\n func: {\n srcRGB: gl.SRC_ALPHA,\n srcAlpha: 1,\n dstRGB: gl.ONE_MINUS_SRC_ALPHA,\n dstAlpha: 1,\n },\n },\n elements: createElements({\n data: triangulation.indices,\n type: gl.UNSIGNED_INT,\n count: triangulation.indices.length,\n }),\n });\n }\n private updateStyle() {\n this.updateColorTexture();\n }\n\n private updateColorTexture() {\n const { createTexture2D } = this.rendererService;\n if (this.texture) {\n this.texture.destroy();\n }\n\n const {\n rampColors,\n } = this.layer.getLayerConfig() as IHeatMapLayerStyleOptions;\n const imageData = generateColorRamp(rampColors as IColorRamp);\n this.colorTexture = createTexture2D({\n data: new Uint8Array(imageData.data),\n width: imageData.width,\n height: imageData.height,\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n min: gl.NEAREST,\n mag: gl.NEAREST,\n flipY: false,\n });\n }\n}\n"],"file":"heatmap.js"}
|
|
@@ -54,6 +54,7 @@ var ImageTileModel = function (_BaseModel) {
|
|
|
54
54
|
|
|
55
55
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
56
56
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "tileLayer", void 0);
|
|
57
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "timestamp", void 0);
|
|
57
58
|
return _this;
|
|
58
59
|
}
|
|
59
60
|
|
|
@@ -113,21 +114,17 @@ var ImageTileModel = function (_BaseModel) {
|
|
|
113
114
|
crstype: 'epsg3857'
|
|
114
115
|
});
|
|
115
116
|
this.tile();
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
t = newT;
|
|
121
|
-
|
|
122
|
-
if (cutT < 16) {
|
|
123
|
-
return;
|
|
117
|
+
this.mapService.on('mapchange', function (e) {
|
|
118
|
+
if (_this2.timestamp) {
|
|
119
|
+
clearTimeout(_this2.timestamp);
|
|
120
|
+
_this2.timestamp = null;
|
|
124
121
|
}
|
|
125
122
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
123
|
+
_this2.timestamp = setTimeout(function () {
|
|
124
|
+
if (_this2.mapService.getZoom() >= 2.0) {
|
|
125
|
+
_this2.tile();
|
|
126
|
+
}
|
|
127
|
+
}, 500);
|
|
131
128
|
});
|
|
132
129
|
}
|
|
133
130
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/imagetile/models/imagetile.ts"],"names":["ImageTileModel","mapService","getBounds","WS","EN","NE","lng","lat","SW","tileLayer","calCurrentTiles","tileCenter","getCenter","currentZoom","getZoom","minSourceZoom","getMinZoom","minZoom","maxZoom","getMaxZoom","layer","zIndex","getLayerConfig","resolution","maxSourceZoom","source","getSource","data","tileurl","Tile","url","layerService","crstype","tile","
|
|
1
|
+
{"version":3,"sources":["../../../src/imagetile/models/imagetile.ts"],"names":["ImageTileModel","mapService","getBounds","WS","EN","NE","lng","lat","SW","tileLayer","calCurrentTiles","tileCenter","getCenter","currentZoom","getZoom","minSourceZoom","getMinZoom","minZoom","maxZoom","getMaxZoom","layer","zIndex","getLayerConfig","resolution","maxSourceZoom","source","getSource","data","tileurl","Tile","url","layerService","crstype","tile","on","e","timestamp","clearTimeout","setTimeout","buildLayerModel","moduleName","vertexShader","ImageTileVert","fragmentShader","ImageTileFrag","triangulation","RasterImageTriangulation","primitive","gl","TRIANGLES","depth","enable","blend","getBlend","removeTiles","initModels","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAIA;;;;;;;;;IAOqBA,c;;;;;;;;;;;;;;;;;;;;;;WAGnB,wBAAqC;AACnC,aAAO,EAAP;AACD;;;WAGD,gBAAc;AACZ,kCAAiB,KAAKC,UAAL,CAAgBC,SAAhB,EAAjB;AAAA;AAAA,UAAOC,EAAP;AAAA,UAAWC,EAAX;;AACA,UAAMC,EAAE,GAAG;AAAEC,QAAAA,GAAG,EAAEF,EAAE,CAAC,CAAD,CAAT;AAAcG,QAAAA,GAAG,EAAEH,EAAE,CAAC,CAAD;AAArB,OAAX;AACA,UAAMI,EAAE,GAAG;AAAEF,QAAAA,GAAG,EAAEH,EAAE,CAAC,CAAD,CAAT;AAAcI,QAAAA,GAAG,EAAEJ,EAAE,CAAC,CAAD;AAArB,OAAX;AACA,WAAKM,SAAL,CAAeC,eAAf,CAA+B;AAC7BL,QAAAA,EAAE,EAAFA,EAD6B;AAE7BG,QAAAA,EAAE,EAAFA,EAF6B;AAG7BG,QAAAA,UAAU,EAAE,KAAKV,UAAL,CAAgBW,SAAhB,EAHiB;AAI7BC,QAAAA,WAAW,EAAE,KAAKZ,UAAL,CAAgBa,OAAhB,EAJgB;AAK7BC,QAAAA,aAAa,EAAE,KAAKd,UAAL,CAAgBe,UAAhB,EALc;AAM7BC,QAAAA,OAAO,EAAE,KAAKhB,UAAL,CAAgBe,UAAhB,EANoB;AAO7BE,QAAAA,OAAO,EAAE,KAAKjB,UAAL,CAAgBkB,UAAhB;AAPoB,OAA/B;AASD;;;WAED,sBAAoB;AAAA;;AAElB,WAAKC,KAAL,CAAWC,MAAX,GAAoB,CAAC,GAArB;;AACA,iBAGI,KAAKD,KAAL,CAAWE,cAAX,EAHJ;AAAA,iCACEC,UADF;AAAA,UACEA,UADF,g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zBC,QAAAA,KAAK,EAAE,KAAKC,QAAL;AAPkB,OAA3B,CADK,CAAP;AAWD;;;WAED,uBAAqB;AACnB,WAAK5C,SAAL,CAAe6C,WAAf;AACD;;;WAED,uBAAqB;AACnB,aAAO,KAAKC,UAAL,EAAP;AACD;;;WAED,qCAAsC;AACpC;AACD;;;EApFyCC,mB","sourcesContent":["import { gl, IModelUniform } from '@antv/l7-core';\nimport BaseModel from '../../core/BaseModel';\nimport { RasterImageTriangulation } from '../../core/triangulation';\nimport ImageTileFrag from './shaders/imagetile_frag.glsl';\nimport ImageTileVert from './shaders/imagetile_vert.glsl';\n\nimport Tile from '../utils/Tile';\n\ninterface IImageLayerStyleOptions {\n resolution: string;\n maxSourceZoom: number;\n}\n\nexport default class ImageTileModel extends BaseModel {\n public tileLayer: any;\n private timestamp: number | null;\n public getUninforms(): IModelUniform {\n return {};\n }\n\n // 瓦片方法\n public tile() {\n const [WS, EN] = this.mapService.getBounds();\n const NE = { lng: EN[0], lat: EN[1] };\n const SW = { lng: WS[0], lat: WS[1] };\n this.tileLayer.calCurrentTiles({\n NE,\n SW,\n tileCenter: this.mapService.getCenter(),\n currentZoom: this.mapService.getZoom(),\n minSourceZoom: this.mapService.getMinZoom(),\n minZoom: this.mapService.getMinZoom(),\n maxZoom: this.mapService.getMaxZoom(),\n });\n }\n\n public initModels() {\n // TODO: 瓦片组件默认在最下层\n this.layer.zIndex = -999;\n const {\n resolution = 'low',\n maxSourceZoom = 17,\n } = this.layer.getLayerConfig() as IImageLayerStyleOptions;\n const source = this.layer.getSource();\n // 当存在 url 的时候生效\n if (source.data.tileurl) {\n this.tileLayer = new Tile({\n url: source.data.tileurl,\n layerService: this.layerService,\n layer: this.layer,\n resolution,\n maxSourceZoom,\n // Tip: 当前为 default\n crstype: 'epsg3857',\n });\n\n // TODO: 首次加载的时候请求瓦片\n this.tile();\n\n this.mapService.on('mapchange', (e) => {\n if (this.timestamp) {\n clearTimeout(this.timestamp);\n this.timestamp = null;\n }\n // @ts-ignore 节流\n this.timestamp = setTimeout(() => {\n // TODO: 瓦片地图最大层级为 2\n if (this.mapService.getZoom() >= 2.0) {\n this.tile();\n }\n }, 500);\n });\n }\n\n return [\n this.layer.buildLayerModel({\n moduleName: 'ImageTileLayer',\n vertexShader: ImageTileVert,\n fragmentShader: ImageTileFrag,\n triangulation: RasterImageTriangulation,\n primitive: gl.TRIANGLES,\n depth: { enable: false },\n blend: this.getBlend(),\n }),\n ];\n }\n\n public clearModels() {\n this.tileLayer.removeTiles();\n }\n\n public buildModels() {\n return this.initModels();\n }\n\n protected registerBuiltinAttributes() {\n return;\n }\n}\n"],"file":"imagetile.js"}
|
package/lib/point/models/fill.js
CHANGED
|
@@ -35,8 +35,8 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
35
35
|
|
|
36
36
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
37
37
|
|
|
38
|
-
var pointFillFrag = "#define Animate 0.0\n\nuniform float u_globel;\nuniform float
|
|
39
|
-
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute float a_Shape;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\nuniform float u_globel;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\n\nuniform float u_opacity : 1;\nuniform float u_stroke_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\nuniform vec2 u_offsets;\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\n\nvoid main() {\n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n float newSize = setPickingSize(a_Size);\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 strokeOpacityAndOffset = calStrokeOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][1] = strokeOpacityAndOffset.r;\n textureOffset = strokeOpacityAndOffset.g;\n\n vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][2] = strokeWidthAndOffset.r;\n textureOffset = strokeWidthAndOffset.g;\n\n vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);\n if(hasStroke()) {\n vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R\n textureOffset += 1.0;\n\n vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G\n textureOffset += 1.0;\n\n vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B\n textureOffset += 1.0;\n\n vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A\n textureOffset += 1.0;\n } else {\n if(u_stroke_color == vec4(0.0)) {\n styleMappingMat[1][0] = v_color.r;\n styleMappingMat[1][1] = v_color.g;\n styleMappingMat[1][2] = v_color.b;\n styleMappingMat[1][3] = v_color.a;\n } else {\n styleMappingMat[1][0] = u_stroke_color.r;\n styleMappingMat[1][1] = u_stroke_color.g;\n styleMappingMat[1][2] = u_stroke_color.b;\n styleMappingMat[1][3] = u_stroke_color.a;\n }\n }\n\n vec2 textrueOffsets = vec2(0.0, 0.0);\n if(hasOffsets()) {\n vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n\n vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n } else {\n textrueOffsets = u_offsets;\n }\n\n // cal style mapping\n\n // unpack color(vec2)\n v_color = a_Color;\n\n // radius(16-bit)\n v_radius = newSize;\n\n // TODO: billboard\n // anti-alias\n float antialiasblur = 1.0 / u_DevicePixelRatio / (newSize + u_stroke_width);\n\n // construct point coords\n // TODP: /abs(extrude.x) \u662F\u4E3A\u4E86\u517C\u5BB9\u5730\u7403\u6A21\u5F0F\n v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);\n\n // vec2 offset = project_pixel(extrude * (newSize + u_stroke_width) + u_offsets);\n vec2 offset = project_pixel(extrude.xy * (newSize + u_stroke_width) + textrueOffsets);\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, 0.0, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n }\n\n if(u_globel > 0.0) {\n gl_Position = u_ViewProjectionMatrix * vec4(a_Position + extrude * newSize * 0.1, 1.0);\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
38
|
+
var pointFillFrag = "#define Animate 0.0\n\nuniform float u_globel;\nuniform float u_additive;\n\nvarying mat4 styleMappingMat; // \u4F20\u9012\u4ECE\u7247\u5143\u4E2D\u4F20\u9012\u7684\u6620\u5C04\u6570\u636E\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\nuniform float u_time;\nuniform vec4 u_aimate: [ 0, 2., 1.0, 0.2 ];\n\n#pragma include \"sdf_2d\"\n#pragma include \"picking\"\n\n\nvoid main() {\n int shape = int(floor(v_data.w + 0.5));\n\n \n vec4 textrueStroke = vec4(\n styleMappingMat[1][0],\n styleMappingMat[1][1],\n styleMappingMat[1][2],\n styleMappingMat[1][3]\n );\n\n float opacity = styleMappingMat[0][0];\n float stroke_opacity = styleMappingMat[0][1];\n float strokeWidth = styleMappingMat[0][2];\n vec4 strokeColor = textrueStroke == vec4(0) ? v_color : textrueStroke;\n\n lowp float antialiasblur = v_data.z;\n float r = v_radius / (v_radius + strokeWidth);\n\n float outer_df;\n float inner_df;\n // 'circle', 'triangle', 'square', 'pentagon', 'hexagon', 'octogon', 'hexagram', 'rhombus', 'vesica'\n if (shape == 0) {\n outer_df = sdCircle(v_data.xy, 1.0);\n inner_df = sdCircle(v_data.xy, r);\n } else if (shape == 1) {\n outer_df = sdEquilateralTriangle(1.1 * v_data.xy);\n inner_df = sdEquilateralTriangle(1.1 / r * v_data.xy);\n } else if (shape == 2) {\n outer_df = sdBox(v_data.xy, vec2(1.));\n inner_df = sdBox(v_data.xy, vec2(r));\n } else if (shape == 3) {\n outer_df = sdPentagon(v_data.xy, 0.8);\n inner_df = sdPentagon(v_data.xy, r * 0.8);\n } else if (shape == 4) {\n outer_df = sdHexagon(v_data.xy, 0.8);\n inner_df = sdHexagon(v_data.xy, r * 0.8);\n } else if (shape == 5) {\n outer_df = sdOctogon(v_data.xy, 1.0);\n inner_df = sdOctogon(v_data.xy, r);\n } else if (shape == 6) {\n outer_df = sdHexagram(v_data.xy, 0.52);\n inner_df = sdHexagram(v_data.xy, r * 0.52);\n } else if (shape == 7) {\n outer_df = sdRhombus(v_data.xy, vec2(1.0));\n inner_df = sdRhombus(v_data.xy, vec2(r));\n } else if (shape == 8) {\n outer_df = sdVesica(v_data.xy, 1.1, 0.8);\n inner_df = sdVesica(v_data.xy, r * 1.1, r * 0.8);\n }\n\n if(u_globel > 0.0) {\n // TODO: \u5730\u7403\u6A21\u5F0F\u4E0B\u907F\u514D\u591A\u4F59\u7247\u5143\u7ED8\u5236\uFF0C\u540C\u65F6\u4E5F\u80FD\u907F\u514D\u6709\u7528\u7247\u5143\u5728\u900F\u660E\u4E14\u91CD\u53E0\u7684\u60C5\u51B5\u4E0B\u65E0\u6CD5\u5199\u5165\n // \u4ED8\u51FA\u7684\u4EE3\u4EF7\u662F\u8FB9\u7F18\u4F1A\u6709\u4E00\u4E9B\u952F\u9F7F\n if(outer_df > antialiasblur + 0.018) discard;\n }\n float opacity_t = smoothstep(0.0, antialiasblur, outer_df); \n\n float color_t = strokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiasblur,\n 0.0,\n inner_df\n );\n float PI = 3.14159;\n float N_RINGS = 3.0;\n float FREQ = 1.0;\n\n gl_FragColor = mix(vec4(v_color.rgb, v_color.a * opacity), strokeColor * stroke_opacity, color_t);\n\n if(u_aimate.x == Animate) {\n float d = length(v_data.xy);\n float intensity = clamp(cos(d * PI), 0.0, 1.0) * clamp(cos(2.0 * PI * (d * 2.0 * u_aimate.z - u_aimate.y * u_time)), 0.0, 1.0);\n \n // TODO: \u6839\u636E\u53E0\u52A0\u6A21\u5F0F\u9009\u62E9\u6548\u679C\n if(u_additive > 0.0) {\n gl_FragColor *= intensity;\n } else {\n gl_FragColor = vec4(gl_FragColor.xyz, intensity);\n }\n \n // TODO: \u4F18\u5316\u5728\u6C34\u6CE2\u7EB9\u60C5\u51B5\u4E0B\u7684\u62FE\u53D6\uFF08a == 0 \u65F6\u65E0\u6CD5\u62FE\u53D6\uFF09\n if(d < 0.7) {\n gl_FragColor.a = max(gl_FragColor.a, 0.001);\n }\n\n if(u_additive > 0.0) {\n gl_FragColor = filterColorAnimate(gl_FragColor);\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n\n } else {\n gl_FragColor = filterColor(gl_FragColor);\n }\n\n gl_FragColor *= opacity_t;\n}\n";
|
|
39
|
+
var pointFillVert = "attribute vec4 a_Color;\nattribute vec3 a_Position;\nattribute vec3 a_Extrude;\nattribute float a_Size;\nattribute float a_Shape;\n\nvarying mat4 styleMappingMat; // \u7528\u4E8E\u5C06\u5728\u9876\u70B9\u7740\u8272\u5668\u4E2D\u8BA1\u7B97\u597D\u7684\u6837\u5F0F\u503C\u4F20\u9012\u7ED9\u7247\u5143\n\nuniform float u_globel;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\n\nvarying vec4 v_data;\nvarying vec4 v_color;\nvarying float v_radius;\n\nuniform float u_opacity : 1;\nuniform float u_stroke_opacity : 1;\nuniform float u_stroke_width : 2;\nuniform vec4 u_stroke_color : [0.0, 0.0, 0.0, 0.0];\nuniform vec2 u_offsets;\n\nuniform float u_blur : 0.0;\n\n#pragma include \"styleMapping\"\n#pragma include \"styleMappingCalOpacity\"\n#pragma include \"styleMappingCalStrokeOpacity\"\n#pragma include \"styleMappingCalStrokeWidth\"\n\n#pragma include \"projection\"\n#pragma include \"picking\"\n\n\nvoid main() {\n vec3 extrude = a_Extrude;\n float shape_type = a_Shape;\n float newSize = setPickingSize(a_Size);\n\n // cal style mapping - \u6570\u636E\u7EB9\u7406\u6620\u5C04\u90E8\u5206\u7684\u8BA1\u7B97\n styleMappingMat = mat4(\n 0.0, 0.0, 0.0, 0.0, // opacity - strokeOpacity - strokeWidth - empty\n 0.0, 0.0, 0.0, 0.0, // strokeR - strokeG - strokeB - strokeA\n 0.0, 0.0, 0.0, 0.0, // offsets[0] - offsets[1]\n 0.0, 0.0, 0.0, 0.0\n );\n\n float rowCount = u_cellTypeLayout[0][0]; // \u5F53\u524D\u7684\u6570\u636E\u7EB9\u7406\u6709\u51E0\u884C\n float columnCount = u_cellTypeLayout[0][1]; // \u5F53\u770B\u5230\u6570\u636E\u7EB9\u7406\u6709\u51E0\u5217\n float columnWidth = 1.0/columnCount; // \u5217\u5BBD\n float rowHeight = 1.0/rowCount; // \u884C\u9AD8\n float cellCount = calCellCount(); // opacity - strokeOpacity - strokeWidth - stroke - offsets\n float id = a_vertexId; // \u7B2Cn\u4E2A\u9876\u70B9\n float cellCurrentRow = floor(id * cellCount / columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u884C\n float cellCurrentColumn = mod(id * cellCount, columnCount) + 1.0; // \u8D77\u59CB\u70B9\u5728\u7B2C\u51E0\u5217\n \n // cell \u56FA\u5B9A\u987A\u5E8F opacity -> strokeOpacity -> strokeWidth -> stroke ... \n // \u6309\u987A\u5E8F\u4ECE cell \u4E2D\u53D6\u503C\u3001\u82E5\u6CA1\u6709\u5219\u81EA\u52A8\u5F80\u4E0B\u53D6\u503C\n float textureOffset = 0.0; // \u5728 cell \u4E2D\u53D6\u503C\u7684\u504F\u79FB\u91CF\n\n vec2 opacityAndOffset = calOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][0] = opacityAndOffset.r;\n textureOffset = opacityAndOffset.g;\n\n vec2 strokeOpacityAndOffset = calStrokeOpacityAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][1] = strokeOpacityAndOffset.r;\n textureOffset = strokeOpacityAndOffset.g;\n\n vec2 strokeWidthAndOffset = calStrokeWidthAndOffset(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset, columnWidth, rowHeight);\n styleMappingMat[0][2] = strokeWidthAndOffset.r;\n textureOffset = strokeWidthAndOffset.g;\n\n vec4 textrueStroke = vec4(-1.0, -1.0, -1.0, -1.0);\n if(hasStroke()) {\n vec2 valueRPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][0] = pos2value(valueRPos, columnWidth, rowHeight); // R\n textureOffset += 1.0;\n\n vec2 valueGPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][1] = pos2value(valueGPos, columnWidth, rowHeight); // G\n textureOffset += 1.0;\n\n vec2 valueBPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][2] = pos2value(valueBPos, columnWidth, rowHeight); // B\n textureOffset += 1.0;\n\n vec2 valueAPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n styleMappingMat[1][3] = pos2value(valueAPos, columnWidth, rowHeight); // A\n textureOffset += 1.0;\n } else {\n if(u_stroke_color == vec4(0.0)) {\n styleMappingMat[1][0] = v_color.r;\n styleMappingMat[1][1] = v_color.g;\n styleMappingMat[1][2] = v_color.b;\n styleMappingMat[1][3] = v_color.a;\n } else {\n styleMappingMat[1][0] = u_stroke_color.r;\n styleMappingMat[1][1] = u_stroke_color.g;\n styleMappingMat[1][2] = u_stroke_color.b;\n styleMappingMat[1][3] = u_stroke_color.a;\n }\n }\n\n vec2 textrueOffsets = vec2(0.0, 0.0);\n if(hasOffsets()) {\n vec2 valueXPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.r = pos2value(valueXPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n\n vec2 valueYPos = nextPos(cellCurrentRow, cellCurrentColumn, columnCount, textureOffset);\n textrueOffsets.g = pos2value(valueYPos, columnWidth, rowHeight); // x\n textureOffset += 1.0;\n } else {\n textrueOffsets = u_offsets;\n }\n\n // cal style mapping\n\n // unpack color(vec2)\n v_color = a_Color;\n\n // radius(16-bit)\n v_radius = newSize;\n\n // TODO: billboard\n // anti-alias\n // float antialiased_blur = -max(u_blur, antialiasblur);\n float antialiasblur = -max(1.0 / u_DevicePixelRatio / (newSize + u_stroke_width), u_blur);\n\n // construct point coords\n // TODP: /abs(extrude.x) \u662F\u4E3A\u4E86\u517C\u5BB9\u5730\u7403\u6A21\u5F0F\n v_data = vec4(extrude.x/abs(extrude.x), extrude.y/abs(extrude.y), antialiasblur,shape_type);\n\n // vec2 offset = project_pixel(extrude * (newSize + u_stroke_width) + u_offsets);\n vec2 offset = project_pixel(extrude.xy * (newSize + u_stroke_width) + textrueOffsets);\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * vec4(project_pos.xy + offset, 0.0, 1.0);\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, project_pixel(setPickingOrder(0.0)), 1.0));\n }\n\n if(u_globel > 0.0) {\n gl_Position = u_ViewProjectionMatrix * vec4(a_Position + extrude * newSize * 0.1, 1.0);\n }\n \n // gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy + offset, 0.0, 1.0));\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
40
40
|
|
|
41
41
|
var FillModel = function (_BaseModel) {
|
|
42
42
|
(0, _inherits2.default)(FillModel, _BaseModel);
|
|
@@ -61,7 +61,8 @@ var FillModel = function (_BaseModel) {
|
|
|
61
61
|
_ref$stroke = _ref.stroke,
|
|
62
62
|
stroke = _ref$stroke === void 0 ? 'rgba(0,0,0,0)' : _ref$stroke,
|
|
63
63
|
_ref$offsets = _ref.offsets,
|
|
64
|
-
offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets
|
|
64
|
+
offsets = _ref$offsets === void 0 ? [0, 0] : _ref$offsets,
|
|
65
|
+
blend = _ref.blend;
|
|
65
66
|
|
|
66
67
|
if (this.dataTextureTest && this.dataTextureNeedUpdate({
|
|
67
68
|
opacity: opacity,
|
|
@@ -103,6 +104,7 @@ var FillModel = function (_BaseModel) {
|
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
return {
|
|
107
|
+
u_additive: blend === 'additive' ? 1.0 : 0.0,
|
|
106
108
|
u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,
|
|
107
109
|
u_dataTexture: this.dataTexture,
|
|
108
110
|
u_cellTypeLayout: this.getCellTypeLayout(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/point/models/fill.ts"],"names":["FillModel","layer","getLayerConfig","opacity","strokeOpacity","strokeWidth","stroke","offsets","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_globel","mapService","version","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_stroke_opacity","u_stroke_width","u_stroke_color","getStrokeColor","u_offsets","isOffsetStatic","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","styleAttributeService","createAttributesAndIndices","PointFillTriangulation","buildModels","isGlobel","buildLayerModel","moduleName","vertexShader","pointFillVert","fragmentShader","pointFillFrag","triangulation","GlobelPointFillTriangulation","depth","enable","blend","getBlend","destroy","option","speed","rings","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","extrude","x","y","z","n1","vec3","fromValues","n2","xzReg","angle","Math","PI","yReg","asin","m","mat4","create","rotateY","rotateX","v1","transformMat4","normalize","v2","v3","v4","extrudeIndex","Array","isArray","shape","shape2d","shapeIndex","indexOf","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAWA;;AAKA;;AASA;;;;;;;;;IAUqBA,S;;;;;;;;;;;;WACnB,wBAAqC;AACnC,iBAMI,KAAKC,KAAL,CAAWC,cAAX,EANJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,oCAEEC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,CAACE,OAAR,CAAgBH,KAAhB,CAAnB;AACA,mBAAO,CAACE,UAAD,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;EAjPoCE,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IAttribute,\n IElements,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport BaseModel, {\n styleColor,\n styleOffset,\n styleSingle,\n} from '../../core/BaseModel';\nimport {\n GlobelPointFillTriangulation,\n PointFillTriangulation,\n} from '../../core/triangulation';\nimport pointFillFrag from '../shaders/fill_frag.glsl';\nimport pointFillVert from '../shaders/fill_vert.glsl';\n\nimport { isNumber } from 'lodash';\n\nimport { mat4, vec3 } from 'gl-matrix';\n\ninterface IPointLayerStyleOptions {\n opacity: styleSingle;\n strokeWidth: styleSingle;\n stroke: styleColor;\n strokeOpacity: styleSingle;\n offsets: styleOffset;\n}\n// 判断当前使用的 style 中的变量属性是否需要进行数据映射\nexport default class FillModel extends BaseModel {\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = 'rgba(0,0,0,0)',\n offsets = [0, 0],\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n });\n\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_stroke_opacity: isNumber(strokeOpacity) ? strokeOpacity : 1.0,\n u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 0.0,\n u_stroke_color: this.getStrokeColor(stroke),\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n return this.styleAttributeService.createAttributesAndIndices(\n this.layer.getEncodedData(),\n PointFillTriangulation,\n );\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointfill',\n vertexShader: pointFillVert,\n fragmentShader: pointFillFrag,\n triangulation: isGlobel\n ? GlobelPointFillTriangulation\n : PointFillTriangulation,\n // depth: { enable: false },\n depth: { enable: isGlobel },\n blend: this.getBlend(),\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected animateOption2Array(option: IAnimateOption): number[] {\n return [option.enable ? 0 : 1.0, option.speed || 1, option.rings || 3, 0];\n }\n protected registerBuiltinAttributes() {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'extrude',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Extrude',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n let extrude;\n // 地球模式\n if (isGlobel) {\n const [x, y, z] = vertex;\n const n1 = vec3.fromValues(0, 0, 1);\n const n2 = vec3.fromValues(x, 0, z);\n\n const xzReg =\n x >= 0 ? vec3.angle(n1, n2) : Math.PI * 2 - vec3.angle(n1, n2);\n\n const yReg = Math.PI * 2 - Math.asin(y / 100);\n\n const m = mat4.create();\n mat4.rotateY(m, m, xzReg);\n mat4.rotateX(m, m, yReg);\n\n const v1 = vec3.fromValues(1, 1, 0);\n vec3.transformMat4(v1, v1, m);\n vec3.normalize(v1, v1);\n\n const v2 = vec3.fromValues(-1, 1, 0);\n vec3.transformMat4(v2, v2, m);\n vec3.normalize(v2, v2);\n\n const v3 = vec3.fromValues(-1, -1, 0);\n vec3.transformMat4(v3, v3, m);\n vec3.normalize(v3, v3);\n\n const v4 = vec3.fromValues(1, -1, 0);\n vec3.transformMat4(v4, v4, m);\n vec3.normalize(v4, v4);\n\n extrude = [...v1, ...v2, ...v3, ...v4];\n } else {\n // 平面模式\n extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n }\n\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 5 } = feature;\n // console.log('featureIdx', featureIdx, feature)\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'shape',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Shape',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { shape = 2 } = feature;\n const shape2d = this.layer.getLayerConfig().shape2d as string[];\n const shapeIndex = shape2d.indexOf(shape as string);\n return [shapeIndex];\n },\n },\n });\n }\n}\n"],"file":"fill.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/point/models/fill.ts"],"names":["FillModel","layer","getLayerConfig","opacity","strokeOpacity","strokeWidth","stroke","offsets","blend","dataTextureTest","dataTextureNeedUpdate","judgeStyleAttributes","encodeData","getEncodedData","calDataFrame","cellLength","cellProperties","data","width","height","rowCount","dataTexture","length","createTexture2D","flipY","format","gl","LUMINANCE","type","FLOAT","u_additive","u_globel","mapService","version","u_dataTexture","u_cellTypeLayout","getCellTypeLayout","u_opacity","u_stroke_opacity","u_stroke_width","u_stroke_color","getStrokeColor","u_offsets","isOffsetStatic","animateOption","u_aimate","animateOption2Array","u_time","getLayerAnimateTime","styleAttributeService","createAttributesAndIndices","PointFillTriangulation","buildModels","isGlobel","buildLayerModel","moduleName","vertexShader","pointFillVert","fragmentShader","pointFillFrag","triangulation","GlobelPointFillTriangulation","depth","enable","getBlend","destroy","option","speed","rings","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","size","update","feature","featureIdx","vertex","attributeIdx","extrude","x","y","z","n1","vec3","fromValues","n2","xzReg","angle","Math","PI","yReg","asin","m","mat4","create","rotateY","rotateX","v1","transformMat4","normalize","v2","v3","v4","extrudeIndex","Array","isArray","shape","shape2d","shapeIndex","indexOf","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAWA;;AAKA;;AASA;;;;;;;;;IAWqBA,S;;;;;;;;;;;;WACnB,wBAAqC;AACnC,iBAOI,KAAKC,KAAL,CAAWC,cAAX,EAPJ;AAAA,8BACEC,OADF;AAAA,UACEA,OADF,6BACY,CADZ;AAAA,oCAEEC,aAFF;AAAA,UAEEA,aAFF,mCAEkB,CAFlB;AAAA,kCAGEC,WAHF;AAAA,UAGEA,WAHF,iCAGgB,CAHhB;AAAA,6BAIEC,MAJF;AAAA,UAIEA,MAJF,4BAIW,eAJX;AAAA,8BAKEC,OALF;AAAA,UAKEA,OALF,6BAKY,CAAC,CAAD,EAAI,CAAJ,CALZ;AAAA,UAMEC,KANF,QAMEA,KANF;;AASA,UACE,KAAKC,eAAL,IACA,KAAKC,qBAAL,CAA2B;AACzBP,QAAAA,OAAO,EAAPA,OADyB;AAEzBC,QAAAA,aAAa,EAAbA,aAFyB;AAGzBC,QAAAA,WAAW,EAAXA,WAHyB;AAIzBC,QAAAA,MAAM,EAANA,MAJyB;AAKzBC,QAAAA,OAAO,EAAPA;AALyB,OAA3B,CAFF,EASE;AAEA,aAAKI,oBAAL,CAA0B;AACxBR,UAAAA,OAAO,EAAPA,OADwB;AAExBC,UAAAA,aAAa,EAAbA,aAFwB;AAGxBC,UAAAA,WAAW,EAAXA,WAHwB;AAIxBC,UAAAA,MAAM,EAANA,MAJwB;AAKxBC,UAAAA,OAAO,EAAPA;AALwB,SAA1B;AAQA,YAAMK,UAAU,GAAG,KAAKX,KAAL,CAAWY,cAAX,EAAnB;;AACA,iCAAgC,KAAKC,YAAL,CAC9B,KAAKC,UADyB,EAE9BH,UAF8B,EAG9B,KAAKI,cAHyB,CAAhC;AAAA,YAAQC,IAAR,sBAAQA,IAAR;AAAA,YAAcC,KAA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EAAE;AAENC,YAAAA,KAAK,EAAEjD,WAAGkD,YAFJ;AAGN3D,YAAAA,IAAI,EAAE,EAHA;AAINW,YAAAA,IAAI,EAAEF,WAAGG;AAJH,WAFE;AAQVgD,UAAAA,IAAI,EAAE,CARI;AASVC,UAAAA,MAAM,EAAE,gBACNC,OADM,EAENC,UAFM,EAGNC,MAHM,EAINC,YAJM,EAKH;AACH,iCAAsBH,OAAtB,CAAQgC,KAAR;AAAA,gBAAQA,KAAR,+BAAgB,CAAhB;;AACA,gBAAMC,OAAO,GAAG,KAAI,CAAC/G,KAAL,CAAWC,cAAX,GAA4B8G,OAA5C;;AACA,gBAAMC,UAAU,GAAGD,OAAO,CAACE,OAAR,CAAgBH,KAAhB,CAAnB;AACA,mBAAO,CAACE,UAAD,CAAP;AACD;AAnBS;AAHoC,OAAlD;AAyBD;;;EAnPoCE,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAnimateOption,\n IAttribute,\n IElements,\n IEncodeFeature,\n ILayerConfig,\n IModel,\n IModelUniform,\n} from '@antv/l7-core';\nimport BaseModel, {\n styleColor,\n styleOffset,\n styleSingle,\n} from '../../core/BaseModel';\nimport {\n GlobelPointFillTriangulation,\n PointFillTriangulation,\n} from '../../core/triangulation';\nimport pointFillFrag from '../shaders/fill_frag.glsl';\nimport pointFillVert from '../shaders/fill_vert.glsl';\n\nimport { isNumber } from 'lodash';\n\nimport { mat4, vec3 } from 'gl-matrix';\n\ninterface IPointLayerStyleOptions {\n opacity: styleSingle;\n strokeWidth: styleSingle;\n stroke: styleColor;\n strokeOpacity: styleSingle;\n offsets: styleOffset;\n blend: string;\n}\n// 判断当前使用的 style 中的变量属性是否需要进行数据映射\nexport default class FillModel extends BaseModel {\n public getUninforms(): IModelUniform {\n const {\n opacity = 1,\n strokeOpacity = 1,\n strokeWidth = 0,\n stroke = 'rgba(0,0,0,0)',\n offsets = [0, 0],\n blend,\n } = this.layer.getLayerConfig() as IPointLayerStyleOptions;\n\n if (\n this.dataTextureTest &&\n this.dataTextureNeedUpdate({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n })\n ) {\n // 判断当前的样式中哪些是需要进行数据映射的,哪些是常量,同时计算用于构建数据纹理的一些中间变量\n this.judgeStyleAttributes({\n opacity,\n strokeOpacity,\n strokeWidth,\n stroke,\n offsets,\n });\n\n const encodeData = this.layer.getEncodedData();\n const { data, width, height } = this.calDataFrame(\n this.cellLength,\n encodeData,\n this.cellProperties,\n );\n this.rowCount = height; // 当前数据纹理有多少行\n\n this.dataTexture =\n this.cellLength > 0 && data.length > 0\n ? this.createTexture2D({\n flipY: true,\n data,\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width,\n height,\n })\n : this.createTexture2D({\n flipY: true,\n data: [1],\n format: gl.LUMINANCE,\n type: gl.FLOAT,\n width: 1,\n height: 1,\n });\n }\n return {\n u_additive: blend === 'additive' ? 1.0 : 0.0,\n u_globel: this.mapService.version === 'GLOBEL' ? 1 : 0,\n u_dataTexture: this.dataTexture, // 数据纹理 - 有数据映射的时候纹理中带数据,若没有任何数据映射时纹理是 [1]\n u_cellTypeLayout: this.getCellTypeLayout(),\n\n u_opacity: isNumber(opacity) ? opacity : 1.0,\n u_stroke_opacity: isNumber(strokeOpacity) ? strokeOpacity : 1.0,\n u_stroke_width: isNumber(strokeWidth) ? strokeWidth : 0.0,\n u_stroke_color: this.getStrokeColor(stroke),\n u_offsets: this.isOffsetStatic(offsets)\n ? (offsets as [number, number])\n : [0, 0],\n };\n }\n public getAnimateUniforms(): IModelUniform {\n const { animateOption } = this.layer.getLayerConfig() as ILayerConfig;\n return {\n u_aimate: this.animateOption2Array(animateOption as IAnimateOption),\n u_time: this.layer.getLayerAnimateTime(),\n };\n }\n\n public getAttribute(): {\n attributes: {\n [attributeName: string]: IAttribute;\n };\n elements: IElements;\n } {\n return this.styleAttributeService.createAttributesAndIndices(\n this.layer.getEncodedData(),\n PointFillTriangulation,\n );\n }\n\n public initModels(): IModel[] {\n return this.buildModels();\n }\n\n public buildModels(): IModel[] {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n return [\n this.layer.buildLayerModel({\n moduleName: 'pointfill',\n vertexShader: pointFillVert,\n fragmentShader: pointFillFrag,\n triangulation: isGlobel\n ? GlobelPointFillTriangulation\n : PointFillTriangulation,\n // depth: { enable: false },\n depth: { enable: isGlobel },\n blend: this.getBlend(),\n }),\n ];\n }\n\n public clearModels() {\n this.dataTexture?.destroy();\n }\n\n protected animateOption2Array(option: IAnimateOption): number[] {\n return [option.enable ? 0 : 1.0, option.speed || 1, option.rings || 3, 0];\n }\n protected registerBuiltinAttributes() {\n // TODO: 判断当前的点图层的模型是普通地图模式还是地球模式\n const isGlobel = this.mapService.version === 'GLOBEL';\n\n this.styleAttributeService.registerStyleAttribute({\n name: 'extrude',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Extrude',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 3,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n let extrude;\n // 地球模式\n if (isGlobel) {\n const [x, y, z] = vertex;\n const n1 = vec3.fromValues(0, 0, 1);\n const n2 = vec3.fromValues(x, 0, z);\n\n const xzReg =\n x >= 0 ? vec3.angle(n1, n2) : Math.PI * 2 - vec3.angle(n1, n2);\n\n const yReg = Math.PI * 2 - Math.asin(y / 100);\n\n const m = mat4.create();\n mat4.rotateY(m, m, xzReg);\n mat4.rotateX(m, m, yReg);\n\n const v1 = vec3.fromValues(1, 1, 0);\n vec3.transformMat4(v1, v1, m);\n vec3.normalize(v1, v1);\n\n const v2 = vec3.fromValues(-1, 1, 0);\n vec3.transformMat4(v2, v2, m);\n vec3.normalize(v2, v2);\n\n const v3 = vec3.fromValues(-1, -1, 0);\n vec3.transformMat4(v3, v3, m);\n vec3.normalize(v3, v3);\n\n const v4 = vec3.fromValues(1, -1, 0);\n vec3.transformMat4(v4, v4, m);\n vec3.normalize(v4, v4);\n\n extrude = [...v1, ...v2, ...v3, ...v4];\n } else {\n // 平面模式\n extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n }\n\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'size',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Size',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { size = 5 } = feature;\n // console.log('featureIdx', featureIdx, feature)\n return Array.isArray(size) ? [size[0]] : [size as number];\n },\n },\n });\n\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'shape',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Shape',\n buffer: {\n // give the WebGL driver a hint that this buffer may change\n usage: gl.DYNAMIC_DRAW,\n data: [],\n type: gl.FLOAT,\n },\n size: 1,\n update: (\n feature: IEncodeFeature,\n featureIdx: number,\n vertex: number[],\n attributeIdx: number,\n ) => {\n const { shape = 2 } = feature;\n const shape2d = this.layer.getLayerConfig().shape2d as string[];\n const shapeIndex = shape2d.indexOf(shape as string);\n return [shapeIndex];\n },\n },\n });\n }\n}\n"],"file":"fill.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/point/shape/extrude.ts"],"names":["extrudePolygon","path","p1","p2","length","slice","n","flattengeo","earcut","flatten","positions","indexArray","normals","j","vertices","push","triangles","holes","dimensions","i","prePoint","nextPoint","indexOffset","map","v","index","fillPolygon","points"],"mappings":";;;;;;;;;;;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,CAAC,GAAGb,CAApB,EAAuBa,CAAC,EAAxB,EAA4B;AAAA,UAAnBA,CAAmB;AAsB3B;;AACD,SAAO;AACLT,IAAAA,SAAS,EAATA,SADK;AAELe,IAAAA,KAAK,EAAEd;AAFF,GAAP;AAID;;AACM,SAASe,WAAT,CAAqBC,MAArB,EAAsC;AAC3C,MAAMpB,UAAU,GAAGC,gBAAOC,OAAP,CAAekB,MAAf,CAAnB;;AACA,MAAMX,SAAS,GAAG,qBAChBT,UAAU,CAACO,QADK,EAEhBP,UAAU,CAACU,KAFK,EAGhBV,UAAU,CAACW,UAHK,CAAlB;AAKA,SAAO;AACLR,IAAAA,SAAS,EAAEH,UAAU,CAACO,QADjB;AAELW,IAAAA,KAAK,EAAET;AAFF,GAAP;AAID","sourcesContent":["import earcut from 'earcut';\nimport { IPath } from '
|
|
1
|
+
{"version":3,"sources":["../../../src/point/shape/extrude.ts"],"names":["extrudePolygon","path","p1","p2","length","slice","n","flattengeo","earcut","flatten","positions","indexArray","normals","j","vertices","push","triangles","holes","dimensions","i","prePoint","nextPoint","indexOffset","map","v","index","fillPolygon","points"],"mappings":";;;;;;;;;;;;AAAA;;AAWe,SAASA,cAAT,CAAwBC,IAAxB,EAAwD;AACrE,MAAMC,EAAE,GAAGD,IAAI,CAAC,CAAD,CAAJ,CAAQ,CAAR,CAAX;AACA,MAAME,EAAE,GAAGF,IAAI,CAAC,CAAD,CAAJ,CAAQA,IAAI,CAAC,CAAD,CAAJ,CAAQG,MAAR,GAAiB,CAAzB,CAAX;;AACA,MAAIF,EAAE,CAAC,CAAD,CAAF,KAAUC,EAAE,CAAC,CAAD,CAAZ,IAAmBD,EAAE,CAAC,CAAD,CAAF,KAAUC,EAAE,CAAC,CAAD,CAAnC,EAAwC;AACtCF,IAAAA,IAAI,CAAC,CAAD,CAAJ,GAAUA,IAAI,CAAC,CAAD,CAAJ,CAAQI,KAAR,CAAc,CAAd,EAAiBJ,IAAI,CAAC,CAAD,CAAJ,CAAQG,MAAR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Path';\nexport interface IExtrudeGeomety {\n positions: number[];\n index: number[];\n}\n/**\n * 拉伸多边形顶点,返回拉伸后的顶点信息\n * @param paths 路径数据组\n * @param extrude 是否拉伸\n */\nexport default function extrudePolygon(path: IPath[]): IExtrudeGeomety {\n const p1 = path[0][0];\n const p2 = path[0][path[0].length - 1];\n if (p1[0] === p2[0] && p1[1] === p2[1]) {\n path[0] = path[0].slice(0, path[0].length - 1);\n }\n const n = path[0].length;\n const flattengeo = earcut.flatten(path);\n const positions = [];\n const indexArray = [];\n const normals = [];\n // 设置顶部z值\n for (let j = 0; j < flattengeo.vertices.length / 3; j++) {\n flattengeo.vertices[j * 3 + 2] = 1;\n normals.push(0, 0, 1);\n }\n positions.push(...flattengeo.vertices);\n const triangles = earcut(\n flattengeo.vertices,\n flattengeo.holes,\n flattengeo.dimensions,\n );\n indexArray.push(...triangles);\n for (let i = 0; i < n; i++) {\n const prePoint = flattengeo.vertices.slice(i * 3, i * 3 + 3);\n let nextPoint = flattengeo.vertices.slice(i * 3 + 3, i * 3 + 6);\n if (nextPoint.length === 0) {\n nextPoint = flattengeo.vertices.slice(0, 3);\n }\n const indexOffset = positions.length / 3;\n positions.push(\n prePoint[0],\n prePoint[1],\n 1,\n nextPoint[0],\n nextPoint[1],\n 1,\n prePoint[0],\n prePoint[1],\n 0,\n nextPoint[0],\n nextPoint[1],\n 0,\n );\n indexArray.push(...[1, 2, 0, 3, 2, 1].map((v) => v + indexOffset));\n }\n return {\n positions,\n index: indexArray,\n };\n}\nexport function fillPolygon(points: IPath[]) {\n const flattengeo = earcut.flatten(points);\n const triangles = earcut(\n flattengeo.vertices,\n flattengeo.holes,\n flattengeo.dimensions,\n );\n return {\n positions: flattengeo.vertices,\n index: triangles,\n };\n}\n"],"file":"extrude.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-layers",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.18",
|
|
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.6.
|
|
28
|
-
"@antv/l7-source": "^2.6.
|
|
29
|
-
"@antv/l7-utils": "^2.6.
|
|
27
|
+
"@antv/l7-core": "^2.6.18",
|
|
28
|
+
"@antv/l7-source": "^2.6.18",
|
|
29
|
+
"@antv/l7-utils": "^2.6.18",
|
|
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": "
|
|
55
|
+
"gitHead": "9267c1da64f93f7acb956bea3b59a2f2eb93f767",
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
58
58
|
}
|
package/es/point/shape/Path.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
declare type IPosition = [number, number, number];
|
|
2
|
-
export declare type IPath = IPosition[];
|
|
3
|
-
export declare enum ShapeType3D {
|
|
4
|
-
CYLINDER = "cylinder",
|
|
5
|
-
SQUARECOLUMN = "squareColumn",
|
|
6
|
-
TRIANGLECOLUMN = "triangleColumn",
|
|
7
|
-
HEXAGONCOLUMN = "hexagonColumn",
|
|
8
|
-
PENTAGONCOLUMN = "pentagonColumn"
|
|
9
|
-
}
|
|
10
|
-
export declare enum ShapeType2D {
|
|
11
|
-
CIRCLE = "circle",
|
|
12
|
-
SQUARE = "square",
|
|
13
|
-
TRIANGLE = "triangle",
|
|
14
|
-
HEXAGON = "hexagon",
|
|
15
|
-
PENTAGON = "pentagon"
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* 生成规则多边形顶点个数
|
|
19
|
-
* @param pointCount 顶点个数 3 => 三角形
|
|
20
|
-
* @param start 顶点起始角度 调整图形的方向
|
|
21
|
-
*/
|
|
22
|
-
export declare function polygonPath(pointCount: number, start?: number): IPath;
|
|
23
|
-
export declare function circle(): IPath;
|
|
24
|
-
export declare function square(): IPath;
|
|
25
|
-
export declare function triangle(): IPath;
|
|
26
|
-
export declare function hexagon(): IPath;
|
|
27
|
-
export declare function pentagon(): IPath;
|
|
28
|
-
export declare const geometryShape: {
|
|
29
|
-
circle: typeof circle;
|
|
30
|
-
hexagon: typeof hexagon;
|
|
31
|
-
triangle: typeof triangle;
|
|
32
|
-
square: typeof square;
|
|
33
|
-
pentagon: typeof pentagon;
|
|
34
|
-
cylinder: typeof circle;
|
|
35
|
-
hexagonColumn: typeof hexagon;
|
|
36
|
-
triangleColumn: typeof triangle;
|
|
37
|
-
squareColumn: typeof square;
|
|
38
|
-
pentagonColumn: typeof pentagon;
|
|
39
|
-
};
|
|
40
|
-
export {};
|
package/es/point/shape/Path.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
|
-
var _geometryShape;
|
|
4
|
-
|
|
5
|
-
export var ShapeType3D;
|
|
6
|
-
|
|
7
|
-
(function (ShapeType3D) {
|
|
8
|
-
ShapeType3D["CYLINDER"] = "cylinder";
|
|
9
|
-
ShapeType3D["SQUARECOLUMN"] = "squareColumn";
|
|
10
|
-
ShapeType3D["TRIANGLECOLUMN"] = "triangleColumn";
|
|
11
|
-
ShapeType3D["HEXAGONCOLUMN"] = "hexagonColumn";
|
|
12
|
-
ShapeType3D["PENTAGONCOLUMN"] = "pentagonColumn";
|
|
13
|
-
})(ShapeType3D || (ShapeType3D = {}));
|
|
14
|
-
|
|
15
|
-
export var ShapeType2D;
|
|
16
|
-
|
|
17
|
-
(function (ShapeType2D) {
|
|
18
|
-
ShapeType2D["CIRCLE"] = "circle";
|
|
19
|
-
ShapeType2D["SQUARE"] = "square";
|
|
20
|
-
ShapeType2D["TRIANGLE"] = "triangle";
|
|
21
|
-
ShapeType2D["HEXAGON"] = "hexagon";
|
|
22
|
-
ShapeType2D["PENTAGON"] = "pentagon";
|
|
23
|
-
})(ShapeType2D || (ShapeType2D = {}));
|
|
24
|
-
|
|
25
|
-
export function polygonPath(pointCount) {
|
|
26
|
-
var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
27
|
-
var step = Math.PI * 2 / pointCount;
|
|
28
|
-
var line = [];
|
|
29
|
-
|
|
30
|
-
for (var i = 0; i < pointCount; i++) {
|
|
31
|
-
line.push(step * i + start * Math.PI / 12);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
var path = line.map(function (t) {
|
|
35
|
-
var x = Math.sin(t + Math.PI / 4);
|
|
36
|
-
var y = Math.cos(t + Math.PI / 4);
|
|
37
|
-
return [x, y, 0];
|
|
38
|
-
});
|
|
39
|
-
return path;
|
|
40
|
-
}
|
|
41
|
-
export function circle() {
|
|
42
|
-
return polygonPath(30);
|
|
43
|
-
}
|
|
44
|
-
export function square() {
|
|
45
|
-
return polygonPath(4);
|
|
46
|
-
}
|
|
47
|
-
export function triangle() {
|
|
48
|
-
return polygonPath(3);
|
|
49
|
-
}
|
|
50
|
-
export function hexagon() {
|
|
51
|
-
return polygonPath(6);
|
|
52
|
-
}
|
|
53
|
-
export function pentagon() {
|
|
54
|
-
return polygonPath(5);
|
|
55
|
-
}
|
|
56
|
-
export var geometryShape = (_geometryShape = {}, _defineProperty(_geometryShape, ShapeType2D.CIRCLE, circle), _defineProperty(_geometryShape, ShapeType2D.HEXAGON, hexagon), _defineProperty(_geometryShape, ShapeType2D.TRIANGLE, triangle), _defineProperty(_geometryShape, ShapeType2D.SQUARE, square), _defineProperty(_geometryShape, ShapeType2D.PENTAGON, pentagon), _defineProperty(_geometryShape, ShapeType3D.CYLINDER, circle), _defineProperty(_geometryShape, ShapeType3D.HEXAGONCOLUMN, hexagon), _defineProperty(_geometryShape, ShapeType3D.TRIANGLECOLUMN, triangle), _defineProperty(_geometryShape, ShapeType3D.SQUARECOLUMN, square), _defineProperty(_geometryShape, ShapeType3D.PENTAGONCOLUMN, pentagon), _geometryShape);
|
|
57
|
-
//# sourceMappingURL=Path.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/point/shape/Path.ts"],"names":["ShapeType3D","ShapeType2D","polygonPath","pointCount","start","step","Math","PI","line","i","push","path","map","t","x","sin","y","cos","circle","square","triangle","hexagon","pentagon","geometryShape","CIRCLE","HEXAGON","TRIANGLE","SQUARE","PENTAGON","CYLINDER","HEXAGONCOLUMN","TRIANGLECOLUMN","SQUARECOLUMN","PENTAGONCOLUMN"],"mappings":";;;;AAEA,WAAYA,WAAZ;;WAAYA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,KAAAA,W;;AAOZ,WAAYC,WAAZ;;WAAYA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,KAAAA,W;;AAaZ,OAAO,SAASC,WAAT,CAAqBC,UAArB,EAAmE;AAAA,MAA1BC,KAA0B,uEAAV,CAAU;AACxE,MAAMC,IAAI,GAAIC,IAAI,CAACC,EAAL,GAAU,CAAX,GAAgBJ,UAA7B;AACA,MAAMK,IAAI,GAAG,EAAb;;AACA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGN,UAApB,EAAgCM,CAAC,EAAjC,EAAqC;AACnCD,IAAAA,IAAI,CAACE,IAAL,CAAUL,IAAI,GAAGI,CAAP,GAAYL,KAAK,GAAGE,IAAI,CAACC,EAAd,GAAoB,EAAzC;AACD;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];\nexport type IPath = IPosition[];\nexport enum ShapeType3D {\n CYLINDER = 'cylinder',\n SQUARECOLUMN = 'squareColumn',\n TRIANGLECOLUMN = 'triangleColumn',\n HEXAGONCOLUMN = 'hexagonColumn',\n PENTAGONCOLUMN = 'pentagonColumn',\n}\nexport enum ShapeType2D {\n CIRCLE = 'circle',\n SQUARE = 'square',\n TRIANGLE = 'triangle',\n HEXAGON = 'hexagon',\n PENTAGON = 'pentagon',\n}\n\n/**\n * 生成规则多边形顶点个数\n * @param pointCount 顶点个数 3 => 三角形\n * @param start 顶点起始角度 调整图形的方向\n */\nexport function polygonPath(pointCount: number, start: number = 0): IPath {\n const step = (Math.PI * 2) / pointCount;\n const line = [];\n for (let i = 0; i < pointCount; i++) {\n line.push(step * i + (start * Math.PI) / 12);\n }\n const path: IPath = line.map((t) => {\n const x = Math.sin(t + Math.PI / 4);\n const y = Math.cos(t + Math.PI / 4);\n return [x, y, 0];\n });\n // path.push(path[0]);\n return path;\n}\n\nexport function circle(): IPath {\n return polygonPath(30);\n}\nexport function square(): IPath {\n return polygonPath(4);\n}\nexport function triangle(): IPath {\n return polygonPath(3);\n}\nexport function hexagon(): IPath {\n return polygonPath(6);\n}\nexport function pentagon(): IPath {\n return polygonPath(5);\n}\n\nexport const geometryShape = {\n [ShapeType2D.CIRCLE]: circle,\n [ShapeType2D.HEXAGON]: hexagon,\n [ShapeType2D.TRIANGLE]: triangle,\n [ShapeType2D.SQUARE]: square,\n [ShapeType2D.PENTAGON]: pentagon,\n [ShapeType3D.CYLINDER]: circle,\n [ShapeType3D.HEXAGONCOLUMN]: hexagon,\n [ShapeType3D.TRIANGLECOLUMN]: triangle,\n [ShapeType3D.SQUARECOLUMN]: square,\n [ShapeType3D.PENTAGONCOLUMN]: pentagon,\n};\n"],"file":"Path.js"}
|
package/lib/point/shape/Path.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.ShapeType3D = exports.ShapeType2D = void 0;
|
|
9
|
-
exports.circle = circle;
|
|
10
|
-
exports.geometryShape = void 0;
|
|
11
|
-
exports.hexagon = hexagon;
|
|
12
|
-
exports.pentagon = pentagon;
|
|
13
|
-
exports.polygonPath = polygonPath;
|
|
14
|
-
exports.square = square;
|
|
15
|
-
exports.triangle = triangle;
|
|
16
|
-
|
|
17
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
18
|
-
|
|
19
|
-
var _geometryShape;
|
|
20
|
-
|
|
21
|
-
var ShapeType3D;
|
|
22
|
-
exports.ShapeType3D = ShapeType3D;
|
|
23
|
-
|
|
24
|
-
(function (ShapeType3D) {
|
|
25
|
-
ShapeType3D["CYLINDER"] = "cylinder";
|
|
26
|
-
ShapeType3D["SQUARECOLUMN"] = "squareColumn";
|
|
27
|
-
ShapeType3D["TRIANGLECOLUMN"] = "triangleColumn";
|
|
28
|
-
ShapeType3D["HEXAGONCOLUMN"] = "hexagonColumn";
|
|
29
|
-
ShapeType3D["PENTAGONCOLUMN"] = "pentagonColumn";
|
|
30
|
-
})(ShapeType3D || (exports.ShapeType3D = ShapeType3D = {}));
|
|
31
|
-
|
|
32
|
-
var ShapeType2D;
|
|
33
|
-
exports.ShapeType2D = ShapeType2D;
|
|
34
|
-
|
|
35
|
-
(function (ShapeType2D) {
|
|
36
|
-
ShapeType2D["CIRCLE"] = "circle";
|
|
37
|
-
ShapeType2D["SQUARE"] = "square";
|
|
38
|
-
ShapeType2D["TRIANGLE"] = "triangle";
|
|
39
|
-
ShapeType2D["HEXAGON"] = "hexagon";
|
|
40
|
-
ShapeType2D["PENTAGON"] = "pentagon";
|
|
41
|
-
})(ShapeType2D || (exports.ShapeType2D = ShapeType2D = {}));
|
|
42
|
-
|
|
43
|
-
function polygonPath(pointCount) {
|
|
44
|
-
var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
45
|
-
var step = Math.PI * 2 / pointCount;
|
|
46
|
-
var line = [];
|
|
47
|
-
|
|
48
|
-
for (var i = 0; i < pointCount; i++) {
|
|
49
|
-
line.push(step * i + start * Math.PI / 12);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
var path = line.map(function (t) {
|
|
53
|
-
var x = Math.sin(t + Math.PI / 4);
|
|
54
|
-
var y = Math.cos(t + Math.PI / 4);
|
|
55
|
-
return [x, y, 0];
|
|
56
|
-
});
|
|
57
|
-
return path;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function circle() {
|
|
61
|
-
return polygonPath(30);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function square() {
|
|
65
|
-
return polygonPath(4);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function triangle() {
|
|
69
|
-
return polygonPath(3);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function hexagon() {
|
|
73
|
-
return polygonPath(6);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function pentagon() {
|
|
77
|
-
return polygonPath(5);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
var geometryShape = (_geometryShape = {}, (0, _defineProperty2.default)(_geometryShape, ShapeType2D.CIRCLE, circle), (0, _defineProperty2.default)(_geometryShape, ShapeType2D.HEXAGON, hexagon), (0, _defineProperty2.default)(_geometryShape, ShapeType2D.TRIANGLE, triangle), (0, _defineProperty2.default)(_geometryShape, ShapeType2D.SQUARE, square), (0, _defineProperty2.default)(_geometryShape, ShapeType2D.PENTAGON, pentagon), (0, _defineProperty2.default)(_geometryShape, ShapeType3D.CYLINDER, circle), (0, _defineProperty2.default)(_geometryShape, ShapeType3D.HEXAGONCOLUMN, hexagon), (0, _defineProperty2.default)(_geometryShape, ShapeType3D.TRIANGLECOLUMN, triangle), (0, _defineProperty2.default)(_geometryShape, ShapeType3D.SQUARECOLUMN, square), (0, _defineProperty2.default)(_geometryShape, ShapeType3D.PENTAGONCOLUMN, pentagon), _geometryShape);
|
|
81
|
-
exports.geometryShape = geometryShape;
|
|
82
|
-
//# sourceMappingURL=Path.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/point/shape/Path.ts"],"names":["ShapeType3D","ShapeType2D","polygonPath","pointCount","start","step","Math","PI","line","i","push","path","map","t","x","sin","y","cos","circle","square","triangle","hexagon","pentagon","geometryShape","CIRCLE","HEXAGON","TRIANGLE","SQUARE","PENTAGON","CYLINDER","HEXAGONCOLUMN","TRIANGLECOLUMN","SQUARECOLUMN","PENTAGONCOLUMN"],"mappings":";;;;;;;;;;;;;;;;;;;;IAEYA,W;;;WAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,2BAAAA,W;;IAOAC,W;;;WAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;AAAAA,EAAAA,W;GAAAA,W,2BAAAA,W;;AAaL,SAASC,WAAT,CAAqBC,UAArB,EAAmE;AAAA,MAA1BC,KAA0B,uEAAV,CAAU;AACxE,MAAMC,IAAI,GAAIC,IAAI,CAACC,EAAL,GAAU,CAAX,GAAgBJ,UAA7B;AACA,MAAMK,IAAI,GAAG,EAAb;;AACA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGN,UAApB,EAAgCM,CAAC,EAAjC,EAAqC;AACnCD,IAAAA,IAAI,CAACE,IAAL,CAAUL,IAAI,GAAGI,CAAP,GAAYL,KAAK,GAAGE,IAAI,CAACC,EAAd,GAAoB,EAAzC;AACD;;AACD,MAAMI,IAAW,GAAGH,IAAI,CAACI,GAAL,CAAS,UAACC,CAAD,EAAO;AAClC,QAAMC,CAAC,GAAGR,IAAI,CAACS,GAAL,CAASF,CAAC,GAAGP,IAAI,CAACC,EAAL,GAAU,CAAvB,CAAV;AACA,QAAMS,CAAC,GAAGV,IAAI,CAACW,GAAL,CAASJ,CAAC,GAAGP,IAAI,CAACC,EAAL,GAAU,CAAvB,CAAV;AACA,WAAO,CAACO,CAAD,EAAIE,CAAJ,EAAO,CAAP,CAAP;AACD,GAJmB,CAApB;AAMA,SAAOL,IAAP;AACD;;AAEM,SAASO,MAAT,GAAyB;AAC9B,SAAOhB,WAAW,CAAC,EAAD,CAAlB;AACD;;AACM,SAASiB,MAAT,GAAyB;AAC9B,SAAOjB,WAAW,CAAC,CAAD,CAAlB;AACD;;AACM,SAASkB,QAAT,GAA2B;AAChC,SAAOlB,WAAW,CAAC,CAAD,CAAlB;AACD;;AACM,SAASmB,OAAT,GAA0B;AAC/B,SAAOnB,WAAW,CAAC,CAAD,CAAlB;AACD;;AACM,SAASoB,QAAT,GAA2B;AAChC,SAAOpB,WAAW,CAAC,CAAD,CAAlB;AACD;;AAEM,IAAMqB,aAAa,uEACvBtB,WAAW,CAACuB,MADW,EACFN,MADE,iDAEvBjB,WAAW,CAACwB,OAFW,EAEDJ,OAFC,iDAGvBpB,WAAW,CAACyB,QAHW,EAGAN,QAHA,iDAIvBnB,WAAW,CAAC0B,MAJW,EAIFR,MAJE,iDAKvBlB,WAAW,CAAC2B,QALW,EAKAN,QALA,iDAMvBtB,WAAW,CAAC6B,QANW,EAMAX,MANA,iDAOvBlB,WAAW,CAAC8B,aAPW,EAOKT,OAPL,iDAQvBrB,WAAW,CAAC+B,cARW,EAQMX,QARN,iDASvBpB,WAAW,CAACgC,YATW,EASIb,MATJ,iDAUvBnB,WAAW,CAACiC,cAVW,EAUMX,QAVN,kBAAnB","sourcesContent":["type IPosition = [number, number, number];\nexport type IPath = IPosition[];\nexport enum ShapeType3D {\n CYLINDER = 'cylinder',\n SQUARECOLUMN = 'squareColumn',\n TRIANGLECOLUMN = 'triangleColumn',\n HEXAGONCOLUMN = 'hexagonColumn',\n PENTAGONCOLUMN = 'pentagonColumn',\n}\nexport enum ShapeType2D {\n CIRCLE = 'circle',\n SQUARE = 'square',\n TRIANGLE = 'triangle',\n HEXAGON = 'hexagon',\n PENTAGON = 'pentagon',\n}\n\n/**\n * 生成规则多边形顶点个数\n * @param pointCount 顶点个数 3 => 三角形\n * @param start 顶点起始角度 调整图形的方向\n */\nexport function polygonPath(pointCount: number, start: number = 0): IPath {\n const step = (Math.PI * 2) / pointCount;\n const line = [];\n for (let i = 0; i < pointCount; i++) {\n line.push(step * i + (start * Math.PI) / 12);\n }\n const path: IPath = line.map((t) => {\n const x = Math.sin(t + Math.PI / 4);\n const y = Math.cos(t + Math.PI / 4);\n return [x, y, 0];\n });\n // path.push(path[0]);\n return path;\n}\n\nexport function circle(): IPath {\n return polygonPath(30);\n}\nexport function square(): IPath {\n return polygonPath(4);\n}\nexport function triangle(): IPath {\n return polygonPath(3);\n}\nexport function hexagon(): IPath {\n return polygonPath(6);\n}\nexport function pentagon(): IPath {\n return polygonPath(5);\n}\n\nexport const geometryShape = {\n [ShapeType2D.CIRCLE]: circle,\n [ShapeType2D.HEXAGON]: hexagon,\n [ShapeType2D.TRIANGLE]: triangle,\n [ShapeType2D.SQUARE]: square,\n [ShapeType2D.PENTAGON]: pentagon,\n [ShapeType3D.CYLINDER]: circle,\n [ShapeType3D.HEXAGONCOLUMN]: hexagon,\n [ShapeType3D.TRIANGLECOLUMN]: triangle,\n [ShapeType3D.SQUARECOLUMN]: square,\n [ShapeType3D.PENTAGONCOLUMN]: pentagon,\n};\n"],"file":"Path.js"}
|