diff --git a/src/ApplicationServices/HostApplicationServices.ts b/src/ApplicationServices/HostApplicationServices.ts index 704149f44..307177adf 100644 --- a/src/ApplicationServices/HostApplicationServices.ts +++ b/src/ApplicationServices/HostApplicationServices.ts @@ -8,6 +8,9 @@ import { DrillingOption } from '../UI/Store/drillInterface'; export class IHostApplicationServices { DefaultMeshMaterial?: MeshBasicMaterial | MeshStandardMaterial; + DefaultFloorMaterial?: MeshBasicMaterial | MeshStandardMaterial; + DefaultWallMaterial?: MeshBasicMaterial | MeshStandardMaterial; + CurrentDimStyle: ObjectId; @ProxyValue isShowLightShadow: boolean = true;//灯光阴影 (除太阳光外) ShowHistoryLog: boolean = true; diff --git a/src/DatabaseServices/Database.ts b/src/DatabaseServices/Database.ts index f157fa0ac..10ecf5de2 100644 --- a/src/DatabaseServices/Database.ts +++ b/src/DatabaseServices/Database.ts @@ -63,7 +63,7 @@ export class Database private idIndex = 1; private idMap = new Map(); - constructor(buildDefaultDrawing = false, private defaultDatabase = false, disableHistoric = false) + constructor(buildDefaultDrawing = false, public IsDefaultDatabase = false, disableHistoric = false) { this.ModelSpace = new BlockTableRecord().SetOwnerDatabase(this); this.MaterialTable = new MaterialTable().SetOwnerDatabase(this); @@ -143,7 +143,7 @@ export class Database SettingDefaultStyleAndMaterial() { - if (!this.defaultDatabase) + if (!this.IsDefaultDatabase) return; this.DefaultMaterial = this.GetObjectId(71)?.Object as PhysicalMaterialRecord ?? this.DefaultMaterial; diff --git a/src/DatabaseServices/MaterialTable.ts b/src/DatabaseServices/MaterialTable.ts index fa61654f1..d5e2bd4a7 100644 --- a/src/DatabaseServices/MaterialTable.ts +++ b/src/DatabaseServices/MaterialTable.ts @@ -1,3 +1,4 @@ +import { HostApplicationServices } from "../ApplicationServices/HostApplicationServices"; import { CADFiler } from "./CADFiler"; import { ObjectId } from "./ObjectId"; import { PhysicalMaterialRecord } from "./PhysicalMaterialRecord"; @@ -17,6 +18,9 @@ export class MaterialTable extends SymbolTable if (id === this._CurFloorMtl) return; this.WriteAllObjectRecord(); this._CurFloorMtl = id; + + if (this._db && this._db.IsDefaultDatabase) + HostApplicationServices.DefaultFloorMaterial = (id.Object as PhysicalMaterialRecord).Material; } set CurWallMtl(id) @@ -24,6 +28,9 @@ export class MaterialTable extends SymbolTable if (id === this._CurWallMtl) return; this.WriteAllObjectRecord(); this._CurWallMtl = id; + + if (this._db && this._db.IsDefaultDatabase) + HostApplicationServices.DefaultWallMaterial = (id.Object as PhysicalMaterialRecord).Material; } get Materials() diff --git a/src/DatabaseServices/Room/Entity/Flat/RoomFlatFloor.ts b/src/DatabaseServices/Room/Entity/Flat/RoomFlatFloor.ts index 93ef93503..488aea7f8 100644 --- a/src/DatabaseServices/Room/Entity/Flat/RoomFlatFloor.ts +++ b/src/DatabaseServices/Room/Entity/Flat/RoomFlatFloor.ts @@ -1,5 +1,8 @@ +import { MeshStandardMaterial } from "three"; +import { HostApplicationServices } from "../../../../ApplicationServices/HostApplicationServices"; import { Factory } from "../../../CADFactory"; import { CADFiler } from "../../../CADFiler"; +import { PhysicalMaterialRecord } from "../../../PhysicalMaterialRecord"; import { RoomFlatBase } from "./RoomFlatBase"; @@ -24,4 +27,11 @@ export class RoomFlatFloor extends RoomFlatBase super.WriteFile(file); file.Write(1);//ver } + + protected get MeshMaterial() + { + if (this._MaterialId && this._MaterialId.Object) + return (this._MaterialId.Object).Material as MeshStandardMaterial; + return HostApplicationServices.DefaultFloorMaterial ?? HostApplicationServices.DefaultMeshMaterial; + } } diff --git a/src/DatabaseServices/Room/Entity/Flat/RoomFlatTop.ts b/src/DatabaseServices/Room/Entity/Flat/RoomFlatTop.ts index 989f00887..4c8686fa5 100644 --- a/src/DatabaseServices/Room/Entity/Flat/RoomFlatTop.ts +++ b/src/DatabaseServices/Room/Entity/Flat/RoomFlatTop.ts @@ -1,7 +1,9 @@ -import { Face3, Geometry, ShapeUtils, Vector3 } from "three"; +import { Face3, Geometry, MeshStandardMaterial, ShapeUtils, Vector3 } from "three"; +import { HostApplicationServices } from "../../../../ApplicationServices/HostApplicationServices"; import { arrayPushArray } from "../../../../Common/ArrayExt"; import { AsVector3 } from "../../../../Geometry/GeUtils"; import { Factory } from "../../../CADFactory"; +import { PhysicalMaterialRecord } from "../../../PhysicalMaterialRecord"; import { RoomFlatBase, UpdateTempPolyline } from "./RoomFlatBase"; @@ -60,4 +62,11 @@ export class RoomFlatTop extends RoomFlatBase { return false; } + + protected get MeshMaterial() + { + if (this._MaterialId && this._MaterialId.Object) + return (this._MaterialId.Object).Material as MeshStandardMaterial; + return HostApplicationServices.DefaultWallMaterial ?? HostApplicationServices.DefaultMeshMaterial; + } } diff --git a/src/DatabaseServices/Room/Entity/Wall/RoomWallBase.ts b/src/DatabaseServices/Room/Entity/Wall/RoomWallBase.ts index 2ea8f6405..aa86ff0b6 100644 --- a/src/DatabaseServices/Room/Entity/Wall/RoomWallBase.ts +++ b/src/DatabaseServices/Room/Entity/Wall/RoomWallBase.ts @@ -1,4 +1,5 @@ -import { Line as TLine, Mesh, Object3D } from "three"; +import { Line as TLine, Mesh, MeshStandardMaterial, Object3D } from "three"; +import { HostApplicationServices } from "../../../../ApplicationServices/HostApplicationServices"; import { ColorMaterial } from "../../../../Common/ColorPalette"; import { equaln } from "../../../../Geometry/GeUtils"; import { RenderType } from "../../../../GraphicsSystem/RenderType"; @@ -11,6 +12,7 @@ import { Curve } from "../../../Entity/Curve"; import { Line } from "../../../Entity/Line"; import { Polyline } from "../../../Entity/Polyline"; import { ObjectId } from "../../../ObjectId"; +import { PhysicalMaterialRecord } from "../../../PhysicalMaterialRecord"; import { RoomBase } from "../RoomBase"; import { RoomHolePolyline } from "./Hole/RoomHolePolyline"; import { WallSnapMode } from "./WallSnapMode"; @@ -108,6 +110,13 @@ export abstract class RoomWallBase extends RoomBase } } + protected get MeshMaterial() + { + if (this._MaterialId && this._MaterialId.Object) + return (this._MaterialId.Object).Material as MeshStandardMaterial; + return HostApplicationServices.DefaultWallMaterial ?? HostApplicationServices.DefaultMeshMaterial; + } + //绘制相关_end //为了支持F后正确的保持洞