Jump to content

FreeCamera direction vector


Recommended Posts

I'm trying to make camera "shoot" projectile in direction camera is facing, but I can't seem to find camera direction vector. Only vector I managed to find is camera upVector but with only one vector I can't calculate camera direction vector. Any help how to get direction vector, or maybe how to fire projectile from camera in some other way is greatly appreciated. 

Link to comment
Share on other sites

  • 1 year later...
  • 11 months later...

Oh -- Handy!

Just to be clear:

var unitVec= camera.getFrontPosition(1).subtract(camera.position);


console.log("Magnitude: " + Math.sqrt(unitVec.x*unitVec.x + unitVec.y*unitVec.y + unitVec.z*unitVec.z));

var bigVec= camera.getFrontPosition(1);


console.log("Magnitude: " + Math.sqrt(bigVec.x*bigVec.x + bigVec.y*bigVec.y + bigVec.z*bigVec.z));


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.

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.


  • Recently Browsing   0 members

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