rina Posted March 22, 2018 Share Posted March 22, 2018 Hi, I want to change camera position on button click in Babylon js so please help hoe to do this. Quote Link to comment Share on other sites More sharing options...
Guest Posted March 22, 2018 Share Posted March 22, 2018 Hello:) you are in the wrong subforum. This is not a bug Can you create a playground of your issue? We have not enough info right now: which camera? is it an HTML or GUI button, etc... Quote Link to comment Share on other sites More sharing options...
rina Posted March 23, 2018 Author Share Posted March 23, 2018 Thank you for your reply I have html button when i click on button i want to chanage position of camera with rotation effect. Like Microsoft xbox example in 3D view.See below video link for what i want https://xboxdesignlab.xbox.com/en-us/customize https://www.screencast.com/t/LbWGVijQA7 And also i have created playground http://www.babylonjs-playground.com/#38KBQB I want to do same xbox effect in my design.but it not working properly,see below video link.Rotate Sphere multiple time and after that click on Sphere. https://www.screencast.com/t/w4vsIPGNgaJl Quote Link to comment Share on other sites More sharing options...
vishnu Posted March 23, 2018 Share Posted March 23, 2018 hi, i think this is okay for you scene.registerBeforeRender(function (){ var view = window.localStorage.getItem("view"); if(scene.isReady()){ if(view == "left"){ you will set camera position and rotation }else if(view == "right"){ you will set camera position and rotation }else if(view == "top"){ you will set camera position and rotation }else if(view == "bottom"){ you will set camera position and rotation }else if(view == "front"){ you will fix camera position and rotation }else if(view == "back"){ you will fix camera position and rotation } } }); Quote Link to comment Share on other sites More sharing options...
rina Posted March 23, 2018 Author Share Posted March 23, 2018 Thank you vishnu, I have try your code but it's not working. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 23, 2018 Share Posted March 23, 2018 Hi gang! https://www.babylonjs-playground.com/#3U658N#2 There is a playground demo that a forum friend and I... built for a project. It's 7 HTML buttons are created dynamically, with JS. It has 7 preset camera positions... each in a function. It might be useful for you, Rina. Quote Link to comment Share on other sites More sharing options...
rina Posted March 23, 2018 Author Share Posted March 23, 2018 Hi Wingnut I have viewed your demo and it not helpful for me.because i want to change camera position with rotation effect. I can explain you in detail with your example,When you rotate your box and after that click on "setDefault" button it jump on default position without any effect,see below video link. https://www.screencast.com/t/isH74uUiu1f I want to use same rotation effect like in Microsoft Xbox.When you rotate Xbox remote multiple times and after that click on back button then it change camera position with proper rotation. See below video link https://www.screencast.com/t/sHJ0BgqYN23 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 23, 2018 Share Posted March 23, 2018 Hi Rina. I'm working on animation. https://www.babylonjs-playground.com/#3U658N#4 ONLY working-on setLateralLeft button, so far. Animation working ok... done in lines 195-203. But see lines 192 and 193? I want to use THOSE instead, and disable 195-203. The two important functions are in lines 164-180. But I have problems: https://www.babylonjs-playground.com/#3U658N#5 Line 193... the camera mover (not the camera target mover)... is failing. Something is wrong with the actual animator line... line 178. I cannot yet find my mistake. I will keep trying, and maybe others will help me find the problem. After we get animateCameraTargetToPosition() and animateCameraToPosition() working properly, then I will change the other 6 camera-mover functions... to use those new functions... for animating the camera position and orientation. Stay tuned. Help me see my mistake, if you can. Line 202 works... so why not line 178? hmm. *scratch scratch*. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 23, 2018 Share Posted March 23, 2018 Whelp... https://www.babylonjs-playground.com/#3U658N#6 I couldn't get my two cool functions to work... so I did it the long way. Line 282 is failing. 'setDefault' button is failing (until some other button is pressed first) The other 6 camera position funcs are working ok. Animations seem to work. Something to play-with and do experiments-on, anyway. Sorry for the messy PG code. I hope I've been helpful. update: PG #7, slightly slimmer. Same issues. Swap lines 270/271, symptoms change. setCamLateralLeft() WILL run at sceneReady. setCamDefault() won't. Weird. SetDefault button works... sometimes. JackFalcon and Dad72 2 Quote Link to comment Share on other sites More sharing options...
JackFalcon Posted March 26, 2018 Share Posted March 26, 2018 ~Thanks, helpful... Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 26, 2018 Share Posted March 26, 2018 https://www.babylonjs-playground.com/#3U658N#7 I wish I could determine WHY line 270 is failing (and why setDefault button doesn't work, initially). The view that you see at PG run-up... is NOT "default view". It is simply some initial camera settings. setCamDefault() at line 205... is failing to animate. NOP 270, OP 271, and we see setCamLateralLeft() func works perfectly, at run-time. After it finishes, setDefault button works fine, again. Go fig. *scratch scratch* I think... after I figure out WHY this is happening, then I can also re-activate animateCameraTargetToPosition() and animateCameraToPosition() again... some streamlining tools. Quote Link to comment Share on other sites More sharing options...
Arte Posted March 26, 2018 Share Posted March 26, 2018 Hi All, Found something! Who knows? var forceRebuild = function () { cam.rebuildAnglesAndRadius(); }; scene.onBeforeRenderObservable.add(forceRebuild); Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 26, 2018 Share Posted March 26, 2018 Hiya Arte! Nice find! It works... almost. https://www.babylonjs-playground.com/#3U658N#9 Good setDefault run at 273. But, click setSuperior/setInferior buttons for awhile, and suddenly we get a canvas blue-screen-of-death. (I do, anyway). Your cool fix has some side effects, it seems. I think I know why. I think it is the "Polar Epsilon"... messing with rebuildAnglesAndRadius(). When cam beta values get near polar... rebuildAnglesAndRadius() does a divide by zero instead of a divide by epsilon (epsilon - a micro value used to avoid divide-by-zero errors, I think). Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 26, 2018 Share Posted March 26, 2018 https://www.babylonjs-playground.com/#3U658N#10 Yep, I was right, or sort-of. Lines 256 and 263. Instead of using 0 in the X and Z params, I changed to .001. Get those darned zeroes out of our way. Hey, thx for the fix, Arte! https://www.babylonjs-playground.com/#3U658N#13 (uses the animateCameraTargetToPosition() and animateCameraToPosition() funcs... so... tighter and cleaner. alright!) Arte 1 Quote Link to comment Share on other sites More sharing options...
Arte Posted March 26, 2018 Share Posted March 26, 2018 Wingnut I have just found old topic. Nice animate camera (target, position) set! PARTY! Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 26, 2018 Share Posted March 26, 2018 Are you going to make the BJS GUI version (instead of HTML)? This PG could get lonely... without its "sister" version. Quote Link to comment Share on other sites More sharing options...
razieh Posted September 4, 2018 Share Posted September 4, 2018 On 3/23/2018 at 4:29 PM, Wingnut said: Whelp... https://www.babylonjs-playground.com/#3U658N#6 I couldn't get my two cool functions to work... so I did it the long way. Line 282 is failing. 'setDefault' button is failing (until some other button is pressed first) The other 6 camera position funcs are working ok. Animations seem to work. Something to play-with and do experiments-on, anyway. Sorry for the messy PG code. I hope I've been helpful. update: PG #7, slightly slimmer. Same issues. Swap lines 270/271, symptoms change. setCamLateralLeft() WILL run at sceneReady. setCamDefault() won't. Weird. SetDefault button works... sometimes. its sounds cool but if you have a webverfrecamera ? how can you change the position of camera Quote Link to comment Share on other sites More sharing options...
Wingnut Posted September 4, 2018 Share Posted September 4, 2018 Hi @razieh, welcome to the forum. Likely, you will need to convert the HTML menu panel... into Babylon GUI stack panel. Camera-moving funcs won't need to change. Just change the type of buttons... from HTML... into Babylon GUI. 10 minute job. Ok, maybe 30 minutes. http://doc.babylonjs.com/search/?bjsq=gui StackPanel's aren't the only way to arrange buttons/controls in Babylon GUI 2D. There is also "grid". Here is a SWEET grid example: https://www.babylonjs-playground.com/#WZZDNR#7 Good luck. Keep us posted. Quote Link to comment Share on other sites More sharing options...
razieh Posted September 12, 2018 Share Posted September 12, 2018 now im working with unity and babylonjs .... but there isnt a good tutorial to get into it ... with unity i can design .... but now i dont know how can write my script ... i found just two video https://www.youtube.com/watch?v=Hq-p9EqhaWE https://www.babylontoolkit.com/videos/GettingStarted.mp4 it was helpfull but i want more event like clicking gazing teleport to some where im writing script for gear vive ... i saw some option to check it and use the webvr but the event i dont know about it :((((( 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.