feat: 新增底部Dock测量面板与回调联动

This commit is contained in:
yuding
2026-03-30 10:53:39 +08:00
parent c11140f967
commit 2574a11284
42 changed files with 18388 additions and 11404 deletions

View File

@@ -121,6 +121,7 @@
<h2>🌍 语言 (Language)</h2>
<div class="btn-container">
<button class="primary" onclick="setLang('zh-CN')">中文</button>
<button class="primary" onclick="setLang('zh-TW')">繁體中文</button>
<button class="primary" onclick="setLang('en-US')">English</button>
</div>
</div>
@@ -135,21 +136,24 @@
</div>
</div>
<!-- 3. 工具栏操作 -->
<div class="control-group">
<h2>🛠️ 工具栏 (Toolbar)</h2>
<!-- 3. 工具栏操作 (CusBimEngine 中已移除 ToolbarManager) -->
<div class="control-group" style="opacity: 0.6;">
<h2>🛠️ 工具栏 (Toolbar) <span style="color: #999; font-size: 0.75rem;">[CusBimEngine 已移除]</span></h2>
<div style="font-size: 0.8rem; color: #888; margin-bottom: 8px;">
当前使用 CusBimEngine不包含工具栏功能
</div>
<div class="btn-container">
<button onclick="toggleToolbar()">显隐工具栏</button>
<button onclick="toggleLabel()">显隐标签</button>
<button onclick="toggleLocationBtn()">显隐定位按钮</button>
<button disabled>显隐工具栏</button>
<button disabled>显隐标签</button>
<button disabled>显隐定位按钮</button>
</div>
<div class="btn-container" style="margin-top: 8px;">
<button onclick="addCustomGroup()">加组</button>
<button onclick="addCustomButton()">加按钮</button>
<button disabled>加组</button>
<button disabled>加按钮</button>
</div>
<div class="btn-container" style="margin-top: 8px;">
<button onclick="setToolbarType('default')">默认样式</button>
<button onclick="setToolbarType('glass-pill')">胶囊样式</button>
<button disabled>默认样式</button>
<button disabled>胶囊样式</button>
</div>
</div>
@@ -168,6 +172,7 @@
<h2>📑 功能面板 (Panels)</h2>
<div class="btn-container">
<button onclick="openPropertyPanel()">属性面板</button>
<button onclick="viewPresetCacheData()">查看预设缓存</button>
</div>
</div>
@@ -324,11 +329,119 @@
let isLabelVisible = true;
let isLocationVisible = true;
let customGroupAdded = false;
let currentLocale = 'zh-CN';
let unsubscribePresetSaved = null;
let unsubscribePresetChanged = null;
let unsubscribePresetDeleted = null;
const PRESET_CACHE_KEY = 'iflow-demo-setting-presets-v1';
function injectSettingPresetsFromCache() {
if (!engine || !engine.setting || typeof engine.setting.setPresetList !== 'function') {
return;
}
engine.setting.setPresetList(buildPresetListFromCache());
console.log('✅ 已注入缓存预设列表');
}
function safeClone(data) {
return JSON.parse(JSON.stringify(data));
}
function loadPresetCache() {
try {
const raw = localStorage.getItem(PRESET_CACHE_KEY);
if (!raw) return [];
const parsed = JSON.parse(raw);
return Array.isArray(parsed) ? parsed : [];
} catch (error) {
console.warn('读取预设缓存失败,已忽略:', error);
return [];
}
}
function savePresetCache(list) {
localStorage.setItem(PRESET_CACHE_KEY, JSON.stringify(list));
}
function buildPresetListFromCache() {
return loadPresetCache().filter((item) => item && typeof item.id === 'string');
}
function upsertPresetCache(preset) {
const list = loadPresetCache();
const index = list.findIndex((item) => item.id === preset.id);
const normalizedPreset = { ...preset, isDefault: Boolean(preset.isDefault) };
if (index >= 0) {
list[index] = normalizedPreset;
} else {
list.push(normalizedPreset);
}
savePresetCache(list);
}
function deletePresetCache(preset) {
const list = loadPresetCache();
const next = list.filter((item) => item && item.id !== preset.id);
savePresetCache(next);
}
function bindPresetEvents() {
if (!engine || typeof engine.on !== 'function') return;
if (unsubscribePresetSaved) {
unsubscribePresetSaved();
unsubscribePresetSaved = null;
}
if (unsubscribePresetChanged) {
unsubscribePresetChanged();
unsubscribePresetChanged = null;
}
if (unsubscribePresetDeleted) {
unsubscribePresetDeleted();
unsubscribePresetDeleted = null;
}
unsubscribePresetSaved = engine.on('setting:preset-saved', ({ preset }) => {
upsertPresetCache(safeClone(preset));
injectSettingPresetsFromCache();
console.log('💾 已写入预设缓存:', preset);
});
unsubscribePresetChanged = engine.on('setting:preset-changed', ({ preset }) => {
console.log('🔁 已切换预设:', preset);
});
unsubscribePresetDeleted = engine.on('setting:preset-deleted', (preset) => {
deletePresetCache(safeClone(preset));
injectSettingPresetsFromCache();
console.log('🗑️ 已删除预设缓存:', preset);
});
}
function viewPresetCacheData() {
const data = loadPresetCache();
console.log('📦 当前预设缓存数据:', data);
window.alert(data.length === 0 ? '当前没有预设缓存数据' : JSON.stringify(data, null, 2));
}
/**
* 销毁所有引擎实例
*/
function destroyAllEngines() {
if (unsubscribePresetSaved) {
unsubscribePresetSaved();
unsubscribePresetSaved = null;
}
if (unsubscribePresetChanged) {
unsubscribePresetChanged();
unsubscribePresetChanged = null;
}
if (unsubscribePresetDeleted) {
unsubscribePresetDeleted();
unsubscribePresetDeleted = null;
}
if (engine) { engine.destroy(); engine = null; }
if (engine2d) { engine2d.destroy(); engine2d = null; }
if (engine720) { engine720.destroy(); engine720 = null; }
@@ -349,7 +462,10 @@
// --- 语言设置 ---
function setLang(lang) {
currentLocale = lang;
if (engine) engine.setLocale(lang);
if (engine2d) engine2d.setLocale(lang);
if (engine720) engine720.setLocale(lang);
}
// --- 弹窗测试 ---
@@ -469,6 +585,7 @@
/**
* 初始化 3D 引擎(独立实例,销毁其他引擎类型)
* 使用 CusBimEngine移除了按钮组和构件树
*/
function initEngine3D() {
destroyAllEngines();
@@ -479,7 +596,7 @@
document.getElementById('btn-load720').disabled = true;
try {
engine = new IflowEngine.BimEngine('app', { locale: 'zh-CN' });
engine = new IflowEngine.CusBimEngine('app', { locale: currentLocale });
var success = engine.engine.initialize({
backgroundColor: 0x333333,
version: 'v2',
@@ -488,6 +605,8 @@
});
if (success) {
injectSettingPresetsFromCache();
bindPresetEvents();
updateEngineStatus('已初始化');
console.log('✅ 3D 引擎初始化成功');
loadModel();
@@ -835,6 +954,7 @@
try {
engine2d = new IflowEngine.BimEngine2d('app', {
locale: currentLocale,
backgroundColor: 0x1a1a1a,
gridEnabled: true,
axesEnabled: true,
@@ -927,6 +1047,7 @@
try {
engine720 = new IflowEngine.BimEngine720('app', {
locale: currentLocale,
fov: 75,
enableZoom: true,
enableRotate: true,
@@ -980,4 +1101,4 @@
</script>
</body>
</html>
</html>