@divinevoxel/vlox 0.0.71 → 0.0.73

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 (271) hide show
  1. package/Contexts/Base/Main/InitDataGenerator.js +0 -9
  2. package/Contexts/Base/Remote/DataSync.types.d.ts +0 -5
  3. package/Contexts/Base/Remote/InitDataSync.js +17 -31
  4. package/Contexts/Render/DivineVoxelEngineRender.d.ts +1 -1
  5. package/Contexts/World/DivineVoxelEngineWorld.d.ts +1 -1
  6. package/Init/StartConstructor.js +7 -7
  7. package/Init/StartWorld.d.ts +1 -1
  8. package/Init/StartWorld.js +0 -12
  9. package/Math/Indexing.d.ts +12 -3
  10. package/Math/Indexing.js +24 -15
  11. package/Mesher/Functions/CompactVoxelMesh.d.ts +2 -2
  12. package/Mesher/Functions/CompactVoxelMesh.js +4 -5
  13. package/Mesher/Functions/MeshSection.d.ts +1 -1
  14. package/Mesher/Functions/MeshSection.js +72 -66
  15. package/Mesher/Functions/MeshTexture.d.ts +1 -1
  16. package/Mesher/Functions/MeshTexture.js +3 -4
  17. package/Mesher/Functions/MeshVoxel.js +20 -26
  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 +108 -125
  22. package/Mesher/Geomtry/VoxelMesh.d.ts +1 -1
  23. package/Mesher/Geomtry/VoxelMesh.js +2 -2
  24. package/Mesher/{Tools → Geomtry}/VoxelMeshBVHBuilder.d.ts +2 -9
  25. package/Mesher/{Tools → Geomtry}/VoxelMeshBVHBuilder.js +4 -16
  26. package/Mesher/Geomtry/{Buffers.d.ts → VoxelMeshBuffers.d.ts} +9 -8
  27. package/Mesher/Geomtry/VoxelMeshBuffers.js +49 -0
  28. package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.d.ts +10 -0
  29. package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.js +10 -0
  30. package/Mesher/Geomtry/index.d.ts +0 -1
  31. package/Mesher/Geomtry/index.js +0 -1
  32. package/Mesher/InitMesher.js +2 -11
  33. package/Mesher/InitTask.js +10 -22
  34. package/Mesher/Models/Common/BoundsFunctions.d.ts +1 -3
  35. package/Mesher/Models/Common/BoundsFunctions.js +0 -16
  36. package/Mesher/Models/Common/Calc/CalcConstants.js +14 -31
  37. package/Mesher/Models/Common/Calc/FaceDataCalc.d.ts +2 -8
  38. package/Mesher/Models/Common/Calc/FaceDataCalc.js +50 -52
  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.d.ts +1 -5
  42. package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +40 -42
  43. package/Mesher/Models/Nodes/GeometryNode.d.ts +3 -5
  44. package/Mesher/Models/Nodes/GeometryNode.js +1 -2
  45. package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.d.ts +3 -6
  46. package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +55 -40
  47. package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.d.ts +2 -6
  48. package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +52 -51
  49. package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.d.ts +2 -6
  50. package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.js +18 -19
  51. package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.d.ts +2 -6
  52. package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.js +37 -40
  53. package/Mesher/{Tools → Models/Protocols}/OutlinedVoxelTool.d.ts +1 -1
  54. package/Mesher/{Tools → Models/Protocols}/OutlinedVoxelTool.js +1 -1
  55. package/Mesher/Models/RenderedMaterials.d.ts +6 -0
  56. package/Mesher/{RenderedMaterials.js → Models/RenderedMaterials.js} +2 -2
  57. package/Mesher/Models/VoxelConstructor.d.ts +4 -5
  58. package/Mesher/Models/VoxelConstructor.js +23 -12
  59. package/Mesher/Models/{VoxelGeometryLookUp.d.ts → VoxelGeometryBuilderCacheSpace.d.ts} +6 -14
  60. package/Mesher/Models/{VoxelGeometryLookUp.js → VoxelGeometryBuilderCacheSpace.js} +26 -44
  61. package/Mesher/{Tools/VoxelMesherDataTool.d.ts → Models/VoxelModelBuilder.d.ts} +10 -8
  62. package/Mesher/{Tools/VoxelMesherDataTool.js → Models/VoxelModelBuilder.js} +44 -19
  63. package/Mesher/Models/VoxelModelConstructorRegister.js +3 -3
  64. package/Models/Defaults/CubeVoxelGeometry.js +4 -0
  65. package/Models/Defaults/CubeVoxelModels.js +344 -344
  66. package/Models/Defaults/LiquidVoxelModel.js +2 -2
  67. package/Models/Defaults/PanelVoxelModels.js +432 -432
  68. package/Models/Defaults/StairVoxelModel.js +576 -576
  69. package/Models/Examples.js +469 -456
  70. package/Models/Indexing/VoxelAOResultsIndex.d.ts +4 -4
  71. package/Models/Indexing/VoxelAOResultsIndex.js +15 -9
  72. package/Models/Indexing/VoxelFaceCullResultsIndex.d.ts +3 -3
  73. package/Models/Indexing/VoxelFaceCullResultsIndex.js +14 -9
  74. package/Models/Indexing/VoxelFaceTransparentResultsIndex.d.ts +1 -1
  75. package/Models/Indexing/VoxelFaceTransparentResultsIndex.js +1 -1
  76. package/Models/Rules/Functions/BuildFinalInputs.js +9 -7
  77. package/Models/Rules/Functions/BuildGeomtryInputs.js +8 -5
  78. package/Models/Rules/Functions/BuildRules.js +4 -4
  79. package/Models/Rules/{VoxelModelManager.d.ts → VoxelModelRuleBuilderRegister.d.ts} +1 -1
  80. package/Models/Rules/VoxelModelRuleBuilderRegister.js +178 -0
  81. package/Models/VoxelModel.types.d.ts +14 -5
  82. package/Renderer/Classes/SectorMesh.d.ts +3 -4
  83. package/Renderer/Classes/SectorMesh.js +6 -11
  84. package/Renderer/InitTasks.js +6 -7
  85. package/Renderer/MeshManager.js +2 -2
  86. package/Renderer/MeshRegister.js +2 -1
  87. package/Settings/EngineSettings.d.ts +1 -1
  88. package/Settings/EngineSettings.js +3 -5
  89. package/Settings/EngineSettings.types.d.ts +17 -18
  90. package/Settings/EngineSettings.types.js +16 -15
  91. package/Tasks/IWG/IWG.d.ts +2 -1
  92. package/Tasks/IWG/IWG.js +9 -3
  93. package/Tasks/IWG/Internal/Classes/BuildQueue.d.ts +11 -0
  94. package/Tasks/IWG/Internal/Classes/BuildQueue.js +49 -0
  95. package/Tasks/IWG/Internal/Classes/Generator.d.ts +6 -1
  96. package/Tasks/IWG/Internal/Classes/Generator.js +14 -2
  97. package/Tasks/IWG/Internal/Classes/IWGTaskBase.js +2 -2
  98. package/Tasks/IWG/Internal/Functions/getSectorState.js +4 -7
  99. package/Tasks/IWG/Internal/Functions/runBuildUpdate.js +21 -2
  100. package/Tasks/IWG/Internal/Functions/runWorldUpdate.js +5 -6
  101. package/Tasks/IWG/Internal/IWGTasks.d.ts +0 -4
  102. package/Tasks/IWG/Internal/IWGTasks.js +12 -31
  103. package/Tasks/IWG/Internal/IWGTools.d.ts +1 -1
  104. package/Tasks/IWG/Procedures/SaveAllSectors.js +2 -0
  105. package/Tasks/Propagation/Flow/FlowManager.d.ts +0 -2
  106. package/Tasks/Propagation/Flow/FlowManager.js +86 -87
  107. package/Tasks/Propagation/Flow/WorldFlow.js +2 -3
  108. package/Tasks/Propagation/Illumanation/WorldRGB.js +1 -2
  109. package/Tasks/Update/InitTasks.d.ts +2 -1
  110. package/Tasks/Update/InitTasks.js +6 -6
  111. package/Tasks/Update/UpdateTask.d.ts +3 -1
  112. package/Tasks/Update/UpdateTask.js +28 -2
  113. package/Tasks/Update/VoxelUpdate.js +21 -7
  114. package/Tasks/WorldGeneration/WorldGenBrush.js +2 -1
  115. package/Templates/Cursor/TemplateCursor.d.ts +2 -2
  116. package/Templates/Cursor/TemplateCursor.js +1 -2
  117. package/Templates/Functions/CreateTemplate.js +1 -1
  118. package/Templates/VoxelTemplate.js +6 -8
  119. package/Templates/VoxelTemplates.types.d.ts +1 -1
  120. package/Textures/Classes/CompiledTexture.d.ts +18 -0
  121. package/Textures/Classes/CompiledTexture.js +50 -0
  122. package/Textures/Classes/CompiledTextureAnimation.d.ts +12 -0
  123. package/Textures/Classes/CompiledTextureAnimation.js +27 -0
  124. package/Textures/Classes/TextureAnimationTexture.d.ts +10 -0
  125. package/Textures/Classes/TextureAnimationTexture.js +32 -0
  126. package/Textures/Functions/BuildTextureData.d.ts +10 -0
  127. package/Textures/Functions/BuildTextureData.js +205 -0
  128. package/Textures/Texture.types.d.ts +50 -64
  129. package/Textures/TextureManager.d.ts +8 -19
  130. package/Textures/TextureManager.js +28 -166
  131. package/Tools/Brush/Brush.d.ts +1 -3
  132. package/Tools/Brush/Brush.js +43 -12
  133. package/Util/Binary/BinaryArrays.d.ts +6 -0
  134. package/Util/Binary/BinaryArrays.js +25 -0
  135. package/Util/Binary/BinaryBuffer.d.ts +29 -0
  136. package/Util/Binary/BinaryBuffer.js +130 -0
  137. package/Util/Binary/BinaryFunctions.d.ts +3 -0
  138. package/Util/Binary/BinaryFunctions.js +11 -0
  139. package/Util/StringPalette.d.ts +1 -0
  140. package/Util/StringPalette.js +8 -0
  141. package/Voxels/Cursor/DataCursor.interface.d.ts +5 -0
  142. package/Voxels/Cursor/VoxelCursor.d.ts +6 -6
  143. package/Voxels/Cursor/VoxelCursor.interface.d.ts +11 -16
  144. package/Voxels/Cursor/VoxelCursor.interface.js +35 -58
  145. package/Voxels/Cursor/VoxelCursor.js +13 -12
  146. package/Voxels/Cursor/VoxelLightData.d.ts +3 -4
  147. package/Voxels/Cursor/VoxelLightData.js +8 -7
  148. package/Voxels/Data/VoxelPalettesRegister.d.ts +8 -0
  149. package/Voxels/Data/VoxelPalettesRegister.js +8 -0
  150. package/Voxels/Data/VoxelTag.types.d.ts +56 -0
  151. package/Voxels/Data/VoxelTag.types.js +23 -0
  152. package/Voxels/{State → Data}/VoxelTagStates.d.ts +2 -2
  153. package/Voxels/{State → Data}/VoxelTagStates.js +5 -5
  154. package/Voxels/Data/VoxelTagsRegister.d.ts +9 -0
  155. package/Voxels/Data/VoxelTagsRegister.js +32 -0
  156. package/Voxels/Functions/BuildStateData.js +12 -12
  157. package/Voxels/Functions/BuildTagAndPaletteData.d.ts +13 -0
  158. package/Voxels/Functions/BuildTagAndPaletteData.js +55 -0
  159. package/Voxels/Indexes/VoxelIndex.js +3 -3
  160. package/Voxels/InitVoxelData.js +31 -73
  161. package/Voxels/State/Schema/StateSchema.d.ts +1 -1
  162. package/Voxels/Types/Voxel.types.d.ts +20 -42
  163. package/Voxels/Types/Voxel.types.js +6 -17
  164. package/Voxels/Types/VoxelModelCompiledData.types.d.ts +11 -13
  165. package/Voxels/Types/VoxelSubstances.types.d.ts +2 -15
  166. package/Voxels/Types/VoxelSubstances.types.js +1 -9
  167. package/World/Archive/Archive.types.d.ts +38 -34
  168. package/World/Archive/Functions/ArchiveArea.js +18 -30
  169. package/World/Archive/Functions/ArchiveSector.js +484 -213
  170. package/World/Archive/Functions/ImportSector.d.ts +3 -3
  171. package/World/Archive/Functions/ImportSector.js +205 -151
  172. package/World/Archive/Functions/Shared.d.ts +6 -0
  173. package/World/Archive/Functions/Shared.js +75 -0
  174. package/World/Archive/InitTasks.js +30 -13
  175. package/World/Cursor/SectionCursor.d.ts +3 -2
  176. package/World/Cursor/SectionCursor.js +9 -4
  177. package/World/Cursor/SectorCursor.d.ts +3 -2
  178. package/World/Cursor/SectorCursor.js +5 -3
  179. package/World/Cursor/WorldCursor.d.ts +2 -2
  180. package/World/Cursor/WorldCursor.js +6 -3
  181. package/World/Cursor/WorldVoxelCursor.d.ts +7 -7
  182. package/World/Cursor/WorldVoxelCursor.js +21 -24
  183. package/World/InitTasks.d.ts +1 -1
  184. package/World/Lock/WorldLock.d.ts +1 -1
  185. package/World/Section/Section.d.ts +31 -23
  186. package/World/Section/Section.js +116 -18
  187. package/World/Section/SectionState.d.ts +10 -0
  188. package/World/Section/SectionState.js +11 -0
  189. package/World/Sector/Sector.d.ts +24 -9
  190. package/World/Sector/Sector.js +92 -21
  191. package/World/Sector/SectorHeightMap.js +3 -5
  192. package/World/Sector/SectorState.d.ts +21 -0
  193. package/World/Sector/SectorState.js +28 -0
  194. package/World/WorldRegister.d.ts +4 -0
  195. package/World/WorldRegister.js +15 -3
  196. package/World/WorldSpaces.d.ts +6 -0
  197. package/World/WorldSpaces.js +25 -6
  198. package/package.json +1 -1
  199. package/Data/Cursor/DataCursor.interface.d.ts +0 -5
  200. package/Data/Cursor/DataCursor.interface.js +0 -2
  201. package/Data/Register/MappedDataRegister.d.ts +0 -5
  202. package/Data/Register/MappedDataRegister.js +0 -9
  203. package/Data/Register/MappedRegisterBase.d.ts +0 -14
  204. package/Data/Register/MappedRegisterBase.js +0 -50
  205. package/Data/Structs/StructBuilder.d.ts +0 -34
  206. package/Data/Structs/StructBuilder.js +0 -157
  207. package/Data/Structs/StructBuilder.types.d.ts +0 -30
  208. package/Mesher/Functions/CompactMesh.d.ts +0 -2
  209. package/Mesher/Functions/CompactMesh.js +0 -42
  210. package/Mesher/Geomtry/Buffers.js +0 -81
  211. package/Mesher/Geomtry/GeometryNormals.d.ts +0 -10
  212. package/Mesher/Geomtry/GeometryNormals.js +0 -52
  213. package/Mesher/Geomtry/MeshData.types.d.ts +0 -13
  214. package/Mesher/Geomtry/MeshData.types.js +0 -6
  215. package/Mesher/Geomtry/Tools/MesherDataTools.d.ts +0 -7
  216. package/Mesher/Geomtry/Tools/MesherDataTools.js +0 -12
  217. package/Mesher/Geomtry/Tools/index.d.ts +0 -1
  218. package/Mesher/Geomtry/Tools/index.js +0 -1
  219. package/Mesher/RenderedMaterials.d.ts +0 -6
  220. package/Models/Rules/VoxelModelManager.js +0 -82
  221. package/Textures/TextureAnimations.d.ts +0 -4
  222. package/Textures/TextureAnimations.js +0 -35
  223. package/Textures/TextureArray.d.ts +0 -47
  224. package/Textures/TextureArray.js +0 -202
  225. package/Textures/TextureBuilder.d.ts +0 -13
  226. package/Textures/TextureBuilder.js +0 -120
  227. package/Textures/TextureRegister.d.ts +0 -9
  228. package/Textures/TextureRegister.js +0 -28
  229. package/Tools/Data/SubstanceDataTool.d.ts +0 -13
  230. package/Tools/Data/SubstanceDataTool.js +0 -51
  231. package/Voxels/Palettes/MaterialPalette.d.ts +0 -9
  232. package/Voxels/Palettes/MaterialPalette.js +0 -11
  233. package/Voxels/Palettes/SubstancePalette.d.ts +0 -9
  234. package/Voxels/Palettes/SubstancePalette.js +0 -11
  235. package/Voxels/Palettes/VoxelPalette.d.ts +0 -11
  236. package/Voxels/Palettes/VoxelPalette.js +0 -15
  237. package/Voxels/Segments/MaterialDataGenerator.d.ts +0 -6
  238. package/Voxels/Segments/MaterialDataGenerator.js +0 -12
  239. package/Voxels/Segments/SubstanceDataGenerator.d.ts +0 -6
  240. package/Voxels/Segments/SubstanceDataGenerator.js +0 -35
  241. package/Voxels/Segments/VoxelDataGenerator.d.ts +0 -10
  242. package/Voxels/Segments/VoxelDataGenerator.js +0 -56
  243. package/Voxels/Structs/Builder/SubstanceStructBuilder.d.ts +0 -2
  244. package/Voxels/Structs/Builder/SubstanceStructBuilder.js +0 -42
  245. package/Voxels/Structs/Builder/VoxelStructBuilder.d.ts +0 -2
  246. package/Voxels/Structs/Builder/VoxelStructBuilder.js +0 -68
  247. package/Voxels/Structs/SubstanceStruct.d.ts +0 -17
  248. package/Voxels/Structs/SubstanceStruct.js +0 -17
  249. package/Voxels/Structs/VoxelStruct.d.ts +0 -27
  250. package/Voxels/Structs/VoxelStruct.js +0 -29
  251. package/World/Section/SectionHeightMap.d.ts +0 -10
  252. package/World/Section/SectionHeightMap.js +0 -39
  253. package/World/Section/SectionStruct.d.ts +0 -8
  254. package/World/Section/SectionStruct.js +0 -29
  255. package/World/Section/SectionStructProperties.d.ts +0 -10
  256. package/World/Section/SectionStructProperties.js +0 -11
  257. package/World/Sector/SectorStruct.d.ts +0 -1
  258. package/World/Sector/SectorStruct.js +0 -46
  259. package/World/Sector/SectorStructIds.d.ts +0 -13
  260. package/World/Sector/SectorStructIds.js +0 -14
  261. package/World/Structs/WorldDataStructProperties.d.ts +0 -8
  262. package/World/Structs/WorldDataStructProperties.js +0 -9
  263. /package/Mesher/{VoxelShaderData.d.ts → Geomtry/VoxelShaderData.d.ts} +0 -0
  264. /package/Mesher/{VoxelShaderData.js → Geomtry/VoxelShaderData.js} +0 -0
  265. /package/{Data/Functions → Util/Binary}/Palettes.d.ts +0 -0
  266. /package/{Data/Functions → Util/Binary}/Palettes.js +0 -0
  267. /package/{Data/Structs/StructBuilder.types.js → Voxels/Cursor/DataCursor.interface.js} +0 -0
  268. /package/Voxels/{VoxelLevelReader.d.ts → Cursor/VoxelLevelReader.d.ts} +0 -0
  269. /package/Voxels/{VoxelLevelReader.js → Cursor/VoxelLevelReader.js} +0 -0
  270. /package/World/{Storage → Types}/WorldStorage.interface.d.ts +0 -0
  271. /package/World/{Storage → Types}/WorldStorage.interface.js +0 -0
@@ -1,23 +1,21 @@
1
1
  import { BrushTool } from "../../../Tools/Brush/Brush.js";
2
- import { SubstanceDataTool } from "../../../Tools/Data/SubstanceDataTool.js";
3
2
  import { WorldCursor } from "../../../World/index.js";
4
3
  export class FlowManager {
5
4
  static _brush = new BrushTool();
6
5
  static _sDataTool = new WorldCursor();
7
6
  static _nDataTool = new WorldCursor();
8
- static _substanceTool = new SubstanceDataTool();
9
7
  static setVoxel(tasks, vox, level, levelState, x, y, z) {
10
8
  /* this.sunCheck(tasks, x, y, z);
11
- SunRemove(tasks);
12
- this._brush.setId(vox).setXYZ(x, y, z).paint();
13
- this._sDataTool.loadInAt(x, y, z);
14
- this._sDataTool
15
- .setLevel(level)
16
- .setLevelState(levelState)
17
- .setLight(this.getAbsorbLight(x, y, z))
18
- .commit();
19
-
20
- SunUpdate(tasks); */
9
+ SunRemove(tasks);
10
+ this._brush.setId(vox).setXYZ(x, y, z).paint();
11
+ this._sDataTool.loadInAt(x, y, z);
12
+ this._sDataTool
13
+ .setLevel(level)
14
+ .setLevelState(levelState)
15
+ .setLight(this.getAbsorbLight(x, y, z))
16
+ .commit();
17
+
18
+ SunUpdate(tasks); */
21
19
  }
22
20
  static setDimension(dimension) {
23
21
  // this._sDataTool.setDimension(dimension);
@@ -27,43 +25,44 @@ export class FlowManager {
27
25
  }
28
26
  static removeVoxel(tasks, x, y, z) {
29
27
  /* for (const n of $3dCardinalNeighbors) {
30
- const nx = x + n[0];
31
- const ny = y + n[1];
32
- const nz = z + n[2];
33
- if (!this._nDataTool.loadInAt(nx, ny, nz)) continue;
34
-
35
- const l = this._nDataTool.getLight();
36
-
37
- if (l <= 0) continue;
38
-
39
- if (this.lightData.getS(l) > 0) {
40
- tasks.sun.update.push(nx, ny, nz);
41
- }
42
-
43
- if (this.lightData.hasRGBLight(l)) {
44
- tasks.rgb.update.push(nx, ny, nz);
45
- }
46
- }
47
- this._nDataTool.loadInAt(x, y, z);
48
- const currentLight = this._nDataTool.getLight();
49
- this._brush.setXYZ(x, y, z).erase();
50
- this._nDataTool.clear().loadInAt(x, y, z);
51
- this._nDataTool.setLight(currentLight).commit();
52
- tasks.rgb.remove.push(x, y, z);
53
- RGBRemove(tasks);
54
- SunUpdate(tasks);
55
- RGBUpdate(tasks); */
28
+ const nx = x + n[0];
29
+ const ny = y + n[1];
30
+ const nz = z + n[2];
31
+ if (!this._nDataTool.loadInAt(nx, ny, nz)) continue;
32
+
33
+ const l = this._nDataTool.getLight();
34
+
35
+ if (l <= 0) continue;
36
+
37
+ if (this.lightData.getS(l) > 0) {
38
+ tasks.sun.update.push(nx, ny, nz);
39
+ }
40
+
41
+ if (this.lightData.hasRGBLight(l)) {
42
+ tasks.rgb.update.push(nx, ny, nz);
43
+ }
44
+ }
45
+ this._nDataTool.loadInAt(x, y, z);
46
+ const currentLight = this._nDataTool.getLight();
47
+ this._brush.setXYZ(x, y, z).erase();
48
+ this._nDataTool.clear().loadInAt(x, y, z);
49
+ this._nDataTool.setLight(currentLight).commit();
50
+ tasks.rgb.remove.push(x, y, z);
51
+ RGBRemove(tasks);
52
+ SunUpdate(tasks);
53
+ RGBUpdate(tasks); */
56
54
  }
57
55
  static getFlowRate(substance) {
58
- this._substanceTool.setSubstanceFromString(substance);
59
- return this._substanceTool.getFlowRate();
56
+ // this._substanceTool.setSubstanceFromString(substance);
57
+ // return this._substanceTool.getFlowRate();
58
+ return 0;
60
59
  }
61
60
  static getVoxel(x, y, z) {
62
61
  /* if (!this._sDataTool.loadInAt(x, y, z)) return false;
63
- if (!this._sDataTool.isRenderable()) return false;
64
-
65
- const substance = this._sDataTool.getSubstnaceData();
66
- if (!substance.isLiquid()) return false; */
62
+ if (!this._sDataTool.isRenderable()) return false;
63
+
64
+ const substance = this._sDataTool.getSubstnaceData();
65
+ if (!substance.isLiquid()) return false; */
67
66
  return this._sDataTool;
68
67
  }
69
68
  static setLevel(level, x, y, z) {
@@ -72,39 +71,39 @@ export class FlowManager {
72
71
  }
73
72
  static getLevel(vox, x, y, z) {
74
73
  /* if (!this._nDataTool.loadInAt(x, y, z)) return -2;
75
- const voxel = this._nDataTool.getStringId();
76
- if (this._nDataTool.isAir()) {
77
- return 0;
78
- }
79
- if (voxel == vox) {
80
- return this._nDataTool.getLevel();
81
- }
82
- return -1; */
74
+ const voxel = this._nDataTool.getStringId();
75
+ if (this._nDataTool.isAir()) {
76
+ return 0;
77
+ }
78
+ if (voxel == vox) {
79
+ return this._nDataTool.getLevel();
80
+ }
81
+ return -1; */
83
82
  }
84
83
  static getLevelState(vox, x, y, z) {
85
84
  /* if (!this._nDataTool.loadInAt(x, y, z)) return -2;
86
- const voxel = this._nDataTool.getStringId();
87
- if (voxel == vox) {
88
- return this._nDataTool.getLevelState();
89
- }
90
- if (this._nDataTool.isAir()) {
91
- return -1;
92
- }
93
- return -3; */
85
+ const voxel = this._nDataTool.getStringId();
86
+ if (voxel == vox) {
87
+ return this._nDataTool.getLevelState();
88
+ }
89
+ if (this._nDataTool.isAir()) {
90
+ return -1;
91
+ }
92
+ return -3; */
94
93
  }
95
94
  static canFlowOutwardTest(vox, x, y, z) {
96
95
  /* const level = this.getLevel(vox, x, y - 1, z);
97
- if (level == -1) {
98
- return true;
99
- }
100
- return false; */
96
+ if (level == -1) {
97
+ return true;
98
+ }
99
+ return false; */
101
100
  }
102
101
  static flowDownTest(vox, x, y, z) {
103
102
  /* const level = this.getLevel(vox, x, y - 1, z);
104
- if (level >= 0) {
105
- return true;
106
- }
107
- return false; */
103
+ if (level >= 0) {
104
+ return true;
105
+ }
106
+ return false; */
108
107
  }
109
108
  static wait(ms) {
110
109
  return new Promise((resolve, reject) => setTimeout(resolve, ms));
@@ -114,29 +113,29 @@ export class FlowManager {
114
113
  ];
115
114
  static getAbsorbLight(x, y, z) {
116
115
  /* for (const n of $3dCardinalNeighbors) {
117
- if (!n[0] && !n[1] && !n[2]) continue;
118
- if (!this._nDataTool.loadInAt(x + n[0], y + n[1], z + n[2])) continue;
119
- let l = this._nDataTool.getLight();
120
- if (l <= 0) continue;
121
- const v = this.lightData.getLightValues(l);
122
- for (let i = 0; i < 4; i++) {
123
- if (this._lightValues[i] < v[i]) {
124
- this._lightValues[i] = v[i];
125
- }
126
- }
116
+ if (!n[0] && !n[1] && !n[2]) continue;
117
+ if (!this._nDataTool.loadInAt(x + n[0], y + n[1], z + n[2])) continue;
118
+ let l = this._nDataTool.getLight();
119
+ if (l <= 0) continue;
120
+ const v = this.lightData.getLightValues(l);
121
+ for (let i = 0; i < 4; i++) {
122
+ if (this._lightValues[i] < v[i]) {
123
+ this._lightValues[i] = v[i];
127
124
  }
128
- let brightest = this.lightData.setLightValues(this._lightValues);
129
- for (let i = 0; i < 4; i++) {
130
- this._lightValues[i] = 0;
131
- } */
125
+ }
126
+ }
127
+ let brightest = this.lightData.setLightValues(this._lightValues);
128
+ for (let i = 0; i < 4; i++) {
129
+ this._lightValues[i] = 0;
130
+ } */
132
131
  // return this.lightData.minusOneForAll(2);
133
132
  }
134
133
  static sunCheck(tasks, x, y, z) {
135
134
  /* if (!this._nDataTool.loadInAt(x, y - 1, z)) return;
136
- if (!this._nDataTool.isAir()) return;
137
- const l = this._nDataTool.getLight();
138
- if (this.lightData.getS(l) == 0xf) {
139
- tasks.sun.remove.push(x, y - 1, z);
140
- } */
135
+ if (!this._nDataTool.isAir()) return;
136
+ const l = this._nDataTool.getLight();
137
+ if (this.lightData.getS(l) == 0xf) {
138
+ tasks.sun.remove.push(x, y - 1, z);
139
+ } */
141
140
  }
142
141
  }
@@ -1,6 +1,5 @@
1
1
  import { WorldSpaces } from "../../../World/WorldSpaces";
2
2
  import { WorldRegister } from "../../../World/WorldRegister";
3
- import { SectionHeightMap } from "../../../World/Section/SectionHeightMap";
4
3
  import { EngineSettings } from "../../../Settings/EngineSettings";
5
4
  import { SunRemove, SunUpdate } from "../Illumanation/SunUpdate";
6
5
  import { RGBRemove, RGBUpdate } from "../Illumanation/RGBUpdate";
@@ -118,7 +117,7 @@ export function WorldFlow(task) {
118
117
  const section = sector.sections[i];
119
118
  if (!section)
120
119
  continue;
121
- let [minY, maxY] = SectionHeightMap.setSection(section).getMinMax();
120
+ let [minY, maxY] = section.getMinMax();
122
121
  const cx = sector.position[0];
123
122
  const cy = sector.position[1] + i * WorldSpaces.section.bounds.y;
124
123
  const cz = sector.position[2];
@@ -130,7 +129,7 @@ export function WorldFlow(task) {
130
129
  const voxel = task.nDataCursor.getVoxel(x, y, z);
131
130
  if (!voxel || voxel.isAir())
132
131
  continue;
133
- if (voxel.getSubstanceData().isLiquid()) {
132
+ if (voxel.getSubstanceData()["dve_is_liquid"]) {
134
133
  for (let i = 0; i < 5; i++) {
135
134
  const nVoxel = task.nDataCursor.getVoxel(x + flowUpdateChecks[i][0], y + flowUpdateChecks[i][1], z + flowUpdateChecks[i][2]);
136
135
  if (nVoxel && nVoxel.isAir()) {
@@ -1,7 +1,6 @@
1
1
  import { WorldSpaces } from "../../../World/WorldSpaces";
2
2
  import { WorldRegister } from "../../../World/WorldRegister";
3
3
  import { SectionCursor } from "../../../World/Cursor/SectionCursor";
4
- import { SectionHeightMap } from "../../../World/Section/SectionHeightMap";
5
4
  import { EngineSettings } from "../../../Settings/EngineSettings";
6
5
  import { RGBUpdate } from "./RGBUpdate";
7
6
  const sectionCursor = new SectionCursor();
@@ -20,7 +19,7 @@ export function WorldRGB(task) {
20
19
  if (!section)
21
20
  continue;
22
21
  sectionCursor.setSection(section);
23
- let [minY, maxY] = SectionHeightMap.setSection(section).getMinMax();
22
+ let [minY, maxY] = section.getMinMax();
24
23
  const cx = sector.position[0];
25
24
  const cy = sector.position[1] + i * WorldSpaces.section.bounds.y;
26
25
  const cz = sector.position[2];
@@ -1,4 +1,5 @@
1
+ import { Thread } from "@amodx/threads";
1
2
  import { UpdateTask } from "./UpdateTask";
2
3
  export default function (props: {
3
- onDone(taks: UpdateTask): void;
4
+ onDone(taks: UpdateTask, origin: Thread): void;
4
5
  }): void;
@@ -2,22 +2,22 @@ import { Threads } from "@amodx/threads";
2
2
  import { TasksIds } from "../TasksIds";
3
3
  import { VoxelUpdate, EreaseAndUpdate, PaintAndUpdate } from "./VoxelUpdate";
4
4
  export default function (props) {
5
- Threads.registerTask(TasksIds.VoxelUpdate, async (data) => {
5
+ Threads.registerTask(TasksIds.VoxelUpdate, async (data, origin) => {
6
6
  const tasks = await VoxelUpdate(data);
7
7
  if (!tasks)
8
8
  return;
9
- props.onDone(tasks);
9
+ props.onDone(tasks, origin);
10
10
  });
11
- Threads.registerTask(TasksIds.VoxelErease, async (data) => {
11
+ Threads.registerTask(TasksIds.VoxelErease, async (data, origin) => {
12
12
  const tasks = await EreaseAndUpdate(data);
13
13
  if (!tasks)
14
14
  return;
15
- props.onDone(tasks);
15
+ props.onDone(tasks, origin);
16
16
  });
17
- Threads.registerTask(TasksIds.VoxelPaint, async (data) => {
17
+ Threads.registerTask(TasksIds.VoxelPaint, async (data, origin) => {
18
18
  const tasks = await PaintAndUpdate(data);
19
19
  if (!tasks)
20
20
  return;
21
- props.onDone(tasks);
21
+ props.onDone(tasks, origin);
22
22
  });
23
23
  }
@@ -15,10 +15,12 @@ declare class UpdatedBounds {
15
15
  _task: UpdateTask;
16
16
  min: Vector3Like;
17
17
  max: Vector3Like;
18
+ dimension: string;
18
19
  constructor(_task: UpdateTask);
19
- reset(): void;
20
+ start(dimension?: string): void;
20
21
  update(x: number, y: number, z: number): void;
21
22
  getSections(): Vec3Array[];
23
+ markSectionsAsDirty(): void;
22
24
  }
23
25
  export declare class UpdateTask {
24
26
  flow: FlowQueues;
@@ -1,6 +1,7 @@
1
1
  import { WorldCursor } from "../../World/Cursor/WorldCursor";
2
2
  import { Vector3Like } from "@amodx/math";
3
3
  import { WorldSpaces } from "../../World/WorldSpaces";
4
+ import { WorldRegister } from "../../World/WorldRegister";
4
5
  export class TaskMap {
5
6
  _map = [];
6
7
  get size() {
@@ -34,10 +35,12 @@ class UpdatedBounds {
34
35
  _task;
35
36
  min = Vector3Like.Clone(InfinityVec3);
36
37
  max = Vector3Like.Clone(NegativeInfinityVec3);
38
+ dimension = "main";
37
39
  constructor(_task) {
38
40
  this._task = _task;
39
41
  }
40
- reset() {
42
+ start(dimension) {
43
+ this.dimension = dimension || "main";
41
44
  Vector3Like.Copy(this.min, InfinityVec3);
42
45
  Vector3Like.Copy(this.max, NegativeInfinityVec3);
43
46
  }
@@ -76,6 +79,29 @@ class UpdatedBounds {
76
79
  }
77
80
  return sectionPositions;
78
81
  }
82
+ markSectionsAsDirty() {
83
+ const minSectionPos = WorldSpaces.section.getPosition(this.min.x - 1, this.min.y - 1, this.min.z - 1, tempPosition);
84
+ const minX = minSectionPos.x;
85
+ const minY = minSectionPos.y;
86
+ const minZ = minSectionPos.z;
87
+ const maxSectionPos = WorldSpaces.section.getPosition(this.max.x + 1, this.max.y + 1, this.max.z + 1, tempPosition);
88
+ const maxX = maxSectionPos.x;
89
+ const maxY = maxSectionPos.y;
90
+ const maxZ = maxSectionPos.z;
91
+ for (let x = minX; x <= maxX; x += WorldSpaces.section.bounds.x) {
92
+ for (let z = minZ; z <= maxZ; z += WorldSpaces.section.bounds.z) {
93
+ for (let y = minY; y <= maxY; y += WorldSpaces.section.bounds.y) {
94
+ if (!WorldSpaces.world.inBounds(x, y, z))
95
+ continue;
96
+ const sector = WorldRegister.sectors.get(this.dimension, x, y, z);
97
+ if (!sector)
98
+ continue;
99
+ const section = sector.getSection(x, y, z);
100
+ section.setDirty(true);
101
+ }
102
+ }
103
+ }
104
+ }
79
105
  }
80
106
  export class UpdateTask {
81
107
  flow = new FlowQueues();
@@ -96,13 +122,13 @@ export class UpdateTask {
96
122
  this.flow.update.map.start(origin[1], origin[2], origin[3]);
97
123
  this.flow.remove.map.start(origin[1], origin[2], origin[3]);
98
124
  this.flow.remove.noRemoveMap.start(origin[1], origin[2], origin[3]);
125
+ this.bounds.start(origin[0]);
99
126
  this.clear();
100
127
  }
101
128
  clear() {
102
129
  this.rgb.clear();
103
130
  this.sun.clear();
104
131
  this.flow.clear();
105
- this.bounds.reset();
106
132
  }
107
133
  }
108
134
  class FlowQueues {
@@ -1,13 +1,11 @@
1
1
  import { EngineSettings as ES } from "../../Settings/EngineSettings.js";
2
2
  import { $3dCardinalNeighbors } from "../../Math/CardinalNeighbors.js";
3
3
  import { UpdateTask } from "./UpdateTask.js";
4
- import { SubstanceDataTool } from "../../Tools/Data/SubstanceDataTool.js";
5
4
  import { RGBRemove, RGBUpdate } from "../Propagation/Illumanation/RGBUpdate.js";
6
5
  import { SunRemove, SunUpdate } from "../Propagation/Illumanation/SunUpdate.js";
7
6
  import { FlowUpdate } from "../Propagation/Flow/FlowUpdate.js";
8
7
  import { FlowRemove } from "../Propagation/Flow/FlowRemove.js";
9
8
  const tasks = new UpdateTask();
10
- const substanceData = new SubstanceDataTool();
11
9
  const updateLightTask = (tasks) => {
12
10
  let doRGB = ES.doRGBPropagation;
13
11
  let doSun = ES.doSunPropagation;
@@ -38,9 +36,9 @@ export async function EreaseAndUpdate(location) {
38
36
  let voxel = tasks.sDataCursor.getVoxel(x, y, z);
39
37
  if (!voxel)
40
38
  return false;
41
- substanceData.setSubstance(voxel.getSubstance());
39
+ const substanceData = voxel.getSubstanceData();
42
40
  if (!voxel.isAir() && ES.doFlow && voxel.isRenderable()) {
43
- if (substanceData.isLiquid()) {
41
+ if (substanceData["dve_is_liquid"]) {
44
42
  FlowRemove(tasks);
45
43
  return tasks;
46
44
  }
@@ -70,6 +68,13 @@ export async function EreaseAndUpdate(location) {
70
68
  SunUpdate(tasks);
71
69
  }
72
70
  }
71
+ tasks.bounds.update(x, y, z);
72
+ tasks.bounds.update(x + 1, y + 1, z + 1);
73
+ for (let i = 0; i < $3dCardinalNeighbors.length; i++) {
74
+ tasks.sDataCursor
75
+ .getVoxel($3dCardinalNeighbors[i][0] + x, $3dCardinalNeighbors[i][1] + y, $3dCardinalNeighbors[i][2] + z)
76
+ ?.updateVoxel(2);
77
+ }
73
78
  return tasks;
74
79
  }
75
80
  export async function PaintAndUpdate(data) {
@@ -107,6 +112,7 @@ export async function PaintAndUpdate(data) {
107
112
  voxel.setLevel(raw[2]);
108
113
  voxel.setState(raw[3]);
109
114
  voxel.setMod(raw[4]);
115
+ voxel.process();
110
116
  if (raw[3] > 0 && voxel.canHaveSecondaryVoxel()) {
111
117
  voxel.setSecondary(true);
112
118
  voxel.setId(raw[5]);
@@ -128,11 +134,17 @@ export async function PaintAndUpdate(data) {
128
134
  }
129
135
  voxel = tasks.sDataCursor.getVoxel(x, y, z);
130
136
  if (ES.doFlow) {
131
- if (!voxel.isAir() &&
132
- substanceData.setSubstance(voxel.getSubstance()).isLiquid()) {
137
+ if (!voxel.isAir() && voxel.getSubstanceData()["dve_is_liquid"]) {
133
138
  FlowUpdate(tasks);
134
139
  }
135
140
  }
141
+ tasks.bounds.update(x, y, z);
142
+ tasks.bounds.update(x + 1, y + 1, z + 1);
143
+ for (let i = 0; i < $3dCardinalNeighbors.length; i++) {
144
+ tasks.sDataCursor
145
+ .getVoxel($3dCardinalNeighbors[i][0] + x, $3dCardinalNeighbors[i][1] + y, $3dCardinalNeighbors[i][2] + z)
146
+ ?.updateVoxel(2);
147
+ }
136
148
  return tasks;
137
149
  }
138
150
  export async function VoxelUpdate(data) {
@@ -155,9 +167,11 @@ export async function VoxelUpdate(data) {
155
167
  }
156
168
  }
157
169
  if (ES.doFlow) {
158
- if (substanceData.setSubstance(voxel.getSubstance()).isLiquid()) {
170
+ if (voxel.getSubstanceData()["dve_is_solid"]) {
159
171
  FlowUpdate(tasks);
160
172
  }
161
173
  }
174
+ tasks.bounds.update(x, y, z);
175
+ tasks.bounds.update(x + 1, y + 1, z + 1);
162
176
  return tasks;
163
177
  }
@@ -56,7 +56,7 @@ export class WorldGenBrush extends BrushTool {
56
56
  }
57
57
  getUpdatedSections() {
58
58
  const queue = this.tasks.bounds.getSections();
59
- this.tasks.bounds.reset();
59
+ this.tasks.bounds.start();
60
60
  return queue;
61
61
  }
62
62
  update() {
@@ -64,6 +64,7 @@ export class WorldGenBrush extends BrushTool {
64
64
  if (!voxel)
65
65
  return false;
66
66
  const sl = voxel.getLight();
67
+ voxel.updateVoxel(2);
67
68
  if (lightData.hasRGBLight(sl)) {
68
69
  this.tasks.rgb.update.push(this.x, this.y, this.z);
69
70
  // Propagation.instance.rgbUpdate(this.tasks);
@@ -1,7 +1,7 @@
1
1
  import { TemplateVoxelCursor } from "./TemplateVoxelCursor";
2
- import { DataCursorInterface } from "../../Data/Cursor/DataCursor.interface";
2
+ import { DataCursorInterface } from "../../Voxels/Cursor/DataCursor.interface";
3
3
  import { FullVoxelTemplate } from "Templates/FullVoxelTemplate";
4
- export declare class TemplateCursor extends DataCursorInterface {
4
+ export declare class TemplateCursor implements DataCursorInterface {
5
5
  _voxelIndex: number;
6
6
  _template: FullVoxelTemplate | null;
7
7
  private voxel;
@@ -1,6 +1,5 @@
1
1
  import { TemplateVoxelCursor } from "./TemplateVoxelCursor";
2
- import { DataCursorInterface } from "../../Data/Cursor/DataCursor.interface";
3
- export class TemplateCursor extends DataCursorInterface {
2
+ export class TemplateCursor {
4
3
  _voxelIndex = 0;
5
4
  _template = null;
6
5
  voxel = new TemplateVoxelCursor(this);
@@ -2,7 +2,7 @@ import { Flat3DIndex, Traverse } from "@amodx/math";
2
2
  import { StringPalette } from "../../Util/StringPalette";
3
3
  import { VoxelTemplate } from "../VoxelTemplate";
4
4
  import { NumberPalette } from "../../Util/NumberPalette";
5
- import { convertToPaletteBuffer } from "../../Data/Functions/Palettes";
5
+ import { convertToPaletteBuffer } from "../../Util/Binary/Palettes";
6
6
  import { WorldCursor } from "../../World";
7
7
  export default function CreateTemplate(dimension, start, end) {
8
8
  const dataTool = new WorldCursor();
@@ -1,10 +1,9 @@
1
1
  import { Flat3DIndex, Traverse } from "@amodx/math";
2
2
  import { StringPalette } from "../Util/StringPalette";
3
3
  import { NumberPalette } from "../Util/NumberPalette";
4
- import { VoxelPalette } from "../Voxels/Palettes/VoxelPalette";
5
- import { VoxelStruct } from "../Voxels/Structs/VoxelStruct";
6
- import { VoxelStructIds } from "../Voxels/Types/Voxel.types";
7
- import { getPaletteArray } from "../Data/Functions/Palettes";
4
+ import { getPaletteArray } from "../Util/Binary/Palettes";
5
+ import { VoxelPalettesRegister } from "../Voxels/Data/VoxelPalettesRegister";
6
+ import { VoxelTagsRegister } from "../Voxels/Data/VoxelTagsRegister";
8
7
  export class VoxelTemplate {
9
8
  index = Flat3DIndex.GetXZYOrder();
10
9
  size;
@@ -49,7 +48,7 @@ export class VoxelTemplate {
49
48
  }
50
49
  getId(index) {
51
50
  const ids = this.ids;
52
- return VoxelPalette.ids.getNumberId(this.idPalette.getStringId(typeof ids == "number" ? ids : ids[index]));
51
+ return VoxelPalettesRegister.voxels.getNumberId(this.idPalette.getStringId(typeof ids == "number" ? ids : ids[index]));
53
52
  }
54
53
  getState(index) {
55
54
  const state = this.state;
@@ -65,9 +64,8 @@ export class VoxelTemplate {
65
64
  }
66
65
  getSecondary(id, index) {
67
66
  const secondary = this.secondary;
68
- VoxelStruct.setVoxel(id);
69
- if (VoxelStruct.instance[VoxelStructIds.canHaveSecondary] == 1) {
70
- return VoxelPalette.ids.getNumberId(this.secondaryIdPalette.getStringId(typeof secondary == "number" ? secondary : secondary[index]));
67
+ if (VoxelTagsRegister.VoxelTags[id]["dve_can_have_secondary"]) {
68
+ return VoxelPalettesRegister.voxels.getNumberId(this.secondaryIdPalette.getStringId(typeof secondary == "number" ? secondary : secondary[index]));
71
69
  }
72
70
  return this.secondaryStatePalette.getValue(typeof secondary == "number" ? secondary : secondary[index]);
73
71
  }
@@ -1,5 +1,5 @@
1
1
  import { Vec3Array } from "@amodx/math";
2
- import { VoxelDataArrays } from "../World";
2
+ import { VoxelDataArrays } from "../Voxels";
3
3
  export interface VoxelTemplateBuffers {
4
4
  ids: Uint16Array | Uint8Array | number;
5
5
  state: Uint16Array | Uint8Array | number;
@@ -0,0 +1,18 @@
1
+ import { Vec2Array } from "@amodx/math";
2
+ import { TextureId } from "../../Textures/Texture.types";
3
+ import { CompiledTextureAnimation } from "./CompiledTextureAnimation";
4
+ import { TextureAnimationTexture } from "./TextureAnimationTexture";
5
+ export declare class CompiledTexture {
6
+ id: string;
7
+ static GetAtlasIndex: (x: number, y: number, boundsX: number) => number;
8
+ static GetAtlasPosition: (index: number, boundsX: number, position?: Vec2Array) => Vec2Array;
9
+ images: HTMLImageElement[];
10
+ atlasSizeMap: Record<string, [width: number, height: number]>;
11
+ textureMap: Record<string, number>;
12
+ animations: CompiledTextureAnimation[];
13
+ shaderTexture: any;
14
+ animatedTexture: TextureAnimationTexture;
15
+ constructor(id: string);
16
+ getTextureIndex(id: TextureId): number;
17
+ getTexturePath(id: TextureId): string;
18
+ }
@@ -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
+ }