Skip to content
Tutorials Center
My learning

Topics

Lesson 3 of 39 ยท Getting Started

Coordinates, Position, Rotation and Scale

Understand the Three.js right-handed coordinate system and learn to position, rotate and scale objects with Vector3, Euler angles and helpers.

Before you can arrange a scene you need to know where things are. Three.js uses a 3D coordinate system with three axes, and every object has three properties that place it: position, rotation and scale. This lesson teaches the axes, the units, and the first tools for moving things around.

The axes

Three.js is right-handed with Y pointing up. Look at the screen: x grows to the right, y grows up, and z points toward you. So a camera at z = 5 looks back toward the origin at (0, 0, 0).

flowchart TB
  O["Origin (0, 0, 0)"] --- X["+X: right"]
  O --- Y["+Y: up"]
  O --- Z["+Z: toward the viewer"]

Right-handed coordinates: +X right, +Y up, +Z toward you.

Units are arbitrary. One unit can be a meter, a foot or a pixel; pick a meaning and stay consistent. Many scenes use meters because physics, models and camera distances then feel natural.

Two helpers make the axes visible: AxesHelper(size) draws red (x), green (y) and blue (z) lines, and GridHelper(size, divisions) draws a floor grid.

Position

object.position is a Vector3, a small object with x, y and z fields. You can assign the fields directly, or use set().

JavaScript
mesh.position.x = 2;
mesh.position.set(2, 0.5, -1);
mesh.position.copy(other.position);
mesh.translateX(1);               // move 1 unit along its own x axis
console.log(mesh.position.length()); // distance from the origin

Rotation

object.rotation is an Euler: three angles in radians applied in an order (default "XYZ"). A full turn is 2 * Math.PI, a half turn is Math.PI. Use THREE.MathUtils.degToRad(90) if you prefer degrees.

JavaScript
mesh.rotation.y = Math.PI / 4;
mesh.rotation.set(0, THREE.MathUtils.degToRad(30), 0);
mesh.rotateZ(0.1);        // rotate a bit more around its own z axis

Euler angles are easy to read but they can suffer from gimbal lock, where two axes line up and one degree of freedom is lost. When you combine rotations in complex ways, use quaternions, covered in the lesson on transforms and math.

Scale

object.scale is another Vector3 that stretches the object along each axis. 1 is the original size; 2 doubles it; negative values mirror it.

JavaScript
mesh.scale.set(2, 1, 0.5);
mesh.scale.setScalar(1.5); // uniform scale

Scale also affects children, so a scaled parent scales everything inside it. Non-uniform scaling combined with rotation of a parent can shear children, so prefer uniform scale on parents.

Try all three

The demo below puts four cubes on a grid with axis lines. Edit the numbers to see how each property changes the result. The red cube is at the origin, the green one is moved along x, the blue one is rotated, and the yellow one is scaled.

Position, rotation and scale

Notice we placed the cubes at y = 0.5. A unit cube is centered on its position, so it reaches half a unit above and below. Lifting it by half its height makes it sit on the grid. This "pivot at the center" rule applies to most geometries and is a common source of "my object is sunk in the floor" confusion.

Local versus world space

Every position you set is relative to the object's parent. An object added directly to the scene is positioned in world space. An object added to a group is positioned in the group's local space, and moves when the group moves. The next chapter on the scene graph explores this fully, but you can already read the world position of any object:

Local and world positions

The child sits at local (0, 0, 2), but the parent is turned a quarter turn about y, so local +z points toward world +x. Add the parent's offset of 10 and the world position becomes (12, 0, 0).

Euler angles are applied in order, and the rotation of an object that has been changed in many steps may not look the way you expect. If rotation looks wrong, set rotation.order explicitly or switch to quaternions.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. In Three.js, which direction is +Y by default?

    The system is right-handed with Y up. X goes right and Z comes toward you.
  2. 2. Which unit does object.rotation use?

    Use THREE.MathUtils.degToRad() to convert if you think in degrees.
  3. 3. A unit BoxGeometry is placed at y = 0 on a floor at y = 0. What do you see?

    Geometries are centered on their origin, so half of a unit cube extends below y = 0.
  4. 4. Where is a child's position measured from?

    Local transforms are relative to the parent, which is why moving a group moves all its children.

Summary

  • Three.js is right-handed with +Y up and +Z toward the viewer.
  • position and scale are Vector3; rotation is an Euler in radians.
  • Geometries are centered, so lift objects by half their height to rest on a floor.
  • Positions are local to the parent; getWorldPosition gives the world result.
  • AxesHelper and GridHelper make the space visible while you debug.

Next: The Render Loop and Timing