@deck.gl/extensions 8.9.14 → 8.9.15
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/package.json +2 -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.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/LICENSE +0 -19
- package/typed/effect-order.d.ts +0 -6
- package/typed/effect-order.d.ts.map +0 -1
|
@@ -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/LICENSE
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2020 Urban Computing Foundation
|
|
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.
|
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"}
|