1
This commit is contained in:
@ -181,44 +181,48 @@ const getEvent = async (dropzone_data, sku) => {
|
||||
|
||||
//点击放置区域执行事件 一般是换配件
|
||||
const executeEvent = async (dropzone_data, result, sku) => {
|
||||
const kernel = getKernel();
|
||||
const kernel = getKernel();
|
||||
|
||||
const { wallName, index, transform } = dropzone_data;
|
||||
const { position, rotation } = transform;
|
||||
|
||||
let modelId = null; // 在外部声明,用于在两个循环之间传递
|
||||
let modelName = null;
|
||||
let pergolaSku = null; // 用于存储棚子的 SKU
|
||||
|
||||
// 第一次循环:处理 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;
|
||||
|
||||
const { wallName, index, transform } = dropzone_data;
|
||||
const { position, rotation } = transform;
|
||||
|
||||
let modelId = null; // 在外部声明,用于在两个循环之间传递
|
||||
let modelName = null;
|
||||
let pergolaSku = null; // 用于存储棚子的 SKU
|
||||
|
||||
// 第一次循环:处理 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
|
||||
modelId = Date.now();
|
||||
modelName = name;
|
||||
kernel.dropZone.recordModelPlacement(wallName, index, name + '_' + modelId);
|
||||
|
||||
await kernel.model.add({
|
||||
modelName: name,
|
||||
modelId: modelId,
|
||||
modelUrl: file_url,
|
||||
modelControlType: model_control_type,
|
||||
drag: {
|
||||
enable: true,
|
||||
axis: rotation.y === 0 || rotation.y === 180 ? 'x' : 'z',
|
||||
step: 0.1,
|
||||
},
|
||||
transform: {
|
||||
position: position,
|
||||
rotation: rotation,
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`百叶模型已放置为 ${name + '_' + modelId}`);
|
||||
}
|
||||
}
|
||||
// 生成唯一的模型ID
|
||||
modelId = Date.now();
|
||||
modelName = name;
|
||||
kernel.dropZone.recordModelPlacement(wallName, index, name + '_' + modelId);
|
||||
|
||||
await kernel.model.add({
|
||||
modelName: name,
|
||||
modelId: modelId,
|
||||
modelUrl: file_url,
|
||||
modelControlType: model_control_type,
|
||||
drag: {
|
||||
enable: true,
|
||||
axis: rotation.y === 0 || rotation.y === 180 ? 'x' : 'z',
|
||||
step: 0.1,
|
||||
snapToZone: true, // 拖拽吸附到最近的分割区域
|
||||
returnWhenOutOfBounds: true, // 拖拽到区域外时返回原位置
|
||||
handleOccupiedZone: true, // 处理已占用区域(false=允许重叠)
|
||||
occupiedZoneAction: 'replace' // 当开关3=true时的行为:'return'=返回原位置,'replace'=替换
|
||||
},
|
||||
transform: {
|
||||
position: position,
|
||||
rotation: rotation,
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`百叶模型已放置为 ${name + '_' + modelId}`);
|
||||
}
|
||||
}
|
||||
|
||||
// 第二次循环:处理 change_color(此时模型已加载完成)
|
||||
for (const event of result.data.events) {
|
||||
@ -265,7 +269,7 @@ const isModelExists = (modelId) => {
|
||||
}
|
||||
|
||||
//一般是换棚子/换颜色/设置放置区域
|
||||
const executeEvent2 = async (result, sku) => {
|
||||
const executeEvent2 = async (result, sku) => {
|
||||
const kernel = getKernel();
|
||||
|
||||
// 检查是否有模型更换事件
|
||||
@ -418,8 +422,8 @@ const getProductConfig = async (sku) => {
|
||||
}
|
||||
|
||||
// API 配置
|
||||
const API_BASE_URL = 'https://ztserver.zguiy.com';
|
||||
|
||||
//const API_BASE_URL = 'https://ztserver.zguiy.com';
|
||||
const API_BASE_URL = 'http://localhost:26517';
|
||||
const getApiUrl = (path) => {
|
||||
return `${API_BASE_URL}${path}`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user