gdcore-tools 2.0.0-gd-v5.5.223-autobuild → 2.0.0-gd-v5.5.224-autobuild

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,2 +1,2 @@
1
- var gdjs;(function(n){const p=async()=>{try{const t=(await import("./jolt-physics.wasm.js")).default;if(!t)throw new Error("No default export found in Jolt.");const e=await t();window.Jolt=e}catch(u){throw console.error("Unable to load Jolt physics library.",u),u}};n.registerAsynchronouslyLoadingLibraryPromise(p());class b{constructor(t,e){this._tempVec3=new Jolt.Vec3;this._tempRVec3=new Jolt.RVec3;this._tempQuat=new Jolt.Quat;this.stepped=!1;this._physics3DHooks=[];this._registeredBehaviors=new Set,this.gravityX=e.gravityX,this.gravityY=e.gravityY,this.gravityZ=e.gravityZ,this.worldScale=e.worldScale,this.worldInvScale=1/this.worldScale;const o=new Jolt.JoltSettings;n.Physics3DSharedData.setupCollisionFiltering(o),this.jolt=new Jolt.JoltInterface(o),Jolt.destroy(o),this.physicsSystem=this.jolt.GetPhysicsSystem(),this.physicsSystem.SetGravity(this.getVec3(this.gravityX,this.gravityY,this.gravityZ)),this.bodyInterface=this.physicsSystem.GetBodyInterface(),this.contactListener=new Jolt.ContactListenerJS,this.physicsSystem.SetContactListener(this.contactListener),this.contactListener.OnContactAdded=(i,s,a,r)=>{const d=Jolt.wrapPointer(i,Jolt.Body),l=Jolt.wrapPointer(s,Jolt.Body),h=d.gdjsAssociatedBehavior,f=l.gdjsAssociatedBehavior;!h||!f||(h.onContactBegin(f),f.onContactBegin(h))},this.contactListener.OnContactRemoved=i=>{const s=Jolt.wrapPointer(i,Jolt.SubShapeIDPair),a=this.physicsSystem.GetBodyLockInterface(),r=a.TryGetBody(s.GetBody1ID()),d=a.TryGetBody(s.GetBody2ID()),l=r.gdjsAssociatedBehavior,h=d.gdjsAssociatedBehavior;!l||!h||(l.onContactEnd(h),h.onContactEnd(l))},this.contactListener.OnContactPersisted=(i,s,a,r)=>{},this.contactListener.OnContactValidate=(i,s,a,r)=>Jolt.ValidateResult_AcceptAllContactsForThisBodyPair}getVec3(t,e,o){const i=this._tempVec3;return i.Set(t,e,o),i}getRVec3(t,e,o){const i=this._tempRVec3;return i.Set(t,e,o),i}getQuat(t,e,o,i){const s=this._tempQuat;return s.Set(t,e,o,i),s}static getSharedData(t,e){if(!t.physics3DSharedData){const o=t.getInitialSharedDataForBehavior(e);t.physics3DSharedData=new n.Physics3DSharedData(t,o)}return t.physics3DSharedData}static setupCollisionFiltering(t){const e=new Jolt.ObjectLayerPairFilterMask,o=new Jolt.BroadPhaseLayer(n.Physics3DSharedData.staticBroadPhaseLayerIndex),i=new Jolt.BroadPhaseLayer(n.Physics3DSharedData.dynamicBroadPhaseLayerIndex),s=new Jolt.BroadPhaseLayerInterfaceMask(2);s.ConfigureLayer(o,n.Physics3DSharedData.staticLayersMask,0),s.ConfigureLayer(i,n.Physics3DSharedData.dynamicLayersMask,0),Jolt.destroy(o),Jolt.destroy(i),t.mObjectLayerPairFilter=e,t.mBroadPhaseLayerInterface=s,t.mObjectVsBroadPhaseLayerFilter=new Jolt.ObjectVsBroadPhaseLayerFilterMask(s)}addToBehaviorsList(t){this._registeredBehaviors.add(t)}removeFromBehaviorsList(t){this._registeredBehaviors.delete(t)}step(t){for(const o of this._registeredBehaviors)o._contactsStartedThisFrame.length=0,o._contactsEndedThisFrame.length=0;for(const o of this._registeredBehaviors)o.updateBodyFromObject();for(const o of this._physics3DHooks)o.doBeforePhysicsStep(t);const e=t>1/55?2:1;this.jolt.Step(t,e),this.stepped=!0;for(const o of this._registeredBehaviors)o.updateObjectFromBody()}registerHook(t){this._physics3DHooks.push(t)}}b.staticLayersMask=15,b.dynamicLayersMask=240,b.allLayersMask=255,b.staticBroadPhaseLayerIndex=1,b.dynamicBroadPhaseLayerIndex=1,n.Physics3DSharedData=b,n.registerRuntimeSceneUnloadedCallback(function(u){const t=u.physics3DSharedData;t&&(Jolt.destroy(t.jolt),Jolt.destroy(t.contactListener),Jolt.destroy(t._tempVec3),Jolt.destroy(t._tempRVec3),Jolt.destroy(t._tempQuat),u.physics3DSharedData=null)});class _ extends n.RuntimeBehavior{constructor(t,e,o){super(t,e,o);this.shapeScale=1;this._contactsStartedThisFrame=[];this._contactsEndedThisFrame=[];this._currentContacts=[];this._body=null;this._needToRecreateBody=!1;this._needToRecreateShape=!1;this._shapeHalfDepth=0;this._objectOldX=0;this._objectOldY=0;this._objectOldZ=0;this._objectOldRotationX=0;this._objectOldRotationY=0;this._objectOldRotationZ=0;this._objectOldWidth=0;this._objectOldHeight=0;this._objectOldDepth=0;this.bodyUpdater=new n.Physics3DRuntimeBehavior.DefaultBodyUpdater(this),this.collisionChecker=new n.Physics3DRuntimeBehavior.DefaultCollisionChecker(this),this.owner3D=o,this.bodyType=e.bodyType,this.bullet=e.bullet,this.fixedRotation=e.fixedRotation,this.shape=e.shape,this.shapeOrientation=e.shapeOrientation,this.shapeDimensionA=e.shapeDimensionA,this.shapeDimensionB=e.shapeDimensionB,this.shapeDimensionC=e.shapeDimensionC,this.density=e.density,this.friction=e.friction,this.restitution=e.restitution,this.linearDamping=Math.max(0,e.linearDamping),this.angularDamping=Math.max(0,e.angularDamping),this.gravityScale=e.gravityScale,this.layers=e.layers,this.masks=e.masks,this._destroyedDuringFrameLogic=!1,this._sharedData=b.getSharedData(t.getScene(),e.name),this._sharedData.addToBehaviorsList(this)}getVec3(t,e,o){const i=this._sharedData._tempVec3;return i.Set(t,e,o),i}getRVec3(t,e,o){const i=this._sharedData._tempRVec3;return i.Set(t,e,o),i}getQuat(t,e,o,i){const s=this._sharedData._tempQuat;return s.Set(t,e,o,i),s}updateFromBehaviorData(t,e){return t.bullet!==e.bullet&&this.setBullet(e.bullet),t.fixedRotation!==e.fixedRotation&&this.setFixedRotation(e.fixedRotation),t.shapeDimensionA!==e.shapeDimensionA&&(this.shapeDimensionA=e.shapeDimensionA,this._needToRecreateShape=!0),t.shapeDimensionB!==e.shapeDimensionB&&(this.shapeDimensionB=e.shapeDimensionB,this._needToRecreateShape=!0),t.density!==e.density&&this.setDensity(e.density),t.friction!==e.friction&&this.setFriction(e.friction),t.restitution!==e.restitution&&this.setRestitution(e.restitution),t.linearDamping!==e.linearDamping&&this.setLinearDamping(e.linearDamping),t.angularDamping!==e.angularDamping&&this.setAngularDamping(e.angularDamping),t.gravityScale!==e.gravityScale&&this.setGravityScale(e.gravityScale),!(t.layers!==e.layers||t.masks!==e.masks||t.vertices!==e.vertices||t.bodyType!==e.bodyType||t.shape!==e.shape)}getNetworkSyncData(){let t;if(this._body){const e=this._body.GetPosition(),o=this._body.GetRotation(),i=this._body.GetLinearVelocity(),s=this._body.GetAngularVelocity();t={px:e.GetX(),py:e.GetY(),pz:e.GetZ(),rx:o.GetX(),ry:o.GetY(),rz:o.GetZ(),rw:o.GetW(),lvx:i.GetX(),lvy:i.GetY(),lvz:i.GetZ(),avx:s.GetX(),avy:s.GetY(),avz:s.GetZ(),aw:this._body.IsActive()}}else t={px:void 0,py:void 0,pz:void 0,rx:void 0,ry:void 0,rz:void 0,rw:void 0,lvx:void 0,lvy:void 0,lvz:void 0,avx:void 0,avy:void 0,avz:void 0,aw:void 0};return{...super.getNetworkSyncData(),props:{...t,layers:this.layers,masks:this.masks}}}updateFromNetworkSyncData(t){super.updateFromNetworkSyncData(t);const e=t.props;e.px!==void 0&&e.py!==void 0&&e.pz!==void 0&&this._body&&this._sharedData.bodyInterface.SetPosition(this._body.GetID(),this.getRVec3(e.px,e.py,e.pz),Jolt.EActivation_DontActivate),e.rx!==void 0&&e.ry!==void 0&&e.rz!==void 0&&e.rw!==void 0&&this._body&&this._sharedData.bodyInterface.SetRotation(this._body.GetID(),this.getQuat(e.rx,e.ry,e.rz,e.rw),Jolt.EActivation_DontActivate),e.lvx!==void 0&&e.lvy!==void 0&&e.lvz!==void 0&&this._body&&this._sharedData.bodyInterface.SetLinearVelocity(this._body.GetID(),this.getVec3(e.lvx,e.lvy,e.lvz)),e.avx!==void 0&&e.avy!==void 0&&e.avz!==void 0&&this._body&&this._sharedData.bodyInterface.SetAngularVelocity(this._body.GetID(),this.getVec3(e.avx,e.avy,e.avz)),e.layers!==void 0&&(this.layers=e.layers),e.masks!==void 0&&(this.masks=e.masks)}onDeActivate(){this._sharedData.removeFromBehaviorsList(this),this._body!==null&&(this._sharedData.bodyInterface.RemoveBody(this._body.GetID()),this._sharedData.bodyInterface.DestroyBody(this._body.GetID()),this._body=null),this._contactsEndedThisFrame.length=0,this._contactsStartedThisFrame.length=0,this._currentContacts.length=0}onActivate(){this._sharedData.addToBehaviorsList(this),this._contactsEndedThisFrame.length=0,this._contactsStartedThisFrame.length=0,this._currentContacts.length=0,this.updateBodyFromObject()}onDestroy(){this._destroyedDuringFrameLogic=!0,this.onDeActivate()}createShape(){let t=this.owner3D.getWidth()*this._sharedData.worldInvScale,e=this.owner3D.getHeight()*this._sharedData.worldInvScale,o=this.owner3D.getDepth()*this._sharedData.worldInvScale;if(this.shapeOrientation==="X"){const c=o;o=t,t=c}else if(this.shapeOrientation==="Y"){const c=o;o=e,e=c}const i=this.shapeScale*this._sharedData.worldInvScale,s=this.shapeDimensionA*i,a=this.shapeDimensionB*i,r=this.shapeDimensionC*i,d=this._sharedData.worldInvScale;let l,h;if(this.shape==="Box"){const c=s>0?s:t>0?t:d,y=a>0?a:e>0?e:d,g=r>0?r:o>0?o:d,D=Math.min(d,Math.min(c,y,g)/4);l=new Jolt.BoxShapeSettings(this.getVec3(c/2,y/2,g/2),D),h=this.getQuat(0,0,0,1),this._shapeHalfDepth=g/2}else if(this.shape==="Capsule"){const c=s>0?s:t>0?Math.sqrt(t*e)/2:d,y=a>0?a:o>0?o:d;l=new Jolt.CapsuleShapeSettings(Math.max(0,y/2-c),c),h=this._getShapeOrientationQuat(),this._shapeHalfDepth=this.shapeOrientation!=="Z"?c:y/2}else if(this.shape==="Cylinder"){const c=s>0?s:t>0?Math.sqrt(t*e)/2:d,y=a>0?a:o>0?o:d,g=Math.min(d,Math.min(y,c)/4);l=new Jolt.CylinderShapeSettings(y/2,c,g),h=this._getShapeOrientationQuat(),this._shapeHalfDepth=this.shapeOrientation!=="Z"?c:y/2}else{const c=s>0?s:t>0?Math.pow(t*e*o,1/3)/2:d;l=new Jolt.SphereShapeSettings(c),h=this.getQuat(0,0,0,1),this._shapeHalfDepth=c}l.mDensity=this.density;const f=new Jolt.RotatedTranslatedShapeSettings(this.getVec3(0,0,0),h,l).Create().Get();return Jolt.destroy(l),f}_getShapeOrientationQuat(){return this.shapeOrientation==="X"?this.getQuat(0,0,Math.sqrt(2)/2,-Math.sqrt(2)/2):this.shapeOrientation==="Y"?this.getQuat(0,0,0,1):this.getQuat(Math.sqrt(2)/2,0,0,Math.sqrt(2)/2)}_recreateShape(){this.bodyUpdater.recreateShape(),this._objectOldWidth=this.owner3D.getWidth(),this._objectOldHeight=this.owner3D.getHeight(),this._objectOldDepth=this.owner3D.getDepth()}getShapeScale(){return this.shapeScale}setShapeScale(t){t!==this.shapeScale&&t>0&&(this.shapeScale=t,this._needToRecreateShape=!0)}getBody(){return this._body===null&&this._createBody(),this._body}_createBody(){return this._needToRecreateBody=!1,this._needToRecreateShape=!1,!this.activated()||this._destroyedDuringFrameLogic?!1:(this._body=this.bodyUpdater.createAndAddBody(),this._body.gdjsAssociatedBehavior=this,this._objectOldWidth=this.owner3D.getWidth(),this._objectOldHeight=this.owner3D.getHeight(),this._objectOldDepth=this.owner3D.getDepth(),!0)}getBodyLayer(){return Jolt.ObjectLayerPairFilterMask.prototype.sGetObjectLayer(this.getLayersAccordingToBodyType(),this.getMasksAccordingToBodyType())}getLayersAccordingToBodyType(){return this.isStatic()?this.layers&n.Physics3DSharedData.staticLayersMask:this.layers&n.Physics3DSharedData.dynamicLayersMask}getMasksAccordingToBodyType(){return this.isStatic()?n.Physics3DSharedData.allLayersMask:this.masks}doStepPreEvents(t){!this._sharedData.stepped&&!t.getScene().getTimeManager().isFirstFrame()&&this._sharedData.step(t.getScene().getTimeManager().getElapsedTime()/1e3)}doStepPostEvents(t){this._sharedData.stepped=!1}onObjectHotReloaded(){this.updateBodyFromObject()}recreateBody(){if(!this._body){this._createBody();return}const t=this._sharedData.bodyInterface,e=this._body.GetLinearVelocity(),o=e.GetX(),i=e.GetY(),s=e.GetZ(),a=this._body.GetAngularVelocity(),r=a.GetX(),d=a.GetY(),l=a.GetZ();let h=this._body.GetID();t.RemoveBody(h),t.DestroyBody(h),this._contactsEndedThisFrame.length=0,this._contactsStartedThisFrame.length=0,this._currentContacts.length=0,this._createBody(),!!this._body&&(h=this._body.GetID(),t.SetLinearVelocity(h,this.getVec3(o,i,s)),t.SetAngularVelocity(h,this.getVec3(r,d,l)))}updateObjectFromBody(){this.bodyUpdater.updateObjectFromBody(),this._objectOldX=this.owner3D.getX(),this._objectOldY=this.owner3D.getY(),this._objectOldZ=this.owner3D.getZ(),this._objectOldRotationX=this.owner3D.getRotationX(),this._objectOldRotationY=this.owner3D.getRotationY(),this._objectOldRotationZ=this.owner3D.getAngle()}updateBodyFromObject(){this._body===null&&!this._createBody()||(this._needToRecreateBody&&this.recreateBody(),(this._needToRecreateShape||!this.hasCustomShapeDimension()&&(this._objectOldWidth!==this.owner3D.getWidth()||this._objectOldHeight!==this.owner3D.getHeight()||this._objectOldDepth!==this.owner3D.getDepth()))&&(this._needToRecreateShape=!1,this._recreateShape()),this.bodyUpdater.updateBodyFromObject())}hasCustomShapeDimension(){return this.shapeDimensionA>0||this.shapeDimensionB>0||this.shapeDimensionC>0}getPhysicsPosition(t){return t.Set(this.owner3D.getCenterXInScene()*this._sharedData.worldInvScale,this.owner3D.getCenterYInScene()*this._sharedData.worldInvScale,this.owner3D.getCenterZInScene()*this._sharedData.worldInvScale),t}getPhysicsRotation(t){const e=this.owner3D.get3DRendererObject();return t.Set(e.quaternion.x,e.quaternion.y,e.quaternion.z,e.quaternion.w),t}moveObjectToPhysicsPosition(t){this.owner3D.setCenterXInScene(t.GetX()*this._sharedData.worldScale),this.owner3D.setCenterYInScene(t.GetY()*this._sharedData.worldScale),this.owner3D.setCenterZInScene(t.GetZ()*this._sharedData.worldScale)}moveObjectToPhysicsRotation(t){const e=this.owner3D.get3DRendererObject();e.quaternion.x=t.GetX(),e.quaternion.y=t.GetY(),e.quaternion.z=t.GetZ(),e.quaternion.w=t.GetW();const o=new THREE.Euler(0,0,0,"ZYX");o.setFromQuaternion(e.quaternion),this.owner3D.setRotationX(n.toDegrees(o.x)),this.owner3D.setRotationY(n.toDegrees(o.y)),this.owner3D.setAngle(n.toDegrees(o.z))}getWorldScale(){return this._sharedData.worldScale}getGravityX(){return this._sharedData.gravityX}getGravityY(){return this._sharedData.gravityY}getGravityZ(){return this._sharedData.gravityZ}setGravityX(t){this._sharedData.gravityX!==t&&(this._sharedData.gravityX=t,this._sharedData.physicsSystem.SetGravity(this.getVec3(this._sharedData.gravityX,this._sharedData.gravityY,this._sharedData.gravityZ)))}setGravityY(t){this._sharedData.gravityX!==t&&(this._sharedData.gravityX=t,this._sharedData.physicsSystem.SetGravity(this.getVec3(this._sharedData.gravityX,this._sharedData.gravityY,this._sharedData.gravityZ)))}setGravityZ(t){this._sharedData.gravityX!==t&&(this._sharedData.gravityZ=t,this._sharedData.physicsSystem.SetGravity(this.getVec3(this._sharedData.gravityX,this._sharedData.gravityY,this._sharedData.gravityZ)))}isDynamic(){return this.bodyType==="Dynamic"}isStatic(){return this.bodyType==="Static"}isKinematic(){return this.bodyType==="Kinematic"}isBullet(){return this.bullet}setBullet(t){if(this.bullet===t||(this.bullet=t,this._body===null&&!this._createBody()))return;const e=this._body;this._sharedData.bodyInterface.SetMotionQuality(e.GetID(),this.bullet?Jolt.EMotionQuality_LinearCast:Jolt.EMotionQuality_Discrete)}hasFixedRotation(){return this.fixedRotation}setFixedRotation(t){this.fixedRotation!==t&&(this.fixedRotation=t,this._needToRecreateBody=!0)}getDensity(){return this.density}setDensity(t){t<0&&(t=0),this.density!==t&&(this.density=t,this._needToRecreateShape=!0)}getFriction(){return this.friction}setFriction(t){if(t<0&&(t=0),this.friction===t||(this.friction=t,this._body===null&&!this._createBody()))return;const e=this._body;this._sharedData.bodyInterface.SetFriction(e.GetID(),t)}getRestitution(){return this.restitution}setRestitution(t){if(t<0&&(t=0),this.restitution===t||(this.restitution=t,this._body===null&&!this._createBody()))return;const e=this._body;this._sharedData.bodyInterface.SetRestitution(e.GetID(),t)}getLinearDamping(){return this.linearDamping}setLinearDamping(t){if(t<0&&(t=0),this.linearDamping===t||(this.linearDamping=t,this._body===null&&!this._createBody()))return;this._body.GetMotionProperties().SetLinearDamping(t)}getAngularDamping(){return this.angularDamping}setAngularDamping(t){if(t<0&&(t=0),this.angularDamping===t||(this.angularDamping=t,this._body===null&&!this._createBody()))return;this._body.GetMotionProperties().SetAngularDamping(t)}getGravityScale(){return this.gravityScale}setGravityScale(t){if(this.gravityScale===t||(this.gravityScale=t,this._body===null&&!this._createBody()))return;this._body.GetMotionProperties().SetGravityFactor(t)}layerEnabled(t){return t=Math.floor(t),t<1||t>8?!1:!!(this.layers&1<<t-1)}enableLayer(t,e){t=Math.floor(t),!(t<1||t>8)&&(e?this.layers|=1<<t-1:this.layers&=~(1<<t-1),this._needToRecreateBody=!0)}maskEnabled(t){return t=Math.floor(t),t<1||t>16?!1:!!(this.masks&1<<t-1)}enableMask(t,e){t=Math.floor(t),!(t<1||t>16)&&(e?this.masks|=1<<t-1:this.masks&=~(1<<t-1),this._needToRecreateBody=!0)}getLinearVelocityX(){return this._body===null&&!this._createBody()?0:this._body.GetLinearVelocity().GetX()*this._sharedData.worldScale}setLinearVelocityX(t){if(this._body===null&&!this._createBody())return;const e=this._body;this._sharedData.bodyInterface.SetLinearVelocity(e.GetID(),this.getVec3(t*this._sharedData.worldInvScale,e.GetLinearVelocity().GetY(),e.GetLinearVelocity().GetZ()))}getLinearVelocityY(){return this._body===null&&!this._createBody()?0:this._body.GetLinearVelocity().GetY()*this._sharedData.worldScale}setLinearVelocityY(t){if(this._body===null&&!this._createBody())return;const e=this._body;this._sharedData.bodyInterface.SetLinearVelocity(e.GetID(),this.getVec3(e.GetLinearVelocity().GetX(),t*this._sharedData.worldInvScale,e.GetLinearVelocity().GetZ()))}getLinearVelocityZ(){return this._body===null&&!this._createBody()?0:this._body.GetLinearVelocity().GetZ()*this._sharedData.worldScale}setLinearVelocityZ(t){if(this._body===null&&!this._createBody())return;const e=this._body;this._sharedData.bodyInterface.SetLinearVelocity(e.GetID(),this.getVec3(e.GetLinearVelocity().GetX(),e.GetLinearVelocity().GetY(),t*this._sharedData.worldInvScale))}getLinearVelocityLength(){return this._body===null&&!this._createBody()?0:this._body.GetLinearVelocity().Length()*this._sharedData.worldScale}getAngularVelocityX(){if(this._body===null&&!this._createBody())return 0;const t=this._body;return n.toDegrees(t.GetAngularVelocity().GetX())}setAngularVelocityX(t){if(this._body===null&&!this._createBody())return;const e=this._body;this._sharedData.bodyInterface.SetAngularVelocity(e.GetID(),this.getVec3(n.toRad(t),e.GetAngularVelocity().GetY(),e.GetAngularVelocity().GetZ()))}getAngularVelocityY(){if(this._body===null&&!this._createBody())return 0;const t=this._body;return n.toDegrees(t.GetAngularVelocity().GetY())}setAngularVelocityY(t){if(this._body===null&&!this._createBody())return;const e=this._body;this._sharedData.bodyInterface.SetAngularVelocity(e.GetID(),this.getVec3(e.GetAngularVelocity().GetX(),n.toRad(t),e.GetAngularVelocity().GetZ()))}getAngularVelocityZ(){if(this._body===null&&!this._createBody())return 0;const t=this._body;return n.toDegrees(t.GetAngularVelocity().GetZ())}setAngularVelocityZ(t){if(this._body===null&&!this._createBody())return;const e=this._body;this._sharedData.bodyInterface.SetAngularVelocity(e.GetID(),this.getVec3(e.GetAngularVelocity().GetX(),e.GetAngularVelocity().GetY(),n.toRad(t)))}applyForce(t,e,o,i,s,a){if(this._body===null&&!this._createBody())return;const r=this._body;this._sharedData.bodyInterface.AddForce(r.GetID(),this.getVec3(t,e,o),this.getRVec3(i*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale,a*this._sharedData.worldInvScale),Jolt.EActivation_Activate)}applyForceAtCenter(t,e,o){if(this._body===null&&!this._createBody())return;const i=this._body;this._sharedData.bodyInterface.AddForce(i.GetID(),this.getVec3(t,e,o),Jolt.EActivation_Activate)}applyForceTowardPosition(t,e,o,i){if(this._body===null&&!this._createBody())return;const s=this._body,a=e-s.GetPosition().GetX(),r=o-s.GetPosition().GetY(),d=i-s.GetPosition().GetZ(),l=a*a+r*r+d*d;if(l===0)return;const h=t/l;this._sharedData.bodyInterface.AddForce(s.GetID(),this.getVec3(a*h,r*h,d*h),Jolt.EActivation_Activate)}applyImpulse(t,e,o,i,s,a){if(this._body===null&&!this._createBody())return;const r=this._body;this._sharedData.bodyInterface.AddImpulse(r.GetID(),this.getVec3(t,e,o),this.getRVec3(i*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale,a*this._sharedData.worldInvScale))}applyImpulseAtCenter(t,e,o){if(this._body===null&&!this._createBody())return;const i=this._body;this._sharedData.bodyInterface.AddImpulse(i.GetID(),this.getVec3(t,e,o))}applyImpulseTowardPosition(t,e,o,i,s,a,r){if(this._body===null&&!this._createBody())return;const d=this._body,l=e-s,h=o-a,f=i-r,c=l*l+h*h+f*f;if(c===0)return;const y=t/c;this._sharedData.bodyInterface.AddImpulse(d.GetID(),this.getVec3(l*y,h*y,f*y),this.getRVec3(s*this._sharedData.worldInvScale,a*this._sharedData.worldInvScale,r*this._sharedData.worldInvScale))}applyTorque(t,e,o){if(this._body===null&&!this._createBody())return;const i=this._body;this._sharedData.bodyInterface.AddTorque(i.GetID(),this.getVec3(n.toRad(t),n.toRad(e),n.toRad(o)),Jolt.EActivation_Activate)}applyAngularImpulse(t,e,o){if(this._body===null&&!this._createBody())return;const i=this._body;this._sharedData.bodyInterface.AddAngularImpulse(i.GetID(),this.getVec3(n.toRad(t),n.toRad(e),n.toRad(o)))}getMass(){if(this._body===null&&!this._createBody())return 0;const t=this._body;return 1/t.GetMotionProperties().GetInverseMass()}getInertiaAroundX(){if(this._body===null&&!this._createBody())return 0;const t=this._body;return 1/t.GetMotionProperties().GetInverseInertiaDiagonal().GetX()}getInertiaAroundY(){if(this._body===null&&!this._createBody())return 0;const t=this._body;return 1/t.GetMotionProperties().GetInverseInertiaDiagonal().GetY()}getInertiaAroundZ(){if(this._body===null&&!this._createBody())return 0;const t=this._body;return 1/t.GetMotionProperties().GetInverseInertiaDiagonal().GetZ()}getMassCenterX(){return this._body===null&&!this._createBody()?0:this._body.GetCenterOfMassPosition().GetX()*this._sharedData.worldScale}getMassCenterY(){return this._body===null&&!this._createBody()?0:this._body.GetCenterOfMassPosition().GetY()*this._sharedData.worldScale}getMassCenterZ(){return this._body===null&&!this._createBody()?0:this._body.GetCenterOfMassPosition().GetZ()*this._sharedData.worldScale}onContactBegin(t){this._currentContacts.push(t);let e=this._contactsEndedThisFrame.indexOf(t);e!==-1?this._contactsEndedThisFrame.splice(e,1):this._contactsStartedThisFrame.push(t)}onContactEnd(t){this._contactsEndedThisFrame.push(t);const e=this._currentContacts.indexOf(t);e!==-1&&this._currentContacts.splice(e,1)}canCollideAgainst(t){return(this.getMasksAccordingToBodyType()&t.getLayersAccordingToBodyType())!=0}static areObjectsColliding(t,e,o){const i=t.getBehavior(o);return i?i.collisionChecker.isColliding(e):!1}static hasCollisionStartedBetween(t,e,o){const i=t.getBehavior(o);return i?i.collisionChecker.hasCollisionStartedWith(e):!1}static hasCollisionStoppedBetween(t,e,o){const i=t.getBehavior(o);return i?i.collisionChecker.hasCollisionStoppedWith(e):!1}}n.Physics3DRuntimeBehavior=_,n.registerBehavior("Physics3D::Physics3DBehavior",n.Physics3DRuntimeBehavior),function(e){class u{constructor(i){this.behavior=i}createAndAddBody(){const{behavior:i}=this,{_sharedData:s}=i,a=i.createShape(),r=new Jolt.BodyCreationSettings(a,i.getPhysicsPosition(s.getRVec3(0,0,0)),i.getPhysicsRotation(s.getQuat(0,0,0,1)),i.bodyType==="Static"?Jolt.EMotionType_Static:i.bodyType==="Kinematic"?Jolt.EMotionType_Kinematic:Jolt.EMotionType_Dynamic,i.getBodyLayer());r.mMotionQuality=i.bullet?Jolt.EMotionQuality_LinearCast:Jolt.EMotionQuality_Discrete,r.mAllowedDOFs=i.fixedRotation?Jolt.EAllowedDOFs_TranslationX|Jolt.EAllowedDOFs_TranslationY|Jolt.EAllowedDOFs_TranslationZ:Jolt.EAllowedDOFs_All,r.mFriction=i.friction,r.mRestitution=i.restitution,r.mLinearDamping=i.linearDamping,r.mAngularDamping=i.angularDamping,r.mGravityFactor=i.gravityScale;const d=s.bodyInterface,l=d.CreateBody(r);return Jolt.destroy(r),d.AddBody(l.GetID(),Jolt.EActivation_Activate),l}updateObjectFromBody(){const{behavior:i}=this,{_body:s}=i;s!==null&&s.IsActive()&&(i.moveObjectToPhysicsPosition(s.GetPosition()),i.moveObjectToPhysicsRotation(s.GetRotation()))}updateBodyFromObject(){const{behavior:i}=this,{owner3D:s,_sharedData:a}=i;if(i._body===null&&!i._createBody())return;const r=i._body;(this.behavior._objectOldX!==s.getX()||this.behavior._objectOldY!==s.getY()||this.behavior._objectOldZ!==s.getZ()||this.behavior._objectOldRotationX!==s.getRotationX()||this.behavior._objectOldRotationY!==s.getRotationY()||this.behavior._objectOldRotationZ!==s.getAngle())&&a.bodyInterface.SetPositionAndRotationWhenChanged(r.GetID(),this.behavior.getPhysicsPosition(a.getRVec3(0,0,0)),this.behavior.getPhysicsRotation(a.getQuat(0,0,0,1)),Jolt.EActivation_Activate)}recreateShape(){const{behavior:i}=this,{_sharedData:s}=i;if(i._body===null&&!i._createBody())return;const a=i._body;s.bodyInterface.SetShape(a.GetID(),i.createShape(),!0,Jolt.EActivation_Activate)}}e.DefaultBodyUpdater=u;class t{constructor(i){this.behavior=i}isColliding(i){return this.behavior._currentContacts.some(s=>s.owner===i)?!0:this.behavior._contactsStartedThisFrame.some(s=>s.owner===i)}hasCollisionStartedWith(i){return this.behavior._contactsStartedThisFrame.some(s=>s.owner===i)}hasCollisionStoppedWith(i){return this.behavior._contactsEndedThisFrame.some(s=>s.owner===i)}}e.DefaultCollisionChecker=t}(_=n.Physics3DRuntimeBehavior||(n.Physics3DRuntimeBehavior={}))})(gdjs||(gdjs={}));
1
+ var gdjs;(function(n){const p=async()=>{try{const t=(await import("./jolt-physics.wasm.js")).default;if(!t)throw new Error("No default export found in Jolt.");const e=await t();window.Jolt=e}catch(u){throw console.error("Unable to load Jolt physics library.",u),u}};n.registerAsynchronouslyLoadingLibraryPromise(p());class b{constructor(t,e){this._tempVec3=new Jolt.Vec3;this._tempRVec3=new Jolt.RVec3;this._tempQuat=new Jolt.Quat;this.stepped=!1;this._physics3DHooks=[];this._registeredBehaviors=new Set,this.gravityX=e.gravityX,this.gravityY=e.gravityY,this.gravityZ=e.gravityZ,this.worldScale=e.worldScale,this.worldInvScale=1/this.worldScale;const o=new Jolt.JoltSettings;n.Physics3DSharedData.setupCollisionFiltering(o),this.jolt=new Jolt.JoltInterface(o),Jolt.destroy(o),this.physicsSystem=this.jolt.GetPhysicsSystem(),this.physicsSystem.SetGravity(this.getVec3(this.gravityX,this.gravityY,this.gravityZ)),this.bodyInterface=this.physicsSystem.GetBodyInterface(),this.contactListener=new Jolt.ContactListenerJS,this.physicsSystem.SetContactListener(this.contactListener),this.contactListener.OnContactAdded=(i,s,a,r)=>{const h=Jolt.wrapPointer(i,Jolt.Body),l=Jolt.wrapPointer(s,Jolt.Body),d=h.gdjsAssociatedBehavior,f=l.gdjsAssociatedBehavior;!d||!f||(d.onContactBegin(f),f.onContactBegin(d))},this.contactListener.OnContactRemoved=i=>{const s=Jolt.wrapPointer(i,Jolt.SubShapeIDPair),a=this.physicsSystem.GetBodyLockInterface(),r=a.TryGetBody(s.GetBody1ID()),h=a.TryGetBody(s.GetBody2ID()),l=r.gdjsAssociatedBehavior,d=h.gdjsAssociatedBehavior;!l||!d||(l.onContactEnd(d),d.onContactEnd(l))},this.contactListener.OnContactPersisted=(i,s,a,r)=>{},this.contactListener.OnContactValidate=(i,s,a,r)=>Jolt.ValidateResult_AcceptAllContactsForThisBodyPair}getVec3(t,e,o){const i=this._tempVec3;return i.Set(t,e,o),i}getRVec3(t,e,o){const i=this._tempRVec3;return i.Set(t,e,o),i}getQuat(t,e,o,i){const s=this._tempQuat;return s.Set(t,e,o,i),s}static getSharedData(t,e){if(!t.physics3DSharedData){const o=t.getInitialSharedDataForBehavior(e);t.physics3DSharedData=new n.Physics3DSharedData(t,o)}return t.physics3DSharedData}static setupCollisionFiltering(t){const e=new Jolt.ObjectLayerPairFilterMask,o=new Jolt.BroadPhaseLayer(n.Physics3DSharedData.staticBroadPhaseLayerIndex),i=new Jolt.BroadPhaseLayer(n.Physics3DSharedData.dynamicBroadPhaseLayerIndex),s=new Jolt.BroadPhaseLayerInterfaceMask(2);s.ConfigureLayer(o,n.Physics3DSharedData.staticLayersMask,0),s.ConfigureLayer(i,n.Physics3DSharedData.dynamicLayersMask,0),Jolt.destroy(o),Jolt.destroy(i),t.mObjectLayerPairFilter=e,t.mBroadPhaseLayerInterface=s,t.mObjectVsBroadPhaseLayerFilter=new Jolt.ObjectVsBroadPhaseLayerFilterMask(s)}addToBehaviorsList(t){this._registeredBehaviors.add(t)}removeFromBehaviorsList(t){this._registeredBehaviors.delete(t)}step(t){for(const o of this._registeredBehaviors)o._contactsStartedThisFrame.length=0,o._contactsEndedThisFrame.length=0;for(const o of this._registeredBehaviors)o.updateBodyFromObject();for(const o of this._physics3DHooks)o.doBeforePhysicsStep(t);const e=t>1/55?2:1;this.jolt.Step(t,e),this.stepped=!0;for(const o of this._registeredBehaviors)o.updateObjectFromBody()}registerHook(t){this._physics3DHooks.push(t)}}b.staticLayersMask=15,b.dynamicLayersMask=240,b.allLayersMask=255,b.staticBroadPhaseLayerIndex=1,b.dynamicBroadPhaseLayerIndex=1,n.Physics3DSharedData=b,n.registerRuntimeSceneUnloadedCallback(function(u){const t=u.physics3DSharedData;t&&(Jolt.destroy(t.jolt),Jolt.destroy(t.contactListener),Jolt.destroy(t._tempVec3),Jolt.destroy(t._tempRVec3),Jolt.destroy(t._tempQuat),u.physics3DSharedData=null)});class _ extends n.RuntimeBehavior{constructor(t,e,o){super(t,e,o);this.shapeScale=1;this._contactsStartedThisFrame=[];this._contactsEndedThisFrame=[];this._currentContacts=[];this._destroyedDuringFrameLogic=!1;this._body=null;this._needToRecreateBody=!1;this._needToRecreateShape=!1;this._shapeHalfDepth=0;this._objectOldX=0;this._objectOldY=0;this._objectOldZ=0;this._objectOldRotationX=0;this._objectOldRotationY=0;this._objectOldRotationZ=0;this._objectOldWidth=0;this._objectOldHeight=0;this._objectOldDepth=0;this.bodyUpdater=new n.Physics3DRuntimeBehavior.DefaultBodyUpdater(this),this.collisionChecker=new n.Physics3DRuntimeBehavior.DefaultCollisionChecker(this),this.owner3D=o,this.bodyType=e.bodyType,this.bullet=e.bullet,this.fixedRotation=e.fixedRotation,this.shape=e.shape,this.shapeOrientation=e.shapeOrientation,this.shapeDimensionA=e.shapeDimensionA,this.shapeDimensionB=e.shapeDimensionB,this.shapeDimensionC=e.shapeDimensionC,this.density=e.density,this.friction=e.friction,this.restitution=e.restitution,this.linearDamping=Math.max(0,e.linearDamping),this.angularDamping=Math.max(0,e.angularDamping),this.gravityScale=e.gravityScale,this.layers=e.layers,this.masks=e.masks,this._sharedData=b.getSharedData(t.getScene(),e.name),this._sharedData.addToBehaviorsList(this)}getVec3(t,e,o){const i=this._sharedData._tempVec3;return i.Set(t,e,o),i}getRVec3(t,e,o){const i=this._sharedData._tempRVec3;return i.Set(t,e,o),i}getQuat(t,e,o,i){const s=this._sharedData._tempQuat;return s.Set(t,e,o,i),s}updateFromBehaviorData(t,e){return t.bullet!==e.bullet&&this.setBullet(e.bullet),t.fixedRotation!==e.fixedRotation&&this.setFixedRotation(e.fixedRotation),t.shapeDimensionA!==e.shapeDimensionA&&(this.shapeDimensionA=e.shapeDimensionA,this._needToRecreateShape=!0),t.shapeDimensionB!==e.shapeDimensionB&&(this.shapeDimensionB=e.shapeDimensionB,this._needToRecreateShape=!0),t.density!==e.density&&this.setDensity(e.density),t.friction!==e.friction&&this.setFriction(e.friction),t.restitution!==e.restitution&&this.setRestitution(e.restitution),t.linearDamping!==e.linearDamping&&this.setLinearDamping(e.linearDamping),t.angularDamping!==e.angularDamping&&this.setAngularDamping(e.angularDamping),t.gravityScale!==e.gravityScale&&this.setGravityScale(e.gravityScale),!(t.layers!==e.layers||t.masks!==e.masks||t.vertices!==e.vertices||t.bodyType!==e.bodyType||t.shape!==e.shape)}getNetworkSyncData(){let t;if(this._body){const e=this._body.GetPosition(),o=this._body.GetRotation(),i=this._body.GetLinearVelocity(),s=this._body.GetAngularVelocity();t={px:e.GetX(),py:e.GetY(),pz:e.GetZ(),rx:o.GetX(),ry:o.GetY(),rz:o.GetZ(),rw:o.GetW(),lvx:i.GetX(),lvy:i.GetY(),lvz:i.GetZ(),avx:s.GetX(),avy:s.GetY(),avz:s.GetZ(),aw:this._body.IsActive()}}else t={px:void 0,py:void 0,pz:void 0,rx:void 0,ry:void 0,rz:void 0,rw:void 0,lvx:void 0,lvy:void 0,lvz:void 0,avx:void 0,avy:void 0,avz:void 0,aw:void 0};return{...super.getNetworkSyncData(),props:{...t,layers:this.layers,masks:this.masks}}}updateFromNetworkSyncData(t){super.updateFromNetworkSyncData(t);const e=t.props;e.px!==void 0&&e.py!==void 0&&e.pz!==void 0&&this._body&&this._sharedData.bodyInterface.SetPosition(this._body.GetID(),this.getRVec3(e.px,e.py,e.pz),Jolt.EActivation_DontActivate),e.rx!==void 0&&e.ry!==void 0&&e.rz!==void 0&&e.rw!==void 0&&this._body&&this._sharedData.bodyInterface.SetRotation(this._body.GetID(),this.getQuat(e.rx,e.ry,e.rz,e.rw),Jolt.EActivation_DontActivate),e.lvx!==void 0&&e.lvy!==void 0&&e.lvz!==void 0&&this._body&&this._sharedData.bodyInterface.SetLinearVelocity(this._body.GetID(),this.getVec3(e.lvx,e.lvy,e.lvz)),e.avx!==void 0&&e.avy!==void 0&&e.avz!==void 0&&this._body&&this._sharedData.bodyInterface.SetAngularVelocity(this._body.GetID(),this.getVec3(e.avx,e.avy,e.avz)),e.layers!==void 0&&(this.layers=e.layers),e.masks!==void 0&&(this.masks=e.masks)}onDeActivate(){this._sharedData.removeFromBehaviorsList(this),this.bodyUpdater.destroyBody(),this._contactsEndedThisFrame.length=0,this._contactsStartedThisFrame.length=0,this._currentContacts.length=0}onActivate(){this._sharedData.addToBehaviorsList(this),this._contactsEndedThisFrame.length=0,this._contactsStartedThisFrame.length=0,this._currentContacts.length=0,this.updateBodyFromObject()}onDestroy(){this._destroyedDuringFrameLogic=!0,this.onDeActivate()}createShape(){let t=this.owner3D.getWidth()*this._sharedData.worldInvScale,e=this.owner3D.getHeight()*this._sharedData.worldInvScale,o=this.owner3D.getDepth()*this._sharedData.worldInvScale;if(this.shapeOrientation==="X"){const c=o;o=t,t=c}else if(this.shapeOrientation==="Y"){const c=o;o=e,e=c}const i=this.shapeScale*this._sharedData.worldInvScale,s=this.shapeDimensionA*i,a=this.shapeDimensionB*i,r=this.shapeDimensionC*i,h=this._sharedData.worldInvScale;let l,d;if(this.shape==="Box"){const c=s>0?s:t>0?t:h,y=a>0?a:e>0?e:h,g=r>0?r:o>0?o:h,D=Math.min(h,Math.min(c,y,g)/4);l=new Jolt.BoxShapeSettings(this.getVec3(c/2,y/2,g/2),D),d=this.getQuat(0,0,0,1),this._shapeHalfDepth=g/2}else if(this.shape==="Capsule"){const c=s>0?s:t>0?Math.sqrt(t*e)/2:h,y=a>0?a:o>0?o:h;l=new Jolt.CapsuleShapeSettings(Math.max(0,y/2-c),c),d=this._getShapeOrientationQuat(),this._shapeHalfDepth=this.shapeOrientation!=="Z"?c:y/2}else if(this.shape==="Cylinder"){const c=s>0?s:t>0?Math.sqrt(t*e)/2:h,y=a>0?a:o>0?o:h,g=Math.min(h,Math.min(y,c)/4);l=new Jolt.CylinderShapeSettings(y/2,c,g),d=this._getShapeOrientationQuat(),this._shapeHalfDepth=this.shapeOrientation!=="Z"?c:y/2}else{const c=s>0?s:t>0?Math.pow(t*e*o,1/3)/2:h;l=new Jolt.SphereShapeSettings(c),d=this.getQuat(0,0,0,1),this._shapeHalfDepth=c}l.mDensity=this.density;const f=new Jolt.RotatedTranslatedShapeSettings(this.getVec3(0,0,0),d,l).Create().Get();return Jolt.destroy(l),f}_getShapeOrientationQuat(){return this.shapeOrientation==="X"?this.getQuat(0,0,Math.sqrt(2)/2,-Math.sqrt(2)/2):this.shapeOrientation==="Y"?this.getQuat(0,0,0,1):this.getQuat(Math.sqrt(2)/2,0,0,Math.sqrt(2)/2)}_recreateShape(){this.bodyUpdater.recreateShape(),this._objectOldWidth=this.owner3D.getWidth(),this._objectOldHeight=this.owner3D.getHeight(),this._objectOldDepth=this.owner3D.getDepth()}getShapeScale(){return this.shapeScale}setShapeScale(t){t!==this.shapeScale&&t>0&&(this.shapeScale=t,this._needToRecreateShape=!0)}getBody(){return this._body===null&&this._createBody(),this._body}_createBody(){return this._needToRecreateBody=!1,this._needToRecreateShape=!1,!this.activated()||this._destroyedDuringFrameLogic||(this._body=this.bodyUpdater.createAndAddBody(),!this._body)?!1:(this._body.gdjsAssociatedBehavior=this,this._objectOldWidth=this.owner3D.getWidth(),this._objectOldHeight=this.owner3D.getHeight(),this._objectOldDepth=this.owner3D.getDepth(),!0)}getBodyLayer(){return Jolt.ObjectLayerPairFilterMask.prototype.sGetObjectLayer(this.getLayersAccordingToBodyType(),this.getMasksAccordingToBodyType())}getLayersAccordingToBodyType(){return this.isStatic()?this.layers&n.Physics3DSharedData.staticLayersMask:this.layers&n.Physics3DSharedData.dynamicLayersMask}getMasksAccordingToBodyType(){return this.isStatic()?n.Physics3DSharedData.allLayersMask:this.masks}doStepPreEvents(t){!this._sharedData.stepped&&!t.getScene().getTimeManager().isFirstFrame()&&this._sharedData.step(t.getScene().getTimeManager().getElapsedTime()/1e3)}doStepPostEvents(t){this._sharedData.stepped=!1}onObjectHotReloaded(){this.updateBodyFromObject()}recreateBody(){if(!this._body){this._createBody();return}const t=this._sharedData.bodyInterface,e=this._body.GetLinearVelocity(),o=e.GetX(),i=e.GetY(),s=e.GetZ(),a=this._body.GetAngularVelocity(),r=a.GetX(),h=a.GetY(),l=a.GetZ();let d=this._body.GetID();t.RemoveBody(d),t.DestroyBody(d),this._contactsEndedThisFrame.length=0,this._contactsStartedThisFrame.length=0,this._currentContacts.length=0,this._createBody(),!!this._body&&(d=this._body.GetID(),t.SetLinearVelocity(d,this.getVec3(o,i,s)),t.SetAngularVelocity(d,this.getVec3(r,h,l)))}updateObjectFromBody(){this.bodyUpdater.updateObjectFromBody(),this._objectOldX=this.owner3D.getX(),this._objectOldY=this.owner3D.getY(),this._objectOldZ=this.owner3D.getZ(),this._objectOldRotationX=this.owner3D.getRotationX(),this._objectOldRotationY=this.owner3D.getRotationY(),this._objectOldRotationZ=this.owner3D.getAngle()}updateBodyFromObject(){this._body===null&&!this._createBody()||(this._needToRecreateBody&&this.recreateBody(),(this._needToRecreateShape||!this.hasCustomShapeDimension()&&(this._objectOldWidth!==this.owner3D.getWidth()||this._objectOldHeight!==this.owner3D.getHeight()||this._objectOldDepth!==this.owner3D.getDepth()))&&(this._needToRecreateShape=!1,this._recreateShape()),this.bodyUpdater.updateBodyFromObject())}hasCustomShapeDimension(){return this.shapeDimensionA>0||this.shapeDimensionB>0||this.shapeDimensionC>0}getPhysicsPosition(t){return t.Set(this.owner3D.getCenterXInScene()*this._sharedData.worldInvScale,this.owner3D.getCenterYInScene()*this._sharedData.worldInvScale,this.owner3D.getCenterZInScene()*this._sharedData.worldInvScale),t}getPhysicsRotation(t){const e=this.owner3D.get3DRendererObject();return t.Set(e.quaternion.x,e.quaternion.y,e.quaternion.z,e.quaternion.w),t}moveObjectToPhysicsPosition(t){this.owner3D.setCenterXInScene(t.GetX()*this._sharedData.worldScale),this.owner3D.setCenterYInScene(t.GetY()*this._sharedData.worldScale),this.owner3D.setCenterZInScene(t.GetZ()*this._sharedData.worldScale)}moveObjectToPhysicsRotation(t){const e=this.owner3D.get3DRendererObject();e.quaternion.x=t.GetX(),e.quaternion.y=t.GetY(),e.quaternion.z=t.GetZ(),e.quaternion.w=t.GetW();const o=new THREE.Euler(0,0,0,"ZYX");o.setFromQuaternion(e.quaternion),this.owner3D.setRotationX(n.toDegrees(o.x)),this.owner3D.setRotationY(n.toDegrees(o.y)),this.owner3D.setAngle(n.toDegrees(o.z))}getWorldScale(){return this._sharedData.worldScale}getGravityX(){return this._sharedData.gravityX}getGravityY(){return this._sharedData.gravityY}getGravityZ(){return this._sharedData.gravityZ}setGravityX(t){this._sharedData.gravityX!==t&&(this._sharedData.gravityX=t,this._sharedData.physicsSystem.SetGravity(this.getVec3(this._sharedData.gravityX,this._sharedData.gravityY,this._sharedData.gravityZ)))}setGravityY(t){this._sharedData.gravityX!==t&&(this._sharedData.gravityX=t,this._sharedData.physicsSystem.SetGravity(this.getVec3(this._sharedData.gravityX,this._sharedData.gravityY,this._sharedData.gravityZ)))}setGravityZ(t){this._sharedData.gravityX!==t&&(this._sharedData.gravityZ=t,this._sharedData.physicsSystem.SetGravity(this.getVec3(this._sharedData.gravityX,this._sharedData.gravityY,this._sharedData.gravityZ)))}isDynamic(){return this.bodyType==="Dynamic"}isStatic(){return this.bodyType==="Static"}isKinematic(){return this.bodyType==="Kinematic"}isBullet(){return this.bullet}setBullet(t){if(this.bullet===t||(this.bullet=t,this._body===null&&!this._createBody()))return;const e=this._body;this._sharedData.bodyInterface.SetMotionQuality(e.GetID(),this.bullet?Jolt.EMotionQuality_LinearCast:Jolt.EMotionQuality_Discrete)}hasFixedRotation(){return this.fixedRotation}setFixedRotation(t){this.fixedRotation!==t&&(this.fixedRotation=t,this._needToRecreateBody=!0)}getDensity(){return this.density}setDensity(t){t<0&&(t=0),this.density!==t&&(this.density=t,this._needToRecreateShape=!0)}getFriction(){return this.friction}setFriction(t){if(t<0&&(t=0),this.friction===t||(this.friction=t,this._body===null&&!this._createBody()))return;const e=this._body;this._sharedData.bodyInterface.SetFriction(e.GetID(),t)}getRestitution(){return this.restitution}setRestitution(t){if(t<0&&(t=0),this.restitution===t||(this.restitution=t,this._body===null&&!this._createBody()))return;const e=this._body;this._sharedData.bodyInterface.SetRestitution(e.GetID(),t)}getLinearDamping(){return this.linearDamping}setLinearDamping(t){if(t<0&&(t=0),this.linearDamping===t||(this.linearDamping=t,this._body===null&&!this._createBody()))return;this._body.GetMotionProperties().SetLinearDamping(t)}getAngularDamping(){return this.angularDamping}setAngularDamping(t){if(t<0&&(t=0),this.angularDamping===t||(this.angularDamping=t,this._body===null&&!this._createBody()))return;this._body.GetMotionProperties().SetAngularDamping(t)}getGravityScale(){return this.gravityScale}setGravityScale(t){if(this.gravityScale===t||(this.gravityScale=t,this._body===null&&!this._createBody()))return;this._body.GetMotionProperties().SetGravityFactor(t)}layerEnabled(t){return t=Math.floor(t),t<1||t>8?!1:!!(this.layers&1<<t-1)}enableLayer(t,e){t=Math.floor(t),!(t<1||t>8)&&(e?this.layers|=1<<t-1:this.layers&=~(1<<t-1),this._needToRecreateBody=!0)}maskEnabled(t){return t=Math.floor(t),t<1||t>16?!1:!!(this.masks&1<<t-1)}enableMask(t,e){t=Math.floor(t),!(t<1||t>16)&&(e?this.masks|=1<<t-1:this.masks&=~(1<<t-1),this._needToRecreateBody=!0)}getLinearVelocityX(){return this._body===null&&!this._createBody()?0:this._body.GetLinearVelocity().GetX()*this._sharedData.worldScale}setLinearVelocityX(t){if(this._body===null&&!this._createBody())return;const e=this._body;this._sharedData.bodyInterface.SetLinearVelocity(e.GetID(),this.getVec3(t*this._sharedData.worldInvScale,e.GetLinearVelocity().GetY(),e.GetLinearVelocity().GetZ()))}getLinearVelocityY(){return this._body===null&&!this._createBody()?0:this._body.GetLinearVelocity().GetY()*this._sharedData.worldScale}setLinearVelocityY(t){if(this._body===null&&!this._createBody())return;const e=this._body;this._sharedData.bodyInterface.SetLinearVelocity(e.GetID(),this.getVec3(e.GetLinearVelocity().GetX(),t*this._sharedData.worldInvScale,e.GetLinearVelocity().GetZ()))}getLinearVelocityZ(){return this._body===null&&!this._createBody()?0:this._body.GetLinearVelocity().GetZ()*this._sharedData.worldScale}setLinearVelocityZ(t){if(this._body===null&&!this._createBody())return;const e=this._body;this._sharedData.bodyInterface.SetLinearVelocity(e.GetID(),this.getVec3(e.GetLinearVelocity().GetX(),e.GetLinearVelocity().GetY(),t*this._sharedData.worldInvScale))}getLinearVelocityLength(){return this._body===null&&!this._createBody()?0:this._body.GetLinearVelocity().Length()*this._sharedData.worldScale}getAngularVelocityX(){if(this._body===null&&!this._createBody())return 0;const t=this._body;return n.toDegrees(t.GetAngularVelocity().GetX())}setAngularVelocityX(t){if(this._body===null&&!this._createBody())return;const e=this._body;this._sharedData.bodyInterface.SetAngularVelocity(e.GetID(),this.getVec3(n.toRad(t),e.GetAngularVelocity().GetY(),e.GetAngularVelocity().GetZ()))}getAngularVelocityY(){if(this._body===null&&!this._createBody())return 0;const t=this._body;return n.toDegrees(t.GetAngularVelocity().GetY())}setAngularVelocityY(t){if(this._body===null&&!this._createBody())return;const e=this._body;this._sharedData.bodyInterface.SetAngularVelocity(e.GetID(),this.getVec3(e.GetAngularVelocity().GetX(),n.toRad(t),e.GetAngularVelocity().GetZ()))}getAngularVelocityZ(){if(this._body===null&&!this._createBody())return 0;const t=this._body;return n.toDegrees(t.GetAngularVelocity().GetZ())}setAngularVelocityZ(t){if(this._body===null&&!this._createBody())return;const e=this._body;this._sharedData.bodyInterface.SetAngularVelocity(e.GetID(),this.getVec3(e.GetAngularVelocity().GetX(),e.GetAngularVelocity().GetY(),n.toRad(t)))}applyForce(t,e,o,i,s,a){if(this._body===null&&!this._createBody())return;const r=this._body;this._sharedData.bodyInterface.AddForce(r.GetID(),this.getVec3(t,e,o),this.getRVec3(i*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale,a*this._sharedData.worldInvScale),Jolt.EActivation_Activate)}applyForceAtCenter(t,e,o){if(this._body===null&&!this._createBody())return;const i=this._body;this._sharedData.bodyInterface.AddForce(i.GetID(),this.getVec3(t,e,o),Jolt.EActivation_Activate)}applyForceTowardPosition(t,e,o,i){if(this._body===null&&!this._createBody())return;const s=this._body,a=e-s.GetPosition().GetX(),r=o-s.GetPosition().GetY(),h=i-s.GetPosition().GetZ(),l=a*a+r*r+h*h;if(l===0)return;const d=t/l;this._sharedData.bodyInterface.AddForce(s.GetID(),this.getVec3(a*d,r*d,h*d),Jolt.EActivation_Activate)}applyImpulse(t,e,o,i,s,a){if(this._body===null&&!this._createBody())return;const r=this._body;this._sharedData.bodyInterface.AddImpulse(r.GetID(),this.getVec3(t,e,o),this.getRVec3(i*this._sharedData.worldInvScale,s*this._sharedData.worldInvScale,a*this._sharedData.worldInvScale))}applyImpulseAtCenter(t,e,o){if(this._body===null&&!this._createBody())return;const i=this._body;this._sharedData.bodyInterface.AddImpulse(i.GetID(),this.getVec3(t,e,o))}applyImpulseTowardPosition(t,e,o,i,s,a,r){if(this._body===null&&!this._createBody())return;const h=this._body,l=e-s,d=o-a,f=i-r,c=l*l+d*d+f*f;if(c===0)return;const y=t/c;this._sharedData.bodyInterface.AddImpulse(h.GetID(),this.getVec3(l*y,d*y,f*y),this.getRVec3(s*this._sharedData.worldInvScale,a*this._sharedData.worldInvScale,r*this._sharedData.worldInvScale))}applyTorque(t,e,o){if(this._body===null&&!this._createBody())return;const i=this._body;this._sharedData.bodyInterface.AddTorque(i.GetID(),this.getVec3(n.toRad(t),n.toRad(e),n.toRad(o)),Jolt.EActivation_Activate)}applyAngularImpulse(t,e,o){if(this._body===null&&!this._createBody())return;const i=this._body;this._sharedData.bodyInterface.AddAngularImpulse(i.GetID(),this.getVec3(n.toRad(t),n.toRad(e),n.toRad(o)))}getMass(){if(this._body===null&&!this._createBody())return 0;const t=this._body;return 1/t.GetMotionProperties().GetInverseMass()}getInertiaAroundX(){if(this._body===null&&!this._createBody())return 0;const t=this._body;return 1/t.GetMotionProperties().GetInverseInertiaDiagonal().GetX()}getInertiaAroundY(){if(this._body===null&&!this._createBody())return 0;const t=this._body;return 1/t.GetMotionProperties().GetInverseInertiaDiagonal().GetY()}getInertiaAroundZ(){if(this._body===null&&!this._createBody())return 0;const t=this._body;return 1/t.GetMotionProperties().GetInverseInertiaDiagonal().GetZ()}getMassCenterX(){return this._body===null&&!this._createBody()?0:this._body.GetCenterOfMassPosition().GetX()*this._sharedData.worldScale}getMassCenterY(){return this._body===null&&!this._createBody()?0:this._body.GetCenterOfMassPosition().GetY()*this._sharedData.worldScale}getMassCenterZ(){return this._body===null&&!this._createBody()?0:this._body.GetCenterOfMassPosition().GetZ()*this._sharedData.worldScale}onContactBegin(t){this._currentContacts.push(t);let e=this._contactsEndedThisFrame.indexOf(t);e!==-1?this._contactsEndedThisFrame.splice(e,1):this._contactsStartedThisFrame.push(t)}onContactEnd(t){this._contactsEndedThisFrame.push(t);const e=this._currentContacts.indexOf(t);e!==-1&&this._currentContacts.splice(e,1)}canCollideAgainst(t){return(this.getMasksAccordingToBodyType()&t.getLayersAccordingToBodyType())!=0}static areObjectsColliding(t,e,o){const i=t.getBehavior(o);return i?i.collisionChecker.isColliding(e):!1}static hasCollisionStartedBetween(t,e,o){const i=t.getBehavior(o);return i?i.collisionChecker.hasCollisionStartedWith(e):!1}static hasCollisionStoppedBetween(t,e,o){const i=t.getBehavior(o);return i?i.collisionChecker.hasCollisionStoppedWith(e):!1}}n.Physics3DRuntimeBehavior=_,n.registerBehavior("Physics3D::Physics3DBehavior",n.Physics3DRuntimeBehavior),function(e){class u{constructor(i){this.behavior=i}createAndAddBody(){const{behavior:i}=this,{_sharedData:s}=i,a=i.createShape(),r=new Jolt.BodyCreationSettings(a,i.getPhysicsPosition(s.getRVec3(0,0,0)),i.getPhysicsRotation(s.getQuat(0,0,0,1)),i.bodyType==="Static"?Jolt.EMotionType_Static:i.bodyType==="Kinematic"?Jolt.EMotionType_Kinematic:Jolt.EMotionType_Dynamic,i.getBodyLayer());r.mMotionQuality=i.bullet?Jolt.EMotionQuality_LinearCast:Jolt.EMotionQuality_Discrete,r.mAllowedDOFs=i.fixedRotation?Jolt.EAllowedDOFs_TranslationX|Jolt.EAllowedDOFs_TranslationY|Jolt.EAllowedDOFs_TranslationZ:Jolt.EAllowedDOFs_All,r.mFriction=i.friction,r.mRestitution=i.restitution,r.mLinearDamping=i.linearDamping,r.mAngularDamping=i.angularDamping,r.mGravityFactor=i.gravityScale;const h=s.bodyInterface,l=h.CreateBody(r);return Jolt.destroy(r),h.AddBody(l.GetID(),Jolt.EActivation_Activate),l}updateObjectFromBody(){const{behavior:i}=this,{_body:s}=i;s!==null&&s.IsActive()&&(i.moveObjectToPhysicsPosition(s.GetPosition()),i.moveObjectToPhysicsRotation(s.GetRotation()))}updateBodyFromObject(){const{behavior:i}=this,{owner3D:s,_sharedData:a}=i;if(i._body===null&&!i._createBody())return;const r=i._body;(this.behavior._objectOldX!==s.getX()||this.behavior._objectOldY!==s.getY()||this.behavior._objectOldZ!==s.getZ()||this.behavior._objectOldRotationX!==s.getRotationX()||this.behavior._objectOldRotationY!==s.getRotationY()||this.behavior._objectOldRotationZ!==s.getAngle())&&a.bodyInterface.SetPositionAndRotationWhenChanged(r.GetID(),this.behavior.getPhysicsPosition(a.getRVec3(0,0,0)),this.behavior.getPhysicsRotation(a.getQuat(0,0,0,1)),Jolt.EActivation_Activate)}recreateShape(){const{behavior:i}=this,{_sharedData:s}=i;if(i._body===null&&!i._createBody())return;const a=i._body;s.bodyInterface.SetShape(a.GetID(),i.createShape(),!0,Jolt.EActivation_Activate)}destroyBody(){const{behavior:i}=this,{_sharedData:s}=i;i._body!==null&&(s.bodyInterface.RemoveBody(i._body.GetID()),s.bodyInterface.DestroyBody(i._body.GetID()),i._body=null)}}e.DefaultBodyUpdater=u;class t{constructor(i){this.behavior=i}isColliding(i){return this.behavior._currentContacts.some(s=>s.owner===i)?!0:this.behavior._contactsStartedThisFrame.some(s=>s.owner===i)}hasCollisionStartedWith(i){return this.behavior._contactsStartedThisFrame.some(s=>s.owner===i)}hasCollisionStoppedWith(i){return this.behavior._contactsEndedThisFrame.some(s=>s.owner===i)}}e.DefaultCollisionChecker=t}(_=n.Physics3DRuntimeBehavior||(n.Physics3DRuntimeBehavior={}))})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=Physics3DRuntimeBehavior.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../GDevelop/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.ts"],
4
- "sourcesContent": ["/// <reference path=\"./jolt-physics.d.ts\" />\n\nnamespace Jolt {\n export interface Body {\n gdjsAssociatedBehavior: gdjs.Physics3DRuntimeBehavior | null;\n }\n}\n\nnamespace gdjs {\n const loadJolt = async () => {\n try {\n const module = await import('./jolt-physics.wasm.js');\n const initializeJoltPhysics = module.default;\n if (!initializeJoltPhysics) {\n throw new Error('No default export found in Jolt.');\n }\n\n const Jolt = await initializeJoltPhysics();\n window.Jolt = Jolt;\n } catch (err) {\n console.error('Unable to load Jolt physics library.', err);\n throw err;\n }\n };\n gdjs.registerAsynchronouslyLoadingLibraryPromise(loadJolt());\n\n export interface RuntimeScene {\n physics3DSharedData: gdjs.Physics3DSharedData | null;\n }\n interface Physics3DNetworkSyncDataType {\n px: number | undefined;\n py: number | undefined;\n pz: number | undefined;\n rx: number | undefined;\n ry: number | undefined;\n rz: number | undefined;\n rw: number | undefined;\n lvx: number | undefined;\n lvy: number | undefined;\n lvz: number | undefined;\n avx: number | undefined;\n avy: number | undefined;\n avz: number | undefined;\n aw: boolean | undefined;\n layers: number;\n masks: number;\n }\n\n export interface Physics3DNetworkSyncData extends BehaviorNetworkSyncData {\n props: Physics3DNetworkSyncDataType;\n }\n\n export class Physics3DSharedData {\n gravityX: float;\n gravityY: float;\n gravityZ: float;\n worldScale: float;\n worldInvScale: float;\n\n jolt: Jolt.JoltInterface;\n physicsSystem: Jolt.PhysicsSystem;\n bodyInterface: Jolt.BodyInterface;\n /** Contact listener to keep track of current collisions */\n contactListener: Jolt.ContactListenerJS;\n /** Avoid creating new vectors all the time */\n _tempVec3 = new Jolt.Vec3();\n _tempRVec3 = new Jolt.RVec3();\n _tempQuat = new Jolt.Quat();\n\n stepped: boolean = false;\n /**\n * List of physics behavior in the runtimeScene. It should be updated\n * when a new physics object is created (constructor), on destruction (onDestroy),\n * on behavior activation (onActivate) and on behavior deactivation (onDeActivate).\n */\n _registeredBehaviors: Set<Physics3DRuntimeBehavior>;\n\n private _physics3DHooks: Array<\n gdjs.Physics3DRuntimeBehavior.Physics3DHook\n > = [];\n\n constructor(instanceContainer: gdjs.RuntimeInstanceContainer, sharedData) {\n this._registeredBehaviors = new Set<Physics3DRuntimeBehavior>();\n this.gravityX = sharedData.gravityX;\n this.gravityY = sharedData.gravityY;\n this.gravityZ = sharedData.gravityZ;\n this.worldScale = sharedData.worldScale;\n this.worldInvScale = 1 / this.worldScale;\n\n // Initialize Jolt\n const settings = new Jolt.JoltSettings();\n gdjs.Physics3DSharedData.setupCollisionFiltering(settings);\n this.jolt = new Jolt.JoltInterface(settings);\n Jolt.destroy(settings);\n this.physicsSystem = this.jolt.GetPhysicsSystem();\n this.physicsSystem.SetGravity(\n this.getVec3(this.gravityX, this.gravityY, this.gravityZ)\n );\n this.bodyInterface = this.physicsSystem.GetBodyInterface();\n\n this.contactListener = new Jolt.ContactListenerJS();\n this.physicsSystem.SetContactListener(this.contactListener);\n this.contactListener.OnContactAdded = (\n bodyPtrA: number,\n bodyPtrB: number,\n manifoldPtr: number,\n settingsPtr: number\n ): void => {\n const bodyA = Jolt.wrapPointer(bodyPtrA, Jolt.Body);\n const bodyB = Jolt.wrapPointer(bodyPtrB, Jolt.Body);\n\n const behaviorA = bodyA.gdjsAssociatedBehavior;\n const behaviorB = bodyB.gdjsAssociatedBehavior;\n if (!behaviorA || !behaviorB) {\n return;\n }\n\n behaviorA.onContactBegin(behaviorB);\n behaviorB.onContactBegin(behaviorA);\n };\n this.contactListener.OnContactRemoved = (\n subShapePairPtr: number\n ): void => {\n const subShapePair = Jolt.wrapPointer(\n subShapePairPtr,\n Jolt.SubShapeIDPair\n );\n\n // This is ok because bodies are not deleted during the Physics step.\n const bodyLockInterface = this.physicsSystem.GetBodyLockInterface();\n const bodyA = bodyLockInterface.TryGetBody(subShapePair.GetBody1ID());\n const bodyB = bodyLockInterface.TryGetBody(subShapePair.GetBody2ID());\n\n const behaviorA = bodyA.gdjsAssociatedBehavior;\n const behaviorB = bodyB.gdjsAssociatedBehavior;\n if (!behaviorA || !behaviorB) {\n return;\n }\n\n behaviorA.onContactEnd(behaviorB);\n behaviorB.onContactEnd(behaviorA);\n };\n this.contactListener.OnContactPersisted = (\n bodyPtrA: number,\n bodyPtrB: number,\n manifoldPtr: number,\n settingsPtr: number\n ): void => {\n // TODO we could rely on this event.\n };\n this.contactListener.OnContactValidate = (\n bodyPtrA: number,\n bodyPtrB: number,\n inBaseOffset: number,\n inCollisionResult: number\n ): number => {\n return Jolt.ValidateResult_AcceptAllContactsForThisBodyPair;\n };\n }\n\n getVec3(x: float, y: float, z: float): Jolt.Vec3 {\n const tempVec3 = this._tempVec3;\n tempVec3.Set(x, y, z);\n return tempVec3;\n }\n\n getRVec3(x: float, y: float, z: float): Jolt.RVec3 {\n const tempRVec3 = this._tempRVec3;\n tempRVec3.Set(x, y, z);\n return tempRVec3;\n }\n\n getQuat(x: float, y: float, z: float, w: float): Jolt.Quat {\n const tempQuat = this._tempQuat;\n tempQuat.Set(x, y, z, w);\n return tempQuat;\n }\n\n static getSharedData(\n runtimeScene: gdjs.RuntimeScene,\n behaviorName: string\n ): gdjs.Physics3DSharedData {\n if (!runtimeScene.physics3DSharedData) {\n const initialData = runtimeScene.getInitialSharedDataForBehavior(\n behaviorName\n );\n runtimeScene.physics3DSharedData = new gdjs.Physics3DSharedData(\n runtimeScene,\n initialData\n );\n }\n return runtimeScene.physics3DSharedData;\n }\n\n // There are 4 bits for static layers and 4 bits for dynamic layers.\n static readonly staticLayersMask = 0x0f;\n static readonly dynamicLayersMask = 0xf0;\n static readonly allLayersMask = 0xff;\n static readonly staticBroadPhaseLayerIndex = 1;\n static readonly dynamicBroadPhaseLayerIndex = 1;\n\n private static setupCollisionFiltering(settings: Jolt.JoltSettings): void {\n const objectFilter = new Jolt.ObjectLayerPairFilterMask();\n const staticBroadPhaseLayer = new Jolt.BroadPhaseLayer(\n gdjs.Physics3DSharedData.staticBroadPhaseLayerIndex\n );\n const dynamicBroadPhaseLayer = new Jolt.BroadPhaseLayer(\n gdjs.Physics3DSharedData.dynamicBroadPhaseLayerIndex\n );\n const broadPhaseLayerInterfaceMask = new Jolt.BroadPhaseLayerInterfaceMask(\n 2\n );\n broadPhaseLayerInterfaceMask.ConfigureLayer(\n staticBroadPhaseLayer,\n gdjs.Physics3DSharedData.staticLayersMask,\n 0\n );\n broadPhaseLayerInterfaceMask.ConfigureLayer(\n dynamicBroadPhaseLayer,\n gdjs.Physics3DSharedData.dynamicLayersMask,\n 0\n );\n // BroadPhaseLayer have been copied into bpInterface\n Jolt.destroy(staticBroadPhaseLayer);\n Jolt.destroy(dynamicBroadPhaseLayer);\n\n settings.mObjectLayerPairFilter = objectFilter;\n settings.mBroadPhaseLayerInterface = broadPhaseLayerInterfaceMask;\n settings.mObjectVsBroadPhaseLayerFilter = new Jolt.ObjectVsBroadPhaseLayerFilterMask(\n broadPhaseLayerInterfaceMask\n );\n }\n\n /**\n * Add a physics object to the list of existing object.\n */\n addToBehaviorsList(physicsBehavior: gdjs.Physics3DRuntimeBehavior): void {\n this._registeredBehaviors.add(physicsBehavior);\n }\n\n /**\n * Remove a physics object to the list of existing object.\n */\n removeFromBehaviorsList(\n physicsBehavior: gdjs.Physics3DRuntimeBehavior\n ): void {\n this._registeredBehaviors.delete(physicsBehavior);\n }\n\n step(deltaTime: float): void {\n for (const physicsBehavior of this._registeredBehaviors) {\n physicsBehavior._contactsStartedThisFrame.length = 0;\n physicsBehavior._contactsEndedThisFrame.length = 0;\n }\n for (const physicsBehavior of this._registeredBehaviors) {\n physicsBehavior.updateBodyFromObject();\n }\n for (const physics3DHook of this._physics3DHooks) {\n physics3DHook.doBeforePhysicsStep(deltaTime);\n }\n\n const numSteps = deltaTime > 1.0 / 55.0 ? 2 : 1;\n this.jolt.Step(deltaTime, numSteps);\n this.stepped = true;\n\n // It's important that updateBodyFromObject and updateObjectFromBody are\n // called at the same time because other behavior may move the object in\n // their doStepPreEvents.\n for (const physicsBehavior of this._registeredBehaviors) {\n physicsBehavior.updateObjectFromBody();\n }\n }\n\n /**\n * A hook must typically be registered by a behavior that requires this one\n * in its onCreate function.\n * The hook must stay forever to avoid side effects like a hooks order\n * change. To handle deactivated behavior, the hook can check that its\n * behavior is activated before doing anything.\n */\n registerHook(hook: gdjs.Physics3DRuntimeBehavior.Physics3DHook) {\n this._physics3DHooks.push(hook);\n }\n }\n gdjs.registerRuntimeSceneUnloadedCallback(function (runtimeScene) {\n const physics3DSharedData = runtimeScene.physics3DSharedData;\n if (physics3DSharedData) {\n Jolt.destroy(physics3DSharedData.jolt);\n Jolt.destroy(physics3DSharedData.contactListener);\n Jolt.destroy(physics3DSharedData._tempVec3);\n Jolt.destroy(physics3DSharedData._tempRVec3);\n Jolt.destroy(physics3DSharedData._tempQuat);\n runtimeScene.physics3DSharedData = null;\n }\n });\n\n export class Physics3DRuntimeBehavior extends gdjs.RuntimeBehavior {\n bodyUpdater: gdjs.Physics3DRuntimeBehavior.BodyUpdater;\n collisionChecker: gdjs.Physics3DRuntimeBehavior.CollisionChecker;\n owner3D: gdjs.RuntimeObject3D;\n\n bodyType: string;\n bullet: boolean;\n fixedRotation: boolean;\n private shape: string;\n private shapeOrientation: string;\n private shapeDimensionA: any;\n private shapeDimensionB: any;\n private shapeDimensionC: any;\n private density: float;\n friction: float;\n restitution: float;\n linearDamping: float;\n angularDamping: float;\n gravityScale: float;\n private layers: integer;\n private masks: integer;\n private shapeScale: number = 1;\n\n /**\n * Array containing the beginning of contacts reported by onContactBegin. Each contact\n * should be unique to avoid recording glitches where the object loses and regain\n * contact between two frames. The array is updated each time the method\n * onContactBegin is called by the listener, which is only called when stepping\n * the world i.e. in the first preEvent called by a physics behavior. This array is\n * cleared just before stepping the world.\n */\n _contactsStartedThisFrame: Array<Physics3DRuntimeBehavior> = [];\n\n /**\n * Array containing the end of contacts reported by onContactEnd. The array is updated\n * each time the method onContactEnd is called by the listener, which can be called at\n * any time. This array is cleared just before stepping the world.\n */\n _contactsEndedThisFrame: Array<Physics3DRuntimeBehavior> = [];\n\n /**\n * Array containing the exact current contacts with the objects. It is updated\n * each time the methods onContactBegin and onContactEnd are called by the contact\n * listener.\n */\n _currentContacts: Array<Physics3DRuntimeBehavior> = [];\n\n private _destroyedDuringFrameLogic: boolean;\n _body: Jolt.Body | null = null;\n /**\n * When set to `true` the body will be recreated before the next physics step.\n */\n private _needToRecreateBody: boolean = false;\n /**\n * When set to `true` the shape will be recreated before the next physics step.\n */\n private _needToRecreateShape: boolean = false;\n /**\n * Used by {@link gdjs.PhysicsCharacter3DRuntimeBehavior} to convert coordinates.\n */\n _shapeHalfDepth: float = 0;\n\n /**\n * sharedData is a reference to the shared data of the scene, that registers\n * every physics behavior that is created so that collisions can be cleared\n * before stepping the world.\n */\n _sharedData: Physics3DSharedData;\n\n _objectOldX: float = 0;\n _objectOldY: float = 0;\n _objectOldZ: float = 0;\n _objectOldRotationX: float = 0;\n _objectOldRotationY: float = 0;\n _objectOldRotationZ: float = 0;\n _objectOldWidth: float = 0;\n _objectOldHeight: float = 0;\n _objectOldDepth: float = 0;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData,\n owner: gdjs.RuntimeObject3D\n ) {\n super(instanceContainer, behaviorData, owner);\n this.bodyUpdater = new gdjs.Physics3DRuntimeBehavior.DefaultBodyUpdater(\n this\n );\n this.collisionChecker = new gdjs.Physics3DRuntimeBehavior.DefaultCollisionChecker(\n this\n );\n this.owner3D = owner;\n this.bodyType = behaviorData.bodyType;\n this.bullet = behaviorData.bullet;\n this.fixedRotation = behaviorData.fixedRotation;\n this.shape = behaviorData.shape;\n this.shapeOrientation = behaviorData.shapeOrientation;\n this.shapeDimensionA = behaviorData.shapeDimensionA;\n this.shapeDimensionB = behaviorData.shapeDimensionB;\n this.shapeDimensionC = behaviorData.shapeDimensionC;\n this.density = behaviorData.density;\n this.friction = behaviorData.friction;\n this.restitution = behaviorData.restitution;\n this.linearDamping = Math.max(0, behaviorData.linearDamping);\n this.angularDamping = Math.max(0, behaviorData.angularDamping);\n this.gravityScale = behaviorData.gravityScale;\n this.layers = behaviorData.layers;\n this.masks = behaviorData.masks;\n this._destroyedDuringFrameLogic = false;\n this._sharedData = Physics3DSharedData.getSharedData(\n instanceContainer.getScene(),\n behaviorData.name\n );\n this._sharedData.addToBehaviorsList(this);\n }\n\n private getVec3(x: float, y: float, z: float): Jolt.Vec3 {\n const tempVec3 = this._sharedData._tempVec3;\n tempVec3.Set(x, y, z);\n return tempVec3;\n }\n\n private getRVec3(x: float, y: float, z: float): Jolt.RVec3 {\n const tempRVec3 = this._sharedData._tempRVec3;\n tempRVec3.Set(x, y, z);\n return tempRVec3;\n }\n\n private getQuat(x: float, y: float, z: float, w: float): Jolt.Quat {\n const tempQuat = this._sharedData._tempQuat;\n tempQuat.Set(x, y, z, w);\n return tempQuat;\n }\n\n updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {\n if (oldBehaviorData.bullet !== newBehaviorData.bullet) {\n this.setBullet(newBehaviorData.bullet);\n }\n if (oldBehaviorData.fixedRotation !== newBehaviorData.fixedRotation) {\n this.setFixedRotation(newBehaviorData.fixedRotation);\n }\n if (oldBehaviorData.shapeDimensionA !== newBehaviorData.shapeDimensionA) {\n this.shapeDimensionA = newBehaviorData.shapeDimensionA;\n this._needToRecreateShape = true;\n }\n if (oldBehaviorData.shapeDimensionB !== newBehaviorData.shapeDimensionB) {\n this.shapeDimensionB = newBehaviorData.shapeDimensionB;\n this._needToRecreateShape = true;\n }\n if (oldBehaviorData.density !== newBehaviorData.density) {\n this.setDensity(newBehaviorData.density);\n }\n if (oldBehaviorData.friction !== newBehaviorData.friction) {\n this.setFriction(newBehaviorData.friction);\n }\n if (oldBehaviorData.restitution !== newBehaviorData.restitution) {\n this.setRestitution(newBehaviorData.restitution);\n }\n if (oldBehaviorData.linearDamping !== newBehaviorData.linearDamping) {\n this.setLinearDamping(newBehaviorData.linearDamping);\n }\n if (oldBehaviorData.angularDamping !== newBehaviorData.angularDamping) {\n this.setAngularDamping(newBehaviorData.angularDamping);\n }\n if (oldBehaviorData.gravityScale !== newBehaviorData.gravityScale) {\n this.setGravityScale(newBehaviorData.gravityScale);\n }\n\n // TODO: make these properties updatable.\n if (oldBehaviorData.layers !== newBehaviorData.layers) {\n return false;\n }\n if (oldBehaviorData.masks !== newBehaviorData.masks) {\n return false;\n }\n if (oldBehaviorData.vertices !== newBehaviorData.vertices) {\n return false;\n }\n if (oldBehaviorData.bodyType !== newBehaviorData.bodyType) {\n return false;\n }\n if (oldBehaviorData.shape !== newBehaviorData.shape) {\n return false;\n }\n return true;\n }\n\n getNetworkSyncData(): Physics3DNetworkSyncData {\n let bodyProps;\n if (this._body) {\n const position = this._body.GetPosition();\n const rotation = this._body.GetRotation();\n const linearVelocity = this._body.GetLinearVelocity();\n const angularVelocity = this._body.GetAngularVelocity();\n bodyProps = {\n px: position.GetX(),\n py: position.GetY(),\n pz: position.GetZ(),\n rx: rotation.GetX(),\n ry: rotation.GetY(),\n rz: rotation.GetZ(),\n rw: rotation.GetW(),\n lvx: linearVelocity.GetX(),\n lvy: linearVelocity.GetY(),\n lvz: linearVelocity.GetZ(),\n avx: angularVelocity.GetX(),\n avy: angularVelocity.GetY(),\n avz: angularVelocity.GetZ(),\n aw: this._body.IsActive(),\n };\n } else {\n bodyProps = {\n px: undefined,\n py: undefined,\n pz: undefined,\n rx: undefined,\n ry: undefined,\n rz: undefined,\n rw: undefined,\n lvx: undefined,\n lvy: undefined,\n lvz: undefined,\n avx: undefined,\n avy: undefined,\n avz: undefined,\n aw: undefined,\n };\n }\n return {\n ...super.getNetworkSyncData(),\n props: {\n ...bodyProps,\n layers: this.layers,\n masks: this.masks,\n },\n };\n }\n\n updateFromNetworkSyncData(networkSyncData: Physics3DNetworkSyncData) {\n super.updateFromNetworkSyncData(networkSyncData);\n\n const behaviorSpecificProps = networkSyncData.props;\n if (\n behaviorSpecificProps.px !== undefined &&\n behaviorSpecificProps.py !== undefined &&\n behaviorSpecificProps.pz !== undefined\n ) {\n if (this._body) {\n this._sharedData.bodyInterface.SetPosition(\n this._body.GetID(),\n this.getRVec3(\n behaviorSpecificProps.px,\n behaviorSpecificProps.py,\n behaviorSpecificProps.pz\n ),\n Jolt.EActivation_DontActivate\n );\n }\n }\n if (\n behaviorSpecificProps.rx !== undefined &&\n behaviorSpecificProps.ry !== undefined &&\n behaviorSpecificProps.rz !== undefined &&\n behaviorSpecificProps.rw !== undefined\n ) {\n if (this._body) {\n this._sharedData.bodyInterface.SetRotation(\n this._body.GetID(),\n this.getQuat(\n behaviorSpecificProps.rx,\n behaviorSpecificProps.ry,\n behaviorSpecificProps.rz,\n behaviorSpecificProps.rw\n ),\n Jolt.EActivation_DontActivate\n );\n }\n }\n if (\n behaviorSpecificProps.lvx !== undefined &&\n behaviorSpecificProps.lvy !== undefined &&\n behaviorSpecificProps.lvz !== undefined\n ) {\n if (this._body) {\n this._sharedData.bodyInterface.SetLinearVelocity(\n this._body.GetID(),\n this.getVec3(\n behaviorSpecificProps.lvx,\n behaviorSpecificProps.lvy,\n behaviorSpecificProps.lvz\n )\n );\n }\n }\n if (\n behaviorSpecificProps.avx !== undefined &&\n behaviorSpecificProps.avy !== undefined &&\n behaviorSpecificProps.avz !== undefined\n ) {\n if (this._body) {\n this._sharedData.bodyInterface.SetAngularVelocity(\n this._body.GetID(),\n this.getVec3(\n behaviorSpecificProps.avx,\n behaviorSpecificProps.avy,\n behaviorSpecificProps.avz\n )\n );\n }\n }\n if (behaviorSpecificProps.layers !== undefined) {\n this.layers = behaviorSpecificProps.layers;\n }\n if (behaviorSpecificProps.masks !== undefined) {\n this.masks = behaviorSpecificProps.masks;\n }\n }\n\n onDeActivate() {\n this._sharedData.removeFromBehaviorsList(this);\n if (this._body !== null) {\n this._sharedData.bodyInterface.RemoveBody(this._body.GetID());\n this._sharedData.bodyInterface.DestroyBody(this._body.GetID());\n this._body = null;\n }\n this._contactsEndedThisFrame.length = 0;\n this._contactsStartedThisFrame.length = 0;\n this._currentContacts.length = 0;\n }\n\n onActivate() {\n this._sharedData.addToBehaviorsList(this);\n\n this._contactsEndedThisFrame.length = 0;\n this._contactsStartedThisFrame.length = 0;\n this._currentContacts.length = 0;\n this.updateBodyFromObject();\n }\n\n onDestroy() {\n this._destroyedDuringFrameLogic = true;\n this.onDeActivate();\n }\n\n createShape(): Jolt.Shape {\n let width = this.owner3D.getWidth() * this._sharedData.worldInvScale;\n let height = this.owner3D.getHeight() * this._sharedData.worldInvScale;\n let depth = this.owner3D.getDepth() * this._sharedData.worldInvScale;\n if (this.shapeOrientation === 'X') {\n const swap = depth;\n depth = width;\n width = swap;\n } else if (this.shapeOrientation === 'Y') {\n const swap = depth;\n depth = height;\n height = swap;\n }\n\n const shapeScale = this.shapeScale * this._sharedData.worldInvScale;\n\n const shapeDimensionA = this.shapeDimensionA * shapeScale;\n const shapeDimensionB = this.shapeDimensionB * shapeScale;\n const shapeDimensionC = this.shapeDimensionC * shapeScale;\n\n const onePixel = this._sharedData.worldInvScale;\n\n let shapeSettings: Jolt.ConvexShapeSettings;\n /** This is fine only because no other Quat is used locally. */\n let quat: Jolt.Quat;\n if (this.shape === 'Box') {\n const boxWidth =\n shapeDimensionA > 0 ? shapeDimensionA : width > 0 ? width : onePixel;\n const boxHeight =\n shapeDimensionB > 0\n ? shapeDimensionB\n : height > 0\n ? height\n : onePixel;\n const boxDepth =\n shapeDimensionC > 0 ? shapeDimensionC : depth > 0 ? depth : onePixel;\n // The convex radius should not eat up the whole volume.\n const convexRadius = Math.min(\n onePixel,\n Math.min(boxWidth, boxHeight, boxDepth) / 4\n );\n shapeSettings = new Jolt.BoxShapeSettings(\n this.getVec3(boxWidth / 2, boxHeight / 2, boxDepth / 2),\n convexRadius\n );\n quat = this.getQuat(0, 0, 0, 1);\n this._shapeHalfDepth = boxDepth / 2;\n } else if (this.shape === 'Capsule') {\n const radius =\n shapeDimensionA > 0\n ? shapeDimensionA\n : width > 0\n ? Math.sqrt(width * height) / 2\n : onePixel;\n const capsuleDepth =\n shapeDimensionB > 0 ? shapeDimensionB : depth > 0 ? depth : onePixel;\n shapeSettings = new Jolt.CapsuleShapeSettings(\n Math.max(0, capsuleDepth / 2 - radius),\n radius\n );\n quat = this._getShapeOrientationQuat();\n this._shapeHalfDepth =\n this.shapeOrientation !== 'Z' ? radius : capsuleDepth / 2;\n } else if (this.shape === 'Cylinder') {\n const radius =\n shapeDimensionA > 0\n ? shapeDimensionA\n : width > 0\n ? Math.sqrt(width * height) / 2\n : onePixel;\n const cylinderDepth =\n shapeDimensionB > 0 ? shapeDimensionB : depth > 0 ? depth : onePixel;\n // The convex radius should not eat up the whole volume.\n const convexRadius = Math.min(\n onePixel,\n Math.min(cylinderDepth, radius) / 4\n );\n shapeSettings = new Jolt.CylinderShapeSettings(\n cylinderDepth / 2,\n radius,\n convexRadius\n );\n quat = this._getShapeOrientationQuat();\n this._shapeHalfDepth =\n this.shapeOrientation !== 'Z' ? radius : cylinderDepth / 2;\n } else {\n // Create a 'Sphere' by default.\n const radius =\n shapeDimensionA > 0\n ? shapeDimensionA\n : width > 0\n ? Math.pow(width * height * depth, 1 / 3) / 2\n : onePixel;\n shapeSettings = new Jolt.SphereShapeSettings(radius);\n quat = this.getQuat(0, 0, 0, 1);\n this._shapeHalfDepth = radius;\n }\n shapeSettings.mDensity = this.density;\n const rotatedShape = new Jolt.RotatedTranslatedShapeSettings(\n this.getVec3(0, 0, 0),\n quat,\n shapeSettings\n )\n .Create()\n .Get();\n\n Jolt.destroy(shapeSettings);\n return rotatedShape;\n }\n\n private _getShapeOrientationQuat(): Jolt.Quat {\n if (this.shapeOrientation === 'X') {\n // Top on X axis.\n return this.getQuat(0, 0, Math.sqrt(2) / 2, -Math.sqrt(2) / 2);\n } else if (this.shapeOrientation === 'Y') {\n // Top on Y axis.\n return this.getQuat(0, 0, 0, 1);\n } else {\n // Top on Z axis.\n return this.getQuat(Math.sqrt(2) / 2, 0, 0, Math.sqrt(2) / 2);\n }\n }\n\n private _recreateShape(): void {\n this.bodyUpdater.recreateShape();\n\n this._objectOldWidth = this.owner3D.getWidth();\n this._objectOldHeight = this.owner3D.getHeight();\n this._objectOldDepth = this.owner3D.getDepth();\n }\n\n getShapeScale(): float {\n return this.shapeScale;\n }\n\n setShapeScale(shapeScale: float): void {\n if (shapeScale !== this.shapeScale && shapeScale > 0) {\n this.shapeScale = shapeScale;\n this._needToRecreateShape = true;\n }\n }\n\n getBody(): Jolt.Body {\n if (this._body === null) {\n this._createBody();\n }\n return this._body!;\n }\n\n _createBody(): boolean {\n this._needToRecreateBody = false;\n this._needToRecreateShape = false;\n\n if (!this.activated() || this._destroyedDuringFrameLogic) return false;\n\n this._body = this.bodyUpdater.createAndAddBody();\n this._body.gdjsAssociatedBehavior = this;\n\n this._objectOldWidth = this.owner3D.getWidth();\n this._objectOldHeight = this.owner3D.getHeight();\n this._objectOldDepth = this.owner3D.getDepth();\n return true;\n }\n\n /**\n * @returns The body layer id according to the behavior configuration.\n */\n getBodyLayer(): number {\n return Jolt.ObjectLayerPairFilterMask.prototype.sGetObjectLayer(\n this.getLayersAccordingToBodyType(),\n this.getMasksAccordingToBodyType()\n );\n }\n\n private getLayersAccordingToBodyType(): integer {\n // Make sure objects don't register in the wrong layer group.\n return this.isStatic()\n ? this.layers & gdjs.Physics3DSharedData.staticLayersMask\n : this.layers & gdjs.Physics3DSharedData.dynamicLayersMask;\n }\n\n private getMasksAccordingToBodyType(): integer {\n // Static objects accept all collisions as it's the mask of dynamic objects that matters.\n return this.isStatic()\n ? gdjs.Physics3DSharedData.allLayersMask\n : this.masks;\n }\n\n doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n // Step the world if not done this frame yet.\n // Don't step at the first frame to allow events to handle overlapping objects.\n if (\n !this._sharedData.stepped &&\n !instanceContainer.getScene().getTimeManager().isFirstFrame()\n ) {\n this._sharedData.step(\n instanceContainer.getScene().getTimeManager().getElapsedTime() /\n 1000.0\n );\n }\n }\n\n doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n // Reset world step to update next frame\n this._sharedData.stepped = false;\n }\n\n onObjectHotReloaded() {\n this.updateBodyFromObject();\n }\n\n recreateBody() {\n if (!this._body) {\n this._createBody();\n return;\n }\n\n const bodyInterface = this._sharedData.bodyInterface;\n const linearVelocity = this._body.GetLinearVelocity();\n const linearVelocityX = linearVelocity.GetX();\n const linearVelocityY = linearVelocity.GetY();\n const linearVelocityZ = linearVelocity.GetZ();\n const angularVelocity = this._body.GetAngularVelocity();\n const angularVelocityX = angularVelocity.GetX();\n const angularVelocityY = angularVelocity.GetY();\n const angularVelocityZ = angularVelocity.GetZ();\n\n let bodyID = this._body.GetID();\n bodyInterface.RemoveBody(bodyID);\n bodyInterface.DestroyBody(bodyID);\n this._contactsEndedThisFrame.length = 0;\n this._contactsStartedThisFrame.length = 0;\n this._currentContacts.length = 0;\n\n this._createBody();\n if (!this._body) {\n return;\n }\n bodyID = this._body.GetID();\n bodyInterface.SetLinearVelocity(\n bodyID,\n this.getVec3(linearVelocityX, linearVelocityY, linearVelocityZ)\n );\n bodyInterface.SetAngularVelocity(\n bodyID,\n this.getVec3(angularVelocityX, angularVelocityY, angularVelocityZ)\n );\n }\n\n updateObjectFromBody() {\n this.bodyUpdater.updateObjectFromBody();\n\n // Update cached transform.\n this._objectOldX = this.owner3D.getX();\n this._objectOldY = this.owner3D.getY();\n this._objectOldZ = this.owner3D.getZ();\n this._objectOldRotationX = this.owner3D.getRotationX();\n this._objectOldRotationY = this.owner3D.getRotationY();\n this._objectOldRotationZ = this.owner3D.getAngle();\n }\n\n updateBodyFromObject() {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n\n if (this._needToRecreateBody) {\n this.recreateBody();\n }\n\n // The object size has changed, recreate the shape.\n // The width has changed and there is no custom dimension A (box: width, circle: radius, edge: length) or\n // The height has changed, the shape is not an edge (edges doesn't have height),\n // it isn't a box with custom height or a circle with custom radius\n if (\n this._needToRecreateShape ||\n (!this.hasCustomShapeDimension() &&\n (this._objectOldWidth !== this.owner3D.getWidth() ||\n this._objectOldHeight !== this.owner3D.getHeight() ||\n this._objectOldDepth !== this.owner3D.getDepth()))\n ) {\n this._needToRecreateShape = false;\n this._recreateShape();\n }\n\n this.bodyUpdater.updateBodyFromObject();\n }\n\n hasCustomShapeDimension() {\n return (\n this.shapeDimensionA > 0 ||\n this.shapeDimensionB > 0 ||\n this.shapeDimensionC > 0\n );\n }\n\n getPhysicsPosition(result: Jolt.RVec3): Jolt.RVec3 {\n result.Set(\n this.owner3D.getCenterXInScene() * this._sharedData.worldInvScale,\n this.owner3D.getCenterYInScene() * this._sharedData.worldInvScale,\n this.owner3D.getCenterZInScene() * this._sharedData.worldInvScale\n );\n return result;\n }\n\n getPhysicsRotation(result: Jolt.Quat): Jolt.Quat {\n const threeObject = this.owner3D.get3DRendererObject();\n result.Set(\n threeObject.quaternion.x,\n threeObject.quaternion.y,\n threeObject.quaternion.z,\n threeObject.quaternion.w\n );\n return result;\n }\n\n moveObjectToPhysicsPosition(physicsPosition: Jolt.RVec3): void {\n this.owner3D.setCenterXInScene(\n physicsPosition.GetX() * this._sharedData.worldScale\n );\n this.owner3D.setCenterYInScene(\n physicsPosition.GetY() * this._sharedData.worldScale\n );\n this.owner3D.setCenterZInScene(\n physicsPosition.GetZ() * this._sharedData.worldScale\n );\n }\n\n moveObjectToPhysicsRotation(physicsRotation: Jolt.Quat): void {\n const threeObject = this.owner3D.get3DRendererObject();\n threeObject.quaternion.x = physicsRotation.GetX();\n threeObject.quaternion.y = physicsRotation.GetY();\n threeObject.quaternion.z = physicsRotation.GetZ();\n threeObject.quaternion.w = physicsRotation.GetW();\n // TODO Avoid this instantiation\n const euler = new THREE.Euler(0, 0, 0, 'ZYX');\n euler.setFromQuaternion(threeObject.quaternion);\n this.owner3D.setRotationX(gdjs.toDegrees(euler.x));\n this.owner3D.setRotationY(gdjs.toDegrees(euler.y));\n this.owner3D.setAngle(gdjs.toDegrees(euler.z));\n }\n\n getWorldScale(): float {\n return this._sharedData.worldScale;\n }\n\n getGravityX(): float {\n return this._sharedData.gravityX;\n }\n\n getGravityY(): float {\n return this._sharedData.gravityY;\n }\n\n getGravityZ(): float {\n return this._sharedData.gravityZ;\n }\n\n setGravityX(gravityX: float): void {\n if (this._sharedData.gravityX === gravityX) {\n return;\n }\n\n this._sharedData.gravityX = gravityX;\n this._sharedData.physicsSystem.SetGravity(\n this.getVec3(\n this._sharedData.gravityX,\n this._sharedData.gravityY,\n this._sharedData.gravityZ\n )\n );\n }\n\n setGravityY(gravityY: float): void {\n if (this._sharedData.gravityX === gravityY) {\n return;\n }\n\n this._sharedData.gravityX = gravityY;\n this._sharedData.physicsSystem.SetGravity(\n this.getVec3(\n this._sharedData.gravityX,\n this._sharedData.gravityY,\n this._sharedData.gravityZ\n )\n );\n }\n\n setGravityZ(gravityZ: float): void {\n if (this._sharedData.gravityX === gravityZ) {\n return;\n }\n\n this._sharedData.gravityZ = gravityZ;\n this._sharedData.physicsSystem.SetGravity(\n this.getVec3(\n this._sharedData.gravityX,\n this._sharedData.gravityY,\n this._sharedData.gravityZ\n )\n );\n }\n\n isDynamic(): boolean {\n return this.bodyType === 'Dynamic';\n }\n\n isStatic(): boolean {\n return this.bodyType === 'Static';\n }\n\n isKinematic(): boolean {\n return this.bodyType === 'Kinematic';\n }\n\n isBullet(): boolean {\n return this.bullet;\n }\n\n setBullet(enable: boolean): void {\n if (this.bullet === enable) {\n return;\n }\n this.bullet = enable;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetMotionQuality(\n body.GetID(),\n this.bullet\n ? Jolt.EMotionQuality_LinearCast\n : Jolt.EMotionQuality_Discrete\n );\n }\n\n hasFixedRotation(): boolean {\n return this.fixedRotation;\n }\n\n setFixedRotation(enable: boolean): void {\n if (this.fixedRotation === enable) {\n return;\n }\n this.fixedRotation = enable;\n this._needToRecreateBody = true;\n }\n\n getDensity() {\n return this.density;\n }\n\n setDensity(density: float): void {\n // Non-negative values only\n if (density < 0) {\n density = 0;\n }\n if (this.density === density) {\n return;\n }\n this.density = density;\n this._needToRecreateShape = true;\n }\n\n getFriction(): float {\n return this.friction;\n }\n\n setFriction(friction: float): void {\n // Non-negative values only\n if (friction < 0) {\n friction = 0;\n }\n if (this.friction === friction) {\n return;\n }\n this.friction = friction;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetFriction(body.GetID(), friction);\n }\n\n getRestitution(): float {\n return this.restitution;\n }\n\n setRestitution(restitution: float): void {\n // Non-negative values only\n if (restitution < 0) {\n restitution = 0;\n }\n if (this.restitution === restitution) {\n return;\n }\n this.restitution = restitution;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetRestitution(body.GetID(), restitution);\n }\n\n getLinearDamping(): float {\n return this.linearDamping;\n }\n\n setLinearDamping(linearDamping: float): void {\n // Non-negative values only\n if (linearDamping < 0) {\n linearDamping = 0;\n }\n if (this.linearDamping === linearDamping) {\n return;\n }\n this.linearDamping = linearDamping;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n body.GetMotionProperties().SetLinearDamping(linearDamping);\n }\n\n getAngularDamping(): float {\n return this.angularDamping;\n }\n\n setAngularDamping(angularDamping: float): void {\n // Non-negative values only\n if (angularDamping < 0) {\n angularDamping = 0;\n }\n if (this.angularDamping === angularDamping) {\n return;\n }\n this.angularDamping = angularDamping;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n body.GetMotionProperties().SetAngularDamping(angularDamping);\n }\n\n getGravityScale(): float {\n return this.gravityScale;\n }\n\n setGravityScale(gravityScale: float): void {\n if (this.gravityScale === gravityScale) {\n return;\n }\n this.gravityScale = gravityScale;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n body.GetMotionProperties().SetGravityFactor(gravityScale);\n }\n\n layerEnabled(layer: integer): boolean {\n // Layer must be an integer\n layer = Math.floor(layer);\n if (layer < 1 || layer > 8) {\n return false;\n }\n return !!(this.layers & (1 << (layer - 1)));\n }\n\n enableLayer(layer: integer, enable: boolean): void {\n // Layer must be an integer\n layer = Math.floor(layer);\n if (layer < 1 || layer > 8) {\n return;\n }\n\n if (enable) {\n this.layers |= 1 << (layer - 1);\n } else {\n this.layers &= ~(1 << (layer - 1));\n }\n\n this._needToRecreateBody = true;\n }\n\n maskEnabled(mask: integer): boolean {\n // Mask must be an integer\n mask = Math.floor(mask);\n if (mask < 1 || mask > 16) {\n return false;\n }\n return !!(this.masks & (1 << (mask - 1)));\n }\n\n enableMask(mask: integer, enable: boolean): void {\n // Mask must be an integer\n mask = Math.floor(mask);\n if (mask < 1 || mask > 16) {\n return;\n }\n\n if (enable) {\n this.masks |= 1 << (mask - 1);\n } else {\n this.masks &= ~(1 << (mask - 1));\n }\n\n this._needToRecreateBody = true;\n }\n\n getLinearVelocityX(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return body.GetLinearVelocity().GetX() * this._sharedData.worldScale;\n }\n\n setLinearVelocityX(linearVelocityX: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetLinearVelocity(\n body.GetID(),\n this.getVec3(\n linearVelocityX * this._sharedData.worldInvScale,\n body.GetLinearVelocity().GetY(),\n body.GetLinearVelocity().GetZ()\n )\n );\n }\n\n getLinearVelocityY(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return body.GetLinearVelocity().GetY() * this._sharedData.worldScale;\n }\n\n setLinearVelocityY(linearVelocityY: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetLinearVelocity(\n body.GetID(),\n this.getVec3(\n body.GetLinearVelocity().GetX(),\n linearVelocityY * this._sharedData.worldInvScale,\n body.GetLinearVelocity().GetZ()\n )\n );\n }\n\n getLinearVelocityZ(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return body.GetLinearVelocity().GetZ() * this._sharedData.worldScale;\n }\n\n setLinearVelocityZ(linearVelocityZ: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetLinearVelocity(\n body.GetID(),\n this.getVec3(\n body.GetLinearVelocity().GetX(),\n body.GetLinearVelocity().GetY(),\n linearVelocityZ * this._sharedData.worldInvScale\n )\n );\n }\n\n getLinearVelocityLength(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return body.GetLinearVelocity().Length() * this._sharedData.worldScale;\n }\n\n getAngularVelocityX(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return gdjs.toDegrees(body.GetAngularVelocity().GetX());\n }\n\n setAngularVelocityX(angularVelocityX: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetAngularVelocity(\n body.GetID(),\n this.getVec3(\n gdjs.toRad(angularVelocityX),\n body.GetAngularVelocity().GetY(),\n body.GetAngularVelocity().GetZ()\n )\n );\n }\n\n getAngularVelocityY(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return gdjs.toDegrees(body.GetAngularVelocity().GetY());\n }\n\n setAngularVelocityY(angularVelocityY: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetAngularVelocity(\n body.GetID(),\n this.getVec3(\n body.GetAngularVelocity().GetX(),\n gdjs.toRad(angularVelocityY),\n body.GetAngularVelocity().GetZ()\n )\n );\n }\n\n getAngularVelocityZ(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return gdjs.toDegrees(body.GetAngularVelocity().GetZ());\n }\n\n setAngularVelocityZ(angularVelocityZ: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetAngularVelocity(\n body.GetID(),\n this.getVec3(\n body.GetAngularVelocity().GetX(),\n body.GetAngularVelocity().GetY(),\n gdjs.toRad(angularVelocityZ)\n )\n );\n }\n\n applyForce(\n forceX: float,\n forceY: float,\n forceZ: float,\n positionX: float,\n positionY: float,\n positionZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddForce(\n body.GetID(),\n this.getVec3(forceX, forceY, forceZ),\n this.getRVec3(\n positionX * this._sharedData.worldInvScale,\n positionY * this._sharedData.worldInvScale,\n positionZ * this._sharedData.worldInvScale\n ),\n Jolt.EActivation_Activate\n );\n }\n\n applyForceAtCenter(forceX: float, forceY: float, forceZ: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddForce(\n body.GetID(),\n this.getVec3(forceX, forceY, forceZ),\n Jolt.EActivation_Activate\n );\n }\n\n applyForceTowardPosition(\n length: float,\n towardX: float,\n towardY: float,\n towardZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n const deltaX = towardX - body.GetPosition().GetX();\n const deltaY = towardY - body.GetPosition().GetY();\n const deltaZ = towardZ - body.GetPosition().GetZ();\n const distance = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;\n if (distance === 0) {\n return;\n }\n const ratio = length / distance;\n\n this._sharedData.bodyInterface.AddForce(\n body.GetID(),\n this.getVec3(deltaX * ratio, deltaY * ratio, deltaZ * ratio),\n Jolt.EActivation_Activate\n );\n }\n\n applyImpulse(\n impulseX: float,\n impulseY: float,\n impulseZ: float,\n positionX: float,\n positionY: float,\n positionZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddImpulse(\n body.GetID(),\n this.getVec3(impulseX, impulseY, impulseZ),\n this.getRVec3(\n positionX * this._sharedData.worldInvScale,\n positionY * this._sharedData.worldInvScale,\n positionZ * this._sharedData.worldInvScale\n )\n );\n }\n\n applyImpulseAtCenter(\n impulseX: float,\n impulseY: float,\n impulseZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddImpulse(\n body.GetID(),\n this.getVec3(impulseX, impulseY, impulseZ)\n );\n }\n\n applyImpulseTowardPosition(\n length: float,\n towardX: float,\n towardY: float,\n towardZ: float,\n originX: float,\n originY: float,\n originZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n const deltaX = towardX - originX;\n const deltaY = towardY - originY;\n const deltaZ = towardZ - originZ;\n const distance = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;\n if (distance === 0) {\n return;\n }\n const ratio = length / distance;\n\n this._sharedData.bodyInterface.AddImpulse(\n body.GetID(),\n this.getVec3(deltaX * ratio, deltaY * ratio, deltaZ * ratio),\n this.getRVec3(\n originX * this._sharedData.worldInvScale,\n originY * this._sharedData.worldInvScale,\n originZ * this._sharedData.worldInvScale\n )\n );\n }\n\n applyTorque(torqueX: float, torqueY: float, torqueZ: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddTorque(\n body.GetID(),\n this.getVec3(\n gdjs.toRad(torqueX),\n gdjs.toRad(torqueY),\n gdjs.toRad(torqueZ)\n ),\n Jolt.EActivation_Activate\n );\n }\n\n applyAngularImpulse(\n angularImpulseX: float,\n angularImpulseY: float,\n angularImpulseZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddAngularImpulse(\n body.GetID(),\n this.getVec3(\n gdjs.toRad(angularImpulseX),\n gdjs.toRad(angularImpulseY),\n gdjs.toRad(angularImpulseZ)\n )\n );\n }\n\n getMass(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return 1 / body.GetMotionProperties().GetInverseMass();\n }\n\n /**\n * @returns The inertia for a rotation around X axis of the object at its\n * default rotation (0\u00B0; 0\u00B0; 0\u00B0).\n */\n getInertiaAroundX(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return 1 / body.GetMotionProperties().GetInverseInertiaDiagonal().GetX();\n }\n\n /**\n * @returns The inertia for a rotation around Y axis of the object at its\n * default rotation (0\u00B0; 0\u00B0; 0\u00B0).\n */\n getInertiaAroundY(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return 1 / body.GetMotionProperties().GetInverseInertiaDiagonal().GetY();\n }\n\n /**\n * @returns The inertia for a rotation around Z axis of the object at its\n * default rotation (0\u00B0; 0\u00B0; 0\u00B0).\n */\n getInertiaAroundZ(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return 1 / body.GetMotionProperties().GetInverseInertiaDiagonal().GetZ();\n }\n\n getMassCenterX(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return (\n body.GetCenterOfMassPosition().GetX() * this._sharedData.worldScale\n );\n }\n\n getMassCenterY(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return (\n body.GetCenterOfMassPosition().GetY() * this._sharedData.worldScale\n );\n }\n\n getMassCenterZ(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return (\n body.GetCenterOfMassPosition().GetZ() * this._sharedData.worldScale\n );\n }\n\n onContactBegin(otherBehavior: Physics3DRuntimeBehavior): void {\n this._currentContacts.push(otherBehavior);\n\n // There might be contacts that end during the frame and\n // start again right away. It is considered a glitch\n // and should not be detected.\n let i = this._contactsEndedThisFrame.indexOf(otherBehavior);\n if (i !== -1) {\n this._contactsEndedThisFrame.splice(i, 1);\n } else {\n this._contactsStartedThisFrame.push(otherBehavior);\n }\n }\n\n onContactEnd(otherBehavior: Physics3DRuntimeBehavior): void {\n this._contactsEndedThisFrame.push(otherBehavior);\n\n const index = this._currentContacts.indexOf(otherBehavior);\n if (index !== -1) {\n this._currentContacts.splice(index, 1);\n }\n }\n\n canCollideAgainst(otherBehavior: gdjs.Physics3DRuntimeBehavior): boolean {\n return (\n (this.getMasksAccordingToBodyType() &\n otherBehavior.getLayersAccordingToBodyType()) !==\n 0\n );\n }\n\n static areObjectsColliding(\n object1: gdjs.RuntimeObject,\n object2: gdjs.RuntimeObject,\n behaviorName: string\n ): boolean {\n const behavior1 = object1.getBehavior(\n behaviorName\n ) as Physics3DRuntimeBehavior | null;\n if (!behavior1) return false;\n return behavior1.collisionChecker.isColliding(object2);\n }\n\n static hasCollisionStartedBetween(\n object1: gdjs.RuntimeObject,\n object2: gdjs.RuntimeObject,\n behaviorName: string\n ): boolean {\n const behavior1 = object1.getBehavior(\n behaviorName\n ) as Physics3DRuntimeBehavior | null;\n if (!behavior1) return false;\n return behavior1.collisionChecker.hasCollisionStartedWith(object2);\n }\n\n static hasCollisionStoppedBetween(\n object1: gdjs.RuntimeObject,\n object2: gdjs.RuntimeObject,\n behaviorName: string\n ): boolean {\n const behavior1 = object1.getBehavior(\n behaviorName\n ) as Physics3DRuntimeBehavior | null;\n if (!behavior1) return false;\n return behavior1.collisionChecker.hasCollisionStoppedWith(object2);\n }\n }\n\n gdjs.registerBehavior(\n 'Physics3D::Physics3DBehavior',\n gdjs.Physics3DRuntimeBehavior\n );\n\n export namespace Physics3DRuntimeBehavior {\n /**\n * Allow extensions relying on the 3D physics to customize its\n * behavior a bit.\n */\n export interface Physics3DHook {\n /**\n * Called before the physics engine step.\n */\n doBeforePhysicsStep(timeDelta: float): void;\n }\n\n export interface BodyUpdater {\n createAndAddBody(): Jolt.Body;\n updateObjectFromBody(): void;\n updateBodyFromObject(): void;\n recreateShape(): void;\n }\n\n export class DefaultBodyUpdater {\n behavior: gdjs.Physics3DRuntimeBehavior;\n\n constructor(behavior: gdjs.Physics3DRuntimeBehavior) {\n this.behavior = behavior;\n }\n\n createAndAddBody(): Jolt.Body {\n const { behavior } = this;\n const { _sharedData } = behavior;\n\n const shape = behavior.createShape();\n const bodyCreationSettings = new Jolt.BodyCreationSettings(\n shape,\n behavior.getPhysicsPosition(_sharedData.getRVec3(0, 0, 0)),\n behavior.getPhysicsRotation(_sharedData.getQuat(0, 0, 0, 1)),\n behavior.bodyType === 'Static'\n ? Jolt.EMotionType_Static\n : behavior.bodyType === 'Kinematic'\n ? Jolt.EMotionType_Kinematic\n : Jolt.EMotionType_Dynamic,\n behavior.getBodyLayer()\n );\n bodyCreationSettings.mMotionQuality = behavior.bullet\n ? Jolt.EMotionQuality_LinearCast\n : Jolt.EMotionQuality_Discrete;\n bodyCreationSettings.mAllowedDOFs = behavior.fixedRotation\n ? Jolt.EAllowedDOFs_TranslationX |\n Jolt.EAllowedDOFs_TranslationY |\n Jolt.EAllowedDOFs_TranslationZ\n : Jolt.EAllowedDOFs_All;\n bodyCreationSettings.mFriction = behavior.friction;\n bodyCreationSettings.mRestitution = behavior.restitution;\n bodyCreationSettings.mLinearDamping = behavior.linearDamping;\n bodyCreationSettings.mAngularDamping = behavior.angularDamping;\n bodyCreationSettings.mGravityFactor = behavior.gravityScale;\n\n const bodyInterface = _sharedData.bodyInterface;\n const body = bodyInterface.CreateBody(bodyCreationSettings);\n Jolt.destroy(bodyCreationSettings);\n\n bodyInterface.AddBody(body.GetID(), Jolt.EActivation_Activate);\n return body;\n }\n\n updateObjectFromBody() {\n const { behavior } = this;\n const { _body } = behavior;\n // Copy transform from body to the GD object.\n // The body is null when the behavior was either deactivated or the object deleted.\n // It would be useless to try to recreate it as updateBodyFromObject already does it.\n // If the body is null, we just don't do anything\n // (but still run the physics simulation - this is independent).\n if (_body !== null && _body.IsActive()) {\n behavior.moveObjectToPhysicsPosition(_body.GetPosition());\n behavior.moveObjectToPhysicsRotation(_body.GetRotation());\n }\n }\n\n updateBodyFromObject() {\n const { behavior } = this;\n const { owner3D, _sharedData } = behavior;\n if (behavior._body === null) {\n if (!behavior._createBody()) return;\n }\n const body = behavior._body!;\n\n if (\n this.behavior._objectOldX !== owner3D.getX() ||\n this.behavior._objectOldY !== owner3D.getY() ||\n this.behavior._objectOldZ !== owner3D.getZ() ||\n this.behavior._objectOldRotationX !== owner3D.getRotationX() ||\n this.behavior._objectOldRotationY !== owner3D.getRotationY() ||\n this.behavior._objectOldRotationZ !== owner3D.getAngle()\n ) {\n _sharedData.bodyInterface.SetPositionAndRotationWhenChanged(\n body.GetID(),\n this.behavior.getPhysicsPosition(_sharedData.getRVec3(0, 0, 0)),\n this.behavior.getPhysicsRotation(_sharedData.getQuat(0, 0, 0, 1)),\n Jolt.EActivation_Activate\n );\n }\n }\n\n recreateShape() {\n const { behavior } = this;\n const { _sharedData } = behavior;\n if (behavior._body === null) {\n if (!behavior._createBody()) return;\n }\n const body = behavior._body!;\n\n const bodyInterface = _sharedData.bodyInterface;\n bodyInterface.SetShape(\n body.GetID(),\n behavior.createShape(),\n true,\n Jolt.EActivation_Activate\n );\n }\n }\n\n export interface CollisionChecker {\n isColliding(object: gdjs.RuntimeObject): boolean;\n hasCollisionStartedWith(object: gdjs.RuntimeObject): boolean;\n hasCollisionStoppedWith(object: gdjs.RuntimeObject): boolean;\n }\n\n /**\n * The default collision checker uses the contacts found while\n * stepping the physics simulation. For characters, another one is used\n * as characters are simulated before the rest of the physics simulation.\n */\n export class DefaultCollisionChecker implements CollisionChecker {\n behavior: gdjs.Physics3DRuntimeBehavior;\n\n constructor(behavior: gdjs.Physics3DRuntimeBehavior) {\n this.behavior = behavior;\n }\n\n isColliding(object: gdjs.RuntimeObject): boolean {\n if (\n this.behavior._currentContacts.some(\n (behavior) => behavior.owner === object\n )\n ) {\n return true;\n }\n return this.behavior._contactsStartedThisFrame.some(\n (behavior) => behavior.owner === object\n );\n }\n\n hasCollisionStartedWith(object: gdjs.RuntimeObject): boolean {\n return this.behavior._contactsStartedThisFrame.some(\n (behavior) => behavior.owner === object\n );\n }\n\n hasCollisionStoppedWith(object: gdjs.RuntimeObject): boolean {\n return this.behavior._contactsEndedThisFrame.some(\n (behavior) => behavior.owner === object\n );\n }\n }\n }\n}\n"],
5
- "mappings": "AAQA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAW,SAAY,CAC3B,GAAI,CAEF,KAAM,GAAwB,AADf,MAAM,QAAO,2BACS,QACrC,GAAI,CAAC,EACH,KAAM,IAAI,OAAM,oCAGlB,KAAM,GAAO,KAAM,KACnB,OAAO,KAAO,QACP,EAAP,CACA,cAAQ,MAAM,uCAAwC,GAChD,IAGV,EAAK,4CAA4C,KA4B1C,OAA0B,CA6B/B,YAAY,EAAkD,EAAY,CAhB1E,eAAY,GAAI,MAAK,KACrB,gBAAa,GAAI,MAAK,MACtB,eAAY,GAAI,MAAK,KAErB,aAAmB,GAQX,qBAEJ,GAGF,KAAK,qBAAuB,GAAI,KAChC,KAAK,SAAW,EAAW,SAC3B,KAAK,SAAW,EAAW,SAC3B,KAAK,SAAW,EAAW,SAC3B,KAAK,WAAa,EAAW,WAC7B,KAAK,cAAgB,EAAI,KAAK,WAG9B,KAAM,GAAW,GAAI,MAAK,aAC1B,EAAK,oBAAoB,wBAAwB,GACjD,KAAK,KAAO,GAAI,MAAK,cAAc,GACnC,KAAK,QAAQ,GACb,KAAK,cAAgB,KAAK,KAAK,mBAC/B,KAAK,cAAc,WACjB,KAAK,QAAQ,KAAK,SAAU,KAAK,SAAU,KAAK,WAElD,KAAK,c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AAS,QAAU,GAG5B,GAEF,KAAK,SAAS,0BAA0B,KAC7C,AAAC,GAAa,EAAS,QAAU,GAIrC,wBAAwB,EAAqC,CAC3D,MAAO,MAAK,SAAS,0BAA0B,KAC7C,AAAC,GAAa,EAAS,QAAU,GAIrC,wBAAwB,EAAqC,CAC3D,MAAO,MAAK,SAAS,wBAAwB,KAC3C,AAAC,GAAa,EAAS,QAAU,IA5BhC,EAAM,2BApIE,iEA/sDT",
4
+ "sourcesContent": ["/// <reference path=\"./jolt-physics.d.ts\" />\n\nnamespace Jolt {\n export interface Body {\n gdjsAssociatedBehavior: gdjs.Physics3DRuntimeBehavior | null;\n }\n}\n\nnamespace gdjs {\n const loadJolt = async () => {\n try {\n const module = await import('./jolt-physics.wasm.js');\n const initializeJoltPhysics = module.default;\n if (!initializeJoltPhysics) {\n throw new Error('No default export found in Jolt.');\n }\n\n const Jolt = await initializeJoltPhysics();\n window.Jolt = Jolt;\n } catch (err) {\n console.error('Unable to load Jolt physics library.', err);\n throw err;\n }\n };\n gdjs.registerAsynchronouslyLoadingLibraryPromise(loadJolt());\n\n export interface RuntimeScene {\n physics3DSharedData: gdjs.Physics3DSharedData | null;\n }\n interface Physics3DNetworkSyncDataType {\n px: number | undefined;\n py: number | undefined;\n pz: number | undefined;\n rx: number | undefined;\n ry: number | undefined;\n rz: number | undefined;\n rw: number | undefined;\n lvx: number | undefined;\n lvy: number | undefined;\n lvz: number | undefined;\n avx: number | undefined;\n avy: number | undefined;\n avz: number | undefined;\n aw: boolean | undefined;\n layers: number;\n masks: number;\n }\n\n export interface Physics3DNetworkSyncData extends BehaviorNetworkSyncData {\n props: Physics3DNetworkSyncDataType;\n }\n\n export class Physics3DSharedData {\n gravityX: float;\n gravityY: float;\n gravityZ: float;\n worldScale: float;\n worldInvScale: float;\n\n jolt: Jolt.JoltInterface;\n physicsSystem: Jolt.PhysicsSystem;\n bodyInterface: Jolt.BodyInterface;\n /** Contact listener to keep track of current collisions */\n contactListener: Jolt.ContactListenerJS;\n /** Avoid creating new vectors all the time */\n _tempVec3 = new Jolt.Vec3();\n _tempRVec3 = new Jolt.RVec3();\n _tempQuat = new Jolt.Quat();\n\n stepped: boolean = false;\n /**\n * List of physics behavior in the runtimeScene. It should be updated\n * when a new physics object is created (constructor), on destruction (onDestroy),\n * on behavior activation (onActivate) and on behavior deactivation (onDeActivate).\n */\n _registeredBehaviors: Set<Physics3DRuntimeBehavior>;\n\n private _physics3DHooks: Array<\n gdjs.Physics3DRuntimeBehavior.Physics3DHook\n > = [];\n\n constructor(instanceContainer: gdjs.RuntimeInstanceContainer, sharedData) {\n this._registeredBehaviors = new Set<Physics3DRuntimeBehavior>();\n this.gravityX = sharedData.gravityX;\n this.gravityY = sharedData.gravityY;\n this.gravityZ = sharedData.gravityZ;\n this.worldScale = sharedData.worldScale;\n this.worldInvScale = 1 / this.worldScale;\n\n // Initialize Jolt\n const settings = new Jolt.JoltSettings();\n gdjs.Physics3DSharedData.setupCollisionFiltering(settings);\n this.jolt = new Jolt.JoltInterface(settings);\n Jolt.destroy(settings);\n this.physicsSystem = this.jolt.GetPhysicsSystem();\n this.physicsSystem.SetGravity(\n this.getVec3(this.gravityX, this.gravityY, this.gravityZ)\n );\n this.bodyInterface = this.physicsSystem.GetBodyInterface();\n\n this.contactListener = new Jolt.ContactListenerJS();\n this.physicsSystem.SetContactListener(this.contactListener);\n this.contactListener.OnContactAdded = (\n bodyPtrA: number,\n bodyPtrB: number,\n manifoldPtr: number,\n settingsPtr: number\n ): void => {\n const bodyA = Jolt.wrapPointer(bodyPtrA, Jolt.Body);\n const bodyB = Jolt.wrapPointer(bodyPtrB, Jolt.Body);\n\n const behaviorA = bodyA.gdjsAssociatedBehavior;\n const behaviorB = bodyB.gdjsAssociatedBehavior;\n if (!behaviorA || !behaviorB) {\n return;\n }\n\n behaviorA.onContactBegin(behaviorB);\n behaviorB.onContactBegin(behaviorA);\n };\n this.contactListener.OnContactRemoved = (\n subShapePairPtr: number\n ): void => {\n const subShapePair = Jolt.wrapPointer(\n subShapePairPtr,\n Jolt.SubShapeIDPair\n );\n\n // This is ok because bodies are not deleted during the Physics step.\n const bodyLockInterface = this.physicsSystem.GetBodyLockInterface();\n const bodyA = bodyLockInterface.TryGetBody(subShapePair.GetBody1ID());\n const bodyB = bodyLockInterface.TryGetBody(subShapePair.GetBody2ID());\n\n const behaviorA = bodyA.gdjsAssociatedBehavior;\n const behaviorB = bodyB.gdjsAssociatedBehavior;\n if (!behaviorA || !behaviorB) {\n return;\n }\n\n behaviorA.onContactEnd(behaviorB);\n behaviorB.onContactEnd(behaviorA);\n };\n this.contactListener.OnContactPersisted = (\n bodyPtrA: number,\n bodyPtrB: number,\n manifoldPtr: number,\n settingsPtr: number\n ): void => {\n // TODO we could rely on this event.\n };\n this.contactListener.OnContactValidate = (\n bodyPtrA: number,\n bodyPtrB: number,\n inBaseOffset: number,\n inCollisionResult: number\n ): number => {\n return Jolt.ValidateResult_AcceptAllContactsForThisBodyPair;\n };\n }\n\n getVec3(x: float, y: float, z: float): Jolt.Vec3 {\n const tempVec3 = this._tempVec3;\n tempVec3.Set(x, y, z);\n return tempVec3;\n }\n\n getRVec3(x: float, y: float, z: float): Jolt.RVec3 {\n const tempRVec3 = this._tempRVec3;\n tempRVec3.Set(x, y, z);\n return tempRVec3;\n }\n\n getQuat(x: float, y: float, z: float, w: float): Jolt.Quat {\n const tempQuat = this._tempQuat;\n tempQuat.Set(x, y, z, w);\n return tempQuat;\n }\n\n static getSharedData(\n runtimeScene: gdjs.RuntimeScene,\n behaviorName: string\n ): gdjs.Physics3DSharedData {\n if (!runtimeScene.physics3DSharedData) {\n const initialData = runtimeScene.getInitialSharedDataForBehavior(\n behaviorName\n );\n runtimeScene.physics3DSharedData = new gdjs.Physics3DSharedData(\n runtimeScene,\n initialData\n );\n }\n return runtimeScene.physics3DSharedData;\n }\n\n // There are 4 bits for static layers and 4 bits for dynamic layers.\n static readonly staticLayersMask = 0x0f;\n static readonly dynamicLayersMask = 0xf0;\n static readonly allLayersMask = 0xff;\n static readonly staticBroadPhaseLayerIndex = 1;\n static readonly dynamicBroadPhaseLayerIndex = 1;\n\n private static setupCollisionFiltering(settings: Jolt.JoltSettings): void {\n const objectFilter = new Jolt.ObjectLayerPairFilterMask();\n const staticBroadPhaseLayer = new Jolt.BroadPhaseLayer(\n gdjs.Physics3DSharedData.staticBroadPhaseLayerIndex\n );\n const dynamicBroadPhaseLayer = new Jolt.BroadPhaseLayer(\n gdjs.Physics3DSharedData.dynamicBroadPhaseLayerIndex\n );\n const broadPhaseLayerInterfaceMask = new Jolt.BroadPhaseLayerInterfaceMask(\n 2\n );\n broadPhaseLayerInterfaceMask.ConfigureLayer(\n staticBroadPhaseLayer,\n gdjs.Physics3DSharedData.staticLayersMask,\n 0\n );\n broadPhaseLayerInterfaceMask.ConfigureLayer(\n dynamicBroadPhaseLayer,\n gdjs.Physics3DSharedData.dynamicLayersMask,\n 0\n );\n // BroadPhaseLayer have been copied into bpInterface\n Jolt.destroy(staticBroadPhaseLayer);\n Jolt.destroy(dynamicBroadPhaseLayer);\n\n settings.mObjectLayerPairFilter = objectFilter;\n settings.mBroadPhaseLayerInterface = broadPhaseLayerInterfaceMask;\n settings.mObjectVsBroadPhaseLayerFilter = new Jolt.ObjectVsBroadPhaseLayerFilterMask(\n broadPhaseLayerInterfaceMask\n );\n }\n\n /**\n * Add a physics object to the list of existing object.\n */\n addToBehaviorsList(physicsBehavior: gdjs.Physics3DRuntimeBehavior): void {\n this._registeredBehaviors.add(physicsBehavior);\n }\n\n /**\n * Remove a physics object to the list of existing object.\n */\n removeFromBehaviorsList(\n physicsBehavior: gdjs.Physics3DRuntimeBehavior\n ): void {\n this._registeredBehaviors.delete(physicsBehavior);\n }\n\n step(deltaTime: float): void {\n for (const physicsBehavior of this._registeredBehaviors) {\n physicsBehavior._contactsStartedThisFrame.length = 0;\n physicsBehavior._contactsEndedThisFrame.length = 0;\n }\n for (const physicsBehavior of this._registeredBehaviors) {\n physicsBehavior.updateBodyFromObject();\n }\n for (const physics3DHook of this._physics3DHooks) {\n physics3DHook.doBeforePhysicsStep(deltaTime);\n }\n\n const numSteps = deltaTime > 1.0 / 55.0 ? 2 : 1;\n this.jolt.Step(deltaTime, numSteps);\n this.stepped = true;\n\n // It's important that updateBodyFromObject and updateObjectFromBody are\n // called at the same time because other behavior may move the object in\n // their doStepPreEvents.\n for (const physicsBehavior of this._registeredBehaviors) {\n physicsBehavior.updateObjectFromBody();\n }\n }\n\n /**\n * A hook must typically be registered by a behavior that requires this one\n * in its onCreate function.\n * The hook must stay forever to avoid side effects like a hooks order\n * change. To handle deactivated behavior, the hook can check that its\n * behavior is activated before doing anything.\n */\n registerHook(hook: gdjs.Physics3DRuntimeBehavior.Physics3DHook) {\n this._physics3DHooks.push(hook);\n }\n }\n gdjs.registerRuntimeSceneUnloadedCallback(function (runtimeScene) {\n const physics3DSharedData = runtimeScene.physics3DSharedData;\n if (physics3DSharedData) {\n Jolt.destroy(physics3DSharedData.jolt);\n Jolt.destroy(physics3DSharedData.contactListener);\n Jolt.destroy(physics3DSharedData._tempVec3);\n Jolt.destroy(physics3DSharedData._tempRVec3);\n Jolt.destroy(physics3DSharedData._tempQuat);\n runtimeScene.physics3DSharedData = null;\n }\n });\n\n export class Physics3DRuntimeBehavior extends gdjs.RuntimeBehavior {\n bodyUpdater: gdjs.Physics3DRuntimeBehavior.BodyUpdater;\n collisionChecker: gdjs.Physics3DRuntimeBehavior.CollisionChecker;\n owner3D: gdjs.RuntimeObject3D;\n\n bodyType: string;\n bullet: boolean;\n fixedRotation: boolean;\n private shape: string;\n private shapeOrientation: string;\n private shapeDimensionA: any;\n private shapeDimensionB: any;\n private shapeDimensionC: any;\n private density: float;\n friction: float;\n restitution: float;\n linearDamping: float;\n angularDamping: float;\n gravityScale: float;\n private layers: integer;\n private masks: integer;\n private shapeScale: number = 1;\n\n /**\n * Array containing the beginning of contacts reported by onContactBegin. Each contact\n * should be unique to avoid recording glitches where the object loses and regain\n * contact between two frames. The array is updated each time the method\n * onContactBegin is called by the listener, which is only called when stepping\n * the world i.e. in the first preEvent called by a physics behavior. This array is\n * cleared just before stepping the world.\n */\n _contactsStartedThisFrame: Array<Physics3DRuntimeBehavior> = [];\n\n /**\n * Array containing the end of contacts reported by onContactEnd. The array is updated\n * each time the method onContactEnd is called by the listener, which can be called at\n * any time. This array is cleared just before stepping the world.\n */\n _contactsEndedThisFrame: Array<Physics3DRuntimeBehavior> = [];\n\n /**\n * Array containing the exact current contacts with the objects. It is updated\n * each time the methods onContactBegin and onContactEnd are called by the contact\n * listener.\n */\n _currentContacts: Array<Physics3DRuntimeBehavior> = [];\n\n private _destroyedDuringFrameLogic: boolean = false;\n _body: Jolt.Body | null = null;\n /**\n * When set to `true` the body will be recreated before the next physics step.\n */\n private _needToRecreateBody: boolean = false;\n /**\n * When set to `true` the shape will be recreated before the next physics step.\n */\n private _needToRecreateShape: boolean = false;\n /**\n * Used by {@link gdjs.PhysicsCharacter3DRuntimeBehavior} to convert coordinates.\n */\n _shapeHalfDepth: float = 0;\n\n /**\n * sharedData is a reference to the shared data of the scene, that registers\n * every physics behavior that is created so that collisions can be cleared\n * before stepping the world.\n */\n _sharedData: Physics3DSharedData;\n\n _objectOldX: float = 0;\n _objectOldY: float = 0;\n _objectOldZ: float = 0;\n _objectOldRotationX: float = 0;\n _objectOldRotationY: float = 0;\n _objectOldRotationZ: float = 0;\n _objectOldWidth: float = 0;\n _objectOldHeight: float = 0;\n _objectOldDepth: float = 0;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData,\n owner: gdjs.RuntimeObject3D\n ) {\n super(instanceContainer, behaviorData, owner);\n this.bodyUpdater = new gdjs.Physics3DRuntimeBehavior.DefaultBodyUpdater(\n this\n );\n this.collisionChecker = new gdjs.Physics3DRuntimeBehavior.DefaultCollisionChecker(\n this\n );\n this.owner3D = owner;\n this.bodyType = behaviorData.bodyType;\n this.bullet = behaviorData.bullet;\n this.fixedRotation = behaviorData.fixedRotation;\n this.shape = behaviorData.shape;\n this.shapeOrientation = behaviorData.shapeOrientation;\n this.shapeDimensionA = behaviorData.shapeDimensionA;\n this.shapeDimensionB = behaviorData.shapeDimensionB;\n this.shapeDimensionC = behaviorData.shapeDimensionC;\n this.density = behaviorData.density;\n this.friction = behaviorData.friction;\n this.restitution = behaviorData.restitution;\n this.linearDamping = Math.max(0, behaviorData.linearDamping);\n this.angularDamping = Math.max(0, behaviorData.angularDamping);\n this.gravityScale = behaviorData.gravityScale;\n this.layers = behaviorData.layers;\n this.masks = behaviorData.masks;\n this._sharedData = Physics3DSharedData.getSharedData(\n instanceContainer.getScene(),\n behaviorData.name\n );\n this._sharedData.addToBehaviorsList(this);\n }\n\n private getVec3(x: float, y: float, z: float): Jolt.Vec3 {\n const tempVec3 = this._sharedData._tempVec3;\n tempVec3.Set(x, y, z);\n return tempVec3;\n }\n\n private getRVec3(x: float, y: float, z: float): Jolt.RVec3 {\n const tempRVec3 = this._sharedData._tempRVec3;\n tempRVec3.Set(x, y, z);\n return tempRVec3;\n }\n\n private getQuat(x: float, y: float, z: float, w: float): Jolt.Quat {\n const tempQuat = this._sharedData._tempQuat;\n tempQuat.Set(x, y, z, w);\n return tempQuat;\n }\n\n updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {\n if (oldBehaviorData.bullet !== newBehaviorData.bullet) {\n this.setBullet(newBehaviorData.bullet);\n }\n if (oldBehaviorData.fixedRotation !== newBehaviorData.fixedRotation) {\n this.setFixedRotation(newBehaviorData.fixedRotation);\n }\n if (oldBehaviorData.shapeDimensionA !== newBehaviorData.shapeDimensionA) {\n this.shapeDimensionA = newBehaviorData.shapeDimensionA;\n this._needToRecreateShape = true;\n }\n if (oldBehaviorData.shapeDimensionB !== newBehaviorData.shapeDimensionB) {\n this.shapeDimensionB = newBehaviorData.shapeDimensionB;\n this._needToRecreateShape = true;\n }\n if (oldBehaviorData.density !== newBehaviorData.density) {\n this.setDensity(newBehaviorData.density);\n }\n if (oldBehaviorData.friction !== newBehaviorData.friction) {\n this.setFriction(newBehaviorData.friction);\n }\n if (oldBehaviorData.restitution !== newBehaviorData.restitution) {\n this.setRestitution(newBehaviorData.restitution);\n }\n if (oldBehaviorData.linearDamping !== newBehaviorData.linearDamping) {\n this.setLinearDamping(newBehaviorData.linearDamping);\n }\n if (oldBehaviorData.angularDamping !== newBehaviorData.angularDamping) {\n this.setAngularDamping(newBehaviorData.angularDamping);\n }\n if (oldBehaviorData.gravityScale !== newBehaviorData.gravityScale) {\n this.setGravityScale(newBehaviorData.gravityScale);\n }\n\n // TODO: make these properties updatable.\n if (oldBehaviorData.layers !== newBehaviorData.layers) {\n return false;\n }\n if (oldBehaviorData.masks !== newBehaviorData.masks) {\n return false;\n }\n if (oldBehaviorData.vertices !== newBehaviorData.vertices) {\n return false;\n }\n if (oldBehaviorData.bodyType !== newBehaviorData.bodyType) {\n return false;\n }\n if (oldBehaviorData.shape !== newBehaviorData.shape) {\n return false;\n }\n return true;\n }\n\n getNetworkSyncData(): Physics3DNetworkSyncData {\n let bodyProps;\n if (this._body) {\n const position = this._body.GetPosition();\n const rotation = this._body.GetRotation();\n const linearVelocity = this._body.GetLinearVelocity();\n const angularVelocity = this._body.GetAngularVelocity();\n bodyProps = {\n px: position.GetX(),\n py: position.GetY(),\n pz: position.GetZ(),\n rx: rotation.GetX(),\n ry: rotation.GetY(),\n rz: rotation.GetZ(),\n rw: rotation.GetW(),\n lvx: linearVelocity.GetX(),\n lvy: linearVelocity.GetY(),\n lvz: linearVelocity.GetZ(),\n avx: angularVelocity.GetX(),\n avy: angularVelocity.GetY(),\n avz: angularVelocity.GetZ(),\n aw: this._body.IsActive(),\n };\n } else {\n bodyProps = {\n px: undefined,\n py: undefined,\n pz: undefined,\n rx: undefined,\n ry: undefined,\n rz: undefined,\n rw: undefined,\n lvx: undefined,\n lvy: undefined,\n lvz: undefined,\n avx: undefined,\n avy: undefined,\n avz: undefined,\n aw: undefined,\n };\n }\n return {\n ...super.getNetworkSyncData(),\n props: {\n ...bodyProps,\n layers: this.layers,\n masks: this.masks,\n },\n };\n }\n\n updateFromNetworkSyncData(networkSyncData: Physics3DNetworkSyncData) {\n super.updateFromNetworkSyncData(networkSyncData);\n\n const behaviorSpecificProps = networkSyncData.props;\n if (\n behaviorSpecificProps.px !== undefined &&\n behaviorSpecificProps.py !== undefined &&\n behaviorSpecificProps.pz !== undefined\n ) {\n if (this._body) {\n this._sharedData.bodyInterface.SetPosition(\n this._body.GetID(),\n this.getRVec3(\n behaviorSpecificProps.px,\n behaviorSpecificProps.py,\n behaviorSpecificProps.pz\n ),\n Jolt.EActivation_DontActivate\n );\n }\n }\n if (\n behaviorSpecificProps.rx !== undefined &&\n behaviorSpecificProps.ry !== undefined &&\n behaviorSpecificProps.rz !== undefined &&\n behaviorSpecificProps.rw !== undefined\n ) {\n if (this._body) {\n this._sharedData.bodyInterface.SetRotation(\n this._body.GetID(),\n this.getQuat(\n behaviorSpecificProps.rx,\n behaviorSpecificProps.ry,\n behaviorSpecificProps.rz,\n behaviorSpecificProps.rw\n ),\n Jolt.EActivation_DontActivate\n );\n }\n }\n if (\n behaviorSpecificProps.lvx !== undefined &&\n behaviorSpecificProps.lvy !== undefined &&\n behaviorSpecificProps.lvz !== undefined\n ) {\n if (this._body) {\n this._sharedData.bodyInterface.SetLinearVelocity(\n this._body.GetID(),\n this.getVec3(\n behaviorSpecificProps.lvx,\n behaviorSpecificProps.lvy,\n behaviorSpecificProps.lvz\n )\n );\n }\n }\n if (\n behaviorSpecificProps.avx !== undefined &&\n behaviorSpecificProps.avy !== undefined &&\n behaviorSpecificProps.avz !== undefined\n ) {\n if (this._body) {\n this._sharedData.bodyInterface.SetAngularVelocity(\n this._body.GetID(),\n this.getVec3(\n behaviorSpecificProps.avx,\n behaviorSpecificProps.avy,\n behaviorSpecificProps.avz\n )\n );\n }\n }\n if (behaviorSpecificProps.layers !== undefined) {\n this.layers = behaviorSpecificProps.layers;\n }\n if (behaviorSpecificProps.masks !== undefined) {\n this.masks = behaviorSpecificProps.masks;\n }\n }\n\n onDeActivate() {\n this._sharedData.removeFromBehaviorsList(this);\n this.bodyUpdater.destroyBody();\n this._contactsEndedThisFrame.length = 0;\n this._contactsStartedThisFrame.length = 0;\n this._currentContacts.length = 0;\n }\n\n onActivate() {\n this._sharedData.addToBehaviorsList(this);\n\n this._contactsEndedThisFrame.length = 0;\n this._contactsStartedThisFrame.length = 0;\n this._currentContacts.length = 0;\n this.updateBodyFromObject();\n }\n\n onDestroy() {\n this._destroyedDuringFrameLogic = true;\n this.onDeActivate();\n }\n\n createShape(): Jolt.Shape {\n let width = this.owner3D.getWidth() * this._sharedData.worldInvScale;\n let height = this.owner3D.getHeight() * this._sharedData.worldInvScale;\n let depth = this.owner3D.getDepth() * this._sharedData.worldInvScale;\n if (this.shapeOrientation === 'X') {\n const swap = depth;\n depth = width;\n width = swap;\n } else if (this.shapeOrientation === 'Y') {\n const swap = depth;\n depth = height;\n height = swap;\n }\n\n const shapeScale = this.shapeScale * this._sharedData.worldInvScale;\n\n const shapeDimensionA = this.shapeDimensionA * shapeScale;\n const shapeDimensionB = this.shapeDimensionB * shapeScale;\n const shapeDimensionC = this.shapeDimensionC * shapeScale;\n\n const onePixel = this._sharedData.worldInvScale;\n\n let shapeSettings: Jolt.ConvexShapeSettings;\n /** This is fine only because no other Quat is used locally. */\n let quat: Jolt.Quat;\n if (this.shape === 'Box') {\n const boxWidth =\n shapeDimensionA > 0 ? shapeDimensionA : width > 0 ? width : onePixel;\n const boxHeight =\n shapeDimensionB > 0\n ? shapeDimensionB\n : height > 0\n ? height\n : onePixel;\n const boxDepth =\n shapeDimensionC > 0 ? shapeDimensionC : depth > 0 ? depth : onePixel;\n // The convex radius should not eat up the whole volume.\n const convexRadius = Math.min(\n onePixel,\n Math.min(boxWidth, boxHeight, boxDepth) / 4\n );\n shapeSettings = new Jolt.BoxShapeSettings(\n this.getVec3(boxWidth / 2, boxHeight / 2, boxDepth / 2),\n convexRadius\n );\n quat = this.getQuat(0, 0, 0, 1);\n this._shapeHalfDepth = boxDepth / 2;\n } else if (this.shape === 'Capsule') {\n const radius =\n shapeDimensionA > 0\n ? shapeDimensionA\n : width > 0\n ? Math.sqrt(width * height) / 2\n : onePixel;\n const capsuleDepth =\n shapeDimensionB > 0 ? shapeDimensionB : depth > 0 ? depth : onePixel;\n shapeSettings = new Jolt.CapsuleShapeSettings(\n Math.max(0, capsuleDepth / 2 - radius),\n radius\n );\n quat = this._getShapeOrientationQuat();\n this._shapeHalfDepth =\n this.shapeOrientation !== 'Z' ? radius : capsuleDepth / 2;\n } else if (this.shape === 'Cylinder') {\n const radius =\n shapeDimensionA > 0\n ? shapeDimensionA\n : width > 0\n ? Math.sqrt(width * height) / 2\n : onePixel;\n const cylinderDepth =\n shapeDimensionB > 0 ? shapeDimensionB : depth > 0 ? depth : onePixel;\n // The convex radius should not eat up the whole volume.\n const convexRadius = Math.min(\n onePixel,\n Math.min(cylinderDepth, radius) / 4\n );\n shapeSettings = new Jolt.CylinderShapeSettings(\n cylinderDepth / 2,\n radius,\n convexRadius\n );\n quat = this._getShapeOrientationQuat();\n this._shapeHalfDepth =\n this.shapeOrientation !== 'Z' ? radius : cylinderDepth / 2;\n } else {\n // Create a 'Sphere' by default.\n const radius =\n shapeDimensionA > 0\n ? shapeDimensionA\n : width > 0\n ? Math.pow(width * height * depth, 1 / 3) / 2\n : onePixel;\n shapeSettings = new Jolt.SphereShapeSettings(radius);\n quat = this.getQuat(0, 0, 0, 1);\n this._shapeHalfDepth = radius;\n }\n shapeSettings.mDensity = this.density;\n const rotatedShape = new Jolt.RotatedTranslatedShapeSettings(\n this.getVec3(0, 0, 0),\n quat,\n shapeSettings\n )\n .Create()\n .Get();\n\n Jolt.destroy(shapeSettings);\n return rotatedShape;\n }\n\n private _getShapeOrientationQuat(): Jolt.Quat {\n if (this.shapeOrientation === 'X') {\n // Top on X axis.\n return this.getQuat(0, 0, Math.sqrt(2) / 2, -Math.sqrt(2) / 2);\n } else if (this.shapeOrientation === 'Y') {\n // Top on Y axis.\n return this.getQuat(0, 0, 0, 1);\n } else {\n // Top on Z axis.\n return this.getQuat(Math.sqrt(2) / 2, 0, 0, Math.sqrt(2) / 2);\n }\n }\n\n private _recreateShape(): void {\n this.bodyUpdater.recreateShape();\n\n this._objectOldWidth = this.owner3D.getWidth();\n this._objectOldHeight = this.owner3D.getHeight();\n this._objectOldDepth = this.owner3D.getDepth();\n }\n\n getShapeScale(): float {\n return this.shapeScale;\n }\n\n setShapeScale(shapeScale: float): void {\n if (shapeScale !== this.shapeScale && shapeScale > 0) {\n this.shapeScale = shapeScale;\n this._needToRecreateShape = true;\n }\n }\n\n getBody(): Jolt.Body {\n if (this._body === null) {\n this._createBody();\n }\n return this._body!;\n }\n\n _createBody(): boolean {\n this._needToRecreateBody = false;\n this._needToRecreateShape = false;\n\n if (!this.activated() || this._destroyedDuringFrameLogic) return false;\n\n this._body = this.bodyUpdater.createAndAddBody();\n if (!this._body) {\n // It can only happen when the character behavior is destroyed.\n return false;\n }\n this._body.gdjsAssociatedBehavior = this;\n\n this._objectOldWidth = this.owner3D.getWidth();\n this._objectOldHeight = this.owner3D.getHeight();\n this._objectOldDepth = this.owner3D.getDepth();\n return true;\n }\n\n /**\n * @returns The body layer id according to the behavior configuration.\n */\n getBodyLayer(): number {\n return Jolt.ObjectLayerPairFilterMask.prototype.sGetObjectLayer(\n this.getLayersAccordingToBodyType(),\n this.getMasksAccordingToBodyType()\n );\n }\n\n private getLayersAccordingToBodyType(): integer {\n // Make sure objects don't register in the wrong layer group.\n return this.isStatic()\n ? this.layers & gdjs.Physics3DSharedData.staticLayersMask\n : this.layers & gdjs.Physics3DSharedData.dynamicLayersMask;\n }\n\n private getMasksAccordingToBodyType(): integer {\n // Static objects accept all collisions as it's the mask of dynamic objects that matters.\n return this.isStatic()\n ? gdjs.Physics3DSharedData.allLayersMask\n : this.masks;\n }\n\n doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n // Step the world if not done this frame yet.\n // Don't step at the first frame to allow events to handle overlapping objects.\n if (\n !this._sharedData.stepped &&\n !instanceContainer.getScene().getTimeManager().isFirstFrame()\n ) {\n this._sharedData.step(\n instanceContainer.getScene().getTimeManager().getElapsedTime() /\n 1000.0\n );\n }\n }\n\n doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n // Reset world step to update next frame\n this._sharedData.stepped = false;\n }\n\n onObjectHotReloaded() {\n this.updateBodyFromObject();\n }\n\n recreateBody() {\n if (!this._body) {\n this._createBody();\n return;\n }\n\n const bodyInterface = this._sharedData.bodyInterface;\n const linearVelocity = this._body.GetLinearVelocity();\n const linearVelocityX = linearVelocity.GetX();\n const linearVelocityY = linearVelocity.GetY();\n const linearVelocityZ = linearVelocity.GetZ();\n const angularVelocity = this._body.GetAngularVelocity();\n const angularVelocityX = angularVelocity.GetX();\n const angularVelocityY = angularVelocity.GetY();\n const angularVelocityZ = angularVelocity.GetZ();\n\n let bodyID = this._body.GetID();\n bodyInterface.RemoveBody(bodyID);\n bodyInterface.DestroyBody(bodyID);\n this._contactsEndedThisFrame.length = 0;\n this._contactsStartedThisFrame.length = 0;\n this._currentContacts.length = 0;\n\n this._createBody();\n if (!this._body) {\n return;\n }\n bodyID = this._body.GetID();\n bodyInterface.SetLinearVelocity(\n bodyID,\n this.getVec3(linearVelocityX, linearVelocityY, linearVelocityZ)\n );\n bodyInterface.SetAngularVelocity(\n bodyID,\n this.getVec3(angularVelocityX, angularVelocityY, angularVelocityZ)\n );\n }\n\n updateObjectFromBody() {\n this.bodyUpdater.updateObjectFromBody();\n\n // Update cached transform.\n this._objectOldX = this.owner3D.getX();\n this._objectOldY = this.owner3D.getY();\n this._objectOldZ = this.owner3D.getZ();\n this._objectOldRotationX = this.owner3D.getRotationX();\n this._objectOldRotationY = this.owner3D.getRotationY();\n this._objectOldRotationZ = this.owner3D.getAngle();\n }\n\n updateBodyFromObject() {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n\n if (this._needToRecreateBody) {\n this.recreateBody();\n }\n\n // The object size has changed, recreate the shape.\n // The width has changed and there is no custom dimension A (box: width, circle: radius, edge: length) or\n // The height has changed, the shape is not an edge (edges doesn't have height),\n // it isn't a box with custom height or a circle with custom radius\n if (\n this._needToRecreateShape ||\n (!this.hasCustomShapeDimension() &&\n (this._objectOldWidth !== this.owner3D.getWidth() ||\n this._objectOldHeight !== this.owner3D.getHeight() ||\n this._objectOldDepth !== this.owner3D.getDepth()))\n ) {\n this._needToRecreateShape = false;\n this._recreateShape();\n }\n\n this.bodyUpdater.updateBodyFromObject();\n }\n\n hasCustomShapeDimension() {\n return (\n this.shapeDimensionA > 0 ||\n this.shapeDimensionB > 0 ||\n this.shapeDimensionC > 0\n );\n }\n\n getPhysicsPosition(result: Jolt.RVec3): Jolt.RVec3 {\n result.Set(\n this.owner3D.getCenterXInScene() * this._sharedData.worldInvScale,\n this.owner3D.getCenterYInScene() * this._sharedData.worldInvScale,\n this.owner3D.getCenterZInScene() * this._sharedData.worldInvScale\n );\n return result;\n }\n\n getPhysicsRotation(result: Jolt.Quat): Jolt.Quat {\n const threeObject = this.owner3D.get3DRendererObject();\n result.Set(\n threeObject.quaternion.x,\n threeObject.quaternion.y,\n threeObject.quaternion.z,\n threeObject.quaternion.w\n );\n return result;\n }\n\n moveObjectToPhysicsPosition(physicsPosition: Jolt.RVec3): void {\n this.owner3D.setCenterXInScene(\n physicsPosition.GetX() * this._sharedData.worldScale\n );\n this.owner3D.setCenterYInScene(\n physicsPosition.GetY() * this._sharedData.worldScale\n );\n this.owner3D.setCenterZInScene(\n physicsPosition.GetZ() * this._sharedData.worldScale\n );\n }\n\n moveObjectToPhysicsRotation(physicsRotation: Jolt.Quat): void {\n const threeObject = this.owner3D.get3DRendererObject();\n threeObject.quaternion.x = physicsRotation.GetX();\n threeObject.quaternion.y = physicsRotation.GetY();\n threeObject.quaternion.z = physicsRotation.GetZ();\n threeObject.quaternion.w = physicsRotation.GetW();\n // TODO Avoid this instantiation\n const euler = new THREE.Euler(0, 0, 0, 'ZYX');\n euler.setFromQuaternion(threeObject.quaternion);\n this.owner3D.setRotationX(gdjs.toDegrees(euler.x));\n this.owner3D.setRotationY(gdjs.toDegrees(euler.y));\n this.owner3D.setAngle(gdjs.toDegrees(euler.z));\n }\n\n getWorldScale(): float {\n return this._sharedData.worldScale;\n }\n\n getGravityX(): float {\n return this._sharedData.gravityX;\n }\n\n getGravityY(): float {\n return this._sharedData.gravityY;\n }\n\n getGravityZ(): float {\n return this._sharedData.gravityZ;\n }\n\n setGravityX(gravityX: float): void {\n if (this._sharedData.gravityX === gravityX) {\n return;\n }\n\n this._sharedData.gravityX = gravityX;\n this._sharedData.physicsSystem.SetGravity(\n this.getVec3(\n this._sharedData.gravityX,\n this._sharedData.gravityY,\n this._sharedData.gravityZ\n )\n );\n }\n\n setGravityY(gravityY: float): void {\n if (this._sharedData.gravityX === gravityY) {\n return;\n }\n\n this._sharedData.gravityX = gravityY;\n this._sharedData.physicsSystem.SetGravity(\n this.getVec3(\n this._sharedData.gravityX,\n this._sharedData.gravityY,\n this._sharedData.gravityZ\n )\n );\n }\n\n setGravityZ(gravityZ: float): void {\n if (this._sharedData.gravityX === gravityZ) {\n return;\n }\n\n this._sharedData.gravityZ = gravityZ;\n this._sharedData.physicsSystem.SetGravity(\n this.getVec3(\n this._sharedData.gravityX,\n this._sharedData.gravityY,\n this._sharedData.gravityZ\n )\n );\n }\n\n isDynamic(): boolean {\n return this.bodyType === 'Dynamic';\n }\n\n isStatic(): boolean {\n return this.bodyType === 'Static';\n }\n\n isKinematic(): boolean {\n return this.bodyType === 'Kinematic';\n }\n\n isBullet(): boolean {\n return this.bullet;\n }\n\n setBullet(enable: boolean): void {\n if (this.bullet === enable) {\n return;\n }\n this.bullet = enable;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetMotionQuality(\n body.GetID(),\n this.bullet\n ? Jolt.EMotionQuality_LinearCast\n : Jolt.EMotionQuality_Discrete\n );\n }\n\n hasFixedRotation(): boolean {\n return this.fixedRotation;\n }\n\n setFixedRotation(enable: boolean): void {\n if (this.fixedRotation === enable) {\n return;\n }\n this.fixedRotation = enable;\n this._needToRecreateBody = true;\n }\n\n getDensity() {\n return this.density;\n }\n\n setDensity(density: float): void {\n // Non-negative values only\n if (density < 0) {\n density = 0;\n }\n if (this.density === density) {\n return;\n }\n this.density = density;\n this._needToRecreateShape = true;\n }\n\n getFriction(): float {\n return this.friction;\n }\n\n setFriction(friction: float): void {\n // Non-negative values only\n if (friction < 0) {\n friction = 0;\n }\n if (this.friction === friction) {\n return;\n }\n this.friction = friction;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetFriction(body.GetID(), friction);\n }\n\n getRestitution(): float {\n return this.restitution;\n }\n\n setRestitution(restitution: float): void {\n // Non-negative values only\n if (restitution < 0) {\n restitution = 0;\n }\n if (this.restitution === restitution) {\n return;\n }\n this.restitution = restitution;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetRestitution(body.GetID(), restitution);\n }\n\n getLinearDamping(): float {\n return this.linearDamping;\n }\n\n setLinearDamping(linearDamping: float): void {\n // Non-negative values only\n if (linearDamping < 0) {\n linearDamping = 0;\n }\n if (this.linearDamping === linearDamping) {\n return;\n }\n this.linearDamping = linearDamping;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n body.GetMotionProperties().SetLinearDamping(linearDamping);\n }\n\n getAngularDamping(): float {\n return this.angularDamping;\n }\n\n setAngularDamping(angularDamping: float): void {\n // Non-negative values only\n if (angularDamping < 0) {\n angularDamping = 0;\n }\n if (this.angularDamping === angularDamping) {\n return;\n }\n this.angularDamping = angularDamping;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n body.GetMotionProperties().SetAngularDamping(angularDamping);\n }\n\n getGravityScale(): float {\n return this.gravityScale;\n }\n\n setGravityScale(gravityScale: float): void {\n if (this.gravityScale === gravityScale) {\n return;\n }\n this.gravityScale = gravityScale;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n body.GetMotionProperties().SetGravityFactor(gravityScale);\n }\n\n layerEnabled(layer: integer): boolean {\n // Layer must be an integer\n layer = Math.floor(layer);\n if (layer < 1 || layer > 8) {\n return false;\n }\n return !!(this.layers & (1 << (layer - 1)));\n }\n\n enableLayer(layer: integer, enable: boolean): void {\n // Layer must be an integer\n layer = Math.floor(layer);\n if (layer < 1 || layer > 8) {\n return;\n }\n\n if (enable) {\n this.layers |= 1 << (layer - 1);\n } else {\n this.layers &= ~(1 << (layer - 1));\n }\n\n this._needToRecreateBody = true;\n }\n\n maskEnabled(mask: integer): boolean {\n // Mask must be an integer\n mask = Math.floor(mask);\n if (mask < 1 || mask > 16) {\n return false;\n }\n return !!(this.masks & (1 << (mask - 1)));\n }\n\n enableMask(mask: integer, enable: boolean): void {\n // Mask must be an integer\n mask = Math.floor(mask);\n if (mask < 1 || mask > 16) {\n return;\n }\n\n if (enable) {\n this.masks |= 1 << (mask - 1);\n } else {\n this.masks &= ~(1 << (mask - 1));\n }\n\n this._needToRecreateBody = true;\n }\n\n getLinearVelocityX(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return body.GetLinearVelocity().GetX() * this._sharedData.worldScale;\n }\n\n setLinearVelocityX(linearVelocityX: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetLinearVelocity(\n body.GetID(),\n this.getVec3(\n linearVelocityX * this._sharedData.worldInvScale,\n body.GetLinearVelocity().GetY(),\n body.GetLinearVelocity().GetZ()\n )\n );\n }\n\n getLinearVelocityY(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return body.GetLinearVelocity().GetY() * this._sharedData.worldScale;\n }\n\n setLinearVelocityY(linearVelocityY: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetLinearVelocity(\n body.GetID(),\n this.getVec3(\n body.GetLinearVelocity().GetX(),\n linearVelocityY * this._sharedData.worldInvScale,\n body.GetLinearVelocity().GetZ()\n )\n );\n }\n\n getLinearVelocityZ(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return body.GetLinearVelocity().GetZ() * this._sharedData.worldScale;\n }\n\n setLinearVelocityZ(linearVelocityZ: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetLinearVelocity(\n body.GetID(),\n this.getVec3(\n body.GetLinearVelocity().GetX(),\n body.GetLinearVelocity().GetY(),\n linearVelocityZ * this._sharedData.worldInvScale\n )\n );\n }\n\n getLinearVelocityLength(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return body.GetLinearVelocity().Length() * this._sharedData.worldScale;\n }\n\n getAngularVelocityX(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return gdjs.toDegrees(body.GetAngularVelocity().GetX());\n }\n\n setAngularVelocityX(angularVelocityX: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetAngularVelocity(\n body.GetID(),\n this.getVec3(\n gdjs.toRad(angularVelocityX),\n body.GetAngularVelocity().GetY(),\n body.GetAngularVelocity().GetZ()\n )\n );\n }\n\n getAngularVelocityY(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return gdjs.toDegrees(body.GetAngularVelocity().GetY());\n }\n\n setAngularVelocityY(angularVelocityY: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetAngularVelocity(\n body.GetID(),\n this.getVec3(\n body.GetAngularVelocity().GetX(),\n gdjs.toRad(angularVelocityY),\n body.GetAngularVelocity().GetZ()\n )\n );\n }\n\n getAngularVelocityZ(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return gdjs.toDegrees(body.GetAngularVelocity().GetZ());\n }\n\n setAngularVelocityZ(angularVelocityZ: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetAngularVelocity(\n body.GetID(),\n this.getVec3(\n body.GetAngularVelocity().GetX(),\n body.GetAngularVelocity().GetY(),\n gdjs.toRad(angularVelocityZ)\n )\n );\n }\n\n applyForce(\n forceX: float,\n forceY: float,\n forceZ: float,\n positionX: float,\n positionY: float,\n positionZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddForce(\n body.GetID(),\n this.getVec3(forceX, forceY, forceZ),\n this.getRVec3(\n positionX * this._sharedData.worldInvScale,\n positionY * this._sharedData.worldInvScale,\n positionZ * this._sharedData.worldInvScale\n ),\n Jolt.EActivation_Activate\n );\n }\n\n applyForceAtCenter(forceX: float, forceY: float, forceZ: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddForce(\n body.GetID(),\n this.getVec3(forceX, forceY, forceZ),\n Jolt.EActivation_Activate\n );\n }\n\n applyForceTowardPosition(\n length: float,\n towardX: float,\n towardY: float,\n towardZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n const deltaX = towardX - body.GetPosition().GetX();\n const deltaY = towardY - body.GetPosition().GetY();\n const deltaZ = towardZ - body.GetPosition().GetZ();\n const distance = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;\n if (distance === 0) {\n return;\n }\n const ratio = length / distance;\n\n this._sharedData.bodyInterface.AddForce(\n body.GetID(),\n this.getVec3(deltaX * ratio, deltaY * ratio, deltaZ * ratio),\n Jolt.EActivation_Activate\n );\n }\n\n applyImpulse(\n impulseX: float,\n impulseY: float,\n impulseZ: float,\n positionX: float,\n positionY: float,\n positionZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddImpulse(\n body.GetID(),\n this.getVec3(impulseX, impulseY, impulseZ),\n this.getRVec3(\n positionX * this._sharedData.worldInvScale,\n positionY * this._sharedData.worldInvScale,\n positionZ * this._sharedData.worldInvScale\n )\n );\n }\n\n applyImpulseAtCenter(\n impulseX: float,\n impulseY: float,\n impulseZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddImpulse(\n body.GetID(),\n this.getVec3(impulseX, impulseY, impulseZ)\n );\n }\n\n applyImpulseTowardPosition(\n length: float,\n towardX: float,\n towardY: float,\n towardZ: float,\n originX: float,\n originY: float,\n originZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n const deltaX = towardX - originX;\n const deltaY = towardY - originY;\n const deltaZ = towardZ - originZ;\n const distance = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;\n if (distance === 0) {\n return;\n }\n const ratio = length / distance;\n\n this._sharedData.bodyInterface.AddImpulse(\n body.GetID(),\n this.getVec3(deltaX * ratio, deltaY * ratio, deltaZ * ratio),\n this.getRVec3(\n originX * this._sharedData.worldInvScale,\n originY * this._sharedData.worldInvScale,\n originZ * this._sharedData.worldInvScale\n )\n );\n }\n\n applyTorque(torqueX: float, torqueY: float, torqueZ: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddTorque(\n body.GetID(),\n this.getVec3(\n gdjs.toRad(torqueX),\n gdjs.toRad(torqueY),\n gdjs.toRad(torqueZ)\n ),\n Jolt.EActivation_Activate\n );\n }\n\n applyAngularImpulse(\n angularImpulseX: float,\n angularImpulseY: float,\n angularImpulseZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddAngularImpulse(\n body.GetID(),\n this.getVec3(\n gdjs.toRad(angularImpulseX),\n gdjs.toRad(angularImpulseY),\n gdjs.toRad(angularImpulseZ)\n )\n );\n }\n\n getMass(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return 1 / body.GetMotionProperties().GetInverseMass();\n }\n\n /**\n * @returns The inertia for a rotation around X axis of the object at its\n * default rotation (0\u00B0; 0\u00B0; 0\u00B0).\n */\n getInertiaAroundX(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return 1 / body.GetMotionProperties().GetInverseInertiaDiagonal().GetX();\n }\n\n /**\n * @returns The inertia for a rotation around Y axis of the object at its\n * default rotation (0\u00B0; 0\u00B0; 0\u00B0).\n */\n getInertiaAroundY(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return 1 / body.GetMotionProperties().GetInverseInertiaDiagonal().GetY();\n }\n\n /**\n * @returns The inertia for a rotation around Z axis of the object at its\n * default rotation (0\u00B0; 0\u00B0; 0\u00B0).\n */\n getInertiaAroundZ(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return 1 / body.GetMotionProperties().GetInverseInertiaDiagonal().GetZ();\n }\n\n getMassCenterX(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return (\n body.GetCenterOfMassPosition().GetX() * this._sharedData.worldScale\n );\n }\n\n getMassCenterY(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return (\n body.GetCenterOfMassPosition().GetY() * this._sharedData.worldScale\n );\n }\n\n getMassCenterZ(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return (\n body.GetCenterOfMassPosition().GetZ() * this._sharedData.worldScale\n );\n }\n\n onContactBegin(otherBehavior: Physics3DRuntimeBehavior): void {\n this._currentContacts.push(otherBehavior);\n\n // There might be contacts that end during the frame and\n // start again right away. It is considered a glitch\n // and should not be detected.\n let i = this._contactsEndedThisFrame.indexOf(otherBehavior);\n if (i !== -1) {\n this._contactsEndedThisFrame.splice(i, 1);\n } else {\n this._contactsStartedThisFrame.push(otherBehavior);\n }\n }\n\n onContactEnd(otherBehavior: Physics3DRuntimeBehavior): void {\n this._contactsEndedThisFrame.push(otherBehavior);\n\n const index = this._currentContacts.indexOf(otherBehavior);\n if (index !== -1) {\n this._currentContacts.splice(index, 1);\n }\n }\n\n canCollideAgainst(otherBehavior: gdjs.Physics3DRuntimeBehavior): boolean {\n return (\n (this.getMasksAccordingToBodyType() &\n otherBehavior.getLayersAccordingToBodyType()) !==\n 0\n );\n }\n\n static areObjectsColliding(\n object1: gdjs.RuntimeObject,\n object2: gdjs.RuntimeObject,\n behaviorName: string\n ): boolean {\n const behavior1 = object1.getBehavior(\n behaviorName\n ) as Physics3DRuntimeBehavior | null;\n if (!behavior1) return false;\n return behavior1.collisionChecker.isColliding(object2);\n }\n\n static hasCollisionStartedBetween(\n object1: gdjs.RuntimeObject,\n object2: gdjs.RuntimeObject,\n behaviorName: string\n ): boolean {\n const behavior1 = object1.getBehavior(\n behaviorName\n ) as Physics3DRuntimeBehavior | null;\n if (!behavior1) return false;\n return behavior1.collisionChecker.hasCollisionStartedWith(object2);\n }\n\n static hasCollisionStoppedBetween(\n object1: gdjs.RuntimeObject,\n object2: gdjs.RuntimeObject,\n behaviorName: string\n ): boolean {\n const behavior1 = object1.getBehavior(\n behaviorName\n ) as Physics3DRuntimeBehavior | null;\n if (!behavior1) return false;\n return behavior1.collisionChecker.hasCollisionStoppedWith(object2);\n }\n }\n\n gdjs.registerBehavior(\n 'Physics3D::Physics3DBehavior',\n gdjs.Physics3DRuntimeBehavior\n );\n\n export namespace Physics3DRuntimeBehavior {\n /**\n * Allow extensions relying on the 3D physics to customize its\n * behavior a bit.\n */\n export interface Physics3DHook {\n /**\n * Called before the physics engine step.\n */\n doBeforePhysicsStep(timeDelta: float): void;\n }\n\n export interface BodyUpdater {\n createAndAddBody(): Jolt.Body | null;\n updateObjectFromBody(): void;\n updateBodyFromObject(): void;\n recreateShape(): void;\n destroyBody(): void;\n }\n\n export class DefaultBodyUpdater {\n behavior: gdjs.Physics3DRuntimeBehavior;\n\n constructor(behavior: gdjs.Physics3DRuntimeBehavior) {\n this.behavior = behavior;\n }\n\n createAndAddBody(): Jolt.Body | null {\n const { behavior } = this;\n const { _sharedData } = behavior;\n\n const shape = behavior.createShape();\n const bodyCreationSettings = new Jolt.BodyCreationSettings(\n shape,\n behavior.getPhysicsPosition(_sharedData.getRVec3(0, 0, 0)),\n behavior.getPhysicsRotation(_sharedData.getQuat(0, 0, 0, 1)),\n behavior.bodyType === 'Static'\n ? Jolt.EMotionType_Static\n : behavior.bodyType === 'Kinematic'\n ? Jolt.EMotionType_Kinematic\n : Jolt.EMotionType_Dynamic,\n behavior.getBodyLayer()\n );\n bodyCreationSettings.mMotionQuality = behavior.bullet\n ? Jolt.EMotionQuality_LinearCast\n : Jolt.EMotionQuality_Discrete;\n bodyCreationSettings.mAllowedDOFs = behavior.fixedRotation\n ? Jolt.EAllowedDOFs_TranslationX |\n Jolt.EAllowedDOFs_TranslationY |\n Jolt.EAllowedDOFs_TranslationZ\n : Jolt.EAllowedDOFs_All;\n bodyCreationSettings.mFriction = behavior.friction;\n bodyCreationSettings.mRestitution = behavior.restitution;\n bodyCreationSettings.mLinearDamping = behavior.linearDamping;\n bodyCreationSettings.mAngularDamping = behavior.angularDamping;\n bodyCreationSettings.mGravityFactor = behavior.gravityScale;\n\n const bodyInterface = _sharedData.bodyInterface;\n const body = bodyInterface.CreateBody(bodyCreationSettings);\n Jolt.destroy(bodyCreationSettings);\n\n bodyInterface.AddBody(body.GetID(), Jolt.EActivation_Activate);\n return body;\n }\n\n updateObjectFromBody() {\n const { behavior } = this;\n const { _body } = behavior;\n // Copy transform from body to the GD object.\n // The body is null when the behavior was either deactivated or the object deleted.\n // It would be useless to try to recreate it as updateBodyFromObject already does it.\n // If the body is null, we just don't do anything\n // (but still run the physics simulation - this is independent).\n if (_body !== null && _body.IsActive()) {\n behavior.moveObjectToPhysicsPosition(_body.GetPosition());\n behavior.moveObjectToPhysicsRotation(_body.GetRotation());\n }\n }\n\n updateBodyFromObject() {\n const { behavior } = this;\n const { owner3D, _sharedData } = behavior;\n if (behavior._body === null) {\n if (!behavior._createBody()) return;\n }\n const body = behavior._body!;\n\n if (\n this.behavior._objectOldX !== owner3D.getX() ||\n this.behavior._objectOldY !== owner3D.getY() ||\n this.behavior._objectOldZ !== owner3D.getZ() ||\n this.behavior._objectOldRotationX !== owner3D.getRotationX() ||\n this.behavior._objectOldRotationY !== owner3D.getRotationY() ||\n this.behavior._objectOldRotationZ !== owner3D.getAngle()\n ) {\n _sharedData.bodyInterface.SetPositionAndRotationWhenChanged(\n body.GetID(),\n this.behavior.getPhysicsPosition(_sharedData.getRVec3(0, 0, 0)),\n this.behavior.getPhysicsRotation(_sharedData.getQuat(0, 0, 0, 1)),\n Jolt.EActivation_Activate\n );\n }\n }\n\n recreateShape() {\n const { behavior } = this;\n const { _sharedData } = behavior;\n if (behavior._body === null) {\n if (!behavior._createBody()) return;\n }\n const body = behavior._body!;\n\n const bodyInterface = _sharedData.bodyInterface;\n bodyInterface.SetShape(\n body.GetID(),\n behavior.createShape(),\n true,\n Jolt.EActivation_Activate\n );\n }\n\n destroyBody() {\n const { behavior } = this;\n const { _sharedData } = behavior;\n if (behavior._body !== null) {\n _sharedData.bodyInterface.RemoveBody(behavior._body.GetID());\n _sharedData.bodyInterface.DestroyBody(behavior._body.GetID());\n behavior._body = null;\n }\n }\n }\n\n export interface CollisionChecker {\n isColliding(object: gdjs.RuntimeObject): boolean;\n hasCollisionStartedWith(object: gdjs.RuntimeObject): boolean;\n hasCollisionStoppedWith(object: gdjs.RuntimeObject): boolean;\n }\n\n /**\n * The default collision checker uses the contacts found while\n * stepping the physics simulation. For characters, another one is used\n * as characters are simulated before the rest of the physics simulation.\n */\n export class DefaultCollisionChecker implements CollisionChecker {\n behavior: gdjs.Physics3DRuntimeBehavior;\n\n constructor(behavior: gdjs.Physics3DRuntimeBehavior) {\n this.behavior = behavior;\n }\n\n isColliding(object: gdjs.RuntimeObject): boolean {\n if (\n this.behavior._currentContacts.some(\n (behavior) => behavior.owner === object\n )\n ) {\n return true;\n }\n return this.behavior._contactsStartedThisFrame.some(\n (behavior) => behavior.owner === object\n );\n }\n\n hasCollisionStartedWith(object: gdjs.RuntimeObject): boolean {\n return this.behavior._contactsStartedThisFrame.some(\n (behavior) => behavior.owner === object\n );\n }\n\n hasCollisionStoppedWith(object: gdjs.RuntimeObject): boolean {\n return this.behavior._contactsEndedThisFrame.some(\n (behavior) => behavior.owner === object\n );\n }\n }\n }\n}\n"],
5
+ "mappings": "AAQA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAW,SAAY,CAC3B,GAAI,CAEF,KAAM,GAAwB,AADf,MAAM,QAAO,2BACS,QACrC,GAAI,CAAC,EACH,KAAM,IAAI,OAAM,oCAGlB,KAAM,GAAO,KAAM,KACnB,OAAO,KAAO,QACP,EAAP,CACA,cAAQ,MAAM,uCAAwC,GAChD,IAGV,EAAK,4CAA4C,KA4B1C,OAA0B,CA6B/B,YAAY,EAAkD,EAAY,CAhB1E,eAAY,GAAI,MAAK,KACrB,gBAAa,GAAI,MAAK,MACtB,eAAY,GAAI,MAAK,KAErB,aAAmB,GAQX,qBAEJ,GAGF,KAAK,qBAAuB,GAAI,KAChC,KAAK,SAAW,EAAW,SAC3B,KAAK,SAAW,EAAW,SAC3B,KAAK,SAAW,EAAW,SAC3B,KAAK,WAAa,EAAW,WAC7B,KAAK,cAAgB,EAAI,KAAK,WAG9B,KAAM,GAAW,GAAI,MAAK,aAC1B,EAAK,oBAAoB,wBAAwB,GACjD,KAA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