Atlaslog
Atlaslog / three.js / API reference / Vector3
three.js · API reference

Vector3

Quick answer

Vector3 stores x, y, z and serves as position, direction, normal, and scale throughout three.js. Chainable methods like set(), add(), cross(), normalize(), applyMatrix4(), and project() make it the workhorse type for geometry and camera math. Remember that these methods mutate the vector and return this.

Last verified 2026-11-03 · three.js 0.160.0 · Cite this page
new THREE.Vector3 ( x , y , z ) → Vector3
Key points
Example
const a = new THREE.Vector3(1, 2, 3);
const b = new THREE.Vector3(4, 0, -2);
const mid = new THREE.Vector3().addVectors(a, b).multiplyScalar(0.5);
const offset = new THREE.Vector3().subVectors(b, a);
const dist = offset.length();
const dir = offset.normalize();   // 注意:normalize 会改写 offset

mesh.position.copy(mid);
mesh.lookAt(b);
const R = 6371000;   // 地球平均半径,单位米

function lonLatToVector3(lon, lat, radius) {
  const phi = THREE.MathUtils.degToRad(90 - lat);
  const theta = THREE.MathUtils.degToRad(lon);

  return new THREE.Vector3(
    radius * Math.sin(phi) * Math.cos(theta),
    radius * Math.cos(phi),
    radius * Math.sin(phi) * Math.sin(theta)
  );
}

const beijing = lonLatToVector3(116.39, 39.9, 1);
Notes
Runnable examplesChinese originalAll API references
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Cite this page

Atlaslog (2026). Vector3. https://www.jingweizhi.com/en/three/api/vector3.html (accessed 2026-11-03).