Jump to content

A bigger issue about arcRotateCamera


celian-garcia
 Share

Recommended Posts

Hello !

It's me again ^^ I found smthg bad with the function setPosition() of arcRotateCamera

 

Here is an example that will show what I mean

http://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 with

freeCam.position = newPosition ;

the camera is at the good position

 

 

 

But ! When we set the position of an ArcRotateCamera with

arcCamera.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 function

ArcRotateCamera.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 =)

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...