@newkrok/nape-js 3.21.7 → 3.22.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.
@@ -1,3 +1,5 @@
1
+ import { P as PhysicsMetricsData } from './PhysicsMetrics-QzFDRdGh.js';
2
+
1
3
  /**
2
4
  * 2D vector used for positions, velocities, forces, and other 2D quantities.
3
5
  *
@@ -1872,6 +1874,25 @@ declare class Space {
1872
1874
  */
1873
1875
  get deterministic(): boolean;
1874
1876
  set deterministic(value: boolean);
1877
+ /**
1878
+ * Enable the built-in performance profiler. When `true`, each `step()` call
1879
+ * measures per-phase timings (broadphase, narrowphase, velocity solver,
1880
+ * position solver, CCD, sleep) and collects entity counters (body, contact,
1881
+ * constraint counts). Read results via {@link metrics}.
1882
+ *
1883
+ * **Performance:** adds ~14 `performance.now()` calls per step (~1 microsecond
1884
+ * total). Default: `false`.
1885
+ */
1886
+ get profilerEnabled(): boolean;
1887
+ set profilerEnabled(value: boolean);
1888
+ /**
1889
+ * Read-only snapshot of the last `step()` metrics.
1890
+ * Returns a reused object (no allocation per call). Only populated when
1891
+ * {@link profilerEnabled} is `true`; all values are zero otherwise.
1892
+ *
1893
+ * Call `metrics.toJSON()` for a plain-object copy suitable for logging.
1894
+ */
1895
+ get metrics(): PhysicsMetricsData;
1875
1896
  /**
1876
1897
  * Number of sub-steps performed per `step()` call. Each sub-step uses
1877
1898
  * `deltaTime / subSteps` and the same velocity/position iteration counts.
@@ -1,3 +1,5 @@
1
+ import { P as PhysicsMetricsData } from './PhysicsMetrics-QzFDRdGh.cjs';
2
+
1
3
  /**
2
4
  * 2D vector used for positions, velocities, forces, and other 2D quantities.
3
5
  *
@@ -1872,6 +1874,25 @@ declare class Space {
1872
1874
  */
1873
1875
  get deterministic(): boolean;
1874
1876
  set deterministic(value: boolean);
1877
+ /**
1878
+ * Enable the built-in performance profiler. When `true`, each `step()` call
1879
+ * measures per-phase timings (broadphase, narrowphase, velocity solver,
1880
+ * position solver, CCD, sleep) and collects entity counters (body, contact,
1881
+ * constraint counts). Read results via {@link metrics}.
1882
+ *
1883
+ * **Performance:** adds ~14 `performance.now()` calls per step (~1 microsecond
1884
+ * total). Default: `false`.
1885
+ */
1886
+ get profilerEnabled(): boolean;
1887
+ set profilerEnabled(value: boolean);
1888
+ /**
1889
+ * Read-only snapshot of the last `step()` metrics.
1890
+ * Returns a reused object (no allocation per call). Only populated when
1891
+ * {@link profilerEnabled} is `true`; all values are zero otherwise.
1892
+ *
1893
+ * Call `metrics.toJSON()` for a plain-object copy suitable for logging.
1894
+ */
1895
+ get metrics(): PhysicsMetricsData;
1875
1896
  /**
1876
1897
  * Number of sub-steps performed per `step()` call. Each sub-step uses
1877
1898
  * `deltaTime / subSteps` and the same velocity/position iteration counts.
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Snapshot of per-step physics metrics collected when `Space.profilerEnabled` is true.
3
+ *
4
+ * All timing values are in **milliseconds**. Counter values are plain integers.
5
+ * The object is reused across steps (no allocation per frame).
6
+ */
7
+ interface PhysicsMetricsData {
8
+ /** Total wall-clock time of the last `step()` call. */
9
+ totalStepTime: number;
10
+ /** Time spent in broadphase collision pair detection. */
11
+ broadphaseTime: number;
12
+ /** Time spent in narrowphase (prestep: contact generation, arbiter setup). */
13
+ narrowphaseTime: number;
14
+ /** Time spent in velocity integration + warm-start + velocity solver iterations. */
15
+ velocitySolverTime: number;
16
+ /** Time spent in position integration + position solver iterations. */
17
+ positionSolverTime: number;
18
+ /** Time spent in continuous collision detection (CCD). */
19
+ ccdTime: number;
20
+ /** Time spent in sleep management and island/forest processing. */
21
+ sleepTime: number;
22
+ /** Total number of bodies in the space. */
23
+ bodyCount: number;
24
+ /** Number of dynamic (awake) bodies. */
25
+ dynamicBodyCount: number;
26
+ /** Number of static bodies. */
27
+ staticBodyCount: number;
28
+ /** Number of kinematic bodies. */
29
+ kinematicBodyCount: number;
30
+ /** Number of sleeping bodies. */
31
+ sleepingBodyCount: number;
32
+ /** Number of active collision arbiters. */
33
+ contactCount: number;
34
+ /** Number of active constraints. */
35
+ constraintCount: number;
36
+ /** Number of broadphase pairs tested. */
37
+ broadphasePairCount: number;
38
+ }
39
+
40
+ export type { PhysicsMetricsData as P };
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Snapshot of per-step physics metrics collected when `Space.profilerEnabled` is true.
3
+ *
4
+ * All timing values are in **milliseconds**. Counter values are plain integers.
5
+ * The object is reused across steps (no allocation per frame).
6
+ */
7
+ interface PhysicsMetricsData {
8
+ /** Total wall-clock time of the last `step()` call. */
9
+ totalStepTime: number;
10
+ /** Time spent in broadphase collision pair detection. */
11
+ broadphaseTime: number;
12
+ /** Time spent in narrowphase (prestep: contact generation, arbiter setup). */
13
+ narrowphaseTime: number;
14
+ /** Time spent in velocity integration + warm-start + velocity solver iterations. */
15
+ velocitySolverTime: number;
16
+ /** Time spent in position integration + position solver iterations. */
17
+ positionSolverTime: number;
18
+ /** Time spent in continuous collision detection (CCD). */
19
+ ccdTime: number;
20
+ /** Time spent in sleep management and island/forest processing. */
21
+ sleepTime: number;
22
+ /** Total number of bodies in the space. */
23
+ bodyCount: number;
24
+ /** Number of dynamic (awake) bodies. */
25
+ dynamicBodyCount: number;
26
+ /** Number of static bodies. */
27
+ staticBodyCount: number;
28
+ /** Number of kinematic bodies. */
29
+ kinematicBodyCount: number;
30
+ /** Number of sleeping bodies. */
31
+ sleepingBodyCount: number;
32
+ /** Number of active collision arbiters. */
33
+ contactCount: number;
34
+ /** Number of active constraints. */
35
+ constraintCount: number;
36
+ /** Number of broadphase pairs tested. */
37
+ broadphasePairCount: number;
38
+ }
39
+
40
+ export type { PhysicsMetricsData as P };