r34
r34

Reputation: 332

WebVR - update scene independently for each eye

I try to implement a scene, where an object is updated in different way for each eye (eg. I want to project opposite rotation of box for each eye).

I have demo application written with WebGL using Three.js as described in Google Developers tutorial.

But there is only one scene, containing one mesh, with single update function. I can't find way to implement separation of update, so it's done seperately for each eye (just as rendering is done) and wonder if it's even possible.

Anybody has any experiences with similar case?

Upvotes: 1

Views: 375

Answers (1)

Paul-Jan
Paul-Jan

Reputation: 17278

Your use case is rather unusual (and may I say, eye-watering), so basically the answer is no: Three.js has abstracted away the left/right eye dichotomy of VR. Internally it renders the scene using an array of 2 camera's, with the correct left/eye setting.

Fortunately, every object has an onBeforeRender(renderer, scene, camera, ...) event. If you hook that event, and find a way to distinguish the left/right eye camera you should be able to modify the orientation just before it gets rendered.

A (perhaps too) simple way to distinguish the camera's would be to keep a track of the index with a counter.

Upvotes: 1

Related Questions