@skewedaspect/sage 0.10.1 → 0.11.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/dist/classes/gameEngine.d.ts +7 -2
- package/dist/interfaces/level.d.ts +2 -0
- package/dist/managers/asset.d.ts +16 -1
- package/dist/sage.d.ts +1 -1
- package/dist/sage.es.js +163 -118
- package/dist/sage.es.js.map +1 -1
- package/package.json +2 -2
|
@@ -20,8 +20,13 @@ import { GameTimer } from "../utils/timer.js";
|
|
|
20
20
|
* Type definition for game lifecycle hook functions
|
|
21
21
|
*/
|
|
22
22
|
export type GameHook<Registry extends NodeEntityRegistry = NodeEntityRegistry> = (gameEngine: GameEngine<Registry>) => Promise<void>;
|
|
23
|
+
/** What a simulation is built with beside its scene and its name (design/architecture.md#how-a-game-consumes-sage). */
|
|
24
|
+
export interface RebuildSimulationOptions {
|
|
25
|
+
meshSource?: MeshLoader;
|
|
26
|
+
fixedStepDuration?: number;
|
|
27
|
+
}
|
|
23
28
|
/** Builds a NodeSimulation named and bound to a scene and a mesh source -- a fresh one for every level that loads. */
|
|
24
|
-
export type SimulationFactory<Registry extends NodeEntityRegistry = NodeEntityRegistry> = (scene: Scene, name: string,
|
|
29
|
+
export type SimulationFactory<Registry extends NodeEntityRegistry = NodeEntityRegistry> = (scene: Scene, name: string, options?: RebuildSimulationOptions) => NodeSimulation<Registry>;
|
|
25
30
|
/**
|
|
26
31
|
* Interface representing the engines used in the game.
|
|
27
32
|
* All engines must implement Disposable for proper cleanup.
|
|
@@ -82,7 +87,7 @@ export declare class GameEngine<Registry extends NodeEntityRegistry = NodeEntity
|
|
|
82
87
|
* NodeEntity it spawns gets a node in that scene and loads its mesh through that source; left unset, a spawned
|
|
83
88
|
* entity gets a node with no mesh (design/simulation.md#the-simulations-name).
|
|
84
89
|
*/
|
|
85
|
-
rebuildSimulation(scene: Scene, name: string,
|
|
90
|
+
rebuildSimulation(scene: Scene, name: string, options?: RebuildSimulationOptions): NodeSimulation<Registry>;
|
|
86
91
|
/**
|
|
87
92
|
* Binds the engine to a simulation, or to none. The one bound before detaches from the bus and the new one
|
|
88
93
|
* attaches, carrying its entities' subscriptions and held emissions across
|
|
@@ -96,6 +96,8 @@ export interface LevelConfig {
|
|
|
96
96
|
* entity this level spawns gets a node with no mesh.
|
|
97
97
|
*/
|
|
98
98
|
meshSource?: MeshLoader;
|
|
99
|
+
/** The fixed-step duration, in seconds, of the simulation this level builds. Left unset, the engine's. */
|
|
100
|
+
fixedStepDuration?: number;
|
|
99
101
|
/** Scene file path, or configuration object with path and options */
|
|
100
102
|
scene?: string | SceneConfig;
|
|
101
103
|
/** Name of a registered custom Level class to use instead of GameLevel */
|
package/dist/managers/asset.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Mesh, AbstractMesh, AssetContainer, InstancedMesh, Scene } from '@babylonjs/core';
|
|
1
|
+
import { Mesh, AbstractMesh, AssetContainer, InstancedMesh, InstantiatedEntries, Scene } from '@babylonjs/core';
|
|
2
2
|
import { EventBus } from '@skewedaspect/sage-core';
|
|
3
3
|
import { SceneEngine } from "../engines/scene.js";
|
|
4
4
|
import { Disposable } from "../interfaces/lifecycle.js";
|
|
@@ -19,6 +19,11 @@ export declare class AssetManager implements Disposable {
|
|
|
19
19
|
private _sourceMeshes;
|
|
20
20
|
/** Container loads still in flight, keyed by base path, so concurrent callers share one load */
|
|
21
21
|
private _pendingContainers;
|
|
22
|
+
/**
|
|
23
|
+
* Containers `instantiate` read for a caller's scene, keyed by that scene and then by base path. Each one is
|
|
24
|
+
* the scene's: Babylon disposes it with the scene, and a scene no one holds takes its entry with it.
|
|
25
|
+
*/
|
|
26
|
+
private _sceneContainers;
|
|
22
27
|
constructor(bus: EventBus, sceneEngine: SceneEngine, logger?: LoggingUtility);
|
|
23
28
|
/**
|
|
24
29
|
* Split a path on `#` into base path and optional fragment name.
|
|
@@ -39,6 +44,11 @@ export declare class AssetManager implements Disposable {
|
|
|
39
44
|
* (design/engine.md#the-asset-manager).
|
|
40
45
|
*/
|
|
41
46
|
private _fetchContainer;
|
|
47
|
+
/**
|
|
48
|
+
* The container for a base path read into the given scene, reading it on the first call. Calls made while
|
|
49
|
+
* the read is in flight share it. A read that fails is not remembered, so the next call reads again.
|
|
50
|
+
*/
|
|
51
|
+
private _containerForScene;
|
|
42
52
|
/**
|
|
43
53
|
* Find a mesh by name inside a container. Throws if not found.
|
|
44
54
|
*/
|
|
@@ -67,6 +77,11 @@ export declare class AssetManager implements Disposable {
|
|
|
67
77
|
* (design/engine.md#the-asset-manager).
|
|
68
78
|
*/
|
|
69
79
|
clone(path: string, into: Scene): Mesh;
|
|
80
|
+
/**
|
|
81
|
+
* Copies a whole file into the scene it is handed: every mesh and node, with the file's skeletons and animation
|
|
82
|
+
* groups. The meshes are cloned and share the container's materials. The copy is the caller's to dispose.
|
|
83
|
+
*/
|
|
84
|
+
instantiate(path: string, scene: Scene): Promise<InstantiatedEntries>;
|
|
70
85
|
/**
|
|
71
86
|
* Preload a batch of asset paths, up to `MAX_CONCURRENT_LOADS` at a time, so a batch costs about as
|
|
72
87
|
* long as its slowest asset rather than the sum of them all.
|
package/dist/sage.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare function createGameEngine<Registry extends NodeEntityRegistry = N
|
|
|
19
19
|
export * from "./interfaces/game.js";
|
|
20
20
|
export * from "./interfaces/logger.js";
|
|
21
21
|
export { AssetManager, AudioEngine, GameEngine, GameManager, LevelManager, SceneEngine };
|
|
22
|
-
export type { DebugTools, Engines, GameHook, Managers, SimulationFactory } from "./classes/gameEngine.js";
|
|
22
|
+
export type { DebugTools, Engines, GameHook, Managers, RebuildSimulationOptions, SimulationFactory, } from "./classes/gameEngine.js";
|
|
23
23
|
export * from "./classes/level.js";
|
|
24
24
|
export * from "./classes/gameLevel.js";
|
|
25
25
|
export type { AssetCompletePayload, AssetProgressPayload, GamePausedPayload, GameResumedPayload, LevelCompletePayload, LevelErrorPayload, LevelProgressPayload, LevelTransitionCompletePayload, LevelTransitionErrorPayload, LevelTransitionProgressPayload, LevelTransitionStartPayload, TriggerEnterPayload, TriggerExitPayload, } from "./events/payloads.js";
|