c-frame / aframe-physics-system

community-maintained fork of n5ro's aframe-physics-system
https://c-frame.github.io/aframe-physics-system/
MIT License
43 stars 11 forks source link

Fix pushing direction #37

Closed Yuma-Mori closed 1 year ago

Yuma-Mori commented 1 year ago

In Ammo's force-pushable example, wherever I click an object, the force comes from (0, 0, 0).

I added vector subtraction to direct force from the clicker to the object. Also, this code works if cursor is mouse.

diarmidmackenzie commented 1 year ago

Thanks for this. I'm happy to merge this as it's clearly an improvement, and this is only test / example code.

A completely correct fix would also allow for the fact that the entity being pushed may not be in world space, so we should use el.object3D.getWorldPostion() rather than el.object3D.position.

It would also be nice to fix up the Cannon version, which looks like it has the same issue.

Further fixes for either of these would be much appreciated!