glmaths 0.0.2 → 0.0.4
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 +570 -552
- package/benchmark.js +2 -2
- package/dist/cjs/glmaths.d.ts +240 -198
- package/dist/cjs/glmaths.js +544 -462
- package/dist/cjs/glmaths.js.map +1 -1
- package/dist/cjs/glmaths.min.js +1 -1
- package/dist/cjs/glmaths.min.js.map +1 -1
- package/dist/esm/glmaths.d.ts +240 -198
- package/dist/esm/glmaths.js +544 -462
- package/dist/esm/glmaths.js.map +1 -1
- package/dist/esm/glmaths.min.js +1 -1
- package/dist/esm/glmaths.min.js.map +1 -1
- package/dist/glmaths.d.ts +240 -198
- package/dist/glmaths.js +544 -462
- package/dist/glmaths.js.map +1 -1
- package/dist/glmaths.min.js +1 -1
- package/dist/glmaths.min.js.map +1 -1
- package/examples/index.html +23 -0
- package/examples/main.js +134 -0
- package/examples/main.ts +159 -0
- package/package.json +1 -1
- package/src/mat2.ts +27 -27
- package/src/mat2x3.ts +37 -31
- package/src/mat3.ts +53 -54
- package/src/mat4.ts +81 -82
- package/src/quat.ts +36 -23
- package/src/quat2.ts +45 -31
- package/src/vec2.ts +90 -70
- package/src/vec3.ts +143 -121
- package/src/vec4.ts +79 -57
- package/tests/mat2.test.ts +53 -53
- package/tests/mat2x3.test.ts +46 -46
- package/tests/mat3.test.ts +59 -59
package/src/vec3.ts
CHANGED
|
@@ -12,22 +12,22 @@ import { Quat } from './quat'
|
|
|
12
12
|
*/
|
|
13
13
|
export class Vec3 extends Float32Array {
|
|
14
14
|
|
|
15
|
-
static get zero() { return
|
|
16
|
-
static get Zero() { return
|
|
17
|
-
static get ZERO() { return
|
|
18
|
-
static get one() { return
|
|
19
|
-
static get One() { return
|
|
20
|
-
static get ONE() { return
|
|
15
|
+
static get zero() { return vec3(0, 0, 0) }
|
|
16
|
+
static get Zero() { return vec3(0, 0, 0) }
|
|
17
|
+
static get ZERO() { return vec3(0, 0, 0) }
|
|
18
|
+
static get one() { return vec3(1, 1, 1) }
|
|
19
|
+
static get One() { return vec3(1, 1, 1) }
|
|
20
|
+
static get ONE() { return vec3(1, 1, 1) }
|
|
21
21
|
|
|
22
|
-
static get unitX() { return
|
|
23
|
-
static get UnitX() { return
|
|
24
|
-
static get unitY() { return
|
|
25
|
-
static get UnitY() { return
|
|
26
|
-
static get unitZ() { return
|
|
27
|
-
static get UnitZ() { return
|
|
22
|
+
static get unitX() { return vec3(1, 0, 0) }
|
|
23
|
+
static get UnitX() { return vec3(1, 0, 0) }
|
|
24
|
+
static get unitY() { return vec3(0, 1, 0) }
|
|
25
|
+
static get UnitY() { return vec3(0, 1, 0) }
|
|
26
|
+
static get unitZ() { return vec3(0, 0, 1) }
|
|
27
|
+
static get UnitZ() { return vec3(0, 0, 1) }
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* Creates
|
|
30
|
+
* Creates new vec3
|
|
31
31
|
*
|
|
32
32
|
* @param {Number} x X component, defaults to 0
|
|
33
33
|
* @param {Number} y Y component, defaults to 0
|
|
@@ -53,10 +53,10 @@ export class Vec3 extends Float32Array {
|
|
|
53
53
|
* Adds two vec3's
|
|
54
54
|
*
|
|
55
55
|
* @param {Number | Vec3} b the second operand
|
|
56
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
56
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3()
|
|
57
57
|
* @returns {Vec3} out
|
|
58
58
|
*/
|
|
59
|
-
plus(b: number | Vec3, out = glmaths.ALWAYS_COPY ?
|
|
59
|
+
plus(b: number | Vec3, out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
60
60
|
if (typeof b === 'number') {
|
|
61
61
|
out[0] = this[0] + b
|
|
62
62
|
out[1] = this[1] + b
|
|
@@ -73,10 +73,10 @@ export class Vec3 extends Float32Array {
|
|
|
73
73
|
* Subtracts two vec3's
|
|
74
74
|
*
|
|
75
75
|
* @param {Number | Vec3} b the second operand
|
|
76
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
76
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3()
|
|
77
77
|
* @returns {Vec3} out
|
|
78
78
|
*/
|
|
79
|
-
minus(b: number | Vec3, out = glmaths.ALWAYS_COPY ?
|
|
79
|
+
minus(b: number | Vec3, out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
80
80
|
if (typeof b === 'number') {
|
|
81
81
|
out[0] = this[0] - b
|
|
82
82
|
out[1] = this[1] - b
|
|
@@ -93,10 +93,10 @@ export class Vec3 extends Float32Array {
|
|
|
93
93
|
* Multiplies two vec3's
|
|
94
94
|
*
|
|
95
95
|
* @param {Number | Vec3} b the second operand
|
|
96
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
96
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3()
|
|
97
97
|
* @returns {Vec3} out
|
|
98
98
|
*/
|
|
99
|
-
mult(b: number | Vec3, out = glmaths.ALWAYS_COPY ?
|
|
99
|
+
mult(b: number | Vec3, out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
100
100
|
if (typeof b === 'number') {
|
|
101
101
|
out[0] = this[0] * b
|
|
102
102
|
out[1] = this[1] * b
|
|
@@ -113,10 +113,10 @@ export class Vec3 extends Float32Array {
|
|
|
113
113
|
* Divides two vec3's
|
|
114
114
|
*
|
|
115
115
|
* @param {Number | Vec3} b the second operand
|
|
116
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
116
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3()
|
|
117
117
|
* @returns {Vec3} out
|
|
118
118
|
*/
|
|
119
|
-
div(b: number | Vec3, out = glmaths.ALWAYS_COPY ?
|
|
119
|
+
div(b: number | Vec3, out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
120
120
|
if (typeof b === 'number') {
|
|
121
121
|
out[0] = this[0] / b
|
|
122
122
|
out[1] = this[1] / b
|
|
@@ -128,7 +128,7 @@ export class Vec3 extends Float32Array {
|
|
|
128
128
|
}
|
|
129
129
|
return out
|
|
130
130
|
}
|
|
131
|
-
invDiv(b: number | Vec3, out = glmaths.ALWAYS_COPY ?
|
|
131
|
+
invDiv(b: number | Vec3, out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
132
132
|
if (typeof b === 'number') {
|
|
133
133
|
out[0] = b / this[0]
|
|
134
134
|
out[1] = b / this[1]
|
|
@@ -142,18 +142,18 @@ export class Vec3 extends Float32Array {
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
|
-
* Negates the components of
|
|
145
|
+
* Negates the components of this vec3
|
|
146
146
|
*
|
|
147
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
147
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3()
|
|
148
148
|
* @returns {Vec3} out
|
|
149
149
|
*/
|
|
150
|
-
negate(out = glmaths.ALWAYS_COPY ?
|
|
150
|
+
negate(out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
151
151
|
out[0] = -this[0]
|
|
152
152
|
out[1] = -this[1]
|
|
153
153
|
out[2] = -this[2]
|
|
154
154
|
return out
|
|
155
155
|
}
|
|
156
|
-
unaryPlus(out = glmaths.ALWAYS_COPY ?
|
|
156
|
+
unaryPlus(out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
157
157
|
if (out != this) {
|
|
158
158
|
out[0] = this[0]
|
|
159
159
|
out[1] = this[1]
|
|
@@ -163,13 +163,13 @@ export class Vec3 extends Float32Array {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
/**
|
|
166
|
-
* Normalizes
|
|
166
|
+
* Normalizes vec3
|
|
167
167
|
*
|
|
168
168
|
* @param {Vec3} v the vector to normalize
|
|
169
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
169
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3
|
|
170
170
|
* @returns {Vec3} out
|
|
171
171
|
*/
|
|
172
|
-
static normalize(v: Vec3, out =
|
|
172
|
+
static normalize(v: Vec3, out = vec3()): Vec3 {
|
|
173
173
|
const x = v[0], y = v[1], z = v[2]
|
|
174
174
|
let len = x * x + y * y + z * z
|
|
175
175
|
if (len > 0) len = 1.0 / Math.sqrt(len)
|
|
@@ -178,13 +178,14 @@ export class Vec3 extends Float32Array {
|
|
|
178
178
|
out[2] = z * len
|
|
179
179
|
return out
|
|
180
180
|
}
|
|
181
|
+
|
|
181
182
|
/**
|
|
182
|
-
* Normalizes
|
|
183
|
+
* Normalizes this vec3
|
|
183
184
|
*
|
|
184
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
185
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3()
|
|
185
186
|
* @returns {Vec3} out
|
|
186
187
|
*/
|
|
187
|
-
normalize(out = glmaths.ALWAYS_COPY ?
|
|
188
|
+
normalize(out = glmaths.ALWAYS_COPY ? vec3() : this): Vec3 {
|
|
188
189
|
const x = this[0], y = this[1], z = this[2]
|
|
189
190
|
let len = x * x + y * y + z * z
|
|
190
191
|
if (len > 0) len = 1.0 / Math.sqrt(len)
|
|
@@ -219,7 +220,7 @@ export class Vec3 extends Float32Array {
|
|
|
219
220
|
}
|
|
220
221
|
|
|
221
222
|
/**
|
|
222
|
-
* Calculates the squared length of
|
|
223
|
+
* Calculates the squared length of vec3
|
|
223
224
|
*
|
|
224
225
|
* @returns {Number} squared length of a vector
|
|
225
226
|
*/
|
|
@@ -229,7 +230,7 @@ export class Vec3 extends Float32Array {
|
|
|
229
230
|
}
|
|
230
231
|
|
|
231
232
|
/**
|
|
232
|
-
* Calculates the length of
|
|
233
|
+
* Calculates the length of vec3
|
|
233
234
|
*
|
|
234
235
|
* @returns {Number} length of a vector
|
|
235
236
|
*/
|
|
@@ -239,69 +240,69 @@ export class Vec3 extends Float32Array {
|
|
|
239
240
|
}
|
|
240
241
|
|
|
241
242
|
/**
|
|
242
|
-
* Returns
|
|
243
|
+
* Returns vec3 with each component floored
|
|
243
244
|
*
|
|
244
245
|
* @param {Vec3} v the vector to floor
|
|
245
246
|
* @returns {Vec3} a new floored vector
|
|
246
247
|
*/
|
|
247
|
-
static floor(v: Vec3, out =
|
|
248
|
+
static floor(v: Vec3, out = vec3()) {
|
|
248
249
|
out[0] = Math.floor(v[0])
|
|
249
250
|
out[1] = Math.floor(v[1])
|
|
250
251
|
out[2] = Math.floor(v[2])
|
|
251
252
|
return out
|
|
252
253
|
}
|
|
253
254
|
/**
|
|
254
|
-
* Returns
|
|
255
|
+
* Returns vec3 with each component rounded
|
|
255
256
|
*
|
|
256
257
|
* @param {Vec3} v the vector to round
|
|
257
258
|
* @returns {Vec3} a new rounded vector
|
|
258
259
|
*/
|
|
259
|
-
static round(v: Vec3, out =
|
|
260
|
+
static round(v: Vec3, out = vec3()) {
|
|
260
261
|
out[0] = Math.round(v[0])
|
|
261
262
|
out[1] = Math.round(v[1])
|
|
262
263
|
out[2] = Math.round(v[2])
|
|
263
264
|
return out
|
|
264
265
|
}
|
|
265
266
|
/**
|
|
266
|
-
* Returns
|
|
267
|
+
* Returns vec3 with each component ceiled
|
|
267
268
|
*
|
|
268
269
|
* @param {Vec3} v the vector to ceil
|
|
269
270
|
* @returns {Vec3} a new ceiled vector
|
|
270
271
|
*/
|
|
271
|
-
static ceil (v: Vec3, out =
|
|
272
|
+
static ceil (v: Vec3, out = vec3()) {
|
|
272
273
|
out[0] = Math.ceil(v[0])
|
|
273
274
|
out[1] = Math.ceil(v[1])
|
|
274
275
|
out[2] = Math.ceil(v[2])
|
|
275
276
|
return out
|
|
276
277
|
}
|
|
277
278
|
/**
|
|
278
|
-
* Floors each component of
|
|
279
|
+
* Floors each component of vec3
|
|
279
280
|
*
|
|
280
281
|
* @returns {Vec3} this
|
|
281
282
|
*/
|
|
282
|
-
floor(out = glmaths.ALWAYS_COPY ?
|
|
283
|
+
floor(out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
283
284
|
out[0] = Math.floor(this[0])
|
|
284
285
|
out[1] = Math.floor(this[1])
|
|
285
286
|
out[2] = Math.floor(this[2])
|
|
286
287
|
return out
|
|
287
288
|
}
|
|
288
289
|
/**
|
|
289
|
-
* Rounds each component of
|
|
290
|
+
* Rounds each component of vec3
|
|
290
291
|
*
|
|
291
292
|
* @returns {Vec3} this
|
|
292
293
|
*/
|
|
293
|
-
round(out = glmaths.ALWAYS_COPY ?
|
|
294
|
+
round(out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
294
295
|
out[0] = Math.round(this[0])
|
|
295
296
|
out[1] = Math.round(this[1])
|
|
296
297
|
out[2] = Math.round(this[2])
|
|
297
298
|
return out
|
|
298
299
|
}
|
|
299
300
|
/**
|
|
300
|
-
* Ceils each component of
|
|
301
|
+
* Ceils each component of vec3
|
|
301
302
|
*
|
|
302
303
|
* @returns {Vec3} this
|
|
303
304
|
*/
|
|
304
|
-
ceil(out = glmaths.ALWAYS_COPY ?
|
|
305
|
+
ceil(out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
305
306
|
out[0] = Math.ceil(this[0])
|
|
306
307
|
out[1] = Math.ceil(this[1])
|
|
307
308
|
out[2] = Math.ceil(this[2])
|
|
@@ -309,23 +310,23 @@ export class Vec3 extends Float32Array {
|
|
|
309
310
|
}
|
|
310
311
|
|
|
311
312
|
/**
|
|
312
|
-
* Returns the inverse of
|
|
313
|
+
* Returns the inverse of vec3
|
|
313
314
|
*
|
|
314
315
|
* @param {Vec3} v the source vector
|
|
315
316
|
* @returns {Vec3} a new inverted vector
|
|
316
317
|
*/
|
|
317
|
-
static inverse(v: Vec3, out =
|
|
318
|
+
static inverse(v: Vec3, out = vec3()) {
|
|
318
319
|
out[0] = 1.0 / v[0]
|
|
319
320
|
out[1] = 1.0 / v[1]
|
|
320
321
|
out[2] = 1.0 / v[2]
|
|
321
322
|
return out
|
|
322
323
|
}
|
|
323
324
|
/**
|
|
324
|
-
* Inverts
|
|
325
|
+
* Inverts vec3 component-wise
|
|
325
326
|
*
|
|
326
327
|
* @returns {Vec3} this
|
|
327
328
|
*/
|
|
328
|
-
inverse(out = glmaths.ALWAYS_COPY ?
|
|
329
|
+
inverse(out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
329
330
|
out[0] = 1.0 / this[0]
|
|
330
331
|
out[1] = 1.0 / this[1]
|
|
331
332
|
out[2] = 1.0 / this[2]
|
|
@@ -333,12 +334,12 @@ export class Vec3 extends Float32Array {
|
|
|
333
334
|
}
|
|
334
335
|
|
|
335
336
|
/**
|
|
336
|
-
* Creates
|
|
337
|
+
* Creates vec3 initialized with values from a vector
|
|
337
338
|
*
|
|
338
|
-
* @returns {Vec3}
|
|
339
|
+
* @returns {Vec3} vec3
|
|
339
340
|
*/
|
|
340
341
|
clone() {
|
|
341
|
-
return
|
|
342
|
+
return vec3(this[0], this[1], this[2])
|
|
342
343
|
}
|
|
343
344
|
|
|
344
345
|
/**
|
|
@@ -360,7 +361,7 @@ export class Vec3 extends Float32Array {
|
|
|
360
361
|
const r = glmaths.RANDOM() * 2.0 * Math.PI
|
|
361
362
|
const z = glmaths.RANDOM() * 2.0 - 1.0
|
|
362
363
|
const zScale = Math.sqrt(1.0 - z * z) * scale
|
|
363
|
-
return
|
|
364
|
+
return vec3(
|
|
364
365
|
Math.cos(r) * zScale,
|
|
365
366
|
Math.sin(r) * zScale,
|
|
366
367
|
z * scale
|
|
@@ -397,10 +398,10 @@ export class Vec3 extends Float32Array {
|
|
|
397
398
|
*
|
|
398
399
|
* @param {Vec3} a the first operand
|
|
399
400
|
* @param {Vec3} b the second operand
|
|
400
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
401
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3
|
|
401
402
|
* @returns {Vec3} out
|
|
402
403
|
*/
|
|
403
|
-
static cross(a: Vec3, b: Vec3, out =
|
|
404
|
+
static cross(a: Vec3, b: Vec3, out = vec3()): Vec3 {
|
|
404
405
|
const ax = a[0], ay = a[1], az = a[2]
|
|
405
406
|
const bx = b[0], by = b[1], bz = b[2]
|
|
406
407
|
out[0] = ay * bz - az * by
|
|
@@ -445,10 +446,10 @@ export class Vec3 extends Float32Array {
|
|
|
445
446
|
* @param {Vec3} a the first operand
|
|
446
447
|
* @param {Vec3} b the second operand
|
|
447
448
|
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
|
|
448
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
449
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3
|
|
449
450
|
* @returns {Vec3} out
|
|
450
451
|
*/
|
|
451
|
-
static lerp(a: Vec3, b: Vec3, t: number, out =
|
|
452
|
+
static lerp(a: Vec3, b: Vec3, t: number, out = vec3()) {
|
|
452
453
|
const ax = a[0], ay = a[1], az = a[2]
|
|
453
454
|
out[0] = ax + (b[0] - ax) * t
|
|
454
455
|
out[1] = ay + (b[1] - ay) * t
|
|
@@ -461,10 +462,10 @@ export class Vec3 extends Float32Array {
|
|
|
461
462
|
* @param {Vec3} a the first operand
|
|
462
463
|
* @param {Vec3} b the second operand
|
|
463
464
|
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
|
|
464
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
465
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3
|
|
465
466
|
* @returns {Vec3} out
|
|
466
467
|
*/
|
|
467
|
-
static slerp(a: Vec3, b: Vec3, t: number, out =
|
|
468
|
+
static slerp(a: Vec3, b: Vec3, t: number, out = vec3()) {
|
|
468
469
|
const angle = Math.acos(Math.min(Math.max(Vec3.dot(a, b), -1), 1))
|
|
469
470
|
const sinTotal = Math.sin(angle)
|
|
470
471
|
const ratioA = Math.sin((1 - t) * angle) / sinTotal
|
|
@@ -482,7 +483,7 @@ export class Vec3 extends Float32Array {
|
|
|
482
483
|
* @param {Vec3} b the second operand
|
|
483
484
|
* @returns {Vec3} a new vector with the max components
|
|
484
485
|
*/
|
|
485
|
-
static max(a: Vec3, b: Vec3, out =
|
|
486
|
+
static max(a: Vec3, b: Vec3, out = vec3()) {
|
|
486
487
|
out[0] = Math.max(a[0], b[0])
|
|
487
488
|
out[1] = Math.max(a[1], b[1])
|
|
488
489
|
out[2] = Math.max(a[2], b[2])
|
|
@@ -495,7 +496,7 @@ export class Vec3 extends Float32Array {
|
|
|
495
496
|
* @param {Vec3} b the second operand
|
|
496
497
|
* @returns {Vec3} a new vector with the min components
|
|
497
498
|
*/
|
|
498
|
-
static min(a: Vec3, b: Vec3, out =
|
|
499
|
+
static min(a: Vec3, b: Vec3, out = vec3()) {
|
|
499
500
|
out[0] = Math.min(a[0], b[0])
|
|
500
501
|
out[1] = Math.min(a[1], b[1])
|
|
501
502
|
out[2] = Math.min(a[2], b[2])
|
|
@@ -511,7 +512,7 @@ export class Vec3 extends Float32Array {
|
|
|
511
512
|
* @param {Vec3} out the receiving vector
|
|
512
513
|
* @returns {Vec3} out
|
|
513
514
|
*/
|
|
514
|
-
static clamp(v: Vec3, min: Vec3 | number, max: Vec3 | number, out =
|
|
515
|
+
static clamp(v: Vec3, min: Vec3 | number, max: Vec3 | number, out = vec3()) {
|
|
515
516
|
const minX = typeof min === 'number' ? min : min[0]
|
|
516
517
|
const minY = typeof min === 'number' ? min : min[1]
|
|
517
518
|
const minZ = typeof min === 'number' ? min : min[2]
|
|
@@ -533,7 +534,7 @@ export class Vec3 extends Float32Array {
|
|
|
533
534
|
* @param {Vec3} out the receiving vector
|
|
534
535
|
* @returns {Vec3} out
|
|
535
536
|
*/
|
|
536
|
-
static mix(a: Vec3, b: Vec3, t: Vec3 | number, out =
|
|
537
|
+
static mix(a: Vec3, b: Vec3, t: Vec3 | number, out = vec3()) {
|
|
537
538
|
if (typeof t === 'number') {
|
|
538
539
|
out[0] = a[0] + (b[0] - a[0]) * t
|
|
539
540
|
out[1] = a[1] + (b[1] - a[1]) * t
|
|
@@ -555,7 +556,7 @@ export class Vec3 extends Float32Array {
|
|
|
555
556
|
* @param {Vec3} out the receiving vector
|
|
556
557
|
* @returns {Vec3} out
|
|
557
558
|
*/
|
|
558
|
-
static smoothstep(edge0: Vec3 | number, edge1: Vec3 | number, v: Vec3, out =
|
|
559
|
+
static smoothstep(edge0: Vec3 | number, edge1: Vec3 | number, v: Vec3, out = vec3()) {
|
|
559
560
|
const e0x = typeof edge0 === 'number' ? edge0 : edge0[0]
|
|
560
561
|
const e0y = typeof edge0 === 'number' ? edge0 : edge0[1]
|
|
561
562
|
const e0z = typeof edge0 === 'number' ? edge0 : edge0[2]
|
|
@@ -572,14 +573,14 @@ export class Vec3 extends Float32Array {
|
|
|
572
573
|
}
|
|
573
574
|
|
|
574
575
|
/**
|
|
575
|
-
* Rotates
|
|
576
|
+
* Rotates vec3 around the X axis
|
|
576
577
|
*
|
|
577
578
|
* @param {Vec3} v the vector to rotate
|
|
578
579
|
* @param {Number} rad the angle of rotation in radians
|
|
579
|
-
* @param {Vec3} origin the origin of the rotation, defaults to vec3(0)
|
|
580
|
+
* @param {Vec3} origin the origin of the rotation, defaults to vec3(0, 0, 0)
|
|
580
581
|
* @returns {Vec3} a new rotated vector
|
|
581
582
|
*/
|
|
582
|
-
static rotateX(v: Vec3, rad: number, origin: Vec3 =
|
|
583
|
+
static rotateX(v: Vec3, rad: number, origin: Vec3 = vec3.zero, out = vec3()): Vec3 {
|
|
583
584
|
const p1 = v[1] - origin[1]
|
|
584
585
|
const p2 = v[2] - origin[2]
|
|
585
586
|
out[0] = v[0]
|
|
@@ -587,14 +588,15 @@ export class Vec3 extends Float32Array {
|
|
|
587
588
|
out[2] = p1 * Math.sin(rad) + p2 * Math.cos(rad) + origin[2]
|
|
588
589
|
return out
|
|
589
590
|
}
|
|
591
|
+
|
|
590
592
|
/**
|
|
591
|
-
* Rotates
|
|
593
|
+
* Rotates vec3 around the X axis
|
|
592
594
|
*
|
|
593
595
|
* @param {Number} rad the angle of rotation in radians
|
|
594
|
-
* @param {Vec3} origin the origin of the rotation, defaults to vec3(0)
|
|
596
|
+
* @param {Vec3} origin the origin of the rotation, defaults to vec3(0, 0, 0)
|
|
595
597
|
* @returns {Vec3} a rotated vector
|
|
596
598
|
*/
|
|
597
|
-
rotateX(rad: number, origin: Vec3 =
|
|
599
|
+
rotateX(rad: number, origin: Vec3 = vec3.zero, out = glmaths.ALWAYS_COPY ? vec3() : this): Vec3 {
|
|
598
600
|
const p1 = this[1] - origin[1]
|
|
599
601
|
const p2 = this[2] - origin[2]
|
|
600
602
|
out[0] = this[0]
|
|
@@ -602,15 +604,16 @@ export class Vec3 extends Float32Array {
|
|
|
602
604
|
out[2] = p1 * Math.sin(rad) + p2 * Math.cos(rad) + origin[2]
|
|
603
605
|
return out
|
|
604
606
|
}
|
|
607
|
+
|
|
605
608
|
/**
|
|
606
|
-
* Rotates
|
|
609
|
+
* Rotates vec3 around the Y axis
|
|
607
610
|
*
|
|
608
611
|
* @param {Vec3} v the vector to rotate
|
|
609
612
|
* @param {Number} rad the angle of rotation in radians
|
|
610
|
-
* @param {Vec3} origin the origin of the rotation, defaults to vec3(0)
|
|
613
|
+
* @param {Vec3} origin the origin of the rotation, defaults to vec3(0, 0, 0)
|
|
611
614
|
* @returns {Vec3} a rotated vector
|
|
612
615
|
*/
|
|
613
|
-
static rotateY(v: Vec3, rad: number, origin: Vec3 =
|
|
616
|
+
static rotateY(v: Vec3, rad: number, origin: Vec3 = vec3.zero, out = vec3()): Vec3 {
|
|
614
617
|
const p0 = v[0] - origin[0]
|
|
615
618
|
const p2 = v[2] - origin[2]
|
|
616
619
|
out[0] = p2 * Math.sin(rad) + p0 * Math.cos(rad) + origin[0]
|
|
@@ -618,13 +621,14 @@ export class Vec3 extends Float32Array {
|
|
|
618
621
|
out[2] = p2 * Math.cos(rad) - p0 * Math.sin(rad) + origin[2]
|
|
619
622
|
return out
|
|
620
623
|
}
|
|
624
|
+
|
|
621
625
|
/**
|
|
622
|
-
* Rotates
|
|
626
|
+
* Rotates vec3 around the Y axis
|
|
623
627
|
*
|
|
624
628
|
* @param {Number} rad the angle of rotation in radians
|
|
625
|
-
* @param {Vec3} origin the origin of the rotation, defaults to vec3(0)
|
|
629
|
+
* @param {Vec3} origin the origin of the rotation, defaults to vec3(0, 0, 0)
|
|
626
630
|
*/
|
|
627
|
-
rotateY(rad: number, origin: Vec3 =
|
|
631
|
+
rotateY(rad: number, origin: Vec3 = vec3.zero, out = glmaths.ALWAYS_COPY ? vec3() : this) : Vec3 {
|
|
628
632
|
const p0 = this[0] - origin[0]
|
|
629
633
|
const p2 = this[2] - origin[2]
|
|
630
634
|
out[0] = p2 * Math.sin(rad) + p0 * Math.cos(rad) + origin[0]
|
|
@@ -633,14 +637,14 @@ export class Vec3 extends Float32Array {
|
|
|
633
637
|
return out
|
|
634
638
|
}
|
|
635
639
|
/**
|
|
636
|
-
* Rotates
|
|
640
|
+
* Rotates vec3 around the Z axis
|
|
637
641
|
*
|
|
638
642
|
* @param {Vec3} v the vector to rotate
|
|
639
643
|
* @param {Number} rad the angle of rotation in radians
|
|
640
644
|
* @param {Vec3} origin the origin of the rotation, defaults to ZERO
|
|
641
645
|
* @returns {Vec3} a new rotated vector
|
|
642
646
|
*/
|
|
643
|
-
static rotateZ(v: Vec3, rad: number, origin: Vec3 =
|
|
647
|
+
static rotateZ(v: Vec3, rad: number, origin: Vec3 = vec3.zero, out = vec3()) {
|
|
644
648
|
const p0 = v[0] - origin[0]
|
|
645
649
|
const p1 = v[1] - origin[1]
|
|
646
650
|
out[0] = p0 * Math.cos(rad) - p1 * Math.sin(rad) + origin[0]
|
|
@@ -649,12 +653,12 @@ export class Vec3 extends Float32Array {
|
|
|
649
653
|
return out
|
|
650
654
|
}
|
|
651
655
|
/**
|
|
652
|
-
* Rotates
|
|
656
|
+
* Rotates vec3 around the Z axis
|
|
653
657
|
*
|
|
654
658
|
* @param {Number} rad the angle of rotation in radians
|
|
655
|
-
* @param {Vec3} origin the origin of the rotation, defaults to vec3(0)
|
|
659
|
+
* @param {Vec3} origin the origin of the rotation, defaults to vec3(0, 0, 0)
|
|
656
660
|
*/
|
|
657
|
-
rotateZ(rad: number, origin: Vec3 =
|
|
661
|
+
rotateZ(rad: number, origin: Vec3 = vec3.zero, out = glmaths.ALWAYS_COPY ? vec3() : this) : Vec3 {
|
|
658
662
|
const p0 = this[0] - origin[0]
|
|
659
663
|
const p1 = this[1] - origin[1]
|
|
660
664
|
out[0] = p0 * Math.cos(rad) - p1 * Math.sin(rad) + origin[0]
|
|
@@ -673,7 +677,7 @@ export class Vec3 extends Float32Array {
|
|
|
673
677
|
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
|
|
674
678
|
* @returns {Vec3} a new vector
|
|
675
679
|
*/
|
|
676
|
-
static hermite(a: Vec3, b: Vec3, c: Vec3, d: Vec3, t: number, out =
|
|
680
|
+
static hermite(a: Vec3, b: Vec3, c: Vec3, d: Vec3, t: number, out = vec3()) {
|
|
677
681
|
const factorTimes2 = t * t
|
|
678
682
|
const factor1 = factorTimes2 * (2 * t - 3) + 1
|
|
679
683
|
const factor2 = factorTimes2 * (t - 2) + t
|
|
@@ -684,6 +688,7 @@ export class Vec3 extends Float32Array {
|
|
|
684
688
|
out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4
|
|
685
689
|
return out
|
|
686
690
|
}
|
|
691
|
+
|
|
687
692
|
/**
|
|
688
693
|
* Performs a bezier interpolation with two control points
|
|
689
694
|
*
|
|
@@ -694,7 +699,7 @@ export class Vec3 extends Float32Array {
|
|
|
694
699
|
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
|
|
695
700
|
* @returns {Vec3} a new vector
|
|
696
701
|
*/
|
|
697
|
-
static bezier(a: Vec3, b: Vec3, c: Vec3, d: Vec3, t: number, out =
|
|
702
|
+
static bezier(a: Vec3, b: Vec3, c: Vec3, d: Vec3, t: number, out = vec3()) {
|
|
698
703
|
const inverseFactor = 1 - t
|
|
699
704
|
const inverseFactorTimesTwo = inverseFactor * inverseFactor
|
|
700
705
|
const factorTimes2 = t * t
|
|
@@ -714,38 +719,40 @@ export class Vec3 extends Float32Array {
|
|
|
714
719
|
* @param {Vec3} a the first operand
|
|
715
720
|
* @param {Vec3} b the second operand
|
|
716
721
|
* @param {Number} scale the amount to scale b by before adding
|
|
717
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
722
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3
|
|
718
723
|
* @returns {Vec3} out
|
|
719
724
|
*/
|
|
720
|
-
static scaleAndAdd(a: Vec3, b: Vec3, scale: number, out =
|
|
725
|
+
static scaleAndAdd(a: Vec3, b: Vec3, scale: number, out = vec3()) {
|
|
721
726
|
out[0] = a[0] + b[0] * scale
|
|
722
727
|
out[1] = a[1] + b[1] * scale
|
|
723
728
|
out[2] = a[2] + b[2] * scale
|
|
724
729
|
return out
|
|
725
730
|
}
|
|
731
|
+
|
|
726
732
|
/**
|
|
727
733
|
* Reflects a vector off a surface with the given normal
|
|
728
734
|
*
|
|
729
735
|
* @param {Vec3} I the incident vector
|
|
730
736
|
* @param {Vec3} N the surface normal
|
|
731
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
737
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3
|
|
732
738
|
* @returns {Vec3} out
|
|
733
739
|
*/
|
|
734
|
-
static reflect(I: Vec3, N: Vec3, out =
|
|
740
|
+
static reflect(I: Vec3, N: Vec3, out = vec3()) {
|
|
735
741
|
const d = Vec3.dot(N, I) * 2
|
|
736
742
|
out[0] = I[0] - d * N[0]; out[1] = I[1] - d * N[1]; out[2] = I[2] - d * N[2]
|
|
737
743
|
return out
|
|
738
744
|
}
|
|
745
|
+
|
|
739
746
|
/**
|
|
740
747
|
* Refracts a vector through a surface with the given normal and index of refraction ratio (Snell's law)
|
|
741
748
|
*
|
|
742
749
|
* @param {Vec3} I the incident vector
|
|
743
750
|
* @param {Vec3} N the surface normal
|
|
744
751
|
* @param {Number} eta the ratio of indices of refraction
|
|
745
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
752
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3
|
|
746
753
|
* @returns {Vec3} out
|
|
747
754
|
*/
|
|
748
|
-
static refract(I: Vec3, N: Vec3, eta: number, out =
|
|
755
|
+
static refract(I: Vec3, N: Vec3, eta: number, out = vec3()) {
|
|
749
756
|
const d = Vec3.dot(N, I)
|
|
750
757
|
const k = 1.0 - eta * eta * (1.0 - d * d)
|
|
751
758
|
if (k < 0.0) { out[0] = out[1] = out[2] = 0; return out }
|
|
@@ -755,31 +762,33 @@ export class Vec3 extends Float32Array {
|
|
|
755
762
|
out[2] = eta * I[2] - f * N[2]
|
|
756
763
|
return out
|
|
757
764
|
}
|
|
765
|
+
|
|
758
766
|
/**
|
|
759
767
|
* Returns a vector pointing in the same direction as another, based on the dot product with a reference
|
|
760
768
|
*
|
|
761
769
|
* @param {Vec3} N the vector to orient
|
|
762
770
|
* @param {Vec3} I the incident vector
|
|
763
771
|
* @param {Vec3} Nref the reference vector
|
|
764
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
772
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3
|
|
765
773
|
* @returns {Vec3} out
|
|
766
774
|
*/
|
|
767
|
-
static faceforward(N: Vec3, I: Vec3, Nref: Vec3, out =
|
|
775
|
+
static faceforward(N: Vec3, I: Vec3, Nref: Vec3, out = vec3()) {
|
|
768
776
|
const d = Vec3.dot(Nref, I)
|
|
769
777
|
const sign = d < 0 ? 1 : -1
|
|
770
778
|
out[0] = N[0] * sign; out[1] = N[1] * sign; out[2] = N[2] * sign
|
|
771
779
|
return out
|
|
772
780
|
}
|
|
781
|
+
|
|
773
782
|
/**
|
|
774
783
|
* Computes the normalized normal of a triangle defined by three points
|
|
775
784
|
*
|
|
776
785
|
* @param {Vec3} p1 the first vertex
|
|
777
786
|
* @param {Vec3} p2 the second vertex
|
|
778
787
|
* @param {Vec3} p3 the third vertex
|
|
779
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
788
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3
|
|
780
789
|
* @returns {Vec3} out
|
|
781
790
|
*/
|
|
782
|
-
static triangleNormal(p1: Vec3, p2: Vec3, p3: Vec3, out =
|
|
791
|
+
static triangleNormal(p1: Vec3, p2: Vec3, p3: Vec3, out = vec3()) {
|
|
783
792
|
const e1x = p2[0]-p1[0], e1y = p2[1]-p1[1], e1z = p2[2]-p1[2]
|
|
784
793
|
const e2x = p3[0]-p1[0], e2y = p3[1]-p1[1], e2z = p3[2]-p1[2]
|
|
785
794
|
out[0] = e1y*e2z - e1z*e2y; out[1] = e1z*e2x - e1x*e2z; out[2] = e1x*e2y - e1y*e2x
|
|
@@ -787,19 +796,21 @@ export class Vec3 extends Float32Array {
|
|
|
787
796
|
if (len > 0) { len = 1/Math.sqrt(len); out[0]*=len; out[1]*=len; out[2]*=len }
|
|
788
797
|
return out
|
|
789
798
|
}
|
|
799
|
+
|
|
790
800
|
/**
|
|
791
801
|
* Projects vector a onto vector b
|
|
792
802
|
*
|
|
793
803
|
* @param {Vec3} a the vector to project
|
|
794
804
|
* @param {Vec3} b the vector to project onto
|
|
795
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
805
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3
|
|
796
806
|
* @returns {Vec3} out
|
|
797
807
|
*/
|
|
798
|
-
static project(a: Vec3, b: Vec3, out =
|
|
808
|
+
static project(a: Vec3, b: Vec3, out = vec3()) {
|
|
799
809
|
const d = Vec3.dot(a, b) / Vec3.dot(b, b)
|
|
800
810
|
out[0] = b[0] * d; out[1] = b[1] * d; out[2] = b[2] * d
|
|
801
811
|
return out
|
|
802
812
|
}
|
|
813
|
+
|
|
803
814
|
/**
|
|
804
815
|
* Returns the signed angle between two vec3's, using a reference axis to determine sign
|
|
805
816
|
*
|
|
@@ -819,36 +830,38 @@ export class Vec3 extends Float32Array {
|
|
|
819
830
|
*
|
|
820
831
|
* @param {Vec3} b the second operand
|
|
821
832
|
* @param {Number} scale the amount to scale b by before adding
|
|
822
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
833
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3()
|
|
823
834
|
* @returns {Vec3} out
|
|
824
835
|
*/
|
|
825
|
-
scaleAndAdd(b: Vec3, scale: number, out = glmaths.ALWAYS_COPY ?
|
|
836
|
+
scaleAndAdd(b: Vec3, scale: number, out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
826
837
|
out[0] = this[0] + b[0] * scale
|
|
827
838
|
out[1] = this[1] + b[1] * scale
|
|
828
839
|
out[2] = this[2] + b[2] * scale
|
|
829
840
|
return out
|
|
830
841
|
}
|
|
842
|
+
|
|
831
843
|
/**
|
|
832
|
-
* Returns
|
|
844
|
+
* Returns vec3 with each component set to its absolute value
|
|
833
845
|
*
|
|
834
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
846
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3()
|
|
835
847
|
* @returns {Vec3} out
|
|
836
848
|
*/
|
|
837
|
-
abs(out = glmaths.ALWAYS_COPY ?
|
|
849
|
+
abs(out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
838
850
|
out[0] = Math.abs(this[0])
|
|
839
851
|
out[1] = Math.abs(this[1])
|
|
840
852
|
out[2] = Math.abs(this[2])
|
|
841
853
|
return out
|
|
842
854
|
}
|
|
855
|
+
|
|
843
856
|
/**
|
|
844
857
|
* Clamps each component of this vector between min and max.
|
|
845
858
|
*
|
|
846
859
|
* @param {Vec3 | number} min the lower bound (per-component or scalar)
|
|
847
860
|
* @param {Vec3 | number} max the upper bound (per-component or scalar)
|
|
848
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
861
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3()
|
|
849
862
|
* @returns {Vec3} out
|
|
850
863
|
*/
|
|
851
|
-
clamp(min: Vec3 | number, max: Vec3 | number, out = glmaths.ALWAYS_COPY ?
|
|
864
|
+
clamp(min: Vec3 | number, max: Vec3 | number, out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
852
865
|
const minX = typeof min === 'number' ? min : min[0]
|
|
853
866
|
const minY = typeof min === 'number' ? min : min[1]
|
|
854
867
|
const minZ = typeof min === 'number' ? min : min[2]
|
|
@@ -860,15 +873,16 @@ export class Vec3 extends Float32Array {
|
|
|
860
873
|
out[2] = Math.min(Math.max(this[2], minZ), maxZ)
|
|
861
874
|
return out
|
|
862
875
|
}
|
|
876
|
+
|
|
863
877
|
/**
|
|
864
878
|
* Performs a linear interpolation between this vector and b.
|
|
865
879
|
*
|
|
866
880
|
* @param {Vec3} b the second operand
|
|
867
881
|
* @param {Vec3 | number} t interpolation amount (per-component or scalar)
|
|
868
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
882
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3()
|
|
869
883
|
* @returns {Vec3} out
|
|
870
884
|
*/
|
|
871
|
-
mix(b: Vec3, t: Vec3 | number, out = glmaths.ALWAYS_COPY ?
|
|
885
|
+
mix(b: Vec3, t: Vec3 | number, out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
872
886
|
if (typeof t === 'number') {
|
|
873
887
|
out[0] = this[0] + (b[0] - this[0]) * t
|
|
874
888
|
out[1] = this[1] + (b[1] - this[1]) * t
|
|
@@ -880,14 +894,15 @@ export class Vec3 extends Float32Array {
|
|
|
880
894
|
}
|
|
881
895
|
return out
|
|
882
896
|
}
|
|
897
|
+
|
|
883
898
|
/**
|
|
884
899
|
* Generates a step function by comparing this vector to edge.
|
|
885
900
|
*
|
|
886
901
|
* @param {Vec3 | number} edge the edge value (per-component or scalar)
|
|
887
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
902
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3()
|
|
888
903
|
* @returns {Vec3} out
|
|
889
904
|
*/
|
|
890
|
-
step(edge: Vec3 | number, out = glmaths.ALWAYS_COPY ?
|
|
905
|
+
step(edge: Vec3 | number, out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
891
906
|
if (typeof edge === 'number') {
|
|
892
907
|
out[0] = this[0] < edge ? 0 : 1
|
|
893
908
|
out[1] = this[1] < edge ? 0 : 1
|
|
@@ -899,15 +914,16 @@ export class Vec3 extends Float32Array {
|
|
|
899
914
|
}
|
|
900
915
|
return out
|
|
901
916
|
}
|
|
917
|
+
|
|
902
918
|
/**
|
|
903
919
|
* Performs Hermite interpolation between two values (smoothstep).
|
|
904
920
|
*
|
|
905
921
|
* @param {Vec3 | number} edge0 the lower edge (per-component or scalar)
|
|
906
922
|
* @param {Vec3 | number} edge1 the upper edge (per-component or scalar)
|
|
907
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
923
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3()
|
|
908
924
|
* @returns {Vec3} out
|
|
909
925
|
*/
|
|
910
|
-
smoothstep(edge0: Vec3 | number, edge1: Vec3 | number, out = glmaths.ALWAYS_COPY ?
|
|
926
|
+
smoothstep(edge0: Vec3 | number, edge1: Vec3 | number, out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
911
927
|
const e0x = typeof edge0 === 'number' ? edge0 : edge0[0]
|
|
912
928
|
const e0y = typeof edge0 === 'number' ? edge0 : edge0[1]
|
|
913
929
|
const e0z = typeof edge0 === 'number' ? edge0 : edge0[2]
|
|
@@ -922,50 +938,54 @@ export class Vec3 extends Float32Array {
|
|
|
922
938
|
out[2] = t2 * t2 * (3 - 2 * t2)
|
|
923
939
|
return out
|
|
924
940
|
}
|
|
941
|
+
|
|
925
942
|
/**
|
|
926
943
|
* Returns the fractional part of each component.
|
|
927
944
|
*
|
|
928
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
945
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3()
|
|
929
946
|
* @returns {Vec3} out
|
|
930
947
|
*/
|
|
931
|
-
fract(out = glmaths.ALWAYS_COPY ?
|
|
948
|
+
fract(out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
932
949
|
out[0] = this[0] - Math.floor(this[0])
|
|
933
950
|
out[1] = this[1] - Math.floor(this[1])
|
|
934
951
|
out[2] = this[2] - Math.floor(this[2])
|
|
935
952
|
return out
|
|
936
953
|
}
|
|
954
|
+
|
|
937
955
|
/**
|
|
938
956
|
* Returns the sign of each component (-1, 0, or 1).
|
|
939
957
|
*
|
|
940
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
958
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3()
|
|
941
959
|
* @returns {Vec3} out
|
|
942
960
|
*/
|
|
943
|
-
sign(out = glmaths.ALWAYS_COPY ?
|
|
961
|
+
sign(out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
944
962
|
out[0] = this[0] > 0 ? 1 : this[0] < 0 ? -1 : 0
|
|
945
963
|
out[1] = this[1] > 0 ? 1 : this[1] < 0 ? -1 : 0
|
|
946
964
|
out[2] = this[2] > 0 ? 1 : this[2] < 0 ? -1 : 0
|
|
947
965
|
return out
|
|
948
966
|
}
|
|
967
|
+
|
|
949
968
|
/**
|
|
950
969
|
* Clamps each component to [0, 1].
|
|
951
970
|
*
|
|
952
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
971
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3()
|
|
953
972
|
* @returns {Vec3} out
|
|
954
973
|
*/
|
|
955
|
-
saturate(out = glmaths.ALWAYS_COPY ?
|
|
974
|
+
saturate(out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
956
975
|
out[0] = Math.min(Math.max(this[0], 0), 1)
|
|
957
976
|
out[1] = Math.min(Math.max(this[1], 0), 1)
|
|
958
977
|
out[2] = Math.min(Math.max(this[2], 0), 1)
|
|
959
978
|
return out
|
|
960
979
|
}
|
|
980
|
+
|
|
961
981
|
/**
|
|
962
982
|
* Transforms this vec3 with a Mat3
|
|
963
983
|
*
|
|
964
984
|
* @param {Mat3} m the 3x3 matrix to transform with
|
|
965
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
985
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3()
|
|
966
986
|
* @returns {Vec3} out
|
|
967
987
|
*/
|
|
968
|
-
transformMat3(m: Mat3, out = glmaths.ALWAYS_COPY ?
|
|
988
|
+
transformMat3(m: Mat3, out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
969
989
|
const x = this[0], y = this[1], z = this[2]
|
|
970
990
|
out[0] = x * m[0] + y * m[3] + z * m[6]
|
|
971
991
|
out[1] = x * m[1] + y * m[4] + z * m[7]
|
|
@@ -977,10 +997,10 @@ export class Vec3 extends Float32Array {
|
|
|
977
997
|
* Transforms this vec3 with a Mat4 (as a point, w=1)
|
|
978
998
|
*
|
|
979
999
|
* @param {Mat4} m the 4x4 matrix to transform with
|
|
980
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
1000
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3()
|
|
981
1001
|
* @returns {Vec3} out
|
|
982
1002
|
*/
|
|
983
|
-
transformMat4(m: Mat4, out = glmaths.ALWAYS_COPY ?
|
|
1003
|
+
transformMat4(m: Mat4, out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
984
1004
|
const x = this[0], y = this[1], z = this[2]
|
|
985
1005
|
let w = m[3] * x + m[7] * y + m[11] * z + m[15]
|
|
986
1006
|
w = w || 1.0
|
|
@@ -994,10 +1014,10 @@ export class Vec3 extends Float32Array {
|
|
|
994
1014
|
* Transforms this vec3 with a quaternion
|
|
995
1015
|
*
|
|
996
1016
|
* @param {Quat} q the quaternion to transform with
|
|
997
|
-
* @param {Vec3} out the receiving vector, defaults to
|
|
1017
|
+
* @param {Vec3} out the receiving vector, defaults to new vec3()
|
|
998
1018
|
* @returns {Vec3} out
|
|
999
1019
|
*/
|
|
1000
|
-
transformQuat(q: Quat, out = glmaths.ALWAYS_COPY ?
|
|
1020
|
+
transformQuat(q: Quat, out = glmaths.ALWAYS_COPY ? vec3() : this) {
|
|
1001
1021
|
const qx = q[0], qy = q[1], qz = q[2], qw = q[3]
|
|
1002
1022
|
const x = this[0], y = this[1], z = this[2]
|
|
1003
1023
|
let uvx = qy * z - qz * y, uvy = qz * x - qx * z, uvz = qx * y - qy * x
|
|
@@ -1028,6 +1048,7 @@ export interface Vec3 {
|
|
|
1028
1048
|
str: () => string
|
|
1029
1049
|
transformMat3x3: (m: Mat3, out?: Vec3) => Vec3
|
|
1030
1050
|
transformMat4x4: (m: Mat4, out?: Vec3) => Vec3
|
|
1051
|
+
normalized: (out?: Vec3) => Vec3
|
|
1031
1052
|
|
|
1032
1053
|
// Auto-generated
|
|
1033
1054
|
x0: Vec2; x1: Vec2; xx: Vec2; xy: Vec2; y0: Vec2; y1: Vec2; yx: Vec2; yy: Vec2; x00: Vec3; x01: Vec3; x0x: Vec3; x0y: Vec3; x0z: Vec3; x10: Vec3; x11: Vec3; x1x: Vec3; x1y: Vec3; x1z: Vec3; xx0: Vec3; xx1: Vec3; xxx: Vec3; xxy: Vec3; xxz: Vec3; xy0: Vec3; xy1: Vec3; xyx: Vec3; xyy: Vec3; xyz: Vec3; xz0: Vec3; xz1: Vec3; xzx: Vec3; xzy: Vec3; xzz: Vec3; y00: Vec3; y01: Vec3; y0x: Vec3; y0y: Vec3; y0z: Vec3; y10: Vec3; y11: Vec3; y1x: Vec3; y1y: Vec3; y1z: Vec3; yx0: Vec3; yx1: Vec3; yxx: Vec3; yxy: Vec3; yxz: Vec3; yy0: Vec3; yy1: Vec3; yyx: Vec3; yyy: Vec3; yyz: Vec3; yz0: Vec3; yz1: Vec3; yzx: Vec3; yzy: Vec3; yzz: Vec3; z00: Vec3; z01: Vec3; z0x: Vec3; z0y: Vec3; z0z: Vec3; z10: Vec3; z11: Vec3; z1x: Vec3; z1y: Vec3; z1z: Vec3; zx0: Vec3; zx1: Vec3; zxx: Vec3; zxy: Vec3; zxz: Vec3; zy0: Vec3; zy1: Vec3; zyx: Vec3; zyy: Vec3; zyz: Vec3; zz0: Vec3; zz1: Vec3; zzx: Vec3; zzy: Vec3; zzz: Vec3; x000: Vec4; x001: Vec4; x00x: Vec4; x00y: Vec4; x00z: Vec4; x00w: Vec4; x010: Vec4; x011: Vec4; x01x: Vec4; x01y: Vec4; x01z: Vec4; x01w: Vec4; x0x0: Vec4; x0x1: Vec4; x0xx: Vec4; x0xy: Vec4; x0xz: Vec4; x0xw: Vec4; x0y0: Vec4; x0y1: Vec4; x0yx: Vec4; x0yy: Vec4; x0yz: Vec4; x0yw: Vec4; x0z0: Vec4; x0z1: Vec4; x0zx: Vec4; x0zy: Vec4; x0zz: Vec4; x0zw: Vec4; x0w0: Vec4; x0w1: Vec4; x0wx: Vec4; x0wy: Vec4; x0wz: Vec4; x0ww: Vec4; x100: Vec4; x101: Vec4; x10x: Vec4; x10y: Vec4; x10z: Vec4; x10w: Vec4; x110: Vec4; x111: Vec4; x11x: Vec4; x11y: Vec4; x11z: Vec4; x11w: Vec4; x1x0: Vec4; x1x1: Vec4; x1xx: Vec4; x1xy: Vec4; x1xz: Vec4; x1xw: Vec4; x1y0: Vec4; x1y1: Vec4; x1yx: Vec4; x1yy: Vec4; x1yz: Vec4; x1yw: Vec4; x1z0: Vec4; x1z1: Vec4; x1zx: Vec4; x1zy: Vec4; x1zz: Vec4; x1zw: Vec4; x1w0: Vec4; x1w1: Vec4; x1wx: Vec4; x1wy: Vec4; x1wz: Vec4; x1ww: Vec4; xx00: Vec4; xx01: Vec4; xx0x: Vec4; xx0y: Vec4; xx0z: Vec4; xx0w: Vec4; xx10: Vec4; xx11: Vec4; xx1x: Vec4; xx1y: Vec4; xx1z: Vec4; xx1w: Vec4; xxx0: Vec4; xxx1: Vec4; xxxx: Vec4; xxxy: Vec4; xxxz: Vec4; xxxw: Vec4; xxy0: Vec4; xxy1: Vec4; xxyx: Vec4; xxyy: Vec4; xxyz: Vec4; xxyw: Vec4; xxz0: Vec4; xxz1: Vec4; xxzx: Vec4; xxzy: Vec4; xxzz: Vec4; xxzw: Vec4; xxw0: Vec4; xxw1: Vec4; xxwx: Vec4; xxwy: Vec4; xxwz: Vec4; xxww: Vec4; xy00: Vec4; xy01: Vec4; xy0x: Vec4; xy0y: Vec4; xy0z: Vec4; xy0w: Vec4; xy10: Vec4; xy11: Vec4; xy1x: Vec4; xy1y: Vec4; xy1z: Vec4; xy1w: Vec4; xyx0: Vec4; xyx1: Vec4; xyxx: Vec4; xyxy: Vec4; xyxz: Vec4; xyxw: Vec4; xyy0: Vec4; xyy1: Vec4; xyyx: Vec4; xyyy: Vec4; xyyz: Vec4; xyyw: Vec4; xyz0: Vec4; xyz1: Vec4; xyzx: Vec4; xyzy: Vec4; xyzz: Vec4; xyzw: Vec4; xyw0: Vec4; xyw1: Vec4; xywx: Vec4; xywy: Vec4; xywz: Vec4; xyww: Vec4; xz00: Vec4; xz01: Vec4; xz0x: Vec4; xz0y: Vec4; xz0z: Vec4; xz0w: Vec4; xz10: Vec4; xz11: Vec4; xz1x: Vec4; xz1y: Vec4; xz1z: Vec4; xz1w: Vec4; xzx0: Vec4; xzx1: Vec4; xzxx: Vec4; xzxy: Vec4; xzxz: Vec4; xzxw: Vec4; xzy0: Vec4; xzy1: Vec4; xzyx: Vec4; xzyy: Vec4; xzyz: Vec4; xzyw: Vec4; xzz0: Vec4; xzz1: Vec4; xzzx: Vec4; xzzy: Vec4; xzzz: Vec4; xzzw: Vec4; xzw0: Vec4; xzw1: Vec4; xzwx: Vec4; xzwy: Vec4; xzwz: Vec4; xzww: Vec4; xw00: Vec4; xw01: Vec4; xw0x: Vec4; xw0y: Vec4; xw0z: Vec4; xw0w: Vec4; xw10: Vec4; xw11: Vec4; xw1x: Vec4; xw1y: Vec4; xw1z: Vec4; xw1w: Vec4; xwx0: Vec4; xwx1: Vec4; xwxx: Vec4; xwxy: Vec4; xwxz: Vec4; xwxw: Vec4; xwy0: Vec4; xwy1: Vec4; xwyx: Vec4; xwyy: Vec4; xwyz: Vec4; xwyw: Vec4; xwz0: Vec4; xwz1: Vec4; xwzx: Vec4; xwzy: Vec4; xwzz: Vec4; xwzw: Vec4; xww0: Vec4; xww1: Vec4; xwwx: Vec4; xwwy: Vec4; xwwz: Vec4; xwww: Vec4; y000: Vec4; y001: Vec4; y00x: Vec4; y00y: Vec4; y00z: Vec4; y00w: Vec4; y010: Vec4; y011: Vec4; y01x: Vec4; y01y: Vec4; y01z: Vec4; y01w: Vec4; y0x0: Vec4; y0x1: Vec4; y0xx: Vec4; y0xy: Vec4; y0xz: Vec4; y0xw: Vec4; y0y0: Vec4; y0y1: Vec4; y0yx: Vec4; y0yy: Vec4; y0yz: Vec4; y0yw: Vec4; y0z0: Vec4; y0z1: Vec4; y0zx: Vec4; y0zy: Vec4; y0zz: Vec4; y0zw: Vec4; y0w0: Vec4; y0w1: Vec4; y0wx: Vec4; y0wy: Vec4; y0wz: Vec4; y0ww: Vec4; y100: Vec4; y101: Vec4; y10x: Vec4; y10y: Vec4; y10z: Vec4; y10w: Vec4; y110: Vec4; y111: Vec4; y11x: Vec4; y11y: Vec4; y11z: Vec4; y11w: Vec4; y1x0: Vec4; y1x1: Vec4; y1xx: Vec4; y1xy: Vec4; y1xz: Vec4; y1xw: Vec4; y1y0: Vec4; y1y1: Vec4; y1yx: Vec4; y1yy: Vec4; y1yz: Vec4; y1yw: Vec4; y1z0: Vec4; y1z1: Vec4; y1zx: Vec4; y1zy: Vec4; y1zz: Vec4; y1zw: Vec4; y1w0: Vec4; y1w1: Vec4; y1wx: Vec4; y1wy: Vec4; y1wz: Vec4; y1ww: Vec4; yx00: Vec4; yx01: Vec4; yx0x: Vec4; yx0y: Vec4; yx0z: Vec4; yx0w: Vec4; yx10: Vec4; yx11: Vec4; yx1x: Vec4; yx1y: Vec4; yx1z: Vec4; yx1w: Vec4; yxx0: Vec4; yxx1: Vec4; yxxx: Vec4; yxxy: Vec4; yxxz: Vec4; yxxw: Vec4; yxy0: Vec4; yxy1: Vec4; yxyx: Vec4; yxyy: Vec4; yxyz: Vec4; yxyw: Vec4; yxz0: Vec4; yxz1: Vec4; yxzx: Vec4; yxzy: Vec4; yxzz: Vec4; yxzw: Vec4; yxw0: Vec4; yxw1: Vec4; yxwx: Vec4; yxwy: Vec4; yxwz: Vec4; yxww: Vec4; yy00: Vec4; yy01: Vec4; yy0x: Vec4; yy0y: Vec4; yy0z: Vec4; yy0w: Vec4; yy10: Vec4; yy11: Vec4; yy1x: Vec4; yy1y: Vec4; yy1z: Vec4; yy1w: Vec4; yyx0: Vec4; yyx1: Vec4; yyxx: Vec4; yyxy: Vec4; yyxz: Vec4; yyxw: Vec4; yyy0: Vec4; yyy1: Vec4; yyyx: Vec4; yyyy: Vec4; yyyz: Vec4; yyyw: Vec4; yyz0: Vec4; yyz1: Vec4; yyzx: Vec4; yyzy: Vec4; yyzz: Vec4; yyzw: Vec4; yyw0: Vec4; yyw1: Vec4; yywx: Vec4; yywy: Vec4; yywz: Vec4; yyww: Vec4; yz00: Vec4; yz01: Vec4; yz0x: Vec4; yz0y: Vec4; yz0z: Vec4; yz0w: Vec4; yz10: Vec4; yz11: Vec4; yz1x: Vec4; yz1y: Vec4; yz1z: Vec4; yz1w: Vec4; yzx0: Vec4; yzx1: Vec4; yzxx: Vec4; yzxy: Vec4; yzxz: Vec4; yzxw: Vec4; yzy0: Vec4; yzy1: Vec4; yzyx: Vec4; yzyy: Vec4; yzyz: Vec4; yzyw: Vec4; yzz0: Vec4; yzz1: Vec4; yzzx: Vec4; yzzy: Vec4; yzzz: Vec4; yzzw: Vec4; yzw0: Vec4; yzw1: Vec4; yzwx: Vec4; yzwy: Vec4; yzwz: Vec4; yzww: Vec4; yw00: Vec4; yw01: Vec4; yw0x: Vec4; yw0y: Vec4; yw0z: Vec4; yw0w: Vec4; yw10: Vec4; yw11: Vec4; yw1x: Vec4; yw1y: Vec4; yw1z: Vec4; yw1w: Vec4; ywx0: Vec4; ywx1: Vec4; ywxx: Vec4; ywxy: Vec4; ywxz: Vec4; ywxw: Vec4; ywy0: Vec4; ywy1: Vec4; ywyx: Vec4; ywyy: Vec4; ywyz: Vec4; ywyw: Vec4; ywz0: Vec4; ywz1: Vec4; ywzx: Vec4; ywzy: Vec4; ywzz: Vec4; ywzw: Vec4; yww0: Vec4; yww1: Vec4; ywwx: Vec4; ywwy: Vec4; ywwz: Vec4; ywww: Vec4; z000: Vec4; z001: Vec4; z00x: Vec4; z00y: Vec4; z00z: Vec4; z00w: Vec4; z010: Vec4; z011: Vec4; z01x: Vec4; z01y: Vec4; z01z: Vec4; z01w: Vec4; z0x0: Vec4; z0x1: Vec4; z0xx: Vec4; z0xy: Vec4; z0xz: Vec4; z0xw: Vec4; z0y0: Vec4; z0y1: Vec4; z0yx: Vec4; z0yy: Vec4; z0yz: Vec4; z0yw: Vec4; z0z0: Vec4; z0z1: Vec4; z0zx: Vec4; z0zy: Vec4; z0zz: Vec4; z0zw: Vec4; z0w0: Vec4; z0w1: Vec4; z0wx: Vec4; z0wy: Vec4; z0wz: Vec4; z0ww: Vec4; z100: Vec4; z101: Vec4; z10x: Vec4; z10y: Vec4; z10z: Vec4; z10w: Vec4; z110: Vec4; z111: Vec4; z11x: Vec4; z11y: Vec4; z11z: Vec4; z11w: Vec4; z1x0: Vec4; z1x1: Vec4; z1xx: Vec4; z1xy: Vec4; z1xz: Vec4; z1xw: Vec4; z1y0: Vec4; z1y1: Vec4; z1yx: Vec4; z1yy: Vec4; z1yz: Vec4; z1yw: Vec4; z1z0: Vec4; z1z1: Vec4; z1zx: Vec4; z1zy: Vec4; z1zz: Vec4; z1zw: Vec4; z1w0: Vec4; z1w1: Vec4; z1wx: Vec4; z1wy: Vec4; z1wz: Vec4; z1ww: Vec4; zx00: Vec4; zx01: Vec4; zx0x: Vec4; zx0y: Vec4; zx0z: Vec4; zx0w: Vec4; zx10: Vec4; zx11: Vec4; zx1x: Vec4; zx1y: Vec4; zx1z: Vec4; zx1w: Vec4; zxx0: Vec4; zxx1: Vec4; zxxx: Vec4; zxxy: Vec4; zxxz: Vec4; zxxw: Vec4; zxy0: Vec4; zxy1: Vec4; zxyx: Vec4; zxyy: Vec4; zxyz: Vec4; zxyw: Vec4; zxz0: Vec4; zxz1: Vec4; zxzx: Vec4; zxzy: Vec4; zxzz: Vec4; zxzw: Vec4; zxw0: Vec4; zxw1: Vec4; zxwx: Vec4; zxwy: Vec4; zxwz: Vec4; zxww: Vec4; zy00: Vec4; zy01: Vec4; zy0x: Vec4; zy0y: Vec4; zy0z: Vec4; zy0w: Vec4; zy10: Vec4; zy11: Vec4; zy1x: Vec4; zy1y: Vec4; zy1z: Vec4; zy1w: Vec4; zyx0: Vec4; zyx1: Vec4; zyxx: Vec4; zyxy: Vec4; zyxz: Vec4; zyxw: Vec4; zyy0: Vec4; zyy1: Vec4; zyyx: Vec4; zyyy: Vec4; zyyz: Vec4; zyyw: Vec4; zyz0: Vec4; zyz1: Vec4; zyzx: Vec4; zyzy: Vec4; zyzz: Vec4; zyzw: Vec4; zyw0: Vec4; zyw1: Vec4; zywx: Vec4; zywy: Vec4; zywz: Vec4; zyww: Vec4; zz00: Vec4; zz01: Vec4; zz0x: Vec4; zz0y: Vec4; zz0z: Vec4; zz0w: Vec4; zz10: Vec4; zz11: Vec4; zz1x: Vec4; zz1y: Vec4; zz1z: Vec4; zz1w: Vec4; zzx0: Vec4; zzx1: Vec4; zzxx: Vec4; zzxy: Vec4; zzxz: Vec4; zzxw: Vec4; zzy0: Vec4; zzy1: Vec4; zzyx: Vec4; zzyy: Vec4; zzyz: Vec4; zzyw: Vec4; zzz0: Vec4; zzz1: Vec4; zzzx: Vec4; zzzy: Vec4; zzzz: Vec4; zzzw: Vec4; zzw0: Vec4; zzw1: Vec4; zzwx: Vec4; zzwy: Vec4; zzwz: Vec4; zzww: Vec4; zw00: Vec4; zw01: Vec4; zw0x: Vec4; zw0y: Vec4; zw0z: Vec4; zw0w: Vec4; zw10: Vec4; zw11: Vec4; zw1x: Vec4; zw1y: Vec4; zw1z: Vec4; zw1w: Vec4; zwx0: Vec4; zwx1: Vec4; zwxx: Vec4; zwxy: Vec4; zwxz: Vec4; zwxw: Vec4; zwy0: Vec4; zwy1: Vec4; zwyx: Vec4; zwyy: Vec4; zwyz: Vec4; zwyw: Vec4; zwz0: Vec4; zwz1: Vec4; zwzx: Vec4; zwzy: Vec4; zwzz: Vec4; zwzw: Vec4; zww0: Vec4; zww1: Vec4; zwwx: Vec4; zwwy: Vec4; zwwz: Vec4; zwww: Vec4; w000: Vec4; w001: Vec4; w00x: Vec4; w00y: Vec4; w00z: Vec4; w00w: Vec4; w010: Vec4; w011: Vec4; w01x: Vec4; w01y: Vec4; w01z: Vec4; w01w: Vec4; w0x0: Vec4; w0x1: Vec4; w0xx: Vec4; w0xy: Vec4; w0xz: Vec4; w0xw: Vec4; w0y0: Vec4; w0y1: Vec4; w0yx: Vec4; w0yy: Vec4; w0yz: Vec4; w0yw: Vec4; w0z0: Vec4; w0z1: Vec4; w0zx: Vec4; w0zy: Vec4; w0zz: Vec4; w0zw: Vec4; w0w0: Vec4; w0w1: Vec4; w0wx: Vec4; w0wy: Vec4; w0wz: Vec4; w0ww: Vec4; w100: Vec4; w101: Vec4; w10x: Vec4; w10y: Vec4; w10z: Vec4; w10w: Vec4; w110: Vec4; w111: Vec4; w11x: Vec4; w11y: Vec4; w11z: Vec4; w11w: Vec4; w1x0: Vec4; w1x1: Vec4; w1xx: Vec4; w1xy: Vec4; w1xz: Vec4; w1xw: Vec4; w1y0: Vec4; w1y1: Vec4; w1yx: Vec4; w1yy: Vec4; w1yz: Vec4; w1yw: Vec4; w1z0: Vec4; w1z1: Vec4; w1zx: Vec4; w1zy: Vec4; w1zz: Vec4; w1zw: Vec4; w1w0: Vec4; w1w1: Vec4; w1wx: Vec4; w1wy: Vec4; w1wz: Vec4; w1ww: Vec4; wx00: Vec4; wx01: Vec4; wx0x: Vec4; wx0y: Vec4; wx0z: Vec4; wx0w: Vec4; wx10: Vec4; wx11: Vec4; wx1x: Vec4; wx1y: Vec4; wx1z: Vec4; wx1w: Vec4; wxx0: Vec4; wxx1: Vec4; wxxx: Vec4; wxxy: Vec4; wxxz: Vec4; wxxw: Vec4; wxy0: Vec4; wxy1: Vec4; wxyx: Vec4; wxyy: Vec4; wxyz: Vec4; wxyw: Vec4; wxz0: Vec4; wxz1: Vec4; wxzx: Vec4; wxzy: Vec4; wxzz: Vec4; wxzw: Vec4; wxw0: Vec4; wxw1: Vec4; wxwx: Vec4; wxwy: Vec4; wxwz: Vec4; wxww: Vec4; wy00: Vec4; wy01: Vec4; wy0x: Vec4; wy0y: Vec4; wy0z: Vec4; wy0w: Vec4; wy10: Vec4; wy11: Vec4; wy1x: Vec4; wy1y: Vec4; wy1z: Vec4; wy1w: Vec4; wyx0: Vec4; wyx1: Vec4; wyxx: Vec4; wyxy: Vec4; wyxz: Vec4; wyxw: Vec4; wyy0: Vec4; wyy1: Vec4; wyyx: Vec4; wyyy: Vec4; wyyz: Vec4; wyyw: Vec4; wyz0: Vec4; wyz1: Vec4; wyzx: Vec4; wyzy: Vec4; wyzz: Vec4; wyzw: Vec4; wyw0: Vec4; wyw1: Vec4; wywx: Vec4; wywy: Vec4; wywz: Vec4; wyww: Vec4; wz00: Vec4; wz01: Vec4; wz0x: Vec4; wz0y: Vec4; wz0z: Vec4; wz0w: Vec4; wz10: Vec4; wz11: Vec4; wz1x: Vec4; wz1y: Vec4; wz1z: Vec4; wz1w: Vec4; wzx0: Vec4; wzx1: Vec4; wzxx: Vec4; wzxy: Vec4; wzxz: Vec4; wzxw: Vec4; wzy0: Vec4; wzy1: Vec4; wzyx: Vec4; wzyy: Vec4; wzyz: Vec4; wzyw: Vec4; wzz0: Vec4; wzz1: Vec4; wzzx: Vec4; wzzy: Vec4; wzzz: Vec4; wzzw: Vec4; wzw0: Vec4; wzw1: Vec4; wzwx: Vec4; wzwy: Vec4; wzwz: Vec4; wzww: Vec4; ww00: Vec4; ww01: Vec4; ww0x: Vec4; ww0y: Vec4; ww0z: Vec4; ww0w: Vec4; ww10: Vec4; ww11: Vec4; ww1x: Vec4; ww1y: Vec4; ww1z: Vec4; ww1w: Vec4; wwx0: Vec4; wwx1: Vec4; wwxx: Vec4; wwxy: Vec4; wwxz: Vec4; wwxw: Vec4; wwy0: Vec4; wwy1: Vec4; wwyx: Vec4; wwyy: Vec4; wwyz: Vec4; wwyw: Vec4; wwz0: Vec4; wwz1: Vec4; wwzx: Vec4; wwzy: Vec4; wwzz: Vec4; wwzw: Vec4; www0: Vec4; www1: Vec4; wwwx: Vec4; wwwy: Vec4; wwwz: Vec4; wwww: Vec4;
|
|
@@ -1052,6 +1073,7 @@ Vec3.prototype.neg = Vec3.prototype.negate
|
|
|
1052
1073
|
Vec3.prototype.unaryMinus = Vec3.prototype.negate
|
|
1053
1074
|
Vec3.prototype.sqrLen = Vec3.prototype.squaredLength
|
|
1054
1075
|
Vec3.prototype.str = Vec3.prototype.toString
|
|
1076
|
+
Vec3.prototype.normalized = Vec3.prototype.normalize
|
|
1055
1077
|
Vec3.prototype.transformMat3x3 = Vec3.prototype.transformMat3
|
|
1056
1078
|
Vec3.prototype.transformMat4x4 = Vec3.prototype.transformMat4
|
|
1057
1079
|
|