@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
@@ -4,7 +4,6 @@ import { getInterpolationValue, shouldCauseFlip, } from "../../Common/Calc/CalcC
4
4
  import { QuadVoxelGometryInputs, } from "../../../../Models/Input/QuadVoxelGometryInputs";
5
5
  import { GeoemtryNode } from "../GeometryNode";
6
6
  import { GetQuadGeometryData } from "../../Common/QuadGeometryNode";
7
- import { UpdateBounds } from "../../Common/BoundsFunctions";
8
7
  import { VoxelLightData } from "../../../../Voxels/Cursor/VoxelLightData";
9
8
  const ArgIndexes = QuadVoxelGometryInputs.ArgIndexes;
10
9
  export class RulelessQuadVoxelGeometryNode extends GeoemtryNode {
@@ -14,8 +13,6 @@ export class RulelessQuadVoxelGeometryNode extends GeoemtryNode {
14
13
  [0, 0, 0],
15
14
  ];
16
15
  vertexWeights;
17
- worldLight;
18
- worldAO;
19
16
  closestFace;
20
17
  lightData = new VoxelLightData();
21
18
  init() {
@@ -28,11 +25,11 @@ export class RulelessQuadVoxelGeometryNode extends GeoemtryNode {
28
25
  this.closestFace = closestFace;
29
26
  }
30
27
  determineShading() {
31
- const tool = this.tool;
28
+ const tool = this.builder;
32
29
  const lightData = tool.lightData[VoxelFaces.Up];
33
- const noAO = this.tool.voxel.isLightSource() || this.tool.voxel.noAO();
34
- const worldLight = this.worldLight;
35
- const worldAO = this.worldAO;
30
+ const noAO = this.builder.voxel.isLightSource() || this.builder.voxel.noAO();
31
+ const worldLight = this.builder.vars.light;
32
+ const worldAO = this.builder.vars.ao;
36
33
  for (let v = 0; v < 4; v++) {
37
34
  worldAO.vertices[v] = 0;
38
35
  worldLight.vertices[v] = getInterpolationValue(lightData, this.vertexWeights[v]);
@@ -41,40 +38,40 @@ export class RulelessQuadVoxelGeometryNode extends GeoemtryNode {
41
38
  }
42
39
  }
43
40
  shouldFlip() {
44
- if (shouldCauseFlip(this.worldAO.vertices[0], this.worldAO.vertices[1], this.worldAO.vertices[2], this.worldAO.vertices[3]))
41
+ const worldLight = this.builder.vars.light;
42
+ const worldAO = this.builder.vars.ao;
43
+ if (shouldCauseFlip(worldAO.vertices[0], worldAO.vertices[1], worldAO.vertices[2], worldAO.vertices[3]))
45
44
  return true;
46
- return (shouldCauseFlip(this.lightData.getS(this.worldLight.vertices[0]), this.lightData.getS(this.worldLight.vertices[1]), this.lightData.getS(this.worldLight.vertices[2]), this.lightData.getS(this.worldLight.vertices[3])) ||
47
- shouldCauseFlip(this.lightData.sumRGB(this.worldLight.vertices[0]), this.lightData.sumRGB(this.worldLight.vertices[1]), this.lightData.sumRGB(this.worldLight.vertices[2]), this.lightData.sumRGB(this.worldLight.vertices[3])));
45
+ return (shouldCauseFlip(this.lightData.getS(worldLight.vertices[0]), this.lightData.getS(worldLight.vertices[1]), this.lightData.getS(worldLight.vertices[2]), this.lightData.getS(worldLight.vertices[3])) ||
46
+ shouldCauseFlip(this.lightData.sumRGB(worldLight.vertices[0]), this.lightData.sumRGB(worldLight.vertices[1]), this.lightData.sumRGB(worldLight.vertices[2]), this.lightData.sumRGB(worldLight.vertices[3])));
48
47
  }
49
- add(tool, originHash, origin, args) {
50
- this.tool = tool;
51
- this.origin = tool.position;
52
- this.worldAO = tool.vars.ao;
53
- this.worldLight = tool.vars.light;
54
- if (args[ArgIndexes.Enabled]) {
55
- tool.calculateFaceData(this.closestFace);
56
- this.determineShading();
57
- const quad = this.quad;
58
- quad.flip = this.shouldFlip() || args[ArgIndexes.Fliped];
59
- tool.vars.textureIndex = args[ArgIndexes.Texture];
60
- quad.doubleSided = args[ArgIndexes.DoubleSided];
61
- const uvs = args[ArgIndexes.UVs];
62
- //1
63
- quad.uvs.vertices[0].x = uvs[0][0];
64
- quad.uvs.vertices[0].y = uvs[0][1];
65
- //2
66
- quad.uvs.vertices[1].x = uvs[1][0];
67
- quad.uvs.vertices[1].y = uvs[1][1];
68
- //3
69
- quad.uvs.vertices[2].x = uvs[2][0];
70
- quad.uvs.vertices[2].y = uvs[2][1];
71
- //4
72
- quad.uvs.vertices[3].x = uvs[3][0];
73
- quad.uvs.vertices[3].y = uvs[3][1];
74
- VoxelGeometryBuilder.addQuad(tool, origin, quad);
75
- UpdateBounds(tool, origin, this.quadBounds);
76
- }
77
- this.worldLight.setAll(0);
78
- this.worldAO.setAll(0);
48
+ add(args) {
49
+ if (!args[ArgIndexes.Enabled])
50
+ return false;
51
+ const tool = this.builder;
52
+ tool.calculateFaceData(this.closestFace);
53
+ this.determineShading();
54
+ const quad = this.quad;
55
+ quad.flip = this.shouldFlip() || args[ArgIndexes.Fliped];
56
+ tool.vars.textureIndex = args[ArgIndexes.Texture];
57
+ quad.doubleSided = args[ArgIndexes.DoubleSided];
58
+ const uvs = args[ArgIndexes.UVs];
59
+ //1
60
+ quad.uvs.vertices[0].x = uvs[0][0];
61
+ quad.uvs.vertices[0].y = uvs[0][1];
62
+ //2
63
+ quad.uvs.vertices[1].x = uvs[1][0];
64
+ quad.uvs.vertices[1].y = uvs[1][1];
65
+ //3
66
+ quad.uvs.vertices[2].x = uvs[2][0];
67
+ quad.uvs.vertices[2].y = uvs[2][1];
68
+ //4
69
+ quad.uvs.vertices[3].x = uvs[3][0];
70
+ quad.uvs.vertices[3].y = uvs[3][1];
71
+ VoxelGeometryBuilder.addQuad(tool, tool.position, quad);
72
+ this.builder.updateBounds(this.quadBounds);
73
+ this.builder.vars.light.setAll(0);
74
+ this.builder.vars.ao.setAll(0);
75
+ return true;
79
76
  }
80
77
  }
@@ -1,4 +1,4 @@
1
- import type { TextureId } from "../../Textures/Texture.types.js";
1
+ import type { TextureId } from "../../../Textures/Texture.types.js";
2
2
  export declare class OutlinedVoxelTool {
3
3
  static _currentTexts: number[];
4
4
  static setCurrentTextures(textures: number[]): void;
@@ -1,4 +1,4 @@
1
- import { VoxelFaces } from "../../Math/index.js";
1
+ import { VoxelFaces } from "../../../Math/index.js";
2
2
  /*
3
3
  0 -> normal direction
4
4
  1 -> top right
@@ -0,0 +1,6 @@
1
+ import { VoxelModelBuilder } from "./VoxelModelBuilder";
2
+ export declare class RenderedMaterials {
3
+ static meshersMap: Map<string, VoxelModelBuilder>;
4
+ static meshers: VoxelModelBuilder[];
5
+ static register(materials: string[]): void;
6
+ }
@@ -1,10 +1,10 @@
1
- import { VoxelMesherDataTool } from "./Tools/VoxelMesherDataTool";
1
+ import { VoxelModelBuilder } from "./VoxelModelBuilder";
2
2
  export class RenderedMaterials {
3
3
  static meshersMap = new Map();
4
4
  static meshers = [];
5
5
  static register(materials) {
6
6
  for (let i = 0; i < materials.length; i++) {
7
- const newTool = new VoxelMesherDataTool(materials[i], i);
7
+ const newTool = new VoxelModelBuilder(materials[i], i);
8
8
  this.meshersMap.set(materials[i], newTool);
9
9
  this.meshers[i] = newTool;
10
10
  }
@@ -1,5 +1,4 @@
1
- import { TextureRegister } from "../../Textures/TextureRegister";
2
- import { VoxelMesherDataTool } from "../../Mesher/Tools/VoxelMesherDataTool";
1
+ import { VoxelModelBuilder } from "./VoxelModelBuilder";
3
2
  import { CompiledVoxelModelInputData, CompiledVoxelModelData } from "../../Voxels/Types/VoxelModelCompiledData.types";
4
3
  import { StateSchema } from "../../Voxels/State/Schema/StateSchema";
5
4
  import { StateTreeReader } from "../../Voxels/State/StateTreeReader";
@@ -8,6 +7,7 @@ import { VoxelModelEffect } from "./VoxelModelEffect";
8
7
  import { CondtionalTreeReader } from "../../Voxels/State/CondiotnalTreeReader";
9
8
  export declare class VoxelConstructor {
10
9
  id: string;
10
+ builder: VoxelModelBuilder;
11
11
  data: CompiledVoxelModelData;
12
12
  isModel: true;
13
13
  geometries: number[][];
@@ -20,9 +20,8 @@ export declare class VoxelConstructor {
20
20
  effects: VoxelModelEffect;
21
21
  shapeStateTree: StateTreeReader;
22
22
  condtioanlShapeStateTree: CondtionalTreeReader;
23
- constructor(id: string, data: CompiledVoxelModelData, voxleData: CompiledVoxelModelInputData);
23
+ constructor(id: string, builder: VoxelModelBuilder, data: CompiledVoxelModelData, voxleData: CompiledVoxelModelInputData);
24
24
  isShapeStateFaceTransparent(modState: number, shapeState: number, geoId: number, faceIndex: number): boolean;
25
25
  isCondtionalStateFaceTransparent(modState: number, shapeState: number, geoId: number, faceIndex: number): boolean;
26
- process(tool: VoxelMesherDataTool): void;
27
- onTexturesRegistered(textureManager: typeof TextureRegister): void;
26
+ process(): boolean;
28
27
  }
@@ -1,5 +1,4 @@
1
1
  import { VoxelModelConstructorRegister } from "./VoxelModelConstructorRegister";
2
- import { VoxelGeometryLookUp } from "./VoxelGeometryLookUp";
3
2
  import { StateSchema } from "../../Voxels/State/Schema/StateSchema";
4
3
  import { StateTreeReader } from "../../Voxels/State/StateTreeReader";
5
4
  import { VoxelFaceTransparentResultsIndex } from "../../Models/Indexing/VoxelFaceTransparentResultsIndex";
@@ -7,6 +6,7 @@ import { VoxelModelEffect } from "./VoxelModelEffect";
7
6
  import { CondtionalTreeReader } from "../../Voxels/State/CondiotnalTreeReader";
8
7
  export class VoxelConstructor {
9
8
  id;
9
+ builder;
10
10
  data;
11
11
  isModel = true;
12
12
  geometries = [];
@@ -19,8 +19,9 @@ export class VoxelConstructor {
19
19
  effects;
20
20
  shapeStateTree;
21
21
  condtioanlShapeStateTree;
22
- constructor(id, data, voxleData) {
22
+ constructor(id, builder, data, voxleData) {
23
23
  this.id = id;
24
+ this.builder = builder;
24
25
  this.data = data;
25
26
  this.baseInputMap = voxleData.baseGeometryInputMap;
26
27
  this.conditonalInputMap = voxleData.condiotnalGeometryInputMap;
@@ -38,10 +39,12 @@ export class VoxelConstructor {
38
39
  isCondtionalStateFaceTransparent(modState, shapeState, geoId, faceIndex) {
39
40
  return (this.transparentIndex.getValue(modState, this.data.relativeGeometryByteIndexMap[this.data.condiotnalShapeStateRelativeGeometryMap[shapeState][geoId]], faceIndex) == 1);
40
41
  }
41
- process(tool) {
42
- const hashed = VoxelGeometryLookUp.getHash(tool.nVoxel, tool.position.x, tool.position.y, tool.position.z);
43
- const treeState = VoxelGeometryLookUp.space.stateCache[hashed];
44
- const modState = VoxelGeometryLookUp.space.modCache[hashed];
42
+ process() {
43
+ let added = false;
44
+ const builder = this.builder;
45
+ const hashed = builder.space.getHash(builder.nVoxel, builder.position.x, builder.position.y, builder.position.z);
46
+ const treeState = builder.space.stateCache[hashed];
47
+ const modState = builder.space.modCache[hashed];
45
48
  if (treeState > -1) {
46
49
  const geoLinks = this.data.shapeStateMap[treeState];
47
50
  const geometries = this.data.shapeStateGeometryMap[treeState];
@@ -53,11 +56,15 @@ export class VoxelConstructor {
53
56
  const geomtry = VoxelModelConstructorRegister.geometry[geometries[i]];
54
57
  const nodesLength = geomtry.nodes.length;
55
58
  for (let k = 0; k < nodesLength; k++) {
56
- geomtry.nodes[k].add(tool, hashed, tool.origin, geoInputs[k]);
59
+ const geo = geomtry.nodes[k];
60
+ geo.builder = this.builder;
61
+ const addedGeo = geo.add(geoInputs[k]);
62
+ if (addedGeo)
63
+ added = true;
57
64
  }
58
65
  }
59
66
  }
60
- const conditonalTreeState = VoxelGeometryLookUp.space.conditonalStateCache[hashed];
67
+ const conditonalTreeState = builder.space.conditonalStateCache[hashed];
61
68
  if (conditonalTreeState > -1) {
62
69
  const condiotnalNodes = this.data.condiotnalShapeStateMap[conditonalTreeState];
63
70
  const condiotnalNodesLength = condiotnalNodes.length;
@@ -71,13 +78,17 @@ export class VoxelConstructor {
71
78
  const geomtry = VoxelModelConstructorRegister.geometry[this.data.geoLinkMap[nodeId]];
72
79
  const nodesLength = geomtry.nodes.length;
73
80
  for (let k = 0; k < nodesLength; k++) {
74
- geomtry.nodes[k].add(tool, hashed, tool.origin, geoInputs[k]);
81
+ const geo = geomtry.nodes[k];
82
+ geo.builder = this.builder;
83
+ const addedGeo = geo.add(geoInputs[k]);
84
+ if (addedGeo)
85
+ added = true;
75
86
  }
76
87
  }
77
88
  }
78
89
  }
79
- this.effects.addEffects(tool.voxel.getState(), tool.origin, tool.effects);
80
- tool.clearCalculatedData();
90
+ this.effects.addEffects(builder.voxel.getState(), builder.origin, builder.effects);
91
+ builder.clearCalculatedData();
92
+ return added;
81
93
  }
82
- onTexturesRegistered(textureManager) { }
83
94
  }
@@ -1,30 +1,22 @@
1
- import { DataCursorInterface } from "../../Data/Cursor/DataCursor.interface";
1
+ import { DataCursorInterface } from "../../Voxels/Cursor/DataCursor.interface";
2
2
  import { Vec3Array, Vector3Like } from "@amodx/math";
3
3
  import { VoxelCursor } from "../../Voxels/Cursor/VoxelCursor";
4
- export declare class VoxelGeometryLookUpSpace {
4
+ export declare class VoxelGeometryBuilderCacheSpace {
5
5
  bounds: Vector3Like;
6
6
  foundHash: Uint8Array;
7
- voxelHash: Uint16Array;
7
+ voxelCache: Uint16Array;
8
8
  modCache: Int32Array;
9
9
  stateCache: Int32Array;
10
10
  conditonalStateCache: Int32Array;
11
11
  noCastAO: Uint8Array;
12
12
  offset: Vec3Array;
13
+ voxelCursor: VoxelCursor;
13
14
  constructor(bounds: Vector3Like);
14
15
  start(x: number, y: number, z: number): void;
15
16
  getIndex(x: number, y: number, z: number): number;
16
17
  getConstructor(index: number): import("./VoxelConstructor").VoxelConstructor | null;
17
18
  getGeomtry(index: number): false | number[];
18
19
  getConditionalGeomtry(index: number): false | number[][];
19
- }
20
- export declare class VoxelGeometryLookUp {
21
- static space: VoxelGeometryLookUpSpace | null;
22
- static voxelCursor: VoxelCursor;
23
- static createSpace(x: number, y: number, z: number): VoxelGeometryLookUpSpace;
24
- static init(): void;
25
- static start(space: VoxelGeometryLookUpSpace): void;
26
- static isRulesless(geoId: number): boolean;
27
- static stop(): void;
28
- static getHash(dataCursor: DataCursorInterface, x: number, y: number, z: number): number;
29
- private static hashState;
20
+ getHash(dataCursor: DataCursorInterface, x: number, y: number, z: number): number;
21
+ private hashState;
30
22
  }
@@ -1,20 +1,21 @@
1
1
  import { VoxelModelConstructorRegister } from "./VoxelModelConstructorRegister";
2
2
  import { VoxelCursor } from "../../Voxels/Cursor/VoxelCursor";
3
3
  import { GetYXZOrderArrayIndex } from "../../Math/Indexing";
4
- export class VoxelGeometryLookUpSpace {
4
+ export class VoxelGeometryBuilderCacheSpace {
5
5
  bounds;
6
6
  foundHash;
7
- voxelHash;
7
+ voxelCache;
8
8
  modCache;
9
9
  stateCache;
10
10
  conditonalStateCache;
11
11
  noCastAO;
12
12
  offset = [0, 0, 0];
13
+ voxelCursor = new VoxelCursor();
13
14
  constructor(bounds) {
14
15
  this.bounds = bounds;
15
16
  const volume = bounds.x * bounds.y * bounds.z;
16
17
  this.foundHash = new Uint8Array(volume);
17
- this.voxelHash = new Uint16Array(volume);
18
+ this.voxelCache = new Uint16Array(volume);
18
19
  this.modCache = new Int32Array(volume);
19
20
  this.stateCache = new Int32Array(volume);
20
21
  this.conditonalStateCache = new Int32Array(volume);
@@ -25,7 +26,7 @@ export class VoxelGeometryLookUpSpace {
25
26
  this.offset[1] = y;
26
27
  this.offset[2] = z;
27
28
  this.foundHash.fill(0);
28
- this.voxelHash.fill(0);
29
+ this.voxelCache.fill(0);
29
30
  this.modCache.fill(-1);
30
31
  this.stateCache.fill(-1);
31
32
  this.conditonalStateCache.fill(-1);
@@ -35,72 +36,53 @@ export class VoxelGeometryLookUpSpace {
35
36
  return GetYXZOrderArrayIndex(x - this.offset[0], y - this.offset[1], z - this.offset[2], this.bounds.x, this.bounds.y, this.bounds.z);
36
37
  }
37
38
  getConstructor(index) {
38
- if (this.foundHash[index] !== 2)
39
+ if (this.foundHash[index] < 2)
39
40
  return null;
40
- return VoxelModelConstructorRegister.constructorsPaltte[this.voxelHash[index]];
41
+ return VoxelModelConstructorRegister.constructorsPaltte[this.voxelCache[index]];
41
42
  }
42
43
  getGeomtry(index) {
43
- if (this.foundHash[index] !== 2)
44
+ if (this.foundHash[index] < 2)
44
45
  return false;
45
- return VoxelModelConstructorRegister.constructorsPaltte[this.voxelHash[index]].data.shapeStateGeometryMap[this.stateCache[index]];
46
+ return VoxelModelConstructorRegister.constructorsPaltte[this.voxelCache[index]].data.shapeStateGeometryMap[this.stateCache[index]];
46
47
  }
47
48
  getConditionalGeomtry(index) {
48
- if (this.foundHash[index] !== 2)
49
+ if (this.foundHash[index] < 2)
49
50
  return false;
50
- return VoxelModelConstructorRegister.constructorsPaltte[this.voxelHash[index]].data.condiotnalShapeStateGeometryMap[this.conditonalStateCache[index]];
51
+ return VoxelModelConstructorRegister.constructorsPaltte[this.voxelCache[index]].data.condiotnalShapeStateGeometryMap[this.conditonalStateCache[index]];
51
52
  }
52
- }
53
- export class VoxelGeometryLookUp {
54
- static space = null;
55
- static voxelCursor = new VoxelCursor();
56
- static createSpace(x, y, z) {
57
- return new VoxelGeometryLookUpSpace({ x, y, z });
58
- }
59
- static init() { }
60
- static start(space) {
61
- this.space = space;
62
- }
63
- static isRulesless(geoId) {
64
- return VoxelModelConstructorRegister.rulesless[geoId] == true;
65
- }
66
- static stop() { }
67
- static getHash(dataCursor, x, y, z) {
68
- if (!this.space)
69
- throw new Error(`Voxel geomtry look up must have space set`);
70
- const hashed = this.space.getIndex(x, y, z);
71
- if (this.space.foundHash[hashed] == 0) {
53
+ getHash(dataCursor, x, y, z) {
54
+ const hashed = this.getIndex(x, y, z);
55
+ if (this.foundHash[hashed] == 0) {
72
56
  this.hashState(dataCursor, hashed, x, y, z);
73
57
  }
74
58
  return hashed;
75
59
  }
76
- static hashState(dataCursor, index, x, y, z) {
77
- if (!this.space)
78
- throw new Error(`Voxel geomtry look up must have space set`);
79
- if (this.space.foundHash[index] == 1)
60
+ hashState(dataCursor, index, x, y, z) {
61
+ if (this.foundHash[index] == 1)
80
62
  return -1;
81
- if (this.space.foundHash[index] == 2)
82
- return this.space.stateCache[index];
63
+ if (this.foundHash[index] == 2)
64
+ return this.stateCache[index];
83
65
  const voxel = dataCursor.getVoxel(x, y, z);
84
66
  if (!voxel || !voxel.isRenderable()) {
85
- this.space.foundHash[index] = 1;
67
+ this.foundHash[index] = 1;
86
68
  return -1;
87
69
  }
88
70
  const voxelId = voxel.getId();
89
71
  const voxelConstructor = VoxelModelConstructorRegister.constructorsPaltte[voxelId];
90
72
  if (!voxelConstructor) {
91
- this.space.foundHash[index] = 1;
73
+ this.foundHash[index] = 1;
92
74
  return -1;
93
75
  }
94
- this.space.voxelHash[index] = voxelId;
95
- this.space.foundHash[index] = 2;
76
+ this.voxelCache[index] = voxelId;
77
+ this.foundHash[index] = 2;
96
78
  //no ao
97
- this.space.noCastAO[index] = voxel.isLightSource() || voxel.noAO() ? 1 : 0;
79
+ this.noCastAO[index] = voxel.isLightSource() || voxel.noAO() ? 1 : 0;
98
80
  //state
99
81
  const state = voxelConstructor.shapeStateTree.getState(voxel.getState());
100
- this.space.stateCache[index] = state;
82
+ this.stateCache[index] = state;
101
83
  //mod
102
84
  const mod = voxelConstructor.modTree.getState(voxel.getMod());
103
- this.space.modCache[index] = mod;
85
+ this.modCache[index] = mod;
104
86
  this.voxelCursor.copy(voxel).process();
105
87
  voxelConstructor.schema.position.x = x;
106
88
  voxelConstructor.schema.position.y = y;
@@ -108,7 +90,7 @@ export class VoxelGeometryLookUp {
108
90
  voxelConstructor.schema.voxel = this.voxelCursor;
109
91
  voxelConstructor.schema.dataCursor = dataCursor;
110
92
  const conditonalState = voxelConstructor.condtioanlShapeStateTree.getState();
111
- this.space.conditonalStateCache[index] = conditonalState;
93
+ this.conditonalStateCache[index] = conditonalState;
112
94
  return 1;
113
95
  }
114
96
  }
@@ -1,25 +1,26 @@
1
- import { MesherDataTool } from "../Geomtry/Tools/MesherDataTools";
2
1
  import { QuadScalarVertexData } from "../Geomtry/Primitives/QuadVertexData";
3
2
  import { VoxelFaces } from "../../Math";
4
3
  import { QuadVerticies } from "../Geomtry/Geometry.types";
5
4
  import { VoxelMesh } from "../Geomtry/VoxelMesh";
6
- import { VoxelMeshBVHBuilder } from "./VoxelMeshBVHBuilder";
7
- import { Vec3Array, Vector3Like } from "@amodx/math";
5
+ import { VoxelMeshBVHBuilder } from "../Geomtry/VoxelMeshBVHBuilder";
6
+ import { Vec3Array, Vector3Like, Vector4Like } from "@amodx/math";
8
7
  import { VoxelCursorInterface } from "../../Voxels/Cursor/VoxelCursor.interface.js";
9
- import { DataCursorInterface } from "../../Data/Cursor/DataCursor.interface.js";
8
+ import { DataCursorInterface } from "../../Voxels/Cursor/DataCursor.interface.js";
9
+ import { VoxelGeometryBuilderCacheSpace } from "./VoxelGeometryBuilderCacheSpace";
10
10
  declare class VoxelVars {
11
11
  faceFlipped: boolean;
12
12
  textureIndex: number;
13
+ overlayTextures: Vector4Like;
13
14
  light: QuadScalarVertexData;
14
15
  ao: QuadScalarVertexData;
15
16
  animation: QuadScalarVertexData;
16
17
  level: QuadScalarVertexData;
17
- overlayTextures: QuadScalarVertexData;
18
18
  reset(): void;
19
19
  }
20
- export declare class VoxelMesherDataTool extends MesherDataTool {
20
+ export declare class VoxelModelBuilder {
21
21
  id: string;
22
22
  materialIndex: number;
23
+ space: VoxelGeometryBuilderCacheSpace;
23
24
  voxel: VoxelCursorInterface;
24
25
  nVoxel: DataCursorInterface;
25
26
  /**The current world position */
@@ -41,9 +42,10 @@ export declare class VoxelMesherDataTool extends MesherDataTool {
41
42
  _indexStart: number;
42
43
  startConstruction(): void;
43
44
  endConstruction(): boolean;
45
+ _boundsUpdate: boolean;
46
+ updateBounds(bounds: [Vec3Array, Vec3Array]): void;
44
47
  calculateFaceData(direction: VoxelFaces): true | undefined;
45
48
  clearCalculatedData(): void;
46
- reset(): void;
47
- resetAll(): this;
49
+ clear(): this;
48
50
  }
49
51
  export {};
@@ -1,28 +1,31 @@
1
1
  //tools
2
- import { MesherDataTool } from "../Geomtry/Tools/MesherDataTools";
3
2
  //data
4
3
  import { QuadScalarVertexData } from "../Geomtry/Primitives/QuadVertexData";
5
4
  import { VoxelFaces, VoxelFacesArray } from "../../Math";
6
5
  import { QuadVerticies } from "../Geomtry/Geometry.types";
7
- import { FaceDataCalc } from "../Models/Common/Calc/FaceDataCalc.js";
6
+ import calculateFaceData from "./Common/Calc/FaceDataCalc.js";
8
7
  import { VoxelMesh } from "../Geomtry/VoxelMesh";
9
- import { Vector3Like } from "@amodx/math";
8
+ import { Vector3Like, Vector4Like } from "@amodx/math";
10
9
  class VoxelVars {
11
10
  faceFlipped = false;
12
11
  textureIndex = 0;
12
+ overlayTextures = Vector4Like.Create();
13
13
  light = new QuadScalarVertexData();
14
14
  ao = new QuadScalarVertexData();
15
15
  animation = new QuadScalarVertexData();
16
16
  level = new QuadScalarVertexData();
17
- overlayTextures = new QuadScalarVertexData();
18
17
  reset() {
19
18
  this.faceFlipped = false;
20
19
  this.textureIndex = 0;
20
+ this.overlayTextures.x = 0;
21
+ this.overlayTextures.y = 0;
22
+ this.overlayTextures.z = 0;
21
23
  }
22
24
  }
23
- export class VoxelMesherDataTool extends MesherDataTool {
25
+ export class VoxelModelBuilder {
24
26
  id;
25
27
  materialIndex;
28
+ space;
26
29
  voxel;
27
30
  nVoxel;
28
31
  /**The current world position */
@@ -37,11 +40,10 @@ export class VoxelMesherDataTool extends MesherDataTool {
37
40
  lightData;
38
41
  effects;
39
42
  constructor(id, materialIndex) {
40
- super();
41
- this.id = id;
42
- this.materialIndex = materialIndex;
43
43
  // this.faceDataOverride.currentVoxel = this.voxel;
44
44
  // this.faceDataOverride.neighborVoxel = this.nVoxel;
45
+ this.id = id;
46
+ this.materialIndex = materialIndex;
45
47
  this.dataCalculated = [];
46
48
  for (const face of VoxelFacesArray) {
47
49
  this.dataCalculated[face] = false;
@@ -70,7 +72,6 @@ export class VoxelMesherDataTool extends MesherDataTool {
70
72
  this.lightData[face][QuadVerticies.BottomLeft] = 0;
71
73
  this.lightData[face][QuadVerticies.BottomRight] = 0;
72
74
  }
73
- this.startNewMesh(new VoxelMesh());
74
75
  }
75
76
  bounds = {
76
77
  min: [0, 0, 0],
@@ -78,27 +79,54 @@ export class VoxelMesherDataTool extends MesherDataTool {
78
79
  };
79
80
  _indexStart = 0;
80
81
  startConstruction() {
81
- this._indexStart = this.mesh.indices.length;
82
+ this._indexStart = this.mesh.indicieCount;
82
83
  this.bounds.min[0] = Infinity;
83
84
  this.bounds.min[1] = Infinity;
84
85
  this.bounds.min[2] = Infinity;
85
86
  this.bounds.max[0] = -Infinity;
86
87
  this.bounds.max[1] = -Infinity;
87
88
  this.bounds.max[2] = -Infinity;
89
+ this._boundsUpdate = true;
88
90
  }
89
91
  endConstruction() {
90
- if (this.bounds.min.includes(Infinity) ||
91
- this.bounds.max.includes(-Infinity))
92
- return false;
92
+ this.vars.reset();
93
93
  if (this.bvhTool) {
94
- this.bvhTool.updateVoxel(this.position.x, this.position.y, this.position.z, this._indexStart, this.materialIndex, this.mesh.indices.length, this.bounds.min[0], this.bounds.min[1], this.bounds.min[2], this.bounds.max[0], this.bounds.max[1], this.bounds.max[2]);
94
+ if (!this._boundsUpdate)
95
+ return false;
96
+ this.bvhTool.updateVoxel(this.position.x, this.position.y, this.position.z, this._indexStart, this.materialIndex, this.mesh.indicieCount, this.bounds.min[0], this.bounds.min[1], this.bounds.min[2], this.bounds.max[0], this.bounds.max[1], this.bounds.max[2]);
97
+ this.bvhTool.structCursor.setIndex(0);
98
+ this.mesh.minBounds.x = this.bvhTool.structCursor.minX;
99
+ this.mesh.minBounds.y = this.bvhTool.structCursor.minY;
100
+ this.mesh.minBounds.z = this.bvhTool.structCursor.minZ;
101
+ this.mesh.maxBounds.x = this.bvhTool.structCursor.maxX;
102
+ this.mesh.maxBounds.y = this.bvhTool.structCursor.maxY;
103
+ this.mesh.maxBounds.z = this.bvhTool.structCursor.maxZ;
95
104
  }
96
105
  return true;
97
106
  }
107
+ _boundsUpdate = false;
108
+ updateBounds(bounds) {
109
+ const origin = this.origin;
110
+ //min
111
+ if (origin.x + bounds[0][0] < this.bounds.min[0])
112
+ this.bounds.min[0] = origin.x + bounds[0][0];
113
+ if (origin.y + bounds[0][1] < this.bounds.min[1])
114
+ this.bounds.min[1] = origin.y + bounds[0][1];
115
+ if (origin.z + bounds[0][2] < this.bounds.min[2])
116
+ this.bounds.min[2] = origin.z + bounds[0][2];
117
+ //max
118
+ if (origin.x + bounds[1][0] > this.bounds.max[0])
119
+ this.bounds.max[0] = origin.x + bounds[1][0];
120
+ if (origin.y + bounds[1][1] > this.bounds.max[1])
121
+ this.bounds.max[1] = origin.y + bounds[1][1];
122
+ if (origin.z + bounds[1][2] > this.bounds.max[2])
123
+ this.bounds.max[2] = origin.z + bounds[1][2];
124
+ this._boundsUpdate = true;
125
+ }
98
126
  calculateFaceData(direction) {
99
127
  if (this.dataCalculated[direction])
100
128
  return true;
101
- FaceDataCalc.calculate(direction, this);
129
+ calculateFaceData(direction, this);
102
130
  this.dataCalculated[direction] = true;
103
131
  }
104
132
  clearCalculatedData() {
@@ -109,10 +137,7 @@ export class VoxelMesherDataTool extends MesherDataTool {
109
137
  this.dataCalculated[VoxelFaces.East] = false;
110
138
  this.dataCalculated[VoxelFaces.West] = false;
111
139
  }
112
- reset() {
113
- this.vars.reset();
114
- }
115
- resetAll() {
140
+ clear() {
116
141
  this.vars.reset();
117
142
  this.mesh.clear();
118
143
  return this;
@@ -1,6 +1,6 @@
1
- import { VoxelPalette } from "../../Voxels/Palettes/VoxelPalette";
2
1
  import { StringPalette } from "../../Util/StringPalette";
3
2
  import { VoxelGeometryConstructor } from "./Nodes/VoxelGeometryConstructor";
3
+ import { VoxelPalettesRegister } from "../../Voxels/Data/VoxelPalettesRegister";
4
4
  export class VoxelModelConstructorRegister {
5
5
  static geometryPalette;
6
6
  static geometry = [];
@@ -31,11 +31,11 @@ export class VoxelModelConstructorRegister {
31
31
  if (Array.isArray(voxel)) {
32
32
  for (const vox of voxel) {
33
33
  this.constructors.set(vox.id, vox);
34
- this.constructorsPaltte[VoxelPalette.ids.getNumberId(vox.id)] = vox;
34
+ this.constructorsPaltte[VoxelPalettesRegister.voxels.getNumberId(vox.id)] = vox;
35
35
  }
36
36
  return;
37
37
  }
38
- this.constructorsPaltte[VoxelPalette.ids.getNumberId(voxel.id)] = voxel;
38
+ this.constructorsPaltte[VoxelPalettesRegister.voxels.getNumberId(voxel.id)] = voxel;
39
39
  this.constructors.set(voxel.id, voxel);
40
40
  }
41
41
  static registerGeometry(geometries) {
@@ -42,6 +42,10 @@ export const cube = {
42
42
  type: "int",
43
43
  default: 0,
44
44
  },
45
+ northTexTransparent: {
46
+ type: "boolean",
47
+ default: false,
48
+ },
45
49
  southTex: {
46
50
  type: "texture",
47
51
  },