@deck.gl/arcgis 9.0.0-beta.10 → 9.0.0-beta.11
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/commons.d.ts +2 -2
- package/dist/commons.d.ts.map +1 -1
- package/dist/commons.js +40 -24
- package/dist/deck-layer-view-2d.d.ts.map +1 -1
- package/dist/deck-layer-view-2d.js +21 -8
- package/dist/deck-renderer.d.ts +2 -1
- package/dist/deck-renderer.d.ts.map +1 -1
- package/dist/deck-renderer.js +11 -4
- package/dist/dist.dev.js +196 -5652
- package/dist/index.cjs +66 -33
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist.min.js +2 -3
- package/package.json +6 -7
- package/src/commons.ts +53 -36
- package/src/deck-layer-view-2d.ts +22 -8
- package/src/deck-renderer.ts +12 -4
package/dist/commons.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Model } from '@luma.gl/engine';
|
|
2
2
|
import { Deck } from '@deck.gl/core';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Texture, Framebuffer } from '@luma.gl/core';
|
|
4
4
|
interface Renderer {
|
|
5
5
|
redraw: () => void;
|
|
6
6
|
}
|
|
@@ -10,7 +10,7 @@ export type RenderResources = {
|
|
|
10
10
|
model: Model;
|
|
11
11
|
fbo: Framebuffer;
|
|
12
12
|
};
|
|
13
|
-
export declare function initializeResources(this: Renderer,
|
|
13
|
+
export declare function initializeResources(this: Renderer, gl: WebGL2RenderingContext): Promise<RenderResources>;
|
|
14
14
|
export declare function render(resources: RenderResources, viewport: {
|
|
15
15
|
width: number;
|
|
16
16
|
height: number;
|
package/dist/commons.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commons.d.ts","sourceRoot":"","sources":["../src/commons.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,KAAK,EAAW,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAC,IAAI,EAAC,MAAM,eAAe,CAAC;AACnC,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"commons.d.ts","sourceRoot":"","sources":["../src/commons.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,KAAK,EAAW,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAC,IAAI,EAAC,MAAM,eAAe,CAAC;AACnC,OAAO,KAAK,EAAS,OAAO,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAEhE,UAAU,QAAQ;IAChB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;IACb,GAAG,EAAE,WAAW,CAAC;CAClB,CAAC;AA8BF,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,QAAQ,EACd,EAAE,EAAE,sBAAsB,GACzB,OAAO,CAAC,eAAe,CAAC,CAkF1B;AAED,wBAAgB,MAAM,CACpB,SAAS,EAAE,eAAe,EAC1B,QAAQ,EAAE;IACR,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,QAgCF;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,eAAe,QAK3D"}
|
package/dist/commons.js
CHANGED
|
@@ -2,7 +2,28 @@
|
|
|
2
2
|
import { GL } from '@luma.gl/constants';
|
|
3
3
|
import { Model, Geometry } from '@luma.gl/engine';
|
|
4
4
|
import { Deck } from '@deck.gl/core';
|
|
5
|
-
|
|
5
|
+
async function createDeckInstance(gl) {
|
|
6
|
+
return new Promise(resolve => {
|
|
7
|
+
const deckInstance = new Deck({
|
|
8
|
+
// Input is handled by the ArcGIS API for JavaScript.
|
|
9
|
+
controller: false,
|
|
10
|
+
// We use the same WebGL context as the ArcGIS API for JavaScript.
|
|
11
|
+
gl,
|
|
12
|
+
// We need depth testing in general; we don't know what layers might be added to the deck.
|
|
13
|
+
parameters: {
|
|
14
|
+
depthCompare: 'less-equal'
|
|
15
|
+
},
|
|
16
|
+
// To disable canvas resizing, since the FBO is owned by the ArcGIS API for JavaScript.
|
|
17
|
+
width: null,
|
|
18
|
+
height: null,
|
|
19
|
+
onDeviceInitialized: (device) => {
|
|
20
|
+
resolve({ deckInstance, device });
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export async function initializeResources(gl) {
|
|
26
|
+
const { deckInstance, device } = await createDeckInstance(gl);
|
|
6
27
|
const texture = device.createTexture({
|
|
7
28
|
format: 'rgba8unorm',
|
|
8
29
|
width: 1,
|
|
@@ -42,7 +63,13 @@ void main(void) {
|
|
|
42
63
|
},
|
|
43
64
|
parameters: {
|
|
44
65
|
depthWriteEnabled: true,
|
|
45
|
-
depthCompare: 'less-equal'
|
|
66
|
+
depthCompare: 'less-equal',
|
|
67
|
+
blendColorSrcFactor: 'one',
|
|
68
|
+
blendColorDstFactor: 'one-minus-src-alpha',
|
|
69
|
+
blendAlphaSrcFactor: 'one',
|
|
70
|
+
blendAlphaDstFactor: 'one-minus-src-alpha',
|
|
71
|
+
blendColorOperation: 'add',
|
|
72
|
+
blendAlphaOperation: 'add'
|
|
46
73
|
},
|
|
47
74
|
geometry: new Geometry({
|
|
48
75
|
topology: 'triangle-strip',
|
|
@@ -56,24 +83,12 @@ void main(void) {
|
|
|
56
83
|
id: 'deckfbo',
|
|
57
84
|
width: 1,
|
|
58
85
|
height: 1,
|
|
59
|
-
colorAttachments: [texture]
|
|
86
|
+
colorAttachments: [texture],
|
|
87
|
+
depthStencilAttachment: 'depth16unorm'
|
|
60
88
|
});
|
|
61
|
-
|
|
62
|
-
// The view state will be set dynamically to track the MapView current extent.
|
|
63
|
-
viewState: {},
|
|
64
|
-
// Input is handled by the ArcGIS API for JavaScript.
|
|
65
|
-
controller: false,
|
|
66
|
-
// We use the same WebGL context as the ArcGIS API for JavaScript.
|
|
67
|
-
device,
|
|
68
|
-
// We need depth testing in general; we don't know what layers might be added to the deck.
|
|
69
|
-
parameters: {
|
|
70
|
-
depthTest: true
|
|
71
|
-
},
|
|
89
|
+
deckInstance.setProps({
|
|
72
90
|
// This deck renders into an auxiliary framebuffer.
|
|
73
91
|
_framebuffer: fbo,
|
|
74
|
-
// To disable canvas resizing, since the FBO is owned by the ArcGIS API for JavaScript.
|
|
75
|
-
width: null,
|
|
76
|
-
height: null,
|
|
77
92
|
_customRender: redrawReason => {
|
|
78
93
|
if (redrawReason === 'arcgis') {
|
|
79
94
|
deckInstance._drawLayers(redrawReason);
|
|
@@ -88,6 +103,7 @@ void main(void) {
|
|
|
88
103
|
export function render(resources, viewport) {
|
|
89
104
|
const { model, deck, fbo } = resources;
|
|
90
105
|
const device = model.device;
|
|
106
|
+
// @ts-ignore device.getParametersWebGL should return `any` not `void`?
|
|
91
107
|
const screenFbo = device.getParametersWebGL(36006);
|
|
92
108
|
const { width, height, ...viewState } = viewport;
|
|
93
109
|
/* global window */
|
|
@@ -102,15 +118,15 @@ export function render(resources, viewport) {
|
|
|
102
118
|
const textureToScreenPass = device.beginRenderPass({
|
|
103
119
|
framebuffer: screenFbo,
|
|
104
120
|
parameters: { viewport: [0, 0, pixelWidth, pixelHeight] },
|
|
105
|
-
clearColor:
|
|
106
|
-
clearDepth:
|
|
121
|
+
clearColor: false,
|
|
122
|
+
clearDepth: false
|
|
107
123
|
});
|
|
108
|
-
|
|
109
|
-
blend: true,
|
|
110
|
-
blendFunc: [1, 771]
|
|
111
|
-
}, () => {
|
|
124
|
+
try {
|
|
112
125
|
model.draw(textureToScreenPass);
|
|
113
|
-
}
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
textureToScreenPass.end();
|
|
129
|
+
}
|
|
114
130
|
}
|
|
115
131
|
export function finalizeResources(resources) {
|
|
116
132
|
resources.deck.finalize();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deck-layer-view-2d.d.ts","sourceRoot":"","sources":["../src/deck-layer-view-2d.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deck-layer-view-2d.d.ts","sourceRoot":"","sources":["../src/deck-layer-view-2d.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,iBAAiB,KAAA,OAgE9D"}
|
|
@@ -1,32 +1,45 @@
|
|
|
1
|
-
import { WebGLDevice } from '@luma.gl/webgl';
|
|
2
1
|
import { initializeResources, render, finalizeResources } from "./commons.js";
|
|
3
2
|
export default function createDeckLayerView2D(BaseLayerViewGL2D) {
|
|
4
3
|
return BaseLayerViewGL2D.createSubclass({
|
|
5
4
|
properties: {
|
|
5
|
+
cancelInitialization: null,
|
|
6
6
|
resources: null
|
|
7
7
|
},
|
|
8
8
|
// Attach is called as soon as the layer view is ready to start rendering.
|
|
9
|
-
attach() {
|
|
9
|
+
async attach() {
|
|
10
10
|
// We use a full-screen quad and shaders to composite the frame rendered
|
|
11
11
|
// with deck.gl on top of the MapView. Composition uses the MapView context.
|
|
12
12
|
const gl = this.context;
|
|
13
|
-
|
|
14
|
-
this.
|
|
13
|
+
let cancelled = false;
|
|
14
|
+
this.cancelInitialization = () => (cancelled = true);
|
|
15
|
+
const resources = await initializeResources.call(this, gl);
|
|
16
|
+
// If the layer got detached while awaiting, do not proceed
|
|
17
|
+
if (cancelled) {
|
|
18
|
+
finalizeResources(resources);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
this.resources = resources;
|
|
15
22
|
// Update deck props
|
|
16
|
-
this.layer.deck.on('change', props =>
|
|
23
|
+
this.layer.deck.on('change', props => resources.deck.setProps(props));
|
|
17
24
|
// We need to start drawing the deck.gl layer immediately.
|
|
18
|
-
|
|
25
|
+
resources.deck.setProps(this.layer.deck.toJSON());
|
|
19
26
|
},
|
|
20
27
|
redraw() {
|
|
21
28
|
this.requestRender();
|
|
22
29
|
},
|
|
23
30
|
// Called when the layer must be destroyed.
|
|
24
31
|
detach() {
|
|
25
|
-
|
|
26
|
-
this.resources
|
|
32
|
+
this.cancelInitialization?.();
|
|
33
|
+
if (this.resources) {
|
|
34
|
+
finalizeResources(this.resources);
|
|
35
|
+
this.resources = null;
|
|
36
|
+
}
|
|
27
37
|
},
|
|
28
38
|
// Called every time that the layer view must be rendered.
|
|
29
39
|
render(renderParameters) {
|
|
40
|
+
if (!this.resources) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
30
43
|
const [width, height] = this.view.state.size;
|
|
31
44
|
// The view state must be kept in-sync with the MapView of the ArcGIS API.
|
|
32
45
|
const state = renderParameters.state;
|
package/dist/deck-renderer.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export default function createDeckRenderer(DeckProps: any, externalRenderers: an
|
|
|
5
5
|
view: SceneView;
|
|
6
6
|
deck: any;
|
|
7
7
|
resources: RenderResources | null;
|
|
8
|
-
|
|
8
|
+
cancelInitialization: (() => void) | null;
|
|
9
|
+
setup(context: any): Promise<void>;
|
|
9
10
|
dispose(): void;
|
|
10
11
|
redraw(): void;
|
|
11
12
|
render(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deck-renderer.d.ts","sourceRoot":"","sources":["../src/deck-renderer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deck-renderer.d.ts","sourceRoot":"","sources":["../src/deck-renderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAiD,eAAe,EAAC,qBAAkB;AAE1F,OAAO,SAAS,MAAM,8BAA8B,CAAC;AAWrD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,SAAS,KAAA,EAAE,iBAAiB,KAAA;eAOjD,SAAS,SAAS,SAAS;cALvC,SAAS;cACT,GAAG;mBACE,eAAe,GAAG,IAAI;8BACX,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI;;;;;;EAqD5C"}
|
package/dist/deck-renderer.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable no-invalid-this */
|
|
2
|
-
import { WebGLDevice } from '@luma.gl/webgl';
|
|
3
2
|
import { initializeResources, render, finalizeResources } from "./commons.js";
|
|
4
3
|
/** Convert ArcGIS FOV to WebMercatorViewport altitude */
|
|
5
4
|
function arcgisFOVToDeckAltitude(fov, aspectRatio) {
|
|
@@ -12,18 +11,26 @@ export default function createDeckRenderer(DeckProps, externalRenderers) {
|
|
|
12
11
|
class DeckRenderer {
|
|
13
12
|
constructor(view, props) {
|
|
14
13
|
this.resources = null;
|
|
14
|
+
this.cancelInitialization = null;
|
|
15
15
|
this.view = view;
|
|
16
16
|
this.deck = new DeckProps(props);
|
|
17
17
|
}
|
|
18
|
-
setup(context) {
|
|
18
|
+
async setup(context) {
|
|
19
19
|
const gl = context.gl;
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
let cancelled = false;
|
|
21
|
+
this.cancelInitialization = () => (cancelled = true);
|
|
22
|
+
const resources = await initializeResources.call(this, gl);
|
|
23
|
+
// If the renderer got disposed while awaiting, do not proceed
|
|
24
|
+
if (cancelled) {
|
|
25
|
+
finalizeResources(resources);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
22
28
|
this.deck.on('change', props => resources.deck.setProps(props));
|
|
23
29
|
resources.deck.setProps(this.deck.toJSON());
|
|
24
30
|
this.resources = resources;
|
|
25
31
|
}
|
|
26
32
|
dispose() {
|
|
33
|
+
this.cancelInitialization?.();
|
|
27
34
|
if (this.resources) {
|
|
28
35
|
finalizeResources(this.resources);
|
|
29
36
|
}
|