diff --git a/src/components/position-at-box-shape-border.js b/src/components/position-at-box-shape-border.js index 65b3d32d282b78613eca464402154f7e9916c4ec..4378d15c6bdb39c636231bbdb3937b79a13f4efa 100644 --- a/src/components/position-at-box-shape-border.js +++ b/src/components/position-at-box-shape-border.js @@ -53,12 +53,15 @@ AFRAME.registerComponent("position-at-box-shape-border", { this.target = this.el.querySelector(this.data.target).object3D; if (!this.target) return; } + if (!this.el.getObject3D("mesh")) { + return; + } if (!this.halfExtents || this.mesh !== this.el.getObject3D("mesh") || this.shape !== this.el.components.shape) { - this.mesh = this.el.getObject3D("mesh"); //... + this.mesh = this.el.getObject3D("mesh"); const box = getBox(this.el, this.mesh); if (this.el.components.shape) { this.shape = this.el.components.shape; - this.halfExtents = this.shape.data.halfExtents.clone(); + this.halfExtents = new THREE.Vector3().copy(this.shape.data.halfExtents); } else { this.halfExtents = box.min .clone()