fix Vec3.cross (#5371)

This commit is contained in:
Yun Hsiao Wu
2019-09-11 16:44:16 +08:00
committed by Weiliang Wang
parent 76542aacf8
commit fdfcd89265
2 changed files with 7 additions and 6 deletions
+5 -4
View File
@@ -315,10 +315,11 @@ export class Vec3 extends ValueType {
* @zh 向量叉积(向量积)
*/
public static cross<Out extends IVec3Like, Vec3Like_1 extends IVec3Like, Vec3Like_2 extends IVec3Like > (out: Out, a: Vec3Like_1, b: Vec3Like_2) {
out.x = a.y * b.z - a.z * b.y;
out.y = a.z * b.x - a.x * b.z;
out.z = a.x * b.y - a.y * b.x;
const { x: ax, y: ay, z: az } = a;
const { x: bx, y: by, z: bz } = b;
out.x = ay * bz - az * by;
out.y = az * bx - ax * bz;
out.z = ax * by - ay * bx;
return out;
}
+2 -2
View File
@@ -2,10 +2,10 @@
* @category 3d/primitive
*/
import { ccclass, property } from '../data/class-decorator';
import { createMesh } from '../3d/misc/utils';
import * as primitives from '../primitive';
import { Mesh } from '../assets/mesh';
import { ccclass, property } from '../data/class-decorator';
import * as primitives from '../primitive';
import { ccenum } from '../value-types/enum';
enum PrimitiveType {