printbench 0.8.0 → 0.8.2

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.
package/README.md CHANGED
@@ -56,7 +56,9 @@ function onExported(payload: PrintBenchExportedPayload) {
56
56
  if (payload.cancelled) return
57
57
  // payload.action: 'download' | 'upload'
58
58
  // payload.blob / fileName / format / unit / size
59
- // payload.longestEdgeMm — 若导出时指定了按最长边缩放
59
+ // payload.longestEdgeMm — 若导出时指定了目标边长缩放
60
+ // payload.scaleAxis — 若按 X/Y/Z 轴缩放(最长边模式不带此字段)
61
+ // payload.partIds / modelSize — 分件导出时带回写出的零件与缩放后整模尺寸
60
62
  }
61
63
  </script>
62
64
 
@@ -97,7 +99,7 @@ function onExported(payload: PrintBenchExportedPayload) {
97
99
  | `features` | `{ numeric?, primitives?, split?, autoSplit?, drafts?, extras?, restore?, layout?, importUnit?, hideEmpty?, hideTour?, hideStatusBar?, hidePanelModeToggle?, hidePreviewLighting?, annotations?, … }` | 能力项默认 `false` | 进阶能力。缺省精简:左栏仅导入 / 零件 / 导出 / 快照。未开 `drafts` 时不读不写自动草稿。导入单位优先用文件声明,否则按包围盒尺寸推测 mm/cm/m 再换算到内部毫米;开 `importUnit` 时可再确认。`split` 为切面拆件;`autoSplit` 为「自动拆件」按钮(默认隐藏,需显式打开)。`restore` 为「复原到导入状态」按钮(默认隐藏,宿主需显式打开;完整工作台预设已开启)。`layout` 打开贴地 / 镜像 / 目标尺寸缩放 / 选面朝下与打印床体积。`annotations` 打开模型批注(默认关闭,`PRINTBENCH_FULL_FEATURES` 也不含该项)。`hideEmpty` / `hideTour` / `hideStatusBar` / `hidePanelModeToggle` / `hidePreviewLighting` 为 `true` 时分别隐藏空画布提示、首次引导 Tour(可与 `extras` 同开)、底栏状态条、零件栏悬浮/通栏切换按钮、预览模式左上角灯光模式控件(默认显示)。 |
98
100
 
99
101
 
100
- 嵌入预览示例(宿主列表 + 色板 + 自定义导出 + 按最长边缩放):
102
+ 嵌入预览示例(宿主列表 + 色板 + 自定义导出 + 按轴/最长边缩放):
101
103
 
102
104
  ```vue
103
105
  <script setup lang="ts">
@@ -122,7 +124,10 @@ async function download() {
122
124
  action: 'download',
123
125
  format: '3mf',
124
126
  unit: 'mm',
125
- longestEdgeMm: 120, // 可选:等比缩放到最长边 120mm 后再导出
127
+ longestEdgeMm: 120, // 可选:目标边长 mm;省略 scaleAxis 则按最长边
128
+ scaleAxis: 'x', // 可选:'x' | 'y' | 'z';省略则按最长边等比缩放
129
+ scaleBasis: 'model', // 默认;分件时用整模比例,导出后仍可组装
130
+ // partIds: [parts.value[0]?.id].filter(Boolean) as string[],
126
131
  silent: true,
127
132
  })
128
133
  if (!file || file.cancelled) return
@@ -137,6 +142,7 @@ async function upload() {
137
142
  action: 'upload',
138
143
  format: 'glb',
139
144
  longestEdgeMm: 120,
145
+ scaleAxis: 'x',
140
146
  })
141
147
  if (!file || file.cancelled) return
142
148
  // 宿主自己的上传;custom-export 时插件不 POST,只返回 blob
@@ -166,7 +172,7 @@ async function upload() {
166
172
 
167
173
  `mode="preview"` 时插件不显示导出 / 快照按钮。宿主用 `ref.exportFile()` / `ref.exportSnapshot()` 只要文件:`customExport` 为 true 时不本地下载、不 POST,返回 `blob` 后由宿主保存或上传。工作台左栏导出与快照仍可用 `uploadUrl` 走插件上传。预览画布左上角默认显示灯光模式(与设置中同一套:`neutral` 标准照明、`studio` 摄影棚、`ibl` 环境光照、`headlamp` 跟随头灯);宿主可设 `:features="{ hidePreviewLighting: true }"` 隐藏该控件。
168
174
 
169
- `exportFile` 的 `longestEdgeMm` 与导出对话框「最长边」一致:按内部毫米将整模 AABB 最长边缩到该值后再换算 `unit` 写出。省略则不缩放。
175
+ `exportFile` 的 `longestEdgeMm` 与导出对话框「目标边长」一致:按内部毫米将参考边(默认最长边,或 `scaleAxis` 指定的 X/Y/Z)缩到该值后再换算 `unit` 写出。省略则不缩放。默认 `scaleBasis: 'model'`(按整模 AABB 算统一比例);`partIds` 只过滤写出内容,不改变比例,分件后仍可组装。`scaleBasis: 'exportSet'` 则按写出集合自身 AABB 缩放。
170
176
 
171
177
  `@parts` 在导入/求值/变换后给出零件列表。`id` 为 meshId 或基本体/布尔节点 id,不要用下标当主键。每项含 `size`(当前 AABB 边长 mm)与 `initialSize`(导入时该 id 的边长;导入后新建的零件为 `null`)。
172
178
 
@@ -179,7 +185,7 @@ async function upload() {
179
185
  | -------------------- | ------------------------------------------------- | -------------------------------------------------- |
180
186
  | `ready` | — | 几何内核就绪 |
181
187
  | `error` | `string` | 可展示错误 |
182
- | `exported` | `{ action, format, fileName, blob, unit, size, longestEdgeMm?, axis? }` | 网格导出完成。`action` 为 `'download'`(下载)或 `'upload'`(一键上传);`size` 为导出单位下的包围盒 `[x,y,z]`;若按最长边缩放则带 `longestEdgeMm`(mm) |
188
+ | `exported` | `{ action, format, fileName, blob, unit, size, longestEdgeMm?, scaleAxis?, scaleBasis?, partIds?, modelSize?, axis? }` | 网格导出完成。`size` 为本次 blob 内网格包围盒;分件且按整模缩放时带 `modelSize`;`partIds` 为实际写出的零件 |
183
189
  | `snapshot` | `{ action, format, fileName, blob, mime, width, height }` | 模型快照完成。`format` 为 `'png'` \| `'jpeg'` |
184
190
  | `report` | 审核报告对象 | 下载 JSON / HTML 审核报告时触发 |
185
191
  | `parts` | `{ id, index, name, initialSize, size, unit }[]` | 零件列表;`size` 为当前尺寸,`initialSize` 为导入时尺寸(无则为 `null`) |
@@ -198,7 +204,7 @@ async function upload() {
198
204
 
199
205
  | 方法 | 说明 |
200
206
  | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
201
- | `exportFile(options?)` | 不打开插件对话框。`action`: `'download'` \| `'upload'`;`format`: `'stl'` \| `'3mf'` \| `'glb'`;`unit` 默认 mm;`longestEdgeMm` 可选,按该毫米最长边等比缩放后再导出;`silent: true` 跳过黄级确认。红级阻断返回 `null`。成功返回与 `exported` 相同的 payload。 |
207
+ | `exportFile(options?)` | 不打开插件对话框。`action` / `format` / `unit` 同上;`longestEdgeMm` + `scaleAxis?` 等比缩放;`scaleBasis`: `'model'`(默认,整模比例)\| `'exportSet'`;`partIds` 只导出指定零件;`silent: true` 跳过确认。成功返回与 `exported` 相同的 payload。 |
202
208
  | `exportSnapshot(options?)` | 按当前视角截取模型图(不含网格、手柄、切面)。`action`: `'download'` \| `'upload'`;`format`: `'png'`(默认)\| `'jpeg'`;`quality` 仅 JPEG。成功返回与 `snapshot` 相同的 payload。`customExport` 时不本地下载、不 POST。 |
203
209
  | `autoSplit(options?)` | 多零件接触面自动装配(≥2 件)。检测接触后一端保留凸起、一端挖槽,再加卡扣。`connector`: `'ballSnap'` \| `'sphere'` \| `'square'`(默认 `ballSnap` 爪扣);`connectorSize` 可选;`silent: true` 时不弹修复确认,未封闭则返回 `{ ok: false, needsRepair: true, repairPartNames }`。成功 `{ ok: true }`。 |
204
210
  | `getPartBounds()` | 同步返回与 `@parts` 相同结构的零件列表(含 `initialSize` / `size`)。无模型时为 `[]`。 |
@@ -290,7 +296,7 @@ JSON 结构:
290
296
  - **STL**:二进制;无单位字段,切片软件需与导出单位一致(推荐毫米)。单零件 `.stl`,多零件 `.zip`(每件一个 STL)。不含颜色。
291
297
  - **3MF**:自带毫米单位;每零件单独 object,并写入 `displaycolor`(零件打印色)
292
298
  - **GLB**:单文件多网格;零件打印色写入材质。无打印单位字段,坐标按导出单位解释。
293
- - **最长边缩放**:导出对话框可填「最长边 mm」(默认预填当前尺寸);或 `exportFile({ longestEdgeMm })`。先按毫米等比缩放,再按所选 `unit` 写出。
299
+ - **目标边长缩放**:导出对话框可选参考轴(最长边 / X / Y / Z)、缩放基准(整模 / 仅导出零件)并填「目标边长 mm」;可勾选「仅导出选中」。宿主:`exportFile({ longestEdgeMm, scaleAxis?, scaleBasis?, partIds? })`。先按毫米等比缩放,再按所选 `unit` 写出。按件循环且需可组装时用默认 `scaleBasis: 'model'`。
294
300
  - **快照**:PNG / JPEG。按当前相机截取模型,不含工作台网格、变换手柄、拆件切面与测量。下载或一键上传(同 `uploadUrl` / `customExport`)。嵌入预览用 `exportSnapshot()`。
295
301
 
296
302
  ### 快捷键
@@ -1,5 +1,5 @@
1
1
  import j from "jszip";
2
- import { h as w, r as R } from "./index-Ci-Js4Ma.js";
2
+ import { h as w, r as R } from "./index-Cwlaqcgp.js";
3
3
  function p(s, l) {
4
4
  return s.match(new RegExp(`\\b${l}\\s*=\\s*"([^"]*)"`, "i"))?.[1];
5
5
  }
@@ -1,6 +1,6 @@
1
1
  import { Group as w, Mesh as l, MeshStandardMaterial as u, DoubleSide as h, Color as c } from "three";
2
2
  import { GLTFExporter as p } from "three/examples/jsm/exporters/GLTFExporter.js";
3
- import { b as d } from "./index-Ci-Js4Ma.js";
3
+ import { b as d } from "./index-Cwlaqcgp.js";
4
4
  async function G(r, e, n) {
5
5
  const t = new w();
6
6
  t.name = "PrintBench", r.forEach((f, o) => {