Browse Source

sprite fix

master
cailean 2 hours ago
parent
commit
429db117e4
  1. 26
      js/Item.js
  2. 1
      js/Player.js

26
js/Item.js

@ -432,13 +432,13 @@ export class Item {
boundingBox.getBoundingSphere(boundingSphere); boundingBox.getBoundingSphere(boundingSphere);
// Set the desired world scale for the indicator based on the object's size // 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); this.hoverIndicator.scale.set(desiredScale, desiredScale, desiredScale);
// Counteract the parent's scale by dividing the indicator's scale by the parent's scale. // 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) { if (this.object.scale.x !== 0 && this.object.scale.y !== 0 && this.object.scale.z !== 0) {
// this.hoverIndicator.scale.divide(this.object.scale); this.hoverIndicator.scale.divide(this.object.scale);
// } }
// Position the sprite at the center of the object, in local space. // Position the sprite at the center of the object, in local space.
this.hoverIndicator.position.copy(boundingSphere.center).sub(this.object.position); this.hoverIndicator.position.copy(boundingSphere.center).sub(this.object.position);
@ -459,15 +459,15 @@ export class Item {
if (this.loadState !== 'loaded') return; if (this.loadState !== 'loaded') return;
// if (this.hoverIndicator) { if (this.hoverIndicator) {
// this.pulseTime += delta * 5; // Adjust the multiplier to change pulse speed this.pulseTime += delta * 5; // Adjust the multiplier to change pulse speed
// const minOpacity = 0.1; const minOpacity = 0.1;
// const maxOpacity = 0.8; const maxOpacity = 0.8;
// // Create a sine wave that oscillates between 0 and 1 // Create a sine wave that oscillates between 0 and 1
// const oscillation = (Math.sin(this.pulseTime) + 1) / 4; const oscillation = (Math.sin(this.pulseTime) + 1) / 4;
// // Apply the oscillation to the desired opacity range // Apply the oscillation to the desired opacity range
// this.hoverIndicator.material.opacity = minOpacity + oscillation * (maxOpacity - minOpacity); this.hoverIndicator.material.opacity = minOpacity + oscillation * (maxOpacity - minOpacity);
// } }
this.lastPosition = this.object.position.clone(); this.lastPosition = this.object.position.clone();

1
js/Player.js

@ -819,6 +819,7 @@ export class Player {
// Use right controller for interaction ray // Use right controller for interaction ray
const controller = this.vrControllers[0]; const controller = this.vrControllers[0];
controller.getWorldPosition(ray.ray.origin); controller.getWorldPosition(ray.ray.origin);
ray.camera = this.camera;
ray.ray.direction.set(0, 0, -1).applyQuaternion(controller.getWorldQuaternion(new THREE.Quaternion())); ray.ray.direction.set(0, 0, -1).applyQuaternion(controller.getWorldQuaternion(new THREE.Quaternion()));
} else { } else {
// Use camera for desktop interaction ray // Use camera for desktop interaction ray

Loading…
Cancel
Save