nucleation 0.10.27 → 0.12.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/README.md +2 -2
- package/Schematic.d.mts +19 -10
- package/Schematic.d.ts +19 -10
- package/Schematic.mjs +50 -16
- package/nucleation.wasm +0 -0
- package/package.json +1 -1
- package/renderer/README.md +2 -2
- package/renderer/Schematic.d.mts +19 -10
- package/renderer/Schematic.d.ts +19 -10
- package/renderer/Schematic.mjs +50 -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/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
|
|
|
@@ -221,6 +220,15 @@ export class Schematic {
|
|
|
221
220
|
*/
|
|
222
221
|
setBlocks(positions: Array<number>, blockName: string): number;
|
|
223
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Place many different blocks in one call: position `i` gets
|
|
225
|
+
* `palette[indices[i]]`. `positions` is flat `[x0,y0,z0, ...]`,
|
|
226
|
+
* `indices` has one entry per position, and `palette_json` is a JSON
|
|
227
|
+
* array of block strings (properties and NBT allowed, `simulate` not).
|
|
228
|
+
* Returns the number of blocks set.
|
|
229
|
+
*/
|
|
230
|
+
setBlocksIndexed(positions: Array<number>, indices: Array<number>, paletteJson: string): number;
|
|
231
|
+
|
|
224
232
|
/**
|
|
225
233
|
* Sequentially hand-place the same block at many positions in one
|
|
226
234
|
* local simulated component. `positions` is flat
|
|
@@ -510,17 +518,17 @@ export class Schematic {
|
|
|
510
518
|
|
|
511
519
|
/**
|
|
512
520
|
* Storage metadata and full block states for palette-index streaming. Region order
|
|
513
|
-
* is default first, then sorted names (highest precedence first); indices are LOCAL to each region.
|
|
514
|
-
*
|
|
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.
|
|
515
523
|
* No block buffer is cloned or serialized here.
|
|
516
524
|
*/
|
|
517
525
|
renderRegionsJson(): string;
|
|
518
526
|
|
|
519
527
|
/**
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
*
|
|
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.
|
|
524
532
|
*/
|
|
525
533
|
regionBlockIndices(regionName: string, start: number, count: number): Uint32Array;
|
|
526
534
|
|
|
@@ -900,8 +908,9 @@ export class Schematic {
|
|
|
900
908
|
tightDimensions(): Dimensions;
|
|
901
909
|
|
|
902
910
|
/**
|
|
903
|
-
* The
|
|
904
|
-
* 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`).
|
|
905
914
|
*/
|
|
906
915
|
allocatedDimensions(): Dimensions;
|
|
907
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
|
|
|
@@ -221,6 +220,15 @@ export class Schematic {
|
|
|
221
220
|
*/
|
|
222
221
|
setBlocks(positions: Array<number>, blockName: string): number;
|
|
223
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Place many different blocks in one call: position `i` gets
|
|
225
|
+
* `palette[indices[i]]`. `positions` is flat `[x0,y0,z0, ...]`,
|
|
226
|
+
* `indices` has one entry per position, and `palette_json` is a JSON
|
|
227
|
+
* array of block strings (properties and NBT allowed, `simulate` not).
|
|
228
|
+
* Returns the number of blocks set.
|
|
229
|
+
*/
|
|
230
|
+
setBlocksIndexed(positions: Array<number>, indices: Array<number>, paletteJson: string): number;
|
|
231
|
+
|
|
224
232
|
/**
|
|
225
233
|
* Sequentially hand-place the same block at many positions in one
|
|
226
234
|
* local simulated component. `positions` is flat
|
|
@@ -510,17 +518,17 @@ export class Schematic {
|
|
|
510
518
|
|
|
511
519
|
/**
|
|
512
520
|
* Storage metadata and full block states for palette-index streaming. Region order
|
|
513
|
-
* is default first, then sorted names (highest precedence first); indices are LOCAL to each region.
|
|
514
|
-
*
|
|
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.
|
|
515
523
|
* No block buffer is cloned or serialized here.
|
|
516
524
|
*/
|
|
517
525
|
renderRegionsJson(): string;
|
|
518
526
|
|
|
519
527
|
/**
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
*
|
|
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.
|
|
524
532
|
*/
|
|
525
533
|
regionBlockIndices(regionName: string, start: number, count: number): Uint32Array;
|
|
526
534
|
|
|
@@ -900,8 +908,9 @@ export class Schematic {
|
|
|
900
908
|
tightDimensions(): Dimensions;
|
|
901
909
|
|
|
902
910
|
/**
|
|
903
|
-
* The
|
|
904
|
-
* 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`).
|
|
905
914
|
*/
|
|
906
915
|
allocatedDimensions(): Dimensions;
|
|
907
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);
|
|
@@ -973,6 +972,40 @@ export class Schematic {
|
|
|
973
972
|
}
|
|
974
973
|
}
|
|
975
974
|
|
|
975
|
+
/**
|
|
976
|
+
* Place many different blocks in one call: position `i` gets
|
|
977
|
+
* `palette[indices[i]]`. `positions` is flat `[x0,y0,z0, ...]`,
|
|
978
|
+
* `indices` has one entry per position, and `palette_json` is a JSON
|
|
979
|
+
* array of block strings (properties and NBT allowed, `simulate` not).
|
|
980
|
+
* Returns the number of blocks set.
|
|
981
|
+
*/
|
|
982
|
+
setBlocksIndexed(positions, indices, paletteJson) {
|
|
983
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
984
|
+
|
|
985
|
+
const positionsSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, positions, "i32")));
|
|
986
|
+
const indicesSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, indices, "u32")));
|
|
987
|
+
const paletteJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, paletteJson)));
|
|
988
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
989
|
+
|
|
990
|
+
|
|
991
|
+
const result = wasm.Schematic_set_blocks_indexed(diplomatReceive.buffer, this.ffiValue, positionsSlice.ptr, indicesSlice.ptr, paletteJsonSlice.ptr);
|
|
992
|
+
|
|
993
|
+
try {
|
|
994
|
+
if (!diplomatReceive.resultFlag) {
|
|
995
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
996
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
997
|
+
}
|
|
998
|
+
return (new Int32Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0];
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
finally {
|
|
1002
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1003
|
+
functionCleanupArena.free();
|
|
1004
|
+
|
|
1005
|
+
diplomatReceive.free();
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
|
|
976
1009
|
/**
|
|
977
1010
|
* Sequentially hand-place the same block at many positions in one
|
|
978
1011
|
* local simulated component. `positions` is flat
|
|
@@ -1976,8 +2009,8 @@ export class Schematic {
|
|
|
1976
2009
|
|
|
1977
2010
|
/**
|
|
1978
2011
|
* Storage metadata and full block states for palette-index streaming. Region order
|
|
1979
|
-
* is default first, then sorted names (highest precedence first); indices are LOCAL to each region.
|
|
1980
|
-
*
|
|
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.
|
|
1981
2014
|
* No block buffer is cloned or serialized here.
|
|
1982
2015
|
*/
|
|
1983
2016
|
renderRegionsJson() {
|
|
@@ -1996,29 +2029,29 @@ export class Schematic {
|
|
|
1996
2029
|
}
|
|
1997
2030
|
|
|
1998
2031
|
/**
|
|
1999
|
-
*
|
|
2000
|
-
*
|
|
2001
|
-
*
|
|
2002
|
-
*
|
|
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.
|
|
2003
2036
|
*/
|
|
2004
2037
|
regionBlockIndices(regionName, start, count) {
|
|
2005
2038
|
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
2006
2039
|
|
|
2007
2040
|
const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
|
|
2008
|
-
const
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
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);
|
|
2012
2044
|
|
|
2013
2045
|
|
|
2014
|
-
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);
|
|
2015
2047
|
|
|
2016
2048
|
try {
|
|
2017
2049
|
if (!diplomatReceive.resultFlag) {
|
|
2018
2050
|
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2019
2051
|
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2020
2052
|
}
|
|
2021
|
-
|
|
2053
|
+
const written = (new Uint32Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0];
|
|
2054
|
+
return new Uint32Array(wasm.memory.buffer, outBuf.ptr, written).slice();
|
|
2022
2055
|
}
|
|
2023
2056
|
|
|
2024
2057
|
finally {
|
|
@@ -3518,8 +3551,9 @@ export class Schematic {
|
|
|
3518
3551
|
}
|
|
3519
3552
|
|
|
3520
3553
|
/**
|
|
3521
|
-
* The
|
|
3522
|
-
* 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`).
|
|
3523
3557
|
*/
|
|
3524
3558
|
allocatedDimensions() {
|
|
3525
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/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
|
|
|
@@ -221,6 +220,15 @@ export class Schematic {
|
|
|
221
220
|
*/
|
|
222
221
|
setBlocks(positions: Array<number>, blockName: string): number;
|
|
223
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Place many different blocks in one call: position `i` gets
|
|
225
|
+
* `palette[indices[i]]`. `positions` is flat `[x0,y0,z0, ...]`,
|
|
226
|
+
* `indices` has one entry per position, and `palette_json` is a JSON
|
|
227
|
+
* array of block strings (properties and NBT allowed, `simulate` not).
|
|
228
|
+
* Returns the number of blocks set.
|
|
229
|
+
*/
|
|
230
|
+
setBlocksIndexed(positions: Array<number>, indices: Array<number>, paletteJson: string): number;
|
|
231
|
+
|
|
224
232
|
/**
|
|
225
233
|
* Sequentially hand-place the same block at many positions in one
|
|
226
234
|
* local simulated component. `positions` is flat
|
|
@@ -510,17 +518,17 @@ export class Schematic {
|
|
|
510
518
|
|
|
511
519
|
/**
|
|
512
520
|
* Storage metadata and full block states for palette-index streaming. Region order
|
|
513
|
-
* is default first, then sorted names (highest precedence first); indices are LOCAL to each region.
|
|
514
|
-
*
|
|
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.
|
|
515
523
|
* No block buffer is cloned or serialized here.
|
|
516
524
|
*/
|
|
517
525
|
renderRegionsJson(): string;
|
|
518
526
|
|
|
519
527
|
/**
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
*
|
|
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.
|
|
524
532
|
*/
|
|
525
533
|
regionBlockIndices(regionName: string, start: number, count: number): Uint32Array;
|
|
526
534
|
|
|
@@ -900,8 +908,9 @@ export class Schematic {
|
|
|
900
908
|
tightDimensions(): Dimensions;
|
|
901
909
|
|
|
902
910
|
/**
|
|
903
|
-
* The
|
|
904
|
-
* 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`).
|
|
905
914
|
*/
|
|
906
915
|
allocatedDimensions(): Dimensions;
|
|
907
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
|
|
|
@@ -221,6 +220,15 @@ export class Schematic {
|
|
|
221
220
|
*/
|
|
222
221
|
setBlocks(positions: Array<number>, blockName: string): number;
|
|
223
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Place many different blocks in one call: position `i` gets
|
|
225
|
+
* `palette[indices[i]]`. `positions` is flat `[x0,y0,z0, ...]`,
|
|
226
|
+
* `indices` has one entry per position, and `palette_json` is a JSON
|
|
227
|
+
* array of block strings (properties and NBT allowed, `simulate` not).
|
|
228
|
+
* Returns the number of blocks set.
|
|
229
|
+
*/
|
|
230
|
+
setBlocksIndexed(positions: Array<number>, indices: Array<number>, paletteJson: string): number;
|
|
231
|
+
|
|
224
232
|
/**
|
|
225
233
|
* Sequentially hand-place the same block at many positions in one
|
|
226
234
|
* local simulated component. `positions` is flat
|
|
@@ -510,17 +518,17 @@ export class Schematic {
|
|
|
510
518
|
|
|
511
519
|
/**
|
|
512
520
|
* Storage metadata and full block states for palette-index streaming. Region order
|
|
513
|
-
* is default first, then sorted names (highest precedence first); indices are LOCAL to each region.
|
|
514
|
-
*
|
|
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.
|
|
515
523
|
* No block buffer is cloned or serialized here.
|
|
516
524
|
*/
|
|
517
525
|
renderRegionsJson(): string;
|
|
518
526
|
|
|
519
527
|
/**
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
*
|
|
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.
|
|
524
532
|
*/
|
|
525
533
|
regionBlockIndices(regionName: string, start: number, count: number): Uint32Array;
|
|
526
534
|
|
|
@@ -900,8 +908,9 @@ export class Schematic {
|
|
|
900
908
|
tightDimensions(): Dimensions;
|
|
901
909
|
|
|
902
910
|
/**
|
|
903
|
-
* The
|
|
904
|
-
* 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`).
|
|
905
914
|
*/
|
|
906
915
|
allocatedDimensions(): Dimensions;
|
|
907
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);
|
|
@@ -973,6 +972,40 @@ export class Schematic {
|
|
|
973
972
|
}
|
|
974
973
|
}
|
|
975
974
|
|
|
975
|
+
/**
|
|
976
|
+
* Place many different blocks in one call: position `i` gets
|
|
977
|
+
* `palette[indices[i]]`. `positions` is flat `[x0,y0,z0, ...]`,
|
|
978
|
+
* `indices` has one entry per position, and `palette_json` is a JSON
|
|
979
|
+
* array of block strings (properties and NBT allowed, `simulate` not).
|
|
980
|
+
* Returns the number of blocks set.
|
|
981
|
+
*/
|
|
982
|
+
setBlocksIndexed(positions, indices, paletteJson) {
|
|
983
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
984
|
+
|
|
985
|
+
const positionsSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, positions, "i32")));
|
|
986
|
+
const indicesSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.slice(wasm, indices, "u32")));
|
|
987
|
+
const paletteJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, paletteJson)));
|
|
988
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
989
|
+
|
|
990
|
+
|
|
991
|
+
const result = wasm.Schematic_set_blocks_indexed(diplomatReceive.buffer, this.ffiValue, positionsSlice.ptr, indicesSlice.ptr, paletteJsonSlice.ptr);
|
|
992
|
+
|
|
993
|
+
try {
|
|
994
|
+
if (!diplomatReceive.resultFlag) {
|
|
995
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
996
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
997
|
+
}
|
|
998
|
+
return (new Int32Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0];
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
finally {
|
|
1002
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
1003
|
+
functionCleanupArena.free();
|
|
1004
|
+
|
|
1005
|
+
diplomatReceive.free();
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
|
|
976
1009
|
/**
|
|
977
1010
|
* Sequentially hand-place the same block at many positions in one
|
|
978
1011
|
* local simulated component. `positions` is flat
|
|
@@ -1976,8 +2009,8 @@ export class Schematic {
|
|
|
1976
2009
|
|
|
1977
2010
|
/**
|
|
1978
2011
|
* Storage metadata and full block states for palette-index streaming. Region order
|
|
1979
|
-
* is default first, then sorted names (highest precedence first); indices are LOCAL to each region.
|
|
1980
|
-
*
|
|
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.
|
|
1981
2014
|
* No block buffer is cloned or serialized here.
|
|
1982
2015
|
*/
|
|
1983
2016
|
renderRegionsJson() {
|
|
@@ -1996,29 +2029,29 @@ export class Schematic {
|
|
|
1996
2029
|
}
|
|
1997
2030
|
|
|
1998
2031
|
/**
|
|
1999
|
-
*
|
|
2000
|
-
*
|
|
2001
|
-
*
|
|
2002
|
-
*
|
|
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.
|
|
2003
2036
|
*/
|
|
2004
2037
|
regionBlockIndices(regionName, start, count) {
|
|
2005
2038
|
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
2006
2039
|
|
|
2007
2040
|
const regionNameSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, regionName)));
|
|
2008
|
-
const
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
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);
|
|
2012
2044
|
|
|
2013
2045
|
|
|
2014
|
-
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);
|
|
2015
2047
|
|
|
2016
2048
|
try {
|
|
2017
2049
|
if (!diplomatReceive.resultFlag) {
|
|
2018
2050
|
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
2019
2051
|
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
2020
2052
|
}
|
|
2021
|
-
|
|
2053
|
+
const written = (new Uint32Array(wasm.memory.buffer, diplomatReceive.buffer, 1))[0];
|
|
2054
|
+
return new Uint32Array(wasm.memory.buffer, outBuf.ptr, written).slice();
|
|
2022
2055
|
}
|
|
2023
2056
|
|
|
2024
2057
|
finally {
|
|
@@ -3518,8 +3551,9 @@ export class Schematic {
|
|
|
3518
3551
|
}
|
|
3519
3552
|
|
|
3520
3553
|
/**
|
|
3521
|
-
* The
|
|
3522
|
-
* 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`).
|
|
3523
3557
|
*/
|
|
3524
3558
|
allocatedDimensions() {
|
|
3525
3559
|
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 12, 4, false);
|
package/renderer/nucleation.wasm
CHANGED
|
Binary file
|