diff --git a/index.html b/index.html index 025c4c6..91bfccd 100644 --- a/index.html +++ b/index.html @@ -329,8 +329,8 @@
- - + + @@ -519,7 +519,11 @@ let sku = "" const skuToFunc = async (currentText) => { sku = currentText; - placementWall(1); + if(currentText.includes("3m")){ + await placementWall(3); + }else{ + await placementWall(1); + } } @@ -814,8 +818,8 @@ }, { name: 'back', - startPoint: [1.37, baseY, 1.4], - endPoint: [-1.43, baseY, 1.4], + startPoint: [1.4, baseY, 1.4], + endPoint: [-1.43, baseY, 1.37], height: 2.2, divisions: divisions, offset: wallOffset @@ -852,7 +856,9 @@ // 监听放置区域点击事件 kernel.on('dropzone:click', async (dropzone_data) => { - const { position,rotation } = dropzone_data.transform; + console.log(dropzone_data); + + const { position, rotation } = dropzone_data.transform; // 将模型放置到该区域 try { @@ -866,11 +872,13 @@ // 使用 for...of 循环以支持 await for (const event of result.data.events) { if (event.event_type === 'change_model') { - const { 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); - - await kernel.model.replace({ - modelId: category, + console.log('替换百叶模型类型:', category); + await kernel.model.add({ + modelId: id+Date.now(), modelUrl: file_url, modelControlType: model_control_type, drag: { @@ -885,7 +893,7 @@ } }); - console.log(`百叶模型已替换为 ${currentText}`); + console.log(`百叶模型已替换为 ${name}`); } if (event.event_type === 'change_color') { diff --git a/src/babylonjs/AppRay.ts b/src/babylonjs/AppRay.ts index 6358180..a6db1e3 100644 --- a/src/babylonjs/AppRay.ts +++ b/src/babylonjs/AppRay.ts @@ -93,7 +93,7 @@ class AppRay extends Monobehiver { const clickedZone = zones.find(zone => zone.mesh === pickInfo.pickedMesh); if (clickedZone) { // 计算该放置区域的目标位置和旋转 - const offsetDistance = 0.1; + const offsetDistance = 0.05; // 增加偏移距离,让模型更往外 const targetPosition = clickedZone.center.add(clickedZone.normal.scale(offsetDistance)); const targetDirection = clickedZone.normal.scale(-1); const angle = Math.atan2(targetDirection.x, targetDirection.z);