nucleation 0.2.17 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +59 -0
- package/Brush.mjs +203 -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/README.md +28 -196
- 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 +113 -0
- package/index.mjs +116 -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
package/StoreIo.mjs
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import { NucleationError } from "./NucleationError.mjs"
|
|
3
|
+
import { Schematic } from "./Schematic.mjs"
|
|
4
|
+
import wasm from "./diplomat-wasm.mjs";
|
|
5
|
+
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
6
|
+
|
|
7
|
+
const StoreIo_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
8
|
+
wasm.StoreIo_destroy(ptr);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Namespace type for the URI-based transparent I/O and format-manager
|
|
13
|
+
* queries (PORTING rule 12).
|
|
14
|
+
*/
|
|
15
|
+
export class StoreIo {
|
|
16
|
+
// Internal ptr reference:
|
|
17
|
+
#ptr = null;
|
|
18
|
+
|
|
19
|
+
// Lifetimes are only to keep dependencies alive.
|
|
20
|
+
// Since JS won't garbage collect until there are no incoming edges.
|
|
21
|
+
#selfEdge = [];
|
|
22
|
+
|
|
23
|
+
#internalConstructor(symbol, ptr, selfEdge) {
|
|
24
|
+
if (symbol !== diplomatRuntime.internalConstructor) {
|
|
25
|
+
console.error("StoreIo is an Opaque type. You cannot call its constructor.");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
this.#ptr = ptr;
|
|
29
|
+
this.#selfEdge = selfEdge;
|
|
30
|
+
|
|
31
|
+
// Are we being borrowed? If not, we can register.
|
|
32
|
+
if (this.#selfEdge.length === 0) {
|
|
33
|
+
StoreIo_box_destroy_registry.register(this, this.#ptr);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
/** @internal */
|
|
39
|
+
get ffiValue() {
|
|
40
|
+
return this.#ptr;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Open a schematic from a URI: a local path, `file://...`, or
|
|
46
|
+
* `s3://bucket/key.schem`. The format is auto-detected from the URI's
|
|
47
|
+
* extension. Single-string URIs for `redis://`, `postgres://`, and
|
|
48
|
+
* `mem://` are rejected by the core resolver; use `Store::open_schematic`
|
|
49
|
+
* with an explicit store for those backends.
|
|
50
|
+
*/
|
|
51
|
+
static open(uri) {
|
|
52
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
53
|
+
|
|
54
|
+
const uriSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, uri)));
|
|
55
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
const result = wasm.StoreIo_open(diplomatReceive.buffer, uriSlice.ptr);
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
if (!diplomatReceive.resultFlag) {
|
|
62
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
63
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
64
|
+
}
|
|
65
|
+
return new Schematic(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
finally {
|
|
69
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
70
|
+
functionCleanupArena.free();
|
|
71
|
+
|
|
72
|
+
diplomatReceive.free();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Save a schematic to a URI: a local path, `file://...`, or
|
|
78
|
+
* `s3://bucket/key.schem`. The format is auto-detected from the URI's
|
|
79
|
+
* extension; `version` selects the format version (empty string =
|
|
80
|
+
* format default). Single-string URIs for `redis://`, `postgres://`, and
|
|
81
|
+
* `mem://` are rejected by the core resolver; use `Store::save_schematic`
|
|
82
|
+
* with an explicit store for those backends.
|
|
83
|
+
*/
|
|
84
|
+
static save(schematic, uri, version) {
|
|
85
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
86
|
+
|
|
87
|
+
const uriSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, uri)));
|
|
88
|
+
const versionSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, version)));
|
|
89
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
const result = wasm.StoreIo_save(diplomatReceive.buffer, schematic.ffiValue, uriSlice.ptr, versionSlice.ptr);
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
if (!diplomatReceive.resultFlag) {
|
|
96
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
97
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
finally {
|
|
102
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
103
|
+
functionCleanupArena.free();
|
|
104
|
+
|
|
105
|
+
diplomatReceive.free();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The JSON schema describing the export settings of `format`. Errors
|
|
111
|
+
* with `NotFound` for an unknown format.
|
|
112
|
+
*/
|
|
113
|
+
static exportSettingsSchema(format) {
|
|
114
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
115
|
+
|
|
116
|
+
const formatSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, format)));
|
|
117
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
118
|
+
|
|
119
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
const result = wasm.StoreIo_export_settings_schema(diplomatReceive.buffer, formatSlice.ptr, write.buffer);
|
|
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 write.readString8();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
finally {
|
|
133
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
134
|
+
functionCleanupArena.free();
|
|
135
|
+
|
|
136
|
+
diplomatReceive.free();
|
|
137
|
+
write.free();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The JSON schema describing the import settings of `format`. Errors
|
|
143
|
+
* with `NotFound` for an unknown format.
|
|
144
|
+
*/
|
|
145
|
+
static importSettingsSchema(format) {
|
|
146
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
147
|
+
|
|
148
|
+
const formatSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, format)));
|
|
149
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
150
|
+
|
|
151
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
const result = wasm.StoreIo_import_settings_schema(diplomatReceive.buffer, formatSlice.ptr, write.buffer);
|
|
155
|
+
|
|
156
|
+
try {
|
|
157
|
+
if (!diplomatReceive.resultFlag) {
|
|
158
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
159
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
160
|
+
}
|
|
161
|
+
return write.readString8();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
finally {
|
|
165
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
166
|
+
functionCleanupArena.free();
|
|
167
|
+
|
|
168
|
+
diplomatReceive.free();
|
|
169
|
+
write.free();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* The supported import formats, written as a JSON array string.
|
|
175
|
+
*/
|
|
176
|
+
static supportedImportFormats() {
|
|
177
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
178
|
+
|
|
179
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
const result = wasm.StoreIo_supported_import_formats(diplomatReceive.buffer, write.buffer);
|
|
183
|
+
|
|
184
|
+
try {
|
|
185
|
+
if (!diplomatReceive.resultFlag) {
|
|
186
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
187
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
188
|
+
}
|
|
189
|
+
return write.readString8();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
finally {
|
|
193
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
194
|
+
diplomatReceive.free();
|
|
195
|
+
write.free();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* The supported export formats, written as a JSON array string.
|
|
201
|
+
*/
|
|
202
|
+
static supportedExportFormats() {
|
|
203
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
204
|
+
|
|
205
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
const result = wasm.StoreIo_supported_export_formats(diplomatReceive.buffer, write.buffer);
|
|
209
|
+
|
|
210
|
+
try {
|
|
211
|
+
if (!diplomatReceive.resultFlag) {
|
|
212
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
213
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
214
|
+
}
|
|
215
|
+
return write.readString8();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
finally {
|
|
219
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
220
|
+
diplomatReceive.free();
|
|
221
|
+
write.free();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* The known versions of an export format, written as a JSON array string
|
|
227
|
+
* (empty array for an unknown format, matching the old ABI).
|
|
228
|
+
*/
|
|
229
|
+
static formatVersions(format) {
|
|
230
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
231
|
+
|
|
232
|
+
const formatSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, format)));
|
|
233
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
234
|
+
|
|
235
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
const result = wasm.StoreIo_format_versions(diplomatReceive.buffer, formatSlice.ptr, write.buffer);
|
|
239
|
+
|
|
240
|
+
try {
|
|
241
|
+
if (!diplomatReceive.resultFlag) {
|
|
242
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
243
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
244
|
+
}
|
|
245
|
+
return write.readString8();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
finally {
|
|
249
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
250
|
+
functionCleanupArena.free();
|
|
251
|
+
|
|
252
|
+
diplomatReceive.free();
|
|
253
|
+
write.free();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* The default version of an export format. Errors with `NotFound` for an
|
|
259
|
+
* unknown format.
|
|
260
|
+
*/
|
|
261
|
+
static defaultFormatVersion(format) {
|
|
262
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
263
|
+
|
|
264
|
+
const formatSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, format)));
|
|
265
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
266
|
+
|
|
267
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
const result = wasm.StoreIo_default_format_version(diplomatReceive.buffer, formatSlice.ptr, write.buffer);
|
|
271
|
+
|
|
272
|
+
try {
|
|
273
|
+
if (!diplomatReceive.resultFlag) {
|
|
274
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
275
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
276
|
+
}
|
|
277
|
+
return write.readString8();
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
finally {
|
|
281
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
282
|
+
functionCleanupArena.free();
|
|
283
|
+
|
|
284
|
+
diplomatReceive.free();
|
|
285
|
+
write.free();
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
constructor(symbol, ptr, selfEdge) {
|
|
290
|
+
return this.#internalConstructor(...arguments)
|
|
291
|
+
}
|
|
292
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { MeshConfig } from "./MeshConfig"
|
|
3
|
+
import type { NucleationError } from "./NucleationError"
|
|
4
|
+
import type { ResourcePack } from "./ResourcePack"
|
|
5
|
+
import type { Schematic } from "./Schematic"
|
|
6
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A packed texture atlas. Wraps {@link schematic_mesher::TextureAtlas}.
|
|
12
|
+
*/
|
|
13
|
+
export class TextureAtlas {
|
|
14
|
+
/** @internal */
|
|
15
|
+
get ffiValue(): pointer;
|
|
16
|
+
/** @internal */
|
|
17
|
+
constructor();
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Build a single shared atlas from every unique block state in the
|
|
22
|
+
* schematic (old ABI: `schematic_build_global_atlas`).
|
|
23
|
+
*/
|
|
24
|
+
static buildGlobal(schematic: Schematic, pack: ResourcePack, config: MeshConfig): TextureAtlas;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Atlas width in pixels.
|
|
28
|
+
*/
|
|
29
|
+
width(): number;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Atlas height in pixels.
|
|
33
|
+
*/
|
|
34
|
+
height(): number;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Raw RGBA atlas pixels, base64-encoded.
|
|
38
|
+
*/
|
|
39
|
+
rgbaDataB64(): string;
|
|
40
|
+
}
|
package/TextureAtlas.mjs
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import { MeshConfig } from "./MeshConfig.mjs"
|
|
3
|
+
import { NucleationError } from "./NucleationError.mjs"
|
|
4
|
+
import { ResourcePack } from "./ResourcePack.mjs"
|
|
5
|
+
import { Schematic } from "./Schematic.mjs"
|
|
6
|
+
import wasm from "./diplomat-wasm.mjs";
|
|
7
|
+
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
8
|
+
|
|
9
|
+
const TextureAtlas_box_destroy_registry = new FinalizationRegistry((ptr) => {
|
|
10
|
+
wasm.TextureAtlas_destroy(ptr);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A packed texture atlas. Wraps {@link schematic_mesher::TextureAtlas}.
|
|
15
|
+
*/
|
|
16
|
+
export class TextureAtlas {
|
|
17
|
+
// Internal ptr reference:
|
|
18
|
+
#ptr = null;
|
|
19
|
+
|
|
20
|
+
// Lifetimes are only to keep dependencies alive.
|
|
21
|
+
// Since JS won't garbage collect until there are no incoming edges.
|
|
22
|
+
#selfEdge = [];
|
|
23
|
+
|
|
24
|
+
#internalConstructor(symbol, ptr, selfEdge) {
|
|
25
|
+
if (symbol !== diplomatRuntime.internalConstructor) {
|
|
26
|
+
console.error("TextureAtlas is an Opaque type. You cannot call its constructor.");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
this.#ptr = ptr;
|
|
30
|
+
this.#selfEdge = selfEdge;
|
|
31
|
+
|
|
32
|
+
// Are we being borrowed? If not, we can register.
|
|
33
|
+
if (this.#selfEdge.length === 0) {
|
|
34
|
+
TextureAtlas_box_destroy_registry.register(this, this.#ptr);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
/** @internal */
|
|
40
|
+
get ffiValue() {
|
|
41
|
+
return this.#ptr;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Build a single shared atlas from every unique block state in the
|
|
47
|
+
* schematic (old ABI: `schematic_build_global_atlas`).
|
|
48
|
+
*/
|
|
49
|
+
static buildGlobal(schematic, pack, config) {
|
|
50
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
const result = wasm.TextureAtlas_build_global(diplomatReceive.buffer, schematic.ffiValue, pack.ffiValue, config.ffiValue);
|
|
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 TextureAtlas(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
finally {
|
|
64
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
65
|
+
diplomatReceive.free();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Atlas width in pixels.
|
|
71
|
+
*/
|
|
72
|
+
width() {
|
|
73
|
+
|
|
74
|
+
const result = wasm.TextureAtlas_width(this.ffiValue);
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
finally {
|
|
81
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Atlas height in pixels.
|
|
87
|
+
*/
|
|
88
|
+
height() {
|
|
89
|
+
|
|
90
|
+
const result = wasm.TextureAtlas_height(this.ffiValue);
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
finally {
|
|
97
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Raw RGBA atlas pixels, base64-encoded.
|
|
103
|
+
*/
|
|
104
|
+
rgbaDataB64() {
|
|
105
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
106
|
+
|
|
107
|
+
wasm.TextureAtlas_rgba_data_b64(this.ffiValue, write.buffer);
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
return write.readString8();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
finally {
|
|
114
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
115
|
+
write.free();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
constructor(symbol, ptr, selfEdge) {
|
|
120
|
+
return this.#internalConstructor(...arguments)
|
|
121
|
+
}
|
|
122
|
+
}
|
package/TextureInfo.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// generated by diplomat-tool
|
|
2
|
+
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
3
|
+
|
|
4
|
+
export type TextureInfo_obj = {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
animated: boolean;
|
|
8
|
+
frameCount: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Texture size/animation metadata for one texture in a resource pack.
|
|
15
|
+
*/
|
|
16
|
+
export class TextureInfo {
|
|
17
|
+
get width(): number;
|
|
18
|
+
set width(value: number);
|
|
19
|
+
get height(): number;
|
|
20
|
+
set height(value: number);
|
|
21
|
+
get animated(): boolean;
|
|
22
|
+
set animated(value: boolean);
|
|
23
|
+
get frameCount(): number;
|
|
24
|
+
set frameCount(value: number);
|
|
25
|
+
/** @internal */
|
|
26
|
+
static fromFields(structObj : TextureInfo_obj) : TextureInfo;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Create `TextureInfo` from an object that contains all of `TextureInfo`s fields.
|
|
30
|
+
* Optional fields do not need to be included in the provided object.
|
|
31
|
+
*/
|
|
32
|
+
constructor(structObj: TextureInfo_obj);
|
|
33
|
+
|
|
34
|
+
}
|
package/TextureInfo.mjs
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
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
|
+
* Texture size/animation metadata for one texture in a resource pack.
|
|
9
|
+
*/
|
|
10
|
+
export class TextureInfo {
|
|
11
|
+
#width;
|
|
12
|
+
get width() {
|
|
13
|
+
return this.#width;
|
|
14
|
+
}
|
|
15
|
+
set width(value){
|
|
16
|
+
this.#width = value;
|
|
17
|
+
}
|
|
18
|
+
#height;
|
|
19
|
+
get height() {
|
|
20
|
+
return this.#height;
|
|
21
|
+
}
|
|
22
|
+
set height(value){
|
|
23
|
+
this.#height = value;
|
|
24
|
+
}
|
|
25
|
+
#animated;
|
|
26
|
+
get animated() {
|
|
27
|
+
return this.#animated;
|
|
28
|
+
}
|
|
29
|
+
set animated(value){
|
|
30
|
+
this.#animated = value;
|
|
31
|
+
}
|
|
32
|
+
#frameCount;
|
|
33
|
+
get frameCount() {
|
|
34
|
+
return this.#frameCount;
|
|
35
|
+
}
|
|
36
|
+
set frameCount(value){
|
|
37
|
+
this.#frameCount = value;
|
|
38
|
+
}
|
|
39
|
+
/** @internal */
|
|
40
|
+
static fromFields(structObj) {
|
|
41
|
+
return new TextureInfo(structObj);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#internalConstructor(structObj) {
|
|
45
|
+
if (typeof structObj !== "object") {
|
|
46
|
+
throw new Error("TextureInfo's constructor takes an object of TextureInfo's fields.");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if ("width" in structObj) {
|
|
50
|
+
this.#width = structObj.width;
|
|
51
|
+
} else {
|
|
52
|
+
throw new Error("Missing required field width.");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if ("height" in structObj) {
|
|
56
|
+
this.#height = structObj.height;
|
|
57
|
+
} else {
|
|
58
|
+
throw new Error("Missing required field height.");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if ("animated" in structObj) {
|
|
62
|
+
this.#animated = structObj.animated;
|
|
63
|
+
} else {
|
|
64
|
+
throw new Error("Missing required field animated.");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if ("frameCount" in structObj) {
|
|
68
|
+
this.#frameCount = structObj.frameCount;
|
|
69
|
+
} else {
|
|
70
|
+
throw new Error("Missing required field frameCount.");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Return this struct in FFI function friendly format.
|
|
77
|
+
// Returns an array that can be expanded with spread syntax (...)
|
|
78
|
+
_intoFFI(
|
|
79
|
+
dst,
|
|
80
|
+
functionCleanupArena,
|
|
81
|
+
appendArrayMap
|
|
82
|
+
) {
|
|
83
|
+
|
|
84
|
+
this._writeToArrayBuffer(wasm.memory.buffer, dst, functionCleanupArena, appendArrayMap);
|
|
85
|
+
|
|
86
|
+
return dst;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
static get _sizeBytes() {
|
|
90
|
+
return 16;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/// Currently unused, we may want to use later on though:
|
|
94
|
+
static get _sizeAlign() {
|
|
95
|
+
return 4;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
static _fromSuppliedValue(internalConstructor, obj) {
|
|
99
|
+
if (internalConstructor !== diplomatRuntime.internalConstructor) {
|
|
100
|
+
throw new Error("_fromSuppliedValue cannot be called externally.");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (obj instanceof TextureInfo) {
|
|
104
|
+
return obj;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return TextureInfo.fromFields(obj);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
_writeToArrayBuffer(
|
|
111
|
+
arrayBuffer,
|
|
112
|
+
offset,
|
|
113
|
+
functionCleanupArena,
|
|
114
|
+
appendArrayMap
|
|
115
|
+
) {
|
|
116
|
+
diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 0, this.#width, Uint32Array);
|
|
117
|
+
diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 4, this.#height, Uint32Array);
|
|
118
|
+
diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 8, this.#animated, Uint8Array);
|
|
119
|
+
diplomatRuntime.writeToArrayBuffer(arrayBuffer, offset + 12, this.#frameCount, Uint32Array);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// This struct contains borrowed fields, so this takes in a list of
|
|
123
|
+
// "edges" corresponding to where each lifetime's data may have been borrowed from
|
|
124
|
+
// and passes it down to individual fields containing the borrow.
|
|
125
|
+
// This method does not attempt to handle any dependencies between lifetimes, the caller
|
|
126
|
+
// should handle this when constructing edge arrays.
|
|
127
|
+
static _fromFFI(internalConstructor, ptr) {
|
|
128
|
+
if (internalConstructor !== diplomatRuntime.internalConstructor) {
|
|
129
|
+
throw new Error("TextureInfo._fromFFI is not meant to be called externally. Please use the default constructor.");
|
|
130
|
+
}
|
|
131
|
+
let structObj = {};
|
|
132
|
+
const widthDeref = (new Uint32Array(wasm.memory.buffer, ptr, 1))[0];
|
|
133
|
+
structObj.width = widthDeref;
|
|
134
|
+
const heightDeref = (new Uint32Array(wasm.memory.buffer, ptr + 4, 1))[0];
|
|
135
|
+
structObj.height = heightDeref;
|
|
136
|
+
const animatedDeref = (new Uint8Array(wasm.memory.buffer, ptr + 8, 1))[0] === 1;
|
|
137
|
+
structObj.animated = animatedDeref;
|
|
138
|
+
const frameCountDeref = (new Uint32Array(wasm.memory.buffer, ptr + 12, 1))[0];
|
|
139
|
+
structObj.frameCount = frameCountDeref;
|
|
140
|
+
|
|
141
|
+
return new TextureInfo(structObj);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
constructor(structObj) {
|
|
146
|
+
return this.#internalConstructor(...arguments)
|
|
147
|
+
}
|
|
148
|
+
}
|