@threenative/terrain 0.1.11 → 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 +1 -0
- package/dist/bake-DJ5cxg0C.d.ts +82 -0
- package/dist/editor/index.d.ts +4 -4
- package/dist/editor/index.js +1 -1
- package/dist/editor/server.d.ts +2 -2
- package/dist/editor/worker.d.ts +1 -1
- package/dist/editor/worker.js +1 -1
- package/dist/export.d.ts +1 -1
- package/dist/index.d.ts +51 -222
- package/dist/index.js +111 -2
- 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 +19 -4
- package/dist/mcp/cook-child.js +9 -6
- package/dist/mcp/server.js +14 -4
- 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 +1141 -6
- package/dist/starter.js +1999 -17
- package/dist/{terrain-CAEaW0mQ.d.ts → terrain-DYCyAOCJ.d.ts} +1 -1
- package/dist/three.d.ts +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/new-environment.md +97 -0
- package/package.json +8 -8
- package/starter/alpine/README.md +22 -14
- 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/coastal/README.md +26 -27
- 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 -25
- 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 +8 -5
- package/starter/forest/bake.mjs +21 -413
- package/starter/forest/playerRig.ts +37 -171
- package/starter/forest/recipe.json +237 -47
- package/starter/forest/render/biomes.ts +2 -1
- package/starter/forest/render/ground/horizon.ts +4 -302
- package/starter/forest/render/ground/terrain.ts +14 -32
- package/starter/forest/render/kitAssets.ts +3 -2
- package/starter/forest/render/props/farForest.ts +2 -1
- package/starter/forest/render/props/pack.ts +4 -2
- package/starter/forest/render/props/prepared.ts +2 -1
- package/starter/forest/render/props/propProgress.ts +1 -11
- package/starter/forest/render/props/propWorld.ts +48 -662
- package/starter/forest/render/props/props.ts +64 -248
- package/starter/forest/render/sky/sky.ts +2 -1
- package/starter/forest/render/worldNames.ts +6 -2
- package/starter/forest/scene.ts +34 -25
- package/starter/forest/sceneProps.ts +2 -2
- package/starter/forest/sceneState.ts +5 -4
- package/starter/forest/surface.json +2 -2
- package/starter/forest/worlds.ts +3 -2
- package/starter/tundra/README.md +35 -16
- 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 +613 -10
- package/starter/forest/diagnostics.ts +0 -1020
- package/starter/forest/render/sky/skyVisibility.ts +0 -121
- package/starter/forest/spawnGate.ts +0 -183
- package/starter/forest/viewStatistics.ts +0 -47
- package/starter/forest/world/streamedGround.ts +0 -139
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// The forest's prop worlds: the bake's containers, the meadow the game plants at load, and the
|
|
2
|
+
// terminal gate this kit gives its spruces. The container loop, the record poses and the loaders
|
|
3
|
+
// live in `@threenative/terrain/starter`; this file supplies the rows that make them the forest's.
|
|
4
|
+
import type { IAssetLoader } from "@threenative/core";
|
|
5
|
+
import type { IShadowRegion, IWorldCellsFollow } from "@threenative/core/world";
|
|
6
|
+
import type { IPlacement, IPropBucketPackage, IPropPackage } from "@threenative/terrain";
|
|
7
|
+
import {
|
|
8
|
+
type IPropWorldOptions as IPackagePropWorldOptions,
|
|
9
|
+
type IPropPreparationProgress,
|
|
10
|
+
type IScatter,
|
|
11
|
+
invalidatePropShadows,
|
|
12
|
+
loadCanopy,
|
|
13
|
+
loadPropPackage,
|
|
14
|
+
loadSky,
|
|
15
|
+
propCounts as propCountsIn,
|
|
16
|
+
streamProps as streamPropsIn,
|
|
17
|
+
} from "@threenative/terrain/starter";
|
|
18
|
+
import type { Box3 } from "three";
|
|
19
|
+
import { FAR_FOREST_IMPOSTOR, FAR_FOREST_LAYER } from "./farForest.js";
|
|
20
|
+
import { standShaded } from "./propMaterials.js";
|
|
21
|
+
import {
|
|
22
|
+
GROUND_RULES,
|
|
23
|
+
type IPropMaterials,
|
|
24
|
+
type IPropPart,
|
|
25
|
+
LOD_BANDS,
|
|
26
|
+
NO_SHADOW_ASSETS,
|
|
27
|
+
PROP_ASSETS,
|
|
28
|
+
type PropGroundQuery,
|
|
29
|
+
lodSteps,
|
|
30
|
+
streamedBucket,
|
|
31
|
+
streamedReach,
|
|
32
|
+
variantFor,
|
|
33
|
+
} from "./props.js";
|
|
34
|
+
|
|
35
|
+
export interface IPropWorldOptions {
|
|
36
|
+
/** The baked package, one streamed world per bucket. May be empty when every placement is live. */
|
|
37
|
+
readonly package?: IPropPackage;
|
|
38
|
+
/**
|
|
39
|
+
* Placements the caller holds live, compiled here through `@threenative/terrain`.
|
|
40
|
+
*
|
|
41
|
+
* The game plants none: its records come from the bake. The editor compiles the placements it is
|
|
42
|
+
* editing, and a script that proves one pose compiles the one it built.
|
|
43
|
+
*/
|
|
44
|
+
readonly placements?: readonly IPlacement[];
|
|
45
|
+
/** Which baked buckets this run keeps; the query flags answer it. Every bucket by default. */
|
|
46
|
+
readonly buckets?: (bucket: IPropBucketPackage) => boolean;
|
|
47
|
+
readonly groundAt: PropGroundQuery;
|
|
48
|
+
readonly parts: Map<string, IPropPart[]>;
|
|
49
|
+
readonly materials: IPropMaterials;
|
|
50
|
+
readonly follow: IWorldCellsFollow;
|
|
51
|
+
/** The world square the bake packaged; live placements use its bounds too. */
|
|
52
|
+
readonly size: number;
|
|
53
|
+
readonly horizonDistance?: number;
|
|
54
|
+
readonly castShadows?: boolean;
|
|
55
|
+
/** The biome row's `standShade`: the tint a spruce takes where no sun shadow is drawn on it. */
|
|
56
|
+
readonly standShade?: readonly [number, number, number];
|
|
57
|
+
/** The sun's outer shadow window, metres; a local spruce takes `standShade` past it. */
|
|
58
|
+
readonly shadowReach?: number;
|
|
59
|
+
readonly bundles?: boolean;
|
|
60
|
+
readonly assets?: IAssetLoader;
|
|
61
|
+
readonly whileCurrent: () => boolean;
|
|
62
|
+
readonly invalidateShadows?: (region?: IShadowRegion) => void;
|
|
63
|
+
readonly onProgress?: (progress: IPropPreparationProgress) => void;
|
|
64
|
+
readonly onPublication?: (bounds: Box3) => void;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Load the prop worlds, pose every record on the ground, and hand each bucket to `WorldCells`.
|
|
69
|
+
*
|
|
70
|
+
* The passes are short and yield between slices, because the whole point of streaming is that the
|
|
71
|
+
* first frame does not wait for 200 000 records: the records are decoded and grounded in slices, and
|
|
72
|
+
* each bucket loads as its own world.
|
|
73
|
+
*/
|
|
74
|
+
export async function streamProps(options: IPropWorldOptions) {
|
|
75
|
+
const packageOptions: IPackagePropWorldOptions = {
|
|
76
|
+
...options,
|
|
77
|
+
groundRules: GROUND_RULES,
|
|
78
|
+
surface: options.materials.bark,
|
|
79
|
+
materials: { ...options.materials },
|
|
80
|
+
variantOf: (placement) => variantFor(placement, placement.asset),
|
|
81
|
+
reachOf: streamedReach,
|
|
82
|
+
bucketOf: (placement, reach) => ({
|
|
83
|
+
name: streamedBucket(placement, reach),
|
|
84
|
+
kind: placement.layer === FAR_FOREST_LAYER ? "far" : "local",
|
|
85
|
+
shadows: !NO_SHADOW_ASSETS.has(placement.asset),
|
|
86
|
+
}),
|
|
87
|
+
lodOf: lodSteps,
|
|
88
|
+
lodHysteresis: LOD_BANDS.hysteresis,
|
|
89
|
+
lodFar: LOD_BANDS.far,
|
|
90
|
+
assetNames: Object.keys(PROP_ASSETS),
|
|
91
|
+
gateAsset: "spruce",
|
|
92
|
+
gateFarDistance: FAR_FOREST_IMPOSTOR,
|
|
93
|
+
shadeStand: standShaded,
|
|
94
|
+
shadowsOf: (bucket) => bucket.bucket.endsWith(":true"),
|
|
95
|
+
};
|
|
96
|
+
return streamPropsIn(packageOptions);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Records per asset across the package's buckets: what the run report calls the scatter's counts. */
|
|
100
|
+
export function propCounts(pkg: IPropPackage): Record<string, number> {
|
|
101
|
+
return propCountsIn(pkg, Object.keys(PROP_ASSETS));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { invalidatePropShadows, loadCanopy, loadPropPackage, loadSky };
|
|
105
|
+
export type { IScatter, IPropPreparationProgress };
|