Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when setting camera.position to Vector3 #11372

Closed
3 of 11 tasks
kgoedecke opened this issue May 21, 2017 · 2 comments
Closed
3 of 11 tasks

Issue when setting camera.position to Vector3 #11372

kgoedecke opened this issue May 21, 2017 · 2 comments
Labels

Comments

@kgoedecke
Copy link

kgoedecke commented May 21, 2017

Description of the problem

I noticed that when setting the position for PerspectiveCamera to a THREE.Vector3 nothing is displayed, but when I directly set the values, it works just fine.

camera.position.set( 0, 0, 0 );

works, but

var newVector = new THREE.Vector3(0, 0, 0)
camera.position.set(newVector);

doesn't. I was wondering if this is a bug?

See the following two JSFiddle:
L8-10: https://jsfiddle.net/4zqkn7yw/5/
L9: https://jsfiddle.net/4zqkn7yw/4/

Three.js version
  • r82
Browser
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, ...)
@Mugen87
Copy link
Collaborator

Mugen87 commented May 21, 2017

That's not a bug. Try this:

var newVector = new THREE.Vector3( 0, 0, 0 )
camera.position.copy( newVector );

Have a look at the docs of Vector3 in order to understand the API.

@WestLangley
Copy link
Collaborator

WestLangley commented May 21, 2017

Object3D's position, rotation, quaternion and scale properties are immutable.

The following pattern is invalid:

object.position = vector;

Instead, you must use either

object.position.set( x, y, z );

or

object.position.copy( vector );

See Object3D.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants