CADViewComponent/src/Dimension.ts
ChenX ba3e5cabfd 完成下列功能:
1.板件显示
2.板件选中状态
3.标注显示
4.相机控制.
2018-05-24 17:13:23 +08:00

59 lines
1.6 KiB
TypeScript

import { Group, Geometry, Vector3, Line, Matrix4 } from "three";
import { ColorMaterial } from "./ColorPalette";
import { DbText } from "./Text";
import { MoveMatrix } from "./GeUtils";
/**
* 标注实体
*
* @export
* @class Dimension
* @extends {Group}
*/
export class Dimension extends Group
{
constructor(length: number, textHeight: number = 25, mirror: boolean = false, mirrorFoot: boolean = false)
{
super();
let footLength = 60;
if (mirrorFoot)
{
footLength = -footLength;
}
//针脚几何体
let lineGeo = new Geometry();
lineGeo.vertices.push(new Vector3(), new Vector3(0, footLength, 0));
//托盘几何体
let lineGeo2 = new Geometry();
lineGeo2.vertices.push(new Vector3(0, footLength), new Vector3(length, footLength, 0));
let material = ColorMaterial.GetLineMaterial(5)
let line1 = new Line(lineGeo, material);
let line2 = new Line(lineGeo, material);
line2.position.x = length;
let line3 = new Line(lineGeo2, material);
let text = new DbText(parseFloat(length.toFixed(2)).toString(), textHeight);
if (mirror)
{
let roMat = new Matrix4().makeRotationZ(Math.PI);
text.applyMatrix(roMat);
text.applyMatrix(MoveMatrix(new Vector3(length * 0.5, footLength - textHeight * 0.1)));
}
else
{
text.applyMatrix(MoveMatrix(new Vector3(length * 0.5, footLength * 1.1)));
}
this.add(text);
this.add(line1, line2, line3);
}
}