nucleation 0.6.0 → 0.8.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.
Files changed (190) hide show
  1. package/AnimationEffect.d.mts +44 -0
  2. package/AnimationEffect.d.ts +1 -1
  3. package/Autostack.d.mts +43 -0
  4. package/Autostack.d.ts +2 -2
  5. package/BlockPos.d.mts +28 -0
  6. package/BlockState.d.mts +39 -0
  7. package/BlockState.d.ts +1 -1
  8. package/Blocks.d.mts +91 -0
  9. package/Blocks.d.ts +1 -1
  10. package/Brush.d.mts +99 -0
  11. package/Brush.d.ts +21 -12
  12. package/Brush.mjs +66 -9
  13. package/BuildAnimation.d.mts +142 -0
  14. package/BuildAnimation.d.ts +5 -5
  15. package/BuildingTool.d.mts +46 -0
  16. package/BuildingTool.d.ts +4 -4
  17. package/CellularSdfConfig.d.mts +22 -0
  18. package/CellularSdfConfig.d.ts +22 -0
  19. package/CellularSdfConfig.mjs +69 -0
  20. package/ChunkMeshResult.d.mts +75 -0
  21. package/ChunkMeshResult.d.ts +7 -7
  22. package/CircuitBuilder.d.mts +118 -0
  23. package/CircuitBuilder.d.ts +6 -6
  24. package/Curve3D.d.mts +27 -0
  25. package/Curve3D.d.ts +1 -1
  26. package/DefinitionRegion.d.mts +274 -0
  27. package/DefinitionRegion.d.ts +5 -5
  28. package/Diff.d.mts +88 -0
  29. package/Diff.d.ts +2 -2
  30. package/Dimensions.d.mts +28 -0
  31. package/DistanceField.d.mts +39 -0
  32. package/DistanceField.d.ts +1 -1
  33. package/ExecutionMode.d.mts +42 -0
  34. package/ExecutionMode.d.ts +2 -2
  35. package/Field3.d.mts +40 -0
  36. package/Field3.d.ts +40 -0
  37. package/Field3.mjs +160 -0
  38. package/FieldProgram.d.mts +40 -0
  39. package/FieldProgram.d.ts +40 -0
  40. package/FieldProgram.mjs +167 -0
  41. package/FieldProgramBinaryOp.d.mts +42 -0
  42. package/FieldProgramBinaryOp.d.ts +42 -0
  43. package/FieldProgramBinaryOp.mjs +118 -0
  44. package/FieldProgramBuilder.d.mts +104 -0
  45. package/FieldProgramBuilder.d.ts +104 -0
  46. package/FieldProgramBuilder.mjs +486 -0
  47. package/FieldProgramDistanceKind.d.mts +26 -0
  48. package/FieldProgramDistanceKind.d.ts +26 -0
  49. package/FieldProgramDistanceKind.mjs +78 -0
  50. package/FieldProgramUnaryOp.d.mts +34 -0
  51. package/FieldProgramUnaryOp.d.ts +34 -0
  52. package/FieldProgramUnaryOp.mjs +102 -0
  53. package/FieldProgramValueType.d.mts +25 -0
  54. package/FieldProgramValueType.d.ts +25 -0
  55. package/FieldProgramValueType.mjs +75 -0
  56. package/FieldRange.d.mts +15 -0
  57. package/FieldRange.d.ts +15 -0
  58. package/FieldRange.mjs +108 -0
  59. package/Fingerprint.d.mts +44 -0
  60. package/Fingerprint.d.ts +2 -2
  61. package/GeneratedChunk.d.mts +35 -0
  62. package/GeneratedChunk.d.ts +35 -0
  63. package/GeneratedChunk.mjs +178 -0
  64. package/GeneratedChunkCoverage.d.mts +25 -0
  65. package/GeneratedChunkCoverage.d.ts +25 -0
  66. package/GeneratedChunkCoverage.mjs +75 -0
  67. package/GeneratedChunkOverlayMode.d.mts +24 -0
  68. package/GeneratedChunkOverlayMode.d.ts +24 -0
  69. package/GeneratedChunkOverlayMode.mjs +72 -0
  70. package/GeneratedWorldStream.d.mts +28 -0
  71. package/GeneratedWorldStream.d.ts +28 -0
  72. package/GeneratedWorldStream.mjs +86 -0
  73. package/Geo.d.mts +41 -0
  74. package/Geo.d.ts +2 -2
  75. package/InterpolationSpace.d.mts +25 -0
  76. package/IoLayout.d.mts +26 -0
  77. package/IoLayoutBuilder.d.mts +73 -0
  78. package/IoLayoutBuilder.d.ts +4 -4
  79. package/IoType.d.mts +41 -0
  80. package/ItemModelConfig.d.mts +65 -0
  81. package/ItemModelConfig.d.ts +1 -1
  82. package/ItemModelPackBuilder.d.mts +32 -0
  83. package/ItemModelPackBuilder.d.ts +1 -1
  84. package/ItemModelResult.d.mts +72 -0
  85. package/ItemModelResult.d.ts +7 -7
  86. package/ItemScale.d.mts +31 -0
  87. package/LayoutFunction.d.mts +52 -0
  88. package/LayoutFunction.d.ts +1 -1
  89. package/MchprsWorld.d.mts +131 -0
  90. package/MchprsWorld.d.ts +3 -3
  91. package/MeshBounds.d.mts +40 -0
  92. package/MeshConfig.d.mts +101 -0
  93. package/MeshConfig.d.ts +1 -1
  94. package/MeshJob.d.mts +44 -0
  95. package/MeshJob.d.ts +7 -7
  96. package/MeshPhase.d.mts +38 -0
  97. package/MeshProgress.d.mts +32 -0
  98. package/MeshProgress.d.ts +1 -1
  99. package/MeshResult.d.mts +65 -0
  100. package/MeshResult.d.ts +5 -5
  101. package/MultiMeshResult.d.mts +50 -0
  102. package/MultiMeshResult.d.ts +5 -5
  103. package/Nbt.d.mts +50 -0
  104. package/Nbt.d.ts +1 -1
  105. package/NucleationError.d.mts +41 -0
  106. package/NucleationError.d.ts +5 -0
  107. package/NucleationError.mjs +8 -1
  108. package/OutputCondition.d.mts +45 -0
  109. package/OutputCondition.d.ts +1 -1
  110. package/Palette.d.mts +145 -0
  111. package/Palette.d.ts +9 -1
  112. package/Palette.mjs +35 -0
  113. package/PaletteBuilder.d.mts +119 -0
  114. package/PaletteBuilder.d.ts +2 -2
  115. package/RawMeshExport.d.mts +74 -0
  116. package/RawMeshExport.d.ts +4 -4
  117. package/RedstoneGraph.d.mts +58 -0
  118. package/RedstoneGraph.d.ts +1 -1
  119. package/RegionBounds.d.mts +41 -0
  120. package/RenderConfig.d.mts +101 -0
  121. package/RenderConfig.d.ts +1 -1
  122. package/Renderer.d.mts +51 -0
  123. package/Renderer.d.ts +4 -4
  124. package/ResourcePack.d.mts +105 -0
  125. package/ResourcePack.d.ts +3 -3
  126. package/ResourcePackList.d.mts +32 -0
  127. package/Schematic.d.mts +734 -0
  128. package/Schematic.d.ts +4 -4
  129. package/SchematicBuilder.d.mts +103 -0
  130. package/SchematicBuilder.d.ts +2 -2
  131. package/SchematicRegions.d.mts +93 -0
  132. package/SchematicRegions.d.ts +3 -3
  133. package/Scripting.d.mts +40 -0
  134. package/Scripting.d.ts +2 -2
  135. package/Sdf.d.mts +234 -0
  136. package/Sdf.d.ts +208 -13
  137. package/Sdf.mjs +1106 -11
  138. package/SdfAxis.d.mts +25 -0
  139. package/SdfAxis.d.ts +25 -0
  140. package/SdfAxis.mjs +75 -0
  141. package/SdfBounds.d.mts +19 -0
  142. package/SdfBounds.d.ts +19 -0
  143. package/SdfBounds.mjs +160 -0
  144. package/SdfCellMode.d.mts +26 -0
  145. package/SdfCellMode.d.ts +26 -0
  146. package/SdfCellMode.mjs +78 -0
  147. package/SdfNormal.d.mts +16 -0
  148. package/SdfNormal.d.ts +16 -0
  149. package/SdfNormal.mjs +121 -0
  150. package/Shape.d.mts +143 -0
  151. package/Shape.d.ts +2 -2
  152. package/SortStrategy.d.mts +86 -0
  153. package/SortStrategy.d.ts +1 -1
  154. package/Store.d.mts +83 -0
  155. package/Store.d.ts +2 -2
  156. package/StoreIo.d.mts +71 -0
  157. package/StoreIo.d.ts +2 -2
  158. package/TextureAtlas.d.mts +40 -0
  159. package/TextureAtlas.d.ts +4 -4
  160. package/TextureInfo.d.mts +34 -0
  161. package/TypedCircuitExecutor.d.mts +101 -0
  162. package/TypedCircuitExecutor.d.ts +6 -6
  163. package/Value.d.mts +73 -0
  164. package/Value.d.ts +1 -1
  165. package/VideoConfig.d.mts +15 -0
  166. package/Voxelizer.d.mts +58 -0
  167. package/Voxelizer.d.ts +4 -4
  168. package/WorldChunkView.d.mts +75 -0
  169. package/WorldChunkView.d.ts +2 -2
  170. package/WorldGenerator.d.mts +75 -0
  171. package/WorldGenerator.d.ts +75 -0
  172. package/WorldGenerator.mjs +255 -0
  173. package/WorldSink.d.mts +50 -0
  174. package/WorldSink.d.ts +2 -2
  175. package/WorldStream.d.mts +45 -0
  176. package/WorldStream.d.ts +2 -2
  177. package/WsPartitionHints.d.mts +29 -0
  178. package/WsPartitionHints.d.ts +1 -1
  179. package/WsProfile.d.mts +46 -0
  180. package/WsProfile.d.ts +1 -1
  181. package/WsRunResult.d.mts +83 -0
  182. package/WsRunResult.d.ts +5 -5
  183. package/WsSegmentJob.d.mts +28 -0
  184. package/WsSegmentJob.d.ts +1 -1
  185. package/diplomat-runtime.d.mts +15 -0
  186. package/index.d.mts +177 -0
  187. package/index.d.ts +106 -70
  188. package/index.mjs +37 -1
  189. package/nucleation.wasm +0 -0
  190. package/package.json +2 -1
package/Value.d.mts ADDED
@@ -0,0 +1,73 @@
1
+ // generated by diplomat-tool
2
+ import type { NucleationError } from "./NucleationError.mjs"
3
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
4
+
5
+
6
+
7
+ /**
8
+ * A typed circuit value (payload-carrying enum; PORTING rule 10).
9
+ */
10
+ export class Value {
11
+ /** @internal */
12
+ get ffiValue(): pointer;
13
+ /** @internal */
14
+ constructor();
15
+
16
+
17
+ /**
18
+ * Create an unsigned 32-bit integer value.
19
+ */
20
+ static fromU32(v: number): Value;
21
+
22
+ /**
23
+ * Create a signed 32-bit integer value.
24
+ */
25
+ static fromI32(v: number): Value;
26
+
27
+ /**
28
+ * Create a 32-bit IEEE 754 float value.
29
+ */
30
+ static fromF32(v: number): Value;
31
+
32
+ /**
33
+ * Create a boolean value.
34
+ */
35
+ static fromBool(v: boolean): Value;
36
+
37
+ /**
38
+ * Create a string value. Fails if the bytes are not valid UTF-8.
39
+ */
40
+ static fromString(s: string): Value;
41
+
42
+ /**
43
+ * The value as u32. Also accepts u64/non-negative signed ints that
44
+ * fit, and bool (false → 0, true → 1); fails otherwise.
45
+ */
46
+ asU32(): number;
47
+
48
+ /**
49
+ * The value as i32. Also accepts i64 values in i32 range; fails for
50
+ * other types.
51
+ */
52
+ asI32(): number;
53
+
54
+ /**
55
+ * The value as f32; fails if this is not an f32 value.
56
+ */
57
+ asF32(): number;
58
+
59
+ /**
60
+ * The value as bool; fails if this is not a bool value.
61
+ */
62
+ asBool(): boolean;
63
+
64
+ /**
65
+ * The string payload; fails if this is not a string value.
66
+ */
67
+ asString(): string;
68
+
69
+ /**
70
+ * The type name (e.g. "u32", "bool", "string").
71
+ */
72
+ typeName(): string;
73
+ }
package/Value.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // generated by diplomat-tool
2
- import type { NucleationError } from "./NucleationError"
2
+ import type { NucleationError } from "./NucleationError.mjs"
3
3
  import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
4
4
 
5
5
 
@@ -0,0 +1,15 @@
1
+ // generated by diplomat-tool
2
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
3
+
4
+
5
+
6
+ /**
7
+ * Native FFmpeg video output preset.
8
+ */
9
+ export class VideoConfig {
10
+ /** @internal */
11
+ get ffiValue(): pointer;
12
+ /** @internal */
13
+ constructor();
14
+
15
+ }
@@ -0,0 +1,58 @@
1
+ // generated by diplomat-tool
2
+ import type { NucleationError } from "./NucleationError.mjs"
3
+ import type { Palette } from "./Palette.mjs"
4
+ import type { Schematic } from "./Schematic.mjs"
5
+ import type { Shape } from "./Shape.mjs"
6
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
7
+
8
+
9
+
10
+ /**
11
+ * Namespace for the mesh-voxelization entry points (GLB/OBJ → shapes
12
+ * and textured schematics).
13
+ */
14
+ export class Voxelizer {
15
+ /** @internal */
16
+ get ffiValue(): pointer;
17
+ /** @internal */
18
+ constructor();
19
+
20
+
21
+ /**
22
+ * Load a binary glTF (`.glb`, embedded buffers/images) and voxelize
23
+ * it into a fillable Shape: the model is uniformly scaled so its
24
+ * largest dimension equals `target_size` voxels, centered on x/z
25
+ * with its base resting at y = 0. Solidity is a parity test at each
26
+ * voxel center (robust on closed meshes), plus — when `shell` > 0 —
27
+ * every voxel whose center is within `shell` blocks of the surface,
28
+ * which rescues thin walls and hollow vessels (0.7–1.0 closes
29
+ * single-voxel shells; 0 = pure parity; a *negative* `shell` is
30
+ * surface-only — a skin |shell| blocks thick with no interior fill,
31
+ * for open sheets/ribbons that dip or self-overlap). Errors with `Parse` on
32
+ * malformed/triangle-less GLB and `InvalidArgument` on a
33
+ * non-positive `target_size`.
34
+ */
35
+ static shapeFromGlb(data: Array<number>, targetSize: number, shell: number): Shape;
36
+
37
+ /**
38
+ * Load a Wavefront OBJ (`v`/`vt`/`f` lines; polygon faces are
39
+ * fan-triangulated, negative indices supported, materials ignored)
40
+ * and voxelize it into a fillable Shape, fitted and shelled exactly
41
+ * like `shape_from_glb`. Errors with `Parse` on malformed/triangle-less
42
+ * OBJ and `InvalidArgument` on invalid UTF-8 or a non-positive
43
+ * `target_size`.
44
+ */
45
+ static shapeFromObj(text: string, targetSize: number, shell: number): Shape;
46
+
47
+ /**
48
+ * Load a binary glTF and voxelize it directly into a textured
49
+ * schematic named `name`: every solid voxel becomes the `palette`
50
+ * block closest to its nearest-surface texture color (interior
51
+ * voxels inherit the nearest surface color; voxels without texture
52
+ * info snap to mid-gray). `shell` behaves as in `shape_from_glb` —
53
+ * use ~0.7 for thin-walled models. Errors with `Parse` on malformed GLB and
54
+ * `InvalidArgument` on invalid UTF-8 or a non-positive
55
+ * `target_size`.
56
+ */
57
+ static schematicFromGlbTextured(data: Array<number>, targetSize: number, shell: number, palette: Palette, name: string): Schematic;
58
+ }
package/Voxelizer.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  // generated by diplomat-tool
2
- import type { NucleationError } from "./NucleationError"
3
- import type { Palette } from "./Palette"
4
- import type { Schematic } from "./Schematic"
5
- import type { Shape } from "./Shape"
2
+ import type { NucleationError } from "./NucleationError.mjs"
3
+ import type { Palette } from "./Palette.mjs"
4
+ import type { Schematic } from "./Schematic.mjs"
5
+ import type { Shape } from "./Shape.mjs"
6
6
  import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
7
7
 
8
8
 
@@ -0,0 +1,75 @@
1
+ // generated by diplomat-tool
2
+ import type { NucleationError } from "./NucleationError.mjs"
3
+ import type { Schematic } from "./Schematic.mjs"
4
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
5
+
6
+
7
+
8
+ /**
9
+ * A single decoded chunk (or a from-scratch chunk under construction).
10
+ */
11
+ export class WorldChunkView {
12
+ /** @internal */
13
+ get ffiValue(): pointer;
14
+ /** @internal */
15
+ constructor();
16
+
17
+
18
+ /**
19
+ * Create an empty chunk view at the given chunk coordinates — the
20
+ * starting point for generating worlds from scratch. Sections are
21
+ * created on demand by `set_block`. Serialized with
22
+ * `status = "minecraft:full"` (Minecraft will not regenerate over it)
23
+ * and the default data version.
24
+ */
25
+ static create(cx: number, cz: number): WorldChunkView;
26
+
27
+ /**
28
+ * The chunk X coordinate (in chunk units).
29
+ */
30
+ cx(): number;
31
+
32
+ /**
33
+ * The chunk Z coordinate (in chunk units).
34
+ */
35
+ cz(): number;
36
+
37
+ /**
38
+ * Convert the chunk view to a standalone schematic.
39
+ */
40
+ toSchematic(): Schematic;
41
+
42
+ /**
43
+ * Build a chunk view at (`cx`, `cz`) from a schematic — every non-air
44
+ * block whose world (x, z) falls in this chunk is copied in, the rest
45
+ * ignored. The write-side twin of `to_schematic`: this is how the
46
+ * schematic building tools become a *world generator*. Fill a schematic
47
+ * with any shape, SDF, brush, or footprint (intersect it with the
48
+ * chunk's cuboid to keep memory flat), then hand it here per chunk and
49
+ * `WorldSink.write_chunk` it. Also the transform step of a world filter:
50
+ * `to_schematic` a streamed chunk, edit it, rebuild with this.
51
+ */
52
+ static fromSchematic(schematic: Schematic, cx: number, cz: number): WorldChunkView;
53
+
54
+ /**
55
+ * Set a block at absolute world coordinates inside this chunk view.
56
+ * `block_name` must be a valid Minecraft block identifier (e.g.
57
+ * `minecraft:stone`). Errors with `InvalidArgument` if (x, z) is outside
58
+ * this chunk's column.
59
+ */
60
+ setBlock(x: number, y: number, z: number, blockName: string): void;
61
+
62
+ /**
63
+ * Overwrite the biome of every currently-present section of the chunk
64
+ * view with `biome_name` (e.g. `minecraft:desert`). Sections are created
65
+ * lazily by `set_block`, so call this AFTER placing blocks.
66
+ */
67
+ setBiome(biomeName: string): void;
68
+
69
+ /**
70
+ * Deduped union of all sections' biome palette entries, in order of
71
+ * first appearance, written as a JSON array string (`[]` if no section
72
+ * carries biome data).
73
+ */
74
+ biomePaletteJson(): string;
75
+ }
@@ -1,6 +1,6 @@
1
1
  // generated by diplomat-tool
2
- import type { NucleationError } from "./NucleationError"
3
- import type { Schematic } from "./Schematic"
2
+ import type { NucleationError } from "./NucleationError.mjs"
3
+ import type { Schematic } from "./Schematic.mjs"
4
4
  import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
5
5
 
6
6
 
@@ -0,0 +1,75 @@
1
+ // generated by diplomat-tool
2
+ import type { Brush } from "./Brush.mjs"
3
+ import type { CellularSdfConfig } from "./CellularSdfConfig.mjs"
4
+ import type { GeneratedChunk } from "./GeneratedChunk.mjs"
5
+ import type { GeneratedChunkOverlayMode } from "./GeneratedChunkOverlayMode.mjs"
6
+ import type { GeneratedWorldStream } from "./GeneratedWorldStream.mjs"
7
+ import type { NucleationError } from "./NucleationError.mjs"
8
+ import type { Sdf } from "./Sdf.mjs"
9
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
10
+
11
+
12
+
13
+ /**
14
+ * An immutable native chunk source graph.
15
+ *
16
+ * Generated bindings expose concrete source constructors rather than host
17
+ * callbacks, so SDF evaluation and block placement stay entirely in Rust.
18
+ */
19
+ export class WorldGenerator {
20
+ /** @internal */
21
+ get ffiValue(): pointer;
22
+ /** @internal */
23
+ constructor();
24
+
25
+
26
+ /**
27
+ * Create an SDF-backed source evaluated at voxel centers over the inclusive
28
+ * Y range. `source_id` and `version` become chunk provenance/cache metadata.
29
+ */
30
+ static sdf(volume: Sdf, material: Brush, minY: number, maxY: number, sourceId: string, version: string): WorldGenerator;
31
+
32
+ /**
33
+ * Create a sparse infinite source by placing a bounded SDF motif once per
34
+ * deterministically transformed cell. Reuse `config` across layers to keep
35
+ * terrain, water, vegetation, paths, and structures coordinated.
36
+ */
37
+ static cellularSdf(volume: Sdf, material: Brush, minY: number, maxY: number, config: CellularSdfConfig, sourceId: string, version: string): WorldGenerator;
38
+
39
+ /**
40
+ * Create a sparse source from projected building footprints, including
41
+ * caller-projected OSM-derived data.
42
+ * `buildings_json` uses the same schema as `Geo.extrude_footprints`:
43
+ * `[{"polygon":[[x,z],...],"height":40,"min_y":1,
44
+ * "block":"minecraft:bricks"}]`. `height` is the absolute top Y, matching
45
+ * `Geo.extrude_footprints`. Fetching and lat/lon projection stay
46
+ * caller-controlled; this source rasterizes only requested chunks.
47
+ */
48
+ static projectedFootprints(buildingsJson: string, baseBlock: string, sourceId: string, version: string): WorldGenerator;
49
+
50
+ /**
51
+ * Create an initially empty ordered source composition.
52
+ */
53
+ static composite(sourceId: string, version: string): WorldGenerator;
54
+
55
+ /**
56
+ * Append a source to a composite. Later `Replace` layers win at occupied
57
+ * voxels; `KeepExisting` layers only fill air. Errors on non-composites.
58
+ *
59
+ * Streams already created from this generator keep the layer list they
60
+ * were built with; only later `generate`/`stream` calls see the addition.
61
+ */
62
+ addLayer(source: WorldGenerator, mode: GeneratedChunkOverlayMode): void;
63
+
64
+ /**
65
+ * Generate one random-access chunk.
66
+ */
67
+ generate(cx: number, cz: number): GeneratedChunk;
68
+
69
+ /**
70
+ * Traverse an inclusive chunk rectangle lazily in canonical region-major
71
+ * order. The stream snapshots the generator's sources at creation, so
72
+ * later `add_layer` calls do not affect a stream already in flight.
73
+ */
74
+ stream(minCx: number, minCz: number, maxCx: number, maxCz: number): GeneratedWorldStream;
75
+ }
@@ -0,0 +1,75 @@
1
+ // generated by diplomat-tool
2
+ import type { Brush } from "./Brush.mjs"
3
+ import type { CellularSdfConfig } from "./CellularSdfConfig.mjs"
4
+ import type { GeneratedChunk } from "./GeneratedChunk.mjs"
5
+ import type { GeneratedChunkOverlayMode } from "./GeneratedChunkOverlayMode.mjs"
6
+ import type { GeneratedWorldStream } from "./GeneratedWorldStream.mjs"
7
+ import type { NucleationError } from "./NucleationError.mjs"
8
+ import type { Sdf } from "./Sdf.mjs"
9
+ import type { pointer, codepoint } from "./diplomat-runtime.d.ts";
10
+
11
+
12
+
13
+ /**
14
+ * An immutable native chunk source graph.
15
+ *
16
+ * Generated bindings expose concrete source constructors rather than host
17
+ * callbacks, so SDF evaluation and block placement stay entirely in Rust.
18
+ */
19
+ export class WorldGenerator {
20
+ /** @internal */
21
+ get ffiValue(): pointer;
22
+ /** @internal */
23
+ constructor();
24
+
25
+
26
+ /**
27
+ * Create an SDF-backed source evaluated at voxel centers over the inclusive
28
+ * Y range. `source_id` and `version` become chunk provenance/cache metadata.
29
+ */
30
+ static sdf(volume: Sdf, material: Brush, minY: number, maxY: number, sourceId: string, version: string): WorldGenerator;
31
+
32
+ /**
33
+ * Create a sparse infinite source by placing a bounded SDF motif once per
34
+ * deterministically transformed cell. Reuse `config` across layers to keep
35
+ * terrain, water, vegetation, paths, and structures coordinated.
36
+ */
37
+ static cellularSdf(volume: Sdf, material: Brush, minY: number, maxY: number, config: CellularSdfConfig, sourceId: string, version: string): WorldGenerator;
38
+
39
+ /**
40
+ * Create a sparse source from projected building footprints, including
41
+ * caller-projected OSM-derived data.
42
+ * `buildings_json` uses the same schema as `Geo.extrude_footprints`:
43
+ * `[{"polygon":[[x,z],...],"height":40,"min_y":1,
44
+ * "block":"minecraft:bricks"}]`. `height` is the absolute top Y, matching
45
+ * `Geo.extrude_footprints`. Fetching and lat/lon projection stay
46
+ * caller-controlled; this source rasterizes only requested chunks.
47
+ */
48
+ static projectedFootprints(buildingsJson: string, baseBlock: string, sourceId: string, version: string): WorldGenerator;
49
+
50
+ /**
51
+ * Create an initially empty ordered source composition.
52
+ */
53
+ static composite(sourceId: string, version: string): WorldGenerator;
54
+
55
+ /**
56
+ * Append a source to a composite. Later `Replace` layers win at occupied
57
+ * voxels; `KeepExisting` layers only fill air. Errors on non-composites.
58
+ *
59
+ * Streams already created from this generator keep the layer list they
60
+ * were built with; only later `generate`/`stream` calls see the addition.
61
+ */
62
+ addLayer(source: WorldGenerator, mode: GeneratedChunkOverlayMode): void;
63
+
64
+ /**
65
+ * Generate one random-access chunk.
66
+ */
67
+ generate(cx: number, cz: number): GeneratedChunk;
68
+
69
+ /**
70
+ * Traverse an inclusive chunk rectangle lazily in canonical region-major
71
+ * order. The stream snapshots the generator's sources at creation, so
72
+ * later `add_layer` calls do not affect a stream already in flight.
73
+ */
74
+ stream(minCx: number, minCz: number, maxCx: number, maxCz: number): GeneratedWorldStream;
75
+ }
@@ -0,0 +1,255 @@
1
+ // generated by diplomat-tool
2
+ import { Brush } from "./Brush.mjs"
3
+ import { CellularSdfConfig } from "./CellularSdfConfig.mjs"
4
+ import { GeneratedChunk } from "./GeneratedChunk.mjs"
5
+ import { GeneratedChunkOverlayMode } from "./GeneratedChunkOverlayMode.mjs"
6
+ import { GeneratedWorldStream } from "./GeneratedWorldStream.mjs"
7
+ import { NucleationError } from "./NucleationError.mjs"
8
+ import { Sdf } from "./Sdf.mjs"
9
+ import wasm from "./diplomat-wasm.mjs";
10
+ import * as diplomatRuntime from "./diplomat-runtime.mjs";
11
+
12
+ const WorldGenerator_box_destroy_registry = new FinalizationRegistry((ptr) => {
13
+ wasm.WorldGenerator_destroy(ptr);
14
+ });
15
+
16
+ /**
17
+ * An immutable native chunk source graph.
18
+ *
19
+ * Generated bindings expose concrete source constructors rather than host
20
+ * callbacks, so SDF evaluation and block placement stay entirely in Rust.
21
+ */
22
+ export class WorldGenerator {
23
+ // Internal ptr reference:
24
+ #ptr = null;
25
+
26
+ // Lifetimes are only to keep dependencies alive.
27
+ // Since JS won't garbage collect until there are no incoming edges.
28
+ #selfEdge = [];
29
+
30
+ #internalConstructor(symbol, ptr, selfEdge) {
31
+ if (symbol !== diplomatRuntime.internalConstructor) {
32
+ console.error("WorldGenerator is an Opaque type. You cannot call its constructor.");
33
+ return;
34
+ }
35
+ this.#ptr = ptr;
36
+ this.#selfEdge = selfEdge;
37
+
38
+ // Are we being borrowed? If not, we can register.
39
+ if (this.#selfEdge.length === 0) {
40
+ WorldGenerator_box_destroy_registry.register(this, this.#ptr);
41
+ }
42
+
43
+ return this;
44
+ }
45
+ /** @internal */
46
+ get ffiValue() {
47
+ return this.#ptr;
48
+ }
49
+
50
+
51
+ /**
52
+ * Create an SDF-backed source evaluated at voxel centers over the inclusive
53
+ * Y range. `source_id` and `version` become chunk provenance/cache metadata.
54
+ */
55
+ static sdf(volume, material, minY, maxY, sourceId, version) {
56
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
57
+
58
+ const sourceIdSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, sourceId)));
59
+ const versionSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, version)));
60
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
61
+
62
+
63
+ const result = wasm.WorldGenerator_sdf(diplomatReceive.buffer, volume.ffiValue, material.ffiValue, minY, maxY, sourceIdSlice.ptr, versionSlice.ptr);
64
+
65
+ try {
66
+ if (!diplomatReceive.resultFlag) {
67
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
68
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
69
+ }
70
+ return new WorldGenerator(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
71
+ }
72
+
73
+ finally {
74
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
75
+ functionCleanupArena.free();
76
+
77
+ diplomatReceive.free();
78
+ }
79
+ }
80
+
81
+ /**
82
+ * Create a sparse infinite source by placing a bounded SDF motif once per
83
+ * deterministically transformed cell. Reuse `config` across layers to keep
84
+ * terrain, water, vegetation, paths, and structures coordinated.
85
+ */
86
+ static cellularSdf(volume, material, minY, maxY, config, sourceId, version) {
87
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
88
+
89
+ const sourceIdSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, sourceId)));
90
+ const versionSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, version)));
91
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
92
+
93
+
94
+ const result = wasm.WorldGenerator_cellular_sdf(diplomatReceive.buffer, volume.ffiValue, material.ffiValue, minY, maxY, config.ffiValue, sourceIdSlice.ptr, versionSlice.ptr);
95
+
96
+ try {
97
+ if (!diplomatReceive.resultFlag) {
98
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
99
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
100
+ }
101
+ return new WorldGenerator(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
102
+ }
103
+
104
+ finally {
105
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
106
+ functionCleanupArena.free();
107
+
108
+ diplomatReceive.free();
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Create a sparse source from projected building footprints, including
114
+ * caller-projected OSM-derived data.
115
+ * `buildings_json` uses the same schema as `Geo.extrude_footprints`:
116
+ * `[{"polygon":[[x,z],...],"height":40,"min_y":1,
117
+ * "block":"minecraft:bricks"}]`. `height` is the absolute top Y, matching
118
+ * `Geo.extrude_footprints`. Fetching and lat/lon projection stay
119
+ * caller-controlled; this source rasterizes only requested chunks.
120
+ */
121
+ static projectedFootprints(buildingsJson, baseBlock, sourceId, version) {
122
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
123
+
124
+ const buildingsJsonSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, buildingsJson)));
125
+ const baseBlockSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, baseBlock)));
126
+ const sourceIdSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, sourceId)));
127
+ const versionSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, version)));
128
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
129
+
130
+
131
+ const result = wasm.WorldGenerator_projected_footprints(diplomatReceive.buffer, buildingsJsonSlice.ptr, baseBlockSlice.ptr, sourceIdSlice.ptr, versionSlice.ptr);
132
+
133
+ try {
134
+ if (!diplomatReceive.resultFlag) {
135
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
136
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
137
+ }
138
+ return new WorldGenerator(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
139
+ }
140
+
141
+ finally {
142
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
143
+ functionCleanupArena.free();
144
+
145
+ diplomatReceive.free();
146
+ }
147
+ }
148
+
149
+ /**
150
+ * Create an initially empty ordered source composition.
151
+ */
152
+ static composite(sourceId, version) {
153
+ let functionCleanupArena = new diplomatRuntime.CleanupArena();
154
+
155
+ const sourceIdSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, sourceId)));
156
+ const versionSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, version)));
157
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
158
+
159
+
160
+ const result = wasm.WorldGenerator_composite(diplomatReceive.buffer, sourceIdSlice.ptr, versionSlice.ptr);
161
+
162
+ try {
163
+ if (!diplomatReceive.resultFlag) {
164
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
165
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
166
+ }
167
+ return new WorldGenerator(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
168
+ }
169
+
170
+ finally {
171
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
172
+ functionCleanupArena.free();
173
+
174
+ diplomatReceive.free();
175
+ }
176
+ }
177
+
178
+ /**
179
+ * Append a source to a composite. Later `Replace` layers win at occupied
180
+ * voxels; `KeepExisting` layers only fill air. Errors on non-composites.
181
+ *
182
+ * Streams already created from this generator keep the layer list they
183
+ * were built with; only later `generate`/`stream` calls see the addition.
184
+ */
185
+ addLayer(source, mode) {
186
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
187
+
188
+
189
+ const result = wasm.WorldGenerator_add_layer(diplomatReceive.buffer, this.ffiValue, source.ffiValue, mode.ffiValue);
190
+
191
+ try {
192
+ if (!diplomatReceive.resultFlag) {
193
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
194
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
195
+ }
196
+ }
197
+
198
+ finally {
199
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
200
+ diplomatReceive.free();
201
+ }
202
+ }
203
+
204
+ /**
205
+ * Generate one random-access chunk.
206
+ */
207
+ generate(cx, cz) {
208
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
209
+
210
+
211
+ const result = wasm.WorldGenerator_generate(diplomatReceive.buffer, this.ffiValue, cx, cz);
212
+
213
+ try {
214
+ if (!diplomatReceive.resultFlag) {
215
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
216
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
217
+ }
218
+ return new GeneratedChunk(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
219
+ }
220
+
221
+ finally {
222
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
223
+ diplomatReceive.free();
224
+ }
225
+ }
226
+
227
+ /**
228
+ * Traverse an inclusive chunk rectangle lazily in canonical region-major
229
+ * order. The stream snapshots the generator's sources at creation, so
230
+ * later `add_layer` calls do not affect a stream already in flight.
231
+ */
232
+ stream(minCx, minCz, maxCx, maxCz) {
233
+ const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);
234
+
235
+
236
+ const result = wasm.WorldGenerator_stream(diplomatReceive.buffer, this.ffiValue, minCx, minCz, maxCx, maxCz);
237
+
238
+ try {
239
+ if (!diplomatReceive.resultFlag) {
240
+ const cause = new NucleationError(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
241
+ throw new globalThis.Error('NucleationError.' + cause.value, { cause });
242
+ }
243
+ return new GeneratedWorldStream(diplomatRuntime.internalConstructor, diplomatRuntime.ptrRead(wasm, diplomatReceive.buffer), []);
244
+ }
245
+
246
+ finally {
247
+ diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
248
+ diplomatReceive.free();
249
+ }
250
+ }
251
+
252
+ constructor(symbol, ptr, selfEdge) {
253
+ return this.#internalConstructor(...arguments)
254
+ }
255
+ }