Pryme8 Posted August 14, 2016 Share Posted August 14, 2016 I might be tripping, but don't we have a quick reference to the cameras forward vector? Like the Unity equivalent to: Camera.main.transform.forward I know we have one for up... Im having trouble doing simple stuff today I feel like my brain is not working. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 14, 2016 Author Share Posted August 14, 2016 var forward = scene.activeCamera.getTarget().subtract(scene.activeCamera.position).normalize(); forward.y=0; that took me way way to long... uhg what a day... Quote Link to comment Share on other sites More sharing options...
Wingnut Posted August 14, 2016 Share Posted August 14, 2016 Some people might say... "but my camera has no target set"... but cameras (such as free cam) have a _currentTarget by default, located 1 unit ahead of the camera. So getTarget() never fails, even on cams that have never had a user-target set. http://playground.babylonjs.com/#14FZUY#0 Yuh, yuh, yuh. I found the answer in about 7 minutes using a forum search for "camera direction". neener. But you answered yourself before I could type this. Sorry. Hope it's less traumatic next time. Did you add a note to the camera tutorial? Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 14, 2016 Author Share Posted August 14, 2016 not sure how to do that (add a note)? :-( I should have been helping with the documentation a while ago... im a goober... sorry Quote Link to comment Share on other sites More sharing options...
adam Posted August 14, 2016 Share Posted August 14, 2016 var wm = camera.getWorldMatrix(); var forwardX = wm.m[8]: var forwardY = wm.m[9]; var forwatdZ = wm.m[10]; I think that should work (I'm on my phone). Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 15, 2016 Author Share Posted August 15, 2016 does that return a normalized vector adam? if so I would bet yours is faster. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 15, 2016 Share Posted August 15, 2016 Or you can use: camera.getFrontPosition(1) 1 is the distance you want between camera position and front position adam and Pryme8 2 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted August 15, 2016 Author Share Posted August 15, 2016 thats the ticket Quote Link to comment Share on other sites More sharing options...
adam Posted August 15, 2016 Share Posted August 15, 2016 4 hours ago, Pryme8 said: does that return a normalized vector adam? yes Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.