|
@@ -0,0 +1,2557 @@
|
|
|
|
|
+/* =========================================================
|
|
|
|
|
+ 数据层:项目参数 / 材质 / 工艺 / 电子件 / 知识库
|
|
|
|
|
+ 单位统一 mm;价格为 2026-11 深圳·东莞行情区间(仅供参考)
|
|
|
|
|
+ ========================================================= */
|
|
|
|
|
+
|
|
|
|
|
+const MATERIALS = {
|
|
|
|
|
+ 'sil-black': {name:'硅胶 哑光黑', albedo:'#22262c', metallic:0.0, rough:0.62, cc:0.20, cci:0.30, swatch:'#22262c', note:'邵氏 A50,喷手感油'},
|
|
|
|
|
+ 'sil-pink': {name:'硅胶 哑光藕粉', albedo:'#d8a8b4', metallic:0.0, rough:0.60, cc:0.20, cci:0.28, swatch:'#d8a8b4', note:'双色拼色 A 料'},
|
|
|
|
|
+ 'sil-mint': {name:'硅胶 雾青', albedo:'#9fc8bd', metallic:0.0, rough:0.60, cc:0.18, cci:0.24, swatch:'#9fc8bd'},
|
|
|
|
|
+ 'abs-gloss': {name:'ABS 光面白', albedo:'#eceef1', metallic:0.0, rough:0.26, cc:0.55, cci:0.45, swatch:'#eceef1', note:'注塑本色,可丝印'},
|
|
|
|
|
+ 'abs-soft': {name:'ABS 类肤灰', albedo:'#b9bdc3', metallic:0.0, rough:0.55, cc:0.12, cci:0.2, swatch:'#b9bdc3', grain:0.15, note:'细皮纹 MT11010'},
|
|
|
|
|
+ 'abs-matte': {name:'ABS 喷油哑光', albedo:'#dfe3e8', metallic:0.0, rough:0.58, cc:0.10, cci:0.18, swatch:'#dfe3e8', grain:0.18, note:'喷橡胶漆,耐磨 500g 摩擦'},
|
|
|
|
|
+ 'abs-black': {name:'ABS 哑光黑', albedo:'#1f2328', metallic:0.0, rough:0.50, cc:0.12, cci:0.20, swatch:'#1f2328'},
|
|
|
|
|
+ 'pc-clear': {name:'PC 透明', albedo:'#dfeaf5', metallic:0.0, rough:0.08, cc:0.6, cci:0.5, swatch:'#cfe2f3', alpha:0.42},
|
|
|
|
|
+ 'alu-silver': {name:'6061 阳极银', albedo:'#c7cfd8', metallic:1.0, rough:0.24, cc:0.18, cci:0.42, swatch:'#c7cfd8', note:'喷砂+阳极 10~15μm'},
|
|
|
|
|
+ 'alu-sand': {name:'6061 喷砂银', albedo:'#c6ccd3', metallic:1.0, rough:0.60, cc:0.05, cci:0.12, swatch:'#c6ccd3'},
|
|
|
|
|
+ 'alu-black': {name:'6061 阳极黑', albedo:'#282c31', metallic:0.9, rough:0.36, cc:0.16, cci:0.30, swatch:'#282c31', note:'阳极后螺纹需二次回攻'},
|
|
|
|
|
+ 'alu-rose': {name:'6061 阳极玫瑰金', albedo:'#d9b49a', metallic:1.0, rough:0.30, cc:0.15, cci:0.35, swatch:'#d9b49a'},
|
|
|
|
|
+ /* 阶段 F 新增:五款新产品专属 PBR 材质(grain = 程序化喷砂微表面,无量贴图文件) */
|
|
|
|
|
+ 'alu-graphite':{name:'钛灰阳极铝', albedo:'#4b5159', metallic:0.95, rough:0.34, cc:0.16, cci:0.34, swatch:'#4b5159', grain:0.35, note:'喷砂 180# + 阳极 12μm'},
|
|
|
|
|
+ 'ti-brush': {name:'钛合金 拉丝', albedo:'#a6acb3', metallic:1.0, rough:0.42, cc:0.06, cci:0.18, swatch:'#a6acb3', grain:0.25, note:'TC4,拉丝 400#,无指纹涂层'},
|
|
|
|
|
+ 'ceramic': {name:'氧化锆陶瓷', albedo:'#f3f1ec', metallic:0.0, rough:0.16, cc:0.7, cci:0.55, swatch:'#f3f1ec', note:'注射成型后抛光,莫氏 8.5'},
|
|
|
|
|
+ 'eink-gray': {name:'E-Ink 珍珠灰', albedo:'#c9cbc6', metallic:0.0, rough:0.72, cc:0.0, cci:0.0, swatch:'#c9cbc6', note:'墨水屏可视区,几乎无反射'},
|
|
|
|
|
+ 'resin-clear':{name:'医用环氧树脂', albedo:'#e4e8ea', metallic:0.0, rough:0.20, cc:0.5, cci:0.45, swatch:'#e4e8ea', alpha:0.62, note:'戒指内衬,生物相容'}
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+/* 内固定材质(不参与材质切换) */
|
|
|
|
|
+const FIXED_MATS = {
|
|
|
|
|
+ glass: {albedo:'#070b10', metallic:0.3, rough:0.06, cc:0.9, cci:0.6},
|
|
|
|
|
+ pcb: {albedo:'#071d17', metallic:0.08, rough:0.78, env:0.28},
|
|
|
|
|
+ pcbDark:{albedo:'#0b1620', metallic:0.15, rough:0.62, env:0.3},
|
|
|
|
|
+ cell: {albedo:'#2b3138', metallic:0.15, rough:0.72},
|
|
|
|
|
+ brass: {albedo:'#b08d57', metallic:1.0, rough:0.34},
|
|
|
|
|
+ dark: {albedo:'#12161b', metallic:0.15, rough:0.5},
|
|
|
|
|
+ cut: {albedo:'#ff7a45', metallic:0.0, rough:0.55, alpha:0.42},
|
|
|
|
|
+ inner: {albedo:'#9c8368', metallic:1.0, rough:0.45, env:0.9}, // 嵌件 / 铜螺母镀镍 / 内衬骨架
|
|
|
|
|
+ glow: {albedo:'#ffb26a', metallic:0.0, rough:0.4, env:0.2}, // 氛围灯(emissive 由 glow 件自身的 emissiveColor 决定)
|
|
|
|
|
+ hinge: {albedo:'#8c929a', metallic:1.0, rough:0.30, env:1.0}, // 不锈钢铰链
|
|
|
|
|
+ titanium:{albedo:'#b9bec4', metallic:1.0, rough:0.38, env:1.0}, // 钛记忆丝
|
|
|
|
|
+ rubber: {albedo:'#2a2d31', metallic:0.0, rough:0.78, env:0.3}, // 振子贴合硅胶
|
|
|
|
|
+ magnet: {albedo:'#3a3f46', metallic:1.0, rough:0.40, env:0.8}, // 钕铁硼(镀镍)
|
|
|
|
|
+ acrylic:{albedo:'#e8f0f6', metallic:0.0, rough:0.05, alpha:0.30, env:1.0} // 充电舱透明罩
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+/* ---------------- 三个项目 ---------------- */
|
|
|
|
|
+const PROJECTS = {
|
|
|
|
|
+ silicone: {
|
|
|
|
|
+ id:'silicone', name:'小恶魔硅胶表壳', en:'SILICONE WATCH CASE',
|
|
|
|
|
+ ref:'HUAWEI GT4 / GT5 41mm · 双色拼色',
|
|
|
|
|
+ accent:'#c993a2',
|
|
|
|
|
+ summary:'包表式硅胶保护壳:外框一体模压、顶部双立体小角、侧边表冠避让。适合小批量双色拼色试产。',
|
|
|
|
|
+ tags:['硅胶模压','双色拼色','MOQ 500'],
|
|
|
|
|
+ params:[
|
|
|
|
|
+ {k:'w', n:'内腔宽', min:30, max:48, step:0.5, def:40.5, group:'腔体'},
|
|
|
|
|
+ {k:'d', n:'内腔高', min:30, max:48, step:0.5, def:40.5, group:'腔体'},
|
|
|
|
|
+ {k:'t', n:'壁厚', min:1.2, max:4, step:0.1, def:2.4, group:'腔体'},
|
|
|
|
|
+ {k:'h', n:'总高', min:8, max:16, step:0.2, def:11.5, group:'腔体'},
|
|
|
|
|
+ {k:'r', n:'内腔圆角', min:4, max:22, step:0.5, def:13, group:'腔体'},
|
|
|
|
|
+ {k:'hh', n:'小角高度', min:1, max:14, step:0.5, def:7, group:'双角'},
|
|
|
|
|
+ {k:'hg', n:'双角间距', min:8, max:36, step:0.5, def:22, group:'双角'},
|
|
|
|
|
+ {k:'hd', n:'角底直径', min:3, max:10, step:0.2, def:5.2, group:'双角'},
|
|
|
|
|
+ {k:'cr', n:'表冠凸出', min:0, max:3, step:0.1, def:1.4, group:'侧边'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ materials:['sil-pink','sil-black','sil-mint','abs-gloss','alu-silver'],
|
|
|
|
|
+ parts:[
|
|
|
|
|
+ {id:'body', n:'硅胶壳体(空心圆角框)', q:'1', mat:'主材质', proc:'模压/液态硅胶', tol:'±0.10'},
|
|
|
|
|
+ {id:'floor', n:'底托(贴机身层)', q:'1', mat:'同壳体', proc:'同模一体', tol:'±0.10'},
|
|
|
|
|
+ {id:'hornL', n:'立体小角(左)', q:'1', mat:'B 色/同色', proc:'一体模压', tol:'±0.15'},
|
|
|
|
|
+ {id:'hornR', n:'立体小角(右)', q:'1', mat:'B 色/同色', proc:'一体模压', tol:'±0.15'},
|
|
|
|
|
+ {id:'screen', n:'屏幕视窗(透光面)', q:'1', mat:'PC 透明/裸屏', proc:'—', tol:'±0.05'},
|
|
|
|
|
+ {id:'crown', n:'表冠避让孔', q:'1', mat:'—', proc:'模压开孔', tol:'±0.15'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ steps:[
|
|
|
|
|
+ {n:'壳体出模、去毛刺', d:'硅胶模压后修边,双角与框体一体,检查双角色差 ΔE≤1.5。'},
|
|
|
|
|
+ {n:'贴底托 / 装表体', d:'表体从内腔嵌入,壁厚 2.4mm 提供回弹夹持,不靠胶水。'},
|
|
|
|
|
+ {n:'屏幕视窗对位', d:'视窗与表盘贴合,四边留 0.15mm 缓冲,避免顶屏。'},
|
|
|
|
|
+ {n:'表冠穿孔校验', d:'表冠凸出位开孔,孔径比表冠大 0.3mm,保证按压不涩。'},
|
|
|
|
|
+ {n:'手感油 / 丝印', d:'表面喷手感油(哑光),logo 丝印或镭雕在底托背面。'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ processes:[
|
|
|
|
|
+ {key:'sil-mold', n:'硅胶模压(钢模)', mold:2200, minQty:500, unit:[[500,5.2],[1000,4.2],[3000,3.4],[5000,2.9]], lead:'12~18 天', note:'双色需两套模/两次成型,模具费上浮 40%'},
|
|
|
|
|
+ {key:'vacuum', n:'真空复模(小批量验证)', mold:300, minQty:10, unit:[[10,26],[30,18],[100,12]], lead:'5~8 天', note:'硅胶模寿命 20~40 件,适合内测'},
|
|
|
|
|
+ {key:'cnc', n:'CNC 手板(ABS/铝)', mold:0, minQty:1, unit:[[1,90],[5,68],[20,46],[50,36]], lead:'3~7 天', note:'含编程调机,后处理另计'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ notes:[
|
|
|
|
|
+ '硅胶最小壁厚建议 ≥1.2mm;本款 2.4mm 属回弹夹持区,低于 1.8mm 易松脱。',
|
|
|
|
|
+ '双角若与框体同色可一次成型;双色需双料注塑或二次硫化套色,单价上浮 15%~25%。',
|
|
|
|
|
+ '表壳包表,内腔尺寸需按实机 ±0.1mm 复测,不能只按官网标称开模。'
|
|
|
|
|
+ ],
|
|
|
|
|
+ tolerance:[['内腔宽/高','±0.10'],['壁厚','±0.08'],['双角位置','±0.20'],['孔位','±0.15'],['未注公差','ISO 2768-m']],
|
|
|
|
|
+ files:['STEP(AP214,含内腔曲面)','STL(弦高 0.05mm)','2D PDF A3 三视图 + 剖视','色卡 Pantone/劳尔号']
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ recorder: {
|
|
|
|
|
+ id:'recorder', name:'AI 录音豆外壳', en:'AI RECORDER PUCK',
|
|
|
|
|
+ ref:'Φ32 磁吸挂扣 · ABS 注塑',
|
|
|
|
|
+ accent:'#8fa3bd',
|
|
|
|
|
+ summary:'圆形豆状外壳:上盖穹顶、侧挂环、四麦孔阵列、Type-C 与单键。内部为自制 PCBA + 软包电芯。',
|
|
|
|
|
+ tags:['ABS 注塑','卡扣装配','MOQ 500'],
|
|
|
|
|
+ params:[
|
|
|
|
|
+ {k:'D', n:'外径', min:24, max:46, step:0.5, def:32, group:'主体'},
|
|
|
|
|
+ {k:'H', n:'总高', min:8, max:20, step:0.2, def:11.5, group:'主体'},
|
|
|
|
|
+ {k:'t', n:'壁厚', min:1.0, max:2.6, step:0.1, def:1.6, group:'主体'},
|
|
|
|
|
+ {k:'dm', n:'穹顶弧高', min:0, max:4, step:0.1, def:1.6, group:'主体'},
|
|
|
|
|
+ {k:'ld', n:'挂环孔径', min:3, max:10, step:0.5, def:4.5, group:'挂扣'},
|
|
|
|
|
+ {k:'lh', n:'挂环长度', min:2, max:8, step:0.5, def:4, group:'挂扣'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ materials:['abs-gloss','abs-matte','abs-black','pc-clear','alu-silver','sil-black'],
|
|
|
|
|
+ parts:[
|
|
|
|
|
+ {id:'body', n:'下壳(含电池仓)', q:'1', mat:'主材质', proc:'注塑 / CNC', tol:'±0.10'},
|
|
|
|
|
+ {id:'lid', n:'上盖(穹顶+麦孔)', q:'1', mat:'主材质', proc:'注塑 / CNC', tol:'±0.10'},
|
|
|
|
|
+ {id:'loop', n:'侧挂环', q:'1', mat:'同壳体', proc:'一体/后装', tol:'±0.20'},
|
|
|
|
|
+ {id:'mic', n:'MEMS 麦孔 ×4', q:'4', mat:'—', proc:'钻孔 Ø1.0', tol:'±0.05'},
|
|
|
|
|
+ {id:'usbc', n:'Type-C 开口', q:'1', mat:'—', proc:'开孔 9.0×3.4', tol:'±0.08'},
|
|
|
|
|
+ {id:'btn', n:'功能按键', q:'1', mat:'同壳体', proc:'注塑 + 硅胶垫', tol:'±0.10'},
|
|
|
|
|
+ {id:'pcb', n:'主控板 Φ26', q:'1', mat:'FR-4', proc:'外购/自制', tol:'±0.15'},
|
|
|
|
|
+ {id:'cell', n:'软包电芯 402030', q:'1', mat:'锂电', proc:'外购 3.7V', tol:'±0.5'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ steps:[
|
|
|
|
|
+ {n:'下壳装电芯', d:'402030 软包(4.0×20×30mm)卡入电池仓,留 5% 膨胀余量。'},
|
|
|
|
|
+ {n:'PCBA 卡扣固定', d:'Φ26 主板落在 3 处限位柱上,卡扣压紧,不用螺丝。'},
|
|
|
|
|
+ {n:'焊线 / 接口', d:'电池线走 MX1.25 或焊盘,Type-C 母座对准侧开口 ±0.1。'},
|
|
|
|
|
+ {n:'上盖合模', d:'上盖与下壳卡扣环扣合,麦孔朝上,环形密封槽可加防水胶。'},
|
|
|
|
|
+ {n:'挂环 + 老化测试', d:'挂环过 5kg 静拉,整机 2h 老化 + 麦克风灵敏度抽检。'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ processes:[
|
|
|
|
|
+ {key:'abs-mold', n:'ABS 注塑(钢模)', mold:6500, minQty:500, unit:[[500,5.0],[1000,4.1],[3000,3.4],[5000,2.8]], lead:'15~20 天', note:'上下壳+按键三套模,含试模'},
|
|
|
|
|
+ {key:'vacuum', n:'真空复模', mold:300, minQty:10, unit:[[10,28],[30,19],[100,13]], lead:'5~8 天'},
|
|
|
|
|
+ {key:'cnc', n:'CNC 铝/ABS 手板', mold:0, minQty:1, unit:[[1,120],[5,86],[20,58],[50,44]], lead:'3~7 天'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ notes:[
|
|
|
|
|
+ '麦孔阵列孔径 Ø1.0,孔后需 1.5mm 声腔,孔壁不能与壳体壁厚直接贯通。',
|
|
|
|
|
+ '卡扣合模需 0.5mm 过盈 + 单边 1° 导向角,否则量产装配良率掉到 80% 以下。',
|
|
|
|
|
+ '若走公模贴牌,MOQ 可降到 200 台整机;只做外观件仍按 500 套起。'
|
|
|
|
|
+ ],
|
|
|
|
|
+ tolerance:[['外径','±0.10'],['总高','±0.15'],['麦孔','±0.05'],['Type-C 开口','±0.08'],['未注公差','ISO 2768-m']],
|
|
|
|
|
+ files:['STEP(AP214 含卡扣)','STL 上下壳分件','2D PDF 含开孔坐标表','装配示意图(爆炸序)']
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ round: {
|
|
|
|
|
+ id:'round', name:'1.85″ 圆屏铝壳', en:'ROUND LCD AL CASE',
|
|
|
|
|
+ ref:'Φ61.6 × 14.6 · 参考微雪 1.85B',
|
|
|
|
|
+ accent:'#aab6c4',
|
|
|
|
|
+ summary:'电子吧唧造型:前框沉台固定 1.85″ 圆屏、后盖旋合、四颗 M2 铜柱锁板、侧边双麦与 Type-C。',
|
|
|
|
|
+ tags:['6061 CNC','沉台 ±0.03','阳极氧化'],
|
|
|
|
|
+ params:[
|
|
|
|
|
+ {k:'D', n:'外径', min:50, max:72, step:0.2, def:61.6, group:'主体'},
|
|
|
|
|
+ {k:'H', n:'总厚', min:11, max:20, step:0.2, def:14.6, group:'主体'},
|
|
|
|
|
+ {k:'t', n:'壁厚', min:1.4, max:3.2, step:0.1, def:2.0, group:'主体'},
|
|
|
|
|
+ {k:'sd', n:'屏可视径', min:38, max:54, step:0.2, def:45.68, group:'屏幕'},
|
|
|
|
|
+ {k:'bd', n:'黑边外径', min:44, max:58, step:0.2, def:55.0, group:'屏幕'},
|
|
|
|
|
+ {k:'dep', n:'屏边弧深(沉台R)', min:0.5, max:2.2, step:0.1, def:1.2, group:'CNC 工艺'},
|
|
|
|
|
+ {k:'rimR',n:'顶部凸圆 R(CNC)', min:0.6, max:3.4, step:0.1, def:1.8, group:'CNC 工艺'},
|
|
|
|
|
+ {k:'cham',n:'底边倒角 C(CNC)', min:0, max:1.2, step:0.1, def:0.5, group:'CNC 工艺'},
|
|
|
|
|
+ {k:'cap', n:'后盖厚', min:1.5, max:4, step:0.1, def:2.4, group:'后盖'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ materials:['alu-silver','alu-sand','alu-black','alu-rose','abs-gloss'],
|
|
|
|
|
+ parts:[
|
|
|
|
|
+ {id:'bezel', n:'前框(沉台+螺纹)', q:'1', mat:'主材质', proc:'CNC 五轴 + 阳极', tol:'±0.05'},
|
|
|
|
|
+ {id:'glass', n:'1.85″ 屏(AA Ø45.68)', q:'1', mat:'外购模组', proc:'—', tol:'±0.10'},
|
|
|
|
|
+ {id:'black', n:'黑边装饰环 Ø55', q:'1', mat:'丝印/黑膜', proc:'—', tol:'±0.10'},
|
|
|
|
|
+ {id:'cap', n:'后盖(M54×1.5 示意)', q:'1', mat:'主材质', proc:'CNC + 阳极 + 回攻', tol:'±0.05'},
|
|
|
|
|
+ {id:'boss', n:'M2 铜柱 ×4', q:'4', mat:'黄铜嵌件', proc:'CNC 攻牙/嵌件', tol:'±0.05'},
|
|
|
|
|
+ {id:'pcb', n:'主控板 Φ44', q:'1', mat:'FR-4', proc:'微雪模组', tol:'±0.2'},
|
|
|
|
|
+ {id:'cell', n:'锂电 3.7V', q:'1', mat:'软包', proc:'外购', tol:'±0.5'},
|
|
|
|
|
+ {id:'side', n:'侧键 / Type-C / 双麦', q:'1', mat:'—', proc:'开孔 + 密封', tol:'±0.08'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ steps:[
|
|
|
|
|
+ {n:'前框阳极 + 螺纹回攻', d:'阳极后 M54×1.5 必须二次回攻,否则后盖咬死。'},
|
|
|
|
|
+ {n:'屏入沉台', d:'沉台深 1.2mm,屏厚 1.0mm + 0.2mm 缓冲垫;深 0.1mm 即顶屏。'},
|
|
|
|
|
+ {n:'主板锁铜柱', d:'4×M2 铜柱同轴度 ≤0.05,板与壳间加绝缘垫避天线。'},
|
|
|
|
|
+ {n:'电池 + 走线', d:'电芯贴后盖,FPC 走侧槽,避开金属腔体谐振点。'},
|
|
|
|
|
+ {n:'后盖旋合', d:'M54×1.5 旋 2.5 圈到位,做 0.5m 跌落与气密抽检。'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ processes:[
|
|
|
|
|
+ {key:'cnc-alu', n:'CNC 铝 6061(手板)', mold:0, minQty:1, unit:[[1,135],[5,98],[20,72],[50,58],[200,48]], lead:'5~10 天', note:'含编程,阳极 10~15 元/套另计'},
|
|
|
|
|
+ {key:'cnc-abs', n:'CNC ABS(验证用)', mold:0, minQty:1, unit:[[1,85],[5,60],[20,38],[50,28]], lead:'3~6 天', note:'螺纹易滑牙,不建议做量产件'},
|
|
|
|
|
+ {key:'die-cast',n:'压铸铝 + CNC 精修', mold:12000, minQty:1000, unit:[[1000,32],[3000,26],[5000,22]], lead:'25~35 天', note:'量产路径,需评估壁厚与阳极'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ notes:[
|
|
|
|
|
+ '沉台深度公差 ±0.03 是整件成本核心,检测需三坐标或专用检具。',
|
|
|
|
|
+ '铝合金外壳会屏蔽 2.4G,天线区域必须开非金属窗或做塑胶拼接。',
|
|
|
|
|
+ '螺纹后盖在小批量下报废率高(15%~25%),可改 4×M2 螺丝锁盖降本 15~25 元/套。'
|
|
|
|
|
+ ],
|
|
|
|
|
+ tolerance:[['外径','±0.05'],['总厚','±0.10'],['沉台深','±0.03'],['铜柱同轴','≤0.05'],['螺纹','M54×1.5-6H(示意)']],
|
|
|
|
|
+ files:['STEP(AP214,含螺纹实体)','STL 分件','2D PDF 关键尺寸 + GD&T','阳极色板 / 膜厚要求']
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+/* ---------------- 电子件库 ---------------- */
|
|
|
|
|
+const BOARDS = [
|
|
|
|
|
+ {
|
|
|
|
|
+ id:'ws185', name:'微雪 ESP32-S3-Touch-LCD-1.85B', tag:'首选 · 成品模组',
|
|
|
|
|
+ od:'Ø61.6 × 14.6', screen:'1.85″ 圆屏 360×360', iface:'QSPI 屏 / I2C 触摸 / Type-C',
|
|
|
|
|
+ soc:'ESP32-S3R8 · 240MHz · 8MB PSRAM · 16MB Flash',
|
|
|
|
|
+ extra:'ES8311 编解码 + ES7210 回声消除 + 双麦阵列 + QMI8658 六轴 + BQ27220 电量 + PCF85063 RTC + MicroSD + MX1.25 电池口 + SH1.0×2',
|
|
|
|
|
+ price:'¥208.06 起(1 件,含税)', fit:'round',
|
|
|
|
|
+ note:'官方尺寸 Ø61.60 / Ø55.00 / 屏 AA Ø45.68 / 厚 14.60。带壳整机,直接拆壳复用最省事。',
|
|
|
|
|
+ source:'waveshare.net / docs.waveshare.net'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id:'ws128', name:'GC9A01 1.28″ 圆屏 + ESP32-S3 底板', tag:'低成本替代',
|
|
|
|
|
+ od:'Ø32.4 屏 / 底板 40×40(参考)', screen:'1.28″ 240×240', iface:'SPI 屏 / I2C',
|
|
|
|
|
+ soc:'ESP32-S3-WROOM-1(18×25.5×3.1)',
|
|
|
|
|
+ extra:'需自配麦克风与功放;无成品壳,需自己做结构',
|
|
|
|
|
+ price:'屏 ¥18~28 / 底板 ¥35~60', fit:'recorder',
|
|
|
|
|
+ note:'尺寸为常见模组值,采购前以实际规格书核对;适合做 Φ32 录音豆的主板。',
|
|
|
|
|
+ source:'通用模组,需核对'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id:'esp32s3', name:'ESP32-S3-WROOM-1 模组', tag:'核心件',
|
|
|
|
|
+ od:'18.0 × 25.5 × 3.1', screen:'—', iface:'2.4G WiFi + BLE5',
|
|
|
|
|
+ soc:'双核 LX7 240MHz · 8MB PSRAM 选配',
|
|
|
|
|
+ extra:'需底板:电源、麦克风、功放、充电管理',
|
|
|
|
|
+ price:'¥18~30', fit:'recorder',
|
|
|
|
|
+ note:'天线净空区 15mm 内不得有金属/电池,壳体需留塑胶窗。',
|
|
|
|
|
+ source:'Espressif 数据手册'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id:'mic', name:'INMP441 I2S MEMS 麦克风', tag:'拾音',
|
|
|
|
|
+ od:'15 × 14(模块,参考)', screen:'—', iface:'I2S',
|
|
|
|
|
+ soc:'—', extra:'信噪比 61dB,灵敏度 -26dBFS',
|
|
|
|
|
+ price:'¥5~9', fit:'recorder',
|
|
|
|
|
+ note:'麦孔 Ø1.0 + 后腔 1.5mm;四麦阵列间距建议 ≥8mm 做波束。',
|
|
|
|
|
+ source:'模块规格,需核对'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id:'amp', name:'MAX98357A I2S 功放', tag:'发声',
|
|
|
|
|
+ od:'模块 15 × 15(参考)', screen:'—', iface:'I2S + 2.5W',
|
|
|
|
|
+ soc:'—', extra:'D 类,需 8Ω 腔体喇叭',
|
|
|
|
|
+ price:'¥8~15', fit:'recorder',
|
|
|
|
|
+ note:'腔体扬声器与麦孔要隔离,否则回声消除压力大。',
|
|
|
|
|
+ source:'模块规格,需核对'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id:'cell402030', name:'软包锂电 402030', tag:'供电',
|
|
|
|
|
+ od:'4.0 × 20 × 30(厚×宽×长)', screen:'—', iface:'3.7V / 约 180~220mAh',
|
|
|
|
|
+ soc:'—', extra:'需保护板 + MX1.25 或焊线',
|
|
|
|
|
+ price:'¥6~10', fit:'recorder',
|
|
|
|
|
+ note:'留 5% 膨胀空间,远离发热器件 2mm 以上。',
|
|
|
|
|
+ source:'常见规格,需核对'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id:'cell103450', name:'软包锂电 103450', tag:'供电',
|
|
|
|
|
+ od:'10 × 34 × 50', screen:'—', iface:'3.7V / 约 1800~2000mAh',
|
|
|
|
|
+ soc:'—', extra:'适用 Φ61 圆屏机',
|
|
|
|
|
+ price:'¥12~18', fit:'round',
|
|
|
|
|
+ note:'厚度 10mm + 结构件,Φ61.6 / 14.6 机身内需精确排布。',
|
|
|
|
|
+ source:'常见规格,需核对'
|
|
|
|
|
+ }
|
|
|
|
|
+];
|
|
|
|
|
+
|
|
|
|
|
+/* ---------------- 知识库 ---------------- */
|
|
|
|
|
+const KB = [
|
|
|
|
|
+ {
|
|
|
|
|
+ id:'process', ix:'01', title:'七种壳体工艺对照(MOQ / 模具 / 单价 / 交期)',
|
|
|
|
|
+ body:[
|
|
|
|
|
+ ['table', ['工艺','典型 MOQ','一次性费用','单价区间','交期','适用'],[
|
|
|
|
|
+ ['硅胶模压(钢模)','500 套','¥1,800~3,500','¥2.5~6/套','12~18 天','量产软壳、包表、双色拼色'],
|
|
|
|
|
+ ['ABS/PC 注塑(钢模)','500 套','¥5,500~9,000','¥2.8~6/套','15~20 天','硬壳量产,外观件首选'],
|
|
|
|
|
+ ['压铸铝 + CNC','1,000 套','¥10,000~22,000','¥22~32/套','25~35 天','金属量产,需评估阳极'],
|
|
|
|
|
+ ['CNC 手板(铝/ABS)','1 件','无模具,收编程调机','¥28~135/套','3~10 天','样机、内测、小批量'],
|
|
|
|
|
+ ['真空复模(硅胶模)','10 件','¥200~400','¥12~28/套','5~8 天','10~100 件验证'],
|
|
|
|
|
+ ['3D 打印(SLA/FDM)','1 件','无','¥20~60/套','2~4 天','结构验证,不做外观件'],
|
|
|
|
|
+ ['公模贴牌','100~200 件','无','¥3~8/套','7~12 天','已有模具,只改色/丝印']
|
|
|
|
|
+ ]],
|
|
|
|
|
+ ['p','判断口径:一次性费用 ÷ 数量 + 单品价 = 单套综合成本。数量过 200~300 套后,CNC 的总成本通常反超「开模 + 注塑」。']
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id:'formats', ix:'02', title:'生产端到底要哪些文件格式(按工艺给清单)',
|
|
|
|
|
+ body:[
|
|
|
|
|
+ ['table', ['格式','用途','要给谁','注意'],[
|
|
|
|
|
+ ['STEP AP214/AP203','3D 实体,含曲面与螺纹','模具厂 / CNC 编程','首选。必须带内腔、卡扣、螺纹实体,不能只给网格'],
|
|
|
|
|
+ ['STL(弦高 0.05mm)','网格,快速评估与 3D 打印','手板厂 / 打印','只用于看形,不能直接开钢模'],
|
|
|
|
|
+ ['3MF','打印用,含颜色与单位','3D 打印','比 STL 稳,少破面'],
|
|
|
|
|
+ ['OBJ','带材质分组的网格','渲染 / 展示','不适合生产'],
|
|
|
|
|
+ ['DXF','2D 轮廓 / 开孔坐标','线切割、开孔','配合 2D 图纸使用'],
|
|
|
|
|
+ ['PDF A3 2D 图纸','三视图 + 剖视 + 尺寸 + GD&T','所有人','1:1 打印,标基准 A/B/C'],
|
|
|
|
|
+ ['BOM / CSV','零件、材质、数量、工艺','采购 / 报价','报价必须逐项回填'],
|
|
|
|
|
+ ['色卡 / 膜厚要求','阳极色号、Pantone、Ra','表面处理厂','不给色号一定返工']
|
|
|
|
|
+ ]],
|
|
|
|
|
+ ['p','给工厂的最小闭环:STEP + 2D PDF + 需求单(材质/工艺/公差/数量/表面处理)。只给 STL 或只给图片,正规厂会直接判定为「无法报价」。']
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id:'draw', ix:'03', title:'2D 图纸标注规范(手机端也能看懂的最小集)',
|
|
|
|
|
+ body:[
|
|
|
|
|
+ ['ul',[
|
|
|
|
|
+ '基准:主基准 A(底面)、B/C(两互相垂直的边或中心线),铜柱与孔位全部相对基准标注。',
|
|
|
|
|
+ '关键尺寸:沉台深、螺纹规格、壁厚、孔位坐标、装配间隙,逐项给公差。',
|
|
|
|
|
+ '未注公差:ABS/硅胶 ISO 2768-m;CNC 金属建议 ±0.1 或 2768-f。',
|
|
|
|
|
+ '形位公差:铜柱同轴度 ≤0.05,平面度 0.1,沉台对基准面平行度 0.05。',
|
|
|
|
|
+ '表面:Ra 标注(CNC 铝 Ra1.6,喷砂 Ra3.2),阳极膜厚 10~15μm。',
|
|
|
|
|
+ '螺纹:M54×1.5-6H(示意);标注「阳极后二次回攻」字样。',
|
|
|
|
|
+ '去毛刺、倒角 C0.3、脱模斜度 1°~2°,写在技术要求里而不是画在图上。'
|
|
|
|
|
+ ]],
|
|
|
|
|
+ ['note','本项目导出的是「需求描述单 + STL/OBJ + 尺寸表」,够工厂报价和评估;正式开模仍需要 STEP 或由工厂按图建模(建模费 ¥500~1,500)。']
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id:'dfm', ix:'04', title:'DFM 检查清单(开模前逐条过)',
|
|
|
|
|
+ body:[
|
|
|
|
|
+ ['table', ['项目','经验值','违反后果'],[
|
|
|
|
|
+ ['ABS 壁厚','1.2~2.0mm,均匀','缩水、变形、装配错位'],
|
|
|
|
|
+ ['硅胶壁厚','≥1.2mm,回弹区 2~3mm','夹持松脱、撕裂'],
|
|
|
|
|
+ ['拔模斜度','1°~2°(纹理面 3°)','拉伤、顶白'],
|
|
|
|
|
+ ['内圆角','≥0.5×壁厚','应力集中、开裂'],
|
|
|
|
|
+ ['卡扣','过盈 0.3~0.5mm + 1° 导向','装配良率 <80%'],
|
|
|
|
|
+ ['螺丝柱','M2 外径 Φ4.0,内孔 Φ1.6','滑牙、缩水'],
|
|
|
|
|
+ ['沉台','深公差 ±0.03,圆角 R0.2','顶碎屏 / 漏光'],
|
|
|
|
|
+ ['天线净空','15mm 内无金属与电池','WiFi 掉到 -75dBm'],
|
|
|
|
|
+ ['密封','槽宽 1.0 + 0.5mm 压缩量','气密不过'],
|
|
|
|
|
+ ['脱模','顶针位避开外观面','顶白不可修']
|
|
|
|
|
+ ]]
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id:'cost', ix:'05', title:'报价谈判口径(怎么问才不被糊)',
|
|
|
|
|
+ body:[
|
|
|
|
|
+ ['ul',[
|
|
|
|
|
+ '先问「模具费是否含试模、改模几次、模具归属」,不接受「模具费摊在单价里」的模糊说法。',
|
|
|
|
|
+ '要求分项:材料费 / 加工费 / 表面处理 / 包装 / 模具 / 打样,一口价无法比价。',
|
|
|
|
|
+ '问清 MOQ 是「模具起订」还是「后处理开机费」。喷油、阳极常有 20 件开机门槛。',
|
|
|
|
|
+ '问清公差是按图纸全检还是抽检,首件是否提供三坐标报告。',
|
|
|
|
|
+ '小批量先做手板(CNC/复模),确认装配与手感后再投钢模,避免 ¥6,500 打水漂。',
|
|
|
|
|
+ '报价单必须写有效期与含税/不含税,模具费通常单独开票。'
|
|
|
|
|
+ ]]
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id:'elec', ix:'06', title:'电子件选型原则:先用成熟开发板,别自己打板',
|
|
|
|
|
+ body:[
|
|
|
|
|
+ ['p','这一轮产品(录音豆 / 圆屏吧唧 / 表壳配件)全部走「成熟模组 + 焊接/接插件 + 结构固定」,把 PCB 风险降到最低。'],
|
|
|
|
|
+ ['ul',[
|
|
|
|
|
+ '圆屏机直接复用微雪 1.85B 整机:屏、触摸、双麦、功放、IMU、电量、RTC、Type-C、锂电口全部现成,只做外壳替换。',
|
|
|
|
|
+ '录音豆用 ESP32-S3-WROOM-1 + INMP441 + MAX98357A + TP4056 + 402030 电芯,飞线或洞洞板即可完成原型。',
|
|
|
|
|
+ '需要量产再把模组方案转成邮票孔底板(仍不打主控板),单板成本可压到 ¥25~40。',
|
|
|
|
|
+ '结构件必须给电子件留「装配余量 + 天线净空 + 声腔」,否则外壳做完装不进去。',
|
|
|
|
|
+ '接口固定优先卡扣/限位柱,其次 M2 螺丝;能不用胶就不用胶。'
|
|
|
|
|
+ ]],
|
|
|
|
|
+ ['note','电子件尺寸一律以官方图纸为准;本项目内的尺寸用于排布预演,打样前需实测。']
|
|
|
|
|
+ ]
|
|
|
|
|
+ }
|
|
|
|
|
+];
|
|
|
|
|
+
|
|
|
|
|
+KB.push({
|
|
|
|
|
+ id:'surface', ix:'07', title:'表面处理:阳极 / 喷油 / 镭雕怎么选',
|
|
|
|
|
+ body:[
|
|
|
|
|
+ ['table',['工艺','效果','成本','注意'],[
|
|
|
|
|
+ ['阳极氧化(铝)','金属质感、耐磨、绝缘','¥6~15/套(含前处理)','颜色批次色差 ΔE≤1.5;螺纹需二次回攻;膜厚 10~15μm'],
|
|
|
|
|
+ ['喷砂 + 阳极','细腻哑光金属','¥3~8/套 加价','砂号 120#~220#,同一批统一喷砂压力'],
|
|
|
|
|
+ ['喷橡胶漆(ABS)','类肤手感、遮缩水','¥1.5~3/套','耐磨 500g/100 次;边角易露底'],
|
|
|
|
|
+ ['UV 高光(ABS)','局部亮面','¥0.8~2/套','需专用治具,小批量分摊高'],
|
|
|
|
|
+ ['丝印 / 移印','logo、刻度','¥0.5~1.5/处','最小线宽 0.15,套色 ≤4 色'],
|
|
|
|
|
+ ['镭雕','永久标识、细字','¥0.3~0.8/处','浅色底要打深色底漆才清晰']
|
|
|
|
|
+ ]],
|
|
|
|
|
+ ['note','表面处理常有最小开机批次(喷油 20 件、阳极 50 件)。数量不足时会被收整批开机费,这也是「CNC 件突然报 MOQ」的常见原因。']
|
|
|
|
|
+ ]
|
|
|
|
|
+});
|
|
|
|
|
+KB.push({
|
|
|
|
|
+ id:'timeline', ix:'08', title:'从创意到量产的 6 个里程碑',
|
|
|
|
|
+ body:[
|
|
|
|
|
+ ['ul',[
|
|
|
|
|
+ 'M1 概念锁定:定外形尺寸、材质、装配方式,产出参数快照(本工具即可)。',
|
|
|
|
|
+ 'M2 手板验证:CNC/复模 1~5 套,装电子件实测干涉、手感、天线。',
|
|
|
|
|
+ 'M3 图纸冻结:补 STEP、2D 图纸、公差与 GD&T,供应商 DFM 回签。',
|
|
|
|
|
+ 'M4 开模试模:T1 试模件确认缩水/变形,T2 修模后做首件报告。',
|
|
|
|
|
+ 'M5 小批试产:50~200 套,跑装配良率与老化,锁定工艺参数。',
|
|
|
|
|
+ 'M6 量产:MOQ 起订,按 AQL 抽检,模具与治具归档。'
|
|
|
|
|
+ ]],
|
|
|
|
|
+ ['p','关键卡点:M2 不做就直接开模,是 80% 外观件返工的原因;M3 不给 STEP 只给图片,正规厂不会接。']
|
|
|
|
|
+ ]
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+KB.push({
|
|
|
|
|
+ id:'model', ix:'09', title:'工艺化轻量建模:为什么「自由雕刻」要按工艺分规则',
|
|
|
|
|
+ body:[
|
|
|
|
|
+ ['p','网页端没有实体布尔运算(不开 CSG 是怕曲面炸开),所以建模走「参数化主体 + 附加结构体」:主体由尺寸参数定义,内部筋、铜柱、开槽、开孔以独立结构件叠加,位置用毫米数值 + 吸附精确控制。'],
|
|
|
|
|
+ ['table',['工艺','自由度','必须在模型里标出来的东西'],
|
|
|
|
|
+ [['注塑 / 硅胶','高:筋、柱、槽都能加','拔模角、最小壁厚、筋厚、圆角、缩水率'],
|
|
|
|
|
+ ['CNC 铝','中:以减料为主','刀具半径(内角 R)、最小壁厚、深腔比、螺纹规格、基准与公差'],
|
|
|
|
|
+ ['真空复模','中:同注塑但更自由','收缩补偿 0.3%、壁厚 ≥1.2'],
|
|
|
|
|
+ ['压铸','低:拔模与料位受限','拔模 ≥1.5°、料位/渣包、后加工余量']]],
|
|
|
|
|
+ ['ul',[
|
|
|
|
|
+ '吸附口径:位置吸附 0.5 / 1 / 5 mm;「贴内壁」按内腔边界自动算 x/z,不留手算误差。',
|
|
|
|
|
+ '每加一个结构件都要能报出:位置(x,y,z)、外形尺寸、壁厚/筋厚、与内腔的余量。',
|
|
|
|
|
+ '余量 < 1mm 的结构件,注塑会粘模、CNC 会让刀,模型阶段就要报警。',
|
|
|
|
|
+ '导出时结构件随主体一起进 STL/OBJ,并在需求单里单列坐标表,工厂才能照着做。'
|
|
|
|
|
+ ]],
|
|
|
|
|
+ ['note','轻量建模的边界:能做「外形 + 内部支撑结构 + 开孔标记」,不能做真实刀路与模流分析;定稿仍要 STEP + 2D 图纸。']
|
|
|
|
|
+ ]
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+const REFS = [
|
|
|
|
|
+ {
|
|
|
|
|
+ id:'wx1', n:'微信公众号文章(待补录全文)',
|
|
|
|
|
+ u:'https://mp.weixin.qq.com/s/9mUdMT78YCpWuuqDSKU5QQ',
|
|
|
|
|
+ d:'该链接对自动抓取有 robots 限制,无法在网页端直接取回正文。已保留原始链接,并提供手动粘贴录入入口,录入后长期保存在本机。',
|
|
|
|
|
+ tag:'参考文章'
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id:'db1', n:'豆包对话记录(本项目前期讨论)',
|
|
|
|
|
+ u:'https://www.doubao.com/thread/xRkAJOJE74pwLYX2H',
|
|
|
|
|
+ d:'前期关于硅胶壳 / 录音豆 / 圆屏铝壳的 MOQ、CNC 与注塑报价讨论原始记录。',
|
|
|
|
|
+ tag:'对话存档'
|
|
|
|
|
+ }
|
|
|
|
|
+];
|
|
|
|
|
+/* =========================================================
|
|
|
|
|
+ 几何引擎:参数化壳体 + 材质 + 爆炸图 + 标注 + 导出
|
|
|
|
|
+ 1 单位 = 1 mm
|
|
|
|
|
+ ========================================================= */
|
|
|
|
|
+
|
|
|
|
|
+export /**
|
|
|
|
|
+ * STAGE —— 3D 建模与渲染引擎(移植自壳体工坊 v2.0,FmodeCode)
|
|
|
|
|
+ * 含 MATERIALS / FIXED_MATS / PROJECTS 与建模、爆炸、材质、标注、导出能力。
|
|
|
|
|
+ * 阶段 F:在原有三款基础上补齐五款产品的专属建模(ai-pin / eink-tag / pocket-ai / bone-headset / smart-ring)。
|
|
|
|
|
+ */
|
|
|
|
|
+const STAGE = (function(){
|
|
|
|
|
+ const B = typeof BABYLON!=='undefined' ? BABYLON : (globalThis.BABYLON||{});
|
|
|
|
|
+ const V3 = function(x,y,z){ return new B.Vector3(x,y,z); };
|
|
|
|
|
+
|
|
|
|
|
+ let engine=null, scene=null, camera=null, ground=null, root=null, dimRoot=null, shadowMat=null;
|
|
|
|
|
+ let host=null, canvas=null, readyFlag=false, pending=null;
|
|
|
|
|
+ let labels=[], labelEls=[];
|
|
|
|
|
+ const matCache={}, fixedCache={};
|
|
|
|
|
+ let cur={ project:'silicone', params:{}, material:'', explode:0, dims:true, cutForce:false, glow:false };
|
|
|
|
|
+ let parts=[];
|
|
|
|
|
+ let customMap={}, cutaway=false, selCb=null, dragCb=null, custUid=1, solo=null;
|
|
|
|
|
+ const grainTex={};
|
|
|
|
|
+ const BIP={dirty:true};
|
|
|
|
|
+
|
|
|
|
|
+ /* ---------------- 材质 ---------------- */
|
|
|
|
|
+ function pbr(key,cfg){
|
|
|
|
|
+ if(matCache[key]) return matCache[key];
|
|
|
|
|
+ const m=new B.PBRMaterial('mat-'+key,scene);
|
|
|
|
|
+ m.albedoColor=B.Color3.FromHexString(cfg.albedo);
|
|
|
|
|
+ /* PBR 无缝微表面(喷砂 / 类肤颗粒):程序化归一化噪声 bump,零贴图文件 */
|
|
|
|
|
+ if(cfg.grain){
|
|
|
|
|
+ if(!grainTex.g){
|
|
|
|
|
+ const size=256, dt=new B.DynamicTexture('grain',{width:size,height:size},scene,false);
|
|
|
|
|
+ const ctx=dt.getContext(), img=ctx.createImageData(size,size);
|
|
|
|
|
+ let seed=7;
|
|
|
|
|
+ for(let i=0;i<size*size;i++){
|
|
|
|
|
+ seed=(seed*1664525+1013904223)>>>0;
|
|
|
|
|
+ const v=110+((seed>>>24)&0x7f);
|
|
|
|
|
+ img.data[i*4]=v; img.data[i*4+1]=v; img.data[i*4+2]=v; img.data[i*4+3]=255;
|
|
|
|
|
+ }
|
|
|
|
|
+ ctx.putImageData(img,0,0); dt.update(); dt.uScale=14; dt.vScale=14;
|
|
|
|
|
+ grainTex.g=dt;
|
|
|
|
|
+ }
|
|
|
|
|
+ m.bumpTexture=grainTex.g;
|
|
|
|
|
+ m.bumpTexture.level=cfg.grain;
|
|
|
|
|
+ }
|
|
|
|
|
+ m.metallic=cfg.metallic!==undefined?cfg.metallic:0;
|
|
|
|
|
+ m.roughness=cfg.rough!==undefined?cfg.rough:0.5;
|
|
|
|
|
+ if(cfg.cc!==undefined){
|
|
|
|
|
+ m.clearCoat.isEnabled=true;
|
|
|
|
|
+ m.clearCoat.intensity=cfg.cc;
|
|
|
|
|
+ m.clearCoat.roughness=Math.max(0.03,1-(cfg.cci||0.35));
|
|
|
|
|
+ }
|
|
|
|
|
+ if(cfg.alpha!==undefined){
|
|
|
|
|
+ m.alpha=cfg.alpha;
|
|
|
|
|
+ m.transparencyMode=B.Material.MATERIAL_ALPHABLEND;
|
|
|
|
|
+ }
|
|
|
|
|
+ m.environmentIntensity=cfg.env!==undefined?cfg.env:(cfg.grain?0.85:1.0);
|
|
|
|
|
+ m.backFaceCulling=false;
|
|
|
|
|
+ matCache[key]=m;
|
|
|
|
|
+ return m;
|
|
|
|
|
+ }
|
|
|
|
|
+ /* 键帽:同色系亮一档的 PBR(双色注塑),与主材质同一质感语言 */
|
|
|
|
|
+ function keyMat(useKey){
|
|
|
|
|
+ const kk='key-'+useKey;
|
|
|
|
|
+ if(matCache[kk]) return matCache[kk];
|
|
|
|
|
+ const src=MATERIALS[useKey]||MATERIALS['abs-matte'];
|
|
|
|
|
+ const c=B.Color3.FromHexString(src.albedo);
|
|
|
|
|
+ const lift=(src.metallic>0.5)?0.06:0.20;
|
|
|
|
|
+ const hx=v=>Math.round(Math.min(1,v+lift)*255).toString(16).padStart(2,'0');
|
|
|
|
|
+ return pbr(kk,{albedo:'#'+hx(c.r)+hx(c.g)+hx(c.b),metallic:src.metallic||0,rough:Math.max(0.32,(src.rough||0.5)+0.05),cc:0.3,cci:0.4,grain:0.12});
|
|
|
|
|
+ }
|
|
|
|
|
+ /* 墨水屏:PBR,但几乎不反射环境(真实墨屏的漫反射特性) */
|
|
|
|
|
+ function inkMat(){
|
|
|
|
|
+ if(matCache['fx-ink']) return matCache['fx-ink'];
|
|
|
|
|
+ const m=pbr('fx-ink',MATERIALS['eink-gray']);
|
|
|
|
|
+ m.environmentIntensity=0.12;
|
|
|
|
|
+ return m;
|
|
|
|
|
+ }
|
|
|
|
|
+ function fixed(key){
|
|
|
|
|
+ if(fixedCache[key]) return fixedCache[key];
|
|
|
|
|
+ fixedCache[key]=pbr('fx-'+key, FIXED_MATS[key]);
|
|
|
|
|
+ return fixedCache[key];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* 半透明「透视」材质:爆炸/剖视时让内部结构可见 */
|
|
|
|
|
+ function ghost(key){
|
|
|
|
|
+ const gk='gh-'+key;
|
|
|
|
|
+ if(matCache[gk]) return matCache[gk];
|
|
|
|
|
+ const src=MATERIALS[key]||MATERIALS[PROJECTS[cur.project].materials[0]];
|
|
|
|
|
+ const cfg=Object.assign({},src,{alpha:0.30,env:0.2,cc:0.05});
|
|
|
|
|
+ return pbr(gk,cfg);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* ---------------- 2D 轮廓 ---------------- */
|
|
|
|
|
+ function roundedPath(w,h,r,seg){
|
|
|
|
|
+ const hw=w/2,hh=h/2;
|
|
|
|
|
+ r=Math.max(0.05,Math.min(r,Math.min(hw,hh)-0.02));
|
|
|
|
|
+ const pts=[];
|
|
|
|
|
+ const corners=[
|
|
|
|
|
+ {cx:hw-r,cz:hh-r,a0:0},
|
|
|
|
|
+ {cx:-(hw-r),cz:hh-r,a0:90},
|
|
|
|
|
+ {cx:-(hw-r),cz:-(hh-r),a0:180},
|
|
|
|
|
+ {cx:hw-r,cz:-(hh-r),a0:270}
|
|
|
|
|
+ ];
|
|
|
|
|
+ for(const c of corners){
|
|
|
|
|
+ for(let i=0;i<seg;i++){
|
|
|
|
|
+ const a=(c.a0+90*i/seg)*Math.PI/180;
|
|
|
|
|
+ pts.push({x:c.cx+r*Math.cos(a),z:c.cz+r*Math.sin(a)});
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return pts;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function radialN(p){ const l=Math.hypot(p.x,p.z)||1; return V3(p.x/l,0,p.z/l); }
|
|
|
|
|
+
|
|
|
|
|
+ function assemble(name,chunks,parent){
|
|
|
|
|
+ const pos=[],idx=[],nrm=[];
|
|
|
|
|
+ let base=0;
|
|
|
|
|
+ chunks.forEach(ch=>{
|
|
|
|
|
+ ch.p.forEach(v=>pos.push(v.x,v.y,v.z));
|
|
|
|
|
+ ch.n.forEach(v=>nrm.push(v.x,v.y,v.z));
|
|
|
|
|
+ ch.i.forEach(i=>idx.push(i+base));
|
|
|
|
|
+ base+=ch.p.length;
|
|
|
|
|
+ });
|
|
|
|
|
+ const vd=new B.VertexData();
|
|
|
|
|
+ vd.positions=pos; vd.indices=idx; vd.normals=nrm;
|
|
|
|
|
+ const mesh=new B.Mesh(name,scene);
|
|
|
|
|
+ vd.applyToMesh(mesh);
|
|
|
|
|
+ if(parent) mesh.parent=parent;
|
|
|
|
|
+ return mesh;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* 环带(上下两个同点数轮廓) */
|
|
|
|
|
+ function ringStrip(ringA,yA,ringB,yB,nf){
|
|
|
|
|
+ const N=ringA.length,p=[],n=[],i=[];
|
|
|
|
|
+ for(let k=0;k<N;k++){
|
|
|
|
|
+ const a=ringA[k],b=ringB[k];
|
|
|
|
|
+ p.push(V3(a.x,yA,a.z),V3(b.x,yB,b.z));
|
|
|
|
|
+ n.push(nf(a,true),nf(b,false));
|
|
|
|
|
+ }
|
|
|
|
|
+ for(let k=0;k<N;k++){
|
|
|
|
|
+ const a1=k*2,b1=k*2+1,a2=((k+1)%N)*2,b2=((k+1)%N)*2+1;
|
|
|
|
|
+ i.push(a1,a2,b2,a1,b2,b1);
|
|
|
|
|
+ }
|
|
|
|
|
+ return {p,n,i};
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* 空心圆角框(表壳类) */
|
|
|
|
|
+ function hollowFrame(name,spec,parent){
|
|
|
|
|
+ const {ow,od,orr,iw,id,irr,y0,y1,chamfer,seg}=spec;
|
|
|
|
|
+ const A=roundedPath(ow,od,orr,seg);
|
|
|
|
|
+ const B2=roundedPath(ow,od,orr,seg); // 原名 Bc 会与模块级 const B = BABYLON 冲突(重复声明 → 整个模块语法错误)
|
|
|
|
|
+ const C=roundedPath(Math.max(1,ow-2*chamfer),Math.max(1,od-2*chamfer),Math.max(0.2,orr-chamfer),seg);
|
|
|
|
|
+ const D=roundedPath(iw,id,irr,seg);
|
|
|
|
|
+ const E=roundedPath(iw,id,irr,seg);
|
|
|
|
|
+ const ch=[];
|
|
|
|
|
+ ch.push(ringStrip(A,y0,B2,y1-chamfer,p=>radialN(p)));
|
|
|
|
|
+ ch.push(ringStrip(B2,y1-chamfer,C,y1,p=>{
|
|
|
|
|
+ const r=radialN(p); return V3(r.x*0.707,0.707,r.z*0.707);
|
|
|
|
|
+ }));
|
|
|
|
|
+ ch.push(ringStrip(C,y1,D,y1,()=>V3(0,1,0)));
|
|
|
|
|
+ ch.push(ringStrip(D,y1,E,y0,p=>{
|
|
|
|
|
+ const r=radialN(p); return V3(-r.x,0,-r.z);
|
|
|
|
|
+ }));
|
|
|
|
|
+ ch.push(ringStrip(E,y0,A,y0,()=>V3(0,-1,0)));
|
|
|
|
|
+ return assemble(name,ch,parent);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* 实心圆角板 */
|
|
|
|
|
+ function solidSlab(name,spec,parent){
|
|
|
|
|
+ const {w,d,r,y0,y1,seg}=spec;
|
|
|
|
|
+ const A=roundedPath(w,d,r,seg);
|
|
|
|
|
+ const ch=[];
|
|
|
|
|
+ ch.push(ringStrip(A,y0,roundedPath(w,d,r,seg),y1,p=>radialN(p)));
|
|
|
|
|
+ const tp=[V3(0,y1,0)],tn=[V3(0,1,0)],ti=[];
|
|
|
|
|
+ A.forEach(p=>{ tp.push(V3(p.x,y1,p.z)); tn.push(V3(0,1,0)); });
|
|
|
|
|
+ for(let k=0;k<A.length;k++) ti.push(0,1+k,1+((k+1)%A.length));
|
|
|
|
|
+ ch.push({p:tp,n:tn,i:ti});
|
|
|
|
|
+ const bp=[V3(0,y0,0)],bn=[V3(0,-1,0)],bi=[];
|
|
|
|
|
+ A.forEach(p=>{ bp.push(V3(p.x,y0,p.z)); bn.push(V3(0,-1,0)); });
|
|
|
|
|
+ for(let k=0;k<A.length;k++) bi.push(0,1+((k+1)%A.length),1+k);
|
|
|
|
|
+ ch.push({p:bp,n:bn,i:bi});
|
|
|
|
|
+ return assemble(name,ch,parent);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* 回转体:profile = [{r,y}] 闭合,按 CCW 给出(法线自动朝外) */
|
|
|
|
|
+ function revolve(name,profile,seg,parent){
|
|
|
|
|
+ const ch=[];
|
|
|
|
|
+ for(let k=0;k<profile.length;k++){
|
|
|
|
|
+ const p0=profile[k],p1=profile[(k+1)%profile.length];
|
|
|
|
|
+ const dr=p1.r-p0.r,dy=p1.y-p0.y,len=Math.hypot(dr,dy);
|
|
|
|
|
+ if(len<1e-4) continue;
|
|
|
|
|
+ const n2r=dy/len,n2y=-dr/len;
|
|
|
|
|
+ const pos=[],nrm=[],idx=[];
|
|
|
|
|
+ for(let j=0;j<seg;j++){
|
|
|
|
|
+ const th=j/seg*Math.PI*2, th2=((j+1)%seg)/seg*Math.PI*2;
|
|
|
|
|
+ const c0=Math.cos(th),s0=Math.sin(th),c1=Math.cos(th2),s1=Math.sin(th2);
|
|
|
|
|
+ pos.push(V3(p0.r*c0,p0.y,p0.r*s0),V3(p1.r*c0,p1.y,p1.r*s0),V3(p1.r*c1,p1.y,p1.r*s1),V3(p0.r*c1,p0.y,p0.r*s1));
|
|
|
|
|
+ nrm.push(V3(n2r*c0,n2y,n2r*s0),V3(n2r*c0,n2y,n2r*s0),V3(n2r*c1,n2y,n2r*s1),V3(n2r*c1,n2y,n2r*s1));
|
|
|
|
|
+ }
|
|
|
|
|
+ for(let j=0;j<seg;j++){
|
|
|
|
|
+ const b=j*4;
|
|
|
|
|
+ idx.push(b,b+1,b+2,b,b+2,b+3);
|
|
|
|
|
+ }
|
|
|
|
|
+ ch.push({p:pos,n:nrm,i:idx});
|
|
|
|
|
+ }
|
|
|
|
|
+ return assemble(name,ch,parent);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function arcPts(cx,cy,r,a0,a1,n){
|
|
|
|
|
+ const out=[];
|
|
|
|
|
+ for(let i=0;i<=n;i++){
|
|
|
|
|
+ const a=(a0+(a1-a0)*i/n)*Math.PI/180;
|
|
|
|
|
+ out.push({r:cx+r*Math.cos(a),y:cy+r*Math.sin(a)});
|
|
|
|
|
+ }
|
|
|
|
|
+ return out;
|
|
|
|
|
+ }
|
|
|
|
|
+ function dedupe(pts){
|
|
|
|
|
+ const out=[];
|
|
|
|
|
+ pts.forEach(p=>{
|
|
|
|
|
+ const last=out[out.length-1];
|
|
|
|
|
+ if(!last||Math.abs(last.r-p.r)>1e-4||Math.abs(last.y-p.y)>1e-4) out.push(p);
|
|
|
|
|
+ });
|
|
|
|
|
+ if(out.length>2){
|
|
|
|
|
+ const f=out[0],l=out[out.length-1];
|
|
|
|
|
+ if(Math.abs(f.r-l.r)<1e-4&&Math.abs(f.y-l.y)<1e-4) out.pop();
|
|
|
|
|
+ }
|
|
|
|
|
+ return out;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* ---------------- 场景 ---------------- */
|
|
|
|
|
+ function init(canvasEl,hostEl){
|
|
|
|
|
+ canvas=canvasEl; host=hostEl;
|
|
|
|
|
+ engine=new B.Engine(canvas,true,{preserveDrawingBuffer:true,stencil:true,alpha:true},true);
|
|
|
|
|
+ engine.setHardwareScalingLevel(1/Math.min(2,window.devicePixelRatio||1));
|
|
|
|
|
+ scene=new B.Scene(engine);
|
|
|
|
|
+ STAGE_SCENE=scene;
|
|
|
|
|
+ BIP.dirty=true;
|
|
|
|
|
+ if(scene.imageProcessingConfiguration) scene.imageProcessingConfiguration.toneMappingEnabled=true; // 色调映射:金属高光不过曝
|
|
|
|
|
+ scene.clearColor=new B.Color4(0,0,0,0);
|
|
|
|
|
+ scene.ambientColor=new B.Color3(0.16,0.18,0.22);
|
|
|
|
|
+
|
|
|
|
|
+ camera=new B.ArcRotateCamera('cam',-1.05,1.03,150,V3(0,0,0),scene);
|
|
|
|
|
+ camera.lowerRadiusLimit=18; camera.upperRadiusLimit=900;
|
|
|
|
|
+ camera.lowerBetaLimit=0.1; camera.upperBetaLimit=1.54;
|
|
|
|
|
+ camera.wheelDeltaPercentage=0.02;
|
|
|
|
|
+ camera.pinchDeltaPercentage=0.03;
|
|
|
|
|
+ camera.attachControl(canvas,true);
|
|
|
|
|
+ camera.minZ=0.1; camera.fov=0.75; camera.inertia=0.72;
|
|
|
|
|
+ camera.pinchZoom=true;
|
|
|
|
|
+ camera.panningSensibility=160;
|
|
|
|
|
+ camera.angularSensibilityX=760; camera.angularSensibilityY=760;
|
|
|
|
|
+ camera.useNaturalPinchZoom=true;
|
|
|
|
|
+ camera.allowUpsideDown=false;
|
|
|
|
|
+
|
|
|
|
|
+ const hemi=new B.HemisphericLight('hemi',V3(0.1,1,0.2),scene);
|
|
|
|
|
+ hemi.intensity=0.5;
|
|
|
|
|
+ hemi.groundColor=new B.Color3(0.10,0.12,0.16);
|
|
|
|
|
+ const d1=new B.DirectionalLight('d1',V3(-0.5,-1,-0.7),scene);
|
|
|
|
|
+ d1.intensity=1.5; d1.position=V3(140,200,160);
|
|
|
|
|
+ const d2=new B.DirectionalLight('d2',V3(0.8,-0.55,0.7),scene);
|
|
|
|
|
+ d2.intensity=0.85; d2.position=V3(-160,120,-180);
|
|
|
|
|
+
|
|
|
|
|
+ installEnv(); // 本地化环境反射贴图(零外链)
|
|
|
|
|
+
|
|
|
|
|
+ const dt=new B.DynamicTexture('shadowTex',{width:256,height:256},scene,false);
|
|
|
|
|
+ const ctx=dt.getContext();
|
|
|
|
|
+ const g=ctx.createRadialGradient(128,128,6,128,128,126);
|
|
|
|
|
+ g.addColorStop(0,'rgba(0,0,0,0.55)');
|
|
|
|
|
+ g.addColorStop(0.4,'rgba(0,0,0,0.28)');
|
|
|
|
|
+ g.addColorStop(0.72,'rgba(0,0,0,0.09)');
|
|
|
|
|
+ g.addColorStop(1,'rgba(0,0,0,0)');
|
|
|
|
|
+ ctx.fillStyle=g; ctx.fillRect(0,0,256,256); dt.update();
|
|
|
|
|
+ ground=B.MeshBuilder.CreateGround('ground',{width:300,height:300},scene);
|
|
|
|
|
+ shadowMat=new B.StandardMaterial('shadowMat',scene);
|
|
|
|
|
+ shadowMat.diffuseTexture=dt; shadowMat.opacityTexture=dt;
|
|
|
|
|
+ shadowMat.emissiveColor=new B.Color3(0,0,0);
|
|
|
|
|
+ shadowMat.specularColor=new B.Color3(0,0,0);
|
|
|
|
|
+ shadowMat.disableLighting=true;
|
|
|
|
|
+ shadowMat.backFaceCulling=false;
|
|
|
|
|
+ ground.material=shadowMat; ground.isPickable=false;
|
|
|
|
|
+
|
|
|
|
|
+ engine.runRenderLoop(()=>{
|
|
|
|
|
+ if(scene) scene.render();
|
|
|
|
|
+ updateLabels();
|
|
|
|
|
+ });
|
|
|
|
|
+ new ResizeObserver(()=>engine.resize()).observe(host);
|
|
|
|
|
+ window.addEventListener('resize',()=>engine.resize());
|
|
|
|
|
+
|
|
|
|
|
+ readyFlag=true;
|
|
|
|
|
+ scene.onPointerObservable.add(pi=>{
|
|
|
|
|
+ if(pi.type===B.PointerEventTypes.POINTERDOUBLETAP){
|
|
|
|
|
+ const m2=pi.pickInfo&&pi.pickInfo.pickedMesh;
|
|
|
|
|
+ const md2=m2&&m2.metadata;
|
|
|
|
|
+ if(md2&&md2.part) focusPart(md2.part); else frame();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(pi.type!==B.PointerEventTypes.POINTERPICK) return;
|
|
|
|
|
+ const m=pi.pickInfo&&pi.pickInfo.pickedMesh;
|
|
|
|
|
+ if(!m) return;
|
|
|
|
|
+ const md=m.metadata||{};
|
|
|
|
|
+ if(!md.part){ if(selCb) selCb(null); return; }
|
|
|
|
|
+ highlight(md.part);
|
|
|
|
|
+ if(selCb) selCb(md.part,md.custom?m:null);
|
|
|
|
|
+ });
|
|
|
|
|
+ ensureLabelHost();
|
|
|
|
|
+ if(pending){ const p=pending; pending=null; load(p.project,p.params,p.material,p.explode); }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* 环境反射:页面通过 STAGE.setEnv({data,size}) 注入本地立方体贴图;未注入时异步加载 vendor/babylon/env/studio.env */
|
|
|
|
|
+ let envData=null, envTried=false;
|
|
|
|
|
+ const ENV_URL=new URL('../../vendor/babylon/env/studio.env',import.meta.url).href;
|
|
|
|
|
+ /* 环境贴图完成(成功或失败)后再 frame(),让金属反射一次到位 */
|
|
|
|
|
+ let envResolvers=[];
|
|
|
|
|
+ function installEnv(){
|
|
|
|
|
+ if(!scene){
|
|
|
|
|
+ envResolvers.forEach(r=>r()); envResolvers=[];
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ try{
|
|
|
|
|
+ if(envData&&envData.data){
|
|
|
|
|
+ const done=()=>{ envResolvers.forEach(r=>r()); envResolvers=[]; };
|
|
|
|
|
+ const t=new B.RawCubeTexture(ENV_URL,scene,envData.size||512,null,1,false,()=>{
|
|
|
|
|
+ scene.environmentTexture=t;
|
|
|
|
|
+ scene.environmentIntensity=1.0;
|
|
|
|
|
+ if(camera) frame();
|
|
|
|
|
+ done();
|
|
|
|
|
+ },false);
|
|
|
|
|
+ t.update(envData.data);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }catch(e){ console.warn('[STAGE] 环境贴图不可用,改用纯灯光反射',e&&e.message); }
|
|
|
|
|
+ if(envTried) return;
|
|
|
|
|
+ envTried=true;
|
|
|
|
|
+ fetch(ENV_URL).then(r=>r.ok?r.arrayBuffer():null).then(buf=>{
|
|
|
|
|
+ if(!buf||!scene) return;
|
|
|
|
|
+ envData={data:new Uint8Array(buf),size:512};
|
|
|
|
|
+ installEnv();
|
|
|
|
|
+ }).catch(()=>{ envResolvers.forEach(r=>r()); envResolvers=[]; });
|
|
|
|
|
+ }
|
|
|
|
|
+ function setEnv(d){ if(d&&d.data){ envData=d; installEnv(); } }
|
|
|
|
|
+
|
|
|
|
|
+ function ensureLabelHost(){
|
|
|
|
|
+ if(!host) return null;
|
|
|
|
|
+ let el=host.querySelector('.dimlayer');
|
|
|
|
|
+ if(!el){ el=document.createElement('div'); el.className='dimlayer'; host.appendChild(el); }
|
|
|
|
|
+ return el;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* ---------------- 标注 ---------------- */
|
|
|
|
|
+ function addDim(a,b,text,color){
|
|
|
|
|
+ if(!dimRoot) dimRoot=new B.TransformNode('dims',scene);
|
|
|
|
|
+ const col=B.Color3.FromHexString(color||'#7ec8ff');
|
|
|
|
|
+ const line=B.MeshBuilder.CreateLines('dl',{points:[a,b]},scene);
|
|
|
|
|
+ line.color=col; line.parent=dimRoot; line.isPickable=false;
|
|
|
|
|
+ const dir=b.subtract(a);
|
|
|
|
|
+ if(dir.length()>0.05){
|
|
|
|
|
+ const d=dir.normalize();
|
|
|
|
|
+ const perp=V3(-d.z,0.4,d.x);
|
|
|
|
|
+ if(perp.length()>0.05){
|
|
|
|
|
+ perp.normalize();
|
|
|
|
|
+ [a,b].forEach(pt=>{
|
|
|
|
|
+ const tick=B.MeshBuilder.CreateLines('tk',{points:[pt.add(perp.scale(2.0)),pt.subtract(perp.scale(2.0))]},scene);
|
|
|
|
|
+ tick.color=col; tick.parent=dimRoot; tick.isPickable=false;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ labels.push({p:a.add(b).scale(0.5),t:text});
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* ---------------- 建模:三款 ---------------- */
|
|
|
|
|
+ function buildSilicone(p){
|
|
|
|
|
+ const g=new B.TransformNode('root',scene);
|
|
|
|
|
+ const seg=24;
|
|
|
|
|
+ const t=p.t, ow=p.w+2*t, od=p.d+2*t, y0=-p.h/2, y1=p.h/2;
|
|
|
|
|
+ const ir=Math.max(0.5,p.r), orr=ir+t;
|
|
|
|
|
+
|
|
|
|
|
+ const body=hollowFrame('body',{ow,od,orr,iw:p.w,id:p.d,irr:ir,y0,y1,chamfer:0.7,seg},g);
|
|
|
|
|
+ body.metadata={role:'body',part:'body'};
|
|
|
|
|
+
|
|
|
|
|
+ const floor=solidSlab('floor',{w:p.w-0.4,d:p.d-0.4,r:Math.max(0.5,ir-0.2),y0,y1:y0+1.2,seg},g);
|
|
|
|
|
+ floor.metadata={role:'body',part:'floor'};
|
|
|
|
|
+
|
|
|
|
|
+ const hx=p.hg/2, hz=-(od/2-3.0);
|
|
|
|
|
+ const hornL=B.MeshBuilder.CreateCylinder('hornL',{diameterBottom:p.hd,diameterTop:p.hd*0.28,height:p.hh,tessellation:18},scene);
|
|
|
|
|
+ hornL.position=V3(-hx,y1+p.hh/2-0.45,hz); hornL.rotation.x=-0.28; hornL.rotation.z=-0.10; hornL.parent=g;
|
|
|
|
|
+ hornL.metadata={role:'accent',part:'hornL'};
|
|
|
|
|
+ const hornR=B.MeshBuilder.CreateCylinder('hornR',{diameterBottom:p.hd,diameterTop:p.hd*0.28,height:p.hh,tessellation:18},scene);
|
|
|
|
|
+ hornR.position=V3(hx,y1+p.hh/2-0.45,hz); hornR.rotation.x=-0.28; hornR.rotation.z=0.10; hornR.parent=g;
|
|
|
|
|
+ hornR.metadata={role:'accent',part:'hornR'};
|
|
|
|
|
+
|
|
|
|
|
+ const screen=solidSlab('screen',{w:Math.max(6,p.w-2.8),d:Math.max(6,p.d-2.8),r:Math.max(0.4,ir-1.4),y0:y1-0.62,y1:y1-0.30,seg},g);
|
|
|
|
|
+ screen.metadata={role:'glass',part:'screen'};
|
|
|
|
|
+
|
|
|
|
|
+ const crown=B.MeshBuilder.CreateCylinder('crown',{diameter:3.2,height:2.2,tessellation:16},scene);
|
|
|
|
|
+ crown.rotation.z=Math.PI/2;
|
|
|
|
|
+ crown.position=V3(ow/2+p.cr*0.5,y0+p.h*0.55,0); crown.parent=g;
|
|
|
|
|
+ crown.metadata={role:'body',part:'crown'};
|
|
|
|
|
+
|
|
|
|
|
+ addDim(V3(-ow/2,y0-5.5,od/2+2.5),V3(ow/2,y0-5.5,od/2+2.5),'外宽 '+ow.toFixed(1));
|
|
|
|
|
+ addDim(V3(-(ow/2+4),y0-1,od/2+3),V3(-(ow/2+4),y1,od/2+3),'总高 '+p.h.toFixed(1));
|
|
|
|
|
+ addDim(V3(ow/2+11,y0-5.5,-od/2),V3(ow/2+11,y0-5.5,od/2),'外深 '+od.toFixed(1));
|
|
|
|
|
+ addDim(V3(-p.hg/2,y1+p.hh+2.0,hz),V3(p.hg/2,y1+p.hh+2.0,hz),'角距 '+p.hg.toFixed(1));
|
|
|
|
|
+
|
|
|
|
|
+ return {root:g,size:V3(ow,p.h+p.hh*2,od),parts:[
|
|
|
|
|
+ {id:'body',node:body,ex:V3(0,0,0)},
|
|
|
|
|
+ {id:'floor',node:floor,ex:V3(0,-14,0)},
|
|
|
|
|
+ {id:'hornL',node:hornL,ex:V3(-7,16,0)},
|
|
|
|
|
+ {id:'hornR',node:hornR,ex:V3(7,16,0)},
|
|
|
|
|
+ {id:'screen',node:screen,ex:V3(0,20,0)},
|
|
|
|
|
+ {id:'crown',node:crown,ex:V3(16,4,0)}
|
|
|
|
|
+ ]};
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function buildRecorder(p){
|
|
|
|
|
+ const g=new B.TransformNode('root',scene);
|
|
|
|
|
+ const seg=48;
|
|
|
|
|
+ const ro=p.D/2, ri=ro-p.t, y0=-p.H/2, y1=p.H/2;
|
|
|
|
|
+ const r=Math.min(p.t*0.65,1.8);
|
|
|
|
|
+
|
|
|
|
|
+ const bodyProf=dedupe([
|
|
|
|
|
+ {r:ri,y:y0+r},
|
|
|
|
|
+ ...arcPts(ri+r,y0+r,r,180,270,3),
|
|
|
|
|
+ ...arcPts(ro-r,y0+r,r,270,360,3),
|
|
|
|
|
+ {r:ro,y:y1},
|
|
|
|
|
+ {r:ri,y:y1}
|
|
|
|
|
+ ]);
|
|
|
|
|
+ const body=revolve('body',bodyProf,seg,g);
|
|
|
|
|
+ body.metadata={role:'body',part:'body'};
|
|
|
|
|
+
|
|
|
|
|
+ const base=revolve('base',dedupe([
|
|
|
|
|
+ {r:0.6,y:y0},{r:Math.max(2,ro-1.2),y:y0},{r:Math.max(2,ro-1.2),y:y0+1.1},{r:0.6,y:y0+1.1}
|
|
|
|
|
+ ]),seg,g);
|
|
|
|
|
+ base.metadata={role:'body',part:'base'};
|
|
|
|
|
+
|
|
|
|
|
+ // 上盖穹顶
|
|
|
|
|
+ const dome=p.dm, lidPts=[{r:0.5,y:y1},{r:ro-0.2,y:y1}];
|
|
|
|
|
+ const steps=9;
|
|
|
|
|
+ for(let i=0;i<=steps;i++){
|
|
|
|
|
+ const a=i/steps*Math.PI/2;
|
|
|
|
|
+ lidPts.push({r:0.5+(ro-0.7)*Math.cos(a),y:y1+dome*Math.sin(a)});
|
|
|
|
|
+ }
|
|
|
|
|
+ const lid=revolve('lid',dedupe(lidPts),seg,g);
|
|
|
|
|
+ lid.metadata={role:'body',part:'lid'};
|
|
|
|
|
+
|
|
|
|
|
+ const loop=B.MeshBuilder.CreateTorus('loop',{diameter:p.ld+p.t*1.9,thickness:p.t*0.9,tessellation:28},scene);
|
|
|
|
|
+ loop.rotation.x=Math.PI/2;
|
|
|
|
|
+ loop.position=V3(ro+p.lh*0.55,y1-1.6,0); loop.parent=g;
|
|
|
|
|
+ loop.metadata={role:'body',part:'loop'};
|
|
|
|
|
+
|
|
|
|
|
+ const micMeshes=[];
|
|
|
|
|
+ const micR=Math.max(4,ro*0.4);
|
|
|
|
|
+ for(let i=0;i<4;i++){
|
|
|
|
|
+ const a=Math.PI/4+i*Math.PI/2;
|
|
|
|
|
+ const m=B.MeshBuilder.CreateCylinder('mic'+i,{diameter:1.0,height:1.8,tessellation:10},scene);
|
|
|
|
|
+ m.position=V3(Math.cos(a)*micR,y1+dome*0.72+0.2,Math.sin(a)*micR);
|
|
|
|
|
+ m.parent=g; m.material=fixed('dark');
|
|
|
|
|
+ m.metadata={role:'dark',part:'mic'};
|
|
|
|
|
+ micMeshes.push(m);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const usb=B.MeshBuilder.CreateBox('usbc',{width:1.4,height:3.2,depth:9.0},scene);
|
|
|
|
|
+ usb.position=V3(ro-0.4,y0+3.0,0); usb.parent=g; usb.material=fixed('dark');
|
|
|
|
|
+ usb.metadata={role:'dark',part:'usbc'};
|
|
|
|
|
+
|
|
|
|
|
+ const btn=B.MeshBuilder.CreateCylinder('btn',{diameter:3.6,height:1.2,tessellation:20},scene);
|
|
|
|
|
+ btn.rotation.z=Math.PI/2; btn.position=V3(-ro+0.1,y1-1.2,0); btn.parent=g;
|
|
|
|
|
+ btn.metadata={role:'body',part:'btn'};
|
|
|
|
|
+
|
|
|
|
|
+ const pcb=B.MeshBuilder.CreateCylinder('pcb',{diameter:Math.min(ro*2-5,26),height:1.2,tessellation:32},scene);
|
|
|
|
|
+ pcb.position=V3(0,y1-3.4,0); pcb.parent=g; pcb.material=fixed('pcb');
|
|
|
|
|
+ pcb.metadata={role:'pcb',part:'pcb'};
|
|
|
|
|
+
|
|
|
|
|
+ const cell=B.MeshBuilder.CreateCylinder('cell',{diameter:Math.min(ro*2-8,20),height:5.4,tessellation:28},scene);
|
|
|
|
|
+ cell.position=V3(0,y0+4.4,0); cell.parent=g; cell.material=fixed('cell');
|
|
|
|
|
+ cell.metadata={role:'cell',part:'cell'};
|
|
|
|
|
+
|
|
|
|
|
+ addDim(V3(-ro,y0-7,0),V3(ro,y0-7,0),'Ø'+p.D.toFixed(1));
|
|
|
|
|
+ addDim(V3(ro+9,y0,0),V3(ro+9,y1,0),'高 '+p.H.toFixed(1));
|
|
|
|
|
+ addDim(V3(0,y1+6,0),V3(ro+p.lh+2,y1+6,0),'挂环 '+p.lh.toFixed(1));
|
|
|
|
|
+
|
|
|
|
|
+ const ps=[
|
|
|
|
|
+ {id:'body',node:body,ex:V3(0,0,0)},
|
|
|
|
|
+ {id:'base',node:base,ex:V3(0,-16,0)},
|
|
|
|
|
+ {id:'cell',node:cell,ex:V3(0,2,0)},
|
|
|
|
|
+ {id:'pcb',node:pcb,ex:V3(0,14,0)},
|
|
|
|
|
+ {id:'lid',node:lid,ex:V3(0,26,0)},
|
|
|
|
|
+ {id:'loop',node:loop,ex:V3(18,2,0)},
|
|
|
|
|
+ {id:'btn',node:btn,ex:V3(-18,2,0)},
|
|
|
|
|
+ {id:'usbc',node:usb,ex:V3(16,-2,0)}
|
|
|
|
|
+ ];
|
|
|
|
|
+ micMeshes.forEach(m=>ps.push({id:'mic',node:m,ex:V3(0,30,0)}));
|
|
|
|
|
+ return {root:g,size:V3(p.D+10,p.H+p.dm, p.D),parts:ps};
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function arcQ(cx,cy,r,a0,a1,n){
|
|
|
|
|
+ const out=[];
|
|
|
|
|
+ for(let i=0;i<=n;i++){
|
|
|
|
|
+ const a=(a0+(a1-a0)*i/n)*Math.PI/180;
|
|
|
|
|
+ out.push({r:cx+r*Math.cos(a),y:cy+r*Math.sin(a)});
|
|
|
|
|
+ }
|
|
|
|
|
+ return out;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function buildRound(p){
|
|
|
|
|
+ const g=new B.TransformNode('root',scene);
|
|
|
|
|
+ const seg=64;
|
|
|
|
|
+ const ro=p.D/2, y0=-p.H/2, y1=p.H/2, bd=p.bd/2, sd=p.sd/2, dep=p.dep;
|
|
|
|
|
+ const re=Math.min(3.0,p.t*1.3);
|
|
|
|
|
+
|
|
|
|
|
+ /* CNC 弧面:外壁 → 顶部凸圆 R → 极短平台 → 屏边凹圆 R → 沉台
|
|
|
|
|
+ 全部由工艺参数驱动,工厂按 rimR / dep / cham 直接编程 */
|
|
|
|
|
+ const rimR=Math.max(0.4,Math.min(p.rimR||1.8, (ro-bd)*0.55));
|
|
|
|
|
+ const cham=Math.max(0,Math.min(p.cham||0.5, (ro-bd)*0.35));
|
|
|
|
|
+ const seam=Math.max(0.5,Math.min(p.dep||1.2, ro-rimR-bd+0.02));
|
|
|
|
|
+ const flat=Math.max(0,ro-rimR-(bd+seam));
|
|
|
|
|
+ const bezelProf=dedupe([
|
|
|
|
|
+ {r:sd,y:y0},
|
|
|
|
|
+ {r:Math.max(sd,ro-cham),y:y0},
|
|
|
|
|
+ ...(cham>0.05?arcPts(ro-cham,y0+cham,cham,270,360,3):[{r:ro,y:y0}]),
|
|
|
|
|
+ {r:ro,y:y1-rimR},
|
|
|
|
|
+ ...arcPts(ro-rimR,y1-rimR,rimR,0,90,6),
|
|
|
|
|
+ ...(flat>0.15?[{r:bd+seam,y:y1}]:[]),
|
|
|
|
|
+ ...arcPts(bd+seam,y1-seam,seam,90,180,6),
|
|
|
|
|
+ {r:sd,y:y1-seam}
|
|
|
|
|
+ ]);
|
|
|
|
|
+ const bezel=revolve('bezel',bezelProf,seg,g);
|
|
|
|
|
+ bezel.metadata={role:'body',part:'bezel'};
|
|
|
|
|
+
|
|
|
|
|
+ const seatY=y1-seam;
|
|
|
|
|
+ const black=B.MeshBuilder.CreateCylinder('black',{diameter:p.bd-0.3,height:0.6,tessellation:seg},scene);
|
|
|
|
|
+ black.position=V3(0,seatY+0.3,0); black.parent=g; black.material=fixed('dark');
|
|
|
|
|
+ black.metadata={role:'dark',part:'black'};
|
|
|
|
|
+
|
|
|
|
|
+ const glass=B.MeshBuilder.CreateCylinder('glass',{diameter:p.sd+0.4,height:0.8,tessellation:seg},scene);
|
|
|
|
|
+ glass.position=V3(0,seatY+0.4,0); glass.parent=g; glass.material=fixed('glass');
|
|
|
|
|
+ glass.metadata={role:'glass',part:'glass'};
|
|
|
|
|
+
|
|
|
|
|
+ const capProf=dedupe([
|
|
|
|
|
+ {r:0.6,y:y0},
|
|
|
|
|
+ {r:ro-p.t-0.6,y:y0},
|
|
|
|
|
+ {r:ro-p.t-0.6,y:y0+p.cap-0.5},
|
|
|
|
|
+ ...arcPts(ro-p.t-1.1,y0+p.cap-0.5,0.5,0,90,2),
|
|
|
|
|
+ {r:0.6,y:y0+p.cap}
|
|
|
|
|
+ ]);
|
|
|
|
|
+ const cap=revolve('cap',capProf,seg,g);
|
|
|
|
|
+ cap.metadata={role:'body',part:'cap'};
|
|
|
|
|
+
|
|
|
|
|
+ const th=B.MeshBuilder.CreateTorus('thread',{diameter:p.D-p.t*2-1.6,thickness:0.9,tessellation:seg},scene);
|
|
|
|
|
+ th.position=V3(0,y0+p.cap+0.05,0); th.parent=g; th.material=fixed('dark');
|
|
|
|
|
+ th.metadata={role:'dark',part:'thread'};
|
|
|
|
|
+
|
|
|
|
|
+ const bosses=[];
|
|
|
|
|
+ for(let i=0;i<4;i++){
|
|
|
|
|
+ const a=Math.PI/4+i*Math.PI/2;
|
|
|
|
|
+ const b=B.MeshBuilder.CreateCylinder('boss'+i,{diameter:4.2,height:5.2,tessellation:14},scene);
|
|
|
|
|
+ b.position=V3(Math.cos(a)*(ro-9),y0+p.cap+2.8,Math.sin(a)*(ro-9));
|
|
|
|
|
+ b.parent=g; b.material=fixed('brass');
|
|
|
|
|
+ b.metadata={role:'brass',part:'boss'};
|
|
|
|
|
+ bosses.push(b);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const pcb=B.MeshBuilder.CreateCylinder('pcb',{diameter:Math.min(44,p.D-14),height:1.2,tessellation:40},scene);
|
|
|
|
|
+ pcb.position=V3(0,y1-dep-3.4,0); pcb.parent=g; pcb.material=fixed('pcbDark');
|
|
|
|
|
+ pcb.metadata={role:'pcb',part:'pcb'};
|
|
|
|
|
+
|
|
|
|
|
+ const cell=B.MeshBuilder.CreateCylinder('cell',{diameter:Math.min(36,p.D-22),height:5.0,tessellation:36},scene);
|
|
|
|
|
+ cell.position=V3(0,y0+p.cap+4.6,0); cell.parent=g; cell.material=fixed('cell');
|
|
|
|
|
+ cell.metadata={role:'cell',part:'cell'};
|
|
|
|
|
+
|
|
|
|
|
+ const sb=B.MeshBuilder.CreateBox('sbtn',{width:1.2,height:5.4,depth:2.0},scene);
|
|
|
|
|
+ sb.position=V3(ro-0.1,1.6,-2); sb.parent=g;
|
|
|
|
|
+ sb.metadata={role:'body',part:'sbtn'};
|
|
|
|
|
+
|
|
|
|
|
+ const usb=B.MeshBuilder.CreateBox('usbc',{width:1.5,height:3.2,depth:8.8},scene);
|
|
|
|
|
+ usb.position=V3(-ro+0.4,y0+5.4,0); usb.parent=g; usb.material=fixed('dark');
|
|
|
|
|
+ usb.metadata={role:'dark',part:'usbc'};
|
|
|
|
|
+
|
|
|
|
|
+ addDim(V3(-ro,y0-7,0),V3(ro,y0-7,0),'Ø'+p.D.toFixed(2));
|
|
|
|
|
+ addDim(V3(ro+6,y0,0),V3(ro+6,y1,0),'厚 '+p.H.toFixed(2));
|
|
|
|
|
+ addDim(V3(-sd,y1+8.5,0),V3(sd,y1+8.5,0),'屏 Ø'+p.sd.toFixed(2));
|
|
|
|
|
+
|
|
|
|
|
+ const ps=[
|
|
|
|
|
+ {id:'bezel',node:bezel,ex:V3(0,0,0)},
|
|
|
|
|
+ {id:'black',node:black,ex:V3(0,22,0)},
|
|
|
|
|
+ {id:'glass',node:glass,ex:V3(0,32,0)},
|
|
|
|
|
+ {id:'pcb',node:pcb,ex:V3(0,8,0)},
|
|
|
|
|
+ {id:'cell',node:cell,ex:V3(0,-10,0)},
|
|
|
|
|
+ {id:'cap',node:cap,ex:V3(0,-28,0)},
|
|
|
|
|
+ {id:'thread',node:th,ex:V3(0,-20,0)},
|
|
|
|
|
+ {id:'sbtn',node:sb,ex:V3(18,2,0)},
|
|
|
|
|
+ {id:'usbc',node:usb,ex:V3(-18,-2,0)}
|
|
|
|
|
+ ];
|
|
|
|
|
+ bosses.forEach(b=>ps.push({id:'boss',node:b,ex:V3(0,-16,0)}));
|
|
|
|
|
+ return {root:g,size:V3(p.D,p.H,p.D),parts:ps};
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* ---------------- 自定义结构件(轻量参数化建模) ---------------- */
|
|
|
|
|
+ /* 形体库:按工艺预置的标准件参数(M2/M2.5/M3 自攻预钻孔按常用规范) */
|
|
|
|
|
+ const PRIMS={
|
|
|
|
|
+ box: {n:'方块', d:{w:8, h:6, dd:8}, tag:'基础'},
|
|
|
|
|
+ cyl: {n:'圆柱', d:{dia:10,h:8}, tag:'基础'},
|
|
|
|
|
+ rib: {n:'加强筋', d:{w:14, h:5, dd:1.2}, tag:'基础'},
|
|
|
|
|
+ pocket:{n:'凹槽(铣削)', d:{w:10, h:2, dd:10}, tag:'基础'},
|
|
|
|
|
+ hole: {n:'开孔(钻孔)', d:{dia:3, h:1}, tag:'基础'},
|
|
|
|
|
+ boss2: {n:'螺丝柱 M2', d:{dia:4.0,h:7,dd:1.6},tag:'紧固'},
|
|
|
|
|
+ boss25:{n:'螺丝柱 M2.5', d:{dia:4.8,h:8,dd:2.1},tag:'紧固'},
|
|
|
|
|
+ boss3: {n:'螺丝柱 M3', d:{dia:5.6,h:9,dd:2.6},tag:'紧固'},
|
|
|
|
|
+ thru25:{n:'M2.5 过孔', d:{dia:2.7,h:1,dd:2.7},tag:'紧固'},
|
|
|
|
|
+ pin3: {n:'定位销 Ø3', d:{dia:3,h:4}, tag:'紧固'},
|
|
|
|
|
+ pad4: {n:'四角柱组 M2.5',d:{w:30,h:7,dd:30,dia:4.8,hd:2.1},tag:'腔体'},
|
|
|
|
|
+ wall: {n:'分隔墙', d:{w:20,h:6,dd:0.8}, tag:'腔体'},
|
|
|
|
|
+ tray: {n:'电池仓', d:{w:22,h:3,dd:18}, tag:'腔体'},
|
|
|
|
|
+ clip: {n:'卡扣', d:{w:5,h:4,dd:1.2}, tag:'腔体'}
|
|
|
|
|
+ };
|
|
|
|
|
+ const FASTEN_TYPES=['boss2','boss25','boss3','thru25','pin3','pad4'];
|
|
|
|
|
+
|
|
|
|
|
+ function cavInfo(){
|
|
|
|
|
+ const id=cur.project, P2=PROJECTS[id]||{}, p=defaultsOf(id);
|
|
|
|
|
+ if(id==='silicone') return {kind:'rect',w:p.w,d:p.d,h:p.h};
|
|
|
|
|
+ if(id==='recorder') return {kind:'cyl',r:(p.D-2*p.t)/2,h:p.H-1.2-p.dm};
|
|
|
|
|
+ if(id==='round') return {kind:'cyl',r:(p.D-2*p.t)/2,h:p.H-p.cap-p.dep};
|
|
|
|
|
+ if(P2.cavity) return P2.cavity(p);
|
|
|
|
|
+ return {kind:'cyl',r:20,h:10};
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function newSpec(type){
|
|
|
|
|
+ const base=(PRIMS[type]||PRIMS.box).d;
|
|
|
|
|
+ const s={uid:custUid++,type:type,x:0,z:0,y:0,draft:1,snap:0.5,note:''};
|
|
|
|
|
+ Object.keys(base).forEach(k=>s[k]=base[k]);
|
|
|
|
|
+ return s;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* 空心柱(螺丝柱 / 过孔):径向回转,内外壁 + 上下环面 */
|
|
|
|
|
+ function hollowBoss(name,od,pid,h,tess){
|
|
|
|
|
+ const ri=Math.max(0.25,pid/2), ro=Math.max(ri+0.4,od/2), hh=Math.max(0.2,h/2);
|
|
|
|
|
+ return revolve(name,[{r:ri,y:-hh},{r:ro,y:-hh},{r:ro,y:hh},{r:ri,y:hh}],tess||20,null);
|
|
|
|
|
+ }
|
|
|
|
|
+ function mergeAll(ms,name){
|
|
|
|
|
+ if(!ms.length) return null;
|
|
|
|
|
+ const mm=B.Mesh.MergeMeshes(ms,true,true);
|
|
|
|
|
+ if(mm) mm.name=name;
|
|
|
|
|
+ return mm||ms[0];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function buildPrim(s){
|
|
|
|
|
+ const t=s.type;
|
|
|
|
|
+ let m=null;
|
|
|
|
|
+ const rect=(t==='box'||t==='pocket'||t==='rib'||t==='wall'||t==='clip');
|
|
|
|
|
+ if(rect){
|
|
|
|
|
+ m=B.MeshBuilder.CreateBox('c'+s.uid,{width:Math.max(0.2,s.w),height:Math.max(0.2,s.h),depth:Math.max(0.2,s.dd)},scene);
|
|
|
|
|
+ if(t==='rib'||t==='wall'){
|
|
|
|
|
+ const dr=Math.min(0.35,Math.tan(Math.max(0,s.draft||0)*Math.PI/180)*s.h/Math.max(1,s.dd)*1.6);
|
|
|
|
|
+ const pos=m.getVerticesData(B.VertexBuffer.PositionKind);
|
|
|
|
|
+ if(pos){ for(let i=0;i<pos.length;i+=3){ if(pos[i+1]>0){ pos[i]*=1-dr; pos[i+2]*=1-dr; } } }
|
|
|
|
|
+ m.updateVerticesData(B.VertexBuffer.PositionKind,pos);
|
|
|
|
|
+ }
|
|
|
|
|
+ }else if(t==='tray'){
|
|
|
|
|
+ const w=Math.max(4,s.w), dp=Math.max(4,s.dd), h=Math.max(1,s.h);
|
|
|
|
|
+ const tw=Math.min(1.4,Math.max(0.6,Math.min(w,dp)/12));
|
|
|
|
|
+ const ps=[];
|
|
|
|
|
+ const base=B.MeshBuilder.CreateBox('trb',{width:w,height:tw,depth:dp},scene);
|
|
|
|
|
+ base.position.y=-h/2+tw/2; ps.push(base);
|
|
|
|
|
+ [-1,1].forEach(sg=>{
|
|
|
|
|
+ const xw=B.MeshBuilder.CreateBox('trx',{width:tw,height:h,depth:dp},scene);
|
|
|
|
|
+ xw.position.x=sg*(w/2-tw/2); ps.push(xw);
|
|
|
|
|
+ const zw=B.MeshBuilder.CreateBox('trz',{width:w,height:h,depth:tw},scene);
|
|
|
|
|
+ zw.position.z=sg*(dp/2-tw/2); ps.push(zw);
|
|
|
|
|
+ });
|
|
|
|
|
+ m=mergeAll(ps,'c'+s.uid);
|
|
|
|
|
+ }else if(t==='pad4'){
|
|
|
|
|
+ const w=Math.max(8,s.w), dp=Math.max(8,s.dd), od=Math.max(2,s.dia||4.8);
|
|
|
|
|
+ const pid=Math.max(0.8,s.hd||2.1), h=Math.max(2,s.h);
|
|
|
|
|
+ const ps=[];
|
|
|
|
|
+ [-1,1].forEach(sx=>[-1,1].forEach(sz=>{
|
|
|
|
|
+ const b=hollowBoss('pb',od,pid,h,16);
|
|
|
|
|
+ b.position.x=sx*Math.max(0,w/2-od/2); b.position.z=sz*Math.max(0,dp/2-od/2);
|
|
|
|
|
+ ps.push(b);
|
|
|
|
|
+ }));
|
|
|
|
|
+ m=mergeAll(ps,'c'+s.uid);
|
|
|
|
|
+ }else if(t==='boss2'||t==='boss25'||t==='boss3'||t==='thru25'){
|
|
|
|
|
+ m=hollowBoss('c'+s.uid,Math.max(1.2,s.dia),Math.max(0.4,s.dd),Math.max(0.4,s.h),20);
|
|
|
|
|
+ }else if(t==='pin3'){
|
|
|
|
|
+ m=B.MeshBuilder.CreateCylinder('c'+s.uid,{diameter:Math.max(0.6,s.dia),height:Math.max(0.4,s.h),tessellation:20},scene);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ m=B.MeshBuilder.CreateCylinder('c'+s.uid,{diameter:Math.max(0.4,s.dia),height:Math.max(0.2,s.h),tessellation:24},scene);
|
|
|
|
|
+ }
|
|
|
|
|
+ m.position=V3(s.x||0,s.y||0,s.z||0);
|
|
|
|
|
+ if(s.rot) m.rotation.y=s.rot*Math.PI/180;
|
|
|
|
|
+ const role=FASTEN_TYPES.indexOf(t)>=0?'brass':((t==='pocket'||t==='hole')?'cut':'body');
|
|
|
|
|
+ m.metadata={role:role,part:'c'+s.uid,custom:true,owner:s.owner||null};
|
|
|
|
|
+
|
|
|
|
|
+ /* 拖动平面:经过零件当前位置的水平面(否则零件会被拉到 y=0 平面) */
|
|
|
|
|
+ const db=new B.PointerDragBehavior({dragPlaneNormal:V3(0,1,0),dragPlanePoint:V3(s.x||0,s.y||0,s.z||0)});
|
|
|
|
|
+ db.useObjectOrientationForDragging=false;
|
|
|
|
|
+ db.onDragStartObservable.add(()=>{ if(camera) camera.detachControl(); });
|
|
|
|
|
+ db.onDragEndObservable.add(()=>{ if(camera&&canvas) camera.attachControl(canvas,true); });
|
|
|
|
|
+ db.onDragObservable.add(()=>{
|
|
|
|
|
+ const st=Math.max(0.1,s.snap||0.5);
|
|
|
|
|
+ m.position.x=Math.round(m.position.x/st)*st;
|
|
|
|
|
+ m.position.z=Math.round(m.position.z/st)*st;
|
|
|
|
|
+ const cav=cavInfo();
|
|
|
|
|
+ const cw=s.w!==undefined?s.w:s.dia, cd=s.dd!==undefined?s.dd:s.dia;
|
|
|
|
|
+ if(cav.kind==='cyl'){
|
|
|
|
|
+ const r=Math.hypot(m.position.x,m.position.z);
|
|
|
|
|
+ const rr=cav.r-Math.max(cw,cd)/2-0.5;
|
|
|
|
|
+ if(r>0.2&&rr>0&&Math.abs(r-rr)<1.5){
|
|
|
|
|
+ m.position.x=Math.round((m.position.x/r*rr)*10)/10;
|
|
|
|
|
+ m.position.z=Math.round((m.position.z/r*rr)*10)/10;
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ const xz=cav.d/2-cd/2-0.5, xx=cav.w/2-cw/2-0.5;
|
|
|
|
|
+ if(Math.abs(Math.abs(m.position.z)-xz)<1.5) m.position.z=(m.position.z<0?-1:1)*xz;
|
|
|
|
|
+ if(Math.abs(Math.abs(m.position.x)-xx)<1.5) m.position.x=(m.position.x<0?-1:1)*xx;
|
|
|
|
|
+ }
|
|
|
|
|
+ s.x=+m.position.x.toFixed(2); s.z=+m.position.z.toFixed(2);
|
|
|
|
|
+ if(dragCb) dragCb(s);
|
|
|
|
|
+ });
|
|
|
|
|
+ m.addBehavior(db);
|
|
|
|
|
+ return m;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function buildCustom(parent){
|
|
|
|
|
+ labels.length=labels.length; // 保持已有标注
|
|
|
|
|
+ const list=customMap[cur.project]||[];
|
|
|
|
|
+ list.forEach(s=>{
|
|
|
|
|
+ const m=buildPrim(s);
|
|
|
|
|
+ m.parent=parent;
|
|
|
|
|
+ parts.push({id:'c'+s.uid,node:m,ex:V3(0,0,0),custom:true,spec:s});
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function outerOf(id){ return (PROJECTS[id]&&PROJECTS[id].outer)||{silicone:['body'],recorder:['body','lid'],round:['bezel','cap']}[id]||[]; }
|
|
|
|
|
+
|
|
|
|
|
+ /* 氛围灯:glow 件走 GlowLayer(PBR 件剔除出泛光层,避免金属被整体发雾) */
|
|
|
|
|
+ function applyGlow(){
|
|
|
|
|
+ if(!root||!B.GlowLayer) return;
|
|
|
|
|
+ if(!BIP.glow){
|
|
|
|
|
+ BIP.glow=new B.GlowLayer('glow',scene,{mainTextureSamples:2,blurKernelSize:16});
|
|
|
|
|
+ BIP.glow.addExcludedMesh=null;
|
|
|
|
|
+ }
|
|
|
|
|
+ BIP.glow.intensity=cur.glow?0.6:0;
|
|
|
|
|
+ root.getChildMeshes().forEach(m=>{
|
|
|
|
|
+ const md=m.metadata||{};
|
|
|
|
|
+ if(md.role==='glow'&&!m.emissiveColor) m.emissiveColor=B.Color3.FromHexString(md.glowColor||'#ff6a00');
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* ---------------- 材质应用 ---------------- */
|
|
|
|
|
+ function applyMaterial(key){
|
|
|
|
|
+ if(!root) return;
|
|
|
|
|
+ const cfg=MATERIALS[key]||MATERIALS[PROJECTS[cur.project].materials[0]];
|
|
|
|
|
+ if(!cfg) return;
|
|
|
|
|
+ const useKey=MATERIALS[key]?key:PROJECTS[cur.project].materials[0];
|
|
|
|
|
+ const bodyM=pbr(useKey,MATERIALS[useKey]);
|
|
|
|
|
+ const accentKey=useKey.indexOf('sil-')===0?'sil-black':useKey;
|
|
|
|
|
+ const accentM=pbr(accentKey,MATERIALS[accentKey]);
|
|
|
|
|
+ const outer=outerOf(cur.project);
|
|
|
|
|
+ root.getChildMeshes().forEach(m=>{
|
|
|
|
|
+ const role=m.metadata&&m.metadata.role;
|
|
|
|
|
+ const pid=m.metadata&&m.metadata.part;
|
|
|
|
|
+ if(role==='body') m.material=(cutaway&&outer.indexOf(pid)>=0)?ghost(useKey):bodyM;
|
|
|
|
|
+ else if(role==='inner') m.material=fixed('inner');
|
|
|
|
|
+ else if(role==='rubber'||role==='magnet'||role==='hinge'||role==='titanium') m.material=fixed(role);
|
|
|
|
|
+ else if(role==='ink') m.material=inkMat();
|
|
|
|
|
+ else if(role==='ceramic') m.material=pbr('ceramic',MATERIALS.ceramic);
|
|
|
|
|
+ else if(role==='key') m.material=keyMat(useKey);
|
|
|
|
|
+ else if(role==='glow') m.material=fixed('glow');
|
|
|
|
|
+ else if(role==='accent') m.material=accentM;
|
|
|
|
|
+ else if(role==='glass') m.material=fixed('glass');
|
|
|
|
|
+ else if(role==='pcb') m.material=fixed('pcb');
|
|
|
|
|
+ else if(role==='cell') m.material=fixed('cell');
|
|
|
|
|
+ else if(role==='brass') m.material=fixed('brass');
|
|
|
|
|
+ else if(role==='dark') m.material=fixed('dark');
|
|
|
|
|
+ else if(role==='cut') m.material=fixed('cut');
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* ---------------- 单件隔离编辑 ---------------- */
|
|
|
|
|
+ function applySolo(id){
|
|
|
|
|
+ if(!root) return;
|
|
|
|
|
+ root.getChildMeshes().forEach(m=>{
|
|
|
|
|
+ const md=m.metadata||{};
|
|
|
|
|
+ const keep=!id||md.part===id||md.owner===id;
|
|
|
|
|
+ m.setEnabled(!!keep);
|
|
|
|
|
+ });
|
|
|
|
|
+ if(dimRoot) dimRoot.setEnabled(!id&&cur.dims);
|
|
|
|
|
+ const layer=host&&host.querySelector('.dimlayer');
|
|
|
|
|
+ if(layer) layer.style.display=(!id&&cur.dims)?'block':'none';
|
|
|
|
|
+ }
|
|
|
|
|
+ function frameSolo(id){
|
|
|
|
|
+ if(!root||!camera) return;
|
|
|
|
|
+ const ms=root.getChildMeshes().filter(m=>m.metadata&&(m.metadata.part===id||m.metadata.owner===id)&&m.isEnabled());
|
|
|
|
|
+ if(!ms.length) return;
|
|
|
|
|
+ const bi=ms[0].getHierarchyBoundingVectors();
|
|
|
|
|
+ const c=bi.max.add(bi.min).scale(0.5);
|
|
|
|
|
+ const dim=Math.max(bi.max.x-bi.min.x,bi.max.y-bi.min.y,bi.max.z-bi.min.z);
|
|
|
|
|
+ camera.target=c;
|
|
|
|
|
+ camera.alpha=-0.95; camera.beta=1.16;
|
|
|
|
|
+ camera.radius=Math.max(34,dim*2.35);
|
|
|
|
|
+ camera.lowerRadiusLimit=Math.max(10,dim*0.6);
|
|
|
|
|
+ }
|
|
|
|
|
+ function focusPart(id){
|
|
|
|
|
+ if(!root||!camera) return;
|
|
|
|
|
+ const ms=root.getChildMeshes().filter(m=>m.metadata&&(m.metadata.part===id||m.metadata.owner===id)&&m.isEnabled());
|
|
|
|
|
+ if(!ms.length) return;
|
|
|
|
|
+ const bi=ms[0].getHierarchyBoundingVectors();
|
|
|
|
|
+ const c=bi.max.add(bi.min).scale(0.5);
|
|
|
|
|
+ const dim=Math.max(bi.max.x-bi.min.x,bi.max.y-bi.min.y,bi.max.z-bi.min.z);
|
|
|
|
|
+ camera.target=c;
|
|
|
|
|
+ camera.radius=Math.max(22,dim*2.1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function setSolo(id){
|
|
|
|
|
+ solo=id||null;
|
|
|
|
|
+ if(!root) return;
|
|
|
|
|
+ cutaway=false;
|
|
|
|
|
+ applyMaterial(cur.material);
|
|
|
|
|
+ applySolo(solo);
|
|
|
|
|
+ if(solo) frameSolo(solo); else frame();
|
|
|
|
|
+ if(cur.hl&&solo&&cur.hl!==solo) highlight(solo);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* ---------------- 组装/重建 ---------------- */
|
|
|
|
|
+ /* 八款产品 → 专属建模函数(函数声明在 IIFE 之后,模块级提升,这里在调用时才引用) */
|
|
|
|
|
+ const BUILDERS={
|
|
|
|
|
+ silicone:buildSilicone, recorder:buildRecorder, round:buildRound,
|
|
|
|
|
+ 'ai-pin':buildPin, 'eink-tag':buildEink, 'pocket-ai':buildPocket, 'bone-headset':buildBone, 'smart-ring':buildRing
|
|
|
|
|
+ };
|
|
|
|
|
+ function defaultsOf(pid,over){
|
|
|
|
|
+ const P2=PROJECTS[pid]||PROJECTS[cur.project];
|
|
|
|
|
+ const out={};
|
|
|
|
|
+ ((P2&&P2.params)||[]).forEach(x=>{ out[x.k]=x.def; });
|
|
|
|
|
+ Object.assign(out,pid===cur.project?(cur.params||{}):{},over||{});
|
|
|
|
|
+ return out;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function rebuild(reframe){
|
|
|
|
|
+ if(!scene) return;
|
|
|
|
|
+ if(root){ root.dispose(); root=null; }
|
|
|
|
|
+ if(dimRoot){ dimRoot.dispose(); dimRoot=null; }
|
|
|
|
|
+ labels=[]; labelEls.forEach(e=>e.remove()); labelEls=[];
|
|
|
|
|
+ const proj=PROJECTS[cur.project];
|
|
|
|
|
+ let out;
|
|
|
|
|
+ try{ out=(BUILDERS[cur.project]||buildSilicone)(defaultsOf(cur.project,cur.params)); }
|
|
|
|
|
+ catch(e){ console.error('[STAGE] 建模失败',cur.project,e); out=buildSilicone(defaultsOf('silicone',{})); }
|
|
|
|
|
+ root=out.root; parts=out.parts;
|
|
|
|
|
+ buildCustom(root);
|
|
|
|
|
+ parts.forEach(pt=>{
|
|
|
|
|
+ if(!pt.node) return;
|
|
|
|
|
+ pt.basePos=pt.node.position.clone();
|
|
|
|
|
+ pt.node.metadata=Object.assign({},pt.node.metadata||{},{part:pt.id});
|
|
|
|
|
+ });
|
|
|
|
|
+ applyMaterial(cur.material);
|
|
|
|
|
+ applyGlow();
|
|
|
|
|
+ applyExplode(cur.explode);
|
|
|
|
|
+ if(solo) applySolo(solo);
|
|
|
|
|
+ placeGround();
|
|
|
|
|
+ if(reframe!==false) frame();
|
|
|
|
|
+ refreshDims();
|
|
|
|
|
+ if(cur.hl) highlight(cur.hl);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function placeGround(){
|
|
|
|
|
+ if(!root||!ground) return;
|
|
|
|
|
+ const bi=root.getHierarchyBoundingVectors();
|
|
|
|
|
+ const dim=Math.max(bi.max.x-bi.min.x,bi.max.y-bi.min.y,bi.max.z-bi.min.z);
|
|
|
|
|
+ ground.position.y=bi.min.y-0.2;
|
|
|
|
|
+ ground.scaling.x=ground.scaling.z=Math.max(1,dim/60);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function frame(){
|
|
|
|
|
+ if(!root||!camera) return;
|
|
|
|
|
+ const bi=root.getHierarchyBoundingVectors();
|
|
|
|
|
+ const c=bi.max.add(bi.min).scale(0.5);
|
|
|
|
|
+ const dim=Math.max(bi.max.x-bi.min.x,bi.max.y-bi.min.y,bi.max.z-bi.min.z);
|
|
|
|
|
+ camera.target=c;
|
|
|
|
|
+ const aspect=(engine?engine.getRenderWidth():1)/Math.max(1,(engine?engine.getRenderHeight():1));
|
|
|
|
|
+ const pad=Math.max(1,1.18/Math.max(0.6,aspect));
|
|
|
|
|
+ camera.radius=Math.max(95,dim*1.98*pad);
|
|
|
|
|
+ camera.lowerRadiusLimit=Math.max(22,dim*0.85);
|
|
|
|
|
+ camera.upperRadiusLimit=Math.max(400,dim*7);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function applyExplode(v){
|
|
|
|
|
+ cur.explode=v||0;
|
|
|
|
|
+ parts.forEach(pt=>{
|
|
|
|
|
+ if(!pt.node||!pt.basePos) return;
|
|
|
|
|
+ pt.node.position=pt.basePos.add(pt.ex.scale(cur.explode));
|
|
|
|
|
+ });
|
|
|
|
|
+ const wantCut=!solo&&((cur.explode>0.2)||!!cur.cutForce);
|
|
|
|
|
+ if(wantCut!==cutaway){
|
|
|
|
|
+ cutaway=wantCut;
|
|
|
|
|
+ applyMaterial(cur.material);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function highlight(partId){
|
|
|
|
|
+ cur.hl=partId;
|
|
|
|
|
+ if(!root) return;
|
|
|
|
|
+ root.getChildMeshes().forEach(m=>{
|
|
|
|
|
+ m.renderOutline=false;
|
|
|
|
|
+ if(partId&&m.metadata&&m.metadata.part===partId){
|
|
|
|
|
+ m.renderOutline=true;
|
|
|
|
|
+ m.outlineColor=new B.Color3(0.25,0.75,1);
|
|
|
|
|
+ m.outlineWidth=0.9;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function setView(name){
|
|
|
|
|
+ if(!camera) return;
|
|
|
|
|
+ const map={iso:[-1.05,1.03],front:[-Math.PI/2,1.53],side:[0,1.53],top:[-Math.PI/2,0.17],low:[-0.55,1.38]};
|
|
|
|
|
+ const v=map[name]||map.iso;
|
|
|
|
|
+ let t=0; const fromA=camera.alpha,fromB=camera.beta,dur=0.42;
|
|
|
|
|
+ const obs=scene.onBeforeRenderObservable.add(()=>{
|
|
|
|
|
+ t+=engine.getDeltaTime()/1000;
|
|
|
|
|
+ const k=Math.min(1,t/dur), e=1-Math.pow(1-k,3);
|
|
|
|
|
+ camera.alpha=fromA+(v[0]-fromA)*e;
|
|
|
|
|
+ camera.beta=fromB+(v[1]-fromB)*e;
|
|
|
|
|
+ if(k>=1) scene.onBeforeRenderObservable.remove(obs);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function refreshDims(){
|
|
|
|
|
+ if(!host) return;
|
|
|
|
|
+ const layer=ensureLabelHost();
|
|
|
|
|
+ if(!layer) return;
|
|
|
|
|
+ layer.innerHTML=''; labelEls=[];
|
|
|
|
|
+ labels.forEach(l=>{
|
|
|
|
|
+ const d=document.createElement('div');
|
|
|
|
|
+ d.className='dimtag'; d.textContent=l.t;
|
|
|
|
|
+ layer.appendChild(d); labelEls.push(d);
|
|
|
|
|
+ });
|
|
|
|
|
+ layer.style.display=(cur.dims&&!solo)?'block':'none';
|
|
|
|
|
+ if(dimRoot) dimRoot.setEnabled(cur.dims&&!solo);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function setDims(on){
|
|
|
|
|
+ cur.dims=!!on;
|
|
|
|
|
+ if(solo&&cur.dims) applySolo(solo); // 隔离视图下标注跟随 solo 状态(这里只同步显隐)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ let lastW=0,lastH=0;
|
|
|
|
|
+ function updateLabels(){
|
|
|
|
|
+ if(!camera||!labelEls.length) return;
|
|
|
|
|
+ const rw=engine.getRenderWidth(), rh=engine.getRenderHeight();
|
|
|
|
|
+ if(rw!==lastW||rh!==lastH){ lastW=rw; lastH=rh; }
|
|
|
|
|
+ const vp=camera.viewport.toGlobal(rw,rh);
|
|
|
|
|
+ const tm=scene.getTransformMatrix();
|
|
|
|
|
+ const cssW=host.clientWidth, cssH=host.clientHeight;
|
|
|
|
|
+ for(let i=0;i<labels.length;i++){
|
|
|
|
|
+ const el=labelEls[i]; if(!el) continue;
|
|
|
|
|
+ const pr=B.Vector3.Project(labels[i].p,B.Matrix.Identity(),tm,vp);
|
|
|
|
|
+ if(pr.z<0||pr.z>1){ el.style.opacity='0'; continue; }
|
|
|
|
|
+ el.style.opacity='1';
|
|
|
|
|
+ const x=Math.min(Math.max((pr.x/rw)*cssW,34),cssW-34);
|
|
|
|
|
+ const y=Math.min(Math.max((pr.y/rh)*cssH,16),cssH-16);
|
|
|
|
|
+ el.style.left=x.toFixed(1)+'px';
|
|
|
|
|
+ el.style.top=y.toFixed(1)+'px';
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function load(projectId,params,material,explode){
|
|
|
|
|
+ if(!PROJECTS[projectId]) projectId='silicone';
|
|
|
|
|
+ if(!readyFlag){ pending={project:projectId,params:params,material:material,explode:explode}; return; }
|
|
|
|
|
+ cur.project=projectId;
|
|
|
|
|
+ cur.params=Object.assign({},params||{});
|
|
|
|
|
+ cur.material=material||PROJECTS[projectId].materials[0];
|
|
|
|
|
+ cur.explode=explode||0;
|
|
|
|
|
+ cur.hl=null;
|
|
|
|
|
+ rebuild();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* ---------------- 导出 ---------------- */
|
|
|
|
|
+ function collectMeshes(partId){
|
|
|
|
|
+ if(!root) return [];
|
|
|
|
|
+ const out=[];
|
|
|
|
|
+ root.getChildMeshes().forEach(m=>{
|
|
|
|
|
+ if(partId){
|
|
|
|
|
+ const md=m.metadata||{};
|
|
|
|
|
+ if(md.part!==partId&&md.owner!==partId) return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!m.getTotalVertices()) return;
|
|
|
|
|
+ const role=m.metadata&&m.metadata.role;
|
|
|
|
|
+ const isCustom=!!(m.metadata&&m.metadata.custom);
|
|
|
|
|
+ if(role==='cut') return;
|
|
|
|
|
+ if(!isCustom&&(role==='dark'||role==='glass'||role==='brass'||role==='pcb'||role==='cell')) return;
|
|
|
|
|
+ out.push(m);
|
|
|
|
|
+ });
|
|
|
|
|
+ return out;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ function exportMesh(kind,name,partId){
|
|
|
|
|
+ const meshes=collectMeshes(partId);
|
|
|
|
|
+ if(!meshes.length) return null;
|
|
|
|
|
+ if(kind==='stl'){
|
|
|
|
|
+ const lines=['solid '+name];
|
|
|
|
|
+ meshes.forEach(m=>{
|
|
|
|
|
+ const pos=m.getVerticesData(B.VertexBuffer.PositionKind);
|
|
|
|
|
+ const idx=m.getIndices();
|
|
|
|
|
+ m.computeWorldMatrix(true);
|
|
|
|
|
+ const wm=m.getWorldMatrix();
|
|
|
|
|
+ for(let i=0;i<idx.length;i+=3){
|
|
|
|
|
+ const a=B.Vector3.TransformCoordinates(V3(pos[idx[i]*3],pos[idx[i]*3+1],pos[idx[i]*3+2]),wm);
|
|
|
|
|
+ const b=B.Vector3.TransformCoordinates(V3(pos[idx[i+1]*3],pos[idx[i+1]*3+1],pos[idx[i+1]*3+2]),wm);
|
|
|
|
|
+ const c=B.Vector3.TransformCoordinates(V3(pos[idx[i+2]*3],pos[idx[i+2]*3+1],pos[idx[i+2]*3+2]),wm);
|
|
|
|
|
+ const n=B.Vector3.Cross(b.subtract(a),c.subtract(a));
|
|
|
|
|
+ if(n.length()<1e-8) continue;
|
|
|
|
|
+ n.normalize();
|
|
|
|
|
+ lines.push('facet normal '+n.x.toFixed(5)+' '+n.y.toFixed(5)+' '+n.z.toFixed(5),' outer loop');
|
|
|
|
|
+ [a,b,c].forEach(v=>lines.push(' vertex '+v.x.toFixed(4)+' '+v.y.toFixed(4)+' '+v.z.toFixed(4)));
|
|
|
|
|
+ lines.push(' endloop','endfacet');
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ lines.push('endsolid '+name);
|
|
|
|
|
+ return {text:lines.join('\n'),ext:'stl'};
|
|
|
|
|
+ }
|
|
|
|
|
+ const out=['# Pocket Shell Studio · unit mm · '+name];
|
|
|
|
|
+ let voff=0;
|
|
|
|
|
+ meshes.forEach((m,mi)=>{
|
|
|
|
|
+ const pos=m.getVerticesData(B.VertexBuffer.PositionKind);
|
|
|
|
|
+ const nrm=m.getVerticesData(B.VertexBuffer.NormalKind);
|
|
|
|
|
+ const idx=m.getIndices();
|
|
|
|
|
+ m.computeWorldMatrix(true);
|
|
|
|
|
+ const wm=m.getWorldMatrix();
|
|
|
|
|
+ out.push('o '+name+'_'+((m.metadata&&m.metadata.part)||mi));
|
|
|
|
|
+ for(let i=0;i<pos.length;i+=3){
|
|
|
|
|
+ const v=B.Vector3.TransformCoordinates(V3(pos[i],pos[i+1],pos[i+2]),wm);
|
|
|
|
|
+ out.push('v '+v.x.toFixed(4)+' '+v.y.toFixed(4)+' '+v.z.toFixed(4));
|
|
|
|
|
+ }
|
|
|
|
|
+ for(let i=0;i<nrm.length;i+=3) out.push('vn '+nrm[i].toFixed(4)+' '+nrm[i+1].toFixed(4)+' '+nrm[i+2].toFixed(4));
|
|
|
|
|
+ for(let i=0;i<idx.length;i+=3){
|
|
|
|
|
+ const a=idx[i]+1+voff,b=idx[i+1]+1+voff,c=idx[i+2]+1+voff;
|
|
|
|
|
+ out.push('f '+a+'//'+a+' '+b+'//'+b+' '+c+'//'+c);
|
|
|
|
|
+ }
|
|
|
|
|
+ voff+=pos.length/3;
|
|
|
|
|
+ });
|
|
|
|
|
+ return {text:out.join('\n'),ext:'obj'};
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return {
|
|
|
|
|
+ init:init,
|
|
|
|
|
+ load:load,
|
|
|
|
|
+ setParams:function(p){ cur.params=Object.assign({},p); rebuild(false); },
|
|
|
|
|
+ setMaterial:function(k){ cur.material=k; applyMaterial(k); },
|
|
|
|
|
+ setExplode:function(v){ applyExplode(v); },
|
|
|
|
|
+ setSolo:function(id){ setSolo(id); },
|
|
|
|
|
+ selectedPart:function(){ return solo; },
|
|
|
|
|
+ _cav:function(){ try{ return cavInfo(); }catch(e){ return null; } },
|
|
|
|
|
+ isSolo:function(){ return solo; },
|
|
|
|
|
+ setCutaway:function(on){ cur.cutForce=!!on; cutaway=!!on||cur.explode>0.2; applyMaterial(cur.material); },
|
|
|
|
|
+ isCutaway:function(){ return cutaway; },
|
|
|
|
|
+ setDims:function(on){ setDims(on); },
|
|
|
|
|
+ setView:setView,
|
|
|
|
|
+ /* 给 IIFE 外的阶段 F 建模函数提供几何原语(同一组函数对象,行为与现有建模一致) */
|
|
|
|
|
+ getBuilders:function(){ return BUILDERS; },
|
|
|
|
|
+ _geoHooks:function(){ return {sweepTube:sweepTube,lensMesh:lensMesh,extrudeLoop:extrudeLoop,frameLoopNamed:frameLoopNamed,rectRing:rectRing}; },
|
|
|
|
|
+ _geo:function(){
|
|
|
|
|
+ return {B:B,V3:V3,revolve:revolve,dedupe:dedupe,arcPts:arcPts,arcQ:arcQ,
|
|
|
|
|
+ solidSlab:solidSlab,hollowFrame:hollowFrame,assemble:assemble,ringStrip:ringStrip,
|
|
|
|
|
+ radialN:radialN,addDim:addDim,fixed:fixed};
|
|
|
|
|
+ },
|
|
|
|
|
+ setGlow:function(on){ cur.glow=!!on; if(root) applyGlow(); },
|
|
|
|
|
+ isGlow:function(){ return !!cur.glow; },
|
|
|
|
|
+ getExplode:function(){ return cur.explode; },
|
|
|
|
|
+ getMaterial:function(){ return cur.material; },
|
|
|
|
|
+ getMaterialKey:function(){ // 返回外层件实际使用的材质 key(剖视时为 gh-*)
|
|
|
|
|
+ const outer=outerOf(cur.project);
|
|
|
|
|
+ const m=root&&root.getChildMeshes().filter(x=>x.metadata&&outer.indexOf(x.metadata.part)>=0)[0];
|
|
|
|
|
+ return m&&m.material?m.material.name.replace(/^mat-/,''):cur.material;
|
|
|
|
|
+ },
|
|
|
|
|
+ getDims:function(){ return cur.dims; },
|
|
|
|
|
+ getView:function(){ return camera?{alpha:camera.alpha,beta:camera.beta,radius:camera.radius,target:{x:camera.target.x,y:camera.target.y,z:camera.target.z}}:null; },
|
|
|
|
|
+ setEnv:setEnv,
|
|
|
|
|
+ envUrl:function(){ return ENV_URL; },
|
|
|
|
|
+ project:function(id){ return PROJECTS[id||cur.project]; },
|
|
|
|
|
+ projectIds:function(){ return Object.keys(PROJECTS); },
|
|
|
|
|
+ frame:function(){ frame(); },
|
|
|
|
|
+ focusPart:focusPart,
|
|
|
|
|
+ highlight:highlight,
|
|
|
|
|
+ /* ---- 自定义结构件 ---- */
|
|
|
|
|
+ PRIMS:PRIMS,
|
|
|
|
|
+ setCustom:function(projectId,list){
|
|
|
|
|
+ customMap[projectId]=(list||[]).map(s=>Object.assign({},s));
|
|
|
|
|
+ if(cur.project===projectId) rebuild(false);
|
|
|
|
|
+ },
|
|
|
|
|
+ customList:function(){ return (customMap[cur.project]||[]).map(s=>Object.assign({},s)); },
|
|
|
|
|
+ addCustom:function(type,patch){
|
|
|
|
|
+ const s=Object.assign(newSpec(type),patch||{});
|
|
|
|
|
+ (customMap[cur.project]=customMap[cur.project]||[]).push(s);
|
|
|
|
|
+ rebuild(false);
|
|
|
|
|
+ highlight('c'+s.uid);
|
|
|
|
|
+ return Object.assign({},s);
|
|
|
|
|
+ },
|
|
|
|
|
+ updateCustom:function(uid,patch){
|
|
|
|
|
+ const l=customMap[cur.project]||[];
|
|
|
|
|
+ const s=l.find(x=>x.uid===uid);
|
|
|
|
|
+ if(!s) return null;
|
|
|
|
|
+ Object.assign(s,patch||{});
|
|
|
|
|
+ rebuild(false);
|
|
|
|
|
+ highlight('c'+uid);
|
|
|
|
|
+ return Object.assign({},s);
|
|
|
|
|
+ },
|
|
|
|
|
+ removeCustom:function(uid){
|
|
|
|
|
+ const l=customMap[cur.project]||[];
|
|
|
|
|
+ const i=l.findIndex(x=>x.uid===uid);
|
|
|
|
|
+ if(i>=0) l.splice(i,1);
|
|
|
|
|
+ rebuild(false);
|
|
|
|
|
+ },
|
|
|
|
|
+ clearCustom:function(){ customMap[cur.project]=[]; rebuild(false); },
|
|
|
|
|
+ onSelect:function(cb){ selCb=cb; },
|
|
|
|
|
+ onDrag:function(cb){ dragCb=cb; },
|
|
|
|
|
+ snapshot:function(){ if(!engine) return null; scene.render(); return canvas.toDataURL('image/png'); },
|
|
|
|
|
+ exportSTL:function(n){ return exportMesh('stl',n); },
|
|
|
|
|
+ exportOBJ:function(n){ return exportMesh('obj',n); },
|
|
|
|
|
+ exportSTLPart:function(n,pid){ return exportMesh('stl',n,pid); },
|
|
|
|
|
+ exportOBJPart:function(n,pid){ return exportMesh('obj',n,pid); },
|
|
|
|
|
+ partIds:function(){ return parts.map(p=>({id:p.id,custom:!!p.custom})); },
|
|
|
|
|
+ parts:function(){ return parts; },
|
|
|
|
|
+ /* 离线 / 调试:直接跑某款建模函数(不依赖渲染,Node 下可配合 BABYLON 替身做几何回归) */
|
|
|
|
|
+ _builders:function(){ return BUILDERS; },
|
|
|
|
|
+ _build:function(pid,params){
|
|
|
|
|
+ const fn=BUILDERS[pid]; if(!fn) throw new Error('未注册建模函数: '+pid);
|
|
|
|
|
+ const out=fn(defaultsOf(pid,Object.assign({},params||{})));
|
|
|
|
|
+ return {size:out.size,parts:out.parts,root:out.root};
|
|
|
|
|
+ },
|
|
|
|
|
+ isReady:function(){ return readyFlag; },
|
|
|
|
|
+ /* 离开页面:释放场景 / 引擎 / 观察者,允许再次 init */
|
|
|
|
|
+ dispose:function(){
|
|
|
|
|
+ try{ if(engine) engine.stopRenderLoop(); }catch(e){}
|
|
|
|
|
+ try{ if(scene) scene.dispose(); }catch(e){}
|
|
|
|
|
+ try{ if(engine) engine.dispose(); }catch(e){}
|
|
|
|
|
+ engine=null; scene=null; camera=null; ground=null; root=null; dimRoot=null; host=null; canvas=null;
|
|
|
|
|
+ readyFlag=false; pending=null; labels=[]; labelEls=[]; parts=[]; solo=null; cutaway=false;
|
|
|
|
|
+ for(const k in matCache) delete matCache[k];
|
|
|
|
|
+ for(const k in fixedCache) delete fixedCache[k];
|
|
|
|
|
+ for(const k in grainTex) delete grainTex[k];
|
|
|
|
|
+ BIP.glow=null;
|
|
|
|
|
+ STAGE_SCENE=null;
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+})();
|
|
|
|
|
+/* =========================================================
|
|
|
|
|
+ 阶段 F:五款产品的专属建模(ai-pin / eink-tag / pocket-ai / bone-headset / smart-ring)
|
|
|
|
|
+ —— 与 buildSilicone / buildRecorder / buildRound 同处模块作用域,判断与写法保持一致:
|
|
|
|
|
+ · 每个零件是真实几何(回转母线 / 圆角框 / 样条扫掠 / 环形阵列),不是盒子拼装
|
|
|
|
|
+ · 每个零件带 ex 爆炸位移向量;metadata 标 role + part(材质系统按 role 上色)
|
|
|
|
|
+ · 至少 3 组 addDim 关键尺寸
|
|
|
|
|
+ 函数声明在 IIFE 之后,调用时由模块级提升解析;几何原语通过 STAGE._geo() 桥接取用。
|
|
|
|
|
+ ========================================================= */
|
|
|
|
|
+const B = typeof BABYLON!=='undefined' ? BABYLON : (globalThis.BABYLON||{}); // 与 IIFE 内同名常量同值
|
|
|
|
|
+function _G(){ return STAGE._geo(); }
|
|
|
|
|
+function BUILD_DEFAULTS(pid){ const o={}; ((PROJECTS[pid]&&PROJECTS[pid].params)||[]).forEach(x=>{ o[x.k]=x.def; }); return o; }
|
|
|
|
|
+function B_(){ return B; } // 模块级 B(与 IIFE 内常量同值)
|
|
|
|
|
+
|
|
|
|
|
+/* 圆角矩形轮廓(XZ 平面,4×seg 点),与 roundedPath 同口径 */
|
|
|
|
|
+function rectRing(w,d,r,seg){
|
|
|
|
|
+ const hw=w/2,hh=d/2;
|
|
|
|
|
+ r=Math.max(0.05,Math.min(r,Math.min(hw,hh)-0.02));
|
|
|
|
|
+ const pts=[];
|
|
|
|
|
+ const corners=[
|
|
|
|
|
+ {cx:hw-r,cz:hh-r,a0:0},{cx:-(hw-r),cz:hh-r,a0:90},
|
|
|
|
|
+ {cx:-(hw-r),cz:-(hh-r),a0:180},{cx:hw-r,cz:-(hh-r),a0:270}
|
|
|
|
|
+ ];
|
|
|
|
|
+ for(const c of corners) for(let i=0;i<seg;i++){
|
|
|
|
|
+ const a=(c.a0+90*i/seg)*Math.PI/180;
|
|
|
|
|
+ pts.push({x:c.cx+r*Math.cos(a),z:c.cz+r*Math.sin(a)});
|
|
|
|
|
+ }
|
|
|
|
|
+ return pts;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* 圆角矩形实体挤出(板 / 键帽 / 电池 / 支架):外壁 + 封顶封底 */
|
|
|
|
|
+function extrudeLoop(name,w,d,r,y0,y1,seg,parent){
|
|
|
|
|
+ const {B,ringStrip,radialN,assemble,V3}=_G();
|
|
|
|
|
+ const A=rectRing(w,d,r,seg);
|
|
|
|
|
+ const ch=[];
|
|
|
|
|
+ ch.push(ringStrip(A,y0,A,y1,p=>radialN(p)));
|
|
|
|
|
+ const tp=[V3(0,y1,0)],tn=[V3(0,1,0)],ti=[];
|
|
|
|
|
+ A.forEach(p=>{ tp.push(V3(p.x,y1,p.z)); tn.push(V3(0,1,0)); });
|
|
|
|
|
+ for(let k=0;k<A.length;k++) ti.push(0,1+k,1+((k+1)%A.length));
|
|
|
|
|
+ ch.push({p:tp,n:tn,i:ti});
|
|
|
|
|
+ const bp=[V3(0,y0,0)],bn=[V3(0,-1,0)],bi=[];
|
|
|
|
|
+ A.forEach(p=>{ bp.push(V3(p.x,y0,p.z)); bn.push(V3(0,-1,0)); });
|
|
|
|
|
+ for(let k=0;k<A.length;k++) bi.push(0,1+((k+1)%A.length),1+k);
|
|
|
|
|
+ ch.push({p:bp,n:bn,i:bi});
|
|
|
|
|
+ return assemble(name,ch,parent);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* 圆角矩形「框」(中间挖空:外壳框 / 电池仓围壁 / 屏亮边) */
|
|
|
|
|
+function frameLoopNamed(name,ow,od,orr,iw,idd,irr,y0,y1,seg,parent){
|
|
|
|
|
+ const {ringStrip,radialN,assemble,V3}=_G();
|
|
|
|
|
+ const O0=rectRing(ow,od,orr,seg), O1=rectRing(ow,od,orr,seg);
|
|
|
|
|
+ const I0=rectRing(iw,idd,irr,seg), I1=rectRing(iw,idd,irr,seg);
|
|
|
|
|
+ const ch=[];
|
|
|
|
|
+ ch.push(ringStrip(O0,y0,O1,y1,p=>radialN(p)));
|
|
|
|
|
+ ch.push(ringStrip(I1,y1,I0,y0,p=>radialN(p).scale(-1)));
|
|
|
|
|
+ ch.push(ringStrip(O1,y1,I1,y1,()=>V3(0,1,0)));
|
|
|
|
|
+ ch.push(ringStrip(I0,y0,O0,y0,()=>V3(0,-1,0)));
|
|
|
|
|
+ return assemble(name,ch,parent);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* 样条扫掠(椭圆截面 + 平行移动标架):U 形颈环、钛丝骨架、别针弯钩 */
|
|
|
|
|
+function sweepTube(name,ctrl,rx,ry,tubeSeg,pathSeg,parent){
|
|
|
|
|
+ const {B,V3}=_G();
|
|
|
|
|
+ const pts=[];
|
|
|
|
|
+ const cr=(a,b,c,d,t)=>{
|
|
|
|
|
+ const t2=t*t,t3=t2*t;
|
|
|
|
|
+ return 0.5*((2*b)+(-a+c)*t+(2*a-5*b+4*c-d)*t2+(-a+3*b-3*c+d)*t3);
|
|
|
|
|
+ };
|
|
|
|
|
+ for(let i=0;i<ctrl.length-1;i++){
|
|
|
|
|
+ const p0=ctrl[Math.max(0,i-1)],p1=ctrl[i],p2=ctrl[i+1],p3=ctrl[Math.min(ctrl.length-1,i+2)];
|
|
|
|
|
+ for(let s=0;s<pathSeg;s++){
|
|
|
|
|
+ const t=s/pathSeg;
|
|
|
|
|
+ pts.push([cr(p0[0],p1[0],p2[0],p3[0],t),cr(p0[1],p1[1],p2[1],p3[1],t),cr(p0[2],p1[2],p2[2],p3[2],t)]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ pts.push(ctrl[ctrl.length-1].slice());
|
|
|
|
|
+ const N=pts.length,pos=[],nrm=[],idx=[];
|
|
|
|
|
+ for(let i=0;i<N;i++){
|
|
|
|
|
+ const a=pts[Math.max(0,i-1)],b=pts[Math.min(N-1,i+1)];
|
|
|
|
|
+ let T=[b[0]-a[0],b[1]-a[1],b[2]-a[2]];
|
|
|
|
|
+ const tl=Math.hypot(T[0],T[1],T[2])||1; T=[T[0]/tl,T[1]/tl,T[2]/tl];
|
|
|
|
|
+ let Sx=[T[2],0,-T[0]];
|
|
|
|
|
+ const sl=Math.hypot(Sx[0],Sx[2])||1; Sx=[Sx[0]/sl,0,Sx[2]/sl];
|
|
|
|
|
+ for(let k=0;k<tubeSeg;k++){
|
|
|
|
|
+ const th=k/tubeSeg*Math.PI*2,c=Math.cos(th),sn=Math.sin(th);
|
|
|
|
|
+ pos.push(V3(pts[i][0]+Sx[0]*rx*c,pts[i][1]+ry*sn,pts[i][2]+Sx[2]*rx*c));
|
|
|
|
|
+ nrm.push(V3(Sx[0]*c,sn,Sx[2]*c)); // 椭圆法向:只取方向,交给引擎归一化
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ for(let i=0;i<N-1;i++) for(let k=0;k<tubeSeg;k++){
|
|
|
|
|
+ const a=i*tubeSeg+k,bb=i*tubeSeg+(k+1)%tubeSeg;
|
|
|
|
|
+ const c=(i+1)*tubeSeg+k,d=(i+1)*tubeSeg+(k+1)%tubeSeg;
|
|
|
|
|
+ idx.push(a,bb,d,a,d,c);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 两端封口:每端一个扇形中心,避免管子两头露空
|
|
|
|
|
+ [[0,true],[N-1,false]].forEach(([i,rev])=>{
|
|
|
|
|
+ const base=pos.length, p0=pts[i];
|
|
|
|
|
+ pos.push(V3(p0[0],p0[1],p0[2]));
|
|
|
|
|
+ const T0=i===0?[pts[1][0]-p0[0],pts[1][1]-p0[1],pts[1][2]-p0[2]]:[p0[0]-pts[i-1][0],p0[1]-pts[i-1][1],p0[2]-pts[i-1][2]];
|
|
|
|
|
+ const tn=rev?[T0[0],T0[1],T0[2]]:[-T0[0],-T0[1],-T0[2]];
|
|
|
|
|
+ nrm.push(V3(tn[0],tn[1],tn[2]));
|
|
|
|
|
+ for(let k=0;k<tubeSeg;k++){ pos.push(pos[i*tubeSeg+k].clone()); nrm.push(V3(tn[0],tn[1],tn[2])); }
|
|
|
|
|
+ for(let k=0;k<tubeSeg;k++){
|
|
|
|
|
+ if(rev) idx.push(base,base+1+k,base+1+(k+1)%tubeSeg);
|
|
|
|
|
+ else idx.push(base,base+1+(k+1)%tubeSeg,base+1+k);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ const flat=[],fn=[];
|
|
|
|
|
+ pos.forEach(v=>flat.push(v.x,v.y,v.z));
|
|
|
|
|
+ nrm.forEach(v=>fn.push(v.x,v.y,v.z));
|
|
|
|
|
+ const vd=new B.VertexData(); vd.positions=flat; vd.indices=idx; vd.normals=fn;
|
|
|
|
|
+ const m=new B.Mesh(name,STAGE_SCENE); vd.applyToMesh(m);
|
|
|
|
|
+ m.metadata={};
|
|
|
|
|
+ if(parent) m.parent=parent;
|
|
|
|
|
+ return m;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* 椭圆「透镜块」(振子贴合面 / 模块压盖):短回转体母线 → 按 z 压成椭圆 */
|
|
|
|
|
+function lensMesh(name,rx,rz,h,tess,parent){
|
|
|
|
|
+ const {revolve,dedupe,arcQ}=_G();
|
|
|
|
|
+ const prof=dedupe([
|
|
|
|
|
+ {r:0.01,y:-h/2},{r:rx-0.6,y:-h/2},
|
|
|
|
|
+ ...arcQ(rx-0.6,-h/2+0.3,0.3,270,360,2),
|
|
|
|
|
+ {r:rx,y:-h/2+0.6},{r:rx,y:h/2-0.6},
|
|
|
|
|
+ ...arcQ(rx-0.6,h/2-0.6,0.6,0,90,3),
|
|
|
|
|
+ {r:0.01,y:h/2}
|
|
|
|
|
+ ]);
|
|
|
|
|
+ const m=revolve(name,prof,tess||28,parent);
|
|
|
|
|
+ m.scaling.z=rz/rx;
|
|
|
|
|
+ return m;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+let STAGE_SCENE=null;
|
|
|
|
|
+
|
|
|
|
|
+/* ---------------- eink-tag:前壳 + 屏框(内凹沉台)+ 墨水屏 + 后盖 + 隐藏折叠支架 ---------------- */
|
|
|
|
|
+function buildEink(p){
|
|
|
|
|
+ p=Object.assign(BUILD_DEFAULTS('eink-tag'),p);
|
|
|
|
|
+ const {V3,revolve,dedupe,arcQ,addDim,fixed}=_G();
|
|
|
|
|
+ const {extrudeLoop,frameLoopNamed}=STAGE._geoHooks();
|
|
|
|
|
+ const g=new (B_()).TransformNode('root',STAGE_SCENE);
|
|
|
|
|
+ const L=p.L, W=p.W, H=p.H, t=p.t;
|
|
|
|
|
+ const r=Math.max(2,Math.min(p.r,Math.min(L,W)/2-1));
|
|
|
|
|
+ const y0=-H/2, y1=H/2, seg=6;
|
|
|
|
|
+ const bz=Math.max(4,p.bezel), dep=p.dep, cap=Math.max(1,p.cap);
|
|
|
|
|
+ const sw=L-bz*2-p.bezW*2-0.6, sh=W-bz*2-p.bezW*2-0.6;
|
|
|
|
|
+
|
|
|
|
|
+ /* 前壳:圆角框(外壁 → 屏沉台);沉台底由「底片」补上,形成真正内凹的沉台 */
|
|
|
|
|
+ const front=frameLoopNamed('front',L,W,r,L-bz*2,W-bz*2,Math.max(0.8,r-bz),y1-dep,y1,seg,g);
|
|
|
|
|
+ front.metadata={role:'body',part:'front-shell'};
|
|
|
|
|
+ const frontFloor=extrudeLoop('frontFloor',L-bz*2+0.4,W-bz*2+0.4,Math.max(0.8,r-bz),y1-dep-0.9,y1-dep,seg,g);
|
|
|
|
|
+ frontFloor.metadata={role:'body',part:'front-frame'};
|
|
|
|
|
+
|
|
|
|
|
+ /* 屏框:沉台内一圈亮边(内凹台阶,框型) */
|
|
|
|
|
+ const frameBezel=frameLoopNamed('frameBezel',L-bz*2,W-bz*2,Math.max(0.6,r-bz),
|
|
|
|
|
+ L-bz*2-p.bezW,W-bz*2-p.bezW,Math.max(0.5,r-bz-p.bezW),y1-dep,y1-dep+0.4,seg,g);
|
|
|
|
|
+ frameBezel.metadata={role:'body',part:'front-frame'};
|
|
|
|
|
+
|
|
|
|
|
+ /* 墨水屏:可视区(e-ink 灰面,略低于亮边 0.3),几乎无反射 */
|
|
|
|
|
+ const ink=extrudeLoop('ink',sw,sh,Math.max(0.4,r-bz-p.bezW),y1-dep-0.55,y1-dep+0.1,seg,g);
|
|
|
|
|
+ ink.metadata={role:'ink',part:'screen'};
|
|
|
|
|
+
|
|
|
|
|
+ /* 后盖:薄圆角板 + 铭牌 + 四个硅胶垫脚 */
|
|
|
|
|
+ const back=extrudeLoop('back',L-0.6,W-0.6,Math.max(0.8,r-0.3),y0,y0+cap,seg,g);
|
|
|
|
|
+ back.metadata={role:'body',part:'back-cover'};
|
|
|
|
|
+ const label=extrudeLoop('backLabel',L*0.4,W*0.14,1.0,y0-0.02,y0+0.03,4,g);
|
|
|
|
|
+ label.position=V3(0,0,W*0.18);
|
|
|
|
|
+ label.material=fixed('inner');
|
|
|
|
|
+ label.metadata={role:'inner',part:'back-label'};
|
|
|
|
|
+ const feet=[];
|
|
|
|
|
+ [[-1,-1],[1,-1],[-1,1],[1,1]].forEach(([sx,sz],i)=>{
|
|
|
|
|
+ const f=B.MeshBuilder.CreateCylinder('foot'+i,{diameter:4,height:0.8,tessellation:16},STAGE_SCENE);
|
|
|
|
|
+ f.position=V3(sx*(L/2-10),y0-0.35,sz*(W/2-10));
|
|
|
|
|
+ f.parent=g; f.material=fixed('rubber');
|
|
|
|
|
+ f.metadata={role:'rubber',part:'rubber-feet'};
|
|
|
|
|
+ feet.push(f);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ /* 隐藏折叠支架:后盖上部的圆角板,绕后盖上沿的销轴转 standDeg(真实角度) */
|
|
|
|
|
+ const pivot=new (B_()).TransformNode('standPivot',STAGE_SCENE);
|
|
|
|
|
+ pivot.parent=g;
|
|
|
|
|
+ pivot.position=V3(0,y0,W/2-14);
|
|
|
|
|
+ const stand=extrudeLoop('stand',L*0.46,p.standL,2.0,-0.9,0.9,4,pivot);
|
|
|
|
|
+ stand.position=V3(0,0,-p.standL/2);
|
|
|
|
|
+ stand.rotation.x=-p.standDeg*Math.PI/180;
|
|
|
|
|
+ stand.metadata={role:'body',part:'kick-stand'};
|
|
|
|
|
+
|
|
|
|
|
+ /* 按键:侧边两枚圆角键(刷新 / 电源) */
|
|
|
|
|
+ const keys=[];
|
|
|
|
|
+ [-1,1].forEach((sz,i)=>{
|
|
|
|
|
+ const k=extrudeLoop('key'+i,8,2.2,0.8,y1-4.5,y1+0.3,3,g);
|
|
|
|
|
+ k.position=V3(L/2-9,0,sz*W*0.24);
|
|
|
|
|
+ k.rotation.y=Math.PI/2;
|
|
|
|
|
+ k.metadata={role:'body',part:i?'btn-power':'btn-refresh'};
|
|
|
|
|
+ keys.push(k);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ /* 扬声器网罩:后盖下部一排小孔 */
|
|
|
|
|
+ const spk=[];
|
|
|
|
|
+ for(let i=0;i<6;i++){
|
|
|
|
|
+ const h=B.MeshBuilder.CreateCylinder('spk'+i,{diameter:1.3,height:0.5,tessellation:10},STAGE_SCENE);
|
|
|
|
|
+ h.position=V3((i-2.5)*3.4,y0-0.1,-W*0.28);
|
|
|
|
|
+ h.parent=g; h.material=fixed('dark');
|
|
|
|
|
+ h.metadata={role:'dark',part:'speaker'};
|
|
|
|
|
+ spk.push(h);
|
|
|
|
|
+ }
|
|
|
|
|
+ /* 壁挂挂孔件:后盖上部金属环 */
|
|
|
|
|
+ const hang=B.MeshBuilder.CreateTorus('hang',{diameter:7,thickness:1.1,tessellation:24},STAGE_SCENE);
|
|
|
|
|
+ hang.rotation.x=Math.PI/2;
|
|
|
|
|
+ hang.position=V3(0,y0-0.5,W/2-12);
|
|
|
|
|
+ hang.parent=g;
|
|
|
|
|
+ hang.metadata={role:'accent',part:'hang-ring'};
|
|
|
|
|
+
|
|
|
|
|
+ /* 电池(扁平)+ 主板 + 铜螺母 ×4 */
|
|
|
|
|
+ const cell=extrudeLoop('cell',L*0.34,W*0.46,2,y0+cap+0.3,y0+cap+4.0,4,g);
|
|
|
|
|
+ cell.position=V3(L*0.26,0,0);
|
|
|
|
|
+ cell.metadata={role:'cell',part:'battery'};
|
|
|
|
|
+ const pcb=extrudeLoop('pcb',L*0.5,W-t*4,1.5,y0+cap+0.3,y0+cap+1.2,4,g);
|
|
|
|
|
+ pcb.position=V3(-L*0.2,0,0);
|
|
|
|
|
+ pcb.metadata={role:'pcb',part:'pcb'};
|
|
|
|
|
+ const brass=[];
|
|
|
|
|
+ [[-1,-1],[1,-1],[-1,1],[1,1]].forEach(([sx,sz],i)=>{
|
|
|
|
|
+ const bh=Math.max(2,dep+1.4);
|
|
|
|
|
+ const b=B.MeshBuilder.CreateCylinder('br'+i,{diameter:3.6,height:bh,tessellation:14},STAGE_SCENE);
|
|
|
|
|
+ b.position=V3(sx*(L/2-5),y1-dep-bh/2,sz*(W/2-5));
|
|
|
|
|
+ b.parent=g; b.material=fixed('brass');
|
|
|
|
|
+ b.metadata={role:'brass',part:'brass'};
|
|
|
|
|
+ brass.push(b);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ addDim(V3(-L/2,y0-6,W/2),V3(L/2,y0-6,W/2),'长 '+L.toFixed(1));
|
|
|
|
|
+ addDim(V3(L/2+8,y0-6,-W/2),V3(L/2+8,y0-6,W/2),'宽 '+W.toFixed(1));
|
|
|
|
|
+ addDim(V3(-L/2-6,y0,W/2),V3(-L/2-6,y1,W/2),'厚 '+H.toFixed(1));
|
|
|
|
|
+ addDim(V3(-sw/2,y1+2.5,-sh/2),V3(sw/2,y1+2.5,-sh/2),'墨水屏 '+sw.toFixed(0)+'×'+sh.toFixed(0));
|
|
|
|
|
+
|
|
|
|
|
+ const ps=[
|
|
|
|
|
+ {id:'front-shell',node:front,ex:V3(0,0,0)},
|
|
|
|
|
+ {id:'front-frame',node:frontFloor,ex:V3(0,0,0)},
|
|
|
|
|
+ {id:'front-frame',node:frameBezel,ex:V3(0,12,0)},
|
|
|
|
|
+ {id:'screen',node:ink,ex:V3(0,20,0)},
|
|
|
|
|
+ {id:'back-cover',node:back,ex:V3(0,-14,0)},
|
|
|
|
|
+ {id:'back-label',node:label,ex:V3(0,-20,0)},
|
|
|
|
|
+ {id:'kick-stand',node:stand,ex:V3(0,-8,24)},
|
|
|
|
|
+ {id:'battery',node:cell,ex:V3(0,-6,0)},
|
|
|
|
|
+ {id:'pcb',node:pcb,ex:V3(0,2,0)},
|
|
|
|
|
+ {id:'hang-ring',node:hang,ex:V3(0,-24,0)}
|
|
|
|
|
+ ];
|
|
|
|
|
+ keys.forEach(k=>ps.push({id:k.metadata.part,node:k,ex:V3(16,0,0)}));
|
|
|
|
|
+ spk.forEach(s=>ps.push({id:'speaker',node:s,ex:V3(0,-18,0)}));
|
|
|
|
|
+ feet.forEach(f=>ps.push({id:'rubber-feet',node:f,ex:V3(0,-16,0)}));
|
|
|
|
|
+ brass.forEach(b=>ps.push({id:'brass',node:b,ex:V3(0,14,0)}));
|
|
|
|
|
+ return {root:g,size:V3(L,H,W),parts:ps};
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function buildPin(p){
|
|
|
|
|
+ p=Object.assign(BUILD_DEFAULTS('ai-pin'),p);
|
|
|
|
|
+ const {V3,revolve,dedupe,arcQ,addDim,fixed}=_G();
|
|
|
|
|
+ const {sweepTube}=STAGE._geoHooks();
|
|
|
|
|
+ const g=new (B_()).TransformNode('root',STAGE_SCENE);
|
|
|
|
|
+ const seg=64, ro=p.D/2, y0=-p.H/2, y1=p.H/2;
|
|
|
|
|
+ const tw=Math.max(0.8,Math.min(p.t,p.H/3-0.2));
|
|
|
|
|
+ const rim=Math.max(0.5,Math.min(1.0,(p.D-p.sd)/2-0.8));
|
|
|
|
|
+ const sd=p.sd/2;
|
|
|
|
|
+ const ba=sd+p.rimW+0.7; /* 金属环外缘 → 沉台口 */
|
|
|
|
|
+ const so=ro-0.15-p.rimW; /* 金属环内缘 */
|
|
|
|
|
+ const ri=ro-tw-1.0; /* 内腔半径 */
|
|
|
|
|
+ const capT=Math.max(0.6,p.cap);
|
|
|
|
|
+
|
|
|
|
|
+ /* 钛灰中框:底倒角 → 直壁 → 顶部外圆角 → 金属环槽(内凹 0.25)→ 屏沉台(2.5D 曲面过渡) */
|
|
|
|
|
+ const dep=p.dep||0.5;
|
|
|
|
|
+ const frameProf=dedupe([
|
|
|
|
|
+ {r:sd,y:y1}, /* 沉台口(屏边) */
|
|
|
|
|
+ {r:ba,y:y1}, /* 顶部平台 */
|
|
|
|
|
+ ...arcQ(ba,y1-dep+1.0,1.0,90,180,4), /* 沉台内壁圆角过渡 */
|
|
|
|
|
+ {r:ro-rim,y:y1-dep}, /* 沉台底 */
|
|
|
|
|
+ {r:so,y:y1-dep}, /* 金属环槽(内凹) */
|
|
|
|
|
+ {r:so,y:y1-0.3},
|
|
|
|
|
+ {r:ro-0.15,y:y1-0.04}, /* 顶面对刀面 */
|
|
|
|
|
+ ...arcQ(ro-0.6,y1-0.6,0.6,0,90,3), /* 顶外 R */
|
|
|
|
|
+ {r:ro,y:y0+p.ch}, /* 外壁 */
|
|
|
|
|
+ ...arcQ(ro-p.ch,y0+p.ch,p.ch,270,360,3), /* 底边倒角 */
|
|
|
|
|
+ {r:ro-p.ch,y:y0},
|
|
|
|
|
+ {r:ri,y:y0}, /* 底面 */
|
|
|
|
|
+ {r:ri,y:y0+tw},
|
|
|
|
|
+ {r:ri+0.15,y:y0+tw}, /* 内腔底(抬出 0.6 放电池) */
|
|
|
|
|
+ {r:ri+0.15,y:y1-dep+0.95},
|
|
|
|
|
+ {r:ba,y:y1-dep+0.95},
|
|
|
|
|
+ {r:ba,y:y1-p.dep+0.55}
|
|
|
|
|
+ ]);
|
|
|
|
|
+ const frame=revolve('midFrame',frameProf,seg,g);
|
|
|
|
|
+ frame.metadata={role:'body',part:'mid-frame'};
|
|
|
|
|
+
|
|
|
|
|
+ /* 极细亮银金属环:顶面外缘独立不锈钢环(嵌进环槽,高出中框 0.12) */
|
|
|
|
|
+ const ringProf=dedupe([
|
|
|
|
|
+ {r:so-0.05,y:y1-p.dep+0.12},{r:so-0.05,y:y1-0.15},
|
|
|
|
|
+ {r:ro-0.20,y:y1-0.02},{r:ro-0.25,y:y1-0.30},{r:so,y:y1-0.30}
|
|
|
|
|
+ ]);
|
|
|
|
|
+ const rimRing=revolve('rim',ringProf,seg,g);
|
|
|
|
|
+ rimRing.metadata={role:'accent',part:'rim'};
|
|
|
|
|
+
|
|
|
|
|
+ /* 圆形触摸屏:2.5D 玻璃(边缘圆角、中心略拱) */
|
|
|
|
|
+ const gp=[{r:0.4,y:0}];
|
|
|
|
|
+ for(let i=0;i<=10;i++){
|
|
|
|
|
+ const k=i/10, r=(sd-0.2)*(1-k*0.06);
|
|
|
|
|
+ gp.push({r, y:0.15+0.35*Math.sin(k*Math.PI/2)});
|
|
|
|
|
+ }
|
|
|
|
|
+ gp.push({r:0.4,y:0.5});
|
|
|
|
|
+ const glass=revolve('screen',dedupe(gp),seg,g);
|
|
|
|
|
+ glass.position=V3(0,y1-p.dep+0.02,0);
|
|
|
|
|
+ glass.metadata={role:'glass',part:'screen'};
|
|
|
|
|
+
|
|
|
|
|
+ /* 陶瓷底盖:氧化锆圆盘(外圈台阶嵌中框,中心微凸) */
|
|
|
|
|
+ const capProf=dedupe([
|
|
|
|
|
+ ...arcQ(ri-0.5,-p.H/2+0.5,0.5,180,270,3), /* 陶瓷底外缘圆角 */
|
|
|
|
|
+ {r:ri,y:y0+0.5},{r:ri,y:y0+capT}, /* 外壁嵌进中框内腔 */
|
|
|
|
|
+ {r:ri-0.4,y:y0+capT+0.02}, /* 中心略凸 0.02,抛光面 */
|
|
|
|
|
+ {r:ri-0.4,y:y0+capT+0.5},
|
|
|
|
|
+ {r:0.4,y:y0+capT+0.5}
|
|
|
|
|
+ ]);
|
|
|
|
|
+ const cap=revolve('cap',capProf,seg,g);
|
|
|
|
|
+ cap.metadata={role:'ceramic',part:'back-cover'};
|
|
|
|
|
+
|
|
|
|
|
+ /* 激光投射窗口:底盖边缘的哑光黑光学窗 */
|
|
|
|
|
+ const laser=revolve('laser',dedupe([{r:0.3,y:0},{r:1.7,y:0},{r:1.7,y:0.4},{r:0.3,y:0.4}]),28,g);
|
|
|
|
|
+ laser.position=V3(ro*0.42,y0-0.05,0);
|
|
|
|
|
+ laser.metadata={role:'dark',part:'laser'};
|
|
|
|
|
+
|
|
|
|
|
+ /* 触控 / 物理复合键:右侧弧面键(短圆柱贴外壁) */
|
|
|
|
|
+ const btn=B.MeshBuilder.CreateCylinder('btn',{diameter:1.6,height:5.0,tessellation:16},STAGE_SCENE);
|
|
|
|
|
+ btn.rotation.z=Math.PI/2;
|
|
|
|
|
+ btn.position=V3(ro+0.3,0.8,0);
|
|
|
|
|
+ btn.parent=g;
|
|
|
|
|
+ btn.metadata={role:'body',part:'btn'};
|
|
|
|
|
+
|
|
|
|
|
+ /* 磁吸别针:SUS 弯钩(沿样条扫掠的圆管),从底盖出发外弯再回钩 */
|
|
|
|
|
+ const yb=y0-0.02;
|
|
|
|
|
+ const rv=p.pinR;
|
|
|
|
|
+ const hook=sweepTube('pin',[
|
|
|
|
|
+ [0,yb,-ro*0.55],[0,yb-rv*0.6,-ro*0.42],[0,yb-rv*1.6,-ro*0.18],
|
|
|
|
|
+ [0,yb-rv*2.2,ro*0.10],[0,yb-rv*2.0,ro*0.38],[0,yb-rv*1.2,ro*0.52]
|
|
|
|
|
+ ],rv,rv,12,9,g);
|
|
|
|
|
+ hook.metadata={role:'accent',part:'pin'};
|
|
|
|
|
+
|
|
|
|
|
+ /* 磁铁 ×4(环形阵列) */
|
|
|
|
|
+ const magnets=[];
|
|
|
|
|
+ for(let i=0;i<4;i++){
|
|
|
|
|
+ const a=Math.PI/4+i*Math.PI/2;
|
|
|
|
|
+ const m=B.MeshBuilder.CreateCylinder('mag'+i,{diameter:3.0,height:0.8,tessellation:18},STAGE_SCENE);
|
|
|
|
|
+ m.position=V3(Math.cos(a)*sd*0.72,y0+capT+0.45,Math.sin(a)*sd*0.72);
|
|
|
|
|
+ m.parent=g;
|
|
|
|
|
+ m.metadata={role:'magnet',part:'magnet'};
|
|
|
|
|
+ magnets.push(m);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* 超薄锂电 + 刚柔主板 + 热熔铜螺母 ×3 */
|
|
|
|
|
+ const cell=B.MeshBuilder.CreateCylinder('cell',{diameter:Math.max(8,sd*1.5),height:1.8,tessellation:seg},STAGE_SCENE);
|
|
|
|
|
+ cell.position=V3(0,y0+capT+1.8,0); cell.parent=g;
|
|
|
|
|
+ cell.metadata={role:'cell',part:'battery'};
|
|
|
|
|
+ const pcb=B.MeshBuilder.CreateCylinder('pcb',{diameter:Math.max(8,sd*1.7),height:0.8,tessellation:seg},STAGE_SCENE);
|
|
|
|
|
+ pcb.position=V3(0,y0+capT+1.8+1.5,0); pcb.parent=g;
|
|
|
|
|
+ pcb.metadata={role:'pcb',part:'main-pcb'};
|
|
|
|
|
+ const brass=[];
|
|
|
|
|
+ for(let i=0;i<3;i++){
|
|
|
|
|
+ const a=Math.PI/6+i*Math.PI*2/3;
|
|
|
|
|
+ const b=B.MeshBuilder.CreateCylinder('br'+i,{diameter:3.0,height:1.4,tessellation:14},STAGE_SCENE);
|
|
|
|
|
+ b.position=V3(Math.cos(a)*sd*0.7,y0+capT+1.8+1.85,Math.sin(a)*sd*0.7);
|
|
|
|
|
+ b.parent=g; b.material=fixed('brass');
|
|
|
|
|
+ b.metadata={role:'brass',part:'brass'};
|
|
|
|
|
+ brass.push(b);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ addDim(V3(-ro,y0-8,0),V3(ro,y0-8,0),'Ø'+p.D.toFixed(1));
|
|
|
|
|
+ addDim(V3(ro+7,y0,0),V3(ro+7,y1,0),'厚 '+p.H.toFixed(1));
|
|
|
|
|
+ addDim(V3(-sd,y1+p.dep+3.5,0),V3(sd,y1+p.dep+3.5,0),'屏 Ø'+p.sd.toFixed(1));
|
|
|
|
|
+ addDim(V3(-ro*0.55,yb-rv*3.2,-ro*0.18),V3(-ro*0.55,yb,-ro*0.18),'别针 R'+p.pinR.toFixed(1));
|
|
|
|
|
+
|
|
|
|
|
+ const ps=[
|
|
|
|
|
+ {id:'mid-frame',node:frame,ex:V3(0,0,0)},
|
|
|
|
|
+ {id:'rim',node:rimRing,ex:V3(0,14,0)},
|
|
|
|
|
+ {id:'screen',node:glass,ex:V3(0,24,0)},
|
|
|
|
|
+ {id:'back-cover',node:cap,ex:V3(0,-16,0)},
|
|
|
|
|
+ {id:'laser',node:laser,ex:V3(0,-26,0)},
|
|
|
|
|
+ {id:'btn',node:btn,ex:V3(14,0,0)},
|
|
|
|
|
+ {id:'pin',node:hook,ex:V3(0,-30,0)},
|
|
|
|
|
+ {id:'battery',node:cell,ex:V3(0,-4,0)},
|
|
|
|
|
+ {id:'main-pcb',node:pcb,ex:V3(0,6,0)}
|
|
|
|
|
+ ];
|
|
|
|
|
+ magnets.forEach(m=>ps.push({id:'magnet',node:m,ex:V3(0,-22,0)}));
|
|
|
|
|
+ brass.forEach(b=>ps.push({id:'brass',node:b,ex:V3(0,8,0)}));
|
|
|
|
|
+ return {root:g,size:V3(p.D,p.H+capT,p.D),parts:ps};
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* ---------------- eink-tag:前壳 + 屏框(内凹沉台)+ 墨水屏 + 后盖 + 隐藏折叠支架 ---------------- */
|
|
|
|
|
+function buildPocket(p){
|
|
|
|
|
+ p=Object.assign(BUILD_DEFAULTS('pocket-ai'),p);
|
|
|
|
|
+ const {V3,revolve,dedupe,arcQ,addDim,fixed}=_G();
|
|
|
|
|
+ const {extrudeLoop,frameLoopNamed}=STAGE._geoHooks();
|
|
|
|
|
+ const g=new (B_()).TransformNode('root',STAGE_SCENE);
|
|
|
|
|
+ const L=p.L, W=p.W, seg=6, t=p.t;
|
|
|
|
|
+ const lidH=Math.max(6,p.lidH), baseH=Math.max(5,p.baseH);
|
|
|
|
|
+ const r=Math.max(2,Math.min(p.r,Math.min(L,W)/2-1));
|
|
|
|
|
+ const yBase0=-lidH-baseH, yBase1=-lidH;
|
|
|
|
|
+ const yLid0=-lidH+p.gap, yLid1=yLid0+1.8, yTop=yLid1+lidH;
|
|
|
|
|
+ const bz=Math.max(4,p.bezel), dep=p.dep;
|
|
|
|
|
+
|
|
|
|
|
+ /* 下盖:圆角板(ABS) */
|
|
|
|
|
+ const base=extrudeLoop('bottom',L,W,r,yBase0,yBase1,seg,g);
|
|
|
|
|
+ base.metadata={role:'body',part:'bottom-cover'};
|
|
|
|
|
+
|
|
|
|
|
+ /* 铝上盖:圆角框 + 沉台底 + 亮边环 */
|
|
|
|
|
+ const lid=frameLoopNamed('topLid',L,W,r,L-bz*2,W-bz*2,Math.max(0.8,r-bz),yLid1,yTop,seg,g);
|
|
|
|
|
+ lid.metadata={role:'body',part:'top-lid'};
|
|
|
|
|
+ const lidFloor=extrudeLoop('lidFloor',L-bz*2+0.4,W-bz*2+0.4,Math.max(0.8,r-bz),yTop-1.3,yTop-dep,seg,g);
|
|
|
|
|
+ lidFloor.metadata={role:'body',part:'screen-bezel'};
|
|
|
|
|
+ const bezelRing=frameLoopNamed('bezelRing',L-bz*2,W-bz*2,Math.max(0.6,r-bz),
|
|
|
|
|
+ L-bz*2-2.0,W-bz*2-2.0,Math.max(0.5,r-bz-2.0),yTop-dep,yTop-dep+0.4,seg,g);
|
|
|
|
|
+ bezelRing.metadata={role:'body',part:'screen-bezel'};
|
|
|
|
|
+
|
|
|
|
|
+ /* 上盖屏:IPS + 2.5D 玻璃 */
|
|
|
|
|
+ const sw=L-bz*2-4.4, sh=W-bz*2-4.4;
|
|
|
|
|
+ const scr=extrudeLoop('screen',sw,sh,Math.max(0.5,r-bz-2.0),yTop-dep-0.55,yTop-dep+0.1,seg,g);
|
|
|
|
|
+ scr.metadata={role:'glass',part:'screen'};
|
|
|
|
|
+
|
|
|
|
|
+ /* 圆柱铰链:后侧一根长轴 + 两端轴套 */
|
|
|
|
|
+ const hr=Math.max(1.6,p.hingeR);
|
|
|
|
|
+ const hinge=B.MeshBuilder.CreateCylinder('hinge',{diameter:hr*2,height:L*0.9,tessellation:28},STAGE_SCENE);
|
|
|
|
|
+ hinge.rotation.z=Math.PI/2;
|
|
|
|
|
+ hinge.position=V3(0,yLid0+0.9,W/2+hr*0.3);
|
|
|
|
|
+ hinge.parent=g;
|
|
|
|
|
+ hinge.metadata={role:'hinge',part:'hinge'};
|
|
|
|
|
+ const knuckles=[];
|
|
|
|
|
+ [-0.46,0.46].forEach((f,i)=>{
|
|
|
|
|
+ const k=B.MeshBuilder.CreateCylinder('kn'+i,{diameter:hr*2+1.2,height:4.6,tessellation:24},STAGE_SCENE);
|
|
|
|
|
+ k.rotation.z=Math.PI/2;
|
|
|
|
|
+ k.position=V3(f*L,yLid0+0.9,W/2+hr*0.3);
|
|
|
|
|
+ k.parent=g;
|
|
|
|
|
+ k.metadata={role:'hinge',part:'hinge'};
|
|
|
|
|
+ knuckles.push(k);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ /* 键盘:下盖键床上的按键阵列,每颗独立圆角键帽(行列数由参数驱动,空格键加宽) */
|
|
|
|
|
+ const keys=[];
|
|
|
|
|
+ const cols=Math.max(4,Math.round(p.cols)), rows=Math.max(2,Math.round(p.rows));
|
|
|
|
|
+ const kbW=L*0.84, kbD=W*0.62;
|
|
|
|
|
+ const stepX=kbW/cols, stepZ=kbD/rows;
|
|
|
|
|
+ const keyW=Math.min(stepX-1.8,7.4), keyD=Math.min(stepZ-1.6,7.4);
|
|
|
|
|
+ const kbY=yBase1+0.4, z0=-W*0.5+W*0.26+keyD/2;
|
|
|
|
|
+ for(let rr=0;rr<rows;rr++){
|
|
|
|
|
+ for(let c=0;c<cols;c++){
|
|
|
|
|
+ const isSpace=(rr===rows-1&&c===Math.floor(cols/2));
|
|
|
|
|
+ const kw=isSpace?Math.min(keyW*3+stepX*2,stepX*3-1.6):keyW;
|
|
|
|
|
+ const k=extrudeLoop('k'+rr+'_'+c,kw,keyD,1.2,kbY,kbY+1.4,3,g);
|
|
|
|
|
+ k.position=V3(-kbW/2+stepX*(c+0.5),0,z0+rr*stepZ);
|
|
|
|
|
+ k.metadata={role:'key',part:'keycap-set'};
|
|
|
|
|
+ keys.push(k);
|
|
|
|
|
+ if(isSpace) c+=(cols>=9?3:2);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* 电池仓:下盖内侧围壁 + 电芯 */
|
|
|
|
|
+ const bayW=L*0.48, bayD=W*0.4;
|
|
|
|
|
+ const bay=frameLoopNamed('bay',bayW,bayD,2,bayW-2.4,bayD-2.4,0.6,yBase0+0.4,yBase1-1.0,4,g);
|
|
|
|
|
+ bay.position=V3(-L*0.24,0,-W*0.2);
|
|
|
|
|
+ bay.metadata={role:'body',part:'battery-bay'};
|
|
|
|
|
+ const cell=extrudeLoop('cell',bayW-3,bayD-3,1.2,yBase0+0.6,yBase1-1.4,4,g);
|
|
|
|
|
+ cell.position=V3(-L*0.24,0,-W*0.2);
|
|
|
|
|
+ cell.metadata={role:'cell',part:'battery'};
|
|
|
|
|
+
|
|
|
|
|
+ /* 主板 + 铜螺母 ×4 + 电源键 */
|
|
|
|
|
+ const pcb=extrudeLoop('pcb',L*0.4,W*0.3,1,yBase0+0.6,yBase1-1.2,4,g);
|
|
|
|
|
+ pcb.position=V3(L*0.25,0,-W*0.2);
|
|
|
|
|
+ pcb.metadata={role:'pcb',part:'main-pcb'};
|
|
|
|
|
+ const brass=[];
|
|
|
|
|
+ [[-1,-1],[1,-1],[-1,1],[1,1]].forEach(([sx,sz],i)=>{
|
|
|
|
|
+ const bh=Math.max(2,baseH-2.0);
|
|
|
|
|
+ const b=B.MeshBuilder.CreateCylinder('br'+i,{diameter:3.6,height:bh,tessellation:14},STAGE_SCENE);
|
|
|
|
|
+ b.position=V3(sx*(L/2-5),yBase0+0.5+bh/2,sz*(W/2-5));
|
|
|
|
|
+ b.parent=g; b.material=fixed('brass');
|
|
|
|
|
+ b.metadata={role:'brass',part:'brass'};
|
|
|
|
|
+ brass.push(b);
|
|
|
|
|
+ });
|
|
|
|
|
+ const pw=B.MeshBuilder.CreateBox('pw',{width:1.4,height:5.2,depth:2.4},STAGE_SCENE);
|
|
|
|
|
+ pw.position=V3(L/2+0.2,yBase1-baseH*0.55,W*0.28);
|
|
|
|
|
+ pw.metadata={role:'body',part:'power-btn'};
|
|
|
|
|
+
|
|
|
|
|
+ addDim(V3(-L/2,yBase0-8,W/2),V3(L/2,yBase0-8,W/2),'长 '+L.toFixed(1));
|
|
|
|
|
+ addDim(V3(L/2+8,yBase0-8,-W/2),V3(L/2+8,yBase0-8,W/2),'宽 '+W.toFixed(1));
|
|
|
|
|
+ addDim(V3(-L/2-7,yBase0,W/2),V3(-L/2-7,yTop,W/2),'合盖厚 '+(lidH+baseH+p.gap).toFixed(1));
|
|
|
|
|
+ addDim(V3(-L/2-7,yLid0,W/2),V3(-L/2-7,yTop,W/2),'上盖 '+lidH.toFixed(1));
|
|
|
|
|
+
|
|
|
|
|
+ const ps=[
|
|
|
|
|
+ {id:'bottom-cover',node:base,ex:V3(0,0,0)},
|
|
|
|
|
+ {id:'battery-bay',node:bay,ex:V3(0,0,0)},
|
|
|
|
|
+ {id:'battery',node:cell,ex:V3(0,10,0)},
|
|
|
|
|
+ {id:'main-pcb',node:pcb,ex:V3(0,6,0)},
|
|
|
|
|
+ {id:'top-lid',node:lid,ex:V3(0,32,0)},
|
|
|
|
|
+ {id:'screen-bezel',node:lidFloor,ex:V3(0,26,0)},
|
|
|
|
|
+ {id:'screen-bezel',node:bezelRing,ex:V3(0,38,0)},
|
|
|
|
|
+ {id:'screen',node:scr,ex:V3(0,46,0)},
|
|
|
|
|
+ {id:'hinge',node:hinge,ex:V3(0,18,14)},
|
|
|
|
|
+ {id:'power-btn',node:pw,ex:V3(14,-6,0)}
|
|
|
|
|
+ ];
|
|
|
|
|
+ knuckles.forEach(k=>ps.push({id:'hinge',node:k,ex:V3(0,18,14)}));
|
|
|
|
|
+ brass.forEach(b=>ps.push({id:'brass',node:b,ex:V3(0,4,0)}));
|
|
|
|
|
+ keys.forEach(k=>ps.push({id:'keycap-set',node:k,ex:V3(0,20,0)}));
|
|
|
|
|
+ return {root:g,size:V3(L,lidH+baseH+p.gap,W),parts:ps};
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* ---------------- bone-headset:U 形颈环(样条扫掠)+ 钛丝骨架 + 左右模块 + 振子贴合面 ---------------- */
|
|
|
|
|
+function buildBone(p){
|
|
|
|
|
+ p=Object.assign(BUILD_DEFAULTS('bone-headset'),p);
|
|
|
|
|
+ const {V3,revolve,dedupe,arcQ,addDim,fixed}=_G();
|
|
|
|
|
+ const {sweepTube,lensMesh,extrudeLoop}=STAGE._geoHooks();
|
|
|
|
|
+ const g=new (B_()).TransformNode('root',STAGE_SCENE);
|
|
|
|
|
+ const N=p.neck, W=p.width, A=p.armLen, Bk=Math.max(0,p.bend);
|
|
|
|
|
+ const rz=Math.max(20,N*0.58);
|
|
|
|
|
+ const xEnd=W/2+A;
|
|
|
|
|
+ const ctrl=[
|
|
|
|
|
+ [0,0.6,-rz],
|
|
|
|
|
+ [W*0.30,0.7,-rz*0.92],
|
|
|
|
|
+ [W*0.46,1.4,-rz*0.55],
|
|
|
|
|
+ [W*0.50,Bk,rz*0.10],
|
|
|
|
|
+ [W*0.50+A*0.55,Bk*0.92,rz*0.70],
|
|
|
|
|
+ [xEnd-2,Bk*0.85,rz*0.95],
|
|
|
|
|
+ [xEnd+1,Bk*0.8,rz*0.98]
|
|
|
|
|
+ ];
|
|
|
|
|
+ const mirror=ctrl.map(c=>[-c[0],c[1],c[2]]).reverse();
|
|
|
|
|
+ const full=mirror.concat(ctrl.slice(1));
|
|
|
|
|
+ const tubeR=Math.max(1.5,p.tubeR);
|
|
|
|
|
+ const my=Bk*0.8+Math.max(2.2,p.modH)*0.08, mz=rz*0.98;
|
|
|
|
|
+
|
|
|
|
|
+ /* U 形软胶颈环:椭圆截面沿样条扫掠 */
|
|
|
|
|
+ const band=sweepTube('neckband',full,tubeR,tubeR*0.8,22,10,g);
|
|
|
|
|
+ band.metadata={role:'body',part:'neckband'};
|
|
|
|
|
+
|
|
|
|
|
+ /* 钛记忆丝:颈环内部通道的细管(略短,两端封胶) */
|
|
|
|
|
+ const core=sweepTube('tiCore',full.slice(1,full.length-1).map(c=>[c[0]*0.995,c[1],c[2]*0.995]),tubeR*0.36,tubeR*0.3,10,10,g);
|
|
|
|
|
+ core.metadata={role:'titanium',part:'titanium-core'};
|
|
|
|
|
+ const plugs=[];
|
|
|
|
|
+ [-1,1].forEach((sx,i)=>{
|
|
|
|
|
+ const pl=B.MeshBuilder.CreateCylinder('plug'+i,{diameter:tubeR*2.1,height:2.4,tessellation:20},STAGE_SCENE);
|
|
|
|
|
+ pl.rotation.z=Math.PI/2;
|
|
|
|
|
+ pl.position=V3(sx*(xEnd-1.2),Bk*0.8,mz);
|
|
|
|
|
+ pl.parent=g; pl.material=fixed('rubber');
|
|
|
|
|
+ pl.metadata={role:'rubber',part:'silicone-plug'};
|
|
|
|
|
+ plugs.push(pl);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ /* 左右骨传导模块(蛋形回转体横置)+ 背壳压盖 + 振子椭圆贴合面 + 内部电池 + 装饰金属环 + 按键 */
|
|
|
|
|
+ const mH=Math.max(6,p.modH), mL=Math.max(10,p.modL);
|
|
|
|
|
+ const mods=[],covers=[],vibes=[],cells=[],logos=[],mbtns=[];
|
|
|
|
|
+ [-1,1].forEach((sx,i)=>{
|
|
|
|
|
+ const half=mL/2;
|
|
|
|
|
+ const modProf=dedupe([
|
|
|
|
|
+ {r:0.01,y:-half},
|
|
|
|
|
+ ...arcQ(mH/2-0.8,-half+0.8,0.8,270,360,2),
|
|
|
|
|
+ {r:mH/2,y:-half+0.9},
|
|
|
|
|
+ {r:mH/2,y:half-0.9},
|
|
|
|
|
+ ...arcQ(mH/2-0.8,half-0.8,0.8,0,90,2),
|
|
|
|
|
+ {r:0.01,y:half}
|
|
|
|
|
+ ]);
|
|
|
|
|
+ const m=revolve('module'+i,modProf,40,g);
|
|
|
|
|
+ m.rotation.z=sx*Math.PI/2;
|
|
|
|
|
+ m.position=V3(sx*xEnd,my,mz);
|
|
|
|
|
+ m.metadata={role:'body',part:sx<0?'left-module':'right-module'};
|
|
|
|
|
+ mods.push(m);
|
|
|
|
|
+ /* 背壳(外侧压盖,椭圆透镜) */
|
|
|
|
|
+ const cov=lensMesh('cover'+i,mH*0.44,mH*0.40,1.1,32,g);
|
|
|
|
|
+ cov.rotation.z=Math.PI/2;
|
|
|
|
|
+ cov.position=V3(sx*(xEnd+half-0.5),my,mz);
|
|
|
|
|
+ cov.metadata={role:'body',part:sx<0?'module-cover-l':'module-cover-r'};
|
|
|
|
|
+ covers.push(cov);
|
|
|
|
|
+ /* 振子贴合面(内侧朝向头骨的椭圆硅胶面,略凸) */
|
|
|
|
|
+ const vb=lensMesh('vibe'+i,mH*0.40,mH*0.46,1.8,36,g);
|
|
|
|
|
+ vb.rotation.z=Math.PI/2;
|
|
|
|
|
+ vb.position=V3(sx*(xEnd-half+0.4),my,mz);
|
|
|
|
|
+ vb.material=fixed('rubber');
|
|
|
|
|
+ vb.metadata={role:'rubber',part:sx<0?'vibrator-l':'vibrator-r'};
|
|
|
|
|
+ vibes.push(vb);
|
|
|
|
|
+ /* 电池组(模块内梭形) */
|
|
|
|
|
+ const c=revolve('cell'+i,dedupe([
|
|
|
|
|
+ {r:0.01,y:-mL*0.28},...arcQ(mH*0.26,mL*0.28+0.5,0.5,270,360,2),
|
|
|
|
|
+ {r:mH*0.26,y:mL*0.28},{r:0.01,y:mL*0.28+0.6}
|
|
|
|
|
+ ]),24,g);
|
|
|
|
|
+ c.rotation.z=sx*Math.PI/2;
|
|
|
|
|
+ c.position=V3(sx*(xEnd+0.2),my,mz);
|
|
|
|
|
+ c.material=fixed('cell');
|
|
|
|
|
+ c.metadata={role:'cell',part:sx<0?'cell-l':'cell-r'};
|
|
|
|
|
+ cells.push(c);
|
|
|
|
|
+ /* 模块与颈环接合处:拉丝金属装饰环 */
|
|
|
|
|
+ const lg=B.MeshBuilder.CreateTorus('logo'+i,{diameter:mH*0.96,thickness:0.7,tessellation:36},STAGE_SCENE);
|
|
|
|
|
+ lg.rotation.z=Math.PI/2;
|
|
|
|
|
+ lg.position=V3(sx*(xEnd-half*0.45),my,mz);
|
|
|
|
|
+ lg.metadata={role:'accent',part:'ring-logo'};
|
|
|
|
|
+ logos.push(lg);
|
|
|
|
|
+ /* 按键:左侧多功能键(顶面大圆)、右侧音量键(细长条) */
|
|
|
|
|
+ let mb;
|
|
|
|
|
+ if(sx<0){
|
|
|
|
|
+ mb=B.MeshBuilder.CreateCylinder('mb'+i,{diameter:3.4,height:1.2,tessellation:20},STAGE_SCENE);
|
|
|
|
|
+ mb.position=V3(sx*(xEnd+mL*0.1),my+mH/2-0.1,mz);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ mb=extrudeLoop('mb'+i,7,2.2,0.9,-0.6,0.6,3,g);
|
|
|
|
|
+ mb.rotation.x=Math.PI/2;
|
|
|
|
|
+ mb.position=V3(sx*(xEnd+mL*0.05),my+mH/2-0.2,mz);
|
|
|
|
|
+ }
|
|
|
|
|
+ mb.parent=g;
|
|
|
|
|
+ mb.metadata={role:'body',part:sx<0?'btn-multifn':'btn-vol'};
|
|
|
|
|
+ mbtns.push(mb);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ /* 控制模块:左侧颈环上的控制舱(扁圆角盒)+ 充电口防水塞 + FPC 走线 */
|
|
|
|
|
+ const ctrlBox=extrudeLoop('ctrl',mL*1.1,mH*0.62,3,-1.6,2.2,4,g);
|
|
|
|
|
+ ctrlBox.position=V3(-W*0.33,Bk*0.5+2.6,-rz*0.86);
|
|
|
|
|
+ ctrlBox.metadata={role:'body',part:'ctrl-module'};
|
|
|
|
|
+ const usb=B.MeshBuilder.CreateBox('usbCover',{width:1.4,height:4.6,depth:3.2},STAGE_SCENE);
|
|
|
|
|
+ usb.position=V3(-W*0.33-mL*0.55,Bk*0.5+2.0,-rz*0.86+1.2);
|
|
|
|
|
+ usb.parent=g; usb.material=fixed('rubber');
|
|
|
|
|
+ usb.metadata={role:'rubber',part:'usb-cover'};
|
|
|
|
|
+ const fpc=sweepTube('fpc',full.slice(2,full.length-2).map(c=>[c[0],c[1]+tubeR*0.45,c[2]]),0.45,0.1,6,10,g);
|
|
|
|
|
+ fpc.material=fixed('pcb');
|
|
|
|
|
+ fpc.metadata={role:'pcb',part:'main-pcb'};
|
|
|
|
|
+
|
|
|
|
|
+ addDim(V3(-xEnd,-7,rz),V3(xEnd,-7,rz),'展开宽 '+(xEnd*2).toFixed(1));
|
|
|
|
|
+ addDim(V3(xEnd+7,-7,-rz),V3(xEnd+7,-7,rz),'颈距 '+(rz*2).toFixed(1));
|
|
|
|
|
+ addDim(V3(-mH*0.5,my+mH/2+3,mz),V3(mH*0.5,my+mH/2+3,mz),'模块 Ø'+p.modH.toFixed(1));
|
|
|
|
|
+ addDim(V3(xEnd-mL/2,my+mH/2+3,mz),V3(xEnd+mL/2,my+mH/2+3,mz),'模块长 '+(mL).toFixed(1));
|
|
|
|
|
+
|
|
|
|
|
+ const ps=[
|
|
|
|
|
+ {id:'neckband',node:band,ex:V3(0,0,0)},
|
|
|
|
|
+ {id:'titanium-core',node:core,ex:V3(0,8,0)},
|
|
|
|
|
+ {id:'main-pcb',node:fpc,ex:V3(0,5,0)},
|
|
|
|
|
+ {id:'ctrl-module',node:ctrlBox,ex:V3(-10,6,-14)},
|
|
|
|
|
+ {id:'usb-cover',node:usb,ex:V3(-14,4,-18)}
|
|
|
|
|
+ ];
|
|
|
|
|
+ [-1,1].forEach((sx,i)=>{
|
|
|
|
|
+ ps.push({id:sx<0?'left-module':'right-module',node:mods[i],ex:V3(sx*12,0,0)});
|
|
|
|
|
+ ps.push({id:sx<0?'vibrator-l':'vibrator-r',node:vibes[i],ex:V3(-sx*8,0,0)});
|
|
|
|
|
+ ps.push({id:sx<0?'module-cover-l':'module-cover-r',node:covers[i],ex:V3(sx*20,0,0)});
|
|
|
|
|
+ ps.push({id:sx<0?'cell-l':'cell-r',node:cells[i],ex:V3(sx*6,10,0)});
|
|
|
|
|
+ ps.push({id:'ring-logo',node:logos[i],ex:V3(sx*16,0,0)});
|
|
|
|
|
+ ps.push({id:sx<0?'btn-multifn':'btn-vol',node:mbtns[i],ex:V3(sx*18,0,0)});
|
|
|
|
|
+ });
|
|
|
|
|
+ plugs.forEach(pl=>ps.push({id:'silicone-plug',node:pl,ex:V3(Math.sign(pl.position.x)*10,4,0)}));
|
|
|
|
|
+ return {root:g,size:V3(xEnd*2,Bk+mH*2,rz*2),parts:ps};
|
|
|
|
|
+}
|
|
|
|
|
+/* ---------------- smart-ring:钛外圈(环体)+ 树脂内衬 + 传感器透窗 + 充电舱 ---------------- */
|
|
|
|
|
+function buildRing(p){
|
|
|
|
|
+ p=Object.assign(BUILD_DEFAULTS('smart-ring'),p);
|
|
|
|
|
+ const {V3,revolve,dedupe,arcQ,addDim,fixed}=_G();
|
|
|
|
|
+ const g=new (B_()).TransformNode('root',STAGE_SCENE);
|
|
|
|
|
+ const seg=72;
|
|
|
|
|
+ const Rin=p.ringD/2, bw=p.bandW, Rb=Rin+bw, Hr=p.H;
|
|
|
|
|
+ const y0=Hr/2, y1=y0+Hr;
|
|
|
|
|
+ const cr=Math.min(1.8,bw*0.38);
|
|
|
|
|
+ const Dk=Math.max(Rb+6,p.dockD/2), Hd=Math.max(Hr+4,p.dockH);
|
|
|
|
|
+
|
|
|
|
|
+ /* 钛外圈:带外圆角的环壁(沉积在充电舱上的戒指本体) */
|
|
|
|
|
+ const outer=revolve('tiOuter',dedupe([
|
|
|
|
|
+ {r:Rin,y:y0},
|
|
|
|
|
+ ...arcQ(Rb-cr,y0+cr,cr,270,360,4),
|
|
|
|
|
+ {r:Rb,y:y1-cr},
|
|
|
|
|
+ ...arcQ(Rb-cr,y1-cr,cr,0,90,4),
|
|
|
|
|
+ {r:Rin,y:y1}
|
|
|
|
|
+ ]),seg,g);
|
|
|
|
|
+ outer.metadata={role:'body',part:'ti-outer'};
|
|
|
|
|
+
|
|
|
|
|
+ /* 树脂内衬:环内贴手指的一层(略高于钛壁 0.1,防刮手),医用环氧半透 */
|
|
|
|
|
+ const resin=revolve('resin',dedupe([
|
|
|
|
|
+ {r:Rin+0.3,y:y0+0.2},
|
|
|
|
|
+ ...arcQ(Rin+0.3+0.5,y1-0.5,0.5,180,270,3).map(a=>({r:a.r,y:a.y})),
|
|
|
|
|
+ {r:Rin+0.3,y:y1+0.1},{r:Rin-0.3,y:y1+0.1},{r:Rin-0.3,y:y0+0.2}
|
|
|
|
|
+ ]),seg,g);
|
|
|
|
|
+ resin.metadata={role:'accent',part:'resin-inner'};
|
|
|
|
|
+
|
|
|
|
|
+ /* 传感器透窗:外壁下沉处的蓝宝石窗(主传感器大,另三处小) */
|
|
|
|
|
+ const sensors=[];
|
|
|
|
|
+ [0,Math.PI*0.5,Math.PI,Math.PI*1.5].forEach((a,i)=>{
|
|
|
|
|
+ const isMain=i===0;
|
|
|
|
|
+ const w=isMain?5.6:1.5, h=isMain?3.8:1.2;
|
|
|
|
|
+ const b=B.MeshBuilder.CreateBox('sw'+i,{width:w,height:h,depth:0.7},STAGE_SCENE);
|
|
|
|
|
+ b.position=V3(Math.cos(a)*(Rb-0.15),(y0+y1)/2,Math.sin(a)*(Rb-0.15));
|
|
|
|
|
+ b.rotation.y=Math.PI/2-a;
|
|
|
|
|
+ b.parent=g;
|
|
|
|
|
+ b.material=fixed('glass');
|
|
|
|
|
+ b.metadata={role:'glass',part:isMain?'sensor-window':'fill-window'};
|
|
|
|
|
+ sensors.push(b);
|
|
|
|
|
+ });
|
|
|
|
|
+ /* 弯曲锂电(环内一圈薄环) + 刚柔主板(更薄的内层环) */
|
|
|
|
|
+ const cell=revolve('ringCell',dedupe([
|
|
|
|
|
+ {r:Rin+1.0,y:y0+1.5},{r:Rin+1.0+(bw-2.4)*0.6,y:y0+1.5},
|
|
|
|
|
+ {r:Rin+1.0+(bw-2.4)*0.6,y:y1-1.5},{r:Rin+1.0,y:y1-1.5}
|
|
|
|
|
+ ]),seg,g);
|
|
|
|
|
+ cell.material=fixed('cell');
|
|
|
|
|
+ cell.metadata={role:'cell',part:'battery'};
|
|
|
|
|
+ const pcb=revolve('ringPcb',dedupe([
|
|
|
|
|
+ {r:Rin+0.9,y:y0+0.85},{r:Rin+0.9+(bw-2.6)*0.7,y:y0+0.85},
|
|
|
|
|
+ {r:Rin+0.9+(bw-2.6)*0.7,y:y0+1.35},{r:Rin+0.9,y:y0+1.35}
|
|
|
|
|
+ ]),seg,g);
|
|
|
|
|
+ pcb.material=fixed('pcb');
|
|
|
|
|
+ pcb.metadata={role:'pcb',part:'pcb'};
|
|
|
|
|
+
|
|
|
|
|
+ /* 充电舱:底座(圆角圆柱 + 底圆角)→ 上壳台阶 → 戒指座槽 */
|
|
|
|
|
+ const dockBase=revolve('dockBase',dedupe([
|
|
|
|
|
+ {r:0.01,y:-0.01},{r:Dk-1.6,y:-0.01},
|
|
|
|
|
+ ...arcQ(Dk-1.6,1.6,1.6,270,360,4),
|
|
|
|
|
+ {r:Dk,y:2.6},{r:Dk,y:Hd*0.52},
|
|
|
|
|
+ ...arcQ(Dk-1.2,Hd*0.52,1.2,0,90,3),
|
|
|
|
|
+ {r:Dk-1.2,y:Hd*0.6},{r:0.01,y:Hd*0.6+0.01}
|
|
|
|
|
+ ]),seg,g);
|
|
|
|
|
+ dockBase.metadata={role:'body',part:'dock-bottom'};
|
|
|
|
|
+ const dockShell=revolve('dockShell',dedupe([
|
|
|
|
|
+ {r:Rb+1.6,y:Hd*0.6},{r:Dk-1.2,y:Hd*0.6},{r:Dk-1.2,y:Hd*0.64},{r:Rb+1.6,y:Hd*0.64}
|
|
|
|
|
+ ]),seg,g);
|
|
|
|
|
+ dockShell.metadata={role:'body',part:'dock-shell'};
|
|
|
|
|
+ /* 透明罩(亚克力):戒指下半截外面的一圈高罩 */
|
|
|
|
|
+ const dome=revolve('dockLid',dedupe([
|
|
|
|
|
+ {r:Rb+1.6,y:Hd*0.64},{r:Dk-2.0,y:Hd*0.64},
|
|
|
|
|
+ {r:Dk-2.0,y:Hd*1.02},{r:Rb+1.6,y:Hd*1.02}
|
|
|
|
|
+ ]),seg,g);
|
|
|
|
|
+ dome.material=fixed('acrylic');
|
|
|
|
|
+ dome.metadata={role:'glass',part:'dock-lid'};
|
|
|
|
|
+ const dockBtn=B.MeshBuilder.CreateCylinder('dockBtn',{diameter:3.4,height:1.4,tessellation:20},STAGE_SCENE);
|
|
|
|
|
+ dockBtn.rotation.z=Math.PI/2;
|
|
|
|
|
+ dockBtn.position=V3(Dk+0.1,Hd*0.22,0);
|
|
|
|
|
+ dockBtn.parent=g;
|
|
|
|
|
+ dockBtn.metadata={role:'body',part:'dock-button'};
|
|
|
|
|
+ const dockCell=B.MeshBuilder.CreateCylinder('dockCell',{diameter:Dk*1.15,height:Hd*0.22,tessellation:40},STAGE_SCENE);
|
|
|
|
|
+ dockCell.position=V3(0,Hd*0.24,0);
|
|
|
|
|
+ dockCell.parent=g; dockCell.material=fixed('cell');
|
|
|
|
|
+ dockCell.metadata={role:'cell',part:'dock-battery'};
|
|
|
|
|
+ const hook=B.MeshBuilder.CreateTorus('dockRing',{diameter:6.4,thickness:1.0,tessellation:24},STAGE_SCENE);
|
|
|
|
|
+ hook.rotation.z=Math.PI/2;
|
|
|
|
|
+ hook.position=V3(-Dk-1.4,Hd*0.3,0);
|
|
|
|
|
+ hook.parent=g;
|
|
|
|
|
+ hook.metadata={role:'accent',part:'dock-ring'};
|
|
|
|
|
+
|
|
|
|
|
+ addDim(V3(-Rb,Hd*0.15,0),V3(Rb,Hd*0.15,0),'外径 Ø'+(Rb*2).toFixed(1));
|
|
|
|
|
+ addDim(V3(Rb+6,y0,0),V3(Rb+6,y1,0),'环高 '+Hr.toFixed(1));
|
|
|
|
|
+ addDim(V3(-Rin,Hd*0.05,0),V3(Rin,Hd*0.05,0),'内径 Ø'+p.ringD.toFixed(1));
|
|
|
|
|
+ addDim(V3(-Dk,-4,0),V3(Dk,-4,0),'充电舱 Ø'+p.dockD.toFixed(1));
|
|
|
|
|
+
|
|
|
|
|
+ const ps=[
|
|
|
|
|
+ {id:'ti-outer',node:outer,ex:V3(0,0,0)},
|
|
|
|
|
+ {id:'resin-inner',node:resin,ex:V3(0,10,0)},
|
|
|
|
|
+ {id:'battery',node:cell,ex:V3(0,16,0)},
|
|
|
|
|
+ {id:'pcb',node:pcb,ex:V3(0,22,0)},
|
|
|
|
|
+ {id:'dock-bottom',node:dockBase,ex:V3(0,-18,0)},
|
|
|
|
|
+ {id:'dock-shell',node:dockShell,ex:V3(0,-10,0)},
|
|
|
|
|
+ {id:'dock-lid',node:dome,ex:V3(0,-6,0)},
|
|
|
|
|
+ {id:'dock-button',node:dockBtn,ex:V3(Dk+8,-12,0)},
|
|
|
|
|
+ {id:'dock-battery',node:dockCell,ex:V3(0,-24,0)},
|
|
|
|
|
+ {id:'dock-ring',node:hook,ex:V3(-Dk-8,-12,0)}
|
|
|
|
|
+ ];
|
|
|
|
|
+ sensors.forEach(s=>ps.push({id:s.metadata.part,node:s,ex:V3(0,28,0)}));
|
|
|
|
|
+ return {root:g,size:V3(Math.max(Rb*2,p.dockD),Hd+6,Math.max(Rb*2,p.dockD)),parts:ps};
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* ---------------- 阶段 F:五款新产品注册 ---------------- */
|
|
|
|
|
+const PROJECT_PIN = {
|
|
|
|
|
+ id:'ai-pin', name:'AI 智能胸针', en:'AI LAPEL PIN', builder:'buildPin',
|
|
|
|
|
+ ref:'Φ40 × 8 钛灰中框 · 亮银环 + 陶瓷底盖',
|
|
|
|
|
+ accent:'#7f8a96',
|
|
|
|
|
+ summary:'Φ40 圆形胸针:钛灰铝中框挖屏沉台、顶面嵌极细亮银金属环,底盖为氧化锆陶瓷;背面磁吸别针弯钩开合,激光投射窗口在底盖边缘。',
|
|
|
|
|
+ params:[
|
|
|
|
|
+ {k:'D', n:'外径', min:34, max:48, step:0.5, def:40, group:'主体'},
|
|
|
|
|
+ {k:'H', n:'中框高', min:6, max:12, step:0.1, def:8, group:'主体'},
|
|
|
|
|
+ {k:'t', n:'壁厚', min:1.0,max:2.6,step:0.1, def:1.6, group:'主体'},
|
|
|
|
|
+ {k:'sd', n:'屏可视径', min:22, max:36, step:0.5, def:30, group:'屏幕'},
|
|
|
|
|
+ {k:'dep', n:'屏沉台深', min:0.3,max:1.2,step:0.1, def:0.5, group:'屏幕'},
|
|
|
|
|
+ {k:'rimW',n:'金属环宽', min:0.6,max:2.4,step:0.1, def:1.2, group:'金属环'},
|
|
|
|
|
+ {k:'ch', n:'底边倒角 C',min:0.2,max:1.2,step:0.1,def:0.3, group:'CNC'},
|
|
|
|
|
+ {k:'cap', n:'陶瓷盖厚', min:0.8,max:2.0,step:0.1, def:1.2, group:'陶瓷盖'},
|
|
|
|
|
+ {k:'pinR',n:'别针丝径', min:0.6,max:2.0,step:0.1, def:1.0, group:'磁吸别针'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ cavity:function(p){ return {kind:'cyl', r:Math.max(2,p.D/2-p.t-1), h:p.H}; },
|
|
|
|
|
+ outer:['mid-frame'],
|
|
|
|
|
+ materials:['alu-graphite','alu-black','alu-silver','alu-rose','ti-brush'],
|
|
|
|
|
+ parts:[
|
|
|
|
|
+ {id:'mid-frame', n:'钛灰铝中框(挖屏沉台)', q:'1', mat:'主材质', proc:'CNC 五轴 + 阳极', tol:'±0.03'},
|
|
|
|
|
+ {id:'rim', n:'极细亮银金属环', q:'1', mat:'SUS 抛光', proc:'车削 + 电解抛光', tol:'±0.02'},
|
|
|
|
|
+ {id:'screen', n:'圆形触摸屏(LTPS+2.5D)',q:'1', mat:'外购模组', proc:'—', tol:'±0.03'},
|
|
|
|
|
+ {id:'back-cover', n:'陶瓷底盖(氧化锆)', q:'1', mat:'陶瓷', proc:'CIM + 抛光', tol:'±0.05'},
|
|
|
|
|
+ {id:'laser', n:'激光投射窗口', q:'1', mat:'BK7 光学玻璃', proc:'—', tol:'±0.02'},
|
|
|
|
|
+ {id:'pin', n:'磁吸别针(SUS 弯钩)', q:'1', mat:'SUS304', proc:'线切割 + 折弯 + 抛光', tol:'±0.1'},
|
|
|
|
|
+ {id:'magnet', n:'对位磁铁 ×4', q:'4', mat:'N42 钕铁硼', proc:'—', tol:'±0.1'},
|
|
|
|
|
+ {id:'btn', n:'触控 / 物理复合键', q:'1', mat:'主材质', proc:'CNC', tol:'±0.03'},
|
|
|
|
|
+ {id:'battery', n:'超薄聚合物锂电', q:'1', mat:'软包', proc:'外购', tol:'±0.2'},
|
|
|
|
|
+ {id:'main-pcb', n:'刚柔结合主板', q:'1', mat:'FR-4+PI', proc:'外协', tol:'±0.05'},
|
|
|
|
|
+ {id:'brass', n:'热熔铜螺母 ×3', q:'3', mat:'黄铜', proc:'热熔', tol:'±0.03'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ steps:[
|
|
|
|
|
+ {n:'中框 CNC + 阳极', d:'先铣外圆与沉台,再铣金属环槽;阳极后退环槽一刀清根,保证环贴死不漏光。'},
|
|
|
|
|
+ {n:'压入金属环', d:'亮银环过盈 0.03 压入环槽,顶面高出中框 0.02,做平面度 0.03 检具。'},
|
|
|
|
|
+ {n:'屏装沉台', d:'2.5D 玻璃落沉台,四周 0.2 缓冲泡棉;沉台深 0.1 过量会顶屏。'},
|
|
|
|
|
+ {n:'陶瓷盖 + 别针', d:'陶瓷盖点胶 + 卡扣双固定;别针尾端从底盖缺口伸出,弹簧片拉力 6~8N。'},
|
|
|
|
|
+ {n:'整机老化', d:'激光窗口对位、磁吸 5N 拉拔、跌落 1m 六面。'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ notes:[
|
|
|
|
|
+ '陶瓷与铝的热膨胀差在温差 40℃ 下约 0.02mm,底部点胶需留 0.1mm 柔性胶层。',
|
|
|
|
|
+ '激光投射窗口必须与发射模组同轴 ±0.05,偏轴会导致投射变形。',
|
|
|
|
|
+ '金属环若阳极同色处理,需先抛光再遮蔽,否则环面被阳极雾化。'
|
|
|
|
|
+ ],
|
|
|
|
|
+ tolerance:[['外径','±0.03'],['中框高','±0.05'],['金属环槽','±0.02'],['别针丝径','±0.03']]
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const PROJECT_EINK = {
|
|
|
|
|
+ id:'eink-tag', name:'电子墨水桌面副屏', en:'E-INK DESK TAG', builder:'buildEink',
|
|
|
|
|
+ ref:'145 × 90 × 9.5 · ABS 前壳 + 隐藏折叠支架',
|
|
|
|
|
+ accent:'#8a9a8c',
|
|
|
|
|
+ summary:'横向 145mm 墨水屏副屏:前壳内凹屏沉台 + 亮边屏框,墨水屏可视区几乎零反射;背面隐藏折叠支架可撑开 90°,壁挂环与磁铁双固定。',
|
|
|
|
|
+ params:[
|
|
|
|
|
+ {k:'L', n:'长', min:100,max:200,step:1, def:145, group:'外形'},
|
|
|
|
|
+ {k:'W', n:'宽', min:60, max:130,step:1, def:90, group:'外形'},
|
|
|
|
|
+ {k:'H', n:'厚', min:6, max:16, step:0.1,def:9.5, group:'外形'},
|
|
|
|
|
+ {k:'r', n:'角 R', min:3, max:24, step:0.5,def:8, group:'外形'},
|
|
|
|
|
+ {k:'t', n:'壁厚', min:1.2,max:3, step:0.1,def:1.8, group:'壁厚'},
|
|
|
|
|
+ {k:'bezel', n:'边框宽', min:5, max:20, step:0.5,def:12, group:'屏框'},
|
|
|
|
|
+ {k:'bezW', n:'亮边宽', min:1.5,max:6, step:0.1,def:2.4, group:'屏框'},
|
|
|
|
|
+ {k:'dep', n:'沉台深', min:0.3,max:1.6,step:0.1,def:0.8, group:'屏框'},
|
|
|
|
|
+ {k:'cap', n:'后盖厚', min:0.8,max:3, step:0.1,def:1.6, group:'后盖'},
|
|
|
|
|
+ {k:'standL', n:'支架长', min:30, max:90, step:1, def:58, group:'支架'},
|
|
|
|
|
+ {k:'standDeg',n:'支架角°', min:20, max:90, step:1, def:65, group:'支架'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ cavity:function(p){ return {kind:'rect', w:p.L-2*p.t, d:p.W-2*p.t, h:p.H}; },
|
|
|
|
|
+ outer:['front-shell','back-cover'],
|
|
|
|
|
+ materials:['abs-matte','abs-gloss','abs-black','alu-sand'],
|
|
|
|
|
+ parts:[
|
|
|
|
|
+ {id:'front-shell', n:'前壳(内凹屏沉台)', q:'1', mat:'主材质', proc:'注塑', tol:'±0.1'},
|
|
|
|
|
+ {id:'front-frame', n:'屏框亮边', q:'1', mat:'主材质', proc:'注塑', tol:'±0.1'},
|
|
|
|
|
+ {id:'screen', n:'电子墨水屏', q:'1', mat:'E-Ink', proc:'—', tol:'±0.1'},
|
|
|
|
|
+ {id:'back-cover', n:'后盖', q:'1', mat:'主材质', proc:'注塑', tol:'±0.1'},
|
|
|
|
|
+ {id:'kick-stand', n:'隐藏折叠支架', q:'1', mat:'主材质', proc:'注塑 + 钢销', tol:'±0.15'},
|
|
|
|
|
+ {id:'back-label', n:'背板铭牌', q:'1', mat:'PET 哑银', proc:'—', tol:'±0.1'},
|
|
|
|
|
+ {id:'speaker', n:'扬声器网罩', q:'1', mat:'SUS 冲孔', proc:'—', tol:'±0.1'},
|
|
|
|
|
+ {id:'btn-refresh', n:'刷新键', q:'1', mat:'主材质', proc:'注塑', tol:'±0.1'},
|
|
|
|
|
+ {id:'btn-power', n:'电源键', q:'1', mat:'主材质', proc:'注塑', tol:'±0.1'},
|
|
|
|
|
+ {id:'rubber-feet', n:'硅胶垫脚 ×4', q:'4', mat:'硅胶', proc:'—', tol:'±0.1'},
|
|
|
|
|
+ {id:'hang-ring', n:'壁挂挂孔件', q:'1', mat:'SUS304', proc:'—', tol:'±0.2'},
|
|
|
|
|
+ {id:'battery', n:'聚合物锂电', q:'1', mat:'软包', proc:'外购', tol:'±0.2'},
|
|
|
|
|
+ {id:'pcb', n:'主板', q:'1', mat:'FR-4', proc:'外协', tol:'±0.1'},
|
|
|
|
|
+ {id:'brass', n:'热熔铜螺母 ×4', q:'4', mat:'黄铜', proc:'热熔', tol:'±0.05'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ steps:[
|
|
|
|
|
+ {n:'前壳沉台与亮边', d:'沉台深 0.8、四周 R0.5,亮边台阶高 0.4 用于压住墨屏边框。'},
|
|
|
|
|
+ {n:'墨水屏入位', d:'屏厚 1.0 + 0.3 泡棉,沉台深公差 ±0.05,深了漏光、浅了顶屏。'},
|
|
|
|
|
+ {n:'支架装配', d:'钢销穿过支架根部的 PEI 轴套,阻尼 0.15~0.25 N·m。'},
|
|
|
|
|
+ {n:'后盖合模', d:'卡扣 6 处 + 2 颗 M2 自攻;垫脚先粘后合,避免压变形。'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ notes:[
|
|
|
|
|
+ '墨水屏是玻璃基板,前壳内圈需 0.3mm 缓冲,跌落测试最容易在角部碎裂。',
|
|
|
|
|
+ '支架撑开角 ≤75° 时重心最稳;超过 80° 易后翻。',
|
|
|
|
|
+ '隐藏支架走的是后盖开口,开口要加 R0.5 圆角防应力开裂。'
|
|
|
|
|
+ ],
|
|
|
|
|
+ tolerance:[['长/宽','±0.1'],['厚','±0.1'],['沉台深','±0.05'],['支架角','±2°']]
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const PROJECT_POCKET = {
|
|
|
|
|
+ id:'pocket-ai', name:'口袋 AI 终端', en:'POCKET AI TERMINAL', builder:'buildPocket',
|
|
|
|
|
+ ref:'90 × 62 翻盖 · 圆柱阻尼铰链 + 独立键帽阵列',
|
|
|
|
|
+ accent:'#7a8ea6',
|
|
|
|
|
+ summary:'掌上翻盖 AI 终端:铝上盖嵌屏、ABS 下盖带独立键帽阵列与电池仓;后侧一整根圆柱阻尼铰链,360° 开合。',
|
|
|
|
|
+ params:[
|
|
|
|
|
+ {k:'L', n:'长', min:70, max:120,step:1, def:90, group:'外形'},
|
|
|
|
|
+ {k:'W', n:'宽', min:45, max:90, step:1, def:62, group:'外形'},
|
|
|
|
|
+ {k:'r', n:'角 R', min:2, max:16, step:0.5,def:6, group:'外形'},
|
|
|
|
|
+ {k:'t', n:'壁厚', min:1.2,max:3, step:0.1,def:1.6,group:'壁厚'},
|
|
|
|
|
+ {k:'lidH', n:'上盖高', min:6, max:16, step:0.5,def:9, group:'开合'},
|
|
|
|
|
+ {k:'baseH', n:'下盖高', min:5, max:16, step:0.5,def:12, group:'开合'},
|
|
|
|
|
+ {k:'gap', n:'合缝', min:0.3,max:2, step:0.1,def:0.8,group:'开合'},
|
|
|
|
|
+ {k:'hingeR', n:'铰链半径', min:1.6,max:4, step:0.1,def:2.6,group:'铰链'},
|
|
|
|
|
+ {k:'bezel', n:'屏边框宽', min:4, max:12, step:0.5,def:6, group:'屏幕'},
|
|
|
|
|
+ {k:'dep', n:'屏沉台深', min:0.3,max:1.6,step:0.1,def:1.0,group:'屏幕'},
|
|
|
|
|
+ {k:'cols', n:'键列数', min:5, max:13, step:1, def:10, group:'键盘'},
|
|
|
|
|
+ {k:'rows', n:'键行数', min:2, max:5, step:1, def:3, group:'键盘'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ cavity:function(p){ return {kind:'rect', w:p.L-2*p.t, d:p.W-2*p.t, h:p.baseH}; },
|
|
|
|
|
+ outer:['top-lid','bottom-cover'],
|
|
|
|
|
+ materials:['alu-silver','alu-black','alu-graphite','abs-matte','abs-gloss'],
|
|
|
|
|
+ parts:[
|
|
|
|
|
+ {id:'top-lid', n:'铝上盖', q:'1', mat:'主材质', proc:'CNC / 压铸 + 阳极', tol:'±0.05'},
|
|
|
|
|
+ {id:'screen-bezel', n:'上盖屏框', q:'1', mat:'主材质', proc:'CNC', tol:'±0.03'},
|
|
|
|
|
+ {id:'screen', n:'触摸屏', q:'1', mat:'IPS', proc:'—', tol:'±0.05'},
|
|
|
|
|
+ {id:'bottom-cover', n:'ABS 下盖', q:'1', mat:'ABS', proc:'注塑', tol:'±0.05'},
|
|
|
|
|
+ {id:'keycap-set', n:'键帽组(独立键帽)',q:'20',mat:'ABS', proc:'双色注塑', tol:'±0.05'},
|
|
|
|
|
+ {id:'hinge', n:'360° 阻尼铰链', q:'1', mat:'SUS304+POM', proc:'车削 + 铆合', tol:'±0.05'},
|
|
|
|
|
+ {id:'power-btn', n:'电源键', q:'1', mat:'ABS', proc:'注塑', tol:'±0.05'},
|
|
|
|
|
+ {id:'battery', n:'聚合物锂电', q:'1', mat:'软包', proc:'外购', tol:'±0.3'},
|
|
|
|
|
+ {id:'battery-bay', n:'电池仓围壁', q:'1', mat:'ABS', proc:'注塑一体', tol:'±0.1'},
|
|
|
|
|
+ {id:'main-pcb', n:'主板', q:'1', mat:'FR-4 HDI', proc:'外协', tol:'±0.1'},
|
|
|
|
|
+ {id:'brass', n:'热熔铜螺母 ×4', q:'4', mat:'黄铜', proc:'热熔', tol:'±0.03'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ steps:[
|
|
|
|
|
+ {n:'上盖 CNC + 阳极', d:'沉台与屏框一刀走完,屏框亮边倒 R0.2。'},
|
|
|
|
|
+ {n:'铰链压装', d:'铰链轴穿上下盖轴套,阻尼 0.05~0.08 N·m/轴,3000 次开合衰减 <15%。'},
|
|
|
|
|
+ {n:'键帽装配', d:'锅仔片贴板后装键帽,键程 0.25,空隙 0.15 不影响手感。'},
|
|
|
|
|
+ {n:'电池入仓', d:'电池仓留 5% 膨胀余量,远离铰链区域避免挤压。'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ notes:[
|
|
|
|
|
+ '翻盖转轴处需要走 FPC:过线槽半径 ≥3mm,否则 3000 次后断线。',
|
|
|
|
|
+ '铝上盖与 ABS 下盖颜色批次要一起核对,双色拼配色差 ΔE≤1。',
|
|
|
|
|
+ '铰链轴套建议用 POM 自润滑,避免长期使用发涩异响。'
|
|
|
|
|
+ ],
|
|
|
|
|
+ tolerance:[['长/宽','±0.05'],['合盖厚','±0.1'],['铰链同轴','≤0.05'],['键帽高差','≤0.1']]
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const PROJECT_BONE = {
|
|
|
|
|
+ id:'bone-headset', name:'颈挂骨传导耳机', en:'NECKBAND BONE HEADSET', builder:'buildBone',
|
|
|
|
|
+ ref:'展开 300 · U 形硅胶颈环 + 钛丝骨架',
|
|
|
|
|
+ accent:'#7d8a7a',
|
|
|
|
|
+ summary:'U 形颈挂骨传导:软胶颈环包住钛记忆丝,两端骨传导模块以椭圆硅胶面贴住颞骨;左侧控制舱带充电防水塞,右侧音量键。',
|
|
|
|
|
+ params:[
|
|
|
|
|
+ {k:'neck', n:'颈环宽', min:90, max:170,step:2, def:120,group:'颈环'},
|
|
|
|
|
+ {k:'width', n:'颈环跨度', min:60, max:120,step:2, def:100,group:'颈环'},
|
|
|
|
|
+ {k:'armLen',n:'臂长', min:20, max:60, step:1, def:40, group:'颈环'},
|
|
|
|
|
+ {k:'bend', n:'上扬高', min:0, max:20, step:0.5,def:10, group:'颈环'},
|
|
|
|
|
+ {k:'tubeR', n:'颈环半径', min:1.5,max:5, step:0.1,def:3, group:'颈环'},
|
|
|
|
|
+ {k:'modH', n:'模块直径', min:8, max:20, step:0.5,def:14, group:'模块'},
|
|
|
|
|
+ {k:'modL', n:'模块长', min:14, max:36, step:1, def:24, group:'模块'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ cavity:function(p){ return {kind:'rect', w:Math.max(6,p.modL*0.8), d:Math.max(6,p.modH*0.8), h:Math.max(4,p.modH*0.8)}; },
|
|
|
|
|
+ outer:['neckband','left-module','right-module'],
|
|
|
|
|
+ materials:['abs-matte','abs-gloss','abs-black','sil-black'],
|
|
|
|
|
+ parts:[
|
|
|
|
|
+ {id:'neckband', n:'U 形软胶颈环', q:'1', mat:'液态硅胶', proc:'包胶', tol:'±0.2'},
|
|
|
|
|
+ {id:'titanium-core', n:'钛记忆丝骨架', q:'1', mat:'TiNi', proc:'—', tol:'±0.3'},
|
|
|
|
|
+ {id:'left-module', n:'左骨传导模块', q:'1', mat:'主材质', proc:'注塑 + 包胶', tol:'±0.1'},
|
|
|
|
|
+ {id:'right-module', n:'右骨传导模块', q:'1', mat:'主材质', proc:'注塑 + 包胶', tol:'±0.1'},
|
|
|
|
|
+ {id:'vibrator-l', n:'左振子贴合面', q:'1', mat:'硅胶 20A', proc:'—', tol:'±0.1'},
|
|
|
|
|
+ {id:'vibrator-r', n:'右振子贴合面', q:'1', mat:'硅胶 20A', proc:'—', tol:'±0.1'},
|
|
|
|
|
+ {id:'module-cover-l', n:'左模块背壳', q:'1', mat:'主材质', proc:'注塑', tol:'±0.1'},
|
|
|
|
|
+ {id:'module-cover-r', n:'右模块背壳', q:'1', mat:'主材质', proc:'注塑', tol:'±0.1'},
|
|
|
|
|
+ {id:'ctrl-module', n:'控制模块', q:'1', mat:'主材质', proc:'注塑', tol:'±0.1'},
|
|
|
|
|
+ {id:'btn-multifn', n:'多功能键', q:'1', mat:'TPU', proc:'—', tol:'±0.1'},
|
|
|
|
|
+ {id:'btn-vol', n:'音量键', q:'1', mat:'TPU', proc:'—', tol:'±0.1'},
|
|
|
|
|
+ {id:'usb-cover', n:'充电口防水盖', q:'1', mat:'TPE', proc:'—', tol:'±0.1'},
|
|
|
|
|
+ {id:'main-pcb', n:'柔性主板', q:'1', mat:'FR-4+FPC', proc:'外协', tol:'±0.1'},
|
|
|
|
|
+ {id:'cell-l', n:'左电池组', q:'1', mat:'软包', proc:'—', tol:'±0.3'},
|
|
|
|
|
+ {id:'cell-r', n:'右电池组', q:'1', mat:'软包', proc:'—', tol:'±0.3'},
|
|
|
|
|
+ {id:'ring-logo', n:'装饰金属环', q:'2', mat:'SUS 拉丝', proc:'—', tol:'±0.1'},
|
|
|
|
|
+ {id:'silicone-plug', n:'钛丝端头封胶', q:'2', mat:'硅胶', proc:'包胶', tol:'±0.1'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ steps:[
|
|
|
|
|
+ {n:'钛丝成型', d:'TiNi 记忆丝按颈环样条定型后热处理,恢复原形的温度 50~60℃。'},
|
|
|
|
|
+ {n:'软胶包覆', d:'包胶壁厚 1.2 以上,两端封胶口直径比钛丝大 0.6。'},
|
|
|
|
|
+ {n:'模块组装', d:'振子与硅胶贴合面用 0.5 过盈,避免漏音。'},
|
|
|
|
|
+ {n:'走线与充电', d:'FPC 从颈环内侧走线到控制舱,充电口防水塞 IPX4。'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ notes:[
|
|
|
|
|
+ '颈环弯曲半径要 <6mm 才不易断,钛丝与软胶的热膨胀差会导致长期使用后端头外露。',
|
|
|
|
|
+ '振子贴合面硅胶越薄声音越清晰,建议 0.8~1.2mm。',
|
|
|
|
|
+ '左右模块必须成对做声学匹配,频响差异 >3dB 会被耳朵听出来。'
|
|
|
|
|
+ ],
|
|
|
|
|
+ tolerance:[['展开宽','±2'],['模块直径','±0.1'],['颈环半径','±0.1'],['振子面贴合','±0.05']]
|
|
|
|
|
+};
|
|
|
|
|
+PROJECT_BONE.materials = ['abs-matte','abs-gloss','abs-black','sil-black','alu-graphite'];
|
|
|
|
|
+
|
|
|
|
|
+const PROJECT_RING = {
|
|
|
|
|
+ id:'smart-ring', name:'智能健康戒指 + 充电舱', en:'SMART RING + DOCK', builder:'buildRing',
|
|
|
|
|
+ ref:'外径 Φ21.6 钛环 + 充电舱',
|
|
|
|
|
+ accent:'#b08d57',
|
|
|
|
|
+ summary:'钛合金外圈 + 环氧内衬的智能戒指:外壁四处蓝宝石透窗,环内一圈弯曲锂电与刚柔主板;充电舱底座 + 亚克力透明罩,戒指半插式充电。',
|
|
|
|
|
+ params:[
|
|
|
|
|
+ {k:'ringD', n:'戒指内径', min:15, max:23, step:0.1,def:19.2,group:'戒指'},
|
|
|
|
|
+ {k:'bandW', n:'截面宽', min:4.5,max:9, step:0.1,def:6.4, group:'戒指'},
|
|
|
|
|
+ {k:'H', n:'截面高', min:4.5,max:10, step:0.1,def:7.6, group:'戒指'},
|
|
|
|
|
+ {k:'dockD', n:'充电舱径', min:28, max:52, step:0.5,def:36, group:'充电舱'},
|
|
|
|
|
+ {k:'dockH', n:'充电舱高', min:6, max:18, step:0.5,def:11, group:'充电舱'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ cavity:function(p){ return {kind:'cyl', r:Math.max(4,p.ringD/2+p.bandW/2), h:p.H}; },
|
|
|
|
|
+ outer:['ti-outer'],
|
|
|
|
|
+ materials:['alu-silver','alu-black','alu-rose','abs-gloss'],
|
|
|
|
|
+ parts:[
|
|
|
|
|
+ {id:'ti-outer', n:'钛外圈', q:'1', mat:'Ti-6Al-4V', proc:'机加工 + 喷砂阳极', tol:'±0.03'},
|
|
|
|
|
+ {id:'resin-inner', n:'树脂内衬', q:'1', mat:'医用环氧', proc:'注塑', tol:'±0.05'},
|
|
|
|
|
+ {id:'battery', n:'弯曲薄膜锂电', q:'1', mat:'柔性锂电', proc:'—', tol:'±0.1'},
|
|
|
|
|
+ {id:'pcb', n:'刚柔主板', q:'1', mat:'4 层刚柔板', proc:'外协', tol:'±0.05'},
|
|
|
|
|
+ {id:'sensor-window', n:'主传感器透窗', q:'1', mat:'蓝宝石', proc:'—', tol:'±0.02'},
|
|
|
|
|
+ {id:'fill-window', n:'辅助透窗', q:'3', mat:'蓝宝石', proc:'—', tol:'±0.02'},
|
|
|
|
|
+ {id:'dock-bottom', n:'充电舱底壳', q:'1', mat:'主材质', proc:'注塑 / CNC', tol:'±0.1'},
|
|
|
|
|
+ {id:'dock-shell', n:'充电舱上壳', q:'1', mat:'主材质', proc:'注塑', tol:'±0.1'},
|
|
|
|
|
+ {id:'dock-lid', n:'充电舱罩(亚克力)', q:'1', mat:'PC 透明', proc:'注塑', tol:'±0.1'},
|
|
|
|
|
+ {id:'dock-button', n:'充电舱按键', q:'1', mat:'主材质', proc:'注塑', tol:'±0.05'},
|
|
|
|
|
+ {id:'dock-battery', n:'充电舱锂电', q:'1', mat:'软包', proc:'—', tol:'±0.2'},
|
|
|
|
|
+ {id:'dock-ring', n:'挂绳扣', q:'1', mat:'SUS304', proc:'—', tol:'±0.2'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ steps:[
|
|
|
|
|
+ {n:'钛圈机加工', d:'内外圆同轴 ≤0.02,透窗开槽 CNC 走刀后电解抛光。'},
|
|
|
|
|
+ {n:'树脂内衬', d:'内衬与钛圈 0.05 过盈,注塑后打磨到 Ra0.8,手感不刮手。'},
|
|
|
|
|
+ {n:'柔性电池贴装', d:'弯曲半径按内圈,贴装后不得有皱褶,否则充电发热。'},
|
|
|
|
|
+ {n:'透窗压合', d:'蓝宝石窗点 UV 胶,胶层 ≤0.05,透光率 ≥92%。'}
|
|
|
|
|
+ ],
|
|
|
|
|
+ notes:[
|
|
|
|
|
+ '戒指尺寸分级 0.5mm,内衬与外圈需留 0.05 公差用于分级。',
|
|
|
|
|
+ '钛外圈会屏蔽射频,蓝牙天线必须从内衬一侧开窗。',
|
|
|
|
|
+ '充电舱透明罩进灰是投诉第一项,罩与底座间隙建议 ≤0.1 并加密封圈。'
|
|
|
|
|
+ ],
|
|
|
|
|
+ tolerance:[['内径','±0.05'],['截面宽/高','±0.05'],['透窗','±0.02'],['充电舱口径','±0.1']]
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+PROJECTS['ai-pin'] = PROJECT_PIN;
|
|
|
|
|
+PROJECTS['eink-tag'] = PROJECT_EINK;
|
|
|
|
|
+PROJECTS['pocket-ai'] = PROJECT_POCKET;
|
|
|
|
|
+PROJECTS['bone-headset'] = PROJECT_BONE;
|
|
|
|
|
+PROJECTS['smart-ring'] = PROJECT_RING;
|
|
|
|
|
+
|
|
|
|
|
+export { PROJECTS, MATERIALS };
|
|
|
|
|
+export default STAGE;
|