@vived/app 2.15.6 → 2.17.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.
- package/lib/Entities/Babylon.d.ts +13 -1
- package/lib/Entities/Babylon.js +45 -1
- package/lib/Entities/FocusCamera.js +57 -28
- package/lib/Entities/QuestionChallenge.js +1 -1
- package/lib/Entities/StateMachine.d.ts +3 -2
- package/lib/Entities/StateMachine.js +9 -2
- package/lib/UseCases/FocusCamera/PixelOrbitFocusCamera.js +2 -1
- package/lib/UseCases/FocusCamera/PixelPlanePanFocusCamera.js +2 -1
- package/lib/Utilities/lerpNumber.d.ts +1 -0
- package/lib/Utilities/lerpNumber.js +18 -0
- package/lib/ValueObjects/Result.d.ts +30 -0
- package/lib/ValueObjects/Result.js +45 -0
- package/lib/ValueObjects/Vector3.d.ts +1 -0
- package/lib/ValueObjects/Vector3.js +7 -0
- package/lib/ValueObjects/index.d.ts +1 -0
- package/lib/ValueObjects/index.js +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ParametricLine, Vector2, Vector3 } from "../ValueObjects";
|
|
1
|
+
import { ParametricLine, Result, Vector2, Vector3 } from "../ValueObjects";
|
|
2
2
|
export declare type OnBabylonChange = () => void;
|
|
3
3
|
export interface ScenePick {
|
|
4
4
|
mouseRay: ParametricLine;
|
|
@@ -16,6 +16,8 @@ export interface Babylon {
|
|
|
16
16
|
renderCanvas?: HTMLCanvasElement;
|
|
17
17
|
scenePick: (pixelPos: Vector2) => ScenePick;
|
|
18
18
|
sceneRay: (pixelPos: Vector2) => ParametricLine;
|
|
19
|
+
sceneObjectPick: (pixelPos: Vector2) => Result<string, SceneObjectPickErrors>;
|
|
20
|
+
makeSceneObjectMeta: (id: string) => object;
|
|
19
21
|
updateCanvasSize: () => void;
|
|
20
22
|
submitRenderCanvas: (canvas: HTMLCanvasElement) => void;
|
|
21
23
|
clearRenderCanvas: () => void;
|
|
@@ -28,3 +30,13 @@ export interface Babylon {
|
|
|
28
30
|
removeObserver: (observer: OnBabylonChange) => void;
|
|
29
31
|
}
|
|
30
32
|
export declare function makeBabylon(): Babylon;
|
|
33
|
+
export declare class SceneObjectPickErrorNoPicker extends Error {
|
|
34
|
+
constructor();
|
|
35
|
+
}
|
|
36
|
+
export declare class SceneObjectPickErrorNoPick extends Error {
|
|
37
|
+
constructor();
|
|
38
|
+
}
|
|
39
|
+
export declare class SceneObjectPickErrorNoID extends Error {
|
|
40
|
+
constructor();
|
|
41
|
+
}
|
|
42
|
+
export declare type SceneObjectPickErrors = SceneObjectPickErrorNoPicker | SceneObjectPickErrorNoPick | SceneObjectPickErrorNoID;
|
package/lib/Entities/Babylon.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeBabylon = void 0;
|
|
3
|
+
exports.SceneObjectPickErrorNoID = exports.SceneObjectPickErrorNoPick = exports.SceneObjectPickErrorNoPicker = exports.makeBabylon = void 0;
|
|
4
4
|
const ValueObjects_1 = require("../ValueObjects");
|
|
5
5
|
const MemoizedBoolean_1 = require("./MemoizedBoolean");
|
|
6
6
|
const MemoizedVector2_1 = require("./MemoizedVector2");
|
|
@@ -11,6 +11,7 @@ function makeBabylon() {
|
|
|
11
11
|
exports.makeBabylon = makeBabylon;
|
|
12
12
|
class BabylonImp {
|
|
13
13
|
constructor() {
|
|
14
|
+
this._scenePickerHasBeenSet = false;
|
|
14
15
|
this.scenePick = () => {
|
|
15
16
|
console.warn("orignal scene picker");
|
|
16
17
|
return {
|
|
@@ -73,10 +74,32 @@ class BabylonImp {
|
|
|
73
74
|
};
|
|
74
75
|
this.registerScenePicker = (picker) => {
|
|
75
76
|
this.scenePick = picker;
|
|
77
|
+
this._scenePickerHasBeenSet = true;
|
|
76
78
|
};
|
|
77
79
|
this.registerSceneRayer = (rayer) => {
|
|
78
80
|
this.sceneRay = rayer;
|
|
79
81
|
};
|
|
82
|
+
this.sceneObjectPick = (pixelPos) => {
|
|
83
|
+
var _a;
|
|
84
|
+
if (!this._scenePickerHasBeenSet) {
|
|
85
|
+
return ValueObjects_1.reject(new SceneObjectPickErrorNoPicker());
|
|
86
|
+
}
|
|
87
|
+
const scenePick = this.scenePick(pixelPos);
|
|
88
|
+
if (!scenePick.hit) {
|
|
89
|
+
return ValueObjects_1.reject(new SceneObjectPickErrorNoPick());
|
|
90
|
+
}
|
|
91
|
+
if (!((_a = scenePick.objectPickMeta) === null || _a === void 0 ? void 0 : _a.hasOwnProperty("sceneObjectID"))) {
|
|
92
|
+
return ValueObjects_1.reject(new SceneObjectPickErrorNoID());
|
|
93
|
+
}
|
|
94
|
+
const sceneObjectId = scenePick.objectPickMeta.sceneObjectID;
|
|
95
|
+
if (!sceneObjectId) {
|
|
96
|
+
return ValueObjects_1.reject(new SceneObjectPickErrorNoID());
|
|
97
|
+
}
|
|
98
|
+
return ValueObjects_1.resolve(sceneObjectId);
|
|
99
|
+
};
|
|
100
|
+
this.makeSceneObjectMeta = (id) => {
|
|
101
|
+
return { sceneObjectID: id };
|
|
102
|
+
};
|
|
80
103
|
this.memoizedShowInspector = new MemoizedBoolean_1.MemoizedBoolean(false, this.observers.notify);
|
|
81
104
|
this.memoizedCanvasSize = new MemoizedVector2_1.MemoizedVector2(ValueObjects_1.Vector2.One(), this.observers.notify);
|
|
82
105
|
}
|
|
@@ -96,3 +119,24 @@ class BabylonImp {
|
|
|
96
119
|
this.memoizedCanvasSize.val = val;
|
|
97
120
|
}
|
|
98
121
|
}
|
|
122
|
+
class SceneObjectPickErrorNoPicker extends Error {
|
|
123
|
+
constructor() {
|
|
124
|
+
super();
|
|
125
|
+
this.message = "No picker has been registered";
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.SceneObjectPickErrorNoPicker = SceneObjectPickErrorNoPicker;
|
|
129
|
+
class SceneObjectPickErrorNoPick extends Error {
|
|
130
|
+
constructor() {
|
|
131
|
+
super();
|
|
132
|
+
this.message = "Nothing was picked on";
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.SceneObjectPickErrorNoPick = SceneObjectPickErrorNoPick;
|
|
136
|
+
class SceneObjectPickErrorNoID extends Error {
|
|
137
|
+
constructor() {
|
|
138
|
+
super();
|
|
139
|
+
this.message = "Picked object does not have a scene ID";
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.SceneObjectPickErrorNoID = SceneObjectPickErrorNoID;
|
|
@@ -33,14 +33,18 @@ class FocusCameraImp {
|
|
|
33
33
|
this.memoizedRadius = new _1.MemoizedNumber(1, this.observers.notify);
|
|
34
34
|
this.memoizedTarget = new _1.MemoizedVector3(ValueObjects_1.Vector3.Zero(), this.observers.notify);
|
|
35
35
|
this.setRadiusLimits = (min, max) => {
|
|
36
|
+
let minToUse = min;
|
|
37
|
+
let maxToUse = max;
|
|
36
38
|
if (min < 0) {
|
|
37
|
-
|
|
39
|
+
console.warn("[Orbit Camera Entity] Mininum Radius must be greater >= 0, forcing to 0");
|
|
40
|
+
minToUse = 0;
|
|
38
41
|
}
|
|
39
|
-
if (max <
|
|
40
|
-
|
|
42
|
+
if (max < minToUse) {
|
|
43
|
+
console.warn(`[Orbit Camera] Max radius must be >= min radius. Forcing to ${minToUse}`);
|
|
44
|
+
maxToUse = minToUse;
|
|
41
45
|
}
|
|
42
|
-
this.maxRadius =
|
|
43
|
-
this.minRadius =
|
|
46
|
+
this.maxRadius = maxToUse;
|
|
47
|
+
this.minRadius = minToUse;
|
|
44
48
|
this.limitRadius = true;
|
|
45
49
|
this.radius = this.radius;
|
|
46
50
|
};
|
|
@@ -50,17 +54,26 @@ class FocusCameraImp {
|
|
|
50
54
|
this.limitRadius = false;
|
|
51
55
|
};
|
|
52
56
|
this.setAlphaLimits = (min, max) => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
57
|
+
let minToUse = min;
|
|
58
|
+
let maxToUse = max;
|
|
56
59
|
if (min < -180) {
|
|
57
|
-
|
|
60
|
+
minToUse = -180;
|
|
61
|
+
console.warn("[Orbit Camera] Min alpha must be >= -180. Forcing to -180");
|
|
58
62
|
}
|
|
59
63
|
if (max > 180) {
|
|
60
|
-
|
|
64
|
+
maxToUse = 180;
|
|
65
|
+
console.warn("[Orbit Camera] Max alpha must be <= 180. Forcing to 180");
|
|
66
|
+
}
|
|
67
|
+
if (minToUse > maxToUse) {
|
|
68
|
+
const absMin = Math.abs(minToUse);
|
|
69
|
+
const absMax = Math.abs(maxToUse);
|
|
70
|
+
const closestToZero = absMin < absMax ? minToUse : maxToUse;
|
|
71
|
+
minToUse = closestToZero;
|
|
72
|
+
maxToUse = closestToZero;
|
|
73
|
+
console.warn(`[Orbit Camera] Max alpha must be <= Min Alpha. Forcing to ${closestToZero}`);
|
|
61
74
|
}
|
|
62
|
-
this.maxAlpha =
|
|
63
|
-
this.minAlpha =
|
|
75
|
+
this.maxAlpha = maxToUse;
|
|
76
|
+
this.minAlpha = minToUse;
|
|
64
77
|
this.limitAlpha = true;
|
|
65
78
|
this.alpha = this.alpha;
|
|
66
79
|
};
|
|
@@ -70,17 +83,26 @@ class FocusCameraImp {
|
|
|
70
83
|
this.limitAlpha = false;
|
|
71
84
|
};
|
|
72
85
|
this.setBetaLimits = (min, max) => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
86
|
+
let minToUse = min;
|
|
87
|
+
let maxToUse = max;
|
|
76
88
|
if (min < -180) {
|
|
77
|
-
|
|
89
|
+
minToUse = -180;
|
|
90
|
+
console.warn("[Orbit Camera] Min beta must be >= -180. Forcing to -180");
|
|
78
91
|
}
|
|
79
92
|
if (max > 180) {
|
|
80
|
-
|
|
93
|
+
maxToUse = 180;
|
|
94
|
+
console.warn("[Orbit Camera] Max beta must be <= 180. Forcing to 180");
|
|
81
95
|
}
|
|
82
|
-
|
|
83
|
-
|
|
96
|
+
if (minToUse > maxToUse) {
|
|
97
|
+
const absMin = Math.abs(minToUse);
|
|
98
|
+
const absMax = Math.abs(maxToUse);
|
|
99
|
+
const closestToZero = absMin < absMax ? minToUse : maxToUse;
|
|
100
|
+
minToUse = closestToZero;
|
|
101
|
+
maxToUse = closestToZero;
|
|
102
|
+
console.warn(`[Orbit Camera] Max beta must be <= Min beta. Forcing to ${closestToZero}`);
|
|
103
|
+
}
|
|
104
|
+
this.maxBeta = maxToUse;
|
|
105
|
+
this.minBeta = minToUse;
|
|
84
106
|
this.limitBeta = true;
|
|
85
107
|
this.beta = this.beta;
|
|
86
108
|
};
|
|
@@ -94,7 +116,8 @@ class FocusCameraImp {
|
|
|
94
116
|
const maxArray = max.array;
|
|
95
117
|
for (let i = 0; i < 3; i++) {
|
|
96
118
|
if (minArray[i] > maxArray[i]) {
|
|
97
|
-
|
|
119
|
+
console.warn("[Orbit Camera] Target limit min's components must all be <= the max. Limits not set");
|
|
120
|
+
return;
|
|
98
121
|
}
|
|
99
122
|
}
|
|
100
123
|
this.maxTargetPosition = max;
|
|
@@ -166,23 +189,29 @@ class FocusCameraImp {
|
|
|
166
189
|
return this.memoizedAlpha.val;
|
|
167
190
|
}
|
|
168
191
|
set alpha(val) {
|
|
169
|
-
let
|
|
192
|
+
let valToUse = val;
|
|
170
193
|
if (this.limitAlpha) {
|
|
171
|
-
|
|
172
|
-
|
|
194
|
+
valToUse = Math.min(valToUse, this.maxAlpha);
|
|
195
|
+
valToUse = Math.max(valToUse, this.minAlpha);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
valToUse = this.clampAngle(val);
|
|
173
199
|
}
|
|
174
|
-
this.memoizedAlpha.val =
|
|
200
|
+
this.memoizedAlpha.val = valToUse;
|
|
175
201
|
}
|
|
176
202
|
get beta() {
|
|
177
203
|
return this.memoizedBeta.val;
|
|
178
204
|
}
|
|
179
205
|
set beta(val) {
|
|
180
|
-
let
|
|
206
|
+
let valToUse = val;
|
|
181
207
|
if (this.limitBeta) {
|
|
182
|
-
|
|
183
|
-
|
|
208
|
+
valToUse = Math.min(valToUse, this.maxBeta);
|
|
209
|
+
valToUse = Math.max(valToUse, this.minBeta);
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
valToUse = this.clampAngle(val);
|
|
184
213
|
}
|
|
185
|
-
this.memoizedBeta.val =
|
|
214
|
+
this.memoizedBeta.val = valToUse;
|
|
186
215
|
}
|
|
187
216
|
get radius() {
|
|
188
217
|
return this.memoizedRadius.val;
|
|
@@ -26,7 +26,7 @@ class QuestionChallengeImp {
|
|
|
26
26
|
};
|
|
27
27
|
this.addAnswer = (answer) => {
|
|
28
28
|
if (this.answerLookup.has(answer.id)) {
|
|
29
|
-
|
|
29
|
+
console.warn(`Answer with ID ${answer.id} already exists. Overwriting`);
|
|
30
30
|
}
|
|
31
31
|
this.answerLookup.set(answer.id, answer);
|
|
32
32
|
this.reset();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Result } from "../ValueObjects";
|
|
1
2
|
export interface SerializedStates {
|
|
2
3
|
version: number;
|
|
3
4
|
systems: SystemState[];
|
|
@@ -17,9 +18,9 @@ export interface SerializedSystem {
|
|
|
17
18
|
export interface StateMachine {
|
|
18
19
|
transitionEaseFunction: (normalizedTime: number) => number;
|
|
19
20
|
getSerializedStates(): SerializedStates;
|
|
20
|
-
setSerializedStates(state: SerializedStates, transitionTime: number):
|
|
21
|
+
setSerializedStates(state: SerializedStates, transitionTime: number): Result<null, Error>;
|
|
21
22
|
applySerializedStatesString: (state: string, duration?: number) => void;
|
|
22
23
|
setDefaultState(transitionTime: number): void;
|
|
23
|
-
registerSerializedSystem(serializedSystem: SerializedSystem):
|
|
24
|
+
registerSerializedSystem(serializedSystem: SerializedSystem): Result<null, Error>;
|
|
24
25
|
}
|
|
25
26
|
export declare function makeStateMachine(): StateMachine;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeStateMachine = void 0;
|
|
4
|
+
const ValueObjects_1 = require("../ValueObjects");
|
|
4
5
|
function makeStateMachine() {
|
|
5
6
|
return new StateMachineImp();
|
|
6
7
|
}
|
|
@@ -29,9 +30,12 @@ class StateMachineImp {
|
|
|
29
30
|
};
|
|
30
31
|
this.registerSerializedSystem = (serializedSystem) => {
|
|
31
32
|
if (this.serializedSystems.has(serializedSystem.name)) {
|
|
32
|
-
|
|
33
|
+
const err = new Error(`[StateMachine] Duplicate stateable systems encountered: ${serializedSystem.name}`);
|
|
34
|
+
console.error(err.message);
|
|
35
|
+
return ValueObjects_1.reject(err);
|
|
33
36
|
}
|
|
34
37
|
this.serializedSystems.set(serializedSystem.name, serializedSystem);
|
|
38
|
+
return ValueObjects_1.resolve(null);
|
|
35
39
|
};
|
|
36
40
|
this.getSerializedStates = () => {
|
|
37
41
|
const systems = Array.from(this.serializedSystems.values());
|
|
@@ -66,10 +70,13 @@ class StateMachineImp {
|
|
|
66
70
|
system.applyDefaultState(duration);
|
|
67
71
|
}
|
|
68
72
|
});
|
|
73
|
+
return ValueObjects_1.resolve(null);
|
|
69
74
|
}
|
|
70
75
|
// Here is where we will add support for future versions
|
|
71
76
|
else {
|
|
72
|
-
|
|
77
|
+
const err = new Error(`[StateMachine] Unsupported sereialized state encountered: ${state.version}`);
|
|
78
|
+
console.error(err.message);
|
|
79
|
+
return ValueObjects_1.reject(err);
|
|
73
80
|
}
|
|
74
81
|
};
|
|
75
82
|
this.setDefaultState = (duration) => {
|
|
@@ -8,7 +8,8 @@ class PixelOrbitFocusCamera {
|
|
|
8
8
|
this.sensitivity = 0.5;
|
|
9
9
|
this.doOrbit = (pixelPosition) => {
|
|
10
10
|
if (!this.previousPixelPos) {
|
|
11
|
-
|
|
11
|
+
console.error("[PixelOrbitFocusCamera] You must initialize first!");
|
|
12
|
+
return;
|
|
12
13
|
}
|
|
13
14
|
const pixelChange = ValueObjects_1.Vector2.Subtract(pixelPosition, this.previousPixelPos);
|
|
14
15
|
this.focusCamera.alpha += pixelChange.x * this.sensitivity;
|
|
@@ -8,7 +8,8 @@ class PixelPlanePanFocusCamera {
|
|
|
8
8
|
this.babylon = babylon;
|
|
9
9
|
this.doPan = (pixelPosition) => {
|
|
10
10
|
if (!this.plane || !this.previousPixelPos) {
|
|
11
|
-
|
|
11
|
+
console.error("[PixelPlanePan_OrbitCamera] You must initialize first!");
|
|
12
|
+
return;
|
|
12
13
|
}
|
|
13
14
|
const initialRay = this.babylon.sceneRay(this.previousPixelPos);
|
|
14
15
|
const finalRay = this.babylon.sceneRay(pixelPosition);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function lerpNumber(start: number, end: number, percent: number, clamp?: boolean): number;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lerpNumber = void 0;
|
|
4
|
+
function lerpNumber(start, end, percent, clamp = false) {
|
|
5
|
+
const range = end - start;
|
|
6
|
+
if (!clamp) {
|
|
7
|
+
return percent * range + start;
|
|
8
|
+
}
|
|
9
|
+
let clampedP = percent;
|
|
10
|
+
if (clampedP < 0) {
|
|
11
|
+
clampedP = 0;
|
|
12
|
+
}
|
|
13
|
+
else if (clampedP > 1) {
|
|
14
|
+
clampedP = 1;
|
|
15
|
+
}
|
|
16
|
+
return clampedP * range + start;
|
|
17
|
+
}
|
|
18
|
+
exports.lerpNumber = lerpNumber;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare type Result<T, E> = Resolved<T, E> | Rejected<T, E>;
|
|
2
|
+
export declare const resolve: <T, E = never>(value: T) => Resolved<T, E>;
|
|
3
|
+
export declare const reject: <T = never, E = unknown>(err: E) => Rejected<T, E>;
|
|
4
|
+
interface IResult<T, E> {
|
|
5
|
+
isResolved: boolean;
|
|
6
|
+
isRejected: boolean;
|
|
7
|
+
value?: T;
|
|
8
|
+
error?: E;
|
|
9
|
+
then<A>(f: (t: T) => A): Result<A, E>;
|
|
10
|
+
catch<U>(f: (e: E) => U): Result<T, U>;
|
|
11
|
+
}
|
|
12
|
+
export declare class Rejected<T, E> implements IResult<T, E> {
|
|
13
|
+
readonly error: E;
|
|
14
|
+
readonly value: undefined;
|
|
15
|
+
get isResolved(): boolean;
|
|
16
|
+
get isRejected(): boolean;
|
|
17
|
+
then<A>(_f: (t: T) => A): Result<A, E>;
|
|
18
|
+
catch<U>(f: (e: E) => U): Result<T, U>;
|
|
19
|
+
constructor(error: E);
|
|
20
|
+
}
|
|
21
|
+
export declare class Resolved<T, E> implements IResult<T, E> {
|
|
22
|
+
readonly value: T;
|
|
23
|
+
readonly error: undefined;
|
|
24
|
+
get isResolved(): boolean;
|
|
25
|
+
get isRejected(): boolean;
|
|
26
|
+
then<A>(f: (t: T) => A): Result<A, E>;
|
|
27
|
+
catch<U>(_f: (e: E) => U): Result<T, U>;
|
|
28
|
+
constructor(value: T);
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Resolved = exports.Rejected = exports.reject = exports.resolve = void 0;
|
|
4
|
+
const resolve = (value) => new Resolved(value);
|
|
5
|
+
exports.resolve = resolve;
|
|
6
|
+
const reject = (err) => new Rejected(err);
|
|
7
|
+
exports.reject = reject;
|
|
8
|
+
class Rejected {
|
|
9
|
+
constructor(error) {
|
|
10
|
+
this.value = undefined;
|
|
11
|
+
this.error = error;
|
|
12
|
+
}
|
|
13
|
+
get isResolved() {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
get isRejected() {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
then(_f) {
|
|
20
|
+
return exports.reject(this.error);
|
|
21
|
+
}
|
|
22
|
+
catch(f) {
|
|
23
|
+
return exports.reject(f(this.error));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.Rejected = Rejected;
|
|
27
|
+
class Resolved {
|
|
28
|
+
constructor(value) {
|
|
29
|
+
this.error = undefined;
|
|
30
|
+
this.value = value;
|
|
31
|
+
}
|
|
32
|
+
get isResolved() {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
get isRejected() {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
then(f) {
|
|
39
|
+
return exports.resolve(f(this.value));
|
|
40
|
+
}
|
|
41
|
+
catch(_f) {
|
|
42
|
+
return exports.resolve(this.value);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.Resolved = Resolved;
|
|
@@ -15,6 +15,7 @@ export declare class Vector3 {
|
|
|
15
15
|
static Cross: (a: Vector3, b: Vector3) => Vector3;
|
|
16
16
|
static Dot: (a: Vector3, b: Vector3) => number;
|
|
17
17
|
static NewVectorOfLength: (vec: Vector3, length: number) => Vector3;
|
|
18
|
+
static Lerp: (initial: Vector3, final: Vector3, percent: number) => Vector3;
|
|
18
19
|
readonly x: number;
|
|
19
20
|
readonly y: number;
|
|
20
21
|
readonly z: number;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Vector3 = void 0;
|
|
4
|
+
const lerpNumber_1 = require("../Utilities/lerpNumber");
|
|
4
5
|
class Vector3 {
|
|
5
6
|
constructor(x, y, z) {
|
|
6
7
|
this.x = x;
|
|
@@ -89,3 +90,9 @@ Vector3.NewVectorOfLength = (vec, length) => {
|
|
|
89
90
|
const unit = vec.unit;
|
|
90
91
|
return new Vector3(length * unit.x, length * unit.y, length * unit.z);
|
|
91
92
|
};
|
|
93
|
+
Vector3.Lerp = (initial, final, percent) => {
|
|
94
|
+
const x = lerpNumber_1.lerpNumber(initial.x, final.x, percent);
|
|
95
|
+
const y = lerpNumber_1.lerpNumber(initial.y, final.y, percent);
|
|
96
|
+
const z = lerpNumber_1.lerpNumber(initial.z, final.z, percent);
|
|
97
|
+
return new Vector3(x, y, z);
|
|
98
|
+
};
|