firstPersonView.module
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.
| Layer | Holds | Drawn by |
|---|---|---|
thirdPersonOnly | the parts a view from inside the body leaves out: its head, its hair, a hat | every camera but the one seated in the body |
firstPersonOnly | the parts drawn for the view from inside the body alone: first-person arms, the copies with the head collapsed | the camera seated in that body |
firstPersonHidden | the firstPersonOnly parts of a body no camera of this engine is seated in | no 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:
| Annotation | Seated | Placement |
|---|---|---|
firstPersonOnly | yes | firstPerson |
firstPersonOnly | no | hidden |
both, or any with no camera seated | everywhere | |
thirdPersonOnly | yes | thirdPerson |
auto, skinned | yes | split: 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 bone | yes | thirdPerson |
auto, rigid, elsewhere | yes | everywhere |
Seats
seat(cameraId, bodyId?)seats a camera in a body, or takes it out with nil.Camera:seatIncalls it, andcontroller.first_personseats 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 carryingFirstPersonBody, and the eyes then draw the body the way a seated camera does.seatedIn(cameraId),eyesSeatedIn()andisSeated(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.