richardsmd Posted December 12, 2016 Share Posted December 12, 2016 I'm trying to build a sort of "tunnel explorer" to show points of interest within a tunnel modeled after something in the real world. Within the tunnel are points of interest. Here's a mockup with a tunnel and some points of interest- http://www.babylonjs-playground.com/#1VFLZF#4 By default I expect users to free-roam with a FreeCamera, but I'd also like to be able to "jump to" any given defect by selecting it via UI not shown in the playground. I'm not sure how to do that though... my best theory is this: Add an invisible object in the approximate center-line of the tunnel (CL) Upon selecting a point of interest to jump to, locate the point on CL closest to the centeroid (mesh.getAbsolutePosition()) of the point of interest and set the camera's position to that point Rotate the camera to look at the point of interest Can anyone help me implement step 2 (jumpNearestOnCenterline in playground)? Note that my actual tunnel not straight and constructed via a point cloud, so there is no good/simple way to determine the center of the tunnel that I'm aware of I've never worked with cameras or automatic camera positioning systems before so my solution is inspired by GIS. If you have a more straight-forward idea I'm all ears. Thank you for your time, Mike Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 12, 2016 Share Posted December 12, 2016 Hello and welcome! you can use camera.setTarget(box.position) to rotate your camera towards a POI In you case, you can align the tunnel on z axis. So then clicking on a red POI will give you the POI.getAbsolutePosition(). Using this position you can keep the z and move your camera.position to (0, 0, z) and then use camera.setTarget Quote Link to comment Share on other sites More sharing options...
richardsmd Posted December 12, 2016 Author Share Posted December 12, 2016 Just realized I had a typo - PG updated at http://www.babylonjs-playground.com/#1VFLZF#5 @Deltakosh I'm confused by both your suggestions How can I align on the Z axis? As stated above, my tunnel is not straight. I'm somewhat familiar with rotations but unclear as to how I would determine the orientation of the localized part of the tunnel a point of interest appears in. Without that, I couldn't rotate correctly camera.setTarget doesn't alter the X axis rotation correctly. See this PG update - http://www.babylonjs-playground.com/#1VFLZF#7 (method is updated to use setTarget; runs automatically after 2 seconds. Drag/pan down to see the box). Am I using the method incorrectly? Thank you again, Mike Quote Link to comment Share on other sites More sharing options...
Nabroski Posted December 12, 2016 Share Posted December 12, 2016 http://doc.babylonjs.com/tutorials/Animations http://www.babylonjs-playground.com/#1VFLZF#10 http://www.babylonjs-playground.com/#VNE2Z#23 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.