@jgengine/core 0.11.0 → 0.12.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/CHANGELOG.md +26 -0
- package/dist/ai/populationDirector.d.ts +103 -0
- package/dist/ai/populationDirector.js +190 -0
- package/dist/ai/pursuit.d.ts +56 -0
- package/dist/ai/pursuit.js +53 -0
- package/dist/authoring.d.ts +1 -1
- package/dist/authoring.js +1 -1
- package/dist/combat.d.ts +1 -0
- package/dist/combat.js +1 -0
- package/dist/devtools/controls.d.ts +38 -0
- package/dist/devtools/controls.js +181 -0
- package/dist/devtools/devtools.d.ts +5 -197
- package/dist/devtools/devtools.js +38 -774
- package/dist/devtools/discover.d.ts +32 -0
- package/dist/devtools/discover.js +240 -0
- package/dist/devtools/fallbackSeams.d.ts +50 -0
- package/dist/devtools/fallbackSeams.js +111 -0
- package/dist/devtools/frame.d.ts +15 -0
- package/dist/devtools/frame.js +247 -0
- package/dist/devtools/logs.d.ts +15 -0
- package/dist/devtools/logs.js +86 -0
- package/dist/devtools/overrides.d.ts +16 -0
- package/dist/devtools/overrides.js +66 -0
- package/dist/devtools/types.d.ts +212 -0
- package/dist/devtools/types.js +1 -0
- package/dist/economy/auctionBook.d.ts +122 -0
- package/dist/economy/auctionBook.js +213 -0
- package/dist/economy/priceHistory.d.ts +44 -0
- package/dist/economy/priceHistory.js +89 -0
- package/dist/economy/unlockPoints.d.ts +92 -0
- package/dist/economy/unlockPoints.js +103 -0
- package/dist/editor/commandApply.d.ts +5 -0
- package/dist/editor/commandApply.js +755 -0
- package/dist/editor/commands.d.ts +48 -3
- package/dist/editor/commands.js +40 -754
- package/dist/editor/directives.d.ts +94 -0
- package/dist/editor/directives.js +206 -0
- package/dist/editor/document.d.ts +37 -2
- package/dist/editor/document.js +422 -6
- package/dist/editor/entityCatalog.d.ts +42 -0
- package/dist/editor/entityCatalog.js +101 -0
- package/dist/editor/environment.d.ts +74 -0
- package/dist/editor/environment.js +169 -0
- package/dist/editor/index.d.ts +26 -1
- package/dist/editor/index.js +8 -1
- package/dist/editor/minimap.d.ts +31 -0
- package/dist/editor/minimap.js +73 -0
- package/dist/editor/streamer.d.ts +66 -0
- package/dist/editor/streamer.js +68 -0
- package/dist/editor/types.d.ts +143 -0
- package/dist/editor/world.d.ts +136 -0
- package/dist/editor/world.js +303 -0
- package/dist/game/breeding.d.ts +161 -0
- package/dist/game/breeding.js +181 -0
- package/dist/game/cameraConfig.d.ts +451 -0
- package/dist/game/cameraConfig.js +1 -0
- package/dist/game/defineGame.d.ts +16 -9
- package/dist/game/defineGame.js +14 -6
- package/dist/game/defineSystem.d.ts +2 -0
- package/dist/game/defineSystem.js +2 -0
- package/dist/game/events.d.ts +28 -0
- package/dist/game/playableGame.d.ts +34 -435
- package/dist/game/playableGame.js +1 -1
- package/dist/game/progression.d.ts +35 -0
- package/dist/game/progression.js +19 -0
- package/dist/game/quest.js +1 -3
- package/dist/game/tribe.d.ts +184 -0
- package/dist/game/tribe.js +432 -0
- package/dist/gameplay.d.ts +3 -1
- package/dist/gameplay.js +3 -1
- package/dist/inventory/encumbrance.d.ts +69 -0
- package/dist/inventory/encumbrance.js +68 -0
- package/dist/item/durability.js +1 -3
- package/dist/meta/changelog.d.ts +1 -1
- package/dist/meta/changelog.js +24 -1
- package/dist/movement/movementModel.d.ts +15 -1
- package/dist/movement/movementModel.js +33 -15
- package/dist/movement/playerMovement.js +102 -2
- package/dist/multiplayer/combatSnapshot.js +13 -8
- package/dist/multiplayer/presenceModel.d.ts +2 -0
- package/dist/multiplayer/presenceModel.js +8 -0
- package/dist/physics/drivableVehicle.d.ts +2 -0
- package/dist/physics/drivableVehicle.js +1 -1
- package/dist/physics/flightDynamics.d.ts +82 -0
- package/dist/physics/flightDynamics.js +165 -0
- package/dist/physics/gravityField.d.ts +25 -0
- package/dist/physics/gravityField.js +41 -0
- package/dist/physics/kinematicVehicle.d.ts +87 -0
- package/dist/physics/kinematicVehicle.js +193 -11
- package/dist/physics/physicsWorld.d.ts +26 -0
- package/dist/physics/physicsWorld.js +109 -117
- package/dist/physics/vehicleObstacles.d.ts +44 -0
- package/dist/physics/vehicleObstacles.js +115 -0
- package/dist/random/rng.d.ts +4 -1
- package/dist/random/rng.js +4 -1
- package/dist/runtime/adapter.d.ts +13 -0
- package/dist/runtime/adapter.js +13 -0
- package/dist/runtime/context/combat.d.ts +51 -0
- package/dist/runtime/context/combat.js +130 -0
- package/dist/runtime/context/deathLoot.d.ts +30 -0
- package/dist/runtime/context/deathLoot.js +39 -0
- package/dist/runtime/context/player.d.ts +48 -0
- package/dist/runtime/context/player.js +125 -0
- package/dist/runtime/context/scene.d.ts +59 -0
- package/dist/runtime/context/scene.js +291 -0
- package/dist/runtime/context/snapshotCodecs.d.ts +12 -0
- package/dist/runtime/context/snapshotCodecs.js +26 -0
- package/dist/runtime/descriptors/baseline.js +26 -3
- package/dist/runtime/descriptors/features.d.ts +5 -0
- package/dist/runtime/descriptors/features.js +20 -2
- package/dist/runtime/gameContext.d.ts +2 -428
- package/dist/runtime/gameContext.js +88 -501
- package/dist/runtime/gameContextTypes.d.ts +467 -0
- package/dist/runtime/gameContextTypes.js +1 -0
- package/dist/runtime/headlessRunner.d.ts +4 -2
- package/dist/runtime/headlessRunner.js +1 -0
- package/dist/runtime/hostPolicy.d.ts +51 -0
- package/dist/runtime/hostPolicy.js +68 -0
- package/dist/runtime/hostedGameRunner.d.ts +3 -1
- package/dist/runtime/hostedGameRunner.js +1 -0
- package/dist/runtime/hostedWorldSession.d.ts +3 -1
- package/dist/runtime/hostedWorldSession.js +1 -0
- package/dist/runtime/worldSnapshot.d.ts +13 -1
- package/dist/runtime/worldSnapshot.js +15 -3
- package/dist/scene/assetCatalog.d.ts +5 -0
- package/dist/scene/assetSpace.js +1 -3
- package/dist/scene/authoredTriggers.d.ts +50 -0
- package/dist/scene/authoredTriggers.js +114 -0
- package/dist/scene/builtinSceneKinds.js +8 -3
- package/dist/scene/colliders.d.ts +58 -0
- package/dist/scene/colliders.js +108 -0
- package/dist/scene/collisionMesh.d.ts +94 -0
- package/dist/scene/collisionMesh.js +699 -0
- package/dist/scene/companion.d.ts +147 -0
- package/dist/scene/companion.js +193 -0
- package/dist/scene/entityStats.d.ts +7 -9
- package/dist/scene/entityStats.js +10 -14
- package/dist/scene/sceneKinds.d.ts +16 -0
- package/dist/scene/sceneKinds.js +4 -0
- package/dist/scene/sceneRaycast.js +15 -0
- package/dist/stats/spawnLevelStats.d.ts +110 -0
- package/dist/stats/spawnLevelStats.js +140 -0
- package/dist/stats/statPool.d.ts +70 -0
- package/dist/stats/statPool.js +59 -0
- package/dist/store/changeSignal.d.ts +3 -0
- package/dist/store/changeSignal.js +2 -0
- package/dist/store/observableKeyedStore.d.ts +2 -0
- package/dist/store/observableKeyedStore.js +1 -0
- package/dist/survival/decayMeter.js +1 -3
- package/dist/survival/regionHealth.js +1 -3
- package/dist/ui/hudLayout.d.ts +5 -0
- package/dist/ui/hudLayout.js +17 -1
- package/dist/world/authoredEntities.d.ts +29 -0
- package/dist/world/authoredEntities.js +29 -0
- package/dist/world/authoredObjects.d.ts +15 -1
- package/dist/world/authoredObjects.js +13 -1
- package/dist/world/authoredSpawn.d.ts +39 -0
- package/dist/world/authoredSpawn.js +37 -0
- package/dist/world/buildSockets.d.ts +152 -0
- package/dist/world/buildSockets.js +188 -0
- package/dist/world/cityBlocks.d.ts +152 -0
- package/dist/world/cityBlocks.js +670 -0
- package/dist/world/cityContent.d.ts +77 -0
- package/dist/world/cityContent.js +261 -0
- package/dist/world/cityGeometry.d.ts +114 -0
- package/dist/world/cityGeometry.js +573 -0
- package/dist/world/cityKind.d.ts +314 -0
- package/dist/world/cityKind.js +1578 -0
- package/dist/world/features.d.ts +18 -3
- package/dist/world/features.js +10 -1
- package/dist/world/grassKind.js +2 -2
- package/dist/world/markers.d.ts +50 -4
- package/dist/world/markers.js +49 -0
- package/dist/world/massing.js +1 -1
- package/dist/world/minimapBake.d.ts +78 -0
- package/dist/world/minimapBake.js +208 -0
- package/dist/world/minimapTrack.d.ts +17 -0
- package/dist/world/minimapTrack.js +22 -0
- package/dist/world/pathNetwork.d.ts +159 -0
- package/dist/world/pathNetwork.js +684 -0
- package/dist/world/place.d.ts +166 -0
- package/dist/world/place.js +96 -0
- package/dist/world/placeAsset.js +3 -1
- package/dist/world/poleLineKind.d.ts +40 -0
- package/dist/world/poleLineKind.js +97 -0
- package/dist/world/polyline.js +9 -2
- package/dist/world/resourceNode.d.ts +109 -0
- package/dist/world/resourceNode.js +140 -0
- package/dist/world/scatter.js +2 -20
- package/dist/world/streets.d.ts +29 -0
- package/dist/world/streets.js +55 -0
- package/dist/world/terraform.js +58 -88
- package/dist/world/terrain.d.ts +45 -0
- package/dist/world/terrain.js +78 -0
- package/dist/world.d.ts +14 -5
- package/dist/world.js +12 -3
- package/package.json +1 -1
- package/skills/game-design/SKILL.md +28 -0
- package/skills/game-design/agents/openai.yaml +4 -0
- package/skills/game-design/references/application-playbook.md +170 -0
- package/skills/game-design/references/field-guide.md +288 -0
- package/skills/jgengine/SKILL.md +7 -4
- package/skills/jgengine/api.md +172 -79
- package/skills/jgengine/capabilities.md +104 -2
- package/skills/jgengine/recipes/minimal-game.md +88 -0
- package/skills/jgengine-combat/SKILL.md +5 -1
- package/skills/jgengine-combat/api.md +36 -0
- package/skills/jgengine-combat/capabilities.md +44 -0
- package/skills/jgengine-combat/recipes/portable-stat-pools.md +122 -0
- package/skills/jgengine-combat/reference.md +12 -2
- package/skills/jgengine-gameplay/api.md +152 -26
- package/skills/jgengine-gameplay/capabilities.md +78 -2
- package/skills/jgengine-gameplay/reference-systems.md +1 -5
- package/skills/jgengine-world/SKILL.md +13 -0
- package/skills/jgengine-world/api.md +419 -15
- package/skills/jgengine-world/capabilities.md +108 -2
- package/skills/jgengine-world/recipes/commanding-entities.md +128 -0
- package/skills/jgengine-world/reference.md +43 -4
- 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,15 @@ 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 { CollisionMeshData } from "../scene/collisionMesh.js";
|
|
12
14
|
import type { SkyEnvironmentConfig } from "../world/features.js";
|
|
13
15
|
import type { VisibilityConfig } from "../visibility/config.js";
|
|
14
16
|
import type { GameDefinition, GameLoop } from "./defineGame.js";
|
|
17
|
+
import type { GameCameraConfig } from "./cameraConfig.js";
|
|
15
18
|
import type { LootFilterRule } from "./lootFilter.js";
|
|
16
19
|
import type { RarityStyle } from "./worldItem.js";
|
|
20
|
+
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";
|
|
21
|
+
export { CAMERA_FRUSTUM_DEFAULTS } from "./cameraConfig.js";
|
|
17
22
|
export interface PointerConfig {
|
|
18
23
|
/**
|
|
19
24
|
* Left-click on open ground runs this command with `{ point, entity, object }`
|
|
@@ -37,445 +42,10 @@ export interface PointerConfig {
|
|
|
37
42
|
/** Right-click runs this command with `{ point, entity, object, aim }` when neither `orderCommand` nor `contextMenu` claims the click (#164.4). */
|
|
38
43
|
secondaryCommand?: string;
|
|
39
44
|
}
|
|
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
45
|
/** 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
46
|
export interface WorldOverlayProps {
|
|
56
47
|
ctx: GameContext;
|
|
57
48
|
}
|
|
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
49
|
export interface EntitySpriteConfig {
|
|
480
50
|
url: string;
|
|
481
51
|
width: number;
|
|
@@ -604,6 +174,8 @@ export interface ModelConfig {
|
|
|
604
174
|
anchor?: "center" | "origin";
|
|
605
175
|
/** Measured footprint/center/minY; supplied automatically when the model resolves through an `@jgengine/assets` catalog. Required for `anchor: "center"` to take effect. */
|
|
606
176
|
dims?: ModelDims;
|
|
177
|
+
/** 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. */
|
|
178
|
+
collisionMesh?: CollisionMeshData;
|
|
607
179
|
/** Per-entity PBR tint/finish override (#151.3); cloned onto each `MeshStandardMaterial` in the model so shared GLTF caches stay untouched. */
|
|
608
180
|
material?: ModelMaterialOverride;
|
|
609
181
|
/** Plays a GLTF animation clip on the model when the source has any (skinned or not); omit to render the rig's bind pose. */
|
|
@@ -696,6 +268,22 @@ export interface MovementCommitFrame {
|
|
|
696
268
|
/** The live game context (#282.2) — movement rules read stores/stats directly instead of module-level bridge objects. */
|
|
697
269
|
ctx: GameContext;
|
|
698
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Per-channel combat presentation toggles for the 3D shell canvas.
|
|
273
|
+
* Missing keys default to enabled when the parent `presentationEffects` is an object.
|
|
274
|
+
*/
|
|
275
|
+
export interface PresentationEffectsConfig {
|
|
276
|
+
/** Ground telegraphs for AoE / cast indicators. Default true. */
|
|
277
|
+
telegraphs?: boolean;
|
|
278
|
+
/** One-shot spell VFX + retained (persistent) VFX instances. Default true. */
|
|
279
|
+
vfx?: boolean;
|
|
280
|
+
/** Floating combat text (damage numbers, etc.). Default true. */
|
|
281
|
+
floatText?: boolean;
|
|
282
|
+
/** Projectile tracer lines. Default true. */
|
|
283
|
+
tracers?: boolean;
|
|
284
|
+
/** Trauma-driven combat camera shake. Default true. */
|
|
285
|
+
shake?: boolean;
|
|
286
|
+
}
|
|
699
287
|
/** How a screenshot host reaches live gameplay in this game — the data behind `shoot --mode play`. */
|
|
700
288
|
export interface GameCaptureConfig {
|
|
701
289
|
/** 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. */
|
|
@@ -724,6 +312,10 @@ export interface PlayableGame<TUi = unknown, TWorldOverlay = unknown, TRenderEnt
|
|
|
724
312
|
WorldOverlay?: TOverlay;
|
|
725
313
|
/** 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
314
|
environment?: TWorldOverlay;
|
|
315
|
+
/** 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. */
|
|
316
|
+
editorLayers?: EditorDocument;
|
|
317
|
+
/** Game-exported gameplay catalog definitions (schemas + defaults). `GameHost` forwards them to the summoned editor's Data panel; no per-game editor bootstrap needed. */
|
|
318
|
+
editorCatalogs?: readonly EditorCatalogDefinition[];
|
|
727
319
|
/** 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
320
|
viewmodel?: TViewmodel;
|
|
729
321
|
/** 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. */
|
|
@@ -777,6 +369,13 @@ export interface PlayableGame<TUi = unknown, TWorldOverlay = unknown, TRenderEnt
|
|
|
777
369
|
roles?: readonly CatalogEntityRole[];
|
|
778
370
|
maxDistance?: number;
|
|
779
371
|
};
|
|
372
|
+
/**
|
|
373
|
+
* Combat presentation stack mounted inside the 3D canvas (telegraphs, spell VFX, retained VFX,
|
|
374
|
+
* float text, projectile tracers, camera shake). Default `true` preserves historical always-on
|
|
375
|
+
* behavior. `false` mounts none. An object mounts only the listed pieces (missing keys default
|
|
376
|
+
* on so games can disable a single expensive channel, e.g. `{ tracers: false }`).
|
|
377
|
+
*/
|
|
378
|
+
presentationEffects?: boolean | PresentationEffectsConfig;
|
|
780
379
|
/** 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
380
|
audio?: {
|
|
782
381
|
sounds: Record<string, SoundDef>;
|
|
@@ -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 an `onLevelUp` callback. */
|
|
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. 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;
|
package/dist/game/progression.js
CHANGED
|
@@ -35,6 +35,14 @@ function interpolate(points, x) {
|
|
|
35
35
|
}
|
|
36
36
|
return last[1];
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Evaluate a progression {@link Curve} at position `x`, applying its rounding
|
|
40
|
+
* mode and min/max clamp. This is the shared numeric backbone for XP-per-level,
|
|
41
|
+
* cost ramps, difficulty scaling, and any other level/rank → value mapping — use
|
|
42
|
+
* it instead of hand-rolling growth formulas.
|
|
43
|
+
*
|
|
44
|
+
* @capability progression-curve evaluate a level/rank curve (const, linear, power, geometric, steps, piecewise) at a point
|
|
45
|
+
*/
|
|
38
46
|
export function evalCurve(spec, x) {
|
|
39
47
|
let y = rawCurve(spec, x);
|
|
40
48
|
if (spec.min !== undefined)
|
|
@@ -52,9 +60,20 @@ export function evalCurve(spec, x) {
|
|
|
52
60
|
return y;
|
|
53
61
|
}
|
|
54
62
|
}
|
|
63
|
+
/** Bind a {@link Curve} into a reusable `(x) => value` evaluator — a partial application of {@link evalCurve}. */
|
|
55
64
|
export function curve(spec) {
|
|
56
65
|
return (x) => evalCurve(spec, x);
|
|
57
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Build a leveling track from an xp-per-level {@link Curve} and a max level. The
|
|
69
|
+
* returned {@link LevelingTrack} resolves how many levels a given xp total earns
|
|
70
|
+
* (rolling over surplus xp, capping at `maxLevel`) and, via `grantXp`, writes the
|
|
71
|
+
* new level/xp back through a {@link LevelingStatAccess} and fires `onLevelUp` for
|
|
72
|
+
* each level gained. Reach for this instead of hand-tracking xp thresholds; pair
|
|
73
|
+
* it with `resource-pool` (mana/stamina) and `ability-bar` (cooldowns) for a hero.
|
|
74
|
+
*
|
|
75
|
+
* @capability leveling-track grant XP, resolve level-ups against a curve, and write level+xp stats back through a stat adapter
|
|
76
|
+
*/
|
|
58
77
|
export function leveling(config) {
|
|
59
78
|
const maxLevel = config.maxLevel;
|
|
60
79
|
const startLevel = config.startLevel ?? 1;
|