@easytwin/runtime

v0.0.51
  • Types
  • ESM

Easytwin中间层引擎,提供场景管理/资源管理/自定义动态组件支持

License
ISC
Install Size
22.7 MB/-
Vulns
1
Published

Get started

$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

Readme

自定义组件

特性

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