create3dApp
创建一个 Three.js WebGPU 应用实例。每次调用返回独立实例,支持同页面多实例。
用法
ts
import { create3dApp } from '@threeuse/core'
const app = create3dApp({
antialias: true,
camera: { fov: 75, position: [0, 0, 5] },
})
app.mount('#canvas-container')参数
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
antialias | boolean | true | 抗锯齿 |
alpha | boolean | false | 透明背景 |
forceWebGL | boolean | undefined | undefined | 强制使用 WebGL |
camera | Partial<CameraOptions> | — | 相机初始参数 |
autoResize | boolean | true | 自动监听容器尺寸变化 |
返回值
ThreeUseApp 对象,包含:
renderer— WebGPURenderer 实例scene— Three.js Scenecamera— PerspectiveCameracanvas— renderer.domElementmount(container)— 挂载到 DOM,启动渲染循环unmount()— 停止循环,清理资源use(plugin)— 安装插件,支持链式调用on/emit/off— 发布订阅onBeforeRender/onAfterRender— 渲染回调globalProperties— 插件挂载点(app.$xxx)config.errorHandler/config.warnHandler— 自定义错误/警告处理