|
|
|
@ -24,6 +24,7 @@ export class Player { |
|
|
|
this.mouseSensitivity = 0.002; |
|
|
|
this.maxInteractionDistance = 200.0; |
|
|
|
|
|
|
|
this.vrDrawing = false; |
|
|
|
this.isDrawing = false; |
|
|
|
this.raycast = new THREE.Raycaster(); |
|
|
|
this.pointer = new THREE.Vector2(); |
|
|
|
@ -224,6 +225,7 @@ export class Player { |
|
|
|
controller.addEventListener('selectstart', () => this._OnVRSelectStart(i)); |
|
|
|
controller.addEventListener('selectend', () => this._OnVRSelectEnd(i)); |
|
|
|
controller.addEventListener('squeezestart', () => this._OnVRSqueezeStart(i)); |
|
|
|
controller.addEventListener('squeezeend', () => this._OnVRSqueezeEnd(i)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -276,13 +278,27 @@ export class Player { |
|
|
|
_OnVRSqueezeStart(controllerIndex) { |
|
|
|
console.log(`Squeeze Started: ${controllerIndex}`); |
|
|
|
// Use squeeze on right controller to detach item
|
|
|
|
if (controllerIndex === 0 && this.attachedItem) { |
|
|
|
this.attachedItem.isActive = false; |
|
|
|
this.attachedItem._removeContentDisplay(); |
|
|
|
this.attachedItem = null; |
|
|
|
if (controllerIndex === 0) { |
|
|
|
if (!this.attachedItem) { |
|
|
|
this.vrDrawing = true; |
|
|
|
this.isDrawing = true; |
|
|
|
} else { |
|
|
|
// Existing detach logic
|
|
|
|
this.attachedItem.isActive = false; |
|
|
|
this.attachedItem._removeContentDisplay(); |
|
|
|
this.attachedItem = null; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
_OnVRSqueezeEnd(controllerIndex) { |
|
|
|
if (controllerIndex === 0) { |
|
|
|
this.vrDrawing = false; |
|
|
|
this.isDrawing = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_handleVRJoystick() { |
|
|
|
// --- Left Controller (Teleport Distance) ---
|
|
|
|
const leftGamepad = this.vrGamepads[1]; |
|
|
|
@ -427,7 +443,7 @@ export class Player { |
|
|
|
const meshesToIntersect = drawableObjects.map(obj => obj.mesh); |
|
|
|
|
|
|
|
// Desktop drawing
|
|
|
|
if (this.isDrawing && !this.vrControllers[0]?.userData.isDrawing) { |
|
|
|
if (this.isDrawing && !this.renderer.xr.isPresenting) { |
|
|
|
this.pointer.x = 0; |
|
|
|
this.pointer.y = 0; |
|
|
|
this.raycast.setFromCamera(this.pointer, this.camera); |
|
|
|
@ -442,7 +458,7 @@ export class Player { |
|
|
|
|
|
|
|
// VR drawing (right controller)
|
|
|
|
const vrController = this.vrControllers[0]; |
|
|
|
if (this.isDrawing && vrController) { |
|
|
|
if (this.vrDrawing && vrController && this.renderer.xr.isPresenting) { |
|
|
|
const controllerMatrix = vrController.matrixWorld; |
|
|
|
const ray = new THREE.Raycaster(); |
|
|
|
ray.ray.origin.setFromMatrixPosition(controllerMatrix); |
|
|
|
|