!266 优化纹理,优化绘制Text

Merge pull request !266 from ZoeLeeFZ/fixUiBug
pull/266/MERGE
ZoeLeeFZ 6 years ago committed by ChenX
parent f75cfd178b
commit d7a5cded42

@ -175,7 +175,8 @@ export class TextArea extends Singleton
f.LoadGlyphs(el.innerText);
await f.AwaitLoaded();
let text = new Text(pos, el.innerText, f.FontName, this.m_TextHeight, this.m_TextRotation);
let text = new Text(new Vector3(), el.innerText, f.FontName, this.m_TextHeight, this.m_TextRotation);
text.ApplyMatrix(app.m_Editor.UCSMatrix.setPosition(pos));
app.m_Database.ModelSpace.Append(text);
this.m_AreaContiner.removeChild(el);
el = null;

@ -43,6 +43,7 @@ export default class TextureContent extends React.Component<ITextureContentProps
if (v instanceof TextureTableRecord)
return (
<Card
style={{ width: 100 }}
>
<div
className="img-select-hint"
@ -59,8 +60,11 @@ export default class TextureContent extends React.Component<ITextureContentProps
}}
/>
</div>
<div>
<span>{option.name}</span>
<div style={{
overflow: "hidden",
textOverflow: "ellipsis"
}}>
<span style={{ whiteSpace: "nowrap" }}>{option.name === "" ? "默认贴图" : option.name}</span>
</div>
<div>
<Popover

@ -2,7 +2,6 @@ import { Button, Intent, Label } from "@blueprintjs/core";
import { inject, observer } from "mobx-react";
import * as React from "react";
import { ClampToEdgeWrapping, MirroredRepeatWrapping, RepeatWrapping } from "three";
import { app } from "../../ApplicationServices/Application";
import { TextureTableRecord } from "../../DatabaseServices/Texture";
import { MaterialStore } from "../Store/MaterialStore";
import { TextureStore } from "../Store/TextureStore";
@ -45,7 +44,6 @@ export class Texture extends React.Component<ITextureProps, {}>{
db.TextureTable.Add(newTexture);
textureStore.textureId = newTexture.Id;
store.BindTextureId(newTexture.Id);
}
store.currentTextureTable = textureStore.textureId.Object as TextureTableRecord;
}
@ -82,7 +80,6 @@ export class Texture extends React.Component<ITextureProps, {}>{
height: 140,
transform: `rotateZ(${textureStore.rotation}deg)`
}}
/>
</div>
<div style={{ flexBasis: 0, flexGrow: 1 }}>

@ -97,11 +97,23 @@ export class MaterialStore extends Singleton
this.InitTextureStore();
this.StartObserve();
}
BindTextureId(objctId: ObjectId)
BindTextureId(texture: TextureTableRecord)
{
this.textureMaping.textureId = this.textureMaping.textureId || objctId;
this.bumpMaping.textureId = this.bumpMaping.textureId || objctId;
this.roughnessMaping.textureId = this.roughnessMaping.textureId || objctId;
const bindTexture = (store: TextureStore) =>
{
if (!store.textureId)
{
let newTexture = texture.Clone() as TextureTableRecord;
let db = this.Material.Db;
newTexture.Name = db.TextureTable.AllocateName();
db.TextureTable.Add(newTexture);
store.textureId = newTexture.Id;
}
}
bindTexture(this.textureMaping);
bindTexture(this.bumpMaping);
bindTexture(this.roughnessMaping);
this.Material.map = this.textureMaping.textureId;
this.Material.bumpMap = this.bumpMaping.textureId;
@ -195,7 +207,7 @@ export class MaterialStore extends Singleton
db.TextureTable.Add(textureClone);
}
this.currentEditorStore.InitStore(textureClone);
this.BindTextureId(textureClone.Id);
this.BindTextureId(textureClone);
this.UpdateMaterial();
}
async ChangeTextureImg(pic: { path: string; })
@ -203,6 +215,7 @@ export class MaterialStore extends Singleton
this.isOpenImgList = false;
this.currentTextureTable.imageUrl = pic.path;
await this.currentTextureTable.Update();
this.BindTextureId(this.currentTextureTable);
this.UpdateMaterial();
}
}

Loading…
Cancel
Save