This commit is contained in:
2026-05-18 18:53:30 +08:00
parent fb193c0528
commit 840e3d6a55
12 changed files with 907 additions and 68 deletions

View File

@ -203,8 +203,8 @@ const isModelExists = (modelId) => {
return kernel.model.exists(modelId);
}
//换棚子
const executeEvent2 = async (result) => {
//一般是换棚子/换颜色/显示放置区域
const executeEvent2 = async (result) => {
const kernel = getKernel();
// 检查是否有模型更换事件
@ -214,10 +214,10 @@ const executeEvent2 = async (result) => {
let modelAlreadyExists = false;
if (hasModelChange) {
const firstModelEvent = result.data.events.find(e => e.event_type === 'change_model');
if (firstModelEvent) {
const { category } = firstModelEvent.target_data;
modelAlreadyExists = isModelExists(category);
console.log(`检查模型 ${category} 是否存在:`, modelAlreadyExists);
if (firstModelEvent && firstModelEvent.target_data) {
const {name, category } = firstModelEvent.target_data;
modelAlreadyExists = kernel.model.exists(name+'_'+category);
console.log(`检查模型 ${name+'_'+category} 是否存在:`, modelAlreadyExists);
}
}
@ -241,12 +241,10 @@ const executeEvent2 = async (result) => {
};
const { id, name, file_url, model_control_type, category, placement_zone } = target_data;
console.log('替换百叶模型:', event);
console.log('替换百叶模型类型:', category);
// 如果模型已存在,跳过加载
if (modelAlreadyExists) {
console.log(`模型 ${category} 已存在,跳过加载`);
console.log(`模型 ${name+'_'+category} 已存在,跳过加载`);
continue;
}
@ -269,7 +267,7 @@ const executeEvent2 = async (result) => {
modelControlType: model_control_type,
})
console.log(`百叶模型已放置为 ${name}`);
console.log(`模型已放置为 ${name}`);
}
}