Log inGet started
Package

firstPersonView.module

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

firstPersonView

What a camera seated in a body draws of that body, and what every other view draws of it. FirstPersonBody places a body's parts from its avatar's firstPerson annotations; this module holds the seats, the layers and the rule that places each part.

local FirstPersonView = require("@builtin::modules.firstPersonView")

local cam = camEntity.component.get("Camera")
cam:seatIn(body)                                  -- seats through FirstPersonView.seat
print(FirstPersonView.seatedIn(camEntity.id))     -- the body's root id
print(FirstPersonView.isSeated(body.id))          -- true
print(FirstPersonView.cameraSpec("all", true))    -- "all !firstPersonHidden !thirdPersonOnly firstPersonOnly"
print(FirstPersonView.place("auto", true, true, false))  -- "split"

Layers

Each part is drawn on a layer of this engine only (renderer.setLocalLayers), so the players who see the same body draw it whole and nothing is saved.

LayerHoldsDrawn by
thirdPersonOnlythe parts a view from inside the body leaves out: its head, its hair, a hatevery camera but the one seated in the body
firstPersonOnlythe parts drawn for the view from inside the body alone: first-person arms, the copies with the head collapsedthe camera seated in that body
firstPersonHiddenthe firstPersonOnly parts of a body no camera of this engine is seated inno camera

A camera's include set (cameraSpec) leaves out firstPersonOnly and firstPersonHidden when its renderLayers seeds all without naming them; a seated camera also leaves out thirdPersonOnly and draws firstPersonOnly.

Placements

place(kind, seated, skinned, underBone) answers where a part is drawn:

AnnotationSeatedPlacement
firstPersonOnlyyesfirstPerson
firstPersonOnlynohidden
both, or any with no camera seatedeverywhere
thirdPersonOnlyyesthirdPerson
auto, skinnedyessplit: drawn whole for every other view, and a copy with the first-person bone and every bone below it collapsed for the seated view
auto, rigid, under the first-person boneyesthirdPerson
auto, rigid, elsewhereyeseverywhere

Seats

  • seat(cameraId, bodyId?) seats a camera in a body, or takes it out with nil. Camera:seatIn calls it, and controller.first_person seats its camera in the entity it rides.
  • seatEyes(bodyId?) seats the eyes of this engine's headset in a body. The XR presentation does it for a body carrying FirstPersonBody, and the eyes then draw the body the way a seated camera does.
  • seatedIn(cameraId), eyesSeatedIn() and isSeated(bodyId) read the seats.
  • revision() moves whenever a seat changes or the layers are first interned, so a camera knows to resolve its include set again.