Filipe Costa Filipe Costa - 1 year ago 82
Javascript Question

Set and clone works differently

i have some doubts about Set and clone on Three js, im trying to render a scene where a sphere moves trought x axis and the camera follow the move with the lookAt, i tryed to do by myself the example on the book learning three js, but i didnt used the clone and my scene did the same but i couldnt see the sphere, with the clone i could see the sphere can someone explain me why that happen??

here is the 2 different codes:

sphere.position.copy(new THREE.Vector3(x,10,0));

sphere.position.set(new THREE.Vector3(x,10,0));

the first shows the sphere the second not :S

Answer Source

position is THREE.Vector3

look at reference and implementation

Vector3.set takes 3 values : numbers x,y and z

Vector3.copy takes Vector3

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download