@skewedaspect/sage 0.9.6 → 0.10.0-beta.1

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 (71) hide show
  1. package/dist/classes/debugConsole.d.ts +1 -0
  2. package/dist/classes/gameEngine.d.ts +24 -46
  3. package/dist/classes/gameLevel.d.ts +15 -12
  4. package/dist/classes/level.d.ts +5 -29
  5. package/dist/debug/builtins.d.ts +4 -0
  6. package/dist/entities/constants.d.ts +1 -0
  7. package/dist/entities/defineEntity.d.ts +17 -0
  8. package/dist/entities/entityPicking.d.ts +14 -0
  9. package/dist/entities/meshConfig.d.ts +14 -0
  10. package/dist/entities/nodeEntity.d.ts +33 -0
  11. package/dist/entities/nodePool.d.ts +8 -0
  12. package/dist/entities/nodeSimulation.d.ts +22 -0
  13. package/dist/entities/nodeSimulationContext.d.ts +13 -0
  14. package/dist/entities/standardMeshSource.d.ts +8 -0
  15. package/dist/events/payloads.d.ts +0 -30
  16. package/dist/events/types.d.ts +2 -23
  17. package/dist/input/actionContext.d.ts +11 -0
  18. package/dist/input/actionRegistry.d.ts +7 -0
  19. package/dist/input/binding.d.ts +31 -0
  20. package/dist/input/bindings/toggle.d.ts +21 -0
  21. package/dist/input/bindings/trigger.d.ts +19 -0
  22. package/dist/input/bindings/value.d.ts +23 -0
  23. package/dist/input/configuration.d.ts +15 -0
  24. package/dist/input/deliverAction.d.ts +3 -0
  25. package/dist/input/deviceReader.d.ts +5 -0
  26. package/dist/input/deviceReaders/gamepad.d.ts +9 -0
  27. package/dist/input/deviceReaders/keyboard.d.ts +8 -0
  28. package/dist/input/deviceReaders/mouse.d.ts +9 -0
  29. package/dist/input/deviceState.d.ts +19 -0
  30. package/dist/input/inputCapture.d.ts +21 -0
  31. package/dist/input/resolveBinding.d.ts +4 -0
  32. package/dist/interfaces/game.d.ts +20 -4
  33. package/dist/interfaces/level.d.ts +19 -1
  34. package/dist/managers/game.d.ts +8 -5
  35. package/dist/managers/level.d.ts +6 -4
  36. package/dist/managers/outline.d.ts +4 -4
  37. package/dist/managers/simulationSave.d.ts +30 -0
  38. package/dist/{postProcessingFrameGraph-CaMgQzR-.js → postProcessingFrameGraph-rr2DbgPi.js} +1 -1
  39. package/dist/{postProcessingFrameGraph-CaMgQzR-.js.map → postProcessingFrameGraph-rr2DbgPi.js.map} +1 -1
  40. package/dist/sage.d.ts +46 -16
  41. package/dist/sage.es.js +1433 -2479
  42. package/dist/sage.es.js.map +1 -1
  43. package/dist/sage.umd.js +1 -1
  44. package/dist/sage.umd.js.map +1 -1
  45. package/dist/utils/physics.d.ts +4 -1
  46. package/package.json +29 -66
  47. package/LICENSE +0 -21
  48. package/Readme.md +0 -73
  49. package/dist/behaviors/index.d.ts +0 -2
  50. package/dist/behaviors/sound.d.ts +0 -137
  51. package/dist/behaviors/stateMachine.d.ts +0 -76
  52. package/dist/classes/bindings/toggle.d.ts +0 -116
  53. package/dist/classes/bindings/trigger.d.ts +0 -81
  54. package/dist/classes/bindings/value.d.ts +0 -104
  55. package/dist/classes/entity.d.ts +0 -332
  56. package/dist/classes/input/gamepad.d.ts +0 -94
  57. package/dist/classes/input/keyboard.d.ts +0 -66
  58. package/dist/classes/input/mouse.d.ts +0 -91
  59. package/dist/classes/input/readers/gamepad.d.ts +0 -73
  60. package/dist/classes/input/readers/keyboard.d.ts +0 -56
  61. package/dist/classes/input/readers/mouse.d.ts +0 -41
  62. package/dist/interfaces/action.d.ts +0 -22
  63. package/dist/interfaces/binding.d.ts +0 -123
  64. package/dist/interfaces/entity.d.ts +0 -97
  65. package/dist/interfaces/input.d.ts +0 -180
  66. package/dist/managers/binding.d.ts +0 -233
  67. package/dist/managers/entity.d.ts +0 -264
  68. package/dist/managers/input.d.ts +0 -54
  69. package/dist/managers/save.d.ts +0 -75
  70. package/dist/utils/entityProxy.d.ts +0 -2
  71. package/dist/utils/raycast.d.ts +0 -26
@@ -0,0 +1,3 @@
1
+ import { GameSimulationContext } from '@skewedaspect/sage-core';
2
+ import { Binding } from "./binding.d.ts";
3
+ export declare function deliverAction<State>(binding: Binding<State>, state: State, context: GameSimulationContext, senderID: string, targetID: string): void;
@@ -0,0 +1,5 @@
1
+ export interface DeviceReader<State> {
2
+ readonly sourceType: string;
3
+ readonly sourceKey: string;
4
+ getValue(state: State): boolean | number | undefined;
5
+ }
@@ -0,0 +1,9 @@
1
+ import { GamepadState } from "../deviceState.d.ts";
2
+ import { DeviceReader } from "../deviceReader.d.ts";
3
+ export type GamepadSourceType = 'button' | 'axis';
4
+ export declare class GamepadReader implements DeviceReader<GamepadState> {
5
+ readonly sourceType: GamepadSourceType;
6
+ readonly sourceKey: string;
7
+ constructor(sourceType: GamepadSourceType, sourceKey: string);
8
+ getValue(state: GamepadState): boolean | number | undefined;
9
+ }
@@ -0,0 +1,8 @@
1
+ import { KeyboardState } from "../deviceState.d.ts";
2
+ import { DeviceReader } from "../deviceReader.d.ts";
3
+ export declare class KeyboardReader implements DeviceReader<KeyboardState> {
4
+ readonly sourceType = "key";
5
+ readonly sourceKey: string;
6
+ constructor(sourceKey: string);
7
+ getValue(state: KeyboardState): boolean | undefined;
8
+ }
@@ -0,0 +1,9 @@
1
+ import { MouseState } from "../deviceState.d.ts";
2
+ import { DeviceReader } from "../deviceReader.d.ts";
3
+ export type MouseSourceType = 'button' | 'position' | 'wheel';
4
+ export declare class MouseReader implements DeviceReader<MouseState> {
5
+ readonly sourceType: MouseSourceType;
6
+ readonly sourceKey: string;
7
+ constructor(sourceType: MouseSourceType, sourceKey: string);
8
+ getValue(state: MouseState): boolean | number | undefined;
9
+ }
@@ -0,0 +1,19 @@
1
+ export interface KeyboardState {
2
+ readonly keys: Readonly<Record<string, boolean>>;
3
+ }
4
+ export interface MouseState {
5
+ readonly buttons: Readonly<Record<string, boolean>>;
6
+ readonly position: Readonly<{
7
+ x: number;
8
+ y: number;
9
+ }>;
10
+ readonly wheel: Readonly<{
11
+ deltaX: number;
12
+ deltaY: number;
13
+ deltaZ: number;
14
+ }>;
15
+ }
16
+ export interface GamepadState {
17
+ readonly buttons: Readonly<Record<string, number>>;
18
+ readonly axes: Readonly<Record<string, number>>;
19
+ }
@@ -0,0 +1,21 @@
1
+ import { BindingInput, DeviceType } from "./binding.d.ts";
2
+ export interface CaptureOptions {
3
+ deviceTypes?: readonly DeviceType[];
4
+ sourceTypes?: readonly string[];
5
+ signal?: AbortSignal;
6
+ }
7
+ export interface CandidateInput {
8
+ device: {
9
+ type: DeviceType;
10
+ index: number;
11
+ };
12
+ sourceType: string;
13
+ sourceKey: string;
14
+ value: boolean | number;
15
+ }
16
+ export declare class InputCapture {
17
+ #private;
18
+ constructor(options?: CaptureOptions);
19
+ feed(candidate: CandidateInput): void;
20
+ wait(): Promise<BindingInput>;
21
+ }
@@ -0,0 +1,4 @@
1
+ import { Action } from '@skewedaspect/sage-core';
2
+ import { Binding, BindingDefinition } from "./binding.d.ts";
3
+ import { DeviceReader } from "./deviceReader.d.ts";
4
+ export declare function resolveBinding<State>(definition: BindingDefinition, action: Action, reader: DeviceReader<State>): Binding<State>;
@@ -1,6 +1,14 @@
1
- import { EngineOptions, NullEngineOptions, WebGPUEngineOptions } from '@babylonjs/core';
1
+ import { AbstractMesh, EngineOptions, NullEngineOptions, Scene, WebGPUEngineOptions } from '@babylonjs/core';
2
+ import { StateBag } from '@skewedaspect/sage-core';
2
3
  import { LogLevel } from "./logger.d.ts";
3
- import { BindingDefinition } from "./binding.d.ts";
4
+ /**
5
+ * Builds a NodeEntity class's mesh from its name and state, into the given scene.
6
+ *
7
+ * NodeSimulationContext's own MeshLoader carries no scene, because the same context that calls it also holds
8
+ * the scene -- but a game's own loader is authored once, before any scene exists, and reused across every
9
+ * level's simulation, so it needs the scene handed in.
10
+ */
11
+ export type EntityMeshLoader = (scene: Scene, name: string, state: Readonly<StateBag>) => Promise<AbstractMesh | undefined>;
4
12
  export type GameCanvas = HTMLCanvasElement | OffscreenCanvas | null;
5
13
  /** Specifies which rendering engine to force using */
6
14
  export type EngineType = 'webgl' | 'webgpu' | 'auto';
@@ -19,8 +27,6 @@ export type RenderEngineOptions = (BabylonEngineOptions | NullEngineOptions | We
19
27
  export interface SageOptions {
20
28
  /** Render engine options for BabylonJS */
21
29
  renderOptions?: RenderEngineOptions;
22
- /** Input bindings to be registered at startup */
23
- bindings?: BindingDefinition[];
24
30
  /** Logging level for the engine */
25
31
  logLevel?: LogLevel;
26
32
  /** Audio channel names. If provided, SAGE initializes AudioV2 with one bus per channel. */
@@ -40,4 +46,14 @@ export interface SageOptions {
40
46
  debug?: false | {
41
47
  namespace?: string;
42
48
  };
49
+ /**
50
+ * Pre-loaded Havok WASM binary, for booting outside a browser.
51
+ *
52
+ * Havok normally fetches its own WASM over HTTP; in node there is nothing to fetch from, so the
53
+ * bytes have to be handed in. Browsers should leave this unset -- it is not a performance knob,
54
+ * and setting it does not change how physics behaves.
55
+ */
56
+ havokBinary?: BufferSource;
57
+ /** The simulation's fixed step duration, in seconds. Default 1/60. */
58
+ fixedStepDuration?: number;
43
59
  }
@@ -1,7 +1,18 @@
1
1
  import { Scene, TransformNode } from '@babylonjs/core';
2
2
  import { GameEngine } from "../classes/gameEngine.d.ts";
3
+ import { EntityMeshLoader } from "./game.d.ts";
3
4
  import { ColliderDebugConfig } from "../managers/colliderDebug.d.ts";
4
5
  import { LoggingUtility } from "../utils/logger.d.ts";
6
+ /**
7
+ * Options controlling how a level loads.
8
+ */
9
+ export interface LevelLoadOptions {
10
+ /**
11
+ * If true, this load is restoring a save: the level runs no marker-driven spawning of its own, since the
12
+ * restored snapshot is the sole source of entities (design/simulation.md#saved-games).
13
+ */
14
+ forRestore?: boolean;
15
+ }
5
16
  /**
6
17
  * Minimal interface for Level that property handlers receive.
7
18
  * This avoids circular dependencies while still providing access to level functionality.
@@ -51,7 +62,9 @@ export interface SpawnDefinition {
51
62
  * Used to configure entities that are marked with the 'entity' property in scene files.
52
63
  */
53
64
  export interface EntityDefinition {
54
- /** Optional name override for the entity (overrides the scene node name). */
65
+ /** The entity type name to spawn, adopting the marked node. */
66
+ entity: string;
67
+ /** Optional human-readable name for the entity instance. */
55
68
  name?: string;
56
69
  /** Tags to apply to the entity (merged with definition tags). */
57
70
  tags?: string[];
@@ -81,6 +94,11 @@ export interface SceneConfig {
81
94
  export interface LevelConfig {
82
95
  /** The name of the level */
83
96
  name: string;
97
+ /**
98
+ * Builds a NodeEntity class's mesh from its name and state, into the level's scene. Left unset, every
99
+ * entity this level spawns gets a node with no mesh.
100
+ */
101
+ meshSource?: EntityMeshLoader;
84
102
  /** Scene file path, or configuration object with path and options */
85
103
  scene?: string | SceneConfig;
86
104
  /** Name of a registered custom Level class to use instead of GameLevel */
@@ -1,9 +1,8 @@
1
1
  import { AbstractEngine, Scene } from '@babylonjs/core';
2
2
  import { Disposable } from "../interfaces/lifecycle.d.ts";
3
3
  import { GameEventBus } from "../classes/eventBus.d.ts";
4
- import { GameEntityManager } from "./entity.d.ts";
4
+ import { GameEngine } from "../classes/gameEngine.d.ts";
5
5
  import { LevelManager } from "./level.d.ts";
6
- import { UserInputManager } from "./input.d.ts";
7
6
  import { LoggingUtility } from "../utils/logger.d.ts";
8
7
  /**
9
8
  * Callback function for frame updates.
@@ -13,8 +12,7 @@ export type FrameCallback = (deltaTime: number) => void;
13
12
  export declare class GameManager implements Disposable {
14
13
  private _engine;
15
14
  private _eventBus;
16
- private _entityManager;
17
- private _inputManager;
15
+ private _gameEngine;
18
16
  private _levelManager;
19
17
  private _log;
20
18
  private _boundRenderLoop;
@@ -26,8 +24,13 @@ export declare class GameManager implements Disposable {
26
24
  /** Whether the game is currently paused */
27
25
  private _paused;
28
26
  started: boolean;
29
- constructor(engine: AbstractEngine, eventBus: GameEventBus, entityManager: GameEntityManager, inputManager: UserInputManager, levelManager: LevelManager, logger?: LoggingUtility);
27
+ constructor(engine: AbstractEngine, eventBus: GameEventBus, levelManager: LevelManager, logger?: LoggingUtility);
30
28
  get currentScene(): Scene | null;
29
+ /**
30
+ * Late-bind the GameEngine after construction.
31
+ * Called by createGameEngine() after the GameEngine instance is created.
32
+ */
33
+ $setGameEngine(gameEngine: GameEngine): void;
31
34
  /**
32
35
  * Whether the game is currently paused.
33
36
  * When paused, entity updates and frame callbacks are skipped, but rendering continues.
@@ -1,4 +1,4 @@
1
- import { LevelConfig, LevelConstructor, PropertyHandler } from "../interfaces/level.d.ts";
1
+ import { LevelConfig, LevelConstructor, LevelLoadOptions, PropertyHandler } from "../interfaces/level.d.ts";
2
2
  import { Disposable } from "../interfaces/lifecycle.d.ts";
3
3
  import { Level } from "../classes/level.d.ts";
4
4
  import { GameEventBus } from "../classes/eventBus.d.ts";
@@ -7,7 +7,7 @@ import { LoggingUtility } from "../utils/logger.d.ts";
7
7
  /**
8
8
  * Options for level transitions.
9
9
  */
10
- export interface TransitionOptions {
10
+ export interface TransitionOptions extends LevelLoadOptions {
11
11
  /** If true, the old level is kept loaded (not disposed) after transitioning away */
12
12
  keepAlive?: boolean;
13
13
  /** If true, the new level is loaded but not activated — currentLevel remains unchanged */
@@ -137,14 +137,16 @@ export declare class LevelManager implements Disposable {
137
137
  * Loads a level by name. The level config must be registered first.
138
138
  *
139
139
  * @param name
140
+ * @param options
140
141
  */
141
- loadLevel(name: string): Promise<Level>;
142
+ loadLevel(name: string, options?: LevelLoadOptions): Promise<Level>;
142
143
  /**
143
144
  * Loads a level from a config. The config will be registered automatically.
144
145
  *
145
146
  * @param config
147
+ * @param options
146
148
  */
147
- loadLevel(config: LevelConfig): Promise<Level>;
149
+ loadLevel(config: LevelConfig, options?: LevelLoadOptions): Promise<Level>;
148
150
  /**
149
151
  * Activates a level by name, loading it if necessary.
150
152
  *
@@ -1,5 +1,5 @@
1
1
  import { Scene, SelectionOutlineLayer } from '@babylonjs/core';
2
- import { GameEntity } from "../classes/entity.d.ts";
2
+ import { NodeEntity } from "../entities/nodeEntity.d.ts";
3
3
  import { OutlineLayerConfig } from "../interfaces/level.d.ts";
4
4
  export declare class OutlineManager {
5
5
  private _scene;
@@ -7,9 +7,9 @@ export declare class OutlineManager {
7
7
  constructor(scene: Scene, configs?: Record<string, OutlineLayerConfig>);
8
8
  get(name: string): SelectionOutlineLayer | undefined;
9
9
  create(name: string, config?: OutlineLayerConfig): SelectionOutlineLayer;
10
- highlightEntity(layerName: string, entity: GameEntity): void;
11
- unhighlightEntity(layerName: string, entity: GameEntity): void;
12
- unhighlightEntityAll(entity: GameEntity): void;
10
+ highlightEntity(layerName: string, entity: NodeEntity): void;
11
+ unhighlightEntity(layerName: string, entity: NodeEntity): void;
12
+ unhighlightEntityAll(entity: NodeEntity): void;
13
13
  clear(layerName: string): void;
14
14
  dispose(): void;
15
15
  private _rebuildSelection;
@@ -0,0 +1,30 @@
1
+ import { GameSimulationManager, GameSimulationSnapshot } from '@skewedaspect/sage-core';
2
+ import { Disposable } from "../interfaces/lifecycle.d.ts";
3
+ import { LevelLoadOptions } from "../interfaces/level.d.ts";
4
+ export interface LevelLoader {
5
+ readonly currentLevel: {
6
+ name: string;
7
+ } | null;
8
+ transition(levelName: string, options?: LevelLoadOptions): Promise<void>;
9
+ }
10
+ export interface SaveEnvelope {
11
+ saveFormatVersion: number;
12
+ engineVersion: string;
13
+ level: string;
14
+ timestamp: number;
15
+ custom: Record<string, unknown>;
16
+ snapshot: GameSimulationSnapshot;
17
+ }
18
+ export type BeforeSaveHook = () => Record<string, unknown>;
19
+ export interface LoadResult {
20
+ simulation: GameSimulationManager;
21
+ envelope: SaveEnvelope;
22
+ }
23
+ export declare class SimulationSaveManager implements Disposable {
24
+ #private;
25
+ constructor(levelLoader: LevelLoader, engineVersion: string, now?: () => number);
26
+ onBeforeSave(hook: BeforeSaveHook): void;
27
+ save(simulation: GameSimulationManager): SaveEnvelope;
28
+ load(envelope: SaveEnvelope, simulation: GameSimulationManager): Promise<LoadResult>;
29
+ $teardown(): Promise<void>;
30
+ }
@@ -67,4 +67,4 @@ async function m(m, h) {
67
67
  //#endregion
68
68
  export { m as applyFrameGraphPostProcessing };
69
69
 
70
- //# sourceMappingURL=postProcessingFrameGraph-CaMgQzR-.js.map
70
+ //# sourceMappingURL=postProcessingFrameGraph-rr2DbgPi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"postProcessingFrameGraph-CaMgQzR-.js","names":[],"sources":["../src/handlers/postProcessingFrameGraph.ts"],"sourcesContent":["//----------------------------------------------------------------------------------------------------------------------\n// Frame Graph Post-Processing Backend\n//\n// Builds a directed task chain using BabylonJS Frame Graph system.\n// Each post-processing effect is a separate task chained via texture handles.\n//----------------------------------------------------------------------------------------------------------------------\n\nimport {\n Constants,\n FrameGraph,\n FrameGraphBloomTask,\n FrameGraphChromaticAberrationTask,\n FrameGraphClearTextureTask,\n FrameGraphCopyToBackbufferColorTask,\n FrameGraphGeometryRendererTask,\n FrameGraphGrainTask,\n FrameGraphImageProcessingTask,\n FrameGraphObjectRendererTask,\n FrameGraphSSAO2RenderingPipelineTask,\n FrameGraphSharpenTask,\n type FrameGraphTextureHandle,\n ImageProcessingConfiguration,\n type Scene,\n} from '@babylonjs/core';\n\nimport type { PostProcessingConfig } from '../interfaces/level.ts';\n\n//----------------------------------------------------------------------------------------------------------------------\n\n/**\n * Map from user-facing tonemap operator names to BabylonJS constants.\n * BabylonJS only has STANDARD (0) and ACES (1) — the other names all map to STANDARD.\n */\nconst TONEMAP_OPERATORS : Record<string, number> = {\n hable: ImageProcessingConfiguration.TONEMAPPING_STANDARD,\n reinhard: ImageProcessingConfiguration.TONEMAPPING_STANDARD,\n hejidawson: ImageProcessingConfiguration.TONEMAPPING_STANDARD,\n photographic: ImageProcessingConfiguration.TONEMAPPING_STANDARD,\n aces: ImageProcessingConfiguration.TONEMAPPING_ACES,\n};\n\n//----------------------------------------------------------------------------------------------------------------------\n\nexport async function applyFrameGraphPostProcessing(scene : Scene, config : PostProcessingConfig) : Promise<void>\n{\n const camera = scene.activeCamera;\n if(!camera)\n {\n return;\n }\n\n const engine = scene.getEngine();\n const fg = new FrameGraph(scene);\n\n // Create the main render target texture\n const colorTexture = fg.textureManager.createRenderTargetTexture('sage-fg-color', {\n size: { width: 100, height: 100 },\n sizeIsPercentage: true,\n options: { formats: [ Constants.TEXTUREFORMAT_RGBA ], samples: 4 },\n });\n\n // 1. Clear\n const clearTask = new FrameGraphClearTextureTask('sage-clear', fg);\n clearTask.targetTexture = colorTexture;\n fg.addTask(clearTask);\n\n // 2. Render objects\n const renderTask = new FrameGraphObjectRendererTask('sage-render', fg, scene);\n renderTask.targetTexture = clearTask.outputTexture;\n renderTask.depthTexture = clearTask.outputDepthTexture;\n renderTask.camera = camera;\n renderTask.objectList = { meshes: scene.meshes, particleSystems: scene.particleSystems };\n renderTask.isMainObjectRenderer = true;\n fg.addTask(renderTask);\n\n // Track the current output texture through the chain\n let currentTexture : FrameGraphTextureHandle = renderTask.outputTexture;\n\n // 3. SSAO (needs geometry renderer for depth/normals)\n if(config.ssao)\n {\n const geoTask = new FrameGraphGeometryRendererTask('sage-geometry', fg, scene);\n fg.addTask(geoTask);\n\n const ssaoTask = new FrameGraphSSAO2RenderingPipelineTask('sage-ssao', fg, 0.5, 1.0);\n ssaoTask.sourceTexture = currentTexture;\n ssaoTask.depthTexture = geoTask.geometryViewDepthTexture;\n ssaoTask.normalTexture = geoTask.geometryViewNormalTexture;\n ssaoTask.camera = camera;\n fg.addTask(ssaoTask);\n\n if(config.ssao.radius !== undefined) { ssaoTask.ssao.radius = config.ssao.radius; }\n if(config.ssao.samples !== undefined) { ssaoTask.ssao.samples = config.ssao.samples; }\n if(config.ssao.totalStrength !== undefined) { ssaoTask.ssao.totalStrength = config.ssao.totalStrength; }\n\n currentTexture = ssaoTask.outputTexture;\n }\n\n // 4. Bloom\n if(config.bloom)\n {\n const bloomTask = new FrameGraphBloomTask(\n 'sage-bloom',\n fg,\n config.bloom.weight ?? 0.5,\n config.bloom.kernel ?? 128,\n config.bloom.threshold ?? 0.1,\n true,\n config.bloom.scale ?? 0.5\n );\n bloomTask.sourceTexture = currentTexture;\n fg.addTask(bloomTask);\n\n currentTexture = bloomTask.outputTexture;\n }\n\n // 5. Grain\n if(config.grain)\n {\n const grainTask = new FrameGraphGrainTask('sage-grain', fg);\n grainTask.sourceTexture = currentTexture;\n fg.addTask(grainTask);\n\n if(config.grain.intensity !== undefined) { grainTask.postProcess.intensity = config.grain.intensity; }\n if(config.grain.animated !== undefined) { grainTask.postProcess.animated = config.grain.animated; }\n\n currentTexture = grainTask.outputTexture;\n }\n\n // 6. Sharpen\n if(config.sharpen)\n {\n const sharpenTask = new FrameGraphSharpenTask('sage-sharpen', fg);\n sharpenTask.sourceTexture = currentTexture;\n fg.addTask(sharpenTask);\n\n if(config.sharpen.edge !== undefined) { sharpenTask.postProcess.edgeAmount = config.sharpen.edge; }\n if(config.sharpen.color !== undefined) { sharpenTask.postProcess.colorAmount = config.sharpen.color; }\n\n currentTexture = sharpenTask.outputTexture;\n }\n\n // 7. Chromatic aberration\n if(config.chromaticAberration)\n {\n const chromTask = new FrameGraphChromaticAberrationTask('sage-chromab', fg);\n chromTask.sourceTexture = currentTexture;\n fg.addTask(chromTask);\n\n if(config.chromaticAberration.amount !== undefined)\n {\n chromTask.postProcess.aberrationAmount = config.chromaticAberration.amount;\n }\n\n currentTexture = chromTask.outputTexture;\n }\n\n // 8. Image processing (tonemap + vignette)\n if(config.tonemap || config.vignette)\n {\n const imgTask = new FrameGraphImageProcessingTask('sage-imgproc', fg);\n imgTask.sourceTexture = currentTexture;\n fg.addTask(imgTask);\n\n if(config.tonemap)\n {\n imgTask.postProcess.toneMappingEnabled = true;\n\n if(config.tonemap.operator)\n {\n imgTask.postProcess.toneMappingType\n = TONEMAP_OPERATORS[config.tonemap.operator]\n ?? ImageProcessingConfiguration.TONEMAPPING_STANDARD;\n }\n }\n\n if(config.vignette)\n {\n imgTask.postProcess.vignetteEnabled = true;\n\n if(config.vignette.weight !== undefined) { imgTask.postProcess.vignetteWeight = config.vignette.weight; }\n if(config.vignette.stretch !== undefined)\n {\n imgTask.postProcess.vignetteStretch = config.vignette.stretch;\n }\n if(config.vignette.color)\n {\n const vc = config.vignette.color;\n imgTask.postProcess.vignetteColor.set(vc.r, vc.g, vc.b, 1);\n }\n }\n\n currentTexture = imgTask.outputTexture;\n }\n\n // 9. Volumetric lighting — not yet wired up for automatic light detection\n if(config.volumetric)\n {\n console.warn(\n '[SAGE] Volumetric lighting config is recognized but automatic light detection is not yet supported. '\n + 'Use scene.frameGraph to add FrameGraphVolumetricLightingTask manually.'\n );\n }\n\n // 10. Output to screen\n const copyTask = new FrameGraphCopyToBackbufferColorTask('sage-output', fg);\n copyTask.sourceTexture = currentTexture;\n fg.addTask(copyTask);\n\n // Wire up the scene — cameraToUseForPointers is needed because activeCamera becomes null between tasks\n scene.cameraToUseForPointers = camera;\n scene.frameGraph = fg;\n\n // Rebuild on resize\n engine.onResizeObservable.add(async () =>\n {\n await fg.buildAsync();\n });\n\n // Initial build\n await fg.buildAsync();\n}\n\n//----------------------------------------------------------------------------------------------------------------------\n"],"mappings":";;AAiCA,IAAM,IAA6C;CAC/C,OAAO,EAA6B;CACpC,UAAU,EAA6B;CACvC,YAAY,EAA6B;CACzC,cAAc,EAA6B;CAC3C,MAAM,EAA6B;CACtC;AAID,eAAsB,EAA8B,GAAe,GACnE;CACI,IAAM,IAAS,EAAM;AACrB,KAAG,CAAC,EAEA;CAGJ,IAAM,IAAS,EAAM,WAAW,EAC1B,IAAK,IAAI,EAAW,EAAM,EAG1B,IAAe,EAAG,eAAe,0BAA0B,iBAAiB;EAC9E,MAAM;GAAE,OAAO;GAAK,QAAQ;GAAK;EACjC,kBAAkB;EAClB,SAAS;GAAE,SAAS,CAAE,EAAU,mBAAoB;GAAE,SAAS;GAAG;EACrE,CAAC,EAGI,IAAY,IAAI,EAA2B,cAAc,EAAG;AAElE,CADA,EAAU,gBAAgB,GAC1B,EAAG,QAAQ,EAAU;CAGrB,IAAM,IAAa,IAAI,EAA6B,eAAe,GAAI,EAAM;AAM7E,CALA,EAAW,gBAAgB,EAAU,eACrC,EAAW,eAAe,EAAU,oBACpC,EAA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AmB,IAAI,YAC9B;AACI,QAAM,EAAG,YAAY;GACvB,EAGF,MAAM,EAAG,YAAY"}
1
+ {"version":3,"file":"postProcessingFrameGraph-rr2DbgPi.js","names":[],"sources":["../src/handlers/postProcessingFrameGraph.ts"],"sourcesContent":["//----------------------------------------------------------------------------------------------------------------------\n// Frame Graph Post-Processing Backend\n//\n// Builds a directed task chain using BabylonJS Frame Graph system.\n// Each post-processing effect is a separate task chained via texture handles.\n//----------------------------------------------------------------------------------------------------------------------\n\nimport {\n Constants,\n FrameGraph,\n FrameGraphBloomTask,\n FrameGraphChromaticAberrationTask,\n FrameGraphClearTextureTask,\n FrameGraphCopyToBackbufferColorTask,\n FrameGraphGeometryRendererTask,\n FrameGraphGrainTask,\n FrameGraphImageProcessingTask,\n FrameGraphObjectRendererTask,\n FrameGraphSSAO2RenderingPipelineTask,\n FrameGraphSharpenTask,\n type FrameGraphTextureHandle,\n ImageProcessingConfiguration,\n type Scene,\n} from '@babylonjs/core';\n\nimport type { PostProcessingConfig } from '../interfaces/level.ts';\n\n//----------------------------------------------------------------------------------------------------------------------\n\n/**\n * Map from user-facing tonemap operator names to BabylonJS constants.\n * BabylonJS only has STANDARD (0) and ACES (1) — the other names all map to STANDARD.\n */\nconst TONEMAP_OPERATORS : Record<string, number> = {\n hable: ImageProcessingConfiguration.TONEMAPPING_STANDARD,\n reinhard: ImageProcessingConfiguration.TONEMAPPING_STANDARD,\n hejidawson: ImageProcessingConfiguration.TONEMAPPING_STANDARD,\n photographic: ImageProcessingConfiguration.TONEMAPPING_STANDARD,\n aces: ImageProcessingConfiguration.TONEMAPPING_ACES,\n};\n\n//----------------------------------------------------------------------------------------------------------------------\n\nexport async function applyFrameGraphPostProcessing(scene : Scene, config : PostProcessingConfig) : Promise<void>\n{\n const camera = scene.activeCamera;\n if(!camera)\n {\n return;\n }\n\n const engine = scene.getEngine();\n const fg = new FrameGraph(scene);\n\n // Create the main render target texture\n const colorTexture = fg.textureManager.createRenderTargetTexture('sage-fg-color', {\n size: { width: 100, height: 100 },\n sizeIsPercentage: true,\n options: { formats: [ Constants.TEXTUREFORMAT_RGBA ], samples: 4 },\n });\n\n // 1. Clear\n const clearTask = new FrameGraphClearTextureTask('sage-clear', fg);\n clearTask.targetTexture = colorTexture;\n fg.addTask(clearTask);\n\n // 2. Render objects\n const renderTask = new FrameGraphObjectRendererTask('sage-render', fg, scene);\n renderTask.targetTexture = clearTask.outputTexture;\n renderTask.depthTexture = clearTask.outputDepthTexture;\n renderTask.camera = camera;\n renderTask.objectList = { meshes: scene.meshes, particleSystems: scene.particleSystems };\n renderTask.isMainObjectRenderer = true;\n fg.addTask(renderTask);\n\n // Track the current output texture through the chain\n let currentTexture : FrameGraphTextureHandle = renderTask.outputTexture;\n\n // 3. SSAO (needs geometry renderer for depth/normals)\n if(config.ssao)\n {\n const geoTask = new FrameGraphGeometryRendererTask('sage-geometry', fg, scene);\n fg.addTask(geoTask);\n\n const ssaoTask = new FrameGraphSSAO2RenderingPipelineTask('sage-ssao', fg, 0.5, 1.0);\n ssaoTask.sourceTexture = currentTexture;\n ssaoTask.depthTexture = geoTask.geometryViewDepthTexture;\n ssaoTask.normalTexture = geoTask.geometryViewNormalTexture;\n ssaoTask.camera = camera;\n fg.addTask(ssaoTask);\n\n if(config.ssao.radius !== undefined) { ssaoTask.ssao.radius = config.ssao.radius; }\n if(config.ssao.samples !== undefined) { ssaoTask.ssao.samples = config.ssao.samples; }\n if(config.ssao.totalStrength !== undefined) { ssaoTask.ssao.totalStrength = config.ssao.totalStrength; }\n\n currentTexture = ssaoTask.outputTexture;\n }\n\n // 4. Bloom\n if(config.bloom)\n {\n const bloomTask = new FrameGraphBloomTask(\n 'sage-bloom',\n fg,\n config.bloom.weight ?? 0.5,\n config.bloom.kernel ?? 128,\n config.bloom.threshold ?? 0.1,\n true,\n config.bloom.scale ?? 0.5\n );\n bloomTask.sourceTexture = currentTexture;\n fg.addTask(bloomTask);\n\n currentTexture = bloomTask.outputTexture;\n }\n\n // 5. Grain\n if(config.grain)\n {\n const grainTask = new FrameGraphGrainTask('sage-grain', fg);\n grainTask.sourceTexture = currentTexture;\n fg.addTask(grainTask);\n\n if(config.grain.intensity !== undefined) { grainTask.postProcess.intensity = config.grain.intensity; }\n if(config.grain.animated !== undefined) { grainTask.postProcess.animated = config.grain.animated; }\n\n currentTexture = grainTask.outputTexture;\n }\n\n // 6. Sharpen\n if(config.sharpen)\n {\n const sharpenTask = new FrameGraphSharpenTask('sage-sharpen', fg);\n sharpenTask.sourceTexture = currentTexture;\n fg.addTask(sharpenTask);\n\n if(config.sharpen.edge !== undefined) { sharpenTask.postProcess.edgeAmount = config.sharpen.edge; }\n if(config.sharpen.color !== undefined) { sharpenTask.postProcess.colorAmount = config.sharpen.color; }\n\n currentTexture = sharpenTask.outputTexture;\n }\n\n // 7. Chromatic aberration\n if(config.chromaticAberration)\n {\n const chromTask = new FrameGraphChromaticAberrationTask('sage-chromab', fg);\n chromTask.sourceTexture = currentTexture;\n fg.addTask(chromTask);\n\n if(config.chromaticAberration.amount !== undefined)\n {\n chromTask.postProcess.aberrationAmount = config.chromaticAberration.amount;\n }\n\n currentTexture = chromTask.outputTexture;\n }\n\n // 8. Image processing (tonemap + vignette)\n if(config.tonemap || config.vignette)\n {\n const imgTask = new FrameGraphImageProcessingTask('sage-imgproc', fg);\n imgTask.sourceTexture = currentTexture;\n fg.addTask(imgTask);\n\n if(config.tonemap)\n {\n imgTask.postProcess.toneMappingEnabled = true;\n\n if(config.tonemap.operator)\n {\n imgTask.postProcess.toneMappingType\n = TONEMAP_OPERATORS[config.tonemap.operator]\n ?? ImageProcessingConfiguration.TONEMAPPING_STANDARD;\n }\n }\n\n if(config.vignette)\n {\n imgTask.postProcess.vignetteEnabled = true;\n\n if(config.vignette.weight !== undefined) { imgTask.postProcess.vignetteWeight = config.vignette.weight; }\n if(config.vignette.stretch !== undefined)\n {\n imgTask.postProcess.vignetteStretch = config.vignette.stretch;\n }\n if(config.vignette.color)\n {\n const vc = config.vignette.color;\n imgTask.postProcess.vignetteColor.set(vc.r, vc.g, vc.b, 1);\n }\n }\n\n currentTexture = imgTask.outputTexture;\n }\n\n // 9. Volumetric lighting — not yet wired up for automatic light detection\n if(config.volumetric)\n {\n console.warn(\n '[SAGE] Volumetric lighting config is recognized but automatic light detection is not yet supported. '\n + 'Use scene.frameGraph to add FrameGraphVolumetricLightingTask manually.'\n );\n }\n\n // 10. Output to screen\n const copyTask = new FrameGraphCopyToBackbufferColorTask('sage-output', fg);\n copyTask.sourceTexture = currentTexture;\n fg.addTask(copyTask);\n\n // Wire up the scene — cameraToUseForPointers is needed because activeCamera becomes null between tasks\n scene.cameraToUseForPointers = camera;\n scene.frameGraph = fg;\n\n // Rebuild on resize\n engine.onResizeObservable.add(async () =>\n {\n await fg.buildAsync();\n });\n\n // Initial build\n await fg.buildAsync();\n}\n\n//----------------------------------------------------------------------------------------------------------------------\n"],"mappings":";;AAiCA,IAAM,IAA6C;CAC/C,OAAO,EAA6B;CACpC,UAAU,EAA6B;CACvC,YAAY,EAA6B;CACzC,cAAc,EAA6B;CAC3C,MAAM,EAA6B;AACvC;AAIA,eAAsB,EAA8B,GAAe,GACnE;CACI,IAAM,IAAS,EAAM;CACrB,IAAG,CAAC,GAEA;CAGJ,IAAM,IAAS,EAAM,UAAU,GACzB,IAAK,IAAI,EAAW,CAAK,GAGzB,IAAe,EAAG,eAAe,0BAA0B,iBAAiB;EAC9E,MAAM;GAAE,OAAO;GAAK,QAAQ;EAAI;EAChC,kBAAkB;EAClB,SAAS;GAAE,SAAS,CAAE,EAAU,kBAAmB;GAAG,SAAS;EAAE;CACrE,CAAC,GAGK,IAAY,IAAI,EAA2B,cAAc,CAAE;CAEjE,AADA,EAAU,gBAAgB,GAC1B,EAAG,QAAQ,CAAS;CAGpB,IAAM,IAAa,IAAI,EAA6B,eAAe,GAAI,CAAK;CAM5E,AALA,EAAW,gBAAgB,EAAU,eACrC,EAAW,eAAe,EAAU,oBACpC,EAAW,SAAS,GACpB,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M,aAAa,GAGnB,EAAO,mBAAmB,IAAI,YAC9B;EACI,MAAM,EAAG,WAAW;CACxB,CAAC,GAGD,MAAM,EAAG,WAAW;AACxB"}
package/dist/sage.d.ts CHANGED
@@ -1,30 +1,27 @@
1
1
  import { GameCanvas, SageOptions } from "./interfaces/game.d.ts";
2
2
  import { GameEngine } from "./classes/gameEngine.d.ts";
3
3
  import { GameEventBus } from "./classes/eventBus.d.ts";
4
+ import { GameEntityType } from '@skewedaspect/sage-core';
4
5
  import { AudioEngine } from "./engines/audio.d.ts";
5
6
  import { SceneEngine } from "./engines/scene.d.ts";
6
7
  import { AssetManager } from "./managers/asset.d.ts";
7
- import { GameEntityDefinition } from "./interfaces/entity.d.ts";
8
8
  /**
9
- * Creates and initializes a fully-wired GameEngine with rendering, physics, input, and entity management.
9
+ * Creates and initializes a fully-wired GameEngine with rendering, physics, and entity management. A
10
+ * game builds its own action registry, contexts, and bindings from the exported input module -- the engine
11
+ * supplies the pieces input.md and events.md#delivery describe, not a device-to-binding routing loop.
10
12
  *
11
13
  * @param canvas
12
- * @param entities - Entity definitions to register before the engine starts
14
+ * @param entityClasses - The entity class table, keyed by class name, that the simulation spawns from
13
15
  * @param options
14
16
  */
15
- export declare function createGameEngine(canvas: GameCanvas, entities: GameEntityDefinition[], options?: SageOptions): Promise<GameEngine>;
16
- export * from "./interfaces/action.d.ts";
17
- export * from "./interfaces/binding.d.ts";
18
- export * from "./interfaces/entity.d.ts";
17
+ export declare function createGameEngine(canvas: GameCanvas, entityClasses: Readonly<Record<string, GameEntityType>>, options?: SageOptions): Promise<GameEngine>;
19
18
  export * from "./interfaces/game.d.ts";
20
- export * from "./interfaces/input.d.ts";
21
19
  export * from "./interfaces/logger.d.ts";
22
20
  export { AssetManager, AudioEngine, GameEngine, GameEventBus, SceneEngine };
21
+ export type { SimulationFactory } from "./classes/gameEngine.d.ts";
23
22
  export * from "./classes/eventBus.d.ts";
24
- export * from "./classes/entity.d.ts";
25
23
  export * from "./classes/level.d.ts";
26
24
  export * from "./classes/gameLevel.d.ts";
27
- export * from "./behaviors/index.d.ts";
28
25
  export * from "./events/index.d.ts";
29
26
  export * from "./handlers/index.d.ts";
30
27
  export * from "./interfaces/level.d.ts";
@@ -33,20 +30,53 @@ export * from "./utils/logger.d.ts";
33
30
  export * from "./utils/metadata.d.ts";
34
31
  export * from "./utils/timer.d.ts";
35
32
  export * from "./utils/version.d.ts";
33
+ export { Behavior, GameEntity, GameSimulationManager } from '@skewedaspect/sage-core';
34
+ export type { BehaviorClass, ComposedOf, EventMap, EventSubscription, GameEntityState, GameEntityType, GameEvent as GameEntityEvent, GameSimulationContext, GameSimulationOptions, GameSimulationSnapshot, NarrowedTo, OpsFor, StateBag, StateFor, } from '@skewedaspect/sage-core';
35
+ export { NodeEntity } from "./entities/nodeEntity.d.ts";
36
+ export type { NodeEntityState, QuaternionState, Vector3State } from "./entities/nodeEntity.d.ts";
37
+ export { NodePool } from "./entities/nodePool.d.ts";
38
+ export { NodeSimulation } from "./entities/nodeSimulation.d.ts";
39
+ export type { NodeSimulationOptions } from "./entities/nodeSimulation.d.ts";
40
+ export type { MeshLoader, NodeSet, NodeSimulationContext } from "./entities/nodeSimulationContext.d.ts";
41
+ export type { EntityPickFilter, EntityPickResult } from "./entities/entityPicking.d.ts";
42
+ export { defineEntity } from "./entities/defineEntity.d.ts";
43
+ export type { GameEntityDefinition, GameEntityDefinitionClass } from "./entities/defineEntity.d.ts";
44
+ export { buildStandardMeshSource } from "./entities/standardMeshSource.d.ts";
45
+ export type { MeshAssetSource } from "./entities/standardMeshSource.d.ts";
46
+ export type { MeshConfig, MeshMaterialConfig } from "./entities/meshConfig.d.ts";
47
+ export { ActionRegistry } from "./input/actionRegistry.d.ts";
48
+ export { ActionContextRegistry } from "./input/actionContext.d.ts";
49
+ export type { Binding, BindingDefinition, BindingFire, BindingInput, BindingKind, DeviceID, DeviceType, } from "./input/binding.d.ts";
50
+ export type { DeviceReader } from "./input/deviceReader.d.ts";
51
+ export type { GamepadState, KeyboardState, MouseState } from "./input/deviceState.d.ts";
52
+ export { KeyboardReader } from "./input/deviceReaders/keyboard.d.ts";
53
+ export { MouseReader } from "./input/deviceReaders/mouse.d.ts";
54
+ export type { MouseSourceType } from "./input/deviceReaders/mouse.d.ts";
55
+ export { GamepadReader } from "./input/deviceReaders/gamepad.d.ts";
56
+ export type { GamepadSourceType } from "./input/deviceReaders/gamepad.d.ts";
57
+ export { TriggerBinding } from "./input/bindings/trigger.d.ts";
58
+ export type { EdgeMode, TriggerOptions } from "./input/bindings/trigger.d.ts";
59
+ export { ToggleBinding } from "./input/bindings/toggle.d.ts";
60
+ export type { ToggleOptions } from "./input/bindings/toggle.d.ts";
61
+ export { ValueBinding } from "./input/bindings/value.d.ts";
62
+ export type { ValueOptions } from "./input/bindings/value.d.ts";
63
+ export { resolveBinding } from "./input/resolveBinding.d.ts";
64
+ export { deliverAction } from "./input/deliverAction.d.ts";
65
+ export { InputCapture } from "./input/inputCapture.d.ts";
66
+ export type { CandidateInput, CaptureOptions } from "./input/inputCapture.d.ts";
67
+ export { exportConfiguration, importConfiguration } from "./input/configuration.d.ts";
68
+ export type { Configuration, ContextDefinition } from "./input/configuration.d.ts";
69
+ export type { Action, AnalogAction, DigitalAction } from '@skewedaspect/sage-core';
36
70
  export type { FrameCallback } from "./managers/game.d.ts";
37
- export type { CreateEntityOptions } from "./managers/entity.d.ts";
38
71
  export type { TransitionOptions } from "./managers/level.d.ts";
39
72
  export { AudioManager } from "./managers/audio.d.ts";
40
73
  export type { ChannelInfo } from "./managers/audio.d.ts";
41
74
  export { ColliderDebugManager } from "./managers/colliderDebug.d.ts";
42
75
  export type { ColliderDebugConfig } from "./managers/colliderDebug.d.ts";
43
76
  export { OutlineManager } from "./managers/outline.d.ts";
44
- export { SaveManager } from "./managers/save.d.ts";
45
- export type { SaveData, SerializedEntity } from "./managers/save.d.ts";
77
+ export { SimulationSaveManager } from "./managers/simulationSave.d.ts";
78
+ export type { BeforeSaveHook, LevelLoader, LoadResult, SaveEnvelope } from "./managers/simulationSave.d.ts";
46
79
  export { DebugConsole } from "./classes/debugConsole.d.ts";
47
- export { createEntityProxy } from "./utils/entityProxy.d.ts";
48
80
  export { generateId } from "./utils/id.d.ts";
49
- export { RaycastHelper } from "./utils/raycast.d.ts";
50
- export type { EntityPickResult, EntityPickFilter } from "./utils/raycast.d.ts";
51
81
  export { StateMachine } from "./utils/stateMachine.d.ts";
52
82
  export { getCanonicalTransform, toQuatObject, toQuaternion, toVec3Object, toVector3, } from "./utils/vectors.d.ts";