From 3247738be5bac4c9f443b3e40d208f8f14419cdb Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 19 Jan 2020 18:17:41 +0800 Subject: [PATCH] Fix error definination --- cocos/core/math/vec3.ts | 75 ++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 39 deletions(-) diff --git a/cocos/core/math/vec3.ts b/cocos/core/math/vec3.ts index f1495b0dd1..157a9d9d81 100644 --- a/cocos/core/math/vec3.ts +++ b/cocos/core/math/vec3.ts @@ -90,7 +90,7 @@ export class Vec3 extends ValueType { /** * @zh 逐元素向量加法 */ - public static add (out: Out, a: Out, b: Out) { + public static add (out: Out, a: IVec3Like, b: IVec3Like) { out.x = a.x + b.x; out.y = a.y + b.y; out.z = a.z + b.z; @@ -100,7 +100,7 @@ export class Vec3 extends ValueType { /** * @zh 逐元素向量减法 */ - public static subtract (out: Out, a: Out, b: Out) { + public static subtract (out: Out, a: IVec3Like, b: IVec3Like) { out.x = a.x - b.x; out.y = a.y - b.y; out.z = a.z - b.z; @@ -110,7 +110,7 @@ export class Vec3 extends ValueType { /** * @zh 逐元素向量乘法 (分量积) */ - public static multiply (out: Out, a: Vec3Like_1, b: Vec3Like_2) { + public static multiply (out: Out, a: IVec3Like, b: IVec3Like) { out.x = a.x * b.x; out.y = a.y * b.y; out.z = a.z * b.z; @@ -120,7 +120,7 @@ export class Vec3 extends ValueType { /** * @zh 逐元素向量除法 */ - public static divide (out: Out, a: Out, b: Out) { + public static divide (out: Out, a: IVec3Like, b: IVec3Like) { out.x = a.x / b.x; out.y = a.y / b.y; out.z = a.z / b.z; @@ -130,7 +130,7 @@ export class Vec3 extends ValueType { /** * @zh 逐元素向量向上取整 */ - public static ceil (out: Out, a: Out) { + public static ceil (out: Out, a: IVec3Like) { out.x = Math.ceil(a.x); out.y = Math.ceil(a.y); out.z = Math.ceil(a.z); @@ -140,7 +140,7 @@ export class Vec3 extends ValueType { /** * @zh 逐元素向量向下取整 */ - public static floor (out: Out, a: Out) { + public static floor (out: Out, a: IVec3Like) { out.x = Math.floor(a.x); out.y = Math.floor(a.y); out.z = Math.floor(a.z); @@ -150,7 +150,7 @@ export class Vec3 extends ValueType { /** * @zh 逐元素向量最小值 */ - public static min (out: Out, a: Out, b: Out) { + public static min (out: Out, a: IVec3Like, b: IVec3Like) { out.x = Math.min(a.x, b.x); out.y = Math.min(a.y, b.y); out.z = Math.min(a.z, b.z); @@ -160,7 +160,7 @@ export class Vec3 extends ValueType { /** * @zh 逐元素向量最大值 */ - public static max (out: Out, a: Out, b: Out) { + public static max (out: Out, a: IVec3Like, b: IVec3Like) { out.x = Math.max(a.x, b.x); out.y = Math.max(a.y, b.y); out.z = Math.max(a.z, b.z); @@ -170,7 +170,7 @@ export class Vec3 extends ValueType { /** * @zh 逐元素向量四舍五入取整 */ - public static round (out: Out, a: Out) { + public static round (out: Out, a: IVec3Like) { out.x = Math.round(a.x); out.y = Math.round(a.y); out.z = Math.round(a.z); @@ -190,7 +190,7 @@ export class Vec3 extends ValueType { /** * @zh 逐元素向量乘加: A + B * scale */ - public static scaleAndAdd (out: Out, a: Out, b: Out, scale: number) { + public static scaleAndAdd (out: Out, a: IVec3Like, b: IVec3Like, scale: number) { out.x = a.x + b.x * scale; out.y = a.y + b.y * scale; out.z = a.z + b.z * scale; @@ -200,7 +200,7 @@ export class Vec3 extends ValueType { /** * @zh 求两向量的欧氏距离 */ - public static distance (a: Out, b: Out) { + public static distance (a: IVec3Like, b: IVec3Like) { _x = b.x - a.x; _y = b.y - a.y; _z = b.z - a.z; @@ -210,7 +210,7 @@ export class Vec3 extends ValueType { /** * @zh 求两向量的欧氏距离平方 */ - public static squaredDistance (a: Out, b: Out) { + public static squaredDistance (a: IVec3Like, b: IVec3Like) { _x = b.x - a.x; _y = b.y - a.y; _z = b.z - a.z; @@ -220,7 +220,7 @@ export class Vec3 extends ValueType { /** * @zh 求向量长度 */ - public static len (a: Out) { + public static len (a: IVec3Like) { _x = a.x; _y = a.y; _z = a.z; @@ -230,7 +230,7 @@ export class Vec3 extends ValueType { /** * @zh 求向量长度平方 */ - public static lengthSqr (a: Out) { + public static lengthSqr (a: IVec3Like) { _x = a.x; _y = a.y; _z = a.z; @@ -240,7 +240,7 @@ export class Vec3 extends ValueType { /** * @zh 逐元素向量取负 */ - public static negate (out: Out, a: Out) { + public static negate (out: Out, a: IVec3Like) { out.x = -a.x; out.y = -a.y; out.z = -a.z; @@ -250,7 +250,7 @@ export class Vec3 extends ValueType { /** * @zh 逐元素向量取倒数,接近 0 时返回 Infinity */ - public static invert (out: Out, a: Out) { + public static invert (out: Out, a: IVec3Like) { out.x = 1.0 / a.x; out.y = 1.0 / a.y; out.z = 1.0 / a.z; @@ -260,7 +260,7 @@ export class Vec3 extends ValueType { /** * @zh 逐元素向量取倒数,接近 0 时返回 0 */ - public static invertSafe (out: Out, a: Out) { + public static invertSafe (out: Out, a: IVec3Like) { _x = a.x; _y = a.y; _z = a.z; @@ -289,7 +289,7 @@ export class Vec3 extends ValueType { /** * @zh 归一化向量 */ - public static normalize (out: Out, a: Vec3Like) { + public static normalize (out: Out, a: IVec3Like) { _x = a.x; _y = a.y; _z = a.z; @@ -307,14 +307,14 @@ export class Vec3 extends ValueType { /** * @zh 向量点积(数量积) */ - public static dot (a: Out, b: Out) { + public static dot (a: Out, b: IVec3Like) { return a.x * b.x + a.y * b.y + a.z * b.z; } /** * @zh 向量叉积(向量积) */ - public static cross (out: Out, a: Vec3Like_1, b: Vec3Like_2) { + public static cross (out: Out, a: IVec3Like, b: IVec3Like) { const { x: ax, y: ay, z: az } = a; const { x: bx, y: by, z: bz } = b; out.x = ay * bz - az * by; @@ -326,7 +326,7 @@ export class Vec3 extends ValueType { /** * @zh 逐元素向量线性插值: A + t * (B - A) */ - public static lerp (out: Out, a: Out, b: Out, t: number) { + public static lerp (out: Out, a: IVec3Like, b: IVec3Like, t: number) { out.x = a.x + t * (b.x - a.x); out.y = a.y + t * (b.y - a.y); out.z = a.z + t * (b.z - a.z); @@ -353,7 +353,7 @@ export class Vec3 extends ValueType { /** * @zh 向量与四维矩阵乘法,默认向量第四位为 1。 */ - public static transformMat4 (out: Out, a: Vec3Like, m: MatLike) { + public static transformMat4 (out: Out, a: IVec3Like, m: IMat4Like) { _x = a.x; _y = a.y; _z = a.z; @@ -368,7 +368,7 @@ export class Vec3 extends ValueType { /** * @zh 向量与四维矩阵乘法,默认向量第四位为 0。 */ - public static transformMat4Normal (out: Out, a: Out, m: MatLike) { + public static transformMat4Normal (out: Out, a: IVec3Like, m: IMat4Like) { _x = a.x; _y = a.y; _z = a.z; @@ -383,7 +383,7 @@ export class Vec3 extends ValueType { /** * @zh 向量与三维矩阵乘法 */ - public static transformMat3 (out: Out, a: Out, m: MatLike) { + public static transformMat3 (out: Out, a: IVec3Like, m: IMat3Like) { _x = a.x; _y = a.y; _z = a.z; @@ -396,8 +396,7 @@ export class Vec3 extends ValueType { /** * @zh 向量仿射变换 */ - public static transformAffine - (out: Out, v: VecLike, m: MatLike) { + public static transformAffine (out: Out, v: IVec3Like, m: IMat4Like) { _x = v.x; _y = v.y; _z = v.z; @@ -410,7 +409,7 @@ export class Vec3 extends ValueType { /** * @zh 向量四元数乘法 */ - public static transformQuat (out: Out, a: VecLike, q: QuatLike) { + public static transformQuat (out: Out, a: IVec3Like, q: IQuatLike) { // benchmarks: http://jsperf.com/quaternion-transform-Vec3-implementations // calculate quat * vec @@ -429,8 +428,7 @@ export class Vec3 extends ValueType { /** * @zh 以缩放 -> 旋转 -> 平移顺序变换向量 */ - public static transformRTS ( - out: Out, a: VecLike, r: QuatLike, t: VecLike, s: VecLike) { + public static transformRTS (out: Out, a: IVec3Like, r: IQuatLike, t: IVec3Like, s: IVec3Like) { const x = a.x * s.x; const y = a.y * s.y; const z = a.z * s.z; @@ -447,8 +445,7 @@ export class Vec3 extends ValueType { /** * @zh 以平移 -> 旋转 -> 缩放顺序逆变换向量 */ - public static transformInverseRTS ( - out: Out, a: VecLike, r: QuatLike, t: VecLike, s: VecLike) { + public static transformInverseRTS (out: Out, a: IVec3Like, r: IQuatLike, t: IVec3Like, s: IVec3Like) { const x = a.x - t.x; const y = a.y - t.y; const z = a.z - t.z; @@ -468,7 +465,7 @@ export class Vec3 extends ValueType { * @param o 旋转中心 * @param a 旋转弧度 */ - public static rotateX (out: Out, v: Out, o: Out, a: number) { + public static rotateX (out: Out, v: IVec3Like, o: IVec3Like, a: number) { // Translate point to the origin _x = v.x - o.x; _y = v.y - o.y; @@ -495,7 +492,7 @@ export class Vec3 extends ValueType { * @param o 旋转中心 * @param a 旋转弧度 */ - public static rotateY (out: Out, v: Out, o: Out, a: number) { + public static rotateY (out: Out, v: IVec3Like, o: IVec3Like, a: number) { // Translate point to the origin _x = v.x - o.x; _y = v.y - o.y; @@ -522,7 +519,7 @@ export class Vec3 extends ValueType { * @param o 旋转中心 * @param a 旋转弧度 */ - public static rotateZ (out: Out, v: Out, o: Out, a: number) { + public static rotateZ (out: Out, v: IVec3Like, o: IVec3Like, a: number) { // Translate point to the origin _x = v.x - o.x; _y = v.y - o.y; @@ -569,14 +566,14 @@ export class Vec3 extends ValueType { /** * @zh 向量等价判断 */ - public static strictEquals (a: Out, b: Out) { + public static strictEquals (a: IVec3Like, b: IVec3Like) { return a.x === b.x && a.y === b.y && a.z === b.z; } /** * @zh 排除浮点数误差的向量近似等价判断 */ - public static equals (a: Out, b: Out, epsilon = EPSILON) { + public static equals (a: IVec3Like, b: IVec3Like, epsilon = EPSILON) { const { x: a0, y: a1, z: a2 } = a; const { x: b0, y: b1, z: b2 } = b; return ( @@ -592,7 +589,7 @@ export class Vec3 extends ValueType { /** * @zh 求两向量夹角弧度 */ - public static angle (a: Out, b: Out) { + public static angle (a: IVec3Like, b: IVec3Like) { Vec3.normalize(v3_1, a); Vec3.normalize(v3_2, b); const cosine = Vec3.dot(v3_1, v3_2); @@ -610,7 +607,7 @@ export class Vec3 extends ValueType { * @param a 待投影向量 * @param n 指定平面的法线 */ - public static projectOnPlane (out: Out, a: Out, n: Out) { + public static projectOnPlane (out: Out, a: IVec3Like, n: IVec3Like) { return Vec3.subtract(out, a, Vec3.project(out, a, n)); } @@ -619,7 +616,7 @@ export class Vec3 extends ValueType { * @param a 待投影向量 * @param n 目标向量 */ - public static project (out: Out, a: Out, b: Out) { + public static project (out: Out, a: IVec3Like, b: IVec3Like) { const sqrLen = Vec3.lengthSqr(b); if (sqrLen < 0.000001) { return Vec3.set(out, 0, 0, 0);