@deck.gl/extensions 8.9.22 → 8.9.24

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.
Files changed (54) hide show
  1. package/LICENSE +1 -1
  2. package/package.json +2 -2
  3. package/typed/brushing/brushing.d.ts +0 -39
  4. package/typed/brushing/brushing.d.ts.map +0 -1
  5. package/typed/brushing/brushing.js +0 -83
  6. package/typed/brushing/shader-module.js +0 -116
  7. package/typed/clip/clip.d.ts +0 -32
  8. package/typed/clip/clip.d.ts.map +0 -1
  9. package/typed/clip/clip.js +0 -114
  10. package/typed/collide/collide-effect.d.ts +0 -28
  11. package/typed/collide/collide-effect.d.ts.map +0 -1
  12. package/typed/collide/collide-pass.d.ts +0 -14
  13. package/typed/collide/collide-pass.d.ts.map +0 -1
  14. package/typed/collide/collide.d.ts +0 -41
  15. package/typed/collide/collide.d.ts.map +0 -1
  16. package/typed/collide/shader-module.d.ts +0 -4
  17. package/typed/collide/shader-module.d.ts.map +0 -1
  18. package/typed/collision-filter/collision-filter.d.ts +0 -41
  19. package/typed/collision-filter/collision-filter.d.ts.map +0 -1
  20. package/typed/common/projection-utils.d.ts +0 -27
  21. package/typed/common/projection-utils.d.ts.map +0 -1
  22. package/typed/data-filter/aggregator.js +0 -98
  23. package/typed/data-filter/data-filter.d.ts +0 -90
  24. package/typed/data-filter/data-filter.d.ts.map +0 -1
  25. package/typed/data-filter/data-filter.js +0 -159
  26. package/typed/data-filter/shader-module.js +0 -152
  27. package/typed/fill-style/fill-style.d.ts +0 -86
  28. package/typed/fill-style/fill-style.d.ts.map +0 -1
  29. package/typed/fill-style/fill-style.js +0 -152
  30. package/typed/fill-style/shaders.glsl.js +0 -95
  31. package/typed/fp64/fp64.d.ts +0 -8
  32. package/typed/fp64/fp64.d.ts.map +0 -1
  33. package/typed/fp64/fp64.js +0 -34
  34. package/typed/fp64/project64.glsl.js +0 -100
  35. package/typed/fp64/project64.js +0 -50
  36. package/typed/index.js +0 -9
  37. package/typed/mask/mask.d.ts +0 -30
  38. package/typed/mask/mask.d.ts.map +0 -1
  39. package/typed/mask/mask.js +0 -48
  40. package/typed/mask/shader-module.js +0 -73
  41. package/typed/mask/utils.d.ts +0 -13
  42. package/typed/mask/utils.d.ts.map +0 -1
  43. package/typed/path-style/path-style.d.ts +0 -66
  44. package/typed/path-style/path-style.d.ts.map +0 -1
  45. package/typed/path-style/path-style.js +0 -107
  46. package/typed/path-style/shaders.glsl.js +0 -93
  47. package/typed/terrain/height-map.d.ts +0 -27
  48. package/typed/terrain/height-map.d.ts.map +0 -1
  49. package/typed/terrain/shader-module-offset.d.ts +0 -4
  50. package/typed/terrain/shader-module-offset.d.ts.map +0 -1
  51. package/typed/terrain/shader-module-source.d.ts +0 -4
  52. package/typed/terrain/shader-module-source.d.ts.map +0 -1
  53. package/typed/terrain/terrain.d.ts +0 -21
  54. package/typed/terrain/terrain.d.ts.map +0 -1
@@ -1,98 +0,0 @@
1
- import { Model, Texture2D, Framebuffer, isWebGL2 } from '@luma.gl/core';
2
- import GL from '@luma.gl/constants';
3
- const AGGREGATE_VS = `\
4
- #define SHADER_NAME data-filter-vertex-shader
5
-
6
- #ifdef FLOAT_TARGET
7
- attribute float filterIndices;
8
- attribute float filterPrevIndices;
9
- #else
10
- attribute vec2 filterIndices;
11
- attribute vec2 filterPrevIndices;
12
- #endif
13
-
14
- varying vec4 vColor;
15
- const float component = 1.0 / 255.0;
16
-
17
- void main() {
18
- #ifdef FLOAT_TARGET
19
- dataFilter_value *= float(filterIndices != filterPrevIndices);
20
- gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
21
- vColor = vec4(0.0, 0.0, 0.0, 1.0);
22
- #else
23
- // Float texture is not supported: pack result into 4 channels x 256 px x 64px
24
- dataFilter_value *= float(filterIndices.x != filterPrevIndices.x);
25
- float col = filterIndices.x;
26
- float row = filterIndices.y * 4.0;
27
- float channel = floor(row);
28
- row = fract(row);
29
- vColor = component * vec4(bvec4(channel == 0.0, channel == 1.0, channel == 2.0, channel == 3.0));
30
- gl_Position = vec4(col * 2.0 - 1.0, row * 2.0 - 1.0, 0.0, 1.0);
31
- #endif
32
- gl_PointSize = 1.0;
33
- }
34
- `;
35
- const AGGREGATE_FS = `\
36
- #define SHADER_NAME data-filter-fragment-shader
37
- precision highp float;
38
-
39
- varying vec4 vColor;
40
-
41
- void main() {
42
- if (dataFilter_value < 0.5) {
43
- discard;
44
- }
45
- gl_FragColor = vColor;
46
- }
47
- `;
48
- export function supportsFloatTarget(gl) {
49
- // https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices#Support_for_float_textures_doesnt_mean_you_can_render_into_them!
50
- return (gl.getExtension('EXT_float_blend') &&
51
- // WebGL 2
52
- (gl.getExtension('EXT_color_buffer_float') ||
53
- // WebGL 1
54
- gl.getExtension('WEBGL_color_buffer_float')));
55
- }
56
- // A 1x1 framebuffer object that encodes the total count of filtered items
57
- export function getFramebuffer(gl, useFloatTarget) {
58
- if (useFloatTarget) {
59
- return new Framebuffer(gl, {
60
- width: 1,
61
- height: 1,
62
- attachments: {
63
- [GL.COLOR_ATTACHMENT0]: new Texture2D(gl, {
64
- format: isWebGL2(gl) ? GL.RGBA32F : GL.RGBA,
65
- type: GL.FLOAT,
66
- mipmaps: false
67
- })
68
- }
69
- });
70
- }
71
- return new Framebuffer(gl, {
72
- width: 256,
73
- height: 64,
74
- depth: false
75
- });
76
- }
77
- // Increments the counter based on dataFilter_value
78
- export function getModel(gl, shaderOptions, useFloatTarget) {
79
- shaderOptions.defines.NON_INSTANCED_MODEL = 1;
80
- if (useFloatTarget) {
81
- shaderOptions.defines.FLOAT_TARGET = 1;
82
- }
83
- return new Model(gl, {
84
- id: 'data-filter-aggregation-model',
85
- vertexCount: 1,
86
- isInstanced: false,
87
- drawMode: GL.POINTS,
88
- vs: AGGREGATE_VS,
89
- fs: AGGREGATE_FS,
90
- ...shaderOptions
91
- });
92
- }
93
- export const parameters = {
94
- blend: true,
95
- blendFunc: [GL.ONE, GL.ONE, GL.ONE, GL.ONE],
96
- blendEquation: [GL.FUNC_ADD, GL.FUNC_ADD],
97
- depthTest: false
98
- };
@@ -1,90 +0,0 @@
1
- import { LayerExtension } from '@deck.gl/core/typed';
2
- import type { Layer, LayerContext, Accessor, UpdateParameters } from '@deck.gl/core/typed';
3
- export declare type DataFilterExtensionProps<DataT = any> = {
4
- /**
5
- * Accessor to retrieve the value for each object that it will be filtered by.
6
- * Returns either a number (if `filterSize: 1`) or an array of numbers.
7
- */
8
- getFilterValue?: Accessor<DataT, number | number[]>;
9
- /**
10
- * Enable/disable the data filter. If the data filter is disabled, all objects are rendered.
11
- * @default true
12
- */
13
- filterEnabled?: boolean;
14
- /**
15
- * The [min, max] bounds which defines whether an object should be rendered.
16
- * If an object's filtered value is within the bounds, the object will be rendered; otherwise it will be hidden.
17
- * @default [-1, 1]
18
- */
19
- filterRange?: [number, number] | [number, number][];
20
- /**
21
- * If specified, objects will be faded in/out instead of abruptly shown/hidden.
22
- * When the filtered value is outside of the bounds defined by `filterSoftRange` but still within the bounds defined by `filterRange`, the object will be rendered as "faded."
23
- * @default null
24
- */
25
- filterSoftRange?: [number, number] | [number, number][] | null;
26
- /**
27
- * When an object is "faded", manipulate its size so that it appears smaller or thinner. Only works if `filterSoftRange` is specified.
28
- * @default true
29
- */
30
- filterTransformSize?: boolean;
31
- /**
32
- * When an object is "faded", manipulate its opacity so that it appears more translucent. Only works if `filterSoftRange` is specified.
33
- * @default true
34
- */
35
- filterTransformColor?: boolean;
36
- /**
37
- * Only called if the `countItems` option is enabled.
38
- */
39
- onFilteredItemsChange?: (evt: {
40
- /** The id of the source layer. */
41
- id: string;
42
- /** The number of data objects that pass the filter. */
43
- count: number;
44
- }) => void;
45
- };
46
- declare type DataFilterExtensionOptions = {
47
- /**
48
- * The size of the filter (number of columns to filter by). The data filter can show/hide data based on 1-4 numeric properties of each object.
49
- * @default 1
50
- */
51
- filterSize: number;
52
- /**
53
- * Use 64-bit precision instead of 32-bit.
54
- * @default false
55
- */
56
- fp64: boolean;
57
- /**
58
- * If `true`, reports the number of filtered objects with the `onFilteredItemsChange` callback.
59
- * @default `false`.
60
- */
61
- countItems: boolean;
62
- };
63
- /** Adds GPU-based data filtering functionalities to layers. It allows the layer to show/hide objects based on user-defined properties. */
64
- export default class DataFilterExtension extends LayerExtension<DataFilterExtensionOptions> {
65
- static defaultProps: {
66
- getFilterValue: {
67
- type: string;
68
- value: number;
69
- };
70
- onFilteredItemsChange: {
71
- type: string;
72
- value: null;
73
- optional: boolean;
74
- };
75
- filterEnabled: boolean;
76
- filterRange: number[];
77
- filterSoftRange: null;
78
- filterTransformSize: boolean;
79
- filterTransformColor: boolean;
80
- };
81
- static extensionName: string;
82
- constructor({ filterSize, fp64, countItems }?: Partial<DataFilterExtensionOptions>);
83
- getShaders(this: Layer<DataFilterExtensionProps>, extension: this): any;
84
- initializeState(this: Layer<DataFilterExtensionProps>, context: LayerContext, extension: this): void;
85
- updateState(this: Layer<DataFilterExtensionProps>, { props, oldProps }: UpdateParameters<Layer<DataFilterExtensionProps>>): void;
86
- draw(this: Layer<DataFilterExtensionProps>, params: any, extension: this): void;
87
- finalizeState(this: Layer<DataFilterExtensionProps>): void;
88
- }
89
- export {};
90
- //# sourceMappingURL=data-filter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"data-filter.d.ts","sourceRoot":"","sources":["../../src/data-filter/data-filter.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAM7C,OAAO,KAAK,EAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAanF,oBAAY,wBAAwB,CAAC,KAAK,GAAG,GAAG,IAAI;IAClD;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;IACpD;;;OAGG;IACH,aAAa,CAAC,EAAE,OAA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,EAAE,QAAQ,EAAC,EAAE,gBAAgB,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAgBtE,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,wBAAwB,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI;IAoCxE,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,wBAAwB,CAAC;CAQpD"}
@@ -1,159 +0,0 @@
1
- // Copyright (c) 2015 - 2017 Uber Technologies, Inc.
2
- //
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy
4
- // of this software and associated documentation files (the "Software"), to deal
5
- // in the Software without restriction, including without limitation the rights
6
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- // copies of the Software, and to permit persons to whom the Software is
8
- // furnished to do so, subject to the following conditions:
9
- //
10
- // The above copyright notice and this permission notice shall be included in
11
- // all copies or substantial portions of the Software.
12
- //
13
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
- // THE SOFTWARE.
20
- import { LayerExtension } from '@deck.gl/core';
21
- import { shaderModule, shaderModule64 } from './shader-module';
22
- import * as aggregator from './aggregator';
23
- import { readPixelsToArray, clear } from '@luma.gl/core';
24
- import GL from '@luma.gl/constants';
25
- const defaultProps = {
26
- getFilterValue: { type: 'accessor', value: 0 },
27
- onFilteredItemsChange: { type: 'function', value: null, compare: false },
28
- filterEnabled: true,
29
- filterRange: [-1, 1],
30
- filterSoftRange: null,
31
- filterTransformSize: true,
32
- filterTransformColor: true
33
- };
34
- const DATA_TYPE_FROM_SIZE = {
35
- 1: 'float',
36
- 2: 'vec2',
37
- 3: 'vec3',
38
- 4: 'vec4'
39
- };
40
- export default class DataFilterExtension extends LayerExtension {
41
- constructor({ filterSize = 1, fp64 = false, countItems = false } = {}) {
42
- if (!DATA_TYPE_FROM_SIZE[filterSize]) {
43
- throw new Error('filterSize out of range');
44
- }
45
- super({ filterSize, fp64, countItems });
46
- }
47
- getShaders(extension) {
48
- const { filterSize, fp64 } = extension.opts;
49
- return {
50
- modules: [fp64 ? shaderModule64 : shaderModule],
51
- defines: {
52
- DATAFILTER_TYPE: DATA_TYPE_FROM_SIZE[filterSize],
53
- DATAFILTER_DOUBLE: Boolean(fp64)
54
- }
55
- };
56
- }
57
- initializeState(context, extension) {
58
- const attributeManager = this.getAttributeManager();
59
- if (attributeManager) {
60
- attributeManager.add({
61
- filterValues: {
62
- size: extension.opts.filterSize,
63
- type: extension.opts.fp64 ? GL.DOUBLE : GL.FLOAT,
64
- accessor: 'getFilterValue',
65
- shaderAttributes: {
66
- filterValues: {
67
- divisor: 0
68
- },
69
- instanceFilterValues: {
70
- divisor: 1
71
- }
72
- }
73
- }
74
- });
75
- }
76
- const { gl } = this.context;
77
- if (attributeManager && extension.opts.countItems) {
78
- const useFloatTarget = aggregator.supportsFloatTarget(gl);
79
- // This attribute is needed for variable-width data, e.g. Path, SolidPolygon, Text
80
- // The vertex shader checks if a vertex has the same "index" as the previous vertex
81
- // so that we only write one count cross multiple vertices of the same object
82
- attributeManager.add({
83
- filterIndices: {
84
- size: useFloatTarget ? 1 : 2,
85
- vertexOffset: 1,
86
- type: GL.UNSIGNED_BYTE,
87
- normalized: true,
88
- accessor: (object, { index }) => {
89
- const i = object && object.__source ? object.__source.index : index;
90
- return useFloatTarget ? (i + 1) % 255 : [(i + 1) % 255, Math.floor(i / 255) % 255];
91
- },
92
- shaderAttributes: {
93
- filterPrevIndices: {
94
- vertexOffset: 0
95
- },
96
- filterIndices: {
97
- vertexOffset: 1
98
- }
99
- }
100
- }
101
- });
102
- const filterFBO = aggregator.getFramebuffer(gl, useFloatTarget);
103
- const filterModel = aggregator.getModel(gl, extension.getShaders(extension), useFloatTarget);
104
- this.setState({ filterFBO, filterModel });
105
- }
106
- }
107
- updateState({ props, oldProps }) {
108
- if (this.state.filterModel) {
109
- const attributeManager = this.getAttributeManager();
110
- const filterNeedsUpdate = attributeManager.attributes.filterValues.needsUpdate() ||
111
- props.filterEnabled !== oldProps.filterEnabled ||
112
- props.filterRange !== oldProps.filterRange ||
113
- props.filterSoftRange !== oldProps.filterSoftRange;
114
- if (filterNeedsUpdate) {
115
- this.setState({ filterNeedsUpdate });
116
- }
117
- }
118
- }
119
- draw(params, extension) {
120
- const { filterFBO, filterModel, filterNeedsUpdate } = this.state;
121
- const { onFilteredItemsChange } = this.props;
122
- if (filterNeedsUpdate && onFilteredItemsChange && filterModel) {
123
- const { attributes: { filterValues, filterIndices } } = this.getAttributeManager();
124
- filterModel.setVertexCount(this.getNumInstances());
125
- const { gl } = this.context;
126
- clear(gl, { framebuffer: filterFBO, color: [0, 0, 0, 0] });
127
- filterModel
128
- .updateModuleSettings(params.moduleParameters)
129
- .setAttributes({
130
- ...filterValues.getShaderAttributes(),
131
- ...(filterIndices && filterIndices.getShaderAttributes())
132
- })
133
- .draw({
134
- framebuffer: filterFBO,
135
- parameters: {
136
- ...aggregator.parameters,
137
- viewport: [0, 0, filterFBO.width, filterFBO.height]
138
- }
139
- });
140
- const color = readPixelsToArray(filterFBO);
141
- let count = 0;
142
- for (let i = 0; i < color.length; i++) {
143
- count += color[i];
144
- }
145
- onFilteredItemsChange({ id: this.id, count });
146
- this.state.filterNeedsUpdate = false;
147
- }
148
- }
149
- finalizeState() {
150
- const { filterFBO, filterModel } = this.state;
151
- if (filterFBO) {
152
- filterFBO.color.delete();
153
- filterFBO.delete();
154
- filterModel.delete();
155
- }
156
- }
157
- }
158
- DataFilterExtension.extensionName = 'DataFilterExtension';
159
- DataFilterExtension.defaultProps = defaultProps;
@@ -1,152 +0,0 @@
1
- /*
2
- * data filter shader module
3
- */
4
- const vs = `
5
- uniform DATAFILTER_TYPE filter_min;
6
- uniform DATAFILTER_TYPE filter_softMin;
7
- uniform DATAFILTER_TYPE filter_softMax;
8
- uniform DATAFILTER_TYPE filter_max;
9
- uniform bool filter_useSoftMargin;
10
- uniform bool filter_enabled;
11
- uniform bool filter_transformSize;
12
-
13
- #ifdef NON_INSTANCED_MODEL
14
- #define DATAFILTER_ATTRIB filterValues
15
- #define DATAFILTER_ATTRIB_64LOW filterValues64Low
16
- #else
17
- #define DATAFILTER_ATTRIB instanceFilterValues
18
- #define DATAFILTER_ATTRIB_64LOW instanceFilterValues64Low
19
- #endif
20
-
21
- attribute DATAFILTER_TYPE DATAFILTER_ATTRIB;
22
- #ifdef DATAFILTER_DOUBLE
23
- attribute DATAFILTER_TYPE DATAFILTER_ATTRIB_64LOW;
24
-
25
- uniform DATAFILTER_TYPE filter_min64High;
26
- uniform DATAFILTER_TYPE filter_max64High;
27
- #endif
28
-
29
- varying float dataFilter_value;
30
-
31
- float dataFilter_reduceValue(float value) {
32
- return value;
33
- }
34
- float dataFilter_reduceValue(vec2 value) {
35
- return min(value.x, value.y);
36
- }
37
- float dataFilter_reduceValue(vec3 value) {
38
- return min(min(value.x, value.y), value.z);
39
- }
40
- float dataFilter_reduceValue(vec4 value) {
41
- return min(min(value.x, value.y), min(value.z, value.w));
42
- }
43
- void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax) {
44
- if (filter_enabled) {
45
- if (filter_useSoftMargin) {
46
- dataFilter_value = dataFilter_reduceValue(
47
- smoothstep(filter_min, filter_softMin, valueFromMin) *
48
- (1.0 - smoothstep(filter_softMax, filter_max, valueFromMax))
49
- );
50
- } else {
51
- dataFilter_value = dataFilter_reduceValue(
52
- step(filter_min, valueFromMin) * step(valueFromMax, filter_max)
53
- );
54
- }
55
- } else {
56
- dataFilter_value = 1.0;
57
- }
58
- }
59
- `;
60
- const fs = `
61
- uniform bool filter_transformColor;
62
- varying float dataFilter_value;
63
- `;
64
- const getUniforms = opts => {
65
- if (!opts || !opts.extensions) {
66
- return {};
67
- }
68
- const { filterRange = [-1, 1], filterEnabled = true, filterTransformSize = true, filterTransformColor = true } = opts;
69
- const filterSoftRange = opts.filterSoftRange || filterRange;
70
- const uniforms = Number.isFinite(filterRange[0])
71
- ? {
72
- filter_min: filterRange[0],
73
- filter_softMin: filterSoftRange[0],
74
- filter_softMax: filterSoftRange[1],
75
- filter_max: filterRange[1]
76
- }
77
- : {
78
- filter_min: filterRange.map(r => r[0]),
79
- filter_softMin: filterSoftRange.map(r => r[0]),
80
- filter_softMax: filterSoftRange.map(r => r[1]),
81
- filter_max: filterRange.map(r => r[1])
82
- };
83
- uniforms.filter_enabled = filterEnabled;
84
- uniforms.filter_useSoftMargin = Boolean(opts.filterSoftRange);
85
- uniforms.filter_transformSize = filterEnabled && filterTransformSize;
86
- uniforms.filter_transformColor = filterEnabled && filterTransformColor;
87
- return uniforms;
88
- };
89
- const getUniforms64 = opts => {
90
- if (!opts || !opts.extensions) {
91
- return {};
92
- }
93
- const uniforms = getUniforms(opts);
94
- if (Number.isFinite(uniforms.filter_min)) {
95
- const min64High = Math.fround(uniforms.filter_min);
96
- uniforms.filter_min -= min64High;
97
- uniforms.filter_softMin -= min64High;
98
- uniforms.filter_min64High = min64High;
99
- const max64High = Math.fround(uniforms.filter_max);
100
- uniforms.filter_max -= max64High;
101
- uniforms.filter_softMax -= max64High;
102
- uniforms.filter_max64High = max64High;
103
- }
104
- else {
105
- const min64High = uniforms.filter_min.map(Math.fround);
106
- uniforms.filter_min = uniforms.filter_min.map((x, i) => x - min64High[i]);
107
- uniforms.filter_softMin = uniforms.filter_softMin.map((x, i) => x - min64High[i]);
108
- uniforms.filter_min64High = min64High;
109
- const max64High = uniforms.filter_max.map(Math.fround);
110
- uniforms.filter_max = uniforms.filter_max.map((x, i) => x - max64High[i]);
111
- uniforms.filter_softMax = uniforms.filter_softMax.map((x, i) => x - max64High[i]);
112
- uniforms.filter_max64High = max64High;
113
- }
114
- return uniforms;
115
- };
116
- const inject = {
117
- 'vs:#main-start': `
118
- #ifdef DATAFILTER_DOUBLE
119
- dataFilter_setValue(
120
- DATAFILTER_ATTRIB - filter_min64High + DATAFILTER_ATTRIB_64LOW,
121
- DATAFILTER_ATTRIB - filter_max64High + DATAFILTER_ATTRIB_64LOW
122
- );
123
- #else
124
- dataFilter_setValue(DATAFILTER_ATTRIB, DATAFILTER_ATTRIB);
125
- #endif
126
- `,
127
- 'vs:DECKGL_FILTER_SIZE': `
128
- if (filter_transformSize) {
129
- size = size * dataFilter_value;
130
- }
131
- `,
132
- 'fs:DECKGL_FILTER_COLOR': `
133
- if (dataFilter_value == 0.0) discard;
134
- if (filter_transformColor) {
135
- color.a *= dataFilter_value;
136
- }
137
- `
138
- };
139
- export const shaderModule = {
140
- name: 'data-filter',
141
- vs,
142
- fs,
143
- inject,
144
- getUniforms
145
- };
146
- export const shaderModule64 = {
147
- name: 'data-filter-fp64',
148
- vs,
149
- fs,
150
- inject,
151
- getUniforms: getUniforms64
152
- };
@@ -1,86 +0,0 @@
1
- import { LayerExtension } from '@deck.gl/core/typed';
2
- import type { Layer, LayerContext, Accessor, AccessorFunction, Texture, UpdateParameters } from '@deck.gl/core/typed';
3
- export declare type FillStyleExtensionProps<DataT = any> = {
4
- /** Cheap toggle to enable/disable pattern fill. Requires the `pattern` option to be on.
5
- * @default true
6
- */
7
- fillPatternEnabled?: boolean;
8
- /** Sprite image url or texture that packs all your patterns into one layout. */
9
- fillPatternAtlas?: string | Texture;
10
- /** Pattern names mapped to pattern definitions, or a url that points to a JSON file. */
11
- fillPatternMapping?: string | Record<string, {
12
- /** Left position of the pattern on the atlas */
13
- x: number;
14
- /** Top position of the pattern on the atlas */
15
- y: number;
16
- /** Width of the pattern */
17
- width: number;
18
- /** Height of the pattern */
19
- height: number;
20
- }>;
21
- /**
22
- * Whether to treat the patterns as transparency masks.
23
- * @default true
24
- */
25
- fillPatternMask?: boolean;
26
- /** Accessor for the name of the pattern. */
27
- getFillPattern?: AccessorFunction<DataT, string>;
28
- /** Accessor for the scale of the pattern, relative to the original size. If the pattern is 24 x 24 pixels, scale `1` roughly yields 24 meters.
29
- * @default 1
30
- */
31
- getFillPatternScale?: Accessor<DataT, number>;
32
- /**
33
- * Accessor for the offset of the pattern, relative to the original size. Offset `[0.5, 0.5]` shifts the pattern alignment by half.
34
- * @default [0, 0]
35
- */
36
- getFillPatternOffset?: Accessor<DataT, [number, number]>;
37
- };
38
- declare type FillStyleExtensionOptions = {
39
- /** If `true`, adds the ability to tile the filled area with a pattern.
40
- * @default false
41
- */
42
- pattern: boolean;
43
- };
44
- /** Adds selected features to layers that render a "fill", such as the `PolygonLayer` and `ScatterplotLayer`. */
45
- export default class FillStyleExtension extends LayerExtension<FillStyleExtensionOptions> {
46
- static defaultProps: {
47
- fillPatternEnabled: boolean;
48
- fillPatternAtlas: {
49
- type: string;
50
- value: null;
51
- async: boolean;
52
- parameters: {
53
- [x: number]: number;
54
- };
55
- };
56
- fillPatternMapping: {
57
- type: string;
58
- value: {};
59
- async: boolean;
60
- };
61
- fillPatternMask: boolean;
62
- getFillPattern: {
63
- type: string;
64
- value: (d: any) => any;
65
- };
66
- getFillPatternScale: {
67
- type: string;
68
- value: number;
69
- };
70
- getFillPatternOffset: {
71
- type: string;
72
- value: number[];
73
- };
74
- };
75
- static extensionName: string;
76
- constructor({ pattern }?: Partial<FillStyleExtensionOptions>);
77
- isEnabled(layer: Layer<FillStyleExtensionProps>): boolean;
78
- getShaders(this: Layer<FillStyleExtensionProps>, extension: this): any;
79
- initializeState(this: Layer<FillStyleExtensionProps>, context: LayerContext, extension: this): void;
80
- updateState(this: Layer<FillStyleExtensionProps>, { props, oldProps }: UpdateParameters<Layer<FillStyleExtensionProps>>, extension: this): void;
81
- draw(this: Layer<FillStyleExtensionProps>, params: any, extension: this): void;
82
- finalizeState(this: Layer<FillStyleExtensionProps>): void;
83
- getPatternFrame(this: Layer<FillStyleExtensionProps>, name: string): any[];
84
- }
85
- export {};
86
- //# sourceMappingURL=fill-style.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fill-style.d.ts","sourceRoot":"","sources":["../../src/fill-style/fill-style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAM7C,OAAO,KAAK,EACV,KAAK,EACL,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,OAAO,EACP,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAmBvB,oBAAY,uBAAuB,CAAC,KAAK,GAAG,GAAG,IAAI;IACjD;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,gFAAgF;IAChF,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACpC,wFAAwF;IACxF,kBAAkB,CAAC,EACf,MAAM,GACN,MAAM,CACJ,MAAM,EACN;QACE,gDAAgD;QAChD,CAAC,EAAE,MAAM,CAAC;QACV,+CAA+C;QAC/C,CAAC,EAAE,MAAM,CAAC;QACV,2BAA2B;QAC3B,KAAK,EAAE,MAAM,CAAC;QACd,4BAA4B;QAC5B,MAAM,EAAE,MAAM,CAAC;KAChB,CACF,CAAC;IACN;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,4CAA4C;IAC5C,cAAc,CAAC,EAAE,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACjD;;OAEG;IACH,mBAAmB,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC9C;;;OAGG;IACH,oBAAoB,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC1D,CAAC;AAEF,aAAK,yBAAyB,GAAG;IAC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