@deck.gl/arcgis 9.0.0-beta.1 → 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 +26 -0
- package/dist/commons.d.ts.map +1 -0
- package/dist/commons.js +136 -0
- package/dist/deck-layer-view-2d.d.ts +2 -0
- package/dist/deck-layer-view-2d.d.ts.map +1 -0
- package/dist/deck-layer-view-2d.js +57 -0
- package/dist/deck-layer.d.ts +2 -0
- package/dist/deck-layer.d.ts.map +1 -0
- package/dist/deck-layer.js +27 -0
- package/dist/deck-props.d.ts +2 -0
- package/dist/deck-props.d.ts.map +1 -0
- package/dist/deck-props.js +53 -0
- package/dist/deck-renderer.d.ts +15 -0
- package/dist/deck-renderer.d.ts.map +1 -0
- package/dist/deck-renderer.js +56 -0
- package/dist/dist.dev.js +227 -8802
- package/dist/index.cjs +393 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/{esm/index.js → index.js} +7 -6
- package/dist/load-modules.d.ts +9 -0
- package/dist/load-modules.d.ts.map +1 -0
- package/dist/load-modules.js +46 -0
- package/dist.min.js +10 -140
- package/package.json +20 -11
- package/src/commons.ts +138 -69
- package/src/{deck-layer-view-2d.js → deck-layer-view-2d.ts} +30 -18
- package/src/deck-renderer.ts +73 -0
- package/src/{load-modules.js → load-modules.ts} +20 -9
- package/dist/es5/commons.js +0 -95
- package/dist/es5/commons.js.map +0 -1
- package/dist/es5/deck-layer-view-2d.js +0 -62
- package/dist/es5/deck-layer-view-2d.js.map +0 -1
- package/dist/es5/deck-layer.js +0 -31
- package/dist/es5/deck-layer.js.map +0 -1
- package/dist/es5/deck-props.js +0 -98
- package/dist/es5/deck-props.js.map +0 -1
- package/dist/es5/deck-renderer.js +0 -78
- package/dist/es5/deck-renderer.js.map +0 -1
- package/dist/es5/index.js +0 -46
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/load-modules.js +0 -109
- package/dist/es5/load-modules.js.map +0 -1
- package/dist/esm/commons.js +0 -96
- package/dist/esm/commons.js.map +0 -1
- package/dist/esm/deck-layer-view-2d.js +0 -45
- package/dist/esm/deck-layer-view-2d.js.map +0 -1
- package/dist/esm/deck-layer.js +0 -27
- package/dist/esm/deck-layer.js.map +0 -1
- package/dist/esm/deck-props.js +0 -64
- package/dist/esm/deck-props.js.map +0 -1
- package/dist/esm/deck-renderer.js +0 -52
- package/dist/esm/deck-renderer.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/load-modules.js +0 -51
- package/dist/esm/load-modules.js.map +0 -1
- package/src/deck-renderer.js +0 -56
- /package/src/{deck-layer.js → deck-layer.ts} +0 -0
- /package/src/{deck-props.js → deck-props.ts} +0 -0
- /package/src/{index.js → index.ts} +0 -0
package/package.json
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
"name": "@deck.gl/arcgis",
|
|
3
3
|
"description": "Use deck.gl as a custom ArcGIS API for JavaScript layer",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"version": "9.0.0-beta.11",
|
|
6
7
|
"publishConfig": {
|
|
7
8
|
"access": "public"
|
|
8
9
|
},
|
|
@@ -16,12 +17,17 @@
|
|
|
16
17
|
"type": "git",
|
|
17
18
|
"url": "https://github.com/visgl/deck.gl.git"
|
|
18
19
|
},
|
|
19
|
-
"main": "dist/
|
|
20
|
-
"module": "dist/
|
|
20
|
+
"main": "dist/index.cjs",
|
|
21
|
+
"module": "dist/index.js",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"import": "./dist/index.js",
|
|
25
|
+
"require": "./dist/index.cjs"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
21
28
|
"files": [
|
|
22
29
|
"dist",
|
|
23
30
|
"src",
|
|
24
|
-
"typed",
|
|
25
31
|
"dist.min.js"
|
|
26
32
|
],
|
|
27
33
|
"sideEffects": false,
|
|
@@ -29,15 +35,18 @@
|
|
|
29
35
|
"build-bundle": "ocular-bundle ./bundle.ts",
|
|
30
36
|
"prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env=dev"
|
|
31
37
|
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@luma.gl/constants": "^9.0.11",
|
|
40
|
+
"esri-loader": "^3.7.0"
|
|
41
|
+
},
|
|
32
42
|
"peerDependencies": {
|
|
33
43
|
"@arcgis/core": "^4.0.0",
|
|
34
|
-
"@deck.gl/core": "^9.0.0-
|
|
35
|
-
"@luma.gl/core": "9.0.0
|
|
36
|
-
"@luma.gl/engine": "9.0.0
|
|
44
|
+
"@deck.gl/core": "^9.0.0-beta",
|
|
45
|
+
"@luma.gl/core": "^9.0.0",
|
|
46
|
+
"@luma.gl/engine": "^9.0.0"
|
|
37
47
|
},
|
|
38
|
-
"
|
|
39
|
-
"@
|
|
40
|
-
"esri-loader": "^3.3.0"
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@arcgis/core": "^4.21.0"
|
|
41
50
|
},
|
|
42
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "d8a3f5bdb644f85caba9d5c1e74baff8f8a3d439"
|
|
43
52
|
}
|
package/src/commons.ts
CHANGED
|
@@ -1,115 +1,184 @@
|
|
|
1
1
|
/* eslint-disable no-invalid-this */
|
|
2
2
|
|
|
3
|
-
import type {Device} from '@luma.gl/core';
|
|
4
|
-
import {Model} from '@luma.gl/engine';
|
|
5
3
|
import {GL} from '@luma.gl/constants';
|
|
6
|
-
import {
|
|
7
|
-
|
|
4
|
+
import {Model, Geometry} from '@luma.gl/engine';
|
|
8
5
|
import {Deck} from '@deck.gl/core';
|
|
6
|
+
import type {Device, Texture, Framebuffer} from '@luma.gl/core';
|
|
7
|
+
|
|
8
|
+
interface Renderer {
|
|
9
|
+
redraw: () => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type RenderResources = {
|
|
13
|
+
deck: Deck;
|
|
14
|
+
texture: Texture;
|
|
15
|
+
model: Model;
|
|
16
|
+
fbo: Framebuffer;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
async function createDeckInstance(gl: WebGL2RenderingContext): Promise<{
|
|
20
|
+
deckInstance: Deck;
|
|
21
|
+
device: Device;
|
|
22
|
+
}> {
|
|
23
|
+
return new Promise(resolve => {
|
|
24
|
+
const deckInstance = new Deck({
|
|
25
|
+
// Input is handled by the ArcGIS API for JavaScript.
|
|
26
|
+
controller: false,
|
|
27
|
+
|
|
28
|
+
// We use the same WebGL context as the ArcGIS API for JavaScript.
|
|
29
|
+
gl,
|
|
30
|
+
|
|
31
|
+
// We need depth testing in general; we don't know what layers might be added to the deck.
|
|
32
|
+
parameters: {
|
|
33
|
+
depthCompare: 'less-equal'
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
// To disable canvas resizing, since the FBO is owned by the ArcGIS API for JavaScript.
|
|
37
|
+
width: null,
|
|
38
|
+
height: null,
|
|
39
|
+
|
|
40
|
+
onDeviceInitialized: (device: Device) => {
|
|
41
|
+
resolve({deckInstance, device});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
9
46
|
|
|
10
|
-
export function initializeResources(
|
|
11
|
-
|
|
12
|
-
|
|
47
|
+
export async function initializeResources(
|
|
48
|
+
this: Renderer,
|
|
49
|
+
gl: WebGL2RenderingContext
|
|
50
|
+
): Promise<RenderResources> {
|
|
51
|
+
const {deckInstance, device} = await createDeckInstance(gl);
|
|
52
|
+
|
|
53
|
+
const texture = device.createTexture({
|
|
54
|
+
format: 'rgba8unorm',
|
|
55
|
+
width: 1,
|
|
56
|
+
height: 1,
|
|
57
|
+
sampler: {
|
|
58
|
+
minFilter: 'linear',
|
|
59
|
+
magFilter: 'linear',
|
|
60
|
+
addressModeU: 'clamp-to-edge',
|
|
61
|
+
addressModeV: 'clamp-to-edge'
|
|
62
|
+
}
|
|
63
|
+
});
|
|
13
64
|
|
|
14
|
-
|
|
65
|
+
const model = new Model(device, {
|
|
15
66
|
vs: `\
|
|
16
67
|
#version 300 es
|
|
17
|
-
in vec2
|
|
68
|
+
in vec2 pos;
|
|
18
69
|
out vec2 v_texcoord;
|
|
19
70
|
void main(void) {
|
|
20
|
-
gl_Position = vec4(
|
|
21
|
-
v_texcoord = (
|
|
71
|
+
gl_Position = vec4(pos, 0.0, 1.0);
|
|
72
|
+
v_texcoord = (pos + 1.0) / 2.0;
|
|
22
73
|
}
|
|
23
74
|
`,
|
|
24
75
|
fs: `\
|
|
25
76
|
#version 300 es
|
|
26
77
|
precision mediump float;
|
|
27
|
-
uniform sampler2D
|
|
78
|
+
uniform sampler2D deckglTexture;
|
|
28
79
|
in vec2 v_texcoord;
|
|
29
80
|
out vec4 fragColor;
|
|
81
|
+
|
|
30
82
|
void main(void) {
|
|
31
|
-
vec4
|
|
32
|
-
|
|
33
|
-
fragColor =
|
|
83
|
+
vec4 imageColor = texture(deckglTexture, v_texcoord);
|
|
84
|
+
imageColor.rgb *= imageColor.a;
|
|
85
|
+
fragColor = imageColor;
|
|
34
86
|
}
|
|
35
87
|
`,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
a_pos: this.buffer
|
|
88
|
+
bindings: {
|
|
89
|
+
deckglTexture: texture
|
|
39
90
|
},
|
|
40
|
-
vertexCount: 4,
|
|
41
|
-
drawMode: GL.TRIANGLE_STRIP
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
this.deckFbo = device.createFramebuffer({width: 1, height: 1});
|
|
45
|
-
|
|
46
|
-
this.deckInstance = new Deck({
|
|
47
|
-
// The view state will be set dynamically to track the MapView current extent.
|
|
48
|
-
viewState: {},
|
|
49
|
-
|
|
50
|
-
// Input is handled by the ArcGIS API for JavaScript.
|
|
51
|
-
controller: false,
|
|
52
|
-
|
|
53
|
-
// We use the same WebGL context as the ArcGIS API for JavaScript.
|
|
54
|
-
gl: device.gl,
|
|
55
|
-
|
|
56
|
-
// We need depth testing in general; we don't know what layers might be added to the deck.
|
|
57
91
|
parameters: {
|
|
58
|
-
|
|
92
|
+
depthWriteEnabled: true,
|
|
93
|
+
depthCompare: 'less-equal',
|
|
94
|
+
blendColorSrcFactor: 'one',
|
|
95
|
+
blendColorDstFactor: 'one-minus-src-alpha',
|
|
96
|
+
blendAlphaSrcFactor: 'one',
|
|
97
|
+
blendAlphaDstFactor: 'one-minus-src-alpha',
|
|
98
|
+
blendColorOperation: 'add',
|
|
99
|
+
blendAlphaOperation: 'add'
|
|
59
100
|
},
|
|
101
|
+
geometry: new Geometry({
|
|
102
|
+
topology: 'triangle-strip',
|
|
103
|
+
attributes: {
|
|
104
|
+
pos: {size: 2, value: new Int8Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1])}
|
|
105
|
+
}
|
|
106
|
+
}),
|
|
107
|
+
vertexCount: 6
|
|
108
|
+
});
|
|
60
109
|
|
|
61
|
-
|
|
62
|
-
|
|
110
|
+
const fbo = device.createFramebuffer({
|
|
111
|
+
id: 'deckfbo',
|
|
112
|
+
width: 1,
|
|
113
|
+
height: 1,
|
|
114
|
+
colorAttachments: [texture],
|
|
115
|
+
depthStencilAttachment: 'depth16unorm'
|
|
116
|
+
});
|
|
63
117
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
118
|
+
deckInstance.setProps({
|
|
119
|
+
// This deck renders into an auxiliary framebuffer.
|
|
120
|
+
_framebuffer: fbo,
|
|
67
121
|
|
|
68
122
|
_customRender: redrawReason => {
|
|
69
123
|
if (redrawReason === 'arcgis') {
|
|
70
|
-
|
|
124
|
+
deckInstance._drawLayers(redrawReason);
|
|
71
125
|
} else {
|
|
72
126
|
this.redraw();
|
|
73
127
|
}
|
|
74
128
|
}
|
|
75
129
|
});
|
|
130
|
+
|
|
131
|
+
return {deck: deckInstance, texture, fbo, model};
|
|
76
132
|
}
|
|
77
133
|
|
|
78
|
-
export function render(
|
|
79
|
-
|
|
134
|
+
export function render(
|
|
135
|
+
resources: RenderResources,
|
|
136
|
+
viewport: {
|
|
137
|
+
width: number;
|
|
138
|
+
height: number;
|
|
139
|
+
longitude: number;
|
|
140
|
+
latitude: number;
|
|
141
|
+
zoom: number;
|
|
142
|
+
altitude?: number;
|
|
143
|
+
pitch: number;
|
|
144
|
+
bearing: number;
|
|
145
|
+
}
|
|
146
|
+
) {
|
|
147
|
+
const {model, deck, fbo} = resources;
|
|
148
|
+
const device = model.device;
|
|
149
|
+
// @ts-ignore device.getParametersWebGL should return `any` not `void`?
|
|
150
|
+
const screenFbo: Framebuffer = device.getParametersWebGL(GL.FRAMEBUFFER_BINDING);
|
|
151
|
+
const {width, height, ...viewState} = viewport;
|
|
80
152
|
|
|
81
153
|
/* global window */
|
|
82
154
|
const dpr = window.devicePixelRatio;
|
|
83
|
-
|
|
84
|
-
|
|
155
|
+
const pixelWidth = Math.round(width * dpr);
|
|
156
|
+
const pixelHeight = Math.round(height * dpr);
|
|
85
157
|
|
|
86
|
-
|
|
158
|
+
fbo.resize({width: pixelWidth, height: pixelHeight});
|
|
87
159
|
|
|
88
|
-
|
|
160
|
+
deck.setProps({viewState});
|
|
89
161
|
// redraw deck immediately into deckFbo
|
|
90
|
-
|
|
162
|
+
deck.redraw('arcgis');
|
|
91
163
|
|
|
92
164
|
// We overlay the texture on top of the map using the full-screen quad.
|
|
93
|
-
withGLParameters(
|
|
94
|
-
gl,
|
|
95
|
-
{
|
|
96
|
-
blend: true,
|
|
97
|
-
blendFunc: [gl.ONE, gl.ONE_MINUS_SRC_ALPHA],
|
|
98
|
-
framebuffer: screenFbo,
|
|
99
|
-
viewport: [0, 0, width, height]
|
|
100
|
-
},
|
|
101
|
-
() => {
|
|
102
|
-
// eslint-disable-next-line camelcase
|
|
103
|
-
this.model.setUniforms({u_texture: this.deckFbo}).draw(this.context.renderPass);
|
|
104
|
-
}
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
165
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
166
|
+
const textureToScreenPass = device.beginRenderPass({
|
|
167
|
+
framebuffer: screenFbo,
|
|
168
|
+
parameters: {viewport: [0, 0, pixelWidth, pixelHeight]},
|
|
169
|
+
clearColor: false,
|
|
170
|
+
clearDepth: false
|
|
171
|
+
});
|
|
172
|
+
try {
|
|
173
|
+
model.draw(textureToScreenPass);
|
|
174
|
+
} finally {
|
|
175
|
+
textureToScreenPass.end();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
111
178
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
179
|
+
export function finalizeResources(resources: RenderResources) {
|
|
180
|
+
resources.deck.finalize();
|
|
181
|
+
resources.model.destroy();
|
|
182
|
+
resources.fbo.destroy();
|
|
183
|
+
resources.texture.destroy();
|
|
115
184
|
}
|
|
@@ -3,24 +3,31 @@ import {initializeResources, render, finalizeResources} from './commons';
|
|
|
3
3
|
export default function createDeckLayerView2D(BaseLayerViewGL2D) {
|
|
4
4
|
return BaseLayerViewGL2D.createSubclass({
|
|
5
5
|
properties: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
model: {},
|
|
9
|
-
buffer: {}
|
|
6
|
+
cancelInitialization: null,
|
|
7
|
+
resources: null
|
|
10
8
|
},
|
|
11
9
|
|
|
12
10
|
// Attach is called as soon as the layer view is ready to start rendering.
|
|
13
|
-
attach() {
|
|
11
|
+
async attach() {
|
|
14
12
|
// We use a full-screen quad and shaders to composite the frame rendered
|
|
15
13
|
// with deck.gl on top of the MapView. Composition uses the MapView context.
|
|
16
14
|
const gl = this.context;
|
|
17
|
-
|
|
15
|
+
|
|
16
|
+
let cancelled = false;
|
|
17
|
+
this.cancelInitialization = () => (cancelled = true);
|
|
18
|
+
const resources = await initializeResources.call(this, gl);
|
|
19
|
+
// If the layer got detached while awaiting, do not proceed
|
|
20
|
+
if (cancelled) {
|
|
21
|
+
finalizeResources(resources);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
this.resources = resources;
|
|
18
25
|
|
|
19
26
|
// Update deck props
|
|
20
|
-
this.layer.deck.on('change', props =>
|
|
27
|
+
this.layer.deck.on('change', props => resources.deck.setProps(props));
|
|
21
28
|
|
|
22
29
|
// We need to start drawing the deck.gl layer immediately.
|
|
23
|
-
|
|
30
|
+
resources.deck.setProps(this.layer.deck.toJSON());
|
|
24
31
|
},
|
|
25
32
|
|
|
26
33
|
redraw() {
|
|
@@ -29,26 +36,31 @@ export default function createDeckLayerView2D(BaseLayerViewGL2D) {
|
|
|
29
36
|
|
|
30
37
|
// Called when the layer must be destroyed.
|
|
31
38
|
detach() {
|
|
32
|
-
|
|
39
|
+
this.cancelInitialization?.();
|
|
40
|
+
if (this.resources) {
|
|
41
|
+
finalizeResources(this.resources);
|
|
42
|
+
this.resources = null;
|
|
43
|
+
}
|
|
33
44
|
},
|
|
34
45
|
|
|
35
46
|
// Called every time that the layer view must be rendered.
|
|
36
47
|
render(renderParameters) {
|
|
48
|
+
if (!this.resources) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
37
52
|
const [width, height] = this.view.state.size;
|
|
38
53
|
// The view state must be kept in-sync with the MapView of the ArcGIS API.
|
|
39
54
|
const state = renderParameters.state;
|
|
40
55
|
|
|
41
|
-
render
|
|
42
|
-
gl: renderParameters.context,
|
|
56
|
+
render(this.resources, {
|
|
43
57
|
width,
|
|
44
58
|
height,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
pitch: 0
|
|
51
|
-
}
|
|
59
|
+
latitude: this.view.center.latitude,
|
|
60
|
+
longitude: this.view.center.longitude,
|
|
61
|
+
zoom: this.view.featuresTilingScheme.scaleToLevel(state.scale),
|
|
62
|
+
bearing: -state.rotation,
|
|
63
|
+
pitch: 0
|
|
52
64
|
});
|
|
53
65
|
}
|
|
54
66
|
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/* eslint-disable no-invalid-this */
|
|
2
|
+
import {initializeResources, render, finalizeResources, RenderResources} from './commons';
|
|
3
|
+
|
|
4
|
+
import SceneView from '@arcgis/core/views/SceneView';
|
|
5
|
+
import type {DeckProps} from '@deck.gl/core';
|
|
6
|
+
|
|
7
|
+
/** Convert ArcGIS FOV to WebMercatorViewport altitude */
|
|
8
|
+
function arcgisFOVToDeckAltitude(fov: number, aspectRatio: number): number {
|
|
9
|
+
// ArcGIS fov is corner-to-corner
|
|
10
|
+
const D = Math.sqrt(1 + aspectRatio ** 2);
|
|
11
|
+
const halfFOV = (fov / 2 / 180) * Math.PI;
|
|
12
|
+
return D / 2 / Math.tan(halfFOV);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default function createDeckRenderer(DeckProps, externalRenderers) {
|
|
16
|
+
class DeckRenderer {
|
|
17
|
+
view: SceneView;
|
|
18
|
+
deck: any;
|
|
19
|
+
resources: RenderResources | null = null;
|
|
20
|
+
cancelInitialization: (() => void) | null = null;
|
|
21
|
+
|
|
22
|
+
constructor(view: SceneView, props: DeckProps) {
|
|
23
|
+
this.view = view;
|
|
24
|
+
this.deck = new DeckProps(props);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async setup(context) {
|
|
28
|
+
const gl = context.gl;
|
|
29
|
+
|
|
30
|
+
let cancelled = false;
|
|
31
|
+
this.cancelInitialization = () => (cancelled = true);
|
|
32
|
+
const resources = await initializeResources.call(this, gl);
|
|
33
|
+
// If the renderer got disposed while awaiting, do not proceed
|
|
34
|
+
if (cancelled) {
|
|
35
|
+
finalizeResources(resources);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
this.deck.on('change', props => resources.deck.setProps(props));
|
|
40
|
+
|
|
41
|
+
resources.deck.setProps(this.deck.toJSON());
|
|
42
|
+
this.resources = resources;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
dispose() {
|
|
46
|
+
this.cancelInitialization?.();
|
|
47
|
+
if (this.resources) {
|
|
48
|
+
finalizeResources(this.resources);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
redraw() {
|
|
53
|
+
externalRenderers.requestRender(this.view);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
render() {
|
|
57
|
+
const [width, height] = this.view.size;
|
|
58
|
+
|
|
59
|
+
render(this.resources!, {
|
|
60
|
+
width,
|
|
61
|
+
height,
|
|
62
|
+
latitude: this.view.center.latitude,
|
|
63
|
+
longitude: this.view.center.longitude,
|
|
64
|
+
altitude: arcgisFOVToDeckAltitude(this.view.camera.fov, width / height),
|
|
65
|
+
zoom: this.view.zoom,
|
|
66
|
+
bearing: this.view.camera.heading,
|
|
67
|
+
pitch: this.view.camera.tilt
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return DeckRenderer;
|
|
73
|
+
}
|
|
@@ -2,11 +2,20 @@ import createDeckProps from './deck-props';
|
|
|
2
2
|
import createDeckLayer from './deck-layer';
|
|
3
3
|
import createDeckLayerView2D from './deck-layer-view-2d';
|
|
4
4
|
import createDeckRenderer from './deck-renderer';
|
|
5
|
-
import {loadModules as esriLoaderLoadModules} from 'esri-loader';
|
|
5
|
+
import {loadModules as esriLoaderLoadModules, ILoadScriptOptions} from 'esri-loader';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
type LoadedModules = {
|
|
8
|
+
DeckLayer: any;
|
|
9
|
+
DeckRenderer: any;
|
|
10
|
+
modules?: unknown[];
|
|
11
|
+
};
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
let arcGIS: LoadedModules;
|
|
14
|
+
|
|
15
|
+
export async function loadArcGISModules(
|
|
16
|
+
modules: string[],
|
|
17
|
+
loadScriptOptions: ILoadScriptOptions
|
|
18
|
+
): Promise<LoadedModules> {
|
|
10
19
|
const namespace = Array.isArray(modules) ? null : modules;
|
|
11
20
|
await loadArcGISModule(namespace, loadScriptOptions);
|
|
12
21
|
|
|
@@ -18,7 +27,10 @@ export async function loadArcGISModules(modules, loadScriptOptions) {
|
|
|
18
27
|
return arcGIS;
|
|
19
28
|
}
|
|
20
29
|
|
|
21
|
-
function loadArcGISModule(
|
|
30
|
+
async function loadArcGISModule(
|
|
31
|
+
esri,
|
|
32
|
+
loadScriptOptions: ILoadScriptOptions
|
|
33
|
+
): Promise<LoadedModules> {
|
|
22
34
|
if (arcGIS) {
|
|
23
35
|
// Already loaded
|
|
24
36
|
return arcGIS;
|
|
@@ -34,7 +46,7 @@ function loadArcGISModule(esri, loadScriptOptions) {
|
|
|
34
46
|
return initialize(Layer, Accessor, BaseLayerViewGL2D, externalRenderers);
|
|
35
47
|
}
|
|
36
48
|
|
|
37
|
-
|
|
49
|
+
const [Layer, Accessor, BaseLayerViewGL2D, externalRenderers] = await esriLoaderLoadModules(
|
|
38
50
|
[
|
|
39
51
|
'esri/layers/Layer',
|
|
40
52
|
'esri/core/Accessor',
|
|
@@ -42,12 +54,11 @@ function loadArcGISModule(esri, loadScriptOptions) {
|
|
|
42
54
|
'esri/views/3d/externalRenderers'
|
|
43
55
|
],
|
|
44
56
|
loadScriptOptions
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
});
|
|
57
|
+
);
|
|
58
|
+
return initialize(Layer, Accessor, BaseLayerViewGL2D, externalRenderers);
|
|
48
59
|
}
|
|
49
60
|
|
|
50
|
-
function initialize(Layer, Accessor, BaseLayerViewGL2D, externalRenderers) {
|
|
61
|
+
function initialize(Layer, Accessor, BaseLayerViewGL2D, externalRenderers): LoadedModules {
|
|
51
62
|
const DeckProps = createDeckProps(Accessor);
|
|
52
63
|
const DeckLayerView2D = createDeckLayerView2D(BaseLayerViewGL2D);
|
|
53
64
|
const DeckLayer = createDeckLayer(DeckProps, Layer, DeckLayerView2D);
|
package/dist/es5/commons.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.initializeResources = initializeResources;
|
|
7
|
-
exports.render = render;
|
|
8
|
-
exports.finalizeResources = finalizeResources;
|
|
9
|
-
|
|
10
|
-
var _engine = require("@luma.gl/engine");
|
|
11
|
-
|
|
12
|
-
var _constants = require("@luma.gl/constants");
|
|
13
|
-
|
|
14
|
-
var _webgl = require("@luma.gl/webgl");
|
|
15
|
-
|
|
16
|
-
var _core = require("@deck.gl/core");
|
|
17
|
-
|
|
18
|
-
function initializeResources(device) {
|
|
19
|
-
var _this = this;
|
|
20
|
-
|
|
21
|
-
this.buffer = device.createBuffer(new Int8Array([-1, -1, 1, -1, -1, 1, 1, 1]));
|
|
22
|
-
this.model = new _engine.Model(device, {
|
|
23
|
-
vs: "#version 300 es\nin vec2 a_pos;\nout vec2 v_texcoord;\nvoid main(void) {\n gl_Position = vec4(a_pos, 0.0, 1.0);\n v_texcoord = (a_pos + 1.0) / 2.0;\n}\n ",
|
|
24
|
-
fs: "#version 300 es\nprecision mediump float;\nuniform sampler2D u_texture;\nin vec2 v_texcoord;\nout vec4 fragColor;\nvoid main(void) {\n vec4 rgba = texture(u_texture, v_texcoord);\n rgba.rgb *= rgba.a;\n fragColor = rgba;\n}\n ",
|
|
25
|
-
attributes: {
|
|
26
|
-
a_pos: this.buffer
|
|
27
|
-
},
|
|
28
|
-
vertexCount: 4,
|
|
29
|
-
drawMode: 5
|
|
30
|
-
});
|
|
31
|
-
this.deckFbo = device.createFramebuffer({
|
|
32
|
-
width: 1,
|
|
33
|
-
height: 1
|
|
34
|
-
});
|
|
35
|
-
this.deckInstance = new _core.Deck({
|
|
36
|
-
viewState: {},
|
|
37
|
-
controller: false,
|
|
38
|
-
gl: device.gl,
|
|
39
|
-
parameters: {
|
|
40
|
-
depthTest: true
|
|
41
|
-
},
|
|
42
|
-
_framebuffer: this.deckFbo,
|
|
43
|
-
width: null,
|
|
44
|
-
height: null,
|
|
45
|
-
_customRender: function _customRender(redrawReason) {
|
|
46
|
-
if (redrawReason === 'arcgis') {
|
|
47
|
-
_this.deckInstance._drawLayers(redrawReason);
|
|
48
|
-
} else {
|
|
49
|
-
_this.redraw();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function render(_ref) {
|
|
56
|
-
var _this2 = this;
|
|
57
|
-
|
|
58
|
-
var gl = _ref.gl,
|
|
59
|
-
width = _ref.width,
|
|
60
|
-
height = _ref.height,
|
|
61
|
-
viewState = _ref.viewState;
|
|
62
|
-
var screenFbo = gl.getParameter(36006);
|
|
63
|
-
var dpr = window.devicePixelRatio;
|
|
64
|
-
width = Math.round(width * dpr);
|
|
65
|
-
height = Math.round(height * dpr);
|
|
66
|
-
this.deckFbo.resize({
|
|
67
|
-
width: width,
|
|
68
|
-
height: height
|
|
69
|
-
});
|
|
70
|
-
this.deckInstance.setProps({
|
|
71
|
-
viewState: viewState
|
|
72
|
-
});
|
|
73
|
-
this.deckInstance.redraw('arcgis');
|
|
74
|
-
(0, _webgl.withGLParameters)(gl, {
|
|
75
|
-
blend: true,
|
|
76
|
-
blendFunc: [1, 771],
|
|
77
|
-
framebuffer: screenFbo,
|
|
78
|
-
viewport: [0, 0, width, height]
|
|
79
|
-
}, function () {
|
|
80
|
-
_this2.model.setUniforms({
|
|
81
|
-
u_texture: _this2.deckFbo
|
|
82
|
-
}).draw(_this2.context.renderPass);
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function finalizeResources() {
|
|
87
|
-
var _this$deckInstance, _this$model, _this$buffer, _this$deckFbo;
|
|
88
|
-
|
|
89
|
-
(_this$deckInstance = this.deckInstance) === null || _this$deckInstance === void 0 ? void 0 : _this$deckInstance.finalize();
|
|
90
|
-
this.deckInstance = null;
|
|
91
|
-
(_this$model = this.model) === null || _this$model === void 0 ? void 0 : _this$model.delete();
|
|
92
|
-
(_this$buffer = this.buffer) === null || _this$buffer === void 0 ? void 0 : _this$buffer.delete();
|
|
93
|
-
(_this$deckFbo = this.deckFbo) === null || _this$deckFbo === void 0 ? void 0 : _this$deckFbo.delete();
|
|
94
|
-
}
|
|
95
|
-
//# sourceMappingURL=commons.js.map
|
package/dist/es5/commons.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commons.ts"],"names":["initializeResources","device","buffer","createBuffer","Int8Array","model","Model","vs","fs","attributes","a_pos","vertexCount","drawMode","deckFbo","createFramebuffer","width","height","deckInstance","Deck","viewState","controller","gl","parameters","depthTest","_framebuffer","_customRender","redrawReason","_drawLayers","redraw","render","screenFbo","getParameter","dpr","window","devicePixelRatio","Math","round","resize","setProps","blend","blendFunc","framebuffer","viewport","setUniforms","u_texture","draw","context","renderPass","finalizeResources","finalize","delete"],"mappings":"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","sourcesContent":["/* eslint-disable no-invalid-this */\n\nimport type {Device} from '@luma.gl/core';\nimport {Model} from '@luma.gl/engine';\nimport {GL} from '@luma.gl/constants';\nimport {withGLParameters} from '@luma.gl/webgl';\n\nimport {Deck} from '@deck.gl/core';\n\nexport function initializeResources(device: Device) {\n // What is `this` referring to this function???\n this.buffer = device.createBuffer(new Int8Array([-1, -1, 1, -1, -1, 1, 1, 1]));\n\n this.model = new Model(device, {\n vs: `\\\n#version 300 es\nin vec2 a_pos;\nout vec2 v_texcoord;\nvoid main(void) {\n gl_Position = vec4(a_pos, 0.0, 1.0);\n v_texcoord = (a_pos + 1.0) / 2.0;\n}\n `,\n fs: `\\\n#version 300 es\nprecision mediump float;\nuniform sampler2D u_texture;\nin vec2 v_texcoord;\nout vec4 fragColor;\nvoid main(void) {\n vec4 rgba = texture(u_texture, v_texcoord);\n rgba.rgb *= rgba.a;\n fragColor = rgba;\n}\n `,\n attributes: {\n // eslint-disable-next-line camelcase\n a_pos: this.buffer\n },\n vertexCount: 4,\n drawMode: GL.TRIANGLE_STRIP\n });\n\n this.deckFbo = device.createFramebuffer({width: 1, height: 1});\n\n this.deckInstance = new Deck({\n // The view state will be set dynamically to track the MapView current extent.\n viewState: {},\n\n // Input is handled by the ArcGIS API for JavaScript.\n controller: false,\n\n // We use the same WebGL context as the ArcGIS API for JavaScript.\n gl: device.gl,\n\n // We need depth testing in general; we don't know what layers might be added to the deck.\n parameters: {\n depthTest: true\n },\n\n // This deck renders into an auxiliary framebuffer.\n _framebuffer: this.deckFbo,\n\n // To disable canvas resizing, since the FBO is owned by the ArcGIS API for JavaScript.\n width: null,\n height: null,\n\n _customRender: redrawReason => {\n if (redrawReason === 'arcgis') {\n this.deckInstance._drawLayers(redrawReason);\n } else {\n this.redraw();\n }\n }\n });\n}\n\nexport function render({gl, width, height, viewState}) {\n const screenFbo = gl.getParameter(gl.FRAMEBUFFER_BINDING);\n\n /* global window */\n const dpr = window.devicePixelRatio;\n width = Math.round(width * dpr);\n height = Math.round(height * dpr);\n\n this.deckFbo.resize({width, height});\n\n this.deckInstance.setProps({viewState});\n // redraw deck immediately into deckFbo\n this.deckInstance.redraw('arcgis');\n\n // We overlay the texture on top of the map using the full-screen quad.\n withGLParameters(\n gl,\n {\n blend: true,\n blendFunc: [gl.ONE, gl.ONE_MINUS_SRC_ALPHA],\n framebuffer: screenFbo,\n viewport: [0, 0, width, height]\n },\n () => {\n // eslint-disable-next-line camelcase\n this.model.setUniforms({u_texture: this.deckFbo}).draw(this.context.renderPass);\n }\n );\n}\n\nexport function finalizeResources() {\n this.deckInstance?.finalize();\n this.deckInstance = null;\n\n this.model?.delete();\n this.buffer?.delete();\n this.deckFbo?.delete();\n}\n"],"file":"commons.js"}
|