@galacean/effects-core 2.1.0-alpha.8 → 2.1.0-alpha.9

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/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: Galacean Effects runtime core for the web
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
6
- * Version: v2.1.0-alpha.8
6
+ * Version: v2.1.0-alpha.9
7
7
  */
8
8
 
9
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -2152,41 +2152,6 @@ __decorate([
2152
2152
  serialize()
2153
2153
  ], RendererComponent.prototype, "_priority", void 0);
2154
2154
 
2155
- function _array_like_to_array(arr, len) {
2156
- if (len == null || len > arr.length) len = arr.length;
2157
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
2158
- return arr2;
2159
- }
2160
-
2161
- function _unsupported_iterable_to_array(o, minLen) {
2162
- if (!o) return;
2163
- if (typeof o === "string") return _array_like_to_array(o, minLen);
2164
- var n = Object.prototype.toString.call(o).slice(8, -1);
2165
- if (n === "Object" && o.constructor) n = o.constructor.name;
2166
- if (n === "Map" || n === "Set") return Array.from(n);
2167
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
2168
- }
2169
-
2170
- function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
2171
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
2172
- if (it) return (it = it.call(o)).next.bind(it);
2173
- // Fallback for engines without symbol support
2174
- if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
2175
- if (it) o = it;
2176
- var i = 0;
2177
- return function() {
2178
- if (i >= o.length) return {
2179
- done: true
2180
- };
2181
- return {
2182
- done: false,
2183
- value: o[i++]
2184
- };
2185
- };
2186
- }
2187
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2188
- }
2189
-
2190
2155
  var PI2 = Math.PI * 2;
2191
2156
  var DEG2RAD = Math.PI / 180;
2192
2157
  var RAD2DEG = 180 / Math.PI;
@@ -3193,26 +3158,26 @@ Vector3.ONE = new Vector3(1.0, 1.0, 1.0);
3193
3158
  Vector3.ZERO = new Vector3(0.0, 0.0, 0.0);
3194
3159
 
3195
3160
  /**
3196
- * 四元数
3197
- */ var Quaternion = /*#__PURE__*/ function() {
3198
- function Quaternion(x, y, z, w) {
3161
+ * 四维向量
3162
+ */ var Vector4 = /*#__PURE__*/ function() {
3163
+ function Vector4(x, y, z, w) {
3199
3164
  if (x === void 0) x = 0;
3200
3165
  if (y === void 0) y = 0;
3201
3166
  if (z === void 0) z = 0;
3202
- if (w === void 0) w = 1;
3167
+ if (w === void 0) w = 0;
3203
3168
  this.x = x;
3204
3169
  this.y = y;
3205
3170
  this.z = z;
3206
3171
  this.w = w;
3207
3172
  }
3208
- var _proto = Quaternion.prototype;
3173
+ var _proto = Vector4.prototype;
3209
3174
  /**
3210
- * 四元数设置
3211
- * @param x - x 分量
3212
- * @param y - y 分量
3213
- * @param z - z 分量
3214
- * @param w - w 分量
3215
- * @returns 四元数
3175
+ * 设置向量
3176
+ * @param x - x 轴分量
3177
+ * @param y - y 轴分量
3178
+ * @param z - z 轴分量
3179
+ * @param w - w 轴分量
3180
+ * @returns
3216
3181
  */ _proto.set = function set(x, y, z, w) {
3217
3182
  this.x = x;
3218
3183
  this.y = y;
@@ -3221,1356 +3186,1165 @@ Vector3.ZERO = new Vector3(0.0, 0.0, 0.0);
3221
3186
  return this;
3222
3187
  };
3223
3188
  /**
3224
- * 通过欧拉角设置四元数
3225
- * @param euler - 欧拉角
3226
- * @returns
3227
- */ _proto.setFromEuler = function setFromEuler(euler) {
3228
- euler.toQuaternion(this);
3229
- return this;
3230
- };
3231
- /**
3232
- * 通过旋转轴和旋转角度设置四元数
3233
- * @param axis - 旋转轴
3234
- * @param angle - 旋转角度(弧度)
3235
- * @returns
3236
- */ _proto.setFromAxisAngle = function setFromAxisAngle(axis, angle) {
3237
- var halfAngle = angle / 2;
3238
- var s = Math.sin(halfAngle);
3239
- var v = Quaternion.tempVec0;
3240
- v.copyFrom(axis).normalize();
3241
- this.x = v.x * s;
3242
- this.y = v.y * s;
3243
- this.z = v.z * s;
3244
- this.w = Math.cos(halfAngle);
3189
+ * 设置零向量
3190
+ * @returns 向量
3191
+ */ _proto.setZero = function setZero() {
3192
+ this.x = 0;
3193
+ this.y = 0;
3194
+ this.z = 0;
3195
+ this.w = 0;
3245
3196
  return this;
3246
3197
  };
3247
3198
  /**
3248
- * 通过 Vector4Like 创建四元数
3249
- * @param v - Vector4Like
3250
- * @returns
3251
- */ _proto.setFromVector4 = function setFromVector4(v) {
3252
- this.x = v.x;
3253
- this.y = v.y;
3254
- this.z = v.z;
3255
- this.w = v.w;
3199
+ * 通过标量数值设置向量
3200
+ * @param num - 数值
3201
+ * @returns 向量
3202
+ */ _proto.setFromNumber = function setFromNumber(num) {
3203
+ this.x = num;
3204
+ this.y = num;
3205
+ this.z = num;
3206
+ this.w = num;
3256
3207
  return this;
3257
3208
  };
3258
3209
  /**
3259
- * 通过数组设置四元数
3210
+ * 通过数组创建向量
3260
3211
  * @param array - 数组
3261
3212
  * @param [offset=0] - 起始偏移值
3262
- * @returns
3213
+ * @returns 向量
3263
3214
  */ _proto.setFromArray = function setFromArray(array, offset) {
3264
3215
  if (offset === void 0) offset = 0;
3265
- this.x = array[offset];
3266
- this.y = array[offset + 1];
3267
- this.z = array[offset + 2];
3268
- this.w = array[offset + 3];
3269
- return this;
3270
- };
3271
- /**
3272
- * 通过矩阵设置四元数
3273
- * @param m - 矩阵
3274
- * @returns
3275
- */ _proto.setFromRotationMatrix = function setFromRotationMatrix(m) {
3276
- // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
3277
- // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
3278
- var te = m.elements;
3279
- var m11 = te[0];
3280
- var m12 = te[4];
3281
- var m13 = te[8];
3282
- var m21 = te[1];
3283
- var m22 = te[5];
3284
- var m23 = te[9];
3285
- var m31 = te[2];
3286
- var m32 = te[6];
3287
- var m33 = te[10];
3288
- var trace = m11 + m22 + m33;
3289
- if (trace > 0) {
3290
- var s = 0.5 / Math.sqrt(trace + 1.0);
3291
- this.w = 0.25 / s;
3292
- this.x = (m32 - m23) * s;
3293
- this.y = (m13 - m31) * s;
3294
- this.z = (m21 - m12) * s;
3295
- } else if (m11 > m22 && m11 > m33) {
3296
- var s1 = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
3297
- this.w = (m32 - m23) / s1;
3298
- this.x = 0.25 * s1;
3299
- this.y = (m12 + m21) / s1;
3300
- this.z = (m13 + m31) / s1;
3301
- this.negate();
3302
- } else if (m22 > m33) {
3303
- var s2 = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
3304
- this.w = (m13 - m31) / s2;
3305
- this.x = (m12 + m21) / s2;
3306
- this.y = 0.25 * s2;
3307
- this.z = (m23 + m32) / s2;
3308
- this.negate();
3309
- } else {
3310
- var s3 = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
3311
- this.w = (m21 - m12) / s3;
3312
- this.x = (m13 + m31) / s3;
3313
- this.y = (m23 + m32) / s3;
3314
- this.z = 0.25 * s3;
3315
- this.negate();
3316
- }
3317
- // 兼容原先数学库
3216
+ var _array_offset;
3217
+ this.x = (_array_offset = array[offset]) != null ? _array_offset : 0;
3218
+ var _array_;
3219
+ this.y = (_array_ = array[offset + 1]) != null ? _array_ : 0;
3220
+ var _array_1;
3221
+ this.z = (_array_1 = array[offset + 2]) != null ? _array_1 : 0;
3222
+ var _array_2;
3223
+ this.w = (_array_2 = array[offset + 3]) != null ? _array_2 : 0;
3318
3224
  return this;
3319
3225
  };
3320
3226
  /**
3321
- * 通过开始和结束向量设置四元数
3322
- * @param from - 开始向量
3323
- * @param to - 结束向量
3324
- * @returns
3325
- */ _proto.setFromUnitVectors = function setFromUnitVectors(from, to) {
3326
- // assumes direction vectors vFrom and vTo are normalized
3327
- var r = from.dot(to) + 1;
3328
- if (r < Number.EPSILON) {
3329
- r = 0;
3330
- if (Math.abs(from.x) > Math.abs(from.z)) {
3331
- this.x = -from.y;
3332
- this.y = from.x;
3333
- this.z = 0;
3334
- this.w = r;
3335
- } else {
3336
- this.x = 0;
3337
- this.y = -from.z;
3338
- this.z = from.y;
3339
- this.w = r;
3340
- }
3341
- } else {
3342
- this.x = from.y * to.z - from.z * to.y;
3343
- this.y = from.z * to.x - from.x * to.z;
3344
- this.z = from.x * to.y - from.y * to.x;
3345
- this.w = r;
3346
- }
3347
- return this.normalize();
3348
- };
3349
- /**
3350
- * 四元数拷贝
3351
- * @param quat - 拷贝目标四元数
3352
- * @returns 拷贝四元数
3353
- */ _proto.copyFrom = function copyFrom(quat) {
3354
- this.x = quat.x;
3355
- this.y = quat.y;
3356
- this.z = quat.z;
3357
- this.w = quat.w;
3227
+ * 拷贝向量
3228
+ * @param v - 复制对象
3229
+ * @returns 拷贝结果
3230
+ */ _proto.copyFrom = function copyFrom(v) {
3231
+ this.x = v.x;
3232
+ this.y = v.y;
3233
+ this.z = v.z;
3234
+ this.w = v.w;
3358
3235
  return this;
3359
3236
  };
3360
3237
  /**
3361
- * 四元数克隆
3238
+ * 克隆向量
3362
3239
  * @returns 克隆结果
3363
3240
  */ _proto.clone = function clone() {
3364
- return new Quaternion(this.x, this.y, this.z, this.w);
3365
- };
3366
- /**
3367
- * 四元数间的夹角计算
3368
- * @param other - 其他四元数
3369
- * @returns 夹角
3370
- */ _proto.angleTo = function angleTo(other) {
3371
- return 2 * Math.acos(Math.abs(clamp$1(this.dot(other), -1, 1)));
3241
+ return new Vector4(this.x, this.y, this.z, this.w);
3372
3242
  };
3373
3243
  /**
3374
- * 四元数向目标旋转
3375
- * @param q - 四元数
3376
- * @param step - 旋转弧度
3377
- * @returns 目标四元数
3378
- */ _proto.rotateTowards = function rotateTowards(q, step) {
3379
- var angle = this.angleTo(q);
3380
- if (angle === 0) {
3381
- return this;
3244
+ * 根据下标设置向量分量
3245
+ * @param index - 下标值
3246
+ * @param value - 分量值
3247
+ * @returns 向量
3248
+ */ _proto.setElement = function setElement(index, value) {
3249
+ switch(index){
3250
+ case 0:
3251
+ this.x = value;
3252
+ break;
3253
+ case 1:
3254
+ this.y = value;
3255
+ break;
3256
+ case 2:
3257
+ this.z = value;
3258
+ break;
3259
+ case 3:
3260
+ this.w = value;
3261
+ break;
3262
+ default:
3263
+ console.error("index is out of range: " + index);
3382
3264
  }
3383
- var t = Math.min(1, step / angle);
3384
- this.slerp(q, t);
3385
3265
  return this;
3386
3266
  };
3387
3267
  /**
3388
- * 四元数单位化
3389
- * @returns 单位四元数
3390
- */ _proto.identity = function identity() {
3391
- return this.set(0, 0, 0, 1);
3268
+ * 根据下标获取向量分量
3269
+ * @param index - 下标
3270
+ * @returns 分量值
3271
+ */ _proto.getElement = function getElement(index) {
3272
+ switch(index){
3273
+ case 0:
3274
+ return this.x;
3275
+ case 1:
3276
+ return this.y;
3277
+ case 2:
3278
+ return this.z;
3279
+ case 3:
3280
+ return this.w;
3281
+ default:
3282
+ console.error("index is out of range: " + index);
3283
+ }
3284
+ return 0;
3392
3285
  };
3393
3286
  /**
3394
- * 四元数求逆
3395
- * @returns 四元数的逆
3396
- */ _proto.invert = function invert() {
3397
- return this.conjugate();
3287
+ * 向量相加
3288
+ * @param right - 相加对象,向量 | 数字
3289
+ * @returns 相加结果
3290
+ */ _proto.add = function add(right) {
3291
+ if (typeof right === "number") {
3292
+ this.x += right;
3293
+ this.y += right;
3294
+ this.z += right;
3295
+ this.w += right;
3296
+ } else if (_instanceof1(right, Array)) {
3297
+ this.x += right[0];
3298
+ this.y += right[1];
3299
+ this.z += right[2];
3300
+ this.w += right[3];
3301
+ } else {
3302
+ this.x += right.x;
3303
+ this.y += right.y;
3304
+ this.z += right.z;
3305
+ this.w += right.w;
3306
+ }
3307
+ return this;
3398
3308
  };
3399
3309
  /**
3400
- * 四元数取负
3401
- * @returns 负四元数
3402
- */ _proto.negate = function negate() {
3403
- this.x = -this.x;
3404
- this.y = -this.y;
3405
- this.z = -this.z;
3406
- this.w = -this.w;
3310
+ * 向量相加
3311
+ * @param left - 向量
3312
+ * @param right - 向量
3313
+ * @returns 求和结果
3314
+ */ _proto.addVectors = function addVectors(left, right) {
3315
+ this.x = left.x + right.x;
3316
+ this.y = left.y + right.y;
3317
+ this.z = left.z + right.z;
3318
+ this.w = left.w + right.w;
3407
3319
  return this;
3408
3320
  };
3409
3321
  /**
3410
- * 四元数求共轭值
3411
- * @returns 四元数的共轭值
3412
- */ _proto.conjugate = function conjugate() {
3413
- this.x = -this.x;
3414
- this.y = -this.y;
3415
- this.z = -this.z;
3322
+ * 向量比例缩放后相加
3323
+ * @param right - 向量
3324
+ * @param s - 比例
3325
+ * @returns 求和结果
3326
+ */ _proto.addScaledVector = function addScaledVector(right, s) {
3327
+ this.x += right.x * s;
3328
+ this.y += right.y * s;
3329
+ this.z += right.z * s;
3330
+ this.w += right.w * s;
3416
3331
  return this;
3417
3332
  };
3418
3333
  /**
3419
- * 四元数点乘结果
3420
- * @param v
3421
- * @return
3422
- */ _proto.dot = function dot(v) {
3423
- return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
3334
+ * 向量相减
3335
+ * @param right - 相减对象,向量 | 数字
3336
+ * @returns 相减结果
3337
+ */ _proto.subtract = function subtract(right) {
3338
+ if (typeof right === "number") {
3339
+ this.x -= right;
3340
+ this.y -= right;
3341
+ this.z -= right;
3342
+ this.w -= right;
3343
+ } else if (_instanceof1(right, Array)) {
3344
+ this.x -= right[0];
3345
+ this.y -= right[1];
3346
+ this.z -= right[2];
3347
+ this.w -= right[3];
3348
+ } else {
3349
+ this.x -= right.x;
3350
+ this.y -= right.y;
3351
+ this.z -= right.z;
3352
+ this.w -= right.w;
3353
+ }
3354
+ return this;
3424
3355
  };
3425
3356
  /**
3426
- * 四元数的模平方
3427
- * @return
3428
- */ _proto.lengthSquared = function lengthSquared() {
3429
- return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
3357
+ * 向量相减
3358
+ * @param left - 向量
3359
+ * @param right - 向量
3360
+ * @returns 向量
3361
+ */ _proto.subtractVectors = function subtractVectors(left, right) {
3362
+ this.x = left.x - right.x;
3363
+ this.y = left.y - right.y;
3364
+ this.z = left.z - right.z;
3365
+ this.w = left.w - right.w;
3366
+ return this;
3430
3367
  };
3431
3368
  /**
3432
- * 四元数的欧式长度
3433
- * @returns 长度
3434
- */ _proto.length = function length() {
3435
- return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
3369
+ * 向量相乘
3370
+ * @param right - 相乘对象,对象 | 数字
3371
+ * @returns 向量
3372
+ */ _proto.multiply = function multiply(right) {
3373
+ if (typeof right === "number") {
3374
+ this.x *= right;
3375
+ this.y *= right;
3376
+ this.z *= right;
3377
+ this.w *= right;
3378
+ } else if (_instanceof1(right, Array)) {
3379
+ this.x *= right[0];
3380
+ this.y *= right[1];
3381
+ this.z *= right[2];
3382
+ this.w *= right[3];
3383
+ } else {
3384
+ this.x *= right.x;
3385
+ this.y *= right.y;
3386
+ this.z *= right.z;
3387
+ this.w *= right.w;
3388
+ }
3389
+ return this;
3436
3390
  };
3437
3391
  /**
3438
- * 四元数归一化
3439
- * @returns 归一化值
3440
- */ _proto.normalize = function normalize() {
3441
- var l = this.length();
3442
- if (l === 0) {
3443
- this.x = 0;
3444
- this.y = 0;
3445
- this.z = 0;
3446
- this.w = 1;
3392
+ * 向量相乘
3393
+ * @param left - 向量
3394
+ * @param right - 向量
3395
+ * @returns 向量
3396
+ */ _proto.multiplyVectors = function multiplyVectors(left, right) {
3397
+ this.x = left.x * right.x;
3398
+ this.y = left.y * right.y;
3399
+ this.z = left.z * right.z;
3400
+ this.w = left.w * right.w;
3401
+ return this;
3402
+ };
3403
+ /**
3404
+ * 向量相除
3405
+ * @param right - 相除对象,对象 | 数字
3406
+ * @returns 向量
3407
+ */ _proto.divide = function divide(right) {
3408
+ if (typeof right === "number") {
3409
+ this.x /= right;
3410
+ this.y /= right;
3411
+ this.z /= right;
3412
+ this.w /= right;
3413
+ } else if (_instanceof1(right, Array)) {
3414
+ this.x /= right[0];
3415
+ this.y /= right[1];
3416
+ this.z /= right[2];
3417
+ this.w /= right[3];
3447
3418
  } else {
3448
- l = 1 / l;
3449
- this.x = this.x * l;
3450
- this.y = this.y * l;
3451
- this.z = this.z * l;
3452
- this.w = this.w * l;
3419
+ this.x /= right.x;
3420
+ this.y /= right.y;
3421
+ this.z /= right.z;
3422
+ this.w /= right.w;
3453
3423
  }
3454
3424
  return this;
3455
3425
  };
3456
3426
  /**
3457
- * 四元数右乘
3458
- * @param right - 右乘的四元数
3459
- * @returns
3460
- */ _proto.multiply = function multiply(right) {
3461
- return this.multiplyQuaternions(this, right);
3427
+ * 向量缩放
3428
+ * @param v - 数字
3429
+ * @returns 缩放结果
3430
+ */ _proto.scale = function scale(v) {
3431
+ this.x *= v;
3432
+ this.y *= v;
3433
+ this.z *= v;
3434
+ this.w *= v;
3435
+ return this;
3462
3436
  };
3463
3437
  /**
3464
- * 四元数左乘
3465
- * @param left - 左乘的四元数
3466
- * @returns
3467
- */ _proto.premultiply = function premultiply(left) {
3468
- return this.multiplyQuaternions(left, this);
3438
+ * 分量求和
3439
+ * @returns 求和结果
3440
+ */ _proto.sum = function sum() {
3441
+ return this.x + this.y + this.z + this.w;
3469
3442
  };
3470
3443
  /**
3471
- * 四元数乘法
3472
- * @param left - 四元数
3473
- * @param right - 四元数
3474
- * @returns 四元数
3475
- */ _proto.multiplyQuaternions = function multiplyQuaternions(left, right) {
3476
- // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
3477
- var qax = left.x;
3478
- var qay = left.y;
3479
- var qaz = left.z;
3480
- var qaw = left.w;
3481
- var qbx = right.x;
3482
- var qby = right.y;
3483
- var qbz = right.z;
3484
- var qbw = right.w;
3485
- this.x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
3486
- this.y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
3487
- this.z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
3488
- this.w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
3444
+ * 向量求最小值
3445
+ * @param v - 向量或数值
3446
+ * @returns 最小值
3447
+ */ _proto.min = function min(v) {
3448
+ if (typeof v === "number") {
3449
+ this.x = Math.min(this.x, v);
3450
+ this.y = Math.min(this.y, v);
3451
+ this.z = Math.min(this.z, v);
3452
+ this.w = Math.min(this.w, v);
3453
+ } else {
3454
+ this.x = Math.min(this.x, v.x);
3455
+ this.y = Math.min(this.y, v.y);
3456
+ this.z = Math.min(this.z, v.z);
3457
+ this.w = Math.min(this.w, v.w);
3458
+ }
3489
3459
  return this;
3490
3460
  };
3491
3461
  /**
3492
- * 四元数线性插值
3493
- * @see http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/
3494
- * @param other - 四元数
3495
- * @param t - 插值比
3496
- * @returns 插值结果
3497
- */ _proto.slerp = function slerp(other, t) {
3498
- if (t === 0) {
3499
- return this;
3500
- }
3501
- if (t === 1) {
3502
- return this.copyFrom(other);
3503
- }
3504
- var _this = this, x = _this.x, y = _this.y, z = _this.z, w = _this.w;
3505
- var cosHalfTheta = w * other.w + x * other.x + y * other.y + z * other.z;
3506
- if (cosHalfTheta < 0) {
3507
- this.w = -other.w;
3508
- this.x = -other.x;
3509
- this.y = -other.y;
3510
- this.z = -other.z;
3511
- cosHalfTheta = -cosHalfTheta;
3462
+ * 向量求最大值
3463
+ * @param v - 向量或数值
3464
+ * @returns 最大值
3465
+ */ _proto.max = function max(v) {
3466
+ if (typeof v === "number") {
3467
+ this.x = Math.max(this.x, v);
3468
+ this.y = Math.max(this.y, v);
3469
+ this.z = Math.max(this.z, v);
3470
+ this.w = Math.max(this.w, v);
3512
3471
  } else {
3513
- this.copyFrom(other);
3514
- }
3515
- if (cosHalfTheta >= 1.0) {
3516
- this.w = w;
3517
- this.x = x;
3518
- this.y = y;
3519
- this.z = z;
3520
- return this;
3521
- }
3522
- var sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta;
3523
- if (sqrSinHalfTheta <= Number.EPSILON) {
3524
- var s = 1 - t;
3525
- this.w = s * w + t * this.w;
3526
- this.x = s * x + t * this.x;
3527
- this.y = s * y + t * this.y;
3528
- this.z = s * z + t * this.z;
3529
- this.normalize();
3530
- return this;
3472
+ this.x = Math.max(this.x, v.x);
3473
+ this.y = Math.max(this.y, v.y);
3474
+ this.z = Math.max(this.z, v.z);
3475
+ this.w = Math.max(this.w, v.w);
3531
3476
  }
3532
- var sinHalfTheta = Math.sqrt(sqrSinHalfTheta);
3533
- var halfTheta = Math.atan2(sinHalfTheta, cosHalfTheta);
3534
- var ratioA = Math.sin((1 - t) * halfTheta) / sinHalfTheta;
3535
- var ratioB = Math.sin(t * halfTheta) / sinHalfTheta;
3536
- this.w = w * ratioA + this.w * ratioB;
3537
- this.x = x * ratioA + this.x * ratioB;
3538
- this.y = y * ratioA + this.y * ratioB;
3539
- this.z = z * ratioA + this.z * ratioB;
3540
3477
  return this;
3541
3478
  };
3542
3479
  /**
3543
- * 两个四元数的线性插值
3544
- * @param qa - 四元数
3545
- * @param qb - 四元数
3546
- * @param t - 插值比
3547
- */ _proto.slerpQuaternions = function slerpQuaternions(qa, qb, t) {
3548
- this.copyFrom(qa).slerp(qb, t);
3480
+ * 向量阈值约束
3481
+ * @param min - 最小值
3482
+ * @param max - 最大值
3483
+ * @returns 向量
3484
+ */ _proto.clamp = function clamp(min, max) {
3485
+ return this.max(min).min(max);
3549
3486
  };
3550
3487
  /**
3551
- * 通过四元数旋转向量
3552
- * @param v - 待旋转向量
3553
- * @param [out] - 旋转结果,如果没有传入直接覆盖输入值
3554
- * @returns
3555
- */ _proto.rotateVector3 = function rotateVector3(v, out) {
3556
- var _this = this, qx = _this.x, qy = _this.y, qz = _this.z, qw = _this.w;
3557
- var vx = v.x, vy = v.y, vz = v.z;
3558
- var ix = qw * vx + qy * vz - qz * vy;
3559
- var iy = qw * vy + qz * vx - qx * vz;
3560
- var iz = qw * vz + qx * vy - qy * vx;
3561
- var iw = -qx * vx - qy * vy - qz * vz;
3562
- var res = out != null ? out : v;
3563
- res.x = ix * qw + iw * -qx + iy * -qz - iz * -qy;
3564
- res.y = iy * qw + iw * -qy + iz * -qx - ix * -qz;
3565
- res.z = iz * qw + iw * -qz + ix * -qy - iy * -qx;
3566
- return res;
3488
+ * 向量向下取整
3489
+ * @returns 取整结果
3490
+ */ _proto.floor = function floor() {
3491
+ this.x = Math.floor(this.x);
3492
+ this.y = Math.floor(this.y);
3493
+ this.z = Math.floor(this.z);
3494
+ this.w = Math.floor(this.w);
3495
+ return this;
3567
3496
  };
3568
3497
  /**
3569
- * 四元数判等
3570
- * @param quaternion - 四元数
3571
- * @returns 判等结果
3572
- */ _proto.equals = function equals(quaternion) {
3573
- return quaternion.x === this.x && quaternion.y === this.y && quaternion.z === this.z && quaternion.w === this.w;
3498
+ * 向量向上取整
3499
+ * @returns 取整结果
3500
+ */ _proto.ceil = function ceil() {
3501
+ this.x = Math.ceil(this.x);
3502
+ this.y = Math.ceil(this.y);
3503
+ this.z = Math.ceil(this.z);
3504
+ this.w = Math.ceil(this.w);
3505
+ return this;
3574
3506
  };
3575
3507
  /**
3576
- * 四元数保存为数组
3577
- * @returns
3578
- */ _proto.toArray = function toArray() {
3579
- return [
3580
- this.x,
3581
- this.y,
3582
- this.z,
3583
- this.w
3584
- ];
3508
+ * 向量四舍五入
3509
+ * @returns 求值结果
3510
+ */ _proto.round = function round() {
3511
+ this.x = Math.round(this.x);
3512
+ this.y = Math.round(this.y);
3513
+ this.z = Math.round(this.z);
3514
+ this.w = Math.round(this.w);
3515
+ return this;
3585
3516
  };
3586
3517
  /**
3587
- * 四元数转四维向量数组
3588
- * @param vec - 目标保存对象
3589
- * @returns 保存结果
3590
- */ _proto.toVector4 = function toVector4(vec) {
3591
- return vec.set(this.x, this.y, this.z, this.w);
3518
+ * 向量取绝对值
3519
+ * @returns 向量
3520
+ */ _proto.abs = function abs() {
3521
+ this.x = Math.abs(this.x);
3522
+ this.y = Math.abs(this.y);
3523
+ this.z = Math.abs(this.z);
3524
+ this.w = Math.abs(this.w);
3525
+ return this;
3592
3526
  };
3593
3527
  /**
3594
- * 四元数转欧拉角
3595
- * @param euler - 目标欧拉角
3596
- * @returns 欧拉角
3597
- */ _proto.toEuler = function toEuler(euler) {
3598
- return euler.setFromQuaternion(this);
3528
+ * 向量取反
3529
+ * @returns 取反结果
3530
+ */ _proto.negate = function negate() {
3531
+ this.x = -this.x;
3532
+ this.y = -this.y;
3533
+ this.z = -this.z;
3534
+ this.w = -this.w;
3535
+ return this;
3599
3536
  };
3600
3537
  /**
3601
- * 四元数转矩阵
3602
- * @param mat - 目标矩阵
3603
- * @returns
3604
- */ _proto.toMatrix4 = function toMatrix4(mat) {
3605
- return mat.compose(Vector3.ZERO, this, Vector3.ONE);
3538
+ * 向量长度平方
3539
+ * @returns 长度平方
3540
+ */ _proto.lengthSquared = function lengthSquared() {
3541
+ return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
3606
3542
  };
3607
3543
  /**
3608
- * 通过欧拉角创建四元数
3609
- * @param euler - 欧拉角
3610
- * @returns 四元数
3611
- */ Quaternion.fromEuler = function fromEuler(euler) {
3612
- return new Quaternion().setFromEuler(euler);
3544
+ * 向量长度
3545
+ * @returns 长度
3546
+ */ _proto.length = function length() {
3547
+ return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
3613
3548
  };
3614
3549
  /**
3615
- * 通过旋转轴和旋转角度创建四元数
3616
- * @param axis - 旋转轴
3617
- * @param angle - 旋转角(弧度值)
3618
- * @returns 四元数
3619
- */ Quaternion.fromAxisAngle = function fromAxisAngle(axis, angle) {
3620
- return new Quaternion().setFromAxisAngle(axis, angle);
3550
+ * 向量归一化
3551
+ * @returns 归一化结果
3552
+ */ _proto.normalize = function normalize() {
3553
+ return this.divide(this.length() || 1);
3621
3554
  };
3622
3555
  /**
3623
- * 通过 Vector4Like 创建四元数
3624
- * @param v - Vector4Like
3625
- * @returns 四元数
3626
- */ Quaternion.fromVector4 = function fromVector4(v) {
3627
- return new Quaternion().setFromVector4(v);
3556
+ * 设置向量长度
3557
+ * @param length - 长度
3558
+ * @returns 向量
3559
+ */ _proto.setLength = function setLength(length) {
3560
+ return this.normalize().multiply(length);
3628
3561
  };
3629
3562
  /**
3630
- * 通过数组创建四元数
3631
- * @param array - 数组
3632
- * @param [offset=0] - 起始偏移值
3633
- * @returns 四元数
3634
- */ Quaternion.fromArray = function fromArray(array, offset) {
3635
- if (offset === void 0) offset = 0;
3636
- return new Quaternion().setFromArray(array, offset);
3563
+ * 向量求线性插值
3564
+ * @param v - 向量
3565
+ * @param alpha - 插值比例
3566
+ * @returns 插值结果
3567
+ */ _proto.lerp = function lerp(v, alpha) {
3568
+ this.x += (v.x - this.x) * alpha;
3569
+ this.y += (v.y - this.y) * alpha;
3570
+ this.z += (v.z - this.z) * alpha;
3571
+ this.w += (v.w - this.w) * alpha;
3572
+ return this;
3637
3573
  };
3638
3574
  /**
3639
- * 通过旋转矩阵创建四元数
3640
- * @param m - 旋转矩阵
3641
- * @returns 四元数
3642
- */ Quaternion.fromRotationMatrix = function fromRotationMatrix(m) {
3643
- return new Quaternion().setFromRotationMatrix(m);
3575
+ * 两向量求线性插值
3576
+ * @param v1 - 第一个向量
3577
+ * @param v2 - 第二个向量
3578
+ * @param alpha - 插值比例
3579
+ * @returns 插值结果
3580
+ */ _proto.lerpVectors = function lerpVectors(v1, v2, alpha) {
3581
+ this.x = v1.x + (v2.x - v1.x) * alpha;
3582
+ this.y = v1.y + (v2.y - v1.y) * alpha;
3583
+ this.z = v1.z + (v2.z - v1.z) * alpha;
3584
+ this.w = v1.w + (v2.w - v1.w) * alpha;
3585
+ return this;
3644
3586
  };
3645
3587
  /**
3646
- * 通过开始和结束向量创建四元数
3647
- * @param from - 开始向量
3648
- * @param to - 结束向量
3649
- * @returns
3650
- */ Quaternion.fromUnitVectors = function fromUnitVectors(from, to) {
3651
- return new Quaternion().setFromUnitVectors(from, to);
3588
+ * 向量求点积
3589
+ * @param v - 向量
3590
+ * @returns 点积结果
3591
+ */ _proto.dot = function dot(v) {
3592
+ return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
3652
3593
  };
3653
- return Quaternion;
3654
- }();
3655
- Quaternion.tempVec0 = new Vector3();
3656
-
3657
- /**
3658
- * 四阶矩阵(列优先矩阵)
3659
- */ var Matrix4 = /*#__PURE__*/ function() {
3660
- function Matrix4(m11, m21, m31, m41, m12, m22, m32, m42, m13, m23, m33, m43, m14, m24, m34, m44) {
3661
- if (m11 === void 0) m11 = 1;
3662
- if (m21 === void 0) m21 = 0;
3663
- if (m31 === void 0) m31 = 0;
3664
- if (m41 === void 0) m41 = 0;
3665
- if (m12 === void 0) m12 = 0;
3666
- if (m22 === void 0) m22 = 1;
3667
- if (m32 === void 0) m32 = 0;
3668
- if (m42 === void 0) m42 = 0;
3669
- if (m13 === void 0) m13 = 0;
3670
- if (m23 === void 0) m23 = 0;
3671
- if (m33 === void 0) m33 = 1;
3672
- if (m43 === void 0) m43 = 0;
3673
- if (m14 === void 0) m14 = 0;
3674
- if (m24 === void 0) m24 = 0;
3675
- if (m34 === void 0) m34 = 0;
3676
- if (m44 === void 0) m44 = 1;
3677
- this.elements = [
3678
- m11,
3679
- m21,
3680
- m31,
3681
- m41,
3682
- m12,
3683
- m22,
3684
- m32,
3685
- m42,
3686
- m13,
3687
- m23,
3688
- m33,
3689
- m43,
3690
- m14,
3691
- m24,
3692
- m34,
3693
- m44
3694
- ];
3695
- }
3696
- var _proto = Matrix4.prototype;
3697
3594
  /**
3698
- * 设置矩阵
3699
- * @param m11 - 第 1 行,第 1 列
3700
- * @param m21 - 第 2 行,第 1 列
3701
- * @param m31 - 3 行,第 1 列
3702
- * @param m41 - 4 行,第 1
3703
- * @param m12 - 第 1 行,第 2 列
3704
- * @param m22 - 第 2 行,第 2 列
3705
- * @param m32 - 第 3 行,第 2 列
3706
- * @param m42 - 第 4 行,第 2 列
3707
- * @param m13 - 第 1 行,第 3 列
3708
- * @param m23 - 第 2 行,第 3 列
3709
- * @param m33 - 第 3 行,第 3 列
3710
- * @param m43 - 第 4 行,第 3 列
3711
- * @param m14 - 第 1 行,第 4 列
3712
- * @param m24 - 第 2 行,第 4 列
3713
- * @param m34 - 第 3 行,第 4 列
3714
- * @param m44 - 第 4 行,第 4 列
3715
- * @returns 矩阵
3716
- */ _proto.set = function set(m11, m21, m31, m41, m12, m22, m32, m42, m13, m23, m33, m43, m14, m24, m34, m44) {
3717
- var e = this.elements;
3718
- e[0] = m11;
3719
- e[1] = m21;
3720
- e[2] = m31;
3721
- e[3] = m41;
3722
- e[4] = m12;
3723
- e[5] = m22;
3724
- e[6] = m32;
3725
- e[7] = m42;
3726
- e[8] = m13;
3727
- e[9] = m23;
3728
- e[10] = m33;
3729
- e[11] = m43;
3730
- e[12] = m14;
3731
- e[13] = m24;
3732
- e[14] = m34;
3733
- e[15] = m44;
3734
- return this;
3595
+ * 向量判等
3596
+ * @param v - 向量
3597
+ * @returns 判等结果
3598
+ */ _proto.equals = function equals(v) {
3599
+ return v.x === this.x && v.y === this.y && v.z === this.z && v.w === this.w;
3735
3600
  };
3736
3601
  /**
3737
- * 通过行优先数据设置矩阵
3738
- * @param m11 - 第 1 行,第 1 列
3739
- * @param m12 - 1 行,第 2 列
3740
- * @param m13 - 第 1 行,第 3 列
3741
- * @param m14 - 1 行,第 4
3742
- * @param m21 - 2 行,第 1
3743
- * @param m22 - 第 2 行,第 2 列
3744
- * @param m23 - 第 2 行,第 3 列
3745
- * @param m24 - 第 2 行,第 4 列
3746
- * @param m31 - 第 3 行,第 1 列
3747
- * @param m32 - 第 3 行,第 2 列
3748
- * @param m33 - 第 3 行,第 3 列
3749
- * @param m34 - 第 3 行,第 4 列
3750
- * @param m41 - 第 4 行,第 1 列
3751
- * @param m42 - 第 4 行,第 2 列
3752
- * @param m43 - 第 4 行,第 3 列
3753
- * @param m44 - 第 4 行,第 4 列
3754
- * @returns 矩阵
3755
- */ _proto.setFromRowMajorData = function setFromRowMajorData(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) {
3756
- var e = this.elements;
3757
- e[0] = m11;
3758
- e[4] = m12;
3759
- e[8] = m13;
3760
- e[12] = m14;
3761
- e[1] = m21;
3762
- e[5] = m22;
3763
- e[9] = m23;
3764
- e[13] = m24;
3765
- e[2] = m31;
3766
- e[6] = m32;
3767
- e[10] = m33;
3768
- e[14] = m34;
3769
- e[3] = m41;
3770
- e[7] = m42;
3771
- e[11] = m43;
3772
- e[15] = m44;
3773
- return this;
3602
+ * 是否零向量
3603
+ * @returns 是否零向量
3604
+ */ _proto.isZero = function isZero() {
3605
+ var eps = NumberEpsilon;
3606
+ var _this = this, x = _this.x, y = _this.y, z = _this.z, w = _this.w;
3607
+ return Math.abs(x) <= eps && Math.abs(y) <= eps && Math.abs(z) <= eps && Math.abs(w) <= eps;
3774
3608
  };
3775
3609
  /**
3776
- * 通过四个列向量设置矩阵
3777
- * @param c1 - 第一列
3778
- * @param c2 - 第二列
3779
- * @param c3 - 第三列
3780
- * @param c4 - 第四列
3781
- * @returns 矩阵
3782
- */ _proto.setFromColumnVectors = function setFromColumnVectors(c1, c2, c3, c4) {
3783
- return this.set(c1.x, c1.y, c1.z, c1.w, c2.x, c2.y, c2.z, c2.w, c3.x, c3.y, c3.z, c3.w, c4.x, c4.y, c4.z, c4.w);
3610
+ * 向量转数组
3611
+ * @returns 数组
3612
+ */ _proto.toArray = function toArray() {
3613
+ return [
3614
+ this.x,
3615
+ this.y,
3616
+ this.z,
3617
+ this.w
3618
+ ];
3784
3619
  };
3785
- /**
3786
- * 通过三维矩阵设置矩阵
3787
- * @param m - 三维矩阵
3788
- * @returns 设置结果
3789
- */ _proto.setFromMatrix3 = function setFromMatrix3(m) {
3790
- var me = m.elements;
3791
- this.set(me[0], me[1], me[2], 0, me[3], me[4], me[5], 0, me[6], me[7], me[8], 0, 0, 0, 0, 1);
3792
- return this;
3620
+ _proto.toVector3 = function toVector3() {
3621
+ return new Vector3(this.x, this.y, this.z);
3793
3622
  };
3794
- /**
3795
- * 通过数组设置矩阵
3796
- * @param array - 数组
3797
- * @param [offset=0] - 起始偏移值
3798
- * @returns 矩阵
3799
- */ _proto.setFromArray = function setFromArray(array, offset) {
3623
+ _proto.fill = function fill(array, offset) {
3800
3624
  if (offset === void 0) offset = 0;
3801
- for(var i = 0; i < 16; i++){
3802
- this.elements[i] = array[offset + i];
3803
- }
3804
- return this;
3625
+ array[offset] = this.x;
3626
+ array[offset + 1] = this.y;
3627
+ array[offset + 2] = this.z;
3628
+ array[offset + 3] = this.w;
3805
3629
  };
3806
3630
  /**
3807
- * 通过缩放设置矩阵
3808
- * @param x - x 方向缩放
3809
- * @param y - y 方向缩放
3810
- * @param z - z 方向缩放
3811
- * @returns 缩放矩阵
3812
- */ _proto.setFromScale = function setFromScale(x, y, z) {
3813
- return this.set(x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, 0, 0, 0, 1);
3631
+ * 生成随机向量
3632
+ * @returns 向量
3633
+ */ _proto.random = function random() {
3634
+ this.x = Math.random();
3635
+ this.y = Math.random();
3636
+ this.z = Math.random();
3637
+ this.w = Math.random();
3638
+ return this;
3814
3639
  };
3815
3640
  /**
3816
- * 通过平移设置矩阵
3817
- * @param x - x 方向平移
3818
- * @param y - y 方向平移
3819
- * @param z - z 方向平移
3820
- * @returns 平移矩阵
3821
- */ _proto.setFromTranslation = function setFromTranslation(x, y, z) {
3822
- return this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1);
3641
+ * 变换矩阵作用于向量
3642
+ * @param m - 变换矩阵
3643
+ * @param [out] - 输出结果,如果没有设置就直接覆盖当前值
3644
+ * @returns 向量
3645
+ */ _proto.applyMatrix = function applyMatrix(m, out) {
3646
+ return m.transformVector4(this, out);
3823
3647
  };
3824
3648
  /**
3825
- * 通过 x 轴旋转角度设置矩阵
3826
- * @param theta - x 轴旋转弧度
3827
- * @returns 矩阵
3828
- */ _proto.setFromRotationX = function setFromRotationX(theta) {
3829
- var c = Math.cos(theta);
3830
- var s = Math.sin(theta);
3831
- return this.set(1, 0, 0, 0, 0, c, s, 0, 0, -s, c, 0, 0, 0, 0, 1);
3649
+ * 通过标量数值创建向量
3650
+ * @param num - 数值
3651
+ * @returns 向量
3652
+ */ Vector4.fromNumber = function fromNumber(num) {
3653
+ return new Vector4().setFromNumber(num);
3832
3654
  };
3833
3655
  /**
3834
- * 通过 y 轴旋转角度设置矩阵
3835
- * @param theta - y 轴旋转弧度
3836
- * @returns 矩阵
3837
- */ _proto.setFromRotationY = function setFromRotationY(theta) {
3838
- var c = Math.cos(theta);
3839
- var s = Math.sin(theta);
3840
- return this.set(c, 0, -s, 0, 0, 1, 0, 0, s, 0, c, 0, 0, 0, 0, 1);
3656
+ * 通过数组创建向量
3657
+ * @param array - 数组
3658
+ * @param [offset=0] - 起始偏移值
3659
+ * @returns 向量
3660
+ */ Vector4.fromArray = function fromArray(array, offset) {
3661
+ if (offset === void 0) offset = 0;
3662
+ return new Vector4().setFromArray(array, offset);
3841
3663
  };
3842
- /**
3843
- * 通过 z 轴旋转角度设置矩阵
3844
- * @param theta - z 轴旋转弧度
3845
- * @returns 矩阵
3846
- */ _proto.setFromRotationZ = function setFromRotationZ(theta) {
3847
- var c = Math.cos(theta);
3848
- var s = Math.sin(theta);
3849
- return this.set(c, s, 0, 0, -s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
3664
+ return Vector4;
3665
+ }();
3666
+ /**
3667
+ * 四维向量的常量
3668
+ */ Vector4.ONE = new Vector4(1.0, 1.0, 1.0, 1.0);
3669
+ Vector4.ZERO = new Vector4(0.0, 0.0, 0.0, 0.0);
3670
+
3671
+ var MeshComponent = /*#__PURE__*/ function(RendererComponent) {
3672
+ _inherits(MeshComponent, RendererComponent);
3673
+ function MeshComponent() {
3674
+ var _this;
3675
+ _this = RendererComponent.apply(this, arguments) || this;
3676
+ /**
3677
+ * 用于点击测试的碰撞器
3678
+ */ _this.meshCollider = new MeshCollider();
3679
+ // TODO 点击测试后续抽象一个 Collider 组件
3680
+ _this.getHitTestParams = function(force) {
3681
+ var area = _this.getBoundingBox();
3682
+ if (area) {
3683
+ return {
3684
+ type: area.type,
3685
+ triangles: area.area
3686
+ };
3687
+ }
3688
+ };
3689
+ return _this;
3690
+ }
3691
+ var _proto = MeshComponent.prototype;
3692
+ _proto.render = function render(renderer) {
3693
+ if (renderer.renderingData.currentFrame.globalUniforms) {
3694
+ renderer.setGlobalMatrix("effects_ObjectToWorld", this.transform.getWorldMatrix());
3695
+ }
3696
+ renderer.drawGeometry(this.geometry, this.material);
3850
3697
  };
3851
- /**
3852
- * 根据三维旋转轴与弧度设置矩阵
3853
- * @param axis - 三维旋转轴
3854
- * @param angle - 旋转弧度
3855
- * @returns 矩阵
3856
- */ _proto.setFromRotationAxis = function setFromRotationAxis(axis, angle) {
3857
- // Based on http://www.gamedev.net/reference/articles/article1199.asp
3858
- var v = Matrix4.tempVec0;
3859
- v.copyFrom(axis).normalize();
3860
- var c = Math.cos(angle);
3861
- var s = Math.sin(angle);
3862
- var t = 1 - c;
3863
- var x = v.x, y = v.y, z = v.z;
3864
- var tx = t * x;
3865
- var ty = t * y;
3866
- return this.set(tx * x + c, tx * y + s * z, tx * z - s * y, 0, tx * y - s * z, ty * y + c, ty * z + s * x, 0, tx * z + s * y, ty * z - s * x, t * z * z + c, 0, 0, 0, 0, 1);
3698
+ _proto.getBoundingBox = function getBoundingBox() {
3699
+ var worldMatrix = this.transform.getWorldMatrix();
3700
+ this.meshCollider.setGeometry(this.geometry, worldMatrix);
3701
+ var boundingBoxData = this.meshCollider.getBoundingBoxData();
3702
+ return boundingBoxData;
3867
3703
  };
3868
- /**
3869
- * 通过欧拉角设置矩阵
3870
- * @param euler - 欧拉角
3871
- * @returns 矩阵
3872
- */ _proto.setFromEuler = function setFromEuler(euler) {
3873
- euler.toMatrix4(this);
3874
- return this;
3704
+ return MeshComponent;
3705
+ }(RendererComponent);
3706
+ __decorate([
3707
+ serialize()
3708
+ ], MeshComponent.prototype, "geometry", void 0);
3709
+
3710
+ var EffectComponent = /*#__PURE__*/ function(MeshComponent) {
3711
+ _inherits(EffectComponent, MeshComponent);
3712
+ function EffectComponent(engine) {
3713
+ var _this;
3714
+ _this = MeshComponent.call(this, engine) || this;
3715
+ _this.name = "EffectComponent";
3716
+ return _this;
3717
+ }
3718
+ var _proto = EffectComponent.prototype;
3719
+ _proto.onStart = function onStart() {
3720
+ this.item.getHitTestParams = this.getHitTestParams;
3875
3721
  };
3876
- /**
3877
- * 通过四元数设置矩阵
3878
- * @param quat - 四元数
3879
- * @returns 矩阵
3880
- */ _proto.setFromQuaternion = function setFromQuaternion(quat) {
3881
- return this.compose(Vector3.ZERO, quat, Vector3.ONE);
3882
- };
3883
- /**
3884
- * 通过倾斜参数设置矩阵
3885
- * @param x - x 方向倾斜分量
3886
- * @param y - y 方向倾斜分量
3887
- * @param z - z 方向倾斜分量
3888
- * @returns 倾斜矩阵
3889
- */ _proto.setFromShear = function setFromShear(x, y, z) {
3890
- return this.set(1, x, x, 0, y, 1, y, 0, z, z, 1, 0, 0, 0, 0, 1);
3891
- };
3892
- /**
3893
- * 通过基轴设置矩阵
3894
- * @param xAxis - x 轴
3895
- * @param yAxis - y 轴
3896
- * @param zAxis - z 轴
3897
- * @returns 倾斜矩阵
3898
- */ _proto.setFromBasis = function setFromBasis(xAxis, yAxis, zAxis) {
3899
- return this.set(xAxis.x, xAxis.y, xAxis.z, 0, yAxis.x, yAxis.y, yAxis.z, 0, zAxis.x, zAxis.y, zAxis.z, 0, 0, 0, 0, 1);
3900
- };
3901
- /**
3902
- * 矩阵清零
3903
- * @returns 零矩阵
3904
- */ _proto.setZero = function setZero() {
3905
- for(var i = 0; i < 16; i++){
3906
- this.elements[i] = 0;
3907
- }
3908
- return this;
3909
- };
3910
- /**
3911
- * 矩阵单位化
3912
- * @returns 单位矩阵
3913
- */ _proto.identity = function identity() {
3914
- return this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
3915
- };
3916
- /**
3917
- * 单位阵判断
3918
- * @returns 判断结果
3919
- */ _proto.isIdentity = function isIdentity() {
3920
- var e = this.elements;
3921
- return e[0] === 1 && e[4] === 0 && e[8] === 0 && e[12] === 0 && e[1] === 0 && e[5] === 1 && e[9] === 0 && e[13] === 0 && e[2] === 0 && e[6] === 0 && e[10] === 1 && e[14] === 0 && e[3] === 0 && e[7] === 0 && e[11] === 0 && e[15] === 1;
3922
- };
3923
- /**
3924
- * 矩阵克隆
3925
- * @returns 克隆结果
3926
- */ _proto.clone = function clone() {
3927
- var e = this.elements;
3928
- return new Matrix4(e[0], e[1], e[2], e[3], e[4], e[5], e[6], e[7], e[8], e[9], e[10], e[11], e[12], e[13], e[14], e[15]);
3929
- };
3930
- /**
3931
- * 矩阵复制
3932
- * @param m - 复制对象
3933
- * @returns 复制结果
3934
- */ _proto.copyFrom = function copyFrom(m) {
3935
- this.elements = [].concat(m.elements);
3936
- return this;
3937
- };
3938
- /**
3939
- * 得到列向量
3940
- * @param i - 列向量索引,从 0 开始
3941
- * @param v
3942
- * @returns 矩阵
3943
- */ _proto.getColumnVector = function getColumnVector(i, v) {
3944
- return v.set(this.elements[i * 4], this.elements[i * 4 + 1], this.elements[i * 4 + 2], this.elements[i * 4 + 3]);
3945
- };
3946
- /**
3947
- * 设置相机矩阵
3948
- * @param eye - 相机位置
3949
- * @param target - 目标位置
3950
- * @param up - 相机方向
3951
- * @returns 矩阵
3952
- */ _proto.lookAt = function lookAt(eye, target, up) {
3953
- var vX = Matrix4.tempVec0;
3954
- var vY = Matrix4.tempVec1;
3955
- var vZ = Matrix4.tempVec2;
3956
- vZ.subtractVectors(eye, target);
3957
- vZ.normalize();
3958
- vX.crossVectors(up, vZ);
3959
- vX.normalize();
3960
- vY.crossVectors(vZ, vX);
3961
- var te = this.elements;
3962
- te[0] = vX.x;
3963
- te[1] = vY.x;
3964
- te[2] = vZ.x;
3965
- te[3] = 0;
3966
- te[4] = vX.y;
3967
- te[5] = vY.y;
3968
- te[6] = vZ.y;
3969
- te[7] = 0;
3970
- te[8] = vX.z;
3971
- te[9] = vY.z;
3972
- te[10] = vZ.z;
3973
- te[11] = 0;
3974
- te[12] = -vX.dot(eye);
3975
- te[13] = -vY.dot(eye);
3976
- te[14] = -vZ.dot(eye);
3977
- te[15] = 1;
3978
- return this;
3722
+ _proto.onUpdate = function onUpdate(dt) {
3723
+ var time = this.item.time;
3724
+ var _this_material_getVector4;
3725
+ var _Time = (_this_material_getVector4 = this.material.getVector4("_Time")) != null ? _this_material_getVector4 : new Vector4();
3726
+ this.material.setVector4("_Time", _Time.set(time / 20, time, time * 2, time * 3));
3979
3727
  };
3980
- /**
3981
- * 矩阵乘比例后相加
3982
- * @param right - 矩阵
3983
- * @param s - 比例
3984
- * @returns 相加结果
3985
- */ _proto.addScaledMatrix = function addScaledMatrix(right, s) {
3986
- var te = this.elements;
3987
- var re = right.elements;
3988
- for(var i = 0; i < 16; i++){
3989
- te[i] += re[i] * s;
3990
- }
3991
- return this;
3728
+ _proto.fromData = function fromData(data) {
3729
+ MeshComponent.prototype.fromData.call(this, data);
3730
+ this.material = this.materials[0];
3992
3731
  };
3993
- /**
3994
- * 矩阵右乘
3995
- * @param right - 右侧矩阵或数值
3996
- * @returns 右乘结果
3997
- */ _proto.multiply = function multiply(right) {
3998
- if (typeof right === "number") {
3999
- for(var i = 0; i < 16; i++){
4000
- this.elements[i] *= right;
4001
- }
4002
- return this;
4003
- } else {
4004
- return this.multiplyMatrices(this, right);
3732
+ return EffectComponent;
3733
+ }(MeshComponent);
3734
+ EffectComponent = __decorate([
3735
+ effectsClass(DataType.EffectComponent)
3736
+ ], EffectComponent);
3737
+
3738
+ var PostProcessVolume = /*#__PURE__*/ function(Behaviour) {
3739
+ _inherits(PostProcessVolume, Behaviour);
3740
+ function PostProcessVolume() {
3741
+ var _this;
3742
+ _this = Behaviour.apply(this, arguments) || this;
3743
+ // Bloom
3744
+ _this.bloomEnabled = true;
3745
+ _this.threshold = 1.0;
3746
+ _this.bloomIntensity = 1.0;
3747
+ // ColorAdjustments
3748
+ _this.brightness = 1.0;
3749
+ _this.saturation = 1.0;
3750
+ _this.contrast = 1.0;
3751
+ // Vignette
3752
+ _this.vignetteIntensity = 0.2;
3753
+ _this.vignetteSmoothness = 0.4;
3754
+ _this.vignetteRoundness = 1.0;
3755
+ // ToneMapping
3756
+ _this.toneMappingEnabled = true // 1: true, 0: false
3757
+ ;
3758
+ return _this;
3759
+ }
3760
+ var _proto = PostProcessVolume.prototype;
3761
+ _proto.onStart = function onStart() {
3762
+ var composition = this.item.composition;
3763
+ if (composition) {
3764
+ composition.renderFrame.globalVolume = this;
4005
3765
  }
4006
3766
  };
3767
+ return PostProcessVolume;
3768
+ }(Behaviour);
3769
+ __decorate([
3770
+ serialize()
3771
+ ], PostProcessVolume.prototype, "bloomEnabled", void 0);
3772
+ __decorate([
3773
+ serialize()
3774
+ ], PostProcessVolume.prototype, "threshold", void 0);
3775
+ __decorate([
3776
+ serialize()
3777
+ ], PostProcessVolume.prototype, "bloomIntensity", void 0);
3778
+ __decorate([
3779
+ serialize()
3780
+ ], PostProcessVolume.prototype, "brightness", void 0);
3781
+ __decorate([
3782
+ serialize()
3783
+ ], PostProcessVolume.prototype, "saturation", void 0);
3784
+ __decorate([
3785
+ serialize()
3786
+ ], PostProcessVolume.prototype, "contrast", void 0);
3787
+ __decorate([
3788
+ serialize()
3789
+ ], PostProcessVolume.prototype, "vignetteIntensity", void 0);
3790
+ __decorate([
3791
+ serialize()
3792
+ ], PostProcessVolume.prototype, "vignetteSmoothness", void 0);
3793
+ __decorate([
3794
+ serialize()
3795
+ ], PostProcessVolume.prototype, "vignetteRoundness", void 0);
3796
+ __decorate([
3797
+ serialize()
3798
+ ], PostProcessVolume.prototype, "toneMappingEnabled", void 0);
3799
+ PostProcessVolume = __decorate([
3800
+ effectsClass("PostProcessVolume")
3801
+ ], PostProcessVolume);
3802
+
3803
+ function _assert_this_initialized(self) {
3804
+ if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
3805
+ return self;
3806
+ }
3807
+
3808
+ /**
3809
+ * 四元数
3810
+ */ var Quaternion = /*#__PURE__*/ function() {
3811
+ function Quaternion(x, y, z, w) {
3812
+ if (x === void 0) x = 0;
3813
+ if (y === void 0) y = 0;
3814
+ if (z === void 0) z = 0;
3815
+ if (w === void 0) w = 1;
3816
+ this.x = x;
3817
+ this.y = y;
3818
+ this.z = z;
3819
+ this.w = w;
3820
+ }
3821
+ var _proto = Quaternion.prototype;
4007
3822
  /**
4008
- * 矩阵左乘
4009
- * @param left - 左侧矩阵
4010
- * @returns 左乘结果
4011
- */ _proto.premultiply = function premultiply(left) {
4012
- return this.multiplyMatrices(left, this);
4013
- };
4014
- /**
4015
- * 矩阵相乘
4016
- * @param left - 矩阵
4017
- * @param right - 矩阵
4018
- * @returns 相乘结果
4019
- */ _proto.multiplyMatrices = function multiplyMatrices(left, right) {
4020
- var ae = left.elements;
4021
- var be = right.elements;
4022
- var te = this.elements;
4023
- var a11 = ae[0], a12 = ae[4], a13 = ae[8], a14 = ae[12];
4024
- var a21 = ae[1], a22 = ae[5], a23 = ae[9], a24 = ae[13];
4025
- var a31 = ae[2], a32 = ae[6], a33 = ae[10], a34 = ae[14];
4026
- var a41 = ae[3], a42 = ae[7], a43 = ae[11], a44 = ae[15];
4027
- var b11 = be[0], b12 = be[4], b13 = be[8], b14 = be[12];
4028
- var b21 = be[1], b22 = be[5], b23 = be[9], b24 = be[13];
4029
- var b31 = be[2], b32 = be[6], b33 = be[10], b34 = be[14];
4030
- var b41 = be[3], b42 = be[7], b43 = be[11], b44 = be[15];
4031
- te[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
4032
- te[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
4033
- te[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
4034
- te[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
4035
- te[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
4036
- te[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
4037
- te[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
4038
- te[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
4039
- te[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
4040
- te[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
4041
- te[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
4042
- te[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
4043
- te[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
4044
- te[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
4045
- te[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
4046
- te[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
4047
- return this;
4048
- };
4049
- /**
4050
- * 矩阵缩放
4051
- * @param s - 缩放比例
4052
- * @returns 缩放结果
4053
- */ _proto.multiplyScalar = function multiplyScalar(s) {
4054
- var e = this.elements;
4055
- e[0] *= s;
4056
- e[4] *= s;
4057
- e[8] *= s;
4058
- e[12] *= s;
4059
- e[1] *= s;
4060
- e[5] *= s;
4061
- e[9] *= s;
4062
- e[13] *= s;
4063
- e[2] *= s;
4064
- e[6] *= s;
4065
- e[10] *= s;
4066
- e[14] *= s;
4067
- e[3] *= s;
4068
- e[7] *= s;
4069
- e[11] *= s;
4070
- e[15] *= s;
3823
+ * 四元数设置
3824
+ * @param x - x 分量
3825
+ * @param y - y 分量
3826
+ * @param z - z 分量
3827
+ * @param w - w 分量
3828
+ * @returns 四元数
3829
+ */ _proto.set = function set(x, y, z, w) {
3830
+ this.x = x;
3831
+ this.y = y;
3832
+ this.z = z;
3833
+ this.w = w;
4071
3834
  return this;
4072
3835
  };
4073
3836
  /**
4074
- * 矩阵求行列式值
4075
- * @returns 行列式值
4076
- */ _proto.determinant = function determinant() {
4077
- var e = this.elements;
4078
- var m11 = e[0], m12 = e[4], m13 = e[8], m14 = e[12];
4079
- var m21 = e[1], m22 = e[5], m23 = e[9], m24 = e[13];
4080
- var m31 = e[2], m32 = e[6], m33 = e[10], m34 = e[14];
4081
- var m41 = e[3], m42 = e[7], m43 = e[11], m44 = e[15];
4082
- return m41 * (+m14 * m23 * m32 - m13 * m24 * m32 - m14 * m22 * m33 + m12 * m24 * m33 + m13 * m22 * m34 - m12 * m23 * m34) + m42 * (+m11 * m23 * m34 - m11 * m24 * m33 + m14 * m21 * m33 - m13 * m21 * m34 + m13 * m24 * m31 - m14 * m23 * m31) + m43 * (+m11 * m24 * m32 - m11 * m22 * m34 - m14 * m21 * m32 + m12 * m21 * m34 + m14 * m22 * m31 - m12 * m24 * m31) + m44 * (-m13 * m22 * m31 - m11 * m23 * m32 + m11 * m22 * m33 + m13 * m21 * m32 - m12 * m21 * m33 + m12 * m23 * m31);
4083
- };
4084
- /**
4085
- * 矩阵转置
4086
- * @returns 转置结果
4087
- */ _proto.transpose = function transpose() {
4088
- var e = this.elements;
4089
- var t;
4090
- t = e[1];
4091
- e[1] = e[4];
4092
- e[4] = t;
4093
- t = e[2];
4094
- e[2] = e[8];
4095
- e[8] = t;
4096
- t = e[3];
4097
- e[3] = e[12];
4098
- e[12] = t;
4099
- //
4100
- t = e[6];
4101
- e[6] = e[9];
4102
- e[9] = t;
4103
- t = e[7];
4104
- e[7] = e[13];
4105
- e[13] = t;
4106
- t = e[11];
4107
- e[11] = e[14];
4108
- e[14] = t;
3837
+ * 通过欧拉角设置四元数
3838
+ * @param euler - 欧拉角
3839
+ * @returns
3840
+ */ _proto.setFromEuler = function setFromEuler(euler) {
3841
+ euler.toQuaternion(this);
4109
3842
  return this;
4110
3843
  };
4111
3844
  /**
4112
- * 矩阵求逆
4113
- * @returns 逆矩阵
4114
- */ _proto.invert = function invert() {
4115
- // based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
4116
- var e = this.elements;
4117
- var m11 = e[0], m21 = e[1], m31 = e[2], m41 = e[3];
4118
- var m12 = e[4], m22 = e[5], m32 = e[6], m42 = e[7];
4119
- var m13 = e[8], m23 = e[9], m33 = e[10], m43 = e[11];
4120
- var m14 = e[12], m24 = e[13], m34 = e[14], m44 = e[15];
4121
- var t11 = m23 * m34 * m42 - m24 * m33 * m42 + m24 * m32 * m43 - m22 * m34 * m43 - m23 * m32 * m44 + m22 * m33 * m44;
4122
- var t12 = m14 * m33 * m42 - m13 * m34 * m42 - m14 * m32 * m43 + m12 * m34 * m43 + m13 * m32 * m44 - m12 * m33 * m44;
4123
- var t13 = m13 * m24 * m42 - m14 * m23 * m42 + m14 * m22 * m43 - m12 * m24 * m43 - m13 * m22 * m44 + m12 * m23 * m44;
4124
- var t14 = m14 * m23 * m32 - m13 * m24 * m32 - m14 * m22 * m33 + m12 * m24 * m33 + m13 * m22 * m34 - m12 * m23 * m34;
4125
- var det = m11 * t11 + m21 * t12 + m31 * t13 + m41 * t14;
4126
- if (det === 0) {
4127
- return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
4128
- }
4129
- var detInv = 1 / det;
4130
- e[0] = t11 * detInv;
4131
- e[1] = (m24 * m33 * m41 - m23 * m34 * m41 - m24 * m31 * m43 + m21 * m34 * m43 + m23 * m31 * m44 - m21 * m33 * m44) * detInv;
4132
- e[2] = (m22 * m34 * m41 - m24 * m32 * m41 + m24 * m31 * m42 - m21 * m34 * m42 - m22 * m31 * m44 + m21 * m32 * m44) * detInv;
4133
- e[3] = (m23 * m32 * m41 - m22 * m33 * m41 - m23 * m31 * m42 + m21 * m33 * m42 + m22 * m31 * m43 - m21 * m32 * m43) * detInv;
4134
- e[4] = t12 * detInv;
4135
- e[5] = (m13 * m34 * m41 - m14 * m33 * m41 + m14 * m31 * m43 - m11 * m34 * m43 - m13 * m31 * m44 + m11 * m33 * m44) * detInv;
4136
- e[6] = (m14 * m32 * m41 - m12 * m34 * m41 - m14 * m31 * m42 + m11 * m34 * m42 + m12 * m31 * m44 - m11 * m32 * m44) * detInv;
4137
- e[7] = (m12 * m33 * m41 - m13 * m32 * m41 + m13 * m31 * m42 - m11 * m33 * m42 - m12 * m31 * m43 + m11 * m32 * m43) * detInv;
4138
- e[8] = t13 * detInv;
4139
- e[9] = (m14 * m23 * m41 - m13 * m24 * m41 - m14 * m21 * m43 + m11 * m24 * m43 + m13 * m21 * m44 - m11 * m23 * m44) * detInv;
4140
- e[10] = (m12 * m24 * m41 - m14 * m22 * m41 + m14 * m21 * m42 - m11 * m24 * m42 - m12 * m21 * m44 + m11 * m22 * m44) * detInv;
4141
- e[11] = (m13 * m22 * m41 - m12 * m23 * m41 - m13 * m21 * m42 + m11 * m23 * m42 + m12 * m21 * m43 - m11 * m22 * m43) * detInv;
4142
- e[12] = t14 * detInv;
4143
- e[13] = (m13 * m24 * m31 - m14 * m23 * m31 + m14 * m21 * m33 - m11 * m24 * m33 - m13 * m21 * m34 + m11 * m23 * m34) * detInv;
4144
- e[14] = (m14 * m22 * m31 - m12 * m24 * m31 - m14 * m21 * m32 + m11 * m24 * m32 + m12 * m21 * m34 - m11 * m22 * m34) * detInv;
4145
- e[15] = (m12 * m23 * m31 - m13 * m22 * m31 + m13 * m21 * m32 - m11 * m23 * m32 - m12 * m21 * m33 + m11 * m22 * m33) * detInv;
3845
+ * 通过旋转轴和旋转角度设置四元数
3846
+ * @param axis - 旋转轴
3847
+ * @param angle - 旋转角度(弧度)
3848
+ * @returns
3849
+ */ _proto.setFromAxisAngle = function setFromAxisAngle(axis, angle) {
3850
+ var halfAngle = angle / 2;
3851
+ var s = Math.sin(halfAngle);
3852
+ var v = Quaternion.tempVec0;
3853
+ v.copyFrom(axis).normalize();
3854
+ this.x = v.x * s;
3855
+ this.y = v.y * s;
3856
+ this.z = v.z * s;
3857
+ this.w = Math.cos(halfAngle);
4146
3858
  return this;
4147
3859
  };
4148
3860
  /**
4149
- * 提取基轴
4150
- * @param xAxis - 提取的 x 轴
4151
- * @param yAxis - 提取的 y 轴
4152
- * @param zAxis - 提取的 z 轴
3861
+ * 通过 Vector4Like 创建四元数
3862
+ * @param v - Vector4Like
4153
3863
  * @returns
4154
- */ _proto.extractBasis = function extractBasis(xAxis, yAxis, zAxis) {
4155
- var te = this.elements;
4156
- xAxis.set(te[0], te[1], te[2]);
4157
- yAxis.set(te[4], te[5], te[6]);
4158
- zAxis.set(te[8], te[9], te[10]);
3864
+ */ _proto.setFromVector4 = function setFromVector4(v) {
3865
+ this.x = v.x;
3866
+ this.y = v.y;
3867
+ this.z = v.z;
3868
+ this.w = v.w;
4159
3869
  return this;
4160
3870
  };
4161
3871
  /**
4162
- * 根据基础信息组装矩阵
4163
- * @param translation - 位置信息
4164
- * @param rotation - 旋转信息
4165
- * @param scale - 缩放信息
4166
- * @param [anchor] - 锚点信息
4167
- * @returns 矩阵
4168
- */ _proto.compose = function compose(translation, rotation, scale, anchor) {
4169
- if (anchor === void 0) anchor = Vector3.ZERO;
4170
- var te = this.elements;
4171
- var x = rotation.x, y = rotation.y, z = rotation.z, w = rotation.w;
4172
- var l = -anchor.x;
4173
- var m = -anchor.y;
4174
- var n = -anchor.z;
4175
- var x2 = x + x;
4176
- var y2 = y + y;
4177
- var z2 = z + z;
4178
- var xx = x * x2;
4179
- var xy = x * y2;
4180
- var xz = x * z2;
4181
- var yy = y * y2;
4182
- var yz = y * z2;
4183
- var zz = z * z2;
4184
- var wx = w * x2;
4185
- var wy = w * y2;
4186
- var wz = w * z2;
4187
- var sx = scale.x, sy = scale.y, sz = scale.z;
4188
- te[0] = (1 - (yy + zz)) * sx;
4189
- te[1] = (xy + wz) * sx;
4190
- te[2] = (xz - wy) * sx;
4191
- te[3] = 0;
4192
- te[4] = (xy - wz) * sy;
4193
- te[5] = (1 - (xx + zz)) * sy;
4194
- te[6] = (yz + wx) * sy;
4195
- te[7] = 0;
4196
- te[8] = (xz + wy) * sz;
4197
- te[9] = (yz - wx) * sz;
4198
- te[10] = (1 - (xx + yy)) * sz;
4199
- te[11] = 0;
4200
- te[12] = l * te[0] + m * te[4] + n * te[8] - l + translation.x;
4201
- te[13] = l * te[1] + m * te[5] + n * te[9] - m + translation.y;
4202
- te[14] = l * te[2] + m * te[6] + n * te[10] - n + translation.z;
3872
+ * 通过数组设置四元数
3873
+ * @param array - 数组
3874
+ * @param [offset=0] - 起始偏移值
3875
+ * @returns
3876
+ */ _proto.setFromArray = function setFromArray(array, offset) {
3877
+ if (offset === void 0) offset = 0;
3878
+ this.x = array[offset];
3879
+ this.y = array[offset + 1];
3880
+ this.z = array[offset + 2];
3881
+ this.w = array[offset + 3];
4203
3882
  return this;
4204
3883
  };
4205
3884
  /**
4206
- * 矩阵拆分为基础信息
4207
- * @param translation - 位置信息
4208
- * @param rotation - 旋转信息
4209
- * @param scale - 缩放信息
4210
- * @returns 矩阵
4211
- */ _proto.decompose = function decompose(translation, rotation, scale) {
4212
- var v = Matrix4.tempVec0;
4213
- var te = this.elements;
4214
- var sx = v.set(te[0], te[1], te[2]).length();
4215
- var sy = v.set(te[4], te[5], te[6]).length();
4216
- var sz = v.set(te[8], te[9], te[10]).length();
4217
- // if determine is negative, we need to invert one scale
4218
- var det = this.determinant();
4219
- if (det < 0) {
4220
- sx = -sx;
3885
+ * 通过矩阵设置四元数
3886
+ * @param m - 矩阵
3887
+ * @returns
3888
+ */ _proto.setFromRotationMatrix = function setFromRotationMatrix(m) {
3889
+ // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
3890
+ // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
3891
+ var te = m.elements;
3892
+ var m11 = te[0];
3893
+ var m12 = te[4];
3894
+ var m13 = te[8];
3895
+ var m21 = te[1];
3896
+ var m22 = te[5];
3897
+ var m23 = te[9];
3898
+ var m31 = te[2];
3899
+ var m32 = te[6];
3900
+ var m33 = te[10];
3901
+ var trace = m11 + m22 + m33;
3902
+ if (trace > 0) {
3903
+ var s = 0.5 / Math.sqrt(trace + 1.0);
3904
+ this.w = 0.25 / s;
3905
+ this.x = (m32 - m23) * s;
3906
+ this.y = (m13 - m31) * s;
3907
+ this.z = (m21 - m12) * s;
3908
+ } else if (m11 > m22 && m11 > m33) {
3909
+ var s1 = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
3910
+ this.w = (m32 - m23) / s1;
3911
+ this.x = 0.25 * s1;
3912
+ this.y = (m12 + m21) / s1;
3913
+ this.z = (m13 + m31) / s1;
3914
+ this.negate();
3915
+ } else if (m22 > m33) {
3916
+ var s2 = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
3917
+ this.w = (m13 - m31) / s2;
3918
+ this.x = (m12 + m21) / s2;
3919
+ this.y = 0.25 * s2;
3920
+ this.z = (m23 + m32) / s2;
3921
+ this.negate();
3922
+ } else {
3923
+ var s3 = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
3924
+ this.w = (m21 - m12) / s3;
3925
+ this.x = (m13 + m31) / s3;
3926
+ this.y = (m23 + m32) / s3;
3927
+ this.z = 0.25 * s3;
3928
+ this.negate();
4221
3929
  }
4222
- translation.x = te[12];
4223
- translation.y = te[13];
4224
- translation.z = te[14];
4225
- // scale the rotation part
4226
- var m = Matrix4.tempMat0;
4227
- m.copyFrom(this);
4228
- var invSX = 1 / sx;
4229
- var invSY = 1 / sy;
4230
- var invSZ = 1 / sz;
4231
- m.elements[0] *= invSX;
4232
- m.elements[1] *= invSX;
4233
- m.elements[2] *= invSX;
4234
- m.elements[4] *= invSY;
4235
- m.elements[5] *= invSY;
4236
- m.elements[6] *= invSY;
4237
- m.elements[8] *= invSZ;
4238
- m.elements[9] *= invSZ;
4239
- m.elements[10] *= invSZ;
4240
- rotation.setFromRotationMatrix(m);
4241
- scale.x = sx;
4242
- scale.y = sy;
4243
- scale.z = sz;
3930
+ // 兼容原先数学库
4244
3931
  return this;
4245
3932
  };
4246
- _proto.getTranslation = function getTranslation(translation) {
4247
- var te = this.elements;
4248
- return translation.set(te[12], te[13], te[14]);
3933
+ /**
3934
+ * 通过开始和结束向量设置四元数
3935
+ * @param from - 开始向量
3936
+ * @param to - 结束向量
3937
+ * @returns
3938
+ */ _proto.setFromUnitVectors = function setFromUnitVectors(from, to) {
3939
+ // assumes direction vectors vFrom and vTo are normalized
3940
+ var r = from.dot(to) + 1;
3941
+ if (r < Number.EPSILON) {
3942
+ r = 0;
3943
+ if (Math.abs(from.x) > Math.abs(from.z)) {
3944
+ this.x = -from.y;
3945
+ this.y = from.x;
3946
+ this.z = 0;
3947
+ this.w = r;
3948
+ } else {
3949
+ this.x = 0;
3950
+ this.y = -from.z;
3951
+ this.z = from.y;
3952
+ this.w = r;
3953
+ }
3954
+ } else {
3955
+ this.x = from.y * to.z - from.z * to.y;
3956
+ this.y = from.z * to.x - from.x * to.z;
3957
+ this.z = from.x * to.y - from.y * to.x;
3958
+ this.w = r;
3959
+ }
3960
+ return this.normalize();
4249
3961
  };
4250
- _proto.getScale = function getScale(scale) {
4251
- var te = this.elements;
4252
- return scale.set(Math.hypot(te[0], te[1], te[2]), Math.hypot(te[4], te[5], te[6]), Math.hypot(te[8], te[9], te[10]));
3962
+ /**
3963
+ * 四元数拷贝
3964
+ * @param quat - 拷贝目标四元数
3965
+ * @returns 拷贝四元数
3966
+ */ _proto.copyFrom = function copyFrom(quat) {
3967
+ this.x = quat.x;
3968
+ this.y = quat.y;
3969
+ this.z = quat.z;
3970
+ this.w = quat.w;
3971
+ return this;
4253
3972
  };
4254
3973
  /**
4255
- * 获得矩阵分解的结果
4256
- * @returns 分解的结果
4257
- */ _proto.getTransform = function getTransform() {
4258
- var translation = new Vector3();
4259
- var rotation = new Quaternion();
4260
- var scale = new Vector3();
4261
- this.decompose(translation, rotation, scale);
4262
- return {
4263
- translation: translation,
4264
- rotation: rotation,
4265
- scale: scale
4266
- };
3974
+ * 四元数克隆
3975
+ * @returns 克隆结果
3976
+ */ _proto.clone = function clone() {
3977
+ return new Quaternion(this.x, this.y, this.z, this.w);
4267
3978
  };
4268
3979
  /**
4269
- * 根据视窗信息设置正交相机投影矩阵
4270
- * @param left - 视窗左平面位置
4271
- * @param right - 视窗右平面位置
4272
- * @param top - 视窗上平面位置
4273
- * @param bottom - 视窗下平面位置
4274
- * @param near - 视窗近平面位置
4275
- * @param far - 视窗远平面位置
4276
- * @returns 矩阵
4277
- */ _proto.orthographic = function orthographic(left, right, top, bottom, near, far) {
4278
- var a = 1.0 / (right - left);
4279
- var b = 1.0 / (top - bottom);
4280
- var c = 1.0 / (far - near);
4281
- var tx = -(right + left) * a;
4282
- var ty = -(top + bottom) * b;
4283
- var tz = -(far + near) * c;
4284
- a *= 2.0;
4285
- b *= 2.0;
4286
- c *= -2.0;
4287
- var te = this.elements;
4288
- te[0] = a;
4289
- te[1] = 0.0;
4290
- te[2] = 0.0;
4291
- te[3] = 0.0;
4292
- //
4293
- te[4] = 0.0;
4294
- te[5] = b;
4295
- te[6] = 0.0;
4296
- te[7] = 0.0;
4297
- //
4298
- te[8] = 0.0;
4299
- te[9] = 0.0;
4300
- te[10] = c;
4301
- te[11] = 0.0;
4302
- //
4303
- te[12] = tx;
4304
- te[13] = ty;
4305
- te[14] = tz;
4306
- te[15] = 1.0;
4307
- return this;
3980
+ * 四元数间的夹角计算
3981
+ * @param other - 其他四元数
3982
+ * @returns 夹角
3983
+ */ _proto.angleTo = function angleTo(other) {
3984
+ return 2 * Math.acos(Math.abs(clamp$1(this.dot(other), -1, 1)));
4308
3985
  };
4309
3986
  /**
4310
- * 通过透视相机基础参数设置投影矩阵
4311
- * @param fov - 视角(弧度)
4312
- * @param aspect - 视窗比例
4313
- * @param near - 近平面
4314
- * @param far - 远平面
4315
- * @param [reverse] - 视锥体长宽反转(3D这里反了?)
4316
- * @returns 投影矩阵
4317
- */ _proto.perspective = function perspective(fov, aspect, near, far, reverse) {
4318
- var f = 1.0 / Math.tan(fov * 0.5);
4319
- var nf = 1 / (near - far);
4320
- var te = this.elements;
4321
- te[0] = reverse ? f : f / aspect;
4322
- te[1] = 0;
4323
- te[2] = 0;
4324
- te[3] = 0;
4325
- //
4326
- te[4] = 0;
4327
- te[5] = reverse ? f * aspect : f;
4328
- te[6] = 0;
4329
- te[7] = 0;
4330
- //
4331
- te[8] = 0;
4332
- te[9] = 0;
4333
- te[10] = (far + near) * nf;
4334
- te[11] = -1;
4335
- //
4336
- te[12] = 0;
4337
- te[13] = 0;
4338
- te[14] = 2 * far * near * nf;
4339
- te[15] = 0;
4340
- if (far === null || far === Infinity) {
4341
- te[10] = -1;
4342
- te[14] = -2 * near;
3987
+ * 四元数向目标旋转
3988
+ * @param q - 四元数
3989
+ * @param step - 旋转弧度
3990
+ * @returns 目标四元数
3991
+ */ _proto.rotateTowards = function rotateTowards(q, step) {
3992
+ var angle = this.angleTo(q);
3993
+ if (angle === 0) {
3994
+ return this;
4343
3995
  }
3996
+ var t = Math.min(1, step / angle);
3997
+ this.slerp(q, t);
4344
3998
  return this;
4345
3999
  };
4346
4000
  /**
4347
- * 对点进行投影变换
4348
- * @param v - 输入点
4349
- * @param [out] - 输出点,如果没有就覆盖输入的数据
4350
- * @returns 投影后的点
4351
- */ _proto.projectPoint = function projectPoint(v, out) {
4352
- var x = v.x, y = v.y, z = v.z;
4353
- var e = this.elements;
4354
- var res = out != null ? out : v;
4355
- res.x = e[0] * x + e[4] * y + e[8] * z + e[12];
4356
- res.y = e[1] * x + e[5] * y + e[9] * z + e[13];
4357
- res.z = e[2] * x + e[6] * y + e[10] * z + e[14];
4358
- var w = e[3] * x + e[7] * y + e[11] * z + e[15];
4359
- return res.multiply(1 / w);
4001
+ * 四元数单位化
4002
+ * @returns 单位四元数
4003
+ */ _proto.identity = function identity() {
4004
+ return this.set(0, 0, 0, 1);
4360
4005
  };
4361
4006
  /**
4362
- * 对点进行矩阵变换
4363
- * @param v - 输入点
4364
- * @param [out] - 输出点,如果没有就覆盖输入的数据
4365
- * @returns 变换后的点
4366
- */ _proto.transformPoint = function transformPoint(v, out) {
4367
- var x = v.x, y = v.y, z = v.z;
4368
- var e = this.elements;
4369
- var res = out != null ? out : v;
4370
- res.x = e[0] * x + e[4] * y + e[8] * z + e[12];
4371
- res.y = e[1] * x + e[5] * y + e[9] * z + e[13];
4372
- res.z = e[2] * x + e[6] * y + e[10] * z + e[14];
4373
- return res;
4007
+ * 四元数求逆
4008
+ * @returns 四元数的逆
4009
+ */ _proto.invert = function invert() {
4010
+ return this.conjugate();
4374
4011
  };
4375
4012
  /**
4376
- * 对法向量进行矩阵变换
4377
- * @param v - 输入法向量
4378
- * @param [out] - 输出法向量,如果没有就覆盖输入的数据
4379
- * @returns 变换后的法向量
4380
- */ _proto.transformNormal = function transformNormal(v, out) {
4381
- var x = v.x, y = v.y, z = v.z;
4382
- var e = this.elements;
4383
- var res = out != null ? out : v;
4384
- res.x = e[0] * x + e[4] * y + e[8] * z;
4385
- res.y = e[1] * x + e[5] * y + e[9] * z;
4386
- res.z = e[2] * x + e[6] * y + e[10] * z;
4387
- return res.normalize();
4013
+ * 四元数取负
4014
+ * @returns 负四元数
4015
+ */ _proto.negate = function negate() {
4016
+ this.x = -this.x;
4017
+ this.y = -this.y;
4018
+ this.z = -this.z;
4019
+ this.w = -this.w;
4020
+ return this;
4388
4021
  };
4389
4022
  /**
4390
- * 对四维向量进行矩阵变换
4391
- * @param v - 输入向量
4392
- * @param [out] - 输出向量,如果没有就覆盖输入的数据
4393
- * @returns 变换后向量
4394
- */ _proto.transformVector4 = function transformVector4(v, out) {
4395
- var x = v.x, y = v.y, z = v.z, w = v.w;
4396
- var e = this.elements;
4397
- var res = out != null ? out : v;
4398
- res.x = e[0] * x + e[4] * y + e[8] * z + e[12] * w;
4399
- res.y = e[1] * x + e[5] * y + e[9] * z + e[13] * w;
4400
- res.z = e[2] * x + e[6] * y + e[10] * z + e[14] * w;
4401
- res.w = e[3] * x + e[7] * y + e[11] * z + e[15] * w;
4402
- return res;
4023
+ * 四元数求共轭值
4024
+ * @returns 四元数的共轭值
4025
+ */ _proto.conjugate = function conjugate() {
4026
+ this.x = -this.x;
4027
+ this.y = -this.y;
4028
+ this.z = -this.z;
4029
+ return this;
4030
+ };
4031
+ /**
4032
+ * 四元数点乘结果
4033
+ * @param v
4034
+ * @return
4035
+ */ _proto.dot = function dot(v) {
4036
+ return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
4037
+ };
4038
+ /**
4039
+ * 四元数的模平方
4040
+ * @return
4041
+ */ _proto.lengthSquared = function lengthSquared() {
4042
+ return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
4403
4043
  };
4404
4044
  /**
4405
- * 矩阵判等
4406
- * @param matrix - 矩阵
4407
- * @returns 判等结果
4408
- */ _proto.equals = function equals(matrix) {
4409
- var te = this.elements;
4410
- var me = matrix.elements;
4411
- for(var i = 0; i < 16; i++){
4412
- if (!isEqual(te[i], me[i])) {
4413
- return false;
4414
- }
4045
+ * 四元数的欧式长度
4046
+ * @returns 长度
4047
+ */ _proto.length = function length() {
4048
+ return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
4049
+ };
4050
+ /**
4051
+ * 四元数归一化
4052
+ * @returns 归一化值
4053
+ */ _proto.normalize = function normalize() {
4054
+ var l = this.length();
4055
+ if (l === 0) {
4056
+ this.x = 0;
4057
+ this.y = 0;
4058
+ this.z = 0;
4059
+ this.w = 1;
4060
+ } else {
4061
+ l = 1 / l;
4062
+ this.x = this.x * l;
4063
+ this.y = this.y * l;
4064
+ this.z = this.z * l;
4065
+ this.w = this.w * l;
4415
4066
  }
4416
- return true;
4067
+ return this;
4417
4068
  };
4418
4069
  /**
4419
- * 矩阵转数组
4070
+ * 四元数右乘
4071
+ * @param right - 右乘的四元数
4420
4072
  * @returns
4421
- */ _proto.toArray = function toArray() {
4422
- return [].concat(this.elements);
4423
- };
4424
- _proto.fill = function fill(array, offset) {
4425
- if (offset === void 0) offset = 0;
4426
- var te = this.elements;
4427
- array[offset] = te[0];
4428
- array[offset + 1] = te[1];
4429
- array[offset + 2] = te[2];
4430
- array[offset + 3] = te[3];
4431
- array[offset + 4] = te[4];
4432
- array[offset + 5] = te[5];
4433
- array[offset + 6] = te[6];
4434
- array[offset + 7] = te[7];
4435
- array[offset + 8] = te[8];
4436
- array[offset + 9] = te[9];
4437
- array[offset + 10] = te[10];
4438
- array[offset + 11] = te[11];
4439
- array[offset + 12] = te[12];
4440
- array[offset + 13] = te[13];
4441
- array[offset + 14] = te[14];
4442
- array[offset + 15] = te[15];
4073
+ */ _proto.multiply = function multiply(right) {
4074
+ return this.multiplyQuaternions(this, right);
4443
4075
  };
4444
4076
  /**
4445
- * 创建单位阵
4446
- * @returns 单位矩阵
4447
- */ Matrix4.fromIdentity = function fromIdentity() {
4448
- return new Matrix4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
4077
+ * 四元数左乘
4078
+ * @param left - 左乘的四元数
4079
+ * @returns
4080
+ */ _proto.premultiply = function premultiply(left) {
4081
+ return this.multiplyQuaternions(left, this);
4449
4082
  };
4450
4083
  /**
4451
- * 创建相机矩阵
4452
- * @param eye - 相机位置
4453
- * @param target - 目标位置
4454
- * @param up - 相机方向
4455
- * @returns 矩阵
4456
- */ Matrix4.fromLookAt = function fromLookAt(eye, target, up) {
4457
- return new Matrix4().lookAt(eye, target, up);
4084
+ * 四元数乘法
4085
+ * @param left - 四元数
4086
+ * @param right - 四元数
4087
+ * @returns 四元数
4088
+ */ _proto.multiplyQuaternions = function multiplyQuaternions(left, right) {
4089
+ // from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
4090
+ var qax = left.x;
4091
+ var qay = left.y;
4092
+ var qaz = left.z;
4093
+ var qaw = left.w;
4094
+ var qbx = right.x;
4095
+ var qby = right.y;
4096
+ var qbz = right.z;
4097
+ var qbw = right.w;
4098
+ this.x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;
4099
+ this.y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;
4100
+ this.z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;
4101
+ this.w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;
4102
+ return this;
4458
4103
  };
4459
4104
  /**
4460
- * 创建投影矩阵
4461
- * @param fov - 视角
4462
- * @param aspect - 视窗比例
4463
- * @param near - 近平面
4464
- * @param far - 远平面
4465
- * @param [reverse] - 视锥体长宽反转
4466
- * @returns 投影矩阵
4467
- */ Matrix4.fromPerspective = function fromPerspective(fov, aspect, near, far, reverse) {
4468
- return new Matrix4().perspective(fov, aspect, near, far, reverse);
4105
+ * 四元数线性插值
4106
+ * @see http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/
4107
+ * @param other - 四元数
4108
+ * @param t - 插值比
4109
+ * @returns 插值结果
4110
+ */ _proto.slerp = function slerp(other, t) {
4111
+ if (t === 0) {
4112
+ return this;
4113
+ }
4114
+ if (t === 1) {
4115
+ return this.copyFrom(other);
4116
+ }
4117
+ var _this = this, x = _this.x, y = _this.y, z = _this.z, w = _this.w;
4118
+ var cosHalfTheta = w * other.w + x * other.x + y * other.y + z * other.z;
4119
+ if (cosHalfTheta < 0) {
4120
+ this.w = -other.w;
4121
+ this.x = -other.x;
4122
+ this.y = -other.y;
4123
+ this.z = -other.z;
4124
+ cosHalfTheta = -cosHalfTheta;
4125
+ } else {
4126
+ this.copyFrom(other);
4127
+ }
4128
+ if (cosHalfTheta >= 1.0) {
4129
+ this.w = w;
4130
+ this.x = x;
4131
+ this.y = y;
4132
+ this.z = z;
4133
+ return this;
4134
+ }
4135
+ var sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta;
4136
+ if (sqrSinHalfTheta <= Number.EPSILON) {
4137
+ var s = 1 - t;
4138
+ this.w = s * w + t * this.w;
4139
+ this.x = s * x + t * this.x;
4140
+ this.y = s * y + t * this.y;
4141
+ this.z = s * z + t * this.z;
4142
+ this.normalize();
4143
+ return this;
4144
+ }
4145
+ var sinHalfTheta = Math.sqrt(sqrSinHalfTheta);
4146
+ var halfTheta = Math.atan2(sinHalfTheta, cosHalfTheta);
4147
+ var ratioA = Math.sin((1 - t) * halfTheta) / sinHalfTheta;
4148
+ var ratioB = Math.sin(t * halfTheta) / sinHalfTheta;
4149
+ this.w = w * ratioA + this.w * ratioB;
4150
+ this.x = x * ratioA + this.x * ratioB;
4151
+ this.y = y * ratioA + this.y * ratioB;
4152
+ this.z = z * ratioA + this.z * ratioB;
4153
+ return this;
4469
4154
  };
4470
4155
  /**
4471
- * 通过四个列向量创建矩阵
4472
- * @param c1 - 第一列
4473
- * @param c2 - 第二列
4474
- * @param c3 - 第三列
4475
- * @param c4 - 第四列
4476
- * @returns
4477
- */ Matrix4.fromColumnVectors = function fromColumnVectors(c1, c2, c3, c4) {
4478
- return new Matrix4().setFromColumnVectors(c1, c2, c3, c4);
4156
+ * 两个四元数的线性插值
4157
+ * @param qa - 四元数
4158
+ * @param qb - 四元数
4159
+ * @param t - 插值比
4160
+ */ _proto.slerpQuaternions = function slerpQuaternions(qa, qb, t) {
4161
+ this.copyFrom(qa).slerp(qb, t);
4479
4162
  };
4480
4163
  /**
4481
- * 通过三阶矩阵创建矩阵
4482
- * @param m - 三阶矩阵
4483
- * @returns 创建的矩阵
4484
- */ Matrix4.fromMatrix3 = function fromMatrix3(m) {
4485
- return new Matrix4().setFromMatrix3(m);
4164
+ * 通过四元数旋转向量
4165
+ * @param v - 待旋转向量
4166
+ * @param [out] - 旋转结果,如果没有传入直接覆盖输入值
4167
+ * @returns
4168
+ */ _proto.rotateVector3 = function rotateVector3(v, out) {
4169
+ var _this = this, qx = _this.x, qy = _this.y, qz = _this.z, qw = _this.w;
4170
+ var vx = v.x, vy = v.y, vz = v.z;
4171
+ var ix = qw * vx + qy * vz - qz * vy;
4172
+ var iy = qw * vy + qz * vx - qx * vz;
4173
+ var iz = qw * vz + qx * vy - qy * vx;
4174
+ var iw = -qx * vx - qy * vy - qz * vz;
4175
+ var res = out != null ? out : v;
4176
+ res.x = ix * qw + iw * -qx + iy * -qz - iz * -qy;
4177
+ res.y = iy * qw + iw * -qy + iz * -qx - ix * -qz;
4178
+ res.z = iz * qw + iw * -qz + ix * -qy - iy * -qx;
4179
+ return res;
4486
4180
  };
4487
4181
  /**
4488
- * 通过数组创建矩阵
4489
- * @param array - 数组
4490
- * @param [offset=0] - 起始偏移值
4491
- * @returns 矩阵
4492
- */ Matrix4.fromArray = function fromArray(array, offset) {
4493
- if (offset === void 0) offset = 0;
4494
- return new Matrix4().setFromArray(array, offset);
4182
+ * 四元数判等
4183
+ * @param quaternion - 四元数
4184
+ * @returns 判等结果
4185
+ */ _proto.equals = function equals(quaternion) {
4186
+ return quaternion.x === this.x && quaternion.y === this.y && quaternion.z === this.z && quaternion.w === this.w;
4495
4187
  };
4496
4188
  /**
4497
- * 通过缩放创建矩阵
4498
- * @param x - x 缩放
4499
- * @param y - y 缩放
4500
- * @param z - z 缩放
4501
- * @returns 缩放结果
4502
- */ Matrix4.fromScale = function fromScale(x, y, z) {
4503
- return new Matrix4().setFromScale(x, y, z);
4189
+ * 四元数保存为数组
4190
+ * @returns
4191
+ */ _proto.toArray = function toArray() {
4192
+ return [
4193
+ this.x,
4194
+ this.y,
4195
+ this.z,
4196
+ this.w
4197
+ ];
4504
4198
  };
4505
4199
  /**
4506
- * 通过平移创建矩阵
4507
- * @param x - x 平移
4508
- * @param y - y 平移
4509
- * @param z - z 平移
4510
- * @returns 平移结果
4511
- */ Matrix4.fromTranslation = function fromTranslation(x, y, z) {
4512
- return new Matrix4().setFromTranslation(x, y, z);
4200
+ * 四元数转四维向量数组
4201
+ * @param vec - 目标保存对象
4202
+ * @returns 保存结果
4203
+ */ _proto.toVector4 = function toVector4(vec) {
4204
+ return vec.set(this.x, this.y, this.z, this.w);
4513
4205
  };
4514
4206
  /**
4515
- * 通过 x 轴旋转创建矩阵
4516
- * @param theta - x 轴旋转弧度
4517
- * @returns 矩阵
4518
- */ Matrix4.fromRotationX = function fromRotationX(theta) {
4519
- return new Matrix4().setFromRotationX(theta);
4207
+ * 四元数转欧拉角
4208
+ * @param euler - 目标欧拉角
4209
+ * @returns 欧拉角
4210
+ */ _proto.toEuler = function toEuler(euler) {
4211
+ return euler.setFromQuaternion(this);
4520
4212
  };
4521
4213
  /**
4522
- * 通过 y 轴旋转创建矩阵
4523
- * @param theta - y 轴旋转弧度
4524
- * @returns 矩阵
4525
- */ Matrix4.fromRotationY = function fromRotationY(theta) {
4526
- return new Matrix4().setFromRotationY(theta);
4214
+ * 四元数转矩阵
4215
+ * @param mat - 目标矩阵
4216
+ * @returns
4217
+ */ _proto.toMatrix4 = function toMatrix4(mat) {
4218
+ return mat.compose(Vector3.ZERO, this, Vector3.ONE);
4527
4219
  };
4528
4220
  /**
4529
- * 通过 z 轴旋转创建矩阵
4530
- * @param theta - z 轴旋转弧度
4531
- * @returns
4532
- */ Matrix4.fromRotationZ = function fromRotationZ(theta) {
4533
- return new Matrix4().setFromRotationZ(theta);
4221
+ * 通过欧拉角创建四元数
4222
+ * @param euler - 欧拉角
4223
+ * @returns 四元数
4224
+ */ Quaternion.fromEuler = function fromEuler(euler) {
4225
+ return new Quaternion().setFromEuler(euler);
4534
4226
  };
4535
4227
  /**
4536
- * 通过旋转轴与旋转弧度创建矩阵
4228
+ * 通过旋转轴和旋转角度创建四元数
4537
4229
  * @param axis - 旋转轴
4538
- * @param angle - 旋转弧度
4539
- * @returns
4540
- */ Matrix4.fromRotationAxis = function fromRotationAxis(axis, angle) {
4541
- return new Matrix4().setFromRotationAxis(axis, angle);
4230
+ * @param angle - 旋转角(弧度值)
4231
+ * @returns 四元数
4232
+ */ Quaternion.fromAxisAngle = function fromAxisAngle(axis, angle) {
4233
+ return new Quaternion().setFromAxisAngle(axis, angle);
4542
4234
  };
4543
4235
  /**
4544
- * 通过欧拉角创建矩阵
4545
- * @param euler - 欧拉角
4546
- * @returns
4547
- */ Matrix4.fromEuler = function fromEuler(euler) {
4548
- return new Matrix4().setFromEuler(euler);
4236
+ * 通过 Vector4Like 创建四元数
4237
+ * @param v - Vector4Like
4238
+ * @returns 四元数
4239
+ */ Quaternion.fromVector4 = function fromVector4(v) {
4240
+ return new Quaternion().setFromVector4(v);
4549
4241
  };
4550
4242
  /**
4551
- * 通过四元数创建矩阵
4552
- * @param quat - 四元数
4553
- * @returns
4554
- */ Matrix4.fromQuaternion = function fromQuaternion(quat) {
4555
- return new Matrix4().setFromQuaternion(quat);
4243
+ * 通过数组创建四元数
4244
+ * @param array - 数组
4245
+ * @param [offset=0] - 起始偏移值
4246
+ * @returns 四元数
4247
+ */ Quaternion.fromArray = function fromArray(array, offset) {
4248
+ if (offset === void 0) offset = 0;
4249
+ return new Quaternion().setFromArray(array, offset);
4556
4250
  };
4557
4251
  /**
4558
- * 通过倾斜创建矩阵
4559
- * @param x - x 方向倾斜分量
4560
- * @param y - y 方向倾斜分量
4561
- * @param z - z 方向倾斜分量
4562
- * @returns 倾斜矩阵
4563
- */ Matrix4.fromShear = function fromShear(x, y, z) {
4564
- return new Matrix4().setFromShear(x, y, z);
4252
+ * 通过旋转矩阵创建四元数
4253
+ * @param m - 旋转矩阵
4254
+ * @returns 四元数
4255
+ */ Quaternion.fromRotationMatrix = function fromRotationMatrix(m) {
4256
+ return new Quaternion().setFromRotationMatrix(m);
4565
4257
  };
4566
4258
  /**
4567
- * 通过基轴创建矩阵
4568
- * @param xAxis - x 轴
4569
- * @param yAxis - y 轴
4570
- * @param zAxis - z 轴
4259
+ * 通过开始和结束向量创建四元数
4260
+ * @param from - 开始向量
4261
+ * @param to - 结束向量
4571
4262
  * @returns
4572
- */ Matrix4.fromBasis = function fromBasis(xAxis, yAxis, zAxis) {
4573
- return new Matrix4().setFromBasis(xAxis, yAxis, zAxis);
4263
+ */ Quaternion.fromUnitVectors = function fromUnitVectors(from, to) {
4264
+ return new Quaternion().setFromUnitVectors(from, to);
4265
+ };
4266
+ return Quaternion;
4267
+ }();
4268
+ Quaternion.tempVec0 = new Vector3();
4269
+
4270
+ /**
4271
+ * 四阶矩阵(列优先矩阵)
4272
+ */ var Matrix4 = /*#__PURE__*/ function() {
4273
+ function Matrix4(m11, m21, m31, m41, m12, m22, m32, m42, m13, m23, m33, m43, m14, m24, m34, m44) {
4274
+ if (m11 === void 0) m11 = 1;
4275
+ if (m21 === void 0) m21 = 0;
4276
+ if (m31 === void 0) m31 = 0;
4277
+ if (m41 === void 0) m41 = 0;
4278
+ if (m12 === void 0) m12 = 0;
4279
+ if (m22 === void 0) m22 = 1;
4280
+ if (m32 === void 0) m32 = 0;
4281
+ if (m42 === void 0) m42 = 0;
4282
+ if (m13 === void 0) m13 = 0;
4283
+ if (m23 === void 0) m23 = 0;
4284
+ if (m33 === void 0) m33 = 1;
4285
+ if (m43 === void 0) m43 = 0;
4286
+ if (m14 === void 0) m14 = 0;
4287
+ if (m24 === void 0) m24 = 0;
4288
+ if (m34 === void 0) m34 = 0;
4289
+ if (m44 === void 0) m44 = 1;
4290
+ this.elements = [
4291
+ m11,
4292
+ m21,
4293
+ m31,
4294
+ m41,
4295
+ m12,
4296
+ m22,
4297
+ m32,
4298
+ m42,
4299
+ m13,
4300
+ m23,
4301
+ m33,
4302
+ m43,
4303
+ m14,
4304
+ m24,
4305
+ m34,
4306
+ m44
4307
+ ];
4308
+ }
4309
+ var _proto = Matrix4.prototype;
4310
+ /**
4311
+ * 设置矩阵
4312
+ * @param m11 - 第 1 行,第 1 列
4313
+ * @param m21 - 第 2 行,第 1 列
4314
+ * @param m31 - 第 3 行,第 1 列
4315
+ * @param m41 - 第 4 行,第 1 列
4316
+ * @param m12 - 第 1 行,第 2 列
4317
+ * @param m22 - 第 2 行,第 2 列
4318
+ * @param m32 - 第 3 行,第 2 列
4319
+ * @param m42 - 第 4 行,第 2 列
4320
+ * @param m13 - 第 1 行,第 3 列
4321
+ * @param m23 - 第 2 行,第 3 列
4322
+ * @param m33 - 第 3 行,第 3 列
4323
+ * @param m43 - 第 4 行,第 3 列
4324
+ * @param m14 - 第 1 行,第 4 列
4325
+ * @param m24 - 第 2 行,第 4 列
4326
+ * @param m34 - 第 3 行,第 4 列
4327
+ * @param m44 - 第 4 行,第 4 列
4328
+ * @returns 矩阵
4329
+ */ _proto.set = function set(m11, m21, m31, m41, m12, m22, m32, m42, m13, m23, m33, m43, m14, m24, m34, m44) {
4330
+ var e = this.elements;
4331
+ e[0] = m11;
4332
+ e[1] = m21;
4333
+ e[2] = m31;
4334
+ e[3] = m41;
4335
+ e[4] = m12;
4336
+ e[5] = m22;
4337
+ e[6] = m32;
4338
+ e[7] = m42;
4339
+ e[8] = m13;
4340
+ e[9] = m23;
4341
+ e[10] = m33;
4342
+ e[11] = m43;
4343
+ e[12] = m14;
4344
+ e[13] = m24;
4345
+ e[14] = m34;
4346
+ e[15] = m44;
4347
+ return this;
4574
4348
  };
4575
4349
  /**
4576
4350
  * 通过行优先数据设置矩阵
@@ -4590,732 +4364,891 @@ Quaternion.tempVec0 = new Vector3();
4590
4364
  * @param m42 - 第 4 行,第 2 列
4591
4365
  * @param m43 - 第 4 行,第 3 列
4592
4366
  * @param m44 - 第 4 行,第 4 列
4593
- * @returns
4594
- */ Matrix4.fromRowMajorData = function fromRowMajorData(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) {
4595
- return new Matrix4(m11, m21, m31, m41, m12, m22, m32, m42, m13, m23, m33, m43, m14, m24, m34, m44);
4367
+ * @returns 矩阵
4368
+ */ _proto.setFromRowMajorData = function setFromRowMajorData(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) {
4369
+ var e = this.elements;
4370
+ e[0] = m11;
4371
+ e[4] = m12;
4372
+ e[8] = m13;
4373
+ e[12] = m14;
4374
+ e[1] = m21;
4375
+ e[5] = m22;
4376
+ e[9] = m23;
4377
+ e[13] = m24;
4378
+ e[2] = m31;
4379
+ e[6] = m32;
4380
+ e[10] = m33;
4381
+ e[14] = m34;
4382
+ e[3] = m41;
4383
+ e[7] = m42;
4384
+ e[11] = m43;
4385
+ e[15] = m44;
4386
+ return this;
4596
4387
  };
4597
- return Matrix4;
4598
- }();
4599
- Matrix4.IDENTITY = new Matrix4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
4600
- Matrix4.ZERO = new Matrix4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
4601
- Matrix4.tempVec0 = new Vector3();
4602
- Matrix4.tempVec1 = new Vector3();
4603
- Matrix4.tempVec2 = new Vector3();
4604
- Matrix4.tempMat0 = new Matrix4();
4605
-
4606
- /**
4607
- * 四维向量
4608
- */ var Vector4 = /*#__PURE__*/ function() {
4609
- function Vector4(x, y, z, w) {
4610
- if (x === void 0) x = 0;
4611
- if (y === void 0) y = 0;
4612
- if (z === void 0) z = 0;
4613
- if (w === void 0) w = 0;
4614
- this.x = x;
4615
- this.y = y;
4616
- this.z = z;
4617
- this.w = w;
4618
- }
4619
- var _proto = Vector4.prototype;
4620
4388
  /**
4621
- * 设置向量
4622
- * @param x - x 轴分量
4623
- * @param y - y 轴分量
4624
- * @param z - z 轴分量
4625
- * @param w - w 轴分量
4626
- * @returns
4627
- */ _proto.set = function set(x, y, z, w) {
4628
- this.x = x;
4629
- this.y = y;
4630
- this.z = z;
4631
- this.w = w;
4389
+ * 通过四个列向量设置矩阵
4390
+ * @param c1 - 第一列
4391
+ * @param c2 - 第二列
4392
+ * @param c3 - 第三列
4393
+ * @param c4 - 第四列
4394
+ * @returns 矩阵
4395
+ */ _proto.setFromColumnVectors = function setFromColumnVectors(c1, c2, c3, c4) {
4396
+ return this.set(c1.x, c1.y, c1.z, c1.w, c2.x, c2.y, c2.z, c2.w, c3.x, c3.y, c3.z, c3.w, c4.x, c4.y, c4.z, c4.w);
4397
+ };
4398
+ /**
4399
+ * 通过三维矩阵设置矩阵
4400
+ * @param m - 三维矩阵
4401
+ * @returns 设置结果
4402
+ */ _proto.setFromMatrix3 = function setFromMatrix3(m) {
4403
+ var me = m.elements;
4404
+ this.set(me[0], me[1], me[2], 0, me[3], me[4], me[5], 0, me[6], me[7], me[8], 0, 0, 0, 0, 1);
4405
+ return this;
4406
+ };
4407
+ /**
4408
+ * 通过数组设置矩阵
4409
+ * @param array - 数组
4410
+ * @param [offset=0] - 起始偏移值
4411
+ * @returns 矩阵
4412
+ */ _proto.setFromArray = function setFromArray(array, offset) {
4413
+ if (offset === void 0) offset = 0;
4414
+ for(var i = 0; i < 16; i++){
4415
+ this.elements[i] = array[offset + i];
4416
+ }
4632
4417
  return this;
4633
4418
  };
4634
4419
  /**
4635
- * 设置零向量
4636
- * @returns 向量
4637
- */ _proto.setZero = function setZero() {
4638
- this.x = 0;
4639
- this.y = 0;
4640
- this.z = 0;
4641
- this.w = 0;
4642
- return this;
4420
+ * 通过缩放设置矩阵
4421
+ * @param x - x 方向缩放
4422
+ * @param y - y 方向缩放
4423
+ * @param z - z 方向缩放
4424
+ * @returns 缩放矩阵
4425
+ */ _proto.setFromScale = function setFromScale(x, y, z) {
4426
+ return this.set(x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, 0, 0, 0, 1);
4427
+ };
4428
+ /**
4429
+ * 通过平移设置矩阵
4430
+ * @param x - x 方向平移
4431
+ * @param y - y 方向平移
4432
+ * @param z - z 方向平移
4433
+ * @returns 平移矩阵
4434
+ */ _proto.setFromTranslation = function setFromTranslation(x, y, z) {
4435
+ return this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, z, 1);
4436
+ };
4437
+ /**
4438
+ * 通过 x 轴旋转角度设置矩阵
4439
+ * @param theta - x 轴旋转弧度
4440
+ * @returns 矩阵
4441
+ */ _proto.setFromRotationX = function setFromRotationX(theta) {
4442
+ var c = Math.cos(theta);
4443
+ var s = Math.sin(theta);
4444
+ return this.set(1, 0, 0, 0, 0, c, s, 0, 0, -s, c, 0, 0, 0, 0, 1);
4445
+ };
4446
+ /**
4447
+ * 通过 y 轴旋转角度设置矩阵
4448
+ * @param theta - y 轴旋转弧度
4449
+ * @returns 矩阵
4450
+ */ _proto.setFromRotationY = function setFromRotationY(theta) {
4451
+ var c = Math.cos(theta);
4452
+ var s = Math.sin(theta);
4453
+ return this.set(c, 0, -s, 0, 0, 1, 0, 0, s, 0, c, 0, 0, 0, 0, 1);
4454
+ };
4455
+ /**
4456
+ * 通过 z 轴旋转角度设置矩阵
4457
+ * @param theta - z 轴旋转弧度
4458
+ * @returns 矩阵
4459
+ */ _proto.setFromRotationZ = function setFromRotationZ(theta) {
4460
+ var c = Math.cos(theta);
4461
+ var s = Math.sin(theta);
4462
+ return this.set(c, s, 0, 0, -s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
4643
4463
  };
4644
4464
  /**
4645
- * 通过标量数值设置向量
4646
- * @param num - 数值
4647
- * @returns 向量
4648
- */ _proto.setFromNumber = function setFromNumber(num) {
4649
- this.x = num;
4650
- this.y = num;
4651
- this.z = num;
4652
- this.w = num;
4653
- return this;
4465
+ * 根据三维旋转轴与弧度设置矩阵
4466
+ * @param axis - 三维旋转轴
4467
+ * @param angle - 旋转弧度
4468
+ * @returns 矩阵
4469
+ */ _proto.setFromRotationAxis = function setFromRotationAxis(axis, angle) {
4470
+ // Based on http://www.gamedev.net/reference/articles/article1199.asp
4471
+ var v = Matrix4.tempVec0;
4472
+ v.copyFrom(axis).normalize();
4473
+ var c = Math.cos(angle);
4474
+ var s = Math.sin(angle);
4475
+ var t = 1 - c;
4476
+ var x = v.x, y = v.y, z = v.z;
4477
+ var tx = t * x;
4478
+ var ty = t * y;
4479
+ return this.set(tx * x + c, tx * y + s * z, tx * z - s * y, 0, tx * y - s * z, ty * y + c, ty * z + s * x, 0, tx * z + s * y, ty * z - s * x, t * z * z + c, 0, 0, 0, 0, 1);
4654
4480
  };
4655
4481
  /**
4656
- * 通过数组创建向量
4657
- * @param array - 数组
4658
- * @param [offset=0] - 起始偏移值
4659
- * @returns 向量
4660
- */ _proto.setFromArray = function setFromArray(array, offset) {
4661
- if (offset === void 0) offset = 0;
4662
- var _array_offset;
4663
- this.x = (_array_offset = array[offset]) != null ? _array_offset : 0;
4664
- var _array_;
4665
- this.y = (_array_ = array[offset + 1]) != null ? _array_ : 0;
4666
- var _array_1;
4667
- this.z = (_array_1 = array[offset + 2]) != null ? _array_1 : 0;
4668
- var _array_2;
4669
- this.w = (_array_2 = array[offset + 3]) != null ? _array_2 : 0;
4482
+ * 通过欧拉角设置矩阵
4483
+ * @param euler - 欧拉角
4484
+ * @returns 矩阵
4485
+ */ _proto.setFromEuler = function setFromEuler(euler) {
4486
+ euler.toMatrix4(this);
4670
4487
  return this;
4671
4488
  };
4672
4489
  /**
4673
- * 拷贝向量
4674
- * @param v - 复制对象
4675
- * @returns 拷贝结果
4676
- */ _proto.copyFrom = function copyFrom(v) {
4677
- this.x = v.x;
4678
- this.y = v.y;
4679
- this.z = v.z;
4680
- this.w = v.w;
4681
- return this;
4490
+ * 通过四元数设置矩阵
4491
+ * @param quat - 四元数
4492
+ * @returns 矩阵
4493
+ */ _proto.setFromQuaternion = function setFromQuaternion(quat) {
4494
+ return this.compose(Vector3.ZERO, quat, Vector3.ONE);
4682
4495
  };
4683
4496
  /**
4684
- * 克隆向量
4685
- * @returns 克隆结果
4686
- */ _proto.clone = function clone() {
4687
- return new Vector4(this.x, this.y, this.z, this.w);
4497
+ * 通过倾斜参数设置矩阵
4498
+ * @param x - x 方向倾斜分量
4499
+ * @param y - y 方向倾斜分量
4500
+ * @param z - z 方向倾斜分量
4501
+ * @returns 倾斜矩阵
4502
+ */ _proto.setFromShear = function setFromShear(x, y, z) {
4503
+ return this.set(1, x, x, 0, y, 1, y, 0, z, z, 1, 0, 0, 0, 0, 1);
4688
4504
  };
4689
4505
  /**
4690
- * 根据下标设置向量分量
4691
- * @param index - 下标值
4692
- * @param value - 分量值
4693
- * @returns 向量
4694
- */ _proto.setElement = function setElement(index, value) {
4695
- switch(index){
4696
- case 0:
4697
- this.x = value;
4698
- break;
4699
- case 1:
4700
- this.y = value;
4701
- break;
4702
- case 2:
4703
- this.z = value;
4704
- break;
4705
- case 3:
4706
- this.w = value;
4707
- break;
4708
- default:
4709
- console.error("index is out of range: " + index);
4506
+ * 通过基轴设置矩阵
4507
+ * @param xAxis - x 轴
4508
+ * @param yAxis - y 轴
4509
+ * @param zAxis - z 轴
4510
+ * @returns 倾斜矩阵
4511
+ */ _proto.setFromBasis = function setFromBasis(xAxis, yAxis, zAxis) {
4512
+ return this.set(xAxis.x, xAxis.y, xAxis.z, 0, yAxis.x, yAxis.y, yAxis.z, 0, zAxis.x, zAxis.y, zAxis.z, 0, 0, 0, 0, 1);
4513
+ };
4514
+ /**
4515
+ * 矩阵清零
4516
+ * @returns 零矩阵
4517
+ */ _proto.setZero = function setZero() {
4518
+ for(var i = 0; i < 16; i++){
4519
+ this.elements[i] = 0;
4710
4520
  }
4711
4521
  return this;
4712
4522
  };
4713
4523
  /**
4714
- * 根据下标获取向量分量
4715
- * @param index - 下标
4716
- * @returns 分量值
4717
- */ _proto.getElement = function getElement(index) {
4718
- switch(index){
4719
- case 0:
4720
- return this.x;
4721
- case 1:
4722
- return this.y;
4723
- case 2:
4724
- return this.z;
4725
- case 3:
4726
- return this.w;
4727
- default:
4728
- console.error("index is out of range: " + index);
4729
- }
4730
- return 0;
4524
+ * 矩阵单位化
4525
+ * @returns 单位矩阵
4526
+ */ _proto.identity = function identity() {
4527
+ return this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
4731
4528
  };
4732
4529
  /**
4733
- * 向量相加
4734
- * @param right - 相加对象,向量 | 数字
4735
- * @returns 相加结果
4736
- */ _proto.add = function add(right) {
4737
- if (typeof right === "number") {
4738
- this.x += right;
4739
- this.y += right;
4740
- this.z += right;
4741
- this.w += right;
4742
- } else if (_instanceof1(right, Array)) {
4743
- this.x += right[0];
4744
- this.y += right[1];
4745
- this.z += right[2];
4746
- this.w += right[3];
4747
- } else {
4748
- this.x += right.x;
4749
- this.y += right.y;
4750
- this.z += right.z;
4751
- this.w += right.w;
4752
- }
4753
- return this;
4530
+ * 单位阵判断
4531
+ * @returns 判断结果
4532
+ */ _proto.isIdentity = function isIdentity() {
4533
+ var e = this.elements;
4534
+ return e[0] === 1 && e[4] === 0 && e[8] === 0 && e[12] === 0 && e[1] === 0 && e[5] === 1 && e[9] === 0 && e[13] === 0 && e[2] === 0 && e[6] === 0 && e[10] === 1 && e[14] === 0 && e[3] === 0 && e[7] === 0 && e[11] === 0 && e[15] === 1;
4754
4535
  };
4755
4536
  /**
4756
- * 向量相加
4757
- * @param left - 向量
4758
- * @param right - 向量
4759
- * @returns 求和结果
4760
- */ _proto.addVectors = function addVectors(left, right) {
4761
- this.x = left.x + right.x;
4762
- this.y = left.y + right.y;
4763
- this.z = left.z + right.z;
4764
- this.w = left.w + right.w;
4765
- return this;
4537
+ * 矩阵克隆
4538
+ * @returns 克隆结果
4539
+ */ _proto.clone = function clone() {
4540
+ var e = this.elements;
4541
+ return new Matrix4(e[0], e[1], e[2], e[3], e[4], e[5], e[6], e[7], e[8], e[9], e[10], e[11], e[12], e[13], e[14], e[15]);
4766
4542
  };
4767
4543
  /**
4768
- * 向量比例缩放后相加
4769
- * @param right - 向量
4770
- * @param s - 比例
4771
- * @returns 求和结果
4772
- */ _proto.addScaledVector = function addScaledVector(right, s) {
4773
- this.x += right.x * s;
4774
- this.y += right.y * s;
4775
- this.z += right.z * s;
4776
- this.w += right.w * s;
4544
+ * 矩阵复制
4545
+ * @param m - 复制对象
4546
+ * @returns 复制结果
4547
+ */ _proto.copyFrom = function copyFrom(m) {
4548
+ this.elements = [].concat(m.elements);
4777
4549
  return this;
4778
4550
  };
4779
4551
  /**
4780
- * 向量相减
4781
- * @param right - 相减对象,向量 | 数字
4782
- * @returns 相减结果
4783
- */ _proto.subtract = function subtract(right) {
4784
- if (typeof right === "number") {
4785
- this.x -= right;
4786
- this.y -= right;
4787
- this.z -= right;
4788
- this.w -= right;
4789
- } else if (_instanceof1(right, Array)) {
4790
- this.x -= right[0];
4791
- this.y -= right[1];
4792
- this.z -= right[2];
4793
- this.w -= right[3];
4794
- } else {
4795
- this.x -= right.x;
4796
- this.y -= right.y;
4797
- this.z -= right.z;
4798
- this.w -= right.w;
4799
- }
4552
+ * 得到列向量
4553
+ * @param i - 列向量索引,从 0 开始
4554
+ * @param v
4555
+ * @returns 矩阵
4556
+ */ _proto.getColumnVector = function getColumnVector(i, v) {
4557
+ return v.set(this.elements[i * 4], this.elements[i * 4 + 1], this.elements[i * 4 + 2], this.elements[i * 4 + 3]);
4558
+ };
4559
+ /**
4560
+ * 设置相机矩阵
4561
+ * @param eye - 相机位置
4562
+ * @param target - 目标位置
4563
+ * @param up - 相机方向
4564
+ * @returns 矩阵
4565
+ */ _proto.lookAt = function lookAt(eye, target, up) {
4566
+ var vX = Matrix4.tempVec0;
4567
+ var vY = Matrix4.tempVec1;
4568
+ var vZ = Matrix4.tempVec2;
4569
+ vZ.subtractVectors(eye, target);
4570
+ vZ.normalize();
4571
+ vX.crossVectors(up, vZ);
4572
+ vX.normalize();
4573
+ vY.crossVectors(vZ, vX);
4574
+ var te = this.elements;
4575
+ te[0] = vX.x;
4576
+ te[1] = vY.x;
4577
+ te[2] = vZ.x;
4578
+ te[3] = 0;
4579
+ te[4] = vX.y;
4580
+ te[5] = vY.y;
4581
+ te[6] = vZ.y;
4582
+ te[7] = 0;
4583
+ te[8] = vX.z;
4584
+ te[9] = vY.z;
4585
+ te[10] = vZ.z;
4586
+ te[11] = 0;
4587
+ te[12] = -vX.dot(eye);
4588
+ te[13] = -vY.dot(eye);
4589
+ te[14] = -vZ.dot(eye);
4590
+ te[15] = 1;
4800
4591
  return this;
4801
4592
  };
4802
4593
  /**
4803
- * 向量相减
4804
- * @param left - 向量
4805
- * @param right - 向量
4806
- * @returns 向量
4807
- */ _proto.subtractVectors = function subtractVectors(left, right) {
4808
- this.x = left.x - right.x;
4809
- this.y = left.y - right.y;
4810
- this.z = left.z - right.z;
4811
- this.w = left.w - right.w;
4594
+ * 矩阵乘比例后相加
4595
+ * @param right - 矩阵
4596
+ * @param s - 比例
4597
+ * @returns 相加结果
4598
+ */ _proto.addScaledMatrix = function addScaledMatrix(right, s) {
4599
+ var te = this.elements;
4600
+ var re = right.elements;
4601
+ for(var i = 0; i < 16; i++){
4602
+ te[i] += re[i] * s;
4603
+ }
4812
4604
  return this;
4813
4605
  };
4814
4606
  /**
4815
- * 向量相乘
4816
- * @param right - 相乘对象,对象 | 数字
4817
- * @returns 向量
4607
+ * 矩阵右乘
4608
+ * @param right - 右侧矩阵或数值
4609
+ * @returns 右乘结果
4818
4610
  */ _proto.multiply = function multiply(right) {
4819
4611
  if (typeof right === "number") {
4820
- this.x *= right;
4821
- this.y *= right;
4822
- this.z *= right;
4823
- this.w *= right;
4824
- } else if (_instanceof1(right, Array)) {
4825
- this.x *= right[0];
4826
- this.y *= right[1];
4827
- this.z *= right[2];
4828
- this.w *= right[3];
4612
+ for(var i = 0; i < 16; i++){
4613
+ this.elements[i] *= right;
4614
+ }
4615
+ return this;
4829
4616
  } else {
4830
- this.x *= right.x;
4831
- this.y *= right.y;
4832
- this.z *= right.z;
4833
- this.w *= right.w;
4617
+ return this.multiplyMatrices(this, right);
4834
4618
  }
4619
+ };
4620
+ /**
4621
+ * 矩阵左乘
4622
+ * @param left - 左侧矩阵
4623
+ * @returns 左乘结果
4624
+ */ _proto.premultiply = function premultiply(left) {
4625
+ return this.multiplyMatrices(left, this);
4626
+ };
4627
+ /**
4628
+ * 矩阵相乘
4629
+ * @param left - 矩阵
4630
+ * @param right - 矩阵
4631
+ * @returns 相乘结果
4632
+ */ _proto.multiplyMatrices = function multiplyMatrices(left, right) {
4633
+ var ae = left.elements;
4634
+ var be = right.elements;
4635
+ var te = this.elements;
4636
+ var a11 = ae[0], a12 = ae[4], a13 = ae[8], a14 = ae[12];
4637
+ var a21 = ae[1], a22 = ae[5], a23 = ae[9], a24 = ae[13];
4638
+ var a31 = ae[2], a32 = ae[6], a33 = ae[10], a34 = ae[14];
4639
+ var a41 = ae[3], a42 = ae[7], a43 = ae[11], a44 = ae[15];
4640
+ var b11 = be[0], b12 = be[4], b13 = be[8], b14 = be[12];
4641
+ var b21 = be[1], b22 = be[5], b23 = be[9], b24 = be[13];
4642
+ var b31 = be[2], b32 = be[6], b33 = be[10], b34 = be[14];
4643
+ var b41 = be[3], b42 = be[7], b43 = be[11], b44 = be[15];
4644
+ te[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
4645
+ te[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
4646
+ te[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
4647
+ te[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
4648
+ te[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
4649
+ te[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
4650
+ te[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
4651
+ te[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
4652
+ te[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
4653
+ te[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
4654
+ te[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
4655
+ te[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
4656
+ te[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
4657
+ te[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
4658
+ te[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
4659
+ te[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
4835
4660
  return this;
4836
4661
  };
4837
4662
  /**
4838
- * 向量相乘
4839
- * @param left - 向量
4840
- * @param right - 向量
4841
- * @returns 向量
4842
- */ _proto.multiplyVectors = function multiplyVectors(left, right) {
4843
- this.x = left.x * right.x;
4844
- this.y = left.y * right.y;
4845
- this.z = left.z * right.z;
4846
- this.w = left.w * right.w;
4663
+ * 矩阵缩放
4664
+ * @param s - 缩放比例
4665
+ * @returns 缩放结果
4666
+ */ _proto.multiplyScalar = function multiplyScalar(s) {
4667
+ var e = this.elements;
4668
+ e[0] *= s;
4669
+ e[4] *= s;
4670
+ e[8] *= s;
4671
+ e[12] *= s;
4672
+ e[1] *= s;
4673
+ e[5] *= s;
4674
+ e[9] *= s;
4675
+ e[13] *= s;
4676
+ e[2] *= s;
4677
+ e[6] *= s;
4678
+ e[10] *= s;
4679
+ e[14] *= s;
4680
+ e[3] *= s;
4681
+ e[7] *= s;
4682
+ e[11] *= s;
4683
+ e[15] *= s;
4847
4684
  return this;
4848
4685
  };
4849
4686
  /**
4850
- * 向量相除
4851
- * @param right - 相除对象,对象 | 数字
4852
- * @returns 向量
4853
- */ _proto.divide = function divide(right) {
4854
- if (typeof right === "number") {
4855
- this.x /= right;
4856
- this.y /= right;
4857
- this.z /= right;
4858
- this.w /= right;
4859
- } else if (_instanceof1(right, Array)) {
4860
- this.x /= right[0];
4861
- this.y /= right[1];
4862
- this.z /= right[2];
4863
- this.w /= right[3];
4864
- } else {
4865
- this.x /= right.x;
4866
- this.y /= right.y;
4867
- this.z /= right.z;
4868
- this.w /= right.w;
4687
+ * 矩阵求行列式值
4688
+ * @returns 行列式值
4689
+ */ _proto.determinant = function determinant() {
4690
+ var e = this.elements;
4691
+ var m11 = e[0], m12 = e[4], m13 = e[8], m14 = e[12];
4692
+ var m21 = e[1], m22 = e[5], m23 = e[9], m24 = e[13];
4693
+ var m31 = e[2], m32 = e[6], m33 = e[10], m34 = e[14];
4694
+ var m41 = e[3], m42 = e[7], m43 = e[11], m44 = e[15];
4695
+ return m41 * (+m14 * m23 * m32 - m13 * m24 * m32 - m14 * m22 * m33 + m12 * m24 * m33 + m13 * m22 * m34 - m12 * m23 * m34) + m42 * (+m11 * m23 * m34 - m11 * m24 * m33 + m14 * m21 * m33 - m13 * m21 * m34 + m13 * m24 * m31 - m14 * m23 * m31) + m43 * (+m11 * m24 * m32 - m11 * m22 * m34 - m14 * m21 * m32 + m12 * m21 * m34 + m14 * m22 * m31 - m12 * m24 * m31) + m44 * (-m13 * m22 * m31 - m11 * m23 * m32 + m11 * m22 * m33 + m13 * m21 * m32 - m12 * m21 * m33 + m12 * m23 * m31);
4696
+ };
4697
+ /**
4698
+ * 矩阵转置
4699
+ * @returns 转置结果
4700
+ */ _proto.transpose = function transpose() {
4701
+ var e = this.elements;
4702
+ var t;
4703
+ t = e[1];
4704
+ e[1] = e[4];
4705
+ e[4] = t;
4706
+ t = e[2];
4707
+ e[2] = e[8];
4708
+ e[8] = t;
4709
+ t = e[3];
4710
+ e[3] = e[12];
4711
+ e[12] = t;
4712
+ //
4713
+ t = e[6];
4714
+ e[6] = e[9];
4715
+ e[9] = t;
4716
+ t = e[7];
4717
+ e[7] = e[13];
4718
+ e[13] = t;
4719
+ t = e[11];
4720
+ e[11] = e[14];
4721
+ e[14] = t;
4722
+ return this;
4723
+ };
4724
+ /**
4725
+ * 矩阵求逆
4726
+ * @returns 逆矩阵
4727
+ */ _proto.invert = function invert() {
4728
+ // based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
4729
+ var e = this.elements;
4730
+ var m11 = e[0], m21 = e[1], m31 = e[2], m41 = e[3];
4731
+ var m12 = e[4], m22 = e[5], m32 = e[6], m42 = e[7];
4732
+ var m13 = e[8], m23 = e[9], m33 = e[10], m43 = e[11];
4733
+ var m14 = e[12], m24 = e[13], m34 = e[14], m44 = e[15];
4734
+ var t11 = m23 * m34 * m42 - m24 * m33 * m42 + m24 * m32 * m43 - m22 * m34 * m43 - m23 * m32 * m44 + m22 * m33 * m44;
4735
+ var t12 = m14 * m33 * m42 - m13 * m34 * m42 - m14 * m32 * m43 + m12 * m34 * m43 + m13 * m32 * m44 - m12 * m33 * m44;
4736
+ var t13 = m13 * m24 * m42 - m14 * m23 * m42 + m14 * m22 * m43 - m12 * m24 * m43 - m13 * m22 * m44 + m12 * m23 * m44;
4737
+ var t14 = m14 * m23 * m32 - m13 * m24 * m32 - m14 * m22 * m33 + m12 * m24 * m33 + m13 * m22 * m34 - m12 * m23 * m34;
4738
+ var det = m11 * t11 + m21 * t12 + m31 * t13 + m41 * t14;
4739
+ if (det === 0) {
4740
+ return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
4869
4741
  }
4742
+ var detInv = 1 / det;
4743
+ e[0] = t11 * detInv;
4744
+ e[1] = (m24 * m33 * m41 - m23 * m34 * m41 - m24 * m31 * m43 + m21 * m34 * m43 + m23 * m31 * m44 - m21 * m33 * m44) * detInv;
4745
+ e[2] = (m22 * m34 * m41 - m24 * m32 * m41 + m24 * m31 * m42 - m21 * m34 * m42 - m22 * m31 * m44 + m21 * m32 * m44) * detInv;
4746
+ e[3] = (m23 * m32 * m41 - m22 * m33 * m41 - m23 * m31 * m42 + m21 * m33 * m42 + m22 * m31 * m43 - m21 * m32 * m43) * detInv;
4747
+ e[4] = t12 * detInv;
4748
+ e[5] = (m13 * m34 * m41 - m14 * m33 * m41 + m14 * m31 * m43 - m11 * m34 * m43 - m13 * m31 * m44 + m11 * m33 * m44) * detInv;
4749
+ e[6] = (m14 * m32 * m41 - m12 * m34 * m41 - m14 * m31 * m42 + m11 * m34 * m42 + m12 * m31 * m44 - m11 * m32 * m44) * detInv;
4750
+ e[7] = (m12 * m33 * m41 - m13 * m32 * m41 + m13 * m31 * m42 - m11 * m33 * m42 - m12 * m31 * m43 + m11 * m32 * m43) * detInv;
4751
+ e[8] = t13 * detInv;
4752
+ e[9] = (m14 * m23 * m41 - m13 * m24 * m41 - m14 * m21 * m43 + m11 * m24 * m43 + m13 * m21 * m44 - m11 * m23 * m44) * detInv;
4753
+ e[10] = (m12 * m24 * m41 - m14 * m22 * m41 + m14 * m21 * m42 - m11 * m24 * m42 - m12 * m21 * m44 + m11 * m22 * m44) * detInv;
4754
+ e[11] = (m13 * m22 * m41 - m12 * m23 * m41 - m13 * m21 * m42 + m11 * m23 * m42 + m12 * m21 * m43 - m11 * m22 * m43) * detInv;
4755
+ e[12] = t14 * detInv;
4756
+ e[13] = (m13 * m24 * m31 - m14 * m23 * m31 + m14 * m21 * m33 - m11 * m24 * m33 - m13 * m21 * m34 + m11 * m23 * m34) * detInv;
4757
+ e[14] = (m14 * m22 * m31 - m12 * m24 * m31 - m14 * m21 * m32 + m11 * m24 * m32 + m12 * m21 * m34 - m11 * m22 * m34) * detInv;
4758
+ e[15] = (m12 * m23 * m31 - m13 * m22 * m31 + m13 * m21 * m32 - m11 * m23 * m32 - m12 * m21 * m33 + m11 * m22 * m33) * detInv;
4870
4759
  return this;
4871
4760
  };
4872
4761
  /**
4873
- * 向量缩放
4874
- * @param v - 数字
4875
- * @returns 缩放结果
4876
- */ _proto.scale = function scale(v) {
4877
- this.x *= v;
4878
- this.y *= v;
4879
- this.z *= v;
4880
- this.w *= v;
4762
+ * 提取基轴
4763
+ * @param xAxis - 提取的 x 轴
4764
+ * @param yAxis - 提取的 y 轴
4765
+ * @param zAxis - 提取的 z 轴
4766
+ * @returns
4767
+ */ _proto.extractBasis = function extractBasis(xAxis, yAxis, zAxis) {
4768
+ var te = this.elements;
4769
+ xAxis.set(te[0], te[1], te[2]);
4770
+ yAxis.set(te[4], te[5], te[6]);
4771
+ zAxis.set(te[8], te[9], te[10]);
4772
+ return this;
4773
+ };
4774
+ /**
4775
+ * 根据基础信息组装矩阵
4776
+ * @param translation - 位置信息
4777
+ * @param rotation - 旋转信息
4778
+ * @param scale - 缩放信息
4779
+ * @param [anchor] - 锚点信息
4780
+ * @returns 矩阵
4781
+ */ _proto.compose = function compose(translation, rotation, scale, anchor) {
4782
+ if (anchor === void 0) anchor = Vector3.ZERO;
4783
+ var te = this.elements;
4784
+ var x = rotation.x, y = rotation.y, z = rotation.z, w = rotation.w;
4785
+ var l = -anchor.x;
4786
+ var m = -anchor.y;
4787
+ var n = -anchor.z;
4788
+ var x2 = x + x;
4789
+ var y2 = y + y;
4790
+ var z2 = z + z;
4791
+ var xx = x * x2;
4792
+ var xy = x * y2;
4793
+ var xz = x * z2;
4794
+ var yy = y * y2;
4795
+ var yz = y * z2;
4796
+ var zz = z * z2;
4797
+ var wx = w * x2;
4798
+ var wy = w * y2;
4799
+ var wz = w * z2;
4800
+ var sx = scale.x, sy = scale.y, sz = scale.z;
4801
+ te[0] = (1 - (yy + zz)) * sx;
4802
+ te[1] = (xy + wz) * sx;
4803
+ te[2] = (xz - wy) * sx;
4804
+ te[3] = 0;
4805
+ te[4] = (xy - wz) * sy;
4806
+ te[5] = (1 - (xx + zz)) * sy;
4807
+ te[6] = (yz + wx) * sy;
4808
+ te[7] = 0;
4809
+ te[8] = (xz + wy) * sz;
4810
+ te[9] = (yz - wx) * sz;
4811
+ te[10] = (1 - (xx + yy)) * sz;
4812
+ te[11] = 0;
4813
+ te[12] = l * te[0] + m * te[4] + n * te[8] - l + translation.x;
4814
+ te[13] = l * te[1] + m * te[5] + n * te[9] - m + translation.y;
4815
+ te[14] = l * te[2] + m * te[6] + n * te[10] - n + translation.z;
4881
4816
  return this;
4882
4817
  };
4883
4818
  /**
4884
- * 分量求和
4885
- * @returns 求和结果
4886
- */ _proto.sum = function sum() {
4887
- return this.x + this.y + this.z + this.w;
4888
- };
4889
- /**
4890
- * 向量求最小值
4891
- * @param v - 向量或数值
4892
- * @returns 最小值
4893
- */ _proto.min = function min(v) {
4894
- if (typeof v === "number") {
4895
- this.x = Math.min(this.x, v);
4896
- this.y = Math.min(this.y, v);
4897
- this.z = Math.min(this.z, v);
4898
- this.w = Math.min(this.w, v);
4899
- } else {
4900
- this.x = Math.min(this.x, v.x);
4901
- this.y = Math.min(this.y, v.y);
4902
- this.z = Math.min(this.z, v.z);
4903
- this.w = Math.min(this.w, v.w);
4819
+ * 矩阵拆分为基础信息
4820
+ * @param translation - 位置信息
4821
+ * @param rotation - 旋转信息
4822
+ * @param scale - 缩放信息
4823
+ * @returns 矩阵
4824
+ */ _proto.decompose = function decompose(translation, rotation, scale) {
4825
+ var v = Matrix4.tempVec0;
4826
+ var te = this.elements;
4827
+ var sx = v.set(te[0], te[1], te[2]).length();
4828
+ var sy = v.set(te[4], te[5], te[6]).length();
4829
+ var sz = v.set(te[8], te[9], te[10]).length();
4830
+ // if determine is negative, we need to invert one scale
4831
+ var det = this.determinant();
4832
+ if (det < 0) {
4833
+ sx = -sx;
4904
4834
  }
4835
+ translation.x = te[12];
4836
+ translation.y = te[13];
4837
+ translation.z = te[14];
4838
+ // scale the rotation part
4839
+ var m = Matrix4.tempMat0;
4840
+ m.copyFrom(this);
4841
+ var invSX = 1 / sx;
4842
+ var invSY = 1 / sy;
4843
+ var invSZ = 1 / sz;
4844
+ m.elements[0] *= invSX;
4845
+ m.elements[1] *= invSX;
4846
+ m.elements[2] *= invSX;
4847
+ m.elements[4] *= invSY;
4848
+ m.elements[5] *= invSY;
4849
+ m.elements[6] *= invSY;
4850
+ m.elements[8] *= invSZ;
4851
+ m.elements[9] *= invSZ;
4852
+ m.elements[10] *= invSZ;
4853
+ rotation.setFromRotationMatrix(m);
4854
+ scale.x = sx;
4855
+ scale.y = sy;
4856
+ scale.z = sz;
4905
4857
  return this;
4906
4858
  };
4907
- /**
4908
- * 向量求最大值
4909
- * @param v - 向量或数值
4910
- * @returns 最大值
4911
- */ _proto.max = function max(v) {
4912
- if (typeof v === "number") {
4913
- this.x = Math.max(this.x, v);
4914
- this.y = Math.max(this.y, v);
4915
- this.z = Math.max(this.z, v);
4916
- this.w = Math.max(this.w, v);
4917
- } else {
4918
- this.x = Math.max(this.x, v.x);
4919
- this.y = Math.max(this.y, v.y);
4920
- this.z = Math.max(this.z, v.z);
4921
- this.w = Math.max(this.w, v.w);
4922
- }
4923
- return this;
4859
+ _proto.getTranslation = function getTranslation(translation) {
4860
+ var te = this.elements;
4861
+ return translation.set(te[12], te[13], te[14]);
4862
+ };
4863
+ _proto.getScale = function getScale(scale) {
4864
+ var te = this.elements;
4865
+ return scale.set(Math.hypot(te[0], te[1], te[2]), Math.hypot(te[4], te[5], te[6]), Math.hypot(te[8], te[9], te[10]));
4924
4866
  };
4925
4867
  /**
4926
- * 向量阈值约束
4927
- * @param min - 最小值
4928
- * @param max - 最大值
4929
- * @returns 向量
4930
- */ _proto.clamp = function clamp(min, max) {
4931
- return this.max(min).min(max);
4868
+ * 获得矩阵分解的结果
4869
+ * @returns 分解的结果
4870
+ */ _proto.getTransform = function getTransform() {
4871
+ var translation = new Vector3();
4872
+ var rotation = new Quaternion();
4873
+ var scale = new Vector3();
4874
+ this.decompose(translation, rotation, scale);
4875
+ return {
4876
+ translation: translation,
4877
+ rotation: rotation,
4878
+ scale: scale
4879
+ };
4932
4880
  };
4933
4881
  /**
4934
- * 向量向下取整
4935
- * @returns 取整结果
4936
- */ _proto.floor = function floor() {
4937
- this.x = Math.floor(this.x);
4938
- this.y = Math.floor(this.y);
4939
- this.z = Math.floor(this.z);
4940
- this.w = Math.floor(this.w);
4882
+ * 根据视窗信息设置正交相机投影矩阵
4883
+ * @param left - 视窗左平面位置
4884
+ * @param right - 视窗右平面位置
4885
+ * @param top - 视窗上平面位置
4886
+ * @param bottom - 视窗下平面位置
4887
+ * @param near - 视窗近平面位置
4888
+ * @param far - 视窗远平面位置
4889
+ * @returns 矩阵
4890
+ */ _proto.orthographic = function orthographic(left, right, top, bottom, near, far) {
4891
+ var a = 1.0 / (right - left);
4892
+ var b = 1.0 / (top - bottom);
4893
+ var c = 1.0 / (far - near);
4894
+ var tx = -(right + left) * a;
4895
+ var ty = -(top + bottom) * b;
4896
+ var tz = -(far + near) * c;
4897
+ a *= 2.0;
4898
+ b *= 2.0;
4899
+ c *= -2.0;
4900
+ var te = this.elements;
4901
+ te[0] = a;
4902
+ te[1] = 0.0;
4903
+ te[2] = 0.0;
4904
+ te[3] = 0.0;
4905
+ //
4906
+ te[4] = 0.0;
4907
+ te[5] = b;
4908
+ te[6] = 0.0;
4909
+ te[7] = 0.0;
4910
+ //
4911
+ te[8] = 0.0;
4912
+ te[9] = 0.0;
4913
+ te[10] = c;
4914
+ te[11] = 0.0;
4915
+ //
4916
+ te[12] = tx;
4917
+ te[13] = ty;
4918
+ te[14] = tz;
4919
+ te[15] = 1.0;
4941
4920
  return this;
4942
4921
  };
4943
4922
  /**
4944
- * 向量向上取整
4945
- * @returns 取整结果
4946
- */ _proto.ceil = function ceil() {
4947
- this.x = Math.ceil(this.x);
4948
- this.y = Math.ceil(this.y);
4949
- this.z = Math.ceil(this.z);
4950
- this.w = Math.ceil(this.w);
4923
+ * 通过透视相机基础参数设置投影矩阵
4924
+ * @param fov - 视角(弧度)
4925
+ * @param aspect - 视窗比例
4926
+ * @param near - 近平面
4927
+ * @param far - 远平面
4928
+ * @param [reverse] - 视锥体长宽反转(3D这里反了?)
4929
+ * @returns 投影矩阵
4930
+ */ _proto.perspective = function perspective(fov, aspect, near, far, reverse) {
4931
+ var f = 1.0 / Math.tan(fov * 0.5);
4932
+ var nf = 1 / (near - far);
4933
+ var te = this.elements;
4934
+ te[0] = reverse ? f : f / aspect;
4935
+ te[1] = 0;
4936
+ te[2] = 0;
4937
+ te[3] = 0;
4938
+ //
4939
+ te[4] = 0;
4940
+ te[5] = reverse ? f * aspect : f;
4941
+ te[6] = 0;
4942
+ te[7] = 0;
4943
+ //
4944
+ te[8] = 0;
4945
+ te[9] = 0;
4946
+ te[10] = (far + near) * nf;
4947
+ te[11] = -1;
4948
+ //
4949
+ te[12] = 0;
4950
+ te[13] = 0;
4951
+ te[14] = 2 * far * near * nf;
4952
+ te[15] = 0;
4953
+ if (far === null || far === Infinity) {
4954
+ te[10] = -1;
4955
+ te[14] = -2 * near;
4956
+ }
4951
4957
  return this;
4952
4958
  };
4953
4959
  /**
4954
- * 向量四舍五入
4955
- * @returns 求值结果
4956
- */ _proto.round = function round() {
4957
- this.x = Math.round(this.x);
4958
- this.y = Math.round(this.y);
4959
- this.z = Math.round(this.z);
4960
- this.w = Math.round(this.w);
4961
- return this;
4960
+ * 对点进行投影变换
4961
+ * @param v - 输入点
4962
+ * @param [out] - 输出点,如果没有就覆盖输入的数据
4963
+ * @returns 投影后的点
4964
+ */ _proto.projectPoint = function projectPoint(v, out) {
4965
+ var x = v.x, y = v.y, z = v.z;
4966
+ var e = this.elements;
4967
+ var res = out != null ? out : v;
4968
+ res.x = e[0] * x + e[4] * y + e[8] * z + e[12];
4969
+ res.y = e[1] * x + e[5] * y + e[9] * z + e[13];
4970
+ res.z = e[2] * x + e[6] * y + e[10] * z + e[14];
4971
+ var w = e[3] * x + e[7] * y + e[11] * z + e[15];
4972
+ return res.multiply(1 / w);
4962
4973
  };
4963
4974
  /**
4964
- * 向量取绝对值
4965
- * @returns 向量
4966
- */ _proto.abs = function abs() {
4967
- this.x = Math.abs(this.x);
4968
- this.y = Math.abs(this.y);
4969
- this.z = Math.abs(this.z);
4970
- this.w = Math.abs(this.w);
4971
- return this;
4975
+ * 对点进行矩阵变换
4976
+ * @param v - 输入点
4977
+ * @param [out] - 输出点,如果没有就覆盖输入的数据
4978
+ * @returns 变换后的点
4979
+ */ _proto.transformPoint = function transformPoint(v, out) {
4980
+ var x = v.x, y = v.y, z = v.z;
4981
+ var e = this.elements;
4982
+ var res = out != null ? out : v;
4983
+ res.x = e[0] * x + e[4] * y + e[8] * z + e[12];
4984
+ res.y = e[1] * x + e[5] * y + e[9] * z + e[13];
4985
+ res.z = e[2] * x + e[6] * y + e[10] * z + e[14];
4986
+ return res;
4972
4987
  };
4973
4988
  /**
4974
- * 向量取反
4975
- * @returns 取反结果
4976
- */ _proto.negate = function negate() {
4977
- this.x = -this.x;
4978
- this.y = -this.y;
4979
- this.z = -this.z;
4980
- this.w = -this.w;
4981
- return this;
4989
+ * 对法向量进行矩阵变换
4990
+ * @param v - 输入法向量
4991
+ * @param [out] - 输出法向量,如果没有就覆盖输入的数据
4992
+ * @returns 变换后的法向量
4993
+ */ _proto.transformNormal = function transformNormal(v, out) {
4994
+ var x = v.x, y = v.y, z = v.z;
4995
+ var e = this.elements;
4996
+ var res = out != null ? out : v;
4997
+ res.x = e[0] * x + e[4] * y + e[8] * z;
4998
+ res.y = e[1] * x + e[5] * y + e[9] * z;
4999
+ res.z = e[2] * x + e[6] * y + e[10] * z;
5000
+ return res.normalize();
4982
5001
  };
4983
5002
  /**
4984
- * 向量长度平方
4985
- * @returns 长度平方
4986
- */ _proto.lengthSquared = function lengthSquared() {
4987
- return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
5003
+ * 对四维向量进行矩阵变换
5004
+ * @param v - 输入向量
5005
+ * @param [out] - 输出向量,如果没有就覆盖输入的数据
5006
+ * @returns 变换后向量
5007
+ */ _proto.transformVector4 = function transformVector4(v, out) {
5008
+ var x = v.x, y = v.y, z = v.z, w = v.w;
5009
+ var e = this.elements;
5010
+ var res = out != null ? out : v;
5011
+ res.x = e[0] * x + e[4] * y + e[8] * z + e[12] * w;
5012
+ res.y = e[1] * x + e[5] * y + e[9] * z + e[13] * w;
5013
+ res.z = e[2] * x + e[6] * y + e[10] * z + e[14] * w;
5014
+ res.w = e[3] * x + e[7] * y + e[11] * z + e[15] * w;
5015
+ return res;
4988
5016
  };
4989
5017
  /**
4990
- * 向量长度
4991
- * @returns 长度
4992
- */ _proto.length = function length() {
4993
- return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
5018
+ * 矩阵判等
5019
+ * @param matrix - 矩阵
5020
+ * @returns 判等结果
5021
+ */ _proto.equals = function equals(matrix) {
5022
+ var te = this.elements;
5023
+ var me = matrix.elements;
5024
+ for(var i = 0; i < 16; i++){
5025
+ if (!isEqual(te[i], me[i])) {
5026
+ return false;
5027
+ }
5028
+ }
5029
+ return true;
4994
5030
  };
4995
5031
  /**
4996
- * 向量归一化
4997
- * @returns 归一化结果
4998
- */ _proto.normalize = function normalize() {
4999
- return this.divide(this.length() || 1);
5032
+ * 矩阵转数组
5033
+ * @returns
5034
+ */ _proto.toArray = function toArray() {
5035
+ return [].concat(this.elements);
5000
5036
  };
5001
- /**
5002
- * 设置向量长度
5003
- * @param length - 长度
5004
- * @returns 向量
5005
- */ _proto.setLength = function setLength(length) {
5006
- return this.normalize().multiply(length);
5037
+ _proto.fill = function fill(array, offset) {
5038
+ if (offset === void 0) offset = 0;
5039
+ var te = this.elements;
5040
+ array[offset] = te[0];
5041
+ array[offset + 1] = te[1];
5042
+ array[offset + 2] = te[2];
5043
+ array[offset + 3] = te[3];
5044
+ array[offset + 4] = te[4];
5045
+ array[offset + 5] = te[5];
5046
+ array[offset + 6] = te[6];
5047
+ array[offset + 7] = te[7];
5048
+ array[offset + 8] = te[8];
5049
+ array[offset + 9] = te[9];
5050
+ array[offset + 10] = te[10];
5051
+ array[offset + 11] = te[11];
5052
+ array[offset + 12] = te[12];
5053
+ array[offset + 13] = te[13];
5054
+ array[offset + 14] = te[14];
5055
+ array[offset + 15] = te[15];
5007
5056
  };
5008
5057
  /**
5009
- * 向量求线性插值
5010
- * @param v - 向量
5011
- * @param alpha - 插值比例
5012
- * @returns 插值结果
5013
- */ _proto.lerp = function lerp(v, alpha) {
5014
- this.x += (v.x - this.x) * alpha;
5015
- this.y += (v.y - this.y) * alpha;
5016
- this.z += (v.z - this.z) * alpha;
5017
- this.w += (v.w - this.w) * alpha;
5018
- return this;
5058
+ * 创建单位阵
5059
+ * @returns 单位矩阵
5060
+ */ Matrix4.fromIdentity = function fromIdentity() {
5061
+ return new Matrix4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
5019
5062
  };
5020
5063
  /**
5021
- * 两向量求线性插值
5022
- * @param v1 - 第一个向量
5023
- * @param v2 - 第二个向量
5024
- * @param alpha - 插值比例
5025
- * @returns 插值结果
5026
- */ _proto.lerpVectors = function lerpVectors(v1, v2, alpha) {
5027
- this.x = v1.x + (v2.x - v1.x) * alpha;
5028
- this.y = v1.y + (v2.y - v1.y) * alpha;
5029
- this.z = v1.z + (v2.z - v1.z) * alpha;
5030
- this.w = v1.w + (v2.w - v1.w) * alpha;
5031
- return this;
5064
+ * 创建相机矩阵
5065
+ * @param eye - 相机位置
5066
+ * @param target - 目标位置
5067
+ * @param up - 相机方向
5068
+ * @returns 矩阵
5069
+ */ Matrix4.fromLookAt = function fromLookAt(eye, target, up) {
5070
+ return new Matrix4().lookAt(eye, target, up);
5032
5071
  };
5033
5072
  /**
5034
- * 向量求点积
5035
- * @param v - 向量
5036
- * @returns 点积结果
5037
- */ _proto.dot = function dot(v) {
5038
- return this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;
5073
+ * 创建投影矩阵
5074
+ * @param fov - 视角
5075
+ * @param aspect - 视窗比例
5076
+ * @param near - 近平面
5077
+ * @param far - 远平面
5078
+ * @param [reverse] - 视锥体长宽反转
5079
+ * @returns 投影矩阵
5080
+ */ Matrix4.fromPerspective = function fromPerspective(fov, aspect, near, far, reverse) {
5081
+ return new Matrix4().perspective(fov, aspect, near, far, reverse);
5039
5082
  };
5040
5083
  /**
5041
- * 向量判等
5042
- * @param v - 向量
5043
- * @returns 判等结果
5044
- */ _proto.equals = function equals(v) {
5045
- return v.x === this.x && v.y === this.y && v.z === this.z && v.w === this.w;
5084
+ * 通过四个列向量创建矩阵
5085
+ * @param c1 - 第一列
5086
+ * @param c2 - 第二列
5087
+ * @param c3 - 第三列
5088
+ * @param c4 - 第四列
5089
+ * @returns
5090
+ */ Matrix4.fromColumnVectors = function fromColumnVectors(c1, c2, c3, c4) {
5091
+ return new Matrix4().setFromColumnVectors(c1, c2, c3, c4);
5046
5092
  };
5047
5093
  /**
5048
- * 是否零向量
5049
- * @returns 是否零向量
5050
- */ _proto.isZero = function isZero() {
5051
- var eps = NumberEpsilon;
5052
- var _this = this, x = _this.x, y = _this.y, z = _this.z, w = _this.w;
5053
- return Math.abs(x) <= eps && Math.abs(y) <= eps && Math.abs(z) <= eps && Math.abs(w) <= eps;
5094
+ * 通过三阶矩阵创建矩阵
5095
+ * @param m - 三阶矩阵
5096
+ * @returns 创建的矩阵
5097
+ */ Matrix4.fromMatrix3 = function fromMatrix3(m) {
5098
+ return new Matrix4().setFromMatrix3(m);
5054
5099
  };
5055
5100
  /**
5056
- * 向量转数组
5057
- * @returns 数组
5058
- */ _proto.toArray = function toArray() {
5059
- return [
5060
- this.x,
5061
- this.y,
5062
- this.z,
5063
- this.w
5064
- ];
5065
- };
5066
- _proto.toVector3 = function toVector3() {
5067
- return new Vector3(this.x, this.y, this.z);
5068
- };
5069
- _proto.fill = function fill(array, offset) {
5101
+ * 通过数组创建矩阵
5102
+ * @param array - 数组
5103
+ * @param [offset=0] - 起始偏移值
5104
+ * @returns 矩阵
5105
+ */ Matrix4.fromArray = function fromArray(array, offset) {
5070
5106
  if (offset === void 0) offset = 0;
5071
- array[offset] = this.x;
5072
- array[offset + 1] = this.y;
5073
- array[offset + 2] = this.z;
5074
- array[offset + 3] = this.w;
5107
+ return new Matrix4().setFromArray(array, offset);
5075
5108
  };
5076
5109
  /**
5077
- * 生成随机向量
5078
- * @returns 向量
5079
- */ _proto.random = function random() {
5080
- this.x = Math.random();
5081
- this.y = Math.random();
5082
- this.z = Math.random();
5083
- this.w = Math.random();
5084
- return this;
5110
+ * 通过缩放创建矩阵
5111
+ * @param x - x 缩放
5112
+ * @param y - y 缩放
5113
+ * @param z - z 缩放
5114
+ * @returns 缩放结果
5115
+ */ Matrix4.fromScale = function fromScale(x, y, z) {
5116
+ return new Matrix4().setFromScale(x, y, z);
5085
5117
  };
5086
5118
  /**
5087
- * 变换矩阵作用于向量
5088
- * @param m - 变换矩阵
5089
- * @param [out] - 输出结果,如果没有设置就直接覆盖当前值
5090
- * @returns 向量
5091
- */ _proto.applyMatrix = function applyMatrix(m, out) {
5092
- return m.transformVector4(this, out);
5119
+ * 通过平移创建矩阵
5120
+ * @param x - x 平移
5121
+ * @param y - y 平移
5122
+ * @param z - z 平移
5123
+ * @returns 平移结果
5124
+ */ Matrix4.fromTranslation = function fromTranslation(x, y, z) {
5125
+ return new Matrix4().setFromTranslation(x, y, z);
5093
5126
  };
5094
5127
  /**
5095
- * 通过标量数值创建向量
5096
- * @param num - 数值
5097
- * @returns 向量
5098
- */ Vector4.fromNumber = function fromNumber(num) {
5099
- return new Vector4().setFromNumber(num);
5128
+ * 通过 x 轴旋转创建矩阵
5129
+ * @param theta - x 轴旋转弧度
5130
+ * @returns 矩阵
5131
+ */ Matrix4.fromRotationX = function fromRotationX(theta) {
5132
+ return new Matrix4().setFromRotationX(theta);
5100
5133
  };
5101
5134
  /**
5102
- * 通过数组创建向量
5103
- * @param array - 数组
5104
- * @param [offset=0] - 起始偏移值
5105
- * @returns 向量
5106
- */ Vector4.fromArray = function fromArray(array, offset) {
5107
- if (offset === void 0) offset = 0;
5108
- return new Vector4().setFromArray(array, offset);
5109
- };
5110
- return Vector4;
5111
- }();
5112
- /**
5113
- * 四维向量的常量
5114
- */ Vector4.ONE = new Vector4(1.0, 1.0, 1.0, 1.0);
5115
- Vector4.ZERO = new Vector4(0.0, 0.0, 0.0, 0.0);
5116
-
5117
- var EffectComponent = /*#__PURE__*/ function(RendererComponent) {
5118
- _inherits(EffectComponent, RendererComponent);
5119
- function EffectComponent(engine) {
5120
- var _this;
5121
- _this = RendererComponent.call(this, engine) || this;
5122
- /**
5123
- * Mesh 的世界矩阵
5124
- */ _this.worldMatrix = Matrix4.fromIdentity();
5125
- _this.triangles = [];
5126
- _this.destroyed = false;
5127
- // TODO 点击测试后续抽象一个 Collider 组件
5128
- _this.getHitTestParams = function(force) {
5129
- var area = _this.getBoundingBox();
5130
- if (area) {
5131
- return {
5132
- type: area.type,
5133
- triangles: area.area
5134
- };
5135
- }
5136
- };
5137
- _this.name = "EffectComponent";
5138
- _this._priority = 0;
5139
- return _this;
5140
- }
5141
- var _proto = EffectComponent.prototype;
5142
- _proto.onStart = function onStart() {
5143
- this.item.getHitTestParams = this.getHitTestParams;
5144
- };
5145
- _proto.onUpdate = function onUpdate(dt) {
5146
- var time = this.item.time;
5147
- var _this_material_getVector4;
5148
- var _Time = (_this_material_getVector4 = this.material.getVector4("_Time")) != null ? _this_material_getVector4 : new Vector4();
5149
- this.material.setVector4("_Time", _Time.set(time / 20, time, time * 2, time * 3));
5135
+ * 通过 y 轴旋转创建矩阵
5136
+ * @param theta - y 轴旋转弧度
5137
+ * @returns 矩阵
5138
+ */ Matrix4.fromRotationY = function fromRotationY(theta) {
5139
+ return new Matrix4().setFromRotationY(theta);
5150
5140
  };
5151
- _proto.render = function render(renderer) {
5152
- if (renderer.renderingData.currentFrame.globalUniforms) {
5153
- renderer.setGlobalMatrix("effects_ObjectToWorld", this.transform.getWorldMatrix());
5154
- }
5155
- renderer.drawGeometry(this.geometry, this.material);
5141
+ /**
5142
+ * 通过 z 轴旋转创建矩阵
5143
+ * @param theta - z 轴旋转弧度
5144
+ * @returns
5145
+ */ Matrix4.fromRotationZ = function fromRotationZ(theta) {
5146
+ return new Matrix4().setFromRotationZ(theta);
5156
5147
  };
5157
5148
  /**
5158
- * 设置当前 Mesh 的材质
5159
- * @param material - 要设置的材质
5160
- * @param destroy - 可选的材质销毁选项
5161
- */ _proto.setMaterial = function setMaterial(material, destroy) {
5162
- if (destroy !== DestroyOptions.keep) {
5163
- this.material.dispose(destroy);
5164
- }
5165
- this.material = material;
5149
+ * 通过旋转轴与旋转弧度创建矩阵
5150
+ * @param axis - 旋转轴
5151
+ * @param angle - 旋转弧度
5152
+ * @returns
5153
+ */ Matrix4.fromRotationAxis = function fromRotationAxis(axis, angle) {
5154
+ return new Matrix4().setFromRotationAxis(axis, angle);
5166
5155
  };
5167
- _proto.getBoundingBox = function getBoundingBox() {
5168
- var worldMatrix = this.transform.getWorldMatrix();
5169
- if (this.hitTestGeometry !== this.geometry) {
5170
- this.triangles = geometryToTriangles(this.geometry);
5171
- this.hitTestGeometry = this.geometry;
5172
- }
5173
- var area = [];
5174
- for(var _iterator = _create_for_of_iterator_helper_loose(this.triangles), _step; !(_step = _iterator()).done;){
5175
- var triangle = _step.value;
5176
- area.push({
5177
- p0: triangle.p0,
5178
- p1: triangle.p1,
5179
- p2: triangle.p2
5180
- });
5181
- }
5182
- area.forEach(function(triangle) {
5183
- triangle.p0 = worldMatrix.transformPoint(triangle.p0, new Vector3());
5184
- triangle.p1 = worldMatrix.transformPoint(triangle.p1, new Vector3());
5185
- triangle.p2 = worldMatrix.transformPoint(triangle.p2, new Vector3());
5186
- });
5187
- return {
5188
- type: HitTestType.triangle,
5189
- area: area
5190
- };
5156
+ /**
5157
+ * 通过欧拉角创建矩阵
5158
+ * @param euler - 欧拉角
5159
+ * @returns
5160
+ */ Matrix4.fromEuler = function fromEuler(euler) {
5161
+ return new Matrix4().setFromEuler(euler);
5191
5162
  };
5192
- _proto.fromData = function fromData(data) {
5193
- RendererComponent.prototype.fromData.call(this, data);
5194
- this.material = this.materials[0];
5163
+ /**
5164
+ * 通过四元数创建矩阵
5165
+ * @param quat - 四元数
5166
+ * @returns
5167
+ */ Matrix4.fromQuaternion = function fromQuaternion(quat) {
5168
+ return new Matrix4().setFromQuaternion(quat);
5195
5169
  };
5196
- _proto.toData = function toData() {
5197
- this.taggedProperties.id = this.guid;
5170
+ /**
5171
+ * 通过倾斜创建矩阵
5172
+ * @param x - x 方向倾斜分量
5173
+ * @param y - y 方向倾斜分量
5174
+ * @param z - z 方向倾斜分量
5175
+ * @returns 倾斜矩阵
5176
+ */ Matrix4.fromShear = function fromShear(x, y, z) {
5177
+ return new Matrix4().setFromShear(x, y, z);
5198
5178
  };
5199
5179
  /**
5200
- * 销毁当前资源
5201
- * @param options - 可选的销毁选项
5202
- */ _proto.dispose = function dispose(options) {
5203
- if (this.destroyed) {
5204
- return;
5205
- }
5206
- this.destroyed = true;
5207
- RendererComponent.prototype.dispose.call(this);
5180
+ * 通过基轴创建矩阵
5181
+ * @param xAxis - x 轴
5182
+ * @param yAxis - y
5183
+ * @param zAxis - z 轴
5184
+ * @returns
5185
+ */ Matrix4.fromBasis = function fromBasis(xAxis, yAxis, zAxis) {
5186
+ return new Matrix4().setFromBasis(xAxis, yAxis, zAxis);
5208
5187
  };
5209
- return EffectComponent;
5210
- }(RendererComponent);
5211
- __decorate([
5212
- serialize()
5213
- ], EffectComponent.prototype, "geometry", void 0);
5214
- EffectComponent = __decorate([
5215
- effectsClass(DataType.EffectComponent)
5216
- ], EffectComponent);
5217
- function geometryToTriangles(geometry) {
5218
- var _geometry_getIndexData;
5219
- var indices = (_geometry_getIndexData = geometry.getIndexData()) != null ? _geometry_getIndexData : [];
5220
- var _geometry_getAttributeData;
5221
- var vertices = (_geometry_getAttributeData = geometry.getAttributeData("aPos")) != null ? _geometry_getAttributeData : [];
5222
- var res = [];
5223
- for(var i = 0; i < indices.length; i += 3){
5224
- var index0 = indices[i] * 3;
5225
- var index1 = indices[i + 1] * 3;
5226
- var index2 = indices[i + 2] * 3;
5227
- var p0 = {
5228
- x: vertices[index0],
5229
- y: vertices[index0 + 1],
5230
- z: vertices[index0 + 2]
5231
- };
5232
- var p1 = {
5233
- x: vertices[index1],
5234
- y: vertices[index1 + 1],
5235
- z: vertices[index1 + 2]
5236
- };
5237
- var p2 = {
5238
- x: vertices[index2],
5239
- y: vertices[index2 + 1],
5240
- z: vertices[index2 + 2]
5241
- };
5242
- res.push({
5243
- p0: p0,
5244
- p1: p1,
5245
- p2: p2
5246
- });
5247
- }
5248
- return res;
5188
+ /**
5189
+ * 通过行优先数据设置矩阵
5190
+ * @param m11 - 第 1 行,第 1 列
5191
+ * @param m12 - 第 1 行,第 2 列
5192
+ * @param m13 - 第 1 行,第 3 列
5193
+ * @param m14 - 第 1 行,第 4 列
5194
+ * @param m21 - 第 2 行,第 1 列
5195
+ * @param m22 - 第 2 行,第 2 列
5196
+ * @param m23 - 第 2 行,第 3 列
5197
+ * @param m24 - 第 2 行,第 4 列
5198
+ * @param m31 - 3 行,第 1
5199
+ * @param m32 - 第 3 行,第 2 列
5200
+ * @param m33 - 3 行,第 3
5201
+ * @param m34 - 第 3 行,第 4 列
5202
+ * @param m41 - 4 行,第 1
5203
+ * @param m42 - 4 行,第 2 列
5204
+ * @param m43 - 4 行,第 3
5205
+ * @param m44 - 4 行,第 4 列
5206
+ * @returns
5207
+ */ Matrix4.fromRowMajorData = function fromRowMajorData(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) {
5208
+ return new Matrix4(m11, m21, m31, m41, m12, m22, m32, m42, m13, m23, m33, m43, m14, m24, m34, m44);
5209
+ };
5210
+ return Matrix4;
5211
+ }();
5212
+ Matrix4.IDENTITY = new Matrix4(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
5213
+ Matrix4.ZERO = new Matrix4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
5214
+ Matrix4.tempVec0 = new Vector3();
5215
+ Matrix4.tempVec1 = new Vector3();
5216
+ Matrix4.tempVec2 = new Vector3();
5217
+ Matrix4.tempMat0 = new Matrix4();
5218
+
5219
+ function _array_like_to_array(arr, len) {
5220
+ if (len == null || len > arr.length) len = arr.length;
5221
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5222
+ return arr2;
5249
5223
  }
5250
5224
 
5251
- var PostProcessVolume = /*#__PURE__*/ function(Behaviour) {
5252
- _inherits(PostProcessVolume, Behaviour);
5253
- function PostProcessVolume() {
5254
- var _this;
5255
- _this = Behaviour.apply(this, arguments) || this;
5256
- // Bloom
5257
- _this.bloomEnabled = true;
5258
- _this.threshold = 1.0;
5259
- _this.bloomIntensity = 1.0;
5260
- // ColorAdjustments
5261
- _this.brightness = 1.0;
5262
- _this.saturation = 1.0;
5263
- _this.contrast = 1.0;
5264
- // Vignette
5265
- _this.vignetteIntensity = 0.2;
5266
- _this.vignetteSmoothness = 0.4;
5267
- _this.vignetteRoundness = 1.0;
5268
- // ToneMapping
5269
- _this.toneMappingEnabled = true // 1: true, 0: false
5270
- ;
5271
- return _this;
5272
- }
5273
- var _proto = PostProcessVolume.prototype;
5274
- _proto.onStart = function onStart() {
5275
- var composition = this.item.composition;
5276
- if (composition) {
5277
- composition.renderFrame.globalVolume = this;
5278
- }
5279
- };
5280
- return PostProcessVolume;
5281
- }(Behaviour);
5282
- __decorate([
5283
- serialize()
5284
- ], PostProcessVolume.prototype, "bloomEnabled", void 0);
5285
- __decorate([
5286
- serialize()
5287
- ], PostProcessVolume.prototype, "threshold", void 0);
5288
- __decorate([
5289
- serialize()
5290
- ], PostProcessVolume.prototype, "bloomIntensity", void 0);
5291
- __decorate([
5292
- serialize()
5293
- ], PostProcessVolume.prototype, "brightness", void 0);
5294
- __decorate([
5295
- serialize()
5296
- ], PostProcessVolume.prototype, "saturation", void 0);
5297
- __decorate([
5298
- serialize()
5299
- ], PostProcessVolume.prototype, "contrast", void 0);
5300
- __decorate([
5301
- serialize()
5302
- ], PostProcessVolume.prototype, "vignetteIntensity", void 0);
5303
- __decorate([
5304
- serialize()
5305
- ], PostProcessVolume.prototype, "vignetteSmoothness", void 0);
5306
- __decorate([
5307
- serialize()
5308
- ], PostProcessVolume.prototype, "vignetteRoundness", void 0);
5309
- __decorate([
5310
- serialize()
5311
- ], PostProcessVolume.prototype, "toneMappingEnabled", void 0);
5312
- PostProcessVolume = __decorate([
5313
- effectsClass("PostProcessVolume")
5314
- ], PostProcessVolume);
5225
+ function _unsupported_iterable_to_array(o, minLen) {
5226
+ if (!o) return;
5227
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
5228
+ var n = Object.prototype.toString.call(o).slice(8, -1);
5229
+ if (n === "Object" && o.constructor) n = o.constructor.name;
5230
+ if (n === "Map" || n === "Set") return Array.from(n);
5231
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
5232
+ }
5315
5233
 
5316
- function _assert_this_initialized(self) {
5317
- if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
5318
- return self;
5234
+ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
5235
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
5236
+ if (it) return (it = it.call(o)).next.bind(it);
5237
+ // Fallback for engines without symbol support
5238
+ if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
5239
+ if (it) o = it;
5240
+ var i = 0;
5241
+ return function() {
5242
+ if (i >= o.length) return {
5243
+ done: true
5244
+ };
5245
+ return {
5246
+ done: false,
5247
+ value: o[i++]
5248
+ };
5249
+ };
5250
+ }
5251
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
5319
5252
  }
5320
5253
 
5321
5254
  var ShaderCompileResultStatus;
@@ -15491,14 +15424,14 @@ var GraphicsPath = /*#__PURE__*/ function() {
15491
15424
  return GraphicsPath;
15492
15425
  }();
15493
15426
 
15494
- var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
15495
- _inherits(ShapeComponent, RendererComponent);
15427
+ var ShapeComponent = /*#__PURE__*/ function(MeshComponent) {
15428
+ _inherits(ShapeComponent, MeshComponent);
15496
15429
  function ShapeComponent(engine) {
15497
15430
  var _this;
15498
- _this = RendererComponent.call(this, engine) || this;
15431
+ _this = MeshComponent.call(this, engine) || this;
15499
15432
  _this.path = new GraphicsPath();
15500
15433
  _this.curveValues = [];
15501
- _this.animated = false;
15434
+ _this.animated = true;
15502
15435
  _this.vert = "\nprecision highp float;\n\nattribute vec3 aPos;//x y\n\nuniform mat4 effects_MatrixVP;\nuniform mat4 effects_MatrixInvV;\nuniform mat4 effects_ObjectToWorld;\n\nvoid main() {\n vec4 pos = vec4(aPos.xyz, 1.0);\n gl_Position = effects_MatrixVP * effects_ObjectToWorld * pos;\n}\n";
15503
15436
  _this.frag = "\nprecision highp float;\n\nuniform vec4 _Color;\n\nvoid main() {\n vec4 color = _Color;\n gl_FragColor = color;\n}\n";
15504
15437
  if (!_this.geometry) {
@@ -15549,18 +15482,15 @@ var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
15549
15482
  return _this;
15550
15483
  }
15551
15484
  var _proto = ShapeComponent.prototype;
15485
+ _proto.onStart = function onStart() {
15486
+ this.item.getHitTestParams = this.getHitTestParams;
15487
+ };
15552
15488
  _proto.onUpdate = function onUpdate(dt) {
15553
15489
  if (this.animated) {
15554
15490
  this.buildPath(this.data);
15555
15491
  this.buildGeometryFromPath(this.path.shapePath);
15556
15492
  }
15557
15493
  };
15558
- _proto.render = function render(renderer) {
15559
- if (renderer.renderingData.currentFrame.globalUniforms) {
15560
- renderer.setGlobalMatrix("effects_ObjectToWorld", this.transform.getWorldMatrix());
15561
- }
15562
- renderer.drawGeometry(this.geometry, this.material);
15563
- };
15564
15494
  _proto.buildGeometryFromPath = function buildGeometryFromPath(shapePath) {
15565
15495
  var shapePrimitives = shapePath.shapePrimitives;
15566
15496
  var vertices = [];
@@ -15657,12 +15587,11 @@ var ShapeComponent = /*#__PURE__*/ function(RendererComponent) {
15657
15587
  }
15658
15588
  };
15659
15589
  _proto.fromData = function fromData(data) {
15660
- RendererComponent.prototype.fromData.call(this, data);
15590
+ MeshComponent.prototype.fromData.call(this, data);
15661
15591
  this.data = data;
15662
- this.animated = true;
15663
15592
  };
15664
15593
  return ShapeComponent;
15665
- }(RendererComponent);
15594
+ }(MeshComponent);
15666
15595
  ShapeComponent = __decorate([
15667
15596
  effectsClass("ShapeComponent")
15668
15597
  ], ShapeComponent);
@@ -16314,6 +16243,76 @@ function shouldIgnoreBouncing(arg, mul) {
16314
16243
  return arg && Math.abs(arg.vx || 0) < threshold && Math.abs(arg.vy || 0) < threshold;
16315
16244
  }
16316
16245
 
16246
+ var MeshCollider = /*#__PURE__*/ function() {
16247
+ function MeshCollider() {
16248
+ this.triangles = [];
16249
+ }
16250
+ var _proto = MeshCollider.prototype;
16251
+ _proto.getBoundingBoxData = function getBoundingBoxData() {
16252
+ return this.boundingBoxData;
16253
+ };
16254
+ _proto.setGeometry = function setGeometry(geometry, worldMatrix) {
16255
+ if (this.geometry !== geometry) {
16256
+ this.triangles = this.geometryToTriangles(geometry);
16257
+ this.geometry = geometry;
16258
+ }
16259
+ var area = [];
16260
+ for(var _iterator = _create_for_of_iterator_helper_loose(this.triangles), _step; !(_step = _iterator()).done;){
16261
+ var triangle = _step.value;
16262
+ area.push({
16263
+ p0: triangle.p0,
16264
+ p1: triangle.p1,
16265
+ p2: triangle.p2
16266
+ });
16267
+ }
16268
+ if (worldMatrix) {
16269
+ area.forEach(function(triangle) {
16270
+ triangle.p0 = worldMatrix.transformPoint(triangle.p0, new Vector3());
16271
+ triangle.p1 = worldMatrix.transformPoint(triangle.p1, new Vector3());
16272
+ triangle.p2 = worldMatrix.transformPoint(triangle.p2, new Vector3());
16273
+ });
16274
+ }
16275
+ this.boundingBoxData = {
16276
+ type: HitTestType.triangle,
16277
+ area: area
16278
+ };
16279
+ };
16280
+ _proto.geometryToTriangles = function geometryToTriangles(geometry) {
16281
+ var _geometry_getIndexData;
16282
+ var indices = (_geometry_getIndexData = geometry.getIndexData()) != null ? _geometry_getIndexData : [];
16283
+ var _geometry_getAttributeData;
16284
+ var vertices = (_geometry_getAttributeData = geometry.getAttributeData("aPos")) != null ? _geometry_getAttributeData : [];
16285
+ var res = [];
16286
+ for(var i = 0; i < indices.length; i += 3){
16287
+ var index0 = indices[i] * 3;
16288
+ var index1 = indices[i + 1] * 3;
16289
+ var index2 = indices[i + 2] * 3;
16290
+ var p0 = {
16291
+ x: vertices[index0],
16292
+ y: vertices[index0 + 1],
16293
+ z: vertices[index0 + 2]
16294
+ };
16295
+ var p1 = {
16296
+ x: vertices[index1],
16297
+ y: vertices[index1 + 1],
16298
+ z: vertices[index1 + 2]
16299
+ };
16300
+ var p2 = {
16301
+ x: vertices[index2],
16302
+ y: vertices[index2 + 1],
16303
+ z: vertices[index2 + 2]
16304
+ };
16305
+ res.push({
16306
+ p0: p0,
16307
+ p1: p1,
16308
+ p2: p2
16309
+ });
16310
+ }
16311
+ return res;
16312
+ };
16313
+ return MeshCollider;
16314
+ }();
16315
+
16317
16316
  var maxSpriteMeshItemCount = 8;
16318
16317
  function setSpriteMeshMaxItemCountByGPU(gpuCapability) {
16319
16318
  if (gpuCapability.maxVertexUniforms >= 256) {
@@ -30644,8 +30643,8 @@ registerPlugin("sprite", SpriteLoader, VFXItem, true);
30644
30643
  registerPlugin("particle", ParticleLoader, VFXItem, true);
30645
30644
  registerPlugin("cal", CalculateLoader, VFXItem, true);
30646
30645
  registerPlugin("interact", InteractLoader, VFXItem, true);
30647
- var version = "2.1.0-alpha.8";
30646
+ var version = "2.1.0-alpha.9";
30648
30647
  logger.info("Core version: " + version + ".");
30649
30648
 
30650
- export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, Asset, AssetLoader, AssetManager, BYTES_TYPE_MAP, BaseRenderComponent, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, ColorCurve, ColorPropertyTrack, Component, ComponentShapeType, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, DEFAULT_FPS, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, EffectsPackage, Engine, EventEmitter, EventSystem, FilterMode, Float16ArrayWrapper, FloatPropertyPlayableAsset, FloatPropertyTrack, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, MaterialTrack, Mesh, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, PassTextureCache, PathSegments, PluginSystem, PostProcessVolume, PropertyTrack, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, Scene, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, ShapeConnectType, ShapePointType, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StaticValue, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, Ticker, TimelineAsset, TimelineClip, TimelinePlayable, TrackAsset, TrackSortWrapper, TrackType, Transform, TransformAnimationPlayable, TransformPlayableAsset, TransformTrack, VFXItem, ValueGetter, Vector4Curve, Vector4PropertyTrack, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, blend, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createCopyShader, createGLContext, createKeyFrameMeta, createShape, createValueGetter, decimalEqual, defaultPlugins, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemFrameFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, normalizeColor, numberToFix, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxItemCountByGPU, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
30649
+ export { AbstractPlugin, ActivationPlayable, ActivationPlayableAsset, ActivationTrack, AnimationClip, AnimationClipPlayable, Asset, AssetLoader, AssetManager, BYTES_TYPE_MAP, BaseRenderComponent, Behaviour, BezierCurve, BezierCurvePath, BezierCurveQuat, BinaryAsset, COMPRESSED_TEXTURE, COPY_FRAGMENT_SHADER, COPY_MESH_SHADER_ID, COPY_VERTEX_SHADER, CalculateLoader, Camera, CameraController, CameraVFXItemLoader, ColorCurve, ColorPropertyTrack, Component, ComponentShapeType, Composition, CompositionComponent, CompositionSourceManager, DEFAULT_FONTS, DEFAULT_FPS, Database, DestroyOptions, Downloader, EFFECTS_COPY_MESH_NAME, EVENT_TYPE_CLICK, EVENT_TYPE_TOUCH_END, EVENT_TYPE_TOUCH_MOVE, EVENT_TYPE_TOUCH_START, EffectComponent, EffectsObject, EffectsPackage, Engine, EventEmitter, EventSystem, FilterMode, Float16ArrayWrapper, FloatPropertyPlayableAsset, FloatPropertyTrack, Framebuffer, GLSLVersion, GPUCapability, Geometry, GlobalUniforms, GradientValue, HELP_LINK, HitTestType, InteractComponent, InteractLoader, InteractMesh, Item, KTXTexture, LineSegments, LinearValue, Material, MaterialDataBlock, MaterialRenderType, MaterialTrack, Mesh, MeshCollider, ObjectBindingTrack, OrderType, PLAYER_OPTIONS_ENV_EDITOR, POST_PROCESS_SETTINGS, ParticleBehaviourPlayable, ParticleBehaviourPlayableAsset, ParticleLoader, ParticleMesh, ParticleSystem, ParticleSystemRenderer, PassTextureCache, PathSegments, PluginSystem, PostProcessVolume, PropertyTrack, RENDER_PASS_NAME_PREFIX, RENDER_PREFER_LOOKUP_TEXTURE, RUNTIME_ENV, RandomSetValue, RandomValue, RandomVectorValue, RenderFrame, RenderPass, RenderPassAttachmentStorageType, RenderPassDestroyAttachmentType, RenderPassPriorityNormal, RenderPassPriorityPostprocess, RenderPassPriorityPrepare, RenderTargetHandle, RenderTextureFormat, Renderbuffer, Renderer, RendererComponent, RuntimeClip, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0, SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0, SEMANTIC_PRE_COLOR_ATTACHMENT_0, SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0, SPRITE_VERTEX_STRIDE, Scene, SemanticMap, SerializationHelper, Shader, ShaderCompileResultStatus, ShaderFactory, ShaderType, ShaderVariant, ShapeComponent, ShapeConnectType, ShapePointType, SpriteColorPlayableAsset, SpriteColorTrack, SpriteComponent, SpriteLoader, StaticValue, SubCompositionPlayableAsset, SubCompositionTrack, TEMPLATE_USE_OFFSCREEN_CANVAS, TextComponent, TextComponentBase, TextLayout, TextLoader, TextStyle, Texture, TextureFactory, TextureLoadAction, TextureSourceType, TextureStoreAction, Ticker, TimelineAsset, TimelineClip, TimelinePlayable, TrackAsset, TrackSortWrapper, TrackType, Transform, TransformAnimationPlayable, TransformPlayableAsset, TransformTrack, VFXItem, ValueGetter, Vector4Curve, Vector4PropertyTrack, addByOrder, addItem, addItemWithOrder, applyMixins, assertExist, asserts, base64ToFile, blend, calculateTranslation, canvasPool, colorGradingFrag, colorStopsFromGradient, colorToArr$1 as colorToArr, combineImageTemplate, createCopyShader, createGLContext, createKeyFrameMeta, createShape, createValueGetter, decimalEqual, defaultPlugins, deserializeMipmapTexture, earcut, effectsClass, effectsClassStore, enlargeBuffer, ensureFixedNumber, ensureVec3, findPreviousRenderPass, gaussianDown_frag as gaussianDownFrag, gaussianDownHFrag, gaussianDownVFrag, gaussianUpFrag, generateEmptyTypedArray, generateGUID, generateHalfFloatTexture, generateTransparentTexture, generateWhiteTexture, getBackgroundImage, getColorFromGradientStops, getConfig, getDefaultTextureFactory, getGeometryByShape, getGeometryTriangles, getImageItemRenderInfo, getKTXTextureOptions, getKeyFrameMetaByRawValue, getMergedStore, getParticleMeshShader, getPixelRatio, getPreMultiAlpha, getStandardComposition, getStandardImage, getStandardItem, getStandardJSON, getTextureSize, glContext, glType2VertexFormatType, gpuTimer, imageDataFromColor, imageDataFromGradient, initErrors, initGLContext, integrate, interpolateColor, isAlipayMiniApp, isAndroid, isArray, isCanvas, isFunction, isIOS, isIOSByUA, isMiniProgram, isObject, isSimulatorCellPhone, isString, isUniformStruct, isUniformStructArray, isValidFontFamily, isWebGL2, isWechatMiniApp, itemFrag, itemFrameFrag, itemVert, loadAVIFOptional, loadBinary, loadBlob, loadImage, loadMedia, loadVideo, loadWebPOptional, logger, index as math, maxSpriteMeshItemCount, modifyMaxKeyframeShader, nearestPowerOfTwo, noop, normalizeColor, numberToFix, parsePercent$1 as parsePercent, particleFrag, particleOriginTranslateMap$1 as particleOriginTranslateMap, particleUniformTypeMap, particleVert, passRenderLevel, pluginLoaderMap, randomInRange, registerPlugin, removeItem, rotateVec2, screenMeshVert, serialize, setBlendMode, setConfig, setDefaultTextureFactory, setMaskMode, setMaxSpriteMeshItemCount, setRayFromCamera, setSideMode, setSpriteMeshMaxItemCountByGPU, sortByOrder, index$1 as spec, spriteMeshShaderFromFilter, spriteMeshShaderFromRenderInfo, spriteMeshShaderIdFromRenderInfo, thresholdFrag, throwDestroyedError, trailVert, translatePoint, trianglesFromRect, unregisterPlugin, valIfUndefined, value, valueDefine, vecFill, vecMulCombine, version, vertexFormatType2GLType };
30651
30650
  //# sourceMappingURL=index.mjs.map