@skewedaspect/sage 0.9.2 → 0.9.3
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/debugConsole.d.ts +22 -0
- package/dist/classes/entity.d.ts +21 -0
- package/dist/classes/gameEngine.d.ts +12 -1
- package/dist/classes/gameLevel.d.ts +5 -0
- package/dist/debug/builtins.d.ts +6 -0
- package/dist/interfaces/entity.d.ts +3 -0
- package/dist/interfaces/game.d.ts +9 -0
- package/dist/interfaces/level.d.ts +5 -0
- package/dist/managers/colliderDebug.d.ts +16 -0
- package/dist/sage.d.ts +4 -0
- package/dist/sage.es.js +471 -207
- 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/entityProxy.d.ts +2 -0
- package/dist/utils/vectors.d.ts +8 -8
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Disposable } from "../interfaces/lifecycle.d.ts";
|
|
2
|
+
interface DynamicGetter {
|
|
3
|
+
get: () => unknown;
|
|
4
|
+
}
|
|
5
|
+
export declare class DebugConsole implements Disposable {
|
|
6
|
+
private _namespaceName;
|
|
7
|
+
private _entries;
|
|
8
|
+
private _disposed;
|
|
9
|
+
constructor(namespaceName?: string);
|
|
10
|
+
expose(name: string, value: unknown | DynamicGetter): void;
|
|
11
|
+
setNamespace(name: string): void;
|
|
12
|
+
get namespaceName(): string;
|
|
13
|
+
dispose(): void;
|
|
14
|
+
$teardown(): Promise<void>;
|
|
15
|
+
private _isDynamicGetter;
|
|
16
|
+
private _getNamespace;
|
|
17
|
+
private _installNamespace;
|
|
18
|
+
private _removeNamespace;
|
|
19
|
+
private _defineGetter;
|
|
20
|
+
private _defineValue;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
package/dist/classes/entity.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TransformNode } from '@babylonjs/core';
|
|
2
2
|
import { GameEntityBehaviorConstructor } from "../interfaces/entity.d.ts";
|
|
3
3
|
import { Destroyable } from "../interfaces/lifecycle.d.ts";
|
|
4
|
+
import { ColliderDebugConfig } from "../managers/colliderDebug.d.ts";
|
|
4
5
|
import { GameEvent, GameEventBus } from "./eventBus.d.ts";
|
|
5
6
|
import { GameEngine } from "./gameEngine.d.ts";
|
|
6
7
|
/**
|
|
@@ -201,6 +202,26 @@ export declare class GameEntity<EntityState extends object = object> implements
|
|
|
201
202
|
* @param layerName - Specific layer to remove from, or omit to remove from all
|
|
202
203
|
*/
|
|
203
204
|
unhighlight(layerName?: string): void;
|
|
205
|
+
/**
|
|
206
|
+
* Shows collider debug visualization for this entity's physics nodes.
|
|
207
|
+
*
|
|
208
|
+
* Overloads:
|
|
209
|
+
* - `showCollider()` — show all colliders, default color
|
|
210
|
+
* - `showCollider(true)` — show all colliders, default color (config-driven)
|
|
211
|
+
* - `showCollider('#ff0000')` — show all colliders with a specific color
|
|
212
|
+
* - `showCollider('head')` — show a specific collider by node name
|
|
213
|
+
* - `showCollider('head', '#ff0000')` — show a specific collider by name with color
|
|
214
|
+
* - `showCollider({ head: '#ff0000', body: false })` — per-collider control
|
|
215
|
+
*/
|
|
216
|
+
showCollider(configOrNameOrColor?: ColliderDebugConfig, color?: string): void;
|
|
217
|
+
/**
|
|
218
|
+
* Hides collider debug visualization for this entity's physics nodes.
|
|
219
|
+
*
|
|
220
|
+
* - `hideCollider()` — hide all colliders
|
|
221
|
+
* - `hideCollider('head')` — hide a specific collider by node name
|
|
222
|
+
*/
|
|
223
|
+
hideCollider(name?: string): void;
|
|
224
|
+
private _getPhysicsNodes;
|
|
204
225
|
/**
|
|
205
226
|
* Adds a child entity to this entity's hierarchy.
|
|
206
227
|
* Sets the child's parent to this entity. If both entities have nodes, parents the child's node.
|
|
@@ -5,6 +5,8 @@ import { SceneEngine } from "../engines/scene.d.ts";
|
|
|
5
5
|
import { AudioEngine } from "../engines/audio.d.ts";
|
|
6
6
|
import { AssetManager } from "../managers/asset.d.ts";
|
|
7
7
|
import { BindingManager } from "../managers/binding.d.ts";
|
|
8
|
+
import { ColliderDebugManager } from "../managers/colliderDebug.d.ts";
|
|
9
|
+
import { DebugConsole } from "./debugConsole.d.ts";
|
|
8
10
|
import { GameManager } from "../managers/game.d.ts";
|
|
9
11
|
import { GameEntityManager } from "../managers/entity.d.ts";
|
|
10
12
|
import { LevelManager } from "../managers/level.d.ts";
|
|
@@ -43,6 +45,14 @@ interface Managers extends Record<string, Disposable | undefined> {
|
|
|
43
45
|
saveManager: SaveManager;
|
|
44
46
|
audioManager?: AudioManager;
|
|
45
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Interface representing the debug tools available on the engine.
|
|
50
|
+
*/
|
|
51
|
+
interface DebugTools {
|
|
52
|
+
colliders: ColliderDebugManager;
|
|
53
|
+
console: DebugConsole | null;
|
|
54
|
+
expose(name: string, value: unknown): void;
|
|
55
|
+
}
|
|
46
56
|
/**
|
|
47
57
|
* Central hub that owns the render loop, physics, event bus, and all managers.
|
|
48
58
|
* Created via `createGameEngine()` in sage.ts.
|
|
@@ -57,6 +67,7 @@ export declare class GameEngine {
|
|
|
57
67
|
logger: LoggingUtility;
|
|
58
68
|
raycast: RaycastHelper;
|
|
59
69
|
timer: GameTimer;
|
|
70
|
+
debug: DebugTools;
|
|
60
71
|
largeWorldRendering: boolean;
|
|
61
72
|
started: boolean;
|
|
62
73
|
private _log;
|
|
@@ -73,7 +84,7 @@ export declare class GameEngine {
|
|
|
73
84
|
* @param engines
|
|
74
85
|
* @param managers
|
|
75
86
|
*/
|
|
76
|
-
constructor(canvas: GameCanvas, renderEngine: AbstractEngine, physics: HavokPlugin, eventBus: GameEventBus, logger: LoggingUtility, raycast: RaycastHelper, timer: GameTimer, engines: Engines, managers: Managers, largeWorldRendering?: boolean);
|
|
87
|
+
constructor(canvas: GameCanvas, renderEngine: AbstractEngine, physics: HavokPlugin, eventBus: GameEventBus, logger: LoggingUtility, raycast: RaycastHelper, timer: GameTimer, engines: Engines, managers: Managers, largeWorldRendering?: boolean, debug?: DebugTools);
|
|
77
88
|
/**
|
|
78
89
|
* Register a function to be called before the game engine starts
|
|
79
90
|
* @param hook
|
|
@@ -135,6 +135,11 @@ export declare class GameLevel extends Level {
|
|
|
135
135
|
* Spawn an entity at the given spawn point and dispose of the placeholder node.
|
|
136
136
|
*/
|
|
137
137
|
private _processSpawnPoint;
|
|
138
|
+
/**
|
|
139
|
+
* Apply debug collider visualization to an entity if configured.
|
|
140
|
+
* Level/spawn config takes priority over the entity definition's debugCollider.
|
|
141
|
+
*/
|
|
142
|
+
private _applyDebugCollider;
|
|
138
143
|
/**
|
|
139
144
|
* Create an entity from a spawn definition, inheriting position/rotation/scaling from the spawn point.
|
|
140
145
|
*/
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DebugConsole } from "../classes/debugConsole.d.ts";
|
|
2
|
+
import { GameEngine } from "../classes/gameEngine.d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Registers all default references and commands onto the debug console namespace.
|
|
5
|
+
*/
|
|
6
|
+
export declare function registerBuiltins(dc: DebugConsole, ge: GameEngine): void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GameEntityBehavior } from "../classes/entity.d.ts";
|
|
2
2
|
import { Action } from "./action.d.ts";
|
|
3
|
+
import { ColliderDebugConfig } from "../managers/colliderDebug.d.ts";
|
|
3
4
|
export type GameEntityBehaviorConstructor<RequiredState extends object = object> = new () => GameEntityBehavior<RequiredState>;
|
|
4
5
|
export interface GameEntityDefinition<State extends object = object> {
|
|
5
6
|
/** Unique type identifier for this entity definition. */
|
|
@@ -85,6 +86,8 @@ export interface GameEntityDefinition<State extends object = object> {
|
|
|
85
86
|
z: number;
|
|
86
87
|
};
|
|
87
88
|
}[];
|
|
89
|
+
/** Debug collider visualization config. Applied automatically during level loading. */
|
|
90
|
+
debugCollider?: ColliderDebugConfig;
|
|
88
91
|
onBeforeCreate?: (state: State) => Promise<State | undefined> | State | undefined;
|
|
89
92
|
onCreate?: (state: State) => Promise<State | undefined> | State | undefined;
|
|
90
93
|
onBeforeDestroy?: (state: State) => Promise<State | undefined> | State | undefined;
|
|
@@ -31,4 +31,13 @@ export interface SageOptions {
|
|
|
31
31
|
* Also enables multi-region Havok physics when physics are active.
|
|
32
32
|
*/
|
|
33
33
|
largeWorldRendering?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Debug console configuration.
|
|
36
|
+
* - `true` or omitted: enabled with default namespace 'sage'
|
|
37
|
+
* - `{ namespace: 'myGame' }`: enabled with custom namespace
|
|
38
|
+
* - `false`: disabled (production builds)
|
|
39
|
+
*/
|
|
40
|
+
debug?: false | {
|
|
41
|
+
namespace?: string;
|
|
42
|
+
};
|
|
34
43
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Scene, TransformNode } from '@babylonjs/core';
|
|
2
2
|
import { GameEngine } from "../classes/gameEngine.d.ts";
|
|
3
|
+
import { ColliderDebugConfig } from "../managers/colliderDebug.d.ts";
|
|
3
4
|
import { LoggingUtility } from "../utils/logger.d.ts";
|
|
4
5
|
/**
|
|
5
6
|
* Minimal interface for Level that property handlers receive.
|
|
@@ -42,6 +43,8 @@ export interface SpawnDefinition {
|
|
|
42
43
|
tags?: string[];
|
|
43
44
|
/** Additional configuration passed to the entity's initial state */
|
|
44
45
|
config?: Record<string, unknown>;
|
|
46
|
+
/** Debug collider visualization config. Overrides the entity definition's debugCollider. */
|
|
47
|
+
debugCollider?: ColliderDebugConfig;
|
|
45
48
|
}
|
|
46
49
|
/**
|
|
47
50
|
* Definition for entity types found in the scene.
|
|
@@ -54,6 +57,8 @@ export interface EntityDefinition {
|
|
|
54
57
|
tags?: string[];
|
|
55
58
|
/** Additional configuration passed to the entity's initial state */
|
|
56
59
|
config?: Record<string, unknown>;
|
|
60
|
+
/** Debug collider visualization config. Overrides the entity definition's debugCollider. */
|
|
61
|
+
debugCollider?: ColliderDebugConfig;
|
|
57
62
|
}
|
|
58
63
|
/**
|
|
59
64
|
* Configuration for loading a scene file.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TransformNode } from '@babylonjs/core';
|
|
2
|
+
import { Disposable } from "../interfaces/lifecycle.d.ts";
|
|
3
|
+
export type ColliderDebugConfig = boolean | string | Record<string, string | false>;
|
|
4
|
+
export declare class ColliderDebugManager implements Disposable {
|
|
5
|
+
private _viewer;
|
|
6
|
+
private _shown;
|
|
7
|
+
private _materials;
|
|
8
|
+
showColliderForNode(node: TransformNode, color?: string): void;
|
|
9
|
+
hideColliderForNode(node: TransformNode): void;
|
|
10
|
+
hideAll(): void;
|
|
11
|
+
isShown(node: TransformNode): boolean;
|
|
12
|
+
$teardown(): Promise<void>;
|
|
13
|
+
dispose(): void;
|
|
14
|
+
private _getViewer;
|
|
15
|
+
private _getColorMaterial;
|
|
16
|
+
}
|
package/dist/sage.d.ts
CHANGED
|
@@ -38,9 +38,13 @@ export type { CreateEntityOptions } from "./managers/entity.d.ts";
|
|
|
38
38
|
export type { TransitionOptions } from "./managers/level.d.ts";
|
|
39
39
|
export { AudioManager } from "./managers/audio.d.ts";
|
|
40
40
|
export type { ChannelInfo } from "./managers/audio.d.ts";
|
|
41
|
+
export { ColliderDebugManager } from "./managers/colliderDebug.d.ts";
|
|
42
|
+
export type { ColliderDebugConfig } from "./managers/colliderDebug.d.ts";
|
|
41
43
|
export { OutlineManager } from "./managers/outline.d.ts";
|
|
42
44
|
export { SaveManager } from "./managers/save.d.ts";
|
|
43
45
|
export type { SaveData, SerializedEntity } from "./managers/save.d.ts";
|
|
46
|
+
export { DebugConsole } from "./classes/debugConsole.d.ts";
|
|
47
|
+
export { createEntityProxy } from "./utils/entityProxy.d.ts";
|
|
44
48
|
export { generateId } from "./utils/id.d.ts";
|
|
45
49
|
export { RaycastHelper } from "./utils/raycast.d.ts";
|
|
46
50
|
export type { EntityPickResult, EntityPickFilter } from "./utils/raycast.d.ts";
|