feat: 后置高刚性防倾翻测试台架与J1电机镂空散热防拉脱托架整合 (P01/P02/P03重构)
This commit is contained in:
+16
-2
@@ -13,9 +13,19 @@ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
from armcore import WEB, DOCS, WORKSPACE
|
||||
SRC = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
import time
|
||||
|
||||
def rebuild_viewer():
|
||||
print("=" * 80, flush=True)
|
||||
print("【第五阶段 5/5】打包单文件三维交互查看器 (机器人手臂3D查看器.html)...", flush=True)
|
||||
print("=" * 80, flush=True)
|
||||
t0 = time.time()
|
||||
print(" - 读取 Three.js 离线 3D 渲染内核...", end="", flush=True)
|
||||
three = io.open(WEB + "/three_inline.js", encoding="utf-8").read()
|
||||
assert len(three) > 400000, len(three)
|
||||
print(f" 完成 ({len(three)/1024:.0f} KB) ✓", flush=True)
|
||||
|
||||
print(" - 读取几何网格与关节运动学数据...", end="", flush=True)
|
||||
data = io.open(WEB + "/mesh_arm.json", encoding="utf-8").read()
|
||||
sheets = io.open(WEB + "/sheets.jsdata", encoding="utf-8").read()
|
||||
col = io.open(DOCS + "/collision.json", encoding="utf-8").read() if os.path.exists(
|
||||
@@ -23,6 +33,9 @@ def rebuild_viewer():
|
||||
trv = io.open(DOCS + "/travel.json", encoding="utf-8").read() if os.path.exists(
|
||||
DOCS + "/travel.json") else "[]"
|
||||
tpl = io.open(SRC + "/viewer_tpl.html", encoding="utf-8").read()
|
||||
print(f" 完成 ({len(data)/1024:.0f} KB) ✓", flush=True)
|
||||
|
||||
print(" - 打包生成全内置单文件 HTML...", end="", flush=True)
|
||||
out = (tpl.replace("/*__THREE__*/", three)
|
||||
.replace("/*__DATA__*/", data)
|
||||
.replace("/*__SHEETS__*/", sheets)
|
||||
@@ -33,8 +46,9 @@ def rebuild_viewer():
|
||||
io.open(dst, "w", encoding="utf-8").write(out)
|
||||
io.open(WEB + "/index.html", "w", encoding="utf-8").write(out)
|
||||
io.open(WORKSPACE + "/机器人手臂3D查看器.html", "w", encoding="utf-8").write(out)
|
||||
print("viewer %s (and in %s) %.2f MB (three %.0f KB + data %.0f KB + sheets %.0f KB)" % (
|
||||
dst, WORKSPACE, os.path.getsize(dst) / 1e6, len(three) / 1024, len(data) / 1024, len(sheets) / 1024))
|
||||
sz_mb = os.path.getsize(dst) / 1e6
|
||||
print(f" 完成 ({sz_mb:.2f} MB, 耗时: {time.time()-t0:.2f}s) ✓", flush=True)
|
||||
print(f"-> 3D查看器已更新至: {dst} 与 根目录/机器人手臂3D查看器.html\n", flush=True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
rebuild_viewer()
|
||||
|
||||
Reference in New Issue
Block a user