修复材质导入问题
This commit is contained in:
@@ -11,6 +11,7 @@ import { GetConfig } from "../lib/libOutputConfig";
|
||||
const sceneSetup = () => {
|
||||
let _editor: MaterialEditor | undefined;
|
||||
let _database: Database | undefined;
|
||||
const _material = ref<PhysicalMaterialRecord>(new PhysicalMaterialRecord());
|
||||
const _currGeometry = ref<string>('球');
|
||||
const _currTexture = ref<Texture>();
|
||||
const CurrGeometry = computed({
|
||||
@@ -19,7 +20,7 @@ const sceneSetup = () => {
|
||||
})
|
||||
const CurrTexture = computed<Texture>(() => _currTexture.value);
|
||||
const Geometries = ref<string[]>([]);
|
||||
const Material = ref<PhysicalMaterialRecord>(new PhysicalMaterialRecord());
|
||||
const Material = computed(() => _material.value);
|
||||
const CurrentShowObject = computed(() => _editor.ShowObject);
|
||||
|
||||
function Initial(canvas: HTMLElement) {
|
||||
@@ -74,15 +75,15 @@ const sceneSetup = () => {
|
||||
}
|
||||
|
||||
async function UpdateMaterialAsync() {
|
||||
console.log('UpdateMaterialAsync')
|
||||
await Material.value.Update();
|
||||
console.log(Material.value.Update);
|
||||
// TODO: Danger: 如果等待下面这一行,会导致更新卡住(未知问题)
|
||||
Material.value.Update();
|
||||
// Material.value.Material.needsUpdate = true;
|
||||
await _editor.Update();
|
||||
Update();
|
||||
}
|
||||
|
||||
async function ChangeTextureFromUrlAsync(url?: string) {
|
||||
|
||||
console.log('ChangeTextureFromUrlAsync')
|
||||
// 关联贴图
|
||||
const db = Material.value.Db;
|
||||
if (!db) return; // 材质未初始化
|
||||
@@ -123,9 +124,10 @@ const sceneSetup = () => {
|
||||
|
||||
async function ImportMaterialAsync(materialJson: string) {
|
||||
const material = MaterialIn(JSON.parse(materialJson));
|
||||
Material.value = material;
|
||||
_editor.setMaterial(material);
|
||||
_material.value = material;
|
||||
_editor.setMaterial(_material.value as PhysicalMaterialRecord);
|
||||
await ChangeTextureFromUrlAsync();
|
||||
await UpdateMaterialAsync();
|
||||
}
|
||||
|
||||
async function GenerateMaterialLogoAsync() {
|
||||
@@ -158,7 +160,8 @@ const sceneSetup = () => {
|
||||
ImportMaterialAsync,
|
||||
GenerateMaterialLogoAsync,
|
||||
Dispose,
|
||||
CurrentShowObject
|
||||
CurrentShowObject,
|
||||
GetEditor: () => _editor
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user