nucleation 0.3.7 → 0.3.8
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/Blocks.d.ts +8 -0
- package/Blocks.mjs +29 -0
- package/PaletteBuilder.d.ts +18 -0
- package/PaletteBuilder.mjs +69 -0
- package/Shape.d.ts +17 -0
- package/Shape.mjs +63 -0
- package/nucleation.wasm +0 -0
- package/package.json +1 -1
package/Blocks.d.ts
CHANGED
|
@@ -38,6 +38,14 @@ export class Blocks {
|
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Ids of every block carrying the vanilla block tag, as a sorted
|
|
41
|
+
* Blocks whose measured texture color is within `max_distance`
|
|
42
|
+
* (Oklab; ~0.05 = same color family, ~0.15 = generous) of the given
|
|
43
|
+
* RGB, as a JSON array of `{"id", "color": [r,g,b], "distance"}`
|
|
44
|
+
* sorted nearest-first. Blocks without color data never match.
|
|
45
|
+
*/
|
|
46
|
+
static byColorJson(r: number, g: number, b: number, maxDistance: number): string;
|
|
47
|
+
|
|
48
|
+
/**
|
|
41
49
|
* JSON array string (`[]` for unknown tags). Accepts
|
|
42
50
|
* `minecraft:wool` and short `wool` forms, including nested paths
|
|
43
51
|
* like `mineable/pickaxe`.
|
package/Blocks.mjs
CHANGED
|
@@ -102,6 +102,35 @@ export class Blocks {
|
|
|
102
102
|
|
|
103
103
|
/**
|
|
104
104
|
* Ids of every block carrying the vanilla block tag, as a sorted
|
|
105
|
+
* Blocks whose measured texture color is within `max_distance`
|
|
106
|
+
* (Oklab; ~0.05 = same color family, ~0.15 = generous) of the given
|
|
107
|
+
* RGB, as a JSON array of `{"id", "color": [r,g,b], "distance"}`
|
|
108
|
+
* sorted nearest-first. Blocks without color data never match.
|
|
109
|
+
*/
|
|
110
|
+
static byColorJson(r, g, b, maxDistance) {
|
|
111
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
112
|
+
|
|
113
|
+
const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
const result = wasm.Blocks_by_color_json(diplomatReceive.buffer, r, g, b, maxDistance, write.buffer);
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
if (!diplomatReceive.resultFlag) {
|
|
120
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
121
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
122
|
+
}
|
|
123
|
+
return write.readString8();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
finally {
|
|
127
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
128
|
+
diplomatReceive.free();
|
|
129
|
+
write.free();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
105
134
|
* JSON array string (`[]` for unknown tags). Accepts
|
|
106
135
|
* `minecraft:wool` and short `wool` forms, including nested paths
|
|
107
136
|
* like `mineable/pickaxe`.
|
package/PaletteBuilder.d.ts
CHANGED
|
@@ -94,6 +94,24 @@ export class PaletteBuilder {
|
|
|
94
94
|
*/
|
|
95
95
|
kind(k: string): void;
|
|
96
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Keep only blocks whose measured Oklab lightness L is within
|
|
99
|
+
* `[min, max]` (0.0 = black, 1.0 = white).
|
|
100
|
+
*/
|
|
101
|
+
lightnessBetween(min: number, max: number): void;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Keep only near-neutral blocks: measured Oklab chroma at most
|
|
105
|
+
* `max` (the grayscale preset uses 0.022).
|
|
106
|
+
*/
|
|
107
|
+
chromaBelow(max: number): void;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Keep only blocks whose measured color is within `max_distance`
|
|
111
|
+
* (Oklab; ~0.05 = same family, ~0.15 = generous) of the RGB color.
|
|
112
|
+
*/
|
|
113
|
+
colorNear(r: number, g: number, b: number, maxDistance: number): void;
|
|
114
|
+
|
|
97
115
|
/**
|
|
98
116
|
* Build the palette; consumes the builder.
|
|
99
117
|
*/
|
package/PaletteBuilder.mjs
CHANGED
|
@@ -359,6 +359,75 @@ export class PaletteBuilder {
|
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
+
/**
|
|
363
|
+
* Keep only blocks whose measured Oklab lightness L is within
|
|
364
|
+
* `[min, max]` (0.0 = black, 1.0 = white).
|
|
365
|
+
*/
|
|
366
|
+
lightnessBetween(min, max) {
|
|
367
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
const result = wasm.PaletteBuilder_lightness_between(diplomatReceive.buffer, this.ffiValue, min, max);
|
|
371
|
+
|
|
372
|
+
try {
|
|
373
|
+
if (!diplomatReceive.resultFlag) {
|
|
374
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
375
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
finally {
|
|
380
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
381
|
+
diplomatReceive.free();
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Keep only near-neutral blocks: measured Oklab chroma at most
|
|
387
|
+
* `max` (the grayscale preset uses 0.022).
|
|
388
|
+
*/
|
|
389
|
+
chromaBelow(max) {
|
|
390
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
const result = wasm.PaletteBuilder_chroma_below(diplomatReceive.buffer, this.ffiValue, max);
|
|
394
|
+
|
|
395
|
+
try {
|
|
396
|
+
if (!diplomatReceive.resultFlag) {
|
|
397
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
398
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
finally {
|
|
403
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
404
|
+
diplomatReceive.free();
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Keep only blocks whose measured color is within `max_distance`
|
|
410
|
+
* (Oklab; ~0.05 = same family, ~0.15 = generous) of the RGB color.
|
|
411
|
+
*/
|
|
412
|
+
colorNear(r, g, b, maxDistance) {
|
|
413
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
const result = wasm.PaletteBuilder_color_near(diplomatReceive.buffer, this.ffiValue, r, g, b, maxDistance);
|
|
417
|
+
|
|
418
|
+
try {
|
|
419
|
+
if (!diplomatReceive.resultFlag) {
|
|
420
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
421
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
finally {
|
|
426
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
427
|
+
diplomatReceive.free();
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
362
431
|
/**
|
|
363
432
|
* Build the palette; consumes the builder.
|
|
364
433
|
*/
|
package/Shape.d.ts
CHANGED
|
@@ -85,6 +85,23 @@ export class Shape {
|
|
|
85
85
|
*/
|
|
86
86
|
static bezier(controlPoints: Array<number>, thickness: number, resolution: number): Shape;
|
|
87
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Any SDF tree as a Shape: the same JSON the terrain sampler takes
|
|
90
|
+
* (primitives, smooth booleans, noise — see the SDF guide) becomes
|
|
91
|
+
* fillable with every brush, combinable with other shapes, and
|
|
92
|
+
* usable in masked fills. Normals come from the field gradient, so
|
|
93
|
+
* the shaded brush shades smooth blends smoothly. Errors with
|
|
94
|
+
* `Parse` on invalid JSON and `InvalidArgument` for unbounded trees
|
|
95
|
+
* (use `sdf_bounded`).
|
|
96
|
+
*/
|
|
97
|
+
static sdf(sdfJson: string): Shape;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Like `sdf`, with explicit sampling bounds (inclusive block
|
|
101
|
+
* coordinates) for unbounded trees such as planes.
|
|
102
|
+
*/
|
|
103
|
+
static sdfBounded(sdfJson: string, minX: number, minY: number, minZ: number, maxX: number, maxY: number, maxZ: number): Shape;
|
|
104
|
+
|
|
88
105
|
/**
|
|
89
106
|
* Hollowed-out copy of this shape with the given wall thickness (clones the
|
|
90
107
|
* input, like the old `shape_hollow`).
|
package/Shape.mjs
CHANGED
|
@@ -265,6 +265,69 @@ export class Shape {
|
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
+
/**
|
|
269
|
+
* Any SDF tree as a Shape: the same JSON the terrain sampler takes
|
|
270
|
+
* (primitives, smooth booleans, noise — see the SDF guide) becomes
|
|
271
|
+
* fillable with every brush, combinable with other shapes, and
|
|
272
|
+
* usable in masked fills. Normals come from the field gradient, so
|
|
273
|
+
* the shaded brush shades smooth blends smoothly. Errors with
|
|
274
|
+
* `Parse` on invalid JSON and `InvalidArgument` for unbounded trees
|
|
275
|
+
* (use `sdf_bounded`).
|
|
276
|
+
*/
|
|
277
|
+
static sdf(sdfJson) {
|
|
278
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
279
|
+
|
|
280
|
+
const sdfJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, sdfJson)));
|
|
281
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
const result = wasm.Shape_sdf(diplomatReceive.buffer, sdfJsonSlice.ptr);
|
|
285
|
+
|
|
286
|
+
try {
|
|
287
|
+
if (!diplomatReceive.resultFlag) {
|
|
288
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
289
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
290
|
+
}
|
|
291
|
+
return new Shape(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
finally {
|
|
295
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
296
|
+
functionCleanupArena.free();
|
|
297
|
+
|
|
298
|
+
diplomatReceive.free();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Like `sdf`, with explicit sampling bounds (inclusive block
|
|
304
|
+
* coordinates) for unbounded trees such as planes.
|
|
305
|
+
*/
|
|
306
|
+
static sdfBounded(sdfJson, minX, minY, minZ, maxX, maxY, maxZ) {
|
|
307
|
+
let functionCleanupArena = new diplomatRuntime.CleanupArena();
|
|
308
|
+
|
|
309
|
+
const sdfJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, sdfJson)));
|
|
310
|
+
const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
const result = wasm.Shape_sdf_bounded(diplomatReceive.buffer, sdfJsonSlice.ptr, minX, minY, minZ, maxX, maxY, maxZ);
|
|
314
|
+
|
|
315
|
+
try {
|
|
316
|
+
if (!diplomatReceive.resultFlag) {
|
|
317
|
+
const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
|
|
318
|
+
throw new globalThis.Error('NucleationError.' + cause.value, { cause });
|
|
319
|
+
}
|
|
320
|
+
return new Shape(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
finally {
|
|
324
|
+
diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
|
|
325
|
+
functionCleanupArena.free();
|
|
326
|
+
|
|
327
|
+
diplomatReceive.free();
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
268
331
|
/**
|
|
269
332
|
* Hollowed-out copy of this shape with the given wall thickness (clones the
|
|
270
333
|
* input, like the old `shape_hollow`).
|
package/nucleation.wasm
CHANGED
|
Binary file
|