@vived/app 2.20.1 → 2.21.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 (153) hide show
  1. package/lib/Core/BaseApp/Boundary.d.ts +49 -0
  2. package/lib/Core/BaseApp/Boundary.js +2 -0
  3. package/lib/Core/BaseApp/Entity.d.ts +11 -0
  4. package/lib/Core/BaseApp/Entity.js +2 -0
  5. package/lib/Core/BaseApp/Errors/ErrorDuplicateSystemName.d.ts +3 -0
  6. package/lib/Core/BaseApp/Errors/ErrorDuplicateSystemName.js +12 -0
  7. package/lib/Core/BaseApp/Errors/ErrorNoHostHandler.d.ts +3 -0
  8. package/lib/Core/BaseApp/Errors/ErrorNoHostHandler.js +10 -0
  9. package/lib/Core/BaseApp/Errors/ErrorUnsupportedVersionNumber.d.ts +3 -0
  10. package/lib/Core/BaseApp/Errors/ErrorUnsupportedVersionNumber.js +10 -0
  11. package/lib/Core/BaseApp/Errors/index.d.ts +3 -0
  12. package/lib/Core/BaseApp/Errors/index.js +15 -0
  13. package/lib/Core/BaseApp/UseCase.d.ts +43 -0
  14. package/lib/Core/BaseApp/UseCase.js +250 -0
  15. package/lib/Core/BaseAppState/Boundary.d.ts +14 -0
  16. package/lib/Core/BaseAppState/Boundary.js +2 -0
  17. package/lib/Core/BaseAppState/Entity.d.ts +5 -0
  18. package/lib/Core/BaseAppState/Entity.js +2 -0
  19. package/lib/Core/BaseAppState/UseCase.d.ts +16 -0
  20. package/lib/Core/BaseAppState/UseCase.js +54 -0
  21. package/lib/Core/BaseAppState/UseCase_Imp.d.ts +16 -0
  22. package/lib/Core/BaseAppState/UseCase_Imp.js +54 -0
  23. package/lib/Core/DevicePreview/DevicePreviewUC_Imp.d.ts +16 -0
  24. package/lib/Core/DevicePreview/DevicePreviewUC_Imp.js +56 -0
  25. package/lib/Core/DevicePreview/boundary.d.ts +14 -0
  26. package/lib/Core/DevicePreview/boundary.js +2 -0
  27. package/lib/Core/DevicePreview/entity.d.ts +5 -0
  28. package/lib/Core/DevicePreview/entity.js +2 -0
  29. package/lib/Core/DispatchToHost/Entity.d.ts +4 -0
  30. package/lib/Core/DispatchToHost/Entity.js +2 -0
  31. package/lib/Core/DispatchToHost/UseCase.d.ts +12 -0
  32. package/lib/Core/DispatchToHost/UseCase.js +70 -0
  33. package/lib/Core/DispatchToHost/boundary.d.ts +9 -0
  34. package/lib/Core/DispatchToHost/boundary.js +2 -0
  35. package/lib/Core/Serilization/Boundary.d.ts +20 -0
  36. package/lib/Core/Serilization/Boundary.js +2 -0
  37. package/lib/Core/Serilization/Entity.d.ts +3 -0
  38. package/lib/Core/Serilization/Entity.js +2 -0
  39. package/lib/Core/Serilization/ErrorDuplicateSystemName.d.ts +3 -0
  40. package/lib/Core/Serilization/ErrorDuplicateSystemName.js +12 -0
  41. package/lib/Core/Serilization/ErrorUnsupportedVersionNumber.d.ts +3 -0
  42. package/lib/Core/Serilization/ErrorUnsupportedVersionNumber.js +10 -0
  43. package/lib/Core/Serilization/Errors.d.ts +6 -0
  44. package/lib/Core/Serilization/Errors.js +19 -0
  45. package/lib/Core/Serilization/UseCase.d.ts +10 -0
  46. package/lib/Core/Serilization/UseCase.js +52 -0
  47. package/lib/Core/Serilization/UseCase_Imp.d.ts +10 -0
  48. package/lib/Core/Serilization/UseCase_Imp.js +51 -0
  49. package/lib/Core/index.d.ts +3 -0
  50. package/lib/Core/index.js +19 -0
  51. package/lib/Entities/Color.d.ts +20 -0
  52. package/lib/Entities/Color.js +59 -0
  53. package/lib/Entities/LineSegment2D.d.ts +11 -0
  54. package/lib/Entities/LineSegment2D.js +70 -0
  55. package/lib/Entities/MouseSceneInput.d.ts +15 -0
  56. package/lib/Entities/MouseSceneInput.js +109 -0
  57. package/lib/Entities/OrbitCamera.d.ts +76 -0
  58. package/lib/Entities/OrbitCamera.js +243 -0
  59. package/lib/Entities/ParametricLine.d.ts +29 -0
  60. package/lib/Entities/ParametricLine.js +79 -0
  61. package/lib/Entities/ParametricPlane.d.ts +20 -0
  62. package/lib/Entities/ParametricPlane.js +63 -0
  63. package/lib/Entities/SceneRoot.d.ts +69 -0
  64. package/lib/Entities/SceneRoot.js +77 -0
  65. package/lib/Entities/TransformNode.d.ts +78 -0
  66. package/lib/Entities/TransformNode.js +217 -0
  67. package/lib/Entities/Vector2.d.ts +21 -0
  68. package/lib/Entities/Vector2.js +83 -0
  69. package/lib/Entities/Vector3.d.ts +19 -0
  70. package/lib/Entities/Vector3.js +75 -0
  71. package/lib/Entities/WorkPlane.d.ts +49 -0
  72. package/lib/Entities/WorkPlane.js +122 -0
  73. package/lib/Entities/index.d.ts +3 -0
  74. package/lib/Entities/index.js +3 -0
  75. package/lib/Interface/Controllers/appHandler.d.ts +12 -0
  76. package/lib/Interface/Controllers/appHandler.js +94 -0
  77. package/lib/Interface/Controllers/defaultAppHanlderFunctions.d.ts +3 -0
  78. package/lib/Interface/Controllers/defaultAppHanlderFunctions.js +31 -0
  79. package/lib/Interface/Controllers/dispatchStateChange.d.ts +2 -0
  80. package/lib/Interface/Controllers/dispatchStateChange.js +10 -0
  81. package/lib/Interface/Controllers/index.d.ts +9 -0
  82. package/lib/Interface/Controllers/index.js +21 -0
  83. package/lib/Interface/Controllers/makeAppHandler.d.ts +12 -0
  84. package/lib/Interface/Controllers/makeAppHandler.js +96 -0
  85. package/lib/Interface/Controllers/setDevicePreview.d.ts +2 -0
  86. package/lib/Interface/Controllers/setDevicePreview.js +14 -0
  87. package/lib/Interface/Controllers/setIsAuthoring.d.ts +2 -0
  88. package/lib/Interface/Controllers/setIsAuthoring.js +14 -0
  89. package/lib/Interface/Controllers/setState.d.ts +2 -0
  90. package/lib/Interface/Controllers/setState.js +21 -0
  91. package/lib/Interface/Controllers/showBabylonInspector.d.ts +2 -0
  92. package/lib/Interface/Controllers/showBabylonInspector.js +9 -0
  93. package/lib/Interface/Controllers/startApp.d.ts +1 -0
  94. package/lib/Interface/Controllers/startApp.js +9 -0
  95. package/lib/Interface/Controllers/stopApp.d.ts +2 -0
  96. package/lib/Interface/Controllers/stopApp.js +10 -0
  97. package/lib/Interface/PresentationManagers/DevicePreviewPM.d.ts +13 -0
  98. package/lib/Interface/PresentationManagers/DevicePreviewPM.js +25 -0
  99. package/lib/Interface/PresentationManagers/IsAuthoringPM.d.ts +10 -0
  100. package/lib/Interface/PresentationManagers/IsAuthoringPM.js +23 -0
  101. package/lib/Interface/PresentationManagers/ShowBabylonInspectorPM.d.ts +10 -0
  102. package/lib/Interface/PresentationManagers/ShowBabylonInspectorPM.js +23 -0
  103. package/lib/Interface/PresentationManagers/index.d.ts +3 -0
  104. package/lib/Interface/PresentationManagers/index.js +15 -0
  105. package/lib/Interface/appHandler.d.ts +12 -0
  106. package/lib/Interface/appHandler.js +94 -0
  107. package/lib/Interface/index.d.ts +2 -0
  108. package/lib/Interface/index.js +14 -0
  109. package/lib/PresentationManagers/OrbitCameraPM.d.ts +14 -0
  110. package/lib/PresentationManagers/OrbitCameraPM.js +31 -0
  111. package/lib/PresentationManagers/TransformNodePM.d.ts +14 -0
  112. package/lib/PresentationManagers/TransformNodePM.js +23 -0
  113. package/lib/PresentationManagers/index.d.ts +1 -0
  114. package/lib/PresentationManagers/index.js +1 -0
  115. package/lib/UseCases/LerpOrbitCamera.d.ts +36 -0
  116. package/lib/UseCases/LerpOrbitCamera.js +71 -0
  117. package/lib/UseCases/OrbitCamera/LerpOrbitCamera.d.ts +36 -0
  118. package/lib/UseCases/OrbitCamera/LerpOrbitCamera.js +71 -0
  119. package/lib/UseCases/OrbitCamera/PixelDolly_OrbitCamera.d.ts +9 -0
  120. package/lib/UseCases/OrbitCamera/PixelDolly_OrbitCamera.js +31 -0
  121. package/lib/UseCases/OrbitCamera/PixelPlanePan_OrbitCamera.d.ts +10 -0
  122. package/lib/UseCases/OrbitCamera/PixelPlanePan_OrbitCamera.js +31 -0
  123. package/lib/UseCases/OrbitCamera/SerializeOrbitCamera.d.ts +22 -0
  124. package/lib/UseCases/OrbitCamera/SerializeOrbitCamera.js +81 -0
  125. package/lib/UseCases/OrbitCamera/index.d.ts +4 -0
  126. package/lib/UseCases/OrbitCamera/index.js +16 -0
  127. package/lib/UseCases/SceneRoot/SerializeSceneRoot.d.ts +18 -0
  128. package/lib/UseCases/SceneRoot/SerializeSceneRoot.js +48 -0
  129. package/lib/UseCases/SceneRoot/index.d.ts +1 -0
  130. package/lib/UseCases/SceneRoot/index.js +13 -0
  131. package/lib/UseCases/SerializeCamera.d.ts +21 -0
  132. package/lib/UseCases/SerializeCamera.js +59 -0
  133. package/lib/UseCases/SerializeOrbitCamera.d.ts +21 -0
  134. package/lib/UseCases/SerializeOrbitCamera.js +59 -0
  135. package/lib/UseCases/SerializedCamDemo.d.ts +0 -0
  136. package/lib/UseCases/SerializedCamDemo.js +1 -0
  137. package/lib/UseCases/index.d.ts +1 -0
  138. package/lib/UseCases/index.js +1 -0
  139. package/lib/ValueObjects/Angle.d.ts +18 -0
  140. package/lib/ValueObjects/Angle.js +26 -2
  141. package/lib/ValueObjects/Color.d.ts +46 -0
  142. package/lib/ValueObjects/Color.js +46 -0
  143. package/lib/ValueObjects/Matrix.d.ts +120 -0
  144. package/lib/ValueObjects/Matrix.js +423 -0
  145. package/lib/ValueObjects/Quaternion.d.ts +94 -0
  146. package/lib/ValueObjects/Quaternion.js +243 -0
  147. package/lib/ValueObjects/Vector2.d.ts +82 -0
  148. package/lib/ValueObjects/Vector2.js +82 -0
  149. package/lib/ValueObjects/Vector3.d.ts +107 -0
  150. package/lib/ValueObjects/Vector3.js +116 -0
  151. package/lib/ValueObjects/index.d.ts +2 -0
  152. package/lib/ValueObjects/index.js +2 -0
  153. package/package.json +1 -1
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeMouseSceneInput = void 0;
4
+ const _1 = require(".");
5
+ function makeMouseSceneInput() {
6
+ return new MouseSceneInputImp();
7
+ }
8
+ exports.makeMouseSceneInput = makeMouseSceneInput;
9
+ class MouseSceneInputImp {
10
+ constructor() {
11
+ this.controllers = [];
12
+ this.maxClickMovement = 5; // pixels
13
+ this._eventElement = undefined;
14
+ this.setEventElement = (eventElement) => {
15
+ if (this._eventElement)
16
+ this.clearInputElement();
17
+ eventElement.addEventListener("mousedown", this.onMouseDown);
18
+ eventElement.addEventListener("mouseup", this.onMouseUp);
19
+ eventElement.addEventListener("mousemove", this.onMouseMove);
20
+ eventElement.addEventListener("mouseout", this.onMouseOut);
21
+ eventElement.addEventListener("wheel", this.onWheel);
22
+ this._eventElement = eventElement;
23
+ };
24
+ this.clearInputElement = () => {
25
+ if (!this._eventElement)
26
+ return;
27
+ this._eventElement.removeEventListener("mousedown", this.onMouseDown);
28
+ this._eventElement.removeEventListener("mouseup", this.onMouseUp);
29
+ this._eventElement.removeEventListener("mousemove", this.onMouseMove);
30
+ this._eventElement.removeEventListener("mouseout", this.onMouseOut);
31
+ this._eventElement.removeEventListener("wheel", this.onWheel);
32
+ this._eventElement = undefined;
33
+ };
34
+ this.registerController = (controller) => {
35
+ this.controllers.push(controller);
36
+ };
37
+ this.removeController = (controller) => {
38
+ const index = this.controllers.indexOf(controller);
39
+ if (index >= 0) {
40
+ this.controllers.splice(index, 1);
41
+ }
42
+ };
43
+ this.onMouseDown = (e) => {
44
+ const mousePos = new _1.Vector2(e.offsetX, e.offsetY);
45
+ this.controllers.forEach((c) => {
46
+ if (c.onDown) {
47
+ c.onDown(e);
48
+ }
49
+ });
50
+ this.pressEvent = e;
51
+ };
52
+ this.onMouseUp = (e) => {
53
+ this.controllers.forEach((c) => {
54
+ if (c.onUp) {
55
+ c.onUp(e);
56
+ }
57
+ });
58
+ if (!this.pressEvent)
59
+ return;
60
+ const deltaX = this.pressEvent.screenX - e.screenX;
61
+ const deltaY = this.pressEvent.screenY - e.screenY;
62
+ const delta = new _1.Vector2(deltaX, deltaY);
63
+ if (delta.magnitued < this.maxClickMovement) {
64
+ this.controllers.forEach((c) => {
65
+ if (c.onClick) {
66
+ c.onClick(e);
67
+ }
68
+ });
69
+ }
70
+ this.pressEvent = undefined;
71
+ };
72
+ this.onMouseMove = (e) => {
73
+ this.controllers.forEach((c) => {
74
+ if (c.onMove) {
75
+ c.onMove(e);
76
+ }
77
+ });
78
+ if (!this.pressEvent)
79
+ return;
80
+ const deltaX = this.pressEvent.screenX - e.screenX;
81
+ const deltaY = this.pressEvent.screenY - e.screenY;
82
+ const delta = new _1.Vector2(deltaX, deltaY);
83
+ if (delta.magnitued > this.maxClickMovement) {
84
+ this.pressEvent = undefined;
85
+ }
86
+ };
87
+ this.onMouseOut = (e) => {
88
+ if (!this.pressEvent)
89
+ return;
90
+ const mousePos = new _1.Vector2(e.offsetX, e.offsetY);
91
+ this.controllers.forEach((c) => {
92
+ if (c.onUp) {
93
+ c.onUp(e);
94
+ }
95
+ });
96
+ this.pressEvent = undefined;
97
+ };
98
+ this.onWheel = (e) => {
99
+ this.controllers.forEach((c) => {
100
+ if (c.onWheel) {
101
+ c.onWheel(e);
102
+ }
103
+ });
104
+ };
105
+ }
106
+ get eventElement() {
107
+ return this._eventElement;
108
+ }
109
+ }
@@ -0,0 +1,76 @@
1
+ import { Vector3 } from ".";
2
+ export declare type OnOrbitCameraChange = () => void;
3
+ export interface CameraLerper {
4
+ cancelLerp: () => void;
5
+ }
6
+ export interface CameraData {
7
+ defaultAlpha?: number;
8
+ defaultBeta?: number;
9
+ defaultRadius?: number;
10
+ defaultTarget?: {
11
+ x: number;
12
+ y: number;
13
+ z: number;
14
+ };
15
+ nearClip?: number;
16
+ farClip?: number;
17
+ alphaLimit?: {
18
+ min: number;
19
+ max: number;
20
+ };
21
+ betaLimit?: {
22
+ min: number;
23
+ max: number;
24
+ };
25
+ radiusLimit?: {
26
+ min: number;
27
+ max: number;
28
+ };
29
+ targetLimit?: {
30
+ min: {
31
+ x: number;
32
+ y: number;
33
+ z: number;
34
+ };
35
+ max: {
36
+ x: number;
37
+ y: number;
38
+ z: number;
39
+ };
40
+ };
41
+ dollyRollSensitivity?: number;
42
+ dollyPixelSensitivity?: number;
43
+ orbitPixelSensitivity?: number;
44
+ dollyPinchSensitivity?: number;
45
+ }
46
+ export interface OrbitCamera {
47
+ alpha: number;
48
+ beta: number;
49
+ radius: number;
50
+ target: Vector3;
51
+ nearClip: number;
52
+ farClip: number;
53
+ defaultAlpha: number;
54
+ defaultBeta: number;
55
+ defaultRadius: number;
56
+ defaultTarget: Vector3;
57
+ dollyRollSensitivity: number;
58
+ dollyPixelSensitivity: number;
59
+ dollyPinchSensitivity: number;
60
+ orbitPixelSensitivity: number;
61
+ setAlphaLimits: (min: number, max: number) => void;
62
+ clearAlphaLimits: () => void;
63
+ setBetaLimits: (min: number, max: number) => void;
64
+ clearBetaLimits: () => void;
65
+ setRadiusLimits: (min: number, max: number) => void;
66
+ clearRadiusLimits: () => void;
67
+ setTargetLimits: (min: Vector3, max: Vector3) => void;
68
+ clearTargetLimits: () => void;
69
+ registerLerp: (lerper: CameraLerper) => void;
70
+ lerpCompleted: () => void;
71
+ cancelLerp: () => void;
72
+ applyData: (data: CameraData) => void;
73
+ addObserver: (observer: OnOrbitCameraChange) => void;
74
+ removeObserver: (observer: OnOrbitCameraChange) => void;
75
+ }
76
+ export declare function makeOrbitCamera(): OrbitCamera;
@@ -0,0 +1,243 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeOrbitCamera = void 0;
4
+ const _1 = require(".");
5
+ function makeOrbitCamera() {
6
+ return new OrbitCameraImp();
7
+ }
8
+ exports.makeOrbitCamera = makeOrbitCamera;
9
+ class OrbitCameraImp {
10
+ constructor() {
11
+ this.farClip = 100;
12
+ this.nearClip = 0.01;
13
+ this.defaultAlpha = 0;
14
+ this.defaultBeta = 30;
15
+ this.defaultRadius = 8;
16
+ this.defaultTarget = _1.Vector3.Zero();
17
+ this.orbitPixelSensitivity = 0.5;
18
+ this.dollyPixelSensitivity = 0.01;
19
+ this.dollyRollSensitivity = 0.001;
20
+ this.dollyPinchSensitivity = 0.005;
21
+ this.limitRadius = false;
22
+ this.minRadius = 0;
23
+ this.maxRadius = 0;
24
+ this.limitAlpha = false;
25
+ this.minAlpha = 0;
26
+ this.maxAlpha = 0;
27
+ this.limitBeta = false;
28
+ this.minBeta = 0;
29
+ this.maxBeta = 0;
30
+ this.limitTarget = false;
31
+ this.maxTargetPosition = _1.Vector3.Zero();
32
+ this.minTargetPosition = _1.Vector3.Zero();
33
+ this.observers = new _1.ObserverList();
34
+ this.memoizedAlpha = new _1.MemoizedNumber(0, this.observers.notify);
35
+ this.memoizedBeta = new _1.MemoizedNumber(0, this.observers.notify);
36
+ this.memoizedRadius = new _1.MemoizedNumber(1, this.observers.notify);
37
+ this.memoizedTarget = new _1.MemoizedVector3(_1.Vector3.Zero(), this.observers.notify);
38
+ this.setRadiusLimits = (min, max) => {
39
+ if (min < 0) {
40
+ throw new Error("[Orbit Camera] Mininum Radius must be greater >= 0");
41
+ }
42
+ if (max < min) {
43
+ throw new Error("[Orbit Camera] Max radius must be >= min radius");
44
+ }
45
+ this.maxRadius = max;
46
+ this.minRadius = min;
47
+ this.limitRadius = true;
48
+ this.radius = this.radius;
49
+ };
50
+ this.clearRadiusLimits = () => {
51
+ this.maxRadius = 0;
52
+ this.minRadius = 0;
53
+ this.limitRadius = false;
54
+ };
55
+ this.setAlphaLimits = (min, max) => {
56
+ if (min > max) {
57
+ throw new Error("[Orbit Camera] Max alpha must be >= min alpha");
58
+ }
59
+ if (min < -180) {
60
+ throw new Error("[Orbit Camera] Min alpha must be >= -180");
61
+ }
62
+ if (max > 180) {
63
+ throw new Error("[Orbit Camera] Max alpha must be <= 180");
64
+ }
65
+ this.maxAlpha = max;
66
+ this.minAlpha = min;
67
+ this.limitAlpha = true;
68
+ this.alpha = this.alpha;
69
+ };
70
+ this.clearAlphaLimits = () => {
71
+ this.maxAlpha = 0;
72
+ this.minAlpha = 0;
73
+ this.limitAlpha = false;
74
+ };
75
+ this.setBetaLimits = (min, max) => {
76
+ if (min > max) {
77
+ throw new Error("[Orbit Camera] Max beta must be >= min beta");
78
+ }
79
+ if (min < -180) {
80
+ throw new Error("[Orbit Camera] Min beta must be >= -180");
81
+ }
82
+ if (max > 180) {
83
+ throw new Error("[Orbit Camera] Max beta must be <= 180");
84
+ }
85
+ this.maxBeta = max;
86
+ this.minBeta = min;
87
+ this.limitBeta = true;
88
+ this.beta = this.beta;
89
+ };
90
+ this.clearBetaLimits = () => {
91
+ this.maxBeta = 0;
92
+ this.minBeta = 0;
93
+ this.limitBeta = false;
94
+ };
95
+ this.setTargetLimits = (min, max) => {
96
+ const minArray = min.asArray();
97
+ const maxArray = max.asArray();
98
+ for (let i = 0; i < 3; i++) {
99
+ if (minArray[i] > maxArray[i]) {
100
+ throw new Error("[Orbit Camera] Min target must be less than the max target");
101
+ }
102
+ }
103
+ this.maxTargetPosition = max;
104
+ this.minTargetPosition = min;
105
+ this.limitTarget = true;
106
+ this.target = this.target;
107
+ };
108
+ this.clearTargetLimits = () => {
109
+ this.maxTargetPosition = _1.Vector3.Zero();
110
+ this.minTargetPosition = _1.Vector3.Zero();
111
+ this.limitTarget = false;
112
+ };
113
+ this.registerLerp = (lerper) => {
114
+ if (this.currentLerp) {
115
+ this.currentLerp.cancelLerp();
116
+ }
117
+ this.currentLerp = lerper;
118
+ };
119
+ this.lerpCompleted = () => {
120
+ this.currentLerp = undefined;
121
+ };
122
+ this.cancelLerp = () => {
123
+ var _a;
124
+ (_a = this.currentLerp) === null || _a === void 0 ? void 0 : _a.cancelLerp();
125
+ this.currentLerp = undefined;
126
+ };
127
+ this.applyData = (data) => {
128
+ if (data.defaultAlpha !== undefined) {
129
+ this.defaultAlpha = data.defaultAlpha;
130
+ }
131
+ if (data.defaultBeta !== undefined) {
132
+ this.defaultBeta = data.defaultBeta;
133
+ }
134
+ if (data.defaultRadius !== undefined) {
135
+ this.defaultRadius = data.defaultRadius;
136
+ }
137
+ if (data.defaultTarget !== undefined) {
138
+ const { x, y, z } = data.defaultTarget;
139
+ this.defaultTarget = new _1.Vector3(x, y, z);
140
+ }
141
+ if (data.nearClip !== undefined) {
142
+ this.nearClip = data.nearClip;
143
+ }
144
+ if (data.farClip !== undefined) {
145
+ this.farClip = data.farClip;
146
+ }
147
+ if (data.alphaLimit !== undefined) {
148
+ this.setAlphaLimits(data.alphaLimit.min, data.alphaLimit.max);
149
+ }
150
+ if (data.betaLimit !== undefined) {
151
+ this.setBetaLimits(data.betaLimit.min, data.betaLimit.max);
152
+ }
153
+ if (data.radiusLimit !== undefined) {
154
+ this.setRadiusLimits(data.radiusLimit.min, data.radiusLimit.max);
155
+ }
156
+ if (data.targetLimit !== undefined) {
157
+ const { max, min } = data.targetLimit;
158
+ this.setTargetLimits(new _1.Vector3(min.x, min.y, min.z), new _1.Vector3(max.x, max.y, max.z));
159
+ }
160
+ if (data.dollyRollSensitivity !== undefined) {
161
+ this.dollyRollSensitivity = data.dollyRollSensitivity;
162
+ }
163
+ if (data.dollyPixelSensitivity !== undefined) {
164
+ this.dollyPixelSensitivity = data.dollyPixelSensitivity;
165
+ }
166
+ if (data.dollyPinchSensitivity !== undefined) {
167
+ this.dollyPinchSensitivity = data.dollyPinchSensitivity;
168
+ }
169
+ if (data.orbitPixelSensitivity !== undefined) {
170
+ this.orbitPixelSensitivity = data.orbitPixelSensitivity;
171
+ }
172
+ };
173
+ this.addObserver = (observer) => {
174
+ this.observers.add(observer);
175
+ };
176
+ this.removeObserver = (observer) => {
177
+ this.observers.remove(observer);
178
+ };
179
+ }
180
+ get alpha() {
181
+ return this.memoizedAlpha.val;
182
+ }
183
+ set alpha(val) {
184
+ let clampedVal = this.clampAngle(val);
185
+ if (this.limitAlpha) {
186
+ clampedVal = Math.min(clampedVal, this.maxAlpha);
187
+ clampedVal = Math.max(clampedVal, this.minAlpha);
188
+ }
189
+ this.memoizedAlpha.val = clampedVal;
190
+ }
191
+ get beta() {
192
+ return this.memoizedBeta.val;
193
+ }
194
+ set beta(val) {
195
+ let clampedVal = this.clampAngle(val);
196
+ if (this.limitBeta) {
197
+ clampedVal = Math.min(clampedVal, this.maxBeta);
198
+ clampedVal = Math.max(clampedVal, this.minBeta);
199
+ }
200
+ this.memoizedBeta.val = clampedVal;
201
+ }
202
+ get radius() {
203
+ return this.memoizedRadius.val;
204
+ }
205
+ set radius(val) {
206
+ let clampedVal = Math.max(val, 0);
207
+ if (this.limitRadius) {
208
+ clampedVal = Math.min(clampedVal, this.maxRadius);
209
+ clampedVal = Math.max(clampedVal, this.minRadius);
210
+ }
211
+ this.memoizedRadius.val = clampedVal;
212
+ }
213
+ get target() {
214
+ return this.memoizedTarget.getVector();
215
+ }
216
+ set target(val) {
217
+ const targetVals = val.asArray();
218
+ if (this.limitTarget) {
219
+ const maxVals = this.maxTargetPosition.asArray();
220
+ const minVals = this.minTargetPosition.asArray();
221
+ for (let i = 0; i < 3; i++) {
222
+ let v = targetVals[i];
223
+ v = Math.min(v, maxVals[i]);
224
+ v = Math.max(v, minVals[i]);
225
+ targetVals[i] = v;
226
+ }
227
+ }
228
+ this.memoizedTarget.setVector(new _1.Vector3(targetVals[0], targetVals[1], targetVals[2]));
229
+ }
230
+ clampAngle(angle) {
231
+ const isNegative = angle < 0 ? true : false;
232
+ const absAngle = Math.abs(angle);
233
+ const revolutions = Math.floor(absAngle / 360);
234
+ let angleWithoutRevolutions = absAngle - revolutions * 360;
235
+ if (angleWithoutRevolutions > 180) {
236
+ angleWithoutRevolutions = angleWithoutRevolutions - 360;
237
+ }
238
+ if (isNegative) {
239
+ angleWithoutRevolutions *= -1;
240
+ }
241
+ return angleWithoutRevolutions;
242
+ }
243
+ }
@@ -0,0 +1,29 @@
1
+ import { Vector3 } from "../ValueObjects/Vector3";
2
+ export interface LineParameters {
3
+ x0: number;
4
+ y0: number;
5
+ z0: number;
6
+ a: number;
7
+ b: number;
8
+ c: number;
9
+ }
10
+ export declare class ParametricLine {
11
+ private x0;
12
+ private y0;
13
+ private z0;
14
+ private a;
15
+ private b;
16
+ private c;
17
+ static FromTwoPoint(p1: Vector3, p2: Vector3): ParametricLine;
18
+ static FromPointDirection(point: Vector3, direction: Vector3): ParametricLine;
19
+ static Forward(): ParametricLine;
20
+ static Backward(): ParametricLine;
21
+ static Up(): ParametricLine;
22
+ static Down(): ParametricLine;
23
+ static Left(): ParametricLine;
24
+ static Right(): ParametricLine;
25
+ getPointAtDistance(distance: number): Vector3;
26
+ getParameters(): LineParameters;
27
+ copy(): ParametricLine;
28
+ constructor(parameters: LineParameters);
29
+ }
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ParametricLine = void 0;
4
+ const Vector3_1 = require("../ValueObjects/Vector3");
5
+ class ParametricLine {
6
+ constructor(parameters) {
7
+ this.x0 = parameters.x0;
8
+ this.y0 = parameters.y0;
9
+ this.z0 = parameters.z0;
10
+ this.a = parameters.a;
11
+ this.b = parameters.b;
12
+ this.c = parameters.c;
13
+ }
14
+ static FromTwoPoint(p1, p2) {
15
+ const dir = Vector3_1.Vector3.subtract(p2, p1).unit;
16
+ return this.FromPointDirection(p1, dir);
17
+ }
18
+ static FromPointDirection(point, direction) {
19
+ return new ParametricLine({
20
+ x0: point.x,
21
+ y0: point.y,
22
+ z0: point.z,
23
+ a: direction.x,
24
+ b: direction.y,
25
+ c: direction.z,
26
+ });
27
+ }
28
+ static Forward() {
29
+ const p = Vector3_1.Vector3.zero();
30
+ const d = new Vector3_1.Vector3(0, 0, 1);
31
+ return this.FromPointDirection(p, d);
32
+ }
33
+ static Backward() {
34
+ const p = Vector3_1.Vector3.zero();
35
+ const d = new Vector3_1.Vector3(0, 0, -1);
36
+ return this.FromPointDirection(p, d);
37
+ }
38
+ static Up() {
39
+ const p = Vector3_1.Vector3.zero();
40
+ const d = new Vector3_1.Vector3(0, 1, 0);
41
+ return this.FromPointDirection(p, d);
42
+ }
43
+ static Down() {
44
+ const p = Vector3_1.Vector3.zero();
45
+ const d = new Vector3_1.Vector3(0, -1, 0);
46
+ return this.FromPointDirection(p, d);
47
+ }
48
+ static Left() {
49
+ const p = Vector3_1.Vector3.zero();
50
+ const d = new Vector3_1.Vector3(-1, 0, 0);
51
+ return this.FromPointDirection(p, d);
52
+ }
53
+ static Right() {
54
+ const p = Vector3_1.Vector3.zero();
55
+ const d = new Vector3_1.Vector3(1, 0, 0);
56
+ return this.FromPointDirection(p, d);
57
+ }
58
+ getPointAtDistance(distance) {
59
+ const x = this.x0 + this.a * distance;
60
+ const y = this.y0 + this.b * distance;
61
+ const z = this.z0 + this.c * distance;
62
+ return new Vector3_1.Vector3(x, y, z);
63
+ }
64
+ getParameters() {
65
+ return {
66
+ x0: this.x0,
67
+ y0: this.y0,
68
+ z0: this.z0,
69
+ a: this.a,
70
+ b: this.b,
71
+ c: this.c,
72
+ };
73
+ }
74
+ copy() {
75
+ const parameters = this.getParameters();
76
+ return new ParametricLine(parameters);
77
+ }
78
+ }
79
+ exports.ParametricLine = ParametricLine;
@@ -0,0 +1,20 @@
1
+ import { ParametricLine } from "./ParametricLine";
2
+ import { Vector3 } from "../ValueObjects/Vector3";
3
+ export interface PlaneParameters {
4
+ a: number;
5
+ b: number;
6
+ c: number;
7
+ d: number;
8
+ }
9
+ export declare class ParametricPlane {
10
+ private point;
11
+ private normal;
12
+ static FromPointNormal(point: Vector3, normal: Vector3): ParametricPlane;
13
+ static FromThreePoints(A: Vector3, B: Vector3, C: Vector3): ParametricPlane;
14
+ static XY(): ParametricPlane;
15
+ static ZX(): ParametricPlane;
16
+ static YZ(): ParametricPlane;
17
+ getParameters(): PlaneParameters;
18
+ intersectLine(line: ParametricLine): Vector3 | undefined;
19
+ constructor(point: Vector3, normal: Vector3);
20
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ParametricPlane = void 0;
4
+ const Vector3_1 = require("../ValueObjects/Vector3");
5
+ class ParametricPlane {
6
+ constructor(point, normal) {
7
+ this.point = point;
8
+ this.normal = normal;
9
+ }
10
+ static FromPointNormal(point, normal) {
11
+ return new ParametricPlane(point, normal);
12
+ }
13
+ static FromThreePoints(A, B, C) {
14
+ const point = A;
15
+ const AB = Vector3_1.Vector3.subtract(B, A);
16
+ const AC = Vector3_1.Vector3.subtract(C, A);
17
+ const normal = Vector3_1.Vector3.cross(AB, AC);
18
+ return new ParametricPlane(point, normal);
19
+ }
20
+ static XY() {
21
+ const p = Vector3_1.Vector3.zero();
22
+ const n = new Vector3_1.Vector3(0, 0, 1);
23
+ return new ParametricPlane(p, n);
24
+ }
25
+ static ZX() {
26
+ const p = Vector3_1.Vector3.zero();
27
+ const n = new Vector3_1.Vector3(0, 1, 0);
28
+ return new ParametricPlane(p, n);
29
+ }
30
+ static YZ() {
31
+ const p = Vector3_1.Vector3.zero();
32
+ const n = new Vector3_1.Vector3(1, 0, 0);
33
+ return new ParametricPlane(p, n);
34
+ }
35
+ getParameters() {
36
+ const a = this.normal.x;
37
+ const b = this.normal.y;
38
+ const c = this.normal.z;
39
+ let d = Vector3_1.Vector3.dot(this.point, this.normal);
40
+ if (d !== 0) {
41
+ d *= -1;
42
+ }
43
+ return {
44
+ a,
45
+ b,
46
+ c,
47
+ d,
48
+ };
49
+ }
50
+ intersectLine(line) {
51
+ const { x0, y0, z0, a, b, c } = line.getParameters();
52
+ const { a: A, b: B, c: C, d: D } = this.getParameters();
53
+ const tNumerator = -(A * x0 + B * y0 + C * z0 + D);
54
+ const tDenominator = A * a + B * b + C * c;
55
+ if (tDenominator === 0) {
56
+ return undefined;
57
+ }
58
+ const t = tNumerator / tDenominator;
59
+ const intersect = line.getPointAtDistance(t);
60
+ return intersect;
61
+ }
62
+ }
63
+ exports.ParametricPlane = ParametricPlane;
@@ -0,0 +1,69 @@
1
+ import { Quaternion, Vector3 } from "../ValueObjects";
2
+ import { EaseFn, TransformNode } from "./TransformNode";
3
+ export declare type OnSceneRootChange = () => void;
4
+ export interface DefaultSceneRootData {
5
+ position: [number, number, number];
6
+ rotation: [number, number, number, number];
7
+ scale: number;
8
+ id: string;
9
+ minScale: number;
10
+ maxScale: number;
11
+ }
12
+ export interface SceneRoot {
13
+ /**
14
+ * The default position of the scene root in local coordinates
15
+ */
16
+ defaultPosition: Vector3;
17
+ /**
18
+ * The default rotation of the scene root in local coordinates
19
+ */
20
+ defaultRoation: Quaternion;
21
+ /**
22
+ * The default scale of the scene root in local coordinates
23
+ */
24
+ defaultScale: Vector3;
25
+ /**
26
+ * The minimum scale allowed for the scene root
27
+ */
28
+ minScale: number;
29
+ /**
30
+ * The maximum scale allowed for the scene root
31
+ */
32
+ maxScale: number;
33
+ /**
34
+ * The identifier for the scene root
35
+ */
36
+ id: string;
37
+ /**
38
+ * Transform node for the scene root
39
+ */
40
+ transform: TransformNode;
41
+ /**
42
+ * Applies the default data to this entity. This will not trigger a notification
43
+ */
44
+ applyDefaultData: (data: DefaultSceneRootData) => void;
45
+ /**
46
+ * Smoothly moves the transform so that the point is a the world origin
47
+ * @param point The point to center on in world coordinates
48
+ * @param durationMS The duration of the transition in milliseconds
49
+ * @param easeFn The easing funciton
50
+ * @param onCompleted An optional callback function when the ease is completed
51
+ */
52
+ centerOnPoint: (point: Vector3, durationMS: number, easeFn: EaseFn, onCompleted?: () => void) => void;
53
+ /**
54
+ * Smoothly moves the transform so that it is back in the default pose
55
+ * @param durationMS The duration of the transition in milliseconds
56
+ * @param easeFn The easing funciton
57
+ * @param onCompleted An optional callback function when the ease is completed
58
+ */
59
+ lerpToDefault: (durationMS: number, easeFn: EaseFn, onCompleted?: () => void) => void;
60
+ /**
61
+ * Bumps the scale of the root by a specific amount. Note this will enforce the min and max limits
62
+ * @param amount The world amount to bump the scale by. It will be applied uniformly
63
+ * @param worldPoint The world position about which to apply the scaling
64
+ */
65
+ bumpScaleAboutPoint: (amount: number, worldPoint: Vector3) => void;
66
+ addObserver: (observer: OnSceneRootChange) => void;
67
+ removeObserver: (observer: OnSceneRootChange) => void;
68
+ }
69
+ export declare function makeSceneRoot(): SceneRoot;