nucleation 0.6.0 → 0.7.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.
- package/AnimationEffect.d.mts +44 -0
- package/AnimationEffect.d.ts +1 -1
- package/Autostack.d.mts +43 -0
- package/Autostack.d.ts +2 -2
- package/BlockPos.d.mts +28 -0
- package/BlockState.d.mts +39 -0
- package/BlockState.d.ts +1 -1
- package/Blocks.d.mts +91 -0
- package/Blocks.d.ts +1 -1
- package/Brush.d.mts +99 -0
- package/Brush.d.ts +21 -12
- package/Brush.mjs +66 -9
- package/BuildAnimation.d.mts +142 -0
- package/BuildAnimation.d.ts +5 -5
- package/BuildingTool.d.mts +46 -0
- package/BuildingTool.d.ts +4 -4
- package/CellularSdfConfig.d.mts +22 -0
- package/CellularSdfConfig.d.ts +22 -0
- package/CellularSdfConfig.mjs +69 -0
- package/ChunkMeshResult.d.mts +75 -0
- package/ChunkMeshResult.d.ts +7 -7
- package/CircuitBuilder.d.mts +118 -0
- package/CircuitBuilder.d.ts +6 -6
- package/Curve3D.d.mts +27 -0
- package/Curve3D.d.ts +1 -1
- package/DefinitionRegion.d.mts +274 -0
- package/DefinitionRegion.d.ts +5 -5
- package/Diff.d.mts +88 -0
- package/Diff.d.ts +2 -2
- package/Dimensions.d.mts +28 -0
- package/DistanceField.d.mts +39 -0
- package/DistanceField.d.ts +1 -1
- package/ExecutionMode.d.mts +42 -0
- package/ExecutionMode.d.ts +2 -2
- package/Field3.d.mts +40 -0
- package/Field3.d.ts +40 -0
- package/Field3.mjs +160 -0
- package/FieldProgram.d.mts +40 -0
- package/FieldProgram.d.ts +40 -0
- package/FieldProgram.mjs +167 -0
- package/FieldProgramBinaryOp.d.mts +42 -0
- package/FieldProgramBinaryOp.d.ts +42 -0
- package/FieldProgramBinaryOp.mjs +118 -0
- package/FieldProgramBuilder.d.mts +104 -0
- package/FieldProgramBuilder.d.ts +104 -0
- package/FieldProgramBuilder.mjs +486 -0
- package/FieldProgramDistanceKind.d.mts +26 -0
- package/FieldProgramDistanceKind.d.ts +26 -0
- package/FieldProgramDistanceKind.mjs +78 -0
- package/FieldProgramUnaryOp.d.mts +34 -0
- package/FieldProgramUnaryOp.d.ts +34 -0
- package/FieldProgramUnaryOp.mjs +102 -0
- package/FieldProgramValueType.d.mts +25 -0
- package/FieldProgramValueType.d.ts +25 -0
- package/FieldProgramValueType.mjs +75 -0
- package/FieldRange.d.mts +15 -0
- package/FieldRange.d.ts +15 -0
- package/FieldRange.mjs +108 -0
- package/Fingerprint.d.mts +44 -0
- package/Fingerprint.d.ts +2 -2
- package/GeneratedChunk.d.mts +35 -0
- package/GeneratedChunk.d.ts +35 -0
- package/GeneratedChunk.mjs +178 -0
- package/GeneratedChunkCoverage.d.mts +25 -0
- package/GeneratedChunkCoverage.d.ts +25 -0
- package/GeneratedChunkCoverage.mjs +75 -0
- package/GeneratedChunkOverlayMode.d.mts +24 -0
- package/GeneratedChunkOverlayMode.d.ts +24 -0
- package/GeneratedChunkOverlayMode.mjs +72 -0
- package/GeneratedWorldStream.d.mts +28 -0
- package/GeneratedWorldStream.d.ts +28 -0
- package/GeneratedWorldStream.mjs +86 -0
- package/Geo.d.mts +41 -0
- package/Geo.d.ts +2 -2
- package/InterpolationSpace.d.mts +25 -0
- package/IoLayout.d.mts +26 -0
- package/IoLayoutBuilder.d.mts +73 -0
- package/IoLayoutBuilder.d.ts +4 -4
- package/IoType.d.mts +41 -0
- package/ItemModelConfig.d.mts +65 -0
- package/ItemModelConfig.d.ts +1 -1
- package/ItemModelPackBuilder.d.mts +32 -0
- package/ItemModelPackBuilder.d.ts +1 -1
- package/ItemModelResult.d.mts +72 -0
- package/ItemModelResult.d.ts +7 -7
- package/ItemScale.d.mts +31 -0
- package/LayoutFunction.d.mts +52 -0
- package/LayoutFunction.d.ts +1 -1
- package/MchprsWorld.d.mts +131 -0
- package/MchprsWorld.d.ts +3 -3
- package/MeshBounds.d.mts +40 -0
- package/MeshConfig.d.mts +101 -0
- package/MeshConfig.d.ts +1 -1
- package/MeshJob.d.mts +44 -0
- package/MeshJob.d.ts +7 -7
- package/MeshPhase.d.mts +38 -0
- package/MeshProgress.d.mts +32 -0
- package/MeshProgress.d.ts +1 -1
- package/MeshResult.d.mts +65 -0
- package/MeshResult.d.ts +5 -5
- package/MultiMeshResult.d.mts +50 -0
- package/MultiMeshResult.d.ts +5 -5
- package/Nbt.d.mts +50 -0
- package/Nbt.d.ts +1 -1
- package/NucleationError.d.mts +41 -0
- package/NucleationError.d.ts +5 -0
- package/NucleationError.mjs +8 -1
- package/OutputCondition.d.mts +45 -0
- package/OutputCondition.d.ts +1 -1
- package/Palette.d.mts +145 -0
- package/Palette.d.ts +9 -1
- package/Palette.mjs +35 -0
- package/PaletteBuilder.d.mts +119 -0
- package/PaletteBuilder.d.ts +2 -2
- package/RawMeshExport.d.mts +74 -0
- package/RawMeshExport.d.ts +4 -4
- package/RedstoneGraph.d.mts +58 -0
- package/RedstoneGraph.d.ts +1 -1
- package/RegionBounds.d.mts +41 -0
- package/RenderConfig.d.mts +101 -0
- package/RenderConfig.d.ts +1 -1
- package/Renderer.d.mts +51 -0
- package/Renderer.d.ts +4 -4
- package/ResourcePack.d.mts +105 -0
- package/ResourcePack.d.ts +3 -3
- package/ResourcePackList.d.mts +32 -0
- package/Schematic.d.mts +734 -0
- package/Schematic.d.ts +4 -4
- package/SchematicBuilder.d.mts +103 -0
- package/SchematicBuilder.d.ts +2 -2
- package/SchematicRegions.d.mts +93 -0
- package/SchematicRegions.d.ts +3 -3
- package/Scripting.d.mts +40 -0
- package/Scripting.d.ts +2 -2
- package/Sdf.d.mts +234 -0
- package/Sdf.d.ts +208 -13
- package/Sdf.mjs +1106 -11
- package/SdfAxis.d.mts +25 -0
- package/SdfAxis.d.ts +25 -0
- package/SdfAxis.mjs +75 -0
- package/SdfBounds.d.mts +19 -0
- package/SdfBounds.d.ts +19 -0
- package/SdfBounds.mjs +160 -0
- package/SdfCellMode.d.mts +26 -0
- package/SdfCellMode.d.ts +26 -0
- package/SdfCellMode.mjs +78 -0
- package/SdfNormal.d.mts +16 -0
- package/SdfNormal.d.ts +16 -0
- package/SdfNormal.mjs +121 -0
- package/Shape.d.mts +143 -0
- package/Shape.d.ts +2 -2
- package/SortStrategy.d.mts +86 -0
- package/SortStrategy.d.ts +1 -1
- package/Store.d.mts +83 -0
- package/Store.d.ts +2 -2
- package/StoreIo.d.mts +71 -0
- package/StoreIo.d.ts +2 -2
- package/TextureAtlas.d.mts +40 -0
- package/TextureAtlas.d.ts +4 -4
- package/TextureInfo.d.mts +34 -0
- package/TypedCircuitExecutor.d.mts +101 -0
- package/TypedCircuitExecutor.d.ts +6 -6
- package/Value.d.mts +73 -0
- package/Value.d.ts +1 -1
- package/VideoConfig.d.mts +15 -0
- package/Voxelizer.d.mts +58 -0
- package/Voxelizer.d.ts +4 -4
- package/WorldChunkView.d.mts +75 -0
- package/WorldChunkView.d.ts +2 -2
- package/WorldGenerator.d.mts +75 -0
- package/WorldGenerator.d.ts +75 -0
- package/WorldGenerator.mjs +255 -0
- package/WorldSink.d.mts +50 -0
- package/WorldSink.d.ts +2 -2
- package/WorldStream.d.mts +45 -0
- package/WorldStream.d.ts +2 -2
- package/WsPartitionHints.d.mts +29 -0
- package/WsPartitionHints.d.ts +1 -1
- package/WsProfile.d.mts +46 -0
- package/WsProfile.d.ts +1 -1
- package/WsRunResult.d.mts +83 -0
- package/WsRunResult.d.ts +5 -5
- package/WsSegmentJob.d.mts +28 -0
- package/WsSegmentJob.d.ts +1 -1
- package/diplomat-runtime.d.mts +15 -0
- package/index.d.mts +177 -0
- package/index.d.ts +106 -70
- package/index.mjs +37 -1
- package/nucleation.wasm +0 -0
- package/package.json +2 -1
package/Sdf.mjs
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
|
+
import { Field3 } from "./Field3.mjs"
|
|
3
|
+
import { FieldProgram } from "./FieldProgram.mjs"
|
|
2
4
|
import { NucleationError } from "./NucleationError.mjs"
|
|
3
5
|
import { Schematic } from "./Schematic.mjs"
|
|
6
|
+
import { SdfAxis } from "./SdfAxis.mjs"
|
|
7
|
+
import { SdfBounds } from "./SdfBounds.mjs"
|
|
8
|
+
import { SdfCellMode } from "./SdfCellMode.mjs"
|
|
9
|
+
import { SdfNormal } from "./SdfNormal.mjs"
|
|
10
|
+
import { Shape } from "./Shape.mjs"
|
|
4
11
|
import wasm from "./diplomat-wasm.mjs";
|
|
5
12
|
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
6
13
|
|
|
@@ -9,8 +16,12 @@ const Sdf_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
|
9
16
|
});
|
|
10
17
|
|
|
11
18
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
19
|
+
* An immutable, composable signed-distance-field expression graph.
|
|
20
|
+
*
|
|
21
|
+
* Primitive constructors and every combinator return a new graph, so values
|
|
22
|
+
* can be shared safely between Flow nodes and across Kotlin/Java, JavaScript,
|
|
23
|
+
* and Python bindings. JSON is retained only for explicit import/export and
|
|
24
|
+
* the legacy sampling helpers.
|
|
14
25
|
*/
|
|
15
26
|
export class Sdf {
|
|
16
27
|
// Internal ptr reference:
|
|
@@ -41,12 +52,1098 @@ export class Sdf {
|
|
|
41
52
|
}
|
|
42
53
|
|
|
43
54
|
|
|
55
|
+
static sphere(radius) {
|
|
56
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
const result = wasm.Sdf_sphere(diplomatReceive.buffer, radius);
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
if (!diplomatReceive.resultFlag) {
|
|
63
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
64
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
65
|
+
}
|
|
66
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
finally {
|
|
70
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
71
|
+
diplomatReceive.free();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Axis-aligned rounded box, centered at the origin.
|
|
77
|
+
*/
|
|
78
|
+
static boxShape(halfX, halfY, halfZ, rounding) {
|
|
79
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
const result = wasm.Sdf_box_shape(diplomatReceive.buffer, halfX, halfY, halfZ, rounding);
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
if (!diplomatReceive.resultFlag) {
|
|
86
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
87
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
88
|
+
}
|
|
89
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
finally {
|
|
93
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
94
|
+
diplomatReceive.free();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
static ellipsoid(radiusX, radiusY, radiusZ) {
|
|
99
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
const result = wasm.Sdf_ellipsoid(diplomatReceive.buffer, radiusX, radiusY, radiusZ);
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
if (!diplomatReceive.resultFlag) {
|
|
106
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
107
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
108
|
+
}
|
|
109
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
finally {
|
|
113
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
114
|
+
diplomatReceive.free();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
static torus(majorRadius, minorRadius) {
|
|
119
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
const result = wasm.Sdf_torus(diplomatReceive.buffer, majorRadius, minorRadius);
|
|
123
|
+
|
|
124
|
+
try {
|
|
125
|
+
if (!diplomatReceive.resultFlag) {
|
|
126
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
127
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
128
|
+
}
|
|
129
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
finally {
|
|
133
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
134
|
+
diplomatReceive.free();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Torus ring cut down to an arc. `cap_angle_degrees` is the half-aperture
|
|
140
|
+
* in `(0, 180]`, measured from +X and mirrored across X; `180` is a full
|
|
141
|
+
* torus.
|
|
142
|
+
*/
|
|
143
|
+
static cappedTorus(majorRadius, minorRadius, capAngleDegrees) {
|
|
144
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
const result = wasm.Sdf_capped_torus(diplomatReceive.buffer, majorRadius, minorRadius, capAngleDegrees);
|
|
148
|
+
|
|
149
|
+
try {
|
|
150
|
+
if (!diplomatReceive.resultFlag) {
|
|
151
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
152
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
153
|
+
}
|
|
154
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
finally {
|
|
158
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
159
|
+
diplomatReceive.free();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Chain-link shape: a torus stretched along Z by `half_length` and
|
|
165
|
+
* capped by two half-tori. `half_length: 0` is a plain torus.
|
|
166
|
+
*/
|
|
167
|
+
static link(majorRadius, minorRadius, halfLength) {
|
|
168
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
const result = wasm.Sdf_link(diplomatReceive.buffer, majorRadius, minorRadius, halfLength);
|
|
172
|
+
|
|
173
|
+
try {
|
|
174
|
+
if (!diplomatReceive.resultFlag) {
|
|
175
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
176
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
177
|
+
}
|
|
178
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
finally {
|
|
182
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
183
|
+
diplomatReceive.free();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
static capsule(ax, ay, az, bx, by, bz, radius) {
|
|
188
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
const result = wasm.Sdf_capsule(diplomatReceive.buffer, ax, ay, az, bx, by, bz, radius);
|
|
192
|
+
|
|
193
|
+
try {
|
|
194
|
+
if (!diplomatReceive.resultFlag) {
|
|
195
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
196
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
197
|
+
}
|
|
198
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
finally {
|
|
202
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
203
|
+
diplomatReceive.free();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Convex hull of two spheres: a capsule with a linear taper between
|
|
209
|
+
* `r1` (at `a`) and `r2` (at `b`) instead of one constant radius.
|
|
210
|
+
*/
|
|
211
|
+
static roundCone(ax, ay, az, bx, by, bz, r1, r2) {
|
|
212
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
const result = wasm.Sdf_round_cone(diplomatReceive.buffer, ax, ay, az, bx, by, bz, r1, r2);
|
|
216
|
+
|
|
217
|
+
try {
|
|
218
|
+
if (!diplomatReceive.resultFlag) {
|
|
219
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
220
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
221
|
+
}
|
|
222
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
finally {
|
|
226
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
227
|
+
diplomatReceive.free();
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Sphere of `radius` intersected with an infinite cone of
|
|
233
|
+
* half-aperture `angle_degrees` (in `(0, 180)`) from the +Y axis,
|
|
234
|
+
* apex at the origin.
|
|
235
|
+
*/
|
|
236
|
+
static solidAngle(radius, angleDegrees) {
|
|
237
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
const result = wasm.Sdf_solid_angle(diplomatReceive.buffer, radius, angleDegrees);
|
|
241
|
+
|
|
242
|
+
try {
|
|
243
|
+
if (!diplomatReceive.resultFlag) {
|
|
244
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
245
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
246
|
+
}
|
|
247
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
finally {
|
|
251
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
252
|
+
diplomatReceive.free();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Sphere cut by the plane `y = height`, keeping the cap above it
|
|
258
|
+
* (a dome). `height` must be strictly between `-radius` and
|
|
259
|
+
* `radius`.
|
|
260
|
+
*/
|
|
261
|
+
static cutSphere(radius, height) {
|
|
262
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
const result = wasm.Sdf_cut_sphere(diplomatReceive.buffer, radius, height);
|
|
266
|
+
|
|
267
|
+
try {
|
|
268
|
+
if (!diplomatReceive.resultFlag) {
|
|
269
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
270
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
271
|
+
}
|
|
272
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
finally {
|
|
276
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
277
|
+
diplomatReceive.free();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Open (hollow) shell of `cut_sphere`'s dome: just the spherical
|
|
283
|
+
* cap surface, offset by `thickness`, with no flat floor.
|
|
284
|
+
*/
|
|
285
|
+
static cutHollowSphere(radius, height, thickness) {
|
|
286
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
const result = wasm.Sdf_cut_hollow_sphere(diplomatReceive.buffer, radius, height, thickness);
|
|
290
|
+
|
|
291
|
+
try {
|
|
292
|
+
if (!diplomatReceive.resultFlag) {
|
|
293
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
294
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
295
|
+
}
|
|
296
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
finally {
|
|
300
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
301
|
+
diplomatReceive.free();
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
static cappedCylinder(radius, halfHeight) {
|
|
306
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
const result = wasm.Sdf_capped_cylinder(diplomatReceive.buffer, radius, halfHeight);
|
|
310
|
+
|
|
311
|
+
try {
|
|
312
|
+
if (!diplomatReceive.resultFlag) {
|
|
313
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
314
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
315
|
+
}
|
|
316
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
finally {
|
|
320
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
321
|
+
diplomatReceive.free();
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Exact Y-axis cylinder with infinite extent. Sampling requires explicit bounds.
|
|
327
|
+
*/
|
|
328
|
+
static infiniteCylinder(radius) {
|
|
329
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
const result = wasm.Sdf_infinite_cylinder(diplomatReceive.buffer, radius);
|
|
333
|
+
|
|
334
|
+
try {
|
|
335
|
+
if (!diplomatReceive.resultFlag) {
|
|
336
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
337
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
338
|
+
}
|
|
339
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
finally {
|
|
343
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
344
|
+
diplomatReceive.free();
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
static cappedCone(halfHeight, bottomRadius, topRadius) {
|
|
349
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
const result = wasm.Sdf_capped_cone(diplomatReceive.buffer, halfHeight, bottomRadius, topRadius);
|
|
353
|
+
|
|
354
|
+
try {
|
|
355
|
+
if (!diplomatReceive.resultFlag) {
|
|
356
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
357
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
358
|
+
}
|
|
359
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
finally {
|
|
363
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
364
|
+
diplomatReceive.free();
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
static plane(normalX, normalY, normalZ, offset) {
|
|
369
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
const result = wasm.Sdf_plane(diplomatReceive.buffer, normalX, normalY, normalZ, offset);
|
|
373
|
+
|
|
374
|
+
try {
|
|
375
|
+
if (!diplomatReceive.resultFlag) {
|
|
376
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
377
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
378
|
+
}
|
|
379
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
finally {
|
|
383
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
384
|
+
diplomatReceive.free();
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
static octahedron(size) {
|
|
389
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
const result = wasm.Sdf_octahedron(diplomatReceive.buffer, size);
|
|
393
|
+
|
|
394
|
+
try {
|
|
395
|
+
if (!diplomatReceive.resultFlag) {
|
|
396
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
397
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
398
|
+
}
|
|
399
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
finally {
|
|
403
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
404
|
+
diplomatReceive.free();
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
static hexPrism(radius, halfHeight) {
|
|
409
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
const result = wasm.Sdf_hex_prism(diplomatReceive.buffer, radius, halfHeight);
|
|
413
|
+
|
|
414
|
+
try {
|
|
415
|
+
if (!diplomatReceive.resultFlag) {
|
|
416
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
417
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
418
|
+
}
|
|
419
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
finally {
|
|
423
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
424
|
+
diplomatReceive.free();
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
static superPrism(halfX, halfY, halfZ, exponent) {
|
|
429
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
const result = wasm.Sdf_super_prism(diplomatReceive.buffer, halfX, halfY, halfZ, exponent);
|
|
433
|
+
|
|
434
|
+
try {
|
|
435
|
+
if (!diplomatReceive.resultFlag) {
|
|
436
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
437
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
438
|
+
}
|
|
439
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
finally {
|
|
443
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
444
|
+
diplomatReceive.free();
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Hollow wireframe box: only the 12 edge beams are solid.
|
|
450
|
+
*/
|
|
451
|
+
static boxFrame(halfX, halfY, halfZ, thickness) {
|
|
452
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
453
|
+
|
|
454
|
+
|
|
455
|
+
const result = wasm.Sdf_box_frame(diplomatReceive.buffer, halfX, halfY, halfZ, thickness);
|
|
456
|
+
|
|
457
|
+
try {
|
|
458
|
+
if (!diplomatReceive.resultFlag) {
|
|
459
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
460
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
461
|
+
}
|
|
462
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
finally {
|
|
466
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
467
|
+
diplomatReceive.free();
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Exact but unbounded Y-axis infinite cone: apex at the origin,
|
|
473
|
+
* single nappe opening along +Y, half-aperture `angle_degrees`
|
|
474
|
+
* strictly in `(0, 90)`.
|
|
475
|
+
*/
|
|
476
|
+
static infiniteCone(angleDegrees) {
|
|
477
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
const result = wasm.Sdf_infinite_cone(diplomatReceive.buffer, angleDegrees);
|
|
481
|
+
|
|
482
|
+
try {
|
|
483
|
+
if (!diplomatReceive.resultFlag) {
|
|
484
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
485
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
486
|
+
}
|
|
487
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
finally {
|
|
491
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
492
|
+
diplomatReceive.free();
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Square-base pyramid, vertically centered: base (half-extent
|
|
498
|
+
* `half_base`) at `y = -height/2`, apex at `y = height/2`. `height`
|
|
499
|
+
* must be at least the smallest positive normal `f32`.
|
|
500
|
+
*/
|
|
501
|
+
static squarePyramid(halfBase, height) {
|
|
502
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
const result = wasm.Sdf_square_pyramid(diplomatReceive.buffer, halfBase, height);
|
|
506
|
+
|
|
507
|
+
try {
|
|
508
|
+
if (!diplomatReceive.resultFlag) {
|
|
509
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
510
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
511
|
+
}
|
|
512
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
finally {
|
|
516
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
517
|
+
diplomatReceive.free();
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
static cells(frequency, seed, jitter, mode, threshold) {
|
|
522
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
const result = wasm.Sdf_cells(diplomatReceive.buffer, frequency, seed, jitter, mode.ffiValue, threshold);
|
|
526
|
+
|
|
527
|
+
try {
|
|
528
|
+
if (!diplomatReceive.resultFlag) {
|
|
529
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
530
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
531
|
+
}
|
|
532
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
finally {
|
|
536
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
537
|
+
diplomatReceive.free();
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
unionWith(other) {
|
|
542
|
+
|
|
543
|
+
const result = wasm.Sdf_union_with(this.ffiValue, other.ffiValue);
|
|
544
|
+
|
|
545
|
+
try {
|
|
546
|
+
return new Sdf(diplomatRuntime.internalConstructor, result, []);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
finally {
|
|
550
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
intersectionWith(other) {
|
|
555
|
+
|
|
556
|
+
const result = wasm.Sdf_intersection_with(this.ffiValue, other.ffiValue);
|
|
557
|
+
|
|
558
|
+
try {
|
|
559
|
+
return new Sdf(diplomatRuntime.internalConstructor, result, []);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
finally {
|
|
563
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
subtract(other) {
|
|
568
|
+
|
|
569
|
+
const result = wasm.Sdf_subtract(this.ffiValue, other.ffiValue);
|
|
570
|
+
|
|
571
|
+
try {
|
|
572
|
+
return new Sdf(diplomatRuntime.internalConstructor, result, []);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
finally {
|
|
576
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
smoothUnion(other, radius) {
|
|
581
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
const result = wasm.Sdf_smooth_union(diplomatReceive.buffer, this.ffiValue, other.ffiValue, radius);
|
|
585
|
+
|
|
586
|
+
try {
|
|
587
|
+
if (!diplomatReceive.resultFlag) {
|
|
588
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
589
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
590
|
+
}
|
|
591
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
finally {
|
|
595
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
596
|
+
diplomatReceive.free();
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
smoothSubtract(other, radius) {
|
|
601
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
const result = wasm.Sdf_smooth_subtract(diplomatReceive.buffer, this.ffiValue, other.ffiValue, radius);
|
|
605
|
+
|
|
606
|
+
try {
|
|
607
|
+
if (!diplomatReceive.resultFlag) {
|
|
608
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
609
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
610
|
+
}
|
|
611
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
finally {
|
|
615
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
616
|
+
diplomatReceive.free();
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
smoothIntersection(other, radius) {
|
|
621
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
const result = wasm.Sdf_smooth_intersection(diplomatReceive.buffer, this.ffiValue, other.ffiValue, radius);
|
|
625
|
+
|
|
626
|
+
try {
|
|
627
|
+
if (!diplomatReceive.resultFlag) {
|
|
628
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
629
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
630
|
+
}
|
|
631
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
finally {
|
|
635
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
636
|
+
diplomatReceive.free();
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
rounded(radius) {
|
|
641
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
const result = wasm.Sdf_rounded(diplomatReceive.buffer, this.ffiValue, radius);
|
|
645
|
+
|
|
646
|
+
try {
|
|
647
|
+
if (!diplomatReceive.resultFlag) {
|
|
648
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
649
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
650
|
+
}
|
|
651
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
finally {
|
|
655
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
656
|
+
diplomatReceive.free();
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
shell(thickness) {
|
|
661
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
662
|
+
|
|
663
|
+
|
|
664
|
+
const result = wasm.Sdf_shell(diplomatReceive.buffer, this.ffiValue, thickness);
|
|
665
|
+
|
|
666
|
+
try {
|
|
667
|
+
if (!diplomatReceive.resultFlag) {
|
|
668
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
669
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
670
|
+
}
|
|
671
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
finally {
|
|
675
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
676
|
+
diplomatReceive.free();
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Symmetric difference (XOR): solid where exactly one of `self`/
|
|
682
|
+
* `other` is solid.
|
|
683
|
+
*/
|
|
684
|
+
xorWith(other) {
|
|
685
|
+
|
|
686
|
+
const result = wasm.Sdf_xor_with(this.ffiValue, other.ffiValue);
|
|
687
|
+
|
|
688
|
+
try {
|
|
689
|
+
return new Sdf(diplomatRuntime.internalConstructor, result, []);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
finally {
|
|
693
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Stretches this graph with IQ's origin-centered `opElongate` fold.
|
|
699
|
+
* Exactness requires a suitable origin-centered, reflection-symmetric
|
|
700
|
+
* child; off-center/asymmetric children are mirrored and produce only
|
|
701
|
+
* an estimate. Half-lengths must be finite and non-negative, with at
|
|
702
|
+
* least one strictly positive.
|
|
703
|
+
*/
|
|
704
|
+
elongate(halfX, halfY, halfZ) {
|
|
705
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
const result = wasm.Sdf_elongate(diplomatReceive.buffer, this.ffiValue, halfX, halfY, halfZ);
|
|
709
|
+
|
|
710
|
+
try {
|
|
711
|
+
if (!diplomatReceive.resultFlag) {
|
|
712
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
713
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
714
|
+
}
|
|
715
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
finally {
|
|
719
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
720
|
+
diplomatReceive.free();
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
translate(x, y, z) {
|
|
725
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
726
|
+
|
|
727
|
+
|
|
728
|
+
const result = wasm.Sdf_translate(diplomatReceive.buffer, this.ffiValue, x, y, z);
|
|
729
|
+
|
|
730
|
+
try {
|
|
731
|
+
if (!diplomatReceive.resultFlag) {
|
|
732
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
733
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
734
|
+
}
|
|
735
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
finally {
|
|
739
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
740
|
+
diplomatReceive.free();
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
rotate(xDegrees, yDegrees, zDegrees) {
|
|
745
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
const result = wasm.Sdf_rotate(diplomatReceive.buffer, this.ffiValue, xDegrees, yDegrees, zDegrees);
|
|
749
|
+
|
|
750
|
+
try {
|
|
751
|
+
if (!diplomatReceive.resultFlag) {
|
|
752
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
753
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
754
|
+
}
|
|
755
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
finally {
|
|
759
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
760
|
+
diplomatReceive.free();
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
scale(factor) {
|
|
765
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
const result = wasm.Sdf_scale(diplomatReceive.buffer, this.ffiValue, factor);
|
|
769
|
+
|
|
770
|
+
try {
|
|
771
|
+
if (!diplomatReceive.resultFlag) {
|
|
772
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
773
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
774
|
+
}
|
|
775
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
finally {
|
|
779
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
780
|
+
diplomatReceive.free();
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
mirror(axis) {
|
|
785
|
+
|
|
786
|
+
const result = wasm.Sdf_mirror(this.ffiValue, axis.ffiValue);
|
|
787
|
+
|
|
788
|
+
try {
|
|
789
|
+
return new Sdf(diplomatRuntime.internalConstructor, result, []);
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
finally {
|
|
793
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* Twists this graph about the Y axis by `amount` radians per unit
|
|
799
|
+
* Y (IQ's `opTwist`). *Distorted*: not guaranteed exact even when
|
|
800
|
+
* `self` is.
|
|
801
|
+
*/
|
|
802
|
+
twist(amount) {
|
|
803
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
const result = wasm.Sdf_twist(diplomatReceive.buffer, this.ffiValue, amount);
|
|
807
|
+
|
|
808
|
+
try {
|
|
809
|
+
if (!diplomatReceive.resultFlag) {
|
|
810
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
811
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
812
|
+
}
|
|
813
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
finally {
|
|
817
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
818
|
+
diplomatReceive.free();
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
* Cheaply bends this graph by `amount` radians per unit X (IQ's
|
|
824
|
+
* `opCheapBend`). *Distorted*: not guaranteed exact even when
|
|
825
|
+
* `self` is.
|
|
826
|
+
*/
|
|
827
|
+
bend(amount) {
|
|
828
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
const result = wasm.Sdf_bend(diplomatReceive.buffer, this.ffiValue, amount);
|
|
832
|
+
|
|
833
|
+
try {
|
|
834
|
+
if (!diplomatReceive.resultFlag) {
|
|
835
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
836
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
837
|
+
}
|
|
838
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
finally {
|
|
842
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
843
|
+
diplomatReceive.free();
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
repeatInfinite(spacingX, spacingY, spacingZ) {
|
|
848
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
849
|
+
|
|
850
|
+
|
|
851
|
+
const result = wasm.Sdf_repeat_infinite(diplomatReceive.buffer, this.ffiValue, spacingX, spacingY, spacingZ);
|
|
852
|
+
|
|
853
|
+
try {
|
|
854
|
+
if (!diplomatReceive.resultFlag) {
|
|
855
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
856
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
857
|
+
}
|
|
858
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
finally {
|
|
862
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
863
|
+
diplomatReceive.free();
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
repeatCounted(spacingX, spacingY, spacingZ, countX, countY, countZ) {
|
|
868
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
const result = wasm.Sdf_repeat_counted(diplomatReceive.buffer, this.ffiValue, spacingX, spacingY, spacingZ, countX, countY, countZ);
|
|
872
|
+
|
|
873
|
+
try {
|
|
874
|
+
if (!diplomatReceive.resultFlag) {
|
|
875
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
876
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
877
|
+
}
|
|
878
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
finally {
|
|
882
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
883
|
+
diplomatReceive.free();
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* Finite rigid instances of this graph at arbitrary XYZ offsets.
|
|
889
|
+
* `offsets` is flat `[x0, y0, z0, x1, y1, z1, ...]` and may contain
|
|
890
|
+
* at most 4096 points.
|
|
891
|
+
*/
|
|
892
|
+
repeatPoints(offsets) {
|
|
893
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
894
|
+
|
|
895
|
+
const offsetsSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, offsets, "f32")));
|
|
896
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
const result = wasm.Sdf_repeat_points(diplomatReceive.buffer, this.ffiValue, offsetsSlice.ptr);
|
|
900
|
+
|
|
901
|
+
try {
|
|
902
|
+
if (!diplomatReceive.resultFlag) {
|
|
903
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
904
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
905
|
+
}
|
|
906
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
finally {
|
|
910
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
911
|
+
functionCleanupArena.free();
|
|
912
|
+
|
|
913
|
+
diplomatReceive.free();
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
displace(amplitude, frequency, seed, octaves) {
|
|
918
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
const result = wasm.Sdf_displace(diplomatReceive.buffer, this.ffiValue, amplitude, frequency, seed, octaves);
|
|
922
|
+
|
|
923
|
+
try {
|
|
924
|
+
if (!diplomatReceive.resultFlag) {
|
|
925
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
926
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
927
|
+
}
|
|
928
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
finally {
|
|
932
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
933
|
+
diplomatReceive.free();
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
* Offset this surface by a reusable scalar field. The resulting zero
|
|
939
|
+
* set is generally an approximate field, not an exact distance field.
|
|
940
|
+
*/
|
|
941
|
+
offsetByField(field, amplitude) {
|
|
942
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
const result = wasm.Sdf_offset_by_field(diplomatReceive.buffer, this.ffiValue, field.ffiValue, amplitude);
|
|
946
|
+
|
|
947
|
+
try {
|
|
948
|
+
if (!diplomatReceive.resultFlag) {
|
|
949
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
950
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
951
|
+
}
|
|
952
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
finally {
|
|
956
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
957
|
+
diplomatReceive.free();
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
warp(amplitude, frequency, seed) {
|
|
962
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
963
|
+
|
|
964
|
+
|
|
965
|
+
const result = wasm.Sdf_warp(diplomatReceive.buffer, this.ffiValue, amplitude, frequency, seed);
|
|
966
|
+
|
|
967
|
+
try {
|
|
968
|
+
if (!diplomatReceive.resultFlag) {
|
|
969
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
970
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
971
|
+
}
|
|
972
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
finally {
|
|
976
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
977
|
+
diplomatReceive.free();
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
evalAt(x, y, z) {
|
|
982
|
+
|
|
983
|
+
const result = wasm.Sdf_eval_at(this.ffiValue, x, y, z);
|
|
984
|
+
|
|
985
|
+
try {
|
|
986
|
+
return result;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
finally {
|
|
990
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
normal(x, y, z, epsilon) {
|
|
995
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 13, 4, true);
|
|
996
|
+
|
|
997
|
+
|
|
998
|
+
const result = wasm.Sdf_normal(diplomatReceive.buffer, this.ffiValue, x, y, z, epsilon);
|
|
999
|
+
|
|
1000
|
+
try {
|
|
1001
|
+
if (!diplomatReceive.resultFlag) {
|
|
1002
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1003
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1004
|
+
}
|
|
1005
|
+
return SdfNormal._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer);
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
finally {
|
|
1009
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1010
|
+
diplomatReceive.free();
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
/**
|
|
1015
|
+
* Conservative finite bounds, or `NotFound` for an unbounded graph
|
|
1016
|
+
* (a bare `plane` or `infinite_cylinder` has no finite extent).
|
|
1017
|
+
*/
|
|
1018
|
+
bounds() {
|
|
1019
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 25, 4, true);
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
const result = wasm.Sdf_bounds(diplomatReceive.buffer, this.ffiValue);
|
|
1023
|
+
|
|
1024
|
+
try {
|
|
1025
|
+
if (!diplomatReceive.resultFlag) {
|
|
1026
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1027
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1028
|
+
}
|
|
1029
|
+
return SdfBounds._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer);
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
finally {
|
|
1033
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1034
|
+
diplomatReceive.free();
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
toShape() {
|
|
1039
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
1040
|
+
|
|
1041
|
+
|
|
1042
|
+
const result = wasm.Sdf_to_shape(diplomatReceive.buffer, this.ffiValue);
|
|
1043
|
+
|
|
1044
|
+
try {
|
|
1045
|
+
if (!diplomatReceive.resultFlag) {
|
|
1046
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1047
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1048
|
+
}
|
|
1049
|
+
return new Shape(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
finally {
|
|
1053
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1054
|
+
diplomatReceive.free();
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
toShapeBounded(minX, minY, minZ, maxX, maxY, maxZ) {
|
|
1059
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
1060
|
+
|
|
1061
|
+
|
|
1062
|
+
const result = wasm.Sdf_to_shape_bounded(diplomatReceive.buffer, this.ffiValue, minX, minY, minZ, maxX, maxY, maxZ);
|
|
1063
|
+
|
|
1064
|
+
try {
|
|
1065
|
+
if (!diplomatReceive.resultFlag) {
|
|
1066
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1067
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1068
|
+
}
|
|
1069
|
+
return new Shape(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
finally {
|
|
1073
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1074
|
+
diplomatReceive.free();
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
static fromJsonString(json) {
|
|
1079
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
1080
|
+
|
|
1081
|
+
const jsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, json)));
|
|
1082
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
1083
|
+
|
|
1084
|
+
|
|
1085
|
+
const result = wasm.Sdf_from_json_string(diplomatReceive.buffer, jsonSlice.ptr);
|
|
1086
|
+
|
|
1087
|
+
try {
|
|
1088
|
+
if (!diplomatReceive.resultFlag) {
|
|
1089
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1090
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1091
|
+
}
|
|
1092
|
+
return new Sdf(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
finally {
|
|
1096
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1097
|
+
functionCleanupArena.free();
|
|
1098
|
+
|
|
1099
|
+
diplomatReceive.free();
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
toJson() {
|
|
1104
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
1105
|
+
|
|
1106
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
1107
|
+
|
|
1108
|
+
|
|
1109
|
+
const result = wasm.Sdf_to_json(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
1110
|
+
|
|
1111
|
+
try {
|
|
1112
|
+
if (!diplomatReceive.resultFlag) {
|
|
1113
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
1114
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
1115
|
+
}
|
|
1116
|
+
return write.readString8();
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
finally {
|
|
1120
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1121
|
+
diplomatReceive.free();
|
|
1122
|
+
write.free();
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
/**
|
|
1127
|
+
* Wrap a validated {@link FieldProgram} as an `Sdf` graph (cloning it,
|
|
1128
|
+
* with its own explicit bounds and distance-kind metadata), so it
|
|
1129
|
+
* composes with every other combinator.
|
|
1130
|
+
*/
|
|
1131
|
+
static fromProgram(program) {
|
|
1132
|
+
|
|
1133
|
+
const result = wasm.Sdf_from_program(program.ffiValue);
|
|
1134
|
+
|
|
1135
|
+
try {
|
|
1136
|
+
return new Sdf(diplomatRuntime.internalConstructor, result, []);
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
finally {
|
|
1140
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
|
|
44
1144
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* the ergonomic path for bounded trees (all primitives except
|
|
48
|
-
* `plane`). Fails with `InvalidArgument` for unbounded trees; use
|
|
49
|
-
* `schematic_from_sdf` with explicit bounds for those.
|
|
1145
|
+
* Legacy JSON-first terrain helper. Prefer typed constructors and
|
|
1146
|
+
* `to_shape()` with `BuildingTool.fill()` for new code.
|
|
50
1147
|
*/
|
|
51
1148
|
static schematicFromSdfAuto(sdfJson, rulesJson) {
|
|
52
1149
|
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
@@ -75,9 +1172,7 @@ export class Sdf {
|
|
|
75
1172
|
}
|
|
76
1173
|
|
|
77
1174
|
/**
|
|
78
|
-
*
|
|
79
|
-
* `InvalidArgument` for unbounded trees) and the `min_*`/`max_*` arguments
|
|
80
|
-
* are ignored.
|
|
1175
|
+
* Legacy JSON-first terrain helper with optional explicit bounds.
|
|
81
1176
|
*/
|
|
82
1177
|
static schematicFromSdf(sdfJson, rulesJson, hasBounds, minX, minY, minZ, maxX, maxY, maxZ) {
|
|
83
1178
|
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
@@ -106,7 +1201,7 @@ export class Sdf {
|
|
|
106
1201
|
}
|
|
107
1202
|
|
|
108
1203
|
/**
|
|
109
|
-
*
|
|
1204
|
+
* Legacy JSON-first evaluator. Prefer `Sdf.from_json_string(...).eval_at(...)`.
|
|
110
1205
|
*/
|
|
111
1206
|
static eval(sdfJson, x, y, z) {
|
|
112
1207
|
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|