@hology/core 0.0.210 → 0.0.212

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 (129) hide show
  1. package/dist/effects/sequence/sequence-player.js +1 -1
  2. package/dist/effects/vfx/initializsers.d.ts +8 -1
  3. package/dist/effects/vfx/initializsers.js +1 -1
  4. package/dist/effects/vfx/vfx-collision-behaviour.js +1 -1
  5. package/dist/effects/vfx/vfx-defs.d.ts +10 -1
  6. package/dist/effects/vfx/vfx-defs.js +1 -1
  7. package/dist/effects/vfx/vfx-materializer.js +1 -1
  8. package/dist/effects/vfx/vfx-renderers.d.ts +1 -0
  9. package/dist/effects/vfx/vfx-renderers.js +1 -1
  10. package/dist/gameplay/actors/actor.d.ts +23 -1
  11. package/dist/gameplay/actors/actor.js +1 -1
  12. package/dist/gameplay/actors/builtin/components/character/character-animation.js +1 -1
  13. package/dist/gameplay/actors/builtin/components/character/character-movement-like.d.ts +23 -0
  14. package/dist/gameplay/actors/builtin/components/character/character-movement-like.js +4 -0
  15. package/dist/gameplay/actors/builtin/components/character/character-movement-policy.d.ts +26 -0
  16. package/dist/gameplay/actors/builtin/components/character/character-movement-policy.js +4 -0
  17. package/dist/gameplay/actors/builtin/components/character/character-movement.d.ts +145 -55
  18. package/dist/gameplay/actors/builtin/components/character/character-movement.js +1 -1
  19. package/dist/gameplay/actors/builtin/components/character/net-character-movement-protocol.d.ts +125 -0
  20. package/dist/gameplay/actors/builtin/components/character/net-character-movement-protocol.js +4 -0
  21. package/dist/gameplay/actors/builtin/components/character/old-character-movement.d.ts +100 -0
  22. package/dist/gameplay/actors/builtin/components/character/old-character-movement.js +4 -0
  23. package/dist/gameplay/actors/builtin/components/index.d.ts +2 -0
  24. package/dist/gameplay/actors/builtin/components/index.js +1 -1
  25. package/dist/gameplay/actors/builtin/navmesh-actor.js +1 -1
  26. package/dist/gameplay/actors/camera/third-person-camera-component.d.ts +3 -0
  27. package/dist/gameplay/actors/camera/third-person-camera-component.js +1 -1
  28. package/dist/gameplay/actors/component.js +1 -1
  29. package/dist/gameplay/actors/controller/actor-controller.d.ts +16 -0
  30. package/dist/gameplay/actors/controller/actor-controller.js +4 -0
  31. package/dist/gameplay/actors/factory.d.ts +3 -0
  32. package/dist/gameplay/actors/factory.js +1 -1
  33. package/dist/gameplay/actors/index.d.ts +4 -0
  34. package/dist/gameplay/actors/index.js +1 -1
  35. package/dist/gameplay/actors/internal/component-init.js +1 -1
  36. package/dist/gameplay/ai/behavior-tree/move.d.ts +2 -2
  37. package/dist/gameplay/index.d.ts +3 -1
  38. package/dist/gameplay/index.js +1 -1
  39. package/dist/gameplay/initiate.d.ts +4 -0
  40. package/dist/gameplay/initiate.js +1 -1
  41. package/dist/gameplay/net/browser/index.d.ts +147 -0
  42. package/dist/gameplay/net/browser/index.js +4 -0
  43. package/dist/gameplay/net/index.d.ts +7 -0
  44. package/dist/gameplay/net/index.js +4 -0
  45. package/dist/gameplay/net/net-connection.d.ts +25 -0
  46. package/dist/gameplay/net/net-connection.js +4 -0
  47. package/dist/gameplay/net/net-session.d.ts +70 -0
  48. package/dist/gameplay/net/net-session.js +4 -0
  49. package/dist/gameplay/net/service/net-actor-role.d.ts +12 -0
  50. package/dist/gameplay/net/service/net-actor-role.js +4 -0
  51. package/dist/gameplay/net/service/net-decorator.d.ts +29 -0
  52. package/dist/gameplay/net/service/net-decorator.js +4 -0
  53. package/dist/gameplay/net/service/net-serializer.d.ts +15 -0
  54. package/dist/gameplay/net/service/net-serializer.js +4 -0
  55. package/dist/gameplay/net/service/net-service.d.ts +171 -0
  56. package/dist/gameplay/net/service/net-service.js +4 -0
  57. package/dist/gameplay/net/service/net-utils.d.ts +8 -0
  58. package/dist/gameplay/net/service/net-utils.js +4 -0
  59. package/dist/gameplay/net/service/replication.d.ts +31 -0
  60. package/dist/gameplay/net/service/replication.js +4 -0
  61. package/dist/gameplay/net/service/rpc-decorator.d.ts +21 -0
  62. package/dist/gameplay/net/service/rpc-decorator.js +4 -0
  63. package/dist/gameplay/net/service/rpc.d.ts +35 -0
  64. package/dist/gameplay/net/service/rpc.js +4 -0
  65. package/dist/gameplay/services/asset-loader.d.ts +3 -2
  66. package/dist/gameplay/services/asset-loader.js +1 -1
  67. package/dist/gameplay/services/physics/abstract-physics-system.d.ts +1 -1
  68. package/dist/gameplay/services/physics/physics-system.d.ts +4 -2
  69. package/dist/gameplay/services/physics/physics-system.js +1 -1
  70. package/dist/gameplay/services/world.d.ts +13 -2
  71. package/dist/gameplay/services/world.js +1 -1
  72. package/dist/rendering/color-pass.js +1 -1
  73. package/dist/rendering.d.ts +2 -0
  74. package/dist/rendering.js +1 -1
  75. package/dist/scene/asset-resource-loader.js +1 -1
  76. package/dist/scene/batched-mesh-2.d.ts +9 -0
  77. package/dist/scene/batched-mesh-2.js +1 -1
  78. package/dist/scene/bootstrap.d.ts +2 -0
  79. package/dist/scene/bootstrap.js +1 -1
  80. package/dist/scene/custom-param-runtime-types.js +1 -1
  81. package/dist/scene/landscape/landscape-manager.d.ts +2 -1
  82. package/dist/scene/landscape/landscape-manager.js +1 -1
  83. package/dist/scene/materializer.d.ts +50 -1
  84. package/dist/scene/materializer.js +1 -1
  85. package/dist/scene/model.d.ts +2 -0
  86. package/dist/scene/scatter/painted-scatter-manager.d.ts +45 -0
  87. package/dist/scene/scatter/painted-scatter-manager.js +4 -0
  88. package/dist/scene/scatter/scatter-limits.d.ts +2 -0
  89. package/dist/scene/scatter/scatter-limits.js +4 -0
  90. package/dist/scene/scatter/surface-scatter-manager.js +1 -1
  91. package/dist/scene/storage/storage.d.ts +1 -1
  92. package/dist/scene/storage/storage.js +1 -1
  93. package/dist/shader/builtin/standard-shader.js +1 -1
  94. package/dist/shader/builtin/toon-shader.js +1 -1
  95. package/dist/shader/builtin/unlit-shader.js +1 -1
  96. package/dist/shader/color-layer.js +1 -1
  97. package/dist/shader/graph/compiler.d.ts +7 -4
  98. package/dist/shader/graph/compiler.js +1 -1
  99. package/dist/shader/graph/model.d.ts +1 -1
  100. package/dist/shader/graph/model.js +1 -1
  101. package/dist/shader/graph/parameters.js +1 -1
  102. package/dist/shader/parameter.d.ts +1 -1
  103. package/dist/shader/parameter.js +1 -1
  104. package/dist/shader/sprite-shader.js +1 -1
  105. package/dist/shader-nodes/depth.js +1 -1
  106. package/dist/shader-nodes/scene-sample.js +1 -1
  107. package/dist/test/batched-mesh-2.test.d.ts +2 -0
  108. package/dist/test/batched-mesh-2.test.js +4 -0
  109. package/dist/test/browser-net-session.test.d.ts +2 -0
  110. package/dist/test/browser-net-session.test.js +4 -0
  111. package/dist/test/first-person-camera-component.test.js +1 -1
  112. package/dist/test/net-character-movement.test.d.ts +2 -0
  113. package/dist/test/net-character-movement.test.js +4 -0
  114. package/dist/test/net-property-snapshot.test.d.ts +2 -0
  115. package/dist/test/net-property-snapshot.test.js +4 -0
  116. package/dist/test/painted-scatter-manager.test.d.ts +2 -0
  117. package/dist/test/painted-scatter-manager.test.js +4 -0
  118. package/dist/test/runtime-param-type-inference.test.js +1 -1
  119. package/dist/test/sequence-animation-retiming.test.js +1 -1
  120. package/dist/test/sequence-post-process.test.js +1 -1
  121. package/dist/test/shader-graph.test.js +1 -1
  122. package/dist/test/vfx-random-color-initializer.test.d.ts +2 -0
  123. package/dist/test/vfx-random-color-initializer.test.js +4 -0
  124. package/dist/test/world-prefab-spawn.test.d.ts +2 -0
  125. package/dist/test/world-prefab-spawn.test.js +4 -0
  126. package/dist/utils/three/placeholder-texture.d.ts +3 -0
  127. package/dist/utils/three/placeholder-texture.js +4 -0
  128. package/package.json +10 -2
  129. package/tsconfig.tsbuildinfo +1 -1
@@ -1,4 +1,4 @@
1
- import{__decorate as t,__metadata as o}from"tslib";import i from"@dimforge/rapier3d-compat";import{takeUntil as e}from"rxjs";import*as s from"three";import{ArrowHelper as n,MathUtils as r,Vector3 as a}from"three";import{RootMotionClip as c}from"../../../../../gameplay/animation/root-motion.js";import{ActionInput as h,AxisInput as l,RotationInput as p}from"../../../../../gameplay/input/index.js";import{PhysicsSystem as m,RayTestResult as u}from"../../../../../gameplay/services/physics/physics-system.js";import{CapsuleCollisionShape as d}from"../../../../../scene/collision/collision-shape.js";import{PhysicsBodyType as y}from"../../../../services/physics/physics-system.js";import{ActorComponent as g,Component as f}from"../../../component.js";import{CharacterMovementMode as M}from"./modes.js";import{inject as S}from"../../../../../gameplay/inject.js";import{Parameter as v}from"../../../../../shader/parameter.js";const w=new a,x=new a,A=1/30,b=131070;let I=class extends g{get autoStepMinWidth(){return this.cc.autostepMinWidth()}set autoStepMinWidth(t){this.cc.enableAutostep(this.cc.autostepMaxHeight(),t,this.cc.autostepIncludesDynamicBodies())}get autoStepDynamicObjects(){return this.cc.autostepIncludesDynamicBodies()}set autoStepDynamicObjects(t){this.cc.enableAutostep(this.cc.autostepMaxHeight(),this.cc.autostepMinWidth(),t)}get autoStepMaxHeight(){return this.cc.autostepMaxHeight()}set autoStepMaxHeight(t){this.cc.enableAutostep(t,this.cc.autostepMinWidth(),this.cc.autostepIncludesDynamicBodies())}get snapToGround(){return this.cc.snapToGroundDistance()}set snapToGround(t){this.cc.enableSnapToGround(t)}set offset(t){this.cc.setOffset(t)}get offset(){return this.cc.offset()}set normalNudgeFactor(t){this.cc.setNormalNudgeFactor(t)}get normalNudgeFactor(){return this.cc.normalNudgeFactor()}constructor(){super(),this.directionInput=new l,this.jumpInput=new h,this.sprintInput=new h,this.rotationInput=new p,this.horizontalSpeed=0,this.maxSpeed=8,this.maxSpeedBackwards=8,this.maxSpeedSprint=12,this.jumpVelocity=7,this.fallingMovementControl=.5,this.fallingReorientation=!1,this.gravityOverride=null,this.colliderHeight=2,this.colliderRadius=.5,this.jumpInAir=!1,this.mass=50,this.allowSliding=!0,this.minSlopeSlideAngle=r.degToRad(70),this.maxSlopeClimbAngle=r.degToRad(70),this.applyImpulsesToDynamicBodies=!0,this.normalizedDirection=!0,this.characterCollision=!1,this.allowRootMotionJumpCancel=!1,this.enabled=!0,this.velocity=new a,this.mode=M.walking,this.isSprinting=!1,this.pressedJump=!1,this.rayTestResult=new u,this.physicsSystem=S(m),this.resetRootMotion=!1,this.rootMotionOptions={},this.rotateToMovementDirection=!1,this.smoothRotation=!0,this.rotationSpeed=40,this.maxRotationSpeed=100,this.impulse=new a,this.impulseDamping=2;const t=this.cc=this.physicsSystem.getCharacterController(.1);t.enableSnapToGround(.1),t.enableAutostep(0,.1,!1)}onInit(){const t=this.cc;t.setApplyImpulsesToDynamicBodies(this.applyImpulsesToDynamicBodies),t.setMinSlopeSlideAngle(this.minSlopeSlideAngle),t.setMaxSlopeClimbAngle(this.maxSlopeClimbAngle),t.setCharacterMass(this.mass),t.setSlideEnabled(this.allowSliding),this.physicsSystem.addActor(this.actor,[this.createCollisionShape()],{mass:0,type:y.kinematic,continousCollisionDetection:!1,friction:0,restitution:.5,ignoreForNavMesh:!0}),this.rotationInput.rotation.copy(this.actor.rotation);let o=this.rotationInput.rotation.y;const i=new a,n=new a,h=new a,l=new a,p=new a,m=new a,u=new a;let d=0,g=null;const f=new a,S=new a,v=new a,I=new a,R=new a,z=new a,C=new a,D=this.characterCollision?null:b;let E=this.rotateToMovementDirection;this.physicsSystem.beforeStep.pipe(e(this.disposed)).subscribe(e=>{if(this.checkGrounded(e),!this.enabled)return;if(S.set(0,0,0),null==this.rootMotionAction||this.rootMotionAction.isRunning()||this.clearRootMotionAction(this.rootMotionAction),null!=this.rootMotionAction&&this.rootMotionOptions.cancelWithJump&&this.jumpInput.activated&&(this.isGrounded||this.jumpInAir)){const t=this.rootMotionAction,o=this.rootMotionOptions.onJumpCancel;this.clearRootMotionAction(t),t.stop(),o?.()}if(null!=this.rootMotionAction){if(this.rootMotionAction.getClip()instanceof c){const t=this.rootMotionInterpolant;this.resetRootMotion&&(f.fromArray(t.evaluate(0)),this.resetRootMotion=!1),z.fromArray(t.evaluate(this.rootMotionAction.time)),S.subVectors(z,f),f.copy(z);(this.rootMotionRootBone??this.rootMotionAction.getRoot()).getWorldScale(R),S.multiply(R)}}e>A&&(e=A);const y=null!=this.rootMotionAction&&this.rootMotionAction.enabled,b=y&&0!==S.lengthSq();this.pressedJump=!y&&this.jumpInput.activated,this.isSprinting=!y&&this.sprintInput.activated;const H=E!==this.rotateToMovementDirection;let B=r.euclideanModulo(this.rotationInput.rotation.y-o+Math.PI,2*Math.PI)-Math.PI;H&&(this.actor.object.quaternion.setFromEuler(F.set(0,this.rotationInput.rotation.y,0)),E?this.actor.object.quaternion.setFromEuler(F.set(0,this.rotationInput.rotation.y,0)):(B=0,o=this.rotationInput.rotation.y),E=this.rotateToMovementDirection),h.copy(this.actor.position),l.set(-this.directionInput.vector.x,0,this.directionInput.vector.y).normalize();const N=!this.rotateToMovementDirection&&l.z<0?this.maxSpeedBackwards:(this.isSprinting?this.maxSpeedSprint:this.maxSpeed)*(this.normalizedDirection?1:Math.min(1,this.directionInput.vector.length()));if(u.set(0,0,0),y)o=this.rotationInput.rotation.y;else if(this.rotateToMovementDirection&&!y){if(l.lengthSq()>0&&this.mode!=M.falling){const t=this.smoothRotation,i=F.setFromQuaternion(this.actor.object.quaternion,"YXZ").y,s=Math.atan2(l.x,l.z),n=.99*this.rotationInput.rotation.y+s;if(t){r.clamp(.5*l.dot(p)+.5,.001,1);const t=r.euclideanModulo(n-i+Math.PI,2*Math.PI)-Math.PI;let o=r.clamp(t*this.rotationSpeed*e,-this.maxRotationSpeed*e,this.maxRotationSpeed*e);Math.abs(o)>Math.abs(t)&&(o=t),this.actor.object.quaternion.setFromEuler(F.set(0,i+o,0))}else this.actor.object.quaternion.setFromEuler(F.set(0,n,0));p.lerp(l,e*this.rotationSpeed),o+=B,u.copy(this.actor.object.getWorldDirection(k).normalize())}}else b||(o+=B,this.actor.object.quaternion.multiply(q.setFromEuler(F.set(0,B,0))),l.lengthSq()>0&&u.copy(l).applyQuaternion(this.actor.object.quaternion).normalize());if(C.set(0,0,0),this.rayTestResult.hasHit&&null!=this.rayTestResult.actor&&this.physicsSystem.getLinearVelocity(this.rayTestResult.actor,C),this.mode===M.walking?(0!==u.lengthSq()?(d=Math.min(N,d),d=r.lerp(d,N,4*e)):d=0,m.copy(u).multiplyScalar(d),this.pressedJump&&(this.mode=M.falling,this.velocity.copy(m),this.velocity.y=this.jumpVelocity),m.y=e*this.getEffectiveGravity(),m.add(C)):this.mode===M.falling&&(this.pressedJump&&this.jumpInAir&&(this.mode=M.falling,this.velocity.copy(m),this.velocity.y=this.jumpVelocity),this.velocity.y+=e*this.getEffectiveGravity(),m.copy(this.velocity),m.addScaledVector(u,this.fallingMovementControl),this.fallingReorientation&&m.applyAxisAngle(new a(0,1,0),B)),b&&(v.copy(S).applyQuaternion(this.actor.quaternion),I.copy(v).divideScalar(e),this.mode===M.walking?(m.x=I.x+C.x,m.z=I.z+C.z):(m.x=I.x,m.z=I.z),l.lengthSq()>0)){const t=Math.sqrt(I.x*I.x+I.z*I.z);t>.4&&(d=t)}if(this.impulse.lengthSq()>.1){const t=Math.min(1,this.impulse.length()/5);m.x=r.lerp(m.x,this.impulse.x,t),m.z=r.lerp(m.z,this.impulse.z,t),m.y+=this.impulse.y;const o=Math.exp(-this.impulseDamping*e);this.impulse.x*=o,this.impulse.y>0?this.impulse.y+=e*this.getEffectiveGravity():this.impulse.y*=o,this.impulse.z*=o}else this.impulse.set(0,0,0);if(n.copy(m).normalize(),i.copy(m),m.length()>0||!this.isGrounded){if(w.copy(m).multiplyScalar(e),this.isGrounded&&this.mode===M.walking&&(this.rayTestResult.distance>t.offset()||(w.y=Math.max(0,C.y*e)),this.physicsSystem.getActorComputedMovement(this.actor,t,w,D),t.computedCollision(0,G),null!=G&&null!=G.normal1)){const o=(new s.Vector3).copy(G.normal1);Math.acos(o.dot(T))>t.maxSlopeClimbAngle()&&(w.y=.016*this.getEffectiveGravity()*.5)}x.copy(this.physicsSystem.getActorComputedMovement(this.actor,t,w,D))}else x.set(0,0,0);this.physicsSystem.setNextKinematicTranslation(this.actor,x);let O=function(t){if(t.numComputedCollisions()>0){const o=t.computedCollision(0);j.x=o.normal2.x,j.y=o.normal2.y,j.z=o.normal2.z;const i=j.angleTo(T);j.x=o.normal1.x,j.y=o.normal1.y,j.z=o.normal1.z;const e=j.angleTo(T);return!(i<100)&&e>t.minSlopeSlideAngle()}return!1}(t);this.isGrounded&&!O||this.mode!==M.falling&&(null==g?g=performance.now():performance.now()-g>100&&(this.mode=M.falling,this.velocity.copy(i))),this.isGrounded&&this.velocity.y<=0&&(this.mode,M.falling,this.mode=M.walking,this.velocity.y=0,g=null),this.mode,M.walking,this.horizontalSpeed=d})}applyImpulse(t){this.impulse.add(t)}debugDirection(){const t=new n(w,this.actor.position,1,65280);this.actor.object.parent.add(t),setTimeout(()=>{t.removeFromParent()},30);const o=new n(x,this.actor.position,1,16711680);this.actor.object.parent.add(o),setTimeout(()=>{o.removeFromParent()},30)}setRootMotionAction(t,o={}){const i=t?.getClip();if(i instanceof c){this.rootMotionAction=t,this.rootMotionOptions=o,this.resetRootMotion=!0;const e=[];this.rootMotionInterpolant=i.motionTrack.InterpolantFactoryMethodSmooth(e);const n=s.PropertyBinding.parseTrackName(i.motionTrack.name);this.rootMotionRootBone=this.actor.object.getObjectByName(n.nodeName)}}clearRootMotionAction(t){null!=t&&this.rootMotionAction!==t||(this.rootMotionAction=null,this.rootMotionOptions={},this.resetRootMotion=!1)}getWallDirection(t,o){const i=t.clone().negate().cross(T);return i.dot(o)<0?i.negate():i}moveTo(t){this.actor.position.copy(t),this.physicsSystem.updateActorTransform(this.actor)}getEffectiveGravity(){return this.gravityOverride??this.physicsSystem.getGravity().y}checkGrounded(t){this.colliderHeight,this.colliderRadius;D.y=-.05,this.physicsSystem.rayTest(R.addVectors(this.actor.position,C.set(0,this.offset,0)),z.addVectors(this.actor.position,D),this.rayTestResult,{excludeActor:this.actor,excludeTriggers:!0})}get isGrounded(){return this.rayTestResult.hasHit||this.cc.computedGrounded()}createCollisionShape(){const t=new d(this.colliderHeight,this.colliderRadius);return t.offset.y=this.colliderRadius+this.colliderHeight/2+this.offset,t.collisionGroup=b,t}step(t){}performMovement(t){}arrowHelper(t,o,i){const e=new n(t.clone().normalize(),o,1,i);this.actor.object.parent.add(e),setTimeout(()=>{e.removeFromParent()},30)}};t([v(),o("design:type",Number)],I.prototype,"colliderHeight",void 0),t([v(),o("design:type",Number)],I.prototype,"colliderRadius",void 0),I=t([f({inEditor:!1}),o("design:paramtypes",[])],I);export{I as CharacterMovementComponent};const T=new a(0,1,0),j=new a;const R=new a,z=new a,C=new a(0,1,0),D=new a(0,-.1,0),G=(new a(0,-1,0),new i.CharacterCollision),q=new s.Quaternion,F=new s.Euler,k=new s.Vector3;/*
1
+ import{__decorate as t,__metadata as e}from"tslib";import i from"@dimforge/rapier3d-simd-compat";import{takeUntil as o}from"rxjs";import*as s from"three";import{ArrowHelper as n,MathUtils as r,Quaternion as a,Vector3 as h}from"three";import{RootMotionClip as c}from"../../../../animation/root-motion.js";import{inject as l}from"../../../../inject.js";import{ActionInput as m,AxisInput as p,RotationInput as u}from"../../../../input/index.js";import{NetRole as d}from"../../../../net/service/net-actor-role.js";import{RunOnClient as v,RunOnNotOwner as y,RunOnServer as S}from"../../../../net/service/rpc-decorator.js";import{NetService as M}from"../../../../net/service/net-service.js";import{PhysicsSystem as g,RayTestResult as f}from"../../../../services/physics/physics-system.js";import{CapsuleCollisionShape as x}from"../../../../../scene/collision/collision-shape.js";import{Parameter as T}from"../../../../../shader/parameter.js";import{PhysicsBodyType as w}from"../../../../services/physics/physics-system.js";import{ActorComponent as A,Component as R}from"../../../component.js";import{CharacterMovementMode as C}from"./modes.js";import{DEFAULT_MAX_CLIENT_TIME_AHEAD as D,DEFAULT_LARGE_CORRECTION_THRESHOLD as q,DEFAULT_MAX_COMBINED_MOVE_DELTA_TIME as b,DEFAULT_MAX_MOVE_DELTA_TIME as k,DEFAULT_MAX_MOVES_PER_PACKET as P,DEFAULT_MAX_REPLAYED_MOVES as z,DEFAULT_MAX_SERVER_MOVES_PER_TICK as I,DEFAULT_MAX_SAVED_MOVES as j,DEFAULT_MAX_SERVER_MOVE_DELTA_TIME_SCALAR as Y,DEFAULT_MAX_SERVER_MOVE_TIME_BUDGET as G,DEFAULT_MAX_SUBSTEP_DELTA_TIME as F,DEFAULT_MOVE_SEND_INTERVAL as O,DEFAULT_SIMULATED_INTERPOLATION_DELAY as V,DEFAULT_SIMULATED_STATE_INTERVAL as X,DEFAULT_SMALL_CORRECTION_TOLERANCE as B,DEFAULT_TELEPORT_SNAP_THRESHOLD as Z,MOVE_FLAG_JUMP as N,MOVE_FLAG_ROOT_MOTION as E,MOVE_FLAG_SPRINT as L,MOVE_FLAG_SPRINT_START as U,NetCharacterProxySmoother as H,NetCharacterSavedMoveBuffer as $,accrueNetCharacterServerMoveTime as Q,createNetCharacterMovementSnapshot as W,createNetCharacterServerMoveTimingState as J,consumeNetCharacterServerMoveTime as K,decodeNetCharacterMoveBatch as _,decodeNetCharacterOwnerAck as tt,decodeNetCharacterOwnerCorrection as et,decodeNetCharacterSimulatedState as it,encodeNetCharacterMoveBatch as ot,encodeNetCharacterOwnerAck as st,encodeNetCharacterOwnerCorrection as nt,encodeNetCharacterSimulatedState as rt,validateNetCharacterMove as at}from"./net-character-movement-protocol.js";import{NetMode as ht}from"../../../../net/net-session.js";export*from"./net-character-movement-protocol.js";const ct=131070,lt=new h(0,1,0),mt=new h,pt=new h,ut=new h,dt=new h,vt=new h,yt=new h,St=new h,Mt=new h,gt=new h,ft=new h,xt=new h,Tt=new h,wt=new h,At=new h,Rt=new h(0,1,0),Ct=new h(0,-.05,0),Dt=new h,qt=new a,bt=new s.Euler,kt=new h,Pt=new h,zt=new h,It=new i.CharacterCollision;let jt=class extends A{get autoStepMinWidth(){return this.cc.autostepMinWidth()}set autoStepMinWidth(t){this.cc.enableAutostep(this.cc.autostepMaxHeight(),t,this.cc.autostepIncludesDynamicBodies())}get autoStepDynamicObjects(){return this.cc.autostepIncludesDynamicBodies()}set autoStepDynamicObjects(t){this.cc.enableAutostep(this.cc.autostepMaxHeight(),this.cc.autostepMinWidth(),t)}get autoStepMaxHeight(){return this.cc.autostepMaxHeight()}set autoStepMaxHeight(t){this.cc.enableAutostep(t,this.cc.autostepMinWidth(),this.cc.autostepIncludesDynamicBodies())}get snapToGround(){return this.cc.snapToGroundDistance()}set snapToGround(t){this.cc.enableSnapToGround(t)}set offset(t){this.cc.setOffset(t)}get offset(){return this.cc.offset()}set normalNudgeFactor(t){this.cc.setNormalNudgeFactor(t)}get normalNudgeFactor(){return this.cc.normalNudgeFactor()}constructor(){super(),this.isDefaultCharacterMovementComponent=!0,this.directionInput=new p,this.jumpInput=new m,this.sprintInput=new m,this.rotationInput=new u,this.horizontalSpeed=0,this.maxSpeed=8,this.maxSpeedBackwards=8,this.maxSpeedSprint=12,this.sprintStartBoostSpeed=0,this.sprintStartBoostDamping=6,this.jumpVelocity=7,this.fallingMovementControl=.5,this.fallingReorientation=!1,this.groundAccelerationRate=4,this.gravityOverride=null,this.colliderHeight=2,this.colliderRadius=.5,this.jumpInAir=!1,this.mass=50,this.allowSliding=!0,this.minSlopeSlideAngle=r.degToRad(70),this.maxSlopeClimbAngle=r.degToRad(70),this.applyImpulsesToDynamicBodies=!0,this.normalizedDirection=!0,this.characterCollision=!1,this.allowRootMotionJumpCancel=!1,this.enabled=!0,this.rotateToMovementDirection=!1,this.smoothRotation=!0,this.rotationSpeed=40,this.maxRotationSpeed=100,this.impulseDamping=2,this.moveSendInterval=O,this.simulatedStateInterval=X,this.maxSavedMoves=j,this.maxReplayedMoves=z,this.maxServerMovesPerTick=I,this.maxMovesPerPacket=P,this.maxMoveDeltaTime=k,this.maxCombinedMoveDeltaTime=b,this.maxServerMoveDeltaTimeScalar=Y,this.maxClientTimeAhead=D,this.maxServerMoveTimeBudget=G,this.maxSubstepDeltaTime=F,this.fallGraceTime=.1,this.correctionToleranceSq=B*B,this.largeCorrectionThreshold=q,this.teleportSnapThreshold=Z,this.listenServerSmoothing=!0,this.listenServerSmoothLocationTime=.04,this.listenServerMaxSmoothUpdateDistance=1,this.listenServerNoSmoothUpdateDistance=2.5,this.debugCorrections=!0,this.velocity=new h,this.visualSmoothingOffset=new h,this.mode=C.walking,this.isSprinting=!1,this.pressedJump=!1,this.rayTestResult=new f,this.physicsSystem=l(g),this.netService=l(M),this.state={sequence:0,position:new h,velocity:new h,yaw:0,lookYaw:0,mode:C.walking,grounded:!1,currentSpeed:0,fallGraceTime:0,prevInputDirection:new h,prevRotateToMovementDirection:!1},this.movementModes=new Map,this.savedMoves=new $(j),this.serverMoveTiming=J(),this.serverMoveQueue=[],this.inputMoveScratch={sequence:0,clientTime:0,dt:0,inputX:0,inputY:0,yaw:0,flags:0,clientX:0,clientY:0,clientZ:0,rootMotionX:0,rootMotionY:0,rootMotionZ:0},this.authoritativeMoveScratch={sequence:0,clientTime:0,dt:0,inputX:0,inputY:0,yaw:0,flags:0,clientX:0,clientY:0,clientZ:0,rootMotionX:0,rootMotionY:0,rootMotionZ:0},this.movementModeContext={component:this,state:this.state,move:this.inputMoveScratch,deltaTime:0,rotatedDirection:pt,platformVelocity:dt,outVelocity:ut,rootMotionActive:!1,startedSprinting:!1},this.proxySmoother=new H(V,Z),this.proxySample=W(),this.pendingSnapshot=W(),this.impulse=new h,this.prevRootMotionPos=new h,this.rootMotionOptions={},this.resetRootMotion=!1,this.nextMoveSequence=0,this.clientMoveTime=0,this.lastSentClientMoveTime=0,this.moveSendAccumulator=0,this.simulatedStateAccumulator=0,this.proxyTime=0,this.lastServerProcessedSequence=0,this.lastServerReceivedSequence=0,this.lastAutonomousMoveFlags=0,this.previousSprintInput=!1,this.initialized=!1,this.cc=this.physicsSystem.getCharacterController(.1),this.cc.enableSnapToGround(.1),this.cc.enableAutostep(0,.1,!1),this.registerMovementMode(Yt),this.registerMovementMode(Gt)}onInit(){this.configureCharacterController(),this.physicsSystem.addActor(this.actor,[this.createCollisionShape()],{mass:0,type:w.kinematic,continousCollisionDetection:!1,friction:0,restitution:.5,ignoreForNavMesh:!0}),this.rotationInput.rotation.copy(this.actor.rotation),this.initializeStateFromActor(),this.initialized=!0,this.physicsSystem.beforeStep.pipe(o(this.disposed)).subscribe(t=>this.tick(t))}onLateUpdate(t){this.updateVisualSmoothing(t)}registerMovementMode(t){this.movementModes.set(t.mode,t)}applyImpulse(t){this.impulse.add(t)}getEffectiveGravity(){return this.gravityOverride??this.physicsSystem.getGravity().y}get isGrounded(){return this.rayTestResult.hasHit||this.cc.computedGrounded()}setRootMotionAction(t,e={}){const i=t?.getClip();if(i instanceof c){this.rootMotionAction=t,this.rootMotionOptions=e,this.resetRootMotion=!0;const o=[];this.rootMotionInterpolant=i.motionTrack.InterpolantFactoryMethodSmooth(o);const n=s.PropertyBinding.parseTrackName(i.motionTrack.name);this.rootMotionRootBone=this.actor.object.getObjectByName(n.nodeName)}}serverMove(t){const e=_(t);if(e.ok)for(const t of e.value.moves)at(t,this.lastServerReceivedSequence,this.maxMoveDeltaTime)&&(this.lastServerReceivedSequence=t.sequence,this.serverMoveQueue.push(t))}clientMoveAck(t){const e=tt(t);e.ok&&this.actor.netRole===d.autonomousProxy&&(this.savedMoves.ack(e.value.sequence),this.sprintPolicy?.ack?.(e.value.sequence,!1))}clientMoveCorrection(t){const e=et(t);e.ok&&this.actor.netRole===d.autonomousProxy&&(this.debugCorrections&&(null==this.correctionDebug&&(this.correctionDebug=new Vt(Bt(this.actor.object))),this.correctionDebug.update(this.state.position,e.value.snapshot)),this.applyCorrection(e.value.snapshot))}simulatedState(t){const e=it(t);e.ok&&this.actor.netRole===d.simulatedProxy&&this.proxySmoother.push(e.value,this.proxyTime)}tick(t){if(!this.initialized)return;t=Math.min(.1,t);const e=this.actor.netRole,i=this.netService.mode;e!==d.simulatedProxy?this.enabled&&(e!==d.autonomousProxy?this.isRemoteControlledAuthority(i,e)?this.tickRemoteAuthority(t):this.tickAuthority(t,i):this.tickAutonomousProxy(t)):this.tickSimulatedProxy(t)}tickAutonomousProxy(t){const e=this.state.mode,i=this.lastAutonomousMoveFlags,o=this.createMoveFromInput(t,++this.nextMoveSequence,{quantizeClientTime:!0});this.performMove(o,Zt);const s=this.state.mode!==e||o.flags!==i;this.lastAutonomousMoveFlags=o.flags,this.savedMoves.capacity=this.maxSavedMoves,this.savedMoves.maxCombinedDeltaTime=Math.min(this.maxCombinedMoveDeltaTime,this.maxMoveDeltaTime),this.savedMoves.push(o),this.sendSavedMoves(t,s)}tickAuthority(t,e){const i=this.createMoveFromInput(t,++this.nextMoveSequence);this.performMove(i,Zt),e!==ht.none&&this.sendSimulatedState(t,!1)}tickRemoteAuthority(t){Q(this.serverMoveTiming,t,this.maxServerMoveTimeBudget);let e=!1;const i=Number.isFinite(this.maxServerMovesPerTick)?Math.max(1,Math.floor(this.maxServerMovesPerTick)):this.serverMoveQueue.length,o=Math.min(this.serverMoveQueue.length,i),s=Pt.copy(this.actor.position);let n=!1;for(let t=0;t<o;t++){const t=this.serverMoveQueue.shift();if(null==t)break;if(!at(t,this.lastServerProcessedSequence,this.maxMoveDeltaTime)){console.log("Net: Invalid move",t),this.sendOwnerCorrection(!0),e=!0;continue}const i=K(this.serverMoveTiming,t,{maxMoveDeltaTime:this.maxMoveDeltaTime,maxServerMoveDeltaTimeScalar:this.maxServerMoveDeltaTimeScalar,maxClientTimeAhead:this.maxClientTimeAhead});if(i<0){this.sendOwnerCorrection(!0),e=!0;continue}const o=Ft(t,this.authoritativeMoveScratch);o.dt=i,o.rootMotionX=0,o.rootMotionY=0,o.rootMotionZ=0,o.flags&=~E,this.performMove(o,{immediate:!0,savedRootMotion:!1}),n=!0,this.lastServerProcessedSequence=o.sequence;const s=Ot(this.state,t);if(s>this.correctionToleranceSq){console.log(`Net server: Correction error: ${Math.sqrt(s)}`);const o=this.state.position.x-t.clientX,n=this.state.position.y-t.clientY,r=this.state.position.z-t.clientZ;console.log(`diff x: ${o}, y: ${n}, z: ${r}`),console.log({sequence:t.sequence,moveDt:t.dt,serverMoveDeltaTime:i,flags:t.flags,mode:this.state.mode,grounded:this.state.grounded,fallGraceTime:this.state.fallGraceTime}),this.sendOwnerCorrection(s>this.largeCorrectionThreshold*this.largeCorrectionThreshold),e=!0}}0===this.lastServerProcessedSequence||e||(this.sprintPolicy?.ack?.(this.lastServerProcessedSequence,!1),this.clientMoveAck(st(this.lastServerProcessedSequence))),n&&this.accumulateListenServerVisualSmoothing(s,this.actor.position),this.sendSimulatedState(t,!1)}tickSimulatedProxy(t){this.proxyTime+=t,this.proxySmoother.sample(this.proxyTime,this.proxySample)&&this.applySnapshot(this.proxySample,!0)}accumulateListenServerVisualSmoothing(t,e){if(!this.shouldSmoothListenServerRemoteAuthority())return void this.visualSmoothingOffset.set(0,0,0);zt.subVectors(t,e);const i=zt.lengthSq();i>1e-8&&(i>this.listenServerNoSmoothUpdateDistance*this.listenServerNoSmoothUpdateDistance?this.visualSmoothingOffset.set(0,0,0):(i>this.listenServerMaxSmoothUpdateDistance*this.listenServerMaxSmoothUpdateDistance&&zt.setLength(this.listenServerMaxSmoothUpdateDistance),this.visualSmoothingOffset.add(zt)))}updateVisualSmoothing(t){if(this.visualSmoothingOffset.lengthSq()<=1e-8)return void this.visualSmoothingOffset.set(0,0,0);if(!this.shouldSmoothListenServerRemoteAuthority())return void this.visualSmoothingOffset.set(0,0,0);const e=Math.max(.001,this.listenServerSmoothLocationTime);t<e?this.visualSmoothingOffset.multiplyScalar(1-t/e):this.visualSmoothingOffset.set(0,0,0),this.visualSmoothingOffset.lengthSq()<=1e-4&&this.visualSmoothingOffset.set(0,0,0)}shouldSmoothListenServerRemoteAuthority(){return this.listenServerSmoothing&&this.actor.netRole===d.authority&&this.netService.isServer&&!this.netService.isDedicatedServer&&this.isRemoteControlledAuthority()}createMoveFromInput(t,e,i={}){const o=r.clamp(t,.001,this.maxMoveDeltaTime);this.clientMoveTime+=o;let s=this.clientMoveTime,n=o;!0===i.quantizeClientTime&&(s=Math.max(this.lastSentClientMoveTime+.001,Math.round(1e3*this.clientMoveTime)/1e3),n=r.clamp(s-this.lastSentClientMoveTime,.001,this.maxMoveDeltaTime),this.lastSentClientMoveTime=s),this.sampleRootMotion(St);const a=this.sprintInput.activated,h=a&&!this.previousSprintInput;this.previousSprintInput=a;const c=(this.jumpInput.activated?N:0)|(a?L:0)|(h?U:0)|(St.lengthSq()>0?E:0),l=function(t,e){e.set(t.x,0,t.y),e.lengthSq()>1&&e.normalize();return e}(this.directionInput.vector,kt),m=this.inputMoveScratch;return m.sequence=e>>>0,m.clientTime=s,m.dt=n,m.inputX=l.x,m.inputY=l.z,m.yaw=this.rotationInput.rotation.y,m.flags=c,m.clientX=this.state.position.x,m.clientY=this.state.position.y,m.clientZ=this.state.position.z,m.rootMotionX=St.x,m.rootMotionY=St.y,m.rootMotionZ=St.z,m}performMove(t,e){const i=r.clamp(t.dt,.001,this.maxMoveDeltaTime),o=Math.max(1,Math.ceil(i/this.maxSubstepDeltaTime));this.sprintPolicy?.update?.(i,t.sequence,0!==(t.flags&L)),Tt.set(e.savedRootMotion?t.rootMotionX:0,e.savedRootMotion?t.rootMotionY:0,e.savedRootMotion?t.rootMotionZ:0),e.savedRootMotion||this.sampleRootMotion(Tt);let s=i;const n=i/o;for(let r=0;r<o;r++){const o=i>0?n/i:1;this.performSubstep(t,Math.min(n,s),Tt,o,e.immediate,0===r),s-=n}t.clientX=this.state.position.x,t.clientY=this.state.position.y,t.clientZ=this.state.position.z,t.flags=Tt.lengthSq()>0?t.flags|E:t.flags&~E,this.state.sequence=t.sequence,this.syncPublicState()}performSubstep(t,e,i,o,s,n){if(e<.001)return;this.checkGrounded(this.state.position),this.state.grounded=this.isGrounded;const r=null!=this.rootMotionAction&&this.rootMotionAction.enabled,a=i.lengthSq()>0,h=!r&&0!==(t.flags&N),c=r||a;this.pressedJump=h,this.isSprinting=!1,this.updateRotation(t,e,r,a),this.resolvePlatformVelocity(dt);const l=this.movementModeContext,m=this.movementModes.get(this.state.mode);if(null!=m){l.move=t,l.deltaTime=e,l.rootMotionActive=c,l.startedSprinting=n&&!c&&0!==(t.flags&U);const i=m.update(l);"number"==typeof i&&(this.state.mode=i)}else ut.set(0,0,0);if(a){Mt.copy(i).multiplyScalar(o).applyQuaternion(this.actor.quaternion),gt.copy(Mt).divideScalar(e),this.state.mode===C.walking?(ut.x=gt.x+dt.x,ut.z=gt.z+dt.z):(ut.x=gt.x,ut.z=gt.z);const t=Math.sqrt(gt.x*gt.x+gt.z*gt.z);t>.4&&(this.state.currentSpeed=t)}this.applyImpulseToVelocity(ut,e),this.state.mode===C.walking&&this.state.velocity.copy(ut),this.applyMovement(ut,e,s),this.checkGrounded(this.state.position),this.state.grounded=this.isGrounded,this.updateModeAfterMove(ut,e)}updateRotation(t,e,i,o){mt.set(-t.inputX,0,t.inputY),mt.lengthSq()>1&&mt.normalize();const s=this.state.prevRotateToMovementDirection!==this.rotateToMovementDirection;let n=r.euclideanModulo(t.yaw-this.state.lookYaw+Math.PI,2*Math.PI)-Math.PI;if(s&&(this.actor.object.quaternion.setFromEuler(bt.set(0,t.yaw,0)),this.state.prevRotateToMovementDirection||(n=0,this.state.lookYaw=t.yaw),this.state.prevRotateToMovementDirection=this.rotateToMovementDirection),pt.set(0,0,0),i)this.state.lookYaw=t.yaw;else if(this.rotateToMovementDirection){if(mt.lengthSq()>0&&this.state.mode!==C.falling){const i=bt.setFromQuaternion(this.actor.object.quaternion,"YXZ").y,o=Math.atan2(mt.x,mt.z),s=.99*t.yaw+o;if(this.smoothRotation){const t=r.euclideanModulo(s-i+Math.PI,2*Math.PI)-Math.PI;let o=r.clamp(t*this.rotationSpeed*e,-this.maxRotationSpeed*e,this.maxRotationSpeed*e);Math.abs(o)>Math.abs(t)&&(o=t),this.actor.object.quaternion.setFromEuler(bt.set(0,i+o,0))}else this.actor.object.quaternion.setFromEuler(bt.set(0,s,0));this.state.prevInputDirection.lerp(mt,e*this.rotationSpeed),this.state.lookYaw+=n,pt.copy(this.actor.object.getWorldDirection(kt).normalize())}}else o||(this.state.lookYaw+=n,this.actor.object.quaternion.multiply(qt.setFromEuler(bt.set(0,n,0))),mt.lengthSq()>0&&pt.copy(mt).applyQuaternion(this.actor.object.quaternion).normalize())}applyMovement(t,e,i){if(t.lengthSq()>0||!this.state.grounded){if(vt.copy(t).multiplyScalar(e),this.state.grounded&&this.state.mode===C.walking&&(this.rayTestResult.distance<=this.cc.offset()&&(vt.y=Math.max(0,dt.y*e)),this.physicsSystem.getActorComputedMovement(this.actor,this.cc,vt,this.getCollisionGroup()),this.cc.computedCollision(0,It),null!=It.normal1)){const t=kt.copy(It.normal1);Math.acos(r.clamp(t.dot(lt),-1,1))>this.cc.maxSlopeClimbAngle()&&(vt.y=.016*this.getEffectiveGravity()*.5)}yt.copy(this.physicsSystem.getActorComputedMovement(this.actor,this.cc,vt,this.getCollisionGroup()))}else yt.set(0,0,0);this.state.position.add(yt),i?(this.actor.position.copy(this.state.position),this.physicsSystem.updateActorTransform(this.actor),this.physicsSystem.flushModifiedBodyPositionsToColliders()):this.physicsSystem.setNextKinematicPosition(this.actor,this.state.position)}updateModeAfterMove(t,e){const i=function(t){if(0===t.numComputedCollisions())return!1;const e=t.computedCollision(0);Dt.set(e.normal2.x,e.normal2.y,e.normal2.z);const i=Dt.angleTo(lt);Dt.set(e.normal1.x,e.normal1.y,e.normal1.z);const o=Dt.angleTo(lt);if(i<100)return!1;return o>t.minSlopeSlideAngle()}(this.cc);!this.state.grounded||i?this.state.mode!==C.falling&&(this.state.fallGraceTime+=e,this.state.fallGraceTime>this.fallGraceTime+1e-6&&(this.state.mode=C.falling,this.state.velocity.copy(t))):this.state.velocity.y<=0&&(this.state.mode=C.walking,this.state.velocity.y=0,this.state.fallGraceTime=0)}applyImpulseToVelocity(t,e){if(this.impulse.lengthSq()<=.1)return void this.impulse.set(0,0,0);const i=Math.min(1,this.impulse.length()/5);t.x=r.lerp(t.x,this.impulse.x,i),t.z=r.lerp(t.z,this.impulse.z,i),t.y+=this.impulse.y;const o=Math.exp(-this.impulseDamping*e);this.impulse.x*=o,this.impulse.y>0?this.impulse.y+=e*this.getEffectiveGravity():this.impulse.y*=o,this.impulse.z*=o}sendSavedMoves(t,e=!1){if(this.moveSendAccumulator+=t,!e&&this.moveSendAccumulator<this.moveSendInterval)return;this.moveSendAccumulator=0;const i=this.savedMoves.getMovesForSend(this.maxMovesPerPacket);0!==i.length&&this.serverMove(ot(i))}sendOwnerCorrection(t){const e=this.toSnapshot(this.pendingSnapshot);t&&(e.horizontalSpeed=this.horizontalSpeed),this.sprintPolicy?.ack?.(e.sequence,!0),this.clientMoveCorrection(nt(e))}sendSimulatedState(t,e){this.simulatedStateAccumulator+=t,!e&&this.simulatedStateAccumulator<this.simulatedStateInterval||(this.simulatedStateAccumulator=0,this.simulatedState(rt(this.toSnapshot(this.pendingSnapshot))))}applyCorrection(t){this.sprintPolicy?.restore?.(t.sequence),this.savedMoves.ack(t.sequence),this.sprintPolicy?.ack?.(t.sequence,!0),this.applySnapshot(t,!0),this.savedMoves.replayAfter(t.sequence,t=>(this.performMove(t,{immediate:!0,savedRootMotion:!0}),null),this.maxReplayedMoves)}applySnapshot(t,e){this.state.sequence=t.sequence,this.state.position.set(t.x,t.y,t.z),this.state.velocity.set(t.velocityX,t.velocityY,t.velocityZ),this.state.yaw=t.yaw,this.state.lookYaw=t.yaw,this.state.mode=t.mode,this.state.currentSpeed=t.horizontalSpeed,this.state.fallGraceTime=0,this.actor.position.copy(this.state.position),this.actor.object.quaternion.setFromEuler(bt.set(0,t.yaw,0)),e&&(this.physicsSystem.updateActorTransform(this.actor),this.physicsSystem.flushModifiedBodyPositionsToColliders()),this.checkGrounded(this.state.position),this.state.grounded=this.isGrounded,this.syncPublicState()}toSnapshot(t){return t.sequence=this.state.sequence,t.x=this.state.position.x,t.y=this.state.position.y,t.z=this.state.position.z,t.velocityX=this.state.velocity.x,t.velocityY=this.state.velocity.y,t.velocityZ=this.state.velocity.z,t.yaw=bt.setFromQuaternion(this.actor.object.quaternion,"YXZ").y,t.mode=this.state.mode,t.horizontalSpeed=this.state.currentSpeed,t}syncPublicState(){this.velocity.copy(this.state.velocity),this.mode=this.state.mode,this.horizontalSpeed=this.state.currentSpeed}sampleRootMotion(t){if(t.set(0,0,0),null==this.rootMotionAction||this.rootMotionAction.isRunning()||this.clearRootMotionAction(this.rootMotionAction),null!=this.rootMotionAction&&this.rootMotionOptions.cancelWithJump&&this.jumpInput.activated&&(this.isGrounded||this.jumpInAir)){const e=this.rootMotionAction,i=this.rootMotionOptions.onJumpCancel;return this.clearRootMotionAction(e),e.stop(),i?.(),t}if(null==this.rootMotionAction)return t;if(!(this.rootMotionAction.getClip()instanceof c))return t;const e=this.rootMotionInterpolant;this.resetRootMotion&&(this.prevRootMotionPos.fromArray(e.evaluate(0)),this.resetRootMotion=!1),xt.fromArray(e.evaluate(this.rootMotionAction.time)),t.subVectors(xt,this.prevRootMotionPos),this.prevRootMotionPos.copy(xt);return(this.rootMotionRootBone??this.rootMotionAction.getRoot()).getWorldScale(ft),t.multiply(ft),t}clearRootMotionAction(t){null!=t&&this.rootMotionAction!==t||(this.rootMotionAction=null,this.rootMotionOptions={},this.resetRootMotion=!1)}isRemoteControlledAuthority(t=this.netService.mode,e=this.actor.netRole){if(t===ht.none||e!==d.authority||t>=ht.client)return!1;return null!=this.netService.resolveActorConnection(this.actor)&&!this.netService.isLocalOwner(this.actor)}configureCharacterController(){const t=this.cc;t.setApplyImpulsesToDynamicBodies(this.applyImpulsesToDynamicBodies),t.setMinSlopeSlideAngle(this.minSlopeSlideAngle),t.setMaxSlopeClimbAngle(this.maxSlopeClimbAngle),t.setCharacterMass(this.mass),t.setSlideEnabled(this.allowSliding)}initializeStateFromActor(){this.state.position.copy(this.actor.position),this.state.velocity.set(0,0,0),this.state.yaw=this.actor.rotation.y,this.state.lookYaw=this.rotationInput.rotation.y,this.state.mode=this.mode,this.state.currentSpeed=this.horizontalSpeed,this.state.prevRotateToMovementDirection=this.rotateToMovementDirection}createCollisionShape(){const t=new x(this.colliderHeight,this.colliderRadius);return t.offset.y=this.colliderRadius+this.colliderHeight/2+this.offset,t.collisionGroup=ct,t}checkGrounded(t){Ct.y=-Math.max(.05,this.cc.snapToGroundDistance()),this.physicsSystem.rayTest(wt.addVectors(t,Rt.set(0,this.offset,0)),At.addVectors(t,Ct),this.rayTestResult,{excludeActor:this.actor,excludeTriggers:!0})}resolvePlatformVelocity(t){return t.set(0,0,0),this.rayTestResult.hasHit&&null!=this.rayTestResult.actor&&this.physicsSystem.getLinearVelocity(this.rayTestResult.actor,t),t}getCollisionGroup(){return this.characterCollision?null:ct}};t([T(),e("design:type",Object)],jt.prototype,"colliderHeight",void 0),t([T(),e("design:type",Object)],jt.prototype,"colliderRadius",void 0),t([S(!1),e("design:type",Function),e("design:paramtypes",[Uint8Array]),e("design:returntype",void 0)],jt.prototype,"serverMove",null),t([v(!1),e("design:type",Function),e("design:paramtypes",[Uint8Array]),e("design:returntype",void 0)],jt.prototype,"clientMoveAck",null),t([v(!0),e("design:type",Function),e("design:paramtypes",[Uint8Array]),e("design:returntype",void 0)],jt.prototype,"clientMoveCorrection",null),t([y(!1),e("design:type",Function),e("design:paramtypes",[Uint8Array]),e("design:returntype",void 0)],jt.prototype,"simulatedState",null),jt=t([R({inEditor:!1}),e("design:paramtypes",[])],jt);export{jt as CharacterMovementComponent};const Yt={mode:C.walking,update(t){const e=t.component,i=t.move,o=t.state,s=t.rotatedDirection,n=Math.min(1,Math.sqrt(i.inputX*i.inputX+i.inputY*i.inputY)),r=!e.rotateToMovementDirection&&i.inputY<0,a=!t.rootMotionActive&&0!==(i.flags&L)&&!r&&0!==s.lengthSq()&&(e.sprintPolicy?.canSprint()??!0),h=(r?e.maxSpeedBackwards:a?e.maxSpeedSprint:e.maxSpeed)*(e.normalizedDirection?1:n);if(0!==s.lengthSq()){e.isSprinting=a,a&&e.sprintPolicy?.commitSprint(t.deltaTime,i.sequence);let c=Math.min(h,o.currentSpeed),l=e.groundAccelerationRate;if(a&&t.startedSprinting&&e.sprintStartBoostSpeed>0){const t=e.normalizedDirection?1:n;c=Math.max(c,h+e.sprintStartBoostSpeed*t),l=e.sprintStartBoostDamping}else a&&!r&&e.sprintStartBoostSpeed>0&&o.currentSpeed>h&&(c=o.currentSpeed,l=e.sprintStartBoostDamping);o.currentSpeed=function(t,e,i,o){return e+(t-e)*Math.exp(-i*o)}(c,h,l,t.deltaTime),t.outVelocity.copy(s).multiplyScalar(function(t,e,i,o){const s=i*o;if(s<=1e-6)return t;return e+(t-e)*(1-Math.exp(-s))/s}(c,h,l,t.deltaTime))}else o.currentSpeed=0,t.outVelocity.set(0,0,0);if(0!==(i.flags&N))return o.mode=C.falling,o.velocity.copy(t.outVelocity),o.velocity.y=e.jumpVelocity,C.falling;t.outVelocity.y=t.deltaTime*e.getEffectiveGravity(),t.outVelocity.add(t.platformVelocity)}},Gt={mode:C.falling,update(t){const e=t.component,i=t.state,o=t.move;0!==(o.flags&N)&&e.jumpInAir&&(i.velocity.copy(t.outVelocity),i.velocity.y=e.jumpVelocity),i.velocity.y+=t.deltaTime*e.getEffectiveGravity(),t.outVelocity.copy(i.velocity),t.outVelocity.addScaledVector(t.rotatedDirection,e.fallingMovementControl),e.fallingReorientation&&t.outVelocity.applyAxisAngle(lt,r.euclideanModulo(o.yaw-i.lookYaw+Math.PI,2*Math.PI)-Math.PI)}};function Ft(t,e){return e.sequence=t.sequence,e.clientTime=t.clientTime,e.dt=t.dt,e.inputX=t.inputX,e.inputY=t.inputY,e.yaw=t.yaw,e.flags=t.flags,e.clientX=t.clientX,e.clientY=t.clientY,e.clientZ=t.clientZ,e.rootMotionX=t.rootMotionX,e.rootMotionY=t.rootMotionY,e.rootMotionZ=t.rootMotionZ,e}function Ot(t,e){const i=t.position.x-e.clientX,o=t.position.y-e.clientY,s=t.position.z-e.clientZ;return i*i+o*o+s*s}class Vt{constructor(t){this.scene=t,this.serverPosition=new h,this.direction=new h}update(t,e){const i=this.serverPosition.set(e.x,e.y,e.z),o=i.distanceTo(t);o>.1&&console.log(`Correction applied. Error: ${o.toFixed(3)}. Server position: (${i.x.toFixed(2)}, ${i.y.toFixed(2)}, ${i.z.toFixed(2)}), Client position: (${t.x.toFixed(2)}, ${t.y.toFixed(2)}, ${t.z.toFixed(2)})`);const s=this.direction.copy(i).sub(t).normalize();Xt.position.copy(t),Xt.setDirection(s),Xt.setLength(o);const n=Bt(this.scene);n.add(Xt),setTimeout(()=>{n.remove(Xt)},1e3)}}const Xt=new n(new h(0,1,0),new h,1,16711680);function Bt(t){return null==t.parent?t:Bt(t.parent)}const Zt={immediate:!1,savedRootMotion:!0};/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -0,0 +1,125 @@
1
+ import { CharacterMovementMode } from "./modes.js";
2
+ export declare const NET_CHARACTER_MOVEMENT_VERSION = 2;
3
+ export declare const MOVE_PACKET_KIND = 1;
4
+ export declare const OWNER_ACK_PACKET_KIND = 2;
5
+ export declare const OWNER_CORRECTION_PACKET_KIND = 3;
6
+ export declare const SIMULATED_STATE_PACKET_KIND = 4;
7
+ export declare const DEFAULT_MOVE_SEND_INTERVAL: number;
8
+ export declare const DEFAULT_SIMULATED_STATE_INTERVAL: number;
9
+ export declare const DEFAULT_MAX_SAVED_MOVES = 128;
10
+ export declare const DEFAULT_MAX_REPLAYED_MOVES = 64;
11
+ export declare const DEFAULT_MAX_SERVER_MOVES_PER_TICK = 4;
12
+ export declare const DEFAULT_MAX_MOVES_PER_PACKET = 16;
13
+ export declare const DEFAULT_MAX_MOVE_DELTA_TIME: number;
14
+ export declare const DEFAULT_MAX_COMBINED_MOVE_DELTA_TIME: number;
15
+ export declare const DEFAULT_MAX_SUBSTEP_DELTA_TIME: number;
16
+ export declare const DEFAULT_MAX_SERVER_MOVE_DELTA_TIME_SCALAR = 1.75;
17
+ export declare const DEFAULT_MAX_CLIENT_TIME_AHEAD = 0.1;
18
+ export declare const DEFAULT_MAX_SERVER_MOVE_TIME_BUDGET = 0.25;
19
+ export declare const DEFAULT_SMALL_CORRECTION_TOLERANCE = 0.08;
20
+ export declare const DEFAULT_LARGE_CORRECTION_THRESHOLD = 1;
21
+ export declare const DEFAULT_TELEPORT_SNAP_THRESHOLD = 5;
22
+ export declare const DEFAULT_SIMULATED_INTERPOLATION_DELAY = 0.1;
23
+ export declare const MOVE_FLAG_JUMP: number;
24
+ export declare const MOVE_FLAG_SPRINT: number;
25
+ export declare const MOVE_FLAG_ROOT_MOTION: number;
26
+ export declare const MOVE_FLAG_SPRINT_START: number;
27
+ export type NetCharacterMove = {
28
+ sequence: number;
29
+ clientTime: number;
30
+ dt: number;
31
+ inputX: number;
32
+ inputY: number;
33
+ yaw: number;
34
+ flags: number;
35
+ clientX: number;
36
+ clientY: number;
37
+ clientZ: number;
38
+ rootMotionX: number;
39
+ rootMotionY: number;
40
+ rootMotionZ: number;
41
+ };
42
+ export type NetCharacterMoveBatch = {
43
+ moves: NetCharacterMove[];
44
+ };
45
+ export type NetCharacterMovementSnapshot = {
46
+ sequence: number;
47
+ x: number;
48
+ y: number;
49
+ z: number;
50
+ velocityX: number;
51
+ velocityY: number;
52
+ velocityZ: number;
53
+ yaw: number;
54
+ mode: CharacterMovementMode;
55
+ horizontalSpeed: number;
56
+ };
57
+ export type NetCharacterOwnerAck = {
58
+ sequence: number;
59
+ };
60
+ export type NetCharacterOwnerCorrection = {
61
+ snapshot: NetCharacterMovementSnapshot;
62
+ };
63
+ export type NetCharacterDecodedPacket<T> = {
64
+ ok: true;
65
+ value: T;
66
+ } | {
67
+ ok: false;
68
+ reason: "malformed" | "unsupported-version" | "wrong-kind";
69
+ };
70
+ export type NetCharacterServerMoveTimingState = {
71
+ lastClientTime: number;
72
+ serverTimeBudget: number;
73
+ };
74
+ export type NetCharacterServerMoveTimingOptions = {
75
+ maxMoveDeltaTime?: number;
76
+ maxServerMoveDeltaTimeScalar?: number;
77
+ maxClientTimeAhead?: number;
78
+ };
79
+ export declare class NetCharacterSavedMoveBuffer {
80
+ capacity: number;
81
+ maxCombinedDeltaTime: number;
82
+ private readonly moves;
83
+ private readonly freeMoves;
84
+ private readonly sendScratch;
85
+ private readonly replayScratch;
86
+ private pending?;
87
+ constructor(capacity?: number, maxCombinedDeltaTime?: number);
88
+ get length(): number;
89
+ push(move: NetCharacterMove): void;
90
+ ack(sequence: number): void;
91
+ clear(): void;
92
+ getMovesForSend(maxCount: number): readonly NetCharacterMove[];
93
+ replayAfter(sequence: number, simulator: (move: NetCharacterMove) => void, maxCount?: number): void;
94
+ private commitPending;
95
+ private trimToCapacity;
96
+ private acquireMove;
97
+ private releaseMove;
98
+ }
99
+ export declare class NetCharacterProxySmoother {
100
+ private readonly interpolationDelay;
101
+ private readonly snapDistance;
102
+ private readonly maxSnapshots;
103
+ private readonly snapshots;
104
+ constructor(interpolationDelay?: number, snapDistance?: number, maxSnapshots?: number);
105
+ push(snapshot: NetCharacterMovementSnapshot, localTime: number): void;
106
+ reset(snapshot?: NetCharacterMovementSnapshot, localTime?: number): void;
107
+ sample(localTime: number, out: NetCharacterMovementSnapshot): boolean;
108
+ }
109
+ export declare function validateNetCharacterMove(move: NetCharacterMove, lastSequence: number, maxDeltaTime?: number): boolean;
110
+ export declare function encodeNetCharacterMoveBatch(moves: readonly NetCharacterMove[]): Uint8Array;
111
+ export declare function decodeNetCharacterMoveBatch(payload: Uint8Array): NetCharacterDecodedPacket<NetCharacterMoveBatch>;
112
+ export declare function encodeNetCharacterOwnerAck(sequence: number): Uint8Array;
113
+ export declare function decodeNetCharacterOwnerAck(payload: Uint8Array): NetCharacterDecodedPacket<NetCharacterOwnerAck>;
114
+ export declare function encodeNetCharacterOwnerCorrection(snapshot: NetCharacterMovementSnapshot): Uint8Array;
115
+ export declare function decodeNetCharacterOwnerCorrection(payload: Uint8Array): NetCharacterDecodedPacket<NetCharacterOwnerCorrection>;
116
+ export declare function encodeNetCharacterSimulatedState(snapshot: NetCharacterMovementSnapshot): Uint8Array;
117
+ export declare function decodeNetCharacterSimulatedState(payload: Uint8Array): NetCharacterDecodedPacket<NetCharacterMovementSnapshot>;
118
+ export declare function replayNetCharacterSavedMoves<TState>(baseState: TState, moves: readonly NetCharacterMove[], simulator: (state: TState, move: NetCharacterMove) => TState, maxMoves?: number): TState;
119
+ export declare function createNetCharacterServerMoveTimingState(): NetCharacterServerMoveTimingState;
120
+ export declare function accrueNetCharacterServerMoveTime(state: NetCharacterServerMoveTimingState, serverDeltaTime: number, maxServerMoveTimeBudget?: number): void;
121
+ export declare function consumeNetCharacterServerMoveTime(state: NetCharacterServerMoveTimingState, move: NetCharacterMove, options?: NetCharacterServerMoveTimingOptions): number;
122
+ export declare function createNetCharacterMovementSnapshot(overrides?: Partial<NetCharacterMovementSnapshot>): NetCharacterMovementSnapshot;
123
+ export declare function isSequenceGreater(a: number, b: number): boolean;
124
+ export declare function isSequenceLessOrEqual(a: number, b: number): boolean;
125
+ //# sourceMappingURL=net-character-movement-protocol.d.ts.map
@@ -0,0 +1,4 @@
1
+ import{MathUtils as t}from"three";import{CharacterMovementMode as e}from"./modes.js";export const NET_CHARACTER_MOVEMENT_VERSION=2;export const MOVE_PACKET_KIND=1;export const OWNER_ACK_PACKET_KIND=2;export const OWNER_CORRECTION_PACKET_KIND=3;export const SIMULATED_STATE_PACKET_KIND=4;export const DEFAULT_MOVE_SEND_INTERVAL=1/30;export const DEFAULT_SIMULATED_STATE_INTERVAL=.05;export const DEFAULT_MAX_SAVED_MOVES=128;export const DEFAULT_MAX_REPLAYED_MOVES=64;export const DEFAULT_MAX_SERVER_MOVES_PER_TICK=4;export const DEFAULT_MAX_MOVES_PER_PACKET=16;export const DEFAULT_MAX_MOVE_DELTA_TIME=1/15;export const DEFAULT_MAX_COMBINED_MOVE_DELTA_TIME=1/15;export const DEFAULT_MAX_SUBSTEP_DELTA_TIME=.017;export const DEFAULT_MAX_SERVER_MOVE_DELTA_TIME_SCALAR=1.75;export const DEFAULT_MAX_CLIENT_TIME_AHEAD=.1;export const DEFAULT_MAX_SERVER_MOVE_TIME_BUDGET=.25;export const DEFAULT_SMALL_CORRECTION_TOLERANCE=.08;export const DEFAULT_LARGE_CORRECTION_THRESHOLD=1;export const DEFAULT_TELEPORT_SNAP_THRESHOLD=5;export const DEFAULT_SIMULATED_INTERPOLATION_DELAY=.1;export const MOVE_FLAG_JUMP=1;export const MOVE_FLAG_SPRINT=2;export const MOVE_FLAG_ROOT_MOTION=4;export const MOVE_FLAG_SPRINT_START=8;const n=.001;export class NetCharacterSavedMoveBuffer{constructor(t=128,e=.06666666666666667){this.capacity=t,this.maxCombinedDeltaTime=e,this.moves=[],this.freeMoves=[],this.sendScratch=[],this.replayScratch={sequence:0,clientTime:0,dt:0,inputX:0,inputY:0,yaw:0,flags:0,clientX:0,clientY:0,clientZ:0,rootMotionX:0,rootMotionY:0,rootMotionZ:0}}get length(){return this.moves.length+(null==this.pending?0:1)}push(e){if(null!=this.pending){if(function(e,o,i=.06666666666666667){if(i<0)return!1;if(s=e.sequence,r=o.sequence,(s>>>0)+1>>>0!=r>>>0)return!1;var s,r;if(e.flags!==o.flags||13&e.flags)return!1;const a=e.clientTime-e.dt,c=o.clientTime-o.dt,h=o.clientTime-a,u=i;if(h<=0||h>u+n)return!1;if(Math.abs(e.clientTime-c)>n)return!1;if(l(e.inputX)!==l(o.inputX)||l(e.inputY)!==l(o.inputY))return!1;return function(e,n){return Math.abs(t.euclideanModulo(n-e+Math.PI,2*Math.PI)-Math.PI)}(e.yaw,o.yaw)<=.001}(this.pending,e,this.maxCombinedDeltaTime))return void function(t,e){const n=t.clientTime-t.dt;t.sequence=e.sequence,t.clientTime=e.clientTime,t.dt=Math.max(.001,e.clientTime-n),t.inputX=e.inputX,t.inputY=e.inputY,t.yaw=e.yaw,t.flags=e.flags,t.clientX=e.clientX,t.clientY=e.clientY,t.clientZ=e.clientZ,t.rootMotionX+=e.rootMotionX,t.rootMotionY+=e.rootMotionY,t.rootMotionZ+=e.rootMotionZ}(this.pending,e);this.commitPending()}this.pending=this.acquireMove(e),this.trimToCapacity()}ack(t){let e=0;for(let n=0;n<this.moves.length;n++)isSequenceLessOrEqual(this.moves[n].sequence,t)&&(e=n+1);if(e>0){for(let t=0;t<e;t++)this.releaseMove(this.moves[t]);this.moves.splice(0,e)}null!=this.pending&&isSequenceLessOrEqual(this.pending.sequence,t)&&(this.releaseMove(this.pending),this.pending=void 0)}clear(){for(let t=0;t<this.moves.length;t++)this.releaseMove(this.moves[t]);this.moves.length=0,null!=this.pending&&this.releaseMove(this.pending),this.pending=void 0,this.sendScratch.length=0}getMovesForSend(t){if(this.commitPending(),this.sendScratch.length=0,t<=0||0===this.moves.length)return this.sendScratch;if(1===t||this.moves.length<=t){for(let e=1===t?this.moves.length-1:0;e<this.moves.length;e++)this.sendScratch.push(this.moves[e]);return this.sendScratch}this.sendScratch.push(this.moves[0]);const e=t-1;for(let t=Math.max(1,this.moves.length-e);t<this.moves.length;t++)this.sendScratch.push(this.moves[t]);return this.sendScratch}replayAfter(t,e,n=64){let o=0;for(let i=0;i<this.moves.length&&o<n;i++){const n=this.moves[i];isSequenceGreater(n.sequence,t)&&(e(s(n,this.replayScratch)),o++)}null!=this.pending&&isSequenceGreater(this.pending.sequence,t)&&o<n&&e(s(this.pending,this.replayScratch))}commitPending(){null!=this.pending&&(this.moves.push(this.pending),this.pending=void 0,this.trimToCapacity())}trimToCapacity(){const t=Math.max(1,Math.floor(this.capacity)),e=this.length-t;if(e>0){for(let t=0;t<e;t++)this.releaseMove(this.moves[t]);this.moves.splice(0,e)}}acquireMove(t){return s(t,this.freeMoves.pop()??{sequence:0,clientTime:0,dt:0,inputX:0,inputY:0,yaw:0,flags:0,clientX:0,clientY:0,clientZ:0,rootMotionX:0,rootMotionY:0,rootMotionZ:0})}releaseMove(t){this.freeMoves.length<Math.max(1,Math.floor(this.capacity))&&this.freeMoves.push(t)}}export class NetCharacterProxySmoother{constructor(t=.1,e=5,n=32){this.interpolationDelay=t,this.snapDistance=e,this.maxSnapshots=n,this.snapshots=[]}push(t,e){const n=function(t){return{...t}}(t);this.snapshots.push({time:e,snapshot:n}),this.snapshots.sort((t,e)=>t.time-e.time),this.snapshots.length>this.maxSnapshots&&this.snapshots.splice(0,this.snapshots.length-this.maxSnapshots)}reset(t,e=0){this.snapshots.length=0,null!=t&&this.push(t,e)}sample(e,n){if(0===this.snapshots.length)return!1;const o=e-this.interpolationDelay,i=this.snapshots[0],s=this.snapshots[this.snapshots.length-1];if(null==i||null==s)return!1;if(o<=i.time||1===this.snapshots.length)return r(i.snapshot,n),!0;if(o>=s.time)return r(s.snapshot,n),!0;for(let e=1;e<this.snapshots.length;e++){const i=this.snapshots[e-1],s=this.snapshots[e];if(null==i||null==s||o>s.time)continue;if(c(i.snapshot,s.snapshot)>this.snapDistance*this.snapDistance)return r(s.snapshot,n),!0;const l=s.time-i.time,h=l>0?t.clamp((o-i.time)/l,0,1):1;return a(i.snapshot,s.snapshot,h,n),!0}return r(s.snapshot,n),!0}}export function validateNetCharacterMove(t,e,n=.06666666666666667){return!!isSequenceGreater(t.sequence,e)&&(!(!Number.isFinite(t.clientTime)||t.clientTime<=0)&&(!(!Number.isFinite(t.dt)||t.dt<=0||t.dt>n)&&(!(!Number.isFinite(t.inputX)||!Number.isFinite(t.inputY))&&(!(t.inputX*t.inputX+t.inputY*t.inputY>1.0001)&&(Number.isFinite(t.yaw)&&Number.isFinite(t.clientX)&&Number.isFinite(t.clientY)&&Number.isFinite(t.clientZ))))))}export function encodeNetCharacterMoveBatch(e){const n=Math.min(65535,e.length),o=new Uint8Array(4+43*n),i=new DataView(o.buffer);let s=0;i.setUint8(s++,2),i.setUint8(s++,1),i.setUint16(s,n,!0),s+=2;for(let o=0;o<n;o++){const n=e[o];i.setUint32(s,n.sequence>>>0,!0),s+=4,i.setUint32(s,t.clamp(Math.round(1e3*n.clientTime),0,4294967295),!0),s+=4,i.setUint16(s,t.clamp(Math.round(1e3*n.dt),1,65535),!0),s+=2,i.setInt16(s,l(n.inputX),!0),s+=2,i.setInt16(s,l(n.inputY),!0),s+=2,i.setFloat32(s,n.yaw,!0),s+=4,i.setUint8(s++,255&n.flags),i.setFloat32(s,n.clientX,!0),s+=4,i.setFloat32(s,n.clientY,!0),s+=4,i.setFloat32(s,n.clientZ,!0),s+=4,i.setFloat32(s,n.rootMotionX,!0),s+=4,i.setFloat32(s,n.rootMotionY,!0),s+=4,i.setFloat32(s,n.rootMotionZ,!0),s+=4}return o}export function decodeNetCharacterMoveBatch(t){if(t.byteLength<4)return{ok:!1,reason:"malformed"};const e=u(t);let n=0;if(2!==e.getUint8(n++))return{ok:!1,reason:"unsupported-version"};if(1!==e.getUint8(n++))return{ok:!1,reason:"wrong-kind"};const o=e.getUint16(n,!0);if(n+=2,t.byteLength!==4+43*o)return{ok:!1,reason:"malformed"};const i=[];for(let t=0;t<o;t++){const t=e.getUint32(n,!0);n+=4;const o=e.getUint32(n,!0)/1e3;n+=4;const s=e.getUint16(n,!0)/1e3;n+=2;const r=h(e.getInt16(n,!0));n+=2;const a=h(e.getInt16(n,!0));n+=2;const c=e.getFloat32(n,!0);n+=4;const l=e.getUint8(n++),u=e.getFloat32(n,!0);n+=4;const p=e.getFloat32(n,!0);n+=4;const m=e.getFloat32(n,!0);n+=4;const M=e.getFloat32(n,!0);n+=4;const d=e.getFloat32(n,!0);n+=4;const g=e.getFloat32(n,!0);n+=4,i.push({sequence:t,clientTime:o,dt:s,inputX:r,inputY:a,yaw:c,flags:l,clientX:u,clientY:p,clientZ:m,rootMotionX:M,rootMotionY:d,rootMotionZ:g})}return{ok:!0,value:{moves:i}}}export function encodeNetCharacterOwnerAck(t){const e=new Uint8Array(6),n=new DataView(e.buffer);return n.setUint8(0,2),n.setUint8(1,2),n.setUint32(2,t>>>0,!0),e}export function decodeNetCharacterOwnerAck(t){if(6!==t.byteLength)return{ok:!1,reason:"malformed"};const e=u(t);return 2!==e.getUint8(0)?{ok:!1,reason:"unsupported-version"}:2!==e.getUint8(1)?{ok:!1,reason:"wrong-kind"}:{ok:!0,value:{sequence:e.getUint32(2,!0)}}}export function encodeNetCharacterOwnerCorrection(t){return o(3,t)}export function decodeNetCharacterOwnerCorrection(t){const e=i(t,3);return!1===e.ok?{ok:!1,reason:e.reason}:{ok:!0,value:{snapshot:e.value}}}export function encodeNetCharacterSimulatedState(t){return o(4,t)}export function decodeNetCharacterSimulatedState(t){return i(t,4)}export function replayNetCharacterSavedMoves(t,e,n,o=64){let i=t;const s=Math.min(o,e.length);for(let t=0;t<s;t++)i=n(i,e[t]);return i}export function createNetCharacterServerMoveTimingState(){return{lastClientTime:0,serverTimeBudget:0}}export function accrueNetCharacterServerMoveTime(t,e,n=.25){!Number.isFinite(e)||e<=0||(t.serverTimeBudget=Math.min(n,t.serverTimeBudget+e))}export function consumeNetCharacterServerMoveTime(t,e,n={}){if(!Number.isFinite(e.clientTime))return-1;const o=e.clientTime-t.lastClientTime;if(!Number.isFinite(o)||o<=0)return-1;const i=n.maxMoveDeltaTime??.06666666666666667,s=Math.max(1,n.maxServerMoveDeltaTimeScalar??1.75),r=n.maxClientTimeAhead??.1,a=Math.max(.001,i*s),c=Math.min(o,a),l=t.serverTimeBudget-c;return l<-r?-1:(t.serverTimeBudget=l,t.lastClientTime=e.clientTime,Math.max(.001,c))}export function createNetCharacterMovementSnapshot(t={}){return{sequence:0,x:0,y:0,z:0,velocityX:0,velocityY:0,velocityZ:0,yaw:0,mode:e.walking,horizontalSpeed:0,...t}}export function isSequenceGreater(t,e){return t-e>>>0<2147483648&&t!==e}export function isSequenceLessOrEqual(t,e){return t===e||!isSequenceGreater(t,e)}function o(t,e){const n=new Uint8Array(40),o=new DataView(n.buffer);let i=0;return o.setUint8(i++,2),o.setUint8(i++,t),o.setUint32(i,e.sequence>>>0,!0),i+=4,o.setFloat32(i,e.x,!0),i+=4,o.setFloat32(i,e.y,!0),i+=4,o.setFloat32(i,e.z,!0),i+=4,o.setFloat32(i,e.velocityX,!0),i+=4,o.setFloat32(i,e.velocityY,!0),i+=4,o.setFloat32(i,e.velocityZ,!0),i+=4,o.setFloat32(i,e.yaw,!0),i+=4,o.setUint8(i++,e.mode),o.setFloat32(i,e.horizontalSpeed,!0),n}function i(t,e){if(40!==t.byteLength)return{ok:!1,reason:"malformed"};const n=u(t);let o=0;if(2!==n.getUint8(o++))return{ok:!1,reason:"unsupported-version"};if(n.getUint8(o++)!==e)return{ok:!1,reason:"wrong-kind"};const i=n.getUint32(o,!0);o+=4;const s=n.getFloat32(o,!0);o+=4;const r=n.getFloat32(o,!0);o+=4;const a=n.getFloat32(o,!0);o+=4;const c=n.getFloat32(o,!0);o+=4;const l=n.getFloat32(o,!0);o+=4;const h=n.getFloat32(o,!0);o+=4;const p=n.getFloat32(o,!0);o+=4;return{ok:!0,value:{sequence:i,x:s,y:r,z:a,velocityX:c,velocityY:l,velocityZ:h,yaw:p,mode:n.getUint8(o++),horizontalSpeed:n.getFloat32(o,!0)}}}function s(t,e){return e.sequence=t.sequence,e.clientTime=t.clientTime,e.dt=t.dt,e.inputX=t.inputX,e.inputY=t.inputY,e.yaw=t.yaw,e.flags=t.flags,e.clientX=t.clientX,e.clientY=t.clientY,e.clientZ=t.clientZ,e.rootMotionX=t.rootMotionX,e.rootMotionY=t.rootMotionY,e.rootMotionZ=t.rootMotionZ,e}function r(t,e){e.sequence=t.sequence,e.x=t.x,e.y=t.y,e.z=t.z,e.velocityX=t.velocityX,e.velocityY=t.velocityY,e.velocityZ=t.velocityZ,e.yaw=t.yaw,e.mode=t.mode,e.horizontalSpeed=t.horizontalSpeed}function a(e,n,o,i){i.sequence=n.sequence,i.x=t.lerp(e.x,n.x,o),i.y=t.lerp(e.y,n.y,o),i.z=t.lerp(e.z,n.z,o),i.velocityX=t.lerp(e.velocityX,n.velocityX,o),i.velocityY=t.lerp(e.velocityY,n.velocityY,o),i.velocityZ=t.lerp(e.velocityZ,n.velocityZ,o),i.yaw=e.yaw+(t.euclideanModulo(n.yaw-e.yaw+Math.PI,2*Math.PI)-Math.PI)*o,i.mode=o<1?e.mode:n.mode,i.horizontalSpeed=t.lerp(e.horizontalSpeed,n.horizontalSpeed,o)}function c(t,e){const n=t.x-e.x,o=t.y-e.y,i=t.z-e.z;return n*n+o*o+i*i}function l(e){return t.clamp(Math.round(32767*t.clamp(e,-1,1)),-32767,32767)}function h(e){return t.clamp(e/32767,-1,1)}function u(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}/*
2
+ * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
+ * See the LICENSE.md file for details.
4
+ */
@@ -0,0 +1,100 @@
1
+ import * as THREE from 'three';
2
+ import { AnimationAction, Vector3 } from 'three';
3
+ import { ActionInput, AxisInput, RotationInput } from '../../../../../gameplay/input/index.js';
4
+ import { ActorComponent } from '../../../component.js';
5
+ import { CharacterMovementMode } from './modes.js';
6
+ export declare class OldCharacterMovementComponent extends ActorComponent {
7
+ readonly directionInput: AxisInput;
8
+ readonly jumpInput: ActionInput;
9
+ readonly sprintInput: ActionInput;
10
+ readonly rotationInput: RotationInput;
11
+ horizontalSpeed: number;
12
+ maxSpeed: number;
13
+ maxSpeedBackwards: number;
14
+ maxSpeedSprint: number;
15
+ jumpVelocity: number;
16
+ fallingMovementControl: number;
17
+ fallingReorientation: boolean;
18
+ gravityOverride: number;
19
+ colliderHeight: number;
20
+ colliderRadius: number;
21
+ jumpInAir: boolean;
22
+ mass: number;
23
+ allowSliding: boolean;
24
+ minSlopeSlideAngle: number;
25
+ maxSlopeClimbAngle: number;
26
+ applyImpulsesToDynamicBodies: boolean;
27
+ normalizedDirection: boolean;
28
+ /** Collide with other characters */
29
+ characterCollision: boolean;
30
+ allowRootMotionJumpCancel: boolean;
31
+ get autoStepMinWidth(): number;
32
+ set autoStepMinWidth(minWidth: number);
33
+ get autoStepDynamicObjects(): boolean;
34
+ set autoStepDynamicObjects(enabled: boolean);
35
+ get autoStepMaxHeight(): number;
36
+ set autoStepMaxHeight(maxHeight: number);
37
+ get snapToGround(): number;
38
+ set snapToGround(distance: number);
39
+ set offset(distance: number);
40
+ get offset(): number;
41
+ set normalNudgeFactor(factor: number);
42
+ get normalNudgeFactor(): number;
43
+ /**
44
+ * Flag for if it should be moving the character.
45
+ * Can be useful to turn of if under certain circumstances the all
46
+ * inputs should be ignored.
47
+ */
48
+ enabled: boolean;
49
+ readonly velocity: THREE.Vector3;
50
+ mode: CharacterMovementMode;
51
+ isSprinting: boolean;
52
+ pressedJump: boolean;
53
+ private cc;
54
+ private rayTestResult;
55
+ private physicsSystem;
56
+ constructor();
57
+ private resetRootMotion;
58
+ private rootMotionInterpolant;
59
+ private rootMotionRootBone;
60
+ private rootMotionOptions;
61
+ /**
62
+ * Makes the character rotate to the direction of movement input instead
63
+ * of strafing or walking backwards
64
+ */
65
+ rotateToMovementDirection: boolean;
66
+ /** Makes the character rotate smoothly to the desired direction */
67
+ smoothRotation: boolean;
68
+ rotationSpeed: number;
69
+ maxRotationSpeed: number;
70
+ private impulse;
71
+ /**
72
+ * The damping factor used to slow down impulses over time
73
+ */
74
+ impulseDamping: number;
75
+ onInit(): void | Promise<void>;
76
+ /**
77
+ * Add an instant velocity to the character which can be used to
78
+ * launch the character or push it.
79
+ * @param impulse
80
+ */
81
+ applyImpulse(impulse: Vector3): void;
82
+ private debugDirection;
83
+ private rootMotionAction;
84
+ setRootMotionAction(action: AnimationAction, options?: RootMotionActionOptions): void;
85
+ private clearRootMotionAction;
86
+ private getWallDirection;
87
+ private moveTo;
88
+ getEffectiveGravity(): number;
89
+ private checkGrounded;
90
+ get isGrounded(): boolean;
91
+ private createCollisionShape;
92
+ private step;
93
+ private performMovement;
94
+ private arrowHelper;
95
+ }
96
+ export type RootMotionActionOptions = {
97
+ cancelWithJump?: boolean;
98
+ onJumpCancel?: () => void;
99
+ };
100
+ //# sourceMappingURL=old-character-movement.d.ts.map
@@ -0,0 +1,4 @@
1
+ import{__decorate as t,__metadata as o}from"tslib";import i from"@dimforge/rapier3d-simd-compat";import{takeUntil as e}from"rxjs";import*as s from"three";import{ArrowHelper as n,MathUtils as r,Vector3 as a}from"three";import{RootMotionClip as c}from"../../../../../gameplay/animation/root-motion.js";import{ActionInput as h,AxisInput as l,RotationInput as p}from"../../../../../gameplay/input/index.js";import{PhysicsSystem as m,RayTestResult as u}from"../../../../../gameplay/services/physics/physics-system.js";import{CapsuleCollisionShape as d}from"../../../../../scene/collision/collision-shape.js";import{PhysicsBodyType as y}from"../../../../services/physics/physics-system.js";import{ActorComponent as g,Component as f}from"../../../component.js";import{CharacterMovementMode as M}from"./modes.js";import{inject as S}from"../../../../../gameplay/inject.js";import{Parameter as v}from"../../../../../shader/parameter.js";const w=new a,x=new a,A=1/30,b=131070;let I=class extends g{get autoStepMinWidth(){return this.cc.autostepMinWidth()}set autoStepMinWidth(t){this.cc.enableAutostep(this.cc.autostepMaxHeight(),t,this.cc.autostepIncludesDynamicBodies())}get autoStepDynamicObjects(){return this.cc.autostepIncludesDynamicBodies()}set autoStepDynamicObjects(t){this.cc.enableAutostep(this.cc.autostepMaxHeight(),this.cc.autostepMinWidth(),t)}get autoStepMaxHeight(){return this.cc.autostepMaxHeight()}set autoStepMaxHeight(t){this.cc.enableAutostep(t,this.cc.autostepMinWidth(),this.cc.autostepIncludesDynamicBodies())}get snapToGround(){return this.cc.snapToGroundDistance()}set snapToGround(t){this.cc.enableSnapToGround(t)}set offset(t){this.cc.setOffset(t)}get offset(){return this.cc.offset()}set normalNudgeFactor(t){this.cc.setNormalNudgeFactor(t)}get normalNudgeFactor(){return this.cc.normalNudgeFactor()}constructor(){super(),this.directionInput=new l,this.jumpInput=new h,this.sprintInput=new h,this.rotationInput=new p,this.horizontalSpeed=0,this.maxSpeed=8,this.maxSpeedBackwards=8,this.maxSpeedSprint=12,this.jumpVelocity=7,this.fallingMovementControl=.5,this.fallingReorientation=!1,this.gravityOverride=null,this.colliderHeight=2,this.colliderRadius=.5,this.jumpInAir=!1,this.mass=50,this.allowSliding=!0,this.minSlopeSlideAngle=r.degToRad(70),this.maxSlopeClimbAngle=r.degToRad(70),this.applyImpulsesToDynamicBodies=!0,this.normalizedDirection=!0,this.characterCollision=!1,this.allowRootMotionJumpCancel=!1,this.enabled=!0,this.velocity=new a,this.mode=M.walking,this.isSprinting=!1,this.pressedJump=!1,this.rayTestResult=new u,this.physicsSystem=S(m),this.resetRootMotion=!1,this.rootMotionOptions={},this.rotateToMovementDirection=!1,this.smoothRotation=!0,this.rotationSpeed=40,this.maxRotationSpeed=100,this.impulse=new a,this.impulseDamping=2;const t=this.cc=this.physicsSystem.getCharacterController(.1);t.enableSnapToGround(.1),t.enableAutostep(0,.1,!1)}onInit(){const t=this.cc;t.setApplyImpulsesToDynamicBodies(this.applyImpulsesToDynamicBodies),t.setMinSlopeSlideAngle(this.minSlopeSlideAngle),t.setMaxSlopeClimbAngle(this.maxSlopeClimbAngle),t.setCharacterMass(this.mass),t.setSlideEnabled(this.allowSliding),this.physicsSystem.addActor(this.actor,[this.createCollisionShape()],{mass:0,type:y.kinematic,continousCollisionDetection:!1,friction:0,restitution:.5,ignoreForNavMesh:!0}),this.rotationInput.rotation.copy(this.actor.rotation);let o=this.rotationInput.rotation.y;const i=new a,n=new a,h=new a,l=new a,p=new a,m=new a,u=new a;let d=0,g=null;const f=new a,S=new a,v=new a,I=new a,R=new a,z=new a,C=new a,D=this.characterCollision?null:b;let E=this.rotateToMovementDirection;this.physicsSystem.beforeStep.pipe(e(this.disposed)).subscribe(e=>{if(this.checkGrounded(e),!this.enabled)return;if(S.set(0,0,0),null==this.rootMotionAction||this.rootMotionAction.isRunning()||this.clearRootMotionAction(this.rootMotionAction),null!=this.rootMotionAction&&this.rootMotionOptions.cancelWithJump&&this.jumpInput.activated&&(this.isGrounded||this.jumpInAir)){const t=this.rootMotionAction,o=this.rootMotionOptions.onJumpCancel;this.clearRootMotionAction(t),t.stop(),o?.()}if(null!=this.rootMotionAction){if(this.rootMotionAction.getClip()instanceof c){const t=this.rootMotionInterpolant;this.resetRootMotion&&(f.fromArray(t.evaluate(0)),this.resetRootMotion=!1),z.fromArray(t.evaluate(this.rootMotionAction.time)),S.subVectors(z,f),f.copy(z);(this.rootMotionRootBone??this.rootMotionAction.getRoot()).getWorldScale(R),S.multiply(R)}}e>A&&(e=A);const y=null!=this.rootMotionAction&&this.rootMotionAction.enabled,b=y&&0!==S.lengthSq();this.pressedJump=!y&&this.jumpInput.activated,this.isSprinting=!y&&this.sprintInput.activated;const H=E!==this.rotateToMovementDirection;let B=r.euclideanModulo(this.rotationInput.rotation.y-o+Math.PI,2*Math.PI)-Math.PI;H&&(this.actor.object.quaternion.setFromEuler(F.set(0,this.rotationInput.rotation.y,0)),E?this.actor.object.quaternion.setFromEuler(F.set(0,this.rotationInput.rotation.y,0)):(B=0,o=this.rotationInput.rotation.y),E=this.rotateToMovementDirection),h.copy(this.actor.position),l.set(-this.directionInput.vector.x,0,this.directionInput.vector.y).normalize();const N=!this.rotateToMovementDirection&&l.z<0?this.maxSpeedBackwards:(this.isSprinting?this.maxSpeedSprint:this.maxSpeed)*(this.normalizedDirection?1:Math.min(1,this.directionInput.vector.length()));if(u.set(0,0,0),y)o=this.rotationInput.rotation.y;else if(this.rotateToMovementDirection&&!y){if(l.lengthSq()>0&&this.mode!=M.falling){const t=this.smoothRotation,i=F.setFromQuaternion(this.actor.object.quaternion,"YXZ").y,s=Math.atan2(l.x,l.z),n=.99*this.rotationInput.rotation.y+s;if(t){r.clamp(.5*l.dot(p)+.5,.001,1);const t=r.euclideanModulo(n-i+Math.PI,2*Math.PI)-Math.PI;let o=r.clamp(t*this.rotationSpeed*e,-this.maxRotationSpeed*e,this.maxRotationSpeed*e);Math.abs(o)>Math.abs(t)&&(o=t),this.actor.object.quaternion.setFromEuler(F.set(0,i+o,0))}else this.actor.object.quaternion.setFromEuler(F.set(0,n,0));p.lerp(l,e*this.rotationSpeed),o+=B,u.copy(this.actor.object.getWorldDirection(k).normalize())}}else b||(o+=B,this.actor.object.quaternion.multiply(q.setFromEuler(F.set(0,B,0))),l.lengthSq()>0&&u.copy(l).applyQuaternion(this.actor.object.quaternion).normalize());if(C.set(0,0,0),this.rayTestResult.hasHit&&null!=this.rayTestResult.actor&&this.physicsSystem.getLinearVelocity(this.rayTestResult.actor,C),this.mode===M.walking?(0!==u.lengthSq()?(d=Math.min(N,d),d=r.lerp(d,N,4*e)):d=0,m.copy(u).multiplyScalar(d),this.pressedJump&&(this.mode=M.falling,this.velocity.copy(m),this.velocity.y=this.jumpVelocity),m.y=e*this.getEffectiveGravity(),m.add(C)):this.mode===M.falling&&(this.pressedJump&&this.jumpInAir&&(this.mode=M.falling,this.velocity.copy(m),this.velocity.y=this.jumpVelocity),this.velocity.y+=e*this.getEffectiveGravity(),m.copy(this.velocity),m.addScaledVector(u,this.fallingMovementControl),this.fallingReorientation&&m.applyAxisAngle(new a(0,1,0),B)),b&&(v.copy(S).applyQuaternion(this.actor.quaternion),I.copy(v).divideScalar(e),this.mode===M.walking?(m.x=I.x+C.x,m.z=I.z+C.z):(m.x=I.x,m.z=I.z),l.lengthSq()>0)){const t=Math.sqrt(I.x*I.x+I.z*I.z);t>.4&&(d=t)}if(this.impulse.lengthSq()>.1){const t=Math.min(1,this.impulse.length()/5);m.x=r.lerp(m.x,this.impulse.x,t),m.z=r.lerp(m.z,this.impulse.z,t),m.y+=this.impulse.y;const o=Math.exp(-this.impulseDamping*e);this.impulse.x*=o,this.impulse.y>0?this.impulse.y+=e*this.getEffectiveGravity():this.impulse.y*=o,this.impulse.z*=o}else this.impulse.set(0,0,0);if(n.copy(m).normalize(),i.copy(m),m.length()>0||!this.isGrounded){if(w.copy(m).multiplyScalar(e),this.isGrounded&&this.mode===M.walking&&(this.rayTestResult.distance>t.offset()||(w.y=Math.max(0,C.y*e)),this.physicsSystem.getActorComputedMovement(this.actor,t,w,D),t.computedCollision(0,G),null!=G&&null!=G.normal1)){const o=(new s.Vector3).copy(G.normal1);Math.acos(o.dot(T))>t.maxSlopeClimbAngle()&&(w.y=.016*this.getEffectiveGravity()*.5)}x.copy(this.physicsSystem.getActorComputedMovement(this.actor,t,w,D))}else x.set(0,0,0);this.physicsSystem.setNextKinematicTranslation(this.actor,x);let O=function(t){if(t.numComputedCollisions()>0){const o=t.computedCollision(0);j.x=o.normal2.x,j.y=o.normal2.y,j.z=o.normal2.z;const i=j.angleTo(T);j.x=o.normal1.x,j.y=o.normal1.y,j.z=o.normal1.z;const e=j.angleTo(T);return!(i<100)&&e>t.minSlopeSlideAngle()}return!1}(t);this.isGrounded&&!O||this.mode!==M.falling&&(null==g?g=performance.now():performance.now()-g>100&&(this.mode=M.falling,this.velocity.copy(i))),this.isGrounded&&this.velocity.y<=0&&(this.mode,M.falling,this.mode=M.walking,this.velocity.y=0,g=null),this.mode,M.walking,this.horizontalSpeed=d})}applyImpulse(t){this.impulse.add(t)}debugDirection(){const t=new n(w,this.actor.position,1,65280);this.actor.object.parent.add(t),setTimeout(()=>{t.removeFromParent()},30);const o=new n(x,this.actor.position,1,16711680);this.actor.object.parent.add(o),setTimeout(()=>{o.removeFromParent()},30)}setRootMotionAction(t,o={}){const i=t?.getClip();if(i instanceof c){this.rootMotionAction=t,this.rootMotionOptions=o,this.resetRootMotion=!0;const e=[];this.rootMotionInterpolant=i.motionTrack.InterpolantFactoryMethodSmooth(e);const n=s.PropertyBinding.parseTrackName(i.motionTrack.name);this.rootMotionRootBone=this.actor.object.getObjectByName(n.nodeName)}}clearRootMotionAction(t){null!=t&&this.rootMotionAction!==t||(this.rootMotionAction=null,this.rootMotionOptions={},this.resetRootMotion=!1)}getWallDirection(t,o){const i=t.clone().negate().cross(T);return i.dot(o)<0?i.negate():i}moveTo(t){this.actor.position.copy(t),this.physicsSystem.updateActorTransform(this.actor)}getEffectiveGravity(){return this.gravityOverride??this.physicsSystem.getGravity().y}checkGrounded(t){this.colliderHeight,this.colliderRadius;D.y=-.05,this.physicsSystem.rayTest(R.addVectors(this.actor.position,C.set(0,this.offset,0)),z.addVectors(this.actor.position,D),this.rayTestResult,{excludeActor:this.actor,excludeTriggers:!0})}get isGrounded(){return this.rayTestResult.hasHit||this.cc.computedGrounded()}createCollisionShape(){const t=new d(this.colliderHeight,this.colliderRadius);return t.offset.y=this.colliderRadius+this.colliderHeight/2+this.offset,t.collisionGroup=b,t}step(t){}performMovement(t){}arrowHelper(t,o,i){const e=new n(t.clone().normalize(),o,1,i);this.actor.object.parent.add(e),setTimeout(()=>{e.removeFromParent()},30)}};t([v(),o("design:type",Number)],I.prototype,"colliderHeight",void 0),t([v(),o("design:type",Number)],I.prototype,"colliderRadius",void 0),I=t([f({inEditor:!1}),o("design:paramtypes",[])],I);export{I as OldCharacterMovementComponent};const T=new a(0,1,0),j=new a;const R=new a,z=new a,C=new a(0,1,0),D=new a(0,-.1,0),G=(new a(0,-1,0),new i.CharacterCollision),q=new s.Quaternion,F=new s.Euler,k=new s.Vector3;/*
2
+ * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
+ * See the LICENSE.md file for details.
4
+ */
@@ -1,4 +1,5 @@
1
1
  import { MeshComponent } from './mesh-component.js';
2
+ import { OldCharacterMovementComponent } from './character/old-character-movement.js';
2
3
  import { CharacterMovementComponent } from './character/character-movement.js';
3
4
  import { CharacterAnimationComponent } from './character/character-animation.js';
4
5
  import { TweenComponent } from './tween-component.js';
@@ -10,6 +11,7 @@ import { ThirdPersonCameraComponent } from '../../camera/third-person-camera-com
10
11
  export declare const builtInComponents: {
11
12
  MeshComponent: typeof MeshComponent;
12
13
  TweenComponent: typeof TweenComponent;
14
+ OldCharacterMovementComponent: typeof OldCharacterMovementComponent;
13
15
  CharacterMovementComponent: typeof CharacterMovementComponent;
14
16
  CharacterAnimationComponent: typeof CharacterAnimationComponent;
15
17
  TriggerVolumeComponent: typeof TriggerVolumeComponent;
@@ -1,4 +1,4 @@
1
- import{MeshComponent as o}from"./mesh-component.js";import{CharacterMovementComponent as r}from"./character/character-movement.js";import{CharacterAnimationComponent as e}from"./character/character-animation.js";import{TweenComponent as m}from"./tween-component.js";import{TriggerVolumeComponent as n}from"../trigger-volume.js";import{PositionalAudioComponent as t}from"../positional-audio-actor.js";import{CameraComponent as a}from"../../camera/camera-component.js";import{FirstPersonCameraComponent as p}from"../../camera/first-person-camera-component.js";import{ThirdPersonCameraComponent as i}from"../../camera/third-person-camera-component.js";export const builtInComponents={MeshComponent:o,TweenComponent:m,CharacterMovementComponent:r,CharacterAnimationComponent:e,TriggerVolumeComponent:n,PositionalAudioComponent:t,CameraComponent:a,FirstPersonCameraComponent:p,ThirdPersonCameraComponent:i};export default builtInComponents;/*
1
+ import{MeshComponent as o}from"./mesh-component.js";import{OldCharacterMovementComponent as r}from"./character/old-character-movement.js";import{CharacterMovementComponent as e}from"./character/character-movement.js";import{CharacterAnimationComponent as m}from"./character/character-animation.js";import{TweenComponent as t}from"./tween-component.js";import{TriggerVolumeComponent as n}from"../trigger-volume.js";import{PositionalAudioComponent as a}from"../positional-audio-actor.js";import{CameraComponent as p}from"../../camera/camera-component.js";import{FirstPersonCameraComponent as c}from"../../camera/first-person-camera-component.js";import{ThirdPersonCameraComponent as i}from"../../camera/third-person-camera-component.js";export const builtInComponents={MeshComponent:o,TweenComponent:t,OldCharacterMovementComponent:r,CharacterMovementComponent:e,CharacterAnimationComponent:m,TriggerVolumeComponent:n,PositionalAudioComponent:a,CameraComponent:p,FirstPersonCameraComponent:c,ThirdPersonCameraComponent:i};export default builtInComponents;/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,4 +1,4 @@
1
- import{__decorate as e,__metadata as t}from"tslib";import{Ball as n,Capsule as o,Cone as s,ConvexPolyhedron as i,Cuboid as r,Cylinder as a,Heightfield as l,ShapeType as c,TriMesh as h}from"@dimforge/rapier3d-compat";import{init as p}from"@recast-navigation/core";import{DebugDrawer as u,getPositionsAndIndices as d}from"@recast-navigation/three";import{BehaviorSubject as m,Subject as f,debounceTime as w,filter as b,firstValueFrom as g,takeUntil as y}from"rxjs";import*as x from"three";import{BufferGeometryUtils as v,ConvexHull as M}from"three/examples/jsm/Addons.js";import{Actor as B,BaseActor as S,Parameter as z,PhysicsSystem as A,ViewController as k,World as C,attach as j,inject as F}from"../../";import{sleepDelay as I}from"../../../utils/async";import{hasSharedArrayBufferSupport as P,toSharedFloat32Array as V,toSharedUint32Array as G}from"../../../utils/buffer";import{DynamicTiledNavMesh as N}from"../../ai/dynamic-tiled-navmesh";import{TriggerVolumeMesh as H}from"./components/volume-editor-component";var D;!function(e){e[e.none=0]="none",e[e.starting=1]="starting",e[e.started=2]="started"}(D||(D={}));let E=D.none,T=new m(!1);export async function safeRecastInit(){return E===D.none?(E=D.starting,p().then(()=>{T.next(!0),E=D.started})):g(T.pipe(b(e=>e)))}new x.Box3(new x.Vector3(-100,-100,-100),new x.Vector3(100,100,100));const R=navigator.hardwareConcurrency??1;let U=!1,q=class extends S{constructor(){super(...arguments),this.physics=F(A),this.view=F(k),this.world=F(C),this.editorVisualisation=j(H),this.debug=!0,this.refreshMs=4e3,this.tileSize=50,this.walkableClimb=.3,this.walkableSlopeAngle=45,this.walkableHeight=2,this.cellSize=.2,this.bounds=new x.Box3}async onInit(){U||(await safeRecastInit(),U=!0),setTimeout(()=>{this.init()},10),this.recreateInterval=setInterval(()=>{if("_hology_transform_group"===this.object.parent?.name)return;$.setFromCenterAndSize(this.position,this.object.scale).equals(this.bounds)||(this.disposed.next(!0),this.disposed=new f,this.init())},2e3)}onEndPlay(){clearInterval(this.recreateInterval)}init(){this.bounds.setFromCenterAndSize(this.position,this.object.scale);const e=this.bounds.max.x-this.bounds.min.x,t=this.bounds.max.z-this.bounds.min.z,n=Math.max(1,Math.min(e,t)),o=Math.min(400,Math.max(50,Math.ceil(n/2))),s=Math.max(this.cellSize,.01),i={tileSize:Math.max(32,Math.floor(o/s)),walkableClimb:this.walkableClimb/s,walkableSlopeAngle:this.walkableSlopeAngle,walkableRadius:2,walkableHeight:this.walkableHeight/s,detailSampleDist:1,minRegionArea:6,mergeRegionArea:400,cs:s,ch:s,maxSimplificationError:1.3,maxEdgeLen:200},r=new N({navMeshBounds:this.bounds,recastConfig:i,maxTiles:1024,workers:R,cacheId:"nav"+this.object.userData?.src?.id});this.navMesh=r.navMesh;const a=this.tileSize*i.cs*2,l=performance.now(),c=new Map,h=new u;h.userData.isDebugDrawer=!0;r.navMesh;const p=this.bounds,m=()=>{const e=this.view.getCamera().getWorldPosition(new x.Vector3),t=new x.Box3((new x.Vector3).copy(e).subScalar(a),(new x.Vector3).copy(e).addScalar(a)),n=[],o=this.physics.world.bodies;if(null==o)return[];const s=new x.Box3;for(const e of o.getAll())for(let o=0,i=e.numColliders();o<i;o++){const i=e.collider(o);if(i.isSensor()||null!=i.parent().userData&&!0===i.parent().userData.ignoreForNavMesh)continue;const r=e.handle+","+o,a=c.get(r)?.mesh,l=a??L(i);if(X(i,l),null!=l){s.copy(l.geometry.boundingBox),s.min.add(l.position),s.max.add(l.position);const e=s.intersectsBox(t)||!0,o=s.intersectsBox(this.bounds);c.set(r,{pos:i.translation(),mesh:l}),e&&o&&n.push(l)}}return n},f=new x.Box3,b=new Map,g=new Map;let v=!0,M=performance.now(),B=!1;const S=function(e,t){let n=!1;return(async()=>{for(;!n;)await e(),await I(t)})(),()=>{n=!0}}(async()=>{if(B)return;const e=new x.Box3,t=m();for(const n of t){const t=b.get(n);!0!==t?.equals(n.position)&&(null!=t&&e.expandByPoint(t),e.expandByObject(n),b.set(n,n.position.clone()))}e.min.subScalar(50),e.max.addScalar(50);const n=r.getTilesForBounds(e);n.length>500&&console.warn("Too many tiles to update. Consider increasing tile size");const o=n.slice(0,500);if(0!=o.length){const n=[];for(const o of t)f.setFromObject(o),f.intersectsBox(e)&&n.push(o);let[s,i]=d(n);i=function(e,t,n){const o=new x.Vector3,s=[];for(let i=0;i<t.length;i+=3){let r=!0;for(let s=0;s<3;s++){const a=3*t[i+s];if(o.fromArray(e,a),!n.containsPoint(o)){r=!1;break}}r&&s.push(t[i],t[i+1],t[i+2])}return new Uint32Array(s)}(s,i,p),P&&(s=V(s),i=G(i));const a=v;v=!1,await Promise.all(o.map(e=>(M=performance.now(),r.buildTile(s,i,e,a).then(()=>{const t=e[0]+","+e[1];g.set(t,(g.get(t)??0)+1),this.debug})))).then(()=>{this.debug,B=!1})}else B=!1},this.refreshMs??1e4);this.disposed.subscribe(()=>S()),r.onNavMeshUpdate.pipe(y(this.disposed),w(200)).subscribe(()=>{h.clear(),h.drawNavMesh(r.navMesh)}),console.log("Create navmesh with debug",this.debug),this.debug&&(this.object.rotation.set(0,0,0),this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.parent.add(h)),this.disposed.subscribe(()=>{r?.destroy(),h.removeFromParent(),h.dispose()});const z=performance.now()-l;z>1e3&&console.warn(`NavMesh update took ${z} ms. Consider changing tileSize or other parameter that may affect performance`)}};e([z(),t("design:type",Boolean)],q.prototype,"debug",void 0),e([z(),t("design:type",Number)],q.prototype,"walkableClimb",void 0),e([z({range:[0,89]}),t("design:type",Number)],q.prototype,"walkableSlopeAngle",void 0),e([z(),t("design:type",Number)],q.prototype,"walkableHeight",void 0),e([z({range:[.01,10]}),t("design:type",Number)],q.prototype,"cellSize",void 0),q=e([B()],q);export default q;const O=new Map,W=new WeakMap;function _(e){if(e.shape instanceof l)return function(e){const t=e.shape;if(t.type!==c.HeightField)throw new Error("The provided collider is not a height field.");let n=!1;const o=t,s=o.heights,i=o.nrows,r=o.ncols,a=o.scale.x,l=o.scale.z,h=o.scale.y,p=i+1,u=new x.PlaneGeometry(l,a,r,i);u.rotateX(-Math.PI/2);const d=u.attributes.position.array;let m=0;for(let e=0;e<p;e++)for(let t=0;t<p;t++)d[m+1]=s[t*p+e]*h,m+=3,0!=d[m+1]&&(n=!0);if(!n){const e=new x.PlaneGeometry(a,l,2,2);return e.rotateX(-Math.PI/2),e}return u}(e);if(e.shape instanceof n)return new x.SphereGeometry(e.shape.radius);if(e.shape instanceof r){const t=e.shape.halfExtents;return new x.BoxGeometry(2*t.x,2*t.y,2*t.z)}if(e.shape instanceof i){const t=function(e){const t=W.get(e);if(void 0!==t)return t;const n=new Uint32Array(e.buffer,e.byteOffset,e.byteLength>>>2);let o=2166136261;for(let e=0;e<n.length;e++)o=Math.imul(o^n[e],16777619)>>>0;return W.set(e,o),o}(e.shape.vertices);let n=O.get(t);return n||(n=function(e){const t=[];for(let n=0;n<e.length;n+=3)t.push(new x.Vector3(e[n],e[n+1],e[n+2]));const n=(new M).setFromPoints(t),o=[];n.faces.forEach(e=>{const t=e.edge.head().point,n=e.edge.next.head().point,s=e.edge.next.next.head().point;o.push(t.x,t.y,t.z),o.push(n.x,n.y,n.z),o.push(s.x,s.y,s.z)});const s=new x.BufferGeometry;return s.setAttribute("position",new x.Float32BufferAttribute(o,3)),s}(e.shape.vertices),O.set(t,n)),n}if(e.shape instanceof h){const t=e.shape.vertices,n=e.shape.indices;let o=new x.BufferGeometry;return o.setAttribute("position",new x.Float32BufferAttribute(t,3)),null!=n?o.setIndex(new x.Uint16BufferAttribute(n,1)):o=v.mergeVertices(o),o.computeVertexNormals(),o}if(e.shape instanceof a){const t=e.shape.halfHeight,n=e.shape.radius;return new x.CylinderGeometry(n,n,2*t)}if(e.shape instanceof s){const t=e.shape.halfHeight,n=e.shape.radius;return new x.ConeGeometry(n,2*t)}if(e.shape instanceof o){const t=e.shape.halfHeight,n=e.shape.radius;return new x.CapsuleGeometry(n,2*t)}return console.warn("Unsupported shape",e.shape.type,e),null}function L(e){const t=_(e);if(null==t)return null;const n=J,o=new x.Mesh(t,n);return o.geometry.computeBoundingBox(),o.geometry.scale(1.01,1.01,1.01),o}function X(e,t){const n=e.translation(),o=e.rotation();t.position.set(n.x,n.y,n.z),t.quaternion.set(o.x,o.y,o.z,o.w)}const $=new x.Box3,J=new x.MeshBasicMaterial({wireframe:!1,color:16711680,side:x.FrontSide});/*
1
+ import{__decorate as e,__metadata as t}from"tslib";import{Ball as n,Capsule as s,Cone as o,ConvexPolyhedron as i,Cuboid as r,Cylinder as a,Heightfield as l,ShapeType as c,TriMesh as h}from"@dimforge/rapier3d-simd-compat";import{init as p}from"@recast-navigation/core";import{DebugDrawer as u,getPositionsAndIndices as d}from"@recast-navigation/three";import{BehaviorSubject as m,Subject as f,debounceTime as w,filter as b,firstValueFrom as g,takeUntil as y}from"rxjs";import*as x from"three";import{BufferGeometryUtils as v,ConvexHull as M}from"three/examples/jsm/Addons.js";import{Actor as B,BaseActor as S,Parameter as z,PhysicsSystem as A,ViewController as k,World as C,attach as j,inject as F}from"../../";import{sleepDelay as I}from"../../../utils/async";import{hasSharedArrayBufferSupport as P,toSharedFloat32Array as V,toSharedUint32Array as G}from"../../../utils/buffer";import{DynamicTiledNavMesh as N}from"../../ai/dynamic-tiled-navmesh";import{TriggerVolumeMesh as H}from"./components/volume-editor-component";var D;!function(e){e[e.none=0]="none",e[e.starting=1]="starting",e[e.started=2]="started"}(D||(D={}));let E=D.none,T=new m(!1);export async function safeRecastInit(){return E===D.none?(E=D.starting,p().then(()=>{T.next(!0),E=D.started})):g(T.pipe(b(e=>e)))}new x.Box3(new x.Vector3(-100,-100,-100),new x.Vector3(100,100,100));const R=navigator.hardwareConcurrency??1;let U=!1,q=class extends S{constructor(){super(...arguments),this.physics=F(A),this.view=F(k),this.world=F(C),this.editorVisualisation=j(H),this.debug=!0,this.refreshMs=4e3,this.tileSize=50,this.walkableClimb=.3,this.walkableSlopeAngle=45,this.walkableHeight=2,this.cellSize=.2,this.bounds=new x.Box3}async onInit(){U||(await safeRecastInit(),U=!0),setTimeout(()=>{this.init()},10),this.recreateInterval=setInterval(()=>{if("_hology_transform_group"===this.object.parent?.name)return;$.setFromCenterAndSize(this.position,this.object.scale).equals(this.bounds)||(this.disposed.next(!0),this.disposed=new f,this.init())},2e3)}onEndPlay(){clearInterval(this.recreateInterval)}init(){this.bounds.setFromCenterAndSize(this.position,this.object.scale);const e=this.bounds.max.x-this.bounds.min.x,t=this.bounds.max.z-this.bounds.min.z,n=Math.max(1,Math.min(e,t)),s=Math.min(400,Math.max(50,Math.ceil(n/2))),o=Math.max(this.cellSize,.01),i={tileSize:Math.max(32,Math.floor(s/o)),walkableClimb:this.walkableClimb/o,walkableSlopeAngle:this.walkableSlopeAngle,walkableRadius:2,walkableHeight:this.walkableHeight/o,detailSampleDist:1,minRegionArea:6,mergeRegionArea:400,cs:o,ch:o,maxSimplificationError:1.3,maxEdgeLen:200},r=new N({navMeshBounds:this.bounds,recastConfig:i,maxTiles:1024,workers:R,cacheId:"nav"+this.object.userData?.src?.id});this.navMesh=r.navMesh;const a=this.tileSize*i.cs*2,l=performance.now(),c=new Map,h=new u;h.userData.isDebugDrawer=!0;r.navMesh;const p=this.bounds,m=()=>{const e=this.view.getCamera().getWorldPosition(new x.Vector3),t=new x.Box3((new x.Vector3).copy(e).subScalar(a),(new x.Vector3).copy(e).addScalar(a)),n=[],s=this.physics.world.bodies;if(null==s)return[];const o=new x.Box3;for(const e of s.getAll())for(let s=0,i=e.numColliders();s<i;s++){const i=e.collider(s);if(i.isSensor()||null!=i.parent().userData&&!0===i.parent().userData.ignoreForNavMesh)continue;const r=e.handle+","+s,a=c.get(r)?.mesh,l=a??L(i);if(X(i,l),null!=l){o.copy(l.geometry.boundingBox),o.min.add(l.position),o.max.add(l.position);const e=o.intersectsBox(t)||!0,s=o.intersectsBox(this.bounds);c.set(r,{pos:i.translation(),mesh:l}),e&&s&&n.push(l)}}return n},f=new x.Box3,b=new Map,g=new Map;let v=!0,M=performance.now(),B=!1;const S=function(e,t){let n=!1;return(async()=>{for(;!n;)await e(),await I(t)})(),()=>{n=!0}}(async()=>{if(B)return;const e=new x.Box3,t=m();for(const n of t){const t=b.get(n);!0!==t?.equals(n.position)&&(null!=t&&e.expandByPoint(t),e.expandByObject(n),b.set(n,n.position.clone()))}e.min.subScalar(50),e.max.addScalar(50);const n=r.getTilesForBounds(e);n.length>500&&console.warn("Too many tiles to update. Consider increasing tile size");const s=n.slice(0,500);if(0!=s.length){const n=[];for(const s of t)f.setFromObject(s),f.intersectsBox(e)&&n.push(s);let[o,i]=d(n);i=function(e,t,n){const s=new x.Vector3,o=[];for(let i=0;i<t.length;i+=3){let r=!0;for(let o=0;o<3;o++){const a=3*t[i+o];if(s.fromArray(e,a),!n.containsPoint(s)){r=!1;break}}r&&o.push(t[i],t[i+1],t[i+2])}return new Uint32Array(o)}(o,i,p),P&&(o=V(o),i=G(i));const a=v;v=!1,await Promise.all(s.map(e=>(M=performance.now(),r.buildTile(o,i,e,a).then(()=>{const t=e[0]+","+e[1];g.set(t,(g.get(t)??0)+1),this.debug})))).then(()=>{this.debug,B=!1})}else B=!1},this.refreshMs??1e4);this.disposed.subscribe(()=>S()),r.onNavMeshUpdate.pipe(y(this.disposed),w(200)).subscribe(()=>{h.clear(),h.drawNavMesh(r.navMesh)}),console.log("Create navmesh with debug",this.debug),this.debug&&(this.object.rotation.set(0,0,0),this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.parent.add(h)),this.disposed.subscribe(()=>{r?.destroy(),h.removeFromParent(),h.dispose()});const z=performance.now()-l;z>1e3&&console.warn(`NavMesh update took ${z} ms. Consider changing tileSize or other parameter that may affect performance`)}};e([z(),t("design:type",Boolean)],q.prototype,"debug",void 0),e([z(),t("design:type",Number)],q.prototype,"walkableClimb",void 0),e([z({range:[0,89]}),t("design:type",Number)],q.prototype,"walkableSlopeAngle",void 0),e([z(),t("design:type",Number)],q.prototype,"walkableHeight",void 0),e([z({range:[.01,10]}),t("design:type",Number)],q.prototype,"cellSize",void 0),q=e([B()],q);export default q;const O=new Map,W=new WeakMap;function _(e){if(e.shape instanceof l)return function(e){const t=e.shape;if(t.type!==c.HeightField)throw new Error("The provided collider is not a height field.");let n=!1;const s=t,o=s.heights,i=s.nrows,r=s.ncols,a=s.scale.x,l=s.scale.z,h=s.scale.y,p=i+1,u=new x.PlaneGeometry(l,a,r,i);u.rotateX(-Math.PI/2);const d=u.attributes.position.array;let m=0;for(let e=0;e<p;e++)for(let t=0;t<p;t++)d[m+1]=o[t*p+e]*h,m+=3,0!=d[m+1]&&(n=!0);if(!n){const e=new x.PlaneGeometry(a,l,2,2);return e.rotateX(-Math.PI/2),e}return u}(e);if(e.shape instanceof n)return new x.SphereGeometry(e.shape.radius);if(e.shape instanceof r){const t=e.shape.halfExtents;return new x.BoxGeometry(2*t.x,2*t.y,2*t.z)}if(e.shape instanceof i){const t=function(e){const t=W.get(e);if(void 0!==t)return t;const n=new Uint32Array(e.buffer,e.byteOffset,e.byteLength>>>2);let s=2166136261;for(let e=0;e<n.length;e++)s=Math.imul(s^n[e],16777619)>>>0;return W.set(e,s),s}(e.shape.vertices);let n=O.get(t);return n||(n=function(e){const t=[];for(let n=0;n<e.length;n+=3)t.push(new x.Vector3(e[n],e[n+1],e[n+2]));const n=(new M).setFromPoints(t),s=[];n.faces.forEach(e=>{const t=e.edge.head().point,n=e.edge.next.head().point,o=e.edge.next.next.head().point;s.push(t.x,t.y,t.z),s.push(n.x,n.y,n.z),s.push(o.x,o.y,o.z)});const o=new x.BufferGeometry;return o.setAttribute("position",new x.Float32BufferAttribute(s,3)),o}(e.shape.vertices),O.set(t,n)),n}if(e.shape instanceof h){const t=e.shape.vertices,n=e.shape.indices;let s=new x.BufferGeometry;return s.setAttribute("position",new x.Float32BufferAttribute(t,3)),null!=n?s.setIndex(new x.Uint16BufferAttribute(n,1)):s=v.mergeVertices(s),s.computeVertexNormals(),s}if(e.shape instanceof a){const t=e.shape.halfHeight,n=e.shape.radius;return new x.CylinderGeometry(n,n,2*t)}if(e.shape instanceof o){const t=e.shape.halfHeight,n=e.shape.radius;return new x.ConeGeometry(n,2*t)}if(e.shape instanceof s){const t=e.shape.halfHeight,n=e.shape.radius;return new x.CapsuleGeometry(n,2*t)}return console.warn("Unsupported shape",e.shape.type,e),null}function L(e){const t=_(e);if(null==t)return null;const n=J,s=new x.Mesh(t,n);return s.geometry.computeBoundingBox(),s.geometry.scale(1.01,1.01,1.01),s}function X(e,t){const n=e.translation(),s=e.rotation();t.position.set(n.x,n.y,n.z),t.quaternion.set(s.x,s.y,s.z,s.w)}const $=new x.Box3,J=new x.MeshBasicMaterial({wireframe:!1,color:16711680,side:x.FrontSide});/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -16,6 +16,7 @@ export declare class ThirdPersonCameraComponent extends ActorComponent {
16
16
  collisionSphereRadius: number;
17
17
  smoothCamera: boolean;
18
18
  smoothSpeed: number;
19
+ teleportSnapDistance: number;
19
20
  camera: PerspectiveCamera;
20
21
  distance: number;
21
22
  minDistance: number;
@@ -58,6 +59,8 @@ export declare class ThirdPersonCameraComponent extends ActorComponent {
58
59
  private updateCameraPosition;
59
60
  private prevLookAt;
60
61
  private smoothedLookAt;
62
+ private previousTargetLookAt;
63
+ private hasSmoothedLookAt;
61
64
  private smoothedRotX;
62
65
  private smoothedRotY;
63
66
  private smoothZoom;
@@ -1,4 +1,4 @@
1
- import{__decorate as t,__metadata as e}from"tslib";import{ActorComponent as i,Component as o}from"../component.js";import{Vector3 as s,MathUtils as n,PerspectiveCamera as h,Object3D as r}from"three";import{ViewController as a}from"../../services/render.js";import{DecimalInput as c,RestrictedRotationInput as d}from"../../input/index.js";import{PhysicsSystem as m}from"../../services/physics/physics-system.js";import{Parameter as l}from"../../../shader/parameter.js";import{World as p}from"../../services/world.js";import{inject as u}from"../../inject.js";import{ease as f}from"@hology/nebula";const v=void 0!==window&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);let k=class extends i{constructor(){super(),this.viewController=u(a),this.physicsSystem=u(m),this.aspect=this.viewController.htmlElement.clientWidth/this.viewController.htmlElement.clientHeight,this.near=.5,this.far=500,this.viewAngle=v?30:45,this.collision=!0,this.collisionSphereRadius=.25,this.smoothCamera=!1,this.smoothSpeed=10,this.camera=new h(this.viewAngle,this.aspect,this.near,this.far),this.distance=9,this.minDistance=1.5,this.maxDistance=this.distance,this.height=3,this.offsetX=-1,this.offsetZ=1.5,this.autoActivate=!0,this.bounceBackSpeed=3,this.restrictedDistance=Math.max(this.distance,this.maxDistance),this.rotationInput=new d(-Math.PI/4,Math.PI/2-.7),this.zoomInput=new c(1,0,1),this.offset=new s,this.lookAtOffset=new s(this.offsetX,0,this.offsetZ),this.fixedBehind=!0,this.world=u(p),this.activated=!1,this.isMouseLocked=!1,this.prevFixedBehind=!1,this.blendDurationLeft=0,this.pointerEventsRegistered=!1,this.canvas=null,this.pointerLockInactivatedAt=null,this.onMouseDown=t=>{this.isMouseLocked||"mouse"!==t.pointerType||this.hideCursor()},this.onKeyDown=t=>{"Escape"===t.key&&this.showCursor()},this.onPointerLockChange=()=>{this.isMouseLocked=null!=document.pointerLockElement||null!=document.mozPointerLockElement,this.isMouseLocked||(this.pointerLockInactivatedAt=performance.now(),this.element.style.cursor="default")},this.prevLookAt=new s,this.smoothedLookAt=new s,this.smoothedRotX=0,this.smoothedRotY=0,this.smoothZoom=0}async onInit(){this.prevFixedBehind=this.fixedBehind,this.world.scene.add(this.camera),this.rotationInput.rotation.copy(this.actor.rotation),this.smoothedRotX=this.rotationInput.rotation.x,this.smoothedRotY=this.rotationInput.rotation.y,this.restrictedDistance=Math.max(this.distance,this.maxDistance),this.lookAtOffset.set(this.offsetX,0,this.offsetZ),this.smoothZoom=this.zoomInput.value,this.autoActivate&&this.activate(),this.disposed.subscribe(()=>{this.unregisterPointerEvents()})}activate(){this.activated=!0,this.viewController.setCamera(this.camera),this.isMouseLocked=null!=document.pointerLockElement||null!=document.mozPointerLockElement,this.registerPointerEvents()}deactivate(){this.activated=!1,this.isMouseLocked=!1,this.unregisterPointerEvents()}registerPointerEvents(){if(this.pointerEventsRegistered||null==document.body.requestPointerLock)return;const t=this.element;t.addEventListener("pointerdown",this.onMouseDown),t.addEventListener("keydown",this.onKeyDown),document.addEventListener("pointerlockchange",this.onPointerLockChange,!1),this.pointerEventsRegistered=!0}unregisterPointerEvents(){if(!this.pointerEventsRegistered)return;const t=this.element;t.removeEventListener("pointerdown",this.onMouseDown),t.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("pointerlockchange",this.onPointerLockChange,!1),this.pointerEventsRegistered=!1}onLateUpdate(t){this.activated&&this.setFromRotation(t)}get element(){return this.viewController.htmlElement}hideCursor(){null!=this.pointerLockInactivatedAt&&performance.now()-this.pointerLockInactivatedAt<1600||(this.element.style.cursor="none",null==this.canvas&&(this.canvas=this.element.getElementsByTagName("canvas")[0]),this.canvas&&this.canvas.requestPointerLock&&(this.canvas.requestPointerLock({unadjustedMovement:!0}),this.isMouseLocked=!0))}showCursor(){this.pointerLockInactivatedAt=performance.now(),this.element.style.cursor="default",null==document.pointerLockElement&&null==document.mozPointerLockElement||window.document.exitPointerLock(),this.isMouseLocked=!1}setFromRotation(t){this.lookAtOffset.set(this.offsetX,0,this.offsetZ),this.fixedBehind!==this.prevFixedBehind?(this.blendDurationLeft=1,this.prevFixedBehind=this.fixedBehind):this.blendDurationLeft>0&&(this.blendDurationLeft-=t),this.collision&&this.checkForCollision(t);let e=this.zoomInput.value,i=this.rotationInput.rotation.x,o=this.rotationInput.rotation.y;if(this.smoothCamera){const s=1-Math.exp(-this.smoothSpeed*t*2);this.smoothedRotX=n.lerp(this.smoothedRotX,i,s),this.smoothedRotY=n.lerp(this.smoothedRotY,o,s),i=this.smoothedRotX,o=this.smoothedRotY,this.smoothZoom=n.lerp(this.smoothZoom,e,.4*s),e=this.smoothZoom}else this.smoothedRotX=i,this.smoothedRotY=o;const s=n.clamp(Math.min(this.restrictedDistance,this.distance),Math.min(this.minDistance,this.restrictedDistance),Math.max(this.distance*e,this.minDistance)),h=Math.cos(i)*s,r=this.fixedBehind?0:o;this.offset.x=Math.sin(-r)*h,this.offset.y=Math.sin(i)*s+2,this.offset.z=Math.cos(-r)*-h,this.fixedBehind&&this.offset.add(this.lookAtOffset),this.updateCameraPosition(t)}checkForCollision(t){const e=this.getLookAtPosition(),i=this.camera.getWorldPosition(x),o=g.subVectors(i,e),s=o.length();if(s<.001)return;o.divideScalar(s);const h=this.physicsSystem.sphereCast(e,this.collisionSphereRadius,o,this.distance,void 0,{excludeActor:this.actor,excludeTriggers:!0,collisionFilter:-2});if(h.hasHit){const e=Math.max(this.minDistance,h.distance-.05);e<this.restrictedDistance?this.restrictedDistance=e:this.restrictedDistance=n.lerp(this.restrictedDistance,e,n.clamp(this.bounceBackSpeed*t,0,1))}else this.restrictedDistance=n.lerp(this.restrictedDistance,this.distance,n.clamp(this.bounceBackSpeed*t,0,1))}getLookAtPosition(){const t=y;return t.set(0,0,0),t.y=this.height,this.fixedBehind&&t.add(this.lookAtOffset),t.applyMatrix4(this.actor.object.matrixWorld),t}updateCameraPosition(t){this.actor.object.updateWorldMatrix(!0,!1),this.fixedBehind?(L.position.set(this.offset.x,this.offset.y,this.offset.z),L.rotation.set(0,0,0),L.scale.set(1,1,1),L.applyMatrix4(this.actor.object.matrix)):L.position.copy(this.actor.position).add(this.offset);const e=f.easeInOutCubic(1-this.blendDurationLeft);if(this.blendDurationLeft>0){const t=this.getLookAtPosition();this.prevLookAt.lerp(t,e),this.camera.lookAt(this.prevLookAt),this.camera.position.lerp(L.position,e),this.smoothedLookAt.copy(this.prevLookAt)}else{const e=this.getLookAtPosition();if(this.smoothCamera){const i=1-Math.exp(-this.smoothSpeed*t);this.smoothedLookAt.distanceToSquared(e)>1?this.smoothedLookAt.copy(e):this.smoothedLookAt.lerp(e,i)}else this.smoothedLookAt.copy(e);w.subVectors(L.position,e),this.camera.position.copy(this.smoothedLookAt).add(w),this.camera.lookAt(this.smoothedLookAt),this.prevLookAt.copy(this.smoothedLookAt)}}};t([l(),e("design:type",Number)],k.prototype,"near",void 0),t([l(),e("design:type",Number)],k.prototype,"far",void 0),t([l(),e("design:type",Number)],k.prototype,"viewAngle",void 0),t([l(),e("design:type",Boolean)],k.prototype,"collision",void 0),t([l(),e("design:type",Number)],k.prototype,"collisionSphereRadius",void 0),t([l(),e("design:type",Boolean)],k.prototype,"smoothCamera",void 0),t([l(),e("design:type",Number)],k.prototype,"smoothSpeed",void 0),k=t([o(),e("design:paramtypes",[])],k);export{k as ThirdPersonCameraComponent};const L=new r,y=new s,w=new s,g=new s,x=(new s,new s);export class ThirdPartyCameraComponent extends k{}/*
1
+ import{__decorate as t,__metadata as e}from"tslib";import{ActorComponent as o,Component as i}from"../component.js";import{Vector3 as s,MathUtils as n,PerspectiveCamera as h,Object3D as r}from"three";import{ViewController as a}from"../../services/render.js";import{DecimalInput as c,RestrictedRotationInput as d}from"../../input/index.js";import{PhysicsSystem as m}from"../../services/physics/physics-system.js";import{Parameter as p}from"../../../shader/parameter.js";import{World as l}from"../../services/world.js";import{inject as u}from"../../inject.js";import{ease as f}from"@hology/nebula";const v=void 0!==window&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);let k=class extends o{constructor(){super(),this.viewController=u(a),this.physicsSystem=u(m),this.aspect=this.viewController.htmlElement.clientWidth/this.viewController.htmlElement.clientHeight,this.near=.5,this.far=500,this.viewAngle=v?30:45,this.collision=!0,this.collisionSphereRadius=.25,this.smoothCamera=!1,this.smoothSpeed=10,this.teleportSnapDistance=5,this.camera=new h(this.viewAngle,this.aspect,this.near,this.far),this.distance=9,this.minDistance=1.5,this.maxDistance=this.distance,this.height=3,this.offsetX=-1,this.offsetZ=1.5,this.autoActivate=!0,this.bounceBackSpeed=3,this.restrictedDistance=Math.max(this.distance,this.maxDistance),this.rotationInput=new d(-Math.PI/4,Math.PI/2-.7),this.zoomInput=new c(1,0,1),this.offset=new s,this.lookAtOffset=new s(this.offsetX,0,this.offsetZ),this.fixedBehind=!0,this.world=u(l),this.activated=!1,this.isMouseLocked=!1,this.prevFixedBehind=!1,this.blendDurationLeft=0,this.pointerEventsRegistered=!1,this.canvas=null,this.pointerLockInactivatedAt=null,this.onMouseDown=t=>{this.isMouseLocked||"mouse"!==t.pointerType||this.hideCursor()},this.onKeyDown=t=>{"Escape"===t.key&&this.showCursor()},this.onPointerLockChange=()=>{this.isMouseLocked=null!=document.pointerLockElement||null!=document.mozPointerLockElement,this.isMouseLocked||(this.pointerLockInactivatedAt=performance.now(),this.element.style.cursor="default")},this.prevLookAt=new s,this.smoothedLookAt=new s,this.previousTargetLookAt=new s,this.hasSmoothedLookAt=!1,this.smoothedRotX=0,this.smoothedRotY=0,this.smoothZoom=0}async onInit(){this.prevFixedBehind=this.fixedBehind,this.world.scene.add(this.camera),this.rotationInput.rotation.copy(this.actor.rotation),this.smoothedRotX=this.rotationInput.rotation.x,this.smoothedRotY=this.rotationInput.rotation.y,this.restrictedDistance=Math.max(this.distance,this.maxDistance),this.lookAtOffset.set(this.offsetX,0,this.offsetZ),this.smoothZoom=this.zoomInput.value,this.autoActivate&&this.activate(),this.disposed.subscribe(()=>{this.unregisterPointerEvents()})}activate(){this.activated=!0,this.hasSmoothedLookAt=!1,this.viewController.setCamera(this.camera),this.isMouseLocked=null!=document.pointerLockElement||null!=document.mozPointerLockElement,this.registerPointerEvents()}deactivate(){this.activated=!1,this.isMouseLocked=!1,this.unregisterPointerEvents()}registerPointerEvents(){if(this.pointerEventsRegistered||null==document.body.requestPointerLock)return;const t=this.element;t.addEventListener("pointerdown",this.onMouseDown),t.addEventListener("keydown",this.onKeyDown),document.addEventListener("pointerlockchange",this.onPointerLockChange,!1),this.pointerEventsRegistered=!0}unregisterPointerEvents(){if(!this.pointerEventsRegistered)return;const t=this.element;t.removeEventListener("pointerdown",this.onMouseDown),t.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("pointerlockchange",this.onPointerLockChange,!1),this.pointerEventsRegistered=!1}onLateUpdate(t){this.activated&&this.setFromRotation(t)}get element(){return this.viewController.htmlElement}hideCursor(){null!=this.pointerLockInactivatedAt&&performance.now()-this.pointerLockInactivatedAt<1600||(this.element.style.cursor="none",null==this.canvas&&(this.canvas=this.element.getElementsByTagName("canvas")[0]),this.canvas&&this.canvas.requestPointerLock&&(this.canvas.requestPointerLock({unadjustedMovement:!0}),this.isMouseLocked=!0))}showCursor(){this.pointerLockInactivatedAt=performance.now(),this.element.style.cursor="default",null==document.pointerLockElement&&null==document.mozPointerLockElement||window.document.exitPointerLock(),this.isMouseLocked=!1}setFromRotation(t){this.lookAtOffset.set(this.offsetX,0,this.offsetZ),this.fixedBehind!==this.prevFixedBehind?(this.blendDurationLeft=1,this.prevFixedBehind=this.fixedBehind):this.blendDurationLeft>0&&(this.blendDurationLeft-=t),this.collision&&this.checkForCollision(t);let e=this.zoomInput.value,o=this.rotationInput.rotation.x,i=this.rotationInput.rotation.y;if(this.smoothCamera){const s=1-Math.exp(-this.smoothSpeed*t*2);this.smoothedRotX=n.lerp(this.smoothedRotX,o,s),this.smoothedRotY=n.lerp(this.smoothedRotY,i,s),o=this.smoothedRotX,i=this.smoothedRotY,this.smoothZoom=n.lerp(this.smoothZoom,e,.4*s),e=this.smoothZoom}else this.smoothedRotX=o,this.smoothedRotY=i;const s=n.clamp(Math.min(this.restrictedDistance,this.distance),Math.min(this.minDistance,this.restrictedDistance),Math.max(this.distance*e,this.minDistance)),h=Math.cos(o)*s,r=this.fixedBehind?0:i;this.offset.x=Math.sin(-r)*h,this.offset.y=Math.sin(o)*s+2,this.offset.z=Math.cos(-r)*-h,this.fixedBehind&&this.offset.add(this.lookAtOffset),this.updateCameraPosition(t)}checkForCollision(t){const e=this.getLookAtPosition(),o=this.camera.getWorldPosition(w),i=A.subVectors(o,e),s=i.length();if(s<.001)return;i.divideScalar(s);const h=this.physicsSystem.sphereCast(e,this.collisionSphereRadius,i,this.distance,void 0,{excludeActor:this.actor,excludeTriggers:!0,collisionFilter:-2});if(h.hasHit){const e=Math.max(this.minDistance,h.distance-.05);e<this.restrictedDistance?this.restrictedDistance=e:this.restrictedDistance=n.lerp(this.restrictedDistance,e,n.clamp(this.bounceBackSpeed*t,0,1))}else this.restrictedDistance=n.lerp(this.restrictedDistance,this.distance,n.clamp(this.bounceBackSpeed*t,0,1))}getLookAtPosition(){const t=y;return t.set(0,0,0),t.y=this.height,this.fixedBehind&&t.add(this.lookAtOffset),t.applyMatrix4(this.actor.object.matrixWorld),t}updateCameraPosition(t){this.actor.object.updateWorldMatrix(!0,!1),this.fixedBehind?(L.position.set(this.offset.x,this.offset.y,this.offset.z),L.rotation.set(0,0,0),L.scale.set(1,1,1),L.applyMatrix4(this.actor.object.matrix)):L.position.copy(this.actor.position).add(this.offset);const e=f.easeInOutCubic(1-this.blendDurationLeft);if(this.blendDurationLeft>0){const t=this.getLookAtPosition();this.prevLookAt.lerp(t,e),this.camera.lookAt(this.prevLookAt),this.camera.position.lerp(L.position,e),this.smoothedLookAt.copy(this.prevLookAt),this.previousTargetLookAt.copy(t),this.hasSmoothedLookAt=!0}else{const e=this.getLookAtPosition();if(this.smoothCamera){const o=1-Math.exp(-this.smoothSpeed*t),i=Math.max(0,this.teleportSnapDistance);!this.hasSmoothedLookAt||this.previousTargetLookAt.distanceToSquared(e)>i*i?this.smoothedLookAt.copy(e):this.smoothedLookAt.lerp(e,o)}else this.smoothedLookAt.copy(e);this.previousTargetLookAt.copy(e),this.hasSmoothedLookAt=!0,g.subVectors(L.position,e),this.camera.position.copy(this.smoothedLookAt).add(g),this.camera.lookAt(this.smoothedLookAt),this.prevLookAt.copy(this.smoothedLookAt)}}};t([p(),e("design:type",Number)],k.prototype,"near",void 0),t([p(),e("design:type",Number)],k.prototype,"far",void 0),t([p(),e("design:type",Number)],k.prototype,"viewAngle",void 0),t([p(),e("design:type",Boolean)],k.prototype,"collision",void 0),t([p(),e("design:type",Number)],k.prototype,"collisionSphereRadius",void 0),t([p(),e("design:type",Boolean)],k.prototype,"smoothCamera",void 0),t([p(),e("design:type",Number)],k.prototype,"smoothSpeed",void 0),t([p(),e("design:type",Number)],k.prototype,"teleportSnapDistance",void 0),k=t([i(),e("design:paramtypes",[])],k);export{k as ThirdPersonCameraComponent};const L=new r,y=new s,g=new s,A=new s,w=(new s,new s);export class ThirdPartyCameraComponent extends k{}/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,4 +1,4 @@
1
- import{Container as t,Service as n,Inject as o}from"typedi";import{_setupActorUpdateEventHandlers as e}from"./actor.js";import{activeContainerInstance as r}from"./internal/container-map.js";import{randomString as i}from"../../utils/math.js";export class ActorComponent{constructor(){e.call(this)}onInit(){}onBeginPlay(){}onEndPlay(){}onUpdate(t){}onLateUpdate(t){}get disposed(){return this.actor.disposed}attach(t,n){return this.actor.attach(t,n)}}ActorComponent.__isActorComponent=!0;export function Component(t={inEditor:!1,editorOnly:!1}){const o=n({transient:!0});return function(n){n.__inEditor=t.inEditor,n.__onlyEditor=t.editorOnly,o(n)}}export function Attach(n={},e){return function(r,i,a){if(null==r)return void Reflect.defineMetadata("design:type",e,e.prototype,i);const c=e??Reflect.getMetadata("design:type",r,i);o(()=>c)(r,i,a);const s=t.handlers.find(t=>t.object===r&&t.propertyName===i&&t.index===a),d=s.value;s.value=t=>{const o=d(t);return Object.assign(o,n)}}}export function attach(n,o){const e=r.value??t.of("default"),a=i();e.set({id:a,type:n,transient:!0});const c=e.get(a);if(null!=o)for(const t of Object.keys(o))c[t]=o[t];return c}/*
1
+ import{Container as t,Service as o,Inject as n}from"typedi";import{_setupActorUpdateEventHandlers as e}from"./actor.js";import{activeContainerInstance as r}from"./internal/container-map.js";import{randomString as i}from"../../utils/math.js";import{actorConstructContext as a}from"./factory.js";export class ActorComponent{constructor(){this.actor=a.actor,e.call(this)}onInit(){}onBeginPlay(){}onEndPlay(){}onUpdate(t){}onLateUpdate(t){}get disposed(){return this.actor.disposed}attach(t,o){return this.actor.attach(t,o)}}ActorComponent.__isActorComponent=!0;export function Component(t={inEditor:!1,editorOnly:!1}){const n=o({transient:!0});return function(o){o.__inEditor=t.inEditor,o.__onlyEditor=t.editorOnly,n(o)}}export function Attach(o={},e){return function(r,i,a){if(null==r)return void Reflect.defineMetadata("design:type",e,e.prototype,i);const c=e??Reflect.getMetadata("design:type",r,i);n(()=>c)(r,i,a);const s=t.handlers.find(t=>t.object===r&&t.propertyName===i&&t.index===a),p=s.value;s.value=t=>{const n=p(t);return Object.assign(n,o)}}}export function attach(o,n){const e=r.value??t.of("default"),a=i();e.set({id:a,type:o,transient:!0});const c=e.get(a);if(null!=n)for(const t of Object.keys(n))c[t]=n[t];return c}/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -0,0 +1,16 @@
1
+ import { BaseActor } from "../actor";
2
+ export declare abstract class ActorController extends BaseActor {
3
+ isLocallyControlled: boolean;
4
+ }
5
+ export declare class BasePlayerController extends ActorController {
6
+ /**
7
+ * Whether this player controller is controlled by the local player.
8
+ * This is set when spawned as the local player controller on server (listend and standalone)
9
+ * or when the player controller is replicated to clients.
10
+ */
11
+ isLocallyControlled: boolean;
12
+ }
13
+ export declare class BaseAIController extends ActorController {
14
+ readonly isLocallyControlled = false;
15
+ }
16
+ //# sourceMappingURL=actor-controller.d.ts.map
@@ -0,0 +1,4 @@
1
+ import{BaseActor as o}from"../actor";export class ActorController extends o{constructor(){super(...arguments),this.isLocallyControlled=!1}}export class BasePlayerController extends ActorController{constructor(){super(...arguments),this.isLocallyControlled=!1}}export class BaseAIController extends ActorController{constructor(){super(...arguments),this.isLocallyControlled=!1}}/*
2
+ * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
+ * See the LICENSE.md file for details.
4
+ */
@@ -3,6 +3,9 @@ import { BaseActor } from './actor.js';
3
3
  import { type EngineEnvironment } from '../env.js';
4
4
  import { ActorProvider } from '../../scene/materializer.js';
5
5
  import { Vector3, Euler } from "three";
6
+ export declare let actorConstructContext: {
7
+ actor: BaseActor;
8
+ };
6
9
  export declare class ActorFactory implements ActorProvider<BaseActor> {
7
10
  private container;
8
11
  private env;
@@ -1,4 +1,4 @@
1
- import{__decorate as t,__metadata as i}from"tslib";import{ContainerInstance as n}from"typedi";import{Service as r}from"typedi";import{initComponents as e,initComponentsSync as o}from"./internal/component-init.js";import{activeContainerInstance as s,containerRefMap as c}from"./internal/container-map.js";let a=class{constructor(t,i){this.container=t,this.env=i,this.classes={}}get inEditor(){return this.env.inEditor??!1}async create(t,i,n,r){const e=this._createActor(t,i,n);return!0!==r&&await this.initActor(e),e}createSync(t,i,n,r){const e=this._createActor(t,i,n);return!0!==r&&this.initActorSync(e),e}_createActor(t,i,n){const r=this.container;s.value=r;const e=(1e4*Math.random()).toString();r.set({id:e,type:t,transient:!0});const o=r.get(e);return s.value=null,r.remove(t),c.set(o,r),i&&o.object.position.copy(i),n&&o.object.rotation.copy(n),o}async initActor(t){await e(t,t,this.env.inEditor??!1),await t.onInit(),t.__isInitialised=!0}initActorSync(t){o(t,t,this.env.inEditor??!1),t.onInit(),t.__isInitialised=!0}};a=t([r(),i("design:paramtypes",[n,Object])],a);export{a as ActorFactory};/*
1
+ import{__decorate as t,__metadata as i}from"tslib";import{ContainerInstance as n}from"typedi";import{Service as o}from"typedi";import{initComponents as r,initComponentsSync as e}from"./internal/component-init.js";import{activeContainerInstance as c,containerRefMap as s}from"./internal/container-map.js";export let actorConstructContext={actor:null};let a=class{constructor(t,i){this.container=t,this.env=i,this.classes={}}get inEditor(){return this.env.inEditor??!1}async create(t,i,n,o){const r=this._createActor(t,i,n);return!0!==o&&await this.initActor(r),r}createSync(t,i,n,o){const r=this._createActor(t,i,n);return!0!==o&&this.initActorSync(r),r}_createActor(t,i,n){const o=this.container;c.value=o;const r=(1e4*Math.random()).toString();o.set({id:r,type:t,transient:!0});const e=o.get(r);return actorConstructContext.actor=null,c.value=null,o.remove(t),s.set(e,o),i&&e.object.position.copy(i),n&&e.object.rotation.copy(n),e}async initActor(t){await r(t,t,this.env.inEditor??!1),await t.onInit(),t.__isInitialised=!0}initActorSync(t){e(t,t,this.env.inEditor??!1),t.onInit(),t.__isInitialised=!0}};a=t([o(),i("design:paramtypes",[n,Object])],a);export{a as ActorFactory};/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -7,7 +7,11 @@ export { TriggerVolume, TriggerVolumeComponent } from './builtin/trigger-volume.
7
7
  export { PositionalAudioActor, PositionalAudioComponent } from './builtin/positional-audio-actor.js';
8
8
  export * from './builtin/components/mesh-component.js';
9
9
  export * from './builtin/components/character/character-movement.js';
10
+ export * from './builtin/components/character/character-movement-policy.js';
11
+ export * from './builtin/components/character/old-character-movement.js';
12
+ export * from './builtin/components/character/character-movement-like.js';
10
13
  export * from './builtin/components/character/modes.js';
11
14
  export * from './builtin/components/character/character-animation.js';
15
+ export * from './controller/actor-controller.js';
12
16
  export { builtInComponents } from './builtin/components/index.js';
13
17
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,4 @@
1
- export{CameraActor}from"./builtin/camera-actor.js";export{CameraComponent}from"./camera/camera-component.js";export{FirstPersonCameraComponent}from"./camera/first-person-camera-component.js";export{ThirdPersonCameraComponent,ThirdPartyCameraComponent}from"./camera/third-person-camera-component.js";export{SpawnPoint}from"./builtin/spawn-point.js";export{TriggerVolume,TriggerVolumeComponent}from"./builtin/trigger-volume.js";export{PositionalAudioActor,PositionalAudioComponent}from"./builtin/positional-audio-actor.js";export*from"./builtin/components/mesh-component.js";export*from"./builtin/components/character/character-movement.js";export*from"./builtin/components/character/modes.js";export*from"./builtin/components/character/character-animation.js";export{builtInComponents}from"./builtin/components/index.js";/*
1
+ export{CameraActor}from"./builtin/camera-actor.js";export{CameraComponent}from"./camera/camera-component.js";export{FirstPersonCameraComponent}from"./camera/first-person-camera-component.js";export{ThirdPersonCameraComponent,ThirdPartyCameraComponent}from"./camera/third-person-camera-component.js";export{SpawnPoint}from"./builtin/spawn-point.js";export{TriggerVolume,TriggerVolumeComponent}from"./builtin/trigger-volume.js";export{PositionalAudioActor,PositionalAudioComponent}from"./builtin/positional-audio-actor.js";export*from"./builtin/components/mesh-component.js";export*from"./builtin/components/character/character-movement.js";export*from"./builtin/components/character/character-movement-policy.js";export*from"./builtin/components/character/old-character-movement.js";export*from"./builtin/components/character/character-movement-like.js";export*from"./builtin/components/character/modes.js";export*from"./builtin/components/character/character-animation.js";export*from"./controller/actor-controller.js";export{builtInComponents}from"./builtin/components/index.js";/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */