Move object along the surface of another object

Hi everyone,

in my scene I’ve created several walls as custom meshes and load several Object3d’s via OBJLoader2. I’ve created a Raycaster to select surfaces of walls. That’s all working fine so far.

Now I’d like to “attach” such an Object3d to a wall and be able to move it along the surface of the wall with DragControls and limit the movement to the area of the wall’s surface.

I looked into DragControls and found that it’s creating _plane dynamically, based on camera direction and position. Then I looked into Plane and tried to figure out how to create one specifically for the surface of a wall. I understand the math basics, but I’d like to generate such a plane based on the geometry (faces) of a wall, after selecting it and then pass it to DragControls.

How would I create such a Plane based on the face of another geometry?
Can I plug the faceNormal vector into the Plane constructor?
Is this approach viable, passing the Plane to DragControls?

Thank you!

Using r113.

1 Like

Have a look at these examples from the Collection of examples from discourse.threejs.org . You might find some useful things there.

In the source code above are the links to the posts in the forum.

https://hofk.de/main/discourse.threejs/2018/RestrictObject/RestrictObject.html
https://hofk.de/main/discourse.threejs/2019/TransformControls/TransformControls.html
https://hofk.de/main/discourse.threejs/2019/WallTHREEg/WallTHREEg.html
https://hofk.de/main/discourse.threejs/2020/DraggingObjects/DraggingObjects.html
https://hofk.de/main/discourse.threejs/2020/TriggerFunction(Animation)/TriggerFunction(Animation).html


raycaster - drag and drop shows you the dynamic plane at Raycaster.
:slightly_smiling_face:

1 Like

Thank you! I will look into these examples.

1 Like