diff --git a/src/Common/ColorPalette.ts b/src/Common/ColorPalette.ts index a238558b1..6fd91723f 100644 --- a/src/Common/ColorPalette.ts +++ b/src/Common/ColorPalette.ts @@ -321,9 +321,8 @@ export class ColorMaterial } private static _ConceptualMaterial: Map = new Map(); - static GetConceptualMaterial(color: number, side: Side = FrontSide, enableTransparent = false, freeze = false, opacity?: number) + static GetConceptualMaterial(color: number, side: Side = FrontSide, enableTransparent = false) { - if (freeze) color = 257; let key = `${color},${side},${enableTransparent ? 1 : 0}`; if (this._ConceptualMaterial.has(key)) return this._ConceptualMaterial.get(key); @@ -336,15 +335,7 @@ export class ColorMaterial get: () => mtl.uniforms.opacity.value !== 1 }); Object.defineProperty(mtl.uniforms.opacity, "value", { - get: () => - { - let conceptualOpacity = HostApplicationServices.ConceptualOpacity; - if (freeze) - conceptualOpacity = 0.5; - else if (opacity) - conceptualOpacity = opacity; - return conceptualOpacity; - } + get: () => HostApplicationServices.ConceptualOpacity }); } this._ConceptualMaterial.set(key, mtl); diff --git a/src/DatabaseServices/Entity/Board.ts b/src/DatabaseServices/Entity/Board.ts index 65678f6c5..4ed31c29b 100644 --- a/src/DatabaseServices/Entity/Board.ts +++ b/src/DatabaseServices/Entity/Board.ts @@ -2199,7 +2199,7 @@ export class Board extends ExtrudeSolid //del_exp2_end //绘制排版面时使用的颜色 - private get PlaceColor() { return this._Color === 8 ? 9 : this._Color; } + private get PlaceColor() { return this._Color === 8 ? 9 : this.DrawColorIndex; } //排版面网格 private GetPlaceFace(): Mesh { diff --git a/src/DatabaseServices/Entity/Extrude.ts b/src/DatabaseServices/Entity/Extrude.ts index 3686956ba..41b5c62ea 100644 --- a/src/DatabaseServices/Entity/Extrude.ts +++ b/src/DatabaseServices/Entity/Extrude.ts @@ -1,6 +1,6 @@ import { Geom3 } from '@jscad/modeling/src/geometries/types'; import Flatbush from 'flatbush'; -import { Box3, BoxGeometry, BufferGeometry, ExtrudeGeometry, ExtrudeGeometryOptions, Float32BufferAttribute, FrontSide, Frustum, Geometry, Group, InstancedInterleavedBuffer, InterleavedBufferAttribute, LineSegments, Matrix3, Matrix4, Mesh, Object3D, Line as TLine, UVGenerator, Vector3 } from "three"; +import { Box3, BoxGeometry, BufferGeometry, ExtrudeGeometry, ExtrudeGeometryOptions, Float32BufferAttribute, FrontSide, Frustum, Geometry, Group, InstancedInterleavedBuffer, InterleavedBufferAttribute, LineSegments, Material, Matrix3, Matrix4, Mesh, Object3D, Line as TLine, UVGenerator, Vector3 } from "three"; import { Line2 } from "three/examples/jsm/lines/Line2"; import { LineGeometry } from "three/examples/jsm/lines/LineGeometry"; import { arrayClone, arrayLast, arrayPushArray, arrayRemoveIf, arrayRemoveOnce, arraySortByNumber, arraySum } from "../../Common/ArrayExt"; @@ -1692,7 +1692,7 @@ export class ExtrudeSolid extends Entity else if (renderType === RenderType.Conceptual) { return new Object3D().add( - new Mesh(this.MeshGeometry, ColorMaterial.GetConceptualMaterial(this.DrawColorIndex, FrontSide, true, this.Freeze)), + new Mesh(this.MeshGeometry, this.GetConceptualMaterial()), new LineSegments(this.EdgeGeometry, ColorMaterial.GetConceptualEdgeMaterial()) ); } @@ -2130,7 +2130,7 @@ export class ExtrudeSolid extends Entity else if (renderType === RenderType.Conceptual) { return obj.add( - new Mesh(this.MeshGeometry, ColorMaterial.GetConceptualMaterial(this.DrawColorIndex, FrontSide, true, this.Freeze)), + new Mesh(this.MeshGeometry, this.GetConceptualMaterial()), new LineSegments(this.EdgeGeometry, ColorMaterial.GetConceptualEdgeMaterial()) ); } @@ -2185,7 +2185,7 @@ export class ExtrudeSolid extends Entity else if (renderType === RenderType.Conceptual) { let mesh = obj.children[0] as Mesh; - mesh.material = ColorMaterial.GetConceptualMaterial(this.DrawColorIndex, FrontSide, true, this.Freeze); + mesh.material = this.GetConceptualMaterial(); } else if (renderType === RenderType.Physical2) { @@ -2198,6 +2198,18 @@ export class ExtrudeSolid extends Entity mesh.material = this.MeshMaterial; } } + //获取概念视图材质 冻结状态使用257色号 半透明 + private GetConceptualMaterial() + { + let mtl: Material; + if (this.Freeze) + mtl = ColorMaterial.GetBasicMaterialTransparent2(257, 0.5); + else + mtl = ColorMaterial.GetConceptualMaterial(this.DrawColorIndex, FrontSide, true); + + return mtl; + } + private GetModelGroove() { const grooves: ExtrudeSolid[] = []; @@ -2218,7 +2230,7 @@ export class ExtrudeSolid extends Entity const meshGeo = grooveClone.MeshGeometry; meshGeo.applyMatrix4(mtx); - const mesh = new Mesh(meshGeo, ColorMaterial.GetConceptualMaterial(1, FrontSide, true, this.Freeze, 0.6)); + const mesh = new Mesh(meshGeo, ColorMaterial.GetConceptualMaterial(1, 0.6)); group.add(mesh, line); } return group;