Modules / Rendering & look

sprite3dplugin

Rows drawn as billboards of a sprite sheet that stand on the floor.

Putting it in a scene

List it before render3d. Each row of a listed kind is drawn as a flat picture that stands on the floor and always turns to face the camera.

"plugins": ["loader", "scenemanager", "player", "sprite3d", "render3d"],
"world": {
  "sprite3d": {
    "ppm": 64,
    "alphaTest": 0.5,
    "kinds": {
      "monster": { "turn": 8 },
      "barrel": { "turn": 1, "sheet": "props", "clip": "barrel", "facing": 0 }
    }
  }
}

A row of the monster kind:

{ "sheet": "monster", "clip": "walk", "frame": 3, "facing": 0, "pos": [4, 0, -6] }

Properties

Read from world.sprite3d. A scene the manager starts uses the manager's if it gives none of its own.

.ppm : number

Pixels of the sheet per metre. A 64 pixel frame at a ppm of 64 stands one metre tall.

.alphaTest : number

Pixels with less opacity than this are not drawn. It keeps the soft edges of a sprite from hiding what is behind it.

.kinds : { [kind]: { turn, sheet?, clip?, facing? } }

turn is how many facings make a whole turn. A row's facing × a whole turn ÷ turn is the direction it heads, counter-clockwise from +x seen from above. sheet, clip and facing can be given once here for a kind whose rows all look the same; a row that also carries one of them is an error.

The row

FieldMeaning
sheetThe loader name of the sprite sheet.
clipThe clip to play, or null while it shows nothing yet.
frameThe frame of the clip to show.
facingWhich way it heads, as above. The sprite shows the run of the clip that matches the angle the camera sees it from, so a monster seen from behind shows its back. A run the sheet mirrors is drawn flipped. A clip with one run on a sheet that mirrors nothing looks the same from every side.
pos[x, y, z] in metres. The frame's anchor stands on it, so a monster's feet are on the floor.

A sprite is hidden, and its sheet requested, until the loader has the sheet.

In the guide