@skewedaspect/sage 0.9.6 → 0.10.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/behaviors/sound.d.ts +12 -127
- package/dist/classes/debugConsole.d.ts +1 -0
- package/dist/classes/gameEngine.d.ts +31 -46
- package/dist/classes/gameLevel.d.ts +21 -12
- package/dist/classes/level.d.ts +24 -29
- package/dist/entities/constants.d.ts +1 -0
- package/dist/entities/defineEntity.d.ts +17 -0
- package/dist/entities/entityPicking.d.ts +15 -0
- package/dist/entities/meshConfig.d.ts +14 -0
- package/dist/entities/nodeEntity.d.ts +43 -0
- package/dist/entities/nodePool.d.ts +8 -0
- package/dist/entities/nodeSimulation.d.ts +30 -0
- package/dist/entities/nodeSimulationContext.d.ts +17 -0
- package/dist/entities/standardMeshSource.d.ts +8 -0
- package/dist/events/payloads.d.ts +0 -42
- package/dist/events/types.d.ts +2 -23
- package/dist/input/actionContext.d.ts +13 -0
- package/dist/input/actionRegistry.d.ts +7 -0
- package/dist/input/binding.d.ts +33 -0
- package/dist/input/bindings/delta.d.ts +23 -0
- package/dist/input/bindings/toggle.d.ts +25 -0
- package/dist/input/bindings/trigger.d.ts +23 -0
- package/dist/input/bindings/value.d.ts +26 -0
- package/dist/input/configuration.d.ts +15 -0
- package/dist/input/deliverAction.d.ts +4 -0
- package/dist/input/deviceReader.d.ts +5 -0
- package/dist/input/deviceReaders/gamepad.d.ts +9 -0
- package/dist/input/deviceReaders/keyboard.d.ts +8 -0
- package/dist/input/deviceReaders/mouse.d.ts +9 -0
- package/dist/input/deviceState.d.ts +24 -0
- package/dist/input/inputCapture.d.ts +21 -0
- package/dist/input/resolveBinding.d.ts +4 -0
- package/dist/interfaces/game.d.ts +21 -5
- package/dist/interfaces/level.d.ts +21 -3
- package/dist/managers/asset.d.ts +17 -3
- package/dist/managers/game.d.ts +15 -5
- package/dist/managers/input.d.ts +31 -51
- package/dist/managers/level.d.ts +20 -4
- package/dist/managers/outline.d.ts +4 -4
- package/dist/managers/simulationSave.d.ts +38 -0
- package/dist/{postProcessingFrameGraph-CaMgQzR-.js → postProcessingFrameGraph-C3Og4kaS.js} +34 -26
- package/dist/postProcessingFrameGraph-C3Og4kaS.js.map +1 -0
- package/dist/sage.d.ts +54 -16
- package/dist/sage.es.js +1868 -2424
- package/dist/sage.es.js.map +1 -1
- package/dist/sage.umd.js +1 -1
- package/dist/sage.umd.js.map +1 -1
- package/dist/utils/bounds.d.ts +11 -0
- package/dist/utils/physics.d.ts +4 -1
- package/package.json +29 -66
- package/LICENSE +0 -21
- package/Readme.md +0 -73
- package/dist/behaviors/index.d.ts +0 -2
- package/dist/behaviors/stateMachine.d.ts +0 -76
- package/dist/classes/bindings/toggle.d.ts +0 -116
- package/dist/classes/bindings/trigger.d.ts +0 -81
- package/dist/classes/bindings/value.d.ts +0 -104
- package/dist/classes/entity.d.ts +0 -332
- package/dist/classes/input/gamepad.d.ts +0 -94
- package/dist/classes/input/keyboard.d.ts +0 -66
- package/dist/classes/input/mouse.d.ts +0 -91
- package/dist/classes/input/readers/gamepad.d.ts +0 -73
- package/dist/classes/input/readers/keyboard.d.ts +0 -56
- package/dist/classes/input/readers/mouse.d.ts +0 -41
- package/dist/interfaces/action.d.ts +0 -22
- package/dist/interfaces/binding.d.ts +0 -123
- package/dist/interfaces/entity.d.ts +0 -97
- package/dist/interfaces/input.d.ts +0 -180
- package/dist/managers/binding.d.ts +0 -233
- package/dist/managers/entity.d.ts +0 -264
- package/dist/managers/save.d.ts +0 -75
- package/dist/postProcessingFrameGraph-CaMgQzR-.js.map +0 -1
- package/dist/utils/entityProxy.d.ts +0 -2
- package/dist/utils/raycast.d.ts +0 -26
package/dist/managers/input.d.ts
CHANGED
|
@@ -1,54 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GameSimulationContext, Unsubscribe } from '@skewedaspect/sage-core';
|
|
2
2
|
import { Disposable } from "../interfaces/lifecycle.d.ts";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*/
|
|
34
|
-
private _publishInputChanged;
|
|
35
|
-
/**
|
|
36
|
-
* Tears down the input manager and clean up event listeners
|
|
37
|
-
*/
|
|
3
|
+
import { Binding, DeviceType } from "../input/binding.d.ts";
|
|
4
|
+
import { InputCapture } from "../input/inputCapture.d.ts";
|
|
5
|
+
import { GamepadState, KeyboardState, MouseState } from "../input/deviceState.d.ts";
|
|
6
|
+
import { ActionContextRegistry } from "../input/actionContext.d.ts";
|
|
7
|
+
import { ActionRegistry } from "../input/actionRegistry.d.ts";
|
|
8
|
+
declare module '@skewedaspect/sage-core' {
|
|
9
|
+
interface EventMap {
|
|
10
|
+
'input:deviceChanged': DeviceChangedPayload;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export interface DeviceChangedPayload {
|
|
14
|
+
deviceType: DeviceType;
|
|
15
|
+
/** Undefined for the first deliberate input of a session, which replaces no device type. */
|
|
16
|
+
previousDeviceType: DeviceType | undefined;
|
|
17
|
+
}
|
|
18
|
+
export declare const ROUTING_LOOP_SENDER_ID = "sage-input";
|
|
19
|
+
export declare const DELIBERATE_THRESHOLD = 0.2;
|
|
20
|
+
export declare const MOVEMENT_THRESHOLD = 2;
|
|
21
|
+
export declare class InputManager implements Disposable {
|
|
22
|
+
#private;
|
|
23
|
+
readonly actions: ActionRegistry;
|
|
24
|
+
readonly contexts: ActionContextRegistry;
|
|
25
|
+
constructor();
|
|
26
|
+
get lastActiveDeviceType(): DeviceType | undefined;
|
|
27
|
+
deviceState(type: 'keyboard', index: number): KeyboardState;
|
|
28
|
+
deviceState(type: 'mouse', index: number): MouseState;
|
|
29
|
+
deviceState(type: 'gamepad', index: number): GamepadState;
|
|
30
|
+
registerCapture(capture: InputCapture): Unsubscribe;
|
|
31
|
+
getBindingsForAction(action: string, deviceType?: DeviceType, context?: string): readonly Binding<unknown>[];
|
|
32
|
+
routeCapturedInput(context: GameSimulationContext): void;
|
|
38
33
|
$teardown(): Promise<void>;
|
|
39
|
-
/**
|
|
40
|
-
* Get all connected input devices (keyboard, mouse, and any gamepads).
|
|
41
|
-
*/
|
|
42
|
-
listDevices(): InputDevice[];
|
|
43
|
-
/**
|
|
44
|
-
* Get a specific input device by ID.
|
|
45
|
-
* Uses device ID prefix (keyboard-, mouse-, gamepad-) for fast lookup.
|
|
46
|
-
*
|
|
47
|
-
* @param deviceId
|
|
48
|
-
*/
|
|
49
|
-
getDevice(deviceId: string): InputDevice | null;
|
|
50
|
-
/**
|
|
51
|
-
* Poll for gamepad state updates - call this in your game loop
|
|
52
|
-
*/
|
|
53
|
-
pollGamepads(): void;
|
|
54
34
|
}
|
package/dist/managers/level.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
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";
|
|
5
5
|
import { GameEngine } from "../classes/gameEngine.d.ts";
|
|
6
|
+
import { NodeSimulation } from "../entities/nodeSimulation.d.ts";
|
|
6
7
|
import { LoggingUtility } from "../utils/logger.d.ts";
|
|
7
8
|
/**
|
|
8
9
|
* Options for level transitions.
|
|
9
10
|
*/
|
|
10
|
-
export interface TransitionOptions {
|
|
11
|
+
export interface TransitionOptions extends LevelLoadOptions {
|
|
11
12
|
/** If true, the old level is kept loaded (not disposed) after transitioning away */
|
|
12
13
|
keepAlive?: boolean;
|
|
13
14
|
/** If true, the new level is loaded but not activated — currentLevel remains unchanged */
|
|
@@ -137,14 +138,29 @@ export declare class LevelManager implements Disposable {
|
|
|
137
138
|
* Loads a level by name. The level config must be registered first.
|
|
138
139
|
*
|
|
139
140
|
* @param name
|
|
141
|
+
* @param options
|
|
140
142
|
*/
|
|
141
|
-
loadLevel(name: string): Promise<Level>;
|
|
143
|
+
loadLevel(name: string, options?: LevelLoadOptions): Promise<Level>;
|
|
142
144
|
/**
|
|
143
145
|
* Loads a level from a config. The config will be registered automatically.
|
|
144
146
|
*
|
|
145
147
|
* @param config
|
|
148
|
+
* @param options
|
|
149
|
+
*/
|
|
150
|
+
loadLevel(config: LevelConfig, options?: LevelLoadOptions): Promise<Level>;
|
|
151
|
+
/**
|
|
152
|
+
* Bind the engine to a level's own simulation. A level that built none leaves the engine as it is.
|
|
153
|
+
*
|
|
154
|
+
* @param level
|
|
155
|
+
*/
|
|
156
|
+
private _bindSimulation;
|
|
157
|
+
/**
|
|
158
|
+
* Hand the current level a simulation built to replace its own, and bind the engine to it. A save load
|
|
159
|
+
* restores into a fresh simulation, and the level that owns the scene has to follow it.
|
|
160
|
+
*
|
|
161
|
+
* @param simulation
|
|
146
162
|
*/
|
|
147
|
-
|
|
163
|
+
$bindSimulation(simulation: NodeSimulation): void;
|
|
148
164
|
/**
|
|
149
165
|
* Activates a level by name, loading it if necessary.
|
|
150
166
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Scene, SelectionOutlineLayer } from '@babylonjs/core';
|
|
2
|
-
import {
|
|
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:
|
|
11
|
-
unhighlightEntity(layerName: string, entity:
|
|
12
|
-
unhighlightEntityAll(entity:
|
|
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,38 @@
|
|
|
1
|
+
import { GameSimulationManager, GameSimulationSnapshot } from '@skewedaspect/sage-core';
|
|
2
|
+
import { GameEngine } from "../classes/gameEngine.d.ts";
|
|
3
|
+
import { NodeSimulation } from "../entities/nodeSimulation.d.ts";
|
|
4
|
+
import { Disposable } from "../interfaces/lifecycle.d.ts";
|
|
5
|
+
import { LevelLoadOptions } from "../interfaces/level.d.ts";
|
|
6
|
+
export interface LevelLoader {
|
|
7
|
+
readonly currentLevel: {
|
|
8
|
+
name: string;
|
|
9
|
+
} | null;
|
|
10
|
+
transition(levelName: string, options?: LevelLoadOptions): Promise<void>;
|
|
11
|
+
$bindSimulation(simulation: NodeSimulation): void;
|
|
12
|
+
}
|
|
13
|
+
export interface SaveEnvelope {
|
|
14
|
+
saveFormatVersion: number;
|
|
15
|
+
engineVersion: string;
|
|
16
|
+
level: string;
|
|
17
|
+
timestamp: number;
|
|
18
|
+
custom: Record<string, unknown>;
|
|
19
|
+
snapshot: GameSimulationSnapshot;
|
|
20
|
+
}
|
|
21
|
+
export type BeforeSaveHook = () => Record<string, unknown>;
|
|
22
|
+
export interface LoadResult {
|
|
23
|
+
simulation: NodeSimulation;
|
|
24
|
+
envelope: SaveEnvelope;
|
|
25
|
+
}
|
|
26
|
+
export declare class SimulationSaveManager implements Disposable {
|
|
27
|
+
#private;
|
|
28
|
+
constructor(levelLoader: LevelLoader, engineVersion: string, now?: () => number);
|
|
29
|
+
/**
|
|
30
|
+
* Late-bind the GameEngine after construction. Called by createGameEngine() after the GameEngine
|
|
31
|
+
* instance is created; load() needs it to reach the simulation a transition just rebuilt.
|
|
32
|
+
*/
|
|
33
|
+
$setGameEngine(gameEngine: GameEngine): void;
|
|
34
|
+
onBeforeSave(hook: BeforeSaveHook): void;
|
|
35
|
+
save(simulation: GameSimulationManager): SaveEnvelope;
|
|
36
|
+
load(envelope: SaveEnvelope): Promise<LoadResult>;
|
|
37
|
+
$teardown(): Promise<void>;
|
|
38
|
+
}
|
|
@@ -10,61 +10,69 @@ var p = {
|
|
|
10
10
|
async function m(m, h) {
|
|
11
11
|
let g = m.activeCamera;
|
|
12
12
|
if (!g) return;
|
|
13
|
-
let _ = m.getEngine(), v = new t(m)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
let _ = m.getEngine(), v = new t(m);
|
|
14
|
+
function y(e, t) {
|
|
15
|
+
return v.textureManager.createRenderTargetTexture(e, {
|
|
16
|
+
size: {
|
|
17
|
+
width: 100,
|
|
18
|
+
height: 100
|
|
19
|
+
},
|
|
20
|
+
sizeIsPercentage: !0,
|
|
21
|
+
options: {
|
|
22
|
+
formats: [t],
|
|
23
|
+
samples: 4
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
let b = y("sage-fg-color", e.TEXTUREFORMAT_RGBA), x = y("sage-fg-depth", e.TEXTUREFORMAT_DEPTH24_STENCIL8), S = new i("sage-clear", v);
|
|
28
|
+
S.targetTexture = b, S.depthTexture = x, S.clearDepth = !0, S.clearStencil = !0, v.addTask(S);
|
|
29
|
+
let C = new l("sage-render", v, m);
|
|
30
|
+
C.targetTexture = S.outputTexture, C.depthTexture = S.outputDepthTexture, C.camera = g, C.objectList = {
|
|
27
31
|
meshes: m.meshes,
|
|
28
32
|
particleSystems: m.particleSystems
|
|
29
|
-
},
|
|
30
|
-
let
|
|
33
|
+
}, C.isMainObjectRenderer = !0, v.addTask(C);
|
|
34
|
+
let w = C.outputTexture;
|
|
31
35
|
if (h.ssao) {
|
|
32
36
|
let e = new o("sage-geometry", v, m);
|
|
33
37
|
v.addTask(e);
|
|
34
38
|
let t = new u("sage-ssao", v, .5, 1);
|
|
35
|
-
t.sourceTexture =
|
|
39
|
+
t.sourceTexture = w, t.depthTexture = e.geometryViewDepthTexture, t.normalTexture = e.geometryViewNormalTexture, t.camera = g, v.addTask(t), h.ssao.radius !== void 0 && (t.ssao.radius = h.ssao.radius), h.ssao.samples !== void 0 && (t.ssao.samples = h.ssao.samples), h.ssao.totalStrength !== void 0 && (t.ssao.totalStrength = h.ssao.totalStrength), w = t.outputTexture;
|
|
36
40
|
}
|
|
37
41
|
if (h.bloom) {
|
|
38
42
|
let e = new n("sage-bloom", v, h.bloom.weight ?? .5, h.bloom.kernel ?? 128, h.bloom.threshold ?? .1, !0, h.bloom.scale ?? .5);
|
|
39
|
-
e.sourceTexture =
|
|
43
|
+
e.sourceTexture = w, v.addTask(e), w = e.outputTexture;
|
|
40
44
|
}
|
|
41
45
|
if (h.grain) {
|
|
42
46
|
let e = new s("sage-grain", v);
|
|
43
|
-
e.sourceTexture =
|
|
47
|
+
e.sourceTexture = w, v.addTask(e), h.grain.intensity !== void 0 && (e.postProcess.intensity = h.grain.intensity), h.grain.animated !== void 0 && (e.postProcess.animated = h.grain.animated), w = e.outputTexture;
|
|
44
48
|
}
|
|
45
49
|
if (h.sharpen) {
|
|
46
50
|
let e = new d("sage-sharpen", v);
|
|
47
|
-
e.sourceTexture =
|
|
51
|
+
e.sourceTexture = w, v.addTask(e), h.sharpen.edge !== void 0 && (e.postProcess.edgeAmount = h.sharpen.edge), h.sharpen.color !== void 0 && (e.postProcess.colorAmount = h.sharpen.color), w = e.outputTexture;
|
|
48
52
|
}
|
|
49
53
|
if (h.chromaticAberration) {
|
|
50
54
|
let e = new r("sage-chromab", v);
|
|
51
|
-
e.sourceTexture =
|
|
55
|
+
e.sourceTexture = w, v.addTask(e), h.chromaticAberration.amount !== void 0 && (e.postProcess.aberrationAmount = h.chromaticAberration.amount), w = e.outputTexture;
|
|
52
56
|
}
|
|
53
57
|
if (h.tonemap || h.vignette) {
|
|
54
58
|
let e = new c("sage-imgproc", v);
|
|
55
|
-
if (e.sourceTexture =
|
|
59
|
+
if (e.sourceTexture = w, v.addTask(e), h.tonemap && (e.postProcess.toneMappingEnabled = !0, h.tonemap.operator && (e.postProcess.toneMappingType = p[h.tonemap.operator] ?? f.TONEMAPPING_STANDARD)), h.vignette && (e.postProcess.vignetteEnabled = !0, h.vignette.weight !== void 0 && (e.postProcess.vignetteWeight = h.vignette.weight), h.vignette.stretch !== void 0 && (e.postProcess.vignetteStretch = h.vignette.stretch), h.vignette.color)) {
|
|
56
60
|
let t = h.vignette.color;
|
|
57
61
|
e.postProcess.vignetteColor.set(t.r, t.g, t.b, 1);
|
|
58
62
|
}
|
|
59
|
-
|
|
63
|
+
w = e.outputTexture;
|
|
60
64
|
}
|
|
61
65
|
h.volumetric && console.warn("[SAGE] Volumetric lighting config is recognized but automatic light detection is not yet supported. Use scene.frameGraph to add FrameGraphVolumetricLightingTask manually.");
|
|
62
|
-
let
|
|
63
|
-
|
|
66
|
+
let T = new a("sage-output", v);
|
|
67
|
+
T.sourceTexture = w, v.addTask(T), m.cameraToUseForPointers = g, m.frameGraph = v;
|
|
68
|
+
let E = _.onResizeObservable.add(async () => {
|
|
64
69
|
await v.buildAsync();
|
|
70
|
+
});
|
|
71
|
+
m.onDisposeObservable.addOnce(() => {
|
|
72
|
+
_.onResizeObservable.remove(E);
|
|
65
73
|
}), await v.buildAsync();
|
|
66
74
|
}
|
|
67
75
|
//#endregion
|
|
68
76
|
export { m as applyFrameGraphPostProcessing };
|
|
69
77
|
|
|
70
|
-
//# sourceMappingURL=postProcessingFrameGraph-
|
|
78
|
+
//# sourceMappingURL=postProcessingFrameGraph-C3Og4kaS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postProcessingFrameGraph-C3Og4kaS.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 // The color target and its depth attachment differ only in format: the object renderer checks that\n // their size and sample count agree when the graph builds.\n function createTarget(name : string, format : number) : FrameGraphTextureHandle\n {\n return fg.textureManager.createRenderTargetTexture(name, {\n size: { width: 100, height: 100 },\n sizeIsPercentage: true,\n options: { formats: [ format ], samples: 4 },\n });\n }\n\n const colorTexture = createTarget('sage-fg-color', Constants.TEXTUREFORMAT_RGBA);\n const depthTexture = createTarget('sage-fg-depth', Constants.TEXTUREFORMAT_DEPTH24_STENCIL8);\n\n // 1. Clear. The clear task resolves its outputDepthTexture handle only when it is given a depth texture\n // to clear; the object renderer below reads that handle, and an unresolved one has no texture behind it.\n const clearTask = new FrameGraphClearTextureTask('sage-clear', fg);\n clearTask.targetTexture = colorTexture;\n clearTask.depthTexture = depthTexture;\n clearTask.clearDepth = true;\n clearTask.clearStencil = true;\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. The scene disposes the graph with itself, and the engine outlives both, so the\n // observer goes with the scene rather than rebuilding a disposed graph for the engine's lifetime.\n const resizeObserver = engine.onResizeObservable.add(async () =>\n {\n await fg.buildAsync();\n });\n\n scene.onDisposeObservable.addOnce(() =>\n {\n engine.onResizeObservable.remove(resizeObserver);\n });\n\n // Initial build\n await fg.buildAsync();\n}\n\n//----------------------------------------------------------------------------------------------------------------------\n"],"mappings":";;AAiCA,IAAM,IAA6C;CAC/C,OAAO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B,EAAU;CAC/B;CAGA,IAAG,EAAO,WAAW,EAAO,UAC5B;EACI,IAAM,IAAU,IAAI,EAA8B,gBAAgB,CAAE;EAgBpE,IAfA,EAAQ,gBAAgB,GACxB,EAAG,QAAQ,CAAO,GAEf,EAAO,YAEN,EAAQ,YAAY,qBAAqB,IAEtC,EAAO,QAAQ,aAEd,EAAQ,YAAY,kBACd,EAAkB,EAAO,QAAQ,aAChC,EAA6B,wBAIzC,EAAO,aAEN,EAAQ,YAAY,kBAAkB,IAEnC,EAAO,SAAS,WAAW,KAAA,MAAa,EAAQ,YAAY,iBAAiB,EAAO,SAAS,SAC7F,EAAO,SAAS,YAAY,KAAA,MAE3B,EAAQ,YAAY,kBAAkB,EAAO,SAAS,UAEvD,EAAO,SAAS,QACnB;GACI,IAAM,IAAK,EAAO,SAAS;GAC3B,EAAQ,YAAY,cAAc,IAAI,EAAG,GAAG,EAAG,GAAG,EAAG,GAAG,CAAC;EAC7D;EAGJ,IAAiB,EAAQ;CAC7B;CAGA,AAAG,EAAO,cAEN,QAAQ,KACJ,4KAEJ;CAIJ,IAAM,IAAW,IAAI,EAAoC,eAAe,CAAE;CAM1E,AALA,EAAS,gBAAgB,GACzB,EAAG,QAAQ,CAAQ,GAGnB,EAAM,yBAAyB,GAC/B,EAAM,aAAa;CAInB,IAAM,IAAiB,EAAO,mBAAmB,IAAI,YACrD;EACI,MAAM,EAAG,WAAW;CACxB,CAAC;CAQD,AANA,EAAM,oBAAoB,cAC1B;EACI,EAAO,mBAAmB,OAAO,CAAc;CACnD,CAAC,GAGD,MAAM,EAAG,WAAW;AACxB"}
|
package/dist/sage.d.ts
CHANGED
|
@@ -1,30 +1,28 @@
|
|
|
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,
|
|
9
|
+
* Creates and initializes a fully-wired GameEngine with rendering, physics, and entity management. The
|
|
10
|
+
* engine owns one InputManager (`engine.managers.inputManager`): its action registry, its action context
|
|
11
|
+
* registry, device state capture, and the routing loop that runs before each frame's fixed steps
|
|
12
|
+
* (docs/design/input.md). A game declares its own actions, contexts, and bindings onto it.
|
|
10
13
|
*
|
|
11
14
|
* @param canvas
|
|
12
|
-
* @param
|
|
15
|
+
* @param entityClasses - The entity class table, keyed by class name, that the simulation spawns from
|
|
13
16
|
* @param options
|
|
14
17
|
*/
|
|
15
|
-
export declare function createGameEngine(canvas: GameCanvas,
|
|
16
|
-
export * from "./interfaces/action.d.ts";
|
|
17
|
-
export * from "./interfaces/binding.d.ts";
|
|
18
|
-
export * from "./interfaces/entity.d.ts";
|
|
18
|
+
export declare function createGameEngine(canvas: GameCanvas, entityClasses: Readonly<Record<string, GameEntityType>>, options?: SageOptions): Promise<GameEngine>;
|
|
19
19
|
export * from "./interfaces/game.d.ts";
|
|
20
|
-
export * from "./interfaces/input.d.ts";
|
|
21
20
|
export * from "./interfaces/logger.d.ts";
|
|
22
21
|
export { AssetManager, AudioEngine, GameEngine, GameEventBus, SceneEngine };
|
|
22
|
+
export type { SimulationFactory } from "./classes/gameEngine.d.ts";
|
|
23
23
|
export * from "./classes/eventBus.d.ts";
|
|
24
|
-
export * from "./classes/entity.d.ts";
|
|
25
24
|
export * from "./classes/level.d.ts";
|
|
26
25
|
export * from "./classes/gameLevel.d.ts";
|
|
27
|
-
export * from "./behaviors/index.d.ts";
|
|
28
26
|
export * from "./events/index.d.ts";
|
|
29
27
|
export * from "./handlers/index.d.ts";
|
|
30
28
|
export * from "./interfaces/level.d.ts";
|
|
@@ -33,20 +31,60 @@ export * from "./utils/logger.d.ts";
|
|
|
33
31
|
export * from "./utils/metadata.d.ts";
|
|
34
32
|
export * from "./utils/timer.d.ts";
|
|
35
33
|
export * from "./utils/version.d.ts";
|
|
34
|
+
export { Behavior, EventBus, GameEntity, GameSimulationManager, NamedBehavior, StateMachineBehavior, defineStates, dilationLimit, drainPassLimit, operationCallDepthLimit, } from '@skewedaspect/sage-core';
|
|
35
|
+
export type { BehaviorClass, ComposedOf, DeepReadonly, EventMap, EventSubscription, GameEntityState, GameEntityType, GameEvent as GameEntityEvent, GameSimulationContext, GameSimulationOptions, GameSimulationSnapshot, NamedState, NarrowedTo, OpsFor, OpsOf, StateBag, StateFor, StateSliceOf, } from '@skewedaspect/sage-core';
|
|
36
|
+
export { NodeEntity } from "./entities/nodeEntity.d.ts";
|
|
37
|
+
export type { NodeEntityState, QuaternionState, Vector3State } from "./entities/nodeEntity.d.ts";
|
|
38
|
+
export { NodePool } from "./entities/nodePool.d.ts";
|
|
39
|
+
export { NodeSimulation } from "./entities/nodeSimulation.d.ts";
|
|
40
|
+
export type { NodeSimulationOptions } from "./entities/nodeSimulation.d.ts";
|
|
41
|
+
export type { MeshLoader, NodeSet, NodeSimulationContext } from "./entities/nodeSimulationContext.d.ts";
|
|
42
|
+
export type { EntityPickFilter, EntityPickResult } from "./entities/entityPicking.d.ts";
|
|
43
|
+
export { defineEntity } from "./entities/defineEntity.d.ts";
|
|
44
|
+
export type { GameEntityDefinition, GameEntityDefinitionClass } from "./entities/defineEntity.d.ts";
|
|
45
|
+
export { buildStandardMeshSource } from "./entities/standardMeshSource.d.ts";
|
|
46
|
+
export type { MeshAssetSource } from "./entities/standardMeshSource.d.ts";
|
|
47
|
+
export type { MeshConfig, MeshMaterialConfig } from "./entities/meshConfig.d.ts";
|
|
48
|
+
export { SoundBehavior } from "./behaviors/sound.d.ts";
|
|
49
|
+
export type { SoundConfig, SoundState } from "./behaviors/sound.d.ts";
|
|
50
|
+
export { ActionRegistry } from "./input/actionRegistry.d.ts";
|
|
51
|
+
export { ActionContextRegistry } from "./input/actionContext.d.ts";
|
|
52
|
+
export type { Binding, BindingDefinition, BindingFire, BindingInput, BindingKind, DeviceID, DeviceType, } from "./input/binding.d.ts";
|
|
53
|
+
export type { DeviceReader } from "./input/deviceReader.d.ts";
|
|
54
|
+
export type { GamepadState, KeyboardState, MouseState } from "./input/deviceState.d.ts";
|
|
55
|
+
export { KeyboardReader } from "./input/deviceReaders/keyboard.d.ts";
|
|
56
|
+
export { MouseReader } from "./input/deviceReaders/mouse.d.ts";
|
|
57
|
+
export type { MouseSourceType } from "./input/deviceReaders/mouse.d.ts";
|
|
58
|
+
export { GamepadReader } from "./input/deviceReaders/gamepad.d.ts";
|
|
59
|
+
export type { GamepadSourceType } from "./input/deviceReaders/gamepad.d.ts";
|
|
60
|
+
export { TriggerBinding } from "./input/bindings/trigger.d.ts";
|
|
61
|
+
export type { EdgeMode, TriggerOptions } from "./input/bindings/trigger.d.ts";
|
|
62
|
+
export { ToggleBinding } from "./input/bindings/toggle.d.ts";
|
|
63
|
+
export type { ToggleOptions } from "./input/bindings/toggle.d.ts";
|
|
64
|
+
export { ValueBinding } from "./input/bindings/value.d.ts";
|
|
65
|
+
export type { ValueOptions } from "./input/bindings/value.d.ts";
|
|
66
|
+
export { DeltaBinding } from "./input/bindings/delta.d.ts";
|
|
67
|
+
export type { DeltaOptions } from "./input/bindings/delta.d.ts";
|
|
68
|
+
export { resolveBinding } from "./input/resolveBinding.d.ts";
|
|
69
|
+
export { deliverAction } from "./input/deliverAction.d.ts";
|
|
70
|
+
export { InputCapture } from "./input/inputCapture.d.ts";
|
|
71
|
+
export type { CandidateInput, CaptureOptions } from "./input/inputCapture.d.ts";
|
|
72
|
+
export { exportConfiguration, importConfiguration } from "./input/configuration.d.ts";
|
|
73
|
+
export type { Configuration, ContextDefinition } from "./input/configuration.d.ts";
|
|
74
|
+
export type { Action, AnalogAction, DigitalAction } from '@skewedaspect/sage-core';
|
|
36
75
|
export type { FrameCallback } from "./managers/game.d.ts";
|
|
37
|
-
export
|
|
76
|
+
export { InputManager, ROUTING_LOOP_SENDER_ID } from "./managers/input.d.ts";
|
|
38
77
|
export type { TransitionOptions } from "./managers/level.d.ts";
|
|
39
78
|
export { AudioManager } from "./managers/audio.d.ts";
|
|
40
79
|
export type { ChannelInfo } from "./managers/audio.d.ts";
|
|
41
80
|
export { ColliderDebugManager } from "./managers/colliderDebug.d.ts";
|
|
42
81
|
export type { ColliderDebugConfig } from "./managers/colliderDebug.d.ts";
|
|
43
82
|
export { OutlineManager } from "./managers/outline.d.ts";
|
|
44
|
-
export {
|
|
45
|
-
export type {
|
|
83
|
+
export { SimulationSaveManager } from "./managers/simulationSave.d.ts";
|
|
84
|
+
export type { BeforeSaveHook, LevelLoader, LoadResult, SaveEnvelope } from "./managers/simulationSave.d.ts";
|
|
46
85
|
export { DebugConsole } from "./classes/debugConsole.d.ts";
|
|
47
|
-
export {
|
|
86
|
+
export { computeHierarchyBounds } from "./utils/bounds.d.ts";
|
|
87
|
+
export type { HierarchyBounds } from "./utils/bounds.d.ts";
|
|
48
88
|
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
89
|
export { StateMachine } from "./utils/stateMachine.d.ts";
|
|
52
90
|
export { getCanonicalTransform, toQuatObject, toQuaternion, toVec3Object, toVector3, } from "./utils/vectors.d.ts";
|