@hology/core 0.0.128 → 0.0.130

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,EAAE,aAAa,EAAiB,MAAM,4DAA4D,CAAC;AAC1G,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;IACrE,IAAW,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAA4G;IAC1J,IAAW,YAAY,IACW,MAAM,CAD2B;IACnE,IAAW,YAAY,CAAC,QAAQ,EAAE,MAAM,EAA0C;IAClF,IAAW,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAiC;IACnE,IAAW,MAAM,IADW,MAAM,CACa;IAC/C,IAAW,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAA0C;IACrF,IAAW,iBAAiB,IADS,MAAM,CAC0B;IAErE;;;;OAIG;IACI,OAAO,UAAO;IAGrB,QAAQ,CAAC,QAAQ,UAAgB;IACjC,IAAI,wBAAgC;IACpC,WAAW,UAAQ;IACnB,WAAW,UAAQ;IAEnB,OAAO,CAAC,EAAE,CAAqC;IAC/C,OAAO,CAAC,aAAa,CAAsB;gBAEvB,aAAa,EAAE,aAAa;IAOhD,OAAO,CAAC,eAAe,CAAQ;IAC/B,OAAO,CAAC,qBAAqB,CAAwB;IAErD;;;OAGG;IACI,yBAAyB,UAAQ;IAExC,mEAAmE;IAC5D,cAAc,UAAO;IAE5B,MAAM,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAiT9B,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,gBAAgB,CAAiB;IAClC,mBAAmB,CAAC,MAAM,EAAE,eAAe;IAUlD,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,MAAM;IAKP,mBAAmB;IAI1B,OAAO,CAAC,aAAa;IAkBrB,IAAW,UAAU,YAEpB;IAED,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,IAAI;IA8BZ,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,WAAW;CAQtB"}
1
+ {"version":3,"file":"character-movement.d.ts","sourceRoot":"","sources":["../../../../../../src/gameplay/actors/builtin/components/character/character-movement.ts"],"names":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,EAAE,MAAM,EAA0C;IAClF,IAAW,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAiC;IACnE,IAAW,MAAM,IADW,MAAM,CACa;IAC/C,IAAW,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAA0C;IACrF,IAAW,iBAAiB,IADS,MAAM,CAC0B;IAErE;;;;OAIG;IACI,OAAO,UAAO;IAGrB,QAAQ,CAAC,QAAQ,UAAgB;IACjC,IAAI,wBAAgC;IACpC,WAAW,UAAQ;IACnB,WAAW,UAAQ;IAEnB,OAAO,CAAC,EAAE,CAA8B;IACxC,OAAO,CAAC,aAAa,CAAsB;gBAEvB,aAAa,EAAE,aAAa;IAOhD,OAAO,CAAC,eAAe,CAAQ;IAC/B,OAAO,CAAC,qBAAqB,CAAwB;IAErD;;;OAGG;IACI,yBAAyB,UAAQ;IAExC,mEAAmE;IAC5D,cAAc,UAAO;IAE5B,MAAM,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAgU9B,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,gBAAgB,CAAiB;IAClC,mBAAmB,CAAC,MAAM,EAAE,eAAe;IAUlD,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,MAAM;IAKP,mBAAmB;IAI1B,OAAO,CAAC,aAAa;IAkBrB,IAAW,UAAU,YAEpB;IAED,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,IAAI;IA8BZ,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,WAAW;CAQtB"}
@@ -1,4 +1,4 @@
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 d}from"../../../../../scene/collision/collision-shape.js";import{takeUntil as u}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,A=1/30,x=-131071;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 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;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,d=null;const g=new c,T=new c,C=new c,j=new c,R=new c,G=this.characterCollision?null:x;this.physicsSystem.beforeStep.pipe(u(this.disposed)).subscribe((u=>{if(this.checkGrounded(u),!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),j.fromArray(t.evaluate(this.rootMotionAction.time)),T.subVectors(j,g),g.copy(j),this.rootMotionAction.getRoot().getWorldScale(C),T.multiply(C)}}u>A&&(u=A);const y=null!=this.rootMotionAction&&this.rootMotionAction.enabled&&0!=T.length();this.pressedJump=this.jumpInput.activated,this.isSprinting=this.sprintInput.activated;let x=this.rotationInput.rotation.y-e;s.copy(this.actor.position),r.set(-this.directionInput.vector.x,0,this.directionInput.vector.y).normalize();const V=!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){z.setFromUnitVectors(n.clone().normalize(),r.clone().normalize()),n.copy(r);const t=(x%(2*Math.PI)+3*Math.PI)%(2*Math.PI)-Math.PI,i=Math.abs(t),o=this.smoothRotation?w(10*u*t,-i,i):t;H.setFromEuler(k.set(0,o,0)),z.multiply(H),this.actor.object.applyQuaternion(z),h.copy(this.actor.object.getWorldDirection(F).normalize()),e+=o}}else h.copy(r).applyAxisAngle(I,this.rotationInput.rotation.y),e=this.rotationInput.rotation.y,this.actor.rotation.y+=x;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.length()?(p=Math.min(V,p),p=a.lerp(p,V,4*u)):p=0,l.copy(h).multiplyScalar(p),this.pressedJump&&(this.mode=m.falling,this.velocity.copy(l),this.velocity.y=this.jumpVelocity),l.y=.016*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+=u*this.getEffectiveGravity(),l.copy(this.velocity),l.addScaledVector(h,this.fallingMovementControl),this.fallingReorientation&&l.applyAxisAngle(new c(0,1,0),x)),o.copy(l).normalize(),i.copy(l),l.length(),y?(T.applyAxisAngle(I,this.actor.rotation.y),T.y+=u*this.getEffectiveGravity(),v.copy(T)):v.copy(l).multiplyScalar(u),this.isGrounded&&this.mode===m.walking&&(this.rayTestResult.distance>t.offset()||(v.y=Math.max(0,R.y*u)),this.physicsSystem.getActorComputedMovement(this.actor,t,v,G),t.computedCollision(0,D),null!=D&&null!=D.normal1)){const e=(new S.Vector3).copy(D.normal1);Math.acos(e.dot(I))>t.maxSlopeClimbAngle()&&(v.y=.016*this.getEffectiveGravity()*.5)}M.copy(this.physicsSystem.getActorComputedMovement(this.actor,t,v,G)),this.physicsSystem.setNextKinematicTranslation(this.actor,M);let E=function(t){if(t.numComputedCollisions()>0){const e=t.computedCollision(0);b.x=e.normal2.x,b.y=e.normal2.y,b.z=e.normal2.z;const i=b.angleTo(I);b.x=e.normal1.x,b.y=e.normal1.y,b.z=e.normal1.z;const o=b.angleTo(I);return!(i<100)&&o>t.minSlopeSlideAngle()}return!1}(t);y||this.isGrounded&&!E||this.mode!==m.falling&&(null==d?d=performance.now():performance.now()-d>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,d=null),this.mode,m.walking,this.horizontalSpeed=p}))}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(I);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;G.y=-.05,this.physicsSystem.rayTest(C.addVectors(this.actor.position,R.set(0,this.offset,0)),j.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 d(this.colliderHeight,this.colliderRadius);return t.offset.y=this.colliderRadius+this.colliderHeight/2+this.offset,t.collisionGroup=x,t}step(t){}performMovement(t){}arrowHelper(t,e,i){const o=new l(t,e,1,i);this.actor.object.parent.add(o),setTimeout((()=>{o.removeFromParent()}),30)}};T=t([p({inEditor:!1}),e("design:paramtypes",[n])],T);export{T as CharacterMovementComponent};const I=new c(0,1,0),b=new c;const C=new c,j=new c,R=new c(0,1,0),G=new c(0,-.1,0),D=(new c(0,-1,0),new g.CharacterCollision),z=new S.Quaternion,H=new S.Quaternion,k=new S.Euler,F=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 d}from"../../../../../scene/collision/collision-shape.js";import{takeUntil as u}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,A=1/30,T=131070;let x=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;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,d=null;const g=new c,x=new c,C=new c,R=new c,j=new c,G=new c,E=this.characterCollision?null:T;this.physicsSystem.beforeStep.pipe(u(this.disposed)).subscribe((u=>{if(this.checkGrounded(u),!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)),x.subVectors(R,g),g.copy(R),this.rootMotionAction.getRoot().getWorldScale(C),x.multiply(C)}}u>A&&(u=A);const y=null!=this.rootMotionAction&&this.rootMotionAction.enabled&&0!=x.length();this.pressedJump=this.jumpInput.activated,this.isSprinting=this.sprintInput.activated;let T=this.rotationInput.rotation.y-e;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*u,Q=G,(W=n).normalize(),N.normalize(),z.setFromUnitVectors(W,N),F.identity(),F.slerp(z,P),Q.copy(W).applyQuaternion(F)):G.copy(r),z.setFromUnitVectors(n.clone().normalize(),G.clone().normalize()),n.copy(G);const t=(T%(2*Math.PI)+3*Math.PI)%(2*Math.PI)-Math.PI,i=Math.abs(t),o=this.smoothRotation?w(10*u*t,-i,i):t;H.setFromEuler(V.set(0,o,0)),z.multiply(H),this.actor.object.applyQuaternion(z),h.copy(this.actor.object.getWorldDirection(k).normalize()),e+=o}}else h.copy(r).applyAxisAngle(I,this.rotationInput.rotation.y),e=this.rotationInput.rotation.y,this.actor.rotation.y+=T;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*u)):p=0,l.copy(h).multiplyScalar(p),this.pressedJump&&(this.mode=m.falling,this.velocity.copy(l),this.velocity.y=this.jumpVelocity),l.y=.016*this.getEffectiveGravity(),l.add(j)):this.mode===m.falling&&(this.pressedJump&&this.jumpInAir&&(this.mode=m.falling,this.velocity.copy(l),this.velocity.y=this.jumpVelocity),this.velocity.y+=u*this.getEffectiveGravity(),l.copy(this.velocity),l.addScaledVector(h,this.fallingMovementControl),this.fallingReorientation&&l.applyAxisAngle(new c(0,1,0),T)),o.copy(l).normalize(),i.copy(l),l.length(),y?(x.applyQuaternion(this.actor.quaternion),x.y+=u*this.getEffectiveGravity(),v.copy(x)):v.copy(l).multiplyScalar(u),this.isGrounded&&this.mode===m.walking&&(this.rayTestResult.distance>t.offset()||(v.y=Math.max(0,j.y*u)),this.physicsSystem.getActorComputedMovement(this.actor,t,v,E),t.computedCollision(0,D),null!=D&&null!=D.normal1)){const e=(new S.Vector3).copy(D.normal1);Math.acos(e.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 e=t.computedCollision(0);b.x=e.normal2.x,b.y=e.normal2.y,b.z=e.normal2.z;const i=b.angleTo(I);b.x=e.normal1.x,b.y=e.normal1.y,b.z=e.normal1.z;const o=b.angleTo(I);return!(i<100)&&o>t.minSlopeSlideAngle()}return!1}(t);y||this.isGrounded&&!O||this.mode!==m.falling&&(null==d?d=performance.now():performance.now()-d>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,d=null),this.mode,m.walking,this.horizontalSpeed=p}))}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(I);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;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 d(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)}};x=t([p({inEditor:!1}),e("design:paramtypes",[n])],x);export{x as CharacterMovementComponent};const I=new c(0,1,0),b=new c;const C=new c,R=new c,j=new c(0,1,0),G=new c(0,-.1,0),D=(new c(0,-1,0),new g.CharacterCollision),z=new S.Quaternion,F=new S.Quaternion,H=new S.Quaternion,V=new S.Euler,k=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":"root-motion.d.ts","sourceRoot":"","sources":["../../../src/gameplay/animation/root-motion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,IAAI,EAA4B,MAAM,OAAO,CAAA;AAiBzF,qBAAa,cAAe,SAAQ,aAAa;IACzC,WAAW,EAAE,mBAAmB,CAAA;IAGhC,YAAY,EAAE,MAAM,CAAI;IACxB,YAAY,UAAQ;IAC3B,OAAO,CAAC,QAAQ,CAAC,CAAM;IACvB,OAAO,CAAC,MAAM,CAAe;WAEf,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,YAAY,UAAQ,EAAE,QAAQ,CAAC,EAAE,IAAI,GAAG,cAAc;IAqBpG;;;;;;;;OAQG;WACW,oBAAoB,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM;IAS1E,KAAK,IAAI,IAAI;CAMd;AAGD,KAAK,WAAW,GAAG,MAAM,CAAA;AAEzB,qBAAa,SAAS;IACpB,IAAI,EAAE,WAAW,CAAU;IAC3B,KAAK,EAAE,MAAM,CAAI;IACjB,QAAQ,EAAE,IAAI,EAAE,CAAK;CACtB"}
1
+ {"version":3,"file":"root-motion.d.ts","sourceRoot":"","sources":["../../../src/gameplay/animation/root-motion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,IAAI,EAA4B,MAAM,OAAO,CAAA;AAiBzF,qBAAa,cAAe,SAAQ,aAAa;IACzC,WAAW,EAAE,mBAAmB,CAAA;IAGhC,YAAY,EAAE,MAAM,CAAI;IACxB,YAAY,UAAQ;IAC3B,OAAO,CAAC,QAAQ,CAAC,CAAM;IACvB,OAAO,CAAC,MAAM,CAAe;WAEf,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,YAAY,UAAQ,EAAE,QAAQ,CAAC,EAAE,IAAI,GAAG,cAAc;IAgCpG;;;;;;;;OAQG;WACW,oBAAoB,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM;IAS1E,KAAK,IAAI,IAAI;CAMd;AAGD,KAAK,WAAW,GAAG,MAAM,CAAA;AAEzB,qBAAa,SAAS;IACpB,IAAI,EAAE,WAAW,CAAU;IAC3B,KAAK,EAAE,MAAM,CAAI;IACjB,QAAQ,EAAE,IAAI,EAAE,CAAK;CACtB"}
@@ -1,4 +1,4 @@
1
- import{AnimationClip as o,Vector3 as t}from"three";export class RootMotionClip extends o{constructor(){super(...arguments),this.displacement=0,this.fixedInPlace=!1}static fromClip(o,e=!1,i){const n=new RootMotionClip(o.name,o.duration,o.tracks.slice(),o.blendMode);if(n.fixedInPlace=e,n.rootBone=i,n.source=o,n.uuid=o.uuid,n.motionTrack=null!=i?o.tracks.find((o=>o.name===`${i.name}.position`)):o.tracks.find((o=>o.name.endsWith(".position"))),n.motionTrack){n.tracks.splice(n.tracks.indexOf(n.motionTrack),1);const o=(new t).fromArray(n.motionTrack.values,0),e=(new t).fromArray(n.motionTrack.values,n.motionTrack.values.length-3);n.displacement=e.distanceTo(o)}else console.error("Could not find root motion track",o,i);return n}static fromClipWithDistance(o,t){const e=new RootMotionClip(o.name,o.duration,o.tracks.slice(),o.blendMode);return e.fixedInPlace=!0,e.source=o,e.uuid=o.uuid,e.displacement=t,e}clone(){const o=RootMotionClip.fromClip(this.source.clone(),this.fixedInPlace,this.rootBone);return o.displacement=this.displacement,o}}let e=53912381;export class BoneLayer{constructor(){this.uuid=e++,this.order=0,this.boneMask=[]}}/*
1
+ import{AnimationClip as o,Vector3 as t}from"three";export class RootMotionClip extends o{constructor(){super(...arguments),this.displacement=0,this.fixedInPlace=!1}static fromClip(o,e=!1,n){const i=new RootMotionClip(o.name,o.duration,o.tracks.slice(),o.blendMode);if(i.fixedInPlace=e,i.rootBone=n,i.source=o,i.uuid=o.uuid,i.motionTrack=null!=n?o.tracks.find((o=>o.name===`${n.name}.position`)):o.tracks.find((o=>o.name.endsWith(".position"))),i.motionTrack){i.tracks.splice(i.tracks.indexOf(i.motionTrack),1);const o=(new t).fromArray(i.motionTrack.values,0),e=(new t).fromArray(i.motionTrack.values,i.motionTrack.values.length-3),n=i.motionTrack.clone();for(let o=0;o<i.motionTrack.values.length;o+=3)n.values[o+0]=0,n.values[o+2]=0;i.tracks.push(n),i.displacement=e.distanceTo(o)}else console.error("Could not find root motion track",o,n);return i}static fromClipWithDistance(o,t){const e=new RootMotionClip(o.name,o.duration,o.tracks.slice(),o.blendMode);return e.fixedInPlace=!0,e.source=o,e.uuid=o.uuid,e.displacement=t,e}clone(){const o=RootMotionClip.fromClip(this.source.clone(),this.fixedInPlace,this.rootBone);return o.displacement=this.displacement,o}}let e=53912381;export class BoneLayer{constructor(){this.uuid=e++,this.order=0,this.boneMask=[]}}/*
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":"initiate.d.ts","sourceRoot":"","sources":["../../src/gameplay/initiate.ts"],"names":[],"mappings":"AAAA,OAAkB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAEpE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;A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U,CAAC,CAAC,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC;IAI/C;;OAEG;IACH,QAAQ;CA6BT"}
@@ -1,4 +1,4 @@
1
- import e from"typedi";import{loadScene as t}from"../scene/bootstrap.js";import{ActorFactory as n}from"./actors/factory.js";import{World as s}from"./services/world.js";import{SceneMaterializer as r}from"../scene/materializer.js";import{ViewController as o}from"./services/render.js";import{RenderingView as i}from"../rendering.js";import{PhysicsSystem as a}from"./services/physics/physics-system.js";import{MeshComponent as c}from"./actors/builtin/components/mesh-component.js";import{activeContainerInstance as m}from"./actors/internal/container-map.js";import{InputService as d}from"./input/index.js";import{RuntimeAssetsService as l}from"../scene/runtime-asset-service.js";import{AssetResourceLoader as p}from"../scene/asset-resource-loader.js";import{AssetLoader as h}from"./services/asset-loader.js";import{polyfillClient as f}from"./polyfill.js";import{Subject as u}from"rxjs";import{PointerEvents as w}from"./services/pointer-events.js";import{RuntimeBundledBackendService as g}from"../scene/runtime-bundled-backend-service.js";import{Scene as j}from"three";import{ShaderProvider as v}from"./services/shader-provider.js";import{SceneDataService as b}from"../scene/scene-data-service.js";export function initiateGame(d,u){if(f(),0!=u.element.childNodes.length)return console.error("Can not initialize the game with a non-empty html element"),null;e.has(o);const S=e.of("default"),y=new HologyRuntime(S),I=new n(S,{inEditor:!1});var x;e.set(n,I),x=u.element,Object.assign(x.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",overflow:"hidden"});const D=new i(u.element,{enableXR:!0===u.xr?.enabled,maxPixelRatio:u.rendering?.maxPixelRatio,bloom:{enabled:!1!==u?.rendering?.bloom?.enabled},reflection:{enabled:!1!==u?.rendering?.reflection?.enabled}});D.renderer.shadowMap.enabled=u.rendering?.shadows?.enabled??!0,D.renderer.shadowMap.autoUpdate=u.rendering?.shadows?.autoUpdate??!0,null!=u?.rendering?.resolutionScale&&(D.resolutionScale=u.rendering.resolutionScale),e.set(i,D);const R=new o(D);e.set(o,R);const G=new g,z=new l(G),H=new p;H.setDataDir(u.dataDir),H.initKtx2(D.renderer);const O=Object.entries(u.shaders).map((([e,t])=>({name:e,type:t}))),P=Object.entries(u.actors).map((([e,t])=>({name:e,type:t}))),W=new v(O);e.set(v,W);const A=new h(H,z,O);e.set(h,A);const M=new j,N=new r(M,new b,z,H,D,O,P,I);e.set(r,N);const T=e.get(s);return e.set(s,T),T.materializer=N,(async()=>{const n=e.get(a);if(await n.start(),y.isShutdown)return;if(await G.preloadData(),y.isShutdown)return;T.scene=M;const{scene:s,actors:r}=await t(D,u.sceneName,u.dataDir,u.shaders,u.actors,I,G,z,H,{detailTier:u.detailTier});T.scene=s,n.scene=T.scene;for(const e of M.children)T.scene.add(e);if(y.isShutdown)return void D.stop();e.import([c]);for(const e of r)T.addActor(e);n.addFromScene(s),D.loop((e=>{})),y.status=5,m.value=S,S.remove(d),S.set({id:d,type:d});const o=S.get(d);m.value=null,y.gameInstance=o,S.get(w).start(),o instanceof GameInstance&&await o.onStart(),y._resolver(!0)})(),y}export class GameInstance{onStart(){}onShutdown(){}}export function createHologyScene(){}export class HologyRuntime{constructor(e){this.containerInstance=e,this.status=0,this.isShutdown=!1,this.shutdownStarted=new u,this.ready=new Promise((e=>{this._resolver=e}))}getWorld(){return this.containerInstance.get(s)}getService(e){return this.containerInstance.get(e)}shutdown(){this.isShutdown=!0,this.shutdownStarted.next(),this.gameInstance instanceof GameInstance&&this.gameInstance.onShutdown(),this.containerInstance.get(d).stop();const e=this.containerInstance.get(i);e?.stop();for(const e of this.getWorld().actors)this.getWorld().removeActor(e);this.containerInstance.get(a).stop(),this.containerInstance.get(r).dispose(),this.containerInstance.get(w).stop(),this.containerInstance.reset()}}/*
1
+ import e from"typedi";import{loadScene as t}from"../scene/bootstrap.js";import{ActorFactory as n}from"./actors/factory.js";import{World as s}from"./services/world.js";import{SceneMaterializer as r}from"../scene/materializer.js";import{ViewController as o}from"./services/render.js";import{RenderingView as i}from"../rendering.js";import{PhysicsSystem as a}from"./services/physics/physics-system.js";import{MeshComponent as c}from"./actors/builtin/components/mesh-component.js";import{activeContainerInstance as m}from"./actors/internal/container-map.js";import{InputService as d}from"./input/index.js";import{RuntimeAssetsService as l}from"../scene/runtime-asset-service.js";import{AssetResourceLoader as p}from"../scene/asset-resource-loader.js";import{AssetLoader as h}from"./services/asset-loader.js";import{polyfillClient as u}from"./polyfill.js";import{Subject as f}from"rxjs";import{PointerEvents as w}from"./services/pointer-events.js";import{RuntimeBundledBackendService as g}from"../scene/runtime-bundled-backend-service.js";import{Scene as j}from"three";import{ShaderProvider as v}from"./services/shader-provider.js";import{SceneDataService as b}from"../scene/scene-data-service.js";export function initiateGame(d,f){if(u(),0!=f.element.childNodes.length)return console.error("Can not initialize the game with a non-empty html element"),null;e.has(o);const S=e.of("default"),y=new HologyRuntime(S),I=new n(S,{inEditor:!1});var x;e.set(n,I),x=f.element,Object.assign(x.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",overflow:"hidden"});const D=new i(f.element,{enableXR:!0===f.xr?.enabled,maxPixelRatio:f.rendering?.maxPixelRatio,bloom:{enabled:!1!==f?.rendering?.bloom?.enabled},reflection:{enabled:!1!==f?.rendering?.reflection?.enabled}});D.renderer.shadowMap.enabled=f.rendering?.shadows?.enabled??!0,D.renderer.shadowMap.autoUpdate=f.rendering?.shadows?.autoUpdate??!0,null!=f?.rendering?.resolutionScale&&(D.resolutionScale=f.rendering.resolutionScale),e.set(i,D);const R=new o(D);e.set(o,R);const G=new g,P=new l(G),z=new p;z.setDataDir(f.dataDir),z.initKtx2(D.renderer);const H=Object.entries(f.shaders).map((([e,t])=>({name:e,type:t}))),M=Object.entries(f.actors).map((([e,t])=>({name:e,type:t}))),O=new v(H);e.set(v,O);const W=new h(z,P,H);e.set(h,W);const A=new j,F=new r(A,new b,P,z,D,H,M,I);e.set(r,F);const N=e.get(s);return e.set(s,N),N.materializer=F,(async()=>{const n=e.get(a);if(await n.start(),y.isShutdown)return;if(await G.preloadData(),y.isShutdown)return;N.scene=A;const{scene:s,actors:r}=await t(D,f.sceneName,f.dataDir,f.shaders,f.actors,I,G,P,z,{detailTier:f.detailTier});N.scene=s,n.scene=N.scene;for(const e of A.children)N.scene.add(e);if(y.isShutdown)return void D.stop();e.import([c]);for(const e of r)N.addActor(e);n.addFromScene(s),D.loop((e=>{})),y.status=5,m.value=S,S.remove(d),S.set({id:d,type:d});const o=S.get(d);m.value=null,y.gameInstance=o,S.get(w).start(),o instanceof GameInstance&&await o.onStart(),y._resolver(!0)})(),y}export class GameInstance{onStart(){}onShutdown(){}}export function createHologyScene(){}export class HologyRuntime{constructor(e){this.containerInstance=e,this.status=0,this.isShutdown=!1,this.shutdownStarted=new f,this.ready=new Promise((e=>{this._resolver=e}))}getWorld(){return this.containerInstance.get(s)}getService(e){return this.containerInstance.get(e)}shutdown(){this.isShutdown=!0,this.shutdownStarted.next(),this.gameInstance instanceof GameInstance&&this.gameInstance.onShutdown(),this.containerInstance.get(d).stop();const e=this.containerInstance.get(i);e?.stop();const t=this.containerInstance.get(o);t.setMuted(!0),t.audioListener.removeFromParent();for(const e of this.getWorld().actors)this.getWorld().removeActor(e);this.containerInstance.get(a).stop(),this.containerInstance.get(r).dispose(),this.containerInstance.get(w).stop(),this.containerInstance.reset()}}/*
2
2
  * Copyright (©) 2025 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -26,6 +26,7 @@ export { Component, ActorComponent, type ComponentOptions, attach, Attach } from
26
26
  * ```
27
27
  */
28
28
  export type InteractionGroups = number;
29
+ export type KinematicCharacterController = RAPIER.KinematicCharacterController;
29
30
  export declare class RayTestResult {
30
31
  actor?: BaseActor;
31
32
  hasHit: boolean;
@@ -74,8 +75,10 @@ export declare class PhysicsSystem extends AbstractPhysicsSystem {
74
75
  private staticBodies;
75
76
  private actorBodies;
76
77
  private bodyActors;
78
+ private colliders;
77
79
  private eventQueue;
78
80
  private fixedupdateSub;
81
+ private collisionSub;
79
82
  private readonly collisionEvents;
80
83
  readonly beforeStep: Subject<number>;
81
84
  readonly afterStep: Subject<number>;
@@ -112,6 +115,7 @@ export declare class PhysicsSystem extends AbstractPhysicsSystem {
112
115
  * @returns A promise that resolves when the physics system is ready
113
116
  */
114
117
  start(): Promise<void>;
118
+ private handleCollisionEvents;
115
119
  /**
116
120
  * Renders debug visualization of physics bodies and colliders.
117
121
  * Only active when showDebug is true.
@@ -196,7 +200,7 @@ export declare class PhysicsSystem extends AbstractPhysicsSystem {
196
200
  * @param offset - The skin offset for the character controller
197
201
  * @returns A new kinematic character controller
198
202
  */
199
- getCharacterController(offset?: number): RAPIER.KinematicCharacterController;
203
+ getCharacterController(offset?: number): KinematicCharacterController;
200
204
  /**
201
205
  * Computes the corrected movement vector for an actor using a character controller.
202
206
  * This uses the first collider of the given actor if the actor has been added to
@@ -211,7 +215,7 @@ export declare class PhysicsSystem extends AbstractPhysicsSystem {
211
215
  * @param collisionGroup - Optional collision group filter
212
216
  * @returns The corrected movement vector accounting for collisions
213
217
  */
214
- getActorComputedMovement(actor: BaseActor, cc: RAPIER.KinematicCharacterController, desiredTranslation: Vector3, collisionGroup?: number): Vector3;
218
+ getActorComputedMovement(actor: BaseActor, cc: KinematicCharacterController, desiredTranslation: Vector3, collisionGroup?: number): Vector3;
215
219
  /**
216
220
  * Creates a collider from a given collision shape.
217
221
  * This method adds a collision shape to the physics world as a collider,
@@ -253,18 +257,26 @@ export declare class PhysicsSystem extends AbstractPhysicsSystem {
253
257
  * by the given collider, taking into account collisions and the specified collision group.
254
258
  *
255
259
  * @param physicsCollider - The PhysicsCollider instance to move.
256
- * @param cc - The RAPIER.KinematicCharacterController to use for movement computation.
260
+ * @param cc - The KinematicCharacterController to use for movement computation.
257
261
  * @param desiredTranslation - The desired movement vector (THREE.Vector3).
258
262
  * @param collisionGroup - Optional collision group filter to restrict which objects are considered for collision.
259
263
  * @returns The corrected movement vector (THREE.Vector3) that accounts for collisions.
260
264
  */
261
- getCharacterComputedMovement(physicsCollider: PhysicsCollider, cc: RAPIER.KinematicCharacterController, desiredTranslation: Vector3, collisionGroup?: number): Vector3;
265
+ getCharacterComputedMovement(physicsCollider: PhysicsCollider, cc: KinematicCharacterController, desiredTranslation: Vector3, collisionGroup?: number): Vector3;
262
266
  /**
263
267
  * Sets the next kinematic translation for an actor.
264
268
  * @param actor - The actor to update
265
269
  * @param vel - The velocity vector to apply
266
270
  */
267
271
  setNextKinematicTranslation(actor: BaseActor, vel: Vector3): void;
272
+ setNextKinematicPosition(actor: BaseActor, position: Vector3): void;
273
+ setNextKinematicRotation(actor: BaseActor, rot: Quaternion): void;
274
+ /**
275
+ * Set the transform of the actor in the physics system for the next step
276
+ * so that it will apply correctly detect collisions.
277
+ * @param actor
278
+ */
279
+ setNextKinematicTransform(actor: BaseActor): void;
268
280
  /**
269
281
  * Sets the angular velocity of an actor's physics body.
270
282
  * @param actor - The actor to update
@@ -606,7 +618,13 @@ export declare class PhysicsSystem extends AbstractPhysicsSystem {
606
618
  * @returns
607
619
  */
608
620
  export declare function extractFloat32Array(attr: THREE.BufferAttribute | THREE.InterleavedBufferAttribute): Float32Array;
621
+ type ColliderCollisionEvent = {
622
+ actor: BaseActor;
623
+ };
609
624
  export declare class PhysicsCollider {
625
+ readonly disposed: Subject<true>;
626
+ readonly onBeginOverlapActor: Subject<ColliderCollisionEvent>;
627
+ readonly onEndOverlapActor: Subject<ColliderCollisionEvent>;
610
628
  constructor(
611
629
  /** @internal */
612
630
  collider: RAPIER.Collider,
@@ -643,7 +661,7 @@ export declare class PhysicsBody {
643
661
  setAngularVelocity(vel: Vector3): void;
644
662
  applyImpulse(impulse: Vector3, wakeUp?: boolean): void;
645
663
  applyTorqueImpulse(torque: Vector3, wakeUp?: boolean): void;
646
- setNextKinematicTranslation(pos: Vector3): void;
664
+ setNextKinematicPosition(pos: Vector3): void;
647
665
  setNextKinematicRotation(rot: Quaternion): void;
648
666
  isDynamic(): boolean;
649
667
  isKinematic(): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"physics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,IAAI,OAAO;IAInB;;;;;;OAMG;IACH,KAAK;IAIL,MAAM;CAGP"}
@@ -1,4 +1,4 @@
1
- import{__decorate as t,__metadata as e}from"tslib";import*as s from"@dimforge/rapier3d-compat";import{QueryFilterFlags as i}from"@dimforge/rapier3d-compat";import{BehaviorSubject as o,distinctUntilChanged as n,filter as r,map as a,Subject as l,takeUntil as c}from"rxjs";import*as d from"three";import{ArrowHelper as h,BufferAttribute as y,BufferGeometry as u,Group as p,LineSegments as g,Matrix4 as m,Object3D as f,Quaternion as w,Raycaster as x,Scene as b,Vector3 as B}from"three";import{Service as v}from"typedi";import{AssetMeshInstance as C}from"../../../scene/asset-resource-loader.js";import{BoxCollisionShape as z,CapsuleCollisionShape as A,CollisionShapeSource as S,ConeCollisionShape as D,ConvexPolyhedronCollisionShape as R,CylinderCollisionShape as M,PhysicalShapeMesh as T,PlaneCollisionShape as E,SphereCollisionShape as P,TrimeshCollisionShape as _}from"../../../index.js";import{LandscapeGroup as I}from"../../../scene/landscape/landscape.js";import{ViewController as V}from"../render.js";import{World as F}from"../world.js";import*as k from"three/examples/jsm/utils/BufferGeometryUtils.js";import{calculateEffectiveScale as W}from"../../../utils/three/traverse.js";import{AbstractPhysicsSystem as j}from"./abstract-physics-system.js";import{ActorComponent as L,Component as N}from"../../../gameplay/actors/component.js";import{inject as O}from"../../../gameplay/inject.js";export{Component,ActorComponent,attach,Attach}from"../../actors/component.js";export class RayTestResult{constructor(){this.hasHit=!1,this.hitPoint=new B,this.hitNormal=new B}}export class ShapeCastResult{constructor(){this.hasHit=!1,this.hitPoint=new B,this.normal=new B}reset(){this.actor=void 0,this.hasHit=!1,this.distance=0,this.hitPoint.set(0,0,0),this.normal.set(0,0,0)}}ShapeCastResult.shared=new ShapeCastResult;export var PhysicsBodyType;!function(t){t[t.dynamic=1]="dynamic",t[t.static=2]="static",t[t.kinematic=4]="kinematic",t[t.kinematicVelocityBased=8]="kinematicVelocityBased"}(PhysicsBodyType||(PhysicsBodyType={}));const G=new B,q=new B,U=new w,H=new w,K=(new w,[]);let Q=class extends j{set showDebug(t){this.shouldRenderDebug=t,this.debugMesh&&(this.debugMesh.visible=t)}get showDebug(){return this.shouldRenderDebug}constructor(t){super(),this.viewController=t,this.staticMeshes=new Map,this.staticBodies=new Map,this.actorBodies=new Map,this.bodyActors=new Map,this.collisionEvents=new l,this.beforeStep=new l,this.afterStep=new l,this.shouldRenderDebug=!1,this.shapeCacheBox=new Map,this.shapeCacheBall=new Map,this._raycaster=new x,this._reusableResult=new RayTestResult,this._raytestDiff=new B,this._raytestDirection=new B,this.controlledActors=new Set,this.ready=this.setup()}getBallShape(t){let e=this.shapeCacheBall.get(t);return null==e&&(e=new s.Ball(t),this.shapeCacheBall.set(t,e)),e}getBoxShape(t,e,i){const o=t+1e6*e+1e12*i;let n=this.shapeCacheBox.get(o);return null==n&&(n=new s.Cuboid(t,e,i),this.shapeCacheBox.set(o,n)),n}hasBoxIntersection(t){const e=t.getCenter(G),s=t.getSize(q),i=this.getBoxShape(s.x/2,s.y/2,s.z/2);return null!=this.world.intersectionWithShape(e,U,i)}hasSphereIntersection(t){const e=this.getBallShape(t.radius);return null!=this.world.intersectionWithShape(t.center,U,e)}createDebugMesh(){return new g(new u,new d.LineBasicMaterial({color:255}))}async start(){return await this.ready,this.handleTick(),this.ready}renderDebug(){if(null==this.scene)return;null==this.debugMesh&&(this.debugMesh=this.createDebugMesh(),this.debugMesh.visible=this.shouldRenderDebug,this.debugMesh.raycast=function(){},this.scene?.add(this.debugMesh));const t=this.world.debugRender();this.debugMesh.geometry.setAttribute("position",new y(t.vertices,3))}async setup(){if(null!=this.rapier)throw new Error("Rapier is already estup");this.rapier=await rt(),this.eventQueue=new s.EventQueue(!0),this.setupWorld()}handleTick(){this.fixedupdateSub=this.viewController.onUpdate().subscribe((t=>{t=Math.min(.1,t),this.beforeStep.next(t),this.updatePhysics(t),this.showDebug&&this.renderDebug(),this.world.bodies.forEach((t=>{if(t.isFixed())return;const e=this.staticMeshes.get(t)??this.bodyActors.get(t)?.object;null!=e&&e.parent instanceof b&&(ct(e.position,t.translation()),(t.isDynamic()||t.isKinematic()&&!this.controlledActors.has(this.bodyActors.get(t)?.id))&&dt(e.quaternion,t.rotation()),e.updateMatrix(),e.updateWorldMatrix(!1,!1))})),this.afterStep.next(t)}))}_updateWorld(){this.world.timestep=0,this.world.step()}updatePhysics(t){this.world.timestep=t,this.world.step(this.eventQueue),this.eventQueue.drainCollisionEvents(((t,e,s)=>{this.collisionEvents.next({handle1:t,handle2:e,started:s}),this.collisionEvents.next({handle1:e,handle2:t,started:s})}))}rayTestFromCamera(t,e,s){this._raycaster.setFromCamera(it,this.viewController.getCamera());const i=this._raycaster.ray.origin,o=this._raycaster.ray.direction.multiplyScalar(t).add(i);return this.rayTest(i,o,e,s)}rayTest(t,e,s,i){null==s&&(s=this._reusableResult);const o=this._raytestDiff,n=this._raytestDirection;if(o.subVectors(e,t),n.copy(o).normalize(),0===n.length())return console.warn("Ray test called with to and from being equal"),s;at(mt.origin,t),at(mt.dir,n);const r=o.length(),a=this.world.castRayAndGetNormal(mt,r,!1,void 0,i?.collisionFilter,void 0,null!=i?.excludeActor?this.actorBodies.get(i.excludeActor.id):void 0,i?.excludeTriggers?t=>!t.isSensor():void 0);if(s.hasHit=null!=a,s.hasHit){const e=mt.pointAt(a.timeOfImpact);s._internal=a,ct(s.hitNormal,a.normal),ct(s.hitPoint,e),s.distance=yt.subVectors(s.hitPoint,t).length();const i=this.world.bodies.getAll().find((t=>function(t,e){for(let s=0,i=t.numColliders();s<i;s++){const i=t.collider(s);if(e(i))return i}}(t,(t=>t===a.collider))));s.actor=null!=i?this.bodyActors.get(i):null}if(this.showDebug){let e;K.length>0?(e=K.pop(),e.setDirection(n),e.position.copy(t),e.setLength(r,.2,.1),e.setColor(i?.debugColor??255)):e=new h(n,t,r,i?.debugColor??255),this.scene?.add(e),setTimeout((()=>{this.scene?.remove(e),K.push(e)}),i?.debugLifetime??200)}return s}setGravity(t,e,s){this.world.gravity.x=t,this.world.gravity.y=e,this.world.gravity.z=s}getGravity(){return J.set(this.world.gravity.x,this.world.gravity.y,this.world.gravity.z)}addFromScene(t){this.addRecursively(t);for(const t of this.staticBodies.values())ht(t,(t=>t.setActiveEvents(s.ActiveEvents.COLLISION_EVENTS)))}addRecursively(t){if(this.removeSceneObject(t),!function(t){if(null!=t.userData?.src){const e=t.userData?.src;return"actor"===e.type}return!1}(t))if(t instanceof T&&null!=t.collisionShape){const e=this.createStaticBody(t,[t.collisionShape],t.physics);this.staticMeshes.set(e,t),this.staticBodies.set(t,e)}else if(t instanceof C&&!1!==t.userData?.src?.collisionDetection)if(t.children[0]&&(t.children[0].instanceMatrix||t.children[0].isBatchedMesh))this.createForInstancedMesh(t.children[0],t.collisionShapes);else{const e=this.createStaticBody(t,t.collisionShapes,t.physics);this.staticMeshes.set(e,t),this.staticBodies.set(t,e)}else t instanceof I?this.addLandscapeGroup(t):(t instanceof p||t instanceof b)&&t.children.forEach((t=>this.addRecursively(t)))}createForInstancedMesh(t,e){const s=new m,i=e.filter((t=>null!=t)).map((t=>t.source===S.rendered?t.withOffset(wt):t));if(t instanceof d.BatchedMesh){const e=t._instanceInfo??t._drawInfo;for(let o=0;o<e.length;o++){if(null!=t.userData.hasCollision&&!t.userData.hasCollision[o])continue;const e=new f;e.matrix.identity(),t.getMatrixAt(o,s),e.applyMatrix4(s);this.createStaticBody(e,i)}}else for(let e=0;e<t.count;e++){if(null!=t.userData.hasCollision&&!t.userData.hasCollision[e])continue;const o=new f;o.matrix.identity(),s.fromArray(t.instanceMatrix.array,16*e),o.applyMatrix4(s);this.createStaticBody(o,i)}}getCharacterController(t){return this.world?.createCharacterController(t)}getActorComputedMovement(t,e,s,o=null){const n=this.actorBodies.get(t.id);this.controlledActors.add(t.id);const r=n.collider(0);e.computeColliderMovement(r,s,i.EXCLUDE_SENSORS,o,pt);const a=e.computedMovement();return ct(ut,a),ut}createCollider(t,e){const s=this.addShape(e?.body,t);return new PhysicsCollider(s,this.world)}createBody(t=PhysicsBodyType.dynamic,e={}){const i=(()=>{switch(t){case PhysicsBodyType.dynamic:return s.RigidBodyDesc.dynamic();case PhysicsBodyType.static:return s.RigidBodyDesc.fixed();case PhysicsBodyType.kinematic:return s.RigidBodyDesc.kinematicPositionBased();case PhysicsBodyType.kinematicVelocityBased:return s.RigidBodyDesc.kinematicVelocityBased();default:return s.RigidBodyDesc.dynamic()}})();e.position&&i.setTranslation(e.position.x,e.position.y,e.position.z),e.rotation&&i.setRotation({x:e.rotation.x,y:e.rotation.y,z:e.rotation.z,w:e.rotation.w}),"boolean"==typeof e.canSleep&&i.setCanSleep(e.canSleep),"boolean"==typeof e.ccdEnabled&&i.setCcdEnabled(e.ccdEnabled),"number"==typeof e.gravityScale&&i.setGravityScale(e.gravityScale),"number"==typeof e.mass&&i.setAdditionalMass(e.mass),void 0!==e.userData&&(i.userData=e.userData);const o=this.world.createRigidBody(i);return new PhysicsBody(o,this.world)}getCharacterComputedMovement(t,e,s,o=null){const n=t.collider;e.computeColliderMovement(n,s,i.EXCLUDE_SENSORS,o,pt);const r=e.computedMovement();return ct(ut,r),ut}setNextKinematicTranslation(t,e){const s=this.actorBodies.get(t.id),i=s.translation();i.x+=e.x,i.y+=e.y,i.z+=e.z,s?.setNextKinematicTranslation(i)}setAngularVelocity(t,e){const s=this.actorBodies.get(t.id);tt.x=e.x,tt.y=e.y,tt.z=e.z,s?.setAngvel(tt,!0)}setLinearVelocity(t,e){const s=this.actorBodies.get(t.id);tt.x=e.x,tt.y=e.y,tt.z=e.z,s?.setLinvel(tt,!0)}getLinearVelocity(t,e=new B){const s=this.actorBodies.get(t.id).linvel();return e.x=s.x,e.y=s.y,e.z=s.z,e}getAngularVelocity(t,e=new B){const s=this.actorBodies.get(t.id).angvel();return e.x=s.x,e.y=s.y,e.z=s.z,e}setLinearDamping(t,e){const s=this.actorBodies.get(t.id);s?.setLinearDamping(e)}setAngularDamping(t,e){const s=this.actorBodies.get(t.id);s?.setAngularDamping(e)}setPosition(t,e){const s=this.actorBodies.get(t.id);s?.setTranslation(ot(e),!1)}getPosition(t,e=new B){const s=this.actorBodies.get(t.id);s&&ct(e,s.translation())}setRotation(t,e){const s=this.actorBodies.get(t.id);s?.setTranslation(nt(e),!1)}getRotation(t,e=new w){const s=this.actorBodies.get(t.id);s&&dt(e,s.rotation())}lockTranslations(t,e){const s=this.actorBodies.get(t.id);s?.lockTranslations(e,!1)}lockRotations(t,e){const s=this.actorBodies.get(t.id);s?.lockRotations(e,!1)}setEnabledTranslations(t,e,s,i){const o=this.actorBodies.get(t.id);o?.setEnabledTranslations(e,s,i,!1)}setEnabledRotations(t,e,s,i){const o=this.actorBodies.get(t.id);o?.setEnabledRotations(e,s,i,!1)}addLandscapeGroup(t){const e=t.userData.src,i=e.landscape.heightMaps;for(const n of t.sections){this.staticBodies.has(n)&&this.world.removeRigidBody(this.staticBodies.get(n));var o=n.getWorldPosition(new B);if(e.landscape.holes&&e.landscape.holes.some((t=>t.m===n.name&&0!==t.w[0]))){const t=n.geometry.clone(),i=n.scale,r=n.geometry.getAttribute("hole"),a=new Float32Array(t.getAttribute("position").array);for(let t=0;t<a.length;t+=3)a[t]*=i.x,a[t+1]*=i.y,a[t+2]*=i.z;const l=t.index;for(let t=0;t<l.count;t+=3){const e=r.getX(l.getX(t)),s=r.getX(l.getY(t)),i=r.getX(l.getZ(t));(e>.5||s>.5||i>.5)&&(l.setX(t,0),l.setY(t,0),l.setZ(t,0))}const c=s.ColliderDesc.trimesh(a,new Uint32Array(t.getIndex().array));if(!1!==e.collisionDetection){const t=this.world.createRigidBody(s.RigidBodyDesc.fixed()),e=new s.Vector3(0,0,0);at(e,o),t.setTranslation(e,!1),this.world.createCollider(c,t),this.staticBodies.set(n,t)}continue}const t=e.landscape.options.density+1,r=e.landscape.options.sectionSize,a=new Array(t);for(let e=0;e<t;e++)a[e]=new Array(t).fill(0);const l=i.find((t=>t.x===n.x&&t.y==n.y));if(null!=l)for(const e of l.points){if(null==a[e.i%t])continue;const s=t-1-Math.floor(e.i/t);s in a[e.i%t]?a[e.i%t][s]=e.y/r:console.warn("wrong index",{points:a,point:e,i:e.i%t,k:s,heightMap:l})}const c=e.landscape.options.density,d=a.flatMap((t=>t.reverse())),h=s.ColliderDesc.heightfield(c,c,new Float32Array(d),new s.Vector3(r,r,r));if(!1!==e.collisionDetection){const t=this.world.createRigidBody(s.RigidBodyDesc.fixed()),e=new s.Vector3(0,0,0);at(e,o),t.setTranslation(e,!1),this.world.createCollider(h,t),this.staticBodies.set(n,t)}}}setEnabled(t,e){const s=this.actorBodies.get(t.id);s?.setEnabled(e)}addActor(t,e,i={}){if(0==e.length)return void console.error("No collision shapes were defined when adding actor to the physics system.");this.removeActor(t);const o=t.object;let n;switch(i.type??PhysicsBodyType.static){case PhysicsBodyType.dynamic:n=s.RigidBodyDesc.dynamic(),n.mass=i.mass??1;break;case PhysicsBodyType.kinematic:n=s.RigidBodyDesc.kinematicPositionBased();break;case PhysicsBodyType.kinematicVelocityBased:n=s.RigidBodyDesc.kinematicVelocityBased();break;default:n=i.isTrigger?s.RigidBodyDesc.kinematicVelocityBased():s.RigidBodyDesc.fixed()}const r=this.world.createRigidBody(n);r.enableCcd(1==i.continousCollisionDetection);for(const t of e)this.addShape(r,t,o);ht(r,(t=>{null!=i.isTrigger&&(t.setSensor(i.isTrigger),t.setActiveCollisionTypes(s.ActiveCollisionTypes.ALL),t.setActiveEvents(s.ActiveEvents.COLLISION_EVENTS)),null!=i.friction&&t.setFriction(i.friction),null!=i.density&&t.setDensity(i.density),null!=i.mass&&t.setMass(i.mass),null!=i.restitution&&t.setRestitution(i.restitution)})),Z(r,o),!0===i.ignoreForNavMesh&&(r.userData={ignoreForNavMesh:!0}),this.actorBodies.set(t.id,r),this.bodyActors.set(r,t)}applyTorque(t,e){const s=this.actorBodies.get(t.id);tt.x=e.x,tt.y=e.y,tt.z=e.z,s?.addTorque(tt,!0)}applyTorqueImpulse(t,e){const s=this.actorBodies.get(t.id);tt.x=e.x,tt.y=e.y,tt.z=e.z,s?.applyTorqueImpulse(tt,!0)}resetForces(t){const e=this.actorBodies.get(t.id);e?.resetForces(!1)}resetTorques(t){const e=this.actorBodies.get(t.id);e?.resetTorques(!1)}applyForce(t,e){const s=this.actorBodies.get(t.id);tt.x=e.x,tt.y=e.y,tt.z=e.z,s?.addForce(tt,!0)}applyImpulse(t,e){const s=this.actorBodies.get(t.id);tt.x=e.x,tt.y=e.y,tt.z=e.z,s?.applyImpulse(tt,!0)}applyLocalForce(t,e,s){const i=this.actorBodies.get(t.id);at(tt,e),null==s?i?.addForce(tt,!0):(at(et,s),i?.addForceAtPoint(tt,et,!0))}applyLocalImpulse(t,e,s){const i=this.actorBodies.get(t.id);at(tt,e),null==s?i.applyImpulse(tt,!0):(at(et,s),i.applyImpulseAtPoint(tt,et,!0))}applyRadiusImpulse(t,e,i){this.world.bodies.forEach((o=>{if(o.collider(0)?.isSensor())return;if(o.bodyType()!==s.RigidBodyType.Dynamic)return;const n=st;ct(n,o.translation());const r=n.clone().sub(t);if(r.length()>e)return;const a=r.clone().normalize().multiplyScalar(i);tt.x=a.x,tt.y=a.y,tt.z=a.z,o.applyImpulse(tt,!0)}))}removeActor(t){if(null==t)return;this.controlledActors.delete(t.id);const e=this.actorBodies.get(t.id);null!=e&&(this.bodyActors.delete(e),this.world.removeRigidBody(e)),this.actorBodies.delete(t.id)}removeRemoved(t){if(null==t)return;const e=new Set;t.traverse((t=>{e.add(t.uuid)}));for(const[t,s]of this.staticBodies.entries())!e.has(t.uuid)&&this.world.getRigidBody(s.handle)&&(this.staticBodies.delete(t),this.world.removeRigidBody(s))}removeSceneObject(t){if(t instanceof I){for(const e of t.sections)this.removeSceneObject(e);return}let e=this.staticBodies.get(t);null!=e&&this.world.getRigidBody(e.handle)&&this.world.removeRigidBody(e),this.staticBodies.delete(t)}activateActorEvents(t){this.actorBodies.get(t.id)}_onCollisionWithActorEvent(t,e,s){return this.activateActorEvents(t),this.collisionEvents.pipe(c(t.disposed),r((({started:t})=>t===s)),a((({handle1:t,handle2:e,started:s})=>({a1:this.bodyActors.get(this.world.getCollider(t)?.parent()),a2:this.bodyActors.get(this.world.getCollider(e)?.parent()),started:s}))),r((({a1:s,a2:i})=>null!=s&&null!=i&&s.id===t.id&&e(s,i))),a((({a2:t})=>t)))}onBeginContact(t){return this.activateActorEvents(t),this.collisionEvents.pipe(c(t.disposed),r((t=>t.started)),r((({handle1:e})=>{const s=this.bodyActors.get(this.world.getCollider(e)?.parent());return null!=s&&s.id===t.id})),a((t=>t.handle2)))}onEndContact(t){return this.activateActorEvents(t),this.collisionEvents.pipe(c(t.disposed),r((t=>!t.started)),r((({handle1:e})=>{const s=this.bodyActors.get(this.world.getCollider(e)?.parent());return null!=s&&s.id===t.id})),a((t=>t.handle2)))}onHasContactChanged(t){const e=new Set,s=new o(!1);return this.onBeginContact(t).subscribe((t=>{e.add(t),s.next(e.size>0)})),this.onEndContact(t).subscribe((t=>{e.delete(t),s.next(e.size>0)})),s.pipe(n())}onBeginOverlapWithActorType(t,e){return this._onCollisionWithActorEvent(t,((t,s)=>s instanceof e),!0)}onEndOverlapWithActorType(t,e){return this._onCollisionWithActorEvent(t,((t,s)=>s instanceof e),!1)}onBeginOverlapWithActor(t,e){return this._onCollisionWithActorEvent(t,((t,s)=>e.id===s.id),!0)}onEndOverlapWithActor(t,e){return this._onCollisionWithActorEvent(t,((t,s)=>e.id===s.id),!1)}onCollisionWithActor(t,e){return this.onBeginOverlapWithActor(t,e)}onCollisionWithActorType(t,e){return this.onBeginOverlapWithActorType(t,e)}updateActorTransform(t){const e=this.actorBodies.get(t.id);null!=e&&Z(e,t.object)}setupWorld(){const t=new s.World({x:0,y:-9.81,z:0});this.world=t}sphereCast(t,e,s,i,o=ShapeCastResult.shared,n=void 0){o.reset();const r=this.getBallShape(e);this.shapeCacheBall.get;const a={x:t.x,y:t.y,z:t.z},l={x:s.x,y:s.y,z:s.z},c=this.world.castShape(a,{x:0,y:0,z:0,w:1},l,r,.01,i,!0,null,n,null,void 0,void 0);if(null!=c){ct(o.hitPoint,c.witness1),o.normal.set(c.normal1.x,c.normal1.y,c.normal1.z),o.distance=c.time_of_impact,o.hasHit=!0;const t=c.collider.parent();if(t){const e=this.bodyActors.get(t);e&&(o.actor=e)}}return o}castActorShape(t,e,s,i=ShapeCastResult.shared,o=void 0){i.reset();const n=this.actorBodies.get(t.id);if(n&&n.numColliders()>0){for(let t=0;t<n.numColliders();t++){const r=n.collider(t);let a=r.shape,l=r.translation(),c=r.rotation(),d=e,h=s;const y=this.world.castShape(l,c,d,a,.01,h,!0,null,o,null,n,void 0);if(null!=y){y.collider;const t=r;return ct(i.hitPoint,y.witness1),xt(t.rotation(),y.normal1,i.normal,H),i.distance=y.time_of_impact,i.actor=this.bodyActors.get(y.collider.parent()),i.hasHit=!0,i}}return i}return console.warn("Actor is not added to the physics system"),i}stop(){this.world?.bodies.forEach((t=>this.world.removeRigidBody(t))),this.world?.free(),this.fixedupdateSub?.unsubscribe(),K.length=0}createStaticBody(t,e,i){const o=i?.type===PhysicsBodyType.dynamic?s.RigidBodyDesc.dynamic():s.RigidBodyDesc.fixed(),n=this.world.createRigidBody(o);for(const s of e){if(null==s){console.warn("Collision shape is missing for object",t);continue}const o=this.addShape(n,s,t);null!=i?.friction&&o.setFriction(i.friction),null!=i?.density&&o.setDensity(i.density),null!=i?.mass&&o.setMass(i.mass/e.length),null!=i?.restitution&&o.setRestitution(i.restitution)}return Z(n,t),n.userData=t.uuid,n}addShape(t=void 0,e,s){const i=s?.getWorldScale(gt)??$,o=this.createShape(e,i);this.applyShapeSettings(o,e);const n=e.offset.clone().multiply(i);at(o.translation,n);const r=(new w).setFromEuler(e.rotation);e instanceof R&&e.mesh instanceof d.Mesh&&r.multiply(e.mesh.getWorldQuaternion(Y)),lt(o.rotation,r);return this.world.createCollider(o,t)}applyShapeSettings(t,e){null!=e.collisionGroup&&t.setCollisionGroups(e.collisionGroup),t.friction=e.friction??.1,null!=e.restitution&&(t.restitution=e.restitution),null!=e.density&&(t.density=e.density,t.massPropsMode=s.MassPropsMode.Density),null!=e.mass&&(t.mass=e.mass,t.massPropsMode=s.MassPropsMode.Mass)}createShape(t,e){if(t instanceof z)return s.ColliderDesc.cuboid(t.dimensions.x*e.x/2,t.dimensions.y*e.y/2,t.dimensions.z*e.z/2);if(t instanceof A){return s.ColliderDesc.capsule(t.length/2*e.y,t.radius*Math.max(e.z,e.x))}if(t instanceof _){const i=null!=t.geometry.getIndex()?t.geometry:k.mergeVertices(t.geometry),o=extractFloat32Array(i.getAttribute("position"));for(let t=0;t<o.length;t+=3)o[t]*=e.x,o[t+1]*=e.y,o[t+2]*=e.z;return s.ColliderDesc.trimesh(o,new Uint32Array(i.getIndex().array))}if(t instanceof R){let i;t.mesh instanceof d.Mesh?i=t.mesh.geometry:t.mesh instanceof d.BufferGeometry?i=t.mesh:console.log("Unknownd shape",{shapeInfo:t});const o=extractFloat32Array(i.getAttribute("position"));if(t.mesh instanceof d.Mesh){const e=W(t.mesh);for(let t=0;t<o.length;t+=3)o[t]*=e.x,o[t+1]*=e.y,o[t+2]*=e.z}for(let t=0;t<o.length;t+=3)o[t]*=e.x,o[t+1]*=e.y,o[t+2]*=e.z;const n=o;n.length;return s.ColliderDesc.convexHull(n)}if(t instanceof P){const i=2*e.x-e.y-e.z;return Math.abs(i)>.01?this.createShape(new R(new d.SphereGeometry(t.radius).scale(e.x,e.y,e.z)),new B(1,1,1)):s.ColliderDesc.ball(t.radius*Math.max(e.x,e.y,e.z))}return t instanceof M?s.ColliderDesc.cylinder(t.height/2*e.y,t.radiusTop*Math.max(e.z,e.x)):t instanceof D?s.ColliderDesc.cone(t.height*e.y,t.radiusBottom/2*Math.max(e.z,e.x)):t instanceof E?s.ColliderDesc.cuboid(t.width/2*e.x,t.height/2*e.y,.001):(console.error("Unsupported shape",t),s.ColliderDesc.cuboid(1,1,1))}createCharacterCollision(){return new s.CharacterCollision}};Q=t([v(),e("design:paramtypes",[V])],Q);export{Q as PhysicsSystem};const X=new B,Y=new d.Quaternion;function Z(t,e){const s=e.getWorldPosition(X),i=e.getWorldQuaternion(Y);t.setTranslation(ot(s),!1),t.setRotation(nt(i),!1)}const J=new B,$=new B(1,1,1),tt=new s.Vector3(0,0,0),et=new s.Vector3(0,0,0),st=new B,it=new d.Vector2;function ot(t){return at(tt,t),tt}function nt(t){return lt(H,t),H}const rt=async()=>{let t=await import("@dimforge/rapier3d-compat");return await t.init(),t};function at(t,e){t.x=e.x,t.y=e.y,t.z=e.z}function lt(t,e){t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w}function ct(t,e){t.x=e.x,t.y=e.y,t.z=e.z}function dt(t,e){t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w}function ht(t,e){for(let s=0,i=t.numColliders();s<i;s++){e(t.collider(s))}}const yt=new B,ut=new B,pt=t=>!t.isSensor(),gt=new B;const mt=new s.Ray(new s.Vector3(0,0,0),new s.Vector3(0,1,0));let ft=class extends L{constructor(){super(...arguments),this._active=!0,this.physics=O(Q),this.world=O(F)}set active(t){this._active=t,t?(this.world.scene.remove(this.actor.object),this.physics.setEnabled(this.actor,t)):(this.world.scene.add(this.actor.object),this.physics.setEnabled(this.actor,t))}get active(){return this._active}};ft=t([N()],ft);export function extractFloat32Array(t){const e=t.itemSize,s=t.count,i=new Float32Array(s*e);for(let o=0;o<s;o++)for(let s=0;s<e;s++)i[o*e+s]=t.getComponent(o,s);return i}const wt=new B;function xt(t,e,s,i){return i.set(t.x,t.y,t.z,t.w),s.set(e.x,e.y,e.z),s.applyQuaternion(i),s}export class PhysicsCollider{constructor(t,e){this.collider=t,this.world=e}dispose(){this.world.removeCollider(this.collider,!1)}set mass(t){this.collider.setMass(t)}get mass(){return this.collider.mass()}set friction(t){this.collider.setFriction(t)}get friction(){return this.collider.friction()}set restitution(t){this.collider.setRestitution(t)}get restitution(){return this.collider.restitution()}set density(t){this.collider.setDensity(t)}get density(){return this.collider.density()}set isTrigger(t){this.collider.setSensor(t)}get isTrigger(){return this.collider.isSensor()}set collisionGroups(t){this.collider.setCollisionGroups(t)}get collisionGroups(){return this.collider.collisionGroups()}set enabled(t){this.collider.setEnabled(t)}get enabled(){return this.collider.isEnabled()}}export class PhysicsBody{constructor(t,e){this.body=t,this.world=e}dispose(){this.world.removeRigidBody(this.body)}setEnabled(t){this.body.setEnabled(t)}isEnabled(){return this.body.isEnabled()}getPosition(t){const e=this.body.translation();return t.set(e.x,e.y,e.z),t}setPosition(t){this.body.setTranslation({x:t.x,y:t.y,z:t.z},!0)}getRotation(t){const e=this.body.rotation();return t.set(e.x,e.y,e.z,e.w),t}setRotation(t){this.body.setRotation({x:t.x,y:t.y,z:t.z,w:t.w},!0)}getLinearVelocity(t){const e=this.body.linvel();return t.set(e.x,e.y,e.z),t}setLinearVelocity(t){this.body.setLinvel({x:t.x,y:t.y,z:t.z},!0)}getAngularVelocity(t){const e=this.body.angvel();return t.set(e.x,e.y,e.z),t}setAngularVelocity(t){this.body.setAngvel({x:t.x,y:t.y,z:t.z},!0)}applyImpulse(t,e=!0){this.body.applyImpulse({x:t.x,y:t.y,z:t.z},e)}applyTorqueImpulse(t,e=!0){this.body.applyTorqueImpulse({x:t.x,y:t.y,z:t.z},e)}setNextKinematicTranslation(t){this.body.setNextKinematicTranslation({x:t.x,y:t.y,z:t.z})}setNextKinematicRotation(t){this.body.setNextKinematicRotation({x:t.x,y:t.y,z:t.z,w:t.w})}isDynamic(){return this.body.isDynamic()}isKinematic(){return this.body.isKinematic()}isStatic(){return this.body.isFixed()}sleep(){this.body.sleep()}wakeUp(){this.body.wakeUp()}}/*
1
+ import{__decorate as t,__metadata as e}from"tslib";import*as i from"@dimforge/rapier3d-compat";import{QueryFilterFlags as s}from"@dimforge/rapier3d-compat";import{BehaviorSubject as o,distinctUntilChanged as n,filter as r,map as a,Subject as l,takeUntil as c}from"rxjs";import*as d from"three";import{ArrowHelper as h,BufferAttribute as u,BufferGeometry as y,Group as p,LineSegments as g,Matrix4 as m,Object3D as f,Quaternion as w,Raycaster as x,Scene as b,Vector3 as B}from"three";import{Service as v}from"typedi";import{AssetMeshInstance as C}from"../../../scene/asset-resource-loader.js";import{BoxCollisionShape as A,CapsuleCollisionShape as S,CollisionShapeSource as z,ConeCollisionShape as R,ConvexPolyhedronCollisionShape as D,CylinderCollisionShape as M,PhysicalShapeMesh as E,PlaneCollisionShape as T,SphereCollisionShape as P,TrimeshCollisionShape as _}from"../../../index.js";import{LandscapeGroup as I}from"../../../scene/landscape/landscape.js";import{ViewController as V}from"../render.js";import{World as F}from"../world.js";import*as W from"three/examples/jsm/utils/BufferGeometryUtils.js";import{calculateEffectiveScale as k}from"../../../utils/three/traverse.js";import{AbstractPhysicsSystem as N}from"./abstract-physics-system.js";import{ActorComponent as j,Component as L}from"../../../gameplay/actors/component.js";import{inject as O}from"../../../gameplay/inject.js";export{Component,ActorComponent,attach,Attach}from"../../actors/component.js";export class RayTestResult{constructor(){this.hasHit=!1,this.hitPoint=new B,this.hitNormal=new B}}export class ShapeCastResult{constructor(){this.hasHit=!1,this.hitPoint=new B,this.normal=new B}reset(){this.actor=void 0,this.hasHit=!1,this.distance=0,this.hitPoint.set(0,0,0),this.normal.set(0,0,0)}}ShapeCastResult.shared=new ShapeCastResult;export var PhysicsBodyType;!function(t){t[t.dynamic=1]="dynamic",t[t.static=2]="static",t[t.kinematic=4]="kinematic",t[t.kinematicVelocityBased=8]="kinematicVelocityBased"}(PhysicsBodyType||(PhysicsBodyType={}));const G=new B,K=new B,q=new w,U=new w,H=(new w,[]);let Q=class extends N{set showDebug(t){this.shouldRenderDebug=t,this.debugMesh&&(this.debugMesh.visible=t)}get showDebug(){return this.shouldRenderDebug}constructor(t){super(),this.viewController=t,this.staticMeshes=new Map,this.staticBodies=new Map,this.actorBodies=new Map,this.bodyActors=new Map,this.colliders=new Map,this.collisionEvents=new l,this.beforeStep=new l,this.afterStep=new l,this.shouldRenderDebug=!1,this.shapeCacheBox=new Map,this.shapeCacheBall=new Map,this._raycaster=new x,this._reusableResult=new RayTestResult,this._raytestDiff=new B,this._raytestDirection=new B,this.controlledActors=new Set,this.ready=this.setup()}getBallShape(t){let e=this.shapeCacheBall.get(t);return null==e&&(e=new i.Ball(t),this.shapeCacheBall.set(t,e)),e}getBoxShape(t,e,s){const o=t+1e6*e+1e12*s;let n=this.shapeCacheBox.get(o);return null==n&&(n=new i.Cuboid(t,e,s),this.shapeCacheBox.set(o,n)),n}hasBoxIntersection(t){const e=t.getCenter(G),i=t.getSize(K),s=this.getBoxShape(i.x/2,i.y/2,i.z/2);return null!=this.world.intersectionWithShape(e,q,s)}hasSphereIntersection(t){const e=this.getBallShape(t.radius);return null!=this.world.intersectionWithShape(t.center,q,e)}createDebugMesh(){return new g(new y,new d.LineBasicMaterial({color:255}))}async start(){return await this.ready,this.handleTick(),this.handleCollisionEvents(),this.ready}handleCollisionEvents(){this.collisionSub=this.collisionEvents.subscribe((t=>{const e=this.colliders.get(t.handle1);if(null==e)return;if(null!=this.colliders.get(t.handle2));else{const i=this.world.getCollider(t.handle2);if(null==i||null==i.parent())return;const s=this.bodyActors.get(i.parent());if(null==s)return;t.started?e.onBeginOverlapActor.next({actor:s}):e.onEndOverlapActor.next({actor:s})}}))}renderDebug(){if(null==this.scene)return;null==this.debugMesh&&(this.debugMesh=this.createDebugMesh(),this.debugMesh.visible=this.shouldRenderDebug,this.debugMesh.raycast=function(){},this.scene?.add(this.debugMesh));const t=this.world.debugRender();this.debugMesh.geometry.setAttribute("position",new u(t.vertices,3))}async setup(){if(null!=this.rapier)throw new Error("Rapier is already estup");this.rapier=await rt(),this.eventQueue=new i.EventQueue(!0),this.setupWorld()}handleTick(){this.fixedupdateSub=this.viewController.onUpdate().subscribe((t=>{t=Math.min(.1,t),this.beforeStep.next(t),this.updatePhysics(t),this.showDebug&&this.renderDebug(),this.world.bodies.forEach((t=>{if(t.isFixed())return;const e=this.staticMeshes.get(t)??this.bodyActors.get(t)?.object;null!=e&&e.parent instanceof b&&(ct(e.position,t.translation()),(t.isDynamic()||t.isKinematic()&&!this.controlledActors.has(this.bodyActors.get(t)?.id))&&dt(e.quaternion,t.rotation()),e.updateMatrix(),e.updateWorldMatrix(!1,!1))})),this.afterStep.next(t)}))}_updateWorld(){this.world.timestep=0,this.world.step()}updatePhysics(t){this.world.timestep=t,this.world.step(this.eventQueue),this.eventQueue.drainCollisionEvents(((t,e,i)=>{this.collisionEvents.next({handle1:t,handle2:e,started:i}),this.collisionEvents.next({handle1:e,handle2:t,started:i})}))}rayTestFromCamera(t,e,i){this._raycaster.setFromCamera(st,this.viewController.getCamera());const s=this._raycaster.ray.origin,o=this._raycaster.ray.direction.multiplyScalar(t).add(s);return this.rayTest(s,o,e,i)}rayTest(t,e,i,s){null==i&&(i=this._reusableResult);const o=this._raytestDiff,n=this._raytestDirection;if(o.subVectors(e,t),n.copy(o).normalize(),0===n.length())return console.warn("Ray test called with to and from being equal"),i;at(mt.origin,t),at(mt.dir,n);const r=o.length(),a=this.world.castRayAndGetNormal(mt,r,!1,void 0,s?.collisionFilter,void 0,null!=s?.excludeActor?this.actorBodies.get(s.excludeActor.id):void 0,s?.excludeTriggers?t=>!t.isSensor():void 0);if(i.hasHit=null!=a,i.hasHit){const e=mt.pointAt(a.timeOfImpact);i._internal=a,ct(i.hitNormal,a.normal),ct(i.hitPoint,e),i.distance=ut.subVectors(i.hitPoint,t).length();const s=this.world.bodies.getAll().find((t=>function(t,e){for(let i=0,s=t.numColliders();i<s;i++){const s=t.collider(i);if(e(s))return s}}(t,(t=>t===a.collider))));i.actor=null!=s?this.bodyActors.get(s):null}if(this.showDebug){let e;H.length>0?(e=H.pop(),e.setDirection(n),e.position.copy(t),e.setLength(r,.2,.1),e.setColor(s?.debugColor??255)):e=new h(n,t,r,s?.debugColor??255),this.scene?.add(e),setTimeout((()=>{this.scene?.remove(e),H.push(e)}),s?.debugLifetime??200)}return i}setGravity(t,e,i){this.world.gravity.x=t,this.world.gravity.y=e,this.world.gravity.z=i}getGravity(){return J.set(this.world.gravity.x,this.world.gravity.y,this.world.gravity.z)}addFromScene(t){this.addRecursively(t);for(const t of this.staticBodies.values())ht(t,(t=>t.setActiveEvents(i.ActiveEvents.COLLISION_EVENTS)))}addRecursively(t){if(this.removeSceneObject(t),!function(t){if(null!=t.userData?.src){const e=t.userData?.src;return"actor"===e.type}return!1}(t))if(t instanceof E&&null!=t.collisionShape){const e=this.createStaticBody(t,[t.collisionShape],t.physics);this.staticMeshes.set(e,t),this.staticBodies.set(t,e)}else if(t instanceof C&&!1!==t.userData?.src?.collisionDetection)if(t.children[0]&&(t.children[0].instanceMatrix||t.children[0].isBatchedMesh))this.createForInstancedMesh(t.children[0],t.collisionShapes);else{const e=this.createStaticBody(t,t.collisionShapes,t.physics);this.staticMeshes.set(e,t),this.staticBodies.set(t,e)}else t instanceof I?this.addLandscapeGroup(t):(t instanceof p||t instanceof b)&&t.children.forEach((t=>this.addRecursively(t)))}createForInstancedMesh(t,e){const i=new m,s=e.filter((t=>null!=t)).map((t=>t.source===z.rendered?t.withOffset(wt):t));if(t instanceof d.BatchedMesh){const e=t._instanceInfo??t._drawInfo;for(let o=0;o<e.length;o++){if(null!=t.userData.hasCollision&&!t.userData.hasCollision[o])continue;const e=new f;e.matrix.identity(),t.getMatrixAt(o,i),e.applyMatrix4(i);this.createStaticBody(e,s)}}else for(let e=0;e<t.count;e++){if(null!=t.userData.hasCollision&&!t.userData.hasCollision[e])continue;const o=new f;o.matrix.identity(),i.fromArray(t.instanceMatrix.array,16*e),o.applyMatrix4(i);this.createStaticBody(o,s)}}getCharacterController(t){return this.world?.createCharacterController(t)}getActorComputedMovement(t,e,i,o=null){const n=this.actorBodies.get(t.id);this.controlledActors.add(t.id);const r=n.collider(0);e.computeColliderMovement(r,i,s.EXCLUDE_SENSORS,o,pt);const a=e.computedMovement();return ct(yt,a),yt}createCollider(t,e){const i=this.addShape(e?.body,t),s=new PhysicsCollider(i,this.world);return this.colliders.set(i.handle,s),s.disposed.subscribe((()=>{this.colliders.delete(i.handle)})),s}createBody(t=PhysicsBodyType.dynamic,e={}){const s=(()=>{switch(t){case PhysicsBodyType.dynamic:return i.RigidBodyDesc.dynamic();case PhysicsBodyType.static:return i.RigidBodyDesc.fixed();case PhysicsBodyType.kinematic:return i.RigidBodyDesc.kinematicPositionBased();case PhysicsBodyType.kinematicVelocityBased:return i.RigidBodyDesc.kinematicVelocityBased();default:return i.RigidBodyDesc.dynamic()}})();e.position&&s.setTranslation(e.position.x,e.position.y,e.position.z),e.rotation&&s.setRotation({x:e.rotation.x,y:e.rotation.y,z:e.rotation.z,w:e.rotation.w}),"boolean"==typeof e.canSleep&&s.setCanSleep(e.canSleep),"boolean"==typeof e.ccdEnabled&&s.setCcdEnabled(e.ccdEnabled),"number"==typeof e.gravityScale&&s.setGravityScale(e.gravityScale),"number"==typeof e.mass&&s.setAdditionalMass(e.mass),void 0!==e.userData&&(s.userData=e.userData);const o=this.world.createRigidBody(s);return new PhysicsBody(o,this.world)}getCharacterComputedMovement(t,e,i,o=null){const n=t.collider;e.computeColliderMovement(n,i,s.EXCLUDE_SENSORS,o,pt);const r=e.computedMovement();return ct(yt,r),yt}setNextKinematicTranslation(t,e){const i=this.actorBodies.get(t.id),s=i.translation();s.x+=e.x,s.y+=e.y,s.z+=e.z,i?.setNextKinematicTranslation(s)}setNextKinematicPosition(t,e){this.actorBodies.get(t.id).setNextKinematicTranslation(e)}setNextKinematicRotation(t,e){this.actorBodies.get(t.id).setNextKinematicRotation(e)}setNextKinematicTransform(t){!function(t,e){const i=e.getWorldPosition(X),s=e.getWorldQuaternion(Y);t.setNextKinematicTranslation(ot(i)),t.setNextKinematicRotation(nt(s))}(this.actorBodies.get(t.id),t.object)}setAngularVelocity(t,e){const i=this.actorBodies.get(t.id);tt.x=e.x,tt.y=e.y,tt.z=e.z,i?.setAngvel(tt,!0)}setLinearVelocity(t,e){const i=this.actorBodies.get(t.id);tt.x=e.x,tt.y=e.y,tt.z=e.z,i?.setLinvel(tt,!0)}getLinearVelocity(t,e=new B){const i=this.actorBodies.get(t.id).linvel();return e.x=i.x,e.y=i.y,e.z=i.z,e}getAngularVelocity(t,e=new B){const i=this.actorBodies.get(t.id).angvel();return e.x=i.x,e.y=i.y,e.z=i.z,e}setLinearDamping(t,e){const i=this.actorBodies.get(t.id);i?.setLinearDamping(e)}setAngularDamping(t,e){const i=this.actorBodies.get(t.id);i?.setAngularDamping(e)}setPosition(t,e){const i=this.actorBodies.get(t.id);i?.setTranslation(ot(e),!1)}getPosition(t,e=new B){const i=this.actorBodies.get(t.id);i&&ct(e,i.translation())}setRotation(t,e){const i=this.actorBodies.get(t.id);i?.setTranslation(nt(e),!1)}getRotation(t,e=new w){const i=this.actorBodies.get(t.id);i&&dt(e,i.rotation())}lockTranslations(t,e){const i=this.actorBodies.get(t.id);i?.lockTranslations(e,!1)}lockRotations(t,e){const i=this.actorBodies.get(t.id);i?.lockRotations(e,!1)}setEnabledTranslations(t,e,i,s){const o=this.actorBodies.get(t.id);o?.setEnabledTranslations(e,i,s,!1)}setEnabledRotations(t,e,i,s){const o=this.actorBodies.get(t.id);o?.setEnabledRotations(e,i,s,!1)}addLandscapeGroup(t){const e=t.userData.src,s=e.landscape.heightMaps;for(const n of t.sections){this.staticBodies.has(n)&&this.world.removeRigidBody(this.staticBodies.get(n));var o=n.getWorldPosition(new B);if(e.landscape.holes&&e.landscape.holes.some((t=>t.m===n.name&&0!==t.w[0]))){const t=n.geometry.clone(),s=n.scale,r=n.geometry.getAttribute("hole"),a=new Float32Array(t.getAttribute("position").array);for(let t=0;t<a.length;t+=3)a[t]*=s.x,a[t+1]*=s.y,a[t+2]*=s.z;const l=t.index;for(let t=0;t<l.count;t+=3){const e=r.getX(l.getX(t)),i=r.getX(l.getY(t)),s=r.getX(l.getZ(t));(e>.5||i>.5||s>.5)&&(l.setX(t,0),l.setY(t,0),l.setZ(t,0))}const c=i.ColliderDesc.trimesh(a,new Uint32Array(t.getIndex().array));if(!1!==e.collisionDetection){const t=this.world.createRigidBody(i.RigidBodyDesc.fixed()),e=new i.Vector3(0,0,0);at(e,o),t.setTranslation(e,!1),this.world.createCollider(c,t),this.staticBodies.set(n,t)}continue}const t=e.landscape.options.density+1,r=e.landscape.options.sectionSize,a=new Array(t);for(let e=0;e<t;e++)a[e]=new Array(t).fill(0);const l=s.find((t=>t.x===n.x&&t.y==n.y));if(null!=l)for(const e of l.points){if(null==a[e.i%t])continue;const i=t-1-Math.floor(e.i/t);i in a[e.i%t]?a[e.i%t][i]=e.y/r:console.warn("wrong index",{points:a,point:e,i:e.i%t,k:i,heightMap:l})}const c=e.landscape.options.density,d=a.flatMap((t=>t.reverse())),h=i.ColliderDesc.heightfield(c,c,new Float32Array(d),new i.Vector3(r,r,r));if(!1!==e.collisionDetection){const t=this.world.createRigidBody(i.RigidBodyDesc.fixed()),e=new i.Vector3(0,0,0);at(e,o),t.setTranslation(e,!1),this.world.createCollider(h,t),this.staticBodies.set(n,t)}}}setEnabled(t,e){const i=this.actorBodies.get(t.id);i?.setEnabled(e)}addActor(t,e,s={}){if(0==e.length)return void console.error("No collision shapes were defined when adding actor to the physics system.");this.removeActor(t);const o=t.object;let n;switch(s.type??PhysicsBodyType.static){case PhysicsBodyType.dynamic:n=i.RigidBodyDesc.dynamic(),n.mass=s.mass??1;break;case PhysicsBodyType.kinematic:n=i.RigidBodyDesc.kinematicPositionBased();break;case PhysicsBodyType.kinematicVelocityBased:n=i.RigidBodyDesc.kinematicVelocityBased();break;default:n=s.isTrigger?i.RigidBodyDesc.kinematicVelocityBased():i.RigidBodyDesc.fixed()}const r=this.world.createRigidBody(n);r.enableCcd(1==s.continousCollisionDetection);for(const t of e)this.addShape(r,t,o);ht(r,(t=>{null!=s.isTrigger&&(t.setSensor(s.isTrigger),t.setActiveCollisionTypes(i.ActiveCollisionTypes.ALL),t.setActiveEvents(i.ActiveEvents.COLLISION_EVENTS)),null!=s.friction&&t.setFriction(s.friction),null!=s.density&&t.setDensity(s.density),null!=s.mass&&t.setMass(s.mass),null!=s.restitution&&t.setRestitution(s.restitution)})),Z(r,o),!0===s.ignoreForNavMesh&&(r.userData={ignoreForNavMesh:!0}),this.actorBodies.set(t.id,r),this.bodyActors.set(r,t)}applyTorque(t,e){const i=this.actorBodies.get(t.id);tt.x=e.x,tt.y=e.y,tt.z=e.z,i?.addTorque(tt,!0)}applyTorqueImpulse(t,e){const i=this.actorBodies.get(t.id);tt.x=e.x,tt.y=e.y,tt.z=e.z,i?.applyTorqueImpulse(tt,!0)}resetForces(t){const e=this.actorBodies.get(t.id);e?.resetForces(!1)}resetTorques(t){const e=this.actorBodies.get(t.id);e?.resetTorques(!1)}applyForce(t,e){const i=this.actorBodies.get(t.id);tt.x=e.x,tt.y=e.y,tt.z=e.z,i?.addForce(tt,!0)}applyImpulse(t,e){const i=this.actorBodies.get(t.id);tt.x=e.x,tt.y=e.y,tt.z=e.z,i?.applyImpulse(tt,!0)}applyLocalForce(t,e,i){const s=this.actorBodies.get(t.id);at(tt,e),null==i?s?.addForce(tt,!0):(at(et,i),s?.addForceAtPoint(tt,et,!0))}applyLocalImpulse(t,e,i){const s=this.actorBodies.get(t.id);at(tt,e),null==i?s.applyImpulse(tt,!0):(at(et,i),s.applyImpulseAtPoint(tt,et,!0))}applyRadiusImpulse(t,e,s){this.world.bodies.forEach((o=>{if(o.collider(0)?.isSensor())return;if(o.bodyType()!==i.RigidBodyType.Dynamic)return;const n=it;ct(n,o.translation());const r=n.clone().sub(t);if(r.length()>e)return;const a=r.clone().normalize().multiplyScalar(s);tt.x=a.x,tt.y=a.y,tt.z=a.z,o.applyImpulse(tt,!0)}))}removeActor(t){if(null==t)return;this.controlledActors.delete(t.id);const e=this.actorBodies.get(t.id);null!=e&&(this.bodyActors.delete(e),this.world.removeRigidBody(e)),this.actorBodies.delete(t.id)}removeRemoved(t){if(null==t)return;const e=new Set;t.traverse((t=>{e.add(t.uuid)}));for(const[t,i]of this.staticBodies.entries())!e.has(t.uuid)&&this.world.getRigidBody(i.handle)&&(this.staticBodies.delete(t),this.world.removeRigidBody(i))}removeSceneObject(t){if(t instanceof I){for(const e of t.sections)this.removeSceneObject(e);return}let e=this.staticBodies.get(t);null!=e&&this.world.getRigidBody(e.handle)&&this.world.removeRigidBody(e),this.staticBodies.delete(t)}activateActorEvents(t){this.actorBodies.get(t.id)}_onCollisionWithActorEvent(t,e,i){return this.activateActorEvents(t),this.collisionEvents.pipe(c(t.disposed),r((({started:t})=>t===i)),a((({handle1:t,handle2:e,started:i})=>({a1:this.bodyActors.get(this.world.getCollider(t)?.parent()),a2:this.bodyActors.get(this.world.getCollider(e)?.parent()),started:i}))),r((({a1:i,a2:s})=>null!=i&&null!=s&&i.id===t.id&&e(i,s))),a((({a2:t})=>t)))}onBeginContact(t){return this.activateActorEvents(t),this.collisionEvents.pipe(c(t.disposed),r((t=>t.started)),r((({handle1:e})=>{const i=this.bodyActors.get(this.world.getCollider(e)?.parent());return null!=i&&i.id===t.id})),a((t=>t.handle2)))}onEndContact(t){return this.activateActorEvents(t),this.collisionEvents.pipe(c(t.disposed),r((t=>!t.started)),r((({handle1:e})=>{const i=this.bodyActors.get(this.world.getCollider(e)?.parent());return null!=i&&i.id===t.id})),a((t=>t.handle2)))}onHasContactChanged(t){const e=new Set,i=new o(!1);return this.onBeginContact(t).subscribe((t=>{e.add(t),i.next(e.size>0)})),this.onEndContact(t).subscribe((t=>{e.delete(t),i.next(e.size>0)})),i.pipe(n())}onBeginOverlapWithActorType(t,e){return this._onCollisionWithActorEvent(t,((t,i)=>i instanceof e),!0)}onEndOverlapWithActorType(t,e){return this._onCollisionWithActorEvent(t,((t,i)=>i instanceof e),!1)}onBeginOverlapWithActor(t,e){return this._onCollisionWithActorEvent(t,((t,i)=>e.id===i.id),!0)}onEndOverlapWithActor(t,e){return this._onCollisionWithActorEvent(t,((t,i)=>e.id===i.id),!1)}onCollisionWithActor(t,e){return this.onBeginOverlapWithActor(t,e)}onCollisionWithActorType(t,e){return this.onBeginOverlapWithActorType(t,e)}updateActorTransform(t){const e=this.actorBodies.get(t.id);null!=e&&Z(e,t.object)}setupWorld(){const t=new i.World({x:0,y:-9.81,z:0});this.world=t}sphereCast(t,e,i,s,o=ShapeCastResult.shared,n=void 0){o.reset();const r=this.getBallShape(e);this.shapeCacheBall.get;const a={x:t.x,y:t.y,z:t.z},l={x:i.x,y:i.y,z:i.z},c=this.world.castShape(a,{x:0,y:0,z:0,w:1},l,r,.01,s,!0,null,n,null,void 0,void 0);if(null!=c){ct(o.hitPoint,c.witness1),o.normal.set(c.normal1.x,c.normal1.y,c.normal1.z),o.distance=c.time_of_impact,o.hasHit=!0;const t=c.collider.parent();if(t){const e=this.bodyActors.get(t);e&&(o.actor=e)}}return o}castActorShape(t,e,i,s=ShapeCastResult.shared,o=void 0){s.reset();const n=this.actorBodies.get(t.id);if(n&&n.numColliders()>0){for(let t=0;t<n.numColliders();t++){const r=n.collider(t);let a=r.shape,l=r.translation(),c=r.rotation(),d=e,h=i;const u=this.world.castShape(l,c,d,a,.01,h,!0,null,o,null,n,void 0);if(null!=u){u.collider;const t=r;return ct(s.hitPoint,u.witness1),xt(t.rotation(),u.normal1,s.normal,U),s.distance=u.time_of_impact,s.actor=this.bodyActors.get(u.collider.parent()),s.hasHit=!0,s}}return s}return console.warn("Actor is not added to the physics system"),s}stop(){this.world?.bodies.forEach((t=>this.world.removeRigidBody(t))),this.world?.free(),this.fixedupdateSub?.unsubscribe(),this.collisionSub?.unsubscribe(),H.length=0}createStaticBody(t,e,s){const o=s?.type===PhysicsBodyType.dynamic?i.RigidBodyDesc.dynamic():i.RigidBodyDesc.fixed(),n=this.world.createRigidBody(o);for(const i of e){if(null==i){console.warn("Collision shape is missing for object",t);continue}const o=this.addShape(n,i,t);null!=s?.friction&&o.setFriction(s.friction),null!=s?.density&&o.setDensity(s.density),null!=s?.mass&&o.setMass(s.mass/e.length),null!=s?.restitution&&o.setRestitution(s.restitution)}return Z(n,t),n.userData=t.uuid,n}addShape(t=void 0,e,i){const s=i?.getWorldScale(gt)??$,o=this.createShape(e,s);this.applyShapeSettings(o,e);const n=e.offset.clone().multiply(s);at(o.translation,n);const r=(new w).setFromEuler(e.rotation);e instanceof D&&e.mesh instanceof d.Mesh&&r.multiply(e.mesh.getWorldQuaternion(Y)),lt(o.rotation,r);return this.world.createCollider(o,t)}applyShapeSettings(t,e){null!=e.collisionGroup&&t.setCollisionGroups(e.collisionGroup),t.friction=e.friction??.1,null!=e.restitution&&(t.restitution=e.restitution),null!=e.density&&(t.density=e.density,t.massPropsMode=i.MassPropsMode.Density),null!=e.mass&&(t.mass=e.mass,t.massPropsMode=i.MassPropsMode.Mass)}createShape(t,e){if(t instanceof A)return i.ColliderDesc.cuboid(t.dimensions.x*e.x/2,t.dimensions.y*e.y/2,t.dimensions.z*e.z/2);if(t instanceof S){return i.ColliderDesc.capsule(t.length/2*e.y,t.radius*Math.max(e.z,e.x))}if(t instanceof _){const s=null!=t.geometry.getIndex()?t.geometry:W.mergeVertices(t.geometry),o=extractFloat32Array(s.getAttribute("position"));for(let t=0;t<o.length;t+=3)o[t]*=e.x,o[t+1]*=e.y,o[t+2]*=e.z;return i.ColliderDesc.trimesh(o,new Uint32Array(s.getIndex().array))}if(t instanceof D){let s;t.mesh instanceof d.Mesh?s=t.mesh.geometry:t.mesh instanceof d.BufferGeometry?s=t.mesh:console.log("Unknownd shape",{shapeInfo:t});const o=extractFloat32Array(s.getAttribute("position"));if(t.mesh instanceof d.Mesh){const e=k(t.mesh);for(let t=0;t<o.length;t+=3)o[t]*=e.x,o[t+1]*=e.y,o[t+2]*=e.z}for(let t=0;t<o.length;t+=3)o[t]*=e.x,o[t+1]*=e.y,o[t+2]*=e.z;const n=o;n.length;return i.ColliderDesc.convexHull(n)}if(t instanceof P){const s=2*e.x-e.y-e.z;return Math.abs(s)>.01?this.createShape(new D(new d.SphereGeometry(t.radius).scale(e.x,e.y,e.z)),new B(1,1,1)):i.ColliderDesc.ball(t.radius*Math.max(e.x,e.y,e.z))}return t instanceof M?i.ColliderDesc.cylinder(t.height/2*e.y,t.radiusTop*Math.max(e.z,e.x)):t instanceof R?i.ColliderDesc.cone(t.height*e.y,t.radiusBottom/2*Math.max(e.z,e.x)):t instanceof T?i.ColliderDesc.cuboid(t.width/2*e.x,t.height/2*e.y,.001):(console.error("Unsupported shape",t),i.ColliderDesc.cuboid(1,1,1))}createCharacterCollision(){return new i.CharacterCollision}};Q=t([v(),e("design:paramtypes",[V])],Q);export{Q as PhysicsSystem};const X=new B,Y=new d.Quaternion;function Z(t,e){const i=e.getWorldPosition(X),s=e.getWorldQuaternion(Y);t.setTranslation(ot(i),!1),t.setRotation(nt(s),!1)}const J=new B,$=new B(1,1,1),tt=new i.Vector3(0,0,0),et=new i.Vector3(0,0,0),it=new B,st=new d.Vector2;function ot(t){return at(tt,t),tt}function nt(t){return lt(U,t),U}const rt=async()=>{let t=await import("@dimforge/rapier3d-compat");return await t.init(),t};function at(t,e){t.x=e.x,t.y=e.y,t.z=e.z}function lt(t,e){t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w}function ct(t,e){t.x=e.x,t.y=e.y,t.z=e.z}function dt(t,e){t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w}function ht(t,e){for(let i=0,s=t.numColliders();i<s;i++){e(t.collider(i))}}const ut=new B,yt=new B,pt=t=>!t.isSensor(),gt=new B;const mt=new i.Ray(new i.Vector3(0,0,0),new i.Vector3(0,1,0));let ft=class extends j{constructor(){super(...arguments),this._active=!0,this.physics=O(Q),this.world=O(F)}set active(t){this._active=t,t?(this.world.scene.remove(this.actor.object),this.physics.setEnabled(this.actor,t)):(this.world.scene.add(this.actor.object),this.physics.setEnabled(this.actor,t))}get active(){return this._active}};ft=t([L()],ft);export function extractFloat32Array(t){const e=t.itemSize,i=t.count,s=new Float32Array(i*e);for(let o=0;o<i;o++)for(let i=0;i<e;i++)s[o*e+i]=t.getComponent(o,i);return s}const wt=new B;function xt(t,e,i,s){return s.set(t.x,t.y,t.z,t.w),i.set(e.x,e.y,e.z),i.applyQuaternion(s),i}export class PhysicsCollider{constructor(t,e){this.collider=t,this.world=e,this.disposed=new l,this.onBeginOverlapActor=new l,this.onEndOverlapActor=new l}dispose(){this.world.removeCollider(this.collider,!1),this.disposed.next(!0),this.disposed.complete(),this.onBeginOverlapActor.complete(),this.onEndOverlapActor.complete()}set mass(t){this.collider.setMass(t)}get mass(){return this.collider.mass()}set friction(t){this.collider.setFriction(t)}get friction(){return this.collider.friction()}set restitution(t){this.collider.setRestitution(t)}get restitution(){return this.collider.restitution()}set density(t){this.collider.setDensity(t)}get density(){return this.collider.density()}set isTrigger(t){this.collider.setSensor(t)}get isTrigger(){return this.collider.isSensor()}set collisionGroups(t){this.collider.setCollisionGroups(t)}get collisionGroups(){return this.collider.collisionGroups()}set enabled(t){this.collider.setEnabled(t)}get enabled(){return this.collider.isEnabled()}}export class PhysicsBody{constructor(t,e){this.body=t,this.world=e}dispose(){this.world.removeRigidBody(this.body)}setEnabled(t){this.body.setEnabled(t)}isEnabled(){return this.body.isEnabled()}getPosition(t){const e=this.body.translation();return t.set(e.x,e.y,e.z),t}setPosition(t){this.body.setTranslation({x:t.x,y:t.y,z:t.z},!0)}getRotation(t){const e=this.body.rotation();return t.set(e.x,e.y,e.z,e.w),t}setRotation(t){this.body.setRotation({x:t.x,y:t.y,z:t.z,w:t.w},!0)}getLinearVelocity(t){const e=this.body.linvel();return t.set(e.x,e.y,e.z),t}setLinearVelocity(t){this.body.setLinvel({x:t.x,y:t.y,z:t.z},!0)}getAngularVelocity(t){const e=this.body.angvel();return t.set(e.x,e.y,e.z),t}setAngularVelocity(t){this.body.setAngvel({x:t.x,y:t.y,z:t.z},!0)}applyImpulse(t,e=!0){this.body.applyImpulse({x:t.x,y:t.y,z:t.z},e)}applyTorqueImpulse(t,e=!0){this.body.applyTorqueImpulse({x:t.x,y:t.y,z:t.z},e)}setNextKinematicPosition(t){this.body.setNextKinematicTranslation(t)}setNextKinematicRotation(t){this.body.setNextKinematicRotation(t)}isDynamic(){return this.body.isDynamic()}isKinematic(){return this.body.isKinematic()}isStatic(){return this.body.isFixed()}sleep(){this.body.sleep()}wakeUp(){this.body.wakeUp()}}/*
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":"asset-resource-loader.d.ts","sourceRoot":"","sources":["../../src/scene/asset-resource-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6G,QAAQ,EAAE,OAAO,EAA+B,MAAM,OAAO,CAAC;AAIlL,OAAO,EAAE,KAAK,EAAY,MAAM,YAAY,CAAC;AAG7C,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAW/D,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,SAAS,CAAmE;IAEpF,OAAO,CAAC,SAAS,CAAsC;IACvD,OAAO,CAAC,SAAS,CAAsC;IACvD,OAAO,CAAC,aAAa,CAAyC;IAC9D,OAAO,CAAC,SAAS,CAAqC;IACtD,OAAO,CAAC,SAAS,CAAqC;IACtD,OAAO,CAAC,UAAU,CAAyC;IAC3D,OAAO,CAAC,SAAS,CAA0C;IAC3D,OAAO,CAAC,UAAU,CAAsC;IACxD,OAAO,CAAC,cAAc,CAAmD;IACzE,OAAO,CAAC,WAAW,CAAuC;IAC1D,OAAO,CAAC,eAAe,CAAQ;IAE/B,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO;IAIhC,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,KAAK,CAAiC;;IAIvC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,aAAa;IAMtC,UAA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iBzD,OAAO,CAAC,mBAAmB,CAAsC;IACjE,OAAO,CAAC,sBAAsB;YAShB,QAAQ;IAyBtB,OAAO,CAAC,eAAe,CAAoB;IAC3C,OAAO,CAAC,kBAAkB;YAyEZ,WAAW;CAkC1B;AAgBD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,iBAAiB,CAAC;IACzB,UAAU,EAAE,KAAK,CAAC,aAAa,EAAE,CAAA;CAClC;AAED,qBAAa,iBAAkB,SAAQ,QAAQ;IAC7C,eAAe,CAAC,EAAE,cAAc,EAAE,CAAA;IAClC,OAAO,CAAC,EAAE,0BAA0B,CAAA;CACrC;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAInD;AAiFD,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;OAIG;IACH,cAAc,EAAE,OAAO,CAAA;CACxB,CAAA"}
@@ -1,4 +1,4 @@
1
- import{AudioLoader as e,BufferGeometry as t,Group as s,LoadingManager as a,Mesh as i,Object3D as r,TextureLoader as n}from"three";import{GLTFLoader as o,MTLLoader as h,OBJLoader as c,DRACOLoader as l,LUTCubeLoader as d}from"three-stdlib";import{FBXLoader as u}from"three-stdlib";import{cloneMesh as m}from"../utils/mesh.js";import{pathJoin as p}from"../utils/files.js";import{Subject as f,firstValueFrom as g}from"rxjs";import{importCollisionShapes as w,isCollisionMesh as y}from"./collision/collision-shape-import.js";import*as x from"three";import{iterateMaterials as L}from"../utils/materials.js";import{BufferGeometryUtils as M,EXRLoader as b,KTX2Loader as A,TGALoader as C,UltraHDRLoader as R}from"three/examples/jsm/Addons.js";const S=new l;S.setDecoderConfig({type:"js"}),S.setDecoderPath("/assets/draco/");const v=["glb","gltf","fbx","obj"];export class AssetResourceLoader{onError(e){console.error(e)}constructor(){this.cache=new Map,this.textureCache=new Map,this.loadingManager=new a,this.glbLoader=new o(this.loadingManager).setDRACOLoader(S),this.fbxLoader=new u(this.loadingManager),this.objLoader=new c(this.loadingManager),this.textureLoader=new n(this.loadingManager),this.tgaLoader=new C(this.loadingManager),this.exrLoader=new b(this.loadingManager),this.cubeLoader=new d(this.loadingManager),this.hdrLoader=new R(this.loadingManager),this.ktx2Loader=new A(this.loadingManager),this._textureLoader=new x.ImageBitmapLoader(this.loadingManager),this.audioLoader=new e(this.loadingManager),this.initialisedKtx2=!1,this.makeReady=new f,this.ready=g(this.makeReady),this.asyncMeshResults=new Map,this.asyncAudioResults=new Map,this.collisionShapeCache=new Map,this.optimizedMeshes=new Set}initKtx2(e){this.initialisedKtx2=!0,this.ktx2Loader.setTranscoderPath("/assets/basis/"),this.ktx2Loader.detectSupport(e)}setDataDir(e){this.basePath=p(e,"asset-resources"),this.makeReady.next(!0)}getUri(e){const t=getElectronArg("windowId");return p(this.basePath,e)+(null!=t?`?windowId=${t}`:"")}async getTexture(e){if(null==e||null==e.fileKey)return null;if(await this.ready,!this.textureCache.has(e.id))try{await this._getTextureLoader(e.fileKey).loadAsync(this.getUri(e.fileKey)).then((t=>(t.texture3D?t=t.texture3D:(t.wrapS=D(e.texture?.wrapS),t.wrapT=D(e.texture?.wrapT),t.flipY=e.texture?.flipY??!0),this.textureCache.set(e.id,t),t)))}catch(t){return console.warn("Failed to load texture "+e.name,t),null}return this.textureCache.get(e.id)}_getTextureLoader(e){return e?.toLowerCase().endsWith(".tga")?this.tgaLoader:e?.toLowerCase().endsWith(".ktx2")?this.ktx2Loader:e?.toLowerCase().endsWith(".exr")?this.exrLoader:e?.toLowerCase().endsWith(".cube")?this.cubeLoader:this.textureLoader}clearCache(e){"mesh"===e.type&&Array.from(this.cache.keys()).forEach((t=>{t.startsWith(e.fileKey)&&this.cache.delete(t)}))}async getMesh(e,t){if(await this.ready,null==e)return console.error("No asset was provided"),{scene:new s,animations:[]};if(!v.includes(e.fileFormat?.toLowerCase()))return console.error("Unsupported mesh file format "+e.fileFormat,e),{scene:new s,animations:[]};const a=e.fileKey+(!0===t?.mergeGeomtries?"1":"0");if(!this.cache.has(a))try{this.asyncMeshResults.has(a)||this.asyncMeshResults.set(a,this.loadMesh(e).finally((()=>this.asyncMeshResults.delete(a)))),this.cache.set(a,await this.asyncMeshResults.get(a))}catch(e){return this.onError(e),{scene:new s,animations:[]}}const r=this.cache.get(a).scene,n=this.computeCollisionShapes(e,r);!0===t?.mergeGeomtries&&this.optimizeDrawGroups(r);const o=m(r),h=this.cache.get(a).animations;o.traverse((e=>{e instanceof i&&e.material instanceof Array&&(e.material=e.material.slice())}));const c=new AssetMeshInstance;c.add(o),c.collisionShapes=n,c.animations=h;const l=e.receiveShadow??!0,d=e.castShadow??!1;return o.traverse((e=>{e.castShadow=d,e.receiveShadow=l})),{scene:c,animations:h}}async getAudio(e){await this.ready;const t=e.fileKey;if(this.asyncAudioResults.has(t))return await this.asyncAudioResults.get(t);const s=this.audioLoader.loadAsync(this.getUri(e.fileKey)).finally((()=>{setTimeout((()=>{this.asyncAudioResults.delete(t)}),1e3)}));return this.asyncAudioResults.set(t,s),s}computeCollisionShapes(e,t){const s=e.id+e.mesh?.collisions?.shapeType;return this.collisionShapeCache.has(s)||this.collisionShapeCache.set(s,w(t,e)),this.collisionShapeCache.get(s)}async loadMesh(e){return await this.ready,await this.loadByAsset(e).then((e=>(e.scene.traverse((e=>{y(e)&&(e.visible=!1)})),e.scene=function(e,t){let s=!1;if(t.traverseVisible((e=>{W.test(e.name)&&(s=!0)})),!s)return t;const a=new x.LOD,i=[t];for(;i.length>0;){const e=i.shift(),t=e.name.match(W);if(null!=t){const s=parseInt(t[1]);0===s?a.addLevel(e,0):console.warn(`Skipping LOD level ${s} for now as LOD is not fully supported`)}else i.push(...e.children)}return a}(0,e.scene),e)))}optimizeDrawGroups(e){if(this.optimizedMeshes.has(e.uuid))return;this.optimizedMeshes.add(e.uuid);let s=!0,a=0,r=0;if(e.traverse((e=>{if(e instanceof i&&e.geometry instanceof t&&!y(e)){a++;const t=Object.keys(e.geometry.attributes).length;t!==r&&0!==r&&(s=!1),r=t}else(e instanceof x.SkinnedMesh||e instanceof x.Bone)&&(s=!1)})),a>1&&s){const s=[],a=[],r=[];e.updateWorldMatrix(!0,!0),e.traverse((e=>{e instanceof i&&e.geometry instanceof t&&!y(e)&&!Array.isArray(e.material)&&(e.updateWorldMatrix(!0,!0),s.push(e.geometry.clone().applyMatrix4(e.matrixWorld)),a.push(e.material),r.push(e))}));for(const e of r)e.removeFromParent();const n=M.mergeGeometries(s,!0),o=[];let h=0;e:for(const e of a){for(const t of o)if(t.m.id===e.id){t.indices.push(h),h++;continue e}o.push({m:e,indices:[h]}),h++}let c=0;for(const e of o){for(const t of e.indices)n.groups[t].materialIndex=c;c++}e.add(new i(n,o.map((e=>e.m))))}e.traverse((e=>{if(e instanceof i&&e.geometry instanceof t){const t=e.geometry;Array.isArray(e.material)&&t.groups.length>1&&t.groups.length>e.material.length&&M.mergeGroups(t)}}))}async loadByAsset(e){this.fbxLoader;const t=this.getUri(e.fileKey);switch(e.fileFormat){case"glb":case"gltf":return this.glbLoader.loadAsync(t).then((e=>({scene:e.scene,animations:e.animations})));case"fbx":return this.fbxLoader.loadAsync(t).then((e=>({scene:e,animations:e.animations})));case"obj":if(null!=e.materialLib){const t=new h;t.materialOptions={normalizeRGB:!1};const s=await t.loadAsync(this.getUri(e.materialLib));this.objLoader.setMaterials(s)}return this.objLoader.loadAsync(t).then((e=>(j(e),e))).then((e=>({scene:e,animations:e.animations})))}}}function j(e){if(e instanceof i)for(const t of L(e.material))t instanceof x.MeshPhongMaterial&&!t.color.isLinear&&(t.color.isLinear=!0);e.children?.forEach(j)}export class AssetMeshInstance extends r{}export function getElectronArg(e){const t=`--${e}=`,s=window.process?.argv.find((e=>e.startsWith(t)));return s?.substring(t.length)}function D(e){switch(e){case"clamp":return x.ClampToEdgeWrapping;case"repeat":return x.RepeatWrapping;case"mirror":return x.MirroredRepeatWrapping}return x.RepeatWrapping}new x.Matrix4;const W=/_LOD(\d+)$/;/*
1
+ import{AudioLoader as e,BufferGeometry as t,Group as s,LoadingManager as a,Mesh as i,Object3D as r,TextureLoader as n}from"three";import{GLTFLoader as o,MTLLoader as h,OBJLoader as l,DRACOLoader as c,LUTCubeLoader as d}from"three-stdlib";import{FBXLoader as u}from"three-stdlib";import{cloneMesh as m}from"../utils/mesh.js";import{pathJoin as p}from"../utils/files.js";import{Subject as f,firstValueFrom as g}from"rxjs";import{importCollisionShapes as w,isCollisionMesh as y}from"./collision/collision-shape-import.js";import*as x from"three";import{iterateMaterials as L}from"../utils/materials.js";import{BufferGeometryUtils as M,EXRLoader as b,KTX2Loader as A,TGALoader as R,UltraHDRLoader as C}from"three/examples/jsm/Addons.js";const v=new c;v.setDecoderConfig({type:"js"}),v.setDecoderPath("/assets/draco/");const S=["glb","gltf","fbx","obj"];export class AssetResourceLoader{onError(e){console.error(e)}constructor(){this.cache=new Map,this.textureCache=new Map,this.loadingManager=new a,this.glbLoader=new o(this.loadingManager).setDRACOLoader(v),this.fbxLoader=new u(this.loadingManager),this.objLoader=new l(this.loadingManager),this.textureLoader=new n(this.loadingManager),this.tgaLoader=new R(this.loadingManager),this.exrLoader=new b(this.loadingManager),this.cubeLoader=new d(this.loadingManager),this.hdrLoader=new C(this.loadingManager),this.ktx2Loader=new A(this.loadingManager),this._textureLoader=new x.ImageBitmapLoader(this.loadingManager),this.audioLoader=new e(this.loadingManager),this.initialisedKtx2=!1,this.makeReady=new f,this.ready=g(this.makeReady),this.asyncMeshResults=new Map,this.asyncAudioResults=new Map,this.collisionShapeCache=new Map,this.optimizedMeshes=new Set}initKtx2(e){this.initialisedKtx2=!0;null!=getElectronArg("windowId")||import.meta.url.includes(".vite")?this.ktx2Loader.setTranscoderPath("/assets/basis/"):this.ktx2Loader.setTranscoderPath(new URL("../assets/basis/",import.meta.url).href),this.ktx2Loader.detectSupport(e)}setDataDir(e){this.basePath=p(e,"asset-resources"),this.makeReady.next(!0)}getUri(e){const t=getElectronArg("windowId");return null!=t||import.meta.url.includes(".vite")?p(this.basePath,e)+(null!=t?`?windowId=${t}`:""):new URL(p("..",this.basePath,e),import.meta.url).href}async getTexture(e){if(null==e||null==e.fileKey)return null;if(await this.ready,!this.textureCache.has(e.id))try{await this._getTextureLoader(e.fileKey).loadAsync(this.getUri(e.fileKey)).then((t=>(t.texture3D?t=t.texture3D:(t.wrapS=k(e.texture?.wrapS),t.wrapT=k(e.texture?.wrapT),t.flipY=e.texture?.flipY??!0),this.textureCache.set(e.id,t),t)))}catch(t){return console.warn("Failed to load texture "+e.name,t),null}return this.textureCache.get(e.id)}_getTextureLoader(e){return e?.toLowerCase().endsWith(".tga")?this.tgaLoader:e?.toLowerCase().endsWith(".ktx2")?this.ktx2Loader:e?.toLowerCase().endsWith(".exr")?this.exrLoader:e?.toLowerCase().endsWith(".cube")?this.cubeLoader:this.textureLoader}clearCache(e){"mesh"===e.type&&Array.from(this.cache.keys()).forEach((t=>{t.startsWith(e.fileKey)&&this.cache.delete(t)}))}async getMesh(e,t){if(await this.ready,null==e)return console.error("No asset was provided"),{scene:new s,animations:[]};if(!S.includes(e.fileFormat?.toLowerCase()))return console.error("Unsupported mesh file format "+e.fileFormat,e),{scene:new s,animations:[]};const a=e.fileKey+(!0===t?.mergeGeomtries?"1":"0");if(!this.cache.has(a))try{this.asyncMeshResults.has(a)||this.asyncMeshResults.set(a,this.loadMesh(e).finally((()=>this.asyncMeshResults.delete(a)))),this.cache.set(a,await this.asyncMeshResults.get(a))}catch(e){return this.onError(e),{scene:new s,animations:[]}}const r=this.cache.get(a).scene,n=this.computeCollisionShapes(e,r);!0===t?.mergeGeomtries&&this.optimizeDrawGroups(r);const o=m(r),h=this.cache.get(a).animations;o.traverse((e=>{e instanceof i&&e.material instanceof Array&&(e.material=e.material.slice())}));const l=new AssetMeshInstance;l.add(o),l.collisionShapes=n,l.animations=h;const c=e.receiveShadow??!0,d=e.castShadow??!1;return o.traverse((e=>{e.castShadow=d,e.receiveShadow=c})),{scene:l,animations:h}}async getAudio(e){await this.ready;const t=e.fileKey;if(this.asyncAudioResults.has(t))return await this.asyncAudioResults.get(t);const s=this.audioLoader.loadAsync(this.getUri(e.fileKey)).finally((()=>{setTimeout((()=>{this.asyncAudioResults.delete(t)}),1e3)}));return this.asyncAudioResults.set(t,s),s}computeCollisionShapes(e,t){const s=e.id+e.mesh?.collisions?.shapeType;return this.collisionShapeCache.has(s)||this.collisionShapeCache.set(s,w(t,e)),this.collisionShapeCache.get(s)}async loadMesh(e){return await this.ready,await this.loadByAsset(e).then((e=>(e.scene.traverse((e=>{y(e)&&(e.visible=!1)})),e.scene=function(e,t){let s=!1;if(t.traverseVisible((e=>{D.test(e.name)&&(s=!0)})),!s)return t;const a=new x.LOD,i=[t];for(;i.length>0;){const e=i.shift(),t=e.name.match(D);if(null!=t){const s=parseInt(t[1]);0===s?a.addLevel(e,0):console.warn(`Skipping LOD level ${s} for now as LOD is not fully supported`)}else i.push(...e.children)}return a}(0,e.scene),e)))}optimizeDrawGroups(e){if(this.optimizedMeshes.has(e.uuid))return;this.optimizedMeshes.add(e.uuid);let s=!0,a=0,r=0;if(e.traverse((e=>{if(e instanceof i&&e.geometry instanceof t&&!y(e)){a++;const t=Object.keys(e.geometry.attributes).length;t!==r&&0!==r&&(s=!1),r=t}else(e instanceof x.SkinnedMesh||e instanceof x.Bone)&&(s=!1)})),a>1&&s){const s=[],a=[],r=[];e.updateWorldMatrix(!0,!0),e.traverse((e=>{e instanceof i&&e.geometry instanceof t&&!y(e)&&!Array.isArray(e.material)&&(e.updateWorldMatrix(!0,!0),s.push(e.geometry.clone().applyMatrix4(e.matrixWorld)),a.push(e.material),r.push(e))}));for(const e of r)e.removeFromParent();const n=M.mergeGeometries(s,!0),o=[];let h=0;e:for(const e of a){for(const t of o)if(t.m.id===e.id){t.indices.push(h),h++;continue e}o.push({m:e,indices:[h]}),h++}let l=0;for(const e of o){for(const t of e.indices)n.groups[t].materialIndex=l;l++}e.add(new i(n,o.map((e=>e.m))))}e.traverse((e=>{if(e instanceof i&&e.geometry instanceof t){const t=e.geometry;Array.isArray(e.material)&&t.groups.length>1&&t.groups.length>e.material.length&&M.mergeGroups(t)}}))}async loadByAsset(e){this.fbxLoader;const t=this.getUri(e.fileKey);switch(e.fileFormat){case"glb":case"gltf":return this.glbLoader.loadAsync(t).then((e=>({scene:e.scene,animations:e.animations})));case"fbx":return this.fbxLoader.loadAsync(t).then((e=>({scene:e,animations:e.animations})));case"obj":if(null!=e.materialLib){const t=new h;t.materialOptions={normalizeRGB:!1};const s=await t.loadAsync(this.getUri(e.materialLib));this.objLoader.setMaterials(s)}return this.objLoader.loadAsync(t).then((e=>(j(e),e))).then((e=>({scene:e,animations:e.animations})))}}}function j(e){if(e instanceof i)for(const t of L(e.material))t instanceof x.MeshPhongMaterial&&!t.color.isLinear&&(t.color.isLinear=!0);e.children?.forEach(j)}export class AssetMeshInstance extends r{}export function getElectronArg(e){const t=`--${e}=`,s=window.process?.argv.find((e=>e.startsWith(t)));return s?.substring(t.length)}function k(e){switch(e){case"clamp":return x.ClampToEdgeWrapping;case"repeat":return x.RepeatWrapping;case"mirror":return x.MirroredRepeatWrapping}return x.RepeatWrapping}new x.Matrix4;const D=/_LOD(\d+)$/;/*
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":"runtime-bundled-backend-service.d.ts","sourceRoot":"","sources":["../../src/scene/runtime-bundled-backend-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAa,SAAS,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,qBAAa,4BAA6B,YAAW,qBAAqB;IAExE,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,UAAU,CAA+B;IAE1C,SAAS,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAG7B,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAIpC,SAAS,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAGjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAIxC,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;WASpD,SAAS;IAIV,WAAW;CAezB"}
1
+ {"version":3,"file":"runtime-bundled-backend-service.d.ts","sourceRoot":"","sources":["../../src/scene/runtime-bundled-backend-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAa,SAAS,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAErE,qBAAa,4BAA6B,YAAW,qBAAqB;IAExE,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,UAAU,CAA+B;IAE1C,SAAS,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAG7B,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAIpC,SAAS,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAGjC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAIxC,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;WASpD,SAAS;IAIV,WAAW;CAmBzB"}
@@ -1,4 +1,4 @@
1
- export class RuntimeBundledBackendService{constructor(){this.assets=new Map,this.scenes=new Map,this.sceneBlobs=new Map}getAssets(){return Promise.resolve(Array.from(this.assets.values()))}getAsset(e){return Promise.resolve(this.assets.get(e))}getScenes(){return Promise.resolve(Array.from(this.scenes.values()))}getScene(e){return Promise.resolve(this.scenes.get(e))}async getSceneData(e){const s=this.sceneBlobs.get(e);return"string"==typeof s.data?JSON.parse(s.data):s.data}static tryCreate(){}async preloadData(){const e=await(await fetch("hology_data.json")).json()??{};for(const s of e.asset??[])this.assets.set(s.id,s);for(const s of e.scene??[])this.scenes.set(s.id,s),this.scenes.set(s.name,s);for(const s of e["scene-blob"]??[])this.sceneBlobs.set(s.id,s)}}/*
1
+ export class RuntimeBundledBackendService{constructor(){this.assets=new Map,this.scenes=new Map,this.sceneBlobs=new Map}getAssets(){return Promise.resolve(Array.from(this.assets.values()))}getAsset(e){return Promise.resolve(this.assets.get(e))}getScenes(){return Promise.resolve(Array.from(this.scenes.values()))}getScene(e){return Promise.resolve(this.scenes.get(e))}async getSceneData(e){const s=this.sceneBlobs.get(e);return"string"==typeof s.data?JSON.parse(s.data):s.data}static tryCreate(){}async preloadData(){const e=new URL("../hology_data.json",import.meta.url),s=await(await fetch(e)).json()??{};for(const e of s.asset??[])this.assets.set(e.id,e);for(const e of s.scene??[])this.scenes.set(e.id,e),this.scenes.set(e.name,e);for(const e of s["scene-blob"]??[])this.sceneBlobs.set(e.id,e)}}/*
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.128",
3
+ "version": "0.0.130",
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.128",
171
+ "@hology/nebula": "^0.0.130",
172
172
  "@plumier/reflect": "^1.1.0",
173
173
  "@recast-navigation/three": "0.39.0",
174
174
  "recast-navigation": "0.39.0",