FlashyGoblin Posted June 8, 2016 Share Posted June 8, 2016 So when switching back and forth between multiple scenes, the camera does an unexpected thing. Each scene has it's own camera, if I update the rotation of one camera, and then switch to a new scene, the new scene's camera animates to the rotation of the previous scene. Here is a Playground link. When the first scene loads, rotate the camera a bit. Then switch to the other scene by clicking on the fps counter in the top right of the screen. The new scene's camera rotations to the position of the previous scene's camera. http://www.babylonjs-playground.com/#1B3R9A#21 This only happens with the rotation, the position is fine. Any thoughts? Quote Link to comment Share on other sites More sharing options...
JohnK Posted June 8, 2016 Share Posted June 8, 2016 Could it be something to do with how windows deals differently with the keyboard input buffer and the mouse input buffer? For position one press of a key does one movement and buffer emptied (?). For rotation mouse movement is to do with change in mouse position and buffer retained (?). Not sure I really know what I am talking about. This may help (or not) https://msdn.microsoft.com/en-us/library/windows/desktop/ms682079%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted June 8, 2016 Share Posted June 8, 2016 Think "camera.attachControl(canvas, true);" needs to be part of the switching process, with only 1 camera attached at a time. Quote Link to comment Share on other sites More sharing options...
RaananW Posted June 13, 2016 Share Posted June 13, 2016 Hi Goblin, As JC said - detach and attach are the secret - http://www.babylonjs-playground.com/#7L1BY And (Playground only!) - you will need to remove the default render loop the playground is adding (I am hacking it in your register render loop function. This is not the BEST solution, but it works ) Also pay attention that registering a click event listener in the palyground must be unregistered, otherwise it will register again and again with every press of run. Hope that helps! 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.