gdcore-tools 2.0.0-gd-v5.5.224-autobuild → 2.0.0-gd-v5.5.225-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 (200) hide show
  1. package/dist/Runtime/CustomRuntimeObject.js +1 -1
  2. package/dist/Runtime/CustomRuntimeObject.js.map +2 -2
  3. package/dist/Runtime/CustomRuntimeObject2D.js.map +2 -2
  4. package/dist/Runtime/Extensions/3D/A_RuntimeObject3D.js.map +2 -2
  5. package/dist/Runtime/Extensions/3D/Base3DBehavior.js.map +2 -2
  6. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js +1 -1
  7. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObject.js.map +2 -2
  8. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObjectPixiRenderer.js +1 -1
  9. package/dist/Runtime/Extensions/3D/Cube3DRuntimeObjectPixiRenderer.js.map +2 -2
  10. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3D.js.map +2 -2
  11. package/dist/Runtime/Extensions/3D/CustomRuntimeObject3DRenderer.js.map +2 -2
  12. package/dist/Runtime/Extensions/3D/JsExtension.js +219 -108
  13. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js +1 -1
  14. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject.js.map +2 -2
  15. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js +1 -1
  16. package/dist/Runtime/Extensions/3D/Model3DRuntimeObject3DRenderer.js.map +2 -2
  17. package/dist/Runtime/Extensions/AdMob/JsExtension.js +63 -1
  18. package/dist/Runtime/Extensions/AdMob/admobtools.js +1 -1
  19. package/dist/Runtime/Extensions/AdMob/admobtools.js.map +2 -2
  20. package/dist/Runtime/Extensions/AdvancedWindow/electron-advancedwindowtools.js.map +2 -2
  21. package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js +1 -1
  22. package/dist/Runtime/Extensions/AnchorBehavior/anchorruntimebehavior.js.map +2 -2
  23. package/dist/Runtime/Extensions/BBText/JsExtension.js +10 -9
  24. package/dist/Runtime/Extensions/BBText/bbtextruntimeobject.js.map +2 -2
  25. package/dist/Runtime/Extensions/BitmapText/JsExtension.js +4 -6
  26. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject-pixi-renderer.js.map +2 -2
  27. package/dist/Runtime/Extensions/BitmapText/bitmaptextruntimeobject.js.map +2 -2
  28. package/dist/Runtime/Extensions/DialogueTree/dialoguetools.js.map +2 -2
  29. package/dist/Runtime/Extensions/DraggableBehavior/draggableruntimebehavior.js.map +2 -2
  30. package/dist/Runtime/Extensions/Effects/adjustment-pixi-filter.js.map +2 -2
  31. package/dist/Runtime/Extensions/Effects/advanced-bloom-pixi-filter.js.map +2 -2
  32. package/dist/Runtime/Extensions/Effects/ascii-pixi-filter.js.map +2 -2
  33. package/dist/Runtime/Extensions/Effects/bevel-pixi-filter.js.map +2 -2
  34. package/dist/Runtime/Extensions/Effects/black-and-white-pixi-filter.js.map +2 -2
  35. package/dist/Runtime/Extensions/Effects/blending-mode-pixi-filter.js.map +2 -2
  36. package/dist/Runtime/Extensions/Effects/brightness-pixi-filter.js.map +2 -2
  37. package/dist/Runtime/Extensions/Effects/bulge-pinch-pixi-filter.js.map +2 -2
  38. package/dist/Runtime/Extensions/Effects/color-map-pixi-filter.js.map +2 -2
  39. package/dist/Runtime/Extensions/Effects/color-replace-pixi-filter.js.map +2 -2
  40. package/dist/Runtime/Extensions/Effects/crt-pixi-filter.js.map +2 -2
  41. package/dist/Runtime/Extensions/Effects/displacement-pixi-filter.js.map +2 -2
  42. package/dist/Runtime/Extensions/Effects/dot-pixi-filter.js.map +2 -2
  43. package/dist/Runtime/Extensions/Effects/drop-shadow-pixi-filter.js.map +2 -2
  44. package/dist/Runtime/Extensions/Effects/glitch-pixi-filter.js.map +2 -2
  45. package/dist/Runtime/Extensions/Effects/glow-pixi-filter.js.map +2 -2
  46. package/dist/Runtime/Extensions/Effects/godray-pixi-filter.js.map +2 -2
  47. package/dist/Runtime/Extensions/Effects/kawase-blur-pixi-filter.js.map +2 -2
  48. package/dist/Runtime/Extensions/Effects/noise-pixi-filter.js.map +2 -2
  49. package/dist/Runtime/Extensions/Effects/old-film-pixi-filter.js.map +2 -2
  50. package/dist/Runtime/Extensions/Effects/outline-pixi-filter.js.map +2 -2
  51. package/dist/Runtime/Extensions/Effects/pixelate-pixi-filter.js.map +2 -2
  52. package/dist/Runtime/Extensions/Effects/pixi-filters/types/drop-shadow/types.d.ts +10 -4
  53. package/dist/Runtime/Extensions/Effects/radial-blur-pixi-filter.js.map +2 -2
  54. package/dist/Runtime/Extensions/Effects/reflection-pixi-filter.js.map +2 -2
  55. package/dist/Runtime/Extensions/Effects/rgb-split-pixi-filter.js.map +2 -2
  56. package/dist/Runtime/Extensions/Effects/sepia-pixi-filter.js.map +2 -2
  57. package/dist/Runtime/Extensions/Effects/shockwave-pixi-filter.js.map +2 -2
  58. package/dist/Runtime/Extensions/Effects/tilt-shift-pixi-filter.js.map +2 -2
  59. package/dist/Runtime/Extensions/Effects/twist-pixi-filter.js.map +2 -2
  60. package/dist/Runtime/Extensions/Effects/zoom-blur-pixi-filter.js.map +2 -2
  61. package/dist/Runtime/Extensions/ExampleJsExtension/dummyeffect.js.map +2 -2
  62. package/dist/Runtime/Extensions/FacebookInstantGames/facebookinstantgamestools.js.map +2 -2
  63. package/dist/Runtime/Extensions/Firebase/A_firebasejs/firebase.d.ts +5 -4
  64. package/dist/Runtime/Extensions/Firebase/B_firebasetools/D_cloudfirestoretools.js.map +2 -2
  65. package/dist/Runtime/Extensions/Firebase/B_firebasetools/D_remoteconfigtools.js.map +2 -2
  66. package/dist/Runtime/Extensions/Firebase/JsExtension.js +21 -21
  67. package/dist/Runtime/Extensions/JsExtensionTypes.d.ts +1 -0
  68. package/dist/Runtime/Extensions/Leaderboards/leaderboardstools.js.map +2 -2
  69. package/dist/Runtime/Extensions/Lighting/JsExtension.js +2 -2
  70. package/dist/Runtime/Extensions/Lighting/lightobstacleruntimebehavior.js.map +2 -2
  71. package/dist/Runtime/Extensions/Lighting/lightruntimeobject-pixi-renderer.js.map +2 -2
  72. package/dist/Runtime/Extensions/Lighting/lightruntimeobject.js.map +2 -2
  73. package/dist/Runtime/Extensions/LinkedObjects/linkedobjects.js.map +2 -2
  74. package/dist/Runtime/Extensions/Multiplayer/JsExtension.js +122 -0
  75. package/dist/Runtime/Extensions/Multiplayer/messageManager.js.map +2 -2
  76. package/dist/Runtime/Extensions/Multiplayer/multiplayerVariablesManager.js.map +2 -2
  77. package/dist/Runtime/Extensions/Multiplayer/multiplayercomponents.js +1 -1
  78. package/dist/Runtime/Extensions/Multiplayer/multiplayercomponents.js.map +2 -2
  79. package/dist/Runtime/Extensions/Multiplayer/multiplayerobjectruntimebehavior.js.map +2 -2
  80. package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js +1 -1
  81. package/dist/Runtime/Extensions/Multiplayer/multiplayertools.js.map +2 -2
  82. package/dist/Runtime/Extensions/Multiplayer/peerJsHelper.js +1 -1
  83. package/dist/Runtime/Extensions/Multiplayer/peerJsHelper.js.map +2 -2
  84. package/dist/Runtime/Extensions/Multiplayer/peerjs.d.ts +8 -10
  85. package/dist/Runtime/Extensions/P2P/peerjs.d.ts +8 -10
  86. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject-pixi-renderer.js.map +2 -2
  87. package/dist/Runtime/Extensions/PanelSpriteObject/panelspriteruntimeobject.js.map +2 -2
  88. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject-pixi-renderer.js.map +2 -2
  89. package/dist/Runtime/Extensions/ParticleSystem/particleemitterobject.js.map +2 -2
  90. package/dist/Runtime/Extensions/ParticleSystem/pixi-particles-pixi-renderer.d.ts +2 -1
  91. package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingobstacleruntimebehavior.js.map +2 -2
  92. package/dist/Runtime/Extensions/PathfindingBehavior/pathfindingruntimebehavior.js.map +2 -2
  93. package/dist/Runtime/Extensions/Physics2Behavior/JsExtension.js +106 -106
  94. package/dist/Runtime/Extensions/Physics2Behavior/box2d.d.ts +13 -7
  95. package/dist/Runtime/Extensions/Physics2Behavior/physics2runtimebehavior.js.map +2 -2
  96. package/dist/Runtime/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.js.map +2 -2
  97. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js +1 -1
  98. package/dist/Runtime/Extensions/Physics3DBehavior/PhysicsCharacter3DRuntimeBehavior.js.map +2 -2
  99. package/dist/Runtime/Extensions/PhysicsBehavior/physicsruntimebehavior.js.map +2 -2
  100. package/dist/Runtime/Extensions/PlatformBehavior/platformerobjectruntimebehavior.js.map +2 -2
  101. package/dist/Runtime/Extensions/PlatformBehavior/platformruntimebehavior.js.map +2 -2
  102. package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationcomponents.js.map +1 -1
  103. package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js +1 -1
  104. package/dist/Runtime/Extensions/PlayerAuthentication/playerauthenticationtools.js.map +2 -2
  105. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject-pixi-renderer.js.map +2 -2
  106. package/dist/Runtime/Extensions/PrimitiveDrawing/shapepainterruntimeobject.js.map +2 -2
  107. package/dist/Runtime/Extensions/SpatialSound/spatialsoundtools.js +1 -1
  108. package/dist/Runtime/Extensions/SpatialSound/spatialsoundtools.js.map +2 -2
  109. package/dist/Runtime/Extensions/Spine/JsExtension.js +5 -4
  110. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js +1 -1
  111. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-atlas-manager.js.map +2 -2
  112. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js +1 -1
  113. package/dist/Runtime/Extensions/Spine/managers/pixi-spine-manager.js.map +2 -2
  114. package/dist/Runtime/Extensions/Spine/spineruntimeobject-pixi-renderer.js.map +2 -2
  115. package/dist/Runtime/Extensions/Spine/spineruntimeobject.js.map +2 -2
  116. package/dist/Runtime/Extensions/Steamworks/JsExtension.js +12 -12
  117. package/dist/Runtime/Extensions/Steamworks/Z_steamworksinputtools.js.map +2 -2
  118. package/dist/Runtime/Extensions/Steamworks/steamworkstools.js.map +2 -2
  119. package/dist/Runtime/Extensions/TextEntryObject/textentryruntimeobject-pixi-renderer.js.map +2 -2
  120. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js +1 -1
  121. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject-pixi-renderer.js.map +2 -2
  122. package/dist/Runtime/Extensions/TextInput/textinputruntimeobject.js.map +2 -2
  123. package/dist/Runtime/Extensions/TextObject/textruntimeobject-pixi-renderer.js.map +2 -2
  124. package/dist/Runtime/Extensions/TextObject/textruntimeobject.js.map +2 -2
  125. package/dist/Runtime/Extensions/TileMap/JsExtension.js +20 -18
  126. package/dist/Runtime/Extensions/TileMap/TileMapRuntimeManager.js.map +2 -2
  127. package/dist/Runtime/Extensions/TileMap/collision/TransformedTileMap.js.map +2 -2
  128. package/dist/Runtime/Extensions/TileMap/helper/dts/model/TileMapModel.d.ts +1 -3
  129. package/dist/Runtime/Extensions/TileMap/simpletilemapruntimeobject.js.map +2 -2
  130. package/dist/Runtime/Extensions/TileMap/tilemapcollisionmaskruntimeobject.js.map +2 -2
  131. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject-pixi-renderer.js.map +1 -1
  132. package/dist/Runtime/Extensions/TileMap/tilemapruntimeobject.js.map +2 -2
  133. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject-pixi-renderer.js.map +2 -2
  134. package/dist/Runtime/Extensions/TiledSpriteObject/tiledspriteruntimeobject.js.map +2 -2
  135. package/dist/Runtime/Extensions/TopDownMovementBehavior/topdownmovementruntimebehavior.js.map +2 -2
  136. package/dist/Runtime/Extensions/TweenBehavior/tweenruntimebehavior.js.map +1 -1
  137. package/dist/Runtime/Extensions/Video/JsExtension.js +2 -1
  138. package/dist/Runtime/Extensions/Video/videoruntimeobject-pixi-renderer.js.map +2 -2
  139. package/dist/Runtime/Extensions/Video/videoruntimeobject.js.map +2 -2
  140. package/dist/Runtime/InAppTutorialMessage.js +6 -0
  141. package/dist/Runtime/InAppTutorialMessage.js.map +7 -0
  142. package/dist/Runtime/Model3DManager.js.map +2 -2
  143. package/dist/Runtime/ResourceLoader.js.map +2 -2
  144. package/dist/Runtime/RuntimeCustomObjectLayer.js +1 -1
  145. package/dist/Runtime/RuntimeCustomObjectLayer.js.map +2 -2
  146. package/dist/Runtime/RuntimeInstanceContainer.js.map +1 -1
  147. package/dist/Runtime/RuntimeLayer.js.map +2 -2
  148. package/dist/Runtime/SpriteAnimator.js.map +2 -2
  149. package/dist/Runtime/affinetransformation.js.map +1 -1
  150. package/dist/Runtime/debugger-client/abstract-debugger-client.js.map +2 -2
  151. package/dist/Runtime/debugger-client/hot-reloader.js +2 -2
  152. package/dist/Runtime/debugger-client/hot-reloader.js.map +2 -2
  153. package/dist/Runtime/debugger-client/websocket-debugger-client.js +1 -1
  154. package/dist/Runtime/debugger-client/websocket-debugger-client.js.map +2 -2
  155. package/dist/Runtime/events-tools/networktools.js +1 -1
  156. package/dist/Runtime/events-tools/networktools.js.map +2 -2
  157. package/dist/Runtime/fontfaceobserver-font-manager/fontfaceobserver-font-manager.js.map +2 -2
  158. package/dist/Runtime/gd.js.map +2 -2
  159. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js +1 -1
  160. package/dist/Runtime/howler-sound-manager/howler-sound-manager.js.map +2 -2
  161. package/dist/Runtime/inputmanager.js.map +2 -2
  162. package/dist/Runtime/jsonmanager.js.map +2 -2
  163. package/dist/Runtime/layer.js.map +2 -2
  164. package/dist/Runtime/libs/nanomarkdown.js +5 -0
  165. package/dist/Runtime/libs/nanomarkdown.js.map +7 -0
  166. package/dist/Runtime/object-capabilities/AnimatableBehavior.js.map +2 -2
  167. package/dist/Runtime/object-capabilities/EffectBehavior.js.map +2 -2
  168. package/dist/Runtime/object-capabilities/FlippableBehavior.js.map +2 -2
  169. package/dist/Runtime/object-capabilities/OpacityBehavior.js.map +2 -2
  170. package/dist/Runtime/object-capabilities/ResizableBehavior.js.map +2 -2
  171. package/dist/Runtime/object-capabilities/ScalableBehavior.js.map +2 -2
  172. package/dist/Runtime/object-capabilities/TextContainerBehavior.js.map +2 -2
  173. package/dist/Runtime/pixi-renderers/CustomRuntimeObject2DPixiRenderer.js.map +2 -2
  174. package/dist/Runtime/pixi-renderers/DebuggerPixiRenderer.js.map +2 -2
  175. package/dist/Runtime/pixi-renderers/layer-pixi-renderer.js.map +2 -2
  176. package/dist/Runtime/pixi-renderers/loadingscreen-pixi-renderer.js.map +2 -2
  177. package/dist/Runtime/pixi-renderers/pixi-bitmapfont-manager.js.map +2 -2
  178. package/dist/Runtime/pixi-renderers/pixi-filters-tools.js.map +2 -2
  179. package/dist/Runtime/pixi-renderers/pixi-image-manager.js +1 -1
  180. package/dist/Runtime/pixi-renderers/pixi-image-manager.js.map +2 -2
  181. package/dist/Runtime/pixi-renderers/pixi.js +123 -177
  182. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js +1 -1
  183. package/dist/Runtime/pixi-renderers/runtimegame-pixi-renderer.js.map +2 -2
  184. package/dist/Runtime/pixi-renderers/runtimescene-pixi-renderer.js.map +2 -2
  185. package/dist/Runtime/pixi-renderers/spriteruntimeobject-pixi-renderer.js.map +2 -2
  186. package/dist/Runtime/profiler.js.map +2 -2
  187. package/dist/Runtime/runtimegame.js +1 -1
  188. package/dist/Runtime/runtimegame.js.map +2 -2
  189. package/dist/Runtime/runtimeobject.js +1 -1
  190. package/dist/Runtime/runtimeobject.js.map +2 -2
  191. package/dist/Runtime/runtimescene.js.map +2 -2
  192. package/dist/Runtime/runtimewatermark.js.map +2 -2
  193. package/dist/Runtime/scenestack.js.map +2 -2
  194. package/dist/Runtime/spriteruntimeobject.js.map +2 -2
  195. package/dist/Runtime/variable.js.map +2 -2
  196. package/dist/Runtime/variablescontainer.js.map +2 -2
  197. package/dist/lib/libGD.cjs +1 -1
  198. package/dist/lib/libGD.wasm +0 -0
  199. package/gd.d.ts +2 -0
  200. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../GDevelop/Extensions/Physics3DBehavior/Physics3DRuntimeBehavior.ts"],
4
- "sourcesContent": ["/// <reference path=\"./jolt-physics.d.ts\" />\n\nnamespace Jolt {\n export interface Body {\n gdjsAssociatedBehavior: gdjs.Physics3DRuntimeBehavior | null;\n }\n}\n\nnamespace gdjs {\n const loadJolt = async () => {\n try {\n const module = await import('./jolt-physics.wasm.js');\n const initializeJoltPhysics = module.default;\n if (!initializeJoltPhysics) {\n throw new Error('No default export found in Jolt.');\n }\n\n const Jolt = await initializeJoltPhysics();\n window.Jolt = Jolt;\n } catch (err) {\n console.error('Unable to load Jolt physics library.', err);\n throw err;\n }\n };\n gdjs.registerAsynchronouslyLoadingLibraryPromise(loadJolt());\n\n export interface RuntimeScene {\n physics3DSharedData: gdjs.Physics3DSharedData | null;\n }\n interface Physics3DNetworkSyncDataType {\n px: number | undefined;\n py: number | undefined;\n pz: number | undefined;\n rx: number | undefined;\n ry: number | undefined;\n rz: number | undefined;\n rw: number | undefined;\n lvx: number | undefined;\n lvy: number | undefined;\n lvz: number | undefined;\n avx: number | undefined;\n avy: number | undefined;\n avz: number | undefined;\n aw: boolean | undefined;\n layers: number;\n masks: number;\n }\n\n export interface Physics3DNetworkSyncData extends BehaviorNetworkSyncData {\n props: Physics3DNetworkSyncDataType;\n }\n\n export class Physics3DSharedData {\n gravityX: float;\n gravityY: float;\n gravityZ: float;\n worldScale: float;\n worldInvScale: float;\n\n jolt: Jolt.JoltInterface;\n physicsSystem: Jolt.PhysicsSystem;\n bodyInterface: Jolt.BodyInterface;\n /** Contact listener to keep track of current collisions */\n contactListener: Jolt.ContactListenerJS;\n /** Avoid creating new vectors all the time */\n _tempVec3 = new Jolt.Vec3();\n _tempRVec3 = new Jolt.RVec3();\n _tempQuat = new Jolt.Quat();\n\n stepped: boolean = false;\n /**\n * List of physics behavior in the runtimeScene. It should be updated\n * when a new physics object is created (constructor), on destruction (onDestroy),\n * on behavior activation (onActivate) and on behavior deactivation (onDeActivate).\n */\n _registeredBehaviors: Set<Physics3DRuntimeBehavior>;\n\n private _physics3DHooks: Array<\n gdjs.Physics3DRuntimeBehavior.Physics3DHook\n > = [];\n\n constructor(instanceContainer: gdjs.RuntimeInstanceContainer, sharedData) {\n this._registeredBehaviors = new Set<Physics3DRuntimeBehavior>();\n this.gravityX = sharedData.gravityX;\n this.gravityY = sharedData.gravityY;\n this.gravityZ = sharedData.gravityZ;\n this.worldScale = sharedData.worldScale;\n this.worldInvScale = 1 / this.worldScale;\n\n // Initialize Jolt\n const settings = new Jolt.JoltSettings();\n gdjs.Physics3DSharedData.setupCollisionFiltering(settings);\n this.jolt = new Jolt.JoltInterface(settings);\n Jolt.destroy(settings);\n this.physicsSystem = this.jolt.GetPhysicsSystem();\n this.physicsSystem.SetGravity(\n this.getVec3(this.gravityX, this.gravityY, this.gravityZ)\n );\n this.bodyInterface = this.physicsSystem.GetBodyInterface();\n\n this.contactListener = new Jolt.ContactListenerJS();\n this.physicsSystem.SetContactListener(this.contactListener);\n this.contactListener.OnContactAdded = (\n bodyPtrA: number,\n bodyPtrB: number,\n manifoldPtr: number,\n settingsPtr: number\n ): void => {\n const bodyA = Jolt.wrapPointer(bodyPtrA, Jolt.Body);\n const bodyB = Jolt.wrapPointer(bodyPtrB, Jolt.Body);\n\n const behaviorA = bodyA.gdjsAssociatedBehavior;\n const behaviorB = bodyB.gdjsAssociatedBehavior;\n if (!behaviorA || !behaviorB) {\n return;\n }\n\n behaviorA.onContactBegin(behaviorB);\n behaviorB.onContactBegin(behaviorA);\n };\n this.contactListener.OnContactRemoved = (\n subShapePairPtr: number\n ): void => {\n const subShapePair = Jolt.wrapPointer(\n subShapePairPtr,\n Jolt.SubShapeIDPair\n );\n\n // This is ok because bodies are not deleted during the Physics step.\n const bodyLockInterface = this.physicsSystem.GetBodyLockInterface();\n const bodyA = bodyLockInterface.TryGetBody(subShapePair.GetBody1ID());\n const bodyB = bodyLockInterface.TryGetBody(subShapePair.GetBody2ID());\n\n const behaviorA = bodyA.gdjsAssociatedBehavior;\n const behaviorB = bodyB.gdjsAssociatedBehavior;\n if (!behaviorA || !behaviorB) {\n return;\n }\n\n behaviorA.onContactEnd(behaviorB);\n behaviorB.onContactEnd(behaviorA);\n };\n this.contactListener.OnContactPersisted = (\n bodyPtrA: number,\n bodyPtrB: number,\n manifoldPtr: number,\n settingsPtr: number\n ): void => {\n // TODO we could rely on this event.\n };\n this.contactListener.OnContactValidate = (\n bodyPtrA: number,\n bodyPtrB: number,\n inBaseOffset: number,\n inCollisionResult: number\n ): number => {\n return Jolt.ValidateResult_AcceptAllContactsForThisBodyPair;\n };\n }\n\n getVec3(x: float, y: float, z: float): Jolt.Vec3 {\n const tempVec3 = this._tempVec3;\n tempVec3.Set(x, y, z);\n return tempVec3;\n }\n\n getRVec3(x: float, y: float, z: float): Jolt.RVec3 {\n const tempRVec3 = this._tempRVec3;\n tempRVec3.Set(x, y, z);\n return tempRVec3;\n }\n\n getQuat(x: float, y: float, z: float, w: float): Jolt.Quat {\n const tempQuat = this._tempQuat;\n tempQuat.Set(x, y, z, w);\n return tempQuat;\n }\n\n static getSharedData(\n runtimeScene: gdjs.RuntimeScene,\n behaviorName: string\n ): gdjs.Physics3DSharedData {\n if (!runtimeScene.physics3DSharedData) {\n const initialData = runtimeScene.getInitialSharedDataForBehavior(\n behaviorName\n );\n runtimeScene.physics3DSharedData = new gdjs.Physics3DSharedData(\n runtimeScene,\n initialData\n );\n }\n return runtimeScene.physics3DSharedData;\n }\n\n // There are 4 bits for static layers and 4 bits for dynamic layers.\n static readonly staticLayersMask = 0x0f;\n static readonly dynamicLayersMask = 0xf0;\n static readonly allLayersMask = 0xff;\n static readonly staticBroadPhaseLayerIndex = 1;\n static readonly dynamicBroadPhaseLayerIndex = 1;\n\n private static setupCollisionFiltering(settings: Jolt.JoltSettings): void {\n const objectFilter = new Jolt.ObjectLayerPairFilterMask();\n const staticBroadPhaseLayer = new Jolt.BroadPhaseLayer(\n gdjs.Physics3DSharedData.staticBroadPhaseLayerIndex\n );\n const dynamicBroadPhaseLayer = new Jolt.BroadPhaseLayer(\n gdjs.Physics3DSharedData.dynamicBroadPhaseLayerIndex\n );\n const broadPhaseLayerInterfaceMask = new Jolt.BroadPhaseLayerInterfaceMask(\n 2\n );\n broadPhaseLayerInterfaceMask.ConfigureLayer(\n staticBroadPhaseLayer,\n gdjs.Physics3DSharedData.staticLayersMask,\n 0\n );\n broadPhaseLayerInterfaceMask.ConfigureLayer(\n dynamicBroadPhaseLayer,\n gdjs.Physics3DSharedData.dynamicLayersMask,\n 0\n );\n // BroadPhaseLayer have been copied into bpInterface\n Jolt.destroy(staticBroadPhaseLayer);\n Jolt.destroy(dynamicBroadPhaseLayer);\n\n settings.mObjectLayerPairFilter = objectFilter;\n settings.mBroadPhaseLayerInterface = broadPhaseLayerInterfaceMask;\n settings.mObjectVsBroadPhaseLayerFilter = new Jolt.ObjectVsBroadPhaseLayerFilterMask(\n broadPhaseLayerInterfaceMask\n );\n }\n\n /**\n * Add a physics object to the list of existing object.\n */\n addToBehaviorsList(physicsBehavior: gdjs.Physics3DRuntimeBehavior): void {\n this._registeredBehaviors.add(physicsBehavior);\n }\n\n /**\n * Remove a physics object to the list of existing object.\n */\n removeFromBehaviorsList(\n physicsBehavior: gdjs.Physics3DRuntimeBehavior\n ): void {\n this._registeredBehaviors.delete(physicsBehavior);\n }\n\n step(deltaTime: float): void {\n for (const physicsBehavior of this._registeredBehaviors) {\n physicsBehavior._contactsStartedThisFrame.length = 0;\n physicsBehavior._contactsEndedThisFrame.length = 0;\n }\n for (const physicsBehavior of this._registeredBehaviors) {\n physicsBehavior.updateBodyFromObject();\n }\n for (const physics3DHook of this._physics3DHooks) {\n physics3DHook.doBeforePhysicsStep(deltaTime);\n }\n\n const numSteps = deltaTime > 1.0 / 55.0 ? 2 : 1;\n this.jolt.Step(deltaTime, numSteps);\n this.stepped = true;\n\n // It's important that updateBodyFromObject and updateObjectFromBody are\n // called at the same time because other behavior may move the object in\n // their doStepPreEvents.\n for (const physicsBehavior of this._registeredBehaviors) {\n physicsBehavior.updateObjectFromBody();\n }\n }\n\n /**\n * A hook must typically be registered by a behavior that requires this one\n * in its onCreate function.\n * The hook must stay forever to avoid side effects like a hooks order\n * change. To handle deactivated behavior, the hook can check that its\n * behavior is activated before doing anything.\n */\n registerHook(hook: gdjs.Physics3DRuntimeBehavior.Physics3DHook) {\n this._physics3DHooks.push(hook);\n }\n }\n gdjs.registerRuntimeSceneUnloadedCallback(function (runtimeScene) {\n const physics3DSharedData = runtimeScene.physics3DSharedData;\n if (physics3DSharedData) {\n Jolt.destroy(physics3DSharedData.jolt);\n Jolt.destroy(physics3DSharedData.contactListener);\n Jolt.destroy(physics3DSharedData._tempVec3);\n Jolt.destroy(physics3DSharedData._tempRVec3);\n Jolt.destroy(physics3DSharedData._tempQuat);\n runtimeScene.physics3DSharedData = null;\n }\n });\n\n export class Physics3DRuntimeBehavior extends gdjs.RuntimeBehavior {\n bodyUpdater: gdjs.Physics3DRuntimeBehavior.BodyUpdater;\n collisionChecker: gdjs.Physics3DRuntimeBehavior.CollisionChecker;\n owner3D: gdjs.RuntimeObject3D;\n\n bodyType: string;\n bullet: boolean;\n fixedRotation: boolean;\n private shape: string;\n private shapeOrientation: string;\n private shapeDimensionA: any;\n private shapeDimensionB: any;\n private shapeDimensionC: any;\n private density: float;\n friction: float;\n restitution: float;\n linearDamping: float;\n angularDamping: float;\n gravityScale: float;\n private layers: integer;\n private masks: integer;\n private shapeScale: number = 1;\n\n /**\n * Array containing the beginning of contacts reported by onContactBegin. Each contact\n * should be unique to avoid recording glitches where the object loses and regain\n * contact between two frames. The array is updated each time the method\n * onContactBegin is called by the listener, which is only called when stepping\n * the world i.e. in the first preEvent called by a physics behavior. This array is\n * cleared just before stepping the world.\n */\n _contactsStartedThisFrame: Array<Physics3DRuntimeBehavior> = [];\n\n /**\n * Array containing the end of contacts reported by onContactEnd. The array is updated\n * each time the method onContactEnd is called by the listener, which can be called at\n * any time. This array is cleared just before stepping the world.\n */\n _contactsEndedThisFrame: Array<Physics3DRuntimeBehavior> = [];\n\n /**\n * Array containing the exact current contacts with the objects. It is updated\n * each time the methods onContactBegin and onContactEnd are called by the contact\n * listener.\n */\n _currentContacts: Array<Physics3DRuntimeBehavior> = [];\n\n private _destroyedDuringFrameLogic: boolean = false;\n _body: Jolt.Body | null = null;\n /**\n * When set to `true` the body will be recreated before the next physics step.\n */\n private _needToRecreateBody: boolean = false;\n /**\n * When set to `true` the shape will be recreated before the next physics step.\n */\n private _needToRecreateShape: boolean = false;\n /**\n * Used by {@link gdjs.PhysicsCharacter3DRuntimeBehavior} to convert coordinates.\n */\n _shapeHalfDepth: float = 0;\n\n /**\n * sharedData is a reference to the shared data of the scene, that registers\n * every physics behavior that is created so that collisions can be cleared\n * before stepping the world.\n */\n _sharedData: Physics3DSharedData;\n\n _objectOldX: float = 0;\n _objectOldY: float = 0;\n _objectOldZ: float = 0;\n _objectOldRotationX: float = 0;\n _objectOldRotationY: float = 0;\n _objectOldRotationZ: float = 0;\n _objectOldWidth: float = 0;\n _objectOldHeight: float = 0;\n _objectOldDepth: float = 0;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData,\n owner: gdjs.RuntimeObject3D\n ) {\n super(instanceContainer, behaviorData, owner);\n this.bodyUpdater = new gdjs.Physics3DRuntimeBehavior.DefaultBodyUpdater(\n this\n );\n this.collisionChecker = new gdjs.Physics3DRuntimeBehavior.DefaultCollisionChecker(\n this\n );\n this.owner3D = owner;\n this.bodyType = behaviorData.bodyType;\n this.bullet = behaviorData.bullet;\n this.fixedRotation = behaviorData.fixedRotation;\n this.shape = behaviorData.shape;\n this.shapeOrientation = behaviorData.shapeOrientation;\n this.shapeDimensionA = behaviorData.shapeDimensionA;\n this.shapeDimensionB = behaviorData.shapeDimensionB;\n this.shapeDimensionC = behaviorData.shapeDimensionC;\n this.density = behaviorData.density;\n this.friction = behaviorData.friction;\n this.restitution = behaviorData.restitution;\n this.linearDamping = Math.max(0, behaviorData.linearDamping);\n this.angularDamping = Math.max(0, behaviorData.angularDamping);\n this.gravityScale = behaviorData.gravityScale;\n this.layers = behaviorData.layers;\n this.masks = behaviorData.masks;\n this._sharedData = Physics3DSharedData.getSharedData(\n instanceContainer.getScene(),\n behaviorData.name\n );\n this._sharedData.addToBehaviorsList(this);\n }\n\n private getVec3(x: float, y: float, z: float): Jolt.Vec3 {\n const tempVec3 = this._sharedData._tempVec3;\n tempVec3.Set(x, y, z);\n return tempVec3;\n }\n\n private getRVec3(x: float, y: float, z: float): Jolt.RVec3 {\n const tempRVec3 = this._sharedData._tempRVec3;\n tempRVec3.Set(x, y, z);\n return tempRVec3;\n }\n\n private getQuat(x: float, y: float, z: float, w: float): Jolt.Quat {\n const tempQuat = this._sharedData._tempQuat;\n tempQuat.Set(x, y, z, w);\n return tempQuat;\n }\n\n updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {\n if (oldBehaviorData.bullet !== newBehaviorData.bullet) {\n this.setBullet(newBehaviorData.bullet);\n }\n if (oldBehaviorData.fixedRotation !== newBehaviorData.fixedRotation) {\n this.setFixedRotation(newBehaviorData.fixedRotation);\n }\n if (oldBehaviorData.shapeDimensionA !== newBehaviorData.shapeDimensionA) {\n this.shapeDimensionA = newBehaviorData.shapeDimensionA;\n this._needToRecreateShape = true;\n }\n if (oldBehaviorData.shapeDimensionB !== newBehaviorData.shapeDimensionB) {\n this.shapeDimensionB = newBehaviorData.shapeDimensionB;\n this._needToRecreateShape = true;\n }\n if (oldBehaviorData.density !== newBehaviorData.density) {\n this.setDensity(newBehaviorData.density);\n }\n if (oldBehaviorData.friction !== newBehaviorData.friction) {\n this.setFriction(newBehaviorData.friction);\n }\n if (oldBehaviorData.restitution !== newBehaviorData.restitution) {\n this.setRestitution(newBehaviorData.restitution);\n }\n if (oldBehaviorData.linearDamping !== newBehaviorData.linearDamping) {\n this.setLinearDamping(newBehaviorData.linearDamping);\n }\n if (oldBehaviorData.angularDamping !== newBehaviorData.angularDamping) {\n this.setAngularDamping(newBehaviorData.angularDamping);\n }\n if (oldBehaviorData.gravityScale !== newBehaviorData.gravityScale) {\n this.setGravityScale(newBehaviorData.gravityScale);\n }\n\n // TODO: make these properties updatable.\n if (oldBehaviorData.layers !== newBehaviorData.layers) {\n return false;\n }\n if (oldBehaviorData.masks !== newBehaviorData.masks) {\n return false;\n }\n if (oldBehaviorData.vertices !== newBehaviorData.vertices) {\n return false;\n }\n if (oldBehaviorData.bodyType !== newBehaviorData.bodyType) {\n return false;\n }\n if (oldBehaviorData.shape !== newBehaviorData.shape) {\n return false;\n }\n return true;\n }\n\n getNetworkSyncData(): Physics3DNetworkSyncData {\n let bodyProps;\n if (this._body) {\n const position = this._body.GetPosition();\n const rotation = this._body.GetRotation();\n const linearVelocity = this._body.GetLinearVelocity();\n const angularVelocity = this._body.GetAngularVelocity();\n bodyProps = {\n px: position.GetX(),\n py: position.GetY(),\n pz: position.GetZ(),\n rx: rotation.GetX(),\n ry: rotation.GetY(),\n rz: rotation.GetZ(),\n rw: rotation.GetW(),\n lvx: linearVelocity.GetX(),\n lvy: linearVelocity.GetY(),\n lvz: linearVelocity.GetZ(),\n avx: angularVelocity.GetX(),\n avy: angularVelocity.GetY(),\n avz: angularVelocity.GetZ(),\n aw: this._body.IsActive(),\n };\n } else {\n bodyProps = {\n px: undefined,\n py: undefined,\n pz: undefined,\n rx: undefined,\n ry: undefined,\n rz: undefined,\n rw: undefined,\n lvx: undefined,\n lvy: undefined,\n lvz: undefined,\n avx: undefined,\n avy: undefined,\n avz: undefined,\n aw: undefined,\n };\n }\n return {\n ...super.getNetworkSyncData(),\n props: {\n ...bodyProps,\n layers: this.layers,\n masks: this.masks,\n },\n };\n }\n\n updateFromNetworkSyncData(networkSyncData: Physics3DNetworkSyncData) {\n super.updateFromNetworkSyncData(networkSyncData);\n\n const behaviorSpecificProps = networkSyncData.props;\n if (\n behaviorSpecificProps.px !== undefined &&\n behaviorSpecificProps.py !== undefined &&\n behaviorSpecificProps.pz !== undefined\n ) {\n if (this._body) {\n this._sharedData.bodyInterface.SetPosition(\n this._body.GetID(),\n this.getRVec3(\n behaviorSpecificProps.px,\n behaviorSpecificProps.py,\n behaviorSpecificProps.pz\n ),\n Jolt.EActivation_DontActivate\n );\n }\n }\n if (\n behaviorSpecificProps.rx !== undefined &&\n behaviorSpecificProps.ry !== undefined &&\n behaviorSpecificProps.rz !== undefined &&\n behaviorSpecificProps.rw !== undefined\n ) {\n if (this._body) {\n this._sharedData.bodyInterface.SetRotation(\n this._body.GetID(),\n this.getQuat(\n behaviorSpecificProps.rx,\n behaviorSpecificProps.ry,\n behaviorSpecificProps.rz,\n behaviorSpecificProps.rw\n ),\n Jolt.EActivation_DontActivate\n );\n }\n }\n if (\n behaviorSpecificProps.lvx !== undefined &&\n behaviorSpecificProps.lvy !== undefined &&\n behaviorSpecificProps.lvz !== undefined\n ) {\n if (this._body) {\n this._sharedData.bodyInterface.SetLinearVelocity(\n this._body.GetID(),\n this.getVec3(\n behaviorSpecificProps.lvx,\n behaviorSpecificProps.lvy,\n behaviorSpecificProps.lvz\n )\n );\n }\n }\n if (\n behaviorSpecificProps.avx !== undefined &&\n behaviorSpecificProps.avy !== undefined &&\n behaviorSpecificProps.avz !== undefined\n ) {\n if (this._body) {\n this._sharedData.bodyInterface.SetAngularVelocity(\n this._body.GetID(),\n this.getVec3(\n behaviorSpecificProps.avx,\n behaviorSpecificProps.avy,\n behaviorSpecificProps.avz\n )\n );\n }\n }\n if (behaviorSpecificProps.layers !== undefined) {\n this.layers = behaviorSpecificProps.layers;\n }\n if (behaviorSpecificProps.masks !== undefined) {\n this.masks = behaviorSpecificProps.masks;\n }\n }\n\n onDeActivate() {\n this._sharedData.removeFromBehaviorsList(this);\n this.bodyUpdater.destroyBody();\n this._contactsEndedThisFrame.length = 0;\n this._contactsStartedThisFrame.length = 0;\n this._currentContacts.length = 0;\n }\n\n onActivate() {\n this._sharedData.addToBehaviorsList(this);\n\n this._contactsEndedThisFrame.length = 0;\n this._contactsStartedThisFrame.length = 0;\n this._currentContacts.length = 0;\n this.updateBodyFromObject();\n }\n\n onDestroy() {\n this._destroyedDuringFrameLogic = true;\n this.onDeActivate();\n }\n\n createShape(): Jolt.Shape {\n let width = this.owner3D.getWidth() * this._sharedData.worldInvScale;\n let height = this.owner3D.getHeight() * this._sharedData.worldInvScale;\n let depth = this.owner3D.getDepth() * this._sharedData.worldInvScale;\n if (this.shapeOrientation === 'X') {\n const swap = depth;\n depth = width;\n width = swap;\n } else if (this.shapeOrientation === 'Y') {\n const swap = depth;\n depth = height;\n height = swap;\n }\n\n const shapeScale = this.shapeScale * this._sharedData.worldInvScale;\n\n const shapeDimensionA = this.shapeDimensionA * shapeScale;\n const shapeDimensionB = this.shapeDimensionB * shapeScale;\n const shapeDimensionC = this.shapeDimensionC * shapeScale;\n\n const onePixel = this._sharedData.worldInvScale;\n\n let shapeSettings: Jolt.ConvexShapeSettings;\n /** This is fine only because no other Quat is used locally. */\n let quat: Jolt.Quat;\n if (this.shape === 'Box') {\n const boxWidth =\n shapeDimensionA > 0 ? shapeDimensionA : width > 0 ? width : onePixel;\n const boxHeight =\n shapeDimensionB > 0\n ? shapeDimensionB\n : height > 0\n ? height\n : onePixel;\n const boxDepth =\n shapeDimensionC > 0 ? shapeDimensionC : depth > 0 ? depth : onePixel;\n // The convex radius should not eat up the whole volume.\n const convexRadius = Math.min(\n onePixel,\n Math.min(boxWidth, boxHeight, boxDepth) / 4\n );\n shapeSettings = new Jolt.BoxShapeSettings(\n this.getVec3(boxWidth / 2, boxHeight / 2, boxDepth / 2),\n convexRadius\n );\n quat = this.getQuat(0, 0, 0, 1);\n this._shapeHalfDepth = boxDepth / 2;\n } else if (this.shape === 'Capsule') {\n const radius =\n shapeDimensionA > 0\n ? shapeDimensionA\n : width > 0\n ? Math.sqrt(width * height) / 2\n : onePixel;\n const capsuleDepth =\n shapeDimensionB > 0 ? shapeDimensionB : depth > 0 ? depth : onePixel;\n shapeSettings = new Jolt.CapsuleShapeSettings(\n Math.max(0, capsuleDepth / 2 - radius),\n radius\n );\n quat = this._getShapeOrientationQuat();\n this._shapeHalfDepth =\n this.shapeOrientation !== 'Z' ? radius : capsuleDepth / 2;\n } else if (this.shape === 'Cylinder') {\n const radius =\n shapeDimensionA > 0\n ? shapeDimensionA\n : width > 0\n ? Math.sqrt(width * height) / 2\n : onePixel;\n const cylinderDepth =\n shapeDimensionB > 0 ? shapeDimensionB : depth > 0 ? depth : onePixel;\n // The convex radius should not eat up the whole volume.\n const convexRadius = Math.min(\n onePixel,\n Math.min(cylinderDepth, radius) / 4\n );\n shapeSettings = new Jolt.CylinderShapeSettings(\n cylinderDepth / 2,\n radius,\n convexRadius\n );\n quat = this._getShapeOrientationQuat();\n this._shapeHalfDepth =\n this.shapeOrientation !== 'Z' ? radius : cylinderDepth / 2;\n } else {\n // Create a 'Sphere' by default.\n const radius =\n shapeDimensionA > 0\n ? shapeDimensionA\n : width > 0\n ? Math.pow(width * height * depth, 1 / 3) / 2\n : onePixel;\n shapeSettings = new Jolt.SphereShapeSettings(radius);\n quat = this.getQuat(0, 0, 0, 1);\n this._shapeHalfDepth = radius;\n }\n shapeSettings.mDensity = this.density;\n const rotatedShape = new Jolt.RotatedTranslatedShapeSettings(\n this.getVec3(0, 0, 0),\n quat,\n shapeSettings\n )\n .Create()\n .Get();\n\n Jolt.destroy(shapeSettings);\n return rotatedShape;\n }\n\n private _getShapeOrientationQuat(): Jolt.Quat {\n if (this.shapeOrientation === 'X') {\n // Top on X axis.\n return this.getQuat(0, 0, Math.sqrt(2) / 2, -Math.sqrt(2) / 2);\n } else if (this.shapeOrientation === 'Y') {\n // Top on Y axis.\n return this.getQuat(0, 0, 0, 1);\n } else {\n // Top on Z axis.\n return this.getQuat(Math.sqrt(2) / 2, 0, 0, Math.sqrt(2) / 2);\n }\n }\n\n private _recreateShape(): void {\n this.bodyUpdater.recreateShape();\n\n this._objectOldWidth = this.owner3D.getWidth();\n this._objectOldHeight = this.owner3D.getHeight();\n this._objectOldDepth = this.owner3D.getDepth();\n }\n\n getShapeScale(): float {\n return this.shapeScale;\n }\n\n setShapeScale(shapeScale: float): void {\n if (shapeScale !== this.shapeScale && shapeScale > 0) {\n this.shapeScale = shapeScale;\n this._needToRecreateShape = true;\n }\n }\n\n getBody(): Jolt.Body {\n if (this._body === null) {\n this._createBody();\n }\n return this._body!;\n }\n\n _createBody(): boolean {\n this._needToRecreateBody = false;\n this._needToRecreateShape = false;\n\n if (!this.activated() || this._destroyedDuringFrameLogic) return false;\n\n this._body = this.bodyUpdater.createAndAddBody();\n if (!this._body) {\n // It can only happen when the character behavior is destroyed.\n return false;\n }\n this._body.gdjsAssociatedBehavior = this;\n\n this._objectOldWidth = this.owner3D.getWidth();\n this._objectOldHeight = this.owner3D.getHeight();\n this._objectOldDepth = this.owner3D.getDepth();\n return true;\n }\n\n /**\n * @returns The body layer id according to the behavior configuration.\n */\n getBodyLayer(): number {\n return Jolt.ObjectLayerPairFilterMask.prototype.sGetObjectLayer(\n this.getLayersAccordingToBodyType(),\n this.getMasksAccordingToBodyType()\n );\n }\n\n private getLayersAccordingToBodyType(): integer {\n // Make sure objects don't register in the wrong layer group.\n return this.isStatic()\n ? this.layers & gdjs.Physics3DSharedData.staticLayersMask\n : this.layers & gdjs.Physics3DSharedData.dynamicLayersMask;\n }\n\n private getMasksAccordingToBodyType(): integer {\n // Static objects accept all collisions as it's the mask of dynamic objects that matters.\n return this.isStatic()\n ? gdjs.Physics3DSharedData.allLayersMask\n : this.masks;\n }\n\n doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n // Step the world if not done this frame yet.\n // Don't step at the first frame to allow events to handle overlapping objects.\n if (\n !this._sharedData.stepped &&\n !instanceContainer.getScene().getTimeManager().isFirstFrame()\n ) {\n this._sharedData.step(\n instanceContainer.getScene().getTimeManager().getElapsedTime() /\n 1000.0\n );\n }\n }\n\n doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n // Reset world step to update next frame\n this._sharedData.stepped = false;\n }\n\n onObjectHotReloaded() {\n this.updateBodyFromObject();\n }\n\n recreateBody() {\n if (!this._body) {\n this._createBody();\n return;\n }\n\n const bodyInterface = this._sharedData.bodyInterface;\n const linearVelocity = this._body.GetLinearVelocity();\n const linearVelocityX = linearVelocity.GetX();\n const linearVelocityY = linearVelocity.GetY();\n const linearVelocityZ = linearVelocity.GetZ();\n const angularVelocity = this._body.GetAngularVelocity();\n const angularVelocityX = angularVelocity.GetX();\n const angularVelocityY = angularVelocity.GetY();\n const angularVelocityZ = angularVelocity.GetZ();\n\n let bodyID = this._body.GetID();\n bodyInterface.RemoveBody(bodyID);\n bodyInterface.DestroyBody(bodyID);\n this._contactsEndedThisFrame.length = 0;\n this._contactsStartedThisFrame.length = 0;\n this._currentContacts.length = 0;\n\n this._createBody();\n if (!this._body) {\n return;\n }\n bodyID = this._body.GetID();\n bodyInterface.SetLinearVelocity(\n bodyID,\n this.getVec3(linearVelocityX, linearVelocityY, linearVelocityZ)\n );\n bodyInterface.SetAngularVelocity(\n bodyID,\n this.getVec3(angularVelocityX, angularVelocityY, angularVelocityZ)\n );\n }\n\n updateObjectFromBody() {\n this.bodyUpdater.updateObjectFromBody();\n\n // Update cached transform.\n this._objectOldX = this.owner3D.getX();\n this._objectOldY = this.owner3D.getY();\n this._objectOldZ = this.owner3D.getZ();\n this._objectOldRotationX = this.owner3D.getRotationX();\n this._objectOldRotationY = this.owner3D.getRotationY();\n this._objectOldRotationZ = this.owner3D.getAngle();\n }\n\n updateBodyFromObject() {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n\n if (this._needToRecreateBody) {\n this.recreateBody();\n }\n\n // The object size has changed, recreate the shape.\n // The width has changed and there is no custom dimension A (box: width, circle: radius, edge: length) or\n // The height has changed, the shape is not an edge (edges doesn't have height),\n // it isn't a box with custom height or a circle with custom radius\n if (\n this._needToRecreateShape ||\n (!this.hasCustomShapeDimension() &&\n (this._objectOldWidth !== this.owner3D.getWidth() ||\n this._objectOldHeight !== this.owner3D.getHeight() ||\n this._objectOldDepth !== this.owner3D.getDepth()))\n ) {\n this._needToRecreateShape = false;\n this._recreateShape();\n }\n\n this.bodyUpdater.updateBodyFromObject();\n }\n\n hasCustomShapeDimension() {\n return (\n this.shapeDimensionA > 0 ||\n this.shapeDimensionB > 0 ||\n this.shapeDimensionC > 0\n );\n }\n\n getPhysicsPosition(result: Jolt.RVec3): Jolt.RVec3 {\n result.Set(\n this.owner3D.getCenterXInScene() * this._sharedData.worldInvScale,\n this.owner3D.getCenterYInScene() * this._sharedData.worldInvScale,\n this.owner3D.getCenterZInScene() * this._sharedData.worldInvScale\n );\n return result;\n }\n\n getPhysicsRotation(result: Jolt.Quat): Jolt.Quat {\n const threeObject = this.owner3D.get3DRendererObject();\n result.Set(\n threeObject.quaternion.x,\n threeObject.quaternion.y,\n threeObject.quaternion.z,\n threeObject.quaternion.w\n );\n return result;\n }\n\n moveObjectToPhysicsPosition(physicsPosition: Jolt.RVec3): void {\n this.owner3D.setCenterXInScene(\n physicsPosition.GetX() * this._sharedData.worldScale\n );\n this.owner3D.setCenterYInScene(\n physicsPosition.GetY() * this._sharedData.worldScale\n );\n this.owner3D.setCenterZInScene(\n physicsPosition.GetZ() * this._sharedData.worldScale\n );\n }\n\n moveObjectToPhysicsRotation(physicsRotation: Jolt.Quat): void {\n const threeObject = this.owner3D.get3DRendererObject();\n threeObject.quaternion.x = physicsRotation.GetX();\n threeObject.quaternion.y = physicsRotation.GetY();\n threeObject.quaternion.z = physicsRotation.GetZ();\n threeObject.quaternion.w = physicsRotation.GetW();\n // TODO Avoid this instantiation\n const euler = new THREE.Euler(0, 0, 0, 'ZYX');\n euler.setFromQuaternion(threeObject.quaternion);\n this.owner3D.setRotationX(gdjs.toDegrees(euler.x));\n this.owner3D.setRotationY(gdjs.toDegrees(euler.y));\n this.owner3D.setAngle(gdjs.toDegrees(euler.z));\n }\n\n getWorldScale(): float {\n return this._sharedData.worldScale;\n }\n\n getGravityX(): float {\n return this._sharedData.gravityX;\n }\n\n getGravityY(): float {\n return this._sharedData.gravityY;\n }\n\n getGravityZ(): float {\n return this._sharedData.gravityZ;\n }\n\n setGravityX(gravityX: float): void {\n if (this._sharedData.gravityX === gravityX) {\n return;\n }\n\n this._sharedData.gravityX = gravityX;\n this._sharedData.physicsSystem.SetGravity(\n this.getVec3(\n this._sharedData.gravityX,\n this._sharedData.gravityY,\n this._sharedData.gravityZ\n )\n );\n }\n\n setGravityY(gravityY: float): void {\n if (this._sharedData.gravityX === gravityY) {\n return;\n }\n\n this._sharedData.gravityX = gravityY;\n this._sharedData.physicsSystem.SetGravity(\n this.getVec3(\n this._sharedData.gravityX,\n this._sharedData.gravityY,\n this._sharedData.gravityZ\n )\n );\n }\n\n setGravityZ(gravityZ: float): void {\n if (this._sharedData.gravityX === gravityZ) {\n return;\n }\n\n this._sharedData.gravityZ = gravityZ;\n this._sharedData.physicsSystem.SetGravity(\n this.getVec3(\n this._sharedData.gravityX,\n this._sharedData.gravityY,\n this._sharedData.gravityZ\n )\n );\n }\n\n isDynamic(): boolean {\n return this.bodyType === 'Dynamic';\n }\n\n isStatic(): boolean {\n return this.bodyType === 'Static';\n }\n\n isKinematic(): boolean {\n return this.bodyType === 'Kinematic';\n }\n\n isBullet(): boolean {\n return this.bullet;\n }\n\n setBullet(enable: boolean): void {\n if (this.bullet === enable) {\n return;\n }\n this.bullet = enable;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetMotionQuality(\n body.GetID(),\n this.bullet\n ? Jolt.EMotionQuality_LinearCast\n : Jolt.EMotionQuality_Discrete\n );\n }\n\n hasFixedRotation(): boolean {\n return this.fixedRotation;\n }\n\n setFixedRotation(enable: boolean): void {\n if (this.fixedRotation === enable) {\n return;\n }\n this.fixedRotation = enable;\n this._needToRecreateBody = true;\n }\n\n getDensity() {\n return this.density;\n }\n\n setDensity(density: float): void {\n // Non-negative values only\n if (density < 0) {\n density = 0;\n }\n if (this.density === density) {\n return;\n }\n this.density = density;\n this._needToRecreateShape = true;\n }\n\n getFriction(): float {\n return this.friction;\n }\n\n setFriction(friction: float): void {\n // Non-negative values only\n if (friction < 0) {\n friction = 0;\n }\n if (this.friction === friction) {\n return;\n }\n this.friction = friction;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetFriction(body.GetID(), friction);\n }\n\n getRestitution(): float {\n return this.restitution;\n }\n\n setRestitution(restitution: float): void {\n // Non-negative values only\n if (restitution < 0) {\n restitution = 0;\n }\n if (this.restitution === restitution) {\n return;\n }\n this.restitution = restitution;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetRestitution(body.GetID(), restitution);\n }\n\n getLinearDamping(): float {\n return this.linearDamping;\n }\n\n setLinearDamping(linearDamping: float): void {\n // Non-negative values only\n if (linearDamping < 0) {\n linearDamping = 0;\n }\n if (this.linearDamping === linearDamping) {\n return;\n }\n this.linearDamping = linearDamping;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n body.GetMotionProperties().SetLinearDamping(linearDamping);\n }\n\n getAngularDamping(): float {\n return this.angularDamping;\n }\n\n setAngularDamping(angularDamping: float): void {\n // Non-negative values only\n if (angularDamping < 0) {\n angularDamping = 0;\n }\n if (this.angularDamping === angularDamping) {\n return;\n }\n this.angularDamping = angularDamping;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n body.GetMotionProperties().SetAngularDamping(angularDamping);\n }\n\n getGravityScale(): float {\n return this.gravityScale;\n }\n\n setGravityScale(gravityScale: float): void {\n if (this.gravityScale === gravityScale) {\n return;\n }\n this.gravityScale = gravityScale;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n body.GetMotionProperties().SetGravityFactor(gravityScale);\n }\n\n layerEnabled(layer: integer): boolean {\n // Layer must be an integer\n layer = Math.floor(layer);\n if (layer < 1 || layer > 8) {\n return false;\n }\n return !!(this.layers & (1 << (layer - 1)));\n }\n\n enableLayer(layer: integer, enable: boolean): void {\n // Layer must be an integer\n layer = Math.floor(layer);\n if (layer < 1 || layer > 8) {\n return;\n }\n\n if (enable) {\n this.layers |= 1 << (layer - 1);\n } else {\n this.layers &= ~(1 << (layer - 1));\n }\n\n this._needToRecreateBody = true;\n }\n\n maskEnabled(mask: integer): boolean {\n // Mask must be an integer\n mask = Math.floor(mask);\n if (mask < 1 || mask > 16) {\n return false;\n }\n return !!(this.masks & (1 << (mask - 1)));\n }\n\n enableMask(mask: integer, enable: boolean): void {\n // Mask must be an integer\n mask = Math.floor(mask);\n if (mask < 1 || mask > 16) {\n return;\n }\n\n if (enable) {\n this.masks |= 1 << (mask - 1);\n } else {\n this.masks &= ~(1 << (mask - 1));\n }\n\n this._needToRecreateBody = true;\n }\n\n getLinearVelocityX(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return body.GetLinearVelocity().GetX() * this._sharedData.worldScale;\n }\n\n setLinearVelocityX(linearVelocityX: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetLinearVelocity(\n body.GetID(),\n this.getVec3(\n linearVelocityX * this._sharedData.worldInvScale,\n body.GetLinearVelocity().GetY(),\n body.GetLinearVelocity().GetZ()\n )\n );\n }\n\n getLinearVelocityY(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return body.GetLinearVelocity().GetY() * this._sharedData.worldScale;\n }\n\n setLinearVelocityY(linearVelocityY: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetLinearVelocity(\n body.GetID(),\n this.getVec3(\n body.GetLinearVelocity().GetX(),\n linearVelocityY * this._sharedData.worldInvScale,\n body.GetLinearVelocity().GetZ()\n )\n );\n }\n\n getLinearVelocityZ(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return body.GetLinearVelocity().GetZ() * this._sharedData.worldScale;\n }\n\n setLinearVelocityZ(linearVelocityZ: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetLinearVelocity(\n body.GetID(),\n this.getVec3(\n body.GetLinearVelocity().GetX(),\n body.GetLinearVelocity().GetY(),\n linearVelocityZ * this._sharedData.worldInvScale\n )\n );\n }\n\n getLinearVelocityLength(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return body.GetLinearVelocity().Length() * this._sharedData.worldScale;\n }\n\n getAngularVelocityX(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return gdjs.toDegrees(body.GetAngularVelocity().GetX());\n }\n\n setAngularVelocityX(angularVelocityX: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetAngularVelocity(\n body.GetID(),\n this.getVec3(\n gdjs.toRad(angularVelocityX),\n body.GetAngularVelocity().GetY(),\n body.GetAngularVelocity().GetZ()\n )\n );\n }\n\n getAngularVelocityY(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return gdjs.toDegrees(body.GetAngularVelocity().GetY());\n }\n\n setAngularVelocityY(angularVelocityY: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetAngularVelocity(\n body.GetID(),\n this.getVec3(\n body.GetAngularVelocity().GetX(),\n gdjs.toRad(angularVelocityY),\n body.GetAngularVelocity().GetZ()\n )\n );\n }\n\n getAngularVelocityZ(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return gdjs.toDegrees(body.GetAngularVelocity().GetZ());\n }\n\n setAngularVelocityZ(angularVelocityZ: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetAngularVelocity(\n body.GetID(),\n this.getVec3(\n body.GetAngularVelocity().GetX(),\n body.GetAngularVelocity().GetY(),\n gdjs.toRad(angularVelocityZ)\n )\n );\n }\n\n applyForce(\n forceX: float,\n forceY: float,\n forceZ: float,\n positionX: float,\n positionY: float,\n positionZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddForce(\n body.GetID(),\n this.getVec3(forceX, forceY, forceZ),\n this.getRVec3(\n positionX * this._sharedData.worldInvScale,\n positionY * this._sharedData.worldInvScale,\n positionZ * this._sharedData.worldInvScale\n ),\n Jolt.EActivation_Activate\n );\n }\n\n applyForceAtCenter(forceX: float, forceY: float, forceZ: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddForce(\n body.GetID(),\n this.getVec3(forceX, forceY, forceZ),\n Jolt.EActivation_Activate\n );\n }\n\n applyForceTowardPosition(\n length: float,\n towardX: float,\n towardY: float,\n towardZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n const deltaX = towardX - body.GetPosition().GetX();\n const deltaY = towardY - body.GetPosition().GetY();\n const deltaZ = towardZ - body.GetPosition().GetZ();\n const distance = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;\n if (distance === 0) {\n return;\n }\n const ratio = length / distance;\n\n this._sharedData.bodyInterface.AddForce(\n body.GetID(),\n this.getVec3(deltaX * ratio, deltaY * ratio, deltaZ * ratio),\n Jolt.EActivation_Activate\n );\n }\n\n applyImpulse(\n impulseX: float,\n impulseY: float,\n impulseZ: float,\n positionX: float,\n positionY: float,\n positionZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddImpulse(\n body.GetID(),\n this.getVec3(impulseX, impulseY, impulseZ),\n this.getRVec3(\n positionX * this._sharedData.worldInvScale,\n positionY * this._sharedData.worldInvScale,\n positionZ * this._sharedData.worldInvScale\n )\n );\n }\n\n applyImpulseAtCenter(\n impulseX: float,\n impulseY: float,\n impulseZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddImpulse(\n body.GetID(),\n this.getVec3(impulseX, impulseY, impulseZ)\n );\n }\n\n applyImpulseTowardPosition(\n length: float,\n towardX: float,\n towardY: float,\n towardZ: float,\n originX: float,\n originY: float,\n originZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n const deltaX = towardX - originX;\n const deltaY = towardY - originY;\n const deltaZ = towardZ - originZ;\n const distance = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;\n if (distance === 0) {\n return;\n }\n const ratio = length / distance;\n\n this._sharedData.bodyInterface.AddImpulse(\n body.GetID(),\n this.getVec3(deltaX * ratio, deltaY * ratio, deltaZ * ratio),\n this.getRVec3(\n originX * this._sharedData.worldInvScale,\n originY * this._sharedData.worldInvScale,\n originZ * this._sharedData.worldInvScale\n )\n );\n }\n\n applyTorque(torqueX: float, torqueY: float, torqueZ: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddTorque(\n body.GetID(),\n this.getVec3(\n gdjs.toRad(torqueX),\n gdjs.toRad(torqueY),\n gdjs.toRad(torqueZ)\n ),\n Jolt.EActivation_Activate\n );\n }\n\n applyAngularImpulse(\n angularImpulseX: float,\n angularImpulseY: float,\n angularImpulseZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddAngularImpulse(\n body.GetID(),\n this.getVec3(\n gdjs.toRad(angularImpulseX),\n gdjs.toRad(angularImpulseY),\n gdjs.toRad(angularImpulseZ)\n )\n );\n }\n\n getMass(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return 1 / body.GetMotionProperties().GetInverseMass();\n }\n\n /**\n * @returns The inertia for a rotation around X axis of the object at its\n * default rotation (0\u00B0; 0\u00B0; 0\u00B0).\n */\n getInertiaAroundX(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return 1 / body.GetMotionProperties().GetInverseInertiaDiagonal().GetX();\n }\n\n /**\n * @returns The inertia for a rotation around Y axis of the object at its\n * default rotation (0\u00B0; 0\u00B0; 0\u00B0).\n */\n getInertiaAroundY(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return 1 / body.GetMotionProperties().GetInverseInertiaDiagonal().GetY();\n }\n\n /**\n * @returns The inertia for a rotation around Z axis of the object at its\n * default rotation (0\u00B0; 0\u00B0; 0\u00B0).\n */\n getInertiaAroundZ(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return 1 / body.GetMotionProperties().GetInverseInertiaDiagonal().GetZ();\n }\n\n getMassCenterX(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return (\n body.GetCenterOfMassPosition().GetX() * this._sharedData.worldScale\n );\n }\n\n getMassCenterY(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return (\n body.GetCenterOfMassPosition().GetY() * this._sharedData.worldScale\n );\n }\n\n getMassCenterZ(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return (\n body.GetCenterOfMassPosition().GetZ() * this._sharedData.worldScale\n );\n }\n\n onContactBegin(otherBehavior: Physics3DRuntimeBehavior): void {\n this._currentContacts.push(otherBehavior);\n\n // There might be contacts that end during the frame and\n // start again right away. It is considered a glitch\n // and should not be detected.\n let i = this._contactsEndedThisFrame.indexOf(otherBehavior);\n if (i !== -1) {\n this._contactsEndedThisFrame.splice(i, 1);\n } else {\n this._contactsStartedThisFrame.push(otherBehavior);\n }\n }\n\n onContactEnd(otherBehavior: Physics3DRuntimeBehavior): void {\n this._contactsEndedThisFrame.push(otherBehavior);\n\n const index = this._currentContacts.indexOf(otherBehavior);\n if (index !== -1) {\n this._currentContacts.splice(index, 1);\n }\n }\n\n canCollideAgainst(otherBehavior: gdjs.Physics3DRuntimeBehavior): boolean {\n return (\n (this.getMasksAccordingToBodyType() &\n otherBehavior.getLayersAccordingToBodyType()) !==\n 0\n );\n }\n\n static areObjectsColliding(\n object1: gdjs.RuntimeObject,\n object2: gdjs.RuntimeObject,\n behaviorName: string\n ): boolean {\n const behavior1 = object1.getBehavior(\n behaviorName\n ) as Physics3DRuntimeBehavior | null;\n if (!behavior1) return false;\n return behavior1.collisionChecker.isColliding(object2);\n }\n\n static hasCollisionStartedBetween(\n object1: gdjs.RuntimeObject,\n object2: gdjs.RuntimeObject,\n behaviorName: string\n ): boolean {\n const behavior1 = object1.getBehavior(\n behaviorName\n ) as Physics3DRuntimeBehavior | null;\n if (!behavior1) return false;\n return behavior1.collisionChecker.hasCollisionStartedWith(object2);\n }\n\n static hasCollisionStoppedBetween(\n object1: gdjs.RuntimeObject,\n object2: gdjs.RuntimeObject,\n behaviorName: string\n ): boolean {\n const behavior1 = object1.getBehavior(\n behaviorName\n ) as Physics3DRuntimeBehavior | null;\n if (!behavior1) return false;\n return behavior1.collisionChecker.hasCollisionStoppedWith(object2);\n }\n }\n\n gdjs.registerBehavior(\n 'Physics3D::Physics3DBehavior',\n gdjs.Physics3DRuntimeBehavior\n );\n\n export namespace Physics3DRuntimeBehavior {\n /**\n * Allow extensions relying on the 3D physics to customize its\n * behavior a bit.\n */\n export interface Physics3DHook {\n /**\n * Called before the physics engine step.\n */\n doBeforePhysicsStep(timeDelta: float): void;\n }\n\n export interface BodyUpdater {\n createAndAddBody(): Jolt.Body | null;\n updateObjectFromBody(): void;\n updateBodyFromObject(): void;\n recreateShape(): void;\n destroyBody(): void;\n }\n\n export class DefaultBodyUpdater {\n behavior: gdjs.Physics3DRuntimeBehavior;\n\n constructor(behavior: gdjs.Physics3DRuntimeBehavior) {\n this.behavior = behavior;\n }\n\n createAndAddBody(): Jolt.Body | null {\n const { behavior } = this;\n const { _sharedData } = behavior;\n\n const shape = behavior.createShape();\n const bodyCreationSettings = new Jolt.BodyCreationSettings(\n shape,\n behavior.getPhysicsPosition(_sharedData.getRVec3(0, 0, 0)),\n behavior.getPhysicsRotation(_sharedData.getQuat(0, 0, 0, 1)),\n behavior.bodyType === 'Static'\n ? Jolt.EMotionType_Static\n : behavior.bodyType === 'Kinematic'\n ? Jolt.EMotionType_Kinematic\n : Jolt.EMotionType_Dynamic,\n behavior.getBodyLayer()\n );\n bodyCreationSettings.mMotionQuality = behavior.bullet\n ? Jolt.EMotionQuality_LinearCast\n : Jolt.EMotionQuality_Discrete;\n bodyCreationSettings.mAllowedDOFs = behavior.fixedRotation\n ? Jolt.EAllowedDOFs_TranslationX |\n Jolt.EAllowedDOFs_TranslationY |\n Jolt.EAllowedDOFs_TranslationZ\n : Jolt.EAllowedDOFs_All;\n bodyCreationSettings.mFriction = behavior.friction;\n bodyCreationSettings.mRestitution = behavior.restitution;\n bodyCreationSettings.mLinearDamping = behavior.linearDamping;\n bodyCreationSettings.mAngularDamping = behavior.angularDamping;\n bodyCreationSettings.mGravityFactor = behavior.gravityScale;\n\n const bodyInterface = _sharedData.bodyInterface;\n const body = bodyInterface.CreateBody(bodyCreationSettings);\n Jolt.destroy(bodyCreationSettings);\n\n bodyInterface.AddBody(body.GetID(), Jolt.EActivation_Activate);\n return body;\n }\n\n updateObjectFromBody() {\n const { behavior } = this;\n const { _body } = behavior;\n // Copy transform from body to the GD object.\n // The body is null when the behavior was either deactivated or the object deleted.\n // It would be useless to try to recreate it as updateBodyFromObject already does it.\n // If the body is null, we just don't do anything\n // (but still run the physics simulation - this is independent).\n if (_body !== null && _body.IsActive()) {\n behavior.moveObjectToPhysicsPosition(_body.GetPosition());\n behavior.moveObjectToPhysicsRotation(_body.GetRotation());\n }\n }\n\n updateBodyFromObject() {\n const { behavior } = this;\n const { owner3D, _sharedData } = behavior;\n if (behavior._body === null) {\n if (!behavior._createBody()) return;\n }\n const body = behavior._body!;\n\n if (\n this.behavior._objectOldX !== owner3D.getX() ||\n this.behavior._objectOldY !== owner3D.getY() ||\n this.behavior._objectOldZ !== owner3D.getZ() ||\n this.behavior._objectOldRotationX !== owner3D.getRotationX() ||\n this.behavior._objectOldRotationY !== owner3D.getRotationY() ||\n this.behavior._objectOldRotationZ !== owner3D.getAngle()\n ) {\n _sharedData.bodyInterface.SetPositionAndRotationWhenChanged(\n body.GetID(),\n this.behavior.getPhysicsPosition(_sharedData.getRVec3(0, 0, 0)),\n this.behavior.getPhysicsRotation(_sharedData.getQuat(0, 0, 0, 1)),\n Jolt.EActivation_Activate\n );\n }\n }\n\n recreateShape() {\n const { behavior } = this;\n const { _sharedData } = behavior;\n if (behavior._body === null) {\n if (!behavior._createBody()) return;\n }\n const body = behavior._body!;\n\n const bodyInterface = _sharedData.bodyInterface;\n bodyInterface.SetShape(\n body.GetID(),\n behavior.createShape(),\n true,\n Jolt.EActivation_Activate\n );\n }\n\n destroyBody() {\n const { behavior } = this;\n const { _sharedData } = behavior;\n if (behavior._body !== null) {\n _sharedData.bodyInterface.RemoveBody(behavior._body.GetID());\n _sharedData.bodyInterface.DestroyBody(behavior._body.GetID());\n behavior._body = null;\n }\n }\n }\n\n export interface CollisionChecker {\n isColliding(object: gdjs.RuntimeObject): boolean;\n hasCollisionStartedWith(object: gdjs.RuntimeObject): boolean;\n hasCollisionStoppedWith(object: gdjs.RuntimeObject): boolean;\n }\n\n /**\n * The default collision checker uses the contacts found while\n * stepping the physics simulation. For characters, another one is used\n * as characters are simulated before the rest of the physics simulation.\n */\n export class DefaultCollisionChecker implements CollisionChecker {\n behavior: gdjs.Physics3DRuntimeBehavior;\n\n constructor(behavior: gdjs.Physics3DRuntimeBehavior) {\n this.behavior = behavior;\n }\n\n isColliding(object: gdjs.RuntimeObject): boolean {\n if (\n this.behavior._currentContacts.some(\n (behavior) => behavior.owner === object\n )\n ) {\n return true;\n }\n return this.behavior._contactsStartedThisFrame.some(\n (behavior) => behavior.owner === object\n );\n }\n\n hasCollisionStartedWith(object: gdjs.RuntimeObject): boolean {\n return this.behavior._contactsStartedThisFrame.some(\n (behavior) => behavior.owner === object\n );\n }\n\n hasCollisionStoppedWith(object: gdjs.RuntimeObject): boolean {\n return this.behavior._contactsEndedThisFrame.some(\n (behavior) => behavior.owner === object\n );\n }\n }\n }\n}\n"],
5
- "mappings": "AAQA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAW,SAAY,CAC3B,GAAI,CAEF,KAAM,GAAwB,AADf,MAAM,QAAO,2BACS,QACrC,GAAI,CAAC,EACH,KAAM,IAAI,OAAM,oCAGlB,KAAM,GAAO,KAAM,KACnB,OAAO,KAAO,QACP,EAAP,CACA,cAAQ,MAAM,uCAAwC,GAChD,IAGV,EAAK,4CAA4C,KA4B1C,OAA0B,CA6B/B,YAAY,EAAkD,EAAY,CAhB1E,eAAY,GAAI,MAAK,KACrB,gBAAa,GAAI,MAAK,MACtB,eAAY,GAAI,MAAK,KAErB,aAAmB,GAQX,qBAEJ,GAGF,KAAK,qBAAuB,GAAI,KAChC,KAAK,SAAW,EAAW,SAC3B,KAAK,SAAW,EAAW,SAC3B,KAAK,SAAW,EAAW,SAC3B,KAAK,WAAa,EAAW,WAC7B,KAAK,cAAgB,EAAI,KAAK,WAG9B,KAAM,GAAW,GAAI,MAAK,aAC1B,EAAK,oBAAoB,wBAAwB,GACjD,KAAK,KAAO,GA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,cAAc,WAAW,EAAS,MAAM,SACpD,EAAY,cAAc,YAAY,EAAS,MAAM,SACrD,EAAS,MAAQ,OA3GhB,EAAM,qBA2HN,OAA0D,CAG/D,YAAY,EAAyC,CACnD,KAAK,SAAW,EAGlB,YAAY,EAAqC,CAC/C,MACE,MAAK,SAAS,iBAAiB,KAC7B,AAAC,GAAa,EAAS,QAAU,GAG5B,GAEF,KAAK,SAAS,0BAA0B,KAC7C,AAAC,GAAa,EAAS,QAAU,GAIrC,wBAAwB,EAAqC,CAC3D,MAAO,MAAK,SAAS,0BAA0B,KAC7C,AAAC,GAAa,EAAS,QAAU,GAIrC,wBAAwB,EAAqC,CAC3D,MAAO,MAAK,SAAS,wBAAwB,KAC3C,AAAC,GAAa,EAAS,QAAU,IA5BhC,EAAM,2BA/IE,iEA9sDT",
4
+ "sourcesContent": ["/// <reference path=\"./jolt-physics.d.ts\" />\n\nnamespace Jolt {\n export interface Body {\n gdjsAssociatedBehavior: gdjs.Physics3DRuntimeBehavior | null;\n }\n}\n\nnamespace gdjs {\n const loadJolt = async () => {\n try {\n const module = await import('./jolt-physics.wasm.js');\n const initializeJoltPhysics = module.default;\n if (!initializeJoltPhysics) {\n throw new Error('No default export found in Jolt.');\n }\n\n const Jolt = await initializeJoltPhysics();\n window.Jolt = Jolt;\n } catch (err) {\n console.error('Unable to load Jolt physics library.', err);\n throw err;\n }\n };\n gdjs.registerAsynchronouslyLoadingLibraryPromise(loadJolt());\n\n export interface RuntimeScene {\n physics3DSharedData: gdjs.Physics3DSharedData | null;\n }\n interface Physics3DNetworkSyncDataType {\n px: number | undefined;\n py: number | undefined;\n pz: number | undefined;\n rx: number | undefined;\n ry: number | undefined;\n rz: number | undefined;\n rw: number | undefined;\n lvx: number | undefined;\n lvy: number | undefined;\n lvz: number | undefined;\n avx: number | undefined;\n avy: number | undefined;\n avz: number | undefined;\n aw: boolean | undefined;\n layers: number;\n masks: number;\n }\n\n export interface Physics3DNetworkSyncData extends BehaviorNetworkSyncData {\n props: Physics3DNetworkSyncDataType;\n }\n\n export class Physics3DSharedData {\n gravityX: float;\n gravityY: float;\n gravityZ: float;\n worldScale: float;\n worldInvScale: float;\n\n jolt: Jolt.JoltInterface;\n physicsSystem: Jolt.PhysicsSystem;\n bodyInterface: Jolt.BodyInterface;\n /** Contact listener to keep track of current collisions */\n contactListener: Jolt.ContactListenerJS;\n /** Avoid creating new vectors all the time */\n _tempVec3 = new Jolt.Vec3();\n _tempRVec3 = new Jolt.RVec3();\n _tempQuat = new Jolt.Quat();\n\n stepped: boolean = false;\n /**\n * List of physics behavior in the runtimeScene. It should be updated\n * when a new physics object is created (constructor), on destruction (onDestroy),\n * on behavior activation (onActivate) and on behavior deactivation (onDeActivate).\n */\n _registeredBehaviors: Set<Physics3DRuntimeBehavior>;\n\n private _physics3DHooks: Array<gdjs.Physics3DRuntimeBehavior.Physics3DHook> =\n [];\n\n constructor(instanceContainer: gdjs.RuntimeInstanceContainer, sharedData) {\n this._registeredBehaviors = new Set<Physics3DRuntimeBehavior>();\n this.gravityX = sharedData.gravityX;\n this.gravityY = sharedData.gravityY;\n this.gravityZ = sharedData.gravityZ;\n this.worldScale = sharedData.worldScale;\n this.worldInvScale = 1 / this.worldScale;\n\n // Initialize Jolt\n const settings = new Jolt.JoltSettings();\n gdjs.Physics3DSharedData.setupCollisionFiltering(settings);\n this.jolt = new Jolt.JoltInterface(settings);\n Jolt.destroy(settings);\n this.physicsSystem = this.jolt.GetPhysicsSystem();\n this.physicsSystem.SetGravity(\n this.getVec3(this.gravityX, this.gravityY, this.gravityZ)\n );\n this.bodyInterface = this.physicsSystem.GetBodyInterface();\n\n this.contactListener = new Jolt.ContactListenerJS();\n this.physicsSystem.SetContactListener(this.contactListener);\n this.contactListener.OnContactAdded = (\n bodyPtrA: number,\n bodyPtrB: number,\n manifoldPtr: number,\n settingsPtr: number\n ): void => {\n const bodyA = Jolt.wrapPointer(bodyPtrA, Jolt.Body);\n const bodyB = Jolt.wrapPointer(bodyPtrB, Jolt.Body);\n\n const behaviorA = bodyA.gdjsAssociatedBehavior;\n const behaviorB = bodyB.gdjsAssociatedBehavior;\n if (!behaviorA || !behaviorB) {\n return;\n }\n\n behaviorA.onContactBegin(behaviorB);\n behaviorB.onContactBegin(behaviorA);\n };\n this.contactListener.OnContactRemoved = (\n subShapePairPtr: number\n ): void => {\n const subShapePair = Jolt.wrapPointer(\n subShapePairPtr,\n Jolt.SubShapeIDPair\n );\n\n // This is ok because bodies are not deleted during the Physics step.\n const bodyLockInterface = this.physicsSystem.GetBodyLockInterface();\n const bodyA = bodyLockInterface.TryGetBody(subShapePair.GetBody1ID());\n const bodyB = bodyLockInterface.TryGetBody(subShapePair.GetBody2ID());\n\n const behaviorA = bodyA.gdjsAssociatedBehavior;\n const behaviorB = bodyB.gdjsAssociatedBehavior;\n if (!behaviorA || !behaviorB) {\n return;\n }\n\n behaviorA.onContactEnd(behaviorB);\n behaviorB.onContactEnd(behaviorA);\n };\n this.contactListener.OnContactPersisted = (\n bodyPtrA: number,\n bodyPtrB: number,\n manifoldPtr: number,\n settingsPtr: number\n ): void => {\n // TODO we could rely on this event.\n };\n this.contactListener.OnContactValidate = (\n bodyPtrA: number,\n bodyPtrB: number,\n inBaseOffset: number,\n inCollisionResult: number\n ): number => {\n return Jolt.ValidateResult_AcceptAllContactsForThisBodyPair;\n };\n }\n\n getVec3(x: float, y: float, z: float): Jolt.Vec3 {\n const tempVec3 = this._tempVec3;\n tempVec3.Set(x, y, z);\n return tempVec3;\n }\n\n getRVec3(x: float, y: float, z: float): Jolt.RVec3 {\n const tempRVec3 = this._tempRVec3;\n tempRVec3.Set(x, y, z);\n return tempRVec3;\n }\n\n getQuat(x: float, y: float, z: float, w: float): Jolt.Quat {\n const tempQuat = this._tempQuat;\n tempQuat.Set(x, y, z, w);\n return tempQuat;\n }\n\n static getSharedData(\n runtimeScene: gdjs.RuntimeScene,\n behaviorName: string\n ): gdjs.Physics3DSharedData {\n if (!runtimeScene.physics3DSharedData) {\n const initialData =\n runtimeScene.getInitialSharedDataForBehavior(behaviorName);\n runtimeScene.physics3DSharedData = new gdjs.Physics3DSharedData(\n runtimeScene,\n initialData\n );\n }\n return runtimeScene.physics3DSharedData;\n }\n\n // There are 4 bits for static layers and 4 bits for dynamic layers.\n static readonly staticLayersMask = 0x0f;\n static readonly dynamicLayersMask = 0xf0;\n static readonly allLayersMask = 0xff;\n static readonly staticBroadPhaseLayerIndex = 1;\n static readonly dynamicBroadPhaseLayerIndex = 1;\n\n private static setupCollisionFiltering(settings: Jolt.JoltSettings): void {\n const objectFilter = new Jolt.ObjectLayerPairFilterMask();\n const staticBroadPhaseLayer = new Jolt.BroadPhaseLayer(\n gdjs.Physics3DSharedData.staticBroadPhaseLayerIndex\n );\n const dynamicBroadPhaseLayer = new Jolt.BroadPhaseLayer(\n gdjs.Physics3DSharedData.dynamicBroadPhaseLayerIndex\n );\n const broadPhaseLayerInterfaceMask =\n new Jolt.BroadPhaseLayerInterfaceMask(2);\n broadPhaseLayerInterfaceMask.ConfigureLayer(\n staticBroadPhaseLayer,\n gdjs.Physics3DSharedData.staticLayersMask,\n 0\n );\n broadPhaseLayerInterfaceMask.ConfigureLayer(\n dynamicBroadPhaseLayer,\n gdjs.Physics3DSharedData.dynamicLayersMask,\n 0\n );\n // BroadPhaseLayer have been copied into bpInterface\n Jolt.destroy(staticBroadPhaseLayer);\n Jolt.destroy(dynamicBroadPhaseLayer);\n\n settings.mObjectLayerPairFilter = objectFilter;\n settings.mBroadPhaseLayerInterface = broadPhaseLayerInterfaceMask;\n settings.mObjectVsBroadPhaseLayerFilter =\n new Jolt.ObjectVsBroadPhaseLayerFilterMask(\n broadPhaseLayerInterfaceMask\n );\n }\n\n /**\n * Add a physics object to the list of existing object.\n */\n addToBehaviorsList(physicsBehavior: gdjs.Physics3DRuntimeBehavior): void {\n this._registeredBehaviors.add(physicsBehavior);\n }\n\n /**\n * Remove a physics object to the list of existing object.\n */\n removeFromBehaviorsList(\n physicsBehavior: gdjs.Physics3DRuntimeBehavior\n ): void {\n this._registeredBehaviors.delete(physicsBehavior);\n }\n\n step(deltaTime: float): void {\n for (const physicsBehavior of this._registeredBehaviors) {\n physicsBehavior._contactsStartedThisFrame.length = 0;\n physicsBehavior._contactsEndedThisFrame.length = 0;\n }\n for (const physicsBehavior of this._registeredBehaviors) {\n physicsBehavior.updateBodyFromObject();\n }\n for (const physics3DHook of this._physics3DHooks) {\n physics3DHook.doBeforePhysicsStep(deltaTime);\n }\n\n const numSteps = deltaTime > 1.0 / 55.0 ? 2 : 1;\n this.jolt.Step(deltaTime, numSteps);\n this.stepped = true;\n\n // It's important that updateBodyFromObject and updateObjectFromBody are\n // called at the same time because other behavior may move the object in\n // their doStepPreEvents.\n for (const physicsBehavior of this._registeredBehaviors) {\n physicsBehavior.updateObjectFromBody();\n }\n }\n\n /**\n * A hook must typically be registered by a behavior that requires this one\n * in its onCreate function.\n * The hook must stay forever to avoid side effects like a hooks order\n * change. To handle deactivated behavior, the hook can check that its\n * behavior is activated before doing anything.\n */\n registerHook(hook: gdjs.Physics3DRuntimeBehavior.Physics3DHook) {\n this._physics3DHooks.push(hook);\n }\n }\n gdjs.registerRuntimeSceneUnloadedCallback(function (runtimeScene) {\n const physics3DSharedData = runtimeScene.physics3DSharedData;\n if (physics3DSharedData) {\n Jolt.destroy(physics3DSharedData.jolt);\n Jolt.destroy(physics3DSharedData.contactListener);\n Jolt.destroy(physics3DSharedData._tempVec3);\n Jolt.destroy(physics3DSharedData._tempRVec3);\n Jolt.destroy(physics3DSharedData._tempQuat);\n runtimeScene.physics3DSharedData = null;\n }\n });\n\n export class Physics3DRuntimeBehavior extends gdjs.RuntimeBehavior {\n bodyUpdater: gdjs.Physics3DRuntimeBehavior.BodyUpdater;\n collisionChecker: gdjs.Physics3DRuntimeBehavior.CollisionChecker;\n owner3D: gdjs.RuntimeObject3D;\n\n bodyType: string;\n bullet: boolean;\n fixedRotation: boolean;\n private shape: string;\n private shapeOrientation: string;\n private shapeDimensionA: any;\n private shapeDimensionB: any;\n private shapeDimensionC: any;\n private density: float;\n friction: float;\n restitution: float;\n linearDamping: float;\n angularDamping: float;\n gravityScale: float;\n private layers: integer;\n private masks: integer;\n private shapeScale: number = 1;\n\n /**\n * Array containing the beginning of contacts reported by onContactBegin. Each contact\n * should be unique to avoid recording glitches where the object loses and regain\n * contact between two frames. The array is updated each time the method\n * onContactBegin is called by the listener, which is only called when stepping\n * the world i.e. in the first preEvent called by a physics behavior. This array is\n * cleared just before stepping the world.\n */\n _contactsStartedThisFrame: Array<Physics3DRuntimeBehavior> = [];\n\n /**\n * Array containing the end of contacts reported by onContactEnd. The array is updated\n * each time the method onContactEnd is called by the listener, which can be called at\n * any time. This array is cleared just before stepping the world.\n */\n _contactsEndedThisFrame: Array<Physics3DRuntimeBehavior> = [];\n\n /**\n * Array containing the exact current contacts with the objects. It is updated\n * each time the methods onContactBegin and onContactEnd are called by the contact\n * listener.\n */\n _currentContacts: Array<Physics3DRuntimeBehavior> = [];\n\n private _destroyedDuringFrameLogic: boolean = false;\n _body: Jolt.Body | null = null;\n /**\n * When set to `true` the body will be recreated before the next physics step.\n */\n private _needToRecreateBody: boolean = false;\n /**\n * When set to `true` the shape will be recreated before the next physics step.\n */\n private _needToRecreateShape: boolean = false;\n /**\n * Used by {@link gdjs.PhysicsCharacter3DRuntimeBehavior} to convert coordinates.\n */\n _shapeHalfDepth: float = 0;\n\n /**\n * sharedData is a reference to the shared data of the scene, that registers\n * every physics behavior that is created so that collisions can be cleared\n * before stepping the world.\n */\n _sharedData: Physics3DSharedData;\n\n _objectOldX: float = 0;\n _objectOldY: float = 0;\n _objectOldZ: float = 0;\n _objectOldRotationX: float = 0;\n _objectOldRotationY: float = 0;\n _objectOldRotationZ: float = 0;\n _objectOldWidth: float = 0;\n _objectOldHeight: float = 0;\n _objectOldDepth: float = 0;\n\n constructor(\n instanceContainer: gdjs.RuntimeInstanceContainer,\n behaviorData,\n owner: gdjs.RuntimeObject3D\n ) {\n super(instanceContainer, behaviorData, owner);\n this.bodyUpdater = new gdjs.Physics3DRuntimeBehavior.DefaultBodyUpdater(\n this\n );\n this.collisionChecker =\n new gdjs.Physics3DRuntimeBehavior.DefaultCollisionChecker(this);\n this.owner3D = owner;\n this.bodyType = behaviorData.bodyType;\n this.bullet = behaviorData.bullet;\n this.fixedRotation = behaviorData.fixedRotation;\n this.shape = behaviorData.shape;\n this.shapeOrientation = behaviorData.shapeOrientation;\n this.shapeDimensionA = behaviorData.shapeDimensionA;\n this.shapeDimensionB = behaviorData.shapeDimensionB;\n this.shapeDimensionC = behaviorData.shapeDimensionC;\n this.density = behaviorData.density;\n this.friction = behaviorData.friction;\n this.restitution = behaviorData.restitution;\n this.linearDamping = Math.max(0, behaviorData.linearDamping);\n this.angularDamping = Math.max(0, behaviorData.angularDamping);\n this.gravityScale = behaviorData.gravityScale;\n this.layers = behaviorData.layers;\n this.masks = behaviorData.masks;\n this._sharedData = Physics3DSharedData.getSharedData(\n instanceContainer.getScene(),\n behaviorData.name\n );\n this._sharedData.addToBehaviorsList(this);\n }\n\n private getVec3(x: float, y: float, z: float): Jolt.Vec3 {\n const tempVec3 = this._sharedData._tempVec3;\n tempVec3.Set(x, y, z);\n return tempVec3;\n }\n\n private getRVec3(x: float, y: float, z: float): Jolt.RVec3 {\n const tempRVec3 = this._sharedData._tempRVec3;\n tempRVec3.Set(x, y, z);\n return tempRVec3;\n }\n\n private getQuat(x: float, y: float, z: float, w: float): Jolt.Quat {\n const tempQuat = this._sharedData._tempQuat;\n tempQuat.Set(x, y, z, w);\n return tempQuat;\n }\n\n updateFromBehaviorData(oldBehaviorData, newBehaviorData): boolean {\n if (oldBehaviorData.bullet !== newBehaviorData.bullet) {\n this.setBullet(newBehaviorData.bullet);\n }\n if (oldBehaviorData.fixedRotation !== newBehaviorData.fixedRotation) {\n this.setFixedRotation(newBehaviorData.fixedRotation);\n }\n if (oldBehaviorData.shapeDimensionA !== newBehaviorData.shapeDimensionA) {\n this.shapeDimensionA = newBehaviorData.shapeDimensionA;\n this._needToRecreateShape = true;\n }\n if (oldBehaviorData.shapeDimensionB !== newBehaviorData.shapeDimensionB) {\n this.shapeDimensionB = newBehaviorData.shapeDimensionB;\n this._needToRecreateShape = true;\n }\n if (oldBehaviorData.density !== newBehaviorData.density) {\n this.setDensity(newBehaviorData.density);\n }\n if (oldBehaviorData.friction !== newBehaviorData.friction) {\n this.setFriction(newBehaviorData.friction);\n }\n if (oldBehaviorData.restitution !== newBehaviorData.restitution) {\n this.setRestitution(newBehaviorData.restitution);\n }\n if (oldBehaviorData.linearDamping !== newBehaviorData.linearDamping) {\n this.setLinearDamping(newBehaviorData.linearDamping);\n }\n if (oldBehaviorData.angularDamping !== newBehaviorData.angularDamping) {\n this.setAngularDamping(newBehaviorData.angularDamping);\n }\n if (oldBehaviorData.gravityScale !== newBehaviorData.gravityScale) {\n this.setGravityScale(newBehaviorData.gravityScale);\n }\n\n // TODO: make these properties updatable.\n if (oldBehaviorData.layers !== newBehaviorData.layers) {\n return false;\n }\n if (oldBehaviorData.masks !== newBehaviorData.masks) {\n return false;\n }\n if (oldBehaviorData.vertices !== newBehaviorData.vertices) {\n return false;\n }\n if (oldBehaviorData.bodyType !== newBehaviorData.bodyType) {\n return false;\n }\n if (oldBehaviorData.shape !== newBehaviorData.shape) {\n return false;\n }\n return true;\n }\n\n getNetworkSyncData(): Physics3DNetworkSyncData {\n let bodyProps;\n if (this._body) {\n const position = this._body.GetPosition();\n const rotation = this._body.GetRotation();\n const linearVelocity = this._body.GetLinearVelocity();\n const angularVelocity = this._body.GetAngularVelocity();\n bodyProps = {\n px: position.GetX(),\n py: position.GetY(),\n pz: position.GetZ(),\n rx: rotation.GetX(),\n ry: rotation.GetY(),\n rz: rotation.GetZ(),\n rw: rotation.GetW(),\n lvx: linearVelocity.GetX(),\n lvy: linearVelocity.GetY(),\n lvz: linearVelocity.GetZ(),\n avx: angularVelocity.GetX(),\n avy: angularVelocity.GetY(),\n avz: angularVelocity.GetZ(),\n aw: this._body.IsActive(),\n };\n } else {\n bodyProps = {\n px: undefined,\n py: undefined,\n pz: undefined,\n rx: undefined,\n ry: undefined,\n rz: undefined,\n rw: undefined,\n lvx: undefined,\n lvy: undefined,\n lvz: undefined,\n avx: undefined,\n avy: undefined,\n avz: undefined,\n aw: undefined,\n };\n }\n return {\n ...super.getNetworkSyncData(),\n props: {\n ...bodyProps,\n layers: this.layers,\n masks: this.masks,\n },\n };\n }\n\n updateFromNetworkSyncData(networkSyncData: Physics3DNetworkSyncData) {\n super.updateFromNetworkSyncData(networkSyncData);\n\n const behaviorSpecificProps = networkSyncData.props;\n if (\n behaviorSpecificProps.px !== undefined &&\n behaviorSpecificProps.py !== undefined &&\n behaviorSpecificProps.pz !== undefined\n ) {\n if (this._body) {\n this._sharedData.bodyInterface.SetPosition(\n this._body.GetID(),\n this.getRVec3(\n behaviorSpecificProps.px,\n behaviorSpecificProps.py,\n behaviorSpecificProps.pz\n ),\n Jolt.EActivation_DontActivate\n );\n }\n }\n if (\n behaviorSpecificProps.rx !== undefined &&\n behaviorSpecificProps.ry !== undefined &&\n behaviorSpecificProps.rz !== undefined &&\n behaviorSpecificProps.rw !== undefined\n ) {\n if (this._body) {\n this._sharedData.bodyInterface.SetRotation(\n this._body.GetID(),\n this.getQuat(\n behaviorSpecificProps.rx,\n behaviorSpecificProps.ry,\n behaviorSpecificProps.rz,\n behaviorSpecificProps.rw\n ),\n Jolt.EActivation_DontActivate\n );\n }\n }\n if (\n behaviorSpecificProps.lvx !== undefined &&\n behaviorSpecificProps.lvy !== undefined &&\n behaviorSpecificProps.lvz !== undefined\n ) {\n if (this._body) {\n this._sharedData.bodyInterface.SetLinearVelocity(\n this._body.GetID(),\n this.getVec3(\n behaviorSpecificProps.lvx,\n behaviorSpecificProps.lvy,\n behaviorSpecificProps.lvz\n )\n );\n }\n }\n if (\n behaviorSpecificProps.avx !== undefined &&\n behaviorSpecificProps.avy !== undefined &&\n behaviorSpecificProps.avz !== undefined\n ) {\n if (this._body) {\n this._sharedData.bodyInterface.SetAngularVelocity(\n this._body.GetID(),\n this.getVec3(\n behaviorSpecificProps.avx,\n behaviorSpecificProps.avy,\n behaviorSpecificProps.avz\n )\n );\n }\n }\n if (behaviorSpecificProps.layers !== undefined) {\n this.layers = behaviorSpecificProps.layers;\n }\n if (behaviorSpecificProps.masks !== undefined) {\n this.masks = behaviorSpecificProps.masks;\n }\n }\n\n onDeActivate() {\n this._sharedData.removeFromBehaviorsList(this);\n this.bodyUpdater.destroyBody();\n this._contactsEndedThisFrame.length = 0;\n this._contactsStartedThisFrame.length = 0;\n this._currentContacts.length = 0;\n }\n\n onActivate() {\n this._sharedData.addToBehaviorsList(this);\n\n this._contactsEndedThisFrame.length = 0;\n this._contactsStartedThisFrame.length = 0;\n this._currentContacts.length = 0;\n this.updateBodyFromObject();\n }\n\n onDestroy() {\n this._destroyedDuringFrameLogic = true;\n this.onDeActivate();\n }\n\n createShape(): Jolt.Shape {\n let width = this.owner3D.getWidth() * this._sharedData.worldInvScale;\n let height = this.owner3D.getHeight() * this._sharedData.worldInvScale;\n let depth = this.owner3D.getDepth() * this._sharedData.worldInvScale;\n if (this.shapeOrientation === 'X') {\n const swap = depth;\n depth = width;\n width = swap;\n } else if (this.shapeOrientation === 'Y') {\n const swap = depth;\n depth = height;\n height = swap;\n }\n\n const shapeScale = this.shapeScale * this._sharedData.worldInvScale;\n\n const shapeDimensionA = this.shapeDimensionA * shapeScale;\n const shapeDimensionB = this.shapeDimensionB * shapeScale;\n const shapeDimensionC = this.shapeDimensionC * shapeScale;\n\n const onePixel = this._sharedData.worldInvScale;\n\n let shapeSettings: Jolt.ConvexShapeSettings;\n /** This is fine only because no other Quat is used locally. */\n let quat: Jolt.Quat;\n if (this.shape === 'Box') {\n const boxWidth =\n shapeDimensionA > 0 ? shapeDimensionA : width > 0 ? width : onePixel;\n const boxHeight =\n shapeDimensionB > 0\n ? shapeDimensionB\n : height > 0\n ? height\n : onePixel;\n const boxDepth =\n shapeDimensionC > 0 ? shapeDimensionC : depth > 0 ? depth : onePixel;\n // The convex radius should not eat up the whole volume.\n const convexRadius = Math.min(\n onePixel,\n Math.min(boxWidth, boxHeight, boxDepth) / 4\n );\n shapeSettings = new Jolt.BoxShapeSettings(\n this.getVec3(boxWidth / 2, boxHeight / 2, boxDepth / 2),\n convexRadius\n );\n quat = this.getQuat(0, 0, 0, 1);\n this._shapeHalfDepth = boxDepth / 2;\n } else if (this.shape === 'Capsule') {\n const radius =\n shapeDimensionA > 0\n ? shapeDimensionA\n : width > 0\n ? Math.sqrt(width * height) / 2\n : onePixel;\n const capsuleDepth =\n shapeDimensionB > 0 ? shapeDimensionB : depth > 0 ? depth : onePixel;\n shapeSettings = new Jolt.CapsuleShapeSettings(\n Math.max(0, capsuleDepth / 2 - radius),\n radius\n );\n quat = this._getShapeOrientationQuat();\n this._shapeHalfDepth =\n this.shapeOrientation !== 'Z' ? radius : capsuleDepth / 2;\n } else if (this.shape === 'Cylinder') {\n const radius =\n shapeDimensionA > 0\n ? shapeDimensionA\n : width > 0\n ? Math.sqrt(width * height) / 2\n : onePixel;\n const cylinderDepth =\n shapeDimensionB > 0 ? shapeDimensionB : depth > 0 ? depth : onePixel;\n // The convex radius should not eat up the whole volume.\n const convexRadius = Math.min(\n onePixel,\n Math.min(cylinderDepth, radius) / 4\n );\n shapeSettings = new Jolt.CylinderShapeSettings(\n cylinderDepth / 2,\n radius,\n convexRadius\n );\n quat = this._getShapeOrientationQuat();\n this._shapeHalfDepth =\n this.shapeOrientation !== 'Z' ? radius : cylinderDepth / 2;\n } else {\n // Create a 'Sphere' by default.\n const radius =\n shapeDimensionA > 0\n ? shapeDimensionA\n : width > 0\n ? Math.pow(width * height * depth, 1 / 3) / 2\n : onePixel;\n shapeSettings = new Jolt.SphereShapeSettings(radius);\n quat = this.getQuat(0, 0, 0, 1);\n this._shapeHalfDepth = radius;\n }\n shapeSettings.mDensity = this.density;\n const rotatedShape = new Jolt.RotatedTranslatedShapeSettings(\n this.getVec3(0, 0, 0),\n quat,\n shapeSettings\n )\n .Create()\n .Get();\n\n Jolt.destroy(shapeSettings);\n return rotatedShape;\n }\n\n private _getShapeOrientationQuat(): Jolt.Quat {\n if (this.shapeOrientation === 'X') {\n // Top on X axis.\n return this.getQuat(0, 0, Math.sqrt(2) / 2, -Math.sqrt(2) / 2);\n } else if (this.shapeOrientation === 'Y') {\n // Top on Y axis.\n return this.getQuat(0, 0, 0, 1);\n } else {\n // Top on Z axis.\n return this.getQuat(Math.sqrt(2) / 2, 0, 0, Math.sqrt(2) / 2);\n }\n }\n\n private _recreateShape(): void {\n this.bodyUpdater.recreateShape();\n\n this._objectOldWidth = this.owner3D.getWidth();\n this._objectOldHeight = this.owner3D.getHeight();\n this._objectOldDepth = this.owner3D.getDepth();\n }\n\n getShapeScale(): float {\n return this.shapeScale;\n }\n\n setShapeScale(shapeScale: float): void {\n if (shapeScale !== this.shapeScale && shapeScale > 0) {\n this.shapeScale = shapeScale;\n this._needToRecreateShape = true;\n }\n }\n\n getBody(): Jolt.Body {\n if (this._body === null) {\n this._createBody();\n }\n return this._body!;\n }\n\n _createBody(): boolean {\n this._needToRecreateBody = false;\n this._needToRecreateShape = false;\n\n if (!this.activated() || this._destroyedDuringFrameLogic) return false;\n\n this._body = this.bodyUpdater.createAndAddBody();\n if (!this._body) {\n // It can only happen when the character behavior is destroyed.\n return false;\n }\n this._body.gdjsAssociatedBehavior = this;\n\n this._objectOldWidth = this.owner3D.getWidth();\n this._objectOldHeight = this.owner3D.getHeight();\n this._objectOldDepth = this.owner3D.getDepth();\n return true;\n }\n\n /**\n * @returns The body layer id according to the behavior configuration.\n */\n getBodyLayer(): number {\n return Jolt.ObjectLayerPairFilterMask.prototype.sGetObjectLayer(\n this.getLayersAccordingToBodyType(),\n this.getMasksAccordingToBodyType()\n );\n }\n\n private getLayersAccordingToBodyType(): integer {\n // Make sure objects don't register in the wrong layer group.\n return this.isStatic()\n ? this.layers & gdjs.Physics3DSharedData.staticLayersMask\n : this.layers & gdjs.Physics3DSharedData.dynamicLayersMask;\n }\n\n private getMasksAccordingToBodyType(): integer {\n // Static objects accept all collisions as it's the mask of dynamic objects that matters.\n return this.isStatic()\n ? gdjs.Physics3DSharedData.allLayersMask\n : this.masks;\n }\n\n doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n // Step the world if not done this frame yet.\n // Don't step at the first frame to allow events to handle overlapping objects.\n if (\n !this._sharedData.stepped &&\n !instanceContainer.getScene().getTimeManager().isFirstFrame()\n ) {\n this._sharedData.step(\n instanceContainer.getScene().getTimeManager().getElapsedTime() /\n 1000.0\n );\n }\n }\n\n doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {\n // Reset world step to update next frame\n this._sharedData.stepped = false;\n }\n\n onObjectHotReloaded() {\n this.updateBodyFromObject();\n }\n\n recreateBody() {\n if (!this._body) {\n this._createBody();\n return;\n }\n\n const bodyInterface = this._sharedData.bodyInterface;\n const linearVelocity = this._body.GetLinearVelocity();\n const linearVelocityX = linearVelocity.GetX();\n const linearVelocityY = linearVelocity.GetY();\n const linearVelocityZ = linearVelocity.GetZ();\n const angularVelocity = this._body.GetAngularVelocity();\n const angularVelocityX = angularVelocity.GetX();\n const angularVelocityY = angularVelocity.GetY();\n const angularVelocityZ = angularVelocity.GetZ();\n\n let bodyID = this._body.GetID();\n bodyInterface.RemoveBody(bodyID);\n bodyInterface.DestroyBody(bodyID);\n this._contactsEndedThisFrame.length = 0;\n this._contactsStartedThisFrame.length = 0;\n this._currentContacts.length = 0;\n\n this._createBody();\n if (!this._body) {\n return;\n }\n bodyID = this._body.GetID();\n bodyInterface.SetLinearVelocity(\n bodyID,\n this.getVec3(linearVelocityX, linearVelocityY, linearVelocityZ)\n );\n bodyInterface.SetAngularVelocity(\n bodyID,\n this.getVec3(angularVelocityX, angularVelocityY, angularVelocityZ)\n );\n }\n\n updateObjectFromBody() {\n this.bodyUpdater.updateObjectFromBody();\n\n // Update cached transform.\n this._objectOldX = this.owner3D.getX();\n this._objectOldY = this.owner3D.getY();\n this._objectOldZ = this.owner3D.getZ();\n this._objectOldRotationX = this.owner3D.getRotationX();\n this._objectOldRotationY = this.owner3D.getRotationY();\n this._objectOldRotationZ = this.owner3D.getAngle();\n }\n\n updateBodyFromObject() {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n\n if (this._needToRecreateBody) {\n this.recreateBody();\n }\n\n // The object size has changed, recreate the shape.\n // The width has changed and there is no custom dimension A (box: width, circle: radius, edge: length) or\n // The height has changed, the shape is not an edge (edges doesn't have height),\n // it isn't a box with custom height or a circle with custom radius\n if (\n this._needToRecreateShape ||\n (!this.hasCustomShapeDimension() &&\n (this._objectOldWidth !== this.owner3D.getWidth() ||\n this._objectOldHeight !== this.owner3D.getHeight() ||\n this._objectOldDepth !== this.owner3D.getDepth()))\n ) {\n this._needToRecreateShape = false;\n this._recreateShape();\n }\n\n this.bodyUpdater.updateBodyFromObject();\n }\n\n hasCustomShapeDimension() {\n return (\n this.shapeDimensionA > 0 ||\n this.shapeDimensionB > 0 ||\n this.shapeDimensionC > 0\n );\n }\n\n getPhysicsPosition(result: Jolt.RVec3): Jolt.RVec3 {\n result.Set(\n this.owner3D.getCenterXInScene() * this._sharedData.worldInvScale,\n this.owner3D.getCenterYInScene() * this._sharedData.worldInvScale,\n this.owner3D.getCenterZInScene() * this._sharedData.worldInvScale\n );\n return result;\n }\n\n getPhysicsRotation(result: Jolt.Quat): Jolt.Quat {\n const threeObject = this.owner3D.get3DRendererObject();\n result.Set(\n threeObject.quaternion.x,\n threeObject.quaternion.y,\n threeObject.quaternion.z,\n threeObject.quaternion.w\n );\n return result;\n }\n\n moveObjectToPhysicsPosition(physicsPosition: Jolt.RVec3): void {\n this.owner3D.setCenterXInScene(\n physicsPosition.GetX() * this._sharedData.worldScale\n );\n this.owner3D.setCenterYInScene(\n physicsPosition.GetY() * this._sharedData.worldScale\n );\n this.owner3D.setCenterZInScene(\n physicsPosition.GetZ() * this._sharedData.worldScale\n );\n }\n\n moveObjectToPhysicsRotation(physicsRotation: Jolt.Quat): void {\n const threeObject = this.owner3D.get3DRendererObject();\n threeObject.quaternion.x = physicsRotation.GetX();\n threeObject.quaternion.y = physicsRotation.GetY();\n threeObject.quaternion.z = physicsRotation.GetZ();\n threeObject.quaternion.w = physicsRotation.GetW();\n // TODO Avoid this instantiation\n const euler = new THREE.Euler(0, 0, 0, 'ZYX');\n euler.setFromQuaternion(threeObject.quaternion);\n this.owner3D.setRotationX(gdjs.toDegrees(euler.x));\n this.owner3D.setRotationY(gdjs.toDegrees(euler.y));\n this.owner3D.setAngle(gdjs.toDegrees(euler.z));\n }\n\n getWorldScale(): float {\n return this._sharedData.worldScale;\n }\n\n getGravityX(): float {\n return this._sharedData.gravityX;\n }\n\n getGravityY(): float {\n return this._sharedData.gravityY;\n }\n\n getGravityZ(): float {\n return this._sharedData.gravityZ;\n }\n\n setGravityX(gravityX: float): void {\n if (this._sharedData.gravityX === gravityX) {\n return;\n }\n\n this._sharedData.gravityX = gravityX;\n this._sharedData.physicsSystem.SetGravity(\n this.getVec3(\n this._sharedData.gravityX,\n this._sharedData.gravityY,\n this._sharedData.gravityZ\n )\n );\n }\n\n setGravityY(gravityY: float): void {\n if (this._sharedData.gravityX === gravityY) {\n return;\n }\n\n this._sharedData.gravityX = gravityY;\n this._sharedData.physicsSystem.SetGravity(\n this.getVec3(\n this._sharedData.gravityX,\n this._sharedData.gravityY,\n this._sharedData.gravityZ\n )\n );\n }\n\n setGravityZ(gravityZ: float): void {\n if (this._sharedData.gravityX === gravityZ) {\n return;\n }\n\n this._sharedData.gravityZ = gravityZ;\n this._sharedData.physicsSystem.SetGravity(\n this.getVec3(\n this._sharedData.gravityX,\n this._sharedData.gravityY,\n this._sharedData.gravityZ\n )\n );\n }\n\n isDynamic(): boolean {\n return this.bodyType === 'Dynamic';\n }\n\n isStatic(): boolean {\n return this.bodyType === 'Static';\n }\n\n isKinematic(): boolean {\n return this.bodyType === 'Kinematic';\n }\n\n isBullet(): boolean {\n return this.bullet;\n }\n\n setBullet(enable: boolean): void {\n if (this.bullet === enable) {\n return;\n }\n this.bullet = enable;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetMotionQuality(\n body.GetID(),\n this.bullet\n ? Jolt.EMotionQuality_LinearCast\n : Jolt.EMotionQuality_Discrete\n );\n }\n\n hasFixedRotation(): boolean {\n return this.fixedRotation;\n }\n\n setFixedRotation(enable: boolean): void {\n if (this.fixedRotation === enable) {\n return;\n }\n this.fixedRotation = enable;\n this._needToRecreateBody = true;\n }\n\n getDensity() {\n return this.density;\n }\n\n setDensity(density: float): void {\n // Non-negative values only\n if (density < 0) {\n density = 0;\n }\n if (this.density === density) {\n return;\n }\n this.density = density;\n this._needToRecreateShape = true;\n }\n\n getFriction(): float {\n return this.friction;\n }\n\n setFriction(friction: float): void {\n // Non-negative values only\n if (friction < 0) {\n friction = 0;\n }\n if (this.friction === friction) {\n return;\n }\n this.friction = friction;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetFriction(body.GetID(), friction);\n }\n\n getRestitution(): float {\n return this.restitution;\n }\n\n setRestitution(restitution: float): void {\n // Non-negative values only\n if (restitution < 0) {\n restitution = 0;\n }\n if (this.restitution === restitution) {\n return;\n }\n this.restitution = restitution;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetRestitution(body.GetID(), restitution);\n }\n\n getLinearDamping(): float {\n return this.linearDamping;\n }\n\n setLinearDamping(linearDamping: float): void {\n // Non-negative values only\n if (linearDamping < 0) {\n linearDamping = 0;\n }\n if (this.linearDamping === linearDamping) {\n return;\n }\n this.linearDamping = linearDamping;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n body.GetMotionProperties().SetLinearDamping(linearDamping);\n }\n\n getAngularDamping(): float {\n return this.angularDamping;\n }\n\n setAngularDamping(angularDamping: float): void {\n // Non-negative values only\n if (angularDamping < 0) {\n angularDamping = 0;\n }\n if (this.angularDamping === angularDamping) {\n return;\n }\n this.angularDamping = angularDamping;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n body.GetMotionProperties().SetAngularDamping(angularDamping);\n }\n\n getGravityScale(): float {\n return this.gravityScale;\n }\n\n setGravityScale(gravityScale: float): void {\n if (this.gravityScale === gravityScale) {\n return;\n }\n this.gravityScale = gravityScale;\n\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n body.GetMotionProperties().SetGravityFactor(gravityScale);\n }\n\n layerEnabled(layer: integer): boolean {\n // Layer must be an integer\n layer = Math.floor(layer);\n if (layer < 1 || layer > 8) {\n return false;\n }\n return !!(this.layers & (1 << (layer - 1)));\n }\n\n enableLayer(layer: integer, enable: boolean): void {\n // Layer must be an integer\n layer = Math.floor(layer);\n if (layer < 1 || layer > 8) {\n return;\n }\n\n if (enable) {\n this.layers |= 1 << (layer - 1);\n } else {\n this.layers &= ~(1 << (layer - 1));\n }\n\n this._needToRecreateBody = true;\n }\n\n maskEnabled(mask: integer): boolean {\n // Mask must be an integer\n mask = Math.floor(mask);\n if (mask < 1 || mask > 16) {\n return false;\n }\n return !!(this.masks & (1 << (mask - 1)));\n }\n\n enableMask(mask: integer, enable: boolean): void {\n // Mask must be an integer\n mask = Math.floor(mask);\n if (mask < 1 || mask > 16) {\n return;\n }\n\n if (enable) {\n this.masks |= 1 << (mask - 1);\n } else {\n this.masks &= ~(1 << (mask - 1));\n }\n\n this._needToRecreateBody = true;\n }\n\n getLinearVelocityX(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return body.GetLinearVelocity().GetX() * this._sharedData.worldScale;\n }\n\n setLinearVelocityX(linearVelocityX: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetLinearVelocity(\n body.GetID(),\n this.getVec3(\n linearVelocityX * this._sharedData.worldInvScale,\n body.GetLinearVelocity().GetY(),\n body.GetLinearVelocity().GetZ()\n )\n );\n }\n\n getLinearVelocityY(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return body.GetLinearVelocity().GetY() * this._sharedData.worldScale;\n }\n\n setLinearVelocityY(linearVelocityY: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetLinearVelocity(\n body.GetID(),\n this.getVec3(\n body.GetLinearVelocity().GetX(),\n linearVelocityY * this._sharedData.worldInvScale,\n body.GetLinearVelocity().GetZ()\n )\n );\n }\n\n getLinearVelocityZ(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return body.GetLinearVelocity().GetZ() * this._sharedData.worldScale;\n }\n\n setLinearVelocityZ(linearVelocityZ: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetLinearVelocity(\n body.GetID(),\n this.getVec3(\n body.GetLinearVelocity().GetX(),\n body.GetLinearVelocity().GetY(),\n linearVelocityZ * this._sharedData.worldInvScale\n )\n );\n }\n\n getLinearVelocityLength(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return body.GetLinearVelocity().Length() * this._sharedData.worldScale;\n }\n\n getAngularVelocityX(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return gdjs.toDegrees(body.GetAngularVelocity().GetX());\n }\n\n setAngularVelocityX(angularVelocityX: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetAngularVelocity(\n body.GetID(),\n this.getVec3(\n gdjs.toRad(angularVelocityX),\n body.GetAngularVelocity().GetY(),\n body.GetAngularVelocity().GetZ()\n )\n );\n }\n\n getAngularVelocityY(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return gdjs.toDegrees(body.GetAngularVelocity().GetY());\n }\n\n setAngularVelocityY(angularVelocityY: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetAngularVelocity(\n body.GetID(),\n this.getVec3(\n body.GetAngularVelocity().GetX(),\n gdjs.toRad(angularVelocityY),\n body.GetAngularVelocity().GetZ()\n )\n );\n }\n\n getAngularVelocityZ(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return gdjs.toDegrees(body.GetAngularVelocity().GetZ());\n }\n\n setAngularVelocityZ(angularVelocityZ: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.SetAngularVelocity(\n body.GetID(),\n this.getVec3(\n body.GetAngularVelocity().GetX(),\n body.GetAngularVelocity().GetY(),\n gdjs.toRad(angularVelocityZ)\n )\n );\n }\n\n applyForce(\n forceX: float,\n forceY: float,\n forceZ: float,\n positionX: float,\n positionY: float,\n positionZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddForce(\n body.GetID(),\n this.getVec3(forceX, forceY, forceZ),\n this.getRVec3(\n positionX * this._sharedData.worldInvScale,\n positionY * this._sharedData.worldInvScale,\n positionZ * this._sharedData.worldInvScale\n ),\n Jolt.EActivation_Activate\n );\n }\n\n applyForceAtCenter(forceX: float, forceY: float, forceZ: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddForce(\n body.GetID(),\n this.getVec3(forceX, forceY, forceZ),\n Jolt.EActivation_Activate\n );\n }\n\n applyForceTowardPosition(\n length: float,\n towardX: float,\n towardY: float,\n towardZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n const deltaX = towardX - body.GetPosition().GetX();\n const deltaY = towardY - body.GetPosition().GetY();\n const deltaZ = towardZ - body.GetPosition().GetZ();\n const distance = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;\n if (distance === 0) {\n return;\n }\n const ratio = length / distance;\n\n this._sharedData.bodyInterface.AddForce(\n body.GetID(),\n this.getVec3(deltaX * ratio, deltaY * ratio, deltaZ * ratio),\n Jolt.EActivation_Activate\n );\n }\n\n applyImpulse(\n impulseX: float,\n impulseY: float,\n impulseZ: float,\n positionX: float,\n positionY: float,\n positionZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddImpulse(\n body.GetID(),\n this.getVec3(impulseX, impulseY, impulseZ),\n this.getRVec3(\n positionX * this._sharedData.worldInvScale,\n positionY * this._sharedData.worldInvScale,\n positionZ * this._sharedData.worldInvScale\n )\n );\n }\n\n applyImpulseAtCenter(\n impulseX: float,\n impulseY: float,\n impulseZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddImpulse(\n body.GetID(),\n this.getVec3(impulseX, impulseY, impulseZ)\n );\n }\n\n applyImpulseTowardPosition(\n length: float,\n towardX: float,\n towardY: float,\n towardZ: float,\n originX: float,\n originY: float,\n originZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n const deltaX = towardX - originX;\n const deltaY = towardY - originY;\n const deltaZ = towardZ - originZ;\n const distance = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;\n if (distance === 0) {\n return;\n }\n const ratio = length / distance;\n\n this._sharedData.bodyInterface.AddImpulse(\n body.GetID(),\n this.getVec3(deltaX * ratio, deltaY * ratio, deltaZ * ratio),\n this.getRVec3(\n originX * this._sharedData.worldInvScale,\n originY * this._sharedData.worldInvScale,\n originZ * this._sharedData.worldInvScale\n )\n );\n }\n\n applyTorque(torqueX: float, torqueY: float, torqueZ: float): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddTorque(\n body.GetID(),\n this.getVec3(\n gdjs.toRad(torqueX),\n gdjs.toRad(torqueY),\n gdjs.toRad(torqueZ)\n ),\n Jolt.EActivation_Activate\n );\n }\n\n applyAngularImpulse(\n angularImpulseX: float,\n angularImpulseY: float,\n angularImpulseZ: float\n ): void {\n if (this._body === null) {\n if (!this._createBody()) return;\n }\n const body = this._body!;\n\n this._sharedData.bodyInterface.AddAngularImpulse(\n body.GetID(),\n this.getVec3(\n gdjs.toRad(angularImpulseX),\n gdjs.toRad(angularImpulseY),\n gdjs.toRad(angularImpulseZ)\n )\n );\n }\n\n getMass(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return 1 / body.GetMotionProperties().GetInverseMass();\n }\n\n /**\n * @returns The inertia for a rotation around X axis of the object at its\n * default rotation (0\u00B0; 0\u00B0; 0\u00B0).\n */\n getInertiaAroundX(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return 1 / body.GetMotionProperties().GetInverseInertiaDiagonal().GetX();\n }\n\n /**\n * @returns The inertia for a rotation around Y axis of the object at its\n * default rotation (0\u00B0; 0\u00B0; 0\u00B0).\n */\n getInertiaAroundY(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return 1 / body.GetMotionProperties().GetInverseInertiaDiagonal().GetY();\n }\n\n /**\n * @returns The inertia for a rotation around Z axis of the object at its\n * default rotation (0\u00B0; 0\u00B0; 0\u00B0).\n */\n getInertiaAroundZ(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return 1 / body.GetMotionProperties().GetInverseInertiaDiagonal().GetZ();\n }\n\n getMassCenterX(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return (\n body.GetCenterOfMassPosition().GetX() * this._sharedData.worldScale\n );\n }\n\n getMassCenterY(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return (\n body.GetCenterOfMassPosition().GetY() * this._sharedData.worldScale\n );\n }\n\n getMassCenterZ(): float {\n if (this._body === null) {\n if (!this._createBody()) return 0;\n }\n const body = this._body!;\n\n return (\n body.GetCenterOfMassPosition().GetZ() * this._sharedData.worldScale\n );\n }\n\n onContactBegin(otherBehavior: Physics3DRuntimeBehavior): void {\n this._currentContacts.push(otherBehavior);\n\n // There might be contacts that end during the frame and\n // start again right away. It is considered a glitch\n // and should not be detected.\n let i = this._contactsEndedThisFrame.indexOf(otherBehavior);\n if (i !== -1) {\n this._contactsEndedThisFrame.splice(i, 1);\n } else {\n this._contactsStartedThisFrame.push(otherBehavior);\n }\n }\n\n onContactEnd(otherBehavior: Physics3DRuntimeBehavior): void {\n this._contactsEndedThisFrame.push(otherBehavior);\n\n const index = this._currentContacts.indexOf(otherBehavior);\n if (index !== -1) {\n this._currentContacts.splice(index, 1);\n }\n }\n\n canCollideAgainst(otherBehavior: gdjs.Physics3DRuntimeBehavior): boolean {\n return (\n (this.getMasksAccordingToBodyType() &\n otherBehavior.getLayersAccordingToBodyType()) !==\n 0\n );\n }\n\n static areObjectsColliding(\n object1: gdjs.RuntimeObject,\n object2: gdjs.RuntimeObject,\n behaviorName: string\n ): boolean {\n const behavior1 = object1.getBehavior(\n behaviorName\n ) as Physics3DRuntimeBehavior | null;\n if (!behavior1) return false;\n return behavior1.collisionChecker.isColliding(object2);\n }\n\n static hasCollisionStartedBetween(\n object1: gdjs.RuntimeObject,\n object2: gdjs.RuntimeObject,\n behaviorName: string\n ): boolean {\n const behavior1 = object1.getBehavior(\n behaviorName\n ) as Physics3DRuntimeBehavior | null;\n if (!behavior1) return false;\n return behavior1.collisionChecker.hasCollisionStartedWith(object2);\n }\n\n static hasCollisionStoppedBetween(\n object1: gdjs.RuntimeObject,\n object2: gdjs.RuntimeObject,\n behaviorName: string\n ): boolean {\n const behavior1 = object1.getBehavior(\n behaviorName\n ) as Physics3DRuntimeBehavior | null;\n if (!behavior1) return false;\n return behavior1.collisionChecker.hasCollisionStoppedWith(object2);\n }\n }\n\n gdjs.registerBehavior(\n 'Physics3D::Physics3DBehavior',\n gdjs.Physics3DRuntimeBehavior\n );\n\n export namespace Physics3DRuntimeBehavior {\n /**\n * Allow extensions relying on the 3D physics to customize its\n * behavior a bit.\n */\n export interface Physics3DHook {\n /**\n * Called before the physics engine step.\n */\n doBeforePhysicsStep(timeDelta: float): void;\n }\n\n export interface BodyUpdater {\n createAndAddBody(): Jolt.Body | null;\n updateObjectFromBody(): void;\n updateBodyFromObject(): void;\n recreateShape(): void;\n destroyBody(): void;\n }\n\n export class DefaultBodyUpdater {\n behavior: gdjs.Physics3DRuntimeBehavior;\n\n constructor(behavior: gdjs.Physics3DRuntimeBehavior) {\n this.behavior = behavior;\n }\n\n createAndAddBody(): Jolt.Body | null {\n const { behavior } = this;\n const { _sharedData } = behavior;\n\n const shape = behavior.createShape();\n const bodyCreationSettings = new Jolt.BodyCreationSettings(\n shape,\n behavior.getPhysicsPosition(_sharedData.getRVec3(0, 0, 0)),\n behavior.getPhysicsRotation(_sharedData.getQuat(0, 0, 0, 1)),\n behavior.bodyType === 'Static'\n ? Jolt.EMotionType_Static\n : behavior.bodyType === 'Kinematic'\n ? Jolt.EMotionType_Kinematic\n : Jolt.EMotionType_Dynamic,\n behavior.getBodyLayer()\n );\n bodyCreationSettings.mMotionQuality = behavior.bullet\n ? Jolt.EMotionQuality_LinearCast\n : Jolt.EMotionQuality_Discrete;\n bodyCreationSettings.mAllowedDOFs = behavior.fixedRotation\n ? Jolt.EAllowedDOFs_TranslationX |\n Jolt.EAllowedDOFs_TranslationY |\n Jolt.EAllowedDOFs_TranslationZ\n : Jolt.EAllowedDOFs_All;\n bodyCreationSettings.mFriction = behavior.friction;\n bodyCreationSettings.mRestitution = behavior.restitution;\n bodyCreationSettings.mLinearDamping = behavior.linearDamping;\n bodyCreationSettings.mAngularDamping = behavior.angularDamping;\n bodyCreationSettings.mGravityFactor = behavior.gravityScale;\n\n const bodyInterface = _sharedData.bodyInterface;\n const body = bodyInterface.CreateBody(bodyCreationSettings);\n Jolt.destroy(bodyCreationSettings);\n\n bodyInterface.AddBody(body.GetID(), Jolt.EActivation_Activate);\n return body;\n }\n\n updateObjectFromBody() {\n const { behavior } = this;\n const { _body } = behavior;\n // Copy transform from body to the GD object.\n // The body is null when the behavior was either deactivated or the object deleted.\n // It would be useless to try to recreate it as updateBodyFromObject already does it.\n // If the body is null, we just don't do anything\n // (but still run the physics simulation - this is independent).\n if (_body !== null && _body.IsActive()) {\n behavior.moveObjectToPhysicsPosition(_body.GetPosition());\n behavior.moveObjectToPhysicsRotation(_body.GetRotation());\n }\n }\n\n updateBodyFromObject() {\n const { behavior } = this;\n const { owner3D, _sharedData } = behavior;\n if (behavior._body === null) {\n if (!behavior._createBody()) return;\n }\n const body = behavior._body!;\n\n if (\n this.behavior._objectOldX !== owner3D.getX() ||\n this.behavior._objectOldY !== owner3D.getY() ||\n this.behavior._objectOldZ !== owner3D.getZ() ||\n this.behavior._objectOldRotationX !== owner3D.getRotationX() ||\n this.behavior._objectOldRotationY !== owner3D.getRotationY() ||\n this.behavior._objectOldRotationZ !== owner3D.getAngle()\n ) {\n _sharedData.bodyInterface.SetPositionAndRotationWhenChanged(\n body.GetID(),\n this.behavior.getPhysicsPosition(_sharedData.getRVec3(0, 0, 0)),\n this.behavior.getPhysicsRotation(_sharedData.getQuat(0, 0, 0, 1)),\n Jolt.EActivation_Activate\n );\n }\n }\n\n recreateShape() {\n const { behavior } = this;\n const { _sharedData } = behavior;\n if (behavior._body === null) {\n if (!behavior._createBody()) return;\n }\n const body = behavior._body!;\n\n const bodyInterface = _sharedData.bodyInterface;\n bodyInterface.SetShape(\n body.GetID(),\n behavior.createShape(),\n true,\n Jolt.EActivation_Activate\n );\n }\n\n destroyBody() {\n const { behavior } = this;\n const { _sharedData } = behavior;\n if (behavior._body !== null) {\n _sharedData.bodyInterface.RemoveBody(behavior._body.GetID());\n _sharedData.bodyInterface.DestroyBody(behavior._body.GetID());\n behavior._body = null;\n }\n }\n }\n\n export interface CollisionChecker {\n isColliding(object: gdjs.RuntimeObject): boolean;\n hasCollisionStartedWith(object: gdjs.RuntimeObject): boolean;\n hasCollisionStoppedWith(object: gdjs.RuntimeObject): boolean;\n }\n\n /**\n * The default collision checker uses the contacts found while\n * stepping the physics simulation. For characters, another one is used\n * as characters are simulated before the rest of the physics simulation.\n */\n export class DefaultCollisionChecker implements CollisionChecker {\n behavior: gdjs.Physics3DRuntimeBehavior;\n\n constructor(behavior: gdjs.Physics3DRuntimeBehavior) {\n this.behavior = behavior;\n }\n\n isColliding(object: gdjs.RuntimeObject): boolean {\n if (\n this.behavior._currentContacts.some(\n (behavior) => behavior.owner === object\n )\n ) {\n return true;\n }\n return this.behavior._contactsStartedThisFrame.some(\n (behavior) => behavior.owner === object\n );\n }\n\n hasCollisionStartedWith(object: gdjs.RuntimeObject): boolean {\n return this.behavior._contactsStartedThisFrame.some(\n (behavior) => behavior.owner === object\n );\n }\n\n hasCollisionStoppedWith(object: gdjs.RuntimeObject): boolean {\n return this.behavior._contactsEndedThisFrame.some(\n (behavior) => behavior.owner === object\n );\n }\n }\n }\n}\n"],
5
+ "mappings": "AAQA,GAAU,MAAV,UAAU,EAAV,CACE,KAAM,GAAW,SAAY,CAC3B,GAAI,CAEF,KAAM,GAAwB,AADf,MAAM,QAAO,2BACS,QACrC,GAAI,CAAC,EACH,KAAM,IAAI,OAAM,oCAGlB,KAAM,GAAO,KAAM,KACnB,OAAO,KAAO,QACP,EAAP,CACA,cAAQ,MAAM,uCAAwC,GAChD,IAGV,EAAK,4CAA4C,KA4B1C,OAA0B,CA4B/B,YAAY,EAAkD,EAAY,CAf1E,eAAY,GAAI,MAAK,KACrB,gBAAa,GAAI,MAAK,MACtB,eAAY,GAAI,MAAK,KAErB,aAAmB,GAQX,qBACN,GAGA,KAAK,qBAAu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,EAAS,QAAU,MACjB,CAAC,EAAS,cAAe,OAE/B,KAAM,GAAO,EAAS,MAGtB,AADsB,EAAY,cACpB,SACZ,EAAK,QACL,EAAS,cACT,GACA,KAAK,sBAIT,aAAc,CACZ,KAAM,CAAE,YAAa,KACf,CAAE,eAAgB,EACxB,AAAI,EAAS,QAAU,MACrB,GAAY,cAAc,WAAW,EAAS,MAAM,SACpD,EAAY,cAAc,YAAY,EAAS,MAAM,SACrD,EAAS,MAAQ,OA3GhB,EAAM,qBA2HN,OAA0D,CAG/D,YAAY,EAAyC,CACnD,KAAK,SAAW,EAGlB,YAAY,EAAqC,CAC/C,MACE,MAAK,SAAS,iBAAiB,KAC7B,AAAC,GAAa,EAAS,QAAU,GAG5B,GAEF,KAAK,SAAS,0BAA0B,KAC7C,AAAC,GAAa,EAAS,QAAU,GAIrC,wBAAwB,EAAqC,CAC3D,MAAO,MAAK,SAAS,0BAA0B,KAC7C,AAAC,GAAa,EAAS,QAAU,GAIrC,wBAAwB,EAAqC,CAC3D,MAAO,MAAK,SAAS,wBAAwB,KAC3C,AAAC,GAAa,EAAS,QAAU,IA5BhC,EAAM,2BA/IE,iEA3sDT",
6
6
  "names": []
7
7
  }
@@ -1,2 +1,2 @@
1
- var gdjs;(function(h){const F=class extends h.RuntimeBehavior{constructor(e,t,a){super(e,t,a);this._physics3D=null;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=a,this._physics3DBehaviorName=t.physics3D,this._sharedData=h.Physics3DSharedData.getSharedData(e.getScene(),t.Physics3D),this.collisionChecker=new h.PhysicsCharacter3DRuntimeBehavior.CharacterCollisionChecker(this),this.charactersManager=h.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,a){const o=this._sharedData._tempVec3;return o.Set(e,t,a),o}getPhysics3D(){if(this._destroyedDuringFrameLogic)return null;if(this._physics3D)return this._physics3D;const e=this.owner.getBehavior(this._physics3DBehaviorName),t=e._sharedData,a=t.jolt,o=new Jolt.ExtendedUpdateSettings,s=new Jolt.DefaultBroadPhaseLayerFilter(a.GetObjectVsBroadPhaseLayerFilter(),h.Physics3DSharedData.dynamicBroadPhaseLayerIndex),r=new Jolt.DefaultObjectLayerFilter(a.GetObjectLayerPairFilter(),e.getBodyLayer()),i=new Jolt.BodyFilter,c=new Jolt.ShapeFilter;return this._physics3D={behavior:e,extendedUpdateSettings:o,broadPhaseLayerFilter:s,objectLayerFilter:r,bodyFilter:i,shapeFilter:c},this.setStairHeightMax(this._stairHeightMax),t.registerHook(this),e.bodyUpdater=new h.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:a}=t;return e.Set(this.owner3D.getCenterXInScene()*this._sharedData.worldInvScale,this.owner3D.getCenterYInScene()*this._sharedData.worldInvScale,this.owner3D.getZ()*this._sharedData.worldInvScale+a._shapeHalfDepth),e}getPhysicsRotation(e){const t=e.sEulerAngles(this.getVec3(0,0,h.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:a}=t;this.owner3D.setCenterXInScene(e.GetX()*this._sharedData.worldScale),this.owner3D.setCenterYInScene(e.GetY()*this._sharedData.worldScale),this.owner3D.setZ((e.GetZ()-a._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 a=new THREE.Euler(0,0,0,"ZYX");a.setFromQuaternion(t.quaternion),this.owner3D.setAngle(h.toDegrees(a.z))}onDeActivate(){this.collisionChecker.clearContacts()}onActivate(){}onDestroy(){this._destroyedDuringFrameLogic=!0,this.onDeActivate(),this._destroyCharacter()}_destroyCharacter(){if(this.character&&(this._canBePushed&&this.charactersManager.removeCharacter(this.character),Jolt.destroy(this.character),this.character=null,this._physics3D)){this._physics3D.behavior._body=null;const{extendedUpdateSettings:e,broadPhaseLayerFilter:t,objectLayerFilter:a,bodyFilter:o,shapeFilter:s}=this._physics3D;Jolt.destroy(e),Jolt.destroy(t),Jolt.destroy(a),Jolt.destroy(o),Jolt.destroy(s),this._physics3D=null}}doStepPreEvents(e){this.getPhysics3D()}doBeforePhysicsStep(e){if(!this.activated())return;const t=this.getPhysics3D();if(!t)return;const{behavior:a,extendedUpdateSettings:o,broadPhaseLayerFilter:s,objectLayerFilter:r,bodyFilter:i,shapeFilter:c}=t;if(!this.character||!a._body)return;const n=this._sharedData.worldInvScale,d=this.character.GetPosition().GetX(),C=this.character.GetPosition().GetY(),S=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 v=0,M=0,A=0;if(this.character.IsSupported()&&this.updateGroundVelocity(a,e)){const _=this.character.GetGroundVelocity();v=_.GetX(),M=_.GetY(),A=_.GetZ()}let p=this._currentForwardSpeed,m=this._currentSidewaysSpeed;if(m!==0&&p!==0){const u=Math.hypot(p/this._forwardSpeedMax,m/this._sidewaysSpeedMax);u>1&&(p/=u,m/=u)}p*=n,m*=n;const y=h.toRad(this._forwardAngle),f=Math.cos(y),g=Math.sin(y),w=p*f-m*g,P=p*g+m*f;if(this.character.SetLinearVelocity(this.getVec3(v+w,M+P,(this._currentJumpSpeed-this._currentFallSpeed)*n)),this.isOnFloor()){const u=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 _=Math.max(-.01+1.01*Math.min(-u*this._slopeClimbingFactor,A*e),-this._maxFallingSpeed*n*e);o.mStickToFloorStepDown.Set(0,0,_)}else o.mStickToFloorStepDown.Set(0,0,0);this.character.ExtendedUpdate(e,this.character.GetUp(),o,s,r,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._hasPressedJumpKey,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()-d)>F.epsilon||Math.abs(this.character.GetPosition().GetY()-C)>F.epsilon||Math.abs(this.character.GetPosition().GetZ()-S)>F.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(h.toRad(this._stickAngle))),this._currentForwardSpeed=F.getAcceleratedSpeed(this._currentForwardSpeed,t,this._forwardSpeedMax,this._forwardAcceleration,this._forwardDeceleration,e);let a=0;this._hasPressedLeftKey!==this._hasPressedRightKey?this._hasPressedLeftKey?a=-this._sidewaysSpeedMax:this._hasPressedRightKey&&(a=this._sidewaysSpeedMax):this._hasUsedStick&&(a=this._sidewaysSpeedMax*this._stickForce*Math.cos(h.toRad(this._stickAngle))),this._currentSidewaysSpeed=F.getAcceleratedSpeed(this._currentSidewaysSpeed,a,this._sidewaysSpeedMax,this._sidewaysAcceleration,this._sidewaysDeceleration,e)}static getAcceleratedSpeed(e,t,a,o,s,r){let i=e;return t<0?e<=t?i=Math.min(t,e+s*r):e<=0?i-=Math.max(-a,o*r):i=Math.max(t,e-Math.max(o,s)*r):t>0?e>=t?i=Math.max(t,e-s*r):e>=0?i=Math.min(a,e+o*r):i=Math.min(t,e+Math.max(o,s)*r):(e<0&&(i=Math.min(e+s*r,0)),e>0&&(i=Math.max(e-s*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 s=this._sharedData.physicsSystem.GetBodyLockInterface().TryGetBody(this.character.GetGroundBodyID()),r=s.IsKinematic()&&s.GetLinearVelocity().Equals(Jolt.Vec3.prototype.sZero())&&s.GetAngularVelocity().Equals(Jolt.Vec3.prototype.sZero());if(r){const n=s.gdjsAssociatedBehavior;if(n){const d=1/t;s.SetLinearVelocity(this.getVec3((n.owner3D.getX()-n._objectOldX)*o*d,(n.owner3D.getY()-n._objectOldY)*o*d,(n.owner3D.getZ()-n._objectOldZ)*o*d)),s.SetAngularVelocity(this.getVec3(0,0,h.toRad(h.evtTools.common.angleDifference(n.owner3D.getAngle(),n._objectOldRotationZ))*d))}}this.character.UpdateGroundVelocity();const i=s.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+=h.toDegrees(n)}r&&(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}doStepPostEvents(e){}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(h.toRad(e))),this._slopeClimbingMinNormalZ=Math.min(Math.cos(h.toRad(e)),1-1/1024))}getStairHeightMax(){return this._stairHeightMax}setStairHeightMax(e){this._stairHeightMax=e;const t=this.getPhysics3D();if(!t)return;const{extendedUpdateSettings:a}=t,o=e*this._sharedData.worldInvScale;a.mWalkStairsStepUp=this.getVec3(0,0,o),a.mWalkStairsMinStepForward=.02/.4*o,a.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 a=this._currentFallSpeed-e;a>0&&(this._currentFallSpeed-=a,this._currentJumpSpeed=Math.max(0,this.getCurrentJumpSpeed()-a))}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(h.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=h.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._currentJumpSpeed!==0||this._currentFallSpeed!==0}getJumpSpeedToReach(e){e=-Math.abs(e);const t=this._gravity,a=this._maxFallingSpeed,o=this._jumpSustainTime,s=a/t,r=n=>Math.sqrt(-n*t*2),i=n=>-t*o+a+Math.sqrt(t*t*o*o-2*n*t-a*a);let c=0,l=0;return s>o?(c=-t*o+Math.sqrt(2*t*t*o*o-4*e*t),l=(t*o+c)/(2*t),l<o?c=r(e):l>s&&(c=i(e))):(c=r(e),l=c/t,l>s&&(c=i(e))),c}};let b=F;b.epsilon=2**-20,h.PhysicsCharacter3DRuntimeBehavior=b,h.registerBehavior("Physics3D::PhysicsCharacter3D",h.PhysicsCharacter3DRuntimeBehavior),function(a){class D{constructor(s){this.characterVsCharacterCollision=new Jolt.CharacterVsCharacterCollisionSimple}static getManager(s){return s.charactersManager||(s.charactersManager=new h.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)}}a.CharactersManager=D,h.registerRuntimeSceneUnloadedCallback(function(o){h.PhysicsCharacter3DRuntimeBehavior.CharactersManager.getManager(o).destroy()});class e{constructor(s){this.characterBehavior=s}createAndAddBody(){const s=this.characterBehavior.getPhysics3D();if(!s)return null;const{behavior:r}=s,{_slopeMaxAngle:i,owner3D:c,_sharedData:l}=this.characterBehavior,n=r.createShape(),d=new Jolt.CharacterVirtualSettings;d.mInnerBodyLayer=this.characterBehavior._canBePushed?0:r.getBodyLayer(),d.mInnerBodyShape=n,d.mMass=n.GetMassProperties().get_mMass(),d.mMaxSlopeAngle=h.toRad(i),d.mShape=n,d.mUp=Jolt.Vec3.prototype.sAxisZ(),d.mBackFaceMode=Jolt.EBackFaceMode_CollideWithBackFaces;const C=c.getDepth()*l.worldInvScale,S=c.getWidth()*l.worldInvScale,v=c.getHeight()*l.worldInvScale,M=C/2,A=Math.sqrt(S*v)/2;d.mSupportingVolume=new Jolt.Plane(Jolt.Vec3.prototype.sAxisZ(),M-A*(1-Math.cos(h.toRad(Math.min(i+20,70)))));const p=new Jolt.CharacterVirtual(d,this.characterBehavior.getPhysicsPosition(l.getRVec3(0,0,0)),r.getPhysicsRotation(l.getQuat(0,0,0,1)),l.physicsSystem),m=l.physicsSystem.GetBodyLockInterface().TryGetBody(p.GetInnerBodyID());if(this.characterBehavior.character=p,this.characterBehavior._canBePushed){this.characterBehavior.charactersManager.addCharacter(p);const y=new Jolt.CharacterContactListenerJS;y.OnAdjustBodyVelocity=(f,g,w,P)=>{},y.OnContactValidate=(f,g,w)=>!0,y.OnCharacterContactValidate=(f,g,w)=>{const P=Jolt.wrapPointer(f,Jolt.CharacterVirtual),u=Jolt.wrapPointer(g,Jolt.CharacterVirtual),_=l.physicsSystem.GetBodyLockInterface().TryGetBody(P.GetInnerBodyID()),B=l.physicsSystem.GetBodyLockInterface().TryGetBody(u.GetInnerBodyID()),J=_.gdjsAssociatedBehavior,j=B.gdjsAssociatedBehavior;return!J||!j?!0:J.canCollideAgainst(j)},y.OnContactAdded=(f,g,w,P,u,_)=>{},y.OnCharacterContactAdded=(f,g,w,P,u,_)=>{},y.OnContactSolve=(f,g,w,P,u,_,B,J,j)=>{},y.OnCharacterContactSolve=(f,g,w,P,u,_,B,J,j)=>{},p.SetListener(y)}return m}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:r}=s,{character:i,owner3D:c,_sharedData:l}=this.characterBehavior;!i||((r._objectOldX!==c.getX()||r._objectOldY!==c.getY()||r._objectOldZ!==c.getZ())&&this.updateCharacterPosition(),(r._objectOldRotationX!==c.getRotationX()||r._objectOldRotationY!==c.getRotationY()||r._objectOldRotationZ!==c.getAngle())&&i.SetRotation(this.characterBehavior.getPhysicsRotation(l.getQuat(0,0,0,1))))}updateCharacterPosition(){const{character:s,_sharedData:r}=this.characterBehavior;!s||s.SetPosition(this.characterBehavior.getPhysicsPosition(r.getRVec3(0,0,0)))}recreateShape(){const s=this.characterBehavior.getPhysics3D();if(!s)return;const{behavior:r,broadPhaseLayerFilter:i,objectLayerFilter:c,bodyFilter:l,shapeFilter:n}=s,{character:d,_sharedData:C}=this.characterBehavior;if(!d)return;const S=r.createShape();!d.SetShape(S,Number.MAX_VALUE,i,c,l,n,C.jolt.GetTempAllocator())||(d.SetInnerBodyShape(S),d.SetMass(S.GetMassProperties().get_mMass()),this.updateCharacterPosition())}destroyBody(){this.characterBehavior._destroyCharacter()}}a.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:r,_sharedData:i}=this.characterBehavior;if(!r)return;const c=r.GetActiveContacts();for(let l=0;l<c.size();l++){const n=c.at(l),S=i.physicsSystem.GetBodyLockInterface().TryGetBody(n.mBodyB).gdjsAssociatedBehavior;S&&this._currentContacts.push(S)}}isColliding(s){const{character:r}=this.characterBehavior;return r?this._currentContacts.some(i=>i.owner===s):!1}hasCollisionStartedWith(s){const{character:r}=this.characterBehavior;return r?this._currentContacts.some(i=>i.owner===s)&&!this._previousContacts.some(i=>i.owner===s):!1}hasCollisionStoppedWith(s){const{character:r}=this.characterBehavior;return r?!this._currentContacts.some(i=>i.owner===s)&&this._previousContacts.some(i=>i.owner===s):!1}}a.CharacterCollisionChecker=t}(b=h.PhysicsCharacter3DRuntimeBehavior||(h.PhysicsCharacter3DRuntimeBehavior={}))})(gdjs||(gdjs={}));
1
+ var gdjs;(function(h){const F=class extends h.RuntimeBehavior{constructor(e,t,a){super(e,t,a);this._physics3D=null;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=a,this._physics3DBehaviorName=t.physics3D,this._sharedData=h.Physics3DSharedData.getSharedData(e.getScene(),t.Physics3D),this.collisionChecker=new h.PhysicsCharacter3DRuntimeBehavior.CharacterCollisionChecker(this),this.charactersManager=h.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,a){const o=this._sharedData._tempVec3;return o.Set(e,t,a),o}getPhysics3D(){if(this._destroyedDuringFrameLogic)return null;if(this._physics3D)return this._physics3D;const e=this.owner.getBehavior(this._physics3DBehaviorName),t=e._sharedData,a=t.jolt,o=new Jolt.ExtendedUpdateSettings,s=new Jolt.DefaultBroadPhaseLayerFilter(a.GetObjectVsBroadPhaseLayerFilter(),h.Physics3DSharedData.dynamicBroadPhaseLayerIndex),r=new Jolt.DefaultObjectLayerFilter(a.GetObjectLayerPairFilter(),e.getBodyLayer()),i=new Jolt.BodyFilter,c=new Jolt.ShapeFilter;return this._physics3D={behavior:e,extendedUpdateSettings:o,broadPhaseLayerFilter:s,objectLayerFilter:r,bodyFilter:i,shapeFilter:c},this.setStairHeightMax(this._stairHeightMax),t.registerHook(this),e.bodyUpdater=new h.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:a}=t;return e.Set(this.owner3D.getCenterXInScene()*this._sharedData.worldInvScale,this.owner3D.getCenterYInScene()*this._sharedData.worldInvScale,this.owner3D.getZ()*this._sharedData.worldInvScale+a._shapeHalfDepth),e}getPhysicsRotation(e){const t=e.sEulerAngles(this.getVec3(0,0,h.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:a}=t;this.owner3D.setCenterXInScene(e.GetX()*this._sharedData.worldScale),this.owner3D.setCenterYInScene(e.GetY()*this._sharedData.worldScale),this.owner3D.setZ((e.GetZ()-a._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 a=new THREE.Euler(0,0,0,"ZYX");a.setFromQuaternion(t.quaternion),this.owner3D.setAngle(h.toDegrees(a.z))}onDeActivate(){this.collisionChecker.clearContacts()}onActivate(){}onDestroy(){this._destroyedDuringFrameLogic=!0,this.onDeActivate(),this._destroyCharacter()}_destroyCharacter(){if(this.character&&(this._canBePushed&&this.charactersManager.removeCharacter(this.character),Jolt.destroy(this.character),this.character=null,this._physics3D)){this._physics3D.behavior._body=null;const{extendedUpdateSettings:e,broadPhaseLayerFilter:t,objectLayerFilter:a,bodyFilter:o,shapeFilter:s}=this._physics3D;Jolt.destroy(e),Jolt.destroy(t),Jolt.destroy(a),Jolt.destroy(o),Jolt.destroy(s),this._physics3D=null}}doStepPreEvents(e){this.getPhysics3D()}doBeforePhysicsStep(e){if(!this.activated())return;const t=this.getPhysics3D();if(!t)return;const{behavior:a,extendedUpdateSettings:o,broadPhaseLayerFilter:s,objectLayerFilter:r,bodyFilter:i,shapeFilter:c}=t;if(!this.character||!a._body)return;const n=this._sharedData.worldInvScale,d=this.character.GetPosition().GetX(),C=this.character.GetPosition().GetY(),S=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 v=0,M=0,A=0;if(this.character.IsSupported()&&this.updateGroundVelocity(a,e)){const _=this.character.GetGroundVelocity();v=_.GetX(),M=_.GetY(),A=_.GetZ()}let p=this._currentForwardSpeed,m=this._currentSidewaysSpeed;if(m!==0&&p!==0){const u=Math.hypot(p/this._forwardSpeedMax,m/this._sidewaysSpeedMax);u>1&&(p/=u,m/=u)}p*=n,m*=n;const y=h.toRad(this._forwardAngle),f=Math.cos(y),g=Math.sin(y),w=p*f-m*g,P=p*g+m*f;if(this.character.SetLinearVelocity(this.getVec3(v+w,M+P,(this._currentJumpSpeed-this._currentFallSpeed)*n)),this.isOnFloor()){const u=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 _=Math.max(-.01+1.01*Math.min(-u*this._slopeClimbingFactor,A*e),-this._maxFallingSpeed*n*e);o.mStickToFloorStepDown.Set(0,0,_)}else o.mStickToFloorStepDown.Set(0,0,0);this.character.ExtendedUpdate(e,this.character.GetUp(),o,s,r,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._hasPressedJumpKey,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()-d)>F.epsilon||Math.abs(this.character.GetPosition().GetY()-C)>F.epsilon||Math.abs(this.character.GetPosition().GetZ()-S)>F.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(h.toRad(this._stickAngle))),this._currentForwardSpeed=F.getAcceleratedSpeed(this._currentForwardSpeed,t,this._forwardSpeedMax,this._forwardAcceleration,this._forwardDeceleration,e);let a=0;this._hasPressedLeftKey!==this._hasPressedRightKey?this._hasPressedLeftKey?a=-this._sidewaysSpeedMax:this._hasPressedRightKey&&(a=this._sidewaysSpeedMax):this._hasUsedStick&&(a=this._sidewaysSpeedMax*this._stickForce*Math.cos(h.toRad(this._stickAngle))),this._currentSidewaysSpeed=F.getAcceleratedSpeed(this._currentSidewaysSpeed,a,this._sidewaysSpeedMax,this._sidewaysAcceleration,this._sidewaysDeceleration,e)}static getAcceleratedSpeed(e,t,a,o,s,r){let i=e;return t<0?e<=t?i=Math.min(t,e+s*r):e<=0?i-=Math.max(-a,o*r):i=Math.max(t,e-Math.max(o,s)*r):t>0?e>=t?i=Math.max(t,e-s*r):e>=0?i=Math.min(a,e+o*r):i=Math.min(t,e+Math.max(o,s)*r):(e<0&&(i=Math.min(e+s*r,0)),e>0&&(i=Math.max(e-s*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 s=this._sharedData.physicsSystem.GetBodyLockInterface().TryGetBody(this.character.GetGroundBodyID()),r=s.IsKinematic()&&s.GetLinearVelocity().Equals(Jolt.Vec3.prototype.sZero())&&s.GetAngularVelocity().Equals(Jolt.Vec3.prototype.sZero());if(r){const n=s.gdjsAssociatedBehavior;if(n){const d=1/t;s.SetLinearVelocity(this.getVec3((n.owner3D.getX()-n._objectOldX)*o*d,(n.owner3D.getY()-n._objectOldY)*o*d,(n.owner3D.getZ()-n._objectOldZ)*o*d)),s.SetAngularVelocity(this.getVec3(0,0,h.toRad(h.evtTools.common.angleDifference(n.owner3D.getAngle(),n._objectOldRotationZ))*d))}}this.character.UpdateGroundVelocity();const i=s.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+=h.toDegrees(n)}r&&(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}doStepPostEvents(e){}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(h.toRad(e))),this._slopeClimbingMinNormalZ=Math.min(Math.cos(h.toRad(e)),1-1/1024))}getStairHeightMax(){return this._stairHeightMax}setStairHeightMax(e){this._stairHeightMax=e;const t=this.getPhysics3D();if(!t)return;const{extendedUpdateSettings:a}=t,o=e*this._sharedData.worldInvScale;a.mWalkStairsStepUp=this.getVec3(0,0,o),a.mWalkStairsMinStepForward=.02/.4*o,a.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 a=this._currentFallSpeed-e;a>0&&(this._currentFallSpeed-=a,this._currentJumpSpeed=Math.max(0,this.getCurrentJumpSpeed()-a))}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(h.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=h.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,a=this._maxFallingSpeed,o=this._jumpSustainTime,s=a/t,r=n=>Math.sqrt(-n*t*2),i=n=>-t*o+a+Math.sqrt(t*t*o*o-2*n*t-a*a);let c=0,l=0;return s>o?(c=-t*o+Math.sqrt(2*t*t*o*o-4*e*t),l=(t*o+c)/(2*t),l<o?c=r(e):l>s&&(c=i(e))):(c=r(e),l=c/t,l>s&&(c=i(e))),c}};let b=F;b.epsilon=2**-20,h.PhysicsCharacter3DRuntimeBehavior=b,h.registerBehavior("Physics3D::PhysicsCharacter3D",h.PhysicsCharacter3DRuntimeBehavior),function(a){class D{constructor(s){this.characterVsCharacterCollision=new Jolt.CharacterVsCharacterCollisionSimple}static getManager(s){return s.charactersManager||(s.charactersManager=new h.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)}}a.CharactersManager=D,h.registerRuntimeSceneUnloadedCallback(function(o){h.PhysicsCharacter3DRuntimeBehavior.CharactersManager.getManager(o).destroy()});class e{constructor(s){this.characterBehavior=s}createAndAddBody(){const s=this.characterBehavior.getPhysics3D();if(!s)return null;const{behavior:r}=s,{_slopeMaxAngle:i,owner3D:c,_sharedData:l}=this.characterBehavior,n=r.createShape(),d=new Jolt.CharacterVirtualSettings;d.mInnerBodyLayer=this.characterBehavior._canBePushed?0:r.getBodyLayer(),d.mInnerBodyShape=n,d.mMass=n.GetMassProperties().get_mMass(),d.mMaxSlopeAngle=h.toRad(i),d.mShape=n,d.mUp=Jolt.Vec3.prototype.sAxisZ(),d.mBackFaceMode=Jolt.EBackFaceMode_CollideWithBackFaces;const C=c.getDepth()*l.worldInvScale,S=c.getWidth()*l.worldInvScale,v=c.getHeight()*l.worldInvScale,M=C/2,A=Math.sqrt(S*v)/2;d.mSupportingVolume=new Jolt.Plane(Jolt.Vec3.prototype.sAxisZ(),M-A*(1-Math.cos(h.toRad(Math.min(i+20,70)))));const p=new Jolt.CharacterVirtual(d,this.characterBehavior.getPhysicsPosition(l.getRVec3(0,0,0)),r.getPhysicsRotation(l.getQuat(0,0,0,1)),l.physicsSystem),m=l.physicsSystem.GetBodyLockInterface().TryGetBody(p.GetInnerBodyID());if(this.characterBehavior.character=p,this.characterBehavior._canBePushed){this.characterBehavior.charactersManager.addCharacter(p);const y=new Jolt.CharacterContactListenerJS;y.OnAdjustBodyVelocity=(f,g,w,P)=>{},y.OnContactValidate=(f,g,w)=>!0,y.OnCharacterContactValidate=(f,g,w)=>{const P=Jolt.wrapPointer(f,Jolt.CharacterVirtual),u=Jolt.wrapPointer(g,Jolt.CharacterVirtual),_=l.physicsSystem.GetBodyLockInterface().TryGetBody(P.GetInnerBodyID()),B=l.physicsSystem.GetBodyLockInterface().TryGetBody(u.GetInnerBodyID()),J=_.gdjsAssociatedBehavior,j=B.gdjsAssociatedBehavior;return!J||!j?!0:J.canCollideAgainst(j)},y.OnContactAdded=(f,g,w,P,u,_)=>{},y.OnCharacterContactAdded=(f,g,w,P,u,_)=>{},y.OnContactSolve=(f,g,w,P,u,_,B,J,j)=>{},y.OnCharacterContactSolve=(f,g,w,P,u,_,B,J,j)=>{},p.SetListener(y)}return m}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:r}=s,{character:i,owner3D:c,_sharedData:l}=this.characterBehavior;!i||((r._objectOldX!==c.getX()||r._objectOldY!==c.getY()||r._objectOldZ!==c.getZ())&&this.updateCharacterPosition(),(r._objectOldRotationX!==c.getRotationX()||r._objectOldRotationY!==c.getRotationY()||r._objectOldRotationZ!==c.getAngle())&&i.SetRotation(this.characterBehavior.getPhysicsRotation(l.getQuat(0,0,0,1))))}updateCharacterPosition(){const{character:s,_sharedData:r}=this.characterBehavior;!s||s.SetPosition(this.characterBehavior.getPhysicsPosition(r.getRVec3(0,0,0)))}recreateShape(){const s=this.characterBehavior.getPhysics3D();if(!s)return;const{behavior:r,broadPhaseLayerFilter:i,objectLayerFilter:c,bodyFilter:l,shapeFilter:n}=s,{character:d,_sharedData:C}=this.characterBehavior;if(!d)return;const S=r.createShape();!d.SetShape(S,Number.MAX_VALUE,i,c,l,n,C.jolt.GetTempAllocator())||(d.SetInnerBodyShape(S),d.SetMass(S.GetMassProperties().get_mMass()),this.updateCharacterPosition())}destroyBody(){this.characterBehavior._destroyCharacter()}}a.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:r,_sharedData:i}=this.characterBehavior;if(!r)return;const c=r.GetActiveContacts();for(let l=0;l<c.size();l++){const n=c.at(l),S=i.physicsSystem.GetBodyLockInterface().TryGetBody(n.mBodyB).gdjsAssociatedBehavior;S&&this._currentContacts.push(S)}}isColliding(s){const{character:r}=this.characterBehavior;return r?this._currentContacts.some(i=>i.owner===s):!1}hasCollisionStartedWith(s){const{character:r}=this.characterBehavior;return r?this._currentContacts.some(i=>i.owner===s)&&!this._previousContacts.some(i=>i.owner===s):!1}hasCollisionStoppedWith(s){const{character:r}=this.characterBehavior;return r?!this._currentContacts.some(i=>i.owner===s)&&this._previousContacts.some(i=>i.owner===s):!1}}a.CharacterCollisionChecker=t}(b=h.PhysicsCharacter3DRuntimeBehavior||(h.PhysicsCharacter3DRuntimeBehavior={}))})(gdjs||(gdjs={}));
2
2
  //# sourceMappingURL=PhysicsCharacter3DRuntimeBehavior.js.map