incanto 0.20.0 → 0.22.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/2d.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t as IncantoError } from "./errors-BpWbnbb_.js";
2
- import { a as AssetStore2D, i as syncTree2D, r as Renderer2D, t as createGame2D } from "./create-game-Ct86zczq.js";
3
- import { _ as RigidBody2D, a as parseCells, c as ColorRect2D, d as AnimatedSprite2D, f as Sprite2D, g as PhysicsBody2D, h as CharacterBody2D, i as mergeSolidRects, l as CharacterController2D, m as Area2D, n as UILayer, o as Particles2D, p as Joint2D, r as TileMap2D, s as Label, t as registerNodes2D, u as Camera2D, v as StaticBody2D, y as Node2D } from "./register-Djwckzgx.js";
4
- import { n as enablePhysics2D, t as Physics2D } from "./physics-2d-BiIdl51r.js";
2
+ import { a as AssetStore2D, i as syncTree2D, r as Renderer2D, t as createGame2D } from "./create-game-B-M1zune.js";
3
+ import { _ as RigidBody2D, a as parseCells, c as ColorRect2D, d as AnimatedSprite2D, f as Sprite2D, g as PhysicsBody2D, h as CharacterBody2D, i as mergeSolidRects, l as CharacterController2D, m as Area2D, n as UILayer, o as Particles2D, p as Joint2D, r as TileMap2D, s as Label, t as registerNodes2D, u as Camera2D, v as StaticBody2D, y as Node2D } from "./register-CvpSUU3O.js";
4
+ import { n as enablePhysics2D, t as Physics2D } from "./physics-2d-DiVFFlH3.js";
5
5
  //#region src/2d/library-sprite.ts
6
6
  /**
7
7
  * Turn a library sprite-animation JSON into a scene-ready spritesheet asset
package/dist/3d.d.ts CHANGED
@@ -532,6 +532,15 @@ interface CausticsConfig {
532
532
  /** Animation speed multiplier. */
533
533
  speed: number;
534
534
  }
535
+ /**
536
+ * God rays: the shafts of sunlight the surface's own ripples focus into the
537
+ * water column. Caustics light what the beams LAND on; this is the beam itself.
538
+ */
539
+ interface LightShaftConfig {
540
+ enabled: boolean;
541
+ /** Brightness of the accumulated shafts. */
542
+ strength: number;
543
+ }
535
544
  /** Resolved underwater look: fog color, view distance, and the caustics layer. */
536
545
  interface UnderwaterConfig {
537
546
  enabled: boolean;
@@ -541,6 +550,8 @@ interface UnderwaterConfig {
541
550
  visibility: number;
542
551
  /** Caustics projected onto submerged surfaces (the floor especially). */
543
552
  caustics: CausticsConfig;
553
+ /** Sunlight shafts hanging in the water column. */
554
+ rays: LightShaftConfig;
544
555
  }
545
556
  //#endregion
546
557
  //#region src/3d/environment-3d.d.ts
@@ -1598,6 +1609,24 @@ interface RiverHit {
1598
1609
  speed: number;
1599
1610
  halfWidth: number;
1600
1611
  }
1612
+ /** A place where the river stops flowing and starts falling. */
1613
+ interface RiverFall {
1614
+ /** Where the water LANDS (local frame) — the plunge point. */
1615
+ x: number;
1616
+ z: number;
1617
+ /** Water surface at the lip and at the base. */
1618
+ topY: number;
1619
+ baseY: number;
1620
+ /** Vertical drop in meters. */
1621
+ drop: number;
1622
+ /** Channel half-width at the base — how wide the curtain is. */
1623
+ halfWidth: number;
1624
+ /** Downstream direction at the base (a fall keeps carrying the water). */
1625
+ dirX: number;
1626
+ dirZ: number;
1627
+ /** Current speed at the base. */
1628
+ speed: number;
1629
+ }
1601
1630
  interface DownhillTraceOptions {
1602
1631
  /** Where the water starts (local frame, same as the sampler). */
1603
1632
  x: number;
@@ -1676,9 +1705,17 @@ declare class River3D extends Node3D implements SunConsumer3D {
1676
1705
  terrain: string;
1677
1706
  /** How hard the current sweeps bodies downstream (0 = visual only). */
1678
1707
  flowForce: number;
1708
+ /**
1709
+ * Mist at the foot of every waterfall the course contains: the node finds
1710
+ * the drops itself (see {@link detectFalls}) and hangs a Particles3D plume
1711
+ * on each, sized by how far the water falls. 0 = off.
1712
+ */
1713
+ spray: number;
1679
1714
  override renderOrder: number;
1680
1715
  private time;
1681
1716
  private rings;
1717
+ private falls;
1718
+ private sprayKey;
1682
1719
  private courseKey;
1683
1720
  private bedAt;
1684
1721
  private world;
@@ -1696,6 +1733,16 @@ declare class River3D extends Node3D implements SunConsumer3D {
1696
1733
  sampleAt(x: number, z: number): (RiverHit & {
1697
1734
  surfaceY: number;
1698
1735
  }) | null;
1736
+ /**
1737
+ * The waterfalls on this course — where the water stops flowing and starts
1738
+ * falling, with the drop height and the plunge point in WORLD coordinates.
1739
+ * Hang your own effects (sound, a rainbow, a hidden cave) on these.
1740
+ */
1741
+ fallsAt(): (RiverFall & {
1742
+ worldX: number;
1743
+ worldY: number;
1744
+ worldZ: number;
1745
+ })[];
1699
1746
  /** @internal The derived centerline stations (surface, grade, current). */
1700
1747
  _rings(): readonly RiverRing[];
1701
1748
  /**
@@ -1716,6 +1763,12 @@ declare class River3D extends Node3D implements SunConsumer3D {
1716
1763
  private buildMaterial;
1717
1764
  private syncUniforms;
1718
1765
  /**
1766
+ * Hang a mist plume on every fall. Runtime children (`__spray*`), rebuilt
1767
+ * only when the course or the dial changes — a plume is a Particles3D, so it
1768
+ * carries its own budget, culling and editor visibility for free.
1769
+ */
1770
+ private syncSpray;
1771
+ /**
1719
1772
  * Drag every body floating in the channel toward the water's own velocity.
1720
1773
  * Drag rather than thrust: a raft accelerates until it matches the current
1721
1774
  * and then coasts, and a swimmer can still fight across a slow ford.
@@ -2276,6 +2329,13 @@ declare class Water3D extends Node3D implements RenderHook3D, SunConsumer3D {
2276
2329
  swellDirectionDeg: number;
2277
2330
  /** Primary swell wavelength in meters (the two crossing trains derive). */
2278
2331
  swellWavelength: number;
2332
+ /**
2333
+ * GERSTNER pinch on the swell: 0 keeps the legacy height-only trains, 1 is
2334
+ * maximum trochoid (crests narrow to a peak, troughs go broad). It also
2335
+ * decides where whitecaps break — the surface's Jacobian collapses on a
2336
+ * folding crest, and that is where foam belongs.
2337
+ */
2338
+ swellSteepness: number;
2279
2339
  /** Open-water whitecap foam on the tallest crests, 0–1 (fancy only). Works
2280
2340
  * best with `swell` — the caps ride the swell's crest lines. */
2281
2341
  whitecaps: number;
@@ -2369,6 +2429,14 @@ declare class Water3D extends Node3D implements RenderHook3D, SunConsumer3D {
2369
2429
  private resolvePalette;
2370
2430
  private syncSimple;
2371
2431
  private stepInteraction;
2432
+ /**
2433
+ * Surface height at WORLD (x, z) — the CPU twin of the shader's own waves,
2434
+ * so gameplay can float a raft, bob a buoy or place a jetty on the sea state
2435
+ * the player is actually looking at. Interaction ripples are excluded (a
2436
+ * splash must not re-trigger itself); outside the footprint it still answers
2437
+ * the still-water level, which is what a caller comparing heights wants.
2438
+ */
2439
+ heightAt(x: number, z: number): number;
2372
2440
  /** Base wave height at world (x, z) — the CPU twin of the active shader.
2373
2441
  * Ripples are excluded on purpose: a splash must not re-trigger itself. */
2374
2442
  private waveOffsetAt;
package/dist/3d.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { t as IncantoError } from "./errors-BpWbnbb_.js";
2
- 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-pNf3sI-Q.js";
3
- import { A as TERRAIN_THEMES, B as QUARTER_PITCH, C as CharacterController3D, D as Billboard3D, E as BoneAttachment3D, F as PhysicsBody3D, H as keyboardIntensity, I as RigidBody3D, L as StaticBody3D, M as Joint3D, N as Area3D, O as Terrain3D, P as CharacterBody3D, R as Node3D, S as FLOWER_VARIETIES, T as BoneLookAt3D, U as movementState, V as cameraRelative, W as rigPose, _ as MeshInstance3D, a as VoxelGrid3D, b as Flowers3D, c as River3D, d as Particles3D, f as ModelInstance3D, g as InstancedMesh3D, h as OmniLight3D, i as VOXEL_PALETTE, j as terrainThemeLayers, k as DEFAULT_TERRAIN_TEXTURE_BASE, l as traceDownhillPath, m as DirectionalLight3D, n as Water3D, o as Tree3D, p as LoftMesh3D, s as Trail3D, t as registerNodes3D, u as WATER_MAX_RIPPLES, v as Foliage3D, w as Camera3D, x as resolveFlowerDensity, y as DENSITY_PRESETS } from "./register-BWFgsGra.js";
2
+ import { A as Water3D, F as StaticBody3D, I as Node3D, M as CharacterBody3D, N as PhysicsBody3D, P as RigidBody3D, j as Area3D, z as WATER_MAX_RIPPLES } from "./gameplay-Dib5mNFD.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-C3uiw80V.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-CHgVdSbp.js";
4
5
  import { n as splatWeights, t as buildHeightmap } from "./heightmap-CRK0M4jT.js";
5
- import { n as enablePhysics3D, t as Physics3D } from "./physics-3d-DxFDfUey.js";
6
+ import { n as enablePhysics3D, t as Physics3D } from "./physics-3d-DLPPRNu4.js";
6
7
  //#region src/3d/environment-runtime.ts
7
8
  /**
8
9
  * Live environment editing — the renderer re-applies `scene.environment`
@@ -3,10 +3,10 @@ import { _ as registerBehavior, n as loadScene, o as computeViewport, s as resol
3
3
  import { l as AudioPlayer, u as Engine } from "./register-nObreUQR.js";
4
4
  import { t as IncantoError } from "./errors-BpWbnbb_.js";
5
5
  import { i as resolveRendering, n as attachTouchControls } from "./touch-031PxtCR.js";
6
- import { n as registerGameplayBehaviors } from "./gameplay-sSqrUcnz.js";
7
- import { g as PhysicsBody2D, n as UILayer, t as registerNodes2D, u as Camera2D, y as Node2D } from "./register-Djwckzgx.js";
6
+ import { n as registerGameplayBehaviors } from "./gameplay-Dib5mNFD.js";
7
+ import { g as PhysicsBody2D, n as UILayer, t as registerNodes2D, u as Camera2D, y as Node2D } from "./register-CvpSUU3O.js";
8
8
  import { t as debugSources } from "./debug-draw-CZmOYjL2.js";
9
- import { n as enablePhysics2D } from "./physics-2d-BiIdl51r.js";
9
+ import { n as enablePhysics2D } from "./physics-2d-DiVFFlH3.js";
10
10
  import { Box3, BufferAttribute, BufferGeometry, Color, LineBasicMaterial, LineSegments, LinearFilter, NearestFilter, OrthographicCamera, Raycaster, SRGBColorSpace, Scene, TextureLoader, Vector2, Vector3, WebGLRenderer } from "three";
11
11
  //#region src/2d/assets.ts
12
12
  /**
@@ -3,10 +3,10 @@ import { _ as registerBehavior, n as loadScene } from "./loader-BZqOKfI2.js";
3
3
  import { l as AudioPlayer, u as Engine } from "./register-nObreUQR.js";
4
4
  import { t as IncantoError } from "./errors-BpWbnbb_.js";
5
5
  import { i as resolveRendering, n as attachTouchControls } from "./touch-031PxtCR.js";
6
- import { n as registerGameplayBehaviors } from "./gameplay-sSqrUcnz.js";
6
+ import { I as Node3D, N as PhysicsBody3D, R as createCausticsQuad, n as registerGameplayBehaviors } from "./gameplay-Dib5mNFD.js";
7
7
  import { t as debugSources } from "./debug-draw-CZmOYjL2.js";
8
- import { F as PhysicsBody3D, R as Node3D, f as ModelInstance3D, m as DirectionalLight3D, r as createCausticsQuad, t as registerNodes3D, w as Camera3D } from "./register-BWFgsGra.js";
9
- import { n as enablePhysics3D } from "./physics-3d-DxFDfUey.js";
8
+ import { d as DirectionalLight3D, l as ModelInstance3D, t as registerNodes3D, x as Camera3D } from "./register-CHgVdSbp.js";
9
+ import { n as enablePhysics3D } from "./physics-3d-DLPPRNu4.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";
@@ -1762,6 +1762,9 @@ var Renderer3D = class {
1762
1762
  u.uCausticIntensity.value = underwater.caustics.intensity;
1763
1763
  u.uCausticScale.value = underwater.caustics.scale;
1764
1764
  u.uMaxDist.value = underwater.visibility;
1765
+ const sunDir = this.environment.sunDirection;
1766
+ if (sunDir) u.uSunDirection.value.set(sunDir[0], sunDir[1], sunDir[2]);
1767
+ u.uRayStrength.value = underwater.rays.enabled ? underwater.rays.strength : 0;
1765
1768
  this.webgl.render(this.causticsScene, camera);
1766
1769
  }
1767
1770
  /**
@@ -1,4 +1,18 @@
1
1
  import { i as serializeNode, t as buildNodeJson } from "./loader-BZqOKfI2.js";
2
+ //#region src/core/order-groups.ts
3
+ const ORDER_GROUP_BASE = {
4
+ background: -2e3,
5
+ terrain: -1e3,
6
+ default: 0,
7
+ characters: 1e3,
8
+ effects: 2e3,
9
+ overlay: 3e3
10
+ };
11
+ /** base + fine offset (unknown group names fall back to `default`). */
12
+ function effectiveOrder(group, renderOrder) {
13
+ return (ORDER_GROUP_BASE[group] ?? 0) + renderOrder;
14
+ }
15
+ //#endregion
2
16
  //#region src/core/scene/duplicate.ts
3
17
  function stripUids(json) {
4
18
  const { uid: _uid, ...rest } = json;
@@ -19,4 +33,4 @@ function duplicateNode(node) {
19
33
  return buildNodeJson(stripUids(serializeNode(node)));
20
34
  }
21
35
  //#endregion
22
- export { duplicateNode as t };
36
+ export { ORDER_GROUP_BASE as n, effectiveOrder as r, duplicateNode as t };