@nice2dev/game-engine 1.3.15 → 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 +9 -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,835 +1,765 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file AnimationSystem.ts
|
|
3
|
-
* @description Animation System for Nice2Dev Game Engine
|
|
4
|
-
* PRO-1.11.4: Animation System
|
|
5
|
-
*
|
|
6
|
-
* Features:
|
|
7
|
-
* - Skeletal animation
|
|
8
|
-
* - Blend trees
|
|
9
|
-
* - Animation state machine
|
|
10
|
-
* - Inverse Kinematics (IK)
|
|
11
|
-
* - Procedural animation
|
|
12
|
-
* - Morph targets
|
|
13
|
-
* - Animation events
|
|
14
|
-
*/
|
|
15
|
-
// ============================================================
|
|
16
|
-
// Animator Controller
|
|
17
|
-
// ============================================================
|
|
18
1
|
class AnimatorController {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
92
|
-
|
|
2
|
+
constructor(boneDescriptors) {
|
|
3
|
+
this.clips = /* @__PURE__ */ new Map();
|
|
4
|
+
this.layers = [];
|
|
5
|
+
this.stateMachine = null;
|
|
6
|
+
this.parameters = /* @__PURE__ */ new Map();
|
|
7
|
+
this.ikChains = /* @__PURE__ */ new Map();
|
|
8
|
+
this.morphTargets = null;
|
|
9
|
+
this.eventCallbacks = /* @__PURE__ */ new Map();
|
|
10
|
+
this.skeleton = new SkeletonImpl(boneDescriptors);
|
|
11
|
+
}
|
|
12
|
+
// ─── Clips ─────────────────────────────────────────────
|
|
13
|
+
addClip(descriptor) {
|
|
14
|
+
const clip = new AnimationClipImpl(descriptor);
|
|
15
|
+
this.clips.set(descriptor.name, clip);
|
|
16
|
+
return clip;
|
|
17
|
+
}
|
|
18
|
+
getClip(name) {
|
|
19
|
+
return this.clips.get(name);
|
|
20
|
+
}
|
|
21
|
+
removeClip(name) {
|
|
22
|
+
this.clips.delete(name);
|
|
23
|
+
}
|
|
24
|
+
// ─── Layers ────────────────────────────────────────────
|
|
25
|
+
addLayer(descriptor) {
|
|
26
|
+
const layer = new AnimationLayerImpl(descriptor, this.skeleton, this.clips, this.parameters);
|
|
27
|
+
this.layers.push(layer);
|
|
28
|
+
return layer;
|
|
29
|
+
}
|
|
30
|
+
getLayer(nameOrIndex) {
|
|
31
|
+
if (typeof nameOrIndex === "number") {
|
|
32
|
+
return this.layers[nameOrIndex];
|
|
33
|
+
}
|
|
34
|
+
return this.layers.find((l) => l.name === nameOrIndex);
|
|
35
|
+
}
|
|
36
|
+
getLayerCount() {
|
|
37
|
+
return this.layers.length;
|
|
38
|
+
}
|
|
39
|
+
// ─── State Machine ─────────────────────────────────────
|
|
40
|
+
createStateMachine(descriptor) {
|
|
41
|
+
this.stateMachine = new AnimationStateMachine(descriptor, this.clips, this.parameters);
|
|
42
|
+
if (descriptor.parameters) {
|
|
43
|
+
for (const param of descriptor.parameters) {
|
|
44
|
+
this.parameters.set(
|
|
45
|
+
param.name,
|
|
46
|
+
param.defaultValue ?? (param.type === "bool" || param.type === "trigger" ? false : 0)
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return this.stateMachine;
|
|
51
|
+
}
|
|
52
|
+
getStateMachine() {
|
|
53
|
+
return this.stateMachine;
|
|
54
|
+
}
|
|
55
|
+
// ─── Parameters ────────────────────────────────────────
|
|
56
|
+
setFloat(name, value) {
|
|
57
|
+
this.parameters.set(name, value);
|
|
58
|
+
}
|
|
59
|
+
getFloat(name) {
|
|
60
|
+
return this.parameters.get(name) ?? 0;
|
|
61
|
+
}
|
|
62
|
+
setInt(name, value) {
|
|
63
|
+
this.parameters.set(name, Math.floor(value));
|
|
64
|
+
}
|
|
65
|
+
getInt(name) {
|
|
66
|
+
return Math.floor(this.parameters.get(name)) ?? 0;
|
|
67
|
+
}
|
|
68
|
+
setBool(name, value) {
|
|
69
|
+
this.parameters.set(name, value);
|
|
70
|
+
}
|
|
71
|
+
getBool(name) {
|
|
72
|
+
return this.parameters.get(name) ?? false;
|
|
73
|
+
}
|
|
74
|
+
setTrigger(name) {
|
|
75
|
+
this.parameters.set(name, true);
|
|
76
|
+
}
|
|
77
|
+
resetTrigger(name) {
|
|
78
|
+
this.parameters.set(name, false);
|
|
79
|
+
}
|
|
80
|
+
// ─── IK ────────────────────────────────────────────────
|
|
81
|
+
addIKChain(name, descriptor) {
|
|
82
|
+
const chain = new IKChainImpl(descriptor);
|
|
83
|
+
this.ikChains.set(name, chain);
|
|
84
|
+
return chain;
|
|
85
|
+
}
|
|
86
|
+
getIKChain(name) {
|
|
87
|
+
return this.ikChains.get(name);
|
|
88
|
+
}
|
|
89
|
+
removeIKChain(name) {
|
|
90
|
+
this.ikChains.delete(name);
|
|
91
|
+
}
|
|
92
|
+
// ─── Morph Targets ─────────────────────────────────────
|
|
93
|
+
createMorphTargetManager() {
|
|
94
|
+
this.morphTargets = new MorphTargetManagerImpl();
|
|
95
|
+
return this.morphTargets;
|
|
96
|
+
}
|
|
97
|
+
getMorphTargetManager() {
|
|
98
|
+
return this.morphTargets;
|
|
99
|
+
}
|
|
100
|
+
// ─── Events ────────────────────────────────────────────
|
|
101
|
+
onEvent(eventName, callback) {
|
|
102
|
+
if (!this.eventCallbacks.has(eventName)) {
|
|
103
|
+
this.eventCallbacks.set(eventName, []);
|
|
104
|
+
}
|
|
105
|
+
this.eventCallbacks.get(eventName).push(callback);
|
|
106
|
+
}
|
|
107
|
+
offEvent(eventName, callback) {
|
|
108
|
+
const callbacks = this.eventCallbacks.get(eventName);
|
|
109
|
+
if (callbacks) {
|
|
110
|
+
const idx = callbacks.indexOf(callback);
|
|
111
|
+
if (idx >= 0) {
|
|
112
|
+
callbacks.splice(idx, 1);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
dispatchEvent(eventName, data) {
|
|
117
|
+
const callbacks = this.eventCallbacks.get(eventName);
|
|
118
|
+
if (callbacks) {
|
|
119
|
+
for (const cb of callbacks) {
|
|
120
|
+
cb(data);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// ─── Update ────────────────────────────────────────────
|
|
125
|
+
update(deltaTime) {
|
|
126
|
+
if (this.stateMachine) {
|
|
127
|
+
this.stateMachine.update(deltaTime);
|
|
128
|
+
const events = this.stateMachine.getTriggeredEvents();
|
|
129
|
+
for (const event of events) {
|
|
130
|
+
this.dispatchEvent(event.name, event.data);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
for (const layer of this.layers) {
|
|
134
|
+
layer.evaluate(deltaTime);
|
|
135
|
+
}
|
|
136
|
+
if (this.stateMachine) {
|
|
137
|
+
this.stateMachine.sample(this.skeleton);
|
|
138
|
+
}
|
|
139
|
+
for (const _layer of this.layers) {
|
|
140
|
+
}
|
|
141
|
+
this.skeleton.computeWorldTransforms();
|
|
142
|
+
for (const chain of this.ikChains.values()) {
|
|
143
|
+
if (chain.isEnabled()) {
|
|
144
|
+
chain.solve(this.skeleton);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
for (const [name, value] of this.parameters.entries()) {
|
|
148
|
+
if (value === true && this.isTrigger(name)) {
|
|
93
149
|
this.parameters.set(name, false);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
// ─── Morph Targets ─────────────────────────────────────
|
|
108
|
-
createMorphTargetManager() {
|
|
109
|
-
this.morphTargets = new MorphTargetManagerImpl();
|
|
110
|
-
return this.morphTargets;
|
|
111
|
-
}
|
|
112
|
-
getMorphTargetManager() {
|
|
113
|
-
return this.morphTargets;
|
|
114
|
-
}
|
|
115
|
-
// ─── Events ────────────────────────────────────────────
|
|
116
|
-
onEvent(eventName, callback) {
|
|
117
|
-
if (!this.eventCallbacks.has(eventName)) {
|
|
118
|
-
this.eventCallbacks.set(eventName, []);
|
|
119
|
-
}
|
|
120
|
-
this.eventCallbacks.get(eventName).push(callback);
|
|
121
|
-
}
|
|
122
|
-
offEvent(eventName, callback) {
|
|
123
|
-
const callbacks = this.eventCallbacks.get(eventName);
|
|
124
|
-
if (callbacks) {
|
|
125
|
-
const idx = callbacks.indexOf(callback);
|
|
126
|
-
if (idx >= 0) {
|
|
127
|
-
callbacks.splice(idx, 1);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
dispatchEvent(eventName, data) {
|
|
132
|
-
const callbacks = this.eventCallbacks.get(eventName);
|
|
133
|
-
if (callbacks) {
|
|
134
|
-
for (const cb of callbacks) {
|
|
135
|
-
cb(data);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
// ─── Update ────────────────────────────────────────────
|
|
140
|
-
update(deltaTime) {
|
|
141
|
-
// Update state machine
|
|
142
|
-
if (this.stateMachine) {
|
|
143
|
-
this.stateMachine.update(deltaTime);
|
|
144
|
-
// Check for animation events
|
|
145
|
-
const events = this.stateMachine.getTriggeredEvents();
|
|
146
|
-
for (const event of events) {
|
|
147
|
-
this.dispatchEvent(event.name, event.data);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
// Update layers
|
|
151
|
-
for (const layer of this.layers) {
|
|
152
|
-
layer.evaluate(deltaTime);
|
|
153
|
-
}
|
|
154
|
-
// Apply state machine to skeleton
|
|
155
|
-
if (this.stateMachine) {
|
|
156
|
-
this.stateMachine.sample(this.skeleton);
|
|
157
|
-
}
|
|
158
|
-
// Apply layers to skeleton
|
|
159
|
-
for (const _layer of this.layers) {
|
|
160
|
-
// Layer application happens in evaluate
|
|
161
|
-
}
|
|
162
|
-
// Compute world transforms
|
|
163
|
-
this.skeleton.computeWorldTransforms();
|
|
164
|
-
// Apply IK
|
|
165
|
-
for (const chain of this.ikChains.values()) {
|
|
166
|
-
if (chain.isEnabled()) {
|
|
167
|
-
chain.solve(this.skeleton);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
// Reset triggers
|
|
171
|
-
for (const [name, value] of this.parameters.entries()) {
|
|
172
|
-
if (value === true && this.isTrigger(name)) {
|
|
173
|
-
this.parameters.set(name, false);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
isTrigger(_name) {
|
|
178
|
-
// Check if parameter is a trigger type
|
|
179
|
-
return false; // Would check against parameter definitions
|
|
180
|
-
}
|
|
181
|
-
// ─── Output ────────────────────────────────────────────
|
|
182
|
-
getSkeleton() {
|
|
183
|
-
return this.skeleton;
|
|
184
|
-
}
|
|
185
|
-
getJointMatrices() {
|
|
186
|
-
return this.skeleton.getJointMatrices();
|
|
187
|
-
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
isTrigger(_name) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
// ─── Output ────────────────────────────────────────────
|
|
157
|
+
getSkeleton() {
|
|
158
|
+
return this.skeleton;
|
|
159
|
+
}
|
|
160
|
+
getJointMatrices() {
|
|
161
|
+
return this.skeleton.getJointMatrices();
|
|
162
|
+
}
|
|
188
163
|
}
|
|
189
|
-
// ============================================================
|
|
190
|
-
// Animation State Machine
|
|
191
|
-
// ============================================================
|
|
192
164
|
class AnimationStateMachine {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
165
|
+
constructor(descriptor, clips, parameters) {
|
|
166
|
+
this.states = /* @__PURE__ */ new Map();
|
|
167
|
+
this.transitions = [];
|
|
168
|
+
this.currentState = null;
|
|
169
|
+
this.activeTransition = null;
|
|
170
|
+
this.previousTime = 0;
|
|
171
|
+
this.triggeredEvents = [];
|
|
172
|
+
this.parameters = parameters;
|
|
173
|
+
for (const stateDesc of descriptor.states) {
|
|
174
|
+
const clip = stateDesc.clip ? clips.get(stateDesc.clip) ?? null : null;
|
|
175
|
+
const state = new AnimationStateImpl(stateDesc, clip);
|
|
176
|
+
this.states.set(stateDesc.name, state);
|
|
177
|
+
}
|
|
178
|
+
for (const transDesc of descriptor.transitions) {
|
|
179
|
+
const from = this.states.get(transDesc.from);
|
|
180
|
+
const to = this.states.get(transDesc.to);
|
|
181
|
+
if (from && to) {
|
|
182
|
+
this.transitions.push(new AnimationTransitionImpl(from, to, transDesc));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (descriptor.defaultState) {
|
|
186
|
+
this.currentState = this.states.get(descriptor.defaultState) ?? null;
|
|
187
|
+
this.currentState?.enter();
|
|
188
|
+
} else if (this.states.size > 0) {
|
|
189
|
+
this.currentState = this.states.values().next().value ?? null;
|
|
190
|
+
this.currentState?.enter();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
getCurrentState() {
|
|
194
|
+
return this.currentState;
|
|
195
|
+
}
|
|
196
|
+
isInTransition() {
|
|
197
|
+
return this.activeTransition !== null;
|
|
198
|
+
}
|
|
199
|
+
getTransitionProgress() {
|
|
200
|
+
return this.activeTransition?.progress ?? 0;
|
|
201
|
+
}
|
|
202
|
+
update(deltaTime) {
|
|
203
|
+
this.triggeredEvents = [];
|
|
204
|
+
if (this.activeTransition) {
|
|
205
|
+
this.activeTransition.update(deltaTime);
|
|
206
|
+
if (this.activeTransition.isComplete()) {
|
|
207
|
+
this.currentState = this.activeTransition.to;
|
|
197
208
|
this.activeTransition = null;
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if (from && to) {
|
|
212
|
-
this.transitions.push(new AnimationTransitionImpl(from, to, transDesc));
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
// Set default state
|
|
216
|
-
if (descriptor.defaultState) {
|
|
217
|
-
this.currentState = this.states.get(descriptor.defaultState) ?? null;
|
|
218
|
-
this.currentState?.enter();
|
|
219
|
-
}
|
|
220
|
-
else if (this.states.size > 0) {
|
|
221
|
-
this.currentState = this.states.values().next().value ?? null;
|
|
222
|
-
this.currentState?.enter();
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
getCurrentState() {
|
|
226
|
-
return this.currentState;
|
|
227
|
-
}
|
|
228
|
-
isInTransition() {
|
|
229
|
-
return this.activeTransition !== null;
|
|
230
|
-
}
|
|
231
|
-
getTransitionProgress() {
|
|
232
|
-
return this.activeTransition?.progress ?? 0;
|
|
233
|
-
}
|
|
234
|
-
update(deltaTime) {
|
|
235
|
-
this.triggeredEvents = [];
|
|
236
|
-
// Update active transition
|
|
237
|
-
if (this.activeTransition) {
|
|
238
|
-
this.activeTransition.update(deltaTime);
|
|
239
|
-
if (this.activeTransition.isComplete()) {
|
|
240
|
-
this.currentState = this.activeTransition.to;
|
|
241
|
-
this.activeTransition = null;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
// Check for transitions
|
|
246
|
-
if (this.currentState) {
|
|
247
|
-
for (const transition of this.transitions) {
|
|
248
|
-
if (transition.from === this.currentState && transition.check(this.parameters)) {
|
|
249
|
-
// Check exit time
|
|
250
|
-
if (transition.hasExitTime) {
|
|
251
|
-
if (this.currentState.normalizedTime >= transition.exitTime) {
|
|
252
|
-
this.startTransition(transition);
|
|
253
|
-
break;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
else {
|
|
257
|
-
this.startTransition(transition);
|
|
258
|
-
break;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
// Update current state
|
|
265
|
-
const prevTime = this.currentState?.time ?? 0;
|
|
266
|
-
this.currentState?.update(deltaTime);
|
|
267
|
-
const currTime = this.currentState?.time ?? 0;
|
|
268
|
-
// Check for events
|
|
269
|
-
if (this.currentState?.clip) {
|
|
270
|
-
const event = this.currentState.clip.getEvent(currTime, prevTime);
|
|
271
|
-
if (event) {
|
|
272
|
-
this.triggeredEvents.push(event);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
startTransition(transition) {
|
|
277
|
-
this.currentState?.exit();
|
|
278
|
-
transition.to.enter();
|
|
279
|
-
transition.to.time = transition.offset * transition.to.clip.duration;
|
|
280
|
-
transition.progress = 0;
|
|
281
|
-
this.activeTransition = transition;
|
|
282
|
-
}
|
|
283
|
-
sample(skeleton) {
|
|
284
|
-
if (this.activeTransition) {
|
|
285
|
-
// Blend between states
|
|
286
|
-
1 - this.activeTransition.progress;
|
|
287
|
-
const toWeight = this.activeTransition.progress;
|
|
288
|
-
// Sample from state
|
|
289
|
-
this.activeTransition.from.sample(skeleton);
|
|
290
|
-
// Would need to blend, simplified here
|
|
291
|
-
if (toWeight > 0.5) {
|
|
292
|
-
this.activeTransition.to.sample(skeleton);
|
|
209
|
+
}
|
|
210
|
+
} else {
|
|
211
|
+
if (this.currentState) {
|
|
212
|
+
for (const transition of this.transitions) {
|
|
213
|
+
if (transition.from === this.currentState && transition.check(this.parameters)) {
|
|
214
|
+
if (transition.hasExitTime) {
|
|
215
|
+
if (this.currentState.normalizedTime >= transition.exitTime) {
|
|
216
|
+
this.startTransition(transition);
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
} else {
|
|
220
|
+
this.startTransition(transition);
|
|
221
|
+
break;
|
|
293
222
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
const prevTime = this.currentState?.time ?? 0;
|
|
228
|
+
this.currentState?.update(deltaTime);
|
|
229
|
+
const currTime = this.currentState?.time ?? 0;
|
|
230
|
+
if (this.currentState?.clip) {
|
|
231
|
+
const event = this.currentState.clip.getEvent(currTime, prevTime);
|
|
232
|
+
if (event) {
|
|
233
|
+
this.triggeredEvents.push(event);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
startTransition(transition) {
|
|
238
|
+
this.currentState?.exit();
|
|
239
|
+
transition.to.enter();
|
|
240
|
+
transition.to.time = transition.offset * transition.to.clip.duration;
|
|
241
|
+
transition.progress = 0;
|
|
242
|
+
this.activeTransition = transition;
|
|
243
|
+
}
|
|
244
|
+
sample(skeleton) {
|
|
245
|
+
if (this.activeTransition) {
|
|
246
|
+
1 - this.activeTransition.progress;
|
|
247
|
+
const toWeight = this.activeTransition.progress;
|
|
248
|
+
this.activeTransition.from.sample(skeleton);
|
|
249
|
+
if (toWeight > 0.5) {
|
|
250
|
+
this.activeTransition.to.sample(skeleton);
|
|
251
|
+
}
|
|
252
|
+
} else if (this.currentState) {
|
|
253
|
+
this.currentState.sample(skeleton);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
getTriggeredEvents() {
|
|
257
|
+
return this.triggeredEvents;
|
|
258
|
+
}
|
|
259
|
+
forceState(stateName) {
|
|
260
|
+
const state = this.states.get(stateName);
|
|
261
|
+
if (state) {
|
|
262
|
+
this.currentState?.exit();
|
|
263
|
+
this.currentState = state;
|
|
264
|
+
this.currentState.enter();
|
|
265
|
+
this.activeTransition = null;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
311
268
|
}
|
|
312
|
-
// ============================================================
|
|
313
|
-
// Internal Implementations
|
|
314
|
-
// ============================================================
|
|
315
269
|
class SkeletonImpl {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
270
|
+
constructor(descriptors) {
|
|
271
|
+
this.boneMap = /* @__PURE__ */ new Map();
|
|
272
|
+
this.bones = descriptors.map((desc, index) => ({
|
|
273
|
+
name: desc.name,
|
|
274
|
+
index,
|
|
275
|
+
parentIndex: desc.parentIndex,
|
|
276
|
+
children: [],
|
|
277
|
+
localPosition: { ...desc.position },
|
|
278
|
+
localRotation: { ...desc.rotation },
|
|
279
|
+
localScale: { ...desc.scale },
|
|
280
|
+
worldPosition: { ...desc.position },
|
|
281
|
+
worldRotation: { ...desc.rotation },
|
|
282
|
+
worldScale: { ...desc.scale },
|
|
283
|
+
inverseBindMatrix: new Float32Array(16)
|
|
284
|
+
}));
|
|
285
|
+
for (let i = 0; i < this.bones.length; i++) {
|
|
286
|
+
const bone = this.bones[i];
|
|
287
|
+
this.boneMap.set(bone.name, i);
|
|
288
|
+
if (bone.parentIndex >= 0) {
|
|
289
|
+
this.bones[bone.parentIndex].children.push(i);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
this.jointMatrices = new Float32Array(this.bones.length * 16);
|
|
293
|
+
this.computeWorldTransforms();
|
|
294
|
+
}
|
|
295
|
+
getBone(nameOrIndex) {
|
|
296
|
+
if (typeof nameOrIndex === "number") {
|
|
297
|
+
return this.bones[nameOrIndex];
|
|
298
|
+
}
|
|
299
|
+
const index = this.boneMap.get(nameOrIndex);
|
|
300
|
+
return index !== void 0 ? this.bones[index] : void 0;
|
|
301
|
+
}
|
|
302
|
+
getBoneIndex(name) {
|
|
303
|
+
return this.boneMap.get(name) ?? -1;
|
|
304
|
+
}
|
|
305
|
+
getBoneCount() {
|
|
306
|
+
return this.bones.length;
|
|
307
|
+
}
|
|
308
|
+
setLocalPose(boneIndex, position, rotation, scale) {
|
|
309
|
+
const bone = this.bones[boneIndex];
|
|
310
|
+
if (bone) {
|
|
311
|
+
bone.localPosition = { ...position };
|
|
312
|
+
bone.localRotation = { ...rotation };
|
|
313
|
+
bone.localScale = { ...scale };
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
getLocalPose(boneIndex) {
|
|
317
|
+
const bone = this.bones[boneIndex];
|
|
318
|
+
return {
|
|
319
|
+
position: { ...bone.localPosition },
|
|
320
|
+
rotation: { ...bone.localRotation },
|
|
321
|
+
scale: { ...bone.localScale }
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
computeWorldTransforms() {
|
|
325
|
+
for (const bone of this.bones) {
|
|
326
|
+
if (bone.parentIndex < 0) {
|
|
327
|
+
bone.worldPosition = { ...bone.localPosition };
|
|
328
|
+
bone.worldRotation = { ...bone.localRotation };
|
|
329
|
+
bone.worldScale = { ...bone.localScale };
|
|
330
|
+
} else {
|
|
331
|
+
const parent = this.bones[bone.parentIndex];
|
|
332
|
+
bone.worldPosition = this.transformPoint(bone.localPosition, parent);
|
|
333
|
+
bone.worldRotation = this.multiplyQuaternions(parent.worldRotation, bone.localRotation);
|
|
334
|
+
bone.worldScale = {
|
|
335
|
+
x: parent.worldScale.x * bone.localScale.x,
|
|
336
|
+
y: parent.worldScale.y * bone.localScale.y,
|
|
337
|
+
z: parent.worldScale.z * bone.localScale.z
|
|
369
338
|
};
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
multiplyQuaternions(a, b) {
|
|
403
|
-
return {
|
|
404
|
-
x: a.w * b.x + a.x * b.w + a.y * b.z - a.z * b.y,
|
|
405
|
-
y: a.w * b.y - a.x * b.z + a.y * b.w + a.z * b.x,
|
|
406
|
-
z: a.w * b.z + a.x * b.y - a.y * b.x + a.z * b.w,
|
|
407
|
-
w: a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z,
|
|
408
|
-
};
|
|
409
|
-
}
|
|
410
|
-
updateJointMatrix(bone) {
|
|
411
|
-
const offset = bone.index * 16;
|
|
412
|
-
// Simplified - would compose TRS matrix
|
|
413
|
-
// Final = WorldMatrix * InverseBindMatrix
|
|
414
|
-
this.jointMatrices[offset] = 1;
|
|
415
|
-
this.jointMatrices[offset + 5] = 1;
|
|
416
|
-
this.jointMatrices[offset + 10] = 1;
|
|
417
|
-
this.jointMatrices[offset + 15] = 1;
|
|
418
|
-
this.jointMatrices[offset + 12] = bone.worldPosition.x;
|
|
419
|
-
this.jointMatrices[offset + 13] = bone.worldPosition.y;
|
|
420
|
-
this.jointMatrices[offset + 14] = bone.worldPosition.z;
|
|
421
|
-
}
|
|
422
|
-
getJointMatrices() {
|
|
423
|
-
return this.jointMatrices;
|
|
424
|
-
}
|
|
339
|
+
}
|
|
340
|
+
this.updateJointMatrix(bone);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
transformPoint(point, parent) {
|
|
344
|
+
return {
|
|
345
|
+
x: parent.worldPosition.x + point.x * parent.worldScale.x,
|
|
346
|
+
y: parent.worldPosition.y + point.y * parent.worldScale.y,
|
|
347
|
+
z: parent.worldPosition.z + point.z * parent.worldScale.z
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
multiplyQuaternions(a, b) {
|
|
351
|
+
return {
|
|
352
|
+
x: a.w * b.x + a.x * b.w + a.y * b.z - a.z * b.y,
|
|
353
|
+
y: a.w * b.y - a.x * b.z + a.y * b.w + a.z * b.x,
|
|
354
|
+
z: a.w * b.z + a.x * b.y - a.y * b.x + a.z * b.w,
|
|
355
|
+
w: a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
updateJointMatrix(bone) {
|
|
359
|
+
const offset = bone.index * 16;
|
|
360
|
+
this.jointMatrices[offset] = 1;
|
|
361
|
+
this.jointMatrices[offset + 5] = 1;
|
|
362
|
+
this.jointMatrices[offset + 10] = 1;
|
|
363
|
+
this.jointMatrices[offset + 15] = 1;
|
|
364
|
+
this.jointMatrices[offset + 12] = bone.worldPosition.x;
|
|
365
|
+
this.jointMatrices[offset + 13] = bone.worldPosition.y;
|
|
366
|
+
this.jointMatrices[offset + 14] = bone.worldPosition.z;
|
|
367
|
+
}
|
|
368
|
+
getJointMatrices() {
|
|
369
|
+
return this.jointMatrices;
|
|
370
|
+
}
|
|
425
371
|
}
|
|
426
372
|
class AnimationClipImpl {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
return
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
return event;
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
return null;
|
|
528
|
-
}
|
|
373
|
+
constructor(descriptor) {
|
|
374
|
+
this.name = descriptor.name;
|
|
375
|
+
this.duration = descriptor.duration;
|
|
376
|
+
this.tracks = descriptor.tracks;
|
|
377
|
+
this.events = descriptor.events ?? [];
|
|
378
|
+
}
|
|
379
|
+
sample(time, skeleton) {
|
|
380
|
+
for (const track of this.tracks) {
|
|
381
|
+
const boneIndex = skeleton.getBoneIndex(track.targetBone);
|
|
382
|
+
if (boneIndex < 0) {
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
const value = this.sampleTrack(track, time);
|
|
386
|
+
const pose = skeleton.getLocalPose(boneIndex);
|
|
387
|
+
switch (track.property) {
|
|
388
|
+
case "position":
|
|
389
|
+
skeleton.setLocalPose(boneIndex, value, pose.rotation, pose.scale);
|
|
390
|
+
break;
|
|
391
|
+
case "rotation":
|
|
392
|
+
skeleton.setLocalPose(boneIndex, pose.position, value, pose.scale);
|
|
393
|
+
break;
|
|
394
|
+
case "scale":
|
|
395
|
+
skeleton.setLocalPose(boneIndex, pose.position, pose.rotation, value);
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
sampleTrack(track, time) {
|
|
401
|
+
const keyframes = track.keyframes;
|
|
402
|
+
if (keyframes.length === 0) {
|
|
403
|
+
return track.property === "rotation" ? { x: 0, y: 0, z: 0, w: 1 } : { x: 0, y: 0, z: 0 };
|
|
404
|
+
}
|
|
405
|
+
if (keyframes.length === 1 || time <= keyframes[0].time) {
|
|
406
|
+
return keyframes[0].value;
|
|
407
|
+
}
|
|
408
|
+
if (time >= keyframes[keyframes.length - 1].time) {
|
|
409
|
+
return keyframes[keyframes.length - 1].value;
|
|
410
|
+
}
|
|
411
|
+
let i = 0;
|
|
412
|
+
while (i < keyframes.length - 1 && keyframes[i + 1].time < time) {
|
|
413
|
+
i++;
|
|
414
|
+
}
|
|
415
|
+
const k0 = keyframes[i];
|
|
416
|
+
const k1 = keyframes[i + 1];
|
|
417
|
+
const t = (time - k0.time) / (k1.time - k0.time);
|
|
418
|
+
if (track.property === "rotation") {
|
|
419
|
+
return this.slerpQuaternion(k0.value, k1.value, t);
|
|
420
|
+
} else {
|
|
421
|
+
return this.lerpVec3(k0.value, k1.value, t);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
lerpVec3(a, b, t) {
|
|
425
|
+
return {
|
|
426
|
+
x: a.x + (b.x - a.x) * t,
|
|
427
|
+
y: a.y + (b.y - a.y) * t,
|
|
428
|
+
z: a.z + (b.z - a.z) * t
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
slerpQuaternion(a, b, t) {
|
|
432
|
+
let dot = a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
|
|
433
|
+
if (dot < 0) {
|
|
434
|
+
b = { x: -b.x, y: -b.y, z: -b.z, w: -b.w };
|
|
435
|
+
dot = -dot;
|
|
436
|
+
}
|
|
437
|
+
if (dot > 0.9995) {
|
|
438
|
+
return this.normalizeQuaternion({
|
|
439
|
+
x: a.x + (b.x - a.x) * t,
|
|
440
|
+
y: a.y + (b.y - a.y) * t,
|
|
441
|
+
z: a.z + (b.z - a.z) * t,
|
|
442
|
+
w: a.w + (b.w - a.w) * t
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
const theta0 = Math.acos(dot);
|
|
446
|
+
const theta = theta0 * t;
|
|
447
|
+
const sinTheta = Math.sin(theta);
|
|
448
|
+
const sinTheta0 = Math.sin(theta0);
|
|
449
|
+
const s0 = Math.cos(theta) - dot * sinTheta / sinTheta0;
|
|
450
|
+
const s1 = sinTheta / sinTheta0;
|
|
451
|
+
return {
|
|
452
|
+
x: a.x * s0 + b.x * s1,
|
|
453
|
+
y: a.y * s0 + b.y * s1,
|
|
454
|
+
z: a.z * s0 + b.z * s1,
|
|
455
|
+
w: a.w * s0 + b.w * s1
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
normalizeQuaternion(q) {
|
|
459
|
+
const len = Math.sqrt(q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w);
|
|
460
|
+
return { x: q.x / len, y: q.y / len, z: q.z / len, w: q.w / len };
|
|
461
|
+
}
|
|
462
|
+
getEvent(time, previousTime) {
|
|
463
|
+
for (const event of this.events) {
|
|
464
|
+
if (event.time > previousTime && event.time <= time) {
|
|
465
|
+
return event;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
return null;
|
|
469
|
+
}
|
|
529
470
|
}
|
|
530
471
|
class AnimationLayerImpl {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
}
|
|
472
|
+
constructor(descriptor, _skeleton, _clips, _parameters) {
|
|
473
|
+
this._mask = null;
|
|
474
|
+
this._currentState = null;
|
|
475
|
+
this.name = descriptor.name;
|
|
476
|
+
this.blendMode = descriptor.blendMode ?? "override";
|
|
477
|
+
this._weight = descriptor.weight ?? 1;
|
|
478
|
+
if (descriptor.mask) {
|
|
479
|
+
this._mask = new AvatarMaskImpl(descriptor.mask);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
getWeight() {
|
|
483
|
+
return this._weight;
|
|
484
|
+
}
|
|
485
|
+
setWeight(weight) {
|
|
486
|
+
this._weight = Math.max(0, Math.min(1, weight));
|
|
487
|
+
}
|
|
488
|
+
getBlendMode() {
|
|
489
|
+
return this.blendMode;
|
|
490
|
+
}
|
|
491
|
+
setBlendMode(mode) {
|
|
492
|
+
this.blendMode = mode;
|
|
493
|
+
}
|
|
494
|
+
getMask() {
|
|
495
|
+
return this._mask;
|
|
496
|
+
}
|
|
497
|
+
setMask(mask) {
|
|
498
|
+
this._mask = mask;
|
|
499
|
+
}
|
|
500
|
+
getCurrentState() {
|
|
501
|
+
return this._currentState;
|
|
502
|
+
}
|
|
503
|
+
setCurrentState(state) {
|
|
504
|
+
this._currentState = state;
|
|
505
|
+
}
|
|
506
|
+
evaluate(_deltaTime) {
|
|
507
|
+
}
|
|
568
508
|
}
|
|
569
509
|
class AvatarMaskImpl {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
510
|
+
constructor(bones) {
|
|
511
|
+
this.weights = /* @__PURE__ */ new Map();
|
|
512
|
+
for (const bone of bones) {
|
|
513
|
+
this.weights.set(bone, 1);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
getBoneWeight(boneName) {
|
|
517
|
+
return this.weights.get(boneName) ?? 0;
|
|
518
|
+
}
|
|
519
|
+
setBoneWeight(boneName, weight) {
|
|
520
|
+
this.weights.set(boneName, weight);
|
|
521
|
+
}
|
|
522
|
+
setAllWeights(weight) {
|
|
523
|
+
for (const bone of this.weights.keys()) {
|
|
524
|
+
this.weights.set(bone, weight);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
587
527
|
}
|
|
588
528
|
class AnimationStateImpl {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
this.blendTree.sample(skeleton);
|
|
637
|
-
}
|
|
638
|
-
}
|
|
529
|
+
constructor(descriptor, clip) {
|
|
530
|
+
this.blendTree = null;
|
|
531
|
+
this.normalizedTime = 0;
|
|
532
|
+
this.time = 0;
|
|
533
|
+
this.name = descriptor.name;
|
|
534
|
+
this.type = descriptor.type;
|
|
535
|
+
this.clip = clip;
|
|
536
|
+
this.speed = descriptor.speed ?? 1;
|
|
537
|
+
this.wrapMode = descriptor.wrapMode ?? "loop";
|
|
538
|
+
}
|
|
539
|
+
enter() {
|
|
540
|
+
this.time = 0;
|
|
541
|
+
this.normalizedTime = 0;
|
|
542
|
+
}
|
|
543
|
+
exit() {
|
|
544
|
+
}
|
|
545
|
+
update(deltaTime) {
|
|
546
|
+
this.time += deltaTime * this.speed;
|
|
547
|
+
if (this.clip) {
|
|
548
|
+
const duration = this.clip.duration;
|
|
549
|
+
switch (this.wrapMode) {
|
|
550
|
+
case "once":
|
|
551
|
+
if (this.time > duration) {
|
|
552
|
+
this.time = duration;
|
|
553
|
+
}
|
|
554
|
+
break;
|
|
555
|
+
case "loop":
|
|
556
|
+
while (this.time > duration) {
|
|
557
|
+
this.time -= duration;
|
|
558
|
+
}
|
|
559
|
+
break;
|
|
560
|
+
case "pingpong":
|
|
561
|
+
break;
|
|
562
|
+
case "clamp":
|
|
563
|
+
this.time = Math.max(0, Math.min(this.time, duration));
|
|
564
|
+
break;
|
|
565
|
+
}
|
|
566
|
+
this.normalizedTime = duration > 0 ? this.time / duration : 0;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
sample(skeleton) {
|
|
570
|
+
if (this.clip) {
|
|
571
|
+
this.clip.sample(this.time, skeleton);
|
|
572
|
+
} else if (this.blendTree) {
|
|
573
|
+
this.blendTree.sample(skeleton);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
639
576
|
}
|
|
640
577
|
class AnimationTransitionImpl {
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
}
|
|
578
|
+
constructor(from, to, descriptor) {
|
|
579
|
+
this.progress = 0;
|
|
580
|
+
this.from = from;
|
|
581
|
+
this.to = to;
|
|
582
|
+
this.duration = descriptor.duration ?? 0.25;
|
|
583
|
+
this.offset = descriptor.offset ?? 0;
|
|
584
|
+
this.conditions = descriptor.conditions ?? [];
|
|
585
|
+
this.hasExitTime = descriptor.hasExitTime ?? false;
|
|
586
|
+
this.exitTime = descriptor.exitTime ?? 1;
|
|
587
|
+
}
|
|
588
|
+
check(parameters) {
|
|
589
|
+
if (this.conditions.length === 0) {
|
|
590
|
+
return true;
|
|
591
|
+
}
|
|
592
|
+
for (const condition of this.conditions) {
|
|
593
|
+
const value = parameters.get(condition.parameter);
|
|
594
|
+
if (value === void 0) {
|
|
595
|
+
continue;
|
|
596
|
+
}
|
|
597
|
+
let result = false;
|
|
598
|
+
switch (condition.mode) {
|
|
599
|
+
case "equals":
|
|
600
|
+
result = value === condition.value;
|
|
601
|
+
break;
|
|
602
|
+
case "not-equals":
|
|
603
|
+
result = value !== condition.value;
|
|
604
|
+
break;
|
|
605
|
+
case "greater":
|
|
606
|
+
result = value > condition.value;
|
|
607
|
+
break;
|
|
608
|
+
case "less":
|
|
609
|
+
result = value < condition.value;
|
|
610
|
+
break;
|
|
611
|
+
case "if":
|
|
612
|
+
result = value === true;
|
|
613
|
+
break;
|
|
614
|
+
case "if-not":
|
|
615
|
+
result = value === false;
|
|
616
|
+
break;
|
|
617
|
+
}
|
|
618
|
+
if (!result) {
|
|
619
|
+
return false;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
return true;
|
|
623
|
+
}
|
|
624
|
+
update(deltaTime) {
|
|
625
|
+
if (this.duration > 0) {
|
|
626
|
+
this.progress += deltaTime / this.duration;
|
|
627
|
+
this.progress = Math.min(1, this.progress);
|
|
628
|
+
} else {
|
|
629
|
+
this.progress = 1;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
isComplete() {
|
|
633
|
+
return this.progress >= 1;
|
|
634
|
+
}
|
|
699
635
|
}
|
|
700
636
|
class IKChainImpl {
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
}
|
|
769
|
-
solveCCD(_skeleton) {
|
|
770
|
-
// Cyclic Coordinate Descent
|
|
771
|
-
for (let i = 0; i < this._iterations; i++) {
|
|
772
|
-
// Iterate through chain from tip to root
|
|
773
|
-
}
|
|
774
|
-
}
|
|
637
|
+
constructor(descriptor) {
|
|
638
|
+
this._target = { x: 0, y: 0, z: 0 };
|
|
639
|
+
this._poleTarget = null;
|
|
640
|
+
this._enabled = true;
|
|
641
|
+
this.type = descriptor.type;
|
|
642
|
+
this.rootBone = descriptor.rootBone;
|
|
643
|
+
this.tipBone = descriptor.tipBone;
|
|
644
|
+
this._weight = descriptor.weight ?? 1;
|
|
645
|
+
this._iterations = descriptor.iterations ?? 10;
|
|
646
|
+
this._tolerance = descriptor.tolerance ?? 1e-3;
|
|
647
|
+
this._poleTarget = descriptor.poleTarget ?? null;
|
|
648
|
+
}
|
|
649
|
+
getTarget() {
|
|
650
|
+
return { ...this._target };
|
|
651
|
+
}
|
|
652
|
+
setTarget(target) {
|
|
653
|
+
this._target = { ...target };
|
|
654
|
+
}
|
|
655
|
+
getPoleTarget() {
|
|
656
|
+
return this._poleTarget ? { ...this._poleTarget } : null;
|
|
657
|
+
}
|
|
658
|
+
setPoleTarget(target) {
|
|
659
|
+
this._poleTarget = target ? { ...target } : null;
|
|
660
|
+
}
|
|
661
|
+
getWeight() {
|
|
662
|
+
return this._weight;
|
|
663
|
+
}
|
|
664
|
+
setWeight(weight) {
|
|
665
|
+
this._weight = Math.max(0, Math.min(1, weight));
|
|
666
|
+
}
|
|
667
|
+
isEnabled() {
|
|
668
|
+
return this._enabled;
|
|
669
|
+
}
|
|
670
|
+
setEnabled(enabled) {
|
|
671
|
+
this._enabled = enabled;
|
|
672
|
+
}
|
|
673
|
+
solve(skeleton) {
|
|
674
|
+
if (!this._enabled || this._weight <= 0) {
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
switch (this.type) {
|
|
678
|
+
case "two-bone":
|
|
679
|
+
this.solveTwoBone(skeleton);
|
|
680
|
+
break;
|
|
681
|
+
case "fabrik":
|
|
682
|
+
this.solveFABRIK(skeleton);
|
|
683
|
+
break;
|
|
684
|
+
case "ccd":
|
|
685
|
+
this.solveCCD(skeleton);
|
|
686
|
+
break;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
solveTwoBone(skeleton) {
|
|
690
|
+
const root = skeleton.getBone(this.rootBone);
|
|
691
|
+
const tip = skeleton.getBone(this.tipBone);
|
|
692
|
+
if (!root || !tip) {
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
solveFABRIK(_skeleton) {
|
|
697
|
+
for (let i = 0; i < this._iterations; i++) {
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
solveCCD(_skeleton) {
|
|
701
|
+
for (let i = 0; i < this._iterations; i++) {
|
|
702
|
+
}
|
|
703
|
+
}
|
|
775
704
|
}
|
|
776
705
|
class MorphTargetManagerImpl {
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
706
|
+
constructor() {
|
|
707
|
+
this.targets = /* @__PURE__ */ new Map();
|
|
708
|
+
}
|
|
709
|
+
getMorphTarget(name) {
|
|
710
|
+
return this.targets.get(name);
|
|
711
|
+
}
|
|
712
|
+
getMorphTargets() {
|
|
713
|
+
return Array.from(this.targets.values());
|
|
714
|
+
}
|
|
715
|
+
addMorphTarget(descriptor) {
|
|
716
|
+
const target = new MorphTargetImpl(descriptor);
|
|
717
|
+
this.targets.set(descriptor.name, target);
|
|
718
|
+
return target;
|
|
719
|
+
}
|
|
720
|
+
removeMorphTarget(name) {
|
|
721
|
+
this.targets.delete(name);
|
|
722
|
+
}
|
|
723
|
+
getWeight(name) {
|
|
724
|
+
return this.targets.get(name)?.weight ?? 0;
|
|
725
|
+
}
|
|
726
|
+
setWeight(name, weight) {
|
|
727
|
+
const target = this.targets.get(name);
|
|
728
|
+
if (target) {
|
|
729
|
+
target.weight = Math.max(0, Math.min(1, weight));
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
getBlendedVertices(baseVertices) {
|
|
733
|
+
const result = new Float32Array(baseVertices);
|
|
734
|
+
for (const target of this.targets.values()) {
|
|
735
|
+
if (target.weight <= 0) {
|
|
736
|
+
continue;
|
|
737
|
+
}
|
|
738
|
+
for (let i = 0; i < result.length; i++) {
|
|
739
|
+
result[i] += target.vertices[i] * target.weight;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
return result;
|
|
743
|
+
}
|
|
815
744
|
}
|
|
816
745
|
class MorphTargetImpl {
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
746
|
+
constructor(descriptor) {
|
|
747
|
+
this.weight = 0;
|
|
748
|
+
this.name = descriptor.name;
|
|
749
|
+
this.vertices = descriptor.vertices;
|
|
750
|
+
this.normals = descriptor.normals ?? null;
|
|
751
|
+
this.tangents = descriptor.tangents ?? null;
|
|
752
|
+
}
|
|
824
753
|
}
|
|
825
|
-
// ============================================================
|
|
826
|
-
// Factory Functions
|
|
827
|
-
// ============================================================
|
|
828
754
|
function createAnimatorController(bones) {
|
|
829
|
-
|
|
755
|
+
return new AnimatorController(bones);
|
|
830
756
|
}
|
|
831
757
|
function createAnimationClip(descriptor) {
|
|
832
|
-
|
|
758
|
+
return new AnimationClipImpl(descriptor);
|
|
833
759
|
}
|
|
834
|
-
|
|
835
|
-
|
|
760
|
+
export {
|
|
761
|
+
AnimationStateMachine,
|
|
762
|
+
AnimatorController,
|
|
763
|
+
createAnimationClip,
|
|
764
|
+
createAnimatorController
|
|
765
|
+
};
|