Hi, I’ve been trying to setup a simple scene using webVR on release 91.
I’ve an Oculus Rift and I’m using Firefox Nightly build.
Everything works great except from the fact that I can’t apply any translation to the camera.
The rotation and head displacement is being properly tracked by the sensors.
But in order to navigate the Scene I need to be able to move around with the keyboard or gamepad
I found many old tutorials which refer to VRControls.js & VReffect.js that seem not to apply any more on this release
I also tried rigging the camera as a child of a dummy object, but the camera is always fixed to the origin
Here is the relevant part of the code I’m using
on init function:
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.vr.enabled = true;
renderer.setSize(1366, 768);
scene = new THREE.Scene();
cam = new THREE.PerspectiveCamera(65,1.77777777,0.1,100000);
cam.position.set(0,1,0);
dolly=new THREE.Group();
scene.add(dolly);
dolly.add(cam);
I tried setting renderer.vr.userHeight to 0, 100, -100 … but the origin of the camera doens’t move at all
Looking throught the source code of webvrmanager I saw a there is a setter for “poseTarget”.
Does it have something to do with the position of the user?
Any hack I could use to affect the position?
Thanks
.setPoseTarget() defines the Object3D on which the pose coming from a VRDevice is applied. Default target is the camera. But you can define a different object and append the camera as a child to it. This approach provides more flexibility when position and orient the camera in the scene.
Can you share your code as a complete example via jsfiddle or codepen?
BTW: I forgot you are using Oculus Rift. In this case renderer.vr.userHeight does not have an effect since the VRDevice should provide stageParameters.sittingToStandingTransform.
I would suggest trying to move the whole world in relation to the camera. if you need good controller scripts, i have a class that handles all buttons and is event based
starting from
update() {
this.gamepads = navigator.getGamepads()
for (var i = 0; i < this.gamepads.length; i ++) {
if (this.gamepads[i].id == "Oculus Touch (Right)") {
if (this.gamepads[i].pose.position != null) {
this.handleController(this.gamepads[i], 0)
}
}
if (this.gamepads[i].id == "Oculus Touch (Left)") {
if (this.gamepads[i].pose.position != null) {
this.handleController(this.gamepads[i], 1)
}
}
}
}
it event bases everything like, button down, button up, button hold, and joystick events. it allso has some extra events like grabstart and grabend, where you can make any object grabbable easily. allso contorller intersection event and laser pointing is implemented.