Vector2
Quick answer
Vector2 holds two components and appears in screen coordinates, normalized device coordinates, and texture UVs. Methods such as add(), multiplyScalar(), distanceTo(), angle(), and applyMatrix3() operate in place and return this for chaining. Remember that screen y grows downward while UV and NDC y grow upward.
new THREE.Vector2 ( x , y ) → Vector2
Key points
- set(x, y) and copy(v) overwrite components; clone() returns an independent Vector2.
- angle() measures counter-clockwise from +X in the range -π to π.
- applyMatrix3() supports UV transforms through a Matrix3.
Example
const pointer = new THREE.Vector2();
function onPointerMove(event) {
const rect = renderer.domElement.getBoundingClientRect();
pointer.x = ((event.clientX - rect.left) / rect.width) * 2 - 1;
pointer.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
}
renderer.domElement.addEventListener('pointermove', onPointerMove);texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set(8, 8); // 覆盖 8 × 8 次
texture.offset.set(0.5, 0);
Notes
- Mixing screen y-down and UV y-up coordinates mirrors picking results vertically.
- Nearly all methods mutate in place; reusing an operand as a target corrupts input.
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Atlaslog (2026). Vector2. https://www.jingweizhi.com/en/three/api/vector2.html (accessed 2026-11-03).