1
This commit is contained in:
73
index.html
73
index.html
@ -315,7 +315,8 @@
|
||||
<div id="info-name" style="margin-bottom: 5px;">名称: -</div>
|
||||
<div id="info-position" style="margin-bottom: 10px; font-size: 12px; color: #666;">坐标: -</div>
|
||||
|
||||
<div style="display: flex; gap: 8px; margin-bottom: 8px;">
|
||||
<!-- 颜色按钮 -->
|
||||
<div id="color-buttons" style="display: none; gap: 8px; margin-bottom: 8px;">
|
||||
<button id="color-btn-1" style="
|
||||
flex: 1;
|
||||
padding: 8px;
|
||||
@ -338,6 +339,30 @@
|
||||
">黑色</button>
|
||||
</div>
|
||||
|
||||
<!-- 旋转按钮 -->
|
||||
<div id="rotation-buttons" style="display: none; gap: 8px; margin-bottom: 8px;">
|
||||
<button id="rotation-btn-90" style="
|
||||
flex: 1;
|
||||
padding: 8px;
|
||||
background: #2196F3;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
">旋转90°</button>
|
||||
<button id="rotation-btn-180" style="
|
||||
flex: 1;
|
||||
padding: 8px;
|
||||
background: #2196F3;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
">旋转180°</button>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 8px;">
|
||||
<button id="remove-model-btn" style="
|
||||
flex: 1;
|
||||
@ -419,7 +444,11 @@
|
||||
const modelUrl = `https://sdk.zguiy.com/resurces/model/${currentText}.glb`;
|
||||
console.log('替换百叶模型:', modelUrl);
|
||||
try {
|
||||
await kernel.model.replace('卷帘小', modelUrl);
|
||||
await kernel.model.replace({
|
||||
modelId: '卷帘小',
|
||||
modelUrl: modelUrl,
|
||||
modelControlType: 'color'
|
||||
});
|
||||
console.log(`百叶模型已替换为 ${currentText}`);
|
||||
} catch (error) {
|
||||
console.error(`百叶模型替换失败:`, error);
|
||||
@ -469,7 +498,7 @@
|
||||
// 这里可以根据配置变更来操作 3D 模型
|
||||
// 例如:
|
||||
// if (e.detail.category === 'size') {
|
||||
// kernel.model.replace('shed', `/models/shed-${e.detail.value}.glb`);
|
||||
// kernel.model.replace({ modelId: 'shed', modelUrl: `/models/shed-${e.detail.value}.glb`, modelControlType: 'rotation' });
|
||||
// }
|
||||
// if (e.detail.category === 'color') {
|
||||
// kernel.material.apply({
|
||||
@ -509,6 +538,44 @@
|
||||
}
|
||||
});
|
||||
|
||||
// 旋转90度按钮事件
|
||||
document.getElementById('rotation-btn-90').addEventListener('click', () => {
|
||||
const pickedMesh = window.getCurrentPickedMesh();
|
||||
if (pickedMesh) {
|
||||
const modelName = kernel.model.findModelNameByMesh?.(pickedMesh);
|
||||
if (modelName) {
|
||||
console.log('旋转90度,模型名:', modelName);
|
||||
kernel.transform.addRotation({
|
||||
modelId: modelName,
|
||||
vector3: { x: 0, y: 90, z: 0 }
|
||||
});
|
||||
} else {
|
||||
console.log('未找到模型名称');
|
||||
}
|
||||
} else {
|
||||
console.log('没有选中的网格');
|
||||
}
|
||||
});
|
||||
|
||||
// 旋转180度按钮事件
|
||||
document.getElementById('rotation-btn-180').addEventListener('click', () => {
|
||||
const pickedMesh = window.getCurrentPickedMesh();
|
||||
if (pickedMesh) {
|
||||
const modelName = kernel.model.findModelNameByMesh?.(pickedMesh);
|
||||
if (modelName) {
|
||||
console.log('旋转180度,模型名:', modelName);
|
||||
kernel.transform.addRotation({
|
||||
modelId: modelName,
|
||||
vector3: { x: 0, y: 180, z: 0 }
|
||||
});
|
||||
} else {
|
||||
console.log('未找到模型名称');
|
||||
}
|
||||
} else {
|
||||
console.log('没有选中的网格');
|
||||
}
|
||||
});
|
||||
|
||||
// 移除按钮事件
|
||||
document.getElementById('remove-model-btn').addEventListener('click', () => {
|
||||
const pickedMesh = window.getCurrentPickedMesh();
|
||||
|
||||
Reference in New Issue
Block a user