# MeshGizmo

使用MeshGizmo,可以在游戏场景中绘制有基础光照的网格。结合RectGizmo、LineGizmo,我们组合了出编辑器的移动指示器

# 方法

函数 功能
center 网格的重心坐标
size 网格的缩放尺度
WorldMatrix 网格世界矩阵的访问器
setTintColor 设定网格的颜色
resetGizmo 重置网格的属性
addRenderCamera 明确指定某个相机需要绘制该Gizmo
deleRenderCamera 明确某个相机不需要绘制该Gizmo
clearRenderCameraSet 标记所有相机均不绘制该Gizmo

# 示例

import engine from "engine";
export default class ExampleClass extends engine.Script{
    
   public meshGizmo;

    public onAwake(){
        var center = engine.Vector3.ZERO;
        var scale = engine.Vector3.ONE;
        // 创建一个框架预置的ConeMesh
        var coneMesh = engine.loader.getAsset('Cone')!;
        this.meshGizmo = engine.Gizmos.createMeshGizmo(center, scale, coneMesh);
        
        // 基础色调整为蓝色
        this.meshGizmo.setTintColor(0.0, 0, 1.0);

        // 将圆旋转之后平移
        var translate: engine.Vector3 =  Vector3.createFromNumber(1, 0, 0);
        var rotate: engine.Matrix4 = engine.Matrix4.xRotate(Math.PI * 0.5);
        var tempWorldMatrix = Matrix4.composeTRS(translate, rotate, scale);
        this.meshGizmo.WorldMatrix = tempWorldMatrix;
    }

    public onDisable(){
        engine.Gizmos.removeGizmo(this.meshGizmo);
    }

}
点击咨询小助手