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