# MML element reference

MML ELEMENT REFERENCE (units: metres, degrees, milliseconds)
Shared on visual elements: id, class, x y z, rx ry rz, sx sy sz, visible, collide (default true), collision-interval, onclick, oncollisionstart/oncollisionmove/oncollisionend, socket (attach to a bone of a parent m-character).
- m-group: container; transforms apply to children.
- m-cube: width height depth (1), color, opacity.   m-sphere: radius (0.5).   m-cylinder: radius (0.5), height (1).   m-plane: width height (a vertical plane; rx="-90" makes a floor).
- m-model: src (https .glb), anim (animation .glb), anim-loop, anim-enabled, anim-start-time, anim-pause-time.
- m-character: like m-model but for rigged avatars; child <m-model socket="hand_r"> parts attach to bones.
- m-light: type (point|spotlight), color, intensity, distance (0 = infinite), angle (spotlight), enabled. Otherside worlds are already lit: never add general/fill/sun lights. Only local lights with distance 3-10 m and intensity about 5-10 (tested: two unlimited lights at 30 and 15 washed a whole scene out in the Swamp). Prefer emissive for glow.
- m-label: content, width, height, font-size (24), font-color, color (background, must be solid), alignment (left|center|right), padding, emissive.
- m-image: src, width/height (one is enough, the other follows the aspect ratio), opacity, emissive.
- m-video: src, width, height, loop, enabled, volume, start-time, pause-time, emissive. Keep volume at 0.5 or lower.
- m-audio: src, loop, loop-duration, volume, cone-angle, cone-falloff-angle, start-time, pause-time, enabled. SAFE SOUND: volume 0.5 or lower (never above 0.8). Everyone in the world instance hears it, so keep it local: for looping/long sounds add an m-position-probe (range 10-15 m) that sets volume only while someone is near and 0 when they leave. Audio files should be normalised to about -23 LUFS.
- m-frame: src (another wss:// or https MML document), load-range, unload-range, min-x..max-z bounds. Embed one scene in another.
- m-prompt: message, placeholder, prefill; onprompt gives event.detail.value (text the player typed). Put a clickable child (e.g. a cube) inside.
- m-link: href (opens a web page).
- m-interaction: range (5), prompt, in-focus (default true: only while the player looks at it), line-of-sight (default false), priority (default 1; the LOWER number is shown first in MML); oninteract fires when a player uses it. Native ODK interactables are a different system (highest priority wins); see mml_guide targets.
- m-position-probe: range, interval; events positionenter / positionmove / positionleave with event.detail.connectionId and positions.
- m-chat-probe: range; onchat gives the chat message and connectionId.
- m-attr-anim: attr, start, end, duration (1000), loop (default true), ping-pong, ping-pong-delay, easing, start-time, pause-time. Place it inside the element it animates. Runs on the shared clock, so it's the smoothest way to move things.
- m-attr-lerp: attr (list or "all"), duration, easing. Smooths every later change of those attributes. The Cave server turns these into shared-clock m-attr-anim glides automatically.
Events in scripts: element.addEventListener("click", (e) => e.detail.connectionId); window.addEventListener("connected"/"disconnected", (e) => e.detail.connectionId).

## Characters and avatars

CHARACTERS AND AVATARS
- Structure: <m-character src="https://.../body.glb"> with child <m-model src="..." socket="head|hand_r|hand_l|spine_03|..."> parts. Use generate kind=character to build one.
- Otherside avatar specs (from Otherside's avatar docs): rigged to the UE5 Mannequin skeleton, max 4 bone influences per vertex, GLB, up to 50,000 triangles, textures up to 2048x2048, 1-2 m tall, under 20 MB (under 10 MB recommended), PBR maps (base colour, normal in OpenGL Y+, packed ORM, emissive). At most 12 meshes per character, attachments included.
- Otherside plays its own standard animation set on avatars, so animations in the MML are ignored for avatars. NPC-style characters placed in a scene (m-model with anim) do play their animation.
- Common sockets: head, neck_01, spine_03, spine_02, pelvis, hand_r, hand_l, lowerarm_r/l, upperarm_r/l, thigh_r/l, calf_r/l, foot_r/l.
- Use m-model (not m-character) for statues, props and NPCs that don't need player bones.

## Building patterns

BUILDING PATTERNS
- Dungeons: generate kind=dungeon (seeded rooms + corridors, merged walls, torches, spawn and exit pads). Change seed for a new layout; same seed gives the same layout. Add doors, traps and loot as separate elements with ids, then script them.
- Mazes: generate kind=maze. Rooms/houses: kind=room. Stairs: kind=stairs (spiral:true for towers). Rings of pillars, fences, rows of seats: kind=array with mode circle|grid|line and your own html snippet.
- Signs and UI: kind=sign, or m-label with a solid background.
- Doors: an m-cube with onclick that CaveKit.moveTo's it up or sideways; save the state with CaveKit.save.
- Buttons and triggers: clickable cubes (clicks worked in one Swamp test, X01). m-position-probe (area detection) and m-interaction ("Press E" prompt) are on Otherside's not-supported-yet list and each failed in one Swamp test (X07, X04), so use them only as extras next to a click control. Collision pads (collision-interval) are not tested yet (X08).
- Keep every generated block in its own <m-group id="..."> so it can be moved, found and replaced later.
- To combine scenes, use m-frame src="wss://<host>/<other-slug>" or paste generated groups into one scene.
- Positions: y is up; the ground is y=0. A 1.8 m avatar needs doorways at least 2.2 m tall and 1.2 m wide.
