celian-garcia Posted June 15, 2014 Share Posted June 15, 2014 Hello !It's me again ^^ I found smthg bad with the function setPosition() of arcRotateCamera Here is an example that will show what I meanhttp://jsfiddle.net/5tScG/8/In this example, you have to change the value of arcRotate variable to « switch » of cameras. The problem is :In case of newPosition.x < 0 and newPosition.z < 0 When I set the position of a freeCamera withfreeCam.position = newPosition ;the camera is at the good position But ! When we set the position of an ArcRotateCamera witharcCamera.setPosition(newPosition) ;the camera is at the opposite of the expected position. Good new, I identified the problem, it comes from the setPosition function and the atan functionArcRotateCamera.prototype.setPosition = function (position) { var radiusv3 = position.subtract(this._getTargetPosition()); this.radius = radiusv3.length(); this.alpha = Math.atan(radiusv3.z / radiusv3.x); this.beta = Math.acos(radiusv3.y / this.radius);};I think in this case it is better to use the other function of conversion which take in count the sign of the z value.ArcRotateCamera.prototype.setPosition = function (position) { var radiusv3 = position.subtract(this._getTargetPosition()); this.radius = radiusv3.length(); 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; } this.beta = Math.acos(radiusv3.y / this.radius);}; I'll test tomorrow this function with different values in order to be sure of the code =) Quote Link to comment Share on other sites More sharing options...
celian-garcia Posted June 15, 2014 Author Share Posted June 15, 2014 Sorry not the good jsfiddle... Here it is http://jsfiddle.net/5tScG/9/ Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 16, 2014 Share Posted June 16, 2014 Sounds good! I let you publish a pull request to get some credits Quote Link to comment Share on other sites More sharing options...
celian-garcia Posted June 16, 2014 Author Share Posted June 16, 2014 Ok =) I test it in all ways and I prepare you a pull request Quote Link to comment Share on other sites More sharing options...
celian-garcia Posted June 16, 2014 Author Share Posted June 16, 2014 I've done the pull request. Hoping all is ok =) 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.