1
This commit is contained in:
@ -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('模型已移除');
|
||||||
// 关闭信息框
|
// 关闭信息框
|
||||||
|
|||||||
11
index.js
11
index.js
@ -120,7 +120,7 @@ export const getPlacementZone = async (sku) => {
|
|||||||
//执行事件
|
//执行事件
|
||||||
export const getEvent = async (dropzone_data, sku) => {
|
export const getEvent = async (dropzone_data, sku) => {
|
||||||
console.log(sku);
|
console.log(sku);
|
||||||
|
|
||||||
// 将模型放置到该区域
|
// 将模型放置到该区域
|
||||||
try {
|
try {
|
||||||
const response = await fetch(apiConfig.getApiUrl(`/api/product-configs/by-sku/${sku}`));
|
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) => {
|
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();
|
||||||
|
|||||||
Reference in New Issue
Block a user