wgge 2.0.19 → 2.0.21
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/README.MD +2 -1
- package/core/model/vector/Vector2.js +12 -3
- package/core/model/vector/Vector3.js +18 -26
- package/package.json +1 -1
- package/bin/deploy.cmd +0 -1
package/README.MD
CHANGED
|
@@ -2,10 +2,12 @@ import ObjectModel from "../ObjectModel";
|
|
|
2
2
|
import Rotation from "./Rotation";
|
|
3
3
|
import NumberHelper from "../../helper/NumberHelper";
|
|
4
4
|
|
|
5
|
-
export const ZERO_VECTOR2 = new Vector2(0, 0);
|
|
6
|
-
|
|
7
5
|
export default class Vector2 extends ObjectModel {
|
|
6
|
+
|
|
7
|
+
_isVector2 = true;
|
|
8
|
+
|
|
8
9
|
x;
|
|
10
|
+
|
|
9
11
|
y;
|
|
10
12
|
|
|
11
13
|
constructor(x = undefined, y = undefined, persistent = true) {
|
|
@@ -25,6 +27,11 @@ export default class Vector2 extends ObjectModel {
|
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
|
|
30
|
+
static isVector2(v) {
|
|
31
|
+
if (v === null || v === undefined) return false;
|
|
32
|
+
return typeof v === 'object' && v._isVector2;
|
|
33
|
+
}
|
|
34
|
+
|
|
28
35
|
distanceTo(v) {
|
|
29
36
|
return Math.sqrt(Math.pow(this.x - v.x, 2) + Math.pow(this.y - v.y, 2));
|
|
30
37
|
}
|
|
@@ -39,7 +46,7 @@ export default class Vector2 extends ObjectModel {
|
|
|
39
46
|
* @param y Number|undefined
|
|
40
47
|
*/
|
|
41
48
|
set(x, y = undefined) {
|
|
42
|
-
if (y === undefined &&
|
|
49
|
+
if (y === undefined && Vector2.isVector2(x)) {
|
|
43
50
|
this.set(x.x, x.y);
|
|
44
51
|
return;
|
|
45
52
|
}
|
|
@@ -210,3 +217,5 @@ export default class Vector2 extends ObjectModel {
|
|
|
210
217
|
return `[${NumberHelper.round(this.x, decimals)},${NumberHelper.round(this.y, decimals)}]`;
|
|
211
218
|
}
|
|
212
219
|
}
|
|
220
|
+
|
|
221
|
+
export const ZERO_VECTOR2 = new Vector2(0, 0);
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import ModelBase from "../ModelBase";
|
|
2
2
|
|
|
3
|
-
export const ZERO_VECTOR3 = new Vector3(0, 0, 0);
|
|
4
|
-
|
|
5
3
|
export default class Vector3 extends ModelBase {
|
|
4
|
+
|
|
5
|
+
_isVector3 = true;
|
|
6
|
+
|
|
6
7
|
x;
|
|
8
|
+
|
|
7
9
|
y;
|
|
10
|
+
|
|
8
11
|
z;
|
|
9
12
|
|
|
10
13
|
constructor(x = undefined, y = undefined, z = undefined, persistent = true) {
|
|
@@ -14,25 +17,25 @@ export default class Vector3 extends ModelBase {
|
|
|
14
17
|
this.y = 0;
|
|
15
18
|
this.z = 0;
|
|
16
19
|
|
|
17
|
-
if (y === undefined &&
|
|
18
|
-
|
|
19
|
-
this.setFromArray(x);
|
|
20
|
-
} else {
|
|
21
|
-
this.set(x);
|
|
22
|
-
}
|
|
20
|
+
if (y === undefined && Vector3.isVector3(x)) {
|
|
21
|
+
this.set(x.x, x.y, x.z);
|
|
23
22
|
} else if (x !== undefined && z !== undefined) {
|
|
24
23
|
this.set(x, y, z);
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
|
|
27
|
+
static isVector3(v) {
|
|
28
|
+
if (v === null || v === undefined) return false;
|
|
29
|
+
return typeof v === 'object' && v._isVector3;
|
|
30
|
+
}
|
|
31
|
+
|
|
28
32
|
equalsTo(v) {
|
|
29
33
|
return (v) ? this.x === v.x && this.y === v.y && this.z === v.z : false;
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
set(x, y = undefined, z = undefined) {
|
|
33
|
-
if (y === undefined &&
|
|
34
|
-
this.set(x.x, x.y, x.z);
|
|
35
|
-
return;
|
|
37
|
+
if (y === undefined && Vector3.isVector3(x)) {
|
|
38
|
+
return this.set(x.x, x.y, x.z);
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
x = Number(x);
|
|
@@ -47,6 +50,8 @@ export default class Vector3 extends ModelBase {
|
|
|
47
50
|
this.makeDirty();
|
|
48
51
|
this.triggerEvent('change', {oldValue: old, newValue: this});
|
|
49
52
|
}
|
|
53
|
+
|
|
54
|
+
return this;
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
add(v) {
|
|
@@ -89,21 +94,6 @@ export default class Vector3 extends ModelBase {
|
|
|
89
94
|
this.setFromArray(state);
|
|
90
95
|
}
|
|
91
96
|
|
|
92
|
-
asRgbColor() {
|
|
93
|
-
return `rgb(${Math.round(this.x)}, ${Math.round(this.y)}, ${Math.round(this.z)})`;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Components in 0-1 range (three.js style)
|
|
98
|
-
* @returns {number}
|
|
99
|
-
*/
|
|
100
|
-
asHexColor() {
|
|
101
|
-
const r = Math.round(Math.min(Math.max(this.x, 0), 1) * 255);
|
|
102
|
-
const g = Math.round(Math.min(Math.max(this.y, 0), 1) * 255);
|
|
103
|
-
const b = Math.round(Math.min(Math.max(this.z, 0), 1) * 255);
|
|
104
|
-
return (r << 16) | (g << 8) | b;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
97
|
size() {
|
|
108
98
|
return Math.sqrt(Math.pow(this.x, 2) + Math.pow(this.y, 2) + Math.pow(this.z, 2));
|
|
109
99
|
}
|
|
@@ -116,3 +106,5 @@ export default class Vector3 extends ModelBase {
|
|
|
116
106
|
return ZERO_VECTOR3;
|
|
117
107
|
}
|
|
118
108
|
}
|
|
109
|
+
|
|
110
|
+
export const ZERO_VECTOR3 = new Vector3(0, 0, 0);
|
package/package.json
CHANGED
package/bin/deploy.cmd
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npm publish
|