nucleation 0.6.0 → 0.8.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/Field3.mjs
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import { FieldRange } from "./FieldRange.mjs"
|
|
3
|
+
import { NucleationError } from "./NucleationError.mjs"
|
|
4
|
+
import wasm from "./diplomat-wasm.mjs";
|
|
5
|
+
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
6
|
+
|
|
7
|
+
const Field3_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
8
|
+
wasm.Field3_destroy(ptr);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Immutable scalar field evaluated over world-space `(x, y, z)`.
|
|
13
|
+
*
|
|
14
|
+
* A `Field3` has scalar semantics only. It may be shared by geometry and
|
|
15
|
+
* material consumers without being reinterpreted as a signed-distance field.
|
|
16
|
+
*/
|
|
17
|
+
export class Field3 {
|
|
18
|
+
// Internal ptr reference:
|
|
19
|
+
#ptr = null;
|
|
20
|
+
|
|
21
|
+
// Lifetimes are only to keep dependencies alive.
|
|
22
|
+
// Since JS won't garbage collect until there are no incoming edges.
|
|
23
|
+
#selfEdge = [];
|
|
24
|
+
|
|
25
|
+
#internalConstructor(symbol, ptr, selfEdge) {
|
|
26
|
+
if (symbol !== diplomatRuntime.internalConstructor) {
|
|
27
|
+
console.error("Field3 is an Opaque type. You cannot call its constructor.");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
this.#ptr = ptr;
|
|
31
|
+
this.#selfEdge = selfEdge;
|
|
32
|
+
|
|
33
|
+
// Are we being borrowed? If not, we can register.
|
|
34
|
+
if (this.#selfEdge.length === 0) {
|
|
35
|
+
Field3_box_destroy_registry.register(this, this.#ptr);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
/** @internal */
|
|
41
|
+
get ffiValue() {
|
|
42
|
+
return this.#ptr;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Deterministic value-noise FBM normalized to `[-1, 1]`.
|
|
48
|
+
*/
|
|
49
|
+
static valueNoiseFbm(frequency, seed, octaves) {
|
|
50
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
const result = wasm.Field3_value_noise_fbm(diplomatReceive.buffer, frequency, seed, octaves);
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
if (!diplomatReceive.resultFlag) {
|
|
57
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
58
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
59
|
+
}
|
|
60
|
+
return new Field3(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
finally {
|
|
64
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
65
|
+
diplomatReceive.free();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
evalAt(x, y, z) {
|
|
70
|
+
|
|
71
|
+
const result = wasm.Field3_eval_at(this.ffiValue, x, y, z);
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
finally {
|
|
78
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The field's analytically proven output range.
|
|
84
|
+
*
|
|
85
|
+
* Returns `NotFound` when no range can be proven — callers mapping a
|
|
86
|
+
* field onto a gradient must handle that rather than silently
|
|
87
|
+
* propagating a sentinel into their `lo`/`hi` bounds.
|
|
88
|
+
*/
|
|
89
|
+
outputRange() {
|
|
90
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true);
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
const result = wasm.Field3_output_range(diplomatReceive.buffer, this.ffiValue);
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
if (!diplomatReceive.resultFlag) {
|
|
97
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
98
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
99
|
+
}
|
|
100
|
+
return FieldRange._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
finally {
|
|
104
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
105
|
+
diplomatReceive.free();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
static fromJsonString(json) {
|
|
110
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
111
|
+
|
|
112
|
+
const jsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, json)));
|
|
113
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
const result = wasm.Field3_from_json_string(diplomatReceive.buffer, jsonSlice.ptr);
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
if (!diplomatReceive.resultFlag) {
|
|
120
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
121
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
122
|
+
}
|
|
123
|
+
return new Field3(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
finally {
|
|
127
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
128
|
+
functionCleanupArena.free();
|
|
129
|
+
|
|
130
|
+
diplomatReceive.free();
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
toJson() {
|
|
135
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
136
|
+
|
|
137
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
const result = wasm.Field3_to_json(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
141
|
+
|
|
142
|
+
try {
|
|
143
|
+
if (!diplomatReceive.resultFlag) {
|
|
144
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
145
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
146
|
+
}
|
|
147
|
+
return write.readString8();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
finally {
|
|
151
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
152
|
+
diplomatReceive.free();
|
|
153
|
+
write.free();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
constructor(symbol, ptr, selfEdge) {
|
|
158
|
+
return this.#internalConstructor(...arguments)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { FieldProgramDistanceKind } from "./FieldProgramDistanceKind.mjs"
|
|
3
|
+
import type { NucleationError } from "./NucleationError.mjs"
|
|
4
|
+
import type { SdfBounds } from "./SdfBounds.mjs"
|
|
5
|
+
import type { SdfNormal } from "./SdfNormal.mjs"
|
|
6
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A validated, sandboxed custom SDF field program: deterministic typed
|
|
12
|
+
* bytecode over scalar/vec3/bool values with bounded loops, carrying
|
|
13
|
+
* its own explicit finite bounds and distance-kind metadata. Build one
|
|
14
|
+
* with {@link FieldProgramBuilder} or import it from JSON.
|
|
15
|
+
*/
|
|
16
|
+
export class FieldProgram {
|
|
17
|
+
/** @internal */
|
|
18
|
+
get ffiValue(): pointer;
|
|
19
|
+
/** @internal */
|
|
20
|
+
constructor();
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
static fromJsonString(json: string): FieldProgram;
|
|
24
|
+
|
|
25
|
+
toJson(): string;
|
|
26
|
+
|
|
27
|
+
evalAt(x: number, y: number, z: number): number;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Unit-length gradient of the scalar output at `(x, y, z)`: the
|
|
31
|
+
* program's own forward-mode analytic gradient where it's
|
|
32
|
+
* differentiable there, falling back to a numerical estimate
|
|
33
|
+
* (central differences via `epsilon`) otherwise.
|
|
34
|
+
*/
|
|
35
|
+
gradient(x: number, y: number, z: number, epsilon: number): SdfNormal;
|
|
36
|
+
|
|
37
|
+
bounds(): SdfBounds;
|
|
38
|
+
|
|
39
|
+
distanceKind(): FieldProgramDistanceKind;
|
|
40
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { FieldProgramDistanceKind } from "./FieldProgramDistanceKind.mjs"
|
|
3
|
+
import type { NucleationError } from "./NucleationError.mjs"
|
|
4
|
+
import type { SdfBounds } from "./SdfBounds.mjs"
|
|
5
|
+
import type { SdfNormal } from "./SdfNormal.mjs"
|
|
6
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A validated, sandboxed custom SDF field program: deterministic typed
|
|
12
|
+
* bytecode over scalar/vec3/bool values with bounded loops, carrying
|
|
13
|
+
* its own explicit finite bounds and distance-kind metadata. Build one
|
|
14
|
+
* with {@link FieldProgramBuilder} or import it from JSON.
|
|
15
|
+
*/
|
|
16
|
+
export class FieldProgram {
|
|
17
|
+
/** @internal */
|
|
18
|
+
get ffiValue(): pointer;
|
|
19
|
+
/** @internal */
|
|
20
|
+
constructor();
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
static fromJsonString(json: string): FieldProgram;
|
|
24
|
+
|
|
25
|
+
toJson(): string;
|
|
26
|
+
|
|
27
|
+
evalAt(x: number, y: number, z: number): number;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Unit-length gradient of the scalar output at `(x, y, z)`: the
|
|
31
|
+
* program's own forward-mode analytic gradient where it's
|
|
32
|
+
* differentiable there, falling back to a numerical estimate
|
|
33
|
+
* (central differences via `epsilon`) otherwise.
|
|
34
|
+
*/
|
|
35
|
+
gradient(x: number, y: number, z: number, epsilon: number): SdfNormal;
|
|
36
|
+
|
|
37
|
+
bounds(): SdfBounds;
|
|
38
|
+
|
|
39
|
+
distanceKind(): FieldProgramDistanceKind;
|
|
40
|
+
}
|
package/FieldProgram.mjs
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import { FieldProgramDistanceKind } from "./FieldProgramDistanceKind.mjs"
|
|
3
|
+
import { NucleationError } from "./NucleationError.mjs"
|
|
4
|
+
import { SdfBounds } from "./SdfBounds.mjs"
|
|
5
|
+
import { SdfNormal } from "./SdfNormal.mjs"
|
|
6
|
+
import wasm from "./diplomat-wasm.mjs";
|
|
7
|
+
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
8
|
+
|
|
9
|
+
const FieldProgram_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
10
|
+
wasm.FieldProgram_destroy(ptr);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A validated, sandboxed custom SDF field program: deterministic typed
|
|
15
|
+
* bytecode over scalar/vec3/bool values with bounded loops, carrying
|
|
16
|
+
* its own explicit finite bounds and distance-kind metadata. Build one
|
|
17
|
+
* with {@link FieldProgramBuilder} or import it from JSON.
|
|
18
|
+
*/
|
|
19
|
+
export class FieldProgram {
|
|
20
|
+
// Internal ptr reference:
|
|
21
|
+
#ptr = null;
|
|
22
|
+
|
|
23
|
+
// Lifetimes are only to keep dependencies alive.
|
|
24
|
+
// Since JS won't garbage collect until there are no incoming edges.
|
|
25
|
+
#selfEdge = [];
|
|
26
|
+
|
|
27
|
+
#internalConstructor(symbol, ptr, selfEdge) {
|
|
28
|
+
if (symbol !== diplomatRuntime.internalConstructor) {
|
|
29
|
+
console.error("FieldProgram is an Opaque type. You cannot call its constructor.");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
this.#ptr = ptr;
|
|
33
|
+
this.#selfEdge = selfEdge;
|
|
34
|
+
|
|
35
|
+
// Are we being borrowed? If not, we can register.
|
|
36
|
+
if (this.#selfEdge.length === 0) {
|
|
37
|
+
FieldProgram_box_destroy_registry.register(this, this.#ptr);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
/** @internal */
|
|
43
|
+
get ffiValue() {
|
|
44
|
+
return this.#ptr;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
static fromJsonString(json) {
|
|
49
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
50
|
+
|
|
51
|
+
const jsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, json)));
|
|
52
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
const result = wasm.FieldProgram_from_json_string(diplomatReceive.buffer, jsonSlice.ptr);
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
if (!diplomatReceive.resultFlag) {
|
|
59
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
60
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
61
|
+
}
|
|
62
|
+
return new FieldProgram(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
finally {
|
|
66
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
67
|
+
functionCleanupArena.free();
|
|
68
|
+
|
|
69
|
+
diplomatReceive.free();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
toJson() {
|
|
74
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
75
|
+
|
|
76
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
const result = wasm.FieldProgram_to_json(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
80
|
+
|
|
81
|
+
try {
|
|
82
|
+
if (!diplomatReceive.resultFlag) {
|
|
83
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
84
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
85
|
+
}
|
|
86
|
+
return write.readString8();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
finally {
|
|
90
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
91
|
+
diplomatReceive.free();
|
|
92
|
+
write.free();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
evalAt(x, y, z) {
|
|
97
|
+
|
|
98
|
+
const result = wasm.FieldProgram_eval_at(this.ffiValue, x, y, z);
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
finally {
|
|
105
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Unit-length gradient of the scalar output at `(x, y, z)`: the
|
|
111
|
+
* program's own forward-mode analytic gradient where it's
|
|
112
|
+
* differentiable there, falling back to a numerical estimate
|
|
113
|
+
* (central differences via `epsilon`) otherwise.
|
|
114
|
+
*/
|
|
115
|
+
gradient(x, y, z, epsilon) {
|
|
116
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 13, 4, true);
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
const result = wasm.FieldProgram_gradient(diplomatReceive.buffer, this.ffiValue, x, y, z, epsilon);
|
|
120
|
+
|
|
121
|
+
try {
|
|
122
|
+
if (!diplomatReceive.resultFlag) {
|
|
123
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
124
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
125
|
+
}
|
|
126
|
+
return SdfNormal._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
finally {
|
|
130
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
131
|
+
diplomatReceive.free();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
bounds() {
|
|
136
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 24, 4, false);
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
const result = wasm.FieldProgram_bounds(diplomatReceive.buffer, this.ffiValue);
|
|
140
|
+
|
|
141
|
+
try {
|
|
142
|
+
return SdfBounds._fromFFI(diplomatRuntime.internalConstructor, diplomatReceive.buffer);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
finally {
|
|
146
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
147
|
+
diplomatReceive.free();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
distanceKind() {
|
|
152
|
+
|
|
153
|
+
const result = wasm.FieldProgram_distance_kind(this.ffiValue);
|
|
154
|
+
|
|
155
|
+
try {
|
|
156
|
+
return new FieldProgramDistanceKind(diplomatRuntime.internalConstructor, result);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
finally {
|
|
160
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
constructor(symbol, ptr, selfEdge) {
|
|
165
|
+
return this.#internalConstructor(...arguments)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Binary field-program operations (see `crate::sdf::BinaryOp`). `Add`
|
|
8
|
+
* and `Sub` accept either two scalars or two vec3s.
|
|
9
|
+
*/
|
|
10
|
+
export class FieldProgramBinaryOp {
|
|
11
|
+
|
|
12
|
+
/** @internal */
|
|
13
|
+
static fromValue(value: FieldProgramBinaryOp | string): FieldProgramBinaryOp;
|
|
14
|
+
|
|
15
|
+
get value(): string;
|
|
16
|
+
|
|
17
|
+
/** @internal */
|
|
18
|
+
get ffiValue(): number;
|
|
19
|
+
|
|
20
|
+
static Add : FieldProgramBinaryOp;
|
|
21
|
+
static Sub : FieldProgramBinaryOp;
|
|
22
|
+
static Mul : FieldProgramBinaryOp;
|
|
23
|
+
static Div : FieldProgramBinaryOp;
|
|
24
|
+
static Min : FieldProgramBinaryOp;
|
|
25
|
+
static Max : FieldProgramBinaryOp;
|
|
26
|
+
static Pow : FieldProgramBinaryOp;
|
|
27
|
+
static Atan2 : FieldProgramBinaryOp;
|
|
28
|
+
static Lt : FieldProgramBinaryOp;
|
|
29
|
+
static Le : FieldProgramBinaryOp;
|
|
30
|
+
static Gt : FieldProgramBinaryOp;
|
|
31
|
+
static Ge : FieldProgramBinaryOp;
|
|
32
|
+
static Eq : FieldProgramBinaryOp;
|
|
33
|
+
static Dot : FieldProgramBinaryOp;
|
|
34
|
+
static Cross : FieldProgramBinaryOp;
|
|
35
|
+
/**
|
|
36
|
+
* `vec3 * scalar`, componentwise.
|
|
37
|
+
*/
|
|
38
|
+
static Scale : FieldProgramBinaryOp;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
constructor(value: FieldProgramBinaryOp | string );
|
|
42
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Binary field-program operations (see `crate::sdf::BinaryOp`). `Add`
|
|
8
|
+
* and `Sub` accept either two scalars or two vec3s.
|
|
9
|
+
*/
|
|
10
|
+
export class FieldProgramBinaryOp {
|
|
11
|
+
|
|
12
|
+
/** @internal */
|
|
13
|
+
static fromValue(value: FieldProgramBinaryOp | string): FieldProgramBinaryOp;
|
|
14
|
+
|
|
15
|
+
get value(): string;
|
|
16
|
+
|
|
17
|
+
/** @internal */
|
|
18
|
+
get ffiValue(): number;
|
|
19
|
+
|
|
20
|
+
static Add : FieldProgramBinaryOp;
|
|
21
|
+
static Sub : FieldProgramBinaryOp;
|
|
22
|
+
static Mul : FieldProgramBinaryOp;
|
|
23
|
+
static Div : FieldProgramBinaryOp;
|
|
24
|
+
static Min : FieldProgramBinaryOp;
|
|
25
|
+
static Max : FieldProgramBinaryOp;
|
|
26
|
+
static Pow : FieldProgramBinaryOp;
|
|
27
|
+
static Atan2 : FieldProgramBinaryOp;
|
|
28
|
+
static Lt : FieldProgramBinaryOp;
|
|
29
|
+
static Le : FieldProgramBinaryOp;
|
|
30
|
+
static Gt : FieldProgramBinaryOp;
|
|
31
|
+
static Ge : FieldProgramBinaryOp;
|
|
32
|
+
static Eq : FieldProgramBinaryOp;
|
|
33
|
+
static Dot : FieldProgramBinaryOp;
|
|
34
|
+
static Cross : FieldProgramBinaryOp;
|
|
35
|
+
/**
|
|
36
|
+
* `vec3 * scalar`, componentwise.
|
|
37
|
+
*/
|
|
38
|
+
static Scale : FieldProgramBinaryOp;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
constructor(value: FieldProgramBinaryOp | string );
|
|
42
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import wasm from "./diplomat-wasm.mjs";
|
|
3
|
+
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Binary field-program operations (see `crate::sdf::BinaryOp`). `Add`
|
|
9
|
+
* and `Sub` accept either two scalars or two vec3s.
|
|
10
|
+
*/
|
|
11
|
+
export class FieldProgramBinaryOp {
|
|
12
|
+
#value = undefined;
|
|
13
|
+
|
|
14
|
+
static #values = new Map([
|
|
15
|
+
["Add", 0],
|
|
16
|
+
["Sub", 1],
|
|
17
|
+
["Mul", 2],
|
|
18
|
+
["Div", 3],
|
|
19
|
+
["Min", 4],
|
|
20
|
+
["Max", 5],
|
|
21
|
+
["Pow", 6],
|
|
22
|
+
["Atan2", 7],
|
|
23
|
+
["Lt", 8],
|
|
24
|
+
["Le", 9],
|
|
25
|
+
["Gt", 10],
|
|
26
|
+
["Ge", 11],
|
|
27
|
+
["Eq", 12],
|
|
28
|
+
["Dot", 13],
|
|
29
|
+
["Cross", 14],
|
|
30
|
+
["Scale", 15]
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
static getAllEntries() {
|
|
34
|
+
return FieldProgramBinaryOp.#values.entries();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#internalConstructor(value) {
|
|
38
|
+
if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) {
|
|
39
|
+
// We pass in two internalConstructor arguments to create *new*
|
|
40
|
+
// instances of this type, otherwise the enums are treated as singletons.
|
|
41
|
+
if (arguments[1] === diplomatRuntime.internalConstructor ) {
|
|
42
|
+
this.#value = arguments[2];
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
return FieldProgramBinaryOp.#objectValues[arguments[1]];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (value instanceof FieldProgramBinaryOp) {
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let intVal = FieldProgramBinaryOp.#values.get(value);
|
|
53
|
+
|
|
54
|
+
// Nullish check, checks for null or undefined
|
|
55
|
+
if (intVal != null) {
|
|
56
|
+
return FieldProgramBinaryOp.#objectValues[intVal];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
throw TypeError(value + " is not a FieldProgramBinaryOp and does not correspond to any of its enumerator values.");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** @internal */
|
|
63
|
+
static fromValue(value) {
|
|
64
|
+
return new FieldProgramBinaryOp(value);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
get value(){
|
|
68
|
+
return [...FieldProgramBinaryOp.#values.keys()][this.#value];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** @internal */
|
|
72
|
+
get ffiValue(){
|
|
73
|
+
return this.#value;
|
|
74
|
+
}
|
|
75
|
+
static #objectValues = [
|
|
76
|
+
new FieldProgramBinaryOp(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
|
|
77
|
+
new FieldProgramBinaryOp(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
|
|
78
|
+
new FieldProgramBinaryOp(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
|
|
79
|
+
new FieldProgramBinaryOp(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3),
|
|
80
|
+
new FieldProgramBinaryOp(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4),
|
|
81
|
+
new FieldProgramBinaryOp(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 5),
|
|
82
|
+
new FieldProgramBinaryOp(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 6),
|
|
83
|
+
new FieldProgramBinaryOp(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 7),
|
|
84
|
+
new FieldProgramBinaryOp(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 8),
|
|
85
|
+
new FieldProgramBinaryOp(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 9),
|
|
86
|
+
new FieldProgramBinaryOp(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 10),
|
|
87
|
+
new FieldProgramBinaryOp(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 11),
|
|
88
|
+
new FieldProgramBinaryOp(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 12),
|
|
89
|
+
new FieldProgramBinaryOp(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 13),
|
|
90
|
+
new FieldProgramBinaryOp(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 14),
|
|
91
|
+
new FieldProgramBinaryOp(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 15),
|
|
92
|
+
];
|
|
93
|
+
|
|
94
|
+
static Add = FieldProgramBinaryOp.#objectValues[0];
|
|
95
|
+
static Sub = FieldProgramBinaryOp.#objectValues[1];
|
|
96
|
+
static Mul = FieldProgramBinaryOp.#objectValues[2];
|
|
97
|
+
static Div = FieldProgramBinaryOp.#objectValues[3];
|
|
98
|
+
static Min = FieldProgramBinaryOp.#objectValues[4];
|
|
99
|
+
static Max = FieldProgramBinaryOp.#objectValues[5];
|
|
100
|
+
static Pow = FieldProgramBinaryOp.#objectValues[6];
|
|
101
|
+
static Atan2 = FieldProgramBinaryOp.#objectValues[7];
|
|
102
|
+
static Lt = FieldProgramBinaryOp.#objectValues[8];
|
|
103
|
+
static Le = FieldProgramBinaryOp.#objectValues[9];
|
|
104
|
+
static Gt = FieldProgramBinaryOp.#objectValues[10];
|
|
105
|
+
static Ge = FieldProgramBinaryOp.#objectValues[11];
|
|
106
|
+
static Eq = FieldProgramBinaryOp.#objectValues[12];
|
|
107
|
+
static Dot = FieldProgramBinaryOp.#objectValues[13];
|
|
108
|
+
static Cross = FieldProgramBinaryOp.#objectValues[14];
|
|
109
|
+
/**
|
|
110
|
+
* `vec3 * scalar`, componentwise.
|
|
111
|
+
*/
|
|
112
|
+
static Scale = FieldProgramBinaryOp.#objectValues[15];
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
constructor(value) {
|
|
116
|
+
return this.#internalConstructor(...arguments)
|
|
117
|
+
}
|
|
118
|
+
}
|