nucleation 0.3.5 → 0.3.7

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/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
package/RenderConfig.d.ts CHANGED
@@ -31,11 +31,21 @@ export class RenderConfig {
31
31
  setPitch(pitch: number): void;
32
32
 
33
33
  /**
34
- * Set the zoom factor scaling the auto-fitted camera distance
35
- * (1.0 = frame the whole model; larger = further away). Default: 1.0.
34
+ * Set the zoom factor applied to the auto-fitted framing
35
+ * (1.0 = frame the whole model; 2.0 = twice as close; 0.5 = twice
36
+ * as far). Default: 1.0.
36
37
  */
37
38
  setZoom(zoom: number): void;
38
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
+
39
49
  /**
40
50
  * Set the vertical field of view in degrees (perspective projection
41
51
  * only). Default: 45.
package/RenderConfig.mjs CHANGED
@@ -83,8 +83,9 @@ export class RenderConfig {
83
83
  }
84
84
 
85
85
  /**
86
- * Set the zoom factor scaling the auto-fitted camera distance
87
- * (1.0 = frame the whole model; larger = further away). Default: 1.0.
86
+ * Set the zoom factor applied to the auto-fitted framing
87
+ * (1.0 = frame the whole model; 2.0 = twice as close; 0.5 = twice
88
+ * as far). Default: 1.0.
88
89
  */
89
90
  setZoom(zoom) {
90
91
  wasm.RenderConfig_set_zoom(this.ffiValue, zoom);
@@ -96,6 +97,23 @@ export class RenderConfig {
96
97
  }
97
98
  }
98
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
+
99
117
  /**
100
118
  * Set the vertical field of view in degrees (perspective projection
101
119
  * only). Default: 45.
package/Schematic.d.ts CHANGED
@@ -37,19 +37,6 @@ export class Schematic {
37
37
  */
38
38
  getBlockName(x: number, y: number, z: number): string;
39
39
 
40
- /**
41
- * Save the schematic to a file, always in Litematic format (the
42
- * extension is not consulted; use `save_to_file_with_format` for
43
- * other formats).
44
- */
45
- saveToFile(path: string): void;
46
-
47
- /**
48
- * Load a schematic from a Litematic file (this path is
49
- * Litematic-only; use `from_data` for format auto-detection).
50
- */
51
- static loadFromFile(path: string): Schematic;
52
-
53
40
  /**
54
41
  * Build a schematic from raw byte data, auto-detecting the format.
55
42
  * Supports Litematic, Sponge Schematic, and McStructure (Bedrock) formats.
@@ -555,12 +542,6 @@ export class Schematic {
555
542
  */
556
543
  saveAsB64(format: string, version: string, settings: string): string;
557
544
 
558
- /**
559
- * Save to a file. If `format` is empty, the format is auto-detected from
560
- * the file extension; `version` may be empty for the default.
561
- */
562
- saveToFileWithFormat(path: string, format: string, version: string): void;
563
-
564
545
  /**
565
546
  * Serialize as a Sponge schematic targeting a specific format version,
566
547
  * base64-encoded.
package/Schematic.mjs CHANGED
@@ -136,64 +136,6 @@ export class Schematic {
136
136
  }
137
137
  }
138
138
 
139
- /**
140
- * Save the schematic to a file, always in Litematic format (the
141
- * extension is not consulted; use `save_to_file_with_format` for
142
- * other formats).
143
- */
144
- saveToFile(path) {
145
- let functionCleanupArena = new diplomatRuntime.CleanupArena();
146
-
147
- const pathSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, path)));
148
- const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
149
-
150
-
151
- const result = wasm.Schematic_save_to_file(diplomatReceive.buffer, this.ffiValue, pathSlice.ptr);
152
-
153
- try {
154
- if (!diplomatReceive.resultFlag) {
155
- const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
156
- throw new globalThis.Error('NucleationError.' + cause.value, { cause });
157
- }
158
- }
159
-
160
- finally {
161
- diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
162
- functionCleanupArena.free();
163
-
164
- diplomatReceive.free();
165
- }
166
- }
167
-
168
- /**
169
- * Load a schematic from a Litematic file (this path is
170
- * Litematic-only; use `from_data` for format auto-detection).
171
- */
172
- static loadFromFile(path) {
173
- let functionCleanupArena = new diplomatRuntime.CleanupArena();
174
-
175
- const pathSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, path)));
176
- const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
177
-
178
-
179
- const result = wasm.Schematic_load_from_file(diplomatReceive.buffer, pathSlice.ptr);
180
-
181
- try {
182
- if (!diplomatReceive.resultFlag) {
183
- const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
184
- throw new globalThis.Error('NucleationError.' + cause.value, { cause });
185
- }
186
- return new Schematic(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
187
- }
188
-
189
- finally {
190
- diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
191
- functionCleanupArena.free();
192
-
193
- diplomatReceive.free();
194
- }
195
- }
196
-
197
139
  /**
198
140
  * Build a schematic from raw byte data, auto-detecting the format.
199
141
  * Supports Litematic, Sponge Schematic, and McStructure (Bedrock) formats.
@@ -2224,36 +2166,6 @@ export class Schematic {
2224
2166
  }
2225
2167
  }
2226
2168
 
2227
- /**
2228
- * Save to a file. If `format` is empty, the format is auto-detected from
2229
- * the file extension; `version` may be empty for the default.
2230
- */
2231
- saveToFileWithFormat(path, format, version) {
2232
- let functionCleanupArena = new diplomatRuntime.CleanupArena();
2233
-
2234
- const pathSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, path)));
2235
- const formatSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, format)));
2236
- const versionSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, version)));
2237
- const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
2238
-
2239
-
2240
- const result = wasm.Schematic_save_to_file_with_format(diplomatReceive.buffer, this.ffiValue, pathSlice.ptr, formatSlice.ptr, versionSlice.ptr);
2241
-
2242
- try {
2243
- if (!diplomatReceive.resultFlag) {
2244
- const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
2245
- throw new globalThis.Error('NucleationError.' + cause.value, { cause });
2246
- }
2247
- }
2248
-
2249
- finally {
2250
- diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
2251
- functionCleanupArena.free();
2252
-
2253
- diplomatReceive.free();
2254
- }
2255
- }
2256
-
2257
2169
  /**
2258
2170
  * Serialize as a Sponge schematic targeting a specific format version,
2259
2171
  * base64-encoded.
package/Sdf.d.ts CHANGED
@@ -18,6 +18,14 @@ export class Sdf {
18
18
 
19
19
  /**
20
20
  * Builds a schematic by sampling an SDF JSON tree with material rules JSON.
21
+ * Sample an SDF tree into a schematic using the tree's own AABB —
22
+ * the ergonomic path for bounded trees (all primitives except
23
+ * `plane`). Fails with `InvalidArgument` for unbounded trees; use
24
+ * `schematic_from_sdf` with explicit bounds for those.
25
+ */
26
+ static schematicFromSdfAuto(sdfJson: string, rulesJson: string): Schematic;
27
+
28
+ /**
21
29
  * When `has_bounds` is false the tree's own AABB is used (fails with
22
30
  * `InvalidArgument` for unbounded trees) and the `min_*`/`max_*` arguments
23
31
  * are ignored.
package/Sdf.mjs CHANGED
@@ -43,6 +43,38 @@ export class Sdf {
43
43
 
44
44
  /**
45
45
  * Builds a schematic by sampling an SDF JSON tree with material rules JSON.
46
+ * Sample an SDF tree into a schematic using the tree's own AABB —
47
+ * the ergonomic path for bounded trees (all primitives except
48
+ * `plane`). Fails with `InvalidArgument` for unbounded trees; use
49
+ * `schematic_from_sdf` with explicit bounds for those.
50
+ */
51
+ static schematicFromSdfAuto(sdfJson, rulesJson) {
52
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
53
+
54
+ const sdfJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, sdfJson)));
55
+ const rulesJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, rulesJson)));
56
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
57
+
58
+
59
+ const result = wasm.Sdf_schematic_from_sdf_auto(diplomatReceive.buffer, sdfJsonSlice.ptr, rulesJsonSlice.ptr);
60
+
61
+ try {
62
+ if (!diplomatReceive.resultFlag) {
63
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
64
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
65
+ }
66
+ return new Schematic(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
67
+ }
68
+
69
+ finally {
70
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
71
+ functionCleanupArena.free();
72
+
73
+ diplomatReceive.free();
74
+ }
75
+ }
76
+
77
+ /**
46
78
  * When `has_bounds` is false the tree's own AABB is used (fails with
47
79
  * `InvalidArgument` for unbounded trees) and the `min_*`/`max_*` arguments
48
80
  * are ignored.
package/nucleation.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nucleation",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "A high-performance Minecraft schematic parser and utility library",
5
5
  "type": "module",
6
6
  "main": "index.mjs",