@zylem/game-lib 0.6.4 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/README.md +18 -2
  2. package/dist/actions.d.ts +321 -11
  3. package/dist/actions.js +1 -936
  4. package/dist/api/game-lib.api.json +54074 -0
  5. package/dist/api/game-lib.api.md +4544 -0
  6. package/dist/api/game-lib.d.ts +8258 -0
  7. package/dist/api/game-lib.typedoc.json +345421 -0
  8. package/dist/audio.d.ts +13 -0
  9. package/dist/audio.js +1 -0
  10. package/dist/base-node-life-cycle-D2NuN1VB.d.ts +151 -0
  11. package/dist/behavior.d.ts +2 -0
  12. package/dist/behavior.js +1 -0
  13. package/dist/blueprints-TbGY-h53.d.ts +162 -0
  14. package/dist/chunk-4QLJUQSJ.js +1 -0
  15. package/dist/chunk-7FR5JSQ2.js +1 -0
  16. package/dist/chunk-7GYFZKK7.js +1 -0
  17. package/dist/chunk-7WRQ2UAN.js +1 -0
  18. package/dist/chunk-BH53MBAZ.js +1 -0
  19. package/dist/chunk-BIGH6D34.js +0 -0
  20. package/dist/chunk-CM5YRNBJ.js +19 -0
  21. package/dist/chunk-COM6HJ2L.js +1 -0
  22. package/dist/chunk-D2PATZCC.js +1 -0
  23. package/dist/chunk-DFLI7ICU.js +0 -0
  24. package/dist/chunk-E3UBSUPX.js +1 -0
  25. package/dist/chunk-FKIKN7RP.js +24 -0
  26. package/dist/chunk-G4HONLWC.js +1 -0
  27. package/dist/chunk-IKWE2W6L.js +1 -0
  28. package/dist/chunk-IPWUDOV5.js +1 -0
  29. package/dist/chunk-JEHFHUH4.js +0 -0
  30. package/dist/chunk-JNKPTL77.js +1 -0
  31. package/dist/chunk-JQKS42G4.js +1 -0
  32. package/dist/chunk-M3XNO56P.js +1 -0
  33. package/dist/chunk-MSC2BEO5.js +1 -0
  34. package/dist/chunk-ORIDWL3T.js +0 -0
  35. package/dist/chunk-QB3NL7VQ.js +1 -0
  36. package/dist/chunk-QXVH6POE.js +1 -0
  37. package/dist/chunk-RXDTAWI2.js +29 -0
  38. package/dist/chunk-TAUWDQZF.js +9 -0
  39. package/dist/chunk-VS2D4B3W.js +1 -0
  40. package/dist/chunk-WQ3WMMZD.js +1 -0
  41. package/dist/chunk-XK63E4SX.js +1 -0
  42. package/dist/chunk-XNDS4YFR.js +1 -0
  43. package/dist/chunk-XNHVRFAK.js +1 -0
  44. package/dist/chunk-XRP4JJXL.js +1 -0
  45. package/dist/chunk-YHEWKN7N.js +1 -0
  46. package/dist/chunk-ZRT3ZQVH.js +1 -0
  47. package/dist/collision-builder-jF-toPIl.d.ts +38 -0
  48. package/dist/core.d.ts +223 -16
  49. package/dist/core.js +1 -12424
  50. package/dist/debug-state-BPT6jEog.d.ts +17 -0
  51. package/dist/debug.d.ts +76 -0
  52. package/dist/debug.js +1 -0
  53. package/dist/default-controls-0-vCnli7.d.ts +111 -0
  54. package/dist/{entity-vj-HTjzU.d.ts → entity-BdSI8CL3.d.ts} +119 -626
  55. package/dist/{entity-Bq_eNEDI.d.ts → entity-DZbFQ1Wg.d.ts} +4 -4
  56. package/dist/entity-type-map-Bd69SpAS.d.ts +928 -0
  57. package/dist/entity.d.ts +268 -0
  58. package/dist/entity.js +1 -0
  59. package/dist/events.d.ts +181 -0
  60. package/dist/events.js +1 -0
  61. package/dist/game-C1FHVqXl.d.ts +1886 -0
  62. package/dist/game-default-QHROHW2O.js +1 -0
  63. package/dist/game-interfaces-mchNYSZE.d.ts +90 -0
  64. package/dist/globals.d.ts +115 -0
  65. package/dist/globals.js +1 -0
  66. package/dist/graphics.d.ts +53 -0
  67. package/dist/graphics.js +1 -0
  68. package/dist/input-ui.d.ts +35 -0
  69. package/dist/input-ui.js +1 -0
  70. package/dist/input.d.ts +73 -0
  71. package/dist/input.js +1 -0
  72. package/dist/material-9vJ6SZaI.d.ts +126 -0
  73. package/dist/public.d.ts +38 -0
  74. package/dist/public.js +1 -0
  75. package/dist/runtime.d.ts +59 -0
  76. package/dist/runtime.js +1 -0
  77. package/dist/schema/entity.schema.json +244 -0
  78. package/dist/schema/game-config.schema.json +625 -0
  79. package/dist/schema/input-config.schema.json +499 -0
  80. package/dist/schema/stage-config.schema.json +93 -0
  81. package/dist/schema/stage.schema.json +271 -0
  82. package/dist/schema.d.ts +538 -0
  83. package/dist/schema.js +1 -0
  84. package/dist/stage-transition-CmGpV4tc.d.ts +46 -0
  85. package/dist/vector-CiSHbivc.d.ts +133 -0
  86. package/dist/web-components.d.ts +70 -0
  87. package/dist/web-components.js +1 -0
  88. package/dist/zylem-camera-C3bn6BTI.d.ts +575 -0
  89. package/package.json +70 -73
  90. package/dist/actions.js.map +0 -1
  91. package/dist/behavior/jumper-2d.d.ts +0 -114
  92. package/dist/behavior/jumper-2d.js +0 -711
  93. package/dist/behavior/jumper-2d.js.map +0 -1
  94. package/dist/behavior/platformer-3d.d.ts +0 -296
  95. package/dist/behavior/platformer-3d.js +0 -761
  96. package/dist/behavior/platformer-3d.js.map +0 -1
  97. package/dist/behavior/ricochet-2d.d.ts +0 -275
  98. package/dist/behavior/ricochet-2d.js +0 -425
  99. package/dist/behavior/ricochet-2d.js.map +0 -1
  100. package/dist/behavior/ricochet-3d.d.ts +0 -117
  101. package/dist/behavior/ricochet-3d.js +0 -443
  102. package/dist/behavior/ricochet-3d.js.map +0 -1
  103. package/dist/behavior/screen-visibility.d.ts +0 -79
  104. package/dist/behavior/screen-visibility.js +0 -358
  105. package/dist/behavior/screen-visibility.js.map +0 -1
  106. package/dist/behavior/screen-wrap.d.ts +0 -87
  107. package/dist/behavior/screen-wrap.js +0 -246
  108. package/dist/behavior/screen-wrap.js.map +0 -1
  109. package/dist/behavior/shooter-2d.d.ts +0 -79
  110. package/dist/behavior/shooter-2d.js +0 -180
  111. package/dist/behavior/shooter-2d.js.map +0 -1
  112. package/dist/behavior/thruster.d.ts +0 -11
  113. package/dist/behavior/thruster.js +0 -292
  114. package/dist/behavior/thruster.js.map +0 -1
  115. package/dist/behavior/top-down-movement.d.ts +0 -56
  116. package/dist/behavior/top-down-movement.js +0 -125
  117. package/dist/behavior/top-down-movement.js.map +0 -1
  118. package/dist/behavior/world-boundary-2d.d.ts +0 -142
  119. package/dist/behavior/world-boundary-2d.js +0 -235
  120. package/dist/behavior/world-boundary-2d.js.map +0 -1
  121. package/dist/behavior/world-boundary-3d.d.ts +0 -76
  122. package/dist/behavior/world-boundary-3d.js +0 -274
  123. package/dist/behavior/world-boundary-3d.js.map +0 -1
  124. package/dist/behavior-descriptor-BXnVR8Ki.d.ts +0 -159
  125. package/dist/blueprints-DmbK2dki.d.ts +0 -26
  126. package/dist/camera-4XO5gbQH.d.ts +0 -905
  127. package/dist/camera.d.ts +0 -6
  128. package/dist/camera.js +0 -1993
  129. package/dist/camera.js.map +0 -1
  130. package/dist/composition-BASvMKrW.d.ts +0 -218
  131. package/dist/core-CARRaS55.d.ts +0 -541
  132. package/dist/core.js.map +0 -1
  133. package/dist/entities-ChFirVL9.d.ts +0 -410
  134. package/dist/entities.d.ts +0 -9
  135. package/dist/entities.js +0 -4986
  136. package/dist/entities.js.map +0 -1
  137. package/dist/entity-types-DAu8sGJH.d.ts +0 -26
  138. package/dist/global-change-2JvMaz44.d.ts +0 -25
  139. package/dist/main.d.ts +0 -1353
  140. package/dist/main.js +0 -19525
  141. package/dist/main.js.map +0 -1
  142. package/dist/physics-pose-DCc4oE44.d.ts +0 -25
  143. package/dist/physics-protocol-BDD3P5W2.d.ts +0 -200
  144. package/dist/physics-worker.d.ts +0 -21
  145. package/dist/physics-worker.js +0 -306
  146. package/dist/physics-worker.js.map +0 -1
  147. package/dist/physics.d.ts +0 -205
  148. package/dist/physics.js +0 -577
  149. package/dist/physics.js.map +0 -1
  150. package/dist/stage-types-C19IhuzA.d.ts +0 -731
  151. package/dist/stage.d.ts +0 -52
  152. package/dist/stage.js +0 -8479
  153. package/dist/stage.js.map +0 -1
  154. package/dist/sync-state-machine-CZyspBpj.d.ts +0 -16
  155. package/dist/thruster-23lzoPZd.d.ts +0 -180
  156. package/dist/world-DfgxoNMt.d.ts +0 -105
@@ -0,0 +1 @@
1
+ import{b as P,d as fe,e as L,j as ye}from"./chunk-CM5YRNBJ.js";import{a as re,b as ae}from"./chunk-YHEWKN7N.js";import{a as he,b as me}from"./chunk-E3UBSUPX.js";import{c as S,d as F,e as le,f as ce,g as ue,h as b,i as pe,j as z}from"./chunk-7WRQ2UAN.js";import{p as de}from"./chunk-XRP4JJXL.js";import{StageBodyKind as Ce}from"@zylem/behaviors/core";import{Color as We,Vector2 as be,Vector3 as ge}from"three";function T(n){if(!n||typeof n!="object")return!1;let e=Object.getPrototypeOf(n);return e===Object.prototype||e===null}function y(n){if(n==null||typeof n=="function"||typeof n!="object")return n;if(n instanceof We||n instanceof be||n instanceof ge)return n.clone();if(n instanceof Float32Array)return new Float32Array(n);if(Array.isArray(n))return n.map(e=>y(e));if(T(n)){let e={};for(let[t,i]of Object.entries(n))t!=="_builders"&&(e[t]=y(i));return e}return n}function C(n,e){let t=y(n);if(!e)return t;if(!T(t)||!T(e))return y(e);let i=t;for(let[o,s]of Object.entries(e)){if(o==="_builders"||s===void 0)continue;let r=i[o];if(o==="shader"){i[o]=y(s);continue}if(r instanceof be&&le(s)){i[o]=pe(s,r);continue}if(r instanceof ge&&ce(s)){i[o]=z(s,r);continue}if(T(r)&&T(s)){i[o]=C(r,s);continue}i[o]=y(s)}return i}function xe(n){return n&&n.__kind==="collision"}function X(n){return n.cloneComponent()}function Ke(n,e){return{kind:n?Ce.Static:Ce.Dynamic,position:[0,0,0],gravityScale:1,canSleep:e.canSleep??!1,ccdEnabled:e.ccdEnabled??!0}}function Xe(n,e){if(e.offset){let t=b(e.offset,S);n.offset=[t.x,t.y,t.z]}e.sensor&&(n.sensor=!0),e.collisionType&&(n.collisionGroups=he(e.collisionType,e.collisionFilter))}function E(n,e,t){return Xe(n,e),{__kind:"collision",bodyDesc:Ke(e.static??!1,e),colliderDesc:n,cloneComponent:t}}function $e(n={}){let e=b(n.size,F),t={shape:{type:"box",halfExtents:[e.x/2,e.y/2,e.z/2]}},i=y(n);return E(t,n,()=>$e(i))}function qe(n={}){let e={shape:{type:"sphere",radius:n.radius??1}},t=y(n);return E(e,n,()=>qe(t))}function Je(n={}){let e=n.radius??1,i={shape:{type:"cone",halfHeight:(n.height??2)/2,radius:e}},o=y(n);return E(i,n,()=>Je(o))}function Qe(n={}){let e=n.radius??1,i={shape:{type:"cone",halfHeight:(n.height??2)/2,radius:e}},o=y(n);return E(i,n,()=>Qe(o))}function et(n={}){let e=Math.max(n.radiusTop??1,n.radiusBottom??1),i={shape:{type:"cylinder",halfHeight:(n.height??2)/2,radius:e}},o=y(n);return E(i,n,()=>et(o))}function tt(n={}){let e=n.radius??.5,i={shape:{type:"capsule",halfHeight:(n.length??1)/2,radius:e}},o=y(n);return E(i,n,()=>tt(o))}function it(n={}){let e=ue(n.tile,{x:10,y:10}),t=n.subdivisions??10,i=(t+1)*(t+1),o=n.heightData??new Float32Array(i),s={shape:{type:"heightfield",rows:t,cols:t,heights:o,scale:[e.x,1,e.y]}},r={...n,static:n.static??!0},a=y(r);return E(s,r,()=>it(a))}function ot(n={}){let e=b(n.size,F),t={shape:{type:"box",halfExtents:[e.x/2,e.y/2,e.z/2]},sensor:!0},i={...n,static:n.static??!0,sensor:!0},o=y(i);return E(t,i,()=>ot(o))}import{Mesh as Se,ShaderMaterial as ct,Group as ut}from"three";var ve=import.meta.env.VITE_DEBUG_FLAG==="true";import{nanoid as nt}from"nanoid";var x=class n{parent=null;children=[];options;uuid="";name="";markedForRemoval=!1;lifecycleCallbacks={setup:[],loaded:[],update:[],destroy:[],cleanup:[]};trackLifecycleRegistrations=!1;userLifecycleRegistrations=[];constructor(e=[]){let t=e.filter(i=>!(i instanceof n)).reduce((i,o)=>({...i,...o}),{});this.options=t,this.uuid=nt()}onSetup(...e){return this.lifecycleCallbacks.setup.push(...e),this.recordLifecycleRegistration("onSetup",e),this}onLoaded(...e){return this.lifecycleCallbacks.loaded.push(...e),this.recordLifecycleRegistration("onLoaded",e),this}onUpdate(...e){return this.lifecycleCallbacks.update.push(...e),this.recordLifecycleRegistration("onUpdate",e),this}onDestroy(...e){return this.lifecycleCallbacks.destroy.push(...e),this.recordLifecycleRegistration("onDestroy",e),this}onCleanup(...e){return this.lifecycleCallbacks.cleanup.push(...e),this.recordLifecycleRegistration("onCleanup",e),this}prependSetup(...e){return this.lifecycleCallbacks.setup.unshift(...e),this.recordLifecycleRegistration("prependSetup",e),this}prependUpdate(...e){return this.lifecycleCallbacks.update.unshift(...e),this.recordLifecycleRegistration("prependUpdate",e),this}setParent(e){this.parent=e}getParent(){return this.parent}add(e){this.children.push(e),e.setParent(this)}remove(e){let t=this.children.indexOf(e);t!==-1&&(this.children.splice(t,1),e.setParent(null))}getChildren(){return this.children}isComposite(){return this.children.length>0}enableUserLifecycleTracking(){this.trackLifecycleRegistrations=!0}replayUserLifecycleRegistrationsTo(e,t){for(let i of this.userLifecycleRegistrations){let o=t?i.callbacks.map(s=>t(s)):[...i.callbacks];switch(i.method){case"onSetup":e.onSetup(...o);break;case"onLoaded":e.onLoaded(...o);break;case"onUpdate":e.onUpdate(...o);break;case"onDestroy":e.onDestroy(...o);break;case"onCleanup":e.onCleanup(...o);break;case"prependSetup":e.prependSetup(...o);break;case"prependUpdate":e.prependUpdate(...o);break}}}cloneChildrenInto(e){for(let t of this.children)e.add(st(t))}nodeSetup(e){this.markedForRemoval=!1,typeof this._setup=="function"&&this._setup(e);for(let t of this.lifecycleCallbacks.setup)t(e);this.children.forEach(t=>t.nodeSetup(e))}nodeUpdate(e){if(!this.markedForRemoval){typeof this._update=="function"&&this._update(e),typeof this._tickActions=="function"&&this._tickActions(e.delta);for(let t of this.lifecycleCallbacks.update)t(e);this.children.forEach(t=>t.nodeUpdate(e))}}nodeDestroy(e){if(!this.markedForRemoval){this.children.forEach(t=>t.nodeDestroy(e));for(let t of this.lifecycleCallbacks.destroy)t(e);typeof this._destroy=="function"&&this._destroy(e),this.markedForRemoval=!0;for(let t of this.lifecycleCallbacks.cleanup)t(e);typeof this._cleanup=="function"&&this._cleanup(e)}}async nodeLoaded(e){typeof this._loaded=="function"&&await this._loaded(e);for(let t of this.lifecycleCallbacks.loaded)t(e)}nodeCleanup(e){this.children.forEach(t=>t.nodeCleanup?.(e));for(let t of this.lifecycleCallbacks.cleanup)t(e);typeof this._cleanup=="function"&&this._cleanup(e)}getOptions(){return this.options}setOptions(e){this.options={...this.options,...e}}recordLifecycleRegistration(e,t){!this.trackLifecycleRegistrations||t.length===0||this.userLifecycleRegistrations.push({method:e,callbacks:[...t]})}};function st(n){let e=n?.clone;if(typeof e!="function")throw new Error(`Cannot clone child node "${n.name||n.uuid||"unknown"}": missing clone() support.`);return e.call(n)}import{createTransformStore as pt}from"@zylem/behaviors/core";import{makeMoveable as rt}from"@zylem/behaviors/core";function Oe(n){let e=rt(n);return de(e)}import{clearVelocityIntent as _e}from"@zylem/behaviors/core";import{Color as at,Vector3 as lt}from"three";var V={position:new lt(0,0,0),material:{color:new at("#ffffff"),shader:P},collision:{static:!1}};function Ti(n,e){let t=n.filter(o=>!(o instanceof x)),i=C(e);for(let o of t)i=C(i,o);return i}function dt(n){return n!=null&&typeof n=="object"}function Ee(n){return{phase:n?.phase??"stay",cooldownMs:n?.cooldownMs}}function ht(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}var D=class extends x{group;mesh;materials;bodyDesc=null;body=null;physicsAttached=!1;physicsWorldRef=null;colliderDesc;custom={};colliderDescs=[];compoundMeshes=[];debugInfo={};debugMaterial;collisionDelegate={collision:[],cooldowns:new Map,nextId:0};collisionType;packKey=null;bundleKey=null;instanceId=-1;isInstanced=!1;isBundled=!1;runtimeHandle=-1;runtimeAttached=!1;wasmStageRef=null;eventDelegate=new re;behaviorRefs=[];cloneFactory=null;trackAddedComponents=!1;trackedComponents=[];transformStore;moveX;moveY;moveZ;moveXY;moveXZ;move;resetVelocity;moveForwardXY;getPosition;getVelocity;setPosition;setPositionX;setPositionY;setPositionZ;wrapAroundXY;wrapAround3D;rotateInDirection;rotateYEuler;rotateEuler;rotateX;rotateY;rotateZ;setRotationY;setRotationX;setRotationZ;setRotationDegrees;setRotationDegreesY;setRotationDegreesX;setRotationDegreesZ;setRotation;getRotation;constructor(){super(),this.transformStore=pt(),Oe(this)}getPose(){if(this.wasmStageRef&&this.runtimeHandle>=0){let o=this.wasmStageRef.getPose(this.runtimeHandle);if(o)return{position:{x:o.position[0],y:o.position[1],z:o.position[2]},rotation:{x:o.rotation[0],y:o.rotation[1],z:o.rotation[2],w:o.rotation[3]}}}let e=this.body;if(!e)return null;let t=e.translation(),i=e.rotation();return{position:{x:t.x,y:t.y,z:t.z},rotation:{x:i.x,y:i.y,z:i.z,w:i.w}}}setPose(e){if(this.wasmStageRef&&this.runtimeHandle>=0){let i=!0;if(e.position){let o=b(e.position);i=this.wasmStageRef.setPosition(this.runtimeHandle,o.x,o.y,o.z)&&i}if(e.rotation){let{x:o,y:s,z:r,w:a}=e.rotation;i=this.wasmStageRef.setRotation(this.runtimeHandle,o,s,r,a)&&i}return i}let t=this.body;if(!t)return!1;if(e.position){let i=b(e.position);t.setTranslation({x:i.x,y:i.y,z:i.z},!0)}return e.rotation&&t.setRotation(e.rotation,!0),!0}add(...e){for(let t of e)t instanceof Se?(this.addMeshComponent(t),this.trackComponent(t)):xe(t)?(this.addCollisionComponent(t),this.trackComponent(t)):super.add(t);return this}addMeshComponent(e){if(this.mesh)this.compoundMeshes.push(e),this.group||(this.group=new ut,this.group.add(this.mesh)),this.group.add(e);else if(this.mesh=e,this.materials||(this.materials=[]),e.material){let t=e.material;Array.isArray(t)?this.materials.push(...t):this.materials.push(t)}}addCollisionComponent(e){if(this.bodyDesc)this.colliderDescs.push(e.colliderDesc);else{this.bodyDesc=e.bodyDesc,this.colliderDesc=e.colliderDesc,this.colliderDescs.push(e.colliderDesc);let t=b(this.options?.position,S);this.bodyDesc.position=[t.x,t.y,t.z]}}trackComponent(e){if(this.trackAddedComponents){if(e instanceof Se){this.trackedComponents.push({kind:"mesh",component:Me(e)});return}this.trackedComponents.push({kind:"collision",component:X(e)})}}_actions=[];runAction(e){return this._actions.push(e),e}action(e){return e.persistent=!0,this._actions.push(e),e}clearActions(){this._actions.length=0}_tickActions(e){if(this._actions.length===0)return;let t=this.transformStore;t.velocity.x=0,t.velocity.y=0,t.velocity.z=0,_e(t,"actions"),t.angularVelocity.x=0,t.angularVelocity.y=0,t.angularVelocity.z=0,t.dirty.angularVelocity=!1;for(let i=this._actions.length-1;i>=0;i--){let o=this._actions[i];o.tick(this,e),o.done&&!o.persistent&&this._actions.splice(i,1)}this._actions.length===0&&(t.velocity.x=0,t.velocity.y=0,t.velocity.z=0,_e(t,"actions"),t.angularVelocity.x=0,t.angularVelocity.y=0,t.angularVelocity.z=0,t.dirty.angularVelocity=!1)}create(){return this.name=this.options.name||"",this}clone(e){if(!this.cloneFactory)throw new Error(`Cannot clone ${this.constructor.name}: clone() is only supported for entities created by official factory helpers.`);let t=this.cloneFactory(C(this.options,e)),i=this.copyBehaviorRefsTo(t),o=r=>ft(r,i);this.replayUserLifecycleRegistrationsTo(t,o);let s=this.getCollisionRegistrations();if(s.length>0)for(let r of s)t.onCollision(o(r.callback),r.options);for(let r of this.trackedComponents){if(r.kind==="mesh"){t.add(Me(r.component));continue}t.add(X(r.component))}return this.cloneChildrenInto(t),t}finalizeCloneSupport(e){return this.cloneFactory=e,this.enableUserLifecycleTracking(),this.trackAddedComponents=!0,this}onCollision(...e){let t=[...this.collisionDelegate.collision??[]],i=this.collisionDelegate.nextId??0;if(e.length===1||e.length===2&&(e[1]==null||dt(e[1]))){let o=e[0];if(!o)return this;let s=e[1];return t.push({id:i,callback:o,options:Ee(s)}),i+=1,this.collisionDelegate.collision=t,this.collisionDelegate.nextId=i,this}for(let o of e)t.push({id:i,callback:o,options:Ee()}),i+=1;return this.collisionDelegate.collision=t,this.collisionDelegate.nextId=i,this}use(e,t){let i={descriptor:e,options:{...e.defaultOptions,...t}};this.behaviorRefs.push(i);let o={getFSM:()=>i.fsm??null,getOptions:()=>i.options,ref:i},s=e.createHandle?.(i)??{};return{...o,...s}}getBehaviorRefs(){return this.behaviorRefs}getCollisionCallbacks(){return this.getCollisionRegistrations().map(e=>e.callback)}getCollisionRegistrations(){return(this.collisionDelegate.collision??[]).map(e=>({id:e.id,callback:e.callback,options:{...e.options}}))}copyBehaviorRefsTo(e){let t=new Map;for(let i of this.behaviorRefs){e.use(i.descriptor,y(i.options));let o=e.getBehaviorRefs().at(-1);o&&t.set(i,o)}return t}_setup(e){for(let t=this._actions.length-1;t>=0;t--){let i=this._actions[t];i.done&&!i.persistent?this._actions.splice(t,1):i.reset()}}async _loaded(e){}_update(e){this.updateMaterials(e)}_destroy(e){}_cleanup(e){this.disposeEvents();for(let t of this.compoundMeshes)t.geometry?.dispose(),Array.isArray(t.material)?t.material.forEach(i=>i.dispose()):t.material?.dispose();this.compoundMeshes.length=0,this.debugMaterial?.dispose(),this.debugMaterial=void 0,this.group?.removeFromParent()}_collision(e,t,i={phase:"stay",nowMs:ht()}){if(!this.collisionDelegate.collision?.length)return;let o=this.collisionDelegate.cooldowns??new Map;this.collisionDelegate.cooldowns=o;for(let s of this.collisionDelegate.collision){if(s.options.phase!==i.phase)continue;let r=s.options.cooldownMs;if(r!=null){let a=`${s.id}:${e.uuid}`,l=o.get(a);if(l!=null&&i.nowMs-l<r)continue;o.set(a,i.nowMs)}s.callback({entity:this,other:e,globals:t})}}updateMaterials(e){if(this.materials?.length)for(let t of this.materials)t instanceof ct&&t.uniforms&&t.uniforms.iTime&&(t.uniforms.iTime.value+=e.delta)}buildInfo(){let e={};return e.name=this.name,e.uuid=this.uuid,e}dispatch(e,t){this.eventDelegate.dispatch(e,t),ae.emit(e,t)}listen(e,t){return this.eventDelegate.listen(e,t)}disposeEvents(){this.eventDelegate.dispose()}};function mt(n){let e=new D;return e.options={...V,...n},$(e,t=>mt(t??{}))}function Me(n){let e=n.clone(!0),t=[],i=[];n.traverse(o=>t.push(o)),e.traverse(o=>i.push(o));for(let o=0;o<t.length;o++){let s=t[o],r=i[o];s?.geometry?.clone&&(r.geometry=s.geometry.clone()),s?.material&&(r.material=Array.isArray(s.material)?s.material.map(a=>a.clone()):s.material.clone())}return e}function ft(n,e){return e.size===0?n:((...t)=>{let i=Array.from(e.entries()).map(([o,s])=>({sourceRef:o,options:o.options,fsm:o.fsm,hasFSM:Object.prototype.hasOwnProperty.call(o,"fsm"),targetRef:s}));for(let o of i)o.sourceRef.options=o.targetRef.options,o.targetRef.fsm===void 0?delete o.sourceRef.fsm:o.sourceRef.fsm=o.targetRef.fsm;try{return n(...t)}finally{for(let o=i.length-1;o>=0;o--){let s=i[o];s.sourceRef.options=s.options,s.hasFSM?s.sourceRef.fsm=s.fsm:delete s.sourceRef.fsm}}})}function $(n,e){return n.finalizeCloneSupport(e),n}function Ae(n){return typeof n?.load=="function"&&typeof n?.data=="function"}var G=class{entityReference;constructor(e){this.entityReference=e}load(){this.entityReference.load&&this.entityReference.load()}data(){return this.entityReference.data?this.entityReference.data():null}};function De(n){let{args:e,defaultConfig:t,EntityClass:i,BuilderClass:o,entityType:s,MeshBuilderClass:r,CollisionBuilderClass:a,cloneFactory:l}=n,d=null,h,c=e.findIndex(p=>!(p instanceof x));c!==-1&&(h=e.splice(c,1).find(f=>!(f instanceof x)));let u=h?C(t,h):C(t);e.push(u);for(let p of e){if(p instanceof x)continue;let f=null,O=new i(p);try{if(Ae(O)){let m=new G(O);m.load(),f=m.data()}}catch(m){console.error("Error creating entity with loader:",m)}d=new o(p,O,r?new r(f):null,a?new a(f):null),p.material&&d.withMaterial(p.material,s)}if(!d)throw new Error(`missing options for ${String(s)}, builder is not initialized.`);return $(d.build(),p=>l(p))}import{Box3 as ie,BufferAttribute as Et,SkinnedMesh as Mt,MeshStandardMaterial as At,Group as Dt,Vector3 as M,Matrix4 as je}from"three";var R=class{async loadFile(e,t){switch(fe(e)){case"fbx":{let o=await L.loadFBX(e,t);return{object:o.object,animation:o.animations?.[0]}}case"gltf":case"glb":{let o=await L.loadGLTF(e,t);return{object:o.object,gltf:o.gltf}}case"obj":return{object:(await L.loadOBJ(e,t)).object};default:throw new Error(`Unsupported file type: ${e}`)}}};import{AnimationMixer as yt,Bone as Be,LoopOnce as bt,LoopRepeat as gt}from"three";function Ct(n){let e=n.lastIndexOf(".");return e>=0?n.slice(0,e):n}function Fe(n,e){if(!n?.name?.endsWith(".position"))return!1;let t=Ct(n.name),i=e.get(t);return i instanceof Be?!(i.parent instanceof Be):/hips\.position$/i.test(n.name)||/root\.position$/i.test(n.name)}function xt(n,e,t,i){for(let o of n.tracks){if(!Fe(o,e)||!o.values||o.values.length<3)continue;let s=o.values[0],r=i??o.values[1],a=o.values[2];for(let l=0;l<o.values.length;l+=3)o.values[l]=s,t&&(o.values[l+1]=r),o.values[l+2]=a}return n}function vt(n,e){for(let t of n.tracks)if(Fe(t,e)&&!(!t.values||t.values.length<3))return t.values[1];return null}var I=class{constructor(e){this.target=e}_mixer=null;_actions={};_animations=[];_currentAction=null;_pauseAtPercentage=0;_isPaused=!1;_queuedKey=null;_fadeDuration=.5;_currentKey="";_assetLoader=new R;async loadAnimations(e,t={}){if(!e.length)return;let i=t.stripRootMotionY??!1,o=t.referenceRootY,s=t.referenceAnimationPath,r=await Promise.all(e.map(c=>this._assetLoader.loadFile(c.path))),a=new Map;this.target.traverse(c=>{c.name&&a.set(c.name,c)});let l=[];if(r.forEach((c,u)=>{c.animation&&l.push({key:e[u].key||u.toString(),clip:c.animation,path:e[u].path})}),!l.length)return;let d=o;if(i&&d===void 0){let c=s?l.findIndex(p=>p.path===s):0,u=c>=0?[c,...l.map((p,f)=>f).filter(p=>p!==c)]:l.map((p,f)=>f);for(let p of u){let f=vt(l[p].clip,a);if(f!==null){d=f;break}}}let h=l.map(({key:c,clip:u})=>({key:c,clip:xt(u,a,i,d)}));this._animations=h.map(c=>c.clip),this._mixer=new yt(this.target),h.forEach(({key:c,clip:u})=>{this._actions[c]=this._mixer.clipAction(u)}),this.playAnimation({key:h[0].key})}update(e){if(!this._mixer||!this._currentAction)return;this._mixer.update(e);let t=this._currentAction.getClip().duration*(this._pauseAtPercentage/100);if(!this._isPaused&&this._pauseAtPercentage>0&&this._currentAction.time>=t&&(this._currentAction.time=t,this._currentAction.paused=!0,this._isPaused=!0,this._queuedKey!==null)){let i=this._actions[this._queuedKey];i.reset().play(),this._currentAction.crossFadeTo(i,this._fadeDuration,!1),this._currentAction=i,this._currentKey=this._queuedKey,this._queuedKey=null}}playAnimation(e){if(!this._mixer)return;let{key:t,pauseAtPercentage:i=0,pauseAtEnd:o=!1,fadeToKey:s,fadeDuration:r=.5}=e;if(t===this._currentKey)return;let a=this._actions[t];if(!a)return;if(a===this._currentAction){this._currentKey=t;return}this._queuedKey=s||null,this._fadeDuration=r,this._pauseAtPercentage=o?100:i,this._isPaused=!1;let l=this._currentAction;this._pauseAtPercentage>0?(a.setLoop(bt,1/0),a.clampWhenFinished=!0):(a.setLoop(gt,1/0),a.clampWhenFinished=!1),a.reset().play(),l&&l.crossFadeTo(a,r,!1),this._currentAction=a,this._currentKey=t}dispose(){Object.values(this._actions).forEach(e=>{e.stop()}),this._mixer&&(this._mixer.stopAllAction(),this._mixer.uncacheRoot(this.target),this._mixer=null),this._actions={},this._animations=[],this._currentAction=null,this._currentKey=""}get currentAnimationKey(){return this._currentKey}get animations(){return this._animations}};import{BufferGeometry as St,Mesh as Re,Color as _t}from"three";import{Mesh as Ot}from"three";var U=class{_build(e,t,i){let o=new Ot(t,i.at(-1));return o.position.set(0,0,0),o.castShadow=!0,o.receiveShadow=!0,o}_postBuild(){}};var N=class extends me{},Te=class extends U{build(e){return new St}postBuild(){}},Z=class{meshBuilder;collisionBuilder;materialBuilder;options;entity;constructor(e,t,i,o){this.options=e,this.entity=t,this.meshBuilder=i,this.collisionBuilder=o,this.materialBuilder=new ye;let s={meshBuilder:this.meshBuilder,collisionBuilder:this.collisionBuilder,materialBuilder:this.materialBuilder};this.options._builders=s,t&&t.options&&(t.options._builders=s)}withPosition(e){return this.options.position=e,this}withMaterial(e,t){return this.materialBuilder&&this.materialBuilder.build(e,t),this}applyMaterialToGroup(e,t){e.traverse(i=>{i instanceof Re&&i.type==="SkinnedMesh"&&t[0]&&!i.material.map&&(i.material=t[0]),i.castShadow=!0,i.receiveShadow=!0})}build(){let e=this.entity;if(this.materialBuilder&&(e.materials=this.materialBuilder.materials),this.meshBuilder&&e.materials){let t=this.meshBuilder.build(this.options);e.mesh=this.meshBuilder._build(this.options,t,e.materials),this.meshBuilder.postBuild()}if(e.group&&e.materials&&this.applyMaterialToGroup(e.group,e.materials),this.collisionBuilder){this.collisionBuilder.withCollision(this.options?.collision||{});let[t,i]=this.collisionBuilder.build(this.options);e.bodyDesc=t,e.colliderDesc=i,e.colliderDescs.push(i);let{x:o,y:s,z:r}=b(this.options.position,S);e.bodyDesc.position=[o,s,r]}if(this.options.collisionType&&(e.collisionType=this.options.collisionType),this.options.color instanceof _t){let t=i=>{let o=i;o&&o.color&&o.color.set&&o.color.set(this.options.color)};if(e.materials?.length)for(let i of e.materials)t(i);if(e.mesh&&e.mesh.material){let i=e.mesh.material;Array.isArray(i)?i.forEach(t):t(i)}e.group&&e.group.traverse(i=>{if(i instanceof Re&&i.material){let o=i.material;Array.isArray(o)?o.forEach(t):t(o)}})}return e}};var ze={...V,material:{shader:P},animations:[],models:[],collisionShape:"capsule"};function w(n){return z(n.scale,F)}var Bt=1e-4,Ft=/foot$/i,q=new M,W=new M,we=new M,Y=new M,ke=new je;function Rt(n){let e=1/0,t=!1;return n.traverse(i=>{if(!i.isSkinnedMesh)return;let o=i,s=o.geometry,r=s.attributes.position,a=s.attributes.skinIndex,l=s.attributes.skinWeight,d=o.skeleton;if(!r||!a||!l||!d)return;t=!0,d.update(),o.updateMatrixWorld(!0);let h=d.boneMatrices;if(h)for(let c=0;c<r.count;c++){we.fromBufferAttribute(r,c).applyMatrix4(o.bindMatrix),Y.set(0,0,0);for(let u=0;u<4;u++){let p=l.getComponent(c,u);if(p===0)continue;let f=a.getComponent(c,u);ke.fromArray(h,f*16),Y.addScaledVector(W.copy(we).applyMatrix4(ke),p)}Y.applyMatrix4(o.bindMatrixInverse).applyMatrix4(o.matrixWorld),e=Math.min(e,Y.y)}}),!t||!Number.isFinite(e)?null:e}function Tt(n,e){e.updateMatrixWorld(!0);let t=e.getWorldPosition(q).y,i=Rt(n)??1/0;if(n.traverse(o=>{!o.isBone||!Ft.test(o.name)||(o.getWorldPosition(q),i=Math.min(i,q.y))}),Number.isFinite(i)||n.traverse(o=>{if(!o.isSkinnedMesh)return;let s=o;if(s.computeBoundingBox(),!s.boundingBox)return;let{min:r,max:a}=s.boundingBox;for(let l of[[r.x,r.y,r.z],[r.x,r.y,a.z],[r.x,a.y,r.z],[r.x,a.y,a.z],[a.x,r.y,r.z],[a.x,r.y,a.z],[a.x,a.y,r.z],[a.x,a.y,a.z]])W.set(l[0],l[1],l[2]),W.applyMatrix4(s.matrixWorld),i=Math.min(i,W.y)}),!Number.isFinite(i)){let o=new ie().setFromObject(n);if(o.isEmpty())return null;i=o.min.y}return i-t}function wt(n,e,t){return n.stripRootMotionY!==void 0?n.stripRootMotionY:!!(e&&t.some(i=>i===e))}function j(n){let e=n.collision?.position;return e?b(e,S):null}function J(n){return!!n.collision?.size}function kt(n){n.hasWarnedDynamicTrimesh||(n.hasWarnedDynamicTrimesh=!0,console.warn(`Actor "${n.name||n.uuid}" requested collisionShape="trimesh" on a dynamic body; falling back to bounds.`))}function Pe(n,e,t){let i=n==="model"?"bounds":n??"capsule";return i==="trimesh"&&!e?(t?.(),"bounds"):i}function Le(n,e){let t=n.x||.5,i=n.y||1,o=n.z||.5,s=Math.max(t,o)/2,r=i/2;return{shape:{type:"capsule",halfHeight:Math.max(0,r-s),radius:s},offset:[e.x,e.y,e.z],sensor:!1}}function B(n){let e=b(n.collision?.size??n.size,{x:.5,y:1,z:.5}),t=e.y||1,i=j(n);return Le({x:e.x||.5,y:t,z:e.z||.5},i??{x:0,y:t/2,z:0})}function Ve(n){let e=n.collision?.size;if(!e)return null;let t=b(e,S),i=t.x/2,o=t.y/2,s=t.z/2,r=j(n);return{shape:{type:"box",halfExtents:[i,o,s]},offset:[r?.x??0,r?.y??o,r?.z??0],sensor:!1}}function Ge(n,e,t){let o=e.matrixWorld.clone().invert().multiply(n.matrixWorld);return new je().makeScale(t.x,t.y,t.z).multiply(o)}function Q(n,e,t){n.updateMatrixWorld(!0);let i=!1,o=new ie;if(n.traverse(a=>{if(!a.isMesh)return;let l=a,d=l.geometry;if(!d)return;let h=null;if(l instanceof Mt?(l.computeBoundingBox(),h=l.boundingBox?.clone()??null):(d.computeBoundingBox(),h=d.boundingBox?.clone()??null),!h)return;let c=h.applyMatrix4(Ge(l,e,t));if(!i){o.copy(c),i=!0;return}o.union(c)}),!i||o.isEmpty())return null;let s=new M,r=new M;return o.getSize(s),o.getCenter(r),{size:s,center:r}}function jt(n,e,t){n.updateMatrixWorld(!0);let i=[],o=[],s=new ie,r=new M,a=!1;if(n.traverse(d=>{if(!d.isMesh)return;let h=d,c=h.geometry;if(!c)return;let u=c.getAttribute("position");if(!(u instanceof Et))return;let p=Ge(h,e,t),f=i.length/3;for(let m=0;m<u.count;m++)r.set(u.getX(m),u.getY(m),u.getZ(m)),r.applyMatrix4(p),i.push(r.x,r.y,r.z),s.expandByPoint(r);let O=c.getIndex();if(O)for(let m=0;m<O.count;m++)o.push(f+O.getX(m));else for(let m=0;m<u.count;m++)o.push(f+m);a=!0}),!a||i.length===0||o.length===0)return null;let l=new M;return s.getCenter(l),{vertices:new Float32Array(i),indices:new Uint32Array(o),center:l}}function Ie(n,e,t){let i=Ve(t);if(i)return i;if(!n||!e)return B(t);let o=Q(n,e,w(t));if(!o)return B(t);let s=j(t);return{shape:{type:"box",halfExtents:[o.size.x/2,o.size.y/2,o.size.z/2]},offset:[s?.x??o.center.x,s?.y??o.center.y,s?.z??o.center.z],sensor:!1}}function Ue(n,e,t,i,o){if(J(o)||!n||!e)return B(o);let s=Q(n,e,w(o));if(!s)return B(o);let a=j(o);if(!a){let l=t&&i?Q(t,i,w(o)):null;a=l?{x:l.center.x,y:l.center.y,z:l.center.z}:{x:s.center.x,y:s.center.y,z:s.center.z}}return Le({x:s.size.x,y:s.size.y,z:s.size.z},a)}function Ne(n,e,t){let i=Ve(t);if(i)return i;if(!n||!e)return B(t);let o=jt(n,e,w(t));if(!o)return B(t);let s=j(t);return{shape:{type:"trimesh",vertices:o.vertices,indices:o.indices},offset:s?[s.x-o.center.x,s.y-o.center.y,s.z-o.center.z]:[0,0,0],sensor:!1}}function H(n){n&&n.traverse(e=>{if(!e.isMesh)return;let t=e;t.geometry?.dispose(),Array.isArray(t.material)?t.material.forEach(i=>i.dispose()):t.material?.dispose()})}var ee=class extends N{objectModel=null;collisionSource=null;collisionShape="capsule";constructor(e){super(),this.objectModel=e.objectModel,this.collisionSource=e.collisionSource??e.objectModel??null,this.collisionShape=e.collisionShape??"capsule"}collider(e){let t=Pe(this.collisionShape,!!e.collision?.static);return t==="bounds"?Ie(this.objectModel,this.objectModel,e):t==="trimesh"?Ne(this.objectModel,this.objectModel,e):Ue(this.collisionSource,this.collisionSource,this.objectModel,this.objectModel,e)}},te=class extends Z{createEntity(e){return new k(e)}},zt=Symbol("Actor"),k=class extends D{static type=zt;_object=null;_collisionSource=null;_animationDelegate=null;_modelFileNames=[];_assetLoader=new R;_loadGeneration=0;_loadStatus="idle";controlledRotation=!1;hasWarnedDynamicTrimesh=!1;constructor(e){super(),this.options=C(ze,e),this.prependUpdate(this.actorUpdate.bind(this)),this.controlledRotation=!0}create(){return this._loadStatus==="idle"&&(this.options.models?.length??0)>0&&this.load(),super.create()}load(){this._loadStatus==="loading"||this._loadStatus==="loaded"||(this._modelFileNames=[...this.options.models||[]],this._modelFileNames.length!==0&&(this.disposeRuntimeState(!0),this._loadStatus="loading",this.loadModelsDeferred(++this._loadGeneration)))}data(){return{animations:this._animationDelegate?.animations,objectModel:this._object,collisionSource:this._collisionSource??this._object,collisionShape:this.options.collisionShape}}needsDeferredModelCollision(){return this.requiresLoadedCollisionSource()?!this.getRuntimeCollisionSource():!1}synchronizeRuntimeCollider(){let e=this.getResolvedCollisionShape(),t;if(e==="bounds")t=Ie(this._object,this.group??this._object,this.options);else if(e==="trimesh")t=Ne(this._object,this.group??this._object,this.options);else{let i=this.getRuntimeCollisionSource();t=Ue(i,i,this._object,this._object,this.options)}this.colliderDesc=t,this.colliderDescs.length>0?this.colliderDescs[0]=t:this.colliderDescs.push(t)}actorUpdate(e){this._animationDelegate?.update(e.delta)}actorDestroy(){this._loadGeneration+=1,this._loadStatus="idle",this.disposeRuntimeState(!0),this._modelFileNames=[]}_cleanup(e){super._cleanup(e),this.actorDestroy()}playAnimation(e){this._animationDelegate?.playAnimation(e)}get object(){return this._object}get collisionSource(){return this._collisionSource??this._object}getDebugInfo(){let e={type:"Actor",models:this._modelFileNames.length>0?this._modelFileNames:"none",modelLoaded:!!this._object,scale:(()=>{let t=b(this.options.scale,F);return`${t.x}, ${t.y}, ${t.z}`})(),collisionShape:this.getResolvedCollisionShape()};if(this._animationDelegate&&(e.currentAnimation=this._animationDelegate.currentAnimationKey||"none",e.animationsCount=this.options.animations?.length||0),this._object){let t=0,i=0;this._object.traverse(o=>{if(!o.isMesh)return;t++;let s=o.geometry;s?.attributes.position&&(i+=s.attributes.position.count)}),e.meshCount=t,e.vertexCount=i}return e}getResolvedCollisionShape(){return Pe(this.options.collisionShape,!!this.options.collision?.static,()=>kt(this))}requiresLoadedCollisionSource(){let e=this.getResolvedCollisionShape();return e==="bounds"||e==="trimesh"?!J(this.options):e==="capsule"?!J(this.options)&&this.getCollisionSourceSelection().file!==null:!1}getRuntimeCollisionSource(){let e=this.getResolvedCollisionShape();return e==="bounds"||e==="trimesh"?this._object:this._collisionSource??this._object}getCollisionSourceSelection(){let e=this.options.models?.[0]??null,t=this.options.animations?.[0]?.path??null;return t?{file:t,reuseVisibleModel:t===e}:{file:e,reuseVisibleModel:!0}}disposeRuntimeState(e){this._animationDelegate&&(this._animationDelegate.dispose(),this._animationDelegate=null);let t=this._collisionSource;H(this._object),t&&t!==this._object&&H(t),this._object=null,this._collisionSource=null,e&&this.group&&(this.group.clear(),this.group=void 0)}loadModelsDeferred(e){this.dispatch("entity:model:loading",{entityId:this.uuid,files:this._modelFileNames});let t=this.getCollisionSourceSelection(),i=this._modelFileNames.map(s=>this._assetLoader.loadFile(s,{clone:!0})),o=t.file&&!t.reuseVisibleModel?this._assetLoader.loadFile(t.file,{clone:!0}):Promise.resolve(null);Promise.all([Promise.all(i),o]).then(([s,r])=>{if(e!==this._loadGeneration){s.forEach(l=>H(l.object??null)),r?.object&&H(r.object);return}this._object=s[0]?.object??null,this._collisionSource=t.reuseVisibleModel?this._object:r?.object??this._object,this._loadStatus=this._object?"loaded":"idle";let a=0;if(this._object){this._object.traverse(u=>{u.isMesh&&a++}),this.group=new Dt,this.group.add(this._object),this.group.scale.copy(w(this.options)),this.applyMaterialOverrides(),this._animationDelegate=new I(this._object);let l=this.options.animations||[],d=this.options.models?.[0],h=l.map(u=>u.path),c=wt(this.options,d,h);l.length>0?this._animationDelegate.loadAnimations(l,{stripRootMotionY:c,referenceAnimationPath:d}).then(()=>{e===this._loadGeneration&&(this.alignVisualModelToGround(),this.dispatch("entity:animation:loaded",{entityId:this.uuid,animationCount:l.length}))}):this.alignVisualModelToGround()}this.dispatch("entity:model:loaded",{entityId:this.uuid,success:!!this._object,meshCount:a})}).catch(s=>{e===this._loadGeneration&&(this._loadStatus="idle",console.error("Failed to load actor model",s),this.dispatch("entity:model:loaded",{entityId:this.uuid,success:!1,meshCount:0,errorMessage:s instanceof Error?s.message:String(s)}))})}alignVisualModelToGround(){if(!this._object||!this.group)return;this._animationDelegate?.update(0),this._object.updateMatrixWorld(!0);let e=Tt(this._object,this.group);if(e===null||Math.abs(e)<Bt)return;let t=this.group.scale.y||1;this._object.position.y-=e/t}applyMaterialOverrides(){let e=this.options.material;!e||!e.color&&!e.path&&e.opacity===void 0||this._object&&this._object.traverse(t=>{if(!t.isMesh)return;let i=t;i.material=Array.isArray(i.material)?i.material.map(o=>this.tintMaterial(o,e)):this.tintMaterial(i.material,e),e.color&&(i.castShadow=!0,i.receiveShadow=!0)})}tintMaterial(e,t){let i="color"in e,o=!!t.color,s=t.opacity!==void 0;if(!o&&!s)return e;if(o&&!i)return new At({color:t.color,emissiveIntensity:.5,lightMapIntensity:.5,fog:!0,opacity:t.opacity??1,transparent:s&&t.opacity<1});let r=e.clone();if(o&&"color"in r&&r.color.copy(t.color),s&&"opacity"in r&&"transparent"in r){let a=r;a.opacity=t.opacity,a.transparent=t.opacity<1}return r.needsUpdate=!0,r}};function Pt(...n){return De({args:n,defaultConfig:ze,EntityClass:k,BuilderClass:te,CollisionBuilderClass:ee,entityType:k.type,cloneFactory:e=>Pt(e??{})})}import{Color as Wt,Fog as Kt,FogExp2 as Xt,Group as $t}from"three";import{Color as Lt}from"three";import{Fn as Ye,fog as Vt,positionWorld as Ze,positionView as Gt,uniform as g,float as It,vec3 as v,clamp as oe,mix as _,max as Ut,smoothstep as Nt,floor as Zt,fract as ne,dot as Yt}from"three/tsl";var K=class{values;u={time:g(0),heightEnabled:g(0),heightLevel:g(0),heightFalloff:g(0),noiseEnabled:g(0),noiseScale:g(0),noiseStrength:g(0),noiseSpeed:g(0)};attachedScene=null;constructor(e){this.values={...e},this.syncUniforms()}setValues(e){Object.assign(this.values,e),this.syncUniforms()}tick(e){this.values.time+=e,this.u.time.value=this.values.time}scan(e){if(this.attachedScene===e)return;let t=e.fog;t&&(e.fogNode=this.buildFogNode(t),this.attachedScene=e)}unpatchAll(){this.attachedScene&&(this.attachedScene.fogNode=null,this.attachedScene=null)}syncUniforms(){this.u.time.value=this.values.time,this.u.heightEnabled.value=this.values.heightEnabled,this.u.heightLevel.value=this.values.heightLevel,this.u.heightFalloff.value=this.values.heightFalloff,this.u.noiseEnabled.value=this.values.noiseEnabled,this.u.noiseScale.value=this.values.noiseScale,this.u.noiseStrength.value=this.values.noiseStrength,this.u.noiseSpeed.value=this.values.noiseSpeed}buildFogNode(e){let t=e.isFogExp2===!0,i=g(new Lt(e.color)),o=Gt.z.negate(),s=t?this.exp2Factor(g(e.density),o):Nt(g(e.near),g(e.far),o),r=this.u.heightLevel.sub(Ze.y),a=oe(r.mul(Ut(this.u.heightFalloff,0)),0,1),l=_(s,s.mul(a),this.u.heightEnabled),d=Ze.mul(this.u.noiseScale).add(v(this.u.time.mul(this.u.noiseSpeed),0,this.u.time.mul(this.u.noiseSpeed).mul(.5))),c=Ht(d).sub(.5).mul(2).mul(oe(this.u.noiseStrength,0,1)),u=oe(l.add(l.mul(c)),0,1),p=_(l,u,this.u.noiseEnabled);return Vt(i,p)}exp2Factor(e,t){return e.mul(e).mul(t).mul(t).negate().exp().oneMinus()}},A=Ye(([n])=>{let e=ne(n.mul(v(443.8975,397.2973,491.1871))),t=e.add(Yt(e,e.yzx.add(19.27)));return ne(t.x.add(t.y).mul(t.z))}),Ht=Ye(([n])=>{let e=Zt(n),t=ne(n),i=t.mul(t).mul(It(3).sub(t.mul(2))),o=A(e.add(v(0,0,0))),s=A(e.add(v(1,0,0))),r=A(e.add(v(0,1,0))),a=A(e.add(v(1,1,0))),l=A(e.add(v(0,0,1))),d=A(e.add(v(1,0,1))),h=A(e.add(v(0,1,1))),c=A(e.add(v(1,1,1))),u=_(o,s,i.x),p=_(r,a,i.x),f=_(l,d,i.x),O=_(h,c,i.x),m=_(u,p,i.y),He=_(f,O,i.y);return _(m,He,i.z)});var qt=Symbol("Fog"),Jt="#9aa3ad",Qt=.015,ei=10,ti=250,ii=5,oi=.2,ni=.05,si=.15,ri=.1,se=class extends D{static type=qt;threeFog=null;attachedScene=null;patcher;patcherEnabled;constructor(e={}){super(),this.options={...e};let t=this.resolveUniformValues(this.options);this.patcher=new K(t),this.patcherEnabled=li(this.options)}create(){return super.create(),this.threeFog=ai(this.options),this.group=new $t,this.group.name=this.name?`Fog:${this.name}`:"Fog",this}attachToScene(e){this.threeFog&&(this.attachedScene=e,e.fog=this.threeFog,this.patcherEnabled&&this.patcher.scan(e))}_update(e){super._update(e),!(!this.attachedScene||!this.patcherEnabled)&&(this.patcher.tick(e.delta),this.patcher.scan(this.attachedScene))}_cleanup(e){this.patcher.unpatchAll(),this.attachedScene&&this.attachedScene.fog===this.threeFog&&(this.attachedScene.fog=null),this.attachedScene=null,this.threeFog=null,super._cleanup(e)}resolveUniformValues(e){let t=e.height,i=e.noise;return{time:0,heightEnabled:t?.enabled?1:0,heightLevel:t?.level??ii,heightFalloff:t?.falloff??oi,noiseEnabled:i?1:0,noiseScale:i?.scale??ni,noiseStrength:i?.strength??si,noiseSpeed:i?.speed??ri}}};function ai(n){let e=new Wt(n.color??Jt);return(n.type??"linear")==="exp2"?new Xt(e,n.density??Qt):new Kt(e,n.start??ei,n.end??ti)}function li(n){let e=!!n.height?.enabled,t=!!n.noise;return e||t}function en(n={}){return new se(n)}export{x as a,C as b,$e as c,qe as d,Je as e,Qe as f,et as g,tt as h,it as i,ot as j,V as k,Ti as l,D as m,mt as n,$ as o,De as p,N as q,Te as r,Z as s,zt as t,k as u,Pt as v,qt as w,se as x,en as y};
@@ -0,0 +1 @@
1
+ import{Euler as d,Vector3 as E,MathUtils as m,Quaternion as c}from"three";import{createTransformStore as v}from"@zylem/behaviors/core";function s(o){!o.group||!o.transformStore||o.group.setRotationFromQuaternion(new c(o.transformStore.rotation.x,o.transformStore.rotation.y,o.transformStore.rotation.z,o.transformStore.rotation.w))}function p(o,r){if(!o.body)return;let t=Math.atan2(-r.x,r.z);l(o,t)}function l(o,r){S(o,new E(0,-r,0))}function S(o,r){if(!o.transformStore)return;let t=new c().setFromEuler(new d(r.x,r.y,r.z));o.transformStore.rotation.w=t.w,o.transformStore.rotation.x=t.x,o.transformStore.rotation.y=t.y,o.transformStore.rotation.z=t.z,o.transformStore.dirty.rotation=!0,s(o)}function z(o,r){if(!o.transformStore)return;let t=r/2,n=Math.cos(t),a=Math.sin(t),e=o.transformStore.rotation,i=e.w*n-e.y*a,u=e.x*n+e.z*a,f=e.y*n+e.w*a,b=e.z*n-e.x*a;o.transformStore.rotation.w=i,o.transformStore.rotation.x=u,o.transformStore.rotation.y=f,o.transformStore.rotation.z=b,o.transformStore.dirty.rotation=!0,s(o)}function h(o,r){if(!o.transformStore)return;let t=r/2,n=Math.cos(t),a=Math.sin(t),e=o.transformStore.rotation,i=e.w*n-e.x*a,u=e.x*n+e.w*a,f=e.y*n+e.z*a,b=e.z*n-e.y*a;o.transformStore.rotation.w=i,o.transformStore.rotation.x=u,o.transformStore.rotation.y=f,o.transformStore.rotation.z=b,o.transformStore.dirty.rotation=!0,s(o)}function D(o,r){if(!o.transformStore)return;let t=r/2,n=Math.cos(t),a=Math.sin(t),e=o.transformStore.rotation,i=e.w*n-e.z*a,u=e.x*n-e.y*a,f=e.y*n+e.x*a,b=e.z*n+e.w*a;o.transformStore.rotation.w=i,o.transformStore.rotation.x=u,o.transformStore.rotation.y=f,o.transformStore.rotation.z=b,o.transformStore.dirty.rotation=!0,o._rotation2DAngle=(o._rotation2DAngle??0)+r,s(o)}function R(o,r){if(!o.transformStore)return;let t=r/2,n=Math.cos(t),a=Math.sin(t);o.transformStore.rotation.w=n,o.transformStore.rotation.x=0,o.transformStore.rotation.y=a,o.transformStore.rotation.z=0,o.transformStore.dirty.rotation=!0,s(o)}function Y(o,r){o.body&&R(o,m.degToRad(r))}function x(o,r){if(!o.transformStore)return;let t=r/2,n=Math.cos(t),a=Math.sin(t);o.transformStore.rotation.w=n,o.transformStore.rotation.x=a,o.transformStore.rotation.y=0,o.transformStore.rotation.z=0,o.transformStore.dirty.rotation=!0,s(o)}function M(o,r){o.body&&x(o,m.degToRad(r))}function w(o,r){if(!o.transformStore)return;let t=r/2,n=Math.cos(t),a=Math.sin(t);o.transformStore.rotation.w=n,o.transformStore.rotation.x=0,o.transformStore.rotation.y=0,o.transformStore.rotation.z=a,o.transformStore.dirty.rotation=!0,o._rotation2DAngle=r,s(o)}function A(o,r){o.body&&w(o,m.degToRad(r))}function g(o,r,t,n){if(!o.transformStore)return;let a=new c().setFromEuler(new d(r,t,n));o.transformStore.rotation.w=a.w,o.transformStore.rotation.x=a.x,o.transformStore.rotation.y=a.y,o.transformStore.rotation.z=a.z,o.transformStore.dirty.rotation=!0,o._rotation2DAngle=n,s(o)}function T(o,r,t,n){o.body&&g(o,m.degToRad(r),m.degToRad(t),m.degToRad(n))}function X(o){return o.body?o.body.rotation():null}function V(o){let r=o;return r.transformStore||(r.transformStore=v()),r.rotateInDirection=t=>p(o,t),r.rotateYEuler=t=>l(o,t),r.rotateEuler=t=>S(o,t),r.rotateX=t=>h(o,t),r.rotateY=t=>z(o,t),r.rotateZ=t=>D(o,t),r.setRotationY=t=>R(o,t),r.setRotationX=t=>x(o,t),r.setRotationZ=t=>w(o,t),r.setRotationDegreesY=t=>Y(o,t),r.setRotationDegreesX=t=>M(o,t),r.setRotationDegreesZ=t=>A(o,t),r.setRotationDegrees=(t,n,a)=>T(o,t,n,a),r.setRotation=(t,n,a)=>g(o,t,n,a),r.getRotation=()=>X(o),r}export{p as a,l as b,S as c,z as d,h as e,D as f,R as g,Y as h,x as i,M as j,w as k,A as l,g as m,T as n,X as o,V as p};
@@ -0,0 +1 @@
1
+ import{a as n}from"./chunk-QXVH6POE.js";var i=class{emitter;unsubscribes=[];constructor(){this.emitter=n()}dispatch(e,t){this.emitter.emit(e,t)}listen(e,t){this.emitter.on(e,t);let s=()=>this.emitter.off(e,t);return this.unsubscribes.push(s),s}listenAll(e){this.emitter.on("*",e);let t=()=>this.emitter.off("*",e);return this.unsubscribes.push(t),t}dispose(){this.unsubscribes.forEach(e=>e()),this.unsubscribes=[],this.emitter.all.clear()}};var a=n();export{i as a,a as b};
@@ -0,0 +1 @@
1
+ function r(i=800,t=.05){c(i,t)}function c(i,t){let e=new(window.AudioContext||window.webkitAudioContext),n=e.createOscillator(),o=e.createGain();n.type="sawtooth",n.frequency.value=i,o.gain.setValueAtTime(.05,e.currentTime),o.gain.exponentialRampToValueAtTime(.001,e.currentTime+t),n.connect(o),o.connect(e.destination),n.start(),n.stop(e.currentTime+t)}function a(i=440,t=.1){u(i,t)}function u(i,t){let e=new(window.AudioContext||window.webkitAudioContext),n=e.createOscillator(),o=e.createGain();n.type="square",n.frequency.value=i,o.gain.setValueAtTime(.05,e.currentTime),o.gain.exponentialRampToValueAtTime(.001,e.currentTime+t),n.connect(o),o.connect(e.destination),n.start(),n.stop(e.currentTime+t)}import{Howl as x}from"howler";export{r as a,a as b,x as c};
@@ -0,0 +1,38 @@
1
+ import { SimulationBodyDefinition, SimulationColliderDefinition } from '@zylem/behaviors/core';
2
+ import { e as Vec3Input } from './vector-CiSHbivc.js';
3
+
4
+ /**
5
+ * Options for configuring entity collision behavior.
6
+ */
7
+ interface CollisionOptions {
8
+ static?: boolean;
9
+ sensor?: boolean;
10
+ canSleep?: boolean;
11
+ ccdEnabled?: boolean;
12
+ size?: Vec3Input;
13
+ position?: Vec3Input;
14
+ collisionType?: string;
15
+ collisionFilter?: string[];
16
+ }
17
+ /**
18
+ * Pack a collision type + filter into the runtime's interaction-groups u32
19
+ * (high 16 bits = membership mask, low 16 bits = filter mask).
20
+ */
21
+ declare function packCollisionGroups(collisionType?: string, collisionFilter?: string[]): number;
22
+ /**
23
+ * Builds plain body + collider definitions consumable by the behaviors
24
+ * `Simulation` (`simulation.spawn(...)`). No physics-engine types appear
25
+ * here — everything is data until the world uploads it to the wasm runtime.
26
+ */
27
+ declare class CollisionBuilder {
28
+ static: boolean;
29
+ sensor: boolean;
30
+ build(options: Partial<CollisionOptions>): [SimulationBodyDefinition, SimulationColliderDefinition];
31
+ withCollision(collisionOptions: Partial<CollisionOptions>): this;
32
+ collider(options: CollisionOptions): SimulationColliderDefinition;
33
+ bodyDesc({ isDynamicBody }: {
34
+ isDynamicBody?: boolean | undefined;
35
+ }): SimulationBodyDefinition;
36
+ }
37
+
38
+ export { CollisionBuilder as C, type CollisionOptions as a, packCollisionGroups as p };
package/dist/core.d.ts CHANGED
@@ -1,17 +1,224 @@
1
- export { V as Vect3, c as createGame, v as vessel } from './core-CARRaS55.js';
2
- export { Z as ZylemGameConfig } from './stage-types-C19IhuzA.js';
3
- export { g as globalChange, a as globalChanges, v as variableChange, b as variableChanges } from './global-change-2JvMaz44.js';
4
- import './entity-vj-HTjzU.js';
5
- import 'three';
6
- import '@dimforge/rapier3d-compat';
7
- import 'bitecs';
8
- import 'mitt';
9
- import './behavior-descriptor-BXnVR8Ki.js';
10
- import './camera-4XO5gbQH.js';
11
- import './entity-Bq_eNEDI.js';
1
+ import { B as Stage, E as StageStateInterface, C as CameraWrapper } from './game-C1FHVqXl.js';
2
+ export { A as AspectRatio, q as AspectRatioValue, k as CameraManager, j as CameraOptions, D as DeviceProfile, p as FirstPersonOptions, l as FirstPersonPerspective, o as Fixed2DOptions, F as Fixed2DPerspective, G as Game, b as GameConfigLike, d as GameDeviceConfig, a as GameLoadingEvent, P as PerspectiveOptions, y as RenderBundleManager, z as RenderStrategyManager, R as ResolutionInput, e as ResolveGameConfigRuntime, v as RetroPreset, w as RetroPresetKey, x as RetroResolution, S as StageConfigLike, h as StageOptions, n as ThirdPersonOptions, T as ThirdPersonPerspective, i as createCamera, c as createGame, m as createPerspective, f as createStage, g as gameConfig, r as getDisplayAspect, t as getPresetResolution, u as parseResolution, s as stageConfig } from './game-C1FHVqXl.js';
3
+ export { G as GameInputConfig, a as GameInputPlayerConfig, K as KeyboardMapping, M as MouseConfig, b as MouseMapping, V as VirtualTouchButtonConfig, d as VirtualTouchButtonSlot, c as VirtualTouchButtonsConfig, e as VirtualTouchConfig, f as VirtualTouchJoystickConfig, g as VirtualTouchJoysticksConfig, h as VirtualTouchPosition, i as VirtualTouchStyle, Z as ZylemGameConfig } from './game-interfaces-mchNYSZE.js';
4
+ import { Vector2 } from 'three';
5
+ import { G as GameEntity, B as BaseNode, N as NodeInterface, a as GameEntityOptions } from './entity-BdSI8CL3.js';
6
+ import { S as StageBlueprint } from './blueprints-TbGY-h53.js';
7
+ import { a as SetupContext, k as LoadedContext, U as UpdateContext, D as DestroyContext, l as CleanupContext } from './base-node-life-cycle-D2NuN1VB.js';
8
+ export { L as LoadingEvent, S as StageNavigationOptions } from './base-node-life-cycle-D2NuN1VB.js';
9
+ export { S as StageTransitionConfig, a as StageTransitionEasing, Z as ZylemTransitionShader, c as crossfadeTransitionShader } from './stage-transition-CmGpV4tc.js';
10
+ import { f as CameraBehavior } from './zylem-camera-C3bn6BTI.js';
11
+ export { g as CameraAction, d as CameraContext, e as CameraPerspective, j as CameraPipeline, h as CameraPipelineState, C as CameraPose, P as PerspectiveType, a as Perspectives, c as PoseDelta, T as TransformLike, V as Viewport, b as ZylemRenderer, i as isWebGPUSupported } from './zylem-camera-C3bn6BTI.js';
12
+ import { e as Vec3Input, c as Vec3 } from './vector-CiSHbivc.js';
13
+ export { f as VEC2_ONE, g as VEC2_ZERO, h as VEC3_ONE, i as VEC3_ZERO, V as Vec2, a as Vec2Components, b as Vec2Input, d as Vec3Components, n as normalizeVec2, j as normalizeVec3, t as toThreeVector2, k as toThreeVector3 } from './vector-CiSHbivc.js';
14
+ import { S as StageEntity } from './entity-DZbFQ1Wg.js';
15
+ import './entity-type-map-Bd69SpAS.js';
16
+ import './material-9vJ6SZaI.js';
12
17
  import 'three/webgpu';
13
- import 'three/examples/jsm/postprocessing/EffectComposer.js';
14
- import './world-DfgxoNMt.js';
15
- import './entity-types-DAu8sGJH.js';
16
- import './physics-pose-DCc4oE44.js';
17
- import './entities-ChFirVL9.js';
18
+ import '@zylem/behaviors/core';
19
+ import '@zylem/behaviors/particle-emitter';
20
+ import 'three/addons/lines/webgpu/Line2.js';
21
+ import './events.js';
22
+ import 'mitt';
23
+ import './default-controls-0-vCnli7.js';
24
+ import './collision-builder-jF-toPIl.js';
25
+ import '@sinclair/typebox';
26
+
27
+ /**
28
+ * Authoring helper for spawning entities into a live stage at runtime.
29
+ *
30
+ * Wraps an entity factory so game code can spawn at absolute coordinates or
31
+ * relative to an existing entity (using its physics body's position/rotation),
32
+ * automatically adding the resulting instance to the stage. Exists to keep
33
+ * gameplay spawn logic (e.g. firing projectiles) declarative and decoupled
34
+ * from the stage's internal entity-management plumbing.
35
+ */
36
+
37
+ interface EntitySpawner {
38
+ spawn: (stage: Stage, x: number, y: number) => Promise<GameEntity<any>>;
39
+ spawnRelative: (source: any, stage: Stage, offset?: Vector2) => Promise<any | void>;
40
+ }
41
+ declare function entitySpawner(factory: (x: number, y: number) => Promise<any> | GameEntity<any>): EntitySpawner;
42
+
43
+ declare function setStageFrameProfilerEnabled(value: boolean): void;
44
+
45
+ declare const stageState: {
46
+ previous: StageBlueprint | null;
47
+ current: StageBlueprint | null;
48
+ next: StageBlueprint | null;
49
+ isLoading: boolean;
50
+ };
51
+ declare const StageManager: {
52
+ staticRegistry: Map<string, {
53
+ name?: string | undefined;
54
+ assets?: string[] | undefined;
55
+ id: string;
56
+ entities: {
57
+ position?: [number, number] | undefined;
58
+ data?: {
59
+ [x: string]: any;
60
+ } | undefined;
61
+ id: string;
62
+ type: string;
63
+ }[];
64
+ }>;
65
+ registerStaticStage(id: string, blueprint: StageBlueprint): void;
66
+ loadStageData(stageId: string): Promise<StageBlueprint>;
67
+ transitionForward(nextStageId: string, loadStaticStage?: (id: string) => Promise<StageBlueprint>): Promise<void>;
68
+ /**
69
+ * Manually set the next stage to pre-load it.
70
+ */
71
+ preloadNext(stageId: string, loadStaticStage?: (id: string) => Promise<StageBlueprint>): Promise<void>;
72
+ };
73
+
74
+ /**
75
+ * Event name for stage state changes.
76
+ * Dispatched when the stage state proxy is updated.
77
+ */
78
+ declare const STAGE_STATE_CHANGE = "STAGE_STATE_CHANGE";
79
+ /**
80
+ * Event detail payload for STAGE_STATE_CHANGE events.
81
+ */
82
+ interface StageStateChangeEvent {
83
+ entities: StageStateInterface['entities'];
84
+ variables: StageStateInterface['variables'];
85
+ }
86
+ /**
87
+ * Initialize the stage state dispatcher.
88
+ * Subscribes to stageState changes and dispatches STAGE_STATE_CHANGE events to the window.
89
+ *
90
+ * @returns Unsubscribe function to stop dispatching events.
91
+ *
92
+ * @example
93
+ * // Start dispatching stage state changes
94
+ * const unsubscribe = initStageStateDispatcher();
95
+ *
96
+ * // Later, stop dispatching
97
+ * unsubscribe();
98
+ */
99
+ declare function initStageStateDispatcher(): () => void;
100
+ /**
101
+ * Manually dispatch the current stage state.
102
+ * Useful for initial sync when a listener is added.
103
+ */
104
+ declare function dispatchStageState(): void;
105
+
106
+ /**
107
+ * Options for the followTarget behavior.
108
+ */
109
+ interface FollowTargetOptions {
110
+ /** Key in CameraContext.targets to follow. Default 'primary'. */
111
+ targetKey?: string;
112
+ /** Position offset from the target. Default (0, 0, 0). */
113
+ offset?: Vec3Input;
114
+ /**
115
+ * Interpolation factor in 0..1, applied per 60Hz frame.
116
+ * 1 = instant snap, lower = smoother follow. The per-frame rate is scaled
117
+ * by dt so tracking speed is identical across refresh rates (60/120/144Hz).
118
+ * Default 0.1.
119
+ */
120
+ lerpFactor?: number;
121
+ }
122
+ /**
123
+ * A simple follow behavior that moves the camera pose toward a target's position + offset.
124
+ *
125
+ * This behavior modifies only the position (and lookAt) of the incoming pose,
126
+ * leaving rotation/fov/zoom to the perspective or other behaviors.
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * camera.addBehavior('follow', createFollowTarget({ targetKey: 'player', offset: new Vector3(0, 3, 8) }));
131
+ * ```
132
+ */
133
+ declare function createFollowTarget(options?: FollowTargetOptions): CameraBehavior;
134
+
135
+ /**
136
+ * Options for setCameraFeed.
137
+ */
138
+ interface CameraFeedOptions {
139
+ /** Render target width in pixels. Only used when the camera does not
140
+ * already have a render target. @default 512 */
141
+ width?: number;
142
+ /** Render target height in pixels. Only used when the camera does not
143
+ * already have a render target. @default 512 */
144
+ height?: number;
145
+ }
146
+ /**
147
+ * Display a camera's live feed on an entity's mesh surface.
148
+ *
149
+ * This is the primary user-facing function for "jumbotron", security-camera,
150
+ * or broadcast-style effects. It ensures the camera has an offscreen render
151
+ * target and replaces the entity's mesh material with one that shows the
152
+ * camera's rendered output.
153
+ *
154
+ * @param entity The entity whose mesh will display the camera feed.
155
+ * @param camera The camera whose view will be rendered to the texture.
156
+ * @param options Optional dimensions for the render target.
157
+ *
158
+ * @example
159
+ * ```ts
160
+ * const feedCam = createCamera({
161
+ * perspective: Perspectives.ThirdPerson,
162
+ * position: new Vector3(0, 30, 60),
163
+ * target: new Vector3(0, 0, 0),
164
+ * renderToTexture: { width: 1024, height: 576 },
165
+ * });
166
+ *
167
+ * const screen = createBox({ size: { x: 16, y: 9, z: 0.2 } });
168
+ * screen.onSetup(({ me }) => {
169
+ * setCameraFeed(me, feedCam);
170
+ * });
171
+ * ```
172
+ */
173
+ declare function setCameraFeed(entity: StageEntity, camera: CameraWrapper, options?: CameraFeedOptions): void;
174
+
175
+ /**
176
+ * A Vessel is an empty container entity that holds child entities.
177
+ * It has no geometry, physics, or rendering of its own, but propagates
178
+ * lifecycle events to its children and provides a logical grouping mechanism.
179
+ *
180
+ * Child entities added to a Vessel will be individually spawned into the
181
+ * stage's physics world and render scene when the Vessel is spawned.
182
+ */
183
+ declare class Vessel extends BaseNode<{}, Vessel> {
184
+ static type: symbol;
185
+ protected _setup(_params: SetupContext<this>): void;
186
+ protected _loaded(_params: LoadedContext<this>): Promise<void>;
187
+ protected _update(_params: UpdateContext<this>): void;
188
+ protected _destroy(_params: DestroyContext<this>): void;
189
+ protected _cleanup(_params: CleanupContext<this>): void;
190
+ create(): this;
191
+ clone(): this;
192
+ /**
193
+ * Add one or more child entities to this vessel.
194
+ * Overrides parent to support multiple arguments.
195
+ * @returns this for chaining
196
+ */
197
+ add(...nodes: NodeInterface[]): this;
198
+ }
199
+ /**
200
+ * Create a vessel containing the given child entities.
201
+ * @param args Child BaseNode entities to add
202
+ * @returns A new Vessel with the children added
203
+ */
204
+ declare function vessel(...args: Array<BaseNode>): Vessel;
205
+
206
+ /** How an entity's mesh is drawn: scene-direct, WebGPU bundle, or instanced pack. */
207
+ type RenderCategory = 'none' | 'environment' | 'pack';
208
+ type RenderCategoryOptions = Pick<GameEntityOptions, 'category'>;
209
+ /** Resolve the render category for an entity. Defaults to `none`. */
210
+ declare function resolveRenderCategory(options?: RenderCategoryOptions | null): RenderCategory;
211
+ /** Whether the entity opts into a managed render path (bundle or instanced). */
212
+ declare function usesManagedRenderPath(options?: RenderCategoryOptions | null): boolean;
213
+ /** Whether the entity is already registered on a managed render path. */
214
+ declare function isManagedRenderEntity(entity: {
215
+ isInstanced?: boolean;
216
+ isBundled?: boolean;
217
+ }): boolean;
218
+
219
+ /**
220
+ * @deprecated Use Vec3 from ../vector instead.
221
+ */
222
+ type Vect3 = Vec3;
223
+
224
+ export { CameraBehavior, type CameraFeedOptions, CameraWrapper, type FollowTargetOptions, type RenderCategory, STAGE_STATE_CHANGE, SetupContext, StageBlueprint, StageEntity, StageManager, type StageStateChangeEvent, UpdateContext, Vec3, Vec3Input, type Vect3, createFollowTarget, dispatchStageState, entitySpawner, initStageStateDispatcher, isManagedRenderEntity, resolveRenderCategory, setCameraFeed, setStageFrameProfilerEnabled, stageState, usesManagedRenderPath, vessel };