@threenative/terrain 0.1.9 → 0.1.12
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/README.md +40 -59
- package/THIRD_PARTY_NOTICES.md +2 -1
- package/dist/bake-DJ5cxg0C.d.ts +82 -0
- package/dist/editor/index.d.ts +4 -4
- package/dist/editor/index.js +130 -128
- package/dist/editor/server.d.ts +2 -2
- package/dist/editor/server.js +38 -35
- package/dist/editor/worker.d.ts +1 -1
- package/dist/editor/worker.js +101 -101
- package/dist/export.d.ts +1 -1
- package/dist/index.d.ts +156 -273
- package/dist/index.js +562 -378
- package/dist/kit-world.d.ts +107 -0
- package/dist/kit-world.js +5134 -0
- package/dist/kit.d.ts +21 -4
- package/dist/kit.js +337 -223
- package/dist/mcp/cook-child.js +1963 -1543
- package/dist/mcp/server.js +716 -429
- package/dist/prop-package-Dwz0EWoB.d.ts +141 -0
- package/dist/{server-B5RdvEAC.d.ts → server-LnFwY8sr.d.ts} +1 -1
- package/dist/starter.d.ts +1142 -7
- package/dist/starter.js +2102 -120
- package/dist/{terrain-CAEaW0mQ.d.ts → terrain-DYCyAOCJ.d.ts} +1 -1
- package/dist/three.d.ts +1 -1
- package/dist/three.js +1 -1
- package/dist/{types-BpH00qsx.d.ts → types-kpI0C4hW.d.ts} +1 -1
- package/dist/{world-package-B8QgHjAQ.d.ts → world-package-DqJC3-Nn.d.ts} +2 -2
- package/docs/authoring/editor.md +73 -0
- package/docs/authoring/new-environment.md +97 -0
- package/docs/authoring/recipes.md +97 -0
- package/docs/authoring/world-export.md +66 -0
- package/package.json +24 -8
- package/starter/alpine/README.md +22 -12
- package/starter/alpine/bake.mjs +14 -1
- package/starter/alpine/biome.data.json +187 -25
- package/starter/alpine/heightmap.r16 +0 -0
- package/starter/alpine/playerRig.ts +89 -0
- package/starter/alpine/recipe.json +169 -15
- package/starter/alpine/render/bakedFile.ts +17 -0
- package/starter/alpine/render/benchmark.ts +77 -0
- package/starter/alpine/render/biomeData.ts +14 -0
- package/starter/alpine/render/biomes.ts +687 -0
- package/starter/alpine/render/ground/cover.ts +565 -0
- package/starter/alpine/render/ground/horizon.ts +219 -0
- package/starter/alpine/render/ground/palette.d.ts +1 -0
- package/starter/alpine/render/ground/palette.js +11 -0
- package/starter/alpine/render/ground/scatter.ts +104 -0
- package/starter/alpine/render/ground/terrain.ts +1860 -0
- package/starter/alpine/render/kitAssets.ts +28 -0
- package/starter/alpine/render/loading.ts +354 -0
- package/starter/alpine/render/lookKnobs.ts +37 -0
- package/starter/alpine/render/orbitCamera.ts +155 -0
- package/starter/alpine/render/props/farForest.ts +94 -0
- package/starter/alpine/render/props/pack.ts +1114 -0
- package/starter/alpine/render/props/prepared.ts +225 -0
- package/starter/alpine/render/props/propMaterials.ts +1239 -0
- package/starter/alpine/render/props/propProgress.ts +2 -0
- package/starter/alpine/render/props/propWorld.ts +105 -0
- package/starter/alpine/render/props/props.ts +633 -0
- package/starter/alpine/render/props/spruce.ts +440 -0
- package/starter/alpine/render/sky/atmosphere.ts +329 -0
- package/starter/alpine/render/sky/sky.ts +382 -0
- package/starter/alpine/render/texturePreparation.ts +135 -0
- package/starter/alpine/render/water/river.ts +1132 -0
- package/starter/alpine/render/worldNames.ts +6 -0
- package/starter/alpine/scene.ts +715 -0
- package/starter/alpine/sceneProps.ts +561 -0
- package/starter/alpine/sceneState.ts +33 -0
- package/starter/alpine/world/terrainAssets.ts +145 -0
- package/starter/alpine/world/walkBand.ts +47 -0
- package/starter/alpine/world/water.ts +74 -0
- package/starter/alpine/worlds.ts +13 -0
- package/starter/arbor/wind.ts +84 -0
- package/starter/coastal/README.md +26 -25
- package/starter/coastal/assets.json +10 -0
- package/starter/coastal/bake.mjs +14 -1
- package/starter/coastal/biome.data.json +18 -3
- package/starter/coastal/playerRig.ts +89 -0
- package/starter/coastal/recipe.json +220 -18
- package/starter/coastal/render/bakedFile.ts +17 -0
- package/starter/coastal/render/benchmark.ts +81 -0
- package/starter/coastal/render/biomeData.ts +14 -0
- package/starter/coastal/render/biomes.ts +678 -0
- package/starter/coastal/render/ground/cover.ts +565 -0
- package/starter/coastal/render/ground/horizon.ts +219 -0
- package/starter/coastal/render/ground/palette.d.ts +1 -0
- package/starter/coastal/render/ground/palette.js +11 -0
- package/starter/coastal/render/ground/scatter.ts +104 -0
- package/starter/coastal/render/ground/terrain.ts +1829 -0
- package/starter/coastal/render/kitAssets.ts +28 -0
- package/starter/coastal/render/loading.ts +354 -0
- package/starter/coastal/render/lookKnobs.ts +37 -0
- package/starter/coastal/render/orbitCamera.ts +155 -0
- package/starter/coastal/render/props/farForest.ts +94 -0
- package/starter/coastal/render/props/pack.ts +1109 -0
- package/starter/coastal/render/props/prepared.ts +225 -0
- package/starter/coastal/render/props/propMaterials.ts +1239 -0
- package/starter/coastal/render/props/propProgress.ts +2 -0
- package/starter/coastal/render/props/propWorld.ts +105 -0
- package/starter/coastal/render/props/props.ts +633 -0
- package/starter/coastal/render/props/spruce.ts +440 -0
- package/starter/coastal/render/sky/atmosphere.ts +329 -0
- package/starter/coastal/render/sky/sky.ts +382 -0
- package/starter/coastal/render/texturePreparation.ts +135 -0
- package/starter/coastal/render/water/ocean.ts +284 -0
- package/starter/coastal/render/water/river.ts +1132 -0
- package/starter/coastal/render/worldNames.ts +6 -0
- package/starter/coastal/scene.ts +740 -0
- package/starter/coastal/sceneProps.ts +559 -0
- package/starter/coastal/sceneState.ts +33 -0
- package/starter/coastal/world/terrainAssets.ts +151 -0
- package/starter/coastal/world/walkBand.ts +47 -0
- package/starter/coastal/world/water.ts +74 -0
- package/starter/coastal/worlds.ts +13 -0
- package/starter/desert/README.md +51 -23
- package/starter/desert/bake-flora.mjs +142 -0
- package/starter/desert/bake-rocks.mjs +291 -0
- package/starter/desert/bake.mjs +14 -1
- package/starter/desert/biome.data.json +24 -12
- package/starter/desert/playerRig.ts +89 -0
- package/starter/desert/recipe.json +63 -16
- package/starter/desert/render/bakedFile.ts +17 -0
- package/starter/desert/render/benchmark.ts +79 -0
- package/starter/desert/render/biomeData.ts +14 -0
- package/starter/desert/render/biomes.ts +660 -0
- package/starter/desert/render/ground/cover.ts +565 -0
- package/starter/desert/render/ground/debris.ts +136 -0
- package/starter/desert/render/ground/horizon.ts +219 -0
- package/starter/desert/render/ground/palette.d.ts +1 -0
- package/starter/desert/render/ground/palette.js +11 -0
- package/starter/desert/render/ground/scatter.ts +104 -0
- package/starter/desert/render/ground/terrain.ts +1854 -0
- package/starter/desert/render/kitAssets.ts +28 -0
- package/starter/desert/render/loading.ts +354 -0
- package/starter/desert/render/lookKnobs.ts +37 -0
- package/starter/desert/render/orbitCamera.ts +155 -0
- package/starter/desert/render/props/farForest.ts +96 -0
- package/starter/desert/render/props/formations.ts +630 -0
- package/starter/desert/render/props/pack.ts +1195 -0
- package/starter/desert/render/props/prepared.ts +225 -0
- package/starter/desert/render/props/propMaterials.ts +1255 -0
- package/starter/desert/render/props/propProgress.ts +2 -0
- package/starter/desert/render/props/propWorld.ts +105 -0
- package/starter/desert/render/props/props.ts +624 -0
- package/starter/desert/render/props/spruce.ts +440 -0
- package/starter/desert/render/sand.ts +581 -0
- package/starter/desert/render/sky/atmosphere.ts +329 -0
- package/starter/desert/render/sky/sky.ts +382 -0
- package/starter/desert/render/texturePreparation.ts +135 -0
- package/starter/desert/render/water/river.ts +1132 -0
- package/starter/desert/render/worldNames.ts +6 -0
- package/starter/desert/scene.ts +748 -0
- package/starter/desert/sceneProps.ts +562 -0
- package/starter/desert/sceneState.ts +33 -0
- package/starter/desert/world/terrainAssets.ts +162 -0
- package/starter/desert/world/walkBand.ts +47 -0
- package/starter/desert/world/water.ts +74 -0
- package/starter/desert/worlds.ts +13 -0
- package/starter/forest/README.md +59 -116
- package/starter/forest/assets.json +14 -14
- package/starter/forest/bake.mjs +26 -4
- package/starter/forest/playerRig.ts +89 -0
- package/starter/forest/recipe.json +233 -43
- package/starter/forest/render/bakedFile.ts +17 -0
- package/starter/forest/render/benchmark.ts +77 -0
- package/starter/forest/render/biomeData.ts +14 -0
- package/starter/forest/render/biomes.ts +637 -0
- package/starter/forest/render/ground/cover.ts +565 -0
- package/starter/forest/render/ground/horizon.ts +219 -0
- package/starter/forest/render/ground/palette.d.ts +1 -0
- package/starter/forest/render/ground/palette.js +11 -0
- package/starter/forest/render/ground/scatter.ts +104 -0
- package/starter/forest/render/ground/terrain.ts +1796 -0
- package/starter/forest/render/kitAssets.ts +28 -0
- package/starter/forest/render/loading.ts +354 -0
- package/starter/forest/render/lookKnobs.ts +37 -0
- package/starter/forest/render/orbitCamera.ts +155 -0
- package/starter/forest/render/props/farForest.ts +94 -0
- package/starter/forest/render/props/pack.ts +1078 -0
- package/starter/forest/render/props/prepared.ts +226 -0
- package/starter/forest/render/props/propMaterials.ts +1247 -0
- package/starter/forest/render/props/propProgress.ts +2 -0
- package/starter/forest/render/props/propWorld.ts +105 -0
- package/starter/forest/render/props/props.ts +624 -0
- package/starter/forest/render/props/spruce.ts +440 -0
- package/starter/forest/render/sky/atmosphere.ts +329 -0
- package/starter/forest/render/sky/sky.ts +382 -0
- package/starter/forest/render/texturePreparation.ts +135 -0
- package/starter/forest/render/water/river.ts +1132 -0
- package/starter/forest/render/worldNames.ts +6 -0
- package/starter/forest/scene.ts +715 -0
- package/starter/forest/sceneProps.ts +559 -0
- package/starter/forest/sceneState.ts +33 -0
- package/starter/forest/surface.json +2 -2
- package/starter/forest/world/terrainAssets.ts +158 -0
- package/starter/forest/world/walkBand.ts +47 -0
- package/starter/forest/world/water.ts +74 -0
- package/starter/forest/worlds.ts +13 -0
- package/starter/tundra/README.md +35 -14
- package/starter/tundra/bake.mjs +14 -1
- package/starter/tundra/biome.data.json +6 -6
- package/starter/tundra/playerRig.ts +89 -0
- package/starter/tundra/recipe.json +111 -110
- package/starter/tundra/render/bakedFile.ts +17 -0
- package/starter/tundra/render/benchmark.ts +79 -0
- package/starter/tundra/render/biomeData.ts +14 -0
- package/starter/tundra/render/biomes.ts +714 -0
- package/starter/tundra/render/ground/cover.ts +565 -0
- package/starter/tundra/render/ground/horizon.ts +219 -0
- package/starter/tundra/render/ground/palette.d.ts +1 -0
- package/starter/tundra/render/ground/palette.js +11 -0
- package/starter/tundra/render/ground/scatter.ts +104 -0
- package/starter/tundra/render/ground/terrain.ts +1874 -0
- package/starter/tundra/render/kitAssets.ts +28 -0
- package/starter/tundra/render/loading.ts +354 -0
- package/starter/tundra/render/lookKnobs.ts +37 -0
- package/starter/tundra/render/orbitCamera.ts +155 -0
- package/starter/tundra/render/props/farForest.ts +96 -0
- package/starter/tundra/render/props/pack.ts +1088 -0
- package/starter/tundra/render/props/prepared.ts +225 -0
- package/starter/tundra/render/props/propMaterials.ts +1247 -0
- package/starter/tundra/render/props/propProgress.ts +2 -0
- package/starter/tundra/render/props/propWorld.ts +105 -0
- package/starter/tundra/render/props/props.ts +624 -0
- package/starter/tundra/render/props/spruce.ts +440 -0
- package/starter/tundra/render/sky/atmosphere.ts +329 -0
- package/starter/tundra/render/sky/sky.ts +382 -0
- package/starter/tundra/render/texturePreparation.ts +135 -0
- package/starter/tundra/render/water/river.ts +1132 -0
- package/starter/tundra/render/worldNames.ts +6 -0
- package/starter/tundra/scene.ts +715 -0
- package/starter/tundra/sceneProps.ts +559 -0
- package/starter/tundra/sceneState.ts +33 -0
- package/starter/tundra/world/terrainAssets.ts +159 -0
- package/starter/tundra/world/walkBand.ts +47 -0
- package/starter/tundra/world/water.ts +74 -0
- package/starter/tundra/worlds.ts +13 -0
- package/starter-assets.json +4 -4
- package/starter-credits.json +901 -15
- package/AGENT_GUIDE.md +0 -209
- package/starter/forest/sky.ts +0 -38
- package/starter/forest/water.ts +0 -257
- package/starter/forest/world.ts +0 -182
package/README.md
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
# @threenative/terrain
|
|
2
2
|
|
|
3
|
-
Optional, headless terrain authoring recovered from Strata. One seeded recipe produces
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Optional, headless terrain authoring recovered from Strata. One seeded recipe produces height and splat
|
|
4
|
+
arrays, resolved placements, baked LOD chunks and world packages. It is authoring tooling: run it in build
|
|
5
|
+
and authoring jobs, and let the game load the baked result. The game owns appearance, collision
|
|
6
|
+
registration and disposal.
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install --save-dev @threenative/terrain three
|
|
10
|
+
```
|
|
6
11
|
|
|
7
12
|
```ts
|
|
8
13
|
import { Terrain, Mask, bakeMesh } from '@threenative/terrain';
|
|
@@ -12,61 +17,37 @@ const terrain = new Terrain({ size: 512, resolution: 257, seed: 73 })
|
|
|
12
17
|
.noise({ id: 'hills', amplitude: 35 })
|
|
13
18
|
.flatten({ id: 'camp', height: 12, mask: Mask.circle([20, 30], 15) });
|
|
14
19
|
const geometry = toGeometry(bakeMesh(terrain.evaluate()));
|
|
15
|
-
// Your game creates the Mesh
|
|
20
|
+
// Your game creates the Mesh and material, and disposes the geometry.
|
|
16
21
|
```
|
|
17
22
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
and
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
The
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
Scatter placement `id` identifies the layer, unsigned seed and candidate attempt,
|
|
50
|
-
not the accepted array index. Mask/spacing changes can remove candidates without
|
|
51
|
-
retargeting surviving keys or their seeded scale/yaw. Changing a seed creates new
|
|
52
|
-
identities. Save keys rather than mesh instance indices for later authoring edits.
|
|
53
|
-
|
|
54
|
-
The authoring document may also contain `placementOverrides`, keyed by those IDs.
|
|
55
|
-
`validatePlacementOverrides()` validates finite position/quaternion/positive scale
|
|
56
|
-
and defaults omitted `grounding` to true. `applyPlacementOverrides(state, overrides)`
|
|
57
|
-
attaches each requested transform to its placement and reports retained unmatched
|
|
58
|
-
keys. `bakeTerrain()` preserves those records. The game applies grounding against
|
|
59
|
-
its actual mesh bounds and terrain triangles; disabling grounding retains measured
|
|
60
|
-
clearance. The example's Select tool uses ordinary Three.js TransformControls and
|
|
61
|
-
numeric fields, saves once per drag, and preserves newer edits on conflict.
|
|
62
|
-
|
|
63
|
-
`mountTerrainEditor` passes `(host, controller)` to `createView`. The view implements
|
|
64
|
-
`setDocument(document, revision)` for metadata changes without terrain evaluation;
|
|
65
|
-
its `update(state)` may return the resolved state for inspection and data bakes.
|
|
66
|
-
|
|
67
|
-
The example also selects stamp, paste and heightmap layers by stable ID. One proxy
|
|
68
|
-
edits recipe footprints and vertical gain/offset; its line follows the visible
|
|
69
|
-
terrain, with rebuilding on commit. X/Z rotation is disabled because a heightfield
|
|
70
|
-
cannot overhang. `stamp`/`paste` accept positive vertical `scale`; `heightmap` also
|
|
71
|
-
accepts optional metre `at`/`size`, degree `rotation` and `falloff` for a bounded
|
|
72
|
-
footprint. The original full-world heightmap path remains the default.
|
|
23
|
+
## Know this first
|
|
24
|
+
|
|
25
|
+
- Metres, Y up, X and Z from `-size/2` to `+size/2`. Degrees for rotations and slopes; placement yaw is radians.
|
|
26
|
+
- An operation records intent; `evaluate()` returns disposable arrays. Edit the recipe, not the arrays.
|
|
27
|
+
- Reusing a layer ID replaces that layer in place. `applyPatch` is atomic: a bad write keeps the previous recipe.
|
|
28
|
+
- `evaluate()` is synchronous. The root and `/three` imports carry no DOM, renderer or editor code, and
|
|
29
|
+
Three.js is a peer dependency, never a second bundled copy.
|
|
30
|
+
|
|
31
|
+
## Entry points
|
|
32
|
+
|
|
33
|
+
| Import | Use |
|
|
34
|
+
| --- | --- |
|
|
35
|
+
| `@threenative/terrain` | `Terrain`, `Mask`, `landform`, `terrainStats`, `bakeTerrain`, `makeExport`, `bakeBiome`, `bakeWorldPackage` |
|
|
36
|
+
| `/three` | `toGeometry(bakeMesh(state))`: indexed geometry from your installed Three.js |
|
|
37
|
+
| `/kit`, `/starter` | `bakeKit` for a copied starter's `bake.mjs`; `addStarterWorld` loads the baked world and its collider |
|
|
38
|
+
| `/editor`, `/editor/server` | the live editor: browser mount and the Vite plugin `terrainEditor({ documentPath })` |
|
|
39
|
+
| `/export` | `prepareWorldGLTF`: a resolved static world for `cookTerrainWorld` in `@threenative/assets` |
|
|
40
|
+
| bin `dist/mcp/server.js` | MCP tools `terrain_generate`, `terrain_biome_new`, `terrain_patch` |
|
|
41
|
+
|
|
42
|
+
Five starter worlds ship as copy-out game source in `starter/<world>/` (`forest`, `coastal`, `alpine`,
|
|
43
|
+
`desert`, `tundra`). Each folder's `README.md` says how to copy, bake and load it.
|
|
44
|
+
|
|
45
|
+
## More detail
|
|
46
|
+
|
|
47
|
+
| Read | When |
|
|
48
|
+
| --- | --- |
|
|
49
|
+
| [Authoring a recipe](docs/authoring/recipes.md) | You write or patch a recipe: operations, masks, materials, water, export formats, limits |
|
|
50
|
+
| [The live editor](docs/authoring/editor.md) | You run the editor, change its environment or assets, or save placement overrides |
|
|
51
|
+
| [A new environment](docs/authoring/new-environment.md) | You make a new biome or place on the forest kit's stack: ground, plants, look, bake |
|
|
52
|
+
| [Exporting a static world](docs/authoring/world-export.md) | You export terrain, models and water as one GLB for another project |
|
|
53
|
+
| [Source provenance](THIRD_PARTY_NOTICES.md) | You need the origin and license of the recovered Strata code |
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -8,7 +8,8 @@ no earlier copyright/license notice; no upstream license or attribution is inven
|
|
|
8
8
|
Source SHA-256:
|
|
9
9
|
|
|
10
10
|
- `strata-terrain.html`: `c0230e6891db829a5196d93ff7c9d714a8f2d964cac4722eb8ce4b2f723d794b`.
|
|
11
|
-
- `AGENT_GUIDE.md`: `487453218f870c5e829d58aea3fe9323e74ea93e0aecef8d5c329ecf56972d06`.
|
|
11
|
+
- `AGENT_GUIDE.md`: `487453218f870c5e829d58aea3fe9323e74ea93e0aecef8d5c329ecf56972d06`. Its maintained
|
|
12
|
+
content now lives in `README.md` and `docs/authoring/`.
|
|
12
13
|
|
|
13
14
|
Recovery used the HTML's named `sources` module map, rather than its duplicated
|
|
14
15
|
worker blob or minified viewer. The algorithms, validation and transactions are
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { T as Terrain } from './terrain-DYCyAOCJ.js';
|
|
2
|
+
import { e as ITerrainConfig, I as ITerrainState, j as IBakeMeshOptions, i as IBakedMesh, k as IBakeTerrainOptions, l as IBakedTerrain } from './types-kpI0C4hW.js';
|
|
3
|
+
|
|
4
|
+
type LandformKind = "alpine" | "temperateMountains" | "rollingHills" | "desertMesa" | "coastalCliffs" | "tundra" | "volcanic";
|
|
5
|
+
interface ILandformOptions extends Partial<ITerrainConfig> {
|
|
6
|
+
/** Highest minus lowest height in metres. Defaults to the kind's real ratio times `size`. */
|
|
7
|
+
relief?: number;
|
|
8
|
+
}
|
|
9
|
+
interface ILandformInfo {
|
|
10
|
+
readonly summary: string;
|
|
11
|
+
/** Default relief as a fraction of the world size. */
|
|
12
|
+
readonly reliefRatio: number;
|
|
13
|
+
/** Where the shape comes from: a public-domain DEM the repo carries, or a cited landscape. */
|
|
14
|
+
readonly reference: string;
|
|
15
|
+
/** Measured DEM statistics (5 km, 513 samples), when the repo carries that DEM; `terrainStats` fields. */
|
|
16
|
+
readonly target?: {
|
|
17
|
+
readonly slopeP50: number;
|
|
18
|
+
readonly slopeP90: number;
|
|
19
|
+
readonly hypsometricIntegral: number;
|
|
20
|
+
readonly curvatureKurtosis: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Shape-only presets. Each names its reference landscape so a calibration can be repeated; no
|
|
25
|
+
* material, colour or texture is chosen here. Targets were measured with `terrainStats` on the
|
|
26
|
+
* 1/3 arc-second USGS 3DEP crops in `examples/strata-terrain-preview/scripts/dem` (public domain).
|
|
27
|
+
*/
|
|
28
|
+
declare const LANDFORMS: Readonly<Record<LandformKind, ILandformInfo>>;
|
|
29
|
+
/**
|
|
30
|
+
* One call, one landscape: a calibrated layer recipe for a kind of environment.
|
|
31
|
+
* @requires npm i @threenative/terrain
|
|
32
|
+
* @situation start an open world, a distant backdrop or a mountain level from a kind of place
|
|
33
|
+
* @constraint returns an ordinary `Terrain`: add roads, rivers, scatter or more layers, then `evaluate()` in a build script
|
|
34
|
+
* @constraint shape only; materials, colours and textures belong to the game
|
|
35
|
+
* @constraint calibrated at size 5000, resolution 513; other sizes keep the same slopes and scale the relief with `size`
|
|
36
|
+
* @example const terrain = landform("alpine", { size: 5000, resolution: 513, seed: 4 }); const state = terrain.evaluate();
|
|
37
|
+
* @override `relief` is the highest-minus-lowest height in metres before the finishing passes shave a few percent; `size`, `resolution` and `seed` as in `Terrain`
|
|
38
|
+
*/
|
|
39
|
+
declare function landform(kind: LandformKind, options?: ILandformOptions): Terrain;
|
|
40
|
+
interface ILandformBackdrop {
|
|
41
|
+
readonly size: number;
|
|
42
|
+
readonly resolution: number;
|
|
43
|
+
/** Row-major metres, centre sample at `centerHeight`. */
|
|
44
|
+
readonly heights: Float32Array;
|
|
45
|
+
}
|
|
46
|
+
interface IBackdropOptions extends Partial<ITerrainConfig> {
|
|
47
|
+
/** Highest minus lowest height of the returned window, metres. Defaults to the kind's ratio times `size`. */
|
|
48
|
+
relief?: number;
|
|
49
|
+
/** Elevation of the centre sample, metres: the game's own ground height where the backdrop meets it. */
|
|
50
|
+
centerHeight?: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Distant mountains around a playable area: a landform window with a valley floor at its centre.
|
|
54
|
+
* @requires npm i @threenative/terrain
|
|
55
|
+
* @situation add a mountain backdrop around a playable area that the game's detail terrain covers
|
|
56
|
+
* @constraint resolution up to 513: the window is cut from a world twice as wide at the same spacing; build script only
|
|
57
|
+
* @constraint shape only; the game places, colours and fades it
|
|
58
|
+
* @example const { size, resolution, heights } = landformBackdrop("temperateMountains", { seed: 7, centerHeight: 13 });
|
|
59
|
+
* @override `relief` and `centerHeight` in metres; `size`, `resolution` and `seed` as in `landform`
|
|
60
|
+
*/
|
|
61
|
+
declare function landformBackdrop(kind: LandformKind, options?: IBackdropOptions): ILandformBackdrop;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Bakes the recovered indexed top surface and optional vertical skirts into caller-owned arrays.
|
|
65
|
+
* @requires npm i @threenative/terrain
|
|
66
|
+
* @situation bake an authored terrain into portable indexed mesh arrays
|
|
67
|
+
* @constraint no material is chosen; vertex colours exist only with a caller-supplied palette
|
|
68
|
+
* @example const mesh = bakeMesh(new Terrain({ resolution: 17 }).evaluate());
|
|
69
|
+
* @override step, chunk bounds, skirtDepth and palette belong to the caller
|
|
70
|
+
*/
|
|
71
|
+
declare function bakeMesh(state: ITerrainState, { step, x, z, cells, skirtDepth, palette, }?: IBakeMeshOptions): IBakedMesh;
|
|
72
|
+
/**
|
|
73
|
+
* Bakes finite LOD chunks, the same collision samples and resolved placements.
|
|
74
|
+
* @requires npm i @threenative/terrain
|
|
75
|
+
* @situation prepare terrain arrays and collision before a game starts
|
|
76
|
+
* @constraint collision origin is the southwest corner; engine Heightfield origin is its centre
|
|
77
|
+
* @example const baked = bakeTerrain(new Terrain({ resolution: 129 }).evaluate(), { chunkCells: 64 });
|
|
78
|
+
* @override chunkCells, lodSteps, skirtDepth and palette are explicit authoring choices
|
|
79
|
+
*/
|
|
80
|
+
declare function bakeTerrain(state: ITerrainState, { chunkCells, lodSteps, skirtDepth, palette, }?: IBakeTerrainOptions): IBakedTerrain;
|
|
81
|
+
|
|
82
|
+
export { type IBackdropOptions as I, type LandformKind as L, type ILandformBackdrop as a, bakeMesh as b, type ILandformInfo as c, type ILandformOptions as d, LANDFORMS as e, bakeTerrain as f, landformBackdrop as g, landform as l };
|
package/dist/editor/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { P as PatchCommand } from '../terrain-
|
|
2
|
-
import { L as Layer,
|
|
3
|
-
import { I as IEditorSnapshot, a as IAuthoringDocument, b as ISavedCamera, c as IFocusRequest, d as IFocusOutcome, e as IFocusBounds, f as IEnvironment, g as IEditorActivation, h as ISpatialQuery, i as ISpatialObservation, j as ICameraOperation, k as ICameraResult, l as IEnvironmentOperation, m as IEnvironmentResult, n as IAssetOperation, o as IAssetResult } from '../server-
|
|
4
|
-
export { p as IAssetAdjust, q as IAssetBounds, r as IAssetKind, s as IAssetLimits, t as ICameraPose, u as ICameraSet, v as IFocusFraming, w as IFocusResolver, x as IFocusTarget, y as IHexColour, z as IPointObservation, A as IProfileObservation, B as IProfileSample, C as IProjectAsset, D as IReferenceObservation, E as ISavedSpatialReference, F as ISpatialControlPoint, G as ISpatialReference, H as ISurfaceMapping, J as ISurfaceMappings, K as ISurfaceReading, L as checkEnvironmentAssets, M as focusCamera, N as inspectSpatial, O as probeTerrain, P as runCameraOperation, Q as runEnvironmentOperation, R as sniff, S as surfaceSpace, T as validateAsset, U as validateAssets, V as validateCamera, W as validateCameras, X as validateEnvironment, Y as validateSpatialReference, Z as validateSurfaces } from '../server-
|
|
1
|
+
import { P as PatchCommand } from '../terrain-DYCyAOCJ.js';
|
|
2
|
+
import { L as Layer, m as IPlacementOverride, I as ITerrainState } from '../types-kpI0C4hW.js';
|
|
3
|
+
import { I as IEditorSnapshot, a as IAuthoringDocument, b as ISavedCamera, c as IFocusRequest, d as IFocusOutcome, e as IFocusBounds, f as IEnvironment, g as IEditorActivation, h as ISpatialQuery, i as ISpatialObservation, j as ICameraOperation, k as ICameraResult, l as IEnvironmentOperation, m as IEnvironmentResult, n as IAssetOperation, o as IAssetResult } from '../server-LnFwY8sr.js';
|
|
4
|
+
export { p as IAssetAdjust, q as IAssetBounds, r as IAssetKind, s as IAssetLimits, t as ICameraPose, u as ICameraSet, v as IFocusFraming, w as IFocusResolver, x as IFocusTarget, y as IHexColour, z as IPointObservation, A as IProfileObservation, B as IProfileSample, C as IProjectAsset, D as IReferenceObservation, E as ISavedSpatialReference, F as ISpatialControlPoint, G as ISpatialReference, H as ISurfaceMapping, J as ISurfaceMappings, K as ISurfaceReading, L as checkEnvironmentAssets, M as focusCamera, N as inspectSpatial, O as probeTerrain, P as runCameraOperation, Q as runEnvironmentOperation, R as sniff, S as surfaceSpace, T as validateAsset, U as validateAssets, V as validateCamera, W as validateCameras, X as validateEnvironment, Y as validateSpatialReference, Z as validateSurfaces } from '../server-LnFwY8sr.js';
|
|
5
5
|
import * as three from 'three';
|
|
6
6
|
import { Quaternion, Vector3, Camera, Vector2, Object3D, Intersection, Mesh, Matrix4 } from 'three';
|
|
7
7
|
import { TransformControls } from 'three/addons/controls/TransformControls.js';
|
package/dist/editor/index.js
CHANGED
|
@@ -155,6 +155,129 @@ function splinePoints(points, step = 3, smooth = true) {
|
|
|
155
155
|
return out;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
// src/core/masks.ts
|
|
159
|
+
var MATERIAL_IDS = Object.freeze([
|
|
160
|
+
"grass",
|
|
161
|
+
"dirt",
|
|
162
|
+
"rock",
|
|
163
|
+
"snow",
|
|
164
|
+
"sand",
|
|
165
|
+
"mud",
|
|
166
|
+
"road",
|
|
167
|
+
"moss"
|
|
168
|
+
]);
|
|
169
|
+
var Mask = Object.freeze({
|
|
170
|
+
all: () => ({ type: "all" }),
|
|
171
|
+
none: () => ({ type: "none" }),
|
|
172
|
+
circle: (at, radius, softness = 0.6) => ({
|
|
173
|
+
type: "circle",
|
|
174
|
+
at,
|
|
175
|
+
radius,
|
|
176
|
+
falloff: softness
|
|
177
|
+
}),
|
|
178
|
+
rectangle: (at, size, rotation = 0, softness = 0.2) => ({ type: "rectangle", at, size, rotation, falloff: softness }),
|
|
179
|
+
height: (min = -1e9, max = 1e9, fade = 0) => ({ type: "height", min, max, fade }),
|
|
180
|
+
slope: (min = 0, max = 90, fade = 0) => ({ type: "slope", min, max, fade }),
|
|
181
|
+
noise: (scale2 = 80, threshold = 0.5, seed = 1, fade = 0.15) => ({
|
|
182
|
+
type: "noise",
|
|
183
|
+
scale: scale2,
|
|
184
|
+
threshold,
|
|
185
|
+
seed,
|
|
186
|
+
fade
|
|
187
|
+
}),
|
|
188
|
+
biome: (name) => ({ type: "biome", name }),
|
|
189
|
+
material: (name) => ({ type: "material", name }),
|
|
190
|
+
and: (...masks) => ({ type: "and", masks }),
|
|
191
|
+
or: (...masks) => ({ type: "or", masks }),
|
|
192
|
+
not: (mask) => ({ type: "not", mask })
|
|
193
|
+
});
|
|
194
|
+
var range = (v, min, max, fade = 0) => fade > 0 ? smoothstep(min - fade, min, v) * (1 - smoothstep(max, max + fade, v)) : Number(v >= min && v <= max);
|
|
195
|
+
function compileMask(mask, s) {
|
|
196
|
+
if (!mask || mask.type === "all") return () => 1;
|
|
197
|
+
switch (mask.type) {
|
|
198
|
+
case "none":
|
|
199
|
+
return () => 0;
|
|
200
|
+
case "circle": {
|
|
201
|
+
const centre = mask.at;
|
|
202
|
+
return (i, x, z) => falloff(
|
|
203
|
+
Math.hypot(x - centre[0], z - centre[1]),
|
|
204
|
+
mask.radius,
|
|
205
|
+
mask.falloff ?? 0.6
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
case "rectangle": {
|
|
209
|
+
const centre = mask.at;
|
|
210
|
+
const rad = (mask.rotation ?? 0) * Math.PI / 180;
|
|
211
|
+
const c = Math.cos(rad);
|
|
212
|
+
const sn = Math.sin(rad);
|
|
213
|
+
const size = Array.isArray(mask.size) ? mask.size : [mask.size, mask.size];
|
|
214
|
+
return (i, x, z) => {
|
|
215
|
+
const dx = x - centre[0];
|
|
216
|
+
const dz = z - centre[1];
|
|
217
|
+
return falloff(
|
|
218
|
+
Math.max(
|
|
219
|
+
Math.abs(dx * c + dz * sn) / (size[0] / 2),
|
|
220
|
+
Math.abs(-dx * sn + dz * c) / (size[1] / 2)
|
|
221
|
+
),
|
|
222
|
+
1,
|
|
223
|
+
mask.falloff ?? 0.2
|
|
224
|
+
);
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
case "height":
|
|
228
|
+
return (i) => range(s.height[i], mask.min ?? -1e9, mask.max ?? 1e9, mask.fade);
|
|
229
|
+
case "slope":
|
|
230
|
+
return (i) => range(slopeAtIndex(s, i), mask.min ?? 0, mask.max ?? 90, mask.fade);
|
|
231
|
+
case "noise":
|
|
232
|
+
return (i, x, z) => smoothstep(
|
|
233
|
+
(mask.threshold ?? 0.5) - (mask.fade ?? 0.15),
|
|
234
|
+
(mask.threshold ?? 0.5) + (mask.fade ?? 0.15),
|
|
235
|
+
noise2(x / mask.scale, z / mask.scale, mask.seed ?? s.seed) * 0.5 + 0.5
|
|
236
|
+
);
|
|
237
|
+
case "biome": {
|
|
238
|
+
const field3 = s.biomes[mask.name];
|
|
239
|
+
return (i) => field3?.[i] ?? 0;
|
|
240
|
+
}
|
|
241
|
+
case "material": {
|
|
242
|
+
const channel = MATERIAL_IDS.indexOf(mask.name);
|
|
243
|
+
if (channel < 0) throw Error(`Unknown material: ${String(mask.name)}`);
|
|
244
|
+
return (i) => s.splat[i * 8 + channel];
|
|
245
|
+
}
|
|
246
|
+
case "not": {
|
|
247
|
+
const inner = compileMask(mask.mask, s);
|
|
248
|
+
return (i, x, z) => 1 - inner(i, x, z);
|
|
249
|
+
}
|
|
250
|
+
case "and": {
|
|
251
|
+
const inner = (mask.masks ?? []).map((entry) => compileMask(entry, s));
|
|
252
|
+
return (i, x, z) => inner.reduce((value, sample) => value * sample(i, x, z), 1);
|
|
253
|
+
}
|
|
254
|
+
case "or": {
|
|
255
|
+
const inner = (mask.masks ?? []).map((entry) => compileMask(entry, s));
|
|
256
|
+
return (i, x, z) => 1 - inner.reduce((value, sample) => value * (1 - sample(i, x, z)), 1);
|
|
257
|
+
}
|
|
258
|
+
default:
|
|
259
|
+
throw Error(`Unknown mask: ${String(mask.type)}`);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function rasterMask(mask, s) {
|
|
263
|
+
if (!mask || mask.type === "all") return null;
|
|
264
|
+
const out = new Float32Array(s.height.length);
|
|
265
|
+
const sample = compileMask(mask, s);
|
|
266
|
+
for (let z = 0; z < s.resolution; z += 1) {
|
|
267
|
+
for (let x = 0; x < s.resolution; x += 1) {
|
|
268
|
+
const i = z * s.resolution + x;
|
|
269
|
+
out[i] = clamp(sample(i, world(s, x), world(s, z)));
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return out;
|
|
273
|
+
}
|
|
274
|
+
function paintWeights(s, i, channel, weight) {
|
|
275
|
+
const w = clamp(weight);
|
|
276
|
+
const base = i * 8;
|
|
277
|
+
for (let c = 0; c < 8; c += 1)
|
|
278
|
+
s.splat[base + c] = s.splat[base + c] * (1 - w) + (c === channel ? w : 0);
|
|
279
|
+
}
|
|
280
|
+
|
|
158
281
|
// src/core/erosion.ts
|
|
159
282
|
function thermal(height, n, size, { iterations = 20, talus = 32, rate = 0.22 } = {}, observations) {
|
|
160
283
|
if (!Number.isInteger(n) || n < 2)
|
|
@@ -781,129 +904,6 @@ function gully(height, n, size, { iterations = 200, capacity = 0.05, rain = 5e-4
|
|
|
781
904
|
return Float32Array.from(h, (surface, i) => surface + sediment[i]);
|
|
782
905
|
}
|
|
783
906
|
|
|
784
|
-
// src/core/masks.ts
|
|
785
|
-
var MATERIAL_IDS = Object.freeze([
|
|
786
|
-
"grass",
|
|
787
|
-
"dirt",
|
|
788
|
-
"rock",
|
|
789
|
-
"snow",
|
|
790
|
-
"sand",
|
|
791
|
-
"mud",
|
|
792
|
-
"road",
|
|
793
|
-
"moss"
|
|
794
|
-
]);
|
|
795
|
-
var Mask = Object.freeze({
|
|
796
|
-
all: () => ({ type: "all" }),
|
|
797
|
-
none: () => ({ type: "none" }),
|
|
798
|
-
circle: (at, radius, softness = 0.6) => ({
|
|
799
|
-
type: "circle",
|
|
800
|
-
at,
|
|
801
|
-
radius,
|
|
802
|
-
falloff: softness
|
|
803
|
-
}),
|
|
804
|
-
rectangle: (at, size, rotation = 0, softness = 0.2) => ({ type: "rectangle", at, size, rotation, falloff: softness }),
|
|
805
|
-
height: (min = -1e9, max = 1e9, fade = 0) => ({ type: "height", min, max, fade }),
|
|
806
|
-
slope: (min = 0, max = 90, fade = 0) => ({ type: "slope", min, max, fade }),
|
|
807
|
-
noise: (scale2 = 80, threshold = 0.5, seed = 1, fade = 0.15) => ({
|
|
808
|
-
type: "noise",
|
|
809
|
-
scale: scale2,
|
|
810
|
-
threshold,
|
|
811
|
-
seed,
|
|
812
|
-
fade
|
|
813
|
-
}),
|
|
814
|
-
biome: (name) => ({ type: "biome", name }),
|
|
815
|
-
material: (name) => ({ type: "material", name }),
|
|
816
|
-
and: (...masks) => ({ type: "and", masks }),
|
|
817
|
-
or: (...masks) => ({ type: "or", masks }),
|
|
818
|
-
not: (mask) => ({ type: "not", mask })
|
|
819
|
-
});
|
|
820
|
-
var range = (v, min, max, fade = 0) => fade > 0 ? smoothstep(min - fade, min, v) * (1 - smoothstep(max, max + fade, v)) : Number(v >= min && v <= max);
|
|
821
|
-
function compileMask(mask, s) {
|
|
822
|
-
if (!mask || mask.type === "all") return () => 1;
|
|
823
|
-
switch (mask.type) {
|
|
824
|
-
case "none":
|
|
825
|
-
return () => 0;
|
|
826
|
-
case "circle": {
|
|
827
|
-
const centre = mask.at;
|
|
828
|
-
return (i, x, z) => falloff(
|
|
829
|
-
Math.hypot(x - centre[0], z - centre[1]),
|
|
830
|
-
mask.radius,
|
|
831
|
-
mask.falloff ?? 0.6
|
|
832
|
-
);
|
|
833
|
-
}
|
|
834
|
-
case "rectangle": {
|
|
835
|
-
const centre = mask.at;
|
|
836
|
-
const rad = (mask.rotation ?? 0) * Math.PI / 180;
|
|
837
|
-
const c = Math.cos(rad);
|
|
838
|
-
const sn = Math.sin(rad);
|
|
839
|
-
const size = Array.isArray(mask.size) ? mask.size : [mask.size, mask.size];
|
|
840
|
-
return (i, x, z) => {
|
|
841
|
-
const dx = x - centre[0];
|
|
842
|
-
const dz = z - centre[1];
|
|
843
|
-
return falloff(
|
|
844
|
-
Math.max(
|
|
845
|
-
Math.abs(dx * c + dz * sn) / (size[0] / 2),
|
|
846
|
-
Math.abs(-dx * sn + dz * c) / (size[1] / 2)
|
|
847
|
-
),
|
|
848
|
-
1,
|
|
849
|
-
mask.falloff ?? 0.2
|
|
850
|
-
);
|
|
851
|
-
};
|
|
852
|
-
}
|
|
853
|
-
case "height":
|
|
854
|
-
return (i) => range(s.height[i], mask.min ?? -1e9, mask.max ?? 1e9, mask.fade);
|
|
855
|
-
case "slope":
|
|
856
|
-
return (i) => range(slopeAtIndex(s, i), mask.min ?? 0, mask.max ?? 90, mask.fade);
|
|
857
|
-
case "noise":
|
|
858
|
-
return (i, x, z) => smoothstep(
|
|
859
|
-
(mask.threshold ?? 0.5) - (mask.fade ?? 0.15),
|
|
860
|
-
(mask.threshold ?? 0.5) + (mask.fade ?? 0.15),
|
|
861
|
-
noise2(x / mask.scale, z / mask.scale, mask.seed ?? s.seed) * 0.5 + 0.5
|
|
862
|
-
);
|
|
863
|
-
case "biome": {
|
|
864
|
-
const field3 = s.biomes[mask.name];
|
|
865
|
-
return (i) => field3?.[i] ?? 0;
|
|
866
|
-
}
|
|
867
|
-
case "material": {
|
|
868
|
-
const channel = MATERIAL_IDS.indexOf(mask.name);
|
|
869
|
-
if (channel < 0) throw Error(`Unknown material: ${String(mask.name)}`);
|
|
870
|
-
return (i) => s.splat[i * 8 + channel];
|
|
871
|
-
}
|
|
872
|
-
case "not": {
|
|
873
|
-
const inner = compileMask(mask.mask, s);
|
|
874
|
-
return (i, x, z) => 1 - inner(i, x, z);
|
|
875
|
-
}
|
|
876
|
-
case "and": {
|
|
877
|
-
const inner = (mask.masks ?? []).map((entry) => compileMask(entry, s));
|
|
878
|
-
return (i, x, z) => inner.reduce((value, sample) => value * sample(i, x, z), 1);
|
|
879
|
-
}
|
|
880
|
-
case "or": {
|
|
881
|
-
const inner = (mask.masks ?? []).map((entry) => compileMask(entry, s));
|
|
882
|
-
return (i, x, z) => 1 - inner.reduce((value, sample) => value * (1 - sample(i, x, z)), 1);
|
|
883
|
-
}
|
|
884
|
-
default:
|
|
885
|
-
throw Error(`Unknown mask: ${String(mask.type)}`);
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
function rasterMask(mask, s) {
|
|
889
|
-
if (!mask || mask.type === "all") return null;
|
|
890
|
-
const out = new Float32Array(s.height.length);
|
|
891
|
-
const sample = compileMask(mask, s);
|
|
892
|
-
for (let z = 0; z < s.resolution; z += 1) {
|
|
893
|
-
for (let x = 0; x < s.resolution; x += 1) {
|
|
894
|
-
const i = z * s.resolution + x;
|
|
895
|
-
out[i] = clamp(sample(i, world(s, x), world(s, z)));
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
return out;
|
|
899
|
-
}
|
|
900
|
-
function paintWeights(s, i, channel, weight) {
|
|
901
|
-
const w = clamp(weight);
|
|
902
|
-
const base = i * 8;
|
|
903
|
-
for (let c = 0; c < 8; c += 1)
|
|
904
|
-
s.splat[base + c] = s.splat[base + c] * (1 - w) + (c === channel ? w : 0);
|
|
905
|
-
}
|
|
906
|
-
|
|
907
907
|
// src/core/scree.ts
|
|
908
908
|
var NEIGHBOURS = [
|
|
909
909
|
[-1, -1],
|
|
@@ -2525,7 +2525,7 @@ var Terrain = class _Terrain {
|
|
|
2525
2525
|
}
|
|
2526
2526
|
};
|
|
2527
2527
|
|
|
2528
|
-
// src/
|
|
2528
|
+
// src/package/bake.ts
|
|
2529
2529
|
var toLinear = (color) => color <= 0.04045 ? color / 12.92 : ((color + 0.055) / 1.055) ** 2.4;
|
|
2530
2530
|
function bakeMesh(state, {
|
|
2531
2531
|
step = 1,
|
|
@@ -2675,7 +2675,7 @@ function validateBakedMesh(mesh) {
|
|
|
2675
2675
|
throw new RangeError("Baked mesh index outside vertex range");
|
|
2676
2676
|
}
|
|
2677
2677
|
|
|
2678
|
-
// src/
|
|
2678
|
+
// src/population/placements.ts
|
|
2679
2679
|
function validatePlacementOverrides(value = {}) {
|
|
2680
2680
|
finiteTree(value, "placementOverrides");
|
|
2681
2681
|
if (!value || typeof value !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
|
|
@@ -3021,7 +3021,7 @@ function encodeGLB(input) {
|
|
|
3021
3021
|
}
|
|
3022
3022
|
const binary = join(chunks);
|
|
3023
3023
|
const doc = {
|
|
3024
|
-
asset: { version: "2.0", generator: "@threenative/terrain 0.1.
|
|
3024
|
+
asset: { version: "2.0", generator: "@threenative/terrain 0.1.12" },
|
|
3025
3025
|
scene: 0,
|
|
3026
3026
|
scenes: [{ nodes: meshes.map((_, i) => i) }],
|
|
3027
3027
|
nodes: meshes.map((m, i) => ({ mesh: i, name: m.name ?? `Terrain ${i}` })),
|
|
@@ -3049,7 +3049,7 @@ function encodeGLB(input) {
|
|
|
3049
3049
|
return out;
|
|
3050
3050
|
}
|
|
3051
3051
|
|
|
3052
|
-
// src/
|
|
3052
|
+
// src/package/export.ts
|
|
3053
3053
|
var enc = new TextEncoder();
|
|
3054
3054
|
var table = Uint32Array.from({ length: 256 }, (_, initial) => {
|
|
3055
3055
|
let n = initial;
|
|
@@ -6300,7 +6300,9 @@ function appendShellDialogs(parent) {
|
|
|
6300
6300
|
shellElement(n22, "br");
|
|
6301
6301
|
n22.appendChild(document.createTextNode("Agent instructions: "));
|
|
6302
6302
|
const n27 = shellElement(n22, "code");
|
|
6303
|
-
n27.appendChild(
|
|
6303
|
+
n27.appendChild(
|
|
6304
|
+
document.createTextNode("node_modules/@threenative/terrain/docs/authoring/editor.md")
|
|
6305
|
+
);
|
|
6304
6306
|
const n28 = shellElement(n1, "div", { class: "dialog-footer" });
|
|
6305
6307
|
const n29 = shellElement(n28, "button", { id: "copy-recipe", class: "ghost" });
|
|
6306
6308
|
shellElement(n29, "span", { "data-icon": "copy" });
|
package/dist/editor/server.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import 'vite';
|
|
2
|
-
import '../types-
|
|
3
|
-
export { a as IAuthoringDocument, g as IEditorActivation, I as IEditorSnapshot, _ as TerrainEditorDocument, $ as terrainEditor } from '../server-
|
|
2
|
+
import '../types-kpI0C4hW.js';
|
|
3
|
+
export { a as IAuthoringDocument, g as IEditorActivation, I as IEditorSnapshot, _ as TerrainEditorDocument, $ as terrainEditor } from '../server-LnFwY8sr.js';
|
package/dist/editor/server.js
CHANGED
|
@@ -2,6 +2,7 @@ import { randomUUID, createHash } from 'crypto';
|
|
|
2
2
|
import { lstatSync, readFileSync, writeFileSync, renameSync, unlinkSync, watchFile, unwatchFile, openSync, fstatSync, readSync, closeSync, mkdirSync, existsSync } from 'fs';
|
|
3
3
|
import { isAbsolute, resolve, dirname, basename, join } from 'path';
|
|
4
4
|
import 'fs/promises';
|
|
5
|
+
import 'os';
|
|
5
6
|
import { pathToFileURL } from 'url';
|
|
6
7
|
import { Vector3, Matrix4, Quaternion } from 'three';
|
|
7
8
|
|
|
@@ -2128,41 +2129,6 @@ function validateDocument(doc) {
|
|
|
2128
2129
|
}
|
|
2129
2130
|
}
|
|
2130
2131
|
|
|
2131
|
-
// src/core/placements.ts
|
|
2132
|
-
function validatePlacementOverrides(value = {}) {
|
|
2133
|
-
finiteTree(value, "placementOverrides");
|
|
2134
|
-
if (!value || typeof value !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
|
|
2135
|
-
throw new Error("Expected placementOverrides object");
|
|
2136
|
-
return Object.fromEntries(
|
|
2137
|
-
Object.entries(value).map(([key, entry]) => {
|
|
2138
|
-
if (!key.length || key.length > 256)
|
|
2139
|
-
throw new Error("Placement key must contain 1\u2013256 characters");
|
|
2140
|
-
if (!entry || typeof entry !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(entry)))
|
|
2141
|
-
throw new Error(`Invalid placement override '${key}'`);
|
|
2142
|
-
const input = entry;
|
|
2143
|
-
if (Object.keys(input).some(
|
|
2144
|
-
(field2) => !["position", "quaternion", "scale", "grounding"].includes(field2)
|
|
2145
|
-
))
|
|
2146
|
-
throw new Error(`Unknown placement override fields '${key}'`);
|
|
2147
|
-
function vector2(field2, length) {
|
|
2148
|
-
const values = input[field2];
|
|
2149
|
-
if (!Array.isArray(values) || values.length !== length || !Array.from(values).every(Number.isFinite))
|
|
2150
|
-
throw new Error(`${key}.${field2} must contain ${length} finite numbers`);
|
|
2151
|
-
return Array.from(values);
|
|
2152
|
-
}
|
|
2153
|
-
const position = vector2("position", 3);
|
|
2154
|
-
const quaternion = vector2("quaternion", 4);
|
|
2155
|
-
const scale2 = vector2("scale", 3);
|
|
2156
|
-
if (scale2.some((item) => item <= 0)) throw new Error(`${key}.scale must be positive`);
|
|
2157
|
-
if (Math.abs(Math.hypot(...quaternion) - 1) > 1e-6)
|
|
2158
|
-
throw new Error(`${key}.quaternion must be a unit quaternion`);
|
|
2159
|
-
const grounding = input.grounding === void 0 ? true : input.grounding;
|
|
2160
|
-
if (typeof grounding !== "boolean") throw new Error(`${key}.grounding must be boolean`);
|
|
2161
|
-
return [key, { position, quaternion, scale: scale2, grounding }];
|
|
2162
|
-
})
|
|
2163
|
-
);
|
|
2164
|
-
}
|
|
2165
|
-
|
|
2166
2132
|
// src/core/terrain.ts
|
|
2167
2133
|
var TerrainEvaluator = class {
|
|
2168
2134
|
cache = /* @__PURE__ */ new Map();
|
|
@@ -2541,6 +2507,43 @@ var Terrain = class _Terrain {
|
|
|
2541
2507
|
return this._operation("paste", options);
|
|
2542
2508
|
}
|
|
2543
2509
|
};
|
|
2510
|
+
|
|
2511
|
+
// src/population/placements.ts
|
|
2512
|
+
function validatePlacementOverrides(value = {}) {
|
|
2513
|
+
finiteTree(value, "placementOverrides");
|
|
2514
|
+
if (!value || typeof value !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
|
|
2515
|
+
throw new Error("Expected placementOverrides object");
|
|
2516
|
+
return Object.fromEntries(
|
|
2517
|
+
Object.entries(value).map(([key, entry]) => {
|
|
2518
|
+
if (!key.length || key.length > 256)
|
|
2519
|
+
throw new Error("Placement key must contain 1\u2013256 characters");
|
|
2520
|
+
if (!entry || typeof entry !== "object" || ![Object.prototype, null].includes(Object.getPrototypeOf(entry)))
|
|
2521
|
+
throw new Error(`Invalid placement override '${key}'`);
|
|
2522
|
+
const input = entry;
|
|
2523
|
+
if (Object.keys(input).some(
|
|
2524
|
+
(field2) => !["position", "quaternion", "scale", "grounding"].includes(field2)
|
|
2525
|
+
))
|
|
2526
|
+
throw new Error(`Unknown placement override fields '${key}'`);
|
|
2527
|
+
function vector2(field2, length) {
|
|
2528
|
+
const values = input[field2];
|
|
2529
|
+
if (!Array.isArray(values) || values.length !== length || !Array.from(values).every(Number.isFinite))
|
|
2530
|
+
throw new Error(`${key}.${field2} must contain ${length} finite numbers`);
|
|
2531
|
+
return Array.from(values);
|
|
2532
|
+
}
|
|
2533
|
+
const position = vector2("position", 3);
|
|
2534
|
+
const quaternion = vector2("quaternion", 4);
|
|
2535
|
+
const scale2 = vector2("scale", 3);
|
|
2536
|
+
if (scale2.some((item) => item <= 0)) throw new Error(`${key}.scale must be positive`);
|
|
2537
|
+
if (Math.abs(Math.hypot(...quaternion) - 1) > 1e-6)
|
|
2538
|
+
throw new Error(`${key}.quaternion must be a unit quaternion`);
|
|
2539
|
+
const grounding = input.grounding === void 0 ? true : input.grounding;
|
|
2540
|
+
if (typeof grounding !== "boolean") throw new Error(`${key}.grounding must be boolean`);
|
|
2541
|
+
return [key, { position, quaternion, scale: scale2, grounding }];
|
|
2542
|
+
})
|
|
2543
|
+
);
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2546
|
+
// src/cook/cook.ts
|
|
2544
2547
|
var MISSING_ASSETS = "terrain_generate needs @threenative/assets in the game project. Run: npm i -D @threenative/assets";
|
|
2545
2548
|
function installedEntry(projectRoot, name) {
|
|
2546
2549
|
let directory = resolve(projectRoot);
|
package/dist/editor/worker.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as ITerrainState, a as IExportArchive, b as ITerrainDocument, E as ExportKind } from '../types-
|
|
1
|
+
import { I as ITerrainState, a as IExportArchive, b as ITerrainDocument, E as ExportKind } from '../types-kpI0C4hW.js';
|
|
2
2
|
|
|
3
3
|
interface IWorkerRequest {
|
|
4
4
|
id: number;
|