genshin-engine 4.3.3 → 4.5.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/README.md CHANGED
@@ -5,14 +5,24 @@
5
5
  [![NPM downloads][badge-npm-downloads]][url-npm]
6
6
  [![NPM Unpacked Size (with version)][badge-npm-unpacked-size]][url-npm]
7
7
 
8
- An anime-style open-world engine for the browser on three.js's WebGPU renderer: toon materials that step light from shade to lit across a narrow ramp, a sky-tinted rim on every silhouette, outlines, cascaded shadows, god rays, height fog, bloom, a colour grade and temporal anti-aliasing, procedural terrain and world kits, and a Web Audio synthesizer that plays a score through instruments of harmonics and an envelope, with recordings a host decodes layered over its voices, each section swelling and fading by its expression. Every module is plain TypeScript or a TSL node graph with one job, so a scene built with it runs in any framework, and the generators behind it are pure, seeded and tested without a GPU.
8
+ An anime-style open-world engine for the browser on three.js's WebGPU renderer. It includes:
9
9
 
10
- It is an unofficial, non-commercial fan engine, not affiliated with HoYoverse. It ships no asset from any game: every mesh, texture, shader and sound is generated by its own code.
10
+ - toon materials that step light from shade to lit across a narrow ramp, with a sky-tinted rim on every silhouette
11
+ - outlines, cascaded shadows, god rays, height fog, bloom, a colour grade and temporal anti-aliasing
12
+ - procedural terrain and world kits
13
+ - a Web Audio synthesizer that plays a score through instruments of harmonics and an envelope, where each section swells and fades by its expression
14
+ - recordings that a host decodes, layered over its voices
15
+
16
+ Each module is plain TypeScript or a TSL node graph with one job, so a scene built with it runs in any framework. The generators behind it are pure, seeded and tested without a GPU.
17
+
18
+ It is an unofficial, non-commercial fan engine. It is not affiliated with HoYoverse. It ships no asset from any game. Every mesh, texture, shader and sound is generated by its own code.
19
+
20
+ Design notes live in [the specs](https://github.com/Esposter/Esposter/tree/main/openspec/specs/genshin).
11
21
 
12
22
  ## Table of Contents
13
23
 
14
24
  - 🚀 [Getting Started](#getting-started)
15
- - 📖 [Documentation](#documentation)
25
+ - 🧩 [Key Exports](#key-exports)
16
26
  - ⚖️ [License](#license)
17
27
 
18
28
  ---
@@ -67,11 +77,24 @@ const { renderPipeline } = createPostPipeline({
67
77
  renderer.setAnimationLoop(() => renderPipeline.render());
68
78
  ```
69
79
 
70
- A web worker generating the ground imports its generators from the `genshin-engine/terrainWorker` subpath instead, `computeTerrainTile` and the height, paint and scatter functions it runs over, which reach three's math and none of the renderer, so the worker starts without loading it.
71
-
72
- ## <a name="documentation">📖 Documentation</a>
73
-
74
- We highly recommend you take a look at the [documentation](https://github.com/Esposter/Esposter/tree/main/openspec/specs/genshin) to level up. The engine's design, from the order a frame runs in to each module's job, is its [architecture page](https://github.com/Esposter/Esposter/blob/main/openspec/specs/genshin/engine-architecture/design.md), and the look it draws is its [rendering style](https://github.com/Esposter/Esposter/blob/main/openspec/specs/genshin/rendering-style/design.md).
80
+ A web worker that generates the ground imports its generators from the `genshin-engine/terrainWorker` subpath, not from the main entry. The subpath holds `computeTerrainTile` and the height, paint and scatter functions that the worker runs. They use three's math and do not use the renderer, so the worker starts without loading the renderer.
81
+
82
+ ## <a name="key-exports">🧩 Key Exports</a>
83
+
84
+ | Export | Kind | Purpose |
85
+ | ------------------------ | -------- | ---------------------------------------------------------------------------------------------------------- |
86
+ | `computeTerrainTile` | function | Samples one terrain tile's grid, normals and colours from the region's heights |
87
+ | `createFogUniforms` | function | One set of fog uniforms for each world, read by the fog pass |
88
+ | `createGenshinRenderer` | function | A three.js WebGPU renderer, falling back to WebGL 2 when WebGPU is missing |
89
+ | `createGodraysLight` | function | A second, unlit sun, with one shadow map that covers the view the god rays march through |
90
+ | `createGradeLutTexture` | function | The colour grade cube, as a 3D texture that the LUT pass samples |
91
+ | `createLightUniforms` | function | One set of light uniforms for each world, shared by every material |
92
+ | `createPostPipeline` | function | Builds the frame's post chain over a scene, from outlines to grade and anti-aliasing |
93
+ | `createPostUniforms` | function | The post chain's uniforms: outline colour and thickness, god-ray colour, grade and white balance |
94
+ | `createRampTexture` | function | A one-row texture of the irradiance that the toon lighting steps between |
95
+ | `createToonMaterial` | function | The environment's toon material, stepping from shade to lit on the world's ramp, and drawing the sky's rim |
96
+ | `QualityTier` | enum | The three quality tiers that set a renderer's cost |
97
+ | `QualityTierSettingsMap` | const | What each quality tier spends: shadow maps, cascades, god-ray steps, bloom and anti-aliasing |
75
98
 
76
99
  ## <a name="license">⚖️ License</a>
77
100
 
package/dist/index.d.ts CHANGED
@@ -6,7 +6,6 @@ import { Capsule } from "three/examples/jsm/math/Capsule.js";
6
6
  import GTAONode from "three/examples/jsm/tsl/display/GTAONode.js";
7
7
  import BloomNode from "three/examples/jsm/tsl/display/BloomNode.js";
8
8
  import GodraysNode from "three/examples/jsm/tsl/display/GodraysNode.js";
9
- import { Inspector } from "three/examples/jsm/inspector/Inspector.js";
10
9
  export interface SkyUniforms {
11
10
  cloudCoverage: UniformNode<"float", number>;
12
11
  cloudDrift: UniformNode<"vec2", Vector2>;
@@ -197,6 +196,7 @@ export interface SkyGradient {
197
196
  export declare enum WeatherKind {
198
197
  Clear = "Clear",
199
198
  Cloudy = "Cloudy",
199
+ Eruption = "Eruption",
200
200
  Fog = "Fog",
201
201
  Rain = "Rain",
202
202
  Sandstorm = "Sandstorm",
@@ -206,7 +206,7 @@ export declare enum WeatherKind {
206
206
  }
207
207
  export declare const SUN_REDRAW_COSINE: number;
208
208
  export declare const DEFAULT_SKY_SHAPE: Readonly<SkyShape>;
209
- export declare const DEFAULT_SKY_GRADIENT: SkyGradient;
209
+ export declare const DEFAULT_SKY_GRADIENT: Readonly<SkyGradient>;
210
210
  export declare const PRECIPITATION_COUNT = 2048;
211
211
  export declare const PRECIPITATION_VOLUME_SIZE = 60;
212
212
  export declare const PRECIPITATION_VOLUME_HEIGHT = 30;
@@ -461,7 +461,7 @@ export declare const FREE_CAMERA_BASE_SPEED = 8;
461
461
  export declare const FREE_CAMERA_SPEED_PER_HEIGHT = .5;
462
462
  export declare const FREE_CAMERA_CLEARANCE = 1.5;
463
463
  export declare const FREE_CAMERA_MAX_PITCH: number;
464
- export declare const FOLLOW_CAMERA_DEFAULT_SETTINGS: FollowCameraSettings;
464
+ export declare const FOLLOW_CAMERA_DEFAULT_SETTINGS: Readonly<FollowCameraSettings>;
465
465
  export declare const FOLLOW_CAMERA_NEUTRAL_SENSITIVITY = 3;
466
466
  export declare const FOLLOW_CAMERA_PIVOT_SHARE = .7;
467
467
  export declare const FOLLOW_CAMERA_FOV = 45;
@@ -520,6 +520,9 @@ export interface InputState {
520
520
  heldActions: ReadonlySet<InputAction>;
521
521
  lookPitch: number;
522
522
  lookYaw: number;
523
+ menuDown: number;
524
+ menuRight: number;
525
+ menuTabSteps: number;
523
526
  moveForward: number;
524
527
  moveRight: number;
525
528
  moveUp: number;
@@ -692,7 +695,6 @@ export interface ToonEdge {
692
695
  }
693
696
  export declare class ToonNodeMaterial extends MeshToonNodeMaterial {
694
697
  edge?: ToonEdge;
695
- emissiveNode: Node | null;
696
698
  instanceMatrix?: Node<"mat4">;
697
699
  readonly isMeshToonMaterial: boolean;
698
700
  override readonly isMeshToonNodeMaterial: boolean;
@@ -908,7 +910,6 @@ export interface PoseAirStance {
908
910
  }
909
911
  export declare const POSE_AIR_STANCES: Partial<Record<LocomotionState, PoseAirStance>>;
910
912
  export declare const MMD_BONE_NAME_MAP: Record<MmdBoneName, string>;
911
- export declare const createCharacterPoseRotations: () => CharacterPoseRotations;
912
913
  export type CharacterBoneNameMap = Partial<Record<MmdBoneName, string>>;
913
914
  export interface Locomotion {
914
915
  capsuleHeight: number;
@@ -948,6 +949,7 @@ interface CharacterPoseUpdate {
948
949
  phase: LocomotionPhase;
949
950
  }
950
951
  export declare const createCharacterPoser: (skinnedMesh: SkinnedMesh, boneNameMap?: CharacterBoneNameMap) => CharacterPoser;
952
+ export declare const createCharacterPoseRotations: () => CharacterPoseRotations;
951
953
  export declare const findSkinnedMesh: (object: Object3D) => SkinnedMesh | undefined;
952
954
  export declare const REGION_FLOORS: {
953
955
  readonly five: 0.6;
@@ -1049,11 +1051,10 @@ interface InstanceCullingOptions {
1049
1051
  isVisible: (instance: Node<"float">) => Node<"float">;
1050
1052
  }
1051
1053
  export declare const createInstanceCulling: ({ count, indexCount, isVisible }: InstanceCullingOptions) => InstanceCulling;
1054
+ export declare const createInstancedGeometry: (geometry: BufferGeometry, instanceCount: number) => InstancedBufferGeometry;
1052
1055
  export declare const createInstanceMatrixBuffer: (matrices: Matrix4[]) => StorageBufferAttribute;
1053
1056
  export declare const createInstanceMatrixNode: (attribute: StorageBufferAttribute, instance: Node<"float">) => Node<"mat4">;
1054
- export declare const createInstancedGeometry: (geometry: BufferGeometry, instanceCount: number) => InstancedBufferGeometry;
1055
1057
  export declare const createSurvivorIndices: (count: number) => Uint32Array;
1056
- export declare const InputActionBindingMap: Readonly<Record<InputAction, readonly (readonly string[])[]>>;
1057
1058
  export declare enum GamepadButton {
1058
1059
  Back = "GamepadBack",
1059
1060
  DirectionalPadDown = "GamepadDirectionalPadDown",
@@ -1091,6 +1092,7 @@ export declare const MOUSE_LOOK_RADIANS_PER_PIXEL = .002;
1091
1092
  export declare const MOUSE_LOOK_MAX_PIXELS_PER_EVENT: number;
1092
1093
  export declare const GAMEPAD_LOOK_RADIANS_PER_SECOND = 2.5;
1093
1094
  export declare const GAMEPAD_STICK_DEADZONE = .15;
1095
+ export declare const createIdleInputState: () => InputState;
1094
1096
  export interface Input {
1095
1097
  dispose: () => void;
1096
1098
  press: (code: string) => void;
@@ -1117,6 +1119,10 @@ export interface InputTarget extends Pick<Window, "addEventListener"> {
1117
1119
  };
1118
1120
  }
1119
1121
  export declare const createInput: (target: InputTarget) => Input;
1122
+ export declare const InputActionBindingMap: Readonly<Record<InputAction, readonly (readonly string[])[]>>;
1123
+ export declare const toAxis: (positive: boolean, negative: boolean) => number;
1124
+ export declare const toClamped: (axis: number) => number;
1125
+ export declare const toDeadzoned: (stickAxis: number) => number;
1120
1126
  export declare const createBoxesGeometry: (boxes: readonly (readonly number[])[]) => BufferGeometry;
1121
1127
  export declare enum RoofKind {
1122
1128
  Conical = "Conical",
@@ -1350,6 +1356,9 @@ export interface PlantCullingOptions {
1350
1356
  eye: UniformNode<"vec3", Vector3>;
1351
1357
  indexCount: number;
1352
1358
  }
1359
+ export declare const createOutlineMaterial: (colorNode: Node<"vec4">, thicknessNode: Node<"float">, instanceMatrix?: Node<"mat4">) => NodeMaterial;
1360
+ export declare const createGameOutlineMaterial: (colorNode: Node<"vec4">, widthNode: Node<"float">, offsetNode: Node<"float">) => NodeMaterial;
1361
+ export declare const getGameOutlineOffset: (viewPosition: Vector3, blue: number, blockBChannel: number, size: number) => Vector3;
1353
1362
  export interface Impostor {
1354
1363
  albedoTarget: RenderTarget;
1355
1364
  bottom: number;
@@ -1469,9 +1478,6 @@ export interface ToonMaterialOptions {
1469
1478
  lightUniforms: LightUniforms;
1470
1479
  rampTexture: DataTexture;
1471
1480
  }
1472
- export declare const createOutlineMaterial: (colorNode: Node<"vec4">, thicknessNode: Node<"float">, instanceMatrix?: Node<"mat4">) => NodeMaterial;
1473
- export declare const createGameOutlineMaterial: (colorNode: Node<"vec4">, widthNode: Node<"float">, offsetNode: Node<"float">) => NodeMaterial;
1474
- export declare const getGameOutlineOffset: (viewPosition: Vector3, blue: number, blockBChannel: number, size: number) => Vector3;
1475
1481
  export interface GradeOptions {
1476
1482
  contrast: number;
1477
1483
  highlightTint: readonly [number, number, number];
@@ -1672,16 +1678,16 @@ export interface UnderwaterFogState {
1672
1678
  isUnderwater: boolean;
1673
1679
  underwaterDensity: number;
1674
1680
  }
1675
- export interface WaterFlow {
1676
- direction: UniformNode<"vec2", Vector2>;
1677
- speed: UniformNode<"float", number>;
1678
- }
1679
1681
  export interface WaterfallSheet {
1680
1682
  across: Vector3;
1681
1683
  drop: number;
1682
1684
  lip: Vector3;
1683
1685
  width: number;
1684
1686
  }
1687
+ export interface WaterFlow {
1688
+ direction: UniformNode<"vec2", Vector2>;
1689
+ speed: UniformNode<"float", number>;
1690
+ }
1685
1691
  export interface GroundPoint {
1686
1692
  x: number;
1687
1693
  z: number;
@@ -1723,8 +1729,8 @@ export declare const createDitherFadeNode: (visibility: Node<"float">) => Node<"
1723
1729
  export declare const createImpostorMaterial: ({ fade, impostor, instanceMatrix, lightUniforms, rampTexture }: ImpostorMaterialOptions) => ToonNodeMaterial;
1724
1730
  export declare const createLeafMaterial: (toonMaterialOptions: ToonMaterialOptions, windUniforms?: WindUniforms, maskNode?: Node<"bool">) => ToonNodeMaterial;
1725
1731
  export declare const createLeafShapeNode: () => Node<"bool">;
1726
- export declare const createLightUniforms: () => LightUniforms;
1727
1732
  export declare const createLightningBoltMaterial: (flash: UniformNode<"float", number>) => MeshBasicNodeMaterial;
1733
+ export declare const createLightUniforms: () => LightUniforms;
1728
1734
  export declare const createMaterialDetailNode: (detail: SurfaceDetail) => Node<"float">;
1729
1735
  export declare const createObjectFadeNode: () => Node<"float">;
1730
1736
  export declare const createObjectSurfaceNode: () => Node<"vec3">;
@@ -1740,8 +1746,8 @@ export declare const createStoneMaterial: (options: StoneMaterialOptions, stoneL
1740
1746
  export declare const createSunVisibilityNode: (lightColor: Node, sunRadiance: UniformNode<"color", Color>) => Node<"float">;
1741
1747
  export declare const createSurfaceDetailNode: (amplitudes: Node<"float">[], texelsPerMetre: Node<"float">) => Node<"float">;
1742
1748
  export declare const createToonMaterial: ({ color, detail, instanceMatrix, isObjectSurface, isOutlined, isVertexColors, lightUniforms, rampTexture }: ToonMaterialOptions) => ToonNodeMaterial;
1743
- export declare const createWaterMaterial: ({ lightColor, sunDirection }: Pick<LightUniforms, "lightColor" | "sunDirection">, { horizonColor, zenithColor }: Pick<SkyUniforms, "horizonColor" | "zenithColor">, { deepColor, deepDepth, foamColor, foamDepth, shallowColor }: WaterUniforms, { direction, speed }: WaterFlow, bendFoam?: Node<"float">) => MeshBasicNodeMaterial;
1744
1749
  export declare const createWaterfallMaterial: ({ foamColor }: Pick<WaterUniforms, "foamColor">) => MeshBasicNodeMaterial;
1750
+ export declare const createWaterMaterial: ({ lightColor, sunDirection }: Pick<LightUniforms, "lightColor" | "sunDirection">, { horizonColor, zenithColor }: Pick<SkyUniforms, "horizonColor" | "zenithColor">, { deepColor, deepDepth, foamColor, foamDepth, shallowColor }: WaterUniforms, { direction, speed }: WaterFlow, bendFoam?: Node<"float">) => MeshBasicNodeMaterial;
1745
1751
  export declare const createWetDarkeningNode: ({ wetness }: Pick<LightUniforms, "wetness">) => Node<"float">;
1746
1752
  export declare const createWetSheenNode: ({ lightColor, sunDirection, wetness }: LightUniforms) => Node<"vec3">;
1747
1753
  export declare const createWindNode: ({ direction, gustSpeed, gustStrength, gustWidth, strength }: WindUniforms, groundPosition: Node<"vec2">) => Node<"vec2">;
@@ -1775,11 +1781,9 @@ export declare const createPostPipeline: ({ camera, fogUniforms, godraysLight, g
1775
1781
  export declare const createPostUniforms: () => PostUniforms;
1776
1782
  export declare const createSightNode: (colorNode: Node<"vec4">, depthNode: TextureNode, camera: Camera, litPass: PassNode, { origin, radius, strength }: SightUniforms) => Node<"vec4">;
1777
1783
  export declare const createSightUniforms: () => SightUniforms;
1778
- export declare const toSceneColor: (displayColor: Color, sceneColor?: Color) => Color;
1779
1784
  export declare const toneMapGenshin: (sceneColor: readonly [number, number, number], toneMapped?: [number, number, number]) => [number, number, number];
1780
1785
  export declare const toneMapGenshinNode: (sceneColor: Node<"vec3">) => Node<"vec3">;
1781
- export declare const QualityTierSettingsMap: Readonly<Record<QualityTier, QualityTierSettings>>;
1782
- export declare const attachInspector: (renderer: Renderer) => Promise<Inspector>;
1786
+ export declare const toSceneColor: (displayColor: Color, sceneColor?: Color) => Color;
1783
1787
  export declare const GENSHIN_TONE_MAPPING: ToneMapping;
1784
1788
  export declare const GENSHIN_TONE_CONTRAST = .5;
1785
1789
  export declare const GENSHIN_TONE_EXPOSURE = 1;
@@ -1789,13 +1793,11 @@ export declare const TONE_CURVE_FLOOR: number;
1789
1793
  export declare const createGenshinRenderer: (canvas: HTMLCanvasElement) => WebGPURenderer;
1790
1794
  export declare const createInstancedMesh: <TGeometry extends BufferGeometry, TMaterial extends Material | Material[]>(geometry: TGeometry, material: TMaterial, count: number) => InstancedMesh<TGeometry, TMaterial>;
1791
1795
  export declare const getScreenDirection: ({ aspect, fov, pitch, yaw }: ScreenCamera, [x, y]: [number, number]) => Vector3;
1796
+ export declare const QualityTierSettingsMap: Readonly<Record<QualityTier, QualityTierSettings>>;
1792
1797
  export declare const MAX_STEPS_PER_FRAME = 5;
1793
1798
  export declare const createFixedStepLoop: (stepSeconds: number, step: () => void) => FixedStepLoop;
1794
1799
  export declare const MAX_TILE_ATTEMPTS = 3;
1795
1800
  export declare const createTileStreamer: <TTile>({ disposeTile, maxCachedCount, maxPendingCount, requestTile }: TileStreamerOptions<TTile>) => TileStreamer<TTile>;
1796
- export declare const TerrainFeatureKindBlendMap: { [K in TerrainFeatureKind]: (feature: Extract<TerrainFeature, {
1797
- kind: K;
1798
- }>, x: number, z: number) => number; };
1799
1801
  export declare const blendGridNodes: (values: readonly number[], sizeX: number, sizeZ: number, column: number, row: number) => number;
1800
1802
  export declare const checkTerrainBoundsOverlap: (first: TerrainBounds, second: TerrainBounds) => boolean;
1801
1803
  export declare const checkTerrainDrawsChanged: ({ finestTileSize }: Pick<TerrainOptions, "finestTileSize">, previous: TerrainSelection, next: TerrainSelection, center: Vector3Like, halfSize: number) => boolean;
@@ -1834,6 +1836,9 @@ export declare const resolveTerrainDraws: ({ levelCount }: Pick<TerrainOptions,
1834
1836
  export declare const sampleGroundLayerField: ({ cellSize, layers, origin, size }: GroundLayerField, x: number, z: number, weights: Record<GroundLayer, number>) => void;
1835
1837
  export declare const sampleTerrainResidualFade: ({ cellSize, clearings, origin, size, weights }: TerrainResidualFade, x: number, z: number) => number;
1836
1838
  export declare const selectTerrainTiles: (terrainOptions: TerrainOptions, eye: Vector3Like, frustum: Frustum | undefined, selection: TerrainSelection) => TerrainSelection;
1839
+ export declare const TerrainFeatureKindBlendMap: { [K in TerrainFeatureKind]: (feature: Extract<TerrainFeature, {
1840
+ kind: K;
1841
+ }>, x: number, z: number) => number; };
1837
1842
  export declare const writeTerrainRingIndices: (ringIndices: Uint32Array, tileIndices: Uint16Array | Uint32Array, drawnOrdinals: readonly number[], vertexCount: number) => number;
1838
1843
  export declare const writeTerrainRingTile: (ring: TerrainTileArrays, base: number, tile: TerrainTile, finestTileSize: number) => void;
1839
1844
  export declare const bakeImpostor: (renderer: Renderer, parts: readonly ImpostorPart[], resolution: number) => Impostor;
@@ -1885,9 +1890,9 @@ export declare const RIVER_BEND_FOAM_ATTRIBUTE = "bendFoam";
1885
1890
  export declare const BEND_FOAM_FULL_RADIUS_WIDTHS = 2;
1886
1891
  export declare const createRiverGeometry: (course: readonly RiverCoursePoint[]) => BufferGeometry;
1887
1892
  export declare const createUnderwaterFogState: () => UnderwaterFogState;
1893
+ export declare const createWaterfallGeometry: ({ across, drop, lip, width }: WaterfallSheet) => BufferGeometry;
1888
1894
  export declare const createWaterFlowUniforms: () => WaterFlow;
1889
1895
  export declare const createWaterUniforms: () => WaterUniforms;
1890
- export declare const createWaterfallGeometry: ({ across, drop, lip, width }: WaterfallSheet) => BufferGeometry;
1891
1896
  export declare const updateUnderwaterFog: (eyeHeight: number, { level, underwaterFogColor, underwaterFogDensity }: Pick<WaterUniforms, "level" | "underwaterFogColor" | "underwaterFogDensity">, { color, density, heightFalloff, maxOpacity, startDistance }: FogUniforms, underwaterFogState: UnderwaterFogState) => void;
1892
1897
  export declare const createWindUniforms: () => WindUniforms;
1893
1898
  export declare const computeOriginShift: (cameraPosition: Vector3, threshold: number, step: number, shift: Vector3) => boolean;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as TERRAIN_RING_INITIAL_TILE_COUNT, C as getCliffBlend, D as TERRAIN_CELL_SIZE, E as GAUSSIAN_REACH_WIDTHS, F as GroundLayer, I as GroundLayers, L as createSeededRandom, M as TILE_INDEX_SPAN, N as createSimplexNoise, O as TERRAIN_HEIGHT_PADDING, P as TerrainFeatureKind, S as getPlateauBlend, T as getTerrainTileLevel, _ as getTerrainTileRow, a as createTerrainFeaturesBlend, b as TerrainFeatureKindBlendMap, c as sampleTerrainResidualFade, d as sampleGroundLayerField, f as getSegmentBounds, g as computeTerrainTile, h as fileByCell, i as createTerrainFeaturesHeight, j as TILE_INDEX_OFFSET, k as TERRAIN_LAYER, l as createGroundPaintColor, m as getGaussianHillBlend, n as createTerrainShapeHeight, o as getTerrainFeatureBounds, p as createGaussianHillsHeight, r as getTerrainShapeLevel, s as createResidualHeight, t as computeScatterPoints, u as createGroundLayerWeights, v as getTerrainTileColumn, w as measureSegment, x as getRidgeBlend, y as blendGridNodes } from "./terrainWorker-Bgj3rmZs.js";
1
+ import { A as TERRAIN_RING_INITIAL_TILE_COUNT, C as getTerrainTileColumn, D as TERRAIN_CELL_SIZE, E as GAUSSIAN_REACH_WIDTHS, F as GroundLayer, I as GroundLayers, L as createSeededRandom, M as TILE_INDEX_SPAN, N as createSimplexNoise, O as TERRAIN_HEIGHT_PADDING, P as TerrainFeatureKind, S as getTerrainTileRow, T as getTerrainTileLevel, _ as getSegmentBounds, a as createTerrainFeaturesBlend, b as fileByCell, c as getPlateauBlend, d as createResidualHeight, f as sampleTerrainResidualFade, g as measureSegment, h as sampleGroundLayerField, i as createTerrainFeaturesHeight, j as TILE_INDEX_OFFSET, k as TERRAIN_LAYER, l as getCliffBlend, m as createGroundLayerWeights, n as createTerrainShapeHeight, o as TerrainFeatureKindBlendMap, p as createGroundPaintColor, r as getTerrainShapeLevel, s as getRidgeBlend, t as computeScatterPoints, u as getTerrainFeatureBounds, v as createGaussianHillsHeight, w as blendGridNodes, x as computeTerrainTile, y as getGaussianHillBlend } from "./terrainWorker-JpiYqzu_.js";
2
2
  import { AdditiveBlending, BackSide, Bone, Box3, BoxGeometry, BufferAttribute, BufferGeometry, CanvasTexture, ClampToEdgeWrapping, Color, CylinderGeometry, Data3DTexture, DataTexture, DataUtils, DirectionalLight, DoubleSide, Euler, Float32BufferAttribute, FloatType, FrontSide, HalfFloatType, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, InterleavedBufferAttribute, LinearFilter, LinearMipmapLinearFilter, MathUtils, Matrix3, Matrix4, Mesh, NearestFilter, NoColorSpace, NoToneMapping, OrthographicCamera, PerspectiveCamera, Quaternion, RGBAFormat, RedFormat, RepeatWrapping, SRGBColorSpace, Scene, Skeleton, SkinnedMesh, Sphere, Sprite, Texture, UnsignedByteType, Vector2, Vector3 } from "three";
3
3
  import { Fn, If, abs, acos, asin, atan, atomicAdd, atomicStore, attribute, cameraFar, cameraNear, cameraPosition, cameraProjectionMatrix, cameraViewMatrix, clamp, color, cos, cross, diffuseColor, distance, dot, exp, exp2, float, fract, getNormalFromDepth, getViewPosition, hash, instanceIndex, instancedBufferAttribute, interleavedGradientNoise, luminance, mat4, max, min, mix, mod, modelViewMatrix, modelWorldMatrix, modelWorldMatrixInverse, mrt, mx_cell_noise_float, mx_fractal_noise_float, mx_noise_float, normalGeometry, normalLocal, normalView, normalViewGeometry, normalWorld, normalWorldGeometry, normalize, output, pass, perspectiveDepthToViewZ, positionGeometry, positionLocal, positionView, positionViewDirection, positionWorld, pow, reflect, renderOutput, sample, saturate, screenCoordinate, screenUV, select, sin, smoothstep, step, storage, tangentLocal, texture, texture3D, time, transformNormal, transformNormalToView, uint, uniform, uniformArray, uv, varying, vec2, vec3, vec4, velocity, vertexColor, viewportDepthTexture, viewportSharedTexture } from "three/tsl";
4
4
  import { IndirectStorageBufferAttribute, LightingModel, MeshBasicNodeMaterial, MeshToonNodeMaterial, NodeMaterial, RenderPipeline, RenderTarget, SpriteNodeMaterial, StorageBufferAttribute, StorageInstancedBufferAttribute, ToonOutlinePassNode, WebGPURenderer } from "three/webgpu";
@@ -27,6 +27,7 @@ let PrecipitationKind = /* @__PURE__ */ function(PrecipitationKind) {
27
27
  let WeatherKind = /* @__PURE__ */ function(WeatherKind) {
28
28
  WeatherKind["Clear"] = "Clear";
29
29
  WeatherKind["Cloudy"] = "Cloudy";
30
+ WeatherKind["Eruption"] = "Eruption";
30
31
  WeatherKind["Fog"] = "Fog";
31
32
  WeatherKind["Rain"] = "Rain";
32
33
  WeatherKind["Sandstorm"] = "Sandstorm";
@@ -37,18 +38,18 @@ let WeatherKind = /* @__PURE__ */ function(WeatherKind) {
37
38
  }({});
38
39
  // src/atmosphere/constants.ts
39
40
  const SUN_REDRAW_COSINE = Math.cos(.6 * Math.PI / 180);
40
- const DEFAULT_SKY_SHAPE = {
41
+ const DEFAULT_SKY_SHAPE = Object.freeze({
41
42
  frontBackBlend: 1,
42
43
  haloHeight: 1,
43
44
  horizonBand: .45,
44
45
  moonSize: 1,
45
46
  sunHaloSize: 1
46
- };
47
+ });
47
48
  const DEFAULT_SAMPLE_COUNT = 33;
48
- const DEFAULT_SKY_GRADIENT = {
49
- green: Array.from({ length: DEFAULT_SAMPLE_COUNT }, () => 0),
50
- red: Array.from({ length: DEFAULT_SAMPLE_COUNT }, (_value, index) => 1 - MathUtils.smoothstep(index, 0, 32))
51
- };
49
+ const DEFAULT_SKY_GRADIENT = Object.freeze({
50
+ green: Object.freeze(Array.from({ length: DEFAULT_SAMPLE_COUNT }, () => 0)),
51
+ red: Object.freeze(Array.from({ length: DEFAULT_SAMPLE_COUNT }, (_value, index) => 1 - MathUtils.smoothstep(index, 0, 32)))
52
+ });
52
53
  const PRECIPITATION_COUNT = 2048;
53
54
  const PRECIPITATION_VOLUME_SIZE = 60;
54
55
  const PRECIPITATION_VOLUME_HEIGHT = 30;
@@ -99,6 +100,11 @@ const WEATHER_SETTINGS_MAP = {
99
100
  fogDensity: 0,
100
101
  wetness: 0
101
102
  },
103
+ ["Eruption"]: {
104
+ cloudCoverage: .8,
105
+ fogDensity: .004,
106
+ wetness: 0
107
+ },
102
108
  ["Fog"]: {
103
109
  cloudCoverage: .4,
104
110
  fogDensity: .006,
@@ -784,12 +790,12 @@ const FREE_CAMERA_BASE_SPEED = 8;
784
790
  const FREE_CAMERA_SPEED_PER_HEIGHT = .5;
785
791
  const FREE_CAMERA_CLEARANCE = 1.5;
786
792
  const FREE_CAMERA_MAX_PITCH = Math.PI / 2 - .01;
787
- const FOLLOW_CAMERA_DEFAULT_SETTINGS = {
793
+ const FOLLOW_CAMERA_DEFAULT_SETTINGS = Object.freeze({
788
794
  defaultDistance: 5,
789
795
  horizontalSensitivity: 3,
790
796
  slopePitch: false,
791
797
  verticalSensitivity: 3
792
- };
798
+ });
793
799
  const FOLLOW_CAMERA_NEUTRAL_SENSITIVITY = 3;
794
800
  const FOLLOW_CAMERA_PIVOT_SHARE = .7;
795
801
  const FOLLOW_CAMERA_FOV = 45;
@@ -1983,7 +1989,6 @@ const getToneColour = (colour, desaturateScale, contrastScale) => {
1983
1989
  // src/models/nodes/ToonNodeMaterial.ts
1984
1990
  var ToonNodeMaterial = class extends MeshToonNodeMaterial {
1985
1991
  edge;
1986
- emissiveNode = null;
1987
1992
  instanceMatrix;
1988
1993
  isMeshToonMaterial;
1989
1994
  isMeshToonNodeMaterial;
@@ -2166,11 +2171,23 @@ const parsePmxBones = (reader) => Array.from({ length: reader.readInt32() }, ()
2166
2171
  position
2167
2172
  };
2168
2173
  });
2174
+ // src/models/character/PmxJointKind.ts
2175
+ let PmxJointKind = /* @__PURE__ */ function(PmxJointKind) {
2176
+ PmxJointKind[PmxJointKind["SpringSixDegreesOfFreedom"] = 0] = "SpringSixDegreesOfFreedom";
2177
+ PmxJointKind[PmxJointKind["SixDegreesOfFreedom"] = 1] = "SixDegreesOfFreedom";
2178
+ PmxJointKind[PmxJointKind["PointToPoint"] = 2] = "PointToPoint";
2179
+ PmxJointKind[PmxJointKind["ConeTwist"] = 3] = "ConeTwist";
2180
+ PmxJointKind[PmxJointKind["Slider"] = 4] = "Slider";
2181
+ PmxJointKind[PmxJointKind["Hinge"] = 5] = "Hinge";
2182
+ return PmxJointKind;
2183
+ }({});
2169
2184
  // src/character/parsePmxJoints.ts
2185
+ const checkIsPmxJointKind = (value) => value in PmxJointKind;
2170
2186
  const parsePmxJoints = (reader) => Array.from({ length: reader.readInt32() }, () => {
2171
2187
  const name = reader.readText();
2172
2188
  reader.readText();
2173
2189
  const kind = reader.readUint8();
2190
+ if (!checkIsPmxJointKind(kind)) throw new RangeError(`Unknown PMX joint kind ${kind}`);
2174
2191
  const firstRigidBodyIndex = reader.readRigidBodyIndex();
2175
2192
  const secondRigidBodyIndex = reader.readRigidBodyIndex();
2176
2193
  const position = reader.readMirroredVector3();
@@ -2219,6 +2236,7 @@ let PmxMaterialFlag = /* @__PURE__ */ function(PmxMaterialFlag) {
2219
2236
  return PmxMaterialFlag;
2220
2237
  }({});
2221
2238
  // src/character/parsePmxMaterials.ts
2239
+ const checkIsPmxSphereMode = (value) => value in PmxSphereMode;
2222
2240
  const parsePmxMaterials = (reader) => Array.from({ length: reader.readInt32() }, () => {
2223
2241
  const name = reader.readText();
2224
2242
  reader.readText();
@@ -2250,6 +2268,7 @@ const parsePmxMaterials = (reader) => Array.from({ length: reader.readInt32() },
2250
2268
  const textureIndex = reader.readTextureIndex();
2251
2269
  const sphereTextureIndex = reader.readTextureIndex();
2252
2270
  const sphereMode = reader.readUint8();
2271
+ if (!checkIsPmxSphereMode(sphereMode)) throw new RangeError(`Unknown PMX sphere mode ${sphereMode}`);
2253
2272
  const isToonShared = Boolean(reader.readUint8());
2254
2273
  const toonIndex = isToonShared ? reader.readUint8() : reader.readTextureIndex();
2255
2274
  reader.readText();
@@ -2298,11 +2317,13 @@ const PmxMorphKindOffsetSizeMap = {
2298
2317
  [8]: ({ materialIndexSize }) => materialIndexSize + 113,
2299
2318
  [3]: ({ vertexIndexSize }) => vertexIndexSize + 16
2300
2319
  };
2320
+ const checkIsPmxMorphKind = (value) => value in PmxMorphKind;
2301
2321
  const parsePmxMorphs = (reader) => Array.from({ length: reader.readInt32() }, () => {
2302
2322
  const name = reader.readText();
2303
2323
  reader.readText();
2304
2324
  reader.readUint8();
2305
2325
  const kind = reader.readUint8();
2326
+ if (!checkIsPmxMorphKind(kind)) throw new RangeError(`Unknown PMX morph kind ${kind}`);
2306
2327
  const offsetCount = reader.readInt32();
2307
2328
  if (kind === 0) {
2308
2329
  const indices = new Uint32Array(offsetCount);
@@ -2340,7 +2361,23 @@ const parsePmxMorphs = (reader) => Array.from({ length: reader.readInt32() }, ()
2340
2361
  values: /* @__PURE__ */ new Float32Array()
2341
2362
  };
2342
2363
  });
2364
+ // src/models/character/PmxPhysicsMode.ts
2365
+ let PmxPhysicsMode = /* @__PURE__ */ function(PmxPhysicsMode) {
2366
+ PmxPhysicsMode[PmxPhysicsMode["FollowBone"] = 0] = "FollowBone";
2367
+ PmxPhysicsMode[PmxPhysicsMode["Physics"] = 1] = "Physics";
2368
+ PmxPhysicsMode[PmxPhysicsMode["PhysicsWithBone"] = 2] = "PhysicsWithBone";
2369
+ return PmxPhysicsMode;
2370
+ }({});
2371
+ // src/models/character/PmxRigidBodyShape.ts
2372
+ let PmxRigidBodyShape = /* @__PURE__ */ function(PmxRigidBodyShape) {
2373
+ PmxRigidBodyShape[PmxRigidBodyShape["Sphere"] = 0] = "Sphere";
2374
+ PmxRigidBodyShape[PmxRigidBodyShape["Box"] = 1] = "Box";
2375
+ PmxRigidBodyShape[PmxRigidBodyShape["Capsule"] = 2] = "Capsule";
2376
+ return PmxRigidBodyShape;
2377
+ }({});
2343
2378
  // src/character/parsePmxRigidBodies.ts
2379
+ const checkIsPmxRigidBodyShape = (value) => value in PmxRigidBodyShape;
2380
+ const checkIsPmxPhysicsMode = (value) => value in PmxPhysicsMode;
2344
2381
  const parsePmxRigidBodies = (reader) => Array.from({ length: reader.readInt32() }, () => {
2345
2382
  const name = reader.readText();
2346
2383
  reader.readText();
@@ -2348,6 +2385,7 @@ const parsePmxRigidBodies = (reader) => Array.from({ length: reader.readInt32()
2348
2385
  const group = reader.readUint8();
2349
2386
  const nonCollidingGroups = reader.readUint16();
2350
2387
  const shape = reader.readUint8();
2388
+ if (!checkIsPmxRigidBodyShape(shape)) throw new RangeError(`Unknown PMX rigid body shape ${shape}`);
2351
2389
  const size = reader.readVector3();
2352
2390
  const position = reader.readMirroredVector3();
2353
2391
  const rotation = reader.readMirroredRotation();
@@ -2355,16 +2393,19 @@ const parsePmxRigidBodies = (reader) => Array.from({ length: reader.readInt32()
2355
2393
  const linearDamping = reader.readFloat32();
2356
2394
  const angularDamping = reader.readFloat32();
2357
2395
  const restitution = reader.readFloat32();
2396
+ const friction = reader.readFloat32();
2397
+ const physicsMode = reader.readUint8();
2398
+ if (!checkIsPmxPhysicsMode(physicsMode)) throw new RangeError(`Unknown PMX physics mode ${physicsMode}`);
2358
2399
  return {
2359
2400
  angularDamping,
2360
2401
  boneIndex,
2361
- friction: reader.readFloat32(),
2402
+ friction,
2362
2403
  group,
2363
2404
  linearDamping,
2364
2405
  mass,
2365
2406
  name,
2366
2407
  nonCollidingGroups,
2367
- physicsMode: reader.readUint8(),
2408
+ physicsMode,
2368
2409
  position,
2369
2410
  restitution,
2370
2411
  rotation,
@@ -2389,6 +2430,7 @@ const PmxWeightDeformBoneCountMap = {
2389
2430
  [3]: 2,
2390
2431
  [1]: 2
2391
2432
  };
2433
+ const checkIsPmxWeightDeform = (value) => value in PmxWeightDeform;
2392
2434
  const parsePmxVertices = (reader) => {
2393
2435
  const vertexCount = reader.readInt32();
2394
2436
  const positions = new Float32Array(vertexCount * 3);
@@ -2409,6 +2451,7 @@ const parsePmxVertices = (reader) => {
2409
2451
  }
2410
2452
  const skinOffset = vertex * 4;
2411
2453
  const weightDeform = reader.readUint8();
2454
+ if (!checkIsPmxWeightDeform(weightDeform)) throw new RangeError(`Unknown PMX weight deform ${weightDeform}`);
2412
2455
  const boneCount = PmxWeightDeformBoneCountMap[weightDeform];
2413
2456
  for (let slot = 0; slot < boneCount; slot++) skinIndices[skinOffset + slot] = Math.max(reader.readBoneIndex(), 0);
2414
2457
  if (boneCount === 1) skinWeights[skinOffset] = 1;
@@ -3074,6 +3117,14 @@ const createInstanceCulling = ({ count, indexCount, isVisible }) => {
3074
3117
  survivor: float(storage(survivorAttribute, "uint", count).toReadOnly().element(instanceIndex))
3075
3118
  };
3076
3119
  };
3120
+ // src/culling/createInstancedGeometry.ts
3121
+ const createInstancedGeometry = (geometry, instanceCount) => {
3122
+ const instancedGeometry = new InstancedBufferGeometry();
3123
+ for (const [name, attribute] of Object.entries(geometry.attributes)) instancedGeometry.setAttribute(name, attribute);
3124
+ instancedGeometry.setIndex(geometry.getIndex());
3125
+ instancedGeometry.instanceCount = instanceCount;
3126
+ return instancedGeometry;
3127
+ };
3077
3128
  // src/culling/createInstanceMatrixBuffer.ts
3078
3129
  const createInstanceMatrixBuffer = (matrices) => {
3079
3130
  const array = new Float32Array(matrices.length * 16);
@@ -3087,14 +3138,6 @@ const createInstanceMatrixNode = (attribute, instance) => {
3087
3138
  const column = (offset) => columns.element(firstColumn.add(uint(offset)));
3088
3139
  return mat4(column(0), column(1), column(2), column(3));
3089
3140
  };
3090
- // src/culling/createInstancedGeometry.ts
3091
- const createInstancedGeometry = (geometry, instanceCount) => {
3092
- const instancedGeometry = new InstancedBufferGeometry();
3093
- for (const [name, attribute] of Object.entries(geometry.attributes)) instancedGeometry.setAttribute(name, attribute);
3094
- instancedGeometry.setIndex(geometry.getIndex());
3095
- instancedGeometry.instanceCount = instanceCount;
3096
- return instancedGeometry;
3097
- };
3098
3141
  // src/models/input/GamepadButton.ts
3099
3142
  let GamepadButton = /* @__PURE__ */ function(GamepadButton) {
3100
3143
  GamepadButton["Back"] = "GamepadBack";
@@ -3122,6 +3165,60 @@ let MouseButton = /* @__PURE__ */ function(MouseButton) {
3122
3165
  MouseButton["Secondary"] = "MouseSecondary";
3123
3166
  return MouseButton;
3124
3167
  }({});
3168
+ // src/input/constants.ts
3169
+ const KEY_CODE_FORWARD = "KeyW";
3170
+ const KEY_CODE_BACKWARD = "KeyS";
3171
+ const KEY_CODE_LEFT = "KeyA";
3172
+ const KEY_CODE_RIGHT = "KeyD";
3173
+ const KEY_CODE_UP = "Space";
3174
+ const KEY_CODE_DOWN = "ShiftLeft";
3175
+ const FOCUS_KEY_CODES = [
3176
+ "Enter",
3177
+ "Space",
3178
+ "Tab"
3179
+ ];
3180
+ const FIELD_SELECTOR = "input, select, textarea, [contenteditable=\"true\"]";
3181
+ const GAMEPAD_BUTTONS = [
3182
+ "GamepadFaceBottom",
3183
+ "GamepadFaceRight",
3184
+ "GamepadFaceLeft",
3185
+ "GamepadFaceTop",
3186
+ "GamepadLeftBumper",
3187
+ "GamepadRightBumper",
3188
+ "GamepadLeftTrigger",
3189
+ "GamepadRightTrigger",
3190
+ "GamepadBack",
3191
+ "GamepadStart",
3192
+ "GamepadLeftStick",
3193
+ "GamepadRightStick",
3194
+ "GamepadDirectionalPadUp",
3195
+ "GamepadDirectionalPadDown",
3196
+ "GamepadDirectionalPadLeft",
3197
+ "GamepadDirectionalPadRight"
3198
+ ];
3199
+ const MOUSE_BUTTONS = [
3200
+ "MousePrimary",
3201
+ "MouseAuxiliary",
3202
+ "MouseSecondary"
3203
+ ];
3204
+ const MOUSE_LOOK_RADIANS_PER_PIXEL = .002;
3205
+ const MOUSE_LOOK_MAX_PIXELS_PER_EVENT = Math.PI / MOUSE_LOOK_RADIANS_PER_PIXEL;
3206
+ const GAMEPAD_LOOK_RADIANS_PER_SECOND = 2.5;
3207
+ const GAMEPAD_STICK_DEADZONE = .15;
3208
+ // src/input/createIdleInputState.ts
3209
+ const createIdleInputState = () => ({
3210
+ heldActions: /* @__PURE__ */ new Set(),
3211
+ lookPitch: 0,
3212
+ lookYaw: 0,
3213
+ menuDown: 0,
3214
+ menuRight: 0,
3215
+ menuTabSteps: 0,
3216
+ moveForward: 0,
3217
+ moveRight: 0,
3218
+ moveUp: 0,
3219
+ pressedActions: /* @__PURE__ */ new Set(),
3220
+ zoomSteps: 0
3221
+ });
3125
3222
  // src/input/InputActionBindingMap.ts
3126
3223
  const InputActionBindingMap = {
3127
3224
  ["Aim"]: [["KeyR"], ["GamepadLeftTrigger"]],
@@ -3168,49 +3265,13 @@ const InputActionBindingMap = {
3168
3265
  ["SwitchToPartyMemberAndBurst4"]: [["AltLeft", "Digit4"]],
3169
3266
  ["SwitchWalkRun"]: [["ControlLeft"]]
3170
3267
  };
3171
- // src/input/constants.ts
3172
- const KEY_CODE_FORWARD = "KeyW";
3173
- const KEY_CODE_BACKWARD = "KeyS";
3174
- const KEY_CODE_LEFT = "KeyA";
3175
- const KEY_CODE_RIGHT = "KeyD";
3176
- const KEY_CODE_UP = "Space";
3177
- const KEY_CODE_DOWN = "ShiftLeft";
3178
- const FOCUS_KEY_CODES = [
3179
- "Enter",
3180
- "Space",
3181
- "Tab"
3182
- ];
3183
- const FIELD_SELECTOR = "input, select, textarea, [contenteditable=\"true\"]";
3184
- const GAMEPAD_BUTTONS = [
3185
- "GamepadFaceBottom",
3186
- "GamepadFaceRight",
3187
- "GamepadFaceLeft",
3188
- "GamepadFaceTop",
3189
- "GamepadLeftBumper",
3190
- "GamepadRightBumper",
3191
- "GamepadLeftTrigger",
3192
- "GamepadRightTrigger",
3193
- "GamepadBack",
3194
- "GamepadStart",
3195
- "GamepadLeftStick",
3196
- "GamepadRightStick",
3197
- "GamepadDirectionalPadUp",
3198
- "GamepadDirectionalPadDown",
3199
- "GamepadDirectionalPadLeft",
3200
- "GamepadDirectionalPadRight"
3201
- ];
3202
- const MOUSE_BUTTONS = [
3203
- "MousePrimary",
3204
- "MouseAuxiliary",
3205
- "MouseSecondary"
3206
- ];
3207
- const MOUSE_LOOK_RADIANS_PER_PIXEL = .002;
3208
- const MOUSE_LOOK_MAX_PIXELS_PER_EVENT = Math.PI / MOUSE_LOOK_RADIANS_PER_PIXEL;
3209
- const GAMEPAD_LOOK_RADIANS_PER_SECOND = 2.5;
3210
- const GAMEPAD_STICK_DEADZONE = .15;
3211
- // src/input/createInput.ts
3268
+ // src/input/toAxis.ts
3212
3269
  const toAxis = (positive, negative) => Number(positive) - Number(negative);
3270
+ // src/input/toClamped.ts
3271
+ const toClamped = (axis) => Math.max(-1, Math.min(1, axis));
3272
+ // src/input/toDeadzoned.ts
3213
3273
  const toDeadzoned = (stickAxis) => Math.abs(stickAxis) < .15 ? 0 : stickAxis;
3274
+ // src/input/createInput.ts
3214
3275
  const createInput = (target) => {
3215
3276
  const controller = new AbortController();
3216
3277
  const { signal } = controller;
@@ -3227,14 +3288,9 @@ const createInput = (target) => {
3227
3288
  const heldActions = /* @__PURE__ */ new Set();
3228
3289
  const pressedActions = /* @__PURE__ */ new Set();
3229
3290
  const inputState = {
3291
+ ...createIdleInputState(),
3230
3292
  heldActions,
3231
- lookPitch: 0,
3232
- lookYaw: 0,
3233
- moveForward: 0,
3234
- moveRight: 0,
3235
- moveUp: 0,
3236
- pressedActions,
3237
- zoomSteps: 0
3293
+ pressedActions
3238
3294
  };
3239
3295
  const press = (code) => {
3240
3296
  if (!heldCodes.has(code)) pressedCodes.add(code);
@@ -3291,9 +3347,12 @@ const createInput = (target) => {
3291
3347
  pendingLookYaw = 0;
3292
3348
  pendingLookPitch = 0;
3293
3349
  pendingZoomSteps = 0;
3294
- inputState.moveForward = Math.max(-1, Math.min(1, toAxis(heldCodes.has(KEY_CODE_FORWARD), heldCodes.has(KEY_CODE_BACKWARD)) - toDeadzoned(stickY) - touchStickY));
3295
- inputState.moveRight = Math.max(-1, Math.min(1, toAxis(heldCodes.has(KEY_CODE_RIGHT), heldCodes.has(KEY_CODE_LEFT)) + toDeadzoned(stickX) + touchStickX));
3350
+ inputState.moveForward = toClamped(toAxis(heldCodes.has(KEY_CODE_FORWARD), heldCodes.has(KEY_CODE_BACKWARD)) - toDeadzoned(stickY) - touchStickY);
3351
+ inputState.moveRight = toClamped(toAxis(heldCodes.has(KEY_CODE_RIGHT), heldCodes.has(KEY_CODE_LEFT)) + toDeadzoned(stickX) + touchStickX);
3296
3352
  inputState.moveUp = toAxis(heldCodes.has(KEY_CODE_UP), heldCodes.has(KEY_CODE_DOWN));
3353
+ inputState.menuDown = toClamped(toAxis(heldCodes.has("GamepadDirectionalPadDown"), heldCodes.has("GamepadDirectionalPadUp")) + toDeadzoned(stickY));
3354
+ inputState.menuRight = toClamped(toAxis(heldCodes.has("GamepadDirectionalPadRight"), heldCodes.has("GamepadDirectionalPadLeft")) + toDeadzoned(stickX));
3355
+ inputState.menuTabSteps = toAxis(pressedCodes.has("GamepadRightBumper"), pressedCodes.has("GamepadLeftBumper"));
3297
3356
  codeChordLengthMap.clear();
3298
3357
  for (const action of InputActions) for (const chord of InputActionBindingMap[action]) {
3299
3358
  const lastCode = chord.at(-1);
@@ -4254,41 +4313,6 @@ const createCharacterController = (options) => {
4254
4313
  }
4255
4314
  };
4256
4315
  };
4257
- // src/models/character/PmxJointKind.ts
4258
- let PmxJointKind = /* @__PURE__ */ function(PmxJointKind) {
4259
- PmxJointKind[PmxJointKind["SpringSixDegreesOfFreedom"] = 0] = "SpringSixDegreesOfFreedom";
4260
- PmxJointKind[PmxJointKind["SixDegreesOfFreedom"] = 1] = "SixDegreesOfFreedom";
4261
- PmxJointKind[PmxJointKind["PointToPoint"] = 2] = "PointToPoint";
4262
- PmxJointKind[PmxJointKind["ConeTwist"] = 3] = "ConeTwist";
4263
- PmxJointKind[PmxJointKind["Slider"] = 4] = "Slider";
4264
- PmxJointKind[PmxJointKind["Hinge"] = 5] = "Hinge";
4265
- return PmxJointKind;
4266
- }({});
4267
- // src/models/character/PmxPhysicsMode.ts
4268
- let PmxPhysicsMode = /* @__PURE__ */ function(PmxPhysicsMode) {
4269
- PmxPhysicsMode[PmxPhysicsMode["FollowBone"] = 0] = "FollowBone";
4270
- PmxPhysicsMode[PmxPhysicsMode["Physics"] = 1] = "Physics";
4271
- PmxPhysicsMode[PmxPhysicsMode["PhysicsWithBone"] = 2] = "PhysicsWithBone";
4272
- return PmxPhysicsMode;
4273
- }({});
4274
- // src/models/character/PmxRigidBodyShape.ts
4275
- let PmxRigidBodyShape = /* @__PURE__ */ function(PmxRigidBodyShape) {
4276
- PmxRigidBodyShape[PmxRigidBodyShape["Sphere"] = 0] = "Sphere";
4277
- PmxRigidBodyShape[PmxRigidBodyShape["Box"] = 1] = "Box";
4278
- PmxRigidBodyShape[PmxRigidBodyShape["Capsule"] = 2] = "Capsule";
4279
- return PmxRigidBodyShape;
4280
- }({});
4281
- // src/models/nodes/ObjectSurface.ts
4282
- var ObjectSurface = class {
4283
- amplitudes;
4284
- color;
4285
- texelsPerMetre;
4286
- constructor(color, amplitudes, texelsPerMetre) {
4287
- this.amplitudes = amplitudes;
4288
- this.color = color;
4289
- this.texelsPerMetre = texelsPerMetre;
4290
- }
4291
- };
4292
4316
  // src/models/nodes/createOutlineMaterial.ts
4293
4317
  const createOutlineMaterial = (colorNode, thicknessNode, instanceMatrix) => {
4294
4318
  const material = Object.assign(new NodeMaterial(), { isMeshToonOutlineMaterial: true });
@@ -4318,6 +4342,22 @@ const createGameOutlineMaterial = (colorNode, widthNode, offsetNode) => {
4318
4342
  material.colorNode = colorNode;
4319
4343
  return material;
4320
4344
  };
4345
+ // src/models/nodes/getGameOutlineOffset.ts
4346
+ const getGameOutlineOffset = (viewPosition, blue, blockBChannel, size) => {
4347
+ const scale = blockBChannel < .5 ? blue - .5 : 1;
4348
+ return viewPosition.clone().normalize().multiplyScalar(size * scale);
4349
+ };
4350
+ // src/models/nodes/ObjectSurface.ts
4351
+ var ObjectSurface = class {
4352
+ amplitudes;
4353
+ color;
4354
+ texelsPerMetre;
4355
+ constructor(color, amplitudes, texelsPerMetre) {
4356
+ this.amplitudes = amplitudes;
4357
+ this.color = color;
4358
+ this.texelsPerMetre = texelsPerMetre;
4359
+ }
4360
+ };
4321
4361
  // src/models/nodes/SharedToonOutlinePassNode.ts
4322
4362
  var SharedToonOutlinePassNode = class extends ToonOutlinePassNode {
4323
4363
  #drawn;
@@ -4422,11 +4462,6 @@ var StoneNodeMaterial = class extends NodeMaterial {
4422
4462
  return new StoneLightingModel(this.stoneLight);
4423
4463
  }
4424
4464
  };
4425
- // src/models/nodes/getGameOutlineOffset.ts
4426
- const getGameOutlineOffset = (viewPosition, blue, blockBChannel, size) => {
4427
- const scale = blockBChannel < .5 ? blue - .5 : 1;
4428
- return viewPosition.clone().normalize().multiplyScalar(size * scale);
4429
- };
4430
4465
  // src/models/renderer/AntialiasingMode.ts
4431
4466
  let AntialiasingMode = /* @__PURE__ */ function(AntialiasingMode) {
4432
4467
  AntialiasingMode["Smaa"] = "Smaa";
@@ -4713,14 +4748,6 @@ const createLeafMaterial = (toonMaterialOptions, windUniforms, maskNode) => {
4713
4748
  }
4714
4749
  return leafMaterial;
4715
4750
  };
4716
- // src/nodes/createLightUniforms.ts
4717
- const createLightUniforms = () => ({
4718
- lightColor: uniform(new Color()),
4719
- rimColor: uniform(new Color()),
4720
- rimStrength: uniform(0),
4721
- sunDirection: uniform(new Vector3(0, 1, 0)),
4722
- wetness: uniform(0)
4723
- });
4724
4751
  // src/nodes/createLightningBoltMaterial.ts
4725
4752
  const createLightningBoltMaterial = (flash) => {
4726
4753
  const lightningBoltMaterial = new MeshBasicNodeMaterial({
@@ -4736,6 +4763,14 @@ const createLightningBoltMaterial = (flash) => {
4736
4763
  lightningBoltMaterial.opacityNode = flash;
4737
4764
  return lightningBoltMaterial;
4738
4765
  };
4766
+ // src/nodes/createLightUniforms.ts
4767
+ const createLightUniforms = () => ({
4768
+ lightColor: uniform(new Color()),
4769
+ rimColor: uniform(new Color()),
4770
+ rimStrength: uniform(0),
4771
+ sunDirection: uniform(new Vector3(0, 1, 0)),
4772
+ wetness: uniform(0)
4773
+ });
4739
4774
  // src/nodes/createObjectFadeNode.ts
4740
4775
  const createObjectFadeNode = () => uniform(0).onObjectUpdate(({ object }) => {
4741
4776
  const fade = object?.userData[OBJECT_FADE_KEY];
@@ -5247,6 +5282,30 @@ const toneMapGenshin = (sceneColor, toneMapped = [
5247
5282
  for (let index = 0; index < 3; index++) toneMapped[index] = Math.min(Math.max(1.0001 - 2 ** (-1 * (sceneColor[index] ?? 0)), 0) ** .51, 1);
5248
5283
  return toneMapped;
5249
5284
  };
5285
+ // src/renderer/createGenshinRenderer.ts
5286
+ const createGenshinRenderer = (canvas) => {
5287
+ const isWindows = window.navigator.userAgent.includes("Windows");
5288
+ const renderer = new WebGPURenderer({
5289
+ antialias: false,
5290
+ canvas,
5291
+ ...isWindows ? {} : { powerPreference: "high-performance" }
5292
+ });
5293
+ renderer.toneMapping = GENSHIN_TONE_MAPPING;
5294
+ return renderer;
5295
+ };
5296
+ // src/renderer/createInstancedMesh.ts
5297
+ const createInstancedMesh = (geometry, material, count) => {
5298
+ const mesh = new InstancedMesh(geometry, material, count);
5299
+ mesh.instanceMatrix = new StorageInstancedBufferAttribute(mesh.instanceMatrix.array, mesh.instanceMatrix.itemSize);
5300
+ return mesh;
5301
+ };
5302
+ // src/renderer/getScreenDirection.ts
5303
+ const X_AXIS = new Vector3(1, 0, 0);
5304
+ const Y_AXIS = new Vector3(0, 1, 0);
5305
+ const getScreenDirection = ({ aspect, fov, pitch, yaw }, [x, y]) => {
5306
+ const halfHeight = Math.tan(MathUtils.degToRad(fov) / 2);
5307
+ return new Vector3((x * 2 - 1) * halfHeight * aspect, (1 - y * 2) * halfHeight, -1).normalize().applyAxisAngle(X_AXIS, pitch).applyAxisAngle(Y_AXIS, yaw);
5308
+ };
5250
5309
  // src/renderer/QualityTierSettingsMap.ts
5251
5310
  const QualityTierSettingsMap = {
5252
5311
  ["High"]: {
@@ -5280,39 +5339,6 @@ const QualityTierSettingsMap = {
5280
5339
  shadowMapSize: 1024
5281
5340
  }
5282
5341
  };
5283
- // src/renderer/attachInspector.ts
5284
- const attachInspector = async (renderer) => {
5285
- const { Inspector } = await import("three/examples/jsm/inspector/Inspector.js");
5286
- if (renderer.inspector instanceof Inspector) return renderer.inspector;
5287
- const inspector = new Inspector();
5288
- renderer.inspector = inspector;
5289
- return inspector;
5290
- };
5291
- // src/renderer/createGenshinRenderer.ts
5292
- const createGenshinRenderer = (canvas) => {
5293
- const isWindows = window.navigator.userAgent.includes("Windows");
5294
- const renderer = new WebGPURenderer({
5295
- antialias: false,
5296
- canvas,
5297
- ...isWindows ? {} : { powerPreference: "high-performance" }
5298
- });
5299
- renderer.toneMapping = GENSHIN_TONE_MAPPING;
5300
- if (import.meta.env?.DEV && !window.navigator.webdriver) attachInspector(renderer);
5301
- return renderer;
5302
- };
5303
- // src/renderer/createInstancedMesh.ts
5304
- const createInstancedMesh = (geometry, material, count) => {
5305
- const mesh = new InstancedMesh(geometry, material, count);
5306
- mesh.instanceMatrix = new StorageInstancedBufferAttribute(mesh.instanceMatrix.array, mesh.instanceMatrix.itemSize);
5307
- return mesh;
5308
- };
5309
- // src/renderer/getScreenDirection.ts
5310
- const X_AXIS = new Vector3(1, 0, 0);
5311
- const Y_AXIS = new Vector3(0, 1, 0);
5312
- const getScreenDirection = ({ aspect, fov, pitch, yaw }, [x, y]) => {
5313
- const halfHeight = Math.tan(MathUtils.degToRad(fov) / 2);
5314
- return new Vector3((x * 2 - 1) * halfHeight * aspect, (1 - y * 2) * halfHeight, -1).normalize().applyAxisAngle(X_AXIS, pitch).applyAxisAngle(Y_AXIS, yaw);
5315
- };
5316
5342
  // src/simulation/constants.ts
5317
5343
  const MAX_STEPS_PER_FRAME = 5;
5318
5344
  // src/simulation/createFixedStepLoop.ts
@@ -6318,18 +6344,6 @@ const createUnderwaterFogState = () => ({
6318
6344
  isUnderwater: false,
6319
6345
  underwaterDensity: 0
6320
6346
  });
6321
- // src/water/createWaterUniforms.ts
6322
- const createWaterUniforms = () => ({
6323
- causticStrength: uniform(0),
6324
- deepColor: uniform(new Color()),
6325
- deepDepth: uniform(1),
6326
- foamColor: uniform(new Color(16777215)),
6327
- foamDepth: uniform(0),
6328
- level: uniform(0),
6329
- shallowColor: uniform(new Color()),
6330
- underwaterFogColor: uniform(new Color()),
6331
- underwaterFogDensity: uniform(0)
6332
- });
6333
6347
  // src/water/createWaterfallGeometry.ts
6334
6348
  const createWaterfallGeometry = ({ across, drop, lip, width }) => {
6335
6349
  const halfWidth = width / 2;
@@ -6370,6 +6384,18 @@ const createWaterfallGeometry = ({ across, drop, lip, width }) => {
6370
6384
  ]);
6371
6385
  return geometry;
6372
6386
  };
6387
+ // src/water/createWaterUniforms.ts
6388
+ const createWaterUniforms = () => ({
6389
+ causticStrength: uniform(0),
6390
+ deepColor: uniform(new Color()),
6391
+ deepDepth: uniform(1),
6392
+ foamColor: uniform(new Color(16777215)),
6393
+ foamDepth: uniform(0),
6394
+ level: uniform(0),
6395
+ shallowColor: uniform(new Color()),
6396
+ underwaterFogColor: uniform(new Color()),
6397
+ underwaterFogDensity: uniform(0)
6398
+ });
6373
6399
  // src/water/updateUnderwaterFog.ts
6374
6400
  const updateUnderwaterFog = (eyeHeight, { level, underwaterFogColor, underwaterFogDensity }, { color, density, heightFalloff, maxOpacity, startDistance }, underwaterFogState) => {
6375
6401
  const isUnderwater = eyeHeight < level.value;
@@ -6426,4 +6452,4 @@ const computeOutlineDistance = (outline, x, z) => {
6426
6452
  }
6427
6453
  return isInside ? 0 : Math.sqrt(nearestSquared);
6428
6454
  };
6429
- export { A4_FREQUENCY, A4_PITCH, AIR_LOCOMOTION_STATES, AnchoredCascadeShadowNode, AntialiasingMode, BEND_FOAM_FULL_RADIUS_WIDTHS, CLIMB_JUMP_STAMINA_COST, CLIMB_LOCOMOTION_STATES, CLIMB_REGRAB_SECONDS, CLIMB_STAMINA_PER_SECOND, CLIMB_START_STAMINA, COOL_RAMP_ROW_BASE, CULLING_FRUSTUM_MARGIN, CULLING_INDEX_COUNT_INDEX, CULLING_INDIRECT_ARGUMENT_COUNT, CULLING_INSTANCE_COUNT_INDEX, CULLING_MATRIX_COLUMN_COUNT, CULLING_MATRIX_ELEMENT_COUNT, CULLING_MIN_SIZE, CharacterMaterialKind, DASH_STAMINA_COST, DEFAULT_LIGHT_AREA, DEFAULT_RAMP_WIDTH, DEFAULT_SKY_GRADIENT, DEFAULT_SKY_SHAPE, DESATURATION_WEIGHTS, EMISSION_ALPHA_FLOOR, FIELD_SELECTOR, FLAT_LIGHT_MAP, FLOWER_BEND_PER_WIND, FLOWER_COLOR_ATTRIBUTE_NAME, FLOWER_MATRIX_ATTRIBUTE_NAMES, FOCUS_KEY_CODES, FOLLOW_CAMERA_ARM_STEP, FOLLOW_CAMERA_CLEARANCE, FOLLOW_CAMERA_DEFAULT_SETTINGS, FOLLOW_CAMERA_DISTANCE_PER_ZOOM_STEP, FOLLOW_CAMERA_EASE_OUT_SPEED, FOLLOW_CAMERA_FOV, FOLLOW_CAMERA_MAX_DISTANCE, FOLLOW_CAMERA_MAX_PITCH, FOLLOW_CAMERA_MIN_DISTANCE, FOLLOW_CAMERA_MIN_PITCH, FOLLOW_CAMERA_NEUTRAL_SENSITIVITY, FOLLOW_CAMERA_PIVOT_SHARE, FOLLOW_CAMERA_SLOPE_PITCH_SPEED, FREE_CAMERA_BASE_SPEED, FREE_CAMERA_CLEARANCE, FREE_CAMERA_MAX_PITCH, FREE_CAMERA_SPEED_PER_HEIGHT, GAMEPAD_BUTTONS, GAMEPAD_LOOK_RADIANS_PER_SECOND, GAMEPAD_STICK_DEADZONE, GAME_MINUTES_PER_SECOND, GAUSSIAN_REACH_WIDTHS, GENSHIN_TONE_CONTRAST, GENSHIN_TONE_EXPOSURE, GENSHIN_TONE_MAPPING, GLIDE_STAMINA_PER_SECOND, GRASS_BEND_PER_WIND, GRASS_DIP_PER_BEND, GRASS_TRAIL_BEND_SHARE, GRASS_TRAIL_EXTENT, GRASS_TRAIL_FADE_END_SHARE, GRASS_TRAIL_FADE_SECONDS, GRASS_TRAIL_FADE_START_SHARE, GRASS_TRAIL_STAMP_RADIUS, GRASS_TRAIL_TEXELS, GRASS_TRAIL_TEXEL_SIZE, GROUND_CONTACT_DISTANCE, GROUND_LOCOMOTION_STATES, GROUND_NORMAL_SPAN, GROUND_PRESS_SPEED, GamepadButton, GroundLayer, GroundLayers, HALF_LAMBERT_OFFSET, HALF_LAMBERT_SCALE, IMPOSTOR_CROSSFADE_SHARE, IMPOSTOR_RESOLUTION, IMPOSTOR_SWITCH_HEIGHTS, InputAction, InputActionBindingMap, InputActions, KEY_CODE_BACKWARD, KEY_CODE_DOWN, KEY_CODE_FORWARD, KEY_CODE_LEFT, KEY_CODE_RIGHT, KEY_CODE_UP, LEAF_SHAPE_KEPT_SHARE, LEAF_SHAPE_WIDTH, LEAST_DIVISOR, LIGHTNING_BOLT_BRIGHTNESS, LIGHTNING_BOLT_COLOR, LIGHTNING_BOLT_OPTIONS, LIGHTNING_FLASH_AMBIENT, LIGHTNING_FLASH_COLOR, LIGHTNING_FLASH_DECAY_SECONDS, LIGHTNING_FLASH_END, LIGHTNING_FLASH_PULSES, LIGHTNING_FLASH_SKY, LIGHTNING_MAX_DISTANCE, LIGHTNING_MIN_DISTANCE, LocomotionState, MAXIMUM_FACE_THRESHOLD, MAXIMUM_WINDOW_FLOOR, MAX_BYTE, MAX_STEPS_PER_FRAME, MAX_TILE_ATTEMPTS, MIDI_VELOCITY_MAX, MINIMUM_FACE_THRESHOLD, MINIMUM_OUTLINE_KNOT_SPAN, MINIMUM_RAMP_WIDTH_VERTEX, MINUTES_PER_DAY, MMD_BONE_NAME_MAP, MOUSE_BUTTONS, MOUSE_LOOK_MAX_PIXELS_PER_EVENT, MOUSE_LOOK_RADIANS_PER_PIXEL, MUSIC_EXPRESSION_WINDOW_SECONDS, MUSIC_LOOKAHEAD_SECONDS, MUSIC_NOISE_BAND_CENTRES, MUSIC_NOISE_LENGTH, MUSIC_SCHEDULE_INTERVAL_MS, MmdBoneName, MouseButton, NEUTRAL_LIGHT_MAP_GREEN, OBJECT_FADE_KEY, OBJECT_SURFACE_KEY, OUTLINE_MAIN_TEXTURE_SHARE, OUTLINE_PROJECTION_SCALE, OUTLINE_WIDTH_SCALE, ObjectSurface, POSE_AIR_STANCES, POSE_ARM_BEND_RADIANS, POSE_ARM_CHAINS, POSE_ARM_LOWER_RADIANS, POSE_BREATH_SECONDS, POSE_CHEST_BREATH_RADIANS, POSE_CROSSFADE_SECONDS, POSE_GAITS, POSE_SHOULDER_BREATH_RADIANS, PRECIPITATION_COUNT, PRECIPITATION_SETTINGS_MAP, PRECIPITATION_SWAY_SPEED, PRECIPITATION_VOLUME_HEIGHT, PRECIPITATION_VOLUME_SIZE, PmxBoneFlag, PmxJointKind, PmxMaterialFlag, PmxMorphKind, PmxPhysicsMode, PmxReader, PmxRigidBodyShape, PmxSphereMode, PmxTextEncoding, PmxWeightDeform, PrecipitationKind, QualityTier, QualityTierSettingsMap, RAMP_ROW_BASE, RAMP_ROW_STEP, REGION_FLOORS, RELEASE_TIME_CONSTANTS, RIVER_BEND_FOAM_ATTRIBUTE, RampLayout, RoofKind, SHARED_TOON_RAMP_SHADES, SOUND_EFFECT_BAND_EDGES, SOUND_EFFECT_FRAME_LENGTH, SPECTRAL_ANGULAR_BIN_COUNT, SPECTRAL_RADIAL_BIN_COUNT, SPHERE_CAST_STRIDE_SHARE, SPLASH_COUNT, SPLASH_LIFETIME, SPLASH_LIFT, SPLASH_OPACITY, SPLASH_RADIUS, SPLASH_SIZE, SPRINT_STAMINA_PER_SECOND, STAMINA_MAX, STAMINA_REFILL_DELAY_SECONDS, STAMINA_REFILL_PER_SECOND, STAMINA_REFILL_STATES, STEEP_SLIDE_SPEED, STONE_DARKENING_TOP, STONE_HARMONIC_COUNT, STONE_HEIGHT_FALLOFF, STONE_MASK_OUTPUT, STONE_RAMP_KNOT_COUNT, STONE_SHADOW_EXPONENT, SUN_REDRAW_COSINE, SURFACE_DETAIL_BAND_SIGMAS, SURFACE_OCTAVE_RESPONSES, SURFACE_OCTAVE_TEXEL_FREQUENCIES, SWIM_DASH_STAMINA_COST, SWIM_DASH_STAMINA_PER_SECOND, SWIM_STROKE_SECONDS, SWIM_STROKE_STAMINA_COST, SharedToonOutlinePassNode, StoneLightingModel, StoneNodeMaterial, TERRAIN_CELL_SIZE, TERRAIN_HEIGHT_PADDING, TERRAIN_LAYER, TERRAIN_RING_INITIAL_TILE_COUNT, TILE_INDEX_OFFSET, TILE_INDEX_SPAN, TONE_CONTRAST_OFFSET, TONE_CURVE_FLOOR, TONE_CURVE_LIFT, TOON_HIGH, TOON_LOW, TerrainFeatureKind, TerrainFeatureKindBlendMap, ToonNodeMaterial, UNIT_OUTLINE_WIDTH_KNOTS, WALK_MOVE_MAGNITUDE, WALL_PRESS_SPEED, WALL_PROBE_DISTANCE, WATER_LOCOMOTION_STATES, WEATHER_SETTINGS_MAP, WEATHER_TRANSITION_SECONDS, WET_DARKENING, WET_SHEEN_POWER, WET_SHEEN_STRENGTH, WeatherKind, addSmoothLoop, advanceGameClock, advanceStridePhase, applyLightningFlash, applyPrecipitationSettings, applySkyState, applyStoneLight, applyWeatherState, attachInspector, bakeImpostor, blendGridNodes, blendWeatherState, checkIsPmxSphereDrawn, checkSunTurned, checkTerrainBoundsOverlap, checkTerrainDrawsChanged, checkTerrainTileCasts, checkTransparentTexels, collectMusicNotes, collectMusicSegments, computeCharacterPose, computeGradeLut, computeGrassBlade, computeGrassTrailCell, computeGrassTrailTexel, computeGrassTrailTexelIndex, computeImpostorFade, computeLeafCards, computeLightningBolt, computeLightningFlash, computeLocomotionState, computeNoiseSamples, computeOriginShift, computeOutlineDistance, computeRampValues, computeScatterPoints, computeSoundEffectSamples, computeStatueSurface, computeStoneDarkening, computeStoneHarmonics, computeStoneRampCoordinate, computeSunDirection, computeSurfaceOctaves, computeTerrainIndices, computeTerrainTile, computeTreeTubes, computeWhiteBalance, computeWindGust, createBoxesGeometry, createBuildingGeometry, createCausticsNode, createCharacterController, createCharacterMaterial, createCharacterPoseRotations, createCharacterPoser, createCharacterShadingInputs, createCharacterShadingNode, createCloudAtlasTexture, createCloudBandSprite, createCloudLayerNode, createCloudLayerProfileTexture, createCloudLayerTexture, createCloudLayerTextures, createCloudLayerUniforms, createDitherFadeNode, createFaceDraw, createFaceShadeNode, createFixedStepLoop, createFlowerGeometry, createFlowerMaterial, createFlowerTileGeometry, createFogUniforms, createFollowCamera, createFreeCamera, createFrustumVisibility, createGameOutlineMaterial, createGaussianHillsHeight, createGenshinRenderer, createGodraysLight, createGradeLutTexture, createGrassBladePoint, createGrassCell, createGrassCulling, createGrassGeometry, createGrassMaterial, createGrassTrail, createGroundCapture, createGroundLayerWeights, createGroundPaintColor, createGroundQuery, createHeightFogNode, createImpostorMaterial, createIndexedGeometry, createInput, createInstanceCulling, createInstanceMatrixBuffer, createInstanceMatrixNode, createInstancedGeometry, createInstancedMesh, createInstrumentWave, createLandmarkCollider, createLatheStackGeometry, createLeafMaterial, createLeafShapeNode, createLightUniforms, createLightningBoltGeometry, createLightningBoltMaterial, createMaterialDetailNode, createMusicPlayer, createNoiseBuffer, createObjectFadeNode, createObjectSurfaceNode, createOcclusionNode, createOutlineColorNode, createOutlineMaterial, createOutlineScaleNode, createPavingGeometry, createPavingStoneGeometry, createPlantCulling, createPmxGeometry, createPmxMesh, createPmxSkeleton, createPmxTexture, createPmxToonTexture, createPostPipeline, createPostUniforms, createPrecipitationGeometry, createPrecipitationMaterial, createPrecipitationUniforms, createRampColumnNode, createRampTexture, createRampUvNode, createResidualHeight, createRimNode, createRiverGeometry, createRiverMaterial, createSeededRandom, createShadingRegionNode, createSightNode, createSightUniforms, createSimplexNoise, createSkyColorNode, createSkyGradientTexture, createSkyNode, createSkyState, createSkyUniforms, createSoundEffectBuffer, createSplashMaterial, createStamina, createStatueGeometries, createStoneGlowNode, createStoneLightUniforms, createStoneMaterial, createSunLight, createSunVisibilityNode, createSurfaceDetailNode, createSurvivorIndices, createTerrainFeaturesBlend, createTerrainFeaturesHeight, createTerrainMaterial, createTerrainRing, createTerrainSelection, createTerrainShapeHeight, createTerrainTileGeometry, createTileStreamer, createToneNode, createToonMaterial, createToonThresholdNode, createTreeGeometry, createUnderwaterFogState, createWaterFlowUniforms, createWaterMaterial, createWaterUniforms, createWaterfallGeometry, createWaterfallMaterial, createWetDarkeningNode, createWetSheenNode, createWindNode, createWindUniforms, fileByCell, findSkinnedMesh, getCliffBlend, getCloudAtlasColumns, getCloudSunColors, getDesaturatedColour, getGameOutlineOffset, getGaussianHillBlend, getMusicRecordingGain, getMusicRecordingRate, getOutlineDepth, getOutlineScale, getParentTerrainTileKey, getPlateauBlend, getRampColumn, getRampRow, getRampWidth, getRidgeBlend, getScreenDirection, getSegmentBounds, getShadingRegion, getSharedToonRamp, getSoundEffectBandBins, getSpectralBin, getTerrainFeatureBounds, getTerrainMorphStart, getTerrainOverlayBounds, getTerrainShapeLevel, getTerrainTileBounds, getTerrainTileColumn, getTerrainTileKey, getTerrainTileLevel, getTerrainTileRow, getToneColour, getToonThreshold, measureSegment, mergeGeometryParts, orderByViewDepth, parsePmx, parsePmxBones, parsePmxJoints, parsePmxMaterials, parsePmxMorphs, parsePmxRigidBodies, parsePmxVertices, placeCloudBand, renderGroundCapture, renderMusicSegment, resolveTerrainDraws, sampleGrassTrail, sampleGroundCapture, sampleGroundLayerField, sampleSkyState, sampleTerrainResidualFade, sampleTreeNormalField, scheduleMusicExpression, scheduleMusicNote, scheduleMusicRecording, selectMusicSample, selectRegionNode, selectTerrainTiles, setObjectFade, setObjectSurface, stepGrassTrail, synthesizeCloudLayerTextures, synthesizeSpectralNoise, toSceneColor, toneMapGenshin, toneMapGenshinNode, transformFourier, transformFourierGrid, updateFaceDraw, updateUnderwaterFog, writeCloudLayerTexture, writeQuadIndices, writeTerrainRingIndices, writeTerrainRingTile };
6455
+ export { A4_FREQUENCY, A4_PITCH, AIR_LOCOMOTION_STATES, AnchoredCascadeShadowNode, AntialiasingMode, BEND_FOAM_FULL_RADIUS_WIDTHS, CLIMB_JUMP_STAMINA_COST, CLIMB_LOCOMOTION_STATES, CLIMB_REGRAB_SECONDS, CLIMB_STAMINA_PER_SECOND, CLIMB_START_STAMINA, COOL_RAMP_ROW_BASE, CULLING_FRUSTUM_MARGIN, CULLING_INDEX_COUNT_INDEX, CULLING_INDIRECT_ARGUMENT_COUNT, CULLING_INSTANCE_COUNT_INDEX, CULLING_MATRIX_COLUMN_COUNT, CULLING_MATRIX_ELEMENT_COUNT, CULLING_MIN_SIZE, CharacterMaterialKind, DASH_STAMINA_COST, DEFAULT_LIGHT_AREA, DEFAULT_RAMP_WIDTH, DEFAULT_SKY_GRADIENT, DEFAULT_SKY_SHAPE, DESATURATION_WEIGHTS, EMISSION_ALPHA_FLOOR, FIELD_SELECTOR, FLAT_LIGHT_MAP, FLOWER_BEND_PER_WIND, FLOWER_COLOR_ATTRIBUTE_NAME, FLOWER_MATRIX_ATTRIBUTE_NAMES, FOCUS_KEY_CODES, FOLLOW_CAMERA_ARM_STEP, FOLLOW_CAMERA_CLEARANCE, FOLLOW_CAMERA_DEFAULT_SETTINGS, FOLLOW_CAMERA_DISTANCE_PER_ZOOM_STEP, FOLLOW_CAMERA_EASE_OUT_SPEED, FOLLOW_CAMERA_FOV, FOLLOW_CAMERA_MAX_DISTANCE, FOLLOW_CAMERA_MAX_PITCH, FOLLOW_CAMERA_MIN_DISTANCE, FOLLOW_CAMERA_MIN_PITCH, FOLLOW_CAMERA_NEUTRAL_SENSITIVITY, FOLLOW_CAMERA_PIVOT_SHARE, FOLLOW_CAMERA_SLOPE_PITCH_SPEED, FREE_CAMERA_BASE_SPEED, FREE_CAMERA_CLEARANCE, FREE_CAMERA_MAX_PITCH, FREE_CAMERA_SPEED_PER_HEIGHT, GAMEPAD_BUTTONS, GAMEPAD_LOOK_RADIANS_PER_SECOND, GAMEPAD_STICK_DEADZONE, GAME_MINUTES_PER_SECOND, GAUSSIAN_REACH_WIDTHS, GENSHIN_TONE_CONTRAST, GENSHIN_TONE_EXPOSURE, GENSHIN_TONE_MAPPING, GLIDE_STAMINA_PER_SECOND, GRASS_BEND_PER_WIND, GRASS_DIP_PER_BEND, GRASS_TRAIL_BEND_SHARE, GRASS_TRAIL_EXTENT, GRASS_TRAIL_FADE_END_SHARE, GRASS_TRAIL_FADE_SECONDS, GRASS_TRAIL_FADE_START_SHARE, GRASS_TRAIL_STAMP_RADIUS, GRASS_TRAIL_TEXELS, GRASS_TRAIL_TEXEL_SIZE, GROUND_CONTACT_DISTANCE, GROUND_LOCOMOTION_STATES, GROUND_NORMAL_SPAN, GROUND_PRESS_SPEED, GamepadButton, GroundLayer, GroundLayers, HALF_LAMBERT_OFFSET, HALF_LAMBERT_SCALE, IMPOSTOR_CROSSFADE_SHARE, IMPOSTOR_RESOLUTION, IMPOSTOR_SWITCH_HEIGHTS, InputAction, InputActionBindingMap, InputActions, KEY_CODE_BACKWARD, KEY_CODE_DOWN, KEY_CODE_FORWARD, KEY_CODE_LEFT, KEY_CODE_RIGHT, KEY_CODE_UP, LEAF_SHAPE_KEPT_SHARE, LEAF_SHAPE_WIDTH, LEAST_DIVISOR, LIGHTNING_BOLT_BRIGHTNESS, LIGHTNING_BOLT_COLOR, LIGHTNING_BOLT_OPTIONS, LIGHTNING_FLASH_AMBIENT, LIGHTNING_FLASH_COLOR, LIGHTNING_FLASH_DECAY_SECONDS, LIGHTNING_FLASH_END, LIGHTNING_FLASH_PULSES, LIGHTNING_FLASH_SKY, LIGHTNING_MAX_DISTANCE, LIGHTNING_MIN_DISTANCE, LocomotionState, MAXIMUM_FACE_THRESHOLD, MAXIMUM_WINDOW_FLOOR, MAX_BYTE, MAX_STEPS_PER_FRAME, MAX_TILE_ATTEMPTS, MIDI_VELOCITY_MAX, MINIMUM_FACE_THRESHOLD, MINIMUM_OUTLINE_KNOT_SPAN, MINIMUM_RAMP_WIDTH_VERTEX, MINUTES_PER_DAY, MMD_BONE_NAME_MAP, MOUSE_BUTTONS, MOUSE_LOOK_MAX_PIXELS_PER_EVENT, MOUSE_LOOK_RADIANS_PER_PIXEL, MUSIC_EXPRESSION_WINDOW_SECONDS, MUSIC_LOOKAHEAD_SECONDS, MUSIC_NOISE_BAND_CENTRES, MUSIC_NOISE_LENGTH, MUSIC_SCHEDULE_INTERVAL_MS, MmdBoneName, MouseButton, NEUTRAL_LIGHT_MAP_GREEN, OBJECT_FADE_KEY, OBJECT_SURFACE_KEY, OUTLINE_MAIN_TEXTURE_SHARE, OUTLINE_PROJECTION_SCALE, OUTLINE_WIDTH_SCALE, ObjectSurface, POSE_AIR_STANCES, POSE_ARM_BEND_RADIANS, POSE_ARM_CHAINS, POSE_ARM_LOWER_RADIANS, POSE_BREATH_SECONDS, POSE_CHEST_BREATH_RADIANS, POSE_CROSSFADE_SECONDS, POSE_GAITS, POSE_SHOULDER_BREATH_RADIANS, PRECIPITATION_COUNT, PRECIPITATION_SETTINGS_MAP, PRECIPITATION_SWAY_SPEED, PRECIPITATION_VOLUME_HEIGHT, PRECIPITATION_VOLUME_SIZE, PmxBoneFlag, PmxJointKind, PmxMaterialFlag, PmxMorphKind, PmxPhysicsMode, PmxReader, PmxRigidBodyShape, PmxSphereMode, PmxTextEncoding, PmxWeightDeform, PrecipitationKind, QualityTier, QualityTierSettingsMap, RAMP_ROW_BASE, RAMP_ROW_STEP, REGION_FLOORS, RELEASE_TIME_CONSTANTS, RIVER_BEND_FOAM_ATTRIBUTE, RampLayout, RoofKind, SHARED_TOON_RAMP_SHADES, SOUND_EFFECT_BAND_EDGES, SOUND_EFFECT_FRAME_LENGTH, SPECTRAL_ANGULAR_BIN_COUNT, SPECTRAL_RADIAL_BIN_COUNT, SPHERE_CAST_STRIDE_SHARE, SPLASH_COUNT, SPLASH_LIFETIME, SPLASH_LIFT, SPLASH_OPACITY, SPLASH_RADIUS, SPLASH_SIZE, SPRINT_STAMINA_PER_SECOND, STAMINA_MAX, STAMINA_REFILL_DELAY_SECONDS, STAMINA_REFILL_PER_SECOND, STAMINA_REFILL_STATES, STEEP_SLIDE_SPEED, STONE_DARKENING_TOP, STONE_HARMONIC_COUNT, STONE_HEIGHT_FALLOFF, STONE_MASK_OUTPUT, STONE_RAMP_KNOT_COUNT, STONE_SHADOW_EXPONENT, SUN_REDRAW_COSINE, SURFACE_DETAIL_BAND_SIGMAS, SURFACE_OCTAVE_RESPONSES, SURFACE_OCTAVE_TEXEL_FREQUENCIES, SWIM_DASH_STAMINA_COST, SWIM_DASH_STAMINA_PER_SECOND, SWIM_STROKE_SECONDS, SWIM_STROKE_STAMINA_COST, SharedToonOutlinePassNode, StoneLightingModel, StoneNodeMaterial, TERRAIN_CELL_SIZE, TERRAIN_HEIGHT_PADDING, TERRAIN_LAYER, TERRAIN_RING_INITIAL_TILE_COUNT, TILE_INDEX_OFFSET, TILE_INDEX_SPAN, TONE_CONTRAST_OFFSET, TONE_CURVE_FLOOR, TONE_CURVE_LIFT, TOON_HIGH, TOON_LOW, TerrainFeatureKind, TerrainFeatureKindBlendMap, ToonNodeMaterial, UNIT_OUTLINE_WIDTH_KNOTS, WALK_MOVE_MAGNITUDE, WALL_PRESS_SPEED, WALL_PROBE_DISTANCE, WATER_LOCOMOTION_STATES, WEATHER_SETTINGS_MAP, WEATHER_TRANSITION_SECONDS, WET_DARKENING, WET_SHEEN_POWER, WET_SHEEN_STRENGTH, WeatherKind, addSmoothLoop, advanceGameClock, advanceStridePhase, applyLightningFlash, applyPrecipitationSettings, applySkyState, applyStoneLight, applyWeatherState, bakeImpostor, blendGridNodes, blendWeatherState, checkIsPmxSphereDrawn, checkSunTurned, checkTerrainBoundsOverlap, checkTerrainDrawsChanged, checkTerrainTileCasts, checkTransparentTexels, collectMusicNotes, collectMusicSegments, computeCharacterPose, computeGradeLut, computeGrassBlade, computeGrassTrailCell, computeGrassTrailTexel, computeGrassTrailTexelIndex, computeImpostorFade, computeLeafCards, computeLightningBolt, computeLightningFlash, computeLocomotionState, computeNoiseSamples, computeOriginShift, computeOutlineDistance, computeRampValues, computeScatterPoints, computeSoundEffectSamples, computeStatueSurface, computeStoneDarkening, computeStoneHarmonics, computeStoneRampCoordinate, computeSunDirection, computeSurfaceOctaves, computeTerrainIndices, computeTerrainTile, computeTreeTubes, computeWhiteBalance, computeWindGust, createBoxesGeometry, createBuildingGeometry, createCausticsNode, createCharacterController, createCharacterMaterial, createCharacterPoseRotations, createCharacterPoser, createCharacterShadingInputs, createCharacterShadingNode, createCloudAtlasTexture, createCloudBandSprite, createCloudLayerNode, createCloudLayerProfileTexture, createCloudLayerTexture, createCloudLayerTextures, createCloudLayerUniforms, createDitherFadeNode, createFaceDraw, createFaceShadeNode, createFixedStepLoop, createFlowerGeometry, createFlowerMaterial, createFlowerTileGeometry, createFogUniforms, createFollowCamera, createFreeCamera, createFrustumVisibility, createGameOutlineMaterial, createGaussianHillsHeight, createGenshinRenderer, createGodraysLight, createGradeLutTexture, createGrassBladePoint, createGrassCell, createGrassCulling, createGrassGeometry, createGrassMaterial, createGrassTrail, createGroundCapture, createGroundLayerWeights, createGroundPaintColor, createGroundQuery, createHeightFogNode, createIdleInputState, createImpostorMaterial, createIndexedGeometry, createInput, createInstanceCulling, createInstanceMatrixBuffer, createInstanceMatrixNode, createInstancedGeometry, createInstancedMesh, createInstrumentWave, createLandmarkCollider, createLatheStackGeometry, createLeafMaterial, createLeafShapeNode, createLightUniforms, createLightningBoltGeometry, createLightningBoltMaterial, createMaterialDetailNode, createMusicPlayer, createNoiseBuffer, createObjectFadeNode, createObjectSurfaceNode, createOcclusionNode, createOutlineColorNode, createOutlineMaterial, createOutlineScaleNode, createPavingGeometry, createPavingStoneGeometry, createPlantCulling, createPmxGeometry, createPmxMesh, createPmxSkeleton, createPmxTexture, createPmxToonTexture, createPostPipeline, createPostUniforms, createPrecipitationGeometry, createPrecipitationMaterial, createPrecipitationUniforms, createRampColumnNode, createRampTexture, createRampUvNode, createResidualHeight, createRimNode, createRiverGeometry, createRiverMaterial, createSeededRandom, createShadingRegionNode, createSightNode, createSightUniforms, createSimplexNoise, createSkyColorNode, createSkyGradientTexture, createSkyNode, createSkyState, createSkyUniforms, createSoundEffectBuffer, createSplashMaterial, createStamina, createStatueGeometries, createStoneGlowNode, createStoneLightUniforms, createStoneMaterial, createSunLight, createSunVisibilityNode, createSurfaceDetailNode, createSurvivorIndices, createTerrainFeaturesBlend, createTerrainFeaturesHeight, createTerrainMaterial, createTerrainRing, createTerrainSelection, createTerrainShapeHeight, createTerrainTileGeometry, createTileStreamer, createToneNode, createToonMaterial, createToonThresholdNode, createTreeGeometry, createUnderwaterFogState, createWaterFlowUniforms, createWaterMaterial, createWaterUniforms, createWaterfallGeometry, createWaterfallMaterial, createWetDarkeningNode, createWetSheenNode, createWindNode, createWindUniforms, fileByCell, findSkinnedMesh, getCliffBlend, getCloudAtlasColumns, getCloudSunColors, getDesaturatedColour, getGameOutlineOffset, getGaussianHillBlend, getMusicRecordingGain, getMusicRecordingRate, getOutlineDepth, getOutlineScale, getParentTerrainTileKey, getPlateauBlend, getRampColumn, getRampRow, getRampWidth, getRidgeBlend, getScreenDirection, getSegmentBounds, getShadingRegion, getSharedToonRamp, getSoundEffectBandBins, getSpectralBin, getTerrainFeatureBounds, getTerrainMorphStart, getTerrainOverlayBounds, getTerrainShapeLevel, getTerrainTileBounds, getTerrainTileColumn, getTerrainTileKey, getTerrainTileLevel, getTerrainTileRow, getToneColour, getToonThreshold, measureSegment, mergeGeometryParts, orderByViewDepth, parsePmx, parsePmxBones, parsePmxJoints, parsePmxMaterials, parsePmxMorphs, parsePmxRigidBodies, parsePmxVertices, placeCloudBand, renderGroundCapture, renderMusicSegment, resolveTerrainDraws, sampleGrassTrail, sampleGroundCapture, sampleGroundLayerField, sampleSkyState, sampleTerrainResidualFade, sampleTreeNormalField, scheduleMusicExpression, scheduleMusicNote, scheduleMusicRecording, selectMusicSample, selectRegionNode, selectTerrainTiles, setObjectFade, setObjectSurface, stepGrassTrail, synthesizeCloudLayerTextures, synthesizeSpectralNoise, toAxis, toClamped, toDeadzoned, toSceneColor, toneMapGenshin, toneMapGenshinNode, transformFourier, transformFourierGrid, updateFaceDraw, updateUnderwaterFog, writeCloudLayerTexture, writeQuadIndices, writeTerrainRingIndices, writeTerrainRingTile };
@@ -89,46 +89,6 @@ const GAUSSIAN_REACH_WIDTHS = 3;
89
89
  const TERRAIN_HEIGHT_PADDING = 2;
90
90
  // src/terrain/getTerrainTileLevel.ts
91
91
  const getTerrainTileLevel = (key) => Math.floor(key / TILE_INDEX_SPAN / TILE_INDEX_SPAN);
92
- // src/terrain/measureSegment.ts
93
- const measurement = /* @__PURE__ */ new Float64Array(2);
94
- const measureSegment = ({ endX, endZ, startX, startZ }, x, z) => {
95
- const directionX = endX - startX;
96
- const directionZ = endZ - startZ;
97
- const length = Math.hypot(directionX, directionZ);
98
- const offsetX = x - startX;
99
- const offsetZ = z - startZ;
100
- const along = (offsetX * directionX + offsetZ * directionZ) / length;
101
- measurement[0] = (directionX * offsetZ - directionZ * offsetX) / length;
102
- measurement[1] = Math.max(0, -along, along - length);
103
- return measurement;
104
- };
105
- // src/terrain/getCliffBlend.ts
106
- const getCliffBlend = (feature, x, z) => {
107
- const measurement = measureSegment(feature, x, z);
108
- const across = measurement[0] ?? 0;
109
- const beyond = measurement[1] ?? 0;
110
- const { falloff, width } = feature;
111
- return MathUtils.smoothstep(across, -falloff, falloff) * (1 - MathUtils.smoothstep(across, width, width + falloff)) * (1 - MathUtils.smoothstep(beyond, 0, falloff));
112
- };
113
- // src/terrain/getPlateauBlend.ts
114
- const getPlateauBlend = (feature, x, z) => {
115
- const { falloff, radius, x: centreX, z: centreZ } = feature;
116
- return 1 - MathUtils.smoothstep(Math.hypot(x - centreX, z - centreZ), radius, radius + falloff);
117
- };
118
- // src/terrain/getRidgeBlend.ts
119
- const getRidgeBlend = (feature, x, z) => {
120
- const measurement = measureSegment(feature, x, z);
121
- const across = measurement[0] ?? 0;
122
- const beyond = measurement[1] ?? 0;
123
- const { width } = feature;
124
- return Math.exp(-(across ** 2 + beyond ** 2) / (2 * width * width));
125
- };
126
- // src/terrain/TerrainFeatureKindBlendMap.ts
127
- const TerrainFeatureKindBlendMap = {
128
- ["cliff"]: getCliffBlend,
129
- ["plateau"]: getPlateauBlend,
130
- ["ridge"]: getRidgeBlend
131
- };
132
92
  // src/terrain/blendGridNodes.ts
133
93
  const blendGridNodes = (values, sizeX, sizeZ, column, row) => {
134
94
  const left = Math.floor(column);
@@ -258,6 +218,19 @@ const getSegmentBounds = (startX, startZ, endX, endZ, reach) => ({
258
218
  minX: Math.min(startX, endX) - reach,
259
219
  minZ: Math.min(startZ, endZ) - reach
260
220
  });
221
+ // src/terrain/measureSegment.ts
222
+ const measurement = /* @__PURE__ */ new Float64Array(2);
223
+ const measureSegment = ({ endX, endZ, startX, startZ }, x, z) => {
224
+ const directionX = endX - startX;
225
+ const directionZ = endZ - startZ;
226
+ const length = Math.hypot(directionX, directionZ);
227
+ const offsetX = x - startX;
228
+ const offsetZ = z - startZ;
229
+ const along = (offsetX * directionX + offsetZ * directionZ) / length;
230
+ measurement[0] = (directionX * offsetZ - directionZ * offsetX) / length;
231
+ measurement[1] = Math.max(0, -along, along - length);
232
+ return measurement;
233
+ };
261
234
  // src/terrain/sampleGroundLayerField.ts
262
235
  const sampleGroundLayerField = ({ cellSize, layers, origin, size }, x, z, weights) => {
263
236
  const sizeX = size[0] ?? 1;
@@ -395,6 +368,33 @@ const TerrainFeatureKindBoundsMap = {
395
368
  }
396
369
  };
397
370
  const getTerrainFeatureBounds = (feature) => TerrainFeatureKindBoundsMap[feature.kind](feature);
371
+ // src/terrain/getCliffBlend.ts
372
+ const getCliffBlend = (feature, x, z) => {
373
+ const measurement = measureSegment(feature, x, z);
374
+ const across = measurement[0] ?? 0;
375
+ const beyond = measurement[1] ?? 0;
376
+ const { falloff, width } = feature;
377
+ return MathUtils.smoothstep(across, -falloff, falloff) * (1 - MathUtils.smoothstep(across, width, width + falloff)) * (1 - MathUtils.smoothstep(beyond, 0, falloff));
378
+ };
379
+ // src/terrain/getPlateauBlend.ts
380
+ const getPlateauBlend = (feature, x, z) => {
381
+ const { falloff, radius, x: centreX, z: centreZ } = feature;
382
+ return 1 - MathUtils.smoothstep(Math.hypot(x - centreX, z - centreZ), radius, radius + falloff);
383
+ };
384
+ // src/terrain/getRidgeBlend.ts
385
+ const getRidgeBlend = (feature, x, z) => {
386
+ const measurement = measureSegment(feature, x, z);
387
+ const across = measurement[0] ?? 0;
388
+ const beyond = measurement[1] ?? 0;
389
+ const { width } = feature;
390
+ return Math.exp(-(across ** 2 + beyond ** 2) / (2 * width * width));
391
+ };
392
+ // src/terrain/TerrainFeatureKindBlendMap.ts
393
+ const TerrainFeatureKindBlendMap = {
394
+ ["cliff"]: getCliffBlend,
395
+ ["plateau"]: getPlateauBlend,
396
+ ["ridge"]: getRidgeBlend
397
+ };
398
398
  // src/terrain/createTerrainFeaturesBlend.ts
399
399
  const createTerrainFeaturesBlend = (features) => {
400
400
  const getFeatures = fileByCell(features, getTerrainFeatureBounds);
@@ -487,4 +487,4 @@ const computeScatterPoints = ({ candidateCount, checkIsAccepted, seed, size, spa
487
487
  }
488
488
  return Float32Array.from(points);
489
489
  };
490
- export { TERRAIN_RING_INITIAL_TILE_COUNT as A, getCliffBlend as C, TERRAIN_CELL_SIZE as D, GAUSSIAN_REACH_WIDTHS as E, GroundLayer as F, GroundLayers as I, createSeededRandom as L, TILE_INDEX_SPAN as M, createSimplexNoise as N, TERRAIN_HEIGHT_PADDING as O, TerrainFeatureKind as P, getPlateauBlend as S, getTerrainTileLevel as T, getTerrainTileRow as _, createTerrainFeaturesBlend as a, TerrainFeatureKindBlendMap as b, sampleTerrainResidualFade as c, sampleGroundLayerField as d, getSegmentBounds as f, computeTerrainTile as g, fileByCell as h, createTerrainFeaturesHeight as i, TILE_INDEX_OFFSET as j, TERRAIN_LAYER as k, createGroundPaintColor as l, getGaussianHillBlend as m, createTerrainShapeHeight as n, getTerrainFeatureBounds as o, createGaussianHillsHeight as p, getTerrainShapeLevel as r, createResidualHeight as s, computeScatterPoints as t, createGroundLayerWeights as u, getTerrainTileColumn as v, measureSegment as w, getRidgeBlend as x, blendGridNodes as y };
490
+ export { TERRAIN_RING_INITIAL_TILE_COUNT as A, getTerrainTileColumn as C, TERRAIN_CELL_SIZE as D, GAUSSIAN_REACH_WIDTHS as E, GroundLayer as F, GroundLayers as I, createSeededRandom as L, TILE_INDEX_SPAN as M, createSimplexNoise as N, TERRAIN_HEIGHT_PADDING as O, TerrainFeatureKind as P, getTerrainTileRow as S, getTerrainTileLevel as T, getSegmentBounds as _, createTerrainFeaturesBlend as a, fileByCell as b, getPlateauBlend as c, createResidualHeight as d, sampleTerrainResidualFade as f, measureSegment as g, sampleGroundLayerField as h, createTerrainFeaturesHeight as i, TILE_INDEX_OFFSET as j, TERRAIN_LAYER as k, getCliffBlend as l, createGroundLayerWeights as m, createTerrainShapeHeight as n, TerrainFeatureKindBlendMap as o, createGroundPaintColor as p, getTerrainShapeLevel as r, getRidgeBlend as s, computeScatterPoints as t, getTerrainFeatureBounds as u, createGaussianHillsHeight as v, blendGridNodes as w, computeTerrainTile as x, getGaussianHillBlend as y };
@@ -1 +1 @@
1
- export { F as GroundLayer, I as GroundLayers, t as computeScatterPoints, g as computeTerrainTile, u as createGroundLayerWeights, l as createGroundPaintColor, L as createSeededRandom, n as createTerrainShapeHeight, v as getTerrainTileColumn, T as getTerrainTileLevel, _ as getTerrainTileRow } from "./terrainWorker-Bgj3rmZs.js";
1
+ export { F as GroundLayer, I as GroundLayers, t as computeScatterPoints, x as computeTerrainTile, m as createGroundLayerWeights, p as createGroundPaintColor, L as createSeededRandom, n as createTerrainShapeHeight, C as getTerrainTileColumn, T as getTerrainTileLevel, S as getTerrainTileRow } from "./terrainWorker-JpiYqzu_.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "genshin-engine",
3
- "version": "4.3.3",
3
+ "version": "4.5.0",
4
4
  "description": "An anime-style open-world engine for the browser on three.js WebGPU — toon materials, outlines, post-processing, streamed terrain, parametric world kits and a Web Audio synthesizer, as plain TypeScript and TSL modules.",
5
5
  "keywords": [
6
6
  "anime",
@@ -48,21 +48,21 @@
48
48
  "lint": "eslint .",
49
49
  "lint:fix": "eslint --fix .",
50
50
  "test": "vitest",
51
- "typecheck": "tsc"
51
+ "typecheck": "tsrs --fast"
52
52
  },
53
53
  "dependencies": {
54
- "three-mesh-bvh": "^0.9.16"
54
+ "three-mesh-bvh": "^0.9.18"
55
55
  },
56
56
  "devDependencies": {
57
- "@esposter/configuration": "4.3.3",
58
- "@esposter/shared-node": "4.3.3",
59
- "@types/node": "^26.6.5",
60
- "@types/three": "^0.186.0",
61
- "tsdown": "^0.23.1",
57
+ "@esposter/configuration": "4.5.0",
58
+ "@esposter/shared-node": "4.5.0",
59
+ "@types/node": "^26.6.6",
60
+ "@types/three": "^0.187.0",
61
+ "tsdown": "^0.23.5",
62
62
  "vite": "^8.3.5"
63
63
  },
64
64
  "peerDependencies": {
65
- "three": "^0.186.1"
65
+ "three": "^0.187.0"
66
66
  },
67
- "gitHead": "955bbc130ad9b28877fd4ae8efc73a045141ce01"
67
+ "gitHead": "e30c001f3b4b15693e75fb53092d62a97ade4d2b"
68
68
  }