20240428 1009
Tags:
transformations
Move objects
position
- possesses 3 essential properties, which are
x
,y
, andz
- instance of the Vector3 class
Useful vector methods
vector length
console.log(mesh.position.length())
distance from another Vector3
console.log(mesh.position.distanceTo(camera.position))
normalise vector
console.log(mesh.position.normalize())
set x, y, z
mesh.position.set(0.7, - 0.6, 1)
Axes helper
- Display 3 lines corresponding to the
x
,y
andz
axes - each starts at the center of the scene and going in the corresponding direction
- 🟢
y
axis - 🔴
x
axis - 🔵
z
axis
/**
* Axes Helper
*/
const axesHelper = new THREE.AxesHelper(2) // length of line
scene.add(axesHelper)
Scale objects
scale
is also a Vector3- By default,
x
,y
andz