@deck.gl/extensions 9.0.0-beta.3 → 9.0.0-beta.5
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/brushing/shader-module.d.ts +1 -1
- package/dist/brushing/shader-module.d.ts.map +1 -1
- package/dist/data-filter/data-filter-extension.d.ts +38 -6
- package/dist/data-filter/data-filter-extension.d.ts.map +1 -1
- package/dist/data-filter/data-filter-extension.js +103 -13
- package/dist/data-filter/shader-module.d.ts +1 -1
- package/dist/data-filter/shader-module.d.ts.map +1 -1
- package/dist/data-filter/shader-module.js +31 -3
- package/dist/dist.dev.js +113 -19
- package/dist/index.cjs +114 -15
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +18 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/mask/mask-effect.d.ts +1 -1
- package/dist/mask/mask-effect.d.ts.map +1 -1
- package/dist/terrain/height-map-builder.d.ts +1 -1
- package/dist/terrain/height-map-builder.d.ts.map +1 -1
- package/dist/terrain/shader-module.d.ts +2 -2
- package/dist/terrain/shader-module.d.ts.map +1 -1
- package/dist/terrain/terrain-cover.d.ts +1 -1
- package/dist/terrain/terrain-cover.d.ts.map +1 -1
- package/dist/terrain/terrain-effect.d.ts +1 -1
- package/dist/terrain/terrain-effect.d.ts.map +1 -1
- package/dist/terrain/terrain-pass.d.ts +2 -2
- package/dist/terrain/terrain-pass.d.ts.map +1 -1
- package/dist/terrain/terrain-picking-pass.d.ts +1 -1
- package/dist/terrain/terrain-picking-pass.d.ts.map +1 -1
- package/dist.min.js +54 -26
- package/package.json +2 -2
- package/src/data-filter/data-filter-extension.ts +144 -22
- package/src/data-filter/shader-module.ts +31 -3
package/dist/index.cjs
CHANGED
|
@@ -207,13 +207,16 @@ uniform DATAFILTER_TYPE filter_max;
|
|
|
207
207
|
uniform bool filter_useSoftMargin;
|
|
208
208
|
uniform bool filter_enabled;
|
|
209
209
|
uniform bool filter_transformSize;
|
|
210
|
+
uniform ivec4 filter_categoryBitMask;
|
|
210
211
|
|
|
211
212
|
#ifdef NON_INSTANCED_MODEL
|
|
212
213
|
#define DATAFILTER_ATTRIB filterValues
|
|
213
214
|
#define DATAFILTER_ATTRIB_64LOW filterValues64Low
|
|
215
|
+
#define DATACATEGORY_ATTRIB filterCategoryValues
|
|
214
216
|
#else
|
|
215
217
|
#define DATAFILTER_ATTRIB instanceFilterValues
|
|
216
218
|
#define DATAFILTER_ATTRIB_64LOW instanceFilterValues64Low
|
|
219
|
+
#define DATACATEGORY_ATTRIB instanceFilterCategoryValues
|
|
217
220
|
#endif
|
|
218
221
|
|
|
219
222
|
in DATAFILTER_TYPE DATAFILTER_ATTRIB;
|
|
@@ -223,6 +226,7 @@ in DATAFILTER_TYPE DATAFILTER_ATTRIB;
|
|
|
223
226
|
uniform DATAFILTER_TYPE filter_min64High;
|
|
224
227
|
uniform DATAFILTER_TYPE filter_max64High;
|
|
225
228
|
#endif
|
|
229
|
+
in DATACATEGORY_TYPE DATACATEGORY_ATTRIB;
|
|
226
230
|
|
|
227
231
|
out float dataFilter_value;
|
|
228
232
|
|
|
@@ -238,7 +242,7 @@ float dataFilter_reduceValue(vec3 value) {
|
|
|
238
242
|
float dataFilter_reduceValue(vec4 value) {
|
|
239
243
|
return min(min(value.x, value.y), min(value.z, value.w));
|
|
240
244
|
}
|
|
241
|
-
void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax) {
|
|
245
|
+
void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax, DATACATEGORY_TYPE category) {
|
|
242
246
|
if (filter_enabled) {
|
|
243
247
|
if (filter_useSoftMargin) {
|
|
244
248
|
dataFilter_value = dataFilter_reduceValue(
|
|
@@ -250,6 +254,29 @@ void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFrom
|
|
|
250
254
|
step(filter_min, valueFromMin) * step(valueFromMax, filter_max)
|
|
251
255
|
);
|
|
252
256
|
}
|
|
257
|
+
|
|
258
|
+
#if DATACATEGORY_CHANNELS == 1 // One 128-bit mask
|
|
259
|
+
int dataFilter_masks = filter_categoryBitMask[int(category / 32.0)];
|
|
260
|
+
#elif DATACATEGORY_CHANNELS == 2 // Two 64-bit masks
|
|
261
|
+
ivec2 dataFilter_masks = ivec2(
|
|
262
|
+
filter_categoryBitMask[int(category.x / 32.0)],
|
|
263
|
+
filter_categoryBitMask[int(category.y / 32.0) + 2]
|
|
264
|
+
);
|
|
265
|
+
#elif DATACATEGORY_CHANNELS == 3 // Three 32-bit masks
|
|
266
|
+
ivec3 dataFilter_masks = filter_categoryBitMask.xyz;
|
|
267
|
+
#else // Four 32-bit masks
|
|
268
|
+
ivec4 dataFilter_masks = filter_categoryBitMask;
|
|
269
|
+
#endif
|
|
270
|
+
|
|
271
|
+
// Shift mask and extract relevant bits
|
|
272
|
+
DATACATEGORY_TYPE dataFilter_bits = DATACATEGORY_TYPE(dataFilter_masks) / pow(DATACATEGORY_TYPE(2.0), mod(category, 32.0));
|
|
273
|
+
dataFilter_bits = mod(floor(dataFilter_bits), 2.0);
|
|
274
|
+
|
|
275
|
+
#if DATACATEGORY_CHANNELS == 1
|
|
276
|
+
if(dataFilter_bits == 0.0) dataFilter_value = 0.0;
|
|
277
|
+
#else
|
|
278
|
+
if(any(equal(dataFilter_bits, DATACATEGORY_TYPE(0.0)))) dataFilter_value = 0.0;
|
|
279
|
+
#endif
|
|
253
280
|
} else {
|
|
254
281
|
dataFilter_value = 1.0;
|
|
255
282
|
}
|
|
@@ -314,10 +341,11 @@ var inject2 = {
|
|
|
314
341
|
#ifdef DATAFILTER_DOUBLE
|
|
315
342
|
dataFilter_setValue(
|
|
316
343
|
DATAFILTER_ATTRIB - filter_min64High + DATAFILTER_ATTRIB_64LOW,
|
|
317
|
-
DATAFILTER_ATTRIB - filter_max64High + DATAFILTER_ATTRIB_64LOW
|
|
344
|
+
DATAFILTER_ATTRIB - filter_max64High + DATAFILTER_ATTRIB_64LOW,
|
|
345
|
+
DATACATEGORY_ATTRIB
|
|
318
346
|
);
|
|
319
347
|
#else
|
|
320
|
-
dataFilter_setValue(DATAFILTER_ATTRIB, DATAFILTER_ATTRIB);
|
|
348
|
+
dataFilter_setValue(DATAFILTER_ATTRIB, DATAFILTER_ATTRIB, DATACATEGORY_ATTRIB);
|
|
321
349
|
#endif
|
|
322
350
|
`,
|
|
323
351
|
"vs:#main-end": `
|
|
@@ -451,13 +479,21 @@ var parameters = {
|
|
|
451
479
|
// dist/data-filter/data-filter-extension.js
|
|
452
480
|
var defaultProps2 = {
|
|
453
481
|
getFilterValue: { type: "accessor", value: 0 },
|
|
482
|
+
getFilterCategory: { type: "accessor", value: 0 },
|
|
454
483
|
onFilteredItemsChange: { type: "function", value: null, optional: true },
|
|
455
484
|
filterEnabled: true,
|
|
456
485
|
filterRange: [-1, 1],
|
|
457
486
|
filterSoftRange: null,
|
|
487
|
+
filterCategories: [0],
|
|
458
488
|
filterTransformSize: true,
|
|
459
489
|
filterTransformColor: true
|
|
460
490
|
};
|
|
491
|
+
var defaultOptions = {
|
|
492
|
+
categorySize: 1,
|
|
493
|
+
filterSize: 1,
|
|
494
|
+
fp64: false,
|
|
495
|
+
countItems: false
|
|
496
|
+
};
|
|
461
497
|
var DATA_TYPE_FROM_SIZE = {
|
|
462
498
|
1: "float",
|
|
463
499
|
2: "vec2",
|
|
@@ -465,17 +501,16 @@ var DATA_TYPE_FROM_SIZE = {
|
|
|
465
501
|
4: "vec4"
|
|
466
502
|
};
|
|
467
503
|
var _DataFilterExtension = class extends import_core3.LayerExtension {
|
|
468
|
-
constructor(
|
|
469
|
-
|
|
470
|
-
throw new Error("filterSize out of range");
|
|
471
|
-
}
|
|
472
|
-
super({ filterSize, fp64: fp642, countItems });
|
|
504
|
+
constructor(opts) {
|
|
505
|
+
super({ ...defaultOptions, ...opts });
|
|
473
506
|
}
|
|
474
507
|
getShaders(extension) {
|
|
475
|
-
const { filterSize, fp64: fp642 } = extension.opts;
|
|
508
|
+
const { categorySize, filterSize, fp64: fp642 } = extension.opts;
|
|
476
509
|
return {
|
|
477
510
|
modules: [fp642 ? shaderModule64 : shaderModule],
|
|
478
511
|
defines: {
|
|
512
|
+
DATACATEGORY_TYPE: DATA_TYPE_FROM_SIZE[categorySize],
|
|
513
|
+
DATACATEGORY_CHANNELS: categorySize,
|
|
479
514
|
DATAFILTER_TYPE: DATA_TYPE_FROM_SIZE[filterSize],
|
|
480
515
|
DATAFILTER_DOUBLE: Boolean(fp642)
|
|
481
516
|
}
|
|
@@ -483,11 +518,12 @@ var _DataFilterExtension = class extends import_core3.LayerExtension {
|
|
|
483
518
|
}
|
|
484
519
|
initializeState(context, extension) {
|
|
485
520
|
const attributeManager = this.getAttributeManager();
|
|
521
|
+
const { categorySize, filterSize, fp64: fp642 } = extension.opts;
|
|
486
522
|
if (attributeManager) {
|
|
487
523
|
attributeManager.add({
|
|
488
524
|
filterValues: {
|
|
489
|
-
size:
|
|
490
|
-
type:
|
|
525
|
+
size: filterSize,
|
|
526
|
+
type: fp642 ? import_constants2.GL.DOUBLE : import_constants2.GL.FLOAT,
|
|
491
527
|
accessor: "getFilterValue",
|
|
492
528
|
shaderAttributes: {
|
|
493
529
|
filterValues: {
|
|
@@ -497,6 +533,20 @@ var _DataFilterExtension = class extends import_core3.LayerExtension {
|
|
|
497
533
|
divisor: 1
|
|
498
534
|
}
|
|
499
535
|
}
|
|
536
|
+
},
|
|
537
|
+
filterCategoryValues: {
|
|
538
|
+
size: categorySize,
|
|
539
|
+
type: import_constants2.GL.FLOAT,
|
|
540
|
+
accessor: "getFilterCategory",
|
|
541
|
+
transform: categorySize === 1 ? (d) => extension._getCategoryKey.call(this, d, 0) : (d) => d.map((x, i) => extension._getCategoryKey.call(this, x, i)),
|
|
542
|
+
shaderAttributes: {
|
|
543
|
+
filterCategoryValues: {
|
|
544
|
+
divisor: 0
|
|
545
|
+
},
|
|
546
|
+
instanceFilterCategoryValues: {
|
|
547
|
+
divisor: 1
|
|
548
|
+
}
|
|
549
|
+
}
|
|
500
550
|
}
|
|
501
551
|
});
|
|
502
552
|
}
|
|
@@ -528,29 +578,50 @@ var _DataFilterExtension = class extends import_core3.LayerExtension {
|
|
|
528
578
|
this.setState({ filterFBO, filterModel });
|
|
529
579
|
}
|
|
530
580
|
}
|
|
531
|
-
updateState({ props, oldProps }) {
|
|
581
|
+
updateState({ props, oldProps, changeFlags }, extension) {
|
|
582
|
+
var _a;
|
|
583
|
+
const attributeManager = this.getAttributeManager();
|
|
584
|
+
const { categorySize } = extension.opts;
|
|
532
585
|
if (this.state.filterModel) {
|
|
533
|
-
const attributeManager =
|
|
534
|
-
const filterNeedsUpdate = attributeManager.attributes.filterValues.needsUpdate() || props.filterEnabled !== oldProps.filterEnabled || props.filterRange !== oldProps.filterRange || props.filterSoftRange !== oldProps.filterSoftRange;
|
|
586
|
+
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;
|
|
535
587
|
if (filterNeedsUpdate) {
|
|
536
588
|
this.setState({ filterNeedsUpdate });
|
|
537
589
|
}
|
|
538
590
|
}
|
|
591
|
+
if (attributeManager == null ? void 0 : attributeManager.attributes.filterCategoryValues) {
|
|
592
|
+
const categoryBitMaskNeedsUpdate = attributeManager.attributes.filterCategoryValues.needsUpdate() || !(0, import_core3._deepEqual)(props.filterCategories, oldProps.filterCategories, 2);
|
|
593
|
+
if (categoryBitMaskNeedsUpdate) {
|
|
594
|
+
this.setState({ categoryBitMaskNeedsUpdate });
|
|
595
|
+
}
|
|
596
|
+
const resetCategories = changeFlags.dataChanged;
|
|
597
|
+
if (resetCategories) {
|
|
598
|
+
this.setState({
|
|
599
|
+
categoryMap: Array(categorySize).fill(0).map(() => ({}))
|
|
600
|
+
});
|
|
601
|
+
attributeManager.attributes.filterCategoryValues.setNeedsUpdate("categoryMap");
|
|
602
|
+
}
|
|
603
|
+
}
|
|
539
604
|
}
|
|
540
605
|
draw(params, extension) {
|
|
541
606
|
const filterFBO = this.state.filterFBO;
|
|
542
607
|
const filterModel = this.state.filterModel;
|
|
543
608
|
const filterNeedsUpdate = this.state.filterNeedsUpdate;
|
|
609
|
+
const categoryBitMaskNeedsUpdate = this.state.categoryBitMaskNeedsUpdate;
|
|
544
610
|
const { onFilteredItemsChange } = this.props;
|
|
611
|
+
if (categoryBitMaskNeedsUpdate) {
|
|
612
|
+
extension._updateCategoryBitMask.call(this, params, extension);
|
|
613
|
+
}
|
|
545
614
|
if (filterNeedsUpdate && onFilteredItemsChange && filterModel) {
|
|
546
|
-
const { attributes: { filterValues, filterIndices } } = this.getAttributeManager();
|
|
615
|
+
const { attributes: { filterValues, filterCategoryValues, filterIndices } } = this.getAttributeManager();
|
|
547
616
|
filterModel.setVertexCount(this.getNumInstances());
|
|
548
617
|
this.context.device.clearWebGL({ framebuffer: filterFBO, color: [0, 0, 0, 0] });
|
|
549
618
|
filterModel.updateModuleSettings(params.moduleParameters);
|
|
550
619
|
filterModel.setAttributes({
|
|
551
620
|
...filterValues.getValue(),
|
|
621
|
+
...filterCategoryValues == null ? void 0 : filterCategoryValues.getValue(),
|
|
552
622
|
...filterIndices == null ? void 0 : filterIndices.getValue()
|
|
553
623
|
});
|
|
624
|
+
filterModel.setUniforms(params.uniforms);
|
|
554
625
|
filterModel.device.withParametersWebGL({
|
|
555
626
|
framebuffer: filterFBO,
|
|
556
627
|
...parameters,
|
|
@@ -573,6 +644,34 @@ var _DataFilterExtension = class extends import_core3.LayerExtension {
|
|
|
573
644
|
filterFBO == null ? void 0 : filterFBO.destroy();
|
|
574
645
|
filterModel == null ? void 0 : filterModel.destroy();
|
|
575
646
|
}
|
|
647
|
+
_updateCategoryBitMask(params, extension) {
|
|
648
|
+
const { categorySize } = extension.opts;
|
|
649
|
+
const { filterCategories } = this.props;
|
|
650
|
+
const categoryBitMask = new Uint32Array([0, 0, 0, 0]);
|
|
651
|
+
const categoryFilters = categorySize === 1 ? [filterCategories] : filterCategories;
|
|
652
|
+
const maxCategories = categorySize === 1 ? 128 : categorySize === 2 ? 64 : 32;
|
|
653
|
+
for (let c = 0; c < categoryFilters.length; c++) {
|
|
654
|
+
const categoryFilter = categoryFilters[c];
|
|
655
|
+
for (const category of categoryFilter) {
|
|
656
|
+
const key = extension._getCategoryKey.call(this, category, c);
|
|
657
|
+
if (key < maxCategories) {
|
|
658
|
+
const channel = c * (maxCategories / 32) + Math.floor(key / 32);
|
|
659
|
+
categoryBitMask[channel] += Math.pow(2, key % 32);
|
|
660
|
+
} else {
|
|
661
|
+
import_core3.log.warn(`Exceeded maximum number of categories (${maxCategories})`)();
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
params.uniforms.filter_categoryBitMask = categoryBitMask;
|
|
666
|
+
this.state.categoryBitMaskNeedsUpdate = false;
|
|
667
|
+
}
|
|
668
|
+
_getCategoryKey(category, channel) {
|
|
669
|
+
const categoryMap = this.state.categoryMap[channel];
|
|
670
|
+
if (!(category in categoryMap)) {
|
|
671
|
+
categoryMap[category] = Object.keys(categoryMap).length;
|
|
672
|
+
}
|
|
673
|
+
return categoryMap[category];
|
|
674
|
+
}
|
|
576
675
|
};
|
|
577
676
|
var DataFilterExtension = _DataFilterExtension;
|
|
578
677
|
(() => {
|