@hology/core 0.0.132 → 0.0.133

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.
@@ -1 +1 @@
1
- {"version":3,"file":"character-movement.d.ts","sourceRoot":"","sources":["../../../../../../src/gameplay/actors/builtin/components/character/character-movement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAC/F,OAAO,EAAgC,aAAa,EAAiB,MAAM,4DAA4D,CAAC;AACxI,OAAO,EAAoB,OAAO,EAAwB,eAAe,EAAE,MAAM,OAAO,CAAC;AACzF,OAAO,EAAE,cAAc,EAAa,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAkBnD,qBACa,0BAA2B,SAAQ,cAAc;IA0D9C,OAAO,CAAC,aAAa;IAvDjC,QAAQ,CAAC,cAAc,YAAkB;IACzC,QAAQ,CAAC,SAAS,cAAoB;IACtC,QAAQ,CAAC,WAAW,cAAoB;IACxC,QAAQ,CAAC,aAAa,gBAAsB;IAGrC,eAAe,SAAI;IAGnB,QAAQ,SAAI;IACZ,iBAAiB,SAAI;IACrB,cAAc,SAAK;IACnB,YAAY,SAAI;IAChB,sBAAsB,SAAK;IAC3B,oBAAoB,UAAQ;IAC5B,eAAe,EAAE,MAAM,CAAO;IAC9B,cAAc,EAAE,MAAM,CAAI;IAC1B,cAAc,EAAE,MAAM,CAAK;IAC3B,SAAS,UAAQ;IACjB,IAAI,SAAK;IACT,YAAY,UAAO;IACnB,kBAAkB,SAAyB;IAC3C,kBAAkB,SAAyB;IAC3C,4BAA4B,UAAO;IAC1C,oCAAoC;IAC7B,kBAAkB,UAAQ;IACjC,IAAW,gBAAgB,IACW,MAAM,CADuB;IACnE,IAAW,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAA4G;IACxJ,IAAW,sBAAsB,IAAI,OAAO,CAAmD;I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AAO,CAAC,WAAW;CAQtB"}
1
+ {"version":3,"file":"character-movement.d.ts","sourceRoot":"","sources":["../../../../../../src/gameplay/actors/builtin/components/character/character-movement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAC/F,OAAO,EAAgC,aAAa,EAAiB,MAAM,4DAA4D,CAAC;AACxI,OAAO,EAAoB,OAAO,EAAwB,eAAe,EAAE,MAAM,OAAO,CAAC;AACzF,OAAO,EAAE,cAAc,EAAa,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAkBnD,qBACa,0BAA2B,SAAQ,cAAc;IA0D9C,OAAO,CAAC,aAAa;IAvDjC,QAAQ,CAAC,cAAc,YAAkB;IACzC,QAAQ,CAAC,SAAS,cAAoB;IACtC,QAAQ,CAAC,WAAW,cAAoB;IACxC,QAAQ,CAAC,aAAa,gBAAsB;IAGrC,eAAe,SAAI;IAGnB,QAAQ,SAAI;IACZ,iBAAiB,SAAI;IACrB,cAAc,SAAK;IACnB,YAAY,SAAI;IAChB,sBAAsB,SAAK;IAC3B,oBAAoB,UAAQ;IAC5B,eAAe,EAAE,MAAM,CAAO;IAC9B,cAAc,EAAE,MAAM,CAAI;IAC1B,cAAc,EAAE,MAAM,CAAK;IAC3B,SAAS,UAAQ;IACjB,IAAI,SAAK;IACT,YAAY,UAAO;IACnB,kBAAkB,SAAyB;IAC3C,kBAAkB,SAAyB;IAC3C,4BAA4B,UAAO;IAC1C,oCAAoC;IAC7B,kBAAkB,UAAQ;IACjC,IAAW,gBAAgB,IACW,MAAM,CADuB;IACnE,IAAW,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAA4G;IACxJ,IAAW,sBAAsB,IAAI,OAAO,CAAmD;IAC/F,IAAW,sBAAsB,CAAC,OAAO,EAAE,OAAO,EAA8F;IAChJ,IAAW,iBAAiB,IACY,MAAM,CADuB;IACr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as o,RotationInput as s}from"../../../../../gameplay/input/index.js";import{PhysicsSystem as n,RayTestResult as r}from"../../../../../gameplay/services/physics/physics-system.js";import{MathUtils as a,Vector3 as l,ArrowHelper as c}from"three";import{ActorComponent as h,Component as p}from"../../../component.js";import{CharacterMovementMode as m}from"./modes.js";import{CapsuleCollisionShape as u}from"../../../../../scene/collision/collision-shape.js";import{takeUntil as d}from"rxjs";import{PhysicsBodyType as y}from"../../../../services/physics/physics-system.js";import g from"@dimforge/rapier3d-compat";import{RootMotionClip as f}from"../../../../../gameplay/animation/root-motion.js";import*as S from"three";import{clamp as w}from"../../../../../utils/math.js";const v=new l,M=new l,x=1/30,A=131070;let T=class extends h{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(t){super(),this.physicsSystem=t,this.directionInput=new o,this.jumpInput=new e,this.sprintInput=new e,this.rotationInput=new s,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=a.degToRad(70),this.maxSlopeClimbAngle=a.degToRad(70),this.applyImpulsesToDynamicBodies=!0,this.characterCollision=!1,this.enabled=!0,this.velocity=new l,this.mode=m.walking,this.isSprinting=!1,this.pressedJump=!1,this.rayTestResult=new r,this.resetRootMotion=!1,this.rotateToMovementDirection=!1,this.smoothRotation=!0,this.impulse=new l,this.impulseDamping=2;const i=this.cc=this.physicsSystem.getCharacterController(.1);i.enableSnapToGround(.1),i.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 i=this.rotationInput.rotation.y;const e=new l,o=new l,s=new l,n=new l(0,0,1),r=new l,c=new l,h=new l;let p=0,u=null;const g=new l,T=new l,C=new l,R=new l,j=new l,G=new l,E=this.characterCollision?null:A;this.physicsSystem.beforeStep.pipe(d(this.disposed)).subscribe((d=>{if(this.checkGrounded(d),!this.enabled)return;if(null!=this.rootMotionAction){if(this.rootMotionAction.getClip()instanceof f){const t=this.rootMotionInterpolant;this.resetRootMotion&&(g.fromArray(t.evaluate(0)),this.resetRootMotion=!1),R.fromArray(t.evaluate(this.rootMotionAction.time)),T.subVectors(R,g),g.copy(R),this.rootMotionAction.getRoot().getWorldScale(C),T.multiply(C)}}d>x&&(d=x);const y=null!=this.rootMotionAction&&this.rootMotionAction.enabled&&0!=T.length();this.pressedJump=this.jumpInput.activated,this.isSprinting=this.sprintInput.activated;let A=this.rotationInput.rotation.y-i;s.copy(this.actor.position),r.set(-this.directionInput.vector.x,0,this.directionInput.vector.y).normalize();const B=!this.rotateToMovementDirection&&r.z<0?this.maxSpeedBackwards:this.isSprinting?this.maxSpeedSprint:this.maxSpeed;if(h.set(0,0,0),this.rotateToMovementDirection){if(r.lengthSq()>0){this.smoothRotation?(N=r,P=11*d,Q=G,(W=n).normalize(),N.normalize(),D.setFromUnitVectors(W,N),F.identity(),F.slerp(D,P),Q.copy(W).applyQuaternion(F)):G.copy(r),D.setFromUnitVectors(n.clone().normalize(),G.clone().normalize()),n.copy(G);const t=(A%(2*Math.PI)+3*Math.PI)%(2*Math.PI)-Math.PI,e=Math.abs(t),o=this.smoothRotation?w(10*d*t,-e,e):t;H.setFromEuler(V.set(0,o,0)),D.multiply(H),this.actor.object.applyQuaternion(D),h.copy(this.actor.object.getWorldDirection(k).normalize()),i+=o}}else h.copy(r).applyAxisAngle(I,this.rotationInput.rotation.y),i=this.rotationInput.rotation.y,this.actor.rotation.y+=A;var W,N,P,Q;if(j.set(0,0,0),this.rayTestResult.hasHit&&null!=this.rayTestResult.actor&&this.physicsSystem.getLinearVelocity(this.rayTestResult.actor,j),this.mode===m.walking?(0!==h.length()?(p=Math.min(B,p),p=a.lerp(p,B,4*d)):p=0,c.copy(h).multiplyScalar(p),this.pressedJump&&(this.mode=m.falling,this.velocity.copy(c),this.velocity.y=this.jumpVelocity),c.y=d*this.getEffectiveGravity(),c.add(j)):this.mode===m.falling&&(this.pressedJump&&this.jumpInAir&&(this.mode=m.falling,this.velocity.copy(c),this.velocity.y=this.jumpVelocity),this.velocity.y+=d*this.getEffectiveGravity(),c.copy(this.velocity),c.addScaledVector(h,this.fallingMovementControl),this.fallingReorientation&&c.applyAxisAngle(new l(0,1,0),A)),this.impulse.lengthSq()>.1){const t=Math.min(1,this.impulse.length()/5);c.x=a.lerp(c.x,this.impulse.x,t),c.z=a.lerp(c.z,this.impulse.z,t),c.y+=this.impulse.y;const i=Math.exp(-this.impulseDamping*d);this.impulse.x*=i,this.impulse.y>0?this.impulse.y+=d*this.getEffectiveGravity():this.impulse.y*=i,this.impulse.z*=i}else this.impulse.set(0,0,0);if(o.copy(c).normalize(),e.copy(c),c.length(),y?(T.applyQuaternion(this.actor.quaternion),T.y+=d*this.getEffectiveGravity(),v.copy(T)):v.copy(c).multiplyScalar(d),this.isGrounded&&this.mode===m.walking&&(this.rayTestResult.distance>t.offset()||(v.y=Math.max(0,j.y*d)),this.physicsSystem.getActorComputedMovement(this.actor,t,v,E),t.computedCollision(0,z),null!=z&&null!=z.normal1)){const i=(new S.Vector3).copy(z.normal1);Math.acos(i.dot(I))>t.maxSlopeClimbAngle()&&(v.y=.016*this.getEffectiveGravity()*.5)}M.copy(this.physicsSystem.getActorComputedMovement(this.actor,t,v,E)),this.physicsSystem.setNextKinematicTranslation(this.actor,M);let O=function(t){if(t.numComputedCollisions()>0){const i=t.computedCollision(0);b.x=i.normal2.x,b.y=i.normal2.y,b.z=i.normal2.z;const e=b.angleTo(I);b.x=i.normal1.x,b.y=i.normal1.y,b.z=i.normal1.z;const o=b.angleTo(I);return!(e<100)&&o>t.minSlopeSlideAngle()}return!1}(t);y||this.isGrounded&&!O||this.mode!==m.falling&&(null==u?u=performance.now():performance.now()-u>100&&(this.mode=m.falling,this.velocity.copy(e))),this.isGrounded&&this.velocity.y<=0&&(this.mode,m.falling,this.mode=m.walking,this.velocity.y=0,u=null),this.mode,m.walking,this.horizontalSpeed=p}))}applyImpulse(t){this.impulse.add(t)}debugDirection(){const t=new c(v,this.actor.position,1,65280);this.actor.object.parent.add(t),setTimeout((()=>{t.removeFromParent()}),30);const i=new c(M,this.actor.position,1,16711680);this.actor.object.parent.add(i),setTimeout((()=>{i.removeFromParent()}),30)}setRootMotionAction(t){const i=t?.getClip();if(i instanceof f){this.rootMotionAction=t,this.resetRootMotion=!0;const e=[];this.rootMotionInterpolant=i.motionTrack.InterpolantFactoryMethodSmooth(e)}}getWallDirection(t,i){const e=t.clone().negate().cross(I);return e.dot(i)<0?e.negate():e}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;G.y=-.05,this.physicsSystem.rayTest(C.addVectors(this.actor.position,j.set(0,this.offset,0)),R.addVectors(this.actor.position,G),this.rayTestResult,{excludeActor:this.actor,excludeTriggers:!0})}get isGrounded(){return this.rayTestResult.hasHit||this.cc.computedGrounded()}createCollisionShape(){const t=new u(this.colliderHeight,this.colliderRadius);return t.offset.y=this.colliderRadius+this.colliderHeight/2+this.offset,t.collisionGroup=A,t}step(t){}performMovement(t){}arrowHelper(t,i,e){const o=new c(t.clone().normalize(),i,1,e);this.actor.object.parent.add(o),setTimeout((()=>{o.removeFromParent()}),30)}};T=t([p({inEditor:!1}),i("design:paramtypes",[n])],T);export{T as CharacterMovementComponent};const I=new l(0,1,0),b=new l;const C=new l,R=new l,j=new l(0,1,0),G=new l(0,-.1,0),z=(new l(0,-1,0),new g.CharacterCollision),D=new S.Quaternion,F=new S.Quaternion,H=new S.Quaternion,V=new S.Euler,k=new S.Vector3;/*
1
+ import{__decorate as t,__metadata as e}from"tslib";import{ActionInput as i,AxisInput as o,RotationInput as s}from"../../../../../gameplay/input/index.js";import{PhysicsSystem as n,RayTestResult as r}from"../../../../../gameplay/services/physics/physics-system.js";import{MathUtils as a,Vector3 as c,ArrowHelper as l}from"three";import{ActorComponent as h,Component as p}from"../../../component.js";import{CharacterMovementMode as m}from"./modes.js";import{CapsuleCollisionShape as u}from"../../../../../scene/collision/collision-shape.js";import{takeUntil as d}from"rxjs";import{PhysicsBodyType as y}from"../../../../services/physics/physics-system.js";import g from"@dimforge/rapier3d-compat";import{RootMotionClip as f}from"../../../../../gameplay/animation/root-motion.js";import*as S from"three";import{clamp as w}from"../../../../../utils/math.js";const v=new c,M=new c,x=1/30,T=131070;let A=class extends h{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(t){super(),this.physicsSystem=t,this.directionInput=new o,this.jumpInput=new i,this.sprintInput=new i,this.rotationInput=new s,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=a.degToRad(70),this.maxSlopeClimbAngle=a.degToRad(70),this.applyImpulsesToDynamicBodies=!0,this.characterCollision=!1,this.enabled=!0,this.velocity=new c,this.mode=m.walking,this.isSprinting=!1,this.pressedJump=!1,this.rayTestResult=new r,this.resetRootMotion=!1,this.rotateToMovementDirection=!1,this.smoothRotation=!0,this.impulse=new c,this.impulseDamping=2;const e=this.cc=this.physicsSystem.getCharacterController(.1);e.enableSnapToGround(.1),e.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 e=this.rotationInput.rotation.y;const i=new c,o=new c,s=new c,n=new c(0,0,1),r=new c,l=new c,h=new c;let p=0,u=null;const g=new c,A=new c,j=new c,C=new c,R=new c,D=new c,k=this.characterCollision?null:T;let q=this.rotateToMovementDirection;this.physicsSystem.beforeStep.pipe(d(this.disposed)).subscribe((d=>{if(this.checkGrounded(d),!this.enabled)return;if(null!=this.rootMotionAction){if(this.rootMotionAction.getClip()instanceof f){const t=this.rootMotionInterpolant;this.resetRootMotion&&(g.fromArray(t.evaluate(0)),this.resetRootMotion=!1),C.fromArray(t.evaluate(this.rootMotionAction.time)),A.subVectors(C,g),g.copy(C),this.rootMotionAction.getRoot().getWorldScale(j),A.multiply(j)}}d>x&&(d=x);const y=null!=this.rootMotionAction&&this.rootMotionAction.enabled&&0!=A.length();this.pressedJump=this.jumpInput.activated,this.isSprinting=this.sprintInput.activated;const T=q!==this.rotateToMovementDirection;let B=this.rotationInput.rotation.y-e;T&&(q?this.actor.object.quaternion.setFromEuler(H.set(0,this.rotationInput.rotation.y,0)):n.set(0,0,1),q=this.rotateToMovementDirection),s.copy(this.actor.position),r.set(-this.directionInput.vector.x,0,this.directionInput.vector.y).normalize();const W=!this.rotateToMovementDirection&&r.z<0?this.maxSpeedBackwards:this.isSprinting?this.maxSpeedSprint:this.maxSpeed;if(h.set(0,0,0),this.rotateToMovementDirection){if(r.lengthSq()>0){this.smoothRotation?(P=r,Q=11*d,O=D,(N=n).normalize(),P.normalize(),G.setFromUnitVectors(N,P),F.identity(),F.slerp(G,Q),O.copy(N).applyQuaternion(F)):D.copy(r),G.setFromUnitVectors(n.clone().normalize(),D.clone().normalize()),n.copy(D);const t=(B%(2*Math.PI)+3*Math.PI)%(2*Math.PI)-Math.PI,i=Math.abs(t),o=this.smoothRotation?w(10*d*t,-i,i):t;E.setFromEuler(H.set(0,o,0)),G.multiply(E),this.actor.object.applyQuaternion(G),h.copy(this.actor.object.getWorldDirection(V).normalize()),e+=o}}else e+=B,this.actor.object.quaternion.multiply(G.setFromEuler(H.set(0,B,0))),r.lengthSq()>0&&h.copy(r).applyQuaternion(this.actor.object.quaternion).normalize();var N,P,Q,O;if(R.set(0,0,0),this.rayTestResult.hasHit&&null!=this.rayTestResult.actor&&this.physicsSystem.getLinearVelocity(this.rayTestResult.actor,R),this.mode===m.walking?(0!==h.lengthSq()?(p=Math.min(W,p),p=a.lerp(p,W,4*d)):p=0,l.copy(h).multiplyScalar(p),this.pressedJump&&(this.mode=m.falling,this.velocity.copy(l),this.velocity.y=this.jumpVelocity),l.y=d*this.getEffectiveGravity(),l.add(R)):this.mode===m.falling&&(this.pressedJump&&this.jumpInAir&&(this.mode=m.falling,this.velocity.copy(l),this.velocity.y=this.jumpVelocity),this.velocity.y+=d*this.getEffectiveGravity(),l.copy(this.velocity),l.addScaledVector(h,this.fallingMovementControl),this.fallingReorientation&&l.applyAxisAngle(new c(0,1,0),B)),this.impulse.lengthSq()>.1){const t=Math.min(1,this.impulse.length()/5);l.x=a.lerp(l.x,this.impulse.x,t),l.z=a.lerp(l.z,this.impulse.z,t),l.y+=this.impulse.y;const e=Math.exp(-this.impulseDamping*d);this.impulse.x*=e,this.impulse.y>0?this.impulse.y+=d*this.getEffectiveGravity():this.impulse.y*=e,this.impulse.z*=e}else this.impulse.set(0,0,0);if(o.copy(l).normalize(),i.copy(l),l.length(),y?(A.applyQuaternion(this.actor.quaternion),A.y+=d*this.getEffectiveGravity(),v.copy(A)):v.copy(l).multiplyScalar(d),this.isGrounded&&this.mode===m.walking&&(this.rayTestResult.distance>t.offset()||(v.y=Math.max(0,R.y*d)),this.physicsSystem.getActorComputedMovement(this.actor,t,v,k),t.computedCollision(0,z),null!=z&&null!=z.normal1)){const e=(new S.Vector3).copy(z.normal1);Math.acos(e.dot(b))>t.maxSlopeClimbAngle()&&(v.y=.016*this.getEffectiveGravity()*.5)}M.copy(this.physicsSystem.getActorComputedMovement(this.actor,t,v,k)),this.physicsSystem.setNextKinematicTranslation(this.actor,M);let J=function(t){if(t.numComputedCollisions()>0){const e=t.computedCollision(0);I.x=e.normal2.x,I.y=e.normal2.y,I.z=e.normal2.z;const i=I.angleTo(b);I.x=e.normal1.x,I.y=e.normal1.y,I.z=e.normal1.z;const o=I.angleTo(b);return!(i<100)&&o>t.minSlopeSlideAngle()}return!1}(t);y||this.isGrounded&&!J||this.mode!==m.falling&&(null==u?u=performance.now():performance.now()-u>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,u=null),this.mode,m.walking,this.horizontalSpeed=p}))}applyImpulse(t){this.impulse.add(t)}debugDirection(){const t=new l(v,this.actor.position,1,65280);this.actor.object.parent.add(t),setTimeout((()=>{t.removeFromParent()}),30);const e=new l(M,this.actor.position,1,16711680);this.actor.object.parent.add(e),setTimeout((()=>{e.removeFromParent()}),30)}setRootMotionAction(t){const e=t?.getClip();if(e instanceof f){this.rootMotionAction=t,this.resetRootMotion=!0;const i=[];this.rootMotionInterpolant=e.motionTrack.InterpolantFactoryMethodSmooth(i)}}getWallDirection(t,e){const i=t.clone().negate().cross(b);return i.dot(e)<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(j.addVectors(this.actor.position,R.set(0,this.offset,0)),C.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 u(this.colliderHeight,this.colliderRadius);return t.offset.y=this.colliderRadius+this.colliderHeight/2+this.offset,t.collisionGroup=T,t}step(t){}performMovement(t){}arrowHelper(t,e,i){const o=new l(t.clone().normalize(),e,1,i);this.actor.object.parent.add(o),setTimeout((()=>{o.removeFromParent()}),30)}};A=t([p({inEditor:!1}),e("design:paramtypes",[n])],A);export{A as CharacterMovementComponent};const b=new c(0,1,0),I=new c;const j=new c,C=new c,R=new c(0,1,0),D=new c(0,-.1,0),z=(new c(0,-1,0),new g.CharacterCollision),G=new S.Quaternion,F=new S.Quaternion,E=new S.Quaternion,H=new S.Euler,V=new S.Vector3;/*
2
2
  * Copyright (©) 2025 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"third-person-camera-component.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/actors/camera/third-person-camera-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA6B,MAAM,iBAAiB,CAAC;AAE5E,OAAO,EAAqB,iBAAiB,EAAC,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAiB,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAiB,MAAM,0CAA0C,CAAC;AAUxF;;;GAGG;AACH,qBACa,0BAA2B,SAAQ,cAAc;IAiChD,OAAO,CAAC,cAAc;IAAkB,OAAO,CAAC,aAAa;IA/BzE,OAAO,CAAC,MAAM,CAA6F;IACvF,IAAI,EAAE,MAAM,CAAc;IAC1B,GAAG,EAAE,MAAM,CAAa;IACxB,SAAS,EAAE,MAAM,CAAqB;IACnD,MAAM,EAAE,iBAAiB,CAA0E;IAEnG,QAAQ,EAAE,MAAM,CAAI;IACpB,WAAW,EAAE,MAAM,CAAM;IACzB,WAAW,SAAgB;IAC3B,MAAM,SAAI;IACV,OAAO,SAAK;IACZ,OAAO,SAAM;IACb,YAAY,EAAE,OAAO,CAAO;IAC5B,eAAe,SAAI;IAE1B,OAAO,CAAC,oBAAoB,CAAK;IACjC,OAAO,CAAC,kBAAkB,CAA4C;IAEtE,SAAgB,aAAa,0BAAwD;IACrF,SAAgB,SAAS,eAA4B;IAErD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IAEvC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA2C;IAEjE,WAAW,UAAO;IAEzB,OAAO,CAAC,KAAK,CAAgB;IAEtB,SAAS,UAAQ;gBAEJ,cAAc,EAAE,cAAc,EAAU,aAAa,EAAE,aAAa;IAEjF,aAAa,UAAQ;IACtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAYtB,QAAQ;IAwBR,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAO5C,OAAO,KAAK,OAAO,GAElB;IAED,OAAO,CAAC,MAAM,CAAqB;IAC5B,UAAU;IAkBjB,OAAO,CAAC,wBAAwB,CAAO;IAEhC,UAAU;IAOjB,OAAO,CAAC,WAAW,CAIlB;IAED,OAAO,CAAC,SAAS,CAIhB;IAED,OAAO,CAAC,mBAAmB,CAK1B;IAED,OAAO,CAAC,eAAe;IAkBvB,OAAO,CAAC,iBAAiB;IA0CzB,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,oBAAoB;CAoB7B;AAcD,8EAA8E;AAC9E,qBAAa,yBAA0B,SAAQ,0BAA0B;CAAG"}
1
+ {"version":3,"file":"third-person-camera-component.d.ts","sourceRoot":"","sources":["../../../../src/gameplay/actors/camera/third-person-camera-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA6B,MAAM,iBAAiB,CAAC;AAE5E,OAAO,EAAqB,iBAAiB,EAAC,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAiB,MAAM,sBAAsB,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAiB,MAAM,0CAA0C,CAAC;AAUxF;;;GAGG;AACH,qBACa,0BAA2B,SAAQ,cAAc;IAiChD,OAAO,CAAC,cAAc;IAAkB,OAAO,CAAC,aAAa;IA/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metadata as e}from"tslib";import{ActorComponent as i,Component as s}from"../component.js";import{Vector3 as o,MathUtils as n,PerspectiveCamera as a}from"three";import{ViewController as h}from"../../services/render.js";import{DecimalInput as r,RestrictedRotationInput as c}from"../../input/index.js";import{PhysicsSystem as d,RayTestResult 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";const f=void 0!==window&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);let v=class extends i{constructor(t,e){super(),this.viewController=t,this.physicsSystem=e,this.aspect=this.viewController.htmlElement.clientWidth/this.viewController.htmlElement.clientHeight,this.near=.5,this.far=500,this.viewAngle=f?30:45,this.camera=new a(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=5,this.collisionCheckRadius=.5,this.restrictedDistance=Math.max(this.distance,this.maxDistance),this.rotationInput=new c(-Math.PI/4,Math.PI/2-.7),this.zoomInput=new r(1,0,1),this.offset=new o,this.lookAtOffset=new o(this.offsetX,0,this.offsetZ),this.fixedBehind=!0,this.world=u(p),this.activated=!1,this.isMouseLocked=!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=()=>{null!=document.pointerLockElement||null!=document.mozPointerLockElement||this.showCursor()}}async onInit(){this.world.scene.add(this.camera),this.rotationInput.rotation.copy(this.actor.rotation),this.restrictedDistance=Math.max(this.distance,this.maxDistance),this.lookAtOffset.set(this.offsetX,0,this.offsetZ),this.autoActivate&&this.activate()}activate(){this.activated=!0,this.viewController.setCamera(this.camera);const t=this.element;null!=document.body.requestPointerLock&&(t.addEventListener("pointerdown",this.onMouseDown),t.addEventListener("keydown",this.onKeyDown),document.addEventListener("pointerlockchange",this.onPointerLockChange,!1),this.disposed.subscribe((()=>{t.removeEventListener("pointerdown",this.onMouseDown),t.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("pointerlockchange",this.onPointerLockChange,!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.isMouseLocked=!0))}showCursor(){this.pointerLockInactivatedAt=performance.now(),this.element.style.cursor="default",window.document.exitPointerLock(),this.isMouseLocked=!1}setFromRotation(t){this.checkForCollision(t);const e=n.clamp(Math.min(this.restrictedDistance,this.distance),Math.min(this.minDistance,this.restrictedDistance),Math.max(this.distance*this.zoomInput.value,this.minDistance)),i=Math.cos(this.rotationInput.rotation.x)*e,s=this.fixedBehind?0:this.rotationInput.rotation.y;this.offset.x=Math.sin(-s)*i,this.offset.y=Math.sin(this.rotationInput.rotation.x)*e+2,this.offset.z=Math.cos(-s)*-i,this.offset.add(this.lookAtOffset),this.updateCameraPosition()}checkForCollision(t){const e=this.getLookAtPosition(),i=y;let s=!1,o=this.distance;const a=new m,h=this.camera.getWorldPosition(g);for(let t=-1;t<=1;t++){const n=k.subVectors(h,e);i.copy(h).add(n.multiplyScalar(1.2)),i.x+=t*this.collisionCheckRadius,this.physicsSystem.rayTest(e,i,a,{debugLifetime:0,excludeActor:this.actor,excludeTriggers:!0}),a.hasHit&&a.distance<this.distance&&(o=Math.min(a.distance,o),s||(s=a.hasHit))}s||(this.restrictedDistance=n.lerp(this.restrictedDistance,this.distance,n.clamp(this.bounceBackSpeed*t,0,1)))}getLookAtPosition(){const t=w;return t.set(0,0,0),t.y=this.height,t.add(this.lookAtOffset),t.applyMatrix4(this.actor.object.matrixWorld),t}updateCameraPosition(){this.fixedBehind?(this.camera.position.set(this.offset.x,this.offset.y,this.offset.z),this.camera.rotation.set(0,0,0),this.camera.scale.set(1,1,1),this.camera.applyMatrix4(this.actor.object.matrix)):this.camera.position.copy(this.actor.position).add(this.offset);const t=this.getLookAtPosition();this.camera.lookAt(t)}};t([l(),e("design:type",Number)],v.prototype,"near",void 0),t([l(),e("design:type",Number)],v.prototype,"far",void 0),t([l(),e("design:type",Number)],v.prototype,"viewAngle",void 0),v=t([s(),e("design:paramtypes",[h,d])],v);export{v as ThirdPersonCameraComponent};const w=new o,y=new o,k=(new o,new o),g=new o;export class ThirdPartyCameraComponent extends v{}/*
1
+ import{__decorate as t,__metadata as e}from"tslib";import{ActorComponent as i,Component as s}from"../component.js";import{Vector3 as o,MathUtils as n,PerspectiveCamera as a}from"three";import{ViewController as h}from"../../services/render.js";import{DecimalInput as r,RestrictedRotationInput as c}from"../../input/index.js";import{PhysicsSystem as d,RayTestResult 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 f}from"../../inject.js";const u=void 0!==window&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);let v=class extends i{constructor(t,e){super(),this.viewController=t,this.physicsSystem=e,this.aspect=this.viewController.htmlElement.clientWidth/this.viewController.htmlElement.clientHeight,this.near=.5,this.far=500,this.viewAngle=u?30:45,this.camera=new a(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=5,this.collisionCheckRadius=.5,this.restrictedDistance=Math.max(this.distance,this.maxDistance),this.rotationInput=new c(-Math.PI/4,Math.PI/2-.7),this.zoomInput=new r(1,0,1),this.offset=new o,this.lookAtOffset=new o(this.offsetX,0,this.offsetZ),this.fixedBehind=!0,this.world=f(p),this.activated=!1,this.isMouseLocked=!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=()=>{null!=document.pointerLockElement||null!=document.mozPointerLockElement||this.showCursor()}}async onInit(){this.world.scene.add(this.camera),this.rotationInput.rotation.copy(this.actor.rotation),this.restrictedDistance=Math.max(this.distance,this.maxDistance),this.lookAtOffset.set(this.offsetX,0,this.offsetZ),this.autoActivate&&this.activate()}activate(){this.activated=!0,this.viewController.setCamera(this.camera);const t=this.element;null!=document.body.requestPointerLock&&(t.addEventListener("pointerdown",this.onMouseDown),t.addEventListener("keydown",this.onKeyDown),document.addEventListener("pointerlockchange",this.onPointerLockChange,!1),this.disposed.subscribe((()=>{t.removeEventListener("pointerdown",this.onMouseDown),t.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("pointerlockchange",this.onPointerLockChange,!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.isMouseLocked=!0))}showCursor(){this.pointerLockInactivatedAt=performance.now(),this.element.style.cursor="default",window.document.exitPointerLock(),this.isMouseLocked=!1}setFromRotation(t){this.lookAtOffset.set(this.offsetX,0,this.offsetZ),this.checkForCollision(t);const e=n.clamp(Math.min(this.restrictedDistance,this.distance),Math.min(this.minDistance,this.restrictedDistance),Math.max(this.distance*this.zoomInput.value,this.minDistance)),i=Math.cos(this.rotationInput.rotation.x)*e,s=this.fixedBehind?0:this.rotationInput.rotation.y;this.offset.x=Math.sin(-s)*i,this.offset.y=Math.sin(this.rotationInput.rotation.x)*e+2,this.offset.z=Math.cos(-s)*-i,this.fixedBehind&&this.offset.add(this.lookAtOffset),this.updateCameraPosition()}checkForCollision(t){const e=this.getLookAtPosition(),i=y;let s=!1,o=this.distance;const a=new m,h=this.camera.getWorldPosition(x);for(let t=-1;t<=1;t++){const n=k.subVectors(h,e);i.copy(h).add(n.multiplyScalar(1.2)),i.x+=t*this.collisionCheckRadius,this.physicsSystem.rayTest(e,i,a,{debugLifetime:0,excludeActor:this.actor,excludeTriggers:!0}),a.hasHit&&a.distance<this.distance&&(o=Math.min(a.distance,o),s||(s=a.hasHit))}s||(this.restrictedDistance=n.lerp(this.restrictedDistance,this.distance,n.clamp(this.bounceBackSpeed*t,0,1)))}getLookAtPosition(){const t=w;return t.set(0,0,0),t.y=this.height,this.fixedBehind&&t.add(this.lookAtOffset),t.applyMatrix4(this.actor.object.matrixWorld),t}updateCameraPosition(){this.fixedBehind?(this.camera.position.set(this.offset.x,this.offset.y,this.offset.z),this.camera.rotation.set(0,0,0),this.camera.scale.set(1,1,1),this.camera.applyMatrix4(this.actor.object.matrix)):this.camera.position.copy(this.actor.position).add(this.offset);const t=this.getLookAtPosition();this.camera.lookAt(t)}};t([l(),e("design:type",Number)],v.prototype,"near",void 0),t([l(),e("design:type",Number)],v.prototype,"far",void 0),t([l(),e("design:type",Number)],v.prototype,"viewAngle",void 0),v=t([s(),e("design:paramtypes",[h,d])],v);export{v as ThirdPersonCameraComponent};const w=new o,y=new o,k=(new o,new o),x=new o;export class ThirdPartyCameraComponent extends v{}/*
2
2
  * Copyright (©) 2025 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -9,6 +9,13 @@ export declare class AxisInput {
9
9
  readonly toggleNegativeX: (active: boolean) => void;
10
10
  }
11
11
  type Callback = () => void;
12
+ /**
13
+ * ActionInput is for activating state while holding down a key.
14
+ * Example use case:
15
+ * - Sprinting temporarily
16
+ * - Jump
17
+ * - Shoot
18
+ */
12
19
  export declare class ActionInput {
13
20
  private readonly emitter;
14
21
  activated: boolean;
@@ -16,6 +23,31 @@ export declare class ActionInput {
16
23
  onStart(cb: Callback): void;
17
24
  onEnd(cb: Callback): void;
18
25
  }
26
+ /**
27
+ * ToggleInput will be activated after a keypress. It is used
28
+ * for state that should be activated or deactivated without continuously
29
+ * holding down a button.
30
+ *
31
+ * It is very similar to ActionInput and some use cases could work with either.
32
+ * A ToggleInput may be for something slower paced or for something that should
33
+ * persist longer.
34
+ *
35
+ * Exmaple use case:
36
+ * - Switch between running to normal walking speed.
37
+ * - Turning on a flash light.
38
+ */
39
+ export declare class ToggleInput {
40
+ private readonly emitter;
41
+ activated: boolean;
42
+ constructor(activated?: boolean);
43
+ /**
44
+ * When called with true, does nothing if already activated.
45
+ * When called with false, toggles the state and emits the appropriate event.
46
+ */
47
+ readonly toggle: (active: boolean) => void;
48
+ onStart(cb: Callback): void;
49
+ onEnd(cb: Callback): void;
50
+ }
19
51
  export declare class RotationInput {
20
52
  readonly rotation: Euler;
21
53
  readonly rotateX: (delta: number) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../src/gameplay/input/input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAW,MAAM,OAAO,CAAC;AAMhD,qBAAa,SAAS;IAClB,QAAQ,CAAC,MAAM,UAAgB;IAC/B,IAAI,UAAU,WAEb;IACD,IAAI,QAAQ,WAEX;IACD,SAAgB,eAAe,GAAI,QAAQ,OAAO,UAEjD;IACD,SAAgB,eAAe,GAAI,QAAQ,OAAO,UAEjD;IACD,SAAgB,eAAe,GAAI,QAAQ,OAAO,UAEjD;IACD,SAAgB,eAAe,GAAI,QAAQ,OAAO,UAEjD;CACJ;AAGD,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAA;AAW1B,qBAAa,WAAW;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;IAE5D,SAAS,UAAQ;IACjB,SAAgB,MAAM,GAAI,QAAQ,OAAO,UAOxC;IACM,OAAO,CAAC,EAAE,EAAE,QAAQ;IAGpB,KAAK,CAAC,EAAE,EAAE,Q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B,QAAQ,CAAC,QAAQ,QAAc;gBAEV,IAAI,GAAE,MAAkB,EACxB,IAAI,GAAE,MAAiB,EACvB,IAAI,GAAE,MAAkB,EACxB,IAAI,GAAE,MAAiB,EACvB,IAAI,GAAE,MAAkB,EACxB,IAAI,GAAE,MAAiB;IAE5C,SAAgB,OAAO,GAAI,OAAO,MAAM,UAEvC;IACD,SAAgB,OAAO,GAAI,OAAO,MAAM,UAEvC;IACD,SAAgB,OAAO,GAAI,OAAO,MAAM,UAEvC;CACJ;AAED,qBAAa,YAAY;IAEiB,OAAO,CAAC,GAAG,CAAC;IAAU,OAAO,CAAC,GAAG,CAAC;IADxE,KAAK,EAAE,MAAM,CAAA;gBACD,YAAY,GAAE,MAAU,EAAU,GAAG,CAAC,EAAE,MAAM,EAAU,GAAG,CAAC,EAAE,MAAM;IAGhF,SAAgB,SAAS,GAAI,OAAO,MAAM,UAEzC;CACJ"}
@@ -1,4 +1,4 @@
1
- import{Euler as t,Vector2 as i}from"three";import{ArrayMap as s}from"../../utils/collections.js";import{clamp as o}from"../../utils/math.js";export class AxisInput{constructor(){this.vector=new i,this.togglePositiveY=t=>{this.vector.y=t?1:Math.min(this.vector.y,0)},this.toggleNegativeY=t=>{this.vector.y=t?-1:Math.max(this.vector.y,0)},this.togglePositiveX=t=>{this.vector.x=t?1:Math.min(this.vector.x,0)},this.toggleNegativeX=t=>{this.vector.x=t?-1:Math.max(this.vector.x,0)}}get horizontal(){return this.vector.x}get vertical(){return this.vector.y}}class h{constructor(){this.map=new s}emit(t){this.map.get(t).forEach((t=>t()))}add(t,i){this.map.push(t,i)}}export class ActionInput{constructor(){this.emitter=new h,this.activated=!1,this.toggle=t=>{t&&!this.activated?this.emitter.emit("start"):!t&&this.activated&&this.emitter.emit("end"),this.activated=t}}onStart(t){this.emitter.add("start",t)}onEnd(t){this.emitter.add("end",t)}}const e=2*Math.PI;export class RotationInput{constructor(){this.rotation=new t,this.rotateX=t=>{this.rotation.x=(this.rotation.x+t)%e},this.rotateY=t=>{this.rotation.y=(this.rotation.y+t)%e},this.rotateZ=t=>{this.rotation.z=(this.rotation.z+t)%e}}}export class RestrictedRotationInput extends RotationInput{constructor(i=-1/0,s=1/0,h=-1/0,e=1/0,r=-1/0,a=1/0){super(),this.minX=i,this.maxX=s,this.minY=h,this.maxY=e,this.minZ=r,this.maxZ=a,this.rotation=new t,this.rotateX=t=>{this.rotation.x=o(this.rotation.x+t,this.minX,this.maxX)},this.rotateY=t=>{this.rotation.y=o(this.rotation.y+t,this.minY,this.maxY)},this.rotateZ=t=>{this.rotation.z=o(this.rotation.z+t,this.minZ,this.maxZ)}}}export class DecimalInput{constructor(t=0,i,s){this.min=i,this.max=s,this.increment=t=>{this.value=o(this.value+t,this.min,this.max)},this.value=t}}/*
1
+ import{Euler as t,Vector2 as i}from"three";import{ArrayMap as s}from"../../utils/collections.js";import{clamp as e}from"../../utils/math.js";export class AxisInput{constructor(){this.vector=new i,this.togglePositiveY=t=>{this.vector.y=t?1:Math.min(this.vector.y,0)},this.toggleNegativeY=t=>{this.vector.y=t?-1:Math.max(this.vector.y,0)},this.togglePositiveX=t=>{this.vector.x=t?1:Math.min(this.vector.x,0)},this.toggleNegativeX=t=>{this.vector.x=t?-1:Math.max(this.vector.x,0)}}get horizontal(){return this.vector.x}get vertical(){return this.vector.y}}class o{constructor(){this.map=new s}emit(t){this.map.get(t).forEach((t=>t()))}add(t,i){this.map.push(t,i)}}export class ActionInput{constructor(){this.emitter=new o,this.activated=!1,this.toggle=t=>{t&&!this.activated?this.emitter.emit("start"):!t&&this.activated&&this.emitter.emit("end"),this.activated=t}}onStart(t){this.emitter.add("start",t)}onEnd(t){this.emitter.add("end",t)}}export class ToggleInput{constructor(t){this.emitter=new o,this.activated=!1,this.toggle=t=>{t||(this.activated=!this.activated,this.activated?this.emitter.emit("start"):this.emitter.emit("end"))},this.activated=t}onStart(t){this.emitter.add("start",t)}onEnd(t){this.emitter.add("end",t)}}const h=2*Math.PI;export class RotationInput{constructor(){this.rotation=new t,this.rotateX=t=>{this.rotation.x=(this.rotation.x+t)%h},this.rotateY=t=>{this.rotation.y=(this.rotation.y+t)%h},this.rotateZ=t=>{this.rotation.z=(this.rotation.z+t)%h}}}export class RestrictedRotationInput extends RotationInput{constructor(i=-1/0,s=1/0,o=-1/0,h=1/0,a=-1/0,r=1/0){super(),this.minX=i,this.maxX=s,this.minY=o,this.maxY=h,this.minZ=a,this.maxZ=r,this.rotation=new t,this.rotateX=t=>{this.rotation.x=e(this.rotation.x+t,this.minX,this.maxX)},this.rotateY=t=>{this.rotation.y=e(this.rotation.y+t,this.minY,this.maxY)},this.rotateZ=t=>{this.rotation.z=e(this.rotation.z+t,this.minZ,this.maxZ)}}}export class DecimalInput{constructor(t=0,i,s){this.min=i,this.max=s,this.increment=t=>{this.value=e(this.value+t,this.min,this.max)},this.value=t}}/*
2
2
  * Copyright (©) 2025 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hology/core",
3
- "version": "0.0.132",
3
+ "version": "0.0.133",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -168,7 +168,7 @@
168
168
  "dependencies": {
169
169
  "@babel/runtime": "^7.24.8",
170
170
  "@dimforge/rapier3d-compat": "^0.14.0",
171
- "@hology/nebula": "^0.0.132",
171
+ "@hology/nebula": "^0.0.133",
172
172
  "@plumier/reflect": "^1.1.0",
173
173
  "@recast-navigation/three": "0.39.0",
174
174
  "recast-navigation": "0.39.0",