slicer-studio 0.3.1 → 0.5.1
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 +54 -22
- package/dist/chunks/ModelPreview-BhBbyX4m.js +61 -0
- package/dist/chunks/PlateEditor-DaNsLzLu.js +1 -0
- package/dist/chunks/{Viewer3D-o2piEXHZ.js → Viewer3D-Bxur8Sh0.js} +2 -2
- package/dist/chunks/bounds-C11tinGE.js +1 -0
- package/dist/chunks/fflate.module-ChfQ5943.js +1 -0
- package/dist/chunks/files-BZtizmc1.js +1 -0
- package/dist/chunks/model-read-F5cM3GZJ.js +5 -0
- package/dist/chunks/plate-3mf-GYeMGaLV.js +15 -0
- package/dist/chunks/plate-geometry-Dd9vKDEP.js +1 -0
- package/dist/chunks/plate-mesh-BoEG27Tx.js +1 -0
- package/dist/chunks/three.core-BHZv2AuD.js +5 -0
- package/dist/chunks/three.module-CQAbjdTy.js +4216 -0
- package/dist/chunks/thumbnail-RKI9IqqD.js +1 -0
- package/dist/chunks/tip-BR1chAbl.js +5 -0
- package/dist/chunks/triangle-alert-5i_bibCW.js +1 -0
- package/dist/chunks/useThemeColors-HWc0Ka_J.js +12 -0
- package/dist/chunks/view-B-ChJ0zi.js +1 -0
- package/dist/slicer-studio.js +22 -22
- package/package.json +1 -1
- package/dist/chunks/ModelPreview-CYVyGDd1.js +0 -61
- package/dist/chunks/files-uJ4WD9Mr.js +0 -1
- package/dist/chunks/model-read-UJhMfy15.js +0 -5
- package/dist/chunks/three.module-MNvRIzJI.js +0 -4220
- package/dist/chunks/thumbnail-21laMIqI.js +0 -1
- package/dist/chunks/tip-C-Kdakwj.js +0 -5
- package/dist/chunks/useThemeColors-Dpdj0pe9.js +0 -12
package/README.md
CHANGED
|
@@ -20,10 +20,12 @@ OrcaSlicer, which does the slicing and holds your printers and prices.
|
|
|
20
20
|
the material, finish, strength and number of copies, then see the price, weight and print time. Every price uses your
|
|
21
21
|
default printer. SLA and SLS jobs get an email button to your lab instead of a price.
|
|
22
22
|
|
|
23
|
-
**Advanced** (`mode="advanced"`) is for staff
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
**Advanced** (`mode="advanced"`) is for staff, and works like a desktop slicer. Models go on the printer's real build
|
|
24
|
+
plate, where staff drag, spin, tip and lay them flat, add copies, and arrange them. Several files share a plate when there
|
|
25
|
+
is room, and there can be several plates, each with its own printer and settings and sliced into its own G-code, shown
|
|
26
|
+
layer by layer. It offers your printers first, then every printer and preset your backend lists. Slicing needs your
|
|
27
|
+
[staff routes](#staff-routes), which run on your own login. It also opens G-code and sliced 3MF files in the browser,
|
|
28
|
+
with no upload. You can [limit it to people your own servers approve](#staff-access).
|
|
27
29
|
|
|
28
30
|
|
|
29
31
|
## Slicer backend
|
|
@@ -221,8 +223,8 @@ own login protects them. Name them with [`staffApi`](#options). Without it, Adva
|
|
|
221
223
|
|---|---|
|
|
222
224
|
| [`GET /health`](#get-health) | Can it slice? |
|
|
223
225
|
| [`GET /printers`](#get-printers) | Every printer you can slice for |
|
|
224
|
-
| [`GET /options`](#staff-get-options) | What one printer offers, with presets |
|
|
225
|
-
| `POST /quotes` | As above, with [more fields](#staff-post-quotes) |
|
|
226
|
+
| [`GET /options`](#staff-get-options) | What one printer offers, with presets and its bed |
|
|
227
|
+
| `POST /quotes` | As above, with [more fields](#staff-post-quotes), and [plates](#plates) |
|
|
226
228
|
| `POST /quotes/{id}/start` | As above |
|
|
227
229
|
| `GET /quotes/{id}` | As above, with `hasGcode: true` once the G-code is ready. An optional `errorDetail` shows to staff in place of `error`, and `price` can be `null` for a material you don't price |
|
|
228
230
|
| `GET /quotes/{id}/gcode` | The G-code, or a redirect to a signed storage address |
|
|
@@ -259,11 +261,19 @@ The studio asks this with `?printer=Bambu%20Lab%20A1%200.4%20nozzle&material=PLA
|
|
|
259
261
|
"defaultProcess": "0.20mm Standard",
|
|
260
262
|
"materials": ["PLA", "PETG", "ABS", "TPU"],
|
|
261
263
|
"processes": ["0.20mm Standard", "0.16mm High Quality"],
|
|
262
|
-
"filaments": [{ "name": "Bambu PLA Basic", "material": "PLA" }]
|
|
264
|
+
"filaments": [{ "name": "Bambu PLA Basic", "material": "PLA" }],
|
|
265
|
+
"bed": {
|
|
266
|
+
"outline": [[0, 0], [256, 0], [256, 256], [0, 256]],
|
|
267
|
+
"exclude": [[[0, 0], [18, 0], [18, 28], [0, 28]]],
|
|
268
|
+
"height": 250
|
|
269
|
+
}
|
|
263
270
|
}
|
|
264
271
|
```
|
|
265
272
|
|
|
266
|
-
`filaments` lists the presets for the requested material.
|
|
273
|
+
`filaments` lists the presets for the requested material. `bed` is the printer's build plate, in its own coordinates,
|
|
274
|
+
the same as its G-code: `outline` is its printable area (any polygon, such as a circle), `exclude` the parts it keeps
|
|
275
|
+
clear, and `height` how tall it prints. Advanced draws the plate from it. Without it Advanced shows a 256 mm stand-in and
|
|
276
|
+
won't slice.
|
|
267
277
|
|
|
268
278
|
#### Staff `POST /quotes`
|
|
269
279
|
|
|
@@ -277,6 +287,26 @@ printer. It always adds the first two of these:
|
|
|
277
287
|
| `supports` | `true` or `false`, a real boolean. Left out, your own setting applies |
|
|
278
288
|
| `process`, `filament` | A preset's name, from `/options` |
|
|
279
289
|
| `rotX`, `rotY`, `rotZ` | `90`, `180` or `270`, the degrees to turn the model around each axis, in that order |
|
|
290
|
+
| `plate` | `true`: the file is a [plate](#plates). A real boolean |
|
|
291
|
+
|
|
292
|
+
#### Plates
|
|
293
|
+
|
|
294
|
+
Advanced sends each plate as one 3MF with `plate: true`, and the backend slices its objects together into one G-code,
|
|
295
|
+
each exactly where staff placed it. The 3MF holds:
|
|
296
|
+
|
|
297
|
+
- **one `<object>` per file,** named after it, with its mesh in the file's own coordinates, in millimetres;
|
|
298
|
+
- **one build `<item>` per object on the plate,** copies being more items for one object. Its `transform` (3MF's 12
|
|
299
|
+
numbers) puts the mesh where it stands, in the printer's coordinates, with its lowest point at z = 0.
|
|
300
|
+
|
|
301
|
+
The backend must:
|
|
302
|
+
|
|
303
|
+
- **keep every object where its item puts it,** without arranging or centring them;
|
|
304
|
+
- **refuse with `422`, naming the file,** an object off the bed's `outline`, in an `exclude` zone, or taller than
|
|
305
|
+
`height`;
|
|
306
|
+
- **answer like any quote,** with `stats` for the whole plate.
|
|
307
|
+
|
|
308
|
+
A plate has up to 50 objects and 1,000,000 triangles, copies included. STEP and IGES files can't be read in the browser,
|
|
309
|
+
so each has a plate of its own and is sent as it is, without `plate`, for the backend to place.
|
|
280
310
|
|
|
281
311
|
### Headless OrcaSlicer
|
|
282
312
|
|
|
@@ -449,7 +479,7 @@ Tested on Vite 8, React 18.3 and 19.3, Next.js 16, Vue 3.5, Nuxt 4, Angular 20,
|
|
|
449
479
|
No npm or build step. Load it from a CDN:
|
|
450
480
|
|
|
451
481
|
```html
|
|
452
|
-
<script type="module" src="https://cdn.jsdelivr.net/npm/slicer-studio@0.
|
|
482
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/slicer-studio@0.5.0/dist/slicer-studio.js"></script>
|
|
453
483
|
|
|
454
484
|
<slicer-studio api-url="https://api.example.com"></slicer-studio>
|
|
455
485
|
|
|
@@ -734,7 +764,7 @@ const studio = useRef<SlicerStudioElement>(null);
|
|
|
734
764
|
| Attribute | Values | Default |
|
|
735
765
|
|---|---|---|
|
|
736
766
|
| `api-url` | The address of your [public routes](#public-routes) | Your page's own origin |
|
|
737
|
-
| `mode` | `quote` (the price page) or `advanced` (the staff tools) | `quote` |
|
|
767
|
+
| `mode` | `quote` (the price page) or `advanced` (the staff tools). Only your page changes it: the studio has no switch | `quote` |
|
|
738
768
|
| `theme` | `light`, `dark` or `system`. Setting it hides the theme switch | Follows the device, and visitors can switch |
|
|
739
769
|
| `config` | JSON of the [options](#options) | Nothing overridden |
|
|
740
770
|
|
|
@@ -856,15 +886,10 @@ the copies. It doesn't fire for SLA or SLS, or in `advanced` mode. A typical `e.
|
|
|
856
886
|
`range` is your backend's `price` times the copies. Weight and time are whole numbers, or the exact figure with
|
|
857
887
|
`pricing.range` at `0`.
|
|
858
888
|
|
|
859
|
-
### `modechange`
|
|
860
|
-
|
|
861
|
-
Fires when someone uses the Simple / Advanced switch, or a refused visitor is sent back to the price page, with `{ mode }`
|
|
862
|
-
in `detail`. The switch only appears in `advanced` mode, and setting the attribute yourself doesn't fire the event.
|
|
863
|
-
|
|
864
889
|
### `advanceddenied`
|
|
865
890
|
|
|
866
|
-
Fires when your servers don't approve a visitor for Advanced
|
|
867
|
-
show your own sign-in. `e.detail.reason` is `refused`, `unreachable` or `not-set-up`, see
|
|
891
|
+
Fires when your servers don't approve a visitor for Advanced. The studio stays in Advanced and shows why, so use this to
|
|
892
|
+
show your own sign-in, or to set `mode` back yourself. `e.detail.reason` is `refused`, `unreachable` or `not-set-up`, see
|
|
868
893
|
[When the check fails](#when-the-check-fails).
|
|
869
894
|
|
|
870
895
|
### `getPrice()`
|
|
@@ -899,6 +924,11 @@ slicer-studio {
|
|
|
899
924
|
slicer-studio[mode="advanced"] { height: calc(100dvh - 64px); }
|
|
900
925
|
```
|
|
901
926
|
|
|
927
|
+
- **Advanced fits the box you give it,** whatever `display` your CSS sets on the tag. From 768px wide the panel and the
|
|
928
|
+
view sit side by side at the box's height, and the panel scrolls. Narrower, the view sits above the panel, at 58% of
|
|
929
|
+
the box, and the box scrolls. Below 360px tall it scrolls rather than squeeze.
|
|
930
|
+
- **Advanced has no header,** because it sits in your page. Open G-code and the theme switch are beside the Slice button.
|
|
931
|
+
|
|
902
932
|
- **Before it loads,** the tag has no size. To stop the page jumping, reserve some room:
|
|
903
933
|
|
|
904
934
|
```css
|
|
@@ -978,7 +1008,7 @@ Studio shows "Checking your access…" (Advanced isn't loaded yet)
|
|
|
978
1008
|
| Not valid: 403
|
|
979
1009
|
|
|
|
980
1010
|
3. Both passed: Advanced opens
|
|
981
|
-
Anything else:
|
|
1011
|
+
Anything else: the reason, with Try again
|
|
982
1012
|
```
|
|
983
1013
|
|
|
984
1014
|
| Who | Holds |
|
|
@@ -994,14 +1024,14 @@ still signed in.
|
|
|
994
1024
|
|
|
995
1025
|
### When the check fails
|
|
996
1026
|
|
|
997
|
-
|
|
998
|
-
|
|
1027
|
+
Advanced shows the reason in its place, with a Try again button, and [`advanceddenied`](#advanceddenied) fires with the
|
|
1028
|
+
reason. The studio stays in Advanced, so your page decides whether to send the visitor elsewhere.
|
|
999
1029
|
|
|
1000
|
-
| Reason | What happened |
|
|
1030
|
+
| Reason | What happened | Message |
|
|
1001
1031
|
|---|---|---|
|
|
1002
1032
|
| `refused` | A server said no, or gave a bad answer | `Advanced is for staff. Sign in and try again.` |
|
|
1003
1033
|
| `unreachable` | A server was down or blocked, or took over 8 seconds | `We couldn’t check your access. Please try again.` |
|
|
1004
|
-
| `not-set-up` | `advanced` is missing a URL | `Advanced isn’t set up on this page
|
|
1034
|
+
| `not-set-up` | `advanced` is missing a URL | `Advanced isn’t set up on this page.`, with no Try again |
|
|
1005
1035
|
|
|
1006
1036
|
### Set it up
|
|
1007
1037
|
|
|
@@ -1173,6 +1203,8 @@ from the toast library. They are harmless, because the studio's styles don't dep
|
|
|
1173
1203
|
|
|
1174
1204
|
- **Browsers:** Chrome and Edge 111+, Firefox 128+, Safari 16.4+. The 3D views need WebGL.
|
|
1175
1205
|
- **Files:** STL, 3MF, OBJ, STEP and IGES, up to 10 at once and 50 MB each. STEP and IGES are priced but have no 3D
|
|
1206
|
+
- **Plates in Advanced:** up to 10 plates, 50 objects on a plate and 1,000,000 triangles on a plate, copies included.
|
|
1207
|
+
Objects that sit off the bed show red and stop that plate from slicing; objects that overlap show amber.
|
|
1176
1208
|
preview. If your backend refuses a file, its message shows on that file's card.
|
|
1177
1209
|
- **Size:** about 215 kB gzipped to start, with the 3D view (about 250 kB) and the fonts (about 240 kB) loading after. The
|
|
1178
1210
|
websocket client (about 18 kB) loads with the first quote.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{a as t,r as n}from"./StudioContext-CsxoZNKd.js";import{n as r,r as i,t as a}from"./tip-BR1chAbl.js";import{n as o,r as s,t as c}from"./triangle-alert-5i_bibCW.js";import{a as l,i as u,n as d,o as f,r as p,t as m}from"./view-B-ChJ0zi.js";import{r as h}from"./files-BZtizmc1.js";import{Ar as g,E as _,Ga as v,L as y,Lt as b,Qi as x,U as S,j as C,qa as w,qt as T,ro as E,ta as D,tr as O}from"./three.core-BHZv2AuD.js";import{a as k,c as A,i as j,l as M,n as ee,o as te,r as ne,t as re,u as N}from"./useThemeColors-HWc0Ka_J.js";import{t as P}from"./bounds-C11tinGE.js";import{n as F,t as I}from"./model-read-F5cM3GZJ.js";var L={name:`maximize`,size:24,node:[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]};L.node;var R=i(L),z={name:`minimize`,size:24,node:[[`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`,key:`hohbtr`}],[`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`,key:`5jw1f3`}],[`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`,key:`198tvr`}],[`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`,key:`ph8mxp`}]]};z.node;var B=i(z),V={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};V.node;var H=i(V);function U(e,t,n,r){var i=class extends D{constructor(i){super({vertexShader:t,fragmentShader:n,...i});for(let t in e)this.uniforms[t]=new v(e[t]),Object.defineProperty(this,t,{get(){return this.uniforms[t].value},set(e){this.uniforms[t].value=e}});this.uniforms=w.clone(this.uniforms),r?.(this)}};return i.key=O.generateUUID(),i}var W=/* @__PURE__ */ parseInt(`186`.replace(/\D+/g,``)),G=/* @__PURE__ */ e(t()),K=/* @__PURE__ */ U({cellSize:.5,sectionSize:1,fadeDistance:100,fadeStrength:1,fadeFrom:1,cellThickness:.5,sectionThickness:1,cellColor:/* @__PURE__ */ new S,sectionColor:/* @__PURE__ */ new S,infiniteGrid:!1,followCamera:!1,worldCamProjPosition:/* @__PURE__ */ new E,worldPlanePosition:/* @__PURE__ */ new E},`
|
|
2
|
+
varying vec3 localPosition;
|
|
3
|
+
varying vec4 worldPosition;
|
|
4
|
+
|
|
5
|
+
uniform vec3 worldCamProjPosition;
|
|
6
|
+
uniform vec3 worldPlanePosition;
|
|
7
|
+
uniform float fadeDistance;
|
|
8
|
+
uniform bool infiniteGrid;
|
|
9
|
+
uniform bool followCamera;
|
|
10
|
+
|
|
11
|
+
void main() {
|
|
12
|
+
localPosition = position.xzy;
|
|
13
|
+
if (infiniteGrid) localPosition *= 1.0 + fadeDistance;
|
|
14
|
+
|
|
15
|
+
worldPosition = modelMatrix * vec4(localPosition, 1.0);
|
|
16
|
+
if (followCamera) {
|
|
17
|
+
worldPosition.xyz += (worldCamProjPosition - worldPlanePosition);
|
|
18
|
+
localPosition = (inverse(modelMatrix) * worldPosition).xyz;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
gl_Position = projectionMatrix * viewMatrix * worldPosition;
|
|
22
|
+
}
|
|
23
|
+
`,`
|
|
24
|
+
varying vec3 localPosition;
|
|
25
|
+
varying vec4 worldPosition;
|
|
26
|
+
|
|
27
|
+
uniform vec3 worldCamProjPosition;
|
|
28
|
+
uniform float cellSize;
|
|
29
|
+
uniform float sectionSize;
|
|
30
|
+
uniform vec3 cellColor;
|
|
31
|
+
uniform vec3 sectionColor;
|
|
32
|
+
uniform float fadeDistance;
|
|
33
|
+
uniform float fadeStrength;
|
|
34
|
+
uniform float fadeFrom;
|
|
35
|
+
uniform float cellThickness;
|
|
36
|
+
uniform float sectionThickness;
|
|
37
|
+
|
|
38
|
+
float getGrid(float size, float thickness) {
|
|
39
|
+
vec2 r = localPosition.xz / size;
|
|
40
|
+
vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);
|
|
41
|
+
float line = min(grid.x, grid.y) + 1.0 - thickness;
|
|
42
|
+
return 1.0 - min(line, 1.0);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void main() {
|
|
46
|
+
float g1 = getGrid(cellSize, cellThickness);
|
|
47
|
+
float g2 = getGrid(sectionSize, sectionThickness);
|
|
48
|
+
|
|
49
|
+
vec3 from = worldCamProjPosition*vec3(fadeFrom);
|
|
50
|
+
float dist = distance(from, worldPosition.xyz);
|
|
51
|
+
float d = 1.0 - min(dist / fadeDistance, 1.0);
|
|
52
|
+
vec3 color = mix(cellColor, sectionColor, min(1.0, sectionThickness * g2));
|
|
53
|
+
|
|
54
|
+
gl_FragColor = vec4(color, (g1 + g2) * pow(d, fadeStrength));
|
|
55
|
+
gl_FragColor.a = mix(0.75 * gl_FragColor.a, gl_FragColor.a, g2);
|
|
56
|
+
if (gl_FragColor.a <= 0.0) discard;
|
|
57
|
+
|
|
58
|
+
#include <tonemapping_fragment>
|
|
59
|
+
#include <${W>=154?`colorspace_fragment`:`encodings_fragment`}>
|
|
60
|
+
}
|
|
61
|
+
`),q=/* @__PURE__ */ G.forwardRef(({args:e,cellColor:t=`#000000`,sectionColor:n=`#2080ff`,cellSize:r=.5,sectionSize:i=1,followCamera:a=!1,infiniteGrid:o=!1,fadeDistance:s=100,fadeStrength:c=1,fadeFrom:l=1,cellThickness:u=.5,sectionThickness:d=1,side:f=1,...p},m)=>{A({GridMaterial:K});let h=G.useRef(null);G.useImperativeHandle(m,()=>h.current,[]);let _=new g,v=new E(0,1,0),y=new E(0,0,0);M(e=>{_.setFromNormalAndCoplanarPoint(v,y).applyMatrix4(h.current.matrixWorld);let t=h.current.material,n=t.uniforms.worldCamProjPosition,r=t.uniforms.worldPlanePosition;_.projectPoint(e.camera.position,n.value),r.value.set(0,0,0).applyMatrix4(h.current.matrixWorld)});let b={cellSize:r,sectionSize:i,cellColor:t,sectionColor:n,cellThickness:u,sectionThickness:d},x={fadeDistance:s,fadeStrength:c,fadeFrom:l,infiniteGrid:o,followCamera:a};return/*#__PURE__*/ G.createElement(`mesh`,k({ref:h,frustumCulled:!1},p),/*#__PURE__*/ G.createElement(`gridMaterial`,k({transparent:!0,"extensions-derivatives":!0,side:f},b,x)),/*#__PURE__*/ G.createElement(`planeGeometry`,{args:e}))}),J=n(),Y=16;function ie(e,t){let n=document.createElement(`canvas`),r=n.getContext(`2d`),i=`500 52px "Archivo Variable", system-ui, sans-serif`;r.font=i,n.width=Math.ceil(r.measureText(e).width)+8,n.height=64,r.font=i,r.fillStyle=t,r.textAlign=`center`,r.textBaseline=`middle`,r.fillText(e,n.width/2,n.height/2);let a=new y(n);return a.colorSpace=x,{texture:a,aspect:n.width/n.height}}function ae({text:e,at:t,color:n}){let r=N(e=>e.size.height),i=N(e=>e.camera.fov),{texture:a,aspect:o}=(0,G.useMemo)(()=>ie(e,n),[e,n]);(0,G.useEffect)(()=>()=>a.dispose(),[a]);let s=Y/r*2*Math.tan(O.degToRad(i/2));return/* @__PURE__ */ (0,J.jsx)(`sprite`,{position:t,scale:[s*o,s,1],renderOrder:3,children:/* @__PURE__ */ (0,J.jsx)(`spriteMaterial`,{map:a,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1})})}function oe({bounds:e,size:t,color:n}){let r=Math.max(6,.06*Math.max(...t)),i=(0,G.useMemo)(()=>m(e,r),[e,r]),a=(0,G.useMemo)(()=>{let e=i.flatMap(e=>[e.from,e.to,...e.ticks.flat()]).flat();return new C().setAttribute(`position`,new b(e,3))},[i]);return(0,G.useEffect)(()=>()=>a.dispose(),[a]),/* @__PURE__ */ (0,J.jsxs)(`group`,{children:[/* @__PURE__ */ (0,J.jsx)(`lineSegments`,{geometry:a,renderOrder:2,children:/* @__PURE__ */ (0,J.jsx)(`lineBasicMaterial`,{color:n,transparent:!0,depthTest:!1})}),i.map(e=>/* @__PURE__ */ (0,J.jsx)(ae,{text:e.label,at:e.at,color:n},e.axis))]})}var X=5e5;function se(e,t){let n=new T;n.rotation.set(...t.map(O.degToRad),`ZYX`),n.add(e.clone()),n.updateMatrixWorld(!0);let r=new _().setFromObject(n),i=new E(-(r.min.x+r.max.x)/2,-(r.min.y+r.max.y)/2,-r.min.z),a=new T;return a.position.copy(i),a.add(n),r.translate(i),{root:a,bounds:{min:r.min.toArray(),max:r.max.toArray()},size:r.getSize(new E).toArray()}}function Z({icon:e,tone:t=`text-muted`,children:n}){return/* @__PURE__ */ (0,J.jsx)(`div`,{className:`absolute inset-0 grid place-items-center p-6`,children:/* @__PURE__ */ (0,J.jsxs)(`div`,{className:`max-w-sm text-center`,children:[/* @__PURE__ */ (0,J.jsx)(e,{className:`mx-auto size-8 ${t}`,strokeWidth:1.6,"aria-hidden":!0}),/* @__PURE__ */ (0,J.jsx)(`div`,{className:`mt-3 text-[14px] text-muted`,children:n})]})})}function Q({label:e,pressed:t,onClick:n,children:i}){return/* @__PURE__ */ (0,J.jsx)(a,{label:e,children:/* @__PURE__ */ (0,J.jsx)(`button`,{type:`button`,"aria-label":e,"aria-pressed":t,onClick:n,className:r(`grid size-9 place-items-center rounded-xl text-ink transition-colors hover:bg-raise`,t&&`bg-raise`),children:i})})}function ce({request:e}){let t=N(e=>e.camera),n=N(e=>e.controls),r=N(e=>e.invalidate);return(0,G.useEffect)(()=>{e&&n&&(t.position.fromArray(d(t.position.toArray(),n.target.toArray(),e.factor)),n.update(),r())},[e,n,t,r]),null}function le({placed:e,tooMany:t,customer:n}){let{root:r,bounds:i,size:a}=e,o=re(),c=(0,G.useRef)(null),[d,m]=(0,G.useState)({view:`iso`,key:0}),[h,g]=(0,G.useState)(null),[_,v]=(0,G.useState)(!0),[y,b]=(0,G.useState)(!1);(0,G.useEffect)(()=>{let e=c.current.getRootNode(),t=()=>b(e.fullscreenElement===c.current);return document.addEventListener(`fullscreenchange`,t),()=>document.removeEventListener(`fullscreenchange`,t)},[]);let x=Math.max(...a,100),S=P({meta:{},bounds:i});return/* @__PURE__ */ (0,J.jsxs)(`div`,{ref:c,className:`@container absolute inset-0 bg-viewer`,children:[/* @__PURE__ */ (0,J.jsxs)(te,{flat:!0,frameloop:`demand`,dpr:[1,2],camera:{fov:35,near:.1,far:1e4,up:[0,0,1],position:[0,-300,200]},children:[/* @__PURE__ */ (0,J.jsx)(`color`,{attach:`background`,args:[o.background]}),/* @__PURE__ */ (0,J.jsx)(`hemisphereLight`,{args:[`#ffffff`,`#b0b1b6`,1.5],position:[0,0,1]}),/* @__PURE__ */ (0,J.jsx)(`directionalLight`,{position:[-150,-300,400],intensity:1.1}),/* @__PURE__ */ (0,J.jsx)(`directionalLight`,{position:[250,120,120],intensity:.35}),/* @__PURE__ */ (0,J.jsx)(q,{position:[0,0,-x*.002],rotation:[Math.PI/2,0,0],infiniteGrid:!0,fadeFrom:0,fadeDistance:x*6,fadeStrength:2,cellSize:10,cellThickness:.6,cellColor:o.rule,sectionSize:50,sectionThickness:.9,sectionColor:o.grid,side:2}),/* @__PURE__ */ (0,J.jsx)(ne,{outline:S,colors:o}),/* @__PURE__ */ (0,J.jsx)(`primitive`,{object:r}),_&&/* @__PURE__ */ (0,J.jsx)(oe,{bounds:i,size:a,color:o.muted}),/* @__PURE__ */ (0,J.jsx)(j,{makeDefault:!0,enableDamping:!0,dampingFactor:.12,screenSpacePanning:!0}),/* @__PURE__ */ (0,J.jsx)(ee,{bounds:i,far:20*x,view:d.view,fitKey:d.key}),/* @__PURE__ */ (0,J.jsx)(ce,{request:h}),/* @__PURE__ */ (0,J.jsx)(p,{})]}),/* @__PURE__ */ (0,J.jsx)(`div`,{className:`pointer-events-none absolute inset-x-3 top-3 z-10 flex flex-wrap items-start justify-between gap-2 [&>*]:pointer-events-auto`,children:/* @__PURE__ */ (0,J.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5 rounded-2xl bg-panel/90 p-1 backdrop-blur`,children:[/* @__PURE__ */ (0,J.jsx)(Q,{label:`Centre the model`,onClick:()=>m(e=>({view:`current`,key:e.key+1})),children:/* @__PURE__ */ (0,J.jsx)(f,{className:`size-[18px]`,"aria-hidden":!0})}),/* @__PURE__ */ (0,J.jsx)(Q,{label:`Zoom in`,onClick:()=>g({factor:.8}),children:/* @__PURE__ */ (0,J.jsx)(l,{className:`size-[18px]`,"aria-hidden":!0})}),/* @__PURE__ */ (0,J.jsx)(Q,{label:`Zoom out`,onClick:()=>g({factor:1.25}),children:/* @__PURE__ */ (0,J.jsx)(u,{className:`size-[18px]`,"aria-hidden":!0})}),/* @__PURE__ */ (0,J.jsx)(Q,{label:`Reset view`,onClick:()=>m(e=>({view:`iso`,key:e.key+1})),children:/* @__PURE__ */ (0,J.jsx)(H,{className:`size-[18px]`,"aria-hidden":!0})}),/* @__PURE__ */ (0,J.jsx)(`span`,{className:`mx-0.5 h-6 w-px bg-rule`,"aria-hidden":!0}),/* @__PURE__ */ (0,J.jsx)(Q,{label:_?`Hide size lines`:`Show size lines`,pressed:_,onClick:()=>v(e=>!e),children:/* @__PURE__ */ (0,J.jsx)(s,{className:`size-[18px]`,"aria-hidden":!0})}),document.fullscreenEnabled&&/* @__PURE__ */ (0,J.jsxs)(J.Fragment,{children:[/* @__PURE__ */ (0,J.jsx)(`span`,{className:`mx-0.5 h-6 w-px bg-rule`,"aria-hidden":!0}),/* @__PURE__ */ (0,J.jsx)(Q,{label:y?`Leave fullscreen`:`Fullscreen`,onClick:()=>(y?document.exitFullscreen():c.current.requestFullscreen()).catch(()=>{}),children:y?/* @__PURE__ */ (0,J.jsx)(B,{className:`size-[18px]`,"aria-hidden":!0}):/* @__PURE__ */ (0,J.jsx)(R,{className:`size-[18px]`,"aria-hidden":!0})})]})]})})]})}function $({file:e,rot:t=[0,0,0],customer:n=!1}){let r=n?`The price still works`:`Slicing still works`,i=h(e.name).format,[a,l]=(0,G.useState)({status:`loading`});(0,G.useEffect)(()=>{if(i===`step`||i===`iges`)return;let t=!0,n=null;l({status:`loading`});let r=setTimeout(()=>{F(e,i).then(e=>{n=e,t&&l({status:`ready`,object:e,triangles:I(e)})}).catch(e=>{t&&l(e.xml?{status:`large`,xml:e.xml}:{status:`error`})})},30);return()=>{t=!1,clearTimeout(r),n?.traverse(e=>e.geometry?.dispose())}},[e,i]);let[u,d,f]=t,p=(0,G.useMemo)(()=>a.object?se(a.object,[u,d,f]):null,[a.object,u,d,f]);return a.status===`ready`&&i!==`step`&&i!==`iges`?/* @__PURE__ */ (0,J.jsx)(le,{placed:p,tooMany:a.triangles>X,customer:n}):i===`step`||i===`iges`?/* @__PURE__ */ (0,J.jsx)(Z,{icon:s,children:n?`${i.toUpperCase()} files can’t be previewed here. The price still works.`:`A ${i.toUpperCase()} file becomes a mesh on the server, so its preview shows once it is sliced.`}):a.status===`loading`?/* @__PURE__ */ (0,J.jsxs)(Z,{icon:o,tone:`text-muted animate-spin`,children:[`Loading preview of `,e.name]}):a.status===`large`?/* @__PURE__ */ (0,J.jsxs)(Z,{icon:s,children:[e.name,` holds `,Math.round(a.xml/1e6),` MB of mesh data, roughly `,(Math.round(a.xml/85/1e4)*1e4).toLocaleString(`en`),` triangles, too much to preview here. `,r,` up to `,X.toLocaleString(`en`),` triangles.`]}):/* @__PURE__ */ (0,J.jsxs)(Z,{icon:c,tone:`text-warn`,children:[`No preview for `,e.name,`. `,n?`It may still be priced`:`It can still be sliced`,`; the server says so if it can’t read it.`]})}export{$ as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{a as t,r as n}from"./StudioContext-CsxoZNKd.js";import{n as r,r as i,t as a}from"./tip-BR1chAbl.js";import{a as o,i as s,n as c,o as l,r as u}from"./view-B-ChJ0zi.js";import{n as d}from"./plate-geometry-Dd9vKDEP.js";import{Ar as f,Lt as p,ia as m,ir as h,j as g,no as _,ra as v,ro as y}from"./three.core-BHZv2AuD.js";import{i as b,n as x,o as S,r as C,t as w,u as T}from"./useThemeColors-HWc0Ka_J.js";import{drawable as E}from"./plate-mesh-BoEG27Tx.js";var D={name:`footprints`,size:24,node:[[`path`,{d:`M4 16v-2.38C4 11.5 2.97 10.5 3 8c.03-2.72 1.49-6 4.5-6C9.37 2 10 3.8 10 5.5c0 3.11-2 5.66-2 8.68V16a2 2 0 1 1-4 0Z`,key:`1dudjm`}],[`path`,{d:`M20 20v-2.38c0-2.12 1.03-3.12 1-5.62-.03-2.72-1.49-6-4.5-6C14.63 6 14 7.8 14 9.5c0 3.11 2 5.66 2 8.68V20a2 2 0 1 0 4 0Z`,key:`l2t8xc`}],[`path`,{d:`M16 17h4`,key:`1dejxt`}],[`path`,{d:`M4 13h4`,key:`1bwh8b`}]]};D.node;var O=i(D),k={name:`scan-search`,size:24,node:[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`path`,{d:`m16 16-1.9-1.9`,key:`1dq9hf`}]]};k.node;var A=i(k),j=/* @__PURE__ */ e(t());function M(e,t=`pointer`,n=`auto`,r=document.body){j.useEffect(()=>{if(e)return r.style.cursor=t,()=>void(r.style.cursor=n)},[e])}var N=n(),P=new f(new y(0,0,1),0),F={clay:`#cbccd0`,selected:`#8fb4ff`,problem:`#ef6461`,overlap:`#f2b347`};function I(e){let t=(0,j.useRef)(/* @__PURE__ */ new Map),n={};for(let[r,i]of Object.entries(e))t.current.has(r)||t.current.set(r,{mesh:i,...E(i)}),n[r]=t.current.get(r);return(0,j.useEffect)(()=>{for(let[n,r]of t.current)e[n]||(r.geometry.dispose(),t.current.delete(n))},[e]),(0,j.useEffect)(()=>()=>{for(let e of t.current.values())e.geometry.dispose()},[]),n}function L({exclude:e}){let t=(0,j.useMemo)(()=>e.map(e=>({fill:new m(new v(e.map(([e,t])=>new _(e,t)))),edge:new g().setAttribute(`position`,new p(e.flatMap(([e,t])=>[e,t,.02]),3))})),[e]);return(0,j.useEffect)(()=>()=>t.forEach(e=>{e.fill.dispose(),e.edge.dispose()}),[t]),t.map((e,t)=>/* @__PURE__ */ (0,N.jsxs)(`group`,{children:[/* @__PURE__ */ (0,N.jsx)(`mesh`,{geometry:e.fill,"position-z":.01,children:/* @__PURE__ */ (0,N.jsx)(`meshBasicMaterial`,{color:F.problem,transparent:!0,opacity:.22,side:2,depthWrite:!1})}),/* @__PURE__ */ (0,N.jsx)(`lineLoop`,{geometry:e.edge,children:/* @__PURE__ */ (0,N.jsx)(`lineBasicMaterial`,{color:F.problem})})]},t))}function R({box:e,height:t,color:n}){let r=(0,j.useMemo)(()=>{let[n,r,i,a]=e,o=t,s=[[n,r],[i,r],[i,a],[n,a]],c=s.flatMap(([e,t],n)=>{let[r,i]=s[(n+1)%4];return[e,t,o,r,i,o,e,t,0,e,t,o]});return new g().setAttribute(`position`,new p(c,3))},[e,t]);return(0,j.useEffect)(()=>()=>r.dispose(),[r]),/* @__PURE__ */ (0,N.jsx)(`lineSegments`,{geometry:r,children:/* @__PURE__ */ (0,N.jsx)(`lineBasicMaterial`,{color:n,transparent:!0,opacity:.45})})}function z({item:e,shape:t,selected:n,layMode:r,offset:i,onSelect:a,onDrag:o,onDrop:s,onLay:c}){let l=T(e=>e.controls),u=T(e=>e.gl),f=(0,j.useRef)(null),[p,m]=(0,j.useState)(!1);M(p,r?`crosshair`:`grab`,`auto`,u.domElement);let g=(0,j.useMemo)(()=>{let[t,n,r,a,o,s,c,l,u]=e.A,[d,f]=i||[0,0];return new h().set(t,n,r,e.t[0]+d,a,o,s,e.t[1]+f,c,l,u,e.t[2],0,0,0,1)},[e.A,e.t,i]),_=e=>e.ray.intersectPlane(P,new y),v=t=>{if(t.stopPropagation(),r){t.face&&c(e.id,d(e.A,[t.face.normal.x,t.face.normal.y,t.face.normal.z]));return}a(e.id);let n=_(t);n&&(t.target.setPointerCapture(t.pointerId),l&&(l.enabled=!1),f.current={from:n,moved:!1})},b=t=>{if(!f.current)return;let n=_(t);if(!n)return;let r=n.x-f.current.from.x,i=n.y-f.current.from.y;!f.current.moved&&Math.hypot(r,i)<.5||(f.current.moved=!0,f.current.delta=[r,i],o(e.id,r,i))},x=t=>{f.current&&=(t.target.releasePointerCapture(t.pointerId),l&&(l.enabled=!0),f.current.moved&&s(e.id,...f.current.delta),null)},S=e.problem?F.problem:e.overlap?F.overlap:n?F.selected:F.clay;return/* @__PURE__ */ (0,N.jsx)(`mesh`,{geometry:t.geometry,matrixAutoUpdate:!1,matrix:g,onPointerDown:v,onPointerMove:b,onPointerUp:x,onPointerCancel:x,onPointerOver:e=>{e.stopPropagation(),m(!0)},onPointerOut:()=>m(!1),children:/* @__PURE__ */ (0,N.jsx)(`meshStandardMaterial`,{color:S,roughness:.72,flatShading:t.flat,emissive:n?`#1d4ed8`:`#000000`,emissiveIntensity:n?.18:0})})}function B({request:e}){let t=T(e=>e.camera),n=T(e=>e.controls),r=T(e=>e.invalidate);return(0,j.useEffect)(()=>{e&&n&&(t.position.fromArray(c(t.position.toArray(),n.target.toArray(),e.factor)),n.update(),r())},[e,n,t,r]),null}function V({label:e,pressed:t,disabled:n,onClick:i,children:o}){return/* @__PURE__ */ (0,N.jsx)(a,{label:e,children:/* @__PURE__ */ (0,N.jsx)(`button`,{type:`button`,"aria-label":e,"aria-pressed":t,disabled:n,onClick:i,className:r(`grid size-9 place-items-center rounded-xl text-ink transition-colors hover:bg-raise disabled:opacity-40`,t&&`bg-ink text-ink-contrast hover:bg-ink`),children:o})})}function H({bed:e,scene:t,meshes:n,selected:r,layMode:i,onSelect:a,onMove:c,onLay:d,onLayMode:f}){let p=w(),m=I(n),[h,g]=(0,j.useState)(null),[_,v]=(0,j.useState)({view:`iso`,key:0}),[y,T]=(0,j.useState)(null),[E,D,k,M]=e.box,P=Math.max(k-E,M-D,e.height),H=(0,j.useMemo)(()=>({min:[E,D,0],max:[k,M,Math.min(e.height,P/4)]}),[E,D,k,M,e.height,P]),U=t.filter(e=>e.problem).length,W=t.filter(e=>e.overlap).length;return/* @__PURE__ */ (0,N.jsxs)(`div`,{className:`absolute inset-0 bg-viewer`,children:[/* @__PURE__ */ (0,N.jsxs)(S,{flat:!0,frameloop:`demand`,dpr:[1,2],camera:{fov:35,near:.1,far:1e4,up:[0,0,1],position:[0,-400,300]},onPointerMissed:()=>{i||a(null)},children:[/* @__PURE__ */ (0,N.jsx)(`color`,{attach:`background`,args:[p.background]}),/* @__PURE__ */ (0,N.jsx)(`hemisphereLight`,{args:[`#ffffff`,`#b0b1b6`,1.5],position:[0,0,1]}),/* @__PURE__ */ (0,N.jsx)(`directionalLight`,{position:[-150,-300,400],intensity:1.1}),/* @__PURE__ */ (0,N.jsx)(`directionalLight`,{position:[250,120,120],intensity:.35}),/* @__PURE__ */ (0,N.jsx)(C,{outline:e.outline,colors:p}),/* @__PURE__ */ (0,N.jsx)(L,{exclude:e.exclude}),!e.standIn&&/* @__PURE__ */ (0,N.jsx)(R,{box:e.box,height:e.height,color:p.bedEdge}),t.filter(e=>e.loaded&&m[e.fileId]).map(e=>/* @__PURE__ */ (0,N.jsx)(z,{item:e,shape:m[e.fileId],selected:e.id===r,layMode:i,offset:h&&h.id===e.id?[h.dx,h.dy]:null,onSelect:a,onLay:d,onDrag:(e,t,n)=>g({id:e,dx:t,dy:n}),onDrop:(e,t,n)=>{g(null),c(e,t,n)}},e.id)),/* @__PURE__ */ (0,N.jsx)(b,{makeDefault:!0,enableDamping:!0,dampingFactor:.12,screenSpacePanning:!0}),/* @__PURE__ */ (0,N.jsx)(x,{bounds:H,far:20*P,view:_.view,fitKey:_.key}),/* @__PURE__ */ (0,N.jsx)(B,{request:y}),/* @__PURE__ */ (0,N.jsx)(u,{})]}),/* @__PURE__ */ (0,N.jsx)(`div`,{className:`pointer-events-none absolute inset-x-3 top-3 z-10 flex justify-end [&>*]:pointer-events-auto`,children:/* @__PURE__ */ (0,N.jsxs)(`div`,{className:`flex items-center gap-0.5 rounded-2xl bg-panel/90 p-1 backdrop-blur`,children:[/* @__PURE__ */ (0,N.jsx)(V,{label:`Lay on face: click a face to stand the object on it`,pressed:i,disabled:!r,onClick:()=>f(!i),children:/* @__PURE__ */ (0,N.jsx)(O,{className:`size-[18px]`,"aria-hidden":!0})}),/* @__PURE__ */ (0,N.jsx)(`span`,{className:`mx-0.5 h-6 w-px bg-rule`,"aria-hidden":!0}),/* @__PURE__ */ (0,N.jsx)(V,{label:`Whole plate`,onClick:()=>v(e=>({view:`iso`,key:e.key+1})),children:/* @__PURE__ */ (0,N.jsx)(A,{className:`size-[18px]`,"aria-hidden":!0})}),/* @__PURE__ */ (0,N.jsx)(V,{label:`From above`,onClick:()=>v(e=>({view:`top`,key:e.key+1})),children:/* @__PURE__ */ (0,N.jsx)(l,{className:`size-[18px]`,"aria-hidden":!0})}),/* @__PURE__ */ (0,N.jsx)(V,{label:`Zoom in`,onClick:()=>T({factor:.8}),children:/* @__PURE__ */ (0,N.jsx)(o,{className:`size-[18px]`,"aria-hidden":!0})}),/* @__PURE__ */ (0,N.jsx)(V,{label:`Zoom out`,onClick:()=>T({factor:1.25}),children:/* @__PURE__ */ (0,N.jsx)(s,{className:`size-[18px]`,"aria-hidden":!0})})]})}),/* @__PURE__ */ (0,N.jsxs)(`div`,{className:`pointer-events-none absolute bottom-3 left-14 z-10 flex flex-wrap gap-1.5 text-[12px]`,children:[i&&/* @__PURE__ */ (0,N.jsx)(`span`,{className:`rounded-full bg-ink px-2.5 py-1 text-ink-contrast`,children:`Click the face to put down`}),e.standIn&&/* @__PURE__ */ (0,N.jsx)(`span`,{className:`rounded-full bg-panel/90 px-2.5 py-1 text-muted backdrop-blur`,children:`Bed size not known yet: a 256 mm stand-in`}),U>0&&/* @__PURE__ */ (0,N.jsxs)(`span`,{className:`rounded-full px-2.5 py-1 text-white`,style:{background:F.problem},children:[U===1?`An object`:`${U} objects`,` can’t be printed there`]}),W>0&&/* @__PURE__ */ (0,N.jsx)(`span`,{className:`rounded-full px-2.5 py-1 text-ink`,style:{background:F.overlap},children:`Objects overlap`})]})]})}export{H as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{a as t,r as n}from"./StudioContext-CsxoZNKd.js";import{n as r}from"./features-6cCl0G7E.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{a as t,r as n}from"./StudioContext-CsxoZNKd.js";import{n as r}from"./features-6cCl0G7E.js";import{A as i,O as a,U as o,an as s,in as c,j as l,ta as u}from"./three.core-BHZv2AuD.js";import{i as d,n as f,o as p,r as m,t as h,u as g}from"./useThemeColors-HWc0Ka_J.js";import{n as _,t as v}from"./bounds-C11tinGE.js";var y=/* @__PURE__ */ e(t(),1),b=`
|
|
2
2
|
attribute vec3 iStart;
|
|
3
3
|
attribute vec3 iEnd;
|
|
4
4
|
attribute float iWidth;
|
|
@@ -57,4 +57,4 @@ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{a as t,r as n}from"./S
|
|
|
57
57
|
gl_FragColor = vec4(uColor, 1.0);
|
|
58
58
|
#include <colorspace_fragment>
|
|
59
59
|
}
|
|
60
|
-
`,w=n();function T({segments:e,features:t,layerMin:n,layerMax:
|
|
60
|
+
`,w=n();function T({segments:e,features:t,layerMin:n,layerMax:i,hidden:l}){let d=g(e=>e.invalidate),f=(0,y.useMemo)(()=>{let t=new a(1,1,1).translate(.5,0,0),n=new s().copy(t);return t.dispose(),n.instanceCount=e.count,n.setAttribute(`iStart`,new c(e.start,3)),n.setAttribute(`iEnd`,new c(e.end,3)),n.setAttribute(`iWidth`,new c(e.width,1)),n.setAttribute(`iHeight`,new c(e.height,1)),n.setAttribute(`iFeature`,new c(Float32Array.from(e.feature),1)),n.setAttribute(`iLayer`,new c(e.layer,1)),n},[e]);(0,y.useEffect)(()=>()=>f.dispose(),[f]);let p=(0,y.useMemo)(()=>new u({vertexShader:b,fragmentShader:x,uniforms:{uLayerMin:{value:0},uLayerMax:{value:1e9},uVisible:{value:(/* @__PURE__ */ new Float32Array(32)).fill(1)},uColors:{value:Array.from({length:32},()=>new o(10066329))}}}),[]);return(0,y.useEffect)(()=>()=>p.dispose(),[p]),(0,y.useLayoutEffect)(()=>{t.forEach((e,t)=>{t<32&&p.uniforms.uColors.value[t].set(r(e.name))}),d()},[t,p,d]),(0,y.useLayoutEffect)(()=>{let e=p.uniforms;e.uLayerMin.value=n,e.uLayerMax.value=i;for(let t=0;t<32;t++)e.uVisible.value[t]=+!l.has(t);d()},[n,i,l,p,d]),/* @__PURE__ */ (0,w.jsx)(`mesh`,{geometry:f,material:p,frustumCulled:!1})}function E({travels:e,layerMin:t,layerMax:n,color:r,visible:a}){let s=g(e=>e.invalidate),c=(0,y.useMemo)(()=>{let t=new Float32Array(e.count*2);for(let n=0;n<e.count;n++)t[2*n]=t[2*n+1]=e.layer[n];let n=new l;return n.setAttribute(`position`,new i(e.pos,3)),n.setAttribute(`aLayer`,new i(t,1)),n},[e]);(0,y.useEffect)(()=>()=>c.dispose(),[c]);let d=(0,y.useMemo)(()=>new u({vertexShader:S,fragmentShader:C,uniforms:{uLayerMin:{value:0},uLayerMax:{value:1e9},uColor:{value:new o}}}),[]);return(0,y.useEffect)(()=>()=>d.dispose(),[d]),(0,y.useLayoutEffect)(()=>{d.uniforms.uLayerMin.value=t,d.uniforms.uLayerMax.value=n,d.uniforms.uColor.value.set(r),s()},[t,n,r,d,s]),/* @__PURE__ */ (0,w.jsx)(`lineSegments`,{geometry:c,material:d,visible:a,frustumCulled:!1})}function D({result:e,layerMin:t,layerMax:n,hidden:r,showTravels:i,view:a,fitKey:o}){let s=h(),c=(0,y.useMemo)(()=>v(e),[e]),l=(0,y.useMemo)(()=>_(e),[e]),u=(0,y.useMemo)(()=>{let e=c.map(e=>e[0]),t=c.map(e=>e[1]);return 20*Math.max(Math.max(...e)-Math.min(...e),Math.max(...t)-Math.min(...t),100)},[c]);return/* @__PURE__ */ (0,w.jsxs)(p,{flat:!0,frameloop:`demand`,dpr:[1,2],camera:{fov:35,near:.1,far:1e4,up:[0,0,1],position:[0,-300,200]},children:[/* @__PURE__ */ (0,w.jsx)(`color`,{attach:`background`,args:[s.background]}),/* @__PURE__ */ (0,w.jsx)(m,{outline:c,colors:s}),/* @__PURE__ */ (0,w.jsx)(T,{segments:e.segments,features:e.features,layerMin:t,layerMax:n,hidden:r}),/* @__PURE__ */ (0,w.jsx)(E,{travels:e.travels,layerMin:t,layerMax:n,color:s.travel,visible:i}),/* @__PURE__ */ (0,w.jsx)(d,{makeDefault:!0,enableDamping:!0,dampingFactor:.12,screenSpacePanning:!0}),/* @__PURE__ */ (0,w.jsx)(f,{bounds:l,far:u,view:a,fitKey:o})]})}export{D as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e({segments:e,features:t,bounds:n}){let r=t.findIndex(e=>e.name===`Custom`),i=[1/0,1/0,1/0],a=[-1/0,-1/0,-1/0],o=!1;for(let t=0;t<e.count;t++)if(e.feature[t]!==r){o=!0;for(let n of[e.start,e.end])for(let e=0;e<3;e++){let r=n[t*3+e];r<i[e]&&(i[e]=r),r>a[e]&&(a[e]=r)}}return o?{min:i,max:a}:n}function t({meta:e,bounds:t}){if(e.bed)return e.bed;let n=t||{min:[0,0,0],max:[200,200,0]};return[[n.min[0]-20,n.min[1]-20],[n.max[0]+20,n.min[1]-20],[n.max[0]+20,n.max[1]+20],[n.min[0]-20,n.max[1]+20]]}export{e as n,t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Uint8Array,t=Uint16Array,n=Int32Array,r=new e([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),i=new e([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),a=new e([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),o=function(e,r){for(var i=new t(31),a=0;a<31;++a)i[a]=r+=1<<e[a-1];for(var o=new n(i[30]),a=1;a<30;++a)for(var s=i[a];s<i[a+1];++s)o[s]=s-i[a]<<5|a;return{b:i,r:o}},s=o(r,2),c=s.b,l=s.r;c[28]=258,l[258]=28;for(var u=o(i,0),d=u.b,f=u.r,p=new t(32768),m=0;m<32768;++m){var h=(m&43690)>>1|(m&21845)<<1;h=(h&52428)>>2|(h&13107)<<2,h=(h&61680)>>4|(h&3855)<<4,p[m]=((h&65280)>>8|(h&255)<<8)>>1}for(var g=(function(e,n,r){for(var i=e.length,a=0,o=new t(n);a<i;++a)e[a]&&++o[e[a]-1];var s=new t(n);for(a=1;a<n;++a)s[a]=s[a-1]+o[a-1]<<1;var c;if(r){c=new t(1<<n);var l=15-n;for(a=0;a<i;++a)if(e[a])for(var u=a<<4|e[a],d=n-e[a],f=s[e[a]-1]++<<d,m=f|(1<<d)-1;f<=m;++f)c[p[f]>>l]=u}else for(c=new t(i),a=0;a<i;++a)e[a]&&(c[a]=p[s[e[a]-1]++]>>15-e[a]);return c}),_=new e(288),m=0;m<144;++m)_[m]=8;for(var m=144;m<256;++m)_[m]=9;for(var m=256;m<280;++m)_[m]=7;for(var m=280;m<288;++m)_[m]=8;for(var v=new e(32),m=0;m<32;++m)v[m]=5;var y=/*#__PURE__*/ g(_,9,0),b=/*#__PURE__*/ g(_,9,1),x=/*#__PURE__*/ g(v,5,0),S=/*#__PURE__*/ g(v,5,1),C=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},w=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},T=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},ee=function(e){return(e+7)/8|0},E=function(t,n,r){return(n==null||n<0)&&(n=0),(r==null||r>t.length)&&(r=t.length),new e(t.subarray(n,r))},D=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],O=function(e,t,n){var r=Error(t||D[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,O),!n)throw r;return r},k=function(t,n,o,s){var l=t.length,u=s?s.length:0;if(!l||n.f&&!n.l)return o||new e(0);var f=!o,p=f||n.i!=2,m=n.i;f&&(o=new e(l*3));var h=function(t){var n=o.length;if(t>n){var r=new e(Math.max(n*2,t));r.set(o),o=r}},_=n.f||0,v=n.p||0,y=n.b||0,x=n.l,D=n.d,k=n.m,A=n.n,j=l*8;do{if(!x){_=w(t,v,1);var M=w(t,v+1,3);if(v+=3,!M){var N=ee(v)+4,P=t[N-4]|t[N-3]<<8,F=N+P;if(F>l){m&&O(0);break}p&&h(y+P),o.set(t.subarray(N,F),y),n.b=y+=P,n.p=v=F*8,n.f=_;continue}if(M==1)x=b,D=S,k=9,A=5;else if(M==2){var te=w(t,v,31)+257,I=w(t,v+10,15)+4,L=te+w(t,v+5,31)+1;v+=14;for(var R=new e(L),z=new e(19),B=0;B<I;++B)z[a[B]]=w(t,v+B*3,7);v+=I*3;for(var V=C(z),H=(1<<V)-1,U=g(z,V,1),B=0;B<L;){var W=U[w(t,v,H)];v+=W&15;var N=W>>4;if(N<16)R[B++]=N;else{var G=0,K=0;for(N==16?(K=3+w(t,v,3),v+=2,G=R[B-1]):N==17?(K=3+w(t,v,7),v+=3):N==18&&(K=11+w(t,v,127),v+=7);K--;)R[B++]=G}}var q=R.subarray(0,te),J=R.subarray(te);k=C(q),A=C(J),x=g(q,k,1),D=g(J,A,1)}else O(1);if(v>j){m&&O(0);break}}p&&h(y+131072);for(var ne=(1<<k)-1,re=(1<<A)-1,Y=v;;Y=v){var G=x[T(t,v)&ne],X=G>>4;if(v+=G&15,v>j){m&&O(0);break}if(G||O(2),X<256)o[y++]=X;else if(X==256){Y=v,x=null;break}else{var Z=X-254;if(X>264){var B=X-257,Q=r[B];Z=w(t,v,(1<<Q)-1)+c[B],v+=Q}var $=D[T(t,v)&re],ie=$>>4;$||O(3),v+=$&15;var J=d[ie];if(ie>3){var Q=i[ie];J+=T(t,v)&(1<<Q)-1,v+=Q}if(v>j){m&&O(0);break}p&&h(y+131072);var ae=y+Z;if(y<J){var oe=u-J,se=Math.min(J,ae);for(oe+y<0&&O(3);y<se;++y)o[y]=s[oe+y]}for(;y<ae;++y)o[y]=o[y-J]}}n.l=x,n.p=Y,n.b=y,n.f=_,x&&(_=1,n.m=k,n.d=D,n.n=A)}while(!_);return y!=o.length&&f?E(o,0,y):o.subarray(0,y)},A=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},j=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},M=function(n,r){for(var i=[],a=0;a<n.length;++a)n[a]&&i.push({s:a,f:n[a]});var o=i.length,s=i.slice();if(!o)return{t:R,l:0};if(o==1){var c=new e(i[0].s+1);return c[i[0].s]=1,{t:c,l:1}}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var l=i[0],u=i[1],d=0,f=1,p=2;for(i[0]={s:-1,f:l.f+u.f,l,r:u};f!=o-1;)l=i[i[d].f<i[p].f?d++:p++],u=i[d!=f&&i[d].f<i[p].f?d++:p++],i[f++]={s:-1,f:l.f+u.f,l,r:u};for(var m=s[0].s,a=1;a<o;++a)s[a].s>m&&(m=s[a].s);var h=new t(m+1),g=N(i[f-1],h,0);if(g>r){var a=0,_=0,v=g-r,y=1<<v;for(s.sort(function(e,t){return h[t.s]-h[e.s]||e.f-t.f});a<o;++a){var b=s[a].s;if(h[b]>r)_+=y-(1<<g-h[b]),h[b]=r;else break}for(_>>=v;_>0;){var x=s[a].s;h[x]<r?_-=1<<r-h[x]++-1:++a}for(;a>=0&&_;--a){var S=s[a].s;h[S]==r&&(--h[S],++_)}g=r}return{t:new e(h),l:g}},N=function(e,t,n){return e.s==-1?Math.max(N(e.l,t,n+1),N(e.r,t,n+1)):t[e.s]=n},P=function(e){for(var n=e.length;n&&!e[--n];);for(var r=new t(++n),i=0,a=e[0],o=1,s=function(e){r[i++]=e},c=1;c<=n;++c)if(e[c]==a&&c!=n)++o;else{if(!a&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(a),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(a);o=1,a=e[c]}return{c:r.subarray(0,i),n}},F=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},te=function(e,t,n){var r=n.length,i=ee(t+2);e[i]=r&255,e[i+1]=r>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var a=0;a<r;++a)e[i+a+4]=n[a];return(i+4+r)*8},I=function(e,n,o,s,c,l,u,d,f,p,m){A(n,m++,o),++c[256];for(var h=M(c,15),b=h.t,S=h.l,C=M(l,15),w=C.t,T=C.l,ee=P(b),E=ee.c,D=ee.n,O=P(w),k=O.c,N=O.n,I=new t(19),L=0;L<E.length;++L)++I[E[L]&31];for(var L=0;L<k.length;++L)++I[k[L]&31];for(var R=M(I,7),z=R.t,B=R.l,V=19;V>4&&!z[a[V-1]];--V);var H=p+5<<3,U=F(c,_)+F(l,v)+u,W=F(c,b)+F(l,w)+u+14+3*V+F(I,z)+2*I[16]+3*I[17]+7*I[18];if(f>=0&&H<=U&&H<=W)return te(n,m,e.subarray(f,f+p));var G,K,q,J;if(A(n,m,1+(W<U)),m+=2,W<U){G=g(b,S,0),K=b,q=g(w,T,0),J=w;var ne=g(z,B,0);A(n,m,D-257),A(n,m+5,N-1),A(n,m+10,V-4),m+=14;for(var L=0;L<V;++L)A(n,m+3*L,z[a[L]]);m+=3*V;for(var re=[E,k],Y=0;Y<2;++Y)for(var X=re[Y],L=0;L<X.length;++L){var Z=X[L]&31;A(n,m,ne[Z]),m+=z[Z],Z>15&&(A(n,m,X[L]>>5&127),m+=X[L]>>12)}}else G=y,K=_,q=x,J=v;for(var L=0;L<d;++L){var Q=s[L];if(Q>255){var Z=Q>>18&31;j(n,m,G[Z+257]),m+=K[Z+257],Z>7&&(A(n,m,Q>>23&31),m+=r[Z]);var $=Q&31;j(n,m,q[$]),m+=J[$],$>3&&(j(n,m,Q>>5&8191),m+=i[$])}else j(n,m,G[Q]),m+=K[Q]}return j(n,m,G[256]),m+K[256]},L=/*#__PURE__*/ new n([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),R=/*#__PURE__*/ new e(0),z=function(a,o,s,c,u,d){var p=d.z||a.length,m=new e(c+p+5*(1+Math.ceil(p/7e3))+u),h=m.subarray(c,m.length-u),g=d.l,_=(d.r||0)&7;if(o){_&&(h[0]=d.r>>3);for(var v=L[o-1],y=v>>13,b=v&8191,x=(1<<s)-1,S=d.p||new t(32768),C=d.h||new t(x+1),w=Math.ceil(s/3),T=2*w,D=function(e){return(a[e]^a[e+1]<<w^a[e+2]<<T)&x},O=new n(25e3),k=new t(288),A=new t(32),j=0,M=0,N=d.i||0,P=0,F=d.w||0,R=0;N+2<p;++N){var z=D(N),B=N&32767,V=C[z];if(S[B]=V,C[z]=B,F<=N){var H=p-N;if((j>7e3||P>24576)&&(H>423||!g)){_=I(a,h,0,O,k,A,M,P,R,N-R,_),P=j=M=0,R=N;for(var U=0;U<286;++U)k[U]=0;for(var U=0;U<30;++U)A[U]=0}var W=2,G=0,K=b,q=B-V&32767;if(H>2&&z==D(N-q))for(var J=Math.min(y,H)-1,ne=Math.min(32767,N),re=Math.min(258,H);q<=ne&&--K&&B!=V;){if(a[N+W]==a[N+W-q]){for(var Y=0;Y<re&&a[N+Y]==a[N+Y-q];++Y);if(Y>W){if(W=Y,G=q,Y>J)break;for(var X=Math.min(q,Y-2),Z=0,U=0;U<X;++U){var Q=N-q+U&32767,$=Q-S[Q]&32767;$>Z&&(Z=$,V=Q)}}}B=V,V=S[B],q+=B-V&32767}if(G){O[P++]=268435456|l[W]<<18|f[G];var ie=l[W]&31,ae=f[G]&31;M+=r[ie]+i[ae],++k[257+ie],++A[ae],F=N+W,++j}else O[P++]=a[N],++k[a[N]]}}for(N=Math.max(N,F);N<p;++N)O[P++]=a[N],++k[a[N]];_=I(a,h,g,O,k,A,M,P,R,N-R,_),g||(d.r=_&7|h[_/8|0]<<3,_-=7,d.h=C,d.p=S,d.i=N,d.w=F)}else{for(var N=d.w||0;N<p+g;N+=65535){var oe=N+65535;oe>=p&&(h[_/8|0]=g,oe=p),_=te(h,_+1,a.subarray(N,oe))}d.i=p}return E(m,0,c+ee(_)+u)},B=/*#__PURE__*/ (function(){for(var e=/* @__PURE__ */ new Int32Array(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e})(),V=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=B[n&255^t[r]]^n>>>8;e=n},d:function(){return~e}}},H=function(t,n,r,i,a){if(!a&&(a={l:1},n.dictionary)){var o=n.dictionary.subarray(-32768),s=new e(o.length+t.length);s.set(o),s.set(t,o.length),t=s,a.w=o.length}return z(t,n.level==null?6:n.level,n.mem==null?a.l?Math.ceil(Math.max(8,Math.min(13,Math.log(t.length)))*1.5):20:12+n.mem,r,i,a)},U=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},W=function(e,t){return e[t]|e[t+1]<<8},G=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},K=function(e,t){return G(e,t)+G(e,t+4)*4294967296},q=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function J(e,t){return H(e,t||{},0,0)}function ne(e,t){return k(e,{i:2},t&&t.out,t&&t.dictionary)}var re=function(t,n,r,i){for(var a in t){var o=t[a],s=n+a,c=i;Array.isArray(o)&&(c=U(i,o[1]),o=o[0]),o instanceof e?r[s]=[o,c]:(r[s+=`/`]=[new e(0),c],re(o,s,r,i))}},Y=typeof TextEncoder<`u`&&/*#__PURE__*/ new TextEncoder,X=typeof TextDecoder<`u`&&/*#__PURE__*/ new TextDecoder;try{X.decode(R,{stream:!0})}catch{}var Z=function(e){for(var t=``,n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:E(e,n-1)};i?i==3?(r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?t+=String.fromCharCode((r&31)<<6|e[n++]&63):t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(r)}};function Q(t,n){if(n){for(var r=new e(t.length),i=0;i<t.length;++i)r[i]=t.charCodeAt(i);return r}if(Y)return Y.encode(t);for(var a=t.length,o=new e(t.length+(t.length>>1)),s=0,c=function(e){o[s++]=e},i=0;i<a;++i){if(s+5>o.length){var l=new e(s+8+(a-i<<1));l.set(o),o=l}var u=t.charCodeAt(i);u<128||n?c(u):u<2048?(c(192|u>>6),c(128|u&63)):u>55295&&u<57344?(u=65536+(u&1047552)|t.charCodeAt(++i)&1023,c(240|u>>18),c(128|u>>12&63),c(128|u>>6&63),c(128|u&63)):(c(224|u>>12),c(128|u>>6&63),c(128|u&63))}return E(o,0,s)}function $(e,t){if(t){for(var n=``,r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}if(X)return X.decode(e);var i=Z(e),a=i.s,n=i.r;return n.length&&O(8),a}var ie=function(e,t){return t+30+W(e,t+26)+W(e,t+28)},ae=function(e,t,n){var r=W(e,t+28),i=$(e.subarray(t+46,t+46+r),!(W(e,t+8)&2048)),a=t+46+r,o=G(e,t+20),s=n&&o==4294967295?oe(e,a):[o,G(e,t+24),G(e,t+42)],c=s[0],l=s[1],u=s[2];return[W(e,t+10),c,l,i,a+W(e,t+30)+W(e,t+32),u]},oe=function(e,t){for(;W(e,t)!=1;t+=4+W(e,t+2));return[K(e,t+12),K(e,t+4),K(e,t+20)]},se=function(e){var t=0;if(e)for(var n in e){var r=e[n].length;r>65535&&O(9),t+=r+4}return t},ce=function(e,t,n,r,i,a,o,s){var c=r.length,l=n.extra,u=s&&s.length,d=se(l);q(e,t,o==null?67324752:33639248),t+=4,o!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=i&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),p=f.getFullYear()-1980;if((p<0||p>119)&&O(10),q(e,t,p<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1&&(q(e,t,n.crc),q(e,t+4,a<0?-a-2:a),q(e,t+8,n.size)),q(e,t+12,c),q(e,t+14,d),t+=16,o!=null&&(q(e,t,u),q(e,t+6,n.attrs),q(e,t+10,o),t+=14),e.set(r,t),t+=c,d)for(var m in l){var h=l[m],g=h.length;q(e,t,+m),q(e,t+2,g),e.set(h,t+4),t+=4+g}return u&&(e.set(s,t),t+=u),t},le=function(e,t,n,r,i){q(e,t,101010256),q(e,t+8,n),q(e,t+10,n),q(e,t+12,r),q(e,t+16,i)};function ue(t,n){n||={};var r={},i=[];re(t,``,r,n);var a=0,o=0;for(var s in r){var c=r[s],l=c[0],u=c[1],d=u.level==0?0:8,f=Q(s),p=f.length,m=u.comment,h=m&&Q(m),g=h&&h.length,_=se(u.extra);p>65535&&O(11);var v=d?J(l,u):l,y=v.length,b=V();b.p(l),i.push(U(u,{size:l.length,crc:b.d(),c:v,f,m:h,u:p!=s.length||h&&m.length!=g,o:a,compression:d})),a+=30+p+_+y,o+=76+2*(p+_)+(g||0)+y}for(var x=new e(o+22),S=a,C=o-a,w=0;w<i.length;++w){var f=i[w];ce(x,f.o,f,f.f,f.u,f.c.length);var T=30+f.f.length+se(f.extra);x.set(f.c,f.o+T),ce(x,a,f,f.f,f.u,f.c.length,f.o,f.m),a+=16+T+(f.m?f.m.length:0)}return le(x,a,i.length,C,S),x}function de(t,n){for(var r={},i=t.length-22;G(t,i)!=101010256;--i)(!i||t.length-i>65558)&&O(13);var a=W(t,i+8);if(!a)return{};var o=G(t,i+16),s=o==4294967295||a==65535;if(s){var c=G(t,i-12);s=G(t,c)==101075792,s&&(a=G(t,c+32),o=G(t,c+48))}for(var l=n&&n.filter,u=0;u<a;++u){var d=ae(t,o,s),f=d[0],p=d[1],m=d[2],h=d[3],g=d[4],_=d[5],v=ie(t,_);o=g,(!l||l({name:h,size:p,originalSize:m,compression:f}))&&(f?f==8?r[h]=ne(t.subarray(v,v+p),{out:new e(m)}):O(14,`unknown compression type `+f):r[h]=E(t,v,v+p))}return r}export{de as n,ue as r,Q as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./fflate.module-ChfQ5943.js";var t={stl:`stl`,"3mf":`3mf`,obj:`obj`,step:`step`,stp:`step`,iges:`iges`,igs:`iges`},n=Object.keys(t).map(e=>`.`+e).join(`,`),r=`.gcode,.gco,.g,.3mf`,i=e=>e>1e6?`${(e/1e6).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1e3))} kB`,a=/^Metadata\/plate_(\d+)\.gcode$/;function o(t,n,r=()=>{}){try{return e(t,{filter:e=>(r(e),n(e.name))})}catch{return null}}function s(e,n){let r=(e.match(/\.(\w+)$/)||[])[1]?.toLowerCase();if([`gcode`,`gco`,`g`].includes(r))return{kind:`gcode`};if(!t[r])return{kind:`unknown`};if(r===`3mf`&&n){let e=[],t=o(n,t=>(e.push(t),/^Metadata\/plate_\d+\.png$/.test(t)))||{},r=e.map(e=>e.match(a)).filter(Boolean).map(e=>Number(e[1])).sort((e,t)=>e-t);if(r.length)return{kind:`gcode3mf`,plates:r.map(e=>({plate:e,thumbnail:t[`Metadata/plate_${e}.png`]||null}))}}return{kind:`model`,format:t[r]}}function c(e){let t=0;return o(e,e=>!1,e=>{/\.model$/i.test(e.name)&&(t+=e.originalSize)}),t}async function l(e){let t=[],n=[];for(let r of e){let e=s(r.name,/\.3mf$/i.test(r.name)?new Uint8Array(await r.arrayBuffer()):void 0);(e.kind===`model`?t:n).push({file:r,what:e})}return{models:t.map(e=>e.file),others:n}}export{c as a,i,n,l as o,s as r,r as t};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{n as e}from"./fflate.module-ChfQ5943.js";import{a as t}from"./files-BZtizmc1.js";import{$n as n,A as r,Fr as i,Ft as a,Hn as o,Ir as s,Kn as c,Ln as l,Lt as u,Ma as d,Mn as f,Qi as p,Rn as m,U as h,V as g,Wi as _,Wr as v,_r as y,ar as b,ct as x,fr as S,gr as C,ir as w,j as T,mr as E,pa as ee,qt as D,ro as O}from"./three.core-BHZv2AuD.js";var k=class extends c{constructor(e){super(e)}load(e,t,n,r){let i=this,o=new a(this.manager);o.setPath(this.path),o.setResponseType(`arraybuffer`),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(n){try{t(i.parse(n))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}},n,r)}parse(e){function t(e){let t=new DataView(e);if(84+t.getUint32(80,!0)*50===t.byteLength)return!0;let r=[115,111,108,105,100];for(let e=0;e<5;e++)if(n(r,t,e))return!1;return!0}function n(e,t,n){for(let r=0,i=e.length;r<i;r++)if(e[r]!==t.getUint8(n+r))return!1;return!0}function i(e){let t=new DataView(e),n=t.getUint32(80,!0),i,a,o,s=!1,c,l,u,d,f;for(let e=0;e<70;e++)t.getUint32(e,!1)==1129270351&&t.getUint8(e+4)==82&&t.getUint8(e+5)==61&&(s=!0,c=new Float32Array(n*3*3),l=t.getUint8(e+6)/255,u=t.getUint8(e+7)/255,d=t.getUint8(e+8)/255,f=t.getUint8(e+9)/255);let m=new T,g=new Float32Array(n*3*3),_=new Float32Array(n*3*3),v=new h;for(let e=0;e<n;e++){let n=84+e*50,r=t.getFloat32(n,!0),f=t.getFloat32(n+4,!0),m=t.getFloat32(n+8,!0);if(s){let e=t.getUint16(n+48,!0);e&32768?(i=l,a=u,o=d):(i=(e&31)/31,a=(e>>5&31)/31,o=(e>>10&31)/31)}for(let l=1;l<=3;l++){let u=n+l*12,d=e*3*3+(l-1)*3;g[d]=t.getFloat32(u,!0),g[d+1]=t.getFloat32(u+4,!0),g[d+2]=t.getFloat32(u+8,!0),_[d]=r,_[d+1]=f,_[d+2]=m,s&&(v.setRGB(i,a,o,p),c[d]=v.r,c[d+1]=v.g,c[d+2]=v.b)}}return m.setAttribute(`position`,new r(g,3)),m.setAttribute(`normal`,new r(_,3)),s&&(m.setAttribute(`color`,new r(c,3)),m.hasColors=!0,m.alpha=f),m}function a(e){let t=new T,n=/solid([\s\S]*?)endsolid/g,r=/facet([\s\S]*?)endfacet/g,i=/solid\s(.+)/,a=0,o=`[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)`,s=RegExp(`vertex`+o+o+o,`g`),c=RegExp(`normal`+o+o+o,`g`),l=[],d=[],f=[],p=new O,m,h=0,g=0,_=0;for(;(m=n.exec(e))!==null;){g=_;let e=m[0],n=(m=i.exec(e))===null?``:m[1];for(f.push(n);(m=r.exec(e))!==null;){let e=0,t=0,n=m[0];for(;(m=c.exec(n))!==null;)p.x=parseFloat(m[1]),p.y=parseFloat(m[2]),p.z=parseFloat(m[3]),t++;for(;(m=s.exec(n))!==null;)l.push(parseFloat(m[1]),parseFloat(m[2]),parseFloat(m[3])),d.push(p.x,p.y,p.z),e++,_++;t!==1&&console.error(`THREE.STLLoader: Something isn't right with the normal of face number `+a),e!==3&&console.error(`THREE.STLLoader: Something isn't right with the vertices of face number `+a),a++}let o=g,u=_-g;t.userData.groupNames=f,t.addGroup(o,u,h),h++}return t.setAttribute(`position`,new u(l,3)),t.setAttribute(`normal`,new u(d,3)),t}function o(e){return typeof e==`string`?e:new TextDecoder().decode(e)}function s(e){if(typeof e==`string`){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t.buffer||t}return e}let c=s(e);return t(c)?i(c):a(o(e))}};function A(e,t=!1){let n=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),i=new Set(Object.keys(e[0].morphAttributes)),a={},o={},s=e[0].morphTargetsRelative,c=new T,l=0;for(let u=0;u<e.length;++u){let d=e[u],f=0;if(n!==(d.index!==null))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.`),null;for(let e in d.attributes){if(!r.has(e))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. All geometries must have compatible attributes; make sure "`+e+`" attribute exists among all geometries, or in none of them.`),null;a[e]===void 0&&(a[e]=[]),a[e].push(d.attributes[e]),f++}if(f!==r.size)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. Make sure all geometries have the same number of attributes.`),null;if(s!==d.morphTargetsRelative)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. .morphTargetsRelative must be consistent throughout all geometries.`),null;for(let e in d.morphAttributes){if(!i.has(e))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. .morphAttributes must be consistent throughout all geometries.`),null;o[e]===void 0&&(o[e]=[]),o[e].push(d.morphAttributes[e])}if(t){let e;if(n)e=d.index.count;else if(d.attributes.position!==void 0)e=d.attributes.position.count;else return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. The geometry must have either an index or a position attribute`),null;c.addGroup(l,e,u),l+=e}}if(n){let t=0,n=[];for(let r=0;r<e.length;++r){let i=e[r].index;for(let e=0;e<i.count;++e)n.push(i.getX(e)+t);t+=e[r].attributes.position.count}c.setIndex(n)}for(let e in a){let t=j(a[e]);if(!t)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` attribute.`),null;c.setAttribute(e,t)}for(let e in o){let t=o[e][0].length;if(t!==0){c.morphAttributes=c.morphAttributes||{},c.morphAttributes[e]=[];for(let n=0;n<t;++n){let t=[];for(let r=0;r<o[e].length;++r)t.push(o[e][r][n]);let r=j(t);if(!r)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` morphAttribute.`),null;c.morphAttributes[e].push(r)}}}return c}function j(e){let t,n,i,a=-1,o=0;for(let r=0;r<e.length;++r){let s=e[r];if(t===void 0&&(t=s.array.constructor),t!==s.array.constructor)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.`),null;if(n===void 0&&(n=s.itemSize),n!==s.itemSize)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.`),null;if(i===void 0&&(i=s.normalized),i!==s.normalized)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.`),null;if(a===-1&&(a=s.gpuType),a!==s.gpuType)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes.`),null;o+=s.count*n}let s=new t(o),c=new r(s,n,i),l=0;for(let t=0;t<e.length;++t){let r=e[t];if(r.isInterleavedBufferAttribute){let e=l/n;for(let t=0,i=r.count;t<i;t++)for(let i=0;i<n;i++){let n=r.getComponent(t,i);c.setComponent(t+e,i,n)}}else s.set(r.array,l);l+=r.count*n}return a!==void 0&&(c.gpuType=a),c}function M(e,t=1e-4){t=Math.max(t,2**-52);let n={},r=e.getIndex(),i=e.getAttribute(`position`),a=r?r.count:i.count,o=0,s=Object.keys(e.attributes),c={},l={},u=[],d=[`getX`,`getY`,`getZ`,`getW`],f=[`setX`,`setY`,`setZ`,`setW`];for(let t=0,n=s.length;t<n;t++){let n=s[t],r=e.attributes[n];c[n]=new r.constructor(new r.array.constructor(r.count*r.itemSize),r.itemSize,r.normalized);let i=e.morphAttributes[n];i&&(l[n]||(l[n]=[]),i.forEach((e,t)=>{let r=new e.array.constructor(e.count*e.itemSize);l[n][t]=new e.constructor(r,e.itemSize,e.normalized)}))}let p=t*.5,m=10**Math.log10(1/t),h=p*m;for(let t=0;t<a;t++){let i=r?r.getX(t):t,a=``;for(let t=0,n=s.length;t<n;t++){let n=s[t],r=e.getAttribute(n),o=r.itemSize;for(let e=0;e<o;e++)a+=`${Math.trunc(r[d[e]](i)*m+h)},`}if(a in n)u.push(n[a]);else{for(let t=0,n=s.length;t<n;t++){let n=s[t],r=e.getAttribute(n),a=e.morphAttributes[n],u=r.itemSize,p=c[n],m=l[n];for(let e=0;e<u;e++){let t=d[e],n=f[e];if(p[n](o,r[t](i)),a)for(let e=0,r=a.length;e<r;e++)m[e][n](o,a[e][t](i))}}n[a]=o,u.push(o),o++}}let g=e.clone();for(let t in e.attributes){let e=c[t];if(g.setAttribute(t,new e.constructor(e.array.slice(0,o*e.itemSize),e.itemSize,e.normalized)),t in l)for(let e=0;e<l[t].length;e++){let n=l[t][e];g.morphAttributes[t][e]=new n.constructor(n.array.slice(0,o*n.itemSize),n.itemSize,n.normalized)}}return g.setIndex(u),g}function N(e,t=Math.PI/3){let n=e.index?e.toNonIndexed():e,i=n.attributes.position,a=i.count,o;if(i.isBufferAttribute===!0&&i.itemSize===3&&i.normalized===!1)o=i.array;else{o=new Float64Array(a*3);for(let e=0;e<a;e++)o[3*e+0]=i.getX(e),o[3*e+1]=i.getY(e),o[3*e+2]=i.getZ(e)}let s=Math.cos(t),c=(1+1e-10)*100,l=a/3,u=new Float64Array(l*3);for(let e=0;e<l;e++){let t=9*e,n=o[t+0],r=o[t+1],i=o[t+2],a=o[t+3],s=o[t+4],c=o[t+5],l=o[t+6],d=o[t+7],f=o[t+8],p=l-a,m=d-s,h=f-c,g=n-a,_=r-s,v=i-c,y=m*v-h*_,b=h*g-p*v,x=p*_-m*g,S=1/(Math.sqrt(y*y+b*b+x*x)||1);u[3*e+0]=y*S,u[3*e+1]=b*S,u[3*e+2]=x*S}let d=new Int32Array(a),f=new Float64Array(a*3),p=1;for(;p<a*2;)p<<=1;let m=p-1,h=new Int32Array(p),g=0;for(let e=0;e<a;e++){let t=3*e,n=Math.trunc(o[t+0]*c),r=Math.trunc(o[t+1]*c),i=Math.trunc(o[t+2]*c),a=(Math.imul(n,73856093)^Math.imul(r,19349663)^Math.imul(i,83492791))&m;for(;;){let t=h[a];if(t===0){let t=3*g;f[t+0]=n,f[t+1]=r,f[t+2]=i,h[a]=g+1,d[e]=g++;break}let o=3*(t-1);if(f[o+0]===n&&f[o+1]===r&&f[o+2]===i){d[e]=t-1;break}a=a+1&m}}let _=new Int32Array(g+1);for(let e=0;e<a;e++)_[d[e]+1]++;for(let e=0;e<g;e++)_[e+1]+=_[e];let v=new Int32Array(a),y=_.slice(0,g);for(let e=0;e<l;e++){let t=3*e;v[y[d[t+0]]++]=e,v[y[d[t+1]]++]=e,v[y[d[t+2]]++]=e}let b=new Float32Array(a*3);for(let e=0;e<l;e++){let t=3*e,n=u[t+0],r=u[t+1],i=u[t+2];for(let e=0;e<3;e++){let a=t+e,o=d[a],c=0,l=0,f=0;for(let e=_[o],t=_[o+1];e<t;e++){let t=3*v[e],a=u[t+0],o=u[t+1],d=u[t+2];n*a+r*o+i*d>s&&(c+=a,l+=o,f+=d)}let p=1/(Math.sqrt(c*c+l*l+f*f)||1);b[3*a+0]=c*p,b[3*a+1]=l*p,b[3*a+2]=f*p}}return n.setAttribute(`normal`,new r(b,3,!1)),n}var P=p,F=`http://schemas.microsoft.com/3dmanufacturing/beamlattice/2017/02`,I=`http://schemas.microsoft.com/3dmanufacturing/beamlattice/balls/2020/07`,te=class extends c{constructor(e){super(e),this.availableExtensions=[]}load(e,t,n,r){let i=this,o=new a(i.manager);o.setPath(i.path),o.setResponseType(`arraybuffer`),o.setRequestHeader(i.requestHeader),o.setWithCredentials(i.withCredentials),o.load(e,function(n){try{t(i.parse(n))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}},n,r)}parse(t){let n=this,i=new d(this.manager);function a(t){let n=null,r=null,i,a,o=[],c=[],l,u={},d={},f={},p=new TextDecoder;try{n=e(new Uint8Array(t))}catch(e){if(e instanceof ReferenceError)return console.error(`THREE.3MFLoader: fflate missing and file is compressed.`),null}let m=null;for(r in n)r.match(/\_rels\/.rels$/)?i=r:r.match(/3D\/_rels\/.*\.model\.rels$/)?a=r:r.match(/^3D\/[^\/]*\.model$/)?m=r:r.match(/^3D\/.*\/.*\.model$/)?o.push(r):r.match(/^3D\/Textures?\/.*/)&&c.push(r);if(o.push(m),i===void 0)throw Error("THREE.ThreeMFLoader: Cannot find relationship file `rels` in 3MF archive.");let h=n[i],g=s(p.decode(h));if(a){let e=n[a];l=s(p.decode(e))}for(let e=0;e<o.length;e++){let t=o[e],r=n[t],i=p.decode(r),a=new DOMParser().parseFromString(i,`application/xml`);a.documentElement.nodeName.toLowerCase()!==`model`&&console.error(`THREE.3MFLoader: Error loading 3MF - no 3MF document found: `,t);let s=a.querySelector(`model`),c={};for(let e=0;e<s.attributes.length;e++){let t=s.attributes[e];t.name.match(/^xmlns:(.+)$/)&&(c[t.value]=RegExp.$1)}let l=G(s);l.xml=s,0<Object.keys(c).length&&(l.extensions=c),u[t]=l}for(let e=0;e<c.length;e++){let t=c[e];f[t]=n[t].buffer}return{rels:g,modelRels:l,model:u,printTicket:d,texture:f}}function s(e){let t=[],n=new DOMParser().parseFromString(e,`application/xml`).querySelectorAll(`Relationship`);for(let e=0;e<n.length;e++){let r=n[e],i={target:r.getAttribute(`Target`),id:r.getAttribute(`Id`),type:r.getAttribute(`Type`)};t.push(i)}return t}function l(e){let t={};for(let n=0;n<e.length;n++){let r=e[n],i=r.getAttribute(`name`);0<=[`Title`,`Designer`,`Description`,`Copyright`,`LicenseTerms`,`Rating`,`CreationDate`,`ModificationDate`].indexOf(i)&&(t[i]=r.textContent)}return t}function f(e){let t={id:e.getAttribute(`id`),basematerials:[]},n=e.querySelectorAll(`base`);for(let e=0;e<n.length;e++){let r=n[e],i=ne(r);i.index=e,t.basematerials.push(i)}return t}function p(e){return{id:e.getAttribute(`id`),path:e.getAttribute(`path`),contenttype:e.getAttribute(`contenttype`),tilestyleu:e.getAttribute(`tilestyleu`),tilestylev:e.getAttribute(`tilestylev`),filter:e.getAttribute(`filter`)}}function k(e){let t={id:e.getAttribute(`id`),texid:e.getAttribute(`texid`),displaypropertiesid:e.getAttribute(`displaypropertiesid`)},n=e.querySelectorAll(`tex2coord`),r=[];for(let e=0;e<n.length;e++){let t=n[e],i=t.getAttribute(`u`),a=t.getAttribute(`v`);r.push(parseFloat(i),parseFloat(a))}return t.uvs=new Float32Array(r),t}function j(e){let t={id:e.getAttribute(`id`),displaypropertiesid:e.getAttribute(`displaypropertiesid`)},n=e.querySelectorAll(`color`),r=[],i=new h;for(let e=0;e<n.length;e++){let t=n[e].getAttribute(`color`);i.setStyle(t.substring(0,7),P),r.push(i.r,i.g,i.b)}return t.colors=new Float32Array(r),t}function M(e){let t=e.children,n={};for(let e=0;e<t.length;e++){let r={type:t[e].nodeName.substring(2)};for(let n=0;n<t[e].attributes.length;n++){let i=t[e].attributes[n];i.specified&&(r[i.name]=i.value)}n[t[e].getAttribute(`identifier`)]=r}return n}function N(e){let t={id:e.getAttribute(`id`),displayname:e.getAttribute(`displayname`)},n=e.children,r={};for(let e=0;e<n.length;e++){let t=n[e];if(t.nodeName===`i:in`||t.nodeName===`i:out`)r[t.nodeName===`i:in`?`inputs`:`outputs`]=M(t);else{let e=t.children,n={op:t.nodeName.substring(2),identifier:t.getAttribute(`identifier`)};for(let t=0;t<e.length;t++)n[e[t].nodeName.substring(2)]=M(e[t]);r[n.identifier]=n}}return t.operations=r,t}function te(e){let t={id:e.getAttribute(`id`)},n=e.querySelectorAll(`pbmetallic`),r=[];for(let e=0;e<n.length;e++){let t=n[e];r.push({name:t.getAttribute(`name`),metallicness:parseFloat(t.getAttribute(`metallicness`)),roughness:parseFloat(t.getAttribute(`roughness`))})}return t.data=r,t}function ne(e){let t={};return t.name=e.getAttribute(`name`),t.displaycolor=e.getAttribute(`displaycolor`),t.displaypropertiesid=e.getAttribute(`displaypropertiesid`),t}function L(e){let t={},n=[],r=e.querySelectorAll(`vertices vertex`);for(let e=0;e<r.length;e++){let t=r[e],i=t.getAttribute(`x`),a=t.getAttribute(`y`),o=t.getAttribute(`z`);n.push(parseFloat(i),parseFloat(a),parseFloat(o))}t.vertices=new Float32Array(n);let i=[],a=[],o=e.querySelectorAll(`triangles triangle`);for(let e=0;e<o.length;e++){let t=o[e],n=t.getAttribute(`v1`),r=t.getAttribute(`v2`),s=t.getAttribute(`v3`),c=t.getAttribute(`p1`),l=t.getAttribute(`p2`),u=t.getAttribute(`p3`),d=t.getAttribute(`pid`),f={};f.v1=parseInt(n,10),f.v2=parseInt(r,10),f.v3=parseInt(s,10),a.push(f.v1,f.v2,f.v3),c&&(f.p1=parseInt(c,10)),l&&(f.p2=parseInt(l,10)),u&&(f.p3=parseInt(u,10)),d&&(f.pid=d),0<Object.keys(f).length&&i.push(f)}t.triangleProperties=i,t.triangles=new Uint32Array(a);let s=e.getElementsByTagNameNS(F,`beamlattice`)[0];return s!==void 0&&(t.beamlattice=R(s)),t}function R(e){let t={radius:parseFloat(e.getAttribute(`radius`)),minLength:parseFloat(e.getAttribute(`minlength`)),cap:e.getAttribute(`cap`)||`sphere`,ballMode:e.getAttributeNS(I,`ballmode`)||`none`,ballRadius:parseFloat(e.getAttributeNS(I,`ballradius`)),beams:[],balls:[]},n=e.getAttribute(`clippingmode`)||e.getAttribute(`clipping`);n!==null&&n!==`none`&&console.warn(`THREE.3MFLoader: Beam lattice clipping is not supported. The lattice is rendered unclipped.`);let r=e.getElementsByTagNameNS(F,`beam`);for(let e=0;e<r.length;e++){let n=r[e],i={v1:parseInt(n.getAttribute(`v1`),10),v2:parseInt(n.getAttribute(`v2`),10)},a=n.getAttribute(`r1`),o=n.getAttribute(`r2`);a!==null&&(i.r1=parseFloat(a)),o!==null&&(i.r2=parseFloat(o)),t.beams.push(i)}let i=e.getElementsByTagNameNS(I,`ball`);for(let e=0;e<i.length;e++){let n=i[e],r={vindex:parseInt(n.getAttribute(`vindex`),10)},a=n.getAttribute(`r`);a!==null&&(r.r=parseFloat(a)),t.balls.push(r)}return t}function z(e){let t=[],n=e.querySelectorAll(`component`);for(let e=0;e<n.length;e++){let r=n[e],i=B(r);t.push(i)}return t}function B(e){let t={};t.objectId=e.getAttribute(`objectid`);let n=e.getAttribute(`transform`);return n&&(t.transform=V(n)),t}function V(e){let t=[];e.split(` `).forEach(function(e){t.push(parseFloat(e))});let n=new w;return n.set(t[0],t[3],t[6],t[9],t[1],t[4],t[7],t[10],t[2],t[5],t[8],t[11],0,0,0,1),n}function H(e){let t={type:e.getAttribute(`type`)},n=e.getAttribute(`id`);n&&(t.id=n);let r=e.getAttribute(`pid`);r&&(t.pid=r);let i=e.getAttribute(`pindex`);i&&(t.pindex=i);let a=e.getAttribute(`thumbnail`);a&&(t.thumbnail=a);let o=e.getAttribute(`partnumber`);o&&(t.partnumber=o);let s=e.getAttribute(`name`);s&&(t.name=s);let c=e.querySelector(`mesh`);c&&(t.mesh=L(c));let l=e.querySelector(`components`);return l&&(t.components=z(l)),t}function U(e){let t={};t.basematerials={};let n=e.querySelectorAll(`basematerials`);for(let e=0;e<n.length;e++){let r=n[e],i=f(r);t.basematerials[i.id]=i}t.texture2d={};let r=e.querySelectorAll(`texture2d`);for(let e=0;e<r.length;e++){let n=r[e],i=p(n);t.texture2d[i.id]=i}t.colorgroup={};let i=e.querySelectorAll(`colorgroup`);for(let e=0;e<i.length;e++){let n=i[e],r=j(n);t.colorgroup[r.id]=r}let a=e.querySelectorAll(`implicitfunction`);a.length>0&&(t.implicitfunction={});for(let e=0;e<a.length;e++){let n=a[e],r=N(n);t.implicitfunction[r.id]=r}t.pbmetallicdisplayproperties={};let o=e.querySelectorAll(`pbmetallicdisplayproperties`);for(let e=0;e<o.length;e++){let n=o[e],r=te(n);t.pbmetallicdisplayproperties[r.id]=r}t.texture2dgroup={};let s=e.querySelectorAll(`texture2dgroup`);for(let e=0;e<s.length;e++){let n=s[e],r=k(n);t.texture2dgroup[r.id]=r}t.object={};let c=e.querySelectorAll(`object`);for(let e=0;e<c.length;e++){let n=c[e],r=H(n);t.object[r.id]=r}return t}function W(e){let t=[],n=e.querySelectorAll(`item`);for(let e=0;e<n.length;e++){let r=n[e],i={objectId:r.getAttribute(`objectid`)},a=r.getAttribute(`transform`);a&&(i.transform=V(a)),t.push(i)}return t}function G(e){let t={unit:e.getAttribute(`unit`)||`millimeter`},n=e.querySelectorAll(`metadata`);n&&(t.metadata=l(n));let r=e.querySelector(`resources`);r&&(t.resources=U(r));let i=e.querySelector(`build`);return i&&(t.build=W(i)),t}function K(e,t,n,r){let a=e.texid,s=n.resources.texture2d[a];if(s){let e=r[s.path],t=s.contenttype,n=new Blob([e],{type:t}),a=URL.createObjectURL(n),c=i.load(a,function(){URL.revokeObjectURL(a)});switch(c.colorSpace=P,s.tilestyleu){case`wrap`:c.wrapS=_;break;case`mirror`:c.wrapS=C;break;case`none`:case`clamp`:c.wrapS=g;break;default:c.wrapS=_}switch(s.tilestylev){case`wrap`:c.wrapT=_;break;case`mirror`:c.wrapT=C;break;case`none`:case`clamp`:c.wrapT=g;break;default:c.wrapT=_}switch(s.filter){case`auto`:c.magFilter=m,c.minFilter=o;break;case`linear`:c.magFilter=m,c.minFilter=m,c.generateMipmaps=!1;break;case`nearest`:c.magFilter=y,c.minFilter=y,c.generateMipmaps=!1;break;default:c.magFilter=m,c.minFilter=o}return c}return null}function q(e,t,n,r,i,a,o){let s=o.pindex,c={};for(let e=0,n=t.length;e<n;e++){let n=t[e],r=n.p1===void 0?s:n.p1;c[r]===void 0&&(c[r]=[]),c[r].push(n)}let l=Object.keys(c),d=[];for(let t=0,s=l.length;t<s;t++){let s=l[t],f=c[s],p=e.basematerials[s],m=Q(p,r,i,a,o,ce),h=new T,g=[],_=n.vertices;for(let e=0,t=f.length;e<t;e++){let t=f[e];g.push(_[t.v1*3+0]),g.push(_[t.v1*3+1]),g.push(_[t.v1*3+2]),g.push(_[t.v2*3+0]),g.push(_[t.v2*3+1]),g.push(_[t.v2*3+2]),g.push(_[t.v3*3+0]),g.push(_[t.v3*3+1]),g.push(_[t.v3*3+2])}h.setAttribute(`position`,new u(g,3));let v=new b(h,m);d.push(v)}return d}function J(e,t,n,r,i,a,o){let s=new T,c=[],l=[],d=n.vertices,f=e.uvs;for(let e=0,n=t.length;e<n;e++){let n=t[e];c.push(d[n.v1*3+0]),c.push(d[n.v1*3+1]),c.push(d[n.v1*3+2]),c.push(d[n.v2*3+0]),c.push(d[n.v2*3+1]),c.push(d[n.v2*3+2]),c.push(d[n.v3*3+0]),c.push(d[n.v3*3+1]),c.push(d[n.v3*3+2]),l.push(f[n.p1*2+0]),l.push(f[n.p1*2+1]),l.push(f[n.p2*2+0]),l.push(f[n.p2*2+1]),l.push(f[n.p3*2+0]),l.push(f[n.p3*2+1])}s.setAttribute(`position`,new u(c,3)),s.setAttribute(`uv`,new u(l,2));let p=Q(e,r,i,a,o,K),m=new S({map:p,flatShading:!0});return new b(s,m)}function Y(e,t,n,r){let i=new T,a=[],o=[],s=n.vertices,c=e.colors;for(let e=0,n=t.length;e<n;e++){let n=t[e],i=n.v1,l=n.v2,u=n.v3;a.push(s[i*3+0]),a.push(s[i*3+1]),a.push(s[i*3+2]),a.push(s[l*3+0]),a.push(s[l*3+1]),a.push(s[l*3+2]),a.push(s[u*3+0]),a.push(s[u*3+1]),a.push(s[u*3+2]);let d=n.p1===void 0?r.pindex:n.p1,f=n.p2===void 0?d:n.p2,p=n.p3===void 0?d:n.p3;o.push(c[d*3+0]),o.push(c[d*3+1]),o.push(c[d*3+2]),o.push(c[f*3+0]),o.push(c[f*3+1]),o.push(c[f*3+2]),o.push(c[p*3+0]),o.push(c[p*3+1]),o.push(c[p*3+2])}i.setAttribute(`position`,new u(a,3)),i.setAttribute(`color`,new u(o,3));let l=new S({vertexColors:!0,flatShading:!0});return new b(i,l)}function X(e){let t=new T;t.setIndex(new r(e.triangles,1)),t.setAttribute(`position`,new r(e.vertices,3));let n=new S({name:c.DEFAULT_MATERIAL_NAME,color:16777215,flatShading:!0});return new b(t,n)}function Z(e){let t=e.beamlattice,n=e.vertices,r=[],i=new O,a=new O,o=new O,s=new O(0,1,0),l=new v,u=new w,d=t.beams,f=t.cap!==`butt`,p=/* @__PURE__ */ new Map;for(let e=0;e<d.length;e++){let c=d[e];i.fromArray(n,c.v1*3),a.fromArray(n,c.v2*3);let m=i.distanceTo(a);if(m<t.minLength)continue;let h=c.r1===void 0?t.radius:c.r1,g=c.r2===void 0?h:c.r2,_=new x(g,h,m,8,1,f);o.subVectors(a,i).divideScalar(m),l.setFromUnitVectors(s,o),u.makeRotationFromQuaternion(l),u.setPosition(i.add(a).multiplyScalar(.5)),_.applyMatrix4(u),r.push(_),f&&(p.set(c.v1,Math.max(h,p.get(c.v1)||0)),p.set(c.v2,Math.max(g,p.get(c.v2)||0))),t.ballMode===`all`&&(p.set(c.v1,Math.max(t.ballRadius,p.get(c.v1)||0)),p.set(c.v2,Math.max(t.ballRadius,p.get(c.v2)||0)))}let m=t.balls;for(let e=0;e<m.length;e++){let n=m[e],r=n.r===void 0?t.ballRadius:n.r;p.set(n.vindex,Math.max(r,p.get(n.vindex)||0))}for(let[e,t]of p){let a=new ee(t,8,6);i.fromArray(n,e*3),a.translate(i.x,i.y,i.z),r.push(a)}let h=A(r),g=new S({name:c.DEFAULT_MATERIAL_NAME,color:16777215});return new b(h,g)}function re(e,t,n,r,i,a){let o=Object.keys(e),s=[];for(let c=0,l=o.length;c<l;c++){let l=o[c],u=e[l];switch(ie(l,r)){case`material`:let e=r.resources.basematerials[l],o=q(e,u,t,n,r,i,a);for(let e=0,t=o.length;e<t;e++)s.push(o[e]);break;case`texture`:let c=r.resources.texture2dgroup[l];s.push(J(c,u,t,n,r,i,a));break;case`vertexColors`:let d=r.resources.colorgroup[l];s.push(Y(d,u,t,a));break;case`default`:s.push(X(t));break;default:console.error(`THREE.3MFLoader: Unsupported resource type.`)}}if(a.name)for(let e=0;e<s.length;e++)s[e].name=a.name;return s}function ie(e,t){if(t.resources.texture2dgroup[e]!==void 0)return`texture`;if(t.resources.basematerials[e]!==void 0)return`material`;if(t.resources.colorgroup[e]!==void 0)return`vertexColors`;if(e==="default")return`default`}function ae(e,t){let n={},r=e.triangleProperties,i=t.pid;for(let e=0,t=r.length;e<t;e++){let t=r[e],a=t.pid===void 0?i:t.pid;a===void 0&&(a=`default`),n[a]===void 0&&(n[a]=[]),n[a].push(t)}return n}function oe(e,t,n,r,i){let a=new D,o=re(ae(e,i),e,t,n,r,i);if(e.beamlattice!==void 0){let t=Z(e);i.name&&(t.name=i.name),o.push(t)}for(let e=0,t=o.length;e<t;e++)a.add(o[e]);return a}function se(e,t,r){if(!e)return;let i=[],a=Object.keys(e);for(let e=0;e<a.length;e++){let t=a[e];for(let e=0;e<n.availableExtensions.length;e++){let r=n.availableExtensions[e];r.ns===t&&i.push(r)}}for(let n=0;n<i.length;n++){let a=i[n];a.apply(r,e[a.ns],t)}}function Q(e,t,n,r,i,a){return e.build===void 0&&(e.build=a(e,t,n,r,i)),e.build}function ce(e,t,n){let r,i=e.displaypropertiesid,a=n.resources.pbmetallicdisplayproperties;if(i!==null&&a[i]!==void 0){let t=a[i].data[e.index];r=new E({flatShading:!0,roughness:t.roughness,metalness:t.metallicness})}else r=new S({flatShading:!0});r.name=e.name;let o=e.displaycolor,s=o.substring(0,7);return r.color.setStyle(s,P),o.length===9&&(r.opacity=parseInt(o.charAt(7)+o.charAt(8),16)/255),r}function le(e,t,n,r){let i=new D;for(let a=0;a<e.length;a++){let o=e[a],s=t[o.objectId];s===void 0&&($(o.objectId,t,n,r),s=t[o.objectId]);let c=s.clone(),l=o.transform;l&&c.applyMatrix4(l),i.add(c)}return i}function $(e,t,n,r){let i=n.resources.object[e];if(i.mesh){let e=i.mesh,a=n.extensions,o=n.xml;se(a,e,o),t[i.id]=Q(e,t,n,r,i,oe)}else{let e=i.components;t[i.id]=Q(e,t,n,r,i,le)}i.name&&(t[i.id].name=i.name),n.resources.implicitfunction&&console.warn(`THREE.ThreeMFLoader: Implicit Functions are implemented in data-only.`,n.resources.implicitfunction)}function ue(e){let t=e.model,n=e.modelRels,r={},i=Object.keys(t),a={};if(n)for(let t=0,r=n.length;t<r;t++){let r=n[t],i=r.target.substring(1);e.texture[i]&&(a[r.target]=e.texture[i])}for(let e=0;e<i.length;e++){let n=t[i[e]],o=Object.keys(n.resources.object);for(let e=0;e<o.length;e++){let t=o[e];$(t,r,n,a)}}return r}function de(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.target.split(`.`).pop().toLowerCase()===`model`)return n}}function fe(e,t){let n=new D,r=de(t.rels),i=t.model[r.target.substring(1)].build;for(let t=0;t<i.length;t++){let r=i[t],a=e[r.objectId].clone(),o=r.transform;o&&a.applyMatrix4(o),n.add(a)}return n}let pe=a(t);return fe(ue(pe),pe)}addExtension(e){this.availableExtensions.push(e)}},ne=/^[og]\s*(.+)?/,L=/^mtllib /,R=/^usemtl /,z=/^usemap /,B=/\s+/,V=new O,H=new O,U=new O,W=new O,G=new O,K=new h;function q(){let e={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1){this.object.name=e,this.object.fromDeclaration=t!==!1;return}let n=this.object&&typeof this.object.currentMaterial==`function`?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize==`function`&&this.object._finalize(!0),this.object={name:e||``,fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(e,t){let n=this._finalize(!1);n&&(n.inherited||n.groupCount<=0)&&this.materials.splice(n.index,1);let r={index:this.materials.length,name:e||``,mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:``,smooth:n===void 0?this.smooth:n.smooth,groupStart:n===void 0?0:n.groupEnd,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){let t={index:typeof e==`number`?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(r),r},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){let t=this.currentMaterial();if(t&&t.groupEnd===-1&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(let e=this.materials.length-1;e>=0;e--)this.materials[e].groupCount<=0&&this.materials.splice(e,1);return e&&this.materials.length===0&&this.materials.push({name:``,smooth:this.smooth}),t}},n&&n.name&&typeof n.clone==`function`){let e=n.clone(0);e.inherited=!0,this.object.materials.push(e)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize==`function`&&this.object._finalize(!0)},parseVertexIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){let r=this.vertices,i=this.object.geometry.vertices;i.push(r[e+0],r[e+1],r[e+2]),i.push(r[t+0],r[t+1],r[t+2]),i.push(r[n+0],r[n+1],r[n+2])},addVertexPoint:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){let r=this.normals,i=this.object.geometry.normals;i.push(r[e+0],r[e+1],r[e+2]),i.push(r[t+0],r[t+1],r[t+2]),i.push(r[n+0],r[n+1],r[n+2])},addFaceNormal:function(e,t,n){let r=this.vertices,i=this.object.geometry.normals;V.fromArray(r,e),H.fromArray(r,t),U.fromArray(r,n),G.subVectors(U,H),W.subVectors(V,H),G.cross(W),G.normalize(),i.push(G.x,G.y,G.z),i.push(G.x,G.y,G.z),i.push(G.x,G.y,G.z)},addColor:function(e,t,n){let r=this.colors,i=this.object.geometry.colors;r[e]!==void 0&&i.push(r[e+0],r[e+1],r[e+2]),r[t]!==void 0&&i.push(r[t+0],r[t+1],r[t+2]),r[n]!==void 0&&i.push(r[n+0],r[n+1],r[n+2])},addUV:function(e,t,n){let r=this.uvs,i=this.object.geometry.uvs;i.push(r[e+0],r[e+1]),i.push(r[t+0],r[t+1]),i.push(r[n+0],r[n+1])},addDefaultUV:function(){let e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){let t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,r,i,a,o,s,c){let l=this.vertices.length,u=this.parseVertexIndex(e,l),d=this.parseVertexIndex(t,l),f=this.parseVertexIndex(n,l);if(this.addVertex(u,d,f),this.addColor(u,d,f),o!==void 0&&o!==``){let e=this.normals.length;u=this.parseNormalIndex(o,e),d=this.parseNormalIndex(s,e),f=this.parseNormalIndex(c,e),this.addNormal(u,d,f)}else this.addFaceNormal(u,d,f);if(r!==void 0&&r!==``){let e=this.uvs.length;u=this.parseUVIndex(r,e),d=this.parseUVIndex(i,e),f=this.parseUVIndex(a,e),this.addUV(u,d,f),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type=`Points`;let t=this.vertices.length;for(let n=0,r=e.length;n<r;n++){let r=this.parseVertexIndex(e[n],t);this.addVertexPoint(r),this.addColor(r)}},addLineGeometry:function(e,t){this.object.geometry.type=`Line`;let n=this.vertices.length,r=this.uvs.length;for(let t=0,r=e.length;t<r;t++)this.addVertexLine(this.parseVertexIndex(e[t],n));for(let e=0,n=t.length;e<n;e++)this.addUVLine(this.parseUVIndex(t[e],r))}};return e.startObject(``,!1),e}var J=class extends c{constructor(e){super(e),this.materials=null}load(e,t,n,r){let i=this,o=new a(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(n){try{t(i.parse(n))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}},n,r)}setMaterials(e){return this.materials=e,this}parse(e){let t=new q;e.indexOf(`\r
|
|
2
|
+
`)!==-1&&(e=e.replace(/\r\n/g,`
|
|
3
|
+
`)),e.indexOf(`\\
|
|
4
|
+
`)!==-1&&(e=e.replace(/\\\n/g,``));let r=e.split(`
|
|
5
|
+
`),a=[];for(let e=0,n=r.length;e<n;e++){let n=r[e].trimStart();if(n.length===0)continue;let i=n.charAt(0);if(i!==`#`){if(i===`v`){let e=n.split(B);switch(e[0]){case`v`:t.vertices.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])),e.length>=7?(K.setRGB(parseFloat(e[4]),parseFloat(e[5]),parseFloat(e[6]),p),t.colors.push(K.r,K.g,K.b)):t.colors.push(void 0,void 0,void 0);break;case`vn`:t.normals.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]));break;case`vt`:t.uvs.push(parseFloat(e[1]),parseFloat(e[2]))}}else if(i===`f`){let e=n.slice(1).trim().split(B),r=[];for(let t=0,n=e.length;t<n;t++){let n=e[t];if(n.length>0){let e=n.split(`/`);r.push(e)}}let i=r[0];for(let e=1,n=r.length-1;e<n;e++){let n=r[e],a=r[e+1];t.addFace(i[0],n[0],a[0],i[1],n[1],a[1],i[2],n[2],a[2])}}else if(i===`l`){let e=n.substring(1).trim().split(` `),r=[],i=[];if(n.indexOf(`/`)===-1)r=e;else for(let t=0,n=e.length;t<n;t++){let n=e[t].split(`/`);n[0]!==``&&r.push(n[0]),n[1]!==``&&i.push(n[1])}t.addLineGeometry(r,i)}else if(i===`p`){let e=n.slice(1).trim().split(` `);t.addPointGeometry(e)}else if((a=ne.exec(n))!==null){let e=(` `+a[0].slice(1).trim()).slice(1);t.startObject(e)}else if(R.test(n))t.object.startMaterial(n.substring(7).trim(),t.materialLibraries);else if(L.test(n))t.materialLibraries.push(n.substring(7).trim());else if(z.test(n))console.warn(`THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.`);else if(i===`s`){if(a=n.split(` `),a.length>1){let e=a[1].trim().toLowerCase();t.object.smooth=e!==`0`&&e!==`off`}else t.object.smooth=!0;let e=t.object.currentMaterial();e&&(e.smooth=t.object.smooth)}else{if(n===`\0`)continue;console.warn(`THREE.OBJLoader: Unexpected line: "`+n+`"`)}}}t.finalize();let o=new D;if(o.materialLibraries=[].concat(t.materialLibraries),t.objects.length!==1||t.objects[0].geometry.vertices.length!==0)for(let e=0,r=t.objects.length;e<r;e++){let r=t.objects[e],a=r.geometry,c=r.materials,d=a.type===`Line`,p=a.type===`Points`,m=!1;if(a.vertices.length===0)continue;let h=new T;h.setAttribute(`position`,new u(a.vertices,3)),a.normals.length>0&&h.setAttribute(`normal`,new u(a.normals,3)),a.colors.length>0&&(m=!0,h.setAttribute(`color`,new u(a.colors,3))),a.hasUVIndices===!0&&h.setAttribute(`uv`,new u(a.uvs,2));let g=[];for(let e=0,r=c.length;e<r;e++){let r=c[e],i=r.name+`_`+r.smooth+`_`+m,a=t.materials[i];if(this.materials!==null){if(a=this.materials.create(r.name),d&&a&&!(a instanceof f)){let e=new f;n.prototype.copy.call(e,a),e.color.copy(a.color),a=e}else if(p&&a&&!(a instanceof s)){let e=new s({size:10,sizeAttenuation:!1});n.prototype.copy.call(e,a),e.color.copy(a.color),e.map=a.map,a=e}}a===void 0&&(a=d?new f:p?new s({size:1,sizeAttenuation:!1}):new S,a.name=r.name,a.flatShading=!r.smooth,a.vertexColors=m,t.materials[i]=a),g.push(a)}let _;if(g.length>1){for(let e=0,t=c.length;e<t;e++){let t=c[e];h.addGroup(t.groupStart,t.groupCount,e)}_=d?new l(h,g):p?new i(h,g):new b(h,g)}else _=d?new l(h,g[0]):p?new i(h,g[0]):new b(h,g[0]);_.name=r.name,o.add(_)}else if(t.vertices.length>0){let e=new s({size:1,sizeAttenuation:!1}),n=new T;n.setAttribute(`position`,new u(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(n.setAttribute(`color`,new u(t.colors,3)),e.vertexColors=!0);let r=new i(n,e);o.add(r)}return o}},Y=3e7,X=new E({color:`#cbccd0`,roughness:.72}),Z=Math.PI/6,re=3e5;async function ie(e,n){if(n===`stl`)return new b(new k().parse(await e.arrayBuffer()));if(n===`3mf`){let n=await e.arrayBuffer(),r=t(new Uint8Array(n));if(r>Y)throw Object.assign(/* @__PURE__ */ Error(`too large to preview`),{xml:r});return new te().parse(n)}return new J().parse(await e.text())}function ae(e){let t=[];e.traverse(e=>{e.isMesh&&t.push(e)});let n=e=>(e.index?e.index.count:e.attributes.position.count)/3,r=t.reduce((e,t)=>e+n(t.geometry),0);for(let e of t){if(e.material=X,r>re)continue;let t=N(e.geometry,Z);t!==e.geometry&&e.geometry.dispose(),e.geometry=t}return r}export{N as a,M as i,ie as n,A as r,ae as t};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import{r as e,t}from"./fflate.module-ChfQ5943.js";function n(e,t){return[e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[8],t[0],t[1],t[2]].map(r).join(` `)}var r=e=>Math.abs(e)<5e-7?`0`:String(+e.toFixed(6)),i=e=>String(e).replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]),a=`<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="model" ContentType="application/vnd.ms-package.3dmanufacturing-3dmodel+xml"/></Types>
|
|
3
|
+
`,o=`<?xml version="1.0" encoding="UTF-8"?>
|
|
4
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Target="/3D/3dmodel.model" Id="rel0" Type="http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel"/></Relationships>
|
|
5
|
+
`;function s(s,c){let l=[`<?xml version="1.0" encoding="UTF-8"?>
|
|
6
|
+
<model unit="millimeter" xml:lang="en-US" xmlns="http://schemas.microsoft.com/3dmanufacturing/core/2015/02">
|
|
7
|
+
`,`<metadata name="Application">slicer-studio</metadata>
|
|
8
|
+
<resources>
|
|
9
|
+
`];for(let e of s){l.push(`<object id="${e.id}" type="model" name="${i(e.name)}"><mesh><vertices>\n`);let t=e.positions;for(let e=0;e<t.length;e+=3)l.push(`<vertex x="${r(t[e])}" y="${r(t[e+1])}" z="${r(t[e+2])}"/>\n`);l.push(`</vertices><triangles>
|
|
10
|
+
`);let n=e.index;for(let e=0;e<n.length;e+=3)l.push(`<triangle v1="${n[e]}" v2="${n[e+1]}" v3="${n[e+2]}"/>\n`);l.push(`</triangles></mesh></object>
|
|
11
|
+
`)}l.push(`</resources>
|
|
12
|
+
<build>
|
|
13
|
+
`);for(let e of c)l.push(`<item objectid="${e.objectId}" transform="${n(e.A,e.t)}"/>\n`);return l.push(`</build>
|
|
14
|
+
</model>
|
|
15
|
+
`),e({"[Content_Types].xml":t(a),"_rels/.rels":t(o),"3D/3dmodel.model":t(l.join(``))},{level:6})}export{s as plate3mf};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=.1,t=[1,0,0,0,1,0,0,0,1],n=e=>e*Math.PI/180,r=e=>{let t=n(e),r=e=>Math.abs(e)<1e-12?0:Math.abs(Math.abs(e)-1)<1e-12?Math.sign(e):e;return[r(Math.cos(t)),r(Math.sin(t))]},i=e=>{let[t,n]=r(e);return[1,0,0,0,t,-n,0,n,t]},a=e=>{let[t,n]=r(e);return[t,0,n,0,1,0,-n,0,t]},o=e=>{let[t,n]=r(e);return[t,-n,0,n,t,0,0,0,1]};function s(e,t){let n=Array(9);for(let r=0;r<3;r++)for(let i=0;i<3;i++)n[r*3+i]=e[r*3]*t[i]+e[r*3+1]*t[3+i]+e[r*3+2]*t[6+i];return n}var c=(e,[t,n,r])=>[e[0]*t+e[1]*n+e[2]*r,e[3]*t+e[4]*n+e[5]*r,e[6]*t+e[7]*n+e[8]*r];function l([e,n,r]){let a=Math.hypot(e,n,r)||1;if([e,n,r]=[e/a,n/a,r/a],r<-1+1e-9)return t.slice();if(r>1-1e-9)return i(180);let o=Math.hypot(e,n),[s,c]=[-n/o,e/o],l=-r,u=Math.sqrt(1-l*l),d=1-l;return[d*s*s+l,d*s*c,u*c,d*s*c,d*c*c+l,-u*s,-u*c,u*s,l]}function u(e,t,n){let r=o(e.spin),i=c(r,t);return{A:s(r,e.orient),t:[n[0]+e.x-i[0],n[1]+e.y-i[1],-i[2]]}}var d=(e,t,n)=>s(o(-t),s(n,s(o(t),e)));function f(e){let t=e.slice().sort((e,t)=>e[0]-t[0]||e[1]-t[1]);if(t.length<3)return t;let n=(e,t,n)=>(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0]),r=[],i=[];for(let e of t){for(;r.length>=2&&n(r[r.length-2],r[r.length-1],e)<=0;)r.pop();r.push(e)}for(let e=t.length-1;e>=0;e--){let r=t[e];for(;i.length>=2&&n(i[i.length-2],i[i.length-1],r)<=0;)i.pop();i.push(r)}return r.slice(0,-1).concat(i.slice(0,-1))}function p(e,t){let[n,r,i,a,o,s,c,l,u]=t,d=e.length/3,p=new Float64Array(d),m=new Float64Array(d),h=1/0,g=-1/0,_=1/0,v=-1/0,y=1/0,b=-1/0;for(let t=0;t<d;t++){let d=e[t*3],f=e[t*3+1],x=e[t*3+2],S=n*d+r*f+i*x,C=a*d+o*f+s*x,w=c*d+l*f+u*x;p[t]=S,m[t]=C,S<h&&(h=S),S>g&&(g=S),C<_&&(_=C),C>v&&(v=C),w<y&&(y=w),w>b&&(b=w)}let x=(h+g)/2,S=(_+v)/2,C=Array(d);for(let e=0;e<d;e++)C[e]=[p[e]-x,m[e]-S];return{hull:f(C),size:[g-h,v-_,b-y],shift:[x,S,y]}}function m(e,t,n,i){let[a,o]=r(t);return e.map(([e,t])=>[n+e*a-t*o,i+e*o+t*a])}var h=e=>{let t=1/0,n=-1/0,r=1/0,i=-1/0;for(let[a,o]of e)a<t&&(t=a),a>n&&(n=a),o<r&&(r=o),o>i&&(i=o);return[t,r,n,i]},g={outline:[[0,0],[256,0],[256,256],[0,256]],exclude:[],height:256};function _(e){let t=e&&Array.isArray(e.outline)&&e.outline.length>=3,n=t?e.outline:g.outline,r=h(n);return{outline:n,exclude:t&&Array.isArray(e.exclude)?e.exclude.filter(e=>e.length>=3):[],height:t&&e.height>0?e.height:g.height,box:r,center:[(r[0]+r[2])/2,(r[1]+r[3])/2],standIn:!t}}function v([e,t],n){let r=!1;for(let i=0,a=n.length-1;i<n.length;a=i++){let[o,s]=n[i],[c,l]=n[a];s>t!=l>t&&e<(c-o)*(t-s)/(l-s)+o&&(r=!r)}return r}function y([e,t],[n,r],[i,a]){let o=i-n,s=a-r,c=o*o+s*s,l=c?Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c)):0;return Math.hypot(e-n-l*o,t-r-l*s)}var b=e=>e.map((t,n)=>[t,e[(n+1)%e.length]]),x=(e,t,n)=>b(t).some(([t,r])=>y(e,t,r)<=n);function S([e,t],[n,r]){let i=(e,t,n)=>Math.sign((t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0])),a=(e,t,n)=>Math.min(e[0],n[0])<=t[0]&&t[0]<=Math.max(e[0],n[0])&&Math.min(e[1],n[1])<=t[1]&&t[1]<=Math.max(e[1],n[1]),o=i(e,t,n),s=i(e,t,r),c=i(n,r,e),l=i(n,r,t);return o!==s&&c!==l||o===0&&a(e,n,t)||s===0&&a(e,r,t)||c===0&&a(n,e,r)||l===0&&a(n,t,r)}function C(e,t){if(!e.length||!t.length)return!1;let[n,r,i,a]=h(e),[o,s,c,l]=h(t);if(i<o||c<n||a<s||l<r)return!1;if(v(e[0],t)||v(t[0],e))return!0;let u=b(t);return b(e).some(e=>u.some(t=>S(e,t)))}function w(e,t){if(C(e,t))return 0;let n=1/0;for(let r of e)for(let[e,i]of b(t))n=Math.min(n,y(r,e,i));for(let r of t)for(let[t,i]of b(e))n=Math.min(n,y(r,t,i));return n}function T(t,n,r){return n>r.height+e?`tall`:t.some(t=>!v(t,r.outline)&&!x(t,r.outline,e))?`outside`:r.exclude.some(e=>C(t,e))?`excluded`:null}function E(e,t){let n={};for(let r of e)n[r.id]={problem:T(r.points,r.height,t),overlap:!1};for(let t=0;t<e.length;t++)for(let r=t+1;r<e.length;r++)C(e[t].points,e[r].points)&&(n[e[t].id].overlap=n[e[r].id].overlap=!0);return n}function D(t,n,r,i,a){let[o,s,c,l]=n,[u,d,f,p]=r.box;if(o<u-e||s<d-e||c>f+e||l>p+e)return!1;for(let e of i){let[n,r,i,u]=e.box;if(!(c+a<=n||i+a<=o||l+a<=r||u+a<=s)&&w(t,e.points)<a)return!1}return T(t,0,r)===null}var O=e=>e.map(e=>({points:e,box:h(e)}));function k(t,n,r,i,a=6){let o=m(t,n,0,0),[s,c,l,u]=h(o),[d,f]=i.center,[p,g,_,v]=i.box,y=O(r),b=[];for(let t=p-s;t<=_-l+e;t+=5)for(let n=g-c;n<=v-u+e;n+=5)b.push([t,n]);b.push([d,f]),b.sort((e,t)=>Math.hypot(e[0]-d,e[1]-f)-Math.hypot(t[0]-d,t[1]-f));for(let[e,t]of b)if(D(o.map(([n,r])=>[n+e,r+t]),[s+e,c+t,l+e,u+t],i,y,a))return{x:e-d,y:t-f};return null}function A(t,n,r=6){let[i,a,o,s]=n.box,c=t.map(e=>{let t=m(e.points,e.spin,0,0),[n,r,i,a]=h(t);return{...e,turned:t,w:i-n,d:a-r,ox:(n+i)/2,oy:(r+a)/2}}).sort((e,t)=>t.d-e.d||t.w-e.w),l=[],u=null,d=a,f=[];for(let t of c)u&&u.x+t.w>o+e&&(d+=u.d+r,u=null),u||={y:d,x:i,d:0,items:[]},d+t.d>s+e||t.w>o-i+e?f.push(t):(u.items.push({item:t,x:u.x}),u.x+=t.w+r,u.d=Math.max(u.d,t.d),l.includes(u)||l.push(u));let p=l.flatMap(e=>e.items.map(({item:t,x:n})=>({item:t,cx:n+t.w/2,cy:e.y+t.d/2})));if(p.length){let[e,t,n,r]=h(p.flatMap(e=>[[e.cx-e.item.w/2,e.cy-e.item.d/2],[e.cx+e.item.w/2,e.cy+e.item.d/2]])),c=(i+o)/2-(e+n)/2,l=(a+s)/2-(t+r)/2;for(let e of p)e.cx+=c,e.cy+=l}let g={},_=[];for(let e of p){let t=e.cx-e.item.ox,i=e.cy-e.item.oy,a=e.item.turned.map(([e,n])=>[e+t,n+i]);D(a,h(a),n,O(_),r/2)?(g[e.item.id]={x:t-n.center[0],y:i-n.center[1]},_.push(a)):f.push(e.item)}let v=[];for(let e of f){let t=k(e.points,e.spin,_,n,r);t?(g[e.id]=t,_.push(m(e.points,e.spin,n.center[0]+t.x,n.center[1]+t.y))):v.push(e.id)}return{positions:g,overflow:v}}export{k as a,u as c,i as d,a as f,_ as i,m as l,d as m,c as n,p as o,l as p,A as r,s,t,E as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./files-BZtizmc1.js";import{A as t,j as n}from"./three.core-BHZv2AuD.js";import{a as r,i,n as a,r as o}from"./model-read-F5cM3GZJ.js";var s=Math.PI/6,c=3e5;function l(e){e.updateMatrixWorld(!0);let t=[];if(e.traverse(e=>{if(!e.isMesh)return;let r=new n().setAttribute(`position`,e.geometry.attributes.position.clone());e.geometry.index&&(r=r.setIndex(e.geometry.index.clone()).toNonIndexed()),r.applyMatrix4(e.matrixWorld),t.push(r)}),!t.length)throw Error(`no mesh in this file`);let r=i(t.length===1?t[0]:o(t),1e-4),a=r.index.array;return{positions:Float32Array.from(r.attributes.position.array),index:Uint32Array.from(a),triangles:a.length/3}}function u({positions:e,index:i,triangles:a}){let o=new n;if(o.setAttribute(`position`,new t(e,3)),o.setIndex(new t(i,1)),a>c)return{geometry:o,flat:!0};let l=r(o,s);return o.dispose(),{geometry:l,flat:!1}}async function d(t){let n=await a(t,e(t.name).format);try{return l(n)}finally{n.traverse(e=>e.geometry?.dispose())}}export{u as drawable,d as loadMesh};
|