@gg-web-engine/core 0.0.2 → 0.0.4

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 (72) hide show
  1. package/dist/2d/entities/controllers/entity-2d-positioning.animator.d.ts +16 -0
  2. package/dist/2d/entities/controllers/entity-2d-positioning.animator.js +26 -0
  3. package/dist/2d/entities/gg-2d-entity.d.ts +12 -6
  4. package/dist/2d/entities/gg-2d-entity.js +52 -20
  5. package/dist/2d/gg-2d-world.d.ts +3 -0
  6. package/dist/2d/gg-2d-world.js +11 -0
  7. package/dist/3d/controllers/car-keyboard.controller.d.ts +10 -10
  8. package/dist/3d/controllers/car-keyboard.controller.js +21 -20
  9. package/dist/3d/controllers/free-camera.controller.d.ts +8 -8
  10. package/dist/3d/entities/controllers/animators/camera-3d.animator.d.ts +17 -0
  11. package/dist/3d/entities/controllers/animators/camera-3d.animator.js +32 -0
  12. package/dist/3d/entities/controllers/animators/entity-3d-positioning.animator.d.ts +16 -0
  13. package/dist/3d/entities/controllers/animators/entity-3d-positioning.animator.js +26 -0
  14. package/dist/3d/entities/controllers/camera-3d.animator.d.ts +17 -0
  15. package/dist/3d/entities/controllers/camera-3d.animator.js +32 -0
  16. package/dist/3d/entities/controllers/entity-3d-positioning.animator.d.ts +16 -0
  17. package/dist/3d/entities/controllers/entity-3d-positioning.animator.js +26 -0
  18. package/dist/3d/entities/controllers/input/car-keyboard-handling.controller.d.ts +25 -0
  19. package/dist/3d/entities/controllers/input/car-keyboard-handling.controller.js +105 -0
  20. package/dist/3d/entities/controllers/input/free-camera.controller.d.ts +54 -0
  21. package/dist/3d/entities/controllers/input/free-camera.controller.js +102 -0
  22. package/dist/3d/entities/gg-3d-camera.entity.d.ts +2 -0
  23. package/dist/3d/entities/gg-3d-camera.entity.js +6 -0
  24. package/dist/3d/entities/gg-3d-entity.d.ts +7 -6
  25. package/dist/3d/entities/gg-3d-entity.js +21 -13
  26. package/dist/3d/entities/gg-3d-map-graph.entity.d.ts +10 -10
  27. package/dist/3d/entities/gg-3d-map-graph.entity.js +2 -3
  28. package/dist/3d/entities/gg-3d-raycast-vehicle.entity.d.ts +6 -5
  29. package/dist/3d/gg-3d-world.d.ts +3 -0
  30. package/dist/3d/gg-3d-world.js +12 -0
  31. package/dist/3d/inputs/car-keyboard.input.d.ts +25 -0
  32. package/dist/3d/inputs/car-keyboard.input.js +100 -0
  33. package/dist/3d/inputs/free-camera.input.d.ts +22 -0
  34. package/dist/3d/inputs/free-camera.input.js +80 -0
  35. package/dist/base/clock/clock.d.ts +25 -0
  36. package/dist/base/clock/clock.js +79 -0
  37. package/dist/base/clock/global-clock.d.ts +16 -0
  38. package/dist/base/clock/global-clock.js +36 -0
  39. package/dist/base/clock/i-clock.d.ts +7 -0
  40. package/dist/base/clock/i-clock.js +2 -0
  41. package/dist/base/clock/pausable-clock.d.ts +25 -0
  42. package/dist/base/clock/pausable-clock.js +79 -0
  43. package/dist/base/entities/base-gg-renderer.d.ts +3 -15
  44. package/dist/base/entities/base-gg-renderer.js +2 -30
  45. package/dist/base/entities/controllers/animation-mixer.d.ts +76 -0
  46. package/dist/base/entities/controllers/animation-mixer.js +143 -0
  47. package/dist/base/entities/gg-entity.d.ts +33 -1
  48. package/dist/base/entities/gg-entity.js +42 -1
  49. package/dist/base/entities/inline-controller.js +1 -7
  50. package/dist/base/entities/interfaces/i-tick-listener.d.ts +25 -1
  51. package/dist/base/entities/interfaces/i-tick-listener.js +17 -1
  52. package/dist/base/gg-viewport-manager.d.ts +4 -0
  53. package/dist/base/gg-world.d.ts +11 -6
  54. package/dist/base/gg-world.js +50 -31
  55. package/dist/base/inputs/direction.keyboard-input.d.ts +41 -0
  56. package/dist/base/inputs/direction.keyboard-input.js +85 -0
  57. package/dist/base/inputs/input.d.ts +50 -0
  58. package/dist/base/inputs/input.js +80 -0
  59. package/dist/base/inputs/keyboard.input.d.ts +45 -0
  60. package/dist/base/inputs/keyboard.input.js +130 -0
  61. package/dist/base/inputs/mouse.input.d.ts +57 -0
  62. package/dist/base/inputs/mouse.input.js +81 -0
  63. package/dist/base/math/matrix4.js +3 -3
  64. package/dist/base/math/point2.js +1 -1
  65. package/dist/base/math/point3.js +1 -1
  66. package/dist/base/math/quaternion.d.ts +83 -9
  67. package/dist/base/math/quaternion.js +93 -10
  68. package/dist/base/models/points.d.ts +9 -9
  69. package/dist/index.d.ts +13 -9
  70. package/dist/index.js +13 -9
  71. package/package.json +1 -1
  72. package/.prettierrc +0 -8
@@ -0,0 +1,16 @@
1
+ import { AnimationFunction, AnimationMixer } from '../../../base/entities/controllers/animation-mixer';
2
+ import { Point2 } from '../../../base/models/points';
3
+ import { Gg2dEntity } from '../gg-2d-entity';
4
+ import { Gg2dWorld } from '../../gg-2d-world';
5
+ declare type Positioning2d = {
6
+ position: Point2;
7
+ rotation: number;
8
+ };
9
+ export declare class Entity2dPositioningAnimator<T extends Gg2dEntity = Gg2dEntity> extends AnimationMixer<Positioning2d> {
10
+ entity: T;
11
+ protected _animationFunction: AnimationFunction<Positioning2d>;
12
+ constructor(entity: T, _animationFunction: AnimationFunction<Positioning2d>);
13
+ onSpawned(world: Gg2dWorld): void;
14
+ protected applyPositioning(value: Positioning2d): void;
15
+ }
16
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Entity2dPositioningAnimator = void 0;
4
+ const animation_mixer_1 = require("../../../base/entities/controllers/animation-mixer");
5
+ const rxjs_1 = require("rxjs");
6
+ const point2_1 = require("../../../base/math/point2");
7
+ const numbers_1 = require("../../../base/math/numbers");
8
+ class Entity2dPositioningAnimator extends animation_mixer_1.AnimationMixer {
9
+ constructor(entity, _animationFunction) {
10
+ super(_animationFunction, (a, b, t) => ({
11
+ position: point2_1.Pnt2.lerp(a.position, b.position, t),
12
+ rotation: (0, numbers_1.lerpNumber)(a.rotation, b.rotation, t),
13
+ }));
14
+ this.entity = entity;
15
+ this._animationFunction = _animationFunction;
16
+ }
17
+ onSpawned(world) {
18
+ super.onSpawned(world);
19
+ this.value$.pipe((0, rxjs_1.takeUntil)(this._onRemoved$)).subscribe(value => this.applyPositioning(value));
20
+ }
21
+ applyPositioning(value) {
22
+ this.entity.position = value.position;
23
+ this.entity.rotation = value.rotation;
24
+ }
25
+ }
26
+ exports.Entity2dPositioningAnimator = Entity2dPositioningAnimator;
@@ -1,18 +1,24 @@
1
- import { Subject } from 'rxjs';
2
1
  import { GgPositionable2dEntity } from './gg-positionable-2d-entity';
3
- import { ITickListener } from '../../base/entities/interfaces/i-tick-listener';
4
2
  import { Point2 } from '../../base/models/points';
5
3
  import { IGg2dBody, IGg2dObject } from '../interfaces';
6
4
  import { Gg2dWorld } from '../gg-2d-world';
7
- export declare class Gg2dEntity extends GgPositionable2dEntity implements ITickListener {
5
+ import { GGTickOrder } from '../../base/entities/gg-entity';
6
+ export declare class Gg2dEntity extends GgPositionable2dEntity {
8
7
  readonly object2D: IGg2dObject | null;
9
8
  readonly objectBody: IGg2dBody | null;
10
- readonly tick$: Subject<[number, number]>;
11
- readonly tickOrder = 750;
12
- private tickSub;
9
+ readonly tickOrder = GGTickOrder.OBJECTS_BINDING;
10
+ get position(): Point2;
13
11
  set position(value: Point2);
12
+ get rotation(): number;
14
13
  set rotation(value: number);
14
+ get scale(): Point2;
15
15
  set scale(value: Point2);
16
+ get visible(): boolean;
17
+ set visible(value: boolean);
18
+ /**
19
+ * Synchronize physics body transform with entity (and object2d if defined)
20
+ * */
21
+ protected runTransformBinding(objectBody: IGg2dBody, object2D: IGg2dObject | null): void;
16
22
  constructor(object2D: IGg2dObject | null, objectBody: IGg2dBody | null);
17
23
  onSpawned(world: Gg2dWorld): void;
18
24
  onRemoved(): void;
@@ -1,34 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Gg2dEntity = void 0;
4
- const rxjs_1 = require("rxjs");
5
4
  const gg_positionable_2d_entity_1 = require("./gg-positionable-2d-entity");
5
+ const gg_entity_1 = require("../../base/entities/gg-entity");
6
6
  class Gg2dEntity extends gg_positionable_2d_entity_1.GgPositionable2dEntity {
7
7
  constructor(object2D, objectBody) {
8
8
  super();
9
9
  this.object2D = object2D;
10
10
  this.objectBody = objectBody;
11
- this.tick$ = new rxjs_1.Subject();
12
- this.tickOrder = 750;
13
- this.tickSub = null;
14
- if (objectBody && object2D) {
15
- this.tickSub = this.tick$.subscribe(() => {
16
- // bind physics body transform to object transform
17
- const pos = objectBody.position;
18
- const rot = objectBody.rotation;
19
- object2D.position = pos;
20
- object2D.rotation = rot;
21
- this._position$.next(pos);
22
- this._rotation$.next(rot);
11
+ this.tickOrder = gg_entity_1.GGTickOrder.OBJECTS_BINDING;
12
+ if (objectBody) {
13
+ objectBody.entity = this;
14
+ this.tick$.subscribe(() => {
15
+ this.runTransformBinding(objectBody, object2D);
23
16
  });
17
+ this.runTransformBinding(objectBody, object2D);
18
+ this.name = objectBody.name;
24
19
  }
25
- else if (!objectBody && !object2D) {
26
- throw new Error('Cannot create entity without a sprite and a body');
20
+ else if (object2D) {
21
+ super.position = object2D.position;
22
+ super.rotation = object2D.rotation;
23
+ super.scale = object2D.scale;
24
+ this.name = object2D.name;
27
25
  }
28
- if (objectBody) {
29
- objectBody.entity = this;
26
+ else {
27
+ throw new Error('Cannot create entity without an object2D and a body');
30
28
  }
31
29
  }
30
+ get position() {
31
+ return super.position;
32
+ }
32
33
  set position(value) {
33
34
  if (this.object2D) {
34
35
  this.object2D.position = value;
@@ -38,6 +39,9 @@ class Gg2dEntity extends gg_positionable_2d_entity_1.GgPositionable2dEntity {
38
39
  }
39
40
  super.position = value;
40
41
  }
42
+ get rotation() {
43
+ return super.rotation;
44
+ }
41
45
  set rotation(value) {
42
46
  if (this.object2D) {
43
47
  this.object2D.rotation = value;
@@ -47,6 +51,9 @@ class Gg2dEntity extends gg_positionable_2d_entity_1.GgPositionable2dEntity {
47
51
  }
48
52
  super.rotation = value;
49
53
  }
54
+ get scale() {
55
+ return super.scale;
56
+ }
50
57
  set scale(value) {
51
58
  if (this.object2D) {
52
59
  this.object2D.scale = value;
@@ -56,6 +63,33 @@ class Gg2dEntity extends gg_positionable_2d_entity_1.GgPositionable2dEntity {
56
63
  }
57
64
  super.scale = value;
58
65
  }
66
+ get visible() {
67
+ var _a;
68
+ return !!((_a = this.object2D) === null || _a === void 0 ? void 0 : _a.visible);
69
+ }
70
+ set visible(value) {
71
+ if (this.object2D) {
72
+ this.object2D.visible = value;
73
+ }
74
+ for (const entity of this._children) {
75
+ if (entity instanceof Gg2dEntity) {
76
+ entity.visible = value;
77
+ }
78
+ }
79
+ }
80
+ /**
81
+ * Synchronize physics body transform with entity (and object2d if defined)
82
+ * */
83
+ runTransformBinding(objectBody, object2D) {
84
+ const pos = objectBody.position;
85
+ const quat = objectBody.rotation;
86
+ if (object2D) {
87
+ object2D.position = pos;
88
+ object2D.rotation = quat;
89
+ }
90
+ this._position$.next(pos);
91
+ this._rotation$.next(quat);
92
+ }
59
93
  onSpawned(world) {
60
94
  var _a, _b;
61
95
  super.onSpawned(world);
@@ -69,10 +103,8 @@ class Gg2dEntity extends gg_positionable_2d_entity_1.GgPositionable2dEntity {
69
103
  super.onRemoved();
70
104
  }
71
105
  dispose() {
72
- var _a;
73
106
  super.dispose();
74
- (_a = this.tickSub) === null || _a === void 0 ? void 0 : _a.unsubscribe();
75
- this.tickSub = null;
107
+ this.tick$.unsubscribe();
76
108
  if (this.object2D) {
77
109
  this.object2D.dispose();
78
110
  }
@@ -1,9 +1,12 @@
1
1
  import { GgWorld } from '../base/gg-world';
2
2
  import { Point2 } from '../base/models/points';
3
3
  import { IGg2dPhysicsWorld, IGg2dVisualScene } from './interfaces';
4
+ import { BodyShape2DDescriptor } from './models/shapes';
5
+ import { Gg2dEntity } from './entities/gg-2d-entity';
4
6
  export declare class Gg2dWorld<V extends IGg2dVisualScene = IGg2dVisualScene, P extends IGg2dPhysicsWorld = IGg2dPhysicsWorld> extends GgWorld<Point2, number, V, P> {
5
7
  readonly visualScene: V;
6
8
  readonly physicsWorld: P;
7
9
  protected readonly consoleEnabled: boolean;
8
10
  constructor(visualScene: V, physicsWorld: P, consoleEnabled?: boolean);
11
+ addPrimitiveRigidBody(descr: BodyShape2DDescriptor, position?: Point2, rotation?: number): Gg2dEntity;
9
12
  }
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Gg2dWorld = void 0;
13
13
  const gg_world_1 = require("../base/gg-world");
14
+ const gg_2d_entity_1 = require("./entities/gg-2d-entity");
14
15
  class Gg2dWorld extends gg_world_1.GgWorld {
15
16
  constructor(visualScene, physicsWorld, consoleEnabled = false) {
16
17
  super(visualScene, physicsWorld, consoleEnabled);
@@ -30,5 +31,15 @@ class Gg2dWorld extends gg_world_1.GgWorld {
30
31
  '{x: 0, y: value}, 2 arguments set the whole vector. Default value is "9.82" or "0 9.82"');
31
32
  }
32
33
  }
34
+ addPrimitiveRigidBody(descr, position = {
35
+ x: 0,
36
+ y: 0,
37
+ }, rotation = 0) {
38
+ const entity = new gg_2d_entity_1.Gg2dEntity(this.visualScene.factory.createPrimitive(descr.shape), this.physicsWorld.factory.createRigidBody(descr));
39
+ entity.position = position;
40
+ entity.rotation = rotation;
41
+ this.addEntity(entity);
42
+ return entity;
43
+ }
33
44
  }
34
45
  exports.Gg2dWorld = Gg2dWorld;
@@ -1,25 +1,25 @@
1
- import { BehaviorSubject } from 'rxjs';
1
+ import { BehaviorSubject, Subject } from 'rxjs';
2
2
  import { IController } from '../../base/controllers/i-controller';
3
3
  import { KeyboardController } from '../../base/controllers/keyboard.controller';
4
4
  import { Gg3dRaycastVehicleEntity } from '../entities/gg-3d-raycast-vehicle.entity';
5
5
  import { DirectionKeymap } from '../../base/controllers/common';
6
- declare type CarKeyboardControllerOptions = {
6
+ export declare type CarKeyboardControllerOptions = {
7
7
  keymap: DirectionKeymap;
8
8
  gearUpDownKeys: [string, string];
9
9
  };
10
10
  export declare class CarKeyboardController implements IController {
11
- private readonly keyboardController;
12
- private readonly options;
13
- private readonly x$;
14
- private readonly y$;
15
- private lastX;
16
- private readonly stop$;
11
+ protected readonly keyboardController: KeyboardController;
12
+ protected readonly options: CarKeyboardControllerOptions;
13
+ protected readonly x$: BehaviorSubject<number>;
14
+ protected readonly y$: BehaviorSubject<number>;
15
+ protected lastX: number;
16
+ protected readonly stop$: Subject<void>;
17
17
  protected readonly car$: BehaviorSubject<Gg3dRaycastVehicleEntity>;
18
- pairTickerPipe: import("rxjs").UnaryFunction<import("rxjs").Observable<number>, import("rxjs").Observable<number>>;
19
18
  set car(value: Gg3dRaycastVehicleEntity);
20
19
  get car(): Gg3dRaycastVehicleEntity;
20
+ switchingGearsEnabled: boolean;
21
+ pairTickerPipe: import("rxjs").UnaryFunction<import("rxjs").Observable<number>, import("rxjs").Observable<number>>;
21
22
  constructor(keyboardController: KeyboardController, car: Gg3dRaycastVehicleEntity, options?: CarKeyboardControllerOptions);
22
23
  start(): Promise<void>;
23
24
  stop(): Promise<void>;
24
25
  }
25
- export {};
@@ -28,6 +28,7 @@ class CarKeyboardController {
28
28
  this.lastX = 0;
29
29
  this.stop$ = new rxjs_1.Subject();
30
30
  this.car$ = new rxjs_1.BehaviorSubject(null);
31
+ this.switchingGearsEnabled = true;
31
32
  this.pairTickerPipe = (0, rxjs_1.pipe)((0, operators_1.startWith)(0), (0, operators_1.pairwise)(), (0, operators_1.map)(([beforeValue, afterValue]) => [this.lastX, afterValue]), (0, operators_1.switchMap)(([beforeValue, afterValue]) => (0, rxjs_1.interval)(TICKER_INTERVAL).pipe((0, operators_1.take)(TICKER_MAX_STEPS), (0, operators_1.map)(count => ++count), (0, operators_1.map)(count => beforeValue * ((TICKER_MAX_STEPS - count) / TICKER_MAX_STEPS) + afterValue * (count / TICKER_MAX_STEPS)), (0, operators_1.tap)(x => {
32
33
  this.lastX = x;
33
34
  }))));
@@ -42,6 +43,26 @@ class CarKeyboardController {
42
43
  start() {
43
44
  return __awaiter(this, void 0, void 0, function* () {
44
45
  let moveDirection = {};
46
+ this.keyboardController
47
+ .bind(this.options.gearUpDownKeys[0])
48
+ .pipe((0, rxjs_1.takeUntil)(this.stop$), (0, rxjs_1.filter)(x => this.switchingGearsEnabled && !!x))
49
+ .subscribe(() => {
50
+ if (this.car$.getValue() &&
51
+ (!this.car$.getValue().carProperties.transmission.isAuto || this.car$.getValue().gear <= 0)) {
52
+ this.car$.getValue().gear++;
53
+ }
54
+ });
55
+ this.keyboardController
56
+ .bind(this.options.gearUpDownKeys[1])
57
+ .pipe((0, rxjs_1.takeUntil)(this.stop$), (0, rxjs_1.filter)(x => this.switchingGearsEnabled && !!x))
58
+ .subscribe(() => {
59
+ if (this.car$.getValue().carProperties.transmission.isAuto && this.car.gear > 1) {
60
+ this.car$.getValue().gear = 0;
61
+ }
62
+ else {
63
+ this.car$.getValue().gear--;
64
+ }
65
+ });
45
66
  (0, common_1.bindDirectionKeys)(this.keyboardController, this.options.keymap)
46
67
  .pipe((0, rxjs_1.takeUntil)(this.stop$))
47
68
  .subscribe(d => {
@@ -67,26 +88,6 @@ class CarKeyboardController {
67
88
  this.car$.getValue().setXAxisControlValue(x);
68
89
  this.car$.getValue().setYAxisControlValue(y);
69
90
  });
70
- this.keyboardController
71
- .bind(this.options.gearUpDownKeys[0])
72
- .pipe((0, rxjs_1.takeUntil)(this.stop$), (0, rxjs_1.filter)(x => !!x))
73
- .subscribe(() => {
74
- if (this.car$.getValue() &&
75
- (!this.car$.getValue().carProperties.transmission.isAuto || this.car$.getValue().gear <= 0)) {
76
- this.car$.getValue().gear++;
77
- }
78
- });
79
- this.keyboardController
80
- .bind(this.options.gearUpDownKeys[1])
81
- .pipe((0, rxjs_1.takeUntil)(this.stop$), (0, rxjs_1.filter)(x => !!x))
82
- .subscribe(() => {
83
- if (this.car$.getValue().carProperties.transmission.isAuto && this.car.gear > 1) {
84
- this.car$.getValue().gear = 0;
85
- }
86
- else {
87
- this.car$.getValue().gear--;
88
- }
89
- });
90
91
  });
91
92
  }
92
93
  stop() {
@@ -1,9 +1,10 @@
1
1
  import { IController } from '../../base/controllers/i-controller';
2
- import { MouseControllerOptions } from '../../base/controllers/mouse.controller';
2
+ import { Subject } from 'rxjs';
3
+ import { MouseController, MouseControllerOptions } from '../../base/controllers/mouse.controller';
3
4
  import { Gg3dCameraEntity } from '../entities/gg-3d-camera.entity';
4
5
  import { KeyboardController } from '../../base/controllers/keyboard.controller';
5
6
  import { DirectionKeymap } from '../../base/controllers/common';
6
- declare type FreeCameraControllerOptions = {
7
+ export declare type FreeCameraControllerOptions = {
7
8
  keymap: DirectionKeymap;
8
9
  movementOptions: {
9
10
  speed: number;
@@ -11,13 +12,12 @@ declare type FreeCameraControllerOptions = {
11
12
  mouseOptions: MouseControllerOptions;
12
13
  };
13
14
  export declare class FreeCameraController implements IController {
14
- private readonly keyboardController;
15
- private readonly camera;
16
- private readonly options;
17
- private readonly mController;
18
- private readonly stop$;
15
+ protected readonly keyboardController: KeyboardController;
16
+ protected readonly camera: Gg3dCameraEntity;
17
+ protected readonly options: FreeCameraControllerOptions;
18
+ protected readonly mController: MouseController;
19
+ protected readonly stop$: Subject<void>;
19
20
  constructor(keyboardController: KeyboardController, camera: Gg3dCameraEntity, options?: FreeCameraControllerOptions);
20
21
  start(): Promise<void>;
21
22
  stop(unlockPointer?: boolean): Promise<void>;
22
23
  }
23
- export {};
@@ -0,0 +1,17 @@
1
+ import { AnimationFunction, AnimationMixer } from '../../../../base/entities/controllers/animation-mixer';
2
+ import { Point3 } from '../../../../base/models/points';
3
+ import { Gg3dWorld } from '../../../gg-3d-world';
4
+ import { Gg3dCameraEntity } from '../../gg-3d-camera.entity';
5
+ export declare type Camera3dAnimationArgs = {
6
+ position: Point3;
7
+ target: Point3;
8
+ up?: Point3;
9
+ fov?: number;
10
+ };
11
+ export declare class Camera3dAnimator extends AnimationMixer<Camera3dAnimationArgs> {
12
+ entity: Gg3dCameraEntity;
13
+ protected _animationFunction: AnimationFunction<Camera3dAnimationArgs>;
14
+ constructor(entity: Gg3dCameraEntity, _animationFunction: AnimationFunction<Camera3dAnimationArgs>);
15
+ onSpawned(world: Gg3dWorld): void;
16
+ protected applyPositioning(value: Camera3dAnimationArgs): void;
17
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Camera3dAnimator = void 0;
4
+ const animation_mixer_1 = require("../../../../base/entities/controllers/animation-mixer");
5
+ const point3_1 = require("../../../../base/math/point3");
6
+ const quaternion_1 = require("../../../../base/math/quaternion");
7
+ const rxjs_1 = require("rxjs");
8
+ const numbers_1 = require("../../../../base/math/numbers");
9
+ const defaultUp = { x: 0, y: 0, z: 1 };
10
+ const defaultFov = 65;
11
+ class Camera3dAnimator extends animation_mixer_1.AnimationMixer {
12
+ constructor(entity, _animationFunction) {
13
+ super(_animationFunction, (a, b, t) => ({
14
+ position: point3_1.Pnt3.lerp(a.position, b.position, t),
15
+ target: point3_1.Pnt3.lerp(a.target, b.target, t),
16
+ up: point3_1.Pnt3.lerp(a.up || defaultUp, b.up || defaultUp, t),
17
+ fov: (0, numbers_1.lerpNumber)(a.fov || defaultFov, b.fov || defaultFov, t),
18
+ }));
19
+ this.entity = entity;
20
+ this._animationFunction = _animationFunction;
21
+ }
22
+ onSpawned(world) {
23
+ super.onSpawned(world);
24
+ this.value$.pipe((0, rxjs_1.takeUntil)(this._onRemoved$)).subscribe(value => this.applyPositioning(value));
25
+ }
26
+ applyPositioning(value) {
27
+ this.entity.position = value.position;
28
+ this.entity.rotation = quaternion_1.Qtrn.lookAt(value.position, value.target, value.up || defaultUp);
29
+ this.entity.fov = value.fov || defaultFov;
30
+ }
31
+ }
32
+ exports.Camera3dAnimator = Camera3dAnimator;
@@ -0,0 +1,16 @@
1
+ import { Gg3dEntity } from '../../gg-3d-entity';
2
+ import { AnimationFunction, AnimationMixer } from '../../../../base/entities/controllers/animation-mixer';
3
+ import { Point3, Point4 } from '../../../../base/models/points';
4
+ import { Gg3dWorld } from '../../../gg-3d-world';
5
+ declare type Positioning3d = {
6
+ position: Point3;
7
+ rotation: Point4;
8
+ };
9
+ export declare class Entity3dPositioningAnimator<T extends Gg3dEntity = Gg3dEntity> extends AnimationMixer<Positioning3d> {
10
+ entity: T;
11
+ protected _animationFunction: AnimationFunction<Positioning3d>;
12
+ constructor(entity: T, _animationFunction: AnimationFunction<Positioning3d>);
13
+ onSpawned(world: Gg3dWorld): void;
14
+ protected applyPositioning(value: Positioning3d): void;
15
+ }
16
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Entity3dPositioningAnimator = void 0;
4
+ const animation_mixer_1 = require("../../../../base/entities/controllers/animation-mixer");
5
+ const point3_1 = require("../../../../base/math/point3");
6
+ const quaternion_1 = require("../../../../base/math/quaternion");
7
+ const rxjs_1 = require("rxjs");
8
+ class Entity3dPositioningAnimator extends animation_mixer_1.AnimationMixer {
9
+ constructor(entity, _animationFunction) {
10
+ super(_animationFunction, (a, b, t) => ({
11
+ position: point3_1.Pnt3.lerp(a.position, b.position, t),
12
+ rotation: quaternion_1.Qtrn.slerp(a.rotation, b.rotation, t),
13
+ }));
14
+ this.entity = entity;
15
+ this._animationFunction = _animationFunction;
16
+ }
17
+ onSpawned(world) {
18
+ super.onSpawned(world);
19
+ this.value$.pipe((0, rxjs_1.takeUntil)(this._onRemoved$)).subscribe(value => this.applyPositioning(value));
20
+ }
21
+ applyPositioning(value) {
22
+ this.entity.position = value.position;
23
+ this.entity.rotation = value.rotation;
24
+ }
25
+ }
26
+ exports.Entity3dPositioningAnimator = Entity3dPositioningAnimator;
@@ -0,0 +1,17 @@
1
+ import { AnimationFunction, AnimationMixer } from '../../../base/entities/controllers/animation-mixer';
2
+ import { Point3 } from '../../../base/models/points';
3
+ import { Gg3dWorld } from '../../gg-3d-world';
4
+ import { Gg3dCameraEntity } from '../gg-3d-camera.entity';
5
+ export declare type Camera3dAnimationArgs = {
6
+ position: Point3;
7
+ target: Point3;
8
+ up?: Point3;
9
+ fov?: number;
10
+ };
11
+ export declare class Camera3dAnimator extends AnimationMixer<Camera3dAnimationArgs> {
12
+ entity: Gg3dCameraEntity;
13
+ protected _animationFunction: AnimationFunction<Camera3dAnimationArgs>;
14
+ constructor(entity: Gg3dCameraEntity, _animationFunction: AnimationFunction<Camera3dAnimationArgs>);
15
+ onSpawned(world: Gg3dWorld): void;
16
+ protected applyPositioning(value: Camera3dAnimationArgs): void;
17
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Camera3dAnimator = void 0;
4
+ const animation_mixer_1 = require("../../../base/entities/controllers/animation-mixer");
5
+ const point3_1 = require("../../../base/math/point3");
6
+ const quaternion_1 = require("../../../base/math/quaternion");
7
+ const rxjs_1 = require("rxjs");
8
+ const numbers_1 = require("../../../base/math/numbers");
9
+ const defaultUp = { x: 0, y: 0, z: 1 };
10
+ const defaultFov = 65;
11
+ class Camera3dAnimator extends animation_mixer_1.AnimationMixer {
12
+ constructor(entity, _animationFunction) {
13
+ super(_animationFunction, (a, b, t) => ({
14
+ position: point3_1.Pnt3.lerp(a.position, b.position, t),
15
+ target: point3_1.Pnt3.lerp(a.target, b.target, t),
16
+ up: point3_1.Pnt3.lerp(a.up || defaultUp, b.up || defaultUp, t),
17
+ fov: (0, numbers_1.lerpNumber)(a.fov || defaultFov, b.fov || defaultFov, t),
18
+ }));
19
+ this.entity = entity;
20
+ this._animationFunction = _animationFunction;
21
+ }
22
+ onSpawned(world) {
23
+ super.onSpawned(world);
24
+ this.value$.pipe((0, rxjs_1.takeUntil)(this.removed$)).subscribe(value => this.applyPositioning(value));
25
+ }
26
+ applyPositioning(value) {
27
+ this.entity.position = value.position;
28
+ this.entity.rotation = quaternion_1.Qtrn.lookAt(value.position, value.target, value.up || defaultUp);
29
+ this.entity.fov = value.fov || defaultFov;
30
+ }
31
+ }
32
+ exports.Camera3dAnimator = Camera3dAnimator;
@@ -0,0 +1,16 @@
1
+ import { Gg3dEntity } from '../gg-3d-entity';
2
+ import { AnimationFunction, AnimationMixer } from '../../../base/entities/controllers/animation-mixer';
3
+ import { Point3, Point4 } from '../../../base/models/points';
4
+ import { Gg3dWorld } from '../../gg-3d-world';
5
+ declare type Positioning3d = {
6
+ position: Point3;
7
+ rotation: Point4;
8
+ };
9
+ export declare class Entity3dPositioningAnimator<T extends Gg3dEntity = Gg3dEntity> extends AnimationMixer<Positioning3d> {
10
+ entity: T;
11
+ protected _animationFunction: AnimationFunction<Positioning3d>;
12
+ constructor(entity: T, _animationFunction: AnimationFunction<Positioning3d>);
13
+ onSpawned(world: Gg3dWorld): void;
14
+ protected applyPositioning(value: Positioning3d): void;
15
+ }
16
+ export {};
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Entity3dPositioningAnimator = void 0;
4
+ const animation_mixer_1 = require("../../../base/entities/controllers/animation-mixer");
5
+ const point3_1 = require("../../../base/math/point3");
6
+ const quaternion_1 = require("../../../base/math/quaternion");
7
+ const rxjs_1 = require("rxjs");
8
+ class Entity3dPositioningAnimator extends animation_mixer_1.AnimationMixer {
9
+ constructor(entity, _animationFunction) {
10
+ super(_animationFunction, (a, b, t) => ({
11
+ position: point3_1.Pnt3.lerp(a.position, b.position, t),
12
+ rotation: quaternion_1.Qtrn.slerp(a.rotation, b.rotation, t),
13
+ }));
14
+ this.entity = entity;
15
+ this._animationFunction = _animationFunction;
16
+ }
17
+ onSpawned(world) {
18
+ super.onSpawned(world);
19
+ this.value$.pipe((0, rxjs_1.takeUntil)(this.removed$)).subscribe(value => this.applyPositioning(value));
20
+ }
21
+ applyPositioning(value) {
22
+ this.entity.position = value.position;
23
+ this.entity.rotation = value.rotation;
24
+ }
25
+ }
26
+ exports.Entity3dPositioningAnimator = Entity3dPositioningAnimator;
@@ -0,0 +1,25 @@
1
+ import { BehaviorSubject } from 'rxjs';
2
+ import { KeyboardInput } from '../../../../base/inputs/keyboard.input';
3
+ import { Gg3dRaycastVehicleEntity } from '../../gg-3d-raycast-vehicle.entity';
4
+ import { DirectionKeyboardInput, DirectionKeyboardKeymap } from '../../../../base/inputs/direction.keyboard-input';
5
+ import { GgEntity, GGTickOrder } from '../../../../base/entities/gg-entity';
6
+ import { GgWorld } from '../../../../base/gg-world';
7
+ export declare type CarKeyboardControllerOptions = {
8
+ keymap: DirectionKeyboardKeymap;
9
+ gearUpDownKeys: [string, string];
10
+ };
11
+ export declare class CarKeyboardHandlingController extends GgEntity {
12
+ protected readonly keyboard: KeyboardInput;
13
+ car: Gg3dRaycastVehicleEntity | null;
14
+ protected readonly options: CarKeyboardControllerOptions;
15
+ readonly tickOrder = GGTickOrder.INPUT_CONTROLLERS;
16
+ protected readonly directionsInput: DirectionKeyboardInput;
17
+ protected readonly x$: BehaviorSubject<number>;
18
+ protected readonly y$: BehaviorSubject<number>;
19
+ protected lastX: number;
20
+ switchingGearsEnabled: boolean;
21
+ pairTickerPipe: import("rxjs").UnaryFunction<import("rxjs").Observable<number>, import("rxjs").Observable<number>>;
22
+ constructor(keyboard: KeyboardInput, car: Gg3dRaycastVehicleEntity | null, options?: CarKeyboardControllerOptions);
23
+ onSpawned(world: GgWorld<any, any>): Promise<void>;
24
+ onRemoved(): Promise<void>;
25
+ }