@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.cjs
CHANGED
|
@@ -3145,6 +3145,9 @@ const forward = new Vector3$1();
|
|
|
3145
3145
|
const up = new Vector3$1();
|
|
3146
3146
|
const right = new Vector3$1();
|
|
3147
3147
|
|
|
3148
|
+
const sin$1 = Math.sin;
|
|
3149
|
+
const cos$1 = Math.cos;
|
|
3150
|
+
|
|
3148
3151
|
let Quaternion$1 = class Quaternion {
|
|
3149
3152
|
/**
|
|
3150
3153
|
*
|
|
@@ -3180,6 +3183,8 @@ let Quaternion$1 = class Quaternion {
|
|
|
3180
3183
|
this.onChanged = new Signal();
|
|
3181
3184
|
}
|
|
3182
3185
|
|
|
3186
|
+
// Making Quaternion comply to array interface
|
|
3187
|
+
|
|
3183
3188
|
get 0() {
|
|
3184
3189
|
return this.x;
|
|
3185
3190
|
}
|
|
@@ -3212,6 +3217,19 @@ let Quaternion$1 = class Quaternion {
|
|
|
3212
3217
|
this.w = v;
|
|
3213
3218
|
}
|
|
3214
3219
|
|
|
3220
|
+
/**
|
|
3221
|
+
* Making quaternion iterable
|
|
3222
|
+
*/
|
|
3223
|
+
* [Symbol.iterator]() {
|
|
3224
|
+
|
|
3225
|
+
yield this.x;
|
|
3226
|
+
yield this.y;
|
|
3227
|
+
yield this.z;
|
|
3228
|
+
yield this.w;
|
|
3229
|
+
|
|
3230
|
+
}
|
|
3231
|
+
|
|
3232
|
+
|
|
3215
3233
|
/**
|
|
3216
3234
|
*
|
|
3217
3235
|
* @param {number} fx forward vector
|
|
@@ -3252,58 +3270,22 @@ let Quaternion$1 = class Quaternion {
|
|
|
3252
3270
|
|
|
3253
3271
|
// construct partial transform matrix
|
|
3254
3272
|
const m00 = right.x;
|
|
3255
|
-
const
|
|
3256
|
-
const
|
|
3257
|
-
const m10 = up.x;
|
|
3258
|
-
const m11 = up.y;
|
|
3259
|
-
const m12 = up.z;
|
|
3260
|
-
const m20 = forward.x;
|
|
3261
|
-
const m21 = forward.y;
|
|
3262
|
-
const m22 = forward.z;
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
const num8 = (m00 + m11) + m22;
|
|
3266
|
-
|
|
3267
|
-
let _x, _y, _z, _w;
|
|
3268
|
-
|
|
3269
|
-
if (num8 > 0) {
|
|
3270
|
-
let num = Math.sqrt(num8 + 1);
|
|
3271
|
-
_w = num * 0.5;
|
|
3272
|
-
num = 0.5 / num;
|
|
3273
|
-
_x = (m12 - m21) * num;
|
|
3274
|
-
_y = (m20 - m02) * num;
|
|
3275
|
-
_z = (m01 - m10) * num;
|
|
3276
|
-
} else if ((m00 >= m11) && (m00 >= m22)) {
|
|
3273
|
+
const m10 = right.y;
|
|
3274
|
+
const m20 = right.z;
|
|
3277
3275
|
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
_x = 0.5 * num7;
|
|
3282
|
-
_y = (m01 + m10) * num4;
|
|
3283
|
-
_z = (m02 + m20) * num4;
|
|
3284
|
-
_w = (m12 - m21) * num4;
|
|
3285
|
-
|
|
3286
|
-
} else if (m11 > m22) {
|
|
3287
|
-
|
|
3288
|
-
const num6 = Math.sqrt(((1 + m11) - m00) - m22);
|
|
3289
|
-
const num3 = 0.5 / num6;
|
|
3290
|
-
|
|
3291
|
-
_x = (m10 + m01) * num3;
|
|
3292
|
-
_y = 0.5 * num6;
|
|
3293
|
-
_z = (m21 + m12) * num3;
|
|
3294
|
-
_w = (m20 - m02) * num3;
|
|
3295
|
-
} else {
|
|
3296
|
-
|
|
3297
|
-
const num5 = Math.sqrt(((1 + m22) - m00) - m11);
|
|
3298
|
-
const num2 = 0.5 / num5;
|
|
3276
|
+
const m01 = up.x;
|
|
3277
|
+
const m11 = up.y;
|
|
3278
|
+
const m21 = up.z;
|
|
3299
3279
|
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
_w = (m01 - m10) * num2;
|
|
3304
|
-
}
|
|
3280
|
+
const m02 = forward.x;
|
|
3281
|
+
const m12 = forward.y;
|
|
3282
|
+
const m22 = forward.z;
|
|
3305
3283
|
|
|
3306
|
-
this.
|
|
3284
|
+
this.__setFromRotationMatrix(
|
|
3285
|
+
m00, m01, m02,
|
|
3286
|
+
m10, m11, m12,
|
|
3287
|
+
m20, m21, m22
|
|
3288
|
+
);
|
|
3307
3289
|
}
|
|
3308
3290
|
|
|
3309
3291
|
/**
|
|
@@ -3311,13 +3293,24 @@ let Quaternion$1 = class Quaternion {
|
|
|
3311
3293
|
* @param {Vector3} vForward
|
|
3312
3294
|
* @param {Vector3} [vUp=Vector3.up]
|
|
3313
3295
|
*
|
|
3314
|
-
* @source http://answers.unity3d.com/questions/467614/what-is-the-source-code-of-quaternionlookrotation.html
|
|
3315
3296
|
*/
|
|
3316
3297
|
lookRotation(vForward, vUp = Vector3$1.up) {
|
|
3317
3298
|
|
|
3318
3299
|
this._lookRotation(vForward.x, vForward.y, vForward.z, vUp.x, vUp.y, vUp.z);
|
|
3319
3300
|
}
|
|
3320
3301
|
|
|
3302
|
+
/**
|
|
3303
|
+
*
|
|
3304
|
+
* @param {Quaternion} other
|
|
3305
|
+
* @return {number}
|
|
3306
|
+
*/
|
|
3307
|
+
dot(other) {
|
|
3308
|
+
return this.x * other.x
|
|
3309
|
+
+ this.y * other.y
|
|
3310
|
+
+ this.z * other.z
|
|
3311
|
+
+ this.w * other.w
|
|
3312
|
+
;
|
|
3313
|
+
}
|
|
3321
3314
|
|
|
3322
3315
|
/**
|
|
3323
3316
|
*
|
|
@@ -3337,14 +3330,14 @@ let Quaternion$1 = class Quaternion {
|
|
|
3337
3330
|
const z = this.z;
|
|
3338
3331
|
const w = this.w;
|
|
3339
3332
|
|
|
3340
|
-
const
|
|
3333
|
+
const length_sqr = x * x + y * y + z * z + w * w;
|
|
3341
3334
|
|
|
3342
|
-
if (
|
|
3335
|
+
if (length_sqr === 0) {
|
|
3343
3336
|
this.set(0, 0, 0, 0);
|
|
3344
3337
|
return;
|
|
3345
3338
|
}
|
|
3346
3339
|
|
|
3347
|
-
const invDot = 1.0 /
|
|
3340
|
+
const invDot = 1.0 / length_sqr;
|
|
3348
3341
|
|
|
3349
3342
|
const _x = -x * invDot;
|
|
3350
3343
|
const _y = -y * invDot;
|
|
@@ -3398,8 +3391,8 @@ let Quaternion$1 = class Quaternion {
|
|
|
3398
3391
|
_fromAxisAngle(ax, ay, az, angle) {
|
|
3399
3392
|
const halfAngle = angle * 0.5;
|
|
3400
3393
|
|
|
3401
|
-
const sinA2 =
|
|
3402
|
-
const cosA2 =
|
|
3394
|
+
const sinA2 = sin$1(halfAngle);
|
|
3395
|
+
const cosA2 = cos$1(halfAngle);
|
|
3403
3396
|
|
|
3404
3397
|
const qx = ax * sinA2;
|
|
3405
3398
|
const qy = ay * sinA2;
|
|
@@ -3480,7 +3473,7 @@ let Quaternion$1 = class Quaternion {
|
|
|
3480
3473
|
toAxisAngle(axis) {
|
|
3481
3474
|
const rad = Math.acos(this.w) * 2.0;
|
|
3482
3475
|
|
|
3483
|
-
const s =
|
|
3476
|
+
const s = sin$1(rad * 0.5);
|
|
3484
3477
|
|
|
3485
3478
|
if (Math.abs(s) > EPSILON) {
|
|
3486
3479
|
axis.set(
|
|
@@ -3523,7 +3516,6 @@ let Quaternion$1 = class Quaternion {
|
|
|
3523
3516
|
}
|
|
3524
3517
|
|
|
3525
3518
|
/**
|
|
3526
|
-
* @see http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
|
|
3527
3519
|
* @param {Quaternion} other
|
|
3528
3520
|
*/
|
|
3529
3521
|
multiply(other) {
|
|
@@ -3563,6 +3555,8 @@ let Quaternion$1 = class Quaternion {
|
|
|
3563
3555
|
*/
|
|
3564
3556
|
_multiplyQuaternions(ax, ay, az, aw, bx, by, bz, bw) {
|
|
3565
3557
|
|
|
3558
|
+
// see http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
|
|
3559
|
+
|
|
3566
3560
|
const x = ax * bw + aw * bx + ay * bz - az * by;
|
|
3567
3561
|
const y = ay * bw + aw * by + az * bx - ax * bz;
|
|
3568
3562
|
const z = az * bw + aw * bz + ax * by - ay * bx;
|
|
@@ -3652,7 +3646,7 @@ let Quaternion$1 = class Quaternion {
|
|
|
3652
3646
|
* @param {number} x
|
|
3653
3647
|
* @param {number} y
|
|
3654
3648
|
* @param {number} z
|
|
3655
|
-
* @param {String} order a combination of capital letters X,Y,Z. Examples: XYZ, YXZ
|
|
3649
|
+
* @param {String} [order] a combination of capital letters X,Y,Z. Examples: XYZ, YXZ
|
|
3656
3650
|
* @returns {Quaternion}
|
|
3657
3651
|
*/
|
|
3658
3652
|
__setFromEuler(x, y, z, order = 'XYZ') {
|
|
@@ -3683,6 +3677,8 @@ let Quaternion$1 = class Quaternion {
|
|
|
3683
3677
|
|
|
3684
3678
|
this.fromEulerAnglesXZY(x, y, z);
|
|
3685
3679
|
|
|
3680
|
+
} else {
|
|
3681
|
+
throw new Error(`Invalid order '${order}', bust be 3 capital letters consisting of X,Y and Z`);
|
|
3686
3682
|
}
|
|
3687
3683
|
|
|
3688
3684
|
return this;
|
|
@@ -3807,16 +3803,13 @@ let Quaternion$1 = class Quaternion {
|
|
|
3807
3803
|
const half_y = y * 0.5;
|
|
3808
3804
|
const half_z = z * 0.5;
|
|
3809
3805
|
|
|
3810
|
-
const
|
|
3811
|
-
const
|
|
3812
|
-
|
|
3813
|
-
const s1 = sin(half_x);
|
|
3814
|
-
const s2 = sin(half_y);
|
|
3815
|
-
const s3 = sin(half_z);
|
|
3806
|
+
const s1 = sin$1(half_x);
|
|
3807
|
+
const s2 = sin$1(half_y);
|
|
3808
|
+
const s3 = sin$1(half_z);
|
|
3816
3809
|
|
|
3817
|
-
const c1 = cos(half_x);
|
|
3818
|
-
const c2 = cos(half_y);
|
|
3819
|
-
const c3 = cos(half_z);
|
|
3810
|
+
const c1 = cos$1(half_x);
|
|
3811
|
+
const c2 = cos$1(half_y);
|
|
3812
|
+
const c3 = cos$1(half_z);
|
|
3820
3813
|
|
|
3821
3814
|
const _x = s1 * c2 * c3 + c1 * s2 * s3;
|
|
3822
3815
|
const _y = c1 * s2 * c3 - s1 * c2 * s3;
|
|
@@ -3840,16 +3833,13 @@ let Quaternion$1 = class Quaternion {
|
|
|
3840
3833
|
const scaled_y = y * 0.5;
|
|
3841
3834
|
const scaled_z = z * 0.5;
|
|
3842
3835
|
|
|
3843
|
-
const
|
|
3844
|
-
const
|
|
3836
|
+
const s1 = sin$1(scaled_x);
|
|
3837
|
+
const s2 = sin$1(scaled_y);
|
|
3838
|
+
const s3 = sin$1(scaled_z);
|
|
3845
3839
|
|
|
3846
|
-
const
|
|
3847
|
-
const
|
|
3848
|
-
const
|
|
3849
|
-
|
|
3850
|
-
const c1 = cos(scaled_x);
|
|
3851
|
-
const c2 = cos(scaled_y);
|
|
3852
|
-
const c3 = cos(scaled_z);
|
|
3840
|
+
const c1 = cos$1(scaled_x);
|
|
3841
|
+
const c2 = cos$1(scaled_y);
|
|
3842
|
+
const c3 = cos$1(scaled_z);
|
|
3853
3843
|
|
|
3854
3844
|
const _x = s1 * c2 * c3 + c1 * s2 * s3;
|
|
3855
3845
|
const _y = c1 * s2 * c3 - s1 * c2 * s3;
|
|
@@ -3873,16 +3863,13 @@ let Quaternion$1 = class Quaternion {
|
|
|
3873
3863
|
const scaled_y = y * 0.5;
|
|
3874
3864
|
const scaled_z = z * 0.5;
|
|
3875
3865
|
|
|
3876
|
-
const
|
|
3877
|
-
const
|
|
3878
|
-
|
|
3879
|
-
const s1 = sin(scaled_x);
|
|
3880
|
-
const s2 = sin(scaled_y);
|
|
3881
|
-
const s3 = sin(scaled_z);
|
|
3866
|
+
const s1 = sin$1(scaled_x);
|
|
3867
|
+
const s2 = sin$1(scaled_y);
|
|
3868
|
+
const s3 = sin$1(scaled_z);
|
|
3882
3869
|
|
|
3883
|
-
const c1 = cos(scaled_x);
|
|
3884
|
-
const c2 = cos(scaled_y);
|
|
3885
|
-
const c3 = cos(scaled_z);
|
|
3870
|
+
const c1 = cos$1(scaled_x);
|
|
3871
|
+
const c2 = cos$1(scaled_y);
|
|
3872
|
+
const c3 = cos$1(scaled_z);
|
|
3886
3873
|
|
|
3887
3874
|
const _x = s1 * c2 * c3 - c1 * s2 * s3;
|
|
3888
3875
|
const _y = c1 * s2 * c3 + s1 * c2 * s3;
|
|
@@ -3906,16 +3893,13 @@ let Quaternion$1 = class Quaternion {
|
|
|
3906
3893
|
const scaled_y = y * 0.5;
|
|
3907
3894
|
const scaled_z = z * 0.5;
|
|
3908
3895
|
|
|
3909
|
-
const
|
|
3910
|
-
const
|
|
3896
|
+
const s1 = sin$1(scaled_x);
|
|
3897
|
+
const s2 = sin$1(scaled_y);
|
|
3898
|
+
const s3 = sin$1(scaled_z);
|
|
3911
3899
|
|
|
3912
|
-
const
|
|
3913
|
-
const
|
|
3914
|
-
const
|
|
3915
|
-
|
|
3916
|
-
const c1 = cos(scaled_x);
|
|
3917
|
-
const c2 = cos(scaled_y);
|
|
3918
|
-
const c3 = cos(scaled_z);
|
|
3900
|
+
const c1 = cos$1(scaled_x);
|
|
3901
|
+
const c2 = cos$1(scaled_y);
|
|
3902
|
+
const c3 = cos$1(scaled_z);
|
|
3919
3903
|
|
|
3920
3904
|
const _x = s1 * c2 * c3 - c1 * s2 * s3;
|
|
3921
3905
|
const _y = c1 * s2 * c3 + s1 * c2 * s3;
|
|
@@ -3939,16 +3923,13 @@ let Quaternion$1 = class Quaternion {
|
|
|
3939
3923
|
const scaled_y = y * 0.5;
|
|
3940
3924
|
const scaled_z = z * 0.5;
|
|
3941
3925
|
|
|
3942
|
-
const
|
|
3943
|
-
const
|
|
3944
|
-
|
|
3945
|
-
const s1 = sin(scaled_x);
|
|
3946
|
-
const s2 = sin(scaled_y);
|
|
3947
|
-
const s3 = sin(scaled_z);
|
|
3926
|
+
const s1 = sin$1(scaled_x);
|
|
3927
|
+
const s2 = sin$1(scaled_y);
|
|
3928
|
+
const s3 = sin$1(scaled_z);
|
|
3948
3929
|
|
|
3949
|
-
const c1 = cos(scaled_x);
|
|
3950
|
-
const c2 = cos(scaled_y);
|
|
3951
|
-
const c3 = cos(scaled_z);
|
|
3930
|
+
const c1 = cos$1(scaled_x);
|
|
3931
|
+
const c2 = cos$1(scaled_y);
|
|
3932
|
+
const c3 = cos$1(scaled_z);
|
|
3952
3933
|
|
|
3953
3934
|
const _x = s1 * c2 * c3 + c1 * s2 * s3;
|
|
3954
3935
|
const _y = c1 * s2 * c3 + s1 * c2 * s3;
|
|
@@ -3972,16 +3953,13 @@ let Quaternion$1 = class Quaternion {
|
|
|
3972
3953
|
const scaled_y = y * 0.5;
|
|
3973
3954
|
const scaled_z = z * 0.5;
|
|
3974
3955
|
|
|
3975
|
-
const
|
|
3976
|
-
const
|
|
3977
|
-
|
|
3978
|
-
const s1 = sin(scaled_x);
|
|
3979
|
-
const s2 = sin(scaled_y);
|
|
3980
|
-
const s3 = sin(scaled_z);
|
|
3956
|
+
const s1 = sin$1(scaled_x);
|
|
3957
|
+
const s2 = sin$1(scaled_y);
|
|
3958
|
+
const s3 = sin$1(scaled_z);
|
|
3981
3959
|
|
|
3982
|
-
const c1 = cos(scaled_x);
|
|
3983
|
-
const c2 = cos(scaled_y);
|
|
3984
|
-
const c3 = cos(scaled_z);
|
|
3960
|
+
const c1 = cos$1(scaled_x);
|
|
3961
|
+
const c2 = cos$1(scaled_y);
|
|
3962
|
+
const c3 = cos$1(scaled_z);
|
|
3985
3963
|
|
|
3986
3964
|
const _x = s1 * c2 * c3 - c1 * s2 * s3;
|
|
3987
3965
|
const _y = c1 * s2 * c3 - s1 * c2 * s3;
|
|
@@ -4155,7 +4133,7 @@ let Quaternion$1 = class Quaternion {
|
|
|
4155
4133
|
}
|
|
4156
4134
|
|
|
4157
4135
|
/**
|
|
4158
|
-
*
|
|
4136
|
+
* @deprecated
|
|
4159
4137
|
* @param {Matrix4} m
|
|
4160
4138
|
*/
|
|
4161
4139
|
setFromRotationMatrix(m) {
|
|
@@ -4311,9 +4289,9 @@ let Quaternion$1 = class Quaternion {
|
|
|
4311
4289
|
if ((1.0 - cosom) > EPSILON) {
|
|
4312
4290
|
// standard case (slerp)
|
|
4313
4291
|
omega = Math.acos(cosom);
|
|
4314
|
-
sinom =
|
|
4315
|
-
scale0 =
|
|
4316
|
-
scale1 =
|
|
4292
|
+
sinom = sin$1(omega);
|
|
4293
|
+
scale0 = sin$1((1.0 - t) * omega) / sinom;
|
|
4294
|
+
scale1 = sin$1(t * omega) / sinom;
|
|
4317
4295
|
} else {
|
|
4318
4296
|
// "from" and "to" quaternions are very close
|
|
4319
4297
|
// ... so we can do a linear interpolation
|
|
@@ -4569,15 +4547,6 @@ let Quaternion$1 = class Quaternion {
|
|
|
4569
4547
|
&& epsilonEquals(this.w, w, tolerance);
|
|
4570
4548
|
}
|
|
4571
4549
|
|
|
4572
|
-
* [Symbol.iterator]() {
|
|
4573
|
-
|
|
4574
|
-
yield this.x;
|
|
4575
|
-
yield this.y;
|
|
4576
|
-
yield this.z;
|
|
4577
|
-
yield this.w;
|
|
4578
|
-
|
|
4579
|
-
}
|
|
4580
|
-
|
|
4581
4550
|
/**
|
|
4582
4551
|
* Based on http://planning.cs.uiuc.edu/node198.html
|
|
4583
4552
|
* @param {function():number} [random]
|
|
@@ -4594,10 +4563,10 @@ let Quaternion$1 = class Quaternion {
|
|
|
4594
4563
|
const u3 = 2 * Math.PI * random();
|
|
4595
4564
|
|
|
4596
4565
|
return this.set(
|
|
4597
|
-
sqrt1u1 *
|
|
4598
|
-
sqrtu1 *
|
|
4599
|
-
sqrtu1 *
|
|
4600
|
-
sqrt1u1 *
|
|
4566
|
+
sqrt1u1 * cos$1(u2),
|
|
4567
|
+
sqrtu1 * sin$1(u3),
|
|
4568
|
+
sqrtu1 * cos$1(u3),
|
|
4569
|
+
sqrt1u1 * sin$1(u2),
|
|
4601
4570
|
);
|
|
4602
4571
|
}
|
|
4603
4572
|
|
|
@@ -4645,6 +4614,7 @@ let Quaternion$1 = class Quaternion {
|
|
|
4645
4614
|
const angle = from.angleTo(to);
|
|
4646
4615
|
|
|
4647
4616
|
if (angle === 0) {
|
|
4617
|
+
// we're already where we need tobe. Also - avoid division by 0
|
|
4648
4618
|
result.copy(to);
|
|
4649
4619
|
} else {
|
|
4650
4620
|
// clamp to 1, to make sure we don't overshoot
|
|
@@ -4711,28 +4681,25 @@ const FLAGS_DEFAULT = TransformFlags.AutomaticChangeDetection;
|
|
|
4711
4681
|
class Transform {
|
|
4712
4682
|
|
|
4713
4683
|
/**
|
|
4714
|
-
* World-space position
|
|
4715
4684
|
* @type {Vector3}
|
|
4716
4685
|
* @readonly
|
|
4717
4686
|
*/
|
|
4718
4687
|
position = new Vector3$1(0, 0, 0);
|
|
4719
4688
|
|
|
4720
4689
|
/**
|
|
4721
|
-
* World-space rotation
|
|
4722
4690
|
* @type {Quaternion}
|
|
4723
4691
|
* @readonly
|
|
4724
4692
|
*/
|
|
4725
4693
|
rotation = new Quaternion$1(0, 0, 0, 1);
|
|
4726
4694
|
|
|
4727
4695
|
/**
|
|
4728
|
-
* World-space scale
|
|
4729
4696
|
* @type {Vector3}
|
|
4730
4697
|
* @readonly
|
|
4731
4698
|
*/
|
|
4732
4699
|
scale = new Vector3$1(1, 1, 1);
|
|
4733
4700
|
|
|
4734
4701
|
/**
|
|
4735
|
-
*
|
|
4702
|
+
* transform matrix, position, rotation and scale must match, but shear can be different
|
|
4736
4703
|
* @readonly
|
|
4737
4704
|
* @type {Float32Array}
|
|
4738
4705
|
*/
|
|
@@ -4740,22 +4707,18 @@ class Transform {
|
|
|
4740
4707
|
|
|
4741
4708
|
/**
|
|
4742
4709
|
* Various bit flags, see {@link TransformFlags}
|
|
4743
|
-
*
|
|
4710
|
+
* This should generally be accessed through getFlag/setFlag instead of modifying the value directly
|
|
4744
4711
|
* @type {number}
|
|
4745
4712
|
*/
|
|
4746
4713
|
flags = FLAGS_DEFAULT;
|
|
4747
4714
|
|
|
4748
|
-
/**
|
|
4749
|
-
*
|
|
4750
|
-
* @constructor
|
|
4751
|
-
*/
|
|
4752
4715
|
constructor() {
|
|
4753
4716
|
// watch changes
|
|
4754
4717
|
this.subscribe(this.#handle_component_change, this);
|
|
4755
4718
|
}
|
|
4756
4719
|
|
|
4757
4720
|
/**
|
|
4758
|
-
* Current "forward" direction
|
|
4721
|
+
* Current "forward" direction
|
|
4759
4722
|
* NOTE that this vector is not live, meaning that if you modify transform, previously-obtained result will no longer be valid
|
|
4760
4723
|
* @returns {Vector3}
|
|
4761
4724
|
*/
|
|
@@ -4767,6 +4730,30 @@ class Transform {
|
|
|
4767
4730
|
return result;
|
|
4768
4731
|
}
|
|
4769
4732
|
|
|
4733
|
+
/**
|
|
4734
|
+
* Current "up" direction
|
|
4735
|
+
* @return {Vector3}
|
|
4736
|
+
*/
|
|
4737
|
+
get up() {
|
|
4738
|
+
const result = Vector3$1.up.clone();
|
|
4739
|
+
|
|
4740
|
+
result.applyDirectionMatrix4(this.matrix);
|
|
4741
|
+
|
|
4742
|
+
return result;
|
|
4743
|
+
}
|
|
4744
|
+
|
|
4745
|
+
/**
|
|
4746
|
+
* Current "right" direction
|
|
4747
|
+
* @return {Vector3}
|
|
4748
|
+
*/
|
|
4749
|
+
get right() {
|
|
4750
|
+
const result = Vector3$1.right.clone();
|
|
4751
|
+
|
|
4752
|
+
result.applyDirectionMatrix4(this.matrix);
|
|
4753
|
+
|
|
4754
|
+
return result;
|
|
4755
|
+
}
|
|
4756
|
+
|
|
4770
4757
|
/**
|
|
4771
4758
|
* Attach change listener
|
|
4772
4759
|
* @param {function} handler
|
|
@@ -4982,6 +4969,7 @@ class Transform {
|
|
|
4982
4969
|
* @param {mat4|number[]|Float32Array} m
|
|
4983
4970
|
*/
|
|
4984
4971
|
fromMatrix4(m) {
|
|
4972
|
+
// 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
|
|
4985
4973
|
const ad = this.getFlag(TransformFlags.AutomaticChangeDetection);
|
|
4986
4974
|
|
|
4987
4975
|
this.clearFlag(TransformFlags.AutomaticChangeDetection);
|
|
@@ -4990,6 +4978,7 @@ class Transform {
|
|
|
4990
4978
|
|
|
4991
4979
|
decompose_matrix_4_array(m, this.position, this.rotation, this.scale);
|
|
4992
4980
|
|
|
4981
|
+
// restore value of the flag
|
|
4993
4982
|
this.writeFlag(TransformFlags.AutomaticChangeDetection, ad);
|
|
4994
4983
|
}
|
|
4995
4984
|
|