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