@divinevoxel/vlox 0.0.7 → 0.0.72

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 (168) hide show
  1. package/Contexts/Base/Main/InitDataGenerator.js +0 -9
  2. package/Contexts/Base/Remote/DataSync.types.d.ts +0 -5
  3. package/Contexts/Base/Remote/InitDataSync.js +17 -31
  4. package/Init/StartConstructor.js +2 -4
  5. package/Init/StartWorld.js +0 -12
  6. package/Math/Indexing.d.ts +12 -3
  7. package/Math/Indexing.js +24 -15
  8. package/Mesher/Functions/CompactVoxelMesh.d.ts +1 -1
  9. package/Mesher/Functions/CompactVoxelMesh.js +3 -4
  10. package/Mesher/Functions/MeshSection.d.ts +1 -1
  11. package/Mesher/Functions/MeshSection.js +54 -60
  12. package/Mesher/Functions/MeshVoxel.js +20 -26
  13. package/Mesher/Geomtry/Buffers.d.ts +9 -8
  14. package/Mesher/Geomtry/Buffers.js +26 -58
  15. package/Mesher/Geomtry/Tools/MesherDataTools.d.ts +1 -1
  16. package/Mesher/Geomtry/Tools/MesherDataTools.js +1 -1
  17. package/Mesher/Geomtry/VoxelGeometryBuilder.js +107 -124
  18. package/Mesher/InitMesher.js +1 -10
  19. package/Mesher/InitTask.js +10 -4
  20. package/Mesher/Models/Common/BoundsFunctions.d.ts +1 -3
  21. package/Mesher/Models/Common/BoundsFunctions.js +0 -16
  22. package/Mesher/Models/Common/Calc/CalcConstants.js +14 -31
  23. package/Mesher/Models/Common/Calc/FaceDataCalc.d.ts +1 -7
  24. package/Mesher/Models/Common/Calc/FaceDataCalc.js +41 -50
  25. package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.d.ts +1 -5
  26. package/Mesher/Models/Nodes/Custom/Liquid/LiquidGeomtryNode.js +30 -26
  27. package/Mesher/Models/Nodes/GeometryNode.d.ts +2 -4
  28. package/Mesher/Models/Nodes/GeometryNode.js +1 -2
  29. package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.d.ts +2 -6
  30. package/Mesher/Models/Nodes/Ruled/BoxVoxelGeometryNode.js +37 -34
  31. package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.d.ts +2 -6
  32. package/Mesher/Models/Nodes/Ruled/QuadVoxelGeometryNode.js +52 -51
  33. package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.d.ts +2 -6
  34. package/Mesher/Models/Nodes/Ruleless/RulelessBoxVoxelGeometryNode.js +18 -19
  35. package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.d.ts +2 -6
  36. package/Mesher/Models/Nodes/Ruleless/RulelessQuadVoxelGeometryNode.js +37 -40
  37. package/Mesher/Models/VoxelConstructor.d.ts +3 -4
  38. package/Mesher/Models/VoxelConstructor.js +23 -12
  39. package/Mesher/Models/{VoxelGeometryLookUp.d.ts → VoxelGeometryBuilderCacheSpace.d.ts} +8 -14
  40. package/Mesher/Models/{VoxelGeometryLookUp.js → VoxelGeometryBuilderCacheSpace.js} +49 -44
  41. package/Mesher/Models/VoxelModelConstructorRegister.js +3 -3
  42. package/Mesher/Tools/VoxelMeshBVHBuilder.d.ts +2 -9
  43. package/Mesher/Tools/VoxelMeshBVHBuilder.js +4 -16
  44. package/Mesher/Tools/VoxelMeshVertexStructCursor.d.ts +10 -0
  45. package/Mesher/Tools/VoxelMeshVertexStructCursor.js +10 -0
  46. package/Mesher/Tools/VoxelMesherDataTool.d.ts +8 -5
  47. package/Mesher/Tools/VoxelMesherDataTool.js +34 -13
  48. package/Models/Indexing/VoxelAOResultsIndex.d.ts +4 -4
  49. package/Models/Indexing/VoxelAOResultsIndex.js +15 -9
  50. package/Models/Indexing/VoxelFaceCullResultsIndex.d.ts +3 -3
  51. package/Models/Indexing/VoxelFaceCullResultsIndex.js +14 -9
  52. package/Models/Indexing/VoxelFaceTransparentResultsIndex.d.ts +1 -1
  53. package/Models/Indexing/VoxelFaceTransparentResultsIndex.js +1 -1
  54. package/Models/Rules/Functions/BuildRules.js +2 -2
  55. package/Tasks/IWG/Internal/Classes/Generator.js +1 -1
  56. package/Tasks/IWG/Internal/Functions/getSectorState.js +4 -7
  57. package/Tasks/IWG/Internal/Functions/runWorldUpdate.js +5 -6
  58. package/Tasks/IWG/Internal/IWGTasks.js +12 -21
  59. package/Tasks/Propagation/Flow/FlowManager.d.ts +0 -2
  60. package/Tasks/Propagation/Flow/FlowManager.js +86 -87
  61. package/Tasks/Propagation/Flow/WorldFlow.js +2 -3
  62. package/Tasks/Propagation/Illumanation/WorldRGB.js +1 -2
  63. package/Tasks/Update/InitTasks.d.ts +2 -1
  64. package/Tasks/Update/InitTasks.js +6 -6
  65. package/Tasks/Update/VoxelUpdate.js +15 -7
  66. package/Tasks/WorldGeneration/WorldGenBrush.js +1 -0
  67. package/Templates/Cursor/TemplateCursor.d.ts +1 -1
  68. package/Templates/Cursor/TemplateCursor.js +1 -1
  69. package/Templates/Functions/CreateTemplate.js +1 -1
  70. package/Templates/VoxelTemplate.js +6 -8
  71. package/Tools/Brush/Brush.d.ts +0 -2
  72. package/Tools/Brush/Brush.js +5 -6
  73. package/{Data/Cursor → Tools}/DataCursor.interface.d.ts +1 -1
  74. package/Util/Binary/BitArray.d.ts +4 -0
  75. package/Util/Binary/BitArray.js +16 -0
  76. package/Util/StringPalette.d.ts +1 -0
  77. package/Util/StringPalette.js +8 -0
  78. package/Voxels/Cursor/VoxelCursor.d.ts +6 -6
  79. package/Voxels/Cursor/VoxelCursor.interface.d.ts +10 -15
  80. package/Voxels/Cursor/VoxelCursor.interface.js +30 -50
  81. package/Voxels/Cursor/VoxelCursor.js +13 -12
  82. package/Voxels/Cursor/VoxelLightData.d.ts +3 -4
  83. package/Voxels/Cursor/VoxelLightData.js +8 -7
  84. package/Voxels/Data/VoxelPalettesRegister.d.ts +13 -0
  85. package/Voxels/Data/VoxelPalettesRegister.js +17 -0
  86. package/Voxels/Data/VoxelTag.types.d.ts +56 -0
  87. package/Voxels/Data/VoxelTag.types.js +23 -0
  88. package/Voxels/{State → Data}/VoxelTagStates.d.ts +2 -2
  89. package/Voxels/{State → Data}/VoxelTagStates.js +5 -5
  90. package/Voxels/Data/VoxelTagsRegister.d.ts +9 -0
  91. package/Voxels/Data/VoxelTagsRegister.js +32 -0
  92. package/Voxels/Functions/BuildStateData.js +3 -3
  93. package/Voxels/Functions/BuildTagAndPaletteData.d.ts +13 -0
  94. package/Voxels/Functions/BuildTagAndPaletteData.js +57 -0
  95. package/Voxels/Indexes/VoxelIndex.js +3 -3
  96. package/Voxels/InitVoxelData.js +20 -61
  97. package/Voxels/State/Schema/StateSchema.d.ts +1 -1
  98. package/Voxels/Types/Voxel.types.d.ts +2 -42
  99. package/Voxels/Types/Voxel.types.js +0 -15
  100. package/Voxels/Types/VoxelModelCompiledData.types.d.ts +11 -13
  101. package/Voxels/Types/VoxelSubstances.types.d.ts +2 -15
  102. package/Voxels/Types/VoxelSubstances.types.js +1 -9
  103. package/World/Archive/Functions/ArchiveArea.js +2 -6
  104. package/World/Archive/Functions/ArchiveSector.js +14 -28
  105. package/World/Archive/Functions/ImportSector.js +27 -34
  106. package/World/Cursor/SectionCursor.d.ts +2 -1
  107. package/World/Cursor/SectionCursor.js +8 -2
  108. package/World/Cursor/SectorCursor.d.ts +2 -1
  109. package/World/Cursor/SectorCursor.js +5 -2
  110. package/World/Cursor/WorldCursor.d.ts +1 -1
  111. package/World/Cursor/WorldCursor.js +6 -2
  112. package/World/Cursor/WorldVoxelCursor.d.ts +7 -7
  113. package/World/Cursor/WorldVoxelCursor.js +20 -24
  114. package/World/Section/Section.d.ts +20 -8
  115. package/World/Section/Section.js +65 -9
  116. package/World/Sector/Sector.d.ts +13 -6
  117. package/World/Sector/Sector.js +30 -9
  118. package/World/Sector/SectorHeightMap.js +1 -3
  119. package/World/Sector/SectorState.d.ts +13 -0
  120. package/World/Sector/SectorState.js +15 -0
  121. package/World/WorldSpaces.d.ts +2 -0
  122. package/World/WorldSpaces.js +7 -1
  123. package/package.json +1 -1
  124. package/Data/Register/MappedDataRegister.d.ts +0 -5
  125. package/Data/Register/MappedDataRegister.js +0 -9
  126. package/Data/Register/MappedRegisterBase.d.ts +0 -14
  127. package/Data/Register/MappedRegisterBase.js +0 -50
  128. package/Data/Structs/StructBuilder.d.ts +0 -34
  129. package/Data/Structs/StructBuilder.js +0 -157
  130. package/Data/Structs/StructBuilder.types.d.ts +0 -30
  131. package/Data/Structs/StructBuilder.types.js +0 -1
  132. package/Tools/Data/SubstanceDataTool.d.ts +0 -13
  133. package/Tools/Data/SubstanceDataTool.js +0 -51
  134. package/Voxels/Palettes/MaterialPalette.d.ts +0 -9
  135. package/Voxels/Palettes/MaterialPalette.js +0 -11
  136. package/Voxels/Palettes/SubstancePalette.d.ts +0 -9
  137. package/Voxels/Palettes/SubstancePalette.js +0 -11
  138. package/Voxels/Palettes/VoxelPalette.d.ts +0 -11
  139. package/Voxels/Palettes/VoxelPalette.js +0 -15
  140. package/Voxels/Segments/MaterialDataGenerator.d.ts +0 -6
  141. package/Voxels/Segments/MaterialDataGenerator.js +0 -12
  142. package/Voxels/Segments/SubstanceDataGenerator.d.ts +0 -6
  143. package/Voxels/Segments/SubstanceDataGenerator.js +0 -35
  144. package/Voxels/Segments/VoxelDataGenerator.d.ts +0 -10
  145. package/Voxels/Segments/VoxelDataGenerator.js +0 -56
  146. package/Voxels/Structs/Builder/SubstanceStructBuilder.d.ts +0 -2
  147. package/Voxels/Structs/Builder/SubstanceStructBuilder.js +0 -42
  148. package/Voxels/Structs/Builder/VoxelStructBuilder.d.ts +0 -2
  149. package/Voxels/Structs/Builder/VoxelStructBuilder.js +0 -68
  150. package/Voxels/Structs/SubstanceStruct.d.ts +0 -17
  151. package/Voxels/Structs/SubstanceStruct.js +0 -17
  152. package/Voxels/Structs/VoxelStruct.d.ts +0 -27
  153. package/Voxels/Structs/VoxelStruct.js +0 -29
  154. package/World/Section/SectionHeightMap.d.ts +0 -10
  155. package/World/Section/SectionHeightMap.js +0 -39
  156. package/World/Section/SectionStruct.d.ts +0 -8
  157. package/World/Section/SectionStruct.js +0 -29
  158. package/World/Section/SectionStructProperties.d.ts +0 -10
  159. package/World/Section/SectionStructProperties.js +0 -11
  160. package/World/Sector/SectorStruct.d.ts +0 -1
  161. package/World/Sector/SectorStruct.js +0 -46
  162. package/World/Sector/SectorStructIds.d.ts +0 -13
  163. package/World/Sector/SectorStructIds.js +0 -14
  164. /package/{Data/Cursor → Tools}/DataCursor.interface.js +0 -0
  165. /package/{Data/Functions → Util/Binary}/Palettes.d.ts +0 -0
  166. /package/{Data/Functions → Util/Binary}/Palettes.js +0 -0
  167. /package/Voxels/{VoxelLevelReader.d.ts → Cursor/VoxelLevelReader.d.ts} +0 -0
  168. /package/Voxels/{VoxelLevelReader.js → Cursor/VoxelLevelReader.js} +0 -0
@@ -4,25 +4,29 @@ import { MesherDataTool } from "../Geomtry/Tools/MesherDataTools";
4
4
  import { QuadScalarVertexData } from "../Geomtry/Primitives/QuadVertexData";
5
5
  import { VoxelFaces, VoxelFacesArray } from "../../Math";
6
6
  import { QuadVerticies } from "../Geomtry/Geometry.types";
7
- import { FaceDataCalc } from "../Models/Common/Calc/FaceDataCalc.js";
7
+ import calculateFaceData from "../Models/Common/Calc/FaceDataCalc.js";
8
8
  import { VoxelMesh } from "../Geomtry/VoxelMesh";
9
- import { Vector3Like } from "@amodx/math";
9
+ import { Vector3Like, Vector4Like } from "@amodx/math";
10
10
  class VoxelVars {
11
11
  faceFlipped = false;
12
12
  textureIndex = 0;
13
+ overlayTextures = Vector4Like.Create();
13
14
  light = new QuadScalarVertexData();
14
15
  ao = new QuadScalarVertexData();
15
16
  animation = new QuadScalarVertexData();
16
17
  level = new QuadScalarVertexData();
17
- overlayTextures = new QuadScalarVertexData();
18
18
  reset() {
19
19
  this.faceFlipped = false;
20
20
  this.textureIndex = 0;
21
+ this.overlayTextures.x = 0;
22
+ this.overlayTextures.y = 0;
23
+ this.overlayTextures.z = 0;
21
24
  }
22
25
  }
23
26
  export class VoxelMesherDataTool extends MesherDataTool {
24
27
  id;
25
28
  materialIndex;
29
+ space;
26
30
  voxel;
27
31
  nVoxel;
28
32
  /**The current world position */
@@ -78,27 +82,47 @@ export class VoxelMesherDataTool extends MesherDataTool {
78
82
  };
79
83
  _indexStart = 0;
80
84
  startConstruction() {
81
- this._indexStart = this.mesh.indices.length;
85
+ this._indexStart = this.mesh.indicieCount;
82
86
  this.bounds.min[0] = Infinity;
83
87
  this.bounds.min[1] = Infinity;
84
88
  this.bounds.min[2] = Infinity;
85
89
  this.bounds.max[0] = -Infinity;
86
90
  this.bounds.max[1] = -Infinity;
87
91
  this.bounds.max[2] = -Infinity;
92
+ this._boundsUpdate = true;
88
93
  }
89
94
  endConstruction() {
90
- if (this.bounds.min.includes(Infinity) ||
91
- this.bounds.max.includes(-Infinity))
92
- return false;
95
+ this.vars.reset();
93
96
  if (this.bvhTool) {
94
- this.bvhTool.updateVoxel(this.position.x, this.position.y, this.position.z, this._indexStart, this.materialIndex, this.mesh.indices.length, this.bounds.min[0], this.bounds.min[1], this.bounds.min[2], this.bounds.max[0], this.bounds.max[1], this.bounds.max[2]);
97
+ if (!this._boundsUpdate)
98
+ return false;
99
+ 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]);
95
100
  }
96
101
  return true;
97
102
  }
103
+ _boundsUpdate = false;
104
+ updateBounds(bounds) {
105
+ const origin = this.origin;
106
+ //min
107
+ if (origin.x + bounds[0][0] < this.bounds.min[0])
108
+ this.bounds.min[0] = origin.x + bounds[0][0];
109
+ if (origin.y + bounds[0][1] < this.bounds.min[1])
110
+ this.bounds.min[1] = origin.y + bounds[0][1];
111
+ if (origin.z + bounds[0][2] < this.bounds.min[2])
112
+ this.bounds.min[2] = origin.z + bounds[0][2];
113
+ //max
114
+ if (origin.x + bounds[1][0] > this.bounds.max[0])
115
+ this.bounds.max[0] = origin.x + bounds[1][0];
116
+ if (origin.y + bounds[1][1] > this.bounds.max[1])
117
+ this.bounds.max[1] = origin.y + bounds[1][1];
118
+ if (origin.z + bounds[1][2] > this.bounds.max[2])
119
+ this.bounds.max[2] = origin.z + bounds[1][2];
120
+ this._boundsUpdate = true;
121
+ }
98
122
  calculateFaceData(direction) {
99
123
  if (this.dataCalculated[direction])
100
124
  return true;
101
- FaceDataCalc.calculate(direction, this);
125
+ calculateFaceData(direction, this);
102
126
  this.dataCalculated[direction] = true;
103
127
  }
104
128
  clearCalculatedData() {
@@ -109,10 +133,7 @@ export class VoxelMesherDataTool extends MesherDataTool {
109
133
  this.dataCalculated[VoxelFaces.East] = false;
110
134
  this.dataCalculated[VoxelFaces.West] = false;
111
135
  }
112
- reset() {
113
- this.vars.reset();
114
- }
115
- resetAll() {
136
+ clear() {
116
137
  this.vars.reset();
117
138
  this.mesh.clear();
118
139
  return this;
@@ -1,12 +1,12 @@
1
1
  export type VoxelAOResultsIndexData = {
2
- buffer: SharedArrayBuffer;
2
+ buffer: ArrayBufferLike;
3
3
  vertexByteCount: number;
4
4
  };
5
5
  export declare class VoxelAOResultsIndex {
6
- data: VoxelAOResultsIndexData;
7
- view: DataView;
6
+ view: Uint8Array;
7
+ readonly vertexByteCount: number;
8
8
  constructor(data: VoxelAOResultsIndexData);
9
- getByteIndex(otherId: number, directionIndex: number): number;
10
9
  getValue(otherId: number, directionIndex: number, vertexIndex: number): number;
11
10
  setValue(otherId: number, directionIndex: number, vertexIndex: number, value?: number): void;
11
+ getData(): VoxelAOResultsIndexData;
12
12
  }
@@ -1,20 +1,26 @@
1
1
  import { BinaryArrays } from "@amodx/binary/Util/BinaryArrays";
2
2
  import { VoxelRelativeCubeIndex } from "./VoxelRelativeCubeIndex";
3
+ const flatIndexSize = VoxelRelativeCubeIndex.flatIndex.size;
4
+ function getByteIndex(otherId, directionIndex, vertexByteCount) {
5
+ return (otherId * vertexByteCount * flatIndexSize + directionIndex * vertexByteCount);
6
+ }
3
7
  export class VoxelAOResultsIndex {
4
- data;
5
8
  view;
9
+ vertexByteCount;
6
10
  constructor(data) {
7
- this.data = data;
8
- this.view = new DataView(data.buffer);
9
- }
10
- getByteIndex(otherId, directionIndex) {
11
- return (otherId * this.data.vertexByteCount * VoxelRelativeCubeIndex.flatIndex.size +
12
- directionIndex * this.data.vertexByteCount);
11
+ this.vertexByteCount = data.vertexByteCount;
12
+ this.view = new Uint8Array(data.buffer);
13
13
  }
14
14
  getValue(otherId, directionIndex, vertexIndex) {
15
- return BinaryArrays.getBitArrayIndex(this.view, this.getByteIndex(otherId, directionIndex), vertexIndex);
15
+ return BinaryArrays.getBitArrayIndex(this.view, getByteIndex(otherId, directionIndex, this.vertexByteCount), vertexIndex);
16
16
  }
17
17
  setValue(otherId, directionIndex, vertexIndex, value = 1) {
18
- BinaryArrays.setBitArrayIndex(this.view, this.getByteIndex(otherId, directionIndex), vertexIndex, value);
18
+ BinaryArrays.setBitArrayIndex(this.view, getByteIndex(otherId, directionIndex, this.vertexByteCount), vertexIndex, value);
19
+ }
20
+ getData() {
21
+ return {
22
+ buffer: this.view.buffer,
23
+ vertexByteCount: this.vertexByteCount,
24
+ };
19
25
  }
20
26
  }
@@ -1,12 +1,12 @@
1
1
  export type VoxelFaceCullResultsIndexData = {
2
- buffer: SharedArrayBuffer;
2
+ buffer: ArrayBufferLike;
3
3
  faceByteCount: number;
4
4
  };
5
5
  export declare class VoxelFaceCullResultsIndex {
6
- data: VoxelFaceCullResultsIndexData;
7
6
  view: Uint16Array;
7
+ readonly faceByteCount: number;
8
8
  constructor(data: VoxelFaceCullResultsIndexData);
9
- getByteIndex(otherId: number, directionIndex: number): number;
10
9
  getValue(otherId: number, directionIndex: number, faceIndex: number): number;
11
10
  setValue(otherId: number, directionIndex: number, faceIndex: number, value?: number): number;
11
+ getData(): VoxelFaceCullResultsIndexData;
12
12
  }
@@ -1,21 +1,26 @@
1
1
  import { VoxelRelativeCubeIndex } from "./VoxelRelativeCubeIndex";
2
+ const flatIndexSize = VoxelRelativeCubeIndex.flatIndex.size;
3
+ function getByteIndex(otherId, directionIndex, faceByteCount) {
4
+ return (otherId * faceByteCount * flatIndexSize + directionIndex * faceByteCount);
5
+ }
2
6
  export class VoxelFaceCullResultsIndex {
3
- data;
4
7
  view;
8
+ faceByteCount;
5
9
  constructor(data) {
6
- this.data = data;
7
10
  this.view = new Uint16Array(data.buffer);
8
- }
9
- getByteIndex(otherId, directionIndex) {
10
- return (otherId * this.data.faceByteCount * VoxelRelativeCubeIndex.flatIndex.size +
11
- directionIndex * this.data.faceByteCount);
11
+ this.faceByteCount = data.faceByteCount;
12
12
  }
13
13
  getValue(otherId, directionIndex, faceIndex) {
14
- const v = this.view[this.getByteIndex(otherId, directionIndex) + faceIndex];
14
+ const v = this.view[getByteIndex(otherId, directionIndex, this.faceByteCount) + faceIndex];
15
15
  return v == 65535 ? -1 : v;
16
16
  }
17
17
  setValue(otherId, directionIndex, faceIndex, value = -1) {
18
- return (this.view[this.getByteIndex(otherId, directionIndex) + faceIndex] =
19
- value);
18
+ return (this.view[getByteIndex(otherId, directionIndex, this.faceByteCount) + faceIndex] = value);
19
+ }
20
+ getData() {
21
+ return {
22
+ buffer: this.view.buffer,
23
+ faceByteCount: this.faceByteCount,
24
+ };
20
25
  }
21
26
  }
@@ -4,7 +4,7 @@ export type VoxelFaceTransparentResultsIndexData = {
4
4
  };
5
5
  export declare class VoxelFaceTransparentResultsIndex {
6
6
  data: VoxelFaceTransparentResultsIndexData;
7
- view: DataView;
7
+ view: Uint8Array;
8
8
  constructor(data: VoxelFaceTransparentResultsIndexData);
9
9
  getValue(modState: number, faceByteIndex: number, faceIndex: number): number;
10
10
  setValue(modState: number, faceByteIndex: number, faceIndex: number, value?: number): void;
@@ -4,7 +4,7 @@ export class VoxelFaceTransparentResultsIndex {
4
4
  view;
5
5
  constructor(data) {
6
6
  this.data = data;
7
- this.view = new DataView(data.buffer);
7
+ this.view = new Uint8Array(data.buffer);
8
8
  }
9
9
  getValue(modState, faceByteIndex, faceIndex) {
10
10
  return BinaryArrays.getBitArrayIndex(this.view, this.data.resultsSize * modState + faceByteIndex, faceIndex);
@@ -179,8 +179,8 @@ export function BuildRules(main, geoPalette) {
179
179
  }
180
180
  }
181
181
  return {
182
- aoIndex: aoIndex.data,
183
- cullIndex: cullIndex.data,
182
+ aoIndex: aoIndex.getData(),
183
+ cullIndex: cullIndex.getData(),
184
184
  faceCullMap,
185
185
  vertexHitMap,
186
186
  };
@@ -26,7 +26,7 @@ export class Generator {
26
26
  }
27
27
  update() {
28
28
  this._positonChanged = false;
29
- WorldSpaces.section.getPosition(this.position.x, this.position.y, this.position.z, this._sectorPosition);
29
+ WorldSpaces.section.getPosition(this.position.x, 0, this.position.z, this._sectorPosition);
30
30
  if (!Vector3Like.Equals(this._sectorPosition, this._cachedPosition)) {
31
31
  this._positonChanged = true;
32
32
  Vector3Like.Copy(this._cachedPosition, this._sectorPosition);
@@ -1,5 +1,4 @@
1
1
  import { WorldRegister } from "../../../../World/WorldRegister";
2
- import { SectorStateStructIds } from "../../../../World/Sector/SectorStructIds";
3
2
  import { $2dMooreNeighborhood } from "../../../../Math/CardinalNeighbors";
4
3
  import { WorldSpaces } from "../../../../World/WorldSpaces";
5
4
  import { Sector } from "../../../../World/index";
@@ -8,7 +7,6 @@ const tempPosition = Vector3Like.Create();
8
7
  export function getSectorState(sector, state, segment) {
9
8
  state.resset();
10
9
  const [cx, cy, cz] = sector.position;
11
- Sector.StateStruct.setData(sector.sectorState);
12
10
  for (let i = 0; i < $2dMooreNeighborhood.length; i++) {
13
11
  const sectorPOS = WorldSpaces.sector.getPosition(cx + $2dMooreNeighborhood[i][0] * WorldSpaces.sector.bounds.x, cy, cz + $2dMooreNeighborhood[i][1] * WorldSpaces.sector.bounds.z, tempPosition);
14
12
  if (!segment.vistedMap.has(sectorPOS.x, cy, sectorPOS.z)) {
@@ -24,17 +22,16 @@ export function getSectorState(sector, state, segment) {
24
22
  state.allLoaded = false;
25
23
  break;
26
24
  }
27
- Sector.StateStruct.setData(sector.sectorState);
28
- if (!Sector.StateStruct.getProperty(SectorStateStructIds.isWorldGenDone)) {
25
+ if (!sector.getBitFlag(Sector.FlagIds.isWorldGenDone)) {
29
26
  state.nWorldGenAllDone = false;
30
27
  }
31
- if (!Sector.StateStruct.getProperty(SectorStateStructIds.isWorldDecorDone)) {
28
+ if (!sector.getBitFlag(Sector.FlagIds.isWorldDecorDone)) {
32
29
  state.nDecorAllDone = false;
33
30
  }
34
- if (!Sector.StateStruct.getProperty(SectorStateStructIds.isWorldSunDone)) {
31
+ if (!sector.getBitFlag(Sector.FlagIds.isWorldSunDone)) {
35
32
  state.nSunAllDone = false;
36
33
  }
37
- if (!Sector.StateStruct.getProperty(SectorStateStructIds.isWorldPropagationDone)) {
34
+ if (!sector.getBitFlag(Sector.FlagIds.isWorldPropagationDone)) {
38
35
  state.nPropagtionAllDone = false;
39
36
  }
40
37
  }
@@ -3,7 +3,6 @@ import { getSectorState } from "./getSectorState";
3
3
  import { SectorState } from "../Classes/SectorState";
4
4
  import { WorldRegister } from "../../../../World/WorldRegister";
5
5
  import { Sector } from "../../../../World";
6
- import { SectorStateStructIds } from "../../../../World/Sector/SectorStructIds";
7
6
  import { WorldLock } from "../../../../World/Lock/WorldLock";
8
7
  import { IWGTasks } from "../IWGTasks";
9
8
  import { IWGDimensions } from "../IWGDimensions";
@@ -41,24 +40,24 @@ export function runWorldUpdate(generators) {
41
40
  continue;
42
41
  }
43
42
  const state = getSectorState(sector, stateCursor, segment);
44
- Sector.StateStruct.setBuffer(sector.buffer);
43
+ sector.getBitFlag(Sector.FlagIds.isWorldGenDone);
45
44
  if (state.allLoaded &&
46
- !Sector.StateStruct.getProperty(SectorStateStructIds.isWorldGenDone)) {
45
+ !sector.getBitFlag(Sector.FlagIds.isWorldGenDone)) {
47
46
  IWGTasks.worldGenTasks.add(generator._dimension, cx, cy, cz);
48
47
  continue;
49
48
  }
50
49
  if (state.nWorldGenAllDone &&
51
- !Sector.StateStruct.getProperty(SectorStateStructIds.isWorldDecorDone)) {
50
+ !sector.getBitFlag(Sector.FlagIds.isWorldDecorDone)) {
52
51
  IWGTasks.worldDecorateTasks.add(generator._dimension, cx, cy, cz);
53
52
  continue;
54
53
  }
55
54
  if (state.nDecorAllDone &&
56
- !Sector.StateStruct.getProperty(SectorStateStructIds.isWorldPropagationDone)) {
55
+ !sector.getBitFlag(Sector.FlagIds.isWorldPropagationDone)) {
57
56
  IWGTasks.worldPropagationTasks.add(generator._dimension, cx, cy, cz);
58
57
  continue;
59
58
  }
60
59
  if (state.nPropagtionAllDone &&
61
- !Sector.StateStruct.getProperty(SectorStateStructIds.isWorldSunDone)) {
60
+ !sector.getBitFlag(Sector.FlagIds.isWorldSunDone)) {
62
61
  IWGTasks.worldSunTasks.add(generator._dimension, cx, cy, cz);
63
62
  continue;
64
63
  }
@@ -1,6 +1,5 @@
1
1
  import { WorldRegister } from "../../../World/WorldRegister";
2
2
  import { Sector } from "../../../World/index";
3
- import { SectorStateStructIds } from "../../../World/Sector/SectorStructIds";
4
3
  import { IWGTools } from "./IWGTools";
5
4
  import { TaskRegister } from "./TaskRegister";
6
5
  export class IWGTasks {
@@ -38,15 +37,13 @@ export class IWGTasks {
38
37
  id: "generate",
39
38
  propagationBlocking: true,
40
39
  async run(location, onDone) {
41
- const sector = WorldRegister.sectors.get(location[0], location[1], location[2], location[3]);
40
+ const sector = WorldRegister.sectors.get(...location);
42
41
  if (!sector)
43
42
  throw new Error(`Sector at ${location.toString()} does not exist when attempting generation.`);
44
- Sector.StateStruct.setBuffer(sector.buffer);
45
- if (Sector.StateStruct.getProperty(SectorStateStructIds.isWorldGenDone))
43
+ if (sector.getBitFlag(Sector.FlagIds.isWorldGenDone))
46
44
  return onDone();
47
45
  IWGTools.taskTool.generate.run([location, []], null, () => {
48
- Sector.StateStruct.setBuffer(sector.buffer);
49
- Sector.StateStruct.setProperty(SectorStateStructIds.isWorldGenDone, 1);
46
+ sector.setBitFlag(Sector.FlagIds.isWorldGenDone, true);
50
47
  onDone();
51
48
  });
52
49
  },
@@ -58,15 +55,13 @@ export class IWGTasks {
58
55
  id: "decorate",
59
56
  propagationBlocking: true,
60
57
  async run(location, onDone) {
61
- const sector = WorldRegister.sectors.get(location[0], location[1], location[2], location[3]);
58
+ const sector = WorldRegister.sectors.get(...location);
62
59
  if (!sector)
63
60
  throw new Error(`Sector at ${location.toString()} does not exist when attempting decoration.`);
64
- Sector.StateStruct.setBuffer(sector.buffer);
65
- if (Sector.StateStruct.getProperty(SectorStateStructIds.isWorldDecorDone))
61
+ if (sector.getBitFlag(Sector.FlagIds.isWorldDecorDone))
66
62
  return onDone();
67
63
  IWGTools.taskTool.decorate.run([location, []], null, () => {
68
- Sector.StateStruct.setBuffer(sector.buffer);
69
- Sector.StateStruct.setProperty(SectorStateStructIds.isWorldDecorDone, 1);
64
+ sector.setBitFlag(Sector.FlagIds.isWorldDecorDone, true);
70
65
  onDone();
71
66
  });
72
67
  },
@@ -78,15 +73,13 @@ export class IWGTasks {
78
73
  id: "wolrd_sun",
79
74
  propagationBlocking: true,
80
75
  async run(location, onDone) {
81
- const sector = WorldRegister.sectors.get(location[0], location[1], location[2], location[3]);
76
+ const sector = WorldRegister.sectors.get(...location);
82
77
  if (!sector)
83
78
  throw new Error(`Sector at ${location.toString()} does not exist when attempting world sun.`);
84
- Sector.StateStruct.setBuffer(sector.buffer);
85
- if (Sector.StateStruct.getProperty(SectorStateStructIds.isWorldSunDone))
79
+ if (sector.getBitFlag(Sector.FlagIds.isWorldSunDone))
86
80
  return onDone();
87
81
  IWGTools.taskTool.worldSun.run(location, null, () => {
88
- Sector.StateStruct.setBuffer(sector.buffer);
89
- Sector.StateStruct.setProperty(SectorStateStructIds.isWorldSunDone, 1);
82
+ sector.setBitFlag(Sector.FlagIds.isWorldSunDone, true);
90
83
  onDone();
91
84
  });
92
85
  },
@@ -98,15 +91,13 @@ export class IWGTasks {
98
91
  id: "propagation",
99
92
  propagationBlocking: true,
100
93
  async run(location, onDone) {
101
- const sector = WorldRegister.sectors.get(location[0], location[1], location[2], location[3]);
94
+ const sector = WorldRegister.sectors.get(...location);
102
95
  if (!sector)
103
96
  throw new Error(`Sector at ${location.toString()} does not exist when attempting propagation.`);
104
- Sector.StateStruct.setBuffer(sector.buffer);
105
- if (Sector.StateStruct.getProperty(SectorStateStructIds.isWorldPropagationDone))
97
+ if (sector.getBitFlag(Sector.FlagIds.isWorldPropagationDone))
106
98
  return onDone();
107
99
  IWGTools.taskTool.propagation.run(location, null, () => {
108
- Sector.StateStruct.setBuffer(sector.buffer);
109
- Sector.StateStruct.setProperty(SectorStateStructIds.isWorldPropagationDone, 1);
100
+ sector.setBitFlag(Sector.FlagIds.isWorldPropagationDone, true);
110
101
  onDone();
111
102
  });
112
103
  },
@@ -1,12 +1,10 @@
1
1
  import { BrushTool } from "../../../Tools/Brush/Brush.js";
2
- import { SubstanceDataTool } from "../../../Tools/Data/SubstanceDataTool.js";
3
2
  import { UpdateTask } from "../../Update/UpdateTask.js";
4
3
  import { WorldCursor } from "../../../World/index.js";
5
4
  export declare class FlowManager {
6
5
  static _brush: BrushTool;
7
6
  static _sDataTool: WorldCursor;
8
7
  static _nDataTool: WorldCursor;
9
- static _substanceTool: SubstanceDataTool;
10
8
  static setVoxel(tasks: UpdateTask, vox: string, level: number, levelState: number, x: number, y: number, z: number): void;
11
9
  static setDimension(dimension: string): void;
12
10
  static removeVoxel(tasks: UpdateTask, x: number, y: number, z: number): void;
@@ -1,23 +1,21 @@
1
1
  import { BrushTool } from "../../../Tools/Brush/Brush.js";
2
- import { SubstanceDataTool } from "../../../Tools/Data/SubstanceDataTool.js";
3
2
  import { WorldCursor } from "../../../World/index.js";
4
3
  export class FlowManager {
5
4
  static _brush = new BrushTool();
6
5
  static _sDataTool = new WorldCursor();
7
6
  static _nDataTool = new WorldCursor();
8
- static _substanceTool = new SubstanceDataTool();
9
7
  static setVoxel(tasks, vox, level, levelState, x, y, z) {
10
8
  /* this.sunCheck(tasks, x, y, z);
11
- SunRemove(tasks);
12
- this._brush.setId(vox).setXYZ(x, y, z).paint();
13
- this._sDataTool.loadInAt(x, y, z);
14
- this._sDataTool
15
- .setLevel(level)
16
- .setLevelState(levelState)
17
- .setLight(this.getAbsorbLight(x, y, z))
18
- .commit();
19
-
20
- SunUpdate(tasks); */
9
+ SunRemove(tasks);
10
+ this._brush.setId(vox).setXYZ(x, y, z).paint();
11
+ this._sDataTool.loadInAt(x, y, z);
12
+ this._sDataTool
13
+ .setLevel(level)
14
+ .setLevelState(levelState)
15
+ .setLight(this.getAbsorbLight(x, y, z))
16
+ .commit();
17
+
18
+ SunUpdate(tasks); */
21
19
  }
22
20
  static setDimension(dimension) {
23
21
  // this._sDataTool.setDimension(dimension);
@@ -27,43 +25,44 @@ export class FlowManager {
27
25
  }
28
26
  static removeVoxel(tasks, x, y, z) {
29
27
  /* for (const n of $3dCardinalNeighbors) {
30
- const nx = x + n[0];
31
- const ny = y + n[1];
32
- const nz = z + n[2];
33
- if (!this._nDataTool.loadInAt(nx, ny, nz)) continue;
34
-
35
- const l = this._nDataTool.getLight();
36
-
37
- if (l <= 0) continue;
38
-
39
- if (this.lightData.getS(l) > 0) {
40
- tasks.sun.update.push(nx, ny, nz);
41
- }
42
-
43
- if (this.lightData.hasRGBLight(l)) {
44
- tasks.rgb.update.push(nx, ny, nz);
45
- }
46
- }
47
- this._nDataTool.loadInAt(x, y, z);
48
- const currentLight = this._nDataTool.getLight();
49
- this._brush.setXYZ(x, y, z).erase();
50
- this._nDataTool.clear().loadInAt(x, y, z);
51
- this._nDataTool.setLight(currentLight).commit();
52
- tasks.rgb.remove.push(x, y, z);
53
- RGBRemove(tasks);
54
- SunUpdate(tasks);
55
- RGBUpdate(tasks); */
28
+ const nx = x + n[0];
29
+ const ny = y + n[1];
30
+ const nz = z + n[2];
31
+ if (!this._nDataTool.loadInAt(nx, ny, nz)) continue;
32
+
33
+ const l = this._nDataTool.getLight();
34
+
35
+ if (l <= 0) continue;
36
+
37
+ if (this.lightData.getS(l) > 0) {
38
+ tasks.sun.update.push(nx, ny, nz);
39
+ }
40
+
41
+ if (this.lightData.hasRGBLight(l)) {
42
+ tasks.rgb.update.push(nx, ny, nz);
43
+ }
44
+ }
45
+ this._nDataTool.loadInAt(x, y, z);
46
+ const currentLight = this._nDataTool.getLight();
47
+ this._brush.setXYZ(x, y, z).erase();
48
+ this._nDataTool.clear().loadInAt(x, y, z);
49
+ this._nDataTool.setLight(currentLight).commit();
50
+ tasks.rgb.remove.push(x, y, z);
51
+ RGBRemove(tasks);
52
+ SunUpdate(tasks);
53
+ RGBUpdate(tasks); */
56
54
  }
57
55
  static getFlowRate(substance) {
58
- this._substanceTool.setSubstanceFromString(substance);
59
- return this._substanceTool.getFlowRate();
56
+ // this._substanceTool.setSubstanceFromString(substance);
57
+ // return this._substanceTool.getFlowRate();
58
+ return 0;
60
59
  }
61
60
  static getVoxel(x, y, z) {
62
61
  /* if (!this._sDataTool.loadInAt(x, y, z)) return false;
63
- if (!this._sDataTool.isRenderable()) return false;
64
-
65
- const substance = this._sDataTool.getSubstnaceData();
66
- if (!substance.isLiquid()) return false; */
62
+ if (!this._sDataTool.isRenderable()) return false;
63
+
64
+ const substance = this._sDataTool.getSubstnaceData();
65
+ if (!substance.isLiquid()) return false; */
67
66
  return this._sDataTool;
68
67
  }
69
68
  static setLevel(level, x, y, z) {
@@ -72,39 +71,39 @@ export class FlowManager {
72
71
  }
73
72
  static getLevel(vox, x, y, z) {
74
73
  /* if (!this._nDataTool.loadInAt(x, y, z)) return -2;
75
- const voxel = this._nDataTool.getStringId();
76
- if (this._nDataTool.isAir()) {
77
- return 0;
78
- }
79
- if (voxel == vox) {
80
- return this._nDataTool.getLevel();
81
- }
82
- return -1; */
74
+ const voxel = this._nDataTool.getStringId();
75
+ if (this._nDataTool.isAir()) {
76
+ return 0;
77
+ }
78
+ if (voxel == vox) {
79
+ return this._nDataTool.getLevel();
80
+ }
81
+ return -1; */
83
82
  }
84
83
  static getLevelState(vox, x, y, z) {
85
84
  /* if (!this._nDataTool.loadInAt(x, y, z)) return -2;
86
- const voxel = this._nDataTool.getStringId();
87
- if (voxel == vox) {
88
- return this._nDataTool.getLevelState();
89
- }
90
- if (this._nDataTool.isAir()) {
91
- return -1;
92
- }
93
- return -3; */
85
+ const voxel = this._nDataTool.getStringId();
86
+ if (voxel == vox) {
87
+ return this._nDataTool.getLevelState();
88
+ }
89
+ if (this._nDataTool.isAir()) {
90
+ return -1;
91
+ }
92
+ return -3; */
94
93
  }
95
94
  static canFlowOutwardTest(vox, x, y, z) {
96
95
  /* const level = this.getLevel(vox, x, y - 1, z);
97
- if (level == -1) {
98
- return true;
99
- }
100
- return false; */
96
+ if (level == -1) {
97
+ return true;
98
+ }
99
+ return false; */
101
100
  }
102
101
  static flowDownTest(vox, x, y, z) {
103
102
  /* const level = this.getLevel(vox, x, y - 1, z);
104
- if (level >= 0) {
105
- return true;
106
- }
107
- return false; */
103
+ if (level >= 0) {
104
+ return true;
105
+ }
106
+ return false; */
108
107
  }
109
108
  static wait(ms) {
110
109
  return new Promise((resolve, reject) => setTimeout(resolve, ms));
@@ -114,29 +113,29 @@ export class FlowManager {
114
113
  ];
115
114
  static getAbsorbLight(x, y, z) {
116
115
  /* for (const n of $3dCardinalNeighbors) {
117
- if (!n[0] && !n[1] && !n[2]) continue;
118
- if (!this._nDataTool.loadInAt(x + n[0], y + n[1], z + n[2])) continue;
119
- let l = this._nDataTool.getLight();
120
- if (l <= 0) continue;
121
- const v = this.lightData.getLightValues(l);
122
- for (let i = 0; i < 4; i++) {
123
- if (this._lightValues[i] < v[i]) {
124
- this._lightValues[i] = v[i];
125
- }
126
- }
116
+ if (!n[0] && !n[1] && !n[2]) continue;
117
+ if (!this._nDataTool.loadInAt(x + n[0], y + n[1], z + n[2])) continue;
118
+ let l = this._nDataTool.getLight();
119
+ if (l <= 0) continue;
120
+ const v = this.lightData.getLightValues(l);
121
+ for (let i = 0; i < 4; i++) {
122
+ if (this._lightValues[i] < v[i]) {
123
+ this._lightValues[i] = v[i];
127
124
  }
128
- let brightest = this.lightData.setLightValues(this._lightValues);
129
- for (let i = 0; i < 4; i++) {
130
- this._lightValues[i] = 0;
131
- } */
125
+ }
126
+ }
127
+ let brightest = this.lightData.setLightValues(this._lightValues);
128
+ for (let i = 0; i < 4; i++) {
129
+ this._lightValues[i] = 0;
130
+ } */
132
131
  // return this.lightData.minusOneForAll(2);
133
132
  }
134
133
  static sunCheck(tasks, x, y, z) {
135
134
  /* if (!this._nDataTool.loadInAt(x, y - 1, z)) return;
136
- if (!this._nDataTool.isAir()) return;
137
- const l = this._nDataTool.getLight();
138
- if (this.lightData.getS(l) == 0xf) {
139
- tasks.sun.remove.push(x, y - 1, z);
140
- } */
135
+ if (!this._nDataTool.isAir()) return;
136
+ const l = this._nDataTool.getLight();
137
+ if (this.lightData.getS(l) == 0xf) {
138
+ tasks.sun.remove.push(x, y - 1, z);
139
+ } */
141
140
  }
142
141
  }