nucleation 0.11.0 → 0.12.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/README.md +2 -2
- package/Renderer.d.mts +8 -0
- package/Renderer.d.ts +8 -0
- package/Renderer.mjs +21 -0
- package/ResourcePack.d.mts +18 -0
- package/ResourcePack.d.ts +18 -0
- package/ResourcePack.mjs +58 -0
- package/Schematic.d.mts +10 -10
- package/Schematic.d.ts +10 -10
- package/Schematic.mjs +16 -16
- package/nucleation.wasm +0 -0
- package/package.json +1 -1
- package/renderer/README.md +2 -2
- package/renderer/Renderer.d.mts +8 -0
- package/renderer/Renderer.d.ts +8 -0
- package/renderer/Renderer.mjs +21 -0
- package/renderer/ResourcePack.d.mts +18 -0
- package/renderer/ResourcePack.d.ts +18 -0
- package/renderer/ResourcePack.mjs +58 -0
- package/renderer/Schematic.d.mts +10 -10
- package/renderer/Schematic.d.ts +10 -10
- package/renderer/Schematic.mjs +16 -16
- package/renderer/nucleation.wasm +0 -0
package/README.md
CHANGED
|
@@ -62,6 +62,6 @@ available from the main `nucleation` entry point. Each entry owns a separate WAS
|
|
|
62
62
|
instance; import only the entry needed by a worker.
|
|
63
63
|
|
|
64
64
|
Use `renderRegionsJson()` for region bounds and palettes, then
|
|
65
|
-
`regionBlockIndices(name, start, count)` for owned `Uint32Array` windows of
|
|
66
|
-
|
|
65
|
+
`regionBlockIndices(name, start, count)` for owned `Uint32Array` windows of any
|
|
66
|
+
size (shorter at the end of the region). Indices use x-fastest, then z, then y order. Call `clearContents()`
|
|
67
67
|
when done to release schematic storage immediately.
|
package/Renderer.d.mts
CHANGED
|
@@ -17,6 +17,14 @@ export class Renderer {
|
|
|
17
17
|
constructor();
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Why the last render on this thread failed, in words; empty after
|
|
22
|
+
* a successful render. A render that is refused because a resource
|
|
23
|
+
* limit is too small for the software Vulkan driver says which limit
|
|
24
|
+
* and how much it needs.
|
|
25
|
+
*/
|
|
26
|
+
static lastErrorDetail(): string;
|
|
27
|
+
|
|
20
28
|
/**
|
|
21
29
|
* Render a schematic to raw RGBA pixel bytes, written as base64
|
|
22
30
|
* (PORTING rule 6). `pack_zip` is a resource-pack zip in memory.
|
package/Renderer.d.ts
CHANGED
|
@@ -17,6 +17,14 @@ export class Renderer {
|
|
|
17
17
|
constructor();
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Why the last render on this thread failed, in words; empty after
|
|
22
|
+
* a successful render. A render that is refused because a resource
|
|
23
|
+
* limit is too small for the software Vulkan driver says which limit
|
|
24
|
+
* and how much it needs.
|
|
25
|
+
*/
|
|
26
|
+
static lastErrorDetail(): string;
|
|
27
|
+
|
|
20
28
|
/**
|
|
21
29
|
* Render a schematic to raw RGBA pixel bytes, written as base64
|
|
22
30
|
* (PORTING rule 6). `pack_zip` is a resource-pack zip in memory.
|
package/Renderer.mjs
CHANGED
|
@@ -42,6 +42,27 @@ export class Renderer {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Why the last render on this thread failed, in words; empty after
|
|
47
|
+
* a successful render. A render that is refused because a resource
|
|
48
|
+
* limit is too small for the software Vulkan driver says which limit
|
|
49
|
+
* and how much it needs.
|
|
50
|
+
*/
|
|
51
|
+
static lastErrorDetail() {
|
|
52
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
53
|
+
|
|
54
|
+
wasm.Renderer_last_error_detail(write.buffer);
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
return write.readString8();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
finally {
|
|
61
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
62
|
+
write.free();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
45
66
|
/**
|
|
46
67
|
* Render a schematic to raw RGBA pixel bytes, written as base64
|
|
47
68
|
* (PORTING rule 6). `pack_zip` is a resource-pack zip in memory.
|
package/ResourcePack.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import type { NucleationError } from "./NucleationError.mjs"
|
|
3
3
|
import type { ResourcePackList } from "./ResourcePackList.mjs"
|
|
4
|
+
import type { Schematic } from "./Schematic.mjs"
|
|
4
5
|
import type { TextureInfo } from "./TextureInfo.mjs"
|
|
5
6
|
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
6
7
|
|
|
@@ -97,6 +98,23 @@ export class ResourcePack {
|
|
|
97
98
|
*/
|
|
98
99
|
addTexture(name: string, width: number, height: number, pixels: Array<number>): void;
|
|
99
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Skin URLs the player heads in `schematic` need, as a sorted JSON
|
|
103
|
+
* array string. Nucleation never downloads skins: fetch each URL and
|
|
104
|
+
* pass the PNG to `add_player_skin`. Heads whose skin is not
|
|
105
|
+
* registered render with vanilla's default skin for their owner.
|
|
106
|
+
*/
|
|
107
|
+
static playerSkinUrlsJson(schematic: Schematic): string;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Register a downloaded player skin: `url_or_hash` is a URL from
|
|
111
|
+
* `player_skin_urls_json` (or its texture hash), `png` the 64x64 (or
|
|
112
|
+
* legacy 64x32) skin image. Writes the texture's resource location,
|
|
113
|
+
* `nucleation:skins/<hash>`. `InvalidArgument` if the URL has no hash
|
|
114
|
+
* or the PNG is not a skin.
|
|
115
|
+
*/
|
|
116
|
+
addPlayerSkin(urlOrHash: string, png: Array<number>): string;
|
|
117
|
+
|
|
100
118
|
/**
|
|
101
119
|
* Register a MeshExporter with the FormatManager so `save_as("mesh", ...)`
|
|
102
120
|
* works. (Old ABI: `schematic_register_mesh_exporter`.)
|
package/ResourcePack.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import type { NucleationError } from "./NucleationError.mjs"
|
|
3
3
|
import type { ResourcePackList } from "./ResourcePackList.mjs"
|
|
4
|
+
import type { Schematic } from "./Schematic.mjs"
|
|
4
5
|
import type { TextureInfo } from "./TextureInfo.mjs"
|
|
5
6
|
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
6
7
|
|
|
@@ -97,6 +98,23 @@ export class ResourcePack {
|
|
|
97
98
|
*/
|
|
98
99
|
addTexture(name: string, width: number, height: number, pixels: Array<number>): void;
|
|
99
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Skin URLs the player heads in `schematic` need, as a sorted JSON
|
|
103
|
+
* array string. Nucleation never downloads skins: fetch each URL and
|
|
104
|
+
* pass the PNG to `add_player_skin`. Heads whose skin is not
|
|
105
|
+
* registered render with vanilla's default skin for their owner.
|
|
106
|
+
*/
|
|
107
|
+
static playerSkinUrlsJson(schematic: Schematic): string;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Register a downloaded player skin: `url_or_hash` is a URL from
|
|
111
|
+
* `player_skin_urls_json` (or its texture hash), `png` the 64x64 (or
|
|
112
|
+
* legacy 64x32) skin image. Writes the texture's resource location,
|
|
113
|
+
* `nucleation:skins/<hash>`. `InvalidArgument` if the URL has no hash
|
|
114
|
+
* or the PNG is not a skin.
|
|
115
|
+
*/
|
|
116
|
+
addPlayerSkin(urlOrHash: string, png: Array<number>): string;
|
|
117
|
+
|
|
100
118
|
/**
|
|
101
119
|
* Register a MeshExporter with the FormatManager so `save_as("mesh", ...)`
|
|
102
120
|
* works. (Old ABI: `schematic_register_mesh_exporter`.)
|
package/ResourcePack.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import { NucleationError } from "./NucleationError.mjs"
|
|
3
3
|
import { ResourcePackList } from "./ResourcePackList.mjs"
|
|
4
|
+
import { Schematic } from "./Schematic.mjs"
|
|
4
5
|
import { TextureInfo } from "./TextureInfo.mjs"
|
|
5
6
|
import wasm from "./diplomat-wasm.mjs";
|
|
6
7
|
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
@@ -418,6 +419,63 @@ export class ResourcePack {
|
|
|
418
419
|
}
|
|
419
420
|
}
|
|
420
421
|
|
|
422
|
+
/**
|
|
423
|
+
* Skin URLs the player heads in `schematic` need, as a sorted JSON
|
|
424
|
+
* array string. Nucleation never downloads skins: fetch each URL and
|
|
425
|
+
* pass the PNG to `add_player_skin`. Heads whose skin is not
|
|
426
|
+
* registered render with vanilla's default skin for their owner.
|
|
427
|
+
*/
|
|
428
|
+
static playerSkinUrlsJson(schematic) {
|
|
429
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
430
|
+
|
|
431
|
+
wasm.ResourcePack_player_skin_urls_json(schematic.ffiValue, write.buffer);
|
|
432
|
+
|
|
433
|
+
try {
|
|
434
|
+
return write.readString8();
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
finally {
|
|
438
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
439
|
+
write.free();
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Register a downloaded player skin: `url_or_hash` is a URL from
|
|
445
|
+
* `player_skin_urls_json` (or its texture hash), `png` the 64x64 (or
|
|
446
|
+
* legacy 64x32) skin image. Writes the texture's resource location,
|
|
447
|
+
* `nucleation:skins/<hash>`. `InvalidArgument` if the URL has no hash
|
|
448
|
+
* or the PNG is not a skin.
|
|
449
|
+
*/
|
|
450
|
+
addPlayerSkin(urlOrHash, png) {
|
|
451
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
452
|
+
|
|
453
|
+
const urlOrHashSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, urlOrHash)));
|
|
454
|
+
const pngSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, png, "u8")));
|
|
455
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
456
|
+
|
|
457
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
const result = wasm.ResourcePack_add_player_skin(diplomatReceive.buffer, this.ffiValue, urlOrHashSlice.ptr, pngSlice.ptr, write.buffer);
|
|
461
|
+
|
|
462
|
+
try {
|
|
463
|
+
if (!diplomatReceive.resultFlag) {
|
|
464
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
465
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
466
|
+
}
|
|
467
|
+
return write.readString8();
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
finally {
|
|
471
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
472
|
+
functionCleanupArena.free();
|
|
473
|
+
|
|
474
|
+
diplomatReceive.free();
|
|
475
|
+
write.free();
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
421
479
|
/**
|
|
422
480
|
* Register a MeshExporter with the FormatManager so `save_as("mesh", ...)`
|
|
423
481
|
* works. (Old ABI: `schematic_register_mesh_exporter`.)
|
package/Schematic.d.mts
CHANGED
|
@@ -68,8 +68,7 @@ export class Schematic {
|
|
|
68
68
|
splitConnectedAttachNearby(minStandaloneBlocks: number, maxAirGap: number): SchematicSplitResult;
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
|
-
* The
|
|
72
|
-
* bounding box.
|
|
71
|
+
* The dimensions (width, height, length) of the schematic's bounding box.
|
|
73
72
|
*/
|
|
74
73
|
dimensions(): Dimensions;
|
|
75
74
|
|
|
@@ -519,17 +518,17 @@ export class Schematic {
|
|
|
519
518
|
|
|
520
519
|
/**
|
|
521
520
|
* Storage metadata and full block states for palette-index streaming. Region order
|
|
522
|
-
* is default first, then sorted names (highest precedence first); indices are LOCAL to each region.
|
|
523
|
-
*
|
|
521
|
+
* is default first, then sorted names (highest precedence first); indices are LOCAL to each region. `min`
|
|
522
|
+
* and `size` are the region's bounds (never tight bounds); `length` cells, x fastest, then z, then y.
|
|
524
523
|
* No block buffer is cloned or serialized here.
|
|
525
524
|
*/
|
|
526
525
|
renderRegionsJson(): string;
|
|
527
526
|
|
|
528
527
|
/**
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
528
|
+
* Copy a window of a region's palette indices (air included) into `out`:
|
|
529
|
+
* cells `start..start + out.len()` of its bounds, in `render_regions_json`
|
|
530
|
+
* order. Returns the number of cells written (fewer than `out.len()` at the
|
|
531
|
+
* end of the region). No coordinate tuples or intermediate allocation.
|
|
533
532
|
*/
|
|
534
533
|
regionBlockIndices(regionName: string, start: number, count: number): Uint32Array;
|
|
535
534
|
|
|
@@ -909,8 +908,9 @@ export class Schematic {
|
|
|
909
908
|
tightDimensions(): Dimensions;
|
|
910
909
|
|
|
911
910
|
/**
|
|
912
|
-
* The
|
|
913
|
-
* the old
|
|
911
|
+
* The default region's storage dimensions: its bounds plus growth
|
|
912
|
+
* padding (named for parity with the old
|
|
913
|
+
* `schematic_get_allocated_dimensions`).
|
|
914
914
|
*/
|
|
915
915
|
allocatedDimensions(): Dimensions;
|
|
916
916
|
|
package/Schematic.d.ts
CHANGED
|
@@ -68,8 +68,7 @@ export class Schematic {
|
|
|
68
68
|
splitConnectedAttachNearby(minStandaloneBlocks: number, maxAirGap: number): SchematicSplitResult;
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
|
-
* The
|
|
72
|
-
* bounding box.
|
|
71
|
+
* The dimensions (width, height, length) of the schematic's bounding box.
|
|
73
72
|
*/
|
|
74
73
|
dimensions(): Dimensions;
|
|
75
74
|
|
|
@@ -519,17 +518,17 @@ export class Schematic {
|
|
|
519
518
|
|
|
520
519
|
/**
|
|
521
520
|
* Storage metadata and full block states for palette-index streaming. Region order
|
|
522
|
-
* is default first, then sorted names (highest precedence first); indices are LOCAL to each region.
|
|
523
|
-
*
|
|
521
|
+
* is default first, then sorted names (highest precedence first); indices are LOCAL to each region. `min`
|
|
522
|
+
* and `size` are the region's bounds (never tight bounds); `length` cells, x fastest, then z, then y.
|
|
524
523
|
* No block buffer is cloned or serialized here.
|
|
525
524
|
*/
|
|
526
525
|
renderRegionsJson(): string;
|
|
527
526
|
|
|
528
527
|
/**
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
528
|
+
* Copy a window of a region's palette indices (air included) into `out`:
|
|
529
|
+
* cells `start..start + out.len()` of its bounds, in `render_regions_json`
|
|
530
|
+
* order. Returns the number of cells written (fewer than `out.len()` at the
|
|
531
|
+
* end of the region). No coordinate tuples or intermediate allocation.
|
|
533
532
|
*/
|
|
534
533
|
regionBlockIndices(regionName: string, start: number, count: number): Uint32Array;
|
|
535
534
|
|
|
@@ -909,8 +908,9 @@ export class Schematic {
|
|
|
909
908
|
tightDimensions(): Dimensions;
|
|
910
909
|
|
|
911
910
|
/**
|
|
912
|
-
* The
|
|
913
|
-
* the old
|
|
911
|
+
* The default region's storage dimensions: its bounds plus growth
|
|
912
|
+
* padding (named for parity with the old
|
|
913
|
+
* `schematic_get_allocated_dimensions`).
|
|
914
914
|
*/
|
|
915
915
|
allocatedDimensions(): Dimensions;
|
|
916
916
|
|
package/Schematic.mjs
CHANGED
|
@@ -217,8 +217,7 @@ export class Schematic {
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
/**
|
|
220
|
-
* The
|
|
221
|
-
* bounding box.
|
|
220
|
+
* The dimensions (width, height, length) of the schematic's bounding box.
|
|
222
221
|
*/
|
|
223
222
|
dimensions() {
|
|
224
223
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 12, 4, false);
|
|
@@ -2010,8 +2009,8 @@ export class Schematic {
|
|
|
2010
2009
|
|
|
2011
2010
|
/**
|
|
2012
2011
|
* Storage metadata and full block states for palette-index streaming. Region order
|
|
2013
|
-
* is default first, then sorted names (highest precedence first); indices are LOCAL to each region.
|
|
2014
|
-
*
|
|
2012
|
+
* is default first, then sorted names (highest precedence first); indices are LOCAL to each region. `min`
|
|
2013
|
+
* and `size` are the region's bounds (never tight bounds); `length` cells, x fastest, then z, then y.
|
|
2015
2014
|
* No block buffer is cloned or serialized here.
|
|
2016
2015
|
*/
|
|
2017
2016
|
renderRegionsJson() {
|
|
@@ -2030,29 +2029,29 @@ export class Schematic {
|
|
|
2030
2029
|
}
|
|
2031
2030
|
|
|
2032
2031
|
/**
|
|
2033
|
-
*
|
|
2034
|
-
*
|
|
2035
|
-
*
|
|
2036
|
-
*
|
|
2032
|
+
* Copy a window of a region's palette indices (air included) into `out`:
|
|
2033
|
+
* cells `start..start + out.len()` of its bounds, in `render_regions_json`
|
|
2034
|
+
* order. Returns the number of cells written (fewer than `out.len()` at the
|
|
2035
|
+
* end of the region). No coordinate tuples or intermediate allocation.
|
|
2037
2036
|
*/
|
|
2038
2037
|
regionBlockIndices(regionName, start, count) {
|
|
2039
2038
|
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
2040
2039
|
|
|
2041
2040
|
const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
|
|
2042
|
-
const
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
let aEdges = [this];
|
|
2041
|
+
const outBuf = diplomatRuntime.DiplomatBuf.slice(wasm, new Uint32Array(count), "u32");
|
|
2042
|
+
const outSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, outBuf));
|
|
2043
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
2046
2044
|
|
|
2047
2045
|
|
|
2048
|
-
const result = wasm.Schematic_region_block_indices(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr, start,
|
|
2046
|
+
const result = wasm.Schematic_region_block_indices(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr, start, outSlice.ptr);
|
|
2049
2047
|
|
|
2050
2048
|
try {
|
|
2051
2049
|
if (!diplomatReceive.resultFlag) {
|
|
2052
2050
|
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2053
2051
|
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2054
2052
|
}
|
|
2055
|
-
|
|
2053
|
+
const written = (new Uint32Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0];
|
|
2054
|
+
return new Uint32Array(wasm.memory.buffer, outBuf.ptr, written).slice();
|
|
2056
2055
|
}
|
|
2057
2056
|
|
|
2058
2057
|
finally {
|
|
@@ -3552,8 +3551,9 @@ export class Schematic {
|
|
|
3552
3551
|
}
|
|
3553
3552
|
|
|
3554
3553
|
/**
|
|
3555
|
-
* The
|
|
3556
|
-
* the old
|
|
3554
|
+
* The default region's storage dimensions: its bounds plus growth
|
|
3555
|
+
* padding (named for parity with the old
|
|
3556
|
+
* `schematic_get_allocated_dimensions`).
|
|
3557
3557
|
*/
|
|
3558
3558
|
allocatedDimensions() {
|
|
3559
3559
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 12, 4, false);
|
package/nucleation.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/renderer/README.md
CHANGED
|
@@ -62,6 +62,6 @@ available from the main `nucleation` entry point. Each entry owns a separate WAS
|
|
|
62
62
|
instance; import only the entry needed by a worker.
|
|
63
63
|
|
|
64
64
|
Use `renderRegionsJson()` for region bounds and palettes, then
|
|
65
|
-
`regionBlockIndices(name, start, count)` for owned `Uint32Array` windows of
|
|
66
|
-
|
|
65
|
+
`regionBlockIndices(name, start, count)` for owned `Uint32Array` windows of any
|
|
66
|
+
size (shorter at the end of the region). Indices use x-fastest, then z, then y order. Call `clearContents()`
|
|
67
67
|
when done to release schematic storage immediately.
|
package/renderer/Renderer.d.mts
CHANGED
|
@@ -17,6 +17,14 @@ export class Renderer {
|
|
|
17
17
|
constructor();
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Why the last render on this thread failed, in words; empty after
|
|
22
|
+
* a successful render. A render that is refused because a resource
|
|
23
|
+
* limit is too small for the software Vulkan driver says which limit
|
|
24
|
+
* and how much it needs.
|
|
25
|
+
*/
|
|
26
|
+
static lastErrorDetail(): string;
|
|
27
|
+
|
|
20
28
|
/**
|
|
21
29
|
* Render a schematic to raw RGBA pixel bytes, written as base64
|
|
22
30
|
* (PORTING rule 6). `pack_zip` is a resource-pack zip in memory.
|
package/renderer/Renderer.d.ts
CHANGED
|
@@ -17,6 +17,14 @@ export class Renderer {
|
|
|
17
17
|
constructor();
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Why the last render on this thread failed, in words; empty after
|
|
22
|
+
* a successful render. A render that is refused because a resource
|
|
23
|
+
* limit is too small for the software Vulkan driver says which limit
|
|
24
|
+
* and how much it needs.
|
|
25
|
+
*/
|
|
26
|
+
static lastErrorDetail(): string;
|
|
27
|
+
|
|
20
28
|
/**
|
|
21
29
|
* Render a schematic to raw RGBA pixel bytes, written as base64
|
|
22
30
|
* (PORTING rule 6). `pack_zip` is a resource-pack zip in memory.
|
package/renderer/Renderer.mjs
CHANGED
|
@@ -42,6 +42,27 @@ export class Renderer {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Why the last render on this thread failed, in words; empty after
|
|
47
|
+
* a successful render. A render that is refused because a resource
|
|
48
|
+
* limit is too small for the software Vulkan driver says which limit
|
|
49
|
+
* and how much it needs.
|
|
50
|
+
*/
|
|
51
|
+
static lastErrorDetail() {
|
|
52
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
53
|
+
|
|
54
|
+
wasm.Renderer_last_error_detail(write.buffer);
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
return write.readString8();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
finally {
|
|
61
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
62
|
+
write.free();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
45
66
|
/**
|
|
46
67
|
* Render a schematic to raw RGBA pixel bytes, written as base64
|
|
47
68
|
* (PORTING rule 6). `pack_zip` is a resource-pack zip in memory.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import type { NucleationError } from "./NucleationError.mjs"
|
|
3
3
|
import type { ResourcePackList } from "./ResourcePackList.mjs"
|
|
4
|
+
import type { Schematic } from "./Schematic.mjs"
|
|
4
5
|
import type { TextureInfo } from "./TextureInfo.mjs"
|
|
5
6
|
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
6
7
|
|
|
@@ -97,6 +98,23 @@ export class ResourcePack {
|
|
|
97
98
|
*/
|
|
98
99
|
addTexture(name: string, width: number, height: number, pixels: Array<number>): void;
|
|
99
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Skin URLs the player heads in `schematic` need, as a sorted JSON
|
|
103
|
+
* array string. Nucleation never downloads skins: fetch each URL and
|
|
104
|
+
* pass the PNG to `add_player_skin`. Heads whose skin is not
|
|
105
|
+
* registered render with vanilla's default skin for their owner.
|
|
106
|
+
*/
|
|
107
|
+
static playerSkinUrlsJson(schematic: Schematic): string;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Register a downloaded player skin: `url_or_hash` is a URL from
|
|
111
|
+
* `player_skin_urls_json` (or its texture hash), `png` the 64x64 (or
|
|
112
|
+
* legacy 64x32) skin image. Writes the texture's resource location,
|
|
113
|
+
* `nucleation:skins/<hash>`. `InvalidArgument` if the URL has no hash
|
|
114
|
+
* or the PNG is not a skin.
|
|
115
|
+
*/
|
|
116
|
+
addPlayerSkin(urlOrHash: string, png: Array<number>): string;
|
|
117
|
+
|
|
100
118
|
/**
|
|
101
119
|
* Register a MeshExporter with the FormatManager so `save_as("mesh", ...)`
|
|
102
120
|
* works. (Old ABI: `schematic_register_mesh_exporter`.)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import type { NucleationError } from "./NucleationError.mjs"
|
|
3
3
|
import type { ResourcePackList } from "./ResourcePackList.mjs"
|
|
4
|
+
import type { Schematic } from "./Schematic.mjs"
|
|
4
5
|
import type { TextureInfo } from "./TextureInfo.mjs"
|
|
5
6
|
import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
|
|
6
7
|
|
|
@@ -97,6 +98,23 @@ export class ResourcePack {
|
|
|
97
98
|
*/
|
|
98
99
|
addTexture(name: string, width: number, height: number, pixels: Array<number>): void;
|
|
99
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Skin URLs the player heads in `schematic` need, as a sorted JSON
|
|
103
|
+
* array string. Nucleation never downloads skins: fetch each URL and
|
|
104
|
+
* pass the PNG to `add_player_skin`. Heads whose skin is not
|
|
105
|
+
* registered render with vanilla's default skin for their owner.
|
|
106
|
+
*/
|
|
107
|
+
static playerSkinUrlsJson(schematic: Schematic): string;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Register a downloaded player skin: `url_or_hash` is a URL from
|
|
111
|
+
* `player_skin_urls_json` (or its texture hash), `png` the 64x64 (or
|
|
112
|
+
* legacy 64x32) skin image. Writes the texture's resource location,
|
|
113
|
+
* `nucleation:skins/<hash>`. `InvalidArgument` if the URL has no hash
|
|
114
|
+
* or the PNG is not a skin.
|
|
115
|
+
*/
|
|
116
|
+
addPlayerSkin(urlOrHash: string, png: Array<number>): string;
|
|
117
|
+
|
|
100
118
|
/**
|
|
101
119
|
* Register a MeshExporter with the FormatManager so `save_as("mesh", ...)`
|
|
102
120
|
* works. (Old ABI: `schematic_register_mesh_exporter`.)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// generated by diplomat-tool
|
|
2
2
|
import { NucleationError } from "./NucleationError.mjs"
|
|
3
3
|
import { ResourcePackList } from "./ResourcePackList.mjs"
|
|
4
|
+
import { Schematic } from "./Schematic.mjs"
|
|
4
5
|
import { TextureInfo } from "./TextureInfo.mjs"
|
|
5
6
|
import wasm from "./diplomat-wasm.mjs";
|
|
6
7
|
import * as diplomatRuntime from "./diplomat-runtime.mjs";
|
|
@@ -418,6 +419,63 @@ export class ResourcePack {
|
|
|
418
419
|
}
|
|
419
420
|
}
|
|
420
421
|
|
|
422
|
+
/**
|
|
423
|
+
* Skin URLs the player heads in `schematic` need, as a sorted JSON
|
|
424
|
+
* array string. Nucleation never downloads skins: fetch each URL and
|
|
425
|
+
* pass the PNG to `add_player_skin`. Heads whose skin is not
|
|
426
|
+
* registered render with vanilla's default skin for their owner.
|
|
427
|
+
*/
|
|
428
|
+
static playerSkinUrlsJson(schematic) {
|
|
429
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
430
|
+
|
|
431
|
+
wasm.ResourcePack_player_skin_urls_json(schematic.ffiValue, write.buffer);
|
|
432
|
+
|
|
433
|
+
try {
|
|
434
|
+
return write.readString8();
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
finally {
|
|
438
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
439
|
+
write.free();
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Register a downloaded player skin: `url_or_hash` is a URL from
|
|
445
|
+
* `player_skin_urls_json` (or its texture hash), `png` the 64x64 (or
|
|
446
|
+
* legacy 64x32) skin image. Writes the texture's resource location,
|
|
447
|
+
* `nucleation:skins/<hash>`. `InvalidArgument` if the URL has no hash
|
|
448
|
+
* or the PNG is not a skin.
|
|
449
|
+
*/
|
|
450
|
+
addPlayerSkin(urlOrHash, png) {
|
|
451
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
452
|
+
|
|
453
|
+
const urlOrHashSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, urlOrHash)));
|
|
454
|
+
const pngSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, png, "u8")));
|
|
455
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
456
|
+
|
|
457
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
const result = wasm.ResourcePack_add_player_skin(diplomatReceive.buffer, this.ffiValue, urlOrHashSlice.ptr, pngSlice.ptr, write.buffer);
|
|
461
|
+
|
|
462
|
+
try {
|
|
463
|
+
if (!diplomatReceive.resultFlag) {
|
|
464
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
465
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
466
|
+
}
|
|
467
|
+
return write.readString8();
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
finally {
|
|
471
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
472
|
+
functionCleanupArena.free();
|
|
473
|
+
|
|
474
|
+
diplomatReceive.free();
|
|
475
|
+
write.free();
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
421
479
|
/**
|
|
422
480
|
* Register a MeshExporter with the FormatManager so `save_as("mesh", ...)`
|
|
423
481
|
* works. (Old ABI: `schematic_register_mesh_exporter`.)
|
package/renderer/Schematic.d.mts
CHANGED
|
@@ -68,8 +68,7 @@ export class Schematic {
|
|
|
68
68
|
splitConnectedAttachNearby(minStandaloneBlocks: number, maxAirGap: number): SchematicSplitResult;
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
|
-
* The
|
|
72
|
-
* bounding box.
|
|
71
|
+
* The dimensions (width, height, length) of the schematic's bounding box.
|
|
73
72
|
*/
|
|
74
73
|
dimensions(): Dimensions;
|
|
75
74
|
|
|
@@ -519,17 +518,17 @@ export class Schematic {
|
|
|
519
518
|
|
|
520
519
|
/**
|
|
521
520
|
* Storage metadata and full block states for palette-index streaming. Region order
|
|
522
|
-
* is default first, then sorted names (highest precedence first); indices are LOCAL to each region.
|
|
523
|
-
*
|
|
521
|
+
* is default first, then sorted names (highest precedence first); indices are LOCAL to each region. `min`
|
|
522
|
+
* and `size` are the region's bounds (never tight bounds); `length` cells, x fastest, then z, then y.
|
|
524
523
|
* No block buffer is cloned or serialized here.
|
|
525
524
|
*/
|
|
526
525
|
renderRegionsJson(): string;
|
|
527
526
|
|
|
528
527
|
/**
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
528
|
+
* Copy a window of a region's palette indices (air included) into `out`:
|
|
529
|
+
* cells `start..start + out.len()` of its bounds, in `render_regions_json`
|
|
530
|
+
* order. Returns the number of cells written (fewer than `out.len()` at the
|
|
531
|
+
* end of the region). No coordinate tuples or intermediate allocation.
|
|
533
532
|
*/
|
|
534
533
|
regionBlockIndices(regionName: string, start: number, count: number): Uint32Array;
|
|
535
534
|
|
|
@@ -909,8 +908,9 @@ export class Schematic {
|
|
|
909
908
|
tightDimensions(): Dimensions;
|
|
910
909
|
|
|
911
910
|
/**
|
|
912
|
-
* The
|
|
913
|
-
* the old
|
|
911
|
+
* The default region's storage dimensions: its bounds plus growth
|
|
912
|
+
* padding (named for parity with the old
|
|
913
|
+
* `schematic_get_allocated_dimensions`).
|
|
914
914
|
*/
|
|
915
915
|
allocatedDimensions(): Dimensions;
|
|
916
916
|
|
package/renderer/Schematic.d.ts
CHANGED
|
@@ -68,8 +68,7 @@ export class Schematic {
|
|
|
68
68
|
splitConnectedAttachNearby(minStandaloneBlocks: number, maxAirGap: number): SchematicSplitResult;
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
|
-
* The
|
|
72
|
-
* bounding box.
|
|
71
|
+
* The dimensions (width, height, length) of the schematic's bounding box.
|
|
73
72
|
*/
|
|
74
73
|
dimensions(): Dimensions;
|
|
75
74
|
|
|
@@ -519,17 +518,17 @@ export class Schematic {
|
|
|
519
518
|
|
|
520
519
|
/**
|
|
521
520
|
* Storage metadata and full block states for palette-index streaming. Region order
|
|
522
|
-
* is default first, then sorted names (highest precedence first); indices are LOCAL to each region.
|
|
523
|
-
*
|
|
521
|
+
* is default first, then sorted names (highest precedence first); indices are LOCAL to each region. `min`
|
|
522
|
+
* and `size` are the region's bounds (never tight bounds); `length` cells, x fastest, then z, then y.
|
|
524
523
|
* No block buffer is cloned or serialized here.
|
|
525
524
|
*/
|
|
526
525
|
renderRegionsJson(): string;
|
|
527
526
|
|
|
528
527
|
/**
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
*
|
|
528
|
+
* Copy a window of a region's palette indices (air included) into `out`:
|
|
529
|
+
* cells `start..start + out.len()` of its bounds, in `render_regions_json`
|
|
530
|
+
* order. Returns the number of cells written (fewer than `out.len()` at the
|
|
531
|
+
* end of the region). No coordinate tuples or intermediate allocation.
|
|
533
532
|
*/
|
|
534
533
|
regionBlockIndices(regionName: string, start: number, count: number): Uint32Array;
|
|
535
534
|
|
|
@@ -909,8 +908,9 @@ export class Schematic {
|
|
|
909
908
|
tightDimensions(): Dimensions;
|
|
910
909
|
|
|
911
910
|
/**
|
|
912
|
-
* The
|
|
913
|
-
* the old
|
|
911
|
+
* The default region's storage dimensions: its bounds plus growth
|
|
912
|
+
* padding (named for parity with the old
|
|
913
|
+
* `schematic_get_allocated_dimensions`).
|
|
914
914
|
*/
|
|
915
915
|
allocatedDimensions(): Dimensions;
|
|
916
916
|
|
package/renderer/Schematic.mjs
CHANGED
|
@@ -217,8 +217,7 @@ export class Schematic {
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
/**
|
|
220
|
-
* The
|
|
221
|
-
* bounding box.
|
|
220
|
+
* The dimensions (width, height, length) of the schematic's bounding box.
|
|
222
221
|
*/
|
|
223
222
|
dimensions() {
|
|
224
223
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 12, 4, false);
|
|
@@ -2010,8 +2009,8 @@ export class Schematic {
|
|
|
2010
2009
|
|
|
2011
2010
|
/**
|
|
2012
2011
|
* Storage metadata and full block states for palette-index streaming. Region order
|
|
2013
|
-
* is default first, then sorted names (highest precedence first); indices are LOCAL to each region.
|
|
2014
|
-
*
|
|
2012
|
+
* is default first, then sorted names (highest precedence first); indices are LOCAL to each region. `min`
|
|
2013
|
+
* and `size` are the region's bounds (never tight bounds); `length` cells, x fastest, then z, then y.
|
|
2015
2014
|
* No block buffer is cloned or serialized here.
|
|
2016
2015
|
*/
|
|
2017
2016
|
renderRegionsJson() {
|
|
@@ -2030,29 +2029,29 @@ export class Schematic {
|
|
|
2030
2029
|
}
|
|
2031
2030
|
|
|
2032
2031
|
/**
|
|
2033
|
-
*
|
|
2034
|
-
*
|
|
2035
|
-
*
|
|
2036
|
-
*
|
|
2032
|
+
* Copy a window of a region's palette indices (air included) into `out`:
|
|
2033
|
+
* cells `start..start + out.len()` of its bounds, in `render_regions_json`
|
|
2034
|
+
* order. Returns the number of cells written (fewer than `out.len()` at the
|
|
2035
|
+
* end of the region). No coordinate tuples or intermediate allocation.
|
|
2037
2036
|
*/
|
|
2038
2037
|
regionBlockIndices(regionName, start, count) {
|
|
2039
2038
|
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
2040
2039
|
|
|
2041
2040
|
const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
|
|
2042
|
-
const
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
let aEdges = [this];
|
|
2041
|
+
const outBuf = diplomatRuntime.DiplomatBuf.slice(wasm, new Uint32Array(count), "u32");
|
|
2042
|
+
const outSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, outBuf));
|
|
2043
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
2046
2044
|
|
|
2047
2045
|
|
|
2048
|
-
const result = wasm.Schematic_region_block_indices(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr, start,
|
|
2046
|
+
const result = wasm.Schematic_region_block_indices(diplomatReceive.buffer, this.ffiValue, regionNameSlice.ptr, start, outSlice.ptr);
|
|
2049
2047
|
|
|
2050
2048
|
try {
|
|
2051
2049
|
if (!diplomatReceive.resultFlag) {
|
|
2052
2050
|
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2053
2051
|
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2054
2052
|
}
|
|
2055
|
-
|
|
2053
|
+
const written = (new Uint32Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0];
|
|
2054
|
+
return new Uint32Array(wasm.memory.buffer, outBuf.ptr, written).slice();
|
|
2056
2055
|
}
|
|
2057
2056
|
|
|
2058
2057
|
finally {
|
|
@@ -3552,8 +3551,9 @@ export class Schematic {
|
|
|
3552
3551
|
}
|
|
3553
3552
|
|
|
3554
3553
|
/**
|
|
3555
|
-
* The
|
|
3556
|
-
* the old
|
|
3554
|
+
* The default region's storage dimensions: its bounds plus growth
|
|
3555
|
+
* padding (named for parity with the old
|
|
3556
|
+
* `schematic_get_allocated_dimensions`).
|
|
3557
3557
|
*/
|
|
3558
3558
|
allocatedDimensions() {
|
|
3559
3559
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 12, 4, false);
|
package/renderer/nucleation.wasm
CHANGED
|
Binary file
|