Coordinate frames
The tables below summarise each frame. For explanations and worked examples, see the Coordinate frames guide.
Space frames
Section titled “Space frames”| Frame | Origin | Axes / units | Read with | Set with |
|---|---|---|---|---|
| Region | South-west corner of the region, height 0 | +X east, +Y north, +Z up; metres, 0–256 horizontally | llGetPos (unattached), llGetRootPosition, llGetRootRotation, llGetRot (except an attachment root), llDetectedPos, llCastRay, OBJECT_POS, PRIM_POSITION and PRIM_ROTATION (always region, also for children and attachments) | llSetRegionPos, llSetPos on an unattached root |
| Global (grid) | South-west corner of the grid | Region axes; metres | llGetRegionCorner + region position | Convert to region first |
| Local (child prims) | The root prim | The root’s axes; metres | llGetLocalPos, llGetLocalRot, PRIM_POS_LOCAL, PRIM_ROT_LOCAL | llSetPos on a child, llSetLocalRot, PRIM_POS_LOCAL, PRIM_ROT_LOCAL |
| Attachment | The attach point | The attach point’s axes; metres | llGetLocalPos, llGetLocalRot in the attachment root | llSetPos, llSetLocalRot on the attachment root |
| Avatar (in an attachment) | The wearer | Region axes | llGetPos (wearer’s region position), llGetRootRotation (wearer’s region rotation) | Not settable |
| HUD (screen) | Each HUD attach point, on screen | +X into the screen, +Y left, +Z up; about 1 unit tall (Z −0.5 to +0.5), width depends on aspect ratio | llGetLocalPos, llGetLocalRot | llSetPos, llSetLocalRot |
Object axes (local flag) | — | FALSE: region axes; TRUE: the object’s axes | — | llApplyImpulse, llSetForce, llSetTorque, llSetAngularVelocity, llApplyRotationalImpulse |
| Camera | Region frame (the avatar’s region for CAMERA_POSITION and CAMERA_FOCUS) | Region axes; metres | llGetCameraPos, llGetCameraRot | CAMERA_POSITION, CAMERA_FOCUS |
| Camera (follow) | The avatar’s position | Relative to the avatar; metres | — | CAMERA_FOCUS_OFFSET (ZERO_VECTOR looks at the avatar’s llGetPos), CAMERA_DISTANCE, CAMERA_PITCH |
| Prim-local offsets | The prim | The prim’s axes; metres | — | llSitTarget offset and rotation, llSetLinkCamera eye and at |
llTargetOmega spins a root around a region axis (an attachment
around the attachment’s axis) and a child around its own local axis. Seated avatars are links
after the last prim, positioned relative to the root.
Conversions
Section titled “Conversions”// Child local to regionvector regionPos = llGetRootPosition() + llGetLocalPos() * llGetRootRotation();rotation regionRot = llGetLocalRot() * llGetRootRotation();
// Region to child localvector localPos = (regionPos - llGetRootPosition()) / llGetRootRotation();rotation localRot = regionRot / llGetRootRotation();
// Region to global, and backvector globalPos = llGetRegionCorner() + llGetPos();vector backToRegion = globalPos - llGetRegionCorner();
// Velocity from region axes to the object's axesvector localVel = llGetVel() / llGetRot();Gotchas
Section titled “Gotchas”llSetRoton a child is offset by the root rotation; usellSetLocalRot(globalRot / llGetRootRotation())orPRIM_ROT_LOCALinsteadllSetPosis local on a child, region on an unattached root, and relative to the attach point on an attachment rootllGetLocalPoson an unattached root returns the region positionPRIM_POSITIONwithLINK_SETmixes frames (root in region or attachment coordinates, children local); useLINK_ROOTllGetRoton an attachment root reports the avatar’s rotation; usellGetLocalRot- An avatar’s facing is only accurate seated or in mouselook
- Animations are invisible to the simulator: there is no skeleton to read
- No member access on a function return: assign
llGetPos()to a variable before reading.z
Surface frames
Section titled “Surface frames”| Function | Frame | Notes |
|---|---|---|
llDetectedTouchST | Face, [0, 1], origin bottom-left | Unaffected by the texture |
llDetectedTouchUV | Texture coordinates | Change with repeats and rotation; vertical flipped on glTF mesh |
llDetectedTouchPos | Region | Metres |
llDetectedTouchNormal, llDetectedTouchBinormal | Region axes | Surface normal and the +T tangent |
Texture transforms
Section titled “Texture transforms”Blinn-Phong (PRIM_TEXTURE, PRIM_NORMAL, PRIM_SPECULAR) | PBR (PRIM_GLTF_*) | |
|---|---|---|
| Origin | Bottom-left | Top-left |
| V direction | Up | Down |
| Pivot | Centre | Top-left corner |
| Positive rotation | Counter-clockwise | Clockwise |
| Order | Rotate, scale, offset | Scale, rotate, offset |
| Offset | From the centre | From the top-left corner |
| Repeats | Per face (default mapping) or per half metre (planar) | The same |
Converting Blinn-Phong to PBR: rotation becomes -rotation, the V offset changes sign, and the
scale is only exact at multiples of 90°. Source: the viewer’s texture transform code
(llface.cpp, textureUtilV.glsl, llgltfmaterial.cpp). Not yet tested in-world: whether
PRIM_GLTF_* values from LSL reach the viewer unchanged, and which way the texture visibly
turns. LSL functions for the conversion are in the guide’s
Texture transforms section.