import { MathHelper } from "./MathHelper";
// import { AssetManager } from "../Game/AssetManager";

export class Vector3Helper {
    public static get Zero(): Laya.Vector3 {
        return new Laya.Vector3(0, 0, 0);
    }

    public static get Up(): Laya.Vector3 {
        return new Laya.Vector3(0, 1, 0);
    }

    public static Add(a: Laya.Vector3, b: Laya.Vector3): Laya.Vector3 {
        return new Laya.Vector3(a.x + b.x, a.y + b.y, a.z + b.z);
    }

    public static Substract(a: Laya.Vector3, b: Laya.Vector3): Laya.Vector3 {
        return new Laya.Vector3(a.x - b.x, a.y - b.y, a.z - b.z);
    }

    public static Scale(a: Laya.Vector3, b: number): Laya.Vector3 {
        let res = Vector3Helper.Zero;
        Laya.Vector3.scale(a, b, res);
        return res;
    }

    public static Lerp(a: Laya.Vector3, b: Laya.Vector3, t: number): Laya.Vector3 {
        let res = Vector3Helper.Zero;
        Laya.Vector3.lerp(a, b, t, res);
        return res;
    }

    public static ClampEuler(euler: Laya.Vector3) {
        return new Laya.Vector3(
            MathHelper.ClampEuler(euler.x),
            MathHelper.ClampEuler(euler.y),
            MathHelper.ClampEuler(euler.z)
        );
    }

    public static RotateY(a: Laya.Vector3, deg: number): Laya.Vector3 {
        let matrix = new Laya.Matrix4x4();
        Laya.Matrix4x4.createRotationY(deg * MathHelper.ToRad(), matrix);
        let res = Vector3Helper.Zero;
        Laya.Vector3.transformCoordinate(a, matrix, res);
        return res;
    }

    /**去括号 */
    public static CancelBrackets(str:string):any[]{
        let a = str.split("(");
        let b = a[1];
        let c = b.split(")");
        let d = c[0];
        let e = d.split(",")
        return e;
    }
}

export class Transform3DHelper {
    static getForward(transform:Laya.Transform3D):Laya.Vector3 {
        let forward = new Laya.Vector3();
        transform.getForward(forward);
        Laya.Vector3.scale(forward, -1, forward);
        Laya.Vector3.normalize(forward, forward);
        return forward;
    }
}