feat: v2.0 DXF 截面学习+多腔体型材挤出落地
- 下载源站 49 个真实型材截面 DXF 用于学习(临时, 已按约定删除) - 自研 DXF 解析器: 提取截面外轮廓/闭合腔体/实体统计 - 学习结论: 外框深46-62宽74-130(3-6腔), 玻璃扇深80-90宽65-72(4-10腔), 中梃深79-84宽~100(3-7腔), 纱扇薄壁19-38, 转角立柱146x150(5腔)等 - 3D 型材升级: 多腔体截面挤出(外框3腔/扇2腔, 玻璃槽深20%, 壁厚比例修正) - 学习结论沉淀至方案文档§3.3, DXF 素材已全部删除
This commit is contained in:
@@ -109,20 +109,37 @@ function overlapArea(a: BBox, b: BBox): number {
|
||||
return w > 0 && h > 0 ? w * h : 0
|
||||
}
|
||||
|
||||
/** U 型槽型材截面: 沿长度方向挤出, 槽口朝玻璃面(u=0 侧) */
|
||||
function profileGeo(len: number, fw: number, depth: number): THREE.BufferGeometry {
|
||||
const t = Math.max(0.004, depth * 0.28) // 壁厚
|
||||
/** 型材截面: 多腔体 + 玻璃槽(比例依据真实 DXF 截面学习: 深度46-90/面宽65-130/腔体3-6/壁厚≈深度1/30) */
|
||||
function profileGeo(len: number, fw: number, depth: number, chambers: number): THREE.BufferGeometry {
|
||||
const t = Math.max(0.004, depth * 0.14) // 壁厚
|
||||
const g = Math.max(0.006, depth * 0.2) // 玻璃槽深
|
||||
const s = new THREE.Shape()
|
||||
// 外轮廓 (u: 深度方向 0=玻璃侧, v: 宽度方向)
|
||||
s.moveTo(0, 0)
|
||||
// 外轮廓: u=0 侧开玻璃槽
|
||||
s.moveTo(0, t)
|
||||
s.lineTo(g, t)
|
||||
s.lineTo(g, fw - t)
|
||||
s.lineTo(0, fw - t)
|
||||
s.lineTo(0, 0)
|
||||
s.lineTo(depth, 0)
|
||||
s.lineTo(depth, fw)
|
||||
s.lineTo(t, fw)
|
||||
s.lineTo(t, t)
|
||||
s.lineTo(depth - t * 1.6, t)
|
||||
s.lineTo(depth - t * 1.6, fw - t)
|
||||
s.lineTo(0, fw - t)
|
||||
s.lineTo(g, fw)
|
||||
s.closePath()
|
||||
// 腔体孔洞(隔热/加强腔)
|
||||
const cH = fw - t * 2
|
||||
const usable = depth - g - t * (chambers + 1)
|
||||
const cw = usable / chambers
|
||||
if (cw > t) {
|
||||
for (let i = 0; i < chambers; i++) {
|
||||
const hx = g + t + i * (cw + t)
|
||||
const hole = new THREE.Path()
|
||||
hole.moveTo(hx, t)
|
||||
hole.lineTo(hx + cw, t)
|
||||
hole.lineTo(hx + cw, t + cH)
|
||||
hole.lineTo(hx, t + cH)
|
||||
hole.closePath()
|
||||
s.holes.push(hole)
|
||||
}
|
||||
}
|
||||
const geo = new THREE.ExtrudeGeometry(s, { depth: len, bevelEnabled: false })
|
||||
geo.translate(0, 0, -len / 2)
|
||||
return geo
|
||||
@@ -130,8 +147,8 @@ function profileGeo(len: number, fw: number, depth: number): THREE.BufferGeometr
|
||||
|
||||
/** 沿 X 轴的型材杆(槽口朝 -Z 玻璃面) */
|
||||
function barX(parent: THREE.Group, mat: THREE.Material, len: number, fw: number,
|
||||
depth: number, cx: number, cy: number, cz: number) {
|
||||
const geo = profileGeo(len, fw, depth)
|
||||
depth: number, cx: number, cy: number, cz: number, chambers = 2) {
|
||||
const geo = profileGeo(len, fw, depth, chambers)
|
||||
const m = new THREE.Mesh(geo, mat)
|
||||
m.rotation.y = -Math.PI / 2
|
||||
m.position.set(cx, cy, cz)
|
||||
@@ -141,8 +158,8 @@ function barX(parent: THREE.Group, mat: THREE.Material, len: number, fw: number,
|
||||
|
||||
/** 沿 Y 轴的型材杆 */
|
||||
function barY(parent: THREE.Group, mat: THREE.Material, len: number, fw: number,
|
||||
depth: number, cx: number, cy: number, cz: number) {
|
||||
const geo = profileGeo(len, fw, depth)
|
||||
depth: number, cx: number, cy: number, cz: number, chambers = 2) {
|
||||
const geo = profileGeo(len, fw, depth, chambers)
|
||||
const m = new THREE.Mesh(geo, mat)
|
||||
m.rotation.x = -Math.PI / 2
|
||||
m.rotation.z = Math.PI / 2
|
||||
@@ -319,10 +336,10 @@ function build(drawing: DrawingData) {
|
||||
const p0 = world(bb.x0, bb.y0), p1 = world(bb.x1, bb.y1)
|
||||
const w = p1.x - p0.x, h = p1.y - p0.y
|
||||
const mx = (p0.x + p1.x) / 2, my = (p0.y + p1.y) / 2
|
||||
barX(frameGroup, frameMat, w + fw * 2, fw, DEPTH, mx, my + h / 2 + fw / 2, 0)
|
||||
barX(frameGroup, frameMat, w + fw * 2, fw, DEPTH, mx, my - h / 2 - fw / 2, 0)
|
||||
barY(frameGroup, frameMat, h, fw, DEPTH, mx - w / 2 - fw / 2, my, 0)
|
||||
barY(frameGroup, frameMat, h, fw, DEPTH, mx + w / 2 + fw / 2, my, 0)
|
||||
barX(frameGroup, frameMat, w + fw * 2, fw, DEPTH, mx, my + h / 2 + fw / 2, 0, 3)
|
||||
barX(frameGroup, frameMat, w + fw * 2, fw, DEPTH, mx, my - h / 2 - fw / 2, 0, 3)
|
||||
barY(frameGroup, frameMat, h, fw, DEPTH, mx - w / 2 - fw / 2, my, 0, 3)
|
||||
barY(frameGroup, frameMat, h, fw, DEPTH, mx + w / 2 + fw / 2, my, 0, 3)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user