@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
@@ -17,13 +17,9 @@ export class VoxelShaderData {
17
17
  static TextureIndexMax = 0xffff;
18
18
  static createTextureIndex(index1, index2) {
19
19
  let value = 0;
20
- value =
21
- (value & ~(this.TextureIndexMax << 0)) |
22
- ((index1 & this.TextureIndexMax) << 0);
23
- value =
24
- (value & ~(this.TextureIndexMax << 16)) |
25
- ((index2 & this.TextureIndexMax) << 16);
26
- return value;
20
+ value = (value & ~(this.TextureIndexMax << 0)) | ((index1 & this.TextureIndexMax) << 0);
21
+ value = (value & ~(this.TextureIndexMax << 16)) | ((index2 & this.TextureIndexMax) << 16);
22
+ return value >>> 0;
27
23
  }
28
24
  static create(light1, light2, light3, light4, ao1, ao2, ao3, ao4, animation, vertexIndex, ref = Vector4Like.Create()) {
29
25
  let x = 0;
@@ -2,32 +2,13 @@ import { VoxelGeometryBuilderCacheSpace } from "./Models/VoxelGeometryBuilderCac
2
2
  import { TemplateCursor } from "../../Templates/Cursor/TemplateCursor.js";
3
3
  import { FullVoxelTemplate } from "../../Templates/Full/FullVoxelTemplate.js";
4
4
  import { CompactTemplateMesh } from "./Base/CompactTemplateMesh.js";
5
- import { VoxelModelConstructorRegister } from "./Models/VoxelModelConstructorRegister.js";
6
5
  import { Vector3Like } from "@amodx/math";
7
6
  import { RenderedMaterials } from "./Models/RenderedMaterials.js";
8
7
  import { VoxelLightData } from "../../Voxels/Cursor/VoxelLightData.js";
8
+ import { BuildVoxel } from "./Base/BuildVoxel.js";
9
9
  const templateCursor = new TemplateCursor();
10
10
  const padding = Vector3Like.Create(5, 5, 5);
11
11
  const lightData = new VoxelLightData();
12
- function meshVoxel(x, y, z, voxel, templateCursor) {
13
- if (voxel.isAir() || !voxel.isRenderable())
14
- return false;
15
- let added = false;
16
- const constructor = VoxelModelConstructorRegister.constructorsPaltte[voxel.getVoxelId()];
17
- const builder = constructor.builder;
18
- builder.origin.x = x;
19
- builder.origin.y = y;
20
- builder.origin.z = z;
21
- builder.position.x = x;
22
- builder.position.y = y;
23
- builder.position.z = z;
24
- builder.voxel = voxel;
25
- builder.nVoxel = templateCursor;
26
- builder.startConstruction();
27
- added = constructor.process();
28
- builder.endConstruction();
29
- return added;
30
- }
31
12
  export function MeshTemplate(fullVoxelData, baseLightValue = lightData.setS(0xf, 0)) {
32
13
  const template = new FullVoxelTemplate(fullVoxelData);
33
14
  templateCursor.setTemplate(template);
@@ -46,16 +27,15 @@ export function MeshTemplate(fullVoxelData, baseLightValue = lightData.setS(0xf,
46
27
  const oldLight = template.light.slice();
47
28
  template.light.fill(baseLightValue);
48
29
  const size = template.bounds.size;
30
+ const origin = Vector3Like.Create();
49
31
  for (let x = 0; x < size.x; x++) {
50
32
  for (let y = 0; y < size.y; y++) {
51
33
  for (let z = 0; z < size.z; z++) {
34
+ origin.x = x;
35
+ origin.y = y;
36
+ origin.z = z;
52
37
  const voxel = templateCursor.getVoxel(x, y, z);
53
- meshVoxel(x, y, z, voxel, templateCursor);
54
- if (voxel.hasSecondaryVoxel()) {
55
- voxel.setSecondary(true);
56
- meshVoxel(x, y, z, voxel, templateCursor);
57
- voxel.setSecondary(false);
58
- }
38
+ BuildVoxel(x, y, z, voxel, templateCursor, origin);
59
39
  }
60
40
  }
61
41
  }
@@ -2,7 +2,9 @@ import { VoxelGeometryBuilderCacheSpace } from "./Models/VoxelGeometryBuilderCac
2
2
  import { TemplateCursor } from "../../Templates/Cursor/TemplateCursor.js";
3
3
  import { FullVoxelTemplate } from "../../Templates/Full/FullVoxelTemplate.js";
4
4
  import { CompactTemplateMesh } from "./Base/CompactTemplateMesh.js";
5
- import { VoxelModelConstructorRegister } from "./Models/VoxelModelConstructorRegister.js";
5
+ import { RenderedMaterials } from "./Models/RenderedMaterials.js";
6
+ import { VoxelLUT } from "../../Voxels/Data/VoxelLUT.js";
7
+ import { BuildVoxelBase } from "./Base/BuildVoxel.js";
6
8
  const template = new FullVoxelTemplate(FullVoxelTemplate.CreateNew([3, 3, 3], 0xf));
7
9
  const templateCursor = new TemplateCursor();
8
10
  templateCursor.setTemplate(template);
@@ -15,14 +17,7 @@ export function MeshVoxel(rawVoxelData) {
15
17
  const voxel = templateCursor.getVoxel(1, 1, 1);
16
18
  if (!voxel.isRenderable())
17
19
  return false;
18
- const constructor = VoxelModelConstructorRegister.getConstructor(voxel.getStringId());
19
- if (!constructor) {
20
- throw new Error(`Could not find constructor for voxel [id:${voxel.getStringId()} name:${voxel.getName()}] `);
21
- }
22
- const builder = constructor.builder;
23
- if (!builder) {
24
- console.error(builder, constructor.id, constructor);
25
- }
20
+ const builder = RenderedMaterials.meshers[VoxelLUT.materialMap[voxel.getVoxelId()]];
26
21
  builder.space = space;
27
22
  builder.bvhTool = null;
28
23
  builder.clear();
@@ -36,7 +31,7 @@ export function MeshVoxel(rawVoxelData) {
36
31
  builder.position.z = 1;
37
32
  builder.voxel = voxel;
38
33
  builder.nVoxel = templateCursor;
39
- constructor.process();
34
+ BuildVoxelBase(builder);
40
35
  const transfers = [];
41
36
  const compacted = CompactTemplateMesh([builder], transfers);
42
37
  builder.clear();
@@ -1,10 +1,9 @@
1
- import { QuadVerticies } from "../../../../Geometry/Geometry.types";
2
- import { VoxelFaces, VoxelFacesArray } from "../../../../../Math";
1
+ import { VoxelFacesArray } from "../../../../../Math";
3
2
  import { VoxelRelativeCubeIndex } from "../../../../../Voxels/Geometry/VoxelRelativeCubeIndex";
4
3
  import { VoxelLightData } from "../../../../../Voxels/Cursor/VoxelLightData";
5
4
  export const GradientCheckSets = [];
6
- GradientCheckSets[VoxelFaces.Up] = [];
7
- GradientCheckSets[VoxelFaces.Up][QuadVerticies.TopRight] = [
5
+ GradientCheckSets[0 /* VoxelFaces.Up */] = [];
6
+ GradientCheckSets[0 /* VoxelFaces.Up */][0 /* QuadVerticies.TopRight */] = [
8
7
  //1
9
8
  1, 1, 0,
10
9
  //2
@@ -12,7 +11,7 @@ GradientCheckSets[VoxelFaces.Up][QuadVerticies.TopRight] = [
12
11
  //3
13
12
  1, 1, 1,
14
13
  ];
15
- GradientCheckSets[VoxelFaces.Up][QuadVerticies.TopLeft] = [
14
+ GradientCheckSets[0 /* VoxelFaces.Up */][1 /* QuadVerticies.TopLeft */] = [
16
15
  //1
17
16
  -1, 1, 0,
18
17
  //2
@@ -20,7 +19,7 @@ GradientCheckSets[VoxelFaces.Up][QuadVerticies.TopLeft] = [
20
19
  //3
21
20
  -1, 1, 1,
22
21
  ];
23
- GradientCheckSets[VoxelFaces.Up][QuadVerticies.BottomLeft] = [
22
+ GradientCheckSets[0 /* VoxelFaces.Up */][2 /* QuadVerticies.BottomLeft */] = [
24
23
  //1
25
24
  -1, 1, 0,
26
25
  //2
@@ -28,7 +27,7 @@ GradientCheckSets[VoxelFaces.Up][QuadVerticies.BottomLeft] = [
28
27
  //3
29
28
  -1, 1, -1,
30
29
  ];
31
- GradientCheckSets[VoxelFaces.Up][QuadVerticies.BottomRight] = [
30
+ GradientCheckSets[0 /* VoxelFaces.Up */][3 /* QuadVerticies.BottomRight */] = [
32
31
  //1
33
32
  1, 1, 0,
34
33
  //2
@@ -36,8 +35,8 @@ GradientCheckSets[VoxelFaces.Up][QuadVerticies.BottomRight] = [
36
35
  //3
37
36
  1, 1, -1,
38
37
  ];
39
- GradientCheckSets[VoxelFaces.Down] = [];
40
- GradientCheckSets[VoxelFaces.Down][QuadVerticies.TopRight] = [
38
+ GradientCheckSets[1 /* VoxelFaces.Down */] = [];
39
+ GradientCheckSets[1 /* VoxelFaces.Down */][0 /* QuadVerticies.TopRight */] = [
41
40
  //1
42
41
  -1, -1, 0,
43
42
  //2
@@ -45,7 +44,7 @@ GradientCheckSets[VoxelFaces.Down][QuadVerticies.TopRight] = [
45
44
  //3
46
45
  -1, -1, 1,
47
46
  ];
48
- GradientCheckSets[VoxelFaces.Down][QuadVerticies.TopLeft] = [
47
+ GradientCheckSets[1 /* VoxelFaces.Down */][1 /* QuadVerticies.TopLeft */] = [
49
48
  //1
50
49
  1, -1, 0,
51
50
  //2
@@ -53,7 +52,7 @@ GradientCheckSets[VoxelFaces.Down][QuadVerticies.TopLeft] = [
53
52
  //3
54
53
  1, -1, 1,
55
54
  ];
56
- GradientCheckSets[VoxelFaces.Down][QuadVerticies.BottomLeft] = [
55
+ GradientCheckSets[1 /* VoxelFaces.Down */][2 /* QuadVerticies.BottomLeft */] = [
57
56
  //1
58
57
  1, -1, 0,
59
58
  //2
@@ -61,7 +60,7 @@ GradientCheckSets[VoxelFaces.Down][QuadVerticies.BottomLeft] = [
61
60
  //3
62
61
  1, -1, -1,
63
62
  ];
64
- GradientCheckSets[VoxelFaces.Down][QuadVerticies.BottomRight] = [
63
+ GradientCheckSets[1 /* VoxelFaces.Down */][3 /* QuadVerticies.BottomRight */] = [
65
64
  //1
66
65
  -1, -1, 0,
67
66
  //2
@@ -69,8 +68,8 @@ GradientCheckSets[VoxelFaces.Down][QuadVerticies.BottomRight] = [
69
68
  //3
70
69
  -1, -1, -1,
71
70
  ];
72
- GradientCheckSets[VoxelFaces.East] = [];
73
- GradientCheckSets[VoxelFaces.East][QuadVerticies.TopRight] = [
71
+ GradientCheckSets[4 /* VoxelFaces.East */] = [];
72
+ GradientCheckSets[4 /* VoxelFaces.East */][0 /* QuadVerticies.TopRight */] = [
74
73
  //1
75
74
  1, 0, 1,
76
75
  //2
@@ -78,7 +77,7 @@ GradientCheckSets[VoxelFaces.East][QuadVerticies.TopRight] = [
78
77
  //3
79
78
  1, 1, 1,
80
79
  ];
81
- GradientCheckSets[VoxelFaces.East][QuadVerticies.TopLeft] = [
80
+ GradientCheckSets[4 /* VoxelFaces.East */][1 /* QuadVerticies.TopLeft */] = [
82
81
  //1
83
82
  1, 0, -1,
84
83
  //2
@@ -86,7 +85,7 @@ GradientCheckSets[VoxelFaces.East][QuadVerticies.TopLeft] = [
86
85
  //3
87
86
  1, 1, -1,
88
87
  ];
89
- GradientCheckSets[VoxelFaces.East][QuadVerticies.BottomLeft] = [
88
+ GradientCheckSets[4 /* VoxelFaces.East */][2 /* QuadVerticies.BottomLeft */] = [
90
89
  //1
91
90
  1, 0, -1,
92
91
  //2
@@ -94,7 +93,7 @@ GradientCheckSets[VoxelFaces.East][QuadVerticies.BottomLeft] = [
94
93
  //3
95
94
  1, -1, -1,
96
95
  ];
97
- GradientCheckSets[VoxelFaces.East][QuadVerticies.BottomRight] = [
96
+ GradientCheckSets[4 /* VoxelFaces.East */][3 /* QuadVerticies.BottomRight */] = [
98
97
  //1
99
98
  1, 0, 1,
100
99
  //2
@@ -102,8 +101,8 @@ GradientCheckSets[VoxelFaces.East][QuadVerticies.BottomRight] = [
102
101
  //3
103
102
  1, -1, 1,
104
103
  ];
105
- GradientCheckSets[VoxelFaces.West] = [];
106
- GradientCheckSets[VoxelFaces.West][QuadVerticies.TopRight] = [
104
+ GradientCheckSets[5 /* VoxelFaces.West */] = [];
105
+ GradientCheckSets[5 /* VoxelFaces.West */][0 /* QuadVerticies.TopRight */] = [
107
106
  //1
108
107
  -1, 0, -1,
109
108
  //2
@@ -111,7 +110,7 @@ GradientCheckSets[VoxelFaces.West][QuadVerticies.TopRight] = [
111
110
  //3
112
111
  -1, 1, -1,
113
112
  ];
114
- GradientCheckSets[VoxelFaces.West][QuadVerticies.TopLeft] = [
113
+ GradientCheckSets[5 /* VoxelFaces.West */][1 /* QuadVerticies.TopLeft */] = [
115
114
  //1
116
115
  -1, 0, 1,
117
116
  //2
@@ -119,7 +118,7 @@ GradientCheckSets[VoxelFaces.West][QuadVerticies.TopLeft] = [
119
118
  //3
120
119
  -1, 1, 1,
121
120
  ];
122
- GradientCheckSets[VoxelFaces.West][QuadVerticies.BottomLeft] = [
121
+ GradientCheckSets[5 /* VoxelFaces.West */][2 /* QuadVerticies.BottomLeft */] = [
123
122
  //1
124
123
  -1, 0, 1,
125
124
  //2
@@ -127,7 +126,7 @@ GradientCheckSets[VoxelFaces.West][QuadVerticies.BottomLeft] = [
127
126
  //3
128
127
  -1, -1, 1,
129
128
  ];
130
- GradientCheckSets[VoxelFaces.West][QuadVerticies.BottomRight] = [
129
+ GradientCheckSets[5 /* VoxelFaces.West */][3 /* QuadVerticies.BottomRight */] = [
131
130
  //1
132
131
  -1, 0, -1,
133
132
  //2
@@ -135,8 +134,8 @@ GradientCheckSets[VoxelFaces.West][QuadVerticies.BottomRight] = [
135
134
  //3
136
135
  -1, -1, -1,
137
136
  ];
138
- GradientCheckSets[VoxelFaces.South] = [];
139
- GradientCheckSets[VoxelFaces.South][QuadVerticies.TopRight] = [
137
+ GradientCheckSets[3 /* VoxelFaces.South */] = [];
138
+ GradientCheckSets[3 /* VoxelFaces.South */][0 /* QuadVerticies.TopRight */] = [
140
139
  //1
141
140
  1, 0, -1,
142
141
  //2
@@ -144,7 +143,7 @@ GradientCheckSets[VoxelFaces.South][QuadVerticies.TopRight] = [
144
143
  //3
145
144
  1, 1, -1,
146
145
  ];
147
- GradientCheckSets[VoxelFaces.South][QuadVerticies.TopLeft] = [
146
+ GradientCheckSets[3 /* VoxelFaces.South */][1 /* QuadVerticies.TopLeft */] = [
148
147
  //1
149
148
  -1, 0, -1,
150
149
  //2
@@ -152,7 +151,7 @@ GradientCheckSets[VoxelFaces.South][QuadVerticies.TopLeft] = [
152
151
  //3
153
152
  -1, 1, -1,
154
153
  ];
155
- GradientCheckSets[VoxelFaces.South][QuadVerticies.BottomLeft] = [
154
+ GradientCheckSets[3 /* VoxelFaces.South */][2 /* QuadVerticies.BottomLeft */] = [
156
155
  //1
157
156
  -1, 0, -1,
158
157
  //2
@@ -160,7 +159,7 @@ GradientCheckSets[VoxelFaces.South][QuadVerticies.BottomLeft] = [
160
159
  //3
161
160
  -1, -1, -1,
162
161
  ];
163
- GradientCheckSets[VoxelFaces.South][QuadVerticies.BottomRight] = [
162
+ GradientCheckSets[3 /* VoxelFaces.South */][3 /* QuadVerticies.BottomRight */] = [
164
163
  //1
165
164
  1, 0, -1,
166
165
  //2
@@ -168,8 +167,8 @@ GradientCheckSets[VoxelFaces.South][QuadVerticies.BottomRight] = [
168
167
  //3
169
168
  1, -1, -1,
170
169
  ];
171
- GradientCheckSets[VoxelFaces.North] = [];
172
- GradientCheckSets[VoxelFaces.North][QuadVerticies.TopRight] = [
170
+ GradientCheckSets[2 /* VoxelFaces.North */] = [];
171
+ GradientCheckSets[2 /* VoxelFaces.North */][0 /* QuadVerticies.TopRight */] = [
173
172
  //1
174
173
  -1, 0, 1,
175
174
  //2
@@ -177,7 +176,7 @@ GradientCheckSets[VoxelFaces.North][QuadVerticies.TopRight] = [
177
176
  //3
178
177
  -1, 1, 1,
179
178
  ];
180
- GradientCheckSets[VoxelFaces.North][QuadVerticies.TopLeft] = [
179
+ GradientCheckSets[2 /* VoxelFaces.North */][1 /* QuadVerticies.TopLeft */] = [
181
180
  //1
182
181
  1, 0, 1,
183
182
  //2
@@ -185,7 +184,7 @@ GradientCheckSets[VoxelFaces.North][QuadVerticies.TopLeft] = [
185
184
  //3
186
185
  1, 1, 1,
187
186
  ];
188
- GradientCheckSets[VoxelFaces.North][QuadVerticies.BottomLeft] = [
187
+ GradientCheckSets[2 /* VoxelFaces.North */][2 /* QuadVerticies.BottomLeft */] = [
189
188
  //1
190
189
  1, 0, 1,
191
190
  //2
@@ -193,7 +192,7 @@ GradientCheckSets[VoxelFaces.North][QuadVerticies.BottomLeft] = [
193
192
  //3
194
193
  1, -1, 1,
195
194
  ];
196
- GradientCheckSets[VoxelFaces.North][QuadVerticies.BottomRight] = [
195
+ GradientCheckSets[2 /* VoxelFaces.North */][3 /* QuadVerticies.BottomRight */] = [
197
196
  //1
198
197
  -1, 0, 1,
199
198
  //2
@@ -203,10 +202,10 @@ GradientCheckSets[VoxelFaces.North][QuadVerticies.BottomRight] = [
203
202
  ];
204
203
  export const GradientCheckSetsArray = new Int8Array(6 * 4 * 9);
205
204
  const verts = [
206
- QuadVerticies.TopRight,
207
- QuadVerticies.TopLeft,
208
- QuadVerticies.BottomLeft,
209
- QuadVerticies.BottomRight,
205
+ 0 /* QuadVerticies.TopRight */,
206
+ 1 /* QuadVerticies.TopLeft */,
207
+ 2 /* QuadVerticies.BottomLeft */,
208
+ 3 /* QuadVerticies.BottomRight */,
210
209
  ];
211
210
  const faceLength = 9 * 4;
212
211
  for (const face of VoxelFacesArray) {
@@ -235,12 +234,12 @@ for (const face of VoxelFacesArray) {
235
234
  }
236
235
  export const CenterDirectionIndex = VoxelRelativeCubeIndex.getIndex(0, 0, 0);
237
236
  export const DirectionIndexes = [];
238
- DirectionIndexes[VoxelFaces.Up] = VoxelRelativeCubeIndex.getIndex(0, 1, 0);
239
- DirectionIndexes[VoxelFaces.Down] = VoxelRelativeCubeIndex.getIndex(0, -1, 0);
240
- DirectionIndexes[VoxelFaces.North] = VoxelRelativeCubeIndex.getIndex(0, 0, 1);
241
- DirectionIndexes[VoxelFaces.South] = VoxelRelativeCubeIndex.getIndex(0, 0, -1);
242
- DirectionIndexes[VoxelFaces.East] = VoxelRelativeCubeIndex.getIndex(1, 0, 0);
243
- DirectionIndexes[VoxelFaces.West] = VoxelRelativeCubeIndex.getIndex(-1, 0, 0);
237
+ DirectionIndexes[0 /* VoxelFaces.Up */] = VoxelRelativeCubeIndex.getIndex(0, 1, 0);
238
+ DirectionIndexes[1 /* VoxelFaces.Down */] = VoxelRelativeCubeIndex.getIndex(0, -1, 0);
239
+ DirectionIndexes[2 /* VoxelFaces.North */] = VoxelRelativeCubeIndex.getIndex(0, 0, 1);
240
+ DirectionIndexes[3 /* VoxelFaces.South */] = VoxelRelativeCubeIndex.getIndex(0, 0, -1);
241
+ DirectionIndexes[4 /* VoxelFaces.East */] = VoxelRelativeCubeIndex.getIndex(1, 0, 0);
242
+ DirectionIndexes[5 /* VoxelFaces.West */] = VoxelRelativeCubeIndex.getIndex(-1, 0, 0);
244
243
  /**
245
244
  quad flip
246
245
  2 1
@@ -7,19 +7,17 @@ export default function calculateFaceData(face, builder) {
7
7
  const y = builder.position.y;
8
8
  const z = builder.position.z;
9
9
  const vertexData = builder.lightData[face];
10
- const nVoxel = builder.nVoxel;
11
10
  const checkSet = GradientCheckSets[face];
12
11
  let startLight = 0;
13
12
  if (builder.voxel.isLightSource()) {
14
13
  startLight = builder.voxel.getLightSourceValue();
15
14
  }
16
15
  else {
17
- startLight =
18
- nVoxel
19
- .getVoxel(x + VoxelFaceDirections[face][0], y + VoxelFaceDirections[face][1], z + VoxelFaceDirections[face][2])
20
- ?.getLight() || -1;
16
+ let hashed = builder.space.getHash(builder.nVoxel, x + VoxelFaceDirections[face][0], y + VoxelFaceDirections[face][1], z + VoxelFaceDirections[face][2]);
17
+ startLight = builder.space.lightCache[hashed];
21
18
  if (startLight <= 0) {
22
- startLight = nVoxel.getVoxel(x, y, z)?.getLight() || 0;
19
+ hashed = builder.space.getHash(builder.nVoxel, x, y, z);
20
+ startLight = builder.space.lightCache[hashed];
23
21
  }
24
22
  }
25
23
  if (startLight < 0)
@@ -35,9 +33,8 @@ export default function calculateFaceData(face, builder) {
35
33
  let g = startG;
36
34
  let b = startB;
37
35
  for (let i = 0; i < 9; i += 3) {
38
- const nl = nVoxel
39
- .getVoxel(checkSet[vertex][i] + x, checkSet[vertex][i + 1] + y, checkSet[vertex][i + 2] + z)
40
- ?.getLight() || -1;
36
+ const hashed = builder.space.getHash(builder.nVoxel, checkSet[vertex][i] + x, checkSet[vertex][i + 1] + y, checkSet[vertex][i + 2] + z);
37
+ const nl = builder.space.lightCache[hashed];
41
38
  if (nl <= 0)
42
39
  continue;
43
40
  let ns = lightData.getS(nl);
@@ -2,67 +2,84 @@ import { VoxelLUT } from "../../../../../Voxels/Data/VoxelLUT";
2
2
  import { GeometryLUT } from "../../../../../Voxels/Data/GeometryLUT";
3
3
  import { VoxelRelativeCubeIndexPositionMap } from "../../../../../Voxels/Geometry/VoxelRelativeCubeIndex";
4
4
  export function CullRulledFace(builder, trueFaceIndex) {
5
- const faceIndexes = GeometryLUT.faceCullMap[trueFaceIndex];
5
+ const faceCullMap = GeometryLUT.faceCullMap;
6
+ const faceIndexes = faceCullMap[trueFaceIndex];
6
7
  if (!faceIndexes)
7
8
  return true;
9
+ const space = builder.space;
10
+ const foundHash = space.foundHash;
11
+ const posX = builder.position.x;
12
+ const posY = builder.position.y;
13
+ const posZ = builder.position.z;
14
+ const nVoxel = builder.nVoxel;
15
+ const geometryIndexLUT = GeometryLUT.geometryIndex;
16
+ const rulelessIndex = GeometryLUT.rulelessIndex;
17
+ const cullingProcedures = GeometryLUT.geometryCullingProcedures;
18
+ const cullingProceduresIndex = GeometryLUT.geometryCullingProceduresIndex;
19
+ const faceCullIndex = GeometryLUT.faceCullIndex;
20
+ const voxelIdToState = VoxelLUT.voxelIdToState;
21
+ const currentVoxelId = builder.voxel.getVoxelId();
8
22
  for (let i = 0; i < faceIndexes.length; i++) {
9
23
  const directionIndex = faceIndexes[i];
10
24
  const p = VoxelRelativeCubeIndexPositionMap[directionIndex];
11
- const hashed = builder.space.getHash(builder.nVoxel, builder.position.x + p[0], builder.position.y + p[1], builder.position.z + p[2]);
12
- if (builder.space.foundHash[hashed] < 2)
25
+ const hashed = space.getHash(nVoxel, posX + p[0], posY + p[1], posZ + p[2]);
26
+ if (foundHash[hashed] < 2)
13
27
  continue;
14
- const voxelStringId = VoxelLUT.voxelIds.getStringId(builder.space.trueVoxelCache[hashed]);
15
- const voxelId = builder.space.voxelCache[hashed];
16
- const reltionalVoxelId = builder.space.reltionalVoxelCache[hashed];
17
- const geometryIndex = VoxelLUT.getGeometryIndex(voxelId, reltionalVoxelId);
18
- const offsetBaseGometry = GeometryLUT.geometryIndex[geometryIndex];
19
- if (offsetBaseGometry) {
20
- for (let i = 0; i < offsetBaseGometry.length; i++) {
21
- const geoId = offsetBaseGometry[i];
22
- if (GeometryLUT.rulelessIndex[geoId])
23
- continue;
24
- const cullingProcedure = GeometryLUT.geometryCullingProcedures[GeometryLUT.geometryCullingProceduresIndex[geoId]];
25
- if (cullingProcedure.type == "transparent") {
26
- if (voxelStringId != builder.voxel.getStringId())
28
+ let count = 1;
29
+ for (let s = 0; s < count; s++) {
30
+ let secondary = s == 1 ? true : false;
31
+ const voxelId = space.getVoxelId(hashed, secondary);
32
+ const reltionalVoxelId = space.getRelationalVoxelId(hashed, secondary);
33
+ const geometryIndex = VoxelLUT.getGeometryIndex(voxelId, reltionalVoxelId);
34
+ const offsetBaseGeometry = geometryIndexLUT[geometryIndex];
35
+ if (offsetBaseGeometry) {
36
+ for (let j = 0; j < offsetBaseGeometry.length; j++) {
37
+ const geoId = offsetBaseGeometry[j];
38
+ if (rulelessIndex[geoId])
27
39
  continue;
28
- }
29
- else {
30
- if (cullingProcedure.type != "default")
40
+ const cullingProcedure = cullingProcedures[cullingProceduresIndex[geoId]];
41
+ const procType = cullingProcedure.type;
42
+ if (procType === "transparent") {
43
+ if (space.getTrueVoxelId(hashed, secondary) !== currentVoxelId)
44
+ continue;
45
+ }
46
+ if (procType == "none") {
31
47
  continue;
32
- }
33
- if (GeometryLUT.faceCullIndex.getValue(geoId, directionIndex, trueFaceIndex) == 1) {
34
- return false;
48
+ }
49
+ if (faceCullIndex.getValue(geoId, directionIndex, trueFaceIndex) === 1) {
50
+ return false;
51
+ }
35
52
  }
36
53
  }
37
- }
38
- const trueVoxelId = builder.space.trueVoxelCache[hashed];
39
- const offsetConditonalGeometry = VoxelLUT.getConditionalGeometryNodes(trueVoxelId);
40
- if (offsetConditonalGeometry) {
41
- const modelState = VoxelLUT.voxelIdToModelState[voxelId];
42
- const reltioanlModSeltate = builder.space.reltionalStateCache[hashed];
43
- for (let i = 0; i < offsetConditonalGeometry.length; i++) {
44
- const [geoId, requiredModelState, requiredReltionalModelState] = offsetConditonalGeometry[i];
45
- if (requiredModelState !== modelState ||
46
- !requiredReltionalModelState[reltioanlModSeltate])
47
- continue;
48
- const geomerties = GeometryLUT.geometryIndex[geoId];
49
- for (let k = 0; k < geomerties.length; k++) {
50
- const geoId = geomerties[k];
51
- if (GeometryLUT.rulelessIndex[geoId])
54
+ const trueVoxelId = space.getTrueVoxelId(hashed, secondary);
55
+ const offsetConditionalGeometry = VoxelLUT.getConditionalGeometryNodes(trueVoxelId);
56
+ if (offsetConditionalGeometry) {
57
+ const modelState = voxelIdToState[voxelId];
58
+ const relationalModState = space.getRelationalState(hashed, secondary);
59
+ for (let j = 0; j < offsetConditionalGeometry.length; j++) {
60
+ const [condGeoId, requiredModelState, requiredRelationalModelState] = offsetConditionalGeometry[j];
61
+ if (requiredModelState !== modelState ||
62
+ !requiredRelationalModelState[relationalModState]) {
52
63
  continue;
53
- const cullingProcedure = GeometryLUT.geometryCullingProcedures[GeometryLUT.geometryCullingProceduresIndex[geoId]];
54
- if (cullingProcedure.type == "transparent") {
55
- if (voxelStringId != builder.voxel.getStringId())
56
- continue;
57
64
  }
58
- else {
59
- if (cullingProcedure.type != "default")
65
+ const geometries = geometryIndexLUT[condGeoId];
66
+ for (let k = 0; k < geometries.length; k++) {
67
+ const geoId = geometries[k];
68
+ if (rulelessIndex[geoId])
60
69
  continue;
70
+ const cullingProcedure = cullingProcedures[cullingProceduresIndex[geoId]];
71
+ const procType = cullingProcedure.type;
72
+ if (procType === "transparent") {
73
+ if (space.getTrueVoxelId(hashed, secondary) !== currentVoxelId)
74
+ continue;
75
+ }
76
+ if (procType == "none") {
77
+ continue;
78
+ }
79
+ if (faceCullIndex.getValue(geoId, directionIndex, trueFaceIndex) === 1) {
80
+ return false;
81
+ }
61
82
  }
62
- if (GeometryLUT.rulelessIndex[geoId])
63
- continue;
64
- if (GeometryLUT.faceCullIndex.getValue(geoId, directionIndex, trueFaceIndex) == 1)
65
- return false;
66
83
  }
67
84
  }
68
85
  }