diff options
Diffstat (limited to 'public/js/world.js')
| -rw-r--r-- | public/js/world.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/public/js/world.js b/public/js/world.js new file mode 100644 index 0000000..caf1cf4 --- /dev/null +++ b/public/js/world.js @@ -0,0 +1,22 @@ +/* global AFRAME */ +// The world that's loaded (campfire, temple, …) is the entity marked +// `data-world="<component>"` in its template. Its component provides `seats` +// ([{ x, y, z, yaw }]) and may provide: +// spawn { x, z, yaw } where people arrive +// screen { x, y, z, yaw, width } where a shared screen first +// appears (screens.js): the middle of its picture. At +// yaw 0 it faces +z, toward someone who arrived with +// spawn yaw 0 +// confine(headPos) moves a head position back inside the walkable area +// floorAt(x, z) floor height there +// tools [{ name, label, object, grip, tip, butt, ink }]: things to +// pick up and draw with (wield.js). Each lies along its +// object's +x; grip, tip and butt are local Vector3s and +// ink is a '#rrggbb' color +// touchables [{ name, label(), distance(worldPos), use() }]: things +// to reach for in VR; the trigger calls use() (wield.js) +// Worlds that leave these out get the campfire's defaults in locomotion.js. +window.CurrentWorld = function (sceneEl) { + const el = (sceneEl || AFRAME.scenes[0]).querySelector('[data-world]'); + return (el && el.components[el.dataset.world]) || null; +}; |