@deck.gl/extensions 9.0.0-alpha.7 → 9.0.0-beta.1

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/dist/dist.dev.js CHANGED
@@ -3121,7 +3121,6 @@ void main(void) {}`;
3121
3121
 
3122
3122
  // ../../node_modules/@luma.gl/webgl/dist/adapter/resources/webgl-buffer.js
3123
3123
  var import_core10 = __toESM(require_core2(), 1);
3124
- var DEBUG_DATA_LENGTH = 10;
3125
3124
  var WEBGLBuffer = class extends import_core10.Buffer {
3126
3125
  constructor(device) {
3127
3126
  let props = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
@@ -3135,7 +3134,6 @@ void main(void) {}`;
3135
3134
  this.glIndexType = 5123;
3136
3135
  this.byteLength = void 0;
3137
3136
  this.bytesUsed = void 0;
3138
- this.debugData = null;
3139
3137
  this.device = device;
3140
3138
  this.gl = this.device.gl;
3141
3139
  this.gl2 = this.device.gl2;
@@ -3148,7 +3146,6 @@ void main(void) {}`;
3148
3146
  this.glTarget = getWebGLTarget(this.props.usage);
3149
3147
  this.glUsage = getWebGLUsage(this.props.usage);
3150
3148
  this.glIndexType = this.props.indexType === "uint32" ? 5125 : 5123;
3151
- this.debugData = null;
3152
3149
  if (props.data) {
3153
3150
  this._initWithData(props.data, props.byteOffset, props.byteLength);
3154
3151
  } else {
@@ -3158,17 +3155,15 @@ void main(void) {}`;
3158
3155
  _initWithData(data) {
3159
3156
  let byteOffset = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
3160
3157
  let byteLength = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : data.byteLength + byteOffset;
3161
- (0, import_core10.assert)(ArrayBuffer.isView(data));
3162
- const glTarget = this._getWriteTarget();
3158
+ const glTarget = this.glTarget;
3163
3159
  this.gl.bindBuffer(glTarget, this.handle);
3164
3160
  this.gl.bufferData(glTarget, byteLength, this.glUsage);
3165
3161
  this.gl.bufferSubData(glTarget, byteOffset, data);
3166
3162
  this.gl.bindBuffer(glTarget, null);
3167
- this.debugData = data.slice(0, DEBUG_DATA_LENGTH);
3168
3163
  this.bytesUsed = byteLength;
3169
3164
  this.byteLength = byteLength;
3165
+ this._setDebugData(data, byteOffset, byteLength);
3170
3166
  this.trackAllocatedMemory(byteLength);
3171
- return this;
3172
3167
  }
3173
3168
  _initWithByteLength(byteLength) {
3174
3169
  (0, import_core10.assert)(byteLength >= 0);
@@ -3176,13 +3171,14 @@ void main(void) {}`;
3176
3171
  if (byteLength === 0) {
3177
3172
  data = new Float32Array(0);
3178
3173
  }
3179
- const glTarget = this._getWriteTarget();
3174
+ const glTarget = this.glTarget;
3180
3175
  this.gl.bindBuffer(glTarget, this.handle);
3181
3176
  this.gl.bufferData(glTarget, data, this.glUsage);
3182
3177
  this.gl.bindBuffer(glTarget, null);
3183
- this.debugData = null;
3184
3178
  this.bytesUsed = byteLength;
3185
3179
  this.byteLength = byteLength;
3180
+ this._setDebugData(null, 0, byteLength);
3181
+ this.trackAllocatedMemory(byteLength);
3186
3182
  return this;
3187
3183
  }
3188
3184
  destroy() {
@@ -3207,29 +3203,27 @@ void main(void) {}`;
3207
3203
  this.gl.bufferSubData(glTarget, byteOffset, data);
3208
3204
  }
3209
3205
  this.gl.bindBuffer(glTarget, null);
3206
+ this._setDebugData(data, byteOffset, data.byteLength);
3210
3207
  }
3211
3208
  async readAsync() {
3209
+ let byteOffset = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
3210
+ let byteLength = arguments.length > 1 ? arguments[1] : void 0;
3211
+ return this.readSyncWebGL2(byteOffset, byteLength);
3212
+ }
3213
+ readSyncWebGL2() {
3212
3214
  var _byteLength;
3213
3215
  let byteOffset = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
3214
3216
  let byteLength = arguments.length > 1 ? arguments[1] : void 0;
3215
3217
  this.device.assertWebGL2();
3216
- byteLength = (_byteLength = byteLength) !== null && _byteLength !== void 0 ? _byteLength : this.byteLength;
3218
+ byteLength = (_byteLength = byteLength) !== null && _byteLength !== void 0 ? _byteLength : this.byteLength - byteOffset;
3217
3219
  const data = new Uint8Array(byteLength);
3218
3220
  const dstOffset = 0;
3219
3221
  this.gl.bindBuffer(36662, this.handle);
3220
3222
  this.gl2.getBufferSubData(36662, byteOffset, data, dstOffset, byteLength);
3221
3223
  this.gl.bindBuffer(36662, null);
3224
+ this._setDebugData(data, byteOffset, byteLength);
3222
3225
  return data;
3223
3226
  }
3224
- _invalidateDebugData() {
3225
- this.debugData = null;
3226
- }
3227
- _getWriteTarget() {
3228
- return this.glTarget;
3229
- }
3230
- _getReadTarget() {
3231
- return this.glTarget;
3232
- }
3233
3227
  };
3234
3228
  function getWebGLTarget(usage) {
3235
3229
  if (usage & import_core10.Buffer.INDEX) {
@@ -10429,13 +10423,12 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
10429
10423
  import_core37.log.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();
10430
10424
  }
10431
10425
  for (const [bufferName, buffer] of Object.entries(buffers)) {
10432
- var _bufferLayout$attribu;
10433
- const bufferLayout = this.bufferLayout.find((layout) => layout.name === bufferName);
10426
+ const bufferLayout = this.bufferLayout.find((layout) => getAttributeNames(layout).includes(bufferName));
10434
10427
  if (!bufferLayout) {
10435
10428
  import_core37.log.warn(`Model(${this.id}): Missing layout for buffer "${bufferName}".`)();
10436
10429
  continue;
10437
10430
  }
10438
- const attributeNames = bufferLayout.attributes ? (_bufferLayout$attribu = bufferLayout.attributes) === null || _bufferLayout$attribu === void 0 ? void 0 : _bufferLayout$attribu.map((layout) => layout.attribute) : [bufferLayout.name];
10431
+ const attributeNames = getAttributeNames(bufferLayout);
10439
10432
  let set2 = false;
10440
10433
  for (const attributeName of attributeNames) {
10441
10434
  const attributeInfo = this._attributeInfos[attributeName];
@@ -10510,10 +10503,40 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
10510
10503
  };
10511
10504
  }
10512
10505
  import_core37.log.table(LOG_DRAW_PRIORITY, uniformTable)();
10506
+ const attributeTable = this._getAttributeDebugTable();
10507
+ import_core37.log.table(LOG_DRAW_PRIORITY, this._attributeInfos)();
10508
+ import_core37.log.table(LOG_DRAW_PRIORITY, attributeTable)();
10513
10509
  import_core37.log.groupEnd(LOG_DRAW_PRIORITY)();
10514
10510
  this._logOpen = false;
10515
10511
  }
10516
10512
  }
10513
+ _getAttributeDebugTable() {
10514
+ const table = {};
10515
+ for (const [name, attributeInfo] of Object.entries(this._attributeInfos)) {
10516
+ table[attributeInfo.location] = {
10517
+ name,
10518
+ type: attributeInfo.shaderType,
10519
+ values: this._getBufferOrConstantValues(this.vertexArray.attributes[attributeInfo.location], attributeInfo.bufferDataType)
10520
+ };
10521
+ }
10522
+ if (this.vertexArray.indexBuffer) {
10523
+ const {
10524
+ indexBuffer
10525
+ } = this.vertexArray;
10526
+ const values = indexBuffer.indexType === "uint32" ? new Uint32Array(indexBuffer.debugData) : new Uint16Array(indexBuffer.debugData);
10527
+ table.indices = {
10528
+ name: "indices",
10529
+ type: indexBuffer.indexType,
10530
+ values: values.toString()
10531
+ };
10532
+ }
10533
+ return table;
10534
+ }
10535
+ _getBufferOrConstantValues(attribute, dataType) {
10536
+ const TypedArrayConstructor = (0, import_core36.getTypedArrayFromDataType)(dataType);
10537
+ const typedArray = attribute instanceof import_core36.Buffer ? new TypedArrayConstructor(attribute.debugData) : attribute;
10538
+ return typedArray.toString();
10539
+ }
10517
10540
  };
10518
10541
  Model.defaultProps = {
10519
10542
  ...import_core36.RenderPipeline.defaultProps,
@@ -10556,6 +10579,10 @@ void mat4_vec4_mul_fp64(vec2 b[16], vec2 a[4], out vec2 out_val[4]) {
10556
10579
  features: device.features
10557
10580
  };
10558
10581
  }
10582
+ function getAttributeNames(bufferLayout) {
10583
+ var _bufferLayout$attribu;
10584
+ return bufferLayout.attributes ? (_bufferLayout$attribu = bufferLayout.attributes) === null || _bufferLayout$attribu === void 0 ? void 0 : _bufferLayout$attribu.map((layout) => layout.attribute) : [bufferLayout.name];
10585
+ }
10559
10586
 
10560
10587
  // src/data-filter/aggregator.ts
10561
10588
  var AGGREGATE_VS = `#version 300 es
@@ -11621,8 +11648,10 @@ float collision_isVisible(vec2 texCoords, vec3 pickingColor) {
11621
11648
  getModuleParameters() {
11622
11649
  return {
11623
11650
  drawToCollisionMap: true,
11624
- pickingActive: 1,
11625
- pickingAttribute: false,
11651
+ picking: {
11652
+ isActive: 1,
11653
+ isAttribute: false
11654
+ },
11626
11655
  lightSources: {}
11627
11656
  };
11628
11657
  }
@@ -12515,7 +12544,7 @@ if ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_US
12515
12544
  sampler = heightMap;
12516
12545
  bounds = heightMapBounds;
12517
12546
  } else if (terrainCover) {
12518
- const isPicking = opts.pickingActive;
12547
+ const isPicking = opts.picking?.isActive;
12519
12548
  sampler = isPicking ? terrainCover.getPickingFramebuffer() : terrainCover.getRenderFramebuffer();
12520
12549
  if (isPicking) {
12521
12550
  mode = TERRAIN_MODE.SKIP;
@@ -64,8 +64,10 @@ var CollisionFilterPass = function (_LayersPass) {
64
64
  _proto.getModuleParameters = function getModuleParameters() {
65
65
  return {
66
66
  drawToCollisionMap: true,
67
- pickingActive: 1,
68
- pickingAttribute: false,
67
+ picking: {
68
+ isActive: 1,
69
+ isAttribute: false
70
+ },
69
71
  lightSources: {}
70
72
  };
71
73
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collision-filter/collision-filter-pass.ts"],"names":["CollisionFilterPass","renderCollisionMap","target","options","padding","clearColor","device","scissorTest","scissor","width","height","blend","depthTest","depthRange","render","pass","getModuleParameters","drawToCollisionMap","pickingActive","pickingAttribute","lightSources","LayersPass"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;;AACA;;;;;;;;;;IAIqBA,mB;;;;;;;;;;;;SACnBC,kB,GAAA,4BAAmBC,MAAnB,EAAwCC,OAAxC,EAAmF;AAAA;;AACjF,QAAMC,OAAO,GAAG,CAAhB;AACA,QAAMC,UAAU,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAnB;AAEA,WAAO,6BACL,KAAKC,MADA,EAEL;AACEC,MAAAA,WAAW,EAAE,IADf;AAEEC,MAAAA,OAAO,EAAE,CAACJ,OAAD,EAAUA,OAAV,EAAmBF,MAAM,CAACO,KAAP,GAAe,IAAIL,OAAtC,EAA+CF,MAAM,CAACQ,MAAP,GAAgB,IAAIN,OAAnE,CAFX;AAGEO,MAAAA,KAAK,EAAE,KAHT;AAIEC,MAAAA,SAAS,EAAE,IAJb;AAKEC,MAAAA,UAAU,EAAE,CAAC,CAAD,EAAI,CAAJ;AALd,KAFK,EASL;AAAA,aAAM,KAAI,CAACC,MAAL,iCAAgBX,OAAhB;AAAyBE,QAAAA,UAAU,EAAVA,UAAzB;AAAqCH,QAAAA,MAAM,EAANA,MAArC;AAA6Ca,QAAAA,IAAI,EAAE;AAAnD,SAAN;AAAA,KATK,CAAP;AAWD,G;;SAEDC,mB,GAAA,+BAAsB;AAEpB,WAAO;AACLC,MAAAA,kBAAkB,EAAE,IADf;AAELC,MAAAA,aAAa,EAAE,CAFV;AAGLC,MAAAA,gBAAgB,EAAE,KAHb;AAILC,MAAAA,YAAY,EAAE;AAJT,KAAP;AAMD,G;;;EA1B8CC,iB","sourcesContent":["import {Framebuffer} from '@luma.gl/core';\nimport {withGLParameters} from '@luma.gl/webgl';\nimport {_LayersPass as LayersPass, LayersPassRenderOptions} from '@deck.gl/core';\n\ntype CollisionFilterPassRenderOptions = LayersPassRenderOptions & {};\n\nexport default class CollisionFilterPass extends LayersPass {\n renderCollisionMap(target: Framebuffer, options: CollisionFilterPassRenderOptions) {\n const padding = 1;\n const clearColor = [0, 0, 0, 0];\n\n return withGLParameters(\n this.device,\n {\n scissorTest: true,\n scissor: [padding, padding, target.width - 2 * padding, target.height - 2 * padding],\n blend: false,\n depthTest: true,\n depthRange: [0, 1]\n },\n () => this.render({...options, clearColor, target, pass: 'collision'})\n );\n }\n\n getModuleParameters() {\n // Draw picking colors into collision FBO\n return {\n drawToCollisionMap: true,\n pickingActive: 1,\n pickingAttribute: false,\n lightSources: {}\n };\n }\n}\n"],"file":"collision-filter-pass.js"}
1
+ {"version":3,"sources":["../../../src/collision-filter/collision-filter-pass.ts"],"names":["CollisionFilterPass","renderCollisionMap","target","options","padding","clearColor","device","scissorTest","scissor","width","height","blend","depthTest","depthRange","render","pass","getModuleParameters","drawToCollisionMap","picking","isActive","isAttribute","lightSources","LayersPass"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;;AACA;;;;;;;;;;IAIqBA,mB;;;;;;;;;;;;SACnBC,kB,GAAA,4BAAmBC,MAAnB,EAAwCC,OAAxC,EAAmF;AAAA;;AACjF,QAAMC,OAAO,GAAG,CAAhB;AACA,QAAMC,UAAU,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAnB;AAEA,WAAO,6BACL,KAAKC,MADA,EAEL;AACEC,MAAAA,WAAW,EAAE,IADf;AAEEC,MAAAA,OAAO,EAAE,CAACJ,OAAD,EAAUA,OAAV,EAAmBF,MAAM,CAACO,KAAP,GAAe,IAAIL,OAAtC,EAA+CF,MAAM,CAACQ,MAAP,GAAgB,IAAIN,OAAnE,CAFX;AAGEO,MAAAA,KAAK,EAAE,KAHT;AAIEC,MAAAA,SAAS,EAAE,IAJb;AAKEC,MAAAA,UAAU,EAAE,CAAC,CAAD,EAAI,CAAJ;AALd,KAFK,EASL;AAAA,aAAM,KAAI,CAACC,MAAL,iCAAgBX,OAAhB;AAAyBE,QAAAA,UAAU,EAAVA,UAAzB;AAAqCH,QAAAA,MAAM,EAANA,MAArC;AAA6Ca,QAAAA,IAAI,EAAE;AAAnD,SAAN;AAAA,KATK,CAAP;AAWD,G;;SAEDC,mB,GAAA,+BAAsB;AAEpB,WAAO;AACLC,MAAAA,kBAAkB,EAAE,IADf;AAELC,MAAAA,OAAO,EAAE;AACPC,QAAAA,QAAQ,EAAE,CADH;AAEPC,QAAAA,WAAW,EAAE;AAFN,OAFJ;AAMLC,MAAAA,YAAY,EAAE;AANT,KAAP;AAQD,G;;;EA5B8CC,iB","sourcesContent":["import {Framebuffer} from '@luma.gl/core';\nimport {withGLParameters} from '@luma.gl/webgl';\nimport {_LayersPass as LayersPass, LayersPassRenderOptions} from '@deck.gl/core';\n\ntype CollisionFilterPassRenderOptions = LayersPassRenderOptions & {};\n\nexport default class CollisionFilterPass extends LayersPass {\n renderCollisionMap(target: Framebuffer, options: CollisionFilterPassRenderOptions) {\n const padding = 1;\n const clearColor = [0, 0, 0, 0];\n\n return withGLParameters(\n this.device,\n {\n scissorTest: true,\n scissor: [padding, padding, target.width - 2 * padding, target.height - 2 * padding],\n blend: false,\n depthTest: true,\n depthRange: [0, 1]\n },\n () => this.render({...options, clearColor, target, pass: 'collision'})\n );\n }\n\n getModuleParameters() {\n // Draw picking colors into collision FBO\n return {\n drawToCollisionMap: true,\n picking: {\n isActive: 1,\n isAttribute: false\n },\n lightSources: {}\n };\n }\n}\n"],"file":"collision-filter-pass.js"}
@@ -55,7 +55,9 @@ var terrainModule = {
55
55
  sampler = heightMap;
56
56
  bounds = heightMapBounds;
57
57
  } else if (terrainCover) {
58
- var isPicking = opts.pickingActive;
58
+ var _opts$picking;
59
+
60
+ var isPicking = (_opts$picking = opts.picking) === null || _opts$picking === void 0 ? void 0 : _opts$picking.isActive;
59
61
  sampler = isPicking ? terrainCover.getPickingFramebuffer() : terrainCover.getRenderFramebuffer();
60
62
 
61
63
  if (isPicking) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/terrain/shader-module.ts"],"names":["TERRAIN_MODE","NONE","WRITE_HEIGHT_MAP","USE_HEIGHT_MAP","USE_COVER","USE_COVER_ONLY","SKIP","TERRAIN_MODE_CONSTANTS","Object","keys","map","key","join","terrainModule","name","dependencies","project","inject","getUniforms","opts","uniforms","drawToTerrainHeightMap","heightMap","heightMapBounds","dummyHeightMap","terrainCover","useTerrainHeightMap","terrainSkipRender","project_uCommonOrigin","mode","sampler","bounds","isPicking","pickingActive","getPickingFramebuffer","getRenderFramebuffer","terrain_mode","terrain_map","terrain_bounds"],"mappings":";;;;;;;AAGA;;AAmBO,IAAMA,YAAY,GAAG;AAC1BC,EAAAA,IAAI,EAAE,CADoB;AAG1BC,EAAAA,gBAAgB,EAAE,CAHQ;AAK1BC,EAAAA,cAAc,EAAE,CALU;AAO1BC,EAAAA,SAAS,EAAE,CAPe;AAS1BC,EAAAA,cAAc,EAAE,CATU;AAW1BC,EAAAA,IAAI,EAAE;AAXoB,CAArB;;AAcP,IAAMC,sBAAsB,GAAGC,MAAM,CAACC,IAAP,CAAYT,YAAZ,EAC5BU,GAD4B,CACxB,UAAAC,GAAG;AAAA,4CAAgCA,GAAhC,gBAAyCX,YAAY,CAACW,GAAD,CAArD;AAAA,CADqB,EAE5BC,IAF4B,CAEvB,IAFuB,CAA/B;AAKO,IAAMC,aAAa,GAAG;AAC3BC,EAAAA,IAAI,EAAE,SADqB;AAE3BC,EAAAA,YAAY,EAAE,CAACC,aAAD,CAFa;AAG3BC,EAAAA,MAAM,EAAE;AACN,4IAKFV,sBALE,WADM;AAQN,8GARM;AAcN,ozBAdM;AAiCN,2IAKFA,sBALE,WAjCM;AAwCN,mJAxCM;AA8CN;AA9CM,GAHmB;AAgE3BW,EAAAA,WAAW,EAAE,uBAAyD;AAAA,QAAxDC,IAAwD,uEAAjB,EAAiB;AAAA,QAAbC,QAAa;;AACpE,QAAI,oBAAoBD,IAAxB,EAA8B;AAC5B,UACEE,sBADF,GAQIF,IARJ,CACEE,sBADF;AAAA,UAEEC,SAFF,GAQIH,IARJ,CAEEG,SAFF;AAAA,UAGEC,eAHF,GAQIJ,IARJ,CAGEI,eAHF;AAAA,UAIEC,cAJF,GAQIL,IARJ,CAIEK,cAJF;AAAA,UAKEC,YAL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AAM,GAClB,CACEA,MAAM,CAAC,CAAD,CAAN,GAAYH,qBAAqB,CAAC,CAAD,CADnC,EAEEG,MAAM,CAAC,CAAD,CAAN,GAAYH,qBAAqB,CAAC,CAAD,CAFnC,EAGEG,MAAM,CAAC,CAAD,CAAN,GAAYA,MAAM,CAAC,CAAD,CAHpB,EAIEA,MAAM,CAAC,CAAD,CAAN,GAAYA,MAAM,CAAC,CAAD,CAJpB,CADkB,GAOlB,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV;AAXC,OAAP;AAaD;;AACD,WAAO,IAAP;AACD;AA5H0B,CAAtB","sourcesContent":["/* eslint-disable camelcase */\n\nimport type {ShaderModule} from '@luma.gl/shadertools';\nimport {project} from '@deck.gl/core';\n\nimport type {Texture} from '@luma.gl/core';\nimport type {Bounds} from '../utils/projection-utils';\nimport type {TerrainCover} from './terrain-cover';\n\n/** Module parameters expected by the terrain shader module */\nexport type TerrainModuleSettings = {\n pickingActive?: boolean;\n heightMap: Texture | null;\n heightMapBounds?: Bounds | null;\n dummyHeightMap: Texture;\n terrainCover?: TerrainCover | null;\n drawToTerrainHeightMap?: boolean;\n useTerrainHeightMap?: boolean;\n terrainSkipRender?: boolean;\n};\n\n/** A model can have one of the following modes */\nexport const TERRAIN_MODE = {\n NONE: 0,\n /** A terrain layer rendering encoded ground elevation into the height map */\n WRITE_HEIGHT_MAP: 1,\n /** An offset layer reading encoded ground elevation from the height map */\n USE_HEIGHT_MAP: 2,\n /** A terrain layer rendering to screen, using the cover fbo overlaid with its own texture */\n USE_COVER: 3,\n /** A terrain layer rendering to screen, using the cover fbo as texture */\n USE_COVER_ONLY: 4,\n /** Draped layer is rendered into a texture, and never to screen */\n SKIP: 5\n};\n\nconst TERRAIN_MODE_CONSTANTS = Object.keys(TERRAIN_MODE)\n .map(key => `const float TERRAIN_MODE_${key} = ${TERRAIN_MODE[key]}.0;`)\n .join('\\n');\n\n// @ts-expect-error\nexport const terrainModule = {\n name: 'terrain',\n dependencies: [project],\n inject: {\n 'vs:#decl': `\nuniform float terrain_mode;\nuniform sampler2D terrain_map;\nuniform vec4 terrain_bounds;\nout vec3 commonPos;\n${TERRAIN_MODE_CONSTANTS}\n `,\n 'vs:#main-start': `\nif (terrain_mode == TERRAIN_MODE_SKIP) {\n gl_Position = vec4(0.0);\n return;\n}\n`,\n 'vs:DECKGL_FILTER_GL_POSITION': `\ncommonPos = geometry.position.xyz;\nif (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {\n vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;\n position = vec4(texCoords * 2.0 - 1.0, 0.0, 1.0);\n commonPos.z += project_uCommonOrigin.z;\n}\nif (terrain_mode == TERRAIN_MODE_USE_HEIGHT_MAP) {\n vec3 anchor = geometry.worldPosition;\n anchor.z = 0.0;\n vec3 anchorCommon = project_position(anchor);\n vec2 texCoords = (anchorCommon.xy - terrain_bounds.xy) / terrain_bounds.zw;\n if (texCoords.x >= 0.0 && texCoords.y >= 0.0 && texCoords.x <= 1.0 && texCoords.y <= 1.0) {\n float terrainZ = texture(terrain_map, texCoords).r;\n geometry.position.z += terrainZ;\n position = project_common_position_to_clipspace(geometry.position);\n }\n}\n `,\n 'fs:#decl': `\nuniform float terrain_mode;\nuniform sampler2D terrain_map;\nuniform vec4 terrain_bounds;\nin vec3 commonPos;\n${TERRAIN_MODE_CONSTANTS}\n `,\n 'fs:#main-start': `\nif (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {\n fragColor = vec4(commonPos.z, 0.0, 0.0, 1.0);\n return;\n}\n `,\n 'fs:DECKGL_FILTER_COLOR': `\nif ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY)) {\n vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;\n vec4 pixel = texture(terrain_map, texCoords);\n if (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY) {\n color = pixel;\n } else {\n // pixel is premultiplied\n color = pixel + color * (1.0 - pixel.a);\n }\n return;\n}\n `\n },\n // eslint-disable-next-line complexity\n getUniforms: (opts: Partial<TerrainModuleSettings> = {}, uniforms) => {\n if ('dummyHeightMap' in opts) {\n const {\n drawToTerrainHeightMap,\n heightMap,\n heightMapBounds,\n dummyHeightMap,\n terrainCover,\n useTerrainHeightMap,\n terrainSkipRender\n } = opts;\n const {project_uCommonOrigin} = uniforms;\n\n let mode: number = terrainSkipRender ? TERRAIN_MODE.SKIP : TERRAIN_MODE.NONE;\n // height map if case USE_HEIGHT_MAP, terrain cover if USE_COVER, otherwise empty\n let sampler = dummyHeightMap as Texture;\n // height map bounds if case USE_HEIGHT_MAP, terrain cover bounds if USE_COVER, otherwise null\n let bounds: number[] | null = null;\n if (drawToTerrainHeightMap) {\n mode = TERRAIN_MODE.WRITE_HEIGHT_MAP;\n bounds = heightMapBounds!;\n } else if (useTerrainHeightMap && heightMap) {\n mode = TERRAIN_MODE.USE_HEIGHT_MAP;\n sampler = heightMap;\n bounds = heightMapBounds!;\n } else if (terrainCover) {\n // This is a terrain layer\n const isPicking = opts.pickingActive;\n // @ts-expect-error\n sampler = isPicking\n ? terrainCover.getPickingFramebuffer()\n : terrainCover.getRenderFramebuffer();\n if (isPicking) {\n // Never render the layer itself in picking pass\n mode = TERRAIN_MODE.SKIP;\n }\n if (sampler) {\n mode = mode === TERRAIN_MODE.SKIP ? TERRAIN_MODE.USE_COVER_ONLY : TERRAIN_MODE.USE_COVER;\n bounds = terrainCover.bounds;\n } else {\n sampler = dummyHeightMap!;\n }\n }\n\n /* eslint-disable camelcase */\n return {\n terrain_mode: mode,\n terrain_map: sampler,\n // Convert bounds to the common space, as [minX, minY, width, height]\n terrain_bounds: bounds\n ? [\n bounds[0] - project_uCommonOrigin[0],\n bounds[1] - project_uCommonOrigin[1],\n bounds[2] - bounds[0],\n bounds[3] - bounds[1]\n ]\n : [0, 0, 0, 0]\n };\n }\n return null;\n }\n} as ShaderModule<TerrainModuleSettings>;\n"],"file":"shader-module.js"}
1
+ {"version":3,"sources":["../../../src/terrain/shader-module.ts"],"names":["TERRAIN_MODE","NONE","WRITE_HEIGHT_MAP","USE_HEIGHT_MAP","USE_COVER","USE_COVER_ONLY","SKIP","TERRAIN_MODE_CONSTANTS","Object","keys","map","key","join","terrainModule","name","dependencies","project","inject","getUniforms","opts","uniforms","drawToTerrainHeightMap","heightMap","heightMapBounds","dummyHeightMap","terrainCover","useTerrainHeightMap","terrainSkipRender","project_uCommonOrigin","mode","sampler","bounds","isPicking","picking","isActive","getPickingFramebuffer","getRenderFramebuffer","terrain_mode","terrain_map","terrain_bounds"],"mappings":";;;;;;;AAGA;;AAmBO,IAAMA,YAAY,GAAG;AAC1BC,EAAAA,IAAI,EAAE,CADoB;AAG1BC,EAAAA,gBAAgB,EAAE,CAHQ;AAK1BC,EAAAA,cAAc,EAAE,CALU;AAO1BC,EAAAA,SAAS,EAAE,CAPe;AAS1BC,EAAAA,cAAc,EAAE,CATU;AAW1BC,EAAAA,IAAI,EAAE;AAXoB,CAArB;;AAcP,IAAMC,sBAAsB,GAAGC,MAAM,CAACC,IAAP,CAAYT,YAAZ,EAC5BU,GAD4B,CACxB,UAAAC,GAAG;AAAA,4CAAgCA,GAAhC,gBAAyCX,YAAY,CAACW,GAAD,CAArD;AAAA,CADqB,EAE5BC,IAF4B,CAEvB,IAFuB,CAA/B;AAKO,IAAMC,aAAa,GAAG;AAC3BC,EAAAA,IAAI,EAAE,SADqB;AAE3BC,EAAAA,YAAY,EAAE,CAACC,aAAD,CAFa;AAG3BC,EAAAA,MAAM,EAAE;AACN,4IAKFV,sBALE,WADM;AAQN,8GARM;AAcN,ozBAdM;AAiCN,2IAKFA,sBALE,WAjCM;AAwCN,mJAxCM;AA8CN;AA9CM,GAHmB;AAgE3BW,EAAAA,WAAW,EAAE,uBAAyD;AAAA,QAAxDC,IAAwD,uEAAjB,EAAiB;AAAA,QAAbC,QAAa;;AACpE,QAAI,oBA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K,cAA1C,GAA2DL,YAAY,CAACI,SAA/E;AACA2B,UAAAA,MAAM,GAAGN,YAAY,CAACM,MAAtB;AACD,SAHD,MAGO;AACLD,UAAAA,OAAO,GAAGN,cAAV;AACD;AACF;;AAGD,aAAO;AACLa,QAAAA,YAAY,EAAER,IADT;AAELS,QAAAA,WAAW,EAAER,OAFR;AAILS,QAAAA,cAAc,EAAER,MAAM,GAClB,CACEA,MAAM,CAAC,CAAD,CAAN,GAAYH,qBAAqB,CAAC,CAAD,CADnC,EAEEG,MAAM,CAAC,CAAD,CAAN,GAAYH,qBAAqB,CAAC,CAAD,CAFnC,EAGEG,MAAM,CAAC,CAAD,CAAN,GAAYA,MAAM,CAAC,CAAD,CAHpB,EAIEA,MAAM,CAAC,CAAD,CAAN,GAAYA,MAAM,CAAC,CAAD,CAJpB,CADkB,GAOlB,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV;AAXC,OAAP;AAaD;;AACD,WAAO,IAAP;AACD;AA5H0B,CAAtB","sourcesContent":["/* eslint-disable camelcase */\n\nimport type {ShaderModule} from '@luma.gl/shadertools';\nimport {project} from '@deck.gl/core';\n\nimport type {Texture} from '@luma.gl/core';\nimport type {Bounds} from '../utils/projection-utils';\nimport type {TerrainCover} from './terrain-cover';\n\n/** Module parameters expected by the terrain shader module */\nexport type TerrainModuleSettings = {\n picking: {isActive?: boolean};\n heightMap: Texture | null;\n heightMapBounds?: Bounds | null;\n dummyHeightMap: Texture;\n terrainCover?: TerrainCover | null;\n drawToTerrainHeightMap?: boolean;\n useTerrainHeightMap?: boolean;\n terrainSkipRender?: boolean;\n};\n\n/** A model can have one of the following modes */\nexport const TERRAIN_MODE = {\n NONE: 0,\n /** A terrain layer rendering encoded ground elevation into the height map */\n WRITE_HEIGHT_MAP: 1,\n /** An offset layer reading encoded ground elevation from the height map */\n USE_HEIGHT_MAP: 2,\n /** A terrain layer rendering to screen, using the cover fbo overlaid with its own texture */\n USE_COVER: 3,\n /** A terrain layer rendering to screen, using the cover fbo as texture */\n USE_COVER_ONLY: 4,\n /** Draped layer is rendered into a texture, and never to screen */\n SKIP: 5\n};\n\nconst TERRAIN_MODE_CONSTANTS = Object.keys(TERRAIN_MODE)\n .map(key => `const float TERRAIN_MODE_${key} = ${TERRAIN_MODE[key]}.0;`)\n .join('\\n');\n\n// @ts-expect-error\nexport const terrainModule = {\n name: 'terrain',\n dependencies: [project],\n inject: {\n 'vs:#decl': `\nuniform float terrain_mode;\nuniform sampler2D terrain_map;\nuniform vec4 terrain_bounds;\nout vec3 commonPos;\n${TERRAIN_MODE_CONSTANTS}\n `,\n 'vs:#main-start': `\nif (terrain_mode == TERRAIN_MODE_SKIP) {\n gl_Position = vec4(0.0);\n return;\n}\n`,\n 'vs:DECKGL_FILTER_GL_POSITION': `\ncommonPos = geometry.position.xyz;\nif (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {\n vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;\n position = vec4(texCoords * 2.0 - 1.0, 0.0, 1.0);\n commonPos.z += project_uCommonOrigin.z;\n}\nif (terrain_mode == TERRAIN_MODE_USE_HEIGHT_MAP) {\n vec3 anchor = geometry.worldPosition;\n anchor.z = 0.0;\n vec3 anchorCommon = project_position(anchor);\n vec2 texCoords = (anchorCommon.xy - terrain_bounds.xy) / terrain_bounds.zw;\n if (texCoords.x >= 0.0 && texCoords.y >= 0.0 && texCoords.x <= 1.0 && texCoords.y <= 1.0) {\n float terrainZ = texture(terrain_map, texCoords).r;\n geometry.position.z += terrainZ;\n position = project_common_position_to_clipspace(geometry.position);\n }\n}\n `,\n 'fs:#decl': `\nuniform float terrain_mode;\nuniform sampler2D terrain_map;\nuniform vec4 terrain_bounds;\nin vec3 commonPos;\n${TERRAIN_MODE_CONSTANTS}\n `,\n 'fs:#main-start': `\nif (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {\n fragColor = vec4(commonPos.z, 0.0, 0.0, 1.0);\n return;\n}\n `,\n 'fs:DECKGL_FILTER_COLOR': `\nif ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY)) {\n vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;\n vec4 pixel = texture(terrain_map, texCoords);\n if (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY) {\n color = pixel;\n } else {\n // pixel is premultiplied\n color = pixel + color * (1.0 - pixel.a);\n }\n return;\n}\n `\n },\n // eslint-disable-next-line complexity\n getUniforms: (opts: Partial<TerrainModuleSettings> = {}, uniforms) => {\n if ('dummyHeightMap' in opts) {\n const {\n drawToTerrainHeightMap,\n heightMap,\n heightMapBounds,\n dummyHeightMap,\n terrainCover,\n useTerrainHeightMap,\n terrainSkipRender\n } = opts;\n const {project_uCommonOrigin} = uniforms;\n\n let mode: number = terrainSkipRender ? TERRAIN_MODE.SKIP : TERRAIN_MODE.NONE;\n // height map if case USE_HEIGHT_MAP, terrain cover if USE_COVER, otherwise empty\n let sampler = dummyHeightMap as Texture;\n // height map bounds if case USE_HEIGHT_MAP, terrain cover bounds if USE_COVER, otherwise null\n let bounds: number[] | null = null;\n if (drawToTerrainHeightMap) {\n mode = TERRAIN_MODE.WRITE_HEIGHT_MAP;\n bounds = heightMapBounds!;\n } else if (useTerrainHeightMap && heightMap) {\n mode = TERRAIN_MODE.USE_HEIGHT_MAP;\n sampler = heightMap;\n bounds = heightMapBounds!;\n } else if (terrainCover) {\n // This is a terrain layer\n const isPicking = opts.picking?.isActive;\n // @ts-expect-error\n sampler = isPicking\n ? terrainCover.getPickingFramebuffer()\n : terrainCover.getRenderFramebuffer();\n if (isPicking) {\n // Never render the layer itself in picking pass\n mode = TERRAIN_MODE.SKIP;\n }\n if (sampler) {\n mode = mode === TERRAIN_MODE.SKIP ? TERRAIN_MODE.USE_COVER_ONLY : TERRAIN_MODE.USE_COVER;\n bounds = terrainCover.bounds;\n } else {\n sampler = dummyHeightMap!;\n }\n }\n\n /* eslint-disable camelcase */\n return {\n terrain_mode: mode,\n terrain_map: sampler,\n // Convert bounds to the common space, as [minX, minY, width, height]\n terrain_bounds: bounds\n ? [\n bounds[0] - project_uCommonOrigin[0],\n bounds[1] - project_uCommonOrigin[1],\n bounds[2] - bounds[0],\n bounds[3] - bounds[1]\n ]\n : [0, 0, 0, 0]\n };\n }\n return null;\n }\n} as ShaderModule<TerrainModuleSettings>;\n"],"file":"shader-module.js"}
@@ -20,8 +20,10 @@ export default class CollisionFilterPass extends LayersPass {
20
20
  getModuleParameters() {
21
21
  return {
22
22
  drawToCollisionMap: true,
23
- pickingActive: 1,
24
- pickingAttribute: false,
23
+ picking: {
24
+ isActive: 1,
25
+ isAttribute: false
26
+ },
25
27
  lightSources: {}
26
28
  };
27
29
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collision-filter/collision-filter-pass.ts"],"names":["withGLParameters","_LayersPass","LayersPass","CollisionFilterPass","renderCollisionMap","target","options","padding","clearColor","device","scissorTest","scissor","width","height","blend","depthTest","depthRange","render","pass","getModuleParameters","drawToCollisionMap","pickingActive","pickingAttribute","lightSources"],"mappings":"AACA,SAAQA,gBAAR,QAA+B,gBAA/B;AACA,SAAQC,WAAW,IAAIC,UAAvB,QAAiE,eAAjE;AAIA,eAAe,MAAMC,mBAAN,SAAkCD,UAAlC,CAA6C;AAC1DE,EAAAA,kBAAkB,CAACC,MAAD,EAAsBC,OAAtB,EAAiE;AACjF,UAAMC,OAAO,GAAG,CAAhB;AACA,UAAMC,UAAU,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAnB;AAEA,WAAOR,gBAAgB,CACrB,KAAKS,MADgB,EAErB;AACEC,MAAAA,WAAW,EAAE,IADf;AAEEC,MAAAA,OAAO,EAAE,CAACJ,OAAD,EAAUA,OAAV,EAAmBF,MAAM,CAACO,KAAP,GAAe,IAAIL,OAAtC,EAA+CF,MAAM,CAACQ,MAAP,GAAgB,IAAIN,OAAnE,CAFX;AAGEO,MAAAA,KAAK,EAAE,KAHT;AAIEC,MAAAA,SAAS,EAAE,IAJb;AAKEC,MAAAA,UAAU,EAAE,CAAC,CAAD,EAAI,CAAJ;AALd,KAFqB,EASrB,MAAM,KAAKC,MAAL,CAAY,EAAC,GAAGX,OAAJ;AAAaE,MAAAA,UAAb;AAAyBH,MAAAA,MAAzB;AAAiCa,MAAAA,IAAI,EAAE;AAAvC,KAAZ,CATe,CAAvB;AAWD;;AAEDC,EAAAA,mBAAmB,GAAG;AAEpB,WAAO;AACLC,MAAAA,kBAAkB,EAAE,IADf;AAELC,MAAAA,aAAa,EAAE,CAFV;AAGLC,MAAAA,gBAAgB,EAAE,KAHb;AAILC,MAAAA,YAAY,EAAE;AAJT,KAAP;AAMD;;AA1ByD","sourcesContent":["import {Framebuffer} from '@luma.gl/core';\nimport {withGLParameters} from '@luma.gl/webgl';\nimport {_LayersPass as LayersPass, LayersPassRenderOptions} from '@deck.gl/core';\n\ntype CollisionFilterPassRenderOptions = LayersPassRenderOptions & {};\n\nexport default class CollisionFilterPass extends LayersPass {\n renderCollisionMap(target: Framebuffer, options: CollisionFilterPassRenderOptions) {\n const padding = 1;\n const clearColor = [0, 0, 0, 0];\n\n return withGLParameters(\n this.device,\n {\n scissorTest: true,\n scissor: [padding, padding, target.width - 2 * padding, target.height - 2 * padding],\n blend: false,\n depthTest: true,\n depthRange: [0, 1]\n },\n () => this.render({...options, clearColor, target, pass: 'collision'})\n );\n }\n\n getModuleParameters() {\n // Draw picking colors into collision FBO\n return {\n drawToCollisionMap: true,\n pickingActive: 1,\n pickingAttribute: false,\n lightSources: {}\n };\n }\n}\n"],"file":"collision-filter-pass.js"}
1
+ {"version":3,"sources":["../../../src/collision-filter/collision-filter-pass.ts"],"names":["withGLParameters","_LayersPass","LayersPass","CollisionFilterPass","renderCollisionMap","target","options","padding","clearColor","device","scissorTest","scissor","width","height","blend","depthTest","depthRange","render","pass","getModuleParameters","drawToCollisionMap","picking","isActive","isAttribute","lightSources"],"mappings":"AACA,SAAQA,gBAAR,QAA+B,gBAA/B;AACA,SAAQC,WAAW,IAAIC,UAAvB,QAAiE,eAAjE;AAIA,eAAe,MAAMC,mBAAN,SAAkCD,UAAlC,CAA6C;AAC1DE,EAAAA,kBAAkB,CAACC,MAAD,EAAsBC,OAAtB,EAAiE;AACjF,UAAMC,OAAO,GAAG,CAAhB;AACA,UAAMC,UAAU,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAnB;AAEA,WAAOR,gBAAgB,CACrB,KAAKS,MADgB,EAErB;AACEC,MAAAA,WAAW,EAAE,IADf;AAEEC,MAAAA,OAAO,EAAE,CAACJ,OAAD,EAAUA,OAAV,EAAmBF,MAAM,CAACO,KAAP,GAAe,IAAIL,OAAtC,EAA+CF,MAAM,CAACQ,MAAP,GAAgB,IAAIN,OAAnE,CAFX;AAGEO,MAAAA,KAAK,EAAE,KAHT;AAIEC,MAAAA,SAAS,EAAE,IAJb;AAKEC,MAAAA,UAAU,EAAE,CAAC,CAAD,EAAI,CAAJ;AALd,KAFqB,EASrB,MAAM,KAAKC,MAAL,CAAY,EAAC,GAAGX,OAAJ;AAAaE,MAAAA,UAAb;AAAyBH,MAAAA,MAAzB;AAAiCa,MAAAA,IAAI,EAAE;AAAvC,KAAZ,CATe,CAAvB;AAWD;;AAEDC,EAAAA,mBAAmB,GAAG;AAEpB,WAAO;AACLC,MAAAA,kBAAkB,EAAE,IADf;AAELC,MAAAA,OAAO,EAAE;AACPC,QAAAA,QAAQ,EAAE,CADH;AAEPC,QAAAA,WAAW,EAAE;AAFN,OAFJ;AAMLC,MAAAA,YAAY,EAAE;AANT,KAAP;AAQD;;AA5ByD","sourcesContent":["import {Framebuffer} from '@luma.gl/core';\nimport {withGLParameters} from '@luma.gl/webgl';\nimport {_LayersPass as LayersPass, LayersPassRenderOptions} from '@deck.gl/core';\n\ntype CollisionFilterPassRenderOptions = LayersPassRenderOptions & {};\n\nexport default class CollisionFilterPass extends LayersPass {\n renderCollisionMap(target: Framebuffer, options: CollisionFilterPassRenderOptions) {\n const padding = 1;\n const clearColor = [0, 0, 0, 0];\n\n return withGLParameters(\n this.device,\n {\n scissorTest: true,\n scissor: [padding, padding, target.width - 2 * padding, target.height - 2 * padding],\n blend: false,\n depthTest: true,\n depthRange: [0, 1]\n },\n () => this.render({...options, clearColor, target, pass: 'collision'})\n );\n }\n\n getModuleParameters() {\n // Draw picking colors into collision FBO\n return {\n drawToCollisionMap: true,\n picking: {\n isActive: 1,\n isAttribute: false\n },\n lightSources: {}\n };\n }\n}\n"],"file":"collision-filter-pass.js"}
@@ -97,7 +97,9 @@ if ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_US
97
97
  sampler = heightMap;
98
98
  bounds = heightMapBounds;
99
99
  } else if (terrainCover) {
100
- const isPicking = opts.pickingActive;
100
+ var _opts$picking;
101
+
102
+ const isPicking = (_opts$picking = opts.picking) === null || _opts$picking === void 0 ? void 0 : _opts$picking.isActive;
101
103
  sampler = isPicking ? terrainCover.getPickingFramebuffer() : terrainCover.getRenderFramebuffer();
102
104
 
103
105
  if (isPicking) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/terrain/shader-module.ts"],"names":["project","TERRAIN_MODE","NONE","WRITE_HEIGHT_MAP","USE_HEIGHT_MAP","USE_COVER","USE_COVER_ONLY","SKIP","TERRAIN_MODE_CONSTANTS","Object","keys","map","key","join","terrainModule","name","dependencies","inject","getUniforms","opts","uniforms","drawToTerrainHeightMap","heightMap","heightMapBounds","dummyHeightMap","terrainCover","useTerrainHeightMap","terrainSkipRender","project_uCommonOrigin","mode","sampler","bounds","isPicking","pickingActive","getPickingFramebuffer","getRenderFramebuffer","terrain_mode","terrain_map","terrain_bounds"],"mappings":"AAGA,SAAQA,OAAR,QAAsB,eAAtB;AAmBA,OAAO,MAAMC,YAAY,GAAG;AAC1BC,EAAAA,IAAI,EAAE,CADoB;AAG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M,CAAC,CAAD,CAAN,GAAYA,MAAM,CAAC,CAAD,CAHpB,EAIEA,MAAM,CAAC,CAAD,CAAN,GAAYA,MAAM,CAAC,CAAD,CAJpB,CADkB,GAOlB,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV;AAXC,OAAP;AAaD;;AACD,WAAO,IAAP;AACD;AA5H0B,CAAtB","sourcesContent":["/* eslint-disable camelcase */\n\nimport type {ShaderModule} from '@luma.gl/shadertools';\nimport {project} from '@deck.gl/core';\n\nimport type {Texture} from '@luma.gl/core';\nimport type {Bounds} from '../utils/projection-utils';\nimport type {TerrainCover} from './terrain-cover';\n\n/** Module parameters expected by the terrain shader module */\nexport type TerrainModuleSettings = {\n pickingActive?: boolean;\n heightMap: Texture | null;\n heightMapBounds?: Bounds | null;\n dummyHeightMap: Texture;\n terrainCover?: TerrainCover | null;\n drawToTerrainHeightMap?: boolean;\n useTerrainHeightMap?: boolean;\n terrainSkipRender?: boolean;\n};\n\n/** A model can have one of the following modes */\nexport const TERRAIN_MODE = {\n NONE: 0,\n /** A terrain layer rendering encoded ground elevation into the height map */\n WRITE_HEIGHT_MAP: 1,\n /** An offset layer reading encoded ground elevation from the height map */\n USE_HEIGHT_MAP: 2,\n /** A terrain layer rendering to screen, using the cover fbo overlaid with its own texture */\n USE_COVER: 3,\n /** A terrain layer rendering to screen, using the cover fbo as texture */\n USE_COVER_ONLY: 4,\n /** Draped layer is rendered into a texture, and never to screen */\n SKIP: 5\n};\n\nconst TERRAIN_MODE_CONSTANTS = Object.keys(TERRAIN_MODE)\n .map(key => `const float TERRAIN_MODE_${key} = ${TERRAIN_MODE[key]}.0;`)\n .join('\\n');\n\n// @ts-expect-error\nexport const terrainModule = {\n name: 'terrain',\n dependencies: [project],\n inject: {\n 'vs:#decl': `\nuniform float terrain_mode;\nuniform sampler2D terrain_map;\nuniform vec4 terrain_bounds;\nout vec3 commonPos;\n${TERRAIN_MODE_CONSTANTS}\n `,\n 'vs:#main-start': `\nif (terrain_mode == TERRAIN_MODE_SKIP) {\n gl_Position = vec4(0.0);\n return;\n}\n`,\n 'vs:DECKGL_FILTER_GL_POSITION': `\ncommonPos = geometry.position.xyz;\nif (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {\n vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;\n position = vec4(texCoords * 2.0 - 1.0, 0.0, 1.0);\n commonPos.z += project_uCommonOrigin.z;\n}\nif (terrain_mode == TERRAIN_MODE_USE_HEIGHT_MAP) {\n vec3 anchor = geometry.worldPosition;\n anchor.z = 0.0;\n vec3 anchorCommon = project_position(anchor);\n vec2 texCoords = (anchorCommon.xy - terrain_bounds.xy) / terrain_bounds.zw;\n if (texCoords.x >= 0.0 && texCoords.y >= 0.0 && texCoords.x <= 1.0 && texCoords.y <= 1.0) {\n float terrainZ = texture(terrain_map, texCoords).r;\n geometry.position.z += terrainZ;\n position = project_common_position_to_clipspace(geometry.position);\n }\n}\n `,\n 'fs:#decl': `\nuniform float terrain_mode;\nuniform sampler2D terrain_map;\nuniform vec4 terrain_bounds;\nin vec3 commonPos;\n${TERRAIN_MODE_CONSTANTS}\n `,\n 'fs:#main-start': `\nif (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {\n fragColor = vec4(commonPos.z, 0.0, 0.0, 1.0);\n return;\n}\n `,\n 'fs:DECKGL_FILTER_COLOR': `\nif ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY)) {\n vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;\n vec4 pixel = texture(terrain_map, texCoords);\n if (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY) {\n color = pixel;\n } else {\n // pixel is premultiplied\n color = pixel + color * (1.0 - pixel.a);\n }\n return;\n}\n `\n },\n // eslint-disable-next-line complexity\n getUniforms: (opts: Partial<TerrainModuleSettings> = {}, uniforms) => {\n if ('dummyHeightMap' in opts) {\n const {\n drawToTerrainHeightMap,\n heightMap,\n heightMapBounds,\n dummyHeightMap,\n terrainCover,\n useTerrainHeightMap,\n terrainSkipRender\n } = opts;\n const {project_uCommonOrigin} = uniforms;\n\n let mode: number = terrainSkipRender ? TERRAIN_MODE.SKIP : TERRAIN_MODE.NONE;\n // height map if case USE_HEIGHT_MAP, terrain cover if USE_COVER, otherwise empty\n let sampler = dummyHeightMap as Texture;\n // height map bounds if case USE_HEIGHT_MAP, terrain cover bounds if USE_COVER, otherwise null\n let bounds: number[] | null = null;\n if (drawToTerrainHeightMap) {\n mode = TERRAIN_MODE.WRITE_HEIGHT_MAP;\n bounds = heightMapBounds!;\n } else if (useTerrainHeightMap && heightMap) {\n mode = TERRAIN_MODE.USE_HEIGHT_MAP;\n sampler = heightMap;\n bounds = heightMapBounds!;\n } else if (terrainCover) {\n // This is a terrain layer\n const isPicking = opts.pickingActive;\n // @ts-expect-error\n sampler = isPicking\n ? terrainCover.getPickingFramebuffer()\n : terrainCover.getRenderFramebuffer();\n if (isPicking) {\n // Never render the layer itself in picking pass\n mode = TERRAIN_MODE.SKIP;\n }\n if (sampler) {\n mode = mode === TERRAIN_MODE.SKIP ? TERRAIN_MODE.USE_COVER_ONLY : TERRAIN_MODE.USE_COVER;\n bounds = terrainCover.bounds;\n } else {\n sampler = dummyHeightMap!;\n }\n }\n\n /* eslint-disable camelcase */\n return {\n terrain_mode: mode,\n terrain_map: sampler,\n // Convert bounds to the common space, as [minX, minY, width, height]\n terrain_bounds: bounds\n ? [\n bounds[0] - project_uCommonOrigin[0],\n bounds[1] - project_uCommonOrigin[1],\n bounds[2] - bounds[0],\n bounds[3] - bounds[1]\n ]\n : [0, 0, 0, 0]\n };\n }\n return null;\n }\n} as ShaderModule<TerrainModuleSettings>;\n"],"file":"shader-module.js"}
1
+ {"version":3,"sources":["../../../src/terrain/shader-module.ts"],"names":["project","TERRAIN_MODE","NONE","WRITE_HEIGHT_MAP","USE_HEIGHT_MAP","USE_COVER","USE_COVER_ONLY","SKIP","TERRAIN_MODE_CONSTANTS","Object","keys","map","key","join","terrainModule","name","dependencies","inject","getUniforms","opts","uniforms","drawToTerrainHeightMap","heightMap","heightMapBounds","dummyHeightMap","terrainCover","useTerrainHeightMap","terrainSkipRender","project_uCommonOrigin","mode","sampler","bounds","isPicking","picking","isActive","getPickingFramebuffer","getRenderFramebuffer","terrain_mode","terrain_map","terrain_bounds"],"mappings":"AAGA,SAAQA,OAAR,QAAsB,eAAtB;AAmBA,OAAO,MAAMC,YAAY,GAAG;AAC1BC,EAAAA,IAAI,EAAE,CADoB;AAG1BC,EAAAA,gBAAgB,EAAE,CAHQ;AAK1BC,EAAAA,cAAc,EAAE,CALU;AAO1BC,EAAAA,SAAS,EAAE,CAPe;AAS1BC,EAAAA,cAAc,EAAE,CATU;AAW1BC,EAAAA,IAAI,EAAE;AAXoB,CAArB;AAcP,MAAMC,sBAAsB,GAAGC,MAAM,CAACC,IAAP,CAAYT,YAAZ,EAC5BU,GAD4B,CACxBC,GAAG,IAAK,4BAA2BA,GAAI,MAAKX,YAAY,CAACW,GAAD,CAAM,KADtC,EAE5BC,IAF4B,CAEvB,IAFuB,CAA/B;AAKA,OAAO,MAAMC,aAAa,GAAG;AAC3BC,EAAAA,IAAI,EAAE,SADqB;AAE3BC,EAAAA,YAAY,EAAE,CAAChB,OAAD,CAFa;AAG3BiB,EAAAA,MAAM,EAAE;AACN,gBAAa;AACjB;AACA;AACA;AACA;AACA,EAAET,sBAAuB;AACzB,KAPU;AAQN,sBAAmB;AACvB;AACA;AACA;AACA;AACA,CAbU;AAcN,oCAAiC;AACrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAhCU;AAiCN,gBAAa;AACjB;AACA;AACA;AACA;AACA,EAAEA,sBAAuB;AACzB,KAvCU;AAwCN,sBAAmB;AACvB;AACA;AACA;AACA;AACA,KA7CU;AA8CN,8BAA2B;AAC/B;AACA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,cAA1C,GAA2DL,YAAY,CAACI,SAA/E;AACA0B,UAAAA,MAAM,GAAGN,YAAY,CAACM,MAAtB;AACD,SAHD,MAGO;AACLD,UAAAA,OAAO,GAAGN,cAAV;AACD;AACF;;AAGD,aAAO;AACLa,QAAAA,YAAY,EAAER,IADT;AAELS,QAAAA,WAAW,EAAER,OAFR;AAILS,QAAAA,cAAc,EAAER,MAAM,GAClB,CACEA,MAAM,CAAC,CAAD,CAAN,GAAYH,qBAAqB,CAAC,CAAD,CADnC,EAEEG,MAAM,CAAC,CAAD,CAAN,GAAYH,qBAAqB,CAAC,CAAD,CAFnC,EAGEG,MAAM,CAAC,CAAD,CAAN,GAAYA,MAAM,CAAC,CAAD,CAHpB,EAIEA,MAAM,CAAC,CAAD,CAAN,GAAYA,MAAM,CAAC,CAAD,CAJpB,CADkB,GAOlB,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV;AAXC,OAAP;AAaD;;AACD,WAAO,IAAP;AACD;AA5H0B,CAAtB","sourcesContent":["/* eslint-disable camelcase */\n\nimport type {ShaderModule} from '@luma.gl/shadertools';\nimport {project} from '@deck.gl/core';\n\nimport type {Texture} from '@luma.gl/core';\nimport type {Bounds} from '../utils/projection-utils';\nimport type {TerrainCover} from './terrain-cover';\n\n/** Module parameters expected by the terrain shader module */\nexport type TerrainModuleSettings = {\n picking: {isActive?: boolean};\n heightMap: Texture | null;\n heightMapBounds?: Bounds | null;\n dummyHeightMap: Texture;\n terrainCover?: TerrainCover | null;\n drawToTerrainHeightMap?: boolean;\n useTerrainHeightMap?: boolean;\n terrainSkipRender?: boolean;\n};\n\n/** A model can have one of the following modes */\nexport const TERRAIN_MODE = {\n NONE: 0,\n /** A terrain layer rendering encoded ground elevation into the height map */\n WRITE_HEIGHT_MAP: 1,\n /** An offset layer reading encoded ground elevation from the height map */\n USE_HEIGHT_MAP: 2,\n /** A terrain layer rendering to screen, using the cover fbo overlaid with its own texture */\n USE_COVER: 3,\n /** A terrain layer rendering to screen, using the cover fbo as texture */\n USE_COVER_ONLY: 4,\n /** Draped layer is rendered into a texture, and never to screen */\n SKIP: 5\n};\n\nconst TERRAIN_MODE_CONSTANTS = Object.keys(TERRAIN_MODE)\n .map(key => `const float TERRAIN_MODE_${key} = ${TERRAIN_MODE[key]}.0;`)\n .join('\\n');\n\n// @ts-expect-error\nexport const terrainModule = {\n name: 'terrain',\n dependencies: [project],\n inject: {\n 'vs:#decl': `\nuniform float terrain_mode;\nuniform sampler2D terrain_map;\nuniform vec4 terrain_bounds;\nout vec3 commonPos;\n${TERRAIN_MODE_CONSTANTS}\n `,\n 'vs:#main-start': `\nif (terrain_mode == TERRAIN_MODE_SKIP) {\n gl_Position = vec4(0.0);\n return;\n}\n`,\n 'vs:DECKGL_FILTER_GL_POSITION': `\ncommonPos = geometry.position.xyz;\nif (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {\n vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;\n position = vec4(texCoords * 2.0 - 1.0, 0.0, 1.0);\n commonPos.z += project_uCommonOrigin.z;\n}\nif (terrain_mode == TERRAIN_MODE_USE_HEIGHT_MAP) {\n vec3 anchor = geometry.worldPosition;\n anchor.z = 0.0;\n vec3 anchorCommon = project_position(anchor);\n vec2 texCoords = (anchorCommon.xy - terrain_bounds.xy) / terrain_bounds.zw;\n if (texCoords.x >= 0.0 && texCoords.y >= 0.0 && texCoords.x <= 1.0 && texCoords.y <= 1.0) {\n float terrainZ = texture(terrain_map, texCoords).r;\n geometry.position.z += terrainZ;\n position = project_common_position_to_clipspace(geometry.position);\n }\n}\n `,\n 'fs:#decl': `\nuniform float terrain_mode;\nuniform sampler2D terrain_map;\nuniform vec4 terrain_bounds;\nin vec3 commonPos;\n${TERRAIN_MODE_CONSTANTS}\n `,\n 'fs:#main-start': `\nif (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {\n fragColor = vec4(commonPos.z, 0.0, 0.0, 1.0);\n return;\n}\n `,\n 'fs:DECKGL_FILTER_COLOR': `\nif ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY)) {\n vec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;\n vec4 pixel = texture(terrain_map, texCoords);\n if (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY) {\n color = pixel;\n } else {\n // pixel is premultiplied\n color = pixel + color * (1.0 - pixel.a);\n }\n return;\n}\n `\n },\n // eslint-disable-next-line complexity\n getUniforms: (opts: Partial<TerrainModuleSettings> = {}, uniforms) => {\n if ('dummyHeightMap' in opts) {\n const {\n drawToTerrainHeightMap,\n heightMap,\n heightMapBounds,\n dummyHeightMap,\n terrainCover,\n useTerrainHeightMap,\n terrainSkipRender\n } = opts;\n const {project_uCommonOrigin} = uniforms;\n\n let mode: number = terrainSkipRender ? TERRAIN_MODE.SKIP : TERRAIN_MODE.NONE;\n // height map if case USE_HEIGHT_MAP, terrain cover if USE_COVER, otherwise empty\n let sampler = dummyHeightMap as Texture;\n // height map bounds if case USE_HEIGHT_MAP, terrain cover bounds if USE_COVER, otherwise null\n let bounds: number[] | null = null;\n if (drawToTerrainHeightMap) {\n mode = TERRAIN_MODE.WRITE_HEIGHT_MAP;\n bounds = heightMapBounds!;\n } else if (useTerrainHeightMap && heightMap) {\n mode = TERRAIN_MODE.USE_HEIGHT_MAP;\n sampler = heightMap;\n bounds = heightMapBounds!;\n } else if (terrainCover) {\n // This is a terrain layer\n const isPicking = opts.picking?.isActive;\n // @ts-expect-error\n sampler = isPicking\n ? terrainCover.getPickingFramebuffer()\n : terrainCover.getRenderFramebuffer();\n if (isPicking) {\n // Never render the layer itself in picking pass\n mode = TERRAIN_MODE.SKIP;\n }\n if (sampler) {\n mode = mode === TERRAIN_MODE.SKIP ? TERRAIN_MODE.USE_COVER_ONLY : TERRAIN_MODE.USE_COVER;\n bounds = terrainCover.bounds;\n } else {\n sampler = dummyHeightMap!;\n }\n }\n\n /* eslint-disable camelcase */\n return {\n terrain_mode: mode,\n terrain_map: sampler,\n // Convert bounds to the common space, as [minX, minY, width, height]\n terrain_bounds: bounds\n ? [\n bounds[0] - project_uCommonOrigin[0],\n bounds[1] - project_uCommonOrigin[1],\n bounds[2] - bounds[0],\n bounds[3] - bounds[1]\n ]\n : [0, 0, 0, 0]\n };\n }\n return null;\n }\n} as ShaderModule<TerrainModuleSettings>;\n"],"file":"shader-module.js"}