@deck.gl/extensions 9.0.0-beta.3 → 9.0.0-beta.4
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 +36 -5
- package/dist/data-filter/data-filter-extension.d.ts.map +1 -1
- package/dist/data-filter/data-filter-extension.js +96 -15
- 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 +106 -21
- package/dist/index.cjs +107 -17
- 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 +47 -19
- package/package.json +2 -2
- package/src/data-filter/data-filter-extension.ts +133 -24
- 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,10 +479,12 @@ 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
|
};
|
|
@@ -465,29 +495,26 @@ var DATA_TYPE_FROM_SIZE = {
|
|
|
465
495
|
4: "vec4"
|
|
466
496
|
};
|
|
467
497
|
var _DataFilterExtension = class extends import_core3.LayerExtension {
|
|
468
|
-
constructor({ filterSize = 1, fp64: fp642 = false, countItems = false } = {}) {
|
|
469
|
-
if (!DATA_TYPE_FROM_SIZE[filterSize]) {
|
|
470
|
-
throw new Error("filterSize out of range");
|
|
471
|
-
}
|
|
472
|
-
super({ filterSize, fp64: fp642, countItems });
|
|
473
|
-
}
|
|
474
498
|
getShaders(extension) {
|
|
475
|
-
const { filterSize, fp64: fp642 } = extension.opts;
|
|
499
|
+
const { categorySize, filterSize, fp64: fp642 } = extension.opts;
|
|
476
500
|
return {
|
|
477
501
|
modules: [fp642 ? shaderModule64 : shaderModule],
|
|
478
502
|
defines: {
|
|
479
|
-
|
|
503
|
+
DATACATEGORY_TYPE: DATA_TYPE_FROM_SIZE[categorySize || 1],
|
|
504
|
+
DATACATEGORY_CHANNELS: categorySize,
|
|
505
|
+
DATAFILTER_TYPE: DATA_TYPE_FROM_SIZE[filterSize || 1],
|
|
480
506
|
DATAFILTER_DOUBLE: Boolean(fp642)
|
|
481
507
|
}
|
|
482
508
|
};
|
|
483
509
|
}
|
|
484
510
|
initializeState(context, extension) {
|
|
485
511
|
const attributeManager = this.getAttributeManager();
|
|
512
|
+
const { categorySize, filterSize, fp64: fp642 } = extension.opts;
|
|
486
513
|
if (attributeManager) {
|
|
487
514
|
attributeManager.add({
|
|
488
515
|
filterValues: {
|
|
489
|
-
size:
|
|
490
|
-
type:
|
|
516
|
+
size: filterSize,
|
|
517
|
+
type: fp642 ? import_constants2.GL.DOUBLE : import_constants2.GL.FLOAT,
|
|
491
518
|
accessor: "getFilterValue",
|
|
492
519
|
shaderAttributes: {
|
|
493
520
|
filterValues: {
|
|
@@ -497,6 +524,20 @@ var _DataFilterExtension = class extends import_core3.LayerExtension {
|
|
|
497
524
|
divisor: 1
|
|
498
525
|
}
|
|
499
526
|
}
|
|
527
|
+
},
|
|
528
|
+
filterCategoryValues: {
|
|
529
|
+
size: categorySize,
|
|
530
|
+
type: import_constants2.GL.FLOAT,
|
|
531
|
+
accessor: "getFilterCategory",
|
|
532
|
+
transform: categorySize === 1 ? (d) => extension._getCategoryKey.call(this, d, 0) : (d) => d.map((x, i) => extension._getCategoryKey.call(this, x, i)),
|
|
533
|
+
shaderAttributes: {
|
|
534
|
+
filterCategoryValues: {
|
|
535
|
+
divisor: 0
|
|
536
|
+
},
|
|
537
|
+
instanceFilterCategoryValues: {
|
|
538
|
+
divisor: 1
|
|
539
|
+
}
|
|
540
|
+
}
|
|
500
541
|
}
|
|
501
542
|
});
|
|
502
543
|
}
|
|
@@ -528,29 +569,50 @@ var _DataFilterExtension = class extends import_core3.LayerExtension {
|
|
|
528
569
|
this.setState({ filterFBO, filterModel });
|
|
529
570
|
}
|
|
530
571
|
}
|
|
531
|
-
updateState({ props, oldProps }) {
|
|
572
|
+
updateState({ props, oldProps, changeFlags }, extension) {
|
|
573
|
+
var _a;
|
|
574
|
+
const attributeManager = this.getAttributeManager();
|
|
575
|
+
const { categorySize } = extension.opts;
|
|
532
576
|
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;
|
|
577
|
+
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
578
|
if (filterNeedsUpdate) {
|
|
536
579
|
this.setState({ filterNeedsUpdate });
|
|
537
580
|
}
|
|
538
581
|
}
|
|
582
|
+
if (attributeManager == null ? void 0 : attributeManager.attributes.filterCategoryValues) {
|
|
583
|
+
const categoryBitMaskNeedsUpdate = attributeManager.attributes.filterCategoryValues.needsUpdate() || !(0, import_core3._deepEqual)(props.filterCategories, oldProps.filterCategories, 2);
|
|
584
|
+
if (categoryBitMaskNeedsUpdate) {
|
|
585
|
+
this.setState({ categoryBitMaskNeedsUpdate });
|
|
586
|
+
}
|
|
587
|
+
const resetCategories = changeFlags.dataChanged;
|
|
588
|
+
if (resetCategories) {
|
|
589
|
+
this.setState({
|
|
590
|
+
categoryMap: Array(categorySize).fill(0).map(() => ({}))
|
|
591
|
+
});
|
|
592
|
+
attributeManager.attributes.filterCategoryValues.setNeedsUpdate("categoryMap");
|
|
593
|
+
}
|
|
594
|
+
}
|
|
539
595
|
}
|
|
540
596
|
draw(params, extension) {
|
|
541
597
|
const filterFBO = this.state.filterFBO;
|
|
542
598
|
const filterModel = this.state.filterModel;
|
|
543
599
|
const filterNeedsUpdate = this.state.filterNeedsUpdate;
|
|
600
|
+
const categoryBitMaskNeedsUpdate = this.state.categoryBitMaskNeedsUpdate;
|
|
544
601
|
const { onFilteredItemsChange } = this.props;
|
|
602
|
+
if (categoryBitMaskNeedsUpdate) {
|
|
603
|
+
extension._updateCategoryBitMask.call(this, params, extension);
|
|
604
|
+
}
|
|
545
605
|
if (filterNeedsUpdate && onFilteredItemsChange && filterModel) {
|
|
546
|
-
const { attributes: { filterValues, filterIndices } } = this.getAttributeManager();
|
|
606
|
+
const { attributes: { filterValues, filterCategoryValues, filterIndices } } = this.getAttributeManager();
|
|
547
607
|
filterModel.setVertexCount(this.getNumInstances());
|
|
548
608
|
this.context.device.clearWebGL({ framebuffer: filterFBO, color: [0, 0, 0, 0] });
|
|
549
609
|
filterModel.updateModuleSettings(params.moduleParameters);
|
|
550
610
|
filterModel.setAttributes({
|
|
551
611
|
...filterValues.getValue(),
|
|
612
|
+
...filterCategoryValues == null ? void 0 : filterCategoryValues.getValue(),
|
|
552
613
|
...filterIndices == null ? void 0 : filterIndices.getValue()
|
|
553
614
|
});
|
|
615
|
+
filterModel.setUniforms(params.uniforms);
|
|
554
616
|
filterModel.device.withParametersWebGL({
|
|
555
617
|
framebuffer: filterFBO,
|
|
556
618
|
...parameters,
|
|
@@ -573,6 +635,34 @@ var _DataFilterExtension = class extends import_core3.LayerExtension {
|
|
|
573
635
|
filterFBO == null ? void 0 : filterFBO.destroy();
|
|
574
636
|
filterModel == null ? void 0 : filterModel.destroy();
|
|
575
637
|
}
|
|
638
|
+
_updateCategoryBitMask(params, extension) {
|
|
639
|
+
const { categorySize } = extension.opts;
|
|
640
|
+
const { filterCategories } = this.props;
|
|
641
|
+
const categoryBitMask = new Uint32Array([0, 0, 0, 0]);
|
|
642
|
+
const categoryFilters = categorySize === 1 ? [filterCategories] : filterCategories;
|
|
643
|
+
const maxCategories = categorySize === 1 ? 128 : categorySize === 2 ? 64 : 32;
|
|
644
|
+
for (let c = 0; c < categoryFilters.length; c++) {
|
|
645
|
+
const categoryFilter = categoryFilters[c];
|
|
646
|
+
for (const category of categoryFilter) {
|
|
647
|
+
const key = extension._getCategoryKey.call(this, category, c);
|
|
648
|
+
if (key < maxCategories) {
|
|
649
|
+
const channel = c * (maxCategories / 32) + Math.floor(key / 32);
|
|
650
|
+
categoryBitMask[channel] += Math.pow(2, key % 32);
|
|
651
|
+
} else {
|
|
652
|
+
import_core3.log.warn(`Exceeded maximum number of categories (${maxCategories})`)();
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
params.uniforms.filter_categoryBitMask = categoryBitMask;
|
|
657
|
+
this.state.categoryBitMaskNeedsUpdate = false;
|
|
658
|
+
}
|
|
659
|
+
_getCategoryKey(category, channel) {
|
|
660
|
+
const categoryMap = this.state.categoryMap[channel];
|
|
661
|
+
if (!(category in categoryMap)) {
|
|
662
|
+
categoryMap[category] = Object.keys(categoryMap).length;
|
|
663
|
+
}
|
|
664
|
+
return categoryMap[category];
|
|
665
|
+
}
|
|
576
666
|
};
|
|
577
667
|
var DataFilterExtension = _DataFilterExtension;
|
|
578
668
|
(() => {
|