@vived/app 2.50.1 → 2.51.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.
Files changed (47) hide show
  1. package/lib/Entities/Babylon.d.ts +1 -0
  2. package/lib/Entities/MemoizedColor.d.ts +9 -0
  3. package/lib/Entities/MemoizedColor.js +23 -0
  4. package/lib/Entities/ModelMesh.d.ts +53 -0
  5. package/lib/Entities/ModelMesh.js +106 -0
  6. package/lib/Entities/SceneModelObject.d.ts +40 -0
  7. package/lib/Entities/SceneModelObject.js +77 -0
  8. package/lib/PresentationManagers/SceneModel/SceneMeshOverlayPM.d.ts +1 -1
  9. package/lib/PresentationManagers/SceneModel/SceneMeshOverlayPM.js +2 -2
  10. package/lib/UseCases/SceneModel/PeelSceneMeshBase.d.ts +20 -0
  11. package/lib/UseCases/SceneModel/PeelSceneMeshBase.js +66 -0
  12. package/lib/UseCases/SceneModel/setActiveSceneModel.d.ts +2 -0
  13. package/lib/UseCases/SceneModel/setActiveSceneModel.js +90 -0
  14. package/lib/UseCases/SceneModel/setupSceneModelFromData.d.ts +2 -0
  15. package/lib/UseCases/SceneModel/setupSceneModelFromData.js +72 -0
  16. package/lib/UseCases/SceneObject/PeelSceneObjectBase.d.ts +20 -0
  17. package/lib/UseCases/SceneObject/PeelSceneObjectBase.js +66 -0
  18. package/lib/UseCases/SceneObject/index.d.ts +1 -0
  19. package/lib/UseCases/{FocusCamera → SceneObject}/index.js +1 -7
  20. package/lib/UseCases/SceneRoot/initializeSceneRoot.d.ts +2 -0
  21. package/lib/UseCases/SceneRoot/initializeSceneRoot.js +9 -0
  22. package/package.json +1 -1
  23. package/lib/Entities/FocusCamera.d.ts +0 -70
  24. package/lib/Entities/FocusCamera.js +0 -272
  25. package/lib/Entities/MeshModel.d.ts +0 -68
  26. package/lib/Entities/MeshModel.js +0 -174
  27. package/lib/Entities/ModelObject.d.ts +0 -10
  28. package/lib/Entities/ModelObject.js +0 -42
  29. package/lib/PresentationManagers/FocusCameraPM.d.ts +0 -15
  30. package/lib/PresentationManagers/FocusCameraPM.js +0 -31
  31. package/lib/PresentationManagers/FocusCameraPosRotPM.d.ts +0 -13
  32. package/lib/PresentationManagers/FocusCameraPosRotPM.js +0 -28
  33. package/lib/UseCases/FocusCamera/BumpDollyFocusCamera.d.ts +0 -17
  34. package/lib/UseCases/FocusCamera/BumpDollyFocusCamera.js +0 -64
  35. package/lib/UseCases/FocusCamera/LerpFocusCamera.d.ts +0 -36
  36. package/lib/UseCases/FocusCamera/LerpFocusCamera.js +0 -71
  37. package/lib/UseCases/FocusCamera/PinchDollyFocusCamera.d.ts +0 -11
  38. package/lib/UseCases/FocusCamera/PinchDollyFocusCamera.js +0 -36
  39. package/lib/UseCases/FocusCamera/PixelDollyFocusCamera.d.ts +0 -11
  40. package/lib/UseCases/FocusCamera/PixelDollyFocusCamera.js +0 -36
  41. package/lib/UseCases/FocusCamera/PixelOrbitFocusCamera.d.ts +0 -11
  42. package/lib/UseCases/FocusCamera/PixelOrbitFocusCamera.js +0 -26
  43. package/lib/UseCases/FocusCamera/PixelPlanePanFocusCamera.d.ts +0 -11
  44. package/lib/UseCases/FocusCamera/PixelPlanePanFocusCamera.js +0 -33
  45. package/lib/UseCases/FocusCamera/SerializeFocusCamera.d.ts +0 -22
  46. package/lib/UseCases/FocusCamera/SerializeFocusCamera.js +0 -81
  47. package/lib/UseCases/FocusCamera/index.d.ts +0 -7
@@ -1,10 +0,0 @@
1
- import { ObservableEntity } from "./ObservableEntity";
2
- export declare abstract class ModelObject extends ObservableEntity {
3
- abstract readonly id: string;
4
- abstract get label(): string;
5
- abstract set label(label: string);
6
- abstract get meshPaths(): string[];
7
- abstract addMeshPath(path: string): void;
8
- abstract removeMeshPath(path: string): void;
9
- }
10
- export declare function makeModelObject(id: string): ModelObject;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeModelObject = exports.ModelObject = void 0;
4
- const MemoizedString_1 = require("./MemoizedString");
5
- const ObservableEntity_1 = require("./ObservableEntity");
6
- class ModelObject extends ObservableEntity_1.ObservableEntity {
7
- }
8
- exports.ModelObject = ModelObject;
9
- function makeModelObject(id) {
10
- return new ModelObjectImp(id);
11
- }
12
- exports.makeModelObject = makeModelObject;
13
- class ModelObjectImp extends ModelObject {
14
- constructor(id) {
15
- super();
16
- this.memoizedLabel = new MemoizedString_1.MemoizedString("", this.notify);
17
- this._meshPaths = new Set([]);
18
- this.id = id;
19
- }
20
- get label() {
21
- return this.memoizedLabel.val;
22
- }
23
- set label(label) {
24
- this.memoizedLabel.val = label;
25
- }
26
- get meshPaths() {
27
- return Array.from(this._meshPaths);
28
- }
29
- addMeshPath(path) {
30
- if (this._meshPaths.has(path)) {
31
- return;
32
- }
33
- this._meshPaths.add(path);
34
- this.notify();
35
- }
36
- removeMeshPath(path) {
37
- if (this._meshPaths.has(path)) {
38
- this._meshPaths.delete(path);
39
- this.notify();
40
- }
41
- }
42
- }
@@ -1,15 +0,0 @@
1
- import { FocusCamera } from "../Entities";
2
- import { Vector3 } from "../ValueObjects";
3
- export interface FocusCameraVM {
4
- alphaEuler: Vector3;
5
- betaEuler: Vector3;
6
- cameraLocalPosition: Vector3;
7
- target: Vector3;
8
- }
9
- export declare class FocusCameraPM {
10
- private orbitCam;
11
- private view;
12
- dispose(): void;
13
- private doUpdateView;
14
- constructor(orbitCamera: FocusCamera, view: (vm: FocusCameraVM) => void);
15
- }
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FocusCameraPM = void 0;
4
- const Utilities_1 = require("../Utilities");
5
- const ValueObjects_1 = require("../ValueObjects");
6
- class FocusCameraPM {
7
- constructor(orbitCamera, view) {
8
- this.doUpdateView = () => {
9
- const { alpha, beta, radius, target } = this.orbitCam;
10
- const alphaRadians = Utilities_1.degreesToRadians(alpha);
11
- const alphaEuler = new ValueObjects_1.Vector3(0, alphaRadians, 0);
12
- const betaRadians = Utilities_1.degreesToRadians(beta);
13
- const betaEuler = new ValueObjects_1.Vector3(betaRadians, 0, 0);
14
- const cameraLocalPosition = new ValueObjects_1.Vector3(0, 0, -radius);
15
- this.view({
16
- alphaEuler,
17
- betaEuler,
18
- cameraLocalPosition,
19
- target,
20
- });
21
- };
22
- this.orbitCam = orbitCamera;
23
- this.view = view;
24
- this.doUpdateView();
25
- this.orbitCam.addObserver(this.doUpdateView);
26
- }
27
- dispose() {
28
- this.orbitCam.removeObserver(this.doUpdateView);
29
- }
30
- }
31
- exports.FocusCameraPM = FocusCameraPM;
@@ -1,13 +0,0 @@
1
- import { FocusCamera } from "../Entities";
2
- import { Vector3 } from "../ValueObjects";
3
- export interface FocusCameraPosRotVM {
4
- position: Vector3;
5
- rotation: Vector3;
6
- }
7
- export declare class FocusCameraPosRotPM {
8
- private focusCam;
9
- private view;
10
- dispose(): void;
11
- private doUpdateView;
12
- constructor(orbitCamera: FocusCamera, view: (vm: FocusCameraPosRotVM) => void);
13
- }
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FocusCameraPosRotPM = void 0;
4
- const Utilities_1 = require("../Utilities");
5
- const ValueObjects_1 = require("../ValueObjects");
6
- class FocusCameraPosRotPM {
7
- constructor(orbitCamera, view) {
8
- this.doUpdateView = () => {
9
- const { alpha, beta } = this.focusCam;
10
- const alphaRadians = Utilities_1.degreesToRadians(alpha);
11
- const betaRadians = Utilities_1.degreesToRadians(beta);
12
- const position = this.focusCam.cameraPosition;
13
- const rotation = new ValueObjects_1.Vector3(betaRadians, alphaRadians, 0);
14
- this.view({
15
- position,
16
- rotation,
17
- });
18
- };
19
- this.focusCam = orbitCamera;
20
- this.view = view;
21
- this.doUpdateView();
22
- this.focusCam.addObserver(this.doUpdateView);
23
- }
24
- dispose() {
25
- this.focusCam.removeObserver(this.doUpdateView);
26
- }
27
- }
28
- exports.FocusCameraPosRotPM = FocusCameraPosRotPM;
@@ -1,17 +0,0 @@
1
- import { FocusCamera } from "../../Entities";
2
- import { Vector3 } from "../../ValueObjects";
3
- export declare class BumpDollyFocusCamera {
4
- private focusCamera;
5
- bumpDurationMS: number;
6
- bumpLerp: (percent: number) => number;
7
- bumpAmount: number;
8
- private interval?;
9
- private chrono;
10
- private delta;
11
- private initialRadius;
12
- private finalRadius;
13
- private pickPoint?;
14
- private onTick;
15
- bump(direction: "IN" | "OUT", target?: Vector3): void;
16
- constructor(focusCamera: FocusCamera);
17
- }
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BumpDollyFocusCamera = void 0;
4
- const ValueObjects_1 = require("../../ValueObjects");
5
- class BumpDollyFocusCamera {
6
- constructor(focusCamera) {
7
- this.focusCamera = focusCamera;
8
- this.bumpDurationMS = 500;
9
- this.bumpLerp = (p) => {
10
- return p;
11
- }; // Linear
12
- this.bumpAmount = 0.1;
13
- this.chrono = 0;
14
- this.delta = 10;
15
- this.initialRadius = 0;
16
- this.finalRadius = 0;
17
- this.onTick = () => {
18
- this.chrono = this.chrono + this.delta;
19
- let nomralizedTime = this.chrono / this.bumpDurationMS;
20
- if (nomralizedTime > 1) {
21
- nomralizedTime = 1;
22
- }
23
- const percent = this.bumpLerp(nomralizedTime);
24
- const range = this.finalRadius - this.initialRadius;
25
- const currentRadius = this.focusCamera.radius;
26
- this.focusCamera.radius = this.initialRadius + range * percent;
27
- if (this.pickPoint !== undefined) {
28
- const percentChange = this.focusCamera.radius / currentRadius;
29
- let pickToTarget = ValueObjects_1.Vector3.Subtract(this.focusCamera.target, this.pickPoint);
30
- const newLength = pickToTarget.magnitued * percentChange;
31
- pickToTarget = ValueObjects_1.Vector3.NewVectorOfLength(pickToTarget, newLength);
32
- const newTargetPos = ValueObjects_1.Vector3.Add(this.pickPoint, pickToTarget);
33
- this.focusCamera.target = newTargetPos;
34
- }
35
- if (nomralizedTime >= 1 && this.interval) {
36
- this.focusCamera.radius = this.finalRadius;
37
- clearInterval(this.interval);
38
- this.interval = undefined;
39
- this.pickPoint = undefined;
40
- }
41
- };
42
- }
43
- bump(direction, target) {
44
- let delta = this.bumpAmount;
45
- if (direction === "IN") {
46
- delta *= -1;
47
- }
48
- this.initialRadius = this.focusCamera.radius;
49
- if (this.interval) {
50
- clearInterval(this.interval);
51
- this.interval = undefined;
52
- this.finalRadius = this.finalRadius + delta;
53
- }
54
- else {
55
- this.finalRadius = this.initialRadius + delta;
56
- }
57
- this.chrono = 0;
58
- this.pickPoint = target;
59
- this.interval = setInterval(() => {
60
- this.onTick();
61
- }, 10);
62
- }
63
- }
64
- exports.BumpDollyFocusCamera = BumpDollyFocusCamera;
@@ -1,36 +0,0 @@
1
- import { FocusCamera } from "../../Entities";
2
- export interface LerpFocusCameraParameters {
3
- duration: number;
4
- finalRadius?: number;
5
- finalBeta?: number;
6
- finalAlpha?: number;
7
- finalTarget?: {
8
- x: number;
9
- y: number;
10
- z: number;
11
- };
12
- onComplete?: () => void;
13
- onAbort?: () => void;
14
- }
15
- export declare class LerpFocusCamera {
16
- get isLerping(): boolean;
17
- private _isLerping;
18
- private focusCamera;
19
- private easeFn;
20
- private lerpDuration;
21
- private lerpRadius;
22
- private lerpBeta;
23
- private lerpAlpha;
24
- private lerpX;
25
- private lerpY;
26
- private lerpZ;
27
- private onComplete?;
28
- private onAbort?;
29
- private interval;
30
- private chrono;
31
- private delta;
32
- cancelLerp: () => void;
33
- private onTick;
34
- constructor(focusCamera: FocusCamera, easeFn: (normalizedTime: number) => number, parameters: LerpFocusCameraParameters);
35
- private makeLerpNumber;
36
- }
@@ -1,71 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LerpFocusCamera = void 0;
4
- const ValueObjects_1 = require("../../ValueObjects");
5
- class LerpFocusCamera {
6
- constructor(focusCamera, easeFn, parameters) {
7
- var _a, _b, _c;
8
- this._isLerping = false;
9
- this.chrono = 0;
10
- this.delta = 10;
11
- this.cancelLerp = () => {
12
- if (!this._isLerping)
13
- return;
14
- clearInterval(this.interval);
15
- if (this.onAbort) {
16
- this.onAbort();
17
- }
18
- this._isLerping = false;
19
- };
20
- this.onTick = () => {
21
- this.chrono = this.chrono + this.delta / 1000;
22
- let nomralizedTime = this.chrono / this.lerpDuration;
23
- if (nomralizedTime > 1) {
24
- nomralizedTime = 1;
25
- }
26
- const percent = this.easeFn(nomralizedTime);
27
- this.focusCamera.radius = this.lerpRadius(percent);
28
- this.focusCamera.beta = this.lerpBeta(percent);
29
- this.focusCamera.alpha = this.lerpAlpha(percent);
30
- const x = this.lerpX(percent);
31
- const y = this.lerpY(percent);
32
- const z = this.lerpZ(percent);
33
- this.focusCamera.target = new ValueObjects_1.Vector3(x, y, z);
34
- if (nomralizedTime >= 1) {
35
- clearInterval(this.interval);
36
- if (this.onComplete) {
37
- this.onComplete();
38
- }
39
- this._isLerping = false;
40
- this.focusCamera.lerpCompleted();
41
- }
42
- };
43
- this.focusCamera = focusCamera;
44
- this.easeFn = easeFn;
45
- this.lerpDuration = parameters.duration;
46
- this.onComplete = parameters.onComplete;
47
- this.onAbort = parameters.onAbort;
48
- this.lerpRadius = this.makeLerpNumber(this.focusCamera.radius, parameters.finalRadius);
49
- this.lerpBeta = this.makeLerpNumber(this.focusCamera.beta, parameters.finalBeta);
50
- this.lerpAlpha = this.makeLerpNumber(this.focusCamera.alpha, parameters.finalAlpha);
51
- this.lerpX = this.makeLerpNumber(this.focusCamera.target.x, (_a = parameters.finalTarget) === null || _a === void 0 ? void 0 : _a.x);
52
- this.lerpY = this.makeLerpNumber(this.focusCamera.target.y, (_b = parameters.finalTarget) === null || _b === void 0 ? void 0 : _b.y);
53
- this.lerpZ = this.makeLerpNumber(this.focusCamera.target.z, (_c = parameters.finalTarget) === null || _c === void 0 ? void 0 : _c.z);
54
- this.interval = setInterval(() => {
55
- this.onTick();
56
- }, this.delta);
57
- this.focusCamera.registerLerp(this);
58
- this._isLerping = true;
59
- }
60
- get isLerping() {
61
- return this._isLerping;
62
- }
63
- makeLerpNumber(initial, final) {
64
- const actualFinal = final !== null && final !== void 0 ? final : initial;
65
- return function Lerp(percent) {
66
- const range = actualFinal - initial;
67
- return initial + range * percent;
68
- };
69
- }
70
- }
71
- exports.LerpFocusCamera = LerpFocusCamera;
@@ -1,11 +0,0 @@
1
- import { FocusCamera } from "../../Entities";
2
- import { Vector3 } from "../../ValueObjects";
3
- export declare class PinchDollyFocusCamera {
4
- private focusCamera;
5
- sensitivity: number;
6
- private previousDistanceBetweenTouches;
7
- private pickPoint?;
8
- doDolly: (distanceBetweenTouches: number) => void;
9
- initializeDolly: (distanceBetweenTouches: number, pickPoint?: Vector3 | undefined) => void;
10
- constructor(focusCamera: FocusCamera);
11
- }
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PinchDollyFocusCamera = void 0;
4
- const ValueObjects_1 = require("../../ValueObjects");
5
- class PinchDollyFocusCamera {
6
- constructor(focusCamera) {
7
- this.focusCamera = focusCamera;
8
- this.sensitivity = 0.05;
9
- this.previousDistanceBetweenTouches = 0;
10
- this.doDolly = (distanceBetweenTouches) => {
11
- const pinchDelta = distanceBetweenTouches - this.previousDistanceBetweenTouches;
12
- const deltaRadius = pinchDelta * this.sensitivity;
13
- const currentRadius = this.focusCamera.radius;
14
- this.focusCamera.radius = currentRadius - deltaRadius;
15
- if (this.pickPoint !== undefined) {
16
- const percentChange = this.focusCamera.radius / currentRadius;
17
- let pickToTarget = ValueObjects_1.Vector3.Subtract(this.focusCamera.target, this.pickPoint);
18
- const newLength = pickToTarget.magnitued * percentChange;
19
- pickToTarget = ValueObjects_1.Vector3.NewVectorOfLength(pickToTarget, newLength);
20
- const newTargetPos = ValueObjects_1.Vector3.Add(this.pickPoint, pickToTarget);
21
- this.focusCamera.target = newTargetPos;
22
- }
23
- this.previousDistanceBetweenTouches = distanceBetweenTouches;
24
- };
25
- this.initializeDolly = (distanceBetweenTouches, pickPoint) => {
26
- this.previousDistanceBetweenTouches = distanceBetweenTouches;
27
- if (pickPoint) {
28
- this.pickPoint = pickPoint;
29
- }
30
- else {
31
- this.pickPoint = undefined;
32
- }
33
- };
34
- }
35
- }
36
- exports.PinchDollyFocusCamera = PinchDollyFocusCamera;
@@ -1,11 +0,0 @@
1
- import { FocusCamera } from "../../Entities";
2
- import { Vector2, Vector3 } from "../../ValueObjects";
3
- export declare class PixelDollyFocusCamera {
4
- private focusCamera;
5
- sensitivity: number;
6
- private previousPixelPosition;
7
- private pickPoint?;
8
- doDolly: (pixelPosition: Vector2) => void;
9
- initializeDolly: (pixelPosition: Vector2, pickPoint?: Vector3 | undefined) => void;
10
- constructor(focusCamera: FocusCamera);
11
- }
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PixelDollyFocusCamera = void 0;
4
- const ValueObjects_1 = require("../../ValueObjects");
5
- class PixelDollyFocusCamera {
6
- constructor(focusCamera) {
7
- this.focusCamera = focusCamera;
8
- this.sensitivity = 0.05;
9
- this.previousPixelPosition = ValueObjects_1.Vector2.Zero();
10
- this.doDolly = (pixelPosition) => {
11
- const pixelDeltaY = pixelPosition.y - this.previousPixelPosition.y;
12
- const deltaRadius = pixelDeltaY * this.sensitivity;
13
- const currentRadius = this.focusCamera.radius;
14
- this.focusCamera.radius = currentRadius - deltaRadius;
15
- if (this.pickPoint !== undefined) {
16
- const percentChange = this.focusCamera.radius / currentRadius;
17
- let pickToTarget = ValueObjects_1.Vector3.Subtract(this.focusCamera.target, this.pickPoint);
18
- const newLength = pickToTarget.magnitued * percentChange;
19
- pickToTarget = ValueObjects_1.Vector3.NewVectorOfLength(pickToTarget, newLength);
20
- const newTargetPos = ValueObjects_1.Vector3.Add(this.pickPoint, pickToTarget);
21
- this.focusCamera.target = newTargetPos;
22
- }
23
- this.previousPixelPosition = pixelPosition;
24
- };
25
- this.initializeDolly = (pixelPosition, pickPoint) => {
26
- this.previousPixelPosition = pixelPosition;
27
- if (pickPoint) {
28
- this.pickPoint = pickPoint;
29
- }
30
- else {
31
- this.pickPoint = undefined;
32
- }
33
- };
34
- }
35
- }
36
- exports.PixelDollyFocusCamera = PixelDollyFocusCamera;
@@ -1,11 +0,0 @@
1
- import { FocusCamera } from "../../Entities";
2
- import { Vector2, Vector3 } from "../../ValueObjects";
3
- export declare class PixelOrbitFocusCamera {
4
- private focusCamera;
5
- sensitivity: number;
6
- private previousPixelPos?;
7
- private pickPoint?;
8
- doOrbit: (pixelPosition: Vector2) => void;
9
- initializeOrbit: (initialPixelPos: Vector2, pickPoint?: Vector3 | undefined) => void;
10
- constructor(focusCamera: FocusCamera);
11
- }
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PixelOrbitFocusCamera = void 0;
4
- const ValueObjects_1 = require("../../ValueObjects");
5
- class PixelOrbitFocusCamera {
6
- constructor(focusCamera) {
7
- this.focusCamera = focusCamera;
8
- this.sensitivity = 0.5;
9
- this.doOrbit = (pixelPosition) => {
10
- if (!this.previousPixelPos) {
11
- console.error("[PixelOrbitFocusCamera] You must initialize first!");
12
- return;
13
- }
14
- const pixelChange = ValueObjects_1.Vector2.Subtract(pixelPosition, this.previousPixelPos);
15
- this.focusCamera.alpha += pixelChange.x * this.sensitivity;
16
- this.focusCamera.beta += pixelChange.y * this.sensitivity;
17
- this.previousPixelPos = pixelPosition;
18
- };
19
- this.initializeOrbit = (initialPixelPos, pickPoint) => {
20
- this.previousPixelPos = initialPixelPos;
21
- this.pickPoint = pickPoint;
22
- this.focusCamera.cancelLerp();
23
- };
24
- }
25
- }
26
- exports.PixelOrbitFocusCamera = PixelOrbitFocusCamera;
@@ -1,11 +0,0 @@
1
- import { Babylon, FocusCamera } from "../../Entities";
2
- import { ParametricPlane, Vector2 } from "../../ValueObjects";
3
- export declare class PixelPlanePanFocusCamera {
4
- private focusCamera;
5
- private babylon;
6
- private plane?;
7
- private previousPixelPos?;
8
- doPan: (pixelPosition: Vector2) => void;
9
- initializePan: (initialPixelPos: Vector2, panPlane: ParametricPlane) => void;
10
- constructor(focusCamera: FocusCamera, babylon: Babylon);
11
- }
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PixelPlanePanFocusCamera = void 0;
4
- const ValueObjects_1 = require("../../ValueObjects");
5
- class PixelPlanePanFocusCamera {
6
- constructor(focusCamera, babylon) {
7
- this.focusCamera = focusCamera;
8
- this.babylon = babylon;
9
- this.doPan = (pixelPosition) => {
10
- if (!this.plane || !this.previousPixelPos) {
11
- console.error("[PixelPlanePan_OrbitCamera] You must initialize first!");
12
- return;
13
- }
14
- const initialRay = this.babylon.sceneRay(this.previousPixelPos);
15
- const finalRay = this.babylon.sceneRay(pixelPosition);
16
- const p1 = this.plane.intersectLine(initialRay);
17
- const p2 = this.plane.intersectLine(finalRay);
18
- if (!p1 || !p2)
19
- return;
20
- const delta = ValueObjects_1.Vector3.Subtract(p2, p1);
21
- const currentTarget = this.focusCamera.target;
22
- const newTarget = new ValueObjects_1.Vector3(currentTarget.x - delta.x, currentTarget.y - delta.y, currentTarget.z - delta.z);
23
- this.focusCamera.target = new ValueObjects_1.Vector3(newTarget.x, newTarget.y, newTarget.z);
24
- this.previousPixelPos = pixelPosition;
25
- };
26
- this.initializePan = (initialPixelPos, panPlane) => {
27
- this.plane = panPlane;
28
- this.previousPixelPos = initialPixelPos;
29
- this.focusCamera.cancelLerp();
30
- };
31
- }
32
- }
33
- exports.PixelPlanePanFocusCamera = PixelPlanePanFocusCamera;
@@ -1,22 +0,0 @@
1
- import { FocusCamera, SerializedSystem, StateMachine } from "../../Entities";
2
- export declare class SerializeFocusCamera implements SerializedSystem {
3
- name: string;
4
- seriliziationVersion: number;
5
- private focusCamera;
6
- private stateMachine;
7
- getSystemState(): object;
8
- applySystemState(serializedState: object, version: number, transitionTime: number): void;
9
- applyDefaultState(transitionDuration: number): void;
10
- private applyV1Data;
11
- private applyImmediate;
12
- private applyLerp;
13
- constructor(focusCamera: FocusCamera, stateMachine: StateMachine);
14
- }
15
- export interface FocusCameraDataV1 {
16
- alpha: number;
17
- beta: number;
18
- radius: number;
19
- target_x: number;
20
- target_y: number;
21
- target_z: number;
22
- }
@@ -1,81 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SerializeFocusCamera = void 0;
4
- const _1 = require(".");
5
- const ValueObjects_1 = require("../../ValueObjects");
6
- class SerializeFocusCamera {
7
- constructor(focusCamera, stateMachine) {
8
- this.name = "focusCamera";
9
- this.seriliziationVersion = 1;
10
- this.focusCamera = focusCamera;
11
- this.stateMachine = stateMachine;
12
- stateMachine.registerSerializedSystem(this);
13
- }
14
- getSystemState() {
15
- const data = {
16
- alpha: this.focusCamera.alpha,
17
- beta: this.focusCamera.beta,
18
- radius: this.focusCamera.radius,
19
- target_x: this.focusCamera.target.x,
20
- target_y: this.focusCamera.target.y,
21
- target_z: this.focusCamera.target.z,
22
- };
23
- return data;
24
- }
25
- applySystemState(serializedState, version, transitionTime) {
26
- try {
27
- if (version === 1) {
28
- const castState = serializedState;
29
- this.applyV1Data(castState, transitionTime);
30
- }
31
- else {
32
- console.warn(`[SerializeFocusCamera] Unsupported version number ${version}. Defaulting`);
33
- this.applyDefaultState(transitionTime);
34
- }
35
- }
36
- catch (e) {
37
- console.warn(`[SerializeFocusCamera] Caught when deserializing ${e}. Defaulting`);
38
- this.applyDefaultState(transitionTime);
39
- }
40
- }
41
- applyDefaultState(transitionDuration) {
42
- const alpha = this.focusCamera.defaultAlpha;
43
- const beta = this.focusCamera.defaultBeta;
44
- const radius = this.focusCamera.defaultRadius;
45
- const target = this.focusCamera.defaultTarget;
46
- if (transitionDuration === 0) {
47
- this.applyImmediate(alpha, beta, radius, target);
48
- }
49
- else {
50
- this.applyLerp(alpha, beta, radius, target, transitionDuration);
51
- }
52
- }
53
- applyV1Data(data, transitionTime) {
54
- const { alpha, beta, radius, target_x, target_y, target_z } = data;
55
- const target = new ValueObjects_1.Vector3(target_x, target_y, target_z);
56
- if (transitionTime === 0) {
57
- this.applyImmediate(alpha, beta, radius, target);
58
- }
59
- else {
60
- this.applyLerp(alpha, beta, radius, target, transitionTime);
61
- }
62
- }
63
- applyImmediate(alpha, beta, radius, target) {
64
- this.focusCamera.cancelLerp();
65
- this.focusCamera.alpha = alpha;
66
- this.focusCamera.beta = beta;
67
- this.focusCamera.radius = radius;
68
- this.focusCamera.target = target;
69
- }
70
- applyLerp(alpha, beta, radius, target, transitionTime) {
71
- const lerpParams = {
72
- duration: transitionTime,
73
- finalRadius: radius,
74
- finalBeta: beta,
75
- finalAlpha: alpha,
76
- finalTarget: target,
77
- };
78
- new _1.LerpFocusCamera(this.focusCamera, this.stateMachine.transitionEaseFunction, lerpParams);
79
- }
80
- }
81
- exports.SerializeFocusCamera = SerializeFocusCamera;
@@ -1,7 +0,0 @@
1
- export * from "./PixelPlanePanFocusCamera";
2
- export * from "./LerpFocusCamera";
3
- export * from "./SerializeFocusCamera";
4
- export * from "./PixelDollyFocusCamera";
5
- export * from "./BumpDollyFocusCamera";
6
- export * from "./PinchDollyFocusCamera";
7
- export * from "./PixelOrbitFocusCamera";