同步代码

This commit is contained in:
ChenX
2023-08-09 15:33:14 +08:00
parent 2adf047675
commit f1a1373831
37 changed files with 211 additions and 78 deletions

View File

@@ -14,7 +14,6 @@ import * as clipperLib from 'js-angusj-clipper/web';
import { JoinType, EndType } from 'js-angusj-clipper/web';
import polylabel from 'polylabel';
function observable() { };
function toJS() { };
/******************************************************************************
Copyright (c) Microsoft Corporation.
@@ -4802,15 +4801,17 @@ Circle = Circle_1 = __decorate([
Factory
], 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;
}
@@ -11070,9 +11071,17 @@ let Region = Region_1 = class Region extends 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 = RenderType.Wireframe) {
if (renderType === RenderType.Wireframe) {
return new LineSegments(this.EdgeGeometry, ColorMaterial.GetLineMaterial(this.ColorIndex));
@@ -11612,6 +11621,15 @@ let CylinderHole = CylinderHole_1 = class CylinderHole extends 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
@@ -14156,9 +14174,17 @@ let SweepSolid = SweepSolid_1 = class SweepSolid extends 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 === RenderType.Wireframe || renderType === RenderType.Edge) {
@@ -17999,6 +18025,10 @@ let ExtrudeSolid = ExtrudeSolid_1 = class ExtrudeSolid extends Entity {
this._MeshGeometry.dispose();
this._MeshGeometry = undefined;
}
ClearDraw() {
this.UpdateDrawGeometry();
return super.ClearDraw();
}
UpdateDrawObject(renderType, obj) {
DisposeThreeObj(obj);
Object3DRemoveAll(obj);
@@ -18499,6 +18529,15 @@ let ExtrudeHole = class ExtrudeHole extends 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 Vector3).setZ(this.Height);
return new OBB(this.OCS, size.multiplyScalar(0.5));
@@ -21941,6 +21980,7 @@ let Board = Board_1 = class Board extends ExtrudeSolid {
br._LayerNails = [...this._LayerNails];
br.ProcessingGroupList = [...this.ProcessingGroupList];
br._BoardProcessOption = { ...this._BoardProcessOption };
br._CustomNumber = this._CustomNumber; //因为CustomNumber不会刷新绘制,所以拷贝这个
let new2old_edgeMap;
//修正排钻边的数据
if (highDrills) {
@@ -22617,7 +22657,7 @@ let Board = Board_1 = class Board extends ExtrudeSolid {
csg.transforms = mtx.toArray();
}
else {
let mtx = MakeMirrorMtx(ZAxis, new Vector3(0, 0, item.depth));
let mtx = MakeMirrorMtx(ZAxis, new 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();
@@ -24145,6 +24185,13 @@ let RoomWallLine = class RoomWallLine extends RoomWallBase {
line.geometry = geometry;
}
}
ClearDraw() {
if (this._MeshGeometry)
this._MeshGeometry = undefined;
if (this._EdgeGeometry)
this._EdgeGeometry = undefined;
return super.ClearDraw();
}
//#endregion
//#region -------------------------File-------------------------
//对象从文件中读取数据,初始化自身
@@ -25134,6 +25181,10 @@ let RoomFlatBase = class RoomFlatBase extends RoomBase {
}
}
}
ClearDraw() {
this.UpdateDrawGeometry();
return super.ClearDraw();
}
//#region -----------------------------File-----------------------------
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
//对象从文件中读取数据,初始化自身
@@ -26507,6 +26558,10 @@ let RoomWallArc = class RoomWallArc extends RoomWallBase {
this._MeshGeometry.dispose();
this._MeshGeometry = undefined;
}
ClearDraw() {
this.UpdateDrawGeometry();
return super.ClearDraw();
}
get EdgeGeometry() {
if (this._EdgeGeometry)
return this._EdgeGeometry;
@@ -27347,6 +27402,10 @@ let RoomHolePolyline = class RoomHolePolyline extends RoomHoleBase {
this._MeshGeometry.dispose();
this._MeshGeometry = undefined;
}
ClearDraw() {
this.UpdateDrawGeometry();
return super.ClearDraw();
}
get EdgeGeometry() {
if (this._EdgeGeometry)
return this._EdgeGeometry;
@@ -35783,20 +35842,13 @@ let RevolveSolid = RevolveSolid_1 = class RevolveSolid extends Entity {
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 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 = ShapeUtils.triangulateShape(this._CacheContourPoints, []);
this._CacheContourPoints3DQ = [];
if (isParallelTo(this._Contour.Normal, YAxis))
@@ -35860,8 +35912,7 @@ let RevolveSolid = RevolveSolid_1 = class RevolveSolid extends Entity {
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 = RenderType.Wireframe) {
@@ -35870,8 +35921,14 @@ let RevolveSolid = RevolveSolid_1 = class RevolveSolid extends Entity {
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 === RenderType.Wireframe) {
@@ -38965,6 +39022,10 @@ let BulkheadCeiling = class BulkheadCeiling extends Entity {
this._FaceGeometry.dispose();
this._FaceGeometry = undefined;
}
ClearDraw() {
this.UpdateDrawGeometry();
return super.ClearDraw();
}
GetGripPoints() {
let pts = [];
for (let data of this._ContourData)