wgge 2.0.19 → 2.0.20
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 +10 -1
- package/core/model/vector/Vector3.js +16 -24
- package/package.json +1 -1
- package/bin/deploy.cmd +0 -1
package/README.MD
CHANGED
|
@@ -5,7 +5,11 @@ import NumberHelper from "../../helper/NumberHelper";
|
|
|
5
5
|
export const ZERO_VECTOR2 = new Vector2(0, 0);
|
|
6
6
|
|
|
7
7
|
export default class Vector2 extends ObjectModel {
|
|
8
|
+
|
|
9
|
+
_isVector2 = true;
|
|
10
|
+
|
|
8
11
|
x;
|
|
12
|
+
|
|
9
13
|
y;
|
|
10
14
|
|
|
11
15
|
constructor(x = undefined, y = undefined, persistent = true) {
|
|
@@ -25,6 +29,11 @@ export default class Vector2 extends ObjectModel {
|
|
|
25
29
|
}
|
|
26
30
|
}
|
|
27
31
|
|
|
32
|
+
static isVector2(v) {
|
|
33
|
+
if (v === null || v === undefined) return false;
|
|
34
|
+
return typeof v === 'object' && v._isVector2;
|
|
35
|
+
}
|
|
36
|
+
|
|
28
37
|
distanceTo(v) {
|
|
29
38
|
return Math.sqrt(Math.pow(this.x - v.x, 2) + Math.pow(this.y - v.y, 2));
|
|
30
39
|
}
|
|
@@ -39,7 +48,7 @@ export default class Vector2 extends ObjectModel {
|
|
|
39
48
|
* @param y Number|undefined
|
|
40
49
|
*/
|
|
41
50
|
set(x, y = undefined) {
|
|
42
|
-
if (y === undefined &&
|
|
51
|
+
if (y === undefined && Vector2.isVector2(x)) {
|
|
43
52
|
this.set(x.x, x.y);
|
|
44
53
|
return;
|
|
45
54
|
}
|
|
@@ -3,8 +3,13 @@ import ModelBase from "../ModelBase";
|
|
|
3
3
|
export const ZERO_VECTOR3 = new Vector3(0, 0, 0);
|
|
4
4
|
|
|
5
5
|
export default class Vector3 extends ModelBase {
|
|
6
|
+
|
|
7
|
+
_isVector3 = true;
|
|
8
|
+
|
|
6
9
|
x;
|
|
10
|
+
|
|
7
11
|
y;
|
|
12
|
+
|
|
8
13
|
z;
|
|
9
14
|
|
|
10
15
|
constructor(x = undefined, y = undefined, z = undefined, persistent = true) {
|
|
@@ -14,25 +19,25 @@ export default class Vector3 extends ModelBase {
|
|
|
14
19
|
this.y = 0;
|
|
15
20
|
this.z = 0;
|
|
16
21
|
|
|
17
|
-
if (y === undefined &&
|
|
18
|
-
|
|
19
|
-
this.setFromArray(x);
|
|
20
|
-
} else {
|
|
21
|
-
this.set(x);
|
|
22
|
-
}
|
|
22
|
+
if (y === undefined && Vector3.isVector3(x)) {
|
|
23
|
+
this.set(x.x, x.y, x.z);
|
|
23
24
|
} else if (x !== undefined && z !== undefined) {
|
|
24
25
|
this.set(x, y, z);
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
static isVector3(v) {
|
|
30
|
+
if (v === null || v === undefined) return false;
|
|
31
|
+
return typeof v === 'object' && v._isVector3;
|
|
32
|
+
}
|
|
33
|
+
|
|
28
34
|
equalsTo(v) {
|
|
29
35
|
return (v) ? this.x === v.x && this.y === v.y && this.z === v.z : false;
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
set(x, y = undefined, z = undefined) {
|
|
33
|
-
if (y === undefined &&
|
|
34
|
-
this.set(x.x, x.y, x.z);
|
|
35
|
-
return;
|
|
39
|
+
if (y === undefined && Vector3.isVector3(x)) {
|
|
40
|
+
return this.set(x.x, x.y, x.z);
|
|
36
41
|
}
|
|
37
42
|
|
|
38
43
|
x = Number(x);
|
|
@@ -47,6 +52,8 @@ export default class Vector3 extends ModelBase {
|
|
|
47
52
|
this.makeDirty();
|
|
48
53
|
this.triggerEvent('change', {oldValue: old, newValue: this});
|
|
49
54
|
}
|
|
55
|
+
|
|
56
|
+
return this;
|
|
50
57
|
}
|
|
51
58
|
|
|
52
59
|
add(v) {
|
|
@@ -89,21 +96,6 @@ export default class Vector3 extends ModelBase {
|
|
|
89
96
|
this.setFromArray(state);
|
|
90
97
|
}
|
|
91
98
|
|
|
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
99
|
size() {
|
|
108
100
|
return Math.sqrt(Math.pow(this.x, 2) + Math.pow(this.y, 2) + Math.pow(this.z, 2));
|
|
109
101
|
}
|
package/package.json
CHANGED
package/bin/deploy.cmd
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
npm publish
|