同步代码
This commit is contained in:
108
api.cjs.js
108
api.cjs.js
@@ -4833,15 +4833,17 @@ exports.Circle = Circle_1 = __decorate([
|
||||
Factory
|
||||
], exports.Circle);
|
||||
|
||||
const ARC_SplitLength = 0.4; //圆的分段长度(虚幻引擎的尺寸单位是厘米)
|
||||
const ARC_RADIUS_MIN = 2.5; //大于半径25的自动优化成36等分圆 保证绘制光滑
|
||||
const Arc_MinSplitCount = 8; //圆的最小分段个数
|
||||
const ARC_MaxSplitCount = 90; //圆的最大分段个数
|
||||
const ARC_DRAW_CONFIG = {
|
||||
ARC_SplitLength: 0.4,
|
||||
ARC_RADIUS_MIN: 2.5,
|
||||
Arc_MinSplitCount: 8,
|
||||
ARC_MaxSplitCount: 90, //圆的最大分段个数
|
||||
};
|
||||
function GetArcDrawCount(arc) {
|
||||
let splitCount = arc.Radius / ARC_SplitLength;
|
||||
let splitCount = arc.Radius / ARC_DRAW_CONFIG.ARC_SplitLength;
|
||||
//保证是偶数(避免奇数和Shape2计算方式一致导致的干涉)
|
||||
splitCount = clamp(Math.floor(splitCount * 0.5) * 2, Arc_MinSplitCount, ARC_MaxSplitCount);
|
||||
if (arc.Radius > ARC_RADIUS_MIN)
|
||||
splitCount = clamp(Math.floor(splitCount * 0.5) * 2, ARC_DRAW_CONFIG.Arc_MinSplitCount, ARC_DRAW_CONFIG.ARC_MaxSplitCount);
|
||||
if (arc.Radius > ARC_DRAW_CONFIG.ARC_RADIUS_MIN)
|
||||
splitCount = Math.max(36, splitCount);
|
||||
return splitCount;
|
||||
}
|
||||
@@ -11101,9 +11103,17 @@ exports.Region = Region_1 = class Region extends exports.Entity {
|
||||
this._MeshGeometry.computeVertexNormals();
|
||||
}
|
||||
UpdateDrawGeometry() {
|
||||
if (this._EdgeGeometry)
|
||||
this._EdgeGeometry.dispose();
|
||||
this._EdgeGeometry = undefined;
|
||||
if (this._MeshGeometry)
|
||||
this._MeshGeometry.dispose();
|
||||
this._MeshGeometry = undefined;
|
||||
}
|
||||
ClearDraw() {
|
||||
this.UpdateDrawGeometry();
|
||||
return super.ClearDraw();
|
||||
}
|
||||
InitDrawObject(renderType = exports.RenderType.Wireframe) {
|
||||
if (renderType === exports.RenderType.Wireframe) {
|
||||
return new three.LineSegments(this.EdgeGeometry, ColorMaterial.GetLineMaterial(this.ColorIndex));
|
||||
@@ -11643,6 +11653,15 @@ exports.CylinderHole = CylinderHole_1 = class CylinderHole extends exports.Hole
|
||||
mesh.material = ColorMaterial.GetConceptualMaterial(this.ColorIndex);
|
||||
}
|
||||
}
|
||||
ClearDraw() {
|
||||
if (this._EdgeGeometry)
|
||||
this._EdgeGeometry.dispose();
|
||||
this._EdgeGeometry = undefined;
|
||||
if (this._MeshGeometry)
|
||||
this._MeshGeometry.dispose();
|
||||
this._MeshGeometry = undefined;
|
||||
return super.ClearDraw();
|
||||
}
|
||||
_ReadFile(file) {
|
||||
super._ReadFile(file);
|
||||
let ver = file.Read(); //1
|
||||
@@ -14187,9 +14206,17 @@ exports.SweepSolid = SweepSolid_1 = class SweepSolid extends exports.Entity {
|
||||
}
|
||||
}
|
||||
UpdateDrawGeometry() {
|
||||
if (this._EdgeGeometry)
|
||||
this._EdgeGeometry.dispose();
|
||||
this._EdgeGeometry = undefined;
|
||||
if (this._MeshGeometry)
|
||||
this._MeshGeometry.dispose();
|
||||
this._MeshGeometry = undefined;
|
||||
}
|
||||
ClearDraw() {
|
||||
this.UpdateDrawGeometry();
|
||||
return super.ClearDraw();
|
||||
}
|
||||
UpdateDrawObject(renderType, obj) {
|
||||
DisposeThreeObj(obj);
|
||||
if (renderType === exports.RenderType.Wireframe || renderType === exports.RenderType.Edge) {
|
||||
@@ -18030,6 +18057,10 @@ exports.ExtrudeSolid = ExtrudeSolid_1 = class ExtrudeSolid extends exports.Entit
|
||||
this._MeshGeometry.dispose();
|
||||
this._MeshGeometry = undefined;
|
||||
}
|
||||
ClearDraw() {
|
||||
this.UpdateDrawGeometry();
|
||||
return super.ClearDraw();
|
||||
}
|
||||
UpdateDrawObject(renderType, obj) {
|
||||
DisposeThreeObj(obj);
|
||||
Object3DRemoveAll(obj);
|
||||
@@ -18530,6 +18561,15 @@ exports.ExtrudeHole = class ExtrudeHole extends exports.Hole {
|
||||
mesh.material = ColorMaterial.GetConceptualMaterial(this.ColorIndex);
|
||||
}
|
||||
}
|
||||
ClearDraw() {
|
||||
if (this._EdgeGeometry)
|
||||
this._EdgeGeometry.dispose();
|
||||
this._EdgeGeometry = undefined;
|
||||
if (this._MeshGeometry)
|
||||
this._MeshGeometry.dispose();
|
||||
this._MeshGeometry = undefined;
|
||||
return super.ClearDraw();
|
||||
}
|
||||
get OBB() {
|
||||
let size = this.ContourCurve.BoundingBox.getSize(new three.Vector3).setZ(this.Height);
|
||||
return new OBB(this.OCS, size.multiplyScalar(0.5));
|
||||
@@ -21972,6 +22012,7 @@ exports.Board = Board_1 = class Board extends exports.ExtrudeSolid {
|
||||
br._LayerNails = [...this._LayerNails];
|
||||
br.ProcessingGroupList = [...this.ProcessingGroupList];
|
||||
br._BoardProcessOption = { ...this._BoardProcessOption };
|
||||
br._CustomNumber = this._CustomNumber; //因为CustomNumber不会刷新绘制,所以拷贝这个
|
||||
let new2old_edgeMap;
|
||||
//修正排钻边的数据
|
||||
if (highDrills) {
|
||||
@@ -22648,7 +22689,7 @@ exports.Board = Board_1 = class Board extends exports.ExtrudeSolid {
|
||||
csg.transforms = mtx.toArray();
|
||||
}
|
||||
else {
|
||||
let mtx = MakeMirrorMtx(ZAxis, new three.Vector3(0, 0, item.depth));
|
||||
let mtx = MakeMirrorMtx(ZAxis, new three.Vector3(0, 0, item.depth * 0.5));
|
||||
// let edge = geometry.EdgeGeom.applyMatrix4(mtx);
|
||||
// this._2DPathDrawObject.add(new LineSegments(edge, ColorMaterial.GetLineMaterial(this.ColorIndex)));
|
||||
csg.transforms = mtx.toArray();
|
||||
@@ -24176,6 +24217,13 @@ exports.RoomWallLine = class RoomWallLine extends exports.RoomWallBase {
|
||||
line.geometry = geometry;
|
||||
}
|
||||
}
|
||||
ClearDraw() {
|
||||
if (this._MeshGeometry)
|
||||
this._MeshGeometry = undefined;
|
||||
if (this._EdgeGeometry)
|
||||
this._EdgeGeometry = undefined;
|
||||
return super.ClearDraw();
|
||||
}
|
||||
//#endregion
|
||||
//#region -------------------------File-------------------------
|
||||
//对象从文件中读取数据,初始化自身
|
||||
@@ -25165,6 +25213,10 @@ exports.RoomFlatBase = class RoomFlatBase extends exports.RoomBase {
|
||||
}
|
||||
}
|
||||
}
|
||||
ClearDraw() {
|
||||
this.UpdateDrawGeometry();
|
||||
return super.ClearDraw();
|
||||
}
|
||||
//#region -----------------------------File-----------------------------
|
||||
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
|
||||
//对象从文件中读取数据,初始化自身
|
||||
@@ -26538,6 +26590,10 @@ exports.RoomWallArc = class RoomWallArc extends exports.RoomWallBase {
|
||||
this._MeshGeometry.dispose();
|
||||
this._MeshGeometry = undefined;
|
||||
}
|
||||
ClearDraw() {
|
||||
this.UpdateDrawGeometry();
|
||||
return super.ClearDraw();
|
||||
}
|
||||
get EdgeGeometry() {
|
||||
if (this._EdgeGeometry)
|
||||
return this._EdgeGeometry;
|
||||
@@ -27378,6 +27434,10 @@ exports.RoomHolePolyline = class RoomHolePolyline extends exports.RoomHoleBase {
|
||||
this._MeshGeometry.dispose();
|
||||
this._MeshGeometry = undefined;
|
||||
}
|
||||
ClearDraw() {
|
||||
this.UpdateDrawGeometry();
|
||||
return super.ClearDraw();
|
||||
}
|
||||
get EdgeGeometry() {
|
||||
if (this._EdgeGeometry)
|
||||
return this._EdgeGeometry;
|
||||
@@ -35814,20 +35874,13 @@ exports.RevolveSolid = RevolveSolid_1 = class RevolveSolid extends exports.Entit
|
||||
this._CacheIsRev = n.y > 0;
|
||||
}
|
||||
if (this._CacheContourPoints === undefined) {
|
||||
this._CacheContourPoints3D = [];
|
||||
let ocsInv = this._Contour.OCSInv;
|
||||
for (let i = 0; i < this._Contour.EndParam; i++) {
|
||||
let c = this._Contour.GetCurveAtIndex(i);
|
||||
this._CacheContourPoints3D.push(c.StartPoint);
|
||||
if (c instanceof exports.Arc) {
|
||||
let minCount = Math.max(2, Math.ceil((c.AllAngle) / Math.PI) * 3);
|
||||
let count = clamp(c.Length / 20, minCount, 30);
|
||||
for (let j = 0; j < count; j++)
|
||||
this._CacheContourPoints3D.push(c.GetPointAtParam((j + 1) / (count + 1)));
|
||||
}
|
||||
this._CacheContourPoints3D.push(c.EndPoint);
|
||||
this._CacheContourPoints = [];
|
||||
for (let p of this._Contour.Shape.getPoints(6)) {
|
||||
this._CacheContourPoints.push(p);
|
||||
if (p["_mask_"])
|
||||
this._CacheContourPoints.push(p);
|
||||
}
|
||||
this._CacheContourPoints = this._CacheContourPoints3D.map(p => AsVector2(p.clone().applyMatrix4(ocsInv)));
|
||||
this._CacheContourPoints3D = this._CacheContourPoints.map(p => AsVector3(p).applyMatrix4(this._Contour.OCSNoClone));
|
||||
this._CacheContourFaces = three.ShapeUtils.triangulateShape(this._CacheContourPoints, []);
|
||||
this._CacheContourPoints3DQ = [];
|
||||
if (isParallelTo(this._Contour.Normal, YAxis))
|
||||
@@ -35891,8 +35944,7 @@ exports.RevolveSolid = RevolveSolid_1 = class RevolveSolid extends exports.Entit
|
||||
RevolveLine(geo, this._CacheContourPoints3DQ, this._CacheContourPoints3DQ2, this._StartAngle, allAngle, us);
|
||||
geo.computeFaceNormals();
|
||||
geo.computeVertexNormals();
|
||||
this._MeshGeometry = geo;
|
||||
return geo;
|
||||
return this._MeshGeometry;
|
||||
}
|
||||
//#region Draw
|
||||
InitDrawObject(renderType = exports.RenderType.Wireframe) {
|
||||
@@ -35901,8 +35953,14 @@ exports.RevolveSolid = RevolveSolid_1 = class RevolveSolid extends exports.Entit
|
||||
return obj;
|
||||
}
|
||||
UpdateDrawGeometry() {
|
||||
if (this._MeshGeometry)
|
||||
this._MeshGeometry.dispose();
|
||||
this._MeshGeometry = undefined;
|
||||
}
|
||||
ClearDraw() {
|
||||
this.UpdateDrawGeometry();
|
||||
return super.ClearDraw();
|
||||
}
|
||||
UpdateDrawObject(type, obj) {
|
||||
Object3DRemoveAll(obj);
|
||||
if (type === exports.RenderType.Wireframe) {
|
||||
@@ -38996,6 +39054,10 @@ exports.BulkheadCeiling = class BulkheadCeiling extends exports.Entity {
|
||||
this._FaceGeometry.dispose();
|
||||
this._FaceGeometry = undefined;
|
||||
}
|
||||
ClearDraw() {
|
||||
this.UpdateDrawGeometry();
|
||||
return super.ClearDraw();
|
||||
}
|
||||
GetGripPoints() {
|
||||
let pts = [];
|
||||
for (let data of this._ContourData)
|
||||
|
Reference in New Issue
Block a user