Specific part of 3D model to follow mouse

I have looked through the other questions regarding model to follow mouse but none talks about isolating the head of a 3d object to follow mouse with a stationary body. For instance, with a hydra, only setting it such that the many heads follow the mouse with a stationary body, is this possible with 3JS?

Yes but it is important that your model fulfills some prerequisites e.g. the head should be a separate 3D object and a child element of the body. If so, you can select the head with a query (e.g. via getObjectByName()) and transform it without affecting other parts of the model.

1 Like

awesome, I’ll try it out

Here is an example.

  1. It loads a glTF and an animation.
  2. It finds and creates a reference to the head bone.
  3. It removes any animation tracks that modify that head bones quaternion, otherwise the mixer will override any changes I make with the mouse.
  4. head bone is then managed by mouse movement.

Head follow mouse : SBCODE Editor


it would look pretty weird/unnatural if only the head follows but it would be not so hard to accomplish natural movement. take a look

there is a codrops article explaining it with vanilla code How to Create an Interactive 3D Character with Three.js | Codrops