@onerjs/core 8.41.5 → 8.41.7

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 (579) hide show
  1. package/Animations/animation.d.ts +6 -2
  2. package/Animations/animation.js +28 -4
  3. package/Animations/animation.js.map +1 -1
  4. package/Animations/animationGroup.d.ts +2 -1
  5. package/Animations/animationGroup.js +3 -2
  6. package/Animations/animationGroup.js.map +1 -1
  7. package/Animations/animatorAvatar.d.ts +161 -0
  8. package/Animations/animatorAvatar.js +573 -0
  9. package/Animations/animatorAvatar.js.map +1 -0
  10. package/Animations/index.d.ts +1 -0
  11. package/Animations/index.js +1 -0
  12. package/Animations/index.js.map +1 -1
  13. package/AudioV2/webAudio/webAudioSoundSource.d.ts +2 -2
  14. package/AudioV2/webAudio/webAudioSoundSource.js +12 -2
  15. package/AudioV2/webAudio/webAudioSoundSource.js.map +1 -1
  16. package/Bones/index.d.ts +1 -0
  17. package/Bones/index.js +1 -0
  18. package/Bones/index.js.map +1 -1
  19. package/Bones/skeleton.d.ts +13 -0
  20. package/Bones/skeleton.functions.d.ts +26 -0
  21. package/Bones/skeleton.functions.js +91 -0
  22. package/Bones/skeleton.functions.js.map +1 -0
  23. package/Bones/skeleton.js +26 -0
  24. package/Bones/skeleton.js.map +1 -1
  25. package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +16 -0
  26. package/Cameras/Inputs/geospatialCameraPointersInput.js +19 -3
  27. package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
  28. package/Cameras/Limits/geospatialLimits.d.ts +0 -6
  29. package/Cameras/Limits/geospatialLimits.js +0 -6
  30. package/Cameras/Limits/geospatialLimits.js.map +1 -1
  31. package/Cameras/geospatialCamera.d.ts +5 -0
  32. package/Cameras/geospatialCamera.js +54 -25
  33. package/Cameras/geospatialCamera.js.map +1 -1
  34. package/Cameras/geospatialCameraMovement.d.ts +8 -1
  35. package/Cameras/geospatialCameraMovement.js +29 -8
  36. package/Cameras/geospatialCameraMovement.js.map +1 -1
  37. package/Collisions/gpuPicker.d.ts +11 -0
  38. package/Collisions/gpuPicker.js +148 -19
  39. package/Collisions/gpuPicker.js.map +1 -1
  40. package/Debug/skeletonViewer.d.ts +4 -8
  41. package/Debug/skeletonViewer.js +13 -22
  42. package/Debug/skeletonViewer.js.map +1 -1
  43. package/Engines/Extensions/engine.multiview.d.ts +2 -0
  44. package/Engines/Extensions/engine.multiview.js +7 -3
  45. package/Engines/Extensions/engine.multiview.js.map +1 -1
  46. package/Engines/abstractEngine.d.ts +2 -2
  47. package/Engines/abstractEngine.js +2 -2
  48. package/Engines/abstractEngine.js.map +1 -1
  49. package/Engines/constants.d.ts +4 -0
  50. package/Engines/constants.js +4 -0
  51. package/Engines/constants.js.map +1 -1
  52. package/Engines/webgpuEngine.d.ts +1 -4
  53. package/Engines/webgpuEngine.js +8 -6
  54. package/Engines/webgpuEngine.js.map +1 -1
  55. package/FrameGraph/frameGraphContext.js +1 -1
  56. package/FrameGraph/frameGraphContext.js.map +1 -1
  57. package/FrameGraph/frameGraphRenderContext.js +2 -2
  58. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  59. package/Instrumentation/engineInstrumentation.js +2 -1
  60. package/Instrumentation/engineInstrumentation.js.map +1 -1
  61. package/Layers/effectLayer.js +1 -3
  62. package/Layers/effectLayer.js.map +1 -1
  63. package/Lights/Shadows/cascadedShadowGenerator.js +2 -2
  64. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  65. package/Lights/Shadows/shadowGenerator.js +3 -4
  66. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  67. package/Lights/lightingVolume.js +1 -1
  68. package/Lights/lightingVolume.js.map +1 -1
  69. package/Materials/Background/backgroundMaterial.js +37 -2
  70. package/Materials/Background/backgroundMaterial.js.map +1 -1
  71. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.d.ts +109 -0
  72. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.js +210 -0
  73. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.js.map +1 -0
  74. package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +1 -0
  75. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +71 -15
  76. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  77. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.d.ts +86 -0
  78. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js +161 -0
  79. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js.map +1 -0
  80. package/Materials/GreasedLine/greasedLinePluginMaterial.js +0 -6
  81. package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -1
  82. package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js +0 -1
  83. package/Materials/GreasedLine/greasedLinePluginMaterialShadersGLSL.js.map +1 -1
  84. package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js +0 -1
  85. package/Materials/GreasedLine/greasedLinePluginMaterialShadersWGSL.js.map +1 -1
  86. package/Materials/Node/Blocks/Dual/clipPlanesBlock.d.ts +14 -0
  87. package/Materials/Node/Blocks/Dual/clipPlanesBlock.js +14 -0
  88. package/Materials/Node/Blocks/Dual/clipPlanesBlock.js.map +1 -1
  89. package/Materials/Node/Blocks/Dual/currentScreenBlock.d.ts +20 -1
  90. package/Materials/Node/Blocks/Dual/currentScreenBlock.js +20 -1
  91. package/Materials/Node/Blocks/Dual/currentScreenBlock.js.map +1 -1
  92. package/Materials/Node/Blocks/Dual/depthSourceBlock.d.ts +13 -0
  93. package/Materials/Node/Blocks/Dual/depthSourceBlock.js +13 -0
  94. package/Materials/Node/Blocks/Dual/depthSourceBlock.js.map +1 -1
  95. package/Materials/Node/Blocks/Dual/fogBlock.d.ts +21 -0
  96. package/Materials/Node/Blocks/Dual/fogBlock.js +21 -0
  97. package/Materials/Node/Blocks/Dual/fogBlock.js.map +1 -1
  98. package/Materials/Node/Blocks/Dual/imageSourceBlock.d.ts +21 -0
  99. package/Materials/Node/Blocks/Dual/imageSourceBlock.js +21 -0
  100. package/Materials/Node/Blocks/Dual/imageSourceBlock.js.map +1 -1
  101. package/Materials/Node/Blocks/Dual/lightBlock.d.ts +38 -0
  102. package/Materials/Node/Blocks/Dual/lightBlock.js +38 -0
  103. package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
  104. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.d.ts +29 -0
  105. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +29 -0
  106. package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
  107. package/Materials/Node/Blocks/Dual/reflectionTextureBlock.d.ts +5 -0
  108. package/Materials/Node/Blocks/Dual/reflectionTextureBlock.js +5 -0
  109. package/Materials/Node/Blocks/Dual/reflectionTextureBlock.js.map +1 -1
  110. package/Materials/Node/Blocks/Dual/sceneDepthBlock.d.ts +16 -0
  111. package/Materials/Node/Blocks/Dual/sceneDepthBlock.js +16 -0
  112. package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
  113. package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.d.ts +16 -0
  114. package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js +16 -0
  115. package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js.map +1 -1
  116. package/Materials/Node/Blocks/Dual/textureBlock.d.ts +34 -0
  117. package/Materials/Node/Blocks/Dual/textureBlock.js +34 -0
  118. package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
  119. package/Materials/Node/Blocks/Fragment/TBNBlock.d.ts +17 -0
  120. package/Materials/Node/Blocks/Fragment/TBNBlock.js +17 -2
  121. package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
  122. package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.d.ts +7 -0
  123. package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.js +7 -0
  124. package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.js.map +1 -1
  125. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.d.ts +21 -0
  126. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +21 -0
  127. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
  128. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.d.ts +10 -0
  129. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js +10 -0
  130. package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -1
  131. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.d.ts +28 -0
  132. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js +28 -0
  133. package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
  134. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.d.ts +30 -0
  135. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js +30 -1
  136. package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
  137. package/Materials/Node/Blocks/Fragment/screenSizeBlock.d.ts +4 -0
  138. package/Materials/Node/Blocks/Fragment/screenSizeBlock.js +4 -0
  139. package/Materials/Node/Blocks/Fragment/screenSizeBlock.js.map +1 -1
  140. package/Materials/Node/Blocks/Fragment/screenSpaceBlock.d.ts +5 -0
  141. package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js +5 -0
  142. package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js.map +1 -1
  143. package/Materials/Node/Blocks/Fragment/twirlBlock.d.ts +3 -0
  144. package/Materials/Node/Blocks/Fragment/twirlBlock.js +3 -0
  145. package/Materials/Node/Blocks/Fragment/twirlBlock.js.map +1 -1
  146. package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.d.ts +6 -0
  147. package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js +6 -0
  148. package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js.map +1 -1
  149. package/Materials/Node/Blocks/Input/inputBlock.d.ts +16 -0
  150. package/Materials/Node/Blocks/Input/inputBlock.js +16 -1
  151. package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
  152. package/Materials/Node/Blocks/Input/prePassTextureBlock.d.ts +5 -0
  153. package/Materials/Node/Blocks/Input/prePassTextureBlock.js +5 -0
  154. package/Materials/Node/Blocks/Input/prePassTextureBlock.js.map +1 -1
  155. package/Materials/Node/Blocks/PBR/anisotropyBlock.d.ts +10 -0
  156. package/Materials/Node/Blocks/PBR/anisotropyBlock.js +10 -1
  157. package/Materials/Node/Blocks/PBR/anisotropyBlock.js.map +1 -1
  158. package/Materials/Node/Blocks/PBR/clearCoatBlock.d.ts +23 -0
  159. package/Materials/Node/Blocks/PBR/clearCoatBlock.js +23 -1
  160. package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
  161. package/Materials/Node/Blocks/PBR/iridescenceBlock.d.ts +17 -0
  162. package/Materials/Node/Blocks/PBR/iridescenceBlock.js +17 -0
  163. package/Materials/Node/Blocks/PBR/iridescenceBlock.js.map +1 -1
  164. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.d.ts +41 -0
  165. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +41 -0
  166. package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
  167. package/Materials/Node/Blocks/PBR/reflectionBlock.d.ts +21 -0
  168. package/Materials/Node/Blocks/PBR/reflectionBlock.js +21 -0
  169. package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
  170. package/Materials/Node/Blocks/PBR/refractionBlock.d.ts +29 -0
  171. package/Materials/Node/Blocks/PBR/refractionBlock.js +29 -0
  172. package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
  173. package/Materials/Node/Blocks/PBR/sheenBlock.d.ts +14 -0
  174. package/Materials/Node/Blocks/PBR/sheenBlock.js +14 -0
  175. package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
  176. package/Materials/Node/Blocks/PBR/subSurfaceBlock.d.ts +7 -0
  177. package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +7 -0
  178. package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
  179. package/Materials/Node/Blocks/Particle/particleTextureBlock.d.ts +23 -0
  180. package/Materials/Node/Blocks/Particle/particleTextureBlock.js +23 -0
  181. package/Materials/Node/Blocks/Particle/particleTextureBlock.js.map +1 -1
  182. package/Materials/Node/Blocks/Teleport/teleportInBlock.d.ts +6 -0
  183. package/Materials/Node/Blocks/Teleport/teleportInBlock.js +6 -0
  184. package/Materials/Node/Blocks/Teleport/teleportInBlock.js.map +1 -1
  185. package/Materials/Node/Blocks/Teleport/teleportOutBlock.d.ts +17 -0
  186. package/Materials/Node/Blocks/Teleport/teleportOutBlock.js +17 -0
  187. package/Materials/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
  188. package/Materials/Node/Blocks/Vertex/bonesBlock.d.ts +22 -0
  189. package/Materials/Node/Blocks/Vertex/bonesBlock.js +22 -0
  190. package/Materials/Node/Blocks/Vertex/bonesBlock.js.map +1 -1
  191. package/Materials/Node/Blocks/Vertex/instancesBlock.d.ts +13 -0
  192. package/Materials/Node/Blocks/Vertex/instancesBlock.js +13 -0
  193. package/Materials/Node/Blocks/Vertex/instancesBlock.js.map +1 -1
  194. package/Materials/Node/Blocks/Vertex/lightInformationBlock.d.ts +20 -0
  195. package/Materials/Node/Blocks/Vertex/lightInformationBlock.js +20 -0
  196. package/Materials/Node/Blocks/Vertex/lightInformationBlock.js.map +1 -1
  197. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.d.ts +27 -0
  198. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +27 -0
  199. package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
  200. package/Materials/Node/Blocks/clampBlock.d.ts +10 -0
  201. package/Materials/Node/Blocks/clampBlock.js +10 -0
  202. package/Materials/Node/Blocks/clampBlock.js.map +1 -1
  203. package/Materials/Node/Blocks/cloudBlock.d.ts +10 -0
  204. package/Materials/Node/Blocks/cloudBlock.js +10 -0
  205. package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
  206. package/Materials/Node/Blocks/colorMergerBlock.d.ts +10 -0
  207. package/Materials/Node/Blocks/colorMergerBlock.js +10 -0
  208. package/Materials/Node/Blocks/colorMergerBlock.js.map +1 -1
  209. package/Materials/Node/Blocks/conditionalBlock.d.ts +14 -0
  210. package/Materials/Node/Blocks/conditionalBlock.js +14 -0
  211. package/Materials/Node/Blocks/conditionalBlock.js.map +1 -1
  212. package/Materials/Node/Blocks/curveBlock.d.ts +10 -0
  213. package/Materials/Node/Blocks/curveBlock.js +10 -0
  214. package/Materials/Node/Blocks/curveBlock.js.map +1 -1
  215. package/Materials/Node/Blocks/customBlock.d.ts +10 -0
  216. package/Materials/Node/Blocks/customBlock.js +10 -0
  217. package/Materials/Node/Blocks/customBlock.js.map +1 -1
  218. package/Materials/Node/Blocks/debugBlock.d.ts +10 -0
  219. package/Materials/Node/Blocks/debugBlock.js +10 -0
  220. package/Materials/Node/Blocks/debugBlock.js.map +1 -1
  221. package/Materials/Node/Blocks/fresnelBlock.d.ts +4 -0
  222. package/Materials/Node/Blocks/fresnelBlock.js +4 -0
  223. package/Materials/Node/Blocks/fresnelBlock.js.map +1 -1
  224. package/Materials/Node/Blocks/gradientBlock.d.ts +10 -0
  225. package/Materials/Node/Blocks/gradientBlock.js +10 -0
  226. package/Materials/Node/Blocks/gradientBlock.js.map +1 -1
  227. package/Materials/Node/Blocks/loopBlock.d.ts +10 -0
  228. package/Materials/Node/Blocks/loopBlock.js +10 -0
  229. package/Materials/Node/Blocks/loopBlock.js.map +1 -1
  230. package/Materials/Node/Blocks/matrixBuilderBlock.d.ts +1 -0
  231. package/Materials/Node/Blocks/matrixBuilderBlock.js +1 -0
  232. package/Materials/Node/Blocks/matrixBuilderBlock.js.map +1 -1
  233. package/Materials/Node/Blocks/meshAttributeExistsBlock.d.ts +10 -0
  234. package/Materials/Node/Blocks/meshAttributeExistsBlock.js +10 -0
  235. package/Materials/Node/Blocks/meshAttributeExistsBlock.js.map +1 -1
  236. package/Materials/Node/Blocks/pannerBlock.d.ts +5 -0
  237. package/Materials/Node/Blocks/pannerBlock.js +5 -0
  238. package/Materials/Node/Blocks/pannerBlock.js.map +1 -1
  239. package/Materials/Node/Blocks/remapBlock.d.ts +10 -0
  240. package/Materials/Node/Blocks/remapBlock.js +10 -0
  241. package/Materials/Node/Blocks/remapBlock.js.map +1 -1
  242. package/Materials/Node/Blocks/rotate2dBlock.d.ts +1 -0
  243. package/Materials/Node/Blocks/rotate2dBlock.js +1 -0
  244. package/Materials/Node/Blocks/rotate2dBlock.js.map +1 -1
  245. package/Materials/Node/Blocks/transformBlock.d.ts +10 -0
  246. package/Materials/Node/Blocks/transformBlock.js +10 -0
  247. package/Materials/Node/Blocks/transformBlock.js.map +1 -1
  248. package/Materials/Node/Blocks/triPlanarBlock.d.ts +22 -0
  249. package/Materials/Node/Blocks/triPlanarBlock.js +22 -0
  250. package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
  251. package/Materials/Node/Blocks/trigonometryBlock.d.ts +10 -0
  252. package/Materials/Node/Blocks/trigonometryBlock.js +10 -0
  253. package/Materials/Node/Blocks/trigonometryBlock.js.map +1 -1
  254. package/Materials/Node/Blocks/vectorMergerBlock.d.ts +10 -0
  255. package/Materials/Node/Blocks/vectorMergerBlock.js +10 -0
  256. package/Materials/Node/Blocks/vectorMergerBlock.js.map +1 -1
  257. package/Materials/Node/Blocks/viewDirectionBlock.d.ts +5 -0
  258. package/Materials/Node/Blocks/viewDirectionBlock.js +5 -0
  259. package/Materials/Node/Blocks/viewDirectionBlock.js.map +1 -1
  260. package/Materials/Node/Blocks/waveBlock.d.ts +10 -0
  261. package/Materials/Node/Blocks/waveBlock.js +10 -0
  262. package/Materials/Node/Blocks/waveBlock.js.map +1 -1
  263. package/Materials/Node/Blocks/worleyNoise3DBlock.d.ts +1 -0
  264. package/Materials/Node/Blocks/worleyNoise3DBlock.js +1 -0
  265. package/Materials/Node/Blocks/worleyNoise3DBlock.js.map +1 -1
  266. package/Materials/Node/nodeMaterial.d.ts +13 -0
  267. package/Materials/Node/nodeMaterial.js +14 -2
  268. package/Materials/Node/nodeMaterial.js.map +1 -1
  269. package/Materials/Node/nodeMaterialBlock.d.ts +0 -3
  270. package/Materials/Node/nodeMaterialBlock.js +1 -6
  271. package/Materials/Node/nodeMaterialBlock.js.map +1 -1
  272. package/Materials/Node/nodeMaterialBlockConnectionPoint.js +1 -2
  273. package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
  274. package/Materials/Textures/Procedurals/proceduralTexture.js +1 -1
  275. package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
  276. package/Materials/Textures/mirrorTexture.js +1 -1
  277. package/Materials/Textures/mirrorTexture.js.map +1 -1
  278. package/Materials/index.d.ts +2 -0
  279. package/Materials/index.js +2 -0
  280. package/Materials/index.js.map +1 -1
  281. package/Maths/math.constants.d.ts +2 -1
  282. package/Maths/math.constants.js +3 -2
  283. package/Maths/math.constants.js.map +1 -1
  284. package/Meshes/Builders/capsuleBuilder.js +0 -3
  285. package/Meshes/Builders/capsuleBuilder.js.map +1 -1
  286. package/Meshes/Builders/cylinderBuilder.d.ts +1 -1
  287. package/Meshes/Builders/cylinderBuilder.js +1 -2
  288. package/Meshes/Builders/cylinderBuilder.js.map +1 -1
  289. package/Meshes/Builders/decalBuilder.js +2 -0
  290. package/Meshes/Builders/decalBuilder.js.map +1 -1
  291. package/Meshes/Builders/discBuilder.js +0 -1
  292. package/Meshes/Builders/discBuilder.js.map +1 -1
  293. package/Meshes/Builders/groundBuilder.d.ts +50 -54
  294. package/Meshes/Builders/groundBuilder.js +50 -54
  295. package/Meshes/Builders/groundBuilder.js.map +1 -1
  296. package/Meshes/Builders/tiledBoxBuilder.d.ts +0 -26
  297. package/Meshes/Builders/tiledBoxBuilder.js +0 -26
  298. package/Meshes/Builders/tiledBoxBuilder.js.map +1 -1
  299. package/Meshes/Builders/tiledPlaneBuilder.d.ts +0 -25
  300. package/Meshes/Builders/tiledPlaneBuilder.js +0 -25
  301. package/Meshes/Builders/tiledPlaneBuilder.js.map +1 -1
  302. package/Meshes/Builders/torusBuilder.d.ts +0 -13
  303. package/Meshes/Builders/torusBuilder.js +0 -13
  304. package/Meshes/Builders/torusBuilder.js.map +1 -1
  305. package/Meshes/Builders/torusKnotBuilder.d.ts +0 -19
  306. package/Meshes/Builders/torusKnotBuilder.js +0 -19
  307. package/Meshes/Builders/torusKnotBuilder.js.map +1 -1
  308. package/Meshes/Compression/dracoCompressionWorker.js.map +1 -1
  309. package/Meshes/Compression/dracoDecoder.js.map +1 -1
  310. package/Meshes/Compression/dracoDecoder.types.d.ts +11 -0
  311. package/Meshes/Compression/dracoDecoder.types.js.map +1 -1
  312. package/Meshes/Compression/dracoEncoder.js.map +1 -1
  313. package/Meshes/Compression/meshoptCompression.js +0 -2
  314. package/Meshes/Compression/meshoptCompression.js.map +1 -1
  315. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +17 -1
  316. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  317. package/Meshes/GreasedLine/greasedLineRibbonMesh.js +0 -8
  318. package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
  319. package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.d.ts +1 -0
  320. package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.js +1 -0
  321. package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.js.map +1 -1
  322. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.d.ts +1 -0
  323. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js +1 -0
  324. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js.map +1 -1
  325. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.d.ts +1 -0
  326. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js +1 -0
  327. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js.map +1 -1
  328. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.d.ts +1 -0
  329. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js +1 -0
  330. package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js.map +1 -1
  331. package/Meshes/Node/Blocks/Matrices/scalingBlock.d.ts +1 -0
  332. package/Meshes/Node/Blocks/Matrices/scalingBlock.js +1 -0
  333. package/Meshes/Node/Blocks/Matrices/scalingBlock.js.map +1 -1
  334. package/Meshes/Node/Blocks/Matrices/translationBlock.d.ts +1 -0
  335. package/Meshes/Node/Blocks/Matrices/translationBlock.js +1 -0
  336. package/Meshes/Node/Blocks/Matrices/translationBlock.js.map +1 -1
  337. package/Meshes/Node/Blocks/Set/aggregatorBlock.d.ts +1 -0
  338. package/Meshes/Node/Blocks/Set/aggregatorBlock.js +1 -0
  339. package/Meshes/Node/Blocks/Set/aggregatorBlock.js.map +1 -1
  340. package/Meshes/Node/Blocks/Set/latticeBlock.d.ts +1 -0
  341. package/Meshes/Node/Blocks/Set/latticeBlock.js +1 -0
  342. package/Meshes/Node/Blocks/Set/latticeBlock.js.map +1 -1
  343. package/Meshes/Node/Blocks/Set/setColorsBlock.d.ts +1 -0
  344. package/Meshes/Node/Blocks/Set/setColorsBlock.js +1 -0
  345. package/Meshes/Node/Blocks/Set/setColorsBlock.js.map +1 -1
  346. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.d.ts +1 -0
  347. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js +1 -0
  348. package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js.map +1 -1
  349. package/Meshes/Node/Blocks/Set/setNormalsBlock.d.ts +1 -0
  350. package/Meshes/Node/Blocks/Set/setNormalsBlock.js +1 -0
  351. package/Meshes/Node/Blocks/Set/setNormalsBlock.js.map +1 -1
  352. package/Meshes/Node/Blocks/Set/setPositionsBlock.d.ts +1 -0
  353. package/Meshes/Node/Blocks/Set/setPositionsBlock.js +1 -0
  354. package/Meshes/Node/Blocks/Set/setPositionsBlock.js.map +1 -1
  355. package/Meshes/Node/Blocks/Set/setTangentsBlock.d.ts +1 -0
  356. package/Meshes/Node/Blocks/Set/setTangentsBlock.js +1 -0
  357. package/Meshes/Node/Blocks/Set/setTangentsBlock.js.map +1 -1
  358. package/Meshes/Node/Blocks/Set/setUVsBlock.d.ts +1 -0
  359. package/Meshes/Node/Blocks/Set/setUVsBlock.js +1 -0
  360. package/Meshes/Node/Blocks/Set/setUVsBlock.js.map +1 -1
  361. package/Meshes/Node/Blocks/Sources/boxBlock.d.ts +2 -0
  362. package/Meshes/Node/Blocks/Sources/boxBlock.js +2 -0
  363. package/Meshes/Node/Blocks/Sources/boxBlock.js.map +1 -1
  364. package/Meshes/Node/Blocks/Sources/capsuleBlock.d.ts +2 -0
  365. package/Meshes/Node/Blocks/Sources/capsuleBlock.js +2 -0
  366. package/Meshes/Node/Blocks/Sources/capsuleBlock.js.map +1 -1
  367. package/Meshes/Node/Blocks/Sources/cylinderBlock.d.ts +2 -0
  368. package/Meshes/Node/Blocks/Sources/cylinderBlock.js +2 -0
  369. package/Meshes/Node/Blocks/Sources/cylinderBlock.js.map +1 -1
  370. package/Meshes/Node/Blocks/Sources/discBlock.d.ts +2 -0
  371. package/Meshes/Node/Blocks/Sources/discBlock.js +2 -0
  372. package/Meshes/Node/Blocks/Sources/discBlock.js.map +1 -1
  373. package/Meshes/Node/Blocks/Sources/gridBlock.d.ts +2 -0
  374. package/Meshes/Node/Blocks/Sources/gridBlock.js +2 -0
  375. package/Meshes/Node/Blocks/Sources/gridBlock.js.map +1 -1
  376. package/Meshes/Node/Blocks/Sources/icoSphereBlock.d.ts +2 -0
  377. package/Meshes/Node/Blocks/Sources/icoSphereBlock.js +2 -0
  378. package/Meshes/Node/Blocks/Sources/icoSphereBlock.js.map +1 -1
  379. package/Meshes/Node/Blocks/Sources/meshBlock.d.ts +1 -0
  380. package/Meshes/Node/Blocks/Sources/meshBlock.js +1 -0
  381. package/Meshes/Node/Blocks/Sources/meshBlock.js.map +1 -1
  382. package/Meshes/Node/Blocks/Sources/planeBlock.d.ts +2 -0
  383. package/Meshes/Node/Blocks/Sources/planeBlock.js +2 -0
  384. package/Meshes/Node/Blocks/Sources/planeBlock.js.map +1 -1
  385. package/Meshes/Node/Blocks/Sources/pointListBlock.d.ts +2 -1
  386. package/Meshes/Node/Blocks/Sources/pointListBlock.js +2 -1
  387. package/Meshes/Node/Blocks/Sources/pointListBlock.js.map +1 -1
  388. package/Meshes/Node/Blocks/Sources/sphereBlock.d.ts +2 -0
  389. package/Meshes/Node/Blocks/Sources/sphereBlock.js +2 -0
  390. package/Meshes/Node/Blocks/Sources/sphereBlock.js.map +1 -1
  391. package/Meshes/Node/Blocks/Sources/torusBlock.d.ts +2 -0
  392. package/Meshes/Node/Blocks/Sources/torusBlock.js +2 -0
  393. package/Meshes/Node/Blocks/Sources/torusBlock.js.map +1 -1
  394. package/Meshes/Node/Blocks/Teleport/teleportInBlock.d.ts +1 -0
  395. package/Meshes/Node/Blocks/Teleport/teleportInBlock.js +1 -0
  396. package/Meshes/Node/Blocks/Teleport/teleportInBlock.js.map +1 -1
  397. package/Meshes/Node/Blocks/Teleport/teleportOutBlock.d.ts +3 -0
  398. package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js +3 -0
  399. package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
  400. package/Meshes/Node/Blocks/Textures/geometryTextureBlock.d.ts +1 -0
  401. package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js +1 -1
  402. package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js.map +1 -1
  403. package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.d.ts +1 -0
  404. package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.js +1 -0
  405. package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.js.map +1 -1
  406. package/Meshes/Node/Blocks/booleanGeometryBlock.d.ts +1 -0
  407. package/Meshes/Node/Blocks/booleanGeometryBlock.js +1 -1
  408. package/Meshes/Node/Blocks/booleanGeometryBlock.js.map +1 -1
  409. package/Meshes/Node/Blocks/cleanGeometryBlock.d.ts +1 -0
  410. package/Meshes/Node/Blocks/cleanGeometryBlock.js +1 -0
  411. package/Meshes/Node/Blocks/cleanGeometryBlock.js.map +1 -1
  412. package/Meshes/Node/Blocks/conditionBlock.d.ts +2 -0
  413. package/Meshes/Node/Blocks/conditionBlock.js +2 -0
  414. package/Meshes/Node/Blocks/conditionBlock.js.map +1 -1
  415. package/Meshes/Node/Blocks/geometryClampBlock.d.ts +1 -0
  416. package/Meshes/Node/Blocks/geometryClampBlock.js +1 -0
  417. package/Meshes/Node/Blocks/geometryClampBlock.js.map +1 -1
  418. package/Meshes/Node/Blocks/geometryCollectionBlock.d.ts +1 -0
  419. package/Meshes/Node/Blocks/geometryCollectionBlock.js +1 -0
  420. package/Meshes/Node/Blocks/geometryCollectionBlock.js.map +1 -1
  421. package/Meshes/Node/Blocks/geometryCurveBlock.d.ts +2 -0
  422. package/Meshes/Node/Blocks/geometryCurveBlock.js +2 -0
  423. package/Meshes/Node/Blocks/geometryCurveBlock.js.map +1 -1
  424. package/Meshes/Node/Blocks/geometryEaseBlock.d.ts +2 -0
  425. package/Meshes/Node/Blocks/geometryEaseBlock.js +2 -0
  426. package/Meshes/Node/Blocks/geometryEaseBlock.js.map +1 -1
  427. package/Meshes/Node/Blocks/geometryInputBlock.d.ts +3 -0
  428. package/Meshes/Node/Blocks/geometryInputBlock.js +3 -0
  429. package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
  430. package/Meshes/Node/Blocks/geometryOptimizeBlock.d.ts +1 -0
  431. package/Meshes/Node/Blocks/geometryOptimizeBlock.js +1 -0
  432. package/Meshes/Node/Blocks/geometryOptimizeBlock.js.map +1 -1
  433. package/Meshes/Node/Blocks/geometryTransformBlock.d.ts +1 -0
  434. package/Meshes/Node/Blocks/geometryTransformBlock.js +1 -0
  435. package/Meshes/Node/Blocks/geometryTransformBlock.js.map +1 -1
  436. package/Meshes/Node/Blocks/geometryTrigonometryBlock.d.ts +2 -0
  437. package/Meshes/Node/Blocks/geometryTrigonometryBlock.js +2 -0
  438. package/Meshes/Node/Blocks/geometryTrigonometryBlock.js.map +1 -1
  439. package/Meshes/Node/Blocks/mappingBlock.d.ts +1 -0
  440. package/Meshes/Node/Blocks/mappingBlock.js +1 -0
  441. package/Meshes/Node/Blocks/mappingBlock.js.map +1 -1
  442. package/Meshes/Node/Blocks/mathBlock.d.ts +1 -0
  443. package/Meshes/Node/Blocks/mathBlock.js +1 -0
  444. package/Meshes/Node/Blocks/mathBlock.js.map +1 -1
  445. package/Meshes/Node/Blocks/mergeGeometryBlock.d.ts +1 -0
  446. package/Meshes/Node/Blocks/mergeGeometryBlock.js +1 -0
  447. package/Meshes/Node/Blocks/mergeGeometryBlock.js.map +1 -1
  448. package/Meshes/Node/Blocks/randomBlock.d.ts +2 -0
  449. package/Meshes/Node/Blocks/randomBlock.js +2 -0
  450. package/Meshes/Node/Blocks/randomBlock.js.map +1 -1
  451. package/Meshes/Node/Blocks/subdivideBlock.d.ts +1 -0
  452. package/Meshes/Node/Blocks/subdivideBlock.js +1 -0
  453. package/Meshes/Node/Blocks/subdivideBlock.js.map +1 -1
  454. package/Meshes/Node/Interfaces/nodeGeometryTextureData.d.ts +3 -0
  455. package/Meshes/Node/Interfaces/nodeGeometryTextureData.js.map +1 -1
  456. package/Meshes/Node/nodeGeometry.js +0 -2
  457. package/Meshes/Node/nodeGeometry.js.map +1 -1
  458. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js +0 -1
  459. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
  460. package/Meshes/Node/nodeGeometryBuildState.js +0 -1
  461. package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
  462. package/Meshes/WebGL/webGLDataBuffer.d.ts +2 -0
  463. package/Meshes/WebGL/webGLDataBuffer.js +2 -0
  464. package/Meshes/WebGL/webGLDataBuffer.js.map +1 -1
  465. package/Meshes/WebGPU/webgpuDataBuffer.d.ts +4 -0
  466. package/Meshes/WebGPU/webgpuDataBuffer.js +4 -0
  467. package/Meshes/WebGPU/webgpuDataBuffer.js.map +1 -1
  468. package/Meshes/abstractMesh.d.ts +1 -0
  469. package/Meshes/abstractMesh.decalMap.d.ts +1 -0
  470. package/Meshes/abstractMesh.decalMap.js.map +1 -1
  471. package/Meshes/abstractMesh.js +1 -6
  472. package/Meshes/abstractMesh.js.map +1 -1
  473. package/Meshes/csg.js +0 -6
  474. package/Meshes/csg.js.map +1 -1
  475. package/Meshes/csg2.js +1 -2
  476. package/Meshes/csg2.js.map +1 -1
  477. package/Meshes/geodesicMesh.d.ts +26 -0
  478. package/Meshes/geodesicMesh.js +18 -3
  479. package/Meshes/geodesicMesh.js.map +1 -1
  480. package/Meshes/groundMesh.d.ts +1 -0
  481. package/Meshes/groundMesh.js +1 -0
  482. package/Meshes/groundMesh.js.map +1 -1
  483. package/Meshes/index.js +0 -2
  484. package/Meshes/index.js.map +1 -1
  485. package/Meshes/instancedMesh.d.ts +18 -3
  486. package/Meshes/instancedMesh.js +11 -3
  487. package/Meshes/instancedMesh.js.map +1 -1
  488. package/Meshes/mesh.d.ts +291 -204
  489. package/Meshes/mesh.js +290 -213
  490. package/Meshes/mesh.js.map +1 -1
  491. package/Meshes/mesh.vertexData.d.ts +15 -19
  492. package/Meshes/mesh.vertexData.js +15 -19
  493. package/Meshes/mesh.vertexData.js.map +1 -1
  494. package/Meshes/meshSimplification.d.ts +0 -1
  495. package/Meshes/meshSimplification.js +6 -1
  496. package/Meshes/meshSimplification.js.map +1 -1
  497. package/Meshes/meshSimplificationSceneComponent.d.ts +2 -0
  498. package/Meshes/meshSimplificationSceneComponent.js.map +1 -1
  499. package/Meshes/meshUVSpaceRenderer.d.ts +1 -0
  500. package/Meshes/meshUVSpaceRenderer.js.map +1 -1
  501. package/Meshes/polygonMesh.js +4 -0
  502. package/Meshes/polygonMesh.js.map +1 -1
  503. package/Meshes/subMesh.project.d.ts +1 -0
  504. package/Meshes/subMesh.project.js.map +1 -1
  505. package/Meshes/thinInstanceMesh.d.ts +5 -0
  506. package/Meshes/thinInstanceMesh.js.map +1 -1
  507. package/Meshes/transformNode.d.ts +1 -1
  508. package/Meshes/transformNode.js +1 -1
  509. package/Meshes/transformNode.js.map +1 -1
  510. package/Misc/dataStorage.d.ts +13 -0
  511. package/Misc/dataStorage.js +25 -0
  512. package/Misc/dataStorage.js.map +1 -1
  513. package/Morph/morphTarget.d.ts +9 -5
  514. package/Morph/morphTarget.js +15 -7
  515. package/Morph/morphTarget.js.map +1 -1
  516. package/Morph/morphTargetManager.d.ts +3 -1
  517. package/Morph/morphTargetManager.js +5 -2
  518. package/Morph/morphTargetManager.js.map +1 -1
  519. package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +1 -1
  520. package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
  521. package/Particles/Node/Blocks/Emitters/coneShapeBlock.js +1 -1
  522. package/Particles/Node/Blocks/Emitters/coneShapeBlock.js.map +1 -1
  523. package/Particles/Node/Blocks/Emitters/customShapeBlock.js +1 -1
  524. package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
  525. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +1 -1
  526. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
  527. package/Particles/Node/Blocks/Emitters/emitters.functions.js +3 -3
  528. package/Particles/Node/Blocks/Emitters/emitters.functions.js.map +1 -1
  529. package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +1 -1
  530. package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
  531. package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +1 -1
  532. package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
  533. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +1 -1
  534. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
  535. package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js +2 -2
  536. package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js.map +1 -1
  537. package/Particles/Node/Blocks/Update/updateNoiseBlock.js +7 -7
  538. package/Particles/Node/Blocks/Update/updateNoiseBlock.js.map +1 -1
  539. package/Particles/Node/Blocks/particleLocalVariableBlock.js +2 -2
  540. package/Particles/Node/Blocks/particleLocalVariableBlock.js.map +1 -1
  541. package/Particles/Node/nodeParticleBuildState.js +7 -7
  542. package/Particles/Node/nodeParticleBuildState.js.map +1 -1
  543. package/Particles/Node/nodeParticleSystemSet.helper.js +9 -4
  544. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  545. package/Particles/particle.d.ts +73 -61
  546. package/Particles/particle.js +106 -91
  547. package/Particles/particle.js.map +1 -1
  548. package/Particles/particleSystem.js +5 -5
  549. package/Particles/particleSystem.js.map +1 -1
  550. package/Particles/thinParticleSystem.function.js +83 -83
  551. package/Particles/thinParticleSystem.function.js.map +1 -1
  552. package/Particles/thinParticleSystem.js +8 -8
  553. package/Particles/thinParticleSystem.js.map +1 -1
  554. package/Physics/v2/Plugins/havokPlugin.d.ts +89 -3
  555. package/Physics/v2/Plugins/havokPlugin.js +388 -53
  556. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  557. package/Probes/reflectionProbe.js +10 -7
  558. package/Probes/reflectionProbe.js.map +1 -1
  559. package/Rendering/depthRenderer.js +1 -1
  560. package/Rendering/depthRenderer.js.map +1 -1
  561. package/Rendering/objectRenderer.d.ts +3 -1
  562. package/Rendering/objectRenderer.js +28 -8
  563. package/Rendering/objectRenderer.js.map +1 -1
  564. package/Rendering/reflectiveShadowMap.js +1 -1
  565. package/Rendering/reflectiveShadowMap.js.map +1 -1
  566. package/Rendering/thinDepthPeelingRenderer.js +8 -0
  567. package/Rendering/thinDepthPeelingRenderer.js.map +1 -1
  568. package/Shaders/gaussianSplatting.fragment.js +8 -2
  569. package/Shaders/gaussianSplatting.fragment.js.map +1 -1
  570. package/Shaders/gaussianSplatting.vertex.js +8 -2
  571. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  572. package/ShadersWGSL/gaussianSplatting.fragment.js +7 -1
  573. package/ShadersWGSL/gaussianSplatting.fragment.js.map +1 -1
  574. package/ShadersWGSL/gaussianSplatting.vertex.js +8 -2
  575. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  576. package/package.json +1 -1
  577. package/scene.d.ts +22 -4
  578. package/scene.js +33 -20
  579. package/scene.js.map +1 -1
@@ -11,6 +11,7 @@ import { InstancedMesh } from "../../../Meshes/instancedMesh.js";
11
11
  import { VertexBuffer } from "../../../Buffers/buffer.js";
12
12
  import { BuildArray } from "../../../Misc/arrayTools.js";
13
13
  import { Observable } from "../../../Misc/observable.js";
14
+ import { FloatingOriginCurrentScene } from "../../../Materials/floatingOriginMatrixOverrides.js";
14
15
  class MeshAccumulator {
15
16
  /**
16
17
  * Constructor of the mesh accumulator
@@ -210,6 +211,137 @@ class TriggerEvent {
210
211
  * The Havok Physics plugin
211
212
  */
212
213
  export class HavokPlugin {
214
+ /**
215
+ * Finds an existing world region that contains the given world position,
216
+ * or creates a new world region centered at that position.
217
+ *
218
+ * When floatingOriginMode is enabled, we use multiple Havok worlds to maintain
219
+ * float32 precision across a large world. Each world region has its own fixed
220
+ * floating origin, and bodies within that region are simulated relative to it.
221
+ *
222
+ * @param worldPosition - The world position of the body being created
223
+ * @returns The world region to use for this body
224
+ */
225
+ _getOrCreateWorldRegion(worldPosition) {
226
+ // Check if floating origin mode is enabled
227
+ const scene = FloatingOriginCurrentScene.getScene();
228
+ if (!scene?.floatingOriginMode) {
229
+ // When floating origin mode is disabled, use the default world region
230
+ return this._worldRegions[0];
231
+ }
232
+ // Find an existing region that contains this position
233
+ for (const region of this._worldRegions) {
234
+ const distance = Vector3.Distance(worldPosition, region.floatingOrigin);
235
+ if (distance <= this._floatingOriginWorldRadius) {
236
+ return region;
237
+ }
238
+ }
239
+ // No existing region found - create a new one centered at this position
240
+ const newWorld = this._hknp.HP_World_Create()[1];
241
+ // Apply stored gravity to new world
242
+ this._hknp.HP_World_SetGravity(newWorld, this._currentGravity);
243
+ // Copy velocity limits from main world
244
+ this._hknp.HP_World_SetSpeedLimit(newWorld, this.getMaxLinearVelocity(), this.getMaxAngularVelocity());
245
+ const newRegion = {
246
+ world: newWorld,
247
+ floatingOrigin: worldPosition.clone(),
248
+ gravity: [...this._currentGravity],
249
+ };
250
+ this._worldRegions.push(newRegion);
251
+ return newRegion;
252
+ }
253
+ /**
254
+ * Checks if a body's world position has left its current region and, if so,
255
+ * moves it to the correct region (existing or newly created).
256
+ * This preserves linear and angular velocity across the transition.
257
+ *
258
+ * @param pluginData - The plugin data for the body (or instance) to check
259
+ */
260
+ _reRegionBodyPluginData(pluginData) {
261
+ const currentRegion = pluginData.worldRegion;
262
+ if (!currentRegion) {
263
+ return;
264
+ }
265
+ // Read the body's current local transform from Havok
266
+ const bodyTransform = this._hknp.HP_Body_GetQTransform(pluginData.hpBodyId)[1];
267
+ const localPos = bodyTransform[0];
268
+ const orientation = bodyTransform[1];
269
+ // Compute world position = local position + floating origin
270
+ const worldPos = TmpVectors.Vector3[2];
271
+ worldPos.set(localPos[0] + currentRegion.floatingOrigin._x, localPos[1] + currentRegion.floatingOrigin._y, localPos[2] + currentRegion.floatingOrigin._z);
272
+ // Check if still within the current region.
273
+ // Use a 20% hysteresis margin so that bodies near the boundary
274
+ // don't oscillate between regions every frame.
275
+ const distToCurrent = Vector3.Distance(worldPos, currentRegion.floatingOrigin);
276
+ if (distToCurrent <= this._floatingOriginWorldRadius * 1.2) {
277
+ return; // still in region (with hysteresis), nothing to do
278
+ }
279
+ // Body has left its region. Use velocity to look ahead and find the best
280
+ // region to join. This prevents creating throwaway intermediate regions
281
+ // when a fast body is heading toward an existing region (e.g. a target).
282
+ const linVel = this._hknp.HP_Body_GetLinearVelocity(pluginData.hpBodyId)[1];
283
+ const angVel = this._hknp.HP_Body_GetAngularVelocity(pluginData.hpBodyId)[1];
284
+ // Project position forward by one second of travel to find a suitable existing region.
285
+ // This is purely for region selection — the body's actual position is not changed.
286
+ const lookAheadPos = TmpVectors.Vector3[3];
287
+ lookAheadPos.set(worldPos._x + linVel[0], worldPos._y + linVel[1], worldPos._z + linVel[2]);
288
+ // Try to find the best region: first check if look-ahead position falls in an existing region
289
+ let newRegion = this._findExistingRegion(lookAheadPos);
290
+ if (!newRegion || newRegion === currentRegion) {
291
+ // Fall back to current position
292
+ newRegion = this._findExistingRegion(worldPos);
293
+ }
294
+ if (!newRegion || newRegion === currentRegion) {
295
+ // No existing region works — create one at the current position
296
+ newRegion = this._getOrCreateWorldRegion(worldPos);
297
+ }
298
+ if (newRegion === currentRegion) {
299
+ return;
300
+ }
301
+ // Remove from old world
302
+ this._hknp.HP_World_RemoveBody(currentRegion.world, pluginData.hpBodyId);
303
+ // Set transform relative to the new region's floating origin
304
+ const newOffset = newRegion.floatingOrigin;
305
+ const newLocalPos = [worldPos._x - newOffset._x, worldPos._y - newOffset._y, worldPos._z - newOffset._z];
306
+ this._hknp.HP_Body_SetQTransform(pluginData.hpBodyId, [newLocalPos, orientation]);
307
+ // Add to new world
308
+ this._hknp.HP_World_AddBody(newRegion.world, pluginData.hpBodyId, false);
309
+ // Restore velocity
310
+ this._hknp.HP_Body_SetLinearVelocity(pluginData.hpBodyId, linVel);
311
+ this._hknp.HP_Body_SetAngularVelocity(pluginData.hpBodyId, angVel);
312
+ // Update the region reference and world transform offset
313
+ pluginData.worldRegion = newRegion;
314
+ pluginData.worldTransformOffset = this._hknp.HP_Body_GetWorldTransformOffset(pluginData.hpBodyId)[1];
315
+ // Garbage-collect the old region if it has no bodies left and it's not the default world
316
+ if (currentRegion !== this._worldRegions[0]) {
317
+ const bodyCount = this._hknp.HP_World_GetNumBodies(currentRegion.world)[1];
318
+ if (bodyCount === 0) {
319
+ this._hknp.HP_World_Release(currentRegion.world);
320
+ const idx = this._worldRegions.indexOf(currentRegion);
321
+ if (idx > 0) {
322
+ this._worldRegions.splice(idx, 1);
323
+ }
324
+ }
325
+ }
326
+ }
327
+ /**
328
+ * Searches existing world regions for one that contains the given position.
329
+ * @param worldPosition - The world position to find a region for
330
+ * @returns null if no existing region contains it (does NOT create a new one).
331
+ */
332
+ _findExistingRegion(worldPosition) {
333
+ const scene = FloatingOriginCurrentScene.getScene();
334
+ if (!scene?.floatingOriginMode) {
335
+ return this._worldRegions[0];
336
+ }
337
+ for (const region of this._worldRegions) {
338
+ const distance = Vector3.Distance(worldPosition, region.floatingOrigin);
339
+ if (distance <= this._floatingOriginWorldRadius) {
340
+ return region;
341
+ }
342
+ }
343
+ return null;
344
+ }
213
345
  constructor(_useDeltaForWorldStep = true, hpInjection = HK, parameters = {}) {
214
346
  this._useDeltaForWorldStep = _useDeltaForWorldStep;
215
347
  /**
@@ -230,6 +362,20 @@ export class HavokPlugin {
230
362
  // Map from constraint id to the pair of bodies, where the first is the parent and the second is the child
231
363
  this._constraintToBodyIdPair = new Map();
232
364
  this._bodyCollisionEndedObservable = new Map();
365
+ /**
366
+ * Array of world regions. The first region is always the default world with origin at Vector3.Zero.
367
+ * Additional regions are created as needed for floating origin mode.
368
+ */
369
+ this._worldRegions = [];
370
+ /**
371
+ * Stored gravity value to apply to new world regions.
372
+ */
373
+ this._currentGravity = [0, -9.81, 0];
374
+ /**
375
+ * Radius of each floating origin world region.
376
+ * Bodies within this radius of a world region's origin will use that world.
377
+ */
378
+ this._floatingOriginWorldRadius = 100000;
233
379
  /**
234
380
  * Observable for collision started and collision continued events
235
381
  */
@@ -254,8 +400,15 @@ export class HavokPlugin {
254
400
  return;
255
401
  }
256
402
  this.world = this._hknp.HP_World_Create()[1];
403
+ // Add the default world as the first region with origin at zero
404
+ this._worldRegions.push({
405
+ world: this.world,
406
+ floatingOrigin: Vector3.Zero(),
407
+ gravity: [...this._currentGravity],
408
+ });
257
409
  this._queryCollector = this._hknp.HP_QueryCollector_Create(1)[1];
258
410
  this.setMaxQueryCollectorHits(parameters.maxQueryCollectorHits ?? 1);
411
+ this._floatingOriginWorldRadius = parameters.floatingOriginWorldRadius ?? 100000;
259
412
  }
260
413
  /**
261
414
  * If this plugin is supported
@@ -268,10 +421,41 @@ export class HavokPlugin {
268
421
  * Sets the gravity of the physics world.
269
422
  *
270
423
  * @param gravity - The gravity vector to set.
424
+ * @param worldPosition - Optional world position to specify which region's gravity to set.
425
+ * If provided, only the region containing this position will be updated.
426
+ * If not provided, all regions will be updated (default behavior).
427
+ * This is useful for planetary scenarios where gravity direction varies by location.
428
+ */
429
+ setGravity(gravity, worldPosition) {
430
+ const gravityArray = this._bVecToV3(gravity);
431
+ if (worldPosition) {
432
+ // Set gravity for a specific region based on world position
433
+ const region = this._getOrCreateWorldRegion(worldPosition);
434
+ region.gravity = gravityArray;
435
+ this._hknp.HP_World_SetGravity(region.world, gravityArray);
436
+ }
437
+ else {
438
+ // Set gravity for all regions (default behavior)
439
+ this._currentGravity = gravityArray;
440
+ for (const region of this._worldRegions) {
441
+ region.gravity = gravityArray;
442
+ this._hknp.HP_World_SetGravity(region.world, gravityArray);
443
+ }
444
+ }
445
+ }
446
+ /**
447
+ * Gets the gravity of the physics world or a specific region.
271
448
  *
449
+ * @param worldPosition - Optional world position to get the gravity for that region.
450
+ * If not provided, returns the default gravity.
451
+ * @returns The gravity vector.
272
452
  */
273
- setGravity(gravity) {
274
- this._hknp.HP_World_SetGravity(this.world, this._bVecToV3(gravity));
453
+ getGravity(worldPosition) {
454
+ if (worldPosition) {
455
+ const region = this._getOrCreateWorldRegion(worldPosition);
456
+ return new Vector3(region.gravity[0], region.gravity[1], region.gravity[2]);
457
+ }
458
+ return new Vector3(this._currentGravity[0], this._currentGravity[1], this._currentGravity[2]);
275
459
  }
276
460
  /**
277
461
  * Sets the fixed time step for the physics engine.
@@ -327,6 +511,21 @@ export class HavokPlugin {
327
511
  * to accurately simulate the physics bodies in the world.
328
512
  */
329
513
  executeStep(delta, physicsBodies) {
514
+ // Re-region bodies that have moved outside their current world region
515
+ // BEFORE pre-step and stepping, so the body participates in the correct
516
+ // world's step and its body buffer transform is valid when sync reads it.
517
+ if (this._worldRegions.length > 1 || FloatingOriginCurrentScene.getScene()?.floatingOriginMode) {
518
+ for (const physicsBody of physicsBodies) {
519
+ if (physicsBody._pluginDataInstances.length > 0) {
520
+ for (const instance of physicsBody._pluginDataInstances) {
521
+ this._reRegionBodyPluginData(instance);
522
+ }
523
+ }
524
+ else if (physicsBody._pluginData) {
525
+ this._reRegionBodyPluginData(physicsBody._pluginData);
526
+ }
527
+ }
528
+ }
330
529
  for (const physicsBody of physicsBodies) {
331
530
  if (physicsBody.disablePreStep) {
332
531
  continue;
@@ -334,16 +533,21 @@ export class HavokPlugin {
334
533
  this.setPhysicsBodyTransformation(physicsBody, physicsBody.transformNode);
335
534
  }
336
535
  const deltaTime = this._useDeltaForWorldStep ? delta : this._fixedTimeStep;
337
- this._hknp.HP_World_SetIdealStepTime(this.world, deltaTime);
338
- this._hknp.HP_World_Step(this.world, deltaTime);
339
- this._bodyBuffer = this._hknp.HP_World_GetBodyBuffer(this.world)[1];
536
+ // Step all world regions
537
+ for (const region of this._worldRegions) {
538
+ this._hknp.HP_World_SetIdealStepTime(region.world, deltaTime);
539
+ this._hknp.HP_World_Step(region.world, deltaTime);
540
+ }
340
541
  for (const physicsBody of physicsBodies) {
341
542
  if (!physicsBody.disableSync) {
342
543
  this.sync(physicsBody);
343
544
  }
344
545
  }
345
- this._notifyCollisions();
346
- this._notifyTriggers();
546
+ // Notify collisions and triggers for all world regions
547
+ for (const region of this._worldRegions) {
548
+ this._notifyCollisions(region.world);
549
+ this._notifyTriggers(region.world);
550
+ }
347
551
  }
348
552
  /**
349
553
  * Returns the version of the physics engine plugin.
@@ -361,7 +565,9 @@ export class HavokPlugin {
361
565
  * @param maxAngularVelocity maximum allowed angular velocity
362
566
  */
363
567
  setVelocityLimits(maxLinearVelocity, maxAngularVelocity) {
364
- this._hknp.HP_World_SetSpeedLimit(this.world, maxLinearVelocity, maxAngularVelocity);
568
+ for (const region of this._worldRegions) {
569
+ this._hknp.HP_World_SetSpeedLimit(region.world, maxLinearVelocity, maxAngularVelocity);
570
+ }
365
571
  }
366
572
  /**
367
573
  * @returns maximum allowed linear velocity
@@ -391,9 +597,13 @@ export class HavokPlugin {
391
597
  initBody(body, motionType, position, orientation) {
392
598
  body._pluginData = new BodyPluginData(this._hknp.HP_Body_Create()[1]);
393
599
  this._internalSetMotionType(body._pluginData, motionType);
394
- const transform = [this._bVecToV3(position), this._bQuatToV4(orientation)]; //<todo temp transform?
600
+ // Get the world region for this body's position
601
+ const worldRegion = this._getOrCreateWorldRegion(position);
602
+ body._pluginData.worldRegion = worldRegion;
603
+ const offset = worldRegion.floatingOrigin;
604
+ const transform = [[position._x - offset._x, position._y - offset._y, position._z - offset._z], this._bQuatToV4(orientation)];
395
605
  this._hknp.HP_Body_SetQTransform(body._pluginData.hpBodyId, transform);
396
- this._hknp.HP_World_AddBody(this.world, body._pluginData.hpBodyId, body.startAsleep);
606
+ this._hknp.HP_World_AddBody(worldRegion.world, body._pluginData.hpBodyId, body.startAsleep);
397
607
  this._bodies.set(body._pluginData.hpBodyId[0], { body: body, index: 0 });
398
608
  }
399
609
  /**
@@ -405,13 +615,13 @@ export class HavokPlugin {
405
615
  if (body._pluginDataInstances && body._pluginDataInstances.length > 0) {
406
616
  for (const instance of body._pluginDataInstances) {
407
617
  this._bodyCollisionObservable.delete(instance.hpBodyId[0]);
408
- this._hknp.HP_World_RemoveBody(this.world, instance.hpBodyId);
618
+ this._hknp.HP_World_RemoveBody(instance.worldRegion.world, instance.hpBodyId);
409
619
  this._bodies.delete(instance.hpBodyId[0]);
410
620
  }
411
621
  }
412
622
  if (body._pluginData) {
413
623
  this._bodyCollisionObservable.delete(body._pluginData.hpBodyId[0]);
414
- this._hknp.HP_World_RemoveBody(this.world, body._pluginData.hpBodyId);
624
+ this._hknp.HP_World_RemoveBody(body._pluginData.worldRegion.world, body._pluginData.hpBodyId);
415
625
  this._bodies.delete(body._pluginData.hpBodyId[0]);
416
626
  }
417
627
  }
@@ -443,15 +653,29 @@ export class HavokPlugin {
443
653
  _createOrUpdateBodyInstances(body, motionType, matrixData, startIndex, endIndex, update) {
444
654
  const rotation = TmpVectors.Quaternion[0];
445
655
  const rotationMatrix = Matrix.Identity();
656
+ const worldPos = TmpVectors.Vector3[0];
446
657
  for (let i = startIndex; i < endIndex; i++) {
447
- const position = [matrixData[i * 16 + 12], matrixData[i * 16 + 13], matrixData[i * 16 + 14]];
658
+ // Get world position for this instance
659
+ worldPos.set(matrixData[i * 16 + 12], matrixData[i * 16 + 13], matrixData[i * 16 + 14]);
448
660
  let hkbody;
661
+ let pluginData;
449
662
  if (!update) {
450
663
  hkbody = this._hknp.HP_Body_Create()[1];
664
+ pluginData = new BodyPluginData(hkbody);
665
+ if (body._pluginDataInstances.length) {
666
+ // If an instance already exists, copy any user-provided mass properties
667
+ pluginData.userMassProps = body._pluginDataInstances[0].userMassProps;
668
+ }
451
669
  }
452
670
  else {
453
- hkbody = body._pluginDataInstances[i].hpBodyId;
671
+ pluginData = body._pluginDataInstances[i];
672
+ hkbody = pluginData.hpBodyId;
454
673
  }
674
+ // Get the world region for this instance's position
675
+ const worldRegion = this._getOrCreateWorldRegion(worldPos);
676
+ const offset = worldRegion.floatingOrigin;
677
+ // Subtract floating origin offset to get small coordinates for Havok (float32 precision)
678
+ const position = [worldPos._x - offset._x, worldPos._y - offset._y, worldPos._z - offset._z];
455
679
  rotationMatrix.setRowFromFloats(0, matrixData[i * 16 + 0], matrixData[i * 16 + 1], matrixData[i * 16 + 2], 0);
456
680
  rotationMatrix.setRowFromFloats(1, matrixData[i * 16 + 4], matrixData[i * 16 + 5], matrixData[i * 16 + 6], 0);
457
681
  rotationMatrix.setRowFromFloats(2, matrixData[i * 16 + 8], matrixData[i * 16 + 9], matrixData[i * 16 + 10], 0);
@@ -459,15 +683,12 @@ export class HavokPlugin {
459
683
  const transform = [position, [rotation.x, rotation.y, rotation.z, rotation.w]];
460
684
  this._hknp.HP_Body_SetQTransform(hkbody, transform);
461
685
  if (!update) {
462
- const pluginData = new BodyPluginData(hkbody);
463
- if (body._pluginDataInstances.length) {
464
- // If an instance already exists, copy any user-provided mass properties
465
- pluginData.userMassProps = body._pluginDataInstances[0].userMassProps;
466
- }
467
686
  this._internalSetMotionType(pluginData, motionType);
468
687
  this._internalUpdateMassProperties(pluginData);
469
688
  body._pluginDataInstances.push(pluginData);
470
- this._hknp.HP_World_AddBody(this.world, hkbody, body.startAsleep);
689
+ // Add to the appropriate world
690
+ pluginData.worldRegion = worldRegion;
691
+ this._hknp.HP_World_AddBody(worldRegion.world, hkbody, body.startAsleep);
471
692
  pluginData.worldTransformOffset = this._hknp.HP_Body_GetWorldTransformOffset(hkbody)[1];
472
693
  }
473
694
  }
@@ -504,7 +725,7 @@ export class HavokPlugin {
504
725
  for (let i = 0; i < instancesToRemove; i++) {
505
726
  const hkbody = body._pluginDataInstances.pop();
506
727
  this._bodies.delete(hkbody.hpBodyId[0]);
507
- this._hknp.HP_World_RemoveBody(this.world, hkbody.hpBodyId);
728
+ this._hknp.HP_World_RemoveBody(hkbody.worldRegion.world, hkbody.hpBodyId);
508
729
  this._hknp.HP_Body_Release(hkbody.hpBodyId);
509
730
  }
510
731
  this._createOrUpdateBodyInstances(body, motionType, matrixData, 0, instancesCount, true);
@@ -535,6 +756,8 @@ export class HavokPlugin {
535
756
  * physical behavior of the body.
536
757
  */
537
758
  syncTransform(body, transformNode) {
759
+ // Get the floating origin offset - this was subtracted when positions were sent to Havok
760
+ // We need to add it back to get the correct world position
538
761
  if (body._pluginDataInstances.length) {
539
762
  // instances
540
763
  const m = transformNode;
@@ -544,26 +767,41 @@ export class HavokPlugin {
544
767
  }
545
768
  const instancesCount = body._pluginDataInstances.length;
546
769
  for (let i = 0; i < instancesCount; i++) {
547
- const bufOffset = body._pluginDataInstances[i].worldTransformOffset;
548
- const transformBuffer = new Float32Array(this._hknp.HEAPU8.buffer, this._bodyBuffer + bufOffset, 16);
770
+ const pluginData = body._pluginDataInstances[i];
771
+ // Use instance's world region offset
772
+ const instanceOffset = pluginData.worldRegion.floatingOrigin;
773
+ // Get body buffer from the instance's own world region (not always the default world)
774
+ const bodyBuffer = this._hknp.HP_World_GetBodyBuffer(pluginData.worldRegion.world)[1];
775
+ const bufOffset = pluginData.worldTransformOffset;
776
+ const transformBuffer = new Float32Array(this._hknp.HEAPU8.buffer, bodyBuffer + bufOffset, 16);
549
777
  const index = i * 16;
550
778
  for (let mi = 0; mi < 15; mi++) {
551
779
  if ((mi & 3) != 3) {
552
780
  matrixData[index + mi] = transformBuffer[mi];
553
781
  }
554
782
  }
783
+ // Add back the floating origin offset to get world position
784
+ // (Havok stores position - offset, so we add offset back)
785
+ matrixData[index + 12] += instanceOffset._x;
786
+ matrixData[index + 13] += instanceOffset._y;
787
+ matrixData[index + 14] += instanceOffset._z;
555
788
  matrixData[index + 15] = 1;
556
789
  }
557
790
  m.thinInstanceBufferUpdated("matrix");
558
791
  }
559
792
  else {
560
793
  try {
561
- // regular
562
794
  const bodyTransform = this._hknp.HP_Body_GetQTransform(body._pluginData.hpBodyId)[1];
563
795
  const bodyTranslation = bodyTransform[0];
564
796
  const bodyOrientation = bodyTransform[1];
565
797
  const quat = TmpVectors.Quaternion[0];
798
+ // Use body's world region offset
799
+ const offset = body._pluginData.worldRegion.floatingOrigin;
566
800
  quat.set(bodyOrientation[0], bodyOrientation[1], bodyOrientation[2], bodyOrientation[3]);
801
+ // Add back the floating origin offset to get world position
802
+ const worldX = bodyTranslation[0] + offset._x;
803
+ const worldY = bodyTranslation[1] + offset._y;
804
+ const worldZ = bodyTranslation[2] + offset._z;
567
805
  const parent = transformNode.parent;
568
806
  // transform position/orientation in parent space
569
807
  if (parent && !parent.getWorldMatrix().isIdentity()) {
@@ -573,7 +811,7 @@ export class HavokPlugin {
573
811
  quat.normalize();
574
812
  const finalTransform = TmpVectors.Matrix[0];
575
813
  const finalTranslation = TmpVectors.Vector3[0];
576
- finalTranslation.copyFromFloats(bodyTranslation[0], bodyTranslation[1], bodyTranslation[2]);
814
+ finalTranslation.copyFromFloats(worldX, worldY, worldZ);
577
815
  Matrix.ComposeToRef(transformNode.absoluteScaling, quat, finalTranslation, finalTransform);
578
816
  const parentInverseTransform = TmpVectors.Matrix[1];
579
817
  parent.getWorldMatrix().invertToRef(parentInverseTransform);
@@ -585,7 +823,7 @@ export class HavokPlugin {
585
823
  transformNode.scaling.copyFrom(TmpVectors.Vector3[1]);
586
824
  }
587
825
  else {
588
- transformNode.position.set(bodyTranslation[0], bodyTranslation[1], bodyTranslation[2]);
826
+ transformNode.position.set(worldX, worldY, worldZ);
589
827
  if (transformNode.rotationQuaternion) {
590
828
  transformNode.rotationQuaternion.copyFrom(quat);
591
829
  }
@@ -938,7 +1176,8 @@ export class HavokPlugin {
938
1176
  */
939
1177
  applyImpulse(body, impulse, location, instanceIndex) {
940
1178
  this._applyToBodyOrInstances(body, (pluginRef) => {
941
- this._hknp.HP_Body_ApplyImpulse(pluginRef.hpBodyId, this._bVecToV3(location), this._bVecToV3(impulse));
1179
+ const offset = pluginRef.worldRegion.floatingOrigin;
1180
+ this._hknp.HP_Body_ApplyImpulse(pluginRef.hpBodyId, this._bVecToV3WithOffset(location, offset), this._bVecToV3(impulse));
942
1181
  }, instanceIndex);
943
1182
  }
944
1183
  /**
@@ -1036,8 +1275,45 @@ export class HavokPlugin {
1036
1275
  this._createOrUpdateBodyInstances(body, body.getMotionType(), matrixData, 0, instancesCount, true);
1037
1276
  }
1038
1277
  else {
1039
- // regular
1040
- this._hknp.HP_Body_SetQTransform(body._pluginData.hpBodyId, this._getTransformInfos(node));
1278
+ // Check if the node's new world position requires a region change.
1279
+ // This ensures teleports (e.g. toggling disablePreStep after moving
1280
+ // the transform node) immediately land in the correct region with
1281
+ // correct local coordinates, avoiding a one-frame precision glitch.
1282
+ const pluginData = body._pluginData;
1283
+ if (pluginData.worldRegion && (this._worldRegions.length > 1 || FloatingOriginCurrentScene.getScene()?.floatingOriginMode)) {
1284
+ // Get world position of the node
1285
+ const worldPos = TmpVectors.Vector3[3];
1286
+ if (node.parent) {
1287
+ node.computeWorldMatrix(true);
1288
+ worldPos.copyFrom(node.absolutePosition);
1289
+ }
1290
+ else {
1291
+ worldPos.copyFrom(node.position);
1292
+ }
1293
+ const currentRegion = pluginData.worldRegion;
1294
+ const distToCurrent = Vector3.Distance(worldPos, currentRegion.floatingOrigin);
1295
+ if (distToCurrent > this._floatingOriginWorldRadius * 1.2) {
1296
+ // Teleporting outside current region - re-region before setting transform
1297
+ const newRegion = this._getOrCreateWorldRegion(worldPos);
1298
+ if (newRegion !== currentRegion) {
1299
+ // Save velocity before removing from old world
1300
+ const linVel = this._hknp.HP_Body_GetLinearVelocity(pluginData.hpBodyId)[1];
1301
+ const angVel = this._hknp.HP_Body_GetAngularVelocity(pluginData.hpBodyId)[1];
1302
+ // Remove from old world, add to new world
1303
+ this._hknp.HP_World_RemoveBody(currentRegion.world, pluginData.hpBodyId);
1304
+ this._hknp.HP_World_AddBody(newRegion.world, pluginData.hpBodyId, false);
1305
+ // Restore velocity
1306
+ this._hknp.HP_Body_SetLinearVelocity(pluginData.hpBodyId, linVel);
1307
+ this._hknp.HP_Body_SetAngularVelocity(pluginData.hpBodyId, angVel);
1308
+ // Update region reference and cached world transform offset
1309
+ pluginData.worldRegion = newRegion;
1310
+ pluginData.worldTransformOffset = this._hknp.HP_Body_GetWorldTransformOffset(pluginData.hpBodyId)[1];
1311
+ }
1312
+ }
1313
+ }
1314
+ // Set transform using the (possibly updated) region offset
1315
+ const offset = body._pluginData.worldRegion.floatingOrigin;
1316
+ this._hknp.HP_Body_SetQTransform(body._pluginData.hpBodyId, this._getTransformInfos(node, offset));
1041
1317
  }
1042
1318
  }
1043
1319
  else if (body.getPrestepType() == PhysicsPrestepType.ACTION) {
@@ -1059,7 +1335,8 @@ export class HavokPlugin {
1059
1335
  */
1060
1336
  setTargetTransform(body, position, rotation, instanceIndex) {
1061
1337
  this._applyToBodyOrInstances(body, (pluginRef) => {
1062
- this._hknp.HP_Body_SetTargetQTransform(pluginRef.hpBodyId, [this._bVecToV3(position), this._bQuatToV4(rotation)]);
1338
+ const offset = pluginRef.worldRegion.floatingOrigin;
1339
+ this._hknp.HP_Body_SetTargetQTransform(pluginRef.hpBodyId, [this._bVecToV3WithOffset(position, offset), this._bQuatToV4(rotation)]);
1063
1340
  }, instanceIndex);
1064
1341
  }
1065
1342
  /**
@@ -1341,12 +1618,13 @@ export class HavokPlugin {
1341
1618
  * It first checks if the node has a rotation quaternion, and if not, it creates one from the node's rotation.
1342
1619
  * It then creates an array containing the position and orientation of the node and returns it.
1343
1620
  * @param node - The transform node.
1621
+ * @param offset - The floating origin offset to apply.
1344
1622
  * @returns An array containing the position and orientation of the node.
1345
1623
  */
1346
- _getTransformInfos(node) {
1624
+ _getTransformInfos(node, offset) {
1347
1625
  if (node.parent) {
1348
1626
  node.computeWorldMatrix(true);
1349
- return [this._bVecToV3(node.absolutePosition), this._bQuatToV4(node.absoluteRotationQuaternion)];
1627
+ return [this._bVecToV3WithOffset(node.absolutePosition, offset), this._bQuatToV4(node.absoluteRotationQuaternion)];
1350
1628
  }
1351
1629
  let orientation = TmpVectors.Quaternion[0];
1352
1630
  if (node.rotationQuaternion) {
@@ -1356,7 +1634,7 @@ export class HavokPlugin {
1356
1634
  const r = node.rotation;
1357
1635
  Quaternion.FromEulerAnglesToRef(r.x, r.y, r.z, orientation);
1358
1636
  }
1359
- const transform = [this._bVecToV3(node.position), this._bQuatToV4(orientation)];
1637
+ const transform = [this._bVecToV3WithOffset(node.position, offset), this._bQuatToV4(orientation)];
1360
1638
  return transform;
1361
1639
  }
1362
1640
  /**
@@ -1905,7 +2183,10 @@ export class HavokPlugin {
1905
2183
  const hitPos = hitData[3];
1906
2184
  const hitNormal = hitData[4];
1907
2185
  const hitTriangle = hitData[5];
1908
- result.setHitData({ x: hitNormal[0], y: hitNormal[1], z: hitNormal[2] }, { x: hitPos[0], y: hitPos[1], z: hitPos[2] }, hitTriangle);
2186
+ // Add floating origin offset back to hit position using the hit body's world region offset
2187
+ // If no hit body (shouldn't happen), use zero offset from default region
2188
+ const offset = hitBody?.body?._pluginData?.worldRegion?.floatingOrigin ?? this._worldRegions[0].floatingOrigin;
2189
+ result.setHitData({ x: hitNormal[0], y: hitNormal[1], z: hitNormal[2] }, { x: hitPos[0] + offset._x, y: hitPos[1] + offset._y, z: hitPos[2] + offset._z }, hitTriangle);
1909
2190
  }
1910
2191
  /**
1911
2192
  * Performs a raycast from a given start point to a given end point and stores the result in a given PhysicsRaycastResult object.
@@ -1929,9 +2210,15 @@ export class HavokPlugin {
1929
2210
  for (const raycastResult of results) {
1930
2211
  raycastResult.reset(from, to);
1931
2212
  }
1932
- const hkQuery = [this._bVecToV3(from), this._bVecToV3(to), [queryMembership, queryCollideWith], shouldHitTriggers, bodyToIgnore];
2213
+ // Use the ignored body's world region if available, otherwise use default region
2214
+ const worldRegion = query?.ignoreBody?._pluginData?.worldRegion ?? this._worldRegions[0];
2215
+ const offset = worldRegion.floatingOrigin;
2216
+ const world = worldRegion.world;
2217
+ const offsetFrom = this._bVecToV3WithOffset(from, offset);
2218
+ const offsetTo = this._bVecToV3WithOffset(to, offset);
2219
+ const hkQuery = [offsetFrom, offsetTo, [queryMembership, queryCollideWith], shouldHitTriggers, bodyToIgnore];
1933
2220
  const queryCollector = results.length === 1 || !this._multiQueryCollector ? this._queryCollector : this._multiQueryCollector;
1934
- this._hknp.HP_World_CastRayWithCollector(this.world, queryCollector, hkQuery);
2221
+ this._hknp.HP_World_CastRayWithCollector(world, queryCollector, hkQuery);
1935
2222
  const numHits = this._hknp.HP_QueryCollector_GetNumHits(queryCollector)[1];
1936
2223
  if (numHits <= 0) {
1937
2224
  return;
@@ -1948,7 +2235,8 @@ export class HavokPlugin {
1948
2235
  for (let i = 0; i < numHits; i++) {
1949
2236
  const [, hitData] = this._hknp.HP_QueryCollector_GetCastRayResult(queryCollector, i)[1];
1950
2237
  const hitPos = hitData[3];
1951
- from.subtractFromFloatsToRef(hitPos[0], hitPos[1], hitPos[2], this._tmpVec3[0]);
2238
+ // Use offsetFrom for distance calculation since hitPos is in Havok's offset space
2239
+ this._tmpVec3[0].set(offsetFrom[0] - hitPos[0], offsetFrom[1] - hitPos[1], offsetFrom[2] - hitPos[2]);
1952
2240
  const distance = this._tmpVec3[0].lengthSquared();
1953
2241
  hitDatas[i] = {
1954
2242
  hitData,
@@ -1974,8 +2262,12 @@ export class HavokPlugin {
1974
2262
  const queryCollideWith = query?.collisionFilter?.collideWith ?? ~0;
1975
2263
  result.reset();
1976
2264
  const bodyToIgnore = query.ignoreBody ? [BigInt(query.ignoreBody._pluginData.hpBodyId[0])] : [BigInt(0)];
1977
- const hkQuery = [this._bVecToV3(query.position), query.maxDistance, [queryMembership, queryCollideWith], query.shouldHitTriggers, bodyToIgnore];
1978
- this._hknp.HP_World_PointProximityWithCollector(this.world, this._queryCollector, hkQuery);
2265
+ // Use the ignored body's world region if available, otherwise use default region
2266
+ const worldRegion = query.ignoreBody?._pluginData?.worldRegion ?? this._worldRegions[0];
2267
+ const offset = worldRegion.floatingOrigin;
2268
+ const world = worldRegion.world;
2269
+ const hkQuery = [this._bVecToV3WithOffset(query.position, offset), query.maxDistance, [queryMembership, queryCollideWith], query.shouldHitTriggers, bodyToIgnore];
2270
+ this._hknp.HP_World_PointProximityWithCollector(world, this._queryCollector, hkQuery);
1979
2271
  if (this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1] > 0) {
1980
2272
  const [distance, hitData] = this._hknp.HP_QueryCollector_GetPointProximityResult(this._queryCollector, 0)[1];
1981
2273
  this._populateHitData(hitData, result);
@@ -1993,8 +2285,12 @@ export class HavokPlugin {
1993
2285
  hitShapeResult.reset();
1994
2286
  const shapeId = query.shape._pluginData;
1995
2287
  const bodyToIgnore = query.ignoreBody ? [BigInt(query.ignoreBody._pluginData.hpBodyId[0])] : [BigInt(0)];
1996
- const hkQuery = [shapeId, this._bVecToV3(query.position), this._bQuatToV4(query.rotation), query.maxDistance, query.shouldHitTriggers, bodyToIgnore];
1997
- this._hknp.HP_World_ShapeProximityWithCollector(this.world, this._queryCollector, hkQuery);
2288
+ // Use the ignored body's world region if available, otherwise use default region
2289
+ const worldRegion = query.ignoreBody?._pluginData?.worldRegion ?? this._worldRegions[0];
2290
+ const offset = worldRegion.floatingOrigin;
2291
+ const world = worldRegion.world;
2292
+ const hkQuery = [shapeId, this._bVecToV3WithOffset(query.position, offset), this._bQuatToV4(query.rotation), query.maxDistance, query.shouldHitTriggers, bodyToIgnore];
2293
+ this._hknp.HP_World_ShapeProximityWithCollector(world, this._queryCollector, hkQuery);
1998
2294
  if (this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1] > 0) {
1999
2295
  const [distance, hitInputData, hitShapeData] = this._hknp.HP_QueryCollector_GetShapeProximityResult(this._queryCollector, 0)[1];
2000
2296
  this._populateHitData(hitInputData, inputShapeResult);
@@ -2014,8 +2310,19 @@ export class HavokPlugin {
2014
2310
  hitShapeResult.reset();
2015
2311
  const shapeId = query.shape._pluginData;
2016
2312
  const bodyToIgnore = query.ignoreBody ? [BigInt(query.ignoreBody._pluginData.hpBodyId[0])] : [BigInt(0)];
2017
- const hkQuery = [shapeId, this._bQuatToV4(query.rotation), this._bVecToV3(query.startPosition), this._bVecToV3(query.endPosition), query.shouldHitTriggers, bodyToIgnore];
2018
- this._hknp.HP_World_ShapeCastWithCollector(this.world, this._queryCollector, hkQuery);
2313
+ // Use the ignored body's world region if available, otherwise use default region
2314
+ const worldRegion = query.ignoreBody?._pluginData?.worldRegion ?? this._worldRegions[0];
2315
+ const offset = worldRegion.floatingOrigin;
2316
+ const world = worldRegion.world;
2317
+ const hkQuery = [
2318
+ shapeId,
2319
+ this._bQuatToV4(query.rotation),
2320
+ this._bVecToV3WithOffset(query.startPosition, offset),
2321
+ this._bVecToV3WithOffset(query.endPosition, offset),
2322
+ query.shouldHitTriggers,
2323
+ bodyToIgnore,
2324
+ ];
2325
+ this._hknp.HP_World_ShapeCastWithCollector(world, this._queryCollector, hkQuery);
2019
2326
  if (this._hknp.HP_QueryCollector_GetNumHits(this._queryCollector)[1] > 0) {
2020
2327
  const [fractionAlongRay, hitInputData, hitShapeData] = this._hknp.HP_QueryCollector_GetShapeCastResult(this._queryCollector, 0)[1];
2021
2328
  this._populateHitData(hitInputData, inputShapeResult);
@@ -2093,8 +2400,9 @@ export class HavokPlugin {
2093
2400
  this._hknp.HP_Body_SetEventMask(body._pluginData.hpBodyId, currentCollideEvents);
2094
2401
  }
2095
2402
  }
2096
- _notifyTriggers() {
2097
- let eventAddress = this._hknp.HP_World_GetTriggerEvents(this.world)[1];
2403
+ _notifyTriggers(world) {
2404
+ const targetWorld = world ?? this.world;
2405
+ let eventAddress = this._hknp.HP_World_GetTriggerEvents(targetWorld)[1];
2098
2406
  const event = new TriggerEvent();
2099
2407
  while (eventAddress) {
2100
2408
  TriggerEvent.readToRef(this._hknp.HEAPU8.buffer, eventAddress, event);
@@ -2111,20 +2419,30 @@ export class HavokPlugin {
2111
2419
  };
2112
2420
  this.onTriggerCollisionObservable.notifyObservers(triggerCollisionInfo);
2113
2421
  }
2114
- eventAddress = this._hknp.HP_World_GetNextTriggerEvent(this.world, eventAddress);
2422
+ eventAddress = this._hknp.HP_World_GetNextTriggerEvent(targetWorld, eventAddress);
2115
2423
  }
2116
2424
  }
2117
2425
  /**
2118
2426
  * Runs thru all detected collisions and filter by body
2427
+ * @param world optional world to check collisions for (defaults to main world)
2119
2428
  */
2120
- _notifyCollisions() {
2121
- let eventAddress = this._hknp.HP_World_GetCollisionEvents(this.world)[1];
2429
+ _notifyCollisions(world) {
2430
+ const targetWorld = world ?? this.world;
2431
+ let eventAddress = this._hknp.HP_World_GetCollisionEvents(targetWorld)[1];
2122
2432
  const event = new CollisionEvent();
2123
- const worldAddr = Number(this.world);
2433
+ const worldAddr = Number(targetWorld);
2434
+ // Find the region for this world to get the correct floating origin offset.
2435
+ // All bodies in a collision share the same world, so use one offset for both.
2436
+ const region = this._worldRegions.find((r) => Number(r.world) === worldAddr) ?? this._worldRegions[0];
2437
+ const regionOffset = region.floatingOrigin;
2124
2438
  while (eventAddress) {
2125
2439
  CollisionEvent.readToRef(this._hknp.HEAPU8.buffer, eventAddress, event);
2126
2440
  const bodyInfoA = this._bodies.get(event.contactOnA.bodyId);
2127
2441
  const bodyInfoB = this._bodies.get(event.contactOnB.bodyId);
2442
+ // Add floating origin offset back to collision contact positions.
2443
+ // Both contacts are in the same world, so use the region's floating origin.
2444
+ event.contactOnA.position.addInPlace(regionOffset);
2445
+ event.contactOnB.position.addInPlace(regionOffset);
2128
2446
  // Bodies may have been disposed between events. Check both still exist.
2129
2447
  if (bodyInfoA && bodyInfoB) {
2130
2448
  const collisionInfo = {
@@ -2212,12 +2530,16 @@ export class HavokPlugin {
2212
2530
  }
2213
2531
  if (this._multiQueryCollector) {
2214
2532
  this._hknp.HP_QueryCollector_Release(this._multiQueryCollector);
2215
- this._multiQueryCollector;
2533
+ this._multiQueryCollector = undefined;
2216
2534
  }
2217
- if (this.world) {
2218
- this._hknp.HP_World_Release(this.world);
2219
- this.world = undefined;
2535
+ // Dispose all world regions (includes the default world)
2536
+ for (const region of this._worldRegions) {
2537
+ if (region.world) {
2538
+ this._hknp.HP_World_Release(region.world);
2539
+ }
2220
2540
  }
2541
+ this._worldRegions.length = 0;
2542
+ this.world = undefined;
2221
2543
  }
2222
2544
  _v3ToBvecRef(v, vec3) {
2223
2545
  vec3.set(v[0], v[1], v[2]);
@@ -2225,6 +2547,19 @@ export class HavokPlugin {
2225
2547
  _bVecToV3(v) {
2226
2548
  return [v._x, v._y, v._z];
2227
2549
  }
2550
+ /**
2551
+ * Converts a Vector3 to Havok format with floating origin offset subtracted.
2552
+ * Use this for world-space positions being sent to Havok.
2553
+ * @param v - The vector to convert
2554
+ * @param offset - Optional offset to use. If not provided, no offset is applied.
2555
+ * @returns The converted vector
2556
+ */
2557
+ _bVecToV3WithOffset(v, offset) {
2558
+ if (offset) {
2559
+ return [v._x - offset._x, v._y - offset._y, v._z - offset._z];
2560
+ }
2561
+ return [v._x, v._y, v._z];
2562
+ }
2228
2563
  _bQuatToV4(q) {
2229
2564
  return [q._x, q._y, q._z, q._w];
2230
2565
  }