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.
Asked
Active
Viewed 645 times
-1

programmer
- 743
- 4
- 10
1 Answers
-1
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.

jscastro
- 3,422
- 1
- 9
- 27
-
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? – Andrea Jan 11 '21 at 11:20
-
AFAIK just instancing that requires to define if it’s 2D or webgl cannot be used for other purpose – jscastro Jan 11 '21 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. – programmer Jan 12 '21 at 00:02
-
If you add some code it’ll be clearer I think – jscastro Jan 12 '21 at 00:06
-
Are you setting `renderer.autoClear = false;`?? – jscastro Jan 12 '21 at 00:10