From d7c57819b6a709f601783b96283908b99798be5f Mon Sep 17 00:00:00 2001 From: joni <johnfshaughnessy@gmail.com> Date: Mon, 9 Jul 2018 16:45:08 -0700 Subject: [PATCH] Fix offset --- src/components/auto-box-collider.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/auto-box-collider.js b/src/components/auto-box-collider.js index 220ad92ed..f0aeb2941 100644 --- a/src/components/auto-box-collider.js +++ b/src/components/auto-box-collider.js @@ -20,10 +20,13 @@ AFRAME.registerComponent("auto-box-collider", { const halfExtents = new THREE.Vector3() .addVectors(min.clone().negate(), max) .multiplyScalar(0.5 / this.el.object3D.scale.x); + const center = new THREE.Vector3().addVectors(min, max).multiplyScalar(0.5); + this.el.object3D.worldToLocal(center); + this.el.object3DMap.mesh.position.sub(center); + this.el.setAttribute("shape", { shape: "box", - halfExtents: halfExtents, - offset: new THREE.Vector3(0, halfExtents.y, 0) + halfExtents: halfExtents }); if (this.data.resize) { this.resize(min, max); -- GitLab