nucleation 0.3.6 → 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 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/Palette.d.ts CHANGED
@@ -55,7 +55,9 @@ export class Palette {
55
55
  static terracotta(): Palette;
56
56
 
57
57
  /**
58
- * Grayscale-leaning blocks (stones, basalt, deepslate, ...).
58
+ * Genuinely gray blocks: opaque full cubes whose measured color
59
+ * is near-neutral (low Oklab chroma) — judged from color data,
60
+ * not names.
59
61
  */
60
62
  static grayscale(): Palette;
61
63
 
@@ -71,6 +73,17 @@ export class Palette {
71
73
  */
72
74
  sortedByLightness(): Palette;
73
75
 
76
+ /**
77
+ * JSON array of exactly `steps` DISTINCT block ids forming the
78
+ * smoothest ramp this palette can make from (`r1`,`g1`,`b1`) to
79
+ * (`r2`,`g2`,`b2`): targets are evenly spaced along the Oklab line
80
+ * and blocks are chosen by a minimum-cost monotonic matching, so
81
+ * off-hue blocks are penalized and no block repeats. Errors with
82
+ * `InvalidArgument` when the palette has fewer than `steps` blocks,
83
+ * `steps` is 0, or start equals end.
84
+ */
85
+ rampIdsJson(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number, steps: number): string;
86
+
74
87
  /**
75
88
  * JSON array of exactly `steps` block ids sampling the color
76
89
  * gradient from (`r1`,`g1`,`b1`) to (`r2`,`g2`,`b2`) in Oklab
package/Palette.mjs CHANGED
@@ -157,7 +157,9 @@ export class Palette {
157
157
  }
158
158
 
159
159
  /**
160
- * Grayscale-leaning blocks (stones, basalt, deepslate, ...).
160
+ * Genuinely gray blocks: opaque full cubes whose measured color
161
+ * is near-neutral (low Oklab chroma) — judged from color data,
162
+ * not names.
161
163
  */
162
164
  static grayscale() {
163
165
 
@@ -206,6 +208,38 @@ export class Palette {
206
208
  }
207
209
  }
208
210
 
211
+ /**
212
+ * JSON array of exactly `steps` DISTINCT block ids forming the
213
+ * smoothest ramp this palette can make from (`r1`,`g1`,`b1`) to
214
+ * (`r2`,`g2`,`b2`): targets are evenly spaced along the Oklab line
215
+ * and blocks are chosen by a minimum-cost monotonic matching, so
216
+ * off-hue blocks are penalized and no block repeats. Errors with
217
+ * `InvalidArgument` when the palette has fewer than `steps` blocks,
218
+ * `steps` is 0, or start equals end.
219
+ */
220
+ rampIdsJson(r1, g1, b1, r2, g2, b2, steps) {
221
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
222
+
223
+ const write = new diplomatRuntime.DiplomatWriteBuf(wasm);
224
+
225
+
226
+ const result = wasm.Palette_ramp_ids_json(diplomatReceive.buffer, this.ffiValue, r1, g1, b1, r2, g2, b2, steps, write.buffer);
227
+
228
+ try {
229
+ if (!diplomatReceive.resultFlag) {
230
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
231
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
232
+ }
233
+ return write.readString8();
234
+ }
235
+
236
+ finally {
237
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
238
+ diplomatReceive.free();
239
+ write.free();
240
+ }
241
+ }
242
+
209
243
  /**
210
244
  * JSON array of exactly `steps` block ids sampling the color
211
245
  * gradient from (`r1`,`g1`,`b1`) to (`r2`,`g2`,`b2`) in Oklab
@@ -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
  */
@@ -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/RenderConfig.d.ts CHANGED
@@ -37,6 +37,15 @@ export class RenderConfig {
37
37
  */
38
38
  setZoom(zoom: number): void;
39
39
 
40
+ /**
41
+ * Fit the camera to the model's bounding sphere instead of its
42
+ * yaw-dependent silhouette. The sphere is rotation invariant, so
43
+ * orbiting cameras (turntables) keep a constant distance instead
44
+ * of pulsing as the silhouette changes. Frames slightly looser
45
+ * than the default fit. Default: false.
46
+ */
47
+ setSphereFit(sphereFit: boolean): void;
48
+
40
49
  /**
41
50
  * Set the vertical field of view in degrees (perspective projection
42
51
  * only). Default: 45.
package/RenderConfig.mjs CHANGED
@@ -97,6 +97,23 @@ export class RenderConfig {
97
97
  }
98
98
  }
99
99
 
100
+ /**
101
+ * Fit the camera to the model's bounding sphere instead of its
102
+ * yaw-dependent silhouette. The sphere is rotation invariant, so
103
+ * orbiting cameras (turntables) keep a constant distance instead
104
+ * of pulsing as the silhouette changes. Frames slightly looser
105
+ * than the default fit. Default: false.
106
+ */
107
+ setSphereFit(sphereFit) {
108
+ wasm.RenderConfig_set_sphere_fit(this.ffiValue, sphereFit);
109
+
110
+ try {}
111
+
112
+ finally {
113
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
114
+ }
115
+ }
116
+
100
117
  /**
101
118
  * Set the vertical field of view in degrees (perspective projection
102
119
  * only). Default: 45.
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nucleation",
3
- "version": "0.3.6",
3
+ "version": "0.3.8",
4
4
  "description": "A high-performance Minecraft schematic parser and utility library",
5
5
  "type": "module",
6
6
  "main": "index.mjs",