Xav Posted November 7, 2017 Share Posted November 7, 2017 Hi! I'm having a problem with my camera alignment on the alpha axis. I would like that when I click on a box my camera is aligned in the axis. It works on small variation of rotation but if I pass on rotations higher than about 180 ° on my dome my camera makes a complete turn on itself and aligns itself. Would anyone have a solution to fix the problem. I probably do not use the good method I put you a playground with my code used: http://www.babylonjs-playground.com/#XCGI1K Thank you! Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 13, 2017 Share Posted November 13, 2017 Hiya Xav! OMG, 6 days with no replies? Sorry. I looked at your code... it is very cool. You are very inventive. I think what we need, here... is... orientCamPerMesh(cam, mesh) That would make our life easier, huh? I will keep thinking. Perhaps others will help. For future info, do you want camera to z-rotate to match mesh, too? If so, perhaps good start is to parent (Universal?) camera... to an invisible/blank "camGizmo" mesh. Then, don't use camera alpha, beta, at all (not available on universal cam, if used). Just use camGizmo to do all camera orientations/positioning. When camGizmo orientation == mesh orientation... success! (or something explodes and scares the dog) I will work on this. Sorry again for slow replies....I'm on it. As-for animating cam/gizmo position/orientation to a DIFFERENT mesh-axis... phew... that seems harrrrrd. Gods are nearby, though. I think we need "Quorbits". Quarter-orbits... around the mesh (after doing an initial orientCamPerMesh(), of course (after someone codes it). Continuous/locked camGizmo.lookAt(mesh.position) might be handy, here, too. Stay tuned. Update: I did some goofing-around with this playground... having some fun trying "meshAddingMode" [ link ] Control-drag for ArcCam target-moving. Many camera adjustments made, added click-on-dome -> re-init cam, added click-on-mesh -> camera.target == picked mesh. Lots of experimental stuff. I haven't begun anything difficult, yet. I think I'm stalling. Quote Link to comment Share on other sites More sharing options...
Xav Posted November 14, 2017 Author Share Posted November 14, 2017 Hello Wingnut thank you for your help. I simplified the playground: http://www.babylonjs-playground.com/#XCGI1K#7 There are now only two cubes. A blue and a yellow. When we click on everything works (until everything is fine;). The problem is that after several clicks in transition the camera makes a complete turn on itself? The problem would not it that the camera returns an angle of 6.2831853072 rad for 360 ° at a time whereas finally one does only half turn of 3.1415926536 rad for 180 °? Is there not a tool to normalize the angle of rotation so that it takes the shortest path rather than making a complete turn? I hope to be clear enough in my explanation because you have to click several times to see the bug and the camera that runs a lot too. Thank you. Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 14, 2017 Share Posted November 14, 2017 Oh, this playground made my eyes a bit soar But all good! You found the problem, now here is the simple solution - http://www.babylonjs-playground.com/#XCGI1K#8 . % (math.PI*2) times the alpha (and beta), will keep the path liner, as it will never be above Math.PI*2 Hope this helped! Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 14, 2017 Share Posted November 14, 2017 Hi @RaananW, thx4help! I still see a "long animation", under certain circumstances. Run #8, then pan camera right... past the yellow box, past the blue box again, and then click on yellow. I see camera alpha animation "unwind". Anyone else see that? Probably easier to see with slower animation. *scratch scratch* Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 14, 2017 Share Posted November 14, 2017 Ohhh, negative values Here - http://www.babylonjs-playground.com/#XCGI1K#9 . JavaScript % operator is sometimes weird... Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 14, 2017 Share Posted November 14, 2017 Thx @RaananW! Did you test the other way? Pan left, past yellow, past blue, then click yellow. Same problem, the other way, it seems. What a pain-in-the-butt I am, eh? Sorry. Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 14, 2017 Share Posted November 14, 2017 It is all about getting both values to be maximum Math.PI*2 apart from each other. I allow you guys to find a nice solution to achieve that Quote Link to comment Share on other sites More sharing options...
Wingnut Posted November 14, 2017 Share Posted November 14, 2017 Ok Xav, Raanan says it's time for helper-bail, so I guess you have all the tools to get the job done. I have plenty of other stalled user-issues to work-on, so, good luck. Thx for info/help, Raanan... I think you are correct... Xav has some new knowledge, now. Me, too. Give it a good try, Xav. Holler-back later if you get stuck. Quote Link to comment Share on other sites More sharing options...
Xav Posted November 15, 2017 Author Share Posted November 15, 2017 Thank you for your time. I will take the time to look at this to find the solution. Good luck and thank you again Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Xav Posted November 15, 2017 Author Share Posted November 15, 2017 Hi ! I think I have fixed the problem: Ligne 52 with this condition if (EndAlpha - StartAlpha > Math.PI){ EndAlpha = EndAlpha - (Math.PI*2); } http://www.babylonjs-playground.com/#XCGI1K#11 Thank you for putting me on the right path GameMonetize and RaananW 2 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.