fix: 修复 3D NaN 崩溃/样品图不刷新/画布点选失效

- replayShape 段过滤补 Y 轴有限值校验(此前仅校验 X)
- inferSashGlyphs bdRect 增加有限值守卫
- WindoorThreed 逐网格有限值防护 + maxDim 守卫, 杜绝 NaN 网格
- CombineCanvas shapePts 过滤非有限点, 修复包围盒污染导致的点选失效
- 组合画布引入 rev 版本号: 原地变异几何后强制 3D 预览重建
  (修复尺寸编辑后样品图不变化)
This commit is contained in:
HHY
2026-09-21 02:26:08 -07:00
parent 4303aa6986
commit 4b52767654
5 changed files with 27 additions and 11 deletions
+7 -2
View File
@@ -79,13 +79,17 @@ function build(drawing: DrawingData) {
const pts: Pt[] = []
for (const s of drawing.sm) {
for (const r of replayShape(s).regions) {
for (const seg of r) { pts.push(seg.ps); pts.push(seg.pe) }
for (const seg of r) {
if (Number.isFinite(seg.ps?.x) && Number.isFinite(seg.ps?.y)) pts.push(seg.ps)
if (Number.isFinite(seg.pe?.x) && Number.isFinite(seg.pe?.y)) pts.push(seg.pe)
}
}
}
if (!pts.length) { info.value = '无几何数据'; hasOpenable.value = false; return }
const gb = bboxOf(pts)
const gw = gb.x1 - gb.x0, gh = gb.y1 - gb.y0
const maxDim = Math.max(gw, gh)
if (!Number.isFinite(maxDim) || maxDim <= 0) { info.value = '无有效几何'; hasOpenable.value = false; return }
const S = 1 / maxDim
const cx = (gb.x0 + gb.x1) / 2, cy = (gb.y0 + gb.y1) / 2
const DEPTH = Math.max(0.04, (drawing.s?.cs ?? 60) * S * 1.2)
@@ -132,6 +136,7 @@ function build(drawing: DrawingData) {
const w = (bb.x1 - bb.x0) * S, h = (bb.y1 - bb.y0) * S
const mx = ((bb.x0 + bb.x1) / 2 - cx) * S
const my = ((bb.y0 + bb.y1) / 2 - cy) * S
if (![w, h, mx, my].every(Number.isFinite) || w <= 0 || h <= 0) continue
const inSash = sashRects.some(r => {
const cxr = (r.x0 + r.x1) / 2, cyr = (r.y0 + r.y1) / 2
return Math.abs(cxr - (bb.x0 + bb.x1) / 2) < w / 2 && Math.abs(cyr - (bb.y0 + bb.y1) / 2) < h / 2
@@ -145,9 +150,9 @@ function build(drawing: DrawingData) {
// 扇面板(可开合):玻璃 + 四周扇框,装入铰链/滑动组
sashes.forEach((s, k) => {
const w = (s.x1 - s.x0) * S, h = (s.y1 - s.y0) * S
if (w < 0.02 || h < 0.02) return
const cxr = ((s.x0 + s.x1) / 2 - cx) * S
const cyr = ((s.y0 + s.y1) / 2 - cy) * S
if (![w, h, cxr, cyr].every(Number.isFinite) || w < 0.02 || h < 0.02) return
const group = new THREE.Group()
const panel = new THREE.Group()
const glass = new THREE.Mesh(new THREE.BoxGeometry(w, h, 0.006), gm)