summaryrefslogtreecommitdiff
path: root/public/js/world.js
diff options
context:
space:
mode:
authorskylar <me@casper>2026-11-01 05:43:24 -0800
committerskylar <me@casper>2026-11-01 05:43:24 -0800
commite69ad01e700e80fa959dfee08cd556ca0d777ffd (patch)
tree645fc9db2142e87a5ef302733a77ba2fec848d88 /public/js/world.js
Yesod: self-hosted WebXR rooms
Start a room in a world and hang out in VR from the headset's browser: A-Frame + Networked-A-Frame over EasyRTC, with a coturn relay that can hide everyone's IP address. Ships with the Campfire, Temple, Cabin, Balcony and Test room worlds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'public/js/world.js')
-rw-r--r--public/js/world.js22
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;
+};