Jump to content

rotating eyes towards the camera


DezOnlyOne
 Share

Recommended Posts

Right now I am trying to figure out how to make my character's eyes rotate and orient towards a camera. I am attaching my babylon file to this, but what I am hoping to do is create a lookAt function for the eyes. 

 

Is there an easy way that I can set the local rotation for the eyes so that they follow the camera, or any object in 3d space? The pivot point of the eyes is in the center of the eyes so they should rotate without a problem. I realize that the idea of the forum is to contribute to the solution as well, but I am a little lost as to where to start. 

 

Is there some information on the web that can help as well?

 

Thanks. 

 

I attached the babylon file in case anyone wanted it. 

content.zip

 

 

 

 

 

Link to comment
Share on other sites

The lookAt function seems to work for keeping the eyes rotated. Is there aw way to apply lookAt to its local rotation? They look directly at the camera, but they fly around outside of my characters. skull. Fitting for Halloween I suppose. :D

This is the function I am using

function look(mesh, pos) {    mesh.lookAt(new BABYLON.Vector3(pos.x, pos.y, pos.z), 0, -Math.PI / 2, 0);};

Billboard had similar results, but the eyes were facing to the right. 

Link to comment
Share on other sites

You can also get the wanted rotation with RotationFromAxis(). This allows you to compute the needed rotation to apply to something to rotate it up to the target system orientation. This target system can be 3 the axis : eye-cam / Y /  3rd orthogonal vector

 

http://doc.babylonjs.com/overviews/How_Rotations_and_Translations_Work  

=> "generating a rotation from a target system" part

 

demo : http://www.babylonjs-playground.com/#VYM1E#5

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...