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