可以替换模型

This commit is contained in:
2026-05-13 16:27:16 +08:00
parent fea24ad19a
commit 8f833be426
5 changed files with 113 additions and 10 deletions

View File

@ -856,9 +856,10 @@
// 监听放置区域点击事件
kernel.on('dropzone:click', async (dropzone_data) => {
console.log(dropzone_data);
console.log('点击了放置区域:', dropzone_data);
const { position, rotation } = dropzone_data.transform;
const { wallName, index, transform } = dropzone_data;
const { position, rotation } = transform;
// 将模型放置到该区域
try {
@ -872,28 +873,35 @@
// 使用 for...of 循环以支持 await
for (const event of result.data.events) {
if (event.event_type === 'change_model') {
console.log( event.target_data);
const {id, name,file_url, model_control_type, category } = event.target_data;
console.log(event.target_data);
const {id, name, file_url, model_control_type, category } = event.target_data;
console.log('替换百叶模型:', event);
console.log('替换百叶模型类型:', category);
// 生成唯一的模型ID
const modelId = id + '_' + Date.now();
// 先记录模型放置(会自动处理替换逻辑)
kernel.dropZone.recordModelPlacement(wallName, index, modelId);
// 加载并放置模型
await kernel.model.add({
modelId: id+Date.now(),
modelId: modelId,
modelUrl: file_url,
modelControlType: model_control_type,
drag: {
enable: true,
axis: 'x',
step: 0.1,
}
,
},
transform: {
position: position,
rotation: rotation,
}
});
console.log(`百叶模型已替换${name}`);
console.log(`百叶模型已放置${name}`);
}
if (event.event_type === 'change_color') {