I am trying to clone some Vector3 but the copy that clone method makes is made by all zero in x,y and z values. An example:
The output of this statement
console.log(this.geometries[j].vertices[i].multiplyScalar(1));
is
LabeledVertex {x: -0.5, y: 0.5, z: 2.6745e-12, label: "U", constructor: function…}
(LabeledVertex is simply an extension of THREE.Vector3)
if I clone this last one
position = this.geometries[j].vertices[i].clone().multiplyScalar(1);
the content inside position is: THREE.Vector3 {x: 0, y: 0, z: 0, constructor: function, set: function…}.
As you can see is made by all zeros. This happens with version r71 of Threejs.
Always make new vector, if you want calculate with, or clone itn fist and calculate with it after in new syntax:
var v2 = v1.clone();
v2 = v2.multiplyScalar( 2 );
//or
v2 = new THREE.Vector3(v1.x,v1.y,v1.z).multiplyScalar( 2 );
//or from gaitat comment
v2 = v1.clone().multiplyScalar( 2 );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With