@antv/l7-layers 2.8.34 → 2.8.37
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/Geometry/index.d.ts +1 -1
- package/es/Geometry/index.js +4 -1
- package/es/Geometry/index.js.map +1 -1
- package/es/Geometry/models/billboard.d.ts +26 -0
- package/es/Geometry/models/billboard.js +213 -0
- package/es/Geometry/models/billboard.js.map +1 -0
- package/es/Geometry/models/index.d.ts +1 -1
- package/es/Geometry/models/index.js +3 -1
- package/es/Geometry/models/index.js.map +1 -1
- package/es/Geometry/models/sprite.js +2 -2
- package/es/core/BaseLayer.d.ts +2 -2
- package/es/core/BaseLayer.js.map +1 -1
- package/es/core/LayerGroup.d.ts +2 -1
- package/es/core/LayerGroup.js +5 -0
- package/es/core/LayerGroup.js.map +1 -1
- package/es/core/interface.d.ts +29 -2
- package/es/core/interface.js.map +1 -1
- package/es/image/models/image.js.map +1 -1
- package/es/index.d.ts +2 -2
- package/es/index.js +2 -2
- package/es/index.js.map +1 -1
- package/es/line/models/arc.js +4 -4
- package/es/line/models/arc.js.map +1 -1
- package/es/line/models/arc_3d.js +4 -5
- package/es/line/models/arc_3d.js.map +1 -1
- package/es/line/models/arcmini.js +5 -5
- package/es/line/models/arcmini.js.map +1 -1
- package/es/line/models/great_circle.js +3 -3
- package/es/line/models/great_circle.js.map +1 -1
- package/es/line/models/line.js +3 -3
- package/es/line/models/line.js.map +1 -1
- package/es/line/models/linearline.js +3 -3
- package/es/line/models/linearline.js.map +1 -1
- package/es/line/models/simpleLine.js +8 -8
- package/es/line/models/simpleLine.js.map +1 -1
- package/es/line/models/wall.js +5 -5
- package/es/line/models/wall.js.map +1 -1
- package/es/mask/index.d.ts +1 -4
- package/es/mask/index.js.map +1 -1
- package/es/mask/models/fill.js.map +1 -1
- package/es/plugins/DataMappingPlugin.d.ts +1 -0
- package/es/plugins/DataMappingPlugin.js +17 -9
- package/es/plugins/DataMappingPlugin.js.map +1 -1
- package/es/plugins/FeatureScalePlugin.d.ts +1 -2
- package/es/plugins/FeatureScalePlugin.js +42 -33
- package/es/plugins/FeatureScalePlugin.js.map +1 -1
- package/es/plugins/ShaderUniformPlugin.d.ts +1 -0
- package/es/plugins/ShaderUniformPlugin.js +12 -0
- package/es/plugins/ShaderUniformPlugin.js.map +1 -1
- package/es/point/models/extrude.js +3 -4
- package/es/point/models/extrude.js.map +1 -1
- package/es/point/models/fill.js +3 -4
- package/es/point/models/fill.js.map +1 -1
- package/es/point/models/fillmage.d.ts +1 -1
- package/es/point/models/fillmage.js +6 -21
- package/es/point/models/fillmage.js.map +1 -1
- package/es/point/models/icon-font.js +1 -1
- package/es/point/models/image.js +4 -4
- package/es/point/models/image.js.map +1 -1
- package/es/point/models/normal.js +1 -2
- package/es/point/models/normal.js.map +1 -1
- package/es/point/models/radar.js +5 -18
- package/es/point/models/radar.js.map +1 -1
- package/es/point/models/simplePoint.js +5 -6
- package/es/point/models/simplePoint.js.map +1 -1
- package/es/point/models/text.js +4 -4
- package/es/point/models/text.js.map +1 -1
- package/es/polygon/models/extrude.js +3 -4
- package/es/polygon/models/extrude.js.map +1 -1
- package/es/polygon/models/fill.d.ts +1 -0
- package/es/polygon/models/fill.js +37 -12
- package/es/polygon/models/fill.js.map +1 -1
- package/es/polygon/models/ocean.js +3 -4
- package/es/polygon/models/ocean.js.map +1 -1
- package/es/polygon/models/water.js +3 -4
- package/es/polygon/models/water.js.map +1 -1
- package/es/raster/index.d.ts +3 -3
- package/es/raster/index.js +16 -6
- package/es/raster/index.js.map +1 -1
- package/es/raster/models/index.d.ts +1 -1
- package/es/raster/models/index.js +3 -1
- package/es/raster/models/index.js.map +1 -1
- package/es/raster/models/raste-tile.d.ts +23 -0
- package/es/raster/models/raste-tile.js +285 -0
- package/es/raster/models/raste-tile.js.map +1 -0
- package/es/raster/models/raster.js +2 -0
- package/es/raster/models/raster.js.map +1 -1
- package/es/wind/index.d.ts +1 -17
- package/es/wind/index.js.map +1 -1
- package/es/wind/models/utils.d.ts +12 -12
- package/es/wind/models/utils.js +6 -5
- package/es/wind/models/utils.js.map +1 -1
- package/es/wind/models/wind.js.map +1 -1
- package/es/wind/models/windRender.js.map +1 -1
- package/lib/Geometry/index.js +4 -1
- package/lib/Geometry/index.js.map +1 -1
- package/lib/Geometry/models/billboard.js +227 -0
- package/lib/Geometry/models/billboard.js.map +1 -0
- package/lib/Geometry/models/index.js +4 -1
- package/lib/Geometry/models/index.js.map +1 -1
- package/lib/Geometry/models/sprite.js +2 -2
- package/lib/core/BaseLayer.js.map +1 -1
- package/lib/core/LayerGroup.js +5 -0
- package/lib/core/LayerGroup.js.map +1 -1
- package/lib/core/interface.js.map +1 -1
- package/lib/image/models/image.js.map +1 -1
- package/lib/index.js +29 -8
- package/lib/index.js.map +1 -1
- package/lib/line/models/arc.js +4 -5
- package/lib/line/models/arc.js.map +1 -1
- package/lib/line/models/arc_3d.js +4 -6
- package/lib/line/models/arc_3d.js.map +1 -1
- package/lib/line/models/arcmini.js +5 -6
- package/lib/line/models/arcmini.js.map +1 -1
- package/lib/line/models/great_circle.js +3 -4
- package/lib/line/models/great_circle.js.map +1 -1
- package/lib/line/models/line.js +3 -4
- package/lib/line/models/line.js.map +1 -1
- package/lib/line/models/linearline.js +3 -4
- package/lib/line/models/linearline.js.map +1 -1
- package/lib/line/models/simpleLine.js +8 -9
- package/lib/line/models/simpleLine.js.map +1 -1
- package/lib/line/models/wall.js +5 -6
- package/lib/line/models/wall.js.map +1 -1
- package/lib/mask/index.js.map +1 -1
- package/lib/mask/models/fill.js.map +1 -1
- package/lib/plugins/DataMappingPlugin.js +17 -9
- package/lib/plugins/DataMappingPlugin.js.map +1 -1
- package/lib/plugins/FeatureScalePlugin.js +43 -33
- package/lib/plugins/FeatureScalePlugin.js.map +1 -1
- package/lib/plugins/ShaderUniformPlugin.js +12 -0
- package/lib/plugins/ShaderUniformPlugin.js.map +1 -1
- package/lib/point/models/extrude.js +3 -5
- package/lib/point/models/extrude.js.map +1 -1
- package/lib/point/models/fill.js +3 -5
- package/lib/point/models/fill.js.map +1 -1
- package/lib/point/models/fillmage.js +7 -23
- package/lib/point/models/fillmage.js.map +1 -1
- package/lib/point/models/icon-font.js +1 -1
- package/lib/point/models/image.js +4 -5
- package/lib/point/models/image.js.map +1 -1
- package/lib/point/models/normal.js +1 -3
- package/lib/point/models/normal.js.map +1 -1
- package/lib/point/models/radar.js +5 -19
- package/lib/point/models/radar.js.map +1 -1
- package/lib/point/models/simplePoint.js +5 -7
- package/lib/point/models/simplePoint.js.map +1 -1
- package/lib/point/models/text.js +4 -5
- package/lib/point/models/text.js.map +1 -1
- package/lib/polygon/models/extrude.js +3 -5
- package/lib/polygon/models/extrude.js.map +1 -1
- package/lib/polygon/models/fill.js +37 -13
- package/lib/polygon/models/fill.js.map +1 -1
- package/lib/polygon/models/ocean.js +3 -5
- package/lib/polygon/models/ocean.js.map +1 -1
- package/lib/polygon/models/water.js +3 -5
- package/lib/polygon/models/water.js.map +1 -1
- package/lib/raster/index.js +16 -6
- package/lib/raster/index.js.map +1 -1
- package/lib/raster/models/index.js +4 -1
- package/lib/raster/models/index.js.map +1 -1
- package/lib/raster/models/raste-tile.js +294 -0
- package/lib/raster/models/raste-tile.js.map +1 -0
- package/lib/raster/models/raster.js +2 -0
- package/lib/raster/models/raster.js.map +1 -1
- package/lib/wind/index.js.map +1 -1
- package/lib/wind/models/utils.js +6 -5
- package/lib/wind/models/utils.js.map +1 -1
- package/lib/wind/models/wind.js.map +1 -1
- package/lib/wind/models/windRender.js.map +1 -1
- package/package.json +7 -6
- package/es/imagetile/index.d.ts +0 -22
- package/es/imagetile/index.js +0 -82
- package/es/imagetile/index.js.map +0 -1
- package/es/imagetile/models/imagetile.d.ts +0 -12
- package/es/imagetile/models/imagetile.js +0 -133
- package/es/imagetile/models/imagetile.js.map +0 -1
- package/es/imagetile/models/index.d.ts +0 -5
- package/es/imagetile/models/index.js +0 -6
- package/es/imagetile/models/index.js.map +0 -1
- package/es/imagetile/utils/ImageTile.d.ts +0 -20
- package/es/imagetile/utils/ImageTile.js +0 -92
- package/es/imagetile/utils/ImageTile.js.map +0 -1
- package/es/imagetile/utils/Tile.d.ts +0 -27
- package/es/imagetile/utils/Tile.js +0 -313
- package/es/imagetile/utils/Tile.js.map +0 -1
- package/es/imagetile/utils/lruCache.d.ts +0 -20
- package/es/imagetile/utils/lruCache.js +0 -105
- package/es/imagetile/utils/lruCache.js.map +0 -1
- package/es/imagetile/utils/tileCache.d.ts +0 -8
- package/es/imagetile/utils/tileCache.js +0 -50
- package/es/imagetile/utils/tileCache.js.map +0 -1
- package/lib/imagetile/index.js +0 -95
- package/lib/imagetile/index.js.map +0 -1
- package/lib/imagetile/models/imagetile.js +0 -146
- package/lib/imagetile/models/imagetile.js.map +0 -1
- package/lib/imagetile/models/index.js +0 -17
- package/lib/imagetile/models/index.js.map +0 -1
- package/lib/imagetile/utils/ImageTile.js +0 -101
- package/lib/imagetile/utils/ImageTile.js.map +0 -1
- package/lib/imagetile/utils/Tile.js +0 -316
- package/lib/imagetile/utils/Tile.js.map +0 -1
- package/lib/imagetile/utils/lruCache.js +0 -109
- package/lib/imagetile/utils/lruCache.js.map +0 -1
- package/lib/imagetile/utils/tileCache.js +0 -58
- package/lib/imagetile/utils/tileCache.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/wind/models/wind.ts"],"names":["AttributeType","gl","FrequencyController","BaseModel","RasterImageTriangulation","Wind","defaultRampColors","WindModel","frequency","run","drawWind","drawColorMode","Error","createTexture2D","rendererService","source","layer","getSource","texture","height","width","glContext","getGLContext","imageCoords","data","dataArray","coordinates","images","then","imageData","getLayerConfig","uMin","uMax","vMin","vMax","fadeOpacity","speedFactor","dropRate","dropRateBump","rampColors","sizeScale","getWindSize","imageWidth","imageHeight","options","wind","setWind","image","layerService","updateLayerRenderList","renderLayers","colorModel","buildLayerModel","moduleName","vertexShader","WindVert","fragmentShader","WindFrag","triangulation","primitive","TRIANGLES","depth","enable","blend","getBlend","p1","mapService","lngLatToPixel","p2","Math","floor","x","y","initModels","destroy","properties","opacity","type","minimum","maximum","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","numParticles","reSize","updateWindDir","updateParticelNum","updateColorRampTexture","draw","d","w","h","setBaseState","uniforms","u_opacity","u_texture"],"mappings":";;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAQO,eARP;AASA,SAASC,mBAAT,QAA4C,gBAA5C;AACA,OAAOC,SAAP,MAAsB,sBAAtB;AACA,SAASC,wBAAT,QAAyC,0BAAzC;;;AAGA,SAA4BC,IAA5B,QAAwC,cAAxC;AAmBA,IAAMC,iBAAiB,GAAG;AACxB,OAAK,SADmB;AAExB,OAAK,SAFmB;AAGxB,OAAK,SAHmB;AAIxB,OAAK,SAJmB;AAKxB,OAAK,SALmB;AAMxB,OAAK,SANmB;AAOxB,OAAK,SAPmB;AAQxB,OAAK;AARmB,CAA1B;;IAWqBC,S;;;;;;;;;;;;;;;;;;;;;;;;gEAMS,G;;gEAIR,IAAIL,mBAAJ,CAAwB,GAAxB,C;;;;;;;WAEpB,kBAAgB;AAAA;;AAEd,WAAKM,SAAL,CAAeC,GAAf,CAAmB,YAAM;AACvB,QAAA,MAAI,CAACC,QAAL;AACD,OAFD;AAGA,WAAKC,aAAL;AACD;;;WAED,wBAAqC;AACnC,YAAM,IAAIC,KAAJ,CAAU,yBAAV,CAAN;AACD;;;WAED,sBAAoB;AAAA;;AAClB,UAAQC,eAAR,GAA4B,KAAKC,eAAjC,CAAQD,eAAR;AAEA,UAAME,MAAM,GAAG,KAAKC,KAAL,CAAWC,SAAX,EAAf;AACA,WAAKC,OAAL,GAAeL,eAAe,CAAC;AAC7BM,QAAAA,MAAM,EAAE,CADqB;AAE7BC,QAAAA,KAAK,EAAE;AAFsB,OAAD,CAA9B;AAKA,UAAMC,SAAS,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EAA8BC,IAA9B,EAAoCC,IAApC,EAA0CC,IAA1C;AAEA,aAAKW,IAAL,CAAUqD,iBAAV,CAA4BH,YAA5B;AAEA,aAAKlD,IAAL,CAAUsD,sBAAV,CAAiC5D,UAAjC;AAEA,aAAKM,IAAL,CAAUV,WAAV,GAAwBA,WAAxB;AACA,aAAKU,IAAL,CAAUT,WAAV,GAAwBA,WAAxB;AACA,aAAKS,IAAL,CAAUR,QAAV,GAAqBA,QAArB;AACA,aAAKQ,IAAL,CAAUP,YAAV,GAAyBA,YAAzB;;AAEA,8BAAoB,KAAKO,IAAL,CAAUuD,IAAV,EAApB;AAAA,YAAQC,CAAR,mBAAQA,CAAR;AAAA,YAAWC,CAAX,mBAAWA,CAAX;AAAA,YAAcC,CAAd,mBAAcA,CAAd;;AAEA,aAAKzF,eAAL,CAAqB0F,YAArB;AACA,aAAKtF,OAAL,CAAawE,MAAb,CAAoB;AAClBlE,UAAAA,IAAI,EAAE6E,CADY;AAElBjF,UAAAA,KAAK,EAAEkF,CAFW;AAGlBnF,UAAAA,MAAM,EAAEoF;AAHU,SAApB;AAKD;AACF;;;WAED,yBAAwB;AACtB,kBAAoB,KAAKvF,KAAL,CAAWc,cAAX,EAApB;AAAA,UAAQ8C,OAAR,SAAQA,OAAR;;AACA,WAAKzB,UAAL,CAAgBiD,IAAhB,CAAqB;AACnBK,QAAAA,QAAQ,EAAE;AACRC,UAAAA,SAAS,EAAE9B,OAAO,IAAI,GADd;AAER+B,UAAAA,SAAS,EAAE,KAAKzF;AAFR;AADS,OAArB;AAMD;;;;EA7MoCf,S;;SAAlBI,S","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IModel,\n IModelUniform,\n ITexture2D,\n Point,\n} from '@antv/l7-core';\nimport { FrequencyController, isMini } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { RasterImageTriangulation } from '../../core/triangulation';\nimport WindFrag from '../shaders/wind_frag.glsl';\nimport WindVert from '../shaders/wind_vert.glsl';\nimport { IWind, IWindProps, Wind } from './windRender';\n\ninterface IWindLayerStyleOptions {\n uMin?: number;\n uMax?: number;\n vMin?: number;\n vMax?: number;\n fadeOpacity?: number;\n speedFactor?: number;\n dropRate?: number;\n dropRateBump?: number;\n opacity?: number;\n numParticles?: number;\n rampColors?: {\n [key: number]: string;\n };\n sizeScale?: number;\n}\n\nconst defaultRampColors = {\n 0.0: '#3288bd',\n 0.1: '#66c2a5',\n 0.2: '#abdda4',\n 0.3: '#e6f598',\n 0.4: '#fee08b',\n 0.5: '#fdae61',\n 0.6: '#f46d43',\n 1.0: '#d53e4f',\n};\n\nexport default class WindModel extends BaseModel {\n protected texture: ITexture2D;\n\n private colorModel: IModel;\n private wind: IWind;\n private imageCoords: [Point, Point];\n private sizeScale: number = 0.5;\n // https://mapbox.github.io/webgl-wind/demo/\n // source: 'http://nomads.ncep.noaa.gov',\n\n private frequency = new FrequencyController(7.2);\n\n public render() {\n // TODO: 控制风场的平均更新频率\n this.frequency.run(() => {\n this.drawWind();\n });\n this.drawColorMode();\n }\n\n public getUninforms(): IModelUniform {\n throw new Error('Method not implemented.');\n }\n\n public initModels() {\n const { createTexture2D } = this.rendererService;\n\n const source = this.layer.getSource();\n this.texture = createTexture2D({\n height: 0,\n width: 0,\n });\n\n const glContext = this.rendererService.getGLContext();\n this.imageCoords = source.data.dataArray[0].coordinates as [Point, Point];\n\n source.data.images.then((imageData: HTMLImageElement[]) => {\n const {\n uMin = -21.32,\n uMax = 26.8,\n vMin = -21.57,\n vMax = 21.42,\n fadeOpacity = 0.996,\n speedFactor = 0.25,\n dropRate = 0.003,\n dropRateBump = 0.01,\n rampColors = defaultRampColors,\n sizeScale = 0.5,\n } = this.layer.getLayerConfig() as IWindLayerStyleOptions;\n this.sizeScale = sizeScale;\n\n const { imageWidth, imageHeight } = this.getWindSize();\n\n const options: IWindProps = {\n glContext,\n imageWidth,\n imageHeight,\n fadeOpacity,\n speedFactor,\n dropRate,\n dropRateBump,\n rampColors,\n };\n\n this.wind = new Wind(options);\n\n // imageData[0] 风场图\n this.wind.setWind({\n uMin,\n uMax,\n vMin,\n vMax,\n image: imageData[0],\n });\n\n this.texture = createTexture2D({\n data: imageData[0],\n width: imageData[0].width,\n height: imageData[0].height,\n });\n\n this.layerService.updateLayerRenderList();\n this.layerService.renderLayers();\n });\n\n this.colorModel = this.layer.buildLayerModel({\n moduleName: 'WindLayer',\n vertexShader: WindVert,\n fragmentShader: WindFrag,\n triangulation: RasterImageTriangulation,\n primitive: gl.TRIANGLES,\n depth: { enable: false },\n blend: this.getBlend(),\n });\n\n return [this.colorModel];\n }\n\n public getWindSize() {\n const p1 = this.mapService.lngLatToPixel(this.imageCoords[0]);\n const p2 = this.mapService.lngLatToPixel(this.imageCoords[1]);\n\n const imageWidth = Math.floor((p2.x - p1.x) * this.sizeScale);\n const imageHeight = Math.floor((p1.y - p2.y) * this.sizeScale);\n return { imageWidth, imageHeight };\n }\n\n public buildModels() {\n return this.initModels();\n }\n\n public clearModels(): void {\n this.texture?.destroy();\n this.wind?.destroy();\n }\n\n protected getConfigSchema() {\n return {\n properties: {\n opacity: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n },\n },\n };\n }\n\n protected registerBuiltinAttributes() {\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Uv',\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\n private drawWind() {\n if (this.wind) {\n const {\n uMin = -21.32,\n uMax = 26.8,\n vMin = -21.57,\n vMax = 21.42,\n numParticles = 65535,\n fadeOpacity = 0.996,\n speedFactor = 0.25,\n dropRate = 0.003,\n dropRateBump = 0.01,\n rampColors = defaultRampColors,\n sizeScale = 0.5,\n } = this.layer.getLayerConfig() as IWindLayerStyleOptions;\n if (typeof sizeScale === 'number' && sizeScale !== this.sizeScale) {\n this.sizeScale = sizeScale;\n const { imageWidth, imageHeight } = this.getWindSize();\n this.wind.reSize(imageWidth, imageHeight);\n }\n\n this.wind.updateWindDir(uMin, uMax, vMin, vMax);\n\n this.wind.updateParticelNum(numParticles);\n\n this.wind.updateColorRampTexture(rampColors);\n\n this.wind.fadeOpacity = fadeOpacity;\n this.wind.speedFactor = speedFactor;\n this.wind.dropRate = dropRate;\n this.wind.dropRateBump = dropRateBump;\n\n const { d, w, h } = this.wind.draw();\n // TODO: 恢复 L7 渲染流程中 gl 状态\n this.rendererService.setBaseState();\n this.texture.update({\n data: d,\n width: w,\n height: h,\n });\n }\n }\n\n private drawColorMode() {\n const { opacity } = this.layer.getLayerConfig() as IWindLayerStyleOptions;\n this.colorModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_texture: this.texture,\n },\n });\n }\n}\n"],"file":"wind.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/wind/models/wind.ts"],"names":["AttributeType","gl","FrequencyController","BaseModel","RasterImageTriangulation","Wind","defaultRampColors","WindModel","frequency","run","drawWind","drawColorMode","Error","createTexture2D","rendererService","source","layer","getSource","texture","height","width","glContext","getGLContext","imageCoords","data","dataArray","coordinates","images","then","imageData","getLayerConfig","uMin","uMax","vMin","vMax","fadeOpacity","speedFactor","dropRate","dropRateBump","rampColors","sizeScale","getWindSize","imageWidth","imageHeight","options","wind","setWind","image","layerService","updateLayerRenderList","renderLayers","colorModel","buildLayerModel","moduleName","vertexShader","WindVert","fragmentShader","WindFrag","triangulation","primitive","TRIANGLES","depth","enable","blend","getBlend","p1","mapService","lngLatToPixel","p2","Math","floor","x","y","initModels","destroy","properties","opacity","type","minimum","maximum","styleAttributeService","registerStyleAttribute","name","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","FLOAT","size","update","feature","featureIdx","vertex","attributeIdx","numParticles","reSize","updateWindDir","updateParticelNum","updateColorRampTexture","draw","d","w","h","setBaseState","uniforms","u_opacity","u_texture"],"mappings":";;;;;;;;;;;;AAAA,SACEA,aADF,EAEEC,EAFF,QAQO,eARP;AASA,SAASC,mBAAT,QAAoC,gBAApC;AACA,OAAOC,SAAP,MAAsB,sBAAtB;AAEA,SAASC,wBAAT,QAAyC,0BAAzC;;;AAGA,SAA4BC,IAA5B,QAAwC,cAAxC;AAEA,IAAMC,iBAAiB,GAAG;AACxB,OAAK,SADmB;AAExB,OAAK,SAFmB;AAGxB,OAAK,SAHmB;AAIxB,OAAK,SAJmB;AAKxB,OAAK,SALmB;AAMxB,OAAK,SANmB;AAOxB,OAAK,SAPmB;AAQxB,OAAK;AARmB,CAA1B;;IAWqBC,S;;;;;;;;;;;;;;;;;;;;;;;;gEAMS,G;;gEAIR,IAAIL,mBAAJ,CAAwB,GAAxB,C;;;;;;;WAEpB,kBAAgB;AAAA;;AAEd,WAAKM,SAAL,CAAeC,GAAf,CAAmB,YAAM;AACvB,QAAA,MAAI,CAACC,QAAL;AACD,OAFD;AAGA,WAAKC,aAAL;AACD;;;WAED,wBAAqC;AACnC,YAAM,IAAIC,KAAJ,CAAU,yBAAV,CAAN;AACD;;;WAED,sBAAoB;AAAA;;AAClB,UAAQC,eAAR,GAA4B,KAAKC,eAAjC,CAAQD,eAAR;AAEA,UAAME,MAAM,GAAG,KAAKC,KAAL,CAAWC,SAAX,EAAf;AACA,WAAKC,OAAL,GAAeL,eAAe,CAAC;AAC7BM,QAAAA,MAAM,EAAE,CADqB;AAE7BC,QAAAA,KAAK,EAAE;AAFsB,OAAD,CAA9B;AAKA,UAAMC,SAAS,GAAG,KAAKP,eAAL,CAAqBQ,YAArB,EAAlB;AACA,WAAKC,WAAL,GAAmBR,MAAM,CAACS,IAAP,CAAYC,SAAZ,CAAsB,CAAtB,EAAyBC,WAA5C;AAEAX,MAAAA,MAAM,CAACS,IAAP,CAAYG,MAAZ,CAAmBC,IAAnB,CAAw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ACA,aAAKU,IAAL,CAAUT,WAAV,GAAwBA,WAAxB;AACA,aAAKS,IAAL,CAAUR,QAAV,GAAqBA,QAArB;AACA,aAAKQ,IAAL,CAAUP,YAAV,GAAyBA,YAAzB;;AAEA,8BAAoB,KAAKO,IAAL,CAAUuD,IAAV,EAApB;AAAA,YAAQC,CAAR,mBAAQA,CAAR;AAAA,YAAWC,CAAX,mBAAWA,CAAX;AAAA,YAAcC,CAAd,mBAAcA,CAAd;;AAEA,aAAKzF,eAAL,CAAqB0F,YAArB;AACA,aAAKtF,OAAL,CAAawE,MAAb,CAAoB;AAClBlE,UAAAA,IAAI,EAAE6E,CADY;AAElBjF,UAAAA,KAAK,EAAEkF,CAFW;AAGlBnF,UAAAA,MAAM,EAAEoF;AAHU,SAApB;AAKD;AACF;;;WAED,yBAAwB;AACtB,kBAAoB,KAAKvF,KAAL,CAAWc,cAAX,EAApB;AAAA,UAAQ8C,OAAR,SAAQA,OAAR;;AACA,WAAKzB,UAAL,CAAgBiD,IAAhB,CAAqB;AACnBK,QAAAA,QAAQ,EAAE;AACRC,UAAAA,SAAS,EAAE9B,OAAO,IAAI,GADd;AAER+B,UAAAA,SAAS,EAAE,KAAKzF;AAFR;AADS,OAArB;AAMD;;;;EA7MoCf,S;;SAAlBI,S","sourcesContent":["import {\n AttributeType,\n gl,\n IEncodeFeature,\n IModel,\n IModelUniform,\n ITexture2D,\n Point,\n} from '@antv/l7-core';\nimport { FrequencyController } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { IWindLayerStyleOptions } from '../../core/interface';\nimport { RasterImageTriangulation } from '../../core/triangulation';\nimport WindFrag from '../shaders/wind_frag.glsl';\nimport WindVert from '../shaders/wind_vert.glsl';\nimport { IWind, IWindProps, Wind } from './windRender';\n\nconst defaultRampColors = {\n 0.0: '#3288bd',\n 0.1: '#66c2a5',\n 0.2: '#abdda4',\n 0.3: '#e6f598',\n 0.4: '#fee08b',\n 0.5: '#fdae61',\n 0.6: '#f46d43',\n 1.0: '#d53e4f',\n};\n\nexport default class WindModel extends BaseModel {\n protected texture: ITexture2D;\n\n private colorModel: IModel;\n private wind: IWind;\n private imageCoords: [Point, Point];\n private sizeScale: number = 0.5;\n // https://mapbox.github.io/webgl-wind/demo/\n // source: 'http://nomads.ncep.noaa.gov',\n\n private frequency = new FrequencyController(7.2);\n\n public render() {\n // TODO: 控制风场的平均更新频率\n this.frequency.run(() => {\n this.drawWind();\n });\n this.drawColorMode();\n }\n\n public getUninforms(): IModelUniform {\n throw new Error('Method not implemented.');\n }\n\n public initModels() {\n const { createTexture2D } = this.rendererService;\n\n const source = this.layer.getSource();\n this.texture = createTexture2D({\n height: 0,\n width: 0,\n });\n\n const glContext = this.rendererService.getGLContext();\n this.imageCoords = source.data.dataArray[0].coordinates as [Point, Point];\n\n source.data.images.then((imageData: HTMLImageElement[]) => {\n const {\n uMin = -21.32,\n uMax = 26.8,\n vMin = -21.57,\n vMax = 21.42,\n fadeOpacity = 0.996,\n speedFactor = 0.25,\n dropRate = 0.003,\n dropRateBump = 0.01,\n rampColors = defaultRampColors,\n sizeScale = 0.5,\n } = this.layer.getLayerConfig() as IWindLayerStyleOptions;\n this.sizeScale = sizeScale;\n\n const { imageWidth, imageHeight } = this.getWindSize();\n\n const options: IWindProps = {\n glContext,\n imageWidth,\n imageHeight,\n fadeOpacity,\n speedFactor,\n dropRate,\n dropRateBump,\n rampColors,\n };\n\n this.wind = new Wind(options);\n\n // imageData[0] 风场图\n this.wind.setWind({\n uMin,\n uMax,\n vMin,\n vMax,\n image: imageData[0],\n });\n\n this.texture = createTexture2D({\n data: imageData[0],\n width: imageData[0].width,\n height: imageData[0].height,\n });\n\n this.layerService.updateLayerRenderList();\n this.layerService.renderLayers();\n });\n\n this.colorModel = this.layer.buildLayerModel({\n moduleName: 'WindLayer',\n vertexShader: WindVert,\n fragmentShader: WindFrag,\n triangulation: RasterImageTriangulation,\n primitive: gl.TRIANGLES,\n depth: { enable: false },\n blend: this.getBlend(),\n });\n\n return [this.colorModel];\n }\n\n public getWindSize() {\n const p1 = this.mapService.lngLatToPixel(this.imageCoords[0]);\n const p2 = this.mapService.lngLatToPixel(this.imageCoords[1]);\n\n const imageWidth = Math.floor((p2.x - p1.x) * this.sizeScale);\n const imageHeight = Math.floor((p1.y - p2.y) * this.sizeScale);\n return { imageWidth, imageHeight };\n }\n\n public buildModels() {\n return this.initModels();\n }\n\n public clearModels(): void {\n this.texture?.destroy();\n this.wind?.destroy();\n }\n\n protected getConfigSchema() {\n return {\n properties: {\n opacity: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n },\n },\n };\n }\n\n protected registerBuiltinAttributes() {\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Uv',\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\n private drawWind() {\n if (this.wind) {\n const {\n uMin = -21.32,\n uMax = 26.8,\n vMin = -21.57,\n vMax = 21.42,\n numParticles = 65535,\n fadeOpacity = 0.996,\n speedFactor = 0.25,\n dropRate = 0.003,\n dropRateBump = 0.01,\n rampColors = defaultRampColors,\n sizeScale = 0.5,\n } = this.layer.getLayerConfig() as IWindLayerStyleOptions;\n if (typeof sizeScale === 'number' && sizeScale !== this.sizeScale) {\n this.sizeScale = sizeScale;\n const { imageWidth, imageHeight } = this.getWindSize();\n this.wind.reSize(imageWidth, imageHeight);\n }\n\n this.wind.updateWindDir(uMin, uMax, vMin, vMax);\n\n this.wind.updateParticelNum(numParticles);\n\n this.wind.updateColorRampTexture(rampColors);\n\n this.wind.fadeOpacity = fadeOpacity;\n this.wind.speedFactor = speedFactor;\n this.wind.dropRate = dropRate;\n this.wind.dropRateBump = dropRateBump;\n\n const { d, w, h } = this.wind.draw();\n // TODO: 恢复 L7 渲染流程中 gl 状态\n this.rendererService.setBaseState();\n this.texture.update({\n data: d,\n width: w,\n height: h,\n });\n }\n }\n\n private drawColorMode() {\n const { opacity } = this.layer.getLayerConfig() as IWindLayerStyleOptions;\n this.colorModel.draw({\n uniforms: {\n u_opacity: opacity || 1.0,\n u_texture: this.texture,\n },\n });\n }\n}\n"],"file":"wind.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/wind/models/windRender.ts"],"names":["glUtils","drawFrag","drawVert","fullScreenFrag","fullScreenVert","updateFrag","updateVert","getColorRamp","colors","canvas","document","createElement","ctx","getContext","width","height","gradient","createLinearGradient","Object","keys","stop","addColorStop","fillStyle","fillRect","Uint8Array","getImageData","data","bindAttribute","gl","buffer","attribute","numComponents","bindBuffer","ARRAY_BUFFER","enableVertexAttribArray","vertexAttribPointer","FLOAT","bindFramebuffer","framebuffer","texture","FRAMEBUFFER","framebufferTexture2D","COLOR_ATTACHMENT0","TEXTURE_2D","Wind","options","glContext","imageWidth","imageHeight","fadeOpacity","speedFactor","dropRate","dropRateBump","rampColors","init","drawProgram","createProgram","fullScreenProgram","updateProgram","quadBuffer","createBuffer","Float32Array","createFramebuffer","colorRampTexture","createTexture","LINEAR","emptyPixels","backgroundTexture","NEAREST","screenTexture","particleRes","particleStateResolution","Math","ceil","sqrt","numParticles","numParticlesSize","particleState","i","length","floor","random","particleStateTexture0","particleStateTexture1","particleIndices","i$1","particleIndexBuffer","windData","windTexture","createDataTexture","image","num","uMin","uMax","vMin","vMax","isColorChanged","deleteTexture","item","key","Number","bindTexture","drawScreen","updateParticles","d","pixels","w","h","viewport","drawFullTexture","drawParticles","disable","BLEND","readPixels","RGBA","UNSIGNED_BYTE","temp","opacity","program","useProgram","a_pos","uniform1i","u_screen","uniform1f","u_opacity","drawArrays","TRIANGLES","a_index","u_wind","u_particles","u_color_ramp","u_particles_res","uniform2f","u_wind_min","u_wind_max","POINTS","u_rand_seed","u_wind_res","u_speed_factor","u_drop_rate","u_drop_rate_bump","deleteBuffer","deleteFramebuffer","deleteShader","vertexShader","fragmentShader","deleteProgram"],"mappings":";;;AAAA,OAAO,KAAKA,OAAZ,MAAyB,SAAzB;AACA,SACEC,QADF,EAEEC,QAFF,EAGEC,cAHF,EAIEC,cAJF,EAKEC,UALF,EAMEC,UANF,QAOO,cAPP;;AASA,SAASC,YAAT,CAAsBC,MAAtB,EAAyD;AACvD,MAAIC,MAAM,GAAGC,QAAQ,CAACC,aAAT,CAAuB,QAAvB,CAAb;AACA,MAAMC,GAAG,GAAGH,MAAM,CAACI,UAAP,CAAkB,IAAlB,CAAZ;AAEAJ,EAAAA,MAAM,CAACK,KAAP,GAAe,GAAf;AACAL,EAAAA,MAAM,CAACM,MAAP,GAAgB,CAAhB;AAEA,MAAMC,QAAQ,GAAGJ,GAAG,CAACK,oBAAJ,CAAyB,CAAzB,EAA4B,CAA5B,EAA+B,GAA/B,EAAoC,CAApC,CAAjB;;AACA,kCAAmBC,MAAM,CAACC,IAAP,CAAYX,MAAZ,CAAnB,kCAAwC;AAAnC,QAAMY,IAAI,mBAAV;AACHJ,IAAAA,QAAQ,CAACK,YAAT,CAAsB,CAACD,IAAvB,EAA6BZ,MAAM,CAAC,CAACY,IAAF,CAAnC;AACD;;AAEDR,EAAAA,GAAG,CAACU,SAAJ,GAAgBN,QAAhB;AACAJ,EAAAA,GAAG,CAACW,QAAJ,CAAa,CAAb,EAAgB,CAAhB,EAAmB,GAAnB,EAAwB,CAAxB;AAGAd,EAAAA,MAAM,GAAG,IAAT;AAEA,SAAO,IAAIe,UAAJ,CAAeZ,GAAG,CAACa,YAAJ,CAAiB,CAAjB,EAAoB,CAApB,EAAuB,GAAvB,EAA4B,CAA5B,EAA+BC,IAA9C,CAAP;AACD;;AAED,SAASC,aAAT,CACEC,EADF,EAEEC,MAFF,EAGEC,SAHF,EAIEC,aAJF,EAKE;AACAH,EAAAA,EAAE,CAAC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E,aAAR,CAAsB,KAAK5B,aAA3B;AACA,WAAKzC,EAAL,CAAQqE,aAAR,CAAsB,KAAKf,qBAA3B;AACA,WAAKtD,EAAL,CAAQqE,aAAR,CAAsB,KAAKd,qBAA3B;AACA,WAAKvD,EAAL,CAAQqE,aAAR,CAAsB,KAAKT,WAA3B;AACD;AAtbH;;AAAA;AAAA","sourcesContent":["import * as glUtils from './utils';\nimport {\n drawFrag,\n drawVert,\n fullScreenFrag,\n fullScreenVert,\n updateFrag,\n updateVert,\n} from './windShader';\n\nfunction getColorRamp(colors: { [key: number]: string }) {\n let canvas = document.createElement('canvas') as HTMLCanvasElement;\n const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;\n\n canvas.width = 256;\n canvas.height = 1;\n\n const gradient = ctx.createLinearGradient(0, 0, 256, 0);\n for (const stop of Object.keys(colors)) {\n gradient.addColorStop(+stop, colors[+stop]);\n }\n\n ctx.fillStyle = gradient;\n ctx.fillRect(0, 0, 256, 1);\n\n // @ts-ignore dispose canvas element\n canvas = null;\n\n return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);\n}\n\nfunction bindAttribute(\n gl: WebGLRenderingContext,\n buffer: any,\n attribute: any,\n numComponents: any,\n) {\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.enableVertexAttribArray(attribute);\n gl.vertexAttribPointer(attribute, numComponents, gl.FLOAT, false, 0, 0);\n}\n\nfunction bindFramebuffer(\n gl: WebGLRenderingContext,\n framebuffer: any,\n texture: any,\n) {\n gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);\n if (texture) {\n gl.framebufferTexture2D(\n gl.FRAMEBUFFER,\n gl.COLOR_ATTACHMENT0,\n gl.TEXTURE_2D,\n texture,\n 0,\n );\n }\n}\n\nexport interface IWindData {\n uMin: number;\n uMax: number;\n vMin: number;\n vMax: number;\n image: HTMLImageElement;\n}\n\nexport interface IWind {\n width: number;\n height: number;\n\n fadeOpacity: number;\n speedFactor: number;\n dropRate: number;\n dropRateBump: number;\n\n setWind: (windData: IWindData) => void;\n draw: () => { d: Uint8Array; w: number; h: number };\n updateParticelNum: (num: number) => void;\n updateWindDir: (\n uMin: number,\n uMax: number,\n vMin: number,\n vMax: number,\n ) => void;\n updateColorRampTexture: (rampColors: { [key: number]: string }) => void;\n\n reSize: (width: number, height: number) => void;\n destroy: () => void;\n}\n\nexport interface IWindProps {\n glContext: WebGLRenderingContext;\n imageWidth: number;\n imageHeight: number;\n fadeOpacity: number;\n speedFactor: number;\n dropRate: number;\n dropRateBump: number;\n rampColors: { [key: number]: string };\n}\n\nexport class Wind {\n public width: number = 512;\n public height: number = 512;\n\n public pixels: Uint8Array;\n\n public fadeOpacity: number;\n public speedFactor: number;\n public dropRate: number;\n public dropRateBump: number;\n private gl: WebGLRenderingContext;\n private drawProgram: WebGLProgram;\n private fullScreenProgram: WebGLProgram;\n private updateProgram: WebGLProgram;\n\n private rampColors: { [key: number]: string };\n\n private numParticles: number = 65536;\n private numParticlesSize: number;\n private particleStateResolution: number;\n\n private quadBuffer: WebGLBuffer | null;\n private particleIndexBuffer: WebGLBuffer | null;\n\n private framebuffer: WebGLFramebuffer | null;\n\n private colorRampTexture: WebGLTexture | null;\n private backgroundTexture: WebGLTexture | null;\n private screenTexture: WebGLTexture | null;\n private particleStateTexture0: WebGLTexture | null;\n private particleStateTexture1: WebGLTexture | null;\n private windTexture: WebGLTexture | null;\n\n private windData: IWindData;\n\n constructor(options: IWindProps) {\n this.gl = options.glContext;\n this.width = options.imageWidth;\n this.height = options.imageHeight;\n this.fadeOpacity = options.fadeOpacity;\n this.speedFactor = options.speedFactor;\n this.dropRate = options.dropRate;\n this.dropRateBump = options.dropRateBump;\n\n this.rampColors = options.rampColors;\n this.init();\n }\n\n public init() {\n const gl = this.gl;\n\n this.fadeOpacity = 0.996; // how fast the particle trails fade on each frame\n this.speedFactor = 0.25; // how fast the particles move\n this.dropRate = 0.003; // how often the particles move to a random place\n this.dropRateBump = 0.01; // drop rate increase relative to individual particle speed\n\n this.drawProgram = glUtils.createProgram(gl, drawVert, drawFrag);\n this.fullScreenProgram = glUtils.createProgram(\n gl,\n fullScreenVert,\n fullScreenFrag,\n );\n this.updateProgram = glUtils.createProgram(gl, updateVert, updateFrag);\n\n this.quadBuffer = glUtils.createBuffer(\n gl,\n new Float32Array([0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]),\n );\n\n this.framebuffer = gl.createFramebuffer();\n\n this.colorRampTexture = glUtils.createTexture(\n this.gl,\n this.gl.LINEAR,\n getColorRamp(this.rampColors),\n 16,\n 16,\n );\n\n const emptyPixels = new Uint8Array(this.width * this.height * 4);\n\n // screen textures to hold the drawn screen for the previous and the current frame\n\n this.backgroundTexture = glUtils.createTexture(\n gl,\n gl.NEAREST,\n emptyPixels,\n this.width,\n this.height,\n );\n this.screenTexture = glUtils.createTexture(\n gl,\n gl.NEAREST,\n emptyPixels,\n this.width,\n this.height,\n );\n\n // we create a square texture where each pixel will hold a particle position encoded as RGBA\n const particleRes = (this.particleStateResolution = Math.ceil(\n Math.sqrt(this.numParticles),\n ));\n // particleRes size\n this.numParticlesSize = particleRes * particleRes;\n\n const particleState = new Uint8Array(this.numParticlesSize * 4);\n for (let i = 0; i < particleState.length; i++) {\n particleState[i] = Math.floor(Math.random() * 256); // randomize the initial particle positions\n }\n // textures to hold the particle state for the current and the next frame\n this.particleStateTexture0 = glUtils.createTexture(\n gl,\n gl.NEAREST,\n particleState,\n particleRes,\n particleRes,\n );\n this.particleStateTexture1 = glUtils.createTexture(\n gl,\n gl.NEAREST,\n particleState,\n particleRes,\n particleRes,\n );\n\n const particleIndices = new Float32Array(this.numParticlesSize);\n for (let i$1 = 0; i$1 < this.numParticlesSize; i$1++) {\n particleIndices[i$1] = i$1;\n }\n this.particleIndexBuffer = glUtils.createBuffer(gl, particleIndices);\n }\n\n public setWind(windData: IWindData) {\n this.windData = windData;\n this.windTexture = glUtils.createDataTexture(\n this.gl,\n this.gl.LINEAR,\n windData.image,\n );\n }\n\n /**\n * 更新风场粒子数量\n * @param num\n */\n public updateParticelNum(num: number) {\n const gl = this.gl;\n if (num !== this.numParticles) {\n this.numParticles = num; // params number\n\n // we create a square texture where each pixel will hold a particle position encoded as RGBA\n const particleRes = (this.particleStateResolution = Math.ceil(\n Math.sqrt(this.numParticles),\n ));\n this.numParticlesSize = particleRes * particleRes;\n\n const particleState = new Uint8Array(this.numParticlesSize * 4);\n for (let i = 0; i < particleState.length; i++) {\n particleState[i] = Math.floor(Math.random() * 256); // randomize the initial particle positions\n }\n // textures to hold the particle state for the current and the next frame\n this.particleStateTexture0 = glUtils.createTexture(\n gl,\n gl.NEAREST,\n particleState,\n particleRes,\n particleRes,\n );\n this.particleStateTexture1 = glUtils.createTexture(\n gl,\n gl.NEAREST,\n particleState,\n particleRes,\n particleRes,\n );\n\n const particleIndices = new Float32Array(this.numParticlesSize);\n for (let i$1 = 0; i$1 < this.numParticlesSize; i$1++) {\n particleIndices[i$1] = i$1;\n }\n this.particleIndexBuffer = glUtils.createBuffer(gl, particleIndices);\n }\n }\n\n /**\n * 更新风场风向风速\n * @param uMin\n * @param uMax\n * @param vMin\n * @param vMax\n */\n public updateWindDir(uMin: number, uMax: number, vMin: number, vMax: number) {\n this.windData.uMin = uMin;\n this.windData.uMax = uMax;\n this.windData.vMin = vMin;\n this.windData.vMax = vMax;\n }\n\n /**\n * update rampColors\n * @param rampColors\n */\n public updateColorRampTexture(rampColors: { [key: number]: string }) {\n if (this.isColorChanged(rampColors)) {\n this.rampColors = rampColors;\n\n const gl = this.gl;\n gl.deleteTexture(this.colorRampTexture);\n this.colorRampTexture = glUtils.createTexture(\n gl,\n gl.LINEAR,\n getColorRamp(rampColors),\n 16,\n 16,\n );\n }\n }\n\n public isColorChanged(rampColors: { [key: number]: string }): boolean {\n const keys = Object.keys(rampColors);\n for (const item of keys) {\n const key = Number(item);\n // exist new key -> color need update\n if (!this.rampColors[key]) {\n return true;\n }\n // value changed -> color need update\n if (this.rampColors[key] && this.rampColors[key] !== rampColors[key]) {\n return true;\n }\n }\n return false;\n }\n\n public reSize(width: number, height: number) {\n if (width !== this.width || height !== this.height) {\n const gl = this.gl;\n gl.deleteTexture(this.backgroundTexture);\n gl.deleteTexture(this.screenTexture);\n\n this.width = width;\n this.height = height;\n const emptyPixels = new Uint8Array(width * height * 4);\n // screen textures to hold the drawn screen for the previous and the current frame\n this.backgroundTexture = glUtils.createTexture(\n gl,\n gl.NEAREST,\n emptyPixels,\n width,\n height,\n );\n this.screenTexture = glUtils.createTexture(\n gl,\n gl.NEAREST,\n emptyPixels,\n width,\n height,\n );\n }\n }\n\n public draw() {\n if (this.windData?.image) {\n const gl = this.gl;\n\n glUtils.bindTexture(gl, this.windTexture, 0);\n glUtils.bindTexture(gl, this.particleStateTexture0, 1);\n\n this.drawScreen(); // draw Particles into framebuffer\n this.updateParticles();\n\n return { d: this.pixels, w: this.width, h: this.height };\n } else {\n return { d: new Uint8Array([0, 0, 0, 0]), w: 1, h: 1 };\n }\n }\n\n public drawScreen() {\n const gl = this.gl;\n\n // draw the screen into a temporary framebuffer to retain it as the background on the next frame\n bindFramebuffer(gl, this.framebuffer, this.screenTexture);\n\n gl.viewport(0, 0, this.width, this.height);\n\n this.drawFullTexture(this.backgroundTexture, this.fadeOpacity);\n this.drawParticles();\n\n gl.disable(gl.BLEND);\n\n this.pixels = new Uint8Array(4 * this.width * this.height);\n gl.readPixels(\n 0,\n 0,\n this.width,\n this.height,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n this.pixels,\n );\n\n bindFramebuffer(gl, null, null);\n gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);\n\n // save the current screen as the background for the next frame\n const temp = this.backgroundTexture;\n this.backgroundTexture = this.screenTexture;\n this.screenTexture = temp;\n }\n\n public drawFullTexture(texture: any, opacity: number) {\n const gl = this.gl;\n const program = this.fullScreenProgram as any;\n gl.useProgram(program);\n\n // bindAttribute(gl, this.quadBuffer, program.a_pos, 2);\n\n gl.bindBuffer(gl.ARRAY_BUFFER, this.quadBuffer);\n gl.vertexAttribPointer(program.a_pos, 2, gl.FLOAT, false, 0, 0);\n gl.enableVertexAttribArray(program.a_pos);\n\n gl.bindBuffer(gl.ARRAY_BUFFER, null);\n\n glUtils.bindTexture(gl, texture, 2);\n gl.uniform1i(program.u_screen, 2);\n gl.uniform1f(program.u_opacity, opacity);\n\n gl.drawArrays(gl.TRIANGLES, 0, 6);\n // gl.drawArrays(gl.POINTS, 0, 6);\n }\n\n public drawParticles() {\n const gl = this.gl;\n const program = this.drawProgram as any;\n gl.useProgram(program);\n\n bindAttribute(gl, this.particleIndexBuffer, program.a_index, 1);\n glUtils.bindTexture(gl, this.colorRampTexture, 2);\n\n gl.uniform1i(program.u_wind, 0);\n gl.uniform1i(program.u_particles, 1);\n gl.uniform1i(program.u_color_ramp, 2);\n\n gl.uniform1f(program.u_particles_res, this.particleStateResolution);\n gl.uniform2f(program.u_wind_min, this.windData.uMin, this.windData.vMin);\n gl.uniform2f(program.u_wind_max, this.windData.uMax, this.windData.vMax);\n\n gl.drawArrays(gl.POINTS, 0, this.numParticlesSize);\n }\n\n public updateParticles() {\n const gl = this.gl;\n bindFramebuffer(gl, this.framebuffer, this.particleStateTexture1);\n gl.viewport(\n 0,\n 0,\n this.particleStateResolution,\n this.particleStateResolution,\n );\n\n const program = this.updateProgram as any;\n gl.useProgram(program);\n\n bindAttribute(gl, this.quadBuffer, program.a_pos, 2);\n\n gl.uniform1i(program.u_wind, 0);\n gl.uniform1i(program.u_particles, 1);\n\n gl.uniform1f(program.u_rand_seed, Math.random());\n gl.uniform2f(\n program.u_wind_res,\n this.windData.image.width * 2,\n this.windData.image.height * 2,\n );\n gl.uniform2f(program.u_wind_min, this.windData.uMin, this.windData.vMin);\n gl.uniform2f(program.u_wind_max, this.windData.uMax, this.windData.vMax);\n gl.uniform1f(program.u_speed_factor, this.speedFactor);\n gl.uniform1f(program.u_drop_rate, this.dropRate);\n gl.uniform1f(program.u_drop_rate_bump, this.dropRateBump);\n\n gl.drawArrays(gl.TRIANGLES, 0, 6);\n\n // swap the particle state textures so the new one becomes the current one\n const temp = this.particleStateTexture0;\n this.particleStateTexture0 = this.particleStateTexture1;\n this.particleStateTexture1 = temp;\n\n bindFramebuffer(gl, null, null);\n\n // gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);\n }\n\n public destroy() {\n // private drawProgram: WebGLProgram;\n // private fullScreenProgram: WebGLProgram;\n // private updateProgram: WebGLProgram;\n\n // private quadBuffer: WebGLBuffer | null;\n // private particleIndexBuffer: WebGLBuffer | null;\n\n // private framebuffer: WebGLFramebuffer | null;\n\n // private colorRampTexture: WebGLTexture | null;\n // private backgroundTexture: WebGLTexture | null;\n // private screenTexture: WebGLTexture | null;\n // private particleStateTexture0: WebGLTexture | null;\n // private particleStateTexture1: WebGLTexture | null;\n // private windTexture: WebGLTexture | null;\n\n this.gl.deleteBuffer(this.quadBuffer);\n this.gl.deleteBuffer(this.particleIndexBuffer);\n\n this.gl.deleteFramebuffer(this.framebuffer);\n\n // @ts-ignore\n this.gl.deleteShader(this.drawProgram.vertexShader);\n // @ts-ignore\n this.gl.deleteShader(this.drawProgram.fragmentShader);\n this.gl.deleteProgram(this.drawProgram);\n\n // @ts-ignore\n this.gl.deleteShader(this.fullScreenProgram.vertexShader);\n // @ts-ignore\n this.gl.deleteShader(this.fullScreenProgram.fragmentShader);\n this.gl.deleteProgram(this.fullScreenProgram);\n\n // @ts-ignore\n this.gl.deleteShader(this.updateProgram.vertexShader);\n // @ts-ignore\n this.gl.deleteShader(this.updateProgram.fragmentShader);\n this.gl.deleteProgram(this.updateProgram);\n\n this.gl.deleteTexture(this.colorRampTexture);\n this.gl.deleteTexture(this.backgroundTexture);\n this.gl.deleteTexture(this.screenTexture);\n this.gl.deleteTexture(this.particleStateTexture0);\n this.gl.deleteTexture(this.particleStateTexture1);\n this.gl.deleteTexture(this.windTexture);\n }\n}\n"],"file":"windRender.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/wind/models/windRender.ts"],"names":["glUtils","drawFrag","drawVert","fullScreenFrag","fullScreenVert","updateFrag","updateVert","getColorRamp","colors","canvas","document","createElement","ctx","getContext","width","height","gradient","createLinearGradient","Object","keys","stop","addColorStop","fillStyle","fillRect","Uint8Array","getImageData","data","bindAttribute","gl","buffer","attribute","numComponents","bindBuffer","ARRAY_BUFFER","enableVertexAttribArray","vertexAttribPointer","FLOAT","bindFramebuffer","framebuffer","texture","FRAMEBUFFER","framebufferTexture2D","COLOR_ATTACHMENT0","TEXTURE_2D","Wind","options","glContext","imageWidth","imageHeight","fadeOpacity","speedFactor","dropRate","dropRateBump","rampColors","init","drawProgram","createProgram","fullScreenProgram","updateProgram","quadBuffer","createBuffer","Float32Array","createFramebuffer","colorRampTexture","createTexture","LINEAR","emptyPixels","backgroundTexture","NEAREST","screenTexture","particleRes","particleStateResolution","Math","ceil","sqrt","numParticles","numParticlesSize","particleState","i","length","floor","random","particleStateTexture0","particleStateTexture1","particleIndices","i$1","particleIndexBuffer","windData","windTexture","createDataTexture","image","num","uMin","uMax","vMin","vMax","isColorChanged","deleteTexture","item","key","Number","bindTexture","drawScreen","updateParticles","d","pixels","w","h","viewport","drawFullTexture","drawParticles","disable","BLEND","readPixels","RGBA","UNSIGNED_BYTE","temp","opacity","program","useProgram","a_pos","uniform1i","u_screen","uniform1f","u_opacity","drawArrays","TRIANGLES","a_index","u_wind","u_particles","u_color_ramp","u_particles_res","uniform2f","u_wind_min","u_wind_max","POINTS","u_rand_seed","u_wind_res","u_speed_factor","u_drop_rate","u_drop_rate_bump","deleteBuffer","deleteFramebuffer","deleteShader","vertexShader","fragmentShader","deleteProgram"],"mappings":";;;AAAA,OAAO,KAAKA,OAAZ,MAAyB,SAAzB;AACA,SACEC,QADF,EAEEC,QAFF,EAGEC,cAHF,EAIEC,cAJF,EAKEC,UALF,EAMEC,UANF,QAOO,cAPP;;AASA,SAASC,YAAT,CAAsBC,MAAtB,EAAyD;AACvD,MAAIC,MAAM,GAAG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ader';\n\nfunction getColorRamp(colors: { [key: number]: string }) {\n let canvas = document.createElement('canvas') as HTMLCanvasElement;\n const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;\n\n canvas.width = 256;\n canvas.height = 1;\n\n const gradient = ctx.createLinearGradient(0, 0, 256, 0);\n for (const stop of Object.keys(colors)) {\n gradient.addColorStop(+stop, colors[+stop]);\n }\n\n ctx.fillStyle = gradient;\n ctx.fillRect(0, 0, 256, 1);\n\n // @ts-ignore dispose canvas element\n canvas = null;\n\n return new Uint8Array(ctx.getImageData(0, 0, 256, 1).data);\n}\n\nfunction bindAttribute(\n gl: WebGLRenderingContext,\n buffer: any,\n attribute: any,\n numComponents: any,\n) {\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n gl.enableVertexAttribArray(attribute);\n gl.vertexAttribPointer(attribute, numComponents, gl.FLOAT, false, 0, 0);\n}\n\nfunction bindFramebuffer(\n gl: WebGLRenderingContext,\n framebuffer: any,\n texture: any,\n) {\n gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);\n if (texture) {\n gl.framebufferTexture2D(\n gl.FRAMEBUFFER,\n gl.COLOR_ATTACHMENT0,\n gl.TEXTURE_2D,\n texture,\n 0,\n );\n }\n}\n\nexport interface IWindData {\n uMin: number;\n uMax: number;\n vMin: number;\n vMax: number;\n image: HTMLImageElement;\n}\n\nexport interface IWind {\n width: number;\n height: number;\n\n fadeOpacity: number;\n speedFactor: number;\n dropRate: number;\n dropRateBump: number;\n\n setWind: (windData: IWindData) => void;\n draw: () => { d: Uint8Array; w: number; h: number };\n updateParticelNum: (num: number) => void;\n updateWindDir: (\n uMin: number,\n uMax: number,\n vMin: number,\n vMax: number,\n ) => void;\n updateColorRampTexture: (rampColors: { [key: number]: string }) => void;\n\n reSize: (width: number, height: number) => void;\n destroy: () => void;\n}\n\nexport interface IWindProps {\n glContext: WebGLRenderingContext;\n imageWidth: number;\n imageHeight: number;\n fadeOpacity: number;\n speedFactor: number;\n dropRate: number;\n dropRateBump: number;\n rampColors: { [key: number]: string };\n}\n\nexport class Wind {\n public width: number = 512;\n public height: number = 512;\n\n public pixels: Uint8Array;\n\n public fadeOpacity: number;\n public speedFactor: number;\n public dropRate: number;\n public dropRateBump: number;\n private gl: WebGLRenderingContext;\n private drawProgram: WebGLProgram;\n private fullScreenProgram: WebGLProgram;\n private updateProgram: WebGLProgram;\n\n private rampColors: { [key: number]: string };\n\n private numParticles: number = 65536;\n private numParticlesSize: number;\n private particleStateResolution: number;\n\n private quadBuffer: WebGLBuffer | null;\n private particleIndexBuffer: WebGLBuffer | null;\n\n private framebuffer: WebGLFramebuffer | null;\n\n private colorRampTexture: WebGLTexture | null;\n private backgroundTexture: WebGLTexture | null;\n private screenTexture: WebGLTexture | null;\n private particleStateTexture0: WebGLTexture | null;\n private particleStateTexture1: WebGLTexture | null;\n private windTexture: WebGLTexture | null;\n\n private windData: IWindData;\n\n constructor(options: IWindProps) {\n this.gl = options.glContext;\n this.width = options.imageWidth;\n this.height = options.imageHeight;\n this.fadeOpacity = options.fadeOpacity;\n this.speedFactor = options.speedFactor;\n this.dropRate = options.dropRate;\n this.dropRateBump = options.dropRateBump;\n\n this.rampColors = options.rampColors;\n this.init();\n }\n\n public init() {\n const gl = this.gl;\n\n this.fadeOpacity = 0.996; // how fast the particle trails fade on each frame\n this.speedFactor = 0.25; // how fast the particles move\n this.dropRate = 0.003; // how often the particles move to a random place\n this.dropRateBump = 0.01; // drop rate increase relative to individual particle speed\n\n this.drawProgram = glUtils.createProgram(\n gl,\n drawVert,\n drawFrag,\n ) as WebGLProgram;\n this.fullScreenProgram = glUtils.createProgram(\n gl,\n fullScreenVert,\n fullScreenFrag,\n ) as WebGLProgram;\n this.updateProgram = glUtils.createProgram(\n gl,\n updateVert,\n updateFrag,\n ) as WebGLProgram;\n\n this.quadBuffer = glUtils.createBuffer(\n gl,\n new Float32Array([0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]),\n );\n\n this.framebuffer = gl.createFramebuffer();\n\n this.colorRampTexture = glUtils.createTexture(\n this.gl,\n this.gl.LINEAR,\n getColorRamp(this.rampColors),\n 16,\n 16,\n );\n\n const emptyPixels = new Uint8Array(this.width * this.height * 4);\n\n // screen textures to hold the drawn screen for the previous and the current frame\n\n this.backgroundTexture = glUtils.createTexture(\n gl,\n gl.NEAREST,\n emptyPixels,\n this.width,\n this.height,\n );\n this.screenTexture = glUtils.createTexture(\n gl,\n gl.NEAREST,\n emptyPixels,\n this.width,\n this.height,\n );\n\n // we create a square texture where each pixel will hold a particle position encoded as RGBA\n const particleRes = (this.particleStateResolution = Math.ceil(\n Math.sqrt(this.numParticles),\n ));\n // particleRes size\n this.numParticlesSize = particleRes * particleRes;\n\n const particleState = new Uint8Array(this.numParticlesSize * 4);\n for (let i = 0; i < particleState.length; i++) {\n particleState[i] = Math.floor(Math.random() * 256); // randomize the initial particle positions\n }\n // textures to hold the particle state for the current and the next frame\n this.particleStateTexture0 = glUtils.createTexture(\n gl,\n gl.NEAREST,\n particleState,\n particleRes,\n particleRes,\n );\n this.particleStateTexture1 = glUtils.createTexture(\n gl,\n gl.NEAREST,\n particleState,\n particleRes,\n particleRes,\n );\n\n const particleIndices = new Float32Array(this.numParticlesSize);\n for (let i$1 = 0; i$1 < this.numParticlesSize; i$1++) {\n particleIndices[i$1] = i$1;\n }\n this.particleIndexBuffer = glUtils.createBuffer(gl, particleIndices);\n }\n\n public setWind(windData: IWindData) {\n this.windData = windData;\n this.windTexture = glUtils.createDataTexture(\n this.gl,\n this.gl.LINEAR,\n windData.image,\n );\n }\n\n /**\n * 更新风场粒子数量\n * @param num\n */\n public updateParticelNum(num: number) {\n const gl = this.gl;\n if (num !== this.numParticles) {\n this.numParticles = num; // params number\n\n // we create a square texture where each pixel will hold a particle position encoded as RGBA\n const particleRes = (this.particleStateResolution = Math.ceil(\n Math.sqrt(this.numParticles),\n ));\n this.numParticlesSize = particleRes * particleRes;\n\n const particleState = new Uint8Array(this.numParticlesSize * 4);\n for (let i = 0; i < particleState.length; i++) {\n particleState[i] = Math.floor(Math.random() * 256); // randomize the initial particle positions\n }\n // textures to hold the particle state for the current and the next frame\n this.particleStateTexture0 = glUtils.createTexture(\n gl,\n gl.NEAREST,\n particleState,\n particleRes,\n particleRes,\n );\n this.particleStateTexture1 = glUtils.createTexture(\n gl,\n gl.NEAREST,\n particleState,\n particleRes,\n particleRes,\n );\n\n const particleIndices = new Float32Array(this.numParticlesSize);\n for (let i$1 = 0; i$1 < this.numParticlesSize; i$1++) {\n particleIndices[i$1] = i$1;\n }\n this.particleIndexBuffer = glUtils.createBuffer(gl, particleIndices);\n }\n }\n\n /**\n * 更新风场风向风速\n * @param uMin\n * @param uMax\n * @param vMin\n * @param vMax\n */\n public updateWindDir(uMin: number, uMax: number, vMin: number, vMax: number) {\n this.windData.uMin = uMin;\n this.windData.uMax = uMax;\n this.windData.vMin = vMin;\n this.windData.vMax = vMax;\n }\n\n /**\n * update rampColors\n * @param rampColors\n */\n public updateColorRampTexture(rampColors: { [key: number]: string }) {\n if (this.isColorChanged(rampColors)) {\n this.rampColors = rampColors;\n\n const gl = this.gl;\n gl.deleteTexture(this.colorRampTexture);\n this.colorRampTexture = glUtils.createTexture(\n gl,\n gl.LINEAR,\n getColorRamp(rampColors),\n 16,\n 16,\n );\n }\n }\n\n public isColorChanged(rampColors: { [key: number]: string }): boolean {\n const keys = Object.keys(rampColors);\n for (const item of keys) {\n const key = Number(item);\n // exist new key -> color need update\n if (!this.rampColors[key]) {\n return true;\n }\n // value changed -> color need update\n if (this.rampColors[key] && this.rampColors[key] !== rampColors[key]) {\n return true;\n }\n }\n return false;\n }\n\n public reSize(width: number, height: number) {\n if (width !== this.width || height !== this.height) {\n const gl = this.gl;\n gl.deleteTexture(this.backgroundTexture);\n gl.deleteTexture(this.screenTexture);\n\n this.width = width;\n this.height = height;\n const emptyPixels = new Uint8Array(width * height * 4);\n // screen textures to hold the drawn screen for the previous and the current frame\n this.backgroundTexture = glUtils.createTexture(\n gl,\n gl.NEAREST,\n emptyPixels,\n width,\n height,\n );\n this.screenTexture = glUtils.createTexture(\n gl,\n gl.NEAREST,\n emptyPixels,\n width,\n height,\n );\n }\n }\n\n public draw() {\n if (this.windData?.image) {\n const gl = this.gl;\n\n glUtils.bindTexture(gl, this.windTexture as WebGLTexture, 0);\n glUtils.bindTexture(gl, this.particleStateTexture0 as WebGLTexture, 1);\n\n this.drawScreen(); // draw Particles into framebuffer\n this.updateParticles();\n\n return { d: this.pixels, w: this.width, h: this.height };\n } else {\n return { d: new Uint8Array([0, 0, 0, 0]), w: 1, h: 1 };\n }\n }\n\n public drawScreen() {\n const gl = this.gl;\n\n // draw the screen into a temporary framebuffer to retain it as the background on the next frame\n bindFramebuffer(gl, this.framebuffer, this.screenTexture);\n\n gl.viewport(0, 0, this.width, this.height);\n\n this.drawFullTexture(this.backgroundTexture, this.fadeOpacity);\n this.drawParticles();\n\n gl.disable(gl.BLEND);\n\n this.pixels = new Uint8Array(4 * this.width * this.height);\n gl.readPixels(\n 0,\n 0,\n this.width,\n this.height,\n gl.RGBA,\n gl.UNSIGNED_BYTE,\n this.pixels,\n );\n\n bindFramebuffer(gl, null, null);\n gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);\n\n // save the current screen as the background for the next frame\n const temp = this.backgroundTexture;\n this.backgroundTexture = this.screenTexture;\n this.screenTexture = temp;\n }\n\n public drawFullTexture(texture: any, opacity: number) {\n const gl = this.gl;\n const program = this.fullScreenProgram as any;\n gl.useProgram(program);\n\n // bindAttribute(gl, this.quadBuffer, program.a_pos, 2);\n\n gl.bindBuffer(gl.ARRAY_BUFFER, this.quadBuffer);\n gl.vertexAttribPointer(program.a_pos, 2, gl.FLOAT, false, 0, 0);\n gl.enableVertexAttribArray(program.a_pos);\n\n gl.bindBuffer(gl.ARRAY_BUFFER, null);\n\n glUtils.bindTexture(gl, texture, 2);\n gl.uniform1i(program.u_screen, 2);\n gl.uniform1f(program.u_opacity, opacity);\n\n gl.drawArrays(gl.TRIANGLES, 0, 6);\n // gl.drawArrays(gl.POINTS, 0, 6);\n }\n\n public drawParticles() {\n const gl = this.gl;\n const program = this.drawProgram as any;\n gl.useProgram(program);\n\n bindAttribute(gl, this.particleIndexBuffer, program.a_index, 1);\n glUtils.bindTexture(gl, this.colorRampTexture as WebGLTexture, 2);\n\n gl.uniform1i(program.u_wind, 0);\n gl.uniform1i(program.u_particles, 1);\n gl.uniform1i(program.u_color_ramp, 2);\n\n gl.uniform1f(program.u_particles_res, this.particleStateResolution);\n gl.uniform2f(program.u_wind_min, this.windData.uMin, this.windData.vMin);\n gl.uniform2f(program.u_wind_max, this.windData.uMax, this.windData.vMax);\n\n gl.drawArrays(gl.POINTS, 0, this.numParticlesSize);\n }\n\n public updateParticles() {\n const gl = this.gl;\n bindFramebuffer(gl, this.framebuffer, this.particleStateTexture1);\n gl.viewport(\n 0,\n 0,\n this.particleStateResolution,\n this.particleStateResolution,\n );\n\n const program = this.updateProgram as any;\n gl.useProgram(program);\n\n bindAttribute(gl, this.quadBuffer, program.a_pos, 2);\n\n gl.uniform1i(program.u_wind, 0);\n gl.uniform1i(program.u_particles, 1);\n\n gl.uniform1f(program.u_rand_seed, Math.random());\n gl.uniform2f(\n program.u_wind_res,\n this.windData.image.width * 2,\n this.windData.image.height * 2,\n );\n gl.uniform2f(program.u_wind_min, this.windData.uMin, this.windData.vMin);\n gl.uniform2f(program.u_wind_max, this.windData.uMax, this.windData.vMax);\n gl.uniform1f(program.u_speed_factor, this.speedFactor);\n gl.uniform1f(program.u_drop_rate, this.dropRate);\n gl.uniform1f(program.u_drop_rate_bump, this.dropRateBump);\n\n gl.drawArrays(gl.TRIANGLES, 0, 6);\n\n // swap the particle state textures so the new one becomes the current one\n const temp = this.particleStateTexture0;\n this.particleStateTexture0 = this.particleStateTexture1;\n this.particleStateTexture1 = temp;\n\n bindFramebuffer(gl, null, null);\n\n // gl.viewport(0, 0, this.gl.canvas.width, this.gl.canvas.height);\n }\n\n public destroy() {\n // private drawProgram: WebGLProgram;\n // private fullScreenProgram: WebGLProgram;\n // private updateProgram: WebGLProgram;\n\n // private quadBuffer: WebGLBuffer | null;\n // private particleIndexBuffer: WebGLBuffer | null;\n\n // private framebuffer: WebGLFramebuffer | null;\n\n // private colorRampTexture: WebGLTexture | null;\n // private backgroundTexture: WebGLTexture | null;\n // private screenTexture: WebGLTexture | null;\n // private particleStateTexture0: WebGLTexture | null;\n // private particleStateTexture1: WebGLTexture | null;\n // private windTexture: WebGLTexture | null;\n\n this.gl.deleteBuffer(this.quadBuffer);\n this.gl.deleteBuffer(this.particleIndexBuffer);\n\n this.gl.deleteFramebuffer(this.framebuffer);\n\n // @ts-ignore\n this.gl.deleteShader(this.drawProgram.vertexShader);\n // @ts-ignore\n this.gl.deleteShader(this.drawProgram.fragmentShader);\n this.gl.deleteProgram(this.drawProgram);\n\n // @ts-ignore\n this.gl.deleteShader(this.fullScreenProgram.vertexShader);\n // @ts-ignore\n this.gl.deleteShader(this.fullScreenProgram.fragmentShader);\n this.gl.deleteProgram(this.fullScreenProgram);\n\n // @ts-ignore\n this.gl.deleteShader(this.updateProgram.vertexShader);\n // @ts-ignore\n this.gl.deleteShader(this.updateProgram.fragmentShader);\n this.gl.deleteProgram(this.updateProgram);\n\n this.gl.deleteTexture(this.colorRampTexture);\n this.gl.deleteTexture(this.backgroundTexture);\n this.gl.deleteTexture(this.screenTexture);\n this.gl.deleteTexture(this.particleStateTexture0);\n this.gl.deleteTexture(this.particleStateTexture1);\n this.gl.deleteTexture(this.windTexture);\n }\n}\n"],"file":"windRender.js"}
|
package/lib/Geometry/index.js
CHANGED
|
@@ -79,7 +79,8 @@ var GeometryLayer = function (_BaseLayer) {
|
|
|
79
79
|
var type = this.getModelType();
|
|
80
80
|
var defaultConfig = {
|
|
81
81
|
plane: {},
|
|
82
|
-
sprite: {}
|
|
82
|
+
sprite: {},
|
|
83
|
+
billboard: {}
|
|
83
84
|
};
|
|
84
85
|
return defaultConfig[type];
|
|
85
86
|
}
|
|
@@ -95,6 +96,8 @@ var GeometryLayer = function (_BaseLayer) {
|
|
|
95
96
|
return 'plane';
|
|
96
97
|
} else if (shape === 'sprite') {
|
|
97
98
|
return 'sprite';
|
|
99
|
+
} else if (shape === 'billboard') {
|
|
100
|
+
return 'billboard';
|
|
98
101
|
} else {
|
|
99
102
|
return 'plane';
|
|
100
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Geometry/index.ts"],"names":["GeometryLayer","modelType","getModelType","layerModel","GeometryModels","models","initModels","buildModels","properties","opacity","type","minimum","maximum","defaultConfig","plane","sprite","shapeAttribute","styleAttributeService","getLayerStyleAttribute","shape","scale","field","BaseLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;;;;;IAEqBA,a;;;;;;;;;;;;;;;uFAGG,e;;;;;;WACtB,uBAAqB;AACnB,UAAMC,SAAS,GAAG,KAAKC,YAAL,EAAlB;AACA,WAAKC,UAAL,GAAkB,IAAIC,gBAAeH,SAAf,CAAJ,CAA8B,IAA9B,CAAlB;AACA,WAAKI,MAAL,GAAc,KAAKF,UAAL,CAAgBG,UAAhB,EAAd;AACD;;;WACD,yBAAuB;AACrB,WAAKD,MAAL,GAAc,KAAKF,UAAL,CAAgBI,WAAhB,EAAd;AACD;;;WAED,2BAA4B;AAC1B,aAAO;AACLC,QAAAA,UAAU,EAAE;AACVC,UAAAA,OAAO,EAAE;AACPC,YAAAA,IAAI,EAAE,QADC;AAEPC,YAAAA,OAAO,EAAE,CAFF;AAGPC,YAAAA,OAAO,EAAE;AAHF;AADC;AADP,OAAP;AASD;;;WACD,4BAA6B;AAC3B,UAAMF,IAAI,GAAG,KAAKR,YAAL,EAAb;AACA,UAAMW,aAAa,GAAG;AACpBC,QAAAA,KAAK,EAAE,EADa;AAEpBC,QAAAA,MAAM,EAAE;
|
|
1
|
+
{"version":3,"sources":["../../src/Geometry/index.ts"],"names":["GeometryLayer","modelType","getModelType","layerModel","GeometryModels","models","initModels","buildModels","properties","opacity","type","minimum","maximum","defaultConfig","plane","sprite","billboard","shapeAttribute","styleAttributeService","getLayerStyleAttribute","shape","scale","field","BaseLayer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;;;;;IAEqBA,a;;;;;;;;;;;;;;;uFAGG,e;;;;;;WACtB,uBAAqB;AACnB,UAAMC,SAAS,GAAG,KAAKC,YAAL,EAAlB;AACA,WAAKC,UAAL,GAAkB,IAAIC,gBAAeH,SAAf,CAAJ,CAA8B,IAA9B,CAAlB;AACA,WAAKI,MAAL,GAAc,KAAKF,UAAL,CAAgBG,UAAhB,EAAd;AACD;;;WACD,yBAAuB;AACrB,WAAKD,MAAL,GAAc,KAAKF,UAAL,CAAgBI,WAAhB,EAAd;AACD;;;WAED,2BAA4B;AAC1B,aAAO;AACLC,QAAAA,UAAU,EAAE;AACVC,UAAAA,OAAO,EAAE;AACPC,YAAAA,IAAI,EAAE,QADC;AAEPC,YAAAA,OAAO,EAAE,CAFF;AAGPC,YAAAA,OAAO,EAAE;AAHF;AADC;AADP,OAAP;AASD;;;WACD,4BAA6B;AAC3B,UAAMF,IAAI,GAAG,KAAKR,YAAL,EAAb;AACA,UAAMW,aAAa,GAAG;AACpBC,QAAAA,KAAK,EAAE,EADa;AAEpBC,QAAAA,MAAM,EAAE,EAFY;AAGpBC,QAAAA,SAAS,EAAE;AAHS,OAAtB;AAKA,aAAOH,aAAa,CAACH,IAAD,CAApB;AACD;;;WAED,wBAA4C;AAAA;;AAC1C,UAAMO,cAAc,GAAG,KAAKC,qBAAL,CAA2BC,sBAA3B,CACrB,OADqB,CAAvB;AAGA,UAAMC,KAAK,GAAGH,cAAH,aAAGA,cAAH,gDAAGA,cAAc,CAAEI,KAAnB,0DAAG,sBAAuBC,KAArC;;AACA,UAAIF,KAAK,KAAK,OAAd,EAAuB;AACrB,eAAO,OAAP;AACD,OAFD,MAEO,IAAIA,KAAK,KAAK,QAAd,EAAwB;AAC7B,eAAO,QAAP;AACD,OAFM,MAEA,IAAIA,KAAK,KAAK,WAAd,EAA2B;AAChC,eAAO,WAAP;AACD,OAFM,MAEA;AACL,eAAO,OAAP;AACD;AACF;;;EAhDwCG,mB","sourcesContent":["import BaseLayer from '../core/BaseLayer';\nimport { IGeometryLayerStyleOptions } from '../core/interface';\nimport GeometryModels, { GeometryModelType } from './models';\n\nexport default class GeometryLayer extends BaseLayer<\n IGeometryLayerStyleOptions\n> {\n public type: string = 'GeometryLayer';\n public buildModels() {\n const modelType = this.getModelType();\n this.layerModel = new GeometryModels[modelType](this);\n this.models = this.layerModel.initModels();\n }\n public rebuildModels() {\n this.models = this.layerModel.buildModels();\n }\n\n protected getConfigSchema() {\n return {\n properties: {\n opacity: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n },\n },\n };\n }\n protected getDefaultConfig() {\n const type = this.getModelType();\n const defaultConfig = {\n plane: {},\n sprite: {},\n billboard: {},\n };\n return defaultConfig[type];\n }\n\n protected getModelType(): GeometryModelType {\n const shapeAttribute = this.styleAttributeService.getLayerStyleAttribute(\n 'shape',\n );\n const shape = shapeAttribute?.scale?.field as GeometryModelType;\n if (shape === 'plane') {\n return 'plane';\n } else if (shape === 'sprite') {\n return 'sprite';\n } else if (shape === 'billboard') {\n return 'billboard';\n } else {\n return 'plane';\n }\n }\n}\n"],"file":"index.js"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
+
|
|
18
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
+
|
|
20
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
+
|
|
22
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
+
|
|
24
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
+
|
|
26
|
+
var _l7Core = require("@antv/l7-core");
|
|
27
|
+
|
|
28
|
+
var _l7Utils = require("@antv/l7-utils");
|
|
29
|
+
|
|
30
|
+
var _BaseModel2 = _interopRequireDefault(require("../../core/BaseModel"));
|
|
31
|
+
|
|
32
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
33
|
+
|
|
34
|
+
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; } }
|
|
35
|
+
|
|
36
|
+
var planeFrag = "\nuniform sampler2D u_texture;\nuniform float u_opacity;\n\nvarying vec3 v_Color;\nvarying vec2 v_uv;\n\n#pragma include \"picking\"\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(v_uv.x, 1.0 - v_uv.y));\n gl_FragColor.a *= u_opacity;\n gl_FragColor = filterColor(gl_FragColor);\n}\n";
|
|
37
|
+
var planeVert = "precision highp float;\nuniform mat4 u_ModelMatrix;\nuniform float u_raisingHeight: 0.0;\nuniform mat4 u_Mvp;\nuniform float u_opacity;\nuniform vec2 u_size: [1.0, 1.0];\nuniform mat2 u_RotateMatrix;\n\nattribute vec3 a_Extrude;\nattribute vec3 a_Position;\nattribute vec2 a_Uv;\nattribute vec3 a_Color;\n\nvarying vec3 v_Color;\nvarying vec2 v_uv;\n\n#pragma include \"projection\"\n#pragma include \"picking\"\nvoid main() {\n vec3 extrude = a_Extrude;\n v_Color = a_Color;\n v_uv = a_Uv;\n\n float raiseHeight = u_raisingHeight;\n if(u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT || u_CoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSET) {\n float mapboxZoomScale = 4.0/pow(2.0, 21.0 - u_Zoom);\n raiseHeight = u_raisingHeight * mapboxZoomScale;\n }\n\n // \u8BA1\u7B97\u7ECF\u7EAC\u5EA6\u70B9\u4F4D\u5750\u6807\n vec4 project_pos = project_position(vec4(a_Position.xy, 0.0, 1.0));\n\n // \u8BA1\u7B97\u7ED5 z \u8F74\u65CB\u8F6C\u540E\u7684\u504F\u79FB\n vec2 offsetXY = project_pixel(u_RotateMatrix * vec2(extrude.x * u_size.x, 0.0));\n // \u7ED5 z \u8F74\u65CB\u8F6C\n float x = project_pos.x + offsetXY.x;\n float y = project_pos.y + offsetXY.y;\n // z \u8F74\u4E0D\u53C2\u4E0E\u65CB\u8F6C\n float z = project_pixel(extrude.y * u_size.y + raiseHeight);\n\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n // gl_Position = u_Mvp * (vec4(project_pos.xy, a_Position.z, 1.0));\n gl_Position = u_Mvp * (vec4(x, y, z, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(x , y, z , 1.0));\n }\n\n setPickingColor(a_PickingColor);\n}\n";
|
|
38
|
+
|
|
39
|
+
var BillBoardModel = function (_BaseModel) {
|
|
40
|
+
(0, _inherits2.default)(BillBoardModel, _BaseModel);
|
|
41
|
+
|
|
42
|
+
var _super = _createSuper(BillBoardModel);
|
|
43
|
+
|
|
44
|
+
function BillBoardModel() {
|
|
45
|
+
var _this;
|
|
46
|
+
|
|
47
|
+
(0, _classCallCheck2.default)(this, BillBoardModel);
|
|
48
|
+
|
|
49
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
50
|
+
args[_key] = arguments[_key];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
54
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "texture", void 0);
|
|
55
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "radian", 0);
|
|
56
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "planeGeometryTriangulation", function () {
|
|
57
|
+
var _ref = _this.layer.getLayerConfig(),
|
|
58
|
+
_ref$center = _ref.center,
|
|
59
|
+
center = _ref$center === void 0 ? [120, 30] : _ref$center;
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
size: 4,
|
|
63
|
+
indices: [0, 1, 2, 2, 3, 0],
|
|
64
|
+
vertices: [].concat((0, _toConsumableArray2.default)(center), [1, 1], (0, _toConsumableArray2.default)(center), [0, 1], (0, _toConsumableArray2.default)(center), [0, 0], (0, _toConsumableArray2.default)(center), [1, 0])
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
return _this;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
(0, _createClass2.default)(BillBoardModel, [{
|
|
71
|
+
key: "getUninforms",
|
|
72
|
+
value: function getUninforms() {
|
|
73
|
+
var _ref2 = this.layer.getLayerConfig(),
|
|
74
|
+
opacity = _ref2.opacity,
|
|
75
|
+
_ref2$width = _ref2.width,
|
|
76
|
+
width = _ref2$width === void 0 ? 1 : _ref2$width,
|
|
77
|
+
_ref2$height = _ref2.height,
|
|
78
|
+
height = _ref2$height === void 0 ? 1 : _ref2$height,
|
|
79
|
+
_ref2$raisingHeight = _ref2.raisingHeight,
|
|
80
|
+
raisingHeight = _ref2$raisingHeight === void 0 ? 0 : _ref2$raisingHeight;
|
|
81
|
+
|
|
82
|
+
var rotateFlag = 1;
|
|
83
|
+
|
|
84
|
+
if (this.mapService.version === 'GAODE2.x' || this.mapService.version === 'GAODE1.x') {
|
|
85
|
+
rotateFlag = -1;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
this.radian = rotateFlag * Math.PI * (this.mapService.getRotation() % 360) / 180;
|
|
89
|
+
return {
|
|
90
|
+
u_raisingHeight: Number(raisingHeight),
|
|
91
|
+
u_RotateMatrix: new Float32Array([Math.cos(this.radian), Math.sin(this.radian), -Math.sin(this.radian), Math.cos(this.radian)]),
|
|
92
|
+
u_opacity: opacity || 1,
|
|
93
|
+
u_texture: this.texture,
|
|
94
|
+
u_size: [width, height]
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
key: "clearModels",
|
|
99
|
+
value: function clearModels() {
|
|
100
|
+
var _this$texture;
|
|
101
|
+
|
|
102
|
+
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
103
|
+
}
|
|
104
|
+
}, {
|
|
105
|
+
key: "initModels",
|
|
106
|
+
value: function initModels() {
|
|
107
|
+
var _ref3 = this.layer.getLayerConfig(),
|
|
108
|
+
_ref3$mask = _ref3.mask,
|
|
109
|
+
mask = _ref3$mask === void 0 ? false : _ref3$mask,
|
|
110
|
+
_ref3$maskInside = _ref3.maskInside,
|
|
111
|
+
maskInside = _ref3$maskInside === void 0 ? true : _ref3$maskInside,
|
|
112
|
+
drawCanvas = _ref3.drawCanvas;
|
|
113
|
+
|
|
114
|
+
var createTexture2D = this.rendererService.createTexture2D;
|
|
115
|
+
this.texture = createTexture2D({
|
|
116
|
+
height: 0,
|
|
117
|
+
width: 0
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
if (drawCanvas) {
|
|
121
|
+
this.updateTexture(drawCanvas);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return [this.layer.buildLayerModel({
|
|
125
|
+
moduleName: 'geometry_billboard',
|
|
126
|
+
vertexShader: planeVert,
|
|
127
|
+
fragmentShader: planeFrag,
|
|
128
|
+
triangulation: this.planeGeometryTriangulation,
|
|
129
|
+
primitive: _l7Core.gl.TRIANGLES,
|
|
130
|
+
depth: {
|
|
131
|
+
enable: true
|
|
132
|
+
},
|
|
133
|
+
blend: this.getBlend(),
|
|
134
|
+
stencil: (0, _l7Utils.getMask)(mask, maskInside)
|
|
135
|
+
})];
|
|
136
|
+
}
|
|
137
|
+
}, {
|
|
138
|
+
key: "buildModels",
|
|
139
|
+
value: function buildModels() {
|
|
140
|
+
return this.initModels();
|
|
141
|
+
}
|
|
142
|
+
}, {
|
|
143
|
+
key: "updateTexture",
|
|
144
|
+
value: function updateTexture(drawCanvas) {
|
|
145
|
+
var createTexture2D = this.rendererService.createTexture2D;
|
|
146
|
+
|
|
147
|
+
var _ref4 = this.layer.getLayerConfig(),
|
|
148
|
+
_ref4$canvasWidth = _ref4.canvasWidth,
|
|
149
|
+
canvasWidth = _ref4$canvasWidth === void 0 ? 1 : _ref4$canvasWidth,
|
|
150
|
+
_ref4$canvasHeight = _ref4.canvasHeight,
|
|
151
|
+
canvasHeight = _ref4$canvasHeight === void 0 ? 1 : _ref4$canvasHeight;
|
|
152
|
+
|
|
153
|
+
var canvas = document.createElement('canvas');
|
|
154
|
+
canvas.width = canvasWidth;
|
|
155
|
+
canvas.height = canvasHeight;
|
|
156
|
+
var ctx = canvas.getContext('2d');
|
|
157
|
+
|
|
158
|
+
if (ctx) {
|
|
159
|
+
drawCanvas(canvas);
|
|
160
|
+
this.texture = createTexture2D({
|
|
161
|
+
data: canvas,
|
|
162
|
+
width: canvas.width,
|
|
163
|
+
height: canvas.height,
|
|
164
|
+
wrapS: _l7Core.gl.CLAMP_TO_EDGE,
|
|
165
|
+
wrapT: _l7Core.gl.CLAMP_TO_EDGE
|
|
166
|
+
});
|
|
167
|
+
this.layerService.updateLayerRenderList();
|
|
168
|
+
this.layerService.renderLayers();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}, {
|
|
172
|
+
key: "getConfigSchema",
|
|
173
|
+
value: function getConfigSchema() {
|
|
174
|
+
return {
|
|
175
|
+
properties: {
|
|
176
|
+
opacity: {
|
|
177
|
+
type: 'number',
|
|
178
|
+
minimum: 0,
|
|
179
|
+
maximum: 1
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
}, {
|
|
185
|
+
key: "registerBuiltinAttributes",
|
|
186
|
+
value: function registerBuiltinAttributes() {
|
|
187
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
188
|
+
name: 'extrude',
|
|
189
|
+
type: _l7Core.AttributeType.Attribute,
|
|
190
|
+
descriptor: {
|
|
191
|
+
name: 'a_Extrude',
|
|
192
|
+
buffer: {
|
|
193
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
194
|
+
data: [],
|
|
195
|
+
type: _l7Core.gl.FLOAT
|
|
196
|
+
},
|
|
197
|
+
size: 3,
|
|
198
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
199
|
+
var extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];
|
|
200
|
+
var extrudeIndex = attributeIdx % 4 * 3;
|
|
201
|
+
return [extrude[extrudeIndex], extrude[extrudeIndex + 1], extrude[extrudeIndex + 2]];
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
this.styleAttributeService.registerStyleAttribute({
|
|
206
|
+
name: 'uv',
|
|
207
|
+
type: _l7Core.AttributeType.Attribute,
|
|
208
|
+
descriptor: {
|
|
209
|
+
name: 'a_Uv',
|
|
210
|
+
buffer: {
|
|
211
|
+
usage: _l7Core.gl.DYNAMIC_DRAW,
|
|
212
|
+
data: [],
|
|
213
|
+
type: _l7Core.gl.FLOAT
|
|
214
|
+
},
|
|
215
|
+
size: 2,
|
|
216
|
+
update: function update(feature, featureIdx, vertex, attributeIdx) {
|
|
217
|
+
return [vertex[2], vertex[3]];
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}]);
|
|
223
|
+
return BillBoardModel;
|
|
224
|
+
}(_BaseModel2.default);
|
|
225
|
+
|
|
226
|
+
exports.default = BillBoardModel;
|
|
227
|
+
//# sourceMappingURL=billboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/Geometry/models/billboard.ts"],"names":["BillBoardModel","layer","getLayerConfig","center","size","indices","vertices","opacity","width","height","raisingHeight","rotateFlag","mapService","version","radian","Math","PI","getRotation","u_raisingHeight","Number","u_RotateMatrix","Float32Array","cos","sin","u_opacity","u_texture","texture","u_size","destroy","mask","maskInside","drawCanvas","createTexture2D","rendererService","updateTexture","buildLayerModel","moduleName","vertexShader","planeVert","fragmentShader","planeFrag","triangulation","planeGeometryTriangulation","primitive","gl","TRIANGLES","depth","enable","blend","getBlend","stencil","initModels","canvasWidth","canvasHeight","canvas","document","createElement","ctx","getContext","data","wrapS","CLAMP_TO_EDGE","wrapT","layerService","updateLayerRenderList","renderLayers","properties","type","minimum","maximum","styleAttributeService","registerStyleAttribute","name","AttributeType","Attribute","descriptor","buffer","usage","DYNAMIC_DRAW","FLOAT","update","feature","featureIdx","vertex","attributeIdx","extrude","extrudeIndex","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAQA;;AACA;;;;;;;;;IAKqBA,c;;;;;;;;;;;;;;;;yFAEM,C;6GAEW,YAAM;AACxC,iBAEI,MAAKC,KAAL,CAAWC,cAAX,EAFJ;AAAA,6BACEC,MADF;AAAA,UACEA,MADF,4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M,EAKH;AACH,mBAAO,CAACD,MAAM,CAAC,CAAD,CAAP,EAAYA,MAAM,CAAC,CAAD,CAAlB,CAAP;AACD;AAhBS;AAHoC,OAAlD;AAsBD;;;EAjMyCI,mB","sourcesContent":["import {\n AttributeType,\n gl,\n IAttrubuteAndElements,\n IEncodeFeature,\n IModelUniform,\n ITexture2D,\n} from '@antv/l7-core';\nimport { getMask, isMini } from '@antv/l7-utils';\nimport BaseModel from '../../core/BaseModel';\nimport { IGeometryLayerStyleOptions } from '../../core/interface';\nimport planeFrag from '../shaders/billboard_frag.glsl';\nimport planeVert from '../shaders/billboard_vert.glsl';\n\nexport default class BillBoardModel extends BaseModel {\n protected texture: ITexture2D;\n private radian: number = 0; // 旋转的弧度\n\n public planeGeometryTriangulation = () => {\n const {\n center = [120, 30],\n } = this.layer.getLayerConfig() as IGeometryLayerStyleOptions;\n return {\n size: 4,\n indices: [0, 1, 2, 2, 3, 0],\n vertices: [\n ...center,\n ...[1, 1],\n ...center,\n ...[0, 1],\n ...center,\n ...[0, 0],\n ...center,\n ...[1, 0],\n ],\n };\n };\n\n public getUninforms(): IModelUniform {\n const {\n opacity,\n width = 1,\n height = 1,\n raisingHeight = 0,\n } = this.layer.getLayerConfig() as IGeometryLayerStyleOptions;\n\n /**\n * rotateFlag\n * L7MAP 1\n * MAPBOX 1\n * GAODE2.x -1\n * GAODE1.x -1\n */\n let rotateFlag = 1;\n if (\n this.mapService.version === 'GAODE2.x' ||\n this.mapService.version === 'GAODE1.x'\n ) {\n rotateFlag = -1;\n }\n // 控制图标的旋转角度(绕 Z 轴旋转)\n this.radian =\n (rotateFlag * Math.PI * (this.mapService.getRotation() % 360)) / 180;\n\n return {\n u_raisingHeight: Number(raisingHeight),\n u_RotateMatrix: new Float32Array([\n // z\n Math.cos(this.radian),\n Math.sin(this.radian),\n -Math.sin(this.radian),\n Math.cos(this.radian),\n ]),\n u_opacity: opacity || 1,\n u_texture: this.texture,\n u_size: [width, height],\n };\n }\n\n public clearModels(): void {\n this.texture?.destroy();\n }\n\n public initModels() {\n const {\n mask = false,\n maskInside = true,\n drawCanvas,\n } = this.layer.getLayerConfig() as IGeometryLayerStyleOptions;\n\n const { createTexture2D } = this.rendererService;\n this.texture = createTexture2D({\n height: 0,\n width: 0,\n });\n\n if (drawCanvas) {\n this.updateTexture(drawCanvas);\n }\n\n return [\n this.layer.buildLayerModel({\n moduleName: 'geometry_billboard',\n vertexShader: planeVert,\n fragmentShader: planeFrag,\n triangulation: this.planeGeometryTriangulation,\n primitive: gl.TRIANGLES,\n depth: { enable: true },\n blend: this.getBlend(),\n stencil: getMask(mask, maskInside),\n }),\n ];\n }\n\n public buildModels() {\n return this.initModels();\n }\n\n public updateTexture(drawCanvas: (canvas: HTMLCanvasElement) => void): void {\n const { createTexture2D } = this.rendererService;\n\n const {\n canvasWidth = 1,\n canvasHeight = 1,\n } = this.layer.getLayerConfig() as IGeometryLayerStyleOptions;\n const canvas = document.createElement('canvas');\n canvas.width = canvasWidth;\n canvas.height = canvasHeight;\n const ctx = canvas.getContext('2d');\n if (ctx) {\n drawCanvas(canvas);\n this.texture = createTexture2D({\n data: canvas,\n width: canvas.width,\n height: canvas.height,\n wrapS: gl.CLAMP_TO_EDGE,\n wrapT: gl.CLAMP_TO_EDGE,\n });\n this.layerService.updateLayerRenderList();\n this.layerService.renderLayers();\n }\n }\n\n protected getConfigSchema() {\n return {\n properties: {\n opacity: {\n type: 'number',\n minimum: 0,\n maximum: 1,\n },\n },\n };\n }\n\n protected registerBuiltinAttributes() {\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 const extrude = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0];\n const extrudeIndex = (attributeIdx % 4) * 3;\n return [\n extrude[extrudeIndex],\n extrude[extrudeIndex + 1],\n extrude[extrudeIndex + 2],\n ];\n },\n },\n });\n // point layer size;\n this.styleAttributeService.registerStyleAttribute({\n name: 'uv',\n type: AttributeType.Attribute,\n descriptor: {\n name: 'a_Uv',\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[2], vertex[3]];\n },\n },\n });\n }\n}\n"],"file":"billboard.js"}
|
|
@@ -7,13 +7,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
|
|
10
|
+
var _billboard = _interopRequireDefault(require("./billboard"));
|
|
11
|
+
|
|
10
12
|
var _plane = _interopRequireDefault(require("./plane"));
|
|
11
13
|
|
|
12
14
|
var _sprite = _interopRequireDefault(require("./sprite"));
|
|
13
15
|
|
|
14
16
|
var GeometryModels = {
|
|
15
17
|
plane: _plane.default,
|
|
16
|
-
sprite: _sprite.default
|
|
18
|
+
sprite: _sprite.default,
|
|
19
|
+
billboard: _billboard.default
|
|
17
20
|
};
|
|
18
21
|
var _default = GeometryModels;
|
|
19
22
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Geometry/models/index.ts"],"names":["GeometryModels","plane","PlaneModel","sprite","SpriteModel"],"mappings":";;;;;;;;;AAAA;;AACA;;AAGA,IAAMA,cAAmD,GAAG;AAC1DC,EAAAA,KAAK,EAAEC,cADmD;AAE1DC,EAAAA,MAAM,EAAEC;
|
|
1
|
+
{"version":3,"sources":["../../../src/Geometry/models/index.ts"],"names":["GeometryModels","plane","PlaneModel","sprite","SpriteModel","billboard","BillBoardModel"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAGA,IAAMA,cAAmD,GAAG;AAC1DC,EAAAA,KAAK,EAAEC,cADmD;AAE1DC,EAAAA,MAAM,EAAEC,eAFkD;AAG1DC,EAAAA,SAAS,EAAEC;AAH+C,CAA5D;eAKeN,c","sourcesContent":["import BillBoardModel from './billboard';\nimport PlaneModel from './plane';\nimport SpriteModel from './sprite';\nexport type GeometryModelType = 'plane' | 'sprite' | 'billboard';\n\nconst GeometryModels: { [key in GeometryModelType]: any } = {\n plane: PlaneModel,\n sprite: SpriteModel,\n billboard: BillBoardModel,\n};\nexport default GeometryModels;\n"],"file":"index.js"}
|
|
@@ -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 spriteFrag = "\nuniform sampler2D u_texture;\nuniform float u_mapFlag;\nuniform float u_opacity;\n\nvarying vec3 v_Color;\nvarying float v_d;\n\
|
|
39
|
-
var spriteVert = "precision highp float;\n\nattribute vec3 a_Position;\nattribute vec3 a_Color;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_opacity;\nuniform float u_Scale;\nvarying vec3 v_Color;\nvarying float v_d;\n\n#pragma include \"projection\"\
|
|
38
|
+
var spriteFrag = "\nuniform sampler2D u_texture;\nuniform float u_mapFlag;\nuniform float u_opacity;\n\nvarying vec3 v_Color;\nvarying float v_d;\n\nvoid main() {\n\n if(v_d < 0.0) {\n discard;\n }\n\n if(u_mapFlag > 0.0) {\n gl_FragColor = texture2D(u_texture, gl_PointCoord);\n gl_FragColor.a *= u_opacity;\n } else {\n gl_FragColor = vec4(v_Color, u_opacity);\n }\n}\n";
|
|
39
|
+
var spriteVert = "precision highp float;\n\nattribute vec3 a_Position;\nattribute vec3 a_Color;\n\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_Mvp;\nuniform float u_opacity;\nuniform float u_Scale;\nvarying vec3 v_Color;\nvarying float v_d;\n\n#pragma include \"projection\"\nvoid main() {\n v_Color = a_Color;\n \n vec4 project_pos = project_position(vec4(a_Position, 1.0));\n\n v_d = a_Position.z;\n\n if(u_CoordinateSystem == COORDINATE_SYSTEM_P20_2) { // gaode2.x\n gl_Position = u_Mvp * (vec4(project_pos.xy, a_Position.z, 1.0));\n } else {\n gl_Position = project_common_position_to_clipspace(vec4(project_pos.xy, a_Position.z, 1.0));\n }\n\n gl_PointSize = pow((u_Zoom - 1.0), 2.0) * u_Scale;\n}\n";
|
|
40
40
|
var SPRITE_ANIMATE_DIR;
|
|
41
41
|
|
|
42
42
|
(function (SPRITE_ANIMATE_DIR) {
|