@fi4f/hg 0.0.10 → 0.0.12
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 +57 -0
- package/dist/asset.d.ts +46 -0
- package/dist/asset.d.ts.map +1 -0
- package/dist/{core/asset.js → asset.js} +5 -30
- package/dist/asset.js.map +1 -0
- package/dist/{core/cache.d.ts → cache.d.ts} +17 -19
- package/dist/cache.d.ts.map +1 -0
- package/dist/{core/cache.js → cache.js} +5 -43
- package/dist/cache.js.map +1 -0
- package/dist/canvas.d.ts +4 -0
- package/dist/canvas.d.ts.map +1 -0
- package/dist/canvas.js +12 -0
- package/dist/canvas.js.map +1 -0
- package/dist/el.d.ts +6 -0
- package/dist/el.d.ts.map +1 -0
- package/dist/el.js +7 -0
- package/dist/el.js.map +1 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js.map +1 -0
- package/dist/hg.d.ts +13 -12
- package/dist/hg.d.ts.map +1 -1
- package/dist/hg.js +14 -13
- package/dist/hg.js.map +1 -1
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/matrix2.d.ts +152 -0
- package/dist/matrix2.d.ts.map +1 -0
- package/dist/matrix2.js +262 -0
- package/dist/matrix2.js.map +1 -0
- package/dist/matrix3.d.ts +196 -0
- package/dist/matrix3.d.ts.map +1 -0
- package/dist/matrix3.js +352 -0
- package/dist/matrix3.js.map +1 -0
- package/dist/matrix4.d.ts +253 -0
- package/dist/matrix4.d.ts.map +1 -0
- package/dist/matrix4.js +465 -0
- package/dist/matrix4.js.map +1 -0
- package/dist/{core/scene.d.ts → scene.d.ts} +2 -3
- package/dist/scene.d.ts.map +1 -0
- package/dist/scene.js.map +1 -0
- package/dist/sprite.d.ts +24 -0
- package/dist/sprite.d.ts.map +1 -0
- package/dist/sprite.js +49 -0
- package/dist/sprite.js.map +1 -0
- package/dist/stage.d.ts +100 -0
- package/dist/stage.d.ts.map +1 -0
- package/dist/stage.js +303 -0
- package/dist/stage.js.map +1 -0
- package/dist/vector2.d.ts +114 -0
- package/dist/vector2.d.ts.map +1 -0
- package/dist/vector2.js +168 -0
- package/dist/vector2.js.map +1 -0
- package/dist/vector3.d.ts +126 -0
- package/dist/vector3.d.ts.map +1 -0
- package/dist/vector3.js +190 -0
- package/dist/vector3.js.map +1 -0
- package/dist/vector4.d.ts +135 -0
- package/dist/vector4.d.ts.map +1 -0
- package/dist/vector4.js +209 -0
- package/dist/vector4.js.map +1 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js.map +1 -0
- package/package.json +1 -1
- package/dist/core/asset.d.ts +0 -71
- package/dist/core/asset.d.ts.map +0 -1
- package/dist/core/asset.js.map +0 -1
- package/dist/core/cache.d.ts.map +0 -1
- package/dist/core/cache.js.map +0 -1
- package/dist/core/event.d.ts.map +0 -1
- package/dist/core/event.js.map +0 -1
- package/dist/core/scene.d.ts.map +0 -1
- package/dist/core/scene.js.map +0 -1
- package/dist/core/stage.d.ts +0 -130
- package/dist/core/stage.d.ts.map +0 -1
- package/dist/core/stage.js +0 -308
- package/dist/core/stage.js.map +0 -1
- package/dist/math/index.d.ts +0 -6
- package/dist/math/index.d.ts.map +0 -1
- package/dist/math/index.js +0 -6
- package/dist/math/index.js.map +0 -1
- package/dist/math/matrix2.d.ts +0 -58
- package/dist/math/matrix2.d.ts.map +0 -1
- package/dist/math/matrix2.js +0 -178
- package/dist/math/matrix2.js.map +0 -1
- package/dist/math/matrix3.d.ts +0 -92
- package/dist/math/matrix3.d.ts.map +0 -1
- package/dist/math/matrix3.js +0 -255
- package/dist/math/matrix3.js.map +0 -1
- package/dist/math/matrix4.d.ts +0 -138
- package/dist/math/matrix4.d.ts.map +0 -1
- package/dist/math/matrix4.js +0 -352
- package/dist/math/matrix4.js.map +0 -1
- package/dist/math/vector2.d.ts +0 -38
- package/dist/math/vector2.d.ts.map +0 -1
- package/dist/math/vector2.js +0 -67
- package/dist/math/vector2.js.map +0 -1
- package/dist/math/vector3.d.ts +0 -34
- package/dist/math/vector3.d.ts.map +0 -1
- package/dist/math/vector3.js +0 -74
- package/dist/math/vector3.js.map +0 -1
- package/dist/math/vector4.d.ts +0 -39
- package/dist/math/vector4.d.ts.map +0 -1
- package/dist/math/vector4.js +0 -81
- package/dist/math/vector4.js.map +0 -1
- package/dist/util/types.d.ts +0 -2
- package/dist/util/types.d.ts.map +0 -1
- package/dist/util/types.js +0 -2
- package/dist/util/types.js.map +0 -1
- package/dist/util/version.d.ts.map +0 -1
- package/dist/util/version.js.map +0 -1
- /package/dist/{core/event.d.ts → event.d.ts} +0 -0
- /package/dist/{core/event.js → event.js} +0 -0
- /package/dist/{core/scene.js → scene.js} +0 -0
- /package/dist/{util/version.d.ts → version.d.ts} +0 -0
- /package/dist/{util/version.js → version.js} +0 -0
package/dist/vector2.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { add, sub, mul, div, mod } from "./el.js";
|
|
2
|
+
/**
|
|
3
|
+
* A collection of constants and functions for constructing and
|
|
4
|
+
* interacting with Vector2 objects.
|
|
5
|
+
*/
|
|
6
|
+
export const Vector2 = {
|
|
7
|
+
/** Constant index for the x-component of a Vector2 */
|
|
8
|
+
X: 0,
|
|
9
|
+
/** Constant index for the y-component of a Vector2 */
|
|
10
|
+
Y: 1,
|
|
11
|
+
/** A collection of getters for Vector2 objects */
|
|
12
|
+
Get: {
|
|
13
|
+
/** Get the x-component of a Vector2 */
|
|
14
|
+
x(a) { return a[Vector2.X]; },
|
|
15
|
+
/** Get the y-component of a Vector2 */
|
|
16
|
+
y(a) { return a[Vector2.Y]; },
|
|
17
|
+
},
|
|
18
|
+
/** A collection of setters for Vector2 objects */
|
|
19
|
+
Set: {
|
|
20
|
+
/** Set the x-component of a Vector2 */
|
|
21
|
+
x(a, x) { return a[Vector2.X] = x; },
|
|
22
|
+
/** Set the y-component of a Vector2 */
|
|
23
|
+
y(a, y) { return a[Vector2.Y] = y; },
|
|
24
|
+
},
|
|
25
|
+
/** Get or set (when `x` is defined) the x-component of a Vector2 */
|
|
26
|
+
x(a, x) {
|
|
27
|
+
if (x === undefined)
|
|
28
|
+
return Vector2.Get.x(a);
|
|
29
|
+
else
|
|
30
|
+
return Vector2.Set.x(a, x);
|
|
31
|
+
},
|
|
32
|
+
/** Get or set (when `y` is defined) the y-component of a Vector2 */
|
|
33
|
+
y(a, y) {
|
|
34
|
+
if (y === undefined)
|
|
35
|
+
return Vector2.Get.y(a);
|
|
36
|
+
else
|
|
37
|
+
return Vector2.Set.y(a, y);
|
|
38
|
+
},
|
|
39
|
+
/**
|
|
40
|
+
* Construct a Vector2 from a variadic array of numbers.
|
|
41
|
+
*
|
|
42
|
+
* Constructs a uniform Vector2 when `a.length === 1`
|
|
43
|
+
* ```js
|
|
44
|
+
* Vector2.new(1) // [1, 1]
|
|
45
|
+
* ```
|
|
46
|
+
* Otherwise constructs a standard zero-padded Vector2
|
|
47
|
+
* ```js
|
|
48
|
+
* Vector2.new( ) // [0, 0]
|
|
49
|
+
* Vector2.new(1, 2) // [1, 2]
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
new(...a) {
|
|
53
|
+
if (a.length === 1)
|
|
54
|
+
return [
|
|
55
|
+
a[Vector2.X],
|
|
56
|
+
a[Vector2.X]
|
|
57
|
+
];
|
|
58
|
+
else
|
|
59
|
+
return [
|
|
60
|
+
a[Vector2.X] ?? 0,
|
|
61
|
+
a[Vector2.Y] ?? 0
|
|
62
|
+
];
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* Constructs a Vector2 from a number or an array of numbers.
|
|
66
|
+
*
|
|
67
|
+
* Constructs a uniform Vector2 when `a` is a number
|
|
68
|
+
* ```js
|
|
69
|
+
* Vector2.from(1) // [1, 1]
|
|
70
|
+
* ```
|
|
71
|
+
* Otherwise constructs a standard zero-padded Vector2
|
|
72
|
+
* ```js
|
|
73
|
+
* Vector2.from([ ]) // [0, 0]
|
|
74
|
+
* Vector2.from([1 ]) // [1, 0]
|
|
75
|
+
* Vector2.from([1, 2]) // [1, 2]
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
from(a) {
|
|
79
|
+
if (typeof a === "number")
|
|
80
|
+
return [
|
|
81
|
+
a,
|
|
82
|
+
a
|
|
83
|
+
];
|
|
84
|
+
else
|
|
85
|
+
return [
|
|
86
|
+
a[Vector2.X] ?? 0,
|
|
87
|
+
a[Vector2.Y] ?? 0
|
|
88
|
+
];
|
|
89
|
+
},
|
|
90
|
+
/**
|
|
91
|
+
* Perform an element-wise operation on two Vector2 objects.
|
|
92
|
+
* Number-like arguments are promoted to uniform Vector2 objects
|
|
93
|
+
* before performing the operation. Constructs a new Vector2 when an
|
|
94
|
+
* output argument is not provided.
|
|
95
|
+
*/
|
|
96
|
+
el(op, a, b, out = Vector2.new()) {
|
|
97
|
+
const [xa, ya] = Vector2.from(a);
|
|
98
|
+
const [xb, yb] = Vector2.from(b);
|
|
99
|
+
Vector2.Set.x(out, op(xa, xb));
|
|
100
|
+
Vector2.Set.y(out, op(ya, yb));
|
|
101
|
+
return out;
|
|
102
|
+
},
|
|
103
|
+
/**
|
|
104
|
+
* Compute the sum of two Vector2 objects. Number-like arguments are
|
|
105
|
+
* promoted to uniform Vector2 objects before performing the operation.
|
|
106
|
+
* Constructs a new Vector2 when an output argument is not provided.
|
|
107
|
+
*/
|
|
108
|
+
add(a, b, out = Vector2.new()) {
|
|
109
|
+
return Vector2.el(add, a, b, out);
|
|
110
|
+
},
|
|
111
|
+
/**
|
|
112
|
+
* Compute the difference of two Vector2 objects. Number-like arguments
|
|
113
|
+
* are promoted to uniform Vector2 objects before performing the
|
|
114
|
+
* operation. Constructs a new Vector2 when an output argument is not
|
|
115
|
+
* provided.
|
|
116
|
+
*/
|
|
117
|
+
sub(a, b, out = Vector2.new()) {
|
|
118
|
+
return Vector2.el(sub, a, b, out);
|
|
119
|
+
},
|
|
120
|
+
/**
|
|
121
|
+
* Compute the hadamard (element-wise) product of two Vector2 objects.
|
|
122
|
+
* Number-like arguments are promoted to uniform Vector2 objects before
|
|
123
|
+
* performing the operation. Constructs a new Vector2 when an output
|
|
124
|
+
* argument is not provided.
|
|
125
|
+
*/
|
|
126
|
+
hmul(a, b, out = Vector2.new()) {
|
|
127
|
+
return Vector2.el(mul, a, b, out);
|
|
128
|
+
},
|
|
129
|
+
/**
|
|
130
|
+
* Compute the hadamard (element-wise) quotient of two Vector2 objects.
|
|
131
|
+
* Number-like arguments are promoted to uniform Vector2 objects before
|
|
132
|
+
* performing the operation. Constructs a new Vector2 when an output
|
|
133
|
+
* argument is not provided.
|
|
134
|
+
*/
|
|
135
|
+
hdiv(a, b, out = Vector2.new()) {
|
|
136
|
+
return Vector2.el(div, a, b, out);
|
|
137
|
+
},
|
|
138
|
+
/**
|
|
139
|
+
* Compute the hadamard (element-wise) remainder of two Vector2 objects.
|
|
140
|
+
* Number-like arguments are promoted to uniform Vector2 objects before
|
|
141
|
+
* performing the operation. Constructs a new Vector2 when an output
|
|
142
|
+
* argument is not provided.
|
|
143
|
+
*/
|
|
144
|
+
hmod(a, b, out = Vector2.new()) {
|
|
145
|
+
return Vector2.el(mod, a, b, out);
|
|
146
|
+
},
|
|
147
|
+
/**
|
|
148
|
+
* Compute the dot product of two Vector2 objects, or simply the
|
|
149
|
+
* dot product of `a` with itself when `b` is not defined. Number-like
|
|
150
|
+
* arguments are promoted to uniform Vector2 objects before performing
|
|
151
|
+
* the operation.
|
|
152
|
+
*/
|
|
153
|
+
dot(a, b = a) {
|
|
154
|
+
const [xa, ya] = Vector2.from(a);
|
|
155
|
+
const [xb, yb] = Vector2.from(b);
|
|
156
|
+
return xa * xb + ya * yb;
|
|
157
|
+
},
|
|
158
|
+
/**
|
|
159
|
+
* Convert a Vector2 into its string representation
|
|
160
|
+
* ```js
|
|
161
|
+
* Vector2.toString([1, 2]) // "vec2<1, 2>"
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
toString([x, y]) {
|
|
165
|
+
return `vec2<${x}, ${y}>`;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=vector2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector2.js","sourceRoot":"","sources":["../src/vector2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAIlD;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,sDAAsD;IACtD,CAAC,EAAE,CAAU;IACb,sDAAsD;IACtD,CAAC,EAAE,CAAU;IAEb,kDAAkD;IAClD,GAAG,EAAE;QACH,uCAAuC;QACvC,CAAC,CAAC,CAAU,IAAI,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA,CAAC,CAAC;QACrC,uCAAuC;QACvC,CAAC,CAAC,CAAU,IAAI,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA,CAAC,CAAC;KACtC;IAED,kDAAkD;IAClD,GAAG,EAAE;QACH,uCAAuC;QACvC,CAAC,CAAC,CAAU,EAAE,CAAS,IAAI,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA,CAAC,CAAC;QACpD,uCAAuC;QACvC,CAAC,CAAC,CAAU,EAAE,CAAS,IAAI,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA,CAAC,CAAC;KACrD;IAED,oEAAoE;IACpE,CAAC,CAAC,CAAU,EAAE,CAAW;QACvB,IAAI,CAAC,KAAK,SAAS;YAAE,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAI,CAAA;;YAC1B,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACjD,CAAC;IAED,oEAAoE;IACpE,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AC,CAAC,CAAC,CAAA;QAChC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAChC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAA;IAC1B,CAAC;IAED;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAW;QACvB,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAY,CAAA;IACpC,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
export type Vector3 = [number, number, number];
|
|
2
|
+
/**
|
|
3
|
+
* A collection of constants and functions for constructing and
|
|
4
|
+
* interacting with Vector3 objects.
|
|
5
|
+
*/
|
|
6
|
+
export declare const Vector3: {
|
|
7
|
+
/** Constant index for the x-component of a Vector3 */
|
|
8
|
+
X: 0;
|
|
9
|
+
/** Constant index for the y-component of a Vector3 */
|
|
10
|
+
Y: 1;
|
|
11
|
+
/** Constant index for the z-component of a Vector3 */
|
|
12
|
+
Z: 2;
|
|
13
|
+
/** A collection of getters for Vector3 objects */
|
|
14
|
+
Get: {
|
|
15
|
+
/** Get the x-component of a Vector3 */
|
|
16
|
+
x(a: Vector3): number;
|
|
17
|
+
/** Get the y-component of a Vector3 */
|
|
18
|
+
y(a: Vector3): number;
|
|
19
|
+
/** Get the z-component of a Vector3 */
|
|
20
|
+
z(a: Vector3): number;
|
|
21
|
+
};
|
|
22
|
+
/** A collection of setters for Vector3 objects */
|
|
23
|
+
Set: {
|
|
24
|
+
/** Set the x-component of a Vector3 */
|
|
25
|
+
x(a: Vector3, x: number): number;
|
|
26
|
+
/** Set the y-component of a Vector3 */
|
|
27
|
+
y(a: Vector3, y: number): number;
|
|
28
|
+
/** Set the z-component of a Vector3 */
|
|
29
|
+
z(a: Vector3, z: number): number;
|
|
30
|
+
};
|
|
31
|
+
/** Get or set (when `x` is defined) the x-component of a Vector3 */
|
|
32
|
+
x(a: Vector3, x?: number): number;
|
|
33
|
+
/** Get or set (when `y` is defined) the y-component of a Vector3 */
|
|
34
|
+
y(a: Vector3, y?: number): number;
|
|
35
|
+
/** Get or set (when `z` is defined) the z-component of a Vector3 */
|
|
36
|
+
z(a: Vector3, z?: number): number;
|
|
37
|
+
/**
|
|
38
|
+
* Construct a Vector3 from a variadic array of numbers.
|
|
39
|
+
*
|
|
40
|
+
* Constructs a uniform Vector3 when `a.length === 1`
|
|
41
|
+
* ```js
|
|
42
|
+
* Vector3.new(1) // [1, 1, 1]
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* Otherwise constructs a standard zero-padded Vector3
|
|
46
|
+
* ```js
|
|
47
|
+
* Vector3.new( ) // [0, 0, 0]
|
|
48
|
+
* Vector3.new(1, 2 ) // [1, 2, 0]
|
|
49
|
+
* Vector3.new(1, 2, 3) // [1, 2, 3]
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
"new"(...a: Array<number>): [number, number, number];
|
|
53
|
+
/**
|
|
54
|
+
* Constructs a Vector3 from a number or an array of numbers.
|
|
55
|
+
*
|
|
56
|
+
* Constructs a uniform Vector3 when `a` is a number
|
|
57
|
+
* ```js
|
|
58
|
+
* Vector3.from(1) // [1, 1, 1]
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* Otherwise constructs a standard zero-padded Vector3
|
|
62
|
+
* ```js
|
|
63
|
+
* Vector3.from([ ]) // [0, 0, 0]
|
|
64
|
+
* Vector3.from([1 ]) // [1, 0, 0]
|
|
65
|
+
* Vector3.from([1, 2 ]) // [1, 2, 0]
|
|
66
|
+
* Vector3.from([1, 2, 3]) // [1, 2, 3]
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
from(a: number | Array<number>): [number, number, number];
|
|
70
|
+
/**
|
|
71
|
+
* Perform an element-wise operation on two Vector3 objects.
|
|
72
|
+
* Number-like arguments are promoted to uniform Vector3 objects
|
|
73
|
+
* before performing the operation. Constructs a new Vector3 when an
|
|
74
|
+
* output argument is not provided.
|
|
75
|
+
*/
|
|
76
|
+
el(op: (a: number, b: number) => number, a: number | Vector3, b: number | Vector3, out?: Vector3): Vector3;
|
|
77
|
+
/**
|
|
78
|
+
* Compute the sum of two Vector3 objects. Number-like arguments are
|
|
79
|
+
* promoted to uniform Vector3 objects before performing the operation.
|
|
80
|
+
* Constructs a new Vector3 when an output argument is not provided.
|
|
81
|
+
*/
|
|
82
|
+
add(a: number | Vector3, b: number | Vector3, out?: Vector3): Vector3;
|
|
83
|
+
/**
|
|
84
|
+
* Compute the difference of two Vector3 objects. Number-like arguments
|
|
85
|
+
* are promoted to uniform Vector3 objects before performing the
|
|
86
|
+
* operation. Constructs a new Vector3 when an output argument is not
|
|
87
|
+
* provided.
|
|
88
|
+
*/
|
|
89
|
+
sub(a: number | Vector3, b: number | Vector3, out?: Vector3): Vector3;
|
|
90
|
+
/**
|
|
91
|
+
* Compute the hadamard (element-wise) product of two Vector3 objects.
|
|
92
|
+
* Number-like arguments are promoted to uniform Vector3 objects before
|
|
93
|
+
* performing the operation. Constructs a new Vector3 when an output
|
|
94
|
+
* argument is not provided.
|
|
95
|
+
*/
|
|
96
|
+
hmul(a: number | Vector3, b: number | Vector3, out?: Vector3): Vector3;
|
|
97
|
+
/**
|
|
98
|
+
* Compute the hadamard (element-wise) quotient of two Vector3 objects.
|
|
99
|
+
* Number-like arguments are promoted to uniform Vector3 objects before
|
|
100
|
+
* performing the operation. Constructs a new Vector3 when an output
|
|
101
|
+
* argument is not provided.
|
|
102
|
+
*/
|
|
103
|
+
hdiv(a: number | Vector3, b: number | Vector3, out?: Vector3): Vector3;
|
|
104
|
+
/**
|
|
105
|
+
* Compute the hadamard (element-wise) remainder of two Vector3 objects.
|
|
106
|
+
* Number-like arguments are promoted to uniform Vector3 objects before
|
|
107
|
+
* performing the operation. Constructs a new Vector3 when an output
|
|
108
|
+
* argument is not provided.
|
|
109
|
+
*/
|
|
110
|
+
hmod(a: number | Vector3, b: number | Vector3, out?: Vector3): Vector3;
|
|
111
|
+
/**
|
|
112
|
+
* Compute the dot product of two Vector3 objects, or simply the
|
|
113
|
+
* dot product of `a` with itself when `b` is not defined. Number-like
|
|
114
|
+
* arguments are promoted to uniform Vector3 objects before performing
|
|
115
|
+
* the operation.
|
|
116
|
+
*/
|
|
117
|
+
dot(a: number | Vector3, b?: number | Vector3): number;
|
|
118
|
+
/**
|
|
119
|
+
* Convert a Vector3 into its string representation.
|
|
120
|
+
* ```js
|
|
121
|
+
* Vector3.toString([1, 2, 3]) // "vec3<1, 2, 3>"
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
toString([x, y, z]: Vector3): `vec3<${number}, ${number}, ${number}>`;
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=vector3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector3.d.ts","sourceRoot":"","sources":["../src/vector3.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AAE9C;;;GAGG;AACH,eAAO,MAAM,OAAO;IAClB,sDAAsD;;IAEtD,sDAAsD;;IAEtD,sDAAsD;;IAGtD,kDAAkD;;QAEhD,uCAAuC;aAClC,OAAO;QACZ,uCAAuC;aAClC,OAAO;QACZ,uCAAuC;aAClC,OAAO;;IAGd,kDAAkD;;QAEhD,uCAAuC;aAClC,OAAO,KAAK,MAAM;QACvB,uCAAuC;aAClC,OAAO,KAAK,MAAM;QACvB,uCAAuC;aAClC,OAAO,KAAK,MAAM;;IAGzB,oEAAoE;SAC/D,OAAO,MAAO,MAAM;IAKzB,oEAAoE;SAC/D,OAAO,MAAO,MAAM;IAKzB,oEAAoE;SAC/D,OAAO,MAAO,MAAM;IAKzB;;;;;;;;;;;;;;OAcG;gBACO,KAAK,CAAC,MAAM,CAAC;IAavB;;;;;;;;;;;;;;;OAeG;YACK,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAa9B;;;;;OAKG;WACI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,KAAK,MAAM,GAAG,OAAO,KAAK,MAAM,GAAG,OAAO,QAAO,OAAO;IAS/F;;;;OAIG;WACI,MAAM,GAAG,OAAO,KAAK,MAAM,GAAG,OAAO,QAAO,OAAO;IAI1D;;;;;OAKG;WACI,MAAM,GAAG,OAAO,KAAK,MAAM,GAAG,OAAO,QAAO,OAAO;IAI1D;;;;;OAKG;YACK,MAAM,GAAG,OAAO,KAAK,MAAM,GAAG,OAAO,QAAO,OAAO;IAI3D;;;;;OAKG;YACK,MAAM,GAAG,OAAO,KAAK,MAAM,GAAG,OAAO,QAAO,OAAO;IAI3D;;;;;OAKG;YACK,MAAM,GAAG,OAAO,KAAK,MAAM,GAAG,OAAO,QAAO,OAAO;IAI3D;;;;;OAKG;WACI,MAAM,GAAG,OAAO,MAAK,MAAM,GAAG,OAAO;IAM5C;;;;;OAKG;wBACkB,OAAO;CAG7B,CAAA"}
|
package/dist/vector3.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { add, sub, mul, div, mod } from "./el.js";
|
|
2
|
+
/**
|
|
3
|
+
* A collection of constants and functions for constructing and
|
|
4
|
+
* interacting with Vector3 objects.
|
|
5
|
+
*/
|
|
6
|
+
export const Vector3 = {
|
|
7
|
+
/** Constant index for the x-component of a Vector3 */
|
|
8
|
+
X: 0,
|
|
9
|
+
/** Constant index for the y-component of a Vector3 */
|
|
10
|
+
Y: 1,
|
|
11
|
+
/** Constant index for the z-component of a Vector3 */
|
|
12
|
+
Z: 2,
|
|
13
|
+
/** A collection of getters for Vector3 objects */
|
|
14
|
+
Get: {
|
|
15
|
+
/** Get the x-component of a Vector3 */
|
|
16
|
+
x(a) { return a[Vector3.X]; },
|
|
17
|
+
/** Get the y-component of a Vector3 */
|
|
18
|
+
y(a) { return a[Vector3.Y]; },
|
|
19
|
+
/** Get the z-component of a Vector3 */
|
|
20
|
+
z(a) { return a[Vector3.Z]; },
|
|
21
|
+
},
|
|
22
|
+
/** A collection of setters for Vector3 objects */
|
|
23
|
+
Set: {
|
|
24
|
+
/** Set the x-component of a Vector3 */
|
|
25
|
+
x(a, x) { return a[Vector3.X] = x; },
|
|
26
|
+
/** Set the y-component of a Vector3 */
|
|
27
|
+
y(a, y) { return a[Vector3.Y] = y; },
|
|
28
|
+
/** Set the z-component of a Vector3 */
|
|
29
|
+
z(a, z) { return a[Vector3.Z] = z; },
|
|
30
|
+
},
|
|
31
|
+
/** Get or set (when `x` is defined) the x-component of a Vector3 */
|
|
32
|
+
x(a, x) {
|
|
33
|
+
if (x === undefined)
|
|
34
|
+
return Vector3.Get.x(a);
|
|
35
|
+
else
|
|
36
|
+
return Vector3.Set.x(a, x);
|
|
37
|
+
},
|
|
38
|
+
/** Get or set (when `y` is defined) the y-component of a Vector3 */
|
|
39
|
+
y(a, y) {
|
|
40
|
+
if (y === undefined)
|
|
41
|
+
return Vector3.Get.y(a);
|
|
42
|
+
else
|
|
43
|
+
return Vector3.Set.y(a, y);
|
|
44
|
+
},
|
|
45
|
+
/** Get or set (when `z` is defined) the z-component of a Vector3 */
|
|
46
|
+
z(a, z) {
|
|
47
|
+
if (z === undefined)
|
|
48
|
+
return Vector3.Get.z(a);
|
|
49
|
+
else
|
|
50
|
+
return Vector3.Set.z(a, z);
|
|
51
|
+
},
|
|
52
|
+
/**
|
|
53
|
+
* Construct a Vector3 from a variadic array of numbers.
|
|
54
|
+
*
|
|
55
|
+
* Constructs a uniform Vector3 when `a.length === 1`
|
|
56
|
+
* ```js
|
|
57
|
+
* Vector3.new(1) // [1, 1, 1]
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* Otherwise constructs a standard zero-padded Vector3
|
|
61
|
+
* ```js
|
|
62
|
+
* Vector3.new( ) // [0, 0, 0]
|
|
63
|
+
* Vector3.new(1, 2 ) // [1, 2, 0]
|
|
64
|
+
* Vector3.new(1, 2, 3) // [1, 2, 3]
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
new(...a) {
|
|
68
|
+
if (a.length === 1)
|
|
69
|
+
return [
|
|
70
|
+
a[Vector3.X],
|
|
71
|
+
a[Vector3.X],
|
|
72
|
+
a[Vector3.X]
|
|
73
|
+
];
|
|
74
|
+
else
|
|
75
|
+
return [
|
|
76
|
+
a[Vector3.X] ?? 0,
|
|
77
|
+
a[Vector3.Y] ?? 0,
|
|
78
|
+
a[Vector3.Z] ?? 0
|
|
79
|
+
];
|
|
80
|
+
},
|
|
81
|
+
/**
|
|
82
|
+
* Constructs a Vector3 from a number or an array of numbers.
|
|
83
|
+
*
|
|
84
|
+
* Constructs a uniform Vector3 when `a` is a number
|
|
85
|
+
* ```js
|
|
86
|
+
* Vector3.from(1) // [1, 1, 1]
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* Otherwise constructs a standard zero-padded Vector3
|
|
90
|
+
* ```js
|
|
91
|
+
* Vector3.from([ ]) // [0, 0, 0]
|
|
92
|
+
* Vector3.from([1 ]) // [1, 0, 0]
|
|
93
|
+
* Vector3.from([1, 2 ]) // [1, 2, 0]
|
|
94
|
+
* Vector3.from([1, 2, 3]) // [1, 2, 3]
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
from(a) {
|
|
98
|
+
if (typeof a === "number")
|
|
99
|
+
return [
|
|
100
|
+
a,
|
|
101
|
+
a,
|
|
102
|
+
a
|
|
103
|
+
];
|
|
104
|
+
else
|
|
105
|
+
return [
|
|
106
|
+
a[Vector3.X] ?? 0,
|
|
107
|
+
a[Vector3.Y] ?? 0,
|
|
108
|
+
a[Vector3.Z] ?? 0
|
|
109
|
+
];
|
|
110
|
+
},
|
|
111
|
+
/**
|
|
112
|
+
* Perform an element-wise operation on two Vector3 objects.
|
|
113
|
+
* Number-like arguments are promoted to uniform Vector3 objects
|
|
114
|
+
* before performing the operation. Constructs a new Vector3 when an
|
|
115
|
+
* output argument is not provided.
|
|
116
|
+
*/
|
|
117
|
+
el(op, a, b, out = Vector3.new()) {
|
|
118
|
+
const [xa, ya, za] = Vector3.from(a);
|
|
119
|
+
const [xb, yb, zb] = Vector3.from(b);
|
|
120
|
+
Vector3.Set.x(out, op(xa, xb));
|
|
121
|
+
Vector3.Set.y(out, op(ya, yb));
|
|
122
|
+
Vector3.Set.z(out, op(za, zb));
|
|
123
|
+
return out;
|
|
124
|
+
},
|
|
125
|
+
/**
|
|
126
|
+
* Compute the sum of two Vector3 objects. Number-like arguments are
|
|
127
|
+
* promoted to uniform Vector3 objects before performing the operation.
|
|
128
|
+
* Constructs a new Vector3 when an output argument is not provided.
|
|
129
|
+
*/
|
|
130
|
+
add(a, b, out = Vector3.new()) {
|
|
131
|
+
return Vector3.el(add, a, b, out);
|
|
132
|
+
},
|
|
133
|
+
/**
|
|
134
|
+
* Compute the difference of two Vector3 objects. Number-like arguments
|
|
135
|
+
* are promoted to uniform Vector3 objects before performing the
|
|
136
|
+
* operation. Constructs a new Vector3 when an output argument is not
|
|
137
|
+
* provided.
|
|
138
|
+
*/
|
|
139
|
+
sub(a, b, out = Vector3.new()) {
|
|
140
|
+
return Vector3.el(sub, a, b, out);
|
|
141
|
+
},
|
|
142
|
+
/**
|
|
143
|
+
* Compute the hadamard (element-wise) product of two Vector3 objects.
|
|
144
|
+
* Number-like arguments are promoted to uniform Vector3 objects before
|
|
145
|
+
* performing the operation. Constructs a new Vector3 when an output
|
|
146
|
+
* argument is not provided.
|
|
147
|
+
*/
|
|
148
|
+
hmul(a, b, out = Vector3.new()) {
|
|
149
|
+
return Vector3.el(mul, a, b, out);
|
|
150
|
+
},
|
|
151
|
+
/**
|
|
152
|
+
* Compute the hadamard (element-wise) quotient of two Vector3 objects.
|
|
153
|
+
* Number-like arguments are promoted to uniform Vector3 objects before
|
|
154
|
+
* performing the operation. Constructs a new Vector3 when an output
|
|
155
|
+
* argument is not provided.
|
|
156
|
+
*/
|
|
157
|
+
hdiv(a, b, out = Vector3.new()) {
|
|
158
|
+
return Vector3.el(div, a, b, out);
|
|
159
|
+
},
|
|
160
|
+
/**
|
|
161
|
+
* Compute the hadamard (element-wise) remainder of two Vector3 objects.
|
|
162
|
+
* Number-like arguments are promoted to uniform Vector3 objects before
|
|
163
|
+
* performing the operation. Constructs a new Vector3 when an output
|
|
164
|
+
* argument is not provided.
|
|
165
|
+
*/
|
|
166
|
+
hmod(a, b, out = Vector3.new()) {
|
|
167
|
+
return Vector3.el(mod, a, b, out);
|
|
168
|
+
},
|
|
169
|
+
/**
|
|
170
|
+
* Compute the dot product of two Vector3 objects, or simply the
|
|
171
|
+
* dot product of `a` with itself when `b` is not defined. Number-like
|
|
172
|
+
* arguments are promoted to uniform Vector3 objects before performing
|
|
173
|
+
* the operation.
|
|
174
|
+
*/
|
|
175
|
+
dot(a, b = a) {
|
|
176
|
+
const [xa, ya, za] = Vector3.from(a);
|
|
177
|
+
const [xb, yb, zb] = Vector3.from(b);
|
|
178
|
+
return xa * xb + ya * yb + za * zb;
|
|
179
|
+
},
|
|
180
|
+
/**
|
|
181
|
+
* Convert a Vector3 into its string representation.
|
|
182
|
+
* ```js
|
|
183
|
+
* Vector3.toString([1, 2, 3]) // "vec3<1, 2, 3>"
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
toString([x, y, z]) {
|
|
187
|
+
return `vec3<${x}, ${y}, ${z}>`;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
//# sourceMappingURL=vector3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector3.js","sourceRoot":"","sources":["../src/vector3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAIlD;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,sDAAsD;IACtD,CAAC,EAAE,CAAU;IACb,sDAA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,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAA;IACnC,CAAC;IAED;;;;;OAKG;IACH,IAAI,CAAC,CAAmB,EAAE,CAAmB,EAAE,MAAe,OAAO,CAAC,GAAG,EAAE;QACzE,OAAO,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAA;IACnC,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,CAAmB,EAAE,IAAsB,CAAC;QAC9C,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACpC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACpC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAA;IACpC,CAAC;IAED;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAW;QAC1B,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,GAAY,CAAA;IAC1C,CAAC;CACF,CAAA"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
export type Vector4 = [number, number, number, number];
|
|
2
|
+
/**
|
|
3
|
+
* A collection of constants and functions for constructing and
|
|
4
|
+
* interacting with Vector4 objects.
|
|
5
|
+
*/
|
|
6
|
+
export declare const Vector4: {
|
|
7
|
+
/** Constant index for the x-component of a Vector4 */
|
|
8
|
+
X: 0;
|
|
9
|
+
/** Constant index for the y-component of a Vector4 */
|
|
10
|
+
Y: 1;
|
|
11
|
+
/** Constant index for the z-component of a Vector4 */
|
|
12
|
+
Z: 2;
|
|
13
|
+
/** Constant index for the w-component of a Vector4 */
|
|
14
|
+
W: 3;
|
|
15
|
+
/** A collection of getters for Vector4 objects */
|
|
16
|
+
Get: {
|
|
17
|
+
/** Get the x-component of a Vector4 */
|
|
18
|
+
x(a: Vector4): number;
|
|
19
|
+
/** Get the y-component of a Vector4 */
|
|
20
|
+
y(a: Vector4): number;
|
|
21
|
+
/** Get the z-component of a Vector4 */
|
|
22
|
+
z(a: Vector4): number;
|
|
23
|
+
/** Get the w-component of a Vector4 */
|
|
24
|
+
w(a: Vector4): number;
|
|
25
|
+
};
|
|
26
|
+
Set: {
|
|
27
|
+
/** Set the x-component of a Vector4 */
|
|
28
|
+
x(a: Vector4, x: number): number;
|
|
29
|
+
/** Set the y-component of a Vector4 */
|
|
30
|
+
y(a: Vector4, y: number): number;
|
|
31
|
+
/** Set the z-component of a Vector4 */
|
|
32
|
+
z(a: Vector4, z: number): number;
|
|
33
|
+
/** Set the w-component of a Vector4 */
|
|
34
|
+
w(a: Vector4, w: number): number;
|
|
35
|
+
};
|
|
36
|
+
/** Get or set (when `x` is defined) the x-component of a Vector4 */
|
|
37
|
+
x(a: Vector4, x?: number): number;
|
|
38
|
+
/** Get or set (when `y` is defined) the y-component of a Vector4 */
|
|
39
|
+
y(a: Vector4, y?: number): number;
|
|
40
|
+
/** Get or set (when `z` is defined) the z-component of a Vector4 */
|
|
41
|
+
z(a: Vector4, z?: number): number;
|
|
42
|
+
/** Get or set (when `w` is defined) the w-component of a Vector4 */
|
|
43
|
+
w(a: Vector4, w?: number): number;
|
|
44
|
+
/**
|
|
45
|
+
* Construct a Vector4 from a variadic array of numbers.
|
|
46
|
+
*
|
|
47
|
+
* Constructs a uniform Vector4 when `a.length === 1`
|
|
48
|
+
* ```js
|
|
49
|
+
* Vector4.new(1) // [1, 1, 1, 1]
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* Otherwise constructs a standard zero-padded Vector4
|
|
53
|
+
* ```js
|
|
54
|
+
* Vector4.new( ) // [0, 0, 0, 0]
|
|
55
|
+
* Vector4.new(1, 2 ) // [1, 2, 0, 0]
|
|
56
|
+
* Vector4.new(1, 2, 3 ) // [1, 2, 3, 0]
|
|
57
|
+
* Vector4.new(1, 2, 3, 4) // [1, 2, 3, 4]
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
"new"(...a: Array<number>): [number, number, number, number];
|
|
61
|
+
/**
|
|
62
|
+
* Constructs a Vector4 from a number or an array of numbers.
|
|
63
|
+
*
|
|
64
|
+
* Constructs a uniform Vector4 when `a` is a number
|
|
65
|
+
* ```js
|
|
66
|
+
* Vector4.from(1) // [1, 1, 1, 1]
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* Otherwise constructs a standard zero-padded Vector4
|
|
70
|
+
* ```js
|
|
71
|
+
* Vector4.from([ ]) // [0, 0, 0, 0]
|
|
72
|
+
* Vector4.from([1 ]) // [1, 0, 0, 0]
|
|
73
|
+
* Vector4.from([1, 2 ]) // [1, 2, 0, 0]
|
|
74
|
+
* Vector4.from([1, 2, 3 ]) // [1, 2, 3, 0]
|
|
75
|
+
* Vector4.from([1, 2, 3, 4]) // [1, 2, 3, 4]
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
from(a: number | Array<number>): [number, number, number, number];
|
|
79
|
+
/**
|
|
80
|
+
* Perform an element-wise operation on two Vector4 objects.
|
|
81
|
+
* Number-like arguments are promoted to uniform Vector4 objects
|
|
82
|
+
* before performing the operation. Constructs a new Vector4 when an
|
|
83
|
+
* output argument is not provided.
|
|
84
|
+
*/
|
|
85
|
+
el(op: (a: number, b: number) => number, a: number | Vector4, b: number | Vector4, out?: Vector4): Vector4;
|
|
86
|
+
/**
|
|
87
|
+
* Compute the sum of two Vector4 objects. Number-like arguments are
|
|
88
|
+
* promoted to uniform Vector4 objects before performing the operation.
|
|
89
|
+
* Constructs a new Vector4 when an output argument is not provided.
|
|
90
|
+
*/
|
|
91
|
+
add(a: number | Vector4, b: number | Vector4, out?: Vector4): Vector4;
|
|
92
|
+
/**
|
|
93
|
+
* Compute the difference of two Vector4 objects. Number-like arguments
|
|
94
|
+
* are promoted to uniform Vector4 objects before performing the
|
|
95
|
+
* operation. Constructs a new Vector4 when an output argument is not
|
|
96
|
+
* provided.
|
|
97
|
+
*/
|
|
98
|
+
sub(a: number | Vector4, b: number | Vector4, out?: Vector4): Vector4;
|
|
99
|
+
/**
|
|
100
|
+
* Compute the hadamard (element-wise) product of two Vector4 objects.
|
|
101
|
+
* Number-like arguments are promoted to uniform Vector4 objects before
|
|
102
|
+
* performing the operation. Constructs a new Vector4 when an output
|
|
103
|
+
* argument is not provided.
|
|
104
|
+
*/
|
|
105
|
+
hmul(a: number | Vector4, b: number | Vector4, out?: Vector4): Vector4;
|
|
106
|
+
/**
|
|
107
|
+
* Compute the hadamard (element-wise) quotient of two Vector4 objects.
|
|
108
|
+
* Number-like arguments are promoted to uniform Vector4 objects before
|
|
109
|
+
* performing the operation. Constructs a new Vector4 when an output
|
|
110
|
+
* argument is not provided.
|
|
111
|
+
*/
|
|
112
|
+
hdiv(a: number | Vector4, b: number | Vector4, out?: Vector4): Vector4;
|
|
113
|
+
/**
|
|
114
|
+
* Compute the hadamard (element-wise) remainder of two Vector4 objects.
|
|
115
|
+
* Number-like arguments are promoted to uniform Vector4 objects before
|
|
116
|
+
* performing the operation. Constructs a new Vector4 when an output
|
|
117
|
+
* argument is not provided.
|
|
118
|
+
*/
|
|
119
|
+
hmod(a: number | Vector4, b: number | Vector4, out?: Vector4): Vector4;
|
|
120
|
+
/**
|
|
121
|
+
* Compute the dot product of two Vector4 objects, or simply the
|
|
122
|
+
* dot product of `a` with itself when `b` is not defined. Number-like
|
|
123
|
+
* arguments are promoted to uniform Vector4 objects before performing
|
|
124
|
+
* the operation.
|
|
125
|
+
*/
|
|
126
|
+
dot(a: number | Vector4, b?: number | Vector4): number;
|
|
127
|
+
/**
|
|
128
|
+
* Convert a Vector4 into its string representation.
|
|
129
|
+
* ```js
|
|
130
|
+
* Vector4.toString([1, 2, 3, 4]) // "vec4<1, 2, 3, 4>"
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
toString([x, y, z, w]: Vector4): `vec4<${number}, ${number}, ${number}, ${number}>`;
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=vector4.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector4.d.ts","sourceRoot":"","sources":["../src/vector4.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AAEtD;;;GAGG;AACH,eAAO,MAAM,OAAO;IAClB,sDAAsD;;IAEtD,sDAAsD;;IAEtD,sDAAsD;;IAEtD,sDAAsD;;IAGtD,kDAAkD;;QAEhD,uCAAuC;aAClC,OAAO;QACZ,uCAAuC;aAClC,OAAO;QACZ,uCAAuC;aAClC,OAAO;QACZ,uCAAuC;aAClC,OAAO;;;QAIZ,uCAAuC;aAClC,OAAO,KAAK,MAAM;QACvB,uCAAuC;aAClC,OAAO,KAAK,MAAM;QACvB,uCAAuC;aAClC,OAAO,KAAK,MAAM;QACvB,uCAAuC;aAClC,OAAO,KAAK,MAAM;;IAGzB,oEAAoE;SAC/D,OAAO,MAAO,MAAM;IAKzB,oEAAoE;SAC/D,OAAO,MAAO,MAAM;IAKzB,oEAAoE;SAC/D,OAAO,MAAO,MAAM;IAKzB,oEAAoE;SAC/D,OAAO,MAAO,MAAM;IAKzB;;;;;;;;;;;;;;;OAeG;gBACO,KAAK,CAAC,MAAM,CAAE;IAexB;;;;;;;;;;;;;;;;OAgBG;YACK,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAe9B;;;;;OAKG;WACI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,KAAK,MAAM,GAAG,OAAO,KAAK,MAAM,GAAG,OAAO,QAAO,OAAO;IAU/F;;;;OAIG;WACI,MAAM,GAAG,OAAO,KAAK,MAAM,GAAG,OAAO,QAAO,OAAO;IAI1D;;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