Hey there,
I got another issue…
I did some vr apps with three js already and they worked pretty good. This time hoewever it is not working, so I must have made some mistake, that I can’t see…
So first of all, to start in a simple way, I enable vr
initRenderer() {
let w = this.m_domParent.offsetWidth;
let h = this.m_domParent.offsetHeight;
this.m_renderer = new THREE.WebGLRenderer({
antialias: true,
alpha: true
});
this.m_renderer.setPixelRatio(window.devicePixelRatio);
this.m_renderer.setSize(w , h);
this.m_renderer.shadowMap.enabled = true;
this.m_renderer.shadowMap.type = THREE.VSMShadowMap;
this.m_renderer.xr.enabled = true;
this.m_domParent.appendChild(this.m_renderer.domElement);
}
then I add the “enter vr button”
initVR() {
document.body.appendChild(VRButton.createButton(this.m_renderer));
}
I also changed the animation loop
animateScene() {
let self = this;
function animate() {
self.m_controls.update();
self.m_renderer.render( self.m_scene, self.m_camera );
}
self.m_renderer.setAnimationLoop(animate);
//requestAnimationFrame( () => {self.animateScene(); } );
}
On my desktop everything looks just fine.
On my occulus in the “normal” browser view, everything looks just fine as well.
When I enter vr the background gets rendered (clear color) but I can’t see any content.
To test, I change the background color and the new color applies to the vr scene, but still no content.
Then I tried to force to look at the point where the objects in the scene should be placed, and moved the camera close enough. This works in the normal-browser view, but in vr, still no content visible.
I am fairly sure I missed something or I my init-order is wrong, something like that.
initUi() {
this.initWindow();
this.initScene();
this.createVirtualFloor();
this.initCamera();
this.initRenderer();
this.initSceneLigths();
this.createSelectPointHelper();
this.initControls();
this.onResize();
this.initSceneContextMenu();
this.initVR();
this.resetView();
this.initRaycaster();
//this.initOutlineSelection();
this.initCadTree();
this.createConstructionFloor();
this.initCadRefferenceGroup();
this.initFont();
this.initDebugTools();
this.animateScene();
}
in initRenderer I enable the vr mode
in initVR I add the VR button (I enabled the renderers vr mode here at first, but that didn’t work either)
Has somebody any idea where I went wrong this time?