slicer-studio 0.0.0-stage → 0.1.0
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/LICENSE +15 -0
- package/README.md +301 -2
- package/dist/chunks/ModelPreview-CYVyGDd1.js +61 -0
- package/dist/chunks/StudioContext-CsxoZNKd.js +1 -0
- package/dist/chunks/Viewer3D-o2piEXHZ.js +60 -0
- package/dist/chunks/features-6cCl0G7E.js +1 -0
- package/dist/chunks/files-uJ4WD9Mr.js +1 -0
- package/dist/chunks/fonts-DxaZCWS1.js +1 -0
- package/dist/chunks/model-read-UJhMfy15.js +5 -0
- package/dist/chunks/rolldown-runtime-XKyaHtl9.js +1 -0
- package/dist/chunks/three.module-MNvRIzJI.js +4220 -0
- package/dist/chunks/thumbnail-21laMIqI.js +1 -0
- package/dist/chunks/tip-C-Kdakwj.js +5 -0
- package/dist/chunks/useThemeColors-Dpdj0pe9.js +12 -0
- package/dist/slicer-studio.js +56 -0
- package/package.json +53 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kerala Startup Mission
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,302 @@
|
|
|
1
|
-
#
|
|
1
|
+
# slicer-studio
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A 3D printing studio as one custom element. Put `<slicer-studio>` on a page, on any stack, and customers can upload
|
|
4
|
+
their models and see what printing them costs, or staff can slice them and inspect the G-code. It brings its own React,
|
|
5
|
+
and a shadow root keeps its styles and your page's apart.
|
|
6
|
+
|
|
7
|
+
It needs a running [slicer-api](https://github.com/kerala-startup-mission/slicer-api), which does the slicing and holds
|
|
8
|
+
your printers and prices.
|
|
9
|
+
|
|
10
|
+
## Quick start
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install slicer-studio
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
import 'slicer-studio';
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<slicer-studio api-url="https://api.example.com"></slicer-studio>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Without a bundler, load it from a CDN:
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/slicer-studio/dist/slicer-studio.js"></script>
|
|
28
|
+
<slicer-studio api-url="https://api.example.com"></slicer-studio>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Then allow your site on the API, under [Set up the API](#set-up-the-api).
|
|
32
|
+
|
|
33
|
+
## Attributes
|
|
34
|
+
|
|
35
|
+
| Attribute | Values | Default |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| `api-url` | The slicer-api address | The page's own origin |
|
|
38
|
+
| `mode` | `quote` (the price page) or `advanced` (the staff tools) | `quote` |
|
|
39
|
+
| `theme` | `light`, `dark` or `system`. Setting it hides the theme switch | Follows the device, with a switch for the visitor |
|
|
40
|
+
| `config` | JSON of the options below | Nothing overridden |
|
|
41
|
+
|
|
42
|
+
The studio takes the width it is given, and lays itself out by that width, not the screen's. `quote` is as tall as its
|
|
43
|
+
content. `advanced` fills `100dvh`; set your own `height` on the element to change that.
|
|
44
|
+
|
|
45
|
+
## Options
|
|
46
|
+
|
|
47
|
+
Set `config` as a property, or as a JSON attribute, which suits server templates. Every key is optional.
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
document.querySelector('slicer-studio').config = {
|
|
51
|
+
// the same names as printers.json, and they win over it
|
|
52
|
+
currency: 'INR',
|
|
53
|
+
pricePerGram: { PLA: 5, PETG: 6 }, // only these materials change
|
|
54
|
+
priceRange: 15,
|
|
55
|
+
regularMode: { supports: false, mode: 'estimate' },
|
|
56
|
+
contact: { name: 'Acme Labs', email: 'hello@example.com' },
|
|
57
|
+
defaultPrinter: 'Bambu Lab P1S 0.4 nozzle',
|
|
58
|
+
|
|
59
|
+
// the choices a customer starts with
|
|
60
|
+
defaults: { material: 'PETG', quality: 'medium', infill: 20, walls: 4 },
|
|
61
|
+
|
|
62
|
+
// the cards to show; all of them when left out
|
|
63
|
+
cards: ['model', 'files', 'material', 'cost'],
|
|
64
|
+
};
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
| Key | Meaning |
|
|
68
|
+
|---|---|
|
|
69
|
+
| `currency` | A code such as `INR` or `USD` |
|
|
70
|
+
| `pricePerGram` | Price per gram by material, merged over the API's |
|
|
71
|
+
| `priceRange` | Show costs, weights and times as a range: the calculated figure up to this percent more. `0` shows exact figures |
|
|
72
|
+
| `regularMode.supports` | Whether estimates include supports |
|
|
73
|
+
| `regularMode.mode` | `estimate` (instant, from the model's shape), `exact` (sliced by OrcaSlicer) or `auto` |
|
|
74
|
+
| `contact` | The lab's `name`, and the `email` that SLA and SLS enquiries go to |
|
|
75
|
+
| `defaultPrinter` | The printer for estimates, one the API has profiles for |
|
|
76
|
+
| `defaults` | `material`, `quality` (`standard`, `medium`, `high`), `infill` (10, 15, 20, then every 10 to 90) and `walls` (1 to 6). They apply to files added after they are set |
|
|
77
|
+
| `cards` | Which cards show. They keep their fixed order and the grid closes around the gaps |
|
|
78
|
+
|
|
79
|
+
Costs are worked out in the browser, so `currency`, `pricePerGram` and `priceRange` need nothing from the API. Anything
|
|
80
|
+
invalid is left out, with a warning in the console. `cards` and `defaults` apply to `quote` mode; the rest applies to both.
|
|
81
|
+
|
|
82
|
+
### Cards
|
|
83
|
+
|
|
84
|
+
The cards are `process`, `model`, `files`, `material` (material and finish), `strength`, `cost` and `contact` (shown for
|
|
85
|
+
SLA and SLS). Hiding one also takes away what it does:
|
|
86
|
+
|
|
87
|
+
| Hidden | What happens |
|
|
88
|
+
|---|---|
|
|
89
|
+
| `process` | Always FDM. The theme switch sits on this card, so it goes too |
|
|
90
|
+
| `material`, `strength` | Customers get the `defaults` values, which is how you fix a choice |
|
|
91
|
+
| `files` | One file at a time: a new file replaces the current one |
|
|
92
|
+
| `cost` | No Get the price button. Call `getPrice()` and show the `estimate` event yourself |
|
|
93
|
+
| `model` and `files` | Nowhere to add a file, so `model` stays, with a console warning |
|
|
94
|
+
|
|
95
|
+
## Events and methods
|
|
96
|
+
|
|
97
|
+
```js
|
|
98
|
+
const studio = document.querySelector('slicer-studio');
|
|
99
|
+
|
|
100
|
+
studio.addEventListener('estimate', e => {
|
|
101
|
+
const { currency, range, files } = e.detail;
|
|
102
|
+
console.log(`${range.low} to ${range.high} ${currency} for ${files.length} files`);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
studio.getPrice(); // what the Get the price button does
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`estimate` fires when every file is priced, and again when the totals change, such as when the customer changes the
|
|
109
|
+
copies. `getPrice()` fires it again if everything is already priced. The event's `detail` holds:
|
|
110
|
+
|
|
111
|
+
| Field | Meaning |
|
|
112
|
+
|---|---|
|
|
113
|
+
| `currency` | The currency code |
|
|
114
|
+
| `range` | `{ low, high }` for all the files, or `null` while a material has no price |
|
|
115
|
+
| `unpriced` | The materials with no price |
|
|
116
|
+
| `gramsRange`, `secondsRange` | `{ low, high }` weight in grams and print time in seconds |
|
|
117
|
+
| `quick` | `true` for estimates from the model's shape, not sliced |
|
|
118
|
+
| `files` | One entry each: `name`, `file` (the customer's `File`), `copies`, `settings`, `range`, `gramsRange`, `secondsRange` |
|
|
119
|
+
|
|
120
|
+
**Work the price out again on your server before you charge for it.** Anything in a browser can be changed, including
|
|
121
|
+
this event.
|
|
122
|
+
|
|
123
|
+
`modechange` fires when the Simple / Advanced switch is used, with `{ mode }` in its `detail`.
|
|
124
|
+
|
|
125
|
+
## Set up the API
|
|
126
|
+
|
|
127
|
+
Set these on slicer-api. Its README explains each one.
|
|
128
|
+
|
|
129
|
+
- `ALLOWED_ORIGINS`: the sites that embed the studio. Without it, browsers block calls from other sites.
|
|
130
|
+
- `RATE_LIMIT_PER_MIN`: turn this on for any API a public page can reach.
|
|
131
|
+
- `TRUST_PROXY`: how many proxies sit in front of the API.
|
|
132
|
+
- Leave `API_KEY` unset behind a public price page. There is deliberately no attribute for a key: anything in a page's
|
|
133
|
+
source is public.
|
|
134
|
+
|
|
135
|
+
Each deployment has one `printers.json`, so a lab runs its own API for its own printers and prices.
|
|
136
|
+
|
|
137
|
+
## On your stack
|
|
138
|
+
|
|
139
|
+
**Laravel.** Import it in `resources/js/app.js`, then in a Blade template:
|
|
140
|
+
|
|
141
|
+
```blade
|
|
142
|
+
<slicer-studio api-url="{{ config('services.slicer.url') }}" config='@json($studio)'></slicer-studio>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Vue.** Tell the compiler it's a custom element, in `vite.config.js`:
|
|
146
|
+
|
|
147
|
+
```js
|
|
148
|
+
vue({ template: { compilerOptions: { isCustomElement: tag => tag === 'slicer-studio' } } })
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
```vue
|
|
152
|
+
<slicer-studio api-url="https://api.example.com" :config.prop="options" @estimate="onEstimate" />
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**React 19** passes properties and events straight through:
|
|
156
|
+
|
|
157
|
+
```jsx
|
|
158
|
+
<slicer-studio api-url="https://api.example.com" config={options} onestimate={onEstimate} />
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**React 18 and older** only set attributes, so use JSON and a ref:
|
|
162
|
+
|
|
163
|
+
```jsx
|
|
164
|
+
const studio = useRef(null);
|
|
165
|
+
useEffect(() => {
|
|
166
|
+
const el = studio.current;
|
|
167
|
+
el.addEventListener('estimate', onEstimate);
|
|
168
|
+
return () => el.removeEventListener('estimate', onEstimate);
|
|
169
|
+
}, []);
|
|
170
|
+
|
|
171
|
+
<slicer-studio ref={studio} api-url="https://api.example.com" config={JSON.stringify(options)} />
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Server rendering is safe: on a server the import does nothing, and the element starts in the browser.
|
|
175
|
+
|
|
176
|
+
## Good to know
|
|
177
|
+
|
|
178
|
+
- **Size:** about 210 kB gzipped to start, with the 3D view (about 250 kB) and the fonts (about 240 kB) loading after.
|
|
179
|
+
- **Content Security Policy:** Advanced's G-code reader needs `worker-src blob:`. Fonts load as data URIs, so `font-src`
|
|
180
|
+
needs `data:`.
|
|
181
|
+
- **Browsers:** recent Chrome, Edge and Firefox, and Safari 16.4 or newer.
|
|
182
|
+
- **One studio per page:** a second works, but both show every toast.
|
|
183
|
+
- **Popups** stay inside your page's stacking context, so a host element with a `transform`, or a higher `z-index`, can
|
|
184
|
+
cover them.
|
|
185
|
+
- **Theming:** colours can't be overridden yet.
|
|
186
|
+
|
|
187
|
+
## What's inside: the price page
|
|
188
|
+
|
|
189
|
+
This is `mode="quote"`.
|
|
190
|
+
|
|
191
|
+
A bento of tiles: the customer's model is the big one, the choices sit around it, and the price is the black tile.
|
|
192
|
+
Phones get one column in reading order. Every estimate uses the lab's default printer, and supports and exact or
|
|
193
|
+
quick estimates follow the config (`regularMode`), so the customer is never asked about them.
|
|
194
|
+
|
|
195
|
+
- **How should we print it?** FDM (filament), SLA (resin) or SLS (nylon powder), for all the files.
|
|
196
|
+
- **FDM** is priced here, with the tiles below.
|
|
197
|
+
- **SLA and SLS** are quoted by the lab's team for now: their tile says what the process is good for and has an
|
|
198
|
+
"Email us about SLA / SLS" button, a ready email to `contact.email` listing the customer's files (the button
|
|
199
|
+
hides while no email is set).
|
|
200
|
+
- **Model**: drop one model or several anywhere on the page, or choose them; up to 10, each up to 50 MB. The
|
|
201
|
+
selected model stands on a plate, with its size and size lines around it. The toolbar centres the model, zooms, shows or hides the size lines and goes
|
|
202
|
+
fullscreen; the axes in the corner turn with the view, and clicking a letter looks along that axis; **Reset view**
|
|
203
|
+
goes back to the starting angle. STL, 3MF and OBJ are previewed; STEP and IGES can't be, but are priced all the
|
|
204
|
+
same. No sliced layers here: those are for Advanced, whose model preview is the same viewer.
|
|
205
|
+
- **Your files**: a box to add more files, and a card for each, two to a page, with a picture of the model, its size and how it
|
|
206
|
+
stands. Once priced, a card shows the weight, print time and cost of all its copies, with a stepper for how many
|
|
207
|
+
(1 to 50); copies only multiply the figures, so changing them needs no new estimate. The choice tiles show the
|
|
208
|
+
selected file's settings; the ⋮ menu copies a file's settings (not its copies) to the other files, or
|
|
209
|
+
removes it. Choices made before uploading are what the first files start with.
|
|
210
|
+
- **Material** (PLA, PETG, ABS, TPU), **Finish** (a three-stop slider: Standard 0.2 mm, Fine 0.15 mm, Extra fine
|
|
211
|
+
0.1 mm) and **Strength** (infill 10% to 90%, walls 1 to 6), per file.
|
|
212
|
+
- **Estimated price**: "Get the price" works out each file that needs it, one after another (its card says why if
|
|
213
|
+
one fails; the others carry on). Cost, weight and time all show as ranges: the calculated figure rounded down, up to
|
|
214
|
+
`priceRange` percent more rounded up, in whole rupees, grams and minutes (₹21.93 with 20% reads ₹21 – ₹27), the
|
|
215
|
+
files' ranges added up, and the ⓘ says how the price is worked out. Print time assumes the prints run one after
|
|
216
|
+
another. After a change a warning says so and it offers "Update the price"; once everything is priced, **View
|
|
217
|
+
details** opens one line per file and the totals.
|
|
218
|
+
|
|
219
|
+
Customers never see a way into Advanced from this mode. Each mode keeps its own files, so switching starts the other
|
|
220
|
+
one fresh.
|
|
221
|
+
|
|
222
|
+
## What's inside: Advanced
|
|
223
|
+
|
|
224
|
+
This is `mode="advanced"`, with every option, for whoever runs the printers:
|
|
225
|
+
|
|
226
|
+
1. **Models**: one or several, as on the price page, with **Turn** buttons (tip forward, tip sideways, spin) to set which side the selected one prints on. Steps 2 to 4 are the
|
|
227
|
+
selected model's settings, so each model can have its own printer and presets; "Use for all" copies them to
|
|
228
|
+
the other models. Each row shows the model's weight and time once sliced, with the total under the list.
|
|
229
|
+
2. **Printer**: "Our printers" (from `printers.json`) come first. "My printer" uses the house templates in
|
|
230
|
+
slicer-api's `templates/`. Otherwise pick a brand, then a model,
|
|
231
|
+
then the nozzle; all of OrcaSlicer's printers are listed. The last printer is remembered.
|
|
232
|
+
3. **Material**: the materials that printer has profiles for; process and filament presets are under
|
|
233
|
+
"Process and filament presets".
|
|
234
|
+
4. **Print settings**: layer height, supports, and bars for infill and walls. "Default" sends nothing, so the printer's
|
|
235
|
+
own profile decides; the reset button next to a bar goes back to it.
|
|
236
|
+
|
|
237
|
+
"Slice model" (or "Slice 3 models") sends each model that needs it to `/api/quote` with `gcode=true`, one after
|
|
238
|
+
another, and the view opens the selected model's G-code; select another row to see its own. G-code you already have opens
|
|
239
|
+
with "Open G-code" (or drop it on the page), and so do sliced 3MF projects from Bambu Studio and OrcaSlicer
|
|
240
|
+
(`.gcode.3mf`): with several plates it asks which one, and shows the plate's thumbnail under print details.
|
|
241
|
+
These files are read in your browser, nothing is uploaded.
|
|
242
|
+
|
|
243
|
+
In the view, lines are colored by feature with the share of filament each uses. Click a feature to hide it,
|
|
244
|
+
Alt-click to see only it. The ruler on the right is the print's Z axis: drag its top and bottom handles to show
|
|
245
|
+
only those layers. Switch between 3D, top and front views, show travel moves, drag to orbit, scroll to zoom,
|
|
246
|
+
right-drag to pan. Weight, time and filament length are under the view; the info button has every detail.
|
|
247
|
+
|
|
248
|
+
If the API has `API_KEY` set, enter it with the key icon; it is kept in that browser.
|
|
249
|
+
|
|
250
|
+
## Working on this repo
|
|
251
|
+
|
|
252
|
+
Start slicer-api first (its `docker compose up --build -d` serves the API on port 3000).
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
npm install
|
|
256
|
+
npm run dev
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
It opens at http://localhost:5173, with `/api` and `/health` forwarded to port 3000 (set `API_URL` for another address).
|
|
260
|
+
`npm test` runs the tests. `npm run build` makes the package in `dist/`, and `npm run build:site` makes our own page in
|
|
261
|
+
`dist-site/`.
|
|
262
|
+
|
|
263
|
+
`src/element.js` is the element. It mounts `src/studio/Studio.jsx`, which picks the mode: the price page is
|
|
264
|
+
`components/quote/QuotePage.jsx` (with a component per card next to it) and Advanced is `components/AdvancedPage.jsx`.
|
|
265
|
+
What both share, the file list and slicing each file in turn, is `hooks/useModelFiles.js` on top of `lib/model-files.js`.
|
|
266
|
+
|
|
267
|
+
`patches/` fixes Radix UI, which reads `document.activeElement` and so can't see focus move inside a shadow root.
|
|
268
|
+
`npm install` applies the patches. When a Radix update comes, check that they still apply, and that arrow keys and Tab
|
|
269
|
+
still work in menus and dialogs.
|
|
270
|
+
|
|
271
|
+
### Our own page
|
|
272
|
+
|
|
273
|
+
`index.html` and `src/site.js` are the page we host: the element filling the window, with Advanced at `#advanced`.
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
docker compose up --build -d
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
It is at http://localhost:8080. nginx forwards `/api` and `/health` to `API_UPSTREAM`, which defaults to the API on the
|
|
280
|
+
same machine:
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
API_UPSTREAM=http://api.example.com:3000 docker compose up --build -d
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Sites can also embed this page in an iframe. Each time its height changes, it tells the parent page, which can size the
|
|
287
|
+
frame so it never scrolls inside:
|
|
288
|
+
|
|
289
|
+
```html
|
|
290
|
+
<iframe id="sfl-quote" src="https://quote.example.org/" title="3D printing prices" allow="fullscreen" style="width: 100%; border: 0; height: 900px"></iframe>
|
|
291
|
+
<script>
|
|
292
|
+
addEventListener('message', e => {
|
|
293
|
+
if (e.origin !== 'https://quote.example.org' || !e.data || e.data.type !== 'superfablab-quote:height') return;
|
|
294
|
+
document.getElementById('sfl-quote').style.height = e.data.height + 'px';
|
|
295
|
+
});
|
|
296
|
+
</script>
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
Replace `https://quote.example.org` with where this page is served. `allow="fullscreen"` lets the model preview go
|
|
300
|
+
fullscreen; without it that button stays away.
|
|
301
|
+
|
|
302
|
+
Built with React, react-three-fiber (three.js), Tailwind CSS, Radix UI, cmdk, Motion, TanStack Query, Lucide icons and Sonner.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{a as t,r as n}from"./StudioContext-CsxoZNKd.js";import{a as r,i,n as a,o,r as s,t as c}from"./tip-C-Kdakwj.js";import{r as l}from"./files-uJ4WD9Mr.js";import{E as u,G as d,H as f,M as p,N as m,Q as h,X as g,Z as _,_ as v,at as y,g as b,lt as x,o as S,ot as ee,p as te,r as ne,s as C,u as w,ut as re,v as T,y as ie,z as ae}from"./three.module-MNvRIzJI.js";import{a as E,c as D,d as O,f as k,i as oe,l as se,n as ce,o as le,s as A,t as ue,u as de}from"./useThemeColors-Dpdj0pe9.js";import{n as fe,t as pe}from"./model-read-UJhMfy15.js";var j={name:`crosshair`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`22`,x2:`18`,y1:`12`,y2:`12`,key:`l9bcsi`}],[`line`,{x1:`6`,x2:`2`,y1:`12`,y2:`12`,key:`13hhkx`}],[`line`,{x1:`12`,x2:`12`,y1:`6`,y2:`2`,key:`10w3f3`}],[`line`,{x1:`12`,x2:`12`,y1:`22`,y2:`18`,key:`15g9kq`}]]};j.node;var me=o(j),M={name:`maximize`,size:24,node:[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]};M.node;var he=o(M),N={name:`minimize`,size:24,node:[[`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`,key:`hohbtr`}],[`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`,key:`5jw1f3`}],[`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`,key:`198tvr`}],[`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`,key:`ph8mxp`}]]};N.node;var P=o(N),F={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};F.node;var I=o(F),L={name:`zoom-in`,size:24,node:[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`,key:`1vmskp`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]};L.node;var R=o(L),z={name:`zoom-out`,size:24,node:[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]};z.node;var ge=o(z);function _e(e,t,n,r){var i=class extends h{constructor(i){super({vertexShader:t,fragmentShader:n,...i});for(let t in e)this.uniforms[t]=new y(e[t]),Object.defineProperty(this,t,{get(){return this.uniforms[t].value},set(e){this.uniforms[t].value=e}});this.uniforms=ee.clone(this.uniforms),r?.(this)}};return i.key=p.generateUUID(),i}var ve=/* @__PURE__ */ parseInt(`186`.replace(/\D+/g,``)),B=/* @__PURE__ */ e(t());function ye(e,t,n){let r=k(e=>e.size),i=k(e=>e.viewport),a=typeof e==`number`?e:r.width*i.dpr,o=typeof t==`number`?t:r.height*i.dpr,s=(typeof e==`number`?n:e)||{},{samples:c=0,depth:l,...d}=s,f=l??s.depthBuffer,p=B.useMemo(()=>{let e=new re(a,o,{minFilter:u,magFilter:u,type:ie,...d});return f&&(e.depthTexture=new te(a,o,v)),e.samples=c,e},[]);return B.useLayoutEffect(()=>{p.setSize(a,o),c&&(p.samples=c)},[c,p,a,o]),B.useEffect(()=>()=>p.dispose(),[]),p}var be=e=>typeof e==`function`,xe=/* @__PURE__ */ B.forwardRef(({envMap:e,resolution:t=256,frames:n=1/0,children:r,makeDefault:i,...a},o)=>{let s=k(({set:e})=>e),c=k(({camera:e})=>e),l=k(({size:e})=>e),u=B.useRef(null);B.useImperativeHandle(o,()=>u.current,[]);let d=B.useRef(null),f=ye(t);B.useLayoutEffect(()=>{a.manual||u.current.updateProjectionMatrix()},[l,a]),B.useLayoutEffect(()=>{u.current.updateProjectionMatrix()}),B.useLayoutEffect(()=>{if(i){let e=c;return s(()=>({camera:u.current})),()=>s(()=>({camera:e}))}},[u,i,s]);let p=0,m=null,h=be(r);return O(t=>{h&&(n===1/0||p<n)&&(d.current.visible=!1,t.gl.setRenderTarget(f),m=t.scene.background,e&&(t.scene.background=e),t.gl.render(t.scene,u.current),t.scene.background=m,t.gl.setRenderTarget(null),d.current.visible=!0,p++)}),/*#__PURE__*/ B.createElement(B.Fragment,null,/*#__PURE__*/ B.createElement(`orthographicCamera`,A({left:l.width/-2,right:l.width/2,top:l.height/2,bottom:l.height/-2,ref:u},a),!h&&r),/*#__PURE__*/ B.createElement(`group`,{ref:d},h&&r(f.texture)))});function Se({defaultScene:e,defaultCamera:t,renderPriority:n=1}){let{gl:r,scene:i,camera:a}=k(),o;return O(()=>{o=r.autoClear,n===1&&(r.autoClear=!0,r.render(e,t)),r.autoClear=!1,r.clearDepth(),r.render(i,a),r.autoClear=o},n),/*#__PURE__*/ B.createElement(`group`,{onPointerOver:()=>null})}function Ce({children:e,renderPriority:t=1}){let{scene:n,camera:r}=k(),[i]=B.useState(()=>new _);return/*#__PURE__*/ B.createElement(B.Fragment,null,se(/*#__PURE__*/ B.createElement(B.Fragment,null,e,/*#__PURE__*/ B.createElement(Se,{defaultScene:n,defaultCamera:r,renderPriority:t})),i,{events:{priority:t+1}}))}var V=/* @__PURE__ */ B.createContext({}),we=()=>B.useContext(V),Te=2*Math.PI,H=/* @__PURE__ */ new ae,U=/* @__PURE__ */ new m,[W,G]=[/* @__PURE__ */ new d,/* @__PURE__ */ new d],K=/* @__PURE__ */ new x,q=/* @__PURE__ */ new x,Ee=e=>`minPolarAngle`in e,J=e=>`getTarget`in e,De=({alignment:e=`bottom-right`,margin:t=[80,80],renderPriority:n=1,onUpdate:r,onTarget:i,children:a})=>{let o=k(e=>e.size),s=k(e=>e.camera),c=k(e=>e.controls),l=k(e=>e.invalidate),u=B.useRef(null),d=B.useRef(null),f=B.useRef(!1),p=B.useRef(0),m=B.useRef(new x(0,0,0)),h=B.useRef(new x(0,0,0));B.useEffect(()=>{h.current.copy(s.up),H.up.copy(s.up)},[s]);let g=B.useCallback(e=>{f.current=!0,(c||i)&&(m.current=i?.()||(J(c)?c.getTarget(m.current):c?.target)),p.current=s.position.distanceTo(K),W.copy(s.quaternion),q.copy(e).multiplyScalar(p.current).add(K),H.lookAt(q),G.copy(H.quaternion),l()},[c,s,i,l]);O((e,t)=>{if(d.current&&u.current){var n;if(f.current){if(W.angleTo(G)<.01)f.current=!1,Ee(c)&&s.up.copy(h.current);else{let e=t*Te;W.rotateTowards(G,e),s.position.set(0,0,1).applyQuaternion(W).multiplyScalar(p.current).add(m.current),s.up.set(0,1,0).applyQuaternion(W).normalize(),s.quaternion.copy(W),J(c)&&c.setPosition(s.position.x,s.position.y,s.position.z),r?r():c&&c.update(t),l()}}U.copy(s.matrix).invert(),(n=u.current)==null||n.quaternion.setFromRotationMatrix(U)}});let _=B.useMemo(()=>({tweenCamera:g}),[g]),[v,y]=t,b=e.endsWith(`-center`)?0:e.endsWith(`-left`)?-o.width/2+v:o.width/2-v,S=e.startsWith(`center-`)?0:e.startsWith(`top-`)?o.height/2-y:-o.height/2+y;return/*#__PURE__*/ B.createElement(Ce,{renderPriority:n},/*#__PURE__*/ B.createElement(V.Provider,{value:_},/*#__PURE__*/ B.createElement(xe,{makeDefault:!0,ref:d,position:[0,0,200]}),/*#__PURE__*/ B.createElement(`group`,{ref:u,position:[b,S,0]},a)))},Oe=/* @__PURE__ */ _e({cellSize:.5,sectionSize:1,fadeDistance:100,fadeStrength:1,fadeFrom:1,cellThickness:.5,sectionThickness:1,cellColor:/* @__PURE__ */ new w,sectionColor:/* @__PURE__ */ new w,infiniteGrid:!1,followCamera:!1,worldCamProjPosition:/* @__PURE__ */ new x,worldPlanePosition:/* @__PURE__ */ new x},`
|
|
2
|
+
varying vec3 localPosition;
|
|
3
|
+
varying vec4 worldPosition;
|
|
4
|
+
|
|
5
|
+
uniform vec3 worldCamProjPosition;
|
|
6
|
+
uniform vec3 worldPlanePosition;
|
|
7
|
+
uniform float fadeDistance;
|
|
8
|
+
uniform bool infiniteGrid;
|
|
9
|
+
uniform bool followCamera;
|
|
10
|
+
|
|
11
|
+
void main() {
|
|
12
|
+
localPosition = position.xzy;
|
|
13
|
+
if (infiniteGrid) localPosition *= 1.0 + fadeDistance;
|
|
14
|
+
|
|
15
|
+
worldPosition = modelMatrix * vec4(localPosition, 1.0);
|
|
16
|
+
if (followCamera) {
|
|
17
|
+
worldPosition.xyz += (worldCamProjPosition - worldPlanePosition);
|
|
18
|
+
localPosition = (inverse(modelMatrix) * worldPosition).xyz;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
gl_Position = projectionMatrix * viewMatrix * worldPosition;
|
|
22
|
+
}
|
|
23
|
+
`,`
|
|
24
|
+
varying vec3 localPosition;
|
|
25
|
+
varying vec4 worldPosition;
|
|
26
|
+
|
|
27
|
+
uniform vec3 worldCamProjPosition;
|
|
28
|
+
uniform float cellSize;
|
|
29
|
+
uniform float sectionSize;
|
|
30
|
+
uniform vec3 cellColor;
|
|
31
|
+
uniform vec3 sectionColor;
|
|
32
|
+
uniform float fadeDistance;
|
|
33
|
+
uniform float fadeStrength;
|
|
34
|
+
uniform float fadeFrom;
|
|
35
|
+
uniform float cellThickness;
|
|
36
|
+
uniform float sectionThickness;
|
|
37
|
+
|
|
38
|
+
float getGrid(float size, float thickness) {
|
|
39
|
+
vec2 r = localPosition.xz / size;
|
|
40
|
+
vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);
|
|
41
|
+
float line = min(grid.x, grid.y) + 1.0 - thickness;
|
|
42
|
+
return 1.0 - min(line, 1.0);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void main() {
|
|
46
|
+
float g1 = getGrid(cellSize, cellThickness);
|
|
47
|
+
float g2 = getGrid(sectionSize, sectionThickness);
|
|
48
|
+
|
|
49
|
+
vec3 from = worldCamProjPosition*vec3(fadeFrom);
|
|
50
|
+
float dist = distance(from, worldPosition.xyz);
|
|
51
|
+
float d = 1.0 - min(dist / fadeDistance, 1.0);
|
|
52
|
+
vec3 color = mix(cellColor, sectionColor, min(1.0, sectionThickness * g2));
|
|
53
|
+
|
|
54
|
+
gl_FragColor = vec4(color, (g1 + g2) * pow(d, fadeStrength));
|
|
55
|
+
gl_FragColor.a = mix(0.75 * gl_FragColor.a, gl_FragColor.a, g2);
|
|
56
|
+
if (gl_FragColor.a <= 0.0) discard;
|
|
57
|
+
|
|
58
|
+
#include <tonemapping_fragment>
|
|
59
|
+
#include <${ve>=154?`colorspace_fragment`:`encodings_fragment`}>
|
|
60
|
+
}
|
|
61
|
+
`),ke=/* @__PURE__ */ B.forwardRef(({args:e,cellColor:t=`#000000`,sectionColor:n=`#2080ff`,cellSize:r=.5,sectionSize:i=1,followCamera:a=!1,infiniteGrid:o=!1,fadeDistance:s=100,fadeStrength:c=1,fadeFrom:l=1,cellThickness:u=.5,sectionThickness:d=1,side:p=1,...m},h)=>{de({GridMaterial:Oe});let g=B.useRef(null);B.useImperativeHandle(h,()=>g.current,[]);let _=new f,v=new x(0,1,0),y=new x(0,0,0);O(e=>{_.setFromNormalAndCoplanarPoint(v,y).applyMatrix4(g.current.matrixWorld);let t=g.current.material,n=t.uniforms.worldCamProjPosition,r=t.uniforms.worldPlanePosition;_.projectPoint(e.camera.position,n.value),r.value.set(0,0,0).applyMatrix4(g.current.matrixWorld)});let b={cellSize:r,sectionSize:i,cellColor:t,sectionColor:n,cellThickness:u,sectionThickness:d},S={fadeDistance:s,fadeStrength:c,fadeFrom:l,infiniteGrid:o,followCamera:a};return/*#__PURE__*/ B.createElement(`mesh`,A({ref:g,frustumCulled:!1},m),/*#__PURE__*/ B.createElement(`gridMaterial`,A({transparent:!0,"extensions-derivatives":!0,side:p},b,S)),/*#__PURE__*/ B.createElement(`planeGeometry`,{args:e}))}),Y=n(),Ae=[{name:`X`,dir:[1,0,0],color:`#e5484d`},{name:`Y`,dir:[0,1,0],color:`#30a46c`},{name:`Z`,dir:[0,0,1],color:`#3e7bfa`}];function je(e,t){let n=document.createElement(`canvas`);n.width=n.height=64;let r=n.getContext(`2d`);return r.fillStyle=t,r.font=`700 48px system-ui, sans-serif`,r.textAlign=`center`,r.textBaseline=`middle`,r.fillText(e,32,34),new C(n)}function Me({name:e,dir:t,color:n}){let{tweenCamera:r}=we(),i=(0,B.useMemo)(()=>new x(...t),[t]),a=(0,B.useMemo)(()=>new d().setFromUnitVectors(new x(0,1,0),i),[i]),o=(0,B.useMemo)(()=>je(e,n),[e,n]);return(0,B.useEffect)(()=>()=>o.dispose(),[o]),/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsxs)(`group`,{quaternion:a,children:[/* @__PURE__ */ (0,Y.jsxs)(`mesh`,{"position-y":.85,children:[/* @__PURE__ */ (0,Y.jsx)(`cylinderGeometry`,{args:[.04,.04,.7,8]}),/* @__PURE__ */ (0,Y.jsx)(`meshBasicMaterial`,{color:n})]}),/* @__PURE__ */ (0,Y.jsxs)(`mesh`,{"position-y":1.32,children:[/* @__PURE__ */ (0,Y.jsx)(`coneGeometry`,{args:[.12,.26,12]}),/* @__PURE__ */ (0,Y.jsx)(`meshBasicMaterial`,{color:n})]})]}),/* @__PURE__ */ (0,Y.jsx)(`sprite`,{position:i.clone().multiplyScalar(1.8),scale:.62,onClick:e=>{e.stopPropagation(),r(i)},children:/* @__PURE__ */ (0,Y.jsx)(`spriteMaterial`,{map:o,transparent:!0,depthWrite:!1})})]})}function Ne(){let e=k(e=>e.size.width)<576;return/* @__PURE__ */ (0,Y.jsx)(De,{alignment:`bottom-left`,margin:e?[48,48]:[72,72],children:/* @__PURE__ */ (0,Y.jsxs)(`group`,{scale:e?18:28,children:[/* @__PURE__ */ (0,Y.jsx)(`ambientLight`,{intensity:1.6}),/* @__PURE__ */ (0,Y.jsx)(`directionalLight`,{position:[2,3,4],intensity:1.6}),/* @__PURE__ */ (0,Y.jsxs)(`mesh`,{children:[/* @__PURE__ */ (0,Y.jsx)(`boxGeometry`,{args:[1,1,1]}),/* @__PURE__ */ (0,Y.jsx)(`meshStandardMaterial`,{color:`#f4f6f4`,roughness:.6})]}),Ae.map(e=>/* @__PURE__ */ (0,Y.jsx)(Me,{...e},e.name))]})})}function Pe({min:[e,t,n],max:[r,i,a]},o){let s=o/2,c=t-o,l=e-o,u=e=>`${e.toFixed(1)} mm`;return[{axis:`x`,label:u(r-e),from:[e,c,n],to:[r,c,n],at:[(e+r)/2,c-o,n],ticks:[e,r].map(e=>[[e,c-s,n],[e,c+s,n]])},{axis:`y`,label:u(i-t),from:[l,t,n],to:[l,i,n],at:[l-o,(t+i)/2,n],ticks:[t,i].map(e=>[[l-s,e,n],[l+s,e,n]])},{axis:`z`,label:u(a-n),from:[l,i,n],to:[l,i,a],at:[l-o,i,(n+a)/2],ticks:[n,a].map(e=>[[l-s,i,e],[l+s,i,e]])}]}function Fe(e,t,n,r=1){let i=e.map((e,n)=>e-t[n]),a=Math.hypot(...i),o=Math.max(a*n,r);return t.map((e,t)=>e+i[t]/a*o)}var Ie=16;function Le(e,t){let n=document.createElement(`canvas`),r=n.getContext(`2d`),i=`500 52px "Archivo Variable", system-ui, sans-serif`;r.font=i,n.width=Math.ceil(r.measureText(e).width)+8,n.height=64,r.font=i,r.fillStyle=t,r.textAlign=`center`,r.textBaseline=`middle`,r.fillText(e,n.width/2,n.height/2);let a=new C(n);return a.colorSpace=g,{texture:a,aspect:n.width/n.height}}function X({text:e,at:t,color:n}){let r=k(e=>e.size.height),i=k(e=>e.camera.fov),{texture:a,aspect:o}=(0,B.useMemo)(()=>Le(e,n),[e,n]);(0,B.useEffect)(()=>()=>a.dispose(),[a]);let s=Ie/r*2*Math.tan(p.degToRad(i/2));return/* @__PURE__ */ (0,Y.jsx)(`sprite`,{position:t,scale:[s*o,s,1],renderOrder:3,children:/* @__PURE__ */ (0,Y.jsx)(`spriteMaterial`,{map:a,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1})})}function Re({bounds:e,size:t,color:n}){let r=Math.max(6,.06*Math.max(...t)),i=(0,B.useMemo)(()=>Pe(e,r),[e,r]),a=(0,B.useMemo)(()=>{let e=i.flatMap(e=>[e.from,e.to,...e.ticks.flat()]).flat();return new S().setAttribute(`position`,new b(e,3))},[i]);return(0,B.useEffect)(()=>()=>a.dispose(),[a]),/* @__PURE__ */ (0,Y.jsxs)(`group`,{children:[/* @__PURE__ */ (0,Y.jsx)(`lineSegments`,{geometry:a,renderOrder:2,children:/* @__PURE__ */ (0,Y.jsx)(`lineBasicMaterial`,{color:n,transparent:!0,depthTest:!1})}),i.map(e=>/* @__PURE__ */ (0,Y.jsx)(X,{text:e.label,at:e.at,color:n},e.axis))]})}var Z=5e5;function ze(e,t){let n=new T;n.rotation.set(...t.map(p.degToRad),`ZYX`),n.add(e.clone()),n.updateMatrixWorld(!0);let r=new ne().setFromObject(n),i=new x(-(r.min.x+r.max.x)/2,-(r.min.y+r.max.y)/2,-r.min.z),a=new T;return a.position.copy(i),a.add(n),r.translate(i),{root:a,bounds:{min:r.min.toArray(),max:r.max.toArray()},size:r.getSize(new x).toArray()}}function Q({icon:e,tone:t=`text-muted`,children:n}){return/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`absolute inset-0 grid place-items-center p-6`,children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`max-w-sm text-center`,children:[/* @__PURE__ */ (0,Y.jsx)(e,{className:`mx-auto size-8 ${t}`,strokeWidth:1.6,"aria-hidden":!0}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`mt-3 text-[14px] text-muted`,children:n})]})})}function $({label:e,pressed:t,onClick:n,children:r}){return/* @__PURE__ */ (0,Y.jsx)(c,{label:e,children:/* @__PURE__ */ (0,Y.jsx)(`button`,{type:`button`,"aria-label":e,"aria-pressed":t,onClick:n,className:a(`grid size-9 place-items-center rounded-xl text-ink transition-colors hover:bg-raise`,t&&`bg-raise`),children:r})})}function Be({request:e}){let t=k(e=>e.camera),n=k(e=>e.controls),r=k(e=>e.invalidate);return(0,B.useEffect)(()=>{e&&n&&(t.position.fromArray(Fe(t.position.toArray(),n.target.toArray(),e.factor)),n.update(),r())},[e,n,t,r]),null}function Ve({placed:e,tooMany:t,customer:n}){let{root:i,bounds:a,size:o}=e,s=ue(),c=(0,B.useRef)(null),[l,u]=(0,B.useState)({view:`iso`,key:0}),[d,f]=(0,B.useState)(null),[p,m]=(0,B.useState)(!0),[h,g]=(0,B.useState)(!1);(0,B.useEffect)(()=>{let e=c.current.getRootNode(),t=()=>g(e.fullscreenElement===c.current);return document.addEventListener(`fullscreenchange`,t),()=>document.removeEventListener(`fullscreenchange`,t)},[]);let _=Math.max(...o,100),v=ce({meta:{},bounds:a});return/* @__PURE__ */ (0,Y.jsxs)(`div`,{ref:c,className:`@container absolute inset-0 bg-viewer`,children:[/* @__PURE__ */ (0,Y.jsxs)(D,{flat:!0,frameloop:`demand`,dpr:[1,2],camera:{fov:35,near:.1,far:1e4,up:[0,0,1],position:[0,-300,200]},children:[/* @__PURE__ */ (0,Y.jsx)(`color`,{attach:`background`,args:[s.background]}),/* @__PURE__ */ (0,Y.jsx)(`hemisphereLight`,{args:[`#ffffff`,`#b0b1b6`,1.5],position:[0,0,1]}),/* @__PURE__ */ (0,Y.jsx)(`directionalLight`,{position:[-150,-300,400],intensity:1.1}),/* @__PURE__ */ (0,Y.jsx)(`directionalLight`,{position:[250,120,120],intensity:.35}),/* @__PURE__ */ (0,Y.jsx)(ke,{position:[0,0,-_*.002],rotation:[Math.PI/2,0,0],infiniteGrid:!0,fadeFrom:0,fadeDistance:_*6,fadeStrength:2,cellSize:10,cellThickness:.6,cellColor:s.rule,sectionSize:50,sectionThickness:.9,sectionColor:s.grid,side:2}),/* @__PURE__ */ (0,Y.jsx)(E,{outline:v,colors:s}),/* @__PURE__ */ (0,Y.jsx)(`primitive`,{object:i}),p&&/* @__PURE__ */ (0,Y.jsx)(Re,{bounds:a,size:o,color:s.muted}),/* @__PURE__ */ (0,Y.jsx)(le,{makeDefault:!0,enableDamping:!0,dampingFactor:.12,screenSpacePanning:!0}),/* @__PURE__ */ (0,Y.jsx)(oe,{bounds:a,far:20*_,view:l.view,fitKey:l.key}),/* @__PURE__ */ (0,Y.jsx)(Be,{request:d}),/* @__PURE__ */ (0,Y.jsx)(Ne,{})]}),/* @__PURE__ */ (0,Y.jsx)(`div`,{className:`pointer-events-none absolute inset-x-3 top-3 z-10 flex flex-wrap items-start justify-between gap-2 [&>*]:pointer-events-auto`,children:/* @__PURE__ */ (0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5 rounded-2xl bg-panel/90 p-1 backdrop-blur`,children:[/* @__PURE__ */ (0,Y.jsx)($,{label:`Centre the model`,onClick:()=>u(e=>({view:`current`,key:e.key+1})),children:/* @__PURE__ */ (0,Y.jsx)(me,{className:`size-[18px]`,"aria-hidden":!0})}),/* @__PURE__ */ (0,Y.jsx)($,{label:`Zoom in`,onClick:()=>f({factor:.8}),children:/* @__PURE__ */ (0,Y.jsx)(R,{className:`size-[18px]`,"aria-hidden":!0})}),/* @__PURE__ */ (0,Y.jsx)($,{label:`Zoom out`,onClick:()=>f({factor:1.25}),children:/* @__PURE__ */ (0,Y.jsx)(ge,{className:`size-[18px]`,"aria-hidden":!0})}),/* @__PURE__ */ (0,Y.jsx)($,{label:`Reset view`,onClick:()=>u(e=>({view:`iso`,key:e.key+1})),children:/* @__PURE__ */ (0,Y.jsx)(I,{className:`size-[18px]`,"aria-hidden":!0})}),/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`mx-0.5 h-6 w-px bg-rule`,"aria-hidden":!0}),/* @__PURE__ */ (0,Y.jsx)($,{label:p?`Hide size lines`:`Show size lines`,pressed:p,onClick:()=>m(e=>!e),children:/* @__PURE__ */ (0,Y.jsx)(r,{className:`size-[18px]`,"aria-hidden":!0})}),document.fullscreenEnabled&&/* @__PURE__ */ (0,Y.jsxs)(Y.Fragment,{children:[/* @__PURE__ */ (0,Y.jsx)(`span`,{className:`mx-0.5 h-6 w-px bg-rule`,"aria-hidden":!0}),/* @__PURE__ */ (0,Y.jsx)($,{label:h?`Leave fullscreen`:`Fullscreen`,onClick:()=>(h?document.exitFullscreen():c.current.requestFullscreen()).catch(()=>{}),children:h?/* @__PURE__ */ (0,Y.jsx)(P,{className:`size-[18px]`,"aria-hidden":!0}):/* @__PURE__ */ (0,Y.jsx)(he,{className:`size-[18px]`,"aria-hidden":!0})})]})]})})]})}function He({file:e,rot:t=[0,0,0],customer:n=!1}){let a=n?`The price still works`:`Slicing still works`,o=l(e.name).format,[c,u]=(0,B.useState)({status:`loading`});(0,B.useEffect)(()=>{if(o===`step`||o===`iges`)return;let t=!0,n=null;u({status:`loading`});let r=setTimeout(()=>{fe(e,o).then(e=>{n=e,t&&u({status:`ready`,object:e,triangles:pe(e)})}).catch(e=>{t&&u(e.xml?{status:`large`,xml:e.xml}:{status:`error`})})},30);return()=>{t=!1,clearTimeout(r),n?.traverse(e=>e.geometry?.dispose())}},[e,o]);let[d,f,p]=t,m=(0,B.useMemo)(()=>c.object?ze(c.object,[d,f,p]):null,[c.object,d,f,p]);return c.status===`ready`&&o!==`step`&&o!==`iges`?/* @__PURE__ */ (0,Y.jsx)(Ve,{placed:m,tooMany:c.triangles>Z,customer:n}):o===`step`||o===`iges`?/* @__PURE__ */ (0,Y.jsx)(Q,{icon:r,children:n?`${o.toUpperCase()} files can’t be previewed here. The price still works.`:`A ${o.toUpperCase()} file becomes a mesh on the server, so its preview shows once it is sliced.`}):c.status===`loading`?/* @__PURE__ */ (0,Y.jsxs)(Q,{icon:i,tone:`text-muted animate-spin`,children:[`Loading preview of `,e.name]}):c.status===`large`?/* @__PURE__ */ (0,Y.jsxs)(Q,{icon:r,children:[e.name,` holds `,Math.round(c.xml/1e6),` MB of mesh data, roughly `,(Math.round(c.xml/85/1e4)*1e4).toLocaleString(`en`),` triangles, too much to preview here. `,a,` up to `,Z.toLocaleString(`en`),` triangles.`]}):/* @__PURE__ */ (0,Y.jsxs)(Q,{icon:s,tone:`text-warn`,children:[`No preview for `,e.name,`. `,n?`It may still be priced`:`It can still be sliced`,`; the server says so if it can’t read it.`]})}export{He as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./rolldown-runtime-XKyaHtl9.js";var n=/* @__PURE__ */ t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function M(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function N(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function P(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,P(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+M(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),P(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+M(a,u),c+=P(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+M(a,u++),c+=P(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return P(N(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function F(e,t,n){if(e==null)return e;var r=[],i=0;return P(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function I(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var L=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function R(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,L)}catch(e){L(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function z(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else R(z.bind(null,e))}var B={map:F,forEach:function(e,t,n){F(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return F(e,function(){t++}),t},toArray:function(e){return F(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=B,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=z,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:I}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=R,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.1`})),r=/* @__PURE__ */ t(((e,t)=>{t.exports=n()})),i=/* @__PURE__ */ t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),a=/* @__PURE__ */ t(((e,t)=>{t.exports=i()})),o=/* @__PURE__ */ t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),s=/* @__PURE__ */ t(((e,t)=>{t.exports=o()})),c=/* @__PURE__ */ e(r(),1),l=(0,c.createContext)(null),u=()=>(0,c.useContext)(l);export{r as a,a as i,u as n,s as r,l as t};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{a as t,r as n}from"./StudioContext-CsxoZNKd.js";import{n as r}from"./features-6cCl0G7E.js";import{Q as i,S as a,a as o,i as s,o as c,u as l,x as u}from"./three.module-MNvRIzJI.js";import{a as d,c as f,f as p,i as m,n as h,o as g,r as _,t as v}from"./useThemeColors-Dpdj0pe9.js";var y=/* @__PURE__ */ e(t(),1),b=`
|
|
2
|
+
attribute vec3 iStart;
|
|
3
|
+
attribute vec3 iEnd;
|
|
4
|
+
attribute float iWidth;
|
|
5
|
+
attribute float iHeight;
|
|
6
|
+
attribute float iFeature;
|
|
7
|
+
attribute float iLayer;
|
|
8
|
+
uniform float uLayerMin;
|
|
9
|
+
uniform float uLayerMax;
|
|
10
|
+
uniform float uVisible[32];
|
|
11
|
+
uniform vec3 uColors[32];
|
|
12
|
+
varying vec3 vColor;
|
|
13
|
+
varying vec3 vNormal;
|
|
14
|
+
void main() {
|
|
15
|
+
int f = min(int(iFeature + 0.5), 31); // features past the last slot share it
|
|
16
|
+
if (iLayer < uLayerMin - 0.5 || iLayer > uLayerMax + 0.5 || uVisible[f] < 0.5) {
|
|
17
|
+
gl_Position = vec4(2.0, 2.0, 2.0, 1.0); // outside the clip volume: not drawn
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
vec3 d = iEnd - iStart;
|
|
21
|
+
float len = length(d);
|
|
22
|
+
vec3 dir = len > 0.0 ? d / len : vec3(1.0, 0.0, 0.0);
|
|
23
|
+
vec3 side = cross(vec3(0.0, 0.0, 1.0), dir);
|
|
24
|
+
side = length(side) < 1e-6 ? vec3(0.0, 1.0, 0.0) : normalize(side);
|
|
25
|
+
vec3 up = cross(dir, side);
|
|
26
|
+
// the box runs from start to end, half a line width longer at each end so corners close;
|
|
27
|
+
// its top is at the nozzle height, like the printed line
|
|
28
|
+
vec3 p = iStart
|
|
29
|
+
+ dir * (position.x * (len + iWidth) - 0.5 * iWidth)
|
|
30
|
+
+ side * (position.y * iWidth)
|
|
31
|
+
+ up * ((position.z - 0.5) * iHeight);
|
|
32
|
+
vNormal = normalize(normalMatrix * (dir * normal.x + side * normal.y + up * normal.z));
|
|
33
|
+
vColor = uColors[f];
|
|
34
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(p, 1.0);
|
|
35
|
+
}
|
|
36
|
+
`,x=`
|
|
37
|
+
varying vec3 vColor;
|
|
38
|
+
varying vec3 vNormal;
|
|
39
|
+
void main() {
|
|
40
|
+
vec3 n = normalize(vNormal);
|
|
41
|
+
float key = max(dot(n, normalize(vec3(0.35, 0.55, 1.0))), 0.0);
|
|
42
|
+
float fill = max(dot(n, normalize(vec3(-0.6, -0.2, 0.4))), 0.0);
|
|
43
|
+
gl_FragColor = vec4(vColor * (0.38 + 0.52 * key + 0.15 * fill), 1.0);
|
|
44
|
+
#include <colorspace_fragment>
|
|
45
|
+
}
|
|
46
|
+
`,S=`
|
|
47
|
+
attribute float aLayer;
|
|
48
|
+
uniform float uLayerMin;
|
|
49
|
+
uniform float uLayerMax;
|
|
50
|
+
void main() {
|
|
51
|
+
if (aLayer < uLayerMin - 0.5 || aLayer > uLayerMax + 0.5) { gl_Position = vec4(2.0, 2.0, 2.0, 1.0); return; }
|
|
52
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
53
|
+
}
|
|
54
|
+
`,C=`
|
|
55
|
+
uniform vec3 uColor;
|
|
56
|
+
void main() {
|
|
57
|
+
gl_FragColor = vec4(uColor, 1.0);
|
|
58
|
+
#include <colorspace_fragment>
|
|
59
|
+
}
|
|
60
|
+
`,w=n();function T({segments:e,features:t,layerMin:n,layerMax:o,hidden:c}){let d=p(e=>e.invalidate),f=(0,y.useMemo)(()=>{let t=new s(1,1,1).translate(.5,0,0),n=new a().copy(t);return t.dispose(),n.instanceCount=e.count,n.setAttribute(`iStart`,new u(e.start,3)),n.setAttribute(`iEnd`,new u(e.end,3)),n.setAttribute(`iWidth`,new u(e.width,1)),n.setAttribute(`iHeight`,new u(e.height,1)),n.setAttribute(`iFeature`,new u(Float32Array.from(e.feature),1)),n.setAttribute(`iLayer`,new u(e.layer,1)),n},[e]);(0,y.useEffect)(()=>()=>f.dispose(),[f]);let m=(0,y.useMemo)(()=>new i({vertexShader:b,fragmentShader:x,uniforms:{uLayerMin:{value:0},uLayerMax:{value:1e9},uVisible:{value:(/* @__PURE__ */ new Float32Array(32)).fill(1)},uColors:{value:Array.from({length:32},()=>new l(10066329))}}}),[]);return(0,y.useEffect)(()=>()=>m.dispose(),[m]),(0,y.useLayoutEffect)(()=>{t.forEach((e,t)=>{t<32&&m.uniforms.uColors.value[t].set(r(e.name))}),d()},[t,m,d]),(0,y.useLayoutEffect)(()=>{let e=m.uniforms;e.uLayerMin.value=n,e.uLayerMax.value=o;for(let t=0;t<32;t++)e.uVisible.value[t]=+!c.has(t);d()},[n,o,c,m,d]),/* @__PURE__ */ (0,w.jsx)(`mesh`,{geometry:f,material:m,frustumCulled:!1})}function E({travels:e,layerMin:t,layerMax:n,color:r,visible:a}){let s=p(e=>e.invalidate),u=(0,y.useMemo)(()=>{let t=new Float32Array(e.count*2);for(let n=0;n<e.count;n++)t[2*n]=t[2*n+1]=e.layer[n];let n=new c;return n.setAttribute(`position`,new o(e.pos,3)),n.setAttribute(`aLayer`,new o(t,1)),n},[e]);(0,y.useEffect)(()=>()=>u.dispose(),[u]);let d=(0,y.useMemo)(()=>new i({vertexShader:S,fragmentShader:C,uniforms:{uLayerMin:{value:0},uLayerMax:{value:1e9},uColor:{value:new l}}}),[]);return(0,y.useEffect)(()=>()=>d.dispose(),[d]),(0,y.useLayoutEffect)(()=>{d.uniforms.uLayerMin.value=t,d.uniforms.uLayerMax.value=n,d.uniforms.uColor.value.set(r),s()},[t,n,r,d,s]),/* @__PURE__ */ (0,w.jsx)(`lineSegments`,{geometry:u,material:d,visible:a,frustumCulled:!1})}function D({result:e,layerMin:t,layerMax:n,hidden:r,showTravels:i,view:a,fitKey:o}){let s=v(),c=(0,y.useMemo)(()=>h(e),[e]),l=(0,y.useMemo)(()=>_(e),[e]),u=(0,y.useMemo)(()=>{let e=c.map(e=>e[0]),t=c.map(e=>e[1]);return 20*Math.max(Math.max(...e)-Math.min(...e),Math.max(...t)-Math.min(...t),100)},[c]);return/* @__PURE__ */ (0,w.jsxs)(f,{flat:!0,frameloop:`demand`,dpr:[1,2],camera:{fov:35,near:.1,far:1e4,up:[0,0,1],position:[0,-300,200]},children:[/* @__PURE__ */ (0,w.jsx)(`color`,{attach:`background`,args:[s.background]}),/* @__PURE__ */ (0,w.jsx)(d,{outline:c,colors:s}),/* @__PURE__ */ (0,w.jsx)(T,{segments:e.segments,features:e.features,layerMin:t,layerMax:n,hidden:r}),/* @__PURE__ */ (0,w.jsx)(E,{travels:e.travels,layerMin:t,layerMax:n,color:s.travel,visible:i}),/* @__PURE__ */ (0,w.jsx)(g,{makeDefault:!0,enableDamping:!0,dampingFactor:.12,screenSpacePanning:!0}),/* @__PURE__ */ (0,w.jsx)(m,{bounds:l,far:u,view:a,fitKey:o})]})}export{D as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={"Outer wall":`#ff7d38`,"Inner wall":`#ffe64d`,"Overhang wall":`#3d4dff`,"Sparse infill":`#b03029`,"Internal solid infill":`#9654cc`,"Solid infill":`#9654cc`,"Top surface":`#f04040`,"Bottom surface":`#6b5cc7`,Ironing:`#ff8c69`,Bridge:`#4d80ba`,"Internal Bridge":`#6fa3d6`,"Gap infill":`#e8e8e8`,Skirt:`#00876e`,Brim:`#00876e`,Support:`#36c44a`,"Support interface":`#1f7a2e`,"Support transition":`#7fbf7f`,"Prime tower":`#b3e3ab`,Custom:`#5ed194`},t=[`Outer wall`,`Inner wall`,`Overhang wall`,`Sparse infill`,`Internal solid infill`,`Solid infill`,`Top surface`,`Bottom surface`,`Bridge`,`Internal Bridge`,`Gap infill`,`Ironing`,`Support`,`Support interface`,`Support transition`,`Skirt`,`Brim`,`Prime tower`,`Custom`],n=e=>e===`Custom`?`Start & end G-code`:e;function r(t){if(e[t])return e[t];let n=0;for(let e of t)n=(n*31+e.charCodeAt(0))%360;return`hsl(${n}, 60%, 55%)`}export{r as n,n as r,t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Uint8Array,t=Uint16Array,n=Int32Array,r=new e([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),i=new e([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),a=new e([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),o=function(e,r){for(var i=new t(31),a=0;a<31;++a)i[a]=r+=1<<e[a-1];for(var o=new n(i[30]),a=1;a<30;++a)for(var s=i[a];s<i[a+1];++s)o[s]=s-i[a]<<5|a;return{b:i,r:o}},s=o(r,2),c=s.b,l=s.r;c[28]=258,l[258]=28;var u=o(i,0),d=u.b;u.r;for(var f=new t(32768),p=0;p<32768;++p){var m=(p&43690)>>1|(p&21845)<<1;m=(m&52428)>>2|(m&13107)<<2,m=(m&61680)>>4|(m&3855)<<4,f[p]=((m&65280)>>8|(m&255)<<8)>>1}for(var h=(function(e,n,r){for(var i=e.length,a=0,o=new t(n);a<i;++a)e[a]&&++o[e[a]-1];var s=new t(n);for(a=1;a<n;++a)s[a]=s[a-1]+o[a-1]<<1;var c;if(r){c=new t(1<<n);var l=15-n;for(a=0;a<i;++a)if(e[a])for(var u=a<<4|e[a],d=n-e[a],p=s[e[a]-1]++<<d,m=p|(1<<d)-1;p<=m;++p)c[f[p]>>l]=u}else for(c=new t(i),a=0;a<i;++a)e[a]&&(c[a]=f[s[e[a]-1]++]>>15-e[a]);return c}),g=new e(288),p=0;p<144;++p)g[p]=8;for(var p=144;p<256;++p)g[p]=9;for(var p=256;p<280;++p)g[p]=7;for(var p=280;p<288;++p)g[p]=8;for(var _=new e(32),p=0;p<32;++p)_[p]=5;var v=/*#__PURE__*/ h(g,9,1),ee=/*#__PURE__*/ h(_,5,1),y=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},b=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},x=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},te=function(e){return(e+7)/8|0},S=function(t,n,r){return(n==null||n<0)&&(n=0),(r==null||r>t.length)&&(r=t.length),new e(t.subarray(n,r))},C=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],w=function(e,t,n){var r=Error(t||C[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,w),!n)throw r;return r},T=function(t,n,o,s){var l=t.length,u=s?s.length:0;if(!l||n.f&&!n.l)return o||new e(0);var f=!o,p=f||n.i!=2,m=n.i;f&&(o=new e(l*3));var g=function(t){var n=o.length;if(t>n){var r=new e(Math.max(n*2,t));r.set(o),o=r}},_=n.f||0,C=n.p||0,T=n.b||0,E=n.l,D=n.d,O=n.m,k=n.n,A=l*8;do{if(!E){_=b(t,C,1);var j=b(t,C+1,3);if(C+=3,!j){var M=te(C)+4,N=t[M-4]|t[M-3]<<8,P=M+N;if(P>l){m&&w(0);break}p&&g(T+N),o.set(t.subarray(M,P),T),n.b=T+=N,n.p=C=P*8,n.f=_;continue}if(j==1)E=v,D=ee,O=9,k=5;else if(j==2){var F=b(t,C,31)+257,I=b(t,C+10,15)+4,L=F+b(t,C+5,31)+1;C+=14;for(var R=new e(L),z=new e(19),B=0;B<I;++B)z[a[B]]=b(t,C+B*3,7);C+=I*3;for(var V=y(z),H=(1<<V)-1,U=h(z,V,1),B=0;B<L;){var W=U[b(t,C,H)];C+=W&15;var M=W>>4;if(M<16)R[B++]=M;else{var G=0,K=0;for(M==16?(K=3+b(t,C,3),C+=2,G=R[B-1]):M==17?(K=3+b(t,C,7),C+=3):M==18&&(K=11+b(t,C,127),C+=7);K--;)R[B++]=G}}var q=R.subarray(0,F),J=R.subarray(F);O=y(q),k=y(J),E=h(q,O,1),D=h(J,k,1)}else w(1);if(C>A){m&&w(0);break}}p&&g(T+131072);for(var ne=(1<<O)-1,re=(1<<k)-1,Y=C;;Y=C){var G=E[x(t,C)&ne],X=G>>4;if(C+=G&15,C>A){m&&w(0);break}if(G||w(2),X<256)o[T++]=X;else if(X==256){Y=C,E=null;break}else{var ie=X-254;if(X>264){var B=X-257,Z=r[B];ie=b(t,C,(1<<Z)-1)+c[B],C+=Z}var Q=D[x(t,C)&re],$=Q>>4;Q||w(3),C+=Q&15;var J=d[$];if($>3){var Z=i[$];J+=x(t,C)&(1<<Z)-1,C+=Z}if(C>A){m&&w(0);break}p&&g(T+131072);var ae=T+ie;if(T<J){var oe=u-J,se=Math.min(J,ae);for(oe+T<0&&w(3);T<se;++T)o[T]=s[oe+T]}for(;T<ae;++T)o[T]=o[T-J]}}n.l=E,n.p=Y,n.b=T,n.f=_,E&&(_=1,n.m=O,n.d=D,n.n=k)}while(!_);return T!=o.length&&f?S(o,0,T):o.subarray(0,T)},E=/*#__PURE__*/ new e(0),D=function(e,t){return e[t]|e[t+1]<<8},O=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},k=function(e,t){return O(e,t)+O(e,t+4)*4294967296};function A(e,t){return T(e,{i:2},t&&t.out,t&&t.dictionary)}var j=typeof TextDecoder<`u`&&/*#__PURE__*/ new TextDecoder;try{j.decode(E,{stream:!0})}catch{}var M=function(e){for(var t=``,n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:S(e,n-1)};i?i==3?(r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?t+=String.fromCharCode((r&31)<<6|e[n++]&63):t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(r)}};function N(e,t){if(t){for(var n=``,r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}if(j)return j.decode(e);var i=M(e),a=i.s,n=i.r;return n.length&&w(8),a}var P=function(e,t){return t+30+D(e,t+26)+D(e,t+28)},F=function(e,t,n){var r=D(e,t+28),i=N(e.subarray(t+46,t+46+r),!(D(e,t+8)&2048)),a=t+46+r,o=O(e,t+20),s=n&&o==4294967295?I(e,a):[o,O(e,t+24),O(e,t+42)],c=s[0],l=s[1],u=s[2];return[D(e,t+10),c,l,i,a+D(e,t+30)+D(e,t+32),u]},I=function(e,t){for(;D(e,t)!=1;t+=4+D(e,t+2));return[k(e,t+12),k(e,t+4),k(e,t+20)]};function L(t,n){for(var r={},i=t.length-22;O(t,i)!=101010256;--i)(!i||t.length-i>65558)&&w(13);var a=D(t,i+8);if(!a)return{};var o=O(t,i+16),s=o==4294967295||a==65535;if(s){var c=O(t,i-12);s=O(t,c)==101075792,s&&(a=O(t,c+32),o=O(t,c+48))}for(var l=n&&n.filter,u=0;u<a;++u){var d=F(t,o,s),f=d[0],p=d[1],m=d[2],h=d[3],g=d[4],_=d[5],v=P(t,_);o=g,(!l||l({name:h,size:p,originalSize:m,compression:f}))&&(f?f==8?r[h]=A(t.subarray(v,v+p),{out:new e(m)}):w(14,`unknown compression type `+f):r[h]=S(t,v,v+p))}return r}var R={stl:`stl`,"3mf":`3mf`,obj:`obj`,step:`step`,stp:`step`,iges:`iges`,igs:`iges`},z=Object.keys(R).map(e=>`.`+e).join(`,`),B=`.gcode,.gco,.g,.3mf`,V=/^Metadata\/plate_(\d+)\.gcode$/;function H(e,t,n=()=>{}){try{return L(e,{filter:e=>(n(e),t(e.name))})}catch{return null}}function U(e,t){let n=(e.match(/\.(\w+)$/)||[])[1]?.toLowerCase();if([`gcode`,`gco`,`g`].includes(n))return{kind:`gcode`};if(!R[n])return{kind:`unknown`};if(n===`3mf`&&t){let e=[],n=H(t,t=>(e.push(t),/^Metadata\/plate_\d+\.png$/.test(t)))||{},r=e.map(e=>e.match(V)).filter(Boolean).map(e=>Number(e[1])).sort((e,t)=>e-t);if(r.length)return{kind:`gcode3mf`,plates:r.map(e=>({plate:e,thumbnail:n[`Metadata/plate_${e}.png`]||null}))}}return{kind:`model`,format:R[n]}}function W(e){let t=0;return H(e,e=>!1,e=>{/\.model$/i.test(e.name)&&(t+=e.originalSize)}),t}async function G(e){let t=[],n=[];for(let r of e){let e=U(r.name,/\.3mf$/i.test(r.name)?new Uint8Array(await r.arrayBuffer()):void 0);(e.kind===`model`?t:n).push({file:r,what:e})}return{models:t.map(e=>e.file),others:n}}export{G as a,W as i,z as n,L as o,U as r,B as t};
|