@deck.gl/extensions 8.9.5 → 8.9.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/dist.dev.js +17 -17
- package/dist/es5/brushing/{brushing.js → brushing-extension.js} +1 -1
- package/dist/es5/brushing/brushing-extension.js.map +1 -0
- package/dist/es5/brushing/shader-module.js.map +1 -1
- package/dist/es5/clip/{clip.js → clip-extension.js} +1 -1
- package/dist/es5/clip/clip-extension.js.map +1 -0
- package/dist/es5/collision-filter/{collision-filter.js → collision-filter-extension.js} +1 -1
- package/dist/es5/collision-filter/collision-filter-extension.js.map +1 -0
- package/dist/es5/data-filter/{data-filter.js → data-filter-extension.js} +1 -1
- package/dist/es5/data-filter/data-filter-extension.js.map +1 -0
- package/dist/es5/data-filter/shader-module.js.map +1 -1
- package/dist/es5/fill-style/{fill-style.js → fill-style-extension.js} +1 -1
- package/dist/es5/fill-style/fill-style-extension.js.map +1 -0
- package/dist/es5/fp64/{fp64.js → fp64-extension.js} +1 -1
- package/dist/es5/fp64/fp64-extension.js.map +1 -0
- package/dist/es5/index.js +18 -18
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/mask/{mask.js → mask-extension.js} +1 -1
- package/dist/es5/mask/mask-extension.js.map +1 -0
- package/dist/es5/path-style/{path-style.js → path-style-extension.js} +1 -1
- package/dist/es5/path-style/path-style-extension.js.map +1 -0
- package/dist/es5/terrain/{terrain.js → terrain-extension.js} +1 -1
- package/dist/es5/terrain/terrain-extension.js.map +1 -0
- package/dist/esm/brushing/{brushing.js → brushing-extension.js} +1 -1
- package/dist/esm/brushing/brushing-extension.js.map +1 -0
- package/dist/esm/brushing/shader-module.js.map +1 -1
- package/dist/esm/clip/{clip.js → clip-extension.js} +1 -1
- package/dist/esm/clip/clip-extension.js.map +1 -0
- package/dist/esm/collision-filter/{collision-filter.js → collision-filter-extension.js} +1 -1
- package/dist/esm/collision-filter/collision-filter-extension.js.map +1 -0
- package/dist/esm/data-filter/{data-filter.js → data-filter-extension.js} +1 -1
- package/dist/esm/data-filter/data-filter-extension.js.map +1 -0
- package/dist/esm/data-filter/shader-module.js.map +1 -1
- package/dist/esm/fill-style/{fill-style.js → fill-style-extension.js} +1 -1
- package/dist/esm/fill-style/fill-style-extension.js.map +1 -0
- package/dist/esm/fp64/{fp64.js → fp64-extension.js} +1 -1
- package/dist/esm/fp64/fp64-extension.js.map +1 -0
- package/dist/esm/index.js +9 -9
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/mask/{mask.js → mask-extension.js} +1 -1
- package/dist/esm/mask/mask-extension.js.map +1 -0
- package/dist/esm/path-style/{path-style.js → path-style-extension.js} +1 -1
- package/dist/esm/path-style/path-style-extension.js.map +1 -0
- package/dist/esm/terrain/{terrain.js → terrain-extension.js} +1 -1
- package/dist/esm/terrain/terrain-extension.js.map +1 -0
- package/package.json +2 -2
- package/src/brushing/shader-module.ts +1 -1
- package/src/data-filter/shader-module.ts +1 -1
- package/src/index.ts +17 -17
- package/typed/brushing/brushing-extension.d.ts +39 -0
- package/typed/brushing/brushing-extension.d.ts.map +1 -0
- package/typed/brushing/brushing.js +83 -0
- package/typed/brushing/shader-module.d.ts +1 -1
- package/typed/brushing/shader-module.d.ts.map +1 -1
- package/typed/brushing/shader-module.js +116 -0
- package/typed/clip/clip-extension.d.ts +32 -0
- package/typed/clip/clip-extension.d.ts.map +1 -0
- package/typed/clip/clip.js +114 -0
- package/typed/collide/collide-effect.d.ts +1 -1
- package/typed/collide/collide-effect.d.ts.map +1 -1
- package/typed/collide/collide-pass.d.ts +0 -1
- package/typed/collide/collide-pass.d.ts.map +1 -1
- package/typed/collide/collide.d.ts +0 -1
- package/typed/collide/collide.d.ts.map +1 -1
- package/typed/collide/shader-module.d.ts.map +1 -1
- package/typed/collision-filter/collision-filter-extension.d.ts +41 -0
- package/typed/collision-filter/collision-filter-extension.d.ts.map +1 -0
- package/typed/data-filter/aggregator.js +98 -0
- package/typed/data-filter/data-filter-extension.d.ts +90 -0
- package/typed/data-filter/data-filter-extension.d.ts.map +1 -0
- package/typed/data-filter/data-filter.js +159 -0
- package/typed/data-filter/shader-module.d.ts +1 -1
- package/typed/data-filter/shader-module.d.ts.map +1 -1
- package/typed/data-filter/shader-module.js +152 -0
- package/typed/fill-style/fill-style-extension.d.ts +86 -0
- package/typed/fill-style/fill-style-extension.d.ts.map +1 -0
- package/typed/fill-style/fill-style.js +152 -0
- package/typed/fill-style/shaders.glsl.js +95 -0
- package/typed/fp64/fp64-extension.d.ts +8 -0
- package/typed/fp64/fp64-extension.d.ts.map +1 -0
- package/typed/fp64/fp64.js +34 -0
- package/typed/fp64/project64.glsl.js +100 -0
- package/typed/fp64/project64.js +50 -0
- package/typed/index.d.ts +17 -17
- package/typed/index.d.ts.map +1 -1
- package/typed/index.js +9 -0
- package/typed/mask/mask-extension.d.ts +30 -0
- package/typed/mask/mask-extension.d.ts.map +1 -0
- package/typed/mask/mask.js +48 -0
- package/typed/mask/shader-module.js +73 -0
- package/typed/path-style/path-style-extension.d.ts +66 -0
- package/typed/path-style/path-style-extension.d.ts.map +1 -0
- package/typed/path-style/path-style.js +107 -0
- package/typed/path-style/shaders.glsl.js +93 -0
- package/typed/terrain/height-map.d.ts +27 -0
- package/typed/terrain/height-map.d.ts.map +1 -0
- package/typed/terrain/shader-module-offset.d.ts +4 -0
- package/typed/terrain/shader-module-offset.d.ts.map +1 -0
- package/typed/terrain/shader-module-source.d.ts +4 -0
- package/typed/terrain/shader-module-source.d.ts.map +1 -0
- package/typed/terrain/terrain-extension.d.ts +21 -0
- package/typed/terrain/terrain-extension.d.ts.map +1 -0
- package/dist/es5/brushing/brushing.js.map +0 -1
- package/dist/es5/clip/clip.js.map +0 -1
- package/dist/es5/collision-filter/collision-filter.js.map +0 -1
- package/dist/es5/data-filter/data-filter.js.map +0 -1
- package/dist/es5/fill-style/fill-style.js.map +0 -1
- package/dist/es5/fp64/fp64.js.map +0 -1
- package/dist/es5/mask/mask.js.map +0 -1
- package/dist/es5/path-style/path-style.js.map +0 -1
- package/dist/es5/terrain/terrain.js.map +0 -1
- package/dist/esm/brushing/brushing.js.map +0 -1
- package/dist/esm/clip/clip.js.map +0 -1
- package/dist/esm/collision-filter/collision-filter.js.map +0 -1
- package/dist/esm/data-filter/data-filter.js.map +0 -1
- package/dist/esm/fill-style/fill-style.js.map +0 -1
- package/dist/esm/fp64/fp64.js.map +0 -1
- package/dist/esm/mask/mask.js.map +0 -1
- package/dist/esm/path-style/path-style.js.map +0 -1
- package/dist/esm/terrain/terrain.js.map +0 -1
- package/typed/effect-order.d.ts +0 -6
- package/typed/effect-order.d.ts.map +0 -1
- /package/src/brushing/{brushing.ts → brushing-extension.ts} +0 -0
- /package/src/clip/{clip.ts → clip-extension.ts} +0 -0
- /package/src/collision-filter/{collision-filter.ts → collision-filter-extension.ts} +0 -0
- /package/src/data-filter/{data-filter.ts → data-filter-extension.ts} +0 -0
- /package/src/fill-style/{fill-style.ts → fill-style-extension.ts} +0 -0
- /package/src/fp64/{fp64.ts → fp64-extension.ts} +0 -0
- /package/src/mask/{mask.ts → mask-extension.ts} +0 -0
- /package/src/path-style/{path-style.ts → path-style-extension.ts} +0 -0
- /package/src/terrain/{terrain.ts → terrain-extension.ts} +0 -0
|
@@ -0,0 +1,159 @@
|
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import { _ShaderModule as ShaderModule } from '@deck.gl/core/typed';
|
|
2
|
-
import type { DataFilterExtensionProps } from './data-filter';
|
|
2
|
+
import type { DataFilterExtensionProps } from './data-filter-extension';
|
|
3
3
|
declare type DataFilterModuleSettings = {
|
|
4
4
|
extensions: any[];
|
|
5
5
|
} & DataFilterExtensionProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/data-filter/shader-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,IAAI,YAAY,EAAC,MAAM,eAAe,CAAC;AAE5D,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/data-filter/shader-module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,IAAI,YAAY,EAAC,MAAM,eAAe,CAAC;AAE5D,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,yBAAyB,CAAC;AAmEtE,aAAK,wBAAwB,GAAG;IAC9B,UAAU,EAAE,GAAG,EAAE,CAAC;CACnB,GAAG,wBAAwB,CAAC;AAiG7B,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,wBAAwB,CAM/D,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,YAAY,CAAC,wBAAwB,CAMjE,CAAC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
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-extension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fill-style-extension.d.ts","sourceRoot":"","sources":["../../src/fill-style/fill-style-extension.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/B;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,gHAAgH;AAChH,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,cAAc,CAAC,yBAAyB,CAAC;IACvF,MAAM,CAAC,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAgB;IACnC,MAAM,CAAC,aAAa,SAAwB;gBAEhC,EAAC,OAAe,EAAC,GAAE,OAAO,CAAC,yBAAyB,CAAM;IAItE,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,uBAAuB,CAAC,GAAG,OAAO;IAIzD,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,uBAAuB,CAAC,EAAE,SAAS,EAAE,IAAI,GAAG,GAAG;IAUtE,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,uBAAuB,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI;IA0D5F,WAAW,CACT,IAAI,EAAE,KAAK,CAAC,uBAAuB,CAAC,EACpC,EAAC,KAAK,EAAE,QAAQ,EAAC,EAAE,gBAAgB,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC,EACnE,SAAS,EAAE,IAAI;IAWjB,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,uBAAuB,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI;IAWvE,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,uBAAuB,CAAC;IAMlD,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,uBAAuB,CAAC,EAAE,IAAI,EAAE,MAAM;CAKnE"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { LayerExtension } from '@deck.gl/core';
|
|
2
|
+
import { Texture2D } from '@luma.gl/core';
|
|
3
|
+
import GL from '@luma.gl/constants';
|
|
4
|
+
import { patternShaders } from './shaders.glsl';
|
|
5
|
+
const defaultProps = {
|
|
6
|
+
fillPatternEnabled: true,
|
|
7
|
+
fillPatternAtlas: null,
|
|
8
|
+
fillPatternMapping: null,
|
|
9
|
+
fillPatternMask: true,
|
|
10
|
+
getFillPattern: { type: 'accessor', value: d => d.pattern },
|
|
11
|
+
getFillPatternScale: { type: 'accessor', value: 1 },
|
|
12
|
+
getFillPatternOffset: { type: 'accessor', value: [0, 0] }
|
|
13
|
+
};
|
|
14
|
+
const DEFAULT_TEXTURE_PARAMETERS = {
|
|
15
|
+
[GL.TEXTURE_MIN_FILTER]: GL.LINEAR,
|
|
16
|
+
// GL.LINEAR is the default value but explicitly set it here
|
|
17
|
+
[GL.TEXTURE_MAG_FILTER]: GL.LINEAR,
|
|
18
|
+
// for texture boundary artifact
|
|
19
|
+
[GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,
|
|
20
|
+
[GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE
|
|
21
|
+
};
|
|
22
|
+
export default class FillStyleExtension extends LayerExtension {
|
|
23
|
+
constructor({ pattern = false } = {}) {
|
|
24
|
+
super({ pattern });
|
|
25
|
+
}
|
|
26
|
+
isEnabled(layer) {
|
|
27
|
+
return layer.getAttributeManager() && !layer.state.pathTesselator;
|
|
28
|
+
}
|
|
29
|
+
getShaders(extension) {
|
|
30
|
+
if (!extension.isEnabled(this)) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
modules: [extension.opts.pattern && patternShaders].filter(Boolean)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
initializeState(context, extension) {
|
|
38
|
+
if (!extension.isEnabled(this)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const attributeManager = this.getAttributeManager();
|
|
42
|
+
if (extension.opts.pattern) {
|
|
43
|
+
attributeManager.add({
|
|
44
|
+
fillPatternFrames: {
|
|
45
|
+
size: 4,
|
|
46
|
+
accessor: 'getFillPattern',
|
|
47
|
+
transform: extension.getPatternFrame.bind(this),
|
|
48
|
+
shaderAttributes: {
|
|
49
|
+
fillPatternFrames: {
|
|
50
|
+
divisor: 0
|
|
51
|
+
},
|
|
52
|
+
instanceFillPatternFrames: {
|
|
53
|
+
divisor: 1
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
fillPatternScales: {
|
|
58
|
+
size: 1,
|
|
59
|
+
accessor: 'getFillPatternScale',
|
|
60
|
+
defaultValue: 1,
|
|
61
|
+
shaderAttributes: {
|
|
62
|
+
fillPatternScales: {
|
|
63
|
+
divisor: 0
|
|
64
|
+
},
|
|
65
|
+
instanceFillPatternScales: {
|
|
66
|
+
divisor: 1
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
fillPatternOffsets: {
|
|
71
|
+
size: 2,
|
|
72
|
+
accessor: 'getFillPatternOffset',
|
|
73
|
+
shaderAttributes: {
|
|
74
|
+
fillPatternOffsets: {
|
|
75
|
+
divisor: 0
|
|
76
|
+
},
|
|
77
|
+
instanceFillPatternOffsets: {
|
|
78
|
+
divisor: 1
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
this.setState({
|
|
85
|
+
emptyTexture: new Texture2D(this.context.gl, {
|
|
86
|
+
data: new Uint8Array(4),
|
|
87
|
+
width: 1,
|
|
88
|
+
height: 1
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
updateState({ props, oldProps }, extension) {
|
|
93
|
+
if (!extension.isEnabled(this)) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (props.fillPatternAtlas && props.fillPatternAtlas !== oldProps.fillPatternAtlas) {
|
|
97
|
+
extension.loadPatternAtlas.call(this, props);
|
|
98
|
+
}
|
|
99
|
+
if (props.fillPatternMapping && props.fillPatternMapping !== oldProps.fillPatternMapping) {
|
|
100
|
+
extension.loadPatternMapping.call(this, props);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
draw(params, extension) {
|
|
104
|
+
if (!extension.isEnabled(this)) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const { patternTexture } = this.state;
|
|
108
|
+
this.setModuleParameters({
|
|
109
|
+
fillPatternTexture: patternTexture || this.state.emptyTexture
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
finalizeState() {
|
|
113
|
+
const { patternTexture, emptyTexture } = this.state;
|
|
114
|
+
patternTexture?.delete();
|
|
115
|
+
emptyTexture?.delete();
|
|
116
|
+
}
|
|
117
|
+
async loadPatternAtlas({ fillPatternAtlas, fetch }) {
|
|
118
|
+
this.state.patternTexture?.delete();
|
|
119
|
+
this.setState({ patternTexture: null });
|
|
120
|
+
let image = fillPatternAtlas;
|
|
121
|
+
if (typeof image === 'string') {
|
|
122
|
+
image = await fetch(image, { propName: 'fillPatternAtlas', layer: this });
|
|
123
|
+
}
|
|
124
|
+
const patternTexture = image instanceof Texture2D
|
|
125
|
+
? image
|
|
126
|
+
: new Texture2D(this.context.gl, {
|
|
127
|
+
data: image,
|
|
128
|
+
parameters: DEFAULT_TEXTURE_PARAMETERS
|
|
129
|
+
});
|
|
130
|
+
this.setState({ patternTexture });
|
|
131
|
+
}
|
|
132
|
+
async loadPatternMapping({ fillPatternMapping, fetch }) {
|
|
133
|
+
this.setState({ patternMapping: null });
|
|
134
|
+
let patternMapping = fillPatternMapping;
|
|
135
|
+
if (typeof patternMapping === 'string') {
|
|
136
|
+
patternMapping = await fetch(patternMapping, {
|
|
137
|
+
propName: 'fillPatternMapping',
|
|
138
|
+
layer: this
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
this.setState({ patternMapping });
|
|
142
|
+
this.getAttributeManager().invalidate('getFillPattern');
|
|
143
|
+
this.setNeedsUpdate();
|
|
144
|
+
}
|
|
145
|
+
getPatternFrame(name) {
|
|
146
|
+
const { patternMapping } = this.state;
|
|
147
|
+
const def = patternMapping && patternMapping[name];
|
|
148
|
+
return def ? [def.x, def.y, def.width, def.height] : [0, 0, 0, 0];
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
FillStyleExtension.extensionName = 'FillStyleExtension';
|
|
152
|
+
FillStyleExtension.defaultProps = defaultProps;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { project, COORDINATE_SYSTEM } from '@deck.gl/core';
|
|
2
|
+
/*
|
|
3
|
+
* fill pattern shader module
|
|
4
|
+
*/
|
|
5
|
+
const patternVs = `
|
|
6
|
+
#ifdef NON_INSTANCED_MODEL
|
|
7
|
+
#define FILL_PATTERN_FRAME_ATTRIB fillPatternFrames
|
|
8
|
+
#define FILL_PATTERN_SCALE_ATTRIB fillPatternScales
|
|
9
|
+
#define FILL_PATTERN_OFFSET_ATTRIB fillPatternOffsets
|
|
10
|
+
#else
|
|
11
|
+
#define FILL_PATTERN_FRAME_ATTRIB instanceFillPatternFrames
|
|
12
|
+
#define FILL_PATTERN_SCALE_ATTRIB instanceFillPatternScales
|
|
13
|
+
#define FILL_PATTERN_OFFSET_ATTRIB instanceFillPatternOffsets
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
attribute vec4 FILL_PATTERN_FRAME_ATTRIB;
|
|
17
|
+
attribute float FILL_PATTERN_SCALE_ATTRIB;
|
|
18
|
+
attribute vec2 FILL_PATTERN_OFFSET_ATTRIB;
|
|
19
|
+
|
|
20
|
+
uniform bool fill_patternEnabled;
|
|
21
|
+
uniform vec2 fill_patternTextureSize;
|
|
22
|
+
|
|
23
|
+
varying vec2 fill_uv;
|
|
24
|
+
varying vec4 fill_patternBounds;
|
|
25
|
+
varying vec3 fill_patternPlacement;
|
|
26
|
+
`;
|
|
27
|
+
const patternFs = `
|
|
28
|
+
uniform bool fill_patternEnabled;
|
|
29
|
+
uniform bool fill_patternMask;
|
|
30
|
+
uniform sampler2D fill_patternTexture;
|
|
31
|
+
uniform vec2 fill_uvCoordinateOrigin;
|
|
32
|
+
|
|
33
|
+
varying vec4 fill_patternBounds;
|
|
34
|
+
varying vec3 fill_patternPlacement;
|
|
35
|
+
varying vec2 fill_uv;
|
|
36
|
+
|
|
37
|
+
const float FILL_UV_SCALE = 512.0 / 40000000.0;
|
|
38
|
+
`;
|
|
39
|
+
const inject = {
|
|
40
|
+
'vs:DECKGL_FILTER_GL_POSITION': `
|
|
41
|
+
fill_uv = geometry.position.xy;
|
|
42
|
+
`,
|
|
43
|
+
'vs:DECKGL_FILTER_COLOR': `
|
|
44
|
+
if (fill_patternEnabled) {
|
|
45
|
+
fill_patternBounds = FILL_PATTERN_FRAME_ATTRIB / vec4(fill_patternTextureSize, fill_patternTextureSize);
|
|
46
|
+
fill_patternPlacement.xy = FILL_PATTERN_OFFSET_ATTRIB;
|
|
47
|
+
fill_patternPlacement.z = FILL_PATTERN_SCALE_ATTRIB * FILL_PATTERN_FRAME_ATTRIB.w;
|
|
48
|
+
}
|
|
49
|
+
`,
|
|
50
|
+
'fs:DECKGL_FILTER_COLOR': `
|
|
51
|
+
if (fill_patternEnabled) {
|
|
52
|
+
float scale = FILL_UV_SCALE * fill_patternPlacement.z;
|
|
53
|
+
vec2 patternUV = mod(mod(fill_uvCoordinateOrigin, scale) + fill_uv, scale) / scale;
|
|
54
|
+
patternUV = mod(fill_patternPlacement.xy + patternUV, 1.0);
|
|
55
|
+
|
|
56
|
+
vec2 texCoords = fill_patternBounds.xy + fill_patternBounds.zw * patternUV;
|
|
57
|
+
|
|
58
|
+
vec4 patternColor = texture2D(fill_patternTexture, texCoords);
|
|
59
|
+
color.a *= patternColor.a;
|
|
60
|
+
if (!fill_patternMask) {
|
|
61
|
+
color.rgb = patternColor.rgb;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
`
|
|
65
|
+
};
|
|
66
|
+
function getPatternUniforms(opts = {}, uniforms) {
|
|
67
|
+
if ('fillPatternTexture' in opts) {
|
|
68
|
+
const { fillPatternTexture } = opts;
|
|
69
|
+
return {
|
|
70
|
+
fill_patternTexture: fillPatternTexture,
|
|
71
|
+
fill_patternTextureSize: [fillPatternTexture.width, fillPatternTexture.height]
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (opts.viewport) {
|
|
75
|
+
const { viewport, fillPatternMask = true, fillPatternEnabled = true } = opts;
|
|
76
|
+
const { project_uCoordinateOrigin, project_uCoordinateSystem } = uniforms;
|
|
77
|
+
const coordinateOriginCommon = project_uCoordinateSystem === COORDINATE_SYSTEM.CARTESIAN
|
|
78
|
+
? project_uCoordinateOrigin
|
|
79
|
+
: viewport.projectPosition(project_uCoordinateOrigin);
|
|
80
|
+
return {
|
|
81
|
+
fill_uvCoordinateOrigin: coordinateOriginCommon.slice(0, 2),
|
|
82
|
+
fill_patternMask: fillPatternMask,
|
|
83
|
+
fill_patternEnabled: fillPatternEnabled
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return {};
|
|
87
|
+
}
|
|
88
|
+
export const patternShaders = {
|
|
89
|
+
name: 'fill-pattern',
|
|
90
|
+
vs: patternVs,
|
|
91
|
+
fs: patternFs,
|
|
92
|
+
inject,
|
|
93
|
+
dependencies: [project],
|
|
94
|
+
getUniforms: getPatternUniforms
|
|
95
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LayerExtension } from '@deck.gl/core/typed';
|
|
2
|
+
import type { Layer } from '@deck.gl/core/typed';
|
|
3
|
+
/** @deprecated Adds the legacy 64-bit precision to geospatial layers. */
|
|
4
|
+
export default class Fp64Extension extends LayerExtension {
|
|
5
|
+
static extensionName: string;
|
|
6
|
+
getShaders(this: Layer): any;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=fp64-extension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fp64-extension.d.ts","sourceRoot":"","sources":["../../src/fp64/fp64-extension.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAC,cAAc,EAAoB,MAAM,eAAe,CAAC;AAGhE,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,eAAe,CAAC;AAEzC,yEAAyE;AACzE,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,cAAc;IACvD,MAAM,CAAC,aAAa,SAAmB;IAEvC,UAAU,CAAC,IAAI,EAAE,KAAK,GAAG,GAAG;CAa7B"}
|