@deck.gl/extensions 8.9.0-alpha.4 → 8.9.0-beta.1
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 +3688 -14538
- package/dist/es5/brushing/brushing.js +0 -8
- package/dist/es5/brushing/brushing.js.map +1 -1
- package/dist/es5/clip/clip.js +5 -5
- package/dist/es5/clip/clip.js.map +1 -1
- package/dist/es5/collide/collide-effect.js +285 -0
- package/dist/es5/collide/collide-effect.js.map +1 -0
- package/dist/es5/collide/collide-pass.js +80 -0
- package/dist/es5/collide/collide-pass.js.map +1 -0
- package/dist/es5/collide/collide.js +116 -0
- package/dist/es5/collide/collide.js.map +1 -0
- package/dist/es5/collide/shader-module.js +39 -0
- package/dist/es5/collide/shader-module.js.map +1 -0
- package/dist/es5/common/projection-utils.js +164 -0
- package/dist/es5/common/projection-utils.js.map +1 -0
- package/dist/es5/data-filter/shader-module.js +1 -0
- package/dist/es5/data-filter/shader-module.js.map +1 -1
- package/dist/es5/fill-style/fill-style.js +16 -125
- package/dist/es5/fill-style/fill-style.js.map +1 -1
- package/dist/es5/fill-style/shaders.glsl.js +6 -8
- package/dist/es5/fill-style/shaders.glsl.js.map +1 -1
- package/dist/es5/fp64/project64.glsl.js +1 -1
- package/dist/es5/index.js +16 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/mask/mask-effect.js +280 -0
- package/dist/es5/mask/mask-effect.js.map +1 -0
- package/dist/es5/mask/mask-pass.js +106 -0
- package/dist/es5/mask/mask-pass.js.map +1 -0
- package/dist/es5/mask/mask.js +17 -4
- package/dist/es5/mask/mask.js.map +1 -1
- package/dist/es5/mask/shader-module.js +1 -1
- package/dist/es5/mask/shader-module.js.map +1 -1
- package/dist/es5/mask/utils.js +136 -0
- package/dist/es5/mask/utils.js.map +1 -0
- package/dist/es5/path-style/shaders.glsl.js +1 -1
- package/dist/es5/terrain/height-map-builder.js +116 -0
- package/dist/es5/terrain/height-map-builder.js.map +1 -0
- package/dist/es5/terrain/shader-module.js +84 -0
- package/dist/es5/terrain/shader-module.js.map +1 -0
- package/dist/es5/terrain/terrain-cover.js +259 -0
- package/dist/es5/terrain/terrain-cover.js.map +1 -0
- package/dist/es5/terrain/terrain-effect.js +337 -0
- package/dist/es5/terrain/terrain-effect.js.map +1 -0
- package/dist/es5/terrain/terrain-pass.js +122 -0
- package/dist/es5/terrain/terrain-pass.js.map +1 -0
- package/dist/es5/terrain/terrain-picking-pass.js +130 -0
- package/dist/es5/terrain/terrain-picking-pass.js.map +1 -0
- package/dist/es5/terrain/terrain.js +101 -0
- package/dist/es5/terrain/terrain.js.map +1 -0
- package/dist/es5/terrain/utils.js +32 -0
- package/dist/es5/terrain/utils.js.map +1 -0
- package/dist/es5/utils/debug.js +71 -0
- package/dist/es5/utils/debug.js.map +1 -0
- package/dist/esm/brushing/brushing.js +0 -7
- package/dist/esm/brushing/brushing.js.map +1 -1
- package/dist/esm/clip/clip.js +5 -4
- package/dist/esm/clip/clip.js.map +1 -1
- package/dist/esm/collide/collide-effect.js +250 -0
- package/dist/esm/collide/collide-effect.js.map +1 -0
- package/dist/esm/collide/collide-pass.js +30 -0
- package/dist/esm/collide/collide-pass.js.map +1 -0
- package/dist/esm/collide/collide.js +78 -0
- package/dist/esm/collide/collide.js.map +1 -0
- package/dist/esm/collide/shader-module.js +32 -0
- package/dist/esm/collide/shader-module.js.map +1 -0
- package/dist/esm/common/projection-utils.js +130 -0
- package/dist/esm/common/projection-utils.js.map +1 -0
- package/dist/esm/data-filter/shader-module.js +1 -0
- package/dist/esm/data-filter/shader-module.js.map +1 -1
- package/dist/esm/fill-style/fill-style.js +20 -72
- package/dist/esm/fill-style/fill-style.js.map +1 -1
- package/dist/esm/fill-style/shaders.glsl.js +5 -7
- package/dist/esm/fill-style/shaders.glsl.js.map +1 -1
- package/dist/esm/fp64/project64.glsl.js +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/mask/mask-effect.js +233 -0
- package/dist/esm/mask/mask-effect.js.map +1 -0
- package/dist/esm/mask/mask-pass.js +62 -0
- package/dist/esm/mask/mask-pass.js.map +1 -0
- package/dist/esm/mask/mask.js +14 -3
- package/dist/esm/mask/mask.js.map +1 -1
- package/dist/esm/mask/shader-module.js +1 -1
- package/dist/esm/mask/shader-module.js.map +1 -1
- package/dist/esm/mask/utils.js +109 -0
- package/dist/esm/mask/utils.js.map +1 -0
- package/dist/esm/path-style/shaders.glsl.js +1 -1
- package/dist/esm/terrain/height-map-builder.js +92 -0
- package/dist/esm/terrain/height-map-builder.js.map +1 -0
- package/dist/esm/terrain/shader-module.js +73 -0
- package/dist/esm/terrain/shader-module.js.map +1 -0
- package/dist/esm/terrain/terrain-cover.js +219 -0
- package/dist/esm/terrain/terrain-cover.js.map +1 -0
- package/dist/esm/terrain/terrain-effect.js +231 -0
- package/dist/esm/terrain/terrain-effect.js.map +1 -0
- package/dist/esm/terrain/terrain-pass.js +69 -0
- package/dist/esm/terrain/terrain-pass.js.map +1 -0
- package/dist/esm/terrain/terrain-picking-pass.js +75 -0
- package/dist/esm/terrain/terrain-picking-pass.js.map +1 -0
- package/dist/esm/terrain/terrain.js +62 -0
- package/dist/esm/terrain/terrain.js.map +1 -0
- package/dist/esm/terrain/utils.js +21 -0
- package/dist/esm/terrain/utils.js.map +1 -0
- package/dist/esm/utils/debug.js +61 -0
- package/dist/esm/utils/debug.js.map +1 -0
- package/dist.min.js +1359 -1
- package/package.json +6 -4
- package/src/brushing/brushing.ts +0 -11
- package/src/clip/clip.ts +6 -5
- package/src/collide/collide-effect.ts +257 -0
- package/src/collide/collide-pass.ts +35 -0
- package/src/collide/collide.ts +79 -0
- package/src/collide/shader-module.ts +113 -0
- package/src/common/projection-utils.ts +187 -0
- package/src/data-filter/shader-module.ts +6 -0
- package/src/fill-style/fill-style.ts +15 -53
- package/src/fill-style/shaders.glsl.ts +6 -7
- package/src/index.ts +4 -0
- package/src/mask/mask-effect.ts +255 -0
- package/src/mask/mask-pass.ts +67 -0
- package/src/mask/mask.ts +17 -7
- package/src/mask/shader-module.ts +7 -1
- package/src/mask/utils.ts +148 -0
- package/src/terrain/height-map-builder.ts +120 -0
- package/src/terrain/shader-module.ts +161 -0
- package/src/terrain/terrain-cover.ts +225 -0
- package/src/terrain/terrain-effect.ts +223 -0
- package/src/terrain/terrain-pass.ts +86 -0
- package/src/terrain/terrain-picking-pass.ts +87 -0
- package/src/terrain/terrain.ts +74 -0
- package/src/terrain/utils.ts +29 -0
- package/src/utils/debug.ts +59 -0
- package/typed/brushing/brushing.d.ts +0 -1
- package/typed/brushing/brushing.d.ts.map +1 -1
- package/typed/brushing/brushing.js +83 -0
- package/typed/brushing/shader-module.js +116 -0
- package/typed/clip/clip.d.ts +1 -1
- package/typed/clip/clip.d.ts.map +1 -1
- package/typed/clip/clip.js +114 -0
- package/typed/collide/collide-effect.d.ts +28 -0
- package/typed/collide/collide-effect.d.ts.map +1 -0
- package/typed/collide/collide-pass.d.ts +14 -0
- package/typed/collide/collide-pass.d.ts.map +1 -0
- package/typed/collide/collide.d.ts +41 -0
- package/typed/collide/collide.d.ts.map +1 -0
- package/typed/collide/shader-module.d.ts +4 -0
- package/typed/collide/shader-module.d.ts.map +1 -0
- package/typed/common/projection-utils.d.ts +27 -0
- package/typed/common/projection-utils.d.ts.map +1 -0
- package/typed/data-filter/aggregator.js +98 -0
- package/typed/data-filter/data-filter.js +159 -0
- 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.d.ts +14 -5
- package/typed/fill-style/fill-style.d.ts.map +1 -1
- package/typed/fill-style/fill-style.js +152 -0
- package/typed/fill-style/shaders.glsl.d.ts.map +1 -1
- package/typed/fill-style/shaders.glsl.js +95 -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 +4 -0
- package/typed/index.d.ts.map +1 -1
- package/typed/index.js +9 -0
- package/typed/mask/mask-effect.d.ts +42 -0
- package/typed/mask/mask-effect.d.ts.map +1 -0
- package/typed/mask/mask-pass.d.ts +19 -0
- package/typed/mask/mask-pass.d.ts.map +1 -0
- package/typed/mask/mask.d.ts +9 -3
- package/typed/mask/mask.d.ts.map +1 -1
- package/typed/mask/mask.js +48 -0
- package/typed/mask/shader-module.d.ts.map +1 -1
- package/typed/mask/shader-module.js +73 -0
- package/typed/mask/utils.d.ts +13 -0
- package/typed/mask/utils.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-builder.d.ts +38 -0
- package/typed/terrain/height-map-builder.d.ts.map +1 -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/shader-module.d.ts +31 -0
- package/typed/terrain/shader-module.d.ts.map +1 -0
- package/typed/terrain/terrain-cover.d.ts +46 -0
- package/typed/terrain/terrain-cover.d.ts.map +1 -0
- package/typed/terrain/terrain-effect.d.ts +29 -0
- package/typed/terrain/terrain-effect.d.ts.map +1 -0
- package/typed/terrain/terrain-pass.d.ts +11 -0
- package/typed/terrain/terrain-pass.d.ts.map +1 -0
- package/typed/terrain/terrain-picking-pass.d.ts +19 -0
- package/typed/terrain/terrain-picking-pass.d.ts.map +1 -0
- package/typed/terrain/terrain.d.ts +21 -0
- package/typed/terrain/terrain.d.ts.map +1 -0
- package/typed/terrain/utils.d.ts +5 -0
- package/typed/terrain/utils.d.ts.map +1 -0
- package/typed/utils/debug.d.ts +6 -0
- package/typed/utils/debug.d.ts.map +1 -0
|
@@ -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,34 @@
|
|
|
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, COORDINATE_SYSTEM } from '@deck.gl/core';
|
|
21
|
+
import project64 from './project64';
|
|
22
|
+
export default class Fp64Extension extends LayerExtension {
|
|
23
|
+
getShaders(opts) {
|
|
24
|
+
const { coordinateSystem } = this.props;
|
|
25
|
+
if (coordinateSystem !== COORDINATE_SYSTEM.LNGLAT &&
|
|
26
|
+
coordinateSystem !== COORDINATE_SYSTEM.DEFAULT) {
|
|
27
|
+
throw new Error('fp64: coordinateSystem must be LNGLAT');
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
modules: [project64]
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
Fp64Extension.extensionName = 'Fp64Extension';
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
export default `\
|
|
21
|
+
|
|
22
|
+
const vec2 WORLD_SCALE_FP64 = vec2(81.4873275756836, 0.0000032873668232014097);
|
|
23
|
+
|
|
24
|
+
uniform vec2 project_uViewProjectionMatrixFP64[16];
|
|
25
|
+
|
|
26
|
+
// longitude: lnglat_fp64.xy; latitude: lnglat_fp64.zw
|
|
27
|
+
void mercatorProject_fp64(vec4 lnglat_fp64, out vec2 out_val[2]) {
|
|
28
|
+
|
|
29
|
+
#if defined(NVIDIA_FP64_WORKAROUND)
|
|
30
|
+
out_val[0] = sum_fp64(radians_fp64(lnglat_fp64.xy), PI_FP64 * ONE);
|
|
31
|
+
#else
|
|
32
|
+
out_val[0] = sum_fp64(radians_fp64(lnglat_fp64.xy), PI_FP64);
|
|
33
|
+
#endif
|
|
34
|
+
out_val[1] = sum_fp64(PI_FP64,
|
|
35
|
+
log_fp64(tan_fp64(sum_fp64(PI_4_FP64, radians_fp64(lnglat_fp64.zw) / 2.0))));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
void project_position_fp64(vec4 position_fp64, out vec2 out_val[2]) {
|
|
40
|
+
vec2 pos_fp64[2];
|
|
41
|
+
mercatorProject_fp64(position_fp64, pos_fp64);
|
|
42
|
+
out_val[0] = mul_fp64(pos_fp64[0], WORLD_SCALE_FP64);
|
|
43
|
+
out_val[1] = mul_fp64(pos_fp64[1], WORLD_SCALE_FP64);
|
|
44
|
+
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
void project_position_fp64(vec2 position, vec2 position64xyLow, out vec2 out_val[2]) {
|
|
49
|
+
vec4 position64xy = vec4(
|
|
50
|
+
position.x, position64xyLow.x,
|
|
51
|
+
position.y, position64xyLow.y);
|
|
52
|
+
|
|
53
|
+
project_position_fp64(position64xy, out_val);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
vec4 project_common_position_to_clipspace_fp64(vec2 vertex_pos_modelspace[4]) {
|
|
57
|
+
vec2 vertex_pos_clipspace[4];
|
|
58
|
+
mat4_vec4_mul_fp64(project_uViewProjectionMatrixFP64, vertex_pos_modelspace,
|
|
59
|
+
vertex_pos_clipspace);
|
|
60
|
+
return vec4(
|
|
61
|
+
vertex_pos_clipspace[0].x,
|
|
62
|
+
vertex_pos_clipspace[1].x,
|
|
63
|
+
vertex_pos_clipspace[2].x,
|
|
64
|
+
vertex_pos_clipspace[3].x
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
vec4 project_position_to_clipspace(
|
|
69
|
+
vec3 position, vec3 position64xyLow, vec3 offset, out vec4 commonPosition
|
|
70
|
+
) {
|
|
71
|
+
// This is the local offset to the instance position
|
|
72
|
+
vec2 offset64[4];
|
|
73
|
+
vec4_fp64(vec4(offset, 0.0), offset64);
|
|
74
|
+
|
|
75
|
+
float z = project_size(position.z);
|
|
76
|
+
|
|
77
|
+
// Apply web mercator projection (depends on coordinate system imn use)
|
|
78
|
+
vec2 projectedPosition64xy[2];
|
|
79
|
+
project_position_fp64(position.xy, position64xyLow.xy, projectedPosition64xy);
|
|
80
|
+
|
|
81
|
+
vec2 commonPosition64[4];
|
|
82
|
+
commonPosition64[0] = sum_fp64(offset64[0], projectedPosition64xy[0]);
|
|
83
|
+
commonPosition64[1] = sum_fp64(offset64[1], projectedPosition64xy[1]);
|
|
84
|
+
commonPosition64[2] = sum_fp64(offset64[2], vec2(z, 0.0));
|
|
85
|
+
commonPosition64[3] = vec2(1.0, 0.0);
|
|
86
|
+
|
|
87
|
+
commonPosition = vec4(projectedPosition64xy[0].x, projectedPosition64xy[1].x, z, 1.0);
|
|
88
|
+
|
|
89
|
+
return project_common_position_to_clipspace_fp64(commonPosition64);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
vec4 project_position_to_clipspace(
|
|
93
|
+
vec3 position, vec3 position64xyLow, vec3 offset
|
|
94
|
+
) {
|
|
95
|
+
vec4 commonPosition;
|
|
96
|
+
return project_position_to_clipspace(
|
|
97
|
+
position, position64xyLow, offset, commonPosition
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
`;
|
|
@@ -0,0 +1,50 @@
|
|
|
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 { fp64 } from '@luma.gl/shadertools';
|
|
21
|
+
const { fp64ify, fp64ifyMatrix4 } = fp64;
|
|
22
|
+
import { project, _memoize as memoize } from '@deck.gl/core';
|
|
23
|
+
import project64Shader from './project64.glsl';
|
|
24
|
+
export default {
|
|
25
|
+
name: 'project64',
|
|
26
|
+
dependencies: [project, fp64],
|
|
27
|
+
vs: project64Shader,
|
|
28
|
+
getUniforms
|
|
29
|
+
};
|
|
30
|
+
// TODO - this module should calculate the 64 bit uniforms
|
|
31
|
+
// It is currently done by project to minimize duplicated work
|
|
32
|
+
const DEFAULT_MODULE_OPTIONS = {};
|
|
33
|
+
const getMemoizedUniforms = memoize(calculateUniforms);
|
|
34
|
+
function getUniforms(opts = DEFAULT_MODULE_OPTIONS) {
|
|
35
|
+
if (opts.viewport) {
|
|
36
|
+
const { viewProjectionMatrix, scale } = opts.viewport;
|
|
37
|
+
// We only need to update fp64 uniforms if fp32 projection is being updated
|
|
38
|
+
return getMemoizedUniforms({ viewProjectionMatrix, scale });
|
|
39
|
+
}
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
function calculateUniforms({ viewProjectionMatrix, scale }) {
|
|
43
|
+
const glViewProjectionMatrixFP64 = fp64ifyMatrix4(viewProjectionMatrix);
|
|
44
|
+
const scaleFP64 = fp64ify(scale);
|
|
45
|
+
return {
|
|
46
|
+
project_uViewProjectionMatrixFP64: glViewProjectionMatrixFP64,
|
|
47
|
+
project64_uViewProjectionMatrix: glViewProjectionMatrixFP64,
|
|
48
|
+
project64_uScale: scaleFP64
|
|
49
|
+
};
|
|
50
|
+
}
|
package/typed/index.d.ts
CHANGED
|
@@ -4,12 +4,16 @@ export { default as Fp64Extension } from './fp64/fp64';
|
|
|
4
4
|
export { default as PathStyleExtension } from './path-style/path-style';
|
|
5
5
|
export { default as FillStyleExtension } from './fill-style/fill-style';
|
|
6
6
|
export { default as ClipExtension } from './clip/clip';
|
|
7
|
+
export { default as CollideExtension } from './collide/collide';
|
|
7
8
|
export { default as MaskExtension } from './mask/mask';
|
|
9
|
+
export { default as TerrainExtension } from './terrain/terrain';
|
|
8
10
|
export { default as project64 } from './fp64/project64';
|
|
9
11
|
export type { BrushingExtensionProps } from './brushing/brushing';
|
|
10
12
|
export type { DataFilterExtensionProps } from './data-filter/data-filter';
|
|
11
13
|
export type { PathStyleExtensionProps } from './path-style/path-style';
|
|
12
14
|
export type { FillStyleExtensionProps } from './fill-style/fill-style';
|
|
13
15
|
export type { ClipExtensionProps } from './clip/clip';
|
|
16
|
+
export type { CollideExtensionProps } from './collide/collide';
|
|
14
17
|
export type { MaskExtensionProps } from './mask/mask';
|
|
18
|
+
export type { TerrainExtensionProps } from './terrain/terrain';
|
|
15
19
|
//# sourceMappingURL=index.d.ts.map
|
package/typed/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAC,OAAO,IAAI,mBAAmB,EAAC,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,aAAa,CAAC;AACrD,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,aAAa,CAAC;AACrD,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAC,OAAO,IAAI,mBAAmB,EAAC,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,aAAa,CAAC;AACrD,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,aAAa,CAAC;AACrD,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,aAAa,CAAC;AACrD,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAG9D,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAGtD,YAAY,EAAC,sBAAsB,EAAC,MAAM,qBAAqB,CAAC;AAChE,YAAY,EAAC,wBAAwB,EAAC,MAAM,2BAA2B,CAAC;AACxE,YAAY,EAAC,uBAAuB,EAAC,MAAM,yBAAyB,CAAC;AACrE,YAAY,EAAC,uBAAuB,EAAC,MAAM,yBAAyB,CAAC;AACrE,YAAY,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AACpD,YAAY,EAAC,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AAC7D,YAAY,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AACpD,YAAY,EAAC,qBAAqB,EAAC,MAAM,mBAAmB,CAAC"}
|
package/typed/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as BrushingExtension } from './brushing/brushing';
|
|
2
|
+
export { default as DataFilterExtension } from './data-filter/data-filter';
|
|
3
|
+
export { default as Fp64Extension } from './fp64/fp64';
|
|
4
|
+
export { default as PathStyleExtension } from './path-style/path-style';
|
|
5
|
+
export { default as FillStyleExtension } from './fill-style/fill-style';
|
|
6
|
+
export { default as ClipExtension } from './clip/clip';
|
|
7
|
+
export { default as MaskExtension } from './mask/mask';
|
|
8
|
+
// Shader module
|
|
9
|
+
export { default as project64 } from './fp64/project64';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Effect, PreRenderOptions, CoordinateSystem } from '@deck.gl/core/typed';
|
|
2
|
+
import { Texture2D } from '@luma.gl/core';
|
|
3
|
+
import { MaskBounds } from './utils';
|
|
4
|
+
declare type Mask = {
|
|
5
|
+
/** The channel index */
|
|
6
|
+
index: number;
|
|
7
|
+
bounds: MaskBounds;
|
|
8
|
+
coordinateOrigin: [number, number, number];
|
|
9
|
+
coordinateSystem: CoordinateSystem;
|
|
10
|
+
};
|
|
11
|
+
export declare type MaskPreRenderStats = {
|
|
12
|
+
didRender: boolean;
|
|
13
|
+
};
|
|
14
|
+
export default class MaskEffect implements Effect {
|
|
15
|
+
id: string;
|
|
16
|
+
props: null;
|
|
17
|
+
useInPicking: boolean;
|
|
18
|
+
order: number;
|
|
19
|
+
private dummyMaskMap?;
|
|
20
|
+
private channels;
|
|
21
|
+
private masks;
|
|
22
|
+
private maskPass?;
|
|
23
|
+
private maskMap?;
|
|
24
|
+
private lastViewport?;
|
|
25
|
+
preRender(gl: WebGLRenderingContext, { layers, layerFilter, viewports, onViewportActive, views, pass }: PreRenderOptions): MaskPreRenderStats;
|
|
26
|
+
private _renderChannel;
|
|
27
|
+
/**
|
|
28
|
+
* Find a channel to render each mask into
|
|
29
|
+
* If a maskId already exists, diff and update the existing channel
|
|
30
|
+
* Otherwise replace a removed mask
|
|
31
|
+
* Otherwise create a new channel
|
|
32
|
+
* Returns a map from mask layer id to channel info
|
|
33
|
+
*/
|
|
34
|
+
private _sortMaskChannels;
|
|
35
|
+
getModuleParameters(): {
|
|
36
|
+
maskMap: Texture2D;
|
|
37
|
+
maskChannels: Record<string, Mask> | null;
|
|
38
|
+
};
|
|
39
|
+
cleanup(): void;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=mask-effect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mask-effect.d.ts","sourceRoot":"","sources":["../../src/mask/mask-effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAM,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAGxC,OAAO,EAAiC,UAAU,EAAC,MAAM,SAAS,CAAC;AAGnE,aAAK,IAAI,GAAG;IACV,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,UAAU,CAAC;IACnB,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,gBAAgB,EAAE,gBAAgB,CAAC;CACpC,CAAC;AAaF,oBAAY,kBAAkB,GAAG;IAC/B,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAGF,MAAM,CAAC,OAAO,OAAO,UAAW,YAAW,MAAM;IAC/C,EAAE,SAAiB;IACnB,KAAK,OAAQ;IACb,YAAY,UAAQ;IACpB,KAAK,SAAK;IAEV,OAAO,CAAC,YAAY,CAAC,CAAY;IACjC,OAAO,CAAC,QAAQ,CAA0B;IAC1C,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,QAAQ,CAAC,CAAW;IAC5B,OAAO,CAAC,OAAO,CAAC,CAAY;IAC5B,OAAO,CAAC,YAAY,CAAC,CAAW;IAEhC,SAAS,CACP,EAAE,EAAE,qBAAqB,EACzB,EAAC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,gBAAgB,EAAE,KAAK,EAAE,IAAI,EAAC,EAAE,gBAAgB,GAChF,kBAAkB;IAgDrB,OAAO,CAAC,cAAc;IAkFtB;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IA4CzB,mBAAmB,IAAI;QACrB,OAAO,EAAE,SAAS,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC;KAC3C;IAOD,OAAO,IAAI,IAAI;CAgBhB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Framebuffer, Texture2D } from '@luma.gl/core';
|
|
2
|
+
import { _LayersPass as LayersPass, LayersPassRenderOptions } from '@deck.gl/core/typed';
|
|
3
|
+
declare type MaskPassRenderOptions = LayersPassRenderOptions & {
|
|
4
|
+
/** The channel to render into, 0:red, 1:green, 2:blue, 3:alpha */
|
|
5
|
+
channel: number;
|
|
6
|
+
};
|
|
7
|
+
export default class MaskPass extends LayersPass {
|
|
8
|
+
maskMap: Texture2D;
|
|
9
|
+
fbo: Framebuffer;
|
|
10
|
+
constructor(gl: any, props: {
|
|
11
|
+
id: string;
|
|
12
|
+
mapSize?: number;
|
|
13
|
+
});
|
|
14
|
+
render(options: MaskPassRenderOptions): any;
|
|
15
|
+
shouldDrawLayer(layer: any): any;
|
|
16
|
+
delete(): void;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=mask-pass.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mask-pass.d.ts","sourceRoot":"","sources":["../../src/mask/mask-pass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,SAAS,EAAiB,MAAM,eAAe,CAAC;AACrE,OAAO,EAAC,WAAW,IAAI,UAAU,EAAE,uBAAuB,EAAC,MAAM,eAAe,CAAC;AAEjF,aAAK,qBAAqB,GAAG,uBAAuB,GAAG;IACrD,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,UAAU;IAC9C,OAAO,EAAE,SAAS,CAAC;IACnB,GAAG,EAAE,WAAW,CAAC;gBAEL,EAAE,KAAA,EAAE,KAAK,EAAE;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAC;IA0BrD,MAAM,CAAC,OAAO,EAAE,qBAAqB;IAoBrC,eAAe,CAAC,KAAK,KAAA;IAIrB,MAAM;CAIP"}
|
package/typed/mask/mask.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { LayerExtension } from '@deck.gl/core/typed';
|
|
2
|
-
import type { Layer } from '@deck.gl/core/typed';
|
|
1
|
+
import { Layer, LayerExtension } from '@deck.gl/core/typed';
|
|
3
2
|
export declare type MaskExtensionProps = {
|
|
4
3
|
/**
|
|
5
4
|
* Id of the layer that defines the mask. The mask layer must use the prop `operation: 'mask'`.
|
|
@@ -11,14 +10,21 @@ export declare type MaskExtensionProps = {
|
|
|
11
10
|
* If not specified, it is automatically deduced from the layer.
|
|
12
11
|
*/
|
|
13
12
|
maskByInstance?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Inverts the masking operation
|
|
15
|
+
*/
|
|
16
|
+
maskInverted?: boolean;
|
|
14
17
|
};
|
|
15
18
|
/** Allows layers to show/hide objects by a geofence. */
|
|
16
19
|
export default class MaskExtension extends LayerExtension {
|
|
17
20
|
static defaultProps: {
|
|
18
21
|
maskId: string;
|
|
22
|
+
maskByInstance: undefined;
|
|
23
|
+
maskInverted: boolean;
|
|
19
24
|
};
|
|
20
25
|
static extensionName: string;
|
|
26
|
+
initializeState(this: Layer<MaskExtensionProps>): void;
|
|
21
27
|
getShaders(this: Layer<MaskExtensionProps>): any;
|
|
22
|
-
draw(this: Layer<MaskExtensionProps
|
|
28
|
+
draw(this: Layer<Required<MaskExtensionProps>>, { uniforms, context, moduleParameters }: any): void;
|
|
23
29
|
}
|
|
24
30
|
//# sourceMappingURL=mask.d.ts.map
|
package/typed/mask/mask.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mask.d.ts","sourceRoot":"","sources":["../../src/mask/mask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,
|
|
1
|
+
{"version":3,"file":"mask.d.ts","sourceRoot":"","sources":["../../src/mask/mask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,EAAE,cAAc,EAAM,MAAM,eAAe,CAAC;AAU5E,oBAAY,kBAAkB,GAAG;IAC/B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,wDAAwD;AACxD,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,cAAc;IACvD,MAAM,CAAC,YAAY;;;;MAAgB;IACnC,MAAM,CAAC,aAAa,SAAmB;IAEvC,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,kBAAkB,CAAC;IAI/C,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,kBAAkB,CAAC,GAAG,GAAG;IAehD,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAC,EAAE,GAAG;CA4B3F"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { COORDINATE_SYSTEM, LayerExtension, log } from '@deck.gl/core';
|
|
2
|
+
import mask from './shader-module';
|
|
3
|
+
const defaultProps = {
|
|
4
|
+
maskId: ''
|
|
5
|
+
};
|
|
6
|
+
export default class MaskExtension extends LayerExtension {
|
|
7
|
+
getShaders() {
|
|
8
|
+
// Infer by geometry if 'maskByInstance' prop isn't explictly set
|
|
9
|
+
let maskByInstance = 'instancePositions' in this.getAttributeManager().attributes;
|
|
10
|
+
// Users can override by setting the `maskByInstance` prop
|
|
11
|
+
if ('maskByInstance' in this.props) {
|
|
12
|
+
maskByInstance = this.props.maskByInstance;
|
|
13
|
+
}
|
|
14
|
+
this.state.maskByInstance = maskByInstance;
|
|
15
|
+
return {
|
|
16
|
+
modules: [mask]
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
draw({ uniforms, context, moduleParameters }) {
|
|
20
|
+
uniforms.mask_maskByInstance = this.state.maskByInstance;
|
|
21
|
+
const { maskId } = this.props;
|
|
22
|
+
const { maskChannels } = moduleParameters;
|
|
23
|
+
const { viewport } = context;
|
|
24
|
+
if (maskChannels && maskChannels[maskId]) {
|
|
25
|
+
const { index, bounds, coordinateOrigin: fromCoordinateOrigin } = maskChannels[maskId];
|
|
26
|
+
let { coordinateSystem: fromCoordinateSystem } = maskChannels[maskId];
|
|
27
|
+
uniforms.mask_enabled = true;
|
|
28
|
+
uniforms.mask_channel = index;
|
|
29
|
+
if (fromCoordinateSystem === COORDINATE_SYSTEM.DEFAULT) {
|
|
30
|
+
fromCoordinateSystem = viewport.isGeospatial
|
|
31
|
+
? COORDINATE_SYSTEM.LNGLAT
|
|
32
|
+
: COORDINATE_SYSTEM.CARTESIAN;
|
|
33
|
+
}
|
|
34
|
+
const opts = { modelMatrix: null, fromCoordinateOrigin, fromCoordinateSystem };
|
|
35
|
+
const bl = this.projectPosition([bounds[0], bounds[1], 0], opts);
|
|
36
|
+
const tr = this.projectPosition([bounds[2], bounds[3], 0], opts);
|
|
37
|
+
uniforms.mask_bounds = [bl[0], bl[1], tr[0], tr[1]];
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
if (maskId) {
|
|
41
|
+
log.warn(`Could not find a mask layer with id: ${maskId}`)();
|
|
42
|
+
}
|
|
43
|
+
uniforms.mask_enabled = false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
MaskExtension.extensionName = 'MaskExtension';
|
|
48
|
+
MaskExtension.defaultProps = defaultProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/mask/shader-module.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,aAAa,IAAI,YAAY,EAAC,MAAM,eAAe,CAAC;AACjE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/mask/shader-module.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,aAAa,IAAI,YAAY,EAAC,MAAM,eAAe,CAAC;AACjE,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAoE9C,aAAK,kBAAkB,GAAG;IACxB,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB,CAAC;;AAYF,wBAOsC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { project } from '@deck.gl/core';
|
|
2
|
+
const vs = `
|
|
3
|
+
uniform vec4 mask_bounds;
|
|
4
|
+
uniform bool mask_maskByInstance;
|
|
5
|
+
vec2 mask_getCoords(vec4 position) {
|
|
6
|
+
return (position.xy - mask_bounds.xy) / (mask_bounds.zw - mask_bounds.xy);
|
|
7
|
+
}
|
|
8
|
+
`;
|
|
9
|
+
const fs = `
|
|
10
|
+
uniform sampler2D mask_texture;
|
|
11
|
+
uniform int mask_channel;
|
|
12
|
+
uniform bool mask_enabled;
|
|
13
|
+
bool mask_isInBounds(vec2 texCoords) {
|
|
14
|
+
if (!mask_enabled) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
vec4 maskColor = texture2D(mask_texture, texCoords);
|
|
18
|
+
float maskValue = 1.0;
|
|
19
|
+
if (mask_channel == 0) {
|
|
20
|
+
maskValue = maskColor.r;
|
|
21
|
+
} else if (mask_channel == 1) {
|
|
22
|
+
maskValue = maskColor.g;
|
|
23
|
+
} else if (mask_channel == 2) {
|
|
24
|
+
maskValue = maskColor.b;
|
|
25
|
+
} else if (mask_channel == 3) {
|
|
26
|
+
maskValue = maskColor.a;
|
|
27
|
+
}
|
|
28
|
+
return maskValue < 0.5;
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
const inject = {
|
|
32
|
+
'vs:#decl': `
|
|
33
|
+
varying vec2 mask_texCoords;
|
|
34
|
+
`,
|
|
35
|
+
'vs:#main-end': `
|
|
36
|
+
vec4 mask_common_position;
|
|
37
|
+
if (mask_maskByInstance) {
|
|
38
|
+
mask_common_position = project_position(vec4(geometry.worldPosition, 1.0));
|
|
39
|
+
} else {
|
|
40
|
+
mask_common_position = geometry.position;
|
|
41
|
+
}
|
|
42
|
+
mask_texCoords = mask_getCoords(mask_common_position);
|
|
43
|
+
`,
|
|
44
|
+
'fs:#decl': `
|
|
45
|
+
varying vec2 mask_texCoords;
|
|
46
|
+
`,
|
|
47
|
+
'fs:#main-start': `
|
|
48
|
+
if (mask_enabled) {
|
|
49
|
+
bool mask = mask_isInBounds(mask_texCoords);
|
|
50
|
+
|
|
51
|
+
// Debug: show extent of render target
|
|
52
|
+
// gl_FragColor = vec4(mask_texCoords, 0.0, 1.0);
|
|
53
|
+
gl_FragColor = texture2D(mask_texture, mask_texCoords);
|
|
54
|
+
|
|
55
|
+
if (!mask) discard;
|
|
56
|
+
}
|
|
57
|
+
`
|
|
58
|
+
};
|
|
59
|
+
const getMaskUniforms = (opts = {}) => {
|
|
60
|
+
const uniforms = {};
|
|
61
|
+
if (opts.maskMap) {
|
|
62
|
+
uniforms.mask_texture = opts.maskMap;
|
|
63
|
+
}
|
|
64
|
+
return uniforms;
|
|
65
|
+
};
|
|
66
|
+
export default {
|
|
67
|
+
name: 'mask',
|
|
68
|
+
dependencies: [project],
|
|
69
|
+
vs,
|
|
70
|
+
fs,
|
|
71
|
+
inject,
|
|
72
|
+
getUniforms: getMaskUniforms
|
|
73
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Layer, Viewport } from '@deck.gl/core/typed';
|
|
2
|
+
export declare type MaskBounds = [number, number, number, number];
|
|
3
|
+
export declare function getMaskBounds({ layers, viewport }: {
|
|
4
|
+
layers: Layer[];
|
|
5
|
+
viewport: Viewport;
|
|
6
|
+
}): MaskBounds;
|
|
7
|
+
export declare function getMaskViewport({ bounds, viewport, width, height }: {
|
|
8
|
+
bounds: MaskBounds;
|
|
9
|
+
viewport: Viewport;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}): Viewport | null;
|
|
13
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/mask/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6C,KAAK,EAAE,QAAQ,EAAC,MAAM,eAAe,CAAC;AAG1F,oBAAY,UAAU,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAO1D,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,QAAQ,EACT,EAAE;IACD,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC;CACpB,GAAG,UAAU,CAkDb;AAKD,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,QAAQ,EACR,KAAK,EACL,MAAM,EACP,EAAE;IACD,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,QAAQ,GAAG,IAAI,CAsDlB"}
|