mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
divide fix & API add (#5082)
This commit is contained in:
@@ -665,13 +665,23 @@ export class Color extends ValueType {
|
||||
return hsv;
|
||||
}
|
||||
|
||||
public set (other:Color);
|
||||
public set (r?:number, g?:number, b?:number, a?:number);
|
||||
/**
|
||||
* 设置当前颜色使其与指定颜色相等。
|
||||
* @param other 相比较的颜色。
|
||||
* @returns 当前颜色。
|
||||
*/
|
||||
public set (other:Color);
|
||||
|
||||
/**
|
||||
* 设置当前颜色使其与指定通道值相等。
|
||||
* @param [r=0] 指定的 Red 通道。
|
||||
* @param [g=0] 指定的 Green 通道。
|
||||
* @param [b=0] 指定的 Blue 通道。
|
||||
* @param [a=255] 指定的 Alpha 通道。
|
||||
* @returns 当前颜色。
|
||||
*/
|
||||
public set (r?:number, g?:number, b?:number, a?:number);
|
||||
|
||||
public set (r?: number|Color, g?:number, b?:number, a?:number ) {
|
||||
if (typeof r === 'object') {
|
||||
g = r.g;
|
||||
|
||||
@@ -42,6 +42,15 @@ deprecatedWrapper({
|
||||
],
|
||||
});
|
||||
|
||||
// 与新添加API 接口重名,需尽快更改后删除此弃用
|
||||
deprecatedWrapper({
|
||||
oldTarget: Vec2.prototype,
|
||||
oldPrefix: "Vec2",
|
||||
pairs: [
|
||||
['divide'],
|
||||
]
|
||||
});
|
||||
|
||||
deprecatedWrapper({
|
||||
oldTarget: Vec3,
|
||||
oldPrefix: 'Vec3',
|
||||
@@ -73,6 +82,15 @@ deprecatedWrapper({
|
||||
],
|
||||
});
|
||||
|
||||
// 与新添加API 接口重名,需尽快更改后删除此弃用
|
||||
deprecatedWrapper({
|
||||
oldTarget: Vec3.prototype,
|
||||
oldPrefix: "Vec3",
|
||||
pairs: [
|
||||
['divide'],
|
||||
]
|
||||
});
|
||||
|
||||
deprecatedWrapper({
|
||||
oldTarget: Vec4,
|
||||
oldPrefix: 'Vec4',
|
||||
@@ -104,6 +122,15 @@ deprecatedWrapper({
|
||||
],
|
||||
});
|
||||
|
||||
// 与新添加API 接口重名,需尽快更改后删除此弃用
|
||||
deprecatedWrapper({
|
||||
oldTarget: Vec4.prototype,
|
||||
oldPrefix: "Vec4",
|
||||
pairs: [
|
||||
['divide'],
|
||||
]
|
||||
});
|
||||
|
||||
deprecatedWrapper({
|
||||
oldTarget: Quat,
|
||||
oldPrefix: 'Quat',
|
||||
|
||||
+10
-4
@@ -637,15 +637,21 @@ export class Mat3 extends ValueType {
|
||||
t.m06, t.m07, t.m08);
|
||||
}
|
||||
|
||||
public set (other: Mat3);
|
||||
public set (m00?: number, m01?: number, m02?: number,
|
||||
m03?: number, m04?: number, m05?: number,
|
||||
m06?: number, m07?: number, m08?: number)
|
||||
/**
|
||||
* 设置当前矩阵使其与指定矩阵相等。
|
||||
* @param other 相比较的矩阵。
|
||||
* @returns `this`
|
||||
*/
|
||||
public set (other: Mat3);
|
||||
|
||||
/**
|
||||
* 设置当前矩阵指定元素值。
|
||||
* @returns `this`
|
||||
*/
|
||||
public set (m00?: number, m01?: number, m02?: number,
|
||||
m03?: number, m04?: number, m05?: number,
|
||||
m06?: number, m07?: number, m08?: number);
|
||||
|
||||
public set (m00: number | Mat3 = 1, m01: number = 0, m02: number = 0,
|
||||
m03: number = 0, m04: number = 1, m05: number = 0,
|
||||
m06: number = 0, m07: number = 0, m08: number = 1 ) {
|
||||
|
||||
+10
-5
@@ -1429,18 +1429,23 @@ export class Mat4 extends ValueType {
|
||||
t.m12, t.m13, t.m14, t.m15);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置当前矩阵使其与指定矩阵相等。
|
||||
* @param other 相比较的矩阵。
|
||||
* @returns `this`
|
||||
*/
|
||||
public set (other: Mat4);
|
||||
|
||||
/**
|
||||
* 设置当前矩阵指定元素值。
|
||||
* @returns `this`
|
||||
*/
|
||||
public set (
|
||||
m00?: number, m01?: number, m02?: number, m03?: number,
|
||||
m04?: number, m05?: number, m06?: number, m07?: number,
|
||||
m08?: number, m09?: number, m10?: number, m11?: number,
|
||||
m12?: number, m13?: number, m14?: number, m15?: number);
|
||||
|
||||
/**
|
||||
* 设置当前矩阵使其与指定矩阵相等。
|
||||
* @param other 相比较的矩阵。
|
||||
* @returns `this`
|
||||
*/
|
||||
public set (m00: Mat4 | number = 1, m01 = 0, m02 = 0, m03 = 0,
|
||||
m04 = 0, m05 = 1, m06 = 0, m07 = 0,
|
||||
m08 = 0, m09 = 0, m10 = 1, m11 = 0,
|
||||
|
||||
+12
-2
@@ -649,13 +649,23 @@ export class Quat extends ValueType {
|
||||
return new Quat(this.x, this.y, this.z, this.w);
|
||||
}
|
||||
|
||||
public set (other: Quat);
|
||||
public set (x?: number, y?: number, z?: number, w?: number);
|
||||
/**
|
||||
* 设置当前四元数使其与指定四元数相等。
|
||||
* @param other 相比较的四元数。
|
||||
* @returns `this`
|
||||
*/
|
||||
public set (other: Quat);
|
||||
|
||||
/**
|
||||
* 设置当前四元数指定元素值。
|
||||
* @param x 四元数 x 元素值
|
||||
* @param y 四元数 y 元素值
|
||||
* @param z 四元数 z 元素值
|
||||
* @param w 四元数 w 元素值
|
||||
* @returns `this`
|
||||
*/
|
||||
public set (x?: number, y?: number, z?: number, w?: number);
|
||||
|
||||
public set (x?: number | Quat, y?: number, z?: number, w?: number) {
|
||||
if (x && typeof x === 'object') {
|
||||
this.x = x.x;
|
||||
|
||||
+12
-2
@@ -271,13 +271,23 @@ export class Rect extends ValueType {
|
||||
return new Rect(this.x, this.y, this.width, this.height);
|
||||
}
|
||||
|
||||
public set (other: Rect);
|
||||
public set (x?: number, y?: number, width?: number, height?: number);
|
||||
/**
|
||||
* 设置当前矩形使其与指定矩形相等。
|
||||
* @param other 相比较的矩形。
|
||||
* @returns `this`
|
||||
*/
|
||||
public set (other: Rect);
|
||||
|
||||
/**
|
||||
* 设置当前矩形使其与指定参数的矩形相等。
|
||||
* @param x 指定矩形的 x 参数
|
||||
* @param y 指定矩形的 y 参数
|
||||
* @param width 指定矩形的 width 参数
|
||||
* @param height 指定矩形的 height 参数
|
||||
* @returns `this`
|
||||
*/
|
||||
public set (x?: number, y?: number, width?: number, height?: number);
|
||||
|
||||
public set (x?: Rect | number, y?: number, width?: number, height?: number) {
|
||||
if (x && typeof x === 'object') {
|
||||
this.y = x.y;
|
||||
|
||||
+10
-2
@@ -99,13 +99,21 @@ export class Size extends ValueType {
|
||||
return new Size(this.width, this.height);
|
||||
}
|
||||
|
||||
public set (other: Size);
|
||||
public set (width?: number, height?: number);
|
||||
/**
|
||||
* 设置当前尺寸使其与指定的尺寸相等。
|
||||
* @param other 相比较的尺寸。
|
||||
* @returns `this`
|
||||
*/
|
||||
public set (other: Size);
|
||||
|
||||
/**
|
||||
* 设置当前尺寸的具体参数。
|
||||
* @param width 要设置的 width 值
|
||||
* @param height 要设置的 height 值
|
||||
* @returns `this`
|
||||
*/
|
||||
public set (width?: number, height?: number);
|
||||
|
||||
public set (width?: Size | number, height?: number) {
|
||||
if (width && typeof width === 'object') {
|
||||
this.height = width.height;
|
||||
|
||||
+57
-3
@@ -102,6 +102,15 @@ export class Vec2 extends ValueType {
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh 逐元素向量除法
|
||||
*/
|
||||
public static divide <Out extends IVec2Like> (out: Out, a: Out, b: Out) {
|
||||
out.x = a.x / b.x;
|
||||
out.y = a.y / b.y;
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh 逐元素向量向上取整
|
||||
*/
|
||||
@@ -401,13 +410,21 @@ export class Vec2 extends ValueType {
|
||||
return new Vec2(this.x, this.y);
|
||||
}
|
||||
|
||||
public set (other: Vec2);
|
||||
public set (x?:number, y?:number);
|
||||
/**
|
||||
* 设置当前向量使其与指定向量相等。
|
||||
* @param other 相比较的向量。
|
||||
* @returns `this`
|
||||
*/
|
||||
public set (other: Vec2);
|
||||
|
||||
/**
|
||||
* 设置当前向量的具体分量值。
|
||||
* @param x 要设置的 x 分量的值
|
||||
* @param y 要设置的 y 分量的值
|
||||
* @returns `this`
|
||||
*/
|
||||
public set (x?:number, y?:number);
|
||||
|
||||
public set (x?: number | Vec2, y?: number) {
|
||||
if (x && typeof x === 'object') {
|
||||
this.x = x.x;
|
||||
@@ -422,7 +439,7 @@ export class Vec2 extends ValueType {
|
||||
/**
|
||||
* 判断当前向量是否在误差范围内与指定向量相等。
|
||||
* @param other 相比较的向量。
|
||||
* @param variance 允许的误差,应为非负数。
|
||||
* @param epsilon 允许的误差,应为非负数。
|
||||
* @returns 当两向量的各分量都在指定的误差范围内分别相等时,返回 `true`;否则返回 `false`。
|
||||
*/
|
||||
public equals (other: Vec2, epsilon = EPSILON) {
|
||||
@@ -434,6 +451,13 @@ export class Vec2 extends ValueType {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前向量是否在误差范围内与指定分量的向量相等。
|
||||
* @param x 相比较的向量的 x 分量。
|
||||
* @param y 相比较的向量的 y 分量。
|
||||
* @param epsilon 允许的误差,应为非负数。
|
||||
* @returns 当两向量的各分量都在指定的误差范围内分别相等时,返回 `true`;否则返回 `false`。
|
||||
*/
|
||||
public equals2f (x: number, y: number, epsilon = EPSILON) {
|
||||
return (
|
||||
Math.abs(this.x - x) <=
|
||||
@@ -452,6 +476,12 @@ export class Vec2 extends ValueType {
|
||||
return other && this.x === other.x && this.y === other.y;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前向量是否与指定分量的向量相等。
|
||||
* @param x 指定向量的 x 分量。
|
||||
* @param y 指定向量的 y 分量。
|
||||
* @returns 两向量的各分量都分别相等时返回 `true`;否则返回 `false`。
|
||||
*/
|
||||
public strictEquals2f (x:number, y:number) {
|
||||
return this.x === x && this.y === y;
|
||||
}
|
||||
@@ -499,6 +529,11 @@ export class Vec2 extends ValueType {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向量加法。将当前向量与指定分量的向量相加
|
||||
* @param x 指定的向量的 x 分量。
|
||||
* @param y 指定的向量的 y 分量。
|
||||
*/
|
||||
public add2f (x:number, y:number) {
|
||||
this.x = this.x + x;
|
||||
this.y = this.y + y;
|
||||
@@ -515,6 +550,11 @@ export class Vec2 extends ValueType {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向量减法。将当前向量减去指定分量的向量
|
||||
* @param x 指定的向量的 x 分量。
|
||||
* @param y 指定的向量的 y 分量。
|
||||
*/
|
||||
public subtract2f (x:number, y:number) {
|
||||
this.x = this.x - x;
|
||||
this.y = this.y - y;
|
||||
@@ -543,18 +583,32 @@ export class Vec2 extends ValueType {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向量乘法。将当前向量与指定分量的向量相乘的结果赋值给当前向量。
|
||||
* @param x 指定的向量的 x 分量。
|
||||
* @param y 指定的向量的 y 分量。
|
||||
*/
|
||||
public multiply2f (x:number, y:number) {
|
||||
this.x = this.x * x;
|
||||
this.y = this.y * y;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。
|
||||
* @param other 指定的向量
|
||||
*/
|
||||
public divide (other: Vec2) {
|
||||
this.x = this.x / other.x;
|
||||
this.y = this.y / other.y;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。
|
||||
* @param x 指定的向量的 x 分量。
|
||||
* @param y 指定的向量的 y 分量。
|
||||
*/
|
||||
public divide2f (x:number, y:number) {
|
||||
this.x = this.x / x;
|
||||
this.y = this.y / y;
|
||||
|
||||
+64
-2
@@ -117,6 +117,16 @@ export class Vec3 extends ValueType {
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh 逐元素向量除法
|
||||
*/
|
||||
public static divide<Out extends IVec3Like> (out: Out, a: Out, b: Out) {
|
||||
out.x = a.x / b.x;
|
||||
out.y = a.y / b.y;
|
||||
out.z = a.z / b.z;
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh 逐元素向量向上取整
|
||||
*/
|
||||
@@ -612,13 +622,22 @@ export class Vec3 extends ValueType {
|
||||
return new Vec3(this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
public set (other: Vec3);
|
||||
public set (x?: number, y?: number, z?: number);
|
||||
/**
|
||||
* 设置当前向量使其与指定向量相等。
|
||||
* @param other 相比较的向量。
|
||||
* @returns `this`
|
||||
*/
|
||||
public set (other: Vec3);
|
||||
|
||||
/**
|
||||
* 设置当前向量的具体分量值。
|
||||
* @param x 要设置的 x 分量的值
|
||||
* @param y 要设置的 y 分量的值
|
||||
* @param z 要设置的 z 分量的值
|
||||
* @returns `this`
|
||||
*/
|
||||
public set (x?: number, y?: number, z?: number);
|
||||
|
||||
public set (x?: number | Vec3, y?: number, z?: number) {
|
||||
if (x && typeof x === 'object') {
|
||||
this.x = x.x;
|
||||
@@ -649,6 +668,14 @@ export class Vec3 extends ValueType {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前向量是否在误差范围内与指定分量的向量相等。
|
||||
* @param x 相比较的向量的 x 分量。
|
||||
* @param y 相比较的向量的 y 分量。
|
||||
* @param z 相比较的向量的 z 分量。
|
||||
* @param epsilon 允许的误差,应为非负数。
|
||||
* @returns 当两向量的各分量都在指定的误差范围内分别相等时,返回 `true`;否则返回 `false`。
|
||||
*/
|
||||
public equals3f (x: number, y: number, z: number, epsilon = EPSILON) {
|
||||
return (
|
||||
Math.abs(this.x - x) <=
|
||||
@@ -670,6 +697,13 @@ export class Vec3 extends ValueType {
|
||||
return this.x === other.x && this.y === other.y && this.z === other.z;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前向量是否与指定分量的向量相等。
|
||||
* @param x 指定向量的 x 分量。
|
||||
* @param y 指定向量的 y 分量。
|
||||
* @param z 指定向量的 z 分量。
|
||||
* @returns 两向量的各分量都分别相等时返回 `true`;否则返回 `false`。
|
||||
*/
|
||||
public strictEquals3f (x:number, y:number, z:number) {
|
||||
return this.x === x && this.y === y && this.z === z;
|
||||
}
|
||||
@@ -705,6 +739,12 @@ export class Vec3 extends ValueType {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向量加法。将当前向量与指定分量的向量相加
|
||||
* @param x 指定的向量的 x 分量。
|
||||
* @param y 指定的向量的 y 分量。
|
||||
* @param z 指定的向量的 z 分量。
|
||||
*/
|
||||
public add3f (x:number, y:number, z:number) {
|
||||
this.x = this.x + x;
|
||||
this.y = this.y + y;
|
||||
@@ -723,6 +763,12 @@ export class Vec3 extends ValueType {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向量减法。将当前向量减去指定分量的向量
|
||||
* @param x 指定的向量的 x 分量。
|
||||
* @param y 指定的向量的 y 分量。
|
||||
* @param z 指定的向量的 z 分量。
|
||||
*/
|
||||
public subtract3f (x:number, y:number, z:number) {
|
||||
this.x = this.x - x;
|
||||
this.y = this.y - y;
|
||||
@@ -754,6 +800,12 @@ export class Vec3 extends ValueType {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向量乘法。将当前向量与指定分量的向量相乘的结果赋值给当前向量。
|
||||
* @param x 指定的向量的 x 分量。
|
||||
* @param y 指定的向量的 y 分量。
|
||||
* @param z 指定的向量的 z 分量。
|
||||
*/
|
||||
public multiply3f (x:number, y:number, z:number) {
|
||||
this.x = this.x * x;
|
||||
this.y = this.y * y;
|
||||
@@ -761,6 +813,10 @@ export class Vec3 extends ValueType {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。
|
||||
* @param other 指定的向量
|
||||
*/
|
||||
public divide (other: Vec3) {
|
||||
this.x = this.x / other.x;
|
||||
this.y = this.y / other.y;
|
||||
@@ -768,6 +824,12 @@ export class Vec3 extends ValueType {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。
|
||||
* @param x 指定的向量的 x 分量。
|
||||
* @param y 指定的向量的 y 分量。
|
||||
* @param z 指定的向量的 z 分量。
|
||||
*/
|
||||
public divide3f (x:number, y:number, z:number) {
|
||||
this.x = this.x / x;
|
||||
this.y = this.y / y;
|
||||
|
||||
+72
-2
@@ -110,6 +110,17 @@ export class Vec4 extends ValueType {
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh 逐元素向量除法
|
||||
*/
|
||||
public static divide <Out extends IVec4Like> (out: Out, a: Out, b: Out) {
|
||||
out.x = a.x / b.x;
|
||||
out.y = a.y / b.y;
|
||||
out.z = a.z / b.z;
|
||||
out.w = a.w / b.w;
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @zh 逐元素向量向上取整
|
||||
*/
|
||||
@@ -459,13 +470,23 @@ export class Vec4 extends ValueType {
|
||||
return new Vec4(this.x, this.y, this.z, this.w);
|
||||
}
|
||||
|
||||
public set (other: Vec4);
|
||||
public set (x?: number, y?: number, z?: number, w?: number);
|
||||
/**
|
||||
* 设置当前向量使其与指定向量相等。
|
||||
* @param other 相比较的向量。
|
||||
* @returns `this`
|
||||
*/
|
||||
public set (other: Vec4);
|
||||
|
||||
/**
|
||||
* 设置当前向量的具体分量值。
|
||||
* @param x 要设置的 x 分量的值
|
||||
* @param y 要设置的 y 分量的值
|
||||
* @param z 要设置的 z 分量的值
|
||||
* @param w 要设置的 w 分量的值
|
||||
* @returns `this`
|
||||
*/
|
||||
public set (x?: number, y?: number, z?: number, w?: number);
|
||||
|
||||
public set (x?: number | Vec4, y?: number, z?: number, w?: number) {
|
||||
if (x && typeof x === 'object') {
|
||||
this.x = x.x;
|
||||
@@ -494,6 +515,15 @@ export class Vec4 extends ValueType {
|
||||
Math.abs(this.w - other.w) <= epsilon * Math.max(1.0, Math.abs(this.w), Math.abs(other.w)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前向量是否在误差范围内与指定分量的向量相等。
|
||||
* @param x 相比较的向量的 x 分量。
|
||||
* @param y 相比较的向量的 y 分量。
|
||||
* @param z 相比较的向量的 z 分量。
|
||||
* @param w 相比较的向量的 w 分量。
|
||||
* @param epsilon 允许的误差,应为非负数。
|
||||
* @returns 当两向量的各分量都在指定的误差范围内分别相等时,返回 `true`;否则返回 `false`。
|
||||
*/
|
||||
public equals4f (x: number, y: number, z: number, w:number, epsilon = EPSILON) {
|
||||
return (Math.abs(this.x - x) <= epsilon * Math.max(1.0, Math.abs(this.x), Math.abs(x)) &&
|
||||
Math.abs(this.y - y) <= epsilon * Math.max(1.0, Math.abs(this.y), Math.abs(y)) &&
|
||||
@@ -510,6 +540,14 @@ export class Vec4 extends ValueType {
|
||||
return this.x === other.x && this.y === other.y && this.z === other.z && this.w === other.w;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前向量是否与指定分量的向量相等。
|
||||
* @param x 指定向量的 x 分量。
|
||||
* @param y 指定向量的 y 分量。
|
||||
* @param z 指定向量的 z 分量。
|
||||
* @param w 指定向量的 w 分量。
|
||||
* @returns 两向量的各分量都分别相等时返回 `true`;否则返回 `false`。
|
||||
*/
|
||||
public strictEquals4f (x: number, y: number, z: number, w:number) {
|
||||
return this.x === x && this.y === y && this.z === z && this.w === w;
|
||||
}
|
||||
@@ -565,6 +603,13 @@ export class Vec4 extends ValueType {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向量加法。将当前向量与指定分量的向量相加
|
||||
* @param x 指定的向量的 x 分量。
|
||||
* @param y 指定的向量的 y 分量。
|
||||
* @param z 指定的向量的 z 分量。
|
||||
* @param w 指定的向量的 w 分量。
|
||||
*/
|
||||
public add4f (x:number, y:number, z:number, w:number) {
|
||||
this.x = this.x + x;
|
||||
this.y = this.y + y;
|
||||
@@ -585,6 +630,13 @@ export class Vec4 extends ValueType {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向量减法。将当前向量减去指定分量的向量
|
||||
* @param x 指定的向量的 x 分量。
|
||||
* @param y 指定的向量的 y 分量。
|
||||
* @param z 指定的向量的 z 分量。
|
||||
* @param w 指定的向量的 w 分量。
|
||||
*/
|
||||
public subtract4f (x:number, y:number, z:number, w:number) {
|
||||
this.x = this.x - x;
|
||||
this.y = this.y - y;
|
||||
@@ -619,6 +671,13 @@ export class Vec4 extends ValueType {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向量乘法。将当前向量与指定分量的向量相乘的结果赋值给当前向量。
|
||||
* @param x 指定的向量的 x 分量。
|
||||
* @param y 指定的向量的 y 分量。
|
||||
* @param z 指定的向量的 z 分量。
|
||||
* @param w 指定的向量的 w 分量。
|
||||
*/
|
||||
public multiply4f (x:number, y:number, z:number, w:number) {
|
||||
this.x = this.x * x;
|
||||
this.y = this.y * y;
|
||||
@@ -627,6 +686,10 @@ export class Vec4 extends ValueType {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。
|
||||
* @param other 指定的向量
|
||||
*/
|
||||
public divide (other: Vec4) {
|
||||
this.x = this.x / other.x;
|
||||
this.y = this.y / other.y;
|
||||
@@ -635,6 +698,13 @@ export class Vec4 extends ValueType {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向量逐元素相除。将当前向量与指定分量的向量相除的结果赋值给当前向量。
|
||||
* @param x 指定的向量的 x 分量。
|
||||
* @param y 指定的向量的 y 分量。
|
||||
* @param z 指定的向量的 z 分量。
|
||||
* @param w 指定的向量的 w 分量。
|
||||
*/
|
||||
public divide4f (x:number, y:number, z:number, w:number) {
|
||||
this.x = this.x / x;
|
||||
this.y = this.y / y;
|
||||
|
||||
@@ -193,8 +193,7 @@ export default class Touch {
|
||||
_vec2.set(this._point);
|
||||
_vec2.subtract(this._prevPoint);
|
||||
Vec2.set(out, cc.view.getScaleX(), cc.view.getScaleY());
|
||||
out.x = _vec2.x / out.x;
|
||||
out.y = _vec2.y / out.y;
|
||||
Vec2.divide(out, _vec2, out);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@@ -184,13 +184,9 @@ export class Node extends BaseNode implements INode {
|
||||
parent.updateWorldTransform();
|
||||
Vec3.subtract(local, this._pos, parent._pos);
|
||||
Vec3.transformQuat(local, local, Quat.conjugate(q_a, parent._rot));
|
||||
local.x /= parent._scale.x;
|
||||
local.y /= parent._scale.y;
|
||||
local.z /= parent._scale.z;
|
||||
Vec3.divide(local, local, parent._scale);
|
||||
Quat.multiply(this._lrot, Quat.conjugate(q_a, parent._rot), this._rot);
|
||||
this._lscale.x = this._scale.x / parent._scale.x;
|
||||
this._lscale.y = this._scale.y / parent._scale.y;
|
||||
this._lscale.z = this._scale.z / parent._scale.z;
|
||||
Vec3.divide(this._lscale, this._scale, parent._scale);
|
||||
} else {
|
||||
Vec3.copy(this._lpos, this._pos);
|
||||
Quat.copy(this._lrot, this._rot);
|
||||
@@ -621,9 +617,7 @@ export class Node extends BaseNode implements INode {
|
||||
parent.updateWorldTransform();
|
||||
Vec3.subtract(local, this._pos, parent._pos);
|
||||
Vec3.transformQuat(local, local, Quat.conjugate(q_a, parent._rot));
|
||||
local.x /= parent._scale.x;
|
||||
local.y /= parent._scale.y;
|
||||
local.z /= parent._scale.z;
|
||||
Vec3.divide(local, local, parent._scale);
|
||||
} else {
|
||||
Vec3.copy(local, this._pos);
|
||||
}
|
||||
@@ -773,9 +767,7 @@ export class Node extends BaseNode implements INode {
|
||||
}
|
||||
if (this._parent) {
|
||||
this._parent.getWorldScale(v3_a);
|
||||
this._lscale.x = this._scale.x / v3_a.x;
|
||||
this._lscale.y = this._scale.y / v3_a.y;
|
||||
this._lscale.z = this._scale.z / v3_a.z;
|
||||
Vec3.divide(this._lscale, this._scale, v3_a);
|
||||
} else {
|
||||
Vec3.copy(this._lscale, this._scale);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user