@margoengine/voxel-edit 0.0.0-stage → 1.0.0

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 (64) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +4 -0
  3. package/README.md +445 -2
  4. package/dist/animation.d.ts +50 -0
  5. package/dist/animation.js +88 -0
  6. package/dist/assist.d.ts +24 -0
  7. package/dist/assist.js +52 -0
  8. package/dist/brush-gpu.d.ts +62 -0
  9. package/dist/bytes.d.ts +55 -0
  10. package/dist/collab.d.ts +77 -0
  11. package/dist/collab.js +159 -0
  12. package/dist/edit.d.ts +30 -0
  13. package/dist/edit.js +361 -0
  14. package/dist/export.d.ts +58 -0
  15. package/dist/export.js +52 -0
  16. package/dist/file-colors-DHT5vrzW.js +55 -0
  17. package/dist/file-colors.d.ts +16 -0
  18. package/dist/format-plist.d.ts +4 -0
  19. package/dist/formats-extra.d.ts +20 -0
  20. package/dist/formats-extra.js +335 -0
  21. package/dist/formats.d.ts +96 -0
  22. package/dist/formats.js +924 -0
  23. package/dist/generate.d.ts +63 -0
  24. package/dist/generate.js +103 -0
  25. package/dist/gox.d.ts +60 -0
  26. package/dist/gpu.d.ts +74 -0
  27. package/dist/gpu.js +167 -0
  28. package/dist/grid-B2V0TGLV.js +120 -0
  29. package/dist/grid.d.ts +75 -0
  30. package/dist/history.d.ts +65 -0
  31. package/dist/history.js +75 -0
  32. package/dist/index.d.ts +5 -0
  33. package/dist/index.js +631 -0
  34. package/dist/layout.d.ts +76 -0
  35. package/dist/library.d.ts +50 -0
  36. package/dist/library.js +89 -0
  37. package/dist/mesh.d.ts +128 -0
  38. package/dist/mesh.js +365 -0
  39. package/dist/model.d.ts +173 -0
  40. package/dist/pick.d.ts +34 -0
  41. package/dist/pick.js +122 -0
  42. package/dist/raster.d.ts +89 -0
  43. package/dist/rig.d.ts +88 -0
  44. package/dist/rig.js +216 -0
  45. package/dist/select.d.ts +50 -0
  46. package/dist/select.js +94 -0
  47. package/dist/shaders-BaY4gcm9.js +234 -0
  48. package/dist/shaders.d.ts +116 -0
  49. package/dist/shaders.js +1 -0
  50. package/dist/slices.d.ts +75 -0
  51. package/dist/smooth.d.ts +43 -0
  52. package/dist/smooth.js +212 -0
  53. package/dist/sparse.d.ts +239 -0
  54. package/dist/sparse.js +646 -0
  55. package/dist/stamp.d.ts +88 -0
  56. package/dist/vmax.d.ts +48 -0
  57. package/dist/vox-resolve.d.ts +64 -0
  58. package/dist/vox-scene.d.ts +51 -0
  59. package/dist/vox.d.ts +30 -0
  60. package/dist/vox.js +684 -0
  61. package/dist/voxelize.d.ts +70 -0
  62. package/dist/voxelize.js +249 -0
  63. package/dist/vxm.d.ts +54 -0
  64. package/package.json +130 -4
@@ -0,0 +1,65 @@
1
+ import { type VoxelGrid } from './grid.js';
2
+ /** Options of {@link VoxelHistory}. */
3
+ export interface HistoryOptions {
4
+ /** Most snapshots kept, including the current one. Default 64. */
5
+ maxDepth?: number;
6
+ /** Most cells of each pushed grid, 1 to 67,108,864. Not a cumulative budget. Default 16,777,216. */
7
+ maxCells?: number;
8
+ /**
9
+ * Bytes of voxel buffers this history may retain at once. A push past it drops the oldest steps until the new one
10
+ * fits, as editors' undo memory limits do; a single step larger than the whole budget is kept as the only step.
11
+ * Default no extra limit (only `maxDepth` applies). This counts the history's own copies, not the rest of an editor
12
+ * document.
13
+ */
14
+ maxBytes?: number;
15
+ }
16
+ /** One recorded state. `grid` is a copy the caller owns. */
17
+ export interface HistoryEntry {
18
+ /** A copy of the grid at this step. */
19
+ grid: VoxelGrid;
20
+ /** Optional name of the operation that produced it. */
21
+ label?: string;
22
+ }
23
+ /**
24
+ * An undo/redo stack of copied grids. Mutating a grid you passed in, or a grid this class returned, does not change
25
+ * the stored steps. `maxCells` checks one grid. `maxBytes`, when set, is the sum of the stored copies only: like
26
+ * GIMP's "Maximum undo memory" (GIMP 3.2 User Manual, "Undoing"), going past it drops the oldest steps, and the newest
27
+ * step always stays, so `bytes` exceeds `maxBytes` only while one step alone is larger than it.
28
+ */
29
+ export declare class VoxelHistory {
30
+ #private;
31
+ /**
32
+ * Starts a history whose first step is a copy of `initial`.
33
+ * @throws RangeError when an option is out of range or `initial` fails the cell budget.
34
+ */
35
+ constructor(initial: VoxelGrid, options?: HistoryOptions);
36
+ /** A copy of the grid at the current step. */
37
+ get current(): VoxelGrid;
38
+ /** Whether a step can be undone. */
39
+ get canUndo(): boolean;
40
+ /** Whether a step can be redone. */
41
+ get canRedo(): boolean;
42
+ /** The label of the current step, if any. */
43
+ get label(): string | undefined;
44
+ /** Number of stored snapshots. */
45
+ get depth(): number;
46
+ /** Bytes of voxel buffers currently stored. */
47
+ get bytes(): number;
48
+ /**
49
+ * Record a copy of `grid`. Discards any redo branch, then drops the oldest steps while the stored copies pass
50
+ * `maxDepth` or `maxBytes` (never the new step). Returns an owned grid copy, like undo/redo/go/current.
51
+ * @throws RangeError when the grid fails the cell budget; nothing is recorded then.
52
+ */
53
+ push(grid: VoxelGrid, label?: string): VoxelGrid;
54
+ /** Move to the previous step and return a copy of its grid, or the current copy if at the start. */
55
+ undo(): VoxelGrid;
56
+ /** Move to the next step and return a copy of its grid, or the current copy if at the end. */
57
+ redo(): VoxelGrid;
58
+ /**
59
+ * Jump to a stored step by index (0 is the oldest) and return a copy of its grid.
60
+ * @throws RangeError when `index` is out of range.
61
+ */
62
+ go(index: number): VoxelGrid;
63
+ /** Copies of the stored entries, oldest first. */
64
+ entries(): readonly HistoryEntry[];
65
+ }
@@ -0,0 +1,75 @@
1
+ import { c as e, o as t } from "./grid-B2V0TGLV.js";
2
+ //#region src/history.ts
3
+ var n = class {
4
+ #e = [];
5
+ #t = -1;
6
+ #n = 0;
7
+ #r;
8
+ #i;
9
+ #a;
10
+ constructor(e, n = {}) {
11
+ if (this.#r = i(n.maxDepth), this.#i = t(n), this.#a = n.maxBytes ?? Infinity, !(this.#a > 0)) throw RangeError("History maxBytes must be greater than 0");
12
+ this.push(e, "initial");
13
+ }
14
+ get current() {
15
+ return r(this.#e[this.#t].grid);
16
+ }
17
+ get canUndo() {
18
+ return this.#t > 0;
19
+ }
20
+ get canRedo() {
21
+ return this.#t < this.#e.length - 1;
22
+ }
23
+ get label() {
24
+ return this.#e[this.#t].label;
25
+ }
26
+ get depth() {
27
+ return this.#e.length;
28
+ }
29
+ get bytes() {
30
+ return this.#n;
31
+ }
32
+ push(t, n) {
33
+ e(t, this.#i, "History grid");
34
+ let i = r(t), a = this.#e.slice(0, this.#t + 1), o = this.#n + i.voxels.byteLength;
35
+ for (let e = a.length; e < this.#e.length; e++) o -= this.#e[e].grid.voxels.byteLength;
36
+ for (a.push({
37
+ grid: i,
38
+ label: n
39
+ }); a.length > this.#r || a.length > 1 && o > this.#a;) o -= a.shift().grid.voxels.byteLength;
40
+ return this.#e = a, this.#t = a.length - 1, this.#n = o, r(i);
41
+ }
42
+ undo() {
43
+ return this.#t > 0 && this.#t--, this.current;
44
+ }
45
+ redo() {
46
+ return this.#t < this.#e.length - 1 && this.#t++, this.current;
47
+ }
48
+ go(e) {
49
+ if (!Number.isInteger(e) || e < 0 || e >= this.#e.length) throw RangeError(`History index ${e} is out of range 0 to ${this.#e.length - 1}; pass an index of an existing entry`);
50
+ return this.#t = e, this.current;
51
+ }
52
+ entries() {
53
+ return this.#e.map((e) => ({
54
+ grid: r(e.grid),
55
+ label: e.label
56
+ }));
57
+ }
58
+ };
59
+ function r(e) {
60
+ return {
61
+ size: [
62
+ e.size[0],
63
+ e.size[1],
64
+ e.size[2]
65
+ ],
66
+ voxels: new Uint8Array(e.voxels)
67
+ };
68
+ }
69
+ function i(e) {
70
+ if (e === void 0) return 64;
71
+ if (!Number.isInteger(e) || e < 1 || e > 1024) throw RangeError("History maxDepth must be an integer from 1 to 1024");
72
+ return e;
73
+ }
74
+ //#endregion
75
+ export { n as VoxelHistory };
@@ -0,0 +1,5 @@
1
+ export { type VoxelGrid, type GridLimits, type GridEdit, type GridHit, cellIndex, cellAt, insideGrid, } from './grid.js';
2
+ export { type CombineOptions, combineGrids, type ShearOptions, shearGrid, type DiagonalOptions, reflectDiagonal, type WrapOptions, wrapGrid, type RepeatOptions, repeatGrid, type ResampleOptions, resampleGrid, type RotateOptions, rotateGrid, type MorphologyOptions, type DilateOptions, dilateGrid, erodeGrid, type FillOptions, fillEnclosed, type PaletteMergeOptions, type PaletteMerge, mergePalettes, type MazeOptions, type Maze, generateMaze, } from './model.js';
3
+ export { type GridLayoutOptions, type GridLayout, type FlipOptions, flipGrid, type TurnOptions, turnGrid, type ShiftOptions, shiftGrid, occupiedBounds, type CropOptions, cropGrid, fitGrid, type InvertOptions, invertGrid, } from './layout.js';
4
+ export { type OwnedBuffer, type BufferOwner, type ByteSource, ownedBuffers, retainedBytes, ByteLedger, } from './bytes.js';
5
+ export { type SlicePixels, type SliceOptions, type SliceLayout, type SliceStack, sliceLayout, stackSlices, } from './slices.js';