@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.
Files changed (434) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/accessibility/Accessibility.js +152 -165
  3. package/dist/cjs/ai/AI.js +292 -294
  4. package/dist/cjs/ai/BehaviorTree.js +1029 -1113
  5. package/dist/cjs/ai/StateMachine.js +694 -756
  6. package/dist/cjs/animation/Animation.js +232 -241
  7. package/dist/cjs/audio/AudioAdvanced.js +221 -236
  8. package/dist/cjs/audio/AudioBridge.js +441 -435
  9. package/dist/cjs/audio/AudioManager.js +242 -259
  10. package/dist/cjs/build-cloud/BuildOrchestration.js +1059 -1098
  11. package/dist/cjs/build-cloud/GodotBuildCloud.js +641 -670
  12. package/dist/cjs/build-cloud/UnityBuildCloud.js +563 -610
  13. package/dist/cjs/build-cloud/UnrealBuildCloud.js +610 -635
  14. package/dist/cjs/core/EventBus.js +51 -56
  15. package/dist/cjs/core/GameClock.js +62 -66
  16. package/dist/cjs/core/GameConfig.js +72 -79
  17. package/dist/cjs/core/GameLoop.js +80 -89
  18. package/dist/cjs/core/ServiceLocator.js +61 -65
  19. package/dist/cjs/core/Validation.js +72 -82
  20. package/dist/cjs/core/math.js +108 -112
  21. package/dist/cjs/devtools/DevTools.js +542 -563
  22. package/dist/cjs/devtools/DeveloperExperience.js +521 -559
  23. package/dist/cjs/devtools/GameplayAnalytics.js +636 -646
  24. package/dist/cjs/dialogue/DialogueSystem.js +984 -986
  25. package/dist/cjs/docs/DocGenerator.js +339 -364
  26. package/dist/cjs/ecs/World.js +355 -371
  27. package/dist/cjs/editor/AchievementEditor.js +580 -636
  28. package/dist/cjs/editor/AdvancedEditor.js +184 -191
  29. package/dist/cjs/editor/AnimationRetargeting.js +696 -741
  30. package/dist/cjs/editor/AssetBrowser.js +1072 -1160
  31. package/dist/cjs/editor/AssetManager.js +187 -192
  32. package/dist/cjs/editor/ConsolePro.js +971 -1061
  33. package/dist/cjs/editor/CraftingEditor.js +680 -730
  34. package/dist/cjs/editor/DebugTools.js +187 -185
  35. package/dist/cjs/editor/DialogueSystem.js +844 -901
  36. package/dist/cjs/editor/LeaderboardSystem.js +429 -483
  37. package/dist/cjs/editor/NiceGameEditor.js +1903 -1201
  38. package/dist/cjs/editor/PrefabSystem.js +772 -838
  39. package/dist/cjs/editor/ProfilerPanel.js +649 -700
  40. package/dist/cjs/editor/QuestEditor.js +792 -839
  41. package/dist/cjs/editor/ReplaySystem.js +585 -634
  42. package/dist/cjs/editor/SceneEditor.js +176 -200
  43. package/dist/cjs/editor/ScreenshotMode.js +621 -688
  44. package/dist/cjs/editor/ShaderGraph.js +1556 -1582
  45. package/dist/cjs/editor/TimelineEditor.js +715 -778
  46. package/dist/cjs/editor/UndoRedoPro.js +830 -904
  47. package/dist/cjs/editor/VRARMode.js +582 -645
  48. package/dist/cjs/engine/NiceGameEngine.js +141 -164
  49. package/dist/cjs/engine/SaveSystem.js +441 -495
  50. package/dist/cjs/enterprise/Enterprise.js +254 -261
  51. package/dist/cjs/export/BevyExporter.js +927 -967
  52. package/dist/cjs/export/CocosExporter.js +644 -673
  53. package/dist/cjs/export/Construct3Exporter.js +783 -794
  54. package/dist/cjs/export/DefoldExporter.js +1028 -1069
  55. package/dist/cjs/export/GDevelopExporter.js +674 -708
  56. package/dist/cjs/export/GameMakerExporter.js +791 -805
  57. package/dist/cjs/export/GodotExporter.js +1003 -1045
  58. package/dist/cjs/export/MinecraftBedrockExporter.js +573 -578
  59. package/dist/cjs/export/MonoGameExporter.js +1265 -1293
  60. package/dist/cjs/export/Pico8Exporter.js +766 -812
  61. package/dist/cjs/export/PlatformExporter.js +188 -206
  62. package/dist/cjs/export/RPGMakerExporter.js +860 -879
  63. package/dist/cjs/export/RobloxExporter.js +883 -919
  64. package/dist/cjs/export/Solar2DExporter.js +1218 -1256
  65. package/dist/cjs/export/ThreeJSExporter.js +1006 -1073
  66. package/dist/cjs/export/Tic80Exporter.js +1210 -1267
  67. package/dist/cjs/export/UnityExporter.js +1116 -1131
  68. package/dist/cjs/export/UnrealExporter.js +889 -919
  69. package/dist/cjs/export/WebExporter.js +931 -970
  70. package/dist/cjs/export/index.js +42 -65
  71. package/dist/cjs/godot-integration/GodotAssetLibrary.js +659 -692
  72. package/dist/cjs/godot-integration/GodotImport.js +929 -1027
  73. package/dist/cjs/godot-integration/GodotLiveLink.js +915 -945
  74. package/dist/cjs/godot-integration/components/GodotProjectBrowser.js +911 -611
  75. package/dist/cjs/i18n/I18n.js +860 -900
  76. package/dist/cjs/i18n/useTranslation.js +84 -89
  77. package/dist/cjs/import/AsepriteImporter.js +658 -716
  78. package/dist/cjs/import/DragonBonesImporter.js +437 -461
  79. package/dist/cjs/import/GameMakerImporter.js +511 -521
  80. package/dist/cjs/import/GodotSceneImporter.js +788 -822
  81. package/dist/cjs/import/LDtkImporter.js +436 -454
  82. package/dist/cjs/import/Live2DImporter.js +497 -518
  83. package/dist/cjs/import/NdgFormat.js +424 -457
  84. package/dist/cjs/import/OgmoImporter.js +466 -493
  85. package/dist/cjs/import/RPGMakerImporter.js +451 -477
  86. package/dist/cjs/import/SceneImporter.js +378 -423
  87. package/dist/cjs/import/SpineImporter.js +511 -546
  88. package/dist/cjs/import/SpriterImporter.js +590 -613
  89. package/dist/cjs/import/TiledMapImporter.js +811 -846
  90. package/dist/cjs/import/UnitySceneImporter.js +687 -703
  91. package/dist/cjs/import/index.js +206 -251
  92. package/dist/cjs/index.js +275 -278
  93. package/dist/cjs/input/GamepadNavigation.js +185 -205
  94. package/dist/cjs/input/InputManager.js +397 -421
  95. package/dist/cjs/input/useGamepads.js +70 -81
  96. package/dist/cjs/integration/IconSprite.js +129 -256
  97. package/dist/cjs/inventory/InventorySystem.js +920 -995
  98. package/dist/cjs/kids/KidMode.js +997 -1022
  99. package/dist/cjs/kids/KidTools.js +570 -594
  100. package/dist/cjs/monetization/Monetization.js +170 -177
  101. package/dist/cjs/multiplayer/LocalMultiplayer.js +287 -287
  102. package/dist/cjs/multiplayer/MiniGameTypes.js +49 -59
  103. package/dist/cjs/native-engine/AnimationSystem.js +731 -806
  104. package/dist/cjs/native-engine/AssetPipeline.js +454 -515
  105. package/dist/cjs/native-engine/AudioEngine.js +763 -804
  106. package/dist/cjs/native-engine/InputSystem.js +1075 -1145
  107. package/dist/cjs/native-engine/NetworkingSystem.js +733 -793
  108. package/dist/cjs/native-engine/PhysicsEngine.js +583 -607
  109. package/dist/cjs/native-engine/RenderingEngine.js +302 -350
  110. package/dist/cjs/native-engine/SceneGraph.js +769 -808
  111. package/dist/cjs/network/MultiplayerTransport.js +97 -132
  112. package/dist/cjs/network/Networking.js +549 -564
  113. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AbortController.js +21 -29
  114. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js +40 -48
  115. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +35 -43
  116. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +10 -15
  117. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Errors.js +103 -135
  118. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +131 -158
  119. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +39 -53
  120. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +5 -8
  121. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +40 -48
  122. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +494 -572
  123. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +826 -953
  124. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +125 -146
  125. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +13 -23
  126. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ILogger.js +11 -25
  127. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ITransport.js +13 -24
  128. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +108 -121
  129. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Loggers.js +10 -14
  130. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +150 -185
  131. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js +158 -196
  132. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +90 -105
  133. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Subject.js +30 -35
  134. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +16 -21
  135. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/Utils.js +215 -248
  136. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +135 -157
  137. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +76 -85
  138. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/index.js +24 -27
  139. package/dist/cjs/node_modules/@microsoft/signalr/dist/esm/pkg-version.js +3 -4
  140. package/dist/cjs/pathfinding/Pathfinding.js +245 -263
  141. package/dist/cjs/performance/AssetStreaming.js +561 -635
  142. package/dist/cjs/performance/BenchmarkSuite.js +283 -311
  143. package/dist/cjs/performance/DeltaCompression.js +467 -526
  144. package/dist/cjs/performance/DeterministicPhysics.js +450 -498
  145. package/dist/cjs/performance/ECSOptimization.js +644 -695
  146. package/dist/cjs/performance/GameSaveSystem.js +509 -556
  147. package/dist/cjs/performance/HotReload.js +447 -500
  148. package/dist/cjs/performance/InputRecording.js +511 -561
  149. package/dist/cjs/performance/InterestManagement.js +453 -500
  150. package/dist/cjs/performance/LocalizationRuntime.js +376 -423
  151. package/dist/cjs/performance/MemoryManagement.js +410 -470
  152. package/dist/cjs/performance/ModSupport.js +445 -496
  153. package/dist/cjs/performance/MultiThreadedPhysics.js +400 -443
  154. package/dist/cjs/performance/NetworkPrediction.js +424 -482
  155. package/dist/cjs/performance/ObjectPooling.js +569 -617
  156. package/dist/cjs/performance/Performance.js +174 -190
  157. package/dist/cjs/performance/PerformanceAdvanced.js +614 -637
  158. package/dist/cjs/performance/WebGPURenderer.js +656 -683
  159. package/dist/cjs/physics/PhysicsAdvanced.js +345 -379
  160. package/dist/cjs/physics/PhysicsEngine2D.js +391 -427
  161. package/dist/cjs/plugins/PluginSDK.js +432 -466
  162. package/dist/cjs/plugins/PluginTestKit.js +307 -330
  163. package/dist/cjs/procedural/Procedural.js +243 -254
  164. package/dist/cjs/procedural/WorldBuilding.js +297 -314
  165. package/dist/cjs/quest/QuestSystem.js +975 -932
  166. package/dist/cjs/release/MobileExport.js +157 -163
  167. package/dist/cjs/release/Release.js +225 -238
  168. package/dist/cjs/rendering/Camera2D.js +121 -124
  169. package/dist/cjs/rendering/Renderer2D.js +321 -335
  170. package/dist/cjs/rendering/WebGPURenderPipeline.js +632 -651
  171. package/dist/cjs/runtime3d/Runtime3D.js +359 -378
  172. package/dist/cjs/runtime3d/SceneEditor3D.js +252 -263
  173. package/dist/cjs/scene/SceneManager.js +177 -193
  174. package/dist/cjs/scripting/GraphToAST.js +574 -547
  175. package/dist/cjs/scripting/LanguageExporter.js +254 -279
  176. package/dist/cjs/scripting/NodeGraph.js +546 -570
  177. package/dist/cjs/scripting/ScriptAST.js +31 -39
  178. package/dist/cjs/scripting/VisualScripting2.js +1016 -1065
  179. package/dist/cjs/scripting/exporters/CSharpExporter.js +464 -496
  180. package/dist/cjs/scripting/exporters/GDScriptExporter.js +390 -442
  181. package/dist/cjs/scripting/exporters/LuaExporter.js +406 -447
  182. package/dist/cjs/scripting/exporters/PythonExporter.js +484 -549
  183. package/dist/cjs/scripting/exporters/RustExporter.js +459 -512
  184. package/dist/cjs/scripting/exporters/TypeScriptExporter.js +505 -556
  185. package/dist/cjs/social/Social.js +72 -80
  186. package/dist/cjs/systems/LightingSystem.js +844 -931
  187. package/dist/cjs/systems/ParticleSystem2.js +1447 -1451
  188. package/dist/cjs/systems/PhysicsDebugSystem.js +1070 -1141
  189. package/dist/cjs/systems/TerrainSystem.js +985 -1098
  190. package/dist/cjs/templates/ActionTemplates.js +296 -309
  191. package/dist/cjs/templates/FightingTemplate.js +417 -463
  192. package/dist/cjs/templates/MetroidvaniaTemplate.js +353 -405
  193. package/dist/cjs/templates/PartyTemplates.js +190 -202
  194. package/dist/cjs/templates/PuzzleTemplates.js +245 -261
  195. package/dist/cjs/templates/RPGTemplates.js +160 -178
  196. package/dist/cjs/templates/SportsTemplates.js +237 -250
  197. package/dist/cjs/templates/StrategyTemplates.js +143 -153
  198. package/dist/cjs/templates/SurvivalTemplate.js +336 -380
  199. package/dist/cjs/templates/WaveDefense.js +499 -526
  200. package/dist/cjs/tilemap/Tilemap.js +207 -214
  201. package/dist/cjs/tutorials/TutorialBranching.js +396 -417
  202. package/dist/cjs/tutorials/TutorialEngine.js +888 -931
  203. package/dist/cjs/tutorials/TutorialOverlay.js +602 -640
  204. package/dist/cjs/tutorials/content/Tutorials_T05_T08.js +787 -809
  205. package/dist/cjs/tutorials/content/Tutorials_T09_T11.js +736 -756
  206. package/dist/cjs/tutorials/content/Tutorials_T12_T15.js +754 -778
  207. package/dist/cjs/ui/GameUI.js +295 -312
  208. package/dist/cjs/unity-integration/UnityAssetStore.js +700 -741
  209. package/dist/cjs/unity-integration/UnityImport.js +1066 -1176
  210. package/dist/cjs/unity-integration/UnityLiveLink.js +934 -981
  211. package/dist/cjs/unity-integration/components/UnityAssetStoreBrowser.js +1233 -757
  212. package/dist/cjs/unity-integration/components/UnityProjectBrowser.js +1240 -768
  213. package/dist/cjs/unreal-integration/UnrealImport.js +391 -412
  214. package/dist/cjs/unreal-integration/UnrealLiveLink.js +1102 -1137
  215. package/dist/cjs/unreal-integration/UnrealMarketplace.js +436 -473
  216. package/dist/cjs/unreal-integration/components/UnrealProjectBrowser.js +1150 -767
  217. package/dist/cjs/xr/ARVR.js +167 -175
  218. package/dist/esm/accessibility/Accessibility.js +160 -164
  219. package/dist/esm/ai/AI.js +310 -293
  220. package/dist/esm/ai/BehaviorTree.js +1057 -1112
  221. package/dist/esm/ai/StateMachine.js +709 -755
  222. package/dist/esm/animation/Animation.js +237 -240
  223. package/dist/esm/audio/AudioAdvanced.js +239 -235
  224. package/dist/esm/audio/AudioBridge.js +448 -434
  225. package/dist/esm/audio/AudioManager.js +243 -258
  226. package/dist/esm/build-cloud/BuildOrchestration.js +1071 -1097
  227. package/dist/esm/build-cloud/GodotBuildCloud.js +647 -669
  228. package/dist/esm/build-cloud/UnityBuildCloud.js +571 -609
  229. package/dist/esm/build-cloud/UnrealBuildCloud.js +615 -634
  230. package/dist/esm/core/EventBus.js +52 -55
  231. package/dist/esm/core/GameClock.js +63 -65
  232. package/dist/esm/core/GameConfig.js +77 -78
  233. package/dist/esm/core/GameLoop.js +81 -88
  234. package/dist/esm/core/ServiceLocator.js +63 -64
  235. package/dist/esm/core/Validation.js +82 -81
  236. package/dist/esm/core/math.js +109 -111
  237. package/dist/esm/devtools/DevTools.js +546 -562
  238. package/dist/esm/devtools/DeveloperExperience.js +535 -558
  239. package/dist/esm/devtools/GameplayAnalytics.js +647 -645
  240. package/dist/esm/dialogue/DialogueSystem.js +998 -985
  241. package/dist/esm/docs/DocGenerator.js +342 -363
  242. package/dist/esm/ecs/World.js +358 -370
  243. package/dist/esm/editor/AchievementEditor.js +584 -635
  244. package/dist/esm/editor/AdvancedEditor.js +191 -190
  245. package/dist/esm/editor/AnimationRetargeting.js +700 -740
  246. package/dist/esm/editor/AssetBrowser.js +1078 -1159
  247. package/dist/esm/editor/AssetManager.js +188 -191
  248. package/dist/esm/editor/ConsolePro.js +977 -1060
  249. package/dist/esm/editor/CraftingEditor.js +684 -729
  250. package/dist/esm/editor/DebugTools.js +194 -184
  251. package/dist/esm/editor/DialogueSystem.js +849 -900
  252. package/dist/esm/editor/LeaderboardSystem.js +433 -482
  253. package/dist/esm/editor/NiceGameEditor.js +1908 -1200
  254. package/dist/esm/editor/PrefabSystem.js +777 -837
  255. package/dist/esm/editor/ProfilerPanel.js +654 -699
  256. package/dist/esm/editor/QuestEditor.js +795 -838
  257. package/dist/esm/editor/ReplaySystem.js +591 -633
  258. package/dist/esm/editor/SceneEditor.js +189 -199
  259. package/dist/esm/editor/ScreenshotMode.js +628 -687
  260. package/dist/esm/editor/ShaderGraph.js +1565 -1581
  261. package/dist/esm/editor/TimelineEditor.js +733 -777
  262. package/dist/esm/editor/UndoRedoPro.js +835 -903
  263. package/dist/esm/editor/VRARMode.js +586 -644
  264. package/dist/esm/engine/NiceGameEngine.js +142 -163
  265. package/dist/esm/engine/SaveSystem.js +447 -494
  266. package/dist/esm/enterprise/Enterprise.js +265 -260
  267. package/dist/esm/export/BevyExporter.js +929 -966
  268. package/dist/esm/export/CocosExporter.js +646 -672
  269. package/dist/esm/export/Construct3Exporter.js +785 -793
  270. package/dist/esm/export/DefoldExporter.js +1030 -1068
  271. package/dist/esm/export/GDevelopExporter.js +676 -707
  272. package/dist/esm/export/GameMakerExporter.js +793 -804
  273. package/dist/esm/export/GodotExporter.js +1004 -1044
  274. package/dist/esm/export/MinecraftBedrockExporter.js +575 -577
  275. package/dist/esm/export/MonoGameExporter.js +1267 -1292
  276. package/dist/esm/export/Pico8Exporter.js +768 -811
  277. package/dist/esm/export/PlatformExporter.js +193 -205
  278. package/dist/esm/export/RPGMakerExporter.js +862 -878
  279. package/dist/esm/export/RobloxExporter.js +885 -918
  280. package/dist/esm/export/Solar2DExporter.js +1220 -1255
  281. package/dist/esm/export/ThreeJSExporter.js +1007 -1072
  282. package/dist/esm/export/Tic80Exporter.js +1212 -1266
  283. package/dist/esm/export/UnityExporter.js +1117 -1130
  284. package/dist/esm/export/UnrealExporter.js +891 -918
  285. package/dist/esm/export/WebExporter.js +933 -969
  286. package/dist/esm/export/index.js +86 -71
  287. package/dist/esm/godot-integration/GodotAssetLibrary.js +663 -691
  288. package/dist/esm/godot-integration/GodotImport.js +935 -1026
  289. package/dist/esm/godot-integration/GodotLiveLink.js +918 -944
  290. package/dist/esm/godot-integration/components/GodotProjectBrowser.js +912 -610
  291. package/dist/esm/i18n/I18n.js +871 -899
  292. package/dist/esm/i18n/useTranslation.js +88 -88
  293. package/dist/esm/import/AsepriteImporter.js +637 -715
  294. package/dist/esm/import/DragonBonesImporter.js +417 -460
  295. package/dist/esm/import/GameMakerImporter.js +491 -520
  296. package/dist/esm/import/GodotSceneImporter.js +767 -821
  297. package/dist/esm/import/LDtkImporter.js +415 -453
  298. package/dist/esm/import/Live2DImporter.js +477 -517
  299. package/dist/esm/import/NdgFormat.js +410 -456
  300. package/dist/esm/import/OgmoImporter.js +446 -492
  301. package/dist/esm/import/RPGMakerImporter.js +431 -476
  302. package/dist/esm/import/SceneImporter.js +385 -422
  303. package/dist/esm/import/SpineImporter.js +491 -545
  304. package/dist/esm/import/SpriterImporter.js +570 -612
  305. package/dist/esm/import/TiledMapImporter.js +790 -845
  306. package/dist/esm/import/UnitySceneImporter.js +666 -702
  307. package/dist/esm/import/index.js +247 -258
  308. package/dist/esm/index.js +1332 -188
  309. package/dist/esm/input/GamepadNavigation.js +187 -204
  310. package/dist/esm/input/InputManager.js +401 -420
  311. package/dist/esm/input/useGamepads.js +72 -80
  312. package/dist/esm/integration/IconSprite.js +143 -255
  313. package/dist/esm/inventory/InventorySystem.js +925 -994
  314. package/dist/esm/kids/KidMode.js +1003 -1021
  315. package/dist/esm/kids/KidTools.js +573 -593
  316. package/dist/esm/monetization/Monetization.js +180 -176
  317. package/dist/esm/multiplayer/LocalMultiplayer.js +290 -286
  318. package/dist/esm/multiplayer/MiniGameTypes.js +58 -58
  319. package/dist/esm/native-engine/AnimationSystem.js +735 -805
  320. package/dist/esm/native-engine/AssetPipeline.js +456 -514
  321. package/dist/esm/native-engine/AudioEngine.js +765 -803
  322. package/dist/esm/native-engine/InputSystem.js +1079 -1144
  323. package/dist/esm/native-engine/NetworkingSystem.js +740 -792
  324. package/dist/esm/native-engine/PhysicsEngine.js +585 -606
  325. package/dist/esm/native-engine/RenderingEngine.js +304 -349
  326. package/dist/esm/native-engine/SceneGraph.js +773 -807
  327. package/dist/esm/network/MultiplayerTransport.js +99 -131
  328. package/dist/esm/network/Networking.js +556 -563
  329. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AbortController.js +22 -28
  330. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/AccessTokenHttpClient.js +41 -47
  331. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultHttpClient.js +36 -42
  332. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/DefaultReconnectPolicy.js +11 -14
  333. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Errors.js +111 -134
  334. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/FetchHttpClient.js +132 -157
  335. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HandshakeProtocol.js +40 -52
  336. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HeaderNames.js +6 -7
  337. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpClient.js +42 -47
  338. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HttpConnection.js +496 -571
  339. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnection.js +828 -952
  340. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/HubConnectionBuilder.js +126 -145
  341. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/IHubProtocol.js +14 -23
  342. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ILogger.js +12 -25
  343. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ITransport.js +15 -24
  344. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/JsonHubProtocol.js +109 -120
  345. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Loggers.js +11 -13
  346. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/LongPollingTransport.js +151 -184
  347. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/MessageBuffer.js +159 -195
  348. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/ServerSentEventsTransport.js +91 -104
  349. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Subject.js +31 -34
  350. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/TextMessageFormat.js +17 -20
  351. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/Utils.js +230 -248
  352. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/WebSocketTransport.js +136 -156
  353. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/XhrHttpClient.js +77 -84
  354. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/index.js +31 -12
  355. package/dist/esm/node_modules/@microsoft/signalr/dist/esm/pkg-version.js +4 -3
  356. package/dist/esm/pathfinding/Pathfinding.js +249 -262
  357. package/dist/esm/performance/AssetStreaming.js +567 -634
  358. package/dist/esm/performance/BenchmarkSuite.js +285 -310
  359. package/dist/esm/performance/DeltaCompression.js +478 -525
  360. package/dist/esm/performance/DeterministicPhysics.js +479 -497
  361. package/dist/esm/performance/ECSOptimization.js +653 -694
  362. package/dist/esm/performance/GameSaveSystem.js +515 -555
  363. package/dist/esm/performance/HotReload.js +454 -499
  364. package/dist/esm/performance/InputRecording.js +520 -560
  365. package/dist/esm/performance/InterestManagement.js +460 -499
  366. package/dist/esm/performance/LocalizationRuntime.js +382 -422
  367. package/dist/esm/performance/MemoryManagement.js +415 -469
  368. package/dist/esm/performance/ModSupport.js +455 -495
  369. package/dist/esm/performance/MultiThreadedPhysics.js +408 -442
  370. package/dist/esm/performance/NetworkPrediction.js +436 -481
  371. package/dist/esm/performance/ObjectPooling.js +582 -616
  372. package/dist/esm/performance/Performance.js +182 -189
  373. package/dist/esm/performance/PerformanceAdvanced.js +621 -636
  374. package/dist/esm/performance/WebGPURenderer.js +660 -682
  375. package/dist/esm/physics/PhysicsAdvanced.js +359 -378
  376. package/dist/esm/physics/PhysicsEngine2D.js +393 -426
  377. package/dist/esm/plugins/PluginSDK.js +435 -465
  378. package/dist/esm/plugins/PluginTestKit.js +315 -329
  379. package/dist/esm/procedural/Procedural.js +248 -253
  380. package/dist/esm/procedural/WorldBuilding.js +316 -313
  381. package/dist/esm/quest/QuestSystem.js +982 -931
  382. package/dist/esm/release/MobileExport.js +163 -162
  383. package/dist/esm/release/Release.js +234 -237
  384. package/dist/esm/rendering/Camera2D.js +122 -123
  385. package/dist/esm/rendering/Renderer2D.js +323 -334
  386. package/dist/esm/rendering/WebGPURenderPipeline.js +647 -650
  387. package/dist/esm/runtime3d/Runtime3D.js +368 -377
  388. package/dist/esm/runtime3d/SceneEditor3D.js +268 -262
  389. package/dist/esm/scene/SceneManager.js +178 -192
  390. package/dist/esm/scripting/GraphToAST.js +576 -546
  391. package/dist/esm/scripting/LanguageExporter.js +263 -278
  392. package/dist/esm/scripting/NodeGraph.js +550 -569
  393. package/dist/esm/scripting/ScriptAST.js +45 -38
  394. package/dist/esm/scripting/VisualScripting2.js +1025 -1064
  395. package/dist/esm/scripting/exporters/CSharpExporter.js +465 -495
  396. package/dist/esm/scripting/exporters/GDScriptExporter.js +391 -441
  397. package/dist/esm/scripting/exporters/LuaExporter.js +407 -446
  398. package/dist/esm/scripting/exporters/PythonExporter.js +485 -548
  399. package/dist/esm/scripting/exporters/RustExporter.js +460 -511
  400. package/dist/esm/scripting/exporters/TypeScriptExporter.js +506 -555
  401. package/dist/esm/social/Social.js +77 -79
  402. package/dist/esm/systems/LightingSystem.js +855 -930
  403. package/dist/esm/systems/ParticleSystem2.js +1453 -1450
  404. package/dist/esm/systems/PhysicsDebugSystem.js +1078 -1140
  405. package/dist/esm/systems/TerrainSystem.js +996 -1097
  406. package/dist/esm/templates/ActionTemplates.js +307 -308
  407. package/dist/esm/templates/FightingTemplate.js +439 -462
  408. package/dist/esm/templates/MetroidvaniaTemplate.js +391 -404
  409. package/dist/esm/templates/PartyTemplates.js +206 -201
  410. package/dist/esm/templates/PuzzleTemplates.js +260 -260
  411. package/dist/esm/templates/RPGTemplates.js +172 -177
  412. package/dist/esm/templates/SportsTemplates.js +251 -249
  413. package/dist/esm/templates/StrategyTemplates.js +158 -152
  414. package/dist/esm/templates/SurvivalTemplate.js +367 -379
  415. package/dist/esm/templates/WaveDefense.js +501 -525
  416. package/dist/esm/tilemap/Tilemap.js +209 -213
  417. package/dist/esm/tutorials/TutorialBranching.js +399 -416
  418. package/dist/esm/tutorials/TutorialEngine.js +893 -930
  419. package/dist/esm/tutorials/TutorialOverlay.js +603 -639
  420. package/dist/esm/tutorials/content/Tutorials_T05_T08.js +792 -808
  421. package/dist/esm/tutorials/content/Tutorials_T09_T11.js +740 -755
  422. package/dist/esm/tutorials/content/Tutorials_T12_T15.js +759 -777
  423. package/dist/esm/ui/GameUI.js +296 -311
  424. package/dist/esm/unity-integration/UnityAssetStore.js +704 -740
  425. package/dist/esm/unity-integration/UnityImport.js +1071 -1175
  426. package/dist/esm/unity-integration/UnityLiveLink.js +938 -980
  427. package/dist/esm/unity-integration/components/UnityAssetStoreBrowser.js +1234 -756
  428. package/dist/esm/unity-integration/components/UnityProjectBrowser.js +1241 -767
  429. package/dist/esm/unreal-integration/UnrealImport.js +395 -411
  430. package/dist/esm/unreal-integration/UnrealLiveLink.js +1105 -1136
  431. package/dist/esm/unreal-integration/UnrealMarketplace.js +442 -472
  432. package/dist/esm/unreal-integration/components/UnrealProjectBrowser.js +1151 -766
  433. package/dist/esm/xr/ARVR.js +181 -174
  434. package/package.json +7 -12
@@ -1,856 +1,822 @@
1
- /**
2
- * @file SceneGraph.ts
3
- * @description Scene Graph system for Nice2Dev Game Engine
4
- * PRO-1.11.1: Core Engine Systems - Scene Graph
5
- *
6
- * Features:
7
- * - Hierarchical transforms
8
- * - Frustum culling
9
- * - Octree/BVH spatial partitioning
10
- * - Instanced rendering support
11
- * - LOD system
12
- */
13
- class SceneNode {
14
- constructor(name, type = 'empty') {
15
- this.parent = null;
16
- this.children = [];
17
- this.visible = true;
18
- this.castShadows = true;
19
- this.receiveShadows = true;
20
- this.layer = 0;
21
- this.tags = new Set();
22
- this.data = {};
23
- this.currentLODLevel = 0;
24
- this.id = `node_${SceneNode.nextId++}`;
25
- this.name = name;
26
- this.type = type;
27
- this.transform = {
28
- position: { x: 0, y: 0, z: 0 },
29
- rotation: { x: 0, y: 0, z: 0, w: 1 },
30
- scale: { x: 1, y: 1, z: 1 },
31
- localMatrix: new Float32Array(16),
32
- worldMatrix: new Float32Array(16),
33
- dirty: true,
34
- };
35
- this.localBounds = {
36
- min: { x: -0.5, y: -0.5, z: -0.5 },
37
- max: { x: 0.5, y: 0.5, z: 0.5 },
38
- };
39
- this.worldBounds = { ...this.localBounds };
40
- this.boundingSphere = {
41
- center: { x: 0, y: 0, z: 0 },
42
- radius: 0.866,
43
- };
44
- mat4Identity(this.transform.localMatrix);
45
- mat4Identity(this.transform.worldMatrix);
46
- }
47
- // ─── Transform Methods ─────────────────────────────────
48
- setPosition(x, y, z) {
49
- this.transform.position.x = x;
50
- this.transform.position.y = y;
51
- this.transform.position.z = z;
52
- this.markDirty();
53
- }
54
- setRotation(x, y, z, w) {
55
- this.transform.rotation.x = x;
56
- this.transform.rotation.y = y;
57
- this.transform.rotation.z = z;
58
- this.transform.rotation.w = w;
59
- this.markDirty();
60
- }
61
- setRotationEuler(pitch, yaw, roll) {
62
- eulerToQuaternion(pitch, yaw, roll, this.transform.rotation);
63
- this.markDirty();
64
- }
65
- setScale(x, y, z) {
66
- this.transform.scale.x = x;
67
- this.transform.scale.y = y;
68
- this.transform.scale.z = z;
69
- this.markDirty();
70
- }
71
- translate(x, y, z) {
72
- this.transform.position.x += x;
73
- this.transform.position.y += y;
74
- this.transform.position.z += z;
75
- this.markDirty();
76
- }
77
- rotate(x, y, z, w) {
78
- const q = this.transform.rotation;
79
- const result = quaternionMultiply(q, { x, y, z, w });
80
- this.transform.rotation.x = result.x;
81
- this.transform.rotation.y = result.y;
82
- this.transform.rotation.z = result.z;
83
- this.transform.rotation.w = result.w;
84
- this.markDirty();
85
- }
86
- lookAt(target, up = { x: 0, y: 1, z: 0 }) {
87
- const forward = vec3Normalize(vec3Subtract(target, this.transform.position));
88
- const right = vec3Normalize(vec3Cross(up, forward));
89
- const newUp = vec3Cross(forward, right);
90
- // Convert rotation matrix to quaternion
91
- this.transform.rotation = matrixToQuaternion(right, newUp, forward);
92
- this.markDirty();
93
- }
94
- getWorldPosition() {
95
- this.updateWorldMatrix();
96
- return {
97
- x: this.transform.worldMatrix[12],
98
- y: this.transform.worldMatrix[13],
99
- z: this.transform.worldMatrix[14],
100
- };
101
- }
102
- getForward() {
103
- this.updateWorldMatrix();
104
- return vec3Normalize({
105
- x: -this.transform.worldMatrix[8],
106
- y: -this.transform.worldMatrix[9],
107
- z: -this.transform.worldMatrix[10],
108
- });
109
- }
110
- getRight() {
111
- this.updateWorldMatrix();
112
- return vec3Normalize({
113
- x: this.transform.worldMatrix[0],
114
- y: this.transform.worldMatrix[1],
115
- z: this.transform.worldMatrix[2],
116
- });
117
- }
118
- getUp() {
119
- this.updateWorldMatrix();
120
- return vec3Normalize({
121
- x: this.transform.worldMatrix[4],
122
- y: this.transform.worldMatrix[5],
123
- z: this.transform.worldMatrix[6],
124
- });
125
- }
126
- markDirty() {
127
- this.transform.dirty = true;
128
- for (const child of this.children) {
129
- child.markDirty();
130
- }
131
- }
132
- updateLocalMatrix() {
133
- // Compose TRS matrix
134
- mat4Compose(this.transform.position, this.transform.rotation, this.transform.scale, this.transform.localMatrix);
135
- }
136
- updateWorldMatrix() {
137
- if (!this.transform.dirty) {
138
- return;
139
- }
140
- this.updateLocalMatrix();
141
- if (this.parent) {
142
- this.parent.updateWorldMatrix();
143
- mat4Multiply(this.parent.transform.worldMatrix, this.transform.localMatrix, this.transform.worldMatrix);
144
- }
145
- else {
146
- mat4Copy(this.transform.localMatrix, this.transform.worldMatrix);
147
- }
148
- this.updateWorldBounds();
149
- this.transform.dirty = false;
150
- }
151
- updateWorldBounds() {
152
- // Transform local AABB by world matrix to get world AABB
153
- const corners = getAABBCorners(this.localBounds);
154
- const transformedCorners = corners.map((c) => transformPoint(c, this.transform.worldMatrix));
155
- this.worldBounds.min = { x: Infinity, y: Infinity, z: Infinity };
156
- this.worldBounds.max = { x: -Infinity, y: -Infinity, z: -Infinity };
157
- for (const corner of transformedCorners) {
158
- this.worldBounds.min.x = Math.min(this.worldBounds.min.x, corner.x);
159
- this.worldBounds.min.y = Math.min(this.worldBounds.min.y, corner.y);
160
- this.worldBounds.min.z = Math.min(this.worldBounds.min.z, corner.z);
161
- this.worldBounds.max.x = Math.max(this.worldBounds.max.x, corner.x);
162
- this.worldBounds.max.y = Math.max(this.worldBounds.max.y, corner.y);
163
- this.worldBounds.max.z = Math.max(this.worldBounds.max.z, corner.z);
164
- }
165
- // Update bounding sphere
166
- this.boundingSphere.center = {
167
- x: (this.worldBounds.min.x + this.worldBounds.max.x) / 2,
168
- y: (this.worldBounds.min.y + this.worldBounds.max.y) / 2,
169
- z: (this.worldBounds.min.z + this.worldBounds.max.z) / 2,
170
- };
171
- const dx = this.worldBounds.max.x - this.boundingSphere.center.x;
172
- const dy = this.worldBounds.max.y - this.boundingSphere.center.y;
173
- const dz = this.worldBounds.max.z - this.boundingSphere.center.z;
174
- this.boundingSphere.radius = Math.sqrt(dx * dx + dy * dy + dz * dz);
175
- }
176
- // ─── Hierarchy Methods ─────────────────────────────────
177
- addChild(node) {
178
- if (node.parent) {
179
- node.parent.removeChild(node);
180
- }
181
- node.parent = this;
182
- this.children.push(node);
183
- node.markDirty();
184
- }
185
- removeChild(node) {
186
- const index = this.children.indexOf(node);
187
- if (index >= 0) {
188
- this.children.splice(index, 1);
189
- node.parent = null;
190
- node.markDirty();
191
- }
192
- }
193
- removeFromParent() {
194
- if (this.parent) {
195
- this.parent.removeChild(this);
196
- }
197
- }
198
- getRoot() {
199
- // eslint-disable-next-line @typescript-eslint/no-this-alias
200
- let node = this;
201
- while (node.parent) {
202
- node = node.parent;
203
- }
204
- return node;
205
- }
206
- findByName(name) {
207
- if (this.name === name) {
208
- return this;
209
- }
210
- for (const child of this.children) {
211
- const found = child.findByName(name);
212
- if (found) {
213
- return found;
214
- }
215
- }
216
- return null;
217
- }
218
- findById(id) {
219
- if (this.id === id) {
220
- return this;
221
- }
222
- for (const child of this.children) {
223
- const found = child.findById(id);
224
- if (found) {
225
- return found;
226
- }
227
- }
228
- return null;
229
- }
230
- findByTag(tag) {
231
- const results = [];
232
- this.collectByTag(tag, results);
233
- return results;
234
- }
235
- collectByTag(tag, results) {
236
- if (this.tags.has(tag)) {
237
- results.push(this);
238
- }
239
- for (const child of this.children) {
240
- child.collectByTag(tag, results);
241
- }
242
- }
243
- traverse(callback) {
244
- if (callback(this) === false) {
245
- return;
246
- }
247
- for (const child of this.children) {
248
- child.traverse(callback);
249
- }
250
- }
251
- traverseVisible(callback) {
252
- if (!this.visible) {
253
- return;
254
- }
255
- if (callback(this) === false) {
256
- return;
257
- }
258
- for (const child of this.children) {
259
- child.traverseVisible(callback);
260
- }
261
- }
262
- // ─── LOD Methods ───────────────────────────────────────
263
- setLOD(config) {
264
- this.lod = config;
265
- }
266
- updateLOD(cameraPosition) {
267
- if (!this.lod) {
268
- return;
269
- }
270
- const worldPos = this.getWorldPosition();
271
- const distance = vec3Distance(worldPos, cameraPosition);
272
- let newLevel = 0;
273
- for (let i = 0; i < this.lod.levels.length; i++) {
274
- if (distance > this.lod.levels[i].distance) {
275
- newLevel = i;
276
- }
277
- else {
278
- break;
279
- }
280
- }
281
- this.currentLODLevel = newLevel;
282
- }
283
- // ─── Clone ─────────────────────────────────────────────
284
- clone(deep = true) {
285
- const clone = new SceneNode(this.name, this.type);
286
- clone.visible = this.visible;
287
- clone.castShadows = this.castShadows;
288
- clone.receiveShadows = this.receiveShadows;
289
- clone.layer = this.layer;
290
- clone.tags = new Set(this.tags);
291
- clone.data = { ...this.data };
292
- clone.instanceGroup = this.instanceGroup;
293
- clone.transform.position = { ...this.transform.position };
294
- clone.transform.rotation = { ...this.transform.rotation };
295
- clone.transform.scale = { ...this.transform.scale };
296
- clone.localBounds = {
297
- min: { ...this.localBounds.min },
298
- max: { ...this.localBounds.max },
299
- };
300
- if (this.lod) {
301
- clone.lod = {
302
- ...this.lod,
303
- levels: this.lod.levels.map((l) => ({ ...l })),
304
- };
305
- }
306
- if (deep) {
307
- for (const child of this.children) {
308
- clone.addChild(child.clone(true));
309
- }
310
- }
311
- return clone;
312
- }
313
- }
314
- SceneNode.nextId = 0;
1
+ const _SceneNode = class _SceneNode {
2
+ constructor(name, type = "empty") {
3
+ this.parent = null;
4
+ this.children = [];
5
+ this.visible = true;
6
+ this.castShadows = true;
7
+ this.receiveShadows = true;
8
+ this.layer = 0;
9
+ this.tags = /* @__PURE__ */ new Set();
10
+ this.data = {};
11
+ this.currentLODLevel = 0;
12
+ this.id = `node_${_SceneNode.nextId++}`;
13
+ this.name = name;
14
+ this.type = type;
15
+ this.transform = {
16
+ position: { x: 0, y: 0, z: 0 },
17
+ rotation: { x: 0, y: 0, z: 0, w: 1 },
18
+ scale: { x: 1, y: 1, z: 1 },
19
+ localMatrix: new Float32Array(16),
20
+ worldMatrix: new Float32Array(16),
21
+ dirty: true
22
+ };
23
+ this.localBounds = {
24
+ min: { x: -0.5, y: -0.5, z: -0.5 },
25
+ max: { x: 0.5, y: 0.5, z: 0.5 }
26
+ };
27
+ this.worldBounds = { ...this.localBounds };
28
+ this.boundingSphere = {
29
+ center: { x: 0, y: 0, z: 0 },
30
+ radius: 0.866
31
+ };
32
+ mat4Identity(this.transform.localMatrix);
33
+ mat4Identity(this.transform.worldMatrix);
34
+ }
35
+ // ─── Transform Methods ─────────────────────────────────
36
+ setPosition(x, y, z) {
37
+ this.transform.position.x = x;
38
+ this.transform.position.y = y;
39
+ this.transform.position.z = z;
40
+ this.markDirty();
41
+ }
42
+ setRotation(x, y, z, w) {
43
+ this.transform.rotation.x = x;
44
+ this.transform.rotation.y = y;
45
+ this.transform.rotation.z = z;
46
+ this.transform.rotation.w = w;
47
+ this.markDirty();
48
+ }
49
+ setRotationEuler(pitch, yaw, roll) {
50
+ eulerToQuaternion(pitch, yaw, roll, this.transform.rotation);
51
+ this.markDirty();
52
+ }
53
+ setScale(x, y, z) {
54
+ this.transform.scale.x = x;
55
+ this.transform.scale.y = y;
56
+ this.transform.scale.z = z;
57
+ this.markDirty();
58
+ }
59
+ translate(x, y, z) {
60
+ this.transform.position.x += x;
61
+ this.transform.position.y += y;
62
+ this.transform.position.z += z;
63
+ this.markDirty();
64
+ }
65
+ rotate(x, y, z, w) {
66
+ const q = this.transform.rotation;
67
+ const result = quaternionMultiply(q, { x, y, z, w });
68
+ this.transform.rotation.x = result.x;
69
+ this.transform.rotation.y = result.y;
70
+ this.transform.rotation.z = result.z;
71
+ this.transform.rotation.w = result.w;
72
+ this.markDirty();
73
+ }
74
+ lookAt(target, up = { x: 0, y: 1, z: 0 }) {
75
+ const forward = vec3Normalize(vec3Subtract(target, this.transform.position));
76
+ const right = vec3Normalize(vec3Cross(up, forward));
77
+ const newUp = vec3Cross(forward, right);
78
+ this.transform.rotation = matrixToQuaternion(right, newUp, forward);
79
+ this.markDirty();
80
+ }
81
+ getWorldPosition() {
82
+ this.updateWorldMatrix();
83
+ return {
84
+ x: this.transform.worldMatrix[12],
85
+ y: this.transform.worldMatrix[13],
86
+ z: this.transform.worldMatrix[14]
87
+ };
88
+ }
89
+ getForward() {
90
+ this.updateWorldMatrix();
91
+ return vec3Normalize({
92
+ x: -this.transform.worldMatrix[8],
93
+ y: -this.transform.worldMatrix[9],
94
+ z: -this.transform.worldMatrix[10]
95
+ });
96
+ }
97
+ getRight() {
98
+ this.updateWorldMatrix();
99
+ return vec3Normalize({
100
+ x: this.transform.worldMatrix[0],
101
+ y: this.transform.worldMatrix[1],
102
+ z: this.transform.worldMatrix[2]
103
+ });
104
+ }
105
+ getUp() {
106
+ this.updateWorldMatrix();
107
+ return vec3Normalize({
108
+ x: this.transform.worldMatrix[4],
109
+ y: this.transform.worldMatrix[5],
110
+ z: this.transform.worldMatrix[6]
111
+ });
112
+ }
113
+ markDirty() {
114
+ this.transform.dirty = true;
115
+ for (const child of this.children) {
116
+ child.markDirty();
117
+ }
118
+ }
119
+ updateLocalMatrix() {
120
+ mat4Compose(
121
+ this.transform.position,
122
+ this.transform.rotation,
123
+ this.transform.scale,
124
+ this.transform.localMatrix
125
+ );
126
+ }
127
+ updateWorldMatrix() {
128
+ if (!this.transform.dirty) {
129
+ return;
130
+ }
131
+ this.updateLocalMatrix();
132
+ if (this.parent) {
133
+ this.parent.updateWorldMatrix();
134
+ mat4Multiply(
135
+ this.parent.transform.worldMatrix,
136
+ this.transform.localMatrix,
137
+ this.transform.worldMatrix
138
+ );
139
+ } else {
140
+ mat4Copy(this.transform.localMatrix, this.transform.worldMatrix);
141
+ }
142
+ this.updateWorldBounds();
143
+ this.transform.dirty = false;
144
+ }
145
+ updateWorldBounds() {
146
+ const corners = getAABBCorners(this.localBounds);
147
+ const transformedCorners = corners.map((c) => transformPoint(c, this.transform.worldMatrix));
148
+ this.worldBounds.min = { x: Infinity, y: Infinity, z: Infinity };
149
+ this.worldBounds.max = { x: -Infinity, y: -Infinity, z: -Infinity };
150
+ for (const corner of transformedCorners) {
151
+ this.worldBounds.min.x = Math.min(this.worldBounds.min.x, corner.x);
152
+ this.worldBounds.min.y = Math.min(this.worldBounds.min.y, corner.y);
153
+ this.worldBounds.min.z = Math.min(this.worldBounds.min.z, corner.z);
154
+ this.worldBounds.max.x = Math.max(this.worldBounds.max.x, corner.x);
155
+ this.worldBounds.max.y = Math.max(this.worldBounds.max.y, corner.y);
156
+ this.worldBounds.max.z = Math.max(this.worldBounds.max.z, corner.z);
157
+ }
158
+ this.boundingSphere.center = {
159
+ x: (this.worldBounds.min.x + this.worldBounds.max.x) / 2,
160
+ y: (this.worldBounds.min.y + this.worldBounds.max.y) / 2,
161
+ z: (this.worldBounds.min.z + this.worldBounds.max.z) / 2
162
+ };
163
+ const dx = this.worldBounds.max.x - this.boundingSphere.center.x;
164
+ const dy = this.worldBounds.max.y - this.boundingSphere.center.y;
165
+ const dz = this.worldBounds.max.z - this.boundingSphere.center.z;
166
+ this.boundingSphere.radius = Math.sqrt(dx * dx + dy * dy + dz * dz);
167
+ }
168
+ // ─── Hierarchy Methods ─────────────────────────────────
169
+ addChild(node) {
170
+ if (node.parent) {
171
+ node.parent.removeChild(node);
172
+ }
173
+ node.parent = this;
174
+ this.children.push(node);
175
+ node.markDirty();
176
+ }
177
+ removeChild(node) {
178
+ const index = this.children.indexOf(node);
179
+ if (index >= 0) {
180
+ this.children.splice(index, 1);
181
+ node.parent = null;
182
+ node.markDirty();
183
+ }
184
+ }
185
+ removeFromParent() {
186
+ if (this.parent) {
187
+ this.parent.removeChild(this);
188
+ }
189
+ }
190
+ getRoot() {
191
+ let node = this;
192
+ while (node.parent) {
193
+ node = node.parent;
194
+ }
195
+ return node;
196
+ }
197
+ findByName(name) {
198
+ if (this.name === name) {
199
+ return this;
200
+ }
201
+ for (const child of this.children) {
202
+ const found = child.findByName(name);
203
+ if (found) {
204
+ return found;
205
+ }
206
+ }
207
+ return null;
208
+ }
209
+ findById(id) {
210
+ if (this.id === id) {
211
+ return this;
212
+ }
213
+ for (const child of this.children) {
214
+ const found = child.findById(id);
215
+ if (found) {
216
+ return found;
217
+ }
218
+ }
219
+ return null;
220
+ }
221
+ findByTag(tag) {
222
+ const results = [];
223
+ this.collectByTag(tag, results);
224
+ return results;
225
+ }
226
+ collectByTag(tag, results) {
227
+ if (this.tags.has(tag)) {
228
+ results.push(this);
229
+ }
230
+ for (const child of this.children) {
231
+ child.collectByTag(tag, results);
232
+ }
233
+ }
234
+ traverse(callback) {
235
+ if (callback(this) === false) {
236
+ return;
237
+ }
238
+ for (const child of this.children) {
239
+ child.traverse(callback);
240
+ }
241
+ }
242
+ traverseVisible(callback) {
243
+ if (!this.visible) {
244
+ return;
245
+ }
246
+ if (callback(this) === false) {
247
+ return;
248
+ }
249
+ for (const child of this.children) {
250
+ child.traverseVisible(callback);
251
+ }
252
+ }
253
+ // ─── LOD Methods ───────────────────────────────────────
254
+ setLOD(config) {
255
+ this.lod = config;
256
+ }
257
+ updateLOD(cameraPosition) {
258
+ if (!this.lod) {
259
+ return;
260
+ }
261
+ const worldPos = this.getWorldPosition();
262
+ const distance = vec3Distance(worldPos, cameraPosition);
263
+ let newLevel = 0;
264
+ for (let i = 0; i < this.lod.levels.length; i++) {
265
+ if (distance > this.lod.levels[i].distance) {
266
+ newLevel = i;
267
+ } else {
268
+ break;
269
+ }
270
+ }
271
+ this.currentLODLevel = newLevel;
272
+ }
273
+ // ─── Clone ─────────────────────────────────────────────
274
+ clone(deep = true) {
275
+ const clone = new _SceneNode(this.name, this.type);
276
+ clone.visible = this.visible;
277
+ clone.castShadows = this.castShadows;
278
+ clone.receiveShadows = this.receiveShadows;
279
+ clone.layer = this.layer;
280
+ clone.tags = new Set(this.tags);
281
+ clone.data = { ...this.data };
282
+ clone.instanceGroup = this.instanceGroup;
283
+ clone.transform.position = { ...this.transform.position };
284
+ clone.transform.rotation = { ...this.transform.rotation };
285
+ clone.transform.scale = { ...this.transform.scale };
286
+ clone.localBounds = {
287
+ min: { ...this.localBounds.min },
288
+ max: { ...this.localBounds.max }
289
+ };
290
+ if (this.lod) {
291
+ clone.lod = {
292
+ ...this.lod,
293
+ levels: this.lod.levels.map((l) => ({ ...l }))
294
+ };
295
+ }
296
+ if (deep) {
297
+ for (const child of this.children) {
298
+ clone.addChild(child.clone(true));
299
+ }
300
+ }
301
+ return clone;
302
+ }
303
+ };
304
+ _SceneNode.nextId = 0;
305
+ let SceneNode = _SceneNode;
315
306
  class Octree {
316
- constructor(bounds, config) {
317
- this.nodePool = [];
318
- this.config = {
319
- maxDepth: 8,
320
- maxObjectsPerNode: 8,
321
- looseness: 1.25,
322
- minSize: 1,
323
- ...config,
324
- };
325
- this.root = this.createNode(bounds, 0);
326
- }
327
- createNode(bounds, depth) {
328
- const node = this.nodePool.pop() ?? new OctreeNode();
329
- node.bounds = bounds;
330
- node.depth = depth;
331
- node.objects = [];
332
- node.children = null;
333
- return node;
334
- }
335
- releaseNode(node) {
336
- if (node.children) {
337
- for (const child of node.children) {
338
- this.releaseNode(child);
339
- }
340
- }
341
- node.objects = [];
342
- node.children = null;
343
- this.nodePool.push(node);
344
- }
345
- insert(node) {
346
- this.insertIntoNode(this.root, node);
347
- }
348
- insertIntoNode(octreeNode, sceneNode) {
349
- // Check if node fits in any child
350
- if (octreeNode.children) {
351
- const childIndex = this.getChildIndex(octreeNode, sceneNode.worldBounds);
352
- if (childIndex >= 0) {
353
- this.insertIntoNode(octreeNode.children[childIndex], sceneNode);
354
- return;
355
- }
356
- }
357
- // Add to this node
358
- octreeNode.objects.push(sceneNode);
359
- // Split if needed
360
- if (!octreeNode.children &&
361
- octreeNode.objects.length > this.config.maxObjectsPerNode &&
362
- octreeNode.depth < this.config.maxDepth) {
363
- this.split(octreeNode);
364
- }
365
- }
366
- split(node) {
367
- const center = {
368
- x: (node.bounds.min.x + node.bounds.max.x) / 2,
369
- y: (node.bounds.min.y + node.bounds.max.y) / 2,
370
- z: (node.bounds.min.z + node.bounds.max.z) / 2,
371
- };
372
- node.children = [];
373
- for (let i = 0; i < 8; i++) {
374
- const childBounds = {
375
- min: {
376
- x: i & 1 ? center.x : node.bounds.min.x,
377
- y: i & 2 ? center.y : node.bounds.min.y,
378
- z: i & 4 ? center.z : node.bounds.min.z,
379
- },
380
- max: {
381
- x: i & 1 ? node.bounds.max.x : center.x,
382
- y: i & 2 ? node.bounds.max.y : center.y,
383
- z: i & 4 ? node.bounds.max.z : center.z,
384
- },
385
- };
386
- node.children.push(this.createNode(childBounds, node.depth + 1));
387
- }
388
- // Redistribute objects
389
- const objects = node.objects;
390
- node.objects = [];
391
- for (const obj of objects) {
392
- this.insertIntoNode(node, obj);
393
- }
394
- }
395
- getChildIndex(octreeNode, bounds) {
396
- if (!octreeNode.children) {
397
- return -1;
398
- }
399
- const center = {
400
- x: (octreeNode.bounds.min.x + octreeNode.bounds.max.x) / 2,
401
- y: (octreeNode.bounds.min.y + octreeNode.bounds.max.y) / 2,
402
- z: (octreeNode.bounds.min.z + octreeNode.bounds.max.z) / 2,
403
- };
404
- // Check if bounds fits entirely in one octant
405
- const minX = bounds.min.x >= center.x;
406
- const maxX = bounds.max.x <= center.x;
407
- const minY = bounds.min.y >= center.y;
408
- const maxY = bounds.max.y <= center.y;
409
- const minZ = bounds.min.z >= center.z;
410
- const maxZ = bounds.max.z <= center.z;
411
- if ((minX || maxX) && (minY || maxY) && (minZ || maxZ)) {
412
- return (minX ? 1 : 0) | (minY ? 2 : 0) | (minZ ? 4 : 0);
413
- }
414
- return -1;
415
- }
416
- remove(node) {
417
- this.removeFromNode(this.root, node);
418
- }
419
- removeFromNode(octreeNode, sceneNode) {
420
- const index = octreeNode.objects.indexOf(sceneNode);
421
- if (index >= 0) {
422
- octreeNode.objects.splice(index, 1);
423
- return true;
424
- }
425
- if (octreeNode.children) {
426
- for (const child of octreeNode.children) {
427
- if (this.removeFromNode(child, sceneNode)) {
428
- return true;
429
- }
430
- }
431
- }
432
- return false;
433
- }
434
- update(node) {
435
- this.remove(node);
436
- this.insert(node);
437
- }
438
- queryFrustum(frustum) {
439
- const results = [];
440
- this.queryFrustumNode(this.root, frustum, results);
441
- return results;
442
- }
443
- queryFrustumNode(octreeNode, frustum, results) {
444
- const result = frustumAABBIntersection(frustum, octreeNode.bounds);
445
- if (result === 'outside') {
446
- return;
447
- }
448
- if (result === 'inside') {
449
- // All objects in this node and children are visible
450
- this.collectAllObjects(octreeNode, results);
451
- return;
452
- }
453
- // Intersecting - test each object
454
- for (const obj of octreeNode.objects) {
455
- if (frustumSphereIntersection(frustum, obj.boundingSphere) !== 'outside') {
456
- results.push(obj);
457
- }
458
- }
459
- if (octreeNode.children) {
460
- for (const child of octreeNode.children) {
461
- this.queryFrustumNode(child, frustum, results);
462
- }
463
- }
464
- }
465
- collectAllObjects(octreeNode, results) {
466
- results.push(...octreeNode.objects);
467
- if (octreeNode.children) {
468
- for (const child of octreeNode.children) {
469
- this.collectAllObjects(child, results);
470
- }
471
- }
472
- }
473
- queryAABB(bounds) {
474
- const results = [];
475
- this.queryAABBNode(this.root, bounds, results);
476
- return results;
477
- }
478
- queryAABBNode(octreeNode, bounds, results) {
479
- if (!aabbIntersects(octreeNode.bounds, bounds)) {
480
- return;
481
- }
482
- for (const obj of octreeNode.objects) {
483
- if (aabbIntersects(obj.worldBounds, bounds)) {
484
- results.push(obj);
485
- }
486
- }
487
- if (octreeNode.children) {
488
- for (const child of octreeNode.children) {
489
- this.queryAABBNode(child, bounds, results);
490
- }
491
- }
492
- }
493
- querySphere(center, radius) {
494
- const results = [];
495
- const sphere = { center, radius };
496
- this.querySphereNode(this.root, sphere, results);
497
- return results;
498
- }
499
- querySphereNode(octreeNode, sphere, results) {
500
- if (!sphereAABBIntersection(sphere, octreeNode.bounds)) {
501
- return;
502
- }
503
- for (const obj of octreeNode.objects) {
504
- if (sphereIntersects(obj.boundingSphere, sphere)) {
505
- results.push(obj);
506
- }
507
- }
508
- if (octreeNode.children) {
509
- for (const child of octreeNode.children) {
510
- this.querySphereNode(child, sphere, results);
511
- }
512
- }
513
- }
514
- raycast(origin, direction, maxDistance = Infinity) {
515
- const results = [];
516
- this.raycastNode(this.root, origin, direction, maxDistance, results);
517
- results.sort((a, b) => a.distance - b.distance);
518
- return results;
519
- }
520
- raycastNode(octreeNode, origin, direction, maxDistance, results) {
521
- const hit = rayAABBIntersection(origin, direction, octreeNode.bounds);
522
- if (!hit || hit.distance > maxDistance) {
523
- return;
524
- }
525
- for (const obj of octreeNode.objects) {
526
- const objHit = rayAABBIntersection(origin, direction, obj.worldBounds);
527
- if (objHit && objHit.distance <= maxDistance) {
528
- results.push({
529
- node: obj,
530
- distance: objHit.distance,
531
- point: objHit.point,
532
- normal: objHit.normal,
533
- });
534
- }
535
- }
536
- if (octreeNode.children) {
537
- for (const child of octreeNode.children) {
538
- this.raycastNode(child, origin, direction, maxDistance, results);
539
- }
540
- }
541
- }
542
- clear() {
543
- this.releaseNode(this.root);
544
- this.root = this.createNode(this.root.bounds, 0);
545
- }
307
+ constructor(bounds, config) {
308
+ this.nodePool = [];
309
+ this.config = {
310
+ maxDepth: 8,
311
+ maxObjectsPerNode: 8,
312
+ looseness: 1.25,
313
+ minSize: 1,
314
+ ...config
315
+ };
316
+ this.root = this.createNode(bounds, 0);
317
+ }
318
+ createNode(bounds, depth) {
319
+ const node = this.nodePool.pop() ?? new OctreeNode();
320
+ node.bounds = bounds;
321
+ node.depth = depth;
322
+ node.objects = [];
323
+ node.children = null;
324
+ return node;
325
+ }
326
+ releaseNode(node) {
327
+ if (node.children) {
328
+ for (const child of node.children) {
329
+ this.releaseNode(child);
330
+ }
331
+ }
332
+ node.objects = [];
333
+ node.children = null;
334
+ this.nodePool.push(node);
335
+ }
336
+ insert(node) {
337
+ this.insertIntoNode(this.root, node);
338
+ }
339
+ insertIntoNode(octreeNode, sceneNode) {
340
+ if (octreeNode.children) {
341
+ const childIndex = this.getChildIndex(octreeNode, sceneNode.worldBounds);
342
+ if (childIndex >= 0) {
343
+ this.insertIntoNode(octreeNode.children[childIndex], sceneNode);
344
+ return;
345
+ }
346
+ }
347
+ octreeNode.objects.push(sceneNode);
348
+ if (!octreeNode.children && octreeNode.objects.length > this.config.maxObjectsPerNode && octreeNode.depth < this.config.maxDepth) {
349
+ this.split(octreeNode);
350
+ }
351
+ }
352
+ split(node) {
353
+ const center = {
354
+ x: (node.bounds.min.x + node.bounds.max.x) / 2,
355
+ y: (node.bounds.min.y + node.bounds.max.y) / 2,
356
+ z: (node.bounds.min.z + node.bounds.max.z) / 2
357
+ };
358
+ node.children = [];
359
+ for (let i = 0; i < 8; i++) {
360
+ const childBounds = {
361
+ min: {
362
+ x: i & 1 ? center.x : node.bounds.min.x,
363
+ y: i & 2 ? center.y : node.bounds.min.y,
364
+ z: i & 4 ? center.z : node.bounds.min.z
365
+ },
366
+ max: {
367
+ x: i & 1 ? node.bounds.max.x : center.x,
368
+ y: i & 2 ? node.bounds.max.y : center.y,
369
+ z: i & 4 ? node.bounds.max.z : center.z
370
+ }
371
+ };
372
+ node.children.push(this.createNode(childBounds, node.depth + 1));
373
+ }
374
+ const objects = node.objects;
375
+ node.objects = [];
376
+ for (const obj of objects) {
377
+ this.insertIntoNode(node, obj);
378
+ }
379
+ }
380
+ getChildIndex(octreeNode, bounds) {
381
+ if (!octreeNode.children) {
382
+ return -1;
383
+ }
384
+ const center = {
385
+ x: (octreeNode.bounds.min.x + octreeNode.bounds.max.x) / 2,
386
+ y: (octreeNode.bounds.min.y + octreeNode.bounds.max.y) / 2,
387
+ z: (octreeNode.bounds.min.z + octreeNode.bounds.max.z) / 2
388
+ };
389
+ const minX = bounds.min.x >= center.x;
390
+ const maxX = bounds.max.x <= center.x;
391
+ const minY = bounds.min.y >= center.y;
392
+ const maxY = bounds.max.y <= center.y;
393
+ const minZ = bounds.min.z >= center.z;
394
+ const maxZ = bounds.max.z <= center.z;
395
+ if ((minX || maxX) && (minY || maxY) && (minZ || maxZ)) {
396
+ return (minX ? 1 : 0) | (minY ? 2 : 0) | (minZ ? 4 : 0);
397
+ }
398
+ return -1;
399
+ }
400
+ remove(node) {
401
+ this.removeFromNode(this.root, node);
402
+ }
403
+ removeFromNode(octreeNode, sceneNode) {
404
+ const index = octreeNode.objects.indexOf(sceneNode);
405
+ if (index >= 0) {
406
+ octreeNode.objects.splice(index, 1);
407
+ return true;
408
+ }
409
+ if (octreeNode.children) {
410
+ for (const child of octreeNode.children) {
411
+ if (this.removeFromNode(child, sceneNode)) {
412
+ return true;
413
+ }
414
+ }
415
+ }
416
+ return false;
417
+ }
418
+ update(node) {
419
+ this.remove(node);
420
+ this.insert(node);
421
+ }
422
+ queryFrustum(frustum) {
423
+ const results = [];
424
+ this.queryFrustumNode(this.root, frustum, results);
425
+ return results;
426
+ }
427
+ queryFrustumNode(octreeNode, frustum, results) {
428
+ const result = frustumAABBIntersection(frustum, octreeNode.bounds);
429
+ if (result === "outside") {
430
+ return;
431
+ }
432
+ if (result === "inside") {
433
+ this.collectAllObjects(octreeNode, results);
434
+ return;
435
+ }
436
+ for (const obj of octreeNode.objects) {
437
+ if (frustumSphereIntersection(frustum, obj.boundingSphere) !== "outside") {
438
+ results.push(obj);
439
+ }
440
+ }
441
+ if (octreeNode.children) {
442
+ for (const child of octreeNode.children) {
443
+ this.queryFrustumNode(child, frustum, results);
444
+ }
445
+ }
446
+ }
447
+ collectAllObjects(octreeNode, results) {
448
+ results.push(...octreeNode.objects);
449
+ if (octreeNode.children) {
450
+ for (const child of octreeNode.children) {
451
+ this.collectAllObjects(child, results);
452
+ }
453
+ }
454
+ }
455
+ queryAABB(bounds) {
456
+ const results = [];
457
+ this.queryAABBNode(this.root, bounds, results);
458
+ return results;
459
+ }
460
+ queryAABBNode(octreeNode, bounds, results) {
461
+ if (!aabbIntersects(octreeNode.bounds, bounds)) {
462
+ return;
463
+ }
464
+ for (const obj of octreeNode.objects) {
465
+ if (aabbIntersects(obj.worldBounds, bounds)) {
466
+ results.push(obj);
467
+ }
468
+ }
469
+ if (octreeNode.children) {
470
+ for (const child of octreeNode.children) {
471
+ this.queryAABBNode(child, bounds, results);
472
+ }
473
+ }
474
+ }
475
+ querySphere(center, radius) {
476
+ const results = [];
477
+ const sphere = { center, radius };
478
+ this.querySphereNode(this.root, sphere, results);
479
+ return results;
480
+ }
481
+ querySphereNode(octreeNode, sphere, results) {
482
+ if (!sphereAABBIntersection(sphere, octreeNode.bounds)) {
483
+ return;
484
+ }
485
+ for (const obj of octreeNode.objects) {
486
+ if (sphereIntersects(obj.boundingSphere, sphere)) {
487
+ results.push(obj);
488
+ }
489
+ }
490
+ if (octreeNode.children) {
491
+ for (const child of octreeNode.children) {
492
+ this.querySphereNode(child, sphere, results);
493
+ }
494
+ }
495
+ }
496
+ raycast(origin, direction, maxDistance = Infinity) {
497
+ const results = [];
498
+ this.raycastNode(this.root, origin, direction, maxDistance, results);
499
+ results.sort((a, b) => a.distance - b.distance);
500
+ return results;
501
+ }
502
+ raycastNode(octreeNode, origin, direction, maxDistance, results) {
503
+ const hit = rayAABBIntersection(origin, direction, octreeNode.bounds);
504
+ if (!hit || hit.distance > maxDistance) {
505
+ return;
506
+ }
507
+ for (const obj of octreeNode.objects) {
508
+ const objHit = rayAABBIntersection(origin, direction, obj.worldBounds);
509
+ if (objHit && objHit.distance <= maxDistance) {
510
+ results.push({
511
+ node: obj,
512
+ distance: objHit.distance,
513
+ point: objHit.point,
514
+ normal: objHit.normal
515
+ });
516
+ }
517
+ }
518
+ if (octreeNode.children) {
519
+ for (const child of octreeNode.children) {
520
+ this.raycastNode(child, origin, direction, maxDistance, results);
521
+ }
522
+ }
523
+ }
524
+ clear() {
525
+ this.releaseNode(this.root);
526
+ this.root = this.createNode(this.root.bounds, 0);
527
+ }
546
528
  }
547
529
  class OctreeNode {
548
- constructor() {
549
- this.children = null;
550
- }
530
+ constructor() {
531
+ this.children = null;
532
+ }
551
533
  }
552
- // ============================================================
553
- // Mathematics Helpers
554
- // ============================================================
555
534
  function mat4Identity(out) {
556
- out[0] = 1;
557
- out[1] = 0;
558
- out[2] = 0;
559
- out[3] = 0;
560
- out[4] = 0;
561
- out[5] = 1;
562
- out[6] = 0;
563
- out[7] = 0;
564
- out[8] = 0;
565
- out[9] = 0;
566
- out[10] = 1;
567
- out[11] = 0;
568
- out[12] = 0;
569
- out[13] = 0;
570
- out[14] = 0;
571
- out[15] = 1;
535
+ out[0] = 1;
536
+ out[1] = 0;
537
+ out[2] = 0;
538
+ out[3] = 0;
539
+ out[4] = 0;
540
+ out[5] = 1;
541
+ out[6] = 0;
542
+ out[7] = 0;
543
+ out[8] = 0;
544
+ out[9] = 0;
545
+ out[10] = 1;
546
+ out[11] = 0;
547
+ out[12] = 0;
548
+ out[13] = 0;
549
+ out[14] = 0;
550
+ out[15] = 1;
572
551
  }
573
552
  function mat4Compose(position, rotation, scale, out) {
574
- const x = rotation.x, y = rotation.y, z = rotation.z, w = rotation.w;
575
- const x2 = x + x, y2 = y + y, z2 = z + z;
576
- const xx = x * x2, xy = x * y2, xz = x * z2;
577
- const yy = y * y2, yz = y * z2, zz = z * z2;
578
- const wx = w * x2, wy = w * y2, wz = w * z2;
579
- out[0] = (1 - (yy + zz)) * scale.x;
580
- out[1] = (xy + wz) * scale.x;
581
- out[2] = (xz - wy) * scale.x;
582
- out[3] = 0;
583
- out[4] = (xy - wz) * scale.y;
584
- out[5] = (1 - (xx + zz)) * scale.y;
585
- out[6] = (yz + wx) * scale.y;
586
- out[7] = 0;
587
- out[8] = (xz + wy) * scale.z;
588
- out[9] = (yz - wx) * scale.z;
589
- out[10] = (1 - (xx + yy)) * scale.z;
590
- out[11] = 0;
591
- out[12] = position.x;
592
- out[13] = position.y;
593
- out[14] = position.z;
594
- out[15] = 1;
553
+ const x = rotation.x, y = rotation.y, z = rotation.z, w = rotation.w;
554
+ const x2 = x + x, y2 = y + y, z2 = z + z;
555
+ const xx = x * x2, xy = x * y2, xz = x * z2;
556
+ const yy = y * y2, yz = y * z2, zz = z * z2;
557
+ const wx = w * x2, wy = w * y2, wz = w * z2;
558
+ out[0] = (1 - (yy + zz)) * scale.x;
559
+ out[1] = (xy + wz) * scale.x;
560
+ out[2] = (xz - wy) * scale.x;
561
+ out[3] = 0;
562
+ out[4] = (xy - wz) * scale.y;
563
+ out[5] = (1 - (xx + zz)) * scale.y;
564
+ out[6] = (yz + wx) * scale.y;
565
+ out[7] = 0;
566
+ out[8] = (xz + wy) * scale.z;
567
+ out[9] = (yz - wx) * scale.z;
568
+ out[10] = (1 - (xx + yy)) * scale.z;
569
+ out[11] = 0;
570
+ out[12] = position.x;
571
+ out[13] = position.y;
572
+ out[14] = position.z;
573
+ out[15] = 1;
595
574
  }
596
575
  function mat4Multiply(a, b, out) {
597
- const a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];
598
- const a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];
599
- const a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11];
600
- const a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];
601
- let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];
602
- out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
603
- out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
604
- out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
605
- out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
606
- b0 = b[4];
607
- b1 = b[5];
608
- b2 = b[6];
609
- b3 = b[7];
610
- out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
611
- out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
612
- out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
613
- out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
614
- b0 = b[8];
615
- b1 = b[9];
616
- b2 = b[10];
617
- b3 = b[11];
618
- out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
619
- out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
620
- out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
621
- out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
622
- b0 = b[12];
623
- b1 = b[13];
624
- b2 = b[14];
625
- b3 = b[15];
626
- out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
627
- out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
628
- out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
629
- out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
576
+ const a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];
577
+ const a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];
578
+ const a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11];
579
+ const a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];
580
+ let b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];
581
+ out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
582
+ out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
583
+ out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
584
+ out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
585
+ b0 = b[4];
586
+ b1 = b[5];
587
+ b2 = b[6];
588
+ b3 = b[7];
589
+ out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
590
+ out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
591
+ out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
592
+ out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
593
+ b0 = b[8];
594
+ b1 = b[9];
595
+ b2 = b[10];
596
+ b3 = b[11];
597
+ out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
598
+ out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
599
+ out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
600
+ out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
601
+ b0 = b[12];
602
+ b1 = b[13];
603
+ b2 = b[14];
604
+ b3 = b[15];
605
+ out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
606
+ out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
607
+ out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
608
+ out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
630
609
  }
631
610
  function mat4Copy(src, dst) {
632
- for (let i = 0; i < 16; i++) {
633
- dst[i] = src[i];
634
- }
611
+ for (let i = 0; i < 16; i++) {
612
+ dst[i] = src[i];
613
+ }
635
614
  }
636
615
  function eulerToQuaternion(pitch, yaw, roll, out) {
637
- const c1 = Math.cos(pitch / 2);
638
- const s1 = Math.sin(pitch / 2);
639
- const c2 = Math.cos(yaw / 2);
640
- const s2 = Math.sin(yaw / 2);
641
- const c3 = Math.cos(roll / 2);
642
- const s3 = Math.sin(roll / 2);
643
- out.x = s1 * c2 * c3 + c1 * s2 * s3;
644
- out.y = c1 * s2 * c3 - s1 * c2 * s3;
645
- out.z = c1 * c2 * s3 + s1 * s2 * c3;
646
- out.w = c1 * c2 * c3 - s1 * s2 * s3;
616
+ const c1 = Math.cos(pitch / 2);
617
+ const s1 = Math.sin(pitch / 2);
618
+ const c2 = Math.cos(yaw / 2);
619
+ const s2 = Math.sin(yaw / 2);
620
+ const c3 = Math.cos(roll / 2);
621
+ const s3 = Math.sin(roll / 2);
622
+ out.x = s1 * c2 * c3 + c1 * s2 * s3;
623
+ out.y = c1 * s2 * c3 - s1 * c2 * s3;
624
+ out.z = c1 * c2 * s3 + s1 * s2 * c3;
625
+ out.w = c1 * c2 * c3 - s1 * s2 * s3;
647
626
  }
648
627
  function quaternionMultiply(a, b) {
649
- return {
650
- x: a.w * b.x + a.x * b.w + a.y * b.z - a.z * b.y,
651
- y: a.w * b.y - a.x * b.z + a.y * b.w + a.z * b.x,
652
- z: a.w * b.z + a.x * b.y - a.y * b.x + a.z * b.w,
653
- w: a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z,
654
- };
628
+ return {
629
+ x: a.w * b.x + a.x * b.w + a.y * b.z - a.z * b.y,
630
+ y: a.w * b.y - a.x * b.z + a.y * b.w + a.z * b.x,
631
+ z: a.w * b.z + a.x * b.y - a.y * b.x + a.z * b.w,
632
+ w: a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z
633
+ };
655
634
  }
656
635
  function matrixToQuaternion(right, up, forward) {
657
- const trace = right.x + up.y + forward.z;
658
- let x, y, z, w;
659
- if (trace > 0) {
660
- const s = 0.5 / Math.sqrt(trace + 1);
661
- w = 0.25 / s;
662
- x = (up.z - forward.y) * s;
663
- y = (forward.x - right.z) * s;
664
- z = (right.y - up.x) * s;
665
- }
666
- else if (right.x > up.y && right.x > forward.z) {
667
- const s = 2 * Math.sqrt(1 + right.x - up.y - forward.z);
668
- w = (up.z - forward.y) / s;
669
- x = 0.25 * s;
670
- y = (up.x + right.y) / s;
671
- z = (forward.x + right.z) / s;
672
- }
673
- else if (up.y > forward.z) {
674
- const s = 2 * Math.sqrt(1 + up.y - right.x - forward.z);
675
- w = (forward.x - right.z) / s;
676
- x = (up.x + right.y) / s;
677
- y = 0.25 * s;
678
- z = (forward.y + up.z) / s;
679
- }
680
- else {
681
- const s = 2 * Math.sqrt(1 + forward.z - right.x - up.y);
682
- w = (right.y - up.x) / s;
683
- x = (forward.x + right.z) / s;
684
- y = (forward.y + up.z) / s;
685
- z = 0.25 * s;
686
- }
687
- return { x, y, z, w };
636
+ const trace = right.x + up.y + forward.z;
637
+ let x, y, z, w;
638
+ if (trace > 0) {
639
+ const s = 0.5 / Math.sqrt(trace + 1);
640
+ w = 0.25 / s;
641
+ x = (up.z - forward.y) * s;
642
+ y = (forward.x - right.z) * s;
643
+ z = (right.y - up.x) * s;
644
+ } else if (right.x > up.y && right.x > forward.z) {
645
+ const s = 2 * Math.sqrt(1 + right.x - up.y - forward.z);
646
+ w = (up.z - forward.y) / s;
647
+ x = 0.25 * s;
648
+ y = (up.x + right.y) / s;
649
+ z = (forward.x + right.z) / s;
650
+ } else if (up.y > forward.z) {
651
+ const s = 2 * Math.sqrt(1 + up.y - right.x - forward.z);
652
+ w = (forward.x - right.z) / s;
653
+ x = (up.x + right.y) / s;
654
+ y = 0.25 * s;
655
+ z = (forward.y + up.z) / s;
656
+ } else {
657
+ const s = 2 * Math.sqrt(1 + forward.z - right.x - up.y);
658
+ w = (right.y - up.x) / s;
659
+ x = (forward.x + right.z) / s;
660
+ y = (forward.y + up.z) / s;
661
+ z = 0.25 * s;
662
+ }
663
+ return { x, y, z, w };
688
664
  }
689
665
  function vec3Subtract(a, b) {
690
- return { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z };
666
+ return { x: a.x - b.x, y: a.y - b.y, z: a.z - b.z };
691
667
  }
692
668
  function vec3Cross(a, b) {
693
- return {
694
- x: a.y * b.z - a.z * b.y,
695
- y: a.z * b.x - a.x * b.z,
696
- z: a.x * b.y - a.y * b.x,
697
- };
669
+ return {
670
+ x: a.y * b.z - a.z * b.y,
671
+ y: a.z * b.x - a.x * b.z,
672
+ z: a.x * b.y - a.y * b.x
673
+ };
698
674
  }
699
675
  function vec3Normalize(v) {
700
- const len = Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
701
- if (len === 0) {
702
- return { x: 0, y: 0, z: 0 };
703
- }
704
- return { x: v.x / len, y: v.y / len, z: v.z / len };
676
+ const len = Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
677
+ if (len === 0) {
678
+ return { x: 0, y: 0, z: 0 };
679
+ }
680
+ return { x: v.x / len, y: v.y / len, z: v.z / len };
705
681
  }
706
682
  function vec3Distance(a, b) {
707
- const dx = a.x - b.x, dy = a.y - b.y, dz = a.z - b.z;
708
- return Math.sqrt(dx * dx + dy * dy + dz * dz);
683
+ const dx = a.x - b.x, dy = a.y - b.y, dz = a.z - b.z;
684
+ return Math.sqrt(dx * dx + dy * dy + dz * dz);
709
685
  }
710
686
  function transformPoint(p, m) {
711
- const w = m[3] * p.x + m[7] * p.y + m[11] * p.z + m[15];
712
- return {
713
- x: (m[0] * p.x + m[4] * p.y + m[8] * p.z + m[12]) / w,
714
- y: (m[1] * p.x + m[5] * p.y + m[9] * p.z + m[13]) / w,
715
- z: (m[2] * p.x + m[6] * p.y + m[10] * p.z + m[14]) / w,
716
- };
687
+ const w = m[3] * p.x + m[7] * p.y + m[11] * p.z + m[15];
688
+ return {
689
+ x: (m[0] * p.x + m[4] * p.y + m[8] * p.z + m[12]) / w,
690
+ y: (m[1] * p.x + m[5] * p.y + m[9] * p.z + m[13]) / w,
691
+ z: (m[2] * p.x + m[6] * p.y + m[10] * p.z + m[14]) / w
692
+ };
717
693
  }
718
694
  function getAABBCorners(aabb) {
719
- return [
720
- { x: aabb.min.x, y: aabb.min.y, z: aabb.min.z },
721
- { x: aabb.max.x, y: aabb.min.y, z: aabb.min.z },
722
- { x: aabb.min.x, y: aabb.max.y, z: aabb.min.z },
723
- { x: aabb.max.x, y: aabb.max.y, z: aabb.min.z },
724
- { x: aabb.min.x, y: aabb.min.y, z: aabb.max.z },
725
- { x: aabb.max.x, y: aabb.min.y, z: aabb.max.z },
726
- { x: aabb.min.x, y: aabb.max.y, z: aabb.max.z },
727
- { x: aabb.max.x, y: aabb.max.y, z: aabb.max.z },
728
- ];
695
+ return [
696
+ { x: aabb.min.x, y: aabb.min.y, z: aabb.min.z },
697
+ { x: aabb.max.x, y: aabb.min.y, z: aabb.min.z },
698
+ { x: aabb.min.x, y: aabb.max.y, z: aabb.min.z },
699
+ { x: aabb.max.x, y: aabb.max.y, z: aabb.min.z },
700
+ { x: aabb.min.x, y: aabb.min.y, z: aabb.max.z },
701
+ { x: aabb.max.x, y: aabb.min.y, z: aabb.max.z },
702
+ { x: aabb.min.x, y: aabb.max.y, z: aabb.max.z },
703
+ { x: aabb.max.x, y: aabb.max.y, z: aabb.max.z }
704
+ ];
729
705
  }
730
706
  function aabbIntersects(a, b) {
731
- return (a.min.x <= b.max.x &&
732
- a.max.x >= b.min.x &&
733
- a.min.y <= b.max.y &&
734
- a.max.y >= b.min.y &&
735
- a.min.z <= b.max.z &&
736
- a.max.z >= b.min.z);
707
+ return a.min.x <= b.max.x && a.max.x >= b.min.x && a.min.y <= b.max.y && a.max.y >= b.min.y && a.min.z <= b.max.z && a.max.z >= b.min.z;
737
708
  }
738
709
  function sphereIntersects(a, b) {
739
- const d = vec3Distance(a.center, b.center);
740
- return d <= a.radius + b.radius;
710
+ const d = vec3Distance(a.center, b.center);
711
+ return d <= a.radius + b.radius;
741
712
  }
742
713
  function sphereAABBIntersection(sphere, aabb) {
743
- const closest = {
744
- x: Math.max(aabb.min.x, Math.min(sphere.center.x, aabb.max.x)),
745
- y: Math.max(aabb.min.y, Math.min(sphere.center.y, aabb.max.y)),
746
- z: Math.max(aabb.min.z, Math.min(sphere.center.z, aabb.max.z)),
747
- };
748
- return vec3Distance(sphere.center, closest) <= sphere.radius;
714
+ const closest = {
715
+ x: Math.max(aabb.min.x, Math.min(sphere.center.x, aabb.max.x)),
716
+ y: Math.max(aabb.min.y, Math.min(sphere.center.y, aabb.max.y)),
717
+ z: Math.max(aabb.min.z, Math.min(sphere.center.z, aabb.max.z))
718
+ };
719
+ return vec3Distance(sphere.center, closest) <= sphere.radius;
749
720
  }
750
721
  function frustumAABBIntersection(frustum, aabb) {
751
- let inside = true;
752
- for (const plane of frustum.planes) {
753
- const p = {
754
- x: plane.normal.x > 0 ? aabb.max.x : aabb.min.x,
755
- y: plane.normal.y > 0 ? aabb.max.y : aabb.min.y,
756
- z: plane.normal.z > 0 ? aabb.max.z : aabb.min.z,
757
- };
758
- const n = {
759
- x: plane.normal.x > 0 ? aabb.min.x : aabb.max.x,
760
- y: plane.normal.y > 0 ? aabb.min.y : aabb.max.y,
761
- z: plane.normal.z > 0 ? aabb.min.z : aabb.max.z,
762
- };
763
- const dp = plane.normal.x * p.x + plane.normal.y * p.y + plane.normal.z * p.z + plane.distance;
764
- const dn = plane.normal.x * n.x + plane.normal.y * n.y + plane.normal.z * n.z + plane.distance;
765
- if (dp < 0) {
766
- return 'outside';
767
- }
768
- if (dn < 0) {
769
- inside = false;
770
- }
722
+ let inside = true;
723
+ for (const plane of frustum.planes) {
724
+ const p = {
725
+ x: plane.normal.x > 0 ? aabb.max.x : aabb.min.x,
726
+ y: plane.normal.y > 0 ? aabb.max.y : aabb.min.y,
727
+ z: plane.normal.z > 0 ? aabb.max.z : aabb.min.z
728
+ };
729
+ const n = {
730
+ x: plane.normal.x > 0 ? aabb.min.x : aabb.max.x,
731
+ y: plane.normal.y > 0 ? aabb.min.y : aabb.max.y,
732
+ z: plane.normal.z > 0 ? aabb.min.z : aabb.max.z
733
+ };
734
+ const dp = plane.normal.x * p.x + plane.normal.y * p.y + plane.normal.z * p.z + plane.distance;
735
+ const dn = plane.normal.x * n.x + plane.normal.y * n.y + plane.normal.z * n.z + plane.distance;
736
+ if (dp < 0) {
737
+ return "outside";
771
738
  }
772
- return inside ? 'inside' : 'intersecting';
739
+ if (dn < 0) {
740
+ inside = false;
741
+ }
742
+ }
743
+ return inside ? "inside" : "intersecting";
773
744
  }
774
745
  function frustumSphereIntersection(frustum, sphere) {
775
- let inside = true;
776
- for (const plane of frustum.planes) {
777
- const d = plane.normal.x * sphere.center.x +
778
- plane.normal.y * sphere.center.y +
779
- plane.normal.z * sphere.center.z +
780
- plane.distance;
781
- if (d < -sphere.radius) {
782
- return 'outside';
783
- }
784
- if (d < sphere.radius) {
785
- inside = false;
786
- }
746
+ let inside = true;
747
+ for (const plane of frustum.planes) {
748
+ const d = plane.normal.x * sphere.center.x + plane.normal.y * sphere.center.y + plane.normal.z * sphere.center.z + plane.distance;
749
+ if (d < -sphere.radius) {
750
+ return "outside";
751
+ }
752
+ if (d < sphere.radius) {
753
+ inside = false;
787
754
  }
788
- return inside ? 'inside' : 'intersecting';
755
+ }
756
+ return inside ? "inside" : "intersecting";
789
757
  }
790
758
  function rayAABBIntersection(origin, direction, aabb) {
791
- let tmin = -Infinity;
792
- let tmax = Infinity;
793
- let normalAxis = 0;
794
- let normalSign = 1;
795
- for (let i = 0; i < 3; i++) {
796
- const o = i === 0 ? origin.x : i === 1 ? origin.y : origin.z;
797
- const d = i === 0 ? direction.x : i === 1 ? direction.y : direction.z;
798
- const min = i === 0 ? aabb.min.x : i === 1 ? aabb.min.y : aabb.min.z;
799
- const max = i === 0 ? aabb.max.x : i === 1 ? aabb.max.y : aabb.max.z;
800
- if (Math.abs(d) < 1e-8) {
801
- if (o < min || o > max) {
802
- return null;
803
- }
804
- }
805
- else {
806
- let t1 = (min - o) / d;
807
- let t2 = (max - o) / d;
808
- let sign = -1;
809
- if (t1 > t2) {
810
- const tmp = t1;
811
- t1 = t2;
812
- t2 = tmp;
813
- sign = 1;
814
- }
815
- if (t1 > tmin) {
816
- tmin = t1;
817
- normalAxis = i;
818
- normalSign = sign;
819
- }
820
- tmax = Math.min(tmax, t2);
821
- if (tmin > tmax) {
822
- return null;
823
- }
824
- }
825
- }
826
- if (tmin < 0) {
759
+ let tmin = -Infinity;
760
+ let tmax = Infinity;
761
+ let normalAxis = 0;
762
+ let normalSign = 1;
763
+ for (let i = 0; i < 3; i++) {
764
+ const o = i === 0 ? origin.x : i === 1 ? origin.y : origin.z;
765
+ const d = i === 0 ? direction.x : i === 1 ? direction.y : direction.z;
766
+ const min = i === 0 ? aabb.min.x : i === 1 ? aabb.min.y : aabb.min.z;
767
+ const max = i === 0 ? aabb.max.x : i === 1 ? aabb.max.y : aabb.max.z;
768
+ if (Math.abs(d) < 1e-8) {
769
+ if (o < min || o > max) {
827
770
  return null;
828
- }
829
- const point = {
830
- x: origin.x + direction.x * tmin,
831
- y: origin.y + direction.y * tmin,
832
- z: origin.z + direction.z * tmin,
833
- };
834
- const normal = { x: 0, y: 0, z: 0 };
835
- if (normalAxis === 0) {
836
- normal.x = normalSign;
837
- }
838
- else if (normalAxis === 1) {
839
- normal.y = normalSign;
840
- }
841
- else {
842
- normal.z = normalSign;
843
- }
844
- return { distance: tmin, point, normal };
771
+ }
772
+ } else {
773
+ let t1 = (min - o) / d;
774
+ let t2 = (max - o) / d;
775
+ let sign = -1;
776
+ if (t1 > t2) {
777
+ const tmp = t1;
778
+ t1 = t2;
779
+ t2 = tmp;
780
+ sign = 1;
781
+ }
782
+ if (t1 > tmin) {
783
+ tmin = t1;
784
+ normalAxis = i;
785
+ normalSign = sign;
786
+ }
787
+ tmax = Math.min(tmax, t2);
788
+ if (tmin > tmax) {
789
+ return null;
790
+ }
791
+ }
792
+ }
793
+ if (tmin < 0) {
794
+ return null;
795
+ }
796
+ const point = {
797
+ x: origin.x + direction.x * tmin,
798
+ y: origin.y + direction.y * tmin,
799
+ z: origin.z + direction.z * tmin
800
+ };
801
+ const normal = { x: 0, y: 0, z: 0 };
802
+ if (normalAxis === 0) {
803
+ normal.x = normalSign;
804
+ } else if (normalAxis === 1) {
805
+ normal.y = normalSign;
806
+ } else {
807
+ normal.z = normalSign;
808
+ }
809
+ return { distance: tmin, point, normal };
845
810
  }
846
- // ============================================================
847
- // Factory Functions
848
- // ============================================================
849
811
  function createSceneNode(name, type) {
850
- return new SceneNode(name, type);
812
+ return new SceneNode(name, type);
851
813
  }
852
814
  function createOctree(bounds, config) {
853
- return new Octree(bounds, config);
815
+ return new Octree(bounds, config);
854
816
  }
855
-
856
- export { Octree, SceneNode, createOctree, createSceneNode };
817
+ export {
818
+ Octree,
819
+ SceneNode,
820
+ createOctree,
821
+ createSceneNode
822
+ };