新增相机限制
This commit is contained in:
22
index.js
22
index.js
@ -39,7 +39,7 @@ export const init = async (customConfig = {}) => {
|
||||
const defaultConfig = {
|
||||
container: document.querySelector('#renderDom'),
|
||||
modelUrlList: [],
|
||||
env: { envPath: 'https://sdk.zguiy.com/resurces/hdr/hdr.env', intensity: 1.2, rotationY: 0.3, background: true },
|
||||
env: { envPath: 'https://sdk.zguiy.com/resurces/hdr/hdr.env', intensity: 1.2, rotationY: 0.3, background: false },
|
||||
gizmo: {
|
||||
position: false,
|
||||
rotation: false,
|
||||
@ -123,7 +123,6 @@ export const getPlacementZone = async (sku) => {
|
||||
|
||||
//执行事件
|
||||
export const getEvent = async (dropzone_data, sku) => {
|
||||
console.log(sku);
|
||||
|
||||
// 将模型放置到该区域
|
||||
try {
|
||||
@ -153,6 +152,8 @@ export const executeEvent = async (dropzone_data, result, sku) => {
|
||||
|
||||
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') {
|
||||
@ -205,6 +206,20 @@ export const executeEvent = async (dropzone_data, result, sku) => {
|
||||
console.log(`百叶模型颜色已替换为 ${color}`);
|
||||
}
|
||||
}
|
||||
|
||||
// 查找棚子的 SKU(从已加载的模型中查找 model_control_type 为 'pergola' 的模型)
|
||||
const allModels = kernel.model.getAllMetadata();
|
||||
for (const model of allModels) {
|
||||
if (model.modelControlType === 'pergola') {
|
||||
pergolaSku = getSkuByModelId(model.modelId);
|
||||
if (pergolaSku) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('当前棚子的 SKU:', pergolaSku);
|
||||
return pergolaSku;
|
||||
}
|
||||
|
||||
|
||||
@ -225,7 +240,6 @@ export const executeEvent2 = async (result, sku) => {
|
||||
console.log(`检查模型 ${name + '_' + category} 是否存在:`, modelAlreadyExists);
|
||||
}
|
||||
}
|
||||
console.log(hasModelChange && !modelAlreadyExists);
|
||||
kernel.dropZone.hide();
|
||||
// 只有在需要更换模型且模型不存在时才清除
|
||||
if (hasModelChange && !modelAlreadyExists) {
|
||||
@ -238,6 +252,8 @@ console.log(hasModelChange && !modelAlreadyExists);
|
||||
|
||||
// 先处理所有 change_model 事件
|
||||
for (const event of result.data.events) {
|
||||
console.log(event);
|
||||
|
||||
if (event.event_type === 'change_model') {
|
||||
const { target_data } = event;
|
||||
console.log(event.target_data);
|
||||
|
||||
Reference in New Issue
Block a user