11b606bd39
v6.0.1 — FFD Freeform Deformation: - ffd_deformation.h/.cpp: Bezier volume lattice, deform_brep/deform_mesh - Bernstein polynomial mapping, topology-preserving - Cage-based + lattice-based FFD, create_cage_lattice() v6.0.2 — Auto-Dimensioning + PMI/MBD + GD&T: - auto_dimensioning.h/.cpp: linear/angular/radial/diameter detection - ISO/ANSI/JIS drawing standards, smart label placement - gdt.h/.cpp: 14 GD&T symbols (ASME Y14.5), MMC/LMC/RFS material conditions - pmi_mbd.h/.cpp: PMIAnnotation, attach_pmi, PMIView, STEP AP242 export - 70/70 tests passing (23 auto-dim + 25 PMI + 22 GD&T regression) v6.0.3 — Web 3D Viewer Enhancement: - viewer/index.html + app.js: Three.js GLB/STL loading - OrbitControls, face coloring, dimension overlay, GD&T display - Measure tool (raycaster), clip plane slider, explode animation - Drag-and-drop file upload, responsive layout
431 lines
11 KiB
HTML
431 lines
11 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>ViewDesignEngine 3D Viewer</title>
|
|
<style>
|
|
:root {
|
|
--bg: #1a1a2e;
|
|
--panel-bg: rgba(10, 10, 30, 0.92);
|
|
--border: rgba(255,255,255,0.12);
|
|
--text: #e0e0e0;
|
|
--accent: #4da6ff;
|
|
--accent2: #ff6b6b;
|
|
--dim: #888;
|
|
--face-planar: #4ecdc4;
|
|
--face-cylindrical: #45b7d1;
|
|
--face-conical: #96ceb4;
|
|
--face-spherical: #ffeaa7;
|
|
--face-toroidal: #dfe6e9;
|
|
--face-spline: #fd79a8;
|
|
--face-default: #b2bec3;
|
|
}
|
|
|
|
* { margin:0; padding:0; box-sizing:border-box; }
|
|
|
|
body {
|
|
background: var(--bg);
|
|
font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
|
|
overflow: hidden;
|
|
height: 100vh;
|
|
width: 100vw;
|
|
user-select: none;
|
|
-webkit-user-select: none;
|
|
}
|
|
|
|
/* ─── Three.js Canvas ─── */
|
|
#viewer-canvas {
|
|
position: absolute;
|
|
top: 0; left: 0;
|
|
width: 100%; height: 100%;
|
|
display: block;
|
|
z-index: 1;
|
|
}
|
|
|
|
/* ─── 尺寸标注 Overlay Canvas ─── */
|
|
#dimension-overlay {
|
|
position: absolute;
|
|
top: 0; left: 0;
|
|
width: 100%; height: 100%;
|
|
pointer-events: none;
|
|
z-index: 2;
|
|
}
|
|
#dimension-overlay.active {
|
|
pointer-events: auto;
|
|
cursor: crosshair;
|
|
}
|
|
|
|
/* ─── 拖放区域 ─── */
|
|
#drop-zone {
|
|
position: absolute;
|
|
top: 50%; left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
z-index: 3;
|
|
color: var(--dim);
|
|
font-size: 20px;
|
|
text-align: center;
|
|
pointer-events: none;
|
|
transition: opacity 0.3s;
|
|
}
|
|
#drop-zone .icon { font-size: 64px; display: block; margin-bottom: 12px; }
|
|
#drop-zone.hidden { display: none; }
|
|
#drop-zone.highlight { color: var(--accent); }
|
|
|
|
/* 全局拖放高亮边框 */
|
|
#drag-border {
|
|
position: absolute;
|
|
top: 0; left: 0;
|
|
width: 100%; height: 100%;
|
|
border: 3px dashed var(--accent);
|
|
z-index: 10;
|
|
pointer-events: none;
|
|
display: none;
|
|
}
|
|
#drag-border.show { display: block; }
|
|
|
|
/* ─── 顶部信息栏 ─── */
|
|
#info-bar {
|
|
position: absolute;
|
|
top: 12px;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
z-index: 4;
|
|
background: var(--panel-bg);
|
|
color: var(--text);
|
|
padding: 6px 18px;
|
|
border-radius: 20px;
|
|
font-size: 13px;
|
|
border: 1px solid var(--border);
|
|
backdrop-filter: blur(12px);
|
|
pointer-events: none;
|
|
}
|
|
|
|
/* ─── 左侧 B-Rep 图例面板 ─── */
|
|
#brep-legend {
|
|
position: absolute;
|
|
top: 100px;
|
|
left: 12px;
|
|
z-index: 4;
|
|
background: var(--panel-bg);
|
|
border: 1px solid var(--border);
|
|
border-radius: 10px;
|
|
padding: 14px 16px;
|
|
color: var(--text);
|
|
font-size: 12px;
|
|
backdrop-filter: blur(12px);
|
|
min-width: 150px;
|
|
display: none;
|
|
}
|
|
#brep-legend h4 {
|
|
margin-bottom: 10px;
|
|
font-size: 13px;
|
|
color: var(--accent);
|
|
border-bottom: 1px solid var(--border);
|
|
padding-bottom: 6px;
|
|
}
|
|
#brep-legend .legend-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
margin-bottom: 6px;
|
|
}
|
|
#brep-legend .legend-swatch {
|
|
width: 14px;
|
|
height: 14px;
|
|
border-radius: 3px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
/* ─── 左侧 GD&T 标注面板 ─── */
|
|
#gdt-panel {
|
|
position: absolute;
|
|
top: 100px;
|
|
left: 190px;
|
|
z-index: 4;
|
|
background: var(--panel-bg);
|
|
border: 1px solid var(--border);
|
|
border-radius: 10px;
|
|
padding: 14px 16px;
|
|
color: var(--text);
|
|
font-size: 12px;
|
|
backdrop-filter: blur(12px);
|
|
min-width: 180px;
|
|
display: none;
|
|
}
|
|
#gdt-panel h4 {
|
|
margin-bottom: 8px;
|
|
font-size: 13px;
|
|
color: var(--accent2);
|
|
border-bottom: 1px solid var(--border);
|
|
padding-bottom: 6px;
|
|
}
|
|
#gdt-panel .gdt-frame {
|
|
display: inline-block;
|
|
border: 2px solid var(--accent2);
|
|
border-radius: 4px;
|
|
padding: 4px 8px;
|
|
margin: 3px 0;
|
|
font-family: monospace;
|
|
font-size: 13px;
|
|
color: var(--accent2);
|
|
background: rgba(255,107,107,0.08);
|
|
}
|
|
#gdt-panel .gdt-rows {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 2px;
|
|
}
|
|
#gdt-panel .gdt-row {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
padding: 2px 0;
|
|
border-bottom: 1px solid rgba(255,255,255,0.06);
|
|
}
|
|
#gdt-panel .gdt-label { color: var(--dim); }
|
|
#gdt-panel .gdt-val { font-weight: 600; }
|
|
|
|
/* ─── 右侧测量信息面板 ─── */
|
|
#measure-panel {
|
|
position: absolute;
|
|
top: 100px;
|
|
right: 12px;
|
|
z-index: 4;
|
|
background: var(--panel-bg);
|
|
border: 1px solid var(--border);
|
|
border-radius: 10px;
|
|
padding: 14px 16px;
|
|
color: var(--text);
|
|
font-size: 12px;
|
|
backdrop-filter: blur(12px);
|
|
min-width: 180px;
|
|
display: none;
|
|
}
|
|
#measure-panel h4 {
|
|
margin-bottom: 8px;
|
|
font-size: 13px;
|
|
color: #ffd93d;
|
|
border-bottom: 1px solid var(--border);
|
|
padding-bottom: 6px;
|
|
}
|
|
#measure-panel .meas-row {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
padding: 2px 0;
|
|
}
|
|
#measure-panel .meas-result {
|
|
font-size: 16px;
|
|
font-weight: 700;
|
|
color: #ffd93d;
|
|
text-align: center;
|
|
padding: 6px 0;
|
|
}
|
|
#measure-panel .meas-hint {
|
|
color: var(--dim);
|
|
font-style: italic;
|
|
text-align: center;
|
|
margin-top: 4px;
|
|
}
|
|
|
|
/* ─── 底部工具栏 ─── */
|
|
#toolbar {
|
|
position: absolute;
|
|
bottom: 16px;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
z-index: 4;
|
|
display: flex;
|
|
gap: 6px;
|
|
background: var(--panel-bg);
|
|
padding: 8px 12px;
|
|
border-radius: 28px;
|
|
border: 1px solid var(--border);
|
|
backdrop-filter: blur(12px);
|
|
flex-wrap: wrap;
|
|
justify-content: center;
|
|
}
|
|
#toolbar button {
|
|
padding: 7px 16px;
|
|
border: 1px solid var(--border);
|
|
background: rgba(255,255,255,0.06);
|
|
color: var(--text);
|
|
border-radius: 20px;
|
|
cursor: pointer;
|
|
font-size: 12px;
|
|
white-space: nowrap;
|
|
transition: all 0.2s;
|
|
}
|
|
#toolbar button:hover {
|
|
background: rgba(255,255,255,0.16);
|
|
}
|
|
#toolbar button.active {
|
|
background: var(--accent);
|
|
border-color: var(--accent);
|
|
color: #fff;
|
|
}
|
|
#toolbar button.danger {
|
|
border-color: var(--accent2);
|
|
color: var(--accent2);
|
|
}
|
|
#toolbar button.danger:hover {
|
|
background: rgba(255,107,107,0.2);
|
|
}
|
|
#toolbar button.danger.active {
|
|
background: var(--accent2);
|
|
color: #fff;
|
|
}
|
|
|
|
/* ─── 剖切面控制栏 ─── */
|
|
#clip-bar {
|
|
position: absolute;
|
|
bottom: 90px;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
z-index: 4;
|
|
background: var(--panel-bg);
|
|
border: 1px solid var(--border);
|
|
border-radius: 10px;
|
|
padding: 10px 18px;
|
|
backdrop-filter: blur(12px);
|
|
display: none;
|
|
align-items: center;
|
|
gap: 12px;
|
|
}
|
|
#clip-bar.show { display: flex; }
|
|
#clip-bar label {
|
|
color: var(--text);
|
|
font-size: 12px;
|
|
white-space: nowrap;
|
|
}
|
|
#clip-bar select {
|
|
background: rgba(255,255,255,0.08);
|
|
color: var(--text);
|
|
border: 1px solid var(--border);
|
|
border-radius: 4px;
|
|
padding: 4px 8px;
|
|
font-size: 12px;
|
|
}
|
|
#clip-plane-slider {
|
|
width: 200px;
|
|
accent-color: var(--accent);
|
|
}
|
|
#clip-bar .clip-val {
|
|
color: var(--accent);
|
|
font-family: monospace;
|
|
font-size: 13px;
|
|
min-width: 40px;
|
|
}
|
|
|
|
/* ─── 文件输入(隐藏) ─── */
|
|
#file-input { display: none; }
|
|
|
|
/* ─── 响应式 ─── */
|
|
@media (max-width: 768px) {
|
|
#brep-legend, #gdt-panel, #measure-panel {
|
|
font-size: 10px;
|
|
padding: 8px 10px;
|
|
}
|
|
#toolbar button { padding: 5px 10px; font-size: 11px; }
|
|
#clip-plane-slider { width: 120px; }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<!-- 3D 画布 -->
|
|
<canvas id="viewer-canvas"></canvas>
|
|
|
|
<!-- 尺寸标注 Overlay -->
|
|
<canvas id="dimension-overlay"></canvas>
|
|
|
|
<!-- 拖放区域 -->
|
|
<div id="drop-zone">
|
|
<span class="icon">📦</span>
|
|
拖放 .glb / .stl 文件到这里<br>
|
|
<span style="font-size:13px;color:var(--dim);margin-top:4px;display:inline-block;">或点击下方「打开文件」按钮</span>
|
|
</div>
|
|
<div id="drag-border"></div>
|
|
|
|
<!-- 顶部信息栏 -->
|
|
<div id="info-bar">ViewDesignEngine 3D Viewer — 等待加载模型</div>
|
|
|
|
<!-- B-Rep 图例面板 -->
|
|
<div id="brep-legend">
|
|
<h4>🎨 B-Rep 面类型</h4>
|
|
<div id="brep-legend-items"></div>
|
|
</div>
|
|
|
|
<!-- GD&T 标注面板 -->
|
|
<div id="gdt-panel">
|
|
<h4>📐 GD&T 几何公差</h4>
|
|
<div id="gdt-content">
|
|
<p style="color:var(--dim);">加载含 GD&T 元数据的模型后可显示</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 测量信息面板 -->
|
|
<div id="measure-panel">
|
|
<h4>📏 测量工具</h4>
|
|
<div class="meas-hint" id="meas-hint">点击模型上两点进行测距</div>
|
|
<div class="meas-result" id="meas-result" style="display:none;"></div>
|
|
<div class="meas-row" id="meas-p1" style="display:none;">
|
|
<span>点1</span><span id="meas-p1-val"></span>
|
|
</div>
|
|
<div class="meas-row" id="meas-p2" style="display:none;">
|
|
<span>点2</span><span id="meas-p2-val"></span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 剖切面控制栏 -->
|
|
<div id="clip-bar">
|
|
<label>剖切轴:</label>
|
|
<select id="clip-axis">
|
|
<option value="x">X 轴</option>
|
|
<option value="y">Y 轴</option>
|
|
<option value="z" selected>Z 轴</option>
|
|
</select>
|
|
<input type="range" id="clip-plane-slider" min="-100" max="100" value="0" step="1">
|
|
<span class="clip-val" id="clip-val">0.00</span>
|
|
</div>
|
|
|
|
<!-- 底部工具栏 -->
|
|
<div id="toolbar">
|
|
<button id="btn-open" onclick="document.getElementById('file-input').click()">📁 打开文件</button>
|
|
<button id="btn-wireframe" onclick="viewer.toggleWireframe()">🔲 线框</button>
|
|
<button id="btn-reset" onclick="viewer.resetCamera()">🔄 重置视角</button>
|
|
<button id="btn-top" onclick="viewer.setView('top')">⬆ 俯视</button>
|
|
<button id="btn-front" onclick="viewer.setView('front')">🔲 前视</button>
|
|
<button id="btn-right" onclick="viewer.setView('right')">➡ 右视</button>
|
|
<button id="btn-measure" onclick="viewer.toggleMeasure()">📏 测量</button>
|
|
<button id="btn-clip" onclick="viewer.toggleClipPlane()">✂️ 剖切</button>
|
|
<button id="btn-explode" onclick="viewer.toggleExplode()">💥 爆炸视图</button>
|
|
<button id="btn-gdt" onclick="viewer.toggleGDTPanel()">📐 GD&T</button>
|
|
<button id="btn-clear" class="danger" onclick="viewer.clear()">🗑 清除</button>
|
|
</div>
|
|
|
|
<input type="file" id="file-input" accept=".glb,.gltf,.stl">
|
|
|
|
<!-- Three.js Import Map -->
|
|
<script type="importmap">
|
|
{
|
|
"imports": {
|
|
"three": "https://unpkg.com/three@0.160.0/build/three.module.js",
|
|
"three/addons/": "https://unpkg.com/three@0.160.0/examples/jsm/"
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<!-- GSAP -->
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/gsap.min.js"></script>
|
|
|
|
<!-- 主应用 -->
|
|
<script type="module">
|
|
import { Viewer3D } from './app.js';
|
|
|
|
// 挂载到 window 以便 HTML onclick 回调访问
|
|
window.viewer = new Viewer3D();
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|