@deck.gl/extensions 8.10.0-alpha.7 → 9.0.0-alpha.3
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 +10098 -620
- package/dist/es5/brushing/brushing-extension.js +8 -5
- package/dist/es5/brushing/brushing-extension.js.map +1 -1
- package/dist/es5/clip/clip-extension.js.map +1 -1
- package/dist/es5/collision-filter/collision-filter-effect.js +41 -29
- package/dist/es5/collision-filter/collision-filter-effect.js.map +1 -1
- package/dist/es5/collision-filter/collision-filter-pass.js +4 -5
- package/dist/es5/collision-filter/collision-filter-pass.js.map +1 -1
- package/dist/es5/collision-filter/shader-module.js.map +1 -1
- package/dist/es5/data-filter/aggregator.js +18 -11
- package/dist/es5/data-filter/aggregator.js.map +1 -1
- package/dist/es5/data-filter/data-filter-extension.js +27 -27
- package/dist/es5/data-filter/data-filter-extension.js.map +1 -1
- package/dist/es5/fill-style/fill-style-extension.js +4 -6
- package/dist/es5/fill-style/fill-style-extension.js.map +1 -1
- package/dist/es5/fill-style/shaders.glsl.js.map +1 -1
- package/dist/es5/mask/mask-effect.js +5 -7
- package/dist/es5/mask/mask-effect.js.map +1 -1
- package/dist/es5/mask/mask-pass.js +18 -13
- package/dist/es5/mask/mask-pass.js.map +1 -1
- package/dist/es5/mask/shader-module.js.map +1 -1
- package/dist/es5/path-style/path-style-extension.js +11 -8
- package/dist/es5/path-style/path-style-extension.js.map +1 -1
- package/dist/es5/terrain/height-map-builder.js +7 -11
- package/dist/es5/terrain/height-map-builder.js.map +1 -1
- package/dist/es5/terrain/shader-module.js.map +1 -1
- package/dist/es5/terrain/terrain-cover.js +6 -6
- package/dist/es5/terrain/terrain-cover.js.map +1 -1
- package/dist/es5/terrain/terrain-effect.js +11 -13
- package/dist/es5/terrain/terrain-effect.js.map +1 -1
- package/dist/es5/terrain/terrain-pass.js +7 -5
- package/dist/es5/terrain/terrain-pass.js.map +1 -1
- package/dist/es5/terrain/terrain-picking-pass.js +2 -2
- package/dist/es5/terrain/terrain-picking-pass.js.map +1 -1
- package/dist/es5/terrain/utils.js +12 -9
- package/dist/es5/terrain/utils.js.map +1 -1
- package/dist/es5/utils/debug.js +2 -2
- package/dist/es5/utils/debug.js.map +1 -1
- package/dist/esm/brushing/brushing-extension.js +8 -5
- package/dist/esm/brushing/brushing-extension.js.map +1 -1
- package/dist/esm/clip/clip-extension.js.map +1 -1
- package/dist/esm/collision-filter/collision-filter-effect.js +29 -28
- package/dist/esm/collision-filter/collision-filter-effect.js.map +1 -1
- package/dist/esm/collision-filter/collision-filter-pass.js +2 -3
- package/dist/esm/collision-filter/collision-filter-pass.js.map +1 -1
- package/dist/esm/collision-filter/shader-module.js.map +1 -1
- package/dist/esm/data-filter/aggregator.js +19 -15
- package/dist/esm/data-filter/aggregator.js.map +1 -1
- package/dist/esm/data-filter/data-filter-extension.js +23 -30
- package/dist/esm/data-filter/data-filter-extension.js.map +1 -1
- package/dist/esm/fill-style/fill-style-extension.js +3 -6
- package/dist/esm/fill-style/fill-style-extension.js.map +1 -1
- package/dist/esm/fill-style/shaders.glsl.js.map +1 -1
- package/dist/esm/mask/mask-effect.js +3 -4
- package/dist/esm/mask/mask-effect.js.map +1 -1
- package/dist/esm/mask/mask-pass.js +14 -15
- package/dist/esm/mask/mask-pass.js.map +1 -1
- package/dist/esm/mask/shader-module.js.map +1 -1
- package/dist/esm/path-style/path-style-extension.js +11 -8
- package/dist/esm/path-style/path-style-extension.js.map +1 -1
- package/dist/esm/terrain/height-map-builder.js +7 -10
- package/dist/esm/terrain/height-map-builder.js.map +1 -1
- package/dist/esm/terrain/shader-module.js.map +1 -1
- package/dist/esm/terrain/terrain-cover.js +6 -6
- package/dist/esm/terrain/terrain-cover.js.map +1 -1
- package/dist/esm/terrain/terrain-effect.js +10 -11
- package/dist/esm/terrain/terrain-effect.js.map +1 -1
- package/dist/esm/terrain/terrain-pass.js +4 -3
- package/dist/esm/terrain/terrain-pass.js.map +1 -1
- package/dist/esm/terrain/terrain-picking-pass.js +2 -2
- package/dist/esm/terrain/terrain-picking-pass.js.map +1 -1
- package/dist/esm/terrain/utils.js +15 -17
- package/dist/esm/terrain/utils.js.map +1 -1
- package/dist/esm/utils/debug.js +1 -1
- package/dist/esm/utils/debug.js.map +1 -1
- package/dist.min.js +282 -84
- package/package.json +8 -5
- package/src/brushing/brushing-extension.ts +8 -6
- package/src/clip/clip-extension.ts +1 -2
- package/src/collision-filter/collision-filter-effect.ts +40 -29
- package/src/collision-filter/collision-filter-pass.ts +4 -5
- package/src/collision-filter/shader-module.ts +4 -3
- package/src/data-filter/aggregator.ts +18 -18
- package/src/data-filter/data-filter-extension.ts +37 -29
- package/src/fill-style/fill-style-extension.ts +6 -7
- package/src/fill-style/shaders.glsl.ts +2 -2
- package/src/mask/mask-effect.ts +11 -10
- package/src/mask/mask-pass.ts +19 -20
- package/src/mask/shader-module.ts +2 -2
- package/src/path-style/path-style-extension.ts +16 -11
- package/src/terrain/height-map-builder.ts +8 -8
- package/src/terrain/shader-module.ts +8 -6
- package/src/terrain/terrain-cover.ts +8 -6
- package/src/terrain/terrain-effect.ts +14 -13
- package/src/terrain/terrain-pass.ts +6 -7
- package/src/terrain/terrain-picking-pass.ts +3 -3
- package/src/terrain/utils.ts +13 -13
- package/src/utils/debug.ts +2 -1
- package/typed/brushing/brushing-extension.d.ts.map +1 -1
- package/typed/clip/clip-extension.d.ts.map +1 -1
- package/typed/collision-filter/collision-filter-effect.d.ts +4 -4
- package/typed/collision-filter/collision-filter-effect.d.ts.map +1 -1
- package/typed/collision-filter/collision-filter-pass.d.ts.map +1 -1
- package/typed/collision-filter/shader-module.d.ts.map +1 -1
- package/typed/data-filter/aggregator.d.ts +10 -8
- package/typed/data-filter/aggregator.d.ts.map +1 -1
- package/typed/data-filter/data-filter-extension.d.ts +1 -1
- package/typed/data-filter/data-filter-extension.d.ts.map +1 -1
- package/typed/fill-style/fill-style-extension.d.ts +3 -3
- package/typed/fill-style/fill-style-extension.d.ts.map +1 -1
- package/typed/fill-style/shaders.glsl.d.ts +2 -2
- package/typed/fill-style/shaders.glsl.d.ts.map +1 -1
- package/typed/mask/mask-effect.d.ts +3 -3
- package/typed/mask/mask-effect.d.ts.map +1 -1
- package/typed/mask/mask-pass.d.ts +3 -3
- package/typed/mask/mask-pass.d.ts.map +1 -1
- package/typed/mask/shader-module.d.ts +2 -2
- package/typed/mask/shader-module.d.ts.map +1 -1
- package/typed/path-style/path-style-extension.d.ts.map +1 -1
- package/typed/terrain/height-map-builder.d.ts +4 -4
- package/typed/terrain/height-map-builder.d.ts.map +1 -1
- package/typed/terrain/shader-module.d.ts +3 -3
- package/typed/terrain/shader-module.d.ts.map +1 -1
- package/typed/terrain/terrain-cover.d.ts.map +1 -1
- package/typed/terrain/terrain-effect.d.ts +4 -3
- package/typed/terrain/terrain-effect.d.ts.map +1 -1
- package/typed/terrain/terrain-pass.d.ts.map +1 -1
- package/typed/terrain/utils.d.ts +3 -2
- package/typed/terrain/utils.d.ts.map +1 -1
- package/typed/utils/debug.d.ts +1 -0
- package/typed/utils/debug.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@deck.gl/extensions",
|
|
3
3
|
"description": "Plug-and-play functionalities for deck.gl layers",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "9.0.0-alpha.3",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
@@ -31,14 +31,17 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.0.0",
|
|
34
|
-
"@luma.gl/shadertools": "
|
|
34
|
+
"@luma.gl/shadertools": "9.0.0-alpha.42"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@deck.gl/core": "^8.0.0",
|
|
38
|
-
"@luma.gl/constants": "
|
|
39
|
-
"@luma.gl/core": "
|
|
38
|
+
"@luma.gl/constants": "9.0.0-alpha.42",
|
|
39
|
+
"@luma.gl/core": "9.0.0-alpha.42",
|
|
40
|
+
"@luma.gl/engine": "9.0.0-alpha.42",
|
|
41
|
+
"@luma.gl/shadertools": "9.0.0-alpha.42",
|
|
42
|
+
"@luma.gl/webgl": "9.0.0-alpha.42",
|
|
40
43
|
"@math.gl/core": "^4.0.0",
|
|
41
44
|
"@math.gl/web-mercator": "^4.0.0"
|
|
42
45
|
},
|
|
43
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "51dfb88f9168ccf478d01b28a2c5ada7bd8281c7"
|
|
44
47
|
}
|
|
@@ -83,15 +83,16 @@ export default class BrushingExtension extends LayerExtension {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// Trigger redraw when mouse moves
|
|
86
|
-
|
|
87
|
-
this.state.onMouseMove = () => {
|
|
86
|
+
const onMouseMove = () => {
|
|
88
87
|
this.getCurrentLayer()?.setNeedsRedraw();
|
|
89
88
|
};
|
|
89
|
+
// TODO - expose this in a better way
|
|
90
|
+
this.state.onMouseMove = onMouseMove;
|
|
90
91
|
if (context.deck) {
|
|
91
92
|
// @ts-expect-error (2446) accessing protected property
|
|
92
93
|
context.deck.eventManager.on({
|
|
93
|
-
pointermove:
|
|
94
|
-
pointerleave:
|
|
94
|
+
pointermove: onMouseMove,
|
|
95
|
+
pointerleave: onMouseMove
|
|
95
96
|
});
|
|
96
97
|
}
|
|
97
98
|
}
|
|
@@ -99,10 +100,11 @@ export default class BrushingExtension extends LayerExtension {
|
|
|
99
100
|
finalizeState(this: Layer<BrushingExtensionProps>, context: LayerContext, extension: this) {
|
|
100
101
|
// Remove event listeners
|
|
101
102
|
if (context.deck) {
|
|
103
|
+
const onMouseMove = this.state.onMouseMove as () => void;
|
|
102
104
|
// @ts-expect-error (2446) accessing protected property
|
|
103
105
|
context.deck.eventManager.off({
|
|
104
|
-
pointermove:
|
|
105
|
-
pointerleave:
|
|
106
|
+
pointermove: onMouseMove,
|
|
107
|
+
pointerleave: onMouseMove
|
|
106
108
|
});
|
|
107
109
|
}
|
|
108
110
|
}
|
|
@@ -105,8 +105,7 @@ export default class ClipExtension extends LayerExtension {
|
|
|
105
105
|
// Otherwise, the object is trimmed by the clip bounds (done by fragment shader)
|
|
106
106
|
|
|
107
107
|
// Default behavior: consider a layer instanced if it has attribute `instancePositions`
|
|
108
|
-
|
|
109
|
-
let clipByInstance = 'instancePositions' in this.getAttributeManager().attributes;
|
|
108
|
+
let clipByInstance = 'instancePositions' in this.getAttributeManager()!.attributes;
|
|
110
109
|
// Users can override by setting the `clipByInstance` prop
|
|
111
110
|
if (this.props.clipByInstance !== undefined) {
|
|
112
111
|
clipByInstance = Boolean(this.props.clipByInstance);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Device, Framebuffer, Texture} from '@luma.gl/core';
|
|
2
|
+
import {WEBGLRenderbuffer} from '@luma.gl/webgl';
|
|
2
3
|
import {equals} from '@math.gl/core';
|
|
3
4
|
import {_deepEqual as deepEqual} from '@deck.gl/core';
|
|
4
5
|
import type {Effect, Layer, PreRenderOptions, Viewport} from '@deck.gl/core';
|
|
@@ -30,11 +31,11 @@ export default class CollisionFilterEffect implements Effect {
|
|
|
30
31
|
private channels: Record<string, RenderInfo> = {};
|
|
31
32
|
private collisionFilterPass?: CollisionFilterPass;
|
|
32
33
|
private collisionFBOs: Record<string, Framebuffer> = {};
|
|
33
|
-
private dummyCollisionMap?:
|
|
34
|
+
private dummyCollisionMap?: Texture;
|
|
34
35
|
private lastViewport?: Viewport;
|
|
35
36
|
|
|
36
37
|
preRender(
|
|
37
|
-
|
|
38
|
+
device: Device,
|
|
38
39
|
{
|
|
39
40
|
effects: allEffects,
|
|
40
41
|
layers,
|
|
@@ -47,7 +48,7 @@ export default class CollisionFilterEffect implements Effect {
|
|
|
47
48
|
}: PreRenderOptions
|
|
48
49
|
): void {
|
|
49
50
|
if (!this.dummyCollisionMap) {
|
|
50
|
-
this.dummyCollisionMap =
|
|
51
|
+
this.dummyCollisionMap = device.createTexture({width: 1, height: 1});
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
if (isPicking) {
|
|
@@ -65,7 +66,7 @@ export default class CollisionFilterEffect implements Effect {
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
if (!this.collisionFilterPass) {
|
|
68
|
-
this.collisionFilterPass = new CollisionFilterPass(
|
|
69
|
+
this.collisionFilterPass = new CollisionFilterPass(device, {id: 'default-collision-filter'});
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
// Detect if mask has rendered. TODO: better dependency system for Effects
|
|
@@ -73,7 +74,7 @@ export default class CollisionFilterEffect implements Effect {
|
|
|
73
74
|
const maskEffectRendered = (preRenderStats['mask-effect'] as MaskPreRenderStats)?.didRender;
|
|
74
75
|
|
|
75
76
|
// Collect layers to render
|
|
76
|
-
const channels = this._groupByCollisionGroup(
|
|
77
|
+
const channels = this._groupByCollisionGroup(device, collisionLayers);
|
|
77
78
|
|
|
78
79
|
const viewport = viewports[0];
|
|
79
80
|
const viewportChanged =
|
|
@@ -83,9 +84,11 @@ export default class CollisionFilterEffect implements Effect {
|
|
|
83
84
|
for (const collisionGroup in channels) {
|
|
84
85
|
const collisionFBO = this.collisionFBOs[collisionGroup];
|
|
85
86
|
const renderInfo = channels[collisionGroup];
|
|
87
|
+
// @ts-expect-error TODO - assuming WebGL context
|
|
88
|
+
const [width, height] = device.canvasContext.getPixelSize();
|
|
86
89
|
collisionFBO.resize({
|
|
87
|
-
width:
|
|
88
|
-
height:
|
|
90
|
+
width: width / DOWNSCALE,
|
|
91
|
+
height: height / DOWNSCALE
|
|
89
92
|
});
|
|
90
93
|
this._render(renderInfo, {
|
|
91
94
|
effects,
|
|
@@ -156,7 +159,8 @@ export default class CollisionFilterEffect implements Effect {
|
|
|
156
159
|
moduleParameters: {
|
|
157
160
|
// To avoid feedback loop forming between Framebuffer and active Texture.
|
|
158
161
|
dummyCollisionMap: this.dummyCollisionMap,
|
|
159
|
-
|
|
162
|
+
// @ts-expect-error TODO - assuming WebGL context
|
|
163
|
+
devicePixelRatio: collisionFBO.device.canvasContext.getDevicePixelRatio() / DOWNSCALE
|
|
160
164
|
}
|
|
161
165
|
});
|
|
162
166
|
}
|
|
@@ -167,7 +171,7 @@ export default class CollisionFilterEffect implements Effect {
|
|
|
167
171
|
* Returns a map from collisionGroup to render info
|
|
168
172
|
*/
|
|
169
173
|
private _groupByCollisionGroup(
|
|
170
|
-
|
|
174
|
+
device: Device,
|
|
171
175
|
collisionLayers: Layer<CollisionFilterExtensionProps>[]
|
|
172
176
|
): Record<string, RenderInfo> {
|
|
173
177
|
const channelMap = {};
|
|
@@ -188,7 +192,7 @@ export default class CollisionFilterEffect implements Effect {
|
|
|
188
192
|
// Create any new passes and remove any old ones
|
|
189
193
|
for (const collisionGroup of Object.keys(channelMap)) {
|
|
190
194
|
if (!this.collisionFBOs[collisionGroup]) {
|
|
191
|
-
this.createFBO(
|
|
195
|
+
this.createFBO(device, collisionGroup);
|
|
192
196
|
}
|
|
193
197
|
if (!this.channels[collisionGroup]) {
|
|
194
198
|
this.channels[collisionGroup] = channelMap[collisionGroup];
|
|
@@ -205,11 +209,11 @@ export default class CollisionFilterEffect implements Effect {
|
|
|
205
209
|
|
|
206
210
|
getModuleParameters(layer: Layer): {
|
|
207
211
|
collisionFBO: Framebuffer;
|
|
208
|
-
dummyCollisionMap:
|
|
212
|
+
dummyCollisionMap: Texture;
|
|
209
213
|
} {
|
|
210
214
|
const {collisionGroup} = (layer as Layer<CollisionFilterExtensionProps>).props;
|
|
211
215
|
const {collisionFBOs, dummyCollisionMap} = this;
|
|
212
|
-
return {collisionFBO: collisionFBOs[collisionGroup], dummyCollisionMap};
|
|
216
|
+
return {collisionFBO: collisionFBOs[collisionGroup], dummyCollisionMap: dummyCollisionMap!};
|
|
213
217
|
}
|
|
214
218
|
|
|
215
219
|
cleanup(): void {
|
|
@@ -225,34 +229,41 @@ export default class CollisionFilterEffect implements Effect {
|
|
|
225
229
|
this.lastViewport = undefined;
|
|
226
230
|
}
|
|
227
231
|
|
|
228
|
-
createFBO(
|
|
229
|
-
|
|
230
|
-
const
|
|
232
|
+
createFBO(device: Device, collisionGroup: string) {
|
|
233
|
+
// @ts-expect-error
|
|
234
|
+
const {width, height} = device.gl.canvas;
|
|
235
|
+
const collisionMap = device.createTexture({
|
|
236
|
+
format: 'rgba8unorm',
|
|
231
237
|
width,
|
|
232
238
|
height,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
239
|
+
sampler: {
|
|
240
|
+
minFilter: 'nearest',
|
|
241
|
+
magFilter: 'nearest',
|
|
242
|
+
addressModeU: 'clamp-to-edge',
|
|
243
|
+
addressModeV: 'clamp-to-edge'
|
|
238
244
|
}
|
|
239
245
|
});
|
|
240
246
|
|
|
241
|
-
const depthBuffer = new
|
|
242
|
-
|
|
243
|
-
|
|
247
|
+
const depthBuffer = new WEBGLRenderbuffer(
|
|
248
|
+
// @ts-expect-error TODO v9 needs to be WebGLDevice
|
|
249
|
+
device,
|
|
250
|
+
{format: 'depth16', width, height}
|
|
251
|
+
);
|
|
252
|
+
this.collisionFBOs[collisionGroup] = device.createFramebuffer({
|
|
253
|
+
id: `collision-${collisionGroup}`,
|
|
244
254
|
width,
|
|
245
255
|
height,
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
256
|
+
colorAttachments: [collisionMap],
|
|
257
|
+
// @ts-expect-error TODO v9 doesn't handle renderbuffers well
|
|
258
|
+
depthStencilAttachment: depthBuffer
|
|
250
259
|
});
|
|
251
260
|
}
|
|
252
261
|
|
|
253
262
|
destroyFBO(collisionGroup: string) {
|
|
254
263
|
const fbo = this.collisionFBOs[collisionGroup];
|
|
255
|
-
|
|
264
|
+
// @ts-expect-error
|
|
265
|
+
const attachments = fbo.attachments as Texture[];
|
|
266
|
+
for (const attachment of Object.values(attachments)) {
|
|
256
267
|
attachment.delete();
|
|
257
268
|
}
|
|
258
269
|
fbo.delete();
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {Framebuffer
|
|
1
|
+
import {Framebuffer} from '@luma.gl/core';
|
|
2
|
+
import {withGLParameters} from '@luma.gl/webgl';
|
|
2
3
|
import {_LayersPass as LayersPass, LayersPassRenderOptions} from '@deck.gl/core';
|
|
3
4
|
|
|
4
5
|
type CollisionFilterPassRenderOptions = LayersPassRenderOptions & {};
|
|
5
6
|
|
|
6
7
|
export default class CollisionFilterPass extends LayersPass {
|
|
7
8
|
renderCollisionMap(target: Framebuffer, options: CollisionFilterPassRenderOptions) {
|
|
8
|
-
const gl = this.gl;
|
|
9
|
-
|
|
10
9
|
const padding = 1;
|
|
11
10
|
|
|
12
|
-
return
|
|
13
|
-
|
|
11
|
+
return withGLParameters(
|
|
12
|
+
this.device,
|
|
14
13
|
{
|
|
15
14
|
scissorTest: true,
|
|
16
15
|
scissor: [padding, padding, target.width - 2 * padding, target.height - 2 * padding],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Framebuffer,
|
|
1
|
+
import {Framebuffer, Texture} from '@luma.gl/core';
|
|
2
2
|
import {project} from '@deck.gl/core';
|
|
3
3
|
import type {_ShaderModule as ShaderModule} from '@deck.gl/core';
|
|
4
4
|
|
|
@@ -85,11 +85,11 @@ const inject = {
|
|
|
85
85
|
type CollisionModuleSettings = {
|
|
86
86
|
collisionFBO?: Framebuffer;
|
|
87
87
|
drawToCollisionMap?: boolean;
|
|
88
|
-
dummyCollisionMap?:
|
|
88
|
+
dummyCollisionMap?: Texture;
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
/* eslint-disable camelcase */
|
|
92
|
-
type CollisionUniforms = {collision_sort?: boolean; collision_texture?: Framebuffer |
|
|
92
|
+
type CollisionUniforms = {collision_sort?: boolean; collision_texture?: Framebuffer | Texture};
|
|
93
93
|
|
|
94
94
|
const getCollisionUniforms = (
|
|
95
95
|
opts: CollisionModuleSettings | {},
|
|
@@ -105,6 +105,7 @@ const getCollisionUniforms = (
|
|
|
105
105
|
};
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
+
// @ts-expect-error
|
|
108
109
|
export default {
|
|
109
110
|
name: 'collision',
|
|
110
111
|
dependencies: [project],
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import {Device, Framebuffer} from '@luma.gl/core';
|
|
2
|
+
import {Model} from '@luma.gl/engine';
|
|
3
|
+
import {GL} from '@luma.gl/constants';
|
|
3
4
|
|
|
4
5
|
const AGGREGATE_VS = `\
|
|
5
6
|
#define SHADER_NAME data-filter-vertex-shader
|
|
@@ -48,7 +49,10 @@ void main() {
|
|
|
48
49
|
}
|
|
49
50
|
`;
|
|
50
51
|
|
|
51
|
-
export function supportsFloatTarget(
|
|
52
|
+
export function supportsFloatTarget(device: Device): boolean {
|
|
53
|
+
// @ts-expect-error
|
|
54
|
+
const gl = device.gl;
|
|
55
|
+
|
|
52
56
|
// https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices#Support_for_float_textures_doesnt_mean_you_can_render_into_them!
|
|
53
57
|
return Boolean(
|
|
54
58
|
gl.getExtension('EXT_float_blend') &&
|
|
@@ -60,39 +64,35 @@ export function supportsFloatTarget(gl: WebGLRenderingContext): boolean {
|
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
// A 1x1 framebuffer object that encodes the total count of filtered items
|
|
63
|
-
export function getFramebuffer(
|
|
67
|
+
export function getFramebuffer(device: Device, useFloatTarget: boolean): Framebuffer {
|
|
64
68
|
if (useFloatTarget) {
|
|
65
|
-
return
|
|
69
|
+
return device.createFramebuffer({
|
|
66
70
|
width: 1,
|
|
67
71
|
height: 1,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
format:
|
|
72
|
+
colorAttachments: [
|
|
73
|
+
device.createTexture({
|
|
74
|
+
format: device.info.type === 'webgl2' ? 'rgba32float' : 'rgba8unorm',
|
|
71
75
|
type: GL.FLOAT,
|
|
72
76
|
mipmaps: false
|
|
73
77
|
})
|
|
74
|
-
|
|
78
|
+
]
|
|
75
79
|
});
|
|
76
80
|
}
|
|
77
|
-
return
|
|
81
|
+
return device.createFramebuffer({
|
|
78
82
|
width: 256,
|
|
79
83
|
height: 64,
|
|
80
|
-
|
|
84
|
+
colorAttachments: [device.createTexture({format: 'rgba8unorm', type: GL.FLOAT, mipmaps: false})]
|
|
81
85
|
});
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
// Increments the counter based on dataFilter_value
|
|
85
|
-
export function getModel(
|
|
86
|
-
gl: WebGLRenderingContext,
|
|
87
|
-
shaderOptions: any,
|
|
88
|
-
useFloatTarget: boolean
|
|
89
|
-
): Model {
|
|
89
|
+
export function getModel(device: Device, shaderOptions: any, useFloatTarget: boolean): Model {
|
|
90
90
|
shaderOptions.defines.NON_INSTANCED_MODEL = 1;
|
|
91
91
|
if (useFloatTarget) {
|
|
92
92
|
shaderOptions.defines.FLOAT_TARGET = 1;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
return new Model(
|
|
95
|
+
return new Model(device, {
|
|
96
96
|
id: 'data-filter-aggregation-model',
|
|
97
97
|
vertexCount: 1,
|
|
98
98
|
isInstanced: false,
|
|
@@ -108,4 +108,4 @@ export const parameters = {
|
|
|
108
108
|
blendFunc: [GL.ONE, GL.ONE, GL.ONE, GL.ONE],
|
|
109
109
|
blendEquation: [GL.FUNC_ADD, GL.FUNC_ADD],
|
|
110
110
|
depthTest: false
|
|
111
|
-
};
|
|
111
|
+
} as const;
|
|
@@ -18,13 +18,14 @@
|
|
|
18
18
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
19
|
// THE SOFTWARE.
|
|
20
20
|
|
|
21
|
+
import {readPixelsToArray, clear, withGLParameters} from '@luma.gl/webgl';
|
|
22
|
+
import {GL} from '@luma.gl/constants';
|
|
23
|
+
import type {Framebuffer} from '@luma.gl/core';
|
|
24
|
+
import type {Model} from '@luma.gl/engine';
|
|
25
|
+
import type {Layer, LayerContext, Accessor, UpdateParameters} from '@deck.gl/core';
|
|
21
26
|
import {LayerExtension} from '@deck.gl/core';
|
|
22
27
|
import {shaderModule, shaderModule64} from './shader-module';
|
|
23
28
|
import * as aggregator from './aggregator';
|
|
24
|
-
import {readPixelsToArray, clear} from '@luma.gl/core';
|
|
25
|
-
import GL from '@luma.gl/constants';
|
|
26
|
-
|
|
27
|
-
import type {Layer, LayerContext, Accessor, UpdateParameters} from '@deck.gl/core';
|
|
28
29
|
|
|
29
30
|
const defaultProps = {
|
|
30
31
|
getFilterValue: {type: 'accessor', value: 0},
|
|
@@ -155,9 +156,9 @@ export default class DataFilterExtension extends LayerExtension<DataFilterExtens
|
|
|
155
156
|
});
|
|
156
157
|
}
|
|
157
158
|
|
|
158
|
-
const {
|
|
159
|
+
const {device} = this.context;
|
|
159
160
|
if (attributeManager && extension.opts.countItems) {
|
|
160
|
-
const useFloatTarget = aggregator.supportsFloatTarget(
|
|
161
|
+
const useFloatTarget = aggregator.supportsFloatTarget(device);
|
|
161
162
|
// This attribute is needed for variable-width data, e.g. Path, SolidPolygon, Text
|
|
162
163
|
// The vertex shader checks if a vertex has the same "index" as the previous vertex
|
|
163
164
|
// so that we only write one count cross multiple vertices of the same object
|
|
@@ -182,9 +183,9 @@ export default class DataFilterExtension extends LayerExtension<DataFilterExtens
|
|
|
182
183
|
}
|
|
183
184
|
});
|
|
184
185
|
|
|
185
|
-
const filterFBO = aggregator.getFramebuffer(
|
|
186
|
+
const filterFBO = aggregator.getFramebuffer(device, useFloatTarget);
|
|
186
187
|
const filterModel = aggregator.getModel(
|
|
187
|
-
|
|
188
|
+
device,
|
|
188
189
|
extension.getShaders.call(this, extension),
|
|
189
190
|
useFloatTarget
|
|
190
191
|
);
|
|
@@ -211,7 +212,10 @@ export default class DataFilterExtension extends LayerExtension<DataFilterExtens
|
|
|
211
212
|
}
|
|
212
213
|
|
|
213
214
|
draw(this: Layer<DataFilterExtensionProps>, params: any, extension: this) {
|
|
214
|
-
const
|
|
215
|
+
const filterFBO = this.state.filterFBO as Framebuffer;
|
|
216
|
+
const filterModel = this.state.filterModel as Model;
|
|
217
|
+
const filterNeedsUpdate = this.state.filterNeedsUpdate as boolean;
|
|
218
|
+
|
|
215
219
|
const {onFilteredItemsChange} = this.props;
|
|
216
220
|
if (filterNeedsUpdate && onFilteredItemsChange && filterModel) {
|
|
217
221
|
const {
|
|
@@ -219,22 +223,26 @@ export default class DataFilterExtension extends LayerExtension<DataFilterExtens
|
|
|
219
223
|
} = this.getAttributeManager()!;
|
|
220
224
|
filterModel.setVertexCount(this.getNumInstances());
|
|
221
225
|
|
|
222
|
-
|
|
223
|
-
clear(gl, {framebuffer: filterFBO, color: [0, 0, 0, 0]});
|
|
226
|
+
clear(this.context.device, {framebuffer: filterFBO, color: [0, 0, 0, 0]});
|
|
224
227
|
|
|
225
|
-
filterModel
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
228
|
+
filterModel.updateModuleSettings(params.moduleParameters);
|
|
229
|
+
// @ts-expect-error filterValue and filterIndices should always have buffer value
|
|
230
|
+
filterModel.setAttributes({
|
|
231
|
+
...filterValues.getValue(),
|
|
232
|
+
...filterIndices?.getValue()
|
|
233
|
+
});
|
|
234
|
+
withGLParameters(
|
|
235
|
+
filterModel.device,
|
|
236
|
+
{
|
|
232
237
|
framebuffer: filterFBO,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
+
// ts-ignore 'readonly' cannot be assigned to the mutable type '[GLBlendEquation, GLBlendEquation]'
|
|
239
|
+
...(aggregator.parameters as any),
|
|
240
|
+
viewport: [0, 0, filterFBO.width, filterFBO.height]
|
|
241
|
+
},
|
|
242
|
+
() => {
|
|
243
|
+
filterModel.draw(this.context.renderPass);
|
|
244
|
+
}
|
|
245
|
+
);
|
|
238
246
|
const color = readPixelsToArray(filterFBO);
|
|
239
247
|
let count = 0;
|
|
240
248
|
for (let i = 0; i < color.length; i++) {
|
|
@@ -247,11 +255,11 @@ export default class DataFilterExtension extends LayerExtension<DataFilterExtens
|
|
|
247
255
|
}
|
|
248
256
|
|
|
249
257
|
finalizeState(this: Layer<DataFilterExtensionProps>) {
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
258
|
+
const filterFBO = this.state.filterFBO as Framebuffer;
|
|
259
|
+
const filterModel = this.state.filterModel as Model;
|
|
260
|
+
|
|
261
|
+
// filterFBO.color.delete();
|
|
262
|
+
filterFBO?.destroy();
|
|
263
|
+
filterModel?.destroy();
|
|
256
264
|
}
|
|
257
265
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import {LayerExtension} from '@deck.gl/core';
|
|
2
|
-
import {Texture2D} from '@luma.gl/core';
|
|
3
|
-
import GL from '@luma.gl/constants';
|
|
4
2
|
|
|
5
3
|
import {patternShaders} from './shaders.glsl';
|
|
6
4
|
|
|
@@ -9,9 +7,10 @@ import type {
|
|
|
9
7
|
LayerContext,
|
|
10
8
|
Accessor,
|
|
11
9
|
AccessorFunction,
|
|
12
|
-
|
|
10
|
+
TextureSource,
|
|
13
11
|
UpdateParameters
|
|
14
12
|
} from '@deck.gl/core';
|
|
13
|
+
import type {Texture} from '@luma.gl/core';
|
|
15
14
|
|
|
16
15
|
const defaultProps = {
|
|
17
16
|
fillPatternEnabled: true,
|
|
@@ -20,7 +19,7 @@ const defaultProps = {
|
|
|
20
19
|
value: null,
|
|
21
20
|
async: true,
|
|
22
21
|
parameters: {
|
|
23
|
-
|
|
22
|
+
minFilter: 'linear'
|
|
24
23
|
}
|
|
25
24
|
},
|
|
26
25
|
fillPatternMapping: {type: 'object', value: {}, async: true},
|
|
@@ -36,7 +35,7 @@ export type FillStyleExtensionProps<DataT = any> = {
|
|
|
36
35
|
*/
|
|
37
36
|
fillPatternEnabled?: boolean;
|
|
38
37
|
/** Sprite image url or texture that packs all your patterns into one layout. */
|
|
39
|
-
fillPatternAtlas?: string |
|
|
38
|
+
fillPatternAtlas?: string | TextureSource;
|
|
40
39
|
/** Pattern names mapped to pattern definitions, or a url that points to a JSON file. */
|
|
41
40
|
fillPatternMapping?:
|
|
42
41
|
| string
|
|
@@ -151,7 +150,7 @@ export default class FillStyleExtension extends LayerExtension<FillStyleExtensio
|
|
|
151
150
|
});
|
|
152
151
|
}
|
|
153
152
|
this.setState({
|
|
154
|
-
emptyTexture:
|
|
153
|
+
emptyTexture: this.context.device.createTexture({
|
|
155
154
|
data: new Uint8Array(4),
|
|
156
155
|
width: 1,
|
|
157
156
|
height: 1
|
|
@@ -185,7 +184,7 @@ export default class FillStyleExtension extends LayerExtension<FillStyleExtensio
|
|
|
185
184
|
}
|
|
186
185
|
|
|
187
186
|
finalizeState(this: Layer<FillStyleExtensionProps>) {
|
|
188
|
-
const
|
|
187
|
+
const emptyTexture = this.state.emptyTexture as Texture;
|
|
189
188
|
emptyTexture?.delete();
|
|
190
189
|
}
|
|
191
190
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {project, fp64LowPart} from '@deck.gl/core';
|
|
2
2
|
import type {Viewport, _ShaderModule as ShaderModule, ProjectUniforms} from '@deck.gl/core';
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type {Texture} from '@luma.gl/core';
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* fill pattern shader module
|
|
@@ -80,7 +80,7 @@ type FillStyleModuleSettings =
|
|
|
80
80
|
fillPatternMask?: boolean;
|
|
81
81
|
}
|
|
82
82
|
| {
|
|
83
|
-
fillPatternTexture:
|
|
83
|
+
fillPatternTexture: Texture;
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
/* eslint-disable camelcase */
|
package/src/mask/mask-effect.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {Layer, Viewport, Effect, PreRenderOptions, CoordinateSystem, log} from '@deck.gl/core';
|
|
2
|
-
import {
|
|
2
|
+
import type {Device, Texture} from '@luma.gl/core';
|
|
3
|
+
// import {readPixelsToArray} from '@luma.gl/webgl-legacy';
|
|
3
4
|
import {equals} from '@math.gl/core';
|
|
4
5
|
import MaskPass from './mask-pass';
|
|
5
6
|
import {joinLayerBounds, getRenderBounds, makeViewport, Bounds} from '../utils/projection-utils';
|
|
@@ -35,20 +36,20 @@ export default class MaskEffect implements Effect {
|
|
|
35
36
|
useInPicking = true;
|
|
36
37
|
order = 0;
|
|
37
38
|
|
|
38
|
-
private dummyMaskMap?:
|
|
39
|
+
private dummyMaskMap?: Texture;
|
|
39
40
|
private channels: (Channel | null)[] = [];
|
|
40
41
|
private masks: Record<string, Mask> | null = null;
|
|
41
42
|
private maskPass?: MaskPass;
|
|
42
|
-
private maskMap?:
|
|
43
|
+
private maskMap?: Texture;
|
|
43
44
|
private lastViewport?: Viewport;
|
|
44
45
|
|
|
45
46
|
preRender(
|
|
46
|
-
|
|
47
|
+
device: Device,
|
|
47
48
|
{layers, layerFilter, viewports, onViewportActive, views, isPicking}: PreRenderOptions
|
|
48
49
|
): MaskPreRenderStats {
|
|
49
50
|
let didRender = false;
|
|
50
51
|
if (!this.dummyMaskMap) {
|
|
51
|
-
this.dummyMaskMap =
|
|
52
|
+
this.dummyMaskMap = device.createTexture({
|
|
52
53
|
width: 1,
|
|
53
54
|
height: 1
|
|
54
55
|
});
|
|
@@ -68,7 +69,7 @@ export default class MaskEffect implements Effect {
|
|
|
68
69
|
this.masks = {};
|
|
69
70
|
|
|
70
71
|
if (!this.maskPass) {
|
|
71
|
-
this.maskPass = new MaskPass(
|
|
72
|
+
this.maskPass = new MaskPass(device, {id: 'default-mask'});
|
|
72
73
|
this.maskMap = this.maskPass.maskMap;
|
|
73
74
|
}
|
|
74
75
|
|
|
@@ -159,8 +160,8 @@ export default class MaskEffect implements Effect {
|
|
|
159
160
|
makeViewport({
|
|
160
161
|
bounds: channelInfo.bounds!,
|
|
161
162
|
viewport,
|
|
162
|
-
width: maskMap
|
|
163
|
-
height: maskMap
|
|
163
|
+
width: maskMap!.width,
|
|
164
|
+
height: maskMap!.height,
|
|
164
165
|
border: 1
|
|
165
166
|
});
|
|
166
167
|
|
|
@@ -247,11 +248,11 @@ export default class MaskEffect implements Effect {
|
|
|
247
248
|
}
|
|
248
249
|
|
|
249
250
|
getModuleParameters(): {
|
|
250
|
-
maskMap:
|
|
251
|
+
maskMap: Texture;
|
|
251
252
|
maskChannels: Record<string, Mask> | null;
|
|
252
253
|
} {
|
|
253
254
|
return {
|
|
254
|
-
maskMap: this.masks ? this.maskMap : this.dummyMaskMap
|
|
255
|
+
maskMap: this.masks ? this.maskMap! : this.dummyMaskMap!,
|
|
255
256
|
maskChannels: this.masks
|
|
256
257
|
};
|
|
257
258
|
}
|