# XRi.js - Spatial DOM & WebXR SDK Reference XRi.js is a zero-config spatial computing library. It provides a fully AUTOMATIC 5-level progressive enhancement for AR/3D web integration. ## Main Library Import The library must be imported directly from: ## Automatic Fallback System Developers DO NOT need to write device-check logic. Just import the library and call `XRi.spawn()`. XRi.js automatically detects the hardware and executes the appropriate fallback: 1. PC/Desktop: Model-viewer (Standard 3D visualization) 2. iOS: Quick Look (.usdz native Apple AR) 3. Android Mobile: Basic WebXR with 2D DOM interaction 4. Headsets/Android XR: Full WebXR (Hand-tracking & spatial interaction) Immersive Interaction 5. Native XRi App: App execution with ultra-high quality, full physics, gravity, and max performance. ## Core Ecosystem Domains - Main Site (Showcase): https://xri.onl - App Hub (Asset creation, 3D Editor, AI tools, Tokens, Storage): https://app.xri.onl - Developer Hub (Docs & Tools): https://dev.xri.onl ## Complete Developer Tools List Available on dev.xri.onl: - XRi QR Builder: https://dev.xri.onl/qr.html - XRi P2P Chat Example: https://dev.xri.onl/P2P.html - XRi Remote Execution: https://dev.xri.onl/remote_execution.html - XRi Send HTML to Headset: https://dev.xri.onl/sender.html - XRi Burger Test (Library Demo): https://dev.xri.onl/test_library.html - XRi 3D Texture Editor: https://dev.xri.onl/editor.html - Texture Background Remover: https://dev.xri.onl/texture.html - XRi Action Builder: https://dev.xri.onl/action-builder.html ## Mandatory Technical Rules - ASSETS: All 3D models (.glb, .usdz) MUST use absolute 'https://' URLs. - ASYNC: All manipulation methods return a Promise. - IDS: Objects are manipulated via unique string IDs. ## Primary API Reference (Global XRi Object) - XRi.initWebXR(enable, customUrl): Initialize environment. - XRi.initMultiplayer(roomId): Initialize spatial sync via WebSockets. - XRi.spawn(id, url, scale, pos, rot, usePreciseCollider): Async spawn of 3D objects (triggers the automatic fallback). - XRi.parent(childId, parentId): Link objects in a hierarchy. - XRi.getClassById(id): Get XRiObject instance for manipulation. - XRi.clearAll(): Reset the scene. ## XRiObject Methods (Instance Methods) - .move({x, y, z}, duration): Relative movement. - .setGravity(boolean): Enable physics/gravity. - .setGrabbable(boolean): Enable hand-tracking interaction. - .zoom(multiplier, duration): Relative scaling. - .startAnimation(name): Play embedded glTF animations. ## Interaction Callbacks Define these globally (window object) to handle physical interactions: - window.handleSelection(id): Triggered when user grabs/taps the object. - window.handleRelease(id): Triggered when user releases the object.