1
This commit is contained in:
@ -203,7 +203,7 @@ const isModelExists = (modelId) => {
|
||||
return kernel.model.exists(modelId);
|
||||
}
|
||||
|
||||
//一般是换棚子/换颜色/显示放置区域
|
||||
//一般是换棚子/换颜色/设置放置区域
|
||||
const executeEvent2 = async (result) => {
|
||||
const kernel = getKernel();
|
||||
|
||||
@ -215,18 +215,19 @@ const isModelExists = (modelId) => {
|
||||
if (hasModelChange) {
|
||||
const firstModelEvent = result.data.events.find(e => e.event_type === 'change_model');
|
||||
if (firstModelEvent && firstModelEvent.target_data) {
|
||||
const {name, category } = firstModelEvent.target_data;
|
||||
modelAlreadyExists = kernel.model.exists(name+'_'+category);
|
||||
console.log(`检查模型 ${name+'_'+category} 是否存在:`, modelAlreadyExists);
|
||||
const { name, category } = firstModelEvent.target_data;
|
||||
modelAlreadyExists = kernel.model.exists(name + '_' + category);
|
||||
console.log(`检查模型 ${name + '_' + category} 是否存在:`, modelAlreadyExists);
|
||||
}
|
||||
}
|
||||
|
||||
// 只有在需要更换模型且模型不存在时才清除
|
||||
if (hasModelChange && !modelAlreadyExists) {
|
||||
console.log('模型不存在,执行清除操作');
|
||||
kernel.dropZone.clearZones();
|
||||
|
||||
kernel.model.removeAll();
|
||||
} else if (modelAlreadyExists) {
|
||||
kernel.dropZone.hide();
|
||||
console.log('模型已存在,跳过清除操作,仅更新材质');
|
||||
}
|
||||
|
||||
@ -241,10 +242,9 @@ const isModelExists = (modelId) => {
|
||||
};
|
||||
|
||||
const { id, name, file_url, model_control_type, category, placement_zone } = target_data;
|
||||
|
||||
// 如果模型已存在,跳过加载
|
||||
if (modelAlreadyExists) {
|
||||
console.log(`模型 ${name+'_'+category} 已存在,跳过加载`);
|
||||
console.log(`模型 ${name + '_' + category} 已存在,跳过加载`);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -262,12 +262,13 @@ const isModelExists = (modelId) => {
|
||||
|
||||
// 加载并放置模型(使用 category 作为 modelId)
|
||||
await kernel.model.add({
|
||||
modelName: name,
|
||||
modelId: category,
|
||||
modelUrl: file_url,
|
||||
modelControlType: model_control_type,
|
||||
})
|
||||
|
||||
console.log(`模型已放置为 ${name}`);
|
||||
console.log(`模型已放置为 ${name + '_' + category}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -293,6 +294,7 @@ const isModelExists = (modelId) => {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//加载热点
|
||||
const getHotspot = async () => {
|
||||
const kernel = getKernel();
|
||||
|
||||
Reference in New Issue
Block a user