NasimiAsl Posted July 16, 2016 Share Posted July 16, 2016 how can correct camera rotation when walk around of sphere http://www.babylonjs-playground.com/#RW25F#4 Quote Link to comment Share on other sites More sharing options...
jerome Posted July 16, 2016 Share Posted July 16, 2016 I think that a FreeCamera, when moving, has a cameraDirection property what a Vector3 oriented in the way the camera moves. So if you add camera.position and camera.cameraDirection, you'll get a result that could be used as camera target. Thus you will look in the way you walk. Quote Link to comment Share on other sites More sharing options...
jerome Posted July 16, 2016 Share Posted July 16, 2016 Sorry, what I just said is stupid : a FreeCamera always looks towards the direction of moving. I suppose that you want to position the camera permanently on the sphere instead ... Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted July 16, 2016 Share Posted July 16, 2016 if it's a perfect round sphere i suppose you could rotate the sphere instead, that should give the wanted result. Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted July 17, 2016 Author Share Posted July 17, 2016 we cant rotate world we have other planets too and all planets is moving usually i try hard way to find a solution i am work on Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted July 17, 2016 Author Share Posted July 17, 2016 @jerome thanks for reply maybe i ask wrong question i correct camera position now and i have gravity for any planet i think i need re calculate " camera target position " my next question : any way to define a jump or automatic walk for camera with collision and gravity? Quote Link to comment Share on other sites More sharing options...
jerome Posted July 17, 2016 Share Posted July 17, 2016 ok just an idea (pseudo code, all these following are vector3 substraction or addition or cross product) : var axisCam = camera.position - sphere.position; // axis cam-sphere center, so a sphere radius vector var axisMove = CopyFrom(camera.cameraDirection); // axis of the cam movement, copy the last defined value. You could get Axis.X before it's defined (before the first camera move) to give an initial view direction, or any direction that you would choose by default. Just don't set it to zero. var cross1 = Cross(axisCam, axisMove); // a first orthogonal vector to the radius and the movement, so cross1 if tangent to the sphere var cross2 = Cross(axisCam, cross1); // this one is orthogonal to the radius, tangent to the sphere and colinear to the movement... if not right try instead Cross(cross1, axisCam) var target = camera.position + cross2; this should work Wingnut and NasimiAsl 2 Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted July 17, 2016 Author Share Posted July 17, 2016 thanks @jerome i check it and share result Quote Link to comment Share on other sites More sharing options...
Wingnut Posted July 18, 2016 Share Posted July 18, 2016 Ain't it great when Jerome talks Math-smack like that? Friggin' Orthogonoids... ya gotta love 'em! Jerome, of course, taking a professor-like approach, where as I... would hack lookAt(). (ie. Make the bottom of the camera constantly lookAt the planet core.) Quote Link to comment Share on other sites More sharing options...
Raggar Posted July 26, 2016 Share Posted July 26, 2016 Out of curiousity, did you manage to make this work? Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted July 27, 2016 Author Share Posted July 27, 2016 who? when? what? Quote Link to comment Share on other sites More sharing options...
Raggar Posted July 28, 2016 Share Posted July 28, 2016 Well. The question was actually directed at you, sir Were you able to somehow reset the camera rotation/translation when getting to the other side of the sphere? I simplyfied your example a bit, just to make it easier for myself: http://www.babylonjs-playground.com/#RW25F#7 I'm not even sure that I understand the issue, really. Is it something like the below demonstration?: I'm leaning mostly toward the first figure, as you quickly get the issue of the camera limitation/boundary downward/Y axis. As well as the camera just being 'off'. This has the potential to make some fun "border-less" game maps, if you adjust the camera accordingly, or make big enough spheres. 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.