@omrips/viewstl 2.0.0-rc.4 → 2.0.0-rc.6
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 +19 -173
- package/build/chunks/archive-QK7XZSVT.js +1 -0
- package/build/{v2/chunks/cad-VY42CMP4.js → chunks/cad-QGVO6UGR.js} +1 -1
- package/build/chunks/chunk-6AW5U52H.js +1 -0
- package/build/{v2/chunks/chunk-R3HNTB5A.js → chunks/chunk-CVGQTUJ5.js} +2 -2
- package/build/chunks/chunk-FUXP2W57.js +1 -0
- package/build/chunks/chunk-LFTKNL2V.js +1 -0
- package/build/{v2/chunks/chunk-ZMK3UZZE.js → chunks/chunk-T6PPRDOE.js} +1 -1
- package/build/chunks/chunk-V6KYGP62.js +1 -0
- package/build/{v2/chunks/export-7OP4ZGGJ.js → chunks/export-2CFMTPJ3.js} +3 -3
- package/build/{v2/chunks/export-cad-QPBT756V.js → chunks/export-cad-XOXIE726.js} +1 -1
- package/build/{v2/chunks/export-zip-EDCWH5PX.js → chunks/export-zip-I2ADLFJI.js} +1 -1
- package/build/chunks/measure-3LDALPCN.js +1 -0
- package/build/chunks/print-check-WWHTT5PW.js +1 -0
- package/build/{v2/chunks/scene-export-KQBS7VRJ.js → chunks/scene-export-FPPL466I.js} +1 -1
- package/build/chunks/scene-reader-WXTRELY3.js +1 -0
- package/build/{v2/node → node}/analysis-worker.js +13 -12
- package/build/{v2/node → node}/index.cjs +7 -7
- package/build/{v2/node → node}/index.js +6 -6
- package/build/stl_viewer.min.js +51 -0
- package/build/{v2/viewstl.cjs → viewstl.cjs} +1641 -272
- package/build/{v2/viewstl.d.cts → viewstl.d.cts} +98 -0
- package/build/{v2/viewstl.d.ts → viewstl.d.ts} +98 -0
- package/build/{v2/viewstl.js → viewstl.js} +1641 -272
- package/build/viewstl.min.js +51 -0
- package/build/viewstl.worker.js +1 -0
- package/docs/releases/2.0.0-rc.6.md +7 -0
- package/docs/v2-compatibility.md +5 -5
- package/docs/v2-usage.md +152 -21
- package/docs/v2-verification.md +169 -0
- package/legacy/README.md +14 -8
- package/package.json +18 -35
- package/build/v2/README.md +0 -15
- package/build/v2/chunks/archive-VGS4J4Z7.js +0 -1
- package/build/v2/chunks/chunk-JH3H3JWA.js +0 -1
- package/build/v2/chunks/chunk-U33KANV7.js +0 -1
- package/build/v2/chunks/print-check-2PU7CSL3.js +0 -1
- package/build/v2/chunks/scene-reader-APUJOPUR.js +0 -1
- package/build/v2/stl_viewer.min.js +0 -51
- package/build/v2/viewstl.min.js +0 -51
- package/build/v2/viewstl.worker.js +0 -1
- /package/build/{v2/THIRD-PARTY-NOTICES.txt → THIRD-PARTY-NOTICES.txt} +0 -0
- /package/build/{v2/cad → cad}/occt-import-js.js +0 -0
- /package/build/{v2/cad → cad}/occt-import-js.source.txt +0 -0
- /package/build/{v2/cad → cad}/occt-import-js.wasm +0 -0
- /package/build/{v2/cad → cad}/prepare-cad.source.txt +0 -0
- /package/build/{v2/chunks/chunk-JS56KC3I.js → chunks/chunk-W5KVLGVR.js} +0 -0
- /package/build/{v2/chunks → chunks}/chunk-ZSV4PTIA.js +0 -0
- /package/build/{v2/node → node}/index.d.cts +0 -0
- /package/build/{v2/node → node}/index.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,194 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
> This is the maintained `@omrips/viewstl` package. The shorter `npm install viewstl` installs the same plugin. Existing `@omrips/viewstl` and `@omrips/viewstl/node` imports remain supported.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# Viewstl
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Javascript STL/OBJ/3MF/STEP/IGES 3D files Viewer
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**ViewSTL v2.00 — release candidate 2.0.0-rc.6.** A new native WebGL 2 implementation; no THREE.js runtime required. Reads local files on the user's device, with resizing, units, duplication, camera bookmarks, model exports, animation, VSB/VSJ scene saving and mesh checks.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
The new plugin is in `src/` and `build/`. Previous versions remain available in [legacy/](https://github.com/omrips/viewstl/tree/main/legacy), on the unchanged [master branch](https://github.com/omrips/viewstl/tree/master), and through their existing tags. v2 has [documented compatibility differences](docs/v2-usage.md#existing-api-and-intentional-differences).
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Usage:
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Paste these three lines into your page's `<body>`:
|
|
13
|
+
Download the [v2 plugin ZIP](https://github.com/omrips/viewstl/releases/download/v2.0.0-rc.6/viewstl-2.0.0-rc.6.zip) and copy its complete `build/` folder to your website. Add to your page:
|
|
16
14
|
|
|
17
15
|
```html
|
|
18
|
-
<div id="
|
|
19
|
-
<script src="/viewstl
|
|
20
|
-
<script>new StlViewer(document.getElementById(
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
Replace `model.stl` with your model's path and open the page over HTTP(S). That's it. You can also drag local files onto the viewer.
|
|
24
|
-
|
|
25
|
-
## Server-only example (Node.js)
|
|
26
|
-
|
|
27
|
-
Requires Node.js 20+. Install `npm install @omrips/viewstl@2.0.0-rc.4`, then save this as `analyze.mjs` beside your `part.stl` file:
|
|
28
|
-
|
|
29
|
-
```js
|
|
30
|
-
import { analyzeFile } from '@omrips/viewstl/node';
|
|
31
|
-
const report = await analyzeFile('part.stl', { units: 'mm' });
|
|
32
|
-
console.log(JSON.stringify(report, null, 2));
|
|
16
|
+
<div id="stl_cont" style="height:500px"></div>
|
|
17
|
+
<script src="build/viewstl.min.js"></script>
|
|
18
|
+
<script>var stl_viewer=new StlViewer(document.getElementById("stl_cont"), {models:[{id:0, filename:"mystl.stl"}]});</script>
|
|
33
19
|
```
|
|
34
20
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
STL, OBJ, 3MF, STEP and IGES are supported. For STL/OBJ, set `units` to your model's actual scale; 3MF/STEP/IGES use their file units. See [server API and limits](https://unpkg.com/@omrips/viewstl@2.0.0-rc.4/docs/v2-usage.md#nodejs-model-analysis) for buffers, batch processing and cancellation.
|
|
38
|
-
|
|
39
|
-
## What v2 can do
|
|
40
|
-
|
|
41
|
-
- **Open models:** binary and ASCII STL, OBJ, 3MF, STEP/STP and IGES/IGS.
|
|
42
|
-
- **Work with scenes:** multiple models, selection, independent position, rotation and scale, colors, camera controls and an infinite grid.
|
|
43
|
-
- **Inspect geometry:** solid, smooth, edges, wireframe, X-ray and face-orientation views, section cuts, dimensions and mesh information.
|
|
44
|
-
- **Save locally:** PNG images and mesh exports in binary STL, OBJ, 3MF, STEP and IGES.
|
|
45
|
-
- **Save and restore scenes:** VSB packages the scene and meshes; VSJ stores scene settings and references to model files.
|
|
46
|
-
- **Check meshes for 3D printing:** topology checks, detailed intersection and volume analysis, issue highlights and optional FDM estimates.
|
|
47
|
-
- **Analyze on a server:** a Node.js API reuses the same parsers and mesh checks in background workers, with bounded concurrency and cancellation.
|
|
48
|
-
- **Embed in your own interface:** use the `StlViewer` API, or bind your own markup to the optional `mountViewstlApp` controller.
|
|
49
|
-
|
|
50
|
-
## Usage
|
|
51
|
-
|
|
52
|
-
Choose a script tag, a browser ES module, or an npm package with your bundler. Each option uses the same viewer API and processes local files on the user's device.
|
|
53
|
-
|
|
54
|
-
### Script tag
|
|
55
|
-
|
|
56
|
-
Copy the **complete `build/v2/` directory** to your web server, for example as `/viewstl-v2/`. Keep its worker, `chunks/`, `cad/` and notice files together with the viewer.
|
|
57
|
-
|
|
58
|
-
```html
|
|
59
|
-
<input id="model-file" type="file" accept=".stl,.obj,.3mf,.step,.stp,.iges,.igs">
|
|
60
|
-
<div id="viewer" style="width:100%;height:500px"></div>
|
|
61
|
-
|
|
62
|
-
<script src="/viewstl-v2/viewstl.min.js"></script>
|
|
63
|
-
<script>
|
|
64
|
-
const viewer = new StlViewer(document.getElementById('viewer'), {
|
|
65
|
-
load_error_callback: message => console.error(message)
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
document.getElementById('model-file').addEventListener('change', event => {
|
|
69
|
-
const file = event.target.files[0];
|
|
70
|
-
if (file) viewer.add_model({ local_file: file });
|
|
71
|
-
});
|
|
72
|
-
</script>
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
Each file selected in this example is added to the viewer. Files are read on the user's device. Serve the page over HTTP(S), and give the viewer container a nonzero height.
|
|
76
|
-
|
|
77
|
-
### ES modules
|
|
78
|
-
|
|
79
|
-
With the same `build/v2/` directory hosted on your server, use a module script:
|
|
80
|
-
|
|
81
|
-
```html
|
|
82
|
-
<div id="viewer" style="width:100%;height:500px"></div>
|
|
83
|
-
<script type="module">
|
|
84
|
-
import StlViewer from '/viewstl-v2/viewstl.js';
|
|
85
|
-
|
|
86
|
-
const viewer = new StlViewer(document.getElementById('viewer'), {
|
|
87
|
-
models: [{ id: 0, filename: '/models/part.stl' }]
|
|
88
|
-
});
|
|
89
|
-
</script>
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
Replace `/models/part.stl` with a model URL you serve. To open a local file instead, call `viewer.add_model({ local_file: file })` with a browser `File`, as in the script-tag example.
|
|
93
|
-
|
|
94
|
-
### npm and bundlers
|
|
95
|
-
|
|
96
|
-
> **Release candidate:** `2.0.0-rc.4` includes the Node.js model-analysis API and a runnable server-only example. Pin the version below for a repeatable installation.
|
|
21
|
+
Replace `mystl.stl` with your model and serve the page over HTTP(S). Keep the worker, `chunks/` and `cad/` folders alongside the viewer. Archive/CAD dependencies are included and load only when needed; v2 does not require a separate JSZip setup.
|
|
97
22
|
|
|
98
|
-
|
|
23
|
+
## npm / Node.js:
|
|
99
24
|
|
|
100
25
|
```sh
|
|
101
|
-
npm install
|
|
26
|
+
npm install viewstl
|
|
102
27
|
```
|
|
103
28
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
Add a container to your page:
|
|
107
|
-
|
|
108
|
-
```html
|
|
109
|
-
<div id="viewer" style="width:100%;height:500px"></div>
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
Then import the viewer in your application's browser entry point, after the container exists:
|
|
29
|
+
Browser apps can import `StlViewer` from `viewstl`; see [worker setup](https://github.com/omrips/viewstl/blob/main/docs/v2-usage.md#es-modules-and-npm). Server-only analysis requires Node.js 20+:
|
|
113
30
|
|
|
114
31
|
```js
|
|
115
|
-
import
|
|
116
|
-
|
|
117
|
-
const viewer = new StlViewer(document.getElementById('viewer'), {
|
|
118
|
-
worker_url: '/viewstl-v2/viewstl.worker.js',
|
|
119
|
-
models: [{ id: 0, filename: '/models/part.stl' }],
|
|
120
|
-
load_error_callback: message => console.error(message)
|
|
121
|
-
});
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
Set `worker_url` to the URL where your application serves the copied worker, and replace `/models/part.stl` with your model URL. The bundler handles the viewer import; the static directory supplies its worker and optional parser assets. Creating a viewer requires a browser DOM and WebGL 2.
|
|
125
|
-
|
|
126
|
-
The distribution includes TypeScript declarations and a CommonJS entry point. The static-assets setup above is verified with Vite 8.3.4 and Webpack 5.112.0. See [usage and packaging](https://unpkg.com/@omrips/viewstl@2.0.0-rc.4/docs/v2-usage.md) for worker factories, callbacks and more examples.
|
|
127
|
-
|
|
128
|
-
## Formats and saving
|
|
129
|
-
|
|
130
|
-
| Format | Open | Save |
|
|
131
|
-
| --- | --- | --- |
|
|
132
|
-
| STL | Binary and ASCII, including supported color variants | Binary STL |
|
|
133
|
-
| OBJ | Geometry | Geometry; optional colors through an MTL companion |
|
|
134
|
-
| 3MF | Supported mesh, component, unit and color data | Meshes and colors |
|
|
135
|
-
| STEP / STP | CAD surfaces tessellated for viewing | Triangle surfaces |
|
|
136
|
-
| IGES / IGS | CAD surfaces tessellated for viewing | Triangle surfaces |
|
|
137
|
-
| VSB | Packaged ViewSTL scene | Scene settings and meshes in one archive |
|
|
138
|
-
| VSJ | ViewSTL scene with model references | Scene settings and model references |
|
|
139
|
-
| PNG | — | Image of the current view |
|
|
140
|
-
|
|
141
|
-
STL, OBJ, 3MF, STEP and IGES export model geometry. **VSB and VSJ save the scene**, including its models, transforms and viewing settings. VSJ requires access to its referenced model files; VSB carries its mesh data inside the archive.
|
|
142
|
-
|
|
143
|
-
STEP/IGES exports describe the loaded triangle mesh. They do not reconstruct original CAD solids, curves, feature history or assemblies. OBJ import does not load external materials or textures, and 3MF support does not cover every extension. See the [format and export details](https://unpkg.com/@omrips/viewstl@2.0.0-rc.4/docs/v2-usage.md#rendering-and-file-processing).
|
|
144
|
-
|
|
145
|
-
## Local files and URL imports
|
|
146
|
-
|
|
147
|
-
In the browser, local file contents are processed on the user's device. Rendering, mesh checks, model exports and scene saving do not require an upload or a conversion service. Archive and CAD support load additional assets only when needed.
|
|
148
|
-
|
|
149
|
-
The optional Node.js API processes files on the machine running Node. If your application accepts uploads for server analysis, those files leave the user's device. The package itself provides no upload endpoint and does not send model data anywhere.
|
|
150
|
-
|
|
151
|
-
Direct URL imports require the remote server to allow browser access through CORS. A host application can configure its own streaming relay for other public URLs. **The relay is a separate server service**, not part of the plugin's JavaScript bundle. The preview website uses such a relay; URL imports pass through that server. See [URL import configuration](https://unpkg.com/@omrips/viewstl@2.0.0-rc.4/docs/v2-usage.md#optional-streaming-url-imports).
|
|
152
|
-
|
|
153
|
-
## Existing users and previous versions
|
|
154
|
-
|
|
155
|
-
**The legacy plugin remains available in the GitHub repository.** v2 has separate source and build directories, so switching to it is an explicit choice. The npm package contains the v2 distribution; it does not replace legacy download paths.
|
|
156
|
-
|
|
157
|
-
| | Legacy v1 | New v2 |
|
|
158
|
-
| --- | --- | --- |
|
|
159
|
-
| Source | Existing files in `src/` | `src/v2/` |
|
|
160
|
-
| Browser script | `build/stl_viewer.min.js` | `build/v2/viewstl.min.js` |
|
|
161
|
-
| Renderer | Three.js | Native WebGL 2 |
|
|
162
|
-
| Documentation | [viewstl.com/plugin](https://www.viewstl.com/plugin/) | [Package usage and API notes](https://unpkg.com/@omrips/viewstl@2.0.0-rc.4/docs/v2-usage.md) |
|
|
163
|
-
|
|
164
|
-
The familiar `StlViewer` constructor and many public methods are retained. Integrations that access Three.js camera, scene, renderer or model internals need migration. v2 requires WebGL 2 and does not include the legacy WebGL 1 or Canvas fallback. See [API differences and migration notes](https://unpkg.com/@omrips/viewstl@2.0.0-rc.4/docs/v2-usage.md#existing-api-and-intentional-differences).
|
|
165
|
-
|
|
166
|
-
Existing tags and release history are retained. The [legacy archive notes](https://unpkg.com/@omrips/viewstl@2.0.0-rc.4/legacy/README.md) also describe the separate local v1.14 snapshot and its provenance.
|
|
167
|
-
|
|
168
|
-
The documentation link remains **https://www.viewstl.com/plugin/**. It currently documents the legacy plugin; v2 guidance is included in this package while the website documentation is prepared.
|
|
169
|
-
|
|
170
|
-
## Requirements and current limits
|
|
171
|
-
|
|
172
|
-
- A browser with WebGL 2 and module-worker support; WebAssembly is required for STEP/IGES import.
|
|
173
|
-
- Model capacity depends on geometry complexity and available browser/GPU memory. Configured limits reject files that exceed the budget.
|
|
174
|
-
- Print checks describe the loaded mesh. FDM results are estimates, and checks do not guarantee a successful print. Models are checked separately; assembly overlaps are not evaluated.
|
|
175
|
-
- The preview has automated and desktop Chromium/Edge coverage. Firefox, Safari and physical mobile-device validation remain pending. See [verification and known limits](https://unpkg.com/@omrips/viewstl@2.0.0-rc.4/docs/v2-verification.md).
|
|
176
|
-
|
|
177
|
-
## Development
|
|
178
|
-
|
|
179
|
-
For contributors working in the source checkout, use Node.js 20 or newer and pnpm. The npm package contains the built viewer and documentation:
|
|
180
|
-
|
|
181
|
-
```sh
|
|
182
|
-
pnpm install --frozen-lockfile
|
|
183
|
-
pnpm build
|
|
184
|
-
pnpm test
|
|
185
|
-
pnpm check:types
|
|
186
|
-
pnpm check:legacy
|
|
187
|
-
pnpm start
|
|
32
|
+
import { analyzeFile } from 'viewstl/node';
|
|
33
|
+
console.log(await analyzeFile('part.stl', { units: 'mm' }));
|
|
188
34
|
```
|
|
189
35
|
|
|
190
|
-
|
|
36
|
+
No version suffix is needed. `npm install @omrips/viewstl` also installs the current release; existing scoped imports remain supported. Both names contain the same plugin, including animation and VSB/VSJ scene persistence.
|
|
191
37
|
|
|
192
|
-
|
|
38
|
+
More at [viewstl.com/plugin](https://www.viewstl.com/plugin/) (legacy documentation). For v2, see [usage and API notes](docs/v2-usage.md), [release notes](docs/releases/2.0.0-rc.6.md) and [verification](docs/v2-verification.md).
|
|
193
39
|
|
|
194
|
-
|
|
40
|
+
The [original README and usage examples](https://github.com/omrips/viewstl/blob/main/legacy/v1/README.md) are preserved with the legacy plugin. ViewSTL uses the [MIT license](LICENSE); optional dependencies retain their [third-party notices](THIRD-PARTY-NOTICES.txt).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d}from"./chunk-CVGQTUJ5.js";import"./chunk-ZSV4PTIA.js";import"./chunk-FUXP2W57.js";import"./chunk-W5KVLGVR.js";import"./chunk-6AW5U52H.js";export{d as parse3MF,a as safePath,b as unzipChecked,c as zipScene};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as A,c as E}from"./chunk-
|
|
1
|
+
import{a as A,c as E}from"./chunk-FUXP2W57.js";import{a as w}from"./chunk-W5KVLGVR.js";import"./chunk-6AW5U52H.js";var u=128*1024**2;function D(t){return u+t*40}async function x(t){let{default:s}=await import(new URL("../cad/occt-import-js.js",import.meta.url).href);return s({...t,locateFile:()=>new URL("../cad/occt-import-js.wasm",import.meta.url).href})}function C(t,s=A,c=0){if(!t?.success||!Array.isArray(t.meshes)||!t.meshes.length)throw new Error("No supported surfaces were found in this CAD file. Export a self-contained STEP or IGES solid/surface model.");let n=0,m=0,f=!1;for(let r of t.meshes){let a=r.attributes?.position?.array,o=r.index?.array;if(!a?.length||a.length%3||!o||o.length%3)throw new Error("Invalid CAD mesh");if(n+=o.length/3,!Number.isSafeInteger(n)||n>s.max_triangles)throw new Error("Triangle limit exceeded");m+=(a.length+o.length+(r.attributes.normal?.array?.length||0))*16,f||=!!r.color||!!r.brep_faces?.some(e=>e.color)}if(!n)throw new Error("This CAD file contains no viewable surfaces.");w(s,c+m+n*224,"CAD model");let h=new Float32Array(n*9),l=f?new Float32Array(h.length):null,d=[144/255,144/255,144/255],i=0;function y(r,a,o){if(!r||r.length!==3||r.some(e=>!Number.isFinite(e)||e<0||e>1))throw new Error("Invalid CAD color");for(let e=a;e<o;e+=3)l.set(r,e)}for(let r of t.meshes){let a=r.attributes.position.array,o=r.index.array;for(let e=0;e<o.length;e++){let g=o[e];if(!Number.isSafeInteger(g)||g<0||g*3+2>=a.length)throw new Error("Invalid CAD triangle index");for(let p=0;p<3;p++)h[i+e*3+p]=a[g*3+p]}if(l){y(r.color||d,i,i+o.length*3);for(let e of r.brep_faces||[])if(e.color){if(!Number.isSafeInteger(e.first)||!Number.isSafeInteger(e.last)||e.first<0||e.last<e.first||e.last>=o.length/3)throw new Error("Invalid CAD face range");y(e.color,i+e.first*9,i+(e.last+1)*9)}}i+=o.length*3}return E(h,l,s)}async function L(t,s,c=A,n=()=>{},m=x){let f=/\.(step|stp|iges|igs)(?:[?#]|$)/i.exec(s)?.[1].toLowerCase();if(!f)throw new Error("Unsupported CAD format");if(!(t instanceof ArrayBuffer)||!t.byteLength||t.byteLength>c.max_file_bytes)throw new Error("Invalid or oversized CAD file");w(c,D(t.byteLength),"CAD file");let h=Math.floor(Math.min(512*1024**2,((c.max_memory_bytes??Number.MAX_SAFE_INTEGER)-u-t.byteLength*3)/2)/65536)*65536;if(h<32*1024**2)throw new Error("CAD import exceeds the device safety budget.");n("loading-cad");let l;try{l=await m({viewstlMaxHeapBytes:h,print(){},printErr(){}})}catch{throw new Error("The CAD reader could not start. Check the connection and that WebAssembly is allowed, then try again.")}n("parsing-cad");let d=/^(step|stp)$/.test(f)?"step":"iges",i;try{i=l[d==="step"?"ReadStepFile":"ReadIgesFile"](new Uint8Array(t),{linearUnit:"millimeter",linearDeflectionType:"bounding_box_ratio",linearDeflection:.001,angularDeflection:.5})}catch{throw new Error("This CAD file could not be processed within the reader limits. Try a smaller or simplified STEP/IGES export.")}return{...C(i,c,u+t.byteLength*3+l.HEAPU8.byteLength),format:d,units:"mm"}}export{u as CAD_OVERHEAD,C as cadGeometry,D as cadMemory,L as parseCAD};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var l=Object.create;var i=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var w=(t,r)=>()=>{try{return r||t((r={exports:{}}).exports,r),r.exports}catch(n){throw r=0,n}};var M=(t,r,n,e)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of h(r))!x.call(t,o)&&o!==n&&i(t,o,{get:()=>r[o],enumerable:!(e=u(r,o))||e.enumerable});return t};var F=(t,r,n)=>(n=t!=null?l(y(t)):{},M(r||!t||!t.__esModule?i(n,"default",{value:t,enumerable:!0}):n,t));var d=(t,r)=>t.map((n,e)=>n-r[e]),p=(t,r)=>t.map(n=>n*r);var _=(t,r)=>[t[1]*r[2]-t[2]*r[1],t[2]*r[0]-t[0]*r[2],t[0]*r[1]-t[1]*r[0]],g=t=>p(t,1/(Math.hypot(...t)||1)),b=()=>new Float64Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);function v(t,r){let n=new Float64Array(16);for(let e=0;e<4;e++)for(let o=0;o<4;o++)for(let a=0;a<4;a++)n[e*4+o]+=t[a*4+o]*r[e*4+a];return n}function z(t,r,n=1){let e=t[3]*r[0]+t[7]*r[1]+t[11]*r[2]+t[15]*n;return[0,1,2].map(o=>(t[o]*r[0]+t[4+o]*r[1]+t[8+o]*r[2]+t[12+o]*n)/(n&&e?e:1))}function A(t,r,n){let e=Math.cos(t),o=Math.sin(t),a=Math.cos(r),s=Math.sin(r),f=Math.cos(n),c=Math.sin(n);return new Float64Array([a*f,e*c+o*f*s,o*c-e*f*s,0,-a*c,e*f-o*c*s,o*f+e*c*s,0,s,-o*a,e*a,0,0,0,0,1])}function j(t){let r=A(t.rotationx,t.rotationy,t.rotationz),n=t.scaleVector;for(let o=0;o<3;o++)for(let a=0;a<3;a++)r[o*4+a]*=n[o];let e=t.center||[0,0,0];for(let o=0;o<3;o++)r[12+o]=[t.x,t.y,t.z][o]-r[o]*e[0]-r[4+o]*e[1]-r[8+o]*e[2];return r}export{w as a,F as b,d as c,_ as d,g as e,b as f,v as g,z as h,j as i};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Mt,d as It}from"./chunk-ZSV4PTIA.js";import{a as Y,b as Rt,c as vt}from"./chunk-
|
|
1
|
+
import{a as Mt,d as It}from"./chunk-ZSV4PTIA.js";import{a as Y,b as Rt,c as vt}from"./chunk-FUXP2W57.js";import{a as G}from"./chunk-W5KVLGVR.js";import{a as K,b as me,f as wt,g as bt,h as St}from"./chunk-6AW5U52H.js";var yt=K(f=>{"use strict";Object.defineProperty(f,"__esModule",{value:!0});f.CHAR=`
|
|
2
2
|
\r -\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}`;f.S=` \r
|
|
3
3
|
`;f.NAME_START_CHAR=":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";f.NAME_CHAR="-"+f.NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";f.CHAR_RE=new RegExp("^["+f.CHAR+"]$","u");f.S_RE=new RegExp("^["+f.S+"]+$","u");f.NAME_START_CHAR_RE=new RegExp("^["+f.NAME_START_CHAR+"]$","u");f.NAME_CHAR_RE=new RegExp("^["+f.NAME_CHAR+"]$","u");f.NAME_RE=new RegExp("^["+f.NAME_START_CHAR+"]["+f.NAME_CHAR+"]*$","u");f.NMTOKEN_RE=new RegExp("^["+f.NAME_CHAR+"]+$","u");var at=9,ot=10,ht=13,lt=32;f.S_LIST=[lt,ot,ht,at];function pe(e){return e>=lt&&e<=55295||e===ot||e===ht||e===at||e>=57344&&e<=65533||e>=65536&&e<=1114111}f.isChar=pe;function ge(e){return e===lt||e===ot||e===ht||e===at}f.isS=ge;function Lt(e){return e>=65&&e<=90||e>=97&&e<=122||e===58||e===95||e===8204||e===8205||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}f.isNameStartChar=Lt;function Ee(e){return Lt(e)||e>=48&&e<=57||e===45||e===46||e===183||e>=768&&e<=879||e>=8255&&e<=8256}f.isNameChar=Ee});var $t=K(c=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});c.CHAR="-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}";c.RESTRICTED_CHAR="-\b\v\f-\x7F-\x84\x86-\x9F";c.S=` \r
|
|
4
4
|
`;c.NAME_START_CHAR=":A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";c.NAME_CHAR="-"+c.NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";c.CHAR_RE=new RegExp("^["+c.CHAR+"]$","u");c.RESTRICTED_CHAR_RE=new RegExp("^["+c.RESTRICTED_CHAR+"]$","u");c.S_RE=new RegExp("^["+c.S+"]+$","u");c.NAME_START_CHAR_RE=new RegExp("^["+c.NAME_START_CHAR+"]$","u");c.NAME_CHAR_RE=new RegExp("^["+c.NAME_CHAR+"]$","u");c.NAME_RE=new RegExp("^["+c.NAME_START_CHAR+"]["+c.NAME_CHAR+"]*$","u");c.NMTOKEN_RE=new RegExp("^["+c.NAME_CHAR+"]+$","u");var Pt=9,kt=10,Ot=13,Ht=32;c.S_LIST=[Ht,kt,Ot,Pt];function Ce(e){return e>=1&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111}c.isChar=Ce;function _e(e){return e>=1&&e<=8||e===11||e===12||e>=14&&e<=31||e>=127&&e<=132||e>=134&&e<=159}c.isRestrictedChar=_e;function Fe(e){return e===9||e===10||e===13||e>31&&e<127||e===133||e>159&&e<=55295||e>=57344&&e<=65533||e>=65536&&e<=1114111}c.isCharAndNotRestricted=Fe;function De(e){return e===Ht||e===kt||e===Ot||e===Pt}c.isS=De;function Bt(e){return e>=65&&e<=90||e>=97&&e<=122||e===58||e===95||e===8204||e===8205||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}c.isNameStartChar=Bt;function Ae(e){return Bt(e)||e>=48&&e<=57||e===45||e===46||e===183||e>=768&&e<=879||e>=8255&&e<=8256}c.isNameChar=Ae});var Xt=K(F=>{"use strict";Object.defineProperty(F,"__esModule",{value:!0});F.NC_NAME_START_CHAR="A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}";F.NC_NAME_CHAR="-"+F.NC_NAME_START_CHAR+".0-9\xB7\u0300-\u036F\u203F-\u2040";F.NC_NAME_START_CHAR_RE=new RegExp("^["+F.NC_NAME_START_CHAR+"]$","u");F.NC_NAME_CHAR_RE=new RegExp("^["+F.NC_NAME_CHAR+"]$","u");F.NC_NAME_RE=new RegExp("^["+F.NC_NAME_START_CHAR+"]["+F.NC_NAME_CHAR+"]*$","u");function Ut(e){return e>=65&&e<=90||e===95||e>=97&&e<=122||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039}F.isNCNameStartChar=Ut;function Te(e){return Ut(e)||e===45||e===46||e>=48&&e<=57||e===183||e>=768&&e<=879||e>=8255&&e<=8256}F.isNCNameChar=Te});var he=K(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.SaxesParser=V.EVENTS=void 0;var q=yt(),Ne=$t(),At=Xt(),D=q.isS,we=q.isChar,z=q.isNameStartChar,Wt=q.isNameChar,ie=q.S_LIST,be=q.NAME_RE,Se=Ne.isChar,Re=At.isNCNameStartChar,ve=At.isNCNameChar,Me=At.NC_NAME_RE,rt="http://www.w3.org/XML/1998/namespace",j="http://www.w3.org/2000/xmlns/",Ie={__proto__:null,xml:rt,xmlns:j},Le={__proto__:null,amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},x=-1,R=-2,jt=0,ye=1,ct=2,Pe=3,U=4,ke=5,Oe=6,He=7,ut=8,Be=9,$e=10,Ue=11,Xe=12,_=13,J=14,dt=15,We=16,ft=17,je=18,Ve=19,xt=20,qe=21,Ge=22,ze=23,Vt=24,mt=25,tt=26,qt=27,Qe=28,Ze=29,Gt=30,Ke=31,Ye=32,B=33,Je=34,pt=35,Q=36,gt=37,ts=38,zt=39,Qt=40,es=41,Zt=42,ss=43,is=44,Et=9,N=10,Ct=13,Kt=32,Yt=33,re=34,Z=38,ne=39,et=45,st=47,rs=59,k=60,X=61,p=62,E=63,ae=91,W=93,Jt=133,te=8232,it=e=>e===re||e===ne,oe=[re,ne],ns=[...oe,ae,p],as=[...oe,k,W],os=[X,E,...ie],hs=[...ie,p,Z,k];function Ft(e,t,s){switch(t){case"xml":s!==rt&&e.fail(`xml prefix must be bound to ${rt}.`);break;case"xmlns":s!==j&&e.fail(`xmlns prefix must be bound to ${j}.`);break;default:}switch(s){case j:e.fail(t===""?`the default namespace may not be set to ${s}.`:`may not assign a prefix (even "xmlns") to the URI ${j}.`);break;case rt:switch(t){case"xml":break;case"":e.fail(`the default namespace may not be set to ${s}.`);break;default:e.fail("may not assign the xml namespace to another prefix.")}break;default:}}function ls(e,t){for(let s of Object.keys(t))Ft(e,s,t[s])}var cs=e=>Me.test(e),us=e=>be.test(e),$=0,ee=1,_t=2;V.EVENTS=["xmldecl","text","processinginstruction","doctype","comment","opentagstart","attribute","opentag","closetag","cdata","error","end","ready"];var se={xmldecl:"xmldeclHandler",text:"textHandler",processinginstruction:"piHandler",doctype:"doctypeHandler",comment:"commentHandler",opentagstart:"openTagStartHandler",attribute:"attributeHandler",opentag:"openTagHandler",closetag:"closeTagHandler",cdata:"cdataHandler",error:"errorHandler",end:"endHandler",ready:"readyHandler"},Dt=class{constructor(t){this.opt=t??{},this.fragmentOpt=!!this.opt.fragment;let s=this.xmlnsOpt=!!this.opt.xmlns;if(this.trackPosition=this.opt.position!==!1,this.fileName=this.opt.fileName,s){this.nameStartCheck=Re,this.nameCheck=ve,this.isName=cs,this.processAttribs=this.processAttribsNS,this.pushAttrib=this.pushAttribNS,this.ns=Object.assign({__proto__:null},Ie);let i=this.opt.additionalNamespaces;i!=null&&(ls(this,i),Object.assign(this.ns,i))}else this.nameStartCheck=z,this.nameCheck=Wt,this.isName=us,this.processAttribs=this.processAttribsPlain,this.pushAttrib=this.pushAttribPlain;this.stateTable=[this.sBegin,this.sBeginWhitespace,this.sDoctype,this.sDoctypeQuote,this.sDTD,this.sDTDQuoted,this.sDTDOpenWaka,this.sDTDOpenWakaBang,this.sDTDComment,this.sDTDCommentEnding,this.sDTDCommentEnded,this.sDTDPI,this.sDTDPIEnding,this.sText,this.sEntity,this.sOpenWaka,this.sOpenWakaBang,this.sComment,this.sCommentEnding,this.sCommentEnded,this.sCData,this.sCDataEnding,this.sCDataEnding2,this.sPIFirstChar,this.sPIRest,this.sPIBody,this.sPIEnding,this.sXMLDeclNameStart,this.sXMLDeclName,this.sXMLDeclEq,this.sXMLDeclValueStart,this.sXMLDeclValue,this.sXMLDeclSeparator,this.sXMLDeclEnding,this.sOpenTag,this.sOpenTagSlash,this.sAttrib,this.sAttribName,this.sAttribNameSawWhite,this.sAttribValue,this.sAttribValueQuoted,this.sAttribValueClosed,this.sAttribValueUnquoted,this.sCloseTag,this.sCloseTagSawWhite],this._init()}get closed(){return this._closed}_init(){var t;this.openWakaBang="",this.text="",this.name="",this.piTarget="",this.entity="",this.q=null,this.tags=[],this.tag=null,this.topNS=null,this.chunk="",this.chunkPosition=0,this.i=0,this.prevI=0,this.carriedFromPrevious=void 0,this.forbiddenState=$,this.attribList=[];let{fragmentOpt:s}=this;this.state=s?_:jt,this.reportedTextBeforeRoot=this.reportedTextAfterRoot=this.closedRoot=this.sawRoot=s,this.xmlDeclPossible=!s,this.xmlDeclExpects=["version"],this.entityReturnState=void 0;let{defaultXMLVersion:i}=this.opt;if(i===void 0){if(this.opt.forceXMLVersion===!0)throw new Error("forceXMLVersion set but defaultXMLVersion is not set");i="1.0"}this.setXMLVersion(i),this.positionAtNewLine=0,this.doctype=!1,this._closed=!1,this.xmlDecl={version:void 0,encoding:void 0,standalone:void 0},this.line=1,this.column=0,this.ENTITIES=Object.create(Le),(t=this.readyHandler)===null||t===void 0||t.call(this)}get position(){return this.chunkPosition+this.i}get columnIndex(){return this.position-this.positionAtNewLine}on(t,s){this[se[t]]=s}off(t){this[se[t]]=void 0}makeError(t){var s;let i=(s=this.fileName)!==null&&s!==void 0?s:"";return this.trackPosition&&(i.length>0&&(i+=":"),i+=`${this.line}:${this.column}`),i.length>0&&(i+=": "),new Error(i+t)}fail(t){let s=this.makeError(t),i=this.errorHandler;if(i===void 0)throw s;return i(s),this}write(t){if(this.closed)return this.fail("cannot write after close; assign an onready handler.");let s=!1;t===null?(s=!0,t=""):typeof t=="object"&&(t=t.toString()),this.carriedFromPrevious!==void 0&&(t=`${this.carriedFromPrevious}${t}`,this.carriedFromPrevious=void 0);let i=t.length,r=t.charCodeAt(i-1);!s&&(r===Ct||r>=55296&&r<=56319)&&(this.carriedFromPrevious=t[i-1],i--,t=t.slice(0,i));let{stateTable:n}=this;for(this.chunk=t,this.i=0;this.i<i;)n[this.state].call(this);return this.chunkPosition+=i,s?this.end():this}close(){return this.write(null)}getCode10(){let{chunk:t,i:s}=this;if(this.prevI=s,this.i=s+1,s>=t.length)return x;let i=t.charCodeAt(s);if(this.column++,i<55296){if(i>=Kt||i===Et)return i;switch(i){case N:return this.line++,this.column=0,this.positionAtNewLine=this.position,N;case Ct:return t.charCodeAt(s+1)===N&&(this.i=s+2),this.line++,this.column=0,this.positionAtNewLine=this.position,R;default:return this.fail("disallowed character."),i}}if(i>56319)return i>=57344&&i<=65533||this.fail("disallowed character."),i;let r=65536+(i-55296)*1024+(t.charCodeAt(s+1)-56320);return this.i=s+2,r>1114111&&this.fail("disallowed character."),r}getCode11(){let{chunk:t,i:s}=this;if(this.prevI=s,this.i=s+1,s>=t.length)return x;let i=t.charCodeAt(s);if(this.column++,i<55296){if(i>31&&i<127||i>159&&i!==te||i===Et)return i;switch(i){case N:return this.line++,this.column=0,this.positionAtNewLine=this.position,N;case Ct:{let n=t.charCodeAt(s+1);(n===N||n===Jt)&&(this.i=s+2)}case Jt:case te:return this.line++,this.column=0,this.positionAtNewLine=this.position,R;default:return this.fail("disallowed character."),i}}if(i>56319)return i>=57344&&i<=65533||this.fail("disallowed character."),i;let r=65536+(i-55296)*1024+(t.charCodeAt(s+1)-56320);return this.i=s+2,r>1114111&&this.fail("disallowed character."),r}getCodeNorm(){let t=this.getCode();return t===R?N:t}unget(){this.i=this.prevI,this.column--}captureTo(t){let{i:s}=this,{chunk:i}=this;for(;;){let r=this.getCode(),n=r===R,o=n?N:r;if(o===x||t.includes(o))return this.text+=i.slice(s,this.prevI),o;n&&(this.text+=`${i.slice(s,this.prevI)}
|
|
@@ -6,7 +6,7 @@ import{a as Mt,d as It}from"./chunk-ZSV4PTIA.js";import{a as Y,b as Rt,c as vt}f
|
|
|
6
6
|
`,s=this.i,r=N;break;case x:return this.text+=i.slice(s),!1;default:}if(r===t)return this.text+=i.slice(s,this.prevI),!0}}captureNameChars(){let{chunk:t,i:s}=this;for(;;){let i=this.getCode();if(i===x)return this.name+=t.slice(s),x;if(!Wt(i))return this.name+=t.slice(s,this.prevI),i===R?N:i}}skipSpaces(){for(;;){let t=this.getCodeNorm();if(t===x||!D(t))return t}}setXMLVersion(t){this.currentXMLVersion=t,t==="1.0"?(this.isChar=we,this.getCode=this.getCode10):(this.isChar=Se,this.getCode=this.getCode11)}sBegin(){this.chunk.charCodeAt(0)===65279&&(this.i++,this.column++),this.state=ye}sBeginWhitespace(){let t=this.i,s=this.skipSpaces();switch(this.prevI!==t&&(this.xmlDeclPossible=!1),s){case k:if(this.state=dt,this.text.length!==0)throw new Error("no-empty text at start");break;case x:break;default:this.unget(),this.state=_,this.xmlDeclPossible=!1}}sDoctype(){var t;let s=this.captureTo(ns);switch(s){case p:{(t=this.doctypeHandler)===null||t===void 0||t.call(this,this.text),this.text="",this.state=_,this.doctype=!0;break}case x:break;default:this.text+=String.fromCodePoint(s),s===ae?this.state=U:it(s)&&(this.state=Pe,this.q=s)}}sDoctypeQuote(){let t=this.q;this.captureToChar(t)&&(this.text+=String.fromCodePoint(t),this.q=null,this.state=ct)}sDTD(){let t=this.captureTo(as);t!==x&&(this.text+=String.fromCodePoint(t),t===W?this.state=ct:t===k?this.state=Oe:it(t)&&(this.state=ke,this.q=t))}sDTDQuoted(){let t=this.q;this.captureToChar(t)&&(this.text+=String.fromCodePoint(t),this.state=U,this.q=null)}sDTDOpenWaka(){let t=this.getCodeNorm();switch(this.text+=String.fromCodePoint(t),t){case Yt:this.state=He,this.openWakaBang="";break;case E:this.state=Ue;break;default:this.state=U}}sDTDOpenWakaBang(){let t=String.fromCodePoint(this.getCodeNorm()),s=this.openWakaBang+=t;this.text+=t,s!=="-"&&(this.state=s==="--"?ut:U,this.openWakaBang="")}sDTDComment(){this.captureToChar(et)&&(this.text+="-",this.state=Be)}sDTDCommentEnding(){let t=this.getCodeNorm();this.text+=String.fromCodePoint(t),this.state=t===et?$e:ut}sDTDCommentEnded(){let t=this.getCodeNorm();this.text+=String.fromCodePoint(t),t===p?this.state=U:(this.fail("malformed comment."),this.state=ut)}sDTDPI(){this.captureToChar(E)&&(this.text+="?",this.state=Xe)}sDTDPIEnding(){let t=this.getCodeNorm();this.text+=String.fromCodePoint(t),t===p&&(this.state=U)}sText(){this.tags.length!==0?this.handleTextInRoot():this.handleTextOutsideRoot()}sEntity(){let{i:t}=this,{chunk:s}=this;t:for(;;)switch(this.getCode()){case R:this.entity+=`${s.slice(t,this.prevI)}
|
|
7
7
|
`,t=this.i;break;case rs:{let{entityReturnState:i}=this,r=this.entity+s.slice(t,this.prevI);this.state=i;let n;r===""?(this.fail("empty entity name."),n="&;"):(n=this.parseEntity(r),this.entity=""),(i!==_||this.textHandler!==void 0)&&(this.text+=n);break t}case x:this.entity+=s.slice(t);break t;default:}}sOpenWaka(){let t=this.getCode();if(z(t))this.state=Je,this.unget(),this.xmlDeclPossible=!1;else switch(t){case st:this.state=ss,this.xmlDeclPossible=!1;break;case Yt:this.state=We,this.openWakaBang="",this.xmlDeclPossible=!1;break;case E:this.state=ze;break;default:this.fail("disallowed character in tag name"),this.state=_,this.xmlDeclPossible=!1}}sOpenWakaBang(){switch(this.openWakaBang+=String.fromCodePoint(this.getCodeNorm()),this.openWakaBang){case"[CDATA[":!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0),this.state=xt,this.openWakaBang="";break;case"--":this.state=ft,this.openWakaBang="";break;case"DOCTYPE":this.state=ct,(this.doctype||this.sawRoot)&&this.fail("inappropriately located doctype declaration."),this.openWakaBang="";break;default:this.openWakaBang.length>=7&&this.fail("incorrect syntax.")}}sComment(){this.captureToChar(et)&&(this.state=je)}sCommentEnding(){var t;let s=this.getCodeNorm();s===et?(this.state=Ve,(t=this.commentHandler)===null||t===void 0||t.call(this,this.text),this.text=""):(this.text+=`-${String.fromCodePoint(s)}`,this.state=ft)}sCommentEnded(){let t=this.getCodeNorm();t!==p?(this.fail("malformed comment."),this.text+=`--${String.fromCodePoint(t)}`,this.state=ft):this.state=_}sCData(){this.captureToChar(W)&&(this.state=qe)}sCDataEnding(){let t=this.getCodeNorm();t===W?this.state=Ge:(this.text+=`]${String.fromCodePoint(t)}`,this.state=xt)}sCDataEnding2(){var t;let s=this.getCodeNorm();switch(s){case p:{(t=this.cdataHandler)===null||t===void 0||t.call(this,this.text),this.text="",this.state=_;break}case W:this.text+="]";break;default:this.text+=`]]${String.fromCodePoint(s)}`,this.state=xt}}sPIFirstChar(){let t=this.getCodeNorm();this.nameStartCheck(t)?(this.piTarget+=String.fromCodePoint(t),this.state=Vt):t===E||D(t)?(this.fail("processing instruction without a target."),this.state=t===E?tt:mt):(this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(t),this.state=Vt)}sPIRest(){let{chunk:t,i:s}=this;for(;;){let i=this.getCodeNorm();if(i===x){this.piTarget+=t.slice(s);return}if(!this.nameCheck(i)){this.piTarget+=t.slice(s,this.prevI);let r=i===E;r||D(i)?this.piTarget==="xml"?(this.xmlDeclPossible||this.fail("an XML declaration must be at the start of the document."),this.state=r?B:qt):this.state=r?tt:mt:(this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(i));break}}}sPIBody(){if(this.text.length===0){let t=this.getCodeNorm();t===E?this.state=tt:D(t)||(this.text=String.fromCodePoint(t))}else this.captureToChar(E)&&(this.state=tt)}sPIEnding(){var t;let s=this.getCodeNorm();if(s===p){let{piTarget:i}=this;i.toLowerCase()==="xml"&&this.fail("the XML declaration must appear at the start of the document."),(t=this.piHandler)===null||t===void 0||t.call(this,{target:i,body:this.text}),this.piTarget=this.text="",this.state=_}else s===E?this.text+="?":(this.text+=`?${String.fromCodePoint(s)}`,this.state=mt);this.xmlDeclPossible=!1}sXMLDeclNameStart(){let t=this.skipSpaces();if(t===E){this.state=B;return}t!==x&&(this.state=Qe,this.name=String.fromCodePoint(t))}sXMLDeclName(){let t=this.captureTo(os);if(t===E){this.state=B,this.name+=this.text,this.text="",this.fail("XML declaration is incomplete.");return}if(D(t)||t===X){if(this.name+=this.text,this.text="",!this.xmlDeclExpects.includes(this.name))switch(this.name.length){case 0:this.fail("did not expect any more name/value pairs.");break;case 1:this.fail(`expected the name ${this.xmlDeclExpects[0]}.`);break;default:this.fail(`expected one of ${this.xmlDeclExpects.join(", ")}`)}this.state=t===X?Gt:Ze}}sXMLDeclEq(){let t=this.getCodeNorm();if(t===E){this.state=B,this.fail("XML declaration is incomplete.");return}D(t)||(t!==X&&this.fail("value required."),this.state=Gt)}sXMLDeclValueStart(){let t=this.getCodeNorm();if(t===E){this.state=B,this.fail("XML declaration is incomplete.");return}D(t)||(it(t)?this.q=t:(this.fail("value must be quoted."),this.q=Kt),this.state=Ke)}sXMLDeclValue(){let t=this.captureTo([this.q,E]);if(t===E){this.state=B,this.text="",this.fail("XML declaration is incomplete.");return}if(t===x)return;let s=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];let i=s;this.xmlDecl.version=i,/^1\.[0-9]+$/.test(i)?this.opt.forceXMLVersion||this.setXMLVersion(i):this.fail("version number must match /^1\\.[0-9]+$/.");break}case"encoding":/^[A-Za-z][A-Za-z0-9._-]*$/.test(s)||this.fail("encoding value must match /^[A-Za-z0-9][A-Za-z0-9._-]*$/."),this.xmlDeclExpects=["standalone"],this.xmlDecl.encoding=s;break;case"standalone":s!=="yes"&&s!=="no"&&this.fail('standalone value must match "yes" or "no".'),this.xmlDeclExpects=[],this.xmlDecl.standalone=s;break;default:}this.name="",this.state=Ye}sXMLDeclSeparator(){let t=this.getCodeNorm();if(t===E){this.state=B;return}D(t)||(this.fail("whitespace required."),this.unget()),this.state=qt}sXMLDeclEnding(){var t;this.getCodeNorm()===p?(this.piTarget!=="xml"?this.fail("processing instructions are not allowed before root."):this.name!=="version"&&this.xmlDeclExpects.includes("version")&&this.fail("XML declaration must contain a version."),(t=this.xmldeclHandler)===null||t===void 0||t.call(this,this.xmlDecl),this.name="",this.piTarget=this.text="",this.state=_):this.fail("The character ? is disallowed anywhere in XML declarations."),this.xmlDeclPossible=!1}sOpenTag(){var t;let s=this.captureNameChars();if(s===x)return;let i=this.tag={name:this.name,attributes:Object.create(null)};switch(this.name="",this.xmlnsOpt&&(this.topNS=i.ns=Object.create(null)),(t=this.openTagStartHandler)===null||t===void 0||t.call(this,i),this.sawRoot=!0,!this.fragmentOpt&&this.closedRoot&&this.fail("documents may contain only one root."),s){case p:this.openTag();break;case st:this.state=pt;break;default:D(s)||this.fail("disallowed character in tag name."),this.state=Q}}sOpenTagSlash(){this.getCode()===p?this.openSelfClosingTag():(this.fail("forward-slash in opening tag not followed by >."),this.state=Q)}sAttrib(){let t=this.skipSpaces();t!==x&&(z(t)?(this.unget(),this.state=gt):t===p?this.openTag():t===st?this.state=pt:this.fail("disallowed character in attribute name."))}sAttribName(){let t=this.captureNameChars();t===X?this.state=zt:D(t)?this.state=ts:t===p?(this.fail("attribute without value."),this.pushAttrib(this.name,this.name),this.name=this.text="",this.openTag()):t!==x&&this.fail("disallowed character in attribute name.")}sAttribNameSawWhite(){let t=this.skipSpaces();switch(t){case x:return;case X:this.state=zt;break;default:this.fail("attribute without value."),this.text="",this.name="",t===p?this.openTag():z(t)?(this.unget(),this.state=gt):(this.fail("disallowed character in attribute name."),this.state=Q)}}sAttribValue(){let t=this.getCodeNorm();it(t)?(this.q=t,this.state=Qt):D(t)||(this.fail("unquoted attribute value."),this.state=Zt,this.unget())}sAttribValueQuoted(){let{q:t,chunk:s}=this,{i}=this;for(;;)switch(this.getCode()){case t:this.pushAttrib(this.name,this.text+s.slice(i,this.prevI)),this.name=this.text="",this.q=null,this.state=es;return;case Z:this.text+=s.slice(i,this.prevI),this.state=J,this.entityReturnState=Qt;return;case N:case R:case Et:this.text+=`${s.slice(i,this.prevI)} `,i=this.i;break;case k:this.text+=s.slice(i,this.prevI),this.fail("disallowed character.");return;case x:this.text+=s.slice(i);return;default:}}sAttribValueClosed(){let t=this.getCodeNorm();D(t)?this.state=Q:t===p?this.openTag():t===st?this.state=pt:z(t)?(this.fail("no whitespace between attributes."),this.unget(),this.state=gt):this.fail("disallowed character in attribute name.")}sAttribValueUnquoted(){let t=this.captureTo(hs);switch(t){case Z:this.state=J,this.entityReturnState=Zt;break;case k:this.fail("disallowed character.");break;case x:break;default:this.text.includes("]]>")&&this.fail('the string "]]>" is disallowed in char data.'),this.pushAttrib(this.name,this.text),this.name=this.text="",t===p?this.openTag():this.state=Q}}sCloseTag(){let t=this.captureNameChars();t===p?this.closeTag():D(t)?this.state=is:t!==x&&this.fail("disallowed character in closing tag.")}sCloseTagSawWhite(){switch(this.skipSpaces()){case p:this.closeTag();break;case x:break;default:this.fail("disallowed character in closing tag.")}}handleTextInRoot(){let{i:t,forbiddenState:s}=this,{chunk:i,textHandler:r}=this;t:for(;;)switch(this.getCode()){case k:{if(this.state=dt,r!==void 0){let{text:n}=this,o=i.slice(t,this.prevI);n.length!==0?(r(n+o),this.text=""):o.length!==0&&r(o)}s=$;break t}case Z:this.state=J,this.entityReturnState=_,r!==void 0&&(this.text+=i.slice(t,this.prevI)),s=$;break t;case W:switch(s){case $:s=ee;break;case ee:s=_t;break;case _t:break;default:throw new Error("impossible state")}break;case p:s===_t&&this.fail('the string "]]>" is disallowed in char data.'),s=$;break;case R:r!==void 0&&(this.text+=`${i.slice(t,this.prevI)}
|
|
8
8
|
`),t=this.i,s=$;break;case x:r!==void 0&&(this.text+=i.slice(t));break t;default:s=$}this.forbiddenState=s}handleTextOutsideRoot(){let{i:t}=this,{chunk:s,textHandler:i}=this,r=!1;t:for(;;){let n=this.getCode();switch(n){case k:{if(this.state=dt,i!==void 0){let{text:o}=this,l=s.slice(t,this.prevI);o.length!==0?(i(o+l),this.text=""):l.length!==0&&i(l)}break t}case Z:this.state=J,this.entityReturnState=_,i!==void 0&&(this.text+=s.slice(t,this.prevI)),r=!0;break t;case R:i!==void 0&&(this.text+=`${s.slice(t,this.prevI)}
|
|
9
|
-
`),t=this.i;break;case x:i!==void 0&&(this.text+=s.slice(t));break t;default:D(n)||(r=!0)}}r&&(!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0))}pushAttribNS(t,s){var i;let{prefix:r,local:n}=this.qname(t),o={name:t,prefix:r,local:n,value:s};if(this.attribList.push(o),(i=this.attributeHandler)===null||i===void 0||i.call(this,o),r==="xmlns"){let l=s.trim();this.currentXMLVersion==="1.0"&&l===""&&this.fail("invalid attempt to undefine prefix in XML 1.0"),this.topNS[n]=l,Ft(this,n,l)}else if(t==="xmlns"){let l=s.trim();this.topNS[""]=l,Ft(this,"",l)}}pushAttribPlain(t,s){var i;let r={name:t,value:s};this.attribList.push(r),(i=this.attributeHandler)===null||i===void 0||i.call(this,r)}end(){var t,s;this.sawRoot||this.fail("document must contain a root element.");let{tags:i}=this;for(;i.length>0;){let n=i.pop();this.fail(`unclosed tag: ${n.name}`)}this.state!==jt&&this.state!==_&&this.fail("unexpected end.");let{text:r}=this;return r.length!==0&&((t=this.textHandler)===null||t===void 0||t.call(this,r),this.text=""),this._closed=!0,(s=this.endHandler)===null||s===void 0||s.call(this),this._init(),this}resolve(t){var s,i;let r=this.topNS[t];if(r!==void 0)return r;let{tags:n}=this;for(let o=n.length-1;o>=0;o--)if(r=n[o].ns[t],r!==void 0)return r;return r=this.ns[t],r!==void 0?r:(i=(s=this.opt).resolvePrefix)===null||i===void 0?void 0:i.call(s,t)}qname(t){let s=t.indexOf(":");if(s===-1)return{prefix:"",local:t};let i=t.slice(s+1),r=t.slice(0,s);return(r===""||i===""||i.includes(":"))&&this.fail(`malformed name: ${t}.`),{prefix:r,local:i}}processAttribsNS(){var t;let{attribList:s}=this,i=this.tag;{let{prefix:o,local:l}=this.qname(i.name);i.prefix=o,i.local=l;let m=i.uri=(t=this.resolve(o))!==null&&t!==void 0?t:"";o!==""&&(o==="xmlns"&&this.fail('tags may not have "xmlns" as prefix.'),m===""&&(this.fail(`unbound namespace prefix: ${JSON.stringify(o)}.`),i.uri=o))}if(s.length===0)return;let{attributes:r}=i,n=new Set;for(let o of s){let{name:l,prefix:m,local:w}=o,d,A;m===""?(d=l==="xmlns"?j:"",A=l):(d=this.resolve(m),d===void 0&&(this.fail(`unbound namespace prefix: ${JSON.stringify(m)}.`),d=m),A=`{${d}}${w}`),n.has(A)&&this.fail(`duplicate attribute: ${A}.`),n.add(A),o.uri=d,r[l]=o}this.attribList=[]}processAttribsPlain(){let{attribList:t}=this,s=this.tag.attributes;for(let{name:i,value:r}of t)s[i]!==void 0&&this.fail(`duplicate attribute: ${i}.`),s[i]=r;this.attribList=[]}openTag(){var t;this.processAttribs();let{tags:s}=this,i=this.tag;i.isSelfClosing=!1,(t=this.openTagHandler)===null||t===void 0||t.call(this,i),s.push(i),this.state=_,this.name=""}openSelfClosingTag(){var t,s,i;this.processAttribs();let{tags:r}=this,n=this.tag;n.isSelfClosing=!0,(t=this.openTagHandler)===null||t===void 0||t.call(this,n),(s=this.closeTagHandler)===null||s===void 0||s.call(this,n),(this.tag=(i=r[r.length-1])!==null&&i!==void 0?i:null)===null&&(this.closedRoot=!0),this.state=_,this.name=""}closeTag(){let{tags:t,name:s}=this;if(this.state=_,this.name="",s===""){this.fail("weird empty close tag."),this.text+="</>";return}let i=this.closeTagHandler,r=t.length;for(;r-- >0;){let n=this.tag=t.pop();if(this.topNS=n.ns,i?.(n),n.name===s)break;this.fail("unexpected close tag.")}r===0?this.closedRoot=!0:r<0&&(this.fail(`unmatched closing tag: ${s}.`),this.text+=`</${s}>`)}parseEntity(t){if(t[0]!=="#"){let i=this.ENTITIES[t];return i!==void 0?i:(this.fail(this.isName(t)?"undefined entity.":"disallowed character in entity name."),`&${t};`)}let s=NaN;return t[1]==="x"&&/^#x[0-9a-f]+$/i.test(t)?s=parseInt(t.slice(2),16):/^#[0-9]+$/.test(t)&&(s=parseInt(t.slice(1),10)),this.isChar(s)?String.fromCodePoint(s):(this.fail("malformed character entity."),`&${t};`)}};V.SaxesParser=Dt});var de=me(he(),1);var Tt=new TextDecoder("utf-8",{fatal:!0}),fs=Uint32Array.from({length:256},(e,t)=>{for(let s=0;s<8;s++)t=t&1?3988292384^t>>>1:t>>>1;return t>>>0});function xs(e,t=4294967295){for(let s of e)t=fs[(t^s)&255]^t>>>8;return t>>>0}function Nt(e){if(!e||e.includes("\\")||e.startsWith("/")||e.includes("\0")||e.split("/").some(t=>t===".."||t===".")||/^[a-z]+:/i.test(e))throw new Error("Unsafe archive path");return e}function ms(e,t=Y){if(e.byteLength>t.max_file_bytes)throw new Error("Archive size limit exceeded");let s=new Uint8Array(e),i=new DataView(e),r=-1;for(let u=s.length-22;u>=Math.max(0,s.length-65557);u--)if(i.getUint32(u,!0)===101010256&&u+22+i.getUint16(u+20,!0)===s.length){r=u;break}if(r<0)throw new Error("ZIP central directory not found");let n=i.getUint16(r+10,!0),o=i.getUint32(r+12,!0),l=i.getUint32(r+16,!0);if(i.getUint16(r+4,!0)||i.getUint16(r+6,!0)||n!==i.getUint16(r+8,!0))throw new Error("Multi-disk ZIP is unsupported");if(n===65535||l===4294967295||o===4294967295)throw new Error("ZIP64 is unsupported");if(n>t.max_archive_entries||l+o>r)throw new Error("Invalid or oversized ZIP directory");let m=[],w=new Set,d=l,A=0;for(let u=0;u<n;u++){if(d+46>l+o||i.getUint32(d,!0)!==33639248)throw new Error("Invalid ZIP directory entry");let C=i.getUint16(d+8,!0),P=i.getUint16(d+10,!0),v=i.getUint32(d+16,!0),M=i.getUint32(d+20,!0),I=i.getUint32(d+24,!0),T=i.getUint16(d+28,!0),L=i.getUint16(d+30,!0),y=i.getUint16(d+32,!0),H=i.getUint32(d+42,!0);if(d+46+T+L+y>l+o)throw new Error("Truncated ZIP directory");let a=Nt(Tt.decode(s.subarray(d+46,d+46+T)));if(w.has(a))throw new Error("Duplicate archive entry");if(w.add(a),C&1||![0,8].includes(P))throw new Error("Encrypted or unsupported ZIP compression");if(A+=I,G(t,67108864+e.byteLength+A*4,"expanded archive"),A>t.max_uncompressed_bytes)throw new Error("Archive expansion limit exceeded");m.push({name:a,method:P,checksum:v,compressed:M,original:I,local:H}),d+=46+T+L+y}if(d!==l+o)throw new Error("ZIP directory size mismatch");let O=new Map;for(let u of m){let C=u.local;if(C+30>l||i.getUint32(C,!0)!==67324752)throw new Error("Invalid ZIP local header");let P=i.getUint16(C+26,!0),v=i.getUint16(C+28,!0),M=C+30+P+v;if(M+u.compressed>l||i.getUint16(C+8,!0)!==u.method||i.getUint16(C+6,!0)&1||Tt.decode(s.subarray(C+30,C+30+P))!==u.name)throw new Error("ZIP header mismatch");let I=new Uint8Array(u.original),T=0,L=4294967295,y=!1,H=(a,h)=>{if(T+a.length>I.length)throw new Error("ZIP entry exceeds declared size");I.set(a,T),T+=a.length,L=xs(a,L),y=h};if(u.method===0)H(s.subarray(M,M+u.compressed),!0);else{let a=new Mt(H);for(let h=0;h<u.compressed;h+=1024)a.push(s.subarray(M+h,M+Math.min(h+1024,u.compressed)),h+1024>=u.compressed)}if(!y||T!==u.original||(L^4294967295)>>>0!==u.checksum)throw new Error("ZIP checksum or length mismatch");u.name.endsWith("/")||O.set(u.name,I)}return O}function Ts(e,t=Y){let s=Object.create(null);s["json_data.vsj"]=new TextEncoder().encode(JSON.stringify(e.vsj));let i=s["json_data.vsj"].length;for(let n of e.files){let o=Nt(`${n.id}.stl`),l=new Uint8Array(n.bin);i+=l.length,s[o]=l}if(Object.keys(s).length>t.max_archive_entries||i>t.max_uncompressed_bytes)throw new Error("Scene archive limit exceeded");let r=It(s,{level:6});if(r.length>t.max_file_bytes)throw new Error("Archive size limit exceeded");return r.buffer}function le(e,t,s=()=>{}){let i=new de.SaxesParser({xmlns:!0});i.on("doctype",()=>{throw new Error("XML document types are not supported")}),i.on("error",r=>{throw r}),i.on("opentag",r=>{let n=Object.create(null);for(let o of Object.values(r.attributes))n[o.local]=o.value;t(r.local,n,r)}),i.on("closetag",r=>s(r.local)),i.write(Tt.decode(e)).close()}function ce(e){if(!e)return wt();let t=e.trim().split(/\s+/).map(Number);if(t.length!==12||t.some(s=>!Number.isFinite(s)))throw new Error("Invalid 3MF transform");return new Float64Array([t[0],t[1],t[2],0,t[3],t[4],t[5],0,t[6],t[7],t[8],0,t[9],t[10],t[11],1])}function Ns(e,t=Y){let s=ms(e,t),i=67108864+e.byteLength+[...s.values()].reduce((a,h)=>a+h.byteLength*3,0),r=null;if(s.has("_rels/.rels")&&le(s.get("_rels/.rels"),(a,h)=>{if(a==="Relationship"&&h.Type?.endsWith("/3dmodel")){if(h.TargetMode==="External")throw new Error("External 3MF resources are unsupported");r=Nt(h.Target.replace(/^\//,""))}}),r??=[...s.keys()].find(a=>/^3d\/3dmodel\.model$/i.test(a)),!r||!s.has(r))throw new Error("3MF model part not found");let n=new Map,o=new Map,l=[],m=null,w=null,d=!1,A=1,O=0,u=0,C=!1;if(le(s.get(r),(a,h,b)=>{if(a==="model"){if(C)throw new Error("Multiple 3MF roots");if(C=!0,A={micron:.001,millimeter:1,centimeter:10,inch:25.4,foot:304.8,meter:1e3}[h.unit||"millimeter"],!A)throw new Error("Unsupported 3MF unit");for(let S of(h.requiredextensions||"").split(/\s+/).filter(Boolean))if(!/material\/2015\/02$/.test(b.ns[S]||""))throw new Error(`Unsupported required 3MF extension: ${S}`)}else if(a==="object"){if(n.has(h.id))throw new Error("Duplicate 3MF object");m={id:h.id,vertices:[],triangles:[],components:[],pid:h.pid,pindex:h.pindex},n.set(h.id,m)}else if(a==="vertex"&&m){let g=[Number(h.x),Number(h.y),Number(h.z)];if(g.some(S=>!Number.isFinite(S)))throw new Error("Invalid 3MF vertex");if(m.vertices.push(g),++u>t.max_triangles*3)throw new Error("3MF vertex limit exceeded");G(t,i+u*128+O*320)}else if(a==="triangle"&&m){if(m.triangles.push(h),++O>t.max_triangles)throw new Error("Triangle limit exceeded");G(t,i+u*128+O*320)}else if(a==="component"&&m){if(h.path)throw new Error("External 3MF components are unsupported");m.components.push({id:h.objectid,matrix:ce(h.transform)})}else if(a==="build")d=!0;else if(a==="item"&&d){if(h.path)throw new Error("External 3MF build items are unsupported");h.printable!=="0"&&l.push({id:h.objectid,matrix:ce(h.transform)})}else if(a==="basematerials"||a==="colorgroup")w=[],o.set(h.id,w);else if((a==="base"||a==="color")&&w){let g=h.displaycolor||h.color;if(!/^#[\da-f]{6}(?:[\da-f]{2})?$/i.test(g||""))throw new Error("Invalid 3MF color");w.push(Rt(g.slice(0,7)))}else if(a==="texture2d"||a==="texture2dgroup"||a==="multiproperties")throw new Error("3MF textures and composite materials are not supported")},a=>{a==="object"&&(m=null),a==="build"&&(d=!1),(a==="basematerials"||a==="colorgroup")&&(w=null)}),!C||!l.length)throw new Error("3MF build is empty");let P=[],v=0,M=0,I=(a,h,b)=>{if(b.includes(a)||b.length>=64)throw new Error("Cyclic or excessively nested 3MF components");if(++M>t.max_archive_entries*1024)throw new Error("3MF component expansion limit exceeded");let g=n.get(a);if(!g)throw new Error("Missing 3MF object");if(v+=g.triangles.length,v>t.max_triangles)throw new Error("Expanded triangle limit exceeded");G(t,i+u*128+O*320+v*224,"expanded model"),g.triangles.length&&P.push({obj:g,matrix:h});for(let S of g.components)I(S.id,bt(h,S.matrix),[...b,a])};for(let a of l)I(a.id,a.matrix,[]);let T=new Float32Array(v*9),L=new Float32Array(v*9),y=0,H=!1;for(let a of P)for(let h of a.obj.triangles)for(let b=0;b<3;b++){let g=Number(h[`v${b+1}`]);if(!Number.isInteger(g)||g<0||g>=a.obj.vertices.length)throw new Error("Invalid 3MF triangle index");T.set(St(a.matrix,a.obj.vertices[g]).map(xe=>xe*A),y);let S=h.pid??a.obj.pid,fe=Number(h[`p${b+1}`]??h.p1??a.obj.pindex??0),nt=[144/255,144/255,144/255];if(S!==void 0){if(nt=o.get(S)?.[fe],!nt)throw new Error("Unsupported or invalid 3MF material reference");H=!0}L.set(nt,y),y+=3}return{...vt(T,H?L:null,t),format:"3mf"}}export{Nt as a,ms as b,Ts as c,Ns as d};
|
|
9
|
+
`),t=this.i;break;case x:i!==void 0&&(this.text+=s.slice(t));break t;default:D(n)||(r=!0)}}r&&(!this.sawRoot&&!this.reportedTextBeforeRoot&&(this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0),this.closedRoot&&!this.reportedTextAfterRoot&&(this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0))}pushAttribNS(t,s){var i;let{prefix:r,local:n}=this.qname(t),o={name:t,prefix:r,local:n,value:s};if(this.attribList.push(o),(i=this.attributeHandler)===null||i===void 0||i.call(this,o),r==="xmlns"){let l=s.trim();this.currentXMLVersion==="1.0"&&l===""&&this.fail("invalid attempt to undefine prefix in XML 1.0"),this.topNS[n]=l,Ft(this,n,l)}else if(t==="xmlns"){let l=s.trim();this.topNS[""]=l,Ft(this,"",l)}}pushAttribPlain(t,s){var i;let r={name:t,value:s};this.attribList.push(r),(i=this.attributeHandler)===null||i===void 0||i.call(this,r)}end(){var t,s;this.sawRoot||this.fail("document must contain a root element.");let{tags:i}=this;for(;i.length>0;){let n=i.pop();this.fail(`unclosed tag: ${n.name}`)}this.state!==jt&&this.state!==_&&this.fail("unexpected end.");let{text:r}=this;return r.length!==0&&((t=this.textHandler)===null||t===void 0||t.call(this,r),this.text=""),this._closed=!0,(s=this.endHandler)===null||s===void 0||s.call(this),this._init(),this}resolve(t){var s,i;let r=this.topNS[t];if(r!==void 0)return r;let{tags:n}=this;for(let o=n.length-1;o>=0;o--)if(r=n[o].ns[t],r!==void 0)return r;return r=this.ns[t],r!==void 0?r:(i=(s=this.opt).resolvePrefix)===null||i===void 0?void 0:i.call(s,t)}qname(t){let s=t.indexOf(":");if(s===-1)return{prefix:"",local:t};let i=t.slice(s+1),r=t.slice(0,s);return(r===""||i===""||i.includes(":"))&&this.fail(`malformed name: ${t}.`),{prefix:r,local:i}}processAttribsNS(){var t;let{attribList:s}=this,i=this.tag;{let{prefix:o,local:l}=this.qname(i.name);i.prefix=o,i.local=l;let m=i.uri=(t=this.resolve(o))!==null&&t!==void 0?t:"";o!==""&&(o==="xmlns"&&this.fail('tags may not have "xmlns" as prefix.'),m===""&&(this.fail(`unbound namespace prefix: ${JSON.stringify(o)}.`),i.uri=o))}if(s.length===0)return;let{attributes:r}=i,n=new Set;for(let o of s){let{name:l,prefix:m,local:w}=o,d,A;m===""?(d=l==="xmlns"?j:"",A=l):(d=this.resolve(m),d===void 0&&(this.fail(`unbound namespace prefix: ${JSON.stringify(m)}.`),d=m),A=`{${d}}${w}`),n.has(A)&&this.fail(`duplicate attribute: ${A}.`),n.add(A),o.uri=d,r[l]=o}this.attribList=[]}processAttribsPlain(){let{attribList:t}=this,s=this.tag.attributes;for(let{name:i,value:r}of t)s[i]!==void 0&&this.fail(`duplicate attribute: ${i}.`),s[i]=r;this.attribList=[]}openTag(){var t;this.processAttribs();let{tags:s}=this,i=this.tag;i.isSelfClosing=!1,(t=this.openTagHandler)===null||t===void 0||t.call(this,i),s.push(i),this.state=_,this.name=""}openSelfClosingTag(){var t,s,i;this.processAttribs();let{tags:r}=this,n=this.tag;n.isSelfClosing=!0,(t=this.openTagHandler)===null||t===void 0||t.call(this,n),(s=this.closeTagHandler)===null||s===void 0||s.call(this,n),(this.tag=(i=r[r.length-1])!==null&&i!==void 0?i:null)===null&&(this.closedRoot=!0),this.state=_,this.name=""}closeTag(){let{tags:t,name:s}=this;if(this.state=_,this.name="",s===""){this.fail("weird empty close tag."),this.text+="</>";return}let i=this.closeTagHandler,r=t.length;for(;r-- >0;){let n=this.tag=t.pop();if(this.topNS=n.ns,i?.(n),n.name===s)break;this.fail("unexpected close tag.")}r===0?this.closedRoot=!0:r<0&&(this.fail(`unmatched closing tag: ${s}.`),this.text+=`</${s}>`)}parseEntity(t){if(t[0]!=="#"){let i=this.ENTITIES[t];return i!==void 0?i:(this.fail(this.isName(t)?"undefined entity.":"disallowed character in entity name."),`&${t};`)}let s=NaN;return t[1]==="x"&&/^#x[0-9a-f]+$/i.test(t)?s=parseInt(t.slice(2),16):/^#[0-9]+$/.test(t)&&(s=parseInt(t.slice(1),10)),this.isChar(s)?String.fromCodePoint(s):(this.fail("malformed character entity."),`&${t};`)}};V.SaxesParser=Dt});var de=me(he(),1);var Tt=new TextDecoder("utf-8",{fatal:!0}),fs=Uint32Array.from({length:256},(e,t)=>{for(let s=0;s<8;s++)t=t&1?3988292384^t>>>1:t>>>1;return t>>>0});function xs(e,t=4294967295){for(let s of e)t=fs[(t^s)&255]^t>>>8;return t>>>0}function Nt(e){if(!e||e.includes("\\")||e.startsWith("/")||e.includes("\0")||e.split("/").some(t=>t===".."||t===".")||/^[a-z]+:/i.test(e))throw new Error("Unsafe archive path");return e}function ms(e,t=Y){if(e.byteLength>t.max_file_bytes)throw new Error("Archive size limit exceeded");let s=new Uint8Array(e),i=new DataView(e),r=-1;for(let u=s.length-22;u>=Math.max(0,s.length-65557);u--)if(i.getUint32(u,!0)===101010256&&u+22+i.getUint16(u+20,!0)===s.length){r=u;break}if(r<0)throw new Error("ZIP central directory not found");let n=i.getUint16(r+10,!0),o=i.getUint32(r+12,!0),l=i.getUint32(r+16,!0);if(i.getUint16(r+4,!0)||i.getUint16(r+6,!0)||n!==i.getUint16(r+8,!0))throw new Error("Multi-disk ZIP is unsupported");if(n===65535||l===4294967295||o===4294967295)throw new Error("ZIP64 is unsupported");if(n>t.max_archive_entries||l+o>r)throw new Error("Invalid or oversized ZIP directory");let m=[],w=new Set,d=l,A=0;for(let u=0;u<n;u++){if(d+46>l+o||i.getUint32(d,!0)!==33639248)throw new Error("Invalid ZIP directory entry");let C=i.getUint16(d+8,!0),P=i.getUint16(d+10,!0),v=i.getUint32(d+16,!0),M=i.getUint32(d+20,!0),I=i.getUint32(d+24,!0),T=i.getUint16(d+28,!0),L=i.getUint16(d+30,!0),y=i.getUint16(d+32,!0),H=i.getUint32(d+42,!0);if(d+46+T+L+y>l+o)throw new Error("Truncated ZIP directory");let a=Nt(Tt.decode(s.subarray(d+46,d+46+T)));if(w.has(a))throw new Error("Duplicate archive entry");if(w.add(a),C&1||![0,8].includes(P))throw new Error("Encrypted or unsupported ZIP compression");if(A+=I,G(t,67108864+e.byteLength+A*4,"expanded archive"),A>t.max_uncompressed_bytes)throw new Error("Archive expansion limit exceeded");m.push({name:a,method:P,checksum:v,compressed:M,original:I,local:H}),d+=46+T+L+y}if(d!==l+o)throw new Error("ZIP directory size mismatch");let O=new Map;for(let u of m){let C=u.local;if(C+30>l||i.getUint32(C,!0)!==67324752)throw new Error("Invalid ZIP local header");let P=i.getUint16(C+26,!0),v=i.getUint16(C+28,!0),M=C+30+P+v;if(M+u.compressed>l||i.getUint16(C+8,!0)!==u.method||i.getUint16(C+6,!0)&1||Tt.decode(s.subarray(C+30,C+30+P))!==u.name)throw new Error("ZIP header mismatch");let I=new Uint8Array(u.original),T=0,L=4294967295,y=!1,H=(a,h)=>{if(T+a.length>I.length)throw new Error("ZIP entry exceeds declared size");I.set(a,T),T+=a.length,L=xs(a,L),y=h};if(u.method===0)H(s.subarray(M,M+u.compressed),!0);else{let a=new Mt(H);for(let h=0;h<u.compressed;h+=1024)a.push(s.subarray(M+h,M+Math.min(h+1024,u.compressed)),h+1024>=u.compressed)}if(!y||T!==u.original||(L^4294967295)>>>0!==u.checksum)throw new Error("ZIP checksum or length mismatch");u.name.endsWith("/")||O.set(u.name,I)}return O}function Ts(e,t=Y){let s=Object.create(null);s["json_data.vsj"]=new TextEncoder().encode(JSON.stringify(e.vsj));let i=s["json_data.vsj"].length;for(let n of e.files){let o=Nt(`${n.id}.stl`),l=new Uint8Array(n.bin);i+=l.length,s[o]=l}if(Object.keys(s).length>t.max_archive_entries||i>t.max_uncompressed_bytes)throw new Error("Scene archive limit exceeded");let r=It(s,{level:6});if(r.length>t.max_file_bytes)throw new Error("Archive size limit exceeded");return r.buffer}function le(e,t,s=()=>{}){let i=new de.SaxesParser({xmlns:!0});i.on("doctype",()=>{throw new Error("XML document types are not supported")}),i.on("error",r=>{throw r}),i.on("opentag",r=>{let n=Object.create(null);for(let o of Object.values(r.attributes))n[o.local]=o.value;t(r.local,n,r)}),i.on("closetag",r=>s(r.local)),i.write(Tt.decode(e)).close()}function ce(e){if(!e)return wt();let t=e.trim().split(/\s+/).map(Number);if(t.length!==12||t.some(s=>!Number.isFinite(s)))throw new Error("Invalid 3MF transform");return new Float64Array([t[0],t[1],t[2],0,t[3],t[4],t[5],0,t[6],t[7],t[8],0,t[9],t[10],t[11],1])}function Ns(e,t=Y){let s=ms(e,t),i=67108864+e.byteLength+[...s.values()].reduce((a,h)=>a+h.byteLength*3,0),r=null;if(s.has("_rels/.rels")&&le(s.get("_rels/.rels"),(a,h)=>{if(a==="Relationship"&&h.Type?.endsWith("/3dmodel")){if(h.TargetMode==="External")throw new Error("External 3MF resources are unsupported");r=Nt(h.Target.replace(/^\//,""))}}),r??=[...s.keys()].find(a=>/^3d\/3dmodel\.model$/i.test(a)),!r||!s.has(r))throw new Error("3MF model part not found");let n=new Map,o=new Map,l=[],m=null,w=null,d=!1,A=1,O=0,u=0,C=!1;if(le(s.get(r),(a,h,b)=>{if(a==="model"){if(C)throw new Error("Multiple 3MF roots");if(C=!0,A={micron:.001,millimeter:1,centimeter:10,inch:25.4,foot:304.8,meter:1e3}[h.unit||"millimeter"],!A)throw new Error("Unsupported 3MF unit");for(let S of(h.requiredextensions||"").split(/\s+/).filter(Boolean))if(!/material\/2015\/02$/.test(b.ns[S]||""))throw new Error(`Unsupported required 3MF extension: ${S}`)}else if(a==="object"){if(n.has(h.id))throw new Error("Duplicate 3MF object");m={id:h.id,vertices:[],triangles:[],components:[],pid:h.pid,pindex:h.pindex},n.set(h.id,m)}else if(a==="vertex"&&m){let g=[Number(h.x),Number(h.y),Number(h.z)];if(g.some(S=>!Number.isFinite(S)))throw new Error("Invalid 3MF vertex");if(m.vertices.push(g),++u>t.max_triangles*3)throw new Error("3MF vertex limit exceeded");G(t,i+u*128+O*320)}else if(a==="triangle"&&m){if(m.triangles.push(h),++O>t.max_triangles)throw new Error("Triangle limit exceeded");G(t,i+u*128+O*320)}else if(a==="component"&&m){if(h.path)throw new Error("External 3MF components are unsupported");m.components.push({id:h.objectid,matrix:ce(h.transform)})}else if(a==="build")d=!0;else if(a==="item"&&d){if(h.path)throw new Error("External 3MF build items are unsupported");h.printable!=="0"&&l.push({id:h.objectid,matrix:ce(h.transform)})}else if(a==="basematerials"||a==="colorgroup")w=[],o.set(h.id,w);else if((a==="base"||a==="color")&&w){let g=h.displaycolor||h.color;if(!/^#[\da-f]{6}(?:[\da-f]{2})?$/i.test(g||""))throw new Error("Invalid 3MF color");w.push(Rt(g.slice(0,7)))}else if(a==="texture2d"||a==="texture2dgroup"||a==="multiproperties")throw new Error("3MF textures and composite materials are not supported")},a=>{a==="object"&&(m=null),a==="build"&&(d=!1),(a==="basematerials"||a==="colorgroup")&&(w=null)}),!C||!l.length)throw new Error("3MF build is empty");let P=[],v=0,M=0,I=(a,h,b)=>{if(b.includes(a)||b.length>=64)throw new Error("Cyclic or excessively nested 3MF components");if(++M>t.max_archive_entries*1024)throw new Error("3MF component expansion limit exceeded");let g=n.get(a);if(!g)throw new Error("Missing 3MF object");if(v+=g.triangles.length,v>t.max_triangles)throw new Error("Expanded triangle limit exceeded");G(t,i+u*128+O*320+v*224,"expanded model"),g.triangles.length&&P.push({obj:g,matrix:h});for(let S of g.components)I(S.id,bt(h,S.matrix),[...b,a])};for(let a of l)I(a.id,a.matrix,[]);let T=new Float32Array(v*9),L=new Float32Array(v*9),y=0,H=!1;for(let a of P)for(let h of a.obj.triangles)for(let b=0;b<3;b++){let g=Number(h[`v${b+1}`]);if(!Number.isInteger(g)||g<0||g>=a.obj.vertices.length)throw new Error("Invalid 3MF triangle index");T.set(St(a.matrix,a.obj.vertices[g]).map(xe=>xe*A),y);let S=h.pid??a.obj.pid,fe=Number(h[`p${b+1}`]??h.p1??a.obj.pindex??0),nt=[144/255,144/255,144/255];if(S!==void 0){if(nt=o.get(S)?.[fe],!nt)throw new Error("Unsupported or invalid 3MF material reference");H=!0}L.set(nt,y),y+=3}return{...vt(T,H?L:null,t),format:"3mf",units:"mm"}}export{Nt as a,ms as b,Ts as c,Ns as d};
|
|
10
10
|
/*! Bundled license information:
|
|
11
11
|
|
|
12
12
|
xmlchars/xml/1.0/ed5.js:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as k}from"./chunk-W5KVLGVR.js";var z=Object.freeze({max_file_bytes:256*1024*1024,max_triangles:5e6,max_uncompressed_bytes:256*1024*1024,max_archive_entries:1024,max_memory_bytes:Number.MAX_SAFE_INTEGER});function O(e){if(typeof e!="string"||!/^#[\da-f]{6}$/i.test(e))throw new Error("Color must be #RRGGBB");return[1,3,5].map(n=>parseInt(e.slice(n,n+2),16)/255)}function U(e,n=null,x=z){if(!(e instanceof Float32Array)||!e.length||e.length%9)throw new Error("Geometry must contain complete triangles");if(e.length/9>x.max_triangles)throw new Error("Triangle limit exceeded");if(k(x,67108864+e.length/9*224),n&&(!(n instanceof Float32Array)||n.length!==e.length))throw new Error("Invalid vertex colors");let f={min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]};for(let t=0;t<e.length;t++){let i=e[t],r=t%3;if(!Number.isFinite(i))throw new Error("Non-finite vertex coordinate");if(f.min[r]=Math.min(f.min[r],i),f.max[r]=Math.max(f.max[r],i),n&&(!Number.isFinite(n[t])||n[t]<0||n[t]>1))throw new Error("Invalid vertex color")}let l=new Float32Array(e.length),s=new Float32Array(Math.ceil(e.length/9/64)*6),c=0,y=0,o=0;for(let t=0;t<e.length;t+=9){let i=e[t+3]-e[t],r=e[t+4]-e[t+1],u=e[t+5]-e[t+2],a=e[t+6]-e[t],m=e[t+7]-e[t+1],w=e[t+8]-e[t+2],M=r*w-u*m,d=u*a-i*w,g=i*m-r*a,E=Math.hypot(M,d,g);c+=E/2,y+=(e[t]*M+e[t+1]*d+e[t+2]*g)/6,E||o++;for(let h=0;h<9;h+=3)l[t+h]=M/(E||1),l[t+h+1]=d/(E||1),l[t+h+2]=g/(E||1);let b=Math.floor(t/9/64)*6;t/9%64===0&&s.set([1/0,1/0,1/0,-1/0,-1/0,-1/0],b);for(let h=0;h<9;h++){let I=h%3;s[b+I]=Math.min(s[b+I],e[t+h]),s[b+3+I]=Math.max(s[b+3+I],e[t+h])}}if(!Number.isFinite(c)||!Number.isFinite(y))throw new Error("Geometry magnitude exceeds numeric limits");return{positions:e,normals:l,colors:n,blocks:s,bounds:f,triangles:e.length/9,area:c,volume:Math.abs(y),degenerateTriangles:o}}function j(e,{smooth:n=!1,edges:x=!1,wire:f=!1,edgeAngle:l=1}={}){let s=new Map,c=new Uint32Array(e.length/3),y=[],o=[];for(let r=0;r<e.length;r+=3){let u=`${e[r]},${e[r+1]},${e[r+2]}`,a=s.get(u);a===void 0&&(a=y.length,s.set(u,a),y.push([e[r],e[r+1],e[r+2]]),o.push([0,0,0])),c[r/3]=a}let t=new Map;for(let r=0;r<e.length;r+=9){let u=e[r+3]-e[r],a=e[r+4]-e[r+1],m=e[r+5]-e[r+2],w=e[r+6]-e[r],M=e[r+7]-e[r+1],d=e[r+8]-e[r+2],g=[a*d-m*M,m*w-u*d,u*M-a*w],E=Math.hypot(...g)||1;for(let b=0;b<3;b++)if(n)for(let h=0;h<3;h++)o[c[r/3+b]][h]+=g[h];if(x||f)for(let b=0;b<3;b++){let h=c[r/3+b],I=c[r/3+(b+1)%3],A=h<I?`${h}:${I}`:`${I}:${h}`,F=g.map(v=>v/E),_=t.get(A);_?(_.count++,_.n.reduce((v,N,T)=>v+N*F[T],0)<Math.cos(l*Math.PI/180)&&(_.sharp=!0)):t.set(A,{a:h,b:I,n:F,count:1,sharp:!1})}}let i={};if(n){i.smoothNormals=new Float32Array(e.length);for(let r=0;r<c.length;r++){let u=o[c[r]],a=Math.hypot(...u)||1;i.smoothNormals.set(u.map(m=>m/a),r*3)}}for(let[r,u,a]of[[x,"edges",m=>m.count!==2||m.sharp],[f,"wire",()=>!0]])if(r){let m=[...t.values()].filter(a),w=new Float32Array(m.length*6);m.forEach((M,d)=>{w.set(y[M.a],d*6),w.set(y[M.b],d*6+3)}),i[u]=w,u==="edges"&&(i.edgeAngle=l)}return i}function D(e,n){if(n[0]===n[1]&&n[1]===n[2])return{area:e.area*n[0]*n[0],volume:e.volume*Math.abs(n[0]**3)};let x=0,f=e.positions;for(let l=0;l<f.length;l+=9){let s=(f[l+3]-f[l])*n[0],c=(f[l+4]-f[l+1])*n[1],y=(f[l+5]-f[l+2])*n[2],o=(f[l+6]-f[l])*n[0],t=(f[l+7]-f[l+1])*n[1],i=(f[l+8]-f[l+2])*n[2];x+=Math.hypot(c*i-y*t,y*o-s*i,s*t-c*o)/2}return{area:x,volume:e.volume*Math.abs(n[0]*n[1]*n[2])}}function V(e,n=[1,1,1],x=[0,0,0]){let f=new ArrayBuffer(84+e.triangles*50),l=new DataView(f),s=e.positions;new Uint8Array(f).set(new TextEncoder().encode("Binary STL by ViewSTL 2")),l.setUint32(80,e.triangles,!0);for(let c=0;c<e.triangles;c++){let y=84+c*50,o=Array.from({length:9},(a,m)=>(s[c*9+m]-x[m%3])*n[m%3]),t=[o[3]-o[0],o[4]-o[1],o[5]-o[2]],i=[o[6]-o[0],o[7]-o[1],o[8]-o[2]],r=[t[1]*i[2]-t[2]*i[1],t[2]*i[0]-t[0]*i[2],t[0]*i[1]-t[1]*i[0]],u=Math.hypot(...r)||1;for(let a=0;a<3;a++)l.setFloat32(y+a*4,r[a]/u,!0);for(let a=0;a<9;a++)l.setFloat32(y+12+a*4,o[a],!0);if(e.colors){let a=[0,1,2].map(m=>Math.round(e.colors[c*9+m]*31));l.setUint16(y+48,32768|a[0]<<10|a[1]<<5|a[2],!0)}}return f}export{z as a,O as b,U as c,j as d,D as e,V as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function m(e={}){let l=e.level??"basic";if(!["basic","detailed"].includes(l))throw new Error("Choose basic or detailed print checks");let i=(r,t,s=1e9)=>{if(!Number.isFinite(r)||r<=0||r>s)throw new Error(`Invalid ${t}`);return r},o=null;if(e.profile!=null){if(e.profile.technology!=="fdm")throw new Error("Only FDM profiles are supported");o={technology:"fdm"};for(let r of["min_wall_mm","line_width_mm"])e.profile[r]!=null&&(o[r]=i(e.profile[r],r));if(e.profile.overhang_degrees!=null&&(o.overhang_degrees=i(e.profile.overhang_degrees,"overhang angle",89.9)),e.profile.build_volume_mm!=null){if(!Array.isArray(e.profile.build_volume_mm)||e.profile.build_volume_mm.length!==3)throw new Error("Build volume requires X, Y and Z");o.build_volume_mm=e.profile.build_volume_mm.map(r=>i(r,"build volume"))}}let n=i(e.max_time_ms??3e4,"check time limit",12e4);return{level:l,profile:o,apply_transforms:e.apply_transforms!==!1,units_confirmed:e.units_confirmed===!0,max_time_ms:n}}var f=e=>64*1024**2+e*2400;export{m as a,f as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as p,d as c,e as x,h as d}from"./chunk-
|
|
1
|
+
import{c as p,d as c,e as x,h as d}from"./chunk-6AW5U52H.js";var u=r=>{if(!Number.isFinite(r))throw new Error("Non-finite export coordinate");return Object.is(r,-0)?"0":String(r)},b=r=>String(r).replace(/[\x00-\x08\x0b\x0c\x0e-\x1f]/g,"").replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t]),m=class{constructor(t){this.limit=t,this.bytes=0}add(t){if(this.bytes+=t,this.bytes>this.limit)throw new Error("Export size limit exceeded")}},g=class{constructor(t){this.budget=t,this.parts=[],this.pending=""}write(t){this.pending+=t,this.pending.length>=32768&&this.flush()}flush(){if(!this.pending)return;let t=new TextEncoder().encode(this.pending);this.budget.add(t.byteLength),this.parts.push(t),this.pending=""}finish(){return this.flush(),this.parts}};function f(r,t){let i=r.positions,e=r.matrix,n=[0,3,6].map(o=>d(e,[i[t+o],i[t+o+1],i[t+o+2]]));if(n.flat().some(o=>!Number.isFinite(o)))throw new Error("Non-finite export coordinate");let a=e[0]*(e[5]*e[10]-e[9]*e[6])-e[4]*(e[1]*e[10]-e[9]*e[2])+e[8]*(e[1]*e[6]-e[5]*e[2]);a<0&&([n[1],n[2]]=[n[2],n[1]]);let s=c(p(n[1],n[0]),p(n[2],n[0]));if(!Number.isFinite(Math.hypot(...s)))throw new Error("Geometry magnitude exceeds export limits");return{vertices:n,normal:x(s),degenerate:!Math.hypot(...s),reflected:a<0}}function h(r,t){return r.color||(r.colors?Array.from(r.colors.subarray(t,t+3)):[144/255,144/255,144/255])}var w=(r,t=1)=>"#"+[...r,t].map(i=>Math.round(Math.max(0,Math.min(1,i))*255).toString(16).padStart(2,"0")).join("").toUpperCase(),y=(r,t)=>[0,1,2].map(i=>(h(r,t)[i]+h(r,t+3)[i]+h(r,t+6)[i])/3);function E(r,t){let i=0;return t({loaded:0,total:r,phase:"exporting"}),()=>{i++,(i%1024===0||i===r)&&t({loaded:i,total:r,phase:"exporting"})}}export{u as a,b,m as c,g as d,f as e,h as f,w as g,y as h,E as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as ae,b as le}from"./chunk-LFTKNL2V.js";import{a as re}from"./chunk-W5KVLGVR.js";import{h as oe}from"./chunk-6AW5U52H.js";var N=(t,r)=>t.map((c,a)=>c-r[a]),R=(t,r)=>t.reduce((c,a,l)=>c+a*r[l],0),C=(t,r)=>[t[1]*r[2]-t[2]*r[1],t[2]*r[0]-t[0]*r[2],t[0]*r[1]-t[1]*r[0]];function D(t,r){return[0,3,6].map(c=>Array.from(t.subarray(r*9+c,r*9+c+3)))}function ue(t,r){let c=t.length/9,a=new Float64Array(c*6);for(let n=0;n<c;n++){n%1024===0&&r();for(let u=0;u<3;u++)a[n*6+u]=Math.min(t[n*9+u],t[n*9+3+u],t[n*9+6+u]),a[n*6+u+3]=Math.max(t[n*9+u],t[n*9+3+u],t[n*9+6+u])}let l=Uint32Array.from({length:c},(n,u)=>u),s=(n,u)=>{r();let M=[1/0,1/0,1/0,-1/0,-1/0,-1/0];for(let f=n;f<u;f++)for(let m=0;m<3;m++)M[m]=Math.min(M[m],a[l[f]*6+m]),M[m+3]=Math.max(M[m+3],a[l[f]*6+m+3]);let _={b:M,start:n,end:u};if(u-n>16){let f=[0,1,2].map($=>M[$+3]-M[$]),m=f.indexOf(Math.max(...f));l.subarray(n,u).sort(($,z)=>a[$*6+m]+a[$*6+m+3]-(a[z*6+m]+a[z*6+m+3]));let g=n+u>>>1;_.left=s(n,g),_.right=s(g,u)}return _};return{root:s(0,c),ids:l,boxes:a}}var ce=(t,r,c)=>[0,1,2].every(a=>t[a]<=r[a+3]+c&&t[a+3]+c>=r[a]);function fe(t,r,c,a){let l=(s,n,u)=>{if(a(),!!ce(s.b,n.b,r))if(!s.left&&!n.left)for(let M=s.start;M<s.end;M++)for(let _=n.start;_<n.end;_++){let f=t.ids[M],m=t.ids[_];u&&f>=m||ce(t.boxes.subarray(f*6,f*6+6),t.boxes.subarray(m*6,m*6+6),r)&&c(f,m)}else u?(l(s.left,s.left,!0),l(s.left,s.right,!1),l(s.right,s.right,!0)):s.left&&(!n.left||s.end-s.start>=n.end-n.start)?(l(s.left,n,!1),l(s.right,n,!1)):(l(s,n.left,!1),l(s,n.right,!1))};l(t.root,t.root,!0)}var J=(t,r,c)=>(r[0]-t[0])*(c[1]-t[1])-(r[1]-t[1])*(c[0]-t[0]);function me(t,r,c,a){let l=C(N(t[1],t[0]),N(t[2],t[0])),s=C(N(r[1],r[0]),N(r[2],r[0])),n=Math.hypot(...l),u=Math.hypot(...s);if(!n||!u)return 0;let M=r.map(d=>R(N(d,t[0]),l)/n),_=t.map(d=>R(N(d,r[0]),s)/u);if([M,_].some(d=>d.every(b=>b>a)||d.every(b=>b<-a)))return 0;let f=C(l.map(d=>d/n),s.map(d=>d/u));if(Math.hypot(...f)<1e-10){if(Math.max(...M.map(Math.abs))>a)return 0;let d=l.map(Math.abs).indexOf(Math.max(...l.map(Math.abs))),b=A=>A.filter((S,I)=>I!==d);if(c>=2){let A=(I,k)=>I.every((E,p)=>E===k[p]),S=t.filter(I=>r.some(k=>A(I,k)));if(S.length===3)return 1;if(S.length===2){let I=t.find(E=>!S.some(p=>A(E,p))),k=r.find(E=>!S.some(p=>A(E,p)));return J(b(S[0]),b(S[1]),b(I))*J(b(S[0]),b(S[1]),b(k))>0?1:0}}let O=t.map(b),q=r.map(b),B=Math.sign(J(...q));for(let A=0;A<3&&O.length;A++){let S=q[A],I=q[(A+1)%3],k=[];for(let E=0;E<O.length;E++){let p=O[E],P=O[(E+1)%O.length],x=B*J(S,I,p),U=B*J(S,I,P);if(x>=0&&k.push(p),x>=0!=U>=0){let K=x/(x-U);k.push(p.map((Y,W)=>Y+(P[W]-Y)*K))}}O=k}return Math.abs(O.reduce((A,S,I)=>{let k=O[(I+1)%O.length],E=O[0];return A+(S[0]-E[0])*(k[1]-E[1])-(S[1]-E[1])*(k[0]-E[0])},0))/2>a*a*4?1:0}if(c>=2)return 0;let m=f.map(d=>d/Math.hypot(...f)),g=(d,b)=>{let O=[];for(let q=0;q<3;q++){Math.abs(b[q])<=a&&O.push(R(d[q],m));let B=(q+1)%3;if(b[q]*b[B]<0){let Q=b[q]/(b[q]-b[B]);O.push(R(d[q].map((A,S)=>A+(d[B][S]-A)*Q),m))}}return O.length?[Math.min(...O),Math.max(...O)]:null},$=g(t,_),z=g(r,M);if(!$||!z)return 0;let L=Math.min($[1],z[1])-Math.max($[0],z[0]);return L>a?1:c?0:L>=-a?2:0}function ye(t,r,c,a){let l=N(c[1],c[0]),s=N(c[2],c[0]),n=C(r,s),u=R(l,n);if(Math.abs(u)<=Math.hypot(...l)*Math.hypot(...s)*1e-12)return null;let M=N(t,c[0]),_=R(M,n)/u,f=C(M,l),m=R(r,f)/u,g=R(s,f)/u;return _<-1e-10||m<-1e-10||_+m>1+1e-10||g<=a?null:{t:g,edge:Math.min(_,m,1-_-m)<1e-8}}function ve(t,r,c,a){let l=0,s=1/0;for(let n=0;n<3;n++)if(Math.abs(r[n])<1e-15){if(t[n]<c[n]-a||t[n]>c[n+3]+a)return!1}else{let u=(c[n]-a-t[n])/r[n],M=(c[n+3]+a-t[n])/r[n];if(l=Math.max(l,Math.min(u,M)),s=Math.min(s,Math.max(u,M)),l>s)return!1}return!0}function ie(t,r,c,a,l,s,n){let u=[],M=_=>{if(n(),!!ve(c,a,_.b,l))if(_.left)M(_.left),M(_.right);else for(let f=_.start;f<_.end;f++){let m=t.ids[f];if(!s(m))continue;let g=ye(c,a,D(r,m),l);g&&u.push({...g,id:m})}};return M(t.root),u}var Me=[["degenerate_faces","Degenerate triangles","error"],["near_degenerate_faces","Very small or thin triangles","warning"],["duplicate_faces","Duplicate triangles","error"],["boundary_edges","Open boundaries","error"],["nonmanifold_edges","Non-manifold edges","error"],["nonmanifold_vertices","Non-manifold vertices","error"],["winding","Triangle winding","error"],["components","Separate connected parts","info"],["intersections","Self-intersections","error"],["shell_orientation","Shell orientation and volume","error"],["units","Physical units","warning"],["build_volume","Build volume fit","warning"],["overhangs","Overhangs","warning"],["bed_contact","Bed contact","warning"],["thin_walls","Thin walls / small features","warning"]];function Ae(t,r={},c={},a=()=>{}){let l=ae(r),s=t.positions.length/9;if(!(t.positions instanceof Float32Array)||!Number.isSafeInteger(s)||s<1||t.matrix?.length!==16||Array.from(t.matrix).some(p=>!Number.isFinite(p)))throw new Error("Invalid print-check geometry");if(s>(c.max_triangles??5e6))throw new Error("Print check triangle limit exceeded");re(c,le(s),"print check");let n=performance.now(),u=n+l.max_time_ms,M=0,_="Topology",f=()=>{if(++M%128===0){if(performance.now()>u)throw new Error("PRINT_TIME_LIMIT");a({phase:_,elapsed_ms:performance.now()-n})}},m=Me.map(([p,P,x])=>({code:p,label:P,severity:x,status:"not_run",count:0,triangle_ids:[],edge_vertices:[],message:"Not run"})),g=p=>m.find(P=>P.code===p),$=(p,P,x)=>Object.assign(g(p),{status:P,message:x}),z=(p,P)=>{let x=g(p);x.count++,P!=null&&x.triangle_ids.length<128&&x.triangle_ids.push(P)},L=(p,P)=>{let x=g(p);x.status=x.count?"issue":"pass",x.message=P||`${x.count} found`},d=new Float64Array(t.positions.length),b=[1/0,1/0,1/0],O=[-1/0,-1/0,-1/0],q=!1,B,Q=[],A=[],S,I=0,k={model_id:t.id,name:t.name,triangles:s,checks:m,settings:l,dimensions_mm:null,volume_mm3:null,volume_valid:!1,elapsed_ms:0,summary:"incomplete"};try{a({phase:_,elapsed_ms:0});for(let e=0;e<t.positions.length;e+=3){e%3072===0&&f();let i=oe(t.matrix,Array.from(t.positions.subarray(e,e+3)));if(i.some(o=>!Number.isFinite(o)))throw new Error("Invalid print-check coordinate");d.set(i,e);for(let o=0;o<3;o++)b[o]=Math.min(b[o],i[o]),O[o]=Math.max(O[o],i[o])}k.dimensions_mm=O.map((e,i)=>e-b[i]);let p=Math.max(...k.dimensions_mm),P=Math.max(...b.map(Math.abs),...O.map(Math.abs));I=Math.max(p*1e-10,P*Number.EPSILON*64,1e-12),k.tolerance_mm=I;for(let e=0;e<d.length;e++)d[e]-=b[e%3];let x=new Uint32Array(s*3),U=[],K=new Map,Y=new Map,W=new Map,Z=[],G=Int32Array.from({length:s},(e,i)=>i),te=e=>{for(;G[e]!==e;)G[e]=G[G[e]],e=G[e];return e},he=(e,i)=>{e=te(e),i=te(i),e!==i&&(G[i]=e)};for(let e=0;e<s;e++){f();for(let h=0;h<3;h++){let w=e*9+h*3,T=Array.from(t.positions.subarray(w,w+3)).join(","),F=K.get(T);F===void 0&&(F=U.length,K.set(T,F),U.push(w),Z.push([])),x[e*3+h]=F,Z[F].push(e)}let i=D(d,e),o=C(N(i[1],i[0]),N(i[2],i[0])),y=Math.hypot(...o);y?y<=I*Math.max(...i.map((h,w)=>Math.hypot(...N(h,i[(w+1)%3]))))&&z("near_degenerate_faces",e):z("degenerate_faces",e);let v=Array.from(x.subarray(e*3,e*3+3)).sort((h,w)=>h-w).join(":");W.has(v)?z("duplicate_faces",e):W.set(v,e);for(let h=0;h<3;h++){let w=x[e*3+h],T=x[e*3+(h+1)%3],F=Math.min(w,T)+":"+Math.max(w,T),j=Y.get(F);j||(j={a:w,b:T,faces:[],direction:0},Y.set(F,j)),j.faces.length&&he(e,j.faces[0]),j.faces.push(e),j.direction+=w<T?1:-1}}let ne=new Set;for(let e of Y.values()){f();let i;if(e.faces.length===1?i="boundary_edges":e.faces.length!==2?(i="nonmanifold_edges",ne.add(e.a),ne.add(e.b)):e.direction!==0&&(i="winding"),i){z(i,e.faces[0]);let o=g(i);o.edge_vertices.length<256*6&&o.edge_vertices.push(...t.positions.subarray(U[e.a],U[e.a]+3),...t.positions.subarray(U[e.b],U[e.b]+3))}}for(let e=0;e<Z.length;e++){if(f(),ne.has(e)){z("nonmanifold_vertices",Z[e][0]);continue}let i=new Set(Z[e]),o=new Set,y=[Z[e][0]];for(;y.length;){f();let v=y.pop();if(!o.has(v)){o.add(v);for(let h=0;h<3;h++){let w=x[v*3+h],T=x[v*3+(h+1)%3];if(w!==e&&T!==e)continue;let F=Y.get(Math.min(w,T)+":"+Math.max(w,T));for(let j of F.faces)o.has(j)||y.push(j)}}}o.size!==i.size&&z("nonmanifold_vertices",Z[e][0])}let H=new Map;S=new Int32Array(s);for(let e=0;e<s;e++){f();let i=te(e);H.has(i)||(H.set(i,H.size),A.push([]),Q.push(0));let o=H.get(i);S[e]=o,A[o].push(e);let y=D(d,e),v=D(d,A[o][0])[0];Q[o]+=R(N(y[0],v),C(N(y[1],v),N(y[2],v)))/6}for(let e of["degenerate_faces","near_degenerate_faces","duplicate_faces","boundary_edges","nonmanifold_edges","nonmanifold_vertices","winding"])L(e);g("components").count=H.size,$("components",H.size>1?"issue":"pass",`${H.size} connected part${H.size===1?"":"s"}. Separate parts can be intentional.`),q=!0,$("units",t.source_units||l.units_confirmed?"pass":"inconclusive",t.source_units?`File units: ${t.source_units}; measurements in mm.`:l.units_confirmed?"Current scale confirmed as millimetres.":"File has no physical units. Confirm the current millimetre scale before using size estimates.");let X=l.profile;X?.build_volume_mm&&(g("build_volume").count=k.dimensions_mm.filter((e,i)=>e>X.build_volume_mm[i]+I).length,L("build_volume",g("build_volume").count?"Exceeds the supplied build volume in the current orientation. Try another orientation or scale in your slicer.":"Fits by dimensions only in the current orientation; placement and printer exclusions are not checked."));let se=m.filter(e=>e.severity==="error"&&e.status!=="not_run").every(e=>e.status==="pass");if(l.level==="detailed"){_="Spatial index",B=ue(d,f),_="Self-intersections";let e=0;if(fe(B,I,(i,o)=>{f();let y=Array.from(x.subarray(i*3,i*3+3)).filter(h=>x.subarray(o*3,o*3+3).includes(h)).length,v=me(D(d,i),D(d,o),y,I);if(v===1){z("intersections",i);let h=g("intersections");h.triangle_ids.length<128&&h.triangle_ids.push(o)}else v===2&&e++},f),L("intersections"),e&&!g("intersections").count&&$("intersections","inconclusive",`${e} near-contact pairs require inspection at the reported numerical tolerance.`),se&&g("intersections").status==="pass"){_="Shell containment";let i=!1;for(let o=0;o<A.length;o++){f();let y=D(d,A[o][0]),v=[0,1,2].map(w=>(y[0][w]+y[1][w]+y[2][w])/3),h=null;for(let w of[[1,.371,.529],[.217,1,.413],[.317,.193,1]]){let T=ie(B,d,v,w,I,j=>S[j]!==o,f);if(T.some(j=>j.edge))continue;let F=new Map;for(let j of T)F.set(S[j.id],(F.get(S[j.id])||0)+1);h=[...F.values()].filter(j=>j%2===1).length;break}if(h===null){i=!0;continue}(Math.abs(Q[o])<=I**3||Math.sign(Q[o])!==(h%2?-1:1))&&z("shell_orientation",A[o][0])}L("shell_orientation","Outer shells must face outward; cavity shells face inward."),i&&!g("shell_orientation").count&&$("shell_orientation","inconclusive","Shell containment is numerically ambiguous."),g("shell_orientation").status==="pass"&&(k.volume_mm3=Q.reduce((o,y)=>o+y,0),k.volume_valid=!0)}else $("shell_orientation","inconclusive","Requires a closed, consistently wound mesh without intersections.")}else $("shell_orientation","not_run","Run Detailed check for intersections, nested shells and validated volume.");if(X){_="FDM estimates";let e=g("units").status==="pass";if(!e)for(let i of["build_volume","bed_contact","thin_walls"])$(i,"inconclusive","Confirm physical units first.");if(X.overhang_degrees!=null)if(!se||(l.level==="detailed"?!k.volume_valid:A.length!==1||Q[0]<=0))$("overhangs","inconclusive","Fix triangle winding and mesh defects before estimating overhangs.");else{let i=-Math.sin(X.overhang_degrees*Math.PI/180),o=0;for(let y=0;y<s;y++){f();let v=D(d,y),h=C(N(v[1],v[0]),N(v[2],v[0])),w=Math.hypot(...h);v.every(T=>T[2]<=I*8)||h[2]/w<i&&(z("overhangs",y),o+=w/2)}g("overhangs").estimated=!0,g("overhangs").area_mm2=o,L("overhangs",`Potential support regions above ${X.overhang_degrees}\xB0 from vertical. +Z is up; bridges/supports are not simulated.`)}if(e){let i=0;for(let y=0;y<s;y++){f();let v=D(d,y);v.every(h=>h[2]<=I*8)&&(i+=Math.hypot(...C(N(v[1],v[0]),N(v[2],v[0])))/2)}g("bed_contact").area_mm2=i,g("bed_contact").estimated=!0,g("bed_contact").count=i<=I**2?1:0,L("bed_contact","Contact area after virtually lowering this model onto an XY bed. Adhesion/stability are not predicted; scene placement is unchanged.");let o=X.min_wall_mm??X.line_width_mm;if(o!=null&&l.level==="detailed"&&k.volume_valid){_="Sampled wall thickness";let y=0,v=0,h=1/0,w=Math.max(1,Math.ceil(s/2048));for(let T=0;T<s;T+=w){f();let F=D(d,T),j=C(N(F[1],F[0]),N(F[2],F[0])),de=Math.hypot(...j),pe=j.map(V=>-V/de),ge=[0,1,2].map(V=>(F[0][V]+F[1][V]+F[2][V])/3),ee=ie(B,d,ge,pe,I*8,V=>V!==T,f).sort((V,_e)=>V.t-_e.t);if(!ee.length||ee[0].edge){v++;continue}y++,h=Math.min(h,ee[0].t),ee[0].t<o&&z("thin_walls",T)}Object.assign(g("thin_walls"),{estimated:!0,samples:y,unresolved_samples:v,minimum_sampled_mm:Number.isFinite(h)?h:null}),$("thin_walls",g("thin_walls").count?"issue":"inconclusive",`${y} face-centre samples; threshold ${o} mm. Sampling can miss thin features and does not prove a minimum wall thickness.`)}else o!=null&&$("thin_walls","inconclusive","Requires Detailed check with valid closed volume and confirmed units.")}}}catch(p){if(p.message!=="PRINT_TIME_LIMIT")throw p;for(let P of m)P.status==="not_run"&&(P.message=`Time limit reached during ${_}; this check was not completed.`);if(!q)for(let P of m.slice(0,8))P.status="inconclusive",P.message="Topology check exceeded the time limit; counts are partial.";k.limit_reason="time"}let E=m.slice(0,11);return k.summary=m.some(p=>p.status==="issue"&&p.severity!=="info")?"issues_found":E.some(p=>["not_run","inconclusive"].includes(p.status))||m.some(p=>p.status==="inconclusive")?"incomplete":"no_issues_found",k.elapsed_ms=performance.now()-n,k}export{Ae as a};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as y,b as M,c as F,d as v,e as $,f as k,g as E,h as S,i as I}from"./chunk-
|
|
1
|
+
import{a as y,b as M,c as F,d as v,e as $,f as k,g as E,h as S,i as I}from"./chunk-T6PPRDOE.js";import{a as j}from"./chunk-FUXP2W57.js";import{a as _}from"./chunk-W5KVLGVR.js";import"./chunk-6AW5U52H.js";function U(t,a){return`${String(t||"scene").split(/[\\/]/).pop().split(/[?#]/)[0].replace(/[<>:"|*\x00-\x1f\x7f]/g,"_").replace(/\.(?:stl|obj|3mf|step|stp|iges|igs|zip|vsb|vsj)$/i,"").replace(/[. ]+$/g,"").slice(0,160)||"scene"}.${a}`}function L(t={}){let a={stp:"step",igs:"iges"},l=String(t.format||"").toLowerCase(),f=a[l]||l;if(!["stl","obj","3mf","step","iges"].includes(f))throw new Error("Export format must be stl, obj, 3mf, step or iges");let n=t.units??"mm";if(!["mm","inch"].includes(n))throw new Error("Export units must be mm or inch");for(let m of["apply_transforms","colors"])if(t[m]!==void 0&&typeof t[m]!="boolean")throw new Error(`${m} must be a boolean`);if(t.on_progress!==void 0&&typeof t.on_progress!="function")throw new Error("on_progress must be a function");let e=t.colors!==!1&&["obj","3mf"].includes(f),p=f==="obj"&&e?"zip":f;return{format:f,units:n,colors:e,apply_transforms:t.apply_transforms!==!1,filename:U(t.filename,p)}}function A(t,a){let l=t.reduce((n,e)=>n+e.geometry.triangles,0);return 67108864+l*{stl:192,obj:2400,"3mf":3e3,step:12e3,iges:4e3}[a.format]+t.length*4096}function z(t,a,l){let f=t.reduce((o,i)=>o+i.positions.length/9,0);if(f>4294967295)throw new Error("STL triangle count limit exceeded");a.add(84+f*50);let n=new Uint8Array(84);n.set(new TextEncoder().encode("Binary STL by ViewSTL 2")),new DataView(n.buffer).setUint32(80,f,!0);let e=[n],p,m,c=0,d=0;for(let o of t)for(let i=0;i<o.positions.length;i+=9){(!p||c===p.length)&&(p=new Uint8Array(Math.min(f-d,16384)*50),m=new DataView(p.buffer),e.push(p),c=0);let{vertices:r,normal:g}=$(o,i),w=[...g,...r.flat()];for(let s=0;s<w.length;s++){if(!Number.isFinite(Math.fround(w[s])))throw new Error("STL coordinate exceeds float32 range");m.setFloat32(c+s*4,w[s],!0)}c+=50,d++,l()}return new Blob(e,{type:"model/stl"})}async function D(t,a,l,f,n){let e=new v(l),p=new v(l),m=new Map;e.write(`# ViewSTL mesh export; units: ${a.units}
|
|
2
2
|
`),a.colors&&e.write(`mtllib materials.mtl
|
|
3
3
|
`);let c=0,d=0,o;for(let r of t){let g=String(r.name).replace(/[^\p{L}\p{N}_.-]/gu,"_").slice(0,160)||"model";e.write(`o model_${r.id}_${g}
|
|
4
4
|
s off
|
|
@@ -11,7 +11,7 @@ illum 1
|
|
|
11
11
|
`),o=x)}for(let u of s)e.write(`v ${u.map(y).join(" ")}
|
|
12
12
|
`);e.write(`vn ${h.map(y).join(" ")}
|
|
13
13
|
`),d++,e.write(`f ${[1,2,3].map(u=>`${c+u}//${d}`).join(" ")}
|
|
14
|
-
`),c+=3,n()}}let i=e.finish();return a.colors?(await import("./export-zip-
|
|
14
|
+
`),c+=3,n()}}let i=e.finish();return a.colors?(await import("./export-zip-I2ADLFJI.js")).zipExport([["model.obj",i],["materials.mtl",p.finish()]],f):new Blob(i,{type:"model/obj"})}function C(t){let a=[],l=new Map,f=new Uint32Array(t.positions.length/3),n=new Map,e=0,p=0,m;for(let c=0;c<t.positions.length;c+=9){let{vertices:d,degenerate:o}=$(t,c);if(o)throw new Error("3MF export requires non-degenerate triangles");m??=d[0];let[i,r,g]=d.map(s=>s.map((h,u)=>h-m[u]));p+=i[0]*(r[1]*g[2]-r[2]*g[1])+i[1]*(r[2]*g[0]-r[0]*g[2])+i[2]*(r[0]*g[1]-r[1]*g[0]);let w=d.map(s=>{let h=s.map(y).join(","),u=l.get(h);return u===void 0&&(u=a.length,l.set(h,u),a.push(s)),u});f.set(w,e),e+=3;for(let s=0;s<3;s++){let h=w[s],u=w[(s+1)%3],x=Math.min(h,u)+":"+Math.max(h,u),b=n.get(x)||{count:0,direction:0};b.count++,b.direction+=h<u?1:-1,n.set(x,b)}}for(let c of n.values())if(c.count!==2||c.direction!==0)throw new Error("3MF export requires closed meshes with consistent triangle winding; use STL or OBJ for open surfaces");if(!(p>0))throw new Error("3MF export requires positive mesh volume and outward triangle winding");return{points:a,indices:f}}async function B(t,a,l,f,n){let e=new v(l),p=new Map,m=(i,r)=>E(k(i,r),i.opacity);if(a.colors)for(let i of t)for(let r=0;r<i.positions.length;r+=3){let g=m(i,r);p.has(g)||p.set(g,p.size)}if(e.write(`<?xml version="1.0" encoding="UTF-8"?>
|
|
15
15
|
<model unit="${a.units==="inch"?"inch":"millimeter"}" xml:lang="en-US" xmlns="http://schemas.microsoft.com/3dmanufacturing/core/2015/02"${a.colors?' xmlns:m="http://schemas.microsoft.com/3dmanufacturing/material/2015/02" recommendedextensions="m"':""}>
|
|
16
16
|
<metadata name="Application">ViewSTL</metadata>
|
|
17
17
|
<resources>
|
|
@@ -26,4 +26,4 @@ illum 1
|
|
|
26
26
|
`)}e.write(`</resources><build>
|
|
27
27
|
`),t.forEach((i,r)=>e.write(`<item objectid="${r+2}"/>
|
|
28
28
|
`)),e.write(`</build></model>
|
|
29
|
-
`);let c=i=>{let r=new v(l);return r.write(i),r.finish()},d=[["3D/3dmodel.model",e.finish()],["[Content_Types].xml",c('<?xml version="1.0" encoding="UTF-8"?><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>')],["_rels/.rels",c('<?xml version="1.0" encoding="UTF-8"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rel0" Type="http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel" Target="/3D/3dmodel.model"/></Relationships>')]],o=(await import("./export-zip-
|
|
29
|
+
`);let c=i=>{let r=new v(l);return r.write(i),r.finish()},d=[["3D/3dmodel.model",e.finish()],["[Content_Types].xml",c('<?xml version="1.0" encoding="UTF-8"?><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>')],["_rels/.rels",c('<?xml version="1.0" encoding="UTF-8"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rel0" Type="http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel" Target="/3D/3dmodel.model"/></Relationships>')]],o=(await import("./export-zip-I2ADLFJI.js")).zipExport(d,f);return o.slice(0,o.size,"model/3mf")}async function K(t,a,l=j,f=()=>{}){let n=L(a);if(!Array.isArray(t)||!t.length)throw new Error("No models to export");let e=0;for(let o of t){if(!(o.positions instanceof Float32Array)||!o.positions.length||o.positions.length%9)throw new Error("Invalid export geometry");if(o.matrix?.length!==16||Array.from(o.matrix).some(i=>!Number.isFinite(i)))throw new Error("Invalid export transform");if(o.colors&&(!(o.colors instanceof Float32Array)||o.colors.length!==o.positions.length))throw new Error("Invalid export colors");if(n.colors){for(let i of[o.colors,o.color])if(i){for(let r of i)if(!Number.isFinite(r)||r<0||r>1)throw new Error("Invalid export colors")}if(!Number.isFinite(o.opacity)||o.opacity<0||o.opacity>1)throw new Error("Invalid export opacity")}e+=o.positions.length/9}if(e>l.max_triangles)throw new Error("Export triangle limit exceeded");_(l,A(t.map(o=>({geometry:{triangles:o.positions.length/9}})),n),"export");let p=n.format==="3mf"||n.format==="obj"&&n.colors,m=new F(p?l.max_uncompressed_bytes:l.max_file_bytes),c=I(e,f),d;if(n.format==="stl")d=z(t,m,c);else if(n.format==="obj")d=await D(t,n,m,l,c);else if(n.format==="3mf")d=await B(t,n,m,l,c);else{let o=await import("./export-cad-XOXIE726.js");d=n.format==="step"?o.writeSTEP(t,n,m,c):o.writeIGES(t,n,m,c)}return f({loaded:e,total:e,phase:"complete"}),{blob:d,filename:n.filename,format:n.format,units:n.units,model_ids:t.map(o=>o.id),triangles:e,representation:"mesh"}}export{K as exportGeometry};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as w,d as u,e as H}from"./chunk-
|
|
1
|
+
import{a as w,d as u,e as H}from"./chunk-T6PPRDOE.js";import{c as G,e as x}from"./chunk-6AW5U52H.js";var X=p=>{let N=w(p).toUpperCase(),[I,$]=N.split("E");return(I.includes(".")?I:I+".")+($===void 0?"":"E"+$)},v=p=>"'"+String(p).replace(/[\x00-\x1f\x7f]/g," ").replace(/['\\\u0080-\uffff]/g,N=>N==="'"?"''":N==="\\"?"\\\\":"\\X2\\"+N.charCodeAt(0).toString(16).padStart(4,"0").toUpperCase()+"\\X0\\")+"'";function ee(p,N,I,$){let E=new u(I);E.write(`ISO-10303-21;
|
|
2
2
|
HEADER;
|
|
3
3
|
FILE_DESCRIPTION(('ViewSTL mesh surfaces'),'2;1');
|
|
4
4
|
`),E.write(`FILE_NAME('scene.step','${new Date().toISOString().slice(0,19)}',(''),(''),'ViewSTL','ViewSTL','');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as a}from"./chunk-
|
|
1
|
+
import{c as a}from"./chunk-T6PPRDOE.js";import{b as c,c as f}from"./chunk-ZSV4PTIA.js";import"./chunk-6AW5U52H.js";function w(r,o){if(r.length>o.max_archive_entries)throw new Error("Export archive entry limit exceeded");let p=[],s=new a(o.max_file_bytes),i=new f((e,t)=>{if(e)throw e;s.add(t.byteLength),p.push(t)});for(let[e,t]of r){let n=new c(e,{level:6});i.add(n);for(let u of t)n.push(u,!1);n.push(new Uint8Array,!0)}return i.end(),new Blob(p,{type:"application/zip"})}export{w as zipExport};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i}from"./chunk-V6KYGP62.js";import"./chunk-LFTKNL2V.js";import{e as a}from"./chunk-FUXP2W57.js";import"./chunk-W5KVLGVR.js";import{i as r}from"./chunk-6AW5U52H.js";function f(o,s=()=>{}){let{positions:t,scale:m,area:l,limits:n}=o,c=a({positions:t,area:l,volume:0},m).area,e=i({positions:t,matrix:r({x:0,y:0,z:0,rotationx:0,rotationy:0,rotationz:0,center:[0,0,0],scaleVector:m})},{level:"detailed",max_time_ms:o.max_time_ms},n,s),d=e.checks.find(u=>u.code==="shell_orientation");return{area_mm2:c,volume_mm3:e.volume_valid?e.volume_mm3:null,volume_valid:e.volume_valid,volume_reason:e.volume_valid?"Closed, consistently oriented mesh; no intersections detected.":d.message}}export{f as measure};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-V6KYGP62.js";import"./chunk-LFTKNL2V.js";import"./chunk-W5KVLGVR.js";import"./chunk-6AW5U52H.js";export{a as checkMesh};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as a}from"./chunk-
|
|
1
|
+
import{c as a}from"./chunk-CVGQTUJ5.js";import"./chunk-ZSV4PTIA.js";import{f as p}from"./chunk-FUXP2W57.js";import"./chunk-W5KVLGVR.js";import"./chunk-6AW5U52H.js";function g(i,t,l,n){let o=[];for(let e of t)o.push({id:e.id,bin:p(e,e.scale,e.center)}),n({loaded:o.length,total:t.length,phase:"exporting"});n({loaded:t.length,total:t.length,phase:"packaging"});let c=a({vsj:i,files:o},l);return n({loaded:t.length,total:t.length,phase:"complete"}),new Blob([c],{type:"application/zip"})}export{g as exportSceneArchive};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-LFTKNL2V.js";import{b as S}from"./chunk-CVGQTUJ5.js";import"./chunk-ZSV4PTIA.js";import{b as y}from"./chunk-FUXP2W57.js";import"./chunk-W5KVLGVR.js";import"./chunk-6AW5U52H.js";var _=["x","y","z","rotationx","rotationy","rotationz","scalex","scaley","scalez"],c=e=>e.startsWith("scale"),f=(e,n,r=!1)=>{if(typeof e!="number"||!Number.isFinite(e)||Math.abs(e)>Number.MAX_SAFE_INTEGER||r&&e<=0)throw new Error(`Invalid animation ${n}`);return e},h=(e,n)=>{if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`Invalid animation ${n}`);return e};function k(e){return Object.fromEntries(_.map(n=>[n,f(e[n]??(c(n)?e.scale??1:0),n,c(n))]))}function b(e){h(e,"definition");let n={},r=new Set;for(let t of["delta","exact"]){if(e[t]==null)continue;let o=h(e[t],t),s={},a=f(o.msec??300,"duration",!0);if(o.loop!==void 0&&typeof o.loop!="boolean")throw new Error("Animation loop must be a boolean");let i=t==="delta"&&!!o.loop;for(let l of _){let m=o[l]??(c(l)?o.scale:void 0);if(m!==void 0){if(r.has(l))throw new Error(`Animation delta/exact conflict: ${l}`);if(f(m,l,t==="exact"&&c(l)),i&&c(l)&&m<0)throw new Error("Looping scale deltas cannot be negative");s[l]=m,r.add(l)}}if(!Object.keys(s).length)throw new Error("Animation track needs a transform");n[t]={...s,msec:a,...i?{loop:!0}:{}}}if(!Object.keys(n).length)throw new Error("Animation needs delta or exact");return n}function x(e){if(h(e,"playback state"),e.version!==1||typeof e.paused!="boolean")throw new Error("Invalid animation playback state version or paused flag");let n=f(e.elapsed_ms,"elapsed time");if(n<0)throw new Error("Invalid animation elapsed time");h(e.origin,"origin");for(let r of _)f(e.origin[r],r,c(r));if(!Array.isArray(e.center)||e.center.length!==3)throw new Error("Invalid animation pivot");return{version:1,elapsed_ms:n,paused:e.paused,origin:k(e.origin),center:e.center.map(r=>f(r,"pivot"))}}function z(e,n,r){let t=b(e),o=r==null?null:x(r),s=o?.origin??k(n),a=Object.entries(t).map(([l,m])=>{let p=Object.entries(m).filter(([u])=>_.includes(u));if(l==="delta")for(let[u,P]of p)f(s[u]+P,`${u} endpoint`,c(u));return{mode:l,values:p,duration:m.msec,loop:!!m.loop,done:!1}}),i={animation:t,origin:s,tracks:a,elapsed_ms:o?.elapsed_ms??0,paused:o?.paused??!1,last_time:null};return O({...i,tracks:a.map(l=>({...l}))},{}),i}function O(e,n){let r=[];for(let o of e.tracks){if(o.done)continue;let s=e.elapsed_ms/o.duration,a=o.loop?s:Math.min(s,1);for(let[i,l]of o.values){let m=e.origin[i],p=o.mode==="delta"?m+l*a:m*(1-a)+l*a;r.push([i,f(p,`${i} result`,c(i))])}}let t=!1;for(let[o,s]of r)t||=c(o)&&n[o]!==s,n[o]=s;for(let o of e.tracks)!o.loop&&e.elapsed_ms>=o.duration&&(o.done=!0);return t&&(n._stats=null),e.tracks.some(o=>!o.done)}var g=["x","y","z"];function E(e){if(!["mm","inch"].includes(e))throw new Error("Choose mm or inch");return e}function A(e){if(!e||e.version!==1||!Array.isArray(e.baseline_mm)||e.baseline_mm.length!==3||e.baseline_mm.some(n=>!Number.isFinite(n)||n<0||n>1e12)||typeof e.editable!="boolean"||e.unit_factor!==void 0&&(!Number.isFinite(e.unit_factor)||e.unit_factor<=0||e.unit_factor>1e12))throw new Error("Invalid saved model size");return{version:1,baseline_mm:[...e.baseline_mm],file_units:E(e.file_units),editable:e.editable,unit_factor:e.unit_factor??1}}function M(e){if(!Array.isArray(e)||e.length>32)throw new Error("Save up to 32 camera views");let n=new Set;return e.map(r=>{let t=typeof r?.name=="string"?r.name.trim():"";if(!t||t.length>80||/[\x00-\x1f]/.test(t)||n.has(t))throw new Error("Use a unique view name of 1\u201380 characters");n.add(t);let o={};for(let i of["position","target","up"]){if(!r.camera?.[i]||g.some(l=>!Number.isFinite(r.camera[i][l])||Math.abs(r.camera[i][l])>1e15))throw new Error("Invalid saved camera");o[i]=Object.fromEntries(g.map(l=>[l,r.camera[i][l]]))}let s=g.map(i=>o.position[i]-o.target[i]),a=g.map(i=>o.up[i]);if(Math.hypot(s[1]*a[2]-s[2]*a[1],s[2]*a[0]-s[0]*a[2],s[0]*a[1]-s[1]*a[0])<1e-12)throw new Error("Degenerate saved camera");return{name:t,camera:o}})}var F=["flat","smooth","wireframe","edges","mesh","xray","studio","orientation"];function j(e,n){if(!F.includes(e))throw new Error("Invalid display mode");if(typeof n!="boolean")throw new Error("smooth_shading must be a boolean");return{display:e,smooth_shading:e==="smooth"||n}}function I(e){if(e==null)return null;if(!["x","y","z"].includes(e.axis))throw new Error("Section axis must be x, y or z");if(!Number.isFinite(e.position)||e.position<0||e.position>1)throw new Error("Section position must be between 0 and 1");if(e.flip!==void 0&&typeof e.flip!="boolean")throw new Error("Section flip must be a boolean");return{axis:e.axis,position:e.position,flip:e.flip??!1}}var w=["x","y","z"],d=(e,n,r=!1)=>{if(typeof e!="number"||!Number.isFinite(e)||r&&e<=0)throw new Error(`Invalid scene ${n}`);return e},N=e=>String(e||"").match(/\.(vsb|vsj)(?:[?#]|$)/i)?.[1].toLowerCase()||"";function v(e,n){if(!e||!Array.isArray(e.models)||!e.models.length||e.models.length>n.max_archive_entries)throw new Error("Invalid, empty or oversized scene manifest");let r={models:[]};e.camera_bookmarks!==void 0&&(r.camera_bookmarks=M(e.camera_bookmarks)),e.display_units!==void 0&&(r.display_units=E(e.display_units));for(let t of["center_models","auto_rotate","grid"])if(e[t]!==void 0){if(typeof e[t]!="boolean")throw new Error(`Invalid scene ${t}`);r[t]=e[t]}if(e.bg_color!==void 0&&(e.bg_color!=="transparent"&&y(e.bg_color),r.bg_color=e.bg_color),e.infinite_grid&&(r.infinite_grid={spacing:d(e.infinite_grid.spacing,"grid spacing",!0),height:d(e.infinite_grid.height,"grid height")}),e.camera_state){let t={};for(let a of["position","target","up"])t[a]=Object.fromEntries(w.map(i=>[i,d(e.camera_state[a]?.[i],"camera")]));let o=w.map(a=>t.position[a]-t.target[a]),s=w.map(a=>t.up[a]);if(!Math.hypot(...o)||!Math.hypot(...s)||!Math.hypot(o[1]*s[2]-o[2]*s[1],o[2]*s[0]-o[0]*s[2],o[0]*s[1]-o[1]*s[0]))throw new Error("Invalid scene camera");r.camera_state=t}for(let t of e.models){if(!t||typeof t.filename!="string"||!t.filename||t.filename.length>8192||/[\x00-\x1f\x7f]/.test(t.filename))throw new Error("Scene model filename is missing or invalid");if(N(t.filename))throw new Error("Nested scene references are not supported");let o={filename:t.filename};typeof t.orig_filename=="string"&&(o.orig_filename=t.orig_filename.slice(0,200));for(let s of w)for(let a of["","rotation","scale"]){let i=a+s;t[i]!==void 0&&(o[i]=d(t[i],i,a==="scale"))}if(t.scale!==void 0&&(o.scale=d(t.scale,"scale",!0)),t.opacity!==void 0&&(o.opacity=d(t.opacity,"opacity"),o.opacity<0||o.opacity>1))throw new Error("Invalid scene opacity");if(t.color!=null&&(t.color!=="transparent"&&y(t.color),o.color=t.color),o.units=t.units??"mm",!["mm","inch"].includes(o.units))throw new Error("Invalid scene units");if(Object.assign(o,j(t.display??"flat",t.smooth_shading??t.display==="smooth")),o.section=I(t.section),t.view_edges!==void 0&&typeof t.view_edges!="boolean")throw new Error("Invalid scene edges");if(o.view_edges=!!t.view_edges,t.animation!=null&&(o.animation=b(t.animation)),t.animation_state!=null){if(!o.animation)throw new Error("Playback state needs an animation");o.animation_state=x(t.animation_state)}if(o.animation&&z(o.animation,o,o.animation_state),t.size_state!==void 0&&(o.size_state=A(t.size_state)),t.display_name!==void 0){if(typeof t.display_name!="string"||t.display_name.length>1024)throw new Error("Invalid model name");o.display_name=t.display_name}r.models.push(o)}return r}function te(e,n,r){let t=Object.create(null),o=e;if(n==="vsb"){let s=S(e,r);if(o=s.get("json_data.vsj"),!o)throw new Error("VSB manifest json_data.vsj is missing");let a=v(JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(o)),r);for(let i of a.models){let l=s.get(i.filename);if(!l)throw new Error("VSB model file is missing: "+i.filename);t[i.filename]=l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength)}return{scene:a,files:t}}return{scene:v(JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(o)),r),files:null}}export{te as readSceneDocument};
|