1
This commit is contained in:
136
index.html
136
index.html
@ -355,7 +355,7 @@
|
||||
</div>
|
||||
|
||||
<button id="hotspot-btn">生成热点</button>
|
||||
<button id="prevent-btn">生成防止区域</button>
|
||||
<button id="prevent-btn">生成防止区域</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -513,8 +513,7 @@
|
||||
|
||||
|
||||
document.querySelector('#hotspot-btn').addEventListener('click', async function () {
|
||||
console.log(11111111111111);
|
||||
|
||||
|
||||
await hotspotRequest();
|
||||
})
|
||||
const skuToFunc = async (currentText) => {
|
||||
@ -526,7 +525,7 @@
|
||||
if (result.code === 200 && result.data) {
|
||||
console.log('SKU配置数据:', result.data);
|
||||
console.log('关联事件:', result.data.events);
|
||||
|
||||
placementWall(1);
|
||||
// 使用 for...of 循环以支持 await
|
||||
for (const event of result.data.events) {
|
||||
if (event.event_type === 'change_model') {
|
||||
@ -738,10 +737,10 @@
|
||||
const materialName = window.getCurrentMaterialName();
|
||||
if (materialName) {
|
||||
console.log('切换为白色,材质名:', materialName);
|
||||
kernel.material.apply({
|
||||
target: materialName,
|
||||
albedoColor: '#FFFFFF',
|
||||
});
|
||||
kernel.material.apply({
|
||||
target: materialName,
|
||||
albedoColor: '#FFFFFF',
|
||||
});
|
||||
} else {
|
||||
console.log('没有选中材质');
|
||||
}
|
||||
@ -752,10 +751,10 @@
|
||||
const materialName = window.getCurrentMaterialName();
|
||||
if (materialName) {
|
||||
console.log('切换为黑色,材质名:', materialName);
|
||||
kernel.material.apply({
|
||||
target: materialName,
|
||||
albedoColor: '#000000',
|
||||
});
|
||||
kernel.material.apply({
|
||||
target: materialName,
|
||||
albedoColor: '#000000',
|
||||
});
|
||||
} else {
|
||||
console.log('没有选中材质');
|
||||
}
|
||||
@ -821,51 +820,8 @@
|
||||
let dropZoneVisible = false;
|
||||
document.getElementById('dropzone-btn').addEventListener('click', () => {
|
||||
if (!dropZoneVisible) {
|
||||
// 先清除旧的放置区域
|
||||
kernel.dropZone.clearAll();
|
||||
|
||||
// 生成新的放置区域(使用新的墙面参数化API)
|
||||
kernel.dropZone.generate({
|
||||
walls: [
|
||||
{
|
||||
name: 'front',
|
||||
startPoint: [-1.4, 0, -1.4],
|
||||
endPoint: [1.4, 0, -1.4],
|
||||
height: 2.3,
|
||||
divisions: 5
|
||||
},
|
||||
{
|
||||
name: 'back',
|
||||
startPoint: [50, 0, 50],
|
||||
endPoint: [-50, 0, 50],
|
||||
height: 30,
|
||||
divisions: 5
|
||||
},
|
||||
{
|
||||
name: 'left',
|
||||
startPoint: [-50, 0, 50],
|
||||
endPoint: [-50, 0, -50],
|
||||
height: 30,
|
||||
divisions: 4
|
||||
},
|
||||
{
|
||||
name: 'right',
|
||||
startPoint: [50, 0, -50],
|
||||
endPoint: [50, 0, 50],
|
||||
height: 30,
|
||||
divisions: 4
|
||||
}
|
||||
],
|
||||
color: "#21c7ff",
|
||||
alpha: 0.3,
|
||||
thickness: 2,
|
||||
showBorder: true,
|
||||
borderColor: "#ffffff"
|
||||
});
|
||||
|
||||
// 显示放置区域
|
||||
kernel.dropZone.showAll();
|
||||
dropZoneVisible = true;
|
||||
|
||||
// 更新按钮文字
|
||||
document.getElementById('dropzone-btn').textContent = '隐藏放置区域';
|
||||
@ -880,6 +836,76 @@
|
||||
console.log('已隐藏放置区域');
|
||||
}
|
||||
});
|
||||
|
||||
const placementWall = (divisions) => {
|
||||
|
||||
// 先清除旧的放置区域
|
||||
kernel.dropZone.clearAll();
|
||||
|
||||
// 生成新的放置区域(使用新的墙面参数化API)
|
||||
// 调整 baseY 来控制整体高度(正数向上,负数向下)
|
||||
const baseY = 0.08; // 修改这个值来调整整体高度
|
||||
|
||||
// 调整 offset 来控制每个面向外或向内的偏移
|
||||
// 正数 = 向外移动,负数 = 向内移动
|
||||
const wallOffset = -0.07; // 修改这个值来调整墙面偏移
|
||||
|
||||
kernel.dropZone.generate({
|
||||
walls: [
|
||||
{
|
||||
name: 'front',
|
||||
startPoint: [-1.43, baseY, -1.4],
|
||||
endPoint: [1.37, baseY, -1.4],
|
||||
height: 2.2,
|
||||
divisions: divisions,
|
||||
offset: wallOffset // 向外或向内偏移
|
||||
},
|
||||
{
|
||||
name: 'back',
|
||||
startPoint: [1.37, baseY, 1.4],
|
||||
endPoint: [-1.43, baseY, 1.4],
|
||||
height: 2.2,
|
||||
divisions: divisions,
|
||||
offset: wallOffset
|
||||
},
|
||||
{
|
||||
name: 'left',
|
||||
startPoint: [-1.43, baseY, 1.39],
|
||||
endPoint: [-1.43, baseY, -1.43],
|
||||
height: 2.2,
|
||||
divisions: divisions,
|
||||
offset: wallOffset
|
||||
},
|
||||
{
|
||||
name: 'right',
|
||||
startPoint: [1.37, baseY, -1.43],
|
||||
endPoint: [1.37, baseY, 1.4],
|
||||
height: 2.2,
|
||||
divisions: divisions,
|
||||
offset: wallOffset
|
||||
}
|
||||
],
|
||||
color: "#21c7ff",
|
||||
alpha: 0.3,
|
||||
thickness: 2,
|
||||
showBorder: true,
|
||||
borderColor: "#ffffff"
|
||||
});
|
||||
|
||||
// 显示放置区域
|
||||
kernel.dropZone.showAll();
|
||||
dropZoneVisible = true;
|
||||
}
|
||||
|
||||
|
||||
// 监听放置区域点击事件
|
||||
kernel.on('dropzone:click', (data) => {
|
||||
console.log('点击了放置区域:', data);
|
||||
console.log('中心点:', data.center);
|
||||
console.log('宽度:', data.width);
|
||||
console.log('高度:', data.height);
|
||||
console.log('法线:', data.normal);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user