@threenative/terrain 0.1.11 → 0.1.13
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
|
@@ -5,16 +5,24 @@
|
|
|
5
5
|
//
|
|
6
6
|
// - The shapes, their variants, their materials and their placement rule are all this file's. They
|
|
7
7
|
// are the picture, and the picture is the game's (AGENTS rule 3).
|
|
8
|
-
// -
|
|
9
|
-
|
|
8
|
+
// - The pose's own steps (snap, burial, footprint, base ring) are the package's `prop-pose`; this
|
|
9
|
+
// file supplies the forest's `GROUND_RULES` rows and `propWorld.ts` delegates LOD to WorldCells.
|
|
10
|
+
import { staticLowestY } from "@threenative/core/world";
|
|
10
11
|
import type { IPlacement, IPlacementOverride } from "@threenative/terrain";
|
|
12
|
+
import {
|
|
13
|
+
type IPropGroundRules,
|
|
14
|
+
type IPropInstance,
|
|
15
|
+
type IPropPoseOverride,
|
|
16
|
+
type PropGroundQuery,
|
|
17
|
+
preparePose as preparePoseIn,
|
|
18
|
+
preparePropTransform as preparePropTransformIn,
|
|
19
|
+
propKey as propKeyIn,
|
|
20
|
+
} from "@threenative/terrain/starter";
|
|
11
21
|
import {
|
|
12
22
|
type BufferGeometry,
|
|
13
23
|
DoubleSide,
|
|
14
24
|
type Material,
|
|
15
|
-
Matrix4,
|
|
16
25
|
MeshStandardMaterial,
|
|
17
|
-
Quaternion,
|
|
18
26
|
Vector3,
|
|
19
27
|
} from "three";
|
|
20
28
|
import { WILDFLOWER, boulder, fernClump, grassClump, poppyCluster } from "../ground/cover.js";
|
|
@@ -463,272 +471,80 @@ export const PROP_ASSETS: Record<string, number> = Object.fromEntries(
|
|
|
463
471
|
Object.entries(PROP_COUNTS).filter(([name]) => name !== "seed"),
|
|
464
472
|
);
|
|
465
473
|
|
|
466
|
-
export type PropGroundQuery = (
|
|
467
|
-
placement: IPlacement,
|
|
468
|
-
position: [number, number, number],
|
|
469
|
-
) => { height: number | null; offset: number };
|
|
470
|
-
export interface IPropInstance {
|
|
471
|
-
material: Material;
|
|
472
|
-
onTransform?: (transform: IPlacementOverride | undefined) => void;
|
|
473
|
-
placement: IPlacement;
|
|
474
|
-
pose: Matrix4;
|
|
475
|
-
geometry: BufferGeometry;
|
|
476
|
-
grounding: boolean;
|
|
477
|
-
clearance: number | null;
|
|
478
|
-
cragBaseClearance?: number;
|
|
479
|
-
cragRingSamples?: number;
|
|
480
|
-
}
|
|
481
474
|
/** Exact lowest world Y of a static geometry under `matrix`: core `staticLowestY`. */
|
|
482
475
|
export const lowestY = staticLowestY;
|
|
483
476
|
|
|
484
477
|
/**
|
|
485
|
-
* The
|
|
486
|
-
*
|
|
487
|
-
* The bake writes it into the record, and the load path hands it back to `preparePose` as the pose
|
|
488
|
-
* override, so one rule composes the rotation and the record carries the result.
|
|
478
|
+
* The forest's own ground rules: which assets bury, which flat footprints sink, which crag rims are
|
|
479
|
+
* measured. The pose steps are the package's; these rows are the picture's.
|
|
489
480
|
*/
|
|
490
|
-
export
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
scale: [scalar, scalar, scalar],
|
|
523
|
-
},
|
|
524
|
-
};
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
/**
|
|
528
|
-
* The model a record draws: its asset, its variant, and the shape a non-uniform edit gave it.
|
|
529
|
-
*
|
|
530
|
-
* `WorldCells` names the model through the run the record sits in, so this key is what the container
|
|
531
|
-
* stores. A placement with one uniform scale draws its variant as authored (`spruce:2`); a placement
|
|
532
|
-
* the editor scaled unevenly draws a model of that shape (`spruce:2@1,0.5,0.5`), so the record stays
|
|
533
|
-
* one uniform scale and the picture keeps the edit.
|
|
534
|
-
*/
|
|
535
|
-
export function propKey(placement: IPlacement): string {
|
|
536
|
-
const variant = `${placement.asset}:${variantFor(placement, placement.asset)}`;
|
|
537
|
-
const scale = placement.transform?.scale ?? [placement.scale, placement.scale, placement.scale];
|
|
538
|
-
const scalar = scale[0] === 0 ? 1 : scale[0];
|
|
539
|
-
const ratio = scale.map((value) => value / scalar);
|
|
540
|
-
const off = ratio.reduce((sum, value) => sum + (value - 1) ** 2, 0);
|
|
541
|
-
return off < 1e-16 ? variant : `${variant}@${ratio.join(",")}`;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
/** The shape `propKey` wrote, so the loader scales the model the record's one scale cannot carry. */
|
|
545
|
-
export function propRatio(key: string): [number, number, number] {
|
|
546
|
-
const at = key.indexOf("@");
|
|
547
|
-
if (at < 0) return [1, 1, 1];
|
|
548
|
-
const ratio = key
|
|
549
|
-
.slice(at + 1)
|
|
550
|
-
.split(",")
|
|
551
|
-
.map(Number);
|
|
552
|
-
// A negative component is a mirror, which the renderer composes like any other shape.
|
|
553
|
-
if (ratio.length !== 3 || ratio.some((value) => !Number.isFinite(value) || value === 0))
|
|
554
|
-
throw new Error(`Prop key '${key}' does not name a usable shape.`);
|
|
555
|
-
return [ratio[0] as number, ratio[1] as number, ratio[2] as number];
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
/**
|
|
559
|
-
* The pose a baked package record carries: the quaternion the bake authored for the placement.
|
|
560
|
-
*
|
|
561
|
-
* A world-v1 record holds position, quaternion and scale, and nothing about `alignToNormal` or the
|
|
562
|
-
* scatter yaw, so the load path hands the record's quaternion here. It replaces the rotation the
|
|
563
|
-
* placement would compose, and every step below it — the ground snap, the boulder burial, the
|
|
564
|
-
* four-footprint sink and the mountain base ring — still runs, because the record is a pose and not
|
|
565
|
-
* an override of the pose.
|
|
566
|
-
*/
|
|
567
|
-
export interface IPropPoseOverride {
|
|
568
|
-
readonly quaternion: readonly [number, number, number, number];
|
|
569
|
-
}
|
|
481
|
+
export const GROUND_RULES: IPropGroundRules = {
|
|
482
|
+
burial: (placement) => {
|
|
483
|
+
if (
|
|
484
|
+
![
|
|
485
|
+
"boulder",
|
|
486
|
+
"riverrock",
|
|
487
|
+
"pebble",
|
|
488
|
+
"scree",
|
|
489
|
+
"cliff",
|
|
490
|
+
"mountain",
|
|
491
|
+
"volcanic",
|
|
492
|
+
"reveal",
|
|
493
|
+
].includes(placement.asset)
|
|
494
|
+
)
|
|
495
|
+
return undefined;
|
|
496
|
+
const crag = ["mountain", "volcanic", "reveal"].includes(placement.asset);
|
|
497
|
+
return {
|
|
498
|
+
share: placement.id.endsWith(":outcrop")
|
|
499
|
+
? 0.35
|
|
500
|
+
: placement.asset === "mountain"
|
|
501
|
+
? 0.82
|
|
502
|
+
: crag
|
|
503
|
+
? 0.55
|
|
504
|
+
: BOULDER_BURIAL,
|
|
505
|
+
crag,
|
|
506
|
+
};
|
|
507
|
+
},
|
|
508
|
+
footprint: (placement) => ["boulder", "riverrock", "scree"].includes(placement.asset),
|
|
509
|
+
footprintThreshold: 0.08,
|
|
510
|
+
baseRing: (placement) => placement.asset === "mountain" && !placement.id.endsWith(":outcrop"),
|
|
511
|
+
baseRingClearance: 0.5,
|
|
512
|
+
};
|
|
570
513
|
|
|
514
|
+
/** The package's pose, grounded by this world's rules and the placement's variant. */
|
|
571
515
|
export function preparePose(
|
|
572
516
|
geometry: BufferGeometry,
|
|
573
|
-
|
|
517
|
+
material: Material,
|
|
574
518
|
placement: IPlacement,
|
|
575
519
|
transform: IPlacementOverride | undefined,
|
|
576
520
|
groundAt: PropGroundQuery,
|
|
577
521
|
pose?: IPropPoseOverride,
|
|
578
522
|
) {
|
|
579
|
-
|
|
580
|
-
// Mesh per placement cost 30 s of the forest's load (218,816 placements, 0.14 ms each).
|
|
581
|
-
const model = {
|
|
582
|
-
position: new Vector3(),
|
|
583
|
-
quaternion: new Quaternion(),
|
|
584
|
-
scale: new Vector3(1, 1, 1),
|
|
585
|
-
matrix: new Matrix4(),
|
|
586
|
-
updateMatrix() {
|
|
587
|
-
this.matrix.compose(this.position, this.quaternion, this.scale);
|
|
588
|
-
},
|
|
589
|
-
};
|
|
590
|
-
model.position.fromArray(transform?.position ?? placement.position);
|
|
591
|
-
if (transform) {
|
|
592
|
-
model.quaternion.fromArray(transform.quaternion);
|
|
593
|
-
model.scale.fromArray(transform.scale);
|
|
594
|
-
} else {
|
|
595
|
-
model.quaternion.fromArray(pose?.quaternion ?? authoredQuaternion(placement));
|
|
596
|
-
model.scale.setScalar(placement.scale);
|
|
597
|
-
}
|
|
598
|
-
const grounding = transform?.grounding ?? true;
|
|
599
|
-
const ground = groundAt(placement, model.position.toArray());
|
|
600
|
-
// GroundSnap's rule: the lowest posed point meets the surface, then the authored offset applies.
|
|
601
|
-
let clearance: number | null = null;
|
|
602
|
-
if (ground.height === null) {
|
|
603
|
-
if (grounding)
|
|
604
|
-
throw new Error(
|
|
605
|
-
`Missing terrain ground for '${placement.id}' at ${JSON.stringify(model.position.toArray())}`,
|
|
606
|
-
);
|
|
607
|
-
} else {
|
|
608
|
-
model.updateMatrix();
|
|
609
|
-
clearance = lowestY(geometry, model.matrix) - ground.height;
|
|
610
|
-
if (grounding) {
|
|
611
|
-
model.position.y += ground.offset - clearance;
|
|
612
|
-
clearance = ground.offset;
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
// A boulder is a rock that is part buried: GroundSnap puts its lowest point on the surface, and on a
|
|
616
|
-
// slope the downhill side then hangs in the air. Sinking it by a share of its own height closes that.
|
|
617
|
-
if (
|
|
618
|
-
grounding &&
|
|
619
|
-
!transform &&
|
|
620
|
-
["boulder", "riverrock", "pebble", "scree", "cliff", "mountain", "volcanic", "reveal"].includes(
|
|
621
|
-
placement.asset,
|
|
622
|
-
) &&
|
|
623
|
-
ground.height !== null
|
|
624
|
-
) {
|
|
625
|
-
geometry.computeBoundingBox();
|
|
626
|
-
const box = geometry.boundingBox;
|
|
627
|
-
if (box) {
|
|
628
|
-
model.updateMatrix();
|
|
629
|
-
const crag = ["mountain", "volcanic", "reveal"].includes(placement.asset);
|
|
630
|
-
const height = crag
|
|
631
|
-
? box.clone().applyMatrix4(model.matrix).getSize(new Vector3()).y
|
|
632
|
-
: (box.max.y - box.min.y) * model.scale.y;
|
|
633
|
-
model.position.y -=
|
|
634
|
-
(placement.id.endsWith(":outcrop")
|
|
635
|
-
? 0.35
|
|
636
|
-
: placement.asset === "mountain"
|
|
637
|
-
? 0.82
|
|
638
|
-
: crag
|
|
639
|
-
? 0.55
|
|
640
|
-
: BOULDER_BURIAL) * height;
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
// Bury the flat footprint on the downhill side too; a centre-only snap leaves a visible lip.
|
|
644
|
-
if (grounding && !transform && ["boulder", "riverrock", "scree"].includes(placement.asset)) {
|
|
645
|
-
model.updateMatrix();
|
|
646
|
-
let gap: number;
|
|
647
|
-
try {
|
|
648
|
-
gap = footprintGap(
|
|
649
|
-
geometry,
|
|
650
|
-
model.matrix,
|
|
651
|
-
(x, z) => groundAt(placement, [x, 0, z]).height,
|
|
652
|
-
0.08,
|
|
653
|
-
);
|
|
654
|
-
} catch (error) {
|
|
655
|
-
throw new Error(`Missing ground under rock '${placement.id}'`, { cause: error });
|
|
656
|
-
}
|
|
657
|
-
model.position.y -= gap;
|
|
658
|
-
}
|
|
659
|
-
let cragBaseClearance: number | undefined;
|
|
660
|
-
let cragRingSamples: number | undefined;
|
|
661
|
-
if (
|
|
662
|
-
grounding &&
|
|
663
|
-
!transform &&
|
|
664
|
-
placement.asset === "mountain" &&
|
|
665
|
-
!placement.id.endsWith(":outcrop")
|
|
666
|
-
) {
|
|
667
|
-
// Lowest rim vertex per angular sector: a narrow buried stem must not support a wide scan
|
|
668
|
-
// collar hanging above the downhill ground.
|
|
669
|
-
if (!geometry.boundingBox) throw new Error(`Crag '${placement.id}' has no bounds`);
|
|
670
|
-
model.updateMatrix();
|
|
671
|
-
let ring: IBaseRing;
|
|
672
|
-
try {
|
|
673
|
-
ring = baseRingGap(geometry, model.matrix, (x, z) => groundAt(placement, [x, 0, z]).height);
|
|
674
|
-
} catch (error) {
|
|
675
|
-
throw new Error(`Missing ground under crag ring '${placement.id}'`, { cause: error });
|
|
676
|
-
}
|
|
677
|
-
const highestGap = ring.gap;
|
|
678
|
-
cragRingSamples = ring.samples;
|
|
679
|
-
if (cragRingSamples < 4) throw new Error(`Incomplete base ring for crag '${placement.id}'`);
|
|
680
|
-
const sink = Math.max(0, highestGap + 0.5);
|
|
681
|
-
model.position.y -= sink;
|
|
682
|
-
cragBaseClearance = highestGap - sink;
|
|
683
|
-
}
|
|
684
|
-
model.updateMatrix();
|
|
685
|
-
if (!new Float32Array(model.matrix.elements).every(Number.isFinite))
|
|
686
|
-
throw new Error(`Transform exceeds the renderer range for '${placement.id}'`);
|
|
687
|
-
return {
|
|
688
|
-
matrix: model.matrix.clone(),
|
|
689
|
-
grounding,
|
|
690
|
-
clearance,
|
|
691
|
-
cragBaseClearance,
|
|
692
|
-
cragRingSamples,
|
|
693
|
-
};
|
|
523
|
+
return preparePoseIn(geometry, material, placement, transform, groundAt, GROUND_RULES, pose);
|
|
694
524
|
}
|
|
525
|
+
|
|
695
526
|
export function preparePropTransform(
|
|
696
527
|
instance: IPropInstance,
|
|
697
528
|
transform: IPlacementOverride | undefined,
|
|
698
529
|
groundAt: PropGroundQuery,
|
|
699
530
|
) {
|
|
700
|
-
return
|
|
701
|
-
...preparePose(instance.geometry, instance.material, instance.placement, transform, groundAt),
|
|
702
|
-
transform,
|
|
703
|
-
};
|
|
531
|
+
return preparePropTransformIn(instance, transform, groundAt, GROUND_RULES);
|
|
704
532
|
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
const changed =
|
|
710
|
-
!instance.pose.equals(prepared.matrix) || instance.grounding !== prepared.grounding;
|
|
711
|
-
instance.pose.copy(prepared.matrix);
|
|
712
|
-
instance.grounding = prepared.grounding;
|
|
713
|
-
instance.clearance = prepared.clearance;
|
|
714
|
-
instance.cragBaseClearance = prepared.cragBaseClearance;
|
|
715
|
-
instance.cragRingSamples = prepared.cragRingSamples;
|
|
716
|
-
if (changed) instance.onTransform?.(prepared.transform);
|
|
717
|
-
}
|
|
718
|
-
export function readPropTransform(instance: IPropInstance): IPlacementOverride {
|
|
719
|
-
const matrix = instance.pose;
|
|
720
|
-
const position = new Vector3();
|
|
721
|
-
const quaternion = new Quaternion();
|
|
722
|
-
const scale = new Vector3();
|
|
723
|
-
matrix.decompose(position, quaternion, scale);
|
|
724
|
-
return {
|
|
725
|
-
position: position.toArray(),
|
|
726
|
-
quaternion: quaternion.normalize().toArray(),
|
|
727
|
-
scale: scale.toArray(),
|
|
728
|
-
grounding: instance.grounding,
|
|
729
|
-
};
|
|
533
|
+
|
|
534
|
+
/** The model a record draws, with the variant this kit's `variantFor` picks for it. */
|
|
535
|
+
export function propKey(placement: IPlacement): string {
|
|
536
|
+
return propKeyIn(placement, variantFor(placement, placement.asset));
|
|
730
537
|
}
|
|
731
538
|
|
|
539
|
+
export {
|
|
540
|
+
authoredQuaternion,
|
|
541
|
+
propRatio,
|
|
542
|
+
readPropTransform,
|
|
543
|
+
withAuthoredPose,
|
|
544
|
+
writePropTransform,
|
|
545
|
+
} from "@threenative/terrain/starter";
|
|
546
|
+
export type { IPropInstance, IPropPoseOverride, PropGroundQuery };
|
|
547
|
+
|
|
732
548
|
/**
|
|
733
549
|
* Assign every placement a variant, deterministically from its own id.
|
|
734
550
|
*
|
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
import type { Node } from "three/webgpu";
|
|
31
31
|
import { BIOMES, type IBiome } from "../biomes.js";
|
|
32
32
|
import { setCanopySun } from "../props/propMaterials.js";
|
|
33
|
+
import { WORLD } from "../worldNames.js";
|
|
33
34
|
import { aerialPerspective, cloudDome, createAtmosphere, skyColour } from "./atmosphere.js";
|
|
34
35
|
|
|
35
36
|
/**
|
|
@@ -130,7 +131,7 @@ export function createOutdoorSky(
|
|
|
130
131
|
const sun = new DirectionalLight(sunColor, biome?.sun.intensity ?? SUN.intensity);
|
|
131
132
|
sun.name = "temperate-sun";
|
|
132
133
|
sun.castShadow = true;
|
|
133
|
-
sun.shadow.radius = biome?.sun.shadowRadius ?? BIOMES.
|
|
134
|
+
sun.shadow.radius = biome?.sun.shadowRadius ?? BIOMES[WORLD].sun.shadowRadius;
|
|
134
135
|
// The owned engine (the default) filters its own virtual shadow maps with PCF; upstream three's
|
|
135
136
|
// `PCFShadowFilter` node is refused by name there (`TN_NATIVE_UNCATALOGUED_PCFSHADOWFILTER`), so the
|
|
136
137
|
// kit names no filter node.
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The one world this kit draws. Every baked file is `world/<WORLD>.*`, so it equals `recipe.json`'s
|
|
3
|
+
* `world.name`; rename both to make a new environment, and the `WorldName` rows follow it.
|
|
4
|
+
*/
|
|
5
|
+
export const WORLD = "forest";
|
|
6
|
+
export const WORLD_NAMES = [WORLD] as const;
|
package/starter/forest/scene.ts
CHANGED
|
@@ -7,16 +7,7 @@ import {
|
|
|
7
7
|
} from "@threenative/core";
|
|
8
8
|
import { Heightfield, warmUnculled } from "@threenative/core/world";
|
|
9
9
|
import { CollisionShape3D, type IPhysicsContext, RigidBody3D } from "@threenative/physics";
|
|
10
|
-
import {
|
|
11
|
-
type AnimationClip,
|
|
12
|
-
Mesh,
|
|
13
|
-
MeshStandardMaterial,
|
|
14
|
-
type PerspectiveCamera,
|
|
15
|
-
Vector2,
|
|
16
|
-
Vector3,
|
|
17
|
-
} from "three";
|
|
18
|
-
import { uniform } from "three/tsl";
|
|
19
|
-
import type { MeshStandardNodeMaterial } from "three/webgpu";
|
|
10
|
+
import { addStreamedGround, createSpawnGate } from "@threenative/terrain/starter";
|
|
20
11
|
import {
|
|
21
12
|
beginScene,
|
|
22
13
|
createMeasure,
|
|
@@ -27,12 +18,27 @@ import {
|
|
|
27
18
|
observeFrame,
|
|
28
19
|
observeWindow,
|
|
29
20
|
publish,
|
|
30
|
-
} from "
|
|
21
|
+
} from "@threenative/terrain/starter";
|
|
22
|
+
import {
|
|
23
|
+
type AnimationClip,
|
|
24
|
+
Mesh,
|
|
25
|
+
MeshStandardMaterial,
|
|
26
|
+
type PerspectiveCamera,
|
|
27
|
+
Vector2,
|
|
28
|
+
Vector3,
|
|
29
|
+
} from "three";
|
|
30
|
+
import { uniform } from "three/tsl";
|
|
31
|
+
import type { MeshStandardNodeMaterial } from "three/webgpu";
|
|
31
32
|
import { type IMannequin, type IPlayerRig, createPlayerRig } from "./playerRig.js";
|
|
32
33
|
import { BENCHMARK, type ViewName, posesFor } from "./render/benchmark.js";
|
|
33
34
|
import { biomeSpec } from "./render/biomeData.js";
|
|
34
35
|
import { BIOMES, type IWorldBiome, measureBiome } from "./render/biomes.js";
|
|
35
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
COLLAR_CURVE,
|
|
38
|
+
HORIZON_REACH,
|
|
39
|
+
createWorldHeight,
|
|
40
|
+
loadHorizonSurroundings,
|
|
41
|
+
} from "./render/ground/horizon.js";
|
|
36
42
|
import { type IBakedWorld, type ITerrainStream, createTerrain } from "./render/ground/terrain.js";
|
|
37
43
|
import { forestAssets } from "./render/kitAssets.js";
|
|
38
44
|
import { createLoadingScreen } from "./render/loading.js";
|
|
@@ -41,10 +47,9 @@ import { invalidatePropShadows } from "./render/props/propWorld.js";
|
|
|
41
47
|
import { buildPropVariants } from "./render/props/props.js";
|
|
42
48
|
import { type IOutdoorSky, createOutdoorSky, installOutdoorOcclusion } from "./render/sky/sky.js";
|
|
43
49
|
import { type IRiverWater, WATER_LAYER, createLakes, createRivers } from "./render/water/river.js";
|
|
50
|
+
import { WORLD } from "./render/worldNames.js";
|
|
44
51
|
import { type IMeadow, type Scatter, type Variants, createMeadow } from "./sceneProps.js";
|
|
45
52
|
import { type TerrainCtx, type TerrainState, initialState } from "./sceneState.js";
|
|
46
|
-
import { createSpawnGate } from "./spawnGate.js";
|
|
47
|
-
import { addStreamedGround } from "./world/streamedGround.js";
|
|
48
53
|
import { walkBandSlices } from "./world/walkBand.js";
|
|
49
54
|
import { waterCurrentAt, waterSurfaceAt } from "./world/water.js";
|
|
50
55
|
import { loadBakedWorld } from "./worlds.js";
|
|
@@ -57,7 +62,7 @@ const SWIM_CLIPS = "mannequin-swim.glb";
|
|
|
57
62
|
/** The player's model, from the game's own asset root (the scaffold ships it). */
|
|
58
63
|
const MANNEQUIN = "mannequin.glb";
|
|
59
64
|
|
|
60
|
-
const world =
|
|
65
|
+
const world = WORLD;
|
|
61
66
|
// What the game resolves this world from: its rules, and the look it is graded under.
|
|
62
67
|
const spec = biomeSpec(world);
|
|
63
68
|
const look = BIOMES[world];
|
|
@@ -186,7 +191,7 @@ export class ForestScene extends Scene<TerrainState, IPhysicsContext> {
|
|
|
186
191
|
revealed: () => ctx.state.set({ revealComplete: true }),
|
|
187
192
|
});
|
|
188
193
|
// One scene-local spawn gate: a single deadline, settled once by the world readiness join, a
|
|
189
|
-
// failure or teardown.
|
|
194
|
+
// failure or teardown. `@threenative/terrain/starter` owns it and reports the one line a failed spawn leaves.
|
|
190
195
|
const gate = createSpawnGate(ctx, {
|
|
191
196
|
world,
|
|
192
197
|
progress: () => (meadow?.progress() ?? 0) + ctx.state.getState().spawnCellsLoaded,
|
|
@@ -348,16 +353,20 @@ export class ForestScene extends Scene<TerrainState, IPhysicsContext> {
|
|
|
348
353
|
const streamLoad = this.#bandLoad;
|
|
349
354
|
groundReady = stream.material.then((surface) => {
|
|
350
355
|
if (streamLoad !== this.#bandLoad) return surface.dispose();
|
|
351
|
-
const ground = addStreamedGround(
|
|
356
|
+
const ground = addStreamedGround({
|
|
352
357
|
ctx,
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
358
|
+
name: world,
|
|
359
|
+
size: data.size,
|
|
360
|
+
resolution: data.resolution,
|
|
361
|
+
height: createWorldHeight(data, world),
|
|
356
362
|
collar,
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
363
|
+
curve: COLLAR_CURVE,
|
|
364
|
+
reach: HORIZON_REACH,
|
|
365
|
+
stream: stream.split,
|
|
366
|
+
surface,
|
|
367
|
+
follow: actor,
|
|
368
|
+
report: (facts) => ctx.state.set(facts),
|
|
369
|
+
});
|
|
361
370
|
ctx.entities.add("streamed-ground", { tiles: ground.tiles, dispose: ground.dispose });
|
|
362
371
|
return ground.ready;
|
|
363
372
|
});
|
|
@@ -602,7 +611,7 @@ export class ForestScene extends Scene<TerrainState, IPhysicsContext> {
|
|
|
602
611
|
const at = (x: number, z: number, up: number): Vector3 =>
|
|
603
612
|
new Vector3(x, field.heightAt(x, z) + up, z);
|
|
604
613
|
ctx.beforeRender(() => {
|
|
605
|
-
observeFrame(
|
|
614
|
+
observeFrame(ctx);
|
|
606
615
|
const view = ctx.state.getState().view;
|
|
607
616
|
rig.figure.root.visible = view === "player" && !ctx.state.getState().showcase;
|
|
608
617
|
if (view === "player") {
|
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
surfaceSampler,
|
|
8
8
|
} from "@threenative/core/world";
|
|
9
9
|
import { ScatterColliders } from "@threenative/physics";
|
|
10
|
+
import type { ISpawnGate, ISpawnWitness } from "@threenative/terrain/starter";
|
|
11
|
+
import type { IRevealProbe } from "@threenative/terrain/starter";
|
|
10
12
|
import {
|
|
11
13
|
Float32BufferAttribute,
|
|
12
14
|
Mesh,
|
|
@@ -15,7 +17,6 @@ import {
|
|
|
15
17
|
PerspectiveCamera,
|
|
16
18
|
Vector3,
|
|
17
19
|
} from "three";
|
|
18
|
-
import type { IRevealProbe } from "./diagnostics.js";
|
|
19
20
|
import { posesFor } from "./render/benchmark.js";
|
|
20
21
|
import type { IBiome, IWorldBiome, WorldName } from "./render/biomes.js";
|
|
21
22
|
import { HORIZON_WALK_BAND } from "./render/ground/horizon.js";
|
|
@@ -42,7 +43,6 @@ import {
|
|
|
42
43
|
import { SHADOW_REACH } from "./render/sky/sky.js";
|
|
43
44
|
import { preparePropTextures } from "./render/texturePreparation.js";
|
|
44
45
|
import type { TerrainCtx } from "./sceneState.js";
|
|
45
|
-
import type { ISpawnGate, ISpawnWitness } from "./spawnGate.js";
|
|
46
46
|
|
|
47
47
|
/** The whole set of placements one world scatters, with the canopy weight painted from them. */
|
|
48
48
|
export type Scatter = IScatter;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import type { ICtx } from "@threenative/core";
|
|
2
2
|
import type { IPhysicsContext } from "@threenative/physics";
|
|
3
|
-
import {
|
|
3
|
+
import { createDiagnosticsState } from "@threenative/terrain/starter";
|
|
4
4
|
import type { ICanopyComparison } from "./render/props/pack.js";
|
|
5
|
+
import { WORLD } from "./render/worldNames.js";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
|
-
* The state this game reports through: every measurement
|
|
8
|
-
* that are a look decision rather than a measurement.
|
|
8
|
+
* The state this game reports through: every measurement the package's diagnostics own, plus the
|
|
9
|
+
* values that are a look decision rather than a measurement.
|
|
9
10
|
*
|
|
10
11
|
* It lives here rather than in `game.ts` because the scene's collaborators — the spawn gate, the
|
|
11
12
|
* meadow build, the player rig — read and write the same store, and importing the state shape from
|
|
12
13
|
* the scene that composes them would close a cycle.
|
|
13
14
|
*/
|
|
14
15
|
export const initialState = {
|
|
15
|
-
...
|
|
16
|
+
...createDiagnosticsState(WORLD),
|
|
16
17
|
canopyComparison: { normals: "authored", specular: "disabled" } as ICanopyComparison,
|
|
17
18
|
showcase: false,
|
|
18
19
|
/** "off" when the `?stream=off` override is in use, so a run reports the arm it ran. */
|
package/starter/forest/worlds.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { IAssetLoader } from "@threenative/core";
|
|
2
2
|
import { fetchBakedFile } from "./render/bakedFile.js";
|
|
3
3
|
import type { IBakedWorld } from "./render/ground/terrain.js";
|
|
4
|
+
import { WORLD } from "./render/worldNames.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
|
-
* The baked terrain arrays (`world
|
|
7
|
+
* The baked terrain arrays (`world/<WORLD>.json`, written by `bake.mjs`), fetched rather than imported:
|
|
7
8
|
* as a JSON module the 6 MB file costs seconds to compile before the first frame.
|
|
8
9
|
*/
|
|
9
10
|
export async function loadBakedWorld(assets: Pick<IAssetLoader, "resolve">): Promise<IBakedWorld> {
|
|
10
|
-
const response = await fetchBakedFile(assets,
|
|
11
|
+
const response = await fetchBakedFile(assets, `world/${WORLD}.json`);
|
|
11
12
|
return (await response.json()) as IBakedWorld;
|
|
12
13
|
}
|
package/starter/tundra/README.md
CHANGED
|
@@ -1,37 +1,56 @@
|
|
|
1
1
|
# Tundra starter kit
|
|
2
2
|
|
|
3
|
-
A 512 m
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
A 512 m alpine tundra on Trail Ridge, Rocky Mountain National Park, 3430-3480 m (USGS 1 m DEM),
|
|
4
|
+
above the tree line: short sedge and grass turf, fellfield gravel and grey lichen, late snow patches,
|
|
5
|
+
two meltwater streams and two kettle ponds, krummholz at the low edge, dwarf willow in the swales and
|
|
6
|
+
lichen-crusted erratics. The far ring is the same survey out to 5 km on the square's own datum: Trail
|
|
7
|
+
Ridge's 3.7-3.8 km peaks and the forested valleys under them. It is game source: once copied, every
|
|
8
|
+
file is yours to edit.
|
|
6
9
|
|
|
7
10
|
| File | What it decides |
|
|
8
11
|
| --- | --- |
|
|
9
|
-
| `recipe.json` | The terrain: the survey heightmap, erosion, the kettle beds, the two
|
|
10
|
-
| `heightmap.r16` | The real elevations the recipe's heightmap layer reads: 16-bit samples, decoded at the bake to 0.1 m steps. |
|
|
11
|
-
| `biome.data.json` | The biome record the
|
|
12
|
-
| `assets.json` | The boulder model,
|
|
13
|
-
| `surface.json` | The ground:
|
|
14
|
-
| `bake.mjs` |
|
|
15
|
-
| `
|
|
16
|
-
| `
|
|
17
|
-
| `water.ts` | The
|
|
12
|
+
| `recipe.json` | The terrain: the survey heightmap, erosion, the kettle beds, the two streams, the two ponds, the surfaces and the erratics; its `world` row names the ground layers, the art and the far ring. |
|
|
13
|
+
| `heightmap.r16` | The real elevations the recipe's heightmap layer reads: 16-bit samples, decoded at the bake to 0.1 m steps. `scripts/cook-kit-survey.ts` in `@threenative/terrain` cuts it and the far ring from any lat/lon. |
|
|
14
|
+
| `biome.data.json` | The biome record: the krummholz, the turf, the cushion plants, the willow, the stones and their bands. The streamed bake places from it. |
|
|
15
|
+
| `assets.json` | The legacy cell package's boulder model, LOD distance, draw distance and bounds. |
|
|
16
|
+
| `surface.json` | The legacy cell package's ground table: moss base, snow and rock layers, tiles, tints and thresholds. |
|
|
17
|
+
| `bake.mjs` | Runs `bakeKit` with this kit's look and writes the streamed world: the baked grid, its splat, the canopy and sky bytes, `horizon.json`, the prop package and the art. |
|
|
18
|
+
| `scene.ts` | The scene, `TundraScene`, and `TUNDRA_GAME`: the streamed ground, the far ring, the props, the sky, the ponds and streams, and the player rig. |
|
|
19
|
+
| `render/` | The look: the biome row (`render/biomes.ts`), the ground material, the palette, the species pack (`render/props/pack.ts`), the sky and the water. |
|
|
20
|
+
| `world.ts`, `sky.ts`, `water.ts` | The legacy cell-package loader, its daylight and its water, kept until the streamed bake retires them here. |
|
|
18
21
|
|
|
19
22
|
Art is CC0 (Poly Haven); provenance is in `@threenative/terrain/starter-credits.json`.
|
|
20
23
|
|
|
24
|
+
## What draws each species
|
|
25
|
+
|
|
26
|
+
The bake's ordered tundra stream places six kinds; `render/props/pack.ts` decides the art for each:
|
|
27
|
+
|
|
28
|
+
| Placed kind | Drawn as |
|
|
29
|
+
| --- | --- |
|
|
30
|
+
| `sapling` | Krummholz spruce and fir: the fir scan, squashed to a wind-pruned mat |
|
|
31
|
+
| `bush` | Dwarf willow and blueberry shrubs |
|
|
32
|
+
| `grass` | Short alpine sedge and grass tufts |
|
|
33
|
+
| `scrub` | Cushion plants and moss mats |
|
|
34
|
+
| `boulder`, `riverrock` | Lichen-crusted erratics and stream stones |
|
|
35
|
+
|
|
21
36
|
## Status
|
|
22
37
|
|
|
23
|
-
The kit
|
|
24
|
-
|
|
38
|
+
The kit is a source kit on the forest's stack: `scene.ts` streams the baked world, its far ring and
|
|
39
|
+
its props, and composes the player rig and diagnostics from `@threenative/terrain/starter`.
|
|
25
40
|
|
|
26
41
|
## Steps
|
|
27
42
|
|
|
28
43
|
1. Copy `node_modules/@threenative/terrain/starter/tundra` to `src/terrain/tundra`.
|
|
29
44
|
2. Run `node src/terrain/tundra/bake.mjs --out assets/terrain/tundra` (needs `@threenative/terrain`
|
|
30
|
-
as
|
|
31
|
-
|
|
45
|
+
and `tsx` as devDependencies, because the bake reads this kit's TypeScript look). The same recipe
|
|
46
|
+
always writes the same bytes.
|
|
47
|
+
3. Spread `TUNDRA_GAME` into `defineGame` and register `TundraScene`, as the forest kit's README shows.
|
|
32
48
|
|
|
33
49
|
## Edit at startup, without rebaking
|
|
34
50
|
|
|
51
|
+
> The streamed bake retires this path for the tundra kit: the ground table and the props now come
|
|
52
|
+
> from `render/`, and the section below still describes the legacy cell package.
|
|
53
|
+
|
|
35
54
|
The copied `world.ts` loads its own `surface.json` as the ground table on every startup.
|
|
36
55
|
Edit tints, tiling and blend thresholds there, or the material graph and prop dressing in
|
|
37
56
|
`world.ts`, then reload. The package's `terrain-table.json` remains the baked default for
|