Docs
API Reference

UIWorldSpace

Shared reference for UIThree, UIBabylon, UIBabylonLite, and UIPlayCanvas. These classes share the UI instance API, with the additions and overrides below. UIWorldSpace is their abstract base and has no public import path.

Methods

MethodReturnsDescription
setCamera(camera: TCamera)voidSets the camera used for pointer picking.
draw(options?: WorldSpaceDrawOptions)WebGPUDrawResult | undefinedDraws into the UI texture, clearing it first.
destroy()boolean | voidAlso releases the UI's GPU texture.

WorldSpaceDrawOptions accepts only submit? and command_encoder? from WebGPU draw options.

Additional creation options

Engine factories accept UI creation options plus:

OptionTypeDefault
texture_widthnumberRequired; texture pixels
texture_heightnumberRequired; texture pixels
world_widthnumberRequired; world units
world_heightnumberRequired; world units
createMaterial(options: MaterialOptions<TTexture>) => TMaterialEngine material factory
createPlane(options: PlaneOptions<TTexture, TMaterial>) => TPlaneEngine plane factory

Callback types

type MaterialOptions<TTexture> = {
  texture: TTexture
  gpu_texture: GPUTexture
  gpu_texture_view: GPUTextureView
}

type PlaneOptions<TTexture, TMaterial> = MaterialOptions<TTexture> & {
  material: TMaterial
  world_width: number
  world_height: number
}

type MapIntersection<TIntersection> = (intersection: TIntersection) => { x: number; y: number } | null

createPlane returns { plane, mapIntersection?, ... }. mapIntersection maps an engine intersection to UV coordinates, or null for no hit.

Factory result

PropertyType
uiConcrete engine UI
textureTTexture
materialTMaterial
gpu_textureGPUTexture
gpu_texture_viewGPUTextureView
...planeResourcesFields returned by createPlane

These are fields of the factory result, not properties of ui.

Each engine factory returns a promise of this result with its own class as ui. Options extend the world-space options; defined_events factories receive the concrete UI instance. No engine class adds public instance properties.

A custom createPlane replaces the default plane resources below and must return the engine's plane type. Set a camera before dispatching pointer events.

UIThree

Import from @uno.build/ui/UIThree. Engine types come from three/webgpu.

APIType / value
FactoryUIThree.create(options: UIThreeOptions<TMaterial, TPlane>)
Additional required optionsNone
CamerasetCamera(camera: THREE.Camera): void
Event dispatchdispatchPlatformEvent(source_event: PlatformEvent): void
TextureTHREE.ExternalTexture
Default materialTHREE.MeshStandardNodeMaterial
Material constraintTMaterial extends UIThreeMaterial: THREE.NodeMaterial with map and color
mapIntersection argumentTHREE.Intersection
Default plane resourcesplane: THREE.Mesh<THREE.PlaneGeometry, TMaterial>, geometry: THREE.PlaneGeometry

UIThreeOptions and UIThreeMaterial are exported by the class module.

UIBabylon

Import from @uno.build/ui/UIBabylon. Engine types come from @babylonjs/core.

APIType / value
FactoryUIBabylon.create(options: UIBabylonOptions<TMaterial, TPlane>)
Additional required optionsscene: Scene
CamerasetCamera(camera: Camera): void
Event dispatchdispatchPlatformEvent(source_event: PlatformEvent): void
TextureTexture
Default materialStandardMaterial
Material constraintTMaterial extends UIBabylonMaterial: StandardMaterial
mapIntersection argumentPickingInfo
Default plane resourcesplane: Mesh, geometry: Geometry | null

UIBabylonOptions and UIBabylonMaterial are exported by the class module.

UIBabylonLite

Import from @uno.build/ui/UIBabylonLite. Engine types come from @babylonjs/lite.

APIType / value
FactoryUIBabylonLite.create(options: UIBabylonLiteOptions<TMaterial, TPlane>)
Additional required optionsengine: EngineContext, scene: SceneContext
CamerasetCamera(camera: Camera): void
Event dispatchdispatchPlatformEvent(source_event: PlatformEvent): Promise<void>
TextureTexture2D
Default materialStandardMaterialProps
Material constraintTMaterial extends UIBabylonLiteMaterial: StandardMaterialProps
mapIntersection argumentPickingInfo
Default plane resourcesplane: Mesh

UIBabylonLiteOptions and UIBabylonLiteMaterial are exported by the class module. Event dispatch uses asynchronous picking.

UIPlayCanvas

Import from @uno.build/ui/UIPlayCanvas. Engine types come from playcanvas.

APIType / value
FactoryUIPlayCanvas.create(options: UIPlayCanvasOptions<TMaterial, TPlane>)
Additional required optionsapp: AppBase
CamerasetCamera(camera: Entity): void; entity with a camera component
Event dispatchdispatchPlatformEvent(source_event: PlatformEvent): void
TextureTexture
Default materialStandardMaterial
Material constraintTMaterial extends UIPlayCanvasMaterial: StandardMaterial
mapIntersection argumentUIPlayCanvasIntersection
Default plane resourcesplane: Entity, geometry: Geometry, mesh: Mesh, mesh_instance: MeshInstance

UIPlayCanvasOptions and UIPlayCanvasMaterial are exported by the class module. It also exports UIPlayCanvasIntersection.

On this page