index.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
  6. <meta name="theme-color" content="#f3f3f3">
  7. <title>3D Viewer</title>
  8. <link rel="icon" href="img/module_icon.svg">
  9. <script src="../script/jquery.min.js"></script>
  10. <script src="../script/ao_module.js"></script>
  11. <link rel="stylesheet" href="css/style.css">
  12. <script type="importmap">
  13. {
  14. "imports": {
  15. "three": "./lib/three/three.module.min.js",
  16. "three/addons/": "./lib/three/addons/"
  17. }
  18. }
  19. </script>
  20. </head>
  21. <body>
  22. <!-- ================= Icon sprite (rule 6: hand drawn inline SVG, no emoji) ================= -->
  23. <svg id="iconsprite" aria-hidden="true" focusable="false">
  24. <defs>
  25. <symbol id="ic-file" viewBox="0 0 24 24">
  26. <path d="M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8l-5-5z" />
  27. <path d="M14 3v5h5" />
  28. </symbol>
  29. <symbol id="ic-fit" viewBox="0 0 24 24">
  30. <path d="M4 9V5h4M20 9V5h-4M4 15v4h4M20 15v4h-4" />
  31. </symbol>
  32. <symbol id="ic-center" viewBox="0 0 24 24">
  33. <circle cx="12" cy="12" r="5" />
  34. <circle cx="12" cy="12" r="1.4" fill="currentColor" stroke="none" />
  35. <path d="M12 2v3M12 19v3M2 12h3M19 12h3" />
  36. </symbol>
  37. <symbol id="ic-rotate" viewBox="0 0 24 24">
  38. <path d="M20 12a8 8 0 1 1-2.6-5.9" />
  39. <path d="M20 4v4h-4" />
  40. </symbol>
  41. <symbol id="ic-pan" viewBox="0 0 24 24">
  42. <path d="M9 11V5.5a1.5 1.5 0 0 1 3 0V11" />
  43. <path d="M12 11V4.5a1.5 1.5 0 0 1 3 0V11" />
  44. <path d="M15 11V6.5a1.5 1.5 0 0 1 3 0V13" />
  45. <path d="M9 11V9.5a1.5 1.5 0 0 0-3 0V15c0 3.3 2.2 6 5.5 6h1.5c3 0 5-2.4 5-5.5V13" />
  46. </symbol>
  47. <symbol id="ic-zoom" viewBox="0 0 24 24">
  48. <circle cx="11" cy="11" r="6.5" />
  49. <path d="M16 16l4.5 4.5" />
  50. </symbol>
  51. <symbol id="ic-expand" viewBox="0 0 24 24">
  52. <path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5" />
  53. </symbol>
  54. <symbol id="ic-cube-solid" viewBox="0 0 24 24">
  55. <path d="M12 2.6l8 4.2v9.4l-8 4.2-8-4.2V6.8z" />
  56. <path d="M4 6.8l8 4.2 8-4.2M12 11v9.4" />
  57. </symbol>
  58. <symbol id="ic-cube-wire" viewBox="0 0 24 24">
  59. <path d="M12 2.6l8 4.2v9.4l-8 4.2-8-4.2V6.8z" />
  60. <path d="M4 6.8l8 4.2 8-4.2M12 11v9.4M4 16.2l8-5.2 8 5.2M12 2.6v8.4" opacity=".55" />
  61. </symbol>
  62. <symbol id="ic-cube-xray" viewBox="0 0 24 24">
  63. <path d="M12 2.6l8 4.2v9.4l-8 4.2-8-4.2V6.8z" stroke-dasharray="3 2.4" />
  64. <path d="M4 6.8l8 4.2 8-4.2M12 11v9.4" stroke-dasharray="2.4 2.4" opacity=".7" />
  65. </symbol>
  66. <symbol id="ic-undo" viewBox="0 0 24 24">
  67. <path d="M4 12a8 8 0 1 0 2.6-5.9" />
  68. <path d="M4 4v4h4" />
  69. </symbol>
  70. <symbol id="ic-sun" viewBox="0 0 24 24">
  71. <circle cx="12" cy="12" r="4" />
  72. <path d="M12 2v2.4M12 19.6V22M2 12h2.4M19.6 12H22M4.9 4.9l1.7 1.7M17.4 17.4l1.7 1.7M19.1 4.9l-1.7 1.7M6.6 17.4l-1.7 1.7" />
  73. </symbol>
  74. <symbol id="ic-image" viewBox="0 0 24 24">
  75. <rect x="3" y="4.5" width="18" height="15" rx="2.2" />
  76. <circle cx="8.5" cy="10" r="1.6" />
  77. <path d="M4 17l5-4.6 4.2 3.8 3-2.6L20 17.6" />
  78. </symbol>
  79. <symbol id="ic-chevron" viewBox="0 0 24 24">
  80. <path d="M6 9.5l6 6 6-6" />
  81. </symbol>
  82. <symbol id="ic-view-top" viewBox="0 0 24 24">
  83. <rect x="6" y="6" width="12" height="12" rx="1.4" />
  84. </symbol>
  85. <symbol id="ic-view-front" viewBox="0 0 24 24">
  86. <path d="M6 8.6l6-3.2 6 3.2v7l-6 3.2-6-3.2z" opacity=".45" />
  87. <path d="M6 8.6l6 3.2 6-3.2M12 11.8v6.9" />
  88. </symbol>
  89. <symbol id="ic-view-right" viewBox="0 0 24 24">
  90. <path d="M6 8.6l6-3.2 6 3.2v7l-6 3.2-6-3.2z" opacity=".45" />
  91. <path d="M12 11.8l6-3.2v7l-6 3.2z" fill="currentColor" fill-opacity=".18" />
  92. <path d="M6 8.6l6 3.2 6-3.2M12 11.8v6.9" />
  93. </symbol>
  94. <symbol id="ic-view-iso" viewBox="0 0 24 24">
  95. <path d="M12 3.4l8.2 4.3v8.6L12 20.6l-8.2-4.3V7.7z" />
  96. <path d="M3.8 7.7l8.2 4.3 8.2-4.3M12 12v8.6" />
  97. </symbol>
  98. <symbol id="ic-folder" viewBox="0 0 24 24">
  99. <path d="M3 7.5A1.5 1.5 0 0 1 4.5 6h4l2 2.4h9A1.5 1.5 0 0 1 21 10v7.5a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 17.5z" />
  100. </symbol>
  101. <symbol id="ic-warning" viewBox="0 0 24 24">
  102. <path d="M12 3.6l9 15.6H3z" />
  103. <path d="M12 9.4v4.4M12 16.4v.1" />
  104. </symbol>
  105. </defs>
  106. </svg>
  107. <div id="app">
  108. <div id="workspace">
  109. <!-- ============================ LEFT PANEL ============================ -->
  110. <aside class="side" id="leftPanel">
  111. <div class="side-scroll">
  112. <!-- File info -->
  113. <section class="card file-card" id="fileCard" title="Reveal in File Manager">
  114. <div class="file-ic"><svg class="ic"><use href="#ic-file" /></svg></div>
  115. <div class="file-meta">
  116. <div class="file-name" id="fileName">No model loaded</div>
  117. <div class="file-sub" id="fileType">&mdash;</div>
  118. <div class="file-sub" id="fileDim">&mdash;</div>
  119. <div class="file-sub" id="fileSize">&mdash;</div>
  120. </div>
  121. </section>
  122. <!-- View -->
  123. <section class="card">
  124. <h3 class="card-title">View</h3>
  125. <div class="segmented" id="viewModes">
  126. <button class="seg active" data-mode="solid">
  127. <svg class="ic"><use href="#ic-cube-solid" /></svg><span>Solid</span>
  128. </button>
  129. <button class="seg" data-mode="wireframe">
  130. <svg class="ic"><use href="#ic-cube-wire" /></svg><span>Wireframe</span>
  131. </button>
  132. <button class="seg" data-mode="xray">
  133. <svg class="ic"><use href="#ic-cube-xray" /></svg><span>X-Ray</span>
  134. </button>
  135. </div>
  136. <div class="field-label">Model Color</div>
  137. <div class="color-field">
  138. <button class="color-btn" id="colorBtn">
  139. <span class="swatch" id="colorSwatch"></span>
  140. <svg class="ic chev"><use href="#ic-chevron" /></svg>
  141. </button>
  142. <div class="palette" id="palette" hidden></div>
  143. </div>
  144. </section>
  145. <!-- Lighting -->
  146. <section class="card">
  147. <h3 class="card-title">
  148. <svg class="ic title-ic"><use href="#ic-sun" /></svg>Lighting
  149. </h3>
  150. <div class="select-wrap">
  151. <select id="lightingPreset">
  152. <option value="studio">Studio</option>
  153. <option value="soft">Soft</option>
  154. <option value="dramatic">Dramatic</option>
  155. <option value="flat">Flat</option>
  156. </select>
  157. <svg class="ic chev"><use href="#ic-chevron" /></svg>
  158. </div>
  159. <div class="field-label">Brightness</div>
  160. <div class="slider-row">
  161. <input type="range" id="brightness" min="10" max="200" step="5" value="100">
  162. <span class="slider-val" id="brightnessVal">100%</span>
  163. </div>
  164. </section>
  165. <!-- Background -->
  166. <section class="card">
  167. <h3 class="card-title">
  168. <svg class="ic title-ic"><use href="#ic-image" /></svg>Background
  169. </h3>
  170. <div class="radio-list" id="bgOptions">
  171. <label class="radio checked"><input type="radio" name="bg" value="light" checked><span class="dot"></span>Light</label>
  172. <label class="radio"><input type="radio" name="bg" value="dark"><span class="dot dark"></span>Dark</label>
  173. <label class="radio"><input type="radio" name="bg" value="gradient"><span class="dot grad"></span>Gradient</label>
  174. </div>
  175. </section>
  176. <!-- More -->
  177. <section class="card collapsible" id="moreCard">
  178. <h3 class="card-title toggle" id="moreToggle">
  179. More
  180. <svg class="ic chev"><use href="#ic-chevron" /></svg>
  181. </h3>
  182. <div class="card-body">
  183. <div class="switch-row">
  184. <span>Show Shadows</span>
  185. <label class="switch">
  186. <input type="checkbox" id="showShadows" checked><span class="track"></span>
  187. </label>
  188. </div>
  189. </div>
  190. </section>
  191. </div>
  192. <div class="side-foot">
  193. <button class="ghost-btn" id="btnReset">
  194. <svg class="ic"><use href="#ic-undo" /></svg><span>Reset View</span>
  195. </button>
  196. </div>
  197. </aside>
  198. <!-- ============================== CENTER ============================== -->
  199. <main id="center">
  200. <div class="card toolbar">
  201. <button class="drawer-toggle" id="btnLeftDrawer" aria-label="Model info">
  202. <svg class="ic"><use href="#ic-file" /></svg>
  203. </button>
  204. <div class="tool-group">
  205. <button class="tool" id="btnFit" data-tip="Fit model to view">
  206. <svg class="ic"><use href="#ic-fit" /></svg><span>Fit</span>
  207. </button>
  208. <button class="tool" id="btnCenter" data-tip="Recenter on model">
  209. <svg class="ic"><use href="#ic-center" /></svg><span>Center</span>
  210. </button>
  211. <button class="tool mode active" data-nav="rotate" data-tip="Drag to orbit">
  212. <svg class="ic"><use href="#ic-rotate" /></svg><span>Rotate</span>
  213. </button>
  214. <button class="tool mode" data-nav="pan" data-tip="Drag to pan">
  215. <svg class="ic"><use href="#ic-pan" /></svg><span>Pan</span>
  216. </button>
  217. <button class="tool mode" data-nav="zoom" data-tip="Drag to zoom">
  218. <svg class="ic"><use href="#ic-zoom" /></svg><span>Zoom</span>
  219. </button>
  220. </div>
  221. <div class="tool-boxed">
  222. <button class="tool" id="btnFullscreen" data-tip="Toggle fullscreen">
  223. <svg class="ic"><use href="#ic-expand" /></svg>
  224. </button>
  225. </div>
  226. </div>
  227. <div id="stage" class="bg-light">
  228. <canvas id="gl"></canvas>
  229. <!-- empty / loading / error overlays -->
  230. <div class="stage-overlay" id="emptyState">
  231. <svg class="ic big"><use href="#ic-view-iso" /></svg>
  232. <p>Open a 3D model to begin.</p>
  233. <p class="hint">STL &middot; OBJ &middot; GLB &middot; glTF &middot; PLY &middot; 3MF &middot; FBX &middot; DAE &middot; STEP &middot; IGES &middot; BREP &middot; G-code</p>
  234. <button class="ghost-btn" id="btnOpen">
  235. <svg class="ic"><use href="#ic-folder" /></svg><span>Open file</span>
  236. </button>
  237. <p class="hint">or drop a file anywhere on this window</p>
  238. </div>
  239. <div class="stage-overlay" id="loadingState" hidden>
  240. <div class="spinner"></div>
  241. <p id="loadingText">Loading model...</p>
  242. </div>
  243. <div class="stage-overlay" id="errorState" hidden>
  244. <svg class="ic big"><use href="#ic-warning" /></svg>
  245. <p id="errorText">Could not load this model.</p>
  246. <button class="ghost-btn" id="btnErrorOpen">
  247. <svg class="ic"><use href="#ic-folder" /></svg><span>Open another file</span>
  248. </button>
  249. </div>
  250. <!-- layer height cut, G-code only -->
  251. <div class="layerbar" id="layerBar" hidden>
  252. <div class="layer-readout" id="layerReadout">&mdash;</div>
  253. <input type="range" id="layerRange" min="0" max="1" step="0.01" value="1"
  254. aria-label="Fade layers above this height">
  255. <div class="layer-caption">Z</div>
  256. </div>
  257. <!-- view presets -->
  258. <div class="viewbar" id="viewPresets">
  259. <button class="tool" data-view="top">
  260. <svg class="ic"><use href="#ic-view-top" /></svg><span>Top</span>
  261. </button>
  262. <button class="tool" data-view="front">
  263. <svg class="ic"><use href="#ic-view-front" /></svg><span>Front</span>
  264. </button>
  265. <button class="tool" data-view="right">
  266. <svg class="ic"><use href="#ic-view-right" /></svg><span>Right</span>
  267. </button>
  268. <button class="tool active" data-view="iso">
  269. <svg class="ic"><use href="#ic-view-iso" /></svg><span>Iso</span>
  270. </button>
  271. </div>
  272. </div>
  273. </main>
  274. <div id="scrim"></div>
  275. </div>
  276. </div>
  277. <div id="dropzone"><div class="dz-inner">Drop a 3D model to open</div></div>
  278. <script type="module" src="js/app.js"></script>
  279. </body>
  280. </html>