incanto 0.26.0 → 0.27.0

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/dist/3d.d.ts CHANGED
@@ -1590,7 +1590,18 @@ interface PathSample {
1590
1590
  }
1591
1591
  /** A cross-section station: where the water is, how wide, how fast. */
1592
1592
  interface RiverRing extends PathSample {
1593
+ /** The width the author ASKED for (half of it) — nominal, drives current. */
1593
1594
  halfWidth: number;
1595
+ /** Wetted half-width to the left of the flow: where the ground rises to the
1596
+ * surface. This, not {@link halfWidth}, is where the water actually ends. */
1597
+ halfLeft: number;
1598
+ /** Wetted half-width to the right of the flow. */
1599
+ halfRight: number;
1600
+ /** No bank on that side: the ground never came up to the surface, so the
1601
+ * water is spilling out over it rather than being held. The ribbon thins to
1602
+ * a film there instead of ending in a wall of water standing on nothing. */
1603
+ spillLeft: boolean;
1604
+ spillRight: boolean;
1594
1605
  /** Water surface height (local Y). */
1595
1606
  surfaceY: number;
1596
1607
  /** Downhill grade of the surface (dimensionless, ≥ 0). */
@@ -1706,6 +1717,18 @@ declare class River3D extends Node3D implements SunConsumer3D {
1706
1717
  sunIntensity: number;
1707
1718
  /** Drape target path; empty = auto-find the first Terrain3D in the tree. */
1708
1719
  terrain: string;
1720
+ /**
1721
+ * Cut the bed. Real water arrives on a hillside and erodes itself a channel;
1722
+ * a ribbon laid on raw ground has nothing holding it and reads as a strip of
1723
+ * blue hovering over the grass. With this on, the river trenches its own
1724
+ * course into the terrain it drapes on — banks the player can walk into, a
1725
+ * collider and `heightAt` that agree with it, and splat that paints the cut.
1726
+ *
1727
+ * Off means you carve it yourself with `Terrain3D.channels` (or the reach is
1728
+ * genuinely a flat flood plain). Either way the surface is FITTED to
1729
+ * whatever ground it finds: it can never stand above its own banks.
1730
+ */
1731
+ carve: boolean;
1709
1732
  /** How hard the current sweeps bodies downstream (0 = visual only). */
1710
1733
  flowForce: number;
1711
1734
  /**
@@ -1721,13 +1744,22 @@ declare class River3D extends Node3D implements SunConsumer3D {
1721
1744
  private sprayKey;
1722
1745
  private courseKey;
1723
1746
  private bedAt;
1747
+ /** Whether the last course was fitted to real ground (see buildRiverRings). */
1748
+ private fitted;
1749
+ /** Everything standing in the current, rescanned on a slow timer. */
1750
+ private rocks;
1751
+ private rockScanAt;
1724
1752
  private world;
1725
1753
  private readonly _bodies;
1726
1754
  /** Loader hook: a malformed river fails at LOAD, not as an invisible ribbon. */
1727
1755
  static validateJson(node: Node): void;
1728
1756
  protected override _createObject3D(): Object3D;
1757
+ override onReady(): void;
1758
+ override onExitTree(): void;
1729
1759
  override update(dt: number): void;
1730
1760
  override _syncObject3D(): void;
1761
+ /** Rocks are picked per FRAME (nearest to the eye), scanned on a timer. */
1762
+ _onRender3D(ctx: RenderContext3D): void;
1731
1763
  /**
1732
1764
  * Where a WORLD point sits in the channel — the query gameplay scripts run
1733
1765
  * (steer a raft, drown a torch, decide a ford is too fast to cross). `null`
@@ -1755,6 +1787,14 @@ declare class River3D extends Node3D implements SunConsumer3D {
1755
1787
  _applySunDirection(dir: readonly [number, number, number]): void;
1756
1788
  override free(): void;
1757
1789
  private widthProfile;
1790
+ /**
1791
+ * Cut (or release) this river's trench in the terrain it drapes on.
1792
+ *
1793
+ * Runs at ready as well as on every course rebuild: the heightfield collider
1794
+ * is built before the first render sync, so a bed cut only at draw time
1795
+ * would leave the player walking on ground that is no longer there.
1796
+ */
1797
+ private applyCarve;
1758
1798
  /** Resolve the drape terrain; an explicit path that misses is a hard error. */
1759
1799
  private resolveTerrain;
1760
1800
  /**
@@ -1764,6 +1804,21 @@ declare class River3D extends Node3D implements SunConsumer3D {
1764
1804
  private ensureCourse;
1765
1805
  private rebuildIfNeeded;
1766
1806
  private buildMaterial;
1807
+ /**
1808
+ * Find everything standing in the current.
1809
+ *
1810
+ * A boulder in a creek is not a physics problem — it is a thing the water
1811
+ * has to be TOLD about, or the stream runs through it as if it were painted
1812
+ * on. Any mesh whose footprint lands inside the wetted channel and whose top
1813
+ * reaches near the surface counts, `InstancedMesh3D` rows included (a rock
1814
+ * scatter is one node with fifty stones in it).
1815
+ *
1816
+ * Scanned on a slow timer rather than per frame: rocks do not move often,
1817
+ * and a river with a hundred of them still writes only the nearest few.
1818
+ */
1819
+ private scanRocks;
1820
+ /** Write the nearest rocks into the shader, faded in by distance. */
1821
+ private syncRocks;
1767
1822
  private syncUniforms;
1768
1823
  /**
1769
1824
  * Hang a mist plume on every fall. Runtime children (`__spray*`), rebuilt
@@ -1965,6 +2020,14 @@ declare class Terrain3D extends Node3D {
1965
2020
  * bed to sit in, and the collider/heightAt/drape all see it. */
1966
2021
  channels: ChannelSpec[];
1967
2022
  /**
2023
+ * Trenches other NODES cut in this terrain — a `River3D` carving its own bed.
2024
+ * Keyed by the node that owns each, so a moving or re-pathed river replaces
2025
+ * its cut instead of stacking a new one. Runtime state, never serialized:
2026
+ * the scene file says "there is a river here", not "here is the ditch it
2027
+ * dug", and re-loading the scene digs it again.
2028
+ */
2029
+ private readonly externalChannels;
2030
+ /**
1968
2031
  * WET SAND band: `{ y, band? }` darkens + glosses the splat in a noisy,
1969
2032
  * breathing band just above height `y` (a waterline) — the trace of the
1970
2033
  * last swash runup. `band` is the max height above `y` that reads wet
@@ -1989,6 +2052,14 @@ declare class Terrain3D extends Node3D {
1989
2052
  * physics bodies follow).
1990
2053
  */
1991
2054
  heightAt(x: number, z: number): number;
2055
+ /**
2056
+ * @internal Cut (spec) or release (null) a trench another node owns. A
2057
+ * `River3D` calls this to dig its own bed; the heightmap, the collider,
2058
+ * `heightAt`, the drape and the mesh all pick it up on their next rebuild.
2059
+ */
2060
+ _setExternalChannel(owner: Node, specs: ChannelSpec[] | null): void;
2061
+ /** Authored trenches plus the ones other nodes cut. */
2062
+ private allChannels;
1992
2063
  /** @internal The pure heightfield (lazily built — physics pulls this). */
1993
2064
  _heightmap(): Heightmap;
1994
2065
  /** The splat layers in effect — theme preset, or `layers` for 'custom'. */
package/dist/3d.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { t as IncantoError } from "./errors-BpWbnbb_.js";
2
2
  import { A as Water3D, F as PhysicsBody3D, I as RigidBody3D, L as StaticBody3D, M as WaterCutout3D, N as Area3D, P as CharacterBody3D, R as Node3D, V as WATER_MAX_RIPPLES, j as WATER_CUTOUT_MAX } from "./gameplay-Ddk13pQ6.js";
3
- import { a as Environment3D, c as sunDirectionFromElevationAzimuth, i as syncTree, l as sunDirectionFromSky, o as horizonColorFromSky, r as Renderer3D, s as parseEnvironment3D, t as createGame3D, u as AssetStore3D } from "./create-game-B_qBR65J.js";
4
- import { A as QUARTER_PITCH, C as BoneAttachment3D, D as TERRAIN_THEMES, E as DEFAULT_TERRAIN_TEXTURE_BASE, M as keyboardIntensity, N as movementState, O as terrainThemeLayers, P as rigPose, S as BoneLookAt3D, T as Terrain3D, _ as Flowers3D, a as Trail3D, b as CharacterController3D, c as Particles3D, d as DirectionalLight3D, f as OmniLight3D, g as DENSITY_PRESETS, h as Foliage3D, i as Tree3D, j as cameraRelative, k as Joint3D, l as ModelInstance3D, m as MeshInstance3D, n as VOXEL_PALETTE, o as River3D, p as InstancedMesh3D, r as VoxelGrid3D, s as traceDownhillPath, t as registerNodes3D, u as LoftMesh3D, v as resolveFlowerDensity, w as Billboard3D, x as Camera3D, y as FLOWER_VARIETIES } from "./register-CeWtdiCw.js";
3
+ import { a as Environment3D, c as sunDirectionFromElevationAzimuth, i as syncTree, l as sunDirectionFromSky, o as horizonColorFromSky, r as Renderer3D, s as parseEnvironment3D, t as createGame3D, u as AssetStore3D } from "./create-game-DUAtTqID.js";
4
+ import { A as QUARTER_PITCH, C as BoneAttachment3D, D as TERRAIN_THEMES, E as DEFAULT_TERRAIN_TEXTURE_BASE, M as keyboardIntensity, N as movementState, O as terrainThemeLayers, P as rigPose, S as BoneLookAt3D, T as Terrain3D, _ as Flowers3D, a as Trail3D, b as CharacterController3D, c as Particles3D, d as DirectionalLight3D, f as OmniLight3D, g as DENSITY_PRESETS, h as Foliage3D, i as Tree3D, j as cameraRelative, k as Joint3D, l as ModelInstance3D, m as MeshInstance3D, n as VOXEL_PALETTE, o as River3D, p as InstancedMesh3D, r as VoxelGrid3D, s as traceDownhillPath, t as registerNodes3D, u as LoftMesh3D, v as resolveFlowerDensity, w as Billboard3D, x as Camera3D, y as FLOWER_VARIETIES } from "./register-DcHXS1MA.js";
5
5
  import { n as splatWeights, t as buildHeightmap } from "./heightmap-CRK0M4jT.js";
6
- import { n as enablePhysics3D, t as Physics3D } from "./physics-3d-Cd7Jl8w1.js";
6
+ import { n as enablePhysics3D, t as Physics3D } from "./physics-3d-4mGzOZ2J.js";
7
7
  //#region src/3d/environment-runtime.ts
8
8
  /**
9
9
  * Live environment editing — the renderer re-applies `scene.environment`
@@ -5,8 +5,8 @@ import { t as IncantoError } from "./errors-BpWbnbb_.js";
5
5
  import { i as resolveRendering, n as attachTouchControls } from "./touch-031PxtCR.js";
6
6
  import { B as createCausticsQuad, F as PhysicsBody3D, R as Node3D, n as registerGameplayBehaviors } from "./gameplay-Ddk13pQ6.js";
7
7
  import { t as debugSources } from "./debug-draw-CZmOYjL2.js";
8
- import { d as DirectionalLight3D, l as ModelInstance3D, t as registerNodes3D, x as Camera3D } from "./register-CeWtdiCw.js";
9
- import { n as enablePhysics3D } from "./physics-3d-Cd7Jl8w1.js";
8
+ import { d as DirectionalLight3D, l as ModelInstance3D, t as registerNodes3D, x as Camera3D } from "./register-DcHXS1MA.js";
9
+ import { n as enablePhysics3D } from "./physics-3d-4mGzOZ2J.js";
10
10
  import { ACESFilmicToneMapping, AmbientLight, Box3, BufferAttribute, BufferGeometry, Color, DepthTexture, EquirectangularReflectionMapping, FloatType, Fog, HalfFloatType, LineBasicMaterial, LineSegments, Matrix4, Mesh, PCFShadowMap, PMREMGenerator, PerspectiveCamera, PlaneGeometry, Quaternion, Raycaster, Scene, ShaderMaterial, Vector2, Vector3, WebGLRenderTarget, WebGLRenderer } from "three";
11
11
  import { VRMLoaderPlugin, VRMUtils } from "@pixiv/three-vrm";
12
12
  import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
package/dist/env.d.ts CHANGED
@@ -376,6 +376,12 @@ interface TerrainOptions {
376
376
  * theme ALWAYS ships its sea — without it the edge-wrap skirt is bare cliff.
377
377
  */
378
378
  water?: boolean;
379
+ /**
380
+ * Grid segments per side (default 128). Raise it when the map carries
381
+ * features finer than a cell — a 2 m creek on a 260 m terrain has to be cut
382
+ * into ~1 m cells (256) or the trench smooths away to nothing.
383
+ */
384
+ resolution?: number;
379
385
  }
380
386
  /**
381
387
  * The environment header that matches a generator theme — sky, horizon fog
package/dist/env.js CHANGED
@@ -1419,7 +1419,7 @@ const TERRAIN_GENERATOR_THEMES = [
1419
1419
  "volcanic"
1420
1420
  ];
1421
1421
  /** Terrain3D's default grid segments — the probe MUST match the runtime grid. */
1422
- const TERRAIN_RESOLUTION = 128;
1422
+ const DEFAULT_TERRAIN_RESOLUTION = 128;
1423
1423
  /** Terrain3D edge wrap: the rim drops this many meters before the −50 m skirt. */
1424
1424
  const EDGE_WRAP_DROP = 20;
1425
1425
  /** Sea margin above the highest rim cliff (> the ~0.52 m wave-trough dip). */
@@ -1676,6 +1676,7 @@ function generateTerrain(opts) {
1676
1676
  prop: "theme",
1677
1677
  validOptions: [...TERRAIN_GENERATOR_THEMES]
1678
1678
  });
1679
+ const TERRAIN_RESOLUTION = Math.max(2, Math.round(opts.resolution ?? DEFAULT_TERRAIN_RESOLUTION));
1679
1680
  let maxHeight = opts.maxHeight || spec.maxHeight;
1680
1681
  const rng = new Rng(seed);
1681
1682
  const isIsland = theme === "island";
@@ -1714,7 +1715,8 @@ function generateTerrain(opts) {
1714
1715
  seed,
1715
1716
  theme: spec.splat,
1716
1717
  ...spec.roughness !== void 0 ? { roughness: spec.roughness } : {},
1717
- ...spec.detail !== void 0 ? { detail: spec.detail } : {}
1718
+ ...spec.detail !== void 0 ? { detail: spec.detail } : {},
1719
+ ...TERRAIN_RESOLUTION !== DEFAULT_TERRAIN_RESOLUTION ? { resolution: TERRAIN_RESOLUTION } : {}
1718
1720
  }
1719
1721
  }]
1720
1722
  }];
@@ -1799,9 +1801,10 @@ function borderMaxHeight(hm) {
1799
1801
  let borderMax = Number.NEGATIVE_INFINITY;
1800
1802
  const hw = hm.width / 2;
1801
1803
  const hd = hm.depth / 2;
1802
- for (let i = 0; i <= TERRAIN_RESOLUTION; i++) {
1803
- const x = -hw + i / TERRAIN_RESOLUTION * hm.width;
1804
- const z = -hd + i / TERRAIN_RESOLUTION * hm.depth;
1804
+ const steps = hm.segsX;
1805
+ for (let i = 0; i <= steps; i++) {
1806
+ const x = -hw + i / steps * hm.width;
1807
+ const z = -hd + i / steps * hm.depth;
1805
1808
  borderMax = Math.max(borderMax, hm.baseHeight(x, -hd), hm.baseHeight(x, hd), hm.baseHeight(-hw, z), hm.baseHeight(hw, z));
1806
1809
  }
1807
1810
  return borderMax;
package/dist/index.js CHANGED
@@ -295,6 +295,6 @@ function newUid() {
295
295
  //#endregion
296
296
  //#region src/index.ts
297
297
  /** Engine version. Kept in sync with package.json by the release pipeline. */
298
- const VERSION = "0.26.0";
298
+ const VERSION = "0.27.0";
299
299
  //#endregion
300
300
  export { AudioBuses, AudioPlayer, Behavior, CONST_REF_KEY, Engine, HudLayer, IncantoError, InputMap, LogManager, MusicManager, Node, ORDER_GROUP_BASE, PARTICLE_PRESETS, PARTICLE_PRESET_NAMES, ParticleSim, ROLLOFF_MODELS, Rng, SCENE_FORMAT, SFX_PRESETS, SFX_PRESET_NAMES, Scene, SceneTree, SfxEngine, Signal, Timer, TouchControls, UiBanner, UiBar, UiButton, UiDialogue, UiText, VERSION, WebAudioMusicBackend, applyParticlePreset, assetUrls, attachTouchControls, auditScene, clearBehaviors, clearRegistry, computeViewport, createNode, createNoise2D, createSaveStore, crossfadeGains, duplicateNode, effectiveOrder, fadeGain, findPath, getBehavior, getNodeSchema, getNodeSignals, getNodeType, gridFromRows, isAudioContextAvailable, isConstRef, joystickVector, jsonClone, jsonEquals, jsonKind, loadScene, mergeStaticSignals, newUid, parseNodePath, preloadUrls, registerBehavior, registerCoreNodes, registerNode, registeredBehaviors, registeredTypes, replay, resolveConstants, resolveRendering, resolveViewport, serializeNode, spatialGain, spatialPan, startRecording, synthSfx };
@@ -2,7 +2,7 @@ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
2
  import { t as IncantoError } from "./errors-BpWbnbb_.js";
3
3
  import { F as PhysicsBody3D, I as RigidBody3D, N as Area3D, P as CharacterBody3D, R as Node3D, z as validateCollider3D } from "./gameplay-Ddk13pQ6.js";
4
4
  import { n as registerDebugSource } from "./debug-draw-CZmOYjL2.js";
5
- import { T as Terrain3D, k as Joint3D } from "./register-CeWtdiCw.js";
5
+ import { T as Terrain3D, k as Joint3D } from "./register-DcHXS1MA.js";
6
6
  import { Euler, Quaternion } from "three";
7
7
  //#region src/3d/physics/physics-3d.ts
8
8
  var physics_3d_exports = /* @__PURE__ */ __exportAll({
package/dist/react.js CHANGED
@@ -156,7 +156,7 @@ function IncantoCanvas(props) {
156
156
  pointer: latest.pointer,
157
157
  ...keyboard !== void 0 ? { keyboard } : {}
158
158
  };
159
- const next = await (_gameFactory ?? (mode === "3d" ? async (o) => (await import("./create-game-B_qBR65J.js").then((n) => n.n)).createGame3D(o) : async (o) => (await import("./create-game-C0bPoURs.js").then((n) => n.n)).createGame2D(o)))(opts);
159
+ const next = await (_gameFactory ?? (mode === "3d" ? async (o) => (await import("./create-game-DUAtTqID.js").then((n) => n.n)).createGame3D(o) : async (o) => (await import("./create-game-C0bPoURs.js").then((n) => n.n)).createGame2D(o)))(opts);
160
160
  if (disposed) {
161
161
  next.dispose();
162
162
  return;