@divinevoxel/vlox 0.0.80 → 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 (162) 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/Inputs/BuildTriangleInputs.js +3 -0
  107. package/Voxels/Indexes/VoxelIndex.js +3 -1
  108. package/Voxels/InitVoxelData.js +3 -1
  109. package/Voxels/Interaction/Functions/PickVoxel.js +3 -5
  110. package/Voxels/Interaction/Functions/PickVoxelWorld.js +4 -6
  111. package/Voxels/Models/Defaults/Examples.d.ts +2 -0
  112. package/Voxels/Models/Defaults/Examples.js +151 -2
  113. package/Voxels/State/Reltional/ReltionalStateBuilder.js +2 -0
  114. package/Voxels/State/Schema/BinarySchema.d.ts +1 -0
  115. package/Voxels/State/Schema/BinarySchema.js +14 -0
  116. package/Voxels/State/VoxelSchemas.d.ts +11 -4
  117. package/Voxels/State/VoxelSchemas.js +42 -9
  118. package/Voxels/Types/PaintVoxelData.js +6 -2
  119. package/World/Archive/Classes/ImportedSection.js +1 -1
  120. package/World/Archive/Classes/ImportedSector.js +0 -1
  121. package/World/Archive/Functions/Sector/ArchiveSector.js +2 -2
  122. package/World/Archive/Functions/Sector/ImportSector.d.ts +1 -0
  123. package/World/Archive/Functions/Sector/ImportSector.js +183 -7
  124. package/World/Cursor/SectorCursor.js +1 -4
  125. package/World/Cursor/WorldCursor.d.ts +12 -3
  126. package/World/Cursor/WorldCursor.js +60 -30
  127. package/World/InitTasks.js +1 -1
  128. package/World/Lock/Function/LockSectors.js +5 -1
  129. package/World/Lock/Function/UnLockSectors.js +5 -1
  130. package/World/SnapShot/SectionSnapShot.d.ts +7 -3
  131. package/World/SnapShot/SectionSnapShot.js +47 -21
  132. package/World/SnapShot/SectionSnapShotCursor.d.ts +4 -2
  133. package/World/SnapShot/SectionSnapShotCursor.js +23 -11
  134. package/World/SnapShot/SnapShots.d.ts +1 -2
  135. package/World/SnapShot/SnapShots.js +3 -3
  136. package/World/WorldSpaces.d.ts +7 -0
  137. package/World/WorldSpaces.js +35 -13
  138. package/WorldSimulation/Dimensions/DimensionSegment.d.ts +2 -0
  139. package/WorldSimulation/Dimensions/DimensionSegment.js +9 -1
  140. package/WorldSimulation/Dimensions/DimensionSimulation.js +6 -7
  141. package/WorldSimulation/Dimensions/Generator.d.ts +4 -0
  142. package/WorldSimulation/Dimensions/Generator.js +15 -1
  143. package/WorldSimulation/Dimensions/SimulationSector.d.ts +1 -0
  144. package/WorldSimulation/Dimensions/SimulationSector.js +18 -0
  145. package/WorldSimulation/Internal/WorldSimulationTasks.js +11 -7
  146. package/WorldSimulation/Procedures/InitalLoad.d.ts +1 -0
  147. package/WorldSimulation/Procedures/InitalLoad.js +18 -8
  148. package/WorldSimulation/Tasks/SimulationTaskBase.d.ts +4 -1
  149. package/WorldSimulation/Tasks/SimulationTaskBase.js +13 -2
  150. package/WorldSimulation/Tasks/TaskSegment.d.ts +4 -2
  151. package/WorldSimulation/Tasks/TaskSegment.js +36 -22
  152. package/WorldSimulation/Voxels/Ticks/Types/LiquidVoxelUpdate.js +1 -2
  153. package/WorldSimulation/WorldSimulation.d.ts +6 -3
  154. package/WorldSimulation/WorldSimulation.js +44 -20
  155. package/package.json +1 -1
  156. package/Mesher/Items/MeshTextureO.d.ts +0 -1
  157. package/Mesher/Items/MeshTextureO.js +0 -277
  158. package/Mesher/Voxels/Models/VoxelConstructor.d.ts +0 -8
  159. package/Mesher/Voxels/Models/VoxelConstructor.js +0 -78
  160. package/Mesher/Voxels/Models/VoxelModelConstructorRegister.js +0 -37
  161. package/WorldSimulation/Procedures/BuildOnly.d.ts +0 -10
  162. package/WorldSimulation/Procedures/BuildOnly.js +0 -55
@@ -1,8 +1,11 @@
1
1
  import { WorldSimulationDimensions } from "../Internal/WorldSimulationDimensions.js";
2
2
  export class SimulationTaskBase {
3
3
  data;
4
- constructor(data) {
4
+ parent;
5
+ _subTask = new Map();
6
+ constructor(data, parent) {
5
7
  this.data = data;
8
+ this.parent = parent;
6
9
  }
7
10
  getTotal(dimensionId) {
8
11
  const dimension = WorldSimulationDimensions.getDimension(dimensionId);
@@ -21,6 +24,9 @@ export class SimulationTaskBase {
21
24
  return;
22
25
  task.add(x, y, z);
23
26
  }
27
+ addSubTask(data) {
28
+ this._subTask.set(data.id, new SimulationTaskBase(data, this));
29
+ }
24
30
  runTask(max = 10) {
25
31
  for (const [key, dimension] of WorldSimulationDimensions._dimensions) {
26
32
  const task = dimension.getTask(this.data.id);
@@ -45,8 +51,13 @@ export class SimulationTaskBase {
45
51
  addBack.push(x, y, z);
46
52
  continue;
47
53
  }
48
- const taskId = task.addTask(x, y, z);
54
+ const taskId = task.addTask(x, y, z, this._subTask.size);
49
55
  this.data.run(dimension, location, taskId, task, sector);
56
+ if (this._subTask.size) {
57
+ for (const [, subTask] of this._subTask) {
58
+ subTask.data.run(dimension, location, taskId, task, sector);
59
+ }
60
+ }
50
61
  if (task.waitingFor > max)
51
62
  break;
52
63
  }
@@ -7,13 +7,15 @@ export declare class TaskSegment {
7
7
  _hash: Set<unknown>;
8
8
  nodes: LocationData[];
9
9
  waitingFor: number;
10
- clear(): void;
11
10
  _taskCount: number;
12
11
  _task: Map<number, LocationData>;
12
+ _subTask: Map<number, number>;
13
13
  constructor(dimension: DimensionSegment, generationTask: boolean, log?: boolean);
14
+ clearAll(): void;
14
15
  _getLocationData(dimension: number, x: number, y: number, z: number): LocationData;
15
16
  completeTask(id: number): boolean;
16
- addTask(x: number, y: number, z: number): number;
17
+ completeSubTask(id: number): false | undefined;
18
+ addTask(x: number, y: number, z: number, subTaskCount: number): number;
17
19
  has(x: number, y: number, z: number): boolean;
18
20
  add(x: number, y: number, z: number): false | undefined;
19
21
  sort(x: number, y: number, z: number): LocationData[];
@@ -1,5 +1,12 @@
1
+ import { Distance3D } from "@amodx/math";
1
2
  import { WorldSpaces } from "../../World/WorldSpaces";
2
3
  const pool = [];
4
+ const sortPosition = [0, 0, 0];
5
+ const sort = (a, b) => {
6
+ const ad = Distance3D(sortPosition[0], sortPosition[1], sortPosition[2], a[1], a[2], a[3]);
7
+ const bd = Distance3D(sortPosition[0], sortPosition[1], sortPosition[2], b[1], b[2], b[3]);
8
+ return bd - ad;
9
+ };
3
10
  export class TaskSegment {
4
11
  dimension;
5
12
  generationTask;
@@ -7,16 +14,20 @@ export class TaskSegment {
7
14
  _hash = new Set();
8
15
  nodes = [];
9
16
  waitingFor = 0;
10
- clear() { }
11
17
  _taskCount = 0;
12
18
  _task = new Map();
19
+ _subTask = new Map();
13
20
  constructor(dimension, generationTask, log = false) {
14
21
  this.dimension = dimension;
15
22
  this.generationTask = generationTask;
16
23
  this.log = log;
17
24
  }
25
+ clearAll() {
26
+ this.nodes = [];
27
+ this._task.clear();
28
+ }
18
29
  _getLocationData(dimension, x, y, z) {
19
- const location = pool.length ? pool.shift() : [0, 0, 0, 0];
30
+ const location = pool.length ? pool.pop() : [0, 0, 0, 0];
20
31
  location[0] = dimension;
21
32
  location[1] = x;
22
33
  location[2] = y;
@@ -24,6 +35,9 @@ export class TaskSegment {
24
35
  return location;
25
36
  }
26
37
  completeTask(id) {
38
+ const subTaskCount = this._subTask.get(id);
39
+ if (subTaskCount !== undefined && subTaskCount > 0)
40
+ return false;
27
41
  const locationData = this._task.get(id);
28
42
  if (!locationData)
29
43
  return false;
@@ -33,9 +47,23 @@ export class TaskSegment {
33
47
  this.waitingFor--;
34
48
  return true;
35
49
  }
36
- addTask(x, y, z) {
50
+ completeSubTask(id) {
51
+ const subTaskCount = this._subTask.get(id);
52
+ if (subTaskCount === undefined)
53
+ return false;
54
+ const newSubTaskCount = subTaskCount - 1;
55
+ if (newSubTaskCount <= 0) {
56
+ this._subTask.set(id, 0);
57
+ this.completeTask(id);
58
+ }
59
+ else {
60
+ this._subTask.set(id, newSubTaskCount);
61
+ }
62
+ }
63
+ addTask(x, y, z, subTaskCount) {
37
64
  const id = this._taskCount;
38
65
  this._task.set(id, this._getLocationData(this.dimension.id, x, y, z));
66
+ this._subTask.set(id, subTaskCount);
39
67
  this._taskCount++;
40
68
  this.waitingFor++;
41
69
  return id;
@@ -53,29 +81,15 @@ export class TaskSegment {
53
81
  }
54
82
  sort(x, y, z) {
55
83
  const sections = this.nodes;
56
- const sx = x, sy = y, sz = z;
57
- let i = sections.length, j, temp, ax, ay, az, bx, by, bz, distA, distB;
58
- while (i > 1) {
59
- for (j = 1; j < i; j++) {
60
- (ax = sections[j - 1][1]),
61
- (ay = sections[j - 1][2]),
62
- (az = sections[j - 1][3]);
63
- (bx = sections[j][1]), (by = sections[j][2]), (bz = sections[j][3]);
64
- distA = (ax - sx) ** 2 + (ay - sy) ** 2 + (az - sz) ** 2;
65
- distB = (bx - sx) ** 2 + (by - sy) ** 2 + (bz - sz) ** 2;
66
- if (distA > distB) {
67
- temp = sections[j - 1];
68
- sections[j - 1] = sections[j];
69
- sections[j] = temp;
70
- }
71
- }
72
- i--;
73
- }
84
+ sortPosition[0] = x;
85
+ sortPosition[1] = y;
86
+ sortPosition[2] = z;
87
+ this.nodes.sort(sort);
74
88
  return sections;
75
89
  }
76
90
  *run() {
77
91
  while (this.nodes.length) {
78
- const vec = this.nodes.shift();
92
+ const vec = this.nodes.pop();
79
93
  const key = WorldSpaces.hash.hashXYZ(vec[1], vec[2], vec[3]);
80
94
  this._hash.delete(key);
81
95
  yield vec;
@@ -1,6 +1,5 @@
1
1
  import { VoxelTickUpdateRegister } from "../VoxelTickUpdateRegister";
2
2
  import { CardinalNeighbors3D } from "../../../../Math/CardinalNeighbors";
3
- import { VoxelFaces } from "../../../../Math";
4
3
  const floodOutChecks = [
5
4
  [1, 0, 0],
6
5
  [-1, 0, 0],
@@ -127,7 +126,7 @@ VoxelTickUpdateRegister.registerType({
127
126
  simulation.bounds.updateDisplay(x, y, z);
128
127
  }
129
128
  const downVoxel = simulation.nDataCursor.getVoxel(x, y - 1, z);
130
- const below = simulation.tickCursor[VoxelFaces.Down].getVoxel(x, y - 2, z);
129
+ const below = simulation.tickCursor[1 /* VoxelFaces.Down */].getVoxel(x, y - 2, z);
131
130
  const isSame = downVoxel && downVoxel.isSameVoxel(voxel);
132
131
  if (downVoxel && (downVoxel.isAir() || isSame)) {
133
132
  let addToTick = false;
@@ -1,8 +1,9 @@
1
1
  import { Thread, ThreadPool } from "@amodx/threads";
2
2
  import { WorldStorageInterface } from "../World/Types/WorldStorage.interface";
3
3
  import { Generator, GeneratorData } from "./Dimensions/Generator";
4
+ import { WorldSimulationTasks } from "./Internal/WorldSimulationTasks";
5
+ import { WorldSimulationTools } from "./Internal/WorldSimulationTools";
4
6
  import { InitalLoad } from "./Procedures/InitalLoad";
5
- import { BuildOnly } from "./Procedures/BuildOnly";
6
7
  import SaveAllSectors from "./Procedures/SaveAllSectors";
7
8
  interface WorldSimulationInitData {
8
9
  parent: Thread;
@@ -16,11 +17,12 @@ interface WorldSimulationInitData {
16
17
  export declare class WorldSimulation {
17
18
  private static _cullGenerators;
18
19
  static readonly _generators: Generator[];
20
+ static Tools: typeof WorldSimulationTools;
21
+ static Tasks: typeof WorldSimulationTasks;
19
22
  static addDimension(id: number): void;
20
23
  static Procedures: {
21
24
  InitalLoad: typeof InitalLoad;
22
25
  SaveAllSectors: typeof SaveAllSectors;
23
- BuildOnly: typeof BuildOnly;
24
26
  };
25
27
  static logTasks(): {
26
28
  loading: number[];
@@ -36,6 +38,7 @@ export declare class WorldSimulation {
36
38
  static getDimension(id: number): import("./Dimensions/DimensionSegment").DimensionSegment;
37
39
  static removeGenerator(generator: Generator): boolean;
38
40
  static doTickUpdates: boolean;
39
- static tick(generationOnly?: boolean): void;
41
+ static clearAll(): void;
42
+ static tick(generationOnly?: boolean, buildOnly?: boolean): void;
40
43
  }
41
44
  export {};
@@ -1,3 +1,4 @@
1
+ import { Thread } from "@amodx/threads";
1
2
  import { TaskTool } from "../Tools/Tasks/TasksTool";
2
3
  import { Generator } from "./Dimensions/Generator";
3
4
  import { WorldSimulationTasks } from "./Internal/WorldSimulationTasks";
@@ -5,9 +6,9 @@ import { WorldSimulationTools } from "./Internal/WorldSimulationTools";
5
6
  import { WorldSimulationDimensions } from "./Internal/WorldSimulationDimensions";
6
7
  import { Vector3Like } from "@amodx/math";
7
8
  import { InitalLoad } from "./Procedures/InitalLoad";
8
- import { BuildOnly } from "./Procedures/BuildOnly";
9
9
  import SaveAllSectors from "./Procedures/SaveAllSectors";
10
10
  import { runActiveSectorUpdate } from "./Internal/runActiveSectorUpdate";
11
+ import { WorldRegister } from "../World/WorldRegister";
11
12
  let initalized = false;
12
13
  /**# Infinite World Generation IWG
13
14
  * Object to handle the loading and generating the world around a created generator.
@@ -15,13 +16,14 @@ let initalized = false;
15
16
  export class WorldSimulation {
16
17
  static _cullGenerators = [];
17
18
  static _generators = [];
19
+ static Tools = WorldSimulationTools;
20
+ static Tasks = WorldSimulationTasks;
18
21
  static addDimension(id) {
19
22
  WorldSimulationDimensions.addDimension(id);
20
23
  }
21
24
  static Procedures = {
22
25
  InitalLoad,
23
26
  SaveAllSectors,
24
- BuildOnly,
25
27
  };
26
28
  static logTasks() {
27
29
  return {
@@ -89,14 +91,40 @@ export class WorldSimulation {
89
91
  return false;
90
92
  }
91
93
  static doTickUpdates = true;
92
- static tick(generationOnly = false) {
94
+ static clearAll() {
95
+ for (const [, dimension] of WorldSimulationDimensions._dimensions) {
96
+ dimension.clearAll();
97
+ }
98
+ WorldSimulationTools.parent.runTask("clear-all", []);
99
+ const meshers = WorldSimulationTools.taskTool.meshers;
100
+ if (meshers instanceof Thread) {
101
+ meshers.runTask("clear-all", []);
102
+ }
103
+ else {
104
+ meshers.runTaskForAll("clear-all", []);
105
+ }
106
+ const generators = WorldSimulationTools.taskTool.generators;
107
+ if (generators instanceof Thread) {
108
+ generators.runTask("clear-all", []);
109
+ }
110
+ else {
111
+ generators.runTaskForAll("clear-all", []);
112
+ }
113
+ WorldRegister.clearAll();
114
+ }
115
+ static tick(generationOnly = false, buildOnly = false) {
93
116
  let total = 0;
94
117
  for (const [, dimension] of WorldSimulationDimensions._dimensions) {
95
118
  dimension.incrementTick();
96
119
  for (let i = 0; i < dimension.activeSectors._sectors.length; i++) {
97
120
  total += dimension.activeSectors._sectors[i].tickQueue.getTotalTicks();
121
+ if (buildOnly) {
122
+ dimension.activeSectors._sectors[i].updateGenAllDone();
123
+ }
98
124
  dimension.activeSectors._sectors[i].tickUpdate(this.doTickUpdates);
99
- dimension.activeSectors._sectors[i].generateUpdate();
125
+ if (!buildOnly) {
126
+ dimension.activeSectors._sectors[i].generateUpdate();
127
+ }
100
128
  }
101
129
  }
102
130
  let needActiveSectorUpdate = false;
@@ -111,24 +139,20 @@ export class WorldSimulation {
111
139
  if (needActiveSectorUpdate) {
112
140
  runActiveSectorUpdate();
113
141
  }
114
- WorldSimulationTasks.worldLoadTasks.runTask();
115
- WorldSimulationTasks.worldGenTasks.runTask();
116
- WorldSimulationTasks.worldDecorateTasks.runTask();
117
- WorldSimulationTasks.worldSunTasks.runTask();
118
- WorldSimulationTasks.worldPropagationTasks.runTask();
119
- /* console.log(
120
- "total ticks",
121
- total,
122
- "building",
123
- "building",
124
- WorldSimulationTasks.buildTasks.getTotalWaitingFor(0),
125
- WorldSimulationTasks.buildTasks.getTotal(0)
126
- ); */
142
+ if (!buildOnly) {
143
+ WorldSimulationTasks.worldLoadTasks.runTask();
144
+ WorldSimulationTasks.worldGenTasks.runTask();
145
+ WorldSimulationTasks.worldDecorateTasks.runTask();
146
+ WorldSimulationTasks.worldSunTasks.runTask();
147
+ WorldSimulationTasks.worldPropagationTasks.runTask();
148
+ }
127
149
  if (generationOnly)
128
150
  return;
129
- WorldSimulationTasks.buildTasks.runTask(32);
130
- WorldSimulationTasks.saveTasks.runTask(50);
131
- WorldSimulationTasks.unloadTasks.runTask(50);
151
+ WorldSimulationTasks.buildTasks.runTask(64);
152
+ if (!buildOnly) {
153
+ WorldSimulationTasks.saveTasks.runTask(50);
154
+ WorldSimulationTasks.unloadTasks.runTask(50);
155
+ }
132
156
  WorldSimulationTasks.unbuildTasks.runTask();
133
157
  }
134
158
  }
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@divinevoxel/vlox","version":"0.0.80","description":"Vlox a block style voxel engine.","main":"index.js","types":"index.d.ts","type":"module","devDependencies":{},"scripts":{"clean:dist-ts":"test -d dist && find dist -type f \\( -name \"*.js\" -o -name \"*.d.ts\" \\) -delete || true","build":"mkdir -p dist && npm run clean:dist-ts && cp package.json dist/package.json && cd ./src && npx tsc","prepare-publish":"mkdir -p dist && rm -rf dist/* && cp package.json dist/package.json && cp README.md ./dist/README.md && cp ./LICENSE.md ./dist/LICENSE.md && cd ./src && npx tsc","compile":"cd src && npx tsc --watch","compile:fresh":"npm run clean:dist-ts && cd src && npx tsc --watch"},"keywords":[],"author":"Divine Star Software","license":"MIT","repository":{"url":"git+https://github.com/Divine-Star-Software/DivineVoxelEngine.git"},"bugs":{"url":"https://github.com/Divine-Star-Software/DivineVoxelEngine/issues"},"dependencies":{"@amodx/math":"latest","@amodx/binary":"latest","@amodx/threads":"latest"},"publishConfig":{"access":"public"}}
1
+ {"name":"@divinevoxel/vlox","version":"0.0.81","description":"Vlox a block style voxel engine.","main":"index.js","types":"index.d.ts","type":"module","devDependencies":{},"scripts":{"clean:dist-ts":"test -d dist && find dist -type f \\( -name \"*.js\" -o -name \"*.d.ts\" \\) -delete || true","build":"mkdir -p dist && npm run clean:dist-ts && cp package.json dist/package.json && cd ./src && npx tsc","prepare-publish":"mkdir -p dist && rm -rf dist/* && cp package.json dist/package.json && cp README.md ./dist/README.md && cp ./LICENSE.md ./dist/LICENSE.md && cd ./src && npx tsc","compile":"cd src && npx tsc --watch","compile:fresh":"npm run clean:dist-ts && cd src && npx tsc --watch"},"keywords":[],"author":"Divine Star Software","license":"MIT","repository":{"url":"git+https://github.com/Divine-Star-Software/DivineVoxelEngine.git"},"bugs":{"url":"https://github.com/Divine-Star-Software/DivineVoxelEngine/issues"},"dependencies":{"@amodx/math":"latest","@amodx/binary":"latest","@amodx/threads":"latest"},"publishConfig":{"access":"public"}}
@@ -1 +0,0 @@
1
- export declare function MeshTexture(textureId: number, textureData: number[]): void;
@@ -1,277 +0,0 @@
1
- import { Quad } from "../Geometry/Primitives/Quad";
2
- const Quads = {
3
- north: Quad.Create([
4
- [1, 1, 0],
5
- [0, 1, 0],
6
- [0, 0, 0],
7
- [1, 0, 0],
8
- ], Quad.FullUVs),
9
- south: Quad.Create([
10
- [1, 1, 0],
11
- [0, 1, 0],
12
- [0, 0, 0],
13
- [1, 0, 0],
14
- ], Quad.FullUVs),
15
- };
16
- //const tool = new MesherDataTool();
17
- //tool.startNewMesh();
18
- //tool.mesh!.attributes.set("uv", [[], 2, BinaryNumberTypes.Float32]);
19
- //tool.mesh!.attributes.set("textureIndex", [[], 3, BinaryNumberTypes.Float32]);
20
- export function MeshTexture(textureId, textureData) {
21
- /* const width = Math.sqrt(textureData.length / 4);
22
- const height = Math.sqrt(textureData.length / 4);
23
- const factor = 1 / width;
24
-
25
- const textureDataIndex = Flat2DIndex.GetXYOrder();
26
- textureDataIndex.setBounds(width, height);
27
-
28
- const origin = Vector3Like.Create(-0.5, -0.5, -0.5);
29
-
30
- const isSolid = (x: number, y: number) =>
31
- x >= 0 &&
32
- x < width &&
33
- y >= 0 &&
34
- y < height &&
35
- textureData[textureDataIndex.getIndexXY(x, y) * 4 + 3] > 0.01
36
- ? true
37
- : false;
38
-
39
- const uvs = tool.mesh!.getAttribute("uv");
40
- const textureIndex = tool.mesh!.getAttribute("textureIndex");
41
- const uvOffset = width > 16 ? -(2 / Math.max(width, height)) : 0;
42
-
43
- const addUvs = (sx: number, sy: number, ex: number, ey: number) => {
44
- uvs.push(
45
- (ex + uvOffset) * factor,
46
- (ey + uvOffset) * factor,
47
- (sx - uvOffset) * factor,
48
- (ey + uvOffset) * factor,
49
- (sx - uvOffset) * factor,
50
- (sy - uvOffset) * factor,
51
- (ex + uvOffset) * factor,
52
- (sy - uvOffset) * factor
53
- );
54
- textureIndex.push(
55
- textureId,
56
- 0,
57
- 0,
58
- textureId,
59
- 0,
60
- 0,
61
- textureId,
62
- 0,
63
- 0,
64
- textureId,
65
- 0,
66
- 0
67
- );
68
- };
69
-
70
- {
71
- GeometryBuilder.addQuad(tool, origin, Quads.south);
72
- uvs.push(
73
- Quads.south.uvs.vertices[QuadVerticies.TopRight].x,
74
- Quads.south.uvs.vertices[QuadVerticies.TopRight].y,
75
- Quads.south.uvs.vertices[QuadVerticies.TopLeft].x,
76
- Quads.south.uvs.vertices[QuadVerticies.TopLeft].y,
77
- Quads.south.uvs.vertices[QuadVerticies.BottomLeft].x,
78
- Quads.south.uvs.vertices[QuadVerticies.BottomLeft].y,
79
- Quads.south.uvs.vertices[QuadVerticies.BottomRight].x,
80
- Quads.south.uvs.vertices[QuadVerticies.BottomRight].y
81
- );
82
-
83
- textureIndex.push(
84
- textureId,
85
- 0,
86
- 0,
87
- textureId,
88
- 0,
89
- 0,
90
- textureId,
91
- 0,
92
- 0,
93
- textureId,
94
- 0,
95
- 0
96
- );
97
- }
98
-
99
- {
100
- const backPositionZ = factor;
101
- Quads.north.positions.vertices[QuadVerticies.TopRight].z = backPositionZ;
102
- Quads.north.positions.vertices[QuadVerticies.TopLeft].z = backPositionZ;
103
- Quads.north.positions.vertices[QuadVerticies.BottomLeft].z = backPositionZ;
104
- Quads.north.positions.vertices[QuadVerticies.BottomRight].z = backPositionZ;
105
- Quads.north.flip = true;
106
- uvs.push(
107
- Quads.north.uvs.vertices[QuadVerticies.TopLeft].x,
108
- Quads.north.uvs.vertices[QuadVerticies.TopLeft].y,
109
- Quads.north.uvs.vertices[QuadVerticies.TopRight].x,
110
- Quads.north.uvs.vertices[QuadVerticies.TopRight].y,
111
- Quads.north.uvs.vertices[QuadVerticies.BottomRight].x,
112
- Quads.north.uvs.vertices[QuadVerticies.BottomRight].y,
113
- Quads.north.uvs.vertices[QuadVerticies.BottomLeft].x,
114
- Quads.north.uvs.vertices[QuadVerticies.BottomLeft].y
115
- );
116
- GeometryBuilder.addQuad(tool, origin, Quads.north);
117
- textureIndex.push(
118
- textureId,
119
- 0,
120
- 0,
121
- textureId,
122
- 0,
123
- 0,
124
- textureId,
125
- 0,
126
- 0,
127
- textureId,
128
- 0,
129
- 0
130
- );
131
- }
132
-
133
- for (let x = 0; x < width; x++) {
134
- let eastFace: Vec2Array | null = null;
135
- let westFace: Vec2Array | null = null;
136
- for (let y = 0; y < height; y++) {
137
- let eastFaceExposed = true;
138
- let westFaceExposed = true;
139
-
140
- if (!isSolid(x, y)) {
141
- eastFaceExposed = false;
142
- westFaceExposed = false;
143
- }
144
- if (isSolid(x + 1, y)) {
145
- eastFaceExposed = false;
146
- }
147
- if (isSolid(x - 1, y)) {
148
- westFaceExposed = false;
149
- }
150
-
151
- if (eastFace && !eastFaceExposed) {
152
- const newQuad = Quad.Create(
153
- [
154
- [x * factor + factor, eastFace[1] * factor, 0],
155
- [x * factor + factor, y * factor, factor],
156
- ],
157
- Quad.FullUVs as any,
158
- false,
159
- 0
160
- );
161
- GeometryBuilder.addQuad(tool, origin, newQuad);
162
-
163
- let [sx, sy] = eastFace;
164
- let ex = x;
165
- let ey = y;
166
- ex += 1;
167
- addUvs(sx, sy, ex, ey);
168
- eastFace = null;
169
- }
170
-
171
- if (westFace && !westFaceExposed) {
172
- const newQuad = Quad.Create(
173
- [
174
- [x * factor, westFace[1] * factor, 0],
175
- [x * factor, y * factor, factor],
176
- ],
177
- Quad.FullUVs as any,
178
- false,
179
- 1
180
- );
181
- GeometryBuilder.addQuad(tool, origin, newQuad);
182
- let [sx, sy] = westFace;
183
- let ex = x;
184
- let ey = y;
185
- ex += 1;
186
- addUvs(sx, sy, ex, ey);
187
- westFace = null;
188
- }
189
- const isPixel = isSolid(x, y);
190
- if (!isSolid(x + 1, y) && !eastFace && isPixel) {
191
- eastFace = [x, y];
192
- }
193
- if (!isSolid(x - 1, y) && !westFace && isPixel) {
194
- westFace = [x, y];
195
- }
196
- }
197
- }
198
- for (let y = 0; y < height; y++) {
199
- let upFace: Vec2Array | null = null;
200
- let downFace: Vec2Array | null = null;
201
-
202
- for (let x = 0; x < width; x++) {
203
- let upFaceExposed = true;
204
- let downFaceExposed = true;
205
-
206
- if (!isSolid(x, y)) {
207
- upFaceExposed = false;
208
- downFaceExposed = false;
209
- }
210
- if (isSolid(x, y + 1)) {
211
- upFaceExposed = false;
212
- }
213
- if (isSolid(x, y - 1)) {
214
- downFaceExposed = false;
215
- }
216
-
217
- if (upFace && !upFaceExposed) {
218
- const newQuad = Quad.Create(
219
- [
220
- [upFace[0] * factor, y * factor + factor, 0],
221
- [x * factor, y * factor + factor, factor],
222
- ],
223
- Quad.FullUVs as any,
224
- false,
225
- 0
226
- );
227
- GeometryBuilder.addQuad(tool, origin, newQuad);
228
- let [sx, sy] = upFace;
229
- let [ex, ey] = [x, y];
230
-
231
- ey += 1;
232
- addUvs(sx, sy, ex, ey);
233
- upFace = null;
234
- }
235
-
236
- if (downFace && !downFaceExposed) {
237
- const newQuad = Quad.Create(
238
- [
239
- [downFace[0] * factor, y * factor, 0],
240
- [x * factor, y * factor, factor],
241
- ],
242
- Quad.FullUVs as any,
243
- false,
244
- 1
245
- );
246
- GeometryBuilder.addQuad(tool, origin, newQuad);
247
- let [sx, sy] = downFace;
248
- let [ex, ey] = [x, y];
249
- ey += 1;
250
- addUvs(sx, sy, ex, ey);
251
- downFace = null;
252
- }
253
-
254
- const isPixel = isSolid(x, y);
255
- if (!isSolid(x, y + 1) && !upFace && isPixel) {
256
- upFace = [x, y];
257
- }
258
- if (!isSolid(x, y - 1) && !downFace && isPixel) {
259
- downFace = [x, y];
260
- }
261
- }
262
- }
263
-
264
- for (const [key, [data]] of tool.mesh!.attributes) {
265
- if (key == "position") {
266
- for (let i = 0; i < data.length; i += 3) {
267
- (data as any as number[])[i] -= 0.5;
268
- (data as any as number[])[i + 1] -= 0.5;
269
- (data as any as number[])[i + 2];
270
- }
271
- }
272
- }
273
-
274
- const compacted = CompactMesh("dve_item", tool);
275
- */
276
- // return tool.mesh;
277
- }
@@ -1,8 +0,0 @@
1
- import { VoxelModelBuilder } from "./VoxelModelBuilder";
2
- export declare class VoxelConstructor {
3
- id: string;
4
- builder: VoxelModelBuilder;
5
- isModel: true;
6
- constructor(id: string, builder: VoxelModelBuilder);
7
- process(): boolean;
8
- }