Learning on Web Dev Open is free for all.

Immersive Web > The 3D mental modelFive coordinate spaces and the argument about Y
Phase 07The 3D mental model335 of 434

Five coordinate spaces and the argument about Y

Object, world, view, clip and screen, plus radians, handedness, and why Euler angles betray you at ninety degrees.

Concept14 minAI pair

A vertex starts in object space, where the model was authored with its own origin. The world matrix puts it in world space, shared by everything in the scene. The camera view matrix moves it into view space, where the camera sits at the origin looking down negative Z. The projection matrix takes it to clip space, and the division that follows gives normalised device coordinates, a cube from -1 to 1. The viewport transform maps that to pixels.

Web 3D is right-handed with Y up, while the fragment coordinate you get inside a shader has its origin at the bottom-left and textures generally do not, which is why an upside-down texture is the single most common first bug of the phase and almost never a bug in your maths. Angles are radians everywhere. Assume degrees anywhere and you get a rotation about fifty-seven times too large.

Euler angles are readable and lossy: apply them in a different order and you get a different orientation, and at ninety degrees two of the three axes collapse into one and you lose a degree of freedom. Quaternions do not have that failure, cannot be read by a human, and interpolate smoothly, which is why every animation system stores them and every inspector shows you Euler.

You should now be able to

  • Name the five spaces a vertex passes through
  • Convert a world position into screen coordinates
  • Say when a quaternion is worth the inconvenience
Ask the community

Loading…