nucleation 0.2.17 → 0.3.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 (125) hide show
  1. package/Autostack.d.ts +43 -0
  2. package/Autostack.mjs +134 -0
  3. package/BlockPos.d.ts +28 -0
  4. package/BlockPos.mjs +129 -0
  5. package/BlockState.d.ts +39 -0
  6. package/BlockState.mjs +134 -0
  7. package/Brush.d.ts +59 -0
  8. package/Brush.mjs +203 -0
  9. package/BuildingTool.d.ts +29 -0
  10. package/BuildingTool.mjs +74 -0
  11. package/ChunkMeshResult.d.ts +75 -0
  12. package/ChunkMeshResult.mjs +253 -0
  13. package/CircuitBuilder.d.ts +118 -0
  14. package/CircuitBuilder.mjs +516 -0
  15. package/DefinitionRegion.d.ts +274 -0
  16. package/DefinitionRegion.mjs +973 -0
  17. package/Diff.d.ts +88 -0
  18. package/Diff.mjs +316 -0
  19. package/Dimensions.d.ts +28 -0
  20. package/Dimensions.mjs +129 -0
  21. package/ExecutionMode.d.ts +42 -0
  22. package/ExecutionMode.mjs +127 -0
  23. package/Fingerprint.d.ts +44 -0
  24. package/Fingerprint.mjs +197 -0
  25. package/InterpolationSpace.d.ts +25 -0
  26. package/InterpolationSpace.mjs +73 -0
  27. package/IoLayout.d.ts +26 -0
  28. package/IoLayout.mjs +81 -0
  29. package/IoLayoutBuilder.d.ts +73 -0
  30. package/IoLayoutBuilder.mjs +315 -0
  31. package/IoType.d.ts +41 -0
  32. package/IoType.mjs +125 -0
  33. package/ItemModelConfig.d.ts +65 -0
  34. package/ItemModelConfig.mjs +223 -0
  35. package/ItemModelPackBuilder.d.ts +32 -0
  36. package/ItemModelPackBuilder.mjs +104 -0
  37. package/ItemModelResult.d.ts +72 -0
  38. package/ItemModelResult.mjs +268 -0
  39. package/ItemScale.d.ts +31 -0
  40. package/ItemScale.mjs +132 -0
  41. package/LayoutFunction.d.ts +52 -0
  42. package/LayoutFunction.mjs +159 -0
  43. package/MchprsWorld.d.ts +131 -0
  44. package/MchprsWorld.mjs +423 -0
  45. package/MeshBounds.d.ts +40 -0
  46. package/MeshBounds.mjs +180 -0
  47. package/MeshConfig.d.ts +101 -0
  48. package/MeshConfig.mjs +306 -0
  49. package/MeshJob.d.ts +44 -0
  50. package/MeshJob.mjs +116 -0
  51. package/MeshPhase.d.ts +38 -0
  52. package/MeshPhase.mjs +90 -0
  53. package/MeshProgress.d.ts +32 -0
  54. package/MeshProgress.mjs +133 -0
  55. package/MeshResult.d.ts +60 -0
  56. package/MeshResult.mjs +206 -0
  57. package/MultiMeshResult.d.ts +50 -0
  58. package/MultiMeshResult.mjs +166 -0
  59. package/Nbt.d.ts +50 -0
  60. package/Nbt.mjs +161 -0
  61. package/NucleationError.d.ts +36 -0
  62. package/NucleationError.mjs +104 -0
  63. package/OutputCondition.d.ts +45 -0
  64. package/OutputCondition.mjs +129 -0
  65. package/README.md +28 -196
  66. package/RawMeshExport.d.ts +74 -0
  67. package/RawMeshExport.mjs +243 -0
  68. package/RedstoneGraph.d.ts +58 -0
  69. package/RedstoneGraph.mjs +242 -0
  70. package/RegionBounds.d.ts +41 -0
  71. package/RegionBounds.mjs +181 -0
  72. package/RenderConfig.d.ts +66 -0
  73. package/RenderConfig.mjs +170 -0
  74. package/Renderer.d.ts +35 -0
  75. package/Renderer.mjs +139 -0
  76. package/ResourcePack.d.ts +105 -0
  77. package/ResourcePack.mjs +447 -0
  78. package/ResourcePackList.d.ts +32 -0
  79. package/ResourcePackList.mjs +96 -0
  80. package/Schematic.d.ts +655 -0
  81. package/Schematic.mjs +2647 -0
  82. package/SchematicBuilder.d.ts +103 -0
  83. package/SchematicBuilder.mjs +401 -0
  84. package/SchematicRegions.d.ts +93 -0
  85. package/SchematicRegions.mjs +411 -0
  86. package/Scripting.d.ts +40 -0
  87. package/Scripting.mjs +138 -0
  88. package/Sdf.d.ts +31 -0
  89. package/Sdf.mjs +107 -0
  90. package/Shape.d.ts +108 -0
  91. package/Shape.mjs +336 -0
  92. package/SortStrategy.d.ts +86 -0
  93. package/SortStrategy.mjs +272 -0
  94. package/Store.d.ts +83 -0
  95. package/Store.mjs +369 -0
  96. package/StoreIo.d.ts +71 -0
  97. package/StoreIo.mjs +292 -0
  98. package/TextureAtlas.d.ts +40 -0
  99. package/TextureAtlas.mjs +122 -0
  100. package/TextureInfo.d.ts +34 -0
  101. package/TextureInfo.mjs +148 -0
  102. package/TypedCircuitExecutor.d.ts +101 -0
  103. package/TypedCircuitExecutor.mjs +378 -0
  104. package/Value.d.ts +73 -0
  105. package/Value.mjs +275 -0
  106. package/WorldChunkView.d.ts +63 -0
  107. package/WorldChunkView.mjs +201 -0
  108. package/WorldSink.d.ts +50 -0
  109. package/WorldSink.mjs +177 -0
  110. package/WorldStream.d.ts +45 -0
  111. package/WorldStream.mjs +184 -0
  112. package/diplomat-runtime.d.ts +15 -0
  113. package/diplomat-runtime.mjs +774 -0
  114. package/diplomat-wasm.mjs +52 -0
  115. package/diplomat.config.mjs +6 -0
  116. package/index.d.ts +113 -0
  117. package/index.mjs +116 -0
  118. package/{nucleation_bg.wasm → nucleation.wasm} +0 -0
  119. package/package.json +19 -41
  120. package/LICENSE +0 -21
  121. package/api.js +0 -608
  122. package/nucleation-cdn-loader.js +0 -15
  123. package/nucleation-original.js +0 -8383
  124. package/nucleation.d.ts +0 -2947
  125. package/nucleation.js +0 -36
package/Sdf.mjs ADDED
@@ -0,0 +1,107 @@
1
+ // generated by diplomat-tool
2
+ import { NucleationError } from "./NucleationError.mjs"
3
+ import { Schematic } from "./Schematic.mjs"
4
+ import wasm from "./diplomat-wasm.mjs";
5
+ import * as diplomatRuntime from "./diplomat-runtime.mjs";
6
+
7
+ const Sdf_box_destroy_registry = new FinalizationRegistry((ptr) => {
8
+ wasm.Sdf_destroy(ptr);
9
+ });
10
+
11
+ /**
12
+ * Namespace for the SDF free functions of the old ABI (`schematic_from_sdf`,
13
+ * `sdf_eval`).
14
+ */
15
+ export class Sdf {
16
+ // Internal ptr reference:
17
+ #ptr = null;
18
+
19
+ // Lifetimes are only to keep dependencies alive.
20
+ // Since JS won't garbage collect until there are no incoming edges.
21
+ #selfEdge = [];
22
+
23
+ #internalConstructor(symbol, ptr, selfEdge) {
24
+ if (symbol !== diplomatRuntime.internalConstructor) {
25
+ console.error("Sdf is an Opaque type. You cannot call its constructor.");
26
+ return;
27
+ }
28
+ this.#ptr = ptr;
29
+ this.#selfEdge = selfEdge;
30
+
31
+ // Are we being borrowed? If not, we can register.
32
+ if (this.#selfEdge.length === 0) {
33
+ Sdf_box_destroy_registry.register(this, this.#ptr);
34
+ }
35
+
36
+ return this;
37
+ }
38
+ /** @internal */
39
+ get ffiValue() {
40
+ return this.#ptr;
41
+ }
42
+
43
+
44
+ /**
45
+ * Builds a schematic by sampling an SDF JSON tree with material rules JSON.
46
+ * When `has_bounds` is false the tree's own AABB is used (fails with
47
+ * `InvalidArgument` for unbounded trees) and the `min_*`/`max_*` arguments
48
+ * are ignored.
49
+ */
50
+ static schematicFromSdf(sdfJson, rulesJson, hasBounds, minX, minY, minZ, maxX, maxY, maxZ) {
51
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
52
+
53
+ const sdfJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, sdfJson)));
54
+ const rulesJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, rulesJson)));
55
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
56
+
57
+
58
+ const result = wasm.Sdf_schematic_from_sdf(diplomatReceive.buffer, sdfJsonSlice.ptr, rulesJsonSlice.ptr, hasBounds, minX, minY, minZ, maxX, maxY, maxZ);
59
+
60
+ try {
61
+ if (!diplomatReceive.resultFlag) {
62
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
63
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
64
+ }
65
+ return new Schematic(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
66
+ }
67
+
68
+ finally {
69
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
70
+ functionCleanupArena.free();
71
+
72
+ diplomatReceive.free();
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Evaluates an SDF JSON tree at a point, returning the signed distance.
78
+ */
79
+ static eval(sdfJson, x, y, z) {
80
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
81
+
82
+ const sdfJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, sdfJson)));
83
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
84
+
85
+
86
+ const result = wasm.Sdf_eval(diplomatReceive.buffer, sdfJsonSlice.ptr, x, y, z);
87
+
88
+ try {
89
+ if (!diplomatReceive.resultFlag) {
90
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
91
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
92
+ }
93
+ return (new Float32Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0];
94
+ }
95
+
96
+ finally {
97
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
98
+ functionCleanupArena.free();
99
+
100
+ diplomatReceive.free();
101
+ }
102
+ }
103
+
104
+ constructor(symbol, ptr, selfEdge) {
105
+ return this.#internalConstructor(...arguments)
106
+ }
107
+ }
package/Shape.d.ts ADDED
@@ -0,0 +1,108 @@
1
+ // generated by diplomat-tool
2
+ import type { NucleationError } from "./NucleationError"
3
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
4
+
5
+
6
+
7
+ /**
8
+ * A solid region of blocks: primitives (sphere, cuboid, …) and boolean
9
+ * combinations thereof. Wraps `ShapeEnum`.
10
+ */
11
+ export class Shape {
12
+ /** @internal */
13
+ get ffiValue(): pointer;
14
+ /** @internal */
15
+ constructor();
16
+
17
+
18
+ /**
19
+ * Sphere centered at (`cx`, `cy`, `cz`) (truncated to block coordinates,
20
+ * matching the old `shape_sphere`).
21
+ */
22
+ static sphere(cx: number, cy: number, cz: number, radius: number): Shape;
23
+
24
+ /**
25
+ * Axis-aligned box spanning the two corners (inclusive).
26
+ */
27
+ static cuboid(minX: number, minY: number, minZ: number, maxX: number, maxY: number, maxZ: number): Shape;
28
+
29
+ /**
30
+ * Ellipsoid centered at (`cx`, `cy`, `cz`) with per-axis radii.
31
+ */
32
+ static ellipsoid(cx: number, cy: number, cz: number, rx: number, ry: number, rz: number): Shape;
33
+
34
+ /**
35
+ * Cylinder from base point along an axis vector.
36
+ */
37
+ static cylinder(bx: number, by: number, bz: number, ax: number, ay: number, az: number, radius: number, height: number): Shape;
38
+
39
+ /**
40
+ * Cylinder spanning the segment between two points.
41
+ */
42
+ static cylinderBetween(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number, radius: number): Shape;
43
+
44
+ /**
45
+ * Cone with apex at (`ax`, `ay`, `az`) opening along direction (`dx`, `dy`, `dz`).
46
+ */
47
+ static cone(ax: number, ay: number, az: number, dx: number, dy: number, dz: number, radius: number, height: number): Shape;
48
+
49
+ /**
50
+ * Torus centered at (`cx`, `cy`, `cz`) with the given major/minor radii and
51
+ * axis (`ax`, `ay`, `az`).
52
+ */
53
+ static torus(cx: number, cy: number, cz: number, majorR: number, minorR: number, ax: number, ay: number, az: number): Shape;
54
+
55
+ /**
56
+ * Rectangular pyramid: base center, half-extents, height, up-axis.
57
+ */
58
+ static pyramid(bx: number, by: number, bz: number, halfW: number, halfD: number, height: number, ax: number, ay: number, az: number): Shape;
59
+
60
+ /**
61
+ * Flat disk: center, radius, plane normal, thickness.
62
+ */
63
+ static disk(cx: number, cy: number, cz: number, radius: number, nx: number, ny: number, nz: number, thickness: number): Shape;
64
+
65
+ /**
66
+ * Finite plane patch: origin, two spanning vectors `u`/`v`, extents along
67
+ * each, thickness.
68
+ */
69
+ static plane(ox: number, oy: number, oz: number, ux: number, uy: number, uz: number, vx: number, vy: number, vz: number, uExt: number, vExt: number, thickness: number): Shape;
70
+
71
+ /**
72
+ * Filled triangle between three vertices, thickened by `thickness`.
73
+ */
74
+ static triangle(ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number, thickness: number): Shape;
75
+
76
+ /**
77
+ * Line segment between two points, thickened by `thickness`.
78
+ */
79
+ static line(x1: number, y1: number, z1: number, x2: number, y2: number, z2: number, thickness: number): Shape;
80
+
81
+ /**
82
+ * Bézier curve through `control_points` (flat `[x0, y0, z0, x1, y1, z1, …]`,
83
+ * so the length must be a non-zero multiple of 3), thickened by `thickness`
84
+ * and sampled at `resolution` steps.
85
+ */
86
+ static bezier(controlPoints: Array<number>, thickness: number, resolution: number): Shape;
87
+
88
+ /**
89
+ * Hollowed-out copy of this shape with the given wall thickness (clones the
90
+ * input, like the old `shape_hollow`).
91
+ */
92
+ hollow(thickness: number): Shape;
93
+
94
+ /**
95
+ * Boolean union of this shape and `other` (clones both inputs).
96
+ */
97
+ unionWith(other: Shape): Shape;
98
+
99
+ /**
100
+ * Boolean intersection of this shape and `other` (clones both inputs).
101
+ */
102
+ intersectionWith(other: Shape): Shape;
103
+
104
+ /**
105
+ * Boolean difference: this shape minus `other` (clones both inputs).
106
+ */
107
+ differenceWith(other: Shape): Shape;
108
+ }
package/Shape.mjs ADDED
@@ -0,0 +1,336 @@
1
+ // generated by diplomat-tool
2
+ import { NucleationError } from "./NucleationError.mjs"
3
+ import wasm from "./diplomat-wasm.mjs";
4
+ import * as diplomatRuntime from "./diplomat-runtime.mjs";
5
+
6
+ const Shape_box_destroy_registry = new FinalizationRegistry((ptr) => {
7
+ wasm.Shape_destroy(ptr);
8
+ });
9
+
10
+ /**
11
+ * A solid region of blocks: primitives (sphere, cuboid, …) and boolean
12
+ * combinations thereof. Wraps `ShapeEnum`.
13
+ */
14
+ export class Shape {
15
+ // Internal ptr reference:
16
+ #ptr = null;
17
+
18
+ // Lifetimes are only to keep dependencies alive.
19
+ // Since JS won't garbage collect until there are no incoming edges.
20
+ #selfEdge = [];
21
+
22
+ #internalConstructor(symbol, ptr, selfEdge) {
23
+ if (symbol !== diplomatRuntime.internalConstructor) {
24
+ console.error("Shape is an Opaque type. You cannot call its constructor.");
25
+ return;
26
+ }
27
+ this.#ptr = ptr;
28
+ this.#selfEdge = selfEdge;
29
+
30
+ // Are we being borrowed? If not, we can register.
31
+ if (this.#selfEdge.length === 0) {
32
+ Shape_box_destroy_registry.register(this, this.#ptr);
33
+ }
34
+
35
+ return this;
36
+ }
37
+ /** @internal */
38
+ get ffiValue() {
39
+ return this.#ptr;
40
+ }
41
+
42
+
43
+ /**
44
+ * Sphere centered at (`cx`, `cy`, `cz`) (truncated to block coordinates,
45
+ * matching the old `shape_sphere`).
46
+ */
47
+ static sphere(cx, cy, cz, radius) {
48
+
49
+ const result = wasm.Shape_sphere(cx, cy, cz, radius);
50
+
51
+ try {
52
+ return new Shape(diplomatRuntime.internalConstructor, result, []);
53
+ }
54
+
55
+ finally {
56
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Axis-aligned box spanning the two corners (inclusive).
62
+ */
63
+ static cuboid(minX, minY, minZ, maxX, maxY, maxZ) {
64
+
65
+ const result = wasm.Shape_cuboid(minX, minY, minZ, maxX, maxY, maxZ);
66
+
67
+ try {
68
+ return new Shape(diplomatRuntime.internalConstructor, result, []);
69
+ }
70
+
71
+ finally {
72
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Ellipsoid centered at (`cx`, `cy`, `cz`) with per-axis radii.
78
+ */
79
+ static ellipsoid(cx, cy, cz, rx, ry, rz) {
80
+
81
+ const result = wasm.Shape_ellipsoid(cx, cy, cz, rx, ry, rz);
82
+
83
+ try {
84
+ return new Shape(diplomatRuntime.internalConstructor, result, []);
85
+ }
86
+
87
+ finally {
88
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Cylinder from base point along an axis vector.
94
+ */
95
+ static cylinder(bx, by, bz, ax, ay, az, radius, height) {
96
+
97
+ const result = wasm.Shape_cylinder(bx, by, bz, ax, ay, az, radius, height);
98
+
99
+ try {
100
+ return new Shape(diplomatRuntime.internalConstructor, result, []);
101
+ }
102
+
103
+ finally {
104
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
105
+ }
106
+ }
107
+
108
+ /**
109
+ * Cylinder spanning the segment between two points.
110
+ */
111
+ static cylinderBetween(x1, y1, z1, x2, y2, z2, radius) {
112
+
113
+ const result = wasm.Shape_cylinder_between(x1, y1, z1, x2, y2, z2, radius);
114
+
115
+ try {
116
+ return new Shape(diplomatRuntime.internalConstructor, result, []);
117
+ }
118
+
119
+ finally {
120
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Cone with apex at (`ax`, `ay`, `az`) opening along direction (`dx`, `dy`, `dz`).
126
+ */
127
+ static cone(ax, ay, az, dx, dy, dz, radius, height) {
128
+
129
+ const result = wasm.Shape_cone(ax, ay, az, dx, dy, dz, radius, height);
130
+
131
+ try {
132
+ return new Shape(diplomatRuntime.internalConstructor, result, []);
133
+ }
134
+
135
+ finally {
136
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
137
+ }
138
+ }
139
+
140
+ /**
141
+ * Torus centered at (`cx`, `cy`, `cz`) with the given major/minor radii and
142
+ * axis (`ax`, `ay`, `az`).
143
+ */
144
+ static torus(cx, cy, cz, majorR, minorR, ax, ay, az) {
145
+
146
+ const result = wasm.Shape_torus(cx, cy, cz, majorR, minorR, ax, ay, az);
147
+
148
+ try {
149
+ return new Shape(diplomatRuntime.internalConstructor, result, []);
150
+ }
151
+
152
+ finally {
153
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Rectangular pyramid: base center, half-extents, height, up-axis.
159
+ */
160
+ static pyramid(bx, by, bz, halfW, halfD, height, ax, ay, az) {
161
+
162
+ const result = wasm.Shape_pyramid(bx, by, bz, halfW, halfD, height, ax, ay, az);
163
+
164
+ try {
165
+ return new Shape(diplomatRuntime.internalConstructor, result, []);
166
+ }
167
+
168
+ finally {
169
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
170
+ }
171
+ }
172
+
173
+ /**
174
+ * Flat disk: center, radius, plane normal, thickness.
175
+ */
176
+ static disk(cx, cy, cz, radius, nx, ny, nz, thickness) {
177
+
178
+ const result = wasm.Shape_disk(cx, cy, cz, radius, nx, ny, nz, thickness);
179
+
180
+ try {
181
+ return new Shape(diplomatRuntime.internalConstructor, result, []);
182
+ }
183
+
184
+ finally {
185
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
186
+ }
187
+ }
188
+
189
+ /**
190
+ * Finite plane patch: origin, two spanning vectors `u`/`v`, extents along
191
+ * each, thickness.
192
+ */
193
+ static plane(ox, oy, oz, ux, uy, uz, vx, vy, vz, uExt, vExt, thickness) {
194
+
195
+ const result = wasm.Shape_plane(ox, oy, oz, ux, uy, uz, vx, vy, vz, uExt, vExt, thickness);
196
+
197
+ try {
198
+ return new Shape(diplomatRuntime.internalConstructor, result, []);
199
+ }
200
+
201
+ finally {
202
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
203
+ }
204
+ }
205
+
206
+ /**
207
+ * Filled triangle between three vertices, thickened by `thickness`.
208
+ */
209
+ static triangle(ax, ay, az, bx, by, bz, cx, cy, cz, thickness) {
210
+
211
+ const result = wasm.Shape_triangle(ax, ay, az, bx, by, bz, cx, cy, cz, thickness);
212
+
213
+ try {
214
+ return new Shape(diplomatRuntime.internalConstructor, result, []);
215
+ }
216
+
217
+ finally {
218
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
219
+ }
220
+ }
221
+
222
+ /**
223
+ * Line segment between two points, thickened by `thickness`.
224
+ */
225
+ static line(x1, y1, z1, x2, y2, z2, thickness) {
226
+
227
+ const result = wasm.Shape_line(x1, y1, z1, x2, y2, z2, thickness);
228
+
229
+ try {
230
+ return new Shape(diplomatRuntime.internalConstructor, result, []);
231
+ }
232
+
233
+ finally {
234
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
235
+ }
236
+ }
237
+
238
+ /**
239
+ * Bézier curve through `control_points` (flat `[x0, y0, z0, x1, y1, z1, …]`,
240
+ * so the length must be a non-zero multiple of 3), thickened by `thickness`
241
+ * and sampled at `resolution` steps.
242
+ */
243
+ static bezier(controlPoints, thickness, resolution) {
244
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
245
+
246
+ const controlPointsSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, controlPoints, "f32")));
247
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
248
+
249
+
250
+ const result = wasm.Shape_bezier(diplomatReceive.buffer, controlPointsSlice.ptr, thickness, resolution);
251
+
252
+ try {
253
+ if (!diplomatReceive.resultFlag) {
254
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
255
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
256
+ }
257
+ return new Shape(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
258
+ }
259
+
260
+ finally {
261
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
262
+ functionCleanupArena.free();
263
+
264
+ diplomatReceive.free();
265
+ }
266
+ }
267
+
268
+ /**
269
+ * Hollowed-out copy of this shape with the given wall thickness (clones the
270
+ * input, like the old `shape_hollow`).
271
+ */
272
+ hollow(thickness) {
273
+
274
+ const result = wasm.Shape_hollow(this.ffiValue, thickness);
275
+
276
+ try {
277
+ return new Shape(diplomatRuntime.internalConstructor, result, []);
278
+ }
279
+
280
+ finally {
281
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
282
+ }
283
+ }
284
+
285
+ /**
286
+ * Boolean union of this shape and `other` (clones both inputs).
287
+ */
288
+ unionWith(other) {
289
+
290
+ const result = wasm.Shape_union_with(this.ffiValue, other.ffiValue);
291
+
292
+ try {
293
+ return new Shape(diplomatRuntime.internalConstructor, result, []);
294
+ }
295
+
296
+ finally {
297
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
298
+ }
299
+ }
300
+
301
+ /**
302
+ * Boolean intersection of this shape and `other` (clones both inputs).
303
+ */
304
+ intersectionWith(other) {
305
+
306
+ const result = wasm.Shape_intersection_with(this.ffiValue, other.ffiValue);
307
+
308
+ try {
309
+ return new Shape(diplomatRuntime.internalConstructor, result, []);
310
+ }
311
+
312
+ finally {
313
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
314
+ }
315
+ }
316
+
317
+ /**
318
+ * Boolean difference: this shape minus `other` (clones both inputs).
319
+ */
320
+ differenceWith(other) {
321
+
322
+ const result = wasm.Shape_difference_with(this.ffiValue, other.ffiValue);
323
+
324
+ try {
325
+ return new Shape(diplomatRuntime.internalConstructor, result, []);
326
+ }
327
+
328
+ finally {
329
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
330
+ }
331
+ }
332
+
333
+ constructor(symbol, ptr, selfEdge) {
334
+ return this.#internalConstructor(...arguments)
335
+ }
336
+ }
@@ -0,0 +1,86 @@
1
+ // generated by diplomat-tool
2
+ import type { NucleationError } from "./NucleationError"
3
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
4
+
5
+
6
+
7
+ /**
8
+ * Ordering applied to region positions before bit assignment
9
+ * (PORTING rule 10).
10
+ */
11
+ export class SortStrategy {
12
+ /** @internal */
13
+ get ffiValue(): pointer;
14
+ /** @internal */
15
+ constructor();
16
+
17
+
18
+ /**
19
+ * Sort by Y ascending, then X, then Z (default Minecraft layer
20
+ * order). The first position after sorting is bit 0 (LSB).
21
+ */
22
+ static yxz(): SortStrategy;
23
+
24
+ /**
25
+ * Sort by X ascending, then Y, then Z.
26
+ */
27
+ static xyz(): SortStrategy;
28
+
29
+ /**
30
+ * Sort by Z ascending, then Y, then X.
31
+ */
32
+ static zyx(): SortStrategy;
33
+
34
+ /**
35
+ * Sort by Y descending, then X ascending, then Z ascending.
36
+ */
37
+ static yDescXz(): SortStrategy;
38
+
39
+ /**
40
+ * Sort by X descending, then Y ascending, then Z ascending.
41
+ */
42
+ static xDescYz(): SortStrategy;
43
+
44
+ /**
45
+ * Sort by Z descending, then Y ascending, then X ascending.
46
+ */
47
+ static zDescYx(): SortStrategy;
48
+
49
+ /**
50
+ * Old ABI name: `sort_strategy_descending`.
51
+ */
52
+ static descending(): SortStrategy;
53
+
54
+ /**
55
+ * Sort by Euclidean distance from the reference point, closest
56
+ * first (ties broken by Y, X, Z ascending).
57
+ */
58
+ static distanceFrom(x: number, y: number, z: number): SortStrategy;
59
+
60
+ /**
61
+ * Sort by Euclidean distance from the reference point, farthest
62
+ * first (ties broken by Y, X, Z descending).
63
+ */
64
+ static distanceFromDesc(x: number, y: number, z: number): SortStrategy;
65
+
66
+ /**
67
+ * Keep positions in the order they were added (no sorting). Useful
68
+ * when positions were ordered manually or box order matters.
69
+ */
70
+ static preserve(): SortStrategy;
71
+
72
+ /**
73
+ * Reverse of the order positions were added.
74
+ */
75
+ static reverse(): SortStrategy;
76
+
77
+ /**
78
+ * Parse from a name (e.g. "yxz", "descending", "preserve").
79
+ */
80
+ static fromString(s: string): SortStrategy;
81
+
82
+ /**
83
+ * The strategy name.
84
+ */
85
+ name(): string;
86
+ }