@divinevoxel/vlox 0.0.72 → 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 (174) hide show
  1. package/Contexts/Render/DivineVoxelEngineRender.d.ts +1 -1
  2. package/Contexts/World/DivineVoxelEngineWorld.d.ts +1 -1
  3. package/Init/StartConstructor.js +6 -4
  4. package/Init/StartWorld.d.ts +1 -1
  5. package/Mesher/Functions/CompactVoxelMesh.d.ts +2 -2
  6. package/Mesher/Functions/CompactVoxelMesh.js +1 -1
  7. package/Mesher/Functions/MeshSection.js +20 -8
  8. package/Mesher/Functions/MeshTexture.d.ts +1 -1
  9. package/Mesher/Functions/MeshTexture.js +3 -4
  10. package/Mesher/Geomtry/Primitives/QuadVertexData.d.ts +12 -10
  11. package/Mesher/Geomtry/Primitives/QuadVertexData.js +49 -56
  12. package/Mesher/Geomtry/VoxelGeometryBuilder.d.ts +2 -2
  13. package/Mesher/Geomtry/VoxelGeometryBuilder.js +2 -2
  14. package/Mesher/Geomtry/VoxelMesh.d.ts +1 -1
  15. package/Mesher/Geomtry/VoxelMesh.js +2 -2
  16. package/Mesher/Geomtry/index.d.ts +0 -1
  17. package/Mesher/Geomtry/index.js +0 -1
  18. package/Mesher/InitMesher.js +1 -1
  19. package/Mesher/InitTask.js +4 -22
  20. package/Mesher/Models/Common/Calc/FaceDataCalc.d.ts +2 -2
  21. package/Mesher/Models/Common/Calc/FaceDataCalc.js +37 -30
  22. package/Mesher/Models/Nodes/Custom/Liquid/FlowGradient.d.ts +2 -2
  23. package/Mesher/Models/Nodes/Custom/Liquid/FlowGradient.js +1 -1
  24. package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +11 -17
  25. package/Mesher/Models/Nodes/GeometryNode.d.ts +2 -2
  26. package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.d.ts +1 -0
  27. package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +24 -12
  28. package/Mesher/{Tools → Models/Protocols}/OutlinedVoxelTool.d.ts +1 -1
  29. package/Mesher/{Tools → Models/Protocols}/OutlinedVoxelTool.js +1 -1
  30. package/Mesher/Models/RenderedMaterials.d.ts +6 -0
  31. package/Mesher/{RenderedMaterials.js → Models/RenderedMaterials.js} +2 -2
  32. package/Mesher/Models/VoxelConstructor.d.ts +3 -3
  33. package/Mesher/Models/VoxelGeometryBuilderCacheSpace.d.ts +1 -3
  34. package/Mesher/Models/VoxelGeometryBuilderCacheSpace.js +0 -23
  35. package/Mesher/{Tools/VoxelMesherDataTool.d.ts → Models/VoxelModelBuilder.d.ts} +4 -5
  36. package/Mesher/{Tools/VoxelMesherDataTool.js → Models/VoxelModelBuilder.js} +11 -7
  37. package/Models/Defaults/CubeVoxelGeometry.js +4 -0
  38. package/Models/Defaults/CubeVoxelModels.js +344 -344
  39. package/Models/Defaults/LiquidVoxelModel.js +2 -2
  40. package/Models/Defaults/PanelVoxelModels.js +432 -432
  41. package/Models/Defaults/StairVoxelModel.js +576 -576
  42. package/Models/Examples.js +469 -456
  43. package/Models/Rules/Functions/BuildFinalInputs.js +9 -7
  44. package/Models/Rules/Functions/BuildGeomtryInputs.js +8 -5
  45. package/Models/Rules/Functions/BuildRules.js +2 -2
  46. package/Models/Rules/{VoxelModelManager.d.ts → VoxelModelRuleBuilderRegister.d.ts} +1 -1
  47. package/Models/Rules/VoxelModelRuleBuilderRegister.js +178 -0
  48. package/Models/VoxelModel.types.d.ts +14 -5
  49. package/Renderer/Classes/SectorMesh.d.ts +3 -4
  50. package/Renderer/Classes/SectorMesh.js +6 -11
  51. package/Renderer/InitTasks.js +6 -7
  52. package/Renderer/MeshManager.js +2 -2
  53. package/Renderer/MeshRegister.js +2 -1
  54. package/Settings/EngineSettings.d.ts +1 -1
  55. package/Settings/EngineSettings.js +3 -5
  56. package/Settings/EngineSettings.types.d.ts +17 -18
  57. package/Settings/EngineSettings.types.js +16 -15
  58. package/Tasks/IWG/IWG.d.ts +2 -1
  59. package/Tasks/IWG/IWG.js +9 -3
  60. package/Tasks/IWG/Internal/Classes/BuildQueue.d.ts +11 -0
  61. package/Tasks/IWG/Internal/Classes/BuildQueue.js +49 -0
  62. package/Tasks/IWG/Internal/Classes/Generator.d.ts +6 -1
  63. package/Tasks/IWG/Internal/Classes/Generator.js +13 -1
  64. package/Tasks/IWG/Internal/Classes/IWGTaskBase.js +2 -2
  65. package/Tasks/IWG/Internal/Functions/runBuildUpdate.js +21 -2
  66. package/Tasks/IWG/Internal/IWGTasks.d.ts +0 -4
  67. package/Tasks/IWG/Internal/IWGTasks.js +0 -10
  68. package/Tasks/IWG/Internal/IWGTools.d.ts +1 -1
  69. package/Tasks/IWG/Procedures/SaveAllSectors.js +2 -0
  70. package/Tasks/Update/UpdateTask.d.ts +3 -1
  71. package/Tasks/Update/UpdateTask.js +28 -2
  72. package/Tasks/Update/VoxelUpdate.js +6 -0
  73. package/Tasks/WorldGeneration/WorldGenBrush.js +1 -1
  74. package/Templates/Cursor/TemplateCursor.d.ts +2 -2
  75. package/Templates/Cursor/TemplateCursor.js +1 -2
  76. package/Templates/VoxelTemplates.types.d.ts +1 -1
  77. package/Textures/Classes/CompiledTexture.d.ts +18 -0
  78. package/Textures/Classes/CompiledTexture.js +50 -0
  79. package/Textures/Classes/CompiledTextureAnimation.d.ts +12 -0
  80. package/Textures/Classes/CompiledTextureAnimation.js +27 -0
  81. package/Textures/Classes/TextureAnimationTexture.d.ts +10 -0
  82. package/Textures/Classes/TextureAnimationTexture.js +32 -0
  83. package/Textures/Functions/BuildTextureData.d.ts +10 -0
  84. package/Textures/Functions/BuildTextureData.js +205 -0
  85. package/Textures/Texture.types.d.ts +50 -64
  86. package/Textures/TextureManager.d.ts +8 -19
  87. package/Textures/TextureManager.js +28 -166
  88. package/Tools/Brush/Brush.d.ts +1 -1
  89. package/Tools/Brush/Brush.js +39 -7
  90. package/Util/Binary/BinaryArrays.d.ts +6 -0
  91. package/Util/Binary/BinaryArrays.js +25 -0
  92. package/Util/Binary/BinaryBuffer.d.ts +29 -0
  93. package/Util/Binary/BinaryBuffer.js +130 -0
  94. package/Util/Binary/{BitArray.d.ts → BinaryFunctions.d.ts} +1 -2
  95. package/Util/Binary/BinaryFunctions.js +11 -0
  96. package/Voxels/Cursor/DataCursor.interface.d.ts +5 -0
  97. package/Voxels/Cursor/VoxelCursor.interface.d.ts +1 -1
  98. package/Voxels/Cursor/VoxelCursor.interface.js +8 -11
  99. package/Voxels/Data/VoxelPalettesRegister.d.ts +0 -5
  100. package/Voxels/Data/VoxelPalettesRegister.js +0 -9
  101. package/Voxels/Data/VoxelTagsRegister.js +7 -7
  102. package/Voxels/Functions/BuildStateData.js +9 -9
  103. package/Voxels/Functions/BuildTagAndPaletteData.js +2 -4
  104. package/Voxels/InitVoxelData.js +12 -13
  105. package/Voxels/State/Schema/StateSchema.d.ts +1 -1
  106. package/Voxels/Types/Voxel.types.d.ts +18 -0
  107. package/Voxels/Types/Voxel.types.js +6 -2
  108. package/World/Archive/Archive.types.d.ts +38 -34
  109. package/World/Archive/Functions/ArchiveArea.js +16 -24
  110. package/World/Archive/Functions/ArchiveSector.js +477 -192
  111. package/World/Archive/Functions/ImportSector.d.ts +3 -3
  112. package/World/Archive/Functions/ImportSector.js +202 -141
  113. package/World/Archive/Functions/Shared.d.ts +6 -0
  114. package/World/Archive/Functions/Shared.js +75 -0
  115. package/World/Archive/InitTasks.js +30 -13
  116. package/World/Cursor/SectionCursor.d.ts +2 -2
  117. package/World/Cursor/SectionCursor.js +2 -3
  118. package/World/Cursor/SectorCursor.d.ts +2 -2
  119. package/World/Cursor/SectorCursor.js +1 -2
  120. package/World/Cursor/WorldCursor.d.ts +2 -2
  121. package/World/Cursor/WorldCursor.js +1 -2
  122. package/World/Cursor/WorldVoxelCursor.js +1 -0
  123. package/World/InitTasks.d.ts +1 -1
  124. package/World/Lock/WorldLock.d.ts +1 -1
  125. package/World/Section/Section.d.ts +12 -16
  126. package/World/Section/Section.js +62 -20
  127. package/World/Section/SectionState.d.ts +10 -0
  128. package/World/Section/SectionState.js +11 -0
  129. package/World/Sector/Sector.d.ts +14 -6
  130. package/World/Sector/Sector.js +67 -17
  131. package/World/Sector/SectorHeightMap.js +2 -2
  132. package/World/Sector/SectorState.d.ts +14 -6
  133. package/World/Sector/SectorState.js +28 -15
  134. package/World/Types/WorldStorage.interface.js +1 -0
  135. package/World/WorldRegister.d.ts +4 -0
  136. package/World/WorldRegister.js +15 -3
  137. package/World/WorldSpaces.d.ts +4 -0
  138. package/World/WorldSpaces.js +19 -6
  139. package/package.json +1 -1
  140. package/Mesher/Functions/CompactMesh.d.ts +0 -2
  141. package/Mesher/Functions/CompactMesh.js +0 -42
  142. package/Mesher/Geomtry/GeometryNormals.d.ts +0 -10
  143. package/Mesher/Geomtry/GeometryNormals.js +0 -52
  144. package/Mesher/Geomtry/MeshData.types.d.ts +0 -13
  145. package/Mesher/Geomtry/MeshData.types.js +0 -6
  146. package/Mesher/Geomtry/Tools/MesherDataTools.d.ts +0 -7
  147. package/Mesher/Geomtry/Tools/MesherDataTools.js +0 -12
  148. package/Mesher/Geomtry/Tools/index.d.ts +0 -1
  149. package/Mesher/Geomtry/Tools/index.js +0 -1
  150. package/Mesher/RenderedMaterials.d.ts +0 -6
  151. package/Models/Rules/VoxelModelManager.js +0 -82
  152. package/Textures/TextureAnimations.d.ts +0 -4
  153. package/Textures/TextureAnimations.js +0 -35
  154. package/Textures/TextureArray.d.ts +0 -47
  155. package/Textures/TextureArray.js +0 -202
  156. package/Textures/TextureBuilder.d.ts +0 -13
  157. package/Textures/TextureBuilder.js +0 -120
  158. package/Textures/TextureRegister.d.ts +0 -9
  159. package/Textures/TextureRegister.js +0 -28
  160. package/Tools/DataCursor.interface.d.ts +0 -5
  161. package/Tools/DataCursor.interface.js +0 -2
  162. package/Util/Binary/BitArray.js +0 -16
  163. package/World/Structs/WorldDataStructProperties.d.ts +0 -8
  164. package/World/Structs/WorldDataStructProperties.js +0 -9
  165. /package/Mesher/{Tools → Geomtry}/VoxelMeshBVHBuilder.d.ts +0 -0
  166. /package/Mesher/{Tools → Geomtry}/VoxelMeshBVHBuilder.js +0 -0
  167. /package/Mesher/Geomtry/{Buffers.d.ts → VoxelMeshBuffers.d.ts} +0 -0
  168. /package/Mesher/Geomtry/{Buffers.js → VoxelMeshBuffers.js} +0 -0
  169. /package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.d.ts +0 -0
  170. /package/Mesher/{Tools → Geomtry}/VoxelMeshVertexStructCursor.js +0 -0
  171. /package/Mesher/{VoxelShaderData.d.ts → Geomtry/VoxelShaderData.d.ts} +0 -0
  172. /package/Mesher/{VoxelShaderData.js → Geomtry/VoxelShaderData.js} +0 -0
  173. /package/{World/Storage/WorldStorage.interface.js → Voxels/Cursor/DataCursor.interface.js} +0 -0
  174. /package/World/{Storage → Types}/WorldStorage.interface.d.ts +0 -0
@@ -49,12 +49,13 @@ export class LiquidGeometryNode extends GeoemtryNode {
49
49
  return false;
50
50
  }
51
51
  determineShading(face) {
52
- const tool = this.builder;
53
- const lightData = tool.lightData[face];
52
+ this.builder.calculateFaceData(face);
53
+ const lightData = this.builder.lightData[face];
54
54
  const worldLight = this.builder.vars.light;
55
- for (let v = 0; v < 4; v++) {
56
- worldLight.vertices[v] = lightData[v];
57
- }
55
+ worldLight.vertices[0] = lightData[0];
56
+ worldLight.vertices[1] = lightData[1];
57
+ worldLight.vertices[2] = lightData[2];
58
+ worldLight.vertices[3] = lightData[3];
58
59
  }
59
60
  shouldFlip() {
60
61
  const worldLight = this.builder.vars.light;
@@ -72,7 +73,6 @@ export class LiquidGeometryNode extends GeoemtryNode {
72
73
  added = true;
73
74
  getFlowGradient(tool, vertexLevel);
74
75
  const quad = Quads[VoxelFaces.Up];
75
- tool.calculateFaceData(VoxelFaces.Up);
76
76
  this.determineShading(VoxelFaces.Up);
77
77
  quad.flip = this.shouldFlip();
78
78
  tool.vars.textureIndex = args.stillTexture;
@@ -99,19 +99,16 @@ export class LiquidGeometryNode extends GeoemtryNode {
99
99
  added = true;
100
100
  tool.vars.textureIndex = args.stillTexture;
101
101
  const quad = Quads[VoxelFaces.Down];
102
- tool.calculateFaceData(VoxelFaces.Down);
103
102
  this.determineShading(VoxelFaces.Down);
104
103
  quad.flip = this.shouldFlip();
105
- tool.vars.textureIndex = args.stillTexture;
106
104
  VoxelGeometryBuilder.addQuad(tool, tool.origin, quad);
107
105
  tool.updateBounds(quadBounds[VoxelFaces.Down]);
108
106
  }
109
107
  if (this.isExposed(VoxelFaces.North)) {
110
108
  added = true;
111
- tool.vars.textureIndex = args.stillTexture;
109
+ tool.vars.textureIndex = args.flowTexture;
112
110
  const quad = Quads[VoxelFaces.North];
113
111
  tool.vars.animation.setAll(1);
114
- tool.calculateFaceData(VoxelFaces.North);
115
112
  this.determineShading(VoxelFaces.North);
116
113
  quad.flip = this.shouldFlip();
117
114
  if (upFaceExposed) {
@@ -134,10 +131,9 @@ export class LiquidGeometryNode extends GeoemtryNode {
134
131
  }
135
132
  if (this.isExposed(VoxelFaces.South)) {
136
133
  added = true;
137
- tool.vars.textureIndex = args.stillTexture;
134
+ tool.vars.textureIndex = args.flowTexture;
138
135
  const quad = Quads[VoxelFaces.South];
139
136
  tool.vars.animation.setAll(1);
140
- tool.calculateFaceData(VoxelFaces.South);
141
137
  this.determineShading(VoxelFaces.South);
142
138
  quad.flip = this.shouldFlip();
143
139
  if (upFaceExposed) {
@@ -160,12 +156,11 @@ export class LiquidGeometryNode extends GeoemtryNode {
160
156
  }
161
157
  if (this.isExposed(VoxelFaces.East)) {
162
158
  added = true;
163
- tool.vars.textureIndex = args.stillTexture;
159
+ tool.vars.textureIndex = args.flowTexture;
164
160
  const quad = Quads[VoxelFaces.East];
165
161
  tool.vars.animation.setAll(1);
166
- tool.calculateFaceData(VoxelFaces.East);
167
162
  this.determineShading(VoxelFaces.East);
168
- // quad.flip = this.shouldFlip();
163
+ quad.flip = this.shouldFlip();
169
164
  if (upFaceExposed) {
170
165
  quad.positions.vertices[QuadVerticies.TopRight].y =
171
166
  vertexValue.vertices[FlowVerticies.NorthEast] * waterHeight;
@@ -186,10 +181,9 @@ export class LiquidGeometryNode extends GeoemtryNode {
186
181
  }
187
182
  if (this.isExposed(VoxelFaces.West)) {
188
183
  added = true;
189
- tool.vars.textureIndex = args.stillTexture;
184
+ tool.vars.textureIndex = args.flowTexture;
190
185
  const quad = Quads[VoxelFaces.West];
191
186
  tool.vars.animation.setAll(1);
192
- tool.calculateFaceData(VoxelFaces.West);
193
187
  this.determineShading(VoxelFaces.West);
194
188
  quad.flip = this.shouldFlip();
195
189
  if (upFaceExposed) {
@@ -1,4 +1,4 @@
1
- import { VoxelMesherDataTool } from "../../../Mesher/Tools/VoxelMesherDataTool";
1
+ import { VoxelModelBuilder } from "../VoxelModelBuilder";
2
2
  import { VoxelGeometryConstructor } from "./VoxelGeometryConstructor";
3
3
  import { VoxelGeometryTransform } from "../../../Voxels/Types/VoxelModelCompiledData.types";
4
4
  export interface GeoemtryNodeConstructor<Data = any, Args = any> {
@@ -13,7 +13,7 @@ export declare abstract class GeoemtryNode<Data = any, Args = any> {
13
13
  vertexIndex: number;
14
14
  faceCount: number;
15
15
  vertexCount: number;
16
- builder: VoxelMesherDataTool;
16
+ builder: VoxelModelBuilder;
17
17
  constructor(geometryPaletteId: number, geomtry: VoxelGeometryConstructor, data: Data, transform: VoxelGeometryTransform);
18
18
  abstract init(): void;
19
19
  abstract add(args: Args): boolean;
@@ -14,6 +14,7 @@ export declare class BoxVoxelGometryNode extends GeoemtryNode<VoxelBoxGeometryNo
14
14
  Vec4Array,
15
15
  Vec4Array
16
16
  ]>;
17
+ _wasAOShaded: boolean;
17
18
  lightData: VoxelLightData;
18
19
  init(): void;
19
20
  isExposed(face: VoxelFaces): boolean;
@@ -11,6 +11,7 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
11
11
  quads;
12
12
  quadBounds = [];
13
13
  vertexWeights;
14
+ _wasAOShaded = false;
14
15
  lightData = new VoxelLightData();
15
16
  init() {
16
17
  this.faceCount = 6;
@@ -41,8 +42,8 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
41
42
  continue;
42
43
  const faceIndex = this.geomtry.cullIndex.getValue(geoId, currentIndex, trueFaceIndex);
43
44
  if (faceIndex > -1 &&
44
- !this.builder
45
- .space.getConstructor(hashed)
45
+ !this.builder.space
46
+ .getConstructor(hashed)
46
47
  ?.isShapeStateFaceTransparent(this.builder.space.modCache[hashed], this.builder.space.stateCache[hashed], geoId, faceIndex)) {
47
48
  return false;
48
49
  }
@@ -58,8 +59,8 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
58
59
  continue;
59
60
  const faceIndex = this.geomtry.cullIndex.getValue(geoId, currentIndex, trueFaceIndex);
60
61
  if (faceIndex > -1 &&
61
- !this.builder
62
- .space.getConstructor(hashed)
62
+ !this.builder.space
63
+ .getConstructor(hashed)
63
64
  ?.isCondtionalStateFaceTransparent(this.builder.space.modCache[hashed], this.builder.space.stateCache[hashed], geoId, faceIndex))
64
65
  return false;
65
66
  }
@@ -99,21 +100,28 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
99
100
  length = baseGeo.length;
100
101
  for (let geoIndex = 0; geoIndex < length; geoIndex++) {
101
102
  if (this.geomtry.aoIndex.getValue(baseGeo[geoIndex], currentIndex, trueVertexIndex)) {
102
- worldAO.vertices[v] = 1;
103
- shaded = true;
104
- break;
103
+ this._wasAOShaded = true;
104
+ worldAO.vertices[v]++;
105
+ if (worldAO.vertices[v] > 4) {
106
+ shaded = true;
107
+ break;
108
+ }
105
109
  }
106
110
  }
107
111
  }
108
- if (!conditonalGeo)
112
+ if (!conditonalGeo || shaded)
109
113
  continue;
110
114
  length = conditonalGeo.length;
111
115
  for (let condtionsIndex = 0; condtionsIndex < length; condtionsIndex++) {
112
116
  const condiotnalength = conditonalGeo[condtionsIndex].length;
113
117
  for (let geoIndex = 0; geoIndex < condiotnalength; geoIndex++) {
114
118
  if (this.geomtry.aoIndex.getValue(conditonalGeo[condtionsIndex][geoIndex], currentIndex, trueVertexIndex)) {
115
- worldAO.vertices[v] = 1;
116
- break;
119
+ this._wasAOShaded = true;
120
+ worldAO.vertices[v]++;
121
+ if (worldAO.vertices[v] > 4) {
122
+ shaded = true;
123
+ break;
124
+ }
117
125
  }
118
126
  }
119
127
  }
@@ -122,9 +130,12 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
122
130
  }
123
131
  shouldFlip() {
124
132
  const worldAO = this.builder.vars.ao;
125
- const worldLight = this.builder.vars.light;
126
- if (shouldCauseFlip(worldAO.vertices[0], worldAO.vertices[1], worldAO.vertices[2], worldAO.vertices[3]))
133
+ if (shouldCauseFlip(worldAO.vertices[0], worldAO.vertices[1], worldAO.vertices[2], worldAO.vertices[3]) &&
134
+ this._wasAOShaded)
127
135
  return true;
136
+ if (this._wasAOShaded)
137
+ return false;
138
+ const worldLight = this.builder.vars.light;
128
139
  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])) ||
129
140
  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])));
130
141
  }
@@ -159,6 +170,7 @@ export class BoxVoxelGometryNode extends GeoemtryNode {
159
170
  }
160
171
  this.builder.vars.ao.setAll(0);
161
172
  this.builder.vars.light.setAll(0);
173
+ this._wasAOShaded = false;
162
174
  return added;
163
175
  }
164
176
  }
@@ -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,4 +1,4 @@
1
- import { VoxelMesherDataTool } from "../../Mesher/Tools/VoxelMesherDataTool";
1
+ import { VoxelModelBuilder } from "./VoxelModelBuilder";
2
2
  import { CompiledVoxelModelInputData, CompiledVoxelModelData } from "../../Voxels/Types/VoxelModelCompiledData.types";
3
3
  import { StateSchema } from "../../Voxels/State/Schema/StateSchema";
4
4
  import { StateTreeReader } from "../../Voxels/State/StateTreeReader";
@@ -7,7 +7,7 @@ import { VoxelModelEffect } from "./VoxelModelEffect";
7
7
  import { CondtionalTreeReader } from "../../Voxels/State/CondiotnalTreeReader";
8
8
  export declare class VoxelConstructor {
9
9
  id: string;
10
- builder: VoxelMesherDataTool;
10
+ builder: VoxelModelBuilder;
11
11
  data: CompiledVoxelModelData;
12
12
  isModel: true;
13
13
  geometries: number[][];
@@ -20,7 +20,7 @@ export declare class VoxelConstructor {
20
20
  effects: VoxelModelEffect;
21
21
  shapeStateTree: StateTreeReader;
22
22
  condtioanlShapeStateTree: CondtionalTreeReader;
23
- constructor(id: string, builder: VoxelMesherDataTool, 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
26
  process(): boolean;
@@ -1,11 +1,10 @@
1
- import { DataCursorInterface } from "../../Tools/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
4
  export declare class VoxelGeometryBuilderCacheSpace {
5
5
  bounds: Vector3Like;
6
6
  foundHash: Uint8Array;
7
7
  voxelCache: Uint16Array;
8
- lightCache: Int32Array;
9
8
  modCache: Int32Array;
10
9
  stateCache: Int32Array;
11
10
  conditonalStateCache: Int32Array;
@@ -19,6 +18,5 @@ export declare class VoxelGeometryBuilderCacheSpace {
19
18
  getGeomtry(index: number): false | number[];
20
19
  getConditionalGeomtry(index: number): false | number[][];
21
20
  getHash(dataCursor: DataCursorInterface, x: number, y: number, z: number): number;
22
- getLight(dataCursor: DataCursorInterface, x: number, y: number, z: number): number;
23
21
  private hashState;
24
22
  }
@@ -5,7 +5,6 @@ export class VoxelGeometryBuilderCacheSpace {
5
5
  bounds;
6
6
  foundHash;
7
7
  voxelCache;
8
- lightCache;
9
8
  modCache;
10
9
  stateCache;
11
10
  conditonalStateCache;
@@ -16,7 +15,6 @@ export class VoxelGeometryBuilderCacheSpace {
16
15
  this.bounds = bounds;
17
16
  const volume = bounds.x * bounds.y * bounds.z;
18
17
  this.foundHash = new Uint8Array(volume);
19
- this.lightCache = new Int32Array(volume);
20
18
  this.voxelCache = new Uint16Array(volume);
21
19
  this.modCache = new Int32Array(volume);
22
20
  this.stateCache = new Int32Array(volume);
@@ -27,7 +25,6 @@ export class VoxelGeometryBuilderCacheSpace {
27
25
  this.offset[0] = x;
28
26
  this.offset[1] = y;
29
27
  this.offset[2] = z;
30
- this.lightCache.fill(-1);
31
28
  this.foundHash.fill(0);
32
29
  this.voxelCache.fill(0);
33
30
  this.modCache.fill(-1);
@@ -60,32 +57,12 @@ export class VoxelGeometryBuilderCacheSpace {
60
57
  }
61
58
  return hashed;
62
59
  }
63
- getLight(dataCursor, x, y, z) {
64
- const index = this.getIndex(x, y, z);
65
- if (this.lightCache[index] == -1) {
66
- this.lightCache[index] = 0;
67
- const voxel = dataCursor.getVoxel(x, y, z);
68
- if (voxel) {
69
- const light = voxel.getLight();
70
- if (light > 0) {
71
- this.lightCache[index] = light;
72
- }
73
- }
74
- }
75
- return this.lightCache[index];
76
- }
77
60
  hashState(dataCursor, index, x, y, z) {
78
61
  if (this.foundHash[index] == 1)
79
62
  return -1;
80
63
  if (this.foundHash[index] == 2)
81
64
  return this.stateCache[index];
82
65
  const voxel = dataCursor.getVoxel(x, y, z);
83
- if (voxel) {
84
- const light = voxel.getLight();
85
- if (light > 0) {
86
- this.lightCache[index] = light;
87
- }
88
- }
89
66
  if (!voxel || !voxel.isRenderable()) {
90
67
  this.foundHash[index] = 1;
91
68
  return -1;
@@ -1,13 +1,12 @@
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";
5
+ import { VoxelMeshBVHBuilder } from "../Geomtry/VoxelMeshBVHBuilder";
7
6
  import { Vec3Array, Vector3Like, Vector4Like } from "@amodx/math";
8
7
  import { VoxelCursorInterface } from "../../Voxels/Cursor/VoxelCursor.interface.js";
9
- import { DataCursorInterface } from "../../Tools/DataCursor.interface.js";
10
- import { VoxelGeometryBuilderCacheSpace } from "../Models/VoxelGeometryBuilderCacheSpace";
8
+ import { DataCursorInterface } from "../../Voxels/Cursor/DataCursor.interface.js";
9
+ import { VoxelGeometryBuilderCacheSpace } from "./VoxelGeometryBuilderCacheSpace";
11
10
  declare class VoxelVars {
12
11
  faceFlipped: boolean;
13
12
  textureIndex: number;
@@ -18,7 +17,7 @@ declare class VoxelVars {
18
17
  level: QuadScalarVertexData;
19
18
  reset(): void;
20
19
  }
21
- export declare class VoxelMesherDataTool extends MesherDataTool {
20
+ export declare class VoxelModelBuilder {
22
21
  id: string;
23
22
  materialIndex: number;
24
23
  space: VoxelGeometryBuilderCacheSpace;
@@ -1,10 +1,9 @@
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 calculateFaceData from "../Models/Common/Calc/FaceDataCalc.js";
6
+ import calculateFaceData from "./Common/Calc/FaceDataCalc.js";
8
7
  import { VoxelMesh } from "../Geomtry/VoxelMesh";
9
8
  import { Vector3Like, Vector4Like } from "@amodx/math";
10
9
  class VoxelVars {
@@ -23,7 +22,7 @@ class VoxelVars {
23
22
  this.overlayTextures.z = 0;
24
23
  }
25
24
  }
26
- export class VoxelMesherDataTool extends MesherDataTool {
25
+ export class VoxelModelBuilder {
27
26
  id;
28
27
  materialIndex;
29
28
  space;
@@ -41,11 +40,10 @@ export class VoxelMesherDataTool extends MesherDataTool {
41
40
  lightData;
42
41
  effects;
43
42
  constructor(id, materialIndex) {
44
- super();
45
- this.id = id;
46
- this.materialIndex = materialIndex;
47
43
  // this.faceDataOverride.currentVoxel = this.voxel;
48
44
  // this.faceDataOverride.neighborVoxel = this.nVoxel;
45
+ this.id = id;
46
+ this.materialIndex = materialIndex;
49
47
  this.dataCalculated = [];
50
48
  for (const face of VoxelFacesArray) {
51
49
  this.dataCalculated[face] = false;
@@ -74,7 +72,6 @@ export class VoxelMesherDataTool extends MesherDataTool {
74
72
  this.lightData[face][QuadVerticies.BottomLeft] = 0;
75
73
  this.lightData[face][QuadVerticies.BottomRight] = 0;
76
74
  }
77
- this.startNewMesh(new VoxelMesh());
78
75
  }
79
76
  bounds = {
80
77
  min: [0, 0, 0],
@@ -97,6 +94,13 @@ export class VoxelMesherDataTool extends MesherDataTool {
97
94
  if (!this._boundsUpdate)
98
95
  return false;
99
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;
100
104
  }
101
105
  return true;
102
106
  }
@@ -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
  },