|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
import { ContextMenu, Menu, MenuItem } from '@blueprintjs/core';
|
|
|
|
|
import { ContextMenu, Icon, Menu, MenuItem } from '@blueprintjs/core';
|
|
|
|
|
import { observable } from 'mobx';
|
|
|
|
|
import { observer } from 'mobx-react';
|
|
|
|
|
import React, { CSSProperties, DragEvent } from 'react';
|
|
|
|
|
import { end } from 'xaop';
|
|
|
|
@ -8,6 +9,7 @@ import { ImgsUrl, MaterialUrls } from '../../Common/HostUrl';
|
|
|
|
|
import { IsMeshMaterialEntity } from '../../Common/IsMeshMaterialEntity';
|
|
|
|
|
import { Post, PostJson, RequestStatus } from '../../Common/Request';
|
|
|
|
|
import { MaterialOut, deflate } from '../../Common/SerializeMaterial';
|
|
|
|
|
import { Sleep } from '../../Common/Sleep';
|
|
|
|
|
import { Intent } from '../../Common/Toaster';
|
|
|
|
|
import { Hole } from '../../DatabaseServices/3DSolid/Hole';
|
|
|
|
|
import { Board } from '../../DatabaseServices/Entity/Board';
|
|
|
|
@ -26,6 +28,7 @@ import { ICON_CDN, IconEnum } from '../IconEnum';
|
|
|
|
|
import { appUi } from '../Layout/ApplicationLayout';
|
|
|
|
|
import { ApplyGoodInfo } from './ApplyGoodInfo';
|
|
|
|
|
import { AppConfirm } from './Common/Confirm';
|
|
|
|
|
import { EDITMATERIAL, MATERIALLOCK } from './MaterialExplorer';
|
|
|
|
|
import { AppToaster } from './Toaster';
|
|
|
|
|
|
|
|
|
|
//蓝图.
|
|
|
|
@ -39,6 +42,7 @@ const RootStyle: CSSProperties = {
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
paddingTop: "10px",
|
|
|
|
|
position: "relative",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//材质球上方的图片预览
|
|
|
|
@ -60,6 +64,7 @@ const TextStyle: CSSProperties = {
|
|
|
|
|
textOverflow: "ellipsis",
|
|
|
|
|
whiteSpace: "nowrap",
|
|
|
|
|
height: "20px",
|
|
|
|
|
padding: "0 10px",
|
|
|
|
|
width: "100%",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -84,6 +89,7 @@ export enum CurDefMtlType
|
|
|
|
|
@observer
|
|
|
|
|
export class Asset extends React.Component<AssetProps, {}>
|
|
|
|
|
{
|
|
|
|
|
@observable isLock = this.props.material.objectId.Object.IsMaterialLock;
|
|
|
|
|
_Image = React.createRef<HTMLImageElement>();
|
|
|
|
|
_DivColorRef = React.createRef<HTMLDivElement>();
|
|
|
|
|
_CurWallMtlIconMarginBottom: number = 2;
|
|
|
|
@ -96,7 +102,11 @@ export class Asset extends React.Component<AssetProps, {}>
|
|
|
|
|
|
|
|
|
|
componentDidMount()
|
|
|
|
|
{
|
|
|
|
|
this._RemoveCall.push(end(this.props.material, this.props.material.Update, () => { this._UpdateRenderPreview(); }));
|
|
|
|
|
this._RemoveCall.push(end(this.props.material, this.props.material.Update, () =>
|
|
|
|
|
{
|
|
|
|
|
this._UpdateRenderPreview();
|
|
|
|
|
this.isLock = this.props.material.IsMaterialLock;
|
|
|
|
|
}));
|
|
|
|
|
this._UpdateRenderPreview();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -105,6 +115,14 @@ export class Asset extends React.Component<AssetProps, {}>
|
|
|
|
|
this._Destroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateTexture = (texture: TextureTableRecord) =>
|
|
|
|
|
{
|
|
|
|
|
if (this.props.material.map?.Object === texture)
|
|
|
|
|
{
|
|
|
|
|
this._UpdateRenderPreview();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 更新渲染材质球预览图
|
|
|
|
|
*/
|
|
|
|
@ -112,11 +130,11 @@ export class Asset extends React.Component<AssetProps, {}>
|
|
|
|
|
{
|
|
|
|
|
if (this._RenderIng) return;
|
|
|
|
|
this._RenderIng = true;
|
|
|
|
|
|
|
|
|
|
await Sleep(20); //减少更新频率
|
|
|
|
|
let material = this.props.material;
|
|
|
|
|
if (material.useMap && material.map && material.map.Object)
|
|
|
|
|
await (material.map.Object as TextureTableRecord).Update();
|
|
|
|
|
await material.Update();
|
|
|
|
|
await (material.map.Object as TextureTableRecord).TextureUpdate();
|
|
|
|
|
await material.PhysicalMaterialUpdate();
|
|
|
|
|
|
|
|
|
|
let imgUrl = MaterialRendererSingle().render(material.Material);
|
|
|
|
|
|
|
|
|
@ -133,7 +151,7 @@ export class Asset extends React.Component<AssetProps, {}>
|
|
|
|
|
|
|
|
|
|
if (this._DivColorRef.current)
|
|
|
|
|
{
|
|
|
|
|
if (!material.map)
|
|
|
|
|
if (!(material.useMap && material.map))
|
|
|
|
|
this._DivColorRef.current.style.border = "1px solid black";
|
|
|
|
|
else
|
|
|
|
|
this._DivColorRef.current.style.border = "none";
|
|
|
|
@ -154,7 +172,7 @@ export class Asset extends React.Component<AssetProps, {}>
|
|
|
|
|
_HandleDoubleClick = async () =>
|
|
|
|
|
{
|
|
|
|
|
await app.Editor.ModalManage.EndExecingCmd();
|
|
|
|
|
if (!commandMachine.CommandStart("编辑材质"))
|
|
|
|
|
if (!commandMachine.CommandStart(EDITMATERIAL))
|
|
|
|
|
{
|
|
|
|
|
AppToaster.show({
|
|
|
|
|
message: "命令正在执行中,无法开始编辑材质!",
|
|
|
|
@ -190,10 +208,13 @@ export class Asset extends React.Component<AssetProps, {}>
|
|
|
|
|
en.OverWriteMaterial.set(num, material.Id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
en.Material = material.Id;
|
|
|
|
|
|
|
|
|
|
if (en instanceof BulkheadCeiling)
|
|
|
|
|
{
|
|
|
|
|
en.Material = material.Id;
|
|
|
|
|
en.SetDefaultMaterialAtAllSlot();
|
|
|
|
|
}
|
|
|
|
|
else if (IsMeshMaterialEntity(en))
|
|
|
|
|
en.SetAllMaterialAtSlot(material.Id);
|
|
|
|
|
|
|
|
|
|
if (en instanceof Board)
|
|
|
|
|
{
|
|
|
|
@ -420,6 +441,7 @@ export class Asset extends React.Component<AssetProps, {}>
|
|
|
|
|
|
|
|
|
|
render()
|
|
|
|
|
{
|
|
|
|
|
const { material } = this.props;
|
|
|
|
|
//样式
|
|
|
|
|
let style: React.CSSProperties = { ...RootStyle };
|
|
|
|
|
if (!userConfig.isLargeIcon)//大图标
|
|
|
|
@ -502,6 +524,21 @@ export class Asset extends React.Component<AssetProps, {}>
|
|
|
|
|
>
|
|
|
|
|
<span>{this.props.material.Name}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
className={this.isLock ? 'material-lock' : 'material-unlock'}
|
|
|
|
|
onClick={(e) =>
|
|
|
|
|
{
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
this.isLock = !this.isLock;
|
|
|
|
|
CommandWrap(() =>
|
|
|
|
|
{
|
|
|
|
|
material.objectId.Object.IsMaterialLock = !material.objectId.Object.IsMaterialLock;
|
|
|
|
|
}, MATERIALLOCK);
|
|
|
|
|
}}
|
|
|
|
|
onDoubleClick={(e) => { e.stopPropagation(); }}
|
|
|
|
|
>
|
|
|
|
|
<Icon size={12} icon={this.isLock ? "lock" : "unlock"}></Icon>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|