- License
- ISC
- Install Size
- 22.7 MB/-
- Vulns
- 1
- Published
$
npm install @easytwin/runtime$
pnpm add @easytwin/runtime$
yarn add @easytwin/runtime$
bun add @easytwin/runtime$
deno add npm:@easytwin/runtime$
vlt install @easytwin/runtime自定义组件
特性
- 生命周期支持
- onAwake: 在帧循环前调用,仅会调用一次
- onStart: 在帧循环最开始调用,仅会调用一次
- onUpdate: 每帧调用一次
- onEnable: 组件被启用时调用一次
- onDisable: 组件被禁用时调用一次
- 碰撞与射线检测(暂未支持)
- onPointerUp: 指针在碰撞体上释放时
- onPointerDown: 指针在碰撞体上按下时
- onPointerEnter: 指针进入碰撞体
- onPointerExit: 指针退出碰撞体
- onPointerClick: 指针点击碰撞体
- onPointerDrag: 拖动物体时
要点须知
- VirtualRootComponent用于数字要素模板/模型, VirtualComponent则用于数字要素的子要素/模型内部结构. 如果不需要启用虚拟子组件,请继承Component
要启用射线检测需要让THREE.Object关联 RuntimeComponent,设置THREE.Object.userdata._target = RuntimeComponent;- data和state中以$R结尾的字段会被判断为资源路径,要求value是string,参与导入导出。