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

Scene & Objects

  • Scene
  • ObjectEntity - Entity in the scene
  • RepresentationEntity - Visual representation of an entity (model, shape, etc.)
  • Entity - Generic entity within a model hierarchy (bones, groups, nested models)
  • Experience
  • Environment
  • EnvironmentFeatures - Capability registry exposed at environment.features.
  • AnchorData
  • CollisionCastHit - Result from scene.raycast() when ray intersects an entity or scene mesh
  • ARRaycastResult - Result from scene.raycastAR() when ray intersects real-world surfaces
  • Kernel - Opaque handle to a compiled GPU compute kernel. Returned by Kernel.fromSource(...) / Kernel.fromAsset(...). Two dispatch entry points: kernel.run({...}) for standalone compute (texture / buffer I/O, no mesh involvement) and mesh.runCompute(kernel, options) when the kernel writes mesh-attribute buffers.
  • Texture - GPU-only / runtime-managed texture. Backed by an ARXDynamicTexture (today's only constructible kind from JS is .computeBacked; sibling kinds – image, video, renderTarget, cameraFeed – wire up alongside material-parameter binding in a follow-up runtime version).
  • TextureBinding - Marker token returned by texture.read / texture.write. Carries the backing texture and the role so dispatch knows whether to bind the texture as a kernel read source or write target.
  • Buffer - Raw GPU buffer wrapping a typed scratch region for compute kernels. Use for things meshes + textures don't model: atomic counters, lookup tables (e.g. marching cubes' triangle / edge tables), per-particle state, scratch arrays between kernel passes.

User Interface

  • UIView - A view node inside a UI panel.

Object Creation

  • Anchor - Anchor types for object placement
  • ObjectTraits - Builder for object traits (transform, materials, adjustments) Use with ObjectDescriptor.traits() to configure object properties
  • 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.

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

  • HTTPClient - HTTP client for making network requests Supports GET, POST, and custom requests with authentication
  • WebSocket - WebSocket connection for real-time communication
  • WebSocketManager - WebSocket connection manager Access via websocket.connect()

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.