From 429db117e4c45fb997e18ff16b52a202eb56aa6b Mon Sep 17 00:00:00 2001 From: cailean Date: Fri, 28 Nov 2025 00:16:08 +0000 Subject: [PATCH] sprite fix --- js/Item.js | 26 +++++++++++++------------- js/Player.js | 1 + 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/js/Item.js b/js/Item.js index 4cbd6ae..8fb4f38 100644 --- a/js/Item.js +++ b/js/Item.js @@ -432,13 +432,13 @@ export class Item { boundingBox.getBoundingSphere(boundingSphere); // Set the desired world scale for the indicator based on the object's size - const desiredScale = boundingSphere.radius * 0.2; + const desiredScale = boundingSphere.radius * 2.5; this.hoverIndicator.scale.set(desiredScale, desiredScale, desiredScale); // Counteract the parent's scale by dividing the indicator's scale by the parent's scale. - // if (this.object.scale.x !== 0 && this.object.scale.y !== 0 && this.object.scale.z !== 0) { - // this.hoverIndicator.scale.divide(this.object.scale); - // } + if (this.object.scale.x !== 0 && this.object.scale.y !== 0 && this.object.scale.z !== 0) { + this.hoverIndicator.scale.divide(this.object.scale); + } // Position the sprite at the center of the object, in local space. this.hoverIndicator.position.copy(boundingSphere.center).sub(this.object.position); @@ -459,15 +459,15 @@ export class Item { if (this.loadState !== 'loaded') return; - // if (this.hoverIndicator) { - // this.pulseTime += delta * 5; // Adjust the multiplier to change pulse speed - // const minOpacity = 0.1; - // const maxOpacity = 0.8; - // // Create a sine wave that oscillates between 0 and 1 - // const oscillation = (Math.sin(this.pulseTime) + 1) / 4; - // // Apply the oscillation to the desired opacity range - // this.hoverIndicator.material.opacity = minOpacity + oscillation * (maxOpacity - minOpacity); - // } + if (this.hoverIndicator) { + this.pulseTime += delta * 5; // Adjust the multiplier to change pulse speed + const minOpacity = 0.1; + const maxOpacity = 0.8; + // Create a sine wave that oscillates between 0 and 1 + const oscillation = (Math.sin(this.pulseTime) + 1) / 4; + // Apply the oscillation to the desired opacity range + this.hoverIndicator.material.opacity = minOpacity + oscillation * (maxOpacity - minOpacity); + } this.lastPosition = this.object.position.clone(); diff --git a/js/Player.js b/js/Player.js index f4cf20f..20a2b0d 100644 --- a/js/Player.js +++ b/js/Player.js @@ -819,6 +819,7 @@ export class Player { // Use right controller for interaction ray const controller = this.vrControllers[0]; controller.getWorldPosition(ray.ray.origin); + ray.camera = this.camera; ray.ray.direction.set(0, 0, -1).applyQuaternion(controller.getWorldQuaternion(new THREE.Quaternion())); } else { // Use camera for desktop interaction ray