Skip to content

Commit

Permalink
clean a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyGlt committed Mar 6, 2025
1 parent 839bbcd commit cb89a63
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
7 changes: 1 addition & 6 deletions packages/Main/src/Controls/VRControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import DEMUtils from 'Utils/DEMUtils';
import { XRControllerModelFactory } from 'ThreeExtended/webxr/XRControllerModelFactory';

/**
* Controller.userData {
* isSelecting,
* lockedTeleportPosition
* }
* Requires a contextXR variable.
* @param {*} _view itowns view object
* @param {*} _groupXR XR 3D object group
Expand Down Expand Up @@ -45,7 +41,6 @@ class VRControls {
controller.addEventListener('connected', (event) => {
controller.name = event.data.handedness; // Left or right
controller.userData.handedness = event.data.handedness;
// bindControllerListeners(controller, vrHeadSet);
controller.gamepad = event.data.gamepad;
this.groupXR.add(controller);

Expand Down Expand Up @@ -91,7 +86,7 @@ class VRControls {
Listening {XRInputSource} and emit changes for convenience user binding,
There is NO JOYSTICK Events so we need to check it ourselves
Adding a few internal states for reactivity
- controller.isStickActive {boolean} true when a controller stick is not on initial state.
- controller.isStickActive {boolean} true when a controller stick is not on initial state.
*/

listenGamepad() {
Expand Down
9 changes: 3 additions & 6 deletions packages/Main/src/Renderer/WebXR.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import * as THREE from 'three';
import VRControls from 'Controls/VRControls';

// TODO handle xr session end


function updateCamera3D(xr, view) {
/* This is what's done in updateUserCamera the WebXRManager.js of threejs
Update projectionMatrix, could be replaced by:
Expand Down Expand Up @@ -29,7 +31,6 @@ function updateCamera3D(xr, view) {
.getWorldQuaternion(view.camera3D.quaternion);


// // TODO is it necessary ?
// Update the local transformation matrix for the object itself
view.camera3D.updateMatrix();
//
Expand Down Expand Up @@ -67,14 +68,13 @@ class WebXR {
this.vrControls = null;
}

// Start the webXR handler
initializeWebXR = () => {
const xr = this.view.renderer.xr;

xr.addEventListener('sessionstart', () => {
xr.enabled = true;

let vrControls;

xr.getReferenceSpace('local');

// To avoid controllers precision issues, headset should handle camera position
Expand All @@ -95,7 +95,6 @@ class WebXR {
this.view._camXR.near = 0.1;
this.view._camXR.updateProjectionMatrix();

// this.view._camXR.updateMatrixWorld(true);
vrHeadSet.add(this.view._camXR);

this.view.notifyChange();
Expand All @@ -104,8 +103,6 @@ class WebXR {
this.vrControls = new VRControls(this.view, vrHeadSet);
}

// TODO Fix asynchronization between xr and MainLoop render loops.
// (see MainLoop#scheduleViewUpdate).
xr.setAnimationLoop((timestamp) => {
if (xr.isPresenting && xr.getCamera().cameras.length > 0) {
// TODO should be called only once, but the first values are wrong because the camL&camR weren't updated
Expand Down

0 comments on commit cb89a63

Please sign in to comment.