|
|
@ -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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|