Animated <canvas> > canvasTexture > dont work in WebXr , why ? 😱

Hello,

  • i’m looking for a way to continiously drawing things in a (an animation) : it’ok !
  • applyng it to a material using canvasTexture: its ok !
  • but the problem come when i enter in WebXR session (in oculus quest 2) :
    once on WebXR , the texture look frozen, the texture became static and unanimated , like the last frame drawn in the canvas before the webxr session :confused:
    im using setAnimationLoop to render things , so the problem or limitation is elsewhere.
    Anyone know about this limit ?

Allowing to play animated canvas can offer many things (like live audio equalizer spectrum mapped on a displacementMap),
but i’m unable to do in WebXR,
i’m fallbacking using a VideoTexture and precalculated animation but its not ideal, i want to rely on realtime things.

Cheers !

Does this work in your Oculus Quest 2 (touch the button with the robot arm - the counter is drawn on a 2D canvas and updated in realtime in XR mode):

https://boytchev.github.io/virtual-robotics/examples/labels.html

Here is another example with a dynamic graph (it is a Canvas2D texture):

https://boytchev.github.io/virtual-robotics/examples/graphs.html

In case it does not work with your hardware, this is what it is suppose to look like (as recorded from my Oculus Quest 2):

2 Likes

Keep in mind… you may Not want to rerender your canvas every time in the animationLoop.

In XR, on each frame, the animationLoop function gets called twice. Once for each eye.

So you can check the xrview.eye == ‘left’ to only rerender your canvas at the beginning of the frame.

1 Like

big thanks guys @PavelBoytchev @manthrax

thanks to remember that animated canvastexture must work on WebXR,
i think i was very tired yesterday, thanks for your hints !

i used in the past the canvas of the mrDoobs stats component , as a canvastexture to monitor FPS in VR.

so, i completly cleaned up my code and thinks a part of my previous function was relyng with… requestanimationFrame #shameOnME

@manthrax very interesting, a cool clue to optimize performance for some calculations that are not mandatory at per eye render framerate.

@PavelBoytchev nice demos :slight_smile:

2 Likes