
    export class NodeUtil {
        public static All: number = Laya.Physics3DUtils.COLLISIONFILTERGROUP_ALLFILTER;
        public static Body: number = Laya.Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER1;
        public static Head: number = Laya.Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER2;
        public static Citizen:number = Laya.Physics3DUtils.COLLISIONFILTERGROUP_CUSTOMFILTER3;

    public static GetChild(node: Laya.Node, cond: Function): Laya.Node {
        let queue = [];
        for (let i = 0; i < node.numChildren; i++) {
            queue.push(node.getChildAt(i));
        }
        while (queue.length > 0) {
            let first = queue.shift();
            if (cond(first)) {
                return first;
            } else {
                for (let i = 0; i < first.numChildren; i++) {
                    queue.push(first.getChildAt(i));
                }
            }
        }
        return null;
    }

    public static GetChildByName(node: Laya.Node, name: string): Laya.Node {
        return NodeUtil.GetChild(node, s => s.name == name);
    }

    public static getChildren(node: Laya.Node, cond: Function): Node[] {
        let finded = [];
        let queue = [];
        for (let i = 0; i < node.numChildren; i++) {
            queue.push(node.getChildAt(i));
        }
        while (queue.length > 0) {
            let first = queue.shift();
            if (cond(first)) {
                finded.push(first);
            }
            for (let i = 0; i < first.numChildren; i++) {
                queue.push(first.getChildAt(i));
            }
        }
        return finded;
    }

    /**关闭碰撞器 */
    public static SetColliderInactive(sp: Laya.Sprite3D) {
        let colliders = NodeUtil.getChildren(sp, s => s.getComponent(Laya.PhysicsCollider)) as any[];
        colliders.forEach(s => {
            let collider = s.getComponent(Laya.PhysicsCollider) as Laya.PhysicsCollider;
            if (collider) {
                collider.enabled = false;
            }
        }, this);
    }

    /**设置碰撞器组 */
    static SetColliderGroup(sp: Laya.Sprite3D,_group:number) {
        let colliders = NodeUtil.getChildren(sp, s => s.getComponent(Laya.PhysicsCollider)) as any[];
        colliders.forEach(s => {
            let collisionGroup = _group;
            let collider = s.getComponent(Laya.PhysicsCollider) as Laya.PhysicsCollider;
            collider.collisionGroup = collisionGroup;
        }, this);
    }

}

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;
    }
}