<sk-viewport-position-constraint>

← prev index next →

Pins a node to a fixed spot on the screen, ignoring camera motion — the way to make HUD markers, screen-space labels, and UI overlays inside a 3D scene.

Remarks

This is the screen-space member of the Constraint family, and the odd one out: instead of reading another scene object, it reads the viewport. Like every constraint it drives its constrained target by recomputing each frame — here it converts a screen position into world space against the current camera, so the target stays glued to that screen spot however the camera pans, orbits, or zooms.

Key attributes. mode chooses how the screen position is expressed: px (absolute CSS pixels, the default), percent (0–100 of viewport width/height, so it survives resizing), or anchor (offsets from a named corner/edge). In anchor mode, anchor names the reference point (e.g. top-left, bottom-right). x and y give the position or offset in the chosen mode's units, and z is the normalized-device depth (0 = near plane, 1 = far plane) that controls what the pinned node draws in front of or behind.

Related. It commonly pins annotation nodes (sk-live-annotation, sk-overlay-annotation). Unlike the other members of the Constraint family — sk-align-to-spline-constraint, sk-orbit-constraint, sk-target-at-constraint — it constrains to the screen rather than to another node; the GPU-parallel PointConstraint applies per-clone effects across a Cloner.

Serve these docs to run the live example. WebGPU needs a secure context — open this page via grunt serve rather than double-clicking the file. The Markup tab works from disk.

Attributes

AttributeTypeDefaultDescription
modeanimatable <viewport-position-mode> ("px" | "percent" | "anchor") Positioning mode.
anchor <anchor> ("center" | "top" | "bottom" | "left" | "right" | "top-left" | "top-right" | "bottom-left" | "bottom-right") Viewport anchor point (required when mode is 'anchor').
x <number> X coordinate: CSS pixels (px mode), percentage 0–100 (percent mode),
y <number> Y coordinate: CSS pixels (px mode), percentage 0–100 (percent mode),
z <number> The Z depth in normalized device coordinates (NDC).