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