I have a WebGLRenderingContext
(XR-compatible) that is being drawn on by regular WebGL calls, and I also want to render on it using a Three.js WebGLRender
. For some reason, creating a THREE.WebGLRenderer
using the existing context (even if render
is never called) makes the canvas go blank, and no drawing shows up after that.
Add a comment
|
1 Answer
If you check HTML5 spec you’ll see you cannot share the context for 2D and webgl. A workaround could be to get a new context from a hidden canvas, that’s what some websites do.
-
Uh, but @programmer didn't say they were using the canvas for 2D, but that it would be used for WebGL by both THREE.js and directly?– mysteryJan 11, 2021 at 11:20
-
AFAIK just instancing that requires to define if it’s 2D or webgl cannot be used for other purpose– jscastroJan 11, 2021 at 11:22
-
The canvas is only used for WebGL, and the
WebGLRenderer
is created using an existing context, so there should only be one context from the canvas. Jan 12, 2021 at 0:02 -
-