@threenative/terrain 0.1.7 → 0.1.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.
Files changed (127) hide show
  1. package/AGENT_GUIDE.md +19 -4
  2. package/dist/editor/index.d.ts +160 -5
  3. package/dist/editor/index.js +3783 -1406
  4. package/dist/editor/server.d.ts +2 -2
  5. package/dist/editor/server.js +555 -121
  6. package/dist/editor/worker.d.ts +33 -1
  7. package/dist/editor/worker.js +444 -110
  8. package/dist/export.d.ts +11 -9
  9. package/dist/export.js +22 -34
  10. package/dist/index.d.ts +727 -73
  11. package/dist/index.js +2434 -553
  12. package/dist/kit.d.ts +56 -0
  13. package/dist/kit.js +2524 -0
  14. package/dist/mcp/cook-child.d.ts +2 -0
  15. package/dist/mcp/cook-child.js +3705 -0
  16. package/dist/mcp/server.d.ts +7 -0
  17. package/dist/mcp/server.js +3279 -0
  18. package/dist/{server-ByM2hmYJ.d.ts → server-C8Ydr_IM.d.ts} +3 -2
  19. package/dist/starter.d.ts +143 -0
  20. package/dist/starter.js +1030 -0
  21. package/dist/{terrain-gPnkCU6S.d.ts → terrain-B3DkduPw.d.ts} +3 -2
  22. package/dist/three.d.ts +1 -1
  23. package/dist/{types-Ant8-Axc.d.ts → types-CPYAc9vo.d.ts} +13 -4
  24. package/dist/world-package-B7KGYIou.d.ts +94 -0
  25. package/package.json +28 -6
  26. package/starter/alpine/README.md +77 -1
  27. package/starter/alpine/bake.mjs +4 -116
  28. package/starter/alpine/biome.data.json +114 -0
  29. package/starter/alpine/heightmap.r16 +0 -0
  30. package/starter/alpine/recipe.json +3 -66051
  31. package/starter/alpine/world.ts +45 -293
  32. package/starter/coastal/README.md +77 -1
  33. package/starter/coastal/bake.mjs +4 -116
  34. package/starter/coastal/biome.data.json +135 -0
  35. package/starter/coastal/heightmap.r16 +0 -0
  36. package/starter/coastal/recipe.json +3 -66051
  37. package/starter/coastal/sea.ts +49 -16
  38. package/starter/coastal/world.ts +53 -318
  39. package/starter/desert/README.md +77 -1
  40. package/starter/desert/bake.mjs +4 -116
  41. package/starter/desert/biome.data.json +114 -0
  42. package/starter/desert/heightmap.r16 +0 -0
  43. package/starter/desert/recipe.json +3 -66051
  44. package/starter/desert/world.ts +45 -293
  45. package/starter/forest/README.md +84 -4
  46. package/starter/forest/assets.json +32 -0
  47. package/starter/forest/bake.mjs +6 -116
  48. package/starter/forest/biome.data.json +150 -0
  49. package/starter/forest/heightmap.r16 +0 -0
  50. package/starter/forest/recipe.json +192 -4428
  51. package/starter/forest/sky.ts +11 -0
  52. package/starter/forest/water.ts +30 -20
  53. package/starter/forest/world.ts +86 -322
  54. package/starter/tundra/README.md +77 -1
  55. package/starter/tundra/bake.mjs +4 -116
  56. package/starter/tundra/biome.data.json +131 -0
  57. package/starter/tundra/heightmap.r16 +0 -0
  58. package/starter/tundra/recipe.json +18 -66066
  59. package/starter/tundra/world.ts +65 -319
  60. package/starter-assets.json +6 -0
  61. package/{starter-assets/credits.json → starter-credits.json} +12 -105
  62. package/starter-assets/bark_brown_02/bark_brown_02_diff_1k.jpg +0 -0
  63. package/starter-assets/bark_brown_02/bark_brown_02_nor_gl_1k.jpg +0 -0
  64. package/starter-assets/bark_brown_02/bark_brown_02_rough_1k.jpg +0 -0
  65. package/starter-assets/boulder_01/boulder-mid.glb +0 -0
  66. package/starter-assets/boulder_01/boulder-near.glb +0 -0
  67. package/starter-assets/cliff_side/cliff_side_ao_1k.jpg +0 -0
  68. package/starter-assets/cliff_side/cliff_side_diff_1k.jpg +0 -0
  69. package/starter-assets/cliff_side/cliff_side_nor_gl_1k.jpg +0 -0
  70. package/starter-assets/cliff_side/cliff_side_rough_1k.jpg +0 -0
  71. package/starter-assets/fern_02/fern_02_alpha_512.png +0 -0
  72. package/starter-assets/fern_02/fern_02_diff_512.jpg +0 -0
  73. package/starter-assets/fern_02/fern_02_nor_gl_512.jpg +0 -0
  74. package/starter-assets/fir_tree_01/fir-b-lod1.glb +0 -0
  75. package/starter-assets/fir_tree_01/fir-b-lod2.glb +0 -0
  76. package/starter-assets/fir_tree_01/fir-c-lod1.glb +0 -0
  77. package/starter-assets/fir_tree_01/fir-c-lod2.glb +0 -0
  78. package/starter-assets/fir_tree_01/fir_tree_01_twig_arm_1k.jpg +0 -0
  79. package/starter-assets/fir_tree_01/fir_tree_01_twig_diff_1k.jpg +0 -0
  80. package/starter-assets/fir_tree_01/fir_tree_01_twig_nor_gl_1k.jpg +0 -0
  81. package/starter-assets/forest_ground_04/forest_ground_04_ao_1k.jpg +0 -0
  82. package/starter-assets/forest_ground_04/forest_ground_04_diff_1k.jpg +0 -0
  83. package/starter-assets/forest_ground_04/forest_ground_04_nor_gl_1k.jpg +0 -0
  84. package/starter-assets/forest_ground_04/forest_ground_04_rough_1k.jpg +0 -0
  85. package/starter-assets/forest_leaves_02/forest_leaves_02_arm_512.jpg +0 -0
  86. package/starter-assets/forest_leaves_02/forest_leaves_02_diff_512.jpg +0 -0
  87. package/starter-assets/forest_leaves_02/forest_leaves_02_nor_gl_512.jpg +0 -0
  88. package/starter-assets/grass_medium_02/grass_medium_02_alpha_512.png +0 -0
  89. package/starter-assets/grass_medium_02/grass_medium_02_diff_512.jpg +0 -0
  90. package/starter-assets/grass_medium_02/grass_medium_02_nor_gl_512.jpg +0 -0
  91. package/starter-assets/hdri/kloofendal_48d_partly_cloudy_1k.hdr +0 -0
  92. package/starter-assets/leafy_grass/leafy_grass_ao_1k.jpg +0 -0
  93. package/starter-assets/leafy_grass/leafy_grass_diff_1k.jpg +0 -0
  94. package/starter-assets/leafy_grass/leafy_grass_nor_gl_1k.jpg +0 -0
  95. package/starter-assets/leafy_grass/leafy_grass_rough_1k.jpg +0 -0
  96. package/starter-assets/lichen_rock/lichen_rock_arm_512.jpg +0 -0
  97. package/starter-assets/lichen_rock/lichen_rock_diff_512.jpg +0 -0
  98. package/starter-assets/lichen_rock/lichen_rock_nor_gl_512.jpg +0 -0
  99. package/starter-assets/mossy_rock/mossy_rock_ao_1k.jpg +0 -0
  100. package/starter-assets/mossy_rock/mossy_rock_diff_1k.jpg +0 -0
  101. package/starter-assets/mossy_rock/mossy_rock_nor_gl_1k.jpg +0 -0
  102. package/starter-assets/mossy_rock/mossy_rock_rough_1k.jpg +0 -0
  103. package/starter-assets/needle-atlas.png +0 -0
  104. package/starter-assets/needle-surface.png +0 -0
  105. package/starter-assets/river_small_rocks/river_small_rocks_arm_512.jpg +0 -0
  106. package/starter-assets/river_small_rocks/river_small_rocks_diff_512.jpg +0 -0
  107. package/starter-assets/river_small_rocks/river_small_rocks_nor_gl_512.jpg +0 -0
  108. package/starter-assets/rock_boulder_dry/rock_boulder_dry_arm_512.jpg +0 -0
  109. package/starter-assets/rock_boulder_dry/rock_boulder_dry_diff_512.jpg +0 -0
  110. package/starter-assets/rock_boulder_dry/rock_boulder_dry_nor_gl_512.jpg +0 -0
  111. package/starter-assets/rocks/boulder-mid.glb +0 -0
  112. package/starter-assets/rocks/boulder-near.glb +0 -0
  113. package/starter-assets/rocks/boulder-prep.json +0 -37
  114. package/starter-assets/rocks/rock01-mid.glb +0 -0
  115. package/starter-assets/rocks/rock01-near.glb +0 -0
  116. package/starter-assets/rocks/rock01-prep.json +0 -37
  117. package/starter-assets/rocks/rock04-mid.glb +0 -0
  118. package/starter-assets/rocks/rock04-near.glb +0 -0
  119. package/starter-assets/rocks/rock04-prep.json +0 -37
  120. package/starter-assets/sand_01/sand_01_ao_1k.jpg +0 -0
  121. package/starter-assets/sand_01/sand_01_diff_1k.jpg +0 -0
  122. package/starter-assets/sand_01/sand_01_nor_gl_1k.jpg +0 -0
  123. package/starter-assets/sand_01/sand_01_rough_1k.jpg +0 -0
  124. package/starter-assets/snow_02/snow_02_ao_1k.jpg +0 -0
  125. package/starter-assets/snow_02/snow_02_diff_1k.jpg +0 -0
  126. package/starter-assets/snow_02/snow_02_nor_gl_1k.jpg +0 -0
  127. package/starter-assets/snow_02/snow_02_rough_1k.jpg +0 -0
@@ -1,5 +1,5 @@
1
1
  import { Plugin } from 'vite';
2
- import { I as ITerrainState, d as ITerrainDocument, h as IPlacementOverride } from './types-Ant8-Axc.js';
2
+ import { I as ITerrainState, b as ITerrainDocument, i as IPlacementOverride } from './types-CPYAc9vo.js';
3
3
 
4
4
  type IAssetKind = "model" | "image" | "environment";
5
5
  interface IAssetBounds {
@@ -606,6 +606,7 @@ declare class TerrainEditorDocument {
606
606
  snapshot(): IEditorSnapshot;
607
607
  subscribe(listener: (snapshot: IEditorSnapshot) => void): () => void;
608
608
  refresh(): void;
609
+ restoreLastValid(): IEditorSnapshot;
609
610
  commit(input: unknown): IEditorSnapshot;
610
611
  }
611
612
  /**
@@ -627,4 +628,4 @@ declare function terrainEditor(options: {
627
628
  activate(): Promise<IEditorActivation>;
628
629
  };
629
630
 
630
- export { terrainEditor as $, type IProfileObservation as A, type IProfileSample as B, type IProjectAsset as C, type IReferenceObservation as D, type ISavedSpatialReference as E, type ISpatialControlPoint as F, type ISpatialReference as G, type ISurfaceMapping as H, type IAuthoringDocument as I, type ISurfaceMappings as J, type ISurfaceReading as K, checkEnvironmentAssets as L, focusCamera as M, inspectSpatial as N, probeTerrain as O, runCameraOperation as P, runEnvironmentOperation as Q, sniff as R, surfaceSpace as S, validateAsset as T, validateAssets as U, validateCamera as V, validateCameras as W, validateEnvironment as X, validateSpatialReference as Y, validateSurfaces as Z, TerrainEditorDocument as _, type ISavedCamera as a, type IFocusRequest as b, type IFocusOutcome as c, type IFocusBounds as d, type IEnvironment as e, type IEditorActivation as f, type IEditorSnapshot as g, type ISpatialQuery as h, type ISpatialObservation as i, type ICameraOperation as j, type ICameraResult as k, type IEnvironmentOperation as l, type IEnvironmentResult as m, type IAssetOperation as n, type IAssetResult as o, type IAssetAdjust as p, type IAssetBounds as q, type IAssetKind as r, type IAssetLimits as s, type ICameraPose as t, type ICameraSet as u, type IFocusFraming as v, type IFocusResolver as w, type IFocusTarget as x, type IHexColour as y, type IPointObservation as z };
631
+ export { terrainEditor as $, type IProfileObservation as A, type IProfileSample as B, type IProjectAsset as C, type IReferenceObservation as D, type ISavedSpatialReference as E, type ISpatialControlPoint as F, type ISpatialReference as G, type ISurfaceMapping as H, type IEditorSnapshot as I, type ISurfaceMappings as J, type ISurfaceReading as K, checkEnvironmentAssets as L, focusCamera as M, inspectSpatial as N, probeTerrain as O, runCameraOperation as P, runEnvironmentOperation as Q, sniff as R, surfaceSpace as S, validateAsset as T, validateAssets as U, validateCamera as V, validateCameras as W, validateEnvironment as X, validateSpatialReference as Y, validateSurfaces as Z, TerrainEditorDocument as _, type IAuthoringDocument as a, type ISavedCamera as b, type IFocusRequest as c, type IFocusOutcome as d, type IFocusBounds as e, type IEnvironment as f, type IEditorActivation as g, type ISpatialQuery as h, type ISpatialObservation as i, type ICameraOperation as j, type ICameraResult as k, type IEnvironmentOperation as l, type IEnvironmentResult as m, type IAssetOperation as n, type IAssetResult as o, type IAssetAdjust as p, type IAssetBounds as q, type IAssetKind as r, type IAssetLimits as s, type ICameraPose as t, type ICameraSet as u, type IFocusFraming as v, type IFocusResolver as w, type IFocusTarget as x, type IHexColour as y, type IPointObservation as z };
@@ -0,0 +1,143 @@
1
+ import { IComputeDriven, ICtx } from '@threenative/core';
2
+ import { IWorldPackage, WorldCells, Heightfield, IWorldCellsLoadOptions } from '@threenative/core/world';
3
+ import { RigidBody3D, IPhysicsContext } from '@threenative/physics';
4
+ import { Object3D, Material, Mesh, Texture, MeshStandardMaterial, Color } from 'three';
5
+ import { i as IPlacementOverride } from './types-CPYAc9vo.js';
6
+
7
+ type PlacementEdit = Omit<IPlacementOverride, "position" | "quaternion" | "scale" | "grounding"> & {
8
+ readonly position: readonly [number, number, number];
9
+ readonly quaternion: readonly [number, number, number, number];
10
+ readonly scale: readonly [number, number, number];
11
+ readonly grounding?: boolean;
12
+ };
13
+ interface IWorldPlacementEdits {
14
+ /** Replace or add asset kinds. Package-relative paths; `bounds` is required. */
15
+ readonly assets?: Readonly<Record<string, IWorldPackage["assets"][string]>>;
16
+ /** Move, rotate or scale by stable ID. */
17
+ readonly overrides?: Readonly<Record<string, PlacementEdit>>;
18
+ /** Remove by stable ID. */
19
+ readonly remove?: readonly string[];
20
+ /** Remove every record inside a circle. */
21
+ readonly clear?: readonly {
22
+ readonly center: readonly [number, number];
23
+ readonly radius: number;
24
+ readonly assets?: readonly string[];
25
+ }[];
26
+ /** New records. Each `id` must not already exist. */
27
+ readonly add?: readonly (PlacementEdit & {
28
+ readonly id: string;
29
+ readonly asset: string;
30
+ })[];
31
+ }
32
+ interface IRemovedPlacement {
33
+ readonly id: string;
34
+ readonly asset: string;
35
+ readonly position: readonly [number, number, number];
36
+ readonly quaternion: readonly [number, number, number, number];
37
+ readonly scale: number;
38
+ }
39
+ /**
40
+ * Apply deterministic startup edits to the decoded placement data before a world is loaded.
41
+ *
42
+ * @situation change generated terrain composition from game source without rebaking the world
43
+ * @requires npm i -D @threenative/terrain
44
+ * @example const edited = editWorldPlacements(data, { remove: ["scree:candidate:7:41"] }, (x, z) => field.heightAt(x, z));
45
+ * @override grounding defaults on, while `grounding: false` preserves the authored Y coordinate
46
+ */
47
+ declare function editWorldPlacements(data: {
48
+ manifest: IWorldPackage;
49
+ placements: ArrayBuffer;
50
+ ids?: readonly string[];
51
+ }, edits: IWorldPlacementEdits, heightAt: (x: number, z: number) => number): {
52
+ manifest: IWorldPackage;
53
+ placements: ArrayBuffer;
54
+ ids?: readonly string[];
55
+ unmatched: readonly string[];
56
+ removed: readonly IRemovedPlacement[];
57
+ };
58
+
59
+ type StarterContext = ICtx<Record<string, unknown>, IPhysicsContext>;
60
+ type StarterColliders = Readonly<Record<string, {
61
+ sphere: number;
62
+ } | {
63
+ capsule: readonly [number, number];
64
+ } | null>>;
65
+ interface IStarterWorld {
66
+ readonly world: WorldCells;
67
+ readonly ground: RigidBody3D;
68
+ readonly colliders: PropColliders;
69
+ readonly field: Heightfield;
70
+ readonly placements: Float32Array;
71
+ readonly manifest: IWorldPackage;
72
+ readonly placementIds?: readonly string[];
73
+ readonly editReport: {
74
+ readonly unmatched: readonly string[];
75
+ readonly removed: readonly IRemovedPlacement[];
76
+ };
77
+ readonly extent: IWorldPackage["extent"];
78
+ }
79
+ interface IStarterWorldSpec<Extra extends {
80
+ dispose(): void;
81
+ }> {
82
+ readonly name: string;
83
+ readonly url: string;
84
+ readonly colliders: StarterColliders;
85
+ readonly colliderReach: number;
86
+ /**
87
+ * Apply startup placement edits before streaming, lighting and collision consume the data.
88
+ * @situation move, remove or add generated props from game source without rebaking
89
+ * @example edits: { remove: ["scree:candidate:7:41"] }
90
+ * @override grounding defaults on; `grounding: false` keeps the authored Y coordinate
91
+ */
92
+ readonly edits?: IWorldPlacementEdits;
93
+ /** Terrain query layer; omitted keeps the physics body's default layer. */
94
+ readonly groundCollisionLayer?: number;
95
+ readonly loadSurface: (ctx: StarterContext, url: string) => Promise<Material>;
96
+ readonly lighting: {
97
+ readonly sky: string;
98
+ readonly lods: boolean;
99
+ readonly dress: (mesh: Mesh, sky: Texture, id: string, originals: ReadonlyMap<MeshStandardMaterial, {
100
+ color: Color;
101
+ }>) => void;
102
+ };
103
+ readonly streaming: Pick<IWorldCellsLoadOptions, "ring" | "impostors" | "gpuScene" | "shadows" | "budgets" | "terrain">;
104
+ readonly water?: (ctx: StarterContext, file: unknown, field: Heightfield, manifest: IWorldPackage, heightmap: Uint16Array) => Extra;
105
+ }
106
+ /** Load caller-authored starter data with one scene lifetime; all appearance comes from spec.
107
+ * @situation attach a baked starter world with game-owned surfaces, prop dressing and water
108
+ * @constraint Runtime subpath; the game supplies every appearance and collision choice
109
+ * @requires npm i -D @threenative/terrain
110
+ * @example await addStarterWorld(ctx, follow, spec);
111
+ */
112
+ declare function addStarterWorld<Extra extends {
113
+ dispose(): void;
114
+ } = {
115
+ dispose(): void;
116
+ }>(ctx: ICtx<Record<string, unknown>, IPhysicsContext>, follow: Object3D, spec: IStarterWorldSpec<Extra>, url?: string, whileCurrent?: () => boolean): Promise<IStarterWorld & {
117
+ extra: Extra | undefined;
118
+ }>;
119
+ /** Stream caller-specified fixed collision shapes around a moving follow object.
120
+ * @situation attach nearby prop collision bodies from baked placement records
121
+ * @constraint Shapes and reach are supplied by the game; detach releases every body
122
+ * @requires npm i -D @threenative/terrain
123
+ * @example new PropColliders(ctx, follow, manifest, records, shapes, reach, name);
124
+ */
125
+ declare class PropColliders extends Object3D implements IComputeDriven {
126
+ #private;
127
+ private readonly ctx;
128
+ private readonly follow;
129
+ private readonly records;
130
+ private readonly shapes;
131
+ private readonly reach;
132
+ readonly warmupNodes: readonly unknown[];
133
+ readonly processCadence: "render";
134
+ constructor(ctx: ICtx<Record<string, unknown>, IPhysicsContext>, follow: Object3D, manifest: IWorldPackage, records: Float32Array, shapes: StarterColliders, reach: number, name: string);
135
+ /** How many prop bodies exist right now. */
136
+ get active(): number;
137
+ get released(): boolean;
138
+ attachRenderer(): void;
139
+ process(): void;
140
+ detach(): void;
141
+ }
142
+
143
+ export { type IRemovedPlacement, type IStarterWorld, type IStarterWorldSpec, type IWorldPlacementEdits, PropColliders, type StarterColliders, type StarterContext, addStarterWorld, editWorldPlacements };