aframe-physics-system icon indicating copy to clipboard operation
aframe-physics-system copied to clipboard

Ammo kinematic transforms break when combined with THREE's .attach()

Open chrisnovello opened this issue 5 years ago • 1 comments

Trying to combine THREE's recent .attach() https://github.com/mrdoob/three.js/pull/16528 with Ammo's kinematic bodies. The ammo bodies don't seem to transform as expected

https://glitch.com/edit/#!/ammo-grab https://ammo-grab.glitch.me/

@InfiniteLee suggested

huh yea it looks like the collider's transform gets totally messed up whatever attach is doing must not be playing nice with how ammo-body grabs the world transform for kinematic bodies i would do some debugging in ammo-body syncToPhysics

This is attempting to use .attach() as a way to keep a physics object firmly locked onto a hand as it moves (even just visually, it is alright if the physics body lags a tiny bit behind)

Hoping this could become a definitive approach to this very commonly desired feature (also haven't thought about if it would be viable in NAF)

https://github.com/donmccurdy/aframe-physics-system/issues/81 https://github.com/aframevr/aframe/issues/2425

chrisnovello avatar Jun 07 '19 06:06 chrisnovello

following up...

Kevin Lee i had an idea just now about what the issue probably is. https://github.com/donmccurdy/aframe-physics-system/blob/6cb498263f0ac6401b5784bce24a5b827e3e7ffc/src/components/body/ammo-body.js#L380

there's this check for the parent of the entity to see whether or not it should try to calculate the world transform or not if attach is doing something where its not actually parenting the grabbed object under the hand, it will still try to use the local transform which would explain why the collider appears in the ground (at origin) that check is probably not super necessary (it was just a perf saving attempt on my part) but you can hack around the issue by nesting the objects under an empty entity not ideal though

which indeed works !

https://grab-again.glitch.me/ https://glitch.com/edit/#!/grab-again

if you opened that issue already, feel free to mention that. I'll have to think about whether or not that check is important or not...

chrisnovello avatar Jun 07 '19 07:06 chrisnovello