dsh-qizhoucnc-cam 1.3.3 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/client.js +21 -13
  2. package/package.json +1 -1
package/client.js CHANGED
@@ -329,27 +329,35 @@ window.__ModuleLoader__.load({
329
329
  const EDGE_SELECTED = '#ff9a3d';
330
330
  const FEAT_FILL = 'rgba(255,154,61,0.72)'; // 已标注特征:橙色高亮
331
331
 
332
- // faces → triangles as individual <polygon> for picking
332
+ // faces → ONE <path> per face (merge all its triangles into a single path).
333
+ // 每个三角形若独立成 <polygon>,复杂 STEP 会有上万 DOM 节点导致崩溃;
334
+ // 合并成单 path 后,DOM 节点数 = 面数,性能与内存都安全。
333
335
  const faceEls = [];
334
336
  for (const f of scene.faces) {
335
337
  const isSel = selected && selected.kind === 'face' && selected.id === f.id;
336
338
  const isFeat = featMap['face:' + f.id];
339
+ let d = '';
340
+ let p0 = null;
337
341
  for (const tri of f.triangles) {
338
342
  const a = f.vertices[tri[0]], b = f.vertices[tri[1]], c = f.vertices[tri[2]];
339
343
  const [ax, ay] = toScreen(a), [bx, by] = toScreen(b), [cx2, cy2] = toScreen(c);
340
- faceEls.push(h('polygon', {
341
- key: 'f' + f.id + '_' + faceEls.length,
342
- points: ax.toFixed(1) + ',' + ay.toFixed(1) + ' ' + bx.toFixed(1) + ',' + by.toFixed(1) + ' ' + cx2.toFixed(1) + ',' + cy2.toFixed(1),
343
- fill: isFeat ? FEAT_FILL : (isSel ? FACE_SELECTED : FACE_FILL),
344
- stroke: isFeat ? '#f97316' : (isSel ? '#f97316' : FACE_STROKE),
345
- strokeWidth: isFeat ? 1 : 0.5, strokeLinejoin: 'round',
346
- style: { cursor: 'pointer' },
347
- onMouseEnter: (e) => { if (!isSel && !isFeat) e.currentTarget.setAttribute('fill', FACE_HOVER); },
348
- onMouseLeave: (e) => { if (!isSel && !isFeat) e.currentTarget.setAttribute('fill', FACE_FILL); },
349
- onClick: clickGuard(() => onSelect({ kind: 'face', id: f.id, center: f.center, area: f.area })),
350
- onDoubleClick: clickGuard(() => onAnnotate({ kind: 'face', id: f.id, center: f.center, area: f.area })),
351
- }));
344
+ d += 'M' + ax.toFixed(1) + ' ' + ay.toFixed(1)
345
+ + 'L' + bx.toFixed(1) + ' ' + by.toFixed(1)
346
+ + 'L' + cx2.toFixed(1) + ' ' + cy2.toFixed(1) + 'Z';
347
+ if (p0 === null) p0 = [ax, ay];
352
348
  }
349
+ faceEls.push(h('path', {
350
+ key: 'f' + f.id,
351
+ d,
352
+ fill: isFeat ? FEAT_FILL : (isSel ? FACE_SELECTED : FACE_FILL),
353
+ stroke: isFeat ? '#f97316' : (isSel ? '#f97316' : FACE_STROKE),
354
+ strokeWidth: isFeat ? 0.8 : 0.4, strokeLinejoin: 'round',
355
+ style: { cursor: 'pointer' },
356
+ onMouseEnter: (e) => { if (!isSel && !isFeat) e.currentTarget.setAttribute('fill', FACE_HOVER); },
357
+ onMouseLeave: (e) => { if (!isSel && !isFeat) e.currentTarget.setAttribute('fill', FACE_FILL); },
358
+ onClick: clickGuard(() => onSelect({ kind: 'face', id: f.id, center: f.center, area: f.area })),
359
+ onDoubleClick: clickGuard(() => onAnnotate({ kind: 'face', id: f.id, center: f.center, area: f.area })),
360
+ }));
353
361
  }
354
362
  // edges as individual <polyline> for picking
355
363
  const edgeEls = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-qizhoucnc-cam",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "description": "CNC program (NC/CNC/G-code) toolpath recognition, 3D toolpath + 3D STEP model viewport (face/edge machining-position annotation), and a large editing view with quote-to-composer, for DeepSeek Harness (DSH). Made by Chengdu Qizhou Machinery Technology Co., Ltd., for research and study only.",
5
5
  "type": "module",
6
6
  "license": "MIT",