功能:在预览绘制时使用户型默认材质

pull/2051/head
ChenX 2 years ago
parent d336b58087
commit d707ef0a9b

@ -8,6 +8,9 @@ import { DrillingOption } from '../UI/Store/drillInterface';
export class IHostApplicationServices export class IHostApplicationServices
{ {
DefaultMeshMaterial?: MeshBasicMaterial | MeshStandardMaterial; DefaultMeshMaterial?: MeshBasicMaterial | MeshStandardMaterial;
DefaultFloorMaterial?: MeshBasicMaterial | MeshStandardMaterial;
DefaultWallMaterial?: MeshBasicMaterial | MeshStandardMaterial;
CurrentDimStyle: ObjectId; CurrentDimStyle: ObjectId;
@ProxyValue isShowLightShadow: boolean = true;//灯光阴影 (除太阳光外) @ProxyValue isShowLightShadow: boolean = true;//灯光阴影 (除太阳光外)
ShowHistoryLog: boolean = true; ShowHistoryLog: boolean = true;

@ -63,7 +63,7 @@ export class Database
private idIndex = 1; private idIndex = 1;
private idMap = new Map<number, ObjectId>(); private idMap = new Map<number, ObjectId>();
constructor(buildDefaultDrawing = false, private defaultDatabase = false, disableHistoric = false) constructor(buildDefaultDrawing = false, public IsDefaultDatabase = false, disableHistoric = false)
{ {
this.ModelSpace = new BlockTableRecord().SetOwnerDatabase(this); this.ModelSpace = new BlockTableRecord().SetOwnerDatabase(this);
this.MaterialTable = new MaterialTable().SetOwnerDatabase(this); this.MaterialTable = new MaterialTable().SetOwnerDatabase(this);
@ -143,7 +143,7 @@ export class Database
SettingDefaultStyleAndMaterial() SettingDefaultStyleAndMaterial()
{ {
if (!this.defaultDatabase) if (!this.IsDefaultDatabase)
return; return;
this.DefaultMaterial = this.GetObjectId(71)?.Object as PhysicalMaterialRecord ?? this.DefaultMaterial; this.DefaultMaterial = this.GetObjectId(71)?.Object as PhysicalMaterialRecord ?? this.DefaultMaterial;

@ -1,3 +1,4 @@
import { HostApplicationServices } from "../ApplicationServices/HostApplicationServices";
import { CADFiler } from "./CADFiler"; import { CADFiler } from "./CADFiler";
import { ObjectId } from "./ObjectId"; import { ObjectId } from "./ObjectId";
import { PhysicalMaterialRecord } from "./PhysicalMaterialRecord"; import { PhysicalMaterialRecord } from "./PhysicalMaterialRecord";
@ -17,6 +18,9 @@ export class MaterialTable extends SymbolTable
if (id === this._CurFloorMtl) return; if (id === this._CurFloorMtl) return;
this.WriteAllObjectRecord(); this.WriteAllObjectRecord();
this._CurFloorMtl = id; this._CurFloorMtl = id;
if (this._db && this._db.IsDefaultDatabase)
HostApplicationServices.DefaultFloorMaterial = (id.Object as PhysicalMaterialRecord).Material;
} }
set CurWallMtl(id) set CurWallMtl(id)
@ -24,6 +28,9 @@ export class MaterialTable extends SymbolTable
if (id === this._CurWallMtl) return; if (id === this._CurWallMtl) return;
this.WriteAllObjectRecord(); this.WriteAllObjectRecord();
this._CurWallMtl = id; this._CurWallMtl = id;
if (this._db && this._db.IsDefaultDatabase)
HostApplicationServices.DefaultWallMaterial = (id.Object as PhysicalMaterialRecord).Material;
} }
get Materials() get Materials()

@ -1,5 +1,8 @@
import { MeshStandardMaterial } from "three";
import { HostApplicationServices } from "../../../../ApplicationServices/HostApplicationServices";
import { Factory } from "../../../CADFactory"; import { Factory } from "../../../CADFactory";
import { CADFiler } from "../../../CADFiler"; import { CADFiler } from "../../../CADFiler";
import { PhysicalMaterialRecord } from "../../../PhysicalMaterialRecord";
import { RoomFlatBase } from "./RoomFlatBase"; import { RoomFlatBase } from "./RoomFlatBase";
@ -24,4 +27,11 @@ export class RoomFlatFloor extends RoomFlatBase
super.WriteFile(file); super.WriteFile(file);
file.Write(1);//ver file.Write(1);//ver
} }
protected get MeshMaterial()
{
if (this._MaterialId && this._MaterialId.Object)
return (<PhysicalMaterialRecord>this._MaterialId.Object).Material as MeshStandardMaterial;
return HostApplicationServices.DefaultFloorMaterial ?? HostApplicationServices.DefaultMeshMaterial;
}
} }

@ -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 { arrayPushArray } from "../../../../Common/ArrayExt";
import { AsVector3 } from "../../../../Geometry/GeUtils"; import { AsVector3 } from "../../../../Geometry/GeUtils";
import { Factory } from "../../../CADFactory"; import { Factory } from "../../../CADFactory";
import { PhysicalMaterialRecord } from "../../../PhysicalMaterialRecord";
import { RoomFlatBase, UpdateTempPolyline } from "./RoomFlatBase"; import { RoomFlatBase, UpdateTempPolyline } from "./RoomFlatBase";
@ -60,4 +62,11 @@ export class RoomFlatTop extends RoomFlatBase
{ {
return false; return false;
} }
protected get MeshMaterial()
{
if (this._MaterialId && this._MaterialId.Object)
return (<PhysicalMaterialRecord>this._MaterialId.Object).Material as MeshStandardMaterial;
return HostApplicationServices.DefaultWallMaterial ?? HostApplicationServices.DefaultMeshMaterial;
}
} }

@ -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 { ColorMaterial } from "../../../../Common/ColorPalette";
import { equaln } from "../../../../Geometry/GeUtils"; import { equaln } from "../../../../Geometry/GeUtils";
import { RenderType } from "../../../../GraphicsSystem/RenderType"; import { RenderType } from "../../../../GraphicsSystem/RenderType";
@ -11,6 +12,7 @@ import { Curve } from "../../../Entity/Curve";
import { Line } from "../../../Entity/Line"; import { Line } from "../../../Entity/Line";
import { Polyline } from "../../../Entity/Polyline"; import { Polyline } from "../../../Entity/Polyline";
import { ObjectId } from "../../../ObjectId"; import { ObjectId } from "../../../ObjectId";
import { PhysicalMaterialRecord } from "../../../PhysicalMaterialRecord";
import { RoomBase } from "../RoomBase"; import { RoomBase } from "../RoomBase";
import { RoomHolePolyline } from "./Hole/RoomHolePolyline"; import { RoomHolePolyline } from "./Hole/RoomHolePolyline";
import { WallSnapMode } from "./WallSnapMode"; import { WallSnapMode } from "./WallSnapMode";
@ -108,6 +110,13 @@ export abstract class RoomWallBase extends RoomBase
} }
} }
protected get MeshMaterial()
{
if (this._MaterialId && this._MaterialId.Object)
return (<PhysicalMaterialRecord>this._MaterialId.Object).Material as MeshStandardMaterial;
return HostApplicationServices.DefaultWallMaterial ?? HostApplicationServices.DefaultMeshMaterial;
}
//绘制相关_end //绘制相关_end
//为了支持F后正确的保持洞 //为了支持F后正确的保持洞

Loading…
Cancel
Save