@deck.gl/extensions 9.0.0-beta.1 → 9.0.0-beta.10
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.js +80 -0
- package/{typed → dist}/brushing/shader-module.d.ts +1 -1
- package/{typed → dist}/brushing/shader-module.d.ts.map +1 -1
- package/dist/brushing/shader-module.js +92 -0
- package/{typed → dist}/clip/clip-extension.d.ts.map +1 -1
- package/dist/clip/clip-extension.js +117 -0
- package/{typed → dist}/collision-filter/collision-filter-effect.d.ts.map +1 -1
- package/dist/collision-filter/collision-filter-effect.js +193 -0
- package/dist/collision-filter/collision-filter-extension.js +49 -0
- package/{typed → dist}/collision-filter/collision-filter-pass.d.ts.map +1 -1
- package/dist/collision-filter/collision-filter-pass.js +25 -0
- package/{typed → dist}/collision-filter/shader-module.d.ts.map +1 -1
- package/dist/collision-filter/shader-module.js +87 -0
- package/dist/data-filter/aggregator.d.ts.map +1 -0
- package/dist/{esm/data-filter → data-filter}/aggregator.js +40 -41
- package/{typed → dist}/data-filter/data-filter-extension.d.ts +38 -6
- package/dist/data-filter/data-filter-extension.d.ts.map +1 -0
- package/dist/data-filter/data-filter-extension.js +249 -0
- package/{typed → dist}/data-filter/shader-module.d.ts +1 -1
- package/dist/data-filter/shader-module.d.ts.map +1 -0
- package/dist/data-filter/shader-module.js +179 -0
- package/dist/dist.dev.js +2203 -10630
- package/{typed → dist}/fill-style/fill-style-extension.d.ts +2 -30
- package/dist/fill-style/fill-style-extension.d.ts.map +1 -0
- package/dist/fill-style/fill-style-extension.js +116 -0
- package/{typed/fill-style/shaders.glsl.d.ts → dist/fill-style/shader-module.d.ts} +1 -1
- package/dist/fill-style/shader-module.d.ts.map +1 -0
- package/dist/fill-style/shader-module.js +96 -0
- package/dist/fp64/fp64-extension.js +35 -0
- package/dist/fp64/project64.glsl.js +81 -0
- package/dist/fp64/project64.js +50 -0
- package/dist/index.cjs +2756 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/{typed → dist}/mask/mask-effect.d.ts +1 -1
- package/dist/mask/mask-effect.d.ts.map +1 -0
- package/dist/mask/mask-effect.js +194 -0
- package/dist/mask/mask-extension.js +57 -0
- package/{typed → dist}/mask/mask-pass.d.ts.map +1 -1
- package/dist/mask/mask-pass.js +44 -0
- package/{typed → dist}/mask/shader-module.d.ts.map +1 -1
- package/dist/mask/shader-module.js +77 -0
- package/dist/path-style/path-style-extension.js +111 -0
- package/dist/path-style/shaders.glsl.js +86 -0
- package/{typed → dist}/terrain/height-map-builder.d.ts +1 -1
- package/dist/terrain/height-map-builder.d.ts.map +1 -0
- package/dist/terrain/height-map-builder.js +104 -0
- package/{typed → dist}/terrain/shader-module.d.ts +2 -2
- package/dist/terrain/shader-module.d.ts.map +1 -0
- package/dist/terrain/shader-module.js +137 -0
- package/{typed → dist}/terrain/terrain-cover.d.ts +1 -1
- package/dist/terrain/terrain-cover.d.ts.map +1 -0
- package/dist/terrain/terrain-cover.js +187 -0
- package/{typed → dist}/terrain/terrain-effect.d.ts +2 -2
- package/dist/terrain/terrain-effect.d.ts.map +1 -0
- package/dist/terrain/terrain-effect.js +184 -0
- package/dist/terrain/terrain-extension.js +44 -0
- package/{typed → dist}/terrain/terrain-pass.d.ts +2 -2
- package/dist/terrain/terrain-pass.d.ts.map +1 -0
- package/dist/terrain/terrain-pass.js +61 -0
- package/{typed → dist}/terrain/terrain-picking-pass.d.ts +1 -1
- package/dist/terrain/terrain-picking-pass.d.ts.map +1 -0
- package/dist/terrain/terrain-picking-pass.js +66 -0
- package/dist/terrain/utils.js +21 -0
- package/{typed → dist}/utils/debug.d.ts.map +1 -1
- package/dist/utils/debug.js +50 -0
- package/dist/utils/projection-utils.js +153 -0
- package/dist/utils/syntax-tags.d.ts +6 -0
- package/dist/utils/syntax-tags.d.ts.map +1 -0
- package/dist/utils/syntax-tags.js +5 -0
- package/dist.min.js +898 -1257
- package/package.json +19 -16
- package/src/brushing/shader-module.ts +4 -3
- package/src/clip/clip-extension.ts +10 -9
- package/src/collision-filter/collision-filter-effect.ts +12 -8
- package/src/collision-filter/collision-filter-pass.ts +1 -3
- package/src/collision-filter/shader-module.ts +6 -4
- package/src/data-filter/aggregator.ts +8 -13
- package/src/data-filter/data-filter-extension.ts +147 -30
- package/src/data-filter/shader-module.ts +38 -9
- package/src/fill-style/fill-style-extension.ts +4 -5
- package/src/fill-style/{shaders.glsl.ts → shader-module.ts} +6 -5
- package/src/mask/mask-effect.ts +0 -1
- package/src/mask/mask-pass.ts +1 -3
- package/src/mask/shader-module.ts +7 -6
- package/src/terrain/shader-module.ts +14 -13
- package/src/terrain/terrain-effect.ts +12 -5
- package/src/terrain/terrain-pass.ts +2 -5
- package/src/terrain/terrain-picking-pass.ts +1 -3
- package/src/terrain/utils.ts +1 -1
- package/src/utils/debug.ts +1 -2
- package/src/utils/syntax-tags.ts +5 -0
- package/dist/es5/brushing/brushing-extension.js +0 -108
- package/dist/es5/brushing/brushing-extension.js.map +0 -1
- package/dist/es5/brushing/shader-module.js +0 -50
- package/dist/es5/brushing/shader-module.js.map +0 -1
- package/dist/es5/clip/clip-extension.js +0 -98
- package/dist/es5/clip/clip-extension.js.map +0 -1
- package/dist/es5/collision-filter/collision-filter-effect.js +0 -294
- package/dist/es5/collision-filter/collision-filter-effect.js.map +0 -1
- package/dist/es5/collision-filter/collision-filter-extension.js +0 -109
- package/dist/es5/collision-filter/collision-filter-extension.js.map +0 -1
- package/dist/es5/collision-filter/collision-filter-pass.js +0 -79
- package/dist/es5/collision-filter/collision-filter-pass.js.map +0 -1
- package/dist/es5/collision-filter/shader-module.js +0 -39
- package/dist/es5/collision-filter/shader-module.js.map +0 -1
- package/dist/es5/data-filter/aggregator.js +0 -79
- package/dist/es5/data-filter/aggregator.js.map +0 -1
- package/dist/es5/data-filter/data-filter-extension.js +0 -236
- package/dist/es5/data-filter/data-filter-extension.js.map +0 -1
- package/dist/es5/data-filter/shader-module.js +0 -122
- package/dist/es5/data-filter/shader-module.js.map +0 -1
- package/dist/es5/fill-style/fill-style-extension.js +0 -190
- package/dist/es5/fill-style/fill-style-extension.js.map +0 -1
- package/dist/es5/fill-style/shaders.glsl.js +0 -59
- package/dist/es5/fill-style/shaders.glsl.js.map +0 -1
- package/dist/es5/fp64/fp64-extension.js +0 -55
- package/dist/es5/fp64/fp64-extension.js.map +0 -1
- package/dist/es5/fp64/project64.glsl.js +0 -9
- package/dist/es5/fp64/project64.glsl.js.map +0 -1
- package/dist/es5/fp64/project64.js +0 -52
- package/dist/es5/fp64/project64.js.map +0 -1
- package/dist/es5/index.js +0 -88
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/mask/mask-effect.js +0 -279
- package/dist/es5/mask/mask-effect.js.map +0 -1
- package/dist/es5/mask/mask-extension.js +0 -113
- package/dist/es5/mask/mask-extension.js.map +0 -1
- package/dist/es5/mask/mask-pass.js +0 -106
- package/dist/es5/mask/mask-pass.js.map +0 -1
- package/dist/es5/mask/shader-module.js +0 -38
- package/dist/es5/mask/shader-module.js.map +0 -1
- package/dist/es5/path-style/path-style-extension.js +0 -169
- package/dist/es5/path-style/path-style-extension.js.map +0 -1
- package/dist/es5/path-style/shaders.glsl.js +0 -25
- package/dist/es5/path-style/shaders.glsl.js.map +0 -1
- package/dist/es5/terrain/height-map-builder.js +0 -111
- package/dist/es5/terrain/height-map-builder.js.map +0 -1
- package/dist/es5/terrain/shader-module.js +0 -86
- package/dist/es5/terrain/shader-module.js.map +0 -1
- package/dist/es5/terrain/terrain-cover.js +0 -256
- package/dist/es5/terrain/terrain-cover.js.map +0 -1
- package/dist/es5/terrain/terrain-effect.js +0 -326
- package/dist/es5/terrain/terrain-effect.js.map +0 -1
- package/dist/es5/terrain/terrain-extension.js +0 -94
- package/dist/es5/terrain/terrain-extension.js.map +0 -1
- package/dist/es5/terrain/terrain-pass.js +0 -121
- package/dist/es5/terrain/terrain-pass.js.map +0 -1
- package/dist/es5/terrain/terrain-picking-pass.js +0 -124
- package/dist/es5/terrain/terrain-picking-pass.js.map +0 -1
- package/dist/es5/terrain/utils.js +0 -35
- package/dist/es5/terrain/utils.js.map +0 -1
- package/dist/es5/utils/debug.js +0 -71
- package/dist/es5/utils/debug.js.map +0 -1
- package/dist/es5/utils/projection-utils.js +0 -168
- package/dist/es5/utils/projection-utils.js.map +0 -1
- package/dist/esm/brushing/brushing-extension.js +0 -68
- package/dist/esm/brushing/brushing-extension.js.map +0 -1
- package/dist/esm/brushing/shader-module.js +0 -103
- package/dist/esm/brushing/shader-module.js.map +0 -1
- package/dist/esm/clip/clip-extension.js +0 -86
- package/dist/esm/clip/clip-extension.js.map +0 -1
- package/dist/esm/collision-filter/collision-filter-effect.js +0 -246
- package/dist/esm/collision-filter/collision-filter-effect.js.map +0 -1
- package/dist/esm/collision-filter/collision-filter-extension.js +0 -75
- package/dist/esm/collision-filter/collision-filter-extension.js.map +0 -1
- package/dist/esm/collision-filter/collision-filter-pass.js +0 -32
- package/dist/esm/collision-filter/collision-filter-pass.js.map +0 -1
- package/dist/esm/collision-filter/shader-module.js +0 -104
- package/dist/esm/collision-filter/shader-module.js.map +0 -1
- package/dist/esm/data-filter/aggregator.js.map +0 -1
- package/dist/esm/data-filter/data-filter-extension.js +0 -189
- package/dist/esm/data-filter/data-filter-extension.js.map +0 -1
- package/dist/esm/data-filter/shader-module.js +0 -164
- package/dist/esm/data-filter/shader-module.js.map +0 -1
- package/dist/esm/fill-style/fill-style-extension.js +0 -156
- package/dist/esm/fill-style/fill-style-extension.js.map +0 -1
- package/dist/esm/fill-style/shaders.glsl.js +0 -108
- package/dist/esm/fill-style/shaders.glsl.js.map +0 -1
- package/dist/esm/fp64/fp64-extension.js +0 -20
- package/dist/esm/fp64/fp64-extension.js.map +0 -1
- package/dist/esm/fp64/project64.glsl.js +0 -82
- package/dist/esm/fp64/project64.glsl.js.map +0 -1
- package/dist/esm/fp64/project64.js +0 -43
- package/dist/esm/fp64/project64.js.map +0 -1
- package/dist/esm/index.js +0 -11
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/mask/mask-effect.js +0 -228
- package/dist/esm/mask/mask-effect.js.map +0 -1
- package/dist/esm/mask/mask-extension.js +0 -83
- package/dist/esm/mask/mask-extension.js.map +0 -1
- package/dist/esm/mask/mask-pass.js +0 -58
- package/dist/esm/mask/mask-pass.js.map +0 -1
- package/dist/esm/mask/shader-module.js +0 -84
- package/dist/esm/mask/shader-module.js.map +0 -1
- package/dist/esm/path-style/path-style-extension.js +0 -130
- package/dist/esm/path-style/path-style-extension.js.map +0 -1
- package/dist/esm/path-style/shaders.glsl.js +0 -84
- package/dist/esm/path-style/shaders.glsl.js.map +0 -1
- package/dist/esm/terrain/height-map-builder.js +0 -86
- package/dist/esm/terrain/height-map-builder.js.map +0 -1
- package/dist/esm/terrain/shader-module.js +0 -127
- package/dist/esm/terrain/shader-module.js.map +0 -1
- package/dist/esm/terrain/terrain-cover.js +0 -212
- package/dist/esm/terrain/terrain-cover.js.map +0 -1
- package/dist/esm/terrain/terrain-effect.js +0 -219
- package/dist/esm/terrain/terrain-effect.js.map +0 -1
- package/dist/esm/terrain/terrain-extension.js +0 -59
- package/dist/esm/terrain/terrain-extension.js.map +0 -1
- package/dist/esm/terrain/terrain-pass.js +0 -71
- package/dist/esm/terrain/terrain-pass.js.map +0 -1
- package/dist/esm/terrain/terrain-picking-pass.js +0 -73
- package/dist/esm/terrain/terrain-picking-pass.js.map +0 -1
- package/dist/esm/terrain/utils.js +0 -19
- package/dist/esm/terrain/utils.js.map +0 -1
- package/dist/esm/utils/debug.js +0 -61
- package/dist/esm/utils/debug.js.map +0 -1
- package/dist/esm/utils/projection-utils.js +0 -134
- package/dist/esm/utils/projection-utils.js.map +0 -1
- package/typed/data-filter/aggregator.d.ts.map +0 -1
- package/typed/data-filter/data-filter-extension.d.ts.map +0 -1
- package/typed/data-filter/shader-module.d.ts.map +0 -1
- package/typed/fill-style/fill-style-extension.d.ts.map +0 -1
- package/typed/fill-style/shaders.glsl.d.ts.map +0 -1
- package/typed/index.d.ts +0 -19
- package/typed/index.d.ts.map +0 -1
- package/typed/mask/mask-effect.d.ts.map +0 -1
- package/typed/terrain/height-map-builder.d.ts.map +0 -1
- package/typed/terrain/shader-module.d.ts.map +0 -1
- package/typed/terrain/terrain-cover.d.ts.map +0 -1
- package/typed/terrain/terrain-effect.d.ts.map +0 -1
- package/typed/terrain/terrain-pass.d.ts.map +0 -1
- package/typed/terrain/terrain-picking-pass.d.ts.map +0 -1
- /package/{typed → dist}/brushing/brushing-extension.d.ts +0 -0
- /package/{typed → dist}/brushing/brushing-extension.d.ts.map +0 -0
- /package/{typed → dist}/clip/clip-extension.d.ts +0 -0
- /package/{typed → dist}/collision-filter/collision-filter-effect.d.ts +0 -0
- /package/{typed → dist}/collision-filter/collision-filter-extension.d.ts +0 -0
- /package/{typed → dist}/collision-filter/collision-filter-extension.d.ts.map +0 -0
- /package/{typed → dist}/collision-filter/collision-filter-pass.d.ts +0 -0
- /package/{typed → dist}/collision-filter/shader-module.d.ts +0 -0
- /package/{typed → dist}/data-filter/aggregator.d.ts +0 -0
- /package/{typed → dist}/fp64/fp64-extension.d.ts +0 -0
- /package/{typed → dist}/fp64/fp64-extension.d.ts.map +0 -0
- /package/{typed → dist}/fp64/project64.d.ts +0 -0
- /package/{typed → dist}/fp64/project64.d.ts.map +0 -0
- /package/{typed → dist}/fp64/project64.glsl.d.ts +0 -0
- /package/{typed → dist}/fp64/project64.glsl.d.ts.map +0 -0
- /package/{typed → dist}/mask/mask-extension.d.ts +0 -0
- /package/{typed → dist}/mask/mask-extension.d.ts.map +0 -0
- /package/{typed → dist}/mask/mask-pass.d.ts +0 -0
- /package/{typed → dist}/mask/shader-module.d.ts +0 -0
- /package/{typed → dist}/path-style/path-style-extension.d.ts +0 -0
- /package/{typed → dist}/path-style/path-style-extension.d.ts.map +0 -0
- /package/{typed → dist}/path-style/shaders.glsl.d.ts +0 -0
- /package/{typed → dist}/path-style/shaders.glsl.d.ts.map +0 -0
- /package/{typed → dist}/terrain/terrain-extension.d.ts +0 -0
- /package/{typed → dist}/terrain/terrain-extension.d.ts.map +0 -0
- /package/{typed → dist}/terrain/utils.d.ts +0 -0
- /package/{typed → dist}/terrain/utils.d.ts.map +0 -0
- /package/{typed → dist}/utils/debug.d.ts +0 -0
- /package/{typed → dist}/utils/projection-utils.d.ts +0 -0
- /package/{typed → dist}/utils/projection-utils.d.ts.map +0 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { log } from '@deck.gl/core';
|
|
2
|
+
import { equals } from '@math.gl/core';
|
|
3
|
+
import MaskPass from "./mask-pass.js";
|
|
4
|
+
import { joinLayerBounds, getRenderBounds, makeViewport } from "../utils/projection-utils.js";
|
|
5
|
+
// Class to manage mask effect
|
|
6
|
+
export default class MaskEffect {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.id = 'mask-effect';
|
|
9
|
+
this.props = null;
|
|
10
|
+
this.useInPicking = true;
|
|
11
|
+
this.order = 0;
|
|
12
|
+
this.channels = [];
|
|
13
|
+
this.masks = null;
|
|
14
|
+
}
|
|
15
|
+
preRender(device, { layers, layerFilter, viewports, onViewportActive, views, isPicking }) {
|
|
16
|
+
let didRender = false;
|
|
17
|
+
if (!this.dummyMaskMap) {
|
|
18
|
+
this.dummyMaskMap = device.createTexture({
|
|
19
|
+
width: 1,
|
|
20
|
+
height: 1
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
if (isPicking) {
|
|
24
|
+
// Do not update on picking pass
|
|
25
|
+
return { didRender };
|
|
26
|
+
}
|
|
27
|
+
const maskLayers = layers.filter(l => l.props.visible && l.props.operation.includes('mask'));
|
|
28
|
+
if (maskLayers.length === 0) {
|
|
29
|
+
this.masks = null;
|
|
30
|
+
this.channels.length = 0;
|
|
31
|
+
return { didRender };
|
|
32
|
+
}
|
|
33
|
+
this.masks = {};
|
|
34
|
+
if (!this.maskPass) {
|
|
35
|
+
this.maskPass = new MaskPass(device, { id: 'default-mask' });
|
|
36
|
+
this.maskMap = this.maskPass.maskMap;
|
|
37
|
+
}
|
|
38
|
+
// Map layers to channels
|
|
39
|
+
const channelMap = this._sortMaskChannels(maskLayers);
|
|
40
|
+
// TODO - support multiple views
|
|
41
|
+
const viewport = viewports[0];
|
|
42
|
+
const viewportChanged = !this.lastViewport || !this.lastViewport.equals(viewport);
|
|
43
|
+
if (viewport.resolution !== undefined) {
|
|
44
|
+
log.warn('MaskExtension is not supported in GlobeView')();
|
|
45
|
+
return { didRender };
|
|
46
|
+
}
|
|
47
|
+
for (const maskId in channelMap) {
|
|
48
|
+
const result = this._renderChannel(channelMap[maskId], {
|
|
49
|
+
layerFilter,
|
|
50
|
+
onViewportActive,
|
|
51
|
+
views,
|
|
52
|
+
viewport,
|
|
53
|
+
viewportChanged
|
|
54
|
+
});
|
|
55
|
+
didRender ||= result;
|
|
56
|
+
}
|
|
57
|
+
// debugFBO(this.maskMap, {opaque: true});
|
|
58
|
+
return { didRender };
|
|
59
|
+
}
|
|
60
|
+
/* eslint-disable-next-line complexity */
|
|
61
|
+
_renderChannel(channelInfo, { layerFilter, onViewportActive, views, viewport, viewportChanged }) {
|
|
62
|
+
let didRender = false;
|
|
63
|
+
const oldChannelInfo = this.channels[channelInfo.index];
|
|
64
|
+
if (!oldChannelInfo) {
|
|
65
|
+
return didRender;
|
|
66
|
+
}
|
|
67
|
+
const maskChanged =
|
|
68
|
+
// If a channel is new
|
|
69
|
+
channelInfo === oldChannelInfo ||
|
|
70
|
+
// If sublayers have changed
|
|
71
|
+
channelInfo.layers.length !== oldChannelInfo.layers.length ||
|
|
72
|
+
channelInfo.layers.some((layer, i) =>
|
|
73
|
+
// Layer instance is updated
|
|
74
|
+
// Layer props might have changed
|
|
75
|
+
// Undetermined props could have an effect on the output geometry of a mask layer,
|
|
76
|
+
// for example getRadius+updateTriggers, radiusScale, modelMatrix
|
|
77
|
+
layer !== oldChannelInfo.layers[i] ||
|
|
78
|
+
// Some prop is in transition
|
|
79
|
+
layer.props.transitions) ||
|
|
80
|
+
// If a sublayer's positions have been updated, the cached bounds will change shallowly
|
|
81
|
+
channelInfo.layerBounds.some((b, i) => b !== oldChannelInfo.layerBounds[i]);
|
|
82
|
+
channelInfo.bounds = oldChannelInfo.bounds;
|
|
83
|
+
channelInfo.maskBounds = oldChannelInfo.maskBounds;
|
|
84
|
+
this.channels[channelInfo.index] = channelInfo;
|
|
85
|
+
if (maskChanged || viewportChanged) {
|
|
86
|
+
// Recalculate mask bounds
|
|
87
|
+
this.lastViewport = viewport;
|
|
88
|
+
const layerBounds = joinLayerBounds(channelInfo.layers, viewport);
|
|
89
|
+
channelInfo.bounds = layerBounds && getRenderBounds(layerBounds, viewport);
|
|
90
|
+
if (maskChanged || !equals(channelInfo.bounds, oldChannelInfo.bounds)) {
|
|
91
|
+
// Rerender mask FBO
|
|
92
|
+
const { maskPass, maskMap } = this;
|
|
93
|
+
const maskViewport = layerBounds &&
|
|
94
|
+
makeViewport({
|
|
95
|
+
bounds: channelInfo.bounds,
|
|
96
|
+
viewport,
|
|
97
|
+
width: maskMap.width,
|
|
98
|
+
height: maskMap.height,
|
|
99
|
+
border: 1
|
|
100
|
+
});
|
|
101
|
+
channelInfo.maskBounds = maskViewport ? maskViewport.getBounds() : [0, 0, 1, 1];
|
|
102
|
+
// @ts-ignore (2532) This method is only called from preRender where maskPass is defined
|
|
103
|
+
maskPass.render({
|
|
104
|
+
pass: 'mask',
|
|
105
|
+
channel: channelInfo.index,
|
|
106
|
+
layers: channelInfo.layers,
|
|
107
|
+
layerFilter,
|
|
108
|
+
viewports: maskViewport ? [maskViewport] : [],
|
|
109
|
+
onViewportActive,
|
|
110
|
+
views,
|
|
111
|
+
moduleParameters: {
|
|
112
|
+
devicePixelRatio: 1
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
didRender = true;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// @ts-ignore (2532) This method is only called from preRender where masks is defined
|
|
119
|
+
this.masks[channelInfo.id] = {
|
|
120
|
+
index: channelInfo.index,
|
|
121
|
+
bounds: channelInfo.maskBounds,
|
|
122
|
+
coordinateOrigin: channelInfo.coordinateOrigin,
|
|
123
|
+
coordinateSystem: channelInfo.coordinateSystem
|
|
124
|
+
};
|
|
125
|
+
return didRender;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Find a channel to render each mask into
|
|
129
|
+
* If a maskId already exists, diff and update the existing channel
|
|
130
|
+
* Otherwise replace a removed mask
|
|
131
|
+
* Otherwise create a new channel
|
|
132
|
+
* Returns a map from mask layer id to channel info
|
|
133
|
+
*/
|
|
134
|
+
_sortMaskChannels(maskLayers) {
|
|
135
|
+
const channelMap = {};
|
|
136
|
+
let channelCount = 0;
|
|
137
|
+
for (const layer of maskLayers) {
|
|
138
|
+
const { id } = layer.root;
|
|
139
|
+
let channelInfo = channelMap[id];
|
|
140
|
+
if (!channelInfo) {
|
|
141
|
+
if (++channelCount > 4) {
|
|
142
|
+
log.warn('Too many mask layers. The max supported is 4')();
|
|
143
|
+
continue; // eslint-disable-line no-continue
|
|
144
|
+
}
|
|
145
|
+
channelInfo = {
|
|
146
|
+
id,
|
|
147
|
+
index: this.channels.findIndex(c => c?.id === id),
|
|
148
|
+
layers: [],
|
|
149
|
+
layerBounds: [],
|
|
150
|
+
coordinateOrigin: layer.root.props.coordinateOrigin,
|
|
151
|
+
coordinateSystem: layer.root.props.coordinateSystem
|
|
152
|
+
};
|
|
153
|
+
channelMap[id] = channelInfo;
|
|
154
|
+
}
|
|
155
|
+
channelInfo.layers.push(layer);
|
|
156
|
+
channelInfo.layerBounds.push(layer.getBounds());
|
|
157
|
+
}
|
|
158
|
+
for (let i = 0; i < 4; i++) {
|
|
159
|
+
const channelInfo = this.channels[i];
|
|
160
|
+
if (!channelInfo || !(channelInfo.id in channelMap)) {
|
|
161
|
+
// The mask id at this channel no longer exists
|
|
162
|
+
this.channels[i] = null;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
for (const maskId in channelMap) {
|
|
166
|
+
const channelInfo = channelMap[maskId];
|
|
167
|
+
if (channelInfo.index < 0) {
|
|
168
|
+
channelInfo.index = this.channels.findIndex(c => !c);
|
|
169
|
+
this.channels[channelInfo.index] = channelInfo;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return channelMap;
|
|
173
|
+
}
|
|
174
|
+
getModuleParameters() {
|
|
175
|
+
return {
|
|
176
|
+
maskMap: this.masks ? this.maskMap : this.dummyMaskMap,
|
|
177
|
+
maskChannels: this.masks
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
cleanup() {
|
|
181
|
+
if (this.dummyMaskMap) {
|
|
182
|
+
this.dummyMaskMap.delete();
|
|
183
|
+
this.dummyMaskMap = undefined;
|
|
184
|
+
}
|
|
185
|
+
if (this.maskPass) {
|
|
186
|
+
this.maskPass.delete();
|
|
187
|
+
this.maskPass = undefined;
|
|
188
|
+
this.maskMap = undefined;
|
|
189
|
+
}
|
|
190
|
+
this.lastViewport = undefined;
|
|
191
|
+
this.masks = null;
|
|
192
|
+
this.channels.length = 0;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { COORDINATE_SYSTEM, LayerExtension, log } from '@deck.gl/core';
|
|
2
|
+
import mask from "./shader-module.js";
|
|
3
|
+
import MaskEffect from "./mask-effect.js";
|
|
4
|
+
const defaultProps = {
|
|
5
|
+
maskId: '',
|
|
6
|
+
maskByInstance: undefined,
|
|
7
|
+
maskInverted: false
|
|
8
|
+
};
|
|
9
|
+
/** Allows layers to show/hide objects by a geofence. */
|
|
10
|
+
export default class MaskExtension extends LayerExtension {
|
|
11
|
+
static { this.defaultProps = defaultProps; }
|
|
12
|
+
static { this.extensionName = 'MaskExtension'; }
|
|
13
|
+
initializeState() {
|
|
14
|
+
this.context.deck?._addDefaultEffect(new MaskEffect());
|
|
15
|
+
}
|
|
16
|
+
getShaders() {
|
|
17
|
+
// Infer by geometry if 'maskByInstance' prop isn't explictly set
|
|
18
|
+
let maskByInstance = 'instancePositions' in this.getAttributeManager().attributes;
|
|
19
|
+
// Users can override by setting the `maskByInstance` prop
|
|
20
|
+
if (this.props.maskByInstance !== undefined) {
|
|
21
|
+
maskByInstance = Boolean(this.props.maskByInstance);
|
|
22
|
+
}
|
|
23
|
+
this.state.maskByInstance = maskByInstance;
|
|
24
|
+
return {
|
|
25
|
+
modules: [mask]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/* eslint-disable camelcase */
|
|
29
|
+
draw({ uniforms, context, moduleParameters }) {
|
|
30
|
+
uniforms.mask_maskByInstance = this.state.maskByInstance;
|
|
31
|
+
const { maskId, maskInverted } = this.props;
|
|
32
|
+
const { maskChannels } = moduleParameters;
|
|
33
|
+
const { viewport } = context;
|
|
34
|
+
if (maskChannels && maskChannels[maskId]) {
|
|
35
|
+
const { index, bounds, coordinateOrigin: fromCoordinateOrigin } = maskChannels[maskId];
|
|
36
|
+
let { coordinateSystem: fromCoordinateSystem } = maskChannels[maskId];
|
|
37
|
+
uniforms.mask_enabled = true;
|
|
38
|
+
uniforms.mask_channel = index;
|
|
39
|
+
uniforms.mask_inverted = maskInverted;
|
|
40
|
+
if (fromCoordinateSystem === COORDINATE_SYSTEM.DEFAULT) {
|
|
41
|
+
fromCoordinateSystem = viewport.isGeospatial
|
|
42
|
+
? COORDINATE_SYSTEM.LNGLAT
|
|
43
|
+
: COORDINATE_SYSTEM.CARTESIAN;
|
|
44
|
+
}
|
|
45
|
+
const opts = { modelMatrix: null, fromCoordinateOrigin, fromCoordinateSystem };
|
|
46
|
+
const bl = this.projectPosition([bounds[0], bounds[1], 0], opts);
|
|
47
|
+
const tr = this.projectPosition([bounds[2], bounds[3], 0], opts);
|
|
48
|
+
uniforms.mask_bounds = [bl[0], bl[1], tr[0], tr[1]];
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
if (maskId) {
|
|
52
|
+
log.warn(`Could not find a mask layer with id: ${maskId}`)();
|
|
53
|
+
}
|
|
54
|
+
uniforms.mask_enabled = false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mask-pass.d.ts","sourceRoot":"","sources":["../../src/mask/mask-pass.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"mask-pass.d.ts","sourceRoot":"","sources":["../../src/mask/mask-pass.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAC,WAAW,IAAI,UAAU,EAAE,uBAAuB,EAAC,MAAM,eAAe,CAAC;AAEjF,KAAK,qBAAqB,GAAG,uBAAuB,GAAG;IACrD,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,UAAU;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,WAAW,CAAC;gBAEL,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAC;IAyBjE,MAAM,CAAC,OAAO,EAAE,qBAAqB;IAiBrC,eAAe,CAAC,KAAK,KAAA;IAIrB,MAAM;CAIP"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { GL } from '@luma.gl/constants';
|
|
2
|
+
import { _LayersPass as LayersPass } from '@deck.gl/core';
|
|
3
|
+
export default class MaskPass extends LayersPass {
|
|
4
|
+
constructor(device, props) {
|
|
5
|
+
super(device, props);
|
|
6
|
+
const { mapSize = 2048 } = props;
|
|
7
|
+
this.maskMap = device.createTexture({
|
|
8
|
+
format: 'rgba8unorm',
|
|
9
|
+
width: mapSize,
|
|
10
|
+
height: mapSize,
|
|
11
|
+
sampler: {
|
|
12
|
+
minFilter: 'linear',
|
|
13
|
+
magFilter: 'linear',
|
|
14
|
+
addressModeU: 'clamp-to-edge',
|
|
15
|
+
addressModeV: 'clamp-to-edge'
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
this.fbo = device.createFramebuffer({
|
|
19
|
+
id: 'maskmap',
|
|
20
|
+
width: mapSize,
|
|
21
|
+
height: mapSize,
|
|
22
|
+
colorAttachments: [this.maskMap]
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
render(options) {
|
|
26
|
+
const colorMask = [false, false, false, false];
|
|
27
|
+
colorMask[options.channel] = true;
|
|
28
|
+
const clearColor = [255, 255, 255, 255];
|
|
29
|
+
return this.device.withParametersWebGL({
|
|
30
|
+
blend: true,
|
|
31
|
+
blendFunc: [0, 1],
|
|
32
|
+
blendEquation: 32778,
|
|
33
|
+
colorMask,
|
|
34
|
+
depthTest: false
|
|
35
|
+
}, () => super.render({ ...options, clearColor, target: this.fbo, pass: 'mask' }));
|
|
36
|
+
}
|
|
37
|
+
shouldDrawLayer(layer) {
|
|
38
|
+
return layer.props.operation.includes('mask');
|
|
39
|
+
}
|
|
40
|
+
delete() {
|
|
41
|
+
this.fbo.delete();
|
|
42
|
+
this.maskMap.delete();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/mask/shader-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"shader-module.d.ts","sourceRoot":"","sources":["../../src/mask/shader-module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AAqE3C,KAAK,kBAAkB,GAAG;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;;AAYF,wBAOsC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { project } from '@deck.gl/core';
|
|
2
|
+
import { glsl } from "../utils/syntax-tags.js";
|
|
3
|
+
const vs = `
|
|
4
|
+
uniform vec4 mask_bounds;
|
|
5
|
+
uniform bool mask_maskByInstance;
|
|
6
|
+
vec2 mask_getCoords(vec4 position) {
|
|
7
|
+
return (position.xy - mask_bounds.xy) / (mask_bounds.zw - mask_bounds.xy);
|
|
8
|
+
}
|
|
9
|
+
`;
|
|
10
|
+
const fs = `
|
|
11
|
+
uniform sampler2D mask_texture;
|
|
12
|
+
uniform int mask_channel;
|
|
13
|
+
uniform bool mask_enabled;
|
|
14
|
+
uniform bool mask_inverted;
|
|
15
|
+
bool mask_isInBounds(vec2 texCoords) {
|
|
16
|
+
if (!mask_enabled) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
vec4 maskColor = texture(mask_texture, texCoords);
|
|
20
|
+
float maskValue = 1.0;
|
|
21
|
+
if (mask_channel == 0) {
|
|
22
|
+
maskValue = maskColor.r;
|
|
23
|
+
} else if (mask_channel == 1) {
|
|
24
|
+
maskValue = maskColor.g;
|
|
25
|
+
} else if (mask_channel == 2) {
|
|
26
|
+
maskValue = maskColor.b;
|
|
27
|
+
} else if (mask_channel == 3) {
|
|
28
|
+
maskValue = maskColor.a;
|
|
29
|
+
}
|
|
30
|
+
if (mask_inverted) {
|
|
31
|
+
return maskValue >= 0.5;
|
|
32
|
+
} else {
|
|
33
|
+
return maskValue < 0.5;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
const inject = {
|
|
38
|
+
'vs:#decl': `
|
|
39
|
+
out vec2 mask_texCoords;
|
|
40
|
+
`,
|
|
41
|
+
'vs:#main-end': `
|
|
42
|
+
vec4 mask_common_position;
|
|
43
|
+
if (mask_maskByInstance) {
|
|
44
|
+
mask_common_position = project_position(vec4(geometry.worldPosition, 1.0));
|
|
45
|
+
} else {
|
|
46
|
+
mask_common_position = geometry.position;
|
|
47
|
+
}
|
|
48
|
+
mask_texCoords = mask_getCoords(mask_common_position);
|
|
49
|
+
`,
|
|
50
|
+
'fs:#decl': `
|
|
51
|
+
in vec2 mask_texCoords;
|
|
52
|
+
`,
|
|
53
|
+
'fs:#main-start': `
|
|
54
|
+
if (mask_enabled) {
|
|
55
|
+
bool mask = mask_isInBounds(mask_texCoords);
|
|
56
|
+
fragColor = texture(mask_texture, mask_texCoords);
|
|
57
|
+
if (!mask) discard;
|
|
58
|
+
}
|
|
59
|
+
`
|
|
60
|
+
};
|
|
61
|
+
/* eslint-disable camelcase */
|
|
62
|
+
const getMaskUniforms = (opts) => {
|
|
63
|
+
if (opts && 'maskMap' in opts) {
|
|
64
|
+
return {
|
|
65
|
+
mask_texture: opts.maskMap
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return {};
|
|
69
|
+
};
|
|
70
|
+
export default {
|
|
71
|
+
name: 'mask',
|
|
72
|
+
dependencies: [project],
|
|
73
|
+
vs,
|
|
74
|
+
fs,
|
|
75
|
+
inject,
|
|
76
|
+
getUniforms: getMaskUniforms
|
|
77
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
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 { vec3 } from '@math.gl/core';
|
|
22
|
+
import { dashShaders, offsetShaders } from "./shaders.glsl.js";
|
|
23
|
+
const defaultProps = {
|
|
24
|
+
getDashArray: { type: 'accessor', value: [0, 0] },
|
|
25
|
+
getOffset: { type: 'accessor', value: 0 },
|
|
26
|
+
dashJustified: false,
|
|
27
|
+
dashGapPickable: false
|
|
28
|
+
};
|
|
29
|
+
/** Adds selected features to the `PathLayer` and composite layers that render the `PathLayer`. */
|
|
30
|
+
export default class PathStyleExtension extends LayerExtension {
|
|
31
|
+
static { this.defaultProps = defaultProps; }
|
|
32
|
+
static { this.extensionName = 'PathStyleExtension'; }
|
|
33
|
+
constructor({ dash = false, offset = false, highPrecisionDash = false } = {}) {
|
|
34
|
+
super({ dash: dash || highPrecisionDash, offset, highPrecisionDash });
|
|
35
|
+
}
|
|
36
|
+
isEnabled(layer) {
|
|
37
|
+
return 'pathTesselator' in layer.state;
|
|
38
|
+
}
|
|
39
|
+
getShaders(extension) {
|
|
40
|
+
if (!extension.isEnabled(this)) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
// Merge shader injection
|
|
44
|
+
let result = {};
|
|
45
|
+
if (extension.opts.dash) {
|
|
46
|
+
result = mergeShaders(result, dashShaders);
|
|
47
|
+
}
|
|
48
|
+
if (extension.opts.offset) {
|
|
49
|
+
result = mergeShaders(result, offsetShaders);
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
initializeState(context, extension) {
|
|
54
|
+
const attributeManager = this.getAttributeManager();
|
|
55
|
+
if (!attributeManager || !extension.isEnabled(this)) {
|
|
56
|
+
// This extension only works with the PathLayer
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (extension.opts.dash) {
|
|
60
|
+
attributeManager.addInstanced({
|
|
61
|
+
instanceDashArrays: { size: 2, accessor: 'getDashArray' },
|
|
62
|
+
instanceDashOffsets: extension.opts.highPrecisionDash
|
|
63
|
+
? {
|
|
64
|
+
size: 1,
|
|
65
|
+
accessor: 'getPath',
|
|
66
|
+
transform: extension.getDashOffsets.bind(this)
|
|
67
|
+
}
|
|
68
|
+
: {
|
|
69
|
+
size: 1,
|
|
70
|
+
update: attribute => {
|
|
71
|
+
attribute.constant = true;
|
|
72
|
+
attribute.value = [0];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
if (extension.opts.offset) {
|
|
78
|
+
attributeManager.addInstanced({
|
|
79
|
+
instanceOffsets: { size: 1, accessor: 'getOffset' }
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
updateState(params, extension) {
|
|
84
|
+
if (!extension.isEnabled(this)) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const uniforms = {};
|
|
88
|
+
if (extension.opts.dash) {
|
|
89
|
+
uniforms.dashAlignMode = this.props.dashJustified ? 1 : 0;
|
|
90
|
+
uniforms.dashGapPickable = Boolean(this.props.dashGapPickable);
|
|
91
|
+
}
|
|
92
|
+
this.state.model?.setUniforms(uniforms);
|
|
93
|
+
}
|
|
94
|
+
getDashOffsets(path) {
|
|
95
|
+
const result = [0];
|
|
96
|
+
const positionSize = this.props.positionFormat === 'XY' ? 2 : 3;
|
|
97
|
+
const isNested = Array.isArray(path[0]);
|
|
98
|
+
const geometrySize = isNested ? path.length : path.length / positionSize;
|
|
99
|
+
let p;
|
|
100
|
+
let prevP;
|
|
101
|
+
for (let i = 0; i < geometrySize - 1; i++) {
|
|
102
|
+
p = isNested ? path[i] : path.slice(i * positionSize, i * positionSize + positionSize);
|
|
103
|
+
p = this.projectPosition(p);
|
|
104
|
+
if (i > 0) {
|
|
105
|
+
result[i] = result[i - 1] + vec3.dist(prevP, p);
|
|
106
|
+
}
|
|
107
|
+
prevP = p;
|
|
108
|
+
}
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export const dashShaders = {
|
|
2
|
+
inject: {
|
|
3
|
+
'vs:#decl': `
|
|
4
|
+
in vec2 instanceDashArrays;
|
|
5
|
+
in float instanceDashOffsets;
|
|
6
|
+
out vec2 vDashArray;
|
|
7
|
+
out 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
|
+
in vec2 vDashArray;
|
|
18
|
+
in float vDashOffset;
|
|
19
|
+
`,
|
|
20
|
+
// if given position is in the gap part of the dashed line
|
|
21
|
+
// dashArray.x: solid stroke length, relative to width
|
|
22
|
+
// dashArray.y: gap length, relative to width
|
|
23
|
+
// alignMode:
|
|
24
|
+
// 0 - no adjustment
|
|
25
|
+
// o---- ---- ---- ---- o---- -o---- ---- o
|
|
26
|
+
// 1 - stretch to fit, draw half dash at each end for nicer joints
|
|
27
|
+
// o-- ---- ---- ---- --o-- --o-- ---- --o
|
|
28
|
+
'fs:#main-start': `
|
|
29
|
+
float solidLength = vDashArray.x;
|
|
30
|
+
float gapLength = vDashArray.y;
|
|
31
|
+
float unitLength = solidLength + gapLength;
|
|
32
|
+
float offset;
|
|
33
|
+
if (unitLength > 0.0) {
|
|
34
|
+
if (dashAlignMode == 0.0) {
|
|
35
|
+
offset = vDashOffset;
|
|
36
|
+
} else {
|
|
37
|
+
unitLength = vPathLength / round(vPathLength / unitLength);
|
|
38
|
+
offset = solidLength / 2.0;
|
|
39
|
+
}
|
|
40
|
+
float unitOffset = mod(vPathPosition.y + offset, unitLength);
|
|
41
|
+
if (gapLength > 0.0 && unitOffset > solidLength) {
|
|
42
|
+
if (capType <= 0.5) {
|
|
43
|
+
if (!(dashGapPickable && bool(picking.isActive))) {
|
|
44
|
+
discard;
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
float distToEnd = length(vec2(
|
|
48
|
+
min(unitOffset - solidLength, unitLength - unitOffset),
|
|
49
|
+
vPathPosition.x
|
|
50
|
+
));
|
|
51
|
+
if (distToEnd > 1.0) {
|
|
52
|
+
if (!(dashGapPickable && bool(picking.isActive))) {
|
|
53
|
+
discard;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
`
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
export const offsetShaders = {
|
|
63
|
+
inject: {
|
|
64
|
+
'vs:#decl': `
|
|
65
|
+
in float instanceOffsets;
|
|
66
|
+
`,
|
|
67
|
+
'vs:DECKGL_FILTER_SIZE': `
|
|
68
|
+
float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;
|
|
69
|
+
size *= offsetWidth;
|
|
70
|
+
`,
|
|
71
|
+
'vs:#main-end': `
|
|
72
|
+
float offsetWidth = abs(instanceOffsets * 2.0) + 1.0;
|
|
73
|
+
float offsetDir = sign(instanceOffsets);
|
|
74
|
+
vPathPosition.x = (vPathPosition.x + offsetDir) * offsetWidth - offsetDir;
|
|
75
|
+
vPathPosition.y *= offsetWidth;
|
|
76
|
+
vPathLength *= offsetWidth;
|
|
77
|
+
`,
|
|
78
|
+
'fs:#main-start': `
|
|
79
|
+
float isInside;
|
|
80
|
+
isInside = step(-1.0, vPathPosition.x) * step(vPathPosition.x, 1.0);
|
|
81
|
+
if (isInside == 0.0) {
|
|
82
|
+
discard;
|
|
83
|
+
}
|
|
84
|
+
`
|
|
85
|
+
}
|
|
86
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Device, Framebuffer } from '@luma.gl/core';
|
|
2
|
-
import { Bounds } from
|
|
2
|
+
import { Bounds } from "../utils/projection-utils.js";
|
|
3
3
|
import type { Viewport, Layer } from '@deck.gl/core';
|
|
4
4
|
/**
|
|
5
5
|
* Manages the lifecycle of the height map (a framebuffer that encodes elevation).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"height-map-builder.d.ts","sourceRoot":"","sources":["../../src/terrain/height-map-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,EAAiD,MAAM,EAAC,qCAAkC;AAGjG,OAAO,KAAK,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,eAAe,CAAC;AAInD;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAC3B,6CAA6C;IAC7C,cAAc,EAAE,QAAQ,GAAG,IAAI,CAAQ;IACvC,2DAA2D;IAC3D,MAAM,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE7B,SAAS,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC;IAC5B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,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,MAAM,EAAE,MAAM,GAAG,OAAO;gBAI/B,MAAM,EAAE,MAAM;IAI1B;;OAEG;IACH,oBAAoB,IAAI,WAAW,GAAG,IAAI;IAU1C,yEAAyE;IACzE,YAAY,CAAC,EAAC,MAAM,EAAE,QAAQ,EAAC,EAAE;QAAC,MAAM,EAAE,KAAK,EAAE,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAA;KAAC,GAAG,OAAO;IAiEhF,MAAM;CAMP"}
|