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