This commit is contained in:
2026-05-19 14:41:03 +08:00
parent 8a427d3557
commit 50b8ea355b
2 changed files with 12 additions and 5 deletions

View File

@ -338,8 +338,9 @@
<button class="option-btn" data-option="louver-3">3m下拉帘</button> <button class="option-btn" data-option="louver-3">3m下拉帘</button>
<button class="option-btn" data-option="louver-4">SPFSW13FTW</button> <button class="option-btn" data-option="louver-4">SPFSW13FTW</button>
<button class="option-btn" data-option="louver-4">SPFSW10FTW</button> <button class="option-btn" data-option="louver-4">SPFSW10FTW</button>
<button class="option-btn" data-option="louver-4">SPFSW10FTC</button> <button class="option-btn" data-option="louver-4">SPFPDS10FTC</button>
<button class="option-btn" data-option="louver-4">SPFPDS10FTW</button> <button class="option-btn" data-option="louver-4">SPFPDS10FTW</button>
</div> </div>
</div> </div>
</div> </div>
@ -750,7 +751,8 @@
const pickedMesh = window.getCurrentPickedMesh(); const pickedMesh = window.getCurrentPickedMesh();
if (pickedMesh) { if (pickedMesh) {
const meshName = pickedMesh.name; const meshName = pickedMesh.name;
const success = kernel.model.remove(meshName); const modelName = kernel.model.findModelNameByMesh(pickedMesh);
const success = kernel.model.removeByName(modelName);
if (success) { if (success) {
console.log('模型已移除'); console.log('模型已移除');
// 关闭信息框 // 关闭信息框

View File

@ -140,6 +140,7 @@ export const getEvent = async (dropzone_data, sku) => {
} }
} }
//点击放置区域执行事件 一般是换配件
//点击放置区域执行事件 一般是换配件 //点击放置区域执行事件 一般是换配件
export const executeEvent = async (dropzone_data, result) => { export const executeEvent = async (dropzone_data, result) => {
const kernel = getKernel(); const kernel = getKernel();
@ -147,14 +148,16 @@ export const executeEvent = async (dropzone_data, result) => {
const { wallName, index, transform } = dropzone_data; const { wallName, index, transform } = dropzone_data;
const { position, rotation } = transform; const { position, rotation } = transform;
let modelId = null; // 在外部声明,用于在两个循环之间传递
let modelName = null;
// 第一次循环:处理 change_model // 第一次循环:处理 change_model
for (const event of result.data.events) { for (const event of result.data.events) {
if (event.event_type === 'change_model') { if (event.event_type === 'change_model') {
const { name, file_url, model_control_type, category } = event.target_data; const { name, file_url, model_control_type, category } = event.target_data;
// 生成唯一的模型ID // 生成唯一的模型ID
const modelId = Date.now(); modelId = Date.now();
modelName = name;
kernel.dropZone.recordModelPlacement(wallName, index, name + '_' + modelId); kernel.dropZone.recordModelPlacement(wallName, index, name + '_' + modelId);
await kernel.model.add({ await kernel.model.add({
@ -185,6 +188,7 @@ export const executeEvent = async (dropzone_data, result) => {
kernel.material.apply({ kernel.material.apply({
target: materialName, target: materialName,
modelId: modelName + '_' + modelId, // 传入 modelId只替换该模型的材质
albedoColor: color, albedoColor: color,
albedoTexture: color_map_url, albedoTexture: color_map_url,
normalMap: normal_map_url, normalMap: normal_map_url,
@ -197,6 +201,7 @@ export const executeEvent = async (dropzone_data, result) => {
} }
} }
//一般是换棚子/换颜色/设置放置区域 //一般是换棚子/换颜色/设置放置区域
export const executeEvent2 = async (result) => { export const executeEvent2 = async (result) => {
const kernel = getKernel(); const kernel = getKernel();