Skip to content

create3dApp

Creates a Three.js WebGPU application instance. Each call returns an independent instance, supporting multiple instances on the same page.

Usage

ts
import { create3dApp } from '@threeuse/core'

const app = create3dApp({
  antialias: true,
  camera: { fov: 75, position: [0, 0, 5] },
})

app.mount('#canvas-container')

Options

OptionTypeDefaultDescription
antialiasbooleantrueEnable antialiasing
alphabooleanfalseTransparent background
cameraPartial<CameraOptions>Initial camera parameters
autoResizebooleantrueAuto-observe container resize

Return Value

ThreeUseApp object containing:

  • renderer — WebGPURenderer instance
  • scene — Three.js Scene
  • camera — PerspectiveCamera
  • canvas — renderer.domElement
  • mount(container) — Mount to DOM and start render loop
  • unmount() — Stop loop and clean up resources
  • use(plugin) — Install plugin, supports chaining
  • on/emit/off — Pub/Sub events
  • onBeforeRender/onAfterRender — Render callbacks
  • globalProperties — Plugin mount point (app.$xxx)
  • config.errorHandler / config.warnHandler — Custom error/warning handlers

Demo

Released under the MIT License.