@jgengine/core 0.11.0 → 0.13.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.
Files changed (256) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/ai/populationDirector.d.ts +103 -0
  3. package/dist/ai/populationDirector.js +190 -0
  4. package/dist/ai/pursuit.d.ts +56 -0
  5. package/dist/ai/pursuit.js +53 -0
  6. package/dist/authoring.d.ts +1 -1
  7. package/dist/authoring.js +1 -1
  8. package/dist/combat/effects.d.ts +11 -4
  9. package/dist/combat/effects.js +24 -17
  10. package/dist/combat/magazine.d.ts +13 -0
  11. package/dist/combat/magazine.js +27 -0
  12. package/dist/combat/vfxPresets.d.ts +176 -0
  13. package/dist/combat/vfxPresets.js +74 -0
  14. package/dist/combat/weaponFire.d.ts +114 -0
  15. package/dist/combat/weaponFire.js +96 -0
  16. package/dist/combat.d.ts +5 -2
  17. package/dist/combat.js +4 -1
  18. package/dist/devtools/controls.d.ts +38 -0
  19. package/dist/devtools/controls.js +181 -0
  20. package/dist/devtools/devtools.d.ts +5 -197
  21. package/dist/devtools/devtools.js +38 -774
  22. package/dist/devtools/discover.d.ts +32 -0
  23. package/dist/devtools/discover.js +240 -0
  24. package/dist/devtools/fallbackSeams.d.ts +50 -0
  25. package/dist/devtools/fallbackSeams.js +111 -0
  26. package/dist/devtools/frame.d.ts +15 -0
  27. package/dist/devtools/frame.js +247 -0
  28. package/dist/devtools/logs.d.ts +15 -0
  29. package/dist/devtools/logs.js +86 -0
  30. package/dist/devtools/overrides.d.ts +16 -0
  31. package/dist/devtools/overrides.js +66 -0
  32. package/dist/devtools/types.d.ts +212 -0
  33. package/dist/devtools/types.js +1 -0
  34. package/dist/devtools/urlFlags.d.ts +22 -0
  35. package/dist/devtools/urlFlags.js +62 -0
  36. package/dist/economy/auctionBook.d.ts +122 -0
  37. package/dist/economy/auctionBook.js +213 -0
  38. package/dist/economy/priceHistory.d.ts +44 -0
  39. package/dist/economy/priceHistory.js +89 -0
  40. package/dist/economy/unlockPoints.d.ts +92 -0
  41. package/dist/economy/unlockPoints.js +103 -0
  42. package/dist/editor/commandApply.d.ts +5 -0
  43. package/dist/editor/commandApply.js +755 -0
  44. package/dist/editor/commands.d.ts +48 -3
  45. package/dist/editor/commands.js +40 -754
  46. package/dist/editor/directives.d.ts +94 -0
  47. package/dist/editor/directives.js +206 -0
  48. package/dist/editor/document.d.ts +37 -2
  49. package/dist/editor/document.js +422 -6
  50. package/dist/editor/entityCatalog.d.ts +42 -0
  51. package/dist/editor/entityCatalog.js +101 -0
  52. package/dist/editor/environment.d.ts +74 -0
  53. package/dist/editor/environment.js +169 -0
  54. package/dist/editor/index.d.ts +26 -1
  55. package/dist/editor/index.js +8 -1
  56. package/dist/editor/minimap.d.ts +31 -0
  57. package/dist/editor/minimap.js +73 -0
  58. package/dist/editor/streamer.d.ts +66 -0
  59. package/dist/editor/streamer.js +68 -0
  60. package/dist/editor/types.d.ts +143 -0
  61. package/dist/editor/world.d.ts +136 -0
  62. package/dist/editor/world.js +303 -0
  63. package/dist/game/breeding.d.ts +161 -0
  64. package/dist/game/breeding.js +181 -0
  65. package/dist/game/cameraConfig.d.ts +451 -0
  66. package/dist/game/cameraConfig.js +1 -0
  67. package/dist/game/clipRoles.d.ts +51 -0
  68. package/dist/game/clipRoles.js +142 -0
  69. package/dist/game/defineGame.d.ts +16 -9
  70. package/dist/game/defineGame.js +14 -6
  71. package/dist/game/defineSystem.d.ts +2 -0
  72. package/dist/game/defineSystem.js +2 -0
  73. package/dist/game/events.d.ts +28 -0
  74. package/dist/game/partAnimation.d.ts +78 -0
  75. package/dist/game/partAnimation.js +147 -0
  76. package/dist/game/playableGame.d.ts +72 -440
  77. package/dist/game/playableGame.js +1 -1
  78. package/dist/game/progression.d.ts +35 -0
  79. package/dist/game/progression.js +22 -1
  80. package/dist/game/quest.js +1 -3
  81. package/dist/game/tribe.d.ts +184 -0
  82. package/dist/game/tribe.js +432 -0
  83. package/dist/gameplay.d.ts +3 -1
  84. package/dist/gameplay.js +3 -1
  85. package/dist/inventory/encumbrance.d.ts +69 -0
  86. package/dist/inventory/encumbrance.js +68 -0
  87. package/dist/inventory/inventoryModel.d.ts +24 -8
  88. package/dist/inventory/inventoryModel.js +47 -8
  89. package/dist/item/durability.js +1 -3
  90. package/dist/meta/changelog.d.ts +1 -1
  91. package/dist/meta/changelog.js +48 -1
  92. package/dist/movement/movementModel.d.ts +15 -1
  93. package/dist/movement/movementModel.js +33 -15
  94. package/dist/movement/playerMovement.js +102 -2
  95. package/dist/multiplayer/combatSnapshot.js +13 -8
  96. package/dist/multiplayer/presenceModel.d.ts +2 -0
  97. package/dist/multiplayer/presenceModel.js +8 -0
  98. package/dist/physics/drivableVehicle.d.ts +2 -0
  99. package/dist/physics/drivableVehicle.js +1 -1
  100. package/dist/physics/flightDynamics.d.ts +82 -0
  101. package/dist/physics/flightDynamics.js +165 -0
  102. package/dist/physics/gravityField.d.ts +25 -0
  103. package/dist/physics/gravityField.js +41 -0
  104. package/dist/physics/kinematicVehicle.d.ts +87 -0
  105. package/dist/physics/kinematicVehicle.js +193 -11
  106. package/dist/physics/physicsWorld.d.ts +26 -0
  107. package/dist/physics/physicsWorld.js +109 -117
  108. package/dist/physics/vehicleObstacles.d.ts +44 -0
  109. package/dist/physics/vehicleObstacles.js +115 -0
  110. package/dist/random/rng.d.ts +4 -1
  111. package/dist/random/rng.js +4 -1
  112. package/dist/runtime/adapter.d.ts +13 -0
  113. package/dist/runtime/adapter.js +13 -0
  114. package/dist/runtime/context/combat.d.ts +51 -0
  115. package/dist/runtime/context/combat.js +131 -0
  116. package/dist/runtime/context/combatFx.js +15 -5
  117. package/dist/runtime/context/deathLoot.d.ts +30 -0
  118. package/dist/runtime/context/deathLoot.js +39 -0
  119. package/dist/runtime/context/player.d.ts +48 -0
  120. package/dist/runtime/context/player.js +125 -0
  121. package/dist/runtime/context/scene.d.ts +60 -0
  122. package/dist/runtime/context/scene.js +329 -0
  123. package/dist/runtime/context/snapshotCodecs.d.ts +12 -0
  124. package/dist/runtime/context/snapshotCodecs.js +26 -0
  125. package/dist/runtime/descriptors/baseline.js +26 -3
  126. package/dist/runtime/descriptors/features.d.ts +5 -0
  127. package/dist/runtime/descriptors/features.js +20 -2
  128. package/dist/runtime/gameContext.d.ts +2 -428
  129. package/dist/runtime/gameContext.js +133 -500
  130. package/dist/runtime/gameContextTypes.d.ts +500 -0
  131. package/dist/runtime/gameContextTypes.js +1 -0
  132. package/dist/runtime/headlessRunner.d.ts +17 -2
  133. package/dist/runtime/headlessRunner.js +15 -0
  134. package/dist/runtime/hostPolicy.d.ts +51 -0
  135. package/dist/runtime/hostPolicy.js +68 -0
  136. package/dist/runtime/hostedGameRunner.d.ts +3 -1
  137. package/dist/runtime/hostedGameRunner.js +1 -0
  138. package/dist/runtime/hostedWorldSession.d.ts +3 -1
  139. package/dist/runtime/hostedWorldSession.js +1 -0
  140. package/dist/runtime/worldSnapshot.d.ts +13 -1
  141. package/dist/runtime/worldSnapshot.js +15 -3
  142. package/dist/scene/assetCatalog.d.ts +7 -0
  143. package/dist/scene/assetSpace.js +1 -3
  144. package/dist/scene/authoredTriggers.d.ts +50 -0
  145. package/dist/scene/authoredTriggers.js +114 -0
  146. package/dist/scene/builtinSceneKinds.js +8 -3
  147. package/dist/scene/colliders.d.ts +79 -0
  148. package/dist/scene/colliders.js +170 -0
  149. package/dist/scene/collisionMesh.d.ts +94 -0
  150. package/dist/scene/collisionMesh.js +699 -0
  151. package/dist/scene/companion.d.ts +147 -0
  152. package/dist/scene/companion.js +193 -0
  153. package/dist/scene/entityStats.d.ts +7 -9
  154. package/dist/scene/entityStats.js +19 -15
  155. package/dist/scene/sceneKinds.d.ts +16 -0
  156. package/dist/scene/sceneKinds.js +4 -0
  157. package/dist/scene/sceneRaycast.js +15 -0
  158. package/dist/stats/spawnLevelStats.d.ts +110 -0
  159. package/dist/stats/spawnLevelStats.js +140 -0
  160. package/dist/stats/statModifiers.d.ts +16 -0
  161. package/dist/stats/statModifiers.js +30 -1
  162. package/dist/stats/statPool.d.ts +70 -0
  163. package/dist/stats/statPool.js +62 -0
  164. package/dist/store/changeSignal.d.ts +3 -0
  165. package/dist/store/changeSignal.js +2 -0
  166. package/dist/store/observableKeyedStore.d.ts +2 -0
  167. package/dist/store/observableKeyedStore.js +1 -0
  168. package/dist/survival/decayMeter.js +1 -3
  169. package/dist/survival/regionHealth.js +1 -3
  170. package/dist/ui/hudLayout.d.ts +5 -0
  171. package/dist/ui/hudLayout.js +17 -1
  172. package/dist/ui/panelModel.d.ts +120 -0
  173. package/dist/ui/panelModel.js +168 -0
  174. package/dist/ui.d.ts +1 -0
  175. package/dist/ui.js +1 -0
  176. package/dist/world/authoredEntities.d.ts +29 -0
  177. package/dist/world/authoredEntities.js +29 -0
  178. package/dist/world/authoredObjects.d.ts +15 -1
  179. package/dist/world/authoredObjects.js +13 -1
  180. package/dist/world/authoredSpawn.d.ts +39 -0
  181. package/dist/world/authoredSpawn.js +37 -0
  182. package/dist/world/buildSockets.d.ts +152 -0
  183. package/dist/world/buildSockets.js +188 -0
  184. package/dist/world/buildingLots.d.ts +84 -0
  185. package/dist/world/buildingLots.js +119 -0
  186. package/dist/world/buildings.d.ts +6 -0
  187. package/dist/world/cityBlocks.d.ts +152 -0
  188. package/dist/world/cityBlocks.js +670 -0
  189. package/dist/world/cityContent.d.ts +77 -0
  190. package/dist/world/cityContent.js +261 -0
  191. package/dist/world/cityGenerator.d.ts +41 -0
  192. package/dist/world/cityGenerator.js +58 -0
  193. package/dist/world/cityGeometry.d.ts +114 -0
  194. package/dist/world/cityGeometry.js +573 -0
  195. package/dist/world/cityKind.d.ts +314 -0
  196. package/dist/world/cityKind.js +1578 -0
  197. package/dist/world/environmentSummary.js +57 -1
  198. package/dist/world/features.d.ts +53 -5
  199. package/dist/world/features.js +15 -3
  200. package/dist/world/grassKind.js +2 -2
  201. package/dist/world/markers.d.ts +50 -4
  202. package/dist/world/markers.js +49 -0
  203. package/dist/world/massing.js +1 -1
  204. package/dist/world/minimapBake.d.ts +78 -0
  205. package/dist/world/minimapBake.js +208 -0
  206. package/dist/world/minimapTrack.d.ts +17 -0
  207. package/dist/world/minimapTrack.js +22 -0
  208. package/dist/world/place.d.ts +166 -0
  209. package/dist/world/place.js +96 -0
  210. package/dist/world/placeAsset.js +3 -1
  211. package/dist/world/poleLineKind.d.ts +40 -0
  212. package/dist/world/poleLineKind.js +97 -0
  213. package/dist/world/polyline.js +9 -2
  214. package/dist/world/resourceNode.d.ts +109 -0
  215. package/dist/world/resourceNode.js +140 -0
  216. package/dist/world/roads.d.ts +19 -2
  217. package/dist/world/roads.js +60 -3
  218. package/dist/world/scatter.js +2 -20
  219. package/dist/world/streetGenerator.d.ts +159 -0
  220. package/dist/world/streetGenerator.js +684 -0
  221. package/dist/world/streets.d.ts +103 -1
  222. package/dist/world/streets.js +273 -0
  223. package/dist/world/terraform.js +58 -88
  224. package/dist/world/terrain.d.ts +65 -1
  225. package/dist/world/terrain.js +119 -2
  226. package/dist/world.d.ts +14 -5
  227. package/dist/world.js +12 -3
  228. package/package.json +1 -1
  229. package/skills/game-design/SKILL.md +28 -0
  230. package/skills/game-design/agents/openai.yaml +4 -0
  231. package/skills/game-design/references/application-playbook.md +170 -0
  232. package/skills/game-design/references/field-guide.md +288 -0
  233. package/skills/jgengine/SKILL.md +8 -4
  234. package/skills/jgengine/api.md +182 -81
  235. package/skills/jgengine/capabilities.md +104 -2
  236. package/skills/jgengine/recipes/minimal-game.md +88 -0
  237. package/skills/jgengine-combat/SKILL.md +19 -1
  238. package/skills/jgengine-combat/api.md +75 -2
  239. package/skills/jgengine-combat/capabilities.md +61 -1
  240. package/skills/jgengine-combat/recipes/portable-damage-effects.md +197 -0
  241. package/skills/jgengine-combat/recipes/portable-runtime-state.md +154 -0
  242. package/skills/jgengine-combat/recipes/portable-stat-pools.md +122 -0
  243. package/skills/jgengine-combat/recipes/portable-weapon-plumbing.md +156 -0
  244. package/skills/jgengine-combat/recipes/visible-attacks.md +81 -0
  245. package/skills/jgengine-combat/reference.md +33 -4
  246. package/skills/jgengine-gameplay/SKILL.md +8 -0
  247. package/skills/jgengine-gameplay/api.md +182 -26
  248. package/skills/jgengine-gameplay/capabilities.md +96 -2
  249. package/skills/jgengine-gameplay/recipes/portable-xp-leveling.md +168 -0
  250. package/skills/jgengine-gameplay/reference-systems.md +10 -5
  251. package/skills/jgengine-world/SKILL.md +13 -0
  252. package/skills/jgengine-world/api.md +453 -21
  253. package/skills/jgengine-world/capabilities.md +112 -2
  254. package/skills/jgengine-world/recipes/commanding-entities.md +128 -0
  255. package/skills/jgengine-world/reference.md +43 -4
  256. package/skills/jgengine/reference-cartridge.md +0 -72
@@ -1,5 +1,6 @@
1
1
  import type { AudioBusDef, SoundDef } from "../audio/audioFalloff.js";
2
2
  import type { MusicTheme } from "../audio/music.js";
3
+ import type { EditorCatalogDefinition, EditorDocument } from "../editor/types.js";
3
4
  import type { PostProcessingConfig } from "../render/postProcessing.js";
4
5
  import type { LookPreset } from "../render/lookPreset.js";
5
6
  import type { TouchControlsConfig } from "../input/touchScheme.js";
@@ -9,11 +10,16 @@ import type { HudPlatform, HudViewportConfig } from "../ui/hudScale.js";
9
10
  import type { PositionedPrompt } from "../interaction/proximityPrompt.js";
10
11
  import type { CatalogEntityRole, GameContext, GameContextContent } from "../runtime/gameContext.js";
11
12
  import type { ModelDims } from "../scene/assetCatalog.js";
13
+ import type { PartMotionParams, PartRole } from "./partAnimation.js";
14
+ import type { CollisionMeshData } from "../scene/collisionMesh.js";
12
15
  import type { SkyEnvironmentConfig } from "../world/features.js";
13
16
  import type { VisibilityConfig } from "../visibility/config.js";
14
17
  import type { GameDefinition, GameLoop } from "./defineGame.js";
18
+ import type { GameCameraConfig } from "./cameraConfig.js";
15
19
  import type { LootFilterRule } from "./lootFilter.js";
16
20
  import type { RarityStyle } from "./worldItem.js";
21
+ export type { CameraFollowState, CameraKeyframe, CameraProjection, CameraRigKind, CameraShakeConfig, ChaseCameraConfig, ChaseView, CinematicCameraConfig, FirstPersonCameraConfig, GameCameraConfig, InspectionCameraConfig, InspectionZoomAnchor, LockOnCameraConfig, ObserverCameraConfig, PlayerFovConfig, RtsCameraConfig, ShoulderCameraConfig, SideScrollCameraConfig, TopDownCameraConfig, TurntableCameraConfig, } from "./cameraConfig.js";
22
+ export { CAMERA_FRUSTUM_DEFAULTS } from "./cameraConfig.js";
17
23
  export interface PointerConfig {
18
24
  /**
19
25
  * Left-click on open ground runs this command with `{ point, entity, object }`
@@ -37,445 +43,10 @@ export interface PointerConfig {
37
43
  /** Right-click runs this command with `{ point, entity, object, aim }` when neither `orderCommand` nor `contextMenu` claims the click (#164.4). */
38
44
  secondaryCommand?: string;
39
45
  }
40
- export interface CameraFollowState {
41
- entityId: string;
42
- target: {
43
- x: number;
44
- y: number;
45
- z: number;
46
- };
47
- camera: {
48
- x: number;
49
- y: number;
50
- z: number;
51
- };
52
- distance: number;
53
- }
54
46
  /** Props handed to a `WorldOverlay` component (#542): explicit `ctx` access so canvas-layer VFX read live engine state directly, without an extra hook or a module-global workaround. */
55
47
  export interface WorldOverlayProps {
56
48
  ctx: GameContext;
57
49
  }
58
- export interface FirstPersonCameraConfig {
59
- /** Camera height above the followed entity's origin. Default 1.6. */
60
- eyeHeight?: number;
61
- /** Mouse-look radians per pixel of pointer movement. Default 0.0025. */
62
- sensitivity?: number;
63
- /** Clamp on look pitch in radians (± from horizon). Default 1.45. */
64
- maxPitch?: number;
65
- /** Show the centered crosshair overlay. Default true. */
66
- reticle?: boolean;
67
- /** Render a viewmodel in view: the built-in three-mesh gun, or `PlayableGame.viewmodel` when set (#542). `false` renders no viewmodel regardless of `PlayableGame.viewmodel`. Default true. */
68
- viewmodel?: boolean;
69
- }
70
- /**
71
- * Which camera rig the shell mounts. Every rig accepts `followEntityId: null`
72
- * (avatar-less games — city-builders, card games, auto-battlers — still get a
73
- * camera). Rigs are tuned through their config block below, never by writing
74
- * camera positions from `onTick`.
75
- * - `orbit` — third-person chase (the historical default; `perspective: "third"`).
76
- * - `first` — pointer-lock mouse-look (`perspective: "first"`).
77
- * - `topDown` — fixed height/pitch/yaw with decoupled follow (ARPG iso, top-down).
78
- * - `rts` — free-pan / edge-scroll / rotate / zoom, optional follow.
79
- * - `shoulder` — over-the-shoulder with ADS transition + shoulder swap.
80
- * - `lockOn` — yaw bound to the player→target vector; move axis becomes strafe.
81
- * - `chase` — speed-reactive vehicle chase (speed→FOV, spring arm, shake) + cockpit/hood/rear views.
82
- * - `observer` — detached spectator/photo cam bound to any entity or fixed point; never reads player input.
83
- * - `turntable` — slow auto-orbit of a fixed point: a rotating display stand for a scene. The friendly, flat spelling of `observer`'s point-orbit mode; providing `camera.turntable` selects it without an explicit `rig`.
84
- * - `sideScroll` — fixed lateral follow (2.5D platformer/beat-'em-up side view); reads no player input.
85
- * - `inspection` — model-viewer / editor rig (#207.7, #866): middle-drag pan, right-drag orbit, scroll zoom toward a configurable anchor; orbits a fixed point, reads no player/entity input.
86
- * - `none` — no camera rig is mounted; use for HUD-only presentations or a game that manages its own camera.
87
- */
88
- export type CameraRigKind = "orbit" | "first" | "topDown" | "rts" | "shoulder" | "lockOn" | "chase" | "observer" | "turntable" | "sideScroll" | "inspection" | "none";
89
- /** Canvas camera projection. "orthographic" renders a flat 2D-style view (side-scrollers, falling-block puzzles) — pair with `rig: "sideScroll"`; default "perspective". */
90
- export type CameraProjection = "perspective" | "orthographic";
91
- /** Fixed lateral 2.5D follow (side-on platformer cam): the camera sits perpendicular to the travel axis, tracks the followed entity, and never reads player look input. */
92
- export interface SideScrollCameraConfig {
93
- /** World axis the action travels along; the camera watches from the perpendicular side. Default "x". */
94
- axis?: "x" | "z";
95
- /** Camera distance from the followed entity along the perpendicular axis. Default 10. */
96
- distance?: number;
97
- /** Camera height above the followed entity. Default 3. */
98
- height?: number;
99
- /** Height of the look point above the entity. Default 1. */
100
- lookHeight?: number;
101
- /** Per-second smoothing factor for the follow (0 hard-locks). Default 8. */
102
- followSmoothing?: number;
103
- fov?: number;
104
- }
105
- /** Fixed top-down / isometric rig (#23) — height/pitch/yaw + decoupled follow. */
106
- export interface TopDownCameraConfig {
107
- /** Camera height above the follow point. Default 18. */
108
- height?: number;
109
- /** Elevation of the camera above the ground plane in radians (PI/2 = straight down, near 0 = grazing; values below 0.05 clamp to 0.05). Default ~1.02 (~58°, ARPG iso). */
110
- pitch?: number;
111
- /** Fixed azimuth in radians; ~PI/4 reads as isometric, 0 as straight top-down. Default PI/4. */
112
- yaw?: number;
113
- /** Horizontal look offset applied to the follow point. */
114
- targetOffset?: {
115
- x?: number;
116
- y?: number;
117
- z?: number;
118
- };
119
- /** Exponential follow smoothing (higher = snappier, decoupled from any orbit drag). Default 8. */
120
- followSmoothing?: number;
121
- /** Scroll zoom bounds as a height multiplier. */
122
- zoom?: {
123
- min?: number;
124
- max?: number;
125
- speed?: number;
126
- };
127
- }
128
- /** Free-pan / edge-scroll RTS rig (#24) — pan/rotate/zoom independent of any avatar. */
129
- export interface RtsCameraConfig extends TopDownCameraConfig {
130
- /** WASD / arrow pan speed in world units per second. Default 24. */
131
- panSpeed?: number;
132
- /** Edge-scroll when the pointer nears a screen edge; number sets the margin fraction. Default true. */
133
- edgeScroll?: boolean | {
134
- margin?: number;
135
- speed?: number;
136
- };
137
- /** Yaw rotate speed (radians/sec) for rotate keys / middle-drag. Default 1.4. */
138
- rotateSpeed?: number;
139
- /** World-space clamp for the pan center. */
140
- bounds?: {
141
- minX?: number;
142
- maxX?: number;
143
- minZ?: number;
144
- maxZ?: number;
145
- };
146
- /** Start centered on this world point when there is no follow target. */
147
- start?: {
148
- x?: number;
149
- z?: number;
150
- };
151
- /** Read WASD/arrow pan, edge-scroll, Q/E rotate, and wheel zoom. `false` sits static at the start/bounds position — a backdrop camera, no input at all. Default true. */
152
- pan?: boolean;
153
- }
154
- /** Over-the-shoulder combat rig (#25) — offset, ADS, shoulder swap, decoupled reticle. */
155
- export interface ShoulderCameraConfig {
156
- /** Lateral shoulder offset (world units, sign flips on swap). Default 0.6. */
157
- shoulderOffset?: number;
158
- /** Vertical offset above the follow point. Default 1.6. */
159
- heightOffset?: number;
160
- /** Boom distance behind the shoulder. Default 3.2. */
161
- distance?: number;
162
- /** Starting shoulder side. Default "right". */
163
- side?: "left" | "right";
164
- /** Aim-down-sights framing, blended in while `aim` is held. */
165
- ads?: {
166
- distance?: number;
167
- shoulderOffset?: number;
168
- fov?: number;
169
- heightOffset?: number;
170
- };
171
- /** ADS blend speed (higher = snappier). Default 10. */
172
- adsTransitionSpeed?: number;
173
- /** Screen-space reticle offset (fraction of viewport), decoupled from camera center. */
174
- reticleOffset?: {
175
- x?: number;
176
- y?: number;
177
- };
178
- /** Mouse-look sensitivity (radians per pixel). Default 0.0025. */
179
- sensitivity?: number;
180
- /** Base field of view. Default 55. */
181
- fov?: number;
182
- }
183
- /** Lock-on / strafe rig (#26) — yaw bound to player→target, move axis becomes strafe. */
184
- export interface LockOnCameraConfig {
185
- /** Target instance id; when omitted the rig reads the follower's current `getTarget`. */
186
- targetEntityId?: string;
187
- /** Boom distance behind the player, away from the target. Default 5. */
188
- distance?: number;
189
- /** Camera height above the follow point. Default 2.4. */
190
- height?: number;
191
- /** Height of the framed look point above the midpoint. Default 1.2. */
192
- lookHeight?: number;
193
- /** 0 frames the player, 1 frames the target, 0.5 the midpoint. Default 0.5. */
194
- framingBias?: number;
195
- /** Exponential yaw smoothing toward the player→target vector. Default 9. */
196
- yawSmoothing?: number;
197
- }
198
- /** Fixed interior view for the chase rig (#27). */
199
- export type ChaseView = "chase" | "cockpit" | "hood" | "rear";
200
- /** Speed-reactive vehicle chase rig (#27) — speed→FOV, spring arm, procedural shake, interior views. */
201
- export interface ChaseCameraConfig {
202
- /** Boom distance behind the vehicle. Default 6. */
203
- distance?: number;
204
- /** Camera height above the follow point. Default 2.6. */
205
- height?: number;
206
- /** Height of the look point above the follow point. Default 1.2. */
207
- lookHeight?: number;
208
- /** Spring-arm damping (higher = stiffer, less lag). Default 6. */
209
- springDamping?: number;
210
- /** Speed→FOV curve: FOV lerps from `base` to `max` as speed climbs to `speedForMax`. */
211
- fov?: {
212
- base?: number;
213
- max?: number;
214
- speedForMax?: number;
215
- };
216
- /** Procedural shake amplitude per unit of speed (adds to the trauma channel). Default 0.0. */
217
- shakePerSpeed?: number;
218
- /** Velocity-lead / predictive follow (#286.9): the rig aims `time` seconds ahead of the target along its velocity, clamped to `max` world units (default 4). */
219
- lead?: {
220
- time: number;
221
- max?: number;
222
- };
223
- /** Roll into turns (#286.10): radians of camera roll per rad/s of the target's yaw rate, clamped to `max` (default 0.35), exponentially smoothed by `damping` (default 8). */
224
- bank?: {
225
- perYawRate: number;
226
- max?: number;
227
- damping?: number;
228
- };
229
- /** Which view to mount. Default "chase". */
230
- view?: ChaseView;
231
- /** Local offset for cockpit/hood/rear seats (relative to the vehicle, +z forward). */
232
- seatOffsets?: {
233
- cockpit?: {
234
- x?: number;
235
- y?: number;
236
- z?: number;
237
- };
238
- hood?: {
239
- x?: number;
240
- y?: number;
241
- z?: number;
242
- };
243
- rear?: {
244
- x?: number;
245
- y?: number;
246
- z?: number;
247
- };
248
- };
249
- }
250
- /** Detached spectator/photo cam (#120) — binds to any entity or fixed point, never reads player input. */
251
- export interface ObserverCameraConfig {
252
- /** What the observer looks at. Omit to stay on a fixed point at the origin (or `point`, if given). */
253
- bind?: {
254
- kind: "entity";
255
- entityId: string;
256
- } | {
257
- kind: "point";
258
- position: {
259
- x: number;
260
- y: number;
261
- z: number;
262
- };
263
- };
264
- /** Orbit distance from the bound subject. Default 8. */
265
- distance?: number;
266
- /** Camera height above the bound subject. Default 3. */
267
- height?: number;
268
- /** Height of the look point above the subject. Default 1.2. */
269
- lookHeight?: number;
270
- /** Radians/second of automatic orbit around the subject (CCTV-style sweep); 0 holds a fixed angle. Default 0.2. */
271
- orbitSpeed?: number;
272
- /** Starting orbit angle in radians. Default 0. */
273
- startAngle?: number;
274
- fov?: number;
275
- }
276
- /**
277
- * Turntable / showcase rig — slowly auto-orbits a fixed world point (no player
278
- * input), the way a museum turntable rotates an object on display. A flat,
279
- * self-describing spelling of `observer`'s point-orbit mode: `target` names the
280
- * point directly instead of `bind: { kind: "point", position }`. Set
281
- * `camera.turntable` and the rig is inferred — you don't also write `rig`.
282
- */
283
- export interface TurntableCameraConfig {
284
- /** World point the camera circles. Default the world origin. */
285
- target?: {
286
- x: number;
287
- y: number;
288
- z: number;
289
- };
290
- /** Orbit radius from the target. Default 8. */
291
- distance?: number;
292
- /** Camera height above the target. Default 3. */
293
- height?: number;
294
- /** Height of the look point above the target. Default 1.2. */
295
- lookHeight?: number;
296
- /** Radians/second of rotation; 0 holds a fixed angle. Default 0.2. */
297
- orbitSpeed?: number;
298
- /** Starting angle in radians. Default 0. */
299
- startAngle?: number;
300
- fov?: number;
301
- }
302
- /**
303
- * How scroll-zoom re-anchors the view for the inspection rig (#207.7):
304
- * - `target` — dolly toward the orbit target (classic OrbitControls behavior).
305
- * - `cursor` — dolly toward the point under the pointer.
306
- * - `center` — dolly toward the viewport center; equivalent to `target` for an
307
- * OrbitControls-driven rig, since the camera always faces `target` and that
308
- * point already projects to the exact center of the viewport.
309
- */
310
- export type InspectionZoomAnchor = "target" | "cursor" | "center";
311
- /** Model-viewer / inspection rig (#207.7) — orbit + pan + anchored zoom around a fixed point, never reads player input. */
312
- export interface InspectionCameraConfig {
313
- /** Where scroll-zoom re-anchors the view. Default "target". */
314
- anchor?: InspectionZoomAnchor;
315
- /** Orbit target (the point orbited/panned around). Default origin. */
316
- target?: {
317
- x?: number;
318
- y?: number;
319
- z?: number;
320
- };
321
- /** Camera distance from `target` used to seed the initial camera position when `initialPosition` is unset. Default 6. */
322
- initialDistance?: number;
323
- /** Explicit starting camera world position; overrides `initialDistance` when set. */
324
- initialPosition?: {
325
- x?: number;
326
- y?: number;
327
- z?: number;
328
- };
329
- minDistance?: number;
330
- maxDistance?: number;
331
- /** Vertical orbit clamp (radians). Unset allows a full pole-to-pole orbit, unlike the tighter default on the classic orbit rig. */
332
- minPolarAngle?: number;
333
- maxPolarAngle?: number;
334
- /** Middle-mouse pan. Default true for this rig. */
335
- pan?: boolean;
336
- rotateSpeed?: number;
337
- zoomSpeed?: number;
338
- dampingFactor?: number;
339
- }
340
- /** One stop on a scripted camera path (#29). */
341
- export interface CameraKeyframe {
342
- position: {
343
- x: number;
344
- y: number;
345
- z: number;
346
- };
347
- lookAt: {
348
- x: number;
349
- y: number;
350
- z: number;
351
- };
352
- fov?: number;
353
- /** Seconds to travel from the previous keyframe to this one. Default 1. */
354
- duration?: number;
355
- /** Interpolation into this keyframe. Default "smooth" (smoothstep ease). */
356
- ease?: "linear" | "smooth";
357
- }
358
- /** Scripted keyframe / path player (#29). When set it overrides the active rig. */
359
- export interface CinematicCameraConfig {
360
- keyframes: readonly CameraKeyframe[];
361
- /** Restart from the first keyframe after the last. Default false. */
362
- loop?: boolean;
363
- }
364
- /** Camera-shake / trauma defaults (#28). Any rig reads the trauma channel; game systems feed it via `cameraShake()`. */
365
- export interface CameraShakeConfig {
366
- /** Positional shake amplitude at full trauma (world units). Default 0.5. */
367
- maxOffset?: number;
368
- /** Rotational shake amplitude at full trauma (radians). Default 0.06. */
369
- maxRoll?: number;
370
- /** Trauma decay per second (fraction). Default 1.6. */
371
- decayPerSecond?: number;
372
- /** Trauma→shake exponent; 2 = quadratic falloff so small hits are subtle. Default 2. */
373
- exponent?: number;
374
- /** Noise frequency (Hz) of the shake oscillation. Default 24. */
375
- frequency?: number;
376
- }
377
- export declare const CAMERA_FRUSTUM_DEFAULTS: {
378
- readonly fov: 55;
379
- readonly near: 0.1;
380
- readonly far: 300;
381
- readonly zoom: 50;
382
- };
383
- /** Player-facing FOV preference applied across every perspective camera rig. Orthographic projections ignore it. */
384
- export interface PlayerFovConfig {
385
- /** Inclusive lower bound for the slider and persisted values. Default 40. */
386
- min?: number;
387
- /** Inclusive upper bound for the slider and persisted values. Default 120. */
388
- max?: number;
389
- /** Initial FOV when nothing is persisted. Defaults to `frustum.fov` or 55. */
390
- default?: number;
391
- /** Persist the preference in localStorage across reloads. Default true. */
392
- persist?: boolean;
393
- /** Show the shell FOV slider. Default true for perspective cameras; forced off for orthographic. */
394
- control?: boolean;
395
- }
396
- export interface GameCameraConfig {
397
- /** Selects the rig. Overrides `perspective`; leave unset to fall back to `perspective`. */
398
- rig?: CameraRigKind;
399
- /** Canvas camera projection. "orthographic" renders a flat 2D-style view (side-scrollers, falling-block puzzles) — pair with `rig: "sideScroll"`; default perspective. */
400
- projection?: CameraProjection;
401
- /** Render frustum overrides applied to the canvas camera. `far` defaults to 300 — raise it for worlds whose content spans more than a few hundred units, or distant scenery silently clips. `zoom` is the orthographic zoom in canvas pixels per world unit, read only when `projection` is "orthographic"; default 50. */
402
- frustum?: {
403
- fov?: number;
404
- near?: number;
405
- far?: number;
406
- zoom?: number;
407
- };
408
- /** Universal player FOV preference (slider + persistence) for perspective rigs. Ignored when `projection` is `"orthographic"`. */
409
- playerFov?: PlayerFovConfig;
410
- /** "third" mounts the orbit camera (default); "first" mounts pointer-lock mouse-look. Shorthand for `rig: "orbit" | "first"`. */
411
- perspective?: "third" | "first";
412
- /** First-person tuning; only read when the rig resolves to "first". */
413
- firstPerson?: FirstPersonCameraConfig;
414
- /** Top-down / isometric tuning (#23); read when `rig: "topDown"`. */
415
- topDown?: TopDownCameraConfig;
416
- /** Free-pan / edge-scroll RTS tuning (#24); read when `rig: "rts"`. */
417
- rts?: RtsCameraConfig;
418
- /** Over-the-shoulder tuning (#25); read when `rig: "shoulder"`. */
419
- shoulder?: ShoulderCameraConfig;
420
- /** Lock-on / strafe tuning (#26); read when `rig: "lockOn"`. */
421
- lockOn?: LockOnCameraConfig;
422
- /** Vehicle chase tuning (#27); read when `rig: "chase"`. */
423
- chase?: ChaseCameraConfig;
424
- /** Detached spectator/photo cam tuning (#120); read when `rig: "observer"`. */
425
- observer?: ObserverCameraConfig;
426
- /** Turntable / showcase tuning; setting this selects the `turntable` rig on its own. */
427
- turntable?: TurntableCameraConfig;
428
- /** Fixed side-on follow tuning; read when `rig: "sideScroll"`. */
429
- sideScroll?: SideScrollCameraConfig;
430
- /** Model-viewer / inspection tuning (#207.7); read when `rig: "inspection"`. */
431
- inspection?: InspectionCameraConfig;
432
- /** Camera-shake / trauma channel defaults (#28); read by every rig. */
433
- shake?: CameraShakeConfig;
434
- /** Scripted keyframe path (#29); when set, plays over the active rig. */
435
- cinematic?: CinematicCameraConfig;
436
- /** Seconds to cross-fade the camera when the rig changes (#29). 0 hard-cuts. Default 0.6. */
437
- transitionSeconds?: number;
438
- minDistance?: number;
439
- maxDistance?: number;
440
- targetHeight?: number;
441
- /** Extra offset on top of entity position for the orbit target. */
442
- targetOffset?: {
443
- x?: number;
444
- y?: number;
445
- z?: number;
446
- };
447
- initialDistance?: number;
448
- initialHeight?: number;
449
- /** Initial horizontal boom facing (radians): 0 = camera behind on -Z, PI = camera on +Z. Seeds the orbit rig; unset keeps the legacy -Z placement. */
450
- initialYaw?: number;
451
- /** Initial boom elevation (radians): 0 = level, positive = camera above the target looking down. Seeds the orbit rig; unset derives elevation from `initialHeight`/`initialDistance`. */
452
- initialPitch?: number;
453
- /** Lock orbit radius while the follow target moves (default true in shell). */
454
- followLock?: boolean;
455
- /** When false, orbit target stays fixed (cinematic / debug). Default true. */
456
- followEnabled?: boolean;
457
- /** Instance id to follow, or null for an avatar-less free camera; defaults to local player in the dev shell. */
458
- followEntityId?: string | null;
459
- /** Fired each frame after cameraFollow lock is applied. */
460
- onCameraFollow?: (state: CameraFollowState) => void;
461
- rotateSpeed?: number;
462
- zoomSpeed?: number;
463
- dampingFactor?: number;
464
- targetSmoothing?: number;
465
- dragTargetSmoothing?: number;
466
- distanceSmoothing?: number;
467
- /** Vertical look clamp (three.js polar angle, radians): 0 = top-down over the head, PI/2 = level, >PI/2 = look up from below. Widen for top-down or vertical aim; unset keeps the standard chase feel. */
468
- minPolarAngle?: number;
469
- maxPolarAngle?: number;
470
- /** Signed boom-elevation clamp `[min, max]` (radians): min < 0 dips the camera below the target, max > 0 rises overhead. Maps onto `minPolarAngle`/`maxPolarAngle` (polar = PI/2 − pitch); explicit polar fields win. */
471
- pitchClamp?: readonly [number, number];
472
- /** Spring-arm occlusion for the orbit rig: pull the camera in past walls/terrain so it never clips inside geometry. Off unless `enabled`. */
473
- collision?: {
474
- enabled?: boolean;
475
- padding?: number;
476
- minTargetDistance?: number;
477
- };
478
- }
479
50
  export interface EntitySpriteConfig {
480
51
  url: string;
481
52
  width: number;
@@ -593,6 +164,14 @@ export interface ModelPart {
593
164
  rotation?: [number, number, number];
594
165
  /** Uniform scale of the part under the parent's transform. Default 1. */
595
166
  scale?: number;
167
+ /**
168
+ * Semantic motion role for a rig-less part-composed character (see `game/partAnimation`).
169
+ * Tagging any part enables the shell's procedural driver on an entity model: legs and arms swing
170
+ * counter-phase with movement speed, the head counter-sways, tails wag, wings flap, and the whole
171
+ * composition gains walk bob, idle breathe, hit flinch, and a death topple. Untagged parts stay
172
+ * static kit pieces.
173
+ */
174
+ role?: PartRole;
596
175
  }
597
176
  export interface ModelConfig {
598
177
  url: string;
@@ -604,14 +183,25 @@ export interface ModelConfig {
604
183
  anchor?: "center" | "origin";
605
184
  /** Measured footprint/center/minY; supplied automatically when the model resolves through an `@jgengine/assets` catalog. Required for `anchor: "center"` to take effect. */
606
185
  dims?: ModelDims;
186
+ /** Opt-in compact collision mesh from the asset index; when present, collider auto-fit raycasts the actual triangles, so shots pass through holes in concave models (torus, archway) instead of hitting the fitted box. Supplied automatically for opted-in catalog assets. */
187
+ collisionMesh?: CollisionMeshData;
607
188
  /** Per-entity PBR tint/finish override (#151.3); cloned onto each `MeshStandardMaterial` in the model so shared GLTF caches stay untouched. */
608
189
  material?: ModelMaterialOverride;
609
- /** Plays a GLTF animation clip on the model when the source has any (skinned or not); omit to render the rig's bind pose. */
610
- animation?: ModelAnimationConfig;
190
+ /**
191
+ * Plays a GLTF animation clip on the model when the source has any (skinned or not).
192
+ * A model resolved from a catalog id whose index carries `clips` animates automatically —
193
+ * semantic clip roles build the idle/walk/run states and hit/death/attack one-shots (see
194
+ * `defaultAnimationForClips`). `"auto"` forces that derivation, `"none"` opts out (bind pose),
195
+ * and an explicit config always wins. Omit on an inline (non-catalog) config to render the
196
+ * rig's bind pose.
197
+ */
198
+ animation?: ModelAnimationConfig | "auto" | "none";
611
199
  /** Props/weapons parented to named bones on this model's rig; each follows its bone through animation. */
612
200
  attachments?: readonly ModelAttachment[];
613
- /** Static kit-of-parts pieces stacked at fixed local offsets — no bone/rig involved. Use this for a compound entity assembled from several modular meshes (a castle keep from base + mid + roof pieces); use `attachments` for props parented to an animated rig's bones. */
201
+ /** Static kit-of-parts pieces stacked at fixed local offsets — no bone/rig involved. Use this for a compound entity assembled from several modular meshes (a castle keep from base + mid + roof pieces); use `attachments` for props parented to an animated rig's bones. Tag parts with a `role` to procedurally animate a rig-less character composition. */
614
202
  parts?: readonly ModelPart[];
203
+ /** Tuning for the procedural part-motion driver when any part carries a `role`; omit for defaults. */
204
+ partMotion?: PartMotionParams;
615
205
  }
616
206
  export interface ObjectStyle {
617
207
  color?: string;
@@ -696,9 +286,37 @@ export interface MovementCommitFrame {
696
286
  /** The live game context (#282.2) — movement rules read stores/stats directly instead of module-level bridge objects. */
697
287
  ctx: GameContext;
698
288
  }
289
+ /**
290
+ * Per-channel combat presentation toggles for the 3D shell canvas.
291
+ * Missing keys default to enabled when the parent `presentationEffects` is an object.
292
+ */
293
+ export interface PresentationEffectsConfig {
294
+ /** Ground telegraphs for AoE / cast indicators. Default true. */
295
+ telegraphs?: boolean;
296
+ /** One-shot spell VFX + retained (persistent) VFX instances. Default true. */
297
+ vfx?: boolean;
298
+ /** Floating combat text (damage numbers, etc.). Default true. */
299
+ floatText?: boolean;
300
+ /** Projectile tracer lines. Default true. */
301
+ tracers?: boolean;
302
+ /** Trauma-driven combat camera shake. Default true. */
303
+ shake?: boolean;
304
+ }
699
305
  /** How a screenshot host reaches live gameplay in this game — the data behind `shoot --mode play`. */
700
306
  export interface GameCaptureConfig {
701
- /** Commands run (in order, via `ctx.game.commands.run`) right after boot when a capture host requests the play screen — the same commands the start-menu buttons dispatch. A bare string runs with a default input; the object form carries the input a command needs (e.g. `[{ name: "class.select", input: { classId: "siren" } }, "startRun"]`). A name the game never registers fails the capture loudly instead of shipping a menu screenshot. */
307
+ /**
308
+ * Commands run (in order, via `ctx.game.commands.run`) right after boot when a capture host requests the
309
+ * play screen — the same commands the start-menu buttons dispatch. A bare string runs with a default input;
310
+ * the object form carries the input a command needs (e.g. `[{ name: "class.select", input: { classId: "siren" } }, "startRun"]`).
311
+ * A name the game never registers fails the capture loudly instead of shipping a menu screenshot.
312
+ *
313
+ * Timing contract: these dispatch **once**, synchronously, at `onContextReady` — after `onNewPlayer` but
314
+ * before any async boot work it kicked off has settled. If the game restores state asynchronously (a
315
+ * whole-world save load, network hydration) and that restore resets the same "started" gate these commands
316
+ * flip, the restore lands *after* the play commands and re-shows the menu — the capture then fails with a
317
+ * start menu still on screen even though `play` is declared. Make such a restore preserve an already-live
318
+ * session (skip the reset when the start gate is already set) so it does not bounce capture back to the title.
319
+ */
702
320
  play?: readonly (string | {
703
321
  name: string;
704
322
  input?: unknown;
@@ -724,6 +342,10 @@ export interface PlayableGame<TUi = unknown, TWorldOverlay = unknown, TRenderEnt
724
342
  WorldOverlay?: TOverlay;
725
343
  /** Replaces the default demo backdrop (ground + grid + rocks) with the game's own scene — ground, sky, structures. Camera, input, HUD, entity rendering, and the loop stay shell-provided; supply your world without forking the shell. When unset and `game.world` is an `environment()` descriptor, the shell auto-renders that world here — no manual wiring needed. */
726
344
  environment?: TWorldOverlay;
345
+ /** The game's authored scene document (`editor.scene.json`, normalized). When set, `defineGame` always mounts `AuthoredScene` over it (draped paths, scatter, studios, placed catalog props) — any `WorldOverlay` renders alongside it as VFX only — and the embedded editor opens it as its default layers: the zero-wiring path from document to play and edit modes. */
346
+ editorLayers?: EditorDocument;
347
+ /** Game-exported gameplay catalog definitions (schemas + defaults). `GameHost` forwards them to the summoned editor's Data panel; no per-game editor bootstrap needed. */
348
+ editorCatalogs?: readonly EditorCatalogDefinition[];
727
349
  /** Custom first-person viewmodel (#542), read when the active rig is first-person. Rendered inside the shell's camera-locked, muzzle-tracked anchor in place of the built-in three-mesh gun; receives a live `cuesRef` (velocity/bob/firing/reloading/recoil) driven from the followed entity — see `@jgengine/shell/camera`'s `ViewmodelProps`. Set `camera.firstPerson.viewmodel: false` to render no viewmodel at all regardless of this field. */
728
350
  viewmodel?: TViewmodel;
729
351
  /** Per-entity visual override: return your own mesh for an entity and the shell still positions it and drives selection/targeting. Return null/undefined to fall back to model → sprite → primitive. */
@@ -770,13 +392,23 @@ export interface PlayableGame<TUi = unknown, TWorldOverlay = unknown, TRenderEnt
770
392
  * declares one of the given roles (default: all); `maxDistance` hides nameplates beyond this many
771
393
  * world units from the player (default 40). Headless: skin every part via `className`/`data-*` hooks
772
394
  * on `WorldNameplates` (`@jgengine/shell/world/WorldHud`) — this flag only turns the readout on and
773
- * scopes which entities it covers.
395
+ * scopes which entities it covers. Set `showHealth: false` for a name-only plate when a game already
396
+ * draws the HP bar itself (its own HUD, or `worldHealthBars`) — otherwise the nameplate's built-in bar
397
+ * stacks a second health bar over every entity.
774
398
  */
775
399
  nameplates?: boolean | {
776
400
  statId?: string;
777
401
  roles?: readonly CatalogEntityRole[];
778
402
  maxDistance?: number;
403
+ showHealth?: boolean;
779
404
  };
405
+ /**
406
+ * Combat presentation stack mounted inside the 3D canvas (telegraphs, spell VFX, retained VFX,
407
+ * float text, projectile tracers, camera shake). Default `true` preserves historical always-on
408
+ * behavior. `false` mounts none. An object mounts only the listed pieces (missing keys default
409
+ * on so games can disable a single expensive channel, e.g. `{ tracers: false }`).
410
+ */
411
+ presentationEffects?: boolean | PresentationEffectsConfig;
780
412
  /** Sound catalog + mix buses (music/sfx/ambient/…) the shell's Web Audio glue plays from. Catalog-first — no per-game audio wiring. `sounds` may be sample (`url`) or procedural (`synth`); `music` holds procedural themes crossfaded via `ctx.game.audio.music(id)`. */
781
413
  audio?: {
782
414
  sounds: Record<string, SoundDef>;
@@ -1,4 +1,4 @@
1
- export const CAMERA_FRUSTUM_DEFAULTS = { fov: 55, near: 0.1, far: 300, zoom: 50 };
1
+ export { CAMERA_FRUSTUM_DEFAULTS } from "./cameraConfig.js";
2
2
  export function worldHealthBarAllowsRole(roles, role) {
3
3
  if (roles === undefined)
4
4
  return true;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * The shape of a progression curve before rounding/clamping: a constant, a
3
+ * linear ramp, a `power` or `geometric` growth, discrete `steps`, or a
4
+ * `piecewise` interpolation between explicit points. Feed it to {@link evalCurve}.
5
+ */
1
6
  export type CurveDef = {
2
7
  kind: "const";
3
8
  value: number;
@@ -20,20 +25,38 @@ export type CurveDef = {
20
25
  kind: "piecewise";
21
26
  points: [number, number][];
22
27
  };
28
+ /** Post-evaluation adjustments applied to a curve's raw output: rounding mode and min/max clamp. */
23
29
  export interface CurveShape {
24
30
  round?: "floor" | "ceil" | "round";
25
31
  min?: number;
26
32
  max?: number;
27
33
  }
34
+ /** A fully specified progression curve — a {@link CurveDef} growth shape plus optional {@link CurveShape} rounding/clamp. */
28
35
  export type Curve = CurveDef & CurveShape;
36
+ /**
37
+ * Evaluate a progression {@link Curve} at position `x`, applying its rounding
38
+ * mode and min/max clamp. This is the shared numeric backbone for XP-per-level,
39
+ * cost ramps, difficulty scaling, and any other level/rank → value mapping — use
40
+ * it instead of hand-rolling growth formulas.
41
+ *
42
+ * @capability progression-curve evaluate a level/rank curve (const, linear, power, geometric, steps, piecewise) at a point
43
+ */
29
44
  export declare function evalCurve(spec: Curve, x: number): number;
45
+ /** Bind a {@link Curve} into a reusable `(x) => value` evaluator — a partial application of {@link evalCurve}. */
30
46
  export declare function curve(spec: Curve): (x: number) => number;
47
+ /** Result of resolving a level+xp pair: the settled `level`, leftover `xp` into the current level, the `xpMax` threshold for the next level, and how many `levelsGained` this resolution produced. */
31
48
  export interface LevelProgress {
32
49
  level: number;
33
50
  xp: number;
34
51
  xpMax: number;
35
52
  levelsGained: number;
36
53
  }
54
+ /**
55
+ * Configuration for a {@link leveling} track: the `xpForLevel` {@link Curve}, the
56
+ * `maxLevel` cap, and optional `startLevel`, stat ids (`xpStat`/`levelStat`,
57
+ * default `"xp"`/`"level"`), and `thresholdMode` — `"perLevel"` (each level costs
58
+ * its own curve value) or `"cumulative"` (curve gives the total xp to reach a level).
59
+ */
37
60
  export interface LevelingConfig {
38
61
  xpForLevel: Curve;
39
62
  maxLevel: number;
@@ -42,6 +65,7 @@ export interface LevelingConfig {
42
65
  levelStat?: string;
43
66
  thresholdMode?: "perLevel" | "cumulative";
44
67
  }
68
+ /** Adapter a {@link LevelingTrack} uses to read and write a user's level/xp stats, so the track stays decoupled from any concrete stats store. */
45
69
  export interface LevelingStatAccess {
46
70
  get(userId: string, statId: string): {
47
71
  current: number;
@@ -52,6 +76,7 @@ export interface LevelingStatAccess {
52
76
  max?: number;
53
77
  }): unknown;
54
78
  }
79
+ /** A resolved leveling track: the immutable `maxLevel`/`startLevel`, the `xpForLevel` threshold lookup, a pure `resolve`, and `grantXp` which writes back through a {@link LevelingStatAccess} and fires `onLevelUp` once for every reached level in ascending order. */
55
80
  export interface LevelingTrack {
56
81
  readonly maxLevel: number;
57
82
  readonly startLevel: number;
@@ -59,4 +84,14 @@ export interface LevelingTrack {
59
84
  resolve(level: number, xp: number): LevelProgress;
60
85
  grantXp(access: LevelingStatAccess, userId: string, amount: number, onLevelUp?: (level: number) => void): number;
61
86
  }
87
+ /**
88
+ * Build a leveling track from an xp-per-level {@link Curve} and a max level. The
89
+ * returned {@link LevelingTrack} resolves how many levels a given xp total earns
90
+ * (rolling over surplus xp, capping at `maxLevel`) and, via `grantXp`, writes the
91
+ * new level/xp back through a {@link LevelingStatAccess} and fires `onLevelUp` for
92
+ * each level gained in ascending order. Reach for this instead of hand-tracking xp thresholds; pair
93
+ * it with `resource-pool` (mana/stamina) and `ability-bar` (cooldowns) for a hero.
94
+ *
95
+ * @capability leveling-track grant XP, resolve level-ups against a curve, and write level+xp stats back through a stat adapter
96
+ */
62
97
  export declare function leveling(config: LevelingConfig): LevelingTrack;