@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
@@ -9,57 +9,198 @@
9
9
  "seed": 41,
10
10
  "stream": "ordered",
11
11
  "cover": {
12
- "ground": "crag",
12
+ "ground": "wood",
13
13
  "seed": 466468,
14
14
  "attempts": 80000,
15
15
  "stoneRadius": 1.9,
16
16
  "clearings": [[850, -1000, 10]],
17
17
  "understorey": {
18
- "attempts": 14000,
19
- "litter": 1,
20
- "fern": 1,
21
- "bush": 1,
22
- "flower": 1,
23
- "deadfall": 0,
24
- "shade": 0,
25
- "shadeRadius": 3
18
+ "attempts": 120000,
19
+ "litter": 1.6,
20
+ "fern": 0.6,
21
+ "bush": 0.6,
22
+ "flower": 1.4,
23
+ "deadfall": 1.5,
24
+ "shade": 0.8,
25
+ "shadeRadius": 1.2
26
26
  }
27
27
  },
28
28
  "foliage": [
29
29
  {
30
30
  "species": "spruce",
31
- "density": 0,
32
- "slope": [0, 32],
33
- "height": [0, 52],
34
- "spacing": [3.4, 3.4],
31
+ "density": 600,
32
+ "slope": [0, 34],
33
+ "height": [0, 40],
34
+ "spacing": [3.6, 7],
35
35
  "collision": "trunk",
36
- "stands": false,
37
- "grassThreshold": 0.18,
38
- "standThreshold": 0.42,
39
- "far": null
36
+ "stands": true,
37
+ "grassThreshold": 0.3,
38
+ "standThreshold": 0.18,
39
+ "far": {
40
+ "cell": 6,
41
+ "spacing": [7, 14],
42
+ "spacingAt": [150, 1200],
43
+ "slope": [30, 44],
44
+ "meadowSlope": [10, 22],
45
+ "reach": 1800,
46
+ "treelineJitter": 25,
47
+ "stand": [0.18, 0.32],
48
+ "seed": 466561,
49
+ "impostor": 95
50
+ }
51
+ },
52
+ {
53
+ "species": "scotspine",
54
+ "density": 1400,
55
+ "slope": [0, 40],
56
+ "height": [0, 30],
57
+ "spacing": [3.4, 6.4],
58
+ "collision": "trunk",
59
+ "stands": true,
60
+ "grassThreshold": 0.26,
61
+ "standThreshold": 0.2,
62
+ "far": {
63
+ "cell": 6,
64
+ "spacing": [7, 14],
65
+ "spacingAt": [150, 1200],
66
+ "slope": [30, 44],
67
+ "meadowSlope": [10, 22],
68
+ "reach": 1900,
69
+ "treelineJitter": 25,
70
+ "stand": [0.18, 0.32],
71
+ "seed": 466563,
72
+ "impostor": 105
73
+ }
74
+ },
75
+ {
76
+ "species": "blackspruce",
77
+ "density": 900,
78
+ "slope": [0, 30],
79
+ "height": [0, 26],
80
+ "spacing": [4.2, 8.2],
81
+ "collision": "trunk",
82
+ "stands": true,
83
+ "grassThreshold": 0.24,
84
+ "standThreshold": 0.22,
85
+ "far": {
86
+ "cell": 6,
87
+ "spacing": [7, 14],
88
+ "spacingAt": [150, 1200],
89
+ "slope": [30, 44],
90
+ "meadowSlope": [10, 22],
91
+ "reach": 1500,
92
+ "treelineJitter": 25,
93
+ "stand": [0.18, 0.32],
94
+ "seed": 466567,
95
+ "impostor": 85
96
+ }
40
97
  }
41
98
  ],
42
99
  "grass": [
43
100
  {
44
- "species": "grass",
45
- "density": 0,
46
- "slope": [0, 0],
101
+ "species": "tundragrass",
102
+ "density": 0.95,
103
+ "slope": [0, 42],
104
+ "height": null,
105
+ "spacing": 0.9,
106
+ "slopeFalloff": 0,
107
+ "heightFalloff": 28,
108
+ "mats": null,
109
+ "waterMargin": 7.5,
110
+ "beach": null,
111
+ "detailSpacing": 0.5,
112
+ "drift": {
113
+ "field": "stand",
114
+ "frequency": [2.1, 2.4],
115
+ "offset": 0,
116
+ "amplitude": 1,
117
+ "band": [0.25, 0.55]
118
+ },
119
+ "bladeScale": 0.5,
120
+ "bladeJitter": 0.5,
121
+ "scrubChance": 0.3,
122
+ "scrubScale": 0.9,
123
+ "scrubJitter": 0.6,
124
+ "scrubBush": false,
125
+ "shoreGround": false,
126
+ "cobbledBed": false
127
+ },
128
+ {
129
+ "species": "tussock",
130
+ "density": 0.6,
131
+ "slope": [0, 42],
47
132
  "height": null,
48
- "spacing": 3.5,
133
+ "spacing": 1.3,
49
134
  "slopeFalloff": 0,
50
135
  "heightFalloff": 28,
51
136
  "mats": null,
52
137
  "waterMargin": 7.5,
53
138
  "beach": null,
54
- "detailSpacing": 0.6,
139
+ "detailSpacing": 0.5,
55
140
  "drift": {
56
141
  "field": "stand",
57
142
  "frequency": [2.1, 2.4],
58
143
  "offset": 0,
59
144
  "amplitude": 1,
60
- "band": [0.3, 0.45]
145
+ "band": [0.2, 0.5]
61
146
  },
62
- "bladeScale": 0.55,
147
+ "bladeScale": 0.7,
148
+ "bladeJitter": 0.5,
149
+ "scrubChance": 0.3,
150
+ "scrubScale": 0.9,
151
+ "scrubJitter": 0.6,
152
+ "scrubBush": false,
153
+ "shoreGround": false,
154
+ "cobbledBed": false
155
+ },
156
+ {
157
+ "species": "fireweed",
158
+ "density": 0.22,
159
+ "slope": [0, 42],
160
+ "height": null,
161
+ "spacing": 1.6,
162
+ "slopeFalloff": 0,
163
+ "heightFalloff": 28,
164
+ "mats": null,
165
+ "waterMargin": 7.5,
166
+ "beach": null,
167
+ "detailSpacing": 0.5,
168
+ "drift": {
169
+ "field": "stand",
170
+ "frequency": [2.1, 2.4],
171
+ "offset": 0,
172
+ "amplitude": 1,
173
+ "band": [0.3, 0.6]
174
+ },
175
+ "bladeScale": 0.8,
176
+ "bladeJitter": 0.5,
177
+ "scrubChance": 0.3,
178
+ "scrubScale": 0.9,
179
+ "scrubJitter": 0.6,
180
+ "scrubBush": false,
181
+ "shoreGround": false,
182
+ "cobbledBed": false
183
+ },
184
+ {
185
+ "species": "blueberry",
186
+ "density": 0.3,
187
+ "slope": [0, 42],
188
+ "height": null,
189
+ "spacing": 1.2,
190
+ "slopeFalloff": 0,
191
+ "heightFalloff": 28,
192
+ "mats": null,
193
+ "waterMargin": 7.5,
194
+ "beach": null,
195
+ "detailSpacing": 0.5,
196
+ "drift": {
197
+ "field": "stand",
198
+ "frequency": [2.1, 2.4],
199
+ "offset": 0,
200
+ "amplitude": 1,
201
+ "band": [0.35, 0.65]
202
+ },
203
+ "bladeScale": 0.6,
63
204
  "bladeJitter": 0.5,
64
205
  "scrubChance": 0.3,
65
206
  "scrubScale": 0.9,
@@ -119,7 +260,28 @@
119
260
  "cameraOffset": [28, 24, 42],
120
261
  "focus": [180, -190]
121
262
  },
122
- "species": ["boulder", "grass", "mountain", "riverrock", "sapling", "scree", "scrub", "spruce"],
263
+ "species": [
264
+ "blackspruce",
265
+ "blueberry",
266
+ "boulder",
267
+ "bush",
268
+ "deadfall",
269
+ "fern",
270
+ "fireweed",
271
+ "grass",
272
+ "litter",
273
+ "mountain",
274
+ "poppy",
275
+ "riverrock",
276
+ "rock",
277
+ "sapling",
278
+ "scotspine",
279
+ "scree",
280
+ "scrub",
281
+ "spruce",
282
+ "tundragrass",
283
+ "tussock"
284
+ ],
123
285
  "aliases": [
124
286
  "alpine",
125
287
  "mountain",
Binary file
@@ -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
+ }
@@ -59,20 +59,24 @@
59
59
  "params": {
60
60
  "rules": [
61
61
  {
62
- "material": "rock",
62
+ "material": "dirt",
63
63
  "mask": {
64
- "type": "all"
65
- }
64
+ "type": "noise",
65
+ "scale": 78,
66
+ "threshold": 0.55,
67
+ "seed": 41,
68
+ "fade": 0.32
69
+ },
70
+ "strength": 0.4
66
71
  },
67
72
  {
68
- "material": "dirt",
73
+ "material": "rock",
69
74
  "mask": {
70
75
  "type": "slope",
71
- "min": 20,
72
- "max": 38,
73
- "fade": 6
74
- },
75
- "strength": 0.4
76
+ "min": 32,
77
+ "max": 90,
78
+ "fade": 8
79
+ }
76
80
  },
77
81
  {
78
82
  "material": "snow",
@@ -81,9 +85,9 @@
81
85
  "masks": [
82
86
  {
83
87
  "type": "height",
84
- "min": 80,
88
+ "min": 800,
85
89
  "max": 1000000000,
86
- "fade": 60
90
+ "fade": 120
87
91
  },
88
92
  {
89
93
  "type": "slope",
@@ -108,12 +112,162 @@
108
112
  "minDistance": 6,
109
113
  "minSlope": 15,
110
114
  "maxSlope": 45,
111
- "scale": [
112
- 0.6,
113
- 1.6
114
- ]
115
+ "scale": [0.6, 1.6]
115
116
  }
116
117
  }
117
118
  ]
119
+ },
120
+ "world": {
121
+ "name": "alpine",
122
+ "ground": {
123
+ "base": "grass",
124
+ "layers": ["dirt", "moss", "sand", "rock", "snow"],
125
+ "roughness": 0.95
126
+ },
127
+ "art": [
128
+ "boulder_01",
129
+ "rock_face",
130
+ "rock_boulder_dry",
131
+ "rocks",
132
+ "river_small_rocks",
133
+ "cliff_side",
134
+ "snow_02",
135
+ "grass_medium",
136
+ "leafy_grass",
137
+ "lichen_rock",
138
+ "mossy_rock",
139
+ "shrub_02",
140
+ "hdri/kloofendal_48d_partly_cloudy_1k.hdr",
141
+ "mannequin-swim.glb",
142
+ "bark_brown_02",
143
+ "celandine_01",
144
+ "dandelion_01",
145
+ "dead_tree_trunk",
146
+ "dry_branches_medium_01",
147
+ "fern_02",
148
+ "forest_ground_04",
149
+ "moss_01",
150
+ "nettle_plant",
151
+ "periwinkle_plant",
152
+ "sand_01",
153
+ "shrub_04",
154
+ "tree_stump_01",
155
+ "weed_plant_02",
156
+ "needle-atlas.png",
157
+ "needle-surface.png",
158
+ "hdri/kloofendal_48d_partly_cloudy_2k.hdr"
159
+ ],
160
+ "farRing": {
161
+ "survey": "alpine-horizon",
162
+ "datum": 1969,
163
+ "seed": 1,
164
+ "layers": []
165
+ },
166
+ "arbor": {
167
+ "alpine_flora/spruce-a": {
168
+ "preset": "spruce",
169
+ "seed": 1,
170
+ "lods": {
171
+ "1": "-near",
172
+ "2": "-mid"
173
+ },
174
+ "form": {
175
+ "levels": [
176
+ {
177
+ "kids": 104
178
+ },
179
+ {
180
+ "len": 0.25
181
+ }
182
+ ],
183
+ "leaves": [
184
+ {
185
+ "count": 56,
186
+ "size": [0.62, 0.38]
187
+ }
188
+ ]
189
+ }
190
+ },
191
+ "alpine_flora/spruce-b": {
192
+ "preset": "spruce",
193
+ "seed": 2,
194
+ "lods": {
195
+ "1": "-near",
196
+ "2": "-mid"
197
+ },
198
+ "form": {
199
+ "levels": [
200
+ {
201
+ "kids": 104
202
+ },
203
+ {
204
+ "len": 0.25
205
+ }
206
+ ],
207
+ "leaves": [
208
+ {
209
+ "count": 56,
210
+ "size": [0.62, 0.38]
211
+ }
212
+ ]
213
+ }
214
+ },
215
+ "alpine_flora/spruce-c": {
216
+ "preset": "spruce",
217
+ "seed": 3,
218
+ "lods": {
219
+ "1": "-near",
220
+ "2": "-mid"
221
+ },
222
+ "form": {
223
+ "levels": [
224
+ {
225
+ "kids": 104
226
+ },
227
+ {
228
+ "len": 0.25
229
+ }
230
+ ],
231
+ "leaves": [
232
+ {
233
+ "count": 56,
234
+ "size": [0.62, 0.38]
235
+ }
236
+ ]
237
+ }
238
+ },
239
+ "alpine_flora/blackspruce-a": {
240
+ "preset": "blackspruce",
241
+ "seed": 1,
242
+ "lods": {
243
+ "1": "-near",
244
+ "2": "-mid"
245
+ },
246
+ "form": {
247
+ "leaves": [
248
+ {
249
+ "count": 22,
250
+ "size": [0.46, 0.33]
251
+ }
252
+ ]
253
+ }
254
+ },
255
+ "alpine_flora/blackspruce-b": {
256
+ "preset": "blackspruce",
257
+ "seed": 2,
258
+ "lods": {
259
+ "1": "-near",
260
+ "2": "-mid"
261
+ },
262
+ "form": {
263
+ "leaves": [
264
+ {
265
+ "count": 22,
266
+ "size": [0.46, 0.33]
267
+ }
268
+ ]
269
+ }
270
+ }
271
+ }
118
272
  }
119
273
  }
@@ -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
+ alpine: {
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
+ // Kleine Scheidegg's postcard: from the pasture's north-west corner across the pass to the
58
+ // Eiger's west flank and north face (bearing about 125 degrees, 1.3-1.9 km above the eye).
59
+ vista: { at: [-200, -200], eye: 0, eyeY: 100, look: [2200, 1400], lookUp: 0, lookY: 500 },
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 ALPINE_SPEC = forest as unknown as IBiomeSpec;
10
+
11
+ /** The world's rules. */
12
+ export function biomeSpec(_world?: WorldName): IBiomeSpec {
13
+ return ALPINE_SPEC;
14
+ }