@deck.gl/arcgis
Advanced tools
Comparing version 9.0.0-beta.7 to 9.0.0-beta.8
@@ -6,3 +6,3 @@ { | ||
"type": "module", | ||
"version": "9.0.0-beta.7", | ||
"version": "9.0.0-beta.8", | ||
"publishConfig": { | ||
@@ -40,3 +40,3 @@ "access": "public" | ||
"dependencies": { | ||
"@luma.gl/constants": "9.0.0-beta.8", | ||
"@luma.gl/constants": "9.0.0-beta.10", | ||
"esri-loader": "^3.3.0" | ||
@@ -47,6 +47,6 @@ }, | ||
"@deck.gl/core": "^9.0.0-beta", | ||
"@luma.gl/core": "9.0.0-beta.8", | ||
"@luma.gl/engine": "9.0.0-beta.8" | ||
"@luma.gl/core": "9.0.0-beta.10", | ||
"@luma.gl/engine": "9.0.0-beta.10" | ||
}, | ||
"gitHead": "1676f8d6f7534259996bf58a7b7e1fba6f3af9ae" | ||
"gitHead": "8867a1047c2693d44e4af9507c296cf7ab61f9e8" | ||
} |
@@ -5,10 +5,25 @@ /* eslint-disable no-invalid-this */ | ||
import {Model} from '@luma.gl/engine'; | ||
import {GL} from '@luma.gl/constants'; | ||
import {Deck} from '@deck.gl/core'; | ||
import {WebGLDevice} from '@luma.gl/webgl'; | ||
export function initializeResources(device: Device) { | ||
// What is `this` referring to this function??? | ||
this.buffer = device.createBuffer(new Int8Array([-1, -1, 1, -1, -1, 1, 1, 1])); | ||
// 'this' refers to the BaseLayerViewGL2D class from | ||
// import BaseLayerViewGL2D from "@arcgis/core/views/2d/layers/BaseLayerViewGL2D.js"; | ||
const deckglTexture = device.createTexture({ | ||
format: 'rgba8unorm', | ||
width: 1, | ||
height: 1, | ||
sampler: { | ||
minFilter: 'linear', | ||
magFilter: 'linear', | ||
addressModeU: 'clamp-to-edge', | ||
addressModeV: 'clamp-to-edge' | ||
} | ||
}); | ||
this.deckglTexture = deckglTexture; | ||
this.buffer = device.createBuffer(new Int8Array([-1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1])); | ||
this.model = new Model(device, { | ||
@@ -27,11 +42,20 @@ vs: `\ | ||
precision mediump float; | ||
uniform sampler2D u_texture; | ||
uniform sampler2D deckglTexture; | ||
in vec2 v_texcoord; | ||
out vec4 fragColor; | ||
void main(void) { | ||
vec4 rgba = texture(u_texture, v_texcoord); | ||
rgba.rgb *= rgba.a; | ||
fragColor = rgba; | ||
vec4 imageColor = texture(deckglTexture, v_texcoord); | ||
imageColor.rgb *= imageColor.a; | ||
fragColor = imageColor; | ||
} | ||
`, | ||
bufferLayout: [{name: 'a_pos', format: 'sint8x2'}], | ||
bindings: { | ||
deckglTexture | ||
}, | ||
parameters: { | ||
depthWriteEnabled: true, | ||
depthCompare: 'less-equal' | ||
}, | ||
attributes: { | ||
@@ -41,7 +65,12 @@ // eslint-disable-next-line camelcase | ||
}, | ||
vertexCount: 4, | ||
drawMode: GL.TRIANGLE_STRIP | ||
vertexCount: 6, | ||
topology: 'triangle-strip' | ||
}); | ||
this.deckFbo = device.createFramebuffer({width: 1, height: 1}); | ||
this.deckFbo = device.createFramebuffer({ | ||
id: 'deckfbo', | ||
width: 1, | ||
height: 1, | ||
colorAttachments: [deckglTexture] | ||
}); | ||
@@ -56,3 +85,3 @@ this.deckInstance = new Deck({ | ||
// We use the same WebGL context as the ArcGIS API for JavaScript. | ||
gl: device.gl, | ||
gl: (device as WebGLDevice).gl, | ||
@@ -96,13 +125,21 @@ // We need depth testing in general; we don't know what layers might be added to the deck. | ||
// We overlay the texture on top of the map using the full-screen quad. | ||
const device: Device = this.deckInstance.deck.device; | ||
const device: WebGLDevice = this.deckInstance.device; | ||
const textureToScreenPass = device.beginRenderPass({ | ||
framebuffer: screenFbo, | ||
parameters: {viewport: [0, 0, width, height]}, | ||
clearColor: [0, 0, 0, 0], | ||
clearDepth: 1 | ||
}); | ||
device.withParametersWebGL( | ||
{ | ||
blend: true, | ||
blendFunc: [gl.ONE, gl.ONE_MINUS_SRC_ALPHA], | ||
framebuffer: screenFbo, | ||
viewport: [0, 0, width, height] | ||
blendFunc: [gl.ONE, gl.ONE_MINUS_SRC_ALPHA] | ||
}, | ||
() => { | ||
// eslint-disable-next-line camelcase | ||
this.model.setUniforms({u_texture: this.deckFbo}).draw(this.context.renderPass); | ||
this.model.setBindings({ | ||
deckglTexture: this.deckFbo.colorAttachments[0] | ||
}); | ||
this.model.draw(textureToScreenPass); | ||
} | ||
@@ -119,2 +156,3 @@ ); | ||
this.deckFbo?.delete(); | ||
this.deckglTexture?.delete(); | ||
} |
@@ -0,1 +1,2 @@ | ||
import {WebGLDevice} from '@luma.gl/webgl'; | ||
import {initializeResources, render, finalizeResources} from './commons'; | ||
@@ -17,4 +18,6 @@ | ||
const gl = this.context; | ||
initializeResources.call(this, gl); | ||
const device = WebGLDevice.attach(gl); | ||
initializeResources.call(this, device); | ||
// Update deck props | ||
@@ -21,0 +24,0 @@ this.layer.deck.on('change', props => this.deckInstance.setProps(props)); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
371320
6873
1
+ Added@luma.gl/constants@9.0.0-beta.10(transitive)
+ Added@luma.gl/core@9.0.0-beta.10(transitive)
+ Added@luma.gl/engine@9.0.0-beta.10(transitive)
+ Added@luma.gl/shadertools@9.0.0-beta.10(transitive)
- Removed@luma.gl/constants@9.0.0-beta.8(transitive)
- Removed@luma.gl/core@9.0.0-beta.8(transitive)
- Removed@luma.gl/engine@9.0.0-beta.8(transitive)
- Removed@luma.gl/shadertools@9.0.0-beta.8(transitive)