@deck.gl/extensions 9.0.40 → 9.1.0-beta.3
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/brushing-extension.d.ts +1 -0
- package/dist/brushing/brushing-extension.d.ts.map +1 -1
- package/dist/brushing/brushing-extension.js +16 -19
- package/dist/brushing/brushing-extension.js.map +1 -0
- package/dist/brushing/shader-module.d.ts +8 -2
- package/dist/brushing/shader-module.d.ts.map +1 -1
- package/dist/brushing/shader-module.js +75 -50
- package/dist/brushing/shader-module.js.map +1 -0
- package/dist/clip/clip-extension.d.ts +5 -2
- package/dist/clip/clip-extension.d.ts.map +1 -1
- package/dist/clip/clip-extension.js +37 -42
- package/dist/clip/clip-extension.js.map +1 -0
- package/dist/collision-filter/collision-filter-effect.d.ts +4 -4
- package/dist/collision-filter/collision-filter-effect.d.ts.map +1 -1
- package/dist/collision-filter/collision-filter-effect.js +28 -13
- package/dist/collision-filter/collision-filter-effect.js.map +1 -0
- package/dist/collision-filter/collision-filter-extension.d.ts +1 -1
- package/dist/collision-filter/collision-filter-extension.d.ts.map +1 -1
- package/dist/collision-filter/collision-filter-extension.js +6 -6
- package/dist/collision-filter/collision-filter-extension.js.map +1 -0
- package/dist/collision-filter/collision-filter-pass.d.ts +9 -5
- package/dist/collision-filter/collision-filter-pass.d.ts.map +1 -1
- package/dist/collision-filter/collision-filter-pass.js +15 -4
- package/dist/collision-filter/collision-filter-pass.js.map +1 -0
- package/dist/collision-filter/shader-module.d.ts +3 -2
- package/dist/collision-filter/shader-module.d.ts.map +1 -1
- package/dist/collision-filter/shader-module.js +75 -52
- package/dist/collision-filter/shader-module.js.map +1 -0
- package/dist/data-filter/aggregator.d.ts +4 -10
- package/dist/data-filter/aggregator.d.ts.map +1 -1
- package/dist/data-filter/aggregator.js +15 -8
- package/dist/data-filter/aggregator.js.map +1 -0
- package/dist/data-filter/data-filter-extension.d.ts.map +1 -1
- package/dist/data-filter/data-filter-extension.js +49 -39
- package/dist/data-filter/data-filter-extension.js.map +1 -0
- package/dist/data-filter/shader-module.d.ts +12 -5
- package/dist/data-filter/shader-module.d.ts.map +1 -1
- package/dist/data-filter/shader-module.js +190 -131
- package/dist/data-filter/shader-module.js.map +1 -0
- package/dist/dist.dev.js +2720 -2037
- package/dist/fill-style/fill-style-extension.d.ts.map +1 -1
- package/dist/fill-style/fill-style-extension.js +12 -4
- package/dist/fill-style/fill-style-extension.js.map +1 -0
- package/dist/fill-style/shader-module.d.ts +64 -6
- package/dist/fill-style/shader-module.d.ts.map +1 -1
- package/dist/fill-style/shader-module.js +74 -51
- package/dist/fill-style/shader-module.js.map +1 -0
- package/dist/fp64/fp64-extension.d.ts +1 -0
- package/dist/fp64/fp64-extension.d.ts.map +1 -1
- package/dist/fp64/fp64-extension.js +8 -19
- package/dist/fp64/fp64-extension.js.map +1 -0
- package/dist/fp64/project64.d.ts +2 -2
- package/dist/fp64/project64.d.ts.map +1 -1
- package/dist/fp64/project64.glsl.d.ts +1 -1
- package/dist/fp64/project64.glsl.d.ts.map +1 -1
- package/dist/fp64/project64.glsl.js +19 -21
- package/dist/fp64/project64.glsl.js.map +1 -0
- package/dist/fp64/project64.js +25 -24
- package/dist/fp64/project64.js.map +1 -0
- package/dist/index.cjs +1034 -528
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/mask/mask-effect.d.ts +5 -3
- package/dist/mask/mask-effect.d.ts.map +1 -1
- package/dist/mask/mask-effect.js +13 -5
- package/dist/mask/mask-effect.js.map +1 -0
- package/dist/mask/mask-extension.d.ts +1 -1
- package/dist/mask/mask-extension.d.ts.map +1 -1
- package/dist/mask/mask-extension.js +14 -8
- package/dist/mask/mask-extension.js.map +1 -0
- package/dist/mask/mask-pass.d.ts +2 -43
- package/dist/mask/mask-pass.d.ts.map +1 -1
- package/dist/mask/mask-pass.js +5 -1
- package/dist/mask/mask-pass.js.map +1 -0
- package/dist/mask/shader-module.d.ts +60 -3
- package/dist/mask/shader-module.d.ts.map +1 -1
- package/dist/mask/shader-module.js +74 -46
- package/dist/mask/shader-module.js.map +1 -0
- package/dist/path-style/path-style-extension.d.ts.map +1 -1
- package/dist/path-style/path-style-extension.js +21 -24
- package/dist/path-style/path-style-extension.js.map +1 -0
- package/dist/path-style/shaders.glsl.d.ts.map +1 -1
- package/dist/path-style/shaders.glsl.js +12 -7
- package/dist/path-style/shaders.glsl.js.map +1 -0
- package/dist/terrain/height-map-builder.d.ts.map +1 -1
- package/dist/terrain/height-map-builder.js +4 -0
- package/dist/terrain/height-map-builder.js.map +1 -0
- package/dist/terrain/shader-module.d.ts +60 -6
- package/dist/terrain/shader-module.d.ts.map +1 -1
- package/dist/terrain/shader-module.js +70 -61
- package/dist/terrain/shader-module.js.map +1 -0
- package/dist/terrain/terrain-cover.d.ts.map +1 -1
- package/dist/terrain/terrain-cover.js +4 -0
- package/dist/terrain/terrain-cover.js.map +1 -0
- package/dist/terrain/terrain-effect.d.ts +4 -2
- package/dist/terrain/terrain-effect.d.ts.map +1 -1
- package/dist/terrain/terrain-effect.js +32 -18
- package/dist/terrain/terrain-effect.js.map +1 -0
- package/dist/terrain/terrain-extension.d.ts.map +1 -1
- package/dist/terrain/terrain-extension.js +4 -0
- package/dist/terrain/terrain-extension.js.map +1 -0
- package/dist/terrain/terrain-pass.d.ts +6 -41
- package/dist/terrain/terrain-pass.d.ts.map +1 -1
- package/dist/terrain/terrain-pass.js +12 -1
- package/dist/terrain/terrain-pass.js.map +1 -0
- package/dist/terrain/terrain-picking-pass.d.ts +7 -1
- package/dist/terrain/terrain-picking-pass.d.ts.map +1 -1
- package/dist/terrain/terrain-picking-pass.js +12 -1
- package/dist/terrain/terrain-picking-pass.js.map +1 -0
- package/dist/terrain/utils.d.ts.map +1 -1
- package/dist/terrain/utils.js +4 -0
- package/dist/terrain/utils.js.map +1 -0
- package/dist/utils/debug.d.ts +2 -2
- package/dist/utils/debug.d.ts.map +1 -1
- package/dist/utils/debug.js +4 -1
- package/dist/utils/debug.js.map +1 -0
- package/dist/utils/projection-utils.d.ts.map +1 -1
- package/dist/utils/projection-utils.js +4 -0
- package/dist/utils/projection-utils.js.map +1 -0
- package/dist.min.js +1102 -817
- package/package.json +8 -8
- package/src/brushing/brushing-extension.ts +17 -20
- package/src/brushing/shader-module.ts +58 -47
- package/src/clip/clip-extension.ts +38 -40
- package/src/collision-filter/collision-filter-effect.ts +31 -20
- package/src/collision-filter/collision-filter-extension.ts +6 -7
- package/src/collision-filter/collision-filter-pass.ts +17 -6
- package/src/collision-filter/shader-module.ts +40 -22
- package/src/data-filter/aggregator.ts +23 -11
- package/src/data-filter/data-filter-extension.ts +76 -49
- package/src/data-filter/shader-module.ts +150 -90
- package/src/fill-style/fill-style-extension.ts +13 -5
- package/src/fill-style/shader-module.ts +84 -52
- package/src/fp64/fp64-extension.ts +8 -19
- package/src/fp64/project64.glsl.ts +18 -21
- package/src/fp64/project64.ts +27 -28
- package/src/index.ts +5 -0
- package/src/mask/mask-effect.ts +17 -7
- package/src/mask/mask-extension.ts +16 -9
- package/src/mask/mask-pass.ts +17 -3
- package/src/mask/shader-module.ts +63 -27
- package/src/path-style/path-style-extension.ts +27 -28
- package/src/path-style/shaders.glsl.ts +13 -7
- package/src/terrain/height-map-builder.ts +4 -0
- package/src/terrain/shader-module.ts +62 -44
- package/src/terrain/terrain-cover.ts +4 -0
- package/src/terrain/terrain-effect.ts +36 -19
- package/src/terrain/terrain-extension.ts +4 -0
- package/src/terrain/terrain-pass.ts +19 -3
- package/src/terrain/terrain-picking-pass.ts +15 -2
- package/src/terrain/utils.ts +4 -0
- package/src/utils/debug.ts +4 -0
- package/src/utils/projection-utils.ts +4 -0
- package/dist/utils/syntax-tags.d.ts +0 -6
- package/dist/utils/syntax-tags.d.ts.map +0 -1
- package/dist/utils/syntax-tags.js +0 -5
- package/src/utils/syntax-tags.ts +0 -5
|
@@ -1,28 +1,16 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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.
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
20
4
|
|
|
21
5
|
export default `\
|
|
22
6
|
|
|
23
7
|
const vec2 WORLD_SCALE_FP64 = vec2(81.4873275756836, 0.0000032873668232014097);
|
|
24
8
|
|
|
25
|
-
uniform
|
|
9
|
+
uniform project64Uniforms {
|
|
10
|
+
vec2 scale;
|
|
11
|
+
mat4 viewProjectionMatrix;
|
|
12
|
+
mat4 viewProjectionMatrix64Low;
|
|
13
|
+
} project64;
|
|
26
14
|
|
|
27
15
|
// longitude: lnglat_fp64.xy; latitude: lnglat_fp64.zw
|
|
28
16
|
void mercatorProject_fp64(vec4 lnglat_fp64, out vec2 out_val[2]) {
|
|
@@ -56,7 +44,16 @@ void project_position_fp64(vec2 position, vec2 position64xyLow, out vec2 out_val
|
|
|
56
44
|
|
|
57
45
|
vec4 project_common_position_to_clipspace_fp64(vec2 vertex_pos_modelspace[4]) {
|
|
58
46
|
vec2 vertex_pos_clipspace[4];
|
|
59
|
-
|
|
47
|
+
vec2 viewProjectionMatrixFP64[16];
|
|
48
|
+
for (int i = 0; i < 4; i++) {
|
|
49
|
+
for (int j = 0; j < 4; j++) {
|
|
50
|
+
viewProjectionMatrixFP64[4 * i + j] = vec2(
|
|
51
|
+
project64.viewProjectionMatrix[j][i],
|
|
52
|
+
project64.viewProjectionMatrix64Low[j][i]
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
mat4_vec4_mul_fp64(viewProjectionMatrixFP64, vertex_pos_modelspace,
|
|
60
57
|
vertex_pos_clipspace);
|
|
61
58
|
return vec4(
|
|
62
59
|
vertex_pos_clipspace[0].x,
|
package/src/fp64/project64.ts
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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.
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
20
4
|
|
|
21
5
|
/* eslint-disable camelcase */
|
|
22
6
|
import {fp64} from '@luma.gl/shadertools';
|
|
@@ -27,7 +11,7 @@ import {project, _memoize as memoize} from '@deck.gl/core';
|
|
|
27
11
|
import type {Viewport} from '@deck.gl/core';
|
|
28
12
|
import project64Shader from './project64.glsl';
|
|
29
13
|
|
|
30
|
-
type
|
|
14
|
+
type Project64ModuleProps = {
|
|
31
15
|
viewport: Viewport;
|
|
32
16
|
};
|
|
33
17
|
|
|
@@ -35,15 +19,21 @@ export default {
|
|
|
35
19
|
name: 'project64',
|
|
36
20
|
dependencies: [project, fp64],
|
|
37
21
|
vs: project64Shader,
|
|
38
|
-
getUniforms
|
|
39
|
-
|
|
22
|
+
getUniforms,
|
|
23
|
+
uniformTypes: {
|
|
24
|
+
scale: 'vec2<f32>',
|
|
25
|
+
// Cannot pass as vec2[16], so instead split into 2 mat4x4
|
|
26
|
+
viewProjectionMatrix: 'mat4x4<f32>',
|
|
27
|
+
viewProjectionMatrix64Low: 'mat4x4<f32>'
|
|
28
|
+
}
|
|
29
|
+
} as ShaderModule<Project64ModuleProps>;
|
|
40
30
|
|
|
41
31
|
// TODO - this module should calculate the 64 bit uniforms
|
|
42
32
|
// It is currently done by project to minimize duplicated work
|
|
43
33
|
|
|
44
34
|
const getMemoizedUniforms = memoize(calculateUniforms);
|
|
45
35
|
|
|
46
|
-
function getUniforms(opts?:
|
|
36
|
+
function getUniforms(opts?: Project64ModuleProps | {}): Record<string, any> {
|
|
47
37
|
if (opts && 'viewport' in opts) {
|
|
48
38
|
const {viewProjectionMatrix, scale} = opts.viewport;
|
|
49
39
|
// We only need to update fp64 uniforms if fp32 projection is being updated
|
|
@@ -60,11 +50,20 @@ function calculateUniforms({
|
|
|
60
50
|
scale: number;
|
|
61
51
|
}) {
|
|
62
52
|
const glViewProjectionMatrixFP64 = fp64ifyMatrix4(viewProjectionMatrix);
|
|
63
|
-
const
|
|
64
|
-
|
|
53
|
+
const viewProjectionMatrix64High = new Float32Array(16);
|
|
54
|
+
const viewProjectionMatrix64Low = new Float32Array(16);
|
|
55
|
+
for (let i = 0; i < 4; i++) {
|
|
56
|
+
for (let j = 0; j < 4; j++) {
|
|
57
|
+
// Match order used in project.viewProjectionMatrix
|
|
58
|
+
const from = 4 * i + j;
|
|
59
|
+
const to = 4 * j + i;
|
|
60
|
+
viewProjectionMatrix64High[to] = glViewProjectionMatrixFP64[2 * from];
|
|
61
|
+
viewProjectionMatrix64Low[to] = glViewProjectionMatrixFP64[2 * from + 1];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
65
64
|
return {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
scale: fp64ify(scale),
|
|
66
|
+
viewProjectionMatrix: [...viewProjectionMatrix64High],
|
|
67
|
+
viewProjectionMatrix64Low: [...viewProjectionMatrix64Low]
|
|
69
68
|
};
|
|
70
69
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
export {default as BrushingExtension} from './brushing/brushing-extension';
|
|
2
6
|
export {default as DataFilterExtension} from './data-filter/data-filter-extension';
|
|
3
7
|
export {default as Fp64Extension} from './fp64/fp64-extension';
|
|
@@ -29,3 +33,4 @@ export type {ClipExtensionProps} from './clip/clip-extension';
|
|
|
29
33
|
export type {CollisionFilterExtensionProps} from './collision-filter/collision-filter-extension';
|
|
30
34
|
export type {MaskExtensionProps} from './mask/mask-extension';
|
|
31
35
|
export type {TerrainExtensionProps} from './terrain/terrain-extension';
|
|
36
|
+
export type {TerrainModuleProps} from './terrain/shader-module';
|
package/src/mask/mask-effect.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import {
|
|
2
6
|
Layer,
|
|
3
7
|
Viewport,
|
|
@@ -186,8 +190,10 @@ export default class MaskEffect implements Effect {
|
|
|
186
190
|
viewports: maskViewport ? [maskViewport] : [],
|
|
187
191
|
onViewportActive,
|
|
188
192
|
views,
|
|
189
|
-
|
|
190
|
-
|
|
193
|
+
shaderModuleProps: {
|
|
194
|
+
project: {
|
|
195
|
+
devicePixelRatio: 1
|
|
196
|
+
}
|
|
191
197
|
}
|
|
192
198
|
});
|
|
193
199
|
|
|
@@ -257,13 +263,17 @@ export default class MaskEffect implements Effect {
|
|
|
257
263
|
return channelMap;
|
|
258
264
|
}
|
|
259
265
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
266
|
+
getShaderModuleProps(): {
|
|
267
|
+
mask: {
|
|
268
|
+
maskMap: Texture;
|
|
269
|
+
maskChannels: Record<string, Mask> | null;
|
|
270
|
+
};
|
|
263
271
|
} {
|
|
264
272
|
return {
|
|
265
|
-
|
|
266
|
-
|
|
273
|
+
mask: {
|
|
274
|
+
maskMap: this.masks ? this.maskMap! : this.dummyMaskMap!,
|
|
275
|
+
maskChannels: this.masks
|
|
276
|
+
}
|
|
267
277
|
};
|
|
268
278
|
}
|
|
269
279
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import {COORDINATE_SYSTEM, Layer, LayerExtension, log} from '@deck.gl/core';
|
|
2
|
-
import mask from './shader-module';
|
|
6
|
+
import mask, {MaskProps} from './shader-module';
|
|
3
7
|
import MaskEffect from './mask-effect';
|
|
4
8
|
|
|
5
9
|
const defaultProps = {
|
|
@@ -49,17 +53,18 @@ export default class MaskExtension extends LayerExtension {
|
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
/* eslint-disable camelcase */
|
|
52
|
-
draw(this: Layer<Required<MaskExtensionProps>>, {
|
|
53
|
-
|
|
56
|
+
draw(this: Layer<Required<MaskExtensionProps>>, {context, shaderModuleProps}: any) {
|
|
57
|
+
const maskProps = {} as MaskProps;
|
|
58
|
+
maskProps.maskByInstance = Boolean(this.state.maskByInstance);
|
|
54
59
|
const {maskId, maskInverted} = this.props;
|
|
55
|
-
const {maskChannels} =
|
|
60
|
+
const {maskChannels} = shaderModuleProps.mask || {};
|
|
56
61
|
const {viewport} = context;
|
|
57
62
|
if (maskChannels && maskChannels[maskId]) {
|
|
58
63
|
const {index, bounds, coordinateOrigin: fromCoordinateOrigin} = maskChannels[maskId];
|
|
59
64
|
let {coordinateSystem: fromCoordinateSystem} = maskChannels[maskId];
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
maskProps.enabled = true;
|
|
66
|
+
maskProps.channel = index;
|
|
67
|
+
maskProps.inverted = maskInverted;
|
|
63
68
|
|
|
64
69
|
if (fromCoordinateSystem === COORDINATE_SYSTEM.DEFAULT) {
|
|
65
70
|
fromCoordinateSystem = viewport.isGeospatial
|
|
@@ -69,12 +74,14 @@ export default class MaskExtension extends LayerExtension {
|
|
|
69
74
|
const opts = {modelMatrix: null, fromCoordinateOrigin, fromCoordinateSystem};
|
|
70
75
|
const bl = this.projectPosition([bounds[0], bounds[1], 0], opts);
|
|
71
76
|
const tr = this.projectPosition([bounds[2], bounds[3], 0], opts);
|
|
72
|
-
|
|
77
|
+
maskProps.bounds = [bl[0], bl[1], tr[0], tr[1]];
|
|
73
78
|
} else {
|
|
74
79
|
if (maskId) {
|
|
75
80
|
log.warn(`Could not find a mask layer with id: ${maskId}`)();
|
|
76
81
|
}
|
|
77
|
-
|
|
82
|
+
maskProps.enabled = false;
|
|
78
83
|
}
|
|
84
|
+
|
|
85
|
+
this.setShaderModuleProps({mask: maskProps});
|
|
79
86
|
}
|
|
80
87
|
}
|
package/src/mask/mask-pass.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
Device,
|
|
7
|
+
Framebuffer,
|
|
8
|
+
Parameters,
|
|
9
|
+
RenderPipelineParameters,
|
|
10
|
+
Texture
|
|
11
|
+
} from '@luma.gl/core';
|
|
2
12
|
import {Layer, _LayersPass as LayersPass, LayersPassRenderOptions, Viewport} from '@deck.gl/core';
|
|
3
13
|
|
|
4
14
|
type MaskPassRenderOptions = LayersPassRenderOptions & {
|
|
@@ -50,11 +60,15 @@ export default class MaskPass extends LayersPass {
|
|
|
50
60
|
super.render({...options, clearColor, colorMask, target: this.fbo, pass: 'mask'});
|
|
51
61
|
}
|
|
52
62
|
|
|
53
|
-
protected getLayerParameters(
|
|
63
|
+
protected getLayerParameters(
|
|
64
|
+
layer: Layer<{}>,
|
|
65
|
+
layerIndex: number,
|
|
66
|
+
viewport: Viewport
|
|
67
|
+
): Parameters {
|
|
54
68
|
return {
|
|
55
69
|
...layer.props.parameters,
|
|
56
70
|
blend: true,
|
|
57
|
-
|
|
71
|
+
depthCompare: 'always',
|
|
58
72
|
...MASK_BLENDING
|
|
59
73
|
};
|
|
60
74
|
}
|
|
@@ -1,38 +1,52 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import type {ShaderModule} from '@luma.gl/shadertools';
|
|
2
6
|
import {project} from '@deck.gl/core';
|
|
3
7
|
import type {Texture} from '@luma.gl/core';
|
|
4
|
-
import {glsl} from '../utils/syntax-tags';
|
|
5
8
|
|
|
6
|
-
const
|
|
7
|
-
uniform
|
|
8
|
-
|
|
9
|
+
const uniformBlock = /* glsl */ `\
|
|
10
|
+
uniform maskUniforms {
|
|
11
|
+
vec4 bounds;
|
|
12
|
+
highp int channel;
|
|
13
|
+
bool enabled;
|
|
14
|
+
bool inverted;
|
|
15
|
+
bool maskByInstance;
|
|
16
|
+
} mask;
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
const vertex = /* glsl */ `
|
|
9
20
|
vec2 mask_getCoords(vec4 position) {
|
|
10
|
-
return (position.xy -
|
|
21
|
+
return (position.xy - mask.bounds.xy) / (mask.bounds.zw - mask.bounds.xy);
|
|
11
22
|
}
|
|
12
23
|
`;
|
|
13
24
|
|
|
14
|
-
const
|
|
25
|
+
const vs = `
|
|
26
|
+
${uniformBlock}
|
|
27
|
+
${vertex}
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
const fragment = /* glsl */ `
|
|
15
31
|
uniform sampler2D mask_texture;
|
|
16
|
-
|
|
17
|
-
uniform bool mask_enabled;
|
|
18
|
-
uniform bool mask_inverted;
|
|
32
|
+
|
|
19
33
|
bool mask_isInBounds(vec2 texCoords) {
|
|
20
|
-
if (!
|
|
34
|
+
if (!mask.enabled) {
|
|
21
35
|
return true;
|
|
22
36
|
}
|
|
23
37
|
vec4 maskColor = texture(mask_texture, texCoords);
|
|
24
38
|
float maskValue = 1.0;
|
|
25
|
-
if (
|
|
39
|
+
if (mask.channel == 0) {
|
|
26
40
|
maskValue = maskColor.r;
|
|
27
|
-
} else if (
|
|
41
|
+
} else if (mask.channel == 1) {
|
|
28
42
|
maskValue = maskColor.g;
|
|
29
|
-
} else if (
|
|
43
|
+
} else if (mask.channel == 2) {
|
|
30
44
|
maskValue = maskColor.b;
|
|
31
|
-
} else if (
|
|
45
|
+
} else if (mask.channel == 3) {
|
|
32
46
|
maskValue = maskColor.a;
|
|
33
47
|
}
|
|
34
48
|
|
|
35
|
-
if (
|
|
49
|
+
if (mask.inverted) {
|
|
36
50
|
return maskValue >= 0.5;
|
|
37
51
|
} else {
|
|
38
52
|
return maskValue < 0.5;
|
|
@@ -40,47 +54,62 @@ bool mask_isInBounds(vec2 texCoords) {
|
|
|
40
54
|
}
|
|
41
55
|
`;
|
|
42
56
|
|
|
57
|
+
const fs = `
|
|
58
|
+
${uniformBlock}
|
|
59
|
+
${fragment}
|
|
60
|
+
`;
|
|
61
|
+
|
|
43
62
|
const inject = {
|
|
44
|
-
'vs:#decl': glsl`
|
|
63
|
+
'vs:#decl': /* glsl */ `
|
|
45
64
|
out vec2 mask_texCoords;
|
|
46
65
|
`,
|
|
47
|
-
'vs:#main-end': glsl`
|
|
66
|
+
'vs:#main-end': /* glsl */ `
|
|
48
67
|
vec4 mask_common_position;
|
|
49
|
-
if (
|
|
68
|
+
if (mask.maskByInstance) {
|
|
50
69
|
mask_common_position = project_position(vec4(geometry.worldPosition, 1.0));
|
|
51
70
|
} else {
|
|
52
71
|
mask_common_position = geometry.position;
|
|
53
72
|
}
|
|
54
73
|
mask_texCoords = mask_getCoords(mask_common_position);
|
|
55
74
|
`,
|
|
56
|
-
'fs:#decl': glsl`
|
|
75
|
+
'fs:#decl': /* glsl */ `
|
|
57
76
|
in vec2 mask_texCoords;
|
|
58
77
|
`,
|
|
59
|
-
'fs:#main-start': glsl`
|
|
60
|
-
if (
|
|
78
|
+
'fs:#main-start': /* glsl */ `
|
|
79
|
+
if (mask.enabled) {
|
|
61
80
|
bool mask = mask_isInBounds(mask_texCoords);
|
|
62
81
|
|
|
63
82
|
// Debug: show extent of render target
|
|
64
83
|
// fragColor = vec4(mask_texCoords, 0.0, 1.0);
|
|
65
|
-
fragColor = texture(mask_texture, mask_texCoords);
|
|
84
|
+
// fragColor = texture(mask_texture, mask_texCoords);
|
|
66
85
|
|
|
67
86
|
if (!mask) discard;
|
|
68
87
|
}
|
|
69
88
|
`
|
|
70
89
|
};
|
|
71
90
|
|
|
72
|
-
type
|
|
91
|
+
type MaskBindingProps = {
|
|
73
92
|
maskMap?: Texture;
|
|
74
93
|
};
|
|
75
94
|
|
|
95
|
+
type MaskUniformProps = {
|
|
96
|
+
bounds: [number, number, number, number];
|
|
97
|
+
channel: number;
|
|
98
|
+
enabled: boolean;
|
|
99
|
+
inverted: boolean;
|
|
100
|
+
maskByInstance: boolean;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export type MaskProps = MaskBindingProps & MaskUniformProps;
|
|
104
|
+
|
|
76
105
|
/* eslint-disable camelcase */
|
|
77
|
-
const getMaskUniforms = (opts?:
|
|
106
|
+
const getMaskUniforms = (opts?: MaskProps | {}): Record<string, any> => {
|
|
78
107
|
if (opts && 'maskMap' in opts) {
|
|
79
108
|
return {
|
|
80
109
|
mask_texture: opts.maskMap
|
|
81
110
|
};
|
|
82
111
|
}
|
|
83
|
-
return {};
|
|
112
|
+
return opts || {};
|
|
84
113
|
};
|
|
85
114
|
|
|
86
115
|
export default {
|
|
@@ -89,5 +118,12 @@ export default {
|
|
|
89
118
|
vs,
|
|
90
119
|
fs,
|
|
91
120
|
inject,
|
|
92
|
-
getUniforms: getMaskUniforms
|
|
93
|
-
|
|
121
|
+
getUniforms: getMaskUniforms,
|
|
122
|
+
uniformTypes: {
|
|
123
|
+
bounds: 'vec4<f32>',
|
|
124
|
+
channel: 'i32',
|
|
125
|
+
enabled: 'i32',
|
|
126
|
+
inverted: 'i32',
|
|
127
|
+
maskByInstance: 'i32'
|
|
128
|
+
}
|
|
129
|
+
} as const satisfies ShaderModule<MaskProps>;
|
|
@@ -1,29 +1,13 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
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.
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
20
4
|
|
|
21
5
|
import {LayerExtension, _mergeShaders as mergeShaders} from '@deck.gl/core';
|
|
22
6
|
import {vec3} from '@math.gl/core';
|
|
23
7
|
import {dashShaders, offsetShaders} from './shaders.glsl';
|
|
24
8
|
|
|
25
9
|
import type {Layer, LayerContext, Accessor, UpdateParameters} from '@deck.gl/core';
|
|
26
|
-
import type {
|
|
10
|
+
import type {ShaderModule} from '@luma.gl/shadertools';
|
|
27
11
|
|
|
28
12
|
const defaultProps = {
|
|
29
13
|
getDashArray: {type: 'accessor', value: [0, 0]},
|
|
@@ -32,6 +16,11 @@ const defaultProps = {
|
|
|
32
16
|
dashGapPickable: false
|
|
33
17
|
};
|
|
34
18
|
|
|
19
|
+
type PathStyleProps = {
|
|
20
|
+
dashAlignMode: number;
|
|
21
|
+
dashGapPickable: boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
35
24
|
export type PathStyleExtensionProps<DataT = any> = {
|
|
36
25
|
/**
|
|
37
26
|
* Accessor for the dash array to draw each path with: `[dashSize, gapSize]` relative to the width of the path.
|
|
@@ -97,7 +86,7 @@ export default class PathStyleExtension extends LayerExtension<PathStyleExtensio
|
|
|
97
86
|
}
|
|
98
87
|
|
|
99
88
|
// Merge shader injection
|
|
100
|
-
let result = {};
|
|
89
|
+
let result = {} as {inject: Record<string, string>};
|
|
101
90
|
if (extension.opts.dash) {
|
|
102
91
|
result = mergeShaders(result, dashShaders);
|
|
103
92
|
}
|
|
@@ -105,7 +94,18 @@ export default class PathStyleExtension extends LayerExtension<PathStyleExtensio
|
|
|
105
94
|
result = mergeShaders(result, offsetShaders);
|
|
106
95
|
}
|
|
107
96
|
|
|
108
|
-
|
|
97
|
+
const {inject} = result;
|
|
98
|
+
const pathStyle: ShaderModule<PathStyleProps> = {
|
|
99
|
+
name: 'pathStyle',
|
|
100
|
+
inject,
|
|
101
|
+
uniformTypes: {
|
|
102
|
+
dashAlignMode: 'f32',
|
|
103
|
+
dashGapPickable: 'i32'
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
modules: [pathStyle]
|
|
108
|
+
};
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
initializeState(this: Layer<PathStyleExtensionProps>, context: LayerContext, extension: this) {
|
|
@@ -149,14 +149,13 @@ export default class PathStyleExtension extends LayerExtension<PathStyleExtensio
|
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
const uniforms: any = {};
|
|
153
|
-
|
|
154
152
|
if (extension.opts.dash) {
|
|
155
|
-
|
|
156
|
-
|
|
153
|
+
const pathStyleProps: PathStyleProps = {
|
|
154
|
+
dashAlignMode: this.props.dashJustified ? 1 : 0,
|
|
155
|
+
dashGapPickable: Boolean(this.props.dashGapPickable)
|
|
156
|
+
};
|
|
157
|
+
this.setShaderModuleProps({pathStyle: pathStyleProps});
|
|
157
158
|
}
|
|
158
|
-
|
|
159
|
-
(this.state.model as Model)?.setUniforms(uniforms);
|
|
160
159
|
}
|
|
161
160
|
|
|
162
161
|
getDashOffsets(this: Layer<PathStyleExtensionProps>, path: number[] | number[][]): number[] {
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
export const dashShaders = {
|
|
2
6
|
inject: {
|
|
3
7
|
'vs:#decl': `
|
|
@@ -13,9 +17,11 @@ vDashOffset = instanceDashOffsets / width.x;
|
|
|
13
17
|
`,
|
|
14
18
|
|
|
15
19
|
'fs:#decl': `
|
|
16
|
-
uniform
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
uniform pathStyleUniforms {
|
|
21
|
+
float dashAlignMode;
|
|
22
|
+
bool dashGapPickable;
|
|
23
|
+
} pathStyle;
|
|
24
|
+
|
|
19
25
|
in vec2 vDashArray;
|
|
20
26
|
in float vDashOffset;
|
|
21
27
|
`,
|
|
@@ -36,7 +42,7 @@ in float vDashOffset;
|
|
|
36
42
|
float offset;
|
|
37
43
|
|
|
38
44
|
if (unitLength > 0.0) {
|
|
39
|
-
if (dashAlignMode == 0.0) {
|
|
45
|
+
if (pathStyle.dashAlignMode == 0.0) {
|
|
40
46
|
offset = vDashOffset;
|
|
41
47
|
} else {
|
|
42
48
|
unitLength = vPathLength / round(vPathLength / unitLength);
|
|
@@ -46,8 +52,8 @@ in float vDashOffset;
|
|
|
46
52
|
float unitOffset = mod(vPathPosition.y + offset, unitLength);
|
|
47
53
|
|
|
48
54
|
if (gapLength > 0.0 && unitOffset > solidLength) {
|
|
49
|
-
if (capType <= 0.5) {
|
|
50
|
-
if (!(dashGapPickable && bool(picking.isActive))) {
|
|
55
|
+
if (path.capType <= 0.5) {
|
|
56
|
+
if (!(pathStyle.dashGapPickable && bool(picking.isActive))) {
|
|
51
57
|
discard;
|
|
52
58
|
}
|
|
53
59
|
} else {
|
|
@@ -57,7 +63,7 @@ in float vDashOffset;
|
|
|
57
63
|
vPathPosition.x
|
|
58
64
|
));
|
|
59
65
|
if (distToEnd > 1.0) {
|
|
60
|
-
if (!(dashGapPickable && bool(picking.isActive))) {
|
|
66
|
+
if (!(pathStyle.dashGapPickable && bool(picking.isActive))) {
|
|
61
67
|
discard;
|
|
62
68
|
}
|
|
63
69
|
}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import {Device, Framebuffer} from '@luma.gl/core';
|
|
2
6
|
import {joinLayerBounds, getRenderBounds, makeViewport, Bounds} from '../utils/projection-utils';
|
|
3
7
|
import {createRenderTarget} from './utils';
|