@nice2dev/game-engine 1.3.14 → 1.3.16
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.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/accessibility/Accessibility.js +152 -165
- package/dist/cjs/ai/AI.js +292 -294
- package/dist/cjs/ai/BehaviorTree.js +1029 -1113
- package/dist/cjs/ai/StateMachine.js +694 -756
- package/dist/cjs/animation/Animation.js +232 -241
- package/dist/cjs/audio/AudioAdvanced.js +221 -236
- package/dist/cjs/audio/AudioBridge.js +441 -435
- package/dist/cjs/audio/AudioManager.js +242 -259
- package/dist/cjs/build-cloud/BuildOrchestration.js +1059 -1098
- package/dist/cjs/build-cloud/GodotBuildCloud.js +641 -670
- package/dist/cjs/build-cloud/UnityBuildCloud.js +563 -610
- package/dist/cjs/build-cloud/UnrealBuildCloud.js +610 -635
- package/dist/cjs/core/EventBus.js +51 -56
- package/dist/cjs/core/GameClock.js +62 -66
- package/dist/cjs/core/GameConfig.js +72 -79
- package/dist/cjs/core/GameLoop.js +80 -89
- package/dist/cjs/core/ServiceLocator.js +61 -65
- package/dist/cjs/core/Validation.js +72 -82
- package/dist/cjs/core/math.js +108 -112
- package/dist/cjs/devtools/DevTools.js +542 -563
- package/dist/cjs/devtools/DeveloperExperience.js +521 -559
- package/dist/cjs/devtools/GameplayAnalytics.js +636 -646
- package/dist/cjs/dialogue/DialogueSystem.js +984 -986
- package/dist/cjs/docs/DocGenerator.js +339 -364
- package/dist/cjs/ecs/World.js +355 -371
- package/dist/cjs/editor/AchievementEditor.js +580 -636
- package/dist/cjs/editor/AdvancedEditor.js +184 -191
- package/dist/cjs/editor/AnimationRetargeting.js +696 -741
- package/dist/cjs/editor/AssetBrowser.js +1072 -1160
- package/dist/cjs/editor/AssetManager.js +187 -192
- package/dist/cjs/editor/ConsolePro.js +971 -1061
- package/dist/cjs/editor/CraftingEditor.js +680 -730
- package/dist/cjs/editor/DebugTools.js +187 -185
- package/dist/cjs/editor/DialogueSystem.js +844 -901
- package/dist/cjs/editor/LeaderboardSystem.js +429 -483
- package/dist/cjs/editor/NiceGameEditor.js +1903 -1201
- package/dist/cjs/editor/PrefabSystem.js +772 -838
- package/dist/cjs/editor/ProfilerPanel.js +649 -700
- package/dist/cjs/editor/QuestEditor.js +792 -839
- package/dist/cjs/editor/ReplaySystem.js +585 -634
- package/dist/cjs/editor/SceneEditor.js +176 -200
- package/dist/cjs/editor/ScreenshotMode.js +621 -688
- package/dist/cjs/editor/ShaderGraph.js +1556 -1582
- package/dist/cjs/editor/TimelineEditor.js +715 -778
- package/dist/cjs/editor/UndoRedoPro.js +830 -904
- package/dist/cjs/editor/VRARMode.js +582 -645
- package/dist/cjs/engine/NiceGameEngine.js +141 -164
- package/dist/cjs/engine/SaveSystem.js +441 -495
- package/dist/cjs/enterprise/Enterprise.js +254 -261
- package/dist/cjs/export/BevyExporter.js +927 -967
- package/dist/cjs/export/CocosExporter.js +644 -673
- package/dist/cjs/export/Construct3Exporter.js +783 -794
- package/dist/cjs/export/DefoldExporter.js +1028 -1069
- package/dist/cjs/export/GDevelopExporter.js +674 -708
- package/dist/cjs/export/GameMakerExporter.js +791 -805
- package/dist/cjs/export/GodotExporter.js +1003 -1045
- package/dist/cjs/export/MinecraftBedrockExporter.js +573 -578
- package/dist/cjs/export/MonoGameExporter.js +1265 -1293
- package/dist/cjs/export/Pico8Exporter.js +766 -812
- package/dist/cjs/export/PlatformExporter.js +188 -206
- package/dist/cjs/export/RPGMakerExporter.js +860 -879
- package/dist/cjs/export/RobloxExporter.js +883 -919
- package/dist/cjs/export/Solar2DExporter.js +1218 -1256
- package/dist/cjs/export/ThreeJSExporter.js +1006 -1073
- package/dist/cjs/export/Tic80Exporter.js +1210 -1267
- package/dist/cjs/export/UnityExporter.js +1116 -1131
- package/dist/cjs/export/UnrealExporter.js +889 -919
- package/dist/cjs/export/WebExporter.js +931 -970
- package/dist/cjs/export/index.js +42 -65
- package/dist/cjs/godot-integration/GodotAssetLibrary.js +659 -692
- package/dist/cjs/godot-integration/GodotImport.js +929 -1027
- package/dist/cjs/godot-integration/GodotLiveLink.js +915 -945
- package/dist/cjs/godot-integration/components/GodotProjectBrowser.js +911 -611
- package/dist/cjs/i18n/I18n.js +860 -900
- package/dist/cjs/i18n/useTranslation.js +84 -89
- package/dist/cjs/import/AsepriteImporter.js +658 -716
- package/dist/cjs/import/DragonBonesImporter.js +437 -461
- package/dist/cjs/import/GameMakerImporter.js +511 -521
- package/dist/cjs/import/GodotSceneImporter.js +788 -822
- package/dist/cjs/import/LDtkImporter.js +436 -454
- package/dist/cjs/import/Live2DImporter.js +497 -518
- package/dist/cjs/import/NdgFormat.js +424 -457
- package/dist/cjs/import/OgmoImporter.js +466 -493
- package/dist/cjs/import/RPGMakerImporter.js +451 -477
- package/dist/cjs/import/SceneImporter.js +378 -423
- package/dist/cjs/import/SpineImporter.js +511 -546
- package/dist/cjs/import/SpriterImporter.js +590 -613
- package/dist/cjs/import/TiledMapImporter.js +811 -846
- package/dist/cjs/import/UnitySceneImporter.js +687 -703
- package/dist/cjs/import/index.js +206 -251
- package/dist/cjs/index.js +275 -278
- package/dist/cjs/input/GamepadNavigation.js +185 -205
- package/dist/cjs/input/InputManager.js +397 -421
- package/dist/cjs/input/useGamepads.js +70 -81
- package/dist/cjs/integration/IconSprite.js +129 -256
- package/dist/cjs/inventory/InventorySystem.js +920 -995
- package/dist/cjs/kids/KidMode.js +997 -1022
- package/dist/cjs/kids/KidTools.js +570 -594
- package/dist/cjs/monetization/Monetization.js +170 -177
- package/dist/cjs/multiplayer/LocalMultiplayer.js +287 -287
- package/dist/cjs/multiplayer/MiniGameTypes.js +49 -59
- package/dist/cjs/native-engine/AnimationSystem.js +731 -806
- package/dist/cjs/native-engine/AssetPipeline.js +454 -515
- package/dist/cjs/native-engine/AudioEngine.js +763 -804
- package/dist/cjs/native-engine/InputSystem.js +1075 -1145
- package/dist/cjs/native-engine/NetworkingSystem.js +733 -793
- package/dist/cjs/native-engine/PhysicsEngine.js +583 -607
- package/dist/cjs/native-engine/RenderingEngine.js +302 -350
- package/dist/cjs/native-engine/SceneGraph.js +769 -808
- package/dist/cjs/network/MultiplayerTransport.js +97 -132
- package/dist/cjs/network/Networking.js +549 -564
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AbortController.js +21 -29
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js +40 -48
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +35 -43
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +10 -15
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Errors.js +103 -135
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +131 -158
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +39 -53
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +5 -8
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +40 -48
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +494 -572
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +826 -953
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +125 -146
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +13 -23
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ILogger.js +11 -25
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ITransport.js +13 -24
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +108 -121
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Loggers.js +10 -14
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +150 -185
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js +158 -196
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +90 -105
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Subject.js +30 -35
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +16 -21
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Utils.js +215 -248
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +135 -157
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +76 -85
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/index.js +24 -27
- package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/pkg-version.js +3 -4
- package/dist/cjs/pathfinding/Pathfinding.js +245 -263
- package/dist/cjs/performance/AssetStreaming.js +561 -635
- package/dist/cjs/performance/BenchmarkSuite.js +283 -311
- package/dist/cjs/performance/DeltaCompression.js +467 -526
- package/dist/cjs/performance/DeterministicPhysics.js +450 -498
- package/dist/cjs/performance/ECSOptimization.js +644 -695
- package/dist/cjs/performance/GameSaveSystem.js +509 -556
- package/dist/cjs/performance/HotReload.js +447 -500
- package/dist/cjs/performance/InputRecording.js +511 -561
- package/dist/cjs/performance/InterestManagement.js +453 -500
- package/dist/cjs/performance/LocalizationRuntime.js +376 -423
- package/dist/cjs/performance/MemoryManagement.js +410 -470
- package/dist/cjs/performance/ModSupport.js +445 -496
- package/dist/cjs/performance/MultiThreadedPhysics.js +400 -443
- package/dist/cjs/performance/NetworkPrediction.js +424 -482
- package/dist/cjs/performance/ObjectPooling.js +569 -617
- package/dist/cjs/performance/Performance.js +174 -190
- package/dist/cjs/performance/PerformanceAdvanced.js +614 -637
- package/dist/cjs/performance/WebGPURenderer.js +656 -683
- package/dist/cjs/physics/PhysicsAdvanced.js +345 -379
- package/dist/cjs/physics/PhysicsEngine2D.js +391 -427
- package/dist/cjs/plugins/PluginSDK.js +432 -466
- package/dist/cjs/plugins/PluginTestKit.js +307 -330
- package/dist/cjs/procedural/Procedural.js +243 -254
- package/dist/cjs/procedural/WorldBuilding.js +297 -314
- package/dist/cjs/quest/QuestSystem.js +975 -932
- package/dist/cjs/release/MobileExport.js +157 -163
- package/dist/cjs/release/Release.js +225 -238
- package/dist/cjs/rendering/Camera2D.js +121 -124
- package/dist/cjs/rendering/Renderer2D.js +321 -335
- package/dist/cjs/rendering/WebGPURenderPipeline.js +632 -651
- package/dist/cjs/runtime3d/Runtime3D.js +359 -378
- package/dist/cjs/runtime3d/SceneEditor3D.js +252 -263
- package/dist/cjs/scene/SceneManager.js +177 -193
- package/dist/cjs/scripting/GraphToAST.js +574 -547
- package/dist/cjs/scripting/LanguageExporter.js +254 -279
- package/dist/cjs/scripting/NodeGraph.js +546 -570
- package/dist/cjs/scripting/ScriptAST.js +31 -39
- package/dist/cjs/scripting/VisualScripting2.js +1016 -1065
- package/dist/cjs/scripting/exporters/CSharpExporter.js +464 -496
- package/dist/cjs/scripting/exporters/GDScriptExporter.js +390 -442
- package/dist/cjs/scripting/exporters/LuaExporter.js +406 -447
- package/dist/cjs/scripting/exporters/PythonExporter.js +484 -549
- package/dist/cjs/scripting/exporters/RustExporter.js +459 -512
- package/dist/cjs/scripting/exporters/TypeScriptExporter.js +505 -556
- package/dist/cjs/social/Social.js +72 -80
- package/dist/cjs/systems/LightingSystem.js +844 -931
- package/dist/cjs/systems/ParticleSystem2.js +1447 -1451
- package/dist/cjs/systems/PhysicsDebugSystem.js +1070 -1141
- package/dist/cjs/systems/TerrainSystem.js +985 -1098
- package/dist/cjs/templates/ActionTemplates.js +296 -309
- package/dist/cjs/templates/FightingTemplate.js +417 -463
- package/dist/cjs/templates/MetroidvaniaTemplate.js +353 -405
- package/dist/cjs/templates/PartyTemplates.js +190 -202
- package/dist/cjs/templates/PuzzleTemplates.js +245 -261
- package/dist/cjs/templates/RPGTemplates.js +160 -178
- package/dist/cjs/templates/SportsTemplates.js +237 -250
- package/dist/cjs/templates/StrategyTemplates.js +143 -153
- package/dist/cjs/templates/SurvivalTemplate.js +336 -380
- package/dist/cjs/templates/WaveDefense.js +499 -526
- package/dist/cjs/tilemap/Tilemap.js +207 -214
- package/dist/cjs/tutorials/TutorialBranching.js +396 -417
- package/dist/cjs/tutorials/TutorialEngine.js +888 -931
- package/dist/cjs/tutorials/TutorialOverlay.js +602 -640
- package/dist/cjs/tutorials/content/Tutorials_T05_T08.js +787 -809
- package/dist/cjs/tutorials/content/Tutorials_T09_T11.js +736 -756
- package/dist/cjs/tutorials/content/Tutorials_T12_T15.js +754 -778
- package/dist/cjs/ui/GameUI.js +295 -312
- package/dist/cjs/unity-integration/UnityAssetStore.js +700 -741
- package/dist/cjs/unity-integration/UnityImport.js +1066 -1176
- package/dist/cjs/unity-integration/UnityLiveLink.js +934 -981
- package/dist/cjs/unity-integration/components/UnityAssetStoreBrowser.js +1233 -757
- package/dist/cjs/unity-integration/components/UnityProjectBrowser.js +1240 -768
- package/dist/cjs/unreal-integration/UnrealImport.js +391 -412
- package/dist/cjs/unreal-integration/UnrealLiveLink.js +1102 -1137
- package/dist/cjs/unreal-integration/UnrealMarketplace.js +436 -473
- package/dist/cjs/unreal-integration/components/UnrealProjectBrowser.js +1150 -767
- package/dist/cjs/xr/ARVR.js +167 -175
- package/dist/esm/accessibility/Accessibility.js +160 -164
- package/dist/esm/ai/AI.js +310 -293
- package/dist/esm/ai/BehaviorTree.js +1057 -1112
- package/dist/esm/ai/StateMachine.js +709 -755
- package/dist/esm/animation/Animation.js +237 -240
- package/dist/esm/audio/AudioAdvanced.js +239 -235
- package/dist/esm/audio/AudioBridge.js +448 -434
- package/dist/esm/audio/AudioManager.js +243 -258
- package/dist/esm/build-cloud/BuildOrchestration.js +1071 -1097
- package/dist/esm/build-cloud/GodotBuildCloud.js +647 -669
- package/dist/esm/build-cloud/UnityBuildCloud.js +571 -609
- package/dist/esm/build-cloud/UnrealBuildCloud.js +615 -634
- package/dist/esm/core/EventBus.js +52 -55
- package/dist/esm/core/GameClock.js +63 -65
- package/dist/esm/core/GameConfig.js +77 -78
- package/dist/esm/core/GameLoop.js +81 -88
- package/dist/esm/core/ServiceLocator.js +63 -64
- package/dist/esm/core/Validation.js +82 -81
- package/dist/esm/core/math.js +109 -111
- package/dist/esm/devtools/DevTools.js +546 -562
- package/dist/esm/devtools/DeveloperExperience.js +535 -558
- package/dist/esm/devtools/GameplayAnalytics.js +647 -645
- package/dist/esm/dialogue/DialogueSystem.js +998 -985
- package/dist/esm/docs/DocGenerator.js +342 -363
- package/dist/esm/ecs/World.js +358 -370
- package/dist/esm/editor/AchievementEditor.js +584 -635
- package/dist/esm/editor/AdvancedEditor.js +191 -190
- package/dist/esm/editor/AnimationRetargeting.js +700 -740
- package/dist/esm/editor/AssetBrowser.js +1078 -1159
- package/dist/esm/editor/AssetManager.js +188 -191
- package/dist/esm/editor/ConsolePro.js +977 -1060
- package/dist/esm/editor/CraftingEditor.js +684 -729
- package/dist/esm/editor/DebugTools.js +194 -184
- package/dist/esm/editor/DialogueSystem.js +849 -900
- package/dist/esm/editor/LeaderboardSystem.js +433 -482
- package/dist/esm/editor/NiceGameEditor.js +1908 -1200
- package/dist/esm/editor/PrefabSystem.js +777 -837
- package/dist/esm/editor/ProfilerPanel.js +654 -699
- package/dist/esm/editor/QuestEditor.js +795 -838
- package/dist/esm/editor/ReplaySystem.js +591 -633
- package/dist/esm/editor/SceneEditor.js +189 -199
- package/dist/esm/editor/ScreenshotMode.js +628 -687
- package/dist/esm/editor/ShaderGraph.js +1565 -1581
- package/dist/esm/editor/TimelineEditor.js +733 -777
- package/dist/esm/editor/UndoRedoPro.js +835 -903
- package/dist/esm/editor/VRARMode.js +586 -644
- package/dist/esm/engine/NiceGameEngine.js +142 -163
- package/dist/esm/engine/SaveSystem.js +447 -494
- package/dist/esm/enterprise/Enterprise.js +265 -260
- package/dist/esm/export/BevyExporter.js +929 -966
- package/dist/esm/export/CocosExporter.js +646 -672
- package/dist/esm/export/Construct3Exporter.js +785 -793
- package/dist/esm/export/DefoldExporter.js +1030 -1068
- package/dist/esm/export/GDevelopExporter.js +676 -707
- package/dist/esm/export/GameMakerExporter.js +793 -804
- package/dist/esm/export/GodotExporter.js +1004 -1044
- package/dist/esm/export/MinecraftBedrockExporter.js +575 -577
- package/dist/esm/export/MonoGameExporter.js +1267 -1292
- package/dist/esm/export/Pico8Exporter.js +768 -811
- package/dist/esm/export/PlatformExporter.js +193 -205
- package/dist/esm/export/RPGMakerExporter.js +862 -878
- package/dist/esm/export/RobloxExporter.js +885 -918
- package/dist/esm/export/Solar2DExporter.js +1220 -1255
- package/dist/esm/export/ThreeJSExporter.js +1007 -1072
- package/dist/esm/export/Tic80Exporter.js +1212 -1266
- package/dist/esm/export/UnityExporter.js +1117 -1130
- package/dist/esm/export/UnrealExporter.js +891 -918
- package/dist/esm/export/WebExporter.js +933 -969
- package/dist/esm/export/index.js +86 -71
- package/dist/esm/godot-integration/GodotAssetLibrary.js +663 -691
- package/dist/esm/godot-integration/GodotImport.js +935 -1026
- package/dist/esm/godot-integration/GodotLiveLink.js +918 -944
- package/dist/esm/godot-integration/components/GodotProjectBrowser.js +912 -610
- package/dist/esm/i18n/I18n.js +871 -899
- package/dist/esm/i18n/useTranslation.js +88 -88
- package/dist/esm/import/AsepriteImporter.js +637 -715
- package/dist/esm/import/DragonBonesImporter.js +417 -460
- package/dist/esm/import/GameMakerImporter.js +491 -520
- package/dist/esm/import/GodotSceneImporter.js +767 -821
- package/dist/esm/import/LDtkImporter.js +415 -453
- package/dist/esm/import/Live2DImporter.js +477 -517
- package/dist/esm/import/NdgFormat.js +410 -456
- package/dist/esm/import/OgmoImporter.js +446 -492
- package/dist/esm/import/RPGMakerImporter.js +431 -476
- package/dist/esm/import/SceneImporter.js +385 -422
- package/dist/esm/import/SpineImporter.js +491 -545
- package/dist/esm/import/SpriterImporter.js +570 -612
- package/dist/esm/import/TiledMapImporter.js +790 -845
- package/dist/esm/import/UnitySceneImporter.js +666 -702
- package/dist/esm/import/index.js +247 -258
- package/dist/esm/index.js +1332 -188
- package/dist/esm/input/GamepadNavigation.js +187 -204
- package/dist/esm/input/InputManager.js +401 -420
- package/dist/esm/input/useGamepads.js +72 -80
- package/dist/esm/integration/IconSprite.js +143 -255
- package/dist/esm/inventory/InventorySystem.js +925 -994
- package/dist/esm/kids/KidMode.js +1003 -1021
- package/dist/esm/kids/KidTools.js +573 -593
- package/dist/esm/monetization/Monetization.js +180 -176
- package/dist/esm/multiplayer/LocalMultiplayer.js +290 -286
- package/dist/esm/multiplayer/MiniGameTypes.js +58 -58
- package/dist/esm/native-engine/AnimationSystem.js +735 -805
- package/dist/esm/native-engine/AssetPipeline.js +456 -514
- package/dist/esm/native-engine/AudioEngine.js +765 -803
- package/dist/esm/native-engine/InputSystem.js +1079 -1144
- package/dist/esm/native-engine/NetworkingSystem.js +740 -792
- package/dist/esm/native-engine/PhysicsEngine.js +585 -606
- package/dist/esm/native-engine/RenderingEngine.js +304 -349
- package/dist/esm/native-engine/SceneGraph.js +773 -807
- package/dist/esm/network/MultiplayerTransport.js +99 -131
- package/dist/esm/network/Networking.js +556 -563
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AbortController.js +22 -28
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js +41 -47
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +36 -42
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +11 -14
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Errors.js +111 -134
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +132 -157
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +40 -52
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +6 -7
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +42 -47
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +496 -571
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +828 -952
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +126 -145
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +14 -23
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ILogger.js +12 -25
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ITransport.js +15 -24
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +109 -120
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Loggers.js +11 -13
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +151 -184
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js +159 -195
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +91 -104
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Subject.js +31 -34
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +17 -20
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Utils.js +230 -248
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +136 -156
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +77 -84
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/index.js +31 -12
- package/dist/esm/node_modules/@microsoft/signalr/dist/esm/pkg-version.js +4 -3
- package/dist/esm/pathfinding/Pathfinding.js +249 -262
- package/dist/esm/performance/AssetStreaming.js +567 -634
- package/dist/esm/performance/BenchmarkSuite.js +285 -310
- package/dist/esm/performance/DeltaCompression.js +478 -525
- package/dist/esm/performance/DeterministicPhysics.js +479 -497
- package/dist/esm/performance/ECSOptimization.js +653 -694
- package/dist/esm/performance/GameSaveSystem.js +515 -555
- package/dist/esm/performance/HotReload.js +454 -499
- package/dist/esm/performance/InputRecording.js +520 -560
- package/dist/esm/performance/InterestManagement.js +460 -499
- package/dist/esm/performance/LocalizationRuntime.js +382 -422
- package/dist/esm/performance/MemoryManagement.js +415 -469
- package/dist/esm/performance/ModSupport.js +455 -495
- package/dist/esm/performance/MultiThreadedPhysics.js +408 -442
- package/dist/esm/performance/NetworkPrediction.js +436 -481
- package/dist/esm/performance/ObjectPooling.js +582 -616
- package/dist/esm/performance/Performance.js +182 -189
- package/dist/esm/performance/PerformanceAdvanced.js +621 -636
- package/dist/esm/performance/WebGPURenderer.js +660 -682
- package/dist/esm/physics/PhysicsAdvanced.js +359 -378
- package/dist/esm/physics/PhysicsEngine2D.js +393 -426
- package/dist/esm/plugins/PluginSDK.js +435 -465
- package/dist/esm/plugins/PluginTestKit.js +315 -329
- package/dist/esm/procedural/Procedural.js +248 -253
- package/dist/esm/procedural/WorldBuilding.js +316 -313
- package/dist/esm/quest/QuestSystem.js +982 -931
- package/dist/esm/release/MobileExport.js +163 -162
- package/dist/esm/release/Release.js +234 -237
- package/dist/esm/rendering/Camera2D.js +122 -123
- package/dist/esm/rendering/Renderer2D.js +323 -334
- package/dist/esm/rendering/WebGPURenderPipeline.js +647 -650
- package/dist/esm/runtime3d/Runtime3D.js +368 -377
- package/dist/esm/runtime3d/SceneEditor3D.js +268 -262
- package/dist/esm/scene/SceneManager.js +178 -192
- package/dist/esm/scripting/GraphToAST.js +576 -546
- package/dist/esm/scripting/LanguageExporter.js +263 -278
- package/dist/esm/scripting/NodeGraph.js +550 -569
- package/dist/esm/scripting/ScriptAST.js +45 -38
- package/dist/esm/scripting/VisualScripting2.js +1025 -1064
- package/dist/esm/scripting/exporters/CSharpExporter.js +465 -495
- package/dist/esm/scripting/exporters/GDScriptExporter.js +391 -441
- package/dist/esm/scripting/exporters/LuaExporter.js +407 -446
- package/dist/esm/scripting/exporters/PythonExporter.js +485 -548
- package/dist/esm/scripting/exporters/RustExporter.js +460 -511
- package/dist/esm/scripting/exporters/TypeScriptExporter.js +506 -555
- package/dist/esm/social/Social.js +77 -79
- package/dist/esm/systems/LightingSystem.js +855 -930
- package/dist/esm/systems/ParticleSystem2.js +1453 -1450
- package/dist/esm/systems/PhysicsDebugSystem.js +1078 -1140
- package/dist/esm/systems/TerrainSystem.js +996 -1097
- package/dist/esm/templates/ActionTemplates.js +307 -308
- package/dist/esm/templates/FightingTemplate.js +439 -462
- package/dist/esm/templates/MetroidvaniaTemplate.js +391 -404
- package/dist/esm/templates/PartyTemplates.js +206 -201
- package/dist/esm/templates/PuzzleTemplates.js +260 -260
- package/dist/esm/templates/RPGTemplates.js +172 -177
- package/dist/esm/templates/SportsTemplates.js +251 -249
- package/dist/esm/templates/StrategyTemplates.js +158 -152
- package/dist/esm/templates/SurvivalTemplate.js +367 -379
- package/dist/esm/templates/WaveDefense.js +501 -525
- package/dist/esm/tilemap/Tilemap.js +209 -213
- package/dist/esm/tutorials/TutorialBranching.js +399 -416
- package/dist/esm/tutorials/TutorialEngine.js +893 -930
- package/dist/esm/tutorials/TutorialOverlay.js +603 -639
- package/dist/esm/tutorials/content/Tutorials_T05_T08.js +792 -808
- package/dist/esm/tutorials/content/Tutorials_T09_T11.js +740 -755
- package/dist/esm/tutorials/content/Tutorials_T12_T15.js +759 -777
- package/dist/esm/ui/GameUI.js +296 -311
- package/dist/esm/unity-integration/UnityAssetStore.js +704 -740
- package/dist/esm/unity-integration/UnityImport.js +1071 -1175
- package/dist/esm/unity-integration/UnityLiveLink.js +938 -980
- package/dist/esm/unity-integration/components/UnityAssetStoreBrowser.js +1234 -756
- package/dist/esm/unity-integration/components/UnityProjectBrowser.js +1241 -767
- package/dist/esm/unreal-integration/UnrealImport.js +395 -411
- package/dist/esm/unreal-integration/UnrealLiveLink.js +1105 -1136
- package/dist/esm/unreal-integration/UnrealMarketplace.js +442 -472
- package/dist/esm/unreal-integration/components/UnrealProjectBrowser.js +1151 -766
- package/dist/esm/xr/ARVR.js +181 -174
- package/package.json +7 -12
|
@@ -1,468 +1,435 @@
|
|
|
1
|
-
import { EventBus } from
|
|
2
|
-
import { v2 } from
|
|
3
|
-
import { System } from
|
|
4
|
-
|
|
5
|
-
/* ────────────────────────────────────────────────────────────────
|
|
6
|
-
PhysicsEngine2D — Built-in 2D physics
|
|
7
|
-
|
|
8
|
-
AABB, Circle, Polygon collision detection & resolution.
|
|
9
|
-
Broad-phase spatial hashing + narrow-phase SAT / overlap.
|
|
10
|
-
──────────────────────────────────────────────────────────────── */
|
|
11
|
-
/* ── Spatial Hash ─────────────────────────────────────────────── */
|
|
1
|
+
import { EventBus } from "../core/EventBus.js";
|
|
2
|
+
import { v2 } from "../core/math.js";
|
|
3
|
+
import { System } from "../ecs/World.js";
|
|
12
4
|
class SpatialHash {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
set.add(id);
|
|
37
|
-
}
|
|
5
|
+
constructor(cellSize = 128) {
|
|
6
|
+
this.cells = /* @__PURE__ */ new Map();
|
|
7
|
+
this.cellSize = cellSize;
|
|
8
|
+
}
|
|
9
|
+
clear() {
|
|
10
|
+
this.cells.clear();
|
|
11
|
+
}
|
|
12
|
+
key(cx, cy) {
|
|
13
|
+
return `${cx},${cy}`;
|
|
14
|
+
}
|
|
15
|
+
insert(id, x, y, hw, hh) {
|
|
16
|
+
const minCX = Math.floor((x - hw) / this.cellSize);
|
|
17
|
+
const maxCX = Math.floor((x + hw) / this.cellSize);
|
|
18
|
+
const minCY = Math.floor((y - hh) / this.cellSize);
|
|
19
|
+
const maxCY = Math.floor((y + hh) / this.cellSize);
|
|
20
|
+
for (let cx = minCX; cx <= maxCX; cx++) {
|
|
21
|
+
for (let cy = minCY; cy <= maxCY; cy++) {
|
|
22
|
+
const k = this.key(cx, cy);
|
|
23
|
+
let set = this.cells.get(k);
|
|
24
|
+
if (!set) {
|
|
25
|
+
set = /* @__PURE__ */ new Set();
|
|
26
|
+
this.cells.set(k, set);
|
|
38
27
|
}
|
|
28
|
+
set.add(id);
|
|
29
|
+
}
|
|
39
30
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
31
|
+
}
|
|
32
|
+
query(x, y, hw, hh) {
|
|
33
|
+
const result = /* @__PURE__ */ new Set();
|
|
34
|
+
const minCX = Math.floor((x - hw) / this.cellSize);
|
|
35
|
+
const maxCX = Math.floor((x + hw) / this.cellSize);
|
|
36
|
+
const minCY = Math.floor((y - hh) / this.cellSize);
|
|
37
|
+
const maxCY = Math.floor((y + hh) / this.cellSize);
|
|
38
|
+
for (let cx = minCX; cx <= maxCX; cx++) {
|
|
39
|
+
for (let cy = minCY; cy <= maxCY; cy++) {
|
|
40
|
+
const set = this.cells.get(this.key(cx, cy));
|
|
41
|
+
if (set) {
|
|
42
|
+
set.forEach((id) => result.add(id));
|
|
53
43
|
}
|
|
54
|
-
|
|
44
|
+
}
|
|
55
45
|
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
56
48
|
}
|
|
57
|
-
/* ── PhysicsEngine2D ──────────────────────────────────────────── */
|
|
58
49
|
class PhysicsEngine2D {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
rb.velocity.y *= 1 / (1 + rb.drag * dt);
|
|
92
|
-
// Angular
|
|
93
|
-
if (!rb.fixedRotation) {
|
|
94
|
-
transform.rotation += rb.angularVelocity * dt;
|
|
95
|
-
rb.angularVelocity *= 1 / (1 + rb.angularDrag * dt);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
// Move
|
|
99
|
-
transform.position.x += rb.velocity.x * dt;
|
|
100
|
-
transform.position.y += rb.velocity.y * dt;
|
|
50
|
+
constructor() {
|
|
51
|
+
this.events = new EventBus();
|
|
52
|
+
this.gravity = { x: 0, y: 980 };
|
|
53
|
+
this.hash = new SpatialHash(128);
|
|
54
|
+
this.activeCollisions = /* @__PURE__ */ new Set();
|
|
55
|
+
this.activeTriggers = /* @__PURE__ */ new Set();
|
|
56
|
+
}
|
|
57
|
+
/* ── Fixed update (call at fixedTimestep) ────────────────────── */
|
|
58
|
+
step(world, dt) {
|
|
59
|
+
this.integrateForces(world, dt);
|
|
60
|
+
const collisions = this.detectCollisions(world);
|
|
61
|
+
this.resolveCollisions(world, collisions);
|
|
62
|
+
this.emitEvents(collisions);
|
|
63
|
+
}
|
|
64
|
+
/* ── Integration ────────────────────────────────────────────── */
|
|
65
|
+
integrateForces(world, dt) {
|
|
66
|
+
for (const id of world.query("Transform", "RigidBody2D")) {
|
|
67
|
+
const transform = world.getComponent(id, "Transform");
|
|
68
|
+
const rb = world.getComponent(id, "RigidBody2D");
|
|
69
|
+
if (rb.bodyType === "static" || !rb.enabled) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
transform.prevPosition = { ...transform.position };
|
|
73
|
+
transform.prevRotation = transform.rotation;
|
|
74
|
+
if (rb.bodyType === "dynamic") {
|
|
75
|
+
rb.velocity.x += (this.gravity.x * rb.gravityScale + rb.acceleration.x) * dt;
|
|
76
|
+
rb.velocity.y += (this.gravity.y * rb.gravityScale + rb.acceleration.y) * dt;
|
|
77
|
+
rb.velocity.x *= 1 / (1 + rb.drag * dt);
|
|
78
|
+
rb.velocity.y *= 1 / (1 + rb.drag * dt);
|
|
79
|
+
if (!rb.fixedRotation) {
|
|
80
|
+
transform.rotation += rb.angularVelocity * dt;
|
|
81
|
+
rb.angularVelocity *= 1 / (1 + rb.angularDrag * dt);
|
|
101
82
|
}
|
|
83
|
+
}
|
|
84
|
+
transform.position.x += rb.velocity.x * dt;
|
|
85
|
+
transform.position.y += rb.velocity.y * dt;
|
|
102
86
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
// Narrow phase
|
|
117
|
-
const checked = new Set();
|
|
118
|
-
for (const idA of bodies) {
|
|
119
|
-
const tA = world.getComponent(idA, 'Transform');
|
|
120
|
-
const cA = world.getComponent(idA, 'Collider2D');
|
|
121
|
-
const hwA = cA.shape === 'circle' ? cA.radius : cA.width / 2;
|
|
122
|
-
const hhA = cA.shape === 'circle' ? cA.radius : cA.height / 2;
|
|
123
|
-
const nearby = this.hash.query(tA.position.x + cA.offset.x, tA.position.y + cA.offset.y, hwA, hhA);
|
|
124
|
-
for (const idB of nearby) {
|
|
125
|
-
if (idA >= idB) {
|
|
126
|
-
continue;
|
|
127
|
-
} // avoid duplicates and self
|
|
128
|
-
const pairKey = `${idA}:${idB}`;
|
|
129
|
-
if (checked.has(pairKey)) {
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
checked.add(pairKey);
|
|
133
|
-
// Layer/mask check
|
|
134
|
-
if (!(cA.layer & world.getComponent(idB, 'Collider2D').mask)) {
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
if (!(world.getComponent(idB, 'Collider2D').layer & cA.mask)) {
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
const tB = world.getComponent(idB, 'Transform');
|
|
141
|
-
const cB = world.getComponent(idB, 'Collider2D');
|
|
142
|
-
const collision = this.narrowPhase(tA, cA, tB, cB);
|
|
143
|
-
if (collision) {
|
|
144
|
-
collisions.push({
|
|
145
|
-
entityA: idA,
|
|
146
|
-
entityB: idB,
|
|
147
|
-
normal: collision.normal,
|
|
148
|
-
depth: collision.depth,
|
|
149
|
-
point: collision.point,
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return collisions;
|
|
87
|
+
}
|
|
88
|
+
/* ── Collision Detection ────────────────────────────────────── */
|
|
89
|
+
detectCollisions(world) {
|
|
90
|
+
const collisions = [];
|
|
91
|
+
const bodies = world.query("Transform", "Collider2D");
|
|
92
|
+
this.hash.clear();
|
|
93
|
+
for (const id of bodies) {
|
|
94
|
+
const t = world.getComponent(id, "Transform");
|
|
95
|
+
const c = world.getComponent(id, "Collider2D");
|
|
96
|
+
const hw = c.shape === "circle" ? c.radius : c.width / 2;
|
|
97
|
+
const hh = c.shape === "circle" ? c.radius : c.height / 2;
|
|
98
|
+
this.hash.insert(id, t.position.x + c.offset.x, t.position.y + c.offset.y, hw, hh);
|
|
155
99
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
100
|
+
const checked = /* @__PURE__ */ new Set();
|
|
101
|
+
for (const idA of bodies) {
|
|
102
|
+
const tA = world.getComponent(idA, "Transform");
|
|
103
|
+
const cA = world.getComponent(idA, "Collider2D");
|
|
104
|
+
const hwA = cA.shape === "circle" ? cA.radius : cA.width / 2;
|
|
105
|
+
const hhA = cA.shape === "circle" ? cA.radius : cA.height / 2;
|
|
106
|
+
const nearby = this.hash.query(
|
|
107
|
+
tA.position.x + cA.offset.x,
|
|
108
|
+
tA.position.y + cA.offset.y,
|
|
109
|
+
hwA,
|
|
110
|
+
hhA
|
|
111
|
+
);
|
|
112
|
+
for (const idB of nearby) {
|
|
113
|
+
if (idA >= idB) {
|
|
114
|
+
continue;
|
|
162
115
|
}
|
|
163
|
-
|
|
164
|
-
if (
|
|
165
|
-
|
|
116
|
+
const pairKey = `${idA}:${idB}`;
|
|
117
|
+
if (checked.has(pairKey)) {
|
|
118
|
+
continue;
|
|
166
119
|
}
|
|
167
|
-
|
|
168
|
-
if (cA.
|
|
169
|
-
|
|
120
|
+
checked.add(pairKey);
|
|
121
|
+
if (!(cA.layer & world.getComponent(idB, "Collider2D").mask)) {
|
|
122
|
+
continue;
|
|
170
123
|
}
|
|
171
|
-
if (
|
|
172
|
-
|
|
173
|
-
if (result) {
|
|
174
|
-
result.normal = v2.negate(result.normal);
|
|
175
|
-
}
|
|
176
|
-
return result;
|
|
124
|
+
if (!(world.getComponent(idB, "Collider2D").layer & cA.mask)) {
|
|
125
|
+
continue;
|
|
177
126
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (cA.isTrigger || cB.isTrigger) {
|
|
190
|
-
continue;
|
|
191
|
-
}
|
|
192
|
-
const tA = world.getComponent(col.entityA, 'Transform');
|
|
193
|
-
const tB = world.getComponent(col.entityB, 'Transform');
|
|
194
|
-
const rbA = world.getComponent(col.entityA, 'RigidBody2D');
|
|
195
|
-
const rbB = world.getComponent(col.entityB, 'RigidBody2D');
|
|
196
|
-
if (!tA || !tB) {
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
const aStatic = !rbA || rbA.bodyType === 'static';
|
|
200
|
-
const bStatic = !rbB || rbB.bodyType === 'static';
|
|
201
|
-
// Positional correction (push apart)
|
|
202
|
-
if (aStatic && !bStatic) {
|
|
203
|
-
tB.position.x += col.normal.x * col.depth;
|
|
204
|
-
tB.position.y += col.normal.y * col.depth;
|
|
205
|
-
}
|
|
206
|
-
else if (!aStatic && bStatic) {
|
|
207
|
-
tA.position.x -= col.normal.x * col.depth;
|
|
208
|
-
tA.position.y -= col.normal.y * col.depth;
|
|
209
|
-
}
|
|
210
|
-
else if (!aStatic && !bStatic) {
|
|
211
|
-
tA.position.x -= col.normal.x * col.depth * 0.5;
|
|
212
|
-
tA.position.y -= col.normal.y * col.depth * 0.5;
|
|
213
|
-
tB.position.x += col.normal.x * col.depth * 0.5;
|
|
214
|
-
tB.position.y += col.normal.y * col.depth * 0.5;
|
|
215
|
-
}
|
|
216
|
-
// Velocity resolution
|
|
217
|
-
if (rbA && rbB && !aStatic && !bStatic) {
|
|
218
|
-
const restitution = Math.min(rbA.restitution, rbB.restitution);
|
|
219
|
-
const relVel = v2.sub(rbB.velocity, rbA.velocity);
|
|
220
|
-
const velAlongNormal = v2.dot(relVel, col.normal);
|
|
221
|
-
if (velAlongNormal > 0) {
|
|
222
|
-
continue;
|
|
223
|
-
} // separating
|
|
224
|
-
const invMassA = 1 / rbA.mass;
|
|
225
|
-
const invMassB = 1 / rbB.mass;
|
|
226
|
-
const j = (-(1 + restitution) * velAlongNormal) / (invMassA + invMassB);
|
|
227
|
-
rbA.velocity.x -= j * invMassA * col.normal.x;
|
|
228
|
-
rbA.velocity.y -= j * invMassA * col.normal.y;
|
|
229
|
-
rbB.velocity.x += j * invMassB * col.normal.x;
|
|
230
|
-
rbB.velocity.y += j * invMassB * col.normal.y;
|
|
231
|
-
}
|
|
232
|
-
else if (rbA && !aStatic && bStatic) {
|
|
233
|
-
const restitution = rbA.restitution;
|
|
234
|
-
const velAlongNormal = v2.dot(rbA.velocity, col.normal);
|
|
235
|
-
if (velAlongNormal > 0) {
|
|
236
|
-
continue;
|
|
237
|
-
}
|
|
238
|
-
rbA.velocity.x -= (1 + restitution) * velAlongNormal * col.normal.x;
|
|
239
|
-
rbA.velocity.y -= (1 + restitution) * velAlongNormal * col.normal.y;
|
|
240
|
-
}
|
|
241
|
-
else if (rbB && !bStatic && aStatic) {
|
|
242
|
-
const restitution = rbB.restitution;
|
|
243
|
-
const velAlongNormal = -v2.dot(rbB.velocity, col.normal);
|
|
244
|
-
if (velAlongNormal > 0) {
|
|
245
|
-
continue;
|
|
246
|
-
}
|
|
247
|
-
rbB.velocity.x += (1 + restitution) * velAlongNormal * col.normal.x;
|
|
248
|
-
rbB.velocity.y += (1 + restitution) * velAlongNormal * col.normal.y;
|
|
249
|
-
}
|
|
127
|
+
const tB = world.getComponent(idB, "Transform");
|
|
128
|
+
const cB = world.getComponent(idB, "Collider2D");
|
|
129
|
+
const collision = this.narrowPhase(tA, cA, tB, cB);
|
|
130
|
+
if (collision) {
|
|
131
|
+
collisions.push({
|
|
132
|
+
entityA: idA,
|
|
133
|
+
entityB: idB,
|
|
134
|
+
normal: collision.normal,
|
|
135
|
+
depth: collision.depth,
|
|
136
|
+
point: collision.point
|
|
137
|
+
});
|
|
250
138
|
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return collisions;
|
|
142
|
+
}
|
|
143
|
+
narrowPhase(tA, cA, tB, cB) {
|
|
144
|
+
const posA = { x: tA.position.x + cA.offset.x, y: tA.position.y + cA.offset.y };
|
|
145
|
+
const posB = { x: tB.position.x + cB.offset.x, y: tB.position.y + cB.offset.y };
|
|
146
|
+
if (cA.shape === "circle" && cB.shape === "circle") {
|
|
147
|
+
return circleVsCircle(posA, cA.radius, posB, cB.radius);
|
|
148
|
+
}
|
|
149
|
+
if (cA.shape === "aabb" && cB.shape === "aabb") {
|
|
150
|
+
return aabbVsAabb(posA, cA.width, cA.height, posB, cB.width, cB.height);
|
|
151
|
+
}
|
|
152
|
+
if (cA.shape === "circle" && cB.shape === "aabb") {
|
|
153
|
+
return circleVsAabb(posA, cA.radius, posB, cB.width, cB.height);
|
|
251
154
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
155
|
+
if (cA.shape === "aabb" && cB.shape === "circle") {
|
|
156
|
+
const result = circleVsAabb(posB, cB.radius, posA, cA.width, cA.height);
|
|
157
|
+
if (result) {
|
|
158
|
+
result.normal = v2.negate(result.normal);
|
|
159
|
+
}
|
|
160
|
+
return result;
|
|
161
|
+
}
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
/* ── Resolution ─────────────────────────────────────────────── */
|
|
165
|
+
resolveCollisions(world, collisions) {
|
|
166
|
+
for (const col of collisions) {
|
|
167
|
+
const cA = world.getComponent(col.entityA, "Collider2D");
|
|
168
|
+
const cB = world.getComponent(col.entityB, "Collider2D");
|
|
169
|
+
if (!cA || !cB) {
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (cA.isTrigger || cB.isTrigger) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
const tA = world.getComponent(col.entityA, "Transform");
|
|
176
|
+
const tB = world.getComponent(col.entityB, "Transform");
|
|
177
|
+
const rbA = world.getComponent(col.entityA, "RigidBody2D");
|
|
178
|
+
const rbB = world.getComponent(col.entityB, "RigidBody2D");
|
|
179
|
+
if (!tA || !tB) {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
const aStatic = !rbA || rbA.bodyType === "static";
|
|
183
|
+
const bStatic = !rbB || rbB.bodyType === "static";
|
|
184
|
+
if (aStatic && !bStatic) {
|
|
185
|
+
tB.position.x += col.normal.x * col.depth;
|
|
186
|
+
tB.position.y += col.normal.y * col.depth;
|
|
187
|
+
} else if (!aStatic && bStatic) {
|
|
188
|
+
tA.position.x -= col.normal.x * col.depth;
|
|
189
|
+
tA.position.y -= col.normal.y * col.depth;
|
|
190
|
+
} else if (!aStatic && !bStatic) {
|
|
191
|
+
tA.position.x -= col.normal.x * col.depth * 0.5;
|
|
192
|
+
tA.position.y -= col.normal.y * col.depth * 0.5;
|
|
193
|
+
tB.position.x += col.normal.x * col.depth * 0.5;
|
|
194
|
+
tB.position.y += col.normal.y * col.depth * 0.5;
|
|
195
|
+
}
|
|
196
|
+
if (rbA && rbB && !aStatic && !bStatic) {
|
|
197
|
+
const restitution = Math.min(rbA.restitution, rbB.restitution);
|
|
198
|
+
const relVel = v2.sub(rbB.velocity, rbA.velocity);
|
|
199
|
+
const velAlongNormal = v2.dot(relVel, col.normal);
|
|
200
|
+
if (velAlongNormal > 0) {
|
|
201
|
+
continue;
|
|
264
202
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
203
|
+
const invMassA = 1 / rbA.mass;
|
|
204
|
+
const invMassB = 1 / rbB.mass;
|
|
205
|
+
const j = -(1 + restitution) * velAlongNormal / (invMassA + invMassB);
|
|
206
|
+
rbA.velocity.x -= j * invMassA * col.normal.x;
|
|
207
|
+
rbA.velocity.y -= j * invMassA * col.normal.y;
|
|
208
|
+
rbB.velocity.x += j * invMassB * col.normal.x;
|
|
209
|
+
rbB.velocity.y += j * invMassB * col.normal.y;
|
|
210
|
+
} else if (rbA && !aStatic && bStatic) {
|
|
211
|
+
const restitution = rbA.restitution;
|
|
212
|
+
const velAlongNormal = v2.dot(rbA.velocity, col.normal);
|
|
213
|
+
if (velAlongNormal > 0) {
|
|
214
|
+
continue;
|
|
271
215
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
const t = world.getComponent(id, 'Transform');
|
|
280
|
-
const c = world.getComponent(id, 'Collider2D');
|
|
281
|
-
if (!(c.layer & layerMask)) {
|
|
282
|
-
continue;
|
|
283
|
-
}
|
|
284
|
-
const center = { x: t.position.x + c.offset.x, y: t.position.y + c.offset.y };
|
|
285
|
-
let hit = null;
|
|
286
|
-
if (c.shape === 'circle') {
|
|
287
|
-
hit = rayVsCircle(origin, dir, center, c.radius, maxDistance);
|
|
288
|
-
}
|
|
289
|
-
else if (c.shape === 'aabb') {
|
|
290
|
-
hit = rayVsAABB(origin, dir, center, c.width, c.height, maxDistance);
|
|
291
|
-
}
|
|
292
|
-
if (hit && (!closest || hit.distance < closest.distance)) {
|
|
293
|
-
closest = { entityId: id, ...hit };
|
|
294
|
-
}
|
|
216
|
+
rbA.velocity.x -= (1 + restitution) * velAlongNormal * col.normal.x;
|
|
217
|
+
rbA.velocity.y -= (1 + restitution) * velAlongNormal * col.normal.y;
|
|
218
|
+
} else if (rbB && !bStatic && aStatic) {
|
|
219
|
+
const restitution = rbB.restitution;
|
|
220
|
+
const velAlongNormal = -v2.dot(rbB.velocity, col.normal);
|
|
221
|
+
if (velAlongNormal > 0) {
|
|
222
|
+
continue;
|
|
295
223
|
}
|
|
296
|
-
|
|
224
|
+
rbB.velocity.x += (1 + restitution) * velAlongNormal * col.normal.x;
|
|
225
|
+
rbB.velocity.y += (1 + restitution) * velAlongNormal * col.normal.y;
|
|
226
|
+
}
|
|
297
227
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
228
|
+
}
|
|
229
|
+
/* ── Events ─────────────────────────────────────────────────── */
|
|
230
|
+
emitEvents(collisions) {
|
|
231
|
+
const currentPairs = /* @__PURE__ */ new Set();
|
|
232
|
+
for (const col of collisions) {
|
|
233
|
+
const cA = col.entityA < col.entityB ? `${col.entityA}:${col.entityB}` : `${col.entityB}:${col.entityA}`;
|
|
234
|
+
currentPairs.add(cA);
|
|
235
|
+
if (!this.activeCollisions.has(cA)) {
|
|
236
|
+
this.events.emit("collision:enter", col);
|
|
237
|
+
}
|
|
238
|
+
this.events.emit("collision:stay", col);
|
|
301
239
|
}
|
|
302
|
-
|
|
303
|
-
|
|
240
|
+
for (const pair of this.activeCollisions) {
|
|
241
|
+
if (!currentPairs.has(pair)) {
|
|
242
|
+
const [a, b] = pair.split(":").map(Number);
|
|
243
|
+
this.events.emit("collision:exit", { entityA: a, entityB: b });
|
|
244
|
+
}
|
|
304
245
|
}
|
|
305
|
-
|
|
306
|
-
|
|
246
|
+
this.activeCollisions = currentPairs;
|
|
247
|
+
}
|
|
248
|
+
/* ── Raycast ────────────────────────────────────────────────── */
|
|
249
|
+
raycast(world, origin, direction, maxDistance = Infinity, layerMask = 65535) {
|
|
250
|
+
const dir = v2.normalize(direction);
|
|
251
|
+
let closest = null;
|
|
252
|
+
for (const id of world.query("Transform", "Collider2D")) {
|
|
253
|
+
const t = world.getComponent(id, "Transform");
|
|
254
|
+
const c = world.getComponent(id, "Collider2D");
|
|
255
|
+
if (!(c.layer & layerMask)) {
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
const center = { x: t.position.x + c.offset.x, y: t.position.y + c.offset.y };
|
|
259
|
+
let hit = null;
|
|
260
|
+
if (c.shape === "circle") {
|
|
261
|
+
hit = rayVsCircle(origin, dir, center, c.radius, maxDistance);
|
|
262
|
+
} else if (c.shape === "aabb") {
|
|
263
|
+
hit = rayVsAABB(origin, dir, center, c.width, c.height, maxDistance);
|
|
264
|
+
}
|
|
265
|
+
if (hit && (!closest || hit.distance < closest.distance)) {
|
|
266
|
+
closest = { entityId: id, ...hit };
|
|
267
|
+
}
|
|
307
268
|
}
|
|
269
|
+
return closest;
|
|
270
|
+
}
|
|
271
|
+
/* ── Static collision test helpers (for unit tests & utilities) ── */
|
|
272
|
+
static testAABBvsAABB(a, b) {
|
|
273
|
+
return aabbVsAabb(a, a.width, a.height, b, b.width, b.height) !== null;
|
|
274
|
+
}
|
|
275
|
+
static testCircleVsCircle(a, b) {
|
|
276
|
+
return circleVsCircle(a, a.radius, b, b.radius) !== null;
|
|
277
|
+
}
|
|
278
|
+
static testAABBvsCircle(aabb, circle) {
|
|
279
|
+
return circleVsAabb(circle, circle.radius, aabb, aabb.width, aabb.height) !== null;
|
|
280
|
+
}
|
|
308
281
|
}
|
|
309
|
-
/* ── PhysicsSystem (ECS wrapper) ──────────────────────────────── */
|
|
310
282
|
class PhysicsSystem extends System {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
283
|
+
constructor(engine, priority = -100) {
|
|
284
|
+
super(priority);
|
|
285
|
+
this.engine = engine;
|
|
286
|
+
}
|
|
287
|
+
fixedUpdate(world, dt) {
|
|
288
|
+
this.engine.step(world, dt);
|
|
289
|
+
}
|
|
318
290
|
}
|
|
319
|
-
/* ── Collision helpers ────────────────────────────────────────── */
|
|
320
291
|
function circleVsCircle(posA, rA, posB, rB) {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
292
|
+
const dx = posB.x - posA.x;
|
|
293
|
+
const dy = posB.y - posA.y;
|
|
294
|
+
const distSq = dx * dx + dy * dy;
|
|
295
|
+
const radSum = rA + rB;
|
|
296
|
+
if (distSq >= radSum * radSum) {
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
const dist = Math.sqrt(distSq);
|
|
300
|
+
const normal = dist > 0 ? { x: dx / dist, y: dy / dist } : { x: 1, y: 0 };
|
|
301
|
+
return {
|
|
302
|
+
normal,
|
|
303
|
+
depth: radSum - dist,
|
|
304
|
+
point: { x: posA.x + normal.x * rA, y: posA.y + normal.y * rA }
|
|
305
|
+
};
|
|
335
306
|
}
|
|
336
307
|
function aabbVsAabb(posA, wA, hA, posB, wB, hB) {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
const ny = dy > 0 ? 1 : -1;
|
|
354
|
-
return {
|
|
355
|
-
normal: { x: 0, y: ny },
|
|
356
|
-
depth: overlapY,
|
|
357
|
-
point: { x: posA.x, y: posA.y + (ny * hA) / 2 },
|
|
358
|
-
};
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
function circleVsAabb(circlePos, radius, aabbPos, aabbW, aabbH) {
|
|
362
|
-
const halfW = aabbW / 2;
|
|
363
|
-
const halfH = aabbH / 2;
|
|
364
|
-
const closestX = Math.max(aabbPos.x - halfW, Math.min(aabbPos.x + halfW, circlePos.x));
|
|
365
|
-
const closestY = Math.max(aabbPos.y - halfH, Math.min(aabbPos.y + halfH, circlePos.y));
|
|
366
|
-
const dx = circlePos.x - closestX;
|
|
367
|
-
const dy = circlePos.y - closestY;
|
|
368
|
-
const distSq = dx * dx + dy * dy;
|
|
369
|
-
if (distSq >= radius * radius) {
|
|
370
|
-
return null;
|
|
371
|
-
}
|
|
372
|
-
const dist = Math.sqrt(distSq);
|
|
373
|
-
const normal = dist > 0 ? { x: dx / dist, y: dy / dist } : { x: 0, y: -1 };
|
|
308
|
+
const dx = posB.x - posA.x;
|
|
309
|
+
const dy = posB.y - posA.y;
|
|
310
|
+
const overlapX = wA / 2 + wB / 2 - Math.abs(dx);
|
|
311
|
+
const overlapY = hA / 2 + hB / 2 - Math.abs(dy);
|
|
312
|
+
if (overlapX <= 0 || overlapY <= 0) {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
if (overlapX < overlapY) {
|
|
316
|
+
const nx = dx > 0 ? 1 : -1;
|
|
317
|
+
return {
|
|
318
|
+
normal: { x: nx, y: 0 },
|
|
319
|
+
depth: overlapX,
|
|
320
|
+
point: { x: posA.x + nx * wA / 2, y: posA.y }
|
|
321
|
+
};
|
|
322
|
+
} else {
|
|
323
|
+
const ny = dy > 0 ? 1 : -1;
|
|
374
324
|
return {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
325
|
+
normal: { x: 0, y: ny },
|
|
326
|
+
depth: overlapY,
|
|
327
|
+
point: { x: posA.x, y: posA.y + ny * hA / 2 }
|
|
378
328
|
};
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
function circleVsAabb(circlePos, radius, aabbPos, aabbW, aabbH) {
|
|
332
|
+
const halfW = aabbW / 2;
|
|
333
|
+
const halfH = aabbH / 2;
|
|
334
|
+
const closestX = Math.max(aabbPos.x - halfW, Math.min(aabbPos.x + halfW, circlePos.x));
|
|
335
|
+
const closestY = Math.max(aabbPos.y - halfH, Math.min(aabbPos.y + halfH, circlePos.y));
|
|
336
|
+
const dx = circlePos.x - closestX;
|
|
337
|
+
const dy = circlePos.y - closestY;
|
|
338
|
+
const distSq = dx * dx + dy * dy;
|
|
339
|
+
if (distSq >= radius * radius) {
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
const dist = Math.sqrt(distSq);
|
|
343
|
+
const normal = dist > 0 ? { x: dx / dist, y: dy / dist } : { x: 0, y: -1 };
|
|
344
|
+
return {
|
|
345
|
+
normal,
|
|
346
|
+
depth: radius - dist,
|
|
347
|
+
point: { x: closestX, y: closestY }
|
|
348
|
+
};
|
|
379
349
|
}
|
|
380
|
-
/* ── Raycast helpers ──────────────────────────────────────────── */
|
|
381
350
|
function rayVsCircle(origin, dir, center, radius, maxDist) {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
351
|
+
const oc = v2.sub(origin, center);
|
|
352
|
+
const b = v2.dot(oc, dir);
|
|
353
|
+
const c = v2.dot(oc, oc) - radius * radius;
|
|
354
|
+
const discriminant = b * b - c;
|
|
355
|
+
if (discriminant < 0) {
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
const sqrtD = Math.sqrt(discriminant);
|
|
359
|
+
let t = -b - sqrtD;
|
|
360
|
+
if (t < 0) {
|
|
361
|
+
t = -b + sqrtD;
|
|
362
|
+
}
|
|
363
|
+
if (t < 0 || t > maxDist) {
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
const point = { x: origin.x + dir.x * t, y: origin.y + dir.y * t };
|
|
367
|
+
const normal = v2.normalize(v2.sub(point, center));
|
|
368
|
+
return { distance: t, point, normal };
|
|
369
|
+
}
|
|
370
|
+
function rayVsAABB(origin, dir, center, w, h, maxDist) {
|
|
371
|
+
const hw = w / 2;
|
|
372
|
+
const hh = h / 2;
|
|
373
|
+
let tMin = 0;
|
|
374
|
+
let tMax = maxDist;
|
|
375
|
+
let normalMin = { x: 0, y: 0 };
|
|
376
|
+
if (Math.abs(dir.x) < 1e-8) {
|
|
377
|
+
if (origin.x < center.x - hw || origin.x > center.x + hw) {
|
|
378
|
+
return null;
|
|
388
379
|
}
|
|
389
|
-
|
|
390
|
-
let
|
|
391
|
-
|
|
392
|
-
|
|
380
|
+
} else {
|
|
381
|
+
let t1 = (center.x - hw - origin.x) / dir.x;
|
|
382
|
+
let t2 = (center.x + hw - origin.x) / dir.x;
|
|
383
|
+
let n = { x: -1, y: 0 };
|
|
384
|
+
if (t1 > t2) {
|
|
385
|
+
const tmp = t1;
|
|
386
|
+
t1 = t2;
|
|
387
|
+
t2 = tmp;
|
|
388
|
+
n = { x: 1, y: 0 };
|
|
393
389
|
}
|
|
394
|
-
if (
|
|
395
|
-
|
|
390
|
+
if (t1 > tMin) {
|
|
391
|
+
tMin = t1;
|
|
392
|
+
normalMin = n;
|
|
396
393
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
return { distance: t, point, normal };
|
|
400
|
-
}
|
|
401
|
-
function rayVsAABB(origin, dir, center, w, h, maxDist) {
|
|
402
|
-
const hw = w / 2;
|
|
403
|
-
const hh = h / 2;
|
|
404
|
-
let tMin = 0;
|
|
405
|
-
let tMax = maxDist;
|
|
406
|
-
let normalMin = { x: 0, y: 0 };
|
|
407
|
-
// X axis
|
|
408
|
-
if (Math.abs(dir.x) < 1e-8) {
|
|
409
|
-
if (origin.x < center.x - hw || origin.x > center.x + hw) {
|
|
410
|
-
return null;
|
|
411
|
-
}
|
|
394
|
+
if (t2 < tMax) {
|
|
395
|
+
tMax = t2;
|
|
412
396
|
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
let t2 = (center.x + hw - origin.x) / dir.x;
|
|
416
|
-
let n = { x: -1, y: 0 };
|
|
417
|
-
if (t1 > t2) {
|
|
418
|
-
const tmp = t1;
|
|
419
|
-
t1 = t2;
|
|
420
|
-
t2 = tmp;
|
|
421
|
-
n = { x: 1, y: 0 };
|
|
422
|
-
}
|
|
423
|
-
if (t1 > tMin) {
|
|
424
|
-
tMin = t1;
|
|
425
|
-
normalMin = n;
|
|
426
|
-
}
|
|
427
|
-
if (t2 < tMax) {
|
|
428
|
-
tMax = t2;
|
|
429
|
-
}
|
|
430
|
-
if (tMin > tMax) {
|
|
431
|
-
return null;
|
|
432
|
-
}
|
|
397
|
+
if (tMin > tMax) {
|
|
398
|
+
return null;
|
|
433
399
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
}
|
|
400
|
+
}
|
|
401
|
+
if (Math.abs(dir.y) < 1e-8) {
|
|
402
|
+
if (origin.y < center.y - hh || origin.y > center.y + hh) {
|
|
403
|
+
return null;
|
|
439
404
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
}
|
|
457
|
-
if (tMin > tMax) {
|
|
458
|
-
return null;
|
|
459
|
-
}
|
|
405
|
+
} else {
|
|
406
|
+
let t1 = (center.y - hh - origin.y) / dir.y;
|
|
407
|
+
let t2 = (center.y + hh - origin.y) / dir.y;
|
|
408
|
+
let n = { x: 0, y: -1 };
|
|
409
|
+
if (t1 > t2) {
|
|
410
|
+
const tmp = t1;
|
|
411
|
+
t1 = t2;
|
|
412
|
+
t2 = tmp;
|
|
413
|
+
n = { x: 0, y: 1 };
|
|
414
|
+
}
|
|
415
|
+
if (t1 > tMin) {
|
|
416
|
+
tMin = t1;
|
|
417
|
+
normalMin = n;
|
|
418
|
+
}
|
|
419
|
+
if (t2 < tMax) {
|
|
420
|
+
tMax = t2;
|
|
460
421
|
}
|
|
461
|
-
if (tMin
|
|
462
|
-
|
|
422
|
+
if (tMin > tMax) {
|
|
423
|
+
return null;
|
|
463
424
|
}
|
|
464
|
-
|
|
465
|
-
|
|
425
|
+
}
|
|
426
|
+
if (tMin < 0) {
|
|
427
|
+
return null;
|
|
428
|
+
}
|
|
429
|
+
const point = { x: origin.x + dir.x * tMin, y: origin.y + dir.y * tMin };
|
|
430
|
+
return { distance: tMin, point, normal: normalMin };
|
|
466
431
|
}
|
|
467
|
-
|
|
468
|
-
|
|
432
|
+
export {
|
|
433
|
+
PhysicsEngine2D,
|
|
434
|
+
PhysicsSystem
|
|
435
|
+
};
|