@luminocity/lemonate-engine 15.2.2 → 15.2.3

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 (375) hide show
  1. package/dist/engine.min.js +302 -0
  2. package/dist/player.zip +302 -0
  3. package/package.json +6 -2
  4. package/dist/Builder.js +0 -93
  5. package/dist/Builder.js.map +0 -1
  6. package/dist/Canvas.js +0 -109
  7. package/dist/Canvas.js.map +0 -1
  8. package/dist/Controllers.js +0 -97
  9. package/dist/Controllers.js.map +0 -1
  10. package/dist/EditorScene.js +0 -372
  11. package/dist/EditorScene.js.map +0 -1
  12. package/dist/Engine.js +0 -1576
  13. package/dist/Engine.js.map +0 -1
  14. package/dist/LoadingManager.js +0 -1195
  15. package/dist/LoadingManager.js.map +0 -1
  16. package/dist/LoadingState.js +0 -37
  17. package/dist/LoadingState.js.map +0 -1
  18. package/dist/Logger.js +0 -141
  19. package/dist/Logger.js.map +0 -1
  20. package/dist/Player.js +0 -470
  21. package/dist/Player.js.map +0 -1
  22. package/dist/Preview.js +0 -166
  23. package/dist/Preview.js.map +0 -1
  24. package/dist/RenderOptions.js +0 -59
  25. package/dist/RenderOptions.js.map +0 -1
  26. package/dist/RenderPassInfo.js +0 -133
  27. package/dist/RenderPassInfo.js.map +0 -1
  28. package/dist/RenderView.js +0 -459
  29. package/dist/RenderView.js.map +0 -1
  30. package/dist/Renderer.js +0 -1867
  31. package/dist/Renderer.js.map +0 -1
  32. package/dist/SceneGraph.js +0 -798
  33. package/dist/SceneGraph.js.map +0 -1
  34. package/dist/SceneGraphCollection.js +0 -614
  35. package/dist/SceneGraphCollection.js.map +0 -1
  36. package/dist/Shortcuts.js +0 -259
  37. package/dist/Shortcuts.js.map +0 -1
  38. package/dist/Tools.js +0 -500
  39. package/dist/Tools.js.map +0 -1
  40. package/dist/Variables.js +0 -243
  41. package/dist/Variables.js.map +0 -1
  42. package/dist/helpers/ArrowHelper.js +0 -104
  43. package/dist/helpers/ArrowHelper.js.map +0 -1
  44. package/dist/helpers/BoxHelper.js +0 -112
  45. package/dist/helpers/BoxHelper.js.map +0 -1
  46. package/dist/helpers/CameraHelper.js +0 -237
  47. package/dist/helpers/CameraHelper.js.map +0 -1
  48. package/dist/helpers/FaceNormalsHelper.js +0 -85
  49. package/dist/helpers/FaceNormalsHelper.js.map +0 -1
  50. package/dist/helpers/MeshHelper.js +0 -92
  51. package/dist/helpers/MeshHelper.js.map +0 -1
  52. package/dist/helpers/MultiGridHelper.js +0 -61
  53. package/dist/helpers/MultiGridHelper.js.map +0 -1
  54. package/dist/helpers/ParticlesHelper.js +0 -245
  55. package/dist/helpers/ParticlesHelper.js.map +0 -1
  56. package/dist/helpers/PointHelper.js +0 -85
  57. package/dist/helpers/PointHelper.js.map +0 -1
  58. package/dist/helpers/SphereHelper.js +0 -62
  59. package/dist/helpers/SphereHelper.js.map +0 -1
  60. package/dist/helpers/VertexNormalsHelper.js +0 -75
  61. package/dist/helpers/VertexNormalsHelper.js.map +0 -1
  62. package/dist/helpers/ViewHelper.js +0 -252
  63. package/dist/helpers/ViewHelper.js.map +0 -1
  64. package/dist/helpers/lighthelpers/DirectionalLightHelper.js +0 -136
  65. package/dist/helpers/lighthelpers/DirectionalLightHelper.js.map +0 -1
  66. package/dist/helpers/lighthelpers/HemisphereLightHelper.js +0 -124
  67. package/dist/helpers/lighthelpers/HemisphereLightHelper.js.map +0 -1
  68. package/dist/helpers/lighthelpers/PointLightHelper.js +0 -133
  69. package/dist/helpers/lighthelpers/PointLightHelper.js.map +0 -1
  70. package/dist/helpers/lighthelpers/SpotLightHelper.js +0 -123
  71. package/dist/helpers/lighthelpers/SpotLightHelper.js.map +0 -1
  72. package/dist/index.js +0 -40
  73. package/dist/index.js.map +0 -1
  74. package/dist/items/AudioCollectionItem.js +0 -230
  75. package/dist/items/AudioCollectionItem.js.map +0 -1
  76. package/dist/items/AudioItem.js +0 -75
  77. package/dist/items/AudioItem.js.map +0 -1
  78. package/dist/items/BackgroundShaderItem.js +0 -239
  79. package/dist/items/BackgroundShaderItem.js.map +0 -1
  80. package/dist/items/CanvasTextureItem.js +0 -194
  81. package/dist/items/CanvasTextureItem.js.map +0 -1
  82. package/dist/items/CompositionItem.js +0 -110
  83. package/dist/items/CompositionItem.js.map +0 -1
  84. package/dist/items/FontItem.js +0 -135
  85. package/dist/items/FontItem.js.map +0 -1
  86. package/dist/items/GaussianSplatsItem.js +0 -103
  87. package/dist/items/GaussianSplatsItem.js.map +0 -1
  88. package/dist/items/GridMapItem.js +0 -202
  89. package/dist/items/GridMapItem.js.map +0 -1
  90. package/dist/items/ImageItem.js +0 -255
  91. package/dist/items/ImageItem.js.map +0 -1
  92. package/dist/items/Item.js +0 -739
  93. package/dist/items/Item.js.map +0 -1
  94. package/dist/items/MaterialCollectionItem.js +0 -216
  95. package/dist/items/MaterialCollectionItem.js.map +0 -1
  96. package/dist/items/MaterialItem.js +0 -1762
  97. package/dist/items/MaterialItem.js.map +0 -1
  98. package/dist/items/MeshCollectionItem.js +0 -258
  99. package/dist/items/MeshCollectionItem.js.map +0 -1
  100. package/dist/items/MeshItem.js +0 -274
  101. package/dist/items/MeshItem.js.map +0 -1
  102. package/dist/items/ParticlesItem.js +0 -187
  103. package/dist/items/ParticlesItem.js.map +0 -1
  104. package/dist/items/PixelShaderItem.js +0 -42
  105. package/dist/items/PixelShaderItem.js.map +0 -1
  106. package/dist/items/PointsItem.js +0 -122
  107. package/dist/items/PointsItem.js.map +0 -1
  108. package/dist/items/PrefabItem.js +0 -140
  109. package/dist/items/PrefabItem.js.map +0 -1
  110. package/dist/items/ProjectItem.js +0 -857
  111. package/dist/items/ProjectItem.js.map +0 -1
  112. package/dist/items/SceneItem.js +0 -443
  113. package/dist/items/SceneItem.js.map +0 -1
  114. package/dist/items/ScriptItem.js +0 -159
  115. package/dist/items/ScriptItem.js.map +0 -1
  116. package/dist/items/VariableSetItem.js +0 -208
  117. package/dist/items/VariableSetItem.js.map +0 -1
  118. package/dist/items/VertexShaderItem.js +0 -42
  119. package/dist/items/VertexShaderItem.js.map +0 -1
  120. package/dist/items/VideoItem.js +0 -152
  121. package/dist/items/VideoItem.js.map +0 -1
  122. package/dist/items/base/ImageOwningItem.js +0 -205
  123. package/dist/items/base/ImageOwningItem.js.map +0 -1
  124. package/dist/items/base/MeshBase.js +0 -342
  125. package/dist/items/base/MeshBase.js.map +0 -1
  126. package/dist/items/base/ShaderBase.js +0 -115
  127. package/dist/items/base/ShaderBase.js.map +0 -1
  128. package/dist/items/helpers/ListEntry.js +0 -113
  129. package/dist/items/helpers/ListEntry.js.map +0 -1
  130. package/dist/items/helpers/ListField.js +0 -210
  131. package/dist/items/helpers/ListField.js.map +0 -1
  132. package/dist/items/helpers/MappingSetup.js +0 -126
  133. package/dist/items/helpers/MappingSetup.js.map +0 -1
  134. package/dist/json/packageVersionInfo.json +0 -6
  135. package/dist/json/shortcuts.json +0 -37
  136. package/dist/renderers/ForwardRenderer.js +0 -50
  137. package/dist/renderers/ForwardRenderer.js.map +0 -1
  138. package/dist/renderers/RendererBase.js +0 -38
  139. package/dist/renderers/RendererBase.js.map +0 -1
  140. package/dist/scenegraph/SgAudio.js +0 -286
  141. package/dist/scenegraph/SgAudio.js.map +0 -1
  142. package/dist/scenegraph/SgAudioListener.js +0 -64
  143. package/dist/scenegraph/SgAudioListener.js.map +0 -1
  144. package/dist/scenegraph/SgBillboard.js +0 -150
  145. package/dist/scenegraph/SgBillboard.js.map +0 -1
  146. package/dist/scenegraph/SgBox.js +0 -54
  147. package/dist/scenegraph/SgBox.js.map +0 -1
  148. package/dist/scenegraph/SgCamera.js +0 -219
  149. package/dist/scenegraph/SgCamera.js.map +0 -1
  150. package/dist/scenegraph/SgCircleShadow.js +0 -105
  151. package/dist/scenegraph/SgCircleShadow.js.map +0 -1
  152. package/dist/scenegraph/SgCone.js +0 -61
  153. package/dist/scenegraph/SgCone.js.map +0 -1
  154. package/dist/scenegraph/SgCylinder.js +0 -62
  155. package/dist/scenegraph/SgCylinder.js.map +0 -1
  156. package/dist/scenegraph/SgGaussianSplats.js +0 -103
  157. package/dist/scenegraph/SgGaussianSplats.js.map +0 -1
  158. package/dist/scenegraph/SgGridMap.js +0 -112
  159. package/dist/scenegraph/SgGridMap.js.map +0 -1
  160. package/dist/scenegraph/SgGroup.js +0 -40
  161. package/dist/scenegraph/SgGroup.js.map +0 -1
  162. package/dist/scenegraph/SgItem.js +0 -1427
  163. package/dist/scenegraph/SgItem.js.map +0 -1
  164. package/dist/scenegraph/SgItemScript.js +0 -117
  165. package/dist/scenegraph/SgItemScript.js.map +0 -1
  166. package/dist/scenegraph/SgLightsource.js +0 -319
  167. package/dist/scenegraph/SgLightsource.js.map +0 -1
  168. package/dist/scenegraph/SgLod.js +0 -82
  169. package/dist/scenegraph/SgLod.js.map +0 -1
  170. package/dist/scenegraph/SgMesh.js +0 -662
  171. package/dist/scenegraph/SgMesh.js.map +0 -1
  172. package/dist/scenegraph/SgNavMesh.js +0 -503
  173. package/dist/scenegraph/SgNavMesh.js.map +0 -1
  174. package/dist/scenegraph/SgParticles.js +0 -796
  175. package/dist/scenegraph/SgParticles.js.map +0 -1
  176. package/dist/scenegraph/SgPhysicsItem.js +0 -806
  177. package/dist/scenegraph/SgPhysicsItem.js.map +0 -1
  178. package/dist/scenegraph/SgPhysicsSubItem.js +0 -449
  179. package/dist/scenegraph/SgPhysicsSubItem.js.map +0 -1
  180. package/dist/scenegraph/SgPlane.js +0 -47
  181. package/dist/scenegraph/SgPlane.js.map +0 -1
  182. package/dist/scenegraph/SgPoints.js +0 -143
  183. package/dist/scenegraph/SgPoints.js.map +0 -1
  184. package/dist/scenegraph/SgPositionalAudio.js +0 -93
  185. package/dist/scenegraph/SgPositionalAudio.js.map +0 -1
  186. package/dist/scenegraph/SgPrefab.js +0 -153
  187. package/dist/scenegraph/SgPrefab.js.map +0 -1
  188. package/dist/scenegraph/SgProceduralGeometryItem.js +0 -146
  189. package/dist/scenegraph/SgProceduralGeometryItem.js.map +0 -1
  190. package/dist/scenegraph/SgResourceOwner.js +0 -127
  191. package/dist/scenegraph/SgResourceOwner.js.map +0 -1
  192. package/dist/scenegraph/SgRibbon.js +0 -107
  193. package/dist/scenegraph/SgRibbon.js.map +0 -1
  194. package/dist/scenegraph/SgRing.js +0 -49
  195. package/dist/scenegraph/SgRing.js.map +0 -1
  196. package/dist/scenegraph/SgRoot.js +0 -87
  197. package/dist/scenegraph/SgRoot.js.map +0 -1
  198. package/dist/scenegraph/SgScriptedMesh.js +0 -213
  199. package/dist/scenegraph/SgScriptedMesh.js.map +0 -1
  200. package/dist/scenegraph/SgSky.js +0 -126
  201. package/dist/scenegraph/SgSky.js.map +0 -1
  202. package/dist/scenegraph/SgSphere.js +0 -59
  203. package/dist/scenegraph/SgSphere.js.map +0 -1
  204. package/dist/scenegraph/SgText.js +0 -182
  205. package/dist/scenegraph/SgText.js.map +0 -1
  206. package/dist/scenegraph/SgTorus.js +0 -48
  207. package/dist/scenegraph/SgTorus.js.map +0 -1
  208. package/dist/scenegraph/SgVehicle.js +0 -370
  209. package/dist/scenegraph/SgVehicle.js.map +0 -1
  210. package/dist/subsystems/AudioSystem.js +0 -128
  211. package/dist/subsystems/AudioSystem.js.map +0 -1
  212. package/dist/subsystems/Billboard.js +0 -190
  213. package/dist/subsystems/Billboard.js.map +0 -1
  214. package/dist/subsystems/FontLoader.js +0 -161
  215. package/dist/subsystems/FontLoader.js.map +0 -1
  216. package/dist/subsystems/Physics.js +0 -1079
  217. package/dist/subsystems/Physics.js.map +0 -1
  218. package/dist/subsystems/Ribbons.js +0 -179
  219. package/dist/subsystems/Ribbons.js.map +0 -1
  220. package/dist/subsystems/gridmap/GridMapBuilder.js +0 -430
  221. package/dist/subsystems/gridmap/GridMapBuilder.js.map +0 -1
  222. package/dist/subsystems/imgui/ImGui.js +0 -742
  223. package/dist/subsystems/imgui/ImGui.js.map +0 -1
  224. package/dist/subsystems/importer/Converter.js +0 -199
  225. package/dist/subsystems/importer/Converter.js.map +0 -1
  226. package/dist/subsystems/importer/ImageConverter.js +0 -77
  227. package/dist/subsystems/importer/ImageConverter.js.map +0 -1
  228. package/dist/subsystems/importer/Importer.js +0 -381
  229. package/dist/subsystems/importer/Importer.js.map +0 -1
  230. package/dist/subsystems/importer/MeshConverter.js +0 -595
  231. package/dist/subsystems/importer/MeshConverter.js.map +0 -1
  232. package/dist/subsystems/particlesystem/CurlNoiseTexturePreview.js +0 -127
  233. package/dist/subsystems/particlesystem/CurlNoiseTexturePreview.js.map +0 -1
  234. package/dist/subsystems/particlesystem/Emitters/CircleEmitter.js +0 -135
  235. package/dist/subsystems/particlesystem/Emitters/CircleEmitter.js.map +0 -1
  236. package/dist/subsystems/particlesystem/Emitters/ConeEmitter.js +0 -192
  237. package/dist/subsystems/particlesystem/Emitters/ConeEmitter.js.map +0 -1
  238. package/dist/subsystems/particlesystem/Emitters/CubeEmitter.js +0 -157
  239. package/dist/subsystems/particlesystem/Emitters/CubeEmitter.js.map +0 -1
  240. package/dist/subsystems/particlesystem/Emitters/EdgeEmitter.js +0 -133
  241. package/dist/subsystems/particlesystem/Emitters/EdgeEmitter.js.map +0 -1
  242. package/dist/subsystems/particlesystem/Emitters/Emitter.js +0 -107
  243. package/dist/subsystems/particlesystem/Emitters/Emitter.js.map +0 -1
  244. package/dist/subsystems/particlesystem/Emitters/HemiSphereEmitter.js +0 -142
  245. package/dist/subsystems/particlesystem/Emitters/HemiSphereEmitter.js.map +0 -1
  246. package/dist/subsystems/particlesystem/Emitters/MeshEmitter.js +0 -56
  247. package/dist/subsystems/particlesystem/Emitters/MeshEmitter.js.map +0 -1
  248. package/dist/subsystems/particlesystem/Emitters/SphereEmitter.js +0 -142
  249. package/dist/subsystems/particlesystem/Emitters/SphereEmitter.js.map +0 -1
  250. package/dist/subsystems/particlesystem/Emitters/TorusEmitter.js +0 -159
  251. package/dist/subsystems/particlesystem/Emitters/TorusEmitter.js.map +0 -1
  252. package/dist/subsystems/particlesystem/ParticleSystem.js +0 -706
  253. package/dist/subsystems/particlesystem/ParticleSystem.js.map +0 -1
  254. package/dist/subsystems/particlesystem/Simulation.js +0 -475
  255. package/dist/subsystems/particlesystem/Simulation.js.map +0 -1
  256. package/dist/subsystems/particlesystem/Visualization.js +0 -518
  257. package/dist/subsystems/particlesystem/Visualization.js.map +0 -1
  258. package/dist/subsystems/particlesystem/shaders/noise/CurlNoiseTexturePreviewShader.js +0 -56
  259. package/dist/subsystems/particlesystem/shaders/noise/CurlNoiseTexturePreviewShader.js.map +0 -1
  260. package/dist/subsystems/particlesystem/utils.js +0 -115
  261. package/dist/subsystems/particlesystem/utils.js.map +0 -1
  262. package/dist/subsystems/scripting/ScriptEngine.js +0 -1074
  263. package/dist/subsystems/scripting/ScriptEngine.js.map +0 -1
  264. package/dist/subsystems/scripting/ScriptRunner.js +0 -153
  265. package/dist/subsystems/scripting/ScriptRunner.js.map +0 -1
  266. package/dist/subsystems/scripting/ScriptRuntime.js +0 -244
  267. package/dist/subsystems/scripting/ScriptRuntime.js.map +0 -1
  268. package/dist/subsystems/scripting/runtime/RtAudio.js +0 -37
  269. package/dist/subsystems/scripting/runtime/RtAudio.js.map +0 -1
  270. package/dist/subsystems/scripting/runtime/RtBase.js +0 -117
  271. package/dist/subsystems/scripting/runtime/RtBase.js.map +0 -1
  272. package/dist/subsystems/scripting/runtime/RtCanvas.js +0 -326
  273. package/dist/subsystems/scripting/runtime/RtCanvas.js.map +0 -1
  274. package/dist/subsystems/scripting/runtime/RtComposer.js +0 -58
  275. package/dist/subsystems/scripting/runtime/RtComposer.js.map +0 -1
  276. package/dist/subsystems/scripting/runtime/RtConsole.js +0 -51
  277. package/dist/subsystems/scripting/runtime/RtConsole.js.map +0 -1
  278. package/dist/subsystems/scripting/runtime/RtControllers.js +0 -52
  279. package/dist/subsystems/scripting/runtime/RtControllers.js.map +0 -1
  280. package/dist/subsystems/scripting/runtime/RtEvents.js +0 -46
  281. package/dist/subsystems/scripting/runtime/RtEvents.js.map +0 -1
  282. package/dist/subsystems/scripting/runtime/RtImGui.js +0 -410
  283. package/dist/subsystems/scripting/runtime/RtImGui.js.map +0 -1
  284. package/dist/subsystems/scripting/runtime/RtItem.js +0 -297
  285. package/dist/subsystems/scripting/runtime/RtItem.js.map +0 -1
  286. package/dist/subsystems/scripting/runtime/RtLoader.js +0 -77
  287. package/dist/subsystems/scripting/runtime/RtLoader.js.map +0 -1
  288. package/dist/subsystems/scripting/runtime/RtObject.js +0 -34
  289. package/dist/subsystems/scripting/runtime/RtObject.js.map +0 -1
  290. package/dist/subsystems/scripting/runtime/RtPhysics.js +0 -69
  291. package/dist/subsystems/scripting/runtime/RtPhysics.js.map +0 -1
  292. package/dist/subsystems/scripting/runtime/RtPointer.js +0 -45
  293. package/dist/subsystems/scripting/runtime/RtPointer.js.map +0 -1
  294. package/dist/subsystems/scripting/runtime/RtProject.js +0 -66
  295. package/dist/subsystems/scripting/runtime/RtProject.js.map +0 -1
  296. package/dist/subsystems/scripting/runtime/RtRenderer.js +0 -138
  297. package/dist/subsystems/scripting/runtime/RtRenderer.js.map +0 -1
  298. package/dist/subsystems/scripting/runtime/RtSceneEntry.js +0 -67
  299. package/dist/subsystems/scripting/runtime/RtSceneEntry.js.map +0 -1
  300. package/dist/subsystems/scripting/runtime/RtSceneObject.js +0 -666
  301. package/dist/subsystems/scripting/runtime/RtSceneObject.js.map +0 -1
  302. package/dist/subsystems/scripting/runtime/RtStorage.js +0 -64
  303. package/dist/subsystems/scripting/runtime/RtStorage.js.map +0 -1
  304. package/dist/subsystems/scripting/runtime/RtSystem.js +0 -85
  305. package/dist/subsystems/scripting/runtime/RtSystem.js.map +0 -1
  306. package/dist/subsystems/scripting/runtime/RtTools.js +0 -37
  307. package/dist/subsystems/scripting/runtime/RtTools.js.map +0 -1
  308. package/dist/subsystems/scripting/runtime/RtVariables.js +0 -57
  309. package/dist/subsystems/scripting/runtime/RtVariables.js.map +0 -1
  310. package/dist/subsystems/scripting/runtime/items/RtCanvasTexture.js +0 -101
  311. package/dist/subsystems/scripting/runtime/items/RtCanvasTexture.js.map +0 -1
  312. package/dist/subsystems/scripting/runtime/items/RtMaterial.js +0 -34
  313. package/dist/subsystems/scripting/runtime/items/RtMaterial.js.map +0 -1
  314. package/dist/subsystems/scripting/runtime/items/RtMesh.js +0 -34
  315. package/dist/subsystems/scripting/runtime/items/RtMesh.js.map +0 -1
  316. package/dist/subsystems/scripting/runtime/items/RtTexture.js +0 -34
  317. package/dist/subsystems/scripting/runtime/items/RtTexture.js.map +0 -1
  318. package/dist/subsystems/scripting/runtime/items/RtVideo.js +0 -56
  319. package/dist/subsystems/scripting/runtime/items/RtVideo.js.map +0 -1
  320. package/dist/subsystems/scripting/runtime/sceneobjects/RtSgAudio.js +0 -59
  321. package/dist/subsystems/scripting/runtime/sceneobjects/RtSgAudio.js.map +0 -1
  322. package/dist/subsystems/scripting/runtime/sceneobjects/RtSgCamera.js +0 -134
  323. package/dist/subsystems/scripting/runtime/sceneobjects/RtSgCamera.js.map +0 -1
  324. package/dist/subsystems/scripting/runtime/sceneobjects/RtSgMesh.js +0 -99
  325. package/dist/subsystems/scripting/runtime/sceneobjects/RtSgMesh.js.map +0 -1
  326. package/dist/subsystems/scripting/runtime/sceneobjects/RtSgNavMesh.js +0 -114
  327. package/dist/subsystems/scripting/runtime/sceneobjects/RtSgNavMesh.js.map +0 -1
  328. package/dist/subsystems/scripting/runtime/sceneobjects/RtSgParticles.js +0 -576
  329. package/dist/subsystems/scripting/runtime/sceneobjects/RtSgParticles.js.map +0 -1
  330. package/dist/subsystems/scripting/runtime/sceneobjects/RtSgPositionalAudio.js +0 -56
  331. package/dist/subsystems/scripting/runtime/sceneobjects/RtSgPositionalAudio.js.map +0 -1
  332. package/dist/subsystems/scripting/runtime/sceneobjects/RtSgRibbon.js +0 -42
  333. package/dist/subsystems/scripting/runtime/sceneobjects/RtSgRibbon.js.map +0 -1
  334. package/dist/subsystems/scripting/runtime/sceneobjects/RtSgScriptedMesh.js +0 -65
  335. package/dist/subsystems/scripting/runtime/sceneobjects/RtSgScriptedMesh.js.map +0 -1
  336. package/dist/subsystems/scripting/runtime/sceneobjects/RtSgVehicle.js +0 -60
  337. package/dist/subsystems/scripting/runtime/sceneobjects/RtSgVehicle.js.map +0 -1
  338. package/dist/tools/AsyncInterval.js +0 -55
  339. package/dist/tools/AsyncInterval.js.map +0 -1
  340. package/dist/tools/Converters.js +0 -41
  341. package/dist/tools/Converters.js.map +0 -1
  342. package/dist/tools/DebugTools.js +0 -91
  343. package/dist/tools/DebugTools.js.map +0 -1
  344. package/dist/tools/FontTools.js +0 -43
  345. package/dist/tools/FontTools.js.map +0 -1
  346. package/dist/tools/FsShader.js +0 -112
  347. package/dist/tools/FsShader.js.map +0 -1
  348. package/dist/tools/GeometryTools.js +0 -373
  349. package/dist/tools/GeometryTools.js.map +0 -1
  350. package/dist/tools/ItemTools.js +0 -139
  351. package/dist/tools/ItemTools.js.map +0 -1
  352. package/dist/tools/MathHelpers.js +0 -125
  353. package/dist/tools/MathHelpers.js.map +0 -1
  354. package/dist/tools/Profiler.js +0 -174
  355. package/dist/tools/Profiler.js.map +0 -1
  356. package/dist/tools/Random.js +0 -48
  357. package/dist/tools/Random.js.map +0 -1
  358. package/dist/tools/RtDebugger.js +0 -84
  359. package/dist/tools/RtDebugger.js.map +0 -1
  360. package/dist/tools/StringExtensions.js +0 -72
  361. package/dist/tools/StringExtensions.js.map +0 -1
  362. package/dist/tools/TextureTools.js +0 -444
  363. package/dist/tools/TextureTools.js.map +0 -1
  364. package/dist/tools/Timer.js +0 -52
  365. package/dist/tools/Timer.js.map +0 -1
  366. package/dist/tools/audioVisualizers/WavyAudioVisualizer.js +0 -59
  367. package/dist/tools/audioVisualizers/WavyAudioVisualizer.js.map +0 -1
  368. /package/dist/renderers/{forwardrenderer.d.ts → ForwardRenderer.d.ts} +0 -0
  369. /package/dist/subsystems/imgui/{imgui.d.ts → ImGui.d.ts} +0 -0
  370. /package/dist/subsystems/importer/{imageconverter.d.ts → ImageConverter.d.ts} +0 -0
  371. /package/dist/subsystems/scripting/{scriptrunner.d.ts → ScriptRunner.d.ts} +0 -0
  372. /package/dist/subsystems/scripting/{scriptruntime.d.ts → ScriptRuntime.d.ts} +0 -0
  373. /package/dist/subsystems/scripting/runtime/{rtAudio.d.ts → RtAudio.d.ts} +0 -0
  374. /package/dist/subsystems/scripting/runtime/{rtComposer.d.ts → RtComposer.d.ts} +0 -0
  375. /package/dist/subsystems/scripting/runtime/{rtObject.d.ts → RtObject.d.ts} +0 -0
@@ -1,1079 +0,0 @@
1
- // -----------------------------------------------------------------------------------------------------------
2
- // __ ______ __ __ ______ __ __ ______ ______ ______
3
- // /\ \ /\ ___\ /\ "-./ \ /\ __ \ /\ "-.\ \ /\ __ \ /\__ _\ /\ ___\
4
- // \ \ \____ \ \ __\ \ \ \-./\ \ \ \ \/\ \ \ \ \-. \ \ \ __ \ \/_/\ \/ \ \ __\
5
- // \ \_____\ \ \_____\ \ \_\ \ \_\ \ \_____\ \ \_\\"\_\ \ \_\ \_\ \ \_\ \ \_____\
6
- // \/_____/ \/_____/ \/_/ \/_/ \/_____/ \/_/ \/_/ \/_/\/_/ \/_/ \/_____/
7
- //
8
- //
9
- // Copyright 2023- Luminocity AG
10
- //
11
- // "The legend never dies." - Apex Legends (2019)
12
- //
13
- // Permission is hereby granted, free of charge, to any person obtaining a copy of this software
14
- // and associated documentation files (the “Software”), to deal in the Software without restriction,
15
- // including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
16
- // and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
17
- // subject to the following conditions:
18
- //
19
- // The above copyright notice and this permission notice shall be included in all copies or substantial
20
- // portions of the Software.
21
- //
22
- // THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
23
- // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24
- // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25
- // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26
- // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
- // -----------------------------------------------------------------------------------------------------------
28
- import PhysicsWorkerUrl from "../../temp/physicsworker";
29
- import { InvalidArgumentException, InvalidStateException, EventEmitter, } from "@luminocity/lemonate-gateway";
30
- import tools from "../Tools.js";
31
- import { SgVehicle } from "../scenegraph/SgVehicle";
32
- import { BufferAttribute, BufferGeometry, LineBasicMaterial, LineSegments } from "three";
33
- import { SgPhysicsSubItem } from "../scenegraph/SgPhysicsSubItem.js";
34
- export var PhysicsConstraint;
35
- (function (PhysicsConstraint) {
36
- PhysicsConstraint["PointToPoint"] = "pointToPoint";
37
- PhysicsConstraint["Hinge"] = "hinge";
38
- PhysicsConstraint["Slider"] = "slider";
39
- PhysicsConstraint["ConeTwist"] = "coneTwist";
40
- })(PhysicsConstraint || (PhysicsConstraint = {}));
41
- export var PhysicsDebugMode;
42
- (function (PhysicsDebugMode) {
43
- PhysicsDebugMode[PhysicsDebugMode["Off"] = 0] = "Off";
44
- PhysicsDebugMode[PhysicsDebugMode["Wireframe"] = 1] = "Wireframe";
45
- PhysicsDebugMode[PhysicsDebugMode["Slider"] = 2] = "Slider";
46
- PhysicsDebugMode[PhysicsDebugMode["Raycast"] = 3] = "Raycast";
47
- })(PhysicsDebugMode || (PhysicsDebugMode = {}));
48
- export var RaycastType;
49
- (function (RaycastType) {
50
- RaycastType["AllHits"] = "AllHits";
51
- RaycastType["Closest"] = "Closest";
52
- })(RaycastType || (RaycastType = {}));
53
- const DefaultBufferSize = 3 * 1000000;
54
- const CONSTRAINT_TYPES = [
55
- "pointToPoint",
56
- "hinge",
57
- "slider",
58
- "coneTwist",
59
- ];
60
- export class Physics extends EventEmitter {
61
- engine;
62
- worker;
63
- bodyMap = new Map();
64
- constraintMap = new Map();
65
- vehiclesMap = new Map();
66
- workerPromises = new Map();
67
- collisionMatrix = [];
68
- ready = false;
69
- running = false;
70
- framesCalculated = 0;
71
- waitForFramesAndStop = 0;
72
- softBodyRequired = true;
73
- debugInfo;
74
- debugMode = PhysicsDebugMode.Off;
75
- raycastDebugInfo = [];
76
- // Those arrays will store information about the last detected collisions
77
- lastPhysicsData;
78
- lastCollisions;
79
- lastCollidedObjects;
80
- // Debug geometry
81
- debugVertices;
82
- debugColors;
83
- debugGeometry;
84
- debugMaterial;
85
- debugMesh;
86
- constructor(engine) {
87
- super();
88
- this.engine = engine;
89
- // Set the default collision matrix which is layer 0 collides with itself but nothing else.
90
- this.setCollisionMatrix([[0]]);
91
- }
92
- async init() {
93
- const promise = new Promise((resolve, reject) => {
94
- this.$on("ready", () => {
95
- this.setPhysicsDebugMode(this.debugMode);
96
- resolve();
97
- });
98
- this.$on("fatal", () => {
99
- reject("Fatal error in physics worker!");
100
- });
101
- });
102
- function dataURItoBlob(dataURI) {
103
- const mime = dataURI.split(',')[0].split(':')[1].split(';')[0];
104
- const binary = atob(dataURI.split(',')[1]);
105
- const array = [];
106
- for (let i = 0; i < binary.length; i++) {
107
- array.push(binary.charCodeAt(i));
108
- }
109
- return new Blob([new Uint8Array(array)], { type: mime });
110
- }
111
- const workerObjectUrl = URL.createObjectURL(dataURItoBlob(PhysicsWorkerUrl));
112
- this.worker = new Worker(workerObjectUrl);
113
- URL.revokeObjectURL(workerObjectUrl);
114
- this.worker.onmessage = async (event) => {
115
- const data = event.data;
116
- switch (data.type) {
117
- case "ready":
118
- this.ready = true;
119
- await this.$emit("ready");
120
- break;
121
- case "fatal": {
122
- await this.$emit("fatal");
123
- break;
124
- }
125
- case "data": {
126
- if (this.running) {
127
- await this._update(data.data);
128
- }
129
- break;
130
- }
131
- case "debug": {
132
- if (this.running && this.debugMode) {
133
- this.debugInfo = data.data;
134
- }
135
- break;
136
- }
137
- case "raycastResult": {
138
- const p = this.workerPromises.get(data.id);
139
- if (p) {
140
- this.workerPromises.delete(data.id);
141
- p.resolve(data.data);
142
- if (this.debugMode === PhysicsDebugMode.Raycast) {
143
- this.debugInfo = null;
144
- const hits = this._extractHits(data.data);
145
- this._addRaycastDebugInfo(p.startVectors, p.endVectors, hits);
146
- }
147
- }
148
- break;
149
- }
150
- case "convexSweepTestResult": {
151
- const p = this.workerPromises.get(data.id);
152
- if (p) {
153
- this.workerPromises.delete(data.id);
154
- p.resolve(data.data);
155
- }
156
- break;
157
- }
158
- }
159
- };
160
- return promise;
161
- }
162
- // returns a flat array of hits from all possible raycast results
163
- _extractHits(input) {
164
- const hits = [];
165
- function arrayExtract(value) {
166
- if (Array.isArray(value)) {
167
- for (const item of value) {
168
- arrayExtract(item);
169
- }
170
- }
171
- else if (typeof value === 'object' && value !== null) {
172
- if ('hit' in value) {
173
- if (value.hit) {
174
- hits.push(value);
175
- }
176
- }
177
- else {
178
- for (const key in value) {
179
- arrayExtract(value[key]);
180
- }
181
- }
182
- }
183
- }
184
- arrayExtract(input);
185
- return hits;
186
- }
187
- _addRaycastDebugInfo(startVectors, endVectors, data) {
188
- if (!data)
189
- return;
190
- startVectors.forEach((vec, i) => {
191
- const hit = data[i];
192
- if (hit) {
193
- this.raycastDebugInfo.push({
194
- startVector: vec,
195
- point: hit.point,
196
- normal: hit.normal,
197
- hit: true
198
- });
199
- }
200
- else {
201
- this.raycastDebugInfo.push({
202
- startVector: vec,
203
- point: endVectors[i],
204
- hit: false
205
- });
206
- }
207
- });
208
- }
209
- setWaitFramesAndStop(count) {
210
- this.waitForFramesAndStop = count;
211
- }
212
- async waitForStop() {
213
- return new Promise((resolve, reject) => {
214
- if (!this.running)
215
- resolve();
216
- setInterval(() => {
217
- if (!this.running)
218
- resolve();
219
- }, 20);
220
- });
221
- }
222
- setPhysicsDebugMode(mode) {
223
- this.debugMode = mode;
224
- if (this.worker) {
225
- // clear the old information
226
- this.debugInfo = null;
227
- // in case we switched to raycasts debug mode, we post the "Off" mode to physics since this one
228
- // we handle directly in this class, not in physics itself
229
- if (mode === PhysicsDebugMode.Raycast)
230
- mode = PhysicsDebugMode.Off;
231
- this.worker.postMessage({
232
- type: "setDebugMode",
233
- data: mode,
234
- });
235
- }
236
- }
237
- getDebugMode() {
238
- return this.debugMode;
239
- }
240
- setCollisionMatrix(collisionMatrix) {
241
- if (!Array.isArray(collisionMatrix)) {
242
- console.error("Collision matrix must be an array.");
243
- return;
244
- }
245
- const matrix = [];
246
- const layerCount = this.engine.renderer.getLayers().length;
247
- for (let i = 0; i < layerCount; i++) {
248
- matrix.push(new Array(layerCount).fill(0, 0, layerCount));
249
- }
250
- for (const [i, value] of collisionMatrix.entries()) {
251
- if (!Array.isArray(value)) {
252
- console.error("Collision matrix must be an array of arrays, containing integers");
253
- }
254
- else {
255
- for (const j of value) {
256
- if (i < layerCount && j >= 0 && j < layerCount) {
257
- matrix[i][j] = 1;
258
- matrix[j][i] = 1;
259
- }
260
- }
261
- }
262
- }
263
- this.collisionMatrix = matrix;
264
- this.engine.mainSceneGraphCollection.forEachItem((item) => {
265
- if (item.isPhysicsItem()) {
266
- item.readdToPhysics();
267
- }
268
- });
269
- }
270
- getCollisionMaskAndGroupForLayer(indices) {
271
- let group = 0;
272
- let mask = 0;
273
- // every object allows to be hit by the raycasting group (0)
274
- mask |= 1 << 0;
275
- // offset layers and masks by one since the first layer is reserved for raycasting
276
- for (const i of indices) {
277
- group |= 1 << i + 1;
278
- for (const [j, on] of this.collisionMatrix[i].entries()) {
279
- if (on)
280
- mask |= 1 << j + 1;
281
- }
282
- }
283
- return { group, mask };
284
- }
285
- _sendBodyMessage(id, message, data) {
286
- if (!this.ready || !this.worker)
287
- throw new InvalidStateException("Physics engine not ready");
288
- if (this.bodyMap.has(id)) {
289
- data = data || {};
290
- data.id = id;
291
- this.worker.postMessage({
292
- type: message,
293
- data: data,
294
- });
295
- }
296
- else {
297
- console.error("[PHYSICS] Body to send message to not found!");
298
- }
299
- }
300
- _sendVehicleMessage(id, message, data) {
301
- if (!this.ready || !this.worker)
302
- throw new InvalidStateException("Physics engine not ready");
303
- if (this.vehiclesMap.has(id)) {
304
- data.id = id;
305
- this.worker.postMessage({
306
- type: message,
307
- data: data,
308
- });
309
- }
310
- else {
311
- console.error("[PHYSICS] Vehicle to send message to not found!");
312
- }
313
- }
314
- reset() {
315
- if (!this.ready || !this.worker)
316
- throw new InvalidStateException("Physics engine not ready");
317
- this.worker.postMessage({
318
- type: "reset",
319
- data: this.softBodyRequired,
320
- });
321
- }
322
- start() {
323
- if (!this.ready || !this.worker)
324
- throw new InvalidStateException("Physics engine not ready");
325
- this.running = true;
326
- this.framesCalculated = 0;
327
- this.worker.postMessage({
328
- type: "start",
329
- });
330
- }
331
- stop() {
332
- if (!this.ready || !this.worker)
333
- throw new InvalidStateException("Physics engine not ready");
334
- this.worker.postMessage({
335
- type: "stop",
336
- });
337
- this.running = false;
338
- this.lastPhysicsData = null;
339
- }
340
- pause() {
341
- if (!this.ready || !this.worker)
342
- throw new InvalidStateException("Physics engine not ready");
343
- this.worker.postMessage({
344
- type: "pause",
345
- });
346
- }
347
- resume() {
348
- if (!this.ready || !this.worker)
349
- throw new InvalidStateException("Physics engine not ready");
350
- this.worker.postMessage({
351
- type: "resume",
352
- });
353
- }
354
- userPause() {
355
- if (!this.ready || !this.worker)
356
- throw new InvalidStateException("Physics engine not ready");
357
- this.worker.postMessage({
358
- type: "userPause",
359
- });
360
- }
361
- userResume() {
362
- if (!this.ready || !this.worker)
363
- throw new InvalidStateException("Physics engine not ready");
364
- this.worker.postMessage({
365
- type: "userResume",
366
- });
367
- }
368
- clearDebugInfo() {
369
- this.debugInfo = null;
370
- this.raycastDebugInfo = [];
371
- }
372
- clear() {
373
- if (!this.ready || !this.worker)
374
- throw new InvalidStateException("Physics engine not ready");
375
- this.worker.postMessage({
376
- type: "clear",
377
- });
378
- }
379
- setGravity(vector) {
380
- if (!this.ready || !this.worker)
381
- throw new InvalidStateException("Physics engine not ready");
382
- this.worker.postMessage({
383
- type: "setGravity",
384
- data: vector,
385
- });
386
- }
387
- _cloneData(data) {
388
- // We have to filter out any proxies that might be in the data, otherwise
389
- // we'll get an error because proxies cannot be sent to a worker. To do that
390
- // we just JSON-clone everything except if it is a Float32Array because they will break
391
- // by doing that.
392
- const clonedData = {};
393
- for (const key in data) {
394
- const val = data[key];
395
- if (!val || val instanceof Float32Array || val instanceof Uint16Array) {
396
- clonedData[key] = val;
397
- }
398
- else {
399
- clonedData[key] = JSON.parse(JSON.stringify(val));
400
- }
401
- }
402
- return clonedData;
403
- }
404
- _prepareAndCloneData(data, owner, Type) {
405
- Type = Type || SgPhysicsSubItem;
406
- if (!this.ready || !this.worker)
407
- throw new InvalidStateException("Physics engine not ready");
408
- if (!(owner instanceof Type))
409
- throw new InvalidStateException("Cannot add object to physics, owner is not a physics enabled item.");
410
- data = this._cloneData(data);
411
- const cm = this.getCollisionMaskAndGroupForLayer(owner.getLayerIndices());
412
- data.mask = cm.mask;
413
- data.group = cm.group;
414
- data.id = tools.createGUID();
415
- data.ownerId = owner.getId();
416
- return {
417
- owner: owner,
418
- data: data
419
- };
420
- }
421
- /**
422
- * Add a rigid body to the physics engine
423
- * @param owner the owning sgphysicsitem
424
- * @param data the physics data of the object
425
- * @return {*|null}
426
- */
427
- addRigidBody(owner, data) {
428
- if (!this.ready || !this.worker)
429
- throw new InvalidStateException("Physics engine not ready");
430
- const body = this._prepareAndCloneData(data, owner);
431
- try {
432
- this.worker.postMessage({
433
- type: "addRigidBody",
434
- data: body.data,
435
- });
436
- this.bodyMap.set(body.data.id, body);
437
- }
438
- catch (err) {
439
- console.error(err);
440
- }
441
- return body.data.id;
442
- }
443
- removeRigidBody(id) {
444
- if (!this.ready || !this.worker)
445
- throw new InvalidStateException("Physics engine not ready");
446
- if (this.bodyMap.has(id)) {
447
- this.bodyMap.delete(id);
448
- this.worker.postMessage({
449
- type: "removeRigidBody",
450
- data: id
451
- });
452
- }
453
- }
454
- /**
455
- * Add a ghost object to physics engine
456
- * @param owner
457
- * @param data
458
- * @return {*|null}
459
- */
460
- addGhostObject(owner, data) {
461
- if (!this.ready || !this.worker)
462
- throw new InvalidStateException("Physics engine not ready");
463
- const body = this._prepareAndCloneData(data, owner);
464
- try {
465
- this.worker.postMessage({
466
- type: "addGhostObject",
467
- data: body.data,
468
- });
469
- this.bodyMap.set(body.data.id, body);
470
- }
471
- catch (err) {
472
- console.error(err);
473
- }
474
- return body.data.id;
475
- }
476
- removeGhostObject(id) {
477
- if (!this.ready || !this.worker)
478
- throw new InvalidStateException("Physics engine not ready");
479
- if (this.bodyMap.has(id)) {
480
- this.bodyMap.delete(id);
481
- this.worker.postMessage({
482
- type: "removeGhostObject",
483
- data: id,
484
- });
485
- }
486
- }
487
- addVehicle(owner, data) {
488
- if (!this.ready || !this.worker)
489
- throw new InvalidStateException("Physics engine not ready");
490
- const body = this._prepareAndCloneData(data, owner, SgVehicle);
491
- try {
492
- this.worker.postMessage({
493
- type: "addVehicle",
494
- data: body.data,
495
- });
496
- this.vehiclesMap.set(body.data.id, body);
497
- }
498
- catch (err) {
499
- console.error(err);
500
- }
501
- return body.data.id;
502
- }
503
- removeVehicle(id) {
504
- if (!this.ready || !this.worker)
505
- throw new InvalidStateException("Physics engine not ready");
506
- if (this.vehiclesMap.has(id)) {
507
- this.vehiclesMap.delete(id);
508
- this.worker.postMessage({
509
- type: "removeVehicle",
510
- data: id,
511
- });
512
- }
513
- }
514
- /**
515
- * Steer a vehicle. Wheels should be an array of { index, value } objects
516
- * @param object
517
- * @param wheels
518
- */
519
- steerVehicle(id, wheels) {
520
- this._sendVehicleMessage(id, "steerVehicle", {
521
- wheels: wheels,
522
- });
523
- }
524
- /**
525
- * Brake a vehicle. Wheels should be an array of { index, value } objects
526
- * @param object
527
- * @param wheels
528
- */
529
- brakeVehicle(id, wheels) {
530
- this._sendVehicleMessage(id, "brakeVehicle", {
531
- wheels: wheels,
532
- });
533
- }
534
- /**
535
- * Accelerate a vehicle. Wheels should be an array of { index, value } objects
536
- * @param object
537
- * @param wheels
538
- */
539
- accelerateVehicle(id, wheels) {
540
- this._sendVehicleMessage(id, "accelerateVehicle", {
541
- wheels: wheels,
542
- });
543
- }
544
- /**
545
- * Add a softbody to physics engine
546
- * @param owner the owning sgphysicsitem
547
- * @param data
548
- * @return {string}
549
- */
550
- addSoftBody(owner, data) {
551
- if (!this.ready || !this.worker)
552
- throw new InvalidStateException("Physics engine not ready");
553
- const body = this._prepareAndCloneData(data, owner);
554
- try {
555
- this.worker.postMessage({
556
- type: "addSoftBody",
557
- data: body.data
558
- });
559
- this.bodyMap.set(body.data.id, body);
560
- }
561
- catch (err) {
562
- console.error(err);
563
- }
564
- return body.data.id;
565
- }
566
- removeSoftBody(id) {
567
- if (!this.ready || !this.worker)
568
- throw new InvalidStateException("Physics engine not ready");
569
- if (this.bodyMap.has(id)) {
570
- this.bodyMap.delete(id);
571
- this.worker.postMessage({
572
- type: "removeSoftBody",
573
- data: id,
574
- });
575
- }
576
- }
577
- resetBody(id) {
578
- this._sendBodyMessage(id, "resetBody");
579
- }
580
- getMaskFromLayerNames(filterLayers) {
581
- if (filterLayers === null || filterLayers === undefined) {
582
- return -1; // will match all layers
583
- }
584
- let mask = 0;
585
- const layerNames = this.engine.renderer.getLayers();
586
- layerNames.forEach((name, index) => {
587
- if (filterLayers.includes(name)) {
588
- mask |= 1 << index + 1; // offset by one since the first layer is reserved for raycasting
589
- }
590
- });
591
- if (mask === 0) {
592
- console.warn("No layers matched the raycasting filter. Matching all layers.");
593
- return -1;
594
- }
595
- return mask;
596
- }
597
- /**
598
- * Send a ray cast
599
- * @param startVector Start vector
600
- * @param endVector End vector
601
- * @param raycastType Type of raycast. Needs to be "Closest" or "AllHits"
602
- * @param filterLayers Optional array of layer names to filter results. If null, no filtering is applied.
603
- * @return Promise<object> returns a promise that resolves into a ray cast result object, containing point, normal and object handle
604
- */
605
- raycast(startVector, endVector, raycastType, filterLayers) {
606
- if (!this.ready || !this.worker)
607
- throw new InvalidStateException("Physics engine not ready");
608
- const id = tools.createGUID();
609
- let promiseResolve;
610
- let promiseReject;
611
- const promise = new Promise((resolve, reject) => {
612
- promiseResolve = resolve;
613
- promiseReject = reject;
614
- this.worker.postMessage({
615
- type: "raycast",
616
- data: {
617
- id: id,
618
- startVector: startVector,
619
- endVector: endVector,
620
- type: raycastType,
621
- mask: this.getMaskFromLayerNames(filterLayers),
622
- },
623
- });
624
- });
625
- this.workerPromises.set(id, {
626
- promise: promise,
627
- resolve: promiseResolve,
628
- reject: promiseReject,
629
- startVectors: [startVector],
630
- endVectors: [endVector]
631
- });
632
- return promise;
633
- }
634
- /**
635
- * Send many ray casts
636
- * @param startVectors Array of start vectors
637
- * @param endVectors Array of end vectors
638
- * @param raycastType Type of raycast. Needs to be "Closest" or "AllHits"
639
- * @param filterLayers Optional array of layer names to filter results. If null, no filtering is applied.
640
- * @return Promise<array> returns a promise that resolves into an array of ray cast result objects, containing point, normal and object handle
641
- */
642
- raycastMany(startVectors, endVectors, raycastType, filterLayers) {
643
- if (!this.ready || !this.worker)
644
- throw new InvalidStateException("Physics engine not ready");
645
- const id = tools.createGUID();
646
- let promiseResolve;
647
- let promiseReject;
648
- const promise = new Promise((resolve, reject) => {
649
- promiseResolve = resolve;
650
- promiseReject = reject;
651
- this.worker.postMessage({
652
- type: "raycastMany",
653
- data: {
654
- id: id,
655
- startVectors: startVectors,
656
- endVectors: endVectors,
657
- type: raycastType,
658
- mask: this.getMaskFromLayerNames(filterLayers),
659
- },
660
- });
661
- });
662
- this.workerPromises.set(id, {
663
- promise: promise,
664
- resolve: promiseResolve,
665
- reject: promiseReject,
666
- startVectors: startVectors,
667
- endVectors: endVectors
668
- });
669
- return promise;
670
- }
671
- /**
672
- * Send a convex sweep test
673
- * @param startVector Start vector
674
- * @param endVector End vector
675
- * @param shape Shape object, containing at least .type with the type of shape to use. Possible values: "Sphere". Sphere also requires .radius
676
- * @param filterLayers Optional array of layer names to filter results. If null, no filtering is applied.
677
- * @return Promise<object> returns a promise that resolves into a ray cast result object, containing point, normal and object handle
678
- */
679
- convexSweepTest(startVector, endVector, shape, filterLayers) {
680
- if (!this.ready || !this.worker)
681
- throw new InvalidStateException("Physics engine not ready");
682
- const id = tools.createGUID();
683
- let promiseResolve;
684
- let promiseReject;
685
- const promise = new Promise((resolve, reject) => {
686
- promiseResolve = resolve;
687
- promiseReject = reject;
688
- this.worker.postMessage({
689
- type: "convexSweepTest",
690
- data: {
691
- id: id,
692
- startVector: startVector,
693
- endVector: endVector,
694
- shape: shape,
695
- mask: this.getMaskFromLayerNames(filterLayers),
696
- },
697
- });
698
- });
699
- this.workerPromises.set(id, {
700
- promise: promise,
701
- resolve: promiseResolve,
702
- reject: promiseReject,
703
- startVectors: [startVector],
704
- endVectors: [endVector]
705
- });
706
- return promise;
707
- }
708
- /**
709
- * Send many convex sweep tests
710
- * @param startVectors Array of start vectors
711
- * @param endVectors Array of end vectors
712
- * @param shape Shape object, containing at least .type with the type of shape to use. Possible values: "Sphere". Sphere also requires .radius
713
- * @param filterLayers Optional array of layer names to filter results. If null, no filtering is applied.
714
- * @return Promise<array> returns a promise that resolves into an array of ray cast result objects, containing point, normal and object handle
715
- */
716
- convexSweepTestMany(startVectors, endVectors, shape, filterLayers) {
717
- if (!this.ready || !this.worker)
718
- throw new InvalidStateException("Physics engine not ready");
719
- const id = tools.createGUID();
720
- let promiseResolve;
721
- let promiseReject;
722
- const promise = new Promise((resolve, reject) => {
723
- promiseResolve = resolve;
724
- promiseReject = reject;
725
- this.worker.postMessage({
726
- type: "convexSweepTestMany",
727
- data: {
728
- id: id,
729
- startVectors: startVectors,
730
- endVectors: endVectors,
731
- shape: shape,
732
- mask: this.getMaskFromLayerNames(filterLayers),
733
- },
734
- });
735
- });
736
- this.workerPromises.set(id, {
737
- promise: promise,
738
- resolve: promiseResolve,
739
- reject: promiseReject,
740
- startVectors: startVectors,
741
- endVectors: endVectors
742
- });
743
- return promise;
744
- }
745
- watchCollisions(id, enabled) {
746
- this._sendBodyMessage(id, "watchCollisions", {
747
- value: enabled,
748
- });
749
- }
750
- reportContactPoints(id, enabled) {
751
- this._sendBodyMessage(id, "reportContactPoints", {
752
- value: enabled,
753
- });
754
- }
755
- filterPotentialCollisions(id, enabled) {
756
- this._sendBodyMessage(id, "filterPotentialCollisions", {
757
- value: enabled,
758
- });
759
- }
760
- watchLinearVelocity(id, enabled) {
761
- this._sendBodyMessage(id, "watchLinearVelocity", {
762
- value: enabled,
763
- });
764
- }
765
- watchAngularVelocity(id, enabled) {
766
- this._sendBodyMessage(id, "watchAngularVelocity", {
767
- value: enabled,
768
- });
769
- }
770
- setRestitution(id, value) {
771
- this._sendBodyMessage(id, "setRestitution", {
772
- value: value,
773
- });
774
- }
775
- setFriction(id, value) {
776
- this._sendBodyMessage(id, "setFriction", {
777
- value: value,
778
- });
779
- }
780
- setSpinningFriction(id, value) {
781
- this._sendBodyMessage(id, "setSpinningFriction", {
782
- value: value,
783
- });
784
- }
785
- setRollingFriction(id, value) {
786
- this._sendBodyMessage(id, "setRollingFriction", {
787
- value: value,
788
- });
789
- }
790
- setLinearDamping(id, value) {
791
- this._sendBodyMessage(id, "setLinearDamping", {
792
- value: value,
793
- });
794
- }
795
- setAngularDamping(id, value) {
796
- this._sendBodyMessage(id, "setAngularDamping", {
797
- value: value,
798
- });
799
- }
800
- setPosition(id, position) {
801
- this._sendBodyMessage(id, "setPosition", {
802
- value: position,
803
- });
804
- }
805
- setRotation(id, rotation) {
806
- this._sendBodyMessage(id, "setRotation", {
807
- value: rotation,
808
- });
809
- }
810
- updateTransform(id, transform) {
811
- if (!this.ready || !this.worker)
812
- throw new InvalidStateException("Physics engine not ready");
813
- if (this.bodyMap.has(id)) {
814
- const body = this.bodyMap.get(id);
815
- transform = transform || body.owner.getWorldTransform();
816
- if (transform) {
817
- this.worker.postMessage({
818
- type: "setTransform",
819
- data: {
820
- id: id,
821
- position: transform.position,
822
- rotation: transform.rotation,
823
- scale: transform.scale,
824
- },
825
- });
826
- }
827
- }
828
- }
829
- disableDeactivation(id) {
830
- if (!this.ready || !this.worker)
831
- throw new InvalidStateException("Physics engine not ready");
832
- if (this.bodyMap.has(id)) {
833
- this.worker.postMessage({
834
- type: "disableDeactivation",
835
- data: id,
836
- });
837
- }
838
- }
839
- setLinearVelocity(id, vector) {
840
- this._sendBodyMessage(id, "setLinearVelocity", {
841
- vector: vector,
842
- });
843
- }
844
- setLinearFactor(id, vector) {
845
- this._sendBodyMessage(id, "setLinearFactor", {
846
- vector: vector,
847
- });
848
- }
849
- setAngularVelocity(id, vector) {
850
- this._sendBodyMessage(id, "setAngularVelocity", {
851
- vector: vector,
852
- });
853
- }
854
- setAngularFactor(id, vector) {
855
- this._sendBodyMessage(id, "setAngularFactor", {
856
- vector: vector,
857
- });
858
- }
859
- clearForces(id) {
860
- this._sendBodyMessage(id, "clearForces");
861
- }
862
- applyForce(id, vector, relPos) {
863
- this._sendBodyMessage(id, "applyForce", {
864
- vector: vector,
865
- relPos: relPos,
866
- });
867
- }
868
- applyImpulse(id, vector, relPos) {
869
- this._sendBodyMessage(id, "applyImpulse", {
870
- vector: vector,
871
- relPos: relPos,
872
- });
873
- }
874
- applyPushImpulse(id, vector, relPos) {
875
- this._sendBodyMessage(id, "applyPushImpulse", {
876
- vector: vector,
877
- relPos: relPos,
878
- });
879
- }
880
- applyCentralImpulse(id, vector) {
881
- this._sendBodyMessage(id, "applyCentralImpulse", {
882
- vector: vector
883
- });
884
- }
885
- applyCentralPushImpulse(id, vector) {
886
- this._sendBodyMessage(id, "applyCentralPushImpulse", {
887
- vector: vector,
888
- });
889
- }
890
- applyTorque(id, vector) {
891
- this._sendBodyMessage(id, "applyTorque", {
892
- vector: vector,
893
- });
894
- }
895
- addConstraint(type, params) {
896
- if (!this.ready || !this.worker)
897
- throw new InvalidStateException("Physics engine not ready");
898
- if (!CONSTRAINT_TYPES.includes(type))
899
- throw new InvalidArgumentException(`Invalid constraint type '${type}'. Allowed are ${CONSTRAINT_TYPES.join(",")}`);
900
- const data = {
901
- id: tools.createGUID(),
902
- jointType: type,
903
- body1: params.bodyId1,
904
- body2: params.bodyId2,
905
- disableCollisions: params.disableCollisions || false,
906
- };
907
- switch (type) {
908
- case "pointToPoint":
909
- data.pivot1 = params.point1;
910
- data.pivot2 = params.point2;
911
- break;
912
- case "hinge":
913
- data.pivot1 = params.point1;
914
- data.pivot2 = params.point2;
915
- data.axis1 = params.axis1;
916
- data.axis2 = params.axis2;
917
- data.useReferenceFrameA = params.useReferenceFrameA;
918
- break;
919
- case "slider":
920
- data.quat1 = params.quat1;
921
- data.quat2 = params.quat2;
922
- data.trans1 = params.trans1;
923
- data.trans2 = params.trans2;
924
- data.useLinearReferenceFrameA = params.useLinearReferenceFrameA;
925
- break;
926
- case "coneTwist":
927
- data.quat1 = params.quat1;
928
- data.quat2 = params.quat2;
929
- data.trans1 = params.trans1;
930
- data.trans2 = params.trans2;
931
- break;
932
- default:
933
- throw new InvalidArgumentException(`Unsupported constraint type '${type}'`);
934
- }
935
- this.constraintMap.set(data.id, data);
936
- this.worker.postMessage({
937
- type: "addConstraint",
938
- data: data,
939
- });
940
- return data.id;
941
- }
942
- removeConstraint(id) {
943
- if (!this.ready || !this.worker)
944
- throw new InvalidStateException("Physics engine not ready");
945
- if (this.constraintMap.has(id)) {
946
- this.constraintMap.delete(id);
947
- this.worker.postMessage({
948
- type: "removeConstraint",
949
- data: id,
950
- });
951
- }
952
- }
953
- resolveOwnerId(id) {
954
- const body = this.bodyMap.get(id);
955
- if (!body)
956
- return null;
957
- return body.owner.getId();
958
- }
959
- processPhysicsUpdate() {
960
- try {
961
- if (!this.lastPhysicsData || !this.running) {
962
- return;
963
- }
964
- let data = this.lastPhysicsData;
965
- this.lastPhysicsData = null;
966
- for (const object of data.objects) {
967
- const body = this.bodyMap.get(object.id);
968
- if (body)
969
- body.owner._physicsUpdate(object, data.timing);
970
- }
971
- for (const object of data.vehicles) {
972
- const vehicle = this.vehiclesMap.get(object.id);
973
- if (vehicle)
974
- vehicle.owner._physicsUpdate(object, data.timing);
975
- }
976
- if (Array.isArray(data.collisions) && data.collisions.length > 0) {
977
- const objects = [];
978
- for (const collision of data.collisions) {
979
- const ownerId1 = this.resolveOwnerId(collision.object1.id);
980
- const ownerId2 = this.resolveOwnerId(collision.object2.id);
981
- objects.push({ object1: ownerId1, object2: ownerId2, contactPoints: collision.contactPoints });
982
- }
983
- this.lastCollisions = data.collisions;
984
- this.lastCollidedObjects = objects;
985
- this.engine.player.pushEvent({
986
- type: "physicsCollisions",
987
- data: this.lastCollidedObjects,
988
- });
989
- }
990
- }
991
- catch (err) {
992
- console.error(err);
993
- }
994
- }
995
- initDebugDrawing(scene) {
996
- this.debugVertices = new Float32Array(DefaultBufferSize);
997
- this.debugColors = new Float32Array(DefaultBufferSize);
998
- this.debugGeometry = new BufferGeometry();
999
- this.debugGeometry.setAttribute("position", new BufferAttribute(this.debugVertices, 3));
1000
- this.debugGeometry.setAttribute("color", new BufferAttribute(this.debugColors, 3));
1001
- this.debugMaterial = new LineBasicMaterial({ vertexColors: true });
1002
- this.debugMesh = new LineSegments(this.debugGeometry, this.debugMaterial);
1003
- this.debugMesh.name = "PhysicsDebugMesh";
1004
- this.debugMesh.frustumCulled = false;
1005
- scene.add(this.debugMesh);
1006
- }
1007
- renderDebugInfo() {
1008
- if (!this.debugVertices || !this.debugColors || !this.debugGeometry || !this.debugMesh)
1009
- return;
1010
- if (this.debugInfo || this.raycastDebugInfo.length) {
1011
- let ti = 0;
1012
- if (this.debugInfo) {
1013
- const vertices = this.debugInfo.vertices;
1014
- const colors = this.debugInfo.colors;
1015
- if (vertices.length) {
1016
- for (let i = 0; i < vertices.length; i++) {
1017
- this.debugVertices[ti] = vertices[i];
1018
- this.debugColors[ti] = colors[i];
1019
- ti++;
1020
- }
1021
- }
1022
- }
1023
- for (const entry of this.raycastDebugInfo) {
1024
- this.debugVertices[ti] = entry.startVector.x;
1025
- this.debugVertices[ti + 1] = entry.startVector.y;
1026
- this.debugVertices[ti + 2] = entry.startVector.z;
1027
- this.debugVertices[ti + 3] = entry.point.x;
1028
- this.debugVertices[ti + 4] = entry.point.y;
1029
- this.debugVertices[ti + 5] = entry.point.z;
1030
- if (entry.hit) {
1031
- this.debugColors[ti] = 0;
1032
- this.debugColors[ti + 1] = 1;
1033
- this.debugColors[ti + 2] = 0;
1034
- this.debugColors[ti + 3] = 0;
1035
- this.debugColors[ti + 4] = 1;
1036
- this.debugColors[ti + 5] = 0;
1037
- }
1038
- else {
1039
- this.debugColors[ti] = 1;
1040
- this.debugColors[ti + 1] = 0;
1041
- this.debugColors[ti + 2] = 0;
1042
- this.debugColors[ti + 3] = 1;
1043
- this.debugColors[ti + 4] = 0;
1044
- this.debugColors[ti + 5] = 0;
1045
- }
1046
- ti += 6;
1047
- }
1048
- this.raycastDebugInfo = [];
1049
- this.debugGeometry.attributes.position.needsUpdate = true;
1050
- this.debugGeometry.attributes.color.needsUpdate = true;
1051
- this.debugGeometry.setDrawRange(0, ti / 3);
1052
- this.debugMesh.visible = true;
1053
- }
1054
- else {
1055
- this.debugMesh.visible = false;
1056
- }
1057
- }
1058
- async _update(data) {
1059
- if (!this.running)
1060
- return;
1061
- if (this.lastPhysicsData) {
1062
- // we already have physics data. just overwriting the old would be an issue since they have not yet
1063
- // been processed. This is fine for object and vehicle updates, collision updates however will need to
1064
- // be accumulated or we're losing collision events!
1065
- data.collisions = [...this.lastPhysicsData.collisions, ...data.collisions];
1066
- }
1067
- this.lastPhysicsData = data;
1068
- if (this.waitForFramesAndStop) {
1069
- // if we're instructed to just run X frames of physics simulation and then stop, just do the update here, otherwise
1070
- // the renderer will call it
1071
- await this.processPhysicsUpdate();
1072
- this.framesCalculated++;
1073
- if (this.framesCalculated === this.waitForFramesAndStop) {
1074
- this.stop();
1075
- }
1076
- }
1077
- }
1078
- }
1079
- //# sourceMappingURL=Physics.js.map