Hello, awesome THREE.Community
I have a weird problem, not entirely sure it fits this forum. If its too stupid, please let me know and I’ll remove it.
I made a scene where Obj1 interacts with other meshes, using Box3.intersectsBox() method.
I have an algorithm in my update method that runs every frame:
- Save the position of Obj1 to a variable ( by using .copy( ) method )
- Move Obj1 according to user input
- Iterate through an array of collidable meshes to see if bounding boxes intersect
- If Intersection happened, then Obj1 position is restored to the saved variable before any transforms.
What I expected to get is that the object will move freely, but when collision occurs, then the translation is not allowed. However theory and practice are different and once the intersection happens, Obj1 gets “stuck” in the mesh it intersected with, as if its position hasnt been reverted.
I managed to recreate the issue in this codepen:
Later I implemented a list of 5 last positions ( currently in the codepen ), and they all seemed to work as expected, except the last position, just like in the described algorithm. Second last position works but its very “jumpy” and doesnt seem like the right solution.