Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit9a85df95a3

README.md

xrConform

Check how a world plays in a headset, for one entity the game expects the player to look at or point at: a pickup, a button, a door. It starts a simulated XR session when none is running and stops it afterwards.

It turns the simulated head to face the entity and reports what the viewport camera's forward ray meets, which is what a game that aims with its camera hits. It turns the dominant controller to the entity and reports what the ray the game builds from its mouse (screenToRay at the mouse position) meets. It lists every visible game screen with whether an XR panel shows it.

local report = tools.use("inputSim", "xrConform", "pickup")
print(report.look.hit, report.look.entity)       -- the camera's forward ray
print(report.point.hit, report.point.onLaser)    -- the ray built from the mouse
for _, screen in report.screens do print(screen.name, screen.onPanel) end

-- an entity whose origin stands at its feet: aim a metre above it
tools.use("inputSim", "xrConform", "door", { x = 0, y = 1, z = 0 })

The answer is data:

FieldMeaning
look.hitThe camera's forward ray meets the entity, or something under it.
look.entity, look.distanceWhat the ray met first.
look.errorDegreesHow far the settled head stands from the entity.
point.hit, point.entity, point.distanceThe same for the ray built from the game's mouse.
point.onLaserThe ray built from the mouse is the laser's own ray.
point.panel, point.reasonThe world panel the laser meets before the entity (the game's mouse stands off the view while a panel takes the laser), or why no ray was built from the mouse.
screens[]name, space, onPanel and the panel showing it, for each visible game screen.
startedSessionThe tool started the simulated session (and stopped it again).

A hit of false with an entity names what stands in the way. The head and the controller are put back to the headset runtime afterwards.