完成下列功能:
1.板件显示 2.板件选中状态 3.标注显示 4.相机控制.
This commit is contained in:
49
src/DrawDimension.ts
Normal file
49
src/DrawDimension.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { Box3, Vector3, Matrix4, Mesh } from "three";
|
||||
import { Dimension, GetBoxArr } from ".";
|
||||
|
||||
|
||||
/**
|
||||
* 绘制标注实体
|
||||
*
|
||||
* @export
|
||||
* @param {Box3} box
|
||||
* @returns 标注实体列表
|
||||
*/
|
||||
export function DrawDimension(brList: Mesh[]): Dimension[]
|
||||
{
|
||||
let box = GetBoxArr(brList);
|
||||
let size = box.getSize(new Vector3());
|
||||
|
||||
let mat4 = new Matrix4();
|
||||
mat4.makeBasis(
|
||||
new Vector3(-1, 0, 0),
|
||||
new Vector3(0, -1, 0),
|
||||
new Vector3(0, 0, 1)
|
||||
)
|
||||
mat4.setPosition(box.min.clone().add(new Vector3(size.x, -30)));
|
||||
|
||||
let textHeight = 45;
|
||||
let dimx = new Dimension(size.x, textHeight, true);
|
||||
dimx.applyMatrix(mat4);
|
||||
|
||||
let dimz = new Dimension(size.z, textHeight);
|
||||
mat4.makeBasis(
|
||||
new Vector3(0, 0, -1),
|
||||
new Vector3(1, 0, 0),
|
||||
new Vector3(0, -1, 0)
|
||||
)
|
||||
mat4.setPosition(box.max.clone().add(new Vector3(30, -size.y)));
|
||||
dimz.applyMatrix(mat4);
|
||||
|
||||
let dimy = new Dimension(size.y, textHeight, true, true);
|
||||
mat4.makeBasis(
|
||||
new Vector3(0, 1, 0),
|
||||
new Vector3(-1, 0, 0),
|
||||
new Vector3(0, 0, 1)
|
||||
)
|
||||
mat4.setPosition(box.max.clone().add(new Vector3(30, -size.y)));
|
||||
dimy.applyMatrix(mat4);
|
||||
|
||||
|
||||
return [dimx, dimy, dimz];
|
||||
}
|
Reference in New Issue
Block a user