Browse Source

sprite

master
cailean 1 hour ago
parent
commit
fc56f27079
  1. 4
      js/Content.js
  2. 11
      js/Item.js

4
js/Content.js

@ -175,8 +175,8 @@ export class ImageContent extends Content {
(texture) => { (texture) => {
this.texture = texture; this.texture = texture;
const aspect = texture.image.width / texture.image.height; const aspect = texture.image.width / texture.image.height;
const maxWidth = 4.5; const maxWidth = 4;
const height = 4; const height = 3;
let width = height * aspect; let width = height * aspect;
if (width > maxWidth) { if (width > maxWidth) {
width = maxWidth; width = maxWidth;

11
js/Item.js

@ -432,16 +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 * 2.5; const desiredScale = boundingSphere.radius * 0.2;
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 (scale.x !== 0 && scale.y !== 0 && scale.z !== 0) { // if (this.object.scale.x !== 0 && this.object.scale.y !== 0 && this.object.scale.z !== 0) {
this.hoverIndicator.scale.divide(scale); // this.hoverIndicator.scale.divide(this.object.scale);
} else { // }
// Avoid division by zero
this.hoverIndicator.scale.set(1, 1, 1);
}
// 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);

Loading…
Cancel
Save