变更:在修改材质时,同步发送材质修改信息

pull/1607/MERGE
ChenX 3 years ago
parent 471a1975b2
commit 994b7d3eda

@ -106,7 +106,7 @@ export class Command_ExportData implements Command
}
}
type Data = {
export type Data = {
Entitys: any[];
Materials: Object[];
Url?: string;
@ -152,7 +152,7 @@ export function Entitys2Data(ents: Entity[]): Data
if (id.Object)
{
let mtl = id.Object as PhysicalMaterialRecord;
d.Materials.push(ConverMaterial(mtl));
d.Materials.push(ConverMaterialData(mtl));
}
}
}
@ -264,7 +264,7 @@ function ConverShape2Data(e: Shape)
return d;
}
function ConverMaterial(material: PhysicalMaterialRecord)
export function ConverMaterialData(material: PhysicalMaterialRecord)
{
let d: any = { };
d.Id = material.Id?.Index ?? 0;

@ -1,10 +1,10 @@
import { Color, MeshPhysicalMaterial } from "three";
import { AutoRecord } from "./AutoRecord";
import { Factory } from "./CADFactory";
import { CADFiler } from "./CADFiler";
import { MaterialTableRecord } from "./MaterialTableRecord";
import { ObjectId } from "./ObjectId";
import { TextureTableRecord } from "./Texture";
import { AutoRecord } from "./AutoRecord";
export interface IGoodProps
@ -22,7 +22,7 @@ export class PhysicalMaterialRecord extends MaterialTableRecord
matalness: number = 0;//金属性 0-1
opacity: number = 1;//不透明度.
depthTest: boolean = true;//深度测试
map: ObjectId;//纹理贴图
@AutoRecord map: ObjectId;//纹理贴图
bumpMap: ObjectId;//凹凸贴图
bumpScale: number = 0.1;//凹凸比例
roughnessMap: ObjectId;//粗糙贴图
@ -36,7 +36,7 @@ export class PhysicalMaterialRecord extends MaterialTableRecord
material: "",
};
//@ts-ignore
private material = new MeshPhysicalMaterial({});
private material = new MeshPhysicalMaterial({ });
@AutoRecord IsFull = false;
async Update()
{

@ -1,5 +1,5 @@
import { end } from "xaop";
import { Entitys2Data } from "../Add-on/ExportData";
import { Data, Entitys2Data } from "../Add-on/ExportData";
import { ApplicationService } from "../ApplicationServices/Application";
import { Hole } from "../DatabaseServices/3DSolid/Hole";
import { CADObject } from "../DatabaseServices/CADObject";
@ -8,11 +8,11 @@ import { CreateObjectData } from "../DatabaseServices/CreateObjectData";
import { Entity } from "../DatabaseServices/Entity/Entity";
import { RemoveObjectData } from "../DatabaseServices/RemoveObjectData";
interface IncrementData
export interface IncrementData
{
Add: Object;
Change: Object;
Delete: Object;
Add: Data;
Change: Data;
Delete: Data;
}
function IsSyncEntity(ent: CADObject): boolean

@ -1,15 +1,17 @@
import { Intent } from "@blueprintjs/core";
import { action, autorun, observable, toJS } from "mobx";
import { end } from "xaop";
import { ConverMaterialData } from "../../Add-on/ExportData";
import { app } from "../../ApplicationServices/Application";
import { Singleton } from "../../Common/Singleton";
import { UpdateDraw } from "../../Common/Status";
import { IGoodProps, PhysicalMaterialRecord } from "../../DatabaseServices/PhysicalMaterialRecord";
import { TextureTableRecord } from "../../DatabaseServices/Texture";
import { MaterialEditor } from "../../Editor/MaterialEditor";
import { IncrementData } from "../../Reactor/SyncDataReactor";
import { IDirectoryProps } from "../Components/SourceManage/CommonPanel";
import { AppToaster } from "../Components/Toaster";
import { TextureStore } from "./TextureStore";
import { UpdateDraw } from "../../Common/Status";
let oldFullStatus = false;
@ -133,6 +135,13 @@ export class MaterialStore extends Singleton
this.Material.map = this.textureMaping.textureId;
this.Material.bumpMap = this.bumpMaping.textureId;
this.Material.roughnessMap = this.roughnessMaping.textureId;
//同步到效果图
if (app.SyncDataReactor.Enable)
{
let d: IncrementData = { Add: { Entitys: [], Materials: [] }, Change: { Entitys: [], Materials: [ConverMaterialData(this.Material)] }, Delete: { Entitys: [], Materials: [] } };
app.WebSocket.Send(JSON.stringify(d));
}
}
UpdateMaterial = async () =>
{

Loading…
Cancel
Save