am-freescan/scripts/verify_scanner_model_files.mjs
lixiaolong 6f8a40644c feat(scanner): 完善补扫、执行监控及资源释放
完善扫描流式预览、成果归档与PLY/STL查看、补扫历史、执行步骤及日志展示,支持局域网访问和改名节点的原始组件识别。修复试运行终止后的占用释放及未采集时重复暂停SDK的问题,增加终止中交互与回归验证。

验证:后端1114项通过、18项既有跳过;前端109项通过,类型检查及构建通过;Python脚本54项通过;模拟扫描设备7组试运行/终止接口回归通过。
2026-10-26 11:04:07 +08:00

32 lines
1.9 KiB
JavaScript

// Read-only local export verification; no scanner controls or business writes.
import fs from 'node:fs'
import { parseScannerModelAsync } from '../am-web/src/views/lab/scan-task/scannerModelWorker.mjs'
import { nodeModelWorker } from '../am-web/src/views/lab/scan-task/scannerModelWorkerTestHelper.mjs'
import { hydrateScannerModel } from '../am-web/src/views/lab/scan-task/scannerModelTransfer.mjs'
import { disposeScannerModel } from '../am-web/src/views/lab/scan-task/scannerModel.mjs'
if (!process.argv.slice(2).length) throw new Error('Provide local PLY/STL/OBJ file paths')
for (const path of process.argv.slice(2)) {
const bytes = fs.readFileSync(path)
const name = fs.existsSync(path + '.json')
? JSON.parse(fs.readFileSync(path + '.json', 'utf8')).name
: path.split(/[\\/]/).pop()
const started = performance.now()
let ticks = 0
const timer = setInterval(() => ticks++, 5)
try {
const data = await parseScannerModelAsync(bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength), name, undefined, nodeModelWorker)
const hydrateStarted = performance.now()
const model = hydrateScannerModel(data)
try {
console.log(JSON.stringify({ name, bytes: bytes.byteLength,
vertices: model.vertices, triangles: model.triangles, points: model.points,
workerParseMs: Math.round(data.parseMs), hydrateMs: Math.round(performance.now() - hydrateStarted),
totalMs: Math.round(performance.now() - started), eventLoopTicks: ticks,
bounds: { min: model.bounds.min.toArray(), max: model.bounds.max.toArray() },
gpuBytes: data.drawables.reduce((sum, drawable) => sum + Object.values(drawable.attributes)
.reduce((size, attribute) => size + attribute.array.byteLength, 0) + (drawable.index?.byteLength || 0), 0) }))
} finally { disposeScannerModel(model.object) }
} finally { clearInterval(timer) }
}