PF Villard d'après le cours de Eric Haines (Autodesk Inc.) disponible sur Udacity
var a = new THREE.Vector3( 1., 0., 0. ) ;
var b = new THREE.Vector3( 0., 1., 0. ) ;
var c = new THREE.Vector3() ;
c=crossVectors (a, b);
Construire un vecteur :
Vector3( x, y, z) ;
Propriétés :
.x
.y
.z
Méthode :
.set(x, y , z)
cube.position.x = xPosition;
cube.position.y = yPosition;
cube.position.z = zPosition;
cube.rotation.x = xRotationInRadians; // e.g. -70 * Math.PI/180
cube.rotation.y = yRotationInRadians;
cube.rotation.z = zRotationInRadians;
cube.scale.x = xSize;
cube.scale.y = ySize;
cube.scale.z = zSize;
Three.js
est toujours scale, rotate, translate
box.position.x = 3.0;
box.rotation.y = 5.7;
est équivalent à :
box.rotation.y = 5.7;
box.position.x = 3.0;
qui est aussi équivalent à :
box.rotation.y = 122113.01;
box.rotation.y = 5.7;
box.position.x = 78893.02;
box.position.x = 3.0;
Rotation puis scale
var block = new THREE.Mesh(
new THREE.CubeGeometry(100,4,4), clockHandMaterial);
block.position.x = 40;
// Faire l’objet parent
var clockHand = new THREE.Object3D();
clockHand.add( block );
clockHand.rotation.y = -70 * Math.PI/180;
scene.add( clockHand );