@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
@@ -0,0 +1,50 @@
1
+ import { TextureAnimationTexture } from "./TextureAnimationTexture";
2
+ export class CompiledTexture {
3
+ id;
4
+ static GetAtlasIndex = (x, y, boundsX) => x + y * boundsX;
5
+ static GetAtlasPosition = (index, boundsX, position = [0, 0]) => {
6
+ position[1] = Math.floor(index / boundsX);
7
+ position[0] = Math.floor(index % boundsX);
8
+ return position;
9
+ };
10
+ images = [];
11
+ atlasSizeMap = {};
12
+ textureMap = {};
13
+ animations = [];
14
+ shaderTexture;
15
+ animatedTexture;
16
+ constructor(id) {
17
+ this.id = id;
18
+ this.animatedTexture = new TextureAnimationTexture(this);
19
+ }
20
+ getTextureIndex(id) {
21
+ let finalId = "";
22
+ let frameIndex = 0;
23
+ if (!Array.isArray(id)) {
24
+ finalId = id;
25
+ }
26
+ if (Array.isArray(id)) {
27
+ finalId = id[0];
28
+ if (typeof id[1] == "number")
29
+ frameIndex = id[1];
30
+ if (Array.isArray(id[1]))
31
+ frameIndex = CompiledTexture.GetAtlasIndex(id[1][0], id[1][1], this.atlasSizeMap[finalId][0]);
32
+ if (typeof id[1] == "string") {
33
+ finalId = `${id[0]}:${id[1]}`;
34
+ if (typeof id[2] == "number")
35
+ frameIndex = id[2];
36
+ if (Array.isArray(id[2]))
37
+ frameIndex = CompiledTexture.GetAtlasIndex(id[2][0], id[2][1], this.atlasSizeMap[finalId][0]);
38
+ }
39
+ }
40
+ const index = this.textureMap[finalId];
41
+ if (index === undefined) {
42
+ console.warn(`Texture with id [passed in: ${id.toString()}] [final: ${finalId}] does not exist on compiled texture [${this.id}]`);
43
+ return 0;
44
+ }
45
+ return index + frameIndex;
46
+ }
47
+ getTexturePath(id) {
48
+ return this.images[this.getTextureIndex(id)].src;
49
+ }
50
+ }
@@ -0,0 +1,12 @@
1
+ export declare class CompiledTextureAnimation {
2
+ textureIndex: number;
3
+ _frames: number[];
4
+ _times: number[];
5
+ _currentTime: number;
6
+ _frameIndex: number;
7
+ _current: number;
8
+ _animatedTextureIndex: number;
9
+ constructor(textureIndex: number);
10
+ tick(delta: number): boolean;
11
+ getIndex(): number;
12
+ }
@@ -0,0 +1,27 @@
1
+ export class CompiledTextureAnimation {
2
+ textureIndex;
3
+ _frames = [];
4
+ _times = [];
5
+ _currentTime = 0;
6
+ _frameIndex = 0;
7
+ _current = Infinity;
8
+ _animatedTextureIndex = -1;
9
+ constructor(textureIndex) {
10
+ this.textureIndex = textureIndex;
11
+ }
12
+ tick(delta) {
13
+ if (this._current == Infinity)
14
+ this._current = this._times[0];
15
+ this._current -= delta;
16
+ if (this._current <= 0) {
17
+ this._frameIndex++;
18
+ this._frameIndex %= this._frames.length;
19
+ this._current = this._times[this._frameIndex];
20
+ return true;
21
+ }
22
+ return false;
23
+ }
24
+ getIndex() {
25
+ return this._frames[this._frameIndex] + this.textureIndex;
26
+ }
27
+ }
@@ -0,0 +1,10 @@
1
+ import { CompiledTexture } from "./CompiledTexture";
2
+ export declare class TextureAnimationTexture {
3
+ _texture: CompiledTexture;
4
+ _buffer: Uint16Array;
5
+ _size: number;
6
+ shaderTexture: any;
7
+ constructor(_texture: CompiledTexture);
8
+ build(): Uint16Array;
9
+ tick(delta: number): boolean;
10
+ }
@@ -0,0 +1,32 @@
1
+ import { CompiledTexture } from "./CompiledTexture";
2
+ export class TextureAnimationTexture {
3
+ _texture;
4
+ _buffer;
5
+ _size = 0;
6
+ shaderTexture;
7
+ constructor(_texture) {
8
+ this._texture = _texture;
9
+ }
10
+ build() {
11
+ const totalTexture = this._texture.images.length;
12
+ const size = Math.pow(2, Math.ceil(Math.log2(Math.ceil(Math.sqrt(totalTexture)))));
13
+ this._size = size;
14
+ this._buffer = new Uint16Array(size * size);
15
+ for (let i = 0; i < this._texture.animations.length; i++) {
16
+ const anim = this._texture.animations[i];
17
+ anim._animatedTextureIndex = CompiledTexture.GetAtlasIndex(...CompiledTexture.GetAtlasPosition(anim.textureIndex, this._size), this._size);
18
+ }
19
+ return this._buffer;
20
+ }
21
+ tick(delta) {
22
+ let update = false;
23
+ for (let i = 0; i < this._texture.animations.length; i++) {
24
+ const anim = this._texture.animations[i];
25
+ if (anim.tick(delta)) {
26
+ update = true;
27
+ this._buffer[anim._animatedTextureIndex] = anim.getIndex();
28
+ }
29
+ }
30
+ return update;
31
+ }
32
+ }
@@ -0,0 +1,10 @@
1
+ import { CompiledTexture } from "../Classes/CompiledTexture";
2
+ import { TextureData } from "../../Textures/Texture.types";
3
+ export type BuildTextureDataProps = {
4
+ type: string;
5
+ baseURL?: string;
6
+ createCache?: boolean;
7
+ textures: TextureData[];
8
+ finalSize?: [width: number, height: number];
9
+ };
10
+ export declare function BuildTextureData({ type, baseURL: currentBaseURL, textures, finalSize: currentFinalSize, createCache, }: BuildTextureDataProps): Promise<CompiledTexture>;
@@ -0,0 +1,205 @@
1
+ import { CompiledTexture } from "../Classes/CompiledTexture";
2
+ import { CompiledTextureAnimation } from "../../Textures/Classes/CompiledTextureAnimation";
3
+ let baseURL = "assets/textures";
4
+ let canvas;
5
+ let context;
6
+ let atlasCanvas;
7
+ let atlasContext;
8
+ const finalSize = [256, 256];
9
+ async function getImageBase64(url) {
10
+ const response = await fetch(url);
11
+ const blob = await response.blob();
12
+ return new Promise((resolve, reject) => {
13
+ const reader = new FileReader();
14
+ reader.readAsDataURL(blob);
15
+ reader.onloadend = () => resolve(reader.result);
16
+ reader.onerror = reject;
17
+ });
18
+ }
19
+ function loadImage(src) {
20
+ return new Promise((resolve, reject) => {
21
+ const img = new Image();
22
+ img.src = src;
23
+ img.onload = () => resolve(img);
24
+ img.onerror = reject;
25
+ });
26
+ }
27
+ async function sliceImageIntoTiles(src, tilesX, tilesY) {
28
+ const image = await loadImage(src);
29
+ const tileWidth = image.width / tilesX;
30
+ const tileHeight = image.height / tilesY;
31
+ atlasCanvas.width = tileWidth;
32
+ atlasCanvas.height = tileHeight;
33
+ const tiles = [];
34
+ for (let x = 0; x < tilesX; x++) {
35
+ for (let y = 0; y < tilesY; y++) {
36
+ atlasContext.clearRect(0, 0, tileWidth, tileHeight);
37
+ atlasContext.drawImage(image, x * tileWidth, y * tileHeight, tileWidth, tileHeight, 0, 0, tileWidth, tileHeight);
38
+ tiles[CompiledTexture.GetAtlasIndex(x, y, tilesX)] =
39
+ atlasCanvas.toDataURL("image/png");
40
+ }
41
+ }
42
+ return tiles;
43
+ }
44
+ async function loadImageForShader(imgSrcData) {
45
+ if (!context)
46
+ throw new Error("");
47
+ canvas.width = finalSize[0];
48
+ canvas.height = finalSize[1];
49
+ const prom = new Promise((resolve, reject) => {
50
+ const image = typeof imgSrcData == "string" ? new Image() : imgSrcData;
51
+ image.onerror = (error) => reject(error);
52
+ if (typeof imgSrcData == "string")
53
+ image.src = imgSrcData;
54
+ image.onload = () => {
55
+ context.clearRect(0, 0, canvas.width, canvas.height);
56
+ context.imageSmoothingEnabled = false;
57
+ context.save();
58
+ context.translate(0, canvas.height);
59
+ context.scale(1, -1);
60
+ context.drawImage(image, 0, 0, canvas.width, canvas.height);
61
+ context.restore();
62
+ const dataUrl = canvas.toDataURL("image/png");
63
+ const returnImage = new Image(canvas.width, canvas.height);
64
+ returnImage.src = dataUrl;
65
+ returnImage.onload = () => {
66
+ resolve(returnImage);
67
+ };
68
+ };
69
+ });
70
+ return prom;
71
+ }
72
+ function getImagePath(data, parentId = null) {
73
+ if (data.base64)
74
+ return data.base64;
75
+ if (data.path)
76
+ return data.path;
77
+ if (!parentId)
78
+ return `${baseURL}/${data.id}.png`;
79
+ return `${baseURL}/${parentId}/${data.id}.png`;
80
+ }
81
+ function getTextureId(data, parentId = null) {
82
+ return `${parentId ? parentId : data.id}${!parentId ? "" : ":" + data.id}`;
83
+ }
84
+ function createAnimationData(atlas, data, startIndex) {
85
+ const compiled = new CompiledTextureAnimation(startIndex);
86
+ if (!data?.frames) {
87
+ const maxFrames = atlas.tiles[0] * atlas.tiles[1];
88
+ for (let i = 0; i < maxFrames; i++) {
89
+ compiled._frames[i] = i;
90
+ compiled._times[i] = data.frameTime;
91
+ }
92
+ }
93
+ else {
94
+ for (let i = 0; i < data.frames.length; i++) {
95
+ const frameData = data.frames[i];
96
+ if (typeof frameData == "number") {
97
+ compiled._frames[i] = frameData;
98
+ compiled._times[i] = data.frameTime;
99
+ continue;
100
+ }
101
+ compiled._frames[i] = frameData.index;
102
+ compiled._times[i] = frameData.time;
103
+ }
104
+ }
105
+ if (data?.pingPong) {
106
+ compiled._frames = [
107
+ ...compiled._frames,
108
+ ...compiled._frames.toReversed().slice(1, compiled._frames.length - 1),
109
+ ];
110
+ compiled._times = [
111
+ ...compiled._times,
112
+ ...compiled._times.toReversed().slice(1, compiled._times.length - 1),
113
+ ];
114
+ }
115
+ return compiled;
116
+ }
117
+ async function process(compiled, data, textureIndex, parent, cache = false) {
118
+ const textureId = getTextureId(data, parent);
119
+ compiled.textureMap[textureId] = textureIndex;
120
+ const imagePath = getImagePath(data, parent);
121
+ if (cache) {
122
+ data.base64 = await getImageBase64(imagePath);
123
+ }
124
+ if (!data.atlas) {
125
+ compiled.images[textureIndex] = await loadImageForShader(imagePath);
126
+ return textureIndex + 1;
127
+ }
128
+ const tiles = await sliceImageIntoTiles(imagePath, ...data.atlas.tiles);
129
+ for (let i = 0; i < tiles.length; i++) {
130
+ compiled.images[textureIndex + i] = await loadImageForShader(tiles[i]);
131
+ }
132
+ compiled.atlasSizeMap[textureId] = data.atlas.tiles;
133
+ if (data.animated) {
134
+ compiled.animations.push(createAnimationData(data.atlas, data.animated, textureIndex));
135
+ }
136
+ if (data.atlas.namedTiles) {
137
+ for (const named of data.atlas.namedTiles) {
138
+ let tIndex = Array.isArray(named.index)
139
+ ? CompiledTexture.GetAtlasIndex(...named.index, data.atlas.tiles[0])
140
+ : named.index;
141
+ compiled.textureMap[`${textureId}:${named.id}`] = textureIndex + tIndex;
142
+ }
143
+ }
144
+ return textureIndex + tiles.length;
145
+ }
146
+ export async function BuildTextureData({ type, baseURL: currentBaseURL, textures, finalSize: currentFinalSize, createCache, }) {
147
+ baseURL = currentBaseURL || "assets/textures";
148
+ finalSize[0] = currentFinalSize ? currentFinalSize[0] : 256;
149
+ finalSize[1] = currentFinalSize ? currentFinalSize[1] : 256;
150
+ if (!canvas) {
151
+ canvas = document.createElement("canvas");
152
+ canvas.width = finalSize[0];
153
+ canvas.height = finalSize[1];
154
+ context = canvas.getContext("2d", { willReadFrequently: true });
155
+ context.imageSmoothingEnabled = false;
156
+ atlasCanvas = document.createElement("canvas");
157
+ atlasContext = atlasCanvas.getContext("2d", { willReadFrequently: true });
158
+ // atlasContext.imageSmoothingEnabled = false;
159
+ if (!context)
160
+ throw new Error(`Error could not create CanvasRenderingContext2D`);
161
+ }
162
+ const compiled = new CompiledTexture(type);
163
+ let count = 0;
164
+ for (const texture of textures) {
165
+ if (!texture.variations?.length) {
166
+ try {
167
+ count = await process(compiled, texture, count, null, createCache);
168
+ continue;
169
+ }
170
+ catch (error) {
171
+ console.warn(`Could not load texture ${texture.id}`);
172
+ console.error(error);
173
+ continue;
174
+ }
175
+ }
176
+ if (texture.variations) {
177
+ for (let i = 0; i < texture.variations.length; i++) {
178
+ const vara = texture.variations[i];
179
+ if (typeof vara == "string") {
180
+ const newData = { type: texture.type, id: vara };
181
+ try {
182
+ count = await process(compiled, newData, count, texture.id, createCache);
183
+ if (createCache)
184
+ texture.variations[i] = newData;
185
+ continue;
186
+ }
187
+ catch (error) {
188
+ console.warn(`Could not load texture ${texture.id}`);
189
+ console.error(error);
190
+ continue;
191
+ }
192
+ }
193
+ try {
194
+ count = await process(compiled, vara, count, texture.id, createCache);
195
+ }
196
+ catch (error) {
197
+ console.warn(`Could not load texture ${texture.id}`);
198
+ console.error(error);
199
+ continue;
200
+ }
201
+ }
202
+ }
203
+ }
204
+ return compiled;
205
+ }
@@ -1,76 +1,62 @@
1
- export type TextureId = [type: string, id: string, varation?: string];
2
- export type TextureTypes = string;
1
+ export type TextureId = [id: string, frame: [x: number, y: number]] | [id: string, index: number] | [id: string, varation: string] | [id: string, varation: string, frame: [x: number, y: number]] | [id: string, varation: string, index: number] | string;
3
2
  export type TextureTypeUVMap = Record<string, Record<string, number>>;
4
- export type TextureAnimationData = {
5
- /**# Frames
6
- * If the texture has animation frames the number of frames must be set to the number
7
- * texture animatoin images. This number must be greater than 1.
8
- *
9
- * The number will be used to locate all the associated frames.
10
- *
11
- * Example: If you specify 3 frames for a texture with the ID **dreamstone** the folder would look like this:
12
- * - dreamstone/default-1.png
13
- * - dreamstone/default-2.png
14
- * - dreamstone/default-3.png
15
- */
16
- frames: number;
17
- /**# Anim Keys
18
- * If the texture is animated you must supply the anim key frames which
19
- * is just the order of the frames.
20
- */
21
- animKeys?: number[];
22
- /**# Global Frame Time
23
- * ---
24
- * Specifies how many frames every anim key should be display.
25
- */
26
- globalFrameTime?: number;
27
- /**# Anim Key Frame Time
28
- * ---
29
- * If set globalFrameTime will be ignored.
30
- * Specifies how many frames every anim should be displayed.
31
- * You must supply a number for every animKey.
32
- */
33
- animKeyFrameTimes?: number[];
34
- };
35
3
  export type TextureDataBase = {
36
- /**# rawData
37
- * Provide a Uint8ClampedArray or an array of Uint8ClampedArray's instead of downloading
38
- */
39
- rawData?: Uint8ClampedArray | Uint8ClampedArray[];
40
- /**# base64
41
- * Provide a base64 encoded string to use instead of downloading
42
- */
43
- base64?: string | string[];
44
- /**# includeInRawDataMap
45
- * Will keep a Uint8ClampedArray of the loaded texture if set to true.
46
- */
47
- includeInRawDataMap?: boolean;
48
- };
49
- export type TextureData = {
50
- type: TextureTypes;
51
- /**# ID
4
+ /**
52
5
  * The id of the texture.
53
- * This will be used to locate the file.
6
+ * This will be used to locate the file if no direct path is given.
54
7
  */
55
8
  id: string;
56
- /**# Path
9
+ /**
57
10
  * If the texture is not in the default path specify it here.
58
11
  */
59
12
  path?: string;
60
- /**# normalMap
61
- * If the texture is an overlay specify it here.
13
+ /**
14
+ * Provide a base64 encoded string to use instead of downloading
62
15
  */
63
- normalMap?: boolean;
64
- /**# Varations
65
- * The name of the texture must be default with the folder being its ID.
66
- * Variations allow you to add variations to the same texture.
16
+ base64?: string;
17
+ /**
18
+ * If the texture is an atlas specify it here.
19
+ */
20
+ atlas?: {
21
+ tiles: [tilesX: number, tilesY: number];
22
+ /**To make it eaiser to use specifc tiles from an atlas you can name tiles.
23
+ *
24
+ * To use the name just at it to the end of the id with a colon ":".
25
+ *
26
+ * dve_dream_stone:grassy-top
27
+ */
28
+ namedTiles?: {
29
+ id: string;
30
+ index: [tileX: number, tileY: number] | number;
31
+ }[];
32
+ };
33
+ /**
34
+ * If the texture is an animated speicfy it here.
35
+ * Only atlas texture can be animated.
36
+ */
37
+ animated?: {
38
+ frameTime: number;
39
+ pingPong?: boolean;
40
+ interpolate?: boolean;
41
+ frames?: (number | {
42
+ index: number;
43
+ time: number;
44
+ })[];
45
+ };
46
+ };
47
+ export type TextureData = {
48
+ /**
49
+ * The type of texture. Used to combined all textures into one final one.
67
50
  *
68
- * If you add a variation of "grassy-up" you must you include in the
69
- * folder of the texture one with the name 'grassy-up'.
51
+ * Defaults to dve_voxel
52
+ */
53
+ type?: string;
54
+ /**
55
+ * Add textures to the same texture that can be refernced with a TextureId.
70
56
  *
71
- * So the files in that folder would be for a texture with the ID **dreamstone**
72
- * - dreamstone/default.png
73
- * - dreamstone/grassy-up.png
57
+ * If not directly giving paths the main texture must be named default
58
+ * and all varations must be in the same folder and be the name of the key they
59
+ * are stored in the variations object.
74
60
  */
75
- variations?: Record<string, TextureAnimationData & TextureDataBase>;
76
- } & TextureAnimationData & TextureDataBase;
61
+ variations?: (string | TextureDataBase)[];
62
+ } & TextureDataBase;
@@ -1,21 +1,10 @@
1
- import type { TextureData, TextureTypeUVMap, TextureId } from "./Texture.types";
2
- import { TextureArray } from "./TextureArray.js";
1
+ import { CompiledTexture } from "./Classes/CompiledTexture.js";
2
+ import { BuildTextureDataProps } from "./Functions/BuildTextureData.js";
3
+ import type { TextureData } from "./Texture.types";
3
4
  export declare class TextureManager {
4
- static defaultTexturePath: string;
5
- static textureTypes: Map<string, TextureArray>;
6
- static getTextureIndex(data: TextureId): number;
7
- static _ready: boolean;
8
- static isReady(): boolean;
9
- static init(): Promise<void>;
10
- static generateTextureUVMap(): TextureTypeUVMap;
11
- static defineDefaultTexturePath(path: string): void;
12
- static getTextureData([type, id, segment]: TextureId): TextureData | undefined;
13
- static getTextureType(id: string): false | TextureArray;
14
- static getOrAddTextureType(id: string): TextureArray;
15
- static addTextureType(id: string): TextureArray;
16
- static clearTextureData(): void;
17
- static registerTexture(textureData: TextureData | TextureData[]): void;
18
- static getTexturePath(textureType: string, id: string, varation: string, segment?: string, frames?: number): string;
19
- static createCached(): Promise<TextureData[]>;
20
- static createRawDataMap(): Promise<Map<string, Uint8ClampedArray>>;
5
+ static _textureTypes: Map<string, TextureData[]>;
6
+ static _compiledTextures: Map<string, CompiledTexture>;
7
+ static registerTexture(textureData: TextureData[]): void;
8
+ static getTexture(id: string): CompiledTexture;
9
+ static compiledTextures(props?: Omit<BuildTextureDataProps, "textures" | "type">): Promise<void>;
21
10
  }