@woosh/meep-engine 2.92.22 → 2.92.24
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/build/meep.cjs +128 -139
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +128 -139
- package/package.json +1 -1
- package/src/core/geom/Quaternion.d.ts +29 -14
- package/src/core/geom/Quaternion.d.ts.map +1 -1
- package/src/core/geom/Quaternion.js +63 -99
- package/src/engine/animation/curve/AnimationCurve.spec.js +3 -2
- package/src/engine/ecs/transform/Transform.d.ts +5 -3
- package/src/engine/ecs/transform/Transform.d.ts.map +1 -1
- package/src/engine/ecs/transform/Transform.js +29 -10
package/build/meep.module.js
CHANGED
|
@@ -3143,6 +3143,9 @@ const forward = new Vector3$1();
|
|
|
3143
3143
|
const up = new Vector3$1();
|
|
3144
3144
|
const right = new Vector3$1();
|
|
3145
3145
|
|
|
3146
|
+
const sin$1 = Math.sin;
|
|
3147
|
+
const cos$1 = Math.cos;
|
|
3148
|
+
|
|
3146
3149
|
let Quaternion$1 = class Quaternion {
|
|
3147
3150
|
/**
|
|
3148
3151
|
*
|
|
@@ -3178,6 +3181,8 @@ let Quaternion$1 = class Quaternion {
|
|
|
3178
3181
|
this.onChanged = new Signal();
|
|
3179
3182
|
}
|
|
3180
3183
|
|
|
3184
|
+
// Making Quaternion comply to array interface
|
|
3185
|
+
|
|
3181
3186
|
get 0() {
|
|
3182
3187
|
return this.x;
|
|
3183
3188
|
}
|
|
@@ -3210,6 +3215,19 @@ let Quaternion$1 = class Quaternion {
|
|
|
3210
3215
|
this.w = v;
|
|
3211
3216
|
}
|
|
3212
3217
|
|
|
3218
|
+
/**
|
|
3219
|
+
* Making quaternion iterable
|
|
3220
|
+
*/
|
|
3221
|
+
* [Symbol.iterator]() {
|
|
3222
|
+
|
|
3223
|
+
yield this.x;
|
|
3224
|
+
yield this.y;
|
|
3225
|
+
yield this.z;
|
|
3226
|
+
yield this.w;
|
|
3227
|
+
|
|
3228
|
+
}
|
|
3229
|
+
|
|
3230
|
+
|
|
3213
3231
|
/**
|
|
3214
3232
|
*
|
|
3215
3233
|
* @param {number} fx forward vector
|
|
@@ -3250,58 +3268,22 @@ let Quaternion$1 = class Quaternion {
|
|
|
3250
3268
|
|
|
3251
3269
|
// construct partial transform matrix
|
|
3252
3270
|
const m00 = right.x;
|
|
3253
|
-
const
|
|
3254
|
-
const
|
|
3255
|
-
const m10 = up.x;
|
|
3256
|
-
const m11 = up.y;
|
|
3257
|
-
const m12 = up.z;
|
|
3258
|
-
const m20 = forward.x;
|
|
3259
|
-
const m21 = forward.y;
|
|
3260
|
-
const m22 = forward.z;
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
const num8 = (m00 + m11) + m22;
|
|
3264
|
-
|
|
3265
|
-
let _x, _y, _z, _w;
|
|
3266
|
-
|
|
3267
|
-
if (num8 > 0) {
|
|
3268
|
-
let num = Math.sqrt(num8 + 1);
|
|
3269
|
-
_w = num * 0.5;
|
|
3270
|
-
num = 0.5 / num;
|
|
3271
|
-
_x = (m12 - m21) * num;
|
|
3272
|
-
_y = (m20 - m02) * num;
|
|
3273
|
-
_z = (m01 - m10) * num;
|
|
3274
|
-
} else if ((m00 >= m11) && (m00 >= m22)) {
|
|
3271
|
+
const m10 = right.y;
|
|
3272
|
+
const m20 = right.z;
|
|
3275
3273
|
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
_x = 0.5 * num7;
|
|
3280
|
-
_y = (m01 + m10) * num4;
|
|
3281
|
-
_z = (m02 + m20) * num4;
|
|
3282
|
-
_w = (m12 - m21) * num4;
|
|
3283
|
-
|
|
3284
|
-
} else if (m11 > m22) {
|
|
3285
|
-
|
|
3286
|
-
const num6 = Math.sqrt(((1 + m11) - m00) - m22);
|
|
3287
|
-
const num3 = 0.5 / num6;
|
|
3288
|
-
|
|
3289
|
-
_x = (m10 + m01) * num3;
|
|
3290
|
-
_y = 0.5 * num6;
|
|
3291
|
-
_z = (m21 + m12) * num3;
|
|
3292
|
-
_w = (m20 - m02) * num3;
|
|
3293
|
-
} else {
|
|
3294
|
-
|
|
3295
|
-
const num5 = Math.sqrt(((1 + m22) - m00) - m11);
|
|
3296
|
-
const num2 = 0.5 / num5;
|
|
3274
|
+
const m01 = up.x;
|
|
3275
|
+
const m11 = up.y;
|
|
3276
|
+
const m21 = up.z;
|
|
3297
3277
|
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
_w = (m01 - m10) * num2;
|
|
3302
|
-
}
|
|
3278
|
+
const m02 = forward.x;
|
|
3279
|
+
const m12 = forward.y;
|
|
3280
|
+
const m22 = forward.z;
|
|
3303
3281
|
|
|
3304
|
-
this.
|
|
3282
|
+
this.__setFromRotationMatrix(
|
|
3283
|
+
m00, m01, m02,
|
|
3284
|
+
m10, m11, m12,
|
|
3285
|
+
m20, m21, m22
|
|
3286
|
+
);
|
|
3305
3287
|
}
|
|
3306
3288
|
|
|
3307
3289
|
/**
|
|
@@ -3309,13 +3291,24 @@ let Quaternion$1 = class Quaternion {
|
|
|
3309
3291
|
* @param {Vector3} vForward
|
|
3310
3292
|
* @param {Vector3} [vUp=Vector3.up]
|
|
3311
3293
|
*
|
|
3312
|
-
* @source http://answers.unity3d.com/questions/467614/what-is-the-source-code-of-quaternionlookrotation.html
|
|
3313
3294
|
*/
|
|
3314
3295
|
lookRotation(vForward, vUp = Vector3$1.up) {
|
|
3315
3296
|
|
|
3316
3297
|
this._lookRotation(vForward.x, vForward.y, vForward.z, vUp.x, vUp.y, vUp.z);
|
|
3317
3298
|
}
|
|
3318
3299
|
|
|
3300
|
+
/**
|
|
3301
|
+
*
|
|
3302
|
+
* @param {Quaternion} other
|
|
3303
|
+
* @return {number}
|
|
3304
|
+
*/
|
|
3305
|
+
dot(other) {
|
|
3306
|
+
return this.x * other.x
|
|
3307
|
+
+ this.y * other.y
|
|
3308
|
+
+ this.z * other.z
|
|
3309
|
+
+ this.w * other.w
|
|
3310
|
+
;
|
|
3311
|
+
}
|
|
3319
3312
|
|
|
3320
3313
|
/**
|
|
3321
3314
|
*
|
|
@@ -3335,14 +3328,14 @@ let Quaternion$1 = class Quaternion {
|
|
|
3335
3328
|
const z = this.z;
|
|
3336
3329
|
const w = this.w;
|
|
3337
3330
|
|
|
3338
|
-
const
|
|
3331
|
+
const length_sqr = x * x + y * y + z * z + w * w;
|
|
3339
3332
|
|
|
3340
|
-
if (
|
|
3333
|
+
if (length_sqr === 0) {
|
|
3341
3334
|
this.set(0, 0, 0, 0);
|
|
3342
3335
|
return;
|
|
3343
3336
|
}
|
|
3344
3337
|
|
|
3345
|
-
const invDot = 1.0 /
|
|
3338
|
+
const invDot = 1.0 / length_sqr;
|
|
3346
3339
|
|
|
3347
3340
|
const _x = -x * invDot;
|
|
3348
3341
|
const _y = -y * invDot;
|
|
@@ -3396,8 +3389,8 @@ let Quaternion$1 = class Quaternion {
|
|
|
3396
3389
|
_fromAxisAngle(ax, ay, az, angle) {
|
|
3397
3390
|
const halfAngle = angle * 0.5;
|
|
3398
3391
|
|
|
3399
|
-
const sinA2 =
|
|
3400
|
-
const cosA2 =
|
|
3392
|
+
const sinA2 = sin$1(halfAngle);
|
|
3393
|
+
const cosA2 = cos$1(halfAngle);
|
|
3401
3394
|
|
|
3402
3395
|
const qx = ax * sinA2;
|
|
3403
3396
|
const qy = ay * sinA2;
|
|
@@ -3478,7 +3471,7 @@ let Quaternion$1 = class Quaternion {
|
|
|
3478
3471
|
toAxisAngle(axis) {
|
|
3479
3472
|
const rad = Math.acos(this.w) * 2.0;
|
|
3480
3473
|
|
|
3481
|
-
const s =
|
|
3474
|
+
const s = sin$1(rad * 0.5);
|
|
3482
3475
|
|
|
3483
3476
|
if (Math.abs(s) > EPSILON) {
|
|
3484
3477
|
axis.set(
|
|
@@ -3521,7 +3514,6 @@ let Quaternion$1 = class Quaternion {
|
|
|
3521
3514
|
}
|
|
3522
3515
|
|
|
3523
3516
|
/**
|
|
3524
|
-
* @see http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
|
|
3525
3517
|
* @param {Quaternion} other
|
|
3526
3518
|
*/
|
|
3527
3519
|
multiply(other) {
|
|
@@ -3561,6 +3553,8 @@ let Quaternion$1 = class Quaternion {
|
|
|
3561
3553
|
*/
|
|
3562
3554
|
_multiplyQuaternions(ax, ay, az, aw, bx, by, bz, bw) {
|
|
3563
3555
|
|
|
3556
|
+
// see http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
|
|
3557
|
+
|
|
3564
3558
|
const x = ax * bw + aw * bx + ay * bz - az * by;
|
|
3565
3559
|
const y = ay * bw + aw * by + az * bx - ax * bz;
|
|
3566
3560
|
const z = az * bw + aw * bz + ax * by - ay * bx;
|
|
@@ -3650,7 +3644,7 @@ let Quaternion$1 = class Quaternion {
|
|
|
3650
3644
|
* @param {number} x
|
|
3651
3645
|
* @param {number} y
|
|
3652
3646
|
* @param {number} z
|
|
3653
|
-
* @param {String} order a combination of capital letters X,Y,Z. Examples: XYZ, YXZ
|
|
3647
|
+
* @param {String} [order] a combination of capital letters X,Y,Z. Examples: XYZ, YXZ
|
|
3654
3648
|
* @returns {Quaternion}
|
|
3655
3649
|
*/
|
|
3656
3650
|
__setFromEuler(x, y, z, order = 'XYZ') {
|
|
@@ -3681,6 +3675,8 @@ let Quaternion$1 = class Quaternion {
|
|
|
3681
3675
|
|
|
3682
3676
|
this.fromEulerAnglesXZY(x, y, z);
|
|
3683
3677
|
|
|
3678
|
+
} else {
|
|
3679
|
+
throw new Error(`Invalid order '${order}', bust be 3 capital letters consisting of X,Y and Z`);
|
|
3684
3680
|
}
|
|
3685
3681
|
|
|
3686
3682
|
return this;
|
|
@@ -3805,16 +3801,13 @@ let Quaternion$1 = class Quaternion {
|
|
|
3805
3801
|
const half_y = y * 0.5;
|
|
3806
3802
|
const half_z = z * 0.5;
|
|
3807
3803
|
|
|
3808
|
-
const
|
|
3809
|
-
const
|
|
3810
|
-
|
|
3811
|
-
const s1 = sin(half_x);
|
|
3812
|
-
const s2 = sin(half_y);
|
|
3813
|
-
const s3 = sin(half_z);
|
|
3804
|
+
const s1 = sin$1(half_x);
|
|
3805
|
+
const s2 = sin$1(half_y);
|
|
3806
|
+
const s3 = sin$1(half_z);
|
|
3814
3807
|
|
|
3815
|
-
const c1 = cos(half_x);
|
|
3816
|
-
const c2 = cos(half_y);
|
|
3817
|
-
const c3 = cos(half_z);
|
|
3808
|
+
const c1 = cos$1(half_x);
|
|
3809
|
+
const c2 = cos$1(half_y);
|
|
3810
|
+
const c3 = cos$1(half_z);
|
|
3818
3811
|
|
|
3819
3812
|
const _x = s1 * c2 * c3 + c1 * s2 * s3;
|
|
3820
3813
|
const _y = c1 * s2 * c3 - s1 * c2 * s3;
|
|
@@ -3838,16 +3831,13 @@ let Quaternion$1 = class Quaternion {
|
|
|
3838
3831
|
const scaled_y = y * 0.5;
|
|
3839
3832
|
const scaled_z = z * 0.5;
|
|
3840
3833
|
|
|
3841
|
-
const
|
|
3842
|
-
const
|
|
3834
|
+
const s1 = sin$1(scaled_x);
|
|
3835
|
+
const s2 = sin$1(scaled_y);
|
|
3836
|
+
const s3 = sin$1(scaled_z);
|
|
3843
3837
|
|
|
3844
|
-
const
|
|
3845
|
-
const
|
|
3846
|
-
const
|
|
3847
|
-
|
|
3848
|
-
const c1 = cos(scaled_x);
|
|
3849
|
-
const c2 = cos(scaled_y);
|
|
3850
|
-
const c3 = cos(scaled_z);
|
|
3838
|
+
const c1 = cos$1(scaled_x);
|
|
3839
|
+
const c2 = cos$1(scaled_y);
|
|
3840
|
+
const c3 = cos$1(scaled_z);
|
|
3851
3841
|
|
|
3852
3842
|
const _x = s1 * c2 * c3 + c1 * s2 * s3;
|
|
3853
3843
|
const _y = c1 * s2 * c3 - s1 * c2 * s3;
|
|
@@ -3871,16 +3861,13 @@ let Quaternion$1 = class Quaternion {
|
|
|
3871
3861
|
const scaled_y = y * 0.5;
|
|
3872
3862
|
const scaled_z = z * 0.5;
|
|
3873
3863
|
|
|
3874
|
-
const
|
|
3875
|
-
const
|
|
3876
|
-
|
|
3877
|
-
const s1 = sin(scaled_x);
|
|
3878
|
-
const s2 = sin(scaled_y);
|
|
3879
|
-
const s3 = sin(scaled_z);
|
|
3864
|
+
const s1 = sin$1(scaled_x);
|
|
3865
|
+
const s2 = sin$1(scaled_y);
|
|
3866
|
+
const s3 = sin$1(scaled_z);
|
|
3880
3867
|
|
|
3881
|
-
const c1 = cos(scaled_x);
|
|
3882
|
-
const c2 = cos(scaled_y);
|
|
3883
|
-
const c3 = cos(scaled_z);
|
|
3868
|
+
const c1 = cos$1(scaled_x);
|
|
3869
|
+
const c2 = cos$1(scaled_y);
|
|
3870
|
+
const c3 = cos$1(scaled_z);
|
|
3884
3871
|
|
|
3885
3872
|
const _x = s1 * c2 * c3 - c1 * s2 * s3;
|
|
3886
3873
|
const _y = c1 * s2 * c3 + s1 * c2 * s3;
|
|
@@ -3904,16 +3891,13 @@ let Quaternion$1 = class Quaternion {
|
|
|
3904
3891
|
const scaled_y = y * 0.5;
|
|
3905
3892
|
const scaled_z = z * 0.5;
|
|
3906
3893
|
|
|
3907
|
-
const
|
|
3908
|
-
const
|
|
3894
|
+
const s1 = sin$1(scaled_x);
|
|
3895
|
+
const s2 = sin$1(scaled_y);
|
|
3896
|
+
const s3 = sin$1(scaled_z);
|
|
3909
3897
|
|
|
3910
|
-
const
|
|
3911
|
-
const
|
|
3912
|
-
const
|
|
3913
|
-
|
|
3914
|
-
const c1 = cos(scaled_x);
|
|
3915
|
-
const c2 = cos(scaled_y);
|
|
3916
|
-
const c3 = cos(scaled_z);
|
|
3898
|
+
const c1 = cos$1(scaled_x);
|
|
3899
|
+
const c2 = cos$1(scaled_y);
|
|
3900
|
+
const c3 = cos$1(scaled_z);
|
|
3917
3901
|
|
|
3918
3902
|
const _x = s1 * c2 * c3 - c1 * s2 * s3;
|
|
3919
3903
|
const _y = c1 * s2 * c3 + s1 * c2 * s3;
|
|
@@ -3937,16 +3921,13 @@ let Quaternion$1 = class Quaternion {
|
|
|
3937
3921
|
const scaled_y = y * 0.5;
|
|
3938
3922
|
const scaled_z = z * 0.5;
|
|
3939
3923
|
|
|
3940
|
-
const
|
|
3941
|
-
const
|
|
3942
|
-
|
|
3943
|
-
const s1 = sin(scaled_x);
|
|
3944
|
-
const s2 = sin(scaled_y);
|
|
3945
|
-
const s3 = sin(scaled_z);
|
|
3924
|
+
const s1 = sin$1(scaled_x);
|
|
3925
|
+
const s2 = sin$1(scaled_y);
|
|
3926
|
+
const s3 = sin$1(scaled_z);
|
|
3946
3927
|
|
|
3947
|
-
const c1 = cos(scaled_x);
|
|
3948
|
-
const c2 = cos(scaled_y);
|
|
3949
|
-
const c3 = cos(scaled_z);
|
|
3928
|
+
const c1 = cos$1(scaled_x);
|
|
3929
|
+
const c2 = cos$1(scaled_y);
|
|
3930
|
+
const c3 = cos$1(scaled_z);
|
|
3950
3931
|
|
|
3951
3932
|
const _x = s1 * c2 * c3 + c1 * s2 * s3;
|
|
3952
3933
|
const _y = c1 * s2 * c3 + s1 * c2 * s3;
|
|
@@ -3970,16 +3951,13 @@ let Quaternion$1 = class Quaternion {
|
|
|
3970
3951
|
const scaled_y = y * 0.5;
|
|
3971
3952
|
const scaled_z = z * 0.5;
|
|
3972
3953
|
|
|
3973
|
-
const
|
|
3974
|
-
const
|
|
3975
|
-
|
|
3976
|
-
const s1 = sin(scaled_x);
|
|
3977
|
-
const s2 = sin(scaled_y);
|
|
3978
|
-
const s3 = sin(scaled_z);
|
|
3954
|
+
const s1 = sin$1(scaled_x);
|
|
3955
|
+
const s2 = sin$1(scaled_y);
|
|
3956
|
+
const s3 = sin$1(scaled_z);
|
|
3979
3957
|
|
|
3980
|
-
const c1 = cos(scaled_x);
|
|
3981
|
-
const c2 = cos(scaled_y);
|
|
3982
|
-
const c3 = cos(scaled_z);
|
|
3958
|
+
const c1 = cos$1(scaled_x);
|
|
3959
|
+
const c2 = cos$1(scaled_y);
|
|
3960
|
+
const c3 = cos$1(scaled_z);
|
|
3983
3961
|
|
|
3984
3962
|
const _x = s1 * c2 * c3 - c1 * s2 * s3;
|
|
3985
3963
|
const _y = c1 * s2 * c3 - s1 * c2 * s3;
|
|
@@ -4153,7 +4131,7 @@ let Quaternion$1 = class Quaternion {
|
|
|
4153
4131
|
}
|
|
4154
4132
|
|
|
4155
4133
|
/**
|
|
4156
|
-
*
|
|
4134
|
+
* @deprecated
|
|
4157
4135
|
* @param {Matrix4} m
|
|
4158
4136
|
*/
|
|
4159
4137
|
setFromRotationMatrix(m) {
|
|
@@ -4309,9 +4287,9 @@ let Quaternion$1 = class Quaternion {
|
|
|
4309
4287
|
if ((1.0 - cosom) > EPSILON) {
|
|
4310
4288
|
// standard case (slerp)
|
|
4311
4289
|
omega = Math.acos(cosom);
|
|
4312
|
-
sinom =
|
|
4313
|
-
scale0 =
|
|
4314
|
-
scale1 =
|
|
4290
|
+
sinom = sin$1(omega);
|
|
4291
|
+
scale0 = sin$1((1.0 - t) * omega) / sinom;
|
|
4292
|
+
scale1 = sin$1(t * omega) / sinom;
|
|
4315
4293
|
} else {
|
|
4316
4294
|
// "from" and "to" quaternions are very close
|
|
4317
4295
|
// ... so we can do a linear interpolation
|
|
@@ -4567,15 +4545,6 @@ let Quaternion$1 = class Quaternion {
|
|
|
4567
4545
|
&& epsilonEquals(this.w, w, tolerance);
|
|
4568
4546
|
}
|
|
4569
4547
|
|
|
4570
|
-
* [Symbol.iterator]() {
|
|
4571
|
-
|
|
4572
|
-
yield this.x;
|
|
4573
|
-
yield this.y;
|
|
4574
|
-
yield this.z;
|
|
4575
|
-
yield this.w;
|
|
4576
|
-
|
|
4577
|
-
}
|
|
4578
|
-
|
|
4579
4548
|
/**
|
|
4580
4549
|
* Based on http://planning.cs.uiuc.edu/node198.html
|
|
4581
4550
|
* @param {function():number} [random]
|
|
@@ -4592,10 +4561,10 @@ let Quaternion$1 = class Quaternion {
|
|
|
4592
4561
|
const u3 = 2 * Math.PI * random();
|
|
4593
4562
|
|
|
4594
4563
|
return this.set(
|
|
4595
|
-
sqrt1u1 *
|
|
4596
|
-
sqrtu1 *
|
|
4597
|
-
sqrtu1 *
|
|
4598
|
-
sqrt1u1 *
|
|
4564
|
+
sqrt1u1 * cos$1(u2),
|
|
4565
|
+
sqrtu1 * sin$1(u3),
|
|
4566
|
+
sqrtu1 * cos$1(u3),
|
|
4567
|
+
sqrt1u1 * sin$1(u2),
|
|
4599
4568
|
);
|
|
4600
4569
|
}
|
|
4601
4570
|
|
|
@@ -4643,6 +4612,7 @@ let Quaternion$1 = class Quaternion {
|
|
|
4643
4612
|
const angle = from.angleTo(to);
|
|
4644
4613
|
|
|
4645
4614
|
if (angle === 0) {
|
|
4615
|
+
// we're already where we need tobe. Also - avoid division by 0
|
|
4646
4616
|
result.copy(to);
|
|
4647
4617
|
} else {
|
|
4648
4618
|
// clamp to 1, to make sure we don't overshoot
|
|
@@ -4709,28 +4679,25 @@ const FLAGS_DEFAULT = TransformFlags.AutomaticChangeDetection;
|
|
|
4709
4679
|
class Transform {
|
|
4710
4680
|
|
|
4711
4681
|
/**
|
|
4712
|
-
* World-space position
|
|
4713
4682
|
* @type {Vector3}
|
|
4714
4683
|
* @readonly
|
|
4715
4684
|
*/
|
|
4716
4685
|
position = new Vector3$1(0, 0, 0);
|
|
4717
4686
|
|
|
4718
4687
|
/**
|
|
4719
|
-
* World-space rotation
|
|
4720
4688
|
* @type {Quaternion}
|
|
4721
4689
|
* @readonly
|
|
4722
4690
|
*/
|
|
4723
4691
|
rotation = new Quaternion$1(0, 0, 0, 1);
|
|
4724
4692
|
|
|
4725
4693
|
/**
|
|
4726
|
-
* World-space scale
|
|
4727
4694
|
* @type {Vector3}
|
|
4728
4695
|
* @readonly
|
|
4729
4696
|
*/
|
|
4730
4697
|
scale = new Vector3$1(1, 1, 1);
|
|
4731
4698
|
|
|
4732
4699
|
/**
|
|
4733
|
-
*
|
|
4700
|
+
* transform matrix, position, rotation and scale must match, but shear can be different
|
|
4734
4701
|
* @readonly
|
|
4735
4702
|
* @type {Float32Array}
|
|
4736
4703
|
*/
|
|
@@ -4738,22 +4705,18 @@ class Transform {
|
|
|
4738
4705
|
|
|
4739
4706
|
/**
|
|
4740
4707
|
* Various bit flags, see {@link TransformFlags}
|
|
4741
|
-
*
|
|
4708
|
+
* This should generally be accessed through getFlag/setFlag instead of modifying the value directly
|
|
4742
4709
|
* @type {number}
|
|
4743
4710
|
*/
|
|
4744
4711
|
flags = FLAGS_DEFAULT;
|
|
4745
4712
|
|
|
4746
|
-
/**
|
|
4747
|
-
*
|
|
4748
|
-
* @constructor
|
|
4749
|
-
*/
|
|
4750
4713
|
constructor() {
|
|
4751
4714
|
// watch changes
|
|
4752
4715
|
this.subscribe(this.#handle_component_change, this);
|
|
4753
4716
|
}
|
|
4754
4717
|
|
|
4755
4718
|
/**
|
|
4756
|
-
* Current "forward" direction
|
|
4719
|
+
* Current "forward" direction
|
|
4757
4720
|
* NOTE that this vector is not live, meaning that if you modify transform, previously-obtained result will no longer be valid
|
|
4758
4721
|
* @returns {Vector3}
|
|
4759
4722
|
*/
|
|
@@ -4765,6 +4728,30 @@ class Transform {
|
|
|
4765
4728
|
return result;
|
|
4766
4729
|
}
|
|
4767
4730
|
|
|
4731
|
+
/**
|
|
4732
|
+
* Current "up" direction
|
|
4733
|
+
* @return {Vector3}
|
|
4734
|
+
*/
|
|
4735
|
+
get up() {
|
|
4736
|
+
const result = Vector3$1.up.clone();
|
|
4737
|
+
|
|
4738
|
+
result.applyDirectionMatrix4(this.matrix);
|
|
4739
|
+
|
|
4740
|
+
return result;
|
|
4741
|
+
}
|
|
4742
|
+
|
|
4743
|
+
/**
|
|
4744
|
+
* Current "right" direction
|
|
4745
|
+
* @return {Vector3}
|
|
4746
|
+
*/
|
|
4747
|
+
get right() {
|
|
4748
|
+
const result = Vector3$1.right.clone();
|
|
4749
|
+
|
|
4750
|
+
result.applyDirectionMatrix4(this.matrix);
|
|
4751
|
+
|
|
4752
|
+
return result;
|
|
4753
|
+
}
|
|
4754
|
+
|
|
4768
4755
|
/**
|
|
4769
4756
|
* Attach change listener
|
|
4770
4757
|
* @param {function} handler
|
|
@@ -4980,6 +4967,7 @@ class Transform {
|
|
|
4980
4967
|
* @param {mat4|number[]|Float32Array} m
|
|
4981
4968
|
*/
|
|
4982
4969
|
fromMatrix4(m) {
|
|
4970
|
+
// we know we are changing the matrix, so we're going to need to disable the flag that sets matrix from position/rotation/scale changes
|
|
4983
4971
|
const ad = this.getFlag(TransformFlags.AutomaticChangeDetection);
|
|
4984
4972
|
|
|
4985
4973
|
this.clearFlag(TransformFlags.AutomaticChangeDetection);
|
|
@@ -4988,6 +4976,7 @@ class Transform {
|
|
|
4988
4976
|
|
|
4989
4977
|
decompose_matrix_4_array(m, this.position, this.rotation, this.scale);
|
|
4990
4978
|
|
|
4979
|
+
// restore value of the flag
|
|
4991
4980
|
this.writeFlag(TransformFlags.AutomaticChangeDetection, ad);
|
|
4992
4981
|
}
|
|
4993
4982
|
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import {Matrix4} from "three";
|
|
1
2
|
import Signal from "../events/signal/Signal";
|
|
2
|
-
import {Matrix4, Quaternion as ThreeQuaternion} from "three";
|
|
3
3
|
import Vector3 from "./Vector3";
|
|
4
4
|
|
|
5
5
|
interface Vector3Like {
|
|
@@ -8,11 +8,18 @@ interface Vector3Like {
|
|
|
8
8
|
z: number
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
interface QuaternionLike {
|
|
12
|
+
x: number
|
|
13
|
+
y: number
|
|
14
|
+
z: number
|
|
15
|
+
w: number
|
|
16
|
+
}
|
|
17
|
+
|
|
11
18
|
export default class Quaternion {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
x: number
|
|
20
|
+
y: number
|
|
21
|
+
z: number
|
|
22
|
+
w: number
|
|
16
23
|
|
|
17
24
|
0: number
|
|
18
25
|
1: number
|
|
@@ -23,13 +30,11 @@ export default class Quaternion {
|
|
|
23
30
|
|
|
24
31
|
set(x: number, y: number, z: number, w: number): void
|
|
25
32
|
|
|
26
|
-
copy(other:
|
|
27
|
-
copy(other: ThreeQuaternion): void
|
|
28
|
-
copy(other: { x: number, y: number, z: number, w: number }): void
|
|
33
|
+
copy(other: QuaternionLike): void
|
|
29
34
|
|
|
30
35
|
clone(): Quaternion
|
|
31
36
|
|
|
32
|
-
random(random?:()=>number):void
|
|
37
|
+
random(random?: () => number): void
|
|
33
38
|
|
|
34
39
|
equals(other: { x: number, y: number, z: number, w: number }): boolean
|
|
35
40
|
|
|
@@ -39,10 +44,22 @@ export default class Quaternion {
|
|
|
39
44
|
|
|
40
45
|
normalize(): void
|
|
41
46
|
|
|
42
|
-
length():number
|
|
47
|
+
length(): number
|
|
43
48
|
|
|
44
49
|
__setFromEuler(x: number, y: number, z: number, order?: string): void
|
|
45
50
|
|
|
51
|
+
fromEulerAnglesXYZ(x: number, y: number, z: number): void
|
|
52
|
+
|
|
53
|
+
fromEulerAnglesYXZ(y: number, x: number, z: number): void
|
|
54
|
+
|
|
55
|
+
fromEulerAnglesZXY(z: number, x: number, y: number): void
|
|
56
|
+
|
|
57
|
+
fromEulerAnglesZYX(z: number, y: number, x: number): void
|
|
58
|
+
|
|
59
|
+
fromEulerAnglesYZX(y: number, z: number, x: number): void
|
|
60
|
+
|
|
61
|
+
fromEulerAnglesXZY(x: number, z: number, y: number): void
|
|
62
|
+
|
|
46
63
|
setFromRotationMatrix(m: Matrix4): void
|
|
47
64
|
|
|
48
65
|
setRotationMatrix(matrix: ArrayLike<number>): void
|
|
@@ -57,11 +74,9 @@ export default class Quaternion {
|
|
|
57
74
|
|
|
58
75
|
toEulerAnglesXYZ(v3: { set(x: number, y: number, z: number): any }): void
|
|
59
76
|
|
|
60
|
-
fromEulerAnglesXYZ(x: number, y: number, z: number): void
|
|
61
|
-
|
|
62
77
|
fromAxisAngle(axis: Vector3Like, angle: number): void
|
|
63
78
|
|
|
64
|
-
toAxisAngle(axis: Vector3):number
|
|
79
|
+
toAxisAngle(axis: Vector3): number
|
|
65
80
|
|
|
66
81
|
computeTwistAngle(axis: Vector3Like): number
|
|
67
82
|
|
|
@@ -79,5 +94,5 @@ export default class Quaternion {
|
|
|
79
94
|
|
|
80
95
|
asArray(): number[]
|
|
81
96
|
|
|
82
|
-
static readonly identity:Quaternion
|
|
97
|
+
static readonly identity: Quaternion
|
|
83
98
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Quaternion.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Quaternion.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Quaternion.d.ts","sourceRoot":"","sources":["../../../../src/core/geom/Quaternion.js"],"names":[],"mappings":";AA0BA;IAk7CI;;;;OAIG;IACH,kCAFa,UAAU,CAQtB;IAED;;;;;;OAMG;IACH,0BALW,MAAM,KACN,MAAM,KACN,MAAM,GACJ,UAAU,CAQtB;IAED;;;;;;OAMG;IACH,6BALW,UAAU,QACV,UAAU,MACV,UAAU,aACV,MAAM,QAiBhB;IAn+CD;;;;;;;OAOG;IACH,4DAwBC;IAtBG;;;OAGG;IACH,UAAU;IACV;;;OAGG;IACH,UAAU;IACV;;;OAGG;IACH,UAAU;IACV;;;OAGG;IACH,UAAU;IAEV,0DAA6B;IAqBjC,mBAEC;IAlBD,gBAEC;IAkBD,mBAEC;IAlBD,gBAEC;IAkBD,mBAEC;IAlBD,gBAEC;IAkBD,mBAEC;IAlBD,gBAEC;IA+BD;;;;;;;;OAQG;IACH,kBAPW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAiDhB;IAED;;;;;OAKG;IACH,uBAJW,OAAO,QACP,OAAO,QAMjB;IAED;;;;OAIG;IACH,WAHW,UAAU,GACT,MAAM,CAQjB;IAED;;;OAGG;IACH,mBAFW,UAAU,QAKpB;IAED;;OAEG;IACH,eAqBC;IAED;;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