@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,1501 +1,1504 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file ParticleSystem2.ts
|
|
3
|
-
* @description Advanced Particle System with GPU Compute and Visual Editor
|
|
4
|
-
* PRO-1.4: Professional Editor Features
|
|
5
|
-
*
|
|
6
|
-
* Features:
|
|
7
|
-
* - GPU-accelerated particles (WebGPU Compute)
|
|
8
|
-
* - Multiple emitter shapes
|
|
9
|
-
* - Force fields (gravity, wind, vortex, etc.)
|
|
10
|
-
* - Sub-emitters and trails
|
|
11
|
-
* - Collision detection
|
|
12
|
-
* - LOD system
|
|
13
|
-
* - Visual editor integration
|
|
14
|
-
*/
|
|
15
|
-
// ============================================================
|
|
16
|
-
// Particle System Class
|
|
17
|
-
// ============================================================
|
|
18
1
|
class ParticleSystem2 {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
particles,
|
|
32
|
-
activeCount: 0,
|
|
33
|
-
time: 0,
|
|
34
|
-
isPlaying: false,
|
|
35
|
-
isPaused: false,
|
|
36
|
-
isStopped: true,
|
|
37
|
-
isEmitting: false,
|
|
38
|
-
randomSeed: (Math.random() * 0xffffffff) | 0,
|
|
39
|
-
emitCounter: 0,
|
|
40
|
-
distanceTraveled: 0,
|
|
41
|
-
lastPosition: new Float32Array([0, 0, 0]),
|
|
42
|
-
burstStates: this.definition.emission.bursts.map((b, i) => ({
|
|
43
|
-
burstIndex: i,
|
|
44
|
-
cycleCount: 0,
|
|
45
|
-
nextTime: b.time,
|
|
46
|
-
})),
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
createDeadParticle() {
|
|
50
|
-
return {
|
|
51
|
-
position: new Float32Array([0, 0, 0]),
|
|
52
|
-
velocity: new Float32Array([0, 0, 0]),
|
|
53
|
-
startColor: new Float32Array([1, 1, 1, 1]),
|
|
54
|
-
color: new Float32Array([1, 1, 1, 1]),
|
|
55
|
-
startSize: new Float32Array([1, 1, 1]),
|
|
56
|
-
size: new Float32Array([1, 1, 1]),
|
|
57
|
-
rotation: new Float32Array([0, 0, 0]),
|
|
58
|
-
angularVelocity: new Float32Array([0, 0, 0]),
|
|
59
|
-
startLifetime: 0,
|
|
60
|
-
remainingLifetime: -1,
|
|
61
|
-
normalizedLifetime: 1,
|
|
62
|
-
randomSeed: (Math.random() * 0xffffffff) | 0,
|
|
63
|
-
startSpeed: 0,
|
|
64
|
-
axisOfRotation: new Float32Array([0, 0, 1]),
|
|
65
|
-
meshIndex: 0,
|
|
66
|
-
customData1: new Float32Array([0, 0, 0, 0]),
|
|
67
|
-
customData2: new Float32Array([0, 0, 0, 0]),
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
// ─── Playback Control ──────────────────────────────────
|
|
71
|
-
play() {
|
|
72
|
-
if (this.state.isPaused) {
|
|
73
|
-
this.state.isPaused = false;
|
|
74
|
-
}
|
|
75
|
-
this.state.isPlaying = true;
|
|
76
|
-
this.state.isStopped = false;
|
|
77
|
-
this.state.isEmitting = true;
|
|
78
|
-
if (this.definition.main.prewarm) {
|
|
79
|
-
this.prewarm();
|
|
80
|
-
}
|
|
2
|
+
constructor(def) {
|
|
3
|
+
this.useGPU = false;
|
|
4
|
+
this.definition = def;
|
|
5
|
+
this.state = this.createInitialState();
|
|
6
|
+
}
|
|
7
|
+
createInitialState() {
|
|
8
|
+
const maxParticles = this.definition.main.maxParticles;
|
|
9
|
+
const particles = [];
|
|
10
|
+
for (let i = 0; i < maxParticles; i++) {
|
|
11
|
+
particles.push(this.createDeadParticle());
|
|
81
12
|
}
|
|
82
|
-
|
|
83
|
-
|
|
13
|
+
return {
|
|
14
|
+
particles,
|
|
15
|
+
activeCount: 0,
|
|
16
|
+
time: 0,
|
|
17
|
+
isPlaying: false,
|
|
18
|
+
isPaused: false,
|
|
19
|
+
isStopped: true,
|
|
20
|
+
isEmitting: false,
|
|
21
|
+
randomSeed: Math.random() * 4294967295 | 0,
|
|
22
|
+
emitCounter: 0,
|
|
23
|
+
distanceTraveled: 0,
|
|
24
|
+
lastPosition: new Float32Array([0, 0, 0]),
|
|
25
|
+
burstStates: this.definition.emission.bursts.map((b, i) => ({
|
|
26
|
+
burstIndex: i,
|
|
27
|
+
cycleCount: 0,
|
|
28
|
+
nextTime: b.time
|
|
29
|
+
}))
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
createDeadParticle() {
|
|
33
|
+
return {
|
|
34
|
+
position: new Float32Array([0, 0, 0]),
|
|
35
|
+
velocity: new Float32Array([0, 0, 0]),
|
|
36
|
+
startColor: new Float32Array([1, 1, 1, 1]),
|
|
37
|
+
color: new Float32Array([1, 1, 1, 1]),
|
|
38
|
+
startSize: new Float32Array([1, 1, 1]),
|
|
39
|
+
size: new Float32Array([1, 1, 1]),
|
|
40
|
+
rotation: new Float32Array([0, 0, 0]),
|
|
41
|
+
angularVelocity: new Float32Array([0, 0, 0]),
|
|
42
|
+
startLifetime: 0,
|
|
43
|
+
remainingLifetime: -1,
|
|
44
|
+
normalizedLifetime: 1,
|
|
45
|
+
randomSeed: Math.random() * 4294967295 | 0,
|
|
46
|
+
startSpeed: 0,
|
|
47
|
+
axisOfRotation: new Float32Array([0, 0, 1]),
|
|
48
|
+
meshIndex: 0,
|
|
49
|
+
customData1: new Float32Array([0, 0, 0, 0]),
|
|
50
|
+
customData2: new Float32Array([0, 0, 0, 0])
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// ─── Playback Control ──────────────────────────────────
|
|
54
|
+
play() {
|
|
55
|
+
if (this.state.isPaused) {
|
|
56
|
+
this.state.isPaused = false;
|
|
84
57
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
this.clear();
|
|
91
|
-
}
|
|
58
|
+
this.state.isPlaying = true;
|
|
59
|
+
this.state.isStopped = false;
|
|
60
|
+
this.state.isEmitting = true;
|
|
61
|
+
if (this.definition.main.prewarm) {
|
|
62
|
+
this.prewarm();
|
|
92
63
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
resetBurstStates() {
|
|
104
|
-
this.state.burstStates = this.definition.emission.bursts.map((b, i) => ({
|
|
105
|
-
burstIndex: i,
|
|
106
|
-
cycleCount: 0,
|
|
107
|
-
nextTime: b.time,
|
|
108
|
-
}));
|
|
109
|
-
}
|
|
110
|
-
prewarm() {
|
|
111
|
-
const duration = this.definition.main.duration;
|
|
112
|
-
const dt = 1 / 60;
|
|
113
|
-
const steps = Math.ceil(duration / dt);
|
|
114
|
-
for (let i = 0; i < steps; i++) {
|
|
115
|
-
this.simulate(dt);
|
|
116
|
-
}
|
|
64
|
+
}
|
|
65
|
+
pause() {
|
|
66
|
+
this.state.isPaused = true;
|
|
67
|
+
}
|
|
68
|
+
stop(clear = true) {
|
|
69
|
+
this.state.isPlaying = false;
|
|
70
|
+
this.state.isStopped = true;
|
|
71
|
+
this.state.isEmitting = false;
|
|
72
|
+
if (clear) {
|
|
73
|
+
this.clear();
|
|
117
74
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
75
|
+
}
|
|
76
|
+
clear() {
|
|
77
|
+
this.state.activeCount = 0;
|
|
78
|
+
this.state.time = 0;
|
|
79
|
+
this.state.emitCounter = 0;
|
|
80
|
+
this.state.distanceTraveled = 0;
|
|
81
|
+
for (const particle of this.state.particles) {
|
|
82
|
+
particle.remainingLifetime = -1;
|
|
123
83
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
particle.startLifetime = this.evaluateMinMaxCurve(main.startLifetime, 0, particle.randomSeed);
|
|
163
|
-
particle.remainingLifetime = particle.startLifetime;
|
|
164
|
-
particle.normalizedLifetime = 0;
|
|
165
|
-
// Size
|
|
166
|
-
if (main.startSize3D) {
|
|
167
|
-
particle.startSize[0] = this.evaluateMinMaxCurve(main.startSizeX, 0, particle.randomSeed);
|
|
168
|
-
particle.startSize[1] = this.evaluateMinMaxCurve(main.startSizeY, 0, particle.randomSeed);
|
|
169
|
-
particle.startSize[2] = this.evaluateMinMaxCurve(main.startSizeZ, 0, particle.randomSeed);
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
const size = this.evaluateMinMaxCurve(main.startSize, 0, particle.randomSeed);
|
|
173
|
-
particle.startSize.set([size, size, size]);
|
|
174
|
-
}
|
|
175
|
-
particle.size.set(particle.startSize);
|
|
176
|
-
// Rotation
|
|
177
|
-
if (main.startRotation3D) {
|
|
178
|
-
particle.rotation[0] = this.evaluateMinMaxCurve(main.startRotationX, 0, particle.randomSeed);
|
|
179
|
-
particle.rotation[1] = this.evaluateMinMaxCurve(main.startRotationY, 0, particle.randomSeed);
|
|
180
|
-
particle.rotation[2] = this.evaluateMinMaxCurve(main.startRotationZ, 0, particle.randomSeed);
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
particle.rotation[2] = this.evaluateMinMaxCurve(main.startRotation, 0, particle.randomSeed);
|
|
184
|
-
}
|
|
185
|
-
// Flip rotation
|
|
186
|
-
if (main.flipRotation > 0 && Math.random() < main.flipRotation) {
|
|
187
|
-
particle.rotation[2] += Math.PI;
|
|
188
|
-
}
|
|
189
|
-
// Color
|
|
190
|
-
const color = this.evaluateMinMaxGradient(main.startColor, 0, particle.randomSeed);
|
|
191
|
-
particle.startColor.set(color);
|
|
192
|
-
particle.color.set(color);
|
|
193
|
-
// Angular velocity (will be set by rotationOverLifetime)
|
|
194
|
-
particle.angularVelocity.set([0, 0, 0]);
|
|
195
|
-
}
|
|
196
|
-
sampleEmitterShape() {
|
|
197
|
-
const shape = this.definition.shape;
|
|
198
|
-
switch (shape.type) {
|
|
199
|
-
case 'sphere':
|
|
200
|
-
return this.sampleSphere(shape);
|
|
201
|
-
case 'hemisphere':
|
|
202
|
-
return this.sampleHemisphere(shape);
|
|
203
|
-
case 'cone':
|
|
204
|
-
return this.sampleCone(shape);
|
|
205
|
-
case 'box':
|
|
206
|
-
return this.sampleBox(shape);
|
|
207
|
-
case 'circle':
|
|
208
|
-
return this.sampleCircle(shape);
|
|
209
|
-
default:
|
|
210
|
-
return { position: [0, 0, 0], velocity: [0, 1, 0] };
|
|
211
|
-
}
|
|
84
|
+
this.resetBurstStates();
|
|
85
|
+
}
|
|
86
|
+
resetBurstStates() {
|
|
87
|
+
this.state.burstStates = this.definition.emission.bursts.map((b, i) => ({
|
|
88
|
+
burstIndex: i,
|
|
89
|
+
cycleCount: 0,
|
|
90
|
+
nextTime: b.time
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
prewarm() {
|
|
94
|
+
const duration = this.definition.main.duration;
|
|
95
|
+
const dt = 1 / 60;
|
|
96
|
+
const steps = Math.ceil(duration / dt);
|
|
97
|
+
for (let i = 0; i < steps; i++) {
|
|
98
|
+
this.simulate(dt);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// ─── Emission ──────────────────────────────────────────
|
|
102
|
+
emit(count, position) {
|
|
103
|
+
for (let i = 0; i < count; i++) {
|
|
104
|
+
this.emitSingleParticle(position);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
emitSingleParticle(overridePosition) {
|
|
108
|
+
const deadIndex = this.findDeadParticleIndex();
|
|
109
|
+
if (deadIndex === -1) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
const particle = this.state.particles[deadIndex];
|
|
113
|
+
this.initializeParticle(particle, overridePosition);
|
|
114
|
+
this.state.activeCount++;
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
findDeadParticleIndex() {
|
|
118
|
+
for (let i = 0; i < this.state.particles.length; i++) {
|
|
119
|
+
if (this.state.particles[i].remainingLifetime < 0) {
|
|
120
|
+
return i;
|
|
121
|
+
}
|
|
212
122
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
123
|
+
return -1;
|
|
124
|
+
}
|
|
125
|
+
initializeParticle(particle, overridePosition) {
|
|
126
|
+
const main = this.definition.main;
|
|
127
|
+
particle.randomSeed = Math.random() * 4294967295 | 0;
|
|
128
|
+
const { position, velocity } = this.sampleEmitterShape();
|
|
129
|
+
if (overridePosition) {
|
|
130
|
+
particle.position.set(overridePosition);
|
|
131
|
+
} else {
|
|
132
|
+
particle.position.set(position);
|
|
133
|
+
}
|
|
134
|
+
const startSpeed = this.evaluateMinMaxCurve(main.startSpeed, 0, particle.randomSeed);
|
|
135
|
+
particle.startSpeed = startSpeed;
|
|
136
|
+
particle.velocity[0] = velocity[0] * startSpeed;
|
|
137
|
+
particle.velocity[1] = velocity[1] * startSpeed;
|
|
138
|
+
particle.velocity[2] = velocity[2] * startSpeed;
|
|
139
|
+
particle.startLifetime = this.evaluateMinMaxCurve(main.startLifetime, 0, particle.randomSeed);
|
|
140
|
+
particle.remainingLifetime = particle.startLifetime;
|
|
141
|
+
particle.normalizedLifetime = 0;
|
|
142
|
+
if (main.startSize3D) {
|
|
143
|
+
particle.startSize[0] = this.evaluateMinMaxCurve(main.startSizeX, 0, particle.randomSeed);
|
|
144
|
+
particle.startSize[1] = this.evaluateMinMaxCurve(main.startSizeY, 0, particle.randomSeed);
|
|
145
|
+
particle.startSize[2] = this.evaluateMinMaxCurve(main.startSizeZ, 0, particle.randomSeed);
|
|
146
|
+
} else {
|
|
147
|
+
const size = this.evaluateMinMaxCurve(main.startSize, 0, particle.randomSeed);
|
|
148
|
+
particle.startSize.set([size, size, size]);
|
|
149
|
+
}
|
|
150
|
+
particle.size.set(particle.startSize);
|
|
151
|
+
if (main.startRotation3D) {
|
|
152
|
+
particle.rotation[0] = this.evaluateMinMaxCurve(main.startRotationX, 0, particle.randomSeed);
|
|
153
|
+
particle.rotation[1] = this.evaluateMinMaxCurve(main.startRotationY, 0, particle.randomSeed);
|
|
154
|
+
particle.rotation[2] = this.evaluateMinMaxCurve(main.startRotationZ, 0, particle.randomSeed);
|
|
155
|
+
} else {
|
|
156
|
+
particle.rotation[2] = this.evaluateMinMaxCurve(main.startRotation, 0, particle.randomSeed);
|
|
157
|
+
}
|
|
158
|
+
if (main.flipRotation > 0 && Math.random() < main.flipRotation) {
|
|
159
|
+
particle.rotation[2] += Math.PI;
|
|
160
|
+
}
|
|
161
|
+
const color = this.evaluateMinMaxGradient(main.startColor, 0, particle.randomSeed);
|
|
162
|
+
particle.startColor.set(color);
|
|
163
|
+
particle.color.set(color);
|
|
164
|
+
particle.angularVelocity.set([0, 0, 0]);
|
|
165
|
+
}
|
|
166
|
+
sampleEmitterShape() {
|
|
167
|
+
const shape = this.definition.shape;
|
|
168
|
+
switch (shape.type) {
|
|
169
|
+
case "sphere":
|
|
170
|
+
return this.sampleSphere(shape);
|
|
171
|
+
case "hemisphere":
|
|
172
|
+
return this.sampleHemisphere(shape);
|
|
173
|
+
case "cone":
|
|
174
|
+
return this.sampleCone(shape);
|
|
175
|
+
case "box":
|
|
176
|
+
return this.sampleBox(shape);
|
|
177
|
+
case "circle":
|
|
178
|
+
return this.sampleCircle(shape);
|
|
179
|
+
default:
|
|
180
|
+
return { position: [0, 0, 0], velocity: [0, 1, 0] };
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
sampleSphere(shape) {
|
|
184
|
+
const theta = Math.random() * 2 * Math.PI;
|
|
185
|
+
const phi = Math.acos(2 * Math.random() - 1);
|
|
186
|
+
const sinPhi = Math.sin(phi);
|
|
187
|
+
const dir = [sinPhi * Math.cos(theta), sinPhi * Math.sin(theta), Math.cos(phi)];
|
|
188
|
+
const radiusFactor = shape.radiusThickness === 1 ? Math.cbrt(Math.random()) : 1 - Math.random() * shape.radiusThickness;
|
|
189
|
+
const r = shape.radius * radiusFactor;
|
|
190
|
+
const position = [
|
|
191
|
+
dir[0] * r + shape.position[0],
|
|
192
|
+
dir[1] * r + shape.position[1],
|
|
193
|
+
dir[2] * r + shape.position[2]
|
|
194
|
+
];
|
|
195
|
+
return { position, velocity: dir };
|
|
196
|
+
}
|
|
197
|
+
sampleHemisphere(shape) {
|
|
198
|
+
const theta = Math.random() * 2 * Math.PI;
|
|
199
|
+
const phi = Math.acos(Math.random());
|
|
200
|
+
const sinPhi = Math.sin(phi);
|
|
201
|
+
const dir = [sinPhi * Math.cos(theta), Math.cos(phi), sinPhi * Math.sin(theta)];
|
|
202
|
+
const radiusFactor = shape.radiusThickness === 1 ? Math.cbrt(Math.random()) : 1 - Math.random() * shape.radiusThickness;
|
|
203
|
+
const r = shape.radius * radiusFactor;
|
|
204
|
+
const position = [
|
|
205
|
+
dir[0] * r + shape.position[0],
|
|
206
|
+
dir[1] * r + shape.position[1],
|
|
207
|
+
dir[2] * r + shape.position[2]
|
|
208
|
+
];
|
|
209
|
+
return { position, velocity: dir };
|
|
210
|
+
}
|
|
211
|
+
sampleCone(shape) {
|
|
212
|
+
const angleRad = shape.angle * Math.PI / 180;
|
|
213
|
+
const theta = Math.random() * 2 * Math.PI;
|
|
214
|
+
const coneAngle = Math.random() * angleRad;
|
|
215
|
+
const sinAngle = Math.sin(coneAngle);
|
|
216
|
+
const cosAngle = Math.cos(coneAngle);
|
|
217
|
+
const dir = [sinAngle * Math.cos(theta), cosAngle, sinAngle * Math.sin(theta)];
|
|
218
|
+
let position;
|
|
219
|
+
switch (shape.emitFrom) {
|
|
220
|
+
case "base": {
|
|
221
|
+
const r = shape.radius * Math.sqrt(Math.random());
|
|
222
|
+
position = [
|
|
223
|
+
r * Math.cos(theta) + shape.position[0],
|
|
224
|
+
shape.position[1],
|
|
225
|
+
r * Math.sin(theta) + shape.position[2]
|
|
228
226
|
];
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const
|
|
233
|
-
const
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
const r = shape.radius * radiusFactor;
|
|
240
|
-
const position = [
|
|
241
|
-
dir[0] * r + shape.position[0],
|
|
242
|
-
dir[1] * r + shape.position[1],
|
|
243
|
-
dir[2] * r + shape.position[2],
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
case "volume": {
|
|
230
|
+
const height = Math.random() * shape.length;
|
|
231
|
+
const radiusAtHeight = shape.radius + height * Math.tan(angleRad);
|
|
232
|
+
const rV = radiusAtHeight * Math.sqrt(Math.random());
|
|
233
|
+
position = [
|
|
234
|
+
rV * Math.cos(theta) + shape.position[0],
|
|
235
|
+
height + shape.position[1],
|
|
236
|
+
rV * Math.sin(theta) + shape.position[2]
|
|
244
237
|
];
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
r * Math.sin(theta) + shape.position[2],
|
|
264
|
-
];
|
|
265
|
-
break;
|
|
266
|
-
}
|
|
267
|
-
case 'volume': {
|
|
268
|
-
const height = Math.random() * shape.length;
|
|
269
|
-
const radiusAtHeight = shape.radius + height * Math.tan(angleRad);
|
|
270
|
-
const rV = radiusAtHeight * Math.sqrt(Math.random());
|
|
271
|
-
position = [
|
|
272
|
-
rV * Math.cos(theta) + shape.position[0],
|
|
273
|
-
height + shape.position[1],
|
|
274
|
-
rV * Math.sin(theta) + shape.position[2],
|
|
275
|
-
];
|
|
276
|
-
break;
|
|
277
|
-
}
|
|
278
|
-
default:
|
|
279
|
-
position = [...shape.position];
|
|
280
|
-
}
|
|
281
|
-
return { position, velocity: dir };
|
|
282
|
-
}
|
|
283
|
-
sampleBox(shape) {
|
|
284
|
-
const hw = shape.scale[0] / 2;
|
|
285
|
-
const hh = shape.scale[1] / 2;
|
|
286
|
-
const hd = shape.scale[2] / 2;
|
|
287
|
-
let position;
|
|
288
|
-
switch (shape.emitFrom) {
|
|
289
|
-
case 'volume':
|
|
290
|
-
position = [
|
|
291
|
-
(Math.random() * 2 - 1) * hw + shape.position[0],
|
|
292
|
-
(Math.random() * 2 - 1) * hh + shape.position[1],
|
|
293
|
-
(Math.random() * 2 - 1) * hd + shape.position[2],
|
|
294
|
-
];
|
|
295
|
-
break;
|
|
296
|
-
case 'shell': {
|
|
297
|
-
// Random face
|
|
298
|
-
const face = Math.floor(Math.random() * 6);
|
|
299
|
-
const u = Math.random() * 2 - 1;
|
|
300
|
-
const v = Math.random() * 2 - 1;
|
|
301
|
-
switch (face) {
|
|
302
|
-
case 0:
|
|
303
|
-
position = [hw, u * hh, v * hd];
|
|
304
|
-
break;
|
|
305
|
-
case 1:
|
|
306
|
-
position = [-hw, u * hh, v * hd];
|
|
307
|
-
break;
|
|
308
|
-
case 2:
|
|
309
|
-
position = [u * hw, hh, v * hd];
|
|
310
|
-
break;
|
|
311
|
-
case 3:
|
|
312
|
-
position = [u * hw, -hh, v * hd];
|
|
313
|
-
break;
|
|
314
|
-
case 4:
|
|
315
|
-
position = [u * hw, v * hh, hd];
|
|
316
|
-
break;
|
|
317
|
-
default:
|
|
318
|
-
position = [u * hw, v * hh, -hd];
|
|
319
|
-
break;
|
|
320
|
-
}
|
|
321
|
-
position[0] += shape.position[0];
|
|
322
|
-
position[1] += shape.position[1];
|
|
323
|
-
position[2] += shape.position[2];
|
|
324
|
-
break;
|
|
325
|
-
}
|
|
326
|
-
default:
|
|
327
|
-
position = [...shape.position];
|
|
328
|
-
}
|
|
329
|
-
return { position, velocity: [0, 1, 0] };
|
|
330
|
-
}
|
|
331
|
-
sampleCircle(shape) {
|
|
332
|
-
const theta = Math.random() * 2 * Math.PI;
|
|
333
|
-
const radiusFactor = shape.radiusThickness === 1
|
|
334
|
-
? Math.sqrt(Math.random())
|
|
335
|
-
: 1 - Math.random() * shape.radiusThickness;
|
|
336
|
-
const r = shape.radius * radiusFactor;
|
|
337
|
-
const position = [
|
|
338
|
-
r * Math.cos(theta) + shape.position[0],
|
|
339
|
-
shape.position[1],
|
|
340
|
-
r * Math.sin(theta) + shape.position[2],
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
default:
|
|
241
|
+
position = [...shape.position];
|
|
242
|
+
}
|
|
243
|
+
return { position, velocity: dir };
|
|
244
|
+
}
|
|
245
|
+
sampleBox(shape) {
|
|
246
|
+
const hw = shape.scale[0] / 2;
|
|
247
|
+
const hh = shape.scale[1] / 2;
|
|
248
|
+
const hd = shape.scale[2] / 2;
|
|
249
|
+
let position;
|
|
250
|
+
switch (shape.emitFrom) {
|
|
251
|
+
case "volume":
|
|
252
|
+
position = [
|
|
253
|
+
(Math.random() * 2 - 1) * hw + shape.position[0],
|
|
254
|
+
(Math.random() * 2 - 1) * hh + shape.position[1],
|
|
255
|
+
(Math.random() * 2 - 1) * hd + shape.position[2]
|
|
341
256
|
];
|
|
342
|
-
|
|
257
|
+
break;
|
|
258
|
+
case "shell": {
|
|
259
|
+
const face = Math.floor(Math.random() * 6);
|
|
260
|
+
const u = Math.random() * 2 - 1;
|
|
261
|
+
const v = Math.random() * 2 - 1;
|
|
262
|
+
switch (face) {
|
|
263
|
+
case 0:
|
|
264
|
+
position = [hw, u * hh, v * hd];
|
|
265
|
+
break;
|
|
266
|
+
case 1:
|
|
267
|
+
position = [-hw, u * hh, v * hd];
|
|
268
|
+
break;
|
|
269
|
+
case 2:
|
|
270
|
+
position = [u * hw, hh, v * hd];
|
|
271
|
+
break;
|
|
272
|
+
case 3:
|
|
273
|
+
position = [u * hw, -hh, v * hd];
|
|
274
|
+
break;
|
|
275
|
+
case 4:
|
|
276
|
+
position = [u * hw, v * hh, hd];
|
|
277
|
+
break;
|
|
278
|
+
default:
|
|
279
|
+
position = [u * hw, v * hh, -hd];
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
position[0] += shape.position[0];
|
|
283
|
+
position[1] += shape.position[1];
|
|
284
|
+
position[2] += shape.position[2];
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
default:
|
|
288
|
+
position = [...shape.position];
|
|
343
289
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
// Update particles
|
|
362
|
-
for (let i = 0; i < this.state.particles.length; i++) {
|
|
363
|
-
const particle = this.state.particles[i];
|
|
364
|
-
if (particle.remainingLifetime >= 0) {
|
|
365
|
-
this.updateParticle(particle, dt);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
290
|
+
return { position, velocity: [0, 1, 0] };
|
|
291
|
+
}
|
|
292
|
+
sampleCircle(shape) {
|
|
293
|
+
const theta = Math.random() * 2 * Math.PI;
|
|
294
|
+
const radiusFactor = shape.radiusThickness === 1 ? Math.sqrt(Math.random()) : 1 - Math.random() * shape.radiusThickness;
|
|
295
|
+
const r = shape.radius * radiusFactor;
|
|
296
|
+
const position = [
|
|
297
|
+
r * Math.cos(theta) + shape.position[0],
|
|
298
|
+
shape.position[1],
|
|
299
|
+
r * Math.sin(theta) + shape.position[2]
|
|
300
|
+
];
|
|
301
|
+
return { position, velocity: [0, 1, 0] };
|
|
302
|
+
}
|
|
303
|
+
// ─── Simulation ────────────────────────────────────────
|
|
304
|
+
simulate(deltaTime) {
|
|
305
|
+
if (!this.state.isPlaying || this.state.isPaused) {
|
|
306
|
+
return;
|
|
368
307
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
// Rate over time
|
|
375
|
-
const rateOverTime = this.evaluateMinMaxCurve(emission.rateOverTime, this.normalizedTime(), 0);
|
|
376
|
-
this.state.emitCounter += rateOverTime * dt;
|
|
377
|
-
while (this.state.emitCounter >= 1) {
|
|
378
|
-
this.emitSingleParticle();
|
|
379
|
-
this.state.emitCounter -= 1;
|
|
380
|
-
}
|
|
381
|
-
// Bursts
|
|
382
|
-
for (const burstState of this.state.burstStates) {
|
|
383
|
-
const burst = emission.bursts[burstState.burstIndex];
|
|
384
|
-
while (this.state.time >= burstState.nextTime && burstState.cycleCount < burst.cycles) {
|
|
385
|
-
// Probability check
|
|
386
|
-
if (Math.random() < burst.probability) {
|
|
387
|
-
const count = Math.round(this.evaluateMinMaxCurve(burst.count, 0, (Math.random() * 0xffffffff) | 0));
|
|
388
|
-
this.emit(count);
|
|
389
|
-
}
|
|
390
|
-
burstState.cycleCount++;
|
|
391
|
-
burstState.nextTime += burst.interval;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
308
|
+
const dt = deltaTime * this.definition.main.simulationSpeed;
|
|
309
|
+
this.state.time += dt;
|
|
310
|
+
if (this.definition.main.looping && this.state.time >= this.definition.main.duration) {
|
|
311
|
+
this.state.time = this.state.time % this.definition.main.duration;
|
|
312
|
+
this.resetBurstStates();
|
|
394
313
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
particle.remainingLifetime -= dt;
|
|
398
|
-
if (particle.remainingLifetime < 0) {
|
|
399
|
-
// Particle died
|
|
400
|
-
this.state.activeCount--;
|
|
401
|
-
// Trigger sub-emitter death
|
|
402
|
-
this.triggerSubEmitters('death', particle);
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
particle.normalizedLifetime = 1 - particle.remainingLifetime / particle.startLifetime;
|
|
406
|
-
// Apply forces
|
|
407
|
-
this.applyForces(particle, dt);
|
|
408
|
-
// Apply velocity/force over lifetime modules
|
|
409
|
-
this.applyVelocityOverLifetime(particle, dt);
|
|
410
|
-
this.applyForceOverLifetime(particle, dt);
|
|
411
|
-
this.applyLimitVelocityOverLifetime(particle, dt);
|
|
412
|
-
// Integrate position
|
|
413
|
-
particle.position[0] += particle.velocity[0] * dt;
|
|
414
|
-
particle.position[1] += particle.velocity[1] * dt;
|
|
415
|
-
particle.position[2] += particle.velocity[2] * dt;
|
|
416
|
-
// Apply noise
|
|
417
|
-
this.applyNoise(particle, dt);
|
|
418
|
-
// Update visual properties
|
|
419
|
-
this.applyColorOverLifetime(particle);
|
|
420
|
-
this.applySizeOverLifetime(particle);
|
|
421
|
-
this.applyRotationOverLifetime(particle, dt);
|
|
422
|
-
// Speed-based modifications
|
|
423
|
-
this.applyColorBySpeed(particle);
|
|
424
|
-
this.applySizeBySpeed(particle);
|
|
425
|
-
this.applyRotationBySpeed(particle, dt);
|
|
426
|
-
// Handle collision
|
|
427
|
-
if (this.definition.collision.enabled) {
|
|
428
|
-
this.handleCollision(particle);
|
|
429
|
-
}
|
|
314
|
+
if (this.state.isEmitting) {
|
|
315
|
+
this.processEmission(dt);
|
|
430
316
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
// External force fields
|
|
437
|
-
if (this.definition.externalForces.enabled) {
|
|
438
|
-
for (const field of this.definition.externalForces.forceFields) {
|
|
439
|
-
this.applyForceField(particle, field, dt);
|
|
440
|
-
}
|
|
441
|
-
}
|
|
317
|
+
for (let i = 0; i < this.state.particles.length; i++) {
|
|
318
|
+
const particle = this.state.particles[i];
|
|
319
|
+
if (particle.remainingLifetime >= 0) {
|
|
320
|
+
this.updateParticle(particle, dt);
|
|
321
|
+
}
|
|
442
322
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
particle.velocity[1] += field.direction[1] * strength * dt;
|
|
449
|
-
particle.velocity[2] += field.direction[2] * strength * dt;
|
|
450
|
-
break;
|
|
451
|
-
}
|
|
452
|
-
case 'directional': {
|
|
453
|
-
const dirStrength = this.evaluateMinMaxCurve(field.strength, particle.normalizedLifetime, particle.randomSeed);
|
|
454
|
-
particle.velocity[0] += field.direction[0] * dirStrength * dt;
|
|
455
|
-
particle.velocity[1] += field.direction[1] * dirStrength * dt;
|
|
456
|
-
particle.velocity[2] += field.direction[2] * dirStrength * dt;
|
|
457
|
-
break;
|
|
458
|
-
}
|
|
459
|
-
case 'vortex': {
|
|
460
|
-
const vortexStrength = this.evaluateMinMaxCurve(field.strength, particle.normalizedLifetime, particle.randomSeed);
|
|
461
|
-
const toCenter = [
|
|
462
|
-
field.center[0] - particle.position[0],
|
|
463
|
-
field.center[1] - particle.position[1],
|
|
464
|
-
field.center[2] - particle.position[2],
|
|
465
|
-
];
|
|
466
|
-
const dist = Math.sqrt(toCenter[0] ** 2 + toCenter[1] ** 2 + toCenter[2] ** 2);
|
|
467
|
-
if (dist > 0.001 && dist < field.radius) {
|
|
468
|
-
// Tangential force (cross product with axis)
|
|
469
|
-
const tangent = [
|
|
470
|
-
field.axis[1] * toCenter[2] - field.axis[2] * toCenter[1],
|
|
471
|
-
field.axis[2] * toCenter[0] - field.axis[0] * toCenter[2],
|
|
472
|
-
field.axis[0] * toCenter[1] - field.axis[1] * toCenter[0],
|
|
473
|
-
];
|
|
474
|
-
const tangentLen = Math.sqrt(tangent[0] ** 2 + tangent[1] ** 2 + tangent[2] ** 2);
|
|
475
|
-
if (tangentLen > 0.001) {
|
|
476
|
-
const factor = (vortexStrength * (1 - dist / field.radius)) / tangentLen;
|
|
477
|
-
particle.velocity[0] += tangent[0] * factor * dt;
|
|
478
|
-
particle.velocity[1] += tangent[1] * factor * dt;
|
|
479
|
-
particle.velocity[2] += tangent[2] * factor * dt;
|
|
480
|
-
}
|
|
481
|
-
// Attraction
|
|
482
|
-
if (field.attractionStrength > 0) {
|
|
483
|
-
const attractFactor = (field.attractionStrength * (1 - dist / field.radius)) / dist;
|
|
484
|
-
particle.velocity[0] += toCenter[0] * attractFactor * dt;
|
|
485
|
-
particle.velocity[1] += toCenter[1] * attractFactor * dt;
|
|
486
|
-
particle.velocity[2] += toCenter[2] * attractFactor * dt;
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
break;
|
|
490
|
-
}
|
|
491
|
-
case 'drag': {
|
|
492
|
-
const dragCoeff = this.evaluateMinMaxCurve(field.coefficient, particle.normalizedLifetime, particle.randomSeed);
|
|
493
|
-
let drag = dragCoeff;
|
|
494
|
-
if (field.multiplyBySize) {
|
|
495
|
-
const sizeMag = Math.sqrt(particle.size[0] ** 2 + particle.size[1] ** 2 + particle.size[2] ** 2);
|
|
496
|
-
drag *= sizeMag;
|
|
497
|
-
}
|
|
498
|
-
if (field.multiplyByVelocity) {
|
|
499
|
-
const velMag = Math.sqrt(particle.velocity[0] ** 2 + particle.velocity[1] ** 2 + particle.velocity[2] ** 2);
|
|
500
|
-
drag *= velMag;
|
|
501
|
-
}
|
|
502
|
-
const factor = Math.max(0, 1 - drag * dt);
|
|
503
|
-
particle.velocity[0] *= factor;
|
|
504
|
-
particle.velocity[1] *= factor;
|
|
505
|
-
particle.velocity[2] *= factor;
|
|
506
|
-
break;
|
|
507
|
-
}
|
|
508
|
-
case 'attractor': {
|
|
509
|
-
const attractorStrength = this.evaluateMinMaxCurve(field.strength, particle.normalizedLifetime, particle.randomSeed);
|
|
510
|
-
const toAttractor = [
|
|
511
|
-
field.position[0] - particle.position[0],
|
|
512
|
-
field.position[1] - particle.position[1],
|
|
513
|
-
field.position[2] - particle.position[2],
|
|
514
|
-
];
|
|
515
|
-
const attractorDist = Math.sqrt(toAttractor[0] ** 2 + toAttractor[1] ** 2 + toAttractor[2] ** 2);
|
|
516
|
-
if (attractorDist > 0.001 && attractorDist < field.radius) {
|
|
517
|
-
const falloff = 1 - attractorDist / field.radius;
|
|
518
|
-
const force = (attractorStrength * falloff) / attractorDist;
|
|
519
|
-
particle.velocity[0] += toAttractor[0] * force * dt;
|
|
520
|
-
particle.velocity[1] += toAttractor[1] * force * dt;
|
|
521
|
-
particle.velocity[2] += toAttractor[2] * force * dt;
|
|
522
|
-
if (field.killOnArrive && attractorDist < 0.1) {
|
|
523
|
-
particle.remainingLifetime = -1;
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
break;
|
|
527
|
-
}
|
|
528
|
-
}
|
|
323
|
+
}
|
|
324
|
+
processEmission(dt) {
|
|
325
|
+
const emission = this.definition.emission;
|
|
326
|
+
if (!emission.enabled) {
|
|
327
|
+
return;
|
|
529
328
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
// Linear velocity
|
|
536
|
-
if (vol.linear.mode !== 'constant' ||
|
|
537
|
-
vol.linear.value[0] !== 0 ||
|
|
538
|
-
vol.linear.value[1] !== 0 ||
|
|
539
|
-
vol.linear.value[2] !== 0) {
|
|
540
|
-
const linear = this.evaluateMinMaxVector3(vol.linear, particle.normalizedLifetime, particle.randomSeed);
|
|
541
|
-
particle.velocity[0] += linear[0] * dt;
|
|
542
|
-
particle.velocity[1] += linear[1] * dt;
|
|
543
|
-
particle.velocity[2] += linear[2] * dt;
|
|
544
|
-
}
|
|
545
|
-
// Radial velocity
|
|
546
|
-
const radial = this.evaluateMinMaxCurve(vol.radial, particle.normalizedLifetime, particle.randomSeed);
|
|
547
|
-
if (radial !== 0) {
|
|
548
|
-
const len = Math.sqrt(particle.position[0] ** 2 + particle.position[1] ** 2 + particle.position[2] ** 2);
|
|
549
|
-
if (len > 0.001) {
|
|
550
|
-
particle.velocity[0] += (particle.position[0] / len) * radial * dt;
|
|
551
|
-
particle.velocity[1] += (particle.position[1] / len) * radial * dt;
|
|
552
|
-
particle.velocity[2] += (particle.position[2] / len) * radial * dt;
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
// Speed modifier
|
|
556
|
-
const speedMod = this.evaluateMinMaxCurve(vol.speedModifier, particle.normalizedLifetime, particle.randomSeed);
|
|
557
|
-
particle.velocity[0] *= speedMod;
|
|
558
|
-
particle.velocity[1] *= speedMod;
|
|
559
|
-
particle.velocity[2] *= speedMod;
|
|
560
|
-
}
|
|
561
|
-
applyForceOverLifetime(particle, dt) {
|
|
562
|
-
const fol = this.definition.forceOverLifetime;
|
|
563
|
-
if (!fol.enabled) {
|
|
564
|
-
return;
|
|
565
|
-
}
|
|
566
|
-
const seed = fol.randomize ? (Math.random() * 0xffffffff) | 0 : particle.randomSeed;
|
|
567
|
-
particle.velocity[0] += this.evaluateMinMaxCurve(fol.x, particle.normalizedLifetime, seed) * dt;
|
|
568
|
-
particle.velocity[1] += this.evaluateMinMaxCurve(fol.y, particle.normalizedLifetime, seed) * dt;
|
|
569
|
-
particle.velocity[2] += this.evaluateMinMaxCurve(fol.z, particle.normalizedLifetime, seed) * dt;
|
|
570
|
-
}
|
|
571
|
-
applyLimitVelocityOverLifetime(particle, dt) {
|
|
572
|
-
const lvol = this.definition.limitVelocityOverLifetime;
|
|
573
|
-
if (!lvol.enabled) {
|
|
574
|
-
return;
|
|
575
|
-
}
|
|
576
|
-
const velMag = Math.sqrt(particle.velocity[0] ** 2 + particle.velocity[1] ** 2 + particle.velocity[2] ** 2);
|
|
577
|
-
let maxSpeed;
|
|
578
|
-
if (lvol.separateAxes) {
|
|
579
|
-
// Per-axis limit (simplified)
|
|
580
|
-
maxSpeed = this.evaluateMinMaxCurve(lvol.speed, particle.normalizedLifetime, particle.randomSeed);
|
|
581
|
-
}
|
|
582
|
-
else {
|
|
583
|
-
maxSpeed = this.evaluateMinMaxCurve(lvol.speed, particle.normalizedLifetime, particle.randomSeed);
|
|
584
|
-
}
|
|
585
|
-
if (velMag > maxSpeed) {
|
|
586
|
-
const dampenFactor = 1 - lvol.dampen;
|
|
587
|
-
const targetSpeed = maxSpeed + (velMag - maxSpeed) * dampenFactor;
|
|
588
|
-
const scale = targetSpeed / velMag;
|
|
589
|
-
particle.velocity[0] *= scale;
|
|
590
|
-
particle.velocity[1] *= scale;
|
|
591
|
-
particle.velocity[2] *= scale;
|
|
592
|
-
}
|
|
593
|
-
// Drag
|
|
594
|
-
const drag = this.evaluateMinMaxCurve(lvol.drag, particle.normalizedLifetime, particle.randomSeed);
|
|
595
|
-
if (drag > 0) {
|
|
596
|
-
const dragFactor = Math.max(0, 1 - drag * dt);
|
|
597
|
-
particle.velocity[0] *= dragFactor;
|
|
598
|
-
particle.velocity[1] *= dragFactor;
|
|
599
|
-
particle.velocity[2] *= dragFactor;
|
|
600
|
-
}
|
|
329
|
+
const rateOverTime = this.evaluateMinMaxCurve(emission.rateOverTime, this.normalizedTime(), 0);
|
|
330
|
+
this.state.emitCounter += rateOverTime * dt;
|
|
331
|
+
while (this.state.emitCounter >= 1) {
|
|
332
|
+
this.emitSingleParticle();
|
|
333
|
+
this.state.emitCounter -= 1;
|
|
601
334
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
// Pseudo-noise
|
|
615
|
-
const noiseX = (Math.sin(nx * 12.9898 + ny * 78.233) * 43758.5453) % 1;
|
|
616
|
-
const noiseY = (Math.sin(ny * 12.9898 + nz * 78.233) * 43758.5453) % 1;
|
|
617
|
-
const noiseZ = (Math.sin(nz * 12.9898 + nx * 78.233) * 43758.5453) % 1;
|
|
618
|
-
const posAmount = this.evaluateMinMaxCurve(noise.positionAmount, particle.normalizedLifetime, particle.randomSeed);
|
|
619
|
-
particle.position[0] += (noiseX * 2 - 1) * strength * posAmount * dt;
|
|
620
|
-
particle.position[1] += (noiseY * 2 - 1) * strength * posAmount * dt;
|
|
621
|
-
particle.position[2] += (noiseZ * 2 - 1) * strength * posAmount * dt;
|
|
622
|
-
}
|
|
623
|
-
applyColorOverLifetime(particle) {
|
|
624
|
-
const col = this.definition.colorOverLifetime;
|
|
625
|
-
if (!col.enabled) {
|
|
626
|
-
return;
|
|
627
|
-
}
|
|
628
|
-
const color = this.evaluateMinMaxGradient(col.color, particle.normalizedLifetime, particle.randomSeed);
|
|
629
|
-
// Multiply with start color
|
|
630
|
-
particle.color[0] = particle.startColor[0] * color[0];
|
|
631
|
-
particle.color[1] = particle.startColor[1] * color[1];
|
|
632
|
-
particle.color[2] = particle.startColor[2] * color[2];
|
|
633
|
-
particle.color[3] = particle.startColor[3] * color[3];
|
|
634
|
-
}
|
|
635
|
-
applySizeOverLifetime(particle) {
|
|
636
|
-
const sol = this.definition.sizeOverLifetime;
|
|
637
|
-
if (!sol.enabled) {
|
|
638
|
-
return;
|
|
639
|
-
}
|
|
640
|
-
if (sol.separateAxes) {
|
|
641
|
-
particle.size[0] =
|
|
642
|
-
particle.startSize[0] *
|
|
643
|
-
this.evaluateMinMaxCurve(sol.sizeX, particle.normalizedLifetime, particle.randomSeed);
|
|
644
|
-
particle.size[1] =
|
|
645
|
-
particle.startSize[1] *
|
|
646
|
-
this.evaluateMinMaxCurve(sol.sizeY, particle.normalizedLifetime, particle.randomSeed);
|
|
647
|
-
particle.size[2] =
|
|
648
|
-
particle.startSize[2] *
|
|
649
|
-
this.evaluateMinMaxCurve(sol.sizeZ, particle.normalizedLifetime, particle.randomSeed);
|
|
650
|
-
}
|
|
651
|
-
else {
|
|
652
|
-
const scale = this.evaluateMinMaxCurve(sol.size, particle.normalizedLifetime, particle.randomSeed);
|
|
653
|
-
particle.size[0] = particle.startSize[0] * scale;
|
|
654
|
-
particle.size[1] = particle.startSize[1] * scale;
|
|
655
|
-
particle.size[2] = particle.startSize[2] * scale;
|
|
656
|
-
}
|
|
335
|
+
for (const burstState of this.state.burstStates) {
|
|
336
|
+
const burst = emission.bursts[burstState.burstIndex];
|
|
337
|
+
while (this.state.time >= burstState.nextTime && burstState.cycleCount < burst.cycles) {
|
|
338
|
+
if (Math.random() < burst.probability) {
|
|
339
|
+
const count = Math.round(
|
|
340
|
+
this.evaluateMinMaxCurve(burst.count, 0, Math.random() * 4294967295 | 0)
|
|
341
|
+
);
|
|
342
|
+
this.emit(count);
|
|
343
|
+
}
|
|
344
|
+
burstState.cycleCount++;
|
|
345
|
+
burstState.nextTime += burst.interval;
|
|
346
|
+
}
|
|
657
347
|
}
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
this.evaluateMinMaxCurve(rol.angularVelocityX, particle.normalizedLifetime, particle.randomSeed) * dt;
|
|
666
|
-
particle.rotation[1] +=
|
|
667
|
-
this.evaluateMinMaxCurve(rol.angularVelocityY, particle.normalizedLifetime, particle.randomSeed) * dt;
|
|
668
|
-
particle.rotation[2] +=
|
|
669
|
-
this.evaluateMinMaxCurve(rol.angularVelocityZ, particle.normalizedLifetime, particle.randomSeed) * dt;
|
|
670
|
-
}
|
|
671
|
-
else {
|
|
672
|
-
particle.rotation[2] +=
|
|
673
|
-
this.evaluateMinMaxCurve(rol.angularVelocity, particle.normalizedLifetime, particle.randomSeed) * dt;
|
|
674
|
-
}
|
|
348
|
+
}
|
|
349
|
+
updateParticle(particle, dt) {
|
|
350
|
+
particle.remainingLifetime -= dt;
|
|
351
|
+
if (particle.remainingLifetime < 0) {
|
|
352
|
+
this.state.activeCount--;
|
|
353
|
+
this.triggerSubEmitters("death", particle);
|
|
354
|
+
return;
|
|
675
355
|
}
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
applySizeBySpeed(particle)
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
}
|
|
694
|
-
const speed = Math.sqrt(particle.velocity[0] ** 2 + particle.velocity[1] ** 2 + particle.velocity[2] ** 2);
|
|
695
|
-
const t = Math.min(1, Math.max(0, (speed - sbs.speedRange[0]) / (sbs.speedRange[1] - sbs.speedRange[0])));
|
|
696
|
-
if (sbs.separateAxes) {
|
|
697
|
-
particle.size[0] *= this.evaluateMinMaxCurve(sbs.sizeX, t, particle.randomSeed);
|
|
698
|
-
particle.size[1] *= this.evaluateMinMaxCurve(sbs.sizeY, t, particle.randomSeed);
|
|
699
|
-
particle.size[2] *= this.evaluateMinMaxCurve(sbs.sizeZ, t, particle.randomSeed);
|
|
700
|
-
}
|
|
701
|
-
else {
|
|
702
|
-
const scale = this.evaluateMinMaxCurve(sbs.size, t, particle.randomSeed);
|
|
703
|
-
particle.size[0] *= scale;
|
|
704
|
-
particle.size[1] *= scale;
|
|
705
|
-
particle.size[2] *= scale;
|
|
706
|
-
}
|
|
356
|
+
particle.normalizedLifetime = 1 - particle.remainingLifetime / particle.startLifetime;
|
|
357
|
+
this.applyForces(particle, dt);
|
|
358
|
+
this.applyVelocityOverLifetime(particle, dt);
|
|
359
|
+
this.applyForceOverLifetime(particle, dt);
|
|
360
|
+
this.applyLimitVelocityOverLifetime(particle, dt);
|
|
361
|
+
particle.position[0] += particle.velocity[0] * dt;
|
|
362
|
+
particle.position[1] += particle.velocity[1] * dt;
|
|
363
|
+
particle.position[2] += particle.velocity[2] * dt;
|
|
364
|
+
this.applyNoise(particle, dt);
|
|
365
|
+
this.applyColorOverLifetime(particle);
|
|
366
|
+
this.applySizeOverLifetime(particle);
|
|
367
|
+
this.applyRotationOverLifetime(particle, dt);
|
|
368
|
+
this.applyColorBySpeed(particle);
|
|
369
|
+
this.applySizeBySpeed(particle);
|
|
370
|
+
this.applyRotationBySpeed(particle, dt);
|
|
371
|
+
if (this.definition.collision.enabled) {
|
|
372
|
+
this.handleCollision(particle);
|
|
707
373
|
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
this.evaluateMinMaxCurve(rbs.angularVelocityZ, t, particle.randomSeed) * dt;
|
|
722
|
-
}
|
|
723
|
-
else {
|
|
724
|
-
particle.rotation[2] +=
|
|
725
|
-
this.evaluateMinMaxCurve(rbs.angularVelocity, t, particle.randomSeed) * dt;
|
|
726
|
-
}
|
|
374
|
+
}
|
|
375
|
+
applyForces(particle, dt) {
|
|
376
|
+
const main = this.definition.main;
|
|
377
|
+
const gravity = this.evaluateMinMaxCurve(
|
|
378
|
+
main.gravityModifier,
|
|
379
|
+
particle.normalizedLifetime,
|
|
380
|
+
particle.randomSeed
|
|
381
|
+
);
|
|
382
|
+
particle.velocity[1] -= 9.81 * gravity * dt;
|
|
383
|
+
if (this.definition.externalForces.enabled) {
|
|
384
|
+
for (const field of this.definition.externalForces.forceFields) {
|
|
385
|
+
this.applyForceField(particle, field, dt);
|
|
386
|
+
}
|
|
727
387
|
}
|
|
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
|
-
|
|
388
|
+
}
|
|
389
|
+
applyForceField(particle, field, dt) {
|
|
390
|
+
switch (field.type) {
|
|
391
|
+
case "gravity": {
|
|
392
|
+
const strength = field.strength;
|
|
393
|
+
particle.velocity[0] += field.direction[0] * strength * dt;
|
|
394
|
+
particle.velocity[1] += field.direction[1] * strength * dt;
|
|
395
|
+
particle.velocity[2] += field.direction[2] * strength * dt;
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
case "directional": {
|
|
399
|
+
const dirStrength = this.evaluateMinMaxCurve(
|
|
400
|
+
field.strength,
|
|
401
|
+
particle.normalizedLifetime,
|
|
402
|
+
particle.randomSeed
|
|
403
|
+
);
|
|
404
|
+
particle.velocity[0] += field.direction[0] * dirStrength * dt;
|
|
405
|
+
particle.velocity[1] += field.direction[1] * dirStrength * dt;
|
|
406
|
+
particle.velocity[2] += field.direction[2] * dirStrength * dt;
|
|
407
|
+
break;
|
|
408
|
+
}
|
|
409
|
+
case "vortex": {
|
|
410
|
+
const vortexStrength = this.evaluateMinMaxCurve(
|
|
411
|
+
field.strength,
|
|
412
|
+
particle.normalizedLifetime,
|
|
413
|
+
particle.randomSeed
|
|
414
|
+
);
|
|
415
|
+
const toCenter = [
|
|
416
|
+
field.center[0] - particle.position[0],
|
|
417
|
+
field.center[1] - particle.position[1],
|
|
418
|
+
field.center[2] - particle.position[2]
|
|
419
|
+
];
|
|
420
|
+
const dist = Math.sqrt(toCenter[0] ** 2 + toCenter[1] ** 2 + toCenter[2] ** 2);
|
|
421
|
+
if (dist > 1e-3 && dist < field.radius) {
|
|
422
|
+
const tangent = [
|
|
423
|
+
field.axis[1] * toCenter[2] - field.axis[2] * toCenter[1],
|
|
424
|
+
field.axis[2] * toCenter[0] - field.axis[0] * toCenter[2],
|
|
425
|
+
field.axis[0] * toCenter[1] - field.axis[1] * toCenter[0]
|
|
426
|
+
];
|
|
427
|
+
const tangentLen = Math.sqrt(tangent[0] ** 2 + tangent[1] ** 2 + tangent[2] ** 2);
|
|
428
|
+
if (tangentLen > 1e-3) {
|
|
429
|
+
const factor = vortexStrength * (1 - dist / field.radius) / tangentLen;
|
|
430
|
+
particle.velocity[0] += tangent[0] * factor * dt;
|
|
431
|
+
particle.velocity[1] += tangent[1] * factor * dt;
|
|
432
|
+
particle.velocity[2] += tangent[2] * factor * dt;
|
|
433
|
+
}
|
|
434
|
+
if (field.attractionStrength > 0) {
|
|
435
|
+
const attractFactor = field.attractionStrength * (1 - dist / field.radius) / dist;
|
|
436
|
+
particle.velocity[0] += toCenter[0] * attractFactor * dt;
|
|
437
|
+
particle.velocity[1] += toCenter[1] * attractFactor * dt;
|
|
438
|
+
particle.velocity[2] += toCenter[2] * attractFactor * dt;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
break;
|
|
442
|
+
}
|
|
443
|
+
case "drag": {
|
|
444
|
+
const dragCoeff = this.evaluateMinMaxCurve(
|
|
445
|
+
field.coefficient,
|
|
446
|
+
particle.normalizedLifetime,
|
|
447
|
+
particle.randomSeed
|
|
448
|
+
);
|
|
449
|
+
let drag = dragCoeff;
|
|
450
|
+
if (field.multiplyBySize) {
|
|
451
|
+
const sizeMag = Math.sqrt(
|
|
452
|
+
particle.size[0] ** 2 + particle.size[1] ** 2 + particle.size[2] ** 2
|
|
453
|
+
);
|
|
454
|
+
drag *= sizeMag;
|
|
455
|
+
}
|
|
456
|
+
if (field.multiplyByVelocity) {
|
|
457
|
+
const velMag = Math.sqrt(
|
|
458
|
+
particle.velocity[0] ** 2 + particle.velocity[1] ** 2 + particle.velocity[2] ** 2
|
|
459
|
+
);
|
|
460
|
+
drag *= velMag;
|
|
461
|
+
}
|
|
462
|
+
const factor = Math.max(0, 1 - drag * dt);
|
|
463
|
+
particle.velocity[0] *= factor;
|
|
464
|
+
particle.velocity[1] *= factor;
|
|
465
|
+
particle.velocity[2] *= factor;
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
case "attractor": {
|
|
469
|
+
const attractorStrength = this.evaluateMinMaxCurve(
|
|
470
|
+
field.strength,
|
|
471
|
+
particle.normalizedLifetime,
|
|
472
|
+
particle.randomSeed
|
|
473
|
+
);
|
|
474
|
+
const toAttractor = [
|
|
475
|
+
field.position[0] - particle.position[0],
|
|
476
|
+
field.position[1] - particle.position[1],
|
|
477
|
+
field.position[2] - particle.position[2]
|
|
478
|
+
];
|
|
479
|
+
const attractorDist = Math.sqrt(
|
|
480
|
+
toAttractor[0] ** 2 + toAttractor[1] ** 2 + toAttractor[2] ** 2
|
|
481
|
+
);
|
|
482
|
+
if (attractorDist > 1e-3 && attractorDist < field.radius) {
|
|
483
|
+
const falloff = 1 - attractorDist / field.radius;
|
|
484
|
+
const force = attractorStrength * falloff / attractorDist;
|
|
485
|
+
particle.velocity[0] += toAttractor[0] * force * dt;
|
|
486
|
+
particle.velocity[1] += toAttractor[1] * force * dt;
|
|
487
|
+
particle.velocity[2] += toAttractor[2] * force * dt;
|
|
488
|
+
if (field.killOnArrive && attractorDist < 0.1) {
|
|
489
|
+
particle.remainingLifetime = -1;
|
|
490
|
+
}
|
|
769
491
|
}
|
|
492
|
+
break;
|
|
493
|
+
}
|
|
770
494
|
}
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
495
|
+
}
|
|
496
|
+
applyVelocityOverLifetime(particle, dt) {
|
|
497
|
+
const vol = this.definition.velocityOverLifetime;
|
|
498
|
+
if (!vol.enabled) {
|
|
499
|
+
return;
|
|
775
500
|
}
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
return curve.min + (curve.max - curve.min) * rand;
|
|
786
|
-
}
|
|
787
|
-
case 'randomBetweenTwoCurves': {
|
|
788
|
-
const randCurve = this.seededRandom(seed);
|
|
789
|
-
const minVal = this.evaluateAnimationCurve(curve.curveMin, t);
|
|
790
|
-
const maxVal = this.evaluateAnimationCurve(curve.curveMax, t);
|
|
791
|
-
return (minVal + (maxVal - minVal) * randCurve) * curve.multiplier;
|
|
792
|
-
}
|
|
793
|
-
}
|
|
501
|
+
if (vol.linear.mode !== "constant" || vol.linear.value[0] !== 0 || vol.linear.value[1] !== 0 || vol.linear.value[2] !== 0) {
|
|
502
|
+
const linear = this.evaluateMinMaxVector3(
|
|
503
|
+
vol.linear,
|
|
504
|
+
particle.normalizedLifetime,
|
|
505
|
+
particle.randomSeed
|
|
506
|
+
);
|
|
507
|
+
particle.velocity[0] += linear[0] * dt;
|
|
508
|
+
particle.velocity[1] += linear[1] * dt;
|
|
509
|
+
particle.velocity[2] += linear[2] * dt;
|
|
794
510
|
}
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
}
|
|
810
|
-
// Find keyframes
|
|
811
|
-
for (let i = 0; i < keyframes.length - 1; i++) {
|
|
812
|
-
const k0 = keyframes[i];
|
|
813
|
-
const k1 = keyframes[i + 1];
|
|
814
|
-
if (t >= k0.time && t <= k1.time) {
|
|
815
|
-
const localT = (t - k0.time) / (k1.time - k0.time);
|
|
816
|
-
// Hermite interpolation
|
|
817
|
-
const t2 = localT * localT;
|
|
818
|
-
const t3 = t2 * localT;
|
|
819
|
-
const h00 = 2 * t3 - 3 * t2 + 1;
|
|
820
|
-
const h10 = t3 - 2 * t2 + localT;
|
|
821
|
-
const h01 = -2 * t3 + 3 * t2;
|
|
822
|
-
const h11 = t3 - t2;
|
|
823
|
-
const dt = k1.time - k0.time;
|
|
824
|
-
return h00 * k0.value + h10 * dt * k0.outTangent + h01 * k1.value + h11 * dt * k1.inTangent;
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
return keyframes[keyframes.length - 1].value;
|
|
828
|
-
}
|
|
829
|
-
handleWrapMode(t, mode) {
|
|
830
|
-
switch (mode) {
|
|
831
|
-
case 'clamp':
|
|
832
|
-
return Math.max(0, Math.min(1, t));
|
|
833
|
-
case 'loop':
|
|
834
|
-
return t - Math.floor(t);
|
|
835
|
-
case 'pingPong': {
|
|
836
|
-
const cycle = Math.floor(t);
|
|
837
|
-
const frac = t - cycle;
|
|
838
|
-
return cycle % 2 === 0 ? frac : 1 - frac;
|
|
839
|
-
}
|
|
840
|
-
}
|
|
511
|
+
const radial = this.evaluateMinMaxCurve(
|
|
512
|
+
vol.radial,
|
|
513
|
+
particle.normalizedLifetime,
|
|
514
|
+
particle.randomSeed
|
|
515
|
+
);
|
|
516
|
+
if (radial !== 0) {
|
|
517
|
+
const len = Math.sqrt(
|
|
518
|
+
particle.position[0] ** 2 + particle.position[1] ** 2 + particle.position[2] ** 2
|
|
519
|
+
);
|
|
520
|
+
if (len > 1e-3) {
|
|
521
|
+
particle.velocity[0] += particle.position[0] / len * radial * dt;
|
|
522
|
+
particle.velocity[1] += particle.position[1] / len * radial * dt;
|
|
523
|
+
particle.velocity[2] += particle.position[2] / len * radial * dt;
|
|
524
|
+
}
|
|
841
525
|
}
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
];
|
|
856
|
-
}
|
|
857
|
-
case 'randomBetweenTwoGradients': {
|
|
858
|
-
const randG = this.seededRandom(seed);
|
|
859
|
-
const minColor = this.evaluateGradient(gradient.gradientMin, t);
|
|
860
|
-
const maxColor = this.evaluateGradient(gradient.gradientMax, t);
|
|
861
|
-
return [
|
|
862
|
-
minColor[0] + (maxColor[0] - minColor[0]) * randG,
|
|
863
|
-
minColor[1] + (maxColor[1] - minColor[1]) * randG,
|
|
864
|
-
minColor[2] + (maxColor[2] - minColor[2]) * randG,
|
|
865
|
-
minColor[3] + (maxColor[3] - minColor[3]) * randG,
|
|
866
|
-
];
|
|
867
|
-
}
|
|
868
|
-
}
|
|
526
|
+
const speedMod = this.evaluateMinMaxCurve(
|
|
527
|
+
vol.speedModifier,
|
|
528
|
+
particle.normalizedLifetime,
|
|
529
|
+
particle.randomSeed
|
|
530
|
+
);
|
|
531
|
+
particle.velocity[0] *= speedMod;
|
|
532
|
+
particle.velocity[1] *= speedMod;
|
|
533
|
+
particle.velocity[2] *= speedMod;
|
|
534
|
+
}
|
|
535
|
+
applyForceOverLifetime(particle, dt) {
|
|
536
|
+
const fol = this.definition.forceOverLifetime;
|
|
537
|
+
if (!fol.enabled) {
|
|
538
|
+
return;
|
|
869
539
|
}
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
540
|
+
const seed = fol.randomize ? Math.random() * 4294967295 | 0 : particle.randomSeed;
|
|
541
|
+
particle.velocity[0] += this.evaluateMinMaxCurve(fol.x, particle.normalizedLifetime, seed) * dt;
|
|
542
|
+
particle.velocity[1] += this.evaluateMinMaxCurve(fol.y, particle.normalizedLifetime, seed) * dt;
|
|
543
|
+
particle.velocity[2] += this.evaluateMinMaxCurve(fol.z, particle.normalizedLifetime, seed) * dt;
|
|
544
|
+
}
|
|
545
|
+
applyLimitVelocityOverLifetime(particle, dt) {
|
|
546
|
+
const lvol = this.definition.limitVelocityOverLifetime;
|
|
547
|
+
if (!lvol.enabled) {
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
const velMag = Math.sqrt(
|
|
551
|
+
particle.velocity[0] ** 2 + particle.velocity[1] ** 2 + particle.velocity[2] ** 2
|
|
552
|
+
);
|
|
553
|
+
let maxSpeed;
|
|
554
|
+
if (lvol.separateAxes) {
|
|
555
|
+
maxSpeed = this.evaluateMinMaxCurve(
|
|
556
|
+
lvol.speed,
|
|
557
|
+
particle.normalizedLifetime,
|
|
558
|
+
particle.randomSeed
|
|
559
|
+
);
|
|
560
|
+
} else {
|
|
561
|
+
maxSpeed = this.evaluateMinMaxCurve(
|
|
562
|
+
lvol.speed,
|
|
563
|
+
particle.normalizedLifetime,
|
|
564
|
+
particle.randomSeed
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
if (velMag > maxSpeed) {
|
|
568
|
+
const dampenFactor = 1 - lvol.dampen;
|
|
569
|
+
const targetSpeed = maxSpeed + (velMag - maxSpeed) * dampenFactor;
|
|
570
|
+
const scale = targetSpeed / velMag;
|
|
571
|
+
particle.velocity[0] *= scale;
|
|
572
|
+
particle.velocity[1] *= scale;
|
|
573
|
+
particle.velocity[2] *= scale;
|
|
574
|
+
}
|
|
575
|
+
const drag = this.evaluateMinMaxCurve(
|
|
576
|
+
lvol.drag,
|
|
577
|
+
particle.normalizedLifetime,
|
|
578
|
+
particle.randomSeed
|
|
579
|
+
);
|
|
580
|
+
if (drag > 0) {
|
|
581
|
+
const dragFactor = Math.max(0, 1 - drag * dt);
|
|
582
|
+
particle.velocity[0] *= dragFactor;
|
|
583
|
+
particle.velocity[1] *= dragFactor;
|
|
584
|
+
particle.velocity[2] *= dragFactor;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
applyNoise(particle, dt) {
|
|
588
|
+
const noise = this.definition.noise;
|
|
589
|
+
if (!noise.enabled) {
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
const strength = this.evaluateMinMaxCurve(
|
|
593
|
+
noise.strength,
|
|
594
|
+
particle.normalizedLifetime,
|
|
595
|
+
particle.randomSeed
|
|
596
|
+
);
|
|
597
|
+
const freq = noise.frequency;
|
|
598
|
+
const scroll = noise.scrollSpeed * this.state.time;
|
|
599
|
+
const nx = particle.position[0] * freq + scroll;
|
|
600
|
+
const ny = particle.position[1] * freq + scroll;
|
|
601
|
+
const nz = particle.position[2] * freq + scroll;
|
|
602
|
+
const noiseX = Math.sin(nx * 12.9898 + ny * 78.233) * 43758.5453 % 1;
|
|
603
|
+
const noiseY = Math.sin(ny * 12.9898 + nz * 78.233) * 43758.5453 % 1;
|
|
604
|
+
const noiseZ = Math.sin(nz * 12.9898 + nx * 78.233) * 43758.5453 % 1;
|
|
605
|
+
const posAmount = this.evaluateMinMaxCurve(
|
|
606
|
+
noise.positionAmount,
|
|
607
|
+
particle.normalizedLifetime,
|
|
608
|
+
particle.randomSeed
|
|
609
|
+
);
|
|
610
|
+
particle.position[0] += (noiseX * 2 - 1) * strength * posAmount * dt;
|
|
611
|
+
particle.position[1] += (noiseY * 2 - 1) * strength * posAmount * dt;
|
|
612
|
+
particle.position[2] += (noiseZ * 2 - 1) * strength * posAmount * dt;
|
|
613
|
+
}
|
|
614
|
+
applyColorOverLifetime(particle) {
|
|
615
|
+
const col = this.definition.colorOverLifetime;
|
|
616
|
+
if (!col.enabled) {
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
const color = this.evaluateMinMaxGradient(
|
|
620
|
+
col.color,
|
|
621
|
+
particle.normalizedLifetime,
|
|
622
|
+
particle.randomSeed
|
|
623
|
+
);
|
|
624
|
+
particle.color[0] = particle.startColor[0] * color[0];
|
|
625
|
+
particle.color[1] = particle.startColor[1] * color[1];
|
|
626
|
+
particle.color[2] = particle.startColor[2] * color[2];
|
|
627
|
+
particle.color[3] = particle.startColor[3] * color[3];
|
|
628
|
+
}
|
|
629
|
+
applySizeOverLifetime(particle) {
|
|
630
|
+
const sol = this.definition.sizeOverLifetime;
|
|
631
|
+
if (!sol.enabled) {
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
if (sol.separateAxes) {
|
|
635
|
+
particle.size[0] = particle.startSize[0] * this.evaluateMinMaxCurve(sol.sizeX, particle.normalizedLifetime, particle.randomSeed);
|
|
636
|
+
particle.size[1] = particle.startSize[1] * this.evaluateMinMaxCurve(sol.sizeY, particle.normalizedLifetime, particle.randomSeed);
|
|
637
|
+
particle.size[2] = particle.startSize[2] * this.evaluateMinMaxCurve(sol.sizeZ, particle.normalizedLifetime, particle.randomSeed);
|
|
638
|
+
} else {
|
|
639
|
+
const scale = this.evaluateMinMaxCurve(
|
|
640
|
+
sol.size,
|
|
641
|
+
particle.normalizedLifetime,
|
|
642
|
+
particle.randomSeed
|
|
643
|
+
);
|
|
644
|
+
particle.size[0] = particle.startSize[0] * scale;
|
|
645
|
+
particle.size[1] = particle.startSize[1] * scale;
|
|
646
|
+
particle.size[2] = particle.startSize[2] * scale;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
applyRotationOverLifetime(particle, dt) {
|
|
650
|
+
const rol = this.definition.rotationOverLifetime;
|
|
651
|
+
if (!rol.enabled) {
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
if (rol.separateAxes) {
|
|
655
|
+
particle.rotation[0] += this.evaluateMinMaxCurve(
|
|
656
|
+
rol.angularVelocityX,
|
|
657
|
+
particle.normalizedLifetime,
|
|
658
|
+
particle.randomSeed
|
|
659
|
+
) * dt;
|
|
660
|
+
particle.rotation[1] += this.evaluateMinMaxCurve(
|
|
661
|
+
rol.angularVelocityY,
|
|
662
|
+
particle.normalizedLifetime,
|
|
663
|
+
particle.randomSeed
|
|
664
|
+
) * dt;
|
|
665
|
+
particle.rotation[2] += this.evaluateMinMaxCurve(
|
|
666
|
+
rol.angularVelocityZ,
|
|
667
|
+
particle.normalizedLifetime,
|
|
668
|
+
particle.randomSeed
|
|
669
|
+
) * dt;
|
|
670
|
+
} else {
|
|
671
|
+
particle.rotation[2] += this.evaluateMinMaxCurve(
|
|
672
|
+
rol.angularVelocity,
|
|
673
|
+
particle.normalizedLifetime,
|
|
674
|
+
particle.randomSeed
|
|
675
|
+
) * dt;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
applyColorBySpeed(particle) {
|
|
679
|
+
const cbs = this.definition.colorBySpeed;
|
|
680
|
+
if (!cbs.enabled) {
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
const speed = Math.sqrt(
|
|
684
|
+
particle.velocity[0] ** 2 + particle.velocity[1] ** 2 + particle.velocity[2] ** 2
|
|
685
|
+
);
|
|
686
|
+
const t = Math.min(
|
|
687
|
+
1,
|
|
688
|
+
Math.max(0, (speed - cbs.speedRange[0]) / (cbs.speedRange[1] - cbs.speedRange[0]))
|
|
689
|
+
);
|
|
690
|
+
const color = this.evaluateMinMaxGradient(cbs.color, t, particle.randomSeed);
|
|
691
|
+
particle.color[0] *= color[0];
|
|
692
|
+
particle.color[1] *= color[1];
|
|
693
|
+
particle.color[2] *= color[2];
|
|
694
|
+
particle.color[3] *= color[3];
|
|
695
|
+
}
|
|
696
|
+
applySizeBySpeed(particle) {
|
|
697
|
+
const sbs = this.definition.sizeBySpeed;
|
|
698
|
+
if (!sbs.enabled) {
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
const speed = Math.sqrt(
|
|
702
|
+
particle.velocity[0] ** 2 + particle.velocity[1] ** 2 + particle.velocity[2] ** 2
|
|
703
|
+
);
|
|
704
|
+
const t = Math.min(
|
|
705
|
+
1,
|
|
706
|
+
Math.max(0, (speed - sbs.speedRange[0]) / (sbs.speedRange[1] - sbs.speedRange[0]))
|
|
707
|
+
);
|
|
708
|
+
if (sbs.separateAxes) {
|
|
709
|
+
particle.size[0] *= this.evaluateMinMaxCurve(sbs.sizeX, t, particle.randomSeed);
|
|
710
|
+
particle.size[1] *= this.evaluateMinMaxCurve(sbs.sizeY, t, particle.randomSeed);
|
|
711
|
+
particle.size[2] *= this.evaluateMinMaxCurve(sbs.sizeZ, t, particle.randomSeed);
|
|
712
|
+
} else {
|
|
713
|
+
const scale = this.evaluateMinMaxCurve(sbs.size, t, particle.randomSeed);
|
|
714
|
+
particle.size[0] *= scale;
|
|
715
|
+
particle.size[1] *= scale;
|
|
716
|
+
particle.size[2] *= scale;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
applyRotationBySpeed(particle, dt) {
|
|
720
|
+
const rbs = this.definition.rotationBySpeed;
|
|
721
|
+
if (!rbs.enabled) {
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
const speed = Math.sqrt(
|
|
725
|
+
particle.velocity[0] ** 2 + particle.velocity[1] ** 2 + particle.velocity[2] ** 2
|
|
726
|
+
);
|
|
727
|
+
const t = Math.min(
|
|
728
|
+
1,
|
|
729
|
+
Math.max(0, (speed - rbs.speedRange[0]) / (rbs.speedRange[1] - rbs.speedRange[0]))
|
|
730
|
+
);
|
|
731
|
+
if (rbs.separateAxes) {
|
|
732
|
+
particle.rotation[0] += this.evaluateMinMaxCurve(rbs.angularVelocityX, t, particle.randomSeed) * dt;
|
|
733
|
+
particle.rotation[1] += this.evaluateMinMaxCurve(rbs.angularVelocityY, t, particle.randomSeed) * dt;
|
|
734
|
+
particle.rotation[2] += this.evaluateMinMaxCurve(rbs.angularVelocityZ, t, particle.randomSeed) * dt;
|
|
735
|
+
} else {
|
|
736
|
+
particle.rotation[2] += this.evaluateMinMaxCurve(rbs.angularVelocity, t, particle.randomSeed) * dt;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
handleCollision(particle) {
|
|
740
|
+
const collision = this.definition.collision;
|
|
741
|
+
if (collision.type === "planes") {
|
|
742
|
+
for (const plane of collision.planes) {
|
|
743
|
+
const dot = particle.position[0] * plane.normal[0] + particle.position[1] * plane.normal[1] + particle.position[2] * plane.normal[2];
|
|
744
|
+
const planeDist = plane.position[0] * plane.normal[0] + plane.position[1] * plane.normal[1] + plane.position[2] * plane.normal[2];
|
|
745
|
+
if (dot < planeDist) {
|
|
746
|
+
const velDotN = particle.velocity[0] * plane.normal[0] + particle.velocity[1] * plane.normal[1] + particle.velocity[2] * plane.normal[2];
|
|
747
|
+
const bounce = this.evaluateMinMaxCurve(
|
|
748
|
+
collision.bounce,
|
|
749
|
+
particle.normalizedLifetime,
|
|
750
|
+
particle.randomSeed
|
|
751
|
+
);
|
|
752
|
+
const dampen = this.evaluateMinMaxCurve(
|
|
753
|
+
collision.dampen,
|
|
754
|
+
particle.normalizedLifetime,
|
|
755
|
+
particle.randomSeed
|
|
756
|
+
);
|
|
757
|
+
particle.velocity[0] -= (1 + bounce) * velDotN * plane.normal[0];
|
|
758
|
+
particle.velocity[1] -= (1 + bounce) * velDotN * plane.normal[1];
|
|
759
|
+
particle.velocity[2] -= (1 + bounce) * velDotN * plane.normal[2];
|
|
760
|
+
particle.velocity[0] *= 1 - dampen;
|
|
761
|
+
particle.velocity[1] *= 1 - dampen;
|
|
762
|
+
particle.velocity[2] *= 1 - dampen;
|
|
763
|
+
particle.position[0] += (planeDist - dot) * plane.normal[0];
|
|
764
|
+
particle.position[1] += (planeDist - dot) * plane.normal[1];
|
|
765
|
+
particle.position[2] += (planeDist - dot) * plane.normal[2];
|
|
766
|
+
const lifetimeLoss = this.evaluateMinMaxCurve(
|
|
767
|
+
collision.lifetimeLoss,
|
|
768
|
+
particle.normalizedLifetime,
|
|
769
|
+
particle.randomSeed
|
|
770
|
+
);
|
|
771
|
+
particle.remainingLifetime -= particle.startLifetime * lifetimeLoss;
|
|
772
|
+
const speed = Math.sqrt(
|
|
773
|
+
particle.velocity[0] ** 2 + particle.velocity[1] ** 2 + particle.velocity[2] ** 2
|
|
774
|
+
);
|
|
775
|
+
if (speed < collision.minKillSpeed) {
|
|
776
|
+
particle.remainingLifetime = -1;
|
|
777
|
+
}
|
|
778
|
+
this.triggerSubEmitters("collision", particle);
|
|
929
779
|
}
|
|
780
|
+
}
|
|
930
781
|
}
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
782
|
+
}
|
|
783
|
+
triggerSubEmitters(trigger, _particle) {
|
|
784
|
+
for (const subEmitter of this.definition.subEmitters) {
|
|
785
|
+
if (subEmitter.trigger === trigger && Math.random() < subEmitter.probability) ;
|
|
934
786
|
}
|
|
935
|
-
|
|
936
|
-
|
|
787
|
+
}
|
|
788
|
+
// ─── Curve/Gradient Evaluation ─────────────────────────
|
|
789
|
+
evaluateMinMaxCurve(curve, t, seed) {
|
|
790
|
+
switch (curve.mode) {
|
|
791
|
+
case "constant":
|
|
792
|
+
return curve.value;
|
|
793
|
+
case "curve":
|
|
794
|
+
return this.evaluateAnimationCurve(curve.curve, t) * curve.multiplier;
|
|
795
|
+
case "randomBetweenTwoConstants": {
|
|
796
|
+
const rand = this.seededRandom(seed);
|
|
797
|
+
return curve.min + (curve.max - curve.min) * rand;
|
|
798
|
+
}
|
|
799
|
+
case "randomBetweenTwoCurves": {
|
|
800
|
+
const randCurve = this.seededRandom(seed);
|
|
801
|
+
const minVal = this.evaluateAnimationCurve(curve.curveMin, t);
|
|
802
|
+
const maxVal = this.evaluateAnimationCurve(curve.curveMax, t);
|
|
803
|
+
return (minVal + (maxVal - minVal) * randCurve) * curve.multiplier;
|
|
804
|
+
}
|
|
937
805
|
}
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
806
|
+
}
|
|
807
|
+
evaluateAnimationCurve(curve, t) {
|
|
808
|
+
const keyframes = curve.keyframes;
|
|
809
|
+
if (keyframes.length === 0) {
|
|
810
|
+
return 0;
|
|
941
811
|
}
|
|
942
|
-
|
|
943
|
-
|
|
812
|
+
if (keyframes.length === 1) {
|
|
813
|
+
return keyframes[0].value;
|
|
944
814
|
}
|
|
945
|
-
|
|
946
|
-
|
|
815
|
+
if (t < 0) {
|
|
816
|
+
t = this.handleWrapMode(t, curve.preWrapMode);
|
|
947
817
|
}
|
|
948
|
-
|
|
949
|
-
|
|
818
|
+
if (t > 1) {
|
|
819
|
+
t = this.handleWrapMode(t, curve.postWrapMode);
|
|
950
820
|
}
|
|
951
|
-
|
|
952
|
-
|
|
821
|
+
for (let i = 0; i < keyframes.length - 1; i++) {
|
|
822
|
+
const k0 = keyframes[i];
|
|
823
|
+
const k1 = keyframes[i + 1];
|
|
824
|
+
if (t >= k0.time && t <= k1.time) {
|
|
825
|
+
const localT = (t - k0.time) / (k1.time - k0.time);
|
|
826
|
+
const t2 = localT * localT;
|
|
827
|
+
const t3 = t2 * localT;
|
|
828
|
+
const h00 = 2 * t3 - 3 * t2 + 1;
|
|
829
|
+
const h10 = t3 - 2 * t2 + localT;
|
|
830
|
+
const h01 = -2 * t3 + 3 * t2;
|
|
831
|
+
const h11 = t3 - t2;
|
|
832
|
+
const dt = k1.time - k0.time;
|
|
833
|
+
return h00 * k0.value + h10 * dt * k0.outTangent + h01 * k1.value + h11 * dt * k1.inTangent;
|
|
834
|
+
}
|
|
953
835
|
}
|
|
954
|
-
|
|
955
|
-
|
|
836
|
+
return keyframes[keyframes.length - 1].value;
|
|
837
|
+
}
|
|
838
|
+
handleWrapMode(t, mode) {
|
|
839
|
+
switch (mode) {
|
|
840
|
+
case "clamp":
|
|
841
|
+
return Math.max(0, Math.min(1, t));
|
|
842
|
+
case "loop":
|
|
843
|
+
return t - Math.floor(t);
|
|
844
|
+
case "pingPong": {
|
|
845
|
+
const cycle = Math.floor(t);
|
|
846
|
+
const frac = t - cycle;
|
|
847
|
+
return cycle % 2 === 0 ? frac : 1 - frac;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
evaluateMinMaxGradient(gradient, t, seed) {
|
|
852
|
+
switch (gradient.mode) {
|
|
853
|
+
case "color":
|
|
854
|
+
return gradient.color;
|
|
855
|
+
case "gradient":
|
|
856
|
+
return this.evaluateGradient(gradient.gradient, t);
|
|
857
|
+
case "randomBetweenTwoColors": {
|
|
858
|
+
const rand = this.seededRandom(seed);
|
|
859
|
+
return [
|
|
860
|
+
gradient.colorMin[0] + (gradient.colorMax[0] - gradient.colorMin[0]) * rand,
|
|
861
|
+
gradient.colorMin[1] + (gradient.colorMax[1] - gradient.colorMin[1]) * rand,
|
|
862
|
+
gradient.colorMin[2] + (gradient.colorMax[2] - gradient.colorMin[2]) * rand,
|
|
863
|
+
gradient.colorMin[3] + (gradient.colorMax[3] - gradient.colorMin[3]) * rand
|
|
864
|
+
];
|
|
865
|
+
}
|
|
866
|
+
case "randomBetweenTwoGradients": {
|
|
867
|
+
const randG = this.seededRandom(seed);
|
|
868
|
+
const minColor = this.evaluateGradient(gradient.gradientMin, t);
|
|
869
|
+
const maxColor = this.evaluateGradient(gradient.gradientMax, t);
|
|
870
|
+
return [
|
|
871
|
+
minColor[0] + (maxColor[0] - minColor[0]) * randG,
|
|
872
|
+
minColor[1] + (maxColor[1] - minColor[1]) * randG,
|
|
873
|
+
minColor[2] + (maxColor[2] - minColor[2]) * randG,
|
|
874
|
+
minColor[3] + (maxColor[3] - minColor[3]) * randG
|
|
875
|
+
];
|
|
876
|
+
}
|
|
956
877
|
}
|
|
957
|
-
|
|
958
|
-
|
|
878
|
+
}
|
|
879
|
+
evaluateGradient(gradient, t) {
|
|
880
|
+
let color = [1, 1, 1];
|
|
881
|
+
const colorKeys = gradient.colorKeys;
|
|
882
|
+
if (colorKeys.length > 0) {
|
|
883
|
+
if (t <= colorKeys[0].time) {
|
|
884
|
+
color = colorKeys[0].color;
|
|
885
|
+
} else if (t >= colorKeys[colorKeys.length - 1].time) {
|
|
886
|
+
color = colorKeys[colorKeys.length - 1].color;
|
|
887
|
+
} else {
|
|
888
|
+
for (let i = 0; i < colorKeys.length - 1; i++) {
|
|
889
|
+
if (t >= colorKeys[i].time && t <= colorKeys[i + 1].time) {
|
|
890
|
+
const localT = (t - colorKeys[i].time) / (colorKeys[i + 1].time - colorKeys[i].time);
|
|
891
|
+
color = [
|
|
892
|
+
colorKeys[i].color[0] + (colorKeys[i + 1].color[0] - colorKeys[i].color[0]) * localT,
|
|
893
|
+
colorKeys[i].color[1] + (colorKeys[i + 1].color[1] - colorKeys[i].color[1]) * localT,
|
|
894
|
+
colorKeys[i].color[2] + (colorKeys[i + 1].color[2] - colorKeys[i].color[2]) * localT
|
|
895
|
+
];
|
|
896
|
+
break;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
959
900
|
}
|
|
960
|
-
|
|
961
|
-
|
|
901
|
+
let alpha = 1;
|
|
902
|
+
const alphaKeys = gradient.alphaKeys;
|
|
903
|
+
if (alphaKeys.length > 0) {
|
|
904
|
+
if (t <= alphaKeys[0].time) {
|
|
905
|
+
alpha = alphaKeys[0].alpha;
|
|
906
|
+
} else if (t >= alphaKeys[alphaKeys.length - 1].time) {
|
|
907
|
+
alpha = alphaKeys[alphaKeys.length - 1].alpha;
|
|
908
|
+
} else {
|
|
909
|
+
for (let i = 0; i < alphaKeys.length - 1; i++) {
|
|
910
|
+
if (t >= alphaKeys[i].time && t <= alphaKeys[i + 1].time) {
|
|
911
|
+
const localT = (t - alphaKeys[i].time) / (alphaKeys[i + 1].time - alphaKeys[i].time);
|
|
912
|
+
alpha = alphaKeys[i].alpha + (alphaKeys[i + 1].alpha - alphaKeys[i].alpha) * localT;
|
|
913
|
+
break;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
}
|
|
962
917
|
}
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
918
|
+
return [color[0], color[1], color[2], alpha];
|
|
919
|
+
}
|
|
920
|
+
evaluateMinMaxVector3(vec, t, seed) {
|
|
921
|
+
switch (vec.mode) {
|
|
922
|
+
case "constant":
|
|
923
|
+
return vec.value;
|
|
924
|
+
case "randomBetweenTwoConstants": {
|
|
925
|
+
const rand = this.seededRandom(seed);
|
|
926
|
+
return [
|
|
927
|
+
vec.min[0] + (vec.max[0] - vec.min[0]) * rand,
|
|
928
|
+
vec.min[1] + (vec.max[1] - vec.min[1]) * rand,
|
|
929
|
+
vec.min[2] + (vec.max[2] - vec.min[2]) * rand
|
|
930
|
+
];
|
|
931
|
+
}
|
|
966
932
|
}
|
|
933
|
+
}
|
|
934
|
+
seededRandom(seed) {
|
|
935
|
+
const x = Math.sin(seed * 12.9898 + 78.233) * 43758.5453;
|
|
936
|
+
return x - Math.floor(x);
|
|
937
|
+
}
|
|
938
|
+
normalizedTime() {
|
|
939
|
+
return this.state.time / this.definition.main.duration;
|
|
940
|
+
}
|
|
941
|
+
// ─── Public API ────────────────────────────────────────
|
|
942
|
+
get particleCount() {
|
|
943
|
+
return this.state.activeCount;
|
|
944
|
+
}
|
|
945
|
+
get isPlaying() {
|
|
946
|
+
return this.state.isPlaying;
|
|
947
|
+
}
|
|
948
|
+
get isPaused() {
|
|
949
|
+
return this.state.isPaused;
|
|
950
|
+
}
|
|
951
|
+
get isStopped() {
|
|
952
|
+
return this.state.isStopped;
|
|
953
|
+
}
|
|
954
|
+
get time() {
|
|
955
|
+
return this.state.time;
|
|
956
|
+
}
|
|
957
|
+
get duration() {
|
|
958
|
+
return this.definition.main.duration;
|
|
959
|
+
}
|
|
960
|
+
getParticles() {
|
|
961
|
+
return this.state.particles.filter((p) => p.remainingLifetime >= 0);
|
|
962
|
+
}
|
|
963
|
+
getDefinition() {
|
|
964
|
+
return this.definition;
|
|
965
|
+
}
|
|
966
|
+
setDefinition(def) {
|
|
967
|
+
this.definition = def;
|
|
968
|
+
this.state = this.createInitialState();
|
|
969
|
+
}
|
|
967
970
|
}
|
|
968
|
-
// ============================================================
|
|
969
|
-
// Factory Functions
|
|
970
|
-
// ============================================================
|
|
971
971
|
function createDefaultParticleSystem(name) {
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
972
|
+
return {
|
|
973
|
+
id: `ps_${Date.now()}`,
|
|
974
|
+
name,
|
|
975
|
+
main: {
|
|
976
|
+
duration: 5,
|
|
977
|
+
looping: true,
|
|
978
|
+
prewarm: false,
|
|
979
|
+
startDelay: { mode: "constant", value: 0 },
|
|
980
|
+
startLifetime: { mode: "constant", value: 5 },
|
|
981
|
+
startSpeed: { mode: "constant", value: 5 },
|
|
982
|
+
startSize3D: false,
|
|
983
|
+
startSize: { mode: "constant", value: 1 },
|
|
984
|
+
startRotation3D: false,
|
|
985
|
+
startRotation: { mode: "constant", value: 0 },
|
|
986
|
+
flipRotation: 0,
|
|
987
|
+
startColor: { mode: "color", color: [1, 1, 1, 1] },
|
|
988
|
+
gravityModifier: { mode: "constant", value: 0 },
|
|
989
|
+
simulationSpace: "local",
|
|
990
|
+
simulationSpeed: 1,
|
|
991
|
+
deltaTime: "scaled",
|
|
992
|
+
scalingMode: "local",
|
|
993
|
+
playOnAwake: true,
|
|
994
|
+
emitterVelocityMode: "transform",
|
|
995
|
+
maxParticles: 1e3,
|
|
996
|
+
stopAction: "none",
|
|
997
|
+
cullingMode: "automatic",
|
|
998
|
+
ringBufferMode: "disabled",
|
|
999
|
+
ringBufferLoopRange: [0, 1]
|
|
1000
|
+
},
|
|
1001
|
+
emission: {
|
|
1002
|
+
enabled: true,
|
|
1003
|
+
rateOverTime: { mode: "constant", value: 10 },
|
|
1004
|
+
rateOverDistance: { mode: "constant", value: 0 },
|
|
1005
|
+
bursts: []
|
|
1006
|
+
},
|
|
1007
|
+
shape: {
|
|
1008
|
+
type: "cone",
|
|
1009
|
+
angle: 25,
|
|
1010
|
+
radius: 1,
|
|
1011
|
+
radiusThickness: 1,
|
|
1012
|
+
arc: 360,
|
|
1013
|
+
arcMode: "random",
|
|
1014
|
+
arcSpeed: 1,
|
|
1015
|
+
length: 5,
|
|
1016
|
+
emitFrom: "base",
|
|
1017
|
+
position: [0, 0, 0],
|
|
1018
|
+
rotation: [0, 0, 0],
|
|
1019
|
+
scale: [1, 1, 1]
|
|
1020
|
+
},
|
|
1021
|
+
velocityOverLifetime: {
|
|
1022
|
+
enabled: false,
|
|
1023
|
+
space: "local",
|
|
1024
|
+
linear: { mode: "constant", value: [0, 0, 0] },
|
|
1025
|
+
orbital: { mode: "constant", value: [0, 0, 0] },
|
|
1026
|
+
offset: { mode: "constant", value: [0, 0, 0] },
|
|
1027
|
+
radial: { mode: "constant", value: 0 },
|
|
1028
|
+
speedModifier: { mode: "constant", value: 1 }
|
|
1029
|
+
},
|
|
1030
|
+
limitVelocityOverLifetime: {
|
|
1031
|
+
enabled: false,
|
|
1032
|
+
separateAxes: false,
|
|
1033
|
+
speed: { mode: "constant", value: 1 },
|
|
1034
|
+
space: "local",
|
|
1035
|
+
dampen: 0.1,
|
|
1036
|
+
drag: { mode: "constant", value: 0 },
|
|
1037
|
+
multiplyDragBySize: false,
|
|
1038
|
+
multiplyDragByVelocity: false
|
|
1039
|
+
},
|
|
1040
|
+
inheritVelocity: {
|
|
1041
|
+
enabled: false,
|
|
1042
|
+
mode: "initial",
|
|
1043
|
+
curve: { mode: "constant", value: 0 }
|
|
1044
|
+
},
|
|
1045
|
+
lifetimeByEmitterSpeed: {
|
|
1046
|
+
enabled: false,
|
|
1047
|
+
curve: { mode: "constant", value: 1 },
|
|
1048
|
+
speedRange: [0, 1]
|
|
1049
|
+
},
|
|
1050
|
+
forceOverLifetime: {
|
|
1051
|
+
enabled: false,
|
|
1052
|
+
space: "local",
|
|
1053
|
+
x: { mode: "constant", value: 0 },
|
|
1054
|
+
y: { mode: "constant", value: 0 },
|
|
1055
|
+
z: { mode: "constant", value: 0 },
|
|
1056
|
+
randomize: false
|
|
1057
|
+
},
|
|
1058
|
+
colorOverLifetime: {
|
|
1059
|
+
enabled: false,
|
|
1060
|
+
color: { mode: "color", color: [1, 1, 1, 1] }
|
|
1061
|
+
},
|
|
1062
|
+
colorBySpeed: {
|
|
1063
|
+
enabled: false,
|
|
1064
|
+
color: { mode: "color", color: [1, 1, 1, 1] },
|
|
1065
|
+
speedRange: [0, 1]
|
|
1066
|
+
},
|
|
1067
|
+
sizeOverLifetime: {
|
|
1068
|
+
enabled: false,
|
|
1069
|
+
separateAxes: false,
|
|
1070
|
+
size: { mode: "constant", value: 1 }
|
|
1071
|
+
},
|
|
1072
|
+
sizeBySpeed: {
|
|
1073
|
+
enabled: false,
|
|
1074
|
+
separateAxes: false,
|
|
1075
|
+
size: { mode: "constant", value: 1 },
|
|
1076
|
+
speedRange: [0, 1]
|
|
1077
|
+
},
|
|
1078
|
+
rotationOverLifetime: {
|
|
1079
|
+
enabled: false,
|
|
1080
|
+
separateAxes: false,
|
|
1081
|
+
angularVelocity: { mode: "constant", value: 0 }
|
|
1082
|
+
},
|
|
1083
|
+
rotationBySpeed: {
|
|
1084
|
+
enabled: false,
|
|
1085
|
+
separateAxes: false,
|
|
1086
|
+
angularVelocity: { mode: "constant", value: 0 },
|
|
1087
|
+
speedRange: [0, 1]
|
|
1088
|
+
},
|
|
1089
|
+
externalForces: {
|
|
1090
|
+
enabled: false,
|
|
1091
|
+
multiplier: { mode: "constant", value: 1 },
|
|
1092
|
+
influenceFilter: "layerMask",
|
|
1093
|
+
influenceMask: 4294967295,
|
|
1094
|
+
forceFields: []
|
|
1095
|
+
},
|
|
1096
|
+
noise: {
|
|
1097
|
+
enabled: false,
|
|
1098
|
+
separateAxes: false,
|
|
1099
|
+
strength: { mode: "constant", value: 1 },
|
|
1100
|
+
frequency: 0.5,
|
|
1101
|
+
scrollSpeed: 0,
|
|
1102
|
+
damping: true,
|
|
1103
|
+
octaves: 1,
|
|
1104
|
+
octaveMultiplier: 0.5,
|
|
1105
|
+
octaveScale: 2,
|
|
1106
|
+
quality: "medium",
|
|
1107
|
+
remapEnabled: false,
|
|
1108
|
+
remapCurve: { keyframes: [], preWrapMode: "clamp", postWrapMode: "clamp" },
|
|
1109
|
+
positionAmount: { mode: "constant", value: 1 },
|
|
1110
|
+
rotationAmount: { mode: "constant", value: 0 },
|
|
1111
|
+
sizeAmount: { mode: "constant", value: 0 }
|
|
1112
|
+
},
|
|
1113
|
+
collision: {
|
|
1114
|
+
enabled: false,
|
|
1115
|
+
type: "planes",
|
|
1116
|
+
planes: [{ normal: [0, 1, 0], position: [0, 0, 0] }],
|
|
1117
|
+
bounce: { mode: "constant", value: 0.5 },
|
|
1118
|
+
lifetimeLoss: { mode: "constant", value: 0 },
|
|
1119
|
+
minKillSpeed: 0,
|
|
1120
|
+
radiusScale: 1,
|
|
1121
|
+
dampen: { mode: "constant", value: 0 },
|
|
1122
|
+
enableDynamicColliders: false,
|
|
1123
|
+
colliderForce: 0,
|
|
1124
|
+
multiplyByCollisionAngle: true,
|
|
1125
|
+
multiplyByParticleSpeed: true,
|
|
1126
|
+
multiplyByParticleSize: false,
|
|
1127
|
+
sendCollisionMessages: false
|
|
1128
|
+
},
|
|
1129
|
+
triggers: {
|
|
1130
|
+
enabled: false,
|
|
1131
|
+
inside: "ignore",
|
|
1132
|
+
outside: "ignore",
|
|
1133
|
+
enter: "ignore",
|
|
1134
|
+
exit: "ignore",
|
|
1135
|
+
colliderQueryMode: "disabled",
|
|
1136
|
+
radiusScale: 1
|
|
1137
|
+
},
|
|
1138
|
+
subEmitters: [],
|
|
1139
|
+
textureSheetAnimation: {
|
|
1140
|
+
enabled: false,
|
|
1141
|
+
mode: "grid",
|
|
1142
|
+
tilesX: 1,
|
|
1143
|
+
tilesY: 1,
|
|
1144
|
+
animation: "wholeSheet",
|
|
1145
|
+
rowIndex: 0,
|
|
1146
|
+
rowMode: "custom",
|
|
1147
|
+
timeMode: "lifetime",
|
|
1148
|
+
frameOverTime: { mode: "constant", value: 0 },
|
|
1149
|
+
startFrame: { mode: "constant", value: 0 },
|
|
1150
|
+
cycleCount: 1,
|
|
1151
|
+
speedRange: [0, 1],
|
|
1152
|
+
fps: 30,
|
|
1153
|
+
sprites: []
|
|
1154
|
+
},
|
|
1155
|
+
lights: {
|
|
1156
|
+
enabled: false,
|
|
1157
|
+
ratio: 1,
|
|
1158
|
+
randomDistribution: true,
|
|
1159
|
+
light: {
|
|
1160
|
+
type: "point",
|
|
1161
|
+
color: { mode: "color", color: [1, 1, 1, 1] },
|
|
1162
|
+
intensity: { mode: "constant", value: 1 },
|
|
1163
|
+
range: { mode: "constant", value: 1 }
|
|
1164
|
+
},
|
|
1165
|
+
useParticleColor: true,
|
|
1166
|
+
sizeAffectsRange: true,
|
|
1167
|
+
alphaAffectsIntensity: true,
|
|
1168
|
+
maxLights: 20
|
|
1169
|
+
},
|
|
1170
|
+
trails: {
|
|
1171
|
+
enabled: false,
|
|
1172
|
+
ratio: 1,
|
|
1173
|
+
lifetime: { mode: "constant", value: 1 },
|
|
1174
|
+
minVertexDistance: 0.2,
|
|
1175
|
+
textureMode: "stretch",
|
|
1176
|
+
worldSpace: false,
|
|
1177
|
+
dieWithParticle: true,
|
|
1178
|
+
sizeAffectsWidth: true,
|
|
1179
|
+
sizeAffectsLifetime: false,
|
|
1180
|
+
inheritParticleColor: true,
|
|
1181
|
+
colorOverLifetime: { mode: "color", color: [1, 1, 1, 1] },
|
|
1182
|
+
widthOverTrail: { mode: "constant", value: 1 },
|
|
1183
|
+
colorOverTrail: { mode: "color", color: [1, 1, 1, 1] },
|
|
1184
|
+
generateLightingData: false,
|
|
1185
|
+
shadowBias: 0.5
|
|
1186
|
+
},
|
|
1187
|
+
customData: {
|
|
1188
|
+
enabled: false,
|
|
1189
|
+
stream1: { mode: "disabled", components: 4 },
|
|
1190
|
+
stream2: { mode: "disabled", components: 4 }
|
|
1191
|
+
},
|
|
1192
|
+
renderer: {
|
|
1193
|
+
enabled: true,
|
|
1194
|
+
renderMode: "billboard",
|
|
1195
|
+
material: "",
|
|
1196
|
+
sortMode: "none",
|
|
1197
|
+
sortingFudge: 0,
|
|
1198
|
+
minParticleSize: 0,
|
|
1199
|
+
maxParticleSize: 0.5,
|
|
1200
|
+
cameraVelocityScale: 0,
|
|
1201
|
+
velocityScale: 0,
|
|
1202
|
+
lengthScale: 2,
|
|
1203
|
+
normalDirection: 1,
|
|
1204
|
+
shadowCastingMode: "off",
|
|
1205
|
+
receiveShadows: false,
|
|
1206
|
+
motionVectors: "cameraMotionOnly",
|
|
1207
|
+
lightProbes: "off",
|
|
1208
|
+
reflectionProbes: "off",
|
|
1209
|
+
maskInteraction: "none",
|
|
1210
|
+
pivot: [0, 0, 0],
|
|
1211
|
+
flip: [0, 0, 0],
|
|
1212
|
+
allowRoll: true,
|
|
1213
|
+
freeformStretching: false,
|
|
1214
|
+
rotateWithStretchDirection: true,
|
|
1215
|
+
enableGPUInstancing: false
|
|
1216
|
+
}
|
|
1217
|
+
};
|
|
1218
1218
|
}
|
|
1219
1219
|
function createParticleSystem(def) {
|
|
1220
|
-
|
|
1220
|
+
return new ParticleSystem2(def);
|
|
1221
1221
|
}
|
|
1222
|
-
// ============================================================
|
|
1223
|
-
// Preset Systems
|
|
1224
|
-
// ============================================================
|
|
1225
1222
|
function createFireParticleSystem() {
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1223
|
+
const def = createDefaultParticleSystem("Fire");
|
|
1224
|
+
def.main.startLifetime = { mode: "randomBetweenTwoConstants", min: 0.5, max: 1.5 };
|
|
1225
|
+
def.main.startSize = { mode: "randomBetweenTwoConstants", min: 0.1, max: 0.5 };
|
|
1226
|
+
def.main.startColor = {
|
|
1227
|
+
mode: "randomBetweenTwoColors",
|
|
1228
|
+
colorMin: [1, 0.5, 0, 1],
|
|
1229
|
+
colorMax: [1, 0.2, 0, 1]
|
|
1230
|
+
};
|
|
1231
|
+
def.main.gravityModifier = { mode: "constant", value: -0.5 };
|
|
1232
|
+
def.emission.rateOverTime = { mode: "constant", value: 50 };
|
|
1233
|
+
def.shape = {
|
|
1234
|
+
type: "cone",
|
|
1235
|
+
angle: 15,
|
|
1236
|
+
radius: 0.2,
|
|
1237
|
+
radiusThickness: 1,
|
|
1238
|
+
arc: 360,
|
|
1239
|
+
arcMode: "random",
|
|
1240
|
+
arcSpeed: 1,
|
|
1241
|
+
length: 1,
|
|
1242
|
+
emitFrom: "base",
|
|
1243
|
+
position: [0, 0, 0],
|
|
1244
|
+
rotation: [0, 0, 0],
|
|
1245
|
+
scale: [1, 1, 1]
|
|
1246
|
+
};
|
|
1247
|
+
def.colorOverLifetime = {
|
|
1248
|
+
enabled: true,
|
|
1249
|
+
color: {
|
|
1250
|
+
mode: "gradient",
|
|
1251
|
+
gradient: {
|
|
1252
|
+
colorKeys: [
|
|
1253
|
+
{ time: 0, color: [1, 0.8, 0] },
|
|
1254
|
+
{ time: 0.3, color: [1, 0.3, 0] },
|
|
1255
|
+
{ time: 1, color: [0.2, 0, 0] }
|
|
1256
|
+
],
|
|
1257
|
+
alphaKeys: [
|
|
1258
|
+
{ time: 0, alpha: 1 },
|
|
1259
|
+
{ time: 0.7, alpha: 0.8 },
|
|
1260
|
+
{ time: 1, alpha: 0 }
|
|
1261
|
+
],
|
|
1262
|
+
mode: "blend"
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
};
|
|
1266
|
+
def.sizeOverLifetime = {
|
|
1267
|
+
enabled: true,
|
|
1268
|
+
separateAxes: false,
|
|
1269
|
+
size: {
|
|
1270
|
+
mode: "curve",
|
|
1271
|
+
curve: {
|
|
1272
|
+
keyframes: [
|
|
1273
|
+
{ time: 0, value: 0.5, inTangent: 0, outTangent: 1, mode: "auto" },
|
|
1274
|
+
{ time: 0.3, value: 1, inTangent: 0, outTangent: 0, mode: "auto" },
|
|
1275
|
+
{ time: 1, value: 0, inTangent: -1, outTangent: 0, mode: "auto" }
|
|
1276
|
+
],
|
|
1277
|
+
preWrapMode: "clamp",
|
|
1278
|
+
postWrapMode: "clamp"
|
|
1279
|
+
},
|
|
1280
|
+
multiplier: 1
|
|
1281
|
+
}
|
|
1282
|
+
};
|
|
1283
|
+
def.noise = {
|
|
1284
|
+
enabled: true,
|
|
1285
|
+
separateAxes: false,
|
|
1286
|
+
strength: { mode: "constant", value: 0.3 },
|
|
1287
|
+
frequency: 1,
|
|
1288
|
+
scrollSpeed: 1,
|
|
1289
|
+
damping: true,
|
|
1290
|
+
octaves: 2,
|
|
1291
|
+
octaveMultiplier: 0.5,
|
|
1292
|
+
octaveScale: 2,
|
|
1293
|
+
quality: "medium",
|
|
1294
|
+
remapEnabled: false,
|
|
1295
|
+
remapCurve: { keyframes: [], preWrapMode: "clamp", postWrapMode: "clamp" },
|
|
1296
|
+
positionAmount: { mode: "constant", value: 1 },
|
|
1297
|
+
rotationAmount: { mode: "constant", value: 0 },
|
|
1298
|
+
sizeAmount: { mode: "constant", value: 0 }
|
|
1299
|
+
};
|
|
1300
|
+
def.renderer.renderMode = "billboard";
|
|
1301
|
+
return def;
|
|
1305
1302
|
}
|
|
1306
1303
|
function createSmokeParticleSystem() {
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1304
|
+
const def = createDefaultParticleSystem("Smoke");
|
|
1305
|
+
def.main.startLifetime = { mode: "randomBetweenTwoConstants", min: 3, max: 5 };
|
|
1306
|
+
def.main.startSize = { mode: "randomBetweenTwoConstants", min: 0.5, max: 1 };
|
|
1307
|
+
def.main.startColor = {
|
|
1308
|
+
mode: "randomBetweenTwoColors",
|
|
1309
|
+
colorMin: [0.5, 0.5, 0.5, 0.5],
|
|
1310
|
+
colorMax: [0.3, 0.3, 0.3, 0.3]
|
|
1311
|
+
};
|
|
1312
|
+
def.main.gravityModifier = { mode: "constant", value: -0.1 };
|
|
1313
|
+
def.emission.rateOverTime = { mode: "constant", value: 20 };
|
|
1314
|
+
def.shape = {
|
|
1315
|
+
type: "circle",
|
|
1316
|
+
radius: 0.3,
|
|
1317
|
+
radiusThickness: 1,
|
|
1318
|
+
arc: 360,
|
|
1319
|
+
arcMode: "random",
|
|
1320
|
+
arcSpeed: 1,
|
|
1321
|
+
position: [0, 0, 0],
|
|
1322
|
+
rotation: [0, 0, 0],
|
|
1323
|
+
scale: [1, 1, 1]
|
|
1324
|
+
};
|
|
1325
|
+
def.sizeOverLifetime = {
|
|
1326
|
+
enabled: true,
|
|
1327
|
+
separateAxes: false,
|
|
1328
|
+
size: {
|
|
1329
|
+
mode: "curve",
|
|
1330
|
+
curve: {
|
|
1331
|
+
keyframes: [
|
|
1332
|
+
{ time: 0, value: 0.3, inTangent: 0, outTangent: 2, mode: "auto" },
|
|
1333
|
+
{ time: 1, value: 3, inTangent: 0.5, outTangent: 0, mode: "auto" }
|
|
1334
|
+
],
|
|
1335
|
+
preWrapMode: "clamp",
|
|
1336
|
+
postWrapMode: "clamp"
|
|
1337
|
+
},
|
|
1338
|
+
multiplier: 1
|
|
1339
|
+
}
|
|
1340
|
+
};
|
|
1341
|
+
def.colorOverLifetime = {
|
|
1342
|
+
enabled: true,
|
|
1343
|
+
color: {
|
|
1344
|
+
mode: "gradient",
|
|
1345
|
+
gradient: {
|
|
1346
|
+
colorKeys: [
|
|
1347
|
+
{ time: 0, color: [0.4, 0.4, 0.4] },
|
|
1348
|
+
{ time: 1, color: [0.6, 0.6, 0.6] }
|
|
1349
|
+
],
|
|
1350
|
+
alphaKeys: [
|
|
1351
|
+
{ time: 0, alpha: 0 },
|
|
1352
|
+
{ time: 0.1, alpha: 0.5 },
|
|
1353
|
+
{ time: 0.8, alpha: 0.3 },
|
|
1354
|
+
{ time: 1, alpha: 0 }
|
|
1355
|
+
],
|
|
1356
|
+
mode: "blend"
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
};
|
|
1360
|
+
def.rotationOverLifetime = {
|
|
1361
|
+
enabled: true,
|
|
1362
|
+
separateAxes: false,
|
|
1363
|
+
angularVelocity: { mode: "randomBetweenTwoConstants", min: -0.5, max: 0.5 }
|
|
1364
|
+
};
|
|
1365
|
+
def.noise = {
|
|
1366
|
+
enabled: true,
|
|
1367
|
+
separateAxes: false,
|
|
1368
|
+
strength: { mode: "constant", value: 0.5 },
|
|
1369
|
+
frequency: 0.3,
|
|
1370
|
+
scrollSpeed: 0.2,
|
|
1371
|
+
damping: true,
|
|
1372
|
+
octaves: 2,
|
|
1373
|
+
octaveMultiplier: 0.5,
|
|
1374
|
+
octaveScale: 2,
|
|
1375
|
+
quality: "medium",
|
|
1376
|
+
remapEnabled: false,
|
|
1377
|
+
remapCurve: { keyframes: [], preWrapMode: "clamp", postWrapMode: "clamp" },
|
|
1378
|
+
positionAmount: { mode: "constant", value: 1 },
|
|
1379
|
+
rotationAmount: { mode: "constant", value: 0 },
|
|
1380
|
+
sizeAmount: { mode: "constant", value: 0 }
|
|
1381
|
+
};
|
|
1382
|
+
return def;
|
|
1386
1383
|
}
|
|
1387
1384
|
function createSparkParticleSystem() {
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1385
|
+
const def = createDefaultParticleSystem("Sparks");
|
|
1386
|
+
def.main.startLifetime = { mode: "randomBetweenTwoConstants", min: 0.2, max: 0.5 };
|
|
1387
|
+
def.main.startSize = { mode: "randomBetweenTwoConstants", min: 0.02, max: 0.05 };
|
|
1388
|
+
def.main.startSpeed = { mode: "randomBetweenTwoConstants", min: 3, max: 8 };
|
|
1389
|
+
def.main.startColor = {
|
|
1390
|
+
mode: "randomBetweenTwoColors",
|
|
1391
|
+
colorMin: [1, 0.8, 0, 1],
|
|
1392
|
+
colorMax: [1, 0.5, 0, 1]
|
|
1393
|
+
};
|
|
1394
|
+
def.main.gravityModifier = { mode: "constant", value: 1 };
|
|
1395
|
+
def.emission.rateOverTime = { mode: "constant", value: 0 };
|
|
1396
|
+
def.emission.bursts = [
|
|
1397
|
+
{
|
|
1398
|
+
time: 0,
|
|
1399
|
+
count: { mode: "randomBetweenTwoConstants", min: 10, max: 30 },
|
|
1400
|
+
cycles: 1,
|
|
1401
|
+
interval: 0.01,
|
|
1402
|
+
probability: 1
|
|
1403
|
+
}
|
|
1404
|
+
];
|
|
1405
|
+
def.shape = {
|
|
1406
|
+
type: "sphere",
|
|
1407
|
+
radius: 0.1,
|
|
1408
|
+
radiusThickness: 0,
|
|
1409
|
+
arc: 360,
|
|
1410
|
+
arcMode: "random",
|
|
1411
|
+
arcSpeed: 1,
|
|
1412
|
+
position: [0, 0, 0],
|
|
1413
|
+
rotation: [0, 0, 0],
|
|
1414
|
+
scale: [1, 1, 1]
|
|
1415
|
+
};
|
|
1416
|
+
def.colorOverLifetime = {
|
|
1417
|
+
enabled: true,
|
|
1418
|
+
color: {
|
|
1419
|
+
mode: "gradient",
|
|
1420
|
+
gradient: {
|
|
1421
|
+
colorKeys: [
|
|
1422
|
+
{ time: 0, color: [1, 0.9, 0.5] },
|
|
1423
|
+
{ time: 0.5, color: [1, 0.5, 0] },
|
|
1424
|
+
{ time: 1, color: [0.5, 0, 0] }
|
|
1425
|
+
],
|
|
1426
|
+
alphaKeys: [
|
|
1427
|
+
{ time: 0, alpha: 1 },
|
|
1428
|
+
{ time: 0.8, alpha: 1 },
|
|
1429
|
+
{ time: 1, alpha: 0 }
|
|
1430
|
+
],
|
|
1431
|
+
mode: "blend"
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
};
|
|
1435
|
+
def.trails = {
|
|
1436
|
+
enabled: true,
|
|
1437
|
+
ratio: 1,
|
|
1438
|
+
lifetime: { mode: "constant", value: 0.1 },
|
|
1439
|
+
minVertexDistance: 0.01,
|
|
1440
|
+
textureMode: "stretch",
|
|
1441
|
+
worldSpace: true,
|
|
1442
|
+
dieWithParticle: true,
|
|
1443
|
+
sizeAffectsWidth: true,
|
|
1444
|
+
sizeAffectsLifetime: false,
|
|
1445
|
+
inheritParticleColor: true,
|
|
1446
|
+
colorOverLifetime: { mode: "color", color: [1, 1, 1, 1] },
|
|
1447
|
+
widthOverTrail: {
|
|
1448
|
+
mode: "curve",
|
|
1449
|
+
curve: {
|
|
1450
|
+
keyframes: [
|
|
1451
|
+
{ time: 0, value: 1, inTangent: 0, outTangent: 0, mode: "auto" },
|
|
1452
|
+
{ time: 1, value: 0, inTangent: -1, outTangent: 0, mode: "auto" }
|
|
1453
|
+
],
|
|
1454
|
+
preWrapMode: "clamp",
|
|
1455
|
+
postWrapMode: "clamp"
|
|
1456
|
+
},
|
|
1457
|
+
multiplier: 1
|
|
1458
|
+
},
|
|
1459
|
+
colorOverTrail: {
|
|
1460
|
+
mode: "gradient",
|
|
1461
|
+
gradient: {
|
|
1462
|
+
colorKeys: [
|
|
1463
|
+
{ time: 0, color: [1, 0.8, 0] },
|
|
1464
|
+
{ time: 1, color: [1, 0.2, 0] }
|
|
1465
|
+
],
|
|
1466
|
+
alphaKeys: [
|
|
1467
|
+
{ time: 0, alpha: 1 },
|
|
1468
|
+
{ time: 1, alpha: 0 }
|
|
1469
|
+
],
|
|
1470
|
+
mode: "blend"
|
|
1471
|
+
}
|
|
1472
|
+
},
|
|
1473
|
+
generateLightingData: false,
|
|
1474
|
+
shadowBias: 0.5
|
|
1475
|
+
};
|
|
1476
|
+
def.collision = {
|
|
1477
|
+
enabled: true,
|
|
1478
|
+
type: "planes",
|
|
1479
|
+
planes: [{ normal: [0, 1, 0], position: [0, 0, 0] }],
|
|
1480
|
+
bounce: { mode: "randomBetweenTwoConstants", min: 0.2, max: 0.6 },
|
|
1481
|
+
lifetimeLoss: { mode: "constant", value: 0.2 },
|
|
1482
|
+
minKillSpeed: 0.1,
|
|
1483
|
+
radiusScale: 1,
|
|
1484
|
+
dampen: { mode: "constant", value: 0.3 },
|
|
1485
|
+
enableDynamicColliders: false,
|
|
1486
|
+
colliderForce: 0,
|
|
1487
|
+
multiplyByCollisionAngle: true,
|
|
1488
|
+
multiplyByParticleSpeed: true,
|
|
1489
|
+
multiplyByParticleSize: false,
|
|
1490
|
+
sendCollisionMessages: false
|
|
1491
|
+
};
|
|
1492
|
+
def.renderer.renderMode = "stretchedBillboard";
|
|
1493
|
+
def.renderer.velocityScale = 0.1;
|
|
1494
|
+
def.renderer.lengthScale = 5;
|
|
1495
|
+
return def;
|
|
1499
1496
|
}
|
|
1500
|
-
|
|
1501
|
-
|
|
1497
|
+
export {
|
|
1498
|
+
ParticleSystem2,
|
|
1499
|
+
createDefaultParticleSystem,
|
|
1500
|
+
createFireParticleSystem,
|
|
1501
|
+
createParticleSystem,
|
|
1502
|
+
createSmokeParticleSystem,
|
|
1503
|
+
createSparkParticleSystem
|
|
1504
|
+
};
|