satguru Posted February 7, 2016 Share Posted February 7, 2016 Any reason why this check for equal position was added in 2.3 https://github.com/BabylonJS/Babylon.js/blob/master/src/Cameras/babylon.arcRotateCamera.ts#L492 This changes the behavior subtly In 2.2 if I wanted to change the target but keep the same position I would save the current position, change the target and do setPosition() using the saved current position. This would have resulted in the alpha, beta ,radius being re-calculated based on the new target while keeping the same position. In 2.3 because of the above check all this is bypassed. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 8, 2016 Share Posted February 8, 2016 Hum I did not think about this case. I updated the code to be more convenient: public rebuildAnglesAndRadius() { var radiusv3 = this.position.subtract(this._getTargetPosition()); this.radius = radiusv3.length(); // Alpha this.alpha = Math.acos(radiusv3.x / Math.sqrt(Math.pow(radiusv3.x, 2) + Math.pow(radiusv3.z, 2))); if (radiusv3.z < 0) { this.alpha = 2 * Math.PI - this.alpha; } // Beta this.beta = Math.acos(radiusv3.y / this.radius); this._checkLimits(); } public setPosition(position: Vector3): void { if (this.position.equals(position)) { return; } this.rebuildAnglesAndRadius(); } public setTarget(target: Vector3): void { if (this.target.equals(target)) { return; } this.rebuildAnglesAndRadius(); } Now you can just set the target and this should be enough Quote Link to comment Share on other sites More sharing options...
satguru Posted February 8, 2016 Author Share Posted February 8, 2016 maybe setPosition() public setPosition(position: Vector3): void { if (this.position.equals(position)) { return; } this.position = position; this.rebuildAnglesAndRadius(); } Also if you change setTarget() won't that break other people existing code? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 8, 2016 Share Posted February 8, 2016 Nope (Do you feel how sure I am? :)) Changes are done btw Quote Link to comment Share on other sites More sharing options...
satguru Posted February 9, 2016 Author Share Posted February 9, 2016 5 hours ago, Deltakosh said: Nope (Do you feel how sure I am? :)) I will trust you on this Thanks for the change. Much conveneint for me now. Quote Link to comment Share on other sites More sharing options...
satguru Posted February 13, 2016 Author Share Posted February 13, 2016 Maybe I was too trusting Looks like the new setTarget() breaks the SceneLoader.load(). Now when a scene is loaded the arc camera does not move to the target. See https://github.com/BabylonJS/Babylon.js/blob/master/src/Cameras/babylon.camera.ts#L693 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 14, 2016 Share Posted February 14, 2016 I do not reproduce. Do you have a sample scene? Quote Link to comment Share on other sites More sharing options...
satguru Posted February 17, 2016 Author Share Posted February 17, 2016 see attached html. It uses babylonjs 2.4 it has a simple scene with ground, box and sphere. The camera targets sphere's position It has 2 buttons "save" and "load" - "save" serializes, "load" loads the serialized data. To test, open the file in browser, click save then click load. Notice the camera position has changed Now comment out the following line https://github.com/BabylonJS/Babylon.js/blob/master/src/Cameras/babylon.arcRotateCamera.ts#L526 and try again. behaves as expected the second time. index.html Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 17, 2016 Share Posted February 17, 2016 Do you have a way to reproduce it on the playground Quote Link to comment Share on other sites More sharing options...
satguru Posted February 18, 2016 Author Share Posted February 18, 2016 @Deltakosh hard to do this on playground tried anyway. see http://www.babylonjs-playground.com/#1LQGCI behaves weird - after load the arc camera turns into a free camera !! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 18, 2016 Share Posted February 18, 2016 This is an awful bug...I'll fix it soon Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 18, 2016 Share Posted February 18, 2016 Fixed: https://github.com/BabylonJS/Babylon.js/commit/ada2eb7f678c664ac28638b5a2b15f1775aa0aa9 Quote Link to comment Share on other sites More sharing options...
satguru Posted February 18, 2016 Author Share Posted February 18, 2016 @Deltakosh Much better now Now that , that problem is fixed , you can see the the original problem. I modified the PG demo slightly. It was hard to see the issue in the original demo, because the camera radius was very large. So I changed the radius from 50 to 5. http://www.babylonjs-playground.com/#1LQGCI#1 You can clearly see the problem now, when you do "save" and then "load" Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 19, 2016 Share Posted February 19, 2016 Working on it:) Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 19, 2016 Share Posted February 19, 2016 Fixed Quote Link to comment Share on other sites More sharing options...
satguru Posted February 19, 2016 Author Share Posted February 19, 2016 Great! Thanks 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.