Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit5e8d2d1288

README.md

FirstPersonBody

Draws the body under this entity the way its avatar's firstPerson annotations say, for a camera seated in the body (or a headset's eyes seated in it) and for every other view. An avatar whose avatar.json states firstPerson (every avatar a VRM imports to) gets this component when it is instantiated or worn, on every peer.

root.component.add("FirstPersonBody", { avatar = asset.resolve("my_vrm", "avatar") })
cam:seatIn(root)  -- controller.first_person does this for the entity it rides
local s = root.component.get("FirstPersonBody"):stats()
print(s.seated, s.thirdPerson, s.firstPerson, s.hidden, s.split, #s.copies)
  • avatar (synced): the avatar whose firstPerson annotations it applies.
  • firstPerson (synced): the annotations applied when no avatar is set, in the same form.

Where each mesh is drawn

AnnotationA camera seated in the bodyEvery other view
bothdrawndrawn
thirdPersonOnlyleft outdrawn
firstPersonOnlydrawnleft out, the cameras seated in other bodies included
auto, skinneda copy with the first-person bone and every bone below it collapseddrawn whole
auto, rigid, under the first-person boneleft outdrawn
auto, rigid, elsewheredrawndrawn

A mesh no annotation names is auto. An annotation names a mesh by its name in the body; a mesh with several primitives is an entity holding one child per primitive, and the annotation reaches each of them. With no camera seated, nothing changes but that the firstPersonOnly meshes are drawn by no view: they stay on firstPersonHidden, which every camera leaves out until it names the layer.

The split rides three render layers, set in this engine only (renderer.setLocalLayers), so the players who see the same body draw it whole and nothing is saved: thirdPersonOnly holds what every view but the seated camera draws, firstPersonOnly what only the camera seated in that body draws, and firstPersonHidden the firstPersonOnly meshes of a body no camera of this engine is seated in. A camera whose renderLayers seeds all leaves out firstPersonOnly and firstPersonHidden until it names them, and a camera seated with Camera:seatIn also leaves out thirdPersonOnly and draws firstPersonOnly. A headset's eyes seated in the body (modules.firstPersonView.seatEyes, which the XR presentation does for the body it embodies) draw it the way a seated camera does.

stats() answers { applied, seated, bone, everywhere, thirdPerson, firstPerson, hidden, split, copies, placements }: the counts of the body's drawn parts by placement, the copies the seated camera draws and each part's placement by its name.