@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
@@ -9,7 +9,7 @@ class Sectors {
9
9
  location[0],
10
10
  ...WorldSpaces.sector.getPositionVec3Array(location[1], location[2], location[3]),
11
11
  ]);
12
- dimension.set(WorldSpaces.hash.hashXYZ(location[1], location[2], location[3]), sector);
12
+ dimension.set(WorldSpaces.hash.hashVec3(WorldSpaces.sector.getPosition(location[1], location[2], location[3])), sector);
13
13
  return sector;
14
14
  }
15
15
  static remove(location) {
@@ -79,7 +79,7 @@ class Dimensions {
79
79
  }
80
80
  }
81
81
  export class MeshRegister {
82
- static _dimensions = new Map([["main", new Map()]]);
82
+ static _dimensions = new Map([[0, new Map()]]);
83
83
  static dimensions = Dimensions;
84
84
  static sectors = Sectors;
85
85
  static clearAll() {
@@ -87,6 +87,7 @@ export class MeshRegister {
87
87
  this.dimensions.remove(dkey);
88
88
  }
89
89
  this._dimensions.clear();
90
- this._dimensions.set("main", new Map());
90
+ this._dimensions.set(0, new Map());
91
91
  }
92
92
  }
93
+ window.MeshRegister = MeshRegister;
@@ -12,11 +12,12 @@ type EngineSettingsEvents = {
12
12
  declare class EngineSettingsClass extends TypedEventTarget<EngineSettingsEvents> {
13
13
  enviorment: "node" | "browser";
14
14
  settings: EngineSettingsData;
15
+ version: string;
15
16
  get doSunPropagation(): boolean;
16
17
  get doRGBPropagation(): boolean;
17
18
  get doLight(): boolean;
18
19
  get doFlow(): boolean;
19
- get isClient(): boolean;
20
+ get doPower(): boolean;
20
21
  getSettings(): EngineSettingsData;
21
22
  syncSettings(data: EngineSettingsData): void;
22
23
  getSettingsCopy(): any;
@@ -8,20 +8,21 @@ import { TypedEventTarget } from "../Util/TypedEventTarget.js";
8
8
  class EngineSettingsClass extends TypedEventTarget {
9
9
  enviorment = Environment.isNode() ? "node" : "browser";
10
10
  settings = new EngineSettingsData();
11
+ version = "0.0.72";
11
12
  get doSunPropagation() {
12
- return this.settings.lighting.autoSunLight == true;
13
+ return this.settings.propagation.sunLightEnabled == true;
13
14
  }
14
15
  get doRGBPropagation() {
15
- return this.settings.lighting.autoRGBLight == true;
16
+ return this.settings.propagation.rgbLightEnabled == true;
16
17
  }
17
18
  get doLight() {
18
19
  return this.doRGBPropagation || this.doSunPropagation;
19
20
  }
20
21
  get doFlow() {
21
- return this.settings.flow.enable;
22
+ return this.settings.propagation.flowEnabled;
22
23
  }
23
- get isClient() {
24
- return this.enviorment != "browser";
24
+ get doPower() {
25
+ return this.settings.propagation.powerEnabled;
25
26
  }
26
27
  getSettings() {
27
28
  return this.settings;
@@ -1,18 +1,27 @@
1
1
  import { Vector3Like } from "@amodx/math";
2
+ export interface MesherSettingsData {
3
+ }
4
+ export declare class MesherSettingsData {
5
+ /**Tell the mesher to shade voxel faces with sun light data. Disable if you are using a custom renderering pipeline. */
6
+ doSunLight: boolean;
7
+ /**Tell the mesher to use the built in AO system. Disable if you are using a custom renderering pipeline. */
8
+ doAO: boolean;
9
+ doColors: boolean;
10
+ }
2
11
  export interface RenderSettingsData {
3
12
  }
4
13
  export declare class RenderSettingsData {
14
+ /**Set the mode to change how mesh data is generated based on the underlying rendering API. */
5
15
  mode: "webgl" | "webgpu";
16
+ /**If set to try the engine will not try to send vertex buffers to woerks for GC. */
6
17
  cpuBound: boolean;
7
18
  }
8
- export interface TextureSettings {
9
- }
10
- export declare class TextureSettings {
11
- textureSize: number;
12
- }
13
19
  export interface UpdatingSettings {
14
20
  }
15
21
  export declare class UpdatingSettings {
22
+ /**Sector sections are marked as dirty so they can be processed later. */
23
+ dirtyMechanism: boolean;
24
+ /**Updated sector sections are auto rebuilt */
16
25
  autoRebuild: boolean;
17
26
  }
18
27
  export interface WorldSettings {
@@ -20,45 +29,21 @@ export interface WorldSettings {
20
29
  export declare class WorldSettings {
21
30
  min: Vector3Like;
22
31
  max: Vector3Like;
32
+ sectorPower2Size: Vector3Like;
33
+ sectionPower2Size: Vector3Like;
23
34
  }
24
- export interface SectorSettings {
25
- }
26
- export declare class SectorSettings {
27
- power2Size: Vector3Like;
28
- }
29
- export interface SectionSettings {
35
+ export interface PropagationSettings {
30
36
  }
31
- export declare class SectionSettings {
32
- power2Size: Vector3Like;
33
- }
34
- export interface VoxelSettings {
35
- }
36
- export declare class VoxelSettings {
37
- doColors: boolean;
38
- }
39
- export interface FlowSettings {
40
- }
41
- export declare class FlowSettings {
42
- enable: boolean;
43
- baseFlowLimit: number;
44
- }
45
- export interface LightingSettings {
46
- }
47
- export declare class LightingSettings {
48
- doAO: boolean;
49
- doSunLight: boolean;
50
- doRGBLight: boolean;
51
- autoRGBLight: boolean;
52
- autoSunLight: boolean;
37
+ export declare class PropagationSettings {
38
+ rgbLightEnabled: boolean;
39
+ sunLightEnabled: boolean;
40
+ flowEnabled: boolean;
41
+ powerEnabled: boolean;
53
42
  }
54
43
  export declare class EngineSettingsData {
44
+ mesher: MesherSettingsData;
55
45
  rendererSettings: RenderSettingsData;
56
- textures: TextureSettings;
57
46
  updating: UpdatingSettings;
58
47
  world: WorldSettings;
59
- sectors: SectorSettings;
60
- sections: SectionSettings;
61
- voxels: VoxelSettings;
62
- flow: FlowSettings;
63
- lighting: LightingSettings;
48
+ propagation: PropagationSettings;
64
49
  }
@@ -1,46 +1,39 @@
1
1
  import { Vector3Like } from "@amodx/math";
2
+ export class MesherSettingsData {
3
+ /**Tell the mesher to shade voxel faces with sun light data. Disable if you are using a custom renderering pipeline. */
4
+ doSunLight = true;
5
+ /**Tell the mesher to use the built in AO system. Disable if you are using a custom renderering pipeline. */
6
+ doAO = true;
7
+ doColors = true;
8
+ }
2
9
  export class RenderSettingsData {
10
+ /**Set the mode to change how mesh data is generated based on the underlying rendering API. */
3
11
  mode = "webgl";
12
+ /**If set to try the engine will not try to send vertex buffers to woerks for GC. */
4
13
  cpuBound = false;
5
14
  }
6
- export class TextureSettings {
7
- textureSize = 16;
8
- }
9
15
  export class UpdatingSettings {
10
- autoRebuild = true;
16
+ /**Sector sections are marked as dirty so they can be processed later. */
17
+ dirtyMechanism = true;
18
+ /**Updated sector sections are auto rebuilt */
19
+ autoRebuild = false;
11
20
  }
12
21
  export class WorldSettings {
13
22
  min = Vector3Like.Create(-Number.MAX_SAFE_INTEGER, 0, -Number.MAX_SAFE_INTEGER);
14
23
  max = Vector3Like.Create(Number.MAX_SAFE_INTEGER, 256, Number.MAX_SAFE_INTEGER);
24
+ sectorPower2Size = Vector3Like.Create(4, 8, 4);
25
+ sectionPower2Size = Vector3Like.Create(4, 4, 4);
15
26
  }
16
- export class SectorSettings {
17
- power2Size = Vector3Like.Create(4, 8, 4);
18
- }
19
- export class SectionSettings {
20
- power2Size = Vector3Like.Create(4, 4, 4);
21
- }
22
- export class VoxelSettings {
23
- doColors = true;
24
- }
25
- export class FlowSettings {
26
- enable = true;
27
- baseFlowLimit = 200;
28
- }
29
- export class LightingSettings {
30
- doAO = true;
31
- doSunLight = true;
32
- doRGBLight = true;
33
- autoRGBLight = true;
34
- autoSunLight = true;
27
+ export class PropagationSettings {
28
+ rgbLightEnabled = true;
29
+ sunLightEnabled = true;
30
+ flowEnabled = true;
31
+ powerEnabled = true;
35
32
  }
36
33
  export class EngineSettingsData {
34
+ mesher = new MesherSettingsData();
37
35
  rendererSettings = new RenderSettingsData();
38
- textures = new TextureSettings();
39
36
  updating = new UpdatingSettings();
40
37
  world = new WorldSettings();
41
- sectors = new SectorSettings();
42
- sections = new SectionSettings();
43
- voxels = new VoxelSettings();
44
- flow = new FlowSettings();
45
- lighting = new LightingSettings();
38
+ propagation = new PropagationSettings();
46
39
  }
@@ -0,0 +1 @@
1
+ export default function (): void;
@@ -0,0 +1,10 @@
1
+ import { Threads } from "@amodx/threads";
2
+ import { TasksIds } from "../TasksIds";
3
+ import { VoxelUpdateTask } from "../VoxelUpdateTask";
4
+ import { VoxelLogicUpdate } from "./VoxelLogicUpdate";
5
+ export default function () {
6
+ const tasks = new VoxelUpdateTask();
7
+ Threads.registerTask(TasksIds.LogicUpdate, async (data, origin) => {
8
+ VoxelLogicUpdate(tasks, data);
9
+ });
10
+ }
@@ -0,0 +1,3 @@
1
+ import { LocationData } from "../../Math";
2
+ import { VoxelUpdateTask } from "../../Tasks/VoxelUpdateTask";
3
+ export declare function VoxelLogicUpdate(task: VoxelUpdateTask, location: LocationData): false | undefined;
@@ -0,0 +1,71 @@
1
+ import { WorldRegister } from "../../World/WorldRegister";
2
+ import { WorldSpaces } from "../../World/WorldSpaces";
3
+ import { SectionCursor } from "../../World/Cursor/SectionCursor";
4
+ import { VoxelLogicRegister } from "../../Voxels/Logic/VoxelLogicRegister";
5
+ import { VoxelTagIds } from "../../Voxels/Data/VoxelTag.types";
6
+ import { RGBRemove, RGBUpdate } from "../../Tasks/Propagation";
7
+ import { $3dCardinalNeighbors } from "../../Math/CardinalNeighbors";
8
+ const sectionCursor = new SectionCursor();
9
+ export function VoxelLogicUpdate(task, location) {
10
+ task.setOrigin(location);
11
+ const sector = WorldRegister.sectors.getAt(location);
12
+ if (!sector) {
13
+ console.warn(`Could not run logic update sector at ${location} does not exist`);
14
+ return false;
15
+ }
16
+ const section = sector.getSection(location[1], location[2], location[3]);
17
+ if (!section) {
18
+ console.warn(`Could not run logic update sector at ${location}. Section does not exist`);
19
+ return false;
20
+ }
21
+ const [minY, maxY] = section.getLogicMinMax();
22
+ const [cx, cy, cz] = section.position;
23
+ const slice = WorldSpaces.section.bounds.x * WorldSpaces.section.bounds.z;
24
+ const startY = minY * slice;
25
+ const endY = (maxY + 1) * slice;
26
+ sectionCursor.setSection(section);
27
+ for (let i = startY; i < endY; i++) {
28
+ if (!(i % slice)) {
29
+ const y = i / slice;
30
+ if (!section.isLogicSliceDirty(y)) {
31
+ i += slice - 1;
32
+ continue;
33
+ }
34
+ }
35
+ if (!section.ids[i] || !section.getVoxelLogicDirty(i))
36
+ continue;
37
+ const voxel = sectionCursor.getVoxelAtIndex(i);
38
+ const x = cx + sectionCursor._voxelPosition.x;
39
+ const y = cy + sectionCursor._voxelPosition.y;
40
+ const z = cz + sectionCursor._voxelPosition.z;
41
+ const logic = VoxelLogicRegister.voxels[section.ids[i]];
42
+ if (!logic)
43
+ continue;
44
+ if (logic.hasTag(VoxelTagIds.isLightSource)) {
45
+ const lightSource = logic.getTagValue(VoxelTagIds.isLightSource, voxel);
46
+ if (lightSource) {
47
+ task.rgb.update.push(x, y, z);
48
+ }
49
+ else {
50
+ for (const n of $3dCardinalNeighbors) {
51
+ const nx = n[0] + x;
52
+ const ny = n[1] + y;
53
+ const nz = n[2] + z;
54
+ const nVoxel = task.nDataCursor.getVoxel(nx, ny, nz);
55
+ if (!nVoxel)
56
+ continue;
57
+ if (nVoxel.hasRGBLight()) {
58
+ task.rgb.remove.push(nx, ny, nz);
59
+ }
60
+ }
61
+ }
62
+ }
63
+ }
64
+ RGBRemove(task);
65
+ RGBUpdate(task);
66
+ section.logicDirtyMap.fill(0);
67
+ section.logicDirty.fill(0);
68
+ section.setLogicDirty(false);
69
+ section.setLogicUpdateInProgress(false);
70
+ task.bounds.markSectionsAsDirty();
71
+ }
@@ -1,4 +1,4 @@
1
- import { UpdateTask } from "../../Update/UpdateTask.js";
1
+ import { VoxelUpdateTask } from "../../VoxelUpdateTask.js";
2
2
  export declare const ExplosionManager: {
3
- runExplosion(tasks: UpdateTask, radius: number): void;
3
+ runExplosion(tasks: VoxelUpdateTask, radius: number): void;
4
4
  };
@@ -5,14 +5,13 @@ import { $3dCardinalNeighbors } from "../../../Math/CardinalNeighbors.js";
5
5
  import { Distance3D } from "@amodx/math/Vectors/Functions/Distance3d";
6
6
  import { RGBRemove, RGBUpdate } from "../Illumanation/RGBUpdate.js";
7
7
  import { SunRemove, SunUpdate } from "../Illumanation/SunUpdate.js";
8
- import { FlowManager } from "../Flow/FlowManager.js";
9
8
  import { VisitedMap } from "../../../Util/VisistedMap";
10
9
  import { VoxelLightData } from "../../../Voxels/Cursor/VoxelLightData.js";
11
10
  const lightData = new VoxelLightData();
12
11
  export const ExplosionManager = {
13
12
  runExplosion(tasks, radius) {
14
13
  const [dimension, sx, sy, sz] = tasks.origin;
15
- FlowManager.setDimension(dimension);
14
+ // FlowManager.setDimension(dimension);
16
15
  const queue = [];
17
16
  const map = new VisitedMap();
18
17
  queue.push([sx, sy, sz]);
@@ -1,13 +1,13 @@
1
1
  import { BrushTool } from "../../../Tools/Brush/Brush.js";
2
- import { UpdateTask } from "../../Update/UpdateTask.js";
2
+ import { VoxelUpdateTask } from "../../VoxelUpdateTask.js";
3
3
  import { WorldCursor } from "../../../World/index.js";
4
4
  export declare class FlowManager {
5
5
  static _brush: BrushTool;
6
6
  static _sDataTool: WorldCursor;
7
7
  static _nDataTool: WorldCursor;
8
- static setVoxel(tasks: UpdateTask, vox: string, level: number, levelState: number, x: number, y: number, z: number): void;
8
+ static setVoxel(tasks: VoxelUpdateTask, vox: string, level: number, levelState: number, x: number, y: number, z: number): void;
9
9
  static setDimension(dimension: string): void;
10
- static removeVoxel(tasks: UpdateTask, x: number, y: number, z: number): void;
10
+ static removeVoxel(tasks: VoxelUpdateTask, x: number, y: number, z: number): void;
11
11
  static getFlowRate(substance: string): number;
12
12
  static getVoxel(x: number, y: number, z: number): WorldCursor;
13
13
  static setLevel(level: number, x: number, y: number, z: number): void;
@@ -18,5 +18,5 @@ export declare class FlowManager {
18
18
  static wait(ms: number): Promise<unknown>;
19
19
  static _lightValues: [s: number, r: number, g: number, b: number];
20
20
  static getAbsorbLight(x: number, y: number, z: number): void;
21
- static sunCheck(tasks: UpdateTask, x: number, y: number, z: number): void;
21
+ static sunCheck(tasks: VoxelUpdateTask, x: number, y: number, z: number): void;
22
22
  }
@@ -1,2 +1,2 @@
1
- import { UpdateTask } from "../../Update/UpdateTask.js";
2
- export declare function FlowRemove(tasks: UpdateTask): Promise<void>;
1
+ import { VoxelUpdateTask } from "../../VoxelUpdateTask.js";
2
+ export declare function FlowRemove(tasks: VoxelUpdateTask): Promise<void>;
@@ -1,2 +1,2 @@
1
- import { UpdateTask } from "../../Update/UpdateTask.js";
2
- export declare function FlowUpdate(tasks: UpdateTask, rebuild?: boolean): Promise<void>;
1
+ import { VoxelUpdateTask } from "../../VoxelUpdateTask.js";
2
+ export declare function FlowUpdate(tasks: VoxelUpdateTask, rebuild?: boolean): Promise<void>;
@@ -1,2 +1,2 @@
1
- import { UpdateTask } from "../../../Tasks/Update/UpdateTask";
2
- export declare function WorldFlow(task: UpdateTask): false | undefined;
1
+ import { VoxelUpdateTask } from "../../VoxelUpdateTask";
2
+ export declare function WorldFlow(task: VoxelUpdateTask): false | undefined;
@@ -1,3 +1,3 @@
1
- import { UpdateTask } from "../../Update/UpdateTask";
2
- export declare function RGBUpdate(tasks: UpdateTask): void;
3
- export declare function RGBRemove(tasks: UpdateTask): void;
1
+ import { VoxelUpdateTask } from "../../VoxelUpdateTask";
2
+ export declare function RGBUpdate(tasks: VoxelUpdateTask): void;
3
+ export declare function RGBRemove(tasks: VoxelUpdateTask): void;
@@ -1,3 +1,3 @@
1
- import { UpdateTask } from "../../Update/UpdateTask";
2
- export declare function SunUpdate(tasks: UpdateTask): void;
3
- export declare function SunRemove(tasks: UpdateTask, clearUpdateMap?: boolean): void;
1
+ import { VoxelUpdateTask } from "../../VoxelUpdateTask";
2
+ export declare function SunUpdate(tasks: VoxelUpdateTask): void;
3
+ export declare function SunRemove(tasks: VoxelUpdateTask, clearUpdateMap?: boolean): void;
@@ -1,2 +1,2 @@
1
- import { UpdateTask } from "../../../Tasks/Update/UpdateTask";
2
- export declare function WorldRGB(task: UpdateTask): false | undefined;
1
+ import { VoxelUpdateTask } from "../../VoxelUpdateTask";
2
+ export declare function WorldRGB(task: VoxelUpdateTask): false | undefined;
@@ -1,2 +1,2 @@
1
- import { UpdateTask } from "../../Update/UpdateTask.js";
2
- export declare function RunWorldSun(tasks: UpdateTask): void;
1
+ import { VoxelUpdateTask } from "../../VoxelUpdateTask.js";
2
+ export declare function RunWorldSun(tasks: VoxelUpdateTask): void;
@@ -1,5 +1,3 @@
1
- //types
2
- //data
3
1
  import { $3dCardinalNeighbors } from "../../../Math/CardinalNeighbors.js";
4
2
  import { WorldSpaces } from "../../../World/WorldSpaces.js";
5
3
  import { SectorHeightMap } from "../../../World/Sector/SectorHeightMap.js";
@@ -15,11 +13,11 @@ const FloodOutPositions = [
15
13
  const queue = [];
16
14
  const lightData = new VoxelLightData();
17
15
  export function RunWorldSun(tasks) {
18
- const [dimension, cx, cy, cz] = tasks.origin;
16
+ const [, cx, cy, cz] = tasks.origin;
19
17
  const RmaxY = SectorHeightMap.getRelative(tasks.origin);
20
18
  const AmaxY = SectorHeightMap.getAbsolute(tasks.origin);
21
19
  const maxX = cx + WorldSpaces.sector.bounds.x;
22
- const maxY = WorldSpaces.world.bounds.MaxY;
20
+ const maxY = cy + WorldSpaces.sector.bounds.y;
23
21
  const maxZ = cz + WorldSpaces.sector.bounds.z;
24
22
  const sectorCursor = tasks.nDataCursor.getSector(tasks.origin[1], tasks.origin[2], tasks.origin[3]);
25
23
  if (!sectorCursor) {
@@ -29,7 +27,7 @@ export function RunWorldSun(tasks) {
29
27
  const minY = AmaxY - 1 < 0 ? 0 : AmaxY;
30
28
  const section = sectorCursor.getSection(cx, minY, cz);
31
29
  const sectionY = section.getPosition()[1] + WorldSpaces.section.bounds.y;
32
- //fill
30
+ //fill to relative max y
33
31
  for (let iy = minY; iy < sectionY; iy++) {
34
32
  for (let ix = cx; ix < maxX; ix++) {
35
33
  for (let iz = cz; iz < maxZ; iz++) {
@@ -43,6 +41,7 @@ export function RunWorldSun(tasks) {
43
41
  }
44
42
  }
45
43
  }
44
+ //fill rest
46
45
  for (let iy = sectionY; iy < maxY; iy += WorldSpaces.section.bounds.y) {
47
46
  const section = sectorCursor.getSection(cx, iy, cz);
48
47
  const length = section.light.length;
@@ -50,9 +49,9 @@ export function RunWorldSun(tasks) {
50
49
  section.light[i] = lightData.setS(0xf, section.light[i]);
51
50
  }
52
51
  }
52
+ //accumulate
53
53
  const maxAcculamteY = AmaxY == RmaxY ? RmaxY + 1 : RmaxY;
54
54
  let index = queue.length;
55
- //accumulate
56
55
  for (let iy = minY; iy <= maxAcculamteY; iy++) {
57
56
  for (let ix = cx; ix < maxX; ix++) {
58
57
  for (let iz = cz; iz < maxZ; iz++) {
@@ -94,9 +93,7 @@ export function RunWorldSun(tasks) {
94
93
  if (nVoxel) {
95
94
  const nl = nVoxel.getLight();
96
95
  if (nl > -1 && isLessThanForSunAdd(nl, sl)) {
97
- queue.push(nx);
98
- queue.push(ny);
99
- queue.push(nz);
96
+ queue.push(nx, ny, nz);
100
97
  nVoxel.setLight(getMinusOneForSun(sl, nl));
101
98
  }
102
99
  }
@@ -106,16 +103,12 @@ export function RunWorldSun(tasks) {
106
103
  const nl = nVoxel.getLight();
107
104
  if (nl > -1 && isLessThanForSunAddDown(nl, sl)) {
108
105
  if (nVoxel.isAir()) {
109
- queue.push(x);
110
- queue.push(y - 1);
111
- queue.push(z);
106
+ queue.push(x, y - 1, z);
112
107
  nVoxel.setLight(getSunLightForUnderVoxel(sl, nl));
113
108
  }
114
109
  else {
115
110
  if (!nVoxel.isOpaque()) {
116
- queue.push(x);
117
- queue.push(y - 1);
118
- queue.push(z);
111
+ queue.push(x, y - 1, z);
119
112
  nVoxel.setLight(getMinusOneForSun(sl, nl));
120
113
  }
121
114
  }
@@ -1,13 +1,13 @@
1
1
  import { Threads } from "@amodx/threads";
2
2
  import { TasksIds } from "../TasksIds";
3
- import { UpdateTask } from "../Update/UpdateTask";
3
+ import { VoxelUpdateTask } from "../VoxelUpdateTask";
4
4
  import { WorldSpaces } from "../../World/WorldSpaces";
5
5
  import { RunWorldSun } from "./Illumanation/WorldSun";
6
6
  import { ExplosionManager } from "./Explosion/ExplosionManager";
7
7
  import { WorldRGB } from "./Illumanation/WorldRGB";
8
8
  export default function InitTasks() {
9
9
  Threads.registerTask(TasksIds.Propagation, async (location) => {
10
- const task = new UpdateTask();
10
+ const task = new VoxelUpdateTask();
11
11
  task.setOrigin(location);
12
12
  WorldRGB(task);
13
13
  // task.setOrigin(location);
@@ -16,7 +16,7 @@ export default function InitTasks() {
16
16
  Threads.registerTask(TasksIds.Explosion, async (data) => {
17
17
  const location = data[0];
18
18
  const sectorPosition = WorldSpaces.sector.getPosition(location[1], location[2], location[3]);
19
- const task = new UpdateTask();
19
+ const task = new VoxelUpdateTask();
20
20
  task.setOrigin([
21
21
  location[0],
22
22
  sectorPosition.x,
@@ -27,7 +27,7 @@ export default function InitTasks() {
27
27
  });
28
28
  Threads.registerTask(TasksIds.WorldSun, (location) => {
29
29
  const sectorPosition = WorldSpaces.sector.getPosition(location[1], location[2], location[3]);
30
- const task = new UpdateTask();
30
+ const task = new VoxelUpdateTask();
31
31
  task.setOrigin([
32
32
  location[0],
33
33
  sectorPosition.x,
@@ -0,0 +1,3 @@
1
+ import { VoxelUpdateTask } from "../../VoxelUpdateTask";
2
+ export declare function PowerUpdate(tasks: VoxelUpdateTask): void;
3
+ export declare function PowerRemove(tasks: VoxelUpdateTask): void;
@@ -0,0 +1,80 @@
1
+ import { $3dCardinalNeighbors } from "../../../Math/CardinalNeighbors";
2
+ //@todo change array to not use push and shift
3
+ export function PowerUpdate(tasks) {
4
+ const queue = tasks.power.update;
5
+ while (queue.length) {
6
+ const x = queue.shift();
7
+ const y = queue.shift();
8
+ const z = queue.shift();
9
+ const voxel = tasks.sDataCursor.getVoxel(x, y, z);
10
+ if (!voxel)
11
+ continue;
12
+ const sl = voxel.getPower();
13
+ if (sl <= 0)
14
+ continue;
15
+ for (let i = 0; i < 6; i++) {
16
+ const nx = $3dCardinalNeighbors[i][0] + x;
17
+ const ny = $3dCardinalNeighbors[i][1] + y;
18
+ const nz = $3dCardinalNeighbors[i][2] + z;
19
+ if (!tasks.nDataCursor.inBounds(nx, ny, nz))
20
+ continue;
21
+ const voxel = tasks.nDataCursor.getVoxel(nx, ny, nz);
22
+ if (!voxel)
23
+ continue;
24
+ const nl = voxel.getPower();
25
+ if (nl > -1 && nl < sl) {
26
+ if (voxel._tags["dve_can_carry_power"]) {
27
+ queue.push(nx, ny, nz);
28
+ }
29
+ voxel.setPower(sl - 1);
30
+ }
31
+ }
32
+ tasks.bounds.update(x, y, z);
33
+ }
34
+ }
35
+ export function PowerRemove(tasks) {
36
+ const remove = tasks.power.remove;
37
+ const update = tasks.power.update;
38
+ const removeMap = tasks.power.removeMap;
39
+ const updateMap = tasks.power.updateMap;
40
+ while (remove.length) {
41
+ const x = remove.shift();
42
+ const y = remove.shift();
43
+ const z = remove.shift();
44
+ if (removeMap.has(x, y, z))
45
+ continue;
46
+ removeMap.add(x, y, z);
47
+ const voxel = tasks.sDataCursor.getVoxel(x, y, z);
48
+ if (!voxel)
49
+ continue;
50
+ const sl = voxel.isAir() ? voxel.getLevel() : voxel.getPower();
51
+ if (sl <= 0)
52
+ continue;
53
+ for (let i = 0; i < 6; i++) {
54
+ const nx = $3dCardinalNeighbors[i][0] + x;
55
+ const ny = $3dCardinalNeighbors[i][1] + y;
56
+ const nz = $3dCardinalNeighbors[i][2] + z;
57
+ if (!tasks.nDataCursor.inBounds(nx, ny, nz))
58
+ continue;
59
+ const voxel = tasks.nDataCursor.getVoxel(nx, ny, nz);
60
+ if (!voxel)
61
+ continue;
62
+ const nl = voxel.isAir() ? voxel.getLevel() : voxel.getPower();
63
+ if (nl > 0 && nl < sl) {
64
+ remove.push(nx, ny, nz);
65
+ if (voxel.isPowerSource()) {
66
+ update.push(nx, ny, nz);
67
+ }
68
+ }
69
+ else {
70
+ if (nl > 0 && nl > sl && !updateMap.has(nx, ny, nz)) {
71
+ updateMap.add(nx, ny, nz);
72
+ update.push(nx, ny, nz);
73
+ }
74
+ }
75
+ }
76
+ tasks.bounds.update(x, y, z);
77
+ voxel.setPower(0);
78
+ }
79
+ removeMap.clear();
80
+ }
@@ -3,13 +3,13 @@ import type { Vec3Array } from "@amodx/math";
3
3
  import type { RawVoxelData } from "../Voxels/Types/Voxel.types.js";
4
4
  import { SectorData } from "World/index.js";
5
5
  export type WorldLockTasks = [
6
- dimension: string,
6
+ dimension: number,
7
7
  start: Vec3Array,
8
8
  end: Vec3Array
9
9
  ];
10
10
  export type VoxelUpdateTasks = [location: LocationData, raw: RawVoxelData];
11
11
  export type RunRebuildTasks = [buildQueue: string];
12
- export type RunBuildQueue = [dimension: string, sections: Vec3Array[]];
12
+ export type RunBuildQueue = [dimension: number, sections: Vec3Array[]];
13
13
  export type GenerateTasks = [location: LocationData, data: any];
14
14
  export type ExplosionTasks = [location: LocationData, radius: number];
15
15
  export type LoadSectorDataTasks = [location: LocationData, sector: SectorData];
@@ -17,5 +17,6 @@ export declare enum TasksIds {
17
17
  Explosion = 15,
18
18
  VoxelErease = 16,
19
19
  VoxelPaint = 17,
20
- VoxelUpdate = 18
20
+ VoxelUpdate = 18,
21
+ LogicUpdate = 19
21
22
  }
package/Tasks/TasksIds.js CHANGED
@@ -19,4 +19,5 @@ export var TasksIds;
19
19
  TasksIds[TasksIds["VoxelErease"] = 16] = "VoxelErease";
20
20
  TasksIds[TasksIds["VoxelPaint"] = 17] = "VoxelPaint";
21
21
  TasksIds[TasksIds["VoxelUpdate"] = 18] = "VoxelUpdate";
22
+ TasksIds[TasksIds["LogicUpdate"] = 19] = "LogicUpdate";
22
23
  })(TasksIds || (TasksIds = {}));
@@ -0,0 +1,3 @@
1
+ import { VoxelUpdateTask } from "../VoxelUpdateTask.js";
2
+ export declare const updateLightTask: (tasks: VoxelUpdateTask) => void;
3
+ export declare const updatePowerTask: (tasks: VoxelUpdateTask) => void;