@fps-games/engine 0.0.1-beta.3 → 0.0.1-beta.5

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.
@@ -0,0 +1,27 @@
1
+ import type { Engine } from '@babylonjs/core/Engines/engine.js';
2
+ import { type FpsFrameClock, type FpsFrameClockOptions, type FpsFrameContext } from '../frame.js';
3
+ export interface CreateFpsBabylonFramePumpOptions {
4
+ readonly engine: Engine;
5
+ readonly onFrame: (frame: Readonly<FpsFrameContext>) => void;
6
+ readonly clock?: FpsFrameClock;
7
+ readonly clockOptions?: FpsFrameClockOptions;
8
+ readonly now?: () => number;
9
+ }
10
+ export interface FpsBabylonFramePump {
11
+ readonly clock: FpsFrameClock;
12
+ isRunning(): boolean;
13
+ isDisposed(): boolean;
14
+ start(): void;
15
+ stop(): void;
16
+ dispose(): void;
17
+ }
18
+ /**
19
+ * Owns only Babylon's outer runRenderLoop registration and frame timing.
20
+ *
21
+ * The callback remains the composition boundary: it can drive the shared
22
+ * Runtime Plugin scheduler, project gameplay, cleanup and Scene rendering in
23
+ * the order selected by the project. The pump does not introduce a competing
24
+ * phase scheduler and does not own the Engine or Scene.
25
+ */
26
+ export declare function createFpsBabylonFramePump(options: CreateFpsBabylonFramePumpOptions): FpsBabylonFramePump;
27
+ //# sourceMappingURL=frame-pump.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frame-pump.d.ts","sourceRoot":"","sources":["../../src/babylon/frame-pump.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACrB,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;IAC7D,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,YAAY,CAAC,EAAE,oBAAoB,CAAC;IAC7C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,SAAS,IAAI,OAAO,CAAC;IACrB,UAAU,IAAI,OAAO,CAAC;IACtB,KAAK,IAAI,IAAI,CAAC;IACd,IAAI,IAAI,IAAI,CAAC;IACb,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,gCAAgC,GACxC,mBAAmB,CAqDrB"}
@@ -0,0 +1,90 @@
1
+ import { createFpsFrameClock, } from '../frame.js';
2
+ /**
3
+ * Owns only Babylon's outer runRenderLoop registration and frame timing.
4
+ *
5
+ * The callback remains the composition boundary: it can drive the shared
6
+ * Runtime Plugin scheduler, project gameplay, cleanup and Scene rendering in
7
+ * the order selected by the project. The pump does not introduce a competing
8
+ * phase scheduler and does not own the Engine or Scene.
9
+ */
10
+ export function createFpsBabylonFramePump(options) {
11
+ assertOptions(options);
12
+ if (options.clock && options.clockOptions) {
13
+ throw new Error('Babylon Frame Pump accepts either clock or clockOptions, not both.');
14
+ }
15
+ const clock = options.clock ?? createFpsFrameClock(options.clockOptions);
16
+ const now = options.now ?? readNowMs;
17
+ let running = false;
18
+ let disposed = false;
19
+ const renderLoop = () => {
20
+ if (!running)
21
+ return;
22
+ options.onFrame(clock.beginFrame(now()));
23
+ };
24
+ return Object.freeze({
25
+ clock,
26
+ isRunning() {
27
+ return running;
28
+ },
29
+ isDisposed() {
30
+ return disposed;
31
+ },
32
+ start() {
33
+ assertOpen(disposed);
34
+ if (running)
35
+ return;
36
+ clock.resetTime();
37
+ running = true;
38
+ try {
39
+ options.engine.runRenderLoop(renderLoop);
40
+ }
41
+ catch (error) {
42
+ running = false;
43
+ clock.resetTime();
44
+ throw error;
45
+ }
46
+ },
47
+ stop() {
48
+ if (!running)
49
+ return;
50
+ options.engine.stopRenderLoop(renderLoop);
51
+ running = false;
52
+ clock.resetTime();
53
+ },
54
+ dispose() {
55
+ if (disposed)
56
+ return;
57
+ if (running) {
58
+ options.engine.stopRenderLoop(renderLoop);
59
+ running = false;
60
+ clock.resetTime();
61
+ }
62
+ disposed = true;
63
+ },
64
+ });
65
+ }
66
+ function assertOptions(options) {
67
+ if (!options || typeof options !== 'object') {
68
+ throw new Error('Babylon Frame Pump options are required.');
69
+ }
70
+ if (!options.engine
71
+ || typeof options.engine.runRenderLoop !== 'function'
72
+ || typeof options.engine.stopRenderLoop !== 'function') {
73
+ throw new Error('Babylon Frame Pump requires an Engine.');
74
+ }
75
+ if (typeof options.onFrame !== 'function') {
76
+ throw new Error('Babylon Frame Pump onFrame callback is required.');
77
+ }
78
+ if (options.now !== undefined && typeof options.now !== 'function') {
79
+ throw new Error('Babylon Frame Pump now must be a function.');
80
+ }
81
+ }
82
+ function assertOpen(disposed) {
83
+ if (disposed)
84
+ throw new Error('Babylon Frame Pump is disposed.');
85
+ }
86
+ function readNowMs() {
87
+ const hostPerformance = globalThis.performance;
88
+ return hostPerformance ? hostPerformance.now() : Date.now();
89
+ }
90
+ //# sourceMappingURL=frame-pump.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frame-pump.js","sourceRoot":"","sources":["../../src/babylon/frame-pump.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,GAIpB,MAAM,aAAa,CAAC;AAmBrB;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CACvC,OAAyC;IAEzC,aAAa,CAAC,OAAO,CAAC,CAAC;IACvB,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;IACxF,CAA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
+ export interface CreateFpsBabylonSceneRendererOptions {
4
+ readonly scene: Scene;
5
+ readonly scheduleNextFrame?: FpsBabylonNextFrameScheduler;
6
+ }
7
+ export interface FpsBabylonSceneRenderer {
8
+ render(): void;
9
+ renderOnce(): Promise<void>;
10
+ }
11
+ /**
12
+ * Creates a non-owning Babylon Scene renderer shared by the continuous frame
13
+ * loop and one-shot warm-up paths.
14
+ *
15
+ * Project composition still decides when Gameplay updates run and when a
16
+ * frame is rendered. This resource does not create a render loop and does not
17
+ * own or dispose the Scene.
18
+ */
19
+ export declare function createFpsBabylonSceneRenderer(options: CreateFpsBabylonSceneRendererOptions): FpsBabylonSceneRenderer;
20
+ //# sourceMappingURL=scene-renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scene-renderer.d.ts","sourceRoot":"","sources":["../../src/babylon/scene-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAEtD,MAAM,MAAM,4BAA4B,GAAG,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;AAE1E,MAAM,WAAW,oCAAoC;IACnD,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,iBAAiB,CAAC,EAAE,4BAA4B,CAAC;CAC3D;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,IAAI,IAAI,CAAC;IACf,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,oCAAoC,GAC5C,uBAAuB,CAezB"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Creates a non-owning Babylon Scene renderer shared by the continuous frame
3
+ * loop and one-shot warm-up paths.
4
+ *
5
+ * Project composition still decides when Gameplay updates run and when a
6
+ * frame is rendered. This resource does not create a render loop and does not
7
+ * own or dispose the Scene.
8
+ */
9
+ export function createFpsBabylonSceneRenderer(options) {
10
+ assertOptions(options);
11
+ const scheduleNextFrame = options.scheduleNextFrame ?? scheduleHostNextFrame;
12
+ const render = () => {
13
+ options.scene.render();
14
+ };
15
+ return Object.freeze({
16
+ render,
17
+ async renderOnce() {
18
+ await options.scene.whenReadyAsync(false);
19
+ await waitForNextFrame(scheduleNextFrame);
20
+ render();
21
+ },
22
+ });
23
+ }
24
+ function assertOptions(options) {
25
+ if (!options || typeof options !== 'object') {
26
+ throw new Error('Babylon Scene Renderer options are required.');
27
+ }
28
+ if (!options.scene
29
+ || typeof options.scene.render !== 'function'
30
+ || typeof options.scene.whenReadyAsync !== 'function') {
31
+ throw new Error('Babylon Scene Renderer requires a Scene.');
32
+ }
33
+ if (options.scheduleNextFrame !== undefined
34
+ && typeof options.scheduleNextFrame !== 'function') {
35
+ throw new Error('Babylon Scene Renderer scheduleNextFrame must be a function.');
36
+ }
37
+ }
38
+ function waitForNextFrame(schedule) {
39
+ return new Promise((resolve, reject) => {
40
+ try {
41
+ schedule(resolve);
42
+ }
43
+ catch (error) {
44
+ reject(error);
45
+ }
46
+ });
47
+ }
48
+ function scheduleHostNextFrame(callback) {
49
+ const host = globalThis;
50
+ if (typeof host.requestAnimationFrame === 'function') {
51
+ host.requestAnimationFrame(callback);
52
+ return;
53
+ }
54
+ if (typeof host.setTimeout === 'function') {
55
+ host.setTimeout(callback, 0);
56
+ return;
57
+ }
58
+ void Promise.resolve().then(callback);
59
+ }
60
+ //# sourceMappingURL=scene-renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scene-renderer.js","sourceRoot":"","sources":["../../src/babylon/scene-renderer.ts"],"names":[],"mappings":"AAcA;;;;;;;GAOG;AACH,MAAM,UAAU,6BAA6B,CAC3C,OAA6C;IAE7C,aAAa,CAAC,OAAO,CAAC,CAAC;IACvB,MAAM,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,IAAI,qBAAqB,CAAC;IAC7E,MAAM,MAAM,GAAG,GAAS,EAAE;QACxB,OAAO,C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BAAqB,KAAK,UAAU,EAAE,CAAC;QACrD,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QACrC,OAAO;IACT,CAAC;IACD,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;QAC1C,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC7B,OAAO;IACT,CAAC;IACD,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACxC,CAAC"}
package/dist/babylon.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export declare const ENGINE_BABYLON_SUBPATH = "@fps-games/engine/babylon";
2
+ export { createFpsBabylonFramePump, type CreateFpsBabylonFramePumpOptions, type FpsBabylonFramePump, } from './babylon/frame-pump.js';
3
+ export { createFpsBabylonSceneRenderer, type CreateFpsBabylonSceneRendererOptions, type FpsBabylonNextFrameScheduler, type FpsBabylonSceneRenderer, } from './babylon/scene-renderer.js';
2
4
  export { applyFpsBabylonCameraProjection, createFpsBabylonCameraResource, resizeFpsBabylonCameraProjection, type CreateFpsBabylonCameraResourceOptions, type FpsBabylonCameraRegistration, type FpsBabylonCameraResource, } from './babylon/camera.js';
3
5
  export { createFpsBabylonLightingController, type FpsBabylonLightingApplyResult, type FpsBabylonLightingController, type FpsBabylonLightingMutation, type FpsBabylonRuntimeLight, } from './babylon/lighting-controller.js';
4
6
  //# sourceMappingURL=babylon.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"babylon.d.ts","sourceRoot":"","sources":["../src/babylon.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,8BAA8B,CAAC;AAElE,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,EAC9B,gCAAgC,EAChC,KAAK,qCAAqC,EAC1C,KAAK,4BAA4B,EACjC,KAAK,wBAAwB,GAC9B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kCAAkC,EAClC,KAAK,6BAA6B,EAClC,KAAK,4BAA4B,EACjC,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,GAC5B,MAAM,kCAAkC,CAAC"}
1
+ {"version":3,"file":"babylon.d.ts","sourceRoot":"","sources":["../src/babylon.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,8BAA8B,CAAC;AAElE,OAAO,EACL,yBAAyB,EACzB,KAAK,gCAAgC,EACrC,KAAK,mBAAmB,GACzB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,6BAA6B,EAC7B,KAAK,oCAAoC,EACzC,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,GAC7B,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,EAC9B,gCAAgC,EAChC,KAAK,qCAAqC,EAC1C,KAAK,4BAA4B,EACjC,KAAK,wBAAwB,GAC9B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kCAAkC,EAClC,KAAK,6BAA6B,EAClC,KAAK,4BAA4B,EACjC,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,GAC5B,MAAM,kCAAkC,CAAC"}
package/dist/babylon.js CHANGED
@@ -1,4 +1,6 @@
1
1
  export const ENGINE_BABYLON_SUBPATH = '@fps-games/engine/babylon';
2
+ export { createFpsBabylonFramePump, } from './babylon/frame-pump.js';
3
+ export { createFpsBabylonSceneRenderer, } from './babylon/scene-renderer.js';
2
4
  export { applyFpsBabylonCameraProjection, createFpsBabylonCameraResource, resizeFpsBabylonCameraProjection, } from './babylon/camera.js';
3
5
  export { createFpsBabylonLightingController, } from './babylon/lighting-controller.js';
4
6
  //# sourceMappingURL=babylon.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"babylon.js","sourceRoot":"","sources":["../src/babylon.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,2BAA2B,CAAC;AAElE,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,EAC9B,gCAAgC,GAIjC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kCAAkC,GAKnC,MAAM,kCAAkC,CAAC"}
1
+ {"version":3,"file":"babylon.js","sourceRoot":"","sources":["../src/babylon.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,2BAA2B,CAAC;AAElE,OAAO,EACL,yBAAyB,GAG1B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,6BAA6B,GAI9B,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,EAC9B,gCAAgC,GAIjC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,kCAAkC,GAKnC,MAAM,kCAAkC,CAAC"}
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "packageName": "@fps-games/engine",
4
- "version": "0.0.1-beta.3",
5
- "gitSha": "266b82b05222646aaac1963e15c566d3a0eb0a63",
6
- "distHash": "eb7df52fec11110e7935feb2119cf846e4f6a403e5373ddb5e1f58dc2363ced1",
7
- "cacheKey": "0.0.1-beta.3-eb7df52fec11"
4
+ "version": "0.0.1-beta.5",
5
+ "gitSha": "34938b614fc42a6e355a593ea5a7027bbe66d084",
6
+ "distHash": "85346472fcce6e7e77f98a2cff925ab2e96d0eeecaf2fdd6a07f568ec29a1a8a",
7
+ "cacheKey": "0.0.1-beta.5-85346472fcce"
8
8
  }
@@ -0,0 +1,32 @@
1
+ export declare const FPS_FRAME_CLOCK_DEFAULT_MAX_DELTA_SECONDS = 0.1;
2
+ /**
3
+ * Renderer-neutral timing emitted once by the outer Runtime frame pump.
4
+ *
5
+ * This is deliberately not a gameplay phase scheduler. Projects and Runtime
6
+ * Plugins decide how a frame is split into update phases and when rendering
7
+ * occurs.
8
+ */
9
+ export interface FpsFrameContext {
10
+ readonly frame: number;
11
+ readonly nowMs: number;
12
+ readonly deltaSeconds: number;
13
+ readonly elapsedSeconds: number;
14
+ }
15
+ export interface FpsFrameClockOptions {
16
+ readonly maxDeltaSeconds?: number;
17
+ }
18
+ export interface FpsFrameClock {
19
+ readonly maxDeltaSeconds: number;
20
+ beginFrame(nowMs: number): Readonly<FpsFrameContext>;
21
+ resetTime(): void;
22
+ reset(): void;
23
+ }
24
+ /**
25
+ * Creates a monotonic, clamped Runtime frame clock.
26
+ *
27
+ * `resetTime()` prevents a stopped, hidden or paused interval from becoming a
28
+ * large delta while preserving the accumulated frame diagnostics. `reset()`
29
+ * starts a completely new frame timeline.
30
+ */
31
+ export declare function createFpsFrameClock(options?: FpsFrameClockOptions): FpsFrameClock;
32
+ //# sourceMappingURL=frame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../src/frame.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yCAAyC,MAAM,CAAC;AAE7D;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC,eAAe,CAAC,CAAC;IACrD,SAAS,IAAI,IAAI,CAAC;IAClB,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,oBAAyB,GACjC,aAAa,CAsCf"}
package/dist/frame.js ADDED
@@ -0,0 +1,54 @@
1
+ export const FPS_FRAME_CLOCK_DEFAULT_MAX_DELTA_SECONDS = 0.1;
2
+ /**
3
+ * Creates a monotonic, clamped Runtime frame clock.
4
+ *
5
+ * `resetTime()` prevents a stopped, hidden or paused interval from becoming a
6
+ * large delta while preserving the accumulated frame diagnostics. `reset()`
7
+ * starts a completely new frame timeline.
8
+ */
9
+ export function createFpsFrameClock(options = {}) {
10
+ const maxDeltaSeconds = readPositiveFinite(options.maxDeltaSeconds ?? FPS_FRAME_CLOCK_DEFAULT_MAX_DELTA_SECONDS, 'maxDeltaSeconds');
11
+ let frame = 0;
12
+ let elapsedSeconds = 0;
13
+ let previousNowMs = null;
14
+ return Object.freeze({
15
+ maxDeltaSeconds,
16
+ beginFrame(nowMs) {
17
+ const currentNowMs = readFinite(nowMs, 'nowMs');
18
+ const rawDeltaSeconds = previousNowMs === null
19
+ ? 0
20
+ : Math.max(0, (currentNowMs - previousNowMs) / 1000);
21
+ const deltaSeconds = Math.min(rawDeltaSeconds, maxDeltaSeconds);
22
+ previousNowMs = currentNowMs;
23
+ elapsedSeconds += deltaSeconds;
24
+ frame += 1;
25
+ return Object.freeze({
26
+ frame,
27
+ nowMs: currentNowMs,
28
+ deltaSeconds,
29
+ elapsedSeconds,
30
+ });
31
+ },
32
+ resetTime() {
33
+ previousNowMs = null;
34
+ },
35
+ reset() {
36
+ frame = 0;
37
+ elapsedSeconds = 0;
38
+ previousNowMs = null;
39
+ },
40
+ });
41
+ }
42
+ function readPositiveFinite(value, label) {
43
+ if (!Number.isFinite(value) || value <= 0) {
44
+ throw new Error(`Frame Clock ${label} must be a positive finite number.`);
45
+ }
46
+ return value;
47
+ }
48
+ function readFinite(value, label) {
49
+ if (!Number.isFinite(value)) {
50
+ throw new Error(`Frame Clock ${label} must be a finite number.`);
51
+ }
52
+ return value;
53
+ }
54
+ //# sourceMappingURL=frame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frame.js","sourceRoot":"","sources":["../src/frame.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yCAAyC,GAAG,GAAG,CAAC;AA2B7D;;;;;;GAMG;AACH,MAAM,UA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CAAC;IAC5E,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,UAAU,CAAC,KAAa,EAAE,KAAa;IAC9C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,eAAe,KAAK,2BAA2B,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export interface FpsEngineRuntimeDataMarker {
4
4
  readonly schemaVersion: 1;
5
5
  readonly marker: typeof ENGINE_PACKAGE_MARKER;
6
6
  }
7
+ export { FPS_FRAME_CLOCK_DEFAULT_MAX_DELTA_SECONDS, createFpsFrameClock, type FpsFrameClock, type FpsFrameClockOptions, type FpsFrameContext, } from './frame.js';
7
8
  export { FPS_CAMERA_PROJECTION_SCHEMA_VERSION, FpsCameraProjectionDataError, createFpsCameraProjectionSnapshot, type FpsCameraProjectionMode, type FpsCameraProjectionSnapshot, } from './camera.js';
8
9
  export { FPS_RUNTIME_LIGHT_COMPONENT_SCHEMA_VERSION, FpsRuntimeLightingDataError, createFpsRuntimeLightSnapshot, createFpsRuntimeStandardSystemLightingSnapshot, createFpsRuntimeSystemLightingSnapshot, normalizeFpsRuntimeLightDirection, type FpsRuntimeDirectionalLight, type FpsRuntimeHemisphericLight, type FpsRuntimeLight, type FpsRuntimeLightColorRgb, type FpsRuntimeLightNodeSnapshot, type FpsRuntimeLightVec3, type FpsRuntimeStandardSystemLightingSnapshot, type FpsRuntimeSystemLightingSnapshot, } from './lighting.js';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AACzD,eAAO,MAAM,2BAA2B,qBAAqB,CAAC;AAE9D,MAAM,WAAW,0BAA0B;IACzC,QAAQ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,EAChC,KAAK,mBAAmB,EACxB,KAAK,wCAAwC,EAC7C,KAAK,gCAAgC,GACtC,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export const ENGINE_PACKAGE_MARKER = '@fps-games/engine';
2
2
  export const ENGINE_IMPLEMENTATION_PHASE = 'domain-migration';
3
+ export { FPS_FRAME_CLOCK_DEFAULT_MAX_DELTA_SECONDS, createFpsFrameClock, } from './frame.js';
3
4
  export { FPS_CAMERA_PROJECTION_SCHEMA_VERSION, FpsCameraProjectionDataError, createFpsCameraProjectionSnapshot, } from './camera.js';
4
5
  export { FPS_RUNTIME_LIGHT_COMPONENT_SCHEMA_VERSION, FpsRuntimeLightingDataError, createFpsRuntimeLightSnapshot, createFpsRuntimeStandardSystemLightingSnapshot, createFpsRuntimeSystemLightingSnapshot, normalizeFpsRuntimeLightDirection, } from './lighting.js';
5
6
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AACzD,MAAM,CAAC,MAAM,2BAA2B,GAAG,kBAAkB,CAAC;AAO9D,OAAO,EACL,oCAAoC,EACpC,4BAA4B,EAC5B,iCAAiC,GAGlC,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,0CAA0C,EAC1C,2BAA2B,EAC3B,6BAA6B,EAC7B,8CAA8C,EAC9C,sCAAsC,EACtC,iCAAiC,GASlC,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CAAC;AACzD,MAAM,CAAC,MAAM,2BAA2B,GAAG,kBAAkB,CAAC;AAO9D,OAAO,EACL,yCAAyC,EACzC,mBAAmB,GAIpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,oCAAoC,EACpC,4BAA4B,EAC5B,iCAAiC,GAGlC,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,0CAA0C,EAC1C,2BAA2B,EAC3B,6BAA6B,EAC7B,8CAA8C,EAC9C,sCAAsC,EACtC,iCAAiC,GASlC,MAAM,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fps-games/engine",
3
- "version": "0.0.1-beta.3",
3
+ "version": "0.0.1-beta.5",
4
4
  "description": "Forge Play game engine Runtime Data and renderer backend product.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",