@bitbybit-dev/base 0.19.8 → 0.20.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/babel.config.cjs +1 -0
- package/babel.config.d.cts +5 -0
- package/index.d.ts +1 -0
- package/{index.ts → index.js} +1 -2
- package/lib/api/index.js +1 -0
- package/lib/api/inputs/base-inputs.d.ts +35 -0
- package/lib/api/inputs/base-inputs.js +1 -0
- package/lib/api/inputs/{color-inputs.ts → color-inputs.d.ts} +26 -48
- package/lib/api/inputs/color-inputs.js +164 -0
- package/lib/api/inputs/dates-inputs.d.ts +216 -0
- package/lib/api/inputs/dates-inputs.js +271 -0
- package/lib/api/inputs/{index.ts → index.d.ts} +1 -0
- package/lib/api/inputs/index.js +10 -0
- package/lib/api/inputs/{inputs.ts → inputs.d.ts} +1 -0
- package/lib/api/inputs/inputs.js +10 -0
- package/lib/api/inputs/{lists-inputs.ts → lists-inputs.d.ts} +91 -190
- package/lib/api/inputs/lists-inputs.js +576 -0
- package/lib/api/inputs/{logic-inputs.ts → logic-inputs.d.ts} +24 -46
- package/lib/api/inputs/logic-inputs.js +111 -0
- package/lib/api/inputs/{math-inputs.ts → math-inputs.d.ts} +53 -97
- package/lib/api/inputs/math-inputs.js +391 -0
- package/lib/api/inputs/{point-inputs.ts → point-inputs.d.ts} +77 -168
- package/lib/api/inputs/point-inputs.js +521 -0
- package/lib/api/inputs/text-inputs.d.ts +83 -0
- package/lib/api/inputs/text-inputs.js +120 -0
- package/lib/api/inputs/{transforms-inputs.ts → transforms-inputs.d.ts} +35 -64
- package/lib/api/inputs/transforms-inputs.js +200 -0
- package/lib/api/inputs/{vector-inputs.ts → vector-inputs.d.ts} +48 -104
- package/lib/api/inputs/vector-inputs.js +304 -0
- package/lib/api/services/color.d.ts +114 -0
- package/lib/api/services/{color.ts → color.js} +15 -34
- package/lib/api/services/dates.d.ts +367 -0
- package/lib/api/services/dates.js +450 -0
- package/lib/api/services/geometry-helper.d.ts +15 -0
- package/lib/api/services/{geometry-helper.ts → geometry-helper.js} +31 -43
- package/lib/api/services/{index.ts → index.d.ts} +2 -1
- package/lib/api/services/index.js +10 -0
- package/lib/api/services/lists.d.ts +287 -0
- package/lib/api/services/{lists.ts → lists.js} +59 -83
- package/lib/api/services/logic.d.ts +99 -0
- package/lib/api/services/{logic.ts → logic.js} +24 -32
- package/lib/api/services/math.d.ts +349 -0
- package/lib/api/services/{math.ts → math.js} +71 -136
- package/lib/api/services/point.d.ts +222 -0
- package/lib/api/services/{point.ts → point.js} +32 -67
- package/lib/api/services/text.d.ts +69 -0
- package/lib/api/services/{text.ts → text.js} +7 -17
- package/lib/api/services/transforms.d.ts +122 -0
- package/lib/api/services/{transforms.ts → transforms.js} +37 -83
- package/lib/api/services/vector.d.ts +320 -0
- package/lib/api/services/{vector.ts → vector.js} +42 -80
- package/lib/{index.ts → index.d.ts} +0 -1
- package/lib/index.js +1 -0
- package/package.json +1 -1
- package/lib/api/inputs/base-inputs.ts +0 -18
- package/lib/api/inputs/text-inputs.ts +0 -108
- package/lib/api/services/color.test.ts +0 -86
- package/lib/api/services/lists.test.ts +0 -612
- package/lib/api/services/logic.test.ts +0 -187
- package/lib/api/services/math.test.ts +0 -622
- package/lib/api/services/text.test.ts +0 -55
- package/lib/api/services/vector.test.ts +0 -360
- package/tsconfig.bitbybit.json +0 -26
- package/tsconfig.json +0 -24
- /package/lib/api/{index.ts → index.d.ts} +0 -0
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import * as Inputs from "../inputs";
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Contains various text methods.
|
|
5
3
|
*/
|
|
6
4
|
export class TextBitByBit {
|
|
7
|
-
|
|
8
5
|
/**
|
|
9
6
|
* Creates a text
|
|
10
7
|
* @param inputs a text
|
|
@@ -13,10 +10,9 @@ export class TextBitByBit {
|
|
|
13
10
|
* @shortname text
|
|
14
11
|
* @drawable false
|
|
15
12
|
*/
|
|
16
|
-
create(inputs
|
|
13
|
+
create(inputs) {
|
|
17
14
|
return inputs.text;
|
|
18
15
|
}
|
|
19
|
-
|
|
20
16
|
/**
|
|
21
17
|
* Split the text to multiple pieces by a separator
|
|
22
18
|
* @param inputs a text
|
|
@@ -25,10 +21,9 @@ export class TextBitByBit {
|
|
|
25
21
|
* @shortname split
|
|
26
22
|
* @drawable false
|
|
27
23
|
*/
|
|
28
|
-
split(inputs
|
|
24
|
+
split(inputs) {
|
|
29
25
|
return inputs.text.split(inputs.separator);
|
|
30
26
|
}
|
|
31
|
-
|
|
32
27
|
/**
|
|
33
28
|
* Replace all occurrences of a text by another text
|
|
34
29
|
* @param inputs a text
|
|
@@ -37,10 +32,9 @@ export class TextBitByBit {
|
|
|
37
32
|
* @shortname replaceAll
|
|
38
33
|
* @drawable false
|
|
39
34
|
*/
|
|
40
|
-
replaceAll(inputs
|
|
35
|
+
replaceAll(inputs) {
|
|
41
36
|
return inputs.text.split(inputs.search).join(inputs.replaceWith);
|
|
42
37
|
}
|
|
43
|
-
|
|
44
38
|
/**
|
|
45
39
|
* Join multiple items by a separator into text
|
|
46
40
|
* @param inputs a list of items
|
|
@@ -49,10 +43,9 @@ export class TextBitByBit {
|
|
|
49
43
|
* @shortname join
|
|
50
44
|
* @drawable false
|
|
51
45
|
*/
|
|
52
|
-
join(inputs
|
|
46
|
+
join(inputs) {
|
|
53
47
|
return inputs.list.join(inputs.separator);
|
|
54
48
|
}
|
|
55
|
-
|
|
56
49
|
/**
|
|
57
50
|
* Transform any item to text
|
|
58
51
|
* @param inputs any item
|
|
@@ -61,10 +54,9 @@ export class TextBitByBit {
|
|
|
61
54
|
* @shortname to string
|
|
62
55
|
* @drawable false
|
|
63
56
|
*/
|
|
64
|
-
toString
|
|
57
|
+
toString(inputs) {
|
|
65
58
|
return inputs.item.toString();
|
|
66
59
|
}
|
|
67
|
-
|
|
68
60
|
/**
|
|
69
61
|
* Transform each item in list to text
|
|
70
62
|
* @param inputs list of items
|
|
@@ -73,10 +65,9 @@ export class TextBitByBit {
|
|
|
73
65
|
* @shortname to strings
|
|
74
66
|
* @drawable false
|
|
75
67
|
*/
|
|
76
|
-
toStringEach
|
|
68
|
+
toStringEach(inputs) {
|
|
77
69
|
return inputs.list.map(i => i.toString());
|
|
78
70
|
}
|
|
79
|
-
|
|
80
71
|
/**
|
|
81
72
|
* Format a text with values
|
|
82
73
|
* @param inputs a text and values
|
|
@@ -85,10 +76,9 @@ export class TextBitByBit {
|
|
|
85
76
|
* @shortname format
|
|
86
77
|
* @drawable false
|
|
87
78
|
*/
|
|
88
|
-
format(inputs
|
|
79
|
+
format(inputs) {
|
|
89
80
|
return inputs.text.replace(/{(\d+)}/g, (match, number) => {
|
|
90
81
|
return typeof inputs.values[number] !== "undefined" ? inputs.values[number] : match;
|
|
91
82
|
});
|
|
92
83
|
}
|
|
93
|
-
|
|
94
84
|
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { Base } from "../inputs/base-inputs";
|
|
2
|
+
import * as Inputs from "../inputs";
|
|
3
|
+
import { MathBitByBit } from "./math";
|
|
4
|
+
import { Vector } from "./vector";
|
|
5
|
+
/**
|
|
6
|
+
* Transformations help to move, scale, rotate objects. You can combine multiple transformations
|
|
7
|
+
* for object to be placed exactly into position and orientation that you want.
|
|
8
|
+
* Contains various methods for transformations that represent 4x4 matrixes in flat 16 number arrays.
|
|
9
|
+
*/
|
|
10
|
+
export declare class Transforms {
|
|
11
|
+
private readonly vector;
|
|
12
|
+
private readonly math;
|
|
13
|
+
constructor(vector: Vector, math: MathBitByBit);
|
|
14
|
+
/**
|
|
15
|
+
* Creates a rotation transformations around the center and an axis
|
|
16
|
+
* @param inputs Rotation around center with an axis information
|
|
17
|
+
* @returns array of transformations
|
|
18
|
+
* @group rotation
|
|
19
|
+
* @shortname center axis
|
|
20
|
+
* @drawable false
|
|
21
|
+
*/
|
|
22
|
+
rotationCenterAxis(inputs: Inputs.Transforms.RotationCenterAxisDto): Base.TransformMatrixes;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a rotation transformations around the center and an X axis
|
|
25
|
+
* @param inputs Rotation around center with an X axis information
|
|
26
|
+
* @returns array of transformations
|
|
27
|
+
* @group rotation
|
|
28
|
+
* @shortname center x
|
|
29
|
+
* @drawable false
|
|
30
|
+
*/
|
|
31
|
+
rotationCenterX(inputs: Inputs.Transforms.RotationCenterDto): Base.TransformMatrixes;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a rotation transformations around the center and an Y axis
|
|
34
|
+
* @param inputs Rotation around center with an Y axis information
|
|
35
|
+
* @returns array of transformations
|
|
36
|
+
* @group rotation
|
|
37
|
+
* @shortname center y
|
|
38
|
+
* @drawable false
|
|
39
|
+
*/
|
|
40
|
+
rotationCenterY(inputs: Inputs.Transforms.RotationCenterDto): Base.TransformMatrixes;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a rotation transformations around the center and an Z axis
|
|
43
|
+
* @param inputs Rotation around center with an Z axis information
|
|
44
|
+
* @returns array of transformations
|
|
45
|
+
* @group rotation
|
|
46
|
+
* @shortname center z
|
|
47
|
+
* @drawable false
|
|
48
|
+
*/
|
|
49
|
+
rotationCenterZ(inputs: Inputs.Transforms.RotationCenterDto): Base.TransformMatrixes;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a rotation transformations with yaw pitch and roll
|
|
52
|
+
* @param inputs Yaw pitch roll rotation information
|
|
53
|
+
* @returns array of transformations
|
|
54
|
+
* @group rotation
|
|
55
|
+
* @shortname yaw pitch roll
|
|
56
|
+
* @drawable false
|
|
57
|
+
*/
|
|
58
|
+
rotationCenterYawPitchRoll(inputs: Inputs.Transforms.RotationCenterYawPitchRollDto): Base.TransformMatrixes;
|
|
59
|
+
/**
|
|
60
|
+
* Scale transformation around center and xyz directions
|
|
61
|
+
* @param inputs Scale center xyz trnansformation
|
|
62
|
+
* @returns array of transformations
|
|
63
|
+
* @group rotation
|
|
64
|
+
* @shortname center xyz
|
|
65
|
+
* @drawable false
|
|
66
|
+
*/
|
|
67
|
+
scaleCenterXYZ(inputs: Inputs.Transforms.ScaleCenterXYZDto): Base.TransformMatrixes;
|
|
68
|
+
/**
|
|
69
|
+
* Creates the scale transformation in x, y and z directions
|
|
70
|
+
* @param inputs Scale XYZ number array information
|
|
71
|
+
* @returns transformation
|
|
72
|
+
* @group scale
|
|
73
|
+
* @shortname xyz
|
|
74
|
+
* @drawable false
|
|
75
|
+
*/
|
|
76
|
+
scaleXYZ(inputs: Inputs.Transforms.ScaleXYZDto): Base.TransformMatrixes;
|
|
77
|
+
/**
|
|
78
|
+
* Creates uniform scale transformation
|
|
79
|
+
* @param inputs Scale Dto
|
|
80
|
+
* @returns transformation
|
|
81
|
+
* @group scale
|
|
82
|
+
* @shortname uniform
|
|
83
|
+
* @drawable false
|
|
84
|
+
*/
|
|
85
|
+
uniformScale(inputs: Inputs.Transforms.UniformScaleDto): Base.TransformMatrixes;
|
|
86
|
+
/**
|
|
87
|
+
* Creates uniform scale transformation from the center
|
|
88
|
+
* @param inputs Scale Dto with center point information
|
|
89
|
+
* @returns array of transformations
|
|
90
|
+
* @group scale
|
|
91
|
+
* @shortname uniform from center
|
|
92
|
+
* @drawable false
|
|
93
|
+
*/
|
|
94
|
+
uniformScaleFromCenter(inputs: Inputs.Transforms.UniformScaleFromCenterDto): Base.TransformMatrixes;
|
|
95
|
+
/**
|
|
96
|
+
* Creates the translation transformation
|
|
97
|
+
* @param inputs Translation information
|
|
98
|
+
* @returns transformation
|
|
99
|
+
* @group translation
|
|
100
|
+
* @shortname xyz
|
|
101
|
+
* @drawable false
|
|
102
|
+
*/
|
|
103
|
+
translationXYZ(inputs: Inputs.Transforms.TranslationXYZDto): Base.TransformMatrixes;
|
|
104
|
+
/**
|
|
105
|
+
* Creates the translation transformation
|
|
106
|
+
* @param inputs Translation information
|
|
107
|
+
* @returns transformation
|
|
108
|
+
* @group translations
|
|
109
|
+
* @shortname xyz
|
|
110
|
+
* @drawable false
|
|
111
|
+
*/
|
|
112
|
+
translationsXYZ(inputs: Inputs.Transforms.TranslationsXYZDto): Base.TransformMatrixes[];
|
|
113
|
+
private translation;
|
|
114
|
+
private scaling;
|
|
115
|
+
private identity;
|
|
116
|
+
private rotationAxis;
|
|
117
|
+
private rotationX;
|
|
118
|
+
private rotationY;
|
|
119
|
+
private rotationZ;
|
|
120
|
+
private rotationYawPitchRoll;
|
|
121
|
+
private rotationMatrixFromQuat;
|
|
122
|
+
}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
import { Base } from "../inputs/base-inputs";
|
|
3
|
-
import * as Inputs from "../inputs";
|
|
4
|
-
import { MathBitByBit } from "./math";
|
|
5
|
-
import { Vector } from "./vector";
|
|
6
|
-
|
|
7
1
|
/**
|
|
8
2
|
* Transformations help to move, scale, rotate objects. You can combine multiple transformations
|
|
9
3
|
* for object to be placed exactly into position and orientation that you want.
|
|
10
4
|
* Contains various methods for transformations that represent 4x4 matrixes in flat 16 number arrays.
|
|
11
5
|
*/
|
|
12
6
|
export class Transforms {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
constructor(vector, math) {
|
|
8
|
+
this.vector = vector;
|
|
9
|
+
this.math = math;
|
|
10
|
+
}
|
|
16
11
|
/**
|
|
17
12
|
* Creates a rotation transformations around the center and an axis
|
|
18
13
|
* @param inputs Rotation around center with an axis information
|
|
@@ -21,17 +16,13 @@ export class Transforms {
|
|
|
21
16
|
* @shortname center axis
|
|
22
17
|
* @drawable false
|
|
23
18
|
*/
|
|
24
|
-
rotationCenterAxis(inputs
|
|
19
|
+
rotationCenterAxis(inputs) {
|
|
25
20
|
return [
|
|
26
21
|
this.translation(-inputs.center[0], -inputs.center[1], -inputs.center[2]),
|
|
27
|
-
this.rotationAxis(
|
|
28
|
-
inputs.axis,
|
|
29
|
-
this.math.degToRad({ number: inputs.angle })
|
|
30
|
-
),
|
|
22
|
+
this.rotationAxis(inputs.axis, this.math.degToRad({ number: inputs.angle })),
|
|
31
23
|
this.translation(inputs.center[0], inputs.center[1], inputs.center[2]),
|
|
32
|
-
]
|
|
24
|
+
];
|
|
33
25
|
}
|
|
34
|
-
|
|
35
26
|
/**
|
|
36
27
|
* Creates a rotation transformations around the center and an X axis
|
|
37
28
|
* @param inputs Rotation around center with an X axis information
|
|
@@ -40,14 +31,13 @@ export class Transforms {
|
|
|
40
31
|
* @shortname center x
|
|
41
32
|
* @drawable false
|
|
42
33
|
*/
|
|
43
|
-
rotationCenterX(inputs
|
|
34
|
+
rotationCenterX(inputs) {
|
|
44
35
|
return [
|
|
45
36
|
this.translation(-inputs.center[0], -inputs.center[1], -inputs.center[2]),
|
|
46
37
|
this.rotationX(this.math.degToRad({ number: inputs.angle })),
|
|
47
38
|
this.translation(inputs.center[0], inputs.center[1], inputs.center[2]),
|
|
48
|
-
]
|
|
39
|
+
];
|
|
49
40
|
}
|
|
50
|
-
|
|
51
41
|
/**
|
|
52
42
|
* Creates a rotation transformations around the center and an Y axis
|
|
53
43
|
* @param inputs Rotation around center with an Y axis information
|
|
@@ -56,14 +46,13 @@ export class Transforms {
|
|
|
56
46
|
* @shortname center y
|
|
57
47
|
* @drawable false
|
|
58
48
|
*/
|
|
59
|
-
rotationCenterY(inputs
|
|
49
|
+
rotationCenterY(inputs) {
|
|
60
50
|
return [
|
|
61
51
|
this.translation(-inputs.center[0], -inputs.center[1], -inputs.center[2]),
|
|
62
52
|
this.rotationY(this.math.degToRad({ number: inputs.angle })),
|
|
63
53
|
this.translation(inputs.center[0], inputs.center[1], inputs.center[2]),
|
|
64
|
-
]
|
|
54
|
+
];
|
|
65
55
|
}
|
|
66
|
-
|
|
67
56
|
/**
|
|
68
57
|
* Creates a rotation transformations around the center and an Z axis
|
|
69
58
|
* @param inputs Rotation around center with an Z axis information
|
|
@@ -72,14 +61,13 @@ export class Transforms {
|
|
|
72
61
|
* @shortname center z
|
|
73
62
|
* @drawable false
|
|
74
63
|
*/
|
|
75
|
-
rotationCenterZ(inputs
|
|
64
|
+
rotationCenterZ(inputs) {
|
|
76
65
|
return [
|
|
77
66
|
this.translation(-inputs.center[0], -inputs.center[1], -inputs.center[2]),
|
|
78
67
|
this.rotationZ(this.math.degToRad({ number: inputs.angle })),
|
|
79
68
|
this.translation(inputs.center[0], inputs.center[1], inputs.center[2]),
|
|
80
|
-
]
|
|
69
|
+
];
|
|
81
70
|
}
|
|
82
|
-
|
|
83
71
|
/**
|
|
84
72
|
* Creates a rotation transformations with yaw pitch and roll
|
|
85
73
|
* @param inputs Yaw pitch roll rotation information
|
|
@@ -88,17 +76,13 @@ export class Transforms {
|
|
|
88
76
|
* @shortname yaw pitch roll
|
|
89
77
|
* @drawable false
|
|
90
78
|
*/
|
|
91
|
-
rotationCenterYawPitchRoll(inputs
|
|
79
|
+
rotationCenterYawPitchRoll(inputs) {
|
|
92
80
|
return [
|
|
93
81
|
this.translation(-inputs.center[0], -inputs.center[1], -inputs.center[2]),
|
|
94
|
-
this.rotationYawPitchRoll(
|
|
95
|
-
this.math.degToRad({ number: inputs.yaw }),
|
|
96
|
-
this.math.degToRad({ number: inputs.pitch }),
|
|
97
|
-
this.math.degToRad({ number: inputs.roll })),
|
|
82
|
+
this.rotationYawPitchRoll(this.math.degToRad({ number: inputs.yaw }), this.math.degToRad({ number: inputs.pitch }), this.math.degToRad({ number: inputs.roll })),
|
|
98
83
|
this.translation(inputs.center[0], inputs.center[1], inputs.center[2]),
|
|
99
|
-
]
|
|
84
|
+
];
|
|
100
85
|
}
|
|
101
|
-
|
|
102
86
|
/**
|
|
103
87
|
* Scale transformation around center and xyz directions
|
|
104
88
|
* @param inputs Scale center xyz trnansformation
|
|
@@ -107,14 +91,13 @@ export class Transforms {
|
|
|
107
91
|
* @shortname center xyz
|
|
108
92
|
* @drawable false
|
|
109
93
|
*/
|
|
110
|
-
scaleCenterXYZ(inputs
|
|
94
|
+
scaleCenterXYZ(inputs) {
|
|
111
95
|
return [
|
|
112
96
|
this.translation(-inputs.center[0], -inputs.center[1], -inputs.center[2]),
|
|
113
97
|
this.scaling(inputs.scaleXyz[0], inputs.scaleXyz[1], inputs.scaleXyz[2]),
|
|
114
98
|
this.translation(inputs.center[0], inputs.center[1], inputs.center[2]),
|
|
115
|
-
]
|
|
99
|
+
];
|
|
116
100
|
}
|
|
117
|
-
|
|
118
101
|
/**
|
|
119
102
|
* Creates the scale transformation in x, y and z directions
|
|
120
103
|
* @param inputs Scale XYZ number array information
|
|
@@ -123,10 +106,9 @@ export class Transforms {
|
|
|
123
106
|
* @shortname xyz
|
|
124
107
|
* @drawable false
|
|
125
108
|
*/
|
|
126
|
-
scaleXYZ(inputs
|
|
127
|
-
return [this.scaling(inputs.scaleXyz[0], inputs.scaleXyz[1], inputs.scaleXyz[2])]
|
|
109
|
+
scaleXYZ(inputs) {
|
|
110
|
+
return [this.scaling(inputs.scaleXyz[0], inputs.scaleXyz[1], inputs.scaleXyz[2])];
|
|
128
111
|
}
|
|
129
|
-
|
|
130
112
|
/**
|
|
131
113
|
* Creates uniform scale transformation
|
|
132
114
|
* @param inputs Scale Dto
|
|
@@ -135,10 +117,9 @@ export class Transforms {
|
|
|
135
117
|
* @shortname uniform
|
|
136
118
|
* @drawable false
|
|
137
119
|
*/
|
|
138
|
-
uniformScale(inputs
|
|
139
|
-
return [this.scaling(inputs.scale, inputs.scale, inputs.scale)]
|
|
120
|
+
uniformScale(inputs) {
|
|
121
|
+
return [this.scaling(inputs.scale, inputs.scale, inputs.scale)];
|
|
140
122
|
}
|
|
141
|
-
|
|
142
123
|
/**
|
|
143
124
|
* Creates uniform scale transformation from the center
|
|
144
125
|
* @param inputs Scale Dto with center point information
|
|
@@ -147,14 +128,13 @@ export class Transforms {
|
|
|
147
128
|
* @shortname uniform from center
|
|
148
129
|
* @drawable false
|
|
149
130
|
*/
|
|
150
|
-
uniformScaleFromCenter(inputs
|
|
131
|
+
uniformScaleFromCenter(inputs) {
|
|
151
132
|
return [
|
|
152
133
|
this.translation(-inputs.center[0], -inputs.center[1], -inputs.center[2]),
|
|
153
134
|
this.scaling(inputs.scale, inputs.scale, inputs.scale),
|
|
154
135
|
this.translation(inputs.center[0], inputs.center[1], inputs.center[2]),
|
|
155
|
-
]
|
|
136
|
+
];
|
|
156
137
|
}
|
|
157
|
-
|
|
158
138
|
/**
|
|
159
139
|
* Creates the translation transformation
|
|
160
140
|
* @param inputs Translation information
|
|
@@ -163,10 +143,9 @@ export class Transforms {
|
|
|
163
143
|
* @shortname xyz
|
|
164
144
|
* @drawable false
|
|
165
145
|
*/
|
|
166
|
-
translationXYZ(inputs
|
|
167
|
-
return [this.translation(inputs.translation[0], inputs.translation[1], inputs.translation[2])]
|
|
146
|
+
translationXYZ(inputs) {
|
|
147
|
+
return [this.translation(inputs.translation[0], inputs.translation[1], inputs.translation[2])];
|
|
168
148
|
}
|
|
169
|
-
|
|
170
149
|
/**
|
|
171
150
|
* Creates the translation transformation
|
|
172
151
|
* @param inputs Translation information
|
|
@@ -175,97 +154,77 @@ export class Transforms {
|
|
|
175
154
|
* @shortname xyz
|
|
176
155
|
* @drawable false
|
|
177
156
|
*/
|
|
178
|
-
translationsXYZ(inputs
|
|
179
|
-
return inputs.translations.map(translation => [this.translation(translation[0], translation[1], translation[2])])
|
|
157
|
+
translationsXYZ(inputs) {
|
|
158
|
+
return inputs.translations.map(translation => [this.translation(translation[0], translation[1], translation[2])]);
|
|
180
159
|
}
|
|
181
|
-
|
|
182
|
-
private translation(x: number, y: number, z: number) {
|
|
160
|
+
translation(x, y, z) {
|
|
183
161
|
return [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, x, y, z, 1.0];
|
|
184
162
|
}
|
|
185
|
-
|
|
186
|
-
private scaling(x: number, y: number, z: number) {
|
|
163
|
+
scaling(x, y, z) {
|
|
187
164
|
return [x, 0.0, 0.0, 0.0, 0.0, y, 0.0, 0.0, 0.0, 0.0, z, 0.0, 0.0, 0.0, 0.0, 1.0];
|
|
188
165
|
}
|
|
189
|
-
|
|
190
|
-
private identity() {
|
|
166
|
+
identity() {
|
|
191
167
|
return [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0];
|
|
192
168
|
}
|
|
193
|
-
|
|
194
|
-
private rotationAxis(axis: Base.Vector3, angle: number) {
|
|
169
|
+
rotationAxis(axis, angle) {
|
|
195
170
|
const s = Math.sin(-angle);
|
|
196
171
|
const c = Math.cos(-angle);
|
|
197
172
|
const c1 = 1 - c;
|
|
198
|
-
|
|
199
173
|
const a = this.vector.normalized({ vector: axis });
|
|
200
|
-
|
|
201
174
|
const x = a[0];
|
|
202
175
|
const y = a[1];
|
|
203
176
|
const z = a[2];
|
|
204
|
-
|
|
205
177
|
const m = this.identity();
|
|
206
|
-
|
|
207
178
|
m[0] = x * x * c1 + c;
|
|
208
179
|
m[1] = x * y * c1 - z * s;
|
|
209
180
|
m[2] = x * z * c1 + y * s;
|
|
210
181
|
m[3] = 0.0;
|
|
211
|
-
|
|
212
182
|
m[4] = y * x * c1 + z * s;
|
|
213
183
|
m[5] = y * y * c1 + c;
|
|
214
184
|
m[6] = y * z * c1 - x * s;
|
|
215
185
|
m[7] = 0.0;
|
|
216
|
-
|
|
217
186
|
m[8] = z * x * c1 - y * s;
|
|
218
187
|
m[9] = z * y * c1 + x * s;
|
|
219
188
|
m[10] = z * z * c1 + c;
|
|
220
189
|
m[11] = 0.0;
|
|
221
|
-
|
|
222
190
|
m[12] = 0.0;
|
|
223
191
|
m[13] = 0.0;
|
|
224
192
|
m[14] = 0.0;
|
|
225
193
|
m[15] = 1.0;
|
|
226
|
-
|
|
227
194
|
return m;
|
|
228
195
|
}
|
|
229
|
-
|
|
230
|
-
private rotationX(angle: number) {
|
|
196
|
+
rotationX(angle) {
|
|
231
197
|
const s = Math.sin(angle);
|
|
232
198
|
const c = Math.cos(angle);
|
|
233
199
|
return [1.0, 0.0, 0.0, 0.0, 0.0, c, s, 0.0, 0.0, -s, c, 0.0, 0.0, 0.0, 0.0, 1.0];
|
|
234
200
|
}
|
|
235
|
-
|
|
236
|
-
private rotationY(angle: number) {
|
|
201
|
+
rotationY(angle) {
|
|
237
202
|
const s = Math.sin(angle);
|
|
238
203
|
const c = Math.cos(angle);
|
|
239
204
|
return [c, 0.0, -s, 0.0, 0.0, 1.0, 0.0, 0.0, s, 0.0, c, 0.0, 0.0, 0.0, 0.0, 1.0];
|
|
240
205
|
}
|
|
241
|
-
|
|
242
|
-
private rotationZ(angle: number) {
|
|
206
|
+
rotationZ(angle) {
|
|
243
207
|
const s = Math.sin(angle);
|
|
244
208
|
const c = Math.cos(angle);
|
|
245
209
|
return [c, s, 0.0, 0.0, -s, c, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0];
|
|
246
210
|
}
|
|
247
|
-
|
|
248
|
-
private rotationYawPitchRoll(yaw: number, pitch: number, roll: number) {
|
|
211
|
+
rotationYawPitchRoll(yaw, pitch, roll) {
|
|
249
212
|
const halfRoll = roll * 0.5;
|
|
250
213
|
const halfPitch = pitch * 0.5;
|
|
251
214
|
const halfYaw = yaw * 0.5;
|
|
252
|
-
|
|
253
215
|
const sinRoll = Math.sin(halfRoll);
|
|
254
216
|
const cosRoll = Math.cos(halfRoll);
|
|
255
217
|
const sinPitch = Math.sin(halfPitch);
|
|
256
218
|
const cosPitch = Math.cos(halfPitch);
|
|
257
219
|
const sinYaw = Math.sin(halfYaw);
|
|
258
220
|
const cosYaw = Math.cos(halfYaw);
|
|
259
|
-
|
|
260
221
|
const x = cosYaw * sinPitch * cosRoll + sinYaw * cosPitch * sinRoll;
|
|
261
222
|
const y = sinYaw * cosPitch * cosRoll - cosYaw * sinPitch * sinRoll;
|
|
262
223
|
const z = cosYaw * cosPitch * sinRoll - sinYaw * sinPitch * cosRoll;
|
|
263
224
|
const w = cosYaw * cosPitch * cosRoll + sinYaw * sinPitch * sinRoll;
|
|
264
|
-
|
|
265
225
|
return this.rotationMatrixFromQuat(x, y, z, w);
|
|
266
226
|
}
|
|
267
|
-
|
|
268
|
-
private rotationMatrixFromQuat(x: number, y: number, z: number, w: number) {
|
|
227
|
+
rotationMatrixFromQuat(x, y, z, w) {
|
|
269
228
|
const xx = x * x;
|
|
270
229
|
const yy = y * y;
|
|
271
230
|
const zz = z * z;
|
|
@@ -275,24 +234,19 @@ export class Transforms {
|
|
|
275
234
|
const yw = y * w;
|
|
276
235
|
const yz = y * z;
|
|
277
236
|
const xw = x * w;
|
|
278
|
-
|
|
279
237
|
const m = this.identity();
|
|
280
|
-
|
|
281
238
|
m[0] = 1.0 - 2.0 * (yy + zz);
|
|
282
239
|
m[1] = 2.0 * (xy + zw);
|
|
283
240
|
m[2] = 2.0 * (zx - yw);
|
|
284
241
|
m[3] = 0.0;
|
|
285
|
-
|
|
286
242
|
m[4] = 2.0 * (xy - zw);
|
|
287
243
|
m[5] = 1.0 - 2.0 * (zz + xx);
|
|
288
244
|
m[6] = 2.0 * (yz + xw);
|
|
289
245
|
m[7] = 0.0;
|
|
290
|
-
|
|
291
246
|
m[8] = 2.0 * (zx + yw);
|
|
292
247
|
m[9] = 2.0 * (yz - xw);
|
|
293
248
|
m[10] = 1.0 - 2.0 * (yy + xx);
|
|
294
249
|
m[11] = 0.0;
|
|
295
|
-
|
|
296
250
|
m[12] = 0.0;
|
|
297
251
|
m[13] = 0.0;
|
|
298
252
|
m[14] = 0.0;
|