@deck.gl/extensions 9.0.35 → 9.1.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/brushing/brushing-extension.d.ts +1 -0
- package/dist/brushing/brushing-extension.d.ts.map +1 -1
- package/dist/brushing/brushing-extension.js +15 -19
- 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 +74 -50
- 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 +36 -42
- 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 +27 -13
- 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 +5 -6
- package/dist/collision-filter/collision-filter-pass.d.ts +7 -3
- package/dist/collision-filter/collision-filter-pass.d.ts.map +1 -1
- package/dist/collision-filter/collision-filter-pass.js +8 -3
- 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 +74 -52
- 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 +14 -8
- package/dist/data-filter/data-filter-extension.d.ts.map +1 -1
- package/dist/data-filter/data-filter-extension.js +40 -38
- package/dist/data-filter/shader-module.d.ts +11 -4
- package/dist/data-filter/shader-module.d.ts.map +1 -1
- package/dist/data-filter/shader-module.js +189 -131
- package/dist/dist.dev.js +2699 -2028
- package/dist/fill-style/fill-style-extension.d.ts.map +1 -1
- package/dist/fill-style/fill-style-extension.js +11 -4
- 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 +73 -51
- 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 +7 -19
- 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 +18 -21
- package/dist/fp64/project64.js +24 -24
- package/dist/index.cjs +1017 -523
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -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 +12 -5
- 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 +13 -8
- package/dist/mask/mask-pass.d.ts +38 -38
- package/dist/mask/mask-pass.d.ts.map +1 -1
- package/dist/mask/mask-pass.js +3 -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 +73 -46
- package/dist/path-style/path-style-extension.d.ts.map +1 -1
- package/dist/path-style/path-style-extension.js +20 -24
- package/dist/path-style/shaders.glsl.d.ts.map +1 -1
- package/dist/path-style/shaders.glsl.js +11 -7
- package/dist/terrain/height-map-builder.d.ts.map +1 -1
- package/dist/terrain/height-map-builder.js +3 -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 +69 -61
- package/dist/terrain/terrain-cover.d.ts.map +1 -1
- package/dist/terrain/terrain-cover.js +3 -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 +31 -18
- package/dist/terrain/terrain-extension.d.ts.map +1 -1
- package/dist/terrain/terrain-extension.js +3 -0
- package/dist/terrain/terrain-pass.d.ts +43 -38
- package/dist/terrain/terrain-pass.d.ts.map +1 -1
- package/dist/terrain/terrain-pass.js +10 -0
- package/dist/terrain/terrain-picking-pass.d.ts +5 -0
- package/dist/terrain/terrain-picking-pass.d.ts.map +1 -1
- package/dist/terrain/terrain-picking-pass.js +10 -0
- package/dist/terrain/utils.d.ts.map +1 -1
- package/dist/terrain/utils.js +3 -0
- package/dist/utils/debug.d.ts +2 -2
- package/dist/utils/debug.d.ts.map +1 -1
- package/dist/utils/debug.js +3 -1
- package/dist/utils/projection-utils.d.ts.map +1 -1
- package/dist/utils/projection-utils.js +3 -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 +9 -3
- 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 +68 -48
- package/src/data-filter/shader-module.ts +144 -84
- 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 +4 -0
- 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 +12 -0
- package/src/terrain/terrain-picking-pass.ts +12 -0
- 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,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';
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
/* eslint-disable camelcase */
|
|
2
6
|
|
|
3
7
|
import type {ShaderModule} from '@luma.gl/shadertools';
|
|
4
|
-
import {project} from '@deck.gl/core';
|
|
8
|
+
import {project, ProjectProps, ProjectUniforms, Viewport} from '@deck.gl/core';
|
|
5
9
|
|
|
6
10
|
import type {Texture} from '@luma.gl/core';
|
|
7
11
|
import type {Bounds} from '../utils/projection-utils';
|
|
8
12
|
import type {TerrainCover} from './terrain-cover';
|
|
9
|
-
import {glsl} from '../utils/syntax-tags';
|
|
10
13
|
|
|
11
14
|
/** Module parameters expected by the terrain shader module */
|
|
12
|
-
export type
|
|
13
|
-
|
|
15
|
+
export type TerrainModuleProps = {
|
|
16
|
+
project: ProjectProps;
|
|
17
|
+
isPicking: boolean;
|
|
14
18
|
heightMap: Texture | null;
|
|
15
19
|
heightMapBounds?: Bounds | null;
|
|
16
20
|
dummyHeightMap: Texture;
|
|
@@ -20,6 +24,15 @@ export type TerrainModuleSettings = {
|
|
|
20
24
|
terrainSkipRender?: boolean;
|
|
21
25
|
};
|
|
22
26
|
|
|
27
|
+
type TerrainModuleUniforms = {
|
|
28
|
+
mode: number;
|
|
29
|
+
bounds: [number, number, number, number];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
type TerrainModuleBindings = {
|
|
33
|
+
terrain_map: Texture;
|
|
34
|
+
};
|
|
35
|
+
|
|
23
36
|
/** A model can have one of the following modes */
|
|
24
37
|
export const TERRAIN_MODE = {
|
|
25
38
|
NONE: 0,
|
|
@@ -39,35 +52,44 @@ const TERRAIN_MODE_CONSTANTS = Object.keys(TERRAIN_MODE)
|
|
|
39
52
|
.map(key => `const float TERRAIN_MODE_${key} = ${TERRAIN_MODE[key]}.0;`)
|
|
40
53
|
.join('\n');
|
|
41
54
|
|
|
55
|
+
const uniformBlock =
|
|
56
|
+
// eslint-disable-next-line prefer-template
|
|
57
|
+
TERRAIN_MODE_CONSTANTS +
|
|
58
|
+
/* glsl */ `
|
|
59
|
+
uniform terrainUniforms {
|
|
60
|
+
float mode;
|
|
61
|
+
vec4 bounds;
|
|
62
|
+
} terrain;
|
|
63
|
+
|
|
64
|
+
uniform sampler2D terrain_map;
|
|
65
|
+
`;
|
|
66
|
+
|
|
42
67
|
export const terrainModule = {
|
|
43
68
|
name: 'terrain',
|
|
44
69
|
dependencies: [project],
|
|
70
|
+
// eslint-disable-next-line prefer-template
|
|
71
|
+
vs: uniformBlock + /* glsl */ 'out vec3 commonPos;',
|
|
72
|
+
// eslint-disable-next-line prefer-template
|
|
73
|
+
fs: uniformBlock + /* glsl */ 'in vec3 commonPos;',
|
|
45
74
|
inject: {
|
|
46
|
-
'vs:#
|
|
47
|
-
|
|
48
|
-
uniform float terrain_mode;
|
|
49
|
-
uniform sampler2D terrain_map;
|
|
50
|
-
uniform vec4 terrain_bounds;
|
|
51
|
-
out vec3 commonPos;
|
|
52
|
-
` + TERRAIN_MODE_CONSTANTS,
|
|
53
|
-
'vs:#main-start': glsl`
|
|
54
|
-
if (terrain_mode == TERRAIN_MODE_SKIP) {
|
|
75
|
+
'vs:#main-start': /* glsl */ `
|
|
76
|
+
if (terrain.mode == TERRAIN_MODE_SKIP) {
|
|
55
77
|
gl_Position = vec4(0.0);
|
|
56
78
|
return;
|
|
57
79
|
}
|
|
58
80
|
`,
|
|
59
|
-
'vs:DECKGL_FILTER_GL_POSITION': glsl`
|
|
81
|
+
'vs:DECKGL_FILTER_GL_POSITION': /* glsl */ `
|
|
60
82
|
commonPos = geometry.position.xyz;
|
|
61
|
-
if (
|
|
62
|
-
vec2 texCoords = (commonPos.xy -
|
|
83
|
+
if (terrain.mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {
|
|
84
|
+
vec2 texCoords = (commonPos.xy - terrain.bounds.xy) / terrain.bounds.zw;
|
|
63
85
|
position = vec4(texCoords * 2.0 - 1.0, 0.0, 1.0);
|
|
64
|
-
commonPos.z +=
|
|
86
|
+
commonPos.z += project.commonOrigin.z;
|
|
65
87
|
}
|
|
66
|
-
if (
|
|
88
|
+
if (terrain.mode == TERRAIN_MODE_USE_HEIGHT_MAP) {
|
|
67
89
|
vec3 anchor = geometry.worldPosition;
|
|
68
90
|
anchor.z = 0.0;
|
|
69
91
|
vec3 anchorCommon = project_position(anchor);
|
|
70
|
-
vec2 texCoords = (anchorCommon.xy -
|
|
92
|
+
vec2 texCoords = (anchorCommon.xy - terrain.bounds.xy) / terrain.bounds.zw;
|
|
71
93
|
if (texCoords.x >= 0.0 && texCoords.y >= 0.0 && texCoords.x <= 1.0 && texCoords.y <= 1.0) {
|
|
72
94
|
float terrainZ = texture(terrain_map, texCoords).r;
|
|
73
95
|
geometry.position.z += terrainZ;
|
|
@@ -75,24 +97,17 @@ if (terrain_mode == TERRAIN_MODE_USE_HEIGHT_MAP) {
|
|
|
75
97
|
}
|
|
76
98
|
}
|
|
77
99
|
`,
|
|
78
|
-
'fs:#
|
|
79
|
-
|
|
80
|
-
uniform float terrain_mode;
|
|
81
|
-
uniform sampler2D terrain_map;
|
|
82
|
-
uniform vec4 terrain_bounds;
|
|
83
|
-
in vec3 commonPos;
|
|
84
|
-
` + TERRAIN_MODE_CONSTANTS,
|
|
85
|
-
'fs:#main-start': glsl`
|
|
86
|
-
if (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {
|
|
100
|
+
'fs:#main-start': /* glsl */ `
|
|
101
|
+
if (terrain.mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {
|
|
87
102
|
fragColor = vec4(commonPos.z, 0.0, 0.0, 1.0);
|
|
88
103
|
return;
|
|
89
104
|
}
|
|
90
105
|
`,
|
|
91
|
-
'fs:DECKGL_FILTER_COLOR': glsl`
|
|
92
|
-
if ((
|
|
93
|
-
vec2 texCoords = (commonPos.xy -
|
|
106
|
+
'fs:DECKGL_FILTER_COLOR': /* glsl */ `
|
|
107
|
+
if ((terrain.mode == TERRAIN_MODE_USE_COVER) || (terrain.mode == TERRAIN_MODE_USE_COVER_ONLY)) {
|
|
108
|
+
vec2 texCoords = (commonPos.xy - terrain.bounds.xy) / terrain.bounds.zw;
|
|
94
109
|
vec4 pixel = texture(terrain_map, texCoords);
|
|
95
|
-
if (
|
|
110
|
+
if (terrain.mode == TERRAIN_MODE_USE_COVER_ONLY) {
|
|
96
111
|
color = pixel;
|
|
97
112
|
} else {
|
|
98
113
|
// pixel is premultiplied
|
|
@@ -103,7 +118,7 @@ if ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_US
|
|
|
103
118
|
`
|
|
104
119
|
},
|
|
105
120
|
// eslint-disable-next-line complexity
|
|
106
|
-
getUniforms: (opts: Partial<
|
|
121
|
+
getUniforms: (opts: Partial<TerrainModuleProps> = {}) => {
|
|
107
122
|
if ('dummyHeightMap' in opts) {
|
|
108
123
|
const {
|
|
109
124
|
drawToTerrainHeightMap,
|
|
@@ -114,8 +129,8 @@ if ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_US
|
|
|
114
129
|
useTerrainHeightMap,
|
|
115
130
|
terrainSkipRender
|
|
116
131
|
} = opts;
|
|
117
|
-
|
|
118
|
-
const {
|
|
132
|
+
const projectUniforms = project.getUniforms(opts.project) as ProjectUniforms;
|
|
133
|
+
const {commonOrigin} = projectUniforms;
|
|
119
134
|
|
|
120
135
|
let mode: number = terrainSkipRender ? TERRAIN_MODE.SKIP : TERRAIN_MODE.NONE;
|
|
121
136
|
// height map if case USE_HEIGHT_MAP, terrain cover if USE_COVER, otherwise empty
|
|
@@ -131,12 +146,11 @@ if ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_US
|
|
|
131
146
|
bounds = heightMapBounds!;
|
|
132
147
|
} else if (terrainCover) {
|
|
133
148
|
// This is a terrain layer
|
|
134
|
-
const
|
|
135
|
-
const fbo = isPicking
|
|
149
|
+
const fbo = opts.isPicking
|
|
136
150
|
? terrainCover.getPickingFramebuffer()
|
|
137
151
|
: terrainCover.getRenderFramebuffer();
|
|
138
152
|
sampler = fbo?.colorAttachments[0].texture;
|
|
139
|
-
if (isPicking) {
|
|
153
|
+
if (opts.isPicking) {
|
|
140
154
|
// Never render the layer itself in picking pass
|
|
141
155
|
mode = TERRAIN_MODE.SKIP;
|
|
142
156
|
}
|
|
@@ -150,19 +164,23 @@ if ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_US
|
|
|
150
164
|
|
|
151
165
|
/* eslint-disable camelcase */
|
|
152
166
|
return {
|
|
153
|
-
|
|
167
|
+
mode,
|
|
154
168
|
terrain_map: sampler,
|
|
155
169
|
// Convert bounds to the common space, as [minX, minY, width, height]
|
|
156
|
-
|
|
170
|
+
bounds: bounds
|
|
157
171
|
? [
|
|
158
|
-
bounds[0] -
|
|
159
|
-
bounds[1] -
|
|
172
|
+
bounds[0] - commonOrigin[0],
|
|
173
|
+
bounds[1] - commonOrigin[1],
|
|
160
174
|
bounds[2] - bounds[0],
|
|
161
175
|
bounds[3] - bounds[1]
|
|
162
176
|
]
|
|
163
177
|
: [0, 0, 0, 0]
|
|
164
178
|
};
|
|
165
179
|
}
|
|
166
|
-
return
|
|
180
|
+
return {};
|
|
181
|
+
},
|
|
182
|
+
uniformTypes: {
|
|
183
|
+
mode: 'f32',
|
|
184
|
+
bounds: 'vec4<f32>'
|
|
167
185
|
}
|
|
168
|
-
} as ShaderModule<
|
|
186
|
+
} as const satisfies ShaderModule<TerrainModuleProps, TerrainModuleUniforms, TerrainModuleBindings>;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import {Texture} from '@luma.gl/core';
|
|
2
6
|
import {log} from '@deck.gl/core';
|
|
3
7
|
|
|
4
|
-
import {terrainModule,
|
|
8
|
+
import {terrainModule, TerrainModuleProps} from './shader-module';
|
|
5
9
|
import {TerrainCover} from './terrain-cover';
|
|
6
10
|
import {TerrainPass} from './terrain-pass';
|
|
7
11
|
import {TerrainPickingPass, TerrainPickingPassRenderOptions} from './terrain-picking-pass';
|
|
@@ -43,7 +47,6 @@ export class TerrainEffect implements Effect {
|
|
|
43
47
|
log.warn('Terrain offset mode is not supported by this browser')();
|
|
44
48
|
}
|
|
45
49
|
|
|
46
|
-
// @ts-expect-error stricter luma gl types
|
|
47
50
|
deck._addDefaultShaderModule(terrainModule);
|
|
48
51
|
}
|
|
49
52
|
|
|
@@ -83,16 +86,23 @@ export class TerrainEffect implements Effect {
|
|
|
83
86
|
this._updateTerrainCovers(terrainLayers, drapeLayers, viewport, opts);
|
|
84
87
|
}
|
|
85
88
|
|
|
86
|
-
|
|
89
|
+
getShaderModuleProps(
|
|
90
|
+
layer: Layer,
|
|
91
|
+
otherShaderModuleProps: Record<string, any>
|
|
92
|
+
): {terrain: TerrainModuleProps} {
|
|
87
93
|
const {terrainDrawMode} = layer.state;
|
|
88
94
|
|
|
89
95
|
return {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
+
terrain: {
|
|
97
|
+
project: otherShaderModuleProps.project,
|
|
98
|
+
isPicking: this.isPicking,
|
|
99
|
+
heightMap: this.heightMap?.getRenderFramebuffer()?.colorAttachments[0].texture || null,
|
|
100
|
+
heightMapBounds: this.heightMap?.bounds,
|
|
101
|
+
dummyHeightMap: this.dummyHeightMap!,
|
|
102
|
+
terrainCover: this.isDrapingEnabled ? this.terrainCovers.get(layer.id) : null,
|
|
103
|
+
useTerrainHeightMap: terrainDrawMode === 'offset',
|
|
104
|
+
terrainSkipRender: terrainDrawMode === 'drape' || !layer.props.operation.includes('draw')
|
|
105
|
+
}
|
|
96
106
|
};
|
|
97
107
|
}
|
|
98
108
|
|
|
@@ -112,7 +122,6 @@ export class TerrainEffect implements Effect {
|
|
|
112
122
|
}
|
|
113
123
|
this.terrainCovers.clear();
|
|
114
124
|
|
|
115
|
-
// @ts-expect-error stricter luma gl types
|
|
116
125
|
deck._removeDefaultShaderModule(terrainModule);
|
|
117
126
|
}
|
|
118
127
|
|
|
@@ -130,11 +139,15 @@ export class TerrainEffect implements Effect {
|
|
|
130
139
|
this.terrainPass.renderHeightMap(this.heightMap, {
|
|
131
140
|
...opts,
|
|
132
141
|
layers: terrainLayers,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
142
|
+
shaderModuleProps: {
|
|
143
|
+
terrain: {
|
|
144
|
+
heightMapBounds: this.heightMap.bounds,
|
|
145
|
+
dummyHeightMap: this.dummyHeightMap,
|
|
146
|
+
drawToTerrainHeightMap: true
|
|
147
|
+
},
|
|
148
|
+
project: {
|
|
149
|
+
devicePixelRatio: 1
|
|
150
|
+
}
|
|
138
151
|
}
|
|
139
152
|
});
|
|
140
153
|
}
|
|
@@ -188,10 +201,14 @@ export class TerrainEffect implements Effect {
|
|
|
188
201
|
renderPass.renderTerrainCover(terrainCover, {
|
|
189
202
|
...opts,
|
|
190
203
|
layers: drapeLayers,
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
204
|
+
shaderModuleProps: {
|
|
205
|
+
terrain: {
|
|
206
|
+
dummyHeightMap: this.dummyHeightMap,
|
|
207
|
+
terrainSkipRender: false
|
|
208
|
+
},
|
|
209
|
+
project: {
|
|
210
|
+
devicePixelRatio: 1
|
|
211
|
+
}
|
|
195
212
|
}
|
|
196
213
|
});
|
|
197
214
|
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// deck.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import {RenderPipelineParameters} from '@luma.gl/core';
|
|
2
6
|
import {Layer, Viewport, _LayersPass as LayersPass, LayersPassRenderOptions} from '@deck.gl/core';
|
|
3
7
|
import type {HeightMapBuilder} from './height-map-builder';
|
|
@@ -83,4 +87,12 @@ export class TerrainPass extends LayersPass {
|
|
|
83
87
|
...(layer.props.operation.includes('terrain') && TERRAIN_BLENDING)
|
|
84
88
|
};
|
|
85
89
|
}
|
|
90
|
+
|
|
91
|
+
getShaderModuleProps(layer: Layer, effects: any, otherShaderModuleProps: Record<string, any>) {
|
|
92
|
+
return {
|
|
93
|
+
terrain: {
|
|
94
|
+
project: otherShaderModuleProps.project
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
86
98
|
}
|
|
@@ -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,
|
|
@@ -78,4 +82,12 @@ export class TerrainPickingPass extends PickLayersPass {
|
|
|
78
82
|
}
|
|
79
83
|
return {...parameters, depthTest: false};
|
|
80
84
|
}
|
|
85
|
+
|
|
86
|
+
getShaderModuleProps(layer: Layer, effects: any, otherShaderModuleProps: Record<string, any>) {
|
|
87
|
+
return {
|
|
88
|
+
terrain: {
|
|
89
|
+
project: otherShaderModuleProps.project
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
81
93
|
}
|
package/src/terrain/utils.ts
CHANGED
package/src/utils/debug.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"syntax-tags.d.ts","sourceRoot":"","sources":["../../src/utils/syntax-tags.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,IAAI,MAAO,oBAAoB,WAAW,CAAC"}
|