@threenative/terrain 0.1.8 → 0.1.9

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 (37) hide show
  1. package/dist/editor/index.d.ts +63 -5
  2. package/dist/editor/index.js +323 -6
  3. package/dist/editor/server.d.ts +2 -2
  4. package/dist/editor/server.js +198 -4
  5. package/dist/editor/worker.d.ts +1 -1
  6. package/dist/editor/worker.js +199 -5
  7. package/dist/export.d.ts +1 -1
  8. package/dist/index.d.ts +146 -7
  9. package/dist/index.js +638 -39
  10. package/dist/kit.d.ts +3 -2
  11. package/dist/kit.js +198 -4
  12. package/dist/mcp/cook-child.js +1766 -125
  13. package/dist/mcp/server.js +728 -37
  14. package/dist/{server-C8Ydr_IM.d.ts → server-B5RdvEAC.d.ts} +1 -1
  15. package/dist/starter.d.ts +1 -1
  16. package/dist/starter.js +2 -1
  17. package/dist/{terrain-B3DkduPw.d.ts → terrain-CAEaW0mQ.d.ts} +1 -1
  18. package/dist/three.d.ts +1 -1
  19. package/dist/{types-CPYAc9vo.d.ts → types-BpH00qsx.d.ts} +10 -3
  20. package/dist/{world-package-B7KGYIou.d.ts → world-package-B8QgHjAQ.d.ts} +9 -50
  21. package/package.json +5 -5
  22. package/starter/alpine/biome.data.json +22 -2
  23. package/starter/alpine/world.ts +1 -1
  24. package/starter/coastal/README.md +5 -2
  25. package/starter/coastal/assets.json +2 -1
  26. package/starter/coastal/biome.data.json +23 -2
  27. package/starter/coastal/sea.ts +2 -50
  28. package/starter/desert/biome.data.json +12 -2
  29. package/starter/desert/world.ts +1 -1
  30. package/starter/forest/README.md +1 -1
  31. package/starter/forest/assets.json +2 -1
  32. package/starter/forest/biome.data.json +37 -14
  33. package/starter/forest/water.ts +9 -28
  34. package/starter/forest/world.ts +6 -1
  35. package/starter/tundra/biome.data.json +12 -2
  36. package/starter/tundra/water.ts +9 -28
  37. package/starter/tundra/world.ts +1 -1
@@ -6,7 +6,7 @@
6
6
  // the shore are this file's to change: the kit owns its look.
7
7
  import type { ICtx } from "@threenative/core";
8
8
  import { WaterSurface3D } from "@threenative/core";
9
- import type { Heightfield } from "@threenative/core/world";
9
+ import { type Heightfield, riverRibbonGeometry } from "@threenative/core/world";
10
10
  import type { IPhysicsContext } from "@threenative/physics";
11
11
  import {
12
12
  BufferAttribute,
@@ -236,32 +236,6 @@ function lakeMaterial(surface: WaterSurface3D): MeshBasicNodeMaterial {
236
236
  return material;
237
237
  }
238
238
 
239
- /** A ribbon along the river's profile: each point's left and right edge across the course. */
240
- function riverGeometry(river: IRiver): BufferGeometry {
241
- const half = river.width / 2;
242
- const positions: number[] = [];
243
- const indices: number[] = [];
244
- river.points.forEach(([x, y, z], i) => {
245
- const before = river.points[Math.max(0, i - 1)] ?? [x, y, z];
246
- const after = river.points[Math.min(river.points.length - 1, i + 1)] ?? [x, y, z];
247
- const tx = after[0] - before[0];
248
- const tz = after[2] - before[2];
249
- const length = Math.hypot(tx, tz) || 1;
250
- const sx = (-tz / length) * half;
251
- const sz = (tx / length) * half;
252
- positions.push(x + sx, y + RIVER_LIFT, z + sz, x - sx, y + RIVER_LIFT, z - sz);
253
- if (i > 0) {
254
- const a = 2 * (i - 1);
255
- const b = 2 * i;
256
- indices.push(a, b, a + 1, b, b + 1, a + 1);
257
- }
258
- });
259
- const geometry = new BufferGeometry();
260
- geometry.setAttribute("position", new BufferAttribute(new Float32Array(positions), 3));
261
- geometry.setIndex(indices);
262
- return geometry;
263
- }
264
-
265
239
  /**
266
240
  * Adds the lake and river the bake wrote. `field` is the ground the props and the colliders stand on.
267
241
  * The caller owns the returned handle: its `dispose` removes both meshes and releases each surface.
@@ -295,7 +269,14 @@ export function addTundraWater(
295
269
  opacity: 0.9,
296
270
  side: DoubleSide,
297
271
  });
298
- meshes.push(new Mesh(riverGeometry(river), material));
272
+ // One channel width across, out a half width past each end where the bed is carved; dry
273
+ // quads drop, so the water ends at the bank (core `riverRibbonGeometry`).
274
+ const mesh = new Mesh(
275
+ riverRibbonGeometry([river], field, { reach: 0.5, columns: 3 }),
276
+ material,
277
+ );
278
+ mesh.position.y = RIVER_LIFT;
279
+ meshes.push(mesh);
299
280
  }
300
281
  for (const mesh of meshes) ctx.add(mesh);
301
282
  return {
@@ -62,7 +62,7 @@ const spec: IStarterWorldSpec<{
62
62
  url,
63
63
  table: surface as unknown as ILoadTerrainSplatOptions["table"],
64
64
  }),
65
- lighting: { sky: "sky.hdr", lods: false, dress: dressProp },
65
+ lighting: { sky: "sky.hdr", lods: true, dress: dressProp },
66
66
  streaming: {
67
67
  ring: 5,
68
68
  impostors: false,