gdcore-tools 2.0.0-gd-v5.5.241-autobuild → 2.0.0-gd-v5.5.243-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.
Files changed (132) hide show
  1. package/dist/Runtime/AsyncTasksManager.js +2 -2
  2. package/dist/Runtime/AsyncTasksManager.js.map +2 -2
  3. package/dist/Runtime/CustomRuntimeObject.js +1 -1
  4. package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
  5. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js +1 -1
  6. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js.map +2 -2
  7. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js +1 -1
  8. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js.map +2 -2
  9. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js +1 -1
  10. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
  11. package/dist/Runtime/Extensions/3D/JsExtension.js +47 -0
  12. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js +1 -1
  13. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js.map +2 -2
  14. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js +1 -1
  15. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js.map +2 -2
  16. package/dist/Runtime/Extensions/3D/Skybox.js +2 -0
  17. package/dist/Runtime/Extensions/3D/Skybox.js.map +7 -0
  18. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js +1 -1
  19. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js.map +2 -2
  20. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js +1 -1
  21. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js.map +2 -2
  22. package/dist/Runtime/Extensions/DebuggerTools/JsExtension.js +3 -1
  23. package/dist/Runtime/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.js +1 -1
  24. package/dist/Runtime/Extensions/DestroyOutsideBehavior/destroyoutsideruntimebehavior.js.map +2 -2
  25. package/dist/Runtime/Extensions/Lighting/lightruntimeobject.js +1 -1
  26. package/dist/Runtime/Extensions/Lighting/lightruntimeobject.js.map +2 -2
  27. package/dist/Runtime/Extensions/Multiplayer/messageManager.js +1 -1
  28. package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
  29. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js +1 -1
  30. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
  31. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js +1 -1
  32. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js.map +2 -2
  33. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js +1 -1
  34. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js.map +2 -2
  35. package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingruntimebehavior.js +1 -1
  36. package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingruntimebehavior.js.map +2 -2
  37. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js +1 -1
  38. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
  39. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js +1 -1
  40. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js.map +2 -2
  41. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js +1 -1
  42. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.js.map +2 -2
  43. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js +1 -1
  44. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js.map +2 -2
  45. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js +1 -1
  46. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js.map +2 -2
  47. package/dist/Runtime/Extensions/PlatformBehavior/platformruntimebehavior.js +1 -1
  48. package/dist/Runtime/Extensions/PlatformBehavior/platformruntimebehavior.js.map +2 -2
  49. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js +1 -1
  50. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js.map +2 -2
  51. package/dist/Runtime/Extensions/SaveState/JsExtension.js +488 -0
  52. package/dist/Runtime/Extensions/SaveState/SaveConfigurationRuntimeBehavior.js +2 -0
  53. package/dist/Runtime/Extensions/SaveState/SaveConfigurationRuntimeBehavior.js.map +7 -0
  54. package/dist/Runtime/Extensions/SaveState/SaveStateTools.js +2 -0
  55. package/dist/Runtime/Extensions/SaveState/SaveStateTools.js.map +7 -0
  56. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js +1 -1
  57. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js.map +2 -2
  58. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js +1 -1
  59. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js.map +2 -2
  60. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js +1 -1
  61. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js.map +2 -2
  62. package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts +4 -4
  63. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js +1 -1
  64. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
  65. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js +1 -1
  66. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js.map +2 -2
  67. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js +1 -1
  68. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js.map +2 -2
  69. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js +1 -1
  70. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js.map +2 -2
  71. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js +1 -1
  72. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js.map +2 -2
  73. package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js +1 -1
  74. package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js.map +2 -2
  75. package/dist/Runtime/Extensions/TweenBehavior/TweenManager.js +2 -2
  76. package/dist/Runtime/Extensions/TweenBehavior/TweenManager.js.map +2 -2
  77. package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js +1 -1
  78. package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js.map +2 -2
  79. package/dist/Runtime/Extensions/TweenBehavior/tweentools.js +1 -1
  80. package/dist/Runtime/Extensions/TweenBehavior/tweentools.js.map +2 -2
  81. package/dist/Runtime/Extensions/Video/videoruntimeobject.js +1 -1
  82. package/dist/Runtime/Extensions/Video/videoruntimeobject.js.map +2 -2
  83. package/dist/Runtime/RuntimeInstanceContainer.js +1 -1
  84. package/dist/Runtime/RuntimeInstanceContainer.js.map +2 -2
  85. package/dist/Runtime/RuntimeLayer.js +1 -1
  86. package/dist/Runtime/RuntimeLayer.js.map +2 -2
  87. package/dist/Runtime/debugger-client/hot-reloader.js +1 -1
  88. package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
  89. package/dist/Runtime/events-tools/objecttools.js +1 -1
  90. package/dist/Runtime/events-tools/objecttools.js.map +2 -2
  91. package/dist/Runtime/events-tools/runtimescenetools.js +1 -1
  92. package/dist/Runtime/events-tools/runtimescenetools.js.map +2 -2
  93. package/dist/Runtime/gd.js +1 -1
  94. package/dist/Runtime/gd.js.map +2 -2
  95. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
  96. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
  97. package/dist/Runtime/indexeddb.js +2 -0
  98. package/dist/Runtime/indexeddb.js.map +7 -0
  99. package/dist/Runtime/oncetriggers.js +1 -1
  100. package/dist/Runtime/oncetriggers.js.map +2 -2
  101. package/dist/Runtime/pixi-renderers/pixi-image-manager.js +1 -1
  102. package/dist/Runtime/pixi-renderers/pixi-image-manager.js.map +2 -2
  103. package/dist/Runtime/pixi-renderers/runtimescene-pixi-renderer.js +2 -2
  104. package/dist/Runtime/pixi-renderers/runtimescene-pixi-renderer.js.map +2 -2
  105. package/dist/Runtime/runtimebehavior.js +1 -1
  106. package/dist/Runtime/runtimebehavior.js.map +2 -2
  107. package/dist/Runtime/runtimegame.js +1 -1
  108. package/dist/Runtime/runtimegame.js.map +2 -2
  109. package/dist/Runtime/runtimeobject.js +1 -1
  110. package/dist/Runtime/runtimeobject.js.map +2 -2
  111. package/dist/Runtime/runtimescene.js +1 -1
  112. package/dist/Runtime/runtimescene.js.map +2 -2
  113. package/dist/Runtime/scenestack.js +1 -1
  114. package/dist/Runtime/scenestack.js.map +2 -2
  115. package/dist/Runtime/spriteruntimeobject.js +1 -1
  116. package/dist/Runtime/spriteruntimeobject.js.map +2 -2
  117. package/dist/Runtime/timemanager.js +1 -1
  118. package/dist/Runtime/timemanager.js.map +2 -2
  119. package/dist/Runtime/timer.js +1 -1
  120. package/dist/Runtime/timer.js.map +2 -2
  121. package/dist/Runtime/types/global-types.d.ts +29 -0
  122. package/dist/Runtime/types/project-data.d.ts +144 -3
  123. package/dist/Runtime/types/save-state.d.ts +9 -0
  124. package/dist/Runtime/variable.js +1 -1
  125. package/dist/Runtime/variable.js.map +2 -2
  126. package/dist/Runtime/variablescontainer.js +1 -1
  127. package/dist/Runtime/variablescontainer.js.map +2 -2
  128. package/dist/lib/libGD.cjs +1 -1
  129. package/dist/lib/libGD.wasm +0 -0
  130. package/dist/loaders.cjs +1 -1
  131. package/gd.d.ts +1 -0
  132. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- var gdjs;(function(c){class x extends c.RuntimeBehavior{constructor(e,t,i){super(e,t,i);this._physics3D=null;this._isHookedToPhysicsStep=!1;this._vehicleController=null;this._stepListener=null;this._vehicleCollisionTester=null;this._destroyedDuringFrameLogic=!1;this._currentSteerRatio=0;this._previousForward=1;this._hasPressedForwardKey=!1;this._hasPressedBackwardKey=!1;this._hasPressedRightKey=!1;this._hasPressedLeftKey=!1;this._hasPressedHandBrakeKey=!1;this._acceleratorStickForce=0;this._steeringStickForce=0;this._wasLeftKeyPressed=!1;this._wasRightKeyPressed=!1;this._wasForwardKeyPressed=!1;this._wasBackwardKeyPressed=!1;this._wasHandBrakeKeyPressed=!1;this._previousAcceleratorStickForce=0;this._previousSteeringStickForce=0;this._dontClearInputsBetweenFrames=!1;this.owner3D=i,this._physics3DBehaviorName=t.physics3D,this._sharedData=c.Physics3DSharedData.getSharedData(e.getScene(),t.Physics3D),this._steerAngleMax=t.steerAngleMax,this._beginningSteerSpeed=t.beginningSteerSpeed,this._endSteerSpeed=t.endSteerSpeed,this._engineTorqueMax=t.engineTorqueMax,this._engineSpeedMax=t.engineSpeedMax,this._engineInertia=t.engineInertia,this._reverseGearRatios=[t.reverseGearRatio1],this._gearRatios=[t.gearRatio1,t.gearRatio2,t.gearRatio3,t.gearRatio4,t.gearRatio5,t.gearRatio6],this._backWheelOffsetX=t.backWheelOffsetX,this._frontWheelOffsetX=t.frontWheelOffsetX,this._wheelOffsetY=t.wheelOffsetY,this._wheelOffsetZ=t.wheelOffsetZ,this._wheelRadius=t.wheelRadius,this._wheelWidth=t.wheelWidth,this._brakeTorqueMax=t.brakeTorqueMax,this._handBrakeTorqueMax=t.handBrakeTorqueMax,this._hasBackWheelDrive=t.hasBackWheelDrive,this._hasFrontWheelDrive=t.hasFrontWheelDrive,this._pitchRollAngleMax=t.pitchRollAngleMax}getVec3(e,t,i){const s=this._sharedData._tempVec3;return s.Set(e,t,i),s}getPhysics3D(){if(this._destroyedDuringFrameLogic)return null;if(this._physics3D)return this._physics3D;const e=this.owner.getBehavior(this._physics3DBehaviorName);if(!e.activated())return null;const t=e._sharedData;return this._physics3D={behavior:e},this._isHookedToPhysicsStep||(t.registerHook(this),this._isHookedToPhysicsStep=!0),e.bodyUpdater=new c.PhysicsCar3DRuntimeBehavior.VehicleBodyUpdater(this,e.bodyUpdater),e.recreateBody(),this._physics3D}updateFromBehaviorData(e,t){return e.steerAngleMax!==t.steerAngleMax&&this.setSteerAngleMax(t.steerAngleMax),e.beginningSteerSpeed!==t.beginningSteerSpeed&&this.setBeginningSteerSpeed(t.beginningSteerSpeed),e.endSteerSpeed!==t.endSteerSpeed&&this.setEndSteerSpeed(t.endSteerSpeed),e.engineTorqueMax!==t.engineTorqueMax&&this.setEngineTorqueMax(t.engineTorqueMax),e.engineSpeedMax!==t.engineSpeedMax&&this.setEngineSpeedMax(t.engineSpeedMax),e.engineInertia!==t.engineInertia&&this.setEngineInertia(t.engineInertia),e.reverseGearRatio1!==t.reverseGearRatio1&&this.setGearRatio(-1,t.reverseGearRatio1),e.gearRatio1!==t.gearRatio1&&this.setGearRatio(1,t.gearRatio1),e.gearRatio2!==t.gearRatio2&&this.setGearRatio(2,t.gearRatio2),e.gearRatio3!==t.gearRatio3&&this.setGearRatio(3,t.gearRatio3),e.gearRatio4!==t.gearRatio4&&this.setGearRatio(4,t.gearRatio4),e.gearRatio5!==t.gearRatio5&&this.setGearRatio(5,t.gearRatio5),e.gearRatio6!==t.gearRatio6&&this.setGearRatio(6,t.gearRatio6),e.backWheelOffsetX!==t.backWheelOffsetX&&this.setBackWheelOffsetX(t.backWheelOffsetX),e.frontWheelOffsetX!==t.frontWheelOffsetX&&this.setFrontWheelOffsetX(t.frontWheelOffsetX),e.wheelOffsetY!==t.wheelOffsetY&&this.setWheelOffsetY(t.wheelOffsetY),e.wheelOffsetZ!==t.wheelOffsetZ&&this.setWheelOffsetZ(t.wheelOffsetZ),e.wheelRadius!==t.wheelRadius&&this.setWheelRadius(t.wheelRadius),e.wheelWidth!==t.wheelWidth&&this.setWheelWidth(t.wheelWidth),e.brakeTorqueMax!==t.brakeTorqueMax&&this.setBrakeTorqueMax(t.brakeTorqueMax),e.handBrakeTorqueMax!==t.handBrakeTorqueMax&&this.setHandBrakeTorqueMax(t.handBrakeTorqueMax),e.hasBackWheelDrive!==t.hasBackWheelDrive&&this.setBackWheelDrive(t.hasBackWheelDrive),e.hasFrontWheelDrive!==t.hasFrontWheelDrive&&this.setFrontWheelDrive(t.hasFrontWheelDrive),e.pitchRollAngleMax!==t.pitchRollAngleMax&&this.setPitchRollAngleMax(t.pitchRollAngleMax),!0}getNetworkSyncData(){return this._dontClearInputsBetweenFrames=!1,{...super.getNetworkSyncData(),props:{lek:this._wasLeftKeyPressed,rik:this._wasRightKeyPressed,upk:this._wasForwardKeyPressed,dok:this._wasBackwardKeyPressed,hbk:this._wasHandBrakeKeyPressed,asf:this._previousAcceleratorStickForce,ssf:this._previousSteeringStickForce,etm:this._engineTorqueMax,esm:this._engineSpeedMax,ei:this._engineInertia}}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e);const t=e.props;this._hasPressedForwardKey=t.upk,this._hasPressedBackwardKey=t.dok,this._hasPressedLeftKey=t.lek,this._hasPressedRightKey=t.rik,this._hasPressedHandBrakeKey=t.hbk,this._acceleratorStickForce=t.asf,this._steeringStickForce=t.ssf,this._engineTorqueMax=t.etm,this._engineSpeedMax=t.esm,this._engineInertia=t.ei,this._dontClearInputsBetweenFrames=!0}_getPhysicsPosition(e){const t=this.getPhysics3D();if(!t)return e.Set(0,0,0),e;const{behavior:i}=t;return e.Set(this.owner3D.getCenterXInScene()*this._sharedData.worldInvScale,this.owner3D.getCenterYInScene()*this._sharedData.worldInvScale,this.owner3D.getZ()*this._sharedData.worldInvScale+i._shapeHalfDepth),e}onDeActivate(){!this._physics3D||this._destroyBody()}onActivate(){const e=this.owner.getBehavior(this._physics3DBehaviorName);!e||e._destroyBody()}onDestroy(){this._destroyedDuringFrameLogic=!0,this._destroyBody()}_destroyBody(){if(!this._vehicleController)return;this._stepListener&&(this._sharedData.physicsSystem.RemoveStepListener(this._stepListener),Jolt.destroy(this._stepListener),this._stepListener=null);const e=this._vehicleController.GetConstraint();if(this._sharedData.physicsSystem.RemoveConstraint(e),this._vehicleController=null,this._vehicleCollisionTester=null,this._physics3D){const{behavior:t}=this._physics3D;t.resetToDefaultBodyUpdater(),this._physics3D=null}}doStepPreEvents(e){this.getPhysics3D()}doStepPostEvents(e){this.getPhysics3D()}doBeforePhysicsStep(e){if(!this.activated())return;const t=this.getPhysics3D();if(!t)return;const{behavior:i}=t;if(!this._vehicleController)return;const s=i._body;if(!s)return;const o=this._steeringStickForce||(this._hasPressedLeftKey?-1:0)+(this._hasPressedRightKey?1:0);if(o===0)this._currentSteerRatio=0;else{const d=c.evtTools.common.lerp(this._beginningSteerSpeed,this._endSteerSpeed,Math.abs(this._currentSteerRatio));o<0&&(this._currentSteerRatio=Math.min(0,this._currentSteerRatio),this._currentSteerRatio+=o*d*e/this._steerAngleMax,this._currentSteerRatio=Math.max(-1,this._currentSteerRatio)),o>0&&(this._currentSteerRatio=Math.max(0,this._currentSteerRatio),this._currentSteerRatio+=o*d*e/this._steerAngleMax,this._currentSteerRatio=Math.min(1,this._currentSteerRatio))}let h=0,l=this._acceleratorStickForce||(this._hasPressedBackwardKey?-1:0)+(this._hasPressedForwardKey?1:0);if(this._previousForward*l<0){const d=s.GetRotation().InverseRotate(s.GetLinearVelocity()).GetX();l>0&&d<-.1||l<0&&d>.1?(l=0,h=1):this._previousForward=l}let r=0;this._hasPressedHandBrakeKey&&(l=0,r=1),this._vehicleController.SetDriverInput(l,-this._currentSteerRatio,h,r),(l!==0||this._currentSteerRatio!==0||h!==0||r!==0)&&this._sharedData.bodyInterface.ActivateBody(s.GetID()),this._wasForwardKeyPressed=this._hasPressedForwardKey,this._wasBackwardKeyPressed=this._hasPressedBackwardKey,this._wasRightKeyPressed=this._hasPressedRightKey,this._wasLeftKeyPressed=this._hasPressedLeftKey,this._wasHandBrakeKeyPressed=this._hasPressedHandBrakeKey,this._previousAcceleratorStickForce=this._acceleratorStickForce,this._previousSteeringStickForce=this._steeringStickForce,this._dontClearInputsBetweenFrames||(this._hasPressedForwardKey=!1,this._hasPressedBackwardKey=!1,this._hasPressedRightKey=!1,this._hasPressedLeftKey=!1,this._hasPressedHandBrakeKey=!1,this._acceleratorStickForce=0,this._steeringStickForce=0)}onObjectHotReloaded(){}simulateForwardKey(){this._hasPressedForwardKey=!0}wasForwardKeyPressed(){return this._wasForwardKeyPressed}simulateBackwardKey(){this._hasPressedBackwardKey=!0}wasBackwardKeyPressed(){return this._wasBackwardKeyPressed}simulateRightKey(){this._hasPressedRightKey=!0}wasRightKeyPressed(){return this._wasRightKeyPressed}simulateLeftKey(){this._hasPressedLeftKey=!0}wasLeftKeyPressed(){return this._wasLeftKeyPressed}simulateHandBrakeKey(){this._hasPressedHandBrakeKey=!0}wasHandBrakeKeyPressed(){return this._wasHandBrakeKeyPressed}simulateAcceleratorStick(e){this._acceleratorStickForce=c.evtTools.common.clamp(-1,1,e)}simulateSteeringStick(e){this._steeringStickForce=c.evtTools.common.clamp(-1,1,e)}getAcceleratorStickForce(){return this._acceleratorStickForce}getSteeringStickForce(){return this._steeringStickForce}getPreviousAcceleratorStickForce(){return this._previousAcceleratorStickForce}getPreviousSteeringStickForce(){return this._previousSteeringStickForce}getSteerAngle(){return this._currentSteerRatio*this._steerAngleMax}getEngineSpeed(){return this._vehicleController?this._vehicleController.GetEngine().GetCurrentRPM():0}getCurrentGear(){return this._vehicleController?this._vehicleController.GetTransmission().GetCurrentGear():0}getSteerAngleMax(){return this._steerAngleMax}setSteerAngleMax(e){this._steerAngleMax=e}getBeginningSteerSpeed(){return this._beginningSteerSpeed}setBeginningSteerSpeed(e){this._beginningSteerSpeed=e}getEndSteerSpeed(){return this._endSteerSpeed}setEndSteerSpeed(e){this._endSteerSpeed=e}invalidateShape(){const e=this.getPhysics3D();if(!e)return;const{behavior:t}=e;t._needToRecreateShape=!0}getEngineTorqueMax(){return this._engineTorqueMax}setEngineTorqueMax(e){this._engineTorqueMax=e,!!this._vehicleController&&(this._vehicleController.GetEngine().mMaxTorque=e)}getEngineSpeedMax(){return this._engineSpeedMax}setEngineSpeedMax(e){this._engineSpeedMax=e,!!this._vehicleController&&(this._vehicleController.GetEngine().mMaxRPM=e)}getEngineInertia(){return this._engineInertia}setEngineInertia(e){this._engineInertia=e,!!this._vehicleController&&(this._vehicleController.GetEngine().mInertia=e)}getGearRatio(e){return e===0?0:e<0?this._reverseGearRatios[-e-1]||0:this._gearRatios[e-1]||0}setGearRatio(e,t){if(e>0){if(this._gearRatios[e-1]=t,!this._vehicleController)return;this._updateGearRatios()}else e<0&&(this._reverseGearRatios[-e-1]=t,this._updateReverseGearRatios())}_updateGearRatios(){if(!this._vehicleController)return;const e=this._vehicleController.GetTransmission().mGearRatios;e.clear();let t=Number.POSITIVE_INFINITY;for(let i=0;i<this._gearRatios.length;i++){const s=this._gearRatios[i];0<s&&s<t&&(e.push_back(s),t=s)}}_updateReverseGearRatios(){if(!this._vehicleController)return;const e=this._vehicleController.GetTransmission().mReverseGearRatios;e.clear();let t=Number.NEGATIVE_INFINITY;for(let i=0;i<this._reverseGearRatios.length;i++){const s=this._reverseGearRatios[i];t<s&&s<0&&(e.push_back(s),t=s)}}getBackWheelOffsetX(){return this._backWheelOffsetX}setBackWheelOffsetX(e){this._backWheelOffsetX=e,this._updateWheels()}getFrontWheelOffsetX(){return this._frontWheelOffsetX}setFrontWheelOffsetX(e){this._frontWheelOffsetX=e,this._updateWheels()}getWheelOffsetY(){return this._wheelOffsetY}setWheelOffsetY(e){this._wheelOffsetY=e,this._updateWheels()}getWheelOffsetZ(){return this._wheelOffsetZ}setWheelOffsetZ(e){this._wheelOffsetZ=e,this._updateWheels()}getWheelRadius(){return this._wheelRadius}setWheelRadius(e){this._wheelRadius=e,this._updateWheels()}getWheelWidth(){return this._wheelWidth}setWheelWidth(e){this._wheelWidth=e,this._updateWheels()}getBrakeTorqueMax(){return this._brakeTorqueMax}setBrakeTorqueMax(e){this._brakeTorqueMax=e,this._updateWheels()}getHandBrakeTorqueMax(){return this._handBrakeTorqueMax}setHandBrakeTorqueMax(e){this._handBrakeTorqueMax=e,this._updateWheels()}hasBackWheelDrive(){return this._hasBackWheelDrive}setBackWheelDrive(e){this._hasBackWheelDrive=e,this.invalidateShape()}hasFrontWheelDrive(){return this._hasFrontWheelDrive}setFrontWheelDrive(e){this._hasFrontWheelDrive=e,this.invalidateShape()}getPitchRollAngleMax(){return this._pitchRollAngleMax}setPitchRollAngleMax(e){this._pitchRollAngleMax=e,!!this._vehicleController&&this._vehicleController.GetConstraint().SetMaxPitchRollAngle(e)}isOnFloor(){if(!!this._vehicleController){for(let e=0;e<4;e++)if(Jolt.castObject(this._vehicleController.GetConstraint().GetWheel(e),Jolt.WheelWV).HasContact())return!0;return!1}}_updateWheels(){if(!this._vehicleController)return;const e=this.getPhysics3D();if(!e)return;const{behavior:t}=e,i=t._shapeHalfWidth,s=t._shapeHalfHeight,o=t._shapeHalfDepth,h=t.shapeScale*t._sharedData.worldInvScale,n=this._wheelRadius*h,l=this._wheelWidth*h,r=i-n+this._backWheelOffsetX*h,d=i-n+this._frontWheelOffsetX*h,u=s-l/2+this._wheelOffsetY*h,p=o+(-t.shapeOffsetZ+this._wheelOffsetZ)*h,S=n,_=1.5*S,g=this._vehicleController.GetConstraint(),R=g.GetWheel(0).GetSettings();R.mPosition=this.getVec3(d,-u,-p);const v=g.GetWheel(1).GetSettings();v.mPosition=this.getVec3(d,u,-p);const y=g.GetWheel(2).GetSettings();y.mPosition=this.getVec3(-r,-u,-p);const m=g.GetWheel(3).GetSettings();m.mPosition=this.getVec3(-r,u,-p);for(let a=0;a<4;a++){const f=Jolt.castObject(g.GetWheel(a),Jolt.WheelWV).GetSettings();f.mRadius=n,f.mWidth=l,f.mSuspensionMinLength=S,f.mSuspensionMaxLength=_,f.mMaxBrakeTorque=this._brakeTorqueMax,a>=2&&(f.mMaxHandBrakeTorque=this._handBrakeTorqueMax)}}}c.PhysicsCar3DRuntimeBehavior=x,c.registerBehavior("Physics3D::PhysicsCar3D",c.PhysicsCar3DRuntimeBehavior),function(e){class B{constructor(i,s){this.carBehavior=i,this.physicsBodyUpdater=s}getVec3(i,s,o){const h=this.carBehavior._sharedData._tempVec3;return h.Set(i,s,o),h}createAndAddBody(){const i=this.carBehavior.getPhysics3D();if(!i)return null;const{behavior:s}=i,{_sharedData:o}=this.carBehavior,h=s.createShape(),n=new Jolt.BodyCreationSettings(h,this.carBehavior._getPhysicsPosition(o.getRVec3(0,0,0)),s._getPhysicsRotation(o.getQuat(0,0,0,1)),Jolt.EMotionType_Dynamic,s.getBodyLayer());n.mFriction=s.friction,n.mRestitution=s.restitution,n.mLinearDamping=s.linearDamping,n.mAngularDamping=s.angularDamping,n.mGravityFactor=s.gravityScale,s.massOverride>0&&(n.mOverrideMassProperties=Jolt.EOverrideMassProperties_CalculateInertia,n.mMassPropertiesOverride.mMass=s.massOverride);const l=o.bodyInterface.CreateBody(n);Jolt.destroy(n),o.bodyInterface.AddBody(l.GetID(),Jolt.EActivation_Activate);const r=new Jolt.VehicleConstraintSettings;r.mUp=this.getVec3(0,0,1),r.mForward=this.getVec3(1,0,0),r.mMaxPitchRollAngle=c.toRad(this.carBehavior._pitchRollAngleMax);const d=0,u=1,p=2,S=3;{const a=W=>{W.mWheelUp=this.getVec3(0,0,1),W.mWheelForward=this.getVec3(1,0,0),W.mSuspensionDirection=this.getVec3(0,0,-1),W.mSteeringAxis=this.getVec3(0,0,1)};r.mWheels.clear();const f=new Jolt.WheelSettingsWV;f.mMaxSteerAngle=c.toRad(this.carBehavior._steerAngleMax),f.mMaxHandBrakeTorque=0,a(f),r.mWheels.push_back(f);const k=new Jolt.WheelSettingsWV;k.mMaxSteerAngle=c.toRad(this.carBehavior._steerAngleMax),k.mMaxHandBrakeTorque=0,a(k),r.mWheels.push_back(k);const P=new Jolt.WheelSettingsWV;P.mMaxSteerAngle=0,a(P),r.mWheels.push_back(P);const M=new Jolt.WheelSettingsWV;M.mMaxSteerAngle=0,a(M),r.mWheels.push_back(M)}const _=new Jolt.WheeledVehicleControllerSettings;_.mEngine.mMaxTorque=this.carBehavior._engineTorqueMax,_.mEngine.mMaxRPM=this.carBehavior._engineSpeedMax,_.mEngine.mInertia=this.carBehavior._engineInertia,r.mController=_;const g=this.carBehavior._hasBackWheelDrive&&this.carBehavior._hasFrontWheelDrive;if(_.mDifferentials.clear(),this.carBehavior._hasFrontWheelDrive){const a=new Jolt.VehicleDifferentialSettings;a.mLeftWheel=d,a.mRightWheel=u,g&&(a.mEngineTorqueRatio=.5),_.mDifferentials.push_back(a)}if(this.carBehavior._hasBackWheelDrive){const a=new Jolt.VehicleDifferentialSettings;a.mLeftWheel=p,a.mRightWheel=S,g&&(a.mEngineTorqueRatio=.5),_.mDifferentials.push_back(a)}r.mAntiRollBars.clear();const R=new Jolt.VehicleAntiRollBar;R.mLeftWheel=d,R.mRightWheel=u;const v=new Jolt.VehicleAntiRollBar;v.mLeftWheel=p,v.mRightWheel=S,r.mAntiRollBars.push_back(R),r.mAntiRollBars.push_back(v);const y=new Jolt.VehicleConstraint(l,r);Jolt.destroy(r);const m=new Jolt.VehicleCollisionTesterCastCylinder(s.getBodyLayer(),.05);if(y.SetVehicleCollisionTester(m),this.carBehavior._vehicleCollisionTester=m,this.carBehavior._vehicleController){const a=this.carBehavior._vehicleController.GetConstraint();this.carBehavior._sharedData.physicsSystem.RemoveConstraint(a)}return o.physicsSystem.AddConstraint(y),this.carBehavior._vehicleController=Jolt.castObject(y.GetController(),Jolt.WheeledVehicleController),this.carBehavior._stepListener&&o.physicsSystem.RemoveStepListener(this.carBehavior._stepListener),this.carBehavior._stepListener=new Jolt.VehicleConstraintStepListener(y),o.physicsSystem.AddStepListener(this.carBehavior._stepListener),this.carBehavior._updateWheels(),this.carBehavior._updateGearRatios(),this.carBehavior._updateReverseGearRatios(),l}updateObjectFromBody(){this.physicsBodyUpdater.updateObjectFromBody()}updateBodyFromObject(){this.physicsBodyUpdater.updateBodyFromObject()}recreateShape(){this.physicsBodyUpdater.recreateShape(),this.carBehavior._updateWheels()}destroyBody(){this.carBehavior._destroyBody(),this.physicsBodyUpdater.destroyBody()}}e.VehicleBodyUpdater=B}(x=c.PhysicsCar3DRuntimeBehavior||(c.PhysicsCar3DRuntimeBehavior={}))})(gdjs||(gdjs={}));
1
+ var gdjs;(function(c){class x extends c.RuntimeBehavior{constructor(e,t,s){super(e,t,s);this._physics3D=null;this._isHookedToPhysicsStep=!1;this._vehicleController=null;this._stepListener=null;this._vehicleCollisionTester=null;this._destroyedDuringFrameLogic=!1;this._currentSteerRatio=0;this._previousForward=1;this._hasPressedForwardKey=!1;this._hasPressedBackwardKey=!1;this._hasPressedRightKey=!1;this._hasPressedLeftKey=!1;this._hasPressedHandBrakeKey=!1;this._acceleratorStickForce=0;this._steeringStickForce=0;this._wasLeftKeyPressed=!1;this._wasRightKeyPressed=!1;this._wasForwardKeyPressed=!1;this._wasBackwardKeyPressed=!1;this._wasHandBrakeKeyPressed=!1;this._previousAcceleratorStickForce=0;this._previousSteeringStickForce=0;this._clearInputsBetweenFrames=!0;this.owner3D=s,this._physics3DBehaviorName=t.physics3D,this._sharedData=c.Physics3DSharedData.getSharedData(e.getScene(),t.Physics3D),this._steerAngleMax=t.steerAngleMax,this._beginningSteerSpeed=t.beginningSteerSpeed,this._endSteerSpeed=t.endSteerSpeed,this._engineTorqueMax=t.engineTorqueMax,this._engineSpeedMax=t.engineSpeedMax,this._engineInertia=t.engineInertia,this._reverseGearRatios=[t.reverseGearRatio1],this._gearRatios=[t.gearRatio1,t.gearRatio2,t.gearRatio3,t.gearRatio4,t.gearRatio5,t.gearRatio6],this._backWheelOffsetX=t.backWheelOffsetX,this._frontWheelOffsetX=t.frontWheelOffsetX,this._wheelOffsetY=t.wheelOffsetY,this._wheelOffsetZ=t.wheelOffsetZ,this._wheelRadius=t.wheelRadius,this._wheelWidth=t.wheelWidth,this._brakeTorqueMax=t.brakeTorqueMax,this._handBrakeTorqueMax=t.handBrakeTorqueMax,this._hasBackWheelDrive=t.hasBackWheelDrive,this._hasFrontWheelDrive=t.hasFrontWheelDrive,this._pitchRollAngleMax=t.pitchRollAngleMax}getVec3(e,t,s){const i=this._sharedData._tempVec3;return i.Set(e,t,s),i}getPhysics3D(){if(this._destroyedDuringFrameLogic)return null;if(this._physics3D)return this._physics3D;const e=this.owner.getBehavior(this._physics3DBehaviorName);if(!e.activated())return null;const t=e._sharedData;this._physics3D={behavior:e},this._isHookedToPhysicsStep||(t.registerHook(this),this._isHookedToPhysicsStep=!0);let s={linearVelocityX:0,linearVelocityY:0,linearVelocityZ:0,angularVelocityX:0,angularVelocityY:0,angularVelocityZ:0};if(e._body){const i=e._body.GetLinearVelocity();s.linearVelocityX=i.GetX(),s.linearVelocityY=i.GetY(),s.linearVelocityZ=i.GetZ();const r=e._body.GetAngularVelocity();s.angularVelocityX=r.GetX(),s.angularVelocityY=r.GetY(),s.angularVelocityZ=r.GetZ(),e.bodyUpdater.destroyBody()}return e.bodyUpdater=new c.PhysicsCar3DRuntimeBehavior.VehicleBodyUpdater(this,e.bodyUpdater),e.recreateBody(s),this._physics3D}updateFromBehaviorData(e,t){return e.steerAngleMax!==t.steerAngleMax&&this.setSteerAngleMax(t.steerAngleMax),e.beginningSteerSpeed!==t.beginningSteerSpeed&&this.setBeginningSteerSpeed(t.beginningSteerSpeed),e.endSteerSpeed!==t.endSteerSpeed&&this.setEndSteerSpeed(t.endSteerSpeed),e.engineTorqueMax!==t.engineTorqueMax&&this.setEngineTorqueMax(t.engineTorqueMax),e.engineSpeedMax!==t.engineSpeedMax&&this.setEngineSpeedMax(t.engineSpeedMax),e.engineInertia!==t.engineInertia&&this.setEngineInertia(t.engineInertia),e.reverseGearRatio1!==t.reverseGearRatio1&&this.setGearRatio(-1,t.reverseGearRatio1),e.gearRatio1!==t.gearRatio1&&this.setGearRatio(1,t.gearRatio1),e.gearRatio2!==t.gearRatio2&&this.setGearRatio(2,t.gearRatio2),e.gearRatio3!==t.gearRatio3&&this.setGearRatio(3,t.gearRatio3),e.gearRatio4!==t.gearRatio4&&this.setGearRatio(4,t.gearRatio4),e.gearRatio5!==t.gearRatio5&&this.setGearRatio(5,t.gearRatio5),e.gearRatio6!==t.gearRatio6&&this.setGearRatio(6,t.gearRatio6),e.backWheelOffsetX!==t.backWheelOffsetX&&this.setBackWheelOffsetX(t.backWheelOffsetX),e.frontWheelOffsetX!==t.frontWheelOffsetX&&this.setFrontWheelOffsetX(t.frontWheelOffsetX),e.wheelOffsetY!==t.wheelOffsetY&&this.setWheelOffsetY(t.wheelOffsetY),e.wheelOffsetZ!==t.wheelOffsetZ&&this.setWheelOffsetZ(t.wheelOffsetZ),e.wheelRadius!==t.wheelRadius&&this.setWheelRadius(t.wheelRadius),e.wheelWidth!==t.wheelWidth&&this.setWheelWidth(t.wheelWidth),e.brakeTorqueMax!==t.brakeTorqueMax&&this.setBrakeTorqueMax(t.brakeTorqueMax),e.handBrakeTorqueMax!==t.handBrakeTorqueMax&&this.setHandBrakeTorqueMax(t.handBrakeTorqueMax),e.hasBackWheelDrive!==t.hasBackWheelDrive&&this.setBackWheelDrive(t.hasBackWheelDrive),e.hasFrontWheelDrive!==t.hasFrontWheelDrive&&this.setFrontWheelDrive(t.hasFrontWheelDrive),e.pitchRollAngleMax!==t.pitchRollAngleMax&&this.setPitchRollAngleMax(t.pitchRollAngleMax),!0}getNetworkSyncData(e){return this._clearInputsBetweenFrames=!0,{...super.getNetworkSyncData(e),props:{lek:this._wasLeftKeyPressed,rik:this._wasRightKeyPressed,upk:this._wasForwardKeyPressed,dok:this._wasBackwardKeyPressed,hbk:this._wasHandBrakeKeyPressed,asf:this._previousAcceleratorStickForce,ssf:this._previousSteeringStickForce,etm:this._engineTorqueMax,esm:this._engineSpeedMax,ei:this._engineInertia,es:this.getEngineSpeed()}}}updateFromNetworkSyncData(e,t){super.updateFromNetworkSyncData(e,t);const s=e.props;this._hasPressedForwardKey=s.upk,this._hasPressedBackwardKey=s.dok,this._hasPressedLeftKey=s.lek,this._hasPressedRightKey=s.rik,this._hasPressedHandBrakeKey=s.hbk,this._acceleratorStickForce=s.asf,this._steeringStickForce=s.ssf,this._engineTorqueMax=s.etm,this._engineSpeedMax=s.esm,this._engineInertia=s.ei,this._vehicleController&&this._vehicleController.GetEngine().SetCurrentRPM(s.es),this._clearInputsBetweenFrames=!!t.clearInputs}_getPhysicsPosition(e){const t=this.getPhysics3D();if(!t)return e.Set(0,0,0),e;const{behavior:s}=t;return e.Set(this.owner3D.getCenterXInScene()*this._sharedData.worldInvScale,this.owner3D.getCenterYInScene()*this._sharedData.worldInvScale,this.owner3D.getZ()*this._sharedData.worldInvScale+s._shapeHalfDepth),e}onDeActivate(){!this._physics3D||this._destroyBody()}onActivate(){const e=this.owner.getBehavior(this._physics3DBehaviorName);!e||e._destroyBody()}onDestroy(){this._destroyedDuringFrameLogic=!0,this._destroyBody()}_destroyBody(){if(!this._vehicleController)return;this._stepListener&&(this._sharedData.physicsSystem.RemoveStepListener(this._stepListener),Jolt.destroy(this._stepListener),this._stepListener=null);const e=this._vehicleController.GetConstraint();if(this._sharedData.physicsSystem.RemoveConstraint(e),this._vehicleController=null,this._vehicleCollisionTester=null,this._physics3D){const{behavior:t}=this._physics3D;t.resetToDefaultBodyUpdater(),this._physics3D=null}}doStepPreEvents(e){this.getPhysics3D()}doStepPostEvents(e){this.getPhysics3D()}doBeforePhysicsStep(e){if(!this.activated())return;const t=this.getPhysics3D();if(!t)return;const{behavior:s}=t;if(!this._vehicleController)return;const i=s._body;if(!i)return;const r=this._steeringStickForce||(this._hasPressedLeftKey?-1:0)+(this._hasPressedRightKey?1:0);if(r===0)this._currentSteerRatio=0;else{const d=c.evtTools.common.lerp(this._beginningSteerSpeed,this._endSteerSpeed,Math.abs(this._currentSteerRatio));r<0&&(this._currentSteerRatio=Math.min(0,this._currentSteerRatio),this._currentSteerRatio+=r*d*e/this._steerAngleMax,this._currentSteerRatio=Math.max(-1,this._currentSteerRatio)),r>0&&(this._currentSteerRatio=Math.max(0,this._currentSteerRatio),this._currentSteerRatio+=r*d*e/this._steerAngleMax,this._currentSteerRatio=Math.min(1,this._currentSteerRatio))}let n=0,l=this._acceleratorStickForce||(this._hasPressedBackwardKey?-1:0)+(this._hasPressedForwardKey?1:0);if(this._previousForward*l<0){const d=i.GetRotation().InverseRotate(i.GetLinearVelocity()).GetX();l>0&&d<-.1||l<0&&d>.1?(l=0,n=1):this._previousForward=l}let a=0;this._hasPressedHandBrakeKey&&(l=0,a=1),this._vehicleController.SetDriverInput(l,-this._currentSteerRatio,n,a),(l!==0||this._currentSteerRatio!==0||n!==0||a!==0)&&this._sharedData.bodyInterface.ActivateBody(i.GetID()),this._wasForwardKeyPressed=this._hasPressedForwardKey,this._wasBackwardKeyPressed=this._hasPressedBackwardKey,this._wasRightKeyPressed=this._hasPressedRightKey,this._wasLeftKeyPressed=this._hasPressedLeftKey,this._wasHandBrakeKeyPressed=this._hasPressedHandBrakeKey,this._previousAcceleratorStickForce=this._acceleratorStickForce,this._previousSteeringStickForce=this._steeringStickForce,this._clearInputsBetweenFrames&&(this._hasPressedForwardKey=!1,this._hasPressedBackwardKey=!1,this._hasPressedRightKey=!1,this._hasPressedLeftKey=!1,this._hasPressedHandBrakeKey=!1,this._acceleratorStickForce=0,this._steeringStickForce=0)}onObjectHotReloaded(){}simulateForwardKey(){this._hasPressedForwardKey=!0}wasForwardKeyPressed(){return this._wasForwardKeyPressed}simulateBackwardKey(){this._hasPressedBackwardKey=!0}wasBackwardKeyPressed(){return this._wasBackwardKeyPressed}simulateRightKey(){this._hasPressedRightKey=!0}wasRightKeyPressed(){return this._wasRightKeyPressed}simulateLeftKey(){this._hasPressedLeftKey=!0}wasLeftKeyPressed(){return this._wasLeftKeyPressed}simulateHandBrakeKey(){this._hasPressedHandBrakeKey=!0}wasHandBrakeKeyPressed(){return this._wasHandBrakeKeyPressed}simulateAcceleratorStick(e){this._acceleratorStickForce=c.evtTools.common.clamp(-1,1,e)}simulateSteeringStick(e){this._steeringStickForce=c.evtTools.common.clamp(-1,1,e)}getAcceleratorStickForce(){return this._acceleratorStickForce}getSteeringStickForce(){return this._steeringStickForce}getPreviousAcceleratorStickForce(){return this._previousAcceleratorStickForce}getPreviousSteeringStickForce(){return this._previousSteeringStickForce}getSteerAngle(){return this._currentSteerRatio*this._steerAngleMax}getEngineSpeed(){return this._vehicleController?this._vehicleController.GetEngine().GetCurrentRPM():0}getCurrentGear(){return this._vehicleController?this._vehicleController.GetTransmission().GetCurrentGear():0}getSteerAngleMax(){return this._steerAngleMax}setSteerAngleMax(e){this._steerAngleMax=e}getBeginningSteerSpeed(){return this._beginningSteerSpeed}setBeginningSteerSpeed(e){this._beginningSteerSpeed=e}getEndSteerSpeed(){return this._endSteerSpeed}setEndSteerSpeed(e){this._endSteerSpeed=e}invalidateShape(){const e=this.getPhysics3D();if(!e)return;const{behavior:t}=e;t._needToRecreateShape=!0}getEngineTorqueMax(){return this._engineTorqueMax}setEngineTorqueMax(e){this._engineTorqueMax=e,!!this._vehicleController&&(this._vehicleController.GetEngine().mMaxTorque=e)}getEngineSpeedMax(){return this._engineSpeedMax}setEngineSpeedMax(e){this._engineSpeedMax=e,!!this._vehicleController&&(this._vehicleController.GetEngine().mMaxRPM=e)}getEngineInertia(){return this._engineInertia}setEngineInertia(e){this._engineInertia=e,!!this._vehicleController&&(this._vehicleController.GetEngine().mInertia=e)}getGearRatio(e){return e===0?0:e<0?this._reverseGearRatios[-e-1]||0:this._gearRatios[e-1]||0}setGearRatio(e,t){if(e>0){if(this._gearRatios[e-1]=t,!this._vehicleController)return;this._updateGearRatios()}else e<0&&(this._reverseGearRatios[-e-1]=t,this._updateReverseGearRatios())}_updateGearRatios(){if(!this._vehicleController)return;const e=this._vehicleController.GetTransmission().mGearRatios;e.clear();let t=Number.POSITIVE_INFINITY;for(let s=0;s<this._gearRatios.length;s++){const i=this._gearRatios[s];0<i&&i<t&&(e.push_back(i),t=i)}}_updateReverseGearRatios(){if(!this._vehicleController)return;const e=this._vehicleController.GetTransmission().mReverseGearRatios;e.clear();let t=Number.NEGATIVE_INFINITY;for(let s=0;s<this._reverseGearRatios.length;s++){const i=this._reverseGearRatios[s];t<i&&i<0&&(e.push_back(i),t=i)}}getBackWheelOffsetX(){return this._backWheelOffsetX}setBackWheelOffsetX(e){this._backWheelOffsetX=e,this._updateWheels()}getFrontWheelOffsetX(){return this._frontWheelOffsetX}setFrontWheelOffsetX(e){this._frontWheelOffsetX=e,this._updateWheels()}getWheelOffsetY(){return this._wheelOffsetY}setWheelOffsetY(e){this._wheelOffsetY=e,this._updateWheels()}getWheelOffsetZ(){return this._wheelOffsetZ}setWheelOffsetZ(e){this._wheelOffsetZ=e,this._updateWheels()}getWheelRadius(){return this._wheelRadius}setWheelRadius(e){this._wheelRadius=e,this._updateWheels()}getWheelWidth(){return this._wheelWidth}setWheelWidth(e){this._wheelWidth=e,this._updateWheels()}getBrakeTorqueMax(){return this._brakeTorqueMax}setBrakeTorqueMax(e){this._brakeTorqueMax=e,this._updateWheels()}getHandBrakeTorqueMax(){return this._handBrakeTorqueMax}setHandBrakeTorqueMax(e){this._handBrakeTorqueMax=e,this._updateWheels()}hasBackWheelDrive(){return this._hasBackWheelDrive}setBackWheelDrive(e){this._hasBackWheelDrive=e,this.invalidateShape()}hasFrontWheelDrive(){return this._hasFrontWheelDrive}setFrontWheelDrive(e){this._hasFrontWheelDrive=e,this.invalidateShape()}getPitchRollAngleMax(){return this._pitchRollAngleMax}setPitchRollAngleMax(e){this._pitchRollAngleMax=e,!!this._vehicleController&&this._vehicleController.GetConstraint().SetMaxPitchRollAngle(e)}isOnFloor(){if(!!this._vehicleController){for(let e=0;e<4;e++)if(Jolt.castObject(this._vehicleController.GetConstraint().GetWheel(e),Jolt.WheelWV).HasContact())return!0;return!1}}_updateWheels(){if(!this._vehicleController)return;const e=this.getPhysics3D();if(!e)return;const{behavior:t}=e,s=t._shapeHalfWidth,i=t._shapeHalfHeight,r=t._shapeHalfDepth,n=t.shapeScale*t._sharedData.worldInvScale,h=this._wheelRadius*n,l=this._wheelWidth*n,a=s-h+this._backWheelOffsetX*n,d=s-h+this._frontWheelOffsetX*n,u=i-l/2+this._wheelOffsetY*n,p=r+(-t.shapeOffsetZ+this._wheelOffsetZ)*n,S=h,_=1.5*S,g=this._vehicleController.GetConstraint(),R=g.GetWheel(0).GetSettings();R.mPosition=this.getVec3(d,-u,-p);const v=g.GetWheel(1).GetSettings();v.mPosition=this.getVec3(d,u,-p);const y=g.GetWheel(2).GetSettings();y.mPosition=this.getVec3(-a,-u,-p);const m=g.GetWheel(3).GetSettings();m.mPosition=this.getVec3(-a,u,-p);for(let o=0;o<4;o++){const f=Jolt.castObject(g.GetWheel(o),Jolt.WheelWV).GetSettings();f.mRadius=h,f.mWidth=l,f.mSuspensionMinLength=S,f.mSuspensionMaxLength=_,f.mMaxBrakeTorque=this._brakeTorqueMax,o>=2&&(f.mMaxHandBrakeTorque=this._handBrakeTorqueMax)}}}c.PhysicsCar3DRuntimeBehavior=x,c.registerBehavior("Physics3D::PhysicsCar3D",c.PhysicsCar3DRuntimeBehavior),function(e){class B{constructor(s,i){this.carBehavior=s,this.physicsBodyUpdater=i}getVec3(s,i,r){const n=this.carBehavior._sharedData._tempVec3;return n.Set(s,i,r),n}createAndAddBody(){const s=this.carBehavior.getPhysics3D();if(!s)return null;const{behavior:i}=s,{_sharedData:r}=this.carBehavior,n=i.createShape(),h=new Jolt.BodyCreationSettings(n,this.carBehavior._getPhysicsPosition(r.getRVec3(0,0,0)),i._getPhysicsRotation(r.getQuat(0,0,0,1)),Jolt.EMotionType_Dynamic,i.getBodyLayer());h.mFriction=i.friction,h.mRestitution=i.restitution,h.mLinearDamping=i.linearDamping,h.mAngularDamping=i.angularDamping,h.mGravityFactor=i.gravityScale,i.massOverride>0&&(h.mOverrideMassProperties=Jolt.EOverrideMassProperties_CalculateInertia,h.mMassPropertiesOverride.mMass=i.massOverride);const l=r.bodyInterface.CreateBody(h);Jolt.destroy(h),r.bodyInterface.AddBody(l.GetID(),Jolt.EActivation_Activate);const a=new Jolt.VehicleConstraintSettings;a.mUp=this.getVec3(0,0,1),a.mForward=this.getVec3(1,0,0),a.mMaxPitchRollAngle=c.toRad(this.carBehavior._pitchRollAngleMax);const d=0,u=1,p=2,S=3;{const o=W=>{W.mWheelUp=this.getVec3(0,0,1),W.mWheelForward=this.getVec3(1,0,0),W.mSuspensionDirection=this.getVec3(0,0,-1),W.mSteeringAxis=this.getVec3(0,0,1)};a.mWheels.clear();const f=new Jolt.WheelSettingsWV;f.mMaxSteerAngle=c.toRad(this.carBehavior._steerAngleMax),f.mMaxHandBrakeTorque=0,o(f),a.mWheels.push_back(f);const k=new Jolt.WheelSettingsWV;k.mMaxSteerAngle=c.toRad(this.carBehavior._steerAngleMax),k.mMaxHandBrakeTorque=0,o(k),a.mWheels.push_back(k);const P=new Jolt.WheelSettingsWV;P.mMaxSteerAngle=0,o(P),a.mWheels.push_back(P);const M=new Jolt.WheelSettingsWV;M.mMaxSteerAngle=0,o(M),a.mWheels.push_back(M)}const _=new Jolt.WheeledVehicleControllerSettings;_.mEngine.mMaxTorque=this.carBehavior._engineTorqueMax,_.mEngine.mMaxRPM=this.carBehavior._engineSpeedMax,_.mEngine.mInertia=this.carBehavior._engineInertia,a.mController=_;const g=this.carBehavior._hasBackWheelDrive&&this.carBehavior._hasFrontWheelDrive;if(_.mDifferentials.clear(),this.carBehavior._hasFrontWheelDrive){const o=new Jolt.VehicleDifferentialSettings;o.mLeftWheel=d,o.mRightWheel=u,g&&(o.mEngineTorqueRatio=.5),_.mDifferentials.push_back(o)}if(this.carBehavior._hasBackWheelDrive){const o=new Jolt.VehicleDifferentialSettings;o.mLeftWheel=p,o.mRightWheel=S,g&&(o.mEngineTorqueRatio=.5),_.mDifferentials.push_back(o)}a.mAntiRollBars.clear();const R=new Jolt.VehicleAntiRollBar;R.mLeftWheel=d,R.mRightWheel=u;const v=new Jolt.VehicleAntiRollBar;v.mLeftWheel=p,v.mRightWheel=S,a.mAntiRollBars.push_back(R),a.mAntiRollBars.push_back(v);const y=new Jolt.VehicleConstraint(l,a);Jolt.destroy(a);const m=new Jolt.VehicleCollisionTesterCastCylinder(i.getBodyLayer(),.05);if(y.SetVehicleCollisionTester(m),this.carBehavior._vehicleCollisionTester=m,this.carBehavior._vehicleController){const o=this.carBehavior._vehicleController.GetConstraint();this.carBehavior._sharedData.physicsSystem.RemoveConstraint(o)}return r.physicsSystem.AddConstraint(y),this.carBehavior._vehicleController=Jolt.castObject(y.GetController(),Jolt.WheeledVehicleController),this.carBehavior._stepListener&&r.physicsSystem.RemoveStepListener(this.carBehavior._stepListener),this.carBehavior._stepListener=new Jolt.VehicleConstraintStepListener(y),r.physicsSystem.AddStepListener(this.carBehavior._stepListener),this.carBehavior._updateWheels(),this.carBehavior._updateGearRatios(),this.carBehavior._updateReverseGearRatios(),l}updateObjectFromBody(){this.physicsBodyUpdater.updateObjectFromBody()}updateBodyFromObject(){this.physicsBodyUpdater.updateBodyFromObject()}recreateShape(){this.physicsBodyUpdater.recreateShape(),this.carBehavior._updateWheels()}destroyBody(){this.carBehavior._destroyBody(),this.physicsBodyUpdater.destroyBody()}}e.VehicleBodyUpdater=B}(x=c.PhysicsCar3DRuntimeBehavior||(c.PhysicsCar3DRuntimeBehavior={}))})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=PhysicsCar3DRuntimeBehavior.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../GDevelop/Extensions/Physics3DBehavior/PhysicsCar3DRuntimeBehavior.ts"],
4
- "sourcesContent": ["/// <reference path=\"./jolt-physics.d.ts\" />\n\nnamespace gdjs {\n interface PhysicsCar3DNetworkSyncDataType {\n lek: boolean;\n rik: boolean;\n upk: boolean;\n dok: boolean;\n hbk: boolean;\n asf: float;\n ssf: float;\n etm: float;\n esm: float;\n ei: float;\n }\n\n export interface PhysicsCar3DNetworkSyncData extends BehaviorNetworkSyncData {\n props: PhysicsCar3DNetworkSyncDataType;\n }\n\n type Physics3D = {\n behavior: gdjs.Physics3DRuntimeBehavior;\n };\n\n export class PhysicsCar3DRuntimeBehavior\n extends gdjs.RuntimeBehavior\n implements gdjs.Physics3DRuntimeBehavior.Physics3DHook\n {\n owner3D: gdjs.RuntimeObject3D;\n private _physics3DBehaviorName: string;\n private _physics3D: Physics3D | null = null;\n private _isHookedToPhysicsStep = false;\n _vehicleController: Jolt.WheeledVehicleController | null = null;\n _stepListener: Jolt.VehicleConstraintStepListener | null = null;\n _vehicleCollisionTester: Jolt.VehicleCollisionTesterCastCylinder | null =\n null;\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: gdjs.Physics3DSharedData;\n private _destroyedDuringFrameLogic: boolean = false;\n\n // Readonly configuration\n\n _steerAngleMax;\n private _beginningSteerSpeed: float;\n private _endSteerSpeed: float;\n _gearRatios: Array<float>;\n _reverseGearRatios: Array<float>;\n private _backWheelOffsetX: float;\n private _frontWheelOffsetX: float;\n private _wheelOffsetY: float;\n private _wheelOffsetZ: float;\n private _wheelRadius: float;\n private _wheelWidth: float;\n private _brakeTorqueMax: float;\n private _handBrakeTorqueMax: float;\n _hasBackWheelDrive: boolean;\n _hasFrontWheelDrive: boolean;\n _pitchRollAngleMax: float;\n\n // Mutable configuration\n\n _engineTorqueMax: float;\n /** in RPM (rotation per minute) */\n _engineSpeedMax: float;\n _engineInertia: float;\n\n // State\n\n private _currentSteerRatio: float = 0;\n /** Used to make sure the car is stopped before going backward. */\n _previousForward = 1;\n\n private _hasPressedForwardKey: boolean = false;\n private _hasPressedBackwardKey: boolean = false;\n private _hasPressedRightKey: boolean = false;\n private _hasPressedLeftKey: boolean = false;\n private _hasPressedHandBrakeKey: boolean = false;\n private _acceleratorStickForce: float = 0;\n private _steeringStickForce: float = 0;\n\n // This is useful for extensions that need to know\n // which keys were pressed and doesn't know the mapping\n // done by the scene events.\n private _wasLeftKeyPressed: boolean = false;\n private _wasRightKeyPressed: boolean = false;\n private _wasForwardKeyPressed: boolean = false;\n private _wasBackwardKeyPressed: boolean = false;\n private _wasHandBrakeKeyPressed: boolean = false;\n private _previousAcceleratorStickForce: float = 0;\n private _previousSteeringStickForce: float = 0;\n\n // This is useful when the object is synchronized by an external source\n // like in a multiplayer game, and we want to be able to predict the\n // movement of the object, even if the inputs are not updated every frame.\n private _dontClearInputsBetweenFrames: boolean = false;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData,\n owner: gdjs.RuntimeObject3D\n ) {\n super(instanceContainer, behaviorData, owner);\n this.owner3D = owner;\n this._physics3DBehaviorName = behaviorData.physics3D;\n this._sharedData = gdjs.Physics3DSharedData.getSharedData(\n instanceContainer.getScene(),\n behaviorData.Physics3D\n );\n this._steerAngleMax = behaviorData.steerAngleMax;\n this._beginningSteerSpeed = behaviorData.beginningSteerSpeed;\n this._endSteerSpeed = behaviorData.endSteerSpeed;\n this._engineTorqueMax = behaviorData.engineTorqueMax;\n this._engineSpeedMax = behaviorData.engineSpeedMax;\n this._engineInertia = behaviorData.engineInertia;\n this._reverseGearRatios = [behaviorData.reverseGearRatio1];\n this._gearRatios = [\n behaviorData.gearRatio1,\n behaviorData.gearRatio2,\n behaviorData.gearRatio3,\n behaviorData.gearRatio4,\n behaviorData.gearRatio5,\n behaviorData.gearRatio6,\n ];\n this._backWheelOffsetX = behaviorData.backWheelOffsetX;\n this._frontWheelOffsetX = behaviorData.frontWheelOffsetX;\n this._wheelOffsetY = behaviorData.wheelOffsetY;\n this._wheelOffsetZ = behaviorData.wheelOffsetZ;\n this._wheelRadius = behaviorData.wheelRadius;\n this._wheelWidth = behaviorData.wheelWidth;\n this._brakeTorqueMax = behaviorData.brakeTorqueMax;\n this._handBrakeTorqueMax = behaviorData.handBrakeTorqueMax;\n this._hasBackWheelDrive = behaviorData.hasBackWheelDrive;\n this._hasFrontWheelDrive = behaviorData.hasFrontWheelDrive;\n this._pitchRollAngleMax = behaviorData.pitchRollAngleMax;\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 getPhysics3D(): Physics3D | null {\n if (this._destroyedDuringFrameLogic) {\n return null;\n }\n if (this._physics3D) {\n return this._physics3D;\n }\n const behavior = this.owner.getBehavior(\n this._physics3DBehaviorName\n ) as gdjs.Physics3DRuntimeBehavior;\n if (!behavior.activated()) {\n return null;\n }\n\n const sharedData = behavior._sharedData;\n\n this._physics3D = {\n behavior,\n };\n if (!this._isHookedToPhysicsStep) {\n sharedData.registerHook(this);\n this._isHookedToPhysicsStep = true;\n }\n\n behavior.bodyUpdater =\n new gdjs.PhysicsCar3DRuntimeBehavior.VehicleBodyUpdater(\n this,\n behavior.bodyUpdater\n );\n behavior.recreateBody();\n\n return this._physics3D;\n }\n\n override updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {\n if (oldBehaviorData.steerAngleMax !== newBehaviorData.steerAngleMax) {\n this.setSteerAngleMax(newBehaviorData.steerAngleMax);\n }\n if (\n oldBehaviorData.beginningSteerSpeed !==\n newBehaviorData.beginningSteerSpeed\n ) {\n this.setBeginningSteerSpeed(newBehaviorData.beginningSteerSpeed);\n }\n if (oldBehaviorData.endSteerSpeed !== newBehaviorData.endSteerSpeed) {\n this.setEndSteerSpeed(newBehaviorData.endSteerSpeed);\n }\n if (oldBehaviorData.engineTorqueMax !== newBehaviorData.engineTorqueMax) {\n this.setEngineTorqueMax(newBehaviorData.engineTorqueMax);\n }\n if (oldBehaviorData.engineSpeedMax !== newBehaviorData.engineSpeedMax) {\n this.setEngineSpeedMax(newBehaviorData.engineSpeedMax);\n }\n if (oldBehaviorData.engineInertia !== newBehaviorData.engineInertia) {\n this.setEngineInertia(newBehaviorData.engineInertia);\n }\n if (\n oldBehaviorData.reverseGearRatio1 !== newBehaviorData.reverseGearRatio1\n ) {\n this.setGearRatio(-1, newBehaviorData.reverseGearRatio1);\n }\n if (oldBehaviorData.gearRatio1 !== newBehaviorData.gearRatio1) {\n this.setGearRatio(1, newBehaviorData.gearRatio1);\n }\n if (oldBehaviorData.gearRatio2 !== newBehaviorData.gearRatio2) {\n this.setGearRatio(2, newBehaviorData.gearRatio2);\n }\n if (oldBehaviorData.gearRatio3 !== newBehaviorData.gearRatio3) {\n this.setGearRatio(3, newBehaviorData.gearRatio3);\n }\n if (oldBehaviorData.gearRatio4 !== newBehaviorData.gearRatio4) {\n this.setGearRatio(4, newBehaviorData.gearRatio4);\n }\n if (oldBehaviorData.gearRatio5 !== newBehaviorData.gearRatio5) {\n this.setGearRatio(5, newBehaviorData.gearRatio5);\n }\n if (oldBehaviorData.gearRatio6 !== newBehaviorData.gearRatio6) {\n this.setGearRatio(6, newBehaviorData.gearRatio6);\n }\n if (\n oldBehaviorData.backWheelOffsetX !== newBehaviorData.backWheelOffsetX\n ) {\n this.setBackWheelOffsetX(newBehaviorData.backWheelOffsetX);\n }\n if (\n oldBehaviorData.frontWheelOffsetX !== newBehaviorData.frontWheelOffsetX\n ) {\n this.setFrontWheelOffsetX(newBehaviorData.frontWheelOffsetX);\n }\n if (oldBehaviorData.wheelOffsetY !== newBehaviorData.wheelOffsetY) {\n this.setWheelOffsetY(newBehaviorData.wheelOffsetY);\n }\n if (oldBehaviorData.wheelOffsetZ !== newBehaviorData.wheelOffsetZ) {\n this.setWheelOffsetZ(newBehaviorData.wheelOffsetZ);\n }\n if (oldBehaviorData.wheelRadius !== newBehaviorData.wheelRadius) {\n this.setWheelRadius(newBehaviorData.wheelRadius);\n }\n if (oldBehaviorData.wheelWidth !== newBehaviorData.wheelWidth) {\n this.setWheelWidth(newBehaviorData.wheelWidth);\n }\n if (oldBehaviorData.brakeTorqueMax !== newBehaviorData.brakeTorqueMax) {\n this.setBrakeTorqueMax(newBehaviorData.brakeTorqueMax);\n }\n if (\n oldBehaviorData.handBrakeTorqueMax !==\n newBehaviorData.handBrakeTorqueMax\n ) {\n this.setHandBrakeTorqueMax(newBehaviorData.handBrakeTorqueMax);\n }\n if (\n oldBehaviorData.hasBackWheelDrive !== newBehaviorData.hasBackWheelDrive\n ) {\n this.setBackWheelDrive(newBehaviorData.hasBackWheelDrive);\n }\n if (\n oldBehaviorData.hasFrontWheelDrive !==\n newBehaviorData.hasFrontWheelDrive\n ) {\n this.setFrontWheelDrive(newBehaviorData.hasFrontWheelDrive);\n }\n if (\n oldBehaviorData.pitchRollAngleMax !== newBehaviorData.pitchRollAngleMax\n ) {\n this.setPitchRollAngleMax(newBehaviorData.pitchRollAngleMax);\n }\n return true;\n }\n\n override getNetworkSyncData(): PhysicsCar3DNetworkSyncData {\n // This method is called, so we are synchronizing this object.\n // Let's clear the inputs between frames as we control it.\n this._dontClearInputsBetweenFrames = false;\n\n return {\n ...super.getNetworkSyncData(),\n props: {\n lek: this._wasLeftKeyPressed,\n rik: this._wasRightKeyPressed,\n upk: this._wasForwardKeyPressed,\n dok: this._wasBackwardKeyPressed,\n hbk: this._wasHandBrakeKeyPressed,\n asf: this._previousAcceleratorStickForce,\n ssf: this._previousSteeringStickForce,\n etm: this._engineTorqueMax,\n esm: this._engineSpeedMax,\n ei: this._engineInertia,\n },\n };\n }\n\n override updateFromNetworkSyncData(\n networkSyncData: PhysicsCar3DNetworkSyncData\n ) {\n super.updateFromNetworkSyncData(networkSyncData);\n\n const behaviorSpecificProps = networkSyncData.props;\n this._hasPressedForwardKey = behaviorSpecificProps.upk;\n this._hasPressedBackwardKey = behaviorSpecificProps.dok;\n this._hasPressedLeftKey = behaviorSpecificProps.lek;\n this._hasPressedRightKey = behaviorSpecificProps.rik;\n this._hasPressedHandBrakeKey = behaviorSpecificProps.hbk;\n this._acceleratorStickForce = behaviorSpecificProps.asf;\n this._steeringStickForce = behaviorSpecificProps.ssf;\n this._engineTorqueMax = behaviorSpecificProps.etm;\n this._engineSpeedMax = behaviorSpecificProps.esm;\n this._engineInertia = behaviorSpecificProps.ei;\n\n // When the object is synchronized from the network, the inputs must not be cleared.\n this._dontClearInputsBetweenFrames = true;\n }\n\n _getPhysicsPosition(result: Jolt.RVec3): Jolt.RVec3 {\n const physics3D = this.getPhysics3D();\n if (!physics3D) {\n result.Set(0, 0, 0);\n return result;\n }\n const { behavior } = physics3D;\n // Same as for characters, the origin is at its feet:\n // - the center is used for X and Y because Box3D origin is at the top-left corner\n // - the origin is used for Z because, when the character is made smaller,\n // it must stay on the ground and not fell from its old size.\n result.Set(\n this.owner3D.getCenterXInScene() * this._sharedData.worldInvScale,\n this.owner3D.getCenterYInScene() * this._sharedData.worldInvScale,\n this.owner3D.getZ() * this._sharedData.worldInvScale +\n behavior._shapeHalfDepth\n );\n return result;\n }\n\n override onDeActivate() {\n if (!this._physics3D) {\n return;\n }\n this._destroyBody();\n }\n\n override onActivate() {\n const behavior = this.owner.getBehavior(\n this._physics3DBehaviorName\n ) as gdjs.Physics3DRuntimeBehavior;\n if (!behavior) {\n return;\n }\n behavior._destroyBody();\n }\n\n override onDestroy() {\n this._destroyedDuringFrameLogic = true;\n this._destroyBody();\n }\n\n _destroyBody() {\n if (!this._vehicleController) {\n return;\n }\n if (this._stepListener) {\n this._sharedData.physicsSystem.RemoveStepListener(this._stepListener);\n Jolt.destroy(this._stepListener);\n this._stepListener = null;\n }\n const constraint = this._vehicleController.GetConstraint();\n this._sharedData.physicsSystem.RemoveConstraint(constraint);\n // The controller is destroyed with the constraint.\n this._vehicleController = null;\n // VehicleConstraint.mVehicleCollisionTester is a RefConst (smart pointer).\n // It is destroyed with the constraint.\n this._vehicleCollisionTester = null;\n if (this._physics3D) {\n const { behavior } = this._physics3D;\n behavior.resetToDefaultBodyUpdater();\n this._physics3D = null;\n }\n }\n\n override doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n // Trigger createAndAddBody()\n this.getPhysics3D();\n }\n\n override doStepPostEvents(\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n // Trigger createAndAddBody()\n this.getPhysics3D();\n }\n\n doBeforePhysicsStep(timeDelta: float): void {\n if (!this.activated()) {\n return;\n }\n const physics3D = this.getPhysics3D();\n if (!physics3D) {\n return;\n }\n const { behavior } = physics3D;\n if (!this._vehicleController) {\n return;\n }\n const carBody = behavior._body;\n if (!carBody) {\n return;\n }\n\n const steeringControl =\n this._steeringStickForce ||\n (this._hasPressedLeftKey ? -1 : 0) + (this._hasPressedRightKey ? 1 : 0);\n if (steeringControl === 0) {\n this._currentSteerRatio = 0;\n } else {\n const steerSpeed = gdjs.evtTools.common.lerp(\n this._beginningSteerSpeed,\n this._endSteerSpeed,\n Math.abs(this._currentSteerRatio)\n );\n if (steeringControl < 0) {\n // Avoid to much latency when changing of direction\n this._currentSteerRatio = Math.min(0, this._currentSteerRatio);\n this._currentSteerRatio +=\n (steeringControl * steerSpeed * timeDelta) / this._steerAngleMax;\n this._currentSteerRatio = Math.max(-1, this._currentSteerRatio);\n }\n if (steeringControl > 0) {\n // Avoid to much latency when changing of direction\n this._currentSteerRatio = Math.max(0, this._currentSteerRatio);\n this._currentSteerRatio +=\n (steeringControl * steerSpeed * timeDelta) / this._steerAngleMax;\n this._currentSteerRatio = Math.min(1, this._currentSteerRatio);\n }\n }\n\n let brake = 0;\n const acceleratorControl =\n this._acceleratorStickForce ||\n (this._hasPressedBackwardKey ? -1 : 0) +\n (this._hasPressedForwardKey ? 1 : 0);\n let forward = acceleratorControl;\n if (this._previousForward * forward < 0.0) {\n const velocity = carBody\n .GetRotation()\n .InverseRotate(carBody.GetLinearVelocity())\n .GetX();\n if (\n (forward > 0.0 && velocity < -0.1) ||\n (forward < 0.0 && velocity > 0.1)\n ) {\n // Brake while we've not stopped yet\n forward = 0.0;\n brake = 1.0;\n } else {\n // When we've come to a stop, accept the new direction\n this._previousForward = forward;\n }\n }\n\n let handBrake = 0;\n if (this._hasPressedHandBrakeKey) {\n forward = 0.0;\n handBrake = 1.0;\n }\n\n this._vehicleController.SetDriverInput(\n forward,\n -this._currentSteerRatio,\n brake,\n handBrake\n );\n if (\n forward !== 0.0 ||\n this._currentSteerRatio !== 0.0 ||\n brake !== 0.0 ||\n handBrake !== 0.0\n ) {\n this._sharedData.bodyInterface.ActivateBody(carBody.GetID());\n }\n\n this._wasForwardKeyPressed = this._hasPressedForwardKey;\n this._wasBackwardKeyPressed = this._hasPressedBackwardKey;\n this._wasRightKeyPressed = this._hasPressedRightKey;\n this._wasLeftKeyPressed = this._hasPressedLeftKey;\n this._wasHandBrakeKeyPressed = this._hasPressedHandBrakeKey;\n this._previousAcceleratorStickForce = this._acceleratorStickForce;\n this._previousSteeringStickForce = this._steeringStickForce;\n\n if (!this._dontClearInputsBetweenFrames) {\n this._hasPressedForwardKey = false;\n this._hasPressedBackwardKey = false;\n this._hasPressedRightKey = false;\n this._hasPressedLeftKey = false;\n this._hasPressedHandBrakeKey = false;\n this._acceleratorStickForce = 0;\n this._steeringStickForce = 0;\n }\n }\n\n override onObjectHotReloaded() {}\n\n simulateForwardKey(): void {\n this._hasPressedForwardKey = true;\n }\n\n wasForwardKeyPressed(): boolean {\n return this._wasForwardKeyPressed;\n }\n\n simulateBackwardKey(): void {\n this._hasPressedBackwardKey = true;\n }\n\n wasBackwardKeyPressed(): boolean {\n return this._wasBackwardKeyPressed;\n }\n\n simulateRightKey(): void {\n this._hasPressedRightKey = true;\n }\n\n wasRightKeyPressed(): boolean {\n return this._wasRightKeyPressed;\n }\n\n simulateLeftKey(): void {\n this._hasPressedLeftKey = true;\n }\n\n wasLeftKeyPressed(): boolean {\n return this._wasLeftKeyPressed;\n }\n\n simulateHandBrakeKey(): void {\n this._hasPressedHandBrakeKey = true;\n }\n\n wasHandBrakeKeyPressed(): boolean {\n return this._wasHandBrakeKeyPressed;\n }\n\n simulateAcceleratorStick(stickForce: float): void {\n this._acceleratorStickForce = gdjs.evtTools.common.clamp(\n -1,\n 1,\n stickForce\n );\n }\n\n simulateSteeringStick(stickForce: float): void {\n this._steeringStickForce = gdjs.evtTools.common.clamp(-1, 1, stickForce);\n }\n\n getAcceleratorStickForce(): float {\n return this._acceleratorStickForce;\n }\n\n getSteeringStickForce(): float {\n return this._steeringStickForce;\n }\n\n getPreviousAcceleratorStickForce(): float {\n return this._previousAcceleratorStickForce;\n }\n\n getPreviousSteeringStickForce(): float {\n return this._previousSteeringStickForce;\n }\n\n getSteerAngle(): float {\n return this._currentSteerRatio * this._steerAngleMax;\n }\n\n /**\n * @returns The engine current speed in RPM (rotation per minute)\n */\n getEngineSpeed(): float {\n return this._vehicleController\n ? this._vehicleController.GetEngine().GetCurrentRPM()\n : 0;\n }\n\n getCurrentGear(): float {\n return this._vehicleController\n ? this._vehicleController.GetTransmission().GetCurrentGear()\n : 0;\n }\n\n getSteerAngleMax(): float {\n return this._steerAngleMax;\n }\n\n setSteerAngleMax(steerAngleMax: float) {\n this._steerAngleMax = steerAngleMax;\n }\n\n getBeginningSteerSpeed(): float {\n return this._beginningSteerSpeed;\n }\n\n setBeginningSteerSpeed(beginningSteerSpeed: float): void {\n this._beginningSteerSpeed = beginningSteerSpeed;\n }\n\n getEndSteerSpeed(): float {\n return this._endSteerSpeed;\n }\n\n setEndSteerSpeed(endSteerSpeed: float): void {\n this._endSteerSpeed = endSteerSpeed;\n }\n\n invalidateShape(): void {\n const physics3D = this.getPhysics3D();\n if (!physics3D) {\n return;\n }\n const { behavior } = physics3D;\n behavior._needToRecreateShape = true;\n }\n\n getEngineTorqueMax(): float {\n return this._engineTorqueMax;\n }\n\n setEngineTorqueMax(engineTorqueMax: float): void {\n this._engineTorqueMax = engineTorqueMax;\n if (!this._vehicleController) {\n return;\n }\n this._vehicleController.GetEngine().mMaxTorque = engineTorqueMax;\n }\n\n /**\n * @returns The engine maximum speed in RPM (rotation per minute)\n */\n getEngineSpeedMax(): float {\n return this._engineSpeedMax;\n }\n\n setEngineSpeedMax(engineSpeedMax: float): void {\n this._engineSpeedMax = engineSpeedMax;\n if (!this._vehicleController) {\n return;\n }\n this._vehicleController.GetEngine().mMaxRPM = engineSpeedMax;\n }\n\n getEngineInertia(): float {\n return this._engineInertia;\n }\n\n setEngineInertia(engineInertia: float): void {\n this._engineInertia = engineInertia;\n if (!this._vehicleController) {\n return;\n }\n this._vehicleController.GetEngine().mInertia = engineInertia;\n }\n\n getGearRatio(gearNumber: integer): float {\n if (gearNumber === 0) {\n return 0;\n }\n if (gearNumber < 0) {\n return this._reverseGearRatios[-gearNumber - 1] || 0;\n }\n return this._gearRatios[gearNumber - 1] || 0;\n }\n\n setGearRatio(gearNumber: integer, ratio: float) {\n if (gearNumber > 0) {\n this._gearRatios[gearNumber - 1] = ratio;\n if (!this._vehicleController) {\n return;\n }\n this._updateGearRatios();\n } else if (gearNumber < 0) {\n this._reverseGearRatios[-gearNumber - 1] = ratio;\n this._updateReverseGearRatios();\n }\n }\n\n _updateGearRatios() {\n if (!this._vehicleController) {\n return;\n }\n const gearRatios = this._vehicleController.GetTransmission().mGearRatios;\n gearRatios.clear();\n let previousGearRatio = Number.POSITIVE_INFINITY;\n for (let index = 0; index < this._gearRatios.length; index++) {\n const gearRatio = this._gearRatios[index];\n if (0 < gearRatio && gearRatio < previousGearRatio) {\n gearRatios.push_back(gearRatio);\n previousGearRatio = gearRatio;\n }\n }\n }\n\n _updateReverseGearRatios() {\n if (!this._vehicleController) {\n return;\n }\n const reverseGearRatios =\n this._vehicleController.GetTransmission().mReverseGearRatios;\n reverseGearRatios.clear();\n let previousGearRatio = Number.NEGATIVE_INFINITY;\n for (let index = 0; index < this._reverseGearRatios.length; index++) {\n const gearRatio = this._reverseGearRatios[index];\n if (previousGearRatio < gearRatio && gearRatio < 0) {\n reverseGearRatios.push_back(gearRatio);\n previousGearRatio = gearRatio;\n }\n }\n }\n\n getBackWheelOffsetX(): float {\n return this._backWheelOffsetX;\n }\n\n setBackWheelOffsetX(backWheelOffsetX: float): void {\n this._backWheelOffsetX = backWheelOffsetX;\n this._updateWheels();\n }\n\n getFrontWheelOffsetX(): float {\n return this._frontWheelOffsetX;\n }\n\n setFrontWheelOffsetX(frontWheelOffsetX: float): void {\n this._frontWheelOffsetX = frontWheelOffsetX;\n this._updateWheels();\n }\n\n getWheelOffsetY(): float {\n return this._wheelOffsetY;\n }\n\n setWheelOffsetY(wheelOffsetY: float): void {\n this._wheelOffsetY = wheelOffsetY;\n this._updateWheels();\n }\n\n getWheelOffsetZ(): float {\n return this._wheelOffsetZ;\n }\n\n setWheelOffsetZ(wheelOffsetZ: float): void {\n this._wheelOffsetZ = wheelOffsetZ;\n this._updateWheels();\n }\n\n getWheelRadius(): float {\n return this._wheelRadius;\n }\n\n setWheelRadius(wheelRadius: float): void {\n this._wheelRadius = wheelRadius;\n this._updateWheels();\n }\n\n getWheelWidth(): float {\n return this._wheelWidth;\n }\n\n setWheelWidth(wheelWidth: float): void {\n this._wheelWidth = wheelWidth;\n this._updateWheels();\n }\n\n getBrakeTorqueMax(): float {\n return this._brakeTorqueMax;\n }\n\n setBrakeTorqueMax(brakeTorqueMax: float): void {\n this._brakeTorqueMax = brakeTorqueMax;\n this._updateWheels();\n }\n\n getHandBrakeTorqueMax(): float {\n return this._handBrakeTorqueMax;\n }\n\n setHandBrakeTorqueMax(handBrakeTorqueMax: float): void {\n this._handBrakeTorqueMax = handBrakeTorqueMax;\n this._updateWheels();\n }\n\n hasBackWheelDrive(): boolean {\n return this._hasBackWheelDrive;\n }\n\n setBackWheelDrive(hasBackWheelDrive: boolean): void {\n this._hasBackWheelDrive = hasBackWheelDrive;\n this.invalidateShape();\n }\n\n hasFrontWheelDrive(): boolean {\n return this._hasFrontWheelDrive;\n }\n\n setFrontWheelDrive(hasFrontWheelDrive: boolean): void {\n this._hasFrontWheelDrive = hasFrontWheelDrive;\n this.invalidateShape();\n }\n\n getPitchRollAngleMax(): float {\n return this._pitchRollAngleMax;\n }\n\n setPitchRollAngleMax(pitchRollAngleMax: float): void {\n this._pitchRollAngleMax = pitchRollAngleMax;\n if (!this._vehicleController) {\n return;\n }\n this._vehicleController\n .GetConstraint()\n .SetMaxPitchRollAngle(pitchRollAngleMax);\n }\n\n isOnFloor() {\n if (!this._vehicleController) {\n return;\n }\n for (let index = 0; index < 4; index++) {\n const wheel = Jolt.castObject(\n this._vehicleController.GetConstraint().GetWheel(index),\n Jolt.WheelWV\n );\n if (wheel.HasContact()) {\n return true;\n }\n }\n return false;\n }\n\n _updateWheels() {\n if (!this._vehicleController) {\n return;\n }\n const physics3D = this.getPhysics3D();\n if (!physics3D) {\n return;\n }\n const { behavior } = physics3D;\n\n // Retrieved the dimensions set by `createShape`.\n const halfVehicleWidth = behavior._shapeHalfWidth;\n const halfVehicleHeight = behavior._shapeHalfHeight;\n const halfVehicleDepth = behavior._shapeHalfDepth;\n\n const shapeScale =\n behavior.shapeScale * behavior._sharedData.worldInvScale;\n\n const wheelRadius = this._wheelRadius * shapeScale;\n const wheelWidth = this._wheelWidth * shapeScale;\n const backWheelOffsetX =\n halfVehicleWidth - wheelRadius + this._backWheelOffsetX * shapeScale;\n const frontWheelOffsetX =\n halfVehicleWidth - wheelRadius + this._frontWheelOffsetX * shapeScale;\n const wheelOffsetY =\n halfVehicleHeight - wheelWidth / 2 + this._wheelOffsetY * shapeScale;\n // Put the wheels center at the bottom of the car physics shape.\n const wheelOffsetZ =\n halfVehicleDepth +\n (-behavior.shapeOffsetZ + this._wheelOffsetZ) * shapeScale;\n const suspensionMinLength = wheelRadius;\n const suspensionMaxLength = 1.5 * suspensionMinLength;\n\n const constraint = this._vehicleController.GetConstraint();\n const fl = constraint.GetWheel(0).GetSettings();\n fl.mPosition = this.getVec3(\n frontWheelOffsetX,\n -wheelOffsetY,\n -wheelOffsetZ\n );\n const fr = constraint.GetWheel(1).GetSettings();\n fr.mPosition = this.getVec3(\n frontWheelOffsetX,\n wheelOffsetY,\n -wheelOffsetZ\n );\n const bl = constraint.GetWheel(2).GetSettings();\n bl.mPosition = this.getVec3(\n -backWheelOffsetX,\n -wheelOffsetY,\n -wheelOffsetZ\n );\n const br = constraint.GetWheel(3).GetSettings();\n br.mPosition = this.getVec3(\n -backWheelOffsetX,\n wheelOffsetY,\n -wheelOffsetZ\n );\n for (let index = 0; index < 4; index++) {\n const wheel = Jolt.castObject(\n constraint.GetWheel(index),\n Jolt.WheelWV\n ).GetSettings();\n wheel.mRadius = wheelRadius;\n wheel.mWidth = wheelWidth;\n wheel.mSuspensionMinLength = suspensionMinLength;\n wheel.mSuspensionMaxLength = suspensionMaxLength;\n wheel.mMaxBrakeTorque = this._brakeTorqueMax;\n if (index >= 2) {\n wheel.mMaxHandBrakeTorque = this._handBrakeTorqueMax;\n }\n }\n }\n }\n\n gdjs.registerBehavior(\n 'Physics3D::PhysicsCar3D',\n gdjs.PhysicsCar3DRuntimeBehavior\n );\n\n export namespace PhysicsCar3DRuntimeBehavior {\n export class VehicleBodyUpdater\n implements gdjs.Physics3DRuntimeBehavior.BodyUpdater\n {\n carBehavior: gdjs.PhysicsCar3DRuntimeBehavior;\n physicsBodyUpdater: gdjs.Physics3DRuntimeBehavior.BodyUpdater;\n\n constructor(\n carBehavior: gdjs.PhysicsCar3DRuntimeBehavior,\n physicsBodyUpdater: gdjs.Physics3DRuntimeBehavior.BodyUpdater\n ) {\n this.carBehavior = carBehavior;\n this.physicsBodyUpdater = physicsBodyUpdater;\n }\n\n private getVec3(x: float, y: float, z: float): Jolt.Vec3 {\n const tempVec3 = this.carBehavior._sharedData._tempVec3;\n tempVec3.Set(x, y, z);\n return tempVec3;\n }\n\n createAndAddBody(): Jolt.Body | null {\n const physics3D = this.carBehavior.getPhysics3D();\n if (!physics3D) {\n return null;\n }\n const { behavior } = physics3D;\n const { _sharedData } = this.carBehavior;\n\n const carShape = behavior.createShape();\n\n // Create car body\n const carBodySettings = new Jolt.BodyCreationSettings(\n carShape,\n this.carBehavior._getPhysicsPosition(_sharedData.getRVec3(0, 0, 0)),\n behavior._getPhysicsRotation(_sharedData.getQuat(0, 0, 0, 1)),\n Jolt.EMotionType_Dynamic,\n behavior.getBodyLayer()\n );\n carBodySettings.mFriction = behavior.friction;\n carBodySettings.mRestitution = behavior.restitution;\n carBodySettings.mLinearDamping = behavior.linearDamping;\n carBodySettings.mAngularDamping = behavior.angularDamping;\n carBodySettings.mGravityFactor = behavior.gravityScale;\n if (behavior.massOverride > 0) {\n carBodySettings.mOverrideMassProperties =\n Jolt.EOverrideMassProperties_CalculateInertia;\n carBodySettings.mMassPropertiesOverride.mMass = behavior.massOverride;\n }\n const carBody = _sharedData.bodyInterface.CreateBody(carBodySettings);\n Jolt.destroy(carBodySettings);\n _sharedData.bodyInterface.AddBody(\n carBody.GetID(),\n Jolt.EActivation_Activate\n );\n\n // Create vehicle constraint\n const vehicle = new Jolt.VehicleConstraintSettings();\n vehicle.mUp = this.getVec3(0, 0, 1);\n vehicle.mForward = this.getVec3(1, 0, 0);\n vehicle.mMaxPitchRollAngle = gdjs.toRad(\n this.carBehavior._pitchRollAngleMax\n );\n\n const FL_WHEEL = 0;\n const FR_WHEEL = 1;\n const BL_WHEEL = 2;\n const BR_WHEEL = 3;\n {\n const setupWheel = (wheelS: Jolt.WheelSettingsWV) => {\n wheelS.mWheelUp = this.getVec3(0, 0, 1);\n wheelS.mWheelForward = this.getVec3(1, 0, 0);\n wheelS.mSuspensionDirection = this.getVec3(0, 0, -1);\n wheelS.mSteeringAxis = this.getVec3(0, 0, 1);\n };\n\n // vehicle.mWheels is a Array of Ref (smart pointer).\n // They are destroyed automatically.\n vehicle.mWheels.clear();\n\n const fl = new Jolt.WheelSettingsWV();\n fl.mMaxSteerAngle = gdjs.toRad(this.carBehavior._steerAngleMax);\n // Front wheel doesn't have hand brake\n fl.mMaxHandBrakeTorque = 0.0;\n setupWheel(fl);\n vehicle.mWheels.push_back(fl);\n\n const fr = new Jolt.WheelSettingsWV();\n fr.mMaxSteerAngle = gdjs.toRad(this.carBehavior._steerAngleMax);\n fr.mMaxHandBrakeTorque = 0.0;\n setupWheel(fr);\n vehicle.mWheels.push_back(fr);\n\n const bl = new Jolt.WheelSettingsWV();\n bl.mMaxSteerAngle = 0.0;\n setupWheel(bl);\n vehicle.mWheels.push_back(bl);\n\n const br = new Jolt.WheelSettingsWV();\n br.mMaxSteerAngle = 0.0;\n setupWheel(br);\n vehicle.mWheels.push_back(br);\n }\n\n const controllerSettings = new Jolt.WheeledVehicleControllerSettings();\n controllerSettings.mEngine.mMaxTorque =\n this.carBehavior._engineTorqueMax;\n controllerSettings.mEngine.mMaxRPM = this.carBehavior._engineSpeedMax;\n controllerSettings.mEngine.mInertia = this.carBehavior._engineInertia;\n // vehicle.mController is a Ref (smart pointer).\n // It is destroyed with the vehicle.\n vehicle.mController = controllerSettings;\n\n const fourWheelDrive =\n this.carBehavior._hasBackWheelDrive &&\n this.carBehavior._hasFrontWheelDrive;\n controllerSettings.mDifferentials.clear();\n\n // Front differential\n if (this.carBehavior._hasFrontWheelDrive) {\n const frontWheelDrive = new Jolt.VehicleDifferentialSettings();\n frontWheelDrive.mLeftWheel = FL_WHEEL;\n frontWheelDrive.mRightWheel = FR_WHEEL;\n if (fourWheelDrive) {\n // Split engine torque when 4 wheels drive\n frontWheelDrive.mEngineTorqueRatio = 0.5;\n }\n controllerSettings.mDifferentials.push_back(frontWheelDrive);\n }\n\n // Rear differential\n if (this.carBehavior._hasBackWheelDrive) {\n const rearWheelDrive = new Jolt.VehicleDifferentialSettings();\n rearWheelDrive.mLeftWheel = BL_WHEEL;\n rearWheelDrive.mRightWheel = BR_WHEEL;\n if (fourWheelDrive) {\n // Split engine torque when 4 wheels drive\n rearWheelDrive.mEngineTorqueRatio = 0.5;\n }\n controllerSettings.mDifferentials.push_back(rearWheelDrive);\n }\n\n // Anti-roll bars\n vehicle.mAntiRollBars.clear();\n const frontRollBar = new Jolt.VehicleAntiRollBar();\n frontRollBar.mLeftWheel = FL_WHEEL;\n frontRollBar.mRightWheel = FR_WHEEL;\n const rearRollBar = new Jolt.VehicleAntiRollBar();\n rearRollBar.mLeftWheel = BL_WHEEL;\n rearRollBar.mRightWheel = BR_WHEEL;\n vehicle.mAntiRollBars.push_back(frontRollBar);\n vehicle.mAntiRollBars.push_back(rearRollBar);\n\n const constraint = new Jolt.VehicleConstraint(carBody, vehicle);\n Jolt.destroy(vehicle);\n\n // VehicleConstraint.mVehicleCollisionTester is a RefConst (smart pointer)\n // previously created ones are destroyed automatically.\n const vehicleCollisionTester =\n new Jolt.VehicleCollisionTesterCastCylinder(\n behavior.getBodyLayer(),\n 0.05\n );\n constraint.SetVehicleCollisionTester(vehicleCollisionTester);\n this.carBehavior._vehicleCollisionTester = vehicleCollisionTester;\n\n if (this.carBehavior._vehicleController) {\n const constraint =\n this.carBehavior._vehicleController.GetConstraint();\n this.carBehavior._sharedData.physicsSystem.RemoveConstraint(\n constraint\n );\n }\n _sharedData.physicsSystem.AddConstraint(constraint);\n this.carBehavior._vehicleController = Jolt.castObject(\n constraint.GetController(),\n Jolt.WheeledVehicleController\n );\n if (this.carBehavior._stepListener) {\n _sharedData.physicsSystem.RemoveStepListener(\n this.carBehavior._stepListener\n );\n }\n this.carBehavior._stepListener = new Jolt.VehicleConstraintStepListener(\n constraint\n );\n _sharedData.physicsSystem.AddStepListener(\n this.carBehavior._stepListener\n );\n this.carBehavior._updateWheels();\n this.carBehavior._updateGearRatios();\n this.carBehavior._updateReverseGearRatios();\n return carBody;\n }\n\n updateObjectFromBody() {\n this.physicsBodyUpdater.updateObjectFromBody();\n }\n\n updateBodyFromObject() {\n this.physicsBodyUpdater.updateBodyFromObject();\n }\n\n recreateShape() {\n this.physicsBodyUpdater.recreateShape();\n this.carBehavior._updateWheels();\n }\n\n destroyBody() {\n this.carBehavior._destroyBody();\n this.physicsBodyUpdater.destroyBody();\n }\n }\n }\n}\n"],
5
- "mappings": "AAEA,GAAU,MAAV,UAAU,EAAV,CAsBS,eACG,GAAK,eAEf,CAyEE,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,SAAY,cAAc,cAAc,GACxC,KAAK,YAAY,mBAAqB,KAAK,WACzC,EAAW,gBACX,KAAK,0BAEH,KAAK,YAAY,eACnB,EAAY,cAAc,mBACxB,KAAK,YAAY,eAGrB,KAAK,YAAY,cAAgB,GAAI,MAAK,8BACxC,GAEF,EAAY,cAAc,gBACxB,KAAK,YAAY,eAEnB,KAAK,YAAY,gBACjB,KAAK,YAAY,oBACjB,KAAK,YAAY,2BACV,EAGT,sBAAuB,CACrB,KAAK,mBAAmB,uBAG1B,sBAAuB,CACrB,KAAK,mBAAmB,uBAG1B,eAAgB,CACd,KAAK,mBAAmB,gBACxB,KAAK,YAAY,gBAGnB,aAAc,CACZ,KAAK,YAAY,eACjB,KAAK,mBAAmB,eAjNrB,EAAM,sBADE,uEAt5BT",
4
+ "sourcesContent": ["/// <reference path=\"./jolt-physics.d.ts\" />\n\nnamespace gdjs {\n interface PhysicsCar3DNetworkSyncDataType {\n lek: boolean;\n rik: boolean;\n upk: boolean;\n dok: boolean;\n hbk: boolean;\n asf: float;\n ssf: float;\n etm: float;\n esm: float;\n ei: float;\n es: float;\n }\n\n export interface PhysicsCar3DNetworkSyncData extends BehaviorNetworkSyncData {\n props: PhysicsCar3DNetworkSyncDataType;\n }\n\n type Physics3D = {\n behavior: gdjs.Physics3DRuntimeBehavior;\n };\n\n export class PhysicsCar3DRuntimeBehavior\n extends gdjs.RuntimeBehavior\n implements gdjs.Physics3DRuntimeBehavior.Physics3DHook\n {\n owner3D: gdjs.RuntimeObject3D;\n private _physics3DBehaviorName: string;\n private _physics3D: Physics3D | null = null;\n private _isHookedToPhysicsStep = false;\n _vehicleController: Jolt.WheeledVehicleController | null = null;\n _stepListener: Jolt.VehicleConstraintStepListener | null = null;\n _vehicleCollisionTester: Jolt.VehicleCollisionTesterCastCylinder | null =\n null;\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: gdjs.Physics3DSharedData;\n private _destroyedDuringFrameLogic: boolean = false;\n\n // Readonly configuration\n\n _steerAngleMax;\n private _beginningSteerSpeed: float;\n private _endSteerSpeed: float;\n _gearRatios: Array<float>;\n _reverseGearRatios: Array<float>;\n private _backWheelOffsetX: float;\n private _frontWheelOffsetX: float;\n private _wheelOffsetY: float;\n private _wheelOffsetZ: float;\n private _wheelRadius: float;\n private _wheelWidth: float;\n private _brakeTorqueMax: float;\n private _handBrakeTorqueMax: float;\n _hasBackWheelDrive: boolean;\n _hasFrontWheelDrive: boolean;\n _pitchRollAngleMax: float;\n\n // Mutable configuration\n\n _engineTorqueMax: float;\n /** in RPM (rotation per minute) */\n _engineSpeedMax: float;\n _engineInertia: float;\n\n // State\n\n private _currentSteerRatio: float = 0;\n /** Used to make sure the car is stopped before going backward. */\n _previousForward = 1;\n\n private _hasPressedForwardKey: boolean = false;\n private _hasPressedBackwardKey: boolean = false;\n private _hasPressedRightKey: boolean = false;\n private _hasPressedLeftKey: boolean = false;\n private _hasPressedHandBrakeKey: boolean = false;\n private _acceleratorStickForce: float = 0;\n private _steeringStickForce: float = 0;\n\n // This is useful for extensions that need to know\n // which keys were pressed and doesn't know the mapping\n // done by the scene events.\n private _wasLeftKeyPressed: boolean = false;\n private _wasRightKeyPressed: boolean = false;\n private _wasForwardKeyPressed: boolean = false;\n private _wasBackwardKeyPressed: boolean = false;\n private _wasHandBrakeKeyPressed: boolean = false;\n private _previousAcceleratorStickForce: float = 0;\n private _previousSteeringStickForce: float = 0;\n\n // This is useful when the object is synchronized by an external source\n // like in a multiplayer game, and we want to be able to predict the\n // movement of the object, even if the inputs are not updated every frame.\n private _clearInputsBetweenFrames: boolean = true;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData,\n owner: gdjs.RuntimeObject3D\n ) {\n super(instanceContainer, behaviorData, owner);\n this.owner3D = owner;\n this._physics3DBehaviorName = behaviorData.physics3D;\n this._sharedData = gdjs.Physics3DSharedData.getSharedData(\n instanceContainer.getScene(),\n behaviorData.Physics3D\n );\n this._steerAngleMax = behaviorData.steerAngleMax;\n this._beginningSteerSpeed = behaviorData.beginningSteerSpeed;\n this._endSteerSpeed = behaviorData.endSteerSpeed;\n this._engineTorqueMax = behaviorData.engineTorqueMax;\n this._engineSpeedMax = behaviorData.engineSpeedMax;\n this._engineInertia = behaviorData.engineInertia;\n this._reverseGearRatios = [behaviorData.reverseGearRatio1];\n this._gearRatios = [\n behaviorData.gearRatio1,\n behaviorData.gearRatio2,\n behaviorData.gearRatio3,\n behaviorData.gearRatio4,\n behaviorData.gearRatio5,\n behaviorData.gearRatio6,\n ];\n this._backWheelOffsetX = behaviorData.backWheelOffsetX;\n this._frontWheelOffsetX = behaviorData.frontWheelOffsetX;\n this._wheelOffsetY = behaviorData.wheelOffsetY;\n this._wheelOffsetZ = behaviorData.wheelOffsetZ;\n this._wheelRadius = behaviorData.wheelRadius;\n this._wheelWidth = behaviorData.wheelWidth;\n this._brakeTorqueMax = behaviorData.brakeTorqueMax;\n this._handBrakeTorqueMax = behaviorData.handBrakeTorqueMax;\n this._hasBackWheelDrive = behaviorData.hasBackWheelDrive;\n this._hasFrontWheelDrive = behaviorData.hasFrontWheelDrive;\n this._pitchRollAngleMax = behaviorData.pitchRollAngleMax;\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 getPhysics3D(): Physics3D | null {\n if (this._destroyedDuringFrameLogic) {\n return null;\n }\n if (this._physics3D) {\n return this._physics3D;\n }\n const behavior = this.owner.getBehavior(\n this._physics3DBehaviorName\n ) as gdjs.Physics3DRuntimeBehavior;\n if (!behavior.activated()) {\n return null;\n }\n\n const sharedData = behavior._sharedData;\n\n this._physics3D = {\n behavior,\n };\n if (!this._isHookedToPhysicsStep) {\n sharedData.registerHook(this);\n this._isHookedToPhysicsStep = true;\n }\n\n // Destroy the body before switching the bodyUpdater,\n // to ensure the body of the previous bodyUpdater is not left alive.\n // (would be a memory leak and would create a phantom body in the physics world)\n // But transfer the linear and angular velocity to the new body,\n // so the body doesn't stop when it is recreated.\n let previousBodyData = {\n linearVelocityX: 0,\n linearVelocityY: 0,\n linearVelocityZ: 0,\n angularVelocityX: 0,\n angularVelocityY: 0,\n angularVelocityZ: 0,\n };\n if (behavior._body) {\n const linearVelocity = behavior._body.GetLinearVelocity();\n previousBodyData.linearVelocityX = linearVelocity.GetX();\n previousBodyData.linearVelocityY = linearVelocity.GetY();\n previousBodyData.linearVelocityZ = linearVelocity.GetZ();\n const angularVelocity = behavior._body.GetAngularVelocity();\n previousBodyData.angularVelocityX = angularVelocity.GetX();\n previousBodyData.angularVelocityY = angularVelocity.GetY();\n previousBodyData.angularVelocityZ = angularVelocity.GetZ();\n behavior.bodyUpdater.destroyBody();\n }\n\n behavior.bodyUpdater =\n new gdjs.PhysicsCar3DRuntimeBehavior.VehicleBodyUpdater(\n this,\n behavior.bodyUpdater\n );\n behavior.recreateBody(previousBodyData);\n\n return this._physics3D;\n }\n\n override updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {\n if (oldBehaviorData.steerAngleMax !== newBehaviorData.steerAngleMax) {\n this.setSteerAngleMax(newBehaviorData.steerAngleMax);\n }\n if (\n oldBehaviorData.beginningSteerSpeed !==\n newBehaviorData.beginningSteerSpeed\n ) {\n this.setBeginningSteerSpeed(newBehaviorData.beginningSteerSpeed);\n }\n if (oldBehaviorData.endSteerSpeed !== newBehaviorData.endSteerSpeed) {\n this.setEndSteerSpeed(newBehaviorData.endSteerSpeed);\n }\n if (oldBehaviorData.engineTorqueMax !== newBehaviorData.engineTorqueMax) {\n this.setEngineTorqueMax(newBehaviorData.engineTorqueMax);\n }\n if (oldBehaviorData.engineSpeedMax !== newBehaviorData.engineSpeedMax) {\n this.setEngineSpeedMax(newBehaviorData.engineSpeedMax);\n }\n if (oldBehaviorData.engineInertia !== newBehaviorData.engineInertia) {\n this.setEngineInertia(newBehaviorData.engineInertia);\n }\n if (\n oldBehaviorData.reverseGearRatio1 !== newBehaviorData.reverseGearRatio1\n ) {\n this.setGearRatio(-1, newBehaviorData.reverseGearRatio1);\n }\n if (oldBehaviorData.gearRatio1 !== newBehaviorData.gearRatio1) {\n this.setGearRatio(1, newBehaviorData.gearRatio1);\n }\n if (oldBehaviorData.gearRatio2 !== newBehaviorData.gearRatio2) {\n this.setGearRatio(2, newBehaviorData.gearRatio2);\n }\n if (oldBehaviorData.gearRatio3 !== newBehaviorData.gearRatio3) {\n this.setGearRatio(3, newBehaviorData.gearRatio3);\n }\n if (oldBehaviorData.gearRatio4 !== newBehaviorData.gearRatio4) {\n this.setGearRatio(4, newBehaviorData.gearRatio4);\n }\n if (oldBehaviorData.gearRatio5 !== newBehaviorData.gearRatio5) {\n this.setGearRatio(5, newBehaviorData.gearRatio5);\n }\n if (oldBehaviorData.gearRatio6 !== newBehaviorData.gearRatio6) {\n this.setGearRatio(6, newBehaviorData.gearRatio6);\n }\n if (\n oldBehaviorData.backWheelOffsetX !== newBehaviorData.backWheelOffsetX\n ) {\n this.setBackWheelOffsetX(newBehaviorData.backWheelOffsetX);\n }\n if (\n oldBehaviorData.frontWheelOffsetX !== newBehaviorData.frontWheelOffsetX\n ) {\n this.setFrontWheelOffsetX(newBehaviorData.frontWheelOffsetX);\n }\n if (oldBehaviorData.wheelOffsetY !== newBehaviorData.wheelOffsetY) {\n this.setWheelOffsetY(newBehaviorData.wheelOffsetY);\n }\n if (oldBehaviorData.wheelOffsetZ !== newBehaviorData.wheelOffsetZ) {\n this.setWheelOffsetZ(newBehaviorData.wheelOffsetZ);\n }\n if (oldBehaviorData.wheelRadius !== newBehaviorData.wheelRadius) {\n this.setWheelRadius(newBehaviorData.wheelRadius);\n }\n if (oldBehaviorData.wheelWidth !== newBehaviorData.wheelWidth) {\n this.setWheelWidth(newBehaviorData.wheelWidth);\n }\n if (oldBehaviorData.brakeTorqueMax !== newBehaviorData.brakeTorqueMax) {\n this.setBrakeTorqueMax(newBehaviorData.brakeTorqueMax);\n }\n if (\n oldBehaviorData.handBrakeTorqueMax !==\n newBehaviorData.handBrakeTorqueMax\n ) {\n this.setHandBrakeTorqueMax(newBehaviorData.handBrakeTorqueMax);\n }\n if (\n oldBehaviorData.hasBackWheelDrive !== newBehaviorData.hasBackWheelDrive\n ) {\n this.setBackWheelDrive(newBehaviorData.hasBackWheelDrive);\n }\n if (\n oldBehaviorData.hasFrontWheelDrive !==\n newBehaviorData.hasFrontWheelDrive\n ) {\n this.setFrontWheelDrive(newBehaviorData.hasFrontWheelDrive);\n }\n if (\n oldBehaviorData.pitchRollAngleMax !== newBehaviorData.pitchRollAngleMax\n ) {\n this.setPitchRollAngleMax(newBehaviorData.pitchRollAngleMax);\n }\n return true;\n }\n\n override getNetworkSyncData(\n syncOptions: GetNetworkSyncDataOptions\n ): PhysicsCar3DNetworkSyncData {\n // This method is called, so we are synchronizing this object.\n // Let's clear the inputs between frames as we control it.\n this._clearInputsBetweenFrames = true;\n\n return {\n ...super.getNetworkSyncData(syncOptions),\n props: {\n lek: this._wasLeftKeyPressed,\n rik: this._wasRightKeyPressed,\n upk: this._wasForwardKeyPressed,\n dok: this._wasBackwardKeyPressed,\n hbk: this._wasHandBrakeKeyPressed,\n asf: this._previousAcceleratorStickForce,\n ssf: this._previousSteeringStickForce,\n etm: this._engineTorqueMax,\n esm: this._engineSpeedMax,\n ei: this._engineInertia,\n es: this.getEngineSpeed(),\n },\n };\n }\n\n override updateFromNetworkSyncData(\n networkSyncData: PhysicsCar3DNetworkSyncData,\n options: UpdateFromNetworkSyncDataOptions\n ) {\n super.updateFromNetworkSyncData(networkSyncData, options);\n\n const behaviorSpecificProps = networkSyncData.props;\n this._hasPressedForwardKey = behaviorSpecificProps.upk;\n this._hasPressedBackwardKey = behaviorSpecificProps.dok;\n this._hasPressedLeftKey = behaviorSpecificProps.lek;\n this._hasPressedRightKey = behaviorSpecificProps.rik;\n this._hasPressedHandBrakeKey = behaviorSpecificProps.hbk;\n this._acceleratorStickForce = behaviorSpecificProps.asf;\n this._steeringStickForce = behaviorSpecificProps.ssf;\n this._engineTorqueMax = behaviorSpecificProps.etm;\n this._engineSpeedMax = behaviorSpecificProps.esm;\n this._engineInertia = behaviorSpecificProps.ei;\n if (this._vehicleController) {\n this._vehicleController\n .GetEngine()\n .SetCurrentRPM(behaviorSpecificProps.es);\n }\n\n // When the object is synchronized from the network, the inputs must not be cleared,\n // except if asked specifically.\n this._clearInputsBetweenFrames = !!options.clearInputs;\n }\n\n _getPhysicsPosition(result: Jolt.RVec3): Jolt.RVec3 {\n const physics3D = this.getPhysics3D();\n if (!physics3D) {\n result.Set(0, 0, 0);\n return result;\n }\n const { behavior } = physics3D;\n // Same as for characters, the origin is at its feet:\n // - the center is used for X and Y because Box3D origin is at the top-left corner\n // - the origin is used for Z because, when the character is made smaller,\n // it must stay on the ground and not fell from its old size.\n result.Set(\n this.owner3D.getCenterXInScene() * this._sharedData.worldInvScale,\n this.owner3D.getCenterYInScene() * this._sharedData.worldInvScale,\n this.owner3D.getZ() * this._sharedData.worldInvScale +\n behavior._shapeHalfDepth\n );\n return result;\n }\n\n override onDeActivate() {\n if (!this._physics3D) {\n return;\n }\n this._destroyBody();\n }\n\n override onActivate() {\n const behavior = this.owner.getBehavior(\n this._physics3DBehaviorName\n ) as gdjs.Physics3DRuntimeBehavior;\n if (!behavior) {\n return;\n }\n behavior._destroyBody();\n }\n\n override onDestroy() {\n this._destroyedDuringFrameLogic = true;\n this._destroyBody();\n }\n\n _destroyBody() {\n if (!this._vehicleController) {\n return;\n }\n if (this._stepListener) {\n this._sharedData.physicsSystem.RemoveStepListener(this._stepListener);\n Jolt.destroy(this._stepListener);\n this._stepListener = null;\n }\n const constraint = this._vehicleController.GetConstraint();\n this._sharedData.physicsSystem.RemoveConstraint(constraint);\n // The controller is destroyed with the constraint.\n this._vehicleController = null;\n // VehicleConstraint.mVehicleCollisionTester is a RefConst (smart pointer).\n // It is destroyed with the constraint.\n this._vehicleCollisionTester = null;\n if (this._physics3D) {\n const { behavior } = this._physics3D;\n behavior.resetToDefaultBodyUpdater();\n this._physics3D = null;\n }\n }\n\n override doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n // Trigger createAndAddBody()\n this.getPhysics3D();\n }\n\n override doStepPostEvents(\n instanceContainer: gdjs.RuntimeInstanceContainer\n ) {\n // Trigger createAndAddBody()\n this.getPhysics3D();\n }\n\n doBeforePhysicsStep(timeDelta: float): void {\n if (!this.activated()) {\n return;\n }\n const physics3D = this.getPhysics3D();\n if (!physics3D) {\n return;\n }\n const { behavior } = physics3D;\n if (!this._vehicleController) {\n return;\n }\n const carBody = behavior._body;\n if (!carBody) {\n return;\n }\n\n const steeringControl =\n this._steeringStickForce ||\n (this._hasPressedLeftKey ? -1 : 0) + (this._hasPressedRightKey ? 1 : 0);\n if (steeringControl === 0) {\n this._currentSteerRatio = 0;\n } else {\n const steerSpeed = gdjs.evtTools.common.lerp(\n this._beginningSteerSpeed,\n this._endSteerSpeed,\n Math.abs(this._currentSteerRatio)\n );\n if (steeringControl < 0) {\n // Avoid to much latency when changing of direction\n this._currentSteerRatio = Math.min(0, this._currentSteerRatio);\n this._currentSteerRatio +=\n (steeringControl * steerSpeed * timeDelta) / this._steerAngleMax;\n this._currentSteerRatio = Math.max(-1, this._currentSteerRatio);\n }\n if (steeringControl > 0) {\n // Avoid to much latency when changing of direction\n this._currentSteerRatio = Math.max(0, this._currentSteerRatio);\n this._currentSteerRatio +=\n (steeringControl * steerSpeed * timeDelta) / this._steerAngleMax;\n this._currentSteerRatio = Math.min(1, this._currentSteerRatio);\n }\n }\n\n let brake = 0;\n const acceleratorControl =\n this._acceleratorStickForce ||\n (this._hasPressedBackwardKey ? -1 : 0) +\n (this._hasPressedForwardKey ? 1 : 0);\n let forward = acceleratorControl;\n if (this._previousForward * forward < 0.0) {\n const velocity = carBody\n .GetRotation()\n .InverseRotate(carBody.GetLinearVelocity())\n .GetX();\n if (\n (forward > 0.0 && velocity < -0.1) ||\n (forward < 0.0 && velocity > 0.1)\n ) {\n // Brake while we've not stopped yet\n forward = 0.0;\n brake = 1.0;\n } else {\n // When we've come to a stop, accept the new direction\n this._previousForward = forward;\n }\n }\n\n let handBrake = 0;\n if (this._hasPressedHandBrakeKey) {\n forward = 0.0;\n handBrake = 1.0;\n }\n\n this._vehicleController.SetDriverInput(\n forward,\n -this._currentSteerRatio,\n brake,\n handBrake\n );\n if (\n forward !== 0.0 ||\n this._currentSteerRatio !== 0.0 ||\n brake !== 0.0 ||\n handBrake !== 0.0\n ) {\n this._sharedData.bodyInterface.ActivateBody(carBody.GetID());\n }\n\n this._wasForwardKeyPressed = this._hasPressedForwardKey;\n this._wasBackwardKeyPressed = this._hasPressedBackwardKey;\n this._wasRightKeyPressed = this._hasPressedRightKey;\n this._wasLeftKeyPressed = this._hasPressedLeftKey;\n this._wasHandBrakeKeyPressed = this._hasPressedHandBrakeKey;\n this._previousAcceleratorStickForce = this._acceleratorStickForce;\n this._previousSteeringStickForce = this._steeringStickForce;\n\n if (this._clearInputsBetweenFrames) {\n this._hasPressedForwardKey = false;\n this._hasPressedBackwardKey = false;\n this._hasPressedRightKey = false;\n this._hasPressedLeftKey = false;\n this._hasPressedHandBrakeKey = false;\n this._acceleratorStickForce = 0;\n this._steeringStickForce = 0;\n }\n }\n\n override onObjectHotReloaded() {}\n\n simulateForwardKey(): void {\n this._hasPressedForwardKey = true;\n }\n\n wasForwardKeyPressed(): boolean {\n return this._wasForwardKeyPressed;\n }\n\n simulateBackwardKey(): void {\n this._hasPressedBackwardKey = true;\n }\n\n wasBackwardKeyPressed(): boolean {\n return this._wasBackwardKeyPressed;\n }\n\n simulateRightKey(): void {\n this._hasPressedRightKey = true;\n }\n\n wasRightKeyPressed(): boolean {\n return this._wasRightKeyPressed;\n }\n\n simulateLeftKey(): void {\n this._hasPressedLeftKey = true;\n }\n\n wasLeftKeyPressed(): boolean {\n return this._wasLeftKeyPressed;\n }\n\n simulateHandBrakeKey(): void {\n this._hasPressedHandBrakeKey = true;\n }\n\n wasHandBrakeKeyPressed(): boolean {\n return this._wasHandBrakeKeyPressed;\n }\n\n simulateAcceleratorStick(stickForce: float): void {\n this._acceleratorStickForce = gdjs.evtTools.common.clamp(\n -1,\n 1,\n stickForce\n );\n }\n\n simulateSteeringStick(stickForce: float): void {\n this._steeringStickForce = gdjs.evtTools.common.clamp(-1, 1, stickForce);\n }\n\n getAcceleratorStickForce(): float {\n return this._acceleratorStickForce;\n }\n\n getSteeringStickForce(): float {\n return this._steeringStickForce;\n }\n\n getPreviousAcceleratorStickForce(): float {\n return this._previousAcceleratorStickForce;\n }\n\n getPreviousSteeringStickForce(): float {\n return this._previousSteeringStickForce;\n }\n\n getSteerAngle(): float {\n return this._currentSteerRatio * this._steerAngleMax;\n }\n\n /**\n * @returns The engine current speed in RPM (rotation per minute)\n */\n getEngineSpeed(): float {\n return this._vehicleController\n ? this._vehicleController.GetEngine().GetCurrentRPM()\n : 0;\n }\n\n getCurrentGear(): float {\n return this._vehicleController\n ? this._vehicleController.GetTransmission().GetCurrentGear()\n : 0;\n }\n\n getSteerAngleMax(): float {\n return this._steerAngleMax;\n }\n\n setSteerAngleMax(steerAngleMax: float) {\n this._steerAngleMax = steerAngleMax;\n }\n\n getBeginningSteerSpeed(): float {\n return this._beginningSteerSpeed;\n }\n\n setBeginningSteerSpeed(beginningSteerSpeed: float): void {\n this._beginningSteerSpeed = beginningSteerSpeed;\n }\n\n getEndSteerSpeed(): float {\n return this._endSteerSpeed;\n }\n\n setEndSteerSpeed(endSteerSpeed: float): void {\n this._endSteerSpeed = endSteerSpeed;\n }\n\n invalidateShape(): void {\n const physics3D = this.getPhysics3D();\n if (!physics3D) {\n return;\n }\n const { behavior } = physics3D;\n behavior._needToRecreateShape = true;\n }\n\n getEngineTorqueMax(): float {\n return this._engineTorqueMax;\n }\n\n setEngineTorqueMax(engineTorqueMax: float): void {\n this._engineTorqueMax = engineTorqueMax;\n if (!this._vehicleController) {\n return;\n }\n this._vehicleController.GetEngine().mMaxTorque = engineTorqueMax;\n }\n\n /**\n * @returns The engine maximum speed in RPM (rotation per minute)\n */\n getEngineSpeedMax(): float {\n return this._engineSpeedMax;\n }\n\n setEngineSpeedMax(engineSpeedMax: float): void {\n this._engineSpeedMax = engineSpeedMax;\n if (!this._vehicleController) {\n return;\n }\n this._vehicleController.GetEngine().mMaxRPM = engineSpeedMax;\n }\n\n getEngineInertia(): float {\n return this._engineInertia;\n }\n\n setEngineInertia(engineInertia: float): void {\n this._engineInertia = engineInertia;\n if (!this._vehicleController) {\n return;\n }\n this._vehicleController.GetEngine().mInertia = engineInertia;\n }\n\n getGearRatio(gearNumber: integer): float {\n if (gearNumber === 0) {\n return 0;\n }\n if (gearNumber < 0) {\n return this._reverseGearRatios[-gearNumber - 1] || 0;\n }\n return this._gearRatios[gearNumber - 1] || 0;\n }\n\n setGearRatio(gearNumber: integer, ratio: float) {\n if (gearNumber > 0) {\n this._gearRatios[gearNumber - 1] = ratio;\n if (!this._vehicleController) {\n return;\n }\n this._updateGearRatios();\n } else if (gearNumber < 0) {\n this._reverseGearRatios[-gearNumber - 1] = ratio;\n this._updateReverseGearRatios();\n }\n }\n\n _updateGearRatios() {\n if (!this._vehicleController) {\n return;\n }\n const gearRatios = this._vehicleController.GetTransmission().mGearRatios;\n gearRatios.clear();\n let previousGearRatio = Number.POSITIVE_INFINITY;\n for (let index = 0; index < this._gearRatios.length; index++) {\n const gearRatio = this._gearRatios[index];\n if (0 < gearRatio && gearRatio < previousGearRatio) {\n gearRatios.push_back(gearRatio);\n previousGearRatio = gearRatio;\n }\n }\n }\n\n _updateReverseGearRatios() {\n if (!this._vehicleController) {\n return;\n }\n const reverseGearRatios =\n this._vehicleController.GetTransmission().mReverseGearRatios;\n reverseGearRatios.clear();\n let previousGearRatio = Number.NEGATIVE_INFINITY;\n for (let index = 0; index < this._reverseGearRatios.length; index++) {\n const gearRatio = this._reverseGearRatios[index];\n if (previousGearRatio < gearRatio && gearRatio < 0) {\n reverseGearRatios.push_back(gearRatio);\n previousGearRatio = gearRatio;\n }\n }\n }\n\n getBackWheelOffsetX(): float {\n return this._backWheelOffsetX;\n }\n\n setBackWheelOffsetX(backWheelOffsetX: float): void {\n this._backWheelOffsetX = backWheelOffsetX;\n this._updateWheels();\n }\n\n getFrontWheelOffsetX(): float {\n return this._frontWheelOffsetX;\n }\n\n setFrontWheelOffsetX(frontWheelOffsetX: float): void {\n this._frontWheelOffsetX = frontWheelOffsetX;\n this._updateWheels();\n }\n\n getWheelOffsetY(): float {\n return this._wheelOffsetY;\n }\n\n setWheelOffsetY(wheelOffsetY: float): void {\n this._wheelOffsetY = wheelOffsetY;\n this._updateWheels();\n }\n\n getWheelOffsetZ(): float {\n return this._wheelOffsetZ;\n }\n\n setWheelOffsetZ(wheelOffsetZ: float): void {\n this._wheelOffsetZ = wheelOffsetZ;\n this._updateWheels();\n }\n\n getWheelRadius(): float {\n return this._wheelRadius;\n }\n\n setWheelRadius(wheelRadius: float): void {\n this._wheelRadius = wheelRadius;\n this._updateWheels();\n }\n\n getWheelWidth(): float {\n return this._wheelWidth;\n }\n\n setWheelWidth(wheelWidth: float): void {\n this._wheelWidth = wheelWidth;\n this._updateWheels();\n }\n\n getBrakeTorqueMax(): float {\n return this._brakeTorqueMax;\n }\n\n setBrakeTorqueMax(brakeTorqueMax: float): void {\n this._brakeTorqueMax = brakeTorqueMax;\n this._updateWheels();\n }\n\n getHandBrakeTorqueMax(): float {\n return this._handBrakeTorqueMax;\n }\n\n setHandBrakeTorqueMax(handBrakeTorqueMax: float): void {\n this._handBrakeTorqueMax = handBrakeTorqueMax;\n this._updateWheels();\n }\n\n hasBackWheelDrive(): boolean {\n return this._hasBackWheelDrive;\n }\n\n setBackWheelDrive(hasBackWheelDrive: boolean): void {\n this._hasBackWheelDrive = hasBackWheelDrive;\n this.invalidateShape();\n }\n\n hasFrontWheelDrive(): boolean {\n return this._hasFrontWheelDrive;\n }\n\n setFrontWheelDrive(hasFrontWheelDrive: boolean): void {\n this._hasFrontWheelDrive = hasFrontWheelDrive;\n this.invalidateShape();\n }\n\n getPitchRollAngleMax(): float {\n return this._pitchRollAngleMax;\n }\n\n setPitchRollAngleMax(pitchRollAngleMax: float): void {\n this._pitchRollAngleMax = pitchRollAngleMax;\n if (!this._vehicleController) {\n return;\n }\n this._vehicleController\n .GetConstraint()\n .SetMaxPitchRollAngle(pitchRollAngleMax);\n }\n\n isOnFloor() {\n if (!this._vehicleController) {\n return;\n }\n for (let index = 0; index < 4; index++) {\n const wheel = Jolt.castObject(\n this._vehicleController.GetConstraint().GetWheel(index),\n Jolt.WheelWV\n );\n if (wheel.HasContact()) {\n return true;\n }\n }\n return false;\n }\n\n _updateWheels() {\n if (!this._vehicleController) {\n return;\n }\n const physics3D = this.getPhysics3D();\n if (!physics3D) {\n return;\n }\n const { behavior } = physics3D;\n\n // Retrieved the dimensions set by `createShape`.\n const halfVehicleWidth = behavior._shapeHalfWidth;\n const halfVehicleHeight = behavior._shapeHalfHeight;\n const halfVehicleDepth = behavior._shapeHalfDepth;\n\n const shapeScale =\n behavior.shapeScale * behavior._sharedData.worldInvScale;\n\n const wheelRadius = this._wheelRadius * shapeScale;\n const wheelWidth = this._wheelWidth * shapeScale;\n const backWheelOffsetX =\n halfVehicleWidth - wheelRadius + this._backWheelOffsetX * shapeScale;\n const frontWheelOffsetX =\n halfVehicleWidth - wheelRadius + this._frontWheelOffsetX * shapeScale;\n const wheelOffsetY =\n halfVehicleHeight - wheelWidth / 2 + this._wheelOffsetY * shapeScale;\n // Put the wheels center at the bottom of the car physics shape.\n const wheelOffsetZ =\n halfVehicleDepth +\n (-behavior.shapeOffsetZ + this._wheelOffsetZ) * shapeScale;\n const suspensionMinLength = wheelRadius;\n const suspensionMaxLength = 1.5 * suspensionMinLength;\n\n const constraint = this._vehicleController.GetConstraint();\n const fl = constraint.GetWheel(0).GetSettings();\n fl.mPosition = this.getVec3(\n frontWheelOffsetX,\n -wheelOffsetY,\n -wheelOffsetZ\n );\n const fr = constraint.GetWheel(1).GetSettings();\n fr.mPosition = this.getVec3(\n frontWheelOffsetX,\n wheelOffsetY,\n -wheelOffsetZ\n );\n const bl = constraint.GetWheel(2).GetSettings();\n bl.mPosition = this.getVec3(\n -backWheelOffsetX,\n -wheelOffsetY,\n -wheelOffsetZ\n );\n const br = constraint.GetWheel(3).GetSettings();\n br.mPosition = this.getVec3(\n -backWheelOffsetX,\n wheelOffsetY,\n -wheelOffsetZ\n );\n for (let index = 0; index < 4; index++) {\n const wheel = Jolt.castObject(\n constraint.GetWheel(index),\n Jolt.WheelWV\n ).GetSettings();\n wheel.mRadius = wheelRadius;\n wheel.mWidth = wheelWidth;\n wheel.mSuspensionMinLength = suspensionMinLength;\n wheel.mSuspensionMaxLength = suspensionMaxLength;\n wheel.mMaxBrakeTorque = this._brakeTorqueMax;\n if (index >= 2) {\n wheel.mMaxHandBrakeTorque = this._handBrakeTorqueMax;\n }\n }\n }\n }\n\n gdjs.registerBehavior(\n 'Physics3D::PhysicsCar3D',\n gdjs.PhysicsCar3DRuntimeBehavior\n );\n\n export namespace PhysicsCar3DRuntimeBehavior {\n export class VehicleBodyUpdater\n implements gdjs.Physics3DRuntimeBehavior.BodyUpdater\n {\n carBehavior: gdjs.PhysicsCar3DRuntimeBehavior;\n physicsBodyUpdater: gdjs.Physics3DRuntimeBehavior.BodyUpdater;\n\n constructor(\n carBehavior: gdjs.PhysicsCar3DRuntimeBehavior,\n physicsBodyUpdater: gdjs.Physics3DRuntimeBehavior.BodyUpdater\n ) {\n this.carBehavior = carBehavior;\n this.physicsBodyUpdater = physicsBodyUpdater;\n }\n\n private getVec3(x: float, y: float, z: float): Jolt.Vec3 {\n const tempVec3 = this.carBehavior._sharedData._tempVec3;\n tempVec3.Set(x, y, z);\n return tempVec3;\n }\n\n createAndAddBody(): Jolt.Body | null {\n const physics3D = this.carBehavior.getPhysics3D();\n if (!physics3D) {\n return null;\n }\n const { behavior } = physics3D;\n const { _sharedData } = this.carBehavior;\n\n const carShape = behavior.createShape();\n\n // Create car body\n const carBodySettings = new Jolt.BodyCreationSettings(\n carShape,\n this.carBehavior._getPhysicsPosition(_sharedData.getRVec3(0, 0, 0)),\n behavior._getPhysicsRotation(_sharedData.getQuat(0, 0, 0, 1)),\n Jolt.EMotionType_Dynamic,\n behavior.getBodyLayer()\n );\n carBodySettings.mFriction = behavior.friction;\n carBodySettings.mRestitution = behavior.restitution;\n carBodySettings.mLinearDamping = behavior.linearDamping;\n carBodySettings.mAngularDamping = behavior.angularDamping;\n carBodySettings.mGravityFactor = behavior.gravityScale;\n if (behavior.massOverride > 0) {\n carBodySettings.mOverrideMassProperties =\n Jolt.EOverrideMassProperties_CalculateInertia;\n carBodySettings.mMassPropertiesOverride.mMass = behavior.massOverride;\n }\n const carBody = _sharedData.bodyInterface.CreateBody(carBodySettings);\n Jolt.destroy(carBodySettings);\n _sharedData.bodyInterface.AddBody(\n carBody.GetID(),\n Jolt.EActivation_Activate\n );\n\n // Create vehicle constraint\n const vehicle = new Jolt.VehicleConstraintSettings();\n vehicle.mUp = this.getVec3(0, 0, 1);\n vehicle.mForward = this.getVec3(1, 0, 0);\n vehicle.mMaxPitchRollAngle = gdjs.toRad(\n this.carBehavior._pitchRollAngleMax\n );\n\n const FL_WHEEL = 0;\n const FR_WHEEL = 1;\n const BL_WHEEL = 2;\n const BR_WHEEL = 3;\n {\n const setupWheel = (wheelS: Jolt.WheelSettingsWV) => {\n wheelS.mWheelUp = this.getVec3(0, 0, 1);\n wheelS.mWheelForward = this.getVec3(1, 0, 0);\n wheelS.mSuspensionDirection = this.getVec3(0, 0, -1);\n wheelS.mSteeringAxis = this.getVec3(0, 0, 1);\n };\n\n // vehicle.mWheels is a Array of Ref (smart pointer).\n // They are destroyed automatically.\n vehicle.mWheels.clear();\n\n const fl = new Jolt.WheelSettingsWV();\n fl.mMaxSteerAngle = gdjs.toRad(this.carBehavior._steerAngleMax);\n // Front wheel doesn't have hand brake\n fl.mMaxHandBrakeTorque = 0.0;\n setupWheel(fl);\n vehicle.mWheels.push_back(fl);\n\n const fr = new Jolt.WheelSettingsWV();\n fr.mMaxSteerAngle = gdjs.toRad(this.carBehavior._steerAngleMax);\n fr.mMaxHandBrakeTorque = 0.0;\n setupWheel(fr);\n vehicle.mWheels.push_back(fr);\n\n const bl = new Jolt.WheelSettingsWV();\n bl.mMaxSteerAngle = 0.0;\n setupWheel(bl);\n vehicle.mWheels.push_back(bl);\n\n const br = new Jolt.WheelSettingsWV();\n br.mMaxSteerAngle = 0.0;\n setupWheel(br);\n vehicle.mWheels.push_back(br);\n }\n\n const controllerSettings = new Jolt.WheeledVehicleControllerSettings();\n controllerSettings.mEngine.mMaxTorque =\n this.carBehavior._engineTorqueMax;\n controllerSettings.mEngine.mMaxRPM = this.carBehavior._engineSpeedMax;\n controllerSettings.mEngine.mInertia = this.carBehavior._engineInertia;\n // vehicle.mController is a Ref (smart pointer).\n // It is destroyed with the vehicle.\n vehicle.mController = controllerSettings;\n\n const fourWheelDrive =\n this.carBehavior._hasBackWheelDrive &&\n this.carBehavior._hasFrontWheelDrive;\n controllerSettings.mDifferentials.clear();\n\n // Front differential\n if (this.carBehavior._hasFrontWheelDrive) {\n const frontWheelDrive = new Jolt.VehicleDifferentialSettings();\n frontWheelDrive.mLeftWheel = FL_WHEEL;\n frontWheelDrive.mRightWheel = FR_WHEEL;\n if (fourWheelDrive) {\n // Split engine torque when 4 wheels drive\n frontWheelDrive.mEngineTorqueRatio = 0.5;\n }\n controllerSettings.mDifferentials.push_back(frontWheelDrive);\n }\n\n // Rear differential\n if (this.carBehavior._hasBackWheelDrive) {\n const rearWheelDrive = new Jolt.VehicleDifferentialSettings();\n rearWheelDrive.mLeftWheel = BL_WHEEL;\n rearWheelDrive.mRightWheel = BR_WHEEL;\n if (fourWheelDrive) {\n // Split engine torque when 4 wheels drive\n rearWheelDrive.mEngineTorqueRatio = 0.5;\n }\n controllerSettings.mDifferentials.push_back(rearWheelDrive);\n }\n\n // Anti-roll bars\n vehicle.mAntiRollBars.clear();\n const frontRollBar = new Jolt.VehicleAntiRollBar();\n frontRollBar.mLeftWheel = FL_WHEEL;\n frontRollBar.mRightWheel = FR_WHEEL;\n const rearRollBar = new Jolt.VehicleAntiRollBar();\n rearRollBar.mLeftWheel = BL_WHEEL;\n rearRollBar.mRightWheel = BR_WHEEL;\n vehicle.mAntiRollBars.push_back(frontRollBar);\n vehicle.mAntiRollBars.push_back(rearRollBar);\n\n const constraint = new Jolt.VehicleConstraint(carBody, vehicle);\n Jolt.destroy(vehicle);\n\n // VehicleConstraint.mVehicleCollisionTester is a RefConst (smart pointer)\n // previously created ones are destroyed automatically.\n const vehicleCollisionTester =\n new Jolt.VehicleCollisionTesterCastCylinder(\n behavior.getBodyLayer(),\n 0.05\n );\n constraint.SetVehicleCollisionTester(vehicleCollisionTester);\n this.carBehavior._vehicleCollisionTester = vehicleCollisionTester;\n\n if (this.carBehavior._vehicleController) {\n const constraint =\n this.carBehavior._vehicleController.GetConstraint();\n this.carBehavior._sharedData.physicsSystem.RemoveConstraint(\n constraint\n );\n }\n _sharedData.physicsSystem.AddConstraint(constraint);\n this.carBehavior._vehicleController = Jolt.castObject(\n constraint.GetController(),\n Jolt.WheeledVehicleController\n );\n if (this.carBehavior._stepListener) {\n _sharedData.physicsSystem.RemoveStepListener(\n this.carBehavior._stepListener\n );\n }\n this.carBehavior._stepListener = new Jolt.VehicleConstraintStepListener(\n constraint\n );\n _sharedData.physicsSystem.AddStepListener(\n this.carBehavior._stepListener\n );\n this.carBehavior._updateWheels();\n this.carBehavior._updateGearRatios();\n this.carBehavior._updateReverseGearRatios();\n return carBody;\n }\n\n updateObjectFromBody() {\n this.physicsBodyUpdater.updateObjectFromBody();\n }\n\n updateBodyFromObject() {\n this.physicsBodyUpdater.updateBodyFromObject();\n }\n\n recreateShape() {\n this.physicsBodyUpdater.recreateShape();\n this.carBehavior._updateWheels();\n }\n\n destroyBody() {\n this.carBehavior._destroyBody();\n this.physicsBodyUpdater.destroyBody();\n }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,GAAI,MAAK,4BAChC,EAAe,WAAa,EAC5B,EAAe,YAAc,EACzB,GAEF,GAAe,mBAAqB,IAEtC,EAAmB,eAAe,UAAU,GAI9C,EAAQ,cAAc,QACtB,KAAM,GAAe,GAAI,MAAK,mBAC9B,EAAa,WAAa,EAC1B,EAAa,YAAc,EAC3B,KAAM,GAAc,GAAI,MAAK,mBAC7B,EAAY,WAAa,EACzB,EAAY,YAAc,EAC1B,EAAQ,cAAc,UAAU,GAChC,EAAQ,cAAc,UAAU,GAEhC,KAAM,GAAa,GAAI,MAAK,kBAAkB,EAAS,GACvD,KAAK,QAAQ,GAIb,KAAM,GACJ,GAAI,MAAK,mCACP,EAAS,eACT,KAKJ,GAHA,EAAW,0BAA0B,GACrC,KAAK,YAAY,wBAA0B,EAEvC,KAAK,YAAY,mBAAoB,CACvC,KAAM,GACJ,KAAK,YAAY,mBAAmB,gBACtC,KAAK,YAAY,YAAY,cAAc,iBACzC,GAGJ,SAAY,cAAc,cAAc,GACxC,KAAK,YAAY,mBAAqB,KAAK,WACzC,EAAW,gBACX,KAAK,0BAEH,KAAK,YAAY,eACnB,EAAY,cAAc,mBACxB,KAAK,YAAY,eAGrB,KAAK,YAAY,cAAgB,GAAI,MAAK,8BACxC,GAEF,EAAY,cAAc,gBACxB,KAAK,YAAY,eAEnB,KAAK,YAAY,gBACjB,KAAK,YAAY,oBACjB,KAAK,YAAY,2BACV,EAGT,sBAAuB,CACrB,KAAK,mBAAmB,uBAG1B,sBAAuB,CACrB,KAAK,mBAAmB,uBAG1B,eAAgB,CACd,KAAK,mBAAmB,gBACxB,KAAK,YAAY,gBAGnB,aAAc,CACZ,KAAK,YAAY,eACjB,KAAK,mBAAmB,eAjNrB,EAAM,sBADE,uEA17BT",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(n){const v=class extends n.RuntimeBehavior{constructor(e,t,r){super(e,t,r);this._physics3D=null;this._isHookedToPhysicsStep=!1;this.character=null;this._destroyedDuringFrameLogic=!1;this._slopeClimbingFactor=1;this._slopeClimbingMinNormalZ=Math.cos(Math.PI/4);this._forwardAngle=0;this._hasPressedForwardKey=!1;this._hasPressedBackwardKey=!1;this._hasPressedRightKey=!1;this._hasPressedLeftKey=!1;this._hasPressedJumpKey=!1;this._hasUsedStick=!1;this._stickAngle=0;this._stickForce=0;this._currentForwardSpeed=0;this._currentSidewaysSpeed=0;this._currentFallSpeed=0;this._canJump=!1;this._currentJumpSpeed=0;this._timeSinceCurrentJumpStart=0;this._jumpKeyHeldSinceJumpStart=!1;this._hasReallyMoved=!1;this._oldPhysicsPosition=[0,0];this._wasLeftKeyPressed=!1;this._wasRightKeyPressed=!1;this._wasForwardKeyPressed=!1;this._wasBackwardKeyPressed=!1;this._wasJumpKeyPressed=!1;this._wasStickUsed=!1;this._dontClearInputsBetweenFrames=!1;this.owner3D=r,this._physics3DBehaviorName=t.physics3D,this._sharedData=n.Physics3DSharedData.getSharedData(e.getScene(),t.Physics3D),this.collisionChecker=new n.PhysicsCharacter3DRuntimeBehavior.CharacterCollisionChecker(this),this.charactersManager=n.PhysicsCharacter3DRuntimeBehavior.CharactersManager.getManager(e),this._slopeMaxAngle=0,this.setSlopeMaxAngle(t.slopeMaxAngle),this._forwardAcceleration=t.forwardAcceleration,this._forwardDeceleration=t.forwardDeceleration,this._forwardSpeedMax=t.forwardSpeedMax,this._sidewaysAcceleration=t.sidewaysAcceleration,this._sidewaysDeceleration=t.sidewaysDeceleration,this._sidewaysSpeedMax=t.sidewaysSpeedMax,this._gravity=t.gravity,this._maxFallingSpeed=t.fallingSpeedMax,this._jumpSustainTime=t.jumpSustainTime,this._jumpSpeed=this.getJumpSpeedToReach(t.jumpHeight),this._shouldBindObjectAndForwardAngle=t.shouldBindObjectAndForwardAngle,this._stairHeightMax=t.stairHeightMax===void 0?20:t.stairHeightMax,this._canBePushed=t.canBePushed===void 0?!0:t.canBePushed}getVec3(e,t,r){const o=this._sharedData._tempVec3;return o.Set(e,t,r),o}getPhysics3D(){if(this._destroyedDuringFrameLogic)return null;if(this._physics3D)return this._physics3D;if(!this.activated())return null;const e=this.owner.getBehavior(this._physics3DBehaviorName);if(!e.activated())return null;const t=e._sharedData,r=t.jolt,o=new Jolt.ExtendedUpdateSettings,s=new Jolt.DefaultBroadPhaseLayerFilter(r.GetObjectVsBroadPhaseLayerFilter(),n.Physics3DSharedData.dynamicBroadPhaseLayerIndex),a=new Jolt.DefaultObjectLayerFilter(r.GetObjectLayerPairFilter(),e.getBodyLayer()),i=new Jolt.BodyFilter,c=new Jolt.ShapeFilter;return this._physics3D={behavior:e,extendedUpdateSettings:o,broadPhaseLayerFilter:s,objectLayerFilter:a,bodyFilter:i,shapeFilter:c},this.setStairHeightMax(this._stairHeightMax),this._isHookedToPhysicsStep||(t.registerHook(this),this._isHookedToPhysicsStep=!0),e.bodyUpdater=new n.PhysicsCharacter3DRuntimeBehavior.CharacterBodyUpdater(this),e.collisionChecker=this.collisionChecker,e.recreateBody(),this._forwardAngle=this.owner.getAngle(),this._physics3D}updateFromBehaviorData(e,t){return e.gravity!==t.gravity&&this.setGravity(t.gravity),e.maxFallingSpeed!==t.maxFallingSpeed&&this.setMaxFallingSpeed(t.maxFallingSpeed),e.forwardAcceleration!==t.forwardAcceleration&&this.setForwardAcceleration(t.forwardAcceleration),e.forwardDeceleration!==t.forwardDeceleration&&this.setForwardDeceleration(t.forwardDeceleration),e.forwardSpeedMax!==t.forwardSpeedMax&&this.setForwardSpeedMax(t.forwardSpeedMax),e.sidewaysAcceleration!==t.sidewaysAcceleration&&this.setSidewaysAcceleration(t.sidewaysAcceleration),e.sidewaysDeceleration!==t.sidewaysDeceleration&&this.setSidewaysDeceleration(t.sidewaysDeceleration),e.sidewaysSpeedMax!==t.sidewaysSpeedMax&&this.setSidewaysSpeedMax(t.sidewaysSpeedMax),e.jumpSustainTime!==t.jumpSustainTime&&this.setJumpSustainTime(t.jumpSustainTime),e.jumpHeight!==t.jumpHeight&&this.setJumpSpeed(this.getJumpSpeedToReach(t.jumpHeight)),e.shouldBindObjectAndForwardAngle!==t.shouldBindObjectAndForwardAngle&&this.setShouldBindObjectAndForwardAngle(t.shouldBindObjectAndForwardAngle),e.stairHeightMax!==t.stairHeightMax&&this.setStairHeightMax(t.stairHeightMax),!0}getNetworkSyncData(){return this._dontClearInputsBetweenFrames=!1,{...super.getNetworkSyncData(),props:{fwa:this._forwardAngle,fws:this._currentForwardSpeed,sws:this._currentSidewaysSpeed,fs:this._currentFallSpeed,js:this._currentJumpSpeed,cj:this._canJump,lek:this._wasLeftKeyPressed,rik:this._wasRightKeyPressed,upk:this._wasForwardKeyPressed,dok:this._wasBackwardKeyPressed,juk:this._wasJumpKeyPressed,us:this._wasStickUsed,sa:this._stickAngle,sf:this._stickForce,tscjs:this._timeSinceCurrentJumpStart,jkhsjs:this._jumpKeyHeldSinceJumpStart}}}updateFromNetworkSyncData(e){super.updateFromNetworkSyncData(e);const t=e.props;this._forwardAngle=t.fwa,this._currentForwardSpeed=t.fws,this._currentSidewaysSpeed=t.sws,this._currentFallSpeed=t.fs,this._currentJumpSpeed=t.js,this._canJump=t.cj,this._hasPressedForwardKey=t.upk,this._hasPressedBackwardKey=t.dok,this._hasPressedLeftKey=t.lek,this._hasPressedRightKey=t.rik,this._hasPressedJumpKey=t.juk,this._hasUsedStick=t.us,this._stickAngle=t.sa,this._stickForce=t.sf,this._timeSinceCurrentJumpStart=t.tscjs,this._jumpKeyHeldSinceJumpStart=t.jkhsjs,this._dontClearInputsBetweenFrames=!0}_getPhysicsPosition(e){const t=this.getPhysics3D();if(!t)return e.Set(0,0,0),e;const{behavior:r}=t;return e.Set(this.owner3D.getCenterXInScene()*this._sharedData.worldInvScale,this.owner3D.getCenterYInScene()*this._sharedData.worldInvScale,this.owner3D.getZ()*this._sharedData.worldInvScale+r._shapeHalfDepth),e}_getPhysicsRotation(e){const t=e.sEulerAngles(this.getVec3(0,0,n.toRad(this.owner3D.getAngle())));return e.Set(t.GetX(),t.GetY(),t.GetZ(),t.GetW()),Jolt.destroy(t),e}_moveObjectToPhysicsPosition(e){const t=this.getPhysics3D();if(!t)return;const{behavior:r}=t;this.owner3D.setCenterXInScene(e.GetX()*this._sharedData.worldScale),this.owner3D.setCenterYInScene(e.GetY()*this._sharedData.worldScale),this.owner3D.setZ((e.GetZ()-r._shapeHalfDepth)*this._sharedData.worldScale)}_moveObjectToPhysicsRotation(e){const t=this.owner3D.get3DRendererObject();t.quaternion.x=e.GetX(),t.quaternion.y=e.GetY(),t.quaternion.z=e.GetZ(),t.quaternion.w=e.GetW();const r=new THREE.Euler(0,0,0,"ZYX");r.setFromQuaternion(t.quaternion),this.owner3D.setAngle(n.toDegrees(r.z))}onDeActivate(){!this._physics3D||this._destroyBody()}onActivate(){const e=this.owner.getBehavior(this._physics3DBehaviorName);!e||e._destroyBody()}onDestroy(){this._destroyedDuringFrameLogic=!0,this.onDeActivate()}_destroyBody(){if(this.character&&(this._canBePushed&&(this.charactersManager.removeCharacter(this.character),Jolt.destroy(this.character.GetListener())),this.collisionChecker.clearContacts(),Jolt.destroy(this.character),this.character=null,this._physics3D)){const{behavior:e}=this._physics3D;e.resetToDefaultBodyUpdater(),e.resetToDefaultCollisionChecker(),this._physics3D.behavior._body=null;const{extendedUpdateSettings:t,broadPhaseLayerFilter:r,objectLayerFilter:o,bodyFilter:s,shapeFilter:a}=this._physics3D;Jolt.destroy(t),Jolt.destroy(r),Jolt.destroy(o),Jolt.destroy(s),Jolt.destroy(a),this._physics3D=null}}doStepPreEvents(e){this.getPhysics3D()}doStepPostEvents(e){this.getPhysics3D()}doBeforePhysicsStep(e){if(!this.activated())return;const t=this.getPhysics3D();if(!t)return;const{behavior:r,extendedUpdateSettings:o,broadPhaseLayerFilter:s,objectLayerFilter:a,bodyFilter:i,shapeFilter:c}=t;if(!this.character||!r._body)return;const h=this._sharedData.worldInvScale,l=this.character.GetPosition().GetX(),C=this.character.GetPosition().GetY(),m=this.character.GetPosition().GetZ();this._shouldBindObjectAndForwardAngle&&(this._forwardAngle=this.owner.getAngle()),this.updateCharacterSpeedFromInputs(e),this._currentJumpSpeed>0&&(this._timeSinceCurrentJumpStart+=e),this._hasPressedJumpKey||(this._jumpKeyHeldSinceJumpStart=!1),this._canJump&&this._hasPressedJumpKey&&!this._jumpKeyHeldSinceJumpStart&&(this._currentJumpSpeed=this._jumpSpeed,this._currentFallSpeed=0,this._canJump=!1,this._jumpKeyHeldSinceJumpStart=!0,this._timeSinceCurrentJumpStart=0),this.isOnFloor()||(this._jumpKeyHeldSinceJumpStart&&this._timeSinceCurrentJumpStart<this._jumpSustainTime||(this._currentJumpSpeed=Math.max(0,this._currentJumpSpeed-this._gravity*e)),this._currentFallSpeed=Math.min(this._maxFallingSpeed,this._currentFallSpeed+this._gravity*e));let F=0,M=0,J=0;if(this.character.IsSupported()&&this.updateGroundVelocity(r,e)){const S=this.character.GetGroundVelocity();F=S.GetX(),M=S.GetY(),J=S.GetZ()}let g=this._currentForwardSpeed,P=this._currentSidewaysSpeed;if(P!==0&&g!==0){const p=Math.hypot(g/this._forwardSpeedMax,P/this._sidewaysSpeedMax);p>1&&(g/=p,P/=p)}g*=h,P*=h;const u=n.toRad(this._forwardAngle),y=Math.cos(u),_=Math.sin(u),f=g*y-P*_,w=g*_+P*y;if(this.character.SetLinearVelocity(this.getVec3(F+f,M+w,(this._currentJumpSpeed-this._currentFallSpeed)*h)),this.isOnFloor()){const p=Math.max(Math.hypot(this.character.GetPosition().GetX()-this._oldPhysicsPosition[0],this.character.GetPosition().GetY()-this._oldPhysicsPosition[1]),Math.hypot(this.character.GetLinearVelocity().GetX(),this.character.GetLinearVelocity().GetY())*e);this._oldPhysicsPosition[0]=this.character.GetPosition().GetX(),this._oldPhysicsPosition[1]=this.character.GetPosition().GetY();const S=Math.max(-.01+1.01*Math.min(-p*this._slopeClimbingFactor,J*e),-this._maxFallingSpeed*h*e);o.mStickToFloorStepDown.Set(0,0,S)}else o.mStickToFloorStepDown.Set(0,0,0);this.character.ExtendedUpdate(e,this.character.GetUp(),o,s,a,i,c,this._sharedData.jolt.GetTempAllocator()),this.collisionChecker.updateContacts(),this.isOnFloor()&&(this._canJump=!0,this._currentFallSpeed=0,this._currentJumpSpeed=0),this._wasForwardKeyPressed=this._hasPressedForwardKey,this._wasBackwardKeyPressed=this._hasPressedBackwardKey,this._wasRightKeyPressed=this._hasPressedRightKey,this._wasLeftKeyPressed=this._hasPressedLeftKey,this._wasJumpKeyPressed=this._hasPressedJumpKey,this._wasStickUsed=this._hasUsedStick,this._dontClearInputsBetweenFrames||(this._hasPressedForwardKey=!1,this._hasPressedBackwardKey=!1,this._hasPressedRightKey=!1,this._hasPressedLeftKey=!1,this._hasPressedJumpKey=!1,this._hasUsedStick=!1),this._hasReallyMoved=Math.abs(this.character.GetPosition().GetX()-l)>v.epsilon||Math.abs(this.character.GetPosition().GetY()-C)>v.epsilon||Math.abs(this.character.GetPosition().GetZ()-m)>v.epsilon}updateCharacterSpeedFromInputs(e){let t=0;this._hasPressedBackwardKey!==this._hasPressedForwardKey?this._hasPressedBackwardKey?t=-this._forwardSpeedMax:this._hasPressedForwardKey&&(t=this._forwardSpeedMax):this._hasUsedStick&&(t=-this._forwardSpeedMax*this._stickForce*Math.sin(n.toRad(this._stickAngle))),this._currentForwardSpeed=v.getAcceleratedSpeed(this._currentForwardSpeed,t,this._forwardSpeedMax,this._forwardAcceleration,this._forwardDeceleration,e);let r=0;this._hasPressedLeftKey!==this._hasPressedRightKey?this._hasPressedLeftKey?r=-this._sidewaysSpeedMax:this._hasPressedRightKey&&(r=this._sidewaysSpeedMax):this._hasUsedStick&&(r=this._sidewaysSpeedMax*this._stickForce*Math.cos(n.toRad(this._stickAngle))),this._currentSidewaysSpeed=v.getAcceleratedSpeed(this._currentSidewaysSpeed,r,this._sidewaysSpeedMax,this._sidewaysAcceleration,this._sidewaysDeceleration,e)}static getAcceleratedSpeed(e,t,r,o,s,a){let i=e;return t<0?e<=t?i=Math.min(t,e+s*a):e<=0?i-=Math.max(-r,o*a):i=Math.max(t,e-Math.max(o,s)*a):t>0?e>=t?i=Math.max(t,e-s*a):e>=0?i=Math.min(r,e+o*a):i=Math.min(t,e+Math.max(o,s)*a):(e<0&&(i=Math.min(e+s*a,0)),e>0&&(i=Math.max(e-s*a,0))),i}updateGroundVelocity(e,t){if(!this.character||!e._body)return!1;const o=this._sharedData.worldInvScale;if(!this.character.IsSupported())return!1;const s=this._sharedData.physicsSystem.GetBodyLockInterface().TryGetBody(this.character.GetGroundBodyID()),a=s.IsKinematic()&&s.GetLinearVelocity().Equals(Jolt.Vec3.prototype.sZero())&&s.GetAngularVelocity().Equals(Jolt.Vec3.prototype.sZero());if(a){const h=s.gdjsAssociatedBehavior;if(h){const l=1/t;s.SetLinearVelocity(this.getVec3((h.owner3D.getX()-h._objectOldX)*o*l,(h.owner3D.getY()-h._objectOldY)*o*l,(h.owner3D.getZ()-h._objectOldZ)*o*l)),s.SetAngularVelocity(this.getVec3(0,0,n.toRad(n.evtTools.common.angleDifference(h.owner3D.getAngle(),h._objectOldRotationZ))*l))}}this.character.UpdateGroundVelocity();const i=s.GetAngularVelocity().GetZ();if(i!==0){const h=i*t;this.character.SetRotation(Jolt.Quat.prototype.sEulerAngles(this.getVec3(0,0,this.character.GetRotation().GetRotationAngle(Jolt.Vec3.prototype.sAxisZ())+h))),this._forwardAngle+=n.toDegrees(h)}a&&(s.SetLinearVelocity(Jolt.Vec3.prototype.sZero()),s.SetAngularVelocity(Jolt.Vec3.prototype.sZero()));const c=1*Math.PI/180;return Math.abs(s.GetAngularVelocity().GetX())<c&&Math.abs(s.GetAngularVelocity().GetY())<c}onObjectHotReloaded(){}getSlopeMaxAngle(){return this._slopeMaxAngle}setSlopeMaxAngle(e){e<0||e>=90||(this._slopeMaxAngle=e,e===45?this._slopeClimbingFactor=1:this._slopeClimbingFactor=Math.max(1/1024,Math.tan(n.toRad(e))),this._slopeClimbingMinNormalZ=Math.min(Math.cos(n.toRad(e)),1-1/1024))}getStairHeightMax(){return this._stairHeightMax}setStairHeightMax(e){this._stairHeightMax=e;const t=this.getPhysics3D();if(!t)return;const{extendedUpdateSettings:r}=t,o=e*this._sharedData.worldInvScale;r.mWalkStairsStepUp=this.getVec3(0,0,o),r.mWalkStairsMinStepForward=.02/.4*o,r.mWalkStairsStepForwardTest=.15/.4*o}getGravity(){return this._gravity}setGravity(e){this._gravity=e}getMaxFallingSpeed(){return this._maxFallingSpeed}setMaxFallingSpeed(e,t=!1){if(t&&!this.isOnFloor()){const r=this._currentFallSpeed-e;r>0&&(this._currentFallSpeed-=r,this._currentJumpSpeed=Math.max(0,this.getCurrentJumpSpeed()-r))}this._maxFallingSpeed=e}getForwardAcceleration(){return this._forwardAcceleration}setForwardAcceleration(e){this._forwardAcceleration=e}getForwardDeceleration(){return this._forwardDeceleration}setForwardDeceleration(e){this._forwardDeceleration=e}getForwardSpeedMax(){return this._forwardSpeedMax}setForwardSpeedMax(e){this._forwardSpeedMax=e}getSidewaysAcceleration(){return this._sidewaysAcceleration}setSidewaysAcceleration(e){this._sidewaysAcceleration=e}getSidewaysDeceleration(){return this._sidewaysDeceleration}setSidewaysDeceleration(e){this._sidewaysDeceleration=e}getSidewaysSpeedMax(){return this._sidewaysSpeedMax}setSidewaysSpeedMax(e){this._sidewaysSpeedMax=e}getJumpSpeed(){return this._jumpSpeed}setJumpSpeed(e){this._jumpSpeed=e}getJumpSustainTime(){return this._jumpSustainTime}setJumpSustainTime(e){this._jumpSustainTime=e}getForwardAngle(){return this._forwardAngle}setForwardAngle(e){this._forwardAngle=e,this._shouldBindObjectAndForwardAngle&&this.owner.setAngle(e)}isForwardAngleAround(e,t){return Math.abs(n.evtTools.common.angleDifference(this._forwardAngle,e))<=t}shouldBindObjectAndForwardAngle(){return this._shouldBindObjectAndForwardAngle}setShouldBindObjectAndForwardAngle(e){this._shouldBindObjectAndForwardAngle=e}getCurrentForwardSpeed(){return this._currentForwardSpeed}setCurrentForwardSpeed(e){this._currentForwardSpeed=e}getCurrentSidewaysSpeed(){return this._currentSidewaysSpeed}setCurrentSidewaysSpeed(e){this._currentSidewaysSpeed=e}getCurrentFallSpeed(){return this._currentFallSpeed}setCurrentFallSpeed(e){this._currentFallSpeed=n.evtTools.common.clamp(e,0,this._maxFallingSpeed)}getCurrentJumpSpeed(){return this._currentJumpSpeed}setCurrentJumpSpeed(e){this._currentJumpSpeed=Math.max(0,e)}canJump(){return this._canJump}setCanJump(){this._canJump=!0}setCanNotAirJump(){(this.isJumping()||this.isFalling())&&(this._canJump=!1)}abortJump(){this.isJumping()&&(this._currentFallSpeed=0,this._currentJumpSpeed=0)}simulateForwardKey(){this._hasPressedForwardKey=!0}wasForwardKeyPressed(){return this._wasForwardKeyPressed}simulateBackwardKey(){this._hasPressedBackwardKey=!0}wasBackwardKeyPressed(){return this._wasBackwardKeyPressed}simulateRightKey(){this._hasPressedRightKey=!0}wasRightKeyPressed(){return this._wasRightKeyPressed}simulateLeftKey(){this._hasPressedLeftKey=!0}wasLeftKeyPressed(){return this._wasLeftKeyPressed}simulateJumpKey(){this._hasPressedJumpKey=!0}wasJumpKeyPressed(){return this._wasJumpKeyPressed}simulateStick(e,t){this._hasUsedStick=!0,this._stickAngle=e,this._stickForce=Math.max(0,Math.min(1,t))}wasStickUsed(){return this._wasStickUsed}getStickAngle(){return this._wasStickUsed?this._stickAngle:0}getStickForce(){return this._wasStickUsed?this._stickForce:0}isOnFloor(){return this.character?this.character.IsSupported()&&this.character.GetGroundNormal().GetZ()>=this._slopeClimbingMinNormalZ&&this._currentJumpSpeed<=this._currentFallSpeed:!1}isOnFloorObject(e){return!e._body||!this.character||!this.isOnFloor()?!1:this.character.GetGroundBodyID().GetIndexAndSequenceNumber()===e._body.GetID().GetIndexAndSequenceNumber()}isJumping(){return this._currentJumpSpeed>0}isFallingWithoutJumping(){return!this.isOnFloor()&&!this.isJumping()}isFalling(){return this.isFallingWithoutJumping()||this.isJumping()&&this._currentFallSpeed>this._currentJumpSpeed}isMovingEvenALittle(){return this._hasReallyMoved&&(this._currentForwardSpeed!==0||this._currentSidewaysSpeed!==0)||this._currentJumpSpeed!==0||this._currentFallSpeed!==0}getJumpSpeedToReach(e){e=-Math.abs(e);const t=this._gravity,r=this._maxFallingSpeed,o=this._jumpSustainTime,s=r/t,a=h=>Math.sqrt(-h*t*2),i=h=>-t*o+r+Math.sqrt(t*t*o*o-2*h*t-r*r);let c=0,d=0;return s>o?(c=-t*o+Math.sqrt(2*t*t*o*o-4*e*t),d=(t*o+c)/(2*t),d<o?c=a(e):d>s&&(c=i(e))):(c=a(e),d=c/t,d>s&&(c=i(e))),c}};let b=v;b.epsilon=2**-20,n.PhysicsCharacter3DRuntimeBehavior=b,n.registerBehavior("Physics3D::PhysicsCharacter3D",n.PhysicsCharacter3DRuntimeBehavior),function(r){class j{constructor(s){this.characterVsCharacterCollision=new Jolt.CharacterVsCharacterCollisionSimple}static getManager(s){return s.charactersManager||(s.charactersManager=new n.PhysicsCharacter3DRuntimeBehavior.CharactersManager(s)),s.charactersManager}addCharacter(s){this.characterVsCharacterCollision.Add(s),s.SetCharacterVsCharacterCollision(this.characterVsCharacterCollision)}removeCharacter(s){this.characterVsCharacterCollision.Remove(s)}destroy(){Jolt.destroy(this.characterVsCharacterCollision)}}r.CharactersManager=j,n.registerRuntimeSceneUnloadedCallback(function(o){n.PhysicsCharacter3DRuntimeBehavior.CharactersManager.getManager(o).destroy()});class e{constructor(s){this.characterBehavior=s}createAndAddBody(){const s=this.characterBehavior.getPhysics3D();if(!s)return null;const{behavior:a}=s,{_slopeMaxAngle:i,owner3D:c,_sharedData:d}=this.characterBehavior,h=a.createShapeWithoutMassCenterOffset(),l=new Jolt.CharacterVirtualSettings;l.mInnerBodyLayer=this.characterBehavior._canBePushed?0:a.getBodyLayer(),l.mInnerBodyShape=h,l.mMass=h.GetMassProperties().get_mMass(),l.mMaxSlopeAngle=n.toRad(i),l.mShape=h,l.mUp=Jolt.Vec3.prototype.sAxisZ(),l.mBackFaceMode=Jolt.EBackFaceMode_CollideWithBackFaces;const C=c.getDepth()*d.worldInvScale,m=c.getWidth()*d.worldInvScale,F=c.getHeight()*d.worldInvScale,M=C/2,J=Math.sqrt(m*F)/2;l.mSupportingVolume=new Jolt.Plane(Jolt.Vec3.prototype.sAxisZ(),M-J*(1-Math.cos(n.toRad(Math.min(i+20,70)))));const g=new Jolt.CharacterVirtual(l,this.characterBehavior._getPhysicsPosition(d.getRVec3(0,0,0)),a._getPhysicsRotation(d.getQuat(0,0,0,1)),d.physicsSystem);Jolt.destroy(l);const P=d.physicsSystem.GetBodyLockInterface().TryGetBody(g.GetInnerBodyID());if(this.characterBehavior.character&&(this.characterBehavior._canBePushed&&(this.characterBehavior.charactersManager.removeCharacter(this.characterBehavior.character),Jolt.destroy(this.characterBehavior.character.GetListener())),Jolt.destroy(this.characterBehavior.character)),this.characterBehavior.character=g,this.characterBehavior._canBePushed){this.characterBehavior.charactersManager.addCharacter(g);const u=new Jolt.CharacterContactListenerJS;u.OnAdjustBodyVelocity=(y,_,f,w)=>{},u.OnContactValidate=(y,_,f)=>!0,u.OnCharacterContactValidate=(y,_,f)=>{const w=Jolt.wrapPointer(y,Jolt.CharacterVirtual),p=Jolt.wrapPointer(_,Jolt.CharacterVirtual),S=d.physicsSystem.GetBodyLockInterface().TryGetBody(w.GetInnerBodyID()),D=d.physicsSystem.GetBodyLockInterface().TryGetBody(p.GetInnerBodyID()),B=S.gdjsAssociatedBehavior,A=D.gdjsAssociatedBehavior;return!B||!A?!0:B.canCollideAgainst(A)},u.OnContactAdded=(y,_,f,w,p,S)=>{},u.OnContactPersisted=(y,_,f,w,p,S)=>{},u.OnContactRemoved=(y,_,f)=>{},u.OnCharacterContactAdded=(y,_,f,w,p,S)=>{},u.OnCharacterContactPersisted=(y,_,f,w,p,S)=>{},u.OnCharacterContactRemoved=(y,_,f)=>{},u.OnContactSolve=(y,_,f,w,p,S,D,B,A)=>{},u.OnCharacterContactSolve=(y,_,f,w,p,S,D,B,A)=>{},g.SetListener(u)}return P}updateObjectFromBody(){const{character:s}=this.characterBehavior;!s||(this.characterBehavior._moveObjectToPhysicsPosition(s.GetPosition()),this.characterBehavior._moveObjectToPhysicsRotation(s.GetRotation()))}updateBodyFromObject(){const s=this.characterBehavior.getPhysics3D();if(!s)return;const{behavior:a}=s,{character:i,owner3D:c,_sharedData:d}=this.characterBehavior;!i||((a._objectOldX!==c.getX()||a._objectOldY!==c.getY()||a._objectOldZ!==c.getZ())&&this.updateCharacterPosition(),(a._objectOldRotationX!==c.getRotationX()||a._objectOldRotationY!==c.getRotationY()||a._objectOldRotationZ!==c.getAngle())&&i.SetRotation(this.characterBehavior._getPhysicsRotation(d.getQuat(0,0,0,1))))}updateCharacterPosition(){const{character:s,_sharedData:a}=this.characterBehavior;!s||s.SetPosition(this.characterBehavior._getPhysicsPosition(a.getRVec3(0,0,0)))}recreateShape(){const s=this.characterBehavior.getPhysics3D();if(!s)return;const{behavior:a,broadPhaseLayerFilter:i,objectLayerFilter:c,bodyFilter:d,shapeFilter:h}=s,{character:l,_sharedData:C}=this.characterBehavior;if(!l)return;const m=a.createShapeWithoutMassCenterOffset();!l.SetShape(m,Number.MAX_VALUE,i,c,d,h,C.jolt.GetTempAllocator())||(l.SetInnerBodyShape(m),l.SetMass(m.GetMassProperties().get_mMass()),this.updateCharacterPosition())}destroyBody(){this.characterBehavior._destroyBody()}}r.CharacterBodyUpdater=e;class t{constructor(s){this._currentContacts=[];this._previousContacts=[];this.characterBehavior=s}clearContacts(){this._previousContacts.length=0,this._currentContacts.length=0}updateContacts(){const s=this._previousContacts;this._previousContacts=this._currentContacts,this._currentContacts=s,this._currentContacts.length=0;const{character:a,_sharedData:i}=this.characterBehavior;if(!a)return;const c=a.GetActiveContacts();for(let d=0;d<c.size();d++){const h=c.at(d),m=i.physicsSystem.GetBodyLockInterface().TryGetBody(h.mBodyB).gdjsAssociatedBehavior;m&&this._currentContacts.push(m)}}isColliding(s){const{character:a}=this.characterBehavior;return a?this._currentContacts.some(i=>i.owner===s):!1}hasCollisionStartedWith(s){const{character:a}=this.characterBehavior;return a?this._currentContacts.some(i=>i.owner===s)&&!this._previousContacts.some(i=>i.owner===s):!1}hasCollisionStoppedWith(s){const{character:a}=this.characterBehavior;return a?!this._currentContacts.some(i=>i.owner===s)&&this._previousContacts.some(i=>i.owner===s):!1}}r.CharacterCollisionChecker=t}(b=n.PhysicsCharacter3DRuntimeBehavior||(n.PhysicsCharacter3DRuntimeBehavior={}))})(gdjs||(gdjs={}));
1
+ var gdjs;(function(l){const v=class extends l.RuntimeBehavior{constructor(e,t,s){super(e,t,s);this._physics3D=null;this._isHookedToPhysicsStep=!1;this.character=null;this._destroyedDuringFrameLogic=!1;this._slopeClimbingFactor=1;this._slopeClimbingMinNormalZ=Math.cos(Math.PI/4);this._forwardAngle=0;this._hasPressedForwardKey=!1;this._hasPressedBackwardKey=!1;this._hasPressedRightKey=!1;this._hasPressedLeftKey=!1;this._hasPressedJumpKey=!1;this._hasUsedStick=!1;this._stickAngle=0;this._stickForce=0;this._currentForwardSpeed=0;this._currentSidewaysSpeed=0;this._currentFallSpeed=0;this._canJump=!1;this._currentJumpSpeed=0;this._timeSinceCurrentJumpStart=0;this._jumpKeyHeldSinceJumpStart=!1;this._hasReallyMoved=!1;this._oldPhysicsPosition=[0,0];this._wasLeftKeyPressed=!1;this._wasRightKeyPressed=!1;this._wasForwardKeyPressed=!1;this._wasBackwardKeyPressed=!1;this._wasJumpKeyPressed=!1;this._wasStickUsed=!1;this._clearInputsBetweenFrames=!0;this.owner3D=s,this._physics3DBehaviorName=t.physics3D,this._sharedData=l.Physics3DSharedData.getSharedData(e.getScene(),t.Physics3D),this.collisionChecker=new l.PhysicsCharacter3DRuntimeBehavior.CharacterCollisionChecker(this),this.charactersManager=l.PhysicsCharacter3DRuntimeBehavior.CharactersManager.getManager(e),this._slopeMaxAngle=0,this.setSlopeMaxAngle(t.slopeMaxAngle),this._forwardAcceleration=t.forwardAcceleration,this._forwardDeceleration=t.forwardDeceleration,this._forwardSpeedMax=t.forwardSpeedMax,this._sidewaysAcceleration=t.sidewaysAcceleration,this._sidewaysDeceleration=t.sidewaysDeceleration,this._sidewaysSpeedMax=t.sidewaysSpeedMax,this._gravity=t.gravity,this._maxFallingSpeed=t.fallingSpeedMax,this._jumpSustainTime=t.jumpSustainTime,this._jumpSpeed=this.getJumpSpeedToReach(t.jumpHeight),this._shouldBindObjectAndForwardAngle=t.shouldBindObjectAndForwardAngle,this._stairHeightMax=t.stairHeightMax===void 0?20:t.stairHeightMax,this._canBePushed=t.canBePushed===void 0?!0:t.canBePushed}getVec3(e,t,s){const o=this._sharedData._tempVec3;return o.Set(e,t,s),o}getPhysics3D(){if(this._destroyedDuringFrameLogic)return null;if(this._physics3D)return this._physics3D;if(!this.activated())return null;const e=this.owner.getBehavior(this._physics3DBehaviorName);if(!e.activated())return null;const t=e._sharedData,s=t.jolt,o=new Jolt.ExtendedUpdateSettings,a=new Jolt.DefaultBroadPhaseLayerFilter(s.GetObjectVsBroadPhaseLayerFilter(),l.Physics3DSharedData.dynamicBroadPhaseLayerIndex),r=new Jolt.DefaultObjectLayerFilter(s.GetObjectLayerPairFilter(),e.getBodyLayer()),i=new Jolt.BodyFilter,h=new Jolt.ShapeFilter;this._physics3D={behavior:e,extendedUpdateSettings:o,broadPhaseLayerFilter:a,objectLayerFilter:r,bodyFilter:i,shapeFilter:h},this.setStairHeightMax(this._stairHeightMax),this._isHookedToPhysicsStep||(t.registerHook(this),this._isHookedToPhysicsStep=!0);let c={linearVelocityX:0,linearVelocityY:0,linearVelocityZ:0,angularVelocityX:0,angularVelocityY:0,angularVelocityZ:0};if(e._body){const n=e._body.GetLinearVelocity();c.linearVelocityX=n.GetX(),c.linearVelocityY=n.GetY(),c.linearVelocityZ=n.GetZ();const d=e._body.GetAngularVelocity();c.angularVelocityX=d.GetX(),c.angularVelocityY=d.GetY(),c.angularVelocityZ=d.GetZ(),e.bodyUpdater.destroyBody()}return e.bodyUpdater=new l.PhysicsCharacter3DRuntimeBehavior.CharacterBodyUpdater(this),e.collisionChecker=this.collisionChecker,e.recreateBody(c),this._forwardAngle=this.owner.getAngle(),this._physics3D}updateFromBehaviorData(e,t){return e.gravity!==t.gravity&&this.setGravity(t.gravity),e.maxFallingSpeed!==t.maxFallingSpeed&&this.setMaxFallingSpeed(t.maxFallingSpeed),e.forwardAcceleration!==t.forwardAcceleration&&this.setForwardAcceleration(t.forwardAcceleration),e.forwardDeceleration!==t.forwardDeceleration&&this.setForwardDeceleration(t.forwardDeceleration),e.forwardSpeedMax!==t.forwardSpeedMax&&this.setForwardSpeedMax(t.forwardSpeedMax),e.sidewaysAcceleration!==t.sidewaysAcceleration&&this.setSidewaysAcceleration(t.sidewaysAcceleration),e.sidewaysDeceleration!==t.sidewaysDeceleration&&this.setSidewaysDeceleration(t.sidewaysDeceleration),e.sidewaysSpeedMax!==t.sidewaysSpeedMax&&this.setSidewaysSpeedMax(t.sidewaysSpeedMax),e.jumpSustainTime!==t.jumpSustainTime&&this.setJumpSustainTime(t.jumpSustainTime),e.jumpHeight!==t.jumpHeight&&this.setJumpSpeed(this.getJumpSpeedToReach(t.jumpHeight)),e.shouldBindObjectAndForwardAngle!==t.shouldBindObjectAndForwardAngle&&this.setShouldBindObjectAndForwardAngle(t.shouldBindObjectAndForwardAngle),e.stairHeightMax!==t.stairHeightMax&&this.setStairHeightMax(t.stairHeightMax),!0}getNetworkSyncData(e){return this._clearInputsBetweenFrames=!0,{...super.getNetworkSyncData(e),props:{sma:this._slopeMaxAngle,shm:this._stairHeightMax,grav:this._gravity,mfs:this._maxFallingSpeed,facc:this._forwardAcceleration,fdec:this._forwardDeceleration,fsm:this._forwardSpeedMax,sacc:this._sidewaysAcceleration,sdec:this._sidewaysDeceleration,ssm:this._sidewaysSpeedMax,jumpspeed:this._jumpSpeed,jumpsustime:this._jumpSustainTime,fwa:this._forwardAngle,sbpa:this._shouldBindObjectAndForwardAngle,fws:this._currentForwardSpeed,sws:this._currentSidewaysSpeed,cfs:this._currentFallSpeed,cjs:this._currentJumpSpeed,cj:this._canJump,lek:this._wasLeftKeyPressed,rik:this._wasRightKeyPressed,upk:this._wasForwardKeyPressed,dok:this._wasBackwardKeyPressed,juk:this._wasJumpKeyPressed,us:this._wasStickUsed,sa:this._stickAngle,sf:this._stickForce,tscjs:this._timeSinceCurrentJumpStart,jkhsjs:this._jumpKeyHeldSinceJumpStart}}}updateFromNetworkSyncData(e,t){super.updateFromNetworkSyncData(e,t);const s=e.props;this._slopeMaxAngle=s.sma,this._stairHeightMax=s.shm,this._gravity=s.grav,this._maxFallingSpeed=s.mfs,this._forwardAcceleration=s.facc,this._forwardDeceleration=s.fdec,this._forwardSpeedMax=s.fsm,this._sidewaysAcceleration=s.sacc,this._sidewaysDeceleration=s.sdec,this._sidewaysSpeedMax=s.ssm,this._jumpSpeed=s.jumpspeed,this._jumpSustainTime=s.jumpsustime,this._forwardAngle=s.fwa,this._shouldBindObjectAndForwardAngle=s.sbpa,this._currentForwardSpeed=s.fws,this._currentSidewaysSpeed=s.sws,this._currentFallSpeed=s.cfs,this._currentJumpSpeed=s.cjs,this._canJump=s.cj,this._hasPressedForwardKey=s.upk,this._hasPressedBackwardKey=s.dok,this._hasPressedLeftKey=s.lek,this._hasPressedRightKey=s.rik,this._hasPressedJumpKey=s.juk,this._hasUsedStick=s.us,this._stickAngle=s.sa,this._stickForce=s.sf,this._timeSinceCurrentJumpStart=s.tscjs,this._jumpKeyHeldSinceJumpStart=s.jkhsjs,this._clearInputsBetweenFrames=!!t.clearInputs}_getPhysicsPosition(e){const t=this.getPhysics3D();if(!t)return e.Set(0,0,0),e;const{behavior:s}=t;return e.Set(this.owner3D.getCenterXInScene()*this._sharedData.worldInvScale,this.owner3D.getCenterYInScene()*this._sharedData.worldInvScale,this.owner3D.getZ()*this._sharedData.worldInvScale+s._shapeHalfDepth),e}_getPhysicsRotation(e){const t=e.sEulerAngles(this.getVec3(0,0,l.toRad(this.owner3D.getAngle())));return e.Set(t.GetX(),t.GetY(),t.GetZ(),t.GetW()),Jolt.destroy(t),e}_moveObjectToPhysicsPosition(e){const t=this.getPhysics3D();if(!t)return;const{behavior:s}=t;this.owner3D.setCenterXInScene(e.GetX()*this._sharedData.worldScale),this.owner3D.setCenterYInScene(e.GetY()*this._sharedData.worldScale),this.owner3D.setZ((e.GetZ()-s._shapeHalfDepth)*this._sharedData.worldScale)}_moveObjectToPhysicsRotation(e){const t=this.owner3D.get3DRendererObject();t.quaternion.x=e.GetX(),t.quaternion.y=e.GetY(),t.quaternion.z=e.GetZ(),t.quaternion.w=e.GetW();const s=new THREE.Euler(0,0,0,"ZYX");s.setFromQuaternion(t.quaternion),this.owner3D.setAngle(l.toDegrees(s.z))}onDeActivate(){!this._physics3D||this._destroyBody()}onActivate(){const e=this.owner.getBehavior(this._physics3DBehaviorName);!e||e._destroyBody()}onDestroy(){this._destroyedDuringFrameLogic=!0,this.onDeActivate()}_destroyBody(){if(this.character&&(this._canBePushed&&(this.charactersManager.removeCharacter(this.character),Jolt.destroy(this.character.GetListener())),this.collisionChecker.clearContacts(),Jolt.destroy(this.character),this.character=null,this._physics3D)){const{behavior:e}=this._physics3D;e.resetToDefaultBodyUpdater(),e.resetToDefaultCollisionChecker(),this._physics3D.behavior._body=null;const{extendedUpdateSettings:t,broadPhaseLayerFilter:s,objectLayerFilter:o,bodyFilter:a,shapeFilter:r}=this._physics3D;Jolt.destroy(t),Jolt.destroy(s),Jolt.destroy(o),Jolt.destroy(a),Jolt.destroy(r),this._physics3D=null}}doStepPreEvents(e){this.getPhysics3D()}doStepPostEvents(e){this.getPhysics3D()}doBeforePhysicsStep(e){if(!this.activated())return;const t=this.getPhysics3D();if(!t)return;const{behavior:s,extendedUpdateSettings:o,broadPhaseLayerFilter:a,objectLayerFilter:r,bodyFilter:i,shapeFilter:h}=t;if(!this.character||!s._body)return;const n=this._sharedData.worldInvScale,d=this.character.GetPosition().GetX(),C=this.character.GetPosition().GetY(),m=this.character.GetPosition().GetZ();this._shouldBindObjectAndForwardAngle&&(this._forwardAngle=this.owner.getAngle()),this.updateCharacterSpeedFromInputs(e),this._currentJumpSpeed>0&&(this._timeSinceCurrentJumpStart+=e),this._hasPressedJumpKey||(this._jumpKeyHeldSinceJumpStart=!1),this._canJump&&this._hasPressedJumpKey&&!this._jumpKeyHeldSinceJumpStart&&(this._currentJumpSpeed=this._jumpSpeed,this._currentFallSpeed=0,this._canJump=!1,this._jumpKeyHeldSinceJumpStart=!0,this._timeSinceCurrentJumpStart=0),this.isOnFloor()||(this._jumpKeyHeldSinceJumpStart&&this._timeSinceCurrentJumpStart<this._jumpSustainTime||(this._currentJumpSpeed=Math.max(0,this._currentJumpSpeed-this._gravity*e)),this._currentFallSpeed=Math.min(this._maxFallingSpeed,this._currentFallSpeed+this._gravity*e));let F=0,M=0,A=0;if(this.character.IsSupported()&&this.updateGroundVelocity(s,e)){const f=this.character.GetGroundVelocity();F=f.GetX(),M=f.GetY(),A=f.GetZ()}let g=this._currentForwardSpeed,P=this._currentSidewaysSpeed;if(P!==0&&g!==0){const p=Math.hypot(g/this._forwardSpeedMax,P/this._sidewaysSpeedMax);p>1&&(g/=p,P/=p)}g*=n,P*=n;const u=l.toRad(this._forwardAngle),y=Math.cos(u),_=Math.sin(u),S=g*y-P*_,w=g*_+P*y;if(this.character.SetLinearVelocity(this.getVec3(F+S,M+w,(this._currentJumpSpeed-this._currentFallSpeed)*n)),this.isOnFloor()){const p=Math.max(Math.hypot(this.character.GetPosition().GetX()-this._oldPhysicsPosition[0],this.character.GetPosition().GetY()-this._oldPhysicsPosition[1]),Math.hypot(this.character.GetLinearVelocity().GetX(),this.character.GetLinearVelocity().GetY())*e);this._oldPhysicsPosition[0]=this.character.GetPosition().GetX(),this._oldPhysicsPosition[1]=this.character.GetPosition().GetY();const f=Math.max(-.01+1.01*Math.min(-p*this._slopeClimbingFactor,A*e),-this._maxFallingSpeed*n*e);o.mStickToFloorStepDown.Set(0,0,f)}else o.mStickToFloorStepDown.Set(0,0,0);this.character.ExtendedUpdate(e,this.character.GetUp(),o,a,r,i,h,this._sharedData.jolt.GetTempAllocator()),this.collisionChecker.updateContacts(),this.isOnFloor()&&(this._canJump=!0,this._currentFallSpeed=0,this._currentJumpSpeed=0),this._wasForwardKeyPressed=this._hasPressedForwardKey,this._wasBackwardKeyPressed=this._hasPressedBackwardKey,this._wasRightKeyPressed=this._hasPressedRightKey,this._wasLeftKeyPressed=this._hasPressedLeftKey,this._wasJumpKeyPressed=this._hasPressedJumpKey,this._wasStickUsed=this._hasUsedStick,this._clearInputsBetweenFrames&&(this._hasPressedForwardKey=!1,this._hasPressedBackwardKey=!1,this._hasPressedRightKey=!1,this._hasPressedLeftKey=!1,this._hasPressedJumpKey=!1,this._hasUsedStick=!1),this._hasReallyMoved=Math.abs(this.character.GetPosition().GetX()-d)>v.epsilon||Math.abs(this.character.GetPosition().GetY()-C)>v.epsilon||Math.abs(this.character.GetPosition().GetZ()-m)>v.epsilon}updateCharacterSpeedFromInputs(e){let t=0;this._hasPressedBackwardKey!==this._hasPressedForwardKey?this._hasPressedBackwardKey?t=-this._forwardSpeedMax:this._hasPressedForwardKey&&(t=this._forwardSpeedMax):this._hasUsedStick&&(t=-this._forwardSpeedMax*this._stickForce*Math.sin(l.toRad(this._stickAngle))),this._currentForwardSpeed=v.getAcceleratedSpeed(this._currentForwardSpeed,t,this._forwardSpeedMax,this._forwardAcceleration,this._forwardDeceleration,e);let s=0;this._hasPressedLeftKey!==this._hasPressedRightKey?this._hasPressedLeftKey?s=-this._sidewaysSpeedMax:this._hasPressedRightKey&&(s=this._sidewaysSpeedMax):this._hasUsedStick&&(s=this._sidewaysSpeedMax*this._stickForce*Math.cos(l.toRad(this._stickAngle))),this._currentSidewaysSpeed=v.getAcceleratedSpeed(this._currentSidewaysSpeed,s,this._sidewaysSpeedMax,this._sidewaysAcceleration,this._sidewaysDeceleration,e)}static getAcceleratedSpeed(e,t,s,o,a,r){let i=e;return t<0?e<=t?i=Math.min(t,e+a*r):e<=0?i-=Math.max(-s,o*r):i=Math.max(t,e-Math.max(o,a)*r):t>0?e>=t?i=Math.max(t,e-a*r):e>=0?i=Math.min(s,e+o*r):i=Math.min(t,e+Math.max(o,a)*r):(e<0&&(i=Math.min(e+a*r,0)),e>0&&(i=Math.max(e-a*r,0))),i}updateGroundVelocity(e,t){if(!this.character||!e._body)return!1;const o=this._sharedData.worldInvScale;if(!this.character.IsSupported())return!1;const a=this._sharedData.physicsSystem.GetBodyLockInterface().TryGetBody(this.character.GetGroundBodyID()),r=a.IsKinematic()&&a.GetLinearVelocity().Equals(Jolt.Vec3.prototype.sZero())&&a.GetAngularVelocity().Equals(Jolt.Vec3.prototype.sZero());if(r){const n=a.gdjsAssociatedBehavior;if(n){const d=1/t;a.SetLinearVelocity(this.getVec3((n.owner3D.getX()-n._objectOldX)*o*d,(n.owner3D.getY()-n._objectOldY)*o*d,(n.owner3D.getZ()-n._objectOldZ)*o*d)),a.SetAngularVelocity(this.getVec3(0,0,l.toRad(l.evtTools.common.angleDifference(n.owner3D.getAngle(),n._objectOldRotationZ))*d))}}this.character.UpdateGroundVelocity();const i=a.GetAngularVelocity().GetZ();if(i!==0){const n=i*t;this.character.SetRotation(Jolt.Quat.prototype.sEulerAngles(this.getVec3(0,0,this.character.GetRotation().GetRotationAngle(Jolt.Vec3.prototype.sAxisZ())+n))),this._forwardAngle+=l.toDegrees(n)}r&&(a.SetLinearVelocity(Jolt.Vec3.prototype.sZero()),a.SetAngularVelocity(Jolt.Vec3.prototype.sZero()));const h=1*Math.PI/180;return Math.abs(a.GetAngularVelocity().GetX())<h&&Math.abs(a.GetAngularVelocity().GetY())<h}onObjectHotReloaded(){}getSlopeMaxAngle(){return this._slopeMaxAngle}setSlopeMaxAngle(e){e<0||e>=90||(this._slopeMaxAngle=e,e===45?this._slopeClimbingFactor=1:this._slopeClimbingFactor=Math.max(1/1024,Math.tan(l.toRad(e))),this._slopeClimbingMinNormalZ=Math.min(Math.cos(l.toRad(e)),1-1/1024))}getStairHeightMax(){return this._stairHeightMax}setStairHeightMax(e){this._stairHeightMax=e;const t=this.getPhysics3D();if(!t)return;const{extendedUpdateSettings:s}=t,o=e*this._sharedData.worldInvScale;s.mWalkStairsStepUp=this.getVec3(0,0,o),s.mWalkStairsMinStepForward=.02/.4*o,s.mWalkStairsStepForwardTest=.15/.4*o}getGravity(){return this._gravity}setGravity(e){this._gravity=e}getMaxFallingSpeed(){return this._maxFallingSpeed}setMaxFallingSpeed(e,t=!1){if(t&&!this.isOnFloor()){const s=this._currentFallSpeed-e;s>0&&(this._currentFallSpeed-=s,this._currentJumpSpeed=Math.max(0,this.getCurrentJumpSpeed()-s))}this._maxFallingSpeed=e}getForwardAcceleration(){return this._forwardAcceleration}setForwardAcceleration(e){this._forwardAcceleration=e}getForwardDeceleration(){return this._forwardDeceleration}setForwardDeceleration(e){this._forwardDeceleration=e}getForwardSpeedMax(){return this._forwardSpeedMax}setForwardSpeedMax(e){this._forwardSpeedMax=e}getSidewaysAcceleration(){return this._sidewaysAcceleration}setSidewaysAcceleration(e){this._sidewaysAcceleration=e}getSidewaysDeceleration(){return this._sidewaysDeceleration}setSidewaysDeceleration(e){this._sidewaysDeceleration=e}getSidewaysSpeedMax(){return this._sidewaysSpeedMax}setSidewaysSpeedMax(e){this._sidewaysSpeedMax=e}getJumpSpeed(){return this._jumpSpeed}setJumpSpeed(e){this._jumpSpeed=e}getJumpSustainTime(){return this._jumpSustainTime}setJumpSustainTime(e){this._jumpSustainTime=e}getForwardAngle(){return this._forwardAngle}setForwardAngle(e){this._forwardAngle=e,this._shouldBindObjectAndForwardAngle&&this.owner.setAngle(e)}isForwardAngleAround(e,t){return Math.abs(l.evtTools.common.angleDifference(this._forwardAngle,e))<=t}shouldBindObjectAndForwardAngle(){return this._shouldBindObjectAndForwardAngle}setShouldBindObjectAndForwardAngle(e){this._shouldBindObjectAndForwardAngle=e}getCurrentForwardSpeed(){return this._currentForwardSpeed}setCurrentForwardSpeed(e){this._currentForwardSpeed=e}getCurrentSidewaysSpeed(){return this._currentSidewaysSpeed}setCurrentSidewaysSpeed(e){this._currentSidewaysSpeed=e}getCurrentFallSpeed(){return this._currentFallSpeed}setCurrentFallSpeed(e){this._currentFallSpeed=l.evtTools.common.clamp(e,0,this._maxFallingSpeed)}getCurrentJumpSpeed(){return this._currentJumpSpeed}setCurrentJumpSpeed(e){this._currentJumpSpeed=Math.max(0,e)}canJump(){return this._canJump}setCanJump(){this._canJump=!0}setCanNotAirJump(){(this.isJumping()||this.isFalling())&&(this._canJump=!1)}abortJump(){this.isJumping()&&(this._currentFallSpeed=0,this._currentJumpSpeed=0)}simulateForwardKey(){this._hasPressedForwardKey=!0}wasForwardKeyPressed(){return this._wasForwardKeyPressed}simulateBackwardKey(){this._hasPressedBackwardKey=!0}wasBackwardKeyPressed(){return this._wasBackwardKeyPressed}simulateRightKey(){this._hasPressedRightKey=!0}wasRightKeyPressed(){return this._wasRightKeyPressed}simulateLeftKey(){this._hasPressedLeftKey=!0}wasLeftKeyPressed(){return this._wasLeftKeyPressed}simulateJumpKey(){this._hasPressedJumpKey=!0}wasJumpKeyPressed(){return this._wasJumpKeyPressed}simulateStick(e,t){this._hasUsedStick=!0,this._stickAngle=e,this._stickForce=Math.max(0,Math.min(1,t))}wasStickUsed(){return this._wasStickUsed}getStickAngle(){return this._wasStickUsed?this._stickAngle:0}getStickForce(){return this._wasStickUsed?this._stickForce:0}isOnFloor(){return this.character?this.character.IsSupported()&&this.character.GetGroundNormal().GetZ()>=this._slopeClimbingMinNormalZ&&this._currentJumpSpeed<=this._currentFallSpeed:!1}isOnFloorObject(e){return!e._body||!this.character||!this.isOnFloor()?!1:this.character.GetGroundBodyID().GetIndexAndSequenceNumber()===e._body.GetID().GetIndexAndSequenceNumber()}isJumping(){return this._currentJumpSpeed>0}isFallingWithoutJumping(){return!this.isOnFloor()&&!this.isJumping()}isFalling(){return this.isFallingWithoutJumping()||this.isJumping()&&this._currentFallSpeed>this._currentJumpSpeed}isMovingEvenALittle(){return this._hasReallyMoved&&(this._currentForwardSpeed!==0||this._currentSidewaysSpeed!==0)||this._currentJumpSpeed!==0||this._currentFallSpeed!==0}getJumpSpeedToReach(e){e=-Math.abs(e);const t=this._gravity,s=this._maxFallingSpeed,o=this._jumpSustainTime,a=s/t,r=n=>Math.sqrt(-n*t*2),i=n=>-t*o+s+Math.sqrt(t*t*o*o-2*n*t-s*s);let h=0,c=0;return a>o?(h=-t*o+Math.sqrt(2*t*t*o*o-4*e*t),c=(t*o+h)/(2*t),c<o?h=r(e):c>a&&(h=i(e))):(h=r(e),c=h/t,c>a&&(h=i(e))),h}};let b=v;b.epsilon=2**-20,l.PhysicsCharacter3DRuntimeBehavior=b,l.registerBehavior("Physics3D::PhysicsCharacter3D",l.PhysicsCharacter3DRuntimeBehavior),function(s){class j{constructor(a){this.characterVsCharacterCollision=new Jolt.CharacterVsCharacterCollisionSimple}static getManager(a){return a.charactersManager||(a.charactersManager=new l.PhysicsCharacter3DRuntimeBehavior.CharactersManager(a)),a.charactersManager}addCharacter(a){this.characterVsCharacterCollision.Add(a),a.SetCharacterVsCharacterCollision(this.characterVsCharacterCollision)}removeCharacter(a){this.characterVsCharacterCollision.Remove(a)}destroy(){Jolt.destroy(this.characterVsCharacterCollision)}}s.CharactersManager=j,l.registerRuntimeSceneUnloadedCallback(function(o){l.PhysicsCharacter3DRuntimeBehavior.CharactersManager.getManager(o).destroy()});class e{constructor(a){this.characterBehavior=a}createAndAddBody(){const a=this.characterBehavior.getPhysics3D();if(!a)return null;const{behavior:r}=a,{_slopeMaxAngle:i,owner3D:h,_sharedData:c}=this.characterBehavior,n=r.createShapeWithoutMassCenterOffset(),d=new Jolt.CharacterVirtualSettings;d.mInnerBodyLayer=this.characterBehavior._canBePushed?0:r.getBodyLayer(),d.mInnerBodyShape=n,d.mMass=n.GetMassProperties().get_mMass(),d.mMaxSlopeAngle=l.toRad(i),d.mShape=n,d.mUp=Jolt.Vec3.prototype.sAxisZ(),d.mBackFaceMode=Jolt.EBackFaceMode_CollideWithBackFaces;const C=h.getDepth()*c.worldInvScale,m=h.getWidth()*c.worldInvScale,F=h.getHeight()*c.worldInvScale,M=C/2,A=Math.sqrt(m*F)/2;d.mSupportingVolume=new Jolt.Plane(Jolt.Vec3.prototype.sAxisZ(),M-A*(1-Math.cos(l.toRad(Math.min(i+20,70)))));const g=new Jolt.CharacterVirtual(d,this.characterBehavior._getPhysicsPosition(c.getRVec3(0,0,0)),r._getPhysicsRotation(c.getQuat(0,0,0,1)),c.physicsSystem);Jolt.destroy(d);const P=c.physicsSystem.GetBodyLockInterface().TryGetBody(g.GetInnerBodyID());if(this.characterBehavior.character&&(this.characterBehavior._canBePushed&&(this.characterBehavior.charactersManager.removeCharacter(this.characterBehavior.character),Jolt.destroy(this.characterBehavior.character.GetListener())),Jolt.destroy(this.characterBehavior.character)),this.characterBehavior.character=g,this.characterBehavior._canBePushed){this.characterBehavior.charactersManager.addCharacter(g);const u=new Jolt.CharacterContactListenerJS;u.OnAdjustBodyVelocity=(y,_,S,w)=>{},u.OnContactValidate=(y,_,S)=>!0,u.OnCharacterContactValidate=(y,_,S)=>{const w=Jolt.wrapPointer(y,Jolt.CharacterVirtual),p=Jolt.wrapPointer(_,Jolt.CharacterVirtual),f=c.physicsSystem.GetBodyLockInterface().TryGetBody(w.GetInnerBodyID()),D=c.physicsSystem.GetBodyLockInterface().TryGetBody(p.GetInnerBodyID()),B=f.gdjsAssociatedBehavior,J=D.gdjsAssociatedBehavior;return!B||!J?!0:B.canCollideAgainst(J)},u.OnContactAdded=(y,_,S,w,p,f)=>{},u.OnContactPersisted=(y,_,S,w,p,f)=>{},u.OnContactRemoved=(y,_,S)=>{},u.OnCharacterContactAdded=(y,_,S,w,p,f)=>{},u.OnCharacterContactPersisted=(y,_,S,w,p,f)=>{},u.OnCharacterContactRemoved=(y,_,S)=>{},u.OnContactSolve=(y,_,S,w,p,f,D,B,J)=>{},u.OnCharacterContactSolve=(y,_,S,w,p,f,D,B,J)=>{},g.SetListener(u)}return P}updateObjectFromBody(){const{character:a}=this.characterBehavior;!a||(this.characterBehavior._moveObjectToPhysicsPosition(a.GetPosition()),this.characterBehavior._moveObjectToPhysicsRotation(a.GetRotation()))}updateBodyFromObject(){const a=this.characterBehavior.getPhysics3D();if(!a)return;const{behavior:r}=a,{character:i,owner3D:h,_sharedData:c}=this.characterBehavior;!i||((r._objectOldX!==h.getX()||r._objectOldY!==h.getY()||r._objectOldZ!==h.getZ())&&this.updateCharacterPosition(),(r._objectOldRotationX!==h.getRotationX()||r._objectOldRotationY!==h.getRotationY()||r._objectOldRotationZ!==h.getAngle())&&i.SetRotation(this.characterBehavior._getPhysicsRotation(c.getQuat(0,0,0,1))))}updateCharacterPosition(){const{character:a,_sharedData:r}=this.characterBehavior;!a||a.SetPosition(this.characterBehavior._getPhysicsPosition(r.getRVec3(0,0,0)))}recreateShape(){const a=this.characterBehavior.getPhysics3D();if(!a)return;const{behavior:r,broadPhaseLayerFilter:i,objectLayerFilter:h,bodyFilter:c,shapeFilter:n}=a,{character:d,_sharedData:C}=this.characterBehavior;if(!d)return;const m=r.createShapeWithoutMassCenterOffset();!d.SetShape(m,Number.MAX_VALUE,i,h,c,n,C.jolt.GetTempAllocator())||(d.SetInnerBodyShape(m),d.SetMass(m.GetMassProperties().get_mMass()),this.updateCharacterPosition())}destroyBody(){this.characterBehavior._destroyBody()}}s.CharacterBodyUpdater=e;class t{constructor(a){this._currentContacts=[];this._previousContacts=[];this.characterBehavior=a}clearContacts(){this._previousContacts.length=0,this._currentContacts.length=0}updateContacts(){const a=this._previousContacts;this._previousContacts=this._currentContacts,this._currentContacts=a,this._currentContacts.length=0;const{character:r,_sharedData:i}=this.characterBehavior;if(!r)return;const h=r.GetActiveContacts();for(let c=0;c<h.size();c++){const n=h.at(c),m=i.physicsSystem.GetBodyLockInterface().TryGetBody(n.mBodyB).gdjsAssociatedBehavior;m&&this._currentContacts.push(m)}}isColliding(a){const{character:r}=this.characterBehavior;return r?this._currentContacts.some(i=>i.owner===a):!1}hasCollisionStartedWith(a){const{character:r}=this.characterBehavior;return r?this._currentContacts.some(i=>i.owner===a)&&!this._previousContacts.some(i=>i.owner===a):!1}hasCollisionStoppedWith(a){const{character:r}=this.characterBehavior;return r?!this._currentContacts.some(i=>i.owner===a)&&this._previousContacts.some(i=>i.owner===a):!1}}s.CharacterCollisionChecker=t}(b=l.PhysicsCharacter3DRuntimeBehavior||(l.PhysicsCharacter3DRuntimeBehavior={}))})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=PhysicsCharacter3DRuntimeBehavior.js.map