@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.
Files changed (61) hide show
  1. package/dist/commons.d.ts +26 -0
  2. package/dist/commons.d.ts.map +1 -0
  3. package/dist/commons.js +136 -0
  4. package/dist/deck-layer-view-2d.d.ts +2 -0
  5. package/dist/deck-layer-view-2d.d.ts.map +1 -0
  6. package/dist/deck-layer-view-2d.js +57 -0
  7. package/dist/deck-layer.d.ts +2 -0
  8. package/dist/deck-layer.d.ts.map +1 -0
  9. package/dist/deck-layer.js +27 -0
  10. package/dist/deck-props.d.ts +2 -0
  11. package/dist/deck-props.d.ts.map +1 -0
  12. package/dist/deck-props.js +53 -0
  13. package/dist/deck-renderer.d.ts +15 -0
  14. package/dist/deck-renderer.d.ts.map +1 -0
  15. package/dist/deck-renderer.js +56 -0
  16. package/dist/dist.dev.js +227 -8802
  17. package/dist/index.cjs +393 -0
  18. package/dist/index.cjs.map +7 -0
  19. package/dist/index.d.ts +15 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/{esm/index.js → index.js} +7 -6
  22. package/dist/load-modules.d.ts +9 -0
  23. package/dist/load-modules.d.ts.map +1 -0
  24. package/dist/load-modules.js +46 -0
  25. package/dist.min.js +10 -140
  26. package/package.json +20 -11
  27. package/src/commons.ts +138 -69
  28. package/src/{deck-layer-view-2d.js → deck-layer-view-2d.ts} +30 -18
  29. package/src/deck-renderer.ts +73 -0
  30. package/src/{load-modules.js → load-modules.ts} +20 -9
  31. package/dist/es5/commons.js +0 -95
  32. package/dist/es5/commons.js.map +0 -1
  33. package/dist/es5/deck-layer-view-2d.js +0 -62
  34. package/dist/es5/deck-layer-view-2d.js.map +0 -1
  35. package/dist/es5/deck-layer.js +0 -31
  36. package/dist/es5/deck-layer.js.map +0 -1
  37. package/dist/es5/deck-props.js +0 -98
  38. package/dist/es5/deck-props.js.map +0 -1
  39. package/dist/es5/deck-renderer.js +0 -78
  40. package/dist/es5/deck-renderer.js.map +0 -1
  41. package/dist/es5/index.js +0 -46
  42. package/dist/es5/index.js.map +0 -1
  43. package/dist/es5/load-modules.js +0 -109
  44. package/dist/es5/load-modules.js.map +0 -1
  45. package/dist/esm/commons.js +0 -96
  46. package/dist/esm/commons.js.map +0 -1
  47. package/dist/esm/deck-layer-view-2d.js +0 -45
  48. package/dist/esm/deck-layer-view-2d.js.map +0 -1
  49. package/dist/esm/deck-layer.js +0 -27
  50. package/dist/esm/deck-layer.js.map +0 -1
  51. package/dist/esm/deck-props.js +0 -64
  52. package/dist/esm/deck-props.js.map +0 -1
  53. package/dist/esm/deck-renderer.js +0 -52
  54. package/dist/esm/deck-renderer.js.map +0 -1
  55. package/dist/esm/index.js.map +0 -1
  56. package/dist/esm/load-modules.js +0 -51
  57. package/dist/esm/load-modules.js.map +0 -1
  58. package/src/deck-renderer.js +0 -56
  59. /package/src/{deck-layer.js → deck-layer.ts} +0 -0
  60. /package/src/{deck-props.js → deck-props.ts} +0 -0
  61. /package/src/{index.js → index.ts} +0 -0
@@ -0,0 +1,26 @@
1
+ import { Model } from '@luma.gl/engine';
2
+ import { Deck } from '@deck.gl/core';
3
+ import type { Texture, Framebuffer } from '@luma.gl/core';
4
+ interface Renderer {
5
+ redraw: () => void;
6
+ }
7
+ export type RenderResources = {
8
+ deck: Deck;
9
+ texture: Texture;
10
+ model: Model;
11
+ fbo: Framebuffer;
12
+ };
13
+ export declare function initializeResources(this: Renderer, gl: WebGL2RenderingContext): Promise<RenderResources>;
14
+ export declare function render(resources: RenderResources, viewport: {
15
+ width: number;
16
+ height: number;
17
+ longitude: number;
18
+ latitude: number;
19
+ zoom: number;
20
+ altitude?: number;
21
+ pitch: number;
22
+ bearing: number;
23
+ }): void;
24
+ export declare function finalizeResources(resources: RenderResources): void;
25
+ export {};
26
+ //# sourceMappingURL=commons.d.ts.map
@@ -0,0 +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,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"}
@@ -0,0 +1,136 @@
1
+ /* eslint-disable no-invalid-this */
2
+ import { GL } from '@luma.gl/constants';
3
+ import { Model, Geometry } from '@luma.gl/engine';
4
+ import { Deck } from '@deck.gl/core';
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);
27
+ const texture = device.createTexture({
28
+ format: 'rgba8unorm',
29
+ width: 1,
30
+ height: 1,
31
+ sampler: {
32
+ minFilter: 'linear',
33
+ magFilter: 'linear',
34
+ addressModeU: 'clamp-to-edge',
35
+ addressModeV: 'clamp-to-edge'
36
+ }
37
+ });
38
+ const model = new Model(device, {
39
+ vs: `\
40
+ #version 300 es
41
+ in vec2 pos;
42
+ out vec2 v_texcoord;
43
+ void main(void) {
44
+ gl_Position = vec4(pos, 0.0, 1.0);
45
+ v_texcoord = (pos + 1.0) / 2.0;
46
+ }
47
+ `,
48
+ fs: `\
49
+ #version 300 es
50
+ precision mediump float;
51
+ uniform sampler2D deckglTexture;
52
+ in vec2 v_texcoord;
53
+ out vec4 fragColor;
54
+
55
+ void main(void) {
56
+ vec4 imageColor = texture(deckglTexture, v_texcoord);
57
+ imageColor.rgb *= imageColor.a;
58
+ fragColor = imageColor;
59
+ }
60
+ `,
61
+ bindings: {
62
+ deckglTexture: texture
63
+ },
64
+ parameters: {
65
+ depthWriteEnabled: true,
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'
73
+ },
74
+ geometry: new Geometry({
75
+ topology: 'triangle-strip',
76
+ attributes: {
77
+ pos: { size: 2, value: new Int8Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1]) }
78
+ }
79
+ }),
80
+ vertexCount: 6
81
+ });
82
+ const fbo = device.createFramebuffer({
83
+ id: 'deckfbo',
84
+ width: 1,
85
+ height: 1,
86
+ colorAttachments: [texture],
87
+ depthStencilAttachment: 'depth16unorm'
88
+ });
89
+ deckInstance.setProps({
90
+ // This deck renders into an auxiliary framebuffer.
91
+ _framebuffer: fbo,
92
+ _customRender: redrawReason => {
93
+ if (redrawReason === 'arcgis') {
94
+ deckInstance._drawLayers(redrawReason);
95
+ }
96
+ else {
97
+ this.redraw();
98
+ }
99
+ }
100
+ });
101
+ return { deck: deckInstance, texture, fbo, model };
102
+ }
103
+ export function render(resources, viewport) {
104
+ const { model, deck, fbo } = resources;
105
+ const device = model.device;
106
+ // @ts-ignore device.getParametersWebGL should return `any` not `void`?
107
+ const screenFbo = device.getParametersWebGL(36006);
108
+ const { width, height, ...viewState } = viewport;
109
+ /* global window */
110
+ const dpr = window.devicePixelRatio;
111
+ const pixelWidth = Math.round(width * dpr);
112
+ const pixelHeight = Math.round(height * dpr);
113
+ fbo.resize({ width: pixelWidth, height: pixelHeight });
114
+ deck.setProps({ viewState });
115
+ // redraw deck immediately into deckFbo
116
+ deck.redraw('arcgis');
117
+ // We overlay the texture on top of the map using the full-screen quad.
118
+ const textureToScreenPass = device.beginRenderPass({
119
+ framebuffer: screenFbo,
120
+ parameters: { viewport: [0, 0, pixelWidth, pixelHeight] },
121
+ clearColor: false,
122
+ clearDepth: false
123
+ });
124
+ try {
125
+ model.draw(textureToScreenPass);
126
+ }
127
+ finally {
128
+ textureToScreenPass.end();
129
+ }
130
+ }
131
+ export function finalizeResources(resources) {
132
+ resources.deck.finalize();
133
+ resources.model.destroy();
134
+ resources.fbo.destroy();
135
+ resources.texture.destroy();
136
+ }
@@ -0,0 +1,2 @@
1
+ export default function createDeckLayerView2D(BaseLayerViewGL2D: any): any;
2
+ //# sourceMappingURL=deck-layer-view-2d.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,57 @@
1
+ import { initializeResources, render, finalizeResources } from "./commons.js";
2
+ export default function createDeckLayerView2D(BaseLayerViewGL2D) {
3
+ return BaseLayerViewGL2D.createSubclass({
4
+ properties: {
5
+ cancelInitialization: null,
6
+ resources: null
7
+ },
8
+ // Attach is called as soon as the layer view is ready to start rendering.
9
+ async attach() {
10
+ // We use a full-screen quad and shaders to composite the frame rendered
11
+ // with deck.gl on top of the MapView. Composition uses the MapView context.
12
+ const gl = this.context;
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;
22
+ // Update deck props
23
+ this.layer.deck.on('change', props => resources.deck.setProps(props));
24
+ // We need to start drawing the deck.gl layer immediately.
25
+ resources.deck.setProps(this.layer.deck.toJSON());
26
+ },
27
+ redraw() {
28
+ this.requestRender();
29
+ },
30
+ // Called when the layer must be destroyed.
31
+ detach() {
32
+ this.cancelInitialization?.();
33
+ if (this.resources) {
34
+ finalizeResources(this.resources);
35
+ this.resources = null;
36
+ }
37
+ },
38
+ // Called every time that the layer view must be rendered.
39
+ render(renderParameters) {
40
+ if (!this.resources) {
41
+ return;
42
+ }
43
+ const [width, height] = this.view.state.size;
44
+ // The view state must be kept in-sync with the MapView of the ArcGIS API.
45
+ const state = renderParameters.state;
46
+ render(this.resources, {
47
+ width,
48
+ height,
49
+ latitude: this.view.center.latitude,
50
+ longitude: this.view.center.longitude,
51
+ zoom: this.view.featuresTilingScheme.scaleToLevel(state.scale),
52
+ bearing: -state.rotation,
53
+ pitch: 0
54
+ });
55
+ }
56
+ });
57
+ }
@@ -0,0 +1,2 @@
1
+ export default function createDeckLayer(DeckProps: any, Layer: any, DeckLayerView2D: any): any;
2
+ //# sourceMappingURL=deck-layer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deck-layer.d.ts","sourceRoot":"","sources":["../src/deck-layer.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,SAAS,KAAA,EAAE,KAAK,KAAA,EAAE,eAAe,KAAA,OAgCxE"}
@@ -0,0 +1,27 @@
1
+ export default function createDeckLayer(DeckProps, Layer, DeckLayerView2D) {
2
+ // A layer that displays inside a MapView using an instance
3
+ // of the layer view defined above.
4
+ return Layer.createSubclass({
5
+ properties: {
6
+ deck: {},
7
+ blendMode: {},
8
+ effect: {}
9
+ },
10
+ constructor() {
11
+ this.deck = new DeckProps();
12
+ },
13
+ // Called by the MapView whenever a layer view
14
+ // needs to be created for a given layer.
15
+ createLayerView(view) {
16
+ if (view.type === '2d') {
17
+ return new DeckLayerView2D({
18
+ view,
19
+ layer: this
20
+ });
21
+ }
22
+ // eslint-disable-next-line
23
+ console.error('DeckLayer does not support SceneView at the moment. Use DeckRenderer instead.');
24
+ return null;
25
+ }
26
+ });
27
+ }
@@ -0,0 +1,2 @@
1
+ export default function createDeckProps(Accessor: any): any;
2
+ //# sourceMappingURL=deck-props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deck-props.d.ts","sourceRoot":"","sources":["../src/deck-props.ts"],"names":[],"mappings":"AAqBA,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,QAAQ,KAAA,OAsC/C"}
@@ -0,0 +1,53 @@
1
+ const properties = {
2
+ layers: {},
3
+ layerFilter: {},
4
+ parameters: {},
5
+ effects: {},
6
+ pickingRadius: {},
7
+ onBeforeRender: {},
8
+ onAfterRender: {},
9
+ onClick: {},
10
+ onHover: {},
11
+ onDragStart: {},
12
+ onDrag: {},
13
+ onDragEnd: {},
14
+ onError: {},
15
+ debug: {},
16
+ drawPickingColors: {},
17
+ getCursor: {},
18
+ getTooltip: {}
19
+ };
20
+ /* eslint-disable callback-return */
21
+ export default function createDeckProps(Accessor) {
22
+ const DeckProps = Accessor.createSubclass({
23
+ properties,
24
+ constructor() {
25
+ this._callbacks = {};
26
+ this.watch(Object.keys(properties), (newValue, oldValue, propName) => {
27
+ this.emit('change', { [propName]: newValue });
28
+ });
29
+ },
30
+ on(eventName, cb) {
31
+ this._callbacks[eventName] = this._callbacks[eventName] || [];
32
+ this._callbacks[eventName].push(cb);
33
+ },
34
+ emit(eventName, details) {
35
+ const callbacks = this._callbacks[eventName];
36
+ if (callbacks) {
37
+ for (const cb of callbacks) {
38
+ cb(details);
39
+ }
40
+ }
41
+ },
42
+ toJSON() {
43
+ const result = {};
44
+ for (const key of this.keys()) {
45
+ if (this[key] !== undefined) {
46
+ result[key] = this[key];
47
+ }
48
+ }
49
+ return result;
50
+ }
51
+ });
52
+ return DeckProps;
53
+ }
@@ -0,0 +1,15 @@
1
+ import { RenderResources } from "./commons.js";
2
+ import SceneView from '@arcgis/core/views/SceneView';
3
+ export default function createDeckRenderer(DeckProps: any, externalRenderers: any): {
4
+ new (view: SceneView, props: DeckProps): {
5
+ view: SceneView;
6
+ deck: any;
7
+ resources: RenderResources | null;
8
+ cancelInitialization: (() => void) | null;
9
+ setup(context: any): Promise<void>;
10
+ dispose(): void;
11
+ redraw(): void;
12
+ render(): void;
13
+ };
14
+ };
15
+ //# sourceMappingURL=deck-renderer.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,56 @@
1
+ /* eslint-disable no-invalid-this */
2
+ import { initializeResources, render, finalizeResources } from "./commons.js";
3
+ /** Convert ArcGIS FOV to WebMercatorViewport altitude */
4
+ function arcgisFOVToDeckAltitude(fov, aspectRatio) {
5
+ // ArcGIS fov is corner-to-corner
6
+ const D = Math.sqrt(1 + aspectRatio ** 2);
7
+ const halfFOV = (fov / 2 / 180) * Math.PI;
8
+ return D / 2 / Math.tan(halfFOV);
9
+ }
10
+ export default function createDeckRenderer(DeckProps, externalRenderers) {
11
+ class DeckRenderer {
12
+ constructor(view, props) {
13
+ this.resources = null;
14
+ this.cancelInitialization = null;
15
+ this.view = view;
16
+ this.deck = new DeckProps(props);
17
+ }
18
+ async setup(context) {
19
+ const gl = context.gl;
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
+ }
28
+ this.deck.on('change', props => resources.deck.setProps(props));
29
+ resources.deck.setProps(this.deck.toJSON());
30
+ this.resources = resources;
31
+ }
32
+ dispose() {
33
+ this.cancelInitialization?.();
34
+ if (this.resources) {
35
+ finalizeResources(this.resources);
36
+ }
37
+ }
38
+ redraw() {
39
+ externalRenderers.requestRender(this.view);
40
+ }
41
+ render() {
42
+ const [width, height] = this.view.size;
43
+ render(this.resources, {
44
+ width,
45
+ height,
46
+ latitude: this.view.center.latitude,
47
+ longitude: this.view.center.longitude,
48
+ altitude: arcgisFOVToDeckAltitude(this.view.camera.fov, width / height),
49
+ zoom: this.view.zoom,
50
+ bearing: this.view.camera.heading,
51
+ pitch: this.view.camera.tilt
52
+ });
53
+ }
54
+ }
55
+ return DeckRenderer;
56
+ }