@deck.gl/extensions 8.9.11 → 8.9.13
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 +0 -2
- package/dist/es5/fill-style/fill-style-extension.js +1 -4
- package/dist/es5/fill-style/fill-style-extension.js.map +1 -1
- package/dist/esm/fill-style/fill-style-extension.js +0 -2
- package/dist/esm/fill-style/fill-style-extension.js.map +1 -1
- package/dist.min.js +1 -1
- package/package.json +3 -3
- package/src/fill-style/fill-style-extension.ts +1 -2
- package/typed/brushing/brushing.js +83 -0
- package/typed/brushing/shader-module.js +116 -0
- package/typed/clip/clip.js +114 -0
- package/typed/collide/collide-effect.d.ts +1 -1
- package/typed/collide/collide-effect.d.ts.map +1 -1
- package/typed/collide/collide-pass.d.ts +0 -1
- package/typed/collide/collide-pass.d.ts.map +1 -1
- package/typed/collide/collide.d.ts +0 -1
- package/typed/collide/collide.d.ts.map +1 -1
- package/typed/collide/shader-module.d.ts.map +1 -1
- package/typed/data-filter/aggregator.js +98 -0
- package/typed/data-filter/data-filter.js +159 -0
- package/typed/data-filter/shader-module.js +152 -0
- package/typed/fill-style/fill-style-extension.d.ts.map +1 -1
- package/typed/fill-style/fill-style.js +152 -0
- 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.js +9 -0
- package/typed/mask/mask.js +48 -0
- package/typed/mask/shader-module.js +73 -0
- package/typed/path-style/path-style.js +107 -0
- package/typed/path-style/shaders.glsl.js +93 -0
- package/typed/terrain/height-map.d.ts +27 -0
- package/typed/terrain/height-map.d.ts.map +1 -0
- package/typed/terrain/shader-module-offset.d.ts +4 -0
- package/typed/terrain/shader-module-offset.d.ts.map +1 -0
- package/typed/terrain/shader-module-source.d.ts +4 -0
- package/typed/terrain/shader-module-source.d.ts.map +1 -0
- package/typed/effect-order.d.ts +0 -6
- package/typed/effect-order.d.ts.map +0 -1
|
@@ -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.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as BrushingExtension } from './brushing/brushing-extension';
|
|
2
|
+
export { default as DataFilterExtension } from './data-filter/data-filter-extension';
|
|
3
|
+
export { default as Fp64Extension } from './fp64/fp64-extension';
|
|
4
|
+
export { default as PathStyleExtension } from './path-style/path-style-extension';
|
|
5
|
+
export { default as FillStyleExtension } from './fill-style/fill-style';
|
|
6
|
+
export { default as ClipExtension } from './clip/clip-extension';
|
|
7
|
+
export { default as MaskExtension } from './mask/mask';
|
|
8
|
+
// Shader module
|
|
9
|
+
export { default as project64 } from './fp64/project64';
|
|
@@ -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;
|
|
@@ -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,107 @@
|
|
|
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, _mergeShaders as mergeShaders } from '@deck.gl/core';
|
|
21
|
+
import { dashShaders, offsetShaders } from './shaders.glsl';
|
|
22
|
+
import { dist } from 'gl-matrix/vec3';
|
|
23
|
+
const defaultProps = {
|
|
24
|
+
getDashArray: { type: 'accessor', value: [0, 0] },
|
|
25
|
+
getOffset: { type: 'accessor', value: 0 },
|
|
26
|
+
dashJustified: false,
|
|
27
|
+
dashGapPickable: false
|
|
28
|
+
};
|
|
29
|
+
export default class PathStyleExtension extends LayerExtension {
|
|
30
|
+
constructor({ dash = false, offset = false, highPrecisionDash = false } = {}) {
|
|
31
|
+
super({ dash: dash || highPrecisionDash, offset, highPrecisionDash });
|
|
32
|
+
}
|
|
33
|
+
isEnabled(layer) {
|
|
34
|
+
return layer.state.pathTesselator;
|
|
35
|
+
}
|
|
36
|
+
getShaders(extension) {
|
|
37
|
+
if (!extension.isEnabled(this)) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
// Merge shader injection
|
|
41
|
+
let result = {};
|
|
42
|
+
if (extension.opts.dash) {
|
|
43
|
+
result = mergeShaders(result, dashShaders);
|
|
44
|
+
}
|
|
45
|
+
if (extension.opts.offset) {
|
|
46
|
+
result = mergeShaders(result, offsetShaders);
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
initializeState(context, extension) {
|
|
51
|
+
const attributeManager = this.getAttributeManager();
|
|
52
|
+
if (!attributeManager || !extension.isEnabled(this)) {
|
|
53
|
+
// This extension only works with the PathLayer
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
extension.enabled = true;
|
|
57
|
+
if (extension.opts.dash) {
|
|
58
|
+
attributeManager.addInstanced({
|
|
59
|
+
instanceDashArrays: { size: 2, accessor: 'getDashArray' }
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (extension.opts.highPrecisionDash) {
|
|
63
|
+
attributeManager.addInstanced({
|
|
64
|
+
instanceDashOffsets: {
|
|
65
|
+
size: 1,
|
|
66
|
+
accessor: 'getPath',
|
|
67
|
+
transform: extension.getDashOffsets.bind(this)
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (extension.opts.offset) {
|
|
72
|
+
attributeManager.addInstanced({
|
|
73
|
+
instanceOffsets: { size: 1, accessor: 'getOffset' }
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
updateState(params, extension) {
|
|
78
|
+
if (!extension.isEnabled(this)) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const uniforms = {};
|
|
82
|
+
if (extension.opts.dash) {
|
|
83
|
+
uniforms.dashAlignMode = this.props.dashJustified ? 1 : 0;
|
|
84
|
+
uniforms.dashGapPickable = Boolean(this.props.dashGapPickable);
|
|
85
|
+
}
|
|
86
|
+
this.state.model.setUniforms(uniforms);
|
|
87
|
+
}
|
|
88
|
+
getDashOffsets(path) {
|
|
89
|
+
const result = [0];
|
|
90
|
+
const positionSize = this.props.positionFormat === 'XY' ? 2 : 3;
|
|
91
|
+
const isNested = Array.isArray(path[0]);
|
|
92
|
+
const geometrySize = isNested ? path.length : path.length / positionSize;
|
|
93
|
+
let p;
|
|
94
|
+
let prevP;
|
|
95
|
+
for (let i = 0; i < geometrySize - 1; i++) {
|
|
96
|
+
p = isNested ? path[i] : path.slice(i * positionSize, i * positionSize + positionSize);
|
|
97
|
+
p = this.projectPosition(p);
|
|
98
|
+
if (i > 0) {
|
|
99
|
+
result[i] = result[i - 1] + dist(prevP, p);
|
|
100
|
+
}
|
|
101
|
+
prevP = p;
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
PathStyleExtension.extensionName = 'PathStyleExtension';
|
|
107
|
+
PathStyleExtension.defaultProps = defaultProps;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export const dashShaders = {
|
|
2
|
+
inject: {
|
|
3
|
+
'vs:#decl': `
|
|
4
|
+
attribute vec2 instanceDashArrays;
|
|
5
|
+
attribute float instanceDashOffsets;
|
|
6
|
+
varying vec2 vDashArray;
|
|
7
|
+
varying float vDashOffset;
|
|
8
|
+
`,
|
|
9
|
+
'vs:#main-end': `
|
|
10
|
+
vDashArray = instanceDashArrays;
|
|
11
|
+
vDashOffset = instanceDashOffsets / width.x;
|
|
12
|
+
`,
|
|
13
|
+
'fs:#decl': `
|
|
14
|
+
uniform float dashAlignMode;
|
|
15
|
+
uniform float capType;
|
|
16
|
+
uniform bool dashGapPickable;
|
|
17
|
+
varying vec2 vDashArray;
|
|
18
|
+
varying float vDashOffset;
|
|
19
|
+
|
|
20
|
+
float round(float x) {
|
|
21
|
+
return floor(x + 0.5);
|
|
22
|
+
}
|
|
23
|
+
`,
|
|
24
|
+
// if given position is in the gap part of the dashed line
|
|
25
|
+
// dashArray.x: solid stroke length, relative to width
|
|
26
|
+
// dashArray.y: gap length, relative to width
|
|
27
|
+
// alignMode:
|
|
28
|
+
// 0 - no adjustment
|
|
29
|
+
// o---- ---- ---- ---- o---- -o---- ---- o
|
|
30
|
+
// 1 - stretch to fit, draw half dash at each end for nicer joints
|
|
31
|
+
// o-- ---- ---- ---- --o-- --o-- ---- --o
|
|
32
|
+
'fs:#main-start': `
|
|
33
|
+
float solidLength = vDashArray.x;
|
|
34
|
+
float gapLength = vDashArray.y;
|
|
35
|
+
float unitLength = solidLength + gapLength;
|
|
36
|
+
|
|
37
|
+
float offset;
|
|
38
|
+
|
|
39
|
+
if (unitLength > 0.0) {
|
|
40
|
+
if (dashAlignMode == 0.0) {
|
|
41
|
+
offset = vDashOffset;
|
|
42
|
+
} else {
|
|
43
|
+
unitLength = vPathLength / round(vPathLength / unitLength);
|
|
44
|
+
offset = solidLength / 2.0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
float unitOffset = mod(clamp(vPathPosition.y, 0.0, vPathLength) + offset, unitLength);
|
|
48
|
+
|
|
49
|
+
if (gapLength > 0.0 && unitOffset > solidLength) {
|
|
50
|
+
if (capType <= 0.5) {
|
|
51
|
+
if (!(dashGapPickable && picking_uActive)) {
|
|
52
|
+
discard;
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
// caps are rounded, test the distance to solid ends
|
|
56
|
+
float distToEnd = length(vec2(
|
|
57
|
+
min(unitOffset - solidLength, unitLength - unitOffset),
|
|
58
|
+
vPathPosition.x
|
|
59
|
+
));
|
|
60
|
+
if (distToEnd > 1.0) {
|
|
61
|
+
if (!(dashGapPickable && picking_uActive)) {
|
|
62
|
+
discard;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
`
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
export const offsetShaders = {
|
|
72
|
+
inject: {
|
|
73
|
+
'vs:#decl': `
|
|
74
|
+
attribute float instanceOffsets;
|
|
75
|
+
`,
|
|
76
|
+
'vs:DECKGL_FILTER_SIZE': `
|
|
77
|
+
float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;
|
|
78
|
+
size *= offsetWidth;
|
|
79
|
+
`,
|
|
80
|
+
'vCornerOffset = offsetVec;': `
|
|
81
|
+
float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;
|
|
82
|
+
vec2 offsetCenter = -instanceOffsets * (isCap ? perp : miterVec * miterSize) * 2.0;
|
|
83
|
+
vCornerOffset = vCornerOffset * offsetWidth - offsetCenter;
|
|
84
|
+
`,
|
|
85
|
+
'fs:#main-start': `
|
|
86
|
+
float isInside;
|
|
87
|
+
isInside = step(-1.0, vPathPosition.x) * step(vPathPosition.x, 1.0);
|
|
88
|
+
if (isInside == 0.0) {
|
|
89
|
+
discard;
|
|
90
|
+
}
|
|
91
|
+
`
|
|
92
|
+
}
|
|
93
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Framebuffer } from '@luma.gl/core';
|
|
2
|
+
import { Bounds } from '../utils/projection-utils';
|
|
3
|
+
import type { Viewport, Layer } from '@deck.gl/core/typed';
|
|
4
|
+
export declare class HeightMap {
|
|
5
|
+
/** Viewport used to draw into the texture */
|
|
6
|
+
renderViewport: Viewport | null;
|
|
7
|
+
/** Bounds of the height map texture, in cartesian space */
|
|
8
|
+
bounds: Bounds | null;
|
|
9
|
+
private fbo?;
|
|
10
|
+
private gl;
|
|
11
|
+
/** Last rendered layers */
|
|
12
|
+
private layers;
|
|
13
|
+
/** Last layer.getBounds() */
|
|
14
|
+
private layersBounds;
|
|
15
|
+
/** The union of layersBounds in cartesian space */
|
|
16
|
+
private layersBoundsCommon;
|
|
17
|
+
private lastViewport;
|
|
18
|
+
static isSupported(gl: WebGLRenderingContext): boolean;
|
|
19
|
+
constructor(gl: WebGLRenderingContext);
|
|
20
|
+
getRenderFramebuffer(): Framebuffer | null;
|
|
21
|
+
shouldUpdate({ layers, viewport }: {
|
|
22
|
+
layers: Layer[];
|
|
23
|
+
viewport: Viewport;
|
|
24
|
+
}): boolean;
|
|
25
|
+
delete(): void;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=height-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"height-map.d.ts","sourceRoot":"","sources":["../../src/terrain/height-map.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAiD,MAAM,EAAC,MAAM,4BAA4B,CAAC;AAGlG,OAAO,KAAK,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,eAAe,CAAC;AAInD,qBAAa,SAAS;IACpB,6CAA6C;IAC7C,cAAc,EAAE,QAAQ,GAAG,IAAI,CAAQ;IACvC,2DAA2D;IAC3D,MAAM,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE7B,OAAO,CAAC,GAAG,CAAC,CAAc;IAC1B,OAAO,CAAC,EAAE,CAAwB;IAClC,2BAA2B;IAC3B,OAAO,CAAC,MAAM,CAAe;IAC7B,6BAA6B;IAC7B,OAAO,CAAC,YAAY,CAAuC;IAC3D,mDAAmD;IACnD,OAAO,CAAC,kBAAkB,CAAuB;IACjD,OAAO,CAAC,YAAY,CAAyB;IAE7C,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,qBAAqB,GAAG,OAAO;gBAI1C,EAAE,EAAE,qBAAqB;IAIrC,oBAAoB,IAAI,WAAW,GAAG,IAAI;IAU1C,YAAY,CAAC,EAAC,MAAM,EAAE,QAAQ,EAAC,EAAE;QAAC,MAAM,EAAE,KAAK,EAAE,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAA;KAAC,GAAG,OAAO;IA4DhF,MAAM;CAMP"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shader-module-offset.d.ts","sourceRoot":"","sources":["../../src/terrain/shader-module-offset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,IAAI,YAAY,EAAC,MAAM,eAAe,CAAC;;AAEjE,wBAyBkB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shader-module-source.d.ts","sourceRoot":"","sources":["../../src/terrain/shader-module-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,IAAI,YAAY,EAAC,MAAM,eAAe,CAAC;;AAEjE,wBAiCkB"}
|
package/typed/effect-order.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"effect-order.d.ts","sourceRoot":"","sources":["../src/effect-order.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,WAAW;;;CAGhB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|