@deck.gl/arcgis 9.0.0-beta.8 → 9.0.0-beta.9

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 CHANGED
@@ -279,7 +279,7 @@ var __exports__ = (() => {
279
279
  // bundle.ts
280
280
  __reExport(bundle_exports, peer_dependency_exports);
281
281
 
282
- // src/deck-props.js
282
+ // dist/deck-props.js
283
283
  var properties = {
284
284
  layers: {},
285
285
  layerFilter: {},
@@ -333,7 +333,7 @@ var __exports__ = (() => {
333
333
  return DeckProps;
334
334
  }
335
335
 
336
- // src/deck-layer.js
336
+ // dist/deck-layer.js
337
337
  function createDeckLayer(DeckProps, Layer2, DeckLayerView2D) {
338
338
  return Layer2.createSubclass({
339
339
  properties: {
@@ -351,9 +351,7 @@ var __exports__ = (() => {
351
351
  layer: this
352
352
  });
353
353
  }
354
- console.error(
355
- "DeckLayer does not support SceneView at the moment. Use DeckRenderer instead."
356
- );
354
+ console.error("DeckLayer does not support SceneView at the moment. Use DeckRenderer instead.");
357
355
  return null;
358
356
  }
359
357
  });
@@ -4532,9 +4530,9 @@ ${source2}`;
4532
4530
  this.device.gl.transformFeedbackVaryings(this.handle, varyings, bufferMode);
4533
4531
  }
4534
4532
  this._linkShaders();
4535
- import_core18.log.time(0, `RenderPipeline ${this.id} - shaderLayout introspection`)();
4533
+ import_core18.log.time(1, `RenderPipeline ${this.id} - shaderLayout introspection`)();
4536
4534
  this.introspectedLayout = getShaderLayout(this.device.gl, this.handle);
4537
- import_core18.log.timeEnd(0, `RenderPipeline ${this.id} - shaderLayout introspection`)();
4535
+ import_core18.log.timeEnd(1, `RenderPipeline ${this.id} - shaderLayout introspection`)();
4538
4536
  this.shaderLayout = (0, import_core19.mergeShaderLayout)(this.introspectedLayout, props.shaderLayout);
4539
4537
  switch (this.props.topology) {
4540
4538
  case "triangle-fan-webgl":
@@ -5824,11 +5822,11 @@ ${source2}`;
5824
5822
  return true;
5825
5823
  }
5826
5824
 
5827
- // src/commons.ts
5825
+ // dist/commons.js
5828
5826
  var import_engine = __toESM(require_engine(), 1);
5829
5827
  var import_core29 = __toESM(require_core(), 1);
5830
5828
  function initializeResources(device) {
5831
- const deckglTexture = device.createTexture({
5829
+ const texture = device.createTexture({
5832
5830
  format: "rgba8unorm",
5833
5831
  width: 1,
5834
5832
  height: 1,
@@ -5839,15 +5837,13 @@ ${source2}`;
5839
5837
  addressModeV: "clamp-to-edge"
5840
5838
  }
5841
5839
  });
5842
- this.deckglTexture = deckglTexture;
5843
- this.buffer = device.createBuffer(new Int8Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1]));
5844
- this.model = new import_engine.Model(device, {
5840
+ const model = new import_engine.Model(device, {
5845
5841
  vs: `#version 300 es
5846
- in vec2 a_pos;
5842
+ in vec2 pos;
5847
5843
  out vec2 v_texcoord;
5848
5844
  void main(void) {
5849
- gl_Position = vec4(a_pos, 0.0, 1.0);
5850
- v_texcoord = (a_pos + 1.0) / 2.0;
5845
+ gl_Position = vec4(pos, 0.0, 1.0);
5846
+ v_texcoord = (pos + 1.0) / 2.0;
5851
5847
  }
5852
5848
  `,
5853
5849
  fs: `#version 300 es
@@ -5862,124 +5858,115 @@ void main(void) {
5862
5858
  fragColor = imageColor;
5863
5859
  }
5864
5860
  `,
5865
- bufferLayout: [{ name: "a_pos", format: "sint8x2" }],
5866
5861
  bindings: {
5867
- deckglTexture
5862
+ deckglTexture: texture
5868
5863
  },
5869
5864
  parameters: {
5870
5865
  depthWriteEnabled: true,
5871
5866
  depthCompare: "less-equal"
5872
5867
  },
5873
- attributes: {
5874
- a_pos: this.buffer
5875
- },
5876
- vertexCount: 6,
5877
- topology: "triangle-strip"
5868
+ geometry: new import_engine.Geometry({
5869
+ topology: "triangle-strip",
5870
+ attributes: {
5871
+ pos: { size: 2, value: new Int8Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1]) }
5872
+ }
5873
+ }),
5874
+ vertexCount: 6
5878
5875
  });
5879
- this.deckFbo = device.createFramebuffer({
5876
+ const fbo = device.createFramebuffer({
5880
5877
  id: "deckfbo",
5881
5878
  width: 1,
5882
5879
  height: 1,
5883
- colorAttachments: [deckglTexture]
5880
+ colorAttachments: [texture]
5884
5881
  });
5885
- this.deckInstance = new import_core29.Deck({
5882
+ const deckInstance = new import_core29.Deck({
5886
5883
  viewState: {},
5887
5884
  controller: false,
5888
- gl: device.gl,
5885
+ device,
5889
5886
  parameters: {
5890
5887
  depthTest: true
5891
5888
  },
5892
- _framebuffer: this.deckFbo,
5889
+ _framebuffer: fbo,
5893
5890
  width: null,
5894
5891
  height: null,
5895
5892
  _customRender: (redrawReason) => {
5896
5893
  if (redrawReason === "arcgis") {
5897
- this.deckInstance._drawLayers(redrawReason);
5894
+ deckInstance._drawLayers(redrawReason);
5898
5895
  } else {
5899
5896
  this.redraw();
5900
5897
  }
5901
5898
  }
5902
5899
  });
5900
+ return { deck: deckInstance, texture, fbo, model };
5903
5901
  }
5904
- function render({ gl, width, height, viewState }) {
5905
- const screenFbo = gl.getParameter(gl.FRAMEBUFFER_BINDING);
5902
+ function render(resources, viewport) {
5903
+ const { model, deck, fbo } = resources;
5904
+ const device = model.device;
5905
+ const screenFbo = device.getParametersWebGL(36006);
5906
+ const { width, height, ...viewState } = viewport;
5906
5907
  const dpr = window.devicePixelRatio;
5907
- width = Math.round(width * dpr);
5908
- height = Math.round(height * dpr);
5909
- this.deckFbo.resize({ width, height });
5910
- this.deckInstance.setProps({ viewState });
5911
- this.deckInstance.redraw("arcgis");
5912
- const device = this.deckInstance.device;
5908
+ const pixelWidth = Math.round(width * dpr);
5909
+ const pixelHeight = Math.round(height * dpr);
5910
+ fbo.resize({ width: pixelWidth, height: pixelHeight });
5911
+ deck.setProps({ viewState });
5912
+ deck.redraw("arcgis");
5913
5913
  const textureToScreenPass = device.beginRenderPass({
5914
5914
  framebuffer: screenFbo,
5915
- parameters: { viewport: [0, 0, width, height] },
5915
+ parameters: { viewport: [0, 0, pixelWidth, pixelHeight] },
5916
5916
  clearColor: [0, 0, 0, 0],
5917
5917
  clearDepth: 1
5918
5918
  });
5919
- device.withParametersWebGL(
5920
- {
5921
- blend: true,
5922
- blendFunc: [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]
5923
- },
5924
- () => {
5925
- this.model.setBindings({
5926
- deckglTexture: this.deckFbo.colorAttachments[0]
5927
- });
5928
- this.model.draw(textureToScreenPass);
5929
- }
5930
- );
5919
+ device.withParametersWebGL({
5920
+ blend: true,
5921
+ blendFunc: [1, 771]
5922
+ }, () => {
5923
+ model.draw(textureToScreenPass);
5924
+ });
5931
5925
  }
5932
- function finalizeResources() {
5933
- this.deckInstance?.finalize();
5934
- this.deckInstance = null;
5935
- this.model?.delete();
5936
- this.buffer?.delete();
5937
- this.deckFbo?.delete();
5938
- this.deckglTexture?.delete();
5926
+ function finalizeResources(resources) {
5927
+ resources.deck.finalize();
5928
+ resources.model.destroy();
5929
+ resources.fbo.destroy();
5930
+ resources.texture.destroy();
5939
5931
  }
5940
5932
 
5941
- // src/deck-layer-view-2d.js
5933
+ // dist/deck-layer-view-2d.js
5942
5934
  function createDeckLayerView2D(BaseLayerViewGL2D) {
5943
5935
  return BaseLayerViewGL2D.createSubclass({
5944
5936
  properties: {
5945
- deckgl: {},
5946
- deckFbo: {},
5947
- model: {},
5948
- buffer: {}
5937
+ resources: null
5949
5938
  },
5950
5939
  attach() {
5951
5940
  const gl = this.context;
5952
5941
  const device = WebGLDevice.attach(gl);
5953
- initializeResources.call(this, device);
5954
- this.layer.deck.on("change", (props) => this.deckInstance.setProps(props));
5955
- this.deckInstance.setProps(this.layer.deck.toJSON());
5942
+ this.resources = initializeResources.call(this, device);
5943
+ this.layer.deck.on("change", (props) => this.resources.deck.setProps(props));
5944
+ this.resources.deck.setProps(this.layer.deck.toJSON());
5956
5945
  },
5957
5946
  redraw() {
5958
5947
  this.requestRender();
5959
5948
  },
5960
5949
  detach() {
5961
- finalizeResources.call(this);
5950
+ finalizeResources(this.resources);
5951
+ this.resources = null;
5962
5952
  },
5963
5953
  render(renderParameters) {
5964
5954
  const [width, height] = this.view.state.size;
5965
5955
  const state = renderParameters.state;
5966
- render.call(this, {
5967
- gl: renderParameters.context,
5956
+ render(this.resources, {
5968
5957
  width,
5969
5958
  height,
5970
- viewState: {
5971
- latitude: this.view.center.latitude,
5972
- longitude: this.view.center.longitude,
5973
- zoom: this.view.featuresTilingScheme.scaleToLevel(state.scale),
5974
- bearing: -state.rotation,
5975
- pitch: 0
5976
- }
5959
+ latitude: this.view.center.latitude,
5960
+ longitude: this.view.center.longitude,
5961
+ zoom: this.view.featuresTilingScheme.scaleToLevel(state.scale),
5962
+ bearing: -state.rotation,
5963
+ pitch: 0
5977
5964
  });
5978
5965
  }
5979
5966
  });
5980
5967
  }
5981
5968
 
5982
- // src/deck-renderer.js
5969
+ // dist/deck-renderer.js
5983
5970
  function arcgisFOVToDeckAltitude(fov, aspectRatio) {
5984
5971
  const D = Math.sqrt(1 + aspectRatio ** 2);
5985
5972
  const halfFOV = fov / 2 / 180 * Math.PI;
@@ -5988,44 +5975,46 @@ void main(void) {
5988
5975
  function createDeckRenderer(DeckProps, externalRenderers) {
5989
5976
  class DeckRenderer {
5990
5977
  constructor(view, props) {
5978
+ this.resources = null;
5991
5979
  this.view = view;
5992
5980
  this.deck = new DeckProps(props);
5993
5981
  }
5994
5982
  setup(context) {
5995
5983
  const gl = context.gl;
5996
- initializeResources.call(this, gl);
5997
- this.deck.on("change", (props) => this.deckInstance.setProps(props));
5998
- this.deckInstance.setProps(this.deck.toJSON());
5984
+ const device = WebGLDevice.attach(gl);
5985
+ const resources = initializeResources.call(this, device);
5986
+ this.deck.on("change", (props) => resources.deck.setProps(props));
5987
+ resources.deck.setProps(this.deck.toJSON());
5988
+ this.resources = resources;
5999
5989
  }
6000
5990
  dispose() {
6001
- finalizeResources.call(this);
5991
+ if (this.resources) {
5992
+ finalizeResources(this.resources);
5993
+ }
6002
5994
  }
6003
5995
  redraw() {
6004
5996
  externalRenderers.requestRender(this.view);
6005
5997
  }
6006
- render(context) {
5998
+ render() {
6007
5999
  const [width, height] = this.view.size;
6008
- render.call(this, {
6009
- gl: context.gl,
6000
+ render(this.resources, {
6010
6001
  width,
6011
6002
  height,
6012
- viewState: {
6013
- latitude: this.view.center.latitude,
6014
- longitude: this.view.center.longitude,
6015
- altitude: arcgisFOVToDeckAltitude(this.view.camera.fov, width / height),
6016
- zoom: this.view.zoom,
6017
- bearing: this.view.camera.heading,
6018
- pitch: this.view.camera.tilt
6019
- }
6003
+ latitude: this.view.center.latitude,
6004
+ longitude: this.view.center.longitude,
6005
+ altitude: arcgisFOVToDeckAltitude(this.view.camera.fov, width / height),
6006
+ zoom: this.view.zoom,
6007
+ bearing: this.view.camera.heading,
6008
+ pitch: this.view.camera.tilt
6020
6009
  });
6021
6010
  }
6022
6011
  }
6023
6012
  return DeckRenderer;
6024
6013
  }
6025
6014
 
6026
- // src/load-modules.js
6015
+ // dist/load-modules.js
6027
6016
  var import_esri_loader = __toESM(require_esri_loader(), 1);
6028
- var arcGIS = null;
6017
+ var arcGIS;
6029
6018
  async function loadArcGISModules(modules, loadScriptOptions) {
6030
6019
  const namespace = Array.isArray(modules) ? null : modules;
6031
6020
  await loadArcGISModule(namespace, loadScriptOptions);
@@ -6036,28 +6025,24 @@ void main(void) {
6036
6025
  }
6037
6026
  return arcGIS;
6038
6027
  }
6039
- function loadArcGISModule(esri, loadScriptOptions) {
6028
+ async function loadArcGISModule(esri, loadScriptOptions) {
6040
6029
  if (arcGIS) {
6041
6030
  return arcGIS;
6042
6031
  }
6043
6032
  if (esri) {
6044
- const Layer2 = esri.layers.Layer;
6045
- const Accessor2 = esri.core.Accessor;
6046
- const BaseLayerViewGL2D = esri.views["2d"].layers.BaseLayerViewGL2D;
6047
- const externalRenderers = esri.views["3d"].externalRenderers;
6048
- return initialize(Layer2, Accessor2, BaseLayerViewGL2D, externalRenderers);
6049
- }
6050
- return (0, import_esri_loader.loadModules)(
6051
- [
6052
- "esri/layers/Layer",
6053
- "esri/core/Accessor",
6054
- "esri/views/2d/layers/BaseLayerViewGL2D",
6055
- "esri/views/3d/externalRenderers"
6056
- ],
6057
- loadScriptOptions
6058
- ).then(([Layer2, Accessor2, BaseLayerViewGL2D, externalRenderers]) => {
6059
- return initialize(Layer2, Accessor2, BaseLayerViewGL2D, externalRenderers);
6060
- });
6033
+ const Layer3 = esri.layers.Layer;
6034
+ const Accessor3 = esri.core.Accessor;
6035
+ const BaseLayerViewGL2D2 = esri.views["2d"].layers.BaseLayerViewGL2D;
6036
+ const externalRenderers2 = esri.views["3d"].externalRenderers;
6037
+ return initialize(Layer3, Accessor3, BaseLayerViewGL2D2, externalRenderers2);
6038
+ }
6039
+ const [Layer2, Accessor2, BaseLayerViewGL2D, externalRenderers] = await (0, import_esri_loader.loadModules)([
6040
+ "esri/layers/Layer",
6041
+ "esri/core/Accessor",
6042
+ "esri/views/2d/layers/BaseLayerViewGL2D",
6043
+ "esri/views/3d/externalRenderers"
6044
+ ], loadScriptOptions);
6045
+ return initialize(Layer2, Accessor2, BaseLayerViewGL2D, externalRenderers);
6061
6046
  }
6062
6047
  function initialize(Layer2, Accessor2, BaseLayerViewGL2D, externalRenderers) {
6063
6048
  const DeckProps = createDeckProps(Accessor2);