完成下列功能:
1.板件显示 2.板件选中状态 3.标注显示 4.相机控制.
This commit is contained in:
58
src/Dimension.ts
Normal file
58
src/Dimension.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user