Browse Source

sprite fix

master
cailean 1 hour 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);
// 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();

1
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

Loading…
Cancel
Save