@divinevoxel/vlox 0.0.79 → 0.0.81

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 (167) hide show
  1. package/Builder/Tools/Brush/BrushTool.d.ts +12 -2
  2. package/Builder/Tools/Brush/BrushTool.js +53 -28
  3. package/Builder/Tools/Debug/DebugTool.d.ts +18 -0
  4. package/Builder/Tools/Debug/DebugTool.js +36 -0
  5. package/Builder/Tools/Path/PahtTool.d.ts +1 -1
  6. package/Builder/Tools/Path/PahtTool.js +1 -1
  7. package/Builder/Tools/Sculpt/SculptTool.js +8 -0
  8. package/Builder/Tools/Wrench/WrenchTool.js +10 -23
  9. package/Builder/Util/SurfaceBoxSelection.js +2 -0
  10. package/Builder/VoxelBuildSpace.js +3 -3
  11. package/Contexts/Base/Remote/InitDataSync.js +1 -1
  12. package/Math/UtilFunctions.js +7 -8
  13. package/Math/VoxelFaces.d.ts +2 -2
  14. package/Math/VoxelFaces.js +46 -55
  15. package/Math/WorldIndexing.d.ts +11 -0
  16. package/Math/WorldIndexing.js +34 -0
  17. package/Mesher/Geometry/Geometry.types.d.ts +2 -2
  18. package/Mesher/Geometry/Geometry.types.js +7 -20
  19. package/Mesher/Geometry/Primitives/QuadVertexData.js +118 -119
  20. package/Mesher/Geometry/Primitives/TriangleVertexData.js +89 -90
  21. package/Mesher/Geometry/Proto/ProtoMesh.d.ts +1 -1
  22. package/Mesher/Geometry/Proto/ProtoMesh.js +22 -29
  23. package/Mesher/Geometry/Proto/ProtoMeshBuffer.d.ts +4 -2
  24. package/Mesher/Geometry/Proto/ProtoMeshBuffer.js +14 -6
  25. package/Mesher/Geometry/Shapes/Box.js +6 -7
  26. package/Mesher/Geometry/Transform/TransformBox.js +8 -9
  27. package/Mesher/Geometry/Transform/TransformQuad.js +4 -5
  28. package/Mesher/Geometry/Transform/TransformTriangle.js +3 -4
  29. package/Mesher/InitMesher.js +4 -9
  30. package/Mesher/Items/Geometry/ItemGeometryBuilder.js +7 -8
  31. package/Mesher/Items/MeshTexture.js +125 -57
  32. package/Mesher/Voxels/Base/BuildVoxel.d.ts +6 -0
  33. package/Mesher/Voxels/Base/BuildVoxel.js +101 -0
  34. package/Mesher/Voxels/Base/CompactVoxelSectionMesh.js +1 -21
  35. package/Mesher/Voxels/Base/MeshSectionBase.js +3 -26
  36. package/Mesher/Voxels/Geometry/VoxelGeometryBuilder.js +33 -31
  37. package/Mesher/Voxels/Geometry/VoxelShaderData.js +3 -7
  38. package/Mesher/Voxels/MeshTemplate.js +6 -26
  39. package/Mesher/Voxels/MeshVoxel.js +5 -10
  40. package/Mesher/Voxels/Models/Common/Calc/CalcConstants.js +41 -42
  41. package/Mesher/Voxels/Models/Common/Calc/FaceDataCalc.js +6 -9
  42. package/Mesher/Voxels/Models/Common/Faces/CullRulledFace.js +64 -47
  43. package/Mesher/Voxels/Models/Common/Faces/ShadeRulledFace.js +57 -43
  44. package/Mesher/Voxels/Models/Nodes/Custom/Liquid/FlowGradient.js +4 -5
  45. package/Mesher/Voxels/Models/Nodes/Custom/Liquid/LiquidGeometryNode.d.ts +1 -1
  46. package/Mesher/Voxels/Models/Nodes/Custom/Liquid/LiquidGeometryNode.js +116 -118
  47. package/Mesher/Voxels/Models/Nodes/Default/QuadVoxelGeometryNode.js +4 -4
  48. package/Mesher/Voxels/Models/Nodes/VoxelGeometryConstructor.js +2 -2
  49. package/Mesher/Voxels/Models/Procedures/Default/OutlinedTextureProcedure.js +19 -21
  50. package/Mesher/Voxels/Models/Procedures/Default/PillarTextureProcedure.js +45 -38
  51. package/Mesher/Voxels/Models/RenderedMaterials.d.ts +1 -1
  52. package/Mesher/Voxels/Models/RenderedMaterials.js +8 -5
  53. package/Mesher/Voxels/Models/VoxelGeometryBuilderCacheSpace.d.ts +18 -4
  54. package/Mesher/Voxels/Models/VoxelGeometryBuilderCacheSpace.js +135 -22
  55. package/Mesher/Voxels/Models/VoxelGeometryBuilderCacheSpaceN.d.ts +33 -0
  56. package/Mesher/Voxels/Models/VoxelGeometryBuilderCacheSpaceN.js +204 -0
  57. package/Mesher/Voxels/Models/{VoxelModelConstructorRegister.d.ts → VoxelGeometryConstructorRegister.d.ts} +1 -6
  58. package/Mesher/Voxels/Models/VoxelGeometryConstructorRegister.js +20 -0
  59. package/Mesher/Voxels/Models/VoxelModelBuilder.js +15 -16
  60. package/Mesher/Voxels/Models/VoxelModelEffect.d.ts +1 -3
  61. package/Mesher/Voxels/Models/VoxelModelEffect.js +1 -3
  62. package/Renderer/DVERenderNode.types.d.ts +1 -0
  63. package/Renderer/InitTasks.js +2 -0
  64. package/Tasks/Paint/Erase/EraseVoxel.js +1 -1
  65. package/Tasks/Propagation/Illumanation/RGBUpdate.js +191 -48
  66. package/Tasks/Propagation/Illumanation/SunUpdate.d.ts +1 -1
  67. package/Tasks/Propagation/Illumanation/SunUpdate.js +167 -63
  68. package/Tasks/Propagation/Illumanation/WorldSun.js +96 -60
  69. package/Tasks/WorldGeneration/WorldGenBrush.d.ts +2 -0
  70. package/Tasks/WorldGeneration/WorldGenBrush.js +31 -0
  71. package/Templates/Archive/ArchivedVoxelTemplate.js +1 -1
  72. package/Templates/Archive/Functions/CreateArchivedTemplate.js +1 -1
  73. package/Templates/Archive/Functions/CreateArchivedTemplateFromFull.d.ts +6 -0
  74. package/Templates/Archive/Functions/CreateArchivedTemplateFromFull.js +174 -0
  75. package/Textures/Classes/CompactedTextureReader.d.ts +22 -0
  76. package/Textures/Classes/CompactedTextureReader.js +90 -0
  77. package/Textures/Classes/CompiledTexture.d.ts +4 -1
  78. package/Textures/Classes/CompiledTexture.js +36 -8
  79. package/Textures/Classes/TextureAtlasIndex.d.ts +7 -0
  80. package/Textures/Classes/TextureAtlasIndex.js +14 -0
  81. package/Textures/Classes/TextureLoader.d.ts +20 -0
  82. package/Textures/Classes/TextureLoader.js +95 -0
  83. package/Textures/Functions/BuildTextureData.d.ts +1 -1
  84. package/Textures/Functions/BuildTextureData.js +19 -122
  85. package/Textures/Functions/CreateCompactedTexture.d.ts +6 -0
  86. package/Textures/Functions/CreateCompactedTexture.js +105 -0
  87. package/Textures/Functions/ReadCompactedTexture.d.ts +2 -0
  88. package/Textures/Functions/ReadCompactedTexture.js +42 -0
  89. package/Textures/Texture.types.d.ts +14 -0
  90. package/Textures/TextureManager.d.ts +7 -1
  91. package/Textures/TextureManager.js +13 -0
  92. package/Tools/Brush/Brush.d.ts +4 -2
  93. package/Tools/Brush/Brush.js +28 -6
  94. package/Util/BinaryBuffer/Functions/BinaryBufferConvert.d.ts +1 -1
  95. package/Util/TickInterval.d.ts +3 -0
  96. package/Util/TickInterval.js +31 -3
  97. package/Voxels/Archive/VoxelPaletteArchiveReader.d.ts +1 -0
  98. package/Voxels/Archive/VoxelPaletteArchiveReader.js +9 -10
  99. package/Voxels/Archive/VoxelPaletteArechive.js +5 -4
  100. package/Voxels/Cursor/VoxelCursor.interface.d.ts +1 -1
  101. package/Voxels/Cursor/VoxelCursor.interface.js +22 -16
  102. package/Voxels/Data/VoxelLUT.d.ts +69 -42
  103. package/Voxels/Data/VoxelLUT.js +110 -53
  104. package/Voxels/Functions/BuildLUTs.js +100 -45
  105. package/Voxels/Functions/Geometry/CalcFunctions.js +6 -7
  106. package/Voxels/Functions/Geometry/Compile/BuildCompiled.d.ts +1 -1
  107. package/Voxels/Functions/Geometry/Inputs/BuildBoxInputs.d.ts +1 -1
  108. package/Voxels/Functions/Geometry/Inputs/BuildCustomInputs.d.ts +1 -1
  109. package/Voxels/Functions/Geometry/Inputs/BuildQuadInputs.d.ts +1 -1
  110. package/Voxels/Functions/Geometry/Inputs/BuildTriangleInputs.d.ts +1 -1
  111. package/Voxels/Functions/Geometry/Inputs/BuildTriangleInputs.js +3 -0
  112. package/Voxels/Indexes/VoxelIndex.js +3 -1
  113. package/Voxels/InitVoxelData.js +3 -1
  114. package/Voxels/Interaction/Functions/PickVoxel.js +3 -5
  115. package/Voxels/Interaction/Functions/PickVoxelWorld.js +4 -6
  116. package/Voxels/Models/Defaults/Examples.d.ts +2 -0
  117. package/Voxels/Models/Defaults/Examples.js +151 -2
  118. package/Voxels/State/Reltional/ReltionalStateBuilder.js +2 -0
  119. package/Voxels/State/Schema/BinarySchema.d.ts +1 -0
  120. package/Voxels/State/Schema/BinarySchema.js +14 -0
  121. package/Voxels/State/VoxelSchemas.d.ts +11 -4
  122. package/Voxels/State/VoxelSchemas.js +42 -9
  123. package/Voxels/Types/PaintVoxelData.js +6 -2
  124. package/World/Archive/Classes/ImportedSection.js +1 -1
  125. package/World/Archive/Classes/ImportedSector.js +0 -1
  126. package/World/Archive/Functions/Sector/ArchiveSector.js +2 -2
  127. package/World/Archive/Functions/Sector/ImportSector.d.ts +1 -0
  128. package/World/Archive/Functions/Sector/ImportSector.js +183 -7
  129. package/World/Cursor/SectorCursor.js +1 -4
  130. package/World/Cursor/WorldCursor.d.ts +12 -3
  131. package/World/Cursor/WorldCursor.js +60 -30
  132. package/World/InitTasks.js +1 -1
  133. package/World/Lock/Function/LockSectors.js +5 -1
  134. package/World/Lock/Function/UnLockSectors.js +5 -1
  135. package/World/SnapShot/SectionSnapShot.d.ts +7 -3
  136. package/World/SnapShot/SectionSnapShot.js +47 -21
  137. package/World/SnapShot/SectionSnapShotCursor.d.ts +4 -2
  138. package/World/SnapShot/SectionSnapShotCursor.js +23 -11
  139. package/World/SnapShot/SnapShots.d.ts +1 -2
  140. package/World/SnapShot/SnapShots.js +3 -3
  141. package/World/WorldSpaces.d.ts +7 -0
  142. package/World/WorldSpaces.js +35 -13
  143. package/WorldSimulation/Dimensions/DimensionSegment.d.ts +2 -0
  144. package/WorldSimulation/Dimensions/DimensionSegment.js +9 -1
  145. package/WorldSimulation/Dimensions/DimensionSimulation.js +6 -7
  146. package/WorldSimulation/Dimensions/Generator.d.ts +4 -0
  147. package/WorldSimulation/Dimensions/Generator.js +15 -1
  148. package/WorldSimulation/Dimensions/SimulationSector.d.ts +1 -0
  149. package/WorldSimulation/Dimensions/SimulationSector.js +18 -0
  150. package/WorldSimulation/Internal/WorldSimulationTasks.js +11 -7
  151. package/WorldSimulation/Procedures/InitalLoad.d.ts +1 -0
  152. package/WorldSimulation/Procedures/InitalLoad.js +18 -8
  153. package/WorldSimulation/Tasks/SimulationTaskBase.d.ts +4 -1
  154. package/WorldSimulation/Tasks/SimulationTaskBase.js +13 -2
  155. package/WorldSimulation/Tasks/TaskSegment.d.ts +4 -2
  156. package/WorldSimulation/Tasks/TaskSegment.js +36 -22
  157. package/WorldSimulation/Voxels/Ticks/Types/LiquidVoxelUpdate.js +1 -2
  158. package/WorldSimulation/WorldSimulation.d.ts +6 -3
  159. package/WorldSimulation/WorldSimulation.js +44 -20
  160. package/package.json +1 -1
  161. package/Mesher/Items/MeshTextureO.d.ts +0 -1
  162. package/Mesher/Items/MeshTextureO.js +0 -277
  163. package/Mesher/Voxels/Models/VoxelConstructor.d.ts +0 -8
  164. package/Mesher/Voxels/Models/VoxelConstructor.js +0 -78
  165. package/Mesher/Voxels/Models/VoxelModelConstructorRegister.js +0 -37
  166. package/WorldSimulation/Procedures/BuildOnly.d.ts +0 -10
  167. package/WorldSimulation/Procedures/BuildOnly.js +0 -55
@@ -1,10 +1,8 @@
1
- import { QuadVerticies } from "../Geometry/Geometry.types";
2
1
  import { Quad } from "../Geometry/Primitives/Quad";
3
2
  import { ItemModelBuilder } from "./Models/ItemModelBuilder";
4
3
  import { addItemQuad } from "./Geometry/ItemGeometryBuilder";
5
4
  import { Flat2DIndex, Vector3Like } from "@amodx/math";
6
5
  import { Box } from "../Geometry/Shapes/Box";
7
- import { VoxelFaces } from "../../Math";
8
6
  import { CompactItemMesh } from "./Base/CompactItemMesh";
9
7
  const { quads: Quads } = Box.Create([
10
8
  [0, 0, 0],
@@ -15,14 +13,14 @@ const addUvs = (quad, factor, sx, sy, ex, ey) => {
15
13
  const uL = sx * factor;
16
14
  const vT = ey * factor;
17
15
  const vB = sy * factor;
18
- quad.uvs.vertices[QuadVerticies.TopRight].x = uR;
19
- quad.uvs.vertices[QuadVerticies.TopRight].y = vT;
20
- quad.uvs.vertices[QuadVerticies.TopLeft].x = uL;
21
- quad.uvs.vertices[QuadVerticies.TopLeft].y = vT;
22
- quad.uvs.vertices[QuadVerticies.BottomLeft].x = uL;
23
- quad.uvs.vertices[QuadVerticies.BottomLeft].y = vB;
24
- quad.uvs.vertices[QuadVerticies.BottomRight].x = uR;
25
- quad.uvs.vertices[QuadVerticies.BottomRight].y = vB;
16
+ quad.uvs.vertices[0 /* QuadVerticies.TopRight */].x = uR;
17
+ quad.uvs.vertices[0 /* QuadVerticies.TopRight */].y = vT;
18
+ quad.uvs.vertices[1 /* QuadVerticies.TopLeft */].x = uL;
19
+ quad.uvs.vertices[1 /* QuadVerticies.TopLeft */].y = vT;
20
+ quad.uvs.vertices[2 /* QuadVerticies.BottomLeft */].x = uL;
21
+ quad.uvs.vertices[2 /* QuadVerticies.BottomLeft */].y = vB;
22
+ quad.uvs.vertices[3 /* QuadVerticies.BottomRight */].x = uR;
23
+ quad.uvs.vertices[3 /* QuadVerticies.BottomRight */].y = vB;
26
24
  };
27
25
  class TextureVoxelData {
28
26
  width;
@@ -45,8 +43,8 @@ class TextureVoxelData {
45
43
  return a > 0.01;
46
44
  }
47
45
  }
48
- Quads[VoxelFaces.North].setUVs(Quad.FullUVs);
49
- Quads[VoxelFaces.South].setUVs(Quad.FullUVs);
46
+ Quads[2 /* VoxelFaces.North */].setUVs(Quad.FullUVs);
47
+ Quads[3 /* VoxelFaces.South */].setUVs(Quad.FullUVs);
50
48
  const tool = new ItemModelBuilder("dve_item");
51
49
  export function MeshTexture(textureId, textureData, origin = Vector3Like.Create(), thickness = null) {
52
50
  const width = Math.sqrt(textureData.length / 4);
@@ -54,25 +52,22 @@ export function MeshTexture(textureId, textureData, origin = Vector3Like.Create(
54
52
  const factor = 1 / width;
55
53
  const data = new TextureVoxelData(width, height, textureData);
56
54
  tool.origin = origin;
55
+ // South face
57
56
  {
58
- //south face
59
57
  tool.vars.textureIndex = textureId;
60
- addItemQuad(tool, Quads[VoxelFaces.South]);
58
+ addItemQuad(tool, Quads[3 /* VoxelFaces.South */]);
61
59
  }
60
+ // North face
62
61
  {
63
- //north face
64
62
  const backPositionZ = factor;
65
- Quads[VoxelFaces.North].positions.vertices[QuadVerticies.TopRight].z =
66
- backPositionZ;
67
- Quads[VoxelFaces.North].positions.vertices[QuadVerticies.TopLeft].z =
68
- backPositionZ;
69
- Quads[VoxelFaces.North].positions.vertices[QuadVerticies.BottomLeft].z =
70
- backPositionZ;
71
- Quads[VoxelFaces.North].positions.vertices[QuadVerticies.BottomRight].z =
72
- backPositionZ;
63
+ Quads[2 /* VoxelFaces.North */].positions.vertices[0 /* QuadVerticies.TopRight */].z = backPositionZ;
64
+ Quads[2 /* VoxelFaces.North */].positions.vertices[1 /* QuadVerticies.TopLeft */].z = backPositionZ;
65
+ Quads[2 /* VoxelFaces.North */].positions.vertices[2 /* QuadVerticies.BottomLeft */].z = backPositionZ;
66
+ Quads[2 /* VoxelFaces.North */].positions.vertices[3 /* QuadVerticies.BottomRight */].z = backPositionZ;
73
67
  tool.vars.textureIndex = textureId;
74
- addItemQuad(tool, Quads[VoxelFaces.North]);
68
+ addItemQuad(tool, Quads[2 /* VoxelFaces.North */]);
75
69
  }
70
+ // East/West faces
76
71
  for (let x = 0; x < width; x++) {
77
72
  let eastFace = null;
78
73
  let westFace = null;
@@ -95,17 +90,16 @@ export function MeshTexture(textureId, textureData, origin = Vector3Like.Create(
95
90
  const y1 = y * factor;
96
91
  const z0 = 0;
97
92
  const z1 = factor;
98
- // Flip winding vs previous: (p1 <-> p3)
99
93
  const newQuad = Quad.Create([
100
- [x1, y0, z0], // p0
101
- [x1, y0, z1], // p1 (was p3)
102
- [x1, y1, z1], // p2
103
- [x1, y1, z0], // p3 (was p1)
94
+ [x1, y0, z0],
95
+ [x1, y0, z1],
96
+ [x1, y1, z1],
97
+ [x1, y1, z0],
104
98
  ], Quad.FullUVs, false);
105
99
  let [sx, sy] = eastFace;
106
100
  let ex = x + 1;
107
101
  let ey = y;
108
- addUvs(newQuad, factor, sx, sy, ex, ey);
102
+ addUvs(newQuad, factor, sx, ey, ex, sy);
109
103
  eastFace = null;
110
104
  tool.vars.textureIndex = textureId;
111
105
  addItemQuad(tool, newQuad);
@@ -116,17 +110,16 @@ export function MeshTexture(textureId, textureData, origin = Vector3Like.Create(
116
110
  const y1 = y * factor;
117
111
  const z0 = 0;
118
112
  const z1 = factor;
119
- // Flip winding vs previous: (p1 <-> p3)
120
113
  const newQuad = Quad.Create([
121
- [x0, y0, z0], // p0
122
- [x0, y1, z0], // p1 (was p3)
123
- [x0, y1, z1], // p2
124
- [x0, y0, z1], // p3 (was p1)
114
+ [x0, y0, z0],
115
+ [x0, y1, z0],
116
+ [x0, y1, z1],
117
+ [x0, y0, z1],
125
118
  ], Quad.FullUVs, false);
126
119
  let [sx, sy] = westFace;
127
120
  let ex = x + 1;
128
121
  let ey = y;
129
- addUvs(newQuad, factor, sx, sy, ex, ey);
122
+ addUvs(newQuad, factor, sx, ey, ex, sy);
130
123
  westFace = null;
131
124
  tool.vars.textureIndex = textureId;
132
125
  addItemQuad(tool, newQuad);
@@ -139,7 +132,47 @@ export function MeshTexture(textureId, textureData, origin = Vector3Like.Create(
139
132
  westFace = [x, y];
140
133
  }
141
134
  }
135
+ // FLUSH: emit any remaining faces at the top edge
136
+ if (eastFace) {
137
+ const x1 = x * factor + factor;
138
+ const y0 = eastFace[1] * factor;
139
+ const y1 = height * factor;
140
+ const z0 = 0;
141
+ const z1 = factor;
142
+ const newQuad = Quad.Create([
143
+ [x1, y0, z0],
144
+ [x1, y0, z1],
145
+ [x1, y1, z1],
146
+ [x1, y1, z0],
147
+ ], Quad.FullUVs, false);
148
+ let [sx, sy] = eastFace;
149
+ let ex = x + 1;
150
+ let ey = height;
151
+ addUvs(newQuad, factor, sx, sy, ex, ey);
152
+ tool.vars.textureIndex = textureId;
153
+ addItemQuad(tool, newQuad);
154
+ }
155
+ if (westFace) {
156
+ const x0 = x * factor;
157
+ const y0 = westFace[1] * factor;
158
+ const y1 = height * factor;
159
+ const z0 = 0;
160
+ const z1 = factor;
161
+ const newQuad = Quad.Create([
162
+ [x0, y0, z0],
163
+ [x0, y1, z0],
164
+ [x0, y1, z1],
165
+ [x0, y0, z1],
166
+ ], Quad.FullUVs, false);
167
+ let [sx, sy] = westFace;
168
+ let ex = x + 1;
169
+ let ey = height;
170
+ addUvs(newQuad, factor, sx, sy, ex, ey);
171
+ tool.vars.textureIndex = textureId;
172
+ addItemQuad(tool, newQuad);
173
+ }
142
174
  }
175
+ // Up/Down faces
143
176
  for (let y = 0; y < height; y++) {
144
177
  let upFace = null;
145
178
  let downFace = null;
@@ -162,18 +195,15 @@ export function MeshTexture(textureId, textureData, origin = Vector3Like.Create(
162
195
  const y1 = y * factor + factor;
163
196
  const z0 = 0;
164
197
  const z1 = factor;
165
- // +Y normal — CCW when viewed from +Y
166
198
  const newQuad = Quad.Create([
167
- [x0, y1, z0], // p0
168
- [x1, y1, z0], // p1
169
- [x1, y1, z1], // p2
170
- [x0, y1, z1], // p3
171
- ], Quad.FullUVs, false
172
- // 0
173
- );
199
+ [x0, y1, z0],
200
+ [x1, y1, z0],
201
+ [x1, y1, z1],
202
+ [x0, y1, z1],
203
+ ], Quad.FullUVs, false);
174
204
  let [sx, sy] = upFace;
175
- let [ex, ey] = [x, y];
176
- ey += 1;
205
+ let ex = x;
206
+ let ey = y + 1;
177
207
  addUvs(newQuad, factor, sx, sy, ex, ey);
178
208
  upFace = null;
179
209
  tool.vars.textureIndex = textureId;
@@ -185,18 +215,15 @@ export function MeshTexture(textureId, textureData, origin = Vector3Like.Create(
185
215
  const y0 = y * factor;
186
216
  const z0 = 0;
187
217
  const z1 = factor;
188
- // -Y normal — flip winding relative to +Y
189
218
  const newQuad = Quad.Create([
190
- [x0, y0, z0], // p0
191
- [x0, y0, z1], // p1
192
- [x1, y0, z1], // p2
193
- [x1, y0, z0], // p3
194
- ], Quad.FullUVs, false
195
- // 1
196
- );
219
+ [x0, y0, z0],
220
+ [x0, y0, z1],
221
+ [x1, y0, z1],
222
+ [x1, y0, z0],
223
+ ], Quad.FullUVs, false);
197
224
  let [sx, sy] = downFace;
198
- let [ex, ey] = [x, y];
199
- ey += 1;
225
+ let ex = x;
226
+ let ey = y + 1;
200
227
  addUvs(newQuad, factor, sx, sy, ex, ey);
201
228
  downFace = null;
202
229
  tool.vars.textureIndex = textureId;
@@ -210,6 +237,47 @@ export function MeshTexture(textureId, textureData, origin = Vector3Like.Create(
210
237
  downFace = [x, y];
211
238
  }
212
239
  }
240
+ // FLUSH: emit any remaining faces at the right edge
241
+ if (upFace) {
242
+ const x0 = upFace[0] * factor;
243
+ const x1 = width * factor;
244
+ const y1 = y * factor + factor;
245
+ const z0 = 0;
246
+ const z1 = factor;
247
+ const newQuad = Quad.Create([
248
+ [x0, y1, z0],
249
+ [x1, y1, z0],
250
+ [x1, y1, z1],
251
+ [x0, y1, z1],
252
+ ], Quad.FullUVs, false);
253
+ let [sx, sy] = upFace;
254
+ let ex = width;
255
+ let ey = y + 1;
256
+ addUvs(newQuad, factor, sx, sy, ex, ey);
257
+ tool.vars.textureIndex = textureId;
258
+ addItemQuad(tool, newQuad);
259
+ }
260
+ if (downFace) {
261
+ const x0 = downFace[0] * factor;
262
+ const x1 = width * factor;
263
+ const y0 = y * factor;
264
+ const z0 = 0;
265
+ const z1 = factor;
266
+ const newQuad = Quad.Create([
267
+ [x0, y0, z0],
268
+ [x0, y0, z1],
269
+ [x1, y0, z1],
270
+ [x1, y0, z0],
271
+ ], Quad.FullUVs, false);
272
+ let [sx, sy] = downFace;
273
+ let ex = width;
274
+ let ey = y + 1;
275
+ addUvs(newQuad, factor, sx, sy, ex, ey);
276
+ tool.vars.textureIndex = textureId;
277
+ addItemQuad(tool, newQuad);
278
+ }
213
279
  }
214
- return CompactItemMesh([tool]);
280
+ const compacted = CompactItemMesh([tool]);
281
+ tool.clear();
282
+ return compacted;
215
283
  }
@@ -0,0 +1,6 @@
1
+ import { DataCursorInterface } from "../../../Voxels/Cursor/DataCursor.interface";
2
+ import { VoxelModelBuilder } from "../Models/VoxelModelBuilder";
3
+ import { Vector3Like } from "@amodx/math";
4
+ import { VoxelCursorInterface } from "Voxels/Cursor/VoxelCursor.interface";
5
+ export declare function BuildVoxelBase(builder: VoxelModelBuilder, secondary?: boolean): boolean;
6
+ export declare function BuildVoxel(x: number, y: number, z: number, voxel: VoxelCursorInterface, worldCursor: DataCursorInterface, origin: Vector3Like): boolean;
@@ -0,0 +1,101 @@
1
+ import { VoxelLUT } from "../../../Voxels/Data/VoxelLUT";
2
+ import { GeometryLUT } from "../../../Voxels/Data/GeometryLUT";
3
+ import { VoxelGeometryConstructorRegister } from "../Models/VoxelGeometryConstructorRegister";
4
+ import { RenderedMaterials } from "../Models/RenderedMaterials";
5
+ export function BuildVoxelBase(builder, secondary = false) {
6
+ let added = false;
7
+ const hashed = builder.space.getHash(builder.nVoxel, builder.position.x, builder.position.y, builder.position.z);
8
+ if (secondary && !builder.space.getHasSecondary(hashed))
9
+ return false;
10
+ const trueVoxelId = builder.space.getTrueVoxelId(hashed, secondary);
11
+ const voxelId = builder.space.getVoxelId(hashed, secondary);
12
+ const reltionalVoxelId = builder.space.getRelationalVoxelId(hashed, secondary);
13
+ const geomtriesIndex = VoxelLUT.getGeometryIndex(voxelId, reltionalVoxelId);
14
+ const geomtries = GeometryLUT.geometryIndex[geomtriesIndex];
15
+ const inputsIndex = VoxelLUT.getGeometryInputIndex(voxelId, reltionalVoxelId);
16
+ const inputs = GeometryLUT.geometryInputsIndex[inputsIndex];
17
+ const geometriesLength = geomtries.length;
18
+ for (let i = 0; i < geometriesLength; i++) {
19
+ const nodeId = geomtries[i];
20
+ const inputsIndex = inputs[i];
21
+ const geoInputs = GeometryLUT.geometryInputs[inputsIndex];
22
+ const geometry = VoxelGeometryConstructorRegister.geometry[nodeId];
23
+ const nodesLength = geometry.nodes.length;
24
+ for (let k = 0; k < nodesLength; k++) {
25
+ const geo = geometry.nodes[k];
26
+ geo.builder = builder;
27
+ const addedGeo = geo.add(geoInputs[k]);
28
+ if (addedGeo)
29
+ added = true;
30
+ }
31
+ }
32
+ const conditioanlNodes = VoxelLUT.getConditionalGeometryNodes(VoxelLUT.modelsIndex[trueVoxelId]);
33
+ if (conditioanlNodes) {
34
+ const modelState = VoxelLUT.voxelIdToState[voxelId];
35
+ const reltionalState = builder.space.getRelationalState(hashed, secondary);
36
+ const nodesLength = conditioanlNodes.length;
37
+ for (let i = 0; i < nodesLength; i++) {
38
+ const [geoId, requiredModelState, requiredModelReltionalState] = conditioanlNodes[i];
39
+ if (requiredModelState !== modelState ||
40
+ !requiredModelReltionalState[reltionalState])
41
+ continue;
42
+ const geomtries = GeometryLUT.geometryIndex[geoId];
43
+ const inputsIndex = VoxelLUT.getConditionalGeometryInputIndex(geoId, voxelId, reltionalVoxelId);
44
+ const inputs = GeometryLUT.geometryInputsIndex[inputsIndex];
45
+ const geometriesLength = geomtries.length;
46
+ for (let i = 0; i < geometriesLength; i++) {
47
+ const nodeId = geomtries[i];
48
+ const inputsIndex = inputs[i];
49
+ const geoInputs = GeometryLUT.geometryInputs[inputsIndex];
50
+ const geometry = VoxelGeometryConstructorRegister.geometry[nodeId];
51
+ const nodesLength = geometry.nodes.length;
52
+ for (let k = 0; k < nodesLength; k++) {
53
+ const geo = geometry.nodes[k];
54
+ geo.builder = builder;
55
+ const addedGeo = geo.add(geoInputs[k]);
56
+ if (addedGeo)
57
+ added = true;
58
+ }
59
+ }
60
+ }
61
+ }
62
+ /* this.effects.addEffects(
63
+ builder.voxel.getState(),
64
+ builder.origin,
65
+ builder.effects
66
+ ); */
67
+ builder.clearCalculatedData();
68
+ return added;
69
+ }
70
+ export function BuildVoxel(x, y, z, voxel, worldCursor, origin) {
71
+ const builder = RenderedMaterials.meshers[VoxelLUT.materialMap[voxel.getVoxelId()]];
72
+ builder.origin.x = origin.x;
73
+ builder.origin.y = origin.y;
74
+ builder.origin.z = origin.z;
75
+ builder.position.x = x;
76
+ builder.position.y = y;
77
+ builder.position.z = z;
78
+ builder.voxel = voxel;
79
+ builder.nVoxel = worldCursor;
80
+ builder.startConstruction();
81
+ const added = BuildVoxelBase(builder);
82
+ builder.endConstruction();
83
+ let addedSecondary = false;
84
+ if (voxel.canHaveSecondaryVoxel()) {
85
+ voxel.setSecondary(true);
86
+ const builder = RenderedMaterials.meshers[VoxelLUT.materialMap[voxel.getVoxelId()]];
87
+ builder.origin.x = origin.x;
88
+ builder.origin.y = origin.y;
89
+ builder.origin.z = origin.z;
90
+ builder.position.x = x;
91
+ builder.position.y = y;
92
+ builder.position.z = z;
93
+ builder.voxel = voxel;
94
+ builder.nVoxel = worldCursor;
95
+ builder.startConstruction();
96
+ addedSecondary = BuildVoxelBase(builder, true);
97
+ builder.endConstruction();
98
+ voxel.setSecondary(false);
99
+ }
100
+ return added || addedSecondary;
101
+ }
@@ -2,39 +2,29 @@ import { VoxelMeshVertexStructCursor } from "../Geometry/VoxelMeshVertexStructCu
2
2
  import { CompactedSectionVoxelMesh, CompactedMeshData, } from "../Geometry/CompactedSectionVoxelMesh";
3
3
  const meshData = new CompactedMeshData();
4
4
  const compactedMesh = new CompactedSectionVoxelMesh();
5
- /** Utility to ensure a value is aligned to 4 bytes. */
6
5
  function align4(value) {
7
6
  return (value + 3) & ~3;
8
7
  }
9
8
  export function CompactVoxelSectionMesh(location, tools, transfers = []) {
10
- // 1) First compute how large the final buffer needs to be (with 4-byte alignment).
11
9
  let headerSize = CompactedSectionVoxelMesh.GetHeaderByteSize(tools.length);
12
- // Make the header itself 4-byte aligned
13
10
  headerSize = align4(headerSize);
14
11
  let totalByteCount = headerSize;
15
12
  for (let i = 0; i < tools.length; i++) {
16
13
  const tool = tools[i];
17
- // Add the vertex data
18
14
  const vertexByteSize = tool.mesh.vertexCount * VoxelMeshVertexStructCursor.VertexByteSize;
19
15
  totalByteCount += vertexByteSize;
20
- // Align after writing vertex data
21
16
  totalByteCount = align4(totalByteCount);
22
- // Add the index data
23
17
  const indexByteSize = tool.mesh.indicieCount * 4;
24
18
  totalByteCount += indexByteSize;
25
- // Align after writing index data
26
19
  totalByteCount = align4(totalByteCount);
27
20
  }
28
- // 2) Allocate the final buffer
29
21
  const buffer = new ArrayBuffer(totalByteCount);
30
22
  compactedMesh.setData(buffer);
31
23
  compactedMesh.setLocation(...location);
32
24
  compactedMesh.setTotalMeshes(tools.length);
33
- // We'll track our position in the buffer here
34
25
  let byteCount = headerSize;
35
26
  for (let i = 0; i < tools.length; i++) {
36
27
  const tool = tools[i];
37
- // Fill out the meshData structure
38
28
  meshData.materialId = tool.id;
39
29
  const minBounds = tool.mesh.minBounds;
40
30
  const maxBounds = tool.mesh.maxBounds;
@@ -44,27 +34,20 @@ export function CompactVoxelSectionMesh(location, tools, transfers = []) {
44
34
  meshData.maxBounds[0] = maxBounds.x;
45
35
  meshData.maxBounds[1] = maxBounds.y;
46
36
  meshData.maxBounds[2] = maxBounds.z;
47
- // Vertex info
48
37
  const totalVertFloats = tool.mesh.vertexCount * VoxelMeshVertexStructCursor.VertexFloatSize;
49
38
  const vertexByteCount = totalVertFloats * 4;
50
39
  meshData.vertexIndex[0] = byteCount;
51
40
  meshData.vertexIndex[1] = totalVertFloats;
52
- // Now move the pointer
53
41
  byteCount += vertexByteCount;
54
- // Align to 4 bytes again before writing indices
55
42
  byteCount = align4(byteCount);
56
- // Index info
57
43
  meshData.indiceIndex[0] = byteCount;
58
44
  meshData.indiceIndex[1] = tool.mesh.indicieCount;
59
45
  const indexByteCount = tool.mesh.indicieCount * 4;
60
46
  byteCount += indexByteCount;
61
- // Align to 4 bytes for the next iteration (or final)
62
47
  byteCount = align4(byteCount);
63
- // Store the meta info
64
48
  compactedMesh.setMeshData(i, meshData);
65
- // Write vertex data
66
49
  const vertexArray = new Float32Array(buffer, meshData.vertexIndex[0], totalVertFloats);
67
- const vertexBuffers = tool.mesh.buffer._buffers;
50
+ const vertexBuffers = tool.mesh.buffer._float32Views;
68
51
  let start = 0;
69
52
  let done = false;
70
53
  for (let b = 0; b < vertexBuffers.length; b++) {
@@ -80,7 +63,6 @@ export function CompactVoxelSectionMesh(location, tools, transfers = []) {
80
63
  if (done)
81
64
  break;
82
65
  }
83
- // Write index data
84
66
  const indicesArray = new Uint32Array(buffer, meshData.indiceIndex[0], tool.mesh.indicieCount);
85
67
  const indiceBuffers = tool.mesh.indices._buffers;
86
68
  start = 0;
@@ -99,8 +81,6 @@ export function CompactVoxelSectionMesh(location, tools, transfers = []) {
99
81
  break;
100
82
  }
101
83
  }
102
- // Transfer the ArrayBuffer to your worker if needed
103
84
  transfers.push(buffer);
104
- // Return the buffer or the task object as needed
105
85
  return buffer;
106
86
  }
@@ -2,30 +2,13 @@
2
2
  import { WorldSpaces } from "../../../World/WorldSpaces.js";
3
3
  //tools
4
4
  import { VoxelGeometryBuilderCacheSpace } from "../Models/VoxelGeometryBuilderCacheSpace.js";
5
- import { VoxelModelConstructorRegister } from "../Models/VoxelModelConstructorRegister.js";
6
5
  import { VoxelMeshBVHBuilder } from "../Geometry/VoxelMeshBVHBuilder";
7
6
  import { Vector3Like } from "@amodx/math";
8
7
  import { RenderedMaterials } from "../Models/RenderedMaterials";
9
8
  import { CompactVoxelSectionMesh } from "./CompactVoxelSectionMesh";
9
+ import { BuildVoxel } from "./BuildVoxel";
10
10
  let space;
11
11
  const bvhTool = new VoxelMeshBVHBuilder();
12
- function meshVoxel(x, y, z, voxel, worldCursor, sectionCursor) {
13
- let added = false;
14
- const constructor = VoxelModelConstructorRegister.constructorsPaltte[voxel.getVoxelId()];
15
- const builder = constructor.builder;
16
- builder.origin.x = sectionCursor._voxelPosition.x;
17
- builder.origin.y = sectionCursor._voxelPosition.y;
18
- builder.origin.z = sectionCursor._voxelPosition.z;
19
- builder.position.x = x;
20
- builder.position.y = y;
21
- builder.position.z = z;
22
- builder.voxel = voxel;
23
- builder.nVoxel = worldCursor;
24
- builder.startConstruction();
25
- added = constructor.process();
26
- builder.endConstruction();
27
- return added;
28
- }
29
12
  const padding = Vector3Like.Create(5, 5, 5);
30
13
  export function MeshSectionBase(worldCursor, sectionCursor, location, transfers = []) {
31
14
  if (!space)
@@ -53,6 +36,7 @@ export function MeshSectionBase(worldCursor, sectionCursor, location, transfers
53
36
  const slice = WorldSpaces.section.bounds.x * WorldSpaces.section.bounds.z;
54
37
  const startY = minY * slice;
55
38
  const endY = (maxY + 1) * slice;
39
+ let first = false;
56
40
  for (let i = startY; i < endY; i++) {
57
41
  if (!(i % slice)) {
58
42
  const y = i / slice;
@@ -68,16 +52,9 @@ export function MeshSectionBase(worldCursor, sectionCursor, location, transfers
68
52
  const y = cy + sectionCursor._voxelPosition.y;
69
53
  const z = cz + sectionCursor._voxelPosition.z;
70
54
  let addedVoxel = false;
71
- if (meshVoxel(x, y, z, voxel, worldCursor, sectionCursor)) {
55
+ if (BuildVoxel(x, y, z, voxel, worldCursor, sectionCursor._voxelPosition)) {
72
56
  addedVoxel = true;
73
57
  }
74
- if (voxel.hasSecondaryVoxel()) {
75
- voxel.setSecondary(true);
76
- if (meshVoxel(x, y, z, voxel, worldCursor, sectionCursor)) {
77
- addedVoxel = true;
78
- }
79
- voxel.setSecondary(false);
80
- }
81
58
  section.setBuried(i, !addedVoxel);
82
59
  }
83
60
  const meshed = [];
@@ -1,6 +1,5 @@
1
1
  import { Vector4Like } from "@amodx/math";
2
2
  import { VoxelShaderData } from "./VoxelShaderData";
3
- import { QuadVerticies } from "../../Geometry/Geometry.types";
4
3
  import { VoxelMeshVertexConstants } from "./VoxelMeshVertexStructCursor";
5
4
  const vector1ShaderData = Vector4Like.Create();
6
5
  const vector2ShaderData = Vector4Like.Create();
@@ -21,9 +20,9 @@ export function addVoxelTriangle(builder, tri) {
21
20
  const topRightNor = tri.normals.vertices[0];
22
21
  const topLeftNor = tri.normals.vertices[1];
23
22
  const bottomLeftNor = tri.normals.vertices[2];
24
- const topRightVoxelData = VoxelShaderData.create(worldLight.vertices[QuadVerticies.TopRight], worldLight.vertices[QuadVerticies.TopLeft], worldLight.vertices[QuadVerticies.BottomLeft], worldLight.vertices[QuadVerticies.BottomRight], worldAO.vertices[QuadVerticies.TopRight], worldAO.vertices[QuadVerticies.TopLeft], worldAO.vertices[QuadVerticies.BottomLeft], worldAO.vertices[QuadVerticies.BottomRight], animData.vertices[QuadVerticies.TopRight], QuadVerticies.TopRight, vector1ShaderData);
25
- const topLeftVoxelData = VoxelShaderData.create(worldLight.vertices[QuadVerticies.TopRight], worldLight.vertices[QuadVerticies.TopLeft], worldLight.vertices[QuadVerticies.BottomLeft], worldLight.vertices[QuadVerticies.BottomRight], worldAO.vertices[QuadVerticies.TopRight], worldAO.vertices[QuadVerticies.TopLeft], worldAO.vertices[QuadVerticies.BottomLeft], worldAO.vertices[QuadVerticies.BottomRight], animData.vertices[QuadVerticies.TopLeft], QuadVerticies.TopLeft, vector2ShaderData);
26
- const bottomLeftVoxelData = VoxelShaderData.create(worldLight.vertices[QuadVerticies.TopRight], worldLight.vertices[QuadVerticies.TopLeft], worldLight.vertices[QuadVerticies.BottomLeft], worldLight.vertices[QuadVerticies.BottomRight], worldAO.vertices[QuadVerticies.TopRight], worldAO.vertices[QuadVerticies.TopLeft], worldAO.vertices[QuadVerticies.BottomLeft], worldAO.vertices[QuadVerticies.BottomRight], animData.vertices[QuadVerticies.BottomLeft], QuadVerticies.BottomLeft, vector3ShaderData);
23
+ const topRightVoxelData = VoxelShaderData.create(worldLight.vertices[0 /* QuadVerticies.TopRight */], worldLight.vertices[1 /* QuadVerticies.TopLeft */], worldLight.vertices[2 /* QuadVerticies.BottomLeft */], worldLight.vertices[3 /* QuadVerticies.BottomRight */], worldAO.vertices[0 /* QuadVerticies.TopRight */], worldAO.vertices[1 /* QuadVerticies.TopLeft */], worldAO.vertices[2 /* QuadVerticies.BottomLeft */], worldAO.vertices[3 /* QuadVerticies.BottomRight */], animData.vertices[0 /* QuadVerticies.TopRight */], 0 /* QuadVerticies.TopRight */, vector1ShaderData);
24
+ const topLeftVoxelData = VoxelShaderData.create(worldLight.vertices[0 /* QuadVerticies.TopRight */], worldLight.vertices[1 /* QuadVerticies.TopLeft */], worldLight.vertices[2 /* QuadVerticies.BottomLeft */], worldLight.vertices[3 /* QuadVerticies.BottomRight */], worldAO.vertices[0 /* QuadVerticies.TopRight */], worldAO.vertices[1 /* QuadVerticies.TopLeft */], worldAO.vertices[2 /* QuadVerticies.BottomLeft */], worldAO.vertices[3 /* QuadVerticies.BottomRight */], animData.vertices[1 /* QuadVerticies.TopLeft */], 1 /* QuadVerticies.TopLeft */, vector2ShaderData);
25
+ const bottomLeftVoxelData = VoxelShaderData.create(worldLight.vertices[0 /* QuadVerticies.TopRight */], worldLight.vertices[1 /* QuadVerticies.TopLeft */], worldLight.vertices[2 /* QuadVerticies.BottomLeft */], worldLight.vertices[3 /* QuadVerticies.BottomRight */], worldAO.vertices[0 /* QuadVerticies.TopRight */], worldAO.vertices[1 /* QuadVerticies.TopLeft */], worldAO.vertices[2 /* QuadVerticies.BottomLeft */], worldAO.vertices[3 /* QuadVerticies.BottomRight */], animData.vertices[2 /* QuadVerticies.BottomLeft */], 2 /* QuadVerticies.BottomLeft */, vector3ShaderData);
27
26
  const indices = builder.mesh.indices;
28
27
  let indIndex = builder.mesh.indicieCount;
29
28
  let sides = tri.doubleSided ? 2 : 1;
@@ -31,11 +30,11 @@ export function addVoxelTriangle(builder, tri) {
31
30
  while (sides--) {
32
31
  const baseIndex = builder.mesh.vertexCount;
33
32
  builder.mesh.buffer.setIndex(baseIndex);
34
- addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentArray, origin, topRightPos, topRightNor, tri.uvs.vertices[QuadVerticies.TopRight], topRightVoxelData, texture, overlayTextures);
33
+ addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentFloat32Array, builder.mesh.buffer.currentUint32Array, origin, topRightPos, topRightNor, tri.uvs.vertices[0 /* QuadVerticies.TopRight */], topRightVoxelData, texture, overlayTextures);
35
34
  builder.mesh.buffer.setIndex(baseIndex + 1);
36
- addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentArray, origin, topLeftPos, topLeftNor, tri.uvs.vertices[QuadVerticies.TopLeft], topLeftVoxelData, texture, overlayTextures);
35
+ addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentFloat32Array, builder.mesh.buffer.currentUint32Array, origin, topLeftPos, topLeftNor, tri.uvs.vertices[1 /* QuadVerticies.TopLeft */], topLeftVoxelData, texture, overlayTextures);
37
36
  builder.mesh.buffer.setIndex(baseIndex + 2);
38
- addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentArray, origin, bottomLeftPos, bottomLeftNor, tri.uvs.vertices[QuadVerticies.BottomLeft], bottomLeftVoxelData, texture, overlayTextures);
37
+ addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentFloat32Array, builder.mesh.buffer.currentUint32Array, origin, bottomLeftPos, bottomLeftNor, tri.uvs.vertices[2 /* QuadVerticies.BottomLeft */], bottomLeftVoxelData, texture, overlayTextures);
39
38
  builder.mesh.addVerticies(3, 3);
40
39
  }
41
40
  if (!tri.doubleSided) {
@@ -80,21 +79,21 @@ export function addVoxelQuad(builder, quad) {
80
79
  const topLeftNor = quad.normals.vertices[1];
81
80
  const bottomLeftNor = quad.normals.vertices[2];
82
81
  const bottomRightNor = quad.normals.vertices[3];
83
- const topRightVoxelData = VoxelShaderData.create(worldLight.vertices[QuadVerticies.TopRight], worldLight.vertices[QuadVerticies.TopLeft], worldLight.vertices[QuadVerticies.BottomLeft], worldLight.vertices[QuadVerticies.BottomRight], worldAO.vertices[QuadVerticies.TopRight], worldAO.vertices[QuadVerticies.TopLeft], worldAO.vertices[QuadVerticies.BottomLeft], worldAO.vertices[QuadVerticies.BottomRight], animData.vertices[QuadVerticies.TopRight], QuadVerticies.TopRight, vector1ShaderData);
84
- const topLeftVoxelData = VoxelShaderData.create(worldLight.vertices[QuadVerticies.TopRight], worldLight.vertices[QuadVerticies.TopLeft], worldLight.vertices[QuadVerticies.BottomLeft], worldLight.vertices[QuadVerticies.BottomRight], worldAO.vertices[QuadVerticies.TopRight], worldAO.vertices[QuadVerticies.TopLeft], worldAO.vertices[QuadVerticies.BottomLeft], worldAO.vertices[QuadVerticies.BottomRight], animData.vertices[QuadVerticies.TopLeft], QuadVerticies.TopLeft, vector2ShaderData);
85
- const bottomLeftVoxelData = VoxelShaderData.create(worldLight.vertices[QuadVerticies.TopRight], worldLight.vertices[QuadVerticies.TopLeft], worldLight.vertices[QuadVerticies.BottomLeft], worldLight.vertices[QuadVerticies.BottomRight], worldAO.vertices[QuadVerticies.TopRight], worldAO.vertices[QuadVerticies.TopLeft], worldAO.vertices[QuadVerticies.BottomLeft], worldAO.vertices[QuadVerticies.BottomRight], animData.vertices[QuadVerticies.BottomLeft], QuadVerticies.BottomLeft, vector3ShaderData);
86
- const bottomRightVoxelData = VoxelShaderData.create(worldLight.vertices[QuadVerticies.TopRight], worldLight.vertices[QuadVerticies.TopLeft], worldLight.vertices[QuadVerticies.BottomLeft], worldLight.vertices[QuadVerticies.BottomRight], worldAO.vertices[QuadVerticies.TopRight], worldAO.vertices[QuadVerticies.TopLeft], worldAO.vertices[QuadVerticies.BottomLeft], worldAO.vertices[QuadVerticies.BottomRight], animData.vertices[QuadVerticies.BottomRight], QuadVerticies.BottomRight, vector4ShaderData);
82
+ const topRightVoxelData = VoxelShaderData.create(worldLight.vertices[0 /* QuadVerticies.TopRight */], worldLight.vertices[1 /* QuadVerticies.TopLeft */], worldLight.vertices[2 /* QuadVerticies.BottomLeft */], worldLight.vertices[3 /* QuadVerticies.BottomRight */], worldAO.vertices[0 /* QuadVerticies.TopRight */], worldAO.vertices[1 /* QuadVerticies.TopLeft */], worldAO.vertices[2 /* QuadVerticies.BottomLeft */], worldAO.vertices[3 /* QuadVerticies.BottomRight */], animData.vertices[0 /* QuadVerticies.TopRight */], 0 /* QuadVerticies.TopRight */, vector1ShaderData);
83
+ const topLeftVoxelData = VoxelShaderData.create(worldLight.vertices[0 /* QuadVerticies.TopRight */], worldLight.vertices[1 /* QuadVerticies.TopLeft */], worldLight.vertices[2 /* QuadVerticies.BottomLeft */], worldLight.vertices[3 /* QuadVerticies.BottomRight */], worldAO.vertices[0 /* QuadVerticies.TopRight */], worldAO.vertices[1 /* QuadVerticies.TopLeft */], worldAO.vertices[2 /* QuadVerticies.BottomLeft */], worldAO.vertices[3 /* QuadVerticies.BottomRight */], animData.vertices[1 /* QuadVerticies.TopLeft */], 1 /* QuadVerticies.TopLeft */, vector2ShaderData);
84
+ const bottomLeftVoxelData = VoxelShaderData.create(worldLight.vertices[0 /* QuadVerticies.TopRight */], worldLight.vertices[1 /* QuadVerticies.TopLeft */], worldLight.vertices[2 /* QuadVerticies.BottomLeft */], worldLight.vertices[3 /* QuadVerticies.BottomRight */], worldAO.vertices[0 /* QuadVerticies.TopRight */], worldAO.vertices[1 /* QuadVerticies.TopLeft */], worldAO.vertices[2 /* QuadVerticies.BottomLeft */], worldAO.vertices[3 /* QuadVerticies.BottomRight */], animData.vertices[2 /* QuadVerticies.BottomLeft */], 2 /* QuadVerticies.BottomLeft */, vector3ShaderData);
85
+ const bottomRightVoxelData = VoxelShaderData.create(worldLight.vertices[0 /* QuadVerticies.TopRight */], worldLight.vertices[1 /* QuadVerticies.TopLeft */], worldLight.vertices[2 /* QuadVerticies.BottomLeft */], worldLight.vertices[3 /* QuadVerticies.BottomRight */], worldAO.vertices[0 /* QuadVerticies.TopRight */], worldAO.vertices[1 /* QuadVerticies.TopLeft */], worldAO.vertices[2 /* QuadVerticies.BottomLeft */], worldAO.vertices[3 /* QuadVerticies.BottomRight */], animData.vertices[3 /* QuadVerticies.BottomRight */], 3 /* QuadVerticies.BottomRight */, vector4ShaderData);
87
86
  const indices = builder.mesh.indices;
88
87
  let indIndex = builder.mesh.indicieCount;
89
88
  const baseIndex = builder.mesh.vertexCount;
90
89
  builder.mesh.buffer.setIndex(baseIndex);
91
- addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentArray, origin, topRightPos, topRightNor, quad.uvs.vertices[QuadVerticies.TopRight], topRightVoxelData, texture, overlayTextures);
90
+ addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentFloat32Array, builder.mesh.buffer.currentUint32Array, origin, topRightPos, topRightNor, quad.uvs.vertices[0 /* QuadVerticies.TopRight */], topRightVoxelData, texture, overlayTextures);
92
91
  builder.mesh.buffer.setIndex(baseIndex + 1);
93
- addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentArray, origin, topLeftPos, topLeftNor, quad.uvs.vertices[QuadVerticies.TopLeft], topLeftVoxelData, texture, overlayTextures);
92
+ addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentFloat32Array, builder.mesh.buffer.currentUint32Array, origin, topLeftPos, topLeftNor, quad.uvs.vertices[1 /* QuadVerticies.TopLeft */], topLeftVoxelData, texture, overlayTextures);
94
93
  builder.mesh.buffer.setIndex(baseIndex + 2);
95
- addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentArray, origin, bottomLeftPos, bottomLeftNor, quad.uvs.vertices[QuadVerticies.BottomLeft], bottomLeftVoxelData, texture, overlayTextures);
94
+ addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentFloat32Array, builder.mesh.buffer.currentUint32Array, origin, bottomLeftPos, bottomLeftNor, quad.uvs.vertices[2 /* QuadVerticies.BottomLeft */], bottomLeftVoxelData, texture, overlayTextures);
96
95
  builder.mesh.buffer.setIndex(baseIndex + 3);
97
- addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentArray, origin, bottomRightPos, bottomRightNor, quad.uvs.vertices[QuadVerticies.BottomRight], bottomRightVoxelData, texture, overlayTextures);
96
+ addVertex(builder.mesh.buffer.curentIndex, builder.mesh.buffer.currentFloat32Array, builder.mesh.buffer.currentUint32Array, origin, bottomRightPos, bottomRightNor, quad.uvs.vertices[3 /* QuadVerticies.BottomRight */], bottomRightVoxelData, texture, overlayTextures);
98
97
  if (!quad.doubleSided) {
99
98
  let index = baseIndex;
100
99
  indices.setIndex(indIndex).currentArray[indices.curentIndex] = index;
@@ -136,27 +135,30 @@ export function addVoxelQuad(builder, quad) {
136
135
  }
137
136
  builder.vars.reset();
138
137
  }
139
- function addVertex(index, array, origin, position, normal, uvs, voxelData, texture, overlayTextures) {
138
+ function addVertex(index, float32Array, uint32Array, origin, position, normal, uvs, voxelData, texture, overlayTextures) {
140
139
  index *= VoxelMeshVertexConstants.VertexFloatSize;
141
- array[VoxelMeshVertexConstants.PositionOffset + index] =
140
+ float32Array[VoxelMeshVertexConstants.PositionOffset + index] =
142
141
  position.x + origin.x;
143
- array[VoxelMeshVertexConstants.PositionOffset + index + 1] =
142
+ float32Array[VoxelMeshVertexConstants.PositionOffset + index + 1] =
144
143
  position.y + origin.y;
145
- array[VoxelMeshVertexConstants.PositionOffset + index + 2] =
144
+ float32Array[VoxelMeshVertexConstants.PositionOffset + index + 2] =
146
145
  position.z + origin.z;
147
- array[VoxelMeshVertexConstants.UVOffset + index] = uvs.x;
148
- array[VoxelMeshVertexConstants.UVOffset + index + 1] = uvs.y;
149
- array[VoxelMeshVertexConstants.NormalOffset + index] = normal.x;
150
- array[VoxelMeshVertexConstants.NormalOffset + index + 1] = normal.y;
151
- array[VoxelMeshVertexConstants.NormalOffset + index + 2] = normal.z;
152
- array[VoxelMeshVertexConstants.TextureIndexOffset + index] =
146
+ float32Array[VoxelMeshVertexConstants.UVOffset + index] = uvs.x;
147
+ float32Array[VoxelMeshVertexConstants.UVOffset + index + 1] = uvs.y;
148
+ float32Array[VoxelMeshVertexConstants.NormalOffset + index] = normal.x;
149
+ float32Array[VoxelMeshVertexConstants.NormalOffset + index + 1] = normal.y;
150
+ float32Array[VoxelMeshVertexConstants.NormalOffset + index + 2] = normal.z;
151
+ uint32Array[VoxelMeshVertexConstants.TextureIndexOffset + index] =
153
152
  VoxelShaderData.createTextureIndex(texture, overlayTextures.x);
154
- array[VoxelMeshVertexConstants.TextureIndexOffset + index + 1] =
153
+ uint32Array[VoxelMeshVertexConstants.TextureIndexOffset + index + 1] =
155
154
  VoxelShaderData.createTextureIndex(overlayTextures.y, overlayTextures.z);
156
- array[VoxelMeshVertexConstants.TextureIndexOffset + index + 2] =
155
+ uint32Array[VoxelMeshVertexConstants.TextureIndexOffset + index + 2] =
157
156
  VoxelShaderData.createTextureIndex(overlayTextures.w, 0);
158
- array[VoxelMeshVertexConstants.VoxelDataOFfset + index] = voxelData.x;
159
- array[VoxelMeshVertexConstants.VoxelDataOFfset + index + 1] = voxelData.y;
160
- array[VoxelMeshVertexConstants.VoxelDataOFfset + index + 2] = voxelData.z;
161
- array[VoxelMeshVertexConstants.VoxelDataOFfset + index + 3] = voxelData.w;
157
+ uint32Array[VoxelMeshVertexConstants.VoxelDataOFfset + index] = voxelData.x;
158
+ uint32Array[VoxelMeshVertexConstants.VoxelDataOFfset + index + 1] =
159
+ voxelData.y;
160
+ uint32Array[VoxelMeshVertexConstants.VoxelDataOFfset + index + 2] =
161
+ voxelData.z;
162
+ uint32Array[VoxelMeshVertexConstants.VoxelDataOFfset + index + 3] =
163
+ voxelData.w;
162
164
  }