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

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