# LineGizmo
使用LineGizmo,在游戏场景中绘制一条条纯色的线段,我们可以拼接出想要的立方体线框
# 方法
函数 | 功能 |
---|---|
start | 线段起始点的访问器 |
end | 线段终点的访问器 |
WorldMatrix | 线段世界矩阵的访问器 |
setTintColor | 设定线段的颜色 |
resetGizmo | 重置线段的属性 |
addRenderCamera | 明确指定某个相机需要绘制该Gizmo |
deleRenderCamera | 明确某个相机不需要绘制该Gizmo |
clearRenderCameraSet | 标记所有相机均不绘制该Gizmo |
# 示例
import engine from "engine";
export default class ExampleClass extends engine.Script{
public lineGizmo;
public onAwake(){
var start = engine.Vector3.ZERO;
var end = engine.Vector3.createFromNumber(1, 1, 1);
// 创建一个起点为(0, 0, 0),终点为(1, 1, 1)的线段Gizmo
this.lineGizmo = engine.Gizmos.createLineGizmo(start, end);
// 调整为红色
this.lineGizmo.setTintColor(1.0, 0, 0);
// 将线段缩放之后平移
var translate: Vector3 = Vector3.createFromNumber(1, 0, 0);
var scale: Vector3 = Vector3.createFromNumber(2, 2, 2);
var tempWorldMatrix = Matrix4.composeTRS(translate, Matrix4.IDENTITY, scale);
this.lineGizmo.WorldMatrix = tempWorldMatrix;
}
public onDisable(){
engine.Gizmos.removeGizmo(this.lineGizmo);
}
}