合并板件实现分支

pull/653835/MERGE
ChenX 7 years ago
commit f936c0c5df

@ -4,6 +4,7 @@ import { Curve } from '../DatabaseServices/Curve';
import { Ellipse } from '../DatabaseServices/Ellipse'; import { Ellipse } from '../DatabaseServices/Ellipse';
import { Region } from '../DatabaseServices/Region'; import { Region } from '../DatabaseServices/Region';
import { Command } from '../Editor/CommandMachine'; import { Command } from '../Editor/CommandMachine';
import { PromptStatus } from '../Editor/PromptResult';
import { SelectSet } from '../Editor/SelectSet'; import { SelectSet } from '../Editor/SelectSet';
import { RegionParse, Route } from '../Geometry/RegionParse'; import { RegionParse, Route } from '../Geometry/RegionParse';
@ -11,6 +12,15 @@ export class DrawRegion implements Command
{ {
async exec(ss: SelectSet) async exec(ss: SelectSet)
{ {
if (ss.SelectEntityList.length === 0)
{
let ssRes = await app.m_Editor.GetSelection();
if (ssRes.Status !== PromptStatus.OK)
return;
ss = ssRes.SelectSet;
}
let lines: Curve[] = []; let lines: Curve[] = [];
for (let en of ss.SelectEntityList) for (let en of ss.SelectEntityList)

@ -0,0 +1,14 @@
import { Command } from "../Editor/CommandMachine";
import { Board } from "../DatabaseServices/Board";
import { app } from "../ApplicationServices/Application";
export class Command_DrawBoard2 implements Command
{
async exec()
{
let br = new Board();
br.InitBoard(1.200, 0.600, 0.018);
app.m_Database.ModelSpace.Append(br);
}
}

@ -29,6 +29,7 @@ export class Arc extends Curve
private m_StartAngle: number; private m_StartAngle: number;
private m_EndAngle: number; private m_EndAngle: number;
private m_Normal = new Vector3(0, 0, 1); private m_Normal = new Vector3(0, 0, 1);
private m_Clockwise = true;//顺时针
get Center() get Center()
{ {
@ -82,6 +83,11 @@ export class Arc extends Curve
this.Update(); this.Update();
} }
get IsClockWise()
{
return this.m_Clockwise;
}
get StartAngle() get StartAngle()
{ {
return this.m_StartAngle; return this.m_StartAngle;
@ -283,8 +289,15 @@ export class Arc extends Curve
this.SetExtendPointAngle(newParam, allAngle); this.SetExtendPointAngle(newParam, allAngle);
} }
} }
}
Reverse()
{
this.WriteAllObjectRecord();
this.m_Clockwise = !this.m_Clockwise;
[this.m_StartAngle, this.m_EndAngle] = [this.m_EndAngle, this.m_StartAngle];
} }
IntersectWith(curve: Curve, intType: Intersect): Vector3[] IntersectWith(curve: Curve, intType: Intersect): Vector3[]
{ {
if (curve instanceof Arc) if (curve instanceof Arc)
@ -407,8 +420,9 @@ export class Arc extends Curve
if (obj) return obj; if (obj) return obj;
let shape = new THREE.Shape(); let shape = new THREE.Shape();
shape.absarc(this.m_Center.x, this.m_Center.y, this.m_Radius, this.m_StartAngle, this.m_EndAngle, true); shape.absarc(this.m_Center.x, this.m_Center.y, this.m_Radius, this.m_StartAngle, this.m_EndAngle, this.m_Clockwise);
let geo = new THREE.Geometry().setFromPoints(shape.getPoints(60)); let geo = new THREE.Geometry().setFromPoints(shape.getPoints(60));
geo.computeBoundingSphere();
let arc = new THREE.Line(geo, ColorMaterial.GetLineMaterial(this.m_Color)); let arc = new THREE.Line(geo, ColorMaterial.GetLineMaterial(this.m_Color));
this.m_DrawEntity.set(renderType, arc); this.m_DrawEntity.set(renderType, arc);
arc.userData = this; arc.userData = this;
@ -425,6 +439,7 @@ export class Arc extends Curve
//圆心x,圆心y,半径,起点角度,端点角度,时针方向 //圆心x,圆心y,半径,起点角度,端点角度,时针方向
shape.absarc(this.m_Center.x, this.m_Center.y, this.m_Radius, this.m_StartAngle, this.m_EndAngle, true); shape.absarc(this.m_Center.x, this.m_Center.y, this.m_Radius, this.m_StartAngle, this.m_EndAngle, true);
geo.setFromPoints(shape.getPoints(60)); geo.setFromPoints(shape.getPoints(60));
geo.computeBoundingSphere();
geo.verticesNeedUpdate = true; geo.verticesNeedUpdate = true;
} }
@ -494,7 +509,7 @@ export class Arc extends Curve
this.m_Radius = file.Read(); this.m_Radius = file.Read();
this.m_StartAngle = file.Read(); this.m_StartAngle = file.Read();
this.m_EndAngle = file.Read(); this.m_EndAngle = file.Read();
this.m_Clockwise = file.Read();
} }
//对象将自身数据写入到文件. //对象将自身数据写入到文件.
WriteFile(file: CADFile) WriteFile(file: CADFile)
@ -506,6 +521,7 @@ export class Arc extends Curve
file.Write(this.m_Radius); file.Write(this.m_Radius);
file.Write(this.m_StartAngle); file.Write(this.m_StartAngle);
file.Write(this.m_EndAngle); file.Write(this.m_EndAngle);
file.Write(this.m_Clockwise);
} }
//#endregion //#endregion
} }

@ -0,0 +1,174 @@
import { ExtrudeGeometry, Matrix4, Mesh, Object3D, Vector3 } from 'three';
import { CoordinateSystem } from '../Geometry/CoordinateSystem';
import { RenderType } from '../GraphicsSystem/Enum';
import { Factory } from './CADFactory';
import { CADFile } from './CADFile';
import { CADObject } from './CADObject';
import { Entity } from './Entity';
import { Line } from './Line';
import { DbPhysicalMaterial } from './PhysicalMaterial';
import { Region } from './Region';
/**
*
*
* @class Board
* @extends {Entity}
*/
@Factory
export class Board extends Entity
{
//板件厚度
private m_Height: number = 18;
private m_Region: Region;
//自身坐标系
private m_Matrix: Matrix4 = new Matrix4();//标准的世界坐标系
constructor(reg?: Region, height?: number)
{
super();
this.m_Region = reg;
this.m_Height = height || this.m_Height;
}
//初始化板件 来自长宽高
InitBoard(length: number, width: number, height: number)
{
this.m_Height = height;
let px1 = new Vector3(0, 0, 0);
let px3 = new Vector3(length, width, 0);
let px2 = new Vector3(px3.x, px1.y);
let px4 = new Vector3(px1.x, px3.y);
let l1 = new Line();
let l2 = new Line();
let l3 = new Line();
let l4 = new Line();
l1.StartPoint = px1;
l1.EndPoint = px2;
l2.StartPoint = px2;
l2.EndPoint = px3;
l3.StartPoint = px3;
l3.EndPoint = px4;
l4.StartPoint = px1;
l4.EndPoint = px4;
this.m_Region = new Region([l1, l2, l3, l4]);
this.Update();
}
ApplyMatrix(m: Matrix4)
{
this.WriteAllObjectRecord();
let coor = new CoordinateSystem();
coor.copyForm(this.m_Matrix);
coor.applyMatrix4(m);
this.m_Matrix.copy(coor.getMatrix4());
this.Update();
}
Draw(renderType: RenderType): Object3D
{
let obj = super.Draw(renderType);
if (obj) return obj;
if (!this.m_Region)
{
//避免空的板件生成
this.InitBoard(1e-5, 1e-5, 1e-5);
}
let extrudeSettings = {
steps: 1,
bevelEnabled: false,
amount: this.m_Height
};
let extGeo = new ExtrudeGeometry(this.m_Region.Shape, extrudeSettings);
let mesh = new Mesh(extGeo);
mesh.userData = this;
if (this.m_MaterialId && this.m_MaterialId.Object)
{
let material = this.m_MaterialId.Object as DbPhysicalMaterial;
mesh.material = material.Material;
}
this.m_DrawEntity.set(renderType, mesh);
this.Update();
return mesh;
}
Update()
{
super.Update();
for (let [, obj] of this.m_DrawEntity)
{
let mesh = obj as Mesh;
mesh.geometry.dispose();
let extrudeSettings = {
steps: 1,
bevelEnabled: false,
amount: this.m_Height
};
mesh.geometry = new ExtrudeGeometry(this.m_Region.Shape, extrudeSettings);
mesh.geometry.computeBoundingSphere();
if (this.m_MaterialId)
{
let material = this.m_MaterialId.Object as DbPhysicalMaterial;
mesh.material = material.Material;
}
for (let [, obj] of this.m_DrawEntity)
{
let mesh = obj as Mesh;
let p = new Vector3().setFromMatrixColumn(this.m_Matrix, 3);
obj.position.copy(p);
obj.quaternion.setFromRotationMatrix(this.m_Matrix);
}
}
}
//#region -------------------------File-------------------------
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
//对象从文件中读取数据,初始化自身
ReadFile(file: CADFile)
{
super.ReadFile(file);
let ver = file.Read();
this.m_Region = file.ReadObject(this._db) as Region;
this.m_Height = file.Read();
this.m_Matrix.fromArray(file.Read())
this.Update();
}
//对象将自身数据写入到文件.
WriteFile(file: CADFile)
{
super.WriteFile(file);
file.Write(1);
file.WriteObject(this.m_Region);
file.Write(this.m_Height);
file.Write(this.m_Matrix.toArray())
}
//局部撤销
ApplyPartialUndo(undoData: CADObject)
{
super.ApplyPartialUndo(undoData);
}
//#endregion
}

@ -62,6 +62,9 @@ export abstract class Curve extends Entity
GetSplitCurves(param: number[] | number): Array<Curve> { return; } GetSplitCurves(param: number[] | number): Array<Curve> { return; }
Extend(newParam: number) { } Extend(newParam: number) { }
//翻转曲线.首尾调换.
Reverse() { };
PtOnCurve(pt: Vector3): boolean { return; } PtOnCurve(pt: Vector3): boolean { return; }
GetOffsetCurves(offsetDist: number): Array<Curve> { return; } GetOffsetCurves(offsetDist: number): Array<Curve> { return; }

@ -63,11 +63,10 @@ export class Database
file.ReadObject(this, this.MaterialDict); file.ReadObject(this, this.MaterialDict);
file.ReadObject(this, this.TextureTableCol); file.ReadObject(this, this.TextureTableCol);
//TODO: 在对象关联情况下.更新可能出现 引用的问题. for (let mat of this.MaterialDict.objectCol)
this.MaterialDict.objectCol.forEach(m =>
{ {
m.Update(); mat.Update();
}) }
this.hm.ReadFile(file); this.hm.ReadFile(file);
} }

@ -1,4 +1,3 @@
//所有图元的基类
import * as THREE from 'three'; import * as THREE from 'three';
import { Matrix4, Vector3, Mesh, Box3 } from 'three'; import { Matrix4, Vector3, Mesh, Box3 } from 'three';
@ -9,6 +8,14 @@ import { CADFile } from './CADFile';
import { CADObject } from './CADObject'; import { CADObject } from './CADObject';
import { ObjectId } from './ObjectId'; import { ObjectId } from './ObjectId';
/**
* Entity ,.
*
* @export
* @class Entity
* @extends {CADObject}
*/
@Factory @Factory
export class Entity extends CADObject export class Entity extends CADObject
{ {
@ -17,6 +24,12 @@ export class Entity extends CADObject
protected m_MaterialId: ObjectId; protected m_MaterialId: ObjectId;
protected m_Color: number = 7; protected m_Color: number = 7;
set Material(material: ObjectId)
{
this.m_MaterialId = material;
this.Update();
}
set ColorIndex(v: number) set ColorIndex(v: number)
{ {
this.m_Color = v; this.m_Color = v;
@ -39,8 +52,15 @@ export class Entity extends CADObject
return new Box3(); return new Box3();
} }
/**
//绘制一个threeJs对象. * ,,.
*
* `computeBoundingSphere` ,.
*
* @param {RenderType} [renderType=RenderType.Wireframe]
* @returns {THREE.Object3D}
* @memberof Entity
*/
Draw(renderType: RenderType = RenderType.Wireframe): THREE.Object3D Draw(renderType: RenderType = RenderType.Wireframe): THREE.Object3D
{ {
if (this.m_DrawEntity && this.m_DrawEntity.has(renderType)) if (this.m_DrawEntity && this.m_DrawEntity.has(renderType))
@ -49,7 +69,13 @@ export class Entity extends CADObject
} }
} }
//你必须重载该方法来更新绘制,在撤销重做时会自动调用该方法. /**
* ,,,.
*
* `computeBoundingSphere` ,.
*
* @memberof Entity
*/
Update() Update()
{ {
this.UpdateVisible(); this.UpdateVisible();
@ -114,6 +140,7 @@ export class Entity extends CADObject
let ver = file.Read(); let ver = file.Read();
super.ReadFile(file); super.ReadFile(file);
this.m_Color = file.Read(); this.m_Color = file.Read();
this.m_MaterialId = this.ReadObjectId(file);
this.Update(); this.Update();
} }
//对象将自身数据写入到文件. //对象将自身数据写入到文件.
@ -122,6 +149,7 @@ export class Entity extends CADObject
file.Write(1); file.Write(1);
super.WriteFile(file); super.WriteFile(file);
file.Write(this.m_Color); file.Write(this.m_Color);
this.WriteObjectId(file, this.m_MaterialId);
} }
//局部撤销 //局部撤销
ApplyPartialUndo(undoData: CADObject) ApplyPartialUndo(undoData: CADObject)

@ -14,13 +14,13 @@ import { Curve } from './Curve';
@Factory @Factory
export class Line extends Curve export class Line extends Curve
{ {
private startPoint: Vector3; private m_StartPoint: Vector3;
private endPoint: Vector3; private m_EndPoint: Vector3;
constructor(sp?: Vector3, ep?: Vector3) constructor(sp?: Vector3, ep?: Vector3)
{ {
super(); super();
this.startPoint = sp || new Vector3(0, 0, 0); this.m_StartPoint = sp || new Vector3(0, 0, 0);
this.endPoint = ep || new Vector3(0, 0, 0); this.m_EndPoint = ep || new Vector3(0, 0, 0);
} }
Draw(renderType: RenderType): Object3D Draw(renderType: RenderType): Object3D
@ -47,8 +47,8 @@ export class Line extends Curve
let geo = lineObj.geometry as THREE.Geometry; let geo = lineObj.geometry as THREE.Geometry;
geo.vertices[0].copy(this.startPoint); geo.vertices[0].copy(this.m_StartPoint);
geo.vertices[1].copy(this.endPoint); geo.vertices[1].copy(this.m_EndPoint);
geo.computeBoundingSphere();//必须调用该函数,使得实体可以被选中. geo.computeBoundingSphere();//必须调用该函数,使得实体可以被选中.
@ -83,8 +83,8 @@ export class Line extends Curve
ApplyMatrix(m: Matrix4) ApplyMatrix(m: Matrix4)
{ {
this.startPoint.applyMatrix4(m); this.m_StartPoint.applyMatrix4(m);
this.endPoint.applyMatrix4(m); this.m_EndPoint.applyMatrix4(m);
this.Update(); this.Update();
} }
@ -112,7 +112,7 @@ export class Line extends Curve
let len = this.Length; let len = this.Length;
if (len == 0) if (len == 0)
{ {
if (equal(this.startPoint, pt)) if (equal(this.m_StartPoint, pt))
return 0; return 0;
else else
return NaN; return NaN;
@ -218,6 +218,12 @@ export class Line extends Curve
} }
} }
Reverse()
{
this.WriteAllObjectRecord();
[this.m_StartPoint, this.m_EndPoint] = [this.m_EndPoint, this.m_StartPoint];
}
GetOffsetCurves(offsetDist: number): Array<Curve> GetOffsetCurves(offsetDist: number): Array<Curve>
{ {
let an = this.GetFistDerivAngle(0) - Math.PI * 0.5; let an = this.GetFistDerivAngle(0) - Math.PI * 0.5;
@ -236,7 +242,7 @@ export class Line extends Curve
return 1; return 1;
} }
//属性 //属性
get Length(): number { return this.startPoint.distanceTo(this.endPoint); } get Length(): number { return this.m_StartPoint.distanceTo(this.m_EndPoint); }
//#region -----------------------------File----------------------------- //#region -----------------------------File-----------------------------
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化 //对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
@ -246,16 +252,16 @@ export class Line extends Curve
{ {
super.ReadFile(file); super.ReadFile(file);
let ver = file.Read();//1 let ver = file.Read();//1
this.startPoint.fromArray(file.Read()); this.m_StartPoint.fromArray(file.Read());
this.endPoint.fromArray(file.Read()); this.m_EndPoint.fromArray(file.Read());
} }
//对象将自身数据写入到文件. //对象将自身数据写入到文件.
WriteFile(file: CADFile) WriteFile(file: CADFile)
{ {
super.WriteFile(file); super.WriteFile(file);
file.Write(1);//ver file.Write(1);//ver
file.Write(this.startPoint.toArray()); file.Write(this.m_StartPoint.toArray());
file.Write(this.endPoint.toArray()); file.Write(this.m_EndPoint.toArray());
} }
//#endregion-----------------------------File End----------------------------- //#endregion-----------------------------File End-----------------------------
@ -263,23 +269,23 @@ export class Line extends Curve
set StartPoint(v: Vector3) set StartPoint(v: Vector3)
{ {
this.WriteAllObjectRecord(); this.WriteAllObjectRecord();
this.startPoint.copy(v); this.m_StartPoint.copy(v);
this.Update(); this.Update();
} }
get StartPoint(): Vector3 get StartPoint(): Vector3
{ {
return this.startPoint.clone(); return this.m_StartPoint.clone();
} }
get EndPoint(): Vector3 get EndPoint(): Vector3
{ {
return this.endPoint.clone(); return this.m_EndPoint.clone();
} }
set EndPoint(v: Vector3) set EndPoint(v: Vector3)
{ {
this.WriteAllObjectRecord(); this.WriteAllObjectRecord();
this.endPoint.copy(v); this.m_EndPoint.copy(v);
this.Update(); this.Update();
} }

@ -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,17 +69,14 @@ 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)
cu.Reverse();
//设置起点
begin.copy(cu.EndPoint);
if (cu instanceof Line) if (cu instanceof Line)
{ {
if (cu.StartPoint.distanceTo(begin) < fuzz)
begin = cu.EndPoint;
else
begin = cu.StartPoint;
this.m_Shape.lineTo(begin.x, begin.y); this.m_Shape.lineTo(begin.x, begin.y);
} }
else if (cu instanceof Circle) else if (cu instanceof Circle)
@ -78,9 +89,6 @@ export class Region extends Entity
} }
else if (cu instanceof Polyline) else if (cu instanceof Polyline)
{ {
if (cu.EndPoint.distanceTo(begin) < fuzz)
cu.Reverse();
let plData = cu.LineData; let plData = cu.LineData;
let pts: Vector2[] = []; let pts: Vector2[] = [];
let bul: number[] = []; let bul: number[] = [];
@ -90,24 +98,12 @@ export class Region extends Entity
bul.push(d.bul); bul.push(d.bul);
} }
CreateBoardUtil.createPath(pts, bul, this.m_Shape); CreateBoardUtil.createPath(pts, bul, this.m_Shape);
begin = cu.EndPoint;
} }
else if (cu instanceof Arc) else if (cu instanceof Arc)
{ {
//起点和终点影响开始角度,结束角度和法向量 this.m_Shape.absarc(cu.Center.x, cu.Center.y, cu.Radius, cu.StartAngle, cu.EndAngle, cu.IsClockWise);
if (begin.distanceTo(cu.StartPoint) < 0.1)
this.m_Shape.absarc(cu.Center.x, cu.Center.y, cu.Radius, cu.StartAngle, cu.EndAngle, cu.Normal.z < 0);
else
this.m_Shape.absarc(cu.Center.x, cu.Center.y, cu.Radius, cu.EndAngle, cu.StartAngle, cu.Normal.z > 0);
} }
} }
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;
} }
//在移动时应用矩阵变换 //在移动时应用矩阵变换

@ -44,6 +44,7 @@ export class CommandMachine
{ {
this.m_CommandIng = false; this.m_CommandIng = false;
app.m_Editor.m_CommandStore.isCmdIng = false; app.m_Editor.m_CommandStore.isCmdIng = false;
app.m_Editor.ClearSnapEntity();
} }
get CommandNameList(): Set<string> get CommandNameList(): Set<string>

@ -1,10 +1,9 @@
import { Command_DrawBoard } from '../Add-on/DrawBoard';
// import { DrawFloor } from '../Add-on/DrawFloor';
import { DrawAxis } from '../Add-on/AddAxis'; import { DrawAxis } from '../Add-on/AddAxis';
import { Command_Copy } from '../Add-on/Copy'; import { Command_Copy } from '../Add-on/Copy';
import { CustomUcs } from '../Add-on/CostumUCS'; import { CustomUcs } from '../Add-on/CostumUCS';
import { Union } from '../Add-on/CSGUnion'; import { Union } from '../Add-on/CSGUnion';
import { DrawArc } from '../Add-on/DrawArc'; import { DrawArc } from '../Add-on/DrawArc';
import { Command_DrawBoard } from '../Add-on/DrawBoard';
import { DrawEllipse } from '../Add-on/DrawEllipse'; import { DrawEllipse } from '../Add-on/DrawEllipse';
import { DrawFloor } from '../Add-on/DrawFloor'; import { DrawFloor } from '../Add-on/DrawFloor';
import { DrawGripStretch } from '../Add-on/DrawGripStretch'; import { DrawGripStretch } from '../Add-on/DrawGripStretch';
@ -18,6 +17,7 @@ import { DrawCircle0 } from '../Add-on/DrawZeroCircle';
import { Entsel } from '../Add-on/Entsel'; import { Entsel } from '../Add-on/Entsel';
import { Command_Erase } from '../Add-on/Erase'; import { Command_Erase } from '../Add-on/Erase';
import { Command_Extend } from '../Add-on/Extends'; import { Command_Extend } from '../Add-on/Extends';
import { CommandFillet } from '../Add-on/Fillet';
import { Fbx } from '../Add-on/loadfbx'; import { Fbx } from '../Add-on/loadfbx';
import { LoadImg } from '../Add-on/LoadImg'; import { LoadImg } from '../Add-on/LoadImg';
import { Command_Move } from '../Add-on/Move'; import { Command_Move } from '../Add-on/Move';
@ -25,17 +25,18 @@ import { Open } from '../Add-on/Open';
import { Command_RevPl } from '../Add-on/RevPl'; import { Command_RevPl } from '../Add-on/RevPl';
import { Command_Rotate } from '../Add-on/Rotate'; import { Command_Rotate } from '../Add-on/Rotate';
import { Save } from '../Add-on/Save'; import { Save } from '../Add-on/Save';
import { Command_Ssget } from '../Add-on/ssget';
import { Stretch } from '../Add-on/Stretch'; import { Stretch } from '../Add-on/Stretch';
import { Command_SwitchCamera } from '../Add-on/SwitchCamera'; import { Command_SwitchCamera } from '../Add-on/SwitchCamera';
import { Command_SwitchPass } from '../Add-on/SwitchPass'; import { Command_SwitchPass } from '../Add-on/SwitchPass';
import { Test } from '../Add-on/test'; import { Test } from '../Add-on/test';
import { Command_DrawBoard2 } from '../Add-on/TestDrawBoard';
import { Command_Trim } from '../Add-on/Trim'; import { Command_Trim } from '../Add-on/Trim';
import { Redo, Undo } from '../Add-on/Undo'; import { Redo, Undo } from '../Add-on/Undo';
import { ViewToFront, ViewToTop } from '../Add-on/ViewChange'; import { ViewToFront, ViewToTop } from '../Add-on/ViewChange';
import { commandMachine } from './CommandMachine'; import { commandMachine } from './CommandMachine';
import { Command_Ssget } from '../Add-on/ssget';
import { CommandFillet } from '../Add-on/Fillet';
// import { DrawFloor } from '../Add-on/DrawFloor';
// import { RevTarget, SaveTarget } from '../Add-on/RenderTarget'; // import { RevTarget, SaveTarget } from '../Add-on/RenderTarget';
export function registerCommand() export function registerCommand()
{ {
@ -111,6 +112,9 @@ export function registerCommand()
commandMachine.RegisterCommand("f", new CommandFillet()); commandMachine.RegisterCommand("f", new CommandFillet());
commandMachine.RegisterCommand("br2", new Command_DrawBoard2());
// commandMachine.RegisterCommand("st", new SaveTarget()) // commandMachine.RegisterCommand("st", new SaveTarget())
// commandMachine.RegisterCommand("rt", new RevTarget()) // commandMachine.RegisterCommand("rt", new RevTarget())
} }

@ -12,7 +12,6 @@ import { SelectBox } from './SelectBox';
import { SelectPick } from './SelectPick'; import { SelectPick } from './SelectPick';
import { SelectSet, SelectType } from './SelectSet'; import { SelectSet, SelectType } from './SelectSet';
import { TransMode } from './TranstrolControl/TransformServices'; import { TransMode } from './TranstrolControl/TransformServices';
import { Entity } from '../DatabaseServices/Entity';
export class SelectControls implements EditorService export class SelectControls implements EditorService
{ {

@ -1,35 +1,44 @@
import * as THREE from 'three'; import { Matrix4, Vector3 } from 'three';
/**
* .
*
* @export
* @class CoordinateSystem
*/
export class CoordinateSystem export class CoordinateSystem
{ {
m_Postion: THREE.Vector3; m_Postion: Vector3;
m_xAxis: THREE.Vector3; m_xAxis: Vector3;
m_yAxis: THREE.Vector3; m_yAxis: Vector3;
m_zAxis: THREE.Vector3; m_zAxis: Vector3;
constructor(postion?: THREE.Vector3, xAxis?: THREE.Vector3, yAxis?: THREE.Vector3, zAxis?: THREE.Vector3) constructor(postion?: Vector3, xAxis?: Vector3, yAxis?: Vector3, zAxis?: Vector3)
{ {
this.m_Postion = postion || new THREE.Vector3(0, 0, 0); this.m_Postion = postion || new Vector3(0, 0, 0);
this.m_xAxis = xAxis || new THREE.Vector3(1, 0, 0); this.m_xAxis = xAxis || new Vector3(1, 0, 0);
this.m_yAxis = yAxis || new THREE.Vector3(0, 1, 0); this.m_yAxis = yAxis || new Vector3(0, 1, 0);
this.m_zAxis = zAxis || new THREE.Vector3(0, 0, 1); this.m_zAxis = zAxis || new Vector3(0, 0, 1);
} }
applyMatrix4(mat4: THREE.Matrix4) applyMatrix4(mat4: Matrix4)
{ {
this.m_Postion.applyMatrix4(mat4) this.m_Postion.applyMatrix4(mat4);
this.m_xAxis.applyMatrix4(mat4) let roMat = new Matrix4();
this.m_yAxis.applyMatrix4(mat4) mat4.extractRotation(roMat);
this.m_zAxis.applyMatrix4(mat4) this.m_xAxis.applyMatrix4(roMat);
this.m_yAxis.applyMatrix4(roMat);
this.m_zAxis.applyMatrix4(roMat);
} }
getMatrix4(): THREE.Matrix4 getMatrix4(): Matrix4
{ {
let m = new THREE.Matrix4() let m = new Matrix4()
m.makeBasis(this.m_xAxis, this.m_yAxis, this.m_zAxis) m.makeBasis(this.m_xAxis, this.m_yAxis, this.m_zAxis)
m.setPosition(this.m_Postion) m.setPosition(this.m_Postion)
return m; return m;
} }
copyForm(mat4: THREE.Matrix4) copyForm(mat4: Matrix4)
{ {
this.m_Postion.set( this.m_Postion.set(
mat4.elements[12], mat4.elements[12],
@ -39,7 +48,7 @@ export class CoordinateSystem
mat4.extractBasis(this.m_xAxis, this.m_yAxis, this.m_zAxis) mat4.extractBasis(this.m_xAxis, this.m_yAxis, this.m_zAxis)
} }
extractBasis(xAxisA: THREE.Vector3, yAxisA: THREE.Vector3, zAxisA: THREE.Vector3) extractBasis(xAxisA: Vector3, yAxisA: Vector3, zAxisA: Vector3)
{ {
xAxisA.copy(this.m_xAxis); xAxisA.copy(this.m_xAxis);
yAxisA.copy(this.m_yAxis); yAxisA.copy(this.m_yAxis);
@ -55,7 +64,11 @@ export class CoordinateSystem
} }
clone() clone()
{ {
let r = new CoordinateSystem() let r = new CoordinateSystem();
return r r.m_Postion = this.m_Postion.clone();
r.m_xAxis = this.m_xAxis.clone();
r.m_yAxis = this.m_yAxis.clone();
r.m_zAxis = this.m_zAxis.clone();
return r;
} }
} }

@ -279,7 +279,7 @@ export class Viewer
en.GoodBye(); en.GoodBye();
} }
}) })
xaop.end(db.ModelSpace, db.ModelSpace.ReadFile, () => xaop.end(db, db.FileRead, () =>
{ {
renderEntitys(); renderEntitys();
}) })

@ -133,13 +133,17 @@ export class Asset extends React.Component<AssetPropsType, {}>{
{ {
//得到选择的实体. //得到选择的实体.
let mat = this.props.showObject as DbPhysicalMaterial; let mat = this.props.showObject as DbPhysicalMaterial;
for (let o of app.m_Viewer.m_OutlinePass.selectedObjects) for (let en of app.m_Editor.m_SelectCtrl.SelectSet.SelectEntityList)
{ {
if (o instanceof THREE.Mesh) en.Material = mat.Id;
{
o.material = mat.Material;
}
} }
// for (let o of app.m_Viewer.m_OutlinePass.selectedObjects)
// {
// if (o instanceof THREE.Mesh)
// {
// o.material = mat.Material;
// }
// }
app.m_Viewer.m_bNeedUpdate = true; app.m_Viewer.m_bNeedUpdate = true;
} }
handleDelete = () => handleDelete = () =>

Loading…
Cancel
Save