Skip to content

API Reference

JavaScript API for creating AR experiences.

Math & Geometry

  • Vector2 - 2D vector for screen coordinates, UV mapping, and 2D math
  • Vector3 - 3D vector for positions, directions, and scales
  • Vector4 - 4D vector for quaternions, colors, and homogeneous coordinates
  • Rotation - Rotation represented as a quaternion
  • Transform - 4x4 transformation matrix representing position, rotation, and scale
  • BoundingBox - Axis-aligned bounding box for collision and visibility testing
  • Ray - A ray with origin and direction, useful for raycasting
  • Color - RGBA color with components in 0-1 range
  • Path beta - Runtime path handle returned by scene.createPath(...). Read-only spline queries; consumed by entity.followPath(...). Not persisted (v1).
  • GeoCoordinate beta - A geographic coordinate. Construct one for a point of interest, or receive a live fix from environment.location.current() (which additionally populates horizontalAccuracy and timestamp).

Scene & Objects

User Interface

  • UIView beta - A view node inside a UI panel.

Object Creation

  • Anchor - Anchor types for object placement
  • ObjectTraits - Builder object passed to the compatibility-only .traits(t => …) callback. New code should skip this entirely and use the direct descriptor methods (.physics(…), .material(…), .shadow(…), .gestures(…), .transform(…), .opacity(…), .fittingBox(…), .pivot(…)), which expose the same configuration and chain.
  • ObjectDescriptor - Descriptor for creating scene objects dynamically
  • Material - Chainable builder for an inline material. Six kinds: unlit, pbr, occlusion, customShader, materialX, video. Use the matching factory (Material.unlit({...}), etc.) or new Material(kind).

Properties map to the underlying material data model with web-standard names: - Colors: color, emissive, sheenColor, specularColor – flat tint. - Maps: map, emissiveMap, roughnessMap, metalnessMap, normalMap, aoMap, specularMap, sheenMap, clearcoatMap, alphaMap – textures accept either a URL/asset-id string or { texture, scale }. - Scalars: roughness, metalness, clearcoat, opacity, emissiveIntensity. - Rendering: opaque, transparent, opacityThreshold, blendMode, faceCulling, wireframe, writesDepth, readsDepth.

  • Mesh beta - Scriptable dynamic mesh with CPU-driven vertex and index updates.
  • Instances beta - Instance-data handles for rep.setInstances(...) / entity.setInstances(...) – GPU mesh instancing draws one copy of a mesh per transform, far cheaper than real entities. Instances are rendering-only (no physics, collision, or per-instance identity); use clone() for objects the user interacts with. Gate with environment.features.has('instancing').

Audio

  • AudioStream - Streaming audio player for real-time audio playback Used for continuous audio streams like OpenAI Realtime API
  • Microphone - Microphone audio streaming Access via scene.microphone

Networking

Animations

  • EntityAnimation - Entity animation factory - create animation descriptors for use with entity.play()
  • ValueAnimation - Value animations with spring and curve timing

Multi-user

  • SharedActivity - Shared activity state for multi-user sessions (SharePlay, WebSocket, etc.)

Functions

Automatically interpolates between from/to values based on their type. Supports numbers, Vector2, Vector3, Vector4, Color, and Rotation. Rotations use spherical interpolation (slerp) automatically.

Animations clean up automatically when complete. For infinite animations, call destroy() to stop, or they clean up when the scene ends.

Returns an ObjectDescriptor – pass to scene.createEntity(...). After the entity loads, reach the mesh via entity.representation.mesh and write buffer data with mesh.writeVertices(...) / mesh.writeIndices(...). Bytes flow straight from Float32Array / Uint32Array into the GPU-side buffer – single memcpy per call, no per-element overhead.