Am using Vec3 for the active object, I am able to detect the collision but could not implement snapping effect like http://jsfiddle.net/gcollect/FD53A/
P.S we are using 3D objects.
I’ve used box3 successfully for this.
It creates a bounding box for your object which you can parent to your object and compare boundary intersections etc
How to handle that bounding box when the object has diagonal movement?
Also learn from this…
http://man.hubwiz.com/docset/HTML.docset/Contents/Resources/Documents/developer.mozilla.org/en-US/docs/Games/Techniques/3D_collision_detection/Bounding_volume_collision_detection_with_THREE.html
Actually, the intersection is already working, am unable to create a magnetic effect in between active and colliding object only in one scenario; when the active object is moving in a diagonal direction (x and z axis, simultaneously ), besides it is working perfectly against x and z-axis.
It would be great if i can find any general solution, not necessorly in Threejs.
Code it so that when intersection occurs…
A new function drives the animation of a for loop from the current location to the intersecting object’s location.
I have the exact code you want.
I just have to dig it up.
Give me a bit and I’ll have something for you
Possibly
Also,if you’re not looking strictly in three.js, there are solutions to this in unreal and other engines.
I will be grateful, Thanks.
If i get general solution using coordinates, i can use it in Threejs, that won’t be big deal.
Did you happen to find any solution?
Hey there!
I am currently implementing such feature and stuck on it…
Did you solve your issue?
I have came to the next idea so far:
I have created box3 object surrounding the item. Transformed it so the min and max vectors of this box includes item’s current rotation and translation (the walls of the room are perpendicular by now, so the rotation is always multiple of 90 so it lays on the plane). This box is used for moving along the intersecting plane (called it movedBox), then the item will be placed to the center of this box after the new position is calculated (it must be at least inside the room).
Next I have created the clone of this movedBox and expanded it on some scalar value (magnet force). This expanded box (magnetBox) is translating and rotating with the movedBox. The purpose of this box is to find does any item lays inside the “magnetic field” of moving item. If it does the item should be translated accordingly.
So I had stuck on calculating new position if multiple items are intersecting the magnetBox
The question is pretty old. I hope you found the solution and will be really happy if you could share it.
Thank you!