Skip to content

AR Compiler

Compiles HoloScript to browser-native Augmented Reality via WebXR — placing HoloScript spatial objects in the physical world through the device camera, with no app download required.

Overview

The AR compiler (--target ar) generates a WebXR immersive-ar session application aligned with the WebXR Device API. It works on any AR-capable device browser:

  • Android Chrome (ARCore)
  • iOS Chrome / Safari (via WebXR viewer or Safari 17+)
  • Meta Browser (Quest passthrough)

This differs from the platform-specific compilers (iOS ARKit, Android ARCore) by targeting the browser layer — no Xcode, no Android Studio, instant deployment via URL.

bash
holoscript compile experience.holo --target ar --output ./web/

Output Structure

web/
  index.html        # WebXR entry point
  ar-bundle.js      # Compiled scene + AR logic
  assets/           # 3D models, textures
  manifest.json     # PWA manifest for home-screen install

Trait → AR Behaviour

HoloScript TraitAR Behaviour
@anchorWorld-locked via hit test
@plane_detectedSurface detection + snapping
@collidableMesh occlusion against real surfaces
@tracked6DOF pose tracking
@grabbableTouch/pinch to move in AR
@pointableGaze/screen-tap selection
@spatial_audio3D positioned audio

Example

holo
composition "FurniturePlacer" {
  template "Chair" {
    @anchor
    @plane_detected
    @grabbable
    @collidable

    geometry: "model/chair.glb"
    scale: [1, 1, 1]

    on_place {
      this.locked = true
      ui.show("Chair placed! Tap to move.")
    }

    on_grab {
      this.locked = false
    }
  }

  logic {
    on_plane_detected(plane) {
      if (plane.label == "floor") {
        ui.show_reticle(plane.center)
      }
    }

    on_tap {
      spawn "Chair" at reticle.position
    }
  }
}

Compiler Options

OptionDefaultDescription
--ar-occlusionfalseEnable depth-based real-world occlusion
--ar-lightingtrueMatch ambient light to real environment
--ar-plane-typesfloor,tablePlane types to detect
--ar-hit-testtrueEnable tap-to-place
--ar-dom-overlaytrueAllow HTML UI overlaid on camera
--ar-depth-sensingfalseEnable raw depth data (ARCore only)

Progressive AR (No Headset Needed)

The AR output degrades gracefully:

Capability AvailableExperience
WebXR immersive-arFull AR with camera passthrough
WebXR inline3D viewer on flat screen
No WebXRStatic 3D model viewer (Three.js)

Device Compatibility

Device/BrowserModeNotes
Android Chrome (ARCore)Full immersive-arBest experience
iOS Safari 17+Limited immersive-arHit test + anchors
iOS WebXR ViewerFull immersive-arVia Mozllia WebXR Viewer app
Meta Quest (browser)Passthrough AR--ar-occlusion not supported
Desktop ChromeInline 3D onlyGraceful fallback

See Also

Released under the MIT License.