@deck.gl/extensions 9.0.5 → 9.0.7

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/index.cjs CHANGED
@@ -193,22 +193,21 @@ var import_core3 = require("@deck.gl/core");
193
193
 
194
194
  // dist/data-filter/shader-module.js
195
195
  var vs2 = `
196
- uniform DATAFILTER_TYPE filter_min;
197
- uniform DATAFILTER_TYPE filter_softMin;
198
- uniform DATAFILTER_TYPE filter_softMax;
199
- uniform DATAFILTER_TYPE filter_max;
200
196
  uniform bool filter_useSoftMargin;
201
197
  uniform bool filter_enabled;
202
198
  uniform bool filter_transformSize;
203
199
  uniform ivec4 filter_categoryBitMask;
200
+ #ifdef DATAFILTER_TYPE
201
+ uniform DATAFILTER_TYPE filter_min;
202
+ uniform DATAFILTER_TYPE filter_softMin;
203
+ uniform DATAFILTER_TYPE filter_softMax;
204
+ uniform DATAFILTER_TYPE filter_max;
204
205
  #ifdef NON_INSTANCED_MODEL
205
206
  #define DATAFILTER_ATTRIB filterValues
206
207
  #define DATAFILTER_ATTRIB_64LOW filterValues64Low
207
- #define DATACATEGORY_ATTRIB filterCategoryValues
208
208
  #else
209
209
  #define DATAFILTER_ATTRIB instanceFilterValues
210
210
  #define DATAFILTER_ATTRIB_64LOW instanceFilterValues64Low
211
- #define DATACATEGORY_ATTRIB instanceFilterCategoryValues
212
211
  #endif
213
212
  in DATAFILTER_TYPE DATAFILTER_ATTRIB;
214
213
  #ifdef DATAFILTER_DOUBLE
@@ -216,7 +215,15 @@ in DATAFILTER_TYPE DATAFILTER_ATTRIB_64LOW;
216
215
  uniform DATAFILTER_TYPE filter_min64High;
217
216
  uniform DATAFILTER_TYPE filter_max64High;
218
217
  #endif
218
+ #endif
219
+ #ifdef DATACATEGORY_TYPE
220
+ #ifdef NON_INSTANCED_MODEL
221
+ #define DATACATEGORY_ATTRIB filterCategoryValues
222
+ #else
223
+ #define DATACATEGORY_ATTRIB instanceFilterCategoryValues
224
+ #endif
219
225
  in DATACATEGORY_TYPE DATACATEGORY_ATTRIB;
226
+ #endif
220
227
  out float dataFilter_value;
221
228
  float dataFilter_reduceValue(float value) {
222
229
  return value;
@@ -230,8 +237,8 @@ return min(min(value.x, value.y), value.z);
230
237
  float dataFilter_reduceValue(vec4 value) {
231
238
  return min(min(value.x, value.y), min(value.z, value.w));
232
239
  }
233
- void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax, DATACATEGORY_TYPE category) {
234
- if (filter_enabled) {
240
+ #ifdef DATAFILTER_ATTRIB
241
+ void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax) {
235
242
  if (filter_useSoftMargin) {
236
243
  dataFilter_value = dataFilter_reduceValue(
237
244
  smoothstep(filter_min, filter_softMin, valueFromMin) *
@@ -242,6 +249,10 @@ dataFilter_value = dataFilter_reduceValue(
242
249
  step(filter_min, valueFromMin) * step(valueFromMax, filter_max)
243
250
  );
244
251
  }
252
+ }
253
+ #endif
254
+ #ifdef DATACATEGORY_ATTRIB
255
+ void dataFilter_setCategoryValue(DATACATEGORY_TYPE category) {
245
256
  #if DATACATEGORY_CHANNELS == 1
246
257
  int dataFilter_masks = filter_categoryBitMask[int(category / 32.0)];
247
258
  #elif DATACATEGORY_CHANNELS == 2
@@ -261,10 +272,8 @@ if(dataFilter_bits == 0.0) dataFilter_value = 0.0;
261
272
  #else
262
273
  if(any(equal(dataFilter_bits, DATACATEGORY_TYPE(0.0)))) dataFilter_value = 0.0;
263
274
  #endif
264
- } else {
265
- dataFilter_value = 1.0;
266
- }
267
275
  }
276
+ #endif
268
277
  `;
269
278
  var fs2 = `
270
279
  uniform bool filter_transformColor;
@@ -322,15 +331,22 @@ function getUniforms64(opts) {
322
331
  }
323
332
  var inject2 = {
324
333
  "vs:#main-start": `
334
+ dataFilter_value = 1.0;
335
+ if (filter_enabled) {
336
+ #ifdef DATAFILTER_ATTRIB
325
337
  #ifdef DATAFILTER_DOUBLE
326
338
  dataFilter_setValue(
327
339
  DATAFILTER_ATTRIB - filter_min64High + DATAFILTER_ATTRIB_64LOW,
328
- DATAFILTER_ATTRIB - filter_max64High + DATAFILTER_ATTRIB_64LOW,
329
- DATACATEGORY_ATTRIB
340
+ DATAFILTER_ATTRIB - filter_max64High + DATAFILTER_ATTRIB_64LOW
330
341
  );
331
342
  #else
332
- dataFilter_setValue(DATAFILTER_ATTRIB, DATAFILTER_ATTRIB, DATACATEGORY_ATTRIB);
343
+ dataFilter_setValue(DATAFILTER_ATTRIB, DATAFILTER_ATTRIB);
344
+ #endif
333
345
  #endif
346
+ #ifdef DATACATEGORY_ATTRIB
347
+ dataFilter_setCategoryValue(DATACATEGORY_ATTRIB);
348
+ #endif
349
+ }
334
350
  `,
335
351
  "vs:#main-end": `
336
352
  if (dataFilter_value == 0.0) {
@@ -476,7 +492,7 @@ var defaultProps2 = {
476
492
  filterTransformColor: true
477
493
  };
478
494
  var defaultOptions = {
479
- categorySize: 1,
495
+ categorySize: 0,
480
496
  filterSize: 1,
481
497
  fp64: false,
482
498
  countItems: false
@@ -493,48 +509,55 @@ var _DataFilterExtension = class extends import_core3.LayerExtension {
493
509
  }
494
510
  getShaders(extension) {
495
511
  const { categorySize, filterSize, fp64: fp642 } = extension.opts;
496
- return {
497
- modules: [fp642 ? shaderModule64 : shaderModule],
498
- defines: {
499
- DATACATEGORY_TYPE: DATA_TYPE_FROM_SIZE[categorySize],
500
- DATACATEGORY_CHANNELS: categorySize,
501
- DATAFILTER_TYPE: DATA_TYPE_FROM_SIZE[filterSize],
502
- DATAFILTER_DOUBLE: Boolean(fp642)
503
- }
504
- };
512
+ const defines = {};
513
+ if (categorySize) {
514
+ defines.DATACATEGORY_TYPE = DATA_TYPE_FROM_SIZE[categorySize];
515
+ defines.DATACATEGORY_CHANNELS = categorySize;
516
+ }
517
+ if (filterSize) {
518
+ defines.DATAFILTER_TYPE = DATA_TYPE_FROM_SIZE[filterSize];
519
+ defines.DATAFILTER_DOUBLE = Boolean(fp642);
520
+ }
521
+ return { modules: [fp642 ? shaderModule64 : shaderModule], defines };
505
522
  }
506
523
  initializeState(context, extension) {
507
524
  const attributeManager = this.getAttributeManager();
508
525
  const { categorySize, filterSize, fp64: fp642 } = extension.opts;
509
526
  if (attributeManager) {
510
- attributeManager.add({
511
- filterValues: {
512
- size: filterSize,
513
- type: fp642 ? "float64" : "float32",
514
- accessor: "getFilterValue",
515
- shaderAttributes: {
516
- filterValues: {
517
- divisor: 0
518
- },
519
- instanceFilterValues: {
520
- divisor: 1
527
+ if (filterSize) {
528
+ attributeManager.add({
529
+ filterValues: {
530
+ size: filterSize,
531
+ type: fp642 ? "float64" : "float32",
532
+ accessor: "getFilterValue",
533
+ shaderAttributes: {
534
+ filterValues: {
535
+ divisor: 0
536
+ },
537
+ instanceFilterValues: {
538
+ divisor: 1
539
+ }
521
540
  }
522
541
  }
523
- },
524
- filterCategoryValues: {
525
- size: categorySize,
526
- accessor: "getFilterCategory",
527
- transform: categorySize === 1 ? (d) => extension._getCategoryKey.call(this, d, 0) : (d) => d.map((x, i) => extension._getCategoryKey.call(this, x, i)),
528
- shaderAttributes: {
529
- filterCategoryValues: {
530
- divisor: 0
531
- },
532
- instanceFilterCategoryValues: {
533
- divisor: 1
542
+ });
543
+ }
544
+ if (categorySize) {
545
+ attributeManager.add({
546
+ filterCategoryValues: {
547
+ size: categorySize,
548
+ accessor: "getFilterCategory",
549
+ transform: categorySize === 1 ? (d) => extension._getCategoryKey.call(this, d, 0) : (d) => d.map((x, i) => extension._getCategoryKey.call(this, x, i)),
550
+ shaderAttributes: {
551
+ filterCategoryValues: {
552
+ divisor: 0
553
+ },
554
+ instanceFilterCategoryValues: {
555
+ divisor: 1
556
+ }
534
557
  }
535
558
  }
536
- }
537
- });
559
+ });
560
+ }
538
561
  }
539
562
  const { device } = this.context;
540
563
  if (attributeManager && extension.opts.countItems) {
@@ -564,11 +587,11 @@ var _DataFilterExtension = class extends import_core3.LayerExtension {
564
587
  }
565
588
  }
566
589
  updateState({ props, oldProps, changeFlags }, extension) {
567
- var _a;
590
+ var _a, _b;
568
591
  const attributeManager = this.getAttributeManager();
569
592
  const { categorySize } = extension.opts;
570
593
  if (this.state.filterModel) {
571
- const filterNeedsUpdate = attributeManager.attributes.filterValues.needsUpdate() || ((_a = attributeManager.attributes.filterCategoryValues) == null ? void 0 : _a.needsUpdate()) || props.filterEnabled !== oldProps.filterEnabled || props.filterRange !== oldProps.filterRange || props.filterSoftRange !== oldProps.filterSoftRange || props.filterCategories !== oldProps.filterCategories;
594
+ const filterNeedsUpdate = ((_a = attributeManager.attributes.filterValues) == null ? void 0 : _a.needsUpdate()) || ((_b = attributeManager.attributes.filterCategoryValues) == null ? void 0 : _b.needsUpdate()) || props.filterEnabled !== oldProps.filterEnabled || props.filterRange !== oldProps.filterRange || props.filterSoftRange !== oldProps.filterSoftRange || props.filterCategories !== oldProps.filterCategories;
572
595
  if (filterNeedsUpdate) {
573
596
  this.setState({ filterNeedsUpdate });
574
597
  }
@@ -602,7 +625,7 @@ var _DataFilterExtension = class extends import_core3.LayerExtension {
602
625
  this.context.device.clearWebGL({ framebuffer: filterFBO, color: [0, 0, 0, 0] });
603
626
  filterModel.updateModuleSettings(params.moduleParameters);
604
627
  filterModel.setAttributes({
605
- ...filterValues.getValue(),
628
+ ...filterValues == null ? void 0 : filterValues.getValue(),
606
629
  ...filterCategoryValues == null ? void 0 : filterCategoryValues.getValue(),
607
630
  ...filterIndices == null ? void 0 : filterIndices.getValue()
608
631
  });
@@ -2195,11 +2218,12 @@ function createRenderTarget(device, opts) {
2195
2218
  type: 5126
2196
2219
  },
2197
2220
  mipmaps: false,
2198
- sampler: {
2221
+ sampler: opts.interpolate === false ? {
2222
+ minFilter: "nearest",
2223
+ magFilter: "nearest"
2224
+ } : {
2199
2225
  minFilter: "linear",
2200
- magFilter: "linear",
2201
- addressModeU: "clamp-to-edge",
2202
- addressModeV: "clamp-to-edge"
2226
+ magFilter: "linear"
2203
2227
  }
2204
2228
  })
2205
2229
  ]
@@ -2319,7 +2343,8 @@ var TerrainCover = class {
2319
2343
  }
2320
2344
  if (!this.pickingFbo) {
2321
2345
  this.pickingFbo = createRenderTarget(this.targetLayer.context.device, {
2322
- id: `${this.id}-picking`
2346
+ id: `${this.id}-picking`,
2347
+ interpolate: false
2323
2348
  });
2324
2349
  }
2325
2350
  return this.pickingFbo;