更新版本

This commit is contained in:
2025-05-20 18:10:58 +08:00
parent 00b58ffefe
commit 1a72a9679d
29 changed files with 162 additions and 102 deletions

View File

@@ -2,6 +2,7 @@ import { measureAggregateVolume, measureBoundingBox as measureBoundingBox$1 } fr
import { Vector3, FrontSide, LineDashedMaterial, Vector2 as Vector2$1, DoubleSide, MeshBasicMaterial, LineBasicMaterial, LineDashDotMaterial, LineDashDoubleDotMaterial, LineCenterMaterial, ShaderMaterial, Color, Matrix4, Box3, MeshPhysicalMaterial, Object3D, MathUtils, Quaternion, BufferGeometry, Shape as Shape$1, ShapeGeometry, BufferAttribute, Line as Line$1, Plane as Plane$1, Line3, EllipseCurve, CatmullRomCurve3, Box2 as Box2$1, Float32BufferAttribute, Path as Path$1, Geometry, Face3, LineSegments, Mesh, CylinderBufferGeometry, InstancedInterleavedBuffer, InterleavedBufferAttribute, ShapeUtils, BoxBufferGeometry, ExtrudeGeometry, Group, BoxGeometry, Triangle, Euler, ShapeBufferGeometry, OrthographicCamera, PerspectiveCamera, AmbientLight as AmbientLight$1, DirectionalLightHelper, SphereBufferGeometry, Matrix3, DirectionalLight as DirectionalLight$1, HemisphereLight as HemisphereLight$1, MirroredRepeatWrapping, Texture, Scene, WebGLRenderTarget, Frustum, MeshNormalMaterial, TextureLoader, PointLight as PointLight$1, SphereGeometry, BackSide, RectAreaLight as RectAreaLight$1, SpotLight as SpotLight$1, ConeGeometry, PointsMaterial, Points, Raycaster } from 'three';
import { Line2 } from 'three/examples/jsm/lines/Line2';
import { LineGeometry } from 'three/examples/jsm/lines/LineGeometry';
import { LineSegments2 } from 'three/examples/jsm/lines/LineSegments2';
import { LineSegmentsGeometry } from 'three/examples/jsm/lines/LineSegmentsGeometry';
import geom3, { toPolygons, transform as transform$1 } from '@jscad/modeling/src/geometries/geom3';
import mat4 from '@jscad/modeling/src/maths/mat4';
@@ -5178,10 +5179,8 @@ let Curve = Curve_1 = class Curve extends Entity {
for (let p of pts)
array.push(p.x, p.y, 0);
let geometry = new LineGeometry().setPositions(array);
const material = ColorMaterial.PrintLineMatrial.clone();
// 引线的颜色
if (HostApplicationServices.printIsColor)
material.color = ColorMaterial.GetColor(this.PrintColorIndex);
// 用 PrintColorIndex 便于 白->黑
const material = ColorMaterial.GetPrintLineMaterial(this.PrintColorIndex);
return new Line2(geometry, material);
}
let geo = new BufferGeometry().setFromPoints(pts);
@@ -5366,13 +5365,9 @@ let Line = Line_1 = class Line extends Curve {
for (let p of pts)
array.push(p.x, p.y, p.z);
let geometry = new LineGeometry().setPositions(array);
// 线段的颜色
if (HostApplicationServices.printIsColor) {
const printLineMatrial = ColorMaterial.PrintLineMatrial.clone();
printLineMatrial.color = ColorMaterial.GetColor(this.PrintColorIndex);
return new Line2(geometry, printLineMatrial);
}
return new Line2(geometry, ColorMaterial.PrintLineMatrial);
// 用 PrintColorIndex 便于 白->黑
const printLineMatrial = ColorMaterial.GetPrintLineMaterial(this.PrintColorIndex);
return new Line2(geometry, printLineMatrial);
}
let geo = new BufferGeometry().setFromPoints(pts);
let line = new Line$1(geo, ColorMaterial.GetLineMaterial(this.DrawColorIndex, this._Freeze, this._LineType));
@@ -5403,10 +5398,8 @@ let Line = Line_1 = class Line extends Curve {
UpdateDrawObjectMaterial(type, obj, material) {
if (type === RenderType.WireframePrint) {
let m = obj;
const mtl = ColorMaterial.PrintLineMatrial.clone();
if (HostApplicationServices.printIsColor) {
mtl.color = ColorMaterial.GetColor(this.PrintColorIndex);
}
// 用 PrintColorIndex 便于 白->黑
const mtl = ColorMaterial.GetPrintLineMaterial(this.PrintColorIndex);
m.material = mtl;
}
else {
@@ -7006,14 +6999,9 @@ let Circle = Circle_1 = class Circle extends Curve {
if (renderType === RenderType.WireframePrint)
{
let geometry = new LineGeometry().setPositions(cirGeo.attributes.position.array as number[]);
// 线段的颜色
if (HostApplicationServices.printIsColor)
{
const printLineMatrial = ColorMaterial.PrintLineMatrial.clone();
printLineMatrial.color = ColorMaterial.GetColor(this.ColorIndex);
return new Line2(geometry, printLineMatrial);
}
obj.add(new Line2(geometry, ColorMaterial.PrintLineMatrial));
// 用 PrintColorIndex 便于 白->黑
const printLineMatrial = ColorMaterial.GetPrintLineMaterial(this.PrintColorIndex);
obj.add(new Line2(geometry, printLineMatrial));
}
else
{
@@ -9830,10 +9818,8 @@ let Polyline = Polyline_1 = class Polyline extends Curve {
// 多段线也支持彩印
if (type === RenderType.WireframePrint) {
let m = obj;
const mtl = ColorMaterial.PrintLineMatrial.clone();
if (HostApplicationServices.printIsColor) {
mtl.color = ColorMaterial.GetColor(this.PrintColorIndex);
}
// 用 PrintColorIndex 便于 白->黑
const mtl = ColorMaterial.GetPrintLineMaterial(this.PrintColorIndex);
m.material = mtl;
}
else {
@@ -15250,6 +15236,7 @@ var ViewType;
/** 映射: 视图->矩阵 */
new Map([
[ViewType.Front, new Matrix4().fromArray([1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1])],
[ViewType.Back, new Matrix4().fromArray([-1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1])],
[ViewType.Left, new Matrix4().fromArray([0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, 0, 0, 1])],
[ViewType.Down, new Matrix4().fromArray([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])],
[ViewType.Right, new Matrix4().fromArray([0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1])],
@@ -17388,6 +17375,7 @@ const DefaultPartsAnalysisOption = {
};
Object.freeze(DefaultPartsAnalysisOption);
const DefaultFastDimOption = {
version: 1,
filterSmallSize: false,
filterSmallSizeValue: 0,
filterAppointSize: false,
@@ -17395,6 +17383,8 @@ const DefaultFastDimOption = {
filterAppointForBoardName: false,
filterAppointForBoardNameValues: "",
conditionType: ForBoardNameType.Same,
filterBoardDist: false,
filterBoardDistValue: 100
};
Object.freeze(DefaultFastDimOption);
const DefaultOneClickInspectionOption = {
@@ -17511,6 +17501,16 @@ const DefaultExtrudePl2Board = {
isDrawBottom: true,
};
Object.freeze(DefaultExtrudePl2Board);
const DefaultExportSTEPOption = {
version: 1,
drillHole: true, // 排钻孔
drilling: true, // 排钻
topLine: true, // 顶线
handle: true, // 拉手
hinge: true, // 铰链
compositeEntity: true, // 复合实体
};
Object.freeze(DefaultExportSTEPOption);
/**
* 使用轮廓和扫描路径构建扫描几何体,实现衣柜中的顶线或者地脚线之类的实体.
@@ -25209,6 +25209,13 @@ let CompositeEntity = CompositeEntity_1 = class CompositeEntity extends Entity {
callback(en);
}
}
ClearDraw() {
this.Traverse(ent => {
if (ent !== this)
ent.ClearDraw();
});
return super.ClearDraw();
}
//实体在被内嵌时,它绘制对象的世界矩阵会被影响,所以这里我们不直接计算它的盒子,而是用绘制对象的盒子来计算包围盒,避免错误
//例如 复合扫略实体 的ZoomObject在这个实现下是错误的(因为扫略实体也是直接取绘制对象的包围盒)
// get BoundingBox()
@@ -29447,6 +29454,7 @@ function Creat2DModelGeom(board, modelings, _2DPathCsgs, faceMtx) {
knifeGeomPts = shapePts.map(p => [p.x, p.y]);
if (sweepContour.IsClockWise)
knifeGeomPts.reverse();
modelKnifePtsCache.set(item.knife.id, knifeGeomPts);
}
//刀截面geom
let knifeGeom = geom2.fromPoints(knifeGeomPts);
@@ -32255,7 +32263,7 @@ let Board = Board_1 = class Board extends ExtrudeSolid {
l = new Line$1(BufferGeometryUtils.CreateFromPts(PointShapeUtils.LinesOpenDirPts(this.height, this.width, openDir)), ColorMaterial.GetWallLineMtl(color));
}
else {
// 虚线 todo线宽>3时可能要对geom做二次填充
// 虚线
if (HostApplicationServices.openDirIsDash) {
const geometry = new LineSegmentsGeometry();
const nums = [];
@@ -32263,10 +32271,11 @@ let Board = Board_1 = class Board extends ExtrudeSolid {
for (let p of pts)
nums.push(p.x, p.y, p.z);
geometry.setPositions(nums);
const material = ColorMaterial.PrintLineMatrial.clone();
material.linewidth = lineWidth;
// 用 PrintColorIndex 便于 白->黑
const material = ColorMaterial.GetPrintLineMaterial(this.PrintColorIndex);
material.linewidth = lineWidth + 1; // 加1好看点
material.color = ColorMaterial.GetColor(color);
l = new LineSegments(geometry, material);
l = new LineSegments2(geometry, material);
}
// 实线
else {
@@ -32276,7 +32285,8 @@ let Board = Board_1 = class Board extends ExtrudeSolid {
for (let p of pts)
nums.push(p.x, p.y, p.z);
geometry.setPositions(nums);
const material = ColorMaterial.PrintLineMatrial.clone();
// 用 PrintColorIndex 便于 白->黑
const material = ColorMaterial.GetPrintLineMaterial(this.PrintColorIndex);
material.linewidth = lineWidth;
material.color = ColorMaterial.GetColor(color);
l = new Line2(geometry, material);
@@ -38755,8 +38765,9 @@ let RoomHolePolyline = class RoomHolePolyline extends RoomHoleBase {
}
this._MeshGeometry = new BufferGeometry().fromGeometry(geo);
for (const group of this._MeshGeometry.groups) {
if (this._OverWriteMaterial.has(group.materialIndex)) {
let mtl = (this._OverWriteMaterial.get(group.materialIndex).Object);
let id = this._OverWriteMaterial.get(group.materialIndex);
if (id) {
let mtl = id.Object;
this.GenWorldUV(this._MeshGeometry, mtl, group.start, group.count);
}
}
@@ -38780,9 +38791,10 @@ let RoomHolePolyline = class RoomHolePolyline extends RoomHoleBase {
}
for (const group of this.MeshGeometry.groups) {
if (this._OverWriteMaterial.size > 0) {
if (this._OverWriteMaterial.has(group.materialIndex)) {
let mtl = (this._OverWriteMaterial.get(group.materialIndex).Object);
this.GenWorldUV(this.MeshGeometry, mtl, group.start, group.count);
let id = this._OverWriteMaterial.get(group.materialIndex);
if (id) {
let mtl = id.Object;
this.GenWorldUV(this._MeshGeometry, mtl, group.start, group.count);
}
}
else {
@@ -42832,6 +42844,10 @@ let Dimension = class Dimension extends Entity {
this.WriteAllObjectRecord();
this._CabinetName = value;
}
ClearDraw() {
this._Text.ClearDraw();
return super.ClearDraw();
}
ReadDimStyle(file) {
this._DimStyleOverride.clear();
let size = file.Read();
@@ -51494,10 +51510,13 @@ let RadiusDimension = class RadiusDimension extends Dimension {
let [line, arrow, textObj] = obj.children;
// 修改箭头类型
{
obj.remove(arrow, textObj);
obj.remove(arrow);
// textObj 可能为undefined
textObj && obj.remove(textObj);
const [newArrow1, newArrow2] = this.GetArrowObject(renderType);
arrow = newArrow1;
obj.add(arrow, textObj);
obj.add(arrow);
textObj && obj.add(textObj);
}
let arrowSize = this.GetDimStyleValue(DimStyleKeyCode.DIMASZ) ?? 10;
if (renderType === RenderType.WireframePrint) {