|
|
@ -1,5 +1,5 @@
|
|
|
|
import { Object3D, ShapeGeometry, Vector2, Vector3 } from 'three';
|
|
|
|
|
|
|
|
import * as THREE from 'three';
|
|
|
|
import * as THREE from 'three';
|
|
|
|
|
|
|
|
import { Object3D, Shape, ShapeGeometry, Vector2, Vector3 } from 'three';
|
|
|
|
import { begin } from 'xaop';
|
|
|
|
import { begin } from 'xaop';
|
|
|
|
|
|
|
|
|
|
|
|
import { CreateBoardUtil } from '../ApplicationServices/mesh/createBoard';
|
|
|
|
import { CreateBoardUtil } from '../ApplicationServices/mesh/createBoard';
|
|
|
@ -21,7 +21,7 @@ const fuzz = 1e-8;
|
|
|
|
export class Region extends Entity
|
|
|
|
export class Region extends Entity
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private m_CuList: Array<Curve> = [];
|
|
|
|
private m_CuList: Array<Curve> = [];
|
|
|
|
private m_Shape: THREE.Shape;
|
|
|
|
private m_Shape: Shape;
|
|
|
|
constructor(curveList?: Array<Curve>)
|
|
|
|
constructor(curveList?: Array<Curve>)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
super();
|
|
|
@ -29,23 +29,37 @@ export class Region extends Entity
|
|
|
|
if (curveList)
|
|
|
|
if (curveList)
|
|
|
|
this.m_CuList.push(...curveList);
|
|
|
|
this.m_CuList.push(...curveList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get Shape(): Shape
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!this.m_Shape) this.GeneralShape();
|
|
|
|
|
|
|
|
return this.m_Shape;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Draw(renderType: RenderType): Object3D
|
|
|
|
Draw(renderType: RenderType): Object3D
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let obj = super.Draw(renderType);
|
|
|
|
let obj = super.Draw(renderType);
|
|
|
|
if (obj) return obj;
|
|
|
|
if (obj) return obj;
|
|
|
|
|
|
|
|
|
|
|
|
this.m_Shape = new THREE.Shape();
|
|
|
|
this.GeneralShape();
|
|
|
|
|
|
|
|
|
|
|
|
let begin: Vector3;
|
|
|
|
let geometry = new ShapeGeometry(this.m_Shape, 60);
|
|
|
|
|
|
|
|
let mesh = new THREE.Mesh(geometry, ColorMaterial.GetLineMaterial(this.ColorIndex));
|
|
|
|
|
|
|
|
this.m_DrawEntity.set(renderType, mesh);
|
|
|
|
|
|
|
|
mesh.userData = this;
|
|
|
|
|
|
|
|
return mesh;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private GeneralShape()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.m_Shape = new THREE.Shape();
|
|
|
|
|
|
|
|
let begin: Vector3;
|
|
|
|
if (this.m_CuList.length > 1)
|
|
|
|
if (this.m_CuList.length > 1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let firstL = this.m_CuList[0];
|
|
|
|
let firstL = this.m_CuList[0];
|
|
|
|
let seconL = this.m_CuList[1];
|
|
|
|
let seconL = this.m_CuList[1];
|
|
|
|
|
|
|
|
|
|
|
|
if (firstL.StartPoint.distanceTo(seconL.StartPoint) < fuzz
|
|
|
|
if (firstL.StartPoint.distanceTo(seconL.StartPoint) < fuzz
|
|
|
|
|| firstL.StartPoint.distanceTo(seconL.EndPoint) < fuzz
|
|
|
|
|| firstL.StartPoint.distanceTo(seconL.EndPoint) < fuzz)
|
|
|
|
)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
begin = firstL.EndPoint;
|
|
|
|
begin = firstL.EndPoint;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -55,15 +69,12 @@ export class Region extends Entity
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.m_Shape.moveTo(begin.x, begin.y);
|
|
|
|
this.m_Shape.moveTo(begin.x, begin.y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (let cu of this.m_CuList)
|
|
|
|
for (let cu of this.m_CuList)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (cu.EndPoint.distanceTo(begin) < fuzz)
|
|
|
|
if (cu.EndPoint.distanceTo(begin) < fuzz)
|
|
|
|
cu.Reverse();
|
|
|
|
cu.Reverse();
|
|
|
|
|
|
|
|
|
|
|
|
//设置起点
|
|
|
|
//设置起点
|
|
|
|
begin.copy(cu.EndPoint);
|
|
|
|
begin.copy(cu.EndPoint);
|
|
|
|
|
|
|
|
|
|
|
|
if (cu instanceof Line)
|
|
|
|
if (cu instanceof Line)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.m_Shape.lineTo(begin.x, begin.y);
|
|
|
|
this.m_Shape.lineTo(begin.x, begin.y);
|
|
|
@ -93,12 +104,6 @@ export class Region extends Entity
|
|
|
|
this.m_Shape.absarc(cu.Center.x, cu.Center.y, cu.Radius, cu.StartAngle, cu.EndAngle, cu.IsClockWise);
|
|
|
|
this.m_Shape.absarc(cu.Center.x, cu.Center.y, cu.Radius, cu.StartAngle, cu.EndAngle, cu.IsClockWise);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let geometry = new ShapeGeometry(this.m_Shape, 60);
|
|
|
|
|
|
|
|
let mesh = new THREE.Mesh(geometry, ColorMaterial.GetLineMaterial(this.ColorIndex));
|
|
|
|
|
|
|
|
this.m_DrawEntity.set(renderType, mesh);
|
|
|
|
|
|
|
|
mesh.userData = this;
|
|
|
|
|
|
|
|
return mesh;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//在移动时应用矩阵变换
|
|
|
|
//在移动时应用矩阵变换
|
|
|
|