@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,9 +1,9 @@
1
1
  import { VoxelBuildSpace } from "../../VoxelBuildSpace";
2
2
  import { VoxelShapeTemplate } from "../../../Templates/Shapes/VoxelShapeTemplate";
3
- import { VoxelPickResult } from "../../../Voxels/Interaction/VoxelPickResult";
4
3
  import { Vector3Like } from "@amodx/math";
5
4
  import { PaintVoxelData } from "../../../Voxels";
6
5
  import { BuilderToolBase, ToolOptionsData } from "../BuilderToolBase";
6
+ import { FreePointSelection } from "../../Util/FreePointSelection";
7
7
  export declare enum BrushPositionModes {
8
8
  Start = "Start",
9
9
  Center = "Center",
@@ -14,6 +14,10 @@ export declare enum BrushToolModes {
14
14
  Extrude = "Extrude",
15
15
  Remove = "Remove"
16
16
  }
17
+ export declare enum BrushToolSelectionPositionModes {
18
+ Surface = "Surface",
19
+ Free = "Free"
20
+ }
17
21
  type BrushVoxelData = {
18
22
  fill: PaintVoxelData;
19
23
  face: PaintVoxelData;
@@ -26,6 +30,7 @@ interface BrushToolEvents {
26
30
  export declare class BrushTool extends BuilderToolBase<BrushToolEvents> {
27
31
  static ToolId: string;
28
32
  static ModeArray: BrushToolModes[];
33
+ static PositionTypeModeArray: BrushToolSelectionPositionModes[];
29
34
  static PositionModeArray: BrushPositionModes[];
30
35
  static get ShapesArray(): string[];
31
36
  static ShapeCreators: Record<string, () => VoxelShapeTemplate>;
@@ -36,6 +41,11 @@ export declare class BrushTool extends BuilderToolBase<BrushToolEvents> {
36
41
  axisYPositionMode: BrushPositionModes;
37
42
  axisZPositionMode: BrushPositionModes;
38
43
  mode: BrushToolModes;
44
+ positionMode: BrushToolSelectionPositionModes;
45
+ private pointSelection;
46
+ freeSelection: FreePointSelection;
47
+ get distance(): number;
48
+ set distance(distance: number);
39
49
  template: VoxelShapeTemplate;
40
50
  get selection(): import("../../../Templates/Shapes/Selections/VoxelShapeSelection").IVoxelShapeSelection<any, import("../../../Templates/Shapes/Selections/VoxelShapeSelection").IVoxelShapeSelectionData<any>>;
41
51
  voxelData: Partial<BrushVoxelData>;
@@ -46,7 +56,7 @@ export declare class BrushTool extends BuilderToolBase<BrushToolEvents> {
46
56
  update(): Promise<void>;
47
57
  cancel(): void;
48
58
  use(): Promise<void>;
49
- protected getPlacePosition(picked: VoxelPickResult): Vector3Like;
59
+ protected getPlacePosition(position: Vector3Like): Vector3Like;
50
60
  updateShape(shape: string): void;
51
61
  getOptionValue(property: string): any;
52
62
  getCurrentOptions(): ToolOptionsData;
@@ -5,6 +5,8 @@ import { PyramidVoxelShapeSelection } from "../../../Templates/Shapes/Selections
5
5
  import { EllipsoidVoxelShapeSelection } from "../../../Templates/Shapes/Selections/EllipsoidVoxelShapeSelection";
6
6
  import { Vector3Like } from "@amodx/math";
7
7
  import { BuilderToolBase } from "../BuilderToolBase";
8
+ import { FreePointSelection } from "../../Util/FreePointSelection";
9
+ import { VoxelPointSelection } from "../../../Templates/Selection/VoxelPointSelection";
8
10
  export var BrushPositionModes;
9
11
  (function (BrushPositionModes) {
10
12
  BrushPositionModes["Start"] = "Start";
@@ -17,6 +19,11 @@ export var BrushToolModes;
17
19
  BrushToolModes["Extrude"] = "Extrude";
18
20
  BrushToolModes["Remove"] = "Remove";
19
21
  })(BrushToolModes || (BrushToolModes = {}));
22
+ export var BrushToolSelectionPositionModes;
23
+ (function (BrushToolSelectionPositionModes) {
24
+ BrushToolSelectionPositionModes["Surface"] = "Surface";
25
+ BrushToolSelectionPositionModes["Free"] = "Free";
26
+ })(BrushToolSelectionPositionModes || (BrushToolSelectionPositionModes = {}));
20
27
  export class BrushTool extends BuilderToolBase {
21
28
  static ToolId = "Brush";
22
29
  static ModeArray = [
@@ -24,6 +31,10 @@ export class BrushTool extends BuilderToolBase {
24
31
  BrushToolModes.Extrude,
25
32
  BrushToolModes.Remove,
26
33
  ];
34
+ static PositionTypeModeArray = [
35
+ BrushToolSelectionPositionModes.Surface,
36
+ BrushToolSelectionPositionModes.Free,
37
+ ];
27
38
  static PositionModeArray = [
28
39
  BrushPositionModes.Start,
29
40
  BrushPositionModes.Center,
@@ -198,6 +209,15 @@ export class BrushTool extends BuilderToolBase {
198
209
  axisYPositionMode = BrushPositionModes.Center;
199
210
  axisZPositionMode = BrushPositionModes.Center;
200
211
  mode = BrushToolModes.Fill;
212
+ positionMode = BrushToolSelectionPositionModes.Surface;
213
+ pointSelection = new VoxelPointSelection();
214
+ freeSelection = new FreePointSelection(this.space, this.pointSelection);
215
+ get distance() {
216
+ return this.freeSelection.distance;
217
+ }
218
+ set distance(distance) {
219
+ this.freeSelection.distance = distance;
220
+ }
201
221
  template;
202
222
  get selection() {
203
223
  return this.template.shapeSelection;
@@ -211,23 +231,32 @@ export class BrushTool extends BuilderToolBase {
211
231
  this.updateShape(this.shape);
212
232
  }
213
233
  async update() {
214
- this._lastPicked = await this.space.pickWithProvider(this.rayProviderIndex);
215
- if (!this._lastPicked)
216
- return;
217
- if (this.mode == BrushToolModes.Fill ||
218
- this.mode == BrushToolModes.Extrude) {
219
- if (!this.space.bounds.intersectsPoint(this._lastPicked.normalPosition)) {
220
- this._lastPicked = null;
234
+ let place = null;
235
+ if (this.positionMode == BrushToolSelectionPositionModes.Surface) {
236
+ this._lastPicked = await this.space.pickWithProvider(this.rayProviderIndex);
237
+ if (!this._lastPicked)
221
238
  return;
239
+ if (this.mode == BrushToolModes.Fill ||
240
+ this.mode == BrushToolModes.Extrude) {
241
+ if (!this.space.bounds.intersectsPoint(this._lastPicked.normalPosition)) {
242
+ this._lastPicked = null;
243
+ return;
244
+ }
222
245
  }
223
- }
224
- if (this.mode == BrushToolModes.Remove) {
225
- if (!this.space.bounds.intersectsPoint(this._lastPicked.position)) {
226
- this._lastPicked = null;
227
- return;
246
+ if (this.mode == BrushToolModes.Remove) {
247
+ if (!this.space.bounds.intersectsPoint(this._lastPicked.position)) {
248
+ this._lastPicked = null;
249
+ return;
250
+ }
228
251
  }
252
+ place = this.getPlacePosition(this._lastPicked.normalPosition);
229
253
  }
230
- const place = this.getPlacePosition(this._lastPicked);
254
+ if (this.positionMode == BrushToolSelectionPositionModes.Free) {
255
+ this.freeSelection.update();
256
+ place = this.getPlacePosition(this.pointSelection.origin);
257
+ }
258
+ if (!place)
259
+ return;
231
260
  this.placePosition.x = place.x;
232
261
  this.placePosition.y = place.y;
233
262
  this.placePosition.z = place.z;
@@ -248,9 +277,9 @@ export class BrushTool extends BuilderToolBase {
248
277
  this.voxelData.fill = newData;
249
278
  }
250
279
  }
280
+ const place = this.placePosition;
251
281
  if (this.mode == BrushToolModes.Fill && this.voxelData.fill) {
252
282
  this.template.setVoxels(this.voxelData.fill);
253
- const place = this.getPlacePosition(this._lastPicked);
254
283
  await this.space.paintTemplate([place.x, place.y, place.z], this.template.toJSON());
255
284
  return;
256
285
  }
@@ -262,51 +291,47 @@ export class BrushTool extends BuilderToolBase {
262
291
  if (this.mode == BrushToolModes.Remove) {
263
292
  const voxel = this._lastPicked.voxel;
264
293
  if (voxel && !voxel.isAir()) {
265
- const place = this.getPlacePosition(this._lastPicked);
266
294
  await this.space.eraseTemplate([place.x, place.y, place.z], this.template.toJSON());
267
295
  }
268
296
  return;
269
297
  }
270
298
  }
271
- getPlacePosition(picked) {
299
+ getPlacePosition(position) {
272
300
  //x
273
301
  if (this.axisXPositionMode == BrushPositionModes.Center) {
274
302
  this._position.x =
275
- picked.normalPosition.x -
276
- Math.floor(this.template.shapeSelection.bounds.size.x / 2);
303
+ position.x - Math.floor(this.template.shapeSelection.bounds.size.x / 2);
277
304
  }
278
305
  if (this.axisXPositionMode == BrushPositionModes.Start) {
279
- this._position.x = picked.normalPosition.x;
306
+ this._position.x = position.x;
280
307
  }
281
308
  if (this.axisXPositionMode == BrushPositionModes.End) {
282
309
  this._position.x =
283
- picked.normalPosition.x - this.template.shapeSelection.bounds.size.x;
310
+ position.x - this.template.shapeSelection.bounds.size.x;
284
311
  }
285
312
  //y
286
313
  if (this.axisYPositionMode == BrushPositionModes.Center) {
287
314
  this._position.y =
288
- picked.normalPosition.y -
289
- Math.floor(this.template.shapeSelection.bounds.size.y / 2);
315
+ position.y - Math.floor(this.template.shapeSelection.bounds.size.y / 2);
290
316
  }
291
317
  if (this.axisYPositionMode == BrushPositionModes.Start) {
292
- this._position.y = picked.normalPosition.y;
318
+ this._position.y = position.y;
293
319
  }
294
320
  if (this.axisYPositionMode == BrushPositionModes.End) {
295
321
  this._position.y =
296
- picked.normalPosition.y - this.template.shapeSelection.bounds.size.y;
322
+ position.y - this.template.shapeSelection.bounds.size.y;
297
323
  }
298
324
  //z
299
325
  if (this.axisZPositionMode == BrushPositionModes.Center) {
300
326
  this._position.z =
301
- picked.normalPosition.z -
302
- Math.floor(this.template.shapeSelection.bounds.size.z / 2);
327
+ position.z - Math.floor(this.template.shapeSelection.bounds.size.z / 2);
303
328
  }
304
329
  if (this.axisZPositionMode == BrushPositionModes.Start) {
305
- this._position.z = picked.normalPosition.z;
330
+ this._position.z = position.z;
306
331
  }
307
332
  if (this.axisXPositionMode == BrushPositionModes.End) {
308
333
  this._position.z =
309
- picked.normalPosition.z - this.template.shapeSelection.bounds.size.z;
334
+ position.z - this.template.shapeSelection.bounds.size.z;
310
335
  }
311
336
  return this._position;
312
337
  }
@@ -0,0 +1,18 @@
1
+ import { PaintVoxelData } from "../../../Voxels";
2
+ import { VoxelPointSelection } from "../../../Templates/Selection/VoxelPointSelection";
3
+ import { BuilderToolBase, ToolOptionsData } from "../BuilderToolBase";
4
+ interface HandToolEvents {
5
+ }
6
+ export declare class DebugTool extends BuilderToolBase<HandToolEvents> {
7
+ static ToolId: string;
8
+ selection: VoxelPointSelection;
9
+ voxelData: PaintVoxelData;
10
+ usePlacingStrategy: boolean;
11
+ update(): Promise<void>;
12
+ cancel(): void;
13
+ use(): Promise<void>;
14
+ getOptionValue(id: string): null;
15
+ getCurrentOptions(): ToolOptionsData;
16
+ updateOption(property: string, value: any): void;
17
+ }
18
+ export {};
@@ -0,0 +1,36 @@
1
+ import { VoxelPointSelection } from "../../../Templates/Selection/VoxelPointSelection";
2
+ import { BuilderToolBase } from "../BuilderToolBase";
3
+ export class DebugTool extends BuilderToolBase {
4
+ static ToolId = "Debug";
5
+ selection = new VoxelPointSelection();
6
+ voxelData;
7
+ usePlacingStrategy = true;
8
+ async update() {
9
+ this._lastPicked = await this.space.pickWithProvider(this.rayProviderIndex);
10
+ if (!this._lastPicked)
11
+ return;
12
+ if (!this.space.bounds.intersectsPoint(this._lastPicked.position)) {
13
+ this._lastPicked = null;
14
+ return;
15
+ }
16
+ this.selection.reConstruct(this._lastPicked.position);
17
+ }
18
+ cancel() {
19
+ this._lastPicked = null;
20
+ }
21
+ async use() {
22
+ if (!this._lastPicked)
23
+ return;
24
+ console.warn("USE DEBUG");
25
+ console.log("PICKED", this._lastPicked.clone());
26
+ console.log("VOXEL", this._lastPicked.voxel.getStringId(), this._lastPicked.voxel.getId(), this._lastPicked.voxel.getVoxelId());
27
+ return;
28
+ }
29
+ getOptionValue(id) {
30
+ return null;
31
+ }
32
+ getCurrentOptions() {
33
+ return [];
34
+ }
35
+ updateOption(property, value) { }
36
+ }
@@ -8,7 +8,7 @@ export declare enum PathToolModes {
8
8
  MovePoints = "Move Points",
9
9
  RemovePoints = "Remove Points",
10
10
  FillPath = "Fill Path",
11
- RemovePath = "Remvoe Path"
11
+ RemovePath = "Remove Path"
12
12
  }
13
13
  interface PathToolEvents {
14
14
  }
@@ -8,7 +8,7 @@ export var PathToolModes;
8
8
  PathToolModes["MovePoints"] = "Move Points";
9
9
  PathToolModes["RemovePoints"] = "Remove Points";
10
10
  PathToolModes["FillPath"] = "Fill Path";
11
- PathToolModes["RemovePath"] = "Remvoe Path";
11
+ PathToolModes["RemovePath"] = "Remove Path";
12
12
  })(PathToolModes || (PathToolModes = {}));
13
13
  export class PathTool extends BuilderToolBase {
14
14
  static ToolId = "Path";
@@ -44,9 +44,17 @@ export class SculptTool extends BuilderToolBase {
44
44
  if (!this._started && !placerMode && picked) {
45
45
  if (this.mode == SculptToolModes.Fill ||
46
46
  this.mode == SculptToolModes.Extrude) {
47
+ if (!this.space.bounds.intersectsPoint(picked.normalPosition)) {
48
+ this._lastPicked = null;
49
+ return;
50
+ }
47
51
  this.selection.reConstruct(picked.normalPosition, picked.normal, Vector3Like.Add(picked.normalPosition, Vector3Like.Create(1, 1, 1)), picked.normal);
48
52
  }
49
53
  if (this.mode == SculptToolModes.Remove) {
54
+ if (!this.space.bounds.intersectsPoint(picked.position)) {
55
+ this._lastPicked = null;
56
+ return;
57
+ }
50
58
  this.selection.reConstruct(picked.position, picked.normal, Vector3Like.Add(picked.position, Vector3Like.Create(1, 1, 1)), picked.normal);
51
59
  }
52
60
  this._normal = { ...picked.normal };
@@ -116,14 +116,12 @@ export class WrenchTool extends BuilderToolBase {
116
116
  return null;
117
117
  const voxelStates = [];
118
118
  const voxelId = this._pickedResult.voxel.id;
119
- const [trueId, , mod] = VoxelLUT.voxels[voxelId];
120
- const stateArray = VoxelLUT.voxelRecord[trueId][mod];
119
+ const trueId = VoxelLUT.voxelIdToTrueId[voxelId];
120
+ const mod = VoxelLUT.voxelIdToMod[voxelId];
121
+ const stateMap = VoxelLUT.modelStateMaps[VoxelLUT.modelsIndex[trueId]];
121
122
  const rawVoxelData = [0, 0, 0, 0];
122
- for (let i = 0; i < stateArray.length; i++) {
123
- const value = stateArray[i];
124
- if (value === undefined || value <= 0)
125
- continue;
126
- rawVoxelData[0] = value;
123
+ for (const [state, index] of stateMap) {
124
+ rawVoxelData[0] = VoxelLUT.getVoxelId(trueId, state, mod);
127
125
  voxelStates.push(PaintVoxelData.FromRaw(rawVoxelData));
128
126
  }
129
127
  return voxelStates;
@@ -134,23 +132,12 @@ export class WrenchTool extends BuilderToolBase {
134
132
  return null;
135
133
  const voxelStates = [];
136
134
  const voxelId = this._pickedResult.voxel.id;
137
- const [trueId, state] = VoxelLUT.voxels[voxelId];
138
- const modArray = VoxelLUT.voxelRecord[trueId];
135
+ const trueId = VoxelLUT.voxelIdToTrueId[voxelId];
136
+ const state = VoxelLUT.voxelIdToState[voxelId];
139
137
  const rawVoxelData = [0, 0, 0, 0];
140
- for (let i = 0; i < modArray.length; i++) {
141
- const stateArray = modArray[i];
142
- if (stateArray === undefined || !stateArray.length)
143
- continue;
144
- let id = -1;
145
- for (let j = 0; j < stateArray.length; j++) {
146
- id = VoxelLUT.voxelRecord[trueId][i][state];
147
- if (id === undefined || id < 0)
148
- continue;
149
- rawVoxelData[0] = id;
150
- break;
151
- }
152
- if (id === undefined || id < 0)
153
- continue;
138
+ const modMap = VoxelLUT.voxelModMaps[trueId];
139
+ for (const [mod, index] of modMap) {
140
+ rawVoxelData[0] = VoxelLUT.getVoxelId(trueId, state, mod);
154
141
  voxelStates.push(PaintVoxelData.FromRaw(rawVoxelData));
155
142
  }
156
143
  return voxelStates;
@@ -20,6 +20,8 @@ export class SurfaceBoxSelection {
20
20
  this.planeNormal.z > 0) {
21
21
  offset++;
22
22
  }
23
+ if (!this.space.bounds.intersectsPoint(intersectionPoint))
24
+ return;
23
25
  this.selection.reConstruct(this.planeOrigin, this.planeNormal, intersectionPoint, this.planeNormal, offset);
24
26
  }
25
27
  }
@@ -92,9 +92,9 @@ export class VoxelBuildSpace {
92
92
  [0, min.x, min.y, min.z],
93
93
  VoxelShapeTemplate.CreateNew({
94
94
  shapeSelection: BoxVoxelShapeSelection.CreateNew({
95
- width: this.bounds.size.x,
96
- height: this.bounds.size.y,
97
- depth: this.bounds.size.z,
95
+ width: this.bounds.size.x + 1,
96
+ height: this.bounds.size.y + 1,
97
+ depth: this.bounds.size.z + 1,
98
98
  }),
99
99
  }),
100
100
  ]);
@@ -9,9 +9,9 @@ import { VoxelSchemas } from "../../../Voxels/State/VoxelSchemas";
9
9
  export default function InitDataSync(props) {
10
10
  Threads.registerTask("sync-data", (data) => {
11
11
  EngineSettings.syncSettings(data.settings);
12
- VoxelSchemas.import(data.schemas);
13
12
  VoxelLUT.import(data.luts.voxel);
14
13
  GeometryLUT.import(data.luts.geometry);
14
+ VoxelSchemas.import(data.schemas);
15
15
  VoxelTagsRegister.VoxelTags = data.tags.tags;
16
16
  VoxelTagsRegister.SubstanceTags = data.tags.substanceTags;
17
17
  for (const id in data.tags.logic) {
@@ -1,5 +1,4 @@
1
1
  import { Vec3ArrayLike, Vector3Like } from "@amodx/math";
2
- import { VoxelFaces } from "./VoxelFaces";
3
2
  const unitNormals = [
4
3
  [0, 1, 0],
5
4
  [0, -1, 0],
@@ -35,18 +34,18 @@ export function closestUnitNormal(v) {
35
34
  }
36
35
  export function closestVoxelFace(v) {
37
36
  const unitNormal = closestUnitNormal(v);
38
- let closestFace = VoxelFaces.Up;
37
+ let closestFace = 0 /* VoxelFaces.Up */;
39
38
  if (unitNormal[0] == 1)
40
- closestFace = VoxelFaces.East;
39
+ closestFace = 4 /* VoxelFaces.East */;
41
40
  if (unitNormal[0] == -1)
42
- closestFace = VoxelFaces.West;
41
+ closestFace = 5 /* VoxelFaces.West */;
43
42
  if (unitNormal[1] == 1)
44
- closestFace = VoxelFaces.Up;
43
+ closestFace = 0 /* VoxelFaces.Up */;
45
44
  if (unitNormal[1] == -1)
46
- closestFace = VoxelFaces.Down;
45
+ closestFace = 1 /* VoxelFaces.Down */;
47
46
  if (unitNormal[2] == 1)
48
- closestFace = VoxelFaces.North;
47
+ closestFace = 2 /* VoxelFaces.North */;
49
48
  if (unitNormal[2] == -1)
50
- closestFace = VoxelFaces.South;
49
+ closestFace = 3 /* VoxelFaces.South */;
51
50
  return closestFace;
52
51
  }
@@ -3,7 +3,7 @@ export type VoxelFaceNames = "up" | "down" | "north" | "south" | "east" | "west"
3
3
  export declare const VoxelFaceNameArray: VoxelFaceNames[];
4
4
  export declare const VoxelFaceNameOppoisteRecord: Record<VoxelFaceNames, VoxelFaceNames>;
5
5
  export declare const VoxelFaceNameDirectionsRecord: Record<VoxelFaceNames, Vec3Array>;
6
- export declare enum VoxelFaces {
6
+ export declare const enum VoxelFaces {
7
7
  Up = 0,
8
8
  Down = 1,
9
9
  North = 2,
@@ -12,7 +12,7 @@ export declare enum VoxelFaces {
12
12
  West = 5
13
13
  }
14
14
  export declare const VoxelFacesArray: readonly VoxelFaces[];
15
- export declare const VoxelFaceDirections: Readonly<Record<VoxelFaces, Vec3Array>>;
15
+ export declare const VoxelFaceDirections: Readonly<Vec3Array[]>;
16
16
  export declare const VoxelFaceOpositeDirectionMap: Record<VoxelFaces, VoxelFaces>;
17
17
  export declare const VoxelFaceCompassDirectionMap: Record<VoxelFaces, CompassDirections>;
18
18
  export declare const CompassDirectionVoxelFaceMap: Record<CompassDirections, VoxelFaces>;
@@ -23,70 +23,61 @@ export const VoxelFaceNameDirectionsRecord = {
23
23
  east: [1, 0, 0],
24
24
  west: [-1, 0, 0],
25
25
  };
26
- export var VoxelFaces;
27
- (function (VoxelFaces) {
28
- VoxelFaces[VoxelFaces["Up"] = 0] = "Up";
29
- VoxelFaces[VoxelFaces["Down"] = 1] = "Down";
30
- VoxelFaces[VoxelFaces["North"] = 2] = "North";
31
- VoxelFaces[VoxelFaces["South"] = 3] = "South";
32
- VoxelFaces[VoxelFaces["East"] = 4] = "East";
33
- VoxelFaces[VoxelFaces["West"] = 5] = "West";
34
- })(VoxelFaces || (VoxelFaces = {}));
35
26
  export const VoxelFacesArray = Object.freeze([
36
- VoxelFaces.Up,
37
- VoxelFaces.Down,
38
- VoxelFaces.North,
39
- VoxelFaces.South,
40
- VoxelFaces.East,
41
- VoxelFaces.West,
27
+ 0 /* VoxelFaces.Up */,
28
+ 1 /* VoxelFaces.Down */,
29
+ 2 /* VoxelFaces.North */,
30
+ 3 /* VoxelFaces.South */,
31
+ 4 /* VoxelFaces.East */,
32
+ 5 /* VoxelFaces.West */,
33
+ ]);
34
+ export const VoxelFaceDirections = Object.freeze([
35
+ [0, 1, 0], // 0 = Up
36
+ [0, -1, 0], // 1 = Down
37
+ [0, 0, 1], // 2 = North
38
+ [0, 0, -1], // 3 = South
39
+ [1, 0, 0], // 4 = East
40
+ [-1, 0, 0], // 5 = West
42
41
  ]);
43
- export const VoxelFaceDirections = Object.freeze({
44
- [VoxelFaces.Up]: [0, 1, 0],
45
- [VoxelFaces.Down]: [0, -1, 0],
46
- [VoxelFaces.North]: [0, 0, 1],
47
- [VoxelFaces.South]: [0, 0, -1],
48
- [VoxelFaces.East]: [1, 0, 0],
49
- [VoxelFaces.West]: [-1, 0, 0],
50
- });
51
42
  export const VoxelFaceOpositeDirectionMap = {
52
- [VoxelFaces.Up]: VoxelFaces.Down,
53
- [VoxelFaces.Down]: VoxelFaces.Up,
54
- [VoxelFaces.North]: VoxelFaces.South,
55
- [VoxelFaces.South]: VoxelFaces.North,
56
- [VoxelFaces.East]: VoxelFaces.West,
57
- [VoxelFaces.West]: VoxelFaces.East,
43
+ [0 /* VoxelFaces.Up */]: 1 /* VoxelFaces.Down */,
44
+ [1 /* VoxelFaces.Down */]: 0 /* VoxelFaces.Up */,
45
+ [2 /* VoxelFaces.North */]: 3 /* VoxelFaces.South */,
46
+ [3 /* VoxelFaces.South */]: 2 /* VoxelFaces.North */,
47
+ [4 /* VoxelFaces.East */]: 5 /* VoxelFaces.West */,
48
+ [5 /* VoxelFaces.West */]: 4 /* VoxelFaces.East */,
58
49
  };
59
50
  export const VoxelFaceCompassDirectionMap = {
60
- [VoxelFaces.Up]: CompassDirections.North,
61
- [VoxelFaces.Down]: CompassDirections.South,
62
- [VoxelFaces.North]: CompassDirections.North,
63
- [VoxelFaces.South]: CompassDirections.South,
64
- [VoxelFaces.East]: CompassDirections.East,
65
- [VoxelFaces.West]: CompassDirections.West,
51
+ [0 /* VoxelFaces.Up */]: CompassDirections.North,
52
+ [1 /* VoxelFaces.Down */]: CompassDirections.South,
53
+ [2 /* VoxelFaces.North */]: CompassDirections.North,
54
+ [3 /* VoxelFaces.South */]: CompassDirections.South,
55
+ [4 /* VoxelFaces.East */]: CompassDirections.East,
56
+ [5 /* VoxelFaces.West */]: CompassDirections.West,
66
57
  };
67
58
  export const CompassDirectionVoxelFaceMap = {
68
- [CompassDirections.North]: VoxelFaces.North,
69
- [CompassDirections.South]: VoxelFaces.South,
70
- [CompassDirections.West]: VoxelFaces.West,
71
- [CompassDirections.East]: VoxelFaces.East,
72
- [CompassDirections.NorthEast]: VoxelFaces.Up,
73
- [CompassDirections.NorthWest]: VoxelFaces.Up,
74
- [CompassDirections.SouthEast]: VoxelFaces.Up,
75
- [CompassDirections.SouthWest]: VoxelFaces.Up,
59
+ [CompassDirections.North]: 2 /* VoxelFaces.North */,
60
+ [CompassDirections.South]: 3 /* VoxelFaces.South */,
61
+ [CompassDirections.West]: 5 /* VoxelFaces.West */,
62
+ [CompassDirections.East]: 4 /* VoxelFaces.East */,
63
+ [CompassDirections.NorthEast]: 0 /* VoxelFaces.Up */,
64
+ [CompassDirections.NorthWest]: 0 /* VoxelFaces.Up */,
65
+ [CompassDirections.SouthEast]: 0 /* VoxelFaces.Up */,
66
+ [CompassDirections.SouthWest]: 0 /* VoxelFaces.Up */,
76
67
  };
77
68
  export const VoxelFaceNameRecord = {
78
- up: VoxelFaces.Up,
79
- down: VoxelFaces.Down,
80
- north: VoxelFaces.North,
81
- south: VoxelFaces.South,
82
- east: VoxelFaces.East,
83
- west: VoxelFaces.West,
69
+ up: 0 /* VoxelFaces.Up */,
70
+ down: 1 /* VoxelFaces.Down */,
71
+ north: 2 /* VoxelFaces.North */,
72
+ south: 3 /* VoxelFaces.South */,
73
+ east: 4 /* VoxelFaces.East */,
74
+ west: 5 /* VoxelFaces.West */,
84
75
  };
85
76
  export const VoxelFaceNameMap = {
86
- [VoxelFaces.Up]: "up",
87
- [VoxelFaces.Down]: "down",
88
- [VoxelFaces.North]: "north",
89
- [VoxelFaces.South]: "south",
90
- [VoxelFaces.East]: "east",
91
- [VoxelFaces.West]: "west",
77
+ [0 /* VoxelFaces.Up */]: "up",
78
+ [1 /* VoxelFaces.Down */]: "down",
79
+ [2 /* VoxelFaces.North */]: "north",
80
+ [3 /* VoxelFaces.South */]: "south",
81
+ [4 /* VoxelFaces.East */]: "east",
82
+ [5 /* VoxelFaces.West */]: "west",
92
83
  };
@@ -0,0 +1,11 @@
1
+ import { Vec3Array, Vector3Like } from "@amodx/math";
2
+ export declare function CubeHashVec3Array(positionX: number, positionY: number, positionZ: number, xPower2: number, yPower2: number, zPower2: number, positionRef?: Vec3Array): Vec3Array;
3
+ export declare function CubeHashVec3(positionX: number, positionY: number, positionZ: number, xPower2: number, yPower2: number, zPower2: number, positionRef?: Vector3Like): Vector3Like;
4
+ export declare function GetYXZOrderArrayIndex(x: number, y: number, z: number, zPower: number, // log2(boundsZ)
5
+ xzPower: number): number;
6
+ export declare function GetYXZOrderArrayPositionVec3(index: number, zPower: number, xzPower: number, zMask: number, // boundsZ - 1
7
+ xMask: number, // boundsX - 1
8
+ positionRef?: Vector3Like): Vector3Like;
9
+ export declare function GetYXZOrderArrayPositionVec3Array(index: number, zPower: number, xzPower: number, zMask: number, // boundsZ - 1
10
+ xMask: number, // boundsX - 1
11
+ positionRef?: Vec3Array): Vec3Array;
@@ -0,0 +1,34 @@
1
+ import { Vector3Like } from "@amodx/math";
2
+ export function CubeHashVec3Array(positionX, positionY, positionZ, xPower2, yPower2, zPower2, positionRef = [0, 0, 0]) {
3
+ positionRef[0] = (positionX >> xPower2) << xPower2;
4
+ positionRef[1] = (positionY >> yPower2) << yPower2;
5
+ positionRef[2] = (positionZ >> zPower2) << zPower2;
6
+ return positionRef;
7
+ }
8
+ export function CubeHashVec3(positionX, positionY, positionZ, xPower2, yPower2, zPower2, positionRef = Vector3Like.Create()) {
9
+ positionRef.x = (positionX >> xPower2) << xPower2;
10
+ positionRef.y = (positionY >> yPower2) << yPower2;
11
+ positionRef.z = (positionZ >> zPower2) << zPower2;
12
+ return positionRef;
13
+ }
14
+ export function GetYXZOrderArrayIndex(x, y, z, zPower, // log2(boundsZ)
15
+ xzPower // log2(boundsX * boundsZ), precomputed
16
+ ) {
17
+ return z | (x << zPower) | (y << xzPower);
18
+ }
19
+ export function GetYXZOrderArrayPositionVec3(index, zPower, xzPower, zMask, // boundsZ - 1
20
+ xMask, // boundsX - 1
21
+ positionRef = Vector3Like.Create()) {
22
+ positionRef.z = index & zMask;
23
+ positionRef.x = (index >> zPower) & xMask;
24
+ positionRef.y = index >> xzPower;
25
+ return positionRef;
26
+ }
27
+ export function GetYXZOrderArrayPositionVec3Array(index, zPower, xzPower, zMask, // boundsZ - 1
28
+ xMask, // boundsX - 1
29
+ positionRef = [0, 0, 0]) {
30
+ positionRef[2] = index & zMask;
31
+ positionRef[0] = (index >> zPower) & xMask;
32
+ positionRef[1] = index >> xzPower;
33
+ return positionRef;
34
+ }
@@ -11,14 +11,14 @@ export interface VoxelGeometryTransform {
11
11
  export type QuadVertexVec3Data = [Vec3Array, Vec3Array, Vec3Array, Vec3Array];
12
12
  export type QuadVertexFloatData = [number, number, number, number];
13
13
  export type QuadUVData = [Vec2Array, Vec2Array, Vec2Array, Vec2Array];
14
- export declare enum QuadVerticies {
14
+ export declare const enum QuadVerticies {
15
15
  TopRight = 0,
16
16
  TopLeft = 1,
17
17
  BottomLeft = 2,
18
18
  BottomRight = 3
19
19
  }
20
20
  export declare const QuadVerticiesArray: QuadVerticies[];
21
- export declare enum TriangleVerticies {
21
+ export declare const enum TriangleVerticies {
22
22
  One = 0,
23
23
  Two = 1,
24
24
  Three = 2