# CubeGizmo
使用CubeGizmo,我们可以在游戏场景中绘制一个有基础光照的立方体
# 方法
函数 | 功能 |
---|---|
center | 立方体的初始坐标 |
size | 立方体的缩放尺度 |
WorldMatrix | 线段世界矩阵的访问器 |
setTintColor | 设定立方体的颜色 |
resetGizmo | 重置立方体的属性 |
addRenderCamera | 明确指定某个相机需要绘制该Gizmo |
deleRenderCamera | 明确某个相机不需要绘制该Gizmo |
clearRenderCameraSet | 标记所有相机均不绘制该Gizmo |
# 示例
import engine from "engine";
export default class ExampleClass extends engine.Script{
public cubeGizmo;
public onAwake(){
var center = engine.Vector3.ZERO;
var size = engine.Vector3.createFromNumber(2, 2, 2);
this.cubeGizmo = engine.Gizmos.createCubeGizmo(center, size);
// 基础色调整为蓝色
this.cubeGizmo.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.cubeGizmo.WorldMatrix = tempWorldMatrix;
}
public onDisable(){
engine.Gizmos.removeGizmo(this.cubeGizmo);
}
}