@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
@@ -1,6 +1,5 @@
1
1
  import { WorldSpaces } from "../../../World/WorldSpaces";
2
2
  import { WorldRegister } from "../../../World/WorldRegister";
3
- import { SectionHeightMap } from "../../../World/Section/SectionHeightMap";
4
3
  import { EngineSettings } from "../../../Settings/EngineSettings";
5
4
  import { SunRemove, SunUpdate } from "../Illumanation/SunUpdate";
6
5
  import { RGBRemove, RGBUpdate } from "../Illumanation/RGBUpdate";
@@ -118,7 +117,7 @@ export function WorldFlow(task) {
118
117
  const section = sector.sections[i];
119
118
  if (!section)
120
119
  continue;
121
- let [minY, maxY] = SectionHeightMap.setSection(section).getMinMax();
120
+ let [minY, maxY] = section.getMinMax();
122
121
  const cx = sector.position[0];
123
122
  const cy = sector.position[1] + i * WorldSpaces.section.bounds.y;
124
123
  const cz = sector.position[2];
@@ -130,7 +129,7 @@ export function WorldFlow(task) {
130
129
  const voxel = task.nDataCursor.getVoxel(x, y, z);
131
130
  if (!voxel || voxel.isAir())
132
131
  continue;
133
- if (voxel.getSubstanceData().isLiquid()) {
132
+ if (voxel.getSubstanceData()["dve_is_liquid"]) {
134
133
  for (let i = 0; i < 5; i++) {
135
134
  const nVoxel = task.nDataCursor.getVoxel(x + flowUpdateChecks[i][0], y + flowUpdateChecks[i][1], z + flowUpdateChecks[i][2]);
136
135
  if (nVoxel && nVoxel.isAir()) {
@@ -1,7 +1,6 @@
1
1
  import { WorldSpaces } from "../../../World/WorldSpaces";
2
2
  import { WorldRegister } from "../../../World/WorldRegister";
3
3
  import { SectionCursor } from "../../../World/Cursor/SectionCursor";
4
- import { SectionHeightMap } from "../../../World/Section/SectionHeightMap";
5
4
  import { EngineSettings } from "../../../Settings/EngineSettings";
6
5
  import { RGBUpdate } from "./RGBUpdate";
7
6
  const sectionCursor = new SectionCursor();
@@ -20,7 +19,7 @@ export function WorldRGB(task) {
20
19
  if (!section)
21
20
  continue;
22
21
  sectionCursor.setSection(section);
23
- let [minY, maxY] = SectionHeightMap.setSection(section).getMinMax();
22
+ let [minY, maxY] = section.getMinMax();
24
23
  const cx = sector.position[0];
25
24
  const cy = sector.position[1] + i * WorldSpaces.section.bounds.y;
26
25
  const cz = sector.position[2];
@@ -1,4 +1,5 @@
1
+ import { Thread } from "@amodx/threads";
1
2
  import { UpdateTask } from "./UpdateTask";
2
3
  export default function (props: {
3
- onDone(taks: UpdateTask): void;
4
+ onDone(taks: UpdateTask, origin: Thread): void;
4
5
  }): void;
@@ -2,22 +2,22 @@ import { Threads } from "@amodx/threads";
2
2
  import { TasksIds } from "../TasksIds";
3
3
  import { VoxelUpdate, EreaseAndUpdate, PaintAndUpdate } from "./VoxelUpdate";
4
4
  export default function (props) {
5
- Threads.registerTask(TasksIds.VoxelUpdate, async (data) => {
5
+ Threads.registerTask(TasksIds.VoxelUpdate, async (data, origin) => {
6
6
  const tasks = await VoxelUpdate(data);
7
7
  if (!tasks)
8
8
  return;
9
- props.onDone(tasks);
9
+ props.onDone(tasks, origin);
10
10
  });
11
- Threads.registerTask(TasksIds.VoxelErease, async (data) => {
11
+ Threads.registerTask(TasksIds.VoxelErease, async (data, origin) => {
12
12
  const tasks = await EreaseAndUpdate(data);
13
13
  if (!tasks)
14
14
  return;
15
- props.onDone(tasks);
15
+ props.onDone(tasks, origin);
16
16
  });
17
- Threads.registerTask(TasksIds.VoxelPaint, async (data) => {
17
+ Threads.registerTask(TasksIds.VoxelPaint, async (data, origin) => {
18
18
  const tasks = await PaintAndUpdate(data);
19
19
  if (!tasks)
20
20
  return;
21
- props.onDone(tasks);
21
+ props.onDone(tasks, origin);
22
22
  });
23
23
  }
@@ -1,13 +1,11 @@
1
1
  import { EngineSettings as ES } from "../../Settings/EngineSettings.js";
2
2
  import { $3dCardinalNeighbors } from "../../Math/CardinalNeighbors.js";
3
3
  import { UpdateTask } from "./UpdateTask.js";
4
- import { SubstanceDataTool } from "../../Tools/Data/SubstanceDataTool.js";
5
4
  import { RGBRemove, RGBUpdate } from "../Propagation/Illumanation/RGBUpdate.js";
6
5
  import { SunRemove, SunUpdate } from "../Propagation/Illumanation/SunUpdate.js";
7
6
  import { FlowUpdate } from "../Propagation/Flow/FlowUpdate.js";
8
7
  import { FlowRemove } from "../Propagation/Flow/FlowRemove.js";
9
8
  const tasks = new UpdateTask();
10
- const substanceData = new SubstanceDataTool();
11
9
  const updateLightTask = (tasks) => {
12
10
  let doRGB = ES.doRGBPropagation;
13
11
  let doSun = ES.doSunPropagation;
@@ -38,9 +36,9 @@ export async function EreaseAndUpdate(location) {
38
36
  let voxel = tasks.sDataCursor.getVoxel(x, y, z);
39
37
  if (!voxel)
40
38
  return false;
41
- substanceData.setSubstance(voxel.getSubstance());
39
+ const substanceData = voxel.getSubstanceData();
42
40
  if (!voxel.isAir() && ES.doFlow && voxel.isRenderable()) {
43
- if (substanceData.isLiquid()) {
41
+ if (substanceData["dve_is_liquid"]) {
44
42
  FlowRemove(tasks);
45
43
  return tasks;
46
44
  }
@@ -70,6 +68,11 @@ export async function EreaseAndUpdate(location) {
70
68
  SunUpdate(tasks);
71
69
  }
72
70
  }
71
+ for (let i = 0; i < $3dCardinalNeighbors.length; i++) {
72
+ tasks.sDataCursor
73
+ .getVoxel($3dCardinalNeighbors[i][0] + x, $3dCardinalNeighbors[i][1] + y, $3dCardinalNeighbors[i][2] + z)
74
+ ?.updateVoxel(2);
75
+ }
73
76
  return tasks;
74
77
  }
75
78
  export async function PaintAndUpdate(data) {
@@ -107,6 +110,7 @@ export async function PaintAndUpdate(data) {
107
110
  voxel.setLevel(raw[2]);
108
111
  voxel.setState(raw[3]);
109
112
  voxel.setMod(raw[4]);
113
+ voxel.process();
110
114
  if (raw[3] > 0 && voxel.canHaveSecondaryVoxel()) {
111
115
  voxel.setSecondary(true);
112
116
  voxel.setId(raw[5]);
@@ -128,11 +132,15 @@ export async function PaintAndUpdate(data) {
128
132
  }
129
133
  voxel = tasks.sDataCursor.getVoxel(x, y, z);
130
134
  if (ES.doFlow) {
131
- if (!voxel.isAir() &&
132
- substanceData.setSubstance(voxel.getSubstance()).isLiquid()) {
135
+ if (!voxel.isAir() && voxel.getSubstanceData()["dve_is_liquid"]) {
133
136
  FlowUpdate(tasks);
134
137
  }
135
138
  }
139
+ for (let i = 0; i < $3dCardinalNeighbors.length; i++) {
140
+ tasks.sDataCursor
141
+ .getVoxel($3dCardinalNeighbors[i][0] + x, $3dCardinalNeighbors[i][1] + y, $3dCardinalNeighbors[i][2] + z)
142
+ ?.updateVoxel(2);
143
+ }
136
144
  return tasks;
137
145
  }
138
146
  export async function VoxelUpdate(data) {
@@ -155,7 +163,7 @@ export async function VoxelUpdate(data) {
155
163
  }
156
164
  }
157
165
  if (ES.doFlow) {
158
- if (substanceData.setSubstance(voxel.getSubstance()).isLiquid()) {
166
+ if (voxel.getSubstanceData()["dve_is_solid"]) {
159
167
  FlowUpdate(tasks);
160
168
  }
161
169
  }
@@ -64,6 +64,7 @@ export class WorldGenBrush extends BrushTool {
64
64
  if (!voxel)
65
65
  return false;
66
66
  const sl = voxel.getLight();
67
+ voxel.updateVoxel(2);
67
68
  if (lightData.hasRGBLight(sl)) {
68
69
  this.tasks.rgb.update.push(this.x, this.y, this.z);
69
70
  // Propagation.instance.rgbUpdate(this.tasks);
@@ -1,5 +1,5 @@
1
1
  import { TemplateVoxelCursor } from "./TemplateVoxelCursor";
2
- import { DataCursorInterface } from "../../Data/Cursor/DataCursor.interface";
2
+ import { DataCursorInterface } from "../../Tools/DataCursor.interface";
3
3
  import { FullVoxelTemplate } from "Templates/FullVoxelTemplate";
4
4
  export declare class TemplateCursor extends DataCursorInterface {
5
5
  _voxelIndex: number;
@@ -1,5 +1,5 @@
1
1
  import { TemplateVoxelCursor } from "./TemplateVoxelCursor";
2
- import { DataCursorInterface } from "../../Data/Cursor/DataCursor.interface";
2
+ import { DataCursorInterface } from "../../Tools/DataCursor.interface";
3
3
  export class TemplateCursor extends DataCursorInterface {
4
4
  _voxelIndex = 0;
5
5
  _template = null;
@@ -2,7 +2,7 @@ import { Flat3DIndex, Traverse } from "@amodx/math";
2
2
  import { StringPalette } from "../../Util/StringPalette";
3
3
  import { VoxelTemplate } from "../VoxelTemplate";
4
4
  import { NumberPalette } from "../../Util/NumberPalette";
5
- import { convertToPaletteBuffer } from "../../Data/Functions/Palettes";
5
+ import { convertToPaletteBuffer } from "../../Util/Binary/Palettes";
6
6
  import { WorldCursor } from "../../World";
7
7
  export default function CreateTemplate(dimension, start, end) {
8
8
  const dataTool = new WorldCursor();
@@ -1,10 +1,9 @@
1
1
  import { Flat3DIndex, Traverse } from "@amodx/math";
2
2
  import { StringPalette } from "../Util/StringPalette";
3
3
  import { NumberPalette } from "../Util/NumberPalette";
4
- import { VoxelPalette } from "../Voxels/Palettes/VoxelPalette";
5
- import { VoxelStruct } from "../Voxels/Structs/VoxelStruct";
6
- import { VoxelStructIds } from "../Voxels/Types/Voxel.types";
7
- import { getPaletteArray } from "../Data/Functions/Palettes";
4
+ import { getPaletteArray } from "../Util/Binary/Palettes";
5
+ import { VoxelPalettesRegister } from "../Voxels/Data/VoxelPalettesRegister";
6
+ import { VoxelTagsRegister } from "../Voxels/Data/VoxelTagsRegister";
8
7
  export class VoxelTemplate {
9
8
  index = Flat3DIndex.GetXZYOrder();
10
9
  size;
@@ -49,7 +48,7 @@ export class VoxelTemplate {
49
48
  }
50
49
  getId(index) {
51
50
  const ids = this.ids;
52
- return VoxelPalette.ids.getNumberId(this.idPalette.getStringId(typeof ids == "number" ? ids : ids[index]));
51
+ return VoxelPalettesRegister.voxels.getNumberId(this.idPalette.getStringId(typeof ids == "number" ? ids : ids[index]));
53
52
  }
54
53
  getState(index) {
55
54
  const state = this.state;
@@ -65,9 +64,8 @@ export class VoxelTemplate {
65
64
  }
66
65
  getSecondary(id, index) {
67
66
  const secondary = this.secondary;
68
- VoxelStruct.setVoxel(id);
69
- if (VoxelStruct.instance[VoxelStructIds.canHaveSecondary] == 1) {
70
- return VoxelPalette.ids.getNumberId(this.secondaryIdPalette.getStringId(typeof secondary == "number" ? secondary : secondary[index]));
67
+ if (VoxelTagsRegister.VoxelTags[id]["dve_can_have_secondary"]) {
68
+ return VoxelPalettesRegister.voxels.getNumberId(this.secondaryIdPalette.getStringId(typeof secondary == "number" ? secondary : secondary[index]));
71
69
  }
72
70
  return this.secondaryStatePalette.getValue(typeof secondary == "number" ? secondary : secondary[index]);
73
71
  }
@@ -1,6 +1,5 @@
1
1
  import type { PaintVoxelData, RawVoxelData } from "../../Voxels/Types/Voxel.types.js";
2
2
  import { WorldCursor } from "../../World/Cursor/WorldCursor.js";
3
- import { SubstanceDataTool } from "../../Tools/Data/SubstanceDataTool.js";
4
3
  import { VoxelCursor } from "../../Voxels/Cursor/VoxelCursor.js";
5
4
  export declare class BrushTool {
6
5
  data: PaintVoxelData;
@@ -11,7 +10,6 @@ export declare class BrushTool {
11
10
  name: string;
12
11
  voxelCursor: VoxelCursor;
13
12
  dataCursor: WorldCursor;
14
- substanceData: SubstanceDataTool;
15
13
  setXYZ(x: number, y: number, z: number): this;
16
14
  newSector(): void;
17
15
  setData(data: Partial<PaintVoxelData>): this;
@@ -1,8 +1,7 @@
1
- import { VoxelPalette } from "../../Voxels/Palettes/VoxelPalette.js";
2
1
  import { WorldCursor } from "../../World/Cursor/WorldCursor.js";
3
- import { SubstanceDataTool } from "../../Tools/Data/SubstanceDataTool.js";
4
2
  import { VoxelCursor } from "../../Voxels/Cursor/VoxelCursor.js";
5
3
  import { WorldRegister } from "../../World/WorldRegister.js";
4
+ import { VoxelPalettesRegister } from "../../Voxels/Data/VoxelPalettesRegister.js";
6
5
  const airId = "dve_air";
7
6
  const air = [0, 0, 0, 0, 0, 0];
8
7
  export class BrushTool {
@@ -21,7 +20,6 @@ export class BrushTool {
21
20
  name = airId;
22
21
  voxelCursor = new VoxelCursor();
23
22
  dataCursor = new WorldCursor();
24
- substanceData = new SubstanceDataTool();
25
23
  setXYZ(x, y, z) {
26
24
  this.x = x;
27
25
  this.y = y;
@@ -67,7 +65,7 @@ export class BrushTool {
67
65
  return this;
68
66
  }
69
67
  setName(name) {
70
- this.data.id = VoxelPalette.name.getId(name);
68
+ this.data.id = VoxelPalettesRegister.voxelName.getId(name);
71
69
  this.name = name;
72
70
  return this;
73
71
  }
@@ -109,7 +107,7 @@ export class BrushTool {
109
107
  const voxel = this.dataCursor.getVoxel(this.x, this.y, this.z);
110
108
  if (!voxel)
111
109
  return;
112
- const id = VoxelPalette.ids.getNumberId(this.data.id);
110
+ const id = VoxelPalettesRegister.voxels.getNumberId(this.data.id);
113
111
  if (id < 0)
114
112
  return false;
115
113
  voxel.setId(id);
@@ -120,13 +118,14 @@ export class BrushTool {
120
118
  voxel.setLevel(this.data.level);
121
119
  voxel.setMod(this.data.mod);
122
120
  if (this.data.secondaryVoxelId) {
123
- const vid = VoxelPalette.ids.getNumberId(this.data.secondaryVoxelId);
121
+ const vid = VoxelPalettesRegister.voxels.getNumberId(this.data.secondaryVoxelId);
124
122
  if (vid > 0) {
125
123
  voxel.setSecondary(true);
126
124
  voxel.setId(vid);
127
125
  voxel.setSecondary(false);
128
126
  }
129
127
  }
128
+ voxel.process();
130
129
  if (voxel.isLightSource() && voxel.getLightSourceValue()) {
131
130
  voxel.setLight(voxel.getLightSourceValue());
132
131
  }
@@ -1,4 +1,4 @@
1
- import { VoxelCursorInterface } from "../../Voxels/Cursor/VoxelCursor.interface";
1
+ import { VoxelCursorInterface } from "../Voxels/Cursor/VoxelCursor.interface";
2
2
  export declare abstract class DataCursorInterface {
3
3
  abstract getVoxel(x: number, y: number, z: number): VoxelCursorInterface | null;
4
4
  abstract inBounds(x: number, y: number, z: number): boolean;
@@ -0,0 +1,4 @@
1
+ export declare function getBitValue(data: number, bitIndex: number, bitSize: number): number;
2
+ export declare function setBitValue(data: number, bitIndex: number, value: number, bitSize: number): number;
3
+ export declare function getBitArrayIndex(data: Uint8Array, arrayIndex: number): number;
4
+ export declare function setBitArrayIndex(data: Uint8Array, arrayIndex: number, value: number): void;
@@ -0,0 +1,16 @@
1
+ export function getBitValue(data, bitIndex, bitSize) {
2
+ const mask = 2 ** bitSize - 1;
3
+ return ((mask << bitIndex) & data) >>> bitIndex;
4
+ }
5
+ export function setBitValue(data, bitIndex, value, bitSize) {
6
+ const mask = 2 ** bitSize - 1;
7
+ return (data & ~(mask << bitIndex)) | ((value & mask) << bitIndex);
8
+ }
9
+ export function getBitArrayIndex(data, arrayIndex) {
10
+ const arrayByteIndex = (arrayIndex / 8) >> 0;
11
+ return getBitValue(data[arrayByteIndex], arrayIndex - arrayByteIndex * 8, 1);
12
+ }
13
+ export function setBitArrayIndex(data, arrayIndex, value) {
14
+ const arrayByteIndex = (arrayIndex / 8) >> 0;
15
+ data[arrayByteIndex] = setBitValue(data[arrayByteIndex], arrayIndex - arrayByteIndex * 8, value, 1);
16
+ }
@@ -4,6 +4,7 @@ export declare class StringPalette {
4
4
  _map: Record<string, number>;
5
5
  constructor(inital?: ArrayLike<string>);
6
6
  get size(): number;
7
+ load(palette: string[]): void;
7
8
  register(string: string): number;
8
9
  get(): string[];
9
10
  getMap(): Record<string, number>;
@@ -13,6 +13,14 @@ export class StringPalette {
13
13
  get size() {
14
14
  return this._count;
15
15
  }
16
+ load(palette) {
17
+ this._palette = [];
18
+ this._map = {};
19
+ const length = palette.length;
20
+ for (let i = 0; i < length; i++) {
21
+ this.register(palette[i]);
22
+ }
23
+ }
16
24
  register(string) {
17
25
  const id = this._count;
18
26
  this._count++;
@@ -2,12 +2,12 @@ import { VoxelCursorInterface } from "./VoxelCursor.interface";
2
2
  import { PaintVoxelData, RawVoxelData } from "../Types/Voxel.types";
3
3
  export declare class VoxelCursor extends VoxelCursorInterface {
4
4
  static VoxelDataToRaw(data: Partial<PaintVoxelData>, light?: number): RawVoxelData;
5
- ids: number[];
6
- light: number[];
7
- level: number[];
8
- state: number[];
9
- secondary: number[];
10
- mod: number[];
5
+ ids: Uint16Array;
6
+ light: Uint16Array;
7
+ level: Uint8Array;
8
+ state: Uint16Array;
9
+ mod: Uint16Array;
10
+ secondary: Uint16Array;
11
11
  loadIn(): void;
12
12
  updateVoxel(mode: 0 | 1): void;
13
13
  }
@@ -1,7 +1,6 @@
1
1
  import { VoxelLightData } from "./VoxelLightData";
2
- import { VoxelStruct } from "../Structs/VoxelStruct";
3
2
  import { RawVoxelData } from "../Types/Voxel.types";
4
- import { SubstanceDataTool } from "../../Tools/Data/SubstanceDataTool";
3
+ import { VoxelSubstanceTags, VoxelTags } from "../../Voxels/Data/VoxelTag.types";
5
4
  interface WritableArrayLike<T> {
6
5
  length: number;
7
6
  [index: number]: T;
@@ -10,7 +9,8 @@ export declare abstract class VoxelCursorInterface {
10
9
  _loadedId: number;
11
10
  id: number;
12
11
  secondaryId: number;
13
- __struct: VoxelStruct;
12
+ _tags: VoxelTags;
13
+ _substanceTags: VoxelSubstanceTags;
14
14
  __secondary: boolean;
15
15
  _index: number;
16
16
  abstract ids: WritableArrayLike<number>;
@@ -21,24 +21,19 @@ export declare abstract class VoxelCursorInterface {
21
21
  abstract mod: WritableArrayLike<number>;
22
22
  /**
23
23
  *
24
- * @param mode 0 for add 1 for remove
24
+ * @param mode 0 for add 1 for remove 2 for the voxel needs a buried check only
25
25
  */
26
- abstract updateVoxel(mode: 0 | 1): void;
26
+ abstract updateVoxel(mode: 0 | 1 | 2): void;
27
27
  _lightData: VoxelLightData;
28
- _substanceData: SubstanceDataTool;
29
28
  process(): void;
30
29
  abstract loadIn(): void;
31
30
  setSecondary(enable: boolean): this;
32
- getRenderedMaterial(): number;
33
- getRenderedMaterialStringId(): string;
34
- getMaterial(): number;
35
- getMaterialStringId(): string;
31
+ getRenderedMaterial(): string;
32
+ getMaterial(): string;
36
33
  checkCollisions(): boolean;
37
- getCollider(): number;
38
- getColliderStringId(): string | null;
39
- getSubstance(): number;
40
- getSubstanceData(): SubstanceDataTool;
41
- getSubstanceStringId(): string;
34
+ getCollider(): string;
35
+ getSubstance(): string;
36
+ getSubstanceData(): VoxelSubstanceTags;
42
37
  isOpaque(): boolean;
43
38
  getMod(): number;
44
39
  setMod(mod: number): this;
@@ -1,26 +1,20 @@
1
- import { VoxelStructIds } from "../Types/Voxel.types";
2
1
  import { VoxelLightData } from "./VoxelLightData";
3
- import { MappedDataRegister } from "../../Data/Register/MappedDataRegister";
4
- import { VoxelStruct } from "../Structs/VoxelStruct";
5
- import { VoxelLevelReader } from "../VoxelLevelReader";
6
- import { VoxelTagStates } from "../State/VoxelTagStates";
7
- import { VoxelPalette } from "../Palettes/VoxelPalette";
8
- import { SubstancePalette } from "../Palettes/SubstancePalette";
9
- import { MaterialPalette } from "../Palettes/MaterialPalette";
10
- import { SubstanceDataTool } from "../../Tools/Data/SubstanceDataTool";
2
+ import { VoxelLevelReader } from "./VoxelLevelReader";
3
+ import { VoxelTagStates } from "../Data/VoxelTagStates";
4
+ import { VoxelTagIds, } from "../../Voxels/Data/VoxelTag.types";
5
+ import { VoxelTagsRegister } from "../../Voxels/Data/VoxelTagsRegister";
6
+ import { VoxelPalettesRegister } from "../../Voxels/Data/VoxelPalettesRegister";
11
7
  export class VoxelCursorInterface {
12
8
  _loadedId = 0;
13
9
  id = 0;
14
10
  secondaryId = 0;
15
- __struct;
11
+ _tags;
12
+ _substanceTags;
16
13
  __secondary = false;
17
14
  // private _section: Section;
18
15
  _index = 0;
19
16
  _lightData = new VoxelLightData();
20
- _substanceData = new SubstanceDataTool();
21
17
  process() {
22
- if (!this.__struct)
23
- this.__struct = VoxelStruct.clone();
24
18
  this.id = this.ids[this._index];
25
19
  this.secondaryId = this.secondary[this._index];
26
20
  if (this.secondaryId > 1) {
@@ -29,52 +23,38 @@ export class VoxelCursorInterface {
29
23
  else {
30
24
  this.secondaryId = 0;
31
25
  }
32
- this.__struct.setIndex(VoxelStruct.voxelIndex[this.id]);
33
26
  this._loadedId = this.getId();
27
+ this._tags = VoxelTagsRegister.VoxelTags[this._loadedId];
28
+ this._substanceTags =
29
+ VoxelTagsRegister.SubstanceStags[VoxelPalettesRegister.substance.getNumberId(this._tags["dve_substance"])];
34
30
  }
35
31
  setSecondary(enable) {
36
32
  this.__secondary = enable;
37
- if (enable) {
38
- this.__struct.setIndex(VoxelStruct.voxelIndex[this.secondaryId]);
39
- }
40
- else {
41
- this.__struct.setIndex(VoxelStruct.voxelIndex[this.id]);
42
- }
33
+ VoxelTagIds;
34
+ VoxelTagsRegister;
43
35
  this._loadedId = this.getId();
44
36
  return this;
45
37
  }
46
38
  getRenderedMaterial() {
47
- return this.__struct[VoxelStructIds.renderedMaterial];
48
- }
49
- getRenderedMaterialStringId() {
50
- return MaterialPalette.id.stringFromNumber(this.__struct[VoxelStructIds.renderedMaterial]);
39
+ return this._tags[VoxelTagIds.renderedMaterial];
51
40
  }
52
41
  getMaterial() {
53
- return this.__struct[VoxelStructIds.voxelMaterial];
54
- }
55
- getMaterialStringId() {
56
- return MaterialPalette.id.stringFromNumber(this.__struct[VoxelStructIds.voxelMaterial]);
42
+ return this._tags[VoxelTagIds.voxelMaterial];
57
43
  }
58
44
  checkCollisions() {
59
- return this.__struct[VoxelStructIds.checkCollisions] == 1;
45
+ return this._tags[VoxelTagIds.checkCollisions];
60
46
  }
61
47
  getCollider() {
62
- return this.__struct[VoxelStructIds.colliderID];
63
- }
64
- getColliderStringId() {
65
- return MappedDataRegister.stringMaps.get("voxel", VoxelStructIds.colliderID, this.__struct[VoxelStructIds.colliderID]);
48
+ return this._tags[VoxelTagIds.colliderID];
66
49
  }
67
50
  getSubstance() {
68
- return this.__struct[VoxelStructIds.substance];
51
+ return this._tags[VoxelTagIds.substance];
69
52
  }
70
53
  getSubstanceData() {
71
- return this._substanceData.setSubstance(this.getSubstance());
72
- }
73
- getSubstanceStringId() {
74
- return SubstancePalette.id.stringFromNumber(this.getSubstance());
54
+ return this._substanceTags;
75
55
  }
76
56
  isOpaque() {
77
- return this.__struct[VoxelStructIds.isTransparent] == 0;
57
+ return this._tags[VoxelTagIds.isTransparent];
78
58
  }
79
59
  getMod() {
80
60
  return this.mod[this._index];
@@ -108,7 +88,7 @@ export class VoxelCursorInterface {
108
88
  return this.secondaryId > 1;
109
89
  }
110
90
  canHaveSecondaryVoxel() {
111
- return this.__struct[VoxelStructIds.canHaveSecondary] == 1;
91
+ return this._tags[VoxelTagIds.canHaveSecondary];
112
92
  }
113
93
  hasRGBLight() {
114
94
  const light = this.getLight();
@@ -125,7 +105,7 @@ export class VoxelCursorInterface {
125
105
  getLight() {
126
106
  if (this._loadedId == 0)
127
107
  return this.light[this._index];
128
- const lightValue = this.__struct[VoxelStructIds.lightValue];
108
+ const lightValue = this._tags[VoxelTagIds.lightValue];
129
109
  if (this.isOpaque()) {
130
110
  if (this.isLightSource() && lightValue) {
131
111
  return lightValue;
@@ -146,19 +126,19 @@ export class VoxelCursorInterface {
146
126
  isLightSource() {
147
127
  if (this._loadedId <= 0)
148
128
  return false;
149
- return VoxelTagStates.isRegistered(this._loadedId, VoxelStructIds.isLightSource)
150
- ? VoxelTagStates.getValue(this._loadedId, VoxelStructIds.isLightSource, this.getState()) === true
151
- : this.__struct[VoxelStructIds.isLightSource] == 1;
129
+ return VoxelTagStates.isRegistered(this._loadedId, VoxelTagIds.isLightSource)
130
+ ? VoxelTagStates.getValue(this._loadedId, VoxelTagIds.isLightSource, this.getState()) === true
131
+ : this._tags[VoxelTagIds.isLightSource];
152
132
  }
153
133
  getLightSourceValue() {
154
134
  if (this._loadedId <= 0)
155
135
  return 0;
156
- return this.__struct[VoxelStructIds.lightValue];
136
+ return this._tags[VoxelTagIds.lightValue];
157
137
  }
158
138
  noAO() {
159
139
  if (this._loadedId <= 0)
160
140
  return false;
161
- return this.__struct[VoxelStructIds.noAO] == 1;
141
+ return this._tags[VoxelTagIds.noAO];
162
142
  }
163
143
  isRenderable() {
164
144
  if (this.id > 0)
@@ -189,16 +169,16 @@ export class VoxelCursorInterface {
189
169
  return this;
190
170
  }
191
171
  setStringId(id) {
192
- return this.setId(VoxelPalette.ids.getNumberId(id));
172
+ return this.setId(VoxelPalettesRegister.voxels.getNumberId(id));
193
173
  }
194
174
  getStringId() {
195
175
  if (this.__secondary) {
196
- return VoxelPalette.ids.getStringId(this.secondaryId);
176
+ return VoxelPalettesRegister.voxels.getStringId(this.secondaryId);
197
177
  }
198
- return VoxelPalette.ids.getStringId(this.id);
178
+ return VoxelPalettesRegister.voxels.getStringId(this.id);
199
179
  }
200
180
  setName(name) {
201
- this.setStringId(VoxelPalette.name.getId(name));
181
+ this.setStringId(VoxelPalettesRegister.voxelName.getId(name));
202
182
  }
203
183
  getName() {
204
184
  return this.getStringId();
@@ -1,11 +1,13 @@
1
1
  import { VoxelCursorInterface } from "./VoxelCursor.interface";
2
- import { VoxelPalette } from "../../Voxels/Palettes/VoxelPalette";
3
- import { VoxelLevelReader } from "../VoxelLevelReader";
2
+ import { VoxelPalettesRegister } from "../../Voxels/Data/VoxelPalettesRegister";
3
+ import { VoxelLevelReader } from "./VoxelLevelReader";
4
4
  export class VoxelCursor extends VoxelCursorInterface {
5
5
  static VoxelDataToRaw(data, light = 0) {
6
- const id = (data.id !== undefined && VoxelPalette.ids.getNumberId(data.id)) || 0;
6
+ const id = (data.id !== undefined &&
7
+ VoxelPalettesRegister.voxels.getNumberId(data.id)) ||
8
+ 0;
7
9
  const secondaryId = (data.secondaryVoxelId !== undefined &&
8
- VoxelPalette.ids.getNumberId(data.secondaryVoxelId)) ||
10
+ VoxelPalettesRegister.voxels.getNumberId(data.secondaryVoxelId)) ||
9
11
  0;
10
12
  let levleData = 0;
11
13
  if (data.level !== undefined)
@@ -14,13 +16,12 @@ export class VoxelCursor extends VoxelCursorInterface {
14
16
  levleData = VoxelLevelReader.setLevelState(levleData, data.levelState);
15
17
  return [id, light, levleData, data.state || 0, data.mod || 0, secondaryId];
16
18
  }
17
- ids = [0];
18
- light = [0];
19
- level = [0];
20
- state = [0];
21
- secondary = [0];
22
- mod = [0];
19
+ ids = new Uint16Array(1);
20
+ light = new Uint16Array(1);
21
+ level = new Uint8Array(1);
22
+ state = new Uint16Array(1);
23
+ mod = new Uint16Array(1);
24
+ secondary = new Uint16Array(1);
23
25
  loadIn() { }
24
- updateVoxel(mode) {
25
- }
26
+ updateVoxel(mode) { }
26
27
  }
@@ -20,8 +20,7 @@ export declare class VoxelLightData {
20
20
  mixLight(l1: number, l2: number): number;
21
21
  getRGB(sl: number): number;
22
22
  setRGB(value: number, sl: number): number;
23
- decodeLightFromVoxelData(voxelData: number): number;
24
- encodeLightIntoVoxelData(voxelData: number, encodedLight: number): number;
23
+ createLightValue(s: number, r: number, g: number, b: number): number;
25
24
  /**# Set Light Values
26
25
  * ---
27
26
  * Give an array of light values it will return an encoded light number.
@@ -37,8 +36,8 @@ export declare class VoxelLightData {
37
36
  * - 3: Blue Light
38
37
  * @param value
39
38
  */
40
- getLightValues(value: number): AllLight;
41
- getLightValuesToRef(value: number, values: AllLight): AllLight;
39
+ getLightValuesArray(value: number): AllLight;
40
+ getLightValuesArrayToRef(value: number, values: AllLight): AllLight;
42
41
  addLightValues(sl: number, sl2: number): number;
43
42
  divideLightValue(sl: number, divisor: number): number;
44
43
  }