@gg-web-engine/core 0.0.40 → 0.0.49

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.
Files changed (187) hide show
  1. package/README.md +0 -0
  2. package/blender_exporter/build_blender_scene.py +0 -1
  3. package/blender_exporter/spherical_to_cube_texture.py +0 -0
  4. package/dist/2d/components/physics/i-physics-world-2d.component.d.ts +0 -0
  5. package/dist/2d/components/physics/i-physics-world-2d.component.js +0 -0
  6. package/dist/2d/components/physics/i-rigid-body-2d.component.d.ts +0 -0
  7. package/dist/2d/components/physics/i-rigid-body-2d.component.js +0 -0
  8. package/dist/2d/components/physics/i-trigger-2d.component.d.ts +0 -0
  9. package/dist/2d/components/physics/i-trigger-2d.component.js +0 -0
  10. package/dist/2d/components/rendering/i-display-object-2d.component.d.ts +0 -0
  11. package/dist/2d/components/rendering/i-display-object-2d.component.js +0 -0
  12. package/dist/2d/components/rendering/i-renderer-2d.component.d.ts +0 -0
  13. package/dist/2d/components/rendering/i-renderer-2d.component.js +0 -0
  14. package/dist/2d/components/rendering/i-visual-scene-2d.component.d.ts +0 -0
  15. package/dist/2d/components/rendering/i-visual-scene-2d.component.js +0 -0
  16. package/dist/2d/entities/controllers/entity-2d-positioning.animator.d.ts +1 -1
  17. package/dist/2d/entities/controllers/entity-2d-positioning.animator.js +0 -0
  18. package/dist/2d/entities/entity-2d.d.ts +0 -0
  19. package/dist/2d/entities/entity-2d.js +25 -25
  20. package/dist/2d/entities/i-renderable-2d.entity.d.ts +0 -0
  21. package/dist/2d/entities/i-renderable-2d.entity.js +0 -0
  22. package/dist/2d/entities/renderer-2d.entity.d.ts +0 -0
  23. package/dist/2d/entities/renderer-2d.entity.js +0 -0
  24. package/dist/2d/entities/trigger-2d.entity.d.ts +0 -0
  25. package/dist/2d/entities/trigger-2d.entity.js +11 -11
  26. package/dist/2d/factories.d.ts +1 -1
  27. package/dist/2d/factories.js +0 -0
  28. package/dist/2d/gg-2d-world.d.ts +3 -3
  29. package/dist/2d/gg-2d-world.js +0 -0
  30. package/dist/2d/index.d.ts +0 -0
  31. package/dist/2d/index.js +0 -0
  32. package/dist/2d/interfaces/i-positionable-2d.d.ts +0 -0
  33. package/dist/2d/interfaces/i-positionable-2d.js +0 -0
  34. package/dist/2d/models/body-options.d.ts +1 -1
  35. package/dist/2d/models/body-options.js +0 -0
  36. package/dist/2d/models/shapes.d.ts +5 -3
  37. package/dist/2d/models/shapes.js +0 -0
  38. package/dist/3d/components/physics/i-physics-world-3d.component.d.ts +0 -0
  39. package/dist/3d/components/physics/i-physics-world-3d.component.js +0 -0
  40. package/dist/3d/components/physics/i-raycast-vehicle.component.d.ts +2 -2
  41. package/dist/3d/components/physics/i-raycast-vehicle.component.js +0 -0
  42. package/dist/3d/components/physics/i-rigid-body-3d.component.d.ts +0 -0
  43. package/dist/3d/components/physics/i-rigid-body-3d.component.js +0 -0
  44. package/dist/3d/components/physics/i-trigger-3d.component.d.ts +0 -0
  45. package/dist/3d/components/physics/i-trigger-3d.component.js +0 -0
  46. package/dist/3d/components/rendering/i-camera.component.d.ts +0 -0
  47. package/dist/3d/components/rendering/i-camera.component.js +0 -0
  48. package/dist/3d/components/rendering/i-display-object-3d.component.d.ts +0 -0
  49. package/dist/3d/components/rendering/i-display-object-3d.component.js +0 -0
  50. package/dist/3d/components/rendering/i-renderer-3d.component.d.ts +0 -0
  51. package/dist/3d/components/rendering/i-renderer-3d.component.js +0 -0
  52. package/dist/3d/components/rendering/i-visual-scene-3d.component.d.ts +0 -0
  53. package/dist/3d/components/rendering/i-visual-scene-3d.component.js +0 -0
  54. package/dist/3d/entities/controllers/animators/camera-3d.animator.d.ts +1 -1
  55. package/dist/3d/entities/controllers/animators/camera-3d.animator.js +0 -0
  56. package/dist/3d/entities/controllers/animators/entity-3d-positioning.animator.d.ts +1 -1
  57. package/dist/3d/entities/controllers/animators/entity-3d-positioning.animator.js +0 -0
  58. package/dist/3d/entities/controllers/input/car-keyboard-handling.controller.d.ts +3 -3
  59. package/dist/3d/entities/controllers/input/car-keyboard-handling.controller.js +3 -3
  60. package/dist/3d/entities/controllers/input/free-camera.controller.d.ts +24 -13
  61. package/dist/3d/entities/controllers/input/free-camera.controller.js +65 -44
  62. package/dist/3d/entities/controllers/input/gg-car-keyboard-handling.controller.d.ts +2 -2
  63. package/dist/3d/entities/controllers/input/gg-car-keyboard-handling.controller.js +0 -0
  64. package/dist/3d/entities/controllers/input/orbit-camera.controller.d.ts +21 -2
  65. package/dist/3d/entities/controllers/input/orbit-camera.controller.js +35 -18
  66. package/dist/3d/entities/entity-3d.d.ts +0 -0
  67. package/dist/3d/entities/entity-3d.js +25 -25
  68. package/dist/3d/entities/gg-car/gg-car.entity.d.ts +1 -1
  69. package/dist/3d/entities/gg-car/gg-car.entity.js +16 -16
  70. package/dist/3d/entities/i-renderable-3d.entity.d.ts +0 -0
  71. package/dist/3d/entities/i-renderable-3d.entity.js +0 -0
  72. package/dist/3d/entities/map-graph-3d.entity.d.ts +7 -3
  73. package/dist/3d/entities/map-graph-3d.entity.js +63 -22
  74. package/dist/3d/entities/raycast-vehicle-3d.entity.d.ts +4 -4
  75. package/dist/3d/entities/raycast-vehicle-3d.entity.js +41 -41
  76. package/dist/3d/entities/renderer-3d.entity.d.ts +0 -0
  77. package/dist/3d/entities/renderer-3d.entity.js +0 -0
  78. package/dist/3d/entities/trigger-3d.entity.d.ts +0 -0
  79. package/dist/3d/entities/trigger-3d.entity.js +11 -11
  80. package/dist/3d/factories.d.ts +1 -1
  81. package/dist/3d/factories.js +0 -0
  82. package/dist/3d/gg-3d-world.d.ts +3 -3
  83. package/dist/3d/gg-3d-world.js +0 -0
  84. package/dist/3d/index.d.ts +0 -0
  85. package/dist/3d/index.js +0 -0
  86. package/dist/3d/interfaces/i-positionable-3d.d.ts +0 -0
  87. package/dist/3d/interfaces/i-positionable-3d.js +0 -0
  88. package/dist/3d/loader.d.ts +4 -4
  89. package/dist/3d/loader.js +7 -7
  90. package/dist/3d/loaders.d.ts +0 -0
  91. package/dist/3d/loaders.js +0 -0
  92. package/dist/3d/models/body-options.d.ts +1 -1
  93. package/dist/3d/models/body-options.js +0 -0
  94. package/dist/3d/models/gg-meta.d.ts +4 -4
  95. package/dist/3d/models/gg-meta.js +0 -0
  96. package/dist/3d/models/shapes.d.ts +6 -4
  97. package/dist/3d/models/shapes.js +0 -0
  98. package/dist/base/clock/global-clock.d.ts +0 -0
  99. package/dist/base/clock/global-clock.js +8 -8
  100. package/dist/base/clock/i-clock.d.ts +0 -0
  101. package/dist/base/clock/i-clock.js +0 -0
  102. package/dist/base/clock/pausable-clock.d.ts +2 -1
  103. package/dist/base/clock/pausable-clock.js +35 -31
  104. package/dist/base/components/i-component.d.ts +0 -0
  105. package/dist/base/components/i-component.js +0 -0
  106. package/dist/base/components/i-world-component.d.ts +0 -0
  107. package/dist/base/components/i-world-component.js +0 -0
  108. package/dist/base/components/physics/i-body.component.d.ts +0 -0
  109. package/dist/base/components/physics/i-body.component.js +0 -0
  110. package/dist/base/components/physics/i-physics-world.component.d.ts +0 -0
  111. package/dist/base/components/physics/i-physics-world.component.js +0 -0
  112. package/dist/base/components/physics/i-rigid-body.component.d.ts +0 -0
  113. package/dist/base/components/physics/i-rigid-body.component.js +0 -0
  114. package/dist/base/components/physics/i-trigger.component.d.ts +0 -0
  115. package/dist/base/components/physics/i-trigger.component.js +0 -0
  116. package/dist/base/components/rendering/i-display-object.component.d.ts +0 -0
  117. package/dist/base/components/rendering/i-display-object.component.js +0 -0
  118. package/dist/base/components/rendering/i-renderer.component.d.ts +1 -1
  119. package/dist/base/components/rendering/i-renderer.component.js +0 -0
  120. package/dist/base/components/rendering/i-visual-scene.component.d.ts +0 -0
  121. package/dist/base/components/rendering/i-visual-scene.component.js +0 -0
  122. package/dist/base/data-structures/bitmask.d.ts +0 -0
  123. package/dist/base/data-structures/bitmask.js +0 -0
  124. package/dist/base/data-structures/graph.d.ts +0 -0
  125. package/dist/base/data-structures/graph.js +4 -4
  126. package/dist/base/entities/controllers/animation-mixer.d.ts +1 -1
  127. package/dist/base/entities/controllers/animation-mixer.js +27 -27
  128. package/dist/base/entities/controllers/inline-controller.d.ts +0 -0
  129. package/dist/base/entities/controllers/inline-controller.js +0 -0
  130. package/dist/base/entities/i-entity.d.ts +0 -0
  131. package/dist/base/entities/i-entity.js +0 -0
  132. package/dist/base/entities/i-renderable.entity.d.ts +0 -0
  133. package/dist/base/entities/i-renderable.entity.js +0 -0
  134. package/dist/base/entities/i-renderer.entity.d.ts +0 -0
  135. package/dist/base/entities/i-renderer.entity.js +15 -15
  136. package/dist/base/gg-world.d.ts +3 -2
  137. package/dist/base/gg-world.js +5 -3
  138. package/dist/base/index.d.ts +1 -0
  139. package/dist/base/index.js +1 -0
  140. package/dist/base/inputs/direction.keyboard.input.d.ts +2 -2
  141. package/dist/base/inputs/direction.keyboard.input.js +6 -6
  142. package/dist/base/inputs/i-input.d.ts +0 -0
  143. package/dist/base/inputs/i-input.js +0 -0
  144. package/dist/base/inputs/keyboard.input.d.ts +0 -0
  145. package/dist/base/inputs/keyboard.input.js +0 -0
  146. package/dist/base/inputs/mouse.input.d.ts +2 -1
  147. package/dist/base/inputs/mouse.input.js +21 -18
  148. package/dist/base/interfaces/i-positionable.d.ts +0 -0
  149. package/dist/base/interfaces/i-positionable.js +0 -0
  150. package/dist/base/math/box.d.ts +0 -0
  151. package/dist/base/math/box.js +0 -0
  152. package/dist/base/math/matrix4.d.ts +0 -0
  153. package/dist/base/math/matrix4.js +0 -0
  154. package/dist/base/math/numbers.d.ts +0 -0
  155. package/dist/base/math/numbers.js +0 -0
  156. package/dist/base/math/point2.d.ts +0 -0
  157. package/dist/base/math/point2.js +0 -0
  158. package/dist/base/math/point3.d.ts +0 -0
  159. package/dist/base/math/point3.js +0 -0
  160. package/dist/base/math/quaternion.d.ts +6 -0
  161. package/dist/base/math/quaternion.js +38 -0
  162. package/dist/base/math/splines.d.ts +0 -0
  163. package/dist/base/math/splines.js +0 -0
  164. package/dist/base/models/axis-directions.d.ts +3 -3
  165. package/dist/base/models/axis-directions.js +0 -0
  166. package/dist/base/models/body-options.d.ts +2 -2
  167. package/dist/base/models/body-options.js +0 -0
  168. package/dist/base/models/geometry-nodes.d.ts +3 -3
  169. package/dist/base/models/geometry-nodes.js +0 -0
  170. package/dist/base/models/points.d.ts +5 -5
  171. package/dist/base/models/points.js +0 -0
  172. package/dist/base/pipes/gg-elastic.pipe.d.ts +5 -0
  173. package/dist/base/pipes/gg-elastic.pipe.js +44 -0
  174. package/dist/dev/gg-console.ui.d.ts +0 -0
  175. package/dist/dev/gg-console.ui.js +0 -0
  176. package/dist/dev/gg-debugger.ui.d.ts +0 -0
  177. package/dist/dev/gg-debugger.ui.js +0 -0
  178. package/dist/dev/gg-static.d.ts +0 -0
  179. package/dist/dev/gg-static.js +46 -46
  180. package/dist/dev/index.d.ts +0 -0
  181. package/dist/dev/index.js +0 -0
  182. package/dist/dev/performance-meter.entity.d.ts +0 -0
  183. package/dist/dev/performance-meter.entity.js +6 -6
  184. package/dist/index.d.ts +0 -0
  185. package/dist/index.js +0 -0
  186. package/package.json +7 -7
  187. package/tsconfig.json +0 -0
@@ -7,25 +7,25 @@ export declare enum CachingStrategy {
7
7
  Files = 1,
8
8
  Entities = 2
9
9
  }
10
- export declare type LoadOptions = {
10
+ export type LoadOptions = {
11
11
  cachingStrategy: CachingStrategy;
12
12
  position: Point3;
13
13
  rotation: Point4;
14
14
  loadProps: boolean;
15
15
  propsPath?: string;
16
16
  };
17
- export declare type LoadResourcesResult<VTypeDoc extends VisualTypeDocRepo3D = VisualTypeDocRepo3D, PTypeDoc extends PhysicsTypeDocRepo3D = PhysicsTypeDocRepo3D> = {
17
+ export type LoadResourcesResult<VTypeDoc extends VisualTypeDocRepo3D = VisualTypeDocRepo3D, PTypeDoc extends PhysicsTypeDocRepo3D = PhysicsTypeDocRepo3D> = {
18
18
  resources: {
19
19
  object3D: VTypeDoc['displayObject'] | null;
20
20
  body: PTypeDoc['rigidBody'] | null;
21
21
  }[];
22
22
  meta: GgMeta;
23
23
  };
24
- export declare type LoadResult<VTypeDoc extends VisualTypeDocRepo3D = VisualTypeDocRepo3D, PTypeDoc extends PhysicsTypeDocRepo3D = PhysicsTypeDocRepo3D> = {
24
+ export type LoadResult<VTypeDoc extends VisualTypeDocRepo3D = VisualTypeDocRepo3D, PTypeDoc extends PhysicsTypeDocRepo3D = PhysicsTypeDocRepo3D> = {
25
25
  entities: Entity3d<VTypeDoc, PTypeDoc>[];
26
26
  meta: GgMeta;
27
27
  };
28
- export declare type LoadResultWithProps<VTypeDoc extends VisualTypeDocRepo3D = VisualTypeDocRepo3D, PTypeDoc extends PhysicsTypeDocRepo3D = PhysicsTypeDocRepo3D> = LoadResult<VTypeDoc, PTypeDoc> & {
28
+ export type LoadResultWithProps<VTypeDoc extends VisualTypeDocRepo3D = VisualTypeDocRepo3D, PTypeDoc extends PhysicsTypeDocRepo3D = PhysicsTypeDocRepo3D> = LoadResult<VTypeDoc, PTypeDoc> & {
29
29
  props?: LoadResult<VTypeDoc, PTypeDoc>[];
30
30
  };
31
31
  export declare class Gg3dLoader<VTypeDoc extends VisualTypeDocRepo3D = VisualTypeDocRepo3D, PTypeDoc extends PhysicsTypeDocRepo3D = PhysicsTypeDocRepo3D> {
package/dist/3d/loader.js CHANGED
@@ -22,7 +22,7 @@ const defaultLoadOptions = {
22
22
  loadProps: true,
23
23
  };
24
24
  const cloneLoadResourcesResult = (loadResult) => ({
25
- meta: loadResult.meta,
25
+ meta: loadResult.meta, // TODO deep clone it
26
26
  resources: loadResult.resources.map(({ object3D, body }) => ({
27
27
  object3D: object3D && object3D.clone(),
28
28
  body: body && body.clone(),
@@ -34,8 +34,8 @@ export class Gg3dLoader {
34
34
  this.filesCache = new Map();
35
35
  this.loadResultCache = new Map();
36
36
  }
37
- loadGgGlbFiles(path, useCache = false) {
38
- return __awaiter(this, void 0, void 0, function* () {
37
+ loadGgGlbFiles(path_1) {
38
+ return __awaiter(this, arguments, void 0, function* (path, useCache = false) {
39
39
  if (useCache && this.filesCache.has(path)) {
40
40
  return this.filesCache.get(path);
41
41
  }
@@ -55,8 +55,8 @@ export class Gg3dLoader {
55
55
  return result;
56
56
  });
57
57
  }
58
- loadGgGlbResources(path, cachingStrategy = CachingStrategy.Nothing) {
59
- return __awaiter(this, void 0, void 0, function* () {
58
+ loadGgGlbResources(path_1) {
59
+ return __awaiter(this, arguments, void 0, function* (path, cachingStrategy = CachingStrategy.Nothing) {
60
60
  if (cachingStrategy == CachingStrategy.Entities && this.loadResultCache.has(path)) {
61
61
  const cached = this.loadResultCache.get(path);
62
62
  const cachedResult = cached instanceof Promise ? yield cached : cached;
@@ -94,8 +94,8 @@ export class Gg3dLoader {
94
94
  return result;
95
95
  });
96
96
  }
97
- loadGgGlb(path, options = defaultLoadOptions) {
98
- return __awaiter(this, void 0, void 0, function* () {
97
+ loadGgGlb(path_1) {
98
+ return __awaiter(this, arguments, void 0, function* (path, options = defaultLoadOptions) {
99
99
  const loadOptions = Object.assign(Object.assign({}, defaultLoadOptions), options);
100
100
  const { resources, meta } = yield this.loadGgGlbResources(path, loadOptions.cachingStrategy);
101
101
  const result = {
File without changes
File without changes
@@ -2,6 +2,6 @@ import { BodyOptions, DebugBodySettings } from '../../base';
2
2
  import { Shape3DDescriptor } from './shapes';
3
3
  export interface Body3DOptions extends BodyOptions {
4
4
  }
5
- export declare type DebugBody3DSettings = DebugBodySettings & {
5
+ export type DebugBody3DSettings = DebugBodySettings & {
6
6
  shape: Shape3DDescriptor;
7
7
  };
File without changes
@@ -1,21 +1,21 @@
1
1
  import { Point3, Point4 } from '../../base';
2
2
  import { BodyShape3DDescriptor } from './shapes';
3
- export declare type GgDummy = {
3
+ export type GgDummy = {
4
4
  name: string;
5
5
  position: Point3;
6
6
  rotation: Point4;
7
7
  } & any;
8
- export declare type GgCurve = {
8
+ export type GgCurve = {
9
9
  name: string;
10
10
  cyclic: boolean;
11
11
  points: Point3[];
12
12
  } & any;
13
- export declare type GgRigidBody = {
13
+ export type GgRigidBody = {
14
14
  name: string;
15
15
  position: Point3;
16
16
  rotation: Point4;
17
17
  } & BodyShape3DDescriptor;
18
- export declare type GgMeta = {
18
+ export type GgMeta = {
19
19
  dummies: GgDummy[];
20
20
  curves: GgCurve[];
21
21
  rigidBodies: GgRigidBody[];
File without changes
@@ -1,6 +1,8 @@
1
1
  import { Point2, Point3, Point4 } from '../../base';
2
2
  import { Body3DOptions } from './body-options';
3
- export declare type Shape3DDescriptor = {
3
+ export type Shape3DDescriptor = {
4
+ collisionMargin?: number;
5
+ } & ({
4
6
  shape: 'PLANE';
5
7
  } | {
6
8
  shape: 'BOX';
@@ -30,8 +32,8 @@ export declare type Shape3DDescriptor = {
30
32
  shape: 'MESH';
31
33
  vertices: Point3[];
32
34
  faces: [number, number, number][];
33
- };
34
- export declare type Shape3DMeshDescriptor = {
35
+ });
36
+ export type Shape3DMeshDescriptor = {
35
37
  shape: 'PLANE';
36
38
  dimensions?: Point2;
37
39
  segments?: Point2;
@@ -71,7 +73,7 @@ export declare type Shape3DMeshDescriptor = {
71
73
  vertices: Point3[];
72
74
  faces: [number, number, number][];
73
75
  };
74
- export declare type BodyShape3DDescriptor = {
76
+ export type BodyShape3DDescriptor = {
75
77
  shape: Shape3DDescriptor;
76
78
  body: Partial<Body3DOptions>;
77
79
  };
File without changes
File without changes
@@ -6,14 +6,6 @@ import { PausableClock } from './pausable-clock';
6
6
  * Starts as soon as accessed and counts time from 01/01/1970
7
7
  */
8
8
  export class GgGlobalClock {
9
- constructor() {
10
- this._tick$ = new Subject();
11
- let oldRelativeTime = this.elapsedTime;
12
- of(undefined, animationFrameScheduler)
13
- .pipe(repeat())
14
- .pipe(map(() => [oldRelativeTime, this.elapsedTime]), tap(([_, cur]) => (oldRelativeTime = cur)))
15
- .subscribe(this._tick$);
16
- }
17
9
  static get instance() {
18
10
  if (!GgGlobalClock._instance) {
19
11
  GgGlobalClock._instance = new GgGlobalClock();
@@ -29,4 +21,12 @@ export class GgGlobalClock {
29
21
  createChildClock(autoStart) {
30
22
  return new PausableClock(autoStart, this);
31
23
  }
24
+ constructor() {
25
+ this._tick$ = new Subject();
26
+ let oldRelativeTime = this.elapsedTime;
27
+ of(undefined, animationFrameScheduler)
28
+ .pipe(repeat())
29
+ .pipe(map(() => [oldRelativeTime, this.elapsedTime]), tap(([_, cur]) => (oldRelativeTime = cur)))
30
+ .subscribe(this._tick$);
31
+ }
32
32
  }
File without changes
File without changes
@@ -1,4 +1,4 @@
1
- import { Observable } from 'rxjs';
1
+ import { Observable, Subject } from 'rxjs';
2
2
  import { IClock } from './i-clock';
3
3
  /**
4
4
  * A class providing the ability to track time, fire ticks, provide time elapsed, and tick delta with the ability to suspend/resume it.
@@ -40,6 +40,7 @@ export declare class PausableClock implements IClock {
40
40
  * Tick rate limiter. If set to 0 - tick rate is unlimited, 15 means "allow at most 15 ticks per second"
41
41
  */
42
42
  tickRateLimit: number;
43
+ readonly paused$: Subject<boolean>;
43
44
  private startedAt;
44
45
  private oldRelativeTime;
45
46
  private pausedAt;
@@ -5,37 +5,6 @@ import { GgGlobalClock } from './global-clock';
5
5
  * A class providing the ability to track time, fire ticks, provide time elapsed, and tick delta with the ability to suspend/resume it.
6
6
  */
7
7
  export class PausableClock {
8
- /**
9
- * Constructs a new PausableClock instance.
10
- * @param autoStart Indicates whether the clock should start automatically upon creation.
11
- * @param parentClock The parent clock to synchronize with. Defaults to GgGlobalClock instance.
12
- */
13
- constructor(autoStart = false, parentClock = GgGlobalClock.instance) {
14
- this.parentClock = parentClock;
15
- this.tickSub = null;
16
- this._internalTick$ = new Subject();
17
- this._tick$ = new Subject();
18
- /**
19
- * Tick rate limiter. If set to 0 - tick rate is unlimited, 15 means "allow at most 15 ticks per second"
20
- */
21
- this.tickRateLimit = 0;
22
- // State variables
23
- this.startedAt = -1;
24
- this.oldRelativeTime = 0; // "elapsed", emitted on last tick
25
- this.pausedAt = -1;
26
- this.lastStopElapsed = 0;
27
- this._timeScale = 1;
28
- this.pausedByTimescale = false;
29
- this.lastFiredTickElapsed = 0;
30
- if (autoStart) {
31
- this.start();
32
- }
33
- this._internalTick$
34
- .pipe(map(([_, newTime]) => [newTime, newTime - this.lastFiredTickElapsed]), filter(([elapsed]) => !this.tickRateLimit ||
35
- Math.floor((this.lastFiredTickElapsed * this.tickRateLimit) / 1000) <
36
- Math.floor((elapsed * this.tickRateLimit) / 1000)), tap(([elapsed]) => (this.lastFiredTickElapsed = elapsed)))
37
- .subscribe(this._tick$);
38
- }
39
8
  /**
40
9
  * Observable stream of ticks, emitting an array containing the current time and the tick delta.
41
10
  */
@@ -101,6 +70,39 @@ export class PausableClock {
101
70
  }
102
71
  return this._timeScale * (this.parentClock.elapsedTime - this.startedAt);
103
72
  }
73
+ /**
74
+ * Constructs a new PausableClock instance.
75
+ * @param autoStart Indicates whether the clock should start automatically upon creation.
76
+ * @param parentClock The parent clock to synchronize with. Defaults to GgGlobalClock instance.
77
+ */
78
+ constructor(autoStart = false, parentClock = GgGlobalClock.instance) {
79
+ this.parentClock = parentClock;
80
+ this.tickSub = null;
81
+ this._internalTick$ = new Subject();
82
+ this._tick$ = new Subject();
83
+ /**
84
+ * Tick rate limiter. If set to 0 - tick rate is unlimited, 15 means "allow at most 15 ticks per second"
85
+ */
86
+ this.tickRateLimit = 0;
87
+ // events
88
+ this.paused$ = new Subject();
89
+ // State variables
90
+ this.startedAt = -1;
91
+ this.oldRelativeTime = 0; // "elapsed", emitted on last tick
92
+ this.pausedAt = -1;
93
+ this.lastStopElapsed = 0;
94
+ this._timeScale = 1;
95
+ this.pausedByTimescale = false;
96
+ this.lastFiredTickElapsed = 0;
97
+ if (autoStart) {
98
+ this.start();
99
+ }
100
+ this._internalTick$
101
+ .pipe(map(([_, newTime]) => [newTime, newTime - this.lastFiredTickElapsed]), filter(([elapsed]) => !this.tickRateLimit ||
102
+ Math.floor((this.lastFiredTickElapsed * this.tickRateLimit) / 1000) <
103
+ Math.floor((elapsed * this.tickRateLimit) / 1000)), tap(([elapsed]) => (this.lastFiredTickElapsed = elapsed)))
104
+ .subscribe(this._tick$);
105
+ }
104
106
  /**
105
107
  * Creates a child clock.
106
108
  * @param autoStart Indicates whether the child clock should start automatically.
@@ -135,6 +137,7 @@ export class PausableClock {
135
137
  this.stopListeningTicks();
136
138
  this.pausedAt = this.parentClock.elapsedTime;
137
139
  this.pausedByTimescale = false;
140
+ this.paused$.next(true);
138
141
  }
139
142
  /**
140
143
  * Resumes the clock.
@@ -146,6 +149,7 @@ export class PausableClock {
146
149
  this.startedAt += this.parentClock.elapsedTime - this.pausedAt;
147
150
  this.pausedAt = -1;
148
151
  this.startListeningTicks();
152
+ this.paused$.next(false);
149
153
  }
150
154
  /**
151
155
  * Starts listening for ticks from the parent clock.
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -13,7 +13,7 @@ import { IVisualSceneComponent } from './i-visual-scene.component';
13
13
  * @property {number} [forceResolution] - Specifies the pixel resolution. Not set by default, which means "use device resolution".
14
14
  * @property {boolean} antialias - Specifies whether antialiasing is turned on/off. true by default.
15
15
  */
16
- export declare type RendererOptions = {
16
+ export type RendererOptions = {
17
17
  transparent: boolean;
18
18
  background: number;
19
19
  size: Point2 | 'fullscreen' | ((pageSize: Point2) => Point2) | Observable<Point2>;
File without changes
File without changes
File without changes
@@ -1,8 +1,4 @@
1
1
  export class Graph {
2
- constructor(data) {
3
- this.data = data;
4
- this.adjacent = new Set();
5
- }
6
2
  /**
7
3
  * Creates a new Graph instance from an array of elements, where each element in the array is a node in the graph.
8
4
  * The first element of the array is used as the root node of the graph.
@@ -47,6 +43,10 @@ export class Graph {
47
43
  }
48
44
  return nodes[0][0];
49
45
  }
46
+ constructor(data) {
47
+ this.data = data;
48
+ this.adjacent = new Set();
49
+ }
50
50
  addAdjacent(node) {
51
51
  if (this.adjacent.has(node)) {
52
52
  return false;
@@ -1,7 +1,7 @@
1
1
  import { IEntity } from '../i-entity';
2
2
  import { Observable, Subject } from 'rxjs';
3
3
  import { GgWorld, PhysicsTypeDocRepo, VisualTypeDocRepo } from '../../gg-world';
4
- export declare type AnimationFunction<T> = (elapsed: number, delta: number) => T;
4
+ export type AnimationFunction<T> = (elapsed: number, delta: number) => T;
5
5
  /**
6
6
  * A class that performs property animations for a specific type `T` by using provided animation function.
7
7
  * Supports smooth transition between animation function by interpolating between values over time.
@@ -8,33 +8,6 @@ import { map, tap } from 'rxjs/operators';
8
8
  * The animation function can be changed with `transitAnimationFunction` or `transitFromStaticState`.
9
9
  */
10
10
  export class AnimationMixer extends IEntity {
11
- /**
12
- * Creates a new `AnimationMixer` entity.
13
- * @param _animationFunction The initial motion control function that determines the animation.
14
- * @param _lerp The linear interpolation between two values of type `T`.
15
- */
16
- constructor(_animationFunction, _lerp = (a, b, t) => b) {
17
- super();
18
- this._animationFunction = _animationFunction;
19
- this._lerp = _lerp;
20
- this.tickOrder = TickOrder.ANIMATION_MIXERS;
21
- /**
22
- * A subject that emits the current value of the animation on every tick.
23
- */
24
- this._value$ = new Subject();
25
- /**
26
- * The current transition time reference `[elapsed, delta]` that interpolates between the old and new functions.
27
- */
28
- this._currentTransitionK = [0, 0];
29
- /**
30
- * The current transition subscription, which is null if no transition is currently active.
31
- */
32
- this._currentTransition = null;
33
- /**
34
- * A behavior subject that emits whether the animator is currently in a transition.
35
- */
36
- this._isInTransition$ = new BehaviorSubject(false);
37
- }
38
11
  /**
39
12
  * Gets an observable of the current value of the animation.
40
13
  */
@@ -76,6 +49,33 @@ export class AnimationMixer extends IEntity {
76
49
  this._currentTransition = value;
77
50
  this._isInTransition$.next(!!value);
78
51
  }
52
+ /**
53
+ * Creates a new `AnimationMixer` entity.
54
+ * @param _animationFunction The initial motion control function that determines the animation.
55
+ * @param _lerp The linear interpolation between two values of type `T`.
56
+ */
57
+ constructor(_animationFunction, _lerp = (a, b, t) => b) {
58
+ super();
59
+ this._animationFunction = _animationFunction;
60
+ this._lerp = _lerp;
61
+ this.tickOrder = TickOrder.ANIMATION_MIXERS;
62
+ /**
63
+ * A subject that emits the current value of the animation on every tick.
64
+ */
65
+ this._value$ = new Subject();
66
+ /**
67
+ * The current transition time reference `[elapsed, delta]` that interpolates between the old and new functions.
68
+ */
69
+ this._currentTransitionK = [0, 0];
70
+ /**
71
+ * The current transition subscription, which is null if no transition is currently active.
72
+ */
73
+ this._currentTransition = null;
74
+ /**
75
+ * A behavior subject that emits whether the animator is currently in a transition.
76
+ */
77
+ this._isInTransition$ = new BehaviorSubject(false);
78
+ }
79
79
  /**
80
80
  * Set output to static value and smoothly transit to new control function
81
81
  * @param newFunc a new function
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -6,21 +6,6 @@ import { distinctUntilChanged, map } from 'rxjs/operators';
6
6
  * @class
7
7
  */
8
8
  export class IRendererEntity extends IEntity {
9
- /**
10
- Initializes a new instance of the BaseGgRenderer class.
11
- * @param renderer
12
- */
13
- constructor(renderer) {
14
- super();
15
- this.renderer = renderer;
16
- this.tickOrder = TickOrder.RENDERING;
17
- /** Represents the current size of the renderer. */
18
- this._rendererSize$ = new BehaviorSubject(null);
19
- this.addComponents(renderer);
20
- this.tick$.subscribe(() => {
21
- this.renderer.render();
22
- });
23
- }
24
9
  /**
25
10
  * Gets the observable that represents the current size of the renderer.
26
11
  * @returns {Observable<Point2 | null>} - An observable that represents the size of the renderer.
@@ -46,6 +31,21 @@ export class IRendererEntity extends IEntity {
46
31
  set physicsDebugViewActive(value) {
47
32
  this.renderer.physicsDebugViewActive = value;
48
33
  }
34
+ /**
35
+ Initializes a new instance of the BaseGgRenderer class.
36
+ * @param renderer
37
+ */
38
+ constructor(renderer) {
39
+ super();
40
+ this.renderer = renderer;
41
+ this.tickOrder = TickOrder.RENDERING;
42
+ /** Represents the current size of the renderer. */
43
+ this._rendererSize$ = new BehaviorSubject(null);
44
+ this.addComponents(renderer);
45
+ this.tick$.subscribe(() => {
46
+ this.renderer.render();
47
+ });
48
+ }
49
49
  onSpawned(world) {
50
50
  this._rendererSize$.next(null);
51
51
  if (this.rendererOptions.size == 'fullscreen' || typeof this.rendererOptions.size === 'function') {
@@ -1,12 +1,12 @@
1
1
  import { IDisplayObjectComponent, IEntity, IPhysicsWorldComponent, IPositionable, IRenderableEntity, IRendererComponent, IRigidBodyComponent, ITriggerComponent, IVisualSceneComponent, KeyboardInput, PausableClock } from '../base';
2
2
  import { Subject } from 'rxjs';
3
- export declare type VisualTypeDocRepo<D, R> = {
3
+ export type VisualTypeDocRepo<D, R> = {
4
4
  factory: unknown;
5
5
  displayObject: IDisplayObjectComponent<D, R>;
6
6
  renderer: IRendererComponent<D, R>;
7
7
  rendererExtraOpts: {};
8
8
  };
9
- export declare type PhysicsTypeDocRepo<D, R> = {
9
+ export type PhysicsTypeDocRepo<D, R> = {
10
10
  factory: unknown;
11
11
  rigidBody: IRigidBodyComponent<D, R>;
12
12
  trigger: ITriggerComponent<D, R>;
@@ -25,6 +25,7 @@ export declare abstract class GgWorld<D, R, VTypeDoc extends VisualTypeDocRepo<D
25
25
  readonly tickStarted$: Subject<void>;
26
26
  readonly tickForwardTo$: Subject<IEntity | 'PHYSICS_WORLD'>;
27
27
  readonly tickForwardedTo$: Subject<IEntity | 'PHYSICS_WORLD'>;
28
+ readonly paused$: Subject<boolean>;
28
29
  protected constructor(visualScene: VS, physicsWorld: PW);
29
30
  init(): Promise<void>;
30
31
  start(): void;
@@ -11,6 +11,9 @@ import { GgGlobalClock, IRendererEntity, KeyboardInput, TickOrder, } from '../ba
11
11
  import { lastValueFrom, Subject, take } from 'rxjs';
12
12
  import { PerformanceMeterEntity } from '../dev';
13
13
  export class GgWorld {
14
+ static get documentWorlds() {
15
+ return [...GgWorld._documentWorlds];
16
+ }
14
17
  constructor(visualScene, physicsWorld) {
15
18
  this.visualScene = visualScene;
16
19
  this.physicsWorld = physicsWorld;
@@ -24,6 +27,7 @@ export class GgWorld {
24
27
  this.tickStarted$ = new Subject();
25
28
  this.tickForwardTo$ = new Subject();
26
29
  this.tickForwardedTo$ = new Subject();
30
+ this.paused$ = new Subject();
27
31
  GgWorld._documentWorlds.push(this);
28
32
  this.keyboardInput.start();
29
33
  if (window.ggstatic) {
@@ -89,9 +93,7 @@ export class GgWorld {
89
93
  'entity in world. Arguments are samples amount (20 by default) and "peak" or "avg" choice, both arguments are ' +
90
94
  'optional. "avg" report sorts entities by average time consumed, "peak" records highest value for each entity');
91
95
  }
92
- }
93
- static get documentWorlds() {
94
- return [...GgWorld._documentWorlds];
96
+ this.worldClock.paused$.subscribe(this.paused$);
95
97
  }
96
98
  init() {
97
99
  return __awaiter(this, void 0, void 0, function* () {
@@ -33,4 +33,5 @@ export * from './math/quaternion';
33
33
  export * from './math/numbers';
34
34
  export * from './math/matrix4';
35
35
  export * from './math/splines';
36
+ export * from './pipes/gg-elastic.pipe';
36
37
  export * from './gg-world';
@@ -33,4 +33,5 @@ export * from './math/quaternion';
33
33
  export * from './math/numbers';
34
34
  export * from './math/matrix4';
35
35
  export * from './math/splines';
36
+ export * from './pipes/gg-elastic.pipe';
36
37
  export * from './gg-world';
@@ -4,11 +4,11 @@ import { IInput } from './i-input';
4
4
  /**
5
5
  * The type representing desired keymap for DirectionKeyboardInput
6
6
  */
7
- export declare type DirectionKeyboardKeymap = 'arrows' | 'wasd' | 'wasd+arrows';
7
+ export type DirectionKeyboardKeymap = 'arrows' | 'wasd' | 'wasd+arrows';
8
8
  /**
9
9
  * The type of DirectionKeyboardInput output value
10
10
  */
11
- export declare type DirectionKeyboardOutput = {
11
+ export type DirectionKeyboardOutput = {
12
12
  upDown?: boolean;
13
13
  leftRight?: boolean;
14
14
  };
@@ -6,6 +6,12 @@ import { IInput } from './i-input';
6
6
  * Supports two the most popular keyboard layouts: WASD and arrows.
7
7
  */
8
8
  export class DirectionKeyboardInput extends IInput {
9
+ /**
10
+ * Returns an observable that emits `DirectionKeyboardOutput` objects whenever the input changes.
11
+ */
12
+ get output$() {
13
+ return this._output$.asObservable();
14
+ }
9
15
  /**
10
16
  * Creates a new instance of the `DirectionKeyboardInput` class.
11
17
  *
@@ -21,12 +27,6 @@ export class DirectionKeyboardInput extends IInput {
21
27
  */
22
28
  this._output$ = new Subject();
23
29
  }
24
- /**
25
- * Returns an observable that emits `DirectionKeyboardOutput` objects whenever the input changes.
26
- */
27
- get output$() {
28
- return this._output$.asObservable();
29
- }
30
30
  /**
31
31
  * Called when the input handling should start.
32
32
  */
File without changes
File without changes
File without changes
File without changes