nucleation 0.2.18 → 0.3.1
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/Autostack.d.ts +43 -0
- package/Autostack.mjs +134 -0
- package/BlockPos.d.ts +28 -0
- package/BlockPos.mjs +129 -0
- package/BlockState.d.ts +39 -0
- package/BlockState.mjs +134 -0
- package/Brush.d.ts +68 -0
- package/Brush.mjs +220 -0
- package/BuildingTool.d.ts +29 -0
- package/BuildingTool.mjs +74 -0
- package/ChunkMeshResult.d.ts +75 -0
- package/ChunkMeshResult.mjs +253 -0
- package/CircuitBuilder.d.ts +118 -0
- package/CircuitBuilder.mjs +516 -0
- package/DefinitionRegion.d.ts +274 -0
- package/DefinitionRegion.mjs +973 -0
- package/Diff.d.ts +88 -0
- package/Diff.mjs +316 -0
- package/Dimensions.d.ts +28 -0
- package/Dimensions.mjs +129 -0
- package/ExecutionMode.d.ts +42 -0
- package/ExecutionMode.mjs +127 -0
- package/Fingerprint.d.ts +44 -0
- package/Fingerprint.mjs +197 -0
- package/InterpolationSpace.d.ts +25 -0
- package/InterpolationSpace.mjs +73 -0
- package/IoLayout.d.ts +26 -0
- package/IoLayout.mjs +81 -0
- package/IoLayoutBuilder.d.ts +73 -0
- package/IoLayoutBuilder.mjs +315 -0
- package/IoType.d.ts +41 -0
- package/IoType.mjs +125 -0
- package/ItemModelConfig.d.ts +65 -0
- package/ItemModelConfig.mjs +223 -0
- package/ItemModelPackBuilder.d.ts +32 -0
- package/ItemModelPackBuilder.mjs +104 -0
- package/ItemModelResult.d.ts +72 -0
- package/ItemModelResult.mjs +268 -0
- package/ItemScale.d.ts +31 -0
- package/ItemScale.mjs +132 -0
- package/LayoutFunction.d.ts +52 -0
- package/LayoutFunction.mjs +159 -0
- package/MchprsWorld.d.ts +131 -0
- package/MchprsWorld.mjs +423 -0
- package/MeshBounds.d.ts +40 -0
- package/MeshBounds.mjs +180 -0
- package/MeshConfig.d.ts +101 -0
- package/MeshConfig.mjs +306 -0
- package/MeshJob.d.ts +44 -0
- package/MeshJob.mjs +116 -0
- package/MeshPhase.d.ts +38 -0
- package/MeshPhase.mjs +90 -0
- package/MeshProgress.d.ts +32 -0
- package/MeshProgress.mjs +133 -0
- package/MeshResult.d.ts +60 -0
- package/MeshResult.mjs +206 -0
- package/MultiMeshResult.d.ts +50 -0
- package/MultiMeshResult.mjs +166 -0
- package/Nbt.d.ts +50 -0
- package/Nbt.mjs +161 -0
- package/NucleationError.d.ts +36 -0
- package/NucleationError.mjs +104 -0
- package/OutputCondition.d.ts +45 -0
- package/OutputCondition.mjs +129 -0
- package/Palette.d.ts +84 -0
- package/Palette.mjs +269 -0
- package/PaletteBuilder.d.ts +76 -0
- package/PaletteBuilder.mjs +297 -0
- package/README.md +28 -197
- package/RawMeshExport.d.ts +74 -0
- package/RawMeshExport.mjs +243 -0
- package/RedstoneGraph.d.ts +58 -0
- package/RedstoneGraph.mjs +242 -0
- package/RegionBounds.d.ts +41 -0
- package/RegionBounds.mjs +181 -0
- package/RenderConfig.d.ts +66 -0
- package/RenderConfig.mjs +170 -0
- package/Renderer.d.ts +35 -0
- package/Renderer.mjs +139 -0
- package/ResourcePack.d.ts +105 -0
- package/ResourcePack.mjs +447 -0
- package/ResourcePackList.d.ts +32 -0
- package/ResourcePackList.mjs +96 -0
- package/Schematic.d.ts +655 -0
- package/Schematic.mjs +2647 -0
- package/SchematicBuilder.d.ts +103 -0
- package/SchematicBuilder.mjs +401 -0
- package/SchematicRegions.d.ts +93 -0
- package/SchematicRegions.mjs +411 -0
- package/Scripting.d.ts +40 -0
- package/Scripting.mjs +138 -0
- package/Sdf.d.ts +31 -0
- package/Sdf.mjs +107 -0
- package/Shape.d.ts +108 -0
- package/Shape.mjs +336 -0
- package/SortStrategy.d.ts +86 -0
- package/SortStrategy.mjs +272 -0
- package/Store.d.ts +83 -0
- package/Store.mjs +369 -0
- package/StoreIo.d.ts +71 -0
- package/StoreIo.mjs +292 -0
- package/TextureAtlas.d.ts +40 -0
- package/TextureAtlas.mjs +122 -0
- package/TextureInfo.d.ts +34 -0
- package/TextureInfo.mjs +148 -0
- package/TypedCircuitExecutor.d.ts +101 -0
- package/TypedCircuitExecutor.mjs +378 -0
- package/Value.d.ts +73 -0
- package/Value.mjs +275 -0
- package/WorldChunkView.d.ts +63 -0
- package/WorldChunkView.mjs +201 -0
- package/WorldSink.d.ts +50 -0
- package/WorldSink.mjs +177 -0
- package/WorldStream.d.ts +45 -0
- package/WorldStream.mjs +184 -0
- package/diplomat-runtime.d.ts +15 -0
- package/diplomat-runtime.mjs +774 -0
- package/diplomat-wasm.mjs +52 -0
- package/diplomat.config.mjs +6 -0
- package/index.d.ts +117 -0
- package/index.mjs +120 -0
- package/{nucleation_bg.wasm → nucleation.wasm} +0 -0
- package/package.json +19 -41
- package/LICENSE +0 -21
- package/api.js +0 -608
- package/nucleation-cdn-loader.js +0 -15
- package/nucleation-original.js +0 -8383
- package/nucleation.d.ts +0 -2947
- package/nucleation.js +0 -36
|
@@ -0,0 +1,242 @@
|
|
|
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 RedstoneGraph_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
7
|
+
wasm.RedstoneGraph_destroy(ptr);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* An extracted redstone logic graph. Wraps
|
|
12
|
+
* {@link crate::simulation::graph::RedstoneGraph}.
|
|
13
|
+
*/
|
|
14
|
+
export class RedstoneGraph {
|
|
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("RedstoneGraph 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
|
+
RedstoneGraph_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
|
+
* Number of nodes in the graph.
|
|
45
|
+
*/
|
|
46
|
+
nodeCount() {
|
|
47
|
+
|
|
48
|
+
const result = wasm.RedstoneGraph_node_count(this.ffiValue);
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
finally {
|
|
55
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Total number of directed edges in the graph.
|
|
61
|
+
*/
|
|
62
|
+
edgeCount() {
|
|
63
|
+
|
|
64
|
+
const result = wasm.RedstoneGraph_edge_count(this.ffiValue);
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
finally {
|
|
71
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The nodes as a JSON array string.
|
|
77
|
+
*/
|
|
78
|
+
nodesJson() {
|
|
79
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
80
|
+
|
|
81
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
const result = wasm.RedstoneGraph_nodes_json(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
if (!diplomatReceive.resultFlag) {
|
|
88
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
89
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
90
|
+
}
|
|
91
|
+
return write.readString8();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
finally {
|
|
95
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
96
|
+
diplomatReceive.free();
|
|
97
|
+
write.free();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The directed edges as a JSON array string.
|
|
103
|
+
*/
|
|
104
|
+
edgesJson() {
|
|
105
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
106
|
+
|
|
107
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
const result = wasm.RedstoneGraph_edges_json(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
111
|
+
|
|
112
|
+
try {
|
|
113
|
+
if (!diplomatReceive.resultFlag) {
|
|
114
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
115
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
116
|
+
}
|
|
117
|
+
return write.readString8();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
finally {
|
|
121
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
122
|
+
diplomatReceive.free();
|
|
123
|
+
write.free();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Computed graph features as a JSON object string.
|
|
129
|
+
*/
|
|
130
|
+
featuresJson() {
|
|
131
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
132
|
+
|
|
133
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
const result = wasm.RedstoneGraph_features_json(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
137
|
+
|
|
138
|
+
try {
|
|
139
|
+
if (!diplomatReceive.resultFlag) {
|
|
140
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
141
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
142
|
+
}
|
|
143
|
+
return write.readString8();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
finally {
|
|
147
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
148
|
+
diplomatReceive.free();
|
|
149
|
+
write.free();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Fingerprint (hex string) for `preset` ("structural" | "functional" |
|
|
155
|
+
* "exact"; empty defaults to "structural").
|
|
156
|
+
*/
|
|
157
|
+
fingerprint(preset) {
|
|
158
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
159
|
+
|
|
160
|
+
const presetSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, preset)));
|
|
161
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
162
|
+
|
|
163
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
const result = wasm.RedstoneGraph_fingerprint(diplomatReceive.buffer, this.ffiValue, presetSlice.ptr, write.buffer);
|
|
167
|
+
|
|
168
|
+
try {
|
|
169
|
+
if (!diplomatReceive.resultFlag) {
|
|
170
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
171
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
172
|
+
}
|
|
173
|
+
return write.readString8();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
finally {
|
|
177
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
178
|
+
functionCleanupArena.free();
|
|
179
|
+
|
|
180
|
+
diplomatReceive.free();
|
|
181
|
+
write.free();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Serialize the whole graph to JSON.
|
|
187
|
+
*/
|
|
188
|
+
toJson() {
|
|
189
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
190
|
+
|
|
191
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
const result = wasm.RedstoneGraph_to_json(diplomatReceive.buffer, this.ffiValue, write.buffer);
|
|
195
|
+
|
|
196
|
+
try {
|
|
197
|
+
if (!diplomatReceive.resultFlag) {
|
|
198
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
199
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
200
|
+
}
|
|
201
|
+
return write.readString8();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
finally {
|
|
205
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
206
|
+
diplomatReceive.free();
|
|
207
|
+
write.free();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Deserialize a graph from a JSON string.
|
|
213
|
+
*/
|
|
214
|
+
static fromJson(json) {
|
|
215
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
216
|
+
|
|
217
|
+
const jsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, json)));
|
|
218
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
const result = wasm.RedstoneGraph_from_json(diplomatReceive.buffer, jsonSlice.ptr);
|
|
222
|
+
|
|
223
|
+
try {
|
|
224
|
+
if (!diplomatReceive.resultFlag) {
|
|
225
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
226
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
227
|
+
}
|
|
228
|
+
return new RedstoneGraph(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
finally {
|
|
232
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
233
|
+
functionCleanupArena.free();
|
|
234
|
+
|
|
235
|
+
diplomatReceive.free();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
constructor(symbol, ptr, selfEdge) {
|
|
240
|
+
return this.#internalConstructor(...arguments)
|
|
241
|
+
}
|
|
242
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
3
|
+
|
|
4
|
+
export type RegionBounds_obj = {
|
|
5
|
+
minX: number;
|
|
6
|
+
minY: number;
|
|
7
|
+
minZ: number;
|
|
8
|
+
maxX: number;
|
|
9
|
+
maxY: number;
|
|
10
|
+
maxZ: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* An inclusive block-coordinate box (a definition region is a union of
|
|
17
|
+
* these).
|
|
18
|
+
*/
|
|
19
|
+
export class RegionBounds {
|
|
20
|
+
get minX(): number;
|
|
21
|
+
set minX(value: number);
|
|
22
|
+
get minY(): number;
|
|
23
|
+
set minY(value: number);
|
|
24
|
+
get minZ(): number;
|
|
25
|
+
set minZ(value: number);
|
|
26
|
+
get maxX(): number;
|
|
27
|
+
set maxX(value: number);
|
|
28
|
+
get maxY(): number;
|
|
29
|
+
set maxY(value: number);
|
|
30
|
+
get maxZ(): number;
|
|
31
|
+
set maxZ(value: number);
|
|
32
|
+
/** @internal */
|
|
33
|
+
static fromFields(structObj : RegionBounds_obj) : RegionBounds;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Create `RegionBounds` from an object that contains all of `RegionBounds`s fields.
|
|
37
|
+
* Optional fields do not need to be included in the provided object.
|
|
38
|
+
*/
|
|
39
|
+
constructor(structObj: RegionBounds_obj);
|
|
40
|
+
|
|
41
|
+
}
|
package/RegionBounds.mjs
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
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
|
+
* An inclusive block-coordinate box (a definition region is a union of
|
|
9
|
+
* these).
|
|
10
|
+
*/
|
|
11
|
+
export class RegionBounds {
|
|
12
|
+
#minX;
|
|
13
|
+
get minX() {
|
|
14
|
+
return this.#minX;
|
|
15
|
+
}
|
|
16
|
+
set minX(value){
|
|
17
|
+
this.#minX = value;
|
|
18
|
+
}
|
|
19
|
+
#minY;
|
|
20
|
+
get minY() {
|
|
21
|
+
return this.#minY;
|
|
22
|
+
}
|
|
23
|
+
set minY(value){
|
|
24
|
+
this.#minY = value;
|
|
25
|
+
}
|
|
26
|
+
#minZ;
|
|
27
|
+
get minZ() {
|
|
28
|
+
return this.#minZ;
|
|
29
|
+
}
|
|
30
|
+
set minZ(value){
|
|
31
|
+
this.#minZ = value;
|
|
32
|
+
}
|
|
33
|
+
#maxX;
|
|
34
|
+
get maxX() {
|
|
35
|
+
return this.#maxX;
|
|
36
|
+
}
|
|
37
|
+
set maxX(value){
|
|
38
|
+
this.#maxX = value;
|
|
39
|
+
}
|
|
40
|
+
#maxY;
|
|
41
|
+
get maxY() {
|
|
42
|
+
return this.#maxY;
|
|
43
|
+
}
|
|
44
|
+
set maxY(value){
|
|
45
|
+
this.#maxY = value;
|
|
46
|
+
}
|
|
47
|
+
#maxZ;
|
|
48
|
+
get maxZ() {
|
|
49
|
+
return this.#maxZ;
|
|
50
|
+
}
|
|
51
|
+
set maxZ(value){
|
|
52
|
+
this.#maxZ = value;
|
|
53
|
+
}
|
|
54
|
+
/** @internal */
|
|
55
|
+
static fromFields(structObj) {
|
|
56
|
+
return new RegionBounds(structObj);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
#internalConstructor(structObj) {
|
|
60
|
+
if (typeof structObj !== "object") {
|
|
61
|
+
throw new Error("RegionBounds's constructor takes an object of RegionBounds's fields.");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if ("minX" in structObj) {
|
|
65
|
+
this.#minX = structObj.minX;
|
|
66
|
+
} else {
|
|
67
|
+
throw new Error("Missing required field minX.");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if ("minY" in structObj) {
|
|
71
|
+
this.#minY = structObj.minY;
|
|
72
|
+
} else {
|
|
73
|
+
throw new Error("Missing required field minY.");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if ("minZ" in structObj) {
|
|
77
|
+
this.#minZ = structObj.minZ;
|
|
78
|
+
} else {
|
|
79
|
+
throw new Error("Missing required field minZ.");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if ("maxX" in structObj) {
|
|
83
|
+
this.#maxX = structObj.maxX;
|
|
84
|
+
} else {
|
|
85
|
+
throw new Error("Missing required field maxX.");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if ("maxY" in structObj) {
|
|
89
|
+
this.#maxY = structObj.maxY;
|
|
90
|
+
} else {
|
|
91
|
+
throw new Error("Missing required field maxY.");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if ("maxZ" in structObj) {
|
|
95
|
+
this.#maxZ = structObj.maxZ;
|
|
96
|
+
} else {
|
|
97
|
+
throw new Error("Missing required field maxZ.");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Return this struct in FFI function friendly format.
|
|
104
|
+
// Returns an array that can be expanded with spread syntax (...)
|
|
105
|
+
_intoFFI(
|
|
106
|
+
dst,
|
|
107
|
+
functionCleanupArena,
|
|
108
|
+
appendArrayMap
|
|
109
|
+
) {
|
|
110
|
+
|
|
111
|
+
this._writeToArrayBuffer(wasm.memory.buffer, dst, functionCleanupArena, appendArrayMap);
|
|
112
|
+
|
|
113
|
+
return dst;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static get _sizeBytes() {
|
|
117
|
+
return 24;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/// Currently unused, we may want to use later on though:
|
|
121
|
+
static get _sizeAlign() {
|
|
122
|
+
return 4;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
static _fromSuppliedValue(internalConstructor, obj) {
|
|
126
|
+
if (internalConstructor !== diplomatRuntime.internalConstructor) {
|
|
127
|
+
throw new Error("_fromSuppliedValue cannot be called externally.");
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (obj instanceof RegionBounds) {
|
|
131
|
+
return obj;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return RegionBounds.fromFields(obj);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
_writeToArrayBuffer(
|
|
138
|
+
arrayBuffer,
|
|
139
|
+
offset,
|
|
140
|
+
functionCleanupArena,
|
|
141
|
+
appendArrayMap
|
|
142
|
+
) {
|
|
143
|
+
diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, this.#minX, Int32Array);
|
|
144
|
+
diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 4, this.#minY, Int32Array);
|
|
145
|
+
diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 8, this.#minZ, Int32Array);
|
|
146
|
+
diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 12, this.#maxX, Int32Array);
|
|
147
|
+
diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 16, this.#maxY, Int32Array);
|
|
148
|
+
diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 20, this.#maxZ, Int32Array);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// This struct contains borrowed fields, so this takes in a list of
|
|
152
|
+
// "edges" corresponding to where each lifetime's data may have been borrowed from
|
|
153
|
+
// and passes it down to individual fields containing the borrow.
|
|
154
|
+
// This method does not attempt to handle any dependencies between lifetimes, the caller
|
|
155
|
+
// should handle this when constructing edge arrays.
|
|
156
|
+
static _fromFFI(internalConstructor, ptr) {
|
|
157
|
+
if (internalConstructor !== diplomatRuntime.internalConstructor) {
|
|
158
|
+
throw new Error("RegionBounds._fromFFI is not meant to be called externally. Please use the default constructor.");
|
|
159
|
+
}
|
|
160
|
+
let structObj = {};
|
|
161
|
+
const minXDeref = (new Int32Array(wasm.memory.buffer, ptr, 1))[0];
|
|
162
|
+
structObj.minX = minXDeref;
|
|
163
|
+
const minYDeref = (new Int32Array(wasm.memory.buffer, ptr + 4, 1))[0];
|
|
164
|
+
structObj.minY = minYDeref;
|
|
165
|
+
const minZDeref = (new Int32Array(wasm.memory.buffer, ptr + 8, 1))[0];
|
|
166
|
+
structObj.minZ = minZDeref;
|
|
167
|
+
const maxXDeref = (new Int32Array(wasm.memory.buffer, ptr + 12, 1))[0];
|
|
168
|
+
structObj.maxX = maxXDeref;
|
|
169
|
+
const maxYDeref = (new Int32Array(wasm.memory.buffer, ptr + 16, 1))[0];
|
|
170
|
+
structObj.maxY = maxYDeref;
|
|
171
|
+
const maxZDeref = (new Int32Array(wasm.memory.buffer, ptr + 20, 1))[0];
|
|
172
|
+
structObj.maxZ = maxZDeref;
|
|
173
|
+
|
|
174
|
+
return new RegionBounds(structObj);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
constructor(structObj) {
|
|
179
|
+
return this.#internalConstructor(...arguments)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Camera / output configuration for rendering.
|
|
8
|
+
*/
|
|
9
|
+
export class RenderConfig {
|
|
10
|
+
/** @internal */
|
|
11
|
+
get ffiValue(): pointer;
|
|
12
|
+
/** @internal */
|
|
13
|
+
constructor();
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Create a config with the given output size in pixels. Camera starts
|
|
18
|
+
* at the defaults: yaw 45°, pitch 30°, zoom 1.0, fov 45°, perspective
|
|
19
|
+
* projection, default sky background.
|
|
20
|
+
*/
|
|
21
|
+
static create(width: number, height: number): RenderConfig;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Set the camera yaw (horizontal orbit angle) in degrees. Default: 45.
|
|
25
|
+
*/
|
|
26
|
+
setYaw(yaw: number): void;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Set the camera pitch (downward tilt) in degrees. Default: 30.
|
|
30
|
+
*/
|
|
31
|
+
setPitch(pitch: number): void;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Set the zoom factor scaling the auto-fitted camera distance
|
|
35
|
+
* (1.0 = frame the whole model; larger = further away). Default: 1.0.
|
|
36
|
+
*/
|
|
37
|
+
setZoom(zoom: number): void;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Set the vertical field of view in degrees (perspective projection
|
|
41
|
+
* only). Default: 45.
|
|
42
|
+
*/
|
|
43
|
+
setFov(fov: number): void;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Set a solid RGBA clear color (linear 0.0–1.0). Alpha < 1.0 yields a
|
|
47
|
+
* transparent PNG. Ignored when HDRI is enabled.
|
|
48
|
+
*/
|
|
49
|
+
setBackground(r: number, g: number, b: number, a: number): void;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Clear the custom background — revert to default sky / HDRI.
|
|
53
|
+
*/
|
|
54
|
+
clearBackground(): void;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Enable (`true`) or disable orthographic projection.
|
|
58
|
+
*/
|
|
59
|
+
setOrthographic(orthographic: boolean): void;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Configure a true isometric view: orthographic at yaw 45° /
|
|
63
|
+
* pitch ≈35.264° (preserves the current width/height).
|
|
64
|
+
*/
|
|
65
|
+
setIsometric(): void;
|
|
66
|
+
}
|
package/RenderConfig.mjs
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import wasm from "./diplomat-wasm.mjs";
|
|
3
|
+
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
4
|
+
|
|
5
|
+
const RenderConfig_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
6
|
+
wasm.RenderConfig_destroy(ptr);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Camera / output configuration for rendering.
|
|
11
|
+
*/
|
|
12
|
+
export class RenderConfig {
|
|
13
|
+
// Internal ptr reference:
|
|
14
|
+
#ptr = null;
|
|
15
|
+
|
|
16
|
+
// Lifetimes are only to keep dependencies alive.
|
|
17
|
+
// Since JS won't garbage collect until there are no incoming edges.
|
|
18
|
+
#selfEdge = [];
|
|
19
|
+
|
|
20
|
+
#internalConstructor(symbol, ptr, selfEdge) {
|
|
21
|
+
if (symbol !== diplomatRuntime.internalConstructor) {
|
|
22
|
+
console.error("RenderConfig is an Opaque type. You cannot call its constructor.");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
this.#ptr = ptr;
|
|
26
|
+
this.#selfEdge = selfEdge;
|
|
27
|
+
|
|
28
|
+
// Are we being borrowed? If not, we can register.
|
|
29
|
+
if (this.#selfEdge.length === 0) {
|
|
30
|
+
RenderConfig_box_destroy_registry.register(this, this.#ptr);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
/** @internal */
|
|
36
|
+
get ffiValue() {
|
|
37
|
+
return this.#ptr;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Create a config with the given output size in pixels. Camera starts
|
|
43
|
+
* at the defaults: yaw 45°, pitch 30°, zoom 1.0, fov 45°, perspective
|
|
44
|
+
* projection, default sky background.
|
|
45
|
+
*/
|
|
46
|
+
static create(width, height) {
|
|
47
|
+
|
|
48
|
+
const result = wasm.RenderConfig_create(width, height);
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
return new RenderConfig(diplomatRuntime.internalConstructor, result, []);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
finally {
|
|
55
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Set the camera yaw (horizontal orbit angle) in degrees. Default: 45.
|
|
61
|
+
*/
|
|
62
|
+
setYaw(yaw) {
|
|
63
|
+
wasm.RenderConfig_set_yaw(this.ffiValue, yaw);
|
|
64
|
+
|
|
65
|
+
try {}
|
|
66
|
+
|
|
67
|
+
finally {
|
|
68
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Set the camera pitch (downward tilt) in degrees. Default: 30.
|
|
74
|
+
*/
|
|
75
|
+
setPitch(pitch) {
|
|
76
|
+
wasm.RenderConfig_set_pitch(this.ffiValue, pitch);
|
|
77
|
+
|
|
78
|
+
try {}
|
|
79
|
+
|
|
80
|
+
finally {
|
|
81
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Set the zoom factor scaling the auto-fitted camera distance
|
|
87
|
+
* (1.0 = frame the whole model; larger = further away). Default: 1.0.
|
|
88
|
+
*/
|
|
89
|
+
setZoom(zoom) {
|
|
90
|
+
wasm.RenderConfig_set_zoom(this.ffiValue, zoom);
|
|
91
|
+
|
|
92
|
+
try {}
|
|
93
|
+
|
|
94
|
+
finally {
|
|
95
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Set the vertical field of view in degrees (perspective projection
|
|
101
|
+
* only). Default: 45.
|
|
102
|
+
*/
|
|
103
|
+
setFov(fov) {
|
|
104
|
+
wasm.RenderConfig_set_fov(this.ffiValue, fov);
|
|
105
|
+
|
|
106
|
+
try {}
|
|
107
|
+
|
|
108
|
+
finally {
|
|
109
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Set a solid RGBA clear color (linear 0.0–1.0). Alpha < 1.0 yields a
|
|
115
|
+
* transparent PNG. Ignored when HDRI is enabled.
|
|
116
|
+
*/
|
|
117
|
+
setBackground(r, g, b, a) {
|
|
118
|
+
wasm.RenderConfig_set_background(this.ffiValue, r, g, b, a);
|
|
119
|
+
|
|
120
|
+
try {}
|
|
121
|
+
|
|
122
|
+
finally {
|
|
123
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Clear the custom background — revert to default sky / HDRI.
|
|
129
|
+
*/
|
|
130
|
+
clearBackground() {
|
|
131
|
+
wasm.RenderConfig_clear_background(this.ffiValue);
|
|
132
|
+
|
|
133
|
+
try {}
|
|
134
|
+
|
|
135
|
+
finally {
|
|
136
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Enable (`true`) or disable orthographic projection.
|
|
142
|
+
*/
|
|
143
|
+
setOrthographic(orthographic) {
|
|
144
|
+
wasm.RenderConfig_set_orthographic(this.ffiValue, orthographic);
|
|
145
|
+
|
|
146
|
+
try {}
|
|
147
|
+
|
|
148
|
+
finally {
|
|
149
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Configure a true isometric view: orthographic at yaw 45° /
|
|
155
|
+
* pitch ≈35.264° (preserves the current width/height).
|
|
156
|
+
*/
|
|
157
|
+
setIsometric() {
|
|
158
|
+
wasm.RenderConfig_set_isometric(this.ffiValue);
|
|
159
|
+
|
|
160
|
+
try {}
|
|
161
|
+
|
|
162
|
+
finally {
|
|
163
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
constructor(symbol, ptr, selfEdge) {
|
|
168
|
+
return this.#internalConstructor(...arguments)
|
|
169
|
+
}
|
|
170
|
+
}
|