!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); f.LoadGlyphs(el.innerText);
await f.AwaitLoaded(); 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); app.m_Database.ModelSpace.Append(text);
this.m_AreaContiner.removeChild(el); this.m_AreaContiner.removeChild(el);
el = null; el = null;

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

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

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

Loading…
Cancel
Save