!264 顶线支持其他视图

Merge pull request !264 from ZoeLeeFZ/optTopline
pull/264/MERGE
ZoeLeeFZ 6 years ago committed by ChenX
parent bac64f2d1c
commit 0ea665f8c6

@ -1,5 +1,5 @@
import * as THREE from 'three';
import { Matrix4, Mesh, MeshNormalMaterial, Object3D, Vector3 } from "three";
import { Matrix4, Mesh, MeshNormalMaterial, Object3D, Vector3, LineSegments } from "three";
import { equalv3, isParallelTo, MoveMatrix } from '../../Geometry/GeUtils';
import { SweepGeometry } from '../../Geometry/SweepGeometry';
import { RenderType } from "../../GraphicsSystem/RenderType";
@ -10,6 +10,9 @@ import { PhysicalMaterialRecord } from '../PhysicalMaterialRecord';
import { IsPointInPolyLine } from '../PointInPolyline';
import { Polyline } from '../Polyline';
import { Solid3D } from "./Solid3D";
import { EdgesGeometry2 } from '../../Geometry/EdgeGeometry';
import { ColorMaterial } from '../../Common/ColorPalette';
import { DisposeThreeObj } from '../../Common/Dispose';
@Factory
export class SweepSolid extends Solid3D
@ -104,21 +107,31 @@ export class SweepSolid extends Solid3D
swpGeo.applyMatrix(this.m_Contour.OCS);
return new SweepGeometry(this.m_Contour, this.m_PathCurve);
}
InitDrawObject(renderType: RenderType): Object3D
private GetObject3DByRenderType(renderType: RenderType)
{
if (this.materialId && this.materialId.Object)
if (renderType === RenderType.Wireframe)
{
let material = this.materialId.Object as PhysicalMaterialRecord;
return new Mesh(this.CreateGeomtry(), material.Material);
let geo = new EdgesGeometry2(this.CreateGeomtry(), 2);
return new LineSegments(geo, ColorMaterial.GetLineMaterial(this.ColorIndex));
}
else return new THREE.Mesh(this.CreateGeomtry(), new MeshNormalMaterial());
else
{
if (this.materialId && this.materialId.Object)
{
let material = this.materialId.Object as PhysicalMaterialRecord;
return new Mesh(this.CreateGeomtry(), material.Material);
}
else return new THREE.Mesh(this.CreateGeomtry(), new MeshNormalMaterial());
}
}
InitDrawObject(renderType: RenderType): Object3D
{
return new Object3D().add(this.GetObject3DByRenderType(renderType));
}
UpdateDrawObject(type: RenderType, en: Object3D)
{
let obj = en as THREE.Mesh;
obj.geometry.dispose();
obj.geometry = this.CreateGeomtry();
DisposeThreeObj(en);
en.add(this.GetObject3DByRenderType(type));
}
/**

@ -1,5 +1,4 @@
import { Vector3 } from "three";
import { FixIndex } from "../../Common/Utils";
import { ConverBoardTypeToSpaceType } from "../../DatabaseServices/Board";
import { Curve } from "../../DatabaseServices/Curve";
import { Polyline } from "../../DatabaseServices/Polyline";
@ -7,6 +6,7 @@ import { Region } from "../../DatabaseServices/Region";
import { BoolOpeartionType } from "../../GraphicsSystem/BoolOperateUtils";
import { equaln, MoveMatrix } from "../GeUtils";
import { ISpaceParse } from "./ISpaceParse";
import { app } from "../../ApplicationServices/Application";
/**
*
@ -17,7 +17,12 @@ export class SurroundOutlineParse extends ISpaceParse
async Parse()
{
let pls: Polyline[] = [];
//俯视图的最高位置
let height = 0;
//右视图最左
let maxX = 0;
let ucsNormal = new Vector3().setFromMatrixColumn(app.m_Editor.UCSMatrix, 2);
for (let [type, brs] of this.m_BoardMap)
{
let splitType = ConverBoardTypeToSpaceType(type);
@ -25,14 +30,34 @@ export class SurroundOutlineParse extends ISpaceParse
for (let b of bs)
{
let max = b.max;
if (max.z > height)
height = max.z;
pls.push(new Polyline().Create2Pt(b.min.clone().setZ(0), max.clone().setZ(0)));
let min = b.min;
if (equaln(Math.abs(ucsNormal.z), 1))
{
if (max.z > height)
height = max.z;
}
else if (equaln(ucsNormal.x, 1))
{
if (max.x > maxX)
maxX = max.x;
}
max.applyMatrix4(app.m_Editor.UCSMatrixInv);
min.applyMatrix4(app.m_Editor.UCSMatrixInv);
let pl = new Polyline().Create2Pt(min.setZ(0), max.setZ(0));
pl.ApplyMatrix(app.m_Editor.UCSMatrix);
pls.push(pl);
}
}
//轮廓曲线移动到空间最高处
pls.forEach(pl => pl.ApplyMatrix(MoveMatrix(new Vector3(0, 0, height))));
if (equaln(Math.abs(ucsNormal.z), 1))
{
//轮廓曲线移动到空间最高处
pls.forEach(pl => pl.ApplyMatrix(MoveMatrix(new Vector3(0, 0, height))));
}
else if (equaln(ucsNormal.x, 1))
{
//轮廓曲线移动到最右
pls.forEach(pl => pl.ApplyMatrix(MoveMatrix(new Vector3(maxX))));
}
this.GetOutline(pls);
}
private GetOutline(cus: Curve[])

Loading…
Cancel
Save