The pack
attach3d
function attach3d(): Pack<{ attach: Attach3dApi }>
The attach-3d pack: local poses composed into world poses every step. Requires a 3D world. The child
is written in WORLD space, so nothing else in the engine has to know it is attached.
Types
Attach3dApi
interface Attach3dApi
game.attach.
to(child: Handle, parent: Handle, offset?: AttachOffset): void— Attachchildtoparentat a local offset. Re-attaching moves it.detach(child: Handle): void— Detach, leaving the child where it currently is in the world.parentOf(child: Handle): Handle | null— The parent of a child, or null.childrenOf(parent: Handle): ReadonlyArray<Handle>— Everything attached to a parent, direct children only.offset(child: Handle, offset: AttachOffset): void— Change a child's local offset without re-attaching. Only the fields given are written.readonly count: number— How many attachments are live.
AttachFace
type AttachFace = 'top' | 'bottom' | 'left' | 'right' | 'front' | 'back'
A face of the parent's box, named by the direction it looks. The child is laid ON that face: its local
+Y — the way every geometry-3d plane already faces — is turned to point out along the face normal,
and its position is the centre of that face, in the parent's own units, so it stays put however the parent
is scaled or turned.
AttachOffset
interface AttachOffset
Where a child sits relative to its parent.
x?: number— Local x. Default 0. In the PARENT's units whenfaceorinheritScaleis set, world units otherwise.y?: number— Local y. Default 0. In the PARENT's units whenfaceorinheritScaleis set, world units otherwise.z?: number— Local z. Default 0. In the PARENT's units whenfaceorinheritScaleis set, world units otherwise.yaw?: number— Local yaw, radians. Default 0. Applied within the child's own frame, so it spins in place on aface.pitch?: number— Local pitch, radians. Default 0.roll?: number— Local roll, radians. Default 0.sx?: number— The child's local x scale. Defaults to whatever it had when it was attached.sy?: number— The child's local y scale. Defaults to whatever it had when it was attached.sz?: number— The child's local z scale. Defaults to whatever it had when it was attached.inheritScale?: boolean— Ride the parent's SIZE as well as its pose: the child's own scale becomes its local scale times the parent's, per axis, and its offset is measured in the parent's units. Default false — a crate's size never inflates its rider, and that remains the common case. Turn it on when parent and child are one object made of two meshes: a tile and the number on it, a card and its border, a button and its cap. Then one tween of the parent's scale — a pop, a squash, a shrink into nothing — moves the whole assembly, instead of every mesh being driven by hand in step.face?: AttachFace— Lay the child ON a face of the parent's box: seeAttachFace. Position, orientation and the parent's units are all handled, so a label stays centred and flat on a face of a box that is being scaled, spun and tweened.lift?: number— How far clear of that face to sit, in WORLD units. Default 0.002. Two exactly coplanar surfaces fight for the depth buffer and the seam flickers as the camera moves, so a plate on a face needs a hair of clearance. This is that hair, not a design offset — it stays a fixed world distance however the parent is scaled, because depth precision does not care how big the parent is. Put deliberate distance inyinstead, which is measured in the parent's units.


