2

I'm using three v 67's WebGLRenderTarget to render a second camera/scene to a buffer for future use in a texture. Standard stuff in Three.js, but it dies a silent death in CocoonJS.

I have tried similar ways of accessing the data in CocoonJS (accessing gl.readPixels straight from the context, similar to Three.js Retrieve data from WebGLRenderTarget (water sim) ). But nothing seems to work. Has anybody else run into this?

Community
  • 1
  • 1
Alex Smith
  • 21
  • 1

1 Answers1

2

I have debugged the native C++ code of CocoonJS running the Three.js demo and I've found the problem.

Three.js creates a framebuffer for the WebGLRenderTarget object, attaches the color buffer (the texture), creates a renderBuffer and attaches a depth/stencil renderbuffer to it. The problem is in the second argument of the WebGL renderbufferStorage method which causes an incomplete framebuffer status. Three.js should check that error (using checkFramebufferStatus method) to avoid the silent error but it seems that it doesn't.

I have commited the fix and it will be ready on the next CocoonJS release.

For now you can fix it on your JS code (in the next release you won't need this fix)

Just replace this line in Three.js

j.renderbufferStorage(j.RENDERBUFFER,j.DEPTH_STENCIL,b.width,b.height)

With this one:

j.renderbufferStorage(j.RENDERBUFFER,navigator.isCocoonJS?35056:j.DEPTH_STENCIL,b.width,b.height)

Good luck with your game :)

MortimerGoro
  • 3,687
  • 2
  • 16
  • 18