@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.
Files changed (243) hide show
  1. package/README.md +40 -59
  2. package/THIRD_PARTY_NOTICES.md +2 -1
  3. package/dist/bake-DJ5cxg0C.d.ts +82 -0
  4. package/dist/editor/index.d.ts +4 -4
  5. package/dist/editor/index.js +130 -128
  6. package/dist/editor/server.d.ts +2 -2
  7. package/dist/editor/server.js +38 -35
  8. package/dist/editor/worker.d.ts +1 -1
  9. package/dist/editor/worker.js +101 -101
  10. package/dist/export.d.ts +1 -1
  11. package/dist/index.d.ts +156 -273
  12. package/dist/index.js +562 -378
  13. package/dist/kit-world.d.ts +107 -0
  14. package/dist/kit-world.js +5134 -0
  15. package/dist/kit.d.ts +21 -4
  16. package/dist/kit.js +337 -223
  17. package/dist/mcp/cook-child.js +1963 -1543
  18. package/dist/mcp/server.js +716 -429
  19. package/dist/prop-package-Dwz0EWoB.d.ts +141 -0
  20. package/dist/{server-B5RdvEAC.d.ts → server-LnFwY8sr.d.ts} +1 -1
  21. package/dist/starter.d.ts +1142 -7
  22. package/dist/starter.js +2102 -120
  23. package/dist/{terrain-CAEaW0mQ.d.ts → terrain-DYCyAOCJ.d.ts} +1 -1
  24. package/dist/three.d.ts +1 -1
  25. package/dist/three.js +1 -1
  26. package/dist/{types-BpH00qsx.d.ts → types-kpI0C4hW.d.ts} +1 -1
  27. package/dist/{world-package-B8QgHjAQ.d.ts → world-package-DqJC3-Nn.d.ts} +2 -2
  28. package/docs/authoring/editor.md +73 -0
  29. package/docs/authoring/new-environment.md +97 -0
  30. package/docs/authoring/recipes.md +97 -0
  31. package/docs/authoring/world-export.md +66 -0
  32. package/package.json +24 -8
  33. package/starter/alpine/README.md +22 -12
  34. package/starter/alpine/bake.mjs +14 -1
  35. package/starter/alpine/biome.data.json +187 -25
  36. package/starter/alpine/heightmap.r16 +0 -0
  37. package/starter/alpine/playerRig.ts +89 -0
  38. package/starter/alpine/recipe.json +169 -15
  39. package/starter/alpine/render/bakedFile.ts +17 -0
  40. package/starter/alpine/render/benchmark.ts +77 -0
  41. package/starter/alpine/render/biomeData.ts +14 -0
  42. package/starter/alpine/render/biomes.ts +687 -0
  43. package/starter/alpine/render/ground/cover.ts +565 -0
  44. package/starter/alpine/render/ground/horizon.ts +219 -0
  45. package/starter/alpine/render/ground/palette.d.ts +1 -0
  46. package/starter/alpine/render/ground/palette.js +11 -0
  47. package/starter/alpine/render/ground/scatter.ts +104 -0
  48. package/starter/alpine/render/ground/terrain.ts +1860 -0
  49. package/starter/alpine/render/kitAssets.ts +28 -0
  50. package/starter/alpine/render/loading.ts +354 -0
  51. package/starter/alpine/render/lookKnobs.ts +37 -0
  52. package/starter/alpine/render/orbitCamera.ts +155 -0
  53. package/starter/alpine/render/props/farForest.ts +94 -0
  54. package/starter/alpine/render/props/pack.ts +1114 -0
  55. package/starter/alpine/render/props/prepared.ts +225 -0
  56. package/starter/alpine/render/props/propMaterials.ts +1239 -0
  57. package/starter/alpine/render/props/propProgress.ts +2 -0
  58. package/starter/alpine/render/props/propWorld.ts +105 -0
  59. package/starter/alpine/render/props/props.ts +633 -0
  60. package/starter/alpine/render/props/spruce.ts +440 -0
  61. package/starter/alpine/render/sky/atmosphere.ts +329 -0
  62. package/starter/alpine/render/sky/sky.ts +382 -0
  63. package/starter/alpine/render/texturePreparation.ts +135 -0
  64. package/starter/alpine/render/water/river.ts +1132 -0
  65. package/starter/alpine/render/worldNames.ts +6 -0
  66. package/starter/alpine/scene.ts +715 -0
  67. package/starter/alpine/sceneProps.ts +561 -0
  68. package/starter/alpine/sceneState.ts +33 -0
  69. package/starter/alpine/world/terrainAssets.ts +145 -0
  70. package/starter/alpine/world/walkBand.ts +47 -0
  71. package/starter/alpine/world/water.ts +74 -0
  72. package/starter/alpine/worlds.ts +13 -0
  73. package/starter/arbor/wind.ts +84 -0
  74. package/starter/coastal/README.md +26 -25
  75. package/starter/coastal/assets.json +10 -0
  76. package/starter/coastal/bake.mjs +14 -1
  77. package/starter/coastal/biome.data.json +18 -3
  78. package/starter/coastal/playerRig.ts +89 -0
  79. package/starter/coastal/recipe.json +220 -18
  80. package/starter/coastal/render/bakedFile.ts +17 -0
  81. package/starter/coastal/render/benchmark.ts +81 -0
  82. package/starter/coastal/render/biomeData.ts +14 -0
  83. package/starter/coastal/render/biomes.ts +678 -0
  84. package/starter/coastal/render/ground/cover.ts +565 -0
  85. package/starter/coastal/render/ground/horizon.ts +219 -0
  86. package/starter/coastal/render/ground/palette.d.ts +1 -0
  87. package/starter/coastal/render/ground/palette.js +11 -0
  88. package/starter/coastal/render/ground/scatter.ts +104 -0
  89. package/starter/coastal/render/ground/terrain.ts +1829 -0
  90. package/starter/coastal/render/kitAssets.ts +28 -0
  91. package/starter/coastal/render/loading.ts +354 -0
  92. package/starter/coastal/render/lookKnobs.ts +37 -0
  93. package/starter/coastal/render/orbitCamera.ts +155 -0
  94. package/starter/coastal/render/props/farForest.ts +94 -0
  95. package/starter/coastal/render/props/pack.ts +1109 -0
  96. package/starter/coastal/render/props/prepared.ts +225 -0
  97. package/starter/coastal/render/props/propMaterials.ts +1239 -0
  98. package/starter/coastal/render/props/propProgress.ts +2 -0
  99. package/starter/coastal/render/props/propWorld.ts +105 -0
  100. package/starter/coastal/render/props/props.ts +633 -0
  101. package/starter/coastal/render/props/spruce.ts +440 -0
  102. package/starter/coastal/render/sky/atmosphere.ts +329 -0
  103. package/starter/coastal/render/sky/sky.ts +382 -0
  104. package/starter/coastal/render/texturePreparation.ts +135 -0
  105. package/starter/coastal/render/water/ocean.ts +284 -0
  106. package/starter/coastal/render/water/river.ts +1132 -0
  107. package/starter/coastal/render/worldNames.ts +6 -0
  108. package/starter/coastal/scene.ts +740 -0
  109. package/starter/coastal/sceneProps.ts +559 -0
  110. package/starter/coastal/sceneState.ts +33 -0
  111. package/starter/coastal/world/terrainAssets.ts +151 -0
  112. package/starter/coastal/world/walkBand.ts +47 -0
  113. package/starter/coastal/world/water.ts +74 -0
  114. package/starter/coastal/worlds.ts +13 -0
  115. package/starter/desert/README.md +51 -23
  116. package/starter/desert/bake-flora.mjs +142 -0
  117. package/starter/desert/bake-rocks.mjs +291 -0
  118. package/starter/desert/bake.mjs +14 -1
  119. package/starter/desert/biome.data.json +24 -12
  120. package/starter/desert/playerRig.ts +89 -0
  121. package/starter/desert/recipe.json +63 -16
  122. package/starter/desert/render/bakedFile.ts +17 -0
  123. package/starter/desert/render/benchmark.ts +79 -0
  124. package/starter/desert/render/biomeData.ts +14 -0
  125. package/starter/desert/render/biomes.ts +660 -0
  126. package/starter/desert/render/ground/cover.ts +565 -0
  127. package/starter/desert/render/ground/debris.ts +136 -0
  128. package/starter/desert/render/ground/horizon.ts +219 -0
  129. package/starter/desert/render/ground/palette.d.ts +1 -0
  130. package/starter/desert/render/ground/palette.js +11 -0
  131. package/starter/desert/render/ground/scatter.ts +104 -0
  132. package/starter/desert/render/ground/terrain.ts +1854 -0
  133. package/starter/desert/render/kitAssets.ts +28 -0
  134. package/starter/desert/render/loading.ts +354 -0
  135. package/starter/desert/render/lookKnobs.ts +37 -0
  136. package/starter/desert/render/orbitCamera.ts +155 -0
  137. package/starter/desert/render/props/farForest.ts +96 -0
  138. package/starter/desert/render/props/formations.ts +630 -0
  139. package/starter/desert/render/props/pack.ts +1195 -0
  140. package/starter/desert/render/props/prepared.ts +225 -0
  141. package/starter/desert/render/props/propMaterials.ts +1255 -0
  142. package/starter/desert/render/props/propProgress.ts +2 -0
  143. package/starter/desert/render/props/propWorld.ts +105 -0
  144. package/starter/desert/render/props/props.ts +624 -0
  145. package/starter/desert/render/props/spruce.ts +440 -0
  146. package/starter/desert/render/sand.ts +581 -0
  147. package/starter/desert/render/sky/atmosphere.ts +329 -0
  148. package/starter/desert/render/sky/sky.ts +382 -0
  149. package/starter/desert/render/texturePreparation.ts +135 -0
  150. package/starter/desert/render/water/river.ts +1132 -0
  151. package/starter/desert/render/worldNames.ts +6 -0
  152. package/starter/desert/scene.ts +748 -0
  153. package/starter/desert/sceneProps.ts +562 -0
  154. package/starter/desert/sceneState.ts +33 -0
  155. package/starter/desert/world/terrainAssets.ts +162 -0
  156. package/starter/desert/world/walkBand.ts +47 -0
  157. package/starter/desert/world/water.ts +74 -0
  158. package/starter/desert/worlds.ts +13 -0
  159. package/starter/forest/README.md +59 -116
  160. package/starter/forest/assets.json +14 -14
  161. package/starter/forest/bake.mjs +26 -4
  162. package/starter/forest/playerRig.ts +89 -0
  163. package/starter/forest/recipe.json +233 -43
  164. package/starter/forest/render/bakedFile.ts +17 -0
  165. package/starter/forest/render/benchmark.ts +77 -0
  166. package/starter/forest/render/biomeData.ts +14 -0
  167. package/starter/forest/render/biomes.ts +637 -0
  168. package/starter/forest/render/ground/cover.ts +565 -0
  169. package/starter/forest/render/ground/horizon.ts +219 -0
  170. package/starter/forest/render/ground/palette.d.ts +1 -0
  171. package/starter/forest/render/ground/palette.js +11 -0
  172. package/starter/forest/render/ground/scatter.ts +104 -0
  173. package/starter/forest/render/ground/terrain.ts +1796 -0
  174. package/starter/forest/render/kitAssets.ts +28 -0
  175. package/starter/forest/render/loading.ts +354 -0
  176. package/starter/forest/render/lookKnobs.ts +37 -0
  177. package/starter/forest/render/orbitCamera.ts +155 -0
  178. package/starter/forest/render/props/farForest.ts +94 -0
  179. package/starter/forest/render/props/pack.ts +1078 -0
  180. package/starter/forest/render/props/prepared.ts +226 -0
  181. package/starter/forest/render/props/propMaterials.ts +1247 -0
  182. package/starter/forest/render/props/propProgress.ts +2 -0
  183. package/starter/forest/render/props/propWorld.ts +105 -0
  184. package/starter/forest/render/props/props.ts +624 -0
  185. package/starter/forest/render/props/spruce.ts +440 -0
  186. package/starter/forest/render/sky/atmosphere.ts +329 -0
  187. package/starter/forest/render/sky/sky.ts +382 -0
  188. package/starter/forest/render/texturePreparation.ts +135 -0
  189. package/starter/forest/render/water/river.ts +1132 -0
  190. package/starter/forest/render/worldNames.ts +6 -0
  191. package/starter/forest/scene.ts +715 -0
  192. package/starter/forest/sceneProps.ts +559 -0
  193. package/starter/forest/sceneState.ts +33 -0
  194. package/starter/forest/surface.json +2 -2
  195. package/starter/forest/world/terrainAssets.ts +158 -0
  196. package/starter/forest/world/walkBand.ts +47 -0
  197. package/starter/forest/world/water.ts +74 -0
  198. package/starter/forest/worlds.ts +13 -0
  199. package/starter/tundra/README.md +35 -14
  200. package/starter/tundra/bake.mjs +14 -1
  201. package/starter/tundra/biome.data.json +6 -6
  202. package/starter/tundra/playerRig.ts +89 -0
  203. package/starter/tundra/recipe.json +111 -110
  204. package/starter/tundra/render/bakedFile.ts +17 -0
  205. package/starter/tundra/render/benchmark.ts +79 -0
  206. package/starter/tundra/render/biomeData.ts +14 -0
  207. package/starter/tundra/render/biomes.ts +714 -0
  208. package/starter/tundra/render/ground/cover.ts +565 -0
  209. package/starter/tundra/render/ground/horizon.ts +219 -0
  210. package/starter/tundra/render/ground/palette.d.ts +1 -0
  211. package/starter/tundra/render/ground/palette.js +11 -0
  212. package/starter/tundra/render/ground/scatter.ts +104 -0
  213. package/starter/tundra/render/ground/terrain.ts +1874 -0
  214. package/starter/tundra/render/kitAssets.ts +28 -0
  215. package/starter/tundra/render/loading.ts +354 -0
  216. package/starter/tundra/render/lookKnobs.ts +37 -0
  217. package/starter/tundra/render/orbitCamera.ts +155 -0
  218. package/starter/tundra/render/props/farForest.ts +96 -0
  219. package/starter/tundra/render/props/pack.ts +1088 -0
  220. package/starter/tundra/render/props/prepared.ts +225 -0
  221. package/starter/tundra/render/props/propMaterials.ts +1247 -0
  222. package/starter/tundra/render/props/propProgress.ts +2 -0
  223. package/starter/tundra/render/props/propWorld.ts +105 -0
  224. package/starter/tundra/render/props/props.ts +624 -0
  225. package/starter/tundra/render/props/spruce.ts +440 -0
  226. package/starter/tundra/render/sky/atmosphere.ts +329 -0
  227. package/starter/tundra/render/sky/sky.ts +382 -0
  228. package/starter/tundra/render/texturePreparation.ts +135 -0
  229. package/starter/tundra/render/water/river.ts +1132 -0
  230. package/starter/tundra/render/worldNames.ts +6 -0
  231. package/starter/tundra/scene.ts +715 -0
  232. package/starter/tundra/sceneProps.ts +559 -0
  233. package/starter/tundra/sceneState.ts +33 -0
  234. package/starter/tundra/world/terrainAssets.ts +159 -0
  235. package/starter/tundra/world/walkBand.ts +47 -0
  236. package/starter/tundra/world/water.ts +74 -0
  237. package/starter/tundra/worlds.ts +13 -0
  238. package/starter-assets.json +4 -4
  239. package/starter-credits.json +901 -15
  240. package/AGENT_GUIDE.md +0 -209
  241. package/starter/forest/sky.ts +0 -38
  242. package/starter/forest/water.ts +0 -257
  243. package/starter/forest/world.ts +0 -182
@@ -0,0 +1,89 @@
1
+ import type { Heightfield } from "@threenative/core/world";
2
+ import {
3
+ type IMannequin,
4
+ type IPlayerRig,
5
+ type PlayerWallProbe,
6
+ createPlayerRig as createRig,
7
+ } from "@threenative/terrain/starter";
8
+ import { type AnimationClip, Vector3 } from "three";
9
+ import { CAMERA_RIG, type WallProbe, createOrbitCamera } from "./render/orbitCamera.js";
10
+ import { SIGHT_RADIUS, sightLine } from "./render/props/pack.js";
11
+ import type { TerrainCtx } from "./sceneState.js";
12
+
13
+ export type { IMannequin, IPlayerRig };
14
+ export type { WallProbe };
15
+
16
+ /** The starter kit's mannequin (Quaternius Universal Animation Library, CC0) and its clips. */
17
+ const CLIPS = {
18
+ idle: "Idle_Loop",
19
+ walk: "Walk_Loop",
20
+ run: "Jog_Fwd_Loop",
21
+ fall: "Jump_Loop",
22
+ swim: "Swim_Fwd_Loop",
23
+ tread: "Swim_Idle_Loop",
24
+ } as const;
25
+ /** Ground speeds in m/s: the walk clip's pace, the jog, and the Shift sprint. */
26
+ const STRIDE = 1.8;
27
+ const JOG = 6;
28
+ const SPRINT = 9;
29
+
30
+ export interface IPlayerRigOptions {
31
+ readonly world: string;
32
+ /** The player's launch point, in world metres. */
33
+ readonly at: readonly [number, number];
34
+ /** Where the launch camera stands relative to the player: above the ground under the spawn. */
35
+ readonly cameraOffset: readonly [number, number, number];
36
+ /** The ground the spawn stands on: the launch pose is measured from it, not guessed. */
37
+ readonly field: Heightfield;
38
+ readonly mannequin: IMannequin;
39
+ /** The rig's two swim clips, which the mannequin's own clips do not carry. */
40
+ readonly swimClips: readonly AnimationClip[];
41
+ /** A staged world streams its own ground, so the player walks only while the player view draws. */
42
+ readonly staged: boolean;
43
+ /** A vista look frames the player from a fixed aim instead of the orbit camera. */
44
+ readonly vista: boolean;
45
+ /** Centres the sun's shadow pages, or clears them when no player framing draws. */
46
+ readonly focusShadows: (at: Vector3 | undefined) => void;
47
+ /** The horizon seam the scene draws under the player, for the scene picker's report. */
48
+ readonly horizon: () => unknown;
49
+ }
50
+
51
+ /**
52
+ * The player: the package's capsule and clip state machine, this kit's mannequin, gait data and
53
+ * orbit camera. The follow camera and the wall probe stay here because the arm's framing and the
54
+ * sight line are look decisions of this game.
55
+ */
56
+ export function createPlayerRig(ctx: TerrainCtx, options: IPlayerRigOptions): IPlayerRig {
57
+ const { at, cameraOffset, field, focusShadows, horizon, mannequin, staged, swimClips, vista } =
58
+ options;
59
+ // The terrain and the prop colliders are the camera's walls; both answer on the kit's ground lens.
60
+ const along = new Vector3();
61
+ const probe: WallProbe = (from, to) =>
62
+ along.subVectors(to, from).lengthSq() < 1e-8
63
+ ? undefined
64
+ : ctx.physics.directSpaceState.intersectRay({
65
+ ...(staged ? {} : { collisionMask: 4 }),
66
+ from,
67
+ to,
68
+ })?.distance;
69
+ const camera = createOrbitCamera(ctx.camera);
70
+ return createRig({
71
+ ctx,
72
+ at,
73
+ field,
74
+ mannequin,
75
+ clips: CLIPS,
76
+ swimClips,
77
+ cameraOffset,
78
+ collisionMask: staged ? undefined : 4,
79
+ gait: { stride: STRIDE, run: JOG, sprint: SPRINT },
80
+ camera,
81
+ probe: probe as PlayerWallProbe,
82
+ following: () => !vista && ctx.state.getState().view === "player",
83
+ aimHeight: CAMERA_RIG.aimHeight,
84
+ // The vision line the camera aims: the player's own eye line at the prop pack's sight radius.
85
+ sight: { aim: sightLine.aim, radius: sightLine.radius, radiusValue: SIGHT_RADIUS },
86
+ focusShadows,
87
+ horizon,
88
+ });
89
+ }
@@ -63,11 +63,11 @@
63
63
  "mask": {
64
64
  "type": "noise",
65
65
  "scale": 78,
66
- "threshold": 0.42,
66
+ "threshold": 0.52,
67
67
  "seed": 73,
68
68
  "fade": 0.32
69
69
  },
70
- "strength": 0.9
70
+ "strength": 0.5
71
71
  },
72
72
  {
73
73
  "material": "rock",
@@ -77,28 +77,6 @@
77
77
  "max": 90,
78
78
  "fade": 9
79
79
  }
80
- },
81
- {
82
- "material": "moss",
83
- "mask": {
84
- "type": "and",
85
- "masks": [
86
- {
87
- "type": "noise",
88
- "scale": 32,
89
- "threshold": 0.6,
90
- "seed": 89,
91
- "fade": 0.22
92
- },
93
- {
94
- "type": "slope",
95
- "min": 10,
96
- "max": 90,
97
- "fade": 5
98
- }
99
- ]
100
- },
101
- "strength": 0.85
102
80
  }
103
81
  ]
104
82
  }
@@ -111,9 +89,21 @@
111
89
  "params": {
112
90
  "followTerrain": true,
113
91
  "points": [
114
- [-240, null, -185],
115
- [-150, null, -185],
116
- [-125, null, -185]
92
+ [
93
+ -240,
94
+ null,
95
+ -185
96
+ ],
97
+ [
98
+ -150,
99
+ null,
100
+ -185
101
+ ],
102
+ [
103
+ -125,
104
+ null,
105
+ -185
106
+ ]
117
107
  ],
118
108
  "width": 6,
119
109
  "shoulder": 4
@@ -125,18 +115,38 @@
125
115
  "id": "building-pad",
126
116
  "type": "flatten",
127
117
  "params": {
128
- "at": [-160, -180],
118
+ "at": [
119
+ -160,
120
+ -180
121
+ ],
129
122
  "radius": 12,
130
123
  "falloff": 0.75
131
124
  }
132
125
  },
126
+ {
127
+ "enabled": true,
128
+ "opacity": 1,
129
+ "id": "pad-surface",
130
+ "type": "paint",
131
+ "params": {
132
+ "at": [
133
+ -160,
134
+ -180
135
+ ],
136
+ "radius": 12,
137
+ "material": "dirt"
138
+ }
139
+ },
133
140
  {
134
141
  "enabled": true,
135
142
  "opacity": 1,
136
143
  "id": "lake-bed",
137
144
  "type": "flatten",
138
145
  "params": {
139
- "at": [-70, 25],
146
+ "at": [
147
+ -70,
148
+ 25
149
+ ],
140
150
  "radius": 105,
141
151
  "height": 11.4,
142
152
  "falloff": 0.1
@@ -156,11 +166,31 @@
156
166
  "params": {
157
167
  "followTerrain": true,
158
168
  "points": [
159
- [-120, null, -220],
160
- [-110, null, -175],
161
- [-120, null, -130],
162
- [-100, null, -95],
163
- [-70, null, -60]
169
+ [
170
+ -120,
171
+ null,
172
+ -220
173
+ ],
174
+ [
175
+ -110,
176
+ null,
177
+ -175
178
+ ],
179
+ [
180
+ -120,
181
+ null,
182
+ -130
183
+ ],
184
+ [
185
+ -100,
186
+ null,
187
+ -95
188
+ ],
189
+ [
190
+ -70,
191
+ null,
192
+ -60
193
+ ]
164
194
  ],
165
195
  "width": 7,
166
196
  "depth": 1.8,
@@ -175,7 +205,10 @@
175
205
  "type": "water",
176
206
  "params": {
177
207
  "kind": "lake",
178
- "at": [-70, 25],
208
+ "at": [
209
+ -70,
210
+ 25
211
+ ],
179
212
  "radius": 105,
180
213
  "level": 13.3
181
214
  }
@@ -191,7 +224,10 @@
191
224
  "minDistance": 3.8,
192
225
  "maxSlope": 32,
193
226
  "avoidWater": true,
194
- "scale": [0.6, 1.45]
227
+ "scale": [
228
+ 0.55,
229
+ 1
230
+ ]
195
231
  },
196
232
  "mask": {
197
233
  "type": "noise",
@@ -210,7 +246,10 @@
210
246
  "minDistance": 4.2,
211
247
  "maxSlope": 32,
212
248
  "avoidWater": true,
213
- "scale": [0.7, 1.3]
249
+ "scale": [
250
+ 0.55,
251
+ 1
252
+ ]
214
253
  },
215
254
  "mask": {
216
255
  "type": "noise",
@@ -229,7 +268,10 @@
229
268
  "minDistance": 3,
230
269
  "maxSlope": 32,
231
270
  "avoidWater": true,
232
- "scale": [0.3, 0.62]
271
+ "scale": [
272
+ 0.2,
273
+ 0.45
274
+ ]
233
275
  },
234
276
  "mask": {
235
277
  "type": "noise",
@@ -251,7 +293,10 @@
251
293
  "minSlope": 4,
252
294
  "maxSlope": 60,
253
295
  "avoidWater": true,
254
- "scale": [0.5, 2.2]
296
+ "scale": [
297
+ 0.5,
298
+ 2.2
299
+ ]
255
300
  },
256
301
  "mask": {
257
302
  "type": "noise",
@@ -272,7 +317,10 @@
272
317
  "minDistance": 1.4,
273
318
  "maxSlope": 28,
274
319
  "avoidWater": true,
275
- "scale": [0.9, 1.6]
320
+ "scale": [
321
+ 0.9,
322
+ 1.6
323
+ ]
276
324
  },
277
325
  "mask": {
278
326
  "type": "noise",
@@ -293,7 +341,10 @@
293
341
  "minDistance": 1.4,
294
342
  "maxSlope": 28,
295
343
  "avoidWater": true,
296
- "scale": [0.8, 1.5]
344
+ "scale": [
345
+ 0.8,
346
+ 1.5
347
+ ]
297
348
  },
298
349
  "mask": {
299
350
  "type": "noise",
@@ -314,7 +365,10 @@
314
365
  "minDistance": 2.5,
315
366
  "maxSlope": 50,
316
367
  "avoidWater": true,
317
- "scale": [0.12, 0.3]
368
+ "scale": [
369
+ 0.12,
370
+ 0.3
371
+ ]
318
372
  },
319
373
  "mask": {
320
374
  "type": "noise",
@@ -335,7 +389,10 @@
335
389
  "minDistance": 2.5,
336
390
  "maxSlope": 50,
337
391
  "avoidWater": true,
338
- "scale": [0.12, 0.3]
392
+ "scale": [
393
+ 0.12,
394
+ 0.3
395
+ ]
339
396
  },
340
397
  "mask": {
341
398
  "type": "noise",
@@ -346,5 +403,138 @@
346
403
  }
347
404
  }
348
405
  ]
406
+ },
407
+ "world": {
408
+ "name": "forest",
409
+ "ground": {
410
+ "base": "grass",
411
+ "layers": [
412
+ "dirt",
413
+ "moss",
414
+ "sand",
415
+ "rock",
416
+ "snow"
417
+ ],
418
+ "roughness": 0.95
419
+ },
420
+ "farRing": {
421
+ "survey": "forest-horizon",
422
+ "backdrop": {
423
+ "id": "usgs-surroundings",
424
+ "landform": "temperateMountains",
425
+ "seed": 23,
426
+ "relief": 865
427
+ },
428
+ "seed": 1,
429
+ "layers": [
430
+ {
431
+ "enabled": true,
432
+ "opacity": 1,
433
+ "id": "crests",
434
+ "type": "noise",
435
+ "params": {
436
+ "mode": "ridged",
437
+ "amplitude": 170,
438
+ "scale": 1100,
439
+ "octaves": 3,
440
+ "warp": 300
441
+ },
442
+ "mask": {
443
+ "type": "height",
444
+ "min": 320,
445
+ "max": 1000000000,
446
+ "fade": 200
447
+ }
448
+ },
449
+ {
450
+ "enabled": true,
451
+ "opacity": 1,
452
+ "id": "spurs",
453
+ "type": "noise",
454
+ "params": {
455
+ "mode": "fbm",
456
+ "amplitude": 45,
457
+ "scale": 320,
458
+ "octaves": 3,
459
+ "warp": 150
460
+ },
461
+ "mask": {
462
+ "type": "height",
463
+ "min": 200,
464
+ "max": 1000000000,
465
+ "fade": 80
466
+ }
467
+ },
468
+ {
469
+ "enabled": true,
470
+ "opacity": 1,
471
+ "id": "gullies",
472
+ "type": "erode",
473
+ "params": {
474
+ "method": "hydraulic",
475
+ "droplets": 40000
476
+ },
477
+ "mask": {
478
+ "type": "height",
479
+ "min": 380,
480
+ "max": 1000000000,
481
+ "fade": 160
482
+ }
483
+ }
484
+ ],
485
+ "massif": {
486
+ "tiles": [
487
+ "longs",
488
+ "teton",
489
+ "maroon"
490
+ ],
491
+ "seed": 6,
492
+ "at": [
493
+ -2050,
494
+ -150
495
+ ],
496
+ "face": 90,
497
+ "keepOut": 650,
498
+ "top": [
499
+ 1100,
500
+ 1160
501
+ ]
502
+ }
503
+ },
504
+ "art": [
505
+ "bark_brown_02",
506
+ "boulder_01",
507
+ "celandine_01",
508
+ "dandelion_01",
509
+ "dead_tree_trunk",
510
+ "dry_branches_medium_01",
511
+ "fern_02",
512
+ "forest_ground_04",
513
+ "grass_medium",
514
+ "leafy_grass",
515
+ "lichen_rock",
516
+ "moss_01",
517
+ "mossy_rock",
518
+ "nettle_plant",
519
+ "periwinkle_plant",
520
+ "river_small_rocks",
521
+ "rock_boulder_dry",
522
+ "rock_face",
523
+ "rocks",
524
+ "sand_01",
525
+ "shrub_02",
526
+ "shrub_04",
527
+ "snow_02",
528
+ "tree_small_02",
529
+ "tree_stump_01",
530
+ "weed_plant_02",
531
+ "needle-atlas.png",
532
+ "needle-surface.png",
533
+ "fir_tree_01/fir_tree_01_twig_arm_1k.jpg",
534
+ "fir_tree_01/fir_tree_01_twig_diff_1k.jpg",
535
+ "fir_tree_01/fir_tree_01_twig_nor_gl_1k.jpg",
536
+ "hdri/kloofendal_48d_partly_cloudy_2k.hdr",
537
+ "mannequin-swim.glb"
538
+ ]
349
539
  }
350
540
  }
@@ -0,0 +1,17 @@
1
+ import { type IAssetLoader, fetchAsset } from "@threenative/core";
2
+
3
+ /**
4
+ * One baked file under `world/`, from the first root the asset loader resolves that serves it
5
+ * (core `fetchAsset`). A miss on every root fails closed, naming the file the world is missing.
6
+ */
7
+ export async function fetchBakedFile(
8
+ assets: Pick<IAssetLoader, "resolve">,
9
+ path: string,
10
+ what = "world file",
11
+ ): Promise<Response> {
12
+ try {
13
+ return await fetchAsset(assets, path);
14
+ } catch (error) {
15
+ throw new Error(`Missing baked ${what}: ${path}`, { cause: error });
16
+ }
17
+ }
@@ -0,0 +1,77 @@
1
+ import type { WorldName } from "./biomes.js";
2
+
3
+ /**
4
+ * The fixed benchmark framings, in world metres, per world.
5
+ *
6
+ * Fixed rather than relative to the player so a capture at seed 73 is the same picture on every
7
+ * machine, and so the rubric's "close ground/vegetation view" and "landscape overview" are two
8
+ * numbers rather than two moods. `eye` is the height above the terrain under the camera, which is
9
+ * what makes "eye height ~1.7 m" true on a slope instead of true only on a flat.
10
+ *
11
+ * The meadow focus is where the ground is grass with spruces on it and a slope to look along, and
12
+ * it is also where the dense grass goes: ground cover is placed around this point, not around the
13
+ * origin, because a meadow is a place rather than a texture.
14
+ */
15
+
16
+ /** Every framing the `V` key can hold, whether or not the current world has one for it. */
17
+ export type ViewName = "meadow-close" | "overview" | "player" | "river" | "vista";
18
+
19
+ interface IBenchmarkPose {
20
+ /** World x and z of the eye, and the height above the terrain under it. */
21
+ readonly at: readonly [number, number];
22
+ readonly eye: number;
23
+ /** Absolute elevation for an overview over surveyed scenery beyond the playable collider. */
24
+ readonly eyeY?: number;
25
+ /** World x and z to look at, and the height above the terrain under *that*. */
26
+ readonly look: readonly [number, number];
27
+ readonly lookUp: number;
28
+ /**
29
+ * An absolute world height to look at instead, for a target with no ground under it: a sea
30
+ * horizon is a direction, and thirty metres below the surface three hundred metres out is how a
31
+ * hillside tips its view down far enough for the water to be a band rather than a line.
32
+ */
33
+ readonly lookY?: number;
34
+ }
35
+
36
+ interface IBenchmark {
37
+ /**
38
+ * The playable square the poses frame, in metres. A cooked world of another size
39
+ * (`STRATA_WORLD`, "a huge spruce forest") scales them, so the vista still stands past its edge.
40
+ */
41
+ readonly size?: number;
42
+ /** Where this world's ground cover is placed. */
43
+ readonly focus: { readonly x: number; readonly z: number };
44
+ readonly poses: Readonly<Record<string, IBenchmarkPose>>;
45
+ /** The order the `V` key walks, and the framings the playtest screenshots. */
46
+ readonly views: readonly ViewName[];
47
+ }
48
+
49
+ export const BENCHMARK: Record<WorldName, IBenchmark> = {
50
+ forest: {
51
+ size: 512,
52
+ focus: { x: 150, z: -100 },
53
+ poses: {
54
+ "meadow-close": { at: [165, -95], eye: 1.7, look: [-70, -180], lookUp: 2.2 },
55
+ overview: { at: [190, 170], eye: 65, look: [-70, 25], lookUp: 5 },
56
+ river: { at: [-145, -120], eye: 1.7, look: [-110, -185], lookUp: 0 },
57
+ // The look goal's frame: from the hillside north-east of the lake, over the lake and the
58
+ // forest to the high backdrop peaks south-west (bearing 210-240 degrees, 0.5-0.7 km tall).
59
+ vista: { at: [360, 200], eye: 0, eyeY: 71, look: [-900, -700], lookUp: 0, lookY: 90 },
60
+ },
61
+ views: ["player", "meadow-close", "overview", "river", "vista"],
62
+ },
63
+ };
64
+
65
+ /** A world's poses for a square of `size` metres: x and z scale with it, heights do not. */
66
+ export function posesFor(world: WorldName, size: number): Readonly<Record<string, IBenchmarkPose>> {
67
+ const { poses, size: framed } = BENCHMARK[world];
68
+ const k = framed === undefined ? 1 : size / framed;
69
+ if (k === 1) return poses;
70
+ const scaled = ([x, z]: readonly [number, number]) => [x * k, z * k] as const;
71
+ return Object.fromEntries(
72
+ Object.entries(poses).map(([name, pose]) => [
73
+ name,
74
+ { ...pose, at: scaled(pose.at), look: scaled(pose.look) },
75
+ ]),
76
+ );
77
+ }
@@ -0,0 +1,14 @@
1
+ import type { IBiomeSpec } from "@threenative/terrain";
2
+ import forest from "../biome.data.json";
3
+ import type { WorldName } from "./biomes.js";
4
+
5
+ /**
6
+ * The forest's biome file (`biome.data.json`): the rules it grows by. The bake validates it with
7
+ * `validateBiome` before it places anything, so the game reads it as data and ships no validator.
8
+ */
9
+ const FOREST_SPEC = forest as unknown as IBiomeSpec;
10
+
11
+ /** The world's rules. */
12
+ export function biomeSpec(_world?: WorldName): IBiomeSpec {
13
+ return FOREST_SPEC;
14
+ }