Issue when setting camera.position to Vector3

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)

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

See the following two JSFiddle:

Three.js version
  • r82
  • All of them
  • Chrome
  • Firefox
  • Internet Explorer
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, …)

Author: Fantashit

2 thoughts on “Issue when setting camera.position to Vector3

  1. 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.

  2. 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 );


    object.position.copy( vector );

    See Object3D.js.

Comments are closed.