Replies: 3 comments 3 replies
-
The skeleton of your layer class should look like this: import {Layer} from '@deck.gl/core';
class MyWebGLLayer extends Layer {
initializeState() {
// Create resources
const {gl} = this.context
this.state = {
buffer: gl.createBuffer()
}
}
updateState({changeFlags}) {
if (changeFlags.propsChanged) {
// Update resources
const {buffer} = this.state
// Update data
const bufferData = new Float32Array(...)
gl.bindBuffer(gl.ARRAY_BUFFER, buffer)
gl.bufferData(gl.ARRAY_BUFFER, bufferData, gl.STATIC_DRAW)
}
}
draw() {
// Use resources
const {buffer} = this.state
gl.bindBuffer(gl.ARRAY_BUFFER, buffer)
// Render something
gl.drawElement(...)
}
finalizeState() {
// Delete resources
const {buffer} = this.state
gl.deleteBuffer(buffer)
}
} |
Beta Was this translation helpful? Give feedback.
3 replies
-
|
I think that was ChatGPT generated, it relies on things that don't exist. https://zhuanlan.zhihu.com/p/634390324 I have had success with this approach however! |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
https://www.npmjs.com/package/@deck.gl-community/three has a good example of how to do this |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Been desperately trying to integrate three.js in one of the deck.gl custom layer for the purpose of a PoC. Basic idea is to create a cube in a custom layer using three.js and render on top of other deck.gl layers showing tiles, icons, links etc. as well as being able to integrate with the cube.
When the deck.gl layers are a more than three, the cube renders for a fraction of a second and then disappears. When there are fewer layers, the cube renders fine but as soon as I interact with the cube (rotate), the cube again disappears.
There are no errors on the console, however I get GL_INVALID_OPERATION: Insufficient buffer size warning. On further investigation, they seems to originate in the gl.drawElement in three.js.
My draw function in the custom layer is very simple, all copied from (almost non existing) material available regarding integration of three.js with deck.gl, I tried fixing this issue however I started getting another issue, location is not from current program. Trying to fix that issue, only throws more warning.
Beta Was this translation helpful? Give feedback.
All reactions