@divinevoxel/vlox 0.0.72 → 0.0.74

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 (307) hide show
  1. package/Contexts/Base/Remote/InitDataSync.js +4 -0
  2. package/Contexts/Base/Remote/InitWorldDataSync.js +1 -1
  3. package/Contexts/Render/DivineVoxelEngineRender.d.ts +2 -1
  4. package/Contexts/World/DivineVoxelEngineWorld.d.ts +2 -1
  5. package/Init/StartConstructor.js +8 -4
  6. package/Init/StartWorld.d.ts +1 -1
  7. package/Math/index.d.ts +5 -1
  8. package/Mesher/Functions/CompactVoxelMesh.d.ts +2 -2
  9. package/Mesher/Functions/CompactVoxelMesh.js +1 -1
  10. package/Mesher/Functions/CompactVoxelSectionMesh.d.ts +4 -0
  11. package/Mesher/Functions/CompactVoxelSectionMesh.js +112 -0
  12. package/Mesher/Functions/MeshSection.d.ts +1 -1
  13. package/Mesher/Functions/MeshSection.js +27 -22
  14. package/Mesher/Functions/MeshTexture.d.ts +1 -1
  15. package/Mesher/Functions/MeshTexture.js +3 -4
  16. package/Mesher/Geomtry/CompactedSectionVoxelMesh.d.ts +23 -0
  17. package/Mesher/Geomtry/CompactedSectionVoxelMesh.js +144 -0
  18. package/Mesher/Geomtry/Primitives/QuadVertexData.d.ts +12 -10
  19. package/Mesher/Geomtry/Primitives/QuadVertexData.js +49 -56
  20. package/Mesher/Geomtry/VoxelGeometryBuilder.d.ts +2 -2
  21. package/Mesher/Geomtry/VoxelGeometryBuilder.js +120 -199
  22. package/Mesher/Geomtry/VoxelMesh.d.ts +1 -1
  23. package/Mesher/Geomtry/VoxelMesh.js +4 -4
  24. package/Mesher/Geomtry/VoxelMeshBVHBuilder.d.ts +16 -0
  25. package/Mesher/Geomtry/VoxelMeshBVHBuilder.js +51 -0
  26. package/Mesher/Geomtry/VoxelMeshBVHStructCursor.d.ts +22 -0
  27. package/Mesher/Geomtry/VoxelMeshBVHStructCursor.js +78 -0
  28. package/Mesher/Geomtry/{Buffers.js → VoxelMeshBuffers.js} +2 -2
  29. package/Mesher/Geomtry/index.d.ts +0 -1
  30. package/Mesher/Geomtry/index.js +0 -1
  31. package/Mesher/InitMesher.js +1 -1
  32. package/Mesher/InitTask.js +9 -23
  33. package/Mesher/Models/Common/BoxGeometryNode.js +7 -7
  34. package/Mesher/Models/Common/Calc/CalcConstants.d.ts +1 -1
  35. package/Mesher/Models/Common/Calc/CalcConstants.js +1 -1
  36. package/Mesher/Models/Common/Calc/FaceDataCalc.d.ts +2 -2
  37. package/Mesher/Models/Common/Calc/FaceDataCalc.js +37 -30
  38. package/Mesher/Models/Common/QuadGeometryNode.js +2 -2
  39. package/Mesher/Models/Nodes/Custom/Liquid/FlowGradient.d.ts +2 -2
  40. package/Mesher/Models/Nodes/Custom/Liquid/FlowGradient.js +1 -1
  41. package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +18 -24
  42. package/Mesher/Models/Nodes/GeometryNode.d.ts +2 -2
  43. package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.d.ts +1 -0
  44. package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +40 -31
  45. package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +2 -2
  46. package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.js +2 -2
  47. package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.js +2 -2
  48. package/Mesher/{Tools → Models/Protocols}/OutlinedVoxelTool.d.ts +1 -1
  49. package/Mesher/{Tools → Models/Protocols}/OutlinedVoxelTool.js +1 -1
  50. package/Mesher/Models/RenderedMaterials.d.ts +6 -0
  51. package/Mesher/{RenderedMaterials.js → Models/RenderedMaterials.js} +2 -2
  52. package/Mesher/Models/VoxelConstructor.d.ts +6 -6
  53. package/Mesher/Models/VoxelConstructor.js +8 -8
  54. package/Mesher/Models/VoxelGeometryBuilderCacheSpace.d.ts +3 -5
  55. package/Mesher/Models/VoxelGeometryBuilderCacheSpace.js +8 -32
  56. package/Mesher/{Tools/VoxelMesherDataTool.d.ts → Models/VoxelModelBuilder.d.ts} +4 -5
  57. package/Mesher/{Tools/VoxelMesherDataTool.js → Models/VoxelModelBuilder.js} +5 -8
  58. package/Mesher/Types/Mesher.types.d.ts +1 -0
  59. package/Models/Defaults/CubeVoxelGeometry.js +4 -0
  60. package/Models/Defaults/CubeVoxelModels.js +360 -383
  61. package/Models/Defaults/LiquidVoxelModel.js +5 -5
  62. package/Models/Defaults/PanelVoxelModels.js +442 -468
  63. package/Models/Defaults/StairVoxelModel.js +582 -597
  64. package/Models/Examples.js +490 -498
  65. package/Models/Rules/Classes/VoxelRulesModel.d.ts +1 -1
  66. package/Models/Rules/Classes/VoxelRulesModel.js +3 -3
  67. package/Models/Rules/Functions/BuildFinalInputs.d.ts +1 -1
  68. package/Models/Rules/Functions/BuildFinalInputs.js +21 -19
  69. package/Models/Rules/Functions/BuildGeomtryInputs.js +8 -5
  70. package/Models/Rules/Functions/BuildRules.js +2 -2
  71. package/Models/Rules/{VoxelModelManager.d.ts → VoxelModelRuleBuilderRegister.d.ts} +1 -1
  72. package/Models/Rules/VoxelModelRuleBuilderRegister.js +178 -0
  73. package/Models/VoxelModel.types.d.ts +17 -8
  74. package/Renderer/Classes/DVESectionMeshes.d.ts +2 -3
  75. package/Renderer/Classes/SectorMesh.d.ts +3 -4
  76. package/Renderer/Classes/SectorMesh.js +6 -11
  77. package/Renderer/InitTasks.js +1 -10
  78. package/Renderer/MeshManager.d.ts +1 -1
  79. package/Renderer/MeshManager.js +26 -25
  80. package/Renderer/MeshRegister.d.ts +5 -5
  81. package/Renderer/MeshRegister.js +4 -3
  82. package/Settings/EngineSettings.d.ts +2 -1
  83. package/Settings/EngineSettings.js +6 -5
  84. package/Settings/EngineSettings.types.d.ts +24 -39
  85. package/Settings/EngineSettings.types.js +22 -29
  86. package/Tasks/Logic/InitTasks.d.ts +1 -0
  87. package/Tasks/Logic/InitTasks.js +10 -0
  88. package/Tasks/Logic/VoxelLogicUpdate.d.ts +3 -0
  89. package/Tasks/Logic/VoxelLogicUpdate.js +71 -0
  90. package/Tasks/Propagation/Explosion/ExplosionManager.d.ts +2 -2
  91. package/Tasks/Propagation/Explosion/ExplosionManager.js +1 -2
  92. package/Tasks/Propagation/Flow/FlowManager.d.ts +4 -4
  93. package/Tasks/Propagation/Flow/FlowRemove.d.ts +2 -2
  94. package/Tasks/Propagation/Flow/FlowUpdate.d.ts +2 -2
  95. package/Tasks/Propagation/Flow/WorldFlow.d.ts +2 -2
  96. package/Tasks/Propagation/Illumanation/RGBUpdate.d.ts +3 -3
  97. package/Tasks/Propagation/Illumanation/SunUpdate.d.ts +3 -3
  98. package/Tasks/Propagation/Illumanation/WorldRGB.d.ts +2 -2
  99. package/Tasks/Propagation/Illumanation/WorldSun.d.ts +2 -2
  100. package/Tasks/Propagation/Illumanation/WorldSun.js +8 -15
  101. package/Tasks/Propagation/InitTasks.js +4 -4
  102. package/Tasks/Propagation/Power/PowerUpdate.d.ts +3 -0
  103. package/Tasks/Propagation/Power/PowerUpdate.js +80 -0
  104. package/Tasks/Tasks.types.d.ts +2 -2
  105. package/Tasks/TasksIds.d.ts +2 -1
  106. package/Tasks/TasksIds.js +1 -0
  107. package/Tasks/Update/Common.d.ts +3 -0
  108. package/Tasks/Update/Common.js +41 -0
  109. package/Tasks/Update/EreaseUpdate.d.ts +3 -0
  110. package/Tasks/Update/EreaseUpdate.js +66 -0
  111. package/Tasks/Update/InitTasks.d.ts +2 -2
  112. package/Tasks/Update/InitTasks.js +3 -1
  113. package/Tasks/Update/PaintUpdate.d.ts +3 -0
  114. package/Tasks/Update/PaintUpdate.js +89 -0
  115. package/Tasks/Update/VoxelUpdate.d.ts +2 -5
  116. package/Tasks/Update/VoxelUpdate.js +7 -143
  117. package/Tasks/{Update/UpdateTask.d.ts → VoxelUpdateTask.d.ts} +16 -6
  118. package/Tasks/{Update/UpdateTask.js → VoxelUpdateTask.js} +44 -5
  119. package/Tasks/WorldGeneration/WorldGenBrush.d.ts +3 -3
  120. package/Tasks/WorldGeneration/WorldGenBrush.js +3 -3
  121. package/Tasks/WorldGeneration/WorldGenRegister.d.ts +1 -1
  122. package/Templates/Cursor/TemplateCursor.d.ts +2 -2
  123. package/Templates/Cursor/TemplateCursor.js +1 -2
  124. package/Templates/Functions/CreateTemplate.d.ts +1 -1
  125. package/Templates/VoxelTemplates.types.d.ts +1 -1
  126. package/Textures/Classes/CompiledTexture.d.ts +18 -0
  127. package/Textures/Classes/CompiledTexture.js +50 -0
  128. package/Textures/Classes/CompiledTextureAnimation.d.ts +12 -0
  129. package/Textures/Classes/CompiledTextureAnimation.js +27 -0
  130. package/Textures/Classes/TextureAnimationTexture.d.ts +10 -0
  131. package/Textures/Classes/TextureAnimationTexture.js +32 -0
  132. package/Textures/Functions/BuildTextureData.d.ts +10 -0
  133. package/Textures/Functions/BuildTextureData.js +205 -0
  134. package/Textures/Texture.types.d.ts +50 -64
  135. package/Textures/TextureManager.d.ts +8 -19
  136. package/Textures/TextureManager.js +28 -166
  137. package/Tools/Brush/AdvancedBrushTool.js +1 -1
  138. package/Tools/Brush/Brush.d.ts +3 -3
  139. package/Tools/Brush/Brush.js +40 -8
  140. package/Tools/Tasks/TasksTool.d.ts +1 -0
  141. package/Tools/Tasks/TasksTool.js +2 -0
  142. package/Util/Binary/BinaryArrays.d.ts +6 -0
  143. package/Util/Binary/BinaryArrays.js +25 -0
  144. package/Util/Binary/BinaryBuffer.d.ts +35 -0
  145. package/Util/Binary/BinaryBuffer.js +136 -0
  146. package/Util/Binary/{BitArray.d.ts → BinaryFunctions.d.ts} +1 -2
  147. package/Util/Binary/BinaryFunctions.js +11 -0
  148. package/{Mesher/Tools/VoxelMeshBVHBuilder.d.ts → Util/Binary/BinaryTree.d.ts} +1 -33
  149. package/Util/Binary/BinaryTree.js +104 -0
  150. package/Voxels/Cursor/DataCursor.interface.d.ts +5 -0
  151. package/Voxels/Cursor/VoxelCursor.interface.d.ts +8 -3
  152. package/Voxels/Cursor/VoxelCursor.interface.js +54 -13
  153. package/Voxels/Cursor/VoxelLightData.js +1 -1
  154. package/Voxels/Data/VoxelPalettesRegister.d.ts +0 -5
  155. package/Voxels/Data/VoxelPalettesRegister.js +0 -9
  156. package/Voxels/Data/VoxelTag.types.d.ts +17 -2
  157. package/Voxels/Data/VoxelTag.types.js +6 -1
  158. package/Voxels/Data/VoxelTagsRegister.js +12 -7
  159. package/Voxels/Functions/BuildStateData.d.ts +6 -6
  160. package/Voxels/Functions/BuildStateData.js +37 -37
  161. package/Voxels/Functions/BuildTagAndPaletteData.js +6 -3
  162. package/Voxels/Indexes/VoxelIndex.d.ts +2 -2
  163. package/Voxels/Indexes/VoxelIndex.js +16 -18
  164. package/Voxels/InitVoxelData.js +24 -21
  165. package/Voxels/Logic/Classes/Default/Types/VoxelPoweredLogicType.d.ts +5 -0
  166. package/Voxels/Logic/Classes/Default/Types/VoxelPoweredLogicType.js +6 -0
  167. package/Voxels/Logic/Classes/VoxelLogic.d.ts +11 -0
  168. package/Voxels/Logic/Classes/VoxelLogic.js +49 -0
  169. package/Voxels/Logic/Classes/VoxelLogicType.d.ts +4 -0
  170. package/Voxels/Logic/Classes/VoxelLogicType.js +2 -0
  171. package/Voxels/Logic/VoxelLogic.types.d.ts +23 -0
  172. package/Voxels/Logic/VoxelLogic.types.js +1 -0
  173. package/Voxels/Logic/VoxelLogicRegister.d.ts +9 -0
  174. package/Voxels/Logic/VoxelLogicRegister.js +15 -0
  175. package/Voxels/State/Schema/StateSchema.d.ts +1 -1
  176. package/Voxels/State/SchemaRegister.js +10 -5
  177. package/Voxels/State/State.types.d.ts +1 -1
  178. package/Voxels/State/StateTreeReader.d.ts +1 -1
  179. package/Voxels/State/StateTreeReader.js +2 -3
  180. package/Voxels/Types/Voxel.types.d.ts +21 -0
  181. package/Voxels/Types/Voxel.types.js +6 -2
  182. package/Voxels/Types/VoxelModelCompiledData.types.d.ts +6 -4
  183. package/World/Archive/Archive.types.d.ts +65 -42
  184. package/World/Archive/Classes/ArchiveClasses.d.ts +66 -0
  185. package/World/Archive/Classes/ArchiveClasses.js +78 -0
  186. package/World/Archive/Classes/ImportedSection.d.ts +40 -0
  187. package/World/Archive/Classes/ImportedSection.js +307 -0
  188. package/World/Archive/Classes/ImportedSector.d.ts +23 -0
  189. package/World/Archive/Classes/ImportedSector.js +97 -0
  190. package/World/Archive/Functions/ArchiveArea.d.ts +1 -1
  191. package/World/Archive/Functions/ArchiveArea.js +49 -54
  192. package/World/Archive/Functions/ArchiveSector.js +373 -282
  193. package/World/Archive/Functions/CreateArchivedSection.d.ts +3 -0
  194. package/World/Archive/Functions/CreateArchivedSection.js +207 -0
  195. package/World/Archive/Functions/ImportSector.d.ts +2 -4
  196. package/World/Archive/Functions/ImportSector.js +50 -220
  197. package/World/Archive/Functions/RemoveDuplicates.d.ts +3 -0
  198. package/World/Archive/Functions/RemoveDuplicates.js +92 -0
  199. package/World/Archive/Functions/Shared.d.ts +6 -0
  200. package/World/Archive/Functions/Shared.js +50 -0
  201. package/World/Archive/InitTasks.js +37 -23
  202. package/World/Cursor/SectionCursor.d.ts +3 -3
  203. package/World/Cursor/SectionCursor.js +2 -3
  204. package/World/Cursor/SectorCursor.d.ts +3 -3
  205. package/World/Cursor/SectorCursor.js +1 -2
  206. package/World/Cursor/WorldCursor.d.ts +6 -5
  207. package/World/Cursor/WorldCursor.js +17 -15
  208. package/World/Cursor/WorldVoxelCursor.d.ts +0 -4
  209. package/World/Cursor/WorldVoxelCursor.js +24 -14
  210. package/World/Dimension/Dimension.d.ts +4 -1
  211. package/World/Dimension/Dimension.js +8 -1
  212. package/World/InitTasks.d.ts +1 -1
  213. package/World/Lock/WorldLock.d.ts +1 -1
  214. package/World/Section/Section.d.ts +27 -18
  215. package/World/Section/Section.js +125 -21
  216. package/World/Section/SectionState.d.ts +12 -0
  217. package/World/Section/SectionState.js +13 -0
  218. package/World/Sector/Sector.d.ts +20 -6
  219. package/World/Sector/Sector.js +100 -17
  220. package/World/Sector/SectorHeightMap.js +2 -2
  221. package/World/Sector/SectorState.d.ts +16 -7
  222. package/World/Sector/SectorState.js +29 -15
  223. package/World/Types/WorldData.types.d.ts +2 -7
  224. package/World/Types/WorldStorage.interface.js +1 -0
  225. package/World/WorldRegister.d.ts +13 -9
  226. package/World/WorldRegister.js +24 -9
  227. package/World/WorldSpaces.d.ts +4 -0
  228. package/World/WorldSpaces.js +25 -12
  229. package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.d.ts +2 -2
  230. package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.d.ts +10 -3
  231. package/{Tasks/IWG → WorldSimulation}/Internal/Classes/Generator.js +19 -3
  232. package/WorldSimulation/Internal/Classes/Queues/BuildQueue.d.ts +5 -0
  233. package/WorldSimulation/Internal/Classes/Queues/BuildQueue.js +6 -0
  234. package/WorldSimulation/Internal/Classes/Queues/LogiccQueue.d.ts +5 -0
  235. package/WorldSimulation/Internal/Classes/Queues/LogiccQueue.js +6 -0
  236. package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorVisistedMap.js +1 -1
  237. package/WorldSimulation/Internal/Classes/TickQueue.d.ts +12 -0
  238. package/WorldSimulation/Internal/Classes/TickQueue.js +58 -0
  239. package/WorldSimulation/Internal/Classes/WorldSimulationTaskBase.d.ts +15 -0
  240. package/{Tasks/IWG/Internal/Classes/IWGTaskBase.js → WorldSimulation/Internal/Classes/WorldSimulationTaskBase.js} +8 -8
  241. package/{Tasks/IWG → WorldSimulation}/Internal/Functions/cullSectors.js +9 -9
  242. package/{Tasks/IWG → WorldSimulation}/Internal/Functions/getSectorState.d.ts +1 -1
  243. package/{Tasks/IWG → WorldSimulation}/Internal/Functions/getSectorState.js +4 -4
  244. package/WorldSimulation/Internal/Functions/runTickUpdate.d.ts +2 -0
  245. package/{Tasks/IWG/Internal/Functions/runBuildUpdate.js → WorldSimulation/Internal/Functions/runTickUpdate.js} +38 -9
  246. package/{Tasks/IWG → WorldSimulation}/Internal/Functions/runWorldUpdate.js +13 -13
  247. package/{Tasks/IWG → WorldSimulation}/Internal/TaskRegister.d.ts +2 -2
  248. package/{Tasks/IWG → WorldSimulation}/Internal/TaskRegister.js +1 -1
  249. package/WorldSimulation/Internal/WorldSimulationDimensions.d.ts +6 -0
  250. package/{Tasks/IWG/Internal/IWGDimensions.js → WorldSimulation/Internal/WorldSimulationDimensions.js} +1 -1
  251. package/WorldSimulation/Internal/WorldSimulationTasks.d.ts +30 -0
  252. package/{Tasks/IWG/Internal/IWGTasks.js → WorldSimulation/Internal/WorldSimulationTasks.js} +14 -24
  253. package/WorldSimulation/Internal/WorldSimulationTools.d.ts +8 -0
  254. package/{Tasks/IWG/Internal/IWGTools.js → WorldSimulation/Internal/WorldSimulationTools.js} +1 -1
  255. package/{Tasks/IWG → WorldSimulation}/Procedures/InitalLoad.d.ts +1 -1
  256. package/{Tasks/IWG → WorldSimulation}/Procedures/InitalLoad.js +11 -11
  257. package/{Tasks/IWG → WorldSimulation}/Procedures/SaveAllSectors.js +7 -5
  258. package/{Tasks/IWG/IWG.d.ts → WorldSimulation/WorldSimulation.d.ts} +6 -5
  259. package/{Tasks/IWG/IWG.js → WorldSimulation/WorldSimulation.js} +29 -23
  260. package/{Tasks/IWG → WorldSimulation}/index.d.ts +1 -1
  261. package/{Tasks/IWG → WorldSimulation}/index.js +1 -1
  262. package/package.json +1 -1
  263. package/Mesher/Functions/CompactMesh.d.ts +0 -2
  264. package/Mesher/Functions/CompactMesh.js +0 -42
  265. package/Mesher/Geomtry/GeometryNormals.d.ts +0 -10
  266. package/Mesher/Geomtry/GeometryNormals.js +0 -52
  267. package/Mesher/Geomtry/MeshData.types.d.ts +0 -13
  268. package/Mesher/Geomtry/MeshData.types.js +0 -6
  269. package/Mesher/Geomtry/Tools/MesherDataTools.d.ts +0 -7
  270. package/Mesher/Geomtry/Tools/MesherDataTools.js +0 -12
  271. package/Mesher/Geomtry/Tools/index.d.ts +0 -1
  272. package/Mesher/Geomtry/Tools/index.js +0 -1
  273. package/Mesher/RenderedMaterials.d.ts +0 -6
  274. package/Mesher/Tools/VoxelMeshBVHBuilder.js +0 -216
  275. package/Models/Rules/VoxelModelManager.js +0 -82
  276. package/Tasks/IWG/Internal/Classes/IWGTaskBase.d.ts +0 -15
  277. package/Tasks/IWG/Internal/Functions/runBuildUpdate.d.ts +0 -2
  278. package/Tasks/IWG/Internal/IWGDimensions.d.ts +0 -6
  279. package/Tasks/IWG/Internal/IWGTasks.d.ts +0 -34
  280. package/Tasks/IWG/Internal/IWGTools.d.ts +0 -8
  281. package/Textures/TextureAnimations.d.ts +0 -4
  282. package/Textures/TextureAnimations.js +0 -35
  283. package/Textures/TextureArray.d.ts +0 -47
  284. package/Textures/TextureArray.js +0 -202
  285. package/Textures/TextureBuilder.d.ts +0 -13
  286. package/Textures/TextureBuilder.js +0 -120
  287. package/Textures/TextureRegister.d.ts +0 -9
  288. package/Textures/TextureRegister.js +0 -28
  289. package/Tools/DataCursor.interface.d.ts +0 -5
  290. package/Tools/DataCursor.interface.js +0 -2
  291. package/Util/Binary/BitArray.js +0 -16
  292. package/World/Structs/WorldDataStructProperties.d.ts +0 -8
  293. package/World/Structs/WorldDataStructProperties.js +0 -9
  294. /package/Mesher/Geomtry/{Buffers.d.ts → VoxelMeshBuffers.d.ts} +0 -0
  295. /package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.d.ts +0 -0
  296. /package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.js +0 -0
  297. /package/Mesher/{VoxelShaderData.d.ts → Geomtry/VoxelShaderData.d.ts} +0 -0
  298. /package/Mesher/{VoxelShaderData.js → Geomtry/VoxelShaderData.js} +0 -0
  299. /package/{World/Storage/WorldStorage.interface.js → Voxels/Cursor/DataCursor.interface.js} +0 -0
  300. /package/World/{Storage → Types}/WorldStorage.interface.d.ts +0 -0
  301. /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/DimensionSegment.js +0 -0
  302. /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorState.d.ts +0 -0
  303. /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorState.js +0 -0
  304. /package/{Tasks/IWG → WorldSimulation}/Internal/Classes/SectorVisistedMap.d.ts +0 -0
  305. /package/{Tasks/IWG → WorldSimulation}/Internal/Functions/cullSectors.d.ts +0 -0
  306. /package/{Tasks/IWG → WorldSimulation}/Internal/Functions/runWorldUpdate.d.ts +0 -0
  307. /package/{Tasks/IWG → WorldSimulation}/Procedures/SaveAllSectors.d.ts +0 -0
@@ -1,6 +1,6 @@
1
- import { IWG } from "../IWG";
2
- import { IWGDimensions } from "../Internal/IWGDimensions";
3
- import { IWGTools } from "../Internal/IWGTools";
1
+ import { WorldSimulation } from "../WorldSimulation";
2
+ import { WorldSimulationDimensions } from "../Internal/WorldSimulationDimensions";
3
+ import { WorldSimulationTools } from "../Internal/WorldSimulationTools";
4
4
  import SaveAllSectors from "./SaveAllSectors";
5
5
  /**# InitalLoad
6
6
  * ---
@@ -8,23 +8,23 @@ import SaveAllSectors from "./SaveAllSectors";
8
8
  */
9
9
  export async function InitalLoad(props) {
10
10
  return new Promise((resolve) => {
11
- const generator = IWG.createGenerator({
11
+ const generator = WorldSimulation.createGenerator({
12
12
  ...props.genData,
13
13
  building: false,
14
14
  culling: false
15
15
  });
16
- if (!IWGDimensions._dimensions.has(generator._dimension)) {
17
- IWGDimensions.addDimension(generator._dimension);
16
+ if (!WorldSimulationDimensions._dimensions.has(generator._dimension)) {
17
+ WorldSimulationDimensions.addDimension(generator._dimension);
18
18
  }
19
- const dimension = IWGDimensions.getDimension(props.dimension || "main");
19
+ const dimension = WorldSimulationDimensions.getDimension(props.dimension || 0);
20
20
  let done = false;
21
21
  generator._building = false;
22
- IWG.addGenerator(generator);
22
+ WorldSimulation.addGenerator(generator);
23
23
  let timeOut = null;
24
24
  const update = () => {
25
25
  if (done)
26
26
  return;
27
- IWG.update();
27
+ WorldSimulation.update();
28
28
  timeOut = setTimeout(update, 0);
29
29
  };
30
30
  update();
@@ -41,9 +41,9 @@ export async function InitalLoad(props) {
41
41
  done = true;
42
42
  clearInterval(inte);
43
43
  clearTimeout(timeOut);
44
- IWG.removeGenerator(generator);
44
+ WorldSimulation.removeGenerator(generator);
45
45
  (async () => {
46
- if (IWGTools.worldStorage) {
46
+ if (WorldSimulationTools.worldStorage) {
47
47
  await SaveAllSectors();
48
48
  }
49
49
  resolve(true);
@@ -1,18 +1,20 @@
1
- import { WorldRegister } from "../../../World/WorldRegister";
2
- import { IWGDimensions } from "../Internal/IWGDimensions";
3
- import { IWGTools } from "../Internal/IWGTools";
1
+ import { WorldRegister } from "../../World/WorldRegister";
2
+ import { WorldSimulationDimensions } from "../Internal/WorldSimulationDimensions";
3
+ import { WorldSimulationTools } from "../Internal/WorldSimulationTools";
4
4
  /**# Save All Sectors
5
5
  * ---
6
6
  * Save all sectors that are loaded.
7
7
  */
8
8
  export default async function SaveAllSectors() {
9
- const worldStorage = IWGTools.worldStorage;
9
+ const worldStorage = WorldSimulationTools.worldStorage;
10
10
  if (!worldStorage)
11
11
  return;
12
12
  const proms = [];
13
- for (const [dimensionId] of IWGDimensions._dimensions) {
13
+ for (const [dimensionId] of WorldSimulationDimensions._dimensions) {
14
14
  const dimension = WorldRegister.dimensions.get(dimensionId);
15
15
  for (const [key, sector] of dimension.sectors) {
16
+ if (sector.isStored())
17
+ continue;
16
18
  proms.push(worldStorage.saveSector([dimensionId, ...sector.position]));
17
19
  }
18
20
  }
@@ -1,9 +1,9 @@
1
1
  import { Thread, ThreadPool } from "@amodx/threads";
2
- import { WorldStorageInterface } from "../../World/Storage/WorldStorage.interface";
2
+ import { WorldStorageInterface } from "../World/Types/WorldStorage.interface";
3
3
  import { Generator, GeneratorData } from "./Internal/Classes/Generator";
4
4
  import { InitalLoad } from "./Procedures/InitalLoad";
5
5
  import SaveAllSectors from "./Procedures/SaveAllSectors";
6
- interface IWGInitData {
6
+ interface WorldSimulationInitData {
7
7
  parent: Thread;
8
8
  threads: Thread | ThreadPool;
9
9
  worldStorage?: WorldStorageInterface;
@@ -11,18 +11,19 @@ interface IWGInitData {
11
11
  /**# Infinite World Generation IWG
12
12
  * Object to handle the loading and generating the world around a created generator.
13
13
  */
14
- export declare class IWG {
14
+ export declare class WorldSimulation {
15
15
  private static _cullGenerators;
16
16
  static readonly _generators: Generator[];
17
- static addDimension(id: string): void;
17
+ static addDimension(id: number): void;
18
18
  static Procedures: {
19
19
  InitalLoad: typeof InitalLoad;
20
20
  SaveAllSectors: typeof SaveAllSectors;
21
21
  };
22
- static init(data: IWGInitData): void;
22
+ static init(data: WorldSimulationInitData): void;
23
23
  static createGenerator(data: Partial<GeneratorData>): Generator;
24
24
  static addGenerator(generator: Generator): void;
25
25
  static removeGenerator(generator: Generator): boolean;
26
+ static tick(): void;
26
27
  static update(): void;
27
28
  }
28
29
  export {};
@@ -1,10 +1,10 @@
1
- import { TaskTool } from "../../Tools/Tasks/TasksTool";
1
+ import { TaskTool } from "../Tools/Tasks/TasksTool";
2
2
  import { Generator } from "./Internal/Classes/Generator";
3
3
  import { runWorldUpdate } from "./Internal/Functions/runWorldUpdate";
4
- import { IWGTasks } from "./Internal/IWGTasks";
5
- import { runBuildUpdate } from "./Internal/Functions/runBuildUpdate";
6
- import { IWGTools } from "./Internal/IWGTools";
7
- import { IWGDimensions } from "./Internal/IWGDimensions";
4
+ import { WorldSimulationTasks } from "./Internal/WorldSimulationTasks";
5
+ import { runTickUpdate } from "./Internal/Functions/runTickUpdate";
6
+ import { WorldSimulationTools } from "./Internal/WorldSimulationTools";
7
+ import { WorldSimulationDimensions } from "./Internal/WorldSimulationDimensions";
8
8
  import { cullSectors } from "./Internal/Functions/cullSectors";
9
9
  import { Vector3Like } from "@amodx/math";
10
10
  import { InitalLoad } from "./Procedures/InitalLoad";
@@ -13,11 +13,11 @@ let initalized = false;
13
13
  /**# Infinite World Generation IWG
14
14
  * Object to handle the loading and generating the world around a created generator.
15
15
  */
16
- export class IWG {
16
+ export class WorldSimulation {
17
17
  static _cullGenerators = [];
18
18
  static _generators = [];
19
19
  static addDimension(id) {
20
- IWGDimensions.addDimension(id);
20
+ WorldSimulationDimensions.addDimension(id);
21
21
  }
22
22
  static Procedures = {
23
23
  InitalLoad,
@@ -25,15 +25,16 @@ export class IWG {
25
25
  };
26
26
  static init(data) {
27
27
  initalized = true;
28
- IWGTools.parent = data.parent;
29
- IWGTools.taskTool = new TaskTool(data.threads);
28
+ WorldSimulationTools.parent = data.parent;
29
+ WorldSimulationTools.taskTool = new TaskTool(data.threads);
30
30
  if (data.worldStorage)
31
- IWGTools.worldStorage = data.worldStorage;
32
- console.warn("load the thing", IWGTools.worldStorage, data.worldStorage);
31
+ WorldSimulationTools.worldStorage = data.worldStorage;
33
32
  }
34
33
  static createGenerator(data) {
35
- return new Generator({
36
- dimension: data.dimension ? data.dimension : "main",
34
+ if (!initalized)
35
+ throw new Error(`IWG must be initalized first before creating generator`);
36
+ return new Generator(WorldSimulationTools.taskTool, {
37
+ dimension: data.dimension ? data.dimension : 0,
37
38
  position: data.position ? data.position : Vector3Like.Create(),
38
39
  renderRadius: data.renderRadius ? data.renderRadius : 150,
39
40
  generationRadius: data.generationRadius ? data.generationRadius : 250,
@@ -53,6 +54,11 @@ export class IWG {
53
54
  }
54
55
  return false;
55
56
  }
57
+ static tick() {
58
+ for (const gen of this._generators) {
59
+ gen.tick();
60
+ }
61
+ }
56
62
  static update() {
57
63
  if (!initalized) {
58
64
  throw new Error(`IWG must be initalized.`);
@@ -76,17 +82,17 @@ export class IWG {
76
82
  }
77
83
  }
78
84
  }
79
- runBuildUpdate(this._generators);
80
- IWGTasks.buildTasks.runTask();
85
+ runTickUpdate(this._generators);
86
+ // IWGTasks.buildTasks.runTask();
81
87
  runWorldUpdate(this._generators);
82
- IWGTasks.worldLoadTasks.runTask();
83
- IWGTasks.worldGenTasks.runTask();
84
- IWGTasks.worldDecorateTasks.runTask();
85
- IWGTasks.worldSunTasks.runTask();
86
- IWGTasks.worldPropagationTasks.runTask();
87
- IWGTasks.saveTasks.runTask();
88
- IWGTasks.saveAndUnloadTasks.runTask();
88
+ WorldSimulationTasks.worldLoadTasks.runTask();
89
+ WorldSimulationTasks.worldGenTasks.runTask();
90
+ WorldSimulationTasks.worldDecorateTasks.runTask();
91
+ WorldSimulationTasks.worldSunTasks.runTask();
92
+ WorldSimulationTasks.worldPropagationTasks.runTask();
93
+ WorldSimulationTasks.saveTasks.runTask();
94
+ WorldSimulationTasks.saveAndUnloadTasks.runTask();
89
95
  cullSectors(this._generators, this._cullGenerators);
90
96
  }
91
97
  }
92
- IWG.addDimension("main");
98
+ WorldSimulation.addDimension(0);
@@ -1,2 +1,2 @@
1
- export * from "./IWG";
1
+ export * from "./WorldSimulation";
2
2
  export * from "./Procedures/InitalLoad";
@@ -1,2 +1,2 @@
1
- export * from "./IWG";
1
+ export * from "./WorldSimulation";
2
2
  export * from "./Procedures/InitalLoad";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@divinevoxel/vlox",
3
- "version": "0.0.72",
3
+ "version": "0.0.74",
4
4
  "description": "Vlox a block style voxel engine.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1,2 +0,0 @@
1
- import { MesherDataTool } from "../Geomtry/Tools/MesherDataTools";
2
- export declare function CompactMesh(materialId: string, tool: MesherDataTool): void;
@@ -1,42 +0,0 @@
1
- export function CompactMesh(materialId, tool) {
2
- /* let webGPU = EngineSettings.settings.rendererSettings.mode == "webgpu";
3
-
4
- const mesh = tool.mesh!;
5
- const byteRanges: [
6
- byteStart: number,
7
- length: number,
8
- type: BinaryNumberTypes,
9
- ][] = [];
10
- const dataMap: CompactSubMesh = [materialId, []];
11
- let totalSize = 0;
12
- for (let [key, [array, stride, type]] of mesh.attributes) {
13
- if (key == MeshDefaultAttributes.Indices) {
14
- if (array.length > 60_000) {
15
- type = BinaryNumberTypes.Uint32;
16
- }
17
- }
18
- let current = totalSize;
19
-
20
- totalSize += MappedByteCounts[type] * array.length;
21
- byteRanges.push([current, array.length, type]);
22
- dataMap[1].push([key, array as any, stride]);
23
- }
24
-
25
- const finalBuffer = new ArrayBuffer(totalSize);
26
-
27
- for (let i = 0; i < dataMap[1].length; i++) {
28
- const startByte = byteRanges[i][0];
29
- const length = byteRanges[i][1];
30
- const type = byteRanges[i][2];
31
- const newArray = new TypedArrayClassMap[type](
32
- finalBuffer,
33
- //@ts-ignore
34
- startByte,
35
- length
36
- ) as Float32Array;
37
- newArray.set(dataMap[1][i][0] as any as number[]);
38
- dataMap[1][i][1] = newArray;
39
- }
40
-
41
- return [0, finalBuffer, [dataMap]]; */
42
- }
@@ -1,10 +0,0 @@
1
- import type { Vec3Array } from "@amodx/math";
2
- export declare class GeometryNormals {
3
- static subtract(v1: Vec3Array, v2: Vec3Array): Vec3Array;
4
- static cross(v1: Vec3Array, v2: Vec3Array): Vec3Array;
5
- static scale(v: Vec3Array, scaleFactor: number): Vec3Array;
6
- static add(v1: Vec3Array, v2: Vec3Array): Vec3Array;
7
- static normalize(v: Vec3Array): Vec3Array;
8
- static getTriangleNormals(p1: Vec3Array, p2: Vec3Array, p3: Vec3Array): Vec3Array;
9
- static getQuadNormal(p1: Vec3Array, p2: Vec3Array, p3: Vec3Array, p4: Vec3Array): [n1: Vec3Array, n2: Vec3Array, n3: Vec3Array, n4: Vec3Array];
10
- }
@@ -1,52 +0,0 @@
1
- export class GeometryNormals {
2
- static subtract(v1, v2) {
3
- return [v1[0] - v2[0], v1[1] - v2[1], v1[2] - v2[2]];
4
- }
5
- static cross(v1, v2) {
6
- return [
7
- v1[1] * v2[2] - v1[2] * v2[1],
8
- v1[2] * v2[0] - v1[0] * v2[2],
9
- v1[0] * v2[1] - v1[1] * v2[0],
10
- ];
11
- }
12
- static scale(v, scaleFactor) {
13
- return [v[0] * scaleFactor, v[1] * scaleFactor, v[2] * scaleFactor];
14
- }
15
- static add(v1, v2) {
16
- return [v1[0] + v2[0], v1[1] + v2[1], v1[2] + v2[2]];
17
- }
18
- static normalize(v) {
19
- const length = Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
20
- return length > 0
21
- ? [v[0] / length, v[1] / length, v[2] / length]
22
- : [0, 0, 0];
23
- }
24
- static getTriangleNormals(p1, p2, p3) {
25
- const a = this.subtract(p2, p1);
26
- const b = this.subtract(p3, p1);
27
- const substract = this.cross(a, b);
28
- const normal = this.scale(substract, -1);
29
- return this.normalize(normal);
30
- }
31
- static getQuadNormal(p1, p2, p3, p4) {
32
- const vectorA1 = [p2[0] - p1[0], p2[1] - p1[1], p2[2] - p1[2]];
33
- const vectorA2 = [p3[0] - p1[0], p3[1] - p1[1], p3[2] - p1[2]];
34
- const normalA = this.normalize(this.cross(vectorA1, vectorA2));
35
- const vectorB1 = [p3[0] - p1[0], p3[1] - p1[1], p3[2] - p1[2]];
36
- const vectorB2 = [p4[0] - p1[0], p4[1] - p1[1], p4[2] - p1[2]];
37
- const normalB = this.normalize(this.cross(vectorB1, vectorB2));
38
- const n1 = this.normalize([
39
- (normalA[0] + normalB[0]) / 2,
40
- (normalA[1] + normalB[1]) / 2,
41
- (normalA[2] + normalB[2]) / 2,
42
- ]);
43
- const n2 = normalA;
44
- const n3 = this.normalize([
45
- (normalA[0] + normalB[0]) / 2,
46
- (normalA[1] + normalB[1]) / 2,
47
- (normalA[2] + normalB[2]) / 2,
48
- ]);
49
- const n4 = normalB;
50
- return [n1, n2, n3, n4];
51
- }
52
- }
@@ -1,13 +0,0 @@
1
- import type { TypedArrays } from "@amodx/binary";
2
- export declare enum MeshDefaultAttributes {
3
- Position = "position",
4
- Normal = "normal",
5
- Indices = "indices"
6
- }
7
- export type MeshAttributes = [
8
- id: string,
9
- data: TypedArrays,
10
- stride: number,
11
- componentTypes?: number,
12
- noramlizer?: number
13
- ][];
@@ -1,6 +0,0 @@
1
- export var MeshDefaultAttributes;
2
- (function (MeshDefaultAttributes) {
3
- MeshDefaultAttributes["Position"] = "position";
4
- MeshDefaultAttributes["Normal"] = "normal";
5
- MeshDefaultAttributes["Indices"] = "indices";
6
- })(MeshDefaultAttributes || (MeshDefaultAttributes = {}));
@@ -1,7 +0,0 @@
1
- import { VoxelMesh } from "../VoxelMesh.js";
2
- export declare class MesherDataTool {
3
- segments: Map<string, number[]>;
4
- mesh: VoxelMesh | null;
5
- startNewMesh(mesh?: VoxelMesh): void;
6
- clear(): this;
7
- }
@@ -1,12 +0,0 @@
1
- import { VoxelMesh } from "../VoxelMesh.js";
2
- export class MesherDataTool {
3
- segments = new Map();
4
- mesh = null;
5
- startNewMesh(mesh) {
6
- this.mesh = mesh ? mesh : new VoxelMesh();
7
- }
8
- clear() {
9
- this.mesh?.clear();
10
- return this;
11
- }
12
- }
@@ -1 +0,0 @@
1
- export * from "./MesherDataTools.js";
@@ -1 +0,0 @@
1
- export * from "./MesherDataTools.js";
@@ -1,6 +0,0 @@
1
- import { VoxelMesherDataTool } from "./Tools/VoxelMesherDataTool";
2
- export declare class RenderedMaterials {
3
- static meshersMap: Map<string, VoxelMesherDataTool>;
4
- static meshers: VoxelMesherDataTool[];
5
- static register(materials: string[]): void;
6
- }
@@ -1,216 +0,0 @@
1
- import { WorldSpaces } from "../../World/WorldSpaces";
2
- const MAX_FLOAT32 = new Float32Array([Infinity])[0];
3
- /**
4
- * A class to help with indexing a full flat binary tree defined by the number of levels it has.
5
- */
6
- class FlatBinaryTreeIndex {
7
- levels;
8
- constructor(levels) {
9
- this.levels = levels;
10
- }
11
- /** Gets the number of nodes at a level of the tree */
12
- getLevelSize(level) {
13
- if (level < 0 || level >= this.levels) {
14
- throw new Error("Invalid level");
15
- }
16
- return 1 << level; // Equivalent to 2^level
17
- }
18
- /**
19
- * Gets the flat index of a node indexed by the level it's on and its relative index in that level.
20
- */
21
- getIndexAtLevel(level, node) {
22
- if (level < 0 || level >= this.levels) {
23
- throw new Error("Invalid level");
24
- }
25
- const levelSize = this.getLevelSize(level);
26
- if (node < 0 || node >= levelSize) {
27
- throw new Error("Invalid node index at the given level");
28
- }
29
- return (1 << level) - 1 + node;
30
- }
31
- /**
32
- * Gets the level and relative index of a node's flat index.
33
- */
34
- getLevelAndIndex(index) {
35
- const totalNodes = (1 << this.levels) - 1;
36
- if (index < 0 || index >= totalNodes) {
37
- throw new Error("Invalid node index");
38
- }
39
- const level = Math.floor(Math.log2(index + 1));
40
- const firstIndexAtLevel = (1 << level) - 1;
41
- const relativeIndex = index - firstIndexAtLevel;
42
- return [level, relativeIndex];
43
- }
44
- /**
45
- * Gets the flat left child of a node, where the node is indexed by its level and its relative index at that level.
46
- * @returns -1 if no child exist
47
- */
48
- getLeftChildAtLevel(level, node) {
49
- if (level + 1 >= this.levels) {
50
- return -1;
51
- }
52
- const nodeIndex = this.getIndexAtLevel(level, node);
53
- return this.getLeftChild(nodeIndex);
54
- }
55
- /**
56
- * Gets the flat right child of a node, where the node is indexed by its level and its relative index at that level.
57
- * @returns -1 if no child exist
58
- */
59
- getRightChildAtLevel(level, node) {
60
- if (level + 1 >= this.levels) {
61
- return -1;
62
- }
63
- const nodeIndex = this.getIndexAtLevel(level, node);
64
- return this.getRightChild(nodeIndex);
65
- }
66
- /**
67
- * Gets the flat index of the parent of a node, where the node is indexed by its level and its relative index at that level.
68
- * @returns -1 if level has no parent
69
- */
70
- getParentAtLevel(level, node) {
71
- if (level === 0) {
72
- return -1;
73
- }
74
- const nodeIndex = this.getIndexAtLevel(level, node);
75
- return this.getParent(nodeIndex);
76
- }
77
- /** Gets the flat index of the left child of the node.
78
- * @returns -1 if no child exist
79
- */
80
- getLeftChild(node) {
81
- const leftChildIndex = 2 * node + 1;
82
- const totalNodes = (1 << this.levels) - 1;
83
- return leftChildIndex < totalNodes ? leftChildIndex : -1;
84
- }
85
- /** Gets the flat index of the right child of the node.
86
- * @returns -1 if no child exist
87
- */
88
- getRightChild(node) {
89
- const rightChildIndex = 2 * node + 2;
90
- const totalNodes = (1 << this.levels) - 1;
91
- return rightChildIndex < totalNodes ? rightChildIndex : -1;
92
- }
93
- /** Gets the flat index of the parent of the node.
94
- * @returns -1 if no parent exist
95
- */
96
- getParent(node) {
97
- if (node === 0) {
98
- return -1; // Root node has no parent
99
- }
100
- return Math.floor((node - 1) / 2);
101
- }
102
- /** Gets the total number of nodes in the tree */
103
- getTotalSize() {
104
- return (1 << this.levels) - 1; // Equivalent to 2^levels - 1
105
- }
106
- }
107
- export class StructCursor {
108
- data;
109
- get minX() {
110
- return this.data[this.trueIndex];
111
- }
112
- get minY() {
113
- return this.data[this.trueIndex + 1];
114
- }
115
- get minZ() {
116
- return this.data[this.trueIndex + 2];
117
- }
118
- get maxX() {
119
- return this.data[this.trueIndex + 4];
120
- }
121
- get maxY() {
122
- return this.data[this.trueIndex + 5];
123
- }
124
- get maxZ() {
125
- return this.data[this.trueIndex + 6];
126
- }
127
- get voxelIndex() {
128
- return this.data[this.trueIndex + 3];
129
- }
130
- get active() {
131
- return this.data[this.trueIndex + 3];
132
- }
133
- get nodeType() {
134
- return this.data[this.trueIndex + 7];
135
- }
136
- trueIndex = 0;
137
- index = 0;
138
- setIndex(index) {
139
- this.trueIndex = index * 8;
140
- }
141
- constructor(data) {
142
- this.data = data;
143
- }
144
- setActive() {
145
- this.data[this.trueIndex + 3] = 1;
146
- }
147
- setVoxelIndex(value) {
148
- this.data[this.trueIndex + 3] = value;
149
- }
150
- setInnerNode() {
151
- this.data[this.trueIndex + 7] = 1;
152
- }
153
- setGeomtryNode() {
154
- this.data[this.trueIndex + 7] = 2;
155
- }
156
- updateMin(x, y, z) {
157
- const ix = this.trueIndex;
158
- const iy = this.trueIndex + 1;
159
- const iz = this.trueIndex + 2;
160
- if (x < this.data[ix] || this.data[ix] == -MAX_FLOAT32) {
161
- this.data[ix] = x;
162
- }
163
- if (y < this.data[iy] || this.data[iy] == -MAX_FLOAT32) {
164
- this.data[iy] = y;
165
- }
166
- if (z < this.data[iz] || this.data[iz] == -MAX_FLOAT32) {
167
- this.data[iz] = z;
168
- }
169
- }
170
- updateMax(x, y, z) {
171
- const ix = this.trueIndex + 4;
172
- const iy = this.trueIndex + 5;
173
- const iz = this.trueIndex + 6;
174
- if (x > this.data[ix] || this.data[ix] == -MAX_FLOAT32) {
175
- this.data[ix] = x;
176
- }
177
- if (y > this.data[iy] || this.data[iy] == -MAX_FLOAT32) {
178
- this.data[iy] = y;
179
- }
180
- if (z > this.data[iz] || this.data[iz] == -MAX_FLOAT32) {
181
- this.data[iz] = z;
182
- }
183
- }
184
- }
185
- export class VoxelMeshBVHBuilder {
186
- static AABBStructByteSize = (4 + 4) * 4;
187
- treeIndex = new FlatBinaryTreeIndex(13);
188
- tree = new Float32Array(new ArrayBuffer(this.treeIndex.getTotalSize() * VoxelMeshBVHBuilder.AABBStructByteSize));
189
- structCursor = new StructCursor(this.tree);
190
- indices = new Uint32Array(this.treeIndex.getLevelSize(12) * 2);
191
- reset() {
192
- this.tree.fill(-MAX_FLOAT32);
193
- this.indices.fill(0);
194
- }
195
- updateVoxel(voxelX, voxelY, voxelZ, meshIndex, indicesStart, indicesEnd, minX, minY, minZ, maxX, maxY, maxZ) {
196
- const voxelIndex = WorldSpaces.voxel.getIndex(voxelX, voxelY, voxelZ);
197
- const leafIndex = this.treeIndex.getIndexAtLevel(12, voxelIndex);
198
- this.indices[voxelIndex * 2] = indicesStart;
199
- this.indices[voxelIndex * 2 + 1] = indicesEnd;
200
- this.structCursor.setIndex(leafIndex);
201
- this.structCursor.updateMin(minX, minY, minZ);
202
- this.structCursor.updateMax(maxX, maxY, maxZ);
203
- this.structCursor.setVoxelIndex(voxelIndex);
204
- this.structCursor.setGeomtryNode();
205
- let current = leafIndex;
206
- for (let level = 1; level < 13; level++) {
207
- let parentNode = this.treeIndex.getParent(current);
208
- this.structCursor.setIndex(parentNode);
209
- this.structCursor.updateMin(minX, minY, minZ);
210
- this.structCursor.updateMax(maxX, maxY, maxZ);
211
- this.structCursor.setActive();
212
- this.structCursor.setInnerNode();
213
- current = parentNode;
214
- }
215
- }
216
- }