Three.Js:2Xmeshes Using Same Vector as Position

THREE.js : 2xMeshes using same vector as position

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

See the source code file Object3D.js.

You can no longer use the following pattern:

object.position = vector;

Instead, you must use either

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

or

object.position.copy( vector );

three.js r.69

Three.JS: Get position along direction vector

var startPos = new THREE.Vector3(1.2, -2.34, 0.5);
var direction = new THREE.Vector3(0.6578737359955765, -0.24972916834682138, 0.710519166466616);
var distance = 1;

var newPos = new THREE.Vector3();
newPos.addVectors ( startPos, direction.multiplyScalar( distance ) );

THREE.js converting from 3D vector to 2D pixel position, interpreting z coordinate

vector.z represents the depth of the point from the screen. Regarding a pixel, or position on the screen, the depth doesn't matter as it doesn't affect the x or y position on the screen. So that component of the vector is not part of the solution, and thus ignored.

As to why it isn't 0, that's because projection multiplies the vertices with the camera matrix. Assuming the camera is positioned to view everything you need, and not pointed somewhere else, the projection function is putting distance (ie depth) between you and the scene.

How to change a scale in three js (through assignment)

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

See the source code file Object3D.js.

For example, you can no longer use the following pattern:

object.scale = vector;

Instead, you must use either

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

or

object.scale.copy( vector );

Similarly for the other properties mentioned.

three.js r.72

Can't copy a THREE.Vector3

You cannot assign an object's position a new THREE.Vector3, as you are doing:

this.position = new THREE.Vector3( 1, 2, 3 );

As explained in this answer, Object3D's position, rotation, quaternion and scale properties are immutable. Use the set() method, instead.

this.position.set( 1, 2, 3 );

three.js r.71



Related Topics



Leave a reply



Submit