Skip to content

Commit ac84a6a

Browse files
Fix force-pushable example for the ammo driver
Don't overwrite the position of the cursor when converting from local to world and use the force vector instead. Remove x10 dampening on the force, as by testing the example this seems to be unnecessary.
1 parent ea1630d commit ac84a6a

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

examples/components/force-pushable.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,12 @@ AFRAME.registerComponent('force-pushable', {
5959
const force = this.force
6060
const impulseBt = this.impulseBtVector
6161
const pusher = e.detail.cursorEl.object3D
62-
pusher.localToWorld(pusher.position)
63-
force.copy(el.object3D.position.sub(pusher.position))
62+
force.copy(pusher.position)
63+
pusher.localToWorld(force)
64+
force.copy(el.object3D.position.sub(force))
6465
force.normalize();
6566

66-
// not sure about units, but force seems much stronger with Ammo than Cannon, so scaling down
67-
// by a factor of 10.
68-
force.multiplyScalar(this.data.force / 10);
67+
force.multiplyScalar(this.data.force);
6968
impulseBt.setValue(force.x, force.y, force.z)
7069

7170
// use data from intersection to determine point at which to apply impulse.

0 commit comments

Comments
 (0)