Skip to content

<model>

<model> draws a rotatable 3D model inside a component — the item in a shop slot, the speaker’s head in a dialogue box, the character preview in an equipment screen.

src/armoury.ts2
<model x="center" y="center" w="fill" h="fill" item={Items.RUNE_SCIMITAR} zoom={520} />

<model> accepts all common props, plus one of these five, which say what to draw:

  • model: A model reference. The model to draw.
  • item: An item reference. Draws that item’s model instead.
  • npcHead: An NPC reference. Draws that NPC’s chathead, as a dialogue box does.
  • objectHead: A world-object reference. Draws that object’s model.
  • playerHead: A flag. Draws the local player’s own chathead.

and these, which say how:

  • itemCount: A number. The stack size, which for some items changes the model drawn.
  • itemCountMode: "auto", "never" or "always". As on <sprite>.
  • anim: An animation reference. Plays that animation on the model.
  • zoom: A number. Camera distance — larger is further away, so a larger number draws a smaller model.
  • pitch: A number, 0–2047. Rotation about the X axis.
  • yaw: A number, 0–2047. Rotation about the Y axis.
  • roll: A number, 0–2047. Rotation about the Z axis.
  • offsetX, offsetY: Numbers. Shift the model within the component, in screen space.
  • orthogonal: A boolean. Draws without perspective.
  • transparent: A boolean. Draws the model translucent.
  • deferred: A boolean. Leave the definition’s value for this model’s state-reading props until the state first moves — see common props.
  • model, item, npcHead, objectHead and playerHead are alternatives. Set one.
  • Angles are 0–2047, not degrees. A quarter turn is 512.
  • Only zoom decides how large the model appears. The component’s width and height place its centre, and the model is not clipped to them.
  • zoom, pitch, yaw, roll, offsetX and offsetY are written together: set one and the rest are 0, so zoom alone draws an item unrotated. Leave all six off and item draws in its inventory pose.
  • Through a ref, the pose is written as a group. ref.pitch = n alone is refused (TS2E215). Write ref.props = { offsetX, offsetY, pitch, yaw, roll, zoom } — see useRef.
src/armoury.ts2
<model x="center" y="center" w="fill" h="fill" item={Items.RUNE_SCIMITAR} zoom={520} />
src/armoury.ts2
<model x="center" y="center" w="fill" h="fill" item={Items.RUNE_SCIMITAR}
zoom={560} yaw={256} pitch={256} />
src/armoury.ts2
<model x="center" y="center" w="fill" h="fill" npcHead={Npcs.WISE_OLD_MAN}
anim={Animations.TALK} zoom={800} />
<model x="center" y="center" w="fill" h="fill" playerHead zoom={800} />

It draws only for a logged-in player.

zoom is a distance, so raise it to shrink the model and lower it to grow it. If nothing appears at all, the model may be off-centre — adjust offsetX and offsetY, and check its parent is large enough.

Angles run 0–2047 rather than 0–359. If you converted from degrees, multiply by about 5.69.

The pose is one group. Write every part of it: ref.props = { offsetX: 0, offsetY: 0, pitch, yaw, roll, zoom }.