@selvajs/mcp 0.2.0-beta.3 → 0.2.0-beta.5
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 +3 -2
- package/dist/app.d.ts +6 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/capture.d.ts +17 -3
- package/dist/capture.d.ts.map +1 -1
- package/dist/capture.js +4 -2
- package/dist/capture.js.map +1 -1
- package/dist/view/index.d.ts +3 -1
- package/dist/view/index.d.ts.map +1 -1
- package/dist/view/index.js +3 -0
- package/dist/view/index.js.map +1 -1
- package/dist/views/capture.html +7 -7
- package/dist/views/solve.html +8 -8
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -135,9 +135,10 @@ that call. `renderViewForm` from `@selvajs/mcp/view` draws the same form in a vi
|
|
|
135
135
|
|
|
136
136
|
## Rendering on the server
|
|
137
137
|
|
|
138
|
-
`captureSolve(response, {
|
|
138
|
+
`captureSolve(response, { views, width, height, grid, look, background, hdr })` from
|
|
139
139
|
`@selvajs/mcp/capture` draws a Rhino.Compute response in the same viewer as the 3D view, in a
|
|
140
|
-
headless Chromium, and resolves to a base64 PNG
|
|
140
|
+
headless Chromium, and resolves to a base64 PNG per view (`pngs`; `png` is the first) for a
|
|
141
|
+
tool's `images`. The views share one scene, so each extra one costs a render, not a solve. `hdr` is the environment
|
|
141
142
|
map as a URL; the page loads nothing from an origin, so a `data:` URL is the reliable form. Captures run one at a time on one browser, which closes after
|
|
142
143
|
two idle minutes. It needs the optional peer `playwright-core` and a browser
|
|
143
144
|
(`npx playwright install --with-deps chromium`, or `executablePath`); without them it throws
|
package/dist/app.d.ts
CHANGED
|
@@ -53,6 +53,12 @@ export interface SolveViewData {
|
|
|
53
53
|
look?: string;
|
|
54
54
|
/** Hex background colour, for looks that don't set their own. */
|
|
55
55
|
background?: string;
|
|
56
|
+
/** The view the first geometry opens in; see `CameraView` in `@selvajs/visualization/render`. */
|
|
57
|
+
camera?: {
|
|
58
|
+
direction: number[];
|
|
59
|
+
position?: number[];
|
|
60
|
+
target?: number[];
|
|
61
|
+
};
|
|
56
62
|
/** A Rhino.Compute response, or only its display trees (`values`, `modelunits`). */
|
|
57
63
|
response?: unknown;
|
|
58
64
|
load?: {
|
package/dist/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,qFAAqF;AACrF,eAAO,MAAM,iBAAiB,8BAA8B,CAAC;AAE7D,wFAAwF;AACxF,eAAO,MAAM,iBAAiB,+BAA+B,CAAC;AAE9D;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,KAAK,CAAC;AAE7C,MAAM,WAAW,MAAM;IACtB,yEAAyE;IACzE,WAAW,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACtB,0CAA0C;IAC1C,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,gDAAgD;IAChD,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,sBAAsB;IACtB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,kBAAkB;IAClC,GAAG,EAAE,QAAQ,MAAM,EAAE,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kGAAkG;IAClG,IAAI,EAAE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,yFAAyF;AACzF,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,kBAAkB,CAe3E;AAED,oEAAoE;AACpE,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oFAAoF;IACpF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;IAC7D,4EAA4E;IAC5E,IAAI,CAAC,EAAE,aAAa,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,yEAAyE;IACzE,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,SAAS,EAAE,CAAC;CACpB;AAED,wFAAwF;AACxF,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;IAC/C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,qFAAqF;AACrF,eAAO,MAAM,iBAAiB,8BAA8B,CAAC;AAE7D,wFAAwF;AACxF,eAAO,MAAM,iBAAiB,+BAA+B,CAAC;AAE9D;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,KAAK,CAAC;AAE7C,MAAM,WAAW,MAAM;IACtB,yEAAyE;IACzE,WAAW,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACtB,0CAA0C;IAC1C,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,gDAAgD;IAChD,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,sBAAsB;IACtB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,kBAAkB;IAClC,GAAG,EAAE,QAAQ,MAAM,EAAE,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kGAAkG;IAClG,IAAI,EAAE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACrC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,yFAAyF;AACzF,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,kBAAkB,CAe3E;AAED,oEAAoE;AACpE,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAEjD;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iGAAiG;IACjG,MAAM,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IACzE,oFAAoF;IACpF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;IAC7D,4EAA4E;IAC5E,IAAI,CAAC,EAAE,aAAa,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,yEAAyE;IACzE,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,SAAS,EAAE,CAAC;CACpB;AAED,wFAAwF;AACxF,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;IAC/C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
package/dist/capture.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
/** A camera direction, as Selva's viewer names them. */
|
|
2
|
-
export type CaptureView = 'iso' | 'top' | 'front' | 'back' | 'left' | 'right' | 'bottom';
|
|
1
|
+
/** A camera direction, as Selva's viewer names them; `default` is `camera`, or iso without one. */
|
|
2
|
+
export type CaptureView = 'default' | 'iso' | 'top' | 'front' | 'back' | 'left' | 'right' | 'bottom';
|
|
3
3
|
export interface CaptureOptions {
|
|
4
|
+
/** One view; ignored when `views` is given. Default `default`. */
|
|
4
5
|
view?: CaptureView;
|
|
6
|
+
/** Several views of the one scene, a PNG each, in order. Costs a render each, not a solve. */
|
|
7
|
+
views?: CaptureView[];
|
|
5
8
|
/** Pixels. Default 1200 × 800. */
|
|
6
9
|
width?: number;
|
|
7
10
|
height?: number;
|
|
@@ -11,6 +14,15 @@ export interface CaptureOptions {
|
|
|
11
14
|
look?: string;
|
|
12
15
|
/** Hex, e.g. `#e6e6e6`. */
|
|
13
16
|
background?: string;
|
|
17
|
+
/**
|
|
18
|
+
* What the `default` view shows: a saved view, as `CameraView` in `@selvajs/visualization/render`.
|
|
19
|
+
* Only its direction counts: the capture frames the model to fit its own canvas.
|
|
20
|
+
*/
|
|
21
|
+
camera?: {
|
|
22
|
+
direction: number[];
|
|
23
|
+
position?: number[];
|
|
24
|
+
target?: number[];
|
|
25
|
+
};
|
|
14
26
|
/**
|
|
15
27
|
* The HDR environment the viewer lights with, as a URL (`data:` works: the page loads no
|
|
16
28
|
* origin). Without it the viewer generates its lighting, which reads flatter.
|
|
@@ -32,8 +44,10 @@ export interface CaptureOptions {
|
|
|
32
44
|
signal?: AbortSignal;
|
|
33
45
|
}
|
|
34
46
|
export interface Capture {
|
|
35
|
-
/** Base64 PNG. */
|
|
47
|
+
/** Base64 PNG of the first view. */
|
|
36
48
|
png: string;
|
|
49
|
+
/** Base64 PNG per view, in the order asked. */
|
|
50
|
+
pngs: string[];
|
|
37
51
|
/** Objects drawn. Zero means the response had no display geometry and `png` is empty. */
|
|
38
52
|
drawn: number;
|
|
39
53
|
}
|
package/dist/capture.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../src/capture.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../src/capture.ts"],"names":[],"mappings":"AAEA,mGAAmG;AACnG,MAAM,MAAM,WAAW,GACtB,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE5E,MAAM,WAAW,cAAc;IAC9B,kEAAkE;IAClE,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,8FAA8F;IAC9F,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC;IACtB,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oBAAoB;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,MAAM,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IACzE;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7B,qGAAqG;IACrG,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,WAAW,OAAO;IACvB,oCAAoC;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,+CAA+C;IAC/C,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,yFAAyF;IACzF,KAAK,EAAE,MAAM,CAAC;CACd;AAED,mFAAmF;AACnF,qBAAa,uBAAwB,SAAQ,KAAK;IACxC,IAAI,SAA6B;CAC1C;AAqDD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,CAc9F"}
|
package/dist/capture.js
CHANGED
|
@@ -73,14 +73,16 @@ async function capture(response, options) {
|
|
|
73
73
|
await page.setViewportSize({ width: options.width ?? 1200, height: options.height ?? 800 });
|
|
74
74
|
await page.setContent(html, { waitUntil: 'load' });
|
|
75
75
|
const hdr = options.hdr ? await options.hdr() : undefined;
|
|
76
|
-
|
|
76
|
+
const { pngs, drawn } = await page.evaluate((req) => globalThis.selvaCapture(req), {
|
|
77
77
|
response,
|
|
78
|
-
|
|
78
|
+
views: options.views?.length ? options.views : [options.view ?? 'default'],
|
|
79
79
|
grid: options.grid ?? true,
|
|
80
80
|
look: options.look,
|
|
81
81
|
background: options.background,
|
|
82
|
+
camera: options.camera,
|
|
82
83
|
hdr
|
|
83
84
|
});
|
|
85
|
+
return { png: pngs[0] ?? '', pngs, drawn };
|
|
84
86
|
}
|
|
85
87
|
finally {
|
|
86
88
|
options.signal?.removeEventListener('abort', closePage);
|
package/dist/capture.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capture.js","sourceRoot":"","sources":["../src/capture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"capture.js","sourceRoot":"","sources":["../src/capture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAuD5C,mFAAmF;AACnF,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACxC,IAAI,GAAG,yBAAyB,CAAC;CAC1C;AAkBD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,4BAA4B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC5E,0FAA0F;AAC1F,MAAM,IAAI,GAAG,CAAC,yBAAyB,EAAE,6BAA6B,EAAE,wBAAwB,CAAC,CAAC;AAClG,2EAA2E;AAC3E,MAAM,aAAa,GAAG,OAAO,CAAC;AAE9B,IAAI,OAAqC,CAAC;AAC1C,IAAI,IAA+C,CAAC;AACpD,wFAAwF;AACxF,IAAI,KAAK,GAAqB,OAAO,CAAC,OAAO,EAAE,CAAC;AAEhD,KAAK,UAAU,MAAM,CAAC,cAAkC,EAAE,OAAe;IACxE,6FAA6F;IAC7F,MAAM,IAAI,GAAG,iBAAiB,CAAC;IAC/B,IAAI,QAAkB,CAAC;IACvB,IAAI,CAAC;QACJ,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAA2B,CAAC,CAAC;IACpF,CAAC;IAAC,MAAM,CAAC;QACR,MAAM,IAAI,uBAAuB,CAChC,sFAAsF,CACtF,CAAC;IACH,CAAC;IACD,IAAI,CAAC;QACJ,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QAChF,QAAQ,CAAC,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC;QACzD,OAAO,QAAQ,CAAC;IACjB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,MAAM,IAAI,uBAAuB,CAChC,8BAA8B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI;YAChG,yFAAyF;YACzF,qCAAqC,CACtC,CAAC;IACH,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,QAAiB,EAAE,UAA0B,EAAE;IAC3E,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3B,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE;QAC3B,MAAM,EAAE,cAAc,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IACH,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC5B,IAAI,CAAC,MAAM;QAAE,OAAO,GAAG,CAAC;IACxB,OAAO,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC/C,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC5C,IAAI,MAAM,CAAC,OAAO;YAAE,OAAO,OAAO,EAAE,CAAC;QACrC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IACvF,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,OAAO,CAAC,QAAiB,EAAE,OAAuB;IAChE,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,IAAI,MAAM,CAAC;IAC5C,YAAY,CAAC,IAAI,CAAC,CAAC;IACnB,OAAO,KAAK,MAAM,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;QAC1E,OAAO,GAAG,SAAS,CAAC;QACpB,MAAM,GAAG,CAAC;IACX,CAAC,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9E,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,CAAC,CAAC;IACrE,8DAA8D;IAC9D,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IAC1D,OAAO,CAAC,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACrE,IAAI,CAAC;QACJ,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;QACjC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAChC,MAAM,IAAI,CAAC,eAAe,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC;QAC5F,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;QACnD,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1D,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ,CAC1C,CAAC,GAAG,EAAE,EAAE,CAEN,UAGA,CAAC,YAAY,CAAC,GAAG,CAAC,EACpB;YACC,QAAQ;YACR,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,IAAI,SAAS,CAAC;YAC1E,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,IAAI;YAC1B,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,GAAG;SACH,CACD,CAAC;QACF,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IAC5C,CAAC;YAAS,CAAC;QACV,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACxD,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACnC,IAAI,GAAG,UAAU,CAAC,GAAG,EAAE;YACtB,MAAM,IAAI,GAAG,OAAO,CAAC;YACrB,OAAO,GAAG,SAAS,CAAC;YACpB,KAAK,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACnD,CAAC,EAAE,aAAa,CAAC,CAAC;QAClB,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;IAChB,CAAC;AACF,CAAC"}
|
package/dist/view/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { App } from '@modelcontextprotocol/ext-apps';
|
|
2
|
-
import { type Look } from '@selvajs/visualization/render';
|
|
2
|
+
import { type CameraView, type Look } from '@selvajs/visualization/render';
|
|
3
3
|
import { type SolveViewData, type SolveViewForm } from '../app.js';
|
|
4
4
|
export { SOLVE_VIEW_KEY, type SolveViewData, type SolveViewForm, type ViewInput } from '../app.js';
|
|
5
5
|
export type { App } from '@modelcontextprotocol/ext-apps';
|
|
@@ -38,6 +38,8 @@ export interface SolveViewerOptions {
|
|
|
38
38
|
look?: string;
|
|
39
39
|
/** Hex colour; fixed once the viewer is made. */
|
|
40
40
|
background?: string;
|
|
41
|
+
/** The view the first geometry opens in. Default: iso, framed to the model. */
|
|
42
|
+
camera?: CameraView;
|
|
41
43
|
}
|
|
42
44
|
/** A 3D viewer filling `container`, drawing Rhino.Compute responses. */
|
|
43
45
|
export declare function mountSolveViewer(container: HTMLElement, options?: SolveViewerOptions): SolveViewer;
|
package/dist/view/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/view/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,GAAG,EAKH,MAAM,gCAAgC,CAAC;AAMxC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/view/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,GAAG,EAKH,MAAM,gCAAgC,CAAC;AAMxC,OAAO,EAIN,KAAK,UAAU,EACf,KAAK,IAAI,EACT,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAkB,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAEnF,OAAO,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACnG,YAAY,EAAE,GAAG,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAEjE,oDAAoD;AACpD,MAAM,WAAW,cAAc;IAC9B,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AASD;;;GAGG;AACH,wBAAsB,WAAW,CAChC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EACvC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,GACzB,OAAO,CAAC,GAAG,CAAC,CAOd;AAED,mFAAmF;AACnF,wBAAgB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAOzD;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,aAAa,GAAG,SAAS,CAE/E;AAED,sGAAsG;AACtG,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,CASvF;AAED,yGAAyG;AACzG,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAErD;AAED,MAAM,WAAW,WAAW;IAC3B,4EAA4E;IAC5E,IAAI,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACzC,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAC1B,sEAAsE;IACtE,MAAM,IAAI,IAAI,CAAC;IACf,SAAS,IAAI,IAAI,CAAC;IAClB,OAAO,IAAI,IAAI,CAAC;CAChB;AAED,MAAM,WAAW,kBAAkB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+EAA+E;IAC/E,MAAM,CAAC,EAAE,UAAU,CAAC;CACpB;AAED,wEAAwE;AACxE,wBAAgB,gBAAgB,CAC/B,SAAS,EAAE,WAAW,EACtB,OAAO,GAAE,kBAAuB,GAC9B,WAAW,CAmDb;AAED,MAAM,WAAW,cAAc;IAC9B,qFAAqF;IACrF,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,gDAAgD;IAChD,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC7B,SAAS,EAAE,WAAW,EACtB,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,GAChD,cAAc,CA0EhB"}
|
package/dist/view/index.js
CHANGED
|
@@ -84,6 +84,9 @@ export function mountSolveViewer(container, options = {}) {
|
|
|
84
84
|
parsing: { material: viewer.getMaterialAppearance() }
|
|
85
85
|
});
|
|
86
86
|
updateScene(viewer.scene, objects, viewer.camera, viewer.controls, framed);
|
|
87
|
+
if (!framed && objects.length > 0 && options.camera) {
|
|
88
|
+
viewer.cameraController.setCameraView(options.camera);
|
|
89
|
+
}
|
|
87
90
|
framed ||= objects.length > 0;
|
|
88
91
|
// The parser built plain materials; a look that overrides them has to be applied again.
|
|
89
92
|
viewer.setLook(look, { deferEmissiveLights: true });
|
package/dist/view/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/view/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,GAAG,EACH,kBAAkB,EAClB,cAAc,EACd,uBAAuB,EAEvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACN,kBAAkB,EAClB,kCAAkC,EAClC,oBAAoB,EACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/view/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,GAAG,EACH,kBAAkB,EAClB,cAAc,EACd,uBAAuB,EAEvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACN,kBAAkB,EAClB,kCAAkC,EAClC,oBAAoB,EACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,SAAS,EACT,KAAK,EACL,WAAW,EAGX,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,cAAc,EAA0C,MAAM,WAAW,CAAC;AAEnF,OAAO,EAAE,cAAc,EAA0D,MAAM,WAAW,CAAC;AAEnG,OAAO,EAAE,KAAK,EAAa,MAAM,+BAA+B,CAAC;AASjE,SAAS,gBAAgB,CAAC,OAAqC;IAC9D,IAAI,CAAC,OAAO;QAAE,OAAO;IACrB,IAAI,OAAO,CAAC,KAAK;QAAE,kBAAkB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACrD,IAAI,OAAO,CAAC,MAAM,EAAE,SAAS;QAAE,uBAAuB,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACjF,IAAI,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK;QAAE,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAC1E,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAChC,IAAuC,EACvC,MAA2B;IAE3B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;IAC1B,GAAG,CAAC,gBAAgB,CAAC,oBAAoB,EAAE,gBAAgB,CAAC,CAAC;IAC7D,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;IACd,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC;IACpB,gBAAgB,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC,CAAC;IACvC,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,UAAU,CAAC,MAAsB;IAChD,OAAO,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;SAC3B,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;QACd,MAAM,KAAK,GAAG,CAAqC,CAAC;QACpD,OAAO,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAChE,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAsB;IACnD,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC,cAAc,CAA8B,CAAC;AACpE,CAAC;AAED,sGAAsG;AACtG,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,GAAQ,EAAE,IAAmB;IACpE,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtD,IAAI,CAAC,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IACjC,MAAM,MAAM,GAAG,CAAC,MAAM,GAAG,CAAC,cAAc,CAAC;QACxC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;QACpB,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE;KACpC,CAAC,CAAmB,CAAC;IACtB,IAAI,MAAM,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,CAAC;IACtF,OAAO,aAAa,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC;AACxC,CAAC;AAED,yGAAyG;AACzG,MAAM,UAAU,MAAM,CAAC,IAAwB;IAC9C,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAY,CAAC,CAAC,CAAC,CAAE,IAAa,CAAC,CAAC,CAAC,WAAW,CAAC;AACpE,CAAC;AAoBD,wEAAwE;AACxE,MAAM,UAAU,gBAAgB,CAC/B,SAAsB,EACtB,UAA8B,EAAE;IAEhC,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,wDAAwD,CAAC;IAChF,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACzB,IAAI,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,gGAAgG;IAChG,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,EAAE;QAChC,IAAI;QACJ,eAAe,EAAE,oBAAoB;QACrC,WAAW,EAAE;YACZ,OAAO,EAAE,KAAK;YACd,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,eAAe,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC;SAClE;KACD,CAAC,CAAC;IACH,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,4FAA4F;IAC5F,MAAM,OAAO,GAAG,GAAG,EAAE;QACpB,MAAM,CAAC,kBAAkB,EAAE,CAAC;QAC5B,MAAM,CAAC,kBAAkB,EAAE,CAAC;QAC5B,MAAM,CAAC,UAAU,EAAE,CAAC;IACrB,CAAC,CAAC;IACF,OAAO;QACN,KAAK,CAAC,IAAI,CAAC,QAAQ;YAClB,MAAM,OAAO,GAAG,MAAM,kCAAkC,CAAC,QAAiB,EAAE;gBAC3E,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,qBAAqB,EAAE,EAAE;aACrD,CAAC,CAAC;YACH,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAC3E,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;gBACrD,MAAM,CAAC,gBAAgB,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACvD,CAAC;YACD,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;YAC9B,wFAAwF;YACxF,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAAC,CAAC;YACpD,MAAM,CAAC,eAAe,EAAE,CAAC;YACzB,OAAO,EAAE,CAAC;YACV,OAAO,OAAO,CAAC,MAAM,CAAC;QACvB,CAAC;QACD,OAAO,CAAC,IAAI;YACX,IAAI,GAAG,IAAI,CAAC;YACZ,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACrB,OAAO,EAAE,CAAC;QACX,CAAC;QACD,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE;QACjC,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE;QACnC,OAAO;YACN,MAAM,CAAC,OAAO,EAAE,CAAC;YACjB,yEAAyE;YACzE,kBAAkB,EAAE,CAAC;YACrB,MAAM,CAAC,MAAM,EAAE,CAAC;QACjB,CAAC;KACD,CAAC;AACH,CAAC;AASD;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC7B,SAAsB,EACtB,IAAmB,EACnB,OAAkD;IAElD,SAAS,CAAC,eAAe,EAAE,CAAC;IAC5B,0FAA0F;IAC1F,MAAM,OAAO,GAA4C,EAAE,CAAC;IAC5D,MAAM,QAAQ,GAAiE,EAAE,CAAC;IAElF,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC9C,KAAK,CAAC,SAAS,GAAG,OAAO,CAAC;QAC1B,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5C,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC;QACxB,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;QAC7E,IAAI,KAAK,CAAC,WAAW;YAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC;QACvD,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEnB,IAAI,OAA6C,CAAC;QAClD,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;YAChD,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;gBAAE,MAAM,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;YACpE,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,EAAE;gBAAE,MAAM,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;YACjF,MAAM,CAAC,KAAK,GAAG,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YAClE,OAAO,GAAG,MAAM,CAAC;YACjB,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACpF,CAAC;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YAC5C,GAAG,CAAC,IAAI,GAAG,UAAU,CAAC;YACtB,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC;YACnC,OAAO,GAAG,GAAG,CAAC;YACd,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;YAC9C,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC/B,CAAC;aAAM,CAAC;YACP,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YAC5C,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;YACvD,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS;gBAAE,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACzD,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS;gBAAE,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACzD,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YACjE,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7F,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC;YACpB,OAAO,GAAG,GAAG,CAAC;YACd,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE;gBACjB,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ;oBAC1B,OAAO,GAAG,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;gBACvE,6EAA6E;gBAC7E,OAAO,GAAG,CAAC,KAAK,KAAK,EAAE,IAAI,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;YACjF,CAAC,CAAC,CAAC;QACJ,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACtB,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAED,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC;IACvB,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC;IAC3B,MAAM,CAAC,WAAW,GAAG,OAAO,CAAC;IAC7B,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtB,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEzB,MAAM,MAAM,GAAG,GAAG,EAAE,CACnB,MAAM,CAAC,WAAW,CACjB,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CACzC,CAAC;IAC9B,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC1D,SAAS,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;QAC3C,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ;YAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,OAAO;QACN,MAAM;QACN,OAAO,CAAC,IAAI;YACX,KAAK,MAAM,CAAC,IAAI,QAAQ;gBAAE,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC;YAC5C,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC;QAClD,CAAC;KACD,CAAC;AACH,CAAC"}
|
package/dist/views/capture.html
CHANGED
|
@@ -5943,15 +5943,15 @@ ${sm}`))})}function lm(e,t){let n=Math.min(1,t.transmission);if(e.userData[zu]=!
|
|
|
5943
5943
|
`))&&a<t&&r<e.byteLength;)o+=s,a+=s.length,r+=128,s=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));return-1<i&&(!1!==n&&(e.pos+=a+i+1),o+s.slice(0,i))},r=function(e){let r=/^#\?(\S+)/,i=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,a=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,o=/^\s*FORMAT=(\S+)\s*$/,s=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,c={valid:0,string:``,comments:``,programtype:`RGBE`,format:``,gamma:1,exposure:1,width:0,height:0},l,u;for((e.pos>=e.byteLength||!(l=n(e)))&&t(1,`no header found`),(u=l.match(r))||t(3,`bad initial token`),c.valid|=1,c.programtype=u[1],c.string+=l+`
|
|
5944
5944
|
`;l=n(e),!1!==l;)if(c.string+=l+`
|
|
5945
5945
|
`,l.charAt(0)===`#`)c.comments+=l+`
|
|
5946
|
-
`;else if((u=l.match(i))&&(c.gamma=parseFloat(u[1])),(u=l.match(a))&&(c.exposure=parseFloat(u[1])),(u=l.match(o))&&(c.valid|=2,c.format=u[1]),(u=l.match(s))&&(c.valid|=4,c.height=parseInt(u[1],10),c.width=parseInt(u[2],10)),c.valid&2&&c.valid&4)break;return c.valid&2||t(3,`missing format specifier`),c.valid&4||t(3,`missing image size specifier`),c},i=function(e,n,r){let i=n;if(i<8||i>32767||e[0]!==2||e[1]!==2||e[2]&128)return new Uint8Array(e);i!==(e[2]<<8|e[3])&&t(3,`wrong scanline width`);let a=new Uint8Array(4*n*r);a.length||t(4,`unable to allocate buffer space`);let o=0,s=0,c=4*i,l=new Uint8Array(4),u=new Uint8Array(c),d=r;for(;d>0&&s<e.byteLength;){s+4>e.byteLength&&t(1),l[0]=e[s++],l[1]=e[s++],l[2]=e[s++],l[3]=e[s++],(l[0]!=2||l[1]!=2||(l[2]<<8|l[3])!=i)&&t(3,`bad rgbe scanline format`);let n=0,r;for(;n<c&&s<e.byteLength;){r=e[s++];let i=r>128;if(i&&(r-=128),(r===0||n+r>c)&&t(3,`bad scanline data`),i){let t=e[s++];for(let e=0;e<r;e++)u[n++]=t}else u.set(e.subarray(s,s+r),n),n+=r,s+=r}let f=i;for(let e=0;e<f;e++){let t=0;a[o]=u[e+t],t+=i,a[o+1]=u[e+t],t+=i,a[o+2]=u[e+t],t+=i,a[o+3]=u[e+t],o+=4}d--}return a},a=function(e,t,n,r){let i=2**(e[t+3]-128)/255;n[r+0]=e[t+0]*i,n[r+1]=e[t+1]*i,n[r+2]=e[t+2]*i,n[r+3]=1},o=function(e,t,n,r){let i=2**(e[t+3]-128)/255;n[r+0]=yr.toHalfFloat(Math.min(e[t+0]*i,65504)),n[r+1]=yr.toHalfFloat(Math.min(e[t+1]*i,65504)),n[r+2]=yr.toHalfFloat(Math.min(e[t+2]*i,65504)),n[r+3]=yr.toHalfFloat(1)},s=new Uint8Array(e);s.pos=0;let c=r(s),l=c.width,u=c.height,d=i(s.subarray(s.pos),l,u),f,p,m;switch(this.type){case E:m=d.length/4;let e=new Float32Array(m*4);for(let t=0;t<m;t++)a(d,t*4,e,t*4);f=e,p=E;break;case D:m=d.length/4;let t=new Uint16Array(m*4);for(let e=0;e<m;e++)o(d,e*4,t,e*4);f=t,p=D;break;default:throw Error(`THREE.HDRLoader: Unsupported type: `+this.type)}return{width:l,height:u,data:f,header:c.string,gamma:c.gamma,exposure:c.exposure,type:p,colorSpace:Ge,minFilter:_,magFilter:_,generateMipmaps:!1,flipY:!0}}setDataType(e){return this.type=e,this}},Cy=[`technical`,`studio`,`showcase`,`arctic`,`xray`,`lineart`,`wireframe`,`night`],wy=`user`,Ty=`app:`;function Ey(e){return`${Ty}${e}`}function Dy(e){return typeof e!=`string`||!e.startsWith(Ty)?null:e.slice(4)||null}function Oy(e){let t=e.userData?.source;return t===`user`||Dy(t)!==null}function ky(e,t){return t===void 0?Oy(e):e.userData?.source===Ey(t)}var Ay=2.5,jy=11,My=4.5,Ny=3.5,Py=.05,Fy=.06,Iy=.65,Ly=.8,Ry=10;function zy(e,t,n,r){let i=new Oi(new pa(t,n),new gi({color:new Z().setScalar(e),side:2}));return i.position.set(...r),i.lookAt(0,0,0),i}function By(){let e=new zn,t=new Oi(Vy(),new gi({vertexColors:!0,side:1})),n=new Oi(new pa(Ry,Ry),new gi({color:new Z().setScalar(Py)}));return n.rotation.x=-Math.PI/2,n.position.y=-4,e.add(t,n,zy(Ay,6.5,4.5,[0,4.8,.6]),zy(jy,1.4,5.5,[-4.7,.8,1.6]),zy(My,.9,5,[4.7,.5,2.4]),zy(Ny,5,.8,[.6,2.2,-4.7])),e}function Vy(){let e=new oa(Ry,Ry,Ry,1,16,1),t=e.attributes.position,n=new Float32Array(t.count*3);for(let e=0;e<t.count;e++){let r=t.getY(e)/(Ry/2),i=r<0?Pt.lerp(Iy,Fy,-r):Pt.lerp(Iy,Ly,r);n.fill(i,e*3,e*3+3)}return e.setAttribute(`color`,new Cr(n,3)),e}function Hy(e){e.traverse(e=>{let t=e;t.geometry?.dispose(),t.material?.dispose()})}var Uy=.5,Wy=.03,Gy=`selvaReflectionEnvironment`;function Ky(e,t,n){let r=new js(t),i=By(),a=r.fromScene(i,Wy).texture;Hy(i),r.dispose(),qy(e,a,n)}function qy(e,t,n){let r={texture:t,rotation:n.clone()};e.userData[Gy]=r,Yy(e,e)}function Jy(e){e.userData[Gy]?.texture.dispose(),delete e.userData[Gy]}function Yy(e,t){let n=t.userData[Gy];n&&e.traverse(e=>{if(e.userData.source!==`compute`)return;let t=e,r=Array.isArray(t.material)?t.material:t.material?[t.material]:[];for(let e of r){if(!(e instanceof Ea)||e.envMap&&e.envMap!==n.texture)continue;let t=e.metalness>Uy?n.texture:null;e.envMap!==t&&(e.envMap=t,e.envMapRotation.copy(n.rotation),e.needsUpdate=!0)}})}function Xy(e){let t=e.clone().normalize(),n=new q(0,0,1),r=new q(0,1,0),i=Math.abs(t.dot(n))>.9?r:n,a=new q().crossVectors(i,t).normalize();return{up:t,forward:new q().crossVectors(t,a).normalize(),right:a}}function Zy(e,t){let{forward:n,right:r,up:i}=Xy(e);return n.clone().multiplyScalar(-1).add(r.clone().multiplyScalar(-1)).add(i).normalize().multiplyScalar(t)}function Qy(e,t,n){let{forward:r,right:i,up:a}=Xy(e);return i.clone().multiplyScalar(t).add(r.clone().multiplyScalar(t)).add(a.clone().multiplyScalar(n))}function $y(e){let t=e.clone().normalize(),n=new q(0,1,0);if(t.dot(n)>.9999)return new pn;if(t.dot(n)<-.9999)return new pn(Math.PI,0,0);let r=new Ft().setFromUnitVectors(n,t);return new pn().setFromQuaternion(r)}function eb(e){let t=Math.abs(e.x),n=Math.abs(e.y),r=Math.abs(e.z);return t>=n&&t>=r?`x`:n>=r?`y`:`z`}var tb=new q(0,0,1);function nb(){return(window.matchMedia?.(`(pointer: coarse)`).matches??!1)&&Math.min(window.screen.width,window.screen.height)<600}function rb(e){let t=e.sceneScale||`m`,n={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[t],r=e.look??`technical`,i=e.render?.lowPower??nb(),a=Eu(r,i);return{sceneScale:t,look:r,camera:{position:e.camera?.position||Zy(e.environment?.sceneUp??tb,n.cameraDistance*Math.sqrt(3)),fov:e.camera?.fov||20,near:e.camera?.near||n.near,far:e.camera?.far||n.far,target:e.camera?.target||new q(0,0,0),dynamicNear:e.camera?.dynamicNear??!0},lighting:{enableSunlight:e.lighting?.enableSunlight??!0,sunlightIntensity:e.lighting?.sunlightIntensity??a.sunlightIntensity,sunlightPosition:e.lighting?.sunlightPosition||Qy(e.environment?.sceneUp??tb,n.lightDistance,n.lightHeight),ambientLightColor:e.lighting?.ambientLightColor||new Z(4210752),ambientLightIntensity:e.lighting?.ambientLightIntensity??a.ambientIntensity,sunlightColor:e.lighting?.sunlightColor||16777215,enableHemisphereLight:e.lighting?.enableHemisphereLight??a.hemisphereIntensity>0,hemisphereSkyColor:e.lighting?.hemisphereSkyColor??14673663,hemisphereGroundColor:e.lighting?.hemisphereGroundColor??7036754,hemisphereIntensity:e.lighting?.hemisphereIntensity??a.hemisphereIntensity},environment:{hdrPath:e.environment?.hdrPath===!1?!1:e.environment?.hdrPath||`/baseHDR.hdr`,backgroundColor:e.environment?.backgroundColor||new Z(15790320),enableEnvironmentLighting:e.environment?.enableEnvironmentLighting??!0,sceneUp:e.environment?.sceneUp||tb,showEnvironment:e.environment?.showEnvironment??!1,environmentIntensity:e.environment?.environmentIntensity??a.environmentIntensity},floor:{enabled:e.floor?.enabled??!1,size:e.floor?.size||n.floorSize,color:e.floor?.color||new Z(8421504),roughness:e.floor?.roughness??.7,metalness:e.floor?.metalness??0,receiveShadow:e.floor?.receiveShadow??!0},render:{enableShadows:e.render?.enableShadows??!0,shadowMapSize:e.render?.shadowMapSize||1024,antialias:e.render?.antialias??!0,pixelRatio:e.render?.pixelRatio||Math.min(window.devicePixelRatio,2),toneMapping:e.render?.toneMapping??a.toneMapping,toneMappingExposure:e.render?.toneMappingExposure??a.toneMappingExposure,preserveDrawingBuffer:e.render?.preserveDrawingBuffer??!1,lowPower:i,idleRefineFrames:e.render?.idleRefineFrames??(i?0:32),lightOrbitFrameMs:e.render?.lightOrbitFrameMs??22,ambientOcclusion:e.render?.ambientOcclusion??a.ambientOcclusion,aoIntensity:e.render?.aoIntensity??1,bloom:e.render?.bloom??a.bloom,aoPixelRatio:e.render?.aoPixelRatio??1,onDemand:e.render?.onDemand??!0},controls:{enableDamping:e.controls?.enableDamping??!1,dampingFactor:e.controls?.dampingFactor||.05,autoRotate:e.controls?.autoRotate??!1,autoRotateSpeed:e.controls?.autoRotateSpeed||.5,enableZoom:e.controls?.enableZoom??!0,enablePan:e.controls?.enablePan??!0,minDistance:e.controls?.minDistance||n.minDistance,maxDistance:e.controls?.maxDistance||1/0},grid:{enabled:e.grid?.enabled??!1,cellSize:e.grid?.cellSize??1,majorEvery:e.grid?.majorEvery??10,cellColor:e.grid?.cellColor??8947848,majorColor:e.grid?.majorColor??4473924,fadeDistance:e.grid?.fadeDistance??100,plane:e.grid?.plane??eb(e.environment?.sceneUp??tb)},gizmo:{enabled:e.gizmo?.enabled??!1},edges:{enabled:e.edges?.enabled??!1,color:e.edges?.color,darken:e.edges?.darken,width:e.edges?.width??1.5,thresholdAngle:e.edges?.thresholdAngle??44,distanceFade:e.edges?.distanceFade??!0,maxTriangles:e.edges?.maxTriangles,maxSegments:e.edges?.maxSegments,maxOverlays:e.edges?.maxOverlays,screenSpaceFallback:e.edges?.screenSpaceFallback},measure:{enabled:e.measure?.enabled??!1,snapPixels:e.measure?.snapPixels,color:e.measure?.color,labelClassName:e.measure?.labelClassName,displayUnit:e.measure?.displayUnit,format:e.measure?.format},events:{onBackgroundClicked:e.events?.onBackgroundClicked,onObjectSelected:e.events?.onObjectSelected,onMeshMetadataClicked:e.events?.onMeshMetadataClicked,onMeshDoubleClicked:e.events?.onMeshDoubleClicked,selectionColor:e.events?.selectionColor||`#ff0000`,enableEventHandlers:e.events?.enableEventHandlers??!0,enableKeyboardControls:e.events?.enableKeyboardControls??!0,enableClickToFocus:e.events?.enableClickToFocus??!0,enableDoubleClickZoom:e.events?.enableDoubleClickZoom??!0,onReady:e.events?.onReady,onFrame:e.events?.onFrame},onMaxAnisotropy:e.onMaxAnisotropy}}var ib=150,ab=8,ob=12;function sb(e,t){let n=0,r=1/t;for(let i=e;i>0;i=Math.floor(i/t))n+=i%t*r,r/=t;return n}function cb(e){let t=0;return e.traverseVisible(e=>{t+=1;let{material:n}=e;for(let e of Array.isArray(n)?n:n?[n]:[])t+=e.version*31}),t}function lb(e){let{scene:t,renderer:n,getPipeline:r,frames:i,lightOrbitFrameMs:a,jitterLights:o,restoreLights:s}=e,c=0,l=0,u=0,d=new K,f=i>0&&a<=0,p=1,m=[],h=e=>{p=Math.min(1,Math.max(0,e)),r()?.setAoWeight(p)},g=e=>{m.push(e),!(m.length<ob)&&(m.sort((e,t)=>e-t),f=m[6]>a,m.length=0)},_=(e,t)=>{let r=e;if(!r.setViewOffset)return;n.getDrawingBufferSize(d);let i=t?sb(t,2)-.5:0,a=t?sb(t,3)-.5:0;r.setViewOffset(d.x,d.y,i,a,d.x,d.y)};return{reset:e=>{c=0,l=e},moving:e=>{i!==0&&(f?h(p-1/ab):g(e))},wants:e=>(c<i||p<1)&&e-l>=ib&&!!r(),step:e=>{let n=r();n&&(p<1?(h(p+1/ab),n.setCamera(e),n.accumulate(0)):(c>0&&o(c),_(e,c),n.setCamera(e),n.accumulate(c),e.clearViewOffset?.(),c>0&&s(),c+=1,c===i&&(u=cb(t))))},present:()=>i===0||c<i?!1:(r()?.presentAccumulated(),!!r()),isHolding:()=>i>0&&c>=i&&!!r()&&u===cb(t)}}var ub=.02,db=6,fb=.62,pb=.018,mb=`sun-target`;function hb(e,t){let n=new Oo(t.lighting.ambientLightColor,t.lighting.ambientLightIntensity);e.add(n);let r=null;if(t.lighting.enableHemisphereLight){r=new lo(t.lighting.hemisphereSkyColor,t.lighting.hemisphereGroundColor,t.lighting.hemisphereIntensity);let n=t.environment.sceneUp??tb;r.position.copy(n),e.add(r)}if(!t.lighting.enableSunlight)return{ambient:n,hemisphere:r,sun:null};let i=new Do(t.lighting.sunlightColor??16777215,t.lighting.sunlightIntensity),a=t.lighting.sunlightPosition;return a&&i.position.set(a.x,a.y,a.z),t.render.enableShadows?(i.castShadow=!0,i.shadow.mapSize.width=t.render.shadowMapSize,i.shadow.mapSize.height=t.render.shadowMapSize,i.shadow.bias=-1e-4,i.shadow.normalBias=ub,i.shadow.radius=db,i.shadow.blurSamples=12,i.shadow.intensity=fb,e.add(i),i.target.userData.id=mb,e.add(i.target),{ambient:n,hemisphere:r,sun:i}):(e.add(i),{ambient:n,hemisphere:r,sun:null})}function gb(e,t){let n=e.position.clone(),r=n.clone().sub(e.target.position),i=new q(0,0,1).cross(r);i.lengthSq()===0&&i.set(1,0,0),i.setLength(r.length()*pb);let a=r.clone().cross(i).setLength(i.length()),o=sb(t,2)*Math.PI*2,s=Math.sqrt(sb(t,3));return e.position.addScaledVector(i,Math.cos(o)*s).addScaledVector(a,Math.sin(o)*s),()=>e.position.copy(n)}function _b(e,t){if(t.isEmpty())return;let n=t.getCenter(new q),r=t.getSize(new q).length()*.5*1.2;if(r===0)return;e.shadow.normalBias=Math.min(ub,r*.0015);let i=e.shadow.camera;i.left=-r,i.right=r,i.top=r,i.bottom=-r;let a=e.position.clone().sub(e.target.position).normalize();e.target.position.copy(n),e.target.updateMatrixWorld();let o=r*2;e.position.copy(n).addScaledVector(a,o),e.updateMatrixWorld(),i.near=o-r,i.far=o+r,i.updateProjectionMatrix()}var vb={HUGE_THRESHOLD:1e4,LARGE_THRESHOLD:1e3,SCALE_RATIO_THRESHOLD:100,NEAR_PLANE_FACTOR:{TINY:1e-4,SMALL:.001,NORMAL:.01},FAR_PLANE_FACTOR:{HUGE:100,LARGE:50,NORMAL:20},INITIAL_DISTANCE_MULTIPLIER:4};function yb(e,t,n,r,i){if(Eb(e,wb(t)),t.length===0)return;t.forEach(t=>{e.add(t),Yy(t,e)});let a=Pu(t),o=a.getCenter(new q),s=a.getSize(new q),c=Math.max(s.x,s.y,s.z);if(c/Math.min(s.x||1,s.y||1,s.z||1)>vb.SCALE_RATIO_THRESHOLD||c>vb.HUGE_THRESHOLD?(n.near=c*vb.NEAR_PLANE_FACTOR.TINY,n.far=c*vb.FAR_PLANE_FACTOR.HUGE):c>vb.LARGE_THRESHOLD?(n.near=c*vb.NEAR_PLANE_FACTOR.SMALL,n.far=c*vb.FAR_PLANE_FACTOR.LARGE):(n.near=Math.max(.01,c*vb.NEAR_PLANE_FACTOR.NORMAL),n.far=Math.max(2e3,c*vb.FAR_PLANE_FACTOR.NORMAL)),n.updateProjectionMatrix(),!i){let e=c*vb.INITIAL_DISTANCE_MULTIPLIER;n.position.copy(o).add(Zy(n.up,e)),r.target.copy(o),r.update()}}var bb=new Set([`grid`,`floor`,`label-layer`,`measure`,mb]);function xb(e){return typeof e.userData.id==`string`&&bb.has(e.userData.id)}function Sb(e){let t=e;for(;t;){if(xb(t))return!0;t=t.parent}return!1}function Cb(e){e.updateMatrixWorld(!0);let t=new er;return e.traverse(e=>{let n=e;e.visible&&!Sb(e)&&n.geometry&&t.expandByObject(e)}),t}function wb(e){let t=new Set;for(let n of e)n.traverse(e=>{let n=e.geometry,r=n&&c(n);r&&t.add(r)});return t}var Tb=new Set([`floor`,`grid`,`label-layer`,mb]);function Eb(e,t=new Set){let n=[],r=[];for(let t of e.children)t.isLight===!0||Tb.has(t.userData.id)||Oy(t)?n.push(t):r.push(t);e.children.length=0;for(let t of n)e.children.push(t);for(let n of r)Wu(n,{keepUploaded:t}),n.parent=null,n.dispatchEvent({type:`removed`}),e.dispatchEvent({type:`childremoved`,child:n})}function Db(e){let{up:t,forward:n,right:r}=Xy(e),i=n.clone().negate(),a=r.clone();return{top:t.clone(),bottom:t.clone().negate(),front:i.clone(),back:i.clone().negate(),right:a.clone(),left:a.clone().negate(),iso:i.clone().multiplyScalar(1.2).add(a.clone()).add(t.clone()).normalize()}}function Ob(e){let{scene:t,perspective:n,controls:r,onActiveCameraChange:i}=e,a=(e.up??n.up).clone().normalize(),o=Db(a),s=new To(-1,1,1,-1,n.near,n.far);s.up.copy(a);let c=`perspective`,l=n.aspect,u=()=>c===`perspective`?n:s,d=null,f=()=>{d?.cancel(),d=null},p=()=>{let e=(c===`orthographic`?s:n).position.distanceTo(r.target)*Math.tan(n.fov*Math.PI/360),t=e*l;s.left=-t,s.right=t,s.top=e,s.bottom=-e,s.near=n.near,s.far=n.far,s.updateProjectionMatrix()},m=e=>{if(e!==c){if(f(),e===`orthographic`)s.position.copy(n.position),s.up.copy(n.up),s.lookAt(r.target),s.zoom=1,p();else{let e=(s.top-s.bottom)/(2*s.zoom)/Math.tan(n.fov*Math.PI/360),t=s.position.clone().sub(r.target);t.lengthSq()<1e-12&&t.copy(a),t.normalize(),n.position.copy(r.target).add(t.multiplyScalar(e))}c=e,r.object=u(),r.update(),i(u())}},h=(e,t,i,o)=>{let l=n.fov*(Math.PI/180),m=t/(2*Math.tan(l/2))*1.5,h=kb(i,a),g=e.clone().add(h.clone().multiplyScalar(m)),_=u();c===`orthographic`&&(s.zoom=1),f(),o?d=jb(_,r,g,e,()=>{c===`orthographic`&&p()}):(_.position.copy(g),r.target.copy(e),c===`orthographic`&&p(),r.update())},g=(e,n=!0)=>{let i=Cb(t),a=i.isEmpty()?r.target.clone():i.getCenter(new q),o=i.isEmpty()?new q(1,1,1):i.getSize(new q),s=Math.max(o.x,o.y,o.z)||1;h(a,s,e,n)};return{getActiveCamera:u,getProjection:()=>c,setProjection:m,toggleProjection:()=>(m(c===`perspective`?`orthographic`:`perspective`),c),setView:(e,t=!0)=>{g(o[e],t)},setViewDirection:g,frameBounds:(e,t=!0)=>{if(e.isEmpty())return;let n=e.getCenter(new q),i=e.getSize(new q),a=Math.max(i.x,i.y,i.z)||1,s=u().position.clone().sub(r.target);s.lengthSq()<1e-12&&s.copy(o.iso),h(n,a,s.normalize(),t)},setRotateEnabled:e=>{r.enableRotate=e},isRotateEnabled:()=>r.enableRotate,updateAspect:(e,t)=>{l=t===0?l:e/t,c===`orthographic`&&p()},dispose:f}}function kb(e,t){let{up:n,forward:r}=Xy(t),i=e.clone().normalize();if(Math.abs(i.dot(n))<.9999)return e;let a=r.clone().negate(),o=.5*Math.PI/180;return i.multiplyScalar(Math.cos(o)).add(a.multiplyScalar(Math.sin(o))).normalize()}var Ab=e=>1-(1-e)**3;function jb(e,t,n,r,i,a=250){let o=e.position.clone(),s=t.target.clone(),c=performance.now(),l=null,u=()=>{l=null;let d=Ab(Math.min((performance.now()-c)/a,1));e.position.lerpVectors(o,n,d),t.target.lerpVectors(s,r,d),i(),t.update(),d<1&&(l=requestAnimationFrame(u))};return l=requestAnimationFrame(u),{cancel:()=>{l!==null&&(cancelAnimationFrame(l),l=null)}}}var Mb=.15,Nb=4096;function Pb(e){let t=Math.floor(e.length/6);if(t===0)return 1/0;let n=Math.max(1,Math.ceil(t/Nb)),r=[];for(let i=0;i<t;i+=n){let t=i*6,n=Math.hypot(e[t+3]-e[t],e[t+4]-e[t+1],e[t+5]-e[t+2]);n>0&&r.push(n)}return r.length===0?1/0:(r.sort((e,t)=>e-t),r[Math.min(r.length-1,Math.floor(r.length*Mb))])}function Fb(e){let t=new Ju;return t.setPositions(e),{geometry:t,segmentCount:e.length/6,edgeSpacing:Pb(e)}}function Ib(e,t,n){let r=1e4,i=Math.cos(Math.PI/180*n),a=e.length/3;if(a>=67108864)throw Error(`extractEdgeSegments: ${a} vertices exceeds 2^26 limit`);let o=new Float64Array(a),s=new Float64Array(a),c=new Float64Array(a);for(let t=0;t<a;t++)o[t]=Math.round(e[3*t]*r),s[t]=Math.round(e[3*t+1]*r),c[t]=Math.round(e[3*t+2]*r);let l=16;for(;l<a*2;)l<<=1;let u=l-1,d=new Int32Array(l).fill(-1),f=new Int32Array(a);for(let e=0;e<a;e++){let t=(Math.imul(o[e]|0,73856093)^Math.imul(s[e]|0,19349663)^Math.imul(c[e]|0,83492791))&u;for(;;){let n=d[t];if(n===-1){d[t]=e,f[e]=e;break}if(o[n]===o[e]&&s[n]===s[e]&&c[n]===c[e]){f[e]=n;break}t=t+1&u}}let p=new Float32Array(6144),m=0,h=new Uint32Array(1024),g=(t,n,r)=>{if(m+6>p.length){let e=new Float32Array(p.length*2);e.set(p),p=e;let t=new Uint32Array(p.length/6);t.set(h),h=t}h[m/6]=r,p[m++]=e[3*t],p[m++]=e[3*t+1],p[m++]=e[3*t+2],p[m++]=e[3*n],p[m++]=e[3*n+1],p[m++]=e[3*n+2]},_=(t?t.length:a)/3,v=new Int32Array(a+1);for(let e=0;e<_;e++){let n=f[t?t[3*e]:3*e],r=f[t?t[3*e+1]:3*e+1],i=f[t?t[3*e+2]:3*e+2];n!==r&&r!==i&&i!==n&&(v[n+1]++,v[r+1]++,v[i+1]++)}for(let e=0;e<a;e++)v[e+1]+=v[e];let y=new Int32Array(v[a]);{let e=v.slice(0,a);for(let n=0;n<_;n++){let r=f[t?t[3*n]:3*n],i=f[t?t[3*n+1]:3*n+1],a=f[t?t[3*n+2]:3*n+2];r!==i&&i!==a&&a!==r&&(y[e[r]++]=i,y[e[i]++]=a,y[e[a]++]=r)}}let b=new Int32Array(y.length).fill(-2),x=(e,t)=>{for(let n=v[e],r=v[e+1];n<r;n++)if(y[n]===t)return n;return-1},S=(e,n)=>t?t[3*e+n]:3*e+n,C=new Float64Array(3),w=t=>{let n=S(t,0),r=S(t,1),i=S(t,2),a=e[3*i]-e[3*r],o=e[3*i+1]-e[3*r+1],s=e[3*i+2]-e[3*r+2],c=e[3*n]-e[3*r],l=e[3*n+1]-e[3*r+1],u=e[3*n+2]-e[3*r+2],d=o*u-s*l,f=s*c-a*u,p=a*l-o*c,m=d*d+f*f+p*p;if(m>0){let e=1/Math.sqrt(m);d*=e,f*=e,p*=e}else d=0,f=0,p=0;C[0]=d,C[1]=f,C[2]=p},T=0,E=new Uint32Array(Math.max(16,y.length>>1)),D=new Int32Array(E.length),O=()=>{let e=new Uint32Array(E.length*2);e.set(E),E=e;let t=new Int32Array(e.length);t.set(D),D=t};for(let e=0;e<_;e++){let t=S(e,0),n=S(e,1),r=S(e,2),a=f[t],o=f[n],s=f[r];if(a===o||o===s||s===a)continue;let c=!1,l=0,u=0,d=0;for(let f=0;f<3;f++){let p=f===0?a:f===1?o:s,m=f===0?o:f===1?s:a,h=x(m,p),_=h===-1?-2:b[h];if(_>=0)c||=(w(e),l=C[0],u=C[1],d=C[2],!0),w(Math.floor(E[_]/3)),l*C[0]+u*C[1]+d*C[2]<=i&&g(f===0?t:f===1?n:r,f===0?n:f===1?r:t,e),b[h]=-1;else{let t=x(p,m);if(b[t]===-2){T===E.length&&O();let n=T++;b[t]=n,E[n]=3*e+f,D[n]=t}}}}for(let e=0;e<T;e++){if(b[D[e]]!==e)continue;let t=E[e],n=Math.floor(t/3),r=t-3*n;g(S(n,r),S(n,r===2?0:r+1),n)}return{segments:p.slice(0,m),faces:h.slice(0,m/6)}}function Lb(){return[`const extract = ${Ib.toString()};`,`self.onmessage = (event) => {`,` const { id, positions, index, thresholdAngle } = event.data;`,` try {`,` const { segments, faces } = extract(positions, index, thresholdAngle);`,` self.postMessage({ id, segments, faces }, [segments.buffer, faces.buffer]);`,` } catch (error) {`,` self.postMessage({ id, error: String((error && error.message) || error) });`,` }`,`};`].join(`
|
|
5947
|
-
`)}var
|
|
5946
|
+
`;else if((u=l.match(i))&&(c.gamma=parseFloat(u[1])),(u=l.match(a))&&(c.exposure=parseFloat(u[1])),(u=l.match(o))&&(c.valid|=2,c.format=u[1]),(u=l.match(s))&&(c.valid|=4,c.height=parseInt(u[1],10),c.width=parseInt(u[2],10)),c.valid&2&&c.valid&4)break;return c.valid&2||t(3,`missing format specifier`),c.valid&4||t(3,`missing image size specifier`),c},i=function(e,n,r){let i=n;if(i<8||i>32767||e[0]!==2||e[1]!==2||e[2]&128)return new Uint8Array(e);i!==(e[2]<<8|e[3])&&t(3,`wrong scanline width`);let a=new Uint8Array(4*n*r);a.length||t(4,`unable to allocate buffer space`);let o=0,s=0,c=4*i,l=new Uint8Array(4),u=new Uint8Array(c),d=r;for(;d>0&&s<e.byteLength;){s+4>e.byteLength&&t(1),l[0]=e[s++],l[1]=e[s++],l[2]=e[s++],l[3]=e[s++],(l[0]!=2||l[1]!=2||(l[2]<<8|l[3])!=i)&&t(3,`bad rgbe scanline format`);let n=0,r;for(;n<c&&s<e.byteLength;){r=e[s++];let i=r>128;if(i&&(r-=128),(r===0||n+r>c)&&t(3,`bad scanline data`),i){let t=e[s++];for(let e=0;e<r;e++)u[n++]=t}else u.set(e.subarray(s,s+r),n),n+=r,s+=r}let f=i;for(let e=0;e<f;e++){let t=0;a[o]=u[e+t],t+=i,a[o+1]=u[e+t],t+=i,a[o+2]=u[e+t],t+=i,a[o+3]=u[e+t],o+=4}d--}return a},a=function(e,t,n,r){let i=2**(e[t+3]-128)/255;n[r+0]=e[t+0]*i,n[r+1]=e[t+1]*i,n[r+2]=e[t+2]*i,n[r+3]=1},o=function(e,t,n,r){let i=2**(e[t+3]-128)/255;n[r+0]=yr.toHalfFloat(Math.min(e[t+0]*i,65504)),n[r+1]=yr.toHalfFloat(Math.min(e[t+1]*i,65504)),n[r+2]=yr.toHalfFloat(Math.min(e[t+2]*i,65504)),n[r+3]=yr.toHalfFloat(1)},s=new Uint8Array(e);s.pos=0;let c=r(s),l=c.width,u=c.height,d=i(s.subarray(s.pos),l,u),f,p,m;switch(this.type){case E:m=d.length/4;let e=new Float32Array(m*4);for(let t=0;t<m;t++)a(d,t*4,e,t*4);f=e,p=E;break;case D:m=d.length/4;let t=new Uint16Array(m*4);for(let e=0;e<m;e++)o(d,e*4,t,e*4);f=t,p=D;break;default:throw Error(`THREE.HDRLoader: Unsupported type: `+this.type)}return{width:l,height:u,data:f,header:c.string,gamma:c.gamma,exposure:c.exposure,type:p,colorSpace:Ge,minFilter:_,magFilter:_,generateMipmaps:!1,flipY:!0}}setDataType(e){return this.type=e,this}},Cy=[`technical`,`studio`,`showcase`,`arctic`,`xray`,`lineart`,`wireframe`,`night`],wy=`user`,Ty=`app:`;function Ey(e){return`${Ty}${e}`}function Dy(e){return typeof e!=`string`||!e.startsWith(Ty)?null:e.slice(4)||null}function Oy(e){let t=e.userData?.source;return t===`user`||Dy(t)!==null}function ky(e,t){return t===void 0?Oy(e):e.userData?.source===Ey(t)}var Ay=2.5,jy=11,My=4.5,Ny=3.5,Py=.05,Fy=.06,Iy=.65,Ly=.8,Ry=10;function zy(e,t,n,r){let i=new Oi(new pa(t,n),new gi({color:new Z().setScalar(e),side:2}));return i.position.set(...r),i.lookAt(0,0,0),i}function By(){let e=new zn,t=new Oi(Vy(),new gi({vertexColors:!0,side:1})),n=new Oi(new pa(Ry,Ry),new gi({color:new Z().setScalar(Py)}));return n.rotation.x=-Math.PI/2,n.position.y=-4,e.add(t,n,zy(Ay,6.5,4.5,[0,4.8,.6]),zy(jy,1.4,5.5,[-4.7,.8,1.6]),zy(My,.9,5,[4.7,.5,2.4]),zy(Ny,5,.8,[.6,2.2,-4.7])),e}function Vy(){let e=new oa(Ry,Ry,Ry,1,16,1),t=e.attributes.position,n=new Float32Array(t.count*3);for(let e=0;e<t.count;e++){let r=t.getY(e)/(Ry/2),i=r<0?Pt.lerp(Iy,Fy,-r):Pt.lerp(Iy,Ly,r);n.fill(i,e*3,e*3+3)}return e.setAttribute(`color`,new Cr(n,3)),e}function Hy(e){e.traverse(e=>{let t=e;t.geometry?.dispose(),t.material?.dispose()})}var Uy=.5,Wy=.03,Gy=`selvaReflectionEnvironment`;function Ky(e,t,n){let r=new js(t),i=By(),a=r.fromScene(i,Wy).texture;Hy(i),r.dispose(),qy(e,a,n)}function qy(e,t,n){let r={texture:t,rotation:n.clone()};e.userData[Gy]=r,Yy(e,e)}function Jy(e){e.userData[Gy]?.texture.dispose(),delete e.userData[Gy]}function Yy(e,t){let n=t.userData[Gy];n&&e.traverse(e=>{if(e.userData.source!==`compute`)return;let t=e,r=Array.isArray(t.material)?t.material:t.material?[t.material]:[];for(let e of r){if(!(e instanceof Ea)||e.envMap&&e.envMap!==n.texture)continue;let t=e.metalness>Uy?n.texture:null;e.envMap!==t&&(e.envMap=t,e.envMapRotation.copy(n.rotation),e.needsUpdate=!0)}})}function Xy(e){let t=e.clone().normalize(),n=new q(0,0,1),r=new q(0,1,0),i=Math.abs(t.dot(n))>.9?r:n,a=new q().crossVectors(i,t).normalize();return{up:t,forward:new q().crossVectors(t,a).normalize(),right:a}}function Zy(e,t){let{forward:n,right:r,up:i}=Xy(e);return n.clone().multiplyScalar(-1).add(r.clone().multiplyScalar(-1)).add(i).normalize().multiplyScalar(t)}function Qy(e,t,n){let{forward:r,right:i,up:a}=Xy(e);return i.clone().multiplyScalar(t).add(r.clone().multiplyScalar(t)).add(a.clone().multiplyScalar(n))}function $y(e){let t=e.clone().normalize(),n=new q(0,1,0);if(t.dot(n)>.9999)return new pn;if(t.dot(n)<-.9999)return new pn(Math.PI,0,0);let r=new Ft().setFromUnitVectors(n,t);return new pn().setFromQuaternion(r)}function eb(e){let t=Math.abs(e.x),n=Math.abs(e.y),r=Math.abs(e.z);return t>=n&&t>=r?`x`:n>=r?`y`:`z`}var tb=new q(0,0,1);function nb(){return(window.matchMedia?.(`(pointer: coarse)`).matches??!1)&&Math.min(window.screen.width,window.screen.height)<600}function rb(e){let t=e.sceneScale||`m`,n={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[t],r=e.look??`technical`,i=e.render?.lowPower??nb(),a=Eu(r,i);return{sceneScale:t,look:r,camera:{position:e.camera?.position||Zy(e.environment?.sceneUp??tb,n.cameraDistance*Math.sqrt(3)),fov:e.camera?.fov||20,near:e.camera?.near||n.near,far:e.camera?.far||n.far,target:e.camera?.target||new q(0,0,0),dynamicNear:e.camera?.dynamicNear??!0},lighting:{enableSunlight:e.lighting?.enableSunlight??!0,sunlightIntensity:e.lighting?.sunlightIntensity??a.sunlightIntensity,sunlightPosition:e.lighting?.sunlightPosition||Qy(e.environment?.sceneUp??tb,n.lightDistance,n.lightHeight),ambientLightColor:e.lighting?.ambientLightColor||new Z(4210752),ambientLightIntensity:e.lighting?.ambientLightIntensity??a.ambientIntensity,sunlightColor:e.lighting?.sunlightColor||16777215,enableHemisphereLight:e.lighting?.enableHemisphereLight??a.hemisphereIntensity>0,hemisphereSkyColor:e.lighting?.hemisphereSkyColor??14673663,hemisphereGroundColor:e.lighting?.hemisphereGroundColor??7036754,hemisphereIntensity:e.lighting?.hemisphereIntensity??a.hemisphereIntensity},environment:{hdrPath:e.environment?.hdrPath===!1?!1:e.environment?.hdrPath||`/baseHDR.hdr`,backgroundColor:e.environment?.backgroundColor||new Z(15790320),enableEnvironmentLighting:e.environment?.enableEnvironmentLighting??!0,sceneUp:e.environment?.sceneUp||tb,showEnvironment:e.environment?.showEnvironment??!1,environmentIntensity:e.environment?.environmentIntensity??a.environmentIntensity},floor:{enabled:e.floor?.enabled??!1,size:e.floor?.size||n.floorSize,color:e.floor?.color||new Z(8421504),roughness:e.floor?.roughness??.7,metalness:e.floor?.metalness??0,receiveShadow:e.floor?.receiveShadow??!0},render:{enableShadows:e.render?.enableShadows??!0,shadowMapSize:e.render?.shadowMapSize||1024,antialias:e.render?.antialias??!0,pixelRatio:e.render?.pixelRatio||Math.min(window.devicePixelRatio,2),toneMapping:e.render?.toneMapping??a.toneMapping,toneMappingExposure:e.render?.toneMappingExposure??a.toneMappingExposure,preserveDrawingBuffer:e.render?.preserveDrawingBuffer??!1,lowPower:i,idleRefineFrames:e.render?.idleRefineFrames??(i?0:32),lightOrbitFrameMs:e.render?.lightOrbitFrameMs??22,ambientOcclusion:e.render?.ambientOcclusion??a.ambientOcclusion,aoIntensity:e.render?.aoIntensity??1,bloom:e.render?.bloom??a.bloom,aoPixelRatio:e.render?.aoPixelRatio??1,onDemand:e.render?.onDemand??!0},controls:{enableDamping:e.controls?.enableDamping??!1,dampingFactor:e.controls?.dampingFactor||.05,autoRotate:e.controls?.autoRotate??!1,autoRotateSpeed:e.controls?.autoRotateSpeed||.5,enableZoom:e.controls?.enableZoom??!0,enablePan:e.controls?.enablePan??!0,minDistance:e.controls?.minDistance||n.minDistance,maxDistance:e.controls?.maxDistance||1/0},grid:{enabled:e.grid?.enabled??!1,cellSize:e.grid?.cellSize??1,majorEvery:e.grid?.majorEvery??10,cellColor:e.grid?.cellColor??8947848,majorColor:e.grid?.majorColor??4473924,fadeDistance:e.grid?.fadeDistance??100,plane:e.grid?.plane??eb(e.environment?.sceneUp??tb)},gizmo:{enabled:e.gizmo?.enabled??!1},edges:{enabled:e.edges?.enabled??!1,color:e.edges?.color,darken:e.edges?.darken,width:e.edges?.width??1.5,thresholdAngle:e.edges?.thresholdAngle??44,distanceFade:e.edges?.distanceFade??!0,maxTriangles:e.edges?.maxTriangles,maxSegments:e.edges?.maxSegments,maxOverlays:e.edges?.maxOverlays,screenSpaceFallback:e.edges?.screenSpaceFallback},measure:{enabled:e.measure?.enabled??!1,snapPixels:e.measure?.snapPixels,color:e.measure?.color,labelClassName:e.measure?.labelClassName,displayUnit:e.measure?.displayUnit,format:e.measure?.format},events:{onBackgroundClicked:e.events?.onBackgroundClicked,onObjectSelected:e.events?.onObjectSelected,onMeshMetadataClicked:e.events?.onMeshMetadataClicked,onMeshDoubleClicked:e.events?.onMeshDoubleClicked,selectionColor:e.events?.selectionColor||`#ff0000`,enableEventHandlers:e.events?.enableEventHandlers??!0,enableKeyboardControls:e.events?.enableKeyboardControls??!0,enableClickToFocus:e.events?.enableClickToFocus??!0,enableDoubleClickZoom:e.events?.enableDoubleClickZoom??!0,onReady:e.events?.onReady,onFrame:e.events?.onFrame},onMaxAnisotropy:e.onMaxAnisotropy}}var ib=150,ab=8,ob=12;function sb(e,t){let n=0,r=1/t;for(let i=e;i>0;i=Math.floor(i/t))n+=i%t*r,r/=t;return n}function cb(e){let t=0;return e.traverseVisible(e=>{t+=1;let{material:n}=e;for(let e of Array.isArray(n)?n:n?[n]:[])t+=e.version*31}),t}function lb(e){let{scene:t,renderer:n,getPipeline:r,frames:i,lightOrbitFrameMs:a,jitterLights:o,restoreLights:s}=e,c=0,l=0,u=0,d=new K,f=i>0&&a<=0,p=1,m=[],h=e=>{p=Math.min(1,Math.max(0,e)),r()?.setAoWeight(p)},g=e=>{m.push(e),!(m.length<ob)&&(m.sort((e,t)=>e-t),f=m[6]>a,m.length=0)},_=(e,t)=>{let r=e;if(!r.setViewOffset)return;n.getDrawingBufferSize(d);let i=t?sb(t,2)-.5:0,a=t?sb(t,3)-.5:0;r.setViewOffset(d.x,d.y,i,a,d.x,d.y)};return{reset:e=>{c=0,l=e},moving:e=>{i!==0&&(f?h(p-1/ab):g(e))},wants:e=>(c<i||p<1)&&e-l>=ib&&!!r(),step:e=>{let n=r();n&&(p<1?(h(p+1/ab),n.setCamera(e),n.accumulate(0)):(c>0&&o(c),_(e,c),n.setCamera(e),n.accumulate(c),e.clearViewOffset?.(),c>0&&s(),c+=1,c===i&&(u=cb(t))))},present:()=>i===0||c<i?!1:(r()?.presentAccumulated(),!!r()),isHolding:()=>i>0&&c>=i&&!!r()&&u===cb(t)}}var ub=.02,db=6,fb=.62,pb=.018,mb=`sun-target`;function hb(e,t){let n=new Oo(t.lighting.ambientLightColor,t.lighting.ambientLightIntensity);e.add(n);let r=null;if(t.lighting.enableHemisphereLight){r=new lo(t.lighting.hemisphereSkyColor,t.lighting.hemisphereGroundColor,t.lighting.hemisphereIntensity);let n=t.environment.sceneUp??tb;r.position.copy(n),e.add(r)}if(!t.lighting.enableSunlight)return{ambient:n,hemisphere:r,sun:null};let i=new Do(t.lighting.sunlightColor??16777215,t.lighting.sunlightIntensity),a=t.lighting.sunlightPosition;return a&&i.position.set(a.x,a.y,a.z),t.render.enableShadows?(i.castShadow=!0,i.shadow.mapSize.width=t.render.shadowMapSize,i.shadow.mapSize.height=t.render.shadowMapSize,i.shadow.bias=-1e-4,i.shadow.normalBias=ub,i.shadow.radius=db,i.shadow.blurSamples=12,i.shadow.intensity=fb,e.add(i),i.target.userData.id=mb,e.add(i.target),{ambient:n,hemisphere:r,sun:i}):(e.add(i),{ambient:n,hemisphere:r,sun:null})}function gb(e,t){let n=e.position.clone(),r=n.clone().sub(e.target.position),i=new q(0,0,1).cross(r);i.lengthSq()===0&&i.set(1,0,0),i.setLength(r.length()*pb);let a=r.clone().cross(i).setLength(i.length()),o=sb(t,2)*Math.PI*2,s=Math.sqrt(sb(t,3));return e.position.addScaledVector(i,Math.cos(o)*s).addScaledVector(a,Math.sin(o)*s),()=>e.position.copy(n)}function _b(e,t){if(t.isEmpty())return;let n=t.getCenter(new q),r=t.getSize(new q).length()*.5*1.2;if(r===0)return;e.shadow.normalBias=Math.min(ub,r*.0015);let i=e.shadow.camera;i.left=-r,i.right=r,i.top=r,i.bottom=-r;let a=e.position.clone().sub(e.target.position).normalize();e.target.position.copy(n),e.target.updateMatrixWorld();let o=r*2;e.position.copy(n).addScaledVector(a,o),e.updateMatrixWorld(),i.near=o-r,i.far=o+r,i.updateProjectionMatrix()}var vb={HUGE_THRESHOLD:1e4,LARGE_THRESHOLD:1e3,SCALE_RATIO_THRESHOLD:100,NEAR_PLANE_FACTOR:{TINY:1e-4,SMALL:.001,NORMAL:.01},FAR_PLANE_FACTOR:{HUGE:100,LARGE:50,NORMAL:20},INITIAL_DISTANCE_MULTIPLIER:4};function yb(e,t,n,r,i){if(Eb(e,wb(t)),t.length===0)return;t.forEach(t=>{e.add(t),Yy(t,e)});let a=Pu(t),o=a.getCenter(new q),s=a.getSize(new q),c=Math.max(s.x,s.y,s.z);if(c/Math.min(s.x||1,s.y||1,s.z||1)>vb.SCALE_RATIO_THRESHOLD||c>vb.HUGE_THRESHOLD?(n.near=c*vb.NEAR_PLANE_FACTOR.TINY,n.far=c*vb.FAR_PLANE_FACTOR.HUGE):c>vb.LARGE_THRESHOLD?(n.near=c*vb.NEAR_PLANE_FACTOR.SMALL,n.far=c*vb.FAR_PLANE_FACTOR.LARGE):(n.near=Math.max(.01,c*vb.NEAR_PLANE_FACTOR.NORMAL),n.far=Math.max(2e3,c*vb.FAR_PLANE_FACTOR.NORMAL)),n.updateProjectionMatrix(),!i){let e=c*vb.INITIAL_DISTANCE_MULTIPLIER;n.position.copy(o).add(Zy(n.up,e)),r.target.copy(o),r.update()}}var bb=new Set([`grid`,`floor`,`label-layer`,`measure`,mb]);function xb(e){return typeof e.userData.id==`string`&&bb.has(e.userData.id)}function Sb(e){let t=e;for(;t;){if(xb(t))return!0;t=t.parent}return!1}function Cb(e){e.updateMatrixWorld(!0);let t=new er;return e.traverse(e=>{let n=e;e.visible&&!Sb(e)&&n.geometry&&t.expandByObject(e)}),t}function wb(e){let t=new Set;for(let n of e)n.traverse(e=>{let n=e.geometry,r=n&&c(n);r&&t.add(r)});return t}var Tb=new Set([`floor`,`grid`,`label-layer`,mb]);function Eb(e,t=new Set){let n=[],r=[];for(let t of e.children)t.isLight===!0||Tb.has(t.userData.id)||Oy(t)?n.push(t):r.push(t);e.children.length=0;for(let t of n)e.children.push(t);for(let n of r)Wu(n,{keepUploaded:t}),n.parent=null,n.dispatchEvent({type:`removed`}),e.dispatchEvent({type:`childremoved`,child:n})}function Db(e){let{up:t,forward:n,right:r}=Xy(e),i=n.clone().negate(),a=r.clone();return{top:t.clone(),bottom:t.clone().negate(),front:i.clone(),back:i.clone().negate(),right:a.clone(),left:a.clone().negate(),iso:i.clone().multiplyScalar(1.2).add(a.clone()).add(t.clone()).normalize()}}function Ob(e){let{scene:t,perspective:n,controls:r,onActiveCameraChange:i}=e,a=(e.up??n.up).clone().normalize(),o=Db(a),s=new To(-1,1,1,-1,n.near,n.far);s.up.copy(a);let c=`perspective`,l=n.aspect,u=()=>c===`perspective`?n:s,d=null,f=()=>{d?.cancel(),d=null},p=()=>{let e=(c===`orthographic`?s:n).position.distanceTo(r.target)*Math.tan(n.fov*Math.PI/360),t=e*l;s.left=-t,s.right=t,s.top=e,s.bottom=-e,s.near=n.near,s.far=n.far,s.updateProjectionMatrix()},m=e=>{if(e!==c){if(f(),e===`orthographic`)s.position.copy(n.position),s.up.copy(n.up),s.lookAt(r.target),s.zoom=1,p();else{let e=(s.top-s.bottom)/(2*s.zoom)/Math.tan(n.fov*Math.PI/360),t=s.position.clone().sub(r.target);t.lengthSq()<1e-12&&t.copy(a),t.normalize(),n.position.copy(r.target).add(t.multiplyScalar(e))}c=e,r.object=u(),r.update(),i(u())}},h=(e,t,i,o)=>{let l=n.fov*(Math.PI/180),m=t/(2*Math.tan(l/2))*1.5,h=jb(i,a),g=e.clone().add(h.clone().multiplyScalar(m)),_=u();c===`orthographic`&&(s.zoom=1),f(),o?d=Nb(_,r,g,e,()=>{c===`orthographic`&&p()}):(_.position.copy(g),r.target.copy(e),c===`orthographic`&&p(),r.update())},g=(e,n=!0)=>{let i=Cb(t),a=i.isEmpty()?r.target.clone():i.getCenter(new q),o=i.isEmpty()?new q(1,1,1):i.getSize(new q),s=Math.max(o.x,o.y,o.z)||1;h(a,s,e,n)},_=(e,t=!0)=>{if(e.isEmpty())return;let n=e.getCenter(new q),i=e.getSize(new q),a=Math.max(i.x,i.y,i.z)||1,s=u().position.clone().sub(r.target);s.lengthSq()<1e-12&&s.copy(o.iso),h(n,a,s.normalize(),t)},v=(e,t=!0)=>{g(o[e],t)};return{getActiveCamera:u,getProjection:()=>c,setProjection:m,toggleProjection:()=>(m(c===`perspective`?`orthographic`:`perspective`),c),setView:v,setViewDirection:g,getCameraView:()=>{let e=r.target,t=u().position.clone().sub(e);return t.lengthSq()<1e-12&&t.copy(o.iso),c===`orthographic`&&t.divideScalar(s.zoom),{direction:kb(t.clone().normalize()),position:kb(e.clone().add(t)),target:kb(e)}},setCameraView:(e,t=!1)=>{let n=Ab(e.position),i=Ab(e.target);if(n&&i&&n.distanceToSquared(i)>1e-12){f();let e=u();if(c===`orthographic`&&(s.zoom=1),t){d=Nb(e,r,n,i,()=>{c===`orthographic`&&p()});return}e.position.copy(n),r.target.copy(i),c===`orthographic`&&p(),r.update();return}let a=Ab(e.direction);a&&a.lengthSq()>1e-12?g(a.normalize(),t):v(`iso`,t)},frameBounds:_,setRotateEnabled:e=>{r.enableRotate=e},isRotateEnabled:()=>r.enableRotate,updateAspect:(e,t)=>{l=t===0?l:e/t,c===`orthographic`&&p()},dispose:f}}var kb=e=>[e.x,e.y,e.z].map(e=>Math.round(e*1e6)/1e6),Ab=e=>e?.length===3&&e.every(Number.isFinite)?new q(e[0],e[1],e[2]):void 0;function jb(e,t){let{up:n,forward:r}=Xy(t),i=e.clone().normalize();if(Math.abs(i.dot(n))<.9999)return e;let a=r.clone().negate(),o=.5*Math.PI/180;return i.multiplyScalar(Math.cos(o)).add(a.multiplyScalar(Math.sin(o))).normalize()}var Mb=e=>1-(1-e)**3;function Nb(e,t,n,r,i,a=250){let o=e.position.clone(),s=t.target.clone(),c=performance.now(),l=null,u=()=>{l=null;let d=Mb(Math.min((performance.now()-c)/a,1));e.position.lerpVectors(o,n,d),t.target.lerpVectors(s,r,d),i(),t.update(),d<1&&(l=requestAnimationFrame(u))};return l=requestAnimationFrame(u),{cancel:()=>{l!==null&&(cancelAnimationFrame(l),l=null)}}}var Pb=.15,Fb=4096;function Ib(e){let t=Math.floor(e.length/6);if(t===0)return 1/0;let n=Math.max(1,Math.ceil(t/Fb)),r=[];for(let i=0;i<t;i+=n){let t=i*6,n=Math.hypot(e[t+3]-e[t],e[t+4]-e[t+1],e[t+5]-e[t+2]);n>0&&r.push(n)}return r.length===0?1/0:(r.sort((e,t)=>e-t),r[Math.min(r.length-1,Math.floor(r.length*Pb))])}function Lb(e){let t=new Ju;return t.setPositions(e),{geometry:t,segmentCount:e.length/6,edgeSpacing:Ib(e)}}function Rb(e,t,n){let r=1e4,i=Math.cos(Math.PI/180*n),a=e.length/3;if(a>=67108864)throw Error(`extractEdgeSegments: ${a} vertices exceeds 2^26 limit`);let o=new Float64Array(a),s=new Float64Array(a),c=new Float64Array(a);for(let t=0;t<a;t++)o[t]=Math.round(e[3*t]*r),s[t]=Math.round(e[3*t+1]*r),c[t]=Math.round(e[3*t+2]*r);let l=16;for(;l<a*2;)l<<=1;let u=l-1,d=new Int32Array(l).fill(-1),f=new Int32Array(a);for(let e=0;e<a;e++){let t=(Math.imul(o[e]|0,73856093)^Math.imul(s[e]|0,19349663)^Math.imul(c[e]|0,83492791))&u;for(;;){let n=d[t];if(n===-1){d[t]=e,f[e]=e;break}if(o[n]===o[e]&&s[n]===s[e]&&c[n]===c[e]){f[e]=n;break}t=t+1&u}}let p=new Float32Array(6144),m=0,h=new Uint32Array(1024),g=(t,n,r)=>{if(m+6>p.length){let e=new Float32Array(p.length*2);e.set(p),p=e;let t=new Uint32Array(p.length/6);t.set(h),h=t}h[m/6]=r,p[m++]=e[3*t],p[m++]=e[3*t+1],p[m++]=e[3*t+2],p[m++]=e[3*n],p[m++]=e[3*n+1],p[m++]=e[3*n+2]},_=(t?t.length:a)/3,v=new Int32Array(a+1);for(let e=0;e<_;e++){let n=f[t?t[3*e]:3*e],r=f[t?t[3*e+1]:3*e+1],i=f[t?t[3*e+2]:3*e+2];n!==r&&r!==i&&i!==n&&(v[n+1]++,v[r+1]++,v[i+1]++)}for(let e=0;e<a;e++)v[e+1]+=v[e];let y=new Int32Array(v[a]);{let e=v.slice(0,a);for(let n=0;n<_;n++){let r=f[t?t[3*n]:3*n],i=f[t?t[3*n+1]:3*n+1],a=f[t?t[3*n+2]:3*n+2];r!==i&&i!==a&&a!==r&&(y[e[r]++]=i,y[e[i]++]=a,y[e[a]++]=r)}}let b=new Int32Array(y.length).fill(-2),x=(e,t)=>{for(let n=v[e],r=v[e+1];n<r;n++)if(y[n]===t)return n;return-1},S=(e,n)=>t?t[3*e+n]:3*e+n,C=new Float64Array(3),w=t=>{let n=S(t,0),r=S(t,1),i=S(t,2),a=e[3*i]-e[3*r],o=e[3*i+1]-e[3*r+1],s=e[3*i+2]-e[3*r+2],c=e[3*n]-e[3*r],l=e[3*n+1]-e[3*r+1],u=e[3*n+2]-e[3*r+2],d=o*u-s*l,f=s*c-a*u,p=a*l-o*c,m=d*d+f*f+p*p;if(m>0){let e=1/Math.sqrt(m);d*=e,f*=e,p*=e}else d=0,f=0,p=0;C[0]=d,C[1]=f,C[2]=p},T=0,E=new Uint32Array(Math.max(16,y.length>>1)),D=new Int32Array(E.length),O=()=>{let e=new Uint32Array(E.length*2);e.set(E),E=e;let t=new Int32Array(e.length);t.set(D),D=t};for(let e=0;e<_;e++){let t=S(e,0),n=S(e,1),r=S(e,2),a=f[t],o=f[n],s=f[r];if(a===o||o===s||s===a)continue;let c=!1,l=0,u=0,d=0;for(let f=0;f<3;f++){let p=f===0?a:f===1?o:s,m=f===0?o:f===1?s:a,h=x(m,p),_=h===-1?-2:b[h];if(_>=0)c||=(w(e),l=C[0],u=C[1],d=C[2],!0),w(Math.floor(E[_]/3)),l*C[0]+u*C[1]+d*C[2]<=i&&g(f===0?t:f===1?n:r,f===0?n:f===1?r:t,e),b[h]=-1;else{let t=x(p,m);if(b[t]===-2){T===E.length&&O();let n=T++;b[t]=n,E[n]=3*e+f,D[n]=t}}}}for(let e=0;e<T;e++){if(b[D[e]]!==e)continue;let t=E[e],n=Math.floor(t/3),r=t-3*n;g(S(n,r),S(n,r===2?0:r+1),n)}return{segments:p.slice(0,m),faces:h.slice(0,m/6)}}function zb(){return[`const extract = ${Rb.toString()};`,`self.onmessage = (event) => {`,` const { id, positions, index, thresholdAngle } = event.data;`,` try {`,` const { segments, faces } = extract(positions, index, thresholdAngle);`,` self.postMessage({ id, segments, faces }, [segments.buffer, faces.buffer]);`,` } catch (error) {`,` self.postMessage({ id, error: String((error && error.message) || error) });`,` }`,`};`].join(`
|
|
5947
|
+
`)}var Bb=`edge-overlay`,Vb=`triangle-cap`,Hb=`overlay-budget`,Ub=2236962,Wb=1.5,Gb=44,Kb=.75,qb=8e6,Jb=2e6,Yb=1500;function Xb(e){return{forcedColor:e.color==null?null:new Z(e.color),darken:Pt.clamp(e.darken??Kb,0,1),width:e.width??Wb,thresholdAngle:e.thresholdAngle??Gb,distanceFade:e.distanceFade??!0,maxTriangles:e.maxTriangles??qb,maxSegments:e.maxSegments??Jb,maxOverlays:e.maxOverlays??Yb}}function Zb(e){let t=e.getAttribute(`position`);return t?(e.index?e.index.count:t.count)/3:0}function Qb(e){let t=e.getAttribute(`position`);if(!t||t.isInterleavedBufferAttribute||t.itemSize!==3||!(t.array instanceof Float32Array)||t.count>=67108864)return null;let n=e.index;return n&&!(n.array instanceof Uint32Array)&&!(n.array instanceof Uint16Array)?null:{positions:t.array,index:n?n.array:null,version:`${t.version}:${n?.version??0}`}}function $b(e,t){let n=4096,r=2166136261,i=e=>{r^=e,r=Math.imul(r,16777619)},a=new Uint32Array(e.positions.buffer,e.positions.byteOffset,e.positions.length),o=Math.min(n,a.length);for(let e=0;e<o;e++)i(a[e]);for(let e=Math.max(o,a.length-n);e<a.length;e++)i(a[e]);let s=0;if(e.index){s=e.index.length;let t=Math.min(n,s);for(let n=0;n<t;n++)i(e.index[n]);for(let r=Math.max(t,s-n);r<s;r++)i(e.index[r])}return`${t}:${e.positions.length}:${s}:${r>>>0}`}function ex(e,t){let n=new fa(e,t),r=n.attributes.position?n.attributes.position.array:new Float32Array;return n.dispose(),{segments:r,faces:null}}var tx=new WeakMap,nx={};function rx(e,t){let n=tx.get(e.positions)?.get(e.index??nx)?.get(t);return n?.version===e.version?n.edges:void 0}function ix(e,t,n){let r=tx.get(e.positions);r||tx.set(e.positions,r=new WeakMap);let i=r.get(e.index??nx);return i||r.set(e.index??nx,i=new Map),i.set(t,{version:e.version,edges:n}),n}function ax(e,t){let n=Qb(e);return n?rx(n,t)??ix(n,t,Rb(n.positions,n.index,t)):ex(e,t)}var ox,sx=new Map,cx=1;function lx(){if(ox!==void 0)return ox;if(typeof Worker>`u`||typeof Blob>`u`||typeof URL>`u`||typeof URL.createObjectURL!=`function`)return ox=null,null;try{let e=URL.createObjectURL(new Blob([zb()],{type:`text/javascript`})),t=new Worker(e);t.onmessage=e=>{let{id:t,segments:n,faces:r,error:i}=e.data,a=sx.get(t);a&&(sx.delete(t),n?a.resolve({segments:n,faces:r??null}):a.reject(Error(i??`edge extraction failed in worker`)))},t.onerror=()=>{for(let e of sx.values())e.reject(Error(`edge extraction worker crashed`));sx.clear(),t.terminate(),ox=null},ox=t}catch{ox=null}return ox}function ux(e,t,n){return new Promise((r,i)=>{let a=cx++;sx.set(a,{resolve:r,reject:i});let o=t.positions.slice(),s=t.index?t.index.slice():null,c=[o.buffer];s&&c.push(s.buffer),e.postMessage({id:a,positions:o,index:s,thresholdAngle:n},c)})}var dx=new Map;function fx(e,t){let n=Qb(e);if(!n||Zb(e)<25e3)return Promise.resolve(ax(e,t));let r=rx(n,t);if(r)return Promise.resolve(r);let i=$b(n,t),a=dx.get(i);if(a)return a;let o=lx();if(!o)return Promise.resolve(ax(e,t));let s=ux(o,n,t).catch(()=>Rb(n.positions,n.index,t)).then(e=>ix(n,t,e)).finally(()=>{dx.delete(i)});return dx.set(i,s),s}function px(e){let t=e.userData?.members;return Array.isArray(t)&&t.length>0?t:null}function mx(e){let t=px(e.object);if(!t||e.faceIndex==null)return null;let n=e.faceIndex*3,r=0,i=t.length-1;for(;r<=i;){let e=r+i>>1,a=t[e];if(a.indexStart==null||a.indexCount==null)return null;if(n<a.indexStart)i=e-1;else if(n>=a.indexStart+a.indexCount)r=e+1;else return{member:a,index:e}}return null}function hx(e,t,n){let r=[];return e.traverse(e=>{let i=px(e);if(i)i.forEach((i,a)=>{i.trackingKey===t&&(i.layer??``)===n&&r.push({object:e,memberIndex:a})});else{let i=e.userData;i?.trackingKey===t&&(i.layer??``)===n&&r.push({object:e,memberIndex:null})}}),r}function gx(e,t){let n=mx(t),r=n?n.member:t.object.userData,i={object:t.object,memberIndex:n?.index??null};if(typeof r?.trackingKey!=`string`||!r.trackingKey)return[i];let a=hx(e,r.trackingKey,r.layer??``);return a.length>1?a:[i]}function _x(e,t){let n=new er,r=e.geometry.getIndex(),i=e.geometry.getAttribute(`position`);if(!r||!i||t.indexStart==null||t.indexCount==null)return n;e.updateMatrixWorld();let a=new q,o=Math.min(t.indexStart+t.indexCount,r.count);for(let s=t.indexStart;s<o;s++)a.fromBufferAttribute(i,r.getX(s)).applyMatrix4(e.matrixWorld),n.expandByPoint(a);return n}function vx(e,t,n,r){return yh(e,t,n,r),()=>bh(e,r)}function yx(e,t){let n=px(e);if(!n)return null;let r=[];for(let e of n){if(e.indexStart==null)return null;r.push(e.indexStart)}let i=new Uint32Array(t.length);for(let e=0;e<t.length;e++){let n=t[e]*3,a=0,o=r.length-1;for(;a<o;){let e=a+o+1>>1;r[e]<=n?a=e:o=e-1}i[e]=a}return i}function bx(e,t,n){let r=0;for(let e=0;e<t.length;e++)n.has(t[e])||r++;let i=new Float32Array(r*6),a=0;for(let r=0;r<t.length;r++)n.has(t[r])||(i.set(e.subarray(r*6,r*6+6),a),a+=6);return i}function xx(e,t,n){let{segments:r,faces:i}=n;if(!i||!px(t))return;let a,o=!1,s=()=>{let n=gh(t);if(n.size===0&&!o||(a??=yx(t,i),!a))return;let s=n.size===0?r:bx(r,a,n);e.geometry.dispose(),e.geometry=Lb(s).geometry,o=n.size>0};s();let c=xh(t,s);e.addEventListener(`removed`,c)}function Sx(e,t){let n=(Array.isArray(e.material)?e.material[0]:e.material)?.color;return n?n.clone().multiplyScalar(1-t):new Z(Ub)}var Cx=class{options;byKey=new Map;constructor(e){this.options=e}for(e,t){let n=this.options.forcedColor??Sx(e,this.options.darken),r=n.getHex()*2+ +!!t,i=this.byKey.get(r);return i||(i=wx(n,this.options.width,t),this.byKey.set(r,i)),i}disposeUnused(e){let t=new Set(e.map(e=>e.material));for(let e of this.byKey.values())t.has(e)||e.dispose()}};function wx(e,t,n){let r=new Yu({color:e});return r.linewidth=t,r.polygonOffset=!0,r.polygonOffsetFactor=0,r.polygonOffsetUnits=-1,n&&(r.transparent=!0),r}function Tx(e,t,n){let r=new md(e.geometry,t);return r.userData.kind=Bb,r.raycast=()=>{},n&&kx(r,e.edgeSpacing),r}var Ex=new q,Dx=new q;function Ox(e,t,n){e.geometry.boundingSphere||e.geometry.computeBoundingSphere();let r=e.geometry.boundingSphere;if(!r)return 1/0;if(t.isPerspectiveCamera){let i=t;Ex.copy(r.center).applyMatrix4(e.matrixWorld);let a=Dx.setFromMatrixPosition(t.matrixWorld).distanceTo(Ex);if(a<=r.radius*e.matrixWorld.getMaxScaleOnAxis())return 1/0;let o=Math.tan(Pt.degToRad(i.fov)*.5),s=2*a*o;return s>0?n/s:1/0}if(t.isOrthographicCamera){let e=t,r=(e.top-e.bottom)/e.zoom;return r>0?n/r:1/0}return 1/0}function kx(e,t){e.onBeforeRender=(n,r,i)=>{md.prototype.onBeforeRender.call(e,n);let a=e.material,o=t*Ox(e,i,a.resolution.y);a.opacity=Pt.clamp((o-1)/3,0,1)}}function Ax(e){return e.userData?.kind===Bb}function jx(e,t){let n=[],r=0;e.traverse(e=>{e instanceof Oi&&e.userData.id!==`floor`&&e.userData.id!==`grid`&&e.userData.kind!==`edge-overlay`&&(e.children.some(e=>e.userData?.kind===`edge-overlay`)?r++:e.geometry&&(Zb(e.geometry)>t.maxTriangles?e.userData.edgesSkipped=Vb:n.push(e)))});let i=Math.max(0,t.maxOverlays-r),a=n.slice(0,i);for(let e of a)delete e.userData.edgesSkipped;for(let e of n.slice(i))e.userData.edgesSkipped=Hb;return n.length>i&&console.debug(`[edges] overlay budget reached: ${n.length} meshes want overlays, ${i} allowed — the rest fall back to the screen-space edge pass.`),a}function Mx(e,t,n,r){let i=Lb(t.segments),a=r.distanceFade&&i.segmentCount<=r.maxSegments,o=Tx(i,n.for(e,a),a);return e.add(o),xx(o,e,t),o}var Nx=new WeakMap;function Px(e){return Nx.get(e)??0}function Fx(e,t){for(let n=e;n;n=n.parent)if(n===t)return!0;return!1}async function Ix(e,t={}){let n=Xb(t),r=new Cx(n),i=Px(e),a=[],o=jx(e,n).map(async t=>{let o=await fx(t.geometry,n.thresholdAngle);Px(e)===i&&Fx(t,e)&&(t.children.some(e=>e.userData?.kind===`edge-overlay`)||a.push(Mx(t,o,r,n)))});return await Promise.all(o),r.disposeUnused(a),a}function Lx(e){Nx.set(e,Px(e)+1);let t=[];e.traverse(e=>{e instanceof md&&Ax(e)&&t.push(e)});let n=new Set;for(let e of t)e.geometry.dispose(),n.add(e.material),e.removeFromParent();return n.forEach(e=>e.dispose()),t.length}function Rx(e){if(!(e>0)||!Number.isFinite(e))return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(n>=5?5:n>=2?2:1)*t}var zx=`
|
|
5948
5948
|
varying vec3 vWorldPos;
|
|
5949
5949
|
void main() {
|
|
5950
5950
|
vec4 world = modelMatrix * vec4(position, 1.0);
|
|
5951
5951
|
vWorldPos = world.xyz;
|
|
5952
5952
|
gl_Position = projectionMatrix * viewMatrix * world;
|
|
5953
5953
|
}
|
|
5954
|
-
`,
|
|
5954
|
+
`,Bx=`
|
|
5955
5955
|
precision highp float;
|
|
5956
5956
|
varying vec3 vWorldPos;
|
|
5957
5957
|
|
|
@@ -5995,7 +5995,7 @@ ${sm}`))})}function lm(e,t){let n=Math.min(1,t.transmission);if(e.userData[zu]=!
|
|
|
5995
5995
|
if (alpha < 0.001) discard;
|
|
5996
5996
|
gl_FragColor = vec4(color, alpha);
|
|
5997
5997
|
}
|
|
5998
|
-
`;function zx(e={}){let{cellSize:t=1,majorEvery:n=10,cellColor:r=8947848,majorColor:i=4473924,fadeDistance:a=100,plane:o=`y`}=e,s=o===`y`?new K(0,2):o===`z`?new K(0,1):new K(1,2),c=2.5,l=new pa(1,1);o===`y`?l.rotateX(-Math.PI/2):o===`x`&&l.rotateY(Math.PI/2);let u=new wa({vertexShader:Lx,fragmentShader:Rx,transparent:!0,depthWrite:!1,side:2,uniforms:{uAxes:{value:s},uCell:{value:t},uMajor:{value:n},uCellColor:{value:new Z(r)},uMajorColor:{value:new Z(i)},uCenter:{value:new q},uFade:{value:a}}}),d=new Oi(l,u);d.name=`grid`,d.userData.id=`grid`,d.renderOrder=-1;let f=a,p=a*c,m=new q;return{object:d,update:e=>{o===`y`?(d.position.set(e.x,0,e.z),m.set(e.x,0,e.z)):o===`z`?(d.position.set(e.x,e.y,0),m.set(e.x,e.y,0)):(d.position.set(0,e.y,e.z),m.set(0,e.y,e.z)),u.uniforms.uCenter.value.copy(m),d.scale.setScalar(p)},fitToContent:e=>{if(e.isEmpty())return;let t=e.getSize(new q),n=(e,t)=>t===0?e.x:t===1?e.y:e.z,r=Math.max(n(t,s.x),n(t,s.y));r>0&&Number.isFinite(r)&&(u.uniforms.uCell.value=Ix(r/20),f=r*2,u.uniforms.uFade.value=f,p=f*c)},setVisible:e=>{d.visible=e},dispose:()=>{d.removeFromParent(),l.dispose(),u.dispose()}}}function Bx(e,t){let n=new Oh,r=n.domElement;r.style.position=`absolute`,r.style.top=`0`,r.style.left=`0`,r.style.overflow=`hidden`,r.style.pointerEvents=`none`,r.style.zIndex=`30`,getComputedStyle(e).position===`static`&&(e.style.position=`relative`),e.appendChild(r);let i={width:e.clientWidth||1,height:e.clientHeight||1};n.setSize(i.width,i.height);let a=new jn;a.name=`label-layer`,a.userData.id=`label-layer`,t.add(a);let o=new Set;return{addLabel:(e,t,n)=>{let r=document.createElement(`div`);r.textContent=e,n?r.className=n:Object.assign(r.style,{padding:`2px 6px`,borderRadius:`4px`,background:`rgba(20, 20, 20, 0.78)`,color:`#fff`,font:`12px/1.3 system-ui, sans-serif`,whiteSpace:`pre`,textAlign:`center`,userSelect:`none`}),r.style.pointerEvents=`none`;let i=new Sh(r);return i.position.copy(t),a.add(i),o.add(i),{object:i,setPosition:e=>i.position.copy(e),setText:e=>{r.textContent=e},remove:()=>{i.removeFromParent(),r.remove(),o.delete(i)}}},render:(e,t)=>n.render(e,t),setSize:(e,t)=>n.setSize(e,t),dispose:()=>{o.forEach(e=>{e.removeFromParent(),e.element.remove()}),o.clear(),a.removeFromParent(),r.remove()}}}var Vx=new WeakMap;function Hx(e){return e?.version??0}function Ux(e){let t=e.attributes.position;if(!t||t.count===0)return null;let n=e.index,r=n??t,i=Vx.get(r);if(i===null)return null;if(i&&i.position===t&&i.positionVersion===Hx(t)&&i.indexVersion===Hx(n))return i.bvh;let a=new Rr;a.setAttribute(`position`,t),n&&a.setIndex(n);try{let e=new Cv(a,{indirect:!0});return Vx.set(r,{position:t,positionVersion:Hx(t),indexVersion:Hx(n),bvh:e}),e}catch{return Vx.set(r,null),null}}function Wx(e){let t=e;return t.isMesh===!0&&!t.isInstancedMesh&&!t.isSkinnedMesh&&!t.isBatchedMesh&&!t.isLineSegments2&&!e.morphTargetInfluences?.length}function Gx(e,t=[]){for(let n of e.children)!n.visible||xb(n)||Ox(n)||(t.push(n),Gx(n,t));return t}function Kx(e){let{groups:t}=e.geometry;if(!Array.isArray(e.material)||t.length===0)return null;let n=e.material;return t.filter(e=>n[e.materialIndex??0]?.visible!==!1).map(e=>({start:e.start,end:e.start+e.count}))}var qx=new X,Jx=new hi,Yx=new Ar;function Xx(e,t,n){qx.copy(e.matrixWorld).invert(),Jx.copy(n.ray).applyMatrix4(qx);let r=Kx(e),i=null;if(!r)i=t.raycastFirst(Jx,2);else for(let e of t.raycast(Jx,2)){let t=(e.faceIndex??0)*3;r.some(e=>t>=e.start&&t<e.end)&&(!i||e.distance<i.distance)&&(i=e)}return!i||(i.point.applyMatrix4(e.matrixWorld),i.distance=i.point.distanceTo(n.ray.origin),i.object=e,i.distance<n.near||i.distance>n.far)?null:i}function Zx(e,t){let n=[];for(let r of Gx(e))if(r.layers.test(t.layers)){if(Wx(r)){let{geometry:e}=r;if(e.boundingSphere||e.computeBoundingSphere(),!e.boundingSphere||(Yx.copy(e.boundingSphere).applyMatrix4(r.matrixWorld),!t.ray.intersectsSphere(Yx)))continue;let i=Ux(e);if(i){let e=Xx(r,i,t);e&&n.push(e);continue}}r.raycast(t,n)}return n.sort((e,t)=>e.distance-t.distance)}function Qx(e){let t=Gx(e).filter(Wx),n=typeof requestIdleCallback==`function`?e=>requestIdleCallback(e,{timeout:500}):e=>setTimeout(e,16),r=typeof cancelIdleCallback==`function`?cancelIdleCallback:e=>clearTimeout(e),i=0,a=!1,o=()=>{if(a)return;let e=t.shift();e&&(Ux(e.geometry),i=n(o))};return i=n(o),()=>{a=!0,r(i)}}var $x=12,eS=16763904,tS=.015,nS=998,rS=999,iS=1e3,aS={Millimeters:{metersPerUnit:1/1e3,suffix:`mm`},Centimeters:{metersPerUnit:1/100,suffix:`cm`},Meters:{metersPerUnit:1,suffix:`m`},Inches:{metersPerUnit:1/39.37,suffix:`in`},Feet:{metersPerUnit:1/3.28084,suffix:`ft`}};function oS(e){let t=e&&aS[e]||aS.Meters;return e=>{let n=e/t.metersPerUnit,r=Math.abs(n),i=r===0?0:Math.min(6,Math.max(0,2-Math.floor(Math.log10(r))));return`${n.toFixed(i)} ${t.suffix}`}}function sS(e){return(t,n)=>{let r=t*1e-6,i=[`x`,`y`,`z`].filter(e=>n[e]>r);return i.length<2?e(t):`${e(t)}\n${i.map(t=>`Δ${t} ${e(n[t])}`).join(` `)}`}}function cS(e,t){if(e.isOrthographicCamera){let t=e;return Math.abs(t.top-t.bottom)/(t.zoom||1)*tS}return((t?e.position.distanceTo(t):e.position.length())||1)*tS}function lS(e){let t=e.object,n=t.geometry;if(!n)return null;if(t.isLineSegments2){let t=n.attributes.instanceStart,r=n.attributes.instanceEnd,i=e.faceIndex;return!t||!r||i==null||i>=t.count?null:[new q().fromBufferAttribute(t,i),new q().fromBufferAttribute(r,i)]}let r=n.attributes.position;if(!r)return null;let i=e=>e.filter(e=>e<r.count).map(e=>new q().fromBufferAttribute(r,e));if(t instanceof Oi)return e.face?i([e.face.a,e.face.b,e.face.c]):null;if(t instanceof $i)return e.index==null?null:i([e.index]);if(t instanceof Ki){if(e.index==null)return null;let t=n.index;return t?e.index+1>=t.count?null:i([t.getX(e.index),t.getX(e.index+1)]):i([e.index,e.index+1])}return null}function uS(e,t,n){let r=e.clone().project(t);return new K((r.x+1)/2*n.width,(1-r.y)/2*n.height)}function dS(e){return e.pointOnLine??e.point}function fS(e,t,n,r){let i=dS(e).clone(),a=lS(e);if(!a)return{point:i,snapped:!1};let o=uS(i,t,n),s={point:i,snapped:!1},c=r;for(let r of a){let i=r.applyMatrix4(e.object.matrixWorld),a=uS(i,t,n).distanceTo(o);a<c&&(c=a,s={point:i,snapped:!0})}return s}function pS(e){let{canvas:t,scene:n,getActiveCamera:r,getViewTarget:i,labelLayer:a,options:o={}}=e,s=e.requestRender??(()=>{}),c=o.snapPixels??$x,l=new Z(o.color??eS),u=o.format??sS(oS(o.displayUnit)),d=new Xo,f=new K,p=!1,m=null,h=[],g=new Ji({color:l,size:8,sizeAttenuation:!1,depthTest:!1}),_=new Ji({color:l,size:12,sizeAttenuation:!1,depthTest:!1}),v=new Ji({color:l,size:7,sizeAttenuation:!1,depthTest:!1,transparent:!0,opacity:.6}),y=(e,t)=>(e.renderOrder=t,e.userData.id=`measure`,e.raycast=()=>{},e.frustumCulled=!1,e),b=(...e)=>{let t=new Rr;t.setAttribute(`position`,new Er(e.flatMap(e=>[e.x,e.y,e.z]),3));let r=y(new $i(t,g),rS);return n.add(r),r},x=(e,t,r=1)=>{let i=new hd;i.setPositions([e.x,e.y,e.z,t.x,t.y,t.z]);let a=new Yu({color:l,transparent:r<1,opacity:r});a.linewidth=2,a.depthTest=!1;let o=y(new gd(i,a),nS);return n.add(o),o},S=(e,t,n)=>{let r=e.geometry.attributes.instanceStart.data;r.array.set([t.x,t.y,t.z,n.x,n.y,n.z]),r.needsUpdate=!0},C=e=>{e.geometry.dispose(),e.material.dispose(),e.removeFromParent()},w=e=>{e.geometry.dispose(),e.removeFromParent()},T=(e,t)=>{let n=new q(Math.abs(t.x-e.x),Math.abs(t.y-e.y),Math.abs(t.z-e.z));return u(e.distanceTo(t),n)},E=(e,t)=>e.clone().add(t).multiplyScalar(.5),D=null,O=null,k=null,A=()=>{D&&(D.visible=!1),O&&(O.visible=!1),k?.remove(),k=null},j=e=>{if(!e){A();return}if(D||(D=b(new q),D.renderOrder=iS),D.material=e.snapped?_:v,D.position.copy(e.point),D.visible=!0,!m){O&&(O.visible=!1),k?.remove(),k=null;return}O||=x(m.point,e.point,.7),S(O,m.point,e.point),O.visible=!0;let t=T(m.point,e.point),n=E(m.point,e.point);k?(k.setText(t),k.setPosition(n)):k=a.addLabel(t,n,o.labelClassName)},M=e=>{let a=t.getBoundingClientRect(),o=e.clientX-a.left,s=e.clientY-a.top;f.x=o/a.width*2-1,f.y=-(s/a.height)*2+1;let l=r();d.setFromCamera(f,l);let u=cS(l,i?.())*2;d.params.Line.threshold=u,d.params.Points.threshold=u,d.params.Line2={threshold:c/2};let p={width:a.width,height:a.height},m=new K(o,s);for(let e of Zx(n,d))if(!(!(e.object.isMesh&&e.face!=null)&&uS(dS(e),l,p).distanceTo(m)>c))return fS(e,l,p,c);return null},N=null,P=0,F=()=>{P&&=(cancelAnimationFrame(P),0),N=null},I=e=>{p&&(N=e,!P&&(P=requestAnimationFrame(()=>{P=0;let e=N;N=null,p&&e&&(j(M(e)),s())})))},ee=()=>{F(),A(),s()},te=()=>{m&&=(w(m.marker),null)},ne=()=>{te();for(let e of h)w(e.markers),C(e.line),e.label.remove();h.length=0,A(),s()},re=()=>{m?(te(),A(),s()):ne()},ie=e=>{if(!p)return!1;F();let t=M(e);if(!t)return!0;if(!m)m={point:t.point,marker:b(t.point)};else if(!t.point.equals(m.point)){let e=m.point,n=t.point;te(),h.push({markers:b(e,n),line:x(e,n),label:a.addLabel(T(e,n),E(e,n),o.labelClassName)})}return j(t),s(),!0},ae=e=>{e.key===`Escape`&&(e.target?.closest?.(`input, textarea, select, [contenteditable]`)||re())},L=``,R=null,oe=e=>{e!==p&&(p=e,e?(L=t.style.cursor,t.style.cursor=`crosshair`,t.addEventListener(`mouseleave`,ee),window.addEventListener(`keydown`,ae),R=Qx(n)):(t.style.cursor=L,t.removeEventListener(`mouseleave`,ee),window.removeEventListener(`keydown`,ae),R?.(),R=null,F(),ne()))};return{setEnabled:oe,isEnabled:()=>p,handleClick:ie,handleMove:I,cancel:re,clear:ne,dispose:()=>{oe(!1),ne(),D&&w(D),O&&C(O),D=null,O=null,g.dispose(),_.dispose(),v.dispose()}}}var mS=.5,hS=.01,gS=.05,_S=256,vS=[];function yS({camera:e,scene:t,groundNormals:n=()=>vS}){let r=e.near,i=e.near,a=bS();return{update:()=>{e.near!==i&&(r=e.near);let o=a.measure(t,e),s=r;if(o!==null){let t=o;for(let r of n())t=Math.min(t,Math.abs(e.position.dot(r)));s=Pt.clamp(t*mS,r,e.far*hS)}Math.abs(s-i)>i*gS&&(e.near=s,e.updateProjectionMatrix(),i=s)}}}function bS(){let e=new WeakMap,t=new Fi,n=new X,r=new q,i=new er,a=new Float64Array(20),o=new Float64Array(20),s=new Float32Array(6),c=new Float64Array(21),l=new Float64Array(21),u=1/0,d=!1,f=(t,n)=>{let r=n.getAttribute(`position`),i=n.getIndex(),a=e.get(n);if(a&&a.position===r&&a.positionVersion===SS(r)&&a.index===i&&a.indexVersion===(i?.version??-1))return a;let o={...wS(r,i,CS(t)),position:r,positionVersion:SS(r),index:i,indexVersion:i?.version??-1};return e.set(n,o),o},p=(e,t,n)=>{let{position:r,index:i}=e,a=i?.array,o=1/0;for(let i=e.ranges[t*2];i<e.ranges[t*2+1];i++){for(let e=0;e<3;e++){let t=a?a[i*3+e]:i*3+e;c[e*3]=r.getX(t),c[e*3+1]=r.getY(t),c[e*3+2]=r.getZ(t)}let e=3;for(let t=0;t<16&&e>0;t+=4){let r=n[t],i=n[t+1],a=n[t+2],o=n[t+3],s=0;for(let t=0;t<e;t++){let n=(t+1)%e,u=c[t*3],d=c[t*3+1],f=c[t*3+2],p=c[n*3],m=c[n*3+1],h=c[n*3+2],g=r*u+i*d+a*f+o,_=r*p+i*m+a*h+o;if(g>=0&&(l[s*3]=u,l[s*3+1]=d,l[s*3+2]=f,s++),g>=0!=_>=0){let e=g/(g-_);l[s*3]=u+(p-u)*e,l[s*3+1]=d+(m-d)*e,l[s*3+2]=f+(h-f)*e,s++}}[c,l]=[l,c],e=s}for(let t=0;t<e;t++){let e=n[16]*c[t*3]+n[17]*c[t*3+1]+n[18]*c[t*3+2]+n[19];e<o&&(o=e)}}return o},m=e=>{let t=e.elements;for(let e=0;e<20;e+=4){let n=a[e],r=a[e+1],i=a[e+2];o[e]=t[0]*n+t[1]*r+t[2]*i,o[e+1]=t[4]*n+t[5]*r+t[6]*i,o[e+2]=t[8]*n+t[9]*r+t[10]*i,o[e+3]=n*t[12]+r*t[13]+i*t[14]+a[e+3]}return o},h=(e,t,n)=>{outer:for(let r=0;r<e.length;r+=6){let i=e[r],a=e[r+1],o=e[r+2],s=e[r+3],c=e[r+4],l=e[r+5];for(let e=0;e<16;e+=4){let n=t[e],r=t[e+1],u=t[e+2];if(n*(n>0?s:i)+r*(r>0?c:a)+u*(u>0?l:o)+t[e+3]<0)continue outer}let d=t[16],f=t[17],m=t[18],h=d*(d>0?i:s)+f*(f>0?a:c)+m*(m>0?o:l)+t[19];h>=u||(u=n?Math.min(u,p(n,r/6,t)):h)}},g=e=>{let t=e.geometry;if(!t?.getAttribute?.(`position`))return;if(d=!0,xS(e)){let n=f(e,t);h(n.boxes,m(e.matrixWorld),n);return}let n=e;n.isInstancedMesh?(n.boundingBox||n.computeBoundingBox(),i.copy(n.boundingBox)):(t.boundingBox||t.computeBoundingBox(),i.copy(t.boundingBox)),!i.isEmpty()&&(s[0]=i.min.x,s[1]=i.min.y,s[2]=i.min.z,s[3]=i.max.x,s[4]=i.max.y,s[5]=i.max.z,h(s,m(e.matrixWorld)))},_=e=>{if(e.visible&&!xb(e)&&e.userData.kind!==`edge-overlay`){g(e);for(let t of e.children)_(t)}};return{measure:(e,i)=>{e.updateMatrixWorld(),i.updateMatrixWorld(),n.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),t.setFromProjectionMatrix(n);for(let e=0;e<4;e++){let n=t.planes[e];a[e*4]=n.normal.x,a[e*4+1]=n.normal.y,a[e*4+2]=n.normal.z,a[e*4+3]=n.constant}i.getWorldDirection(r),a[16]=r.x,a[17]=r.y,a[18]=r.z,a[19]=-r.dot(i.position),u=1/0,d=!1;for(let t of e.children)_(t);return d?u:null}}}function xS(e){let t=e;if(!t.isMesh||t.isInstancedMesh||t.isSkinnedMesh)return!1;let n=t.geometry;return!n.isInstancedBufferGeometry&&Object.keys(n.morphAttributes).length===0}function SS(e){return e.isInterleavedBufferAttribute?e.data.version:e.version}function CS(e){let t=[];for(let n of dx(e)??[])n.indexStart!==void 0&&t.push(n.indexStart/3);return t.sort((e,t)=>e-t)}function wS(e,t,n){let r=Math.floor((t?t.count:e.count)/3),i=[],a=0;for(let e=0;e<r;){for(;a<n.length&&n[a]<=e;)a++;let t=Math.min(r,e+_S,n[a]??r);i.push(e,t),e=t}let o=i.length/2,s=new Float32Array(o*6),c=!e.isInterleavedBufferAttribute,l=e.array,u=c&&e.itemSize===3&&!e.normalized,d=t?.array;for(let t=0;t<o;t++){let n=1/0,r=1/0,a=1/0,o=-1/0,c=-1/0,f=-1/0,p=i[t*2+1]*3;for(let s=i[t*2]*3;s<p;s++){let t=d?d[s]:s,i=u?l[t*3]:e.getX(t),p=u?l[t*3+1]:e.getY(t),m=u?l[t*3+2]:e.getZ(t);i<n&&(n=i),p<r&&(r=p),m<a&&(a=m),i>o&&(o=i),p>c&&(c=p),m>f&&(f=m)}let m=t*6;s[m]=n,s[m+1]=r,s[m+2]=a,s[m+3]=o,s[m+4]=c,s[m+5]=f}return{boxes:s,ranges:Uint32Array.from(i)}}function TS(){let e=[],t=null,n=()=>e.sort((e,t)=>t.priority-e.priority),r=t=>e.findIndex(e=>e.id===t),i=n=>{let i=r(n);i!==-1&&(e.splice(i,1),t===n&&(t=null))};return{register:({id:t,tool:r,priority:a=0})=>(i(t),e.push({id:t,tool:r,priority:a}),n(),()=>i(t)),unregister:i,get:t=>e[r(t)]?.tool??null,setActive:n=>{t=n;for(let t of e)t.tool.setEnabled?.(t.id===n)},getActive:()=>t,handleClick:t=>{for(let n of[...e])if(n.tool.handleClick(t))return!0;return!1},handleMove:t=>{for(let n of[...e])n.tool.handleMove?.(t)}}}function ES(e){let{camera:t,domElement:n,controller:r}=e,i=new wv(t,n);i.setLabels(`X`,`Y`,`Z`);let a=!0,o=new Xo,s=new To(-2,2,2,-2,0,4);s.position.set(0,0,2),s.updateMatrixWorld();let c={posX:new q(1,0,0),negX:new q(-1,0,0),posY:new q(0,1,0),negY:new q(0,-1,0),posZ:new q(0,0,1),negZ:new q(0,0,-1)},l=e=>{let r=n.getBoundingClientRect(),a=r.left+n.offsetWidth-128-i.location.right,l=r.top+n.offsetHeight-128-i.location.bottom,u=new K((e.clientX-a)/128*2-1,-((e.clientY-l)/128)*2+1);if(Math.abs(u.x)>1||Math.abs(u.y)>1)return null;i.quaternion.copy(t.quaternion).invert(),i.updateMatrixWorld(),o.setFromCamera(u,s);let d=o.intersectObjects(i.children,!1);for(let e of d){let t=e.object.userData?.type;if(typeof t==`string`&&t in c)return t}return null};return{render:e=>{if(!a)return;let t=e.autoClear;e.autoClear=!1,i.render(e),e.autoClear=t},handleClick:e=>{if(!a)return!1;let t=l(e);return t?(r.getProjection()===`orthographic`&&r.setProjection(`perspective`),r.setViewDirection(c[t],!1),!0):!1},setVisible:e=>{a=e},isVisible:()=>a,dispose:()=>i.dispose()}}function DS(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m=!0,h){let g=null,_=performance.now(),v=!0,y=0,b=new X,x=new X,S=null,C=()=>{v=!0},w=e=>{e.updateMatrixWorld();let t=S!==e||!b.equals(e.matrixWorld)||!x.equals(e.projectionMatrix);return t&&(S=e,b.copy(e.matrixWorld),x.copy(e.projectionMatrix)),t},T=e.domElement,E=[`pointerdown`,`pointerup`,`wheel`];if(m)for(let e of E)T.addEventListener(e,C,{passive:!0});let D=()=>{let{width:t,height:r}=o();if(t===0||r===0)return;let a=s(),c=Math.floor(t*a),l=Math.floor(r*a);(e.domElement.width!==c||e.domElement.height!==l)&&(e.setPixelRatio(a),e.setSize(t,r,!1),n.aspect=t/r,n.updateProjectionMatrix(),i.updateAspect(t,r),d?.()?.setSize(t,r,a),f?.setSize(t,r),C())},O=n=>{f&&f.render(t,n),u&&u.render(e)},k=(n,r)=>{let i=d?.();i?(i.setCamera(n),i.render(r)):e.render(t,n),O(n)},A=()=>{let e=r();h?.present()?O(e):k(e,0)},j=function(){g=requestAnimationFrame(j);let e=performance.now(),t=(e-_)/1e3;_=e,D(),(a.enableDamping||a.autoRotate)&&a.update(),l&&l.update(r().position),p&&p.update(),c?.(t);let n=r();if(m){let r=w(n);r&&h?.moving(t*1e3);let i=v||r;if(!i&&h?.wants(e)){h.step(n),O(n);return}let a=e-y>=500;if(!i&&!a||(y=e,!i&&h?.isHolding()))return;v=!1,h?.reset(e)}k(n,t)};return{animate:j,dispose:()=>{if(g!==null&&(cancelAnimationFrame(g),g=null),m)for(let e of E)T.removeEventListener(e,C)},invalidate:C,renderNow:A}}var OS=3,kS=2,AS=1024,jS=1/3,MS=.05,NS=160/(4*Math.PI)*.005,PS=.07,FS=7,IS=.15;function LS(e){let t=_h(e);return t?.userData.selvaEmissive?t:null}function RS(e){let t=dx(e);if(!t)return[new er().setFromObject(e)];let n=gh(e);return t.filter((e,t)=>!n.has(t)).map(t=>hx(e,t)).filter(e=>!e.isEmpty())}function zS(e,t){let n=e=>e.getSize(new q).length(),r=Math.max(n(e),n(t))*MS;return e.clone().expandByScalar(r).intersectsBox(t)}function BS(e,t){let n=[];for(let r of e){let i={bounds:r.bounds.clone(),meshes:new Set([r.mesh])},a=[];for(let e of n)if(zS(e.bounds,r.bounds)){i.bounds.union(e.bounds);for(let t of e.meshes)i.meshes.add(t)}else a.push(e);if(n=[...a,i],n.length>t){let t=new er;for(let n of e)t.union(n.bounds);return[{bounds:t,meshes:new Set(e.map(e=>e.mesh))}]}}return n}function VS(e,t){let n=new Map;for(let t of e){let{emissive:e,emissiveIntensity:r,userData:i}=t.material,a=`${e.getHexString()}|${r}|${i[Ou]}`,o=n.get(a);o?o.push(t):n.set(a,[t])}return[...n.values()].flatMap(e=>{let{emissive:n,emissiveIntensity:r,userData:i}=e[0].material;return BS(e,t).map(e=>({...e,color:n,strength:r,light:i[Ou]}))})}function HS(e,t=OS){let n=Math.max(0,...e.map(e=>e.strength));return e.filter(e=>e.strength>=n*jS).sort((e,t)=>t.strength-e.strength).slice(0,t)}function US(e){let t=[],n=new Set,r=new q,i=n=>{let r=new wo(16777215,1,0,2),i=new wo(16777215,1,0,1);n&&(r.castShadow=!0,r.shadow.mapSize.setScalar(AS),r.shadow.radius=FS,r.shadow.autoUpdate=!1);let a={key:r,bounce:i,home:new q,size:new q};return t.push(a),e.add(r,i),a},a=()=>{let t=new er,n=[];return e.traverseVisible(e=>{let r=e;if(!r.isMesh||e.userData.source!==`compute`)return;t.union(new er().setFromObject(r));let i=LS(r);if(i)for(let e of RS(r))n.push({mesh:r,material:i,bounds:e})}),{parts:n,radius:t.getSize(new q).length()/2}},o=(e,r)=>{for(let{mesh:i,bounds:a}of e)r.some((e,n)=>e.meshes.has(i)||a.containsPoint(t[n].key.position))&&i.castShadow&&(i.castShadow=!1,n.add(i))},s=(r,s=OS,c=1)=>{for(let e of n)e.castShadow=!0;n.clear();let{parts:l,radius:u}=r?a():{parts:[],radius:0},d=HS(VS(l,s),s);for(d.forEach((e,n)=>{let{key:r,bounce:a,home:o,size:s}=t[n]??i(n<kS),l=(e.light??e.strength*NS)*c;r.color.copy(e.color);let d=e.bounds.getSize(new q).length()/2/u;r.intensity=!e.light&&d>IS?0:l,e.bounds.getCenter(r.position),o.copy(r.position),e.bounds.getSize(s),a.color.copy(e.color),a.intensity=l*PS/u,a.position.copy(r.position),r.castShadow&&(r.shadow.camera.near=u*.005,r.shadow.camera.far=u*4,r.shadow.camera.updateProjectionMatrix(),r.shadow.bias=-.002,r.shadow.normalBias=u*.002,r.shadow.needsUpdate=!0)});t.length>d.length;){let{key:n,bounce:r}=t.pop();e.remove(n,r),n.dispose(),r.dispose()}o(l,d)},c=e=>{for(let{key:n,home:r,size:i}of t)n.position.copy(e(r,i)),n.castShadow&&(n.shadow.needsUpdate=!0)};return{sync:s,jitter:e=>c((t,n)=>r.set(sb(e,2)-.5,sb(e,3)-.5,sb(e,5)-.5).multiply(n).add(t)),settle:()=>c(e=>e),dispose:()=>s(!1)}}var WS=`__selvaLookBaseline`;function GS(e,t){e.color?.setHex(t.color),e.metalness!==void 0&&(e.metalness=t.metalness),e.roughness!==void 0&&(e.roughness=t.roughness),e.emissiveIntensity!==void 0&&(e.emissiveIntensity=t.emissiveIntensity),e.opacity=t.opacity,e.transparent=t.transparent,e.depthWrite=t.depthWrite,e.wireframe!==void 0&&(e.wireframe=t.wireframe),e.side=t.side}function KS(e){let t=e[WS];t&&(GS(e,t),delete e[WS])}function qS(e,t){let n=e;t?(n[WS]?GS(n,n[WS]):n[WS]={color:n.color?.getHex()??16777215,metalness:n.metalness??0,roughness:n.roughness??1,emissiveIntensity:n.emissiveIntensity??0,opacity:n.opacity,transparent:n.transparent,depthWrite:n.depthWrite,wireframe:n.wireframe??!1,side:n.side},t.color!==void 0&&n.color?.setHex(t.color),t.metalness!==void 0&&n.metalness!==void 0&&(n.metalness=t.metalness),t.roughness!==void 0&&n.roughness!==void 0&&(n.roughness=t.roughness),t.emissiveIntensity!==void 0&&n.userData.selvaEmissive&&(n.emissiveIntensity=t.emissiveIntensity),t.opacity!==void 0&&(n.opacity=t.opacity,n.transparent=t.opacity<1),t.depthWrite!==void 0&&(n.depthWrite=t.depthWrite),t.wireframe!==void 0&&n.wireframe!==void 0&&(n.wireframe=t.wireframe),t.side!==void 0&&(n.side=t.side),n.needsUpdate=!0):(KS(n),n.needsUpdate=!0)}function JS(e,t){if(t.materialOverride)return t.envMapIntensity;let n=e.userData[ku];if(n!=null)return n;let r=e,i=r[WS]?.metalness??r.metalness??0;return Au(t.envMapIntensity,i,t.metalReflection)}function YS(e,t){return Math.min(e,t.maxPixelRatio??e)}function XS(e){let{scene:t,renderer:n,lights:r,config:i,pipeline:a,fullPixelRatio:o,requestRender:s}=e,c=e=>Eu(e,i.render.lowPower),l=i.look,u=US(t),d=n.shadowMap.type,f=e=>{let t=e.emissiveLights?1:d;n.shadowMap.type!==t&&(n.shadowMap.type=t,n.shadowMap.needsUpdate=!0)},p,m=e=>{e.background===void 0?(p!==void 0&&(t.background=p),p=void 0):(p??=t.background,t.background=new Z(e.background))};m(c(l)),f(c(l));let h=e=>{e.ambientIntensity!==void 0&&(r.ambient.intensity=e.ambientIntensity),e.hemisphereIntensity!==void 0&&!r.hemisphere&&e.hemisphereIntensity>0&&(r.hemisphere=new lo(e.hemisphereSkyColor??i.lighting.hemisphereSkyColor,e.hemisphereGroundColor??i.lighting.hemisphereGroundColor,e.hemisphereIntensity),r.hemisphere.position.copy(i.environment.sceneUp??tb),t.add(r.hemisphere)),r.hemisphere&&(e.hemisphereIntensity!==void 0&&(r.hemisphere.intensity=e.hemisphereIntensity),e.hemisphereSkyColor!==void 0&&r.hemisphere.color.set(e.hemisphereSkyColor),e.hemisphereGroundColor!==void 0&&r.hemisphere.groundColor.set(e.hemisphereGroundColor)),s()},g=e=>{i.environment.environmentIntensity=e,t.environmentIntensity=e,s()},_=e=>{i.render.toneMappingExposure=e,n.toneMappingExposure=e,a.get()&&a.rebuild()},v=e=>{i.render.aoIntensity=e,a.get()&&a.rebuild()},y=()=>{let{emissiveLights:e,maxEmissiveLights:t,emissiveLightScale:n}=c(l);u.sync(!!e,t,n),s()};return{setFillLights:h,setEnvironmentIntensity:g,setToneMappingExposure:_,setAoIntensity:v,setLook:(e,s)=>{let u=c(e);l=e,n.toneMapping=u.toneMapping,n.toneMappingExposure=u.toneMappingExposure,i.render.toneMapping=u.toneMapping,i.render.toneMappingExposure=u.toneMappingExposure,h({hemisphereIntensity:u.hemisphereIntensity,ambientIntensity:u.ambientIntensity}),g(u.environmentIntensity),r.sun&&(r.sun.intensity=u.sunlightIntensity,i.lighting.sunlightIntensity=u.sunlightIntensity),m(u),f(u),i.render.bloom=u.bloom,i.render.pixelRatio=YS(o,u),a.setAmbientOcclusion(u.ambientOcclusion),t.traverse(e=>{if(e.userData.source!==`compute`)return;let t=e,n=Array.isArray(t.material)?t.material:t.material?[t.material]:[];for(let e of n)`envMapIntensity`in e&&(e.envMapIntensity=JS(e,u)),qS(e,u.materialOverride)}),Yy(t,t),s?.deferEmissiveLights||y()},syncEmissiveLights:y,jitterEmissiveLights:u.jitter,settleEmissiveLights:u.settle,getMaterialAppearance:()=>ju(l)}}function ZS(e,t){let n=t.parentElement,r=n?n.clientWidth:window.innerWidth,i=n?n.clientHeight:window.innerHeight,a=new So(e.camera.fov,r/i,e.camera.near,e.camera.far),o=e.camera.position;return o&&a.position.set(o.x,o.y,o.z),a}function QS(e){let t=new zn;return t.background=(typeof e.environment.backgroundColor==`string`?new Z(e.environment.backgroundColor):e.environment.backgroundColor)||null,t}function $S(e,t){Wu(e,t),e.environment?.dispose(),Jy(e),e.background instanceof Zt&&e.background.dispose()}var eC={uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},uResolution:{value:new K(1,1)},uColor:{value:new Z(2236962)},uOpacity:{value:1},uNormalThreshold:{value:.4},uDepthThreshold:{value:.02},uThickness:{value:1},uNear:{value:.1},uFar:{value:1e3},uPerspective:{value:1}},vertexShader:`
|
|
5998
|
+
`;function Vx(e={}){let{cellSize:t=1,majorEvery:n=10,cellColor:r=8947848,majorColor:i=4473924,fadeDistance:a=100,plane:o=`y`}=e,s=o===`y`?new K(0,2):o===`z`?new K(0,1):new K(1,2),c=2.5,l=new pa(1,1);o===`y`?l.rotateX(-Math.PI/2):o===`x`&&l.rotateY(Math.PI/2);let u=new wa({vertexShader:zx,fragmentShader:Bx,transparent:!0,depthWrite:!1,side:2,uniforms:{uAxes:{value:s},uCell:{value:t},uMajor:{value:n},uCellColor:{value:new Z(r)},uMajorColor:{value:new Z(i)},uCenter:{value:new q},uFade:{value:a}}}),d=new Oi(l,u);d.name=`grid`,d.userData.id=`grid`,d.renderOrder=-1;let f=a,p=a*c,m=new q;return{object:d,update:e=>{o===`y`?(d.position.set(e.x,0,e.z),m.set(e.x,0,e.z)):o===`z`?(d.position.set(e.x,e.y,0),m.set(e.x,e.y,0)):(d.position.set(0,e.y,e.z),m.set(0,e.y,e.z)),u.uniforms.uCenter.value.copy(m),d.scale.setScalar(p)},fitToContent:e=>{if(e.isEmpty())return;let t=e.getSize(new q),n=(e,t)=>t===0?e.x:t===1?e.y:e.z,r=Math.max(n(t,s.x),n(t,s.y));r>0&&Number.isFinite(r)&&(u.uniforms.uCell.value=Rx(r/20),f=r*2,u.uniforms.uFade.value=f,p=f*c)},setVisible:e=>{d.visible=e},dispose:()=>{d.removeFromParent(),l.dispose(),u.dispose()}}}function Hx(e,t){let n=new Oh,r=n.domElement;r.style.position=`absolute`,r.style.top=`0`,r.style.left=`0`,r.style.overflow=`hidden`,r.style.pointerEvents=`none`,r.style.zIndex=`30`,getComputedStyle(e).position===`static`&&(e.style.position=`relative`),e.appendChild(r);let i={width:e.clientWidth||1,height:e.clientHeight||1};n.setSize(i.width,i.height);let a=new jn;a.name=`label-layer`,a.userData.id=`label-layer`,t.add(a);let o=new Set;return{addLabel:(e,t,n)=>{let r=document.createElement(`div`);r.textContent=e,n?r.className=n:Object.assign(r.style,{padding:`2px 6px`,borderRadius:`4px`,background:`rgba(20, 20, 20, 0.78)`,color:`#fff`,font:`12px/1.3 system-ui, sans-serif`,whiteSpace:`pre`,textAlign:`center`,userSelect:`none`}),r.style.pointerEvents=`none`;let i=new Sh(r);return i.position.copy(t),a.add(i),o.add(i),{object:i,setPosition:e=>i.position.copy(e),setText:e=>{r.textContent=e},remove:()=>{i.removeFromParent(),r.remove(),o.delete(i)}}},render:(e,t)=>n.render(e,t),setSize:(e,t)=>n.setSize(e,t),dispose:()=>{o.forEach(e=>{e.removeFromParent(),e.element.remove()}),o.clear(),a.removeFromParent(),r.remove()}}}var Ux=new WeakMap;function Wx(e){return e?.version??0}function Gx(e){let t=e.attributes.position;if(!t||t.count===0)return null;let n=e.index,r=n??t,i=Ux.get(r);if(i===null)return null;if(i&&i.position===t&&i.positionVersion===Wx(t)&&i.indexVersion===Wx(n))return i.bvh;let a=new Rr;a.setAttribute(`position`,t),n&&a.setIndex(n);try{let e=new Cv(a,{indirect:!0});return Ux.set(r,{position:t,positionVersion:Wx(t),indexVersion:Wx(n),bvh:e}),e}catch{return Ux.set(r,null),null}}function Kx(e){let t=e;return t.isMesh===!0&&!t.isInstancedMesh&&!t.isSkinnedMesh&&!t.isBatchedMesh&&!t.isLineSegments2&&!e.morphTargetInfluences?.length}function qx(e,t=[]){for(let n of e.children)!n.visible||xb(n)||Ax(n)||(t.push(n),qx(n,t));return t}function Jx(e){let{groups:t}=e.geometry;if(!Array.isArray(e.material)||t.length===0)return null;let n=e.material;return t.filter(e=>n[e.materialIndex??0]?.visible!==!1).map(e=>({start:e.start,end:e.start+e.count}))}var Yx=new X,Xx=new hi,Zx=new Ar;function Qx(e,t,n){Yx.copy(e.matrixWorld).invert(),Xx.copy(n.ray).applyMatrix4(Yx);let r=Jx(e),i=null;if(!r)i=t.raycastFirst(Xx,2);else for(let e of t.raycast(Xx,2)){let t=(e.faceIndex??0)*3;r.some(e=>t>=e.start&&t<e.end)&&(!i||e.distance<i.distance)&&(i=e)}return!i||(i.point.applyMatrix4(e.matrixWorld),i.distance=i.point.distanceTo(n.ray.origin),i.object=e,i.distance<n.near||i.distance>n.far)?null:i}function $x(e,t){let n=[];for(let r of qx(e))if(r.layers.test(t.layers)){if(Kx(r)){let{geometry:e}=r;if(e.boundingSphere||e.computeBoundingSphere(),!e.boundingSphere||(Zx.copy(e.boundingSphere).applyMatrix4(r.matrixWorld),!t.ray.intersectsSphere(Zx)))continue;let i=Gx(e);if(i){let e=Qx(r,i,t);e&&n.push(e);continue}}r.raycast(t,n)}return n.sort((e,t)=>e.distance-t.distance)}function eS(e){let t=qx(e).filter(Kx),n=typeof requestIdleCallback==`function`?e=>requestIdleCallback(e,{timeout:500}):e=>setTimeout(e,16),r=typeof cancelIdleCallback==`function`?cancelIdleCallback:e=>clearTimeout(e),i=0,a=!1,o=()=>{if(a)return;let e=t.shift();e&&(Gx(e.geometry),i=n(o))};return i=n(o),()=>{a=!0,r(i)}}var tS=12,nS=16763904,rS=.015,iS=998,aS=999,oS=1e3,sS={Millimeters:{metersPerUnit:1/1e3,suffix:`mm`},Centimeters:{metersPerUnit:1/100,suffix:`cm`},Meters:{metersPerUnit:1,suffix:`m`},Inches:{metersPerUnit:1/39.37,suffix:`in`},Feet:{metersPerUnit:1/3.28084,suffix:`ft`}};function cS(e){let t=e&&sS[e]||sS.Meters;return e=>{let n=e/t.metersPerUnit,r=Math.abs(n),i=r===0?0:Math.min(6,Math.max(0,2-Math.floor(Math.log10(r))));return`${n.toFixed(i)} ${t.suffix}`}}function lS(e){return(t,n)=>{let r=t*1e-6,i=[`x`,`y`,`z`].filter(e=>n[e]>r);return i.length<2?e(t):`${e(t)}\n${i.map(t=>`Δ${t} ${e(n[t])}`).join(` `)}`}}function uS(e,t){if(e.isOrthographicCamera){let t=e;return Math.abs(t.top-t.bottom)/(t.zoom||1)*rS}return((t?e.position.distanceTo(t):e.position.length())||1)*rS}function dS(e){let t=e.object,n=t.geometry;if(!n)return null;if(t.isLineSegments2){let t=n.attributes.instanceStart,r=n.attributes.instanceEnd,i=e.faceIndex;return!t||!r||i==null||i>=t.count?null:[new q().fromBufferAttribute(t,i),new q().fromBufferAttribute(r,i)]}let r=n.attributes.position;if(!r)return null;let i=e=>e.filter(e=>e<r.count).map(e=>new q().fromBufferAttribute(r,e));if(t instanceof Oi)return e.face?i([e.face.a,e.face.b,e.face.c]):null;if(t instanceof $i)return e.index==null?null:i([e.index]);if(t instanceof Ki){if(e.index==null)return null;let t=n.index;return t?e.index+1>=t.count?null:i([t.getX(e.index),t.getX(e.index+1)]):i([e.index,e.index+1])}return null}function fS(e,t,n){let r=e.clone().project(t);return new K((r.x+1)/2*n.width,(1-r.y)/2*n.height)}function pS(e){return e.pointOnLine??e.point}function mS(e,t,n,r){let i=pS(e).clone(),a=dS(e);if(!a)return{point:i,snapped:!1};let o=fS(i,t,n),s={point:i,snapped:!1},c=r;for(let r of a){let i=r.applyMatrix4(e.object.matrixWorld),a=fS(i,t,n).distanceTo(o);a<c&&(c=a,s={point:i,snapped:!0})}return s}function hS(e){let{canvas:t,scene:n,getActiveCamera:r,getViewTarget:i,labelLayer:a,options:o={}}=e,s=e.requestRender??(()=>{}),c=o.snapPixels??tS,l=new Z(o.color??nS),u=o.format??lS(cS(o.displayUnit)),d=new Xo,f=new K,p=!1,m=null,h=[],g=new Ji({color:l,size:8,sizeAttenuation:!1,depthTest:!1}),_=new Ji({color:l,size:12,sizeAttenuation:!1,depthTest:!1}),v=new Ji({color:l,size:7,sizeAttenuation:!1,depthTest:!1,transparent:!0,opacity:.6}),y=(e,t)=>(e.renderOrder=t,e.userData.id=`measure`,e.raycast=()=>{},e.frustumCulled=!1,e),b=(...e)=>{let t=new Rr;t.setAttribute(`position`,new Er(e.flatMap(e=>[e.x,e.y,e.z]),3));let r=y(new $i(t,g),aS);return n.add(r),r},x=(e,t,r=1)=>{let i=new hd;i.setPositions([e.x,e.y,e.z,t.x,t.y,t.z]);let a=new Yu({color:l,transparent:r<1,opacity:r});a.linewidth=2,a.depthTest=!1;let o=y(new gd(i,a),iS);return n.add(o),o},S=(e,t,n)=>{let r=e.geometry.attributes.instanceStart.data;r.array.set([t.x,t.y,t.z,n.x,n.y,n.z]),r.needsUpdate=!0},C=e=>{e.geometry.dispose(),e.material.dispose(),e.removeFromParent()},w=e=>{e.geometry.dispose(),e.removeFromParent()},T=(e,t)=>{let n=new q(Math.abs(t.x-e.x),Math.abs(t.y-e.y),Math.abs(t.z-e.z));return u(e.distanceTo(t),n)},E=(e,t)=>e.clone().add(t).multiplyScalar(.5),D=null,O=null,k=null,A=()=>{D&&(D.visible=!1),O&&(O.visible=!1),k?.remove(),k=null},j=e=>{if(!e){A();return}if(D||(D=b(new q),D.renderOrder=oS),D.material=e.snapped?_:v,D.position.copy(e.point),D.visible=!0,!m){O&&(O.visible=!1),k?.remove(),k=null;return}O||=x(m.point,e.point,.7),S(O,m.point,e.point),O.visible=!0;let t=T(m.point,e.point),n=E(m.point,e.point);k?(k.setText(t),k.setPosition(n)):k=a.addLabel(t,n,o.labelClassName)},M=e=>{let a=t.getBoundingClientRect(),o=e.clientX-a.left,s=e.clientY-a.top;f.x=o/a.width*2-1,f.y=-(s/a.height)*2+1;let l=r();d.setFromCamera(f,l);let u=uS(l,i?.())*2;d.params.Line.threshold=u,d.params.Points.threshold=u,d.params.Line2={threshold:c/2};let p={width:a.width,height:a.height},m=new K(o,s);for(let e of $x(n,d))if(!(!(e.object.isMesh&&e.face!=null)&&fS(pS(e),l,p).distanceTo(m)>c))return mS(e,l,p,c);return null},N=null,P=0,F=()=>{P&&=(cancelAnimationFrame(P),0),N=null},I=e=>{p&&(N=e,!P&&(P=requestAnimationFrame(()=>{P=0;let e=N;N=null,p&&e&&(j(M(e)),s())})))},ee=()=>{F(),A(),s()},te=()=>{m&&=(w(m.marker),null)},ne=()=>{te();for(let e of h)w(e.markers),C(e.line),e.label.remove();h.length=0,A(),s()},re=()=>{m?(te(),A(),s()):ne()},ie=e=>{if(!p)return!1;F();let t=M(e);if(!t)return!0;if(!m)m={point:t.point,marker:b(t.point)};else if(!t.point.equals(m.point)){let e=m.point,n=t.point;te(),h.push({markers:b(e,n),line:x(e,n),label:a.addLabel(T(e,n),E(e,n),o.labelClassName)})}return j(t),s(),!0},ae=e=>{e.key===`Escape`&&(e.target?.closest?.(`input, textarea, select, [contenteditable]`)||re())},L=``,R=null,oe=e=>{e!==p&&(p=e,e?(L=t.style.cursor,t.style.cursor=`crosshair`,t.addEventListener(`mouseleave`,ee),window.addEventListener(`keydown`,ae),R=eS(n)):(t.style.cursor=L,t.removeEventListener(`mouseleave`,ee),window.removeEventListener(`keydown`,ae),R?.(),R=null,F(),ne()))};return{setEnabled:oe,isEnabled:()=>p,handleClick:ie,handleMove:I,cancel:re,clear:ne,dispose:()=>{oe(!1),ne(),D&&w(D),O&&C(O),D=null,O=null,g.dispose(),_.dispose(),v.dispose()}}}var gS=.5,_S=.01,vS=.05,yS=256,bS=[];function xS({camera:e,scene:t,groundNormals:n=()=>bS}){let r=e.near,i=e.near,a=SS();return{update:()=>{e.near!==i&&(r=e.near);let o=a.measure(t,e),s=r;if(o!==null){let t=o;for(let r of n())t=Math.min(t,Math.abs(e.position.dot(r)));s=Pt.clamp(t*gS,r,e.far*_S)}Math.abs(s-i)>i*vS&&(e.near=s,e.updateProjectionMatrix(),i=s)}}}function SS(){let e=new WeakMap,t=new Fi,n=new X,r=new q,i=new er,a=new Float64Array(20),o=new Float64Array(20),s=new Float32Array(6),c=new Float64Array(21),l=new Float64Array(21),u=1/0,d=!1,f=(t,n)=>{let r=n.getAttribute(`position`),i=n.getIndex(),a=e.get(n);if(a&&a.position===r&&a.positionVersion===wS(r)&&a.index===i&&a.indexVersion===(i?.version??-1))return a;let o={...ES(r,i,TS(t)),position:r,positionVersion:wS(r),index:i,indexVersion:i?.version??-1};return e.set(n,o),o},p=(e,t,n)=>{let{position:r,index:i}=e,a=i?.array,o=1/0;for(let i=e.ranges[t*2];i<e.ranges[t*2+1];i++){for(let e=0;e<3;e++){let t=a?a[i*3+e]:i*3+e;c[e*3]=r.getX(t),c[e*3+1]=r.getY(t),c[e*3+2]=r.getZ(t)}let e=3;for(let t=0;t<16&&e>0;t+=4){let r=n[t],i=n[t+1],a=n[t+2],o=n[t+3],s=0;for(let t=0;t<e;t++){let n=(t+1)%e,u=c[t*3],d=c[t*3+1],f=c[t*3+2],p=c[n*3],m=c[n*3+1],h=c[n*3+2],g=r*u+i*d+a*f+o,_=r*p+i*m+a*h+o;if(g>=0&&(l[s*3]=u,l[s*3+1]=d,l[s*3+2]=f,s++),g>=0!=_>=0){let e=g/(g-_);l[s*3]=u+(p-u)*e,l[s*3+1]=d+(m-d)*e,l[s*3+2]=f+(h-f)*e,s++}}[c,l]=[l,c],e=s}for(let t=0;t<e;t++){let e=n[16]*c[t*3]+n[17]*c[t*3+1]+n[18]*c[t*3+2]+n[19];e<o&&(o=e)}}return o},m=e=>{let t=e.elements;for(let e=0;e<20;e+=4){let n=a[e],r=a[e+1],i=a[e+2];o[e]=t[0]*n+t[1]*r+t[2]*i,o[e+1]=t[4]*n+t[5]*r+t[6]*i,o[e+2]=t[8]*n+t[9]*r+t[10]*i,o[e+3]=n*t[12]+r*t[13]+i*t[14]+a[e+3]}return o},h=(e,t,n)=>{outer:for(let r=0;r<e.length;r+=6){let i=e[r],a=e[r+1],o=e[r+2],s=e[r+3],c=e[r+4],l=e[r+5];for(let e=0;e<16;e+=4){let n=t[e],r=t[e+1],u=t[e+2];if(n*(n>0?s:i)+r*(r>0?c:a)+u*(u>0?l:o)+t[e+3]<0)continue outer}let d=t[16],f=t[17],m=t[18],h=d*(d>0?i:s)+f*(f>0?a:c)+m*(m>0?o:l)+t[19];h>=u||(u=n?Math.min(u,p(n,r/6,t)):h)}},g=e=>{let t=e.geometry;if(!t?.getAttribute?.(`position`))return;if(d=!0,CS(e)){let n=f(e,t);h(n.boxes,m(e.matrixWorld),n);return}let n=e;n.isInstancedMesh?(n.boundingBox||n.computeBoundingBox(),i.copy(n.boundingBox)):(t.boundingBox||t.computeBoundingBox(),i.copy(t.boundingBox)),!i.isEmpty()&&(s[0]=i.min.x,s[1]=i.min.y,s[2]=i.min.z,s[3]=i.max.x,s[4]=i.max.y,s[5]=i.max.z,h(s,m(e.matrixWorld)))},_=e=>{if(e.visible&&!xb(e)&&e.userData.kind!==`edge-overlay`){g(e);for(let t of e.children)_(t)}};return{measure:(e,i)=>{e.updateMatrixWorld(),i.updateMatrixWorld(),n.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),t.setFromProjectionMatrix(n);for(let e=0;e<4;e++){let n=t.planes[e];a[e*4]=n.normal.x,a[e*4+1]=n.normal.y,a[e*4+2]=n.normal.z,a[e*4+3]=n.constant}i.getWorldDirection(r),a[16]=r.x,a[17]=r.y,a[18]=r.z,a[19]=-r.dot(i.position),u=1/0,d=!1;for(let t of e.children)_(t);return d?u:null}}}function CS(e){let t=e;if(!t.isMesh||t.isInstancedMesh||t.isSkinnedMesh)return!1;let n=t.geometry;return!n.isInstancedBufferGeometry&&Object.keys(n.morphAttributes).length===0}function wS(e){return e.isInterleavedBufferAttribute?e.data.version:e.version}function TS(e){let t=[];for(let n of px(e)??[])n.indexStart!==void 0&&t.push(n.indexStart/3);return t.sort((e,t)=>e-t)}function ES(e,t,n){let r=Math.floor((t?t.count:e.count)/3),i=[],a=0;for(let e=0;e<r;){for(;a<n.length&&n[a]<=e;)a++;let t=Math.min(r,e+yS,n[a]??r);i.push(e,t),e=t}let o=i.length/2,s=new Float32Array(o*6),c=!e.isInterleavedBufferAttribute,l=e.array,u=c&&e.itemSize===3&&!e.normalized,d=t?.array;for(let t=0;t<o;t++){let n=1/0,r=1/0,a=1/0,o=-1/0,c=-1/0,f=-1/0,p=i[t*2+1]*3;for(let s=i[t*2]*3;s<p;s++){let t=d?d[s]:s,i=u?l[t*3]:e.getX(t),p=u?l[t*3+1]:e.getY(t),m=u?l[t*3+2]:e.getZ(t);i<n&&(n=i),p<r&&(r=p),m<a&&(a=m),i>o&&(o=i),p>c&&(c=p),m>f&&(f=m)}let m=t*6;s[m]=n,s[m+1]=r,s[m+2]=a,s[m+3]=o,s[m+4]=c,s[m+5]=f}return{boxes:s,ranges:Uint32Array.from(i)}}function DS(){let e=[],t=null,n=()=>e.sort((e,t)=>t.priority-e.priority),r=t=>e.findIndex(e=>e.id===t),i=n=>{let i=r(n);i!==-1&&(e.splice(i,1),t===n&&(t=null))};return{register:({id:t,tool:r,priority:a=0})=>(i(t),e.push({id:t,tool:r,priority:a}),n(),()=>i(t)),unregister:i,get:t=>e[r(t)]?.tool??null,setActive:n=>{t=n;for(let t of e)t.tool.setEnabled?.(t.id===n)},getActive:()=>t,handleClick:t=>{for(let n of[...e])if(n.tool.handleClick(t))return!0;return!1},handleMove:t=>{for(let n of[...e])n.tool.handleMove?.(t)}}}function OS(e){let{camera:t,domElement:n,controller:r}=e,i=new wv(t,n);i.setLabels(`X`,`Y`,`Z`);let a=!0,o=new Xo,s=new To(-2,2,2,-2,0,4);s.position.set(0,0,2),s.updateMatrixWorld();let c={posX:new q(1,0,0),negX:new q(-1,0,0),posY:new q(0,1,0),negY:new q(0,-1,0),posZ:new q(0,0,1),negZ:new q(0,0,-1)},l=e=>{let r=n.getBoundingClientRect(),a=r.left+n.offsetWidth-128-i.location.right,l=r.top+n.offsetHeight-128-i.location.bottom,u=new K((e.clientX-a)/128*2-1,-((e.clientY-l)/128)*2+1);if(Math.abs(u.x)>1||Math.abs(u.y)>1)return null;i.quaternion.copy(t.quaternion).invert(),i.updateMatrixWorld(),o.setFromCamera(u,s);let d=o.intersectObjects(i.children,!1);for(let e of d){let t=e.object.userData?.type;if(typeof t==`string`&&t in c)return t}return null};return{render:e=>{if(!a)return;let t=e.autoClear;e.autoClear=!1,i.render(e),e.autoClear=t},handleClick:e=>{if(!a)return!1;let t=l(e);return t?(r.getProjection()===`orthographic`&&r.setProjection(`perspective`),r.setViewDirection(c[t],!1),!0):!1},setVisible:e=>{a=e},isVisible:()=>a,dispose:()=>i.dispose()}}function kS(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m=!0,h){let g=null,_=performance.now(),v=!0,y=0,b=new X,x=new X,S=null,C=()=>{v=!0},w=e=>{e.updateMatrixWorld();let t=S!==e||!b.equals(e.matrixWorld)||!x.equals(e.projectionMatrix);return t&&(S=e,b.copy(e.matrixWorld),x.copy(e.projectionMatrix)),t},T=e.domElement,E=[`pointerdown`,`pointerup`,`wheel`];if(m)for(let e of E)T.addEventListener(e,C,{passive:!0});let D=()=>{let{width:t,height:r}=o();if(t===0||r===0)return;let a=s(),c=Math.floor(t*a),l=Math.floor(r*a);(e.domElement.width!==c||e.domElement.height!==l)&&(e.setPixelRatio(a),e.setSize(t,r,!1),n.aspect=t/r,n.updateProjectionMatrix(),i.updateAspect(t,r),d?.()?.setSize(t,r,a),f?.setSize(t,r),C())},O=n=>{f&&f.render(t,n),u&&u.render(e)},k=(n,r)=>{let i=d?.();i?(i.setCamera(n),i.render(r)):e.render(t,n),O(n)},A=()=>{let e=r();h?.present()?O(e):k(e,0)},j=function(){g=requestAnimationFrame(j);let e=performance.now(),t=(e-_)/1e3;_=e,D(),(a.enableDamping||a.autoRotate)&&a.update(),l&&l.update(r().position),p&&p.update(),c?.(t);let n=r();if(m){let r=w(n);r&&h?.moving(t*1e3);let i=v||r;if(!i&&h?.wants(e)){h.step(n),O(n);return}let a=e-y>=500;if(!i&&!a||(y=e,!i&&h?.isHolding()))return;v=!1,h?.reset(e)}k(n,t)};return{animate:j,dispose:()=>{if(g!==null&&(cancelAnimationFrame(g),g=null),m)for(let e of E)T.removeEventListener(e,C)},invalidate:C,renderNow:A}}var AS=3,jS=2,MS=1024,NS=1/3,PS=.05,FS=160/(4*Math.PI)*.005,IS=.07,LS=7,RS=.15;function zS(e){let t=_h(e);return t?.userData.selvaEmissive?t:null}function BS(e){let t=px(e);if(!t)return[new er().setFromObject(e)];let n=gh(e);return t.filter((e,t)=>!n.has(t)).map(t=>_x(e,t)).filter(e=>!e.isEmpty())}function VS(e,t){let n=e=>e.getSize(new q).length(),r=Math.max(n(e),n(t))*PS;return e.clone().expandByScalar(r).intersectsBox(t)}function HS(e,t){let n=[];for(let r of e){let i={bounds:r.bounds.clone(),meshes:new Set([r.mesh])},a=[];for(let e of n)if(VS(e.bounds,r.bounds)){i.bounds.union(e.bounds);for(let t of e.meshes)i.meshes.add(t)}else a.push(e);if(n=[...a,i],n.length>t){let t=new er;for(let n of e)t.union(n.bounds);return[{bounds:t,meshes:new Set(e.map(e=>e.mesh))}]}}return n}function US(e,t){let n=new Map;for(let t of e){let{emissive:e,emissiveIntensity:r,userData:i}=t.material,a=`${e.getHexString()}|${r}|${i[Ou]}`,o=n.get(a);o?o.push(t):n.set(a,[t])}return[...n.values()].flatMap(e=>{let{emissive:n,emissiveIntensity:r,userData:i}=e[0].material;return HS(e,t).map(e=>({...e,color:n,strength:r,light:i[Ou]}))})}function WS(e,t=AS){let n=Math.max(0,...e.map(e=>e.strength));return e.filter(e=>e.strength>=n*NS).sort((e,t)=>t.strength-e.strength).slice(0,t)}function GS(e){let t=[],n=new Set,r=new q,i=n=>{let r=new wo(16777215,1,0,2),i=new wo(16777215,1,0,1);n&&(r.castShadow=!0,r.shadow.mapSize.setScalar(MS),r.shadow.radius=LS,r.shadow.autoUpdate=!1);let a={key:r,bounce:i,home:new q,size:new q};return t.push(a),e.add(r,i),a},a=()=>{let t=new er,n=[];return e.traverseVisible(e=>{let r=e;if(!r.isMesh||e.userData.source!==`compute`)return;t.union(new er().setFromObject(r));let i=zS(r);if(i)for(let e of BS(r))n.push({mesh:r,material:i,bounds:e})}),{parts:n,radius:t.getSize(new q).length()/2}},o=(e,r)=>{for(let{mesh:i,bounds:a}of e)r.some((e,n)=>e.meshes.has(i)||a.containsPoint(t[n].key.position))&&i.castShadow&&(i.castShadow=!1,n.add(i))},s=(r,s=AS,c=1)=>{for(let e of n)e.castShadow=!0;n.clear();let{parts:l,radius:u}=r?a():{parts:[],radius:0},d=WS(US(l,s),s);for(d.forEach((e,n)=>{let{key:r,bounce:a,home:o,size:s}=t[n]??i(n<jS),l=(e.light??e.strength*FS)*c;r.color.copy(e.color);let d=e.bounds.getSize(new q).length()/2/u;r.intensity=!e.light&&d>RS?0:l,e.bounds.getCenter(r.position),o.copy(r.position),e.bounds.getSize(s),a.color.copy(e.color),a.intensity=l*IS/u,a.position.copy(r.position),r.castShadow&&(r.shadow.camera.near=u*.005,r.shadow.camera.far=u*4,r.shadow.camera.updateProjectionMatrix(),r.shadow.bias=-.002,r.shadow.normalBias=u*.002,r.shadow.needsUpdate=!0)});t.length>d.length;){let{key:n,bounce:r}=t.pop();e.remove(n,r),n.dispose(),r.dispose()}o(l,d)},c=e=>{for(let{key:n,home:r,size:i}of t)n.position.copy(e(r,i)),n.castShadow&&(n.shadow.needsUpdate=!0)};return{sync:s,jitter:e=>c((t,n)=>r.set(sb(e,2)-.5,sb(e,3)-.5,sb(e,5)-.5).multiply(n).add(t)),settle:()=>c(e=>e),dispose:()=>s(!1)}}var KS=`__selvaLookBaseline`;function qS(e,t){e.color?.setHex(t.color),e.metalness!==void 0&&(e.metalness=t.metalness),e.roughness!==void 0&&(e.roughness=t.roughness),e.emissiveIntensity!==void 0&&(e.emissiveIntensity=t.emissiveIntensity),e.opacity=t.opacity,e.transparent=t.transparent,e.depthWrite=t.depthWrite,e.wireframe!==void 0&&(e.wireframe=t.wireframe),e.side=t.side}function JS(e){let t=e[KS];t&&(qS(e,t),delete e[KS])}function YS(e,t){let n=e;t?(n[KS]?qS(n,n[KS]):n[KS]={color:n.color?.getHex()??16777215,metalness:n.metalness??0,roughness:n.roughness??1,emissiveIntensity:n.emissiveIntensity??0,opacity:n.opacity,transparent:n.transparent,depthWrite:n.depthWrite,wireframe:n.wireframe??!1,side:n.side},t.color!==void 0&&n.color?.setHex(t.color),t.metalness!==void 0&&n.metalness!==void 0&&(n.metalness=t.metalness),t.roughness!==void 0&&n.roughness!==void 0&&(n.roughness=t.roughness),t.emissiveIntensity!==void 0&&n.userData.selvaEmissive&&(n.emissiveIntensity=t.emissiveIntensity),t.opacity!==void 0&&(n.opacity=t.opacity,n.transparent=t.opacity<1),t.depthWrite!==void 0&&(n.depthWrite=t.depthWrite),t.wireframe!==void 0&&n.wireframe!==void 0&&(n.wireframe=t.wireframe),t.side!==void 0&&(n.side=t.side),n.needsUpdate=!0):(JS(n),n.needsUpdate=!0)}function XS(e,t){if(t.materialOverride)return t.envMapIntensity;let n=e.userData[ku];if(n!=null)return n;let r=e,i=r[KS]?.metalness??r.metalness??0;return Au(t.envMapIntensity,i,t.metalReflection)}function ZS(e,t){return Math.min(e,t.maxPixelRatio??e)}function QS(e){let{scene:t,renderer:n,lights:r,config:i,pipeline:a,fullPixelRatio:o,requestRender:s}=e,c=e=>Eu(e,i.render.lowPower),l=i.look,u=GS(t),d=n.shadowMap.type,f=e=>{let t=e.emissiveLights?1:d;n.shadowMap.type!==t&&(n.shadowMap.type=t,n.shadowMap.needsUpdate=!0)},p,m=e=>{e.background===void 0?(p!==void 0&&(t.background=p),p=void 0):(p??=t.background,t.background=new Z(e.background))};m(c(l)),f(c(l));let h=e=>{e.ambientIntensity!==void 0&&(r.ambient.intensity=e.ambientIntensity),e.hemisphereIntensity!==void 0&&!r.hemisphere&&e.hemisphereIntensity>0&&(r.hemisphere=new lo(e.hemisphereSkyColor??i.lighting.hemisphereSkyColor,e.hemisphereGroundColor??i.lighting.hemisphereGroundColor,e.hemisphereIntensity),r.hemisphere.position.copy(i.environment.sceneUp??tb),t.add(r.hemisphere)),r.hemisphere&&(e.hemisphereIntensity!==void 0&&(r.hemisphere.intensity=e.hemisphereIntensity),e.hemisphereSkyColor!==void 0&&r.hemisphere.color.set(e.hemisphereSkyColor),e.hemisphereGroundColor!==void 0&&r.hemisphere.groundColor.set(e.hemisphereGroundColor)),s()},g=e=>{i.environment.environmentIntensity=e,t.environmentIntensity=e,s()},_=e=>{i.render.toneMappingExposure=e,n.toneMappingExposure=e,a.get()&&a.rebuild()},v=e=>{i.render.aoIntensity=e,a.get()&&a.rebuild()},y=()=>{let{emissiveLights:e,maxEmissiveLights:t,emissiveLightScale:n}=c(l);u.sync(!!e,t,n),s()};return{setFillLights:h,setEnvironmentIntensity:g,setToneMappingExposure:_,setAoIntensity:v,setLook:(e,s)=>{let u=c(e);l=e,n.toneMapping=u.toneMapping,n.toneMappingExposure=u.toneMappingExposure,i.render.toneMapping=u.toneMapping,i.render.toneMappingExposure=u.toneMappingExposure,h({hemisphereIntensity:u.hemisphereIntensity,ambientIntensity:u.ambientIntensity}),g(u.environmentIntensity),r.sun&&(r.sun.intensity=u.sunlightIntensity,i.lighting.sunlightIntensity=u.sunlightIntensity),m(u),f(u),i.render.bloom=u.bloom,i.render.pixelRatio=ZS(o,u),a.setAmbientOcclusion(u.ambientOcclusion),t.traverse(e=>{if(e.userData.source!==`compute`)return;let t=e,n=Array.isArray(t.material)?t.material:t.material?[t.material]:[];for(let e of n)`envMapIntensity`in e&&(e.envMapIntensity=XS(e,u)),YS(e,u.materialOverride)}),Yy(t,t),s?.deferEmissiveLights||y()},syncEmissiveLights:y,jitterEmissiveLights:u.jitter,settleEmissiveLights:u.settle,getMaterialAppearance:()=>ju(l)}}function $S(e,t){let n=t.parentElement,r=n?n.clientWidth:window.innerWidth,i=n?n.clientHeight:window.innerHeight,a=new So(e.camera.fov,r/i,e.camera.near,e.camera.far),o=e.camera.position;return o&&a.position.set(o.x,o.y,o.z),a}function eC(e){let t=new zn;return t.background=(typeof e.environment.backgroundColor==`string`?new Z(e.environment.backgroundColor):e.environment.backgroundColor)||null,t}function tC(e,t){Wu(e,t),e.environment?.dispose(),Jy(e),e.background instanceof Zt&&e.background.dispose()}var nC={uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},uResolution:{value:new K(1,1)},uColor:{value:new Z(2236962)},uOpacity:{value:1},uNormalThreshold:{value:.4},uDepthThreshold:{value:.02},uThickness:{value:1},uNear:{value:.1},uFar:{value:1e3},uPerspective:{value:1}},vertexShader:`
|
|
5999
5999
|
varying vec2 vUv;
|
|
6000
6000
|
void main() {
|
|
6001
6001
|
vUv = uv;
|
|
@@ -6049,7 +6049,7 @@ ${sm}`))})}function lm(e,t){let n=Math.min(1,t.transmission);if(e.userData[zu]=!
|
|
|
6049
6049
|
float edge = max(depthEdge, normalEdge) * uOpacity;
|
|
6050
6050
|
gl_FragColor = vec4(mix(color.rgb, uColor, edge), color.a);
|
|
6051
6051
|
}
|
|
6052
|
-
`},
|
|
6052
|
+
`},rC=class extends Ev{camera;scene;normalMaterial;edgeMaterial;fsQuad;normalTarget=null;width;height;constructor(e,t,n,r,i={}){super(),this.scene=e,this.camera=t,this.width=Math.max(1,n),this.height=Math.max(1,r),this.normalMaterial=new Oa,this.normalMaterial.blending=0,this.edgeMaterial=new wa({uniforms:xa.clone(nC.uniforms),vertexShader:nC.vertexShader,fragmentShader:nC.fragmentShader});let a=this.edgeMaterial.uniforms;a.uColor.value=new Z(i.color??2236962),a.uOpacity.value=i.opacity??1,a.uNormalThreshold.value=i.normalThreshold??.4,a.uDepthThreshold.value=i.depthThreshold??.02,a.uThickness.value=i.thickness??1,this.fsQuad=new kv(this.edgeMaterial),this.needsSwap=!0}acquireNormalTarget(){if(!this.normalTarget){let e=new ra(this.width,this.height);this.normalTarget=new en(this.width,this.height,{minFilter:m,magFilter:m,depthTexture:e})}return this.normalTarget}setSize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.normalTarget?.setSize(this.width,this.height)}render(e,t,n){let r=this.acquireNormalTarget(),i=e.getRenderTarget(),a=e.autoClear,o=e.getClearColor(new Z),s=e.getClearAlpha(),c=this.scene.overrideMaterial;e.setRenderTarget(r),e.setClearColor(7829503,1),e.autoClear=!0,this.scene.overrideMaterial=this.normalMaterial;let l=Vu(this.scene);e.render(this.scene,this.camera),l(),this.scene.overrideMaterial=c,e.setClearColor(o,s),e.autoClear=a;let u=this.edgeMaterial.uniforms;u.tDiffuse.value=n.texture,u.tNormal.value=r.texture,u.tDepth.value=r.depthTexture,u.uResolution.value.set(this.width,this.height);let d=this.camera;u.uPerspective.value=+!!d.isPerspectiveCamera,u.uNear.value=this.camera.near??.1,u.uFar.value=this.camera.far??1e3,e.setRenderTarget(this.renderToScreen?null:t),this.fsQuad.render(e),e.setRenderTarget(i)}dispose(){this.normalTarget?.dispose(),this.normalMaterial.dispose(),this.edgeMaterial.dispose(),this.fsQuad.dispose()}},iC={name:`HdrClamp`,uniforms:{tDiffuse:{value:null}},vertexShader:`
|
|
6053
6053
|
varying vec2 vUv;
|
|
6054
6054
|
void main() {
|
|
6055
6055
|
vUv = uv;
|
|
@@ -6064,7 +6064,7 @@ ${sm}`))})}function lm(e,t){let n=Math.min(1,t.transmission);if(e.userData[zu]=!
|
|
|
6064
6064
|
void main() {
|
|
6065
6065
|
vec4 color = texture2D(tDiffuse, vUv);
|
|
6066
6066
|
gl_FragColor = vec4(safe(color.r), safe(color.g), safe(color.b), color.a);
|
|
6067
|
-
}`},
|
|
6067
|
+
}`},aC={vertexShader:`
|
|
6068
6068
|
varying vec2 vUv;
|
|
6069
6069
|
void main() {
|
|
6070
6070
|
vUv = uv;
|
|
@@ -6074,7 +6074,7 @@ ${sm}`))})}function lm(e,t){let n=Math.min(1,t.transmission);if(e.userData[zu]=!
|
|
|
6074
6074
|
varying vec2 vUv;
|
|
6075
6075
|
void main() {
|
|
6076
6076
|
gl_FragColor = texture2D(tFrame, vUv);
|
|
6077
|
-
}`};function iC(e){let t=new en(1,1,{type:D,depthBuffer:!1}),n=new wa({...rC,uniforms:{tFrame:{value:null}},depthTest:!1,depthWrite:!1,toneMapped:!1,blending:5,blendSrc:213,blendDst:214}),r=new kv(n),i=(t,i)=>{n.uniforms.tFrame.value=t,n.blendAlpha=i;let a=e.autoClear;e.autoClear=!1,r.render(e),e.autoClear=a},a=()=>{e.setRenderTarget(null),i(t.texture,1)};return{add:(n,r,o,s)=>{(t.width!==o||t.height!==s)&&t.setSize(o,s),e.setRenderTarget(t),i(n,1/(r+1)),a()},present:a,dispose:()=>{t.dispose(),n.dispose(),r.dispose()}}}function aC(e){return e>=2?0:4}function oC(e){let t=e,n=t._overrideVisibility.bind(e),r=t._restoreVisibility.bind(e),i=()=>{};t._overrideVisibility=()=>{n(),i=Vu(e.scene)},t._restoreVisibility=()=>{i(),r()}}function sC(e,t,n,r,i,a){let o=new en(r,i,{type:D}),s=new Nv(e,o);s.renderTarget2.samples=0;let c=e=>{s.readBuffer=o,s.writeBuffer=s.renderTarget2,s.render(e)},l=new Pv(t,n);s.addPass(l);let u=null;(a.ambientOcclusion??!0)&&(u=new Wv(t,n,r,i),u.blendIntensity=a.aoIntensity??1,u.updateGtaoMaterial({screenSpaceRadius:!0}),oC(u),s.addPass(u));let d=null,f=null;if(a.bloom){let{strength:e,radius:t,threshold:n}=a.bloom;d=new Av(nC),s.addPass(d),f=new Qv(new K(r,i),e,t,n),s.addPass(f)}let p=new tC(t,n,r,i,typeof a.edgeDetection==`object`?a.edgeDetection:{});p.enabled=!!a.edgeDetection,s.addPass(p);let m=new Jv;s.addPass(m);let h=new Xv;s.addPass(h),e.toneMapping=a.toneMapping,e.toneMappingExposure=a.toneMappingExposure;let g=null,_=a.aoPixelRatio??1,v=1;if(u){let e=u.setSize.bind(u);u.setSize=(t,n)=>e(Math.max(1,Math.round(t*v)),Math.max(1,Math.round(n*v)))}let y=e=>{v=Math.min(e,_)/e;let t=aC(e);o.samples!==t&&(o.samples=t,o.dispose()),s.setPixelRatio(e)};return y(e.getPixelRatio()),s.setSize(r,i),{render:c,setSize:(e,t,n)=>{y(n),s.setSize(e,t)},setCamera:e=>{if(l.camera=e,p.camera=e,!u)return;u.camera=e;let t=+!!e.isPerspectiveCamera;u.gtaoMaterial.defines.PERSPECTIVE_CAMERA!==t&&(u.gtaoMaterial.defines.PERSPECTIVE_CAMERA=t,u.gtaoMaterial.needsUpdate=!0)},setEdgeDetection:e=>{p.enabled=e},edgeDetectionEnabled:()=>p.enabled,accumulate:t=>{s.renderToScreen=!1,c(0),s.renderToScreen=!0,g??=iC(e);let{texture:n,width:r,height:i}=s.readBuffer;g.add(n,t,r,i)},presentAccumulated:()=>g?.present(),setAoWeight:e=>{u&&(u.enabled=e>0,u.blendIntensity=(a.aoIntensity??1)*e)},dispose:()=>{s.dispose(),g?.dispose(),u?.dispose(),d?.dispose(),f?.dispose(),p.dispose(),m.dispose(),h.dispose()}}}function cC(e){let{renderer:t,scene:n,getActiveCamera:r,getCanvasSize:i,config:a,requestRender:o}=e,s=null,c=!!a.render.ambientOcclusion,l=!1,u=()=>({ambientOcclusion:c,bloom:a.render.bloom,toneMapping:a.render.toneMapping,toneMappingExposure:a.render.toneMappingExposure}),d=u(),f=()=>{let e=u();return e.ambientOcclusion!==d.ambientOcclusion||e.bloom!==d.bloom||e.toneMapping!==d.toneMapping||e.toneMappingExposure!==d.toneMappingExposure},p=()=>{let{width:e,height:o}=i(),s=sC(t,n,r(),Math.max(1,e),Math.max(1,o),{toneMapping:a.render.toneMapping??7,toneMappingExposure:a.render.toneMappingExposure??1,ambientOcclusion:c,aoIntensity:a.render.aoIntensity,aoPixelRatio:a.render.aoPixelRatio,bloom:a.render.bloom,edgeDetection:!1});return s.setSize(Math.max(1,e),Math.max(1,o),a.render.pixelRatio),s},m=()=>{c||l||a.render.bloom?((!s||f())&&(s?.dispose(),s=p(),d=u()),s.setEdgeDetection(l),o()):(s?.dispose(),s=null,o())};return{get:()=>s,sync:m,rebuild:()=>{s?.dispose(),s=null,m()},setAmbientOcclusion:e=>{c=e,m()},setEdgeFallback:e=>{e!==l&&(l=e,m())},isEdgeFallbackActive:()=>l,dispose:()=>{s?.dispose(),s=null}}}function lC(e,t,n){let r=new ly(e,t),i=n.camera.target;return i&&r.target.set(i.x,i.y,i.z),r.enableDamping=n.controls.enableDamping||!1,r.dampingFactor=n.controls.dampingFactor||.05,r.autoRotate=n.controls.autoRotate||!1,r.autoRotateSpeed=n.controls.autoRotateSpeed||.5,r.enableZoom=n.controls.enableZoom??!0,r.enablePan=n.controls.enablePan??!0,r.minDistance=n.controls.minDistance||.001,r.maxDistance=n.controls.maxDistance||1/0,r.screenSpacePanning=!1,r.maxPolarAngle=Math.PI,r.update(),r}function uC(e,t,n,r){if(n.environment.enableEnvironmentLighting){if(Ky(e,t,$y(n.environment.sceneUp??tb)),n.environment.hdrPath===!1){n.events.onReady?.();return}new Sy().load(n.environment.hdrPath||`/baseHDR.hdr`,function(i){if(r()){i.dispose();return}if(!i?.image){wu().warn(`HDR loaded without image data; skipping environment map.`),i?.dispose(),n.events.onReady?.();return}i.mapping=303;let a=new js(t);a.compileEquirectangularShader();let o=a.fromEquirectangular(i).texture;a.dispose(),e.environment=o,e.environmentIntensity=n.environment.environmentIntensity??1;let s=$y(n.environment.sceneUp??tb);e.environmentRotation.copy(s),n.environment.showEnvironment?(e.background=i,e.backgroundRotation.copy(s)):i.dispose(),n.events.onReady?.()},void 0,function(e){r()||(wu().warn(`HDR texture could not be loaded, falling back to basic lighting:`,e),n.events.onReady?.())})}else n.events.onReady?.()}function dC(e,t){let n=t.floor.size,r=new Oi(new pa(n,n),new Ea({color:typeof t.floor.color==`string`?new Z(t.floor.color):t.floor.color,roughness:t.floor.roughness,metalness:t.floor.metalness,side:2}));r.userData.id=`floor`,r.name=`floor`;let i=(t.environment?.sceneUp||tb).clone().normalize();r.quaternion.setFromUnitVectors(new q(0,0,1),i),r.position.set(0,0,0),t.floor.receiveShadow&&t.render.enableShadows&&(r.receiveShadow=!0),e.add(r)}var fC=.75,pC=.6,mC=.2,hC=1,gC=`#ffb020`,_C=[8,16],vC=8,yC=300,bC=30,xC=.35,SC=new Z(`#2f7bff`);function CC(e,t){let n=e.color;return n&&Math.hypot(n.r-t.r,n.g-t.g,n.b-t.b)<xC?SC:t}function wC(e,t,n){let r=CC(e,t);if(n&&`emissive`in e){let t=e;t.emissive=r.clone(),t.emissiveIntensity=pC,t.color.lerp(r,fC),t.metalness=Math.min(t.metalness,mC),t.opacity<hC&&(t.opacity=hC,t.transparent=!1,t.depthWrite=!0)}else`color`in e&&(e.color=r.clone())}function TC(e,t,n,r,i){let a=new Set,o=new Map,s=[],c=null,l=!1,u=new Xo,d=new K,f=()=>n.getActiveCamera(),p=()=>{let e=Cb(t);e.isEmpty()?wu().warn(`No objects to fit to view`):n.frameBounds(e,!1)},m=typeof r.events.selectionColor==`string`?new Z(r.events.selectionColor):r.events.selectionColor instanceof Z?r.events.selectionColor:new Z(`#ff0000`),h=new Z(gC),g=[],_=[],v=(e,n)=>{let r=e;for(;r.parent;)r=r.parent;r!==t&&(n instanceof Jr?n.dispose():n.forEach(e=>e.dispose()))},y=()=>{for(let{restore:e,material:t}of _)e(),t.dispose();_.length=0;for(let{object:e,original:t}of g){let n=e.material;n instanceof Jr&&n.dispose(),e.material=t,v(e,t)}g.length=0},b=e=>{let t=[],n=new Map;for(let{object:r,memberIndex:i}of e){if(i===null){t.push(r);continue}let e=n.get(r);e||n.set(r,e=new Set),e.add(i)}return{whole:t,membersByMesh:n}},x=(e,t=null)=>{if(y(),!e)return;let n=e instanceof An?[{object:e,memberIndex:t}]:e,{whole:r,membersByMesh:i}=b(n);for(let[e,t]of i){if(!(e instanceof Oi)){r.push(e);continue}let n=_h(e).clone();wC(n,h,!0),_.push({restore:gx(e,t,n,`hover`),material:n})}for(let e of r){if(a.has(e))continue;let t=e;if(!(t.material instanceof Jr))continue;let n=vh(t.material);wC(n,h,e instanceof Oi),g.push({object:t,original:t.material}),t.material=n}},S=()=>{for(let{restore:e,material:t}of s)e(),t.dispose();s.length=0,a.forEach(e=>{let t=e;if(o.has(e)){let n=o.get(e),r=t.material;r instanceof Jr?r.dispose():Array.isArray(r)&&r.forEach(e=>e.dispose()),t.material=n,o.delete(e),v(e,n)}}),a.clear(),c=null,l=!1},C=(e,t)=>{if(t&&e instanceof Oi){let n=_h(e).clone();return wC(n,m,!0),s.push({restore:gx(e,t,n),material:n}),!0}let n=e;if(!(n.material instanceof Jr))return!1;let r=vh(n.material);return wC(r,m,e instanceof Oi),o.set(e,n.material),n.material=r,!0},w=e=>{let{whole:t,membersByMesh:n}=b(e);for(let e of t)a.add(e),C(e,null);for(let[e,t]of n)a.add(e),C(e,t)},T=e=>{(e.length!==0||l)&&(y(),S(),w(e),l=e.length>0)},E=null,D=-1,O=()=>{if(E===null||t.children.length!==D){let e=Cb(t);E=e.isEmpty()?1:e.getSize(new q).length(),D=t.children.length}u.params.Points.threshold=E*.01},k=(t,n)=>{let r=e.getBoundingClientRect();d.x=(t-r.left)/r.width*2-1,d.y=-((n-r.top)/r.height)*2+1},A=(e,n)=>(k(e,n),O(),u.setFromCamera(d,f()),Zx(t,u)[0]??null),j=(e,t,n)=>{let r=A(e,t);if(r||!n)return r;for(let n of _C){let r=null;for(let i=0;i<vC;i++){let a=i/vC*Math.PI*2,o=A(e+Math.cos(a)*n,t+Math.sin(a)*n);o&&(!r||o.distance<r.distance)&&(r=o)}if(r)return r}return null},M=null,N=e=>{let t=M;if(M={time:e.timeStamp,x:e.clientX,y:e.clientY},!t)return!1;let n=e.timeStamp-t.time<=yC&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<=bC;return n&&(M=null),n},P=e=>{if(!i.wasTap())return;let n=i.pointerType()!==`mouse`;if(n&&N(e)){I(e.clientX,e.clientY,!0);return}let a=j(e.clientX,e.clientY,n);if(!a){S(),k(e.clientX,e.clientY),r.events?.onBackgroundClicked?.({x:d.x,y:d.y});return}let o=a.object,s=fx(a),u=s?.index??null;(l||c?.object!==o||c.memberIndex!==u)&&(y(),S(),c={object:o,memberIndex:u},w(mx(t,a)),r.events?.onObjectSelected?.(o),s?r.events?.onMeshMetadataClicked?.({source:o.userData?.source,name:s.member.name,layer:s.member.layer,trackingKey:s.member.trackingKey,metadata:s.member.metadata}):o instanceof Oi&&Object.keys(o.userData).length>0&&r.events?.onMeshMetadataClicked?.(o.userData))},F=e=>{i.wasTap()&&i.pointerType()===`mouse`&&I(e.clientX,e.clientY,!1)},I=(e,i,a)=>{let o=j(e,i,a);if(!o){r.events?.enableDoubleClickZoom&&n.frameBounds(Cb(t),!0);return}let s=o.object;if(r.events?.onMeshDoubleClicked?.(s),!r.events?.enableDoubleClickZoom)return;let c=new er;for(let{object:e,memberIndex:n}of mx(t,o)){let t=n===null?null:dx(e)?.[n];c.union(t&&e instanceof Oi?hx(e,t):new er().setFromObject(e))}c.isEmpty()||n.frameBounds(c,!0)},ee=e=>{if(r.events?.enableKeyboardControls)switch(e.key.toLowerCase()){case`f`:e.preventDefault(),p();break;case`escape`:e.preventDefault(),S();break;case` `:e.preventDefault(),p()}};return r.events?.enableClickToFocus&&(e.addEventListener(`click`,P),e.addEventListener(`dblclick`,F)),r.events?.enableKeyboardControls&&(e.setAttribute(`tabindex`,`0`),e.addEventListener(`keydown`,ee)),{dispose:()=>{e.removeEventListener(`click`,P),e.removeEventListener(`dblclick`,F),e.removeEventListener(`keydown`,ee),y(),S()},fitToView:p,clearSelection:S,selectEntries:T,setHover:x}}var EC=5,DC=10,OC=500;function kC(e){let t=new Map,n=`mouse`,r=0,i=0,a=0,o=!1,s=!1,c=e=>{let n=t.get(e.pointerId);n&&(a=Math.max(a,Math.hypot(e.clientX-n.x,e.clientY-n.y)))},l=e=>{t.size===0&&(n=e.pointerType,r=e.timeStamp,i=0,a=0,o=!1),t.set(e.pointerId,{x:e.clientX,y:e.clientY}),i=Math.max(i,t.size)},u=e=>c(e),d=e=>{if(!t.has(e.pointerId)||(c(e),e.type===`pointercancel`&&(o=!0),t.delete(e.pointerId),t.size>0))return;let l=n===`mouse`;s=!o&&i===1&&a<=(l?EC:DC)&&(l||e.timeStamp-r<=OC)},f={capture:!0,passive:!0};return e.addEventListener(`pointerdown`,l,f),e.addEventListener(`pointermove`,u,f),e.addEventListener(`pointerup`,d,f),e.addEventListener(`pointercancel`,d,f),{wasTap:()=>s,pointerType:()=>n,dispose:()=>{e.removeEventListener(`pointerdown`,l,f),e.removeEventListener(`pointermove`,u,f),e.removeEventListener(`pointerup`,d,f),e.removeEventListener(`pointercancel`,d,f)}}}function AC(e,t,n){let r=new bu({antialias:t.render.antialias,canvas:e,alpha:!0,powerPreference:`high-performance`,preserveDrawingBuffer:t.render.preserveDrawingBuffer,logarithmicDepthBuffer:!1}),i=e.parentElement,a=i?i.clientWidth:window.innerWidth,o=i?i.clientHeight:window.innerHeight;return i&&(e.style.width=`100%`,e.style.height=`100%`,e.style.display=`block`),r.setSize(a,o,!1),r.setPixelRatio(n),t.render.enableShadows&&(r.shadowMap.enabled=!0,r.shadowMap.type=3),r.toneMapping=t.render.toneMapping,r.toneMappingExposure=t.render.toneMappingExposure??1,r.outputColorSpace=We,r.sortObjects=!0,r}var jC=function(e,t){let n=rb(t||{}),r=n.environment?.sceneUp||tb,i=n.render.pixelRatio??Math.min(window.devicePixelRatio,2),a=YS(i,Eu(n.look,n.render.lowPower));n.render.pixelRatio=a;let o=QS(n),s=ZS(n,e);s.up.copy(r);let c=AC(e,n,a);Lu(c.capabilities.getMaxAnisotropy()),t?.onMaxAnisotropy?.(c.capabilities.getMaxAnisotropy());let l=lC(s,e,n),u=Ob({scene:o,perspective:s,controls:l,onActiveCameraChange:()=>{},up:r}),d=()=>u.getActiveCamera(),f=!1;uC(o,c,n,()=>f);let p=hb(o,n),m=p.sun,h=()=>{m&&_b(m,Cb(o))};n.floor?.enabled&&dC(o,n);let g=n.floor?.enabled?o.children.find(e=>e.userData.id===`floor`)??null:null,_=n.grid.enabled?zx({cellSize:n.grid.cellSize,majorEvery:n.grid.majorEvery,cellColor:n.grid.cellColor,majorColor:n.grid.majorColor,fadeDistance:n.grid.fadeDistance,plane:n.grid.plane}):null;_&&o.add(_.object);let v=()=>{_&&_.fitToContent(Cb(o))},y=n.gizmo.enabled?ES({camera:s,domElement:e,controller:u}):null,b=n.grid.plane??eb(r),x=new q(+(b===`x`),+(b===`y`),+(b===`z`)),S=r.clone().normalize(),C=n.camera.dynamicNear?yS({camera:s,scene:o,groundNormals:()=>{let e=[];return _?.object.visible&&e.push(x),n.floor.enabled&&g?.visible&&e.push(S),e}}):null,w=Bx(e.parentElement??e,o),T=n.measure.enabled?pS({canvas:e,scene:o,getActiveCamera:d,getViewTarget:()=>l.target,requestRender:()=>j(),labelLayer:w,options:{snapPixels:n.measure.snapPixels,color:n.measure.color,labelClassName:n.measure.labelClassName,displayUnit:n.measure.displayUnit,format:n.measure.format}}):null,E=kC(e),D=n.events.enableEventHandlers===!1?{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{},selectEntries:()=>{},setHover:()=>{}}:TC(e,o,u,n,E),O=TS();T&&O.register({id:`measure`,tool:T,priority:0}),y&&O.register({id:`gizmo`,tool:y,priority:-100});let k=e=>{E.wasTap()&&O.handleClick(e)&&e.stopImmediatePropagation()};e.addEventListener(`click`,k,{capture:!0});let A=e=>O.handleMove(e);e.addEventListener(`mousemove`,A,{passive:!0});let j=()=>{},M=(e,t)=>{Px(e,{color:n.edges.color,darken:n.edges.darken,width:n.edges.width,thresholdAngle:n.edges.thresholdAngle,distanceFade:n.edges.distanceFade,maxTriangles:n.edges.maxTriangles,maxSegments:n.edges.maxSegments,maxOverlays:n.edges.maxOverlays,...t}).then(()=>{N(e),j()})},N=e=>{if(n.edges.screenSpaceFallback===!1)return;let t=!1;e.traverse(e=>{let n=e.userData?.edgesSkipped;(n===`triangle-cap`||n===`overlay-budget`)&&(t=!0)}),ee.setEdgeFallback(t)},P=e=>{Fx(e),ee.setEdgeFallback(!1),j()},F=e.parentElement,I=()=>F?{width:F.clientWidth,height:F.clientHeight}:{width:window.innerWidth,height:window.innerHeight},ee=cC({renderer:c,scene:o,getActiveCamera:d,getCanvasSize:I,config:n,requestRender:()=>j()});ee.sync();let te=XS({scene:o,renderer:c,lights:p,config:n,pipeline:ee,fullPixelRatio:i,requestRender:()=>j()}),ne,re=lb({scene:o,renderer:c,getPipeline:()=>ee.get(),frames:n.render.idleRefineFrames,lightOrbitFrameMs:n.render.lightOrbitFrameMs,jitterLights:e=>{m&&(ne=gb(m,e)),te.jitterEmissiveLights(e)},restoreLights:()=>{ne?.(),te.settleEmissiveLights()}}),{animate:ie,dispose:ae,invalidate:L,renderNow:R}=DS(c,o,s,d,u,l,I,()=>n.render.pixelRatio,n.events.onFrame,_,y,()=>ee.get(),w,C,n.render.onDemand??!0,re);return j=L,ie(),o.up.set(r.x,r.y,r.z),h(),v(),{scene:o,camera:s,controls:l,renderer:c,cameraController:u,grid:_,gizmo:y,measureTool:T,labelLayer:w,tools:O,applyEdges:M,clearEdges:P,invalidate:L,captureImage:(e=`image/png`,t)=>(R(),new Promise(n=>c.domElement.toBlob(n,e,t))),setAmbientOcclusion:ee.setAmbientOcclusion,setLook:te.setLook,syncEmissiveLights:te.syncEmissiveLights,setFillLights:te.setFillLights,setEnvironmentIntensity:te.setEnvironmentIntensity,setToneMappingExposure:te.setToneMappingExposure,setAoIntensity:te.setAoIntensity,getMaterialAppearance:te.getMaterialAppearance,updateShadowBounds:h,updateGridScale:v,dispose:()=>{f||(f=!0,ae(),D.dispose(),E.dispose(),e.removeEventListener(`click`,k,{capture:!0}),e.removeEventListener(`mousemove`,A),T?.dispose(),w?.dispose(),y?.dispose(),_?.dispose(),ee.dispose(),u.dispose(),l.dispose(),c.dispose(),c.forceContextLoss(),$S(o))},fitToView:D.fitToView,clearSelection:D.clearSelection,selectEntries:e=>{D.selectEntries(e),L()},setHover:(e,t)=>{D.setHover(e,t),L()},addUserGeometry:(e,t)=>{e.userData.source=t===void 0?wy:Ey(t),o.add(e),j()},removeUserGeometry:e=>{e.removeFromParent(),Wu(e),j()},clearUserGeometry:e=>{o.children.filter(t=>ky(t,e)).forEach(e=>{e.removeFromParent(),Wu(e)}),j()}}},MC=1e4,NC=()=>new Promise(e=>requestAnimationFrame(()=>e(void 0)));window.selvaCapture=async({response:e,view:t,grid:n,look:r,background:i,hdr:a})=>{let o=document.createElement(`canvas`);o.style.cssText=`display:block;width:100%;height:100%`,document.getElementById(`stage`).append(o);let s,c=new Promise(e=>s=e),l=jC(o,{look:Cy.includes(r)?r:`technical`,onMaxAnisotropy:Ap,environment:{hdrPath:a??!1,...i&&{backgroundColor:i}},events:{enableEventHandlers:!1,onReady:()=>s()}});await Promise.race([c,new Promise(e=>setTimeout(e,MC))]);let u=await Zm(e,{parsing:{material:l.getMaterialAppearance()}});if(yb(l.scene,u,l.camera,l.controls,!1),!u.length)return{png:``,drawn:0};l.grid?.setVisible(n),l.updateGridScale(),l.updateShadowBounds(),l.syncEmissiveLights(),l.cameraController.setView(t,!1),await NC(),await NC();let d=await l.captureImage(`image/png`);if(!d)return{png:``,drawn:u.length};let f=new Uint8Array(await d.arrayBuffer()),p=``;for(let e=0;e<f.length;e+=32768)p+=String.fromCharCode(...f.subarray(e,e+32768));return{png:btoa(p),drawn:u.length}};</script>
|
|
6077
|
+
}`};function oC(e){let t=new en(1,1,{type:D,depthBuffer:!1}),n=new wa({...aC,uniforms:{tFrame:{value:null}},depthTest:!1,depthWrite:!1,toneMapped:!1,blending:5,blendSrc:213,blendDst:214}),r=new kv(n),i=(t,i)=>{n.uniforms.tFrame.value=t,n.blendAlpha=i;let a=e.autoClear;e.autoClear=!1,r.render(e),e.autoClear=a},a=()=>{e.setRenderTarget(null),i(t.texture,1)};return{add:(n,r,o,s)=>{(t.width!==o||t.height!==s)&&t.setSize(o,s),e.setRenderTarget(t),i(n,1/(r+1)),a()},present:a,dispose:()=>{t.dispose(),n.dispose(),r.dispose()}}}function sC(e){return e>=2?0:4}function cC(e){let t=e,n=t._overrideVisibility.bind(e),r=t._restoreVisibility.bind(e),i=()=>{};t._overrideVisibility=()=>{n(),i=Vu(e.scene)},t._restoreVisibility=()=>{i(),r()}}function lC(e,t,n,r,i,a){let o=new en(r,i,{type:D}),s=new Nv(e,o);s.renderTarget2.samples=0;let c=e=>{s.readBuffer=o,s.writeBuffer=s.renderTarget2,s.render(e)},l=new Pv(t,n);s.addPass(l);let u=null;(a.ambientOcclusion??!0)&&(u=new Wv(t,n,r,i),u.blendIntensity=a.aoIntensity??1,u.updateGtaoMaterial({screenSpaceRadius:!0}),cC(u),s.addPass(u));let d=null,f=null;if(a.bloom){let{strength:e,radius:t,threshold:n}=a.bloom;d=new Av(iC),s.addPass(d),f=new Qv(new K(r,i),e,t,n),s.addPass(f)}let p=new rC(t,n,r,i,typeof a.edgeDetection==`object`?a.edgeDetection:{});p.enabled=!!a.edgeDetection,s.addPass(p);let m=new Jv;s.addPass(m);let h=new Xv;s.addPass(h),e.toneMapping=a.toneMapping,e.toneMappingExposure=a.toneMappingExposure;let g=null,_=a.aoPixelRatio??1,v=1;if(u){let e=u.setSize.bind(u);u.setSize=(t,n)=>e(Math.max(1,Math.round(t*v)),Math.max(1,Math.round(n*v)))}let y=e=>{v=Math.min(e,_)/e;let t=sC(e);o.samples!==t&&(o.samples=t,o.dispose()),s.setPixelRatio(e)};return y(e.getPixelRatio()),s.setSize(r,i),{render:c,setSize:(e,t,n)=>{y(n),s.setSize(e,t)},setCamera:e=>{if(l.camera=e,p.camera=e,!u)return;u.camera=e;let t=+!!e.isPerspectiveCamera;u.gtaoMaterial.defines.PERSPECTIVE_CAMERA!==t&&(u.gtaoMaterial.defines.PERSPECTIVE_CAMERA=t,u.gtaoMaterial.needsUpdate=!0)},setEdgeDetection:e=>{p.enabled=e},edgeDetectionEnabled:()=>p.enabled,accumulate:t=>{s.renderToScreen=!1,c(0),s.renderToScreen=!0,g??=oC(e);let{texture:n,width:r,height:i}=s.readBuffer;g.add(n,t,r,i)},presentAccumulated:()=>g?.present(),setAoWeight:e=>{u&&(u.enabled=e>0,u.blendIntensity=(a.aoIntensity??1)*e)},dispose:()=>{s.dispose(),g?.dispose(),u?.dispose(),d?.dispose(),f?.dispose(),p.dispose(),m.dispose(),h.dispose()}}}function uC(e){let{renderer:t,scene:n,getActiveCamera:r,getCanvasSize:i,config:a,requestRender:o}=e,s=null,c=!!a.render.ambientOcclusion,l=!1,u=()=>({ambientOcclusion:c,bloom:a.render.bloom,toneMapping:a.render.toneMapping,toneMappingExposure:a.render.toneMappingExposure}),d=u(),f=()=>{let e=u();return e.ambientOcclusion!==d.ambientOcclusion||e.bloom!==d.bloom||e.toneMapping!==d.toneMapping||e.toneMappingExposure!==d.toneMappingExposure},p=()=>{let{width:e,height:o}=i(),s=lC(t,n,r(),Math.max(1,e),Math.max(1,o),{toneMapping:a.render.toneMapping??7,toneMappingExposure:a.render.toneMappingExposure??1,ambientOcclusion:c,aoIntensity:a.render.aoIntensity,aoPixelRatio:a.render.aoPixelRatio,bloom:a.render.bloom,edgeDetection:!1});return s.setSize(Math.max(1,e),Math.max(1,o),a.render.pixelRatio),s},m=()=>{c||l||a.render.bloom?((!s||f())&&(s?.dispose(),s=p(),d=u()),s.setEdgeDetection(l),o()):(s?.dispose(),s=null,o())};return{get:()=>s,sync:m,rebuild:()=>{s?.dispose(),s=null,m()},setAmbientOcclusion:e=>{c=e,m()},setEdgeFallback:e=>{e!==l&&(l=e,m())},isEdgeFallbackActive:()=>l,dispose:()=>{s?.dispose(),s=null}}}function dC(e,t,n){let r=new ly(e,t),i=n.camera.target;return i&&r.target.set(i.x,i.y,i.z),r.enableDamping=n.controls.enableDamping||!1,r.dampingFactor=n.controls.dampingFactor||.05,r.autoRotate=n.controls.autoRotate||!1,r.autoRotateSpeed=n.controls.autoRotateSpeed||.5,r.enableZoom=n.controls.enableZoom??!0,r.enablePan=n.controls.enablePan??!0,r.minDistance=n.controls.minDistance||.001,r.maxDistance=n.controls.maxDistance||1/0,r.screenSpacePanning=!1,r.maxPolarAngle=Math.PI,r.update(),r}function fC(e,t,n,r){if(n.environment.enableEnvironmentLighting){if(Ky(e,t,$y(n.environment.sceneUp??tb)),n.environment.hdrPath===!1){n.events.onReady?.();return}new Sy().load(n.environment.hdrPath||`/baseHDR.hdr`,function(i){if(r()){i.dispose();return}if(!i?.image){wu().warn(`HDR loaded without image data; skipping environment map.`),i?.dispose(),n.events.onReady?.();return}i.mapping=303;let a=new js(t);a.compileEquirectangularShader();let o=a.fromEquirectangular(i).texture;a.dispose(),e.environment=o,e.environmentIntensity=n.environment.environmentIntensity??1;let s=$y(n.environment.sceneUp??tb);e.environmentRotation.copy(s),n.environment.showEnvironment?(e.background=i,e.backgroundRotation.copy(s)):i.dispose(),n.events.onReady?.()},void 0,function(e){r()||(wu().warn(`HDR texture could not be loaded, falling back to basic lighting:`,e),n.events.onReady?.())})}else n.events.onReady?.()}function pC(e,t){let n=t.floor.size,r=new Oi(new pa(n,n),new Ea({color:typeof t.floor.color==`string`?new Z(t.floor.color):t.floor.color,roughness:t.floor.roughness,metalness:t.floor.metalness,side:2}));r.userData.id=`floor`,r.name=`floor`;let i=(t.environment?.sceneUp||tb).clone().normalize();r.quaternion.setFromUnitVectors(new q(0,0,1),i),r.position.set(0,0,0),t.floor.receiveShadow&&t.render.enableShadows&&(r.receiveShadow=!0),e.add(r)}var mC=.75,hC=.6,gC=.2,_C=1,vC=`#ffb020`,yC=[8,16],bC=8,xC=300,SC=30,CC=.35,wC=new Z(`#2f7bff`);function TC(e,t){let n=e.color;return n&&Math.hypot(n.r-t.r,n.g-t.g,n.b-t.b)<CC?wC:t}function EC(e,t,n){let r=TC(e,t);if(n&&`emissive`in e){let t=e;t.emissive=r.clone(),t.emissiveIntensity=hC,t.color.lerp(r,mC),t.metalness=Math.min(t.metalness,gC),t.opacity<_C&&(t.opacity=_C,t.transparent=!1,t.depthWrite=!0)}else`color`in e&&(e.color=r.clone())}function DC(e,t,n,r,i){let a=new Set,o=new Map,s=[],c=null,l=!1,u=new Xo,d=new K,f=()=>n.getActiveCamera(),p=()=>{let e=Cb(t);e.isEmpty()?wu().warn(`No objects to fit to view`):n.frameBounds(e,!1)},m=typeof r.events.selectionColor==`string`?new Z(r.events.selectionColor):r.events.selectionColor instanceof Z?r.events.selectionColor:new Z(`#ff0000`),h=new Z(vC),g=[],_=[],v=(e,n)=>{let r=e;for(;r.parent;)r=r.parent;r!==t&&(n instanceof Jr?n.dispose():n.forEach(e=>e.dispose()))},y=()=>{for(let{restore:e,material:t}of _)e(),t.dispose();_.length=0;for(let{object:e,original:t}of g){let n=e.material;n instanceof Jr&&n.dispose(),e.material=t,v(e,t)}g.length=0},b=e=>{let t=[],n=new Map;for(let{object:r,memberIndex:i}of e){if(i===null){t.push(r);continue}let e=n.get(r);e||n.set(r,e=new Set),e.add(i)}return{whole:t,membersByMesh:n}},x=(e,t=null)=>{if(y(),!e)return;let n=e instanceof An?[{object:e,memberIndex:t}]:e,{whole:r,membersByMesh:i}=b(n);for(let[e,t]of i){if(!(e instanceof Oi)){r.push(e);continue}let n=_h(e).clone();EC(n,h,!0),_.push({restore:vx(e,t,n,`hover`),material:n})}for(let e of r){if(a.has(e))continue;let t=e;if(!(t.material instanceof Jr))continue;let n=vh(t.material);EC(n,h,e instanceof Oi),g.push({object:t,original:t.material}),t.material=n}},S=()=>{for(let{restore:e,material:t}of s)e(),t.dispose();s.length=0,a.forEach(e=>{let t=e;if(o.has(e)){let n=o.get(e),r=t.material;r instanceof Jr?r.dispose():Array.isArray(r)&&r.forEach(e=>e.dispose()),t.material=n,o.delete(e),v(e,n)}}),a.clear(),c=null,l=!1},C=(e,t)=>{if(t&&e instanceof Oi){let n=_h(e).clone();return EC(n,m,!0),s.push({restore:vx(e,t,n),material:n}),!0}let n=e;if(!(n.material instanceof Jr))return!1;let r=vh(n.material);return EC(r,m,e instanceof Oi),o.set(e,n.material),n.material=r,!0},w=e=>{let{whole:t,membersByMesh:n}=b(e);for(let e of t)a.add(e),C(e,null);for(let[e,t]of n)a.add(e),C(e,t)},T=e=>{(e.length!==0||l)&&(y(),S(),w(e),l=e.length>0)},E=null,D=-1,O=()=>{if(E===null||t.children.length!==D){let e=Cb(t);E=e.isEmpty()?1:e.getSize(new q).length(),D=t.children.length}u.params.Points.threshold=E*.01},k=(t,n)=>{let r=e.getBoundingClientRect();d.x=(t-r.left)/r.width*2-1,d.y=-((n-r.top)/r.height)*2+1},A=(e,n)=>(k(e,n),O(),u.setFromCamera(d,f()),$x(t,u)[0]??null),j=(e,t,n)=>{let r=A(e,t);if(r||!n)return r;for(let n of yC){let r=null;for(let i=0;i<bC;i++){let a=i/bC*Math.PI*2,o=A(e+Math.cos(a)*n,t+Math.sin(a)*n);o&&(!r||o.distance<r.distance)&&(r=o)}if(r)return r}return null},M=null,N=e=>{let t=M;if(M={time:e.timeStamp,x:e.clientX,y:e.clientY},!t)return!1;let n=e.timeStamp-t.time<=xC&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<=SC;return n&&(M=null),n},P=e=>{if(!i.wasTap())return;let n=i.pointerType()!==`mouse`;if(n&&N(e)){I(e.clientX,e.clientY,!0);return}let a=j(e.clientX,e.clientY,n);if(!a){S(),k(e.clientX,e.clientY),r.events?.onBackgroundClicked?.({x:d.x,y:d.y});return}let o=a.object,s=mx(a),u=s?.index??null;(l||c?.object!==o||c.memberIndex!==u)&&(y(),S(),c={object:o,memberIndex:u},w(gx(t,a)),r.events?.onObjectSelected?.(o),s?r.events?.onMeshMetadataClicked?.({source:o.userData?.source,name:s.member.name,layer:s.member.layer,trackingKey:s.member.trackingKey,metadata:s.member.metadata}):o instanceof Oi&&Object.keys(o.userData).length>0&&r.events?.onMeshMetadataClicked?.(o.userData))},F=e=>{i.wasTap()&&i.pointerType()===`mouse`&&I(e.clientX,e.clientY,!1)},I=(e,i,a)=>{let o=j(e,i,a);if(!o){r.events?.enableDoubleClickZoom&&n.frameBounds(Cb(t),!0);return}let s=o.object;if(r.events?.onMeshDoubleClicked?.(s),!r.events?.enableDoubleClickZoom)return;let c=new er;for(let{object:e,memberIndex:n}of gx(t,o)){let t=n===null?null:px(e)?.[n];c.union(t&&e instanceof Oi?_x(e,t):new er().setFromObject(e))}c.isEmpty()||n.frameBounds(c,!0)},ee=e=>{if(r.events?.enableKeyboardControls)switch(e.key.toLowerCase()){case`f`:e.preventDefault(),p();break;case`escape`:e.preventDefault(),S();break;case` `:e.preventDefault(),p()}};return r.events?.enableClickToFocus&&(e.addEventListener(`click`,P),e.addEventListener(`dblclick`,F)),r.events?.enableKeyboardControls&&(e.setAttribute(`tabindex`,`0`),e.addEventListener(`keydown`,ee)),{dispose:()=>{e.removeEventListener(`click`,P),e.removeEventListener(`dblclick`,F),e.removeEventListener(`keydown`,ee),y(),S()},fitToView:p,clearSelection:S,selectEntries:T,setHover:x}}var OC=5,kC=10,AC=500;function jC(e){let t=new Map,n=`mouse`,r=0,i=0,a=0,o=!1,s=!1,c=e=>{let n=t.get(e.pointerId);n&&(a=Math.max(a,Math.hypot(e.clientX-n.x,e.clientY-n.y)))},l=e=>{t.size===0&&(n=e.pointerType,r=e.timeStamp,i=0,a=0,o=!1),t.set(e.pointerId,{x:e.clientX,y:e.clientY}),i=Math.max(i,t.size)},u=e=>c(e),d=e=>{if(!t.has(e.pointerId)||(c(e),e.type===`pointercancel`&&(o=!0),t.delete(e.pointerId),t.size>0))return;let l=n===`mouse`;s=!o&&i===1&&a<=(l?OC:kC)&&(l||e.timeStamp-r<=AC)},f={capture:!0,passive:!0};return e.addEventListener(`pointerdown`,l,f),e.addEventListener(`pointermove`,u,f),e.addEventListener(`pointerup`,d,f),e.addEventListener(`pointercancel`,d,f),{wasTap:()=>s,pointerType:()=>n,dispose:()=>{e.removeEventListener(`pointerdown`,l,f),e.removeEventListener(`pointermove`,u,f),e.removeEventListener(`pointerup`,d,f),e.removeEventListener(`pointercancel`,d,f)}}}function MC(e,t,n){let r=new bu({antialias:t.render.antialias,canvas:e,alpha:!0,powerPreference:`high-performance`,preserveDrawingBuffer:t.render.preserveDrawingBuffer,logarithmicDepthBuffer:!1}),i=e.parentElement,a=i?i.clientWidth:window.innerWidth,o=i?i.clientHeight:window.innerHeight;return i&&(e.style.width=`100%`,e.style.height=`100%`,e.style.display=`block`),r.setSize(a,o,!1),r.setPixelRatio(n),t.render.enableShadows&&(r.shadowMap.enabled=!0,r.shadowMap.type=3),r.toneMapping=t.render.toneMapping,r.toneMappingExposure=t.render.toneMappingExposure??1,r.outputColorSpace=We,r.sortObjects=!0,r}var NC=function(e,t){let n=rb(t||{}),r=n.environment?.sceneUp||tb,i=n.render.pixelRatio??Math.min(window.devicePixelRatio,2),a=ZS(i,Eu(n.look,n.render.lowPower));n.render.pixelRatio=a;let o=eC(n),s=$S(n,e);s.up.copy(r);let c=MC(e,n,a);Lu(c.capabilities.getMaxAnisotropy()),t?.onMaxAnisotropy?.(c.capabilities.getMaxAnisotropy());let l=dC(s,e,n),u=Ob({scene:o,perspective:s,controls:l,onActiveCameraChange:()=>{},up:r}),d=()=>u.getActiveCamera(),f=!1;fC(o,c,n,()=>f);let p=hb(o,n),m=p.sun,h=()=>{m&&_b(m,Cb(o))};n.floor?.enabled&&pC(o,n);let g=n.floor?.enabled?o.children.find(e=>e.userData.id===`floor`)??null:null,_=n.grid.enabled?Vx({cellSize:n.grid.cellSize,majorEvery:n.grid.majorEvery,cellColor:n.grid.cellColor,majorColor:n.grid.majorColor,fadeDistance:n.grid.fadeDistance,plane:n.grid.plane}):null;_&&o.add(_.object);let v=()=>{_&&_.fitToContent(Cb(o))},y=n.gizmo.enabled?OS({camera:s,domElement:e,controller:u}):null,b=n.grid.plane??eb(r),x=new q(+(b===`x`),+(b===`y`),+(b===`z`)),S=r.clone().normalize(),C=n.camera.dynamicNear?xS({camera:s,scene:o,groundNormals:()=>{let e=[];return _?.object.visible&&e.push(x),n.floor.enabled&&g?.visible&&e.push(S),e}}):null,w=Hx(e.parentElement??e,o),T=n.measure.enabled?hS({canvas:e,scene:o,getActiveCamera:d,getViewTarget:()=>l.target,requestRender:()=>j(),labelLayer:w,options:{snapPixels:n.measure.snapPixels,color:n.measure.color,labelClassName:n.measure.labelClassName,displayUnit:n.measure.displayUnit,format:n.measure.format}}):null,E=jC(e),D=n.events.enableEventHandlers===!1?{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{},selectEntries:()=>{},setHover:()=>{}}:DC(e,o,u,n,E),O=DS();T&&O.register({id:`measure`,tool:T,priority:0}),y&&O.register({id:`gizmo`,tool:y,priority:-100});let k=e=>{E.wasTap()&&O.handleClick(e)&&e.stopImmediatePropagation()};e.addEventListener(`click`,k,{capture:!0});let A=e=>O.handleMove(e);e.addEventListener(`mousemove`,A,{passive:!0});let j=()=>{},M=(e,t)=>{Ix(e,{color:n.edges.color,darken:n.edges.darken,width:n.edges.width,thresholdAngle:n.edges.thresholdAngle,distanceFade:n.edges.distanceFade,maxTriangles:n.edges.maxTriangles,maxSegments:n.edges.maxSegments,maxOverlays:n.edges.maxOverlays,...t}).then(()=>{N(e),j()})},N=e=>{if(n.edges.screenSpaceFallback===!1)return;let t=!1;e.traverse(e=>{let n=e.userData?.edgesSkipped;(n===`triangle-cap`||n===`overlay-budget`)&&(t=!0)}),ee.setEdgeFallback(t)},P=e=>{Lx(e),ee.setEdgeFallback(!1),j()},F=e.parentElement,I=()=>F?{width:F.clientWidth,height:F.clientHeight}:{width:window.innerWidth,height:window.innerHeight},ee=uC({renderer:c,scene:o,getActiveCamera:d,getCanvasSize:I,config:n,requestRender:()=>j()});ee.sync();let te=QS({scene:o,renderer:c,lights:p,config:n,pipeline:ee,fullPixelRatio:i,requestRender:()=>j()}),ne,re=lb({scene:o,renderer:c,getPipeline:()=>ee.get(),frames:n.render.idleRefineFrames,lightOrbitFrameMs:n.render.lightOrbitFrameMs,jitterLights:e=>{m&&(ne=gb(m,e)),te.jitterEmissiveLights(e)},restoreLights:()=>{ne?.(),te.settleEmissiveLights()}}),{animate:ie,dispose:ae,invalidate:L,renderNow:R}=kS(c,o,s,d,u,l,I,()=>n.render.pixelRatio,n.events.onFrame,_,y,()=>ee.get(),w,C,n.render.onDemand??!0,re);return j=L,ie(),o.up.set(r.x,r.y,r.z),h(),v(),{scene:o,camera:s,controls:l,renderer:c,cameraController:u,grid:_,gizmo:y,measureTool:T,labelLayer:w,tools:O,applyEdges:M,clearEdges:P,invalidate:L,captureImage:(e=`image/png`,t)=>(R(),new Promise(n=>c.domElement.toBlob(n,e,t))),setAmbientOcclusion:ee.setAmbientOcclusion,setLook:te.setLook,syncEmissiveLights:te.syncEmissiveLights,setFillLights:te.setFillLights,setEnvironmentIntensity:te.setEnvironmentIntensity,setToneMappingExposure:te.setToneMappingExposure,setAoIntensity:te.setAoIntensity,getMaterialAppearance:te.getMaterialAppearance,updateShadowBounds:h,updateGridScale:v,dispose:()=>{f||(f=!0,ae(),D.dispose(),E.dispose(),e.removeEventListener(`click`,k,{capture:!0}),e.removeEventListener(`mousemove`,A),T?.dispose(),w?.dispose(),y?.dispose(),_?.dispose(),ee.dispose(),u.dispose(),l.dispose(),c.dispose(),c.forceContextLoss(),tC(o))},fitToView:D.fitToView,clearSelection:D.clearSelection,selectEntries:e=>{D.selectEntries(e),L()},setHover:(e,t)=>{D.setHover(e,t),L()},addUserGeometry:(e,t)=>{e.userData.source=t===void 0?wy:Ey(t),o.add(e),j()},removeUserGeometry:e=>{e.removeFromParent(),Wu(e),j()},clearUserGeometry:e=>{o.children.filter(t=>ky(t,e)).forEach(e=>{e.removeFromParent(),Wu(e)}),j()}}},PC=1e4,FC=()=>new Promise(e=>requestAnimationFrame(()=>e(void 0)));window.selvaCapture=async({response:e,views:t,camera:n,grid:r,look:i,background:a,hdr:o})=>{let s=document.createElement(`canvas`);s.style.cssText=`display:block;width:100%;height:100%`,document.getElementById(`stage`).append(s);let c,l=new Promise(e=>c=e),u=NC(s,{look:Cy.includes(i)?i:`technical`,onMaxAnisotropy:Ap,environment:{hdrPath:o??!1,...a&&{backgroundColor:a}},events:{enableEventHandlers:!1,onReady:()=>c()}});await Promise.race([l,new Promise(e=>setTimeout(e,PC))]);let d=await Zm(e,{parsing:{material:u.getMaterialAppearance()}});if(yb(u.scene,d,u.camera,u.controls,!1),!d.length)return{pngs:[],drawn:0};u.grid?.setVisible(r),u.updateGridScale(),u.updateShadowBounds(),u.syncEmissiveLights();let f=[];for(let e of t){e==="default"?n?u.cameraController.setCameraView({direction:n.direction},!1):u.cameraController.setView(`iso`,!1):u.cameraController.setView(e,!1),await FC(),await FC();let t=await u.captureImage(`image/png`);f.push(t?IC(new Uint8Array(await t.arrayBuffer())):``)}return{pngs:f,drawn:d.length}};function IC(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}</script>
|
|
6078
6078
|
</head>
|
|
6079
6079
|
<body>
|
|
6080
6080
|
<div id="stage"></div>
|
package/dist/views/solve.html
CHANGED
|
@@ -6044,15 +6044,15 @@ ${nj}`))})}function ij(e,t){let n=Math.min(1,t.transmission);if(e.userData[FD]=!
|
|
|
6044
6044
|
`))&&a<t&&r<e.byteLength;)o+=s,a+=s.length,r+=128,s=String.fromCharCode.apply(null,new Uint16Array(e.subarray(r,r+128)));return-1<i&&(!1!==n&&(e.pos+=a+i+1),o+s.slice(0,i))},r=function(e){let r=/^#\?(\S+)/,i=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,a=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,o=/^\s*FORMAT=(\S+)\s*$/,s=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,c={valid:0,string:``,comments:``,programtype:`RGBE`,format:``,gamma:1,exposure:1,width:0,height:0},l,u;for((e.pos>=e.byteLength||!(l=n(e)))&&t(1,`no header found`),(u=l.match(r))||t(3,`bad initial token`),c.valid|=1,c.programtype=u[1],c.string+=l+`
|
|
6045
6045
|
`;l=n(e),!1!==l;)if(c.string+=l+`
|
|
6046
6046
|
`,l.charAt(0)===`#`)c.comments+=l+`
|
|
6047
|
-
`;else if((u=l.match(i))&&(c.gamma=parseFloat(u[1])),(u=l.match(a))&&(c.exposure=parseFloat(u[1])),(u=l.match(o))&&(c.valid|=2,c.format=u[1]),(u=l.match(s))&&(c.valid|=4,c.height=parseInt(u[1],10),c.width=parseInt(u[2],10)),c.valid&2&&c.valid&4)break;return c.valid&2||t(3,`missing format specifier`),c.valid&4||t(3,`missing image size specifier`),c},i=function(e,n,r){let i=n;if(i<8||i>32767||e[0]!==2||e[1]!==2||e[2]&128)return new Uint8Array(e);i!==(e[2]<<8|e[3])&&t(3,`wrong scanline width`);let a=new Uint8Array(4*n*r);a.length||t(4,`unable to allocate buffer space`);let o=0,s=0,c=4*i,l=new Uint8Array(4),u=new Uint8Array(c),d=r;for(;d>0&&s<e.byteLength;){s+4>e.byteLength&&t(1),l[0]=e[s++],l[1]=e[s++],l[2]=e[s++],l[3]=e[s++],(l[0]!=2||l[1]!=2||(l[2]<<8|l[3])!=i)&&t(3,`bad rgbe scanline format`);let n=0,r;for(;n<c&&s<e.byteLength;){r=e[s++];let i=r>128;if(i&&(r-=128),(r===0||n+r>c)&&t(3,`bad scanline data`),i){let t=e[s++];for(let e=0;e<r;e++)u[n++]=t}else u.set(e.subarray(s,s+r),n),n+=r,s+=r}let f=i;for(let e=0;e<f;e++){let t=0;a[o]=u[e+t],t+=i,a[o+1]=u[e+t],t+=i,a[o+2]=u[e+t],t+=i,a[o+3]=u[e+t],o+=4}d--}return a},a=function(e,t,n,r){let i=2**(e[t+3]-128)/255;n[r+0]=e[t+0]*i,n[r+1]=e[t+1]*i,n[r+2]=e[t+2]*i,n[r+3]=1},o=function(e,t,n,r){let i=2**(e[t+3]-128)/255;n[r+0]=hb.toHalfFloat(Math.min(e[t+0]*i,65504)),n[r+1]=hb.toHalfFloat(Math.min(e[t+1]*i,65504)),n[r+2]=hb.toHalfFloat(Math.min(e[t+2]*i,65504)),n[r+3]=hb.toHalfFloat(1)},s=new Uint8Array(e);s.pos=0;let c=r(s),l=c.width,u=c.height,d=i(s.subarray(s.pos),l,u),f,p,m;switch(this.type){case Og:m=d.length/4;let e=new Float32Array(m*4);for(let t=0;t<m;t++)a(d,t*4,e,t*4);f=e,p=Og;break;case kg:m=d.length/4;let t=new Uint16Array(m*4);for(let e=0;e<m;e++)o(d,e*4,t,e*4);f=t,p=kg;break;default:throw Error(`THREE.HDRLoader: Unsupported type: `+this.type)}return{width:l,height:u,data:f,header:c.string,gamma:c.gamma,exposure:c.exposure,type:p,colorSpace:I_,minFilter:yg,magFilter:yg,generateMipmaps:!1,flipY:!0}}setDataType(e){return this.type=e,this}},yI=[`technical`,`studio`,`showcase`,`arctic`,`xray`,`lineart`,`wireframe`,`night`],bI=`user`,xI=`app:`;function SI(e){return`${xI}${e}`}function CI(e){return typeof e!=`string`||!e.startsWith(xI)?null:e.slice(4)||null}function wI(e){let t=e.userData?.source;return t===`user`||CI(t)!==null}function TI(e,t){return t===void 0?wI(e):e.userData?.source===SI(t)}var EI=2.5,DI=11,OI=4.5,kI=3.5,AI=.05,jI=.06,MI=.65,NI=.8,PI=10;function FI(e,t,n,r){let i=new wx(new lS(t,n),new fx({color:new Q().setScalar(e),side:2}));return i.position.set(...r),i.lookAt(0,0,0),i}function II(){let e=new Fy,t=new wx(LI(),new fx({vertexColors:!0,side:1})),n=new wx(new lS(PI,PI),new fx({color:new Q().setScalar(AI)}));return n.rotation.x=-Math.PI/2,n.position.y=-4,e.add(t,n,FI(EI,6.5,4.5,[0,4.8,.6]),FI(DI,1.4,5.5,[-4.7,.8,1.6]),FI(OI,.9,5,[4.7,.5,2.4]),FI(kI,5,.8,[.6,2.2,-4.7])),e}function LI(){let e=new nS(PI,PI,PI,1,16,1),t=e.attributes.position,n=new Float32Array(t.count*3);for(let e=0;e<t.count;e++){let r=t.getY(e)/(PI/2),i=r<0?Ov.lerp(MI,jI,-r):Ov.lerp(MI,NI,r);n.fill(i,e*3,e*3+3)}return e.setAttribute(`color`,new yb(n,3)),e}function RI(e){e.traverse(e=>{let t=e;t.geometry?.dispose(),t.material?.dispose()})}var zI=.5,BI=.03,VI=`selvaReflectionEnvironment`;function HI(e,t,n){let r=new Dw(t),i=II(),a=r.fromScene(i,BI).texture;RI(i),r.dispose(),UI(e,a,n)}function UI(e,t,n){let r={texture:t,rotation:n.clone()};e.userData[VI]=r,GI(e,e)}function WI(e){e.userData[VI]?.texture.dispose(),delete e.userData[VI]}function GI(e,t){let n=t.userData[VI];n&&e.traverse(e=>{if(e.userData.source!==`compute`)return;let t=e,r=Array.isArray(t.material)?t.material:t.material?[t.material]:[];for(let e of r){if(!(e instanceof SS)||e.envMap&&e.envMap!==n.texture)continue;let t=e.metalness>zI?n.texture:null;e.envMap!==t&&(e.envMap=t,e.envMapRotation.copy(n.rotation),e.needsUpdate=!0)}})}function KI(e){let t=e.clone().normalize(),n=new Z(0,0,1),r=new Z(0,1,0),i=Math.abs(t.dot(n))>.9?r:n,a=new Z().crossVectors(i,t).normalize();return{up:t,forward:new Z().crossVectors(t,a).normalize(),right:a}}function qI(e,t){let{forward:n,right:r,up:i}=KI(e);return n.clone().multiplyScalar(-1).add(r.clone().multiplyScalar(-1)).add(i).normalize().multiplyScalar(t)}function JI(e,t,n){let{forward:r,right:i,up:a}=KI(e);return i.clone().multiplyScalar(t).add(r.clone().multiplyScalar(t)).add(a.clone().multiplyScalar(n))}function YI(e){let t=e.clone().normalize(),n=new Z(0,1,0);if(t.dot(n)>.9999)return new ly;if(t.dot(n)<-.9999)return new ly(Math.PI,0,0);let r=new kv().setFromUnitVectors(n,t);return new ly().setFromQuaternion(r)}function XI(e){let t=Math.abs(e.x),n=Math.abs(e.y),r=Math.abs(e.z);return t>=n&&t>=r?`x`:n>=r?`y`:`z`}var ZI=new Z(0,0,1);function QI(){return(window.matchMedia?.(`(pointer: coarse)`).matches??!1)&&Math.min(window.screen.width,window.screen.height)<600}function $I(e){let t=e.sceneScale||`m`,n={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[t],r=e.look??`technical`,i=e.render?.lowPower??QI(),a=SD(r,i);return{sceneScale:t,look:r,camera:{position:e.camera?.position||qI(e.environment?.sceneUp??ZI,n.cameraDistance*Math.sqrt(3)),fov:e.camera?.fov||20,near:e.camera?.near||n.near,far:e.camera?.far||n.far,target:e.camera?.target||new Z(0,0,0),dynamicNear:e.camera?.dynamicNear??!0},lighting:{enableSunlight:e.lighting?.enableSunlight??!0,sunlightIntensity:e.lighting?.sunlightIntensity??a.sunlightIntensity,sunlightPosition:e.lighting?.sunlightPosition||JI(e.environment?.sceneUp??ZI,n.lightDistance,n.lightHeight),ambientLightColor:e.lighting?.ambientLightColor||new Q(4210752),ambientLightIntensity:e.lighting?.ambientLightIntensity??a.ambientIntensity,sunlightColor:e.lighting?.sunlightColor||16777215,enableHemisphereLight:e.lighting?.enableHemisphereLight??a.hemisphereIntensity>0,hemisphereSkyColor:e.lighting?.hemisphereSkyColor??14673663,hemisphereGroundColor:e.lighting?.hemisphereGroundColor??7036754,hemisphereIntensity:e.lighting?.hemisphereIntensity??a.hemisphereIntensity},environment:{hdrPath:e.environment?.hdrPath===!1?!1:e.environment?.hdrPath||`/baseHDR.hdr`,backgroundColor:e.environment?.backgroundColor||new Q(15790320),enableEnvironmentLighting:e.environment?.enableEnvironmentLighting??!0,sceneUp:e.environment?.sceneUp||ZI,showEnvironment:e.environment?.showEnvironment??!1,environmentIntensity:e.environment?.environmentIntensity??a.environmentIntensity},floor:{enabled:e.floor?.enabled??!1,size:e.floor?.size||n.floorSize,color:e.floor?.color||new Q(8421504),roughness:e.floor?.roughness??.7,metalness:e.floor?.metalness??0,receiveShadow:e.floor?.receiveShadow??!0},render:{enableShadows:e.render?.enableShadows??!0,shadowMapSize:e.render?.shadowMapSize||1024,antialias:e.render?.antialias??!0,pixelRatio:e.render?.pixelRatio||Math.min(window.devicePixelRatio,2),toneMapping:e.render?.toneMapping??a.toneMapping,toneMappingExposure:e.render?.toneMappingExposure??a.toneMappingExposure,preserveDrawingBuffer:e.render?.preserveDrawingBuffer??!1,lowPower:i,idleRefineFrames:e.render?.idleRefineFrames??(i?0:32),lightOrbitFrameMs:e.render?.lightOrbitFrameMs??22,ambientOcclusion:e.render?.ambientOcclusion??a.ambientOcclusion,aoIntensity:e.render?.aoIntensity??1,bloom:e.render?.bloom??a.bloom,aoPixelRatio:e.render?.aoPixelRatio??1,onDemand:e.render?.onDemand??!0},controls:{enableDamping:e.controls?.enableDamping??!1,dampingFactor:e.controls?.dampingFactor||.05,autoRotate:e.controls?.autoRotate??!1,autoRotateSpeed:e.controls?.autoRotateSpeed||.5,enableZoom:e.controls?.enableZoom??!0,enablePan:e.controls?.enablePan??!0,minDistance:e.controls?.minDistance||n.minDistance,maxDistance:e.controls?.maxDistance||1/0},grid:{enabled:e.grid?.enabled??!1,cellSize:e.grid?.cellSize??1,majorEvery:e.grid?.majorEvery??10,cellColor:e.grid?.cellColor??8947848,majorColor:e.grid?.majorColor??4473924,fadeDistance:e.grid?.fadeDistance??100,plane:e.grid?.plane??XI(e.environment?.sceneUp??ZI)},gizmo:{enabled:e.gizmo?.enabled??!1},edges:{enabled:e.edges?.enabled??!1,color:e.edges?.color,darken:e.edges?.darken,width:e.edges?.width??1.5,thresholdAngle:e.edges?.thresholdAngle??44,distanceFade:e.edges?.distanceFade??!0,maxTriangles:e.edges?.maxTriangles,maxSegments:e.edges?.maxSegments,maxOverlays:e.edges?.maxOverlays,screenSpaceFallback:e.edges?.screenSpaceFallback},measure:{enabled:e.measure?.enabled??!1,snapPixels:e.measure?.snapPixels,color:e.measure?.color,labelClassName:e.measure?.labelClassName,displayUnit:e.measure?.displayUnit,format:e.measure?.format},events:{onBackgroundClicked:e.events?.onBackgroundClicked,onObjectSelected:e.events?.onObjectSelected,onMeshMetadataClicked:e.events?.onMeshMetadataClicked,onMeshDoubleClicked:e.events?.onMeshDoubleClicked,selectionColor:e.events?.selectionColor||`#ff0000`,enableEventHandlers:e.events?.enableEventHandlers??!0,enableKeyboardControls:e.events?.enableKeyboardControls??!0,enableClickToFocus:e.events?.enableClickToFocus??!0,enableDoubleClickZoom:e.events?.enableDoubleClickZoom??!0,onReady:e.events?.onReady,onFrame:e.events?.onFrame},onMaxAnisotropy:e.onMaxAnisotropy}}var eL=150,tL=8,nL=12;function rL(e,t){let n=0,r=1/t;for(let i=e;i>0;i=Math.floor(i/t))n+=i%t*r,r/=t;return n}function iL(e){let t=0;return e.traverseVisible(e=>{t+=1;let{material:n}=e;for(let e of Array.isArray(n)?n:n?[n]:[])t+=e.version*31}),t}function aL(e){let{scene:t,renderer:n,getPipeline:r,frames:i,lightOrbitFrameMs:a,jitterLights:o,restoreLights:s}=e,c=0,l=0,u=0,d=new X,f=i>0&&a<=0,p=1,m=[],h=e=>{p=Math.min(1,Math.max(0,e)),r()?.setAoWeight(p)},g=e=>{m.push(e),!(m.length<nL)&&(m.sort((e,t)=>e-t),f=m[6]>a,m.length=0)},_=(e,t)=>{let r=e;if(!r.setViewOffset)return;n.getDrawingBufferSize(d);let i=t?rL(t,2)-.5:0,a=t?rL(t,3)-.5:0;r.setViewOffset(d.x,d.y,i,a,d.x,d.y)};return{reset:e=>{c=0,l=e},moving:e=>{i!==0&&(f?h(p-1/tL):g(e))},wants:e=>(c<i||p<1)&&e-l>=eL&&!!r(),step:e=>{let n=r();n&&(p<1?(h(p+1/tL),n.setCamera(e),n.accumulate(0)):(c>0&&o(c),_(e,c),n.setCamera(e),n.accumulate(c),e.clearViewOffset?.(),c>0&&s(),c+=1,c===i&&(u=iL(t))))},present:()=>i===0||c<i?!1:(r()?.presentAccumulated(),!!r()),isHolding:()=>i>0&&c>=i&&!!r()&&u===iL(t)}}var oL=.02,sL=6,cL=.62,lL=.018,uL=`sun-target`;function dL(e,t){let n=new CC(t.lighting.ambientLightColor,t.lighting.ambientLightIntensity);e.add(n);let r=null;if(t.lighting.enableHemisphereLight){r=new aC(t.lighting.hemisphereSkyColor,t.lighting.hemisphereGroundColor,t.lighting.hemisphereIntensity);let n=t.environment.sceneUp??ZI;r.position.copy(n),e.add(r)}if(!t.lighting.enableSunlight)return{ambient:n,hemisphere:r,sun:null};let i=new SC(t.lighting.sunlightColor??16777215,t.lighting.sunlightIntensity),a=t.lighting.sunlightPosition;return a&&i.position.set(a.x,a.y,a.z),t.render.enableShadows?(i.castShadow=!0,i.shadow.mapSize.width=t.render.shadowMapSize,i.shadow.mapSize.height=t.render.shadowMapSize,i.shadow.bias=-1e-4,i.shadow.normalBias=oL,i.shadow.radius=sL,i.shadow.blurSamples=12,i.shadow.intensity=cL,e.add(i),i.target.userData.id=uL,e.add(i.target),{ambient:n,hemisphere:r,sun:i}):(e.add(i),{ambient:n,hemisphere:r,sun:null})}function fL(e,t){let n=e.position.clone(),r=n.clone().sub(e.target.position),i=new Z(0,0,1).cross(r);i.lengthSq()===0&&i.set(1,0,0),i.setLength(r.length()*lL);let a=r.clone().cross(i).setLength(i.length()),o=rL(t,2)*Math.PI*2,s=Math.sqrt(rL(t,3));return e.position.addScaledVector(i,Math.cos(o)*s).addScaledVector(a,Math.sin(o)*s),()=>e.position.copy(n)}function pL(e,t){if(t.isEmpty())return;let n=t.getCenter(new Z),r=t.getSize(new Z).length()*.5*1.2;if(r===0)return;e.shadow.normalBias=Math.min(oL,r*.0015);let i=e.shadow.camera;i.left=-r,i.right=r,i.top=r,i.bottom=-r;let a=e.position.clone().sub(e.target.position).normalize();e.target.position.copy(n),e.target.updateMatrixWorld();let o=r*2;e.position.copy(n).addScaledVector(a,o),e.updateMatrixWorld(),i.near=o-r,i.far=o+r,i.updateProjectionMatrix()}var mL={HUGE_THRESHOLD:1e4,LARGE_THRESHOLD:1e3,SCALE_RATIO_THRESHOLD:100,NEAR_PLANE_FACTOR:{TINY:1e-4,SMALL:.001,NORMAL:.01},FAR_PLANE_FACTOR:{HUGE:100,LARGE:50,NORMAL:20},INITIAL_DISTANCE_MULTIPLIER:4};function hL(e,t,n,r,i){if(SL(e,bL(t)),t.length===0)return;t.forEach(t=>{e.add(t),GI(t,e)});let a=AD(t),o=a.getCenter(new Z),s=a.getSize(new Z),c=Math.max(s.x,s.y,s.z);if(c/Math.min(s.x||1,s.y||1,s.z||1)>mL.SCALE_RATIO_THRESHOLD||c>mL.HUGE_THRESHOLD?(n.near=c*mL.NEAR_PLANE_FACTOR.TINY,n.far=c*mL.FAR_PLANE_FACTOR.HUGE):c>mL.LARGE_THRESHOLD?(n.near=c*mL.NEAR_PLANE_FACTOR.SMALL,n.far=c*mL.FAR_PLANE_FACTOR.LARGE):(n.near=Math.max(.01,c*mL.NEAR_PLANE_FACTOR.NORMAL),n.far=Math.max(2e3,c*mL.FAR_PLANE_FACTOR.NORMAL)),n.updateProjectionMatrix(),!i){let e=c*mL.INITIAL_DISTANCE_MULTIPLIER;n.position.copy(o).add(qI(n.up,e)),r.target.copy(o),r.update()}}var gL=new Set([`grid`,`floor`,`label-layer`,`measure`,uL]);function _L(e){return typeof e.userData.id==`string`&&gL.has(e.userData.id)}function vL(e){let t=e;for(;t;){if(_L(t))return!0;t=t.parent}return!1}function yL(e){e.updateMatrixWorld(!0);let t=new Xy;return e.traverse(e=>{let n=e;e.visible&&!vL(e)&&n.geometry&&t.expandByObject(e)}),t}function bL(e){let t=new Set;for(let n of e)n.traverse(e=>{let n=e.geometry,r=n&&ug(n);r&&t.add(r)});return t}var xL=new Set([`floor`,`grid`,`label-layer`,uL]);function SL(e,t=new Set){let n=[],r=[];for(let t of e.children)t.isLight===!0||xL.has(t.userData.id)||wI(t)?n.push(t):r.push(t);e.children.length=0;for(let t of n)e.children.push(t);for(let n of r)BD(n,{keepUploaded:t}),n.parent=null,n.dispatchEvent({type:`removed`}),e.dispatchEvent({type:`childremoved`,child:n})}function CL(e){let{up:t,forward:n,right:r}=KI(e),i=n.clone().negate(),a=r.clone();return{top:t.clone(),bottom:t.clone().negate(),front:i.clone(),back:i.clone().negate(),right:a.clone(),left:a.clone().negate(),iso:i.clone().multiplyScalar(1.2).add(a.clone()).add(t.clone()).normalize()}}function wL(e){let{scene:t,perspective:n,controls:r,onActiveCameraChange:i}=e,a=(e.up??n.up).clone().normalize(),o=CL(a),s=new bC(-1,1,1,-1,n.near,n.far);s.up.copy(a);let c=`perspective`,l=n.aspect,u=()=>c===`perspective`?n:s,d=null,f=()=>{d?.cancel(),d=null},p=()=>{let e=(c===`orthographic`?s:n).position.distanceTo(r.target)*Math.tan(n.fov*Math.PI/360),t=e*l;s.left=-t,s.right=t,s.top=e,s.bottom=-e,s.near=n.near,s.far=n.far,s.updateProjectionMatrix()},m=e=>{if(e!==c){if(f(),e===`orthographic`)s.position.copy(n.position),s.up.copy(n.up),s.lookAt(r.target),s.zoom=1,p();else{let e=(s.top-s.bottom)/(2*s.zoom)/Math.tan(n.fov*Math.PI/360),t=s.position.clone().sub(r.target);t.lengthSq()<1e-12&&t.copy(a),t.normalize(),n.position.copy(r.target).add(t.multiplyScalar(e))}c=e,r.object=u(),r.update(),i(u())}},h=(e,t,i,o)=>{let l=n.fov*(Math.PI/180),m=t/(2*Math.tan(l/2))*1.5,h=TL(i,a),g=e.clone().add(h.clone().multiplyScalar(m)),_=u();c===`orthographic`&&(s.zoom=1),f(),o?d=DL(_,r,g,e,()=>{c===`orthographic`&&p()}):(_.position.copy(g),r.target.copy(e),c===`orthographic`&&p(),r.update())},g=(e,n=!0)=>{let i=yL(t),a=i.isEmpty()?r.target.clone():i.getCenter(new Z),o=i.isEmpty()?new Z(1,1,1):i.getSize(new Z),s=Math.max(o.x,o.y,o.z)||1;h(a,s,e,n)};return{getActiveCamera:u,getProjection:()=>c,setProjection:m,toggleProjection:()=>(m(c===`perspective`?`orthographic`:`perspective`),c),setView:(e,t=!0)=>{g(o[e],t)},setViewDirection:g,frameBounds:(e,t=!0)=>{if(e.isEmpty())return;let n=e.getCenter(new Z),i=e.getSize(new Z),a=Math.max(i.x,i.y,i.z)||1,s=u().position.clone().sub(r.target);s.lengthSq()<1e-12&&s.copy(o.iso),h(n,a,s.normalize(),t)},setRotateEnabled:e=>{r.enableRotate=e},isRotateEnabled:()=>r.enableRotate,updateAspect:(e,t)=>{l=t===0?l:e/t,c===`orthographic`&&p()},dispose:f}}function TL(e,t){let{up:n,forward:r}=KI(t),i=e.clone().normalize();if(Math.abs(i.dot(n))<.9999)return e;let a=r.clone().negate(),o=.5*Math.PI/180;return i.multiplyScalar(Math.cos(o)).add(a.multiplyScalar(Math.sin(o))).normalize()}var EL=e=>1-(1-e)**3;function DL(e,t,n,r,i,a=250){let o=e.position.clone(),s=t.target.clone(),c=performance.now(),l=null,u=()=>{l=null;let d=EL(Math.min((performance.now()-c)/a,1));e.position.lerpVectors(o,n,d),t.target.lerpVectors(s,r,d),i(),t.update(),d<1&&(l=requestAnimationFrame(u))};return l=requestAnimationFrame(u),{cancel:()=>{l!==null&&(cancelAnimationFrame(l),l=null)}}}var OL=.15,kL=4096;function AL(e){let t=Math.floor(e.length/6);if(t===0)return 1/0;let n=Math.max(1,Math.ceil(t/kL)),r=[];for(let i=0;i<t;i+=n){let t=i*6,n=Math.hypot(e[t+3]-e[t],e[t+4]-e[t+1],e[t+5]-e[t+2]);n>0&&r.push(n)}return r.length===0?1/0:(r.sort((e,t)=>e-t),r[Math.min(r.length-1,Math.floor(r.length*OL))])}function jL(e){let t=new WD;return t.setPositions(e),{geometry:t,segmentCount:e.length/6,edgeSpacing:AL(e)}}function ML(e,t,n){let r=1e4,i=Math.cos(Math.PI/180*n),a=e.length/3;if(a>=67108864)throw Error(`extractEdgeSegments: ${a} vertices exceeds 2^26 limit`);let o=new Float64Array(a),s=new Float64Array(a),c=new Float64Array(a);for(let t=0;t<a;t++)o[t]=Math.round(e[3*t]*r),s[t]=Math.round(e[3*t+1]*r),c[t]=Math.round(e[3*t+2]*r);let l=16;for(;l<a*2;)l<<=1;let u=l-1,d=new Int32Array(l).fill(-1),f=new Int32Array(a);for(let e=0;e<a;e++){let t=(Math.imul(o[e]|0,73856093)^Math.imul(s[e]|0,19349663)^Math.imul(c[e]|0,83492791))&u;for(;;){let n=d[t];if(n===-1){d[t]=e,f[e]=e;break}if(o[n]===o[e]&&s[n]===s[e]&&c[n]===c[e]){f[e]=n;break}t=t+1&u}}let p=new Float32Array(6144),m=0,h=new Uint32Array(1024),g=(t,n,r)=>{if(m+6>p.length){let e=new Float32Array(p.length*2);e.set(p),p=e;let t=new Uint32Array(p.length/6);t.set(h),h=t}h[m/6]=r,p[m++]=e[3*t],p[m++]=e[3*t+1],p[m++]=e[3*t+2],p[m++]=e[3*n],p[m++]=e[3*n+1],p[m++]=e[3*n+2]},_=(t?t.length:a)/3,v=new Int32Array(a+1);for(let e=0;e<_;e++){let n=f[t?t[3*e]:3*e],r=f[t?t[3*e+1]:3*e+1],i=f[t?t[3*e+2]:3*e+2];n!==r&&r!==i&&i!==n&&(v[n+1]++,v[r+1]++,v[i+1]++)}for(let e=0;e<a;e++)v[e+1]+=v[e];let y=new Int32Array(v[a]);{let e=v.slice(0,a);for(let n=0;n<_;n++){let r=f[t?t[3*n]:3*n],i=f[t?t[3*n+1]:3*n+1],a=f[t?t[3*n+2]:3*n+2];r!==i&&i!==a&&a!==r&&(y[e[r]++]=i,y[e[i]++]=a,y[e[a]++]=r)}}let b=new Int32Array(y.length).fill(-2),x=(e,t)=>{for(let n=v[e],r=v[e+1];n<r;n++)if(y[n]===t)return n;return-1},S=(e,n)=>t?t[3*e+n]:3*e+n,C=new Float64Array(3),w=t=>{let n=S(t,0),r=S(t,1),i=S(t,2),a=e[3*i]-e[3*r],o=e[3*i+1]-e[3*r+1],s=e[3*i+2]-e[3*r+2],c=e[3*n]-e[3*r],l=e[3*n+1]-e[3*r+1],u=e[3*n+2]-e[3*r+2],d=o*u-s*l,f=s*c-a*u,p=a*l-o*c,m=d*d+f*f+p*p;if(m>0){let e=1/Math.sqrt(m);d*=e,f*=e,p*=e}else d=0,f=0,p=0;C[0]=d,C[1]=f,C[2]=p},T=0,E=new Uint32Array(Math.max(16,y.length>>1)),D=new Int32Array(E.length),O=()=>{let e=new Uint32Array(E.length*2);e.set(E),E=e;let t=new Int32Array(e.length);t.set(D),D=t};for(let e=0;e<_;e++){let t=S(e,0),n=S(e,1),r=S(e,2),a=f[t],o=f[n],s=f[r];if(a===o||o===s||s===a)continue;let c=!1,l=0,u=0,d=0;for(let f=0;f<3;f++){let p=f===0?a:f===1?o:s,m=f===0?o:f===1?s:a,h=x(m,p),_=h===-1?-2:b[h];if(_>=0)c||=(w(e),l=C[0],u=C[1],d=C[2],!0),w(Math.floor(E[_]/3)),l*C[0]+u*C[1]+d*C[2]<=i&&g(f===0?t:f===1?n:r,f===0?n:f===1?r:t,e),b[h]=-1;else{let t=x(p,m);if(b[t]===-2){T===E.length&&O();let n=T++;b[t]=n,E[n]=3*e+f,D[n]=t}}}}for(let e=0;e<T;e++){if(b[D[e]]!==e)continue;let t=E[e],n=Math.floor(t/3),r=t-3*n;g(S(n,r),S(n,r===2?0:r+1),n)}return{segments:p.slice(0,m),faces:h.slice(0,m/6)}}function NL(){return[`const extract = ${ML.toString()};`,`self.onmessage = (event) => {`,` const { id, positions, index, thresholdAngle } = event.data;`,` try {`,` const { segments, faces } = extract(positions, index, thresholdAngle);`,` self.postMessage({ id, segments, faces }, [segments.buffer, faces.buffer]);`,` } catch (error) {`,` self.postMessage({ id, error: String((error && error.message) || error) });`,` }`,`};`].join(`
|
|
6048
|
-
`)}var
|
|
6047
|
+
`;else if((u=l.match(i))&&(c.gamma=parseFloat(u[1])),(u=l.match(a))&&(c.exposure=parseFloat(u[1])),(u=l.match(o))&&(c.valid|=2,c.format=u[1]),(u=l.match(s))&&(c.valid|=4,c.height=parseInt(u[1],10),c.width=parseInt(u[2],10)),c.valid&2&&c.valid&4)break;return c.valid&2||t(3,`missing format specifier`),c.valid&4||t(3,`missing image size specifier`),c},i=function(e,n,r){let i=n;if(i<8||i>32767||e[0]!==2||e[1]!==2||e[2]&128)return new Uint8Array(e);i!==(e[2]<<8|e[3])&&t(3,`wrong scanline width`);let a=new Uint8Array(4*n*r);a.length||t(4,`unable to allocate buffer space`);let o=0,s=0,c=4*i,l=new Uint8Array(4),u=new Uint8Array(c),d=r;for(;d>0&&s<e.byteLength;){s+4>e.byteLength&&t(1),l[0]=e[s++],l[1]=e[s++],l[2]=e[s++],l[3]=e[s++],(l[0]!=2||l[1]!=2||(l[2]<<8|l[3])!=i)&&t(3,`bad rgbe scanline format`);let n=0,r;for(;n<c&&s<e.byteLength;){r=e[s++];let i=r>128;if(i&&(r-=128),(r===0||n+r>c)&&t(3,`bad scanline data`),i){let t=e[s++];for(let e=0;e<r;e++)u[n++]=t}else u.set(e.subarray(s,s+r),n),n+=r,s+=r}let f=i;for(let e=0;e<f;e++){let t=0;a[o]=u[e+t],t+=i,a[o+1]=u[e+t],t+=i,a[o+2]=u[e+t],t+=i,a[o+3]=u[e+t],o+=4}d--}return a},a=function(e,t,n,r){let i=2**(e[t+3]-128)/255;n[r+0]=e[t+0]*i,n[r+1]=e[t+1]*i,n[r+2]=e[t+2]*i,n[r+3]=1},o=function(e,t,n,r){let i=2**(e[t+3]-128)/255;n[r+0]=hb.toHalfFloat(Math.min(e[t+0]*i,65504)),n[r+1]=hb.toHalfFloat(Math.min(e[t+1]*i,65504)),n[r+2]=hb.toHalfFloat(Math.min(e[t+2]*i,65504)),n[r+3]=hb.toHalfFloat(1)},s=new Uint8Array(e);s.pos=0;let c=r(s),l=c.width,u=c.height,d=i(s.subarray(s.pos),l,u),f,p,m;switch(this.type){case Og:m=d.length/4;let e=new Float32Array(m*4);for(let t=0;t<m;t++)a(d,t*4,e,t*4);f=e,p=Og;break;case kg:m=d.length/4;let t=new Uint16Array(m*4);for(let e=0;e<m;e++)o(d,e*4,t,e*4);f=t,p=kg;break;default:throw Error(`THREE.HDRLoader: Unsupported type: `+this.type)}return{width:l,height:u,data:f,header:c.string,gamma:c.gamma,exposure:c.exposure,type:p,colorSpace:I_,minFilter:yg,magFilter:yg,generateMipmaps:!1,flipY:!0}}setDataType(e){return this.type=e,this}},yI=[`technical`,`studio`,`showcase`,`arctic`,`xray`,`lineart`,`wireframe`,`night`],bI=`user`,xI=`app:`;function SI(e){return`${xI}${e}`}function CI(e){return typeof e!=`string`||!e.startsWith(xI)?null:e.slice(4)||null}function wI(e){let t=e.userData?.source;return t===`user`||CI(t)!==null}function TI(e,t){return t===void 0?wI(e):e.userData?.source===SI(t)}var EI=2.5,DI=11,OI=4.5,kI=3.5,AI=.05,jI=.06,MI=.65,NI=.8,PI=10;function FI(e,t,n,r){let i=new wx(new lS(t,n),new fx({color:new Q().setScalar(e),side:2}));return i.position.set(...r),i.lookAt(0,0,0),i}function II(){let e=new Fy,t=new wx(LI(),new fx({vertexColors:!0,side:1})),n=new wx(new lS(PI,PI),new fx({color:new Q().setScalar(AI)}));return n.rotation.x=-Math.PI/2,n.position.y=-4,e.add(t,n,FI(EI,6.5,4.5,[0,4.8,.6]),FI(DI,1.4,5.5,[-4.7,.8,1.6]),FI(OI,.9,5,[4.7,.5,2.4]),FI(kI,5,.8,[.6,2.2,-4.7])),e}function LI(){let e=new nS(PI,PI,PI,1,16,1),t=e.attributes.position,n=new Float32Array(t.count*3);for(let e=0;e<t.count;e++){let r=t.getY(e)/(PI/2),i=r<0?Ov.lerp(MI,jI,-r):Ov.lerp(MI,NI,r);n.fill(i,e*3,e*3+3)}return e.setAttribute(`color`,new yb(n,3)),e}function RI(e){e.traverse(e=>{let t=e;t.geometry?.dispose(),t.material?.dispose()})}var zI=.5,BI=.03,VI=`selvaReflectionEnvironment`;function HI(e,t,n){let r=new Dw(t),i=II(),a=r.fromScene(i,BI).texture;RI(i),r.dispose(),UI(e,a,n)}function UI(e,t,n){let r={texture:t,rotation:n.clone()};e.userData[VI]=r,GI(e,e)}function WI(e){e.userData[VI]?.texture.dispose(),delete e.userData[VI]}function GI(e,t){let n=t.userData[VI];n&&e.traverse(e=>{if(e.userData.source!==`compute`)return;let t=e,r=Array.isArray(t.material)?t.material:t.material?[t.material]:[];for(let e of r){if(!(e instanceof SS)||e.envMap&&e.envMap!==n.texture)continue;let t=e.metalness>zI?n.texture:null;e.envMap!==t&&(e.envMap=t,e.envMapRotation.copy(n.rotation),e.needsUpdate=!0)}})}function KI(e){let t=e.clone().normalize(),n=new Z(0,0,1),r=new Z(0,1,0),i=Math.abs(t.dot(n))>.9?r:n,a=new Z().crossVectors(i,t).normalize();return{up:t,forward:new Z().crossVectors(t,a).normalize(),right:a}}function qI(e,t){let{forward:n,right:r,up:i}=KI(e);return n.clone().multiplyScalar(-1).add(r.clone().multiplyScalar(-1)).add(i).normalize().multiplyScalar(t)}function JI(e,t,n){let{forward:r,right:i,up:a}=KI(e);return i.clone().multiplyScalar(t).add(r.clone().multiplyScalar(t)).add(a.clone().multiplyScalar(n))}function YI(e){let t=e.clone().normalize(),n=new Z(0,1,0);if(t.dot(n)>.9999)return new ly;if(t.dot(n)<-.9999)return new ly(Math.PI,0,0);let r=new kv().setFromUnitVectors(n,t);return new ly().setFromQuaternion(r)}function XI(e){let t=Math.abs(e.x),n=Math.abs(e.y),r=Math.abs(e.z);return t>=n&&t>=r?`x`:n>=r?`y`:`z`}var ZI=new Z(0,0,1);function QI(){return(window.matchMedia?.(`(pointer: coarse)`).matches??!1)&&Math.min(window.screen.width,window.screen.height)<600}function $I(e){let t=e.sceneScale||`m`,n={mm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:10,lightHeight:20,minDistance:.1,shadowSize:100,scaleFactor:1e3},cm:{cameraDistance:20,near:.1,far:2e3,floorSize:100,lightDistance:25,lightHeight:50,minDistance:.1,shadowSize:100,scaleFactor:100},m:{cameraDistance:10,near:.01,far:2e3,floorSize:50,lightDistance:25,lightHeight:50,minDistance:.001,shadowSize:100,scaleFactor:1},inches:{cameraDistance:15,near:.1,far:2e3,floorSize:80,lightDistance:20,lightHeight:40,minDistance:.1,shadowSize:80,scaleFactor:39.37},feet:{cameraDistance:8,near:.1,far:2e3,floorSize:40,lightDistance:15,lightHeight:30,minDistance:.1,shadowSize:60,scaleFactor:3.28084}}[t],r=e.look??`technical`,i=e.render?.lowPower??QI(),a=SD(r,i);return{sceneScale:t,look:r,camera:{position:e.camera?.position||qI(e.environment?.sceneUp??ZI,n.cameraDistance*Math.sqrt(3)),fov:e.camera?.fov||20,near:e.camera?.near||n.near,far:e.camera?.far||n.far,target:e.camera?.target||new Z(0,0,0),dynamicNear:e.camera?.dynamicNear??!0},lighting:{enableSunlight:e.lighting?.enableSunlight??!0,sunlightIntensity:e.lighting?.sunlightIntensity??a.sunlightIntensity,sunlightPosition:e.lighting?.sunlightPosition||JI(e.environment?.sceneUp??ZI,n.lightDistance,n.lightHeight),ambientLightColor:e.lighting?.ambientLightColor||new Q(4210752),ambientLightIntensity:e.lighting?.ambientLightIntensity??a.ambientIntensity,sunlightColor:e.lighting?.sunlightColor||16777215,enableHemisphereLight:e.lighting?.enableHemisphereLight??a.hemisphereIntensity>0,hemisphereSkyColor:e.lighting?.hemisphereSkyColor??14673663,hemisphereGroundColor:e.lighting?.hemisphereGroundColor??7036754,hemisphereIntensity:e.lighting?.hemisphereIntensity??a.hemisphereIntensity},environment:{hdrPath:e.environment?.hdrPath===!1?!1:e.environment?.hdrPath||`/baseHDR.hdr`,backgroundColor:e.environment?.backgroundColor||new Q(15790320),enableEnvironmentLighting:e.environment?.enableEnvironmentLighting??!0,sceneUp:e.environment?.sceneUp||ZI,showEnvironment:e.environment?.showEnvironment??!1,environmentIntensity:e.environment?.environmentIntensity??a.environmentIntensity},floor:{enabled:e.floor?.enabled??!1,size:e.floor?.size||n.floorSize,color:e.floor?.color||new Q(8421504),roughness:e.floor?.roughness??.7,metalness:e.floor?.metalness??0,receiveShadow:e.floor?.receiveShadow??!0},render:{enableShadows:e.render?.enableShadows??!0,shadowMapSize:e.render?.shadowMapSize||1024,antialias:e.render?.antialias??!0,pixelRatio:e.render?.pixelRatio||Math.min(window.devicePixelRatio,2),toneMapping:e.render?.toneMapping??a.toneMapping,toneMappingExposure:e.render?.toneMappingExposure??a.toneMappingExposure,preserveDrawingBuffer:e.render?.preserveDrawingBuffer??!1,lowPower:i,idleRefineFrames:e.render?.idleRefineFrames??(i?0:32),lightOrbitFrameMs:e.render?.lightOrbitFrameMs??22,ambientOcclusion:e.render?.ambientOcclusion??a.ambientOcclusion,aoIntensity:e.render?.aoIntensity??1,bloom:e.render?.bloom??a.bloom,aoPixelRatio:e.render?.aoPixelRatio??1,onDemand:e.render?.onDemand??!0},controls:{enableDamping:e.controls?.enableDamping??!1,dampingFactor:e.controls?.dampingFactor||.05,autoRotate:e.controls?.autoRotate??!1,autoRotateSpeed:e.controls?.autoRotateSpeed||.5,enableZoom:e.controls?.enableZoom??!0,enablePan:e.controls?.enablePan??!0,minDistance:e.controls?.minDistance||n.minDistance,maxDistance:e.controls?.maxDistance||1/0},grid:{enabled:e.grid?.enabled??!1,cellSize:e.grid?.cellSize??1,majorEvery:e.grid?.majorEvery??10,cellColor:e.grid?.cellColor??8947848,majorColor:e.grid?.majorColor??4473924,fadeDistance:e.grid?.fadeDistance??100,plane:e.grid?.plane??XI(e.environment?.sceneUp??ZI)},gizmo:{enabled:e.gizmo?.enabled??!1},edges:{enabled:e.edges?.enabled??!1,color:e.edges?.color,darken:e.edges?.darken,width:e.edges?.width??1.5,thresholdAngle:e.edges?.thresholdAngle??44,distanceFade:e.edges?.distanceFade??!0,maxTriangles:e.edges?.maxTriangles,maxSegments:e.edges?.maxSegments,maxOverlays:e.edges?.maxOverlays,screenSpaceFallback:e.edges?.screenSpaceFallback},measure:{enabled:e.measure?.enabled??!1,snapPixels:e.measure?.snapPixels,color:e.measure?.color,labelClassName:e.measure?.labelClassName,displayUnit:e.measure?.displayUnit,format:e.measure?.format},events:{onBackgroundClicked:e.events?.onBackgroundClicked,onObjectSelected:e.events?.onObjectSelected,onMeshMetadataClicked:e.events?.onMeshMetadataClicked,onMeshDoubleClicked:e.events?.onMeshDoubleClicked,selectionColor:e.events?.selectionColor||`#ff0000`,enableEventHandlers:e.events?.enableEventHandlers??!0,enableKeyboardControls:e.events?.enableKeyboardControls??!0,enableClickToFocus:e.events?.enableClickToFocus??!0,enableDoubleClickZoom:e.events?.enableDoubleClickZoom??!0,onReady:e.events?.onReady,onFrame:e.events?.onFrame},onMaxAnisotropy:e.onMaxAnisotropy}}var eL=150,tL=8,nL=12;function rL(e,t){let n=0,r=1/t;for(let i=e;i>0;i=Math.floor(i/t))n+=i%t*r,r/=t;return n}function iL(e){let t=0;return e.traverseVisible(e=>{t+=1;let{material:n}=e;for(let e of Array.isArray(n)?n:n?[n]:[])t+=e.version*31}),t}function aL(e){let{scene:t,renderer:n,getPipeline:r,frames:i,lightOrbitFrameMs:a,jitterLights:o,restoreLights:s}=e,c=0,l=0,u=0,d=new X,f=i>0&&a<=0,p=1,m=[],h=e=>{p=Math.min(1,Math.max(0,e)),r()?.setAoWeight(p)},g=e=>{m.push(e),!(m.length<nL)&&(m.sort((e,t)=>e-t),f=m[6]>a,m.length=0)},_=(e,t)=>{let r=e;if(!r.setViewOffset)return;n.getDrawingBufferSize(d);let i=t?rL(t,2)-.5:0,a=t?rL(t,3)-.5:0;r.setViewOffset(d.x,d.y,i,a,d.x,d.y)};return{reset:e=>{c=0,l=e},moving:e=>{i!==0&&(f?h(p-1/tL):g(e))},wants:e=>(c<i||p<1)&&e-l>=eL&&!!r(),step:e=>{let n=r();n&&(p<1?(h(p+1/tL),n.setCamera(e),n.accumulate(0)):(c>0&&o(c),_(e,c),n.setCamera(e),n.accumulate(c),e.clearViewOffset?.(),c>0&&s(),c+=1,c===i&&(u=iL(t))))},present:()=>i===0||c<i?!1:(r()?.presentAccumulated(),!!r()),isHolding:()=>i>0&&c>=i&&!!r()&&u===iL(t)}}var oL=.02,sL=6,cL=.62,lL=.018,uL=`sun-target`;function dL(e,t){let n=new CC(t.lighting.ambientLightColor,t.lighting.ambientLightIntensity);e.add(n);let r=null;if(t.lighting.enableHemisphereLight){r=new aC(t.lighting.hemisphereSkyColor,t.lighting.hemisphereGroundColor,t.lighting.hemisphereIntensity);let n=t.environment.sceneUp??ZI;r.position.copy(n),e.add(r)}if(!t.lighting.enableSunlight)return{ambient:n,hemisphere:r,sun:null};let i=new SC(t.lighting.sunlightColor??16777215,t.lighting.sunlightIntensity),a=t.lighting.sunlightPosition;return a&&i.position.set(a.x,a.y,a.z),t.render.enableShadows?(i.castShadow=!0,i.shadow.mapSize.width=t.render.shadowMapSize,i.shadow.mapSize.height=t.render.shadowMapSize,i.shadow.bias=-1e-4,i.shadow.normalBias=oL,i.shadow.radius=sL,i.shadow.blurSamples=12,i.shadow.intensity=cL,e.add(i),i.target.userData.id=uL,e.add(i.target),{ambient:n,hemisphere:r,sun:i}):(e.add(i),{ambient:n,hemisphere:r,sun:null})}function fL(e,t){let n=e.position.clone(),r=n.clone().sub(e.target.position),i=new Z(0,0,1).cross(r);i.lengthSq()===0&&i.set(1,0,0),i.setLength(r.length()*lL);let a=r.clone().cross(i).setLength(i.length()),o=rL(t,2)*Math.PI*2,s=Math.sqrt(rL(t,3));return e.position.addScaledVector(i,Math.cos(o)*s).addScaledVector(a,Math.sin(o)*s),()=>e.position.copy(n)}function pL(e,t){if(t.isEmpty())return;let n=t.getCenter(new Z),r=t.getSize(new Z).length()*.5*1.2;if(r===0)return;e.shadow.normalBias=Math.min(oL,r*.0015);let i=e.shadow.camera;i.left=-r,i.right=r,i.top=r,i.bottom=-r;let a=e.position.clone().sub(e.target.position).normalize();e.target.position.copy(n),e.target.updateMatrixWorld();let o=r*2;e.position.copy(n).addScaledVector(a,o),e.updateMatrixWorld(),i.near=o-r,i.far=o+r,i.updateProjectionMatrix()}var mL={HUGE_THRESHOLD:1e4,LARGE_THRESHOLD:1e3,SCALE_RATIO_THRESHOLD:100,NEAR_PLANE_FACTOR:{TINY:1e-4,SMALL:.001,NORMAL:.01},FAR_PLANE_FACTOR:{HUGE:100,LARGE:50,NORMAL:20},INITIAL_DISTANCE_MULTIPLIER:4};function hL(e,t,n,r,i){if(SL(e,bL(t)),t.length===0)return;t.forEach(t=>{e.add(t),GI(t,e)});let a=AD(t),o=a.getCenter(new Z),s=a.getSize(new Z),c=Math.max(s.x,s.y,s.z);if(c/Math.min(s.x||1,s.y||1,s.z||1)>mL.SCALE_RATIO_THRESHOLD||c>mL.HUGE_THRESHOLD?(n.near=c*mL.NEAR_PLANE_FACTOR.TINY,n.far=c*mL.FAR_PLANE_FACTOR.HUGE):c>mL.LARGE_THRESHOLD?(n.near=c*mL.NEAR_PLANE_FACTOR.SMALL,n.far=c*mL.FAR_PLANE_FACTOR.LARGE):(n.near=Math.max(.01,c*mL.NEAR_PLANE_FACTOR.NORMAL),n.far=Math.max(2e3,c*mL.FAR_PLANE_FACTOR.NORMAL)),n.updateProjectionMatrix(),!i){let e=c*mL.INITIAL_DISTANCE_MULTIPLIER;n.position.copy(o).add(qI(n.up,e)),r.target.copy(o),r.update()}}var gL=new Set([`grid`,`floor`,`label-layer`,`measure`,uL]);function _L(e){return typeof e.userData.id==`string`&&gL.has(e.userData.id)}function vL(e){let t=e;for(;t;){if(_L(t))return!0;t=t.parent}return!1}function yL(e){e.updateMatrixWorld(!0);let t=new Xy;return e.traverse(e=>{let n=e;e.visible&&!vL(e)&&n.geometry&&t.expandByObject(e)}),t}function bL(e){let t=new Set;for(let n of e)n.traverse(e=>{let n=e.geometry,r=n&&ug(n);r&&t.add(r)});return t}var xL=new Set([`floor`,`grid`,`label-layer`,uL]);function SL(e,t=new Set){let n=[],r=[];for(let t of e.children)t.isLight===!0||xL.has(t.userData.id)||wI(t)?n.push(t):r.push(t);e.children.length=0;for(let t of n)e.children.push(t);for(let n of r)BD(n,{keepUploaded:t}),n.parent=null,n.dispatchEvent({type:`removed`}),e.dispatchEvent({type:`childremoved`,child:n})}function CL(e){let{up:t,forward:n,right:r}=KI(e),i=n.clone().negate(),a=r.clone();return{top:t.clone(),bottom:t.clone().negate(),front:i.clone(),back:i.clone().negate(),right:a.clone(),left:a.clone().negate(),iso:i.clone().multiplyScalar(1.2).add(a.clone()).add(t.clone()).normalize()}}function wL(e){let{scene:t,perspective:n,controls:r,onActiveCameraChange:i}=e,a=(e.up??n.up).clone().normalize(),o=CL(a),s=new bC(-1,1,1,-1,n.near,n.far);s.up.copy(a);let c=`perspective`,l=n.aspect,u=()=>c===`perspective`?n:s,d=null,f=()=>{d?.cancel(),d=null},p=()=>{let e=(c===`orthographic`?s:n).position.distanceTo(r.target)*Math.tan(n.fov*Math.PI/360),t=e*l;s.left=-t,s.right=t,s.top=e,s.bottom=-e,s.near=n.near,s.far=n.far,s.updateProjectionMatrix()},m=e=>{if(e!==c){if(f(),e===`orthographic`)s.position.copy(n.position),s.up.copy(n.up),s.lookAt(r.target),s.zoom=1,p();else{let e=(s.top-s.bottom)/(2*s.zoom)/Math.tan(n.fov*Math.PI/360),t=s.position.clone().sub(r.target);t.lengthSq()<1e-12&&t.copy(a),t.normalize(),n.position.copy(r.target).add(t.multiplyScalar(e))}c=e,r.object=u(),r.update(),i(u())}},h=(e,t,i,o)=>{let l=n.fov*(Math.PI/180),m=t/(2*Math.tan(l/2))*1.5,h=DL(i,a),g=e.clone().add(h.clone().multiplyScalar(m)),_=u();c===`orthographic`&&(s.zoom=1),f(),o?d=kL(_,r,g,e,()=>{c===`orthographic`&&p()}):(_.position.copy(g),r.target.copy(e),c===`orthographic`&&p(),r.update())},g=(e,n=!0)=>{let i=yL(t),a=i.isEmpty()?r.target.clone():i.getCenter(new Z),o=i.isEmpty()?new Z(1,1,1):i.getSize(new Z),s=Math.max(o.x,o.y,o.z)||1;h(a,s,e,n)},_=(e,t=!0)=>{if(e.isEmpty())return;let n=e.getCenter(new Z),i=e.getSize(new Z),a=Math.max(i.x,i.y,i.z)||1,s=u().position.clone().sub(r.target);s.lengthSq()<1e-12&&s.copy(o.iso),h(n,a,s.normalize(),t)},v=(e,t=!0)=>{g(o[e],t)};return{getActiveCamera:u,getProjection:()=>c,setProjection:m,toggleProjection:()=>(m(c===`perspective`?`orthographic`:`perspective`),c),setView:v,setViewDirection:g,getCameraView:()=>{let e=r.target,t=u().position.clone().sub(e);return t.lengthSq()<1e-12&&t.copy(o.iso),c===`orthographic`&&t.divideScalar(s.zoom),{direction:TL(t.clone().normalize()),position:TL(e.clone().add(t)),target:TL(e)}},setCameraView:(e,t=!1)=>{let n=EL(e.position),i=EL(e.target);if(n&&i&&n.distanceToSquared(i)>1e-12){f();let e=u();if(c===`orthographic`&&(s.zoom=1),t){d=kL(e,r,n,i,()=>{c===`orthographic`&&p()});return}e.position.copy(n),r.target.copy(i),c===`orthographic`&&p(),r.update();return}let a=EL(e.direction);a&&a.lengthSq()>1e-12?g(a.normalize(),t):v(`iso`,t)},frameBounds:_,setRotateEnabled:e=>{r.enableRotate=e},isRotateEnabled:()=>r.enableRotate,updateAspect:(e,t)=>{l=t===0?l:e/t,c===`orthographic`&&p()},dispose:f}}var TL=e=>[e.x,e.y,e.z].map(e=>Math.round(e*1e6)/1e6),EL=e=>e?.length===3&&e.every(Number.isFinite)?new Z(e[0],e[1],e[2]):void 0;function DL(e,t){let{up:n,forward:r}=KI(t),i=e.clone().normalize();if(Math.abs(i.dot(n))<.9999)return e;let a=r.clone().negate(),o=.5*Math.PI/180;return i.multiplyScalar(Math.cos(o)).add(a.multiplyScalar(Math.sin(o))).normalize()}var OL=e=>1-(1-e)**3;function kL(e,t,n,r,i,a=250){let o=e.position.clone(),s=t.target.clone(),c=performance.now(),l=null,u=()=>{l=null;let d=OL(Math.min((performance.now()-c)/a,1));e.position.lerpVectors(o,n,d),t.target.lerpVectors(s,r,d),i(),t.update(),d<1&&(l=requestAnimationFrame(u))};return l=requestAnimationFrame(u),{cancel:()=>{l!==null&&(cancelAnimationFrame(l),l=null)}}}var AL=.15,jL=4096;function ML(e){let t=Math.floor(e.length/6);if(t===0)return 1/0;let n=Math.max(1,Math.ceil(t/jL)),r=[];for(let i=0;i<t;i+=n){let t=i*6,n=Math.hypot(e[t+3]-e[t],e[t+4]-e[t+1],e[t+5]-e[t+2]);n>0&&r.push(n)}return r.length===0?1/0:(r.sort((e,t)=>e-t),r[Math.min(r.length-1,Math.floor(r.length*AL))])}function NL(e){let t=new WD;return t.setPositions(e),{geometry:t,segmentCount:e.length/6,edgeSpacing:ML(e)}}function PL(e,t,n){let r=1e4,i=Math.cos(Math.PI/180*n),a=e.length/3;if(a>=67108864)throw Error(`extractEdgeSegments: ${a} vertices exceeds 2^26 limit`);let o=new Float64Array(a),s=new Float64Array(a),c=new Float64Array(a);for(let t=0;t<a;t++)o[t]=Math.round(e[3*t]*r),s[t]=Math.round(e[3*t+1]*r),c[t]=Math.round(e[3*t+2]*r);let l=16;for(;l<a*2;)l<<=1;let u=l-1,d=new Int32Array(l).fill(-1),f=new Int32Array(a);for(let e=0;e<a;e++){let t=(Math.imul(o[e]|0,73856093)^Math.imul(s[e]|0,19349663)^Math.imul(c[e]|0,83492791))&u;for(;;){let n=d[t];if(n===-1){d[t]=e,f[e]=e;break}if(o[n]===o[e]&&s[n]===s[e]&&c[n]===c[e]){f[e]=n;break}t=t+1&u}}let p=new Float32Array(6144),m=0,h=new Uint32Array(1024),g=(t,n,r)=>{if(m+6>p.length){let e=new Float32Array(p.length*2);e.set(p),p=e;let t=new Uint32Array(p.length/6);t.set(h),h=t}h[m/6]=r,p[m++]=e[3*t],p[m++]=e[3*t+1],p[m++]=e[3*t+2],p[m++]=e[3*n],p[m++]=e[3*n+1],p[m++]=e[3*n+2]},_=(t?t.length:a)/3,v=new Int32Array(a+1);for(let e=0;e<_;e++){let n=f[t?t[3*e]:3*e],r=f[t?t[3*e+1]:3*e+1],i=f[t?t[3*e+2]:3*e+2];n!==r&&r!==i&&i!==n&&(v[n+1]++,v[r+1]++,v[i+1]++)}for(let e=0;e<a;e++)v[e+1]+=v[e];let y=new Int32Array(v[a]);{let e=v.slice(0,a);for(let n=0;n<_;n++){let r=f[t?t[3*n]:3*n],i=f[t?t[3*n+1]:3*n+1],a=f[t?t[3*n+2]:3*n+2];r!==i&&i!==a&&a!==r&&(y[e[r]++]=i,y[e[i]++]=a,y[e[a]++]=r)}}let b=new Int32Array(y.length).fill(-2),x=(e,t)=>{for(let n=v[e],r=v[e+1];n<r;n++)if(y[n]===t)return n;return-1},S=(e,n)=>t?t[3*e+n]:3*e+n,C=new Float64Array(3),w=t=>{let n=S(t,0),r=S(t,1),i=S(t,2),a=e[3*i]-e[3*r],o=e[3*i+1]-e[3*r+1],s=e[3*i+2]-e[3*r+2],c=e[3*n]-e[3*r],l=e[3*n+1]-e[3*r+1],u=e[3*n+2]-e[3*r+2],d=o*u-s*l,f=s*c-a*u,p=a*l-o*c,m=d*d+f*f+p*p;if(m>0){let e=1/Math.sqrt(m);d*=e,f*=e,p*=e}else d=0,f=0,p=0;C[0]=d,C[1]=f,C[2]=p},T=0,E=new Uint32Array(Math.max(16,y.length>>1)),D=new Int32Array(E.length),O=()=>{let e=new Uint32Array(E.length*2);e.set(E),E=e;let t=new Int32Array(e.length);t.set(D),D=t};for(let e=0;e<_;e++){let t=S(e,0),n=S(e,1),r=S(e,2),a=f[t],o=f[n],s=f[r];if(a===o||o===s||s===a)continue;let c=!1,l=0,u=0,d=0;for(let f=0;f<3;f++){let p=f===0?a:f===1?o:s,m=f===0?o:f===1?s:a,h=x(m,p),_=h===-1?-2:b[h];if(_>=0)c||=(w(e),l=C[0],u=C[1],d=C[2],!0),w(Math.floor(E[_]/3)),l*C[0]+u*C[1]+d*C[2]<=i&&g(f===0?t:f===1?n:r,f===0?n:f===1?r:t,e),b[h]=-1;else{let t=x(p,m);if(b[t]===-2){T===E.length&&O();let n=T++;b[t]=n,E[n]=3*e+f,D[n]=t}}}}for(let e=0;e<T;e++){if(b[D[e]]!==e)continue;let t=E[e],n=Math.floor(t/3),r=t-3*n;g(S(n,r),S(n,r===2?0:r+1),n)}return{segments:p.slice(0,m),faces:h.slice(0,m/6)}}function FL(){return[`const extract = ${PL.toString()};`,`self.onmessage = (event) => {`,` const { id, positions, index, thresholdAngle } = event.data;`,` try {`,` const { segments, faces } = extract(positions, index, thresholdAngle);`,` self.postMessage({ id, segments, faces }, [segments.buffer, faces.buffer]);`,` } catch (error) {`,` self.postMessage({ id, error: String((error && error.message) || error) });`,` }`,`};`].join(`
|
|
6048
|
+
`)}var IL=`edge-overlay`,LL=`triangle-cap`,RL=`overlay-budget`,zL=2236962,BL=1.5,VL=44,HL=.75,UL=8e6,WL=2e6,GL=1500;function KL(e){return{forcedColor:e.color==null?null:new Q(e.color),darken:Ov.clamp(e.darken??HL,0,1),width:e.width??BL,thresholdAngle:e.thresholdAngle??VL,distanceFade:e.distanceFade??!0,maxTriangles:e.maxTriangles??UL,maxSegments:e.maxSegments??WL,maxOverlays:e.maxOverlays??GL}}function qL(e){let t=e.getAttribute(`position`);return t?(e.index?e.index.count:t.count)/3:0}function JL(e){let t=e.getAttribute(`position`);if(!t||t.isInterleavedBufferAttribute||t.itemSize!==3||!(t.array instanceof Float32Array)||t.count>=67108864)return null;let n=e.index;return n&&!(n.array instanceof Uint32Array)&&!(n.array instanceof Uint16Array)?null:{positions:t.array,index:n?n.array:null,version:`${t.version}:${n?.version??0}`}}function YL(e,t){let n=4096,r=2166136261,i=e=>{r^=e,r=Math.imul(r,16777619)},a=new Uint32Array(e.positions.buffer,e.positions.byteOffset,e.positions.length),o=Math.min(n,a.length);for(let e=0;e<o;e++)i(a[e]);for(let e=Math.max(o,a.length-n);e<a.length;e++)i(a[e]);let s=0;if(e.index){s=e.index.length;let t=Math.min(n,s);for(let n=0;n<t;n++)i(e.index[n]);for(let r=Math.max(t,s-n);r<s;r++)i(e.index[r])}return`${t}:${e.positions.length}:${s}:${r>>>0}`}function XL(e,t){let n=new cS(e,t),r=n.attributes.position?n.attributes.position.array:new Float32Array;return n.dispose(),{segments:r,faces:null}}var ZL=new WeakMap,QL={};function $L(e,t){let n=ZL.get(e.positions)?.get(e.index??QL)?.get(t);return n?.version===e.version?n.edges:void 0}function eR(e,t,n){let r=ZL.get(e.positions);r||ZL.set(e.positions,r=new WeakMap);let i=r.get(e.index??QL);return i||r.set(e.index??QL,i=new Map),i.set(t,{version:e.version,edges:n}),n}function tR(e,t){let n=JL(e);return n?$L(n,t)??eR(n,t,PL(n.positions,n.index,t)):XL(e,t)}var nR,rR=new Map,iR=1;function aR(){if(nR!==void 0)return nR;if(typeof Worker>`u`||typeof Blob>`u`||typeof URL>`u`||typeof URL.createObjectURL!=`function`)return nR=null,null;try{let e=URL.createObjectURL(new Blob([FL()],{type:`text/javascript`})),t=new Worker(e);t.onmessage=e=>{let{id:t,segments:n,faces:r,error:i}=e.data,a=rR.get(t);a&&(rR.delete(t),n?a.resolve({segments:n,faces:r??null}):a.reject(Error(i??`edge extraction failed in worker`)))},t.onerror=()=>{for(let e of rR.values())e.reject(Error(`edge extraction worker crashed`));rR.clear(),t.terminate(),nR=null},nR=t}catch{nR=null}return nR}function oR(e,t,n){return new Promise((r,i)=>{let a=iR++;rR.set(a,{resolve:r,reject:i});let o=t.positions.slice(),s=t.index?t.index.slice():null,c=[o.buffer];s&&c.push(s.buffer),e.postMessage({id:a,positions:o,index:s,thresholdAngle:n},c)})}var sR=new Map;function cR(e,t){let n=JL(e);if(!n||qL(e)<25e3)return Promise.resolve(tR(e,t));let r=$L(n,t);if(r)return Promise.resolve(r);let i=YL(n,t),a=sR.get(i);if(a)return a;let o=aR();if(!o)return Promise.resolve(tR(e,t));let s=oR(o,n,t).catch(()=>PL(n.positions,n.index,t)).then(e=>eR(n,t,e)).finally(()=>{sR.delete(i)});return sR.set(i,s),s}function lR(e){let t=e.userData?.members;return Array.isArray(t)&&t.length>0?t:null}function uR(e){let t=lR(e.object);if(!t||e.faceIndex==null)return null;let n=e.faceIndex*3,r=0,i=t.length-1;for(;r<=i;){let e=r+i>>1,a=t[e];if(a.indexStart==null||a.indexCount==null)return null;if(n<a.indexStart)i=e-1;else if(n>=a.indexStart+a.indexCount)r=e+1;else return{member:a,index:e}}return null}function dR(e,t,n){let r=[];return e.traverse(e=>{let i=lR(e);if(i)i.forEach((i,a)=>{i.trackingKey===t&&(i.layer??``)===n&&r.push({object:e,memberIndex:a})});else{let i=e.userData;i?.trackingKey===t&&(i.layer??``)===n&&r.push({object:e,memberIndex:null})}}),r}function fR(e,t){let n=uR(t),r=n?n.member:t.object.userData,i={object:t.object,memberIndex:n?.index??null};if(typeof r?.trackingKey!=`string`||!r.trackingKey)return[i];let a=dR(e,r.trackingKey,r.layer??``);return a.length>1?a:[i]}function pR(e,t){let n=new Xy,r=e.geometry.getIndex(),i=e.geometry.getAttribute(`position`);if(!r||!i||t.indexStart==null||t.indexCount==null)return n;e.updateMatrixWorld();let a=new Z,o=Math.min(t.indexStart+t.indexCount,r.count);for(let s=t.indexStart;s<o;s++)a.fromBufferAttribute(i,r.getX(s)).applyMatrix4(e.matrixWorld),n.expandByPoint(a);return n}function mR(e,t,n,r){return hM(e,t,n,r),()=>gM(e,r)}function hR(e,t){let n=lR(e);if(!n)return null;let r=[];for(let e of n){if(e.indexStart==null)return null;r.push(e.indexStart)}let i=new Uint32Array(t.length);for(let e=0;e<t.length;e++){let n=t[e]*3,a=0,o=r.length-1;for(;a<o;){let e=a+o+1>>1;r[e]<=n?a=e:o=e-1}i[e]=a}return i}function gR(e,t,n){let r=0;for(let e=0;e<t.length;e++)n.has(t[e])||r++;let i=new Float32Array(r*6),a=0;for(let r=0;r<t.length;r++)n.has(t[r])||(i.set(e.subarray(r*6,r*6+6),a),a+=6);return i}function _R(e,t,n){let{segments:r,faces:i}=n;if(!i||!lR(t))return;let a,o=!1,s=()=>{let n=fM(t);if(n.size===0&&!o||(a??=hR(t,i),!a))return;let s=n.size===0?r:gR(r,a,n);e.geometry.dispose(),e.geometry=NL(s).geometry,o=n.size>0};s();let c=_M(t,s);e.addEventListener(`removed`,c)}function vR(e,t){let n=(Array.isArray(e.material)?e.material[0]:e.material)?.color;return n?n.clone().multiplyScalar(1-t):new Q(zL)}var yR=class{options;byKey=new Map;constructor(e){this.options=e}for(e,t){let n=this.options.forcedColor??vR(e,this.options.darken),r=n.getHex()*2+ +!!t,i=this.byKey.get(r);return i||(i=bR(n,this.options.width,t),this.byKey.set(r,i)),i}disposeUnused(e){let t=new Set(e.map(e=>e.material));for(let e of this.byKey.values())t.has(e)||e.dispose()}};function bR(e,t,n){let r=new GD({color:e});return r.linewidth=t,r.polygonOffset=!0,r.polygonOffsetFactor=0,r.polygonOffsetUnits=-1,n&&(r.transparent=!0),r}function xR(e,t,n){let r=new uO(e.geometry,t);return r.userData.kind=IL,r.raycast=()=>{},n&&TR(r,e.edgeSpacing),r}var SR=new Z,CR=new Z;function wR(e,t,n){e.geometry.boundingSphere||e.geometry.computeBoundingSphere();let r=e.geometry.boundingSphere;if(!r)return 1/0;if(t.isPerspectiveCamera){let i=t;SR.copy(r.center).applyMatrix4(e.matrixWorld);let a=CR.setFromMatrixPosition(t.matrixWorld).distanceTo(SR);if(a<=r.radius*e.matrixWorld.getMaxScaleOnAxis())return 1/0;let o=Math.tan(Ov.degToRad(i.fov)*.5),s=2*a*o;return s>0?n/s:1/0}if(t.isOrthographicCamera){let e=t,r=(e.top-e.bottom)/e.zoom;return r>0?n/r:1/0}return 1/0}function TR(e,t){e.onBeforeRender=(n,r,i)=>{uO.prototype.onBeforeRender.call(e,n);let a=e.material,o=t*wR(e,i,a.resolution.y);a.opacity=Ov.clamp((o-1)/3,0,1)}}function ER(e){return e.userData?.kind===IL}function DR(e,t){let n=[],r=0;e.traverse(e=>{e instanceof wx&&e.userData.id!==`floor`&&e.userData.id!==`grid`&&e.userData.kind!==`edge-overlay`&&(e.children.some(e=>e.userData?.kind===`edge-overlay`)?r++:e.geometry&&(qL(e.geometry)>t.maxTriangles?e.userData.edgesSkipped=LL:n.push(e)))});let i=Math.max(0,t.maxOverlays-r),a=n.slice(0,i);for(let e of a)delete e.userData.edgesSkipped;for(let e of n.slice(i))e.userData.edgesSkipped=RL;return n.length>i&&console.debug(`[edges] overlay budget reached: ${n.length} meshes want overlays, ${i} allowed — the rest fall back to the screen-space edge pass.`),a}function OR(e,t,n,r){let i=NL(t.segments),a=r.distanceFade&&i.segmentCount<=r.maxSegments,o=xR(i,n.for(e,a),a);return e.add(o),_R(o,e,t),o}var kR=new WeakMap;function AR(e){return kR.get(e)??0}function jR(e,t){for(let n=e;n;n=n.parent)if(n===t)return!0;return!1}async function MR(e,t={}){let n=KL(t),r=new yR(n),i=AR(e),a=[],o=DR(e,n).map(async t=>{let o=await cR(t.geometry,n.thresholdAngle);AR(e)===i&&jR(t,e)&&(t.children.some(e=>e.userData?.kind===`edge-overlay`)||a.push(OR(t,o,r,n)))});return await Promise.all(o),r.disposeUnused(a),a}function NR(e){kR.set(e,AR(e)+1);let t=[];e.traverse(e=>{e instanceof uO&&ER(e)&&t.push(e)});let n=new Set;for(let e of t)e.geometry.dispose(),n.add(e.material),e.removeFromParent();return n.forEach(e=>e.dispose()),t.length}function PR(e){if(!(e>0)||!Number.isFinite(e))return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(n>=5?5:n>=2?2:1)*t}var FR=`
|
|
6049
6049
|
varying vec3 vWorldPos;
|
|
6050
6050
|
void main() {
|
|
6051
6051
|
vec4 world = modelMatrix * vec4(position, 1.0);
|
|
6052
6052
|
vWorldPos = world.xyz;
|
|
6053
6053
|
gl_Position = projectionMatrix * viewMatrix * world;
|
|
6054
6054
|
}
|
|
6055
|
-
`,
|
|
6055
|
+
`,IR=`
|
|
6056
6056
|
precision highp float;
|
|
6057
6057
|
varying vec3 vWorldPos;
|
|
6058
6058
|
|
|
@@ -6096,7 +6096,7 @@ ${nj}`))})}function ij(e,t){let n=Math.min(1,t.transmission);if(e.userData[FD]=!
|
|
|
6096
6096
|
if (alpha < 0.001) discard;
|
|
6097
6097
|
gl_FragColor = vec4(color, alpha);
|
|
6098
6098
|
}
|
|
6099
|
-
`;function FR(e={}){let{cellSize:t=1,majorEvery:n=10,cellColor:r=8947848,majorColor:i=4473924,fadeDistance:a=100,plane:o=`y`}=e,s=o===`y`?new X(0,2):o===`z`?new X(0,1):new X(1,2),c=2.5,l=new lS(1,1);o===`y`?l.rotateX(-Math.PI/2):o===`x`&&l.rotateY(Math.PI/2);let u=new bS({vertexShader:NR,fragmentShader:PR,transparent:!0,depthWrite:!1,side:2,uniforms:{uAxes:{value:s},uCell:{value:t},uMajor:{value:n},uCellColor:{value:new Q(r)},uMajorColor:{value:new Q(i)},uCenter:{value:new Z},uFade:{value:a}}}),d=new wx(l,u);d.name=`grid`,d.userData.id=`grid`,d.renderOrder=-1;let f=a,p=a*c,m=new Z;return{object:d,update:e=>{o===`y`?(d.position.set(e.x,0,e.z),m.set(e.x,0,e.z)):o===`z`?(d.position.set(e.x,e.y,0),m.set(e.x,e.y,0)):(d.position.set(0,e.y,e.z),m.set(0,e.y,e.z)),u.uniforms.uCenter.value.copy(m),d.scale.setScalar(p)},fitToContent:e=>{if(e.isEmpty())return;let t=e.getSize(new Z),n=(e,t)=>t===0?e.x:t===1?e.y:e.z,r=Math.max(n(t,s.x),n(t,s.y));r>0&&Number.isFinite(r)&&(u.uniforms.uCell.value=MR(r/20),f=r*2,u.uniforms.uFade.value=f,p=f*c)},setVisible:e=>{d.visible=e},dispose:()=>{d.removeFromParent(),l.dispose(),u.dispose()}}}function IR(e,t){let n=new wM,r=n.domElement;r.style.position=`absolute`,r.style.top=`0`,r.style.left=`0`,r.style.overflow=`hidden`,r.style.pointerEvents=`none`,r.style.zIndex=`30`,getComputedStyle(e).position===`static`&&(e.style.position=`relative`),e.appendChild(r);let i={width:e.clientWidth||1,height:e.clientHeight||1};n.setSize(i.width,i.height);let a=new Dy;a.name=`label-layer`,a.userData.id=`label-layer`,t.add(a);let o=new Set;return{addLabel:(e,t,n)=>{let r=document.createElement(`div`);r.textContent=e,n?r.className=n:Object.assign(r.style,{padding:`2px 6px`,borderRadius:`4px`,background:`rgba(20, 20, 20, 0.78)`,color:`#fff`,font:`12px/1.3 system-ui, sans-serif`,whiteSpace:`pre`,textAlign:`center`,userSelect:`none`}),r.style.pointerEvents=`none`;let i=new vM(r);return i.position.copy(t),a.add(i),o.add(i),{object:i,setPosition:e=>i.position.copy(e),setText:e=>{r.textContent=e},remove:()=>{i.removeFromParent(),r.remove(),o.delete(i)}}},render:(e,t)=>n.render(e,t),setSize:(e,t)=>n.setSize(e,t),dispose:()=>{o.forEach(e=>{e.removeFromParent(),e.element.remove()}),o.clear(),a.removeFromParent(),r.remove()}}}var LR=new WeakMap;function RR(e){return e?.version??0}function zR(e){let t=e.attributes.position;if(!t||t.count===0)return null;let n=e.index,r=n??t,i=LR.get(r);if(i===null)return null;if(i&&i.position===t&&i.positionVersion===RR(t)&&i.indexVersion===RR(n))return i.bvh;let a=new Pb;a.setAttribute(`position`,t),n&&a.setIndex(n);try{let e=new yF(a,{indirect:!0});return LR.set(r,{position:t,positionVersion:RR(t),indexVersion:RR(n),bvh:e}),e}catch{return LR.set(r,null),null}}function BR(e){let t=e;return t.isMesh===!0&&!t.isInstancedMesh&&!t.isSkinnedMesh&&!t.isBatchedMesh&&!t.isLineSegments2&&!e.morphTargetInfluences?.length}function VR(e,t=[]){for(let n of e.children)!n.visible||_L(n)||wR(n)||(t.push(n),VR(n,t));return t}function HR(e){let{groups:t}=e.geometry;if(!Array.isArray(e.material)||t.length===0)return null;let n=e.material;return t.filter(e=>n[e.materialIndex??0]?.visible!==!1).map(e=>({start:e.start,end:e.start+e.count}))}var UR=new $v,WR=new dx,GR=new Eb;function KR(e,t,n){UR.copy(e.matrixWorld).invert(),WR.copy(n.ray).applyMatrix4(UR);let r=HR(e),i=null;if(!r)i=t.raycastFirst(WR,2);else for(let e of t.raycast(WR,2)){let t=(e.faceIndex??0)*3;r.some(e=>t>=e.start&&t<e.end)&&(!i||e.distance<i.distance)&&(i=e)}return!i||(i.point.applyMatrix4(e.matrixWorld),i.distance=i.point.distanceTo(n.ray.origin),i.object=e,i.distance<n.near||i.distance>n.far)?null:i}function qR(e,t){let n=[];for(let r of VR(e))if(r.layers.test(t.layers)){if(BR(r)){let{geometry:e}=r;if(e.boundingSphere||e.computeBoundingSphere(),!e.boundingSphere||(GR.copy(e.boundingSphere).applyMatrix4(r.matrixWorld),!t.ray.intersectsSphere(GR)))continue;let i=zR(e);if(i){let e=KR(r,i,t);e&&n.push(e);continue}}r.raycast(t,n)}return n.sort((e,t)=>e.distance-t.distance)}function JR(e){let t=VR(e).filter(BR),n=typeof requestIdleCallback==`function`?e=>requestIdleCallback(e,{timeout:500}):e=>setTimeout(e,16),r=typeof cancelIdleCallback==`function`?cancelIdleCallback:e=>clearTimeout(e),i=0,a=!1,o=()=>{if(a)return;let e=t.shift();e&&(zR(e.geometry),i=n(o))};return i=n(o),()=>{a=!0,r(i)}}var YR=12,XR=16763904,ZR=.015,QR=998,$R=999,ez=1e3,tz={Millimeters:{metersPerUnit:1/1e3,suffix:`mm`},Centimeters:{metersPerUnit:1/100,suffix:`cm`},Meters:{metersPerUnit:1,suffix:`m`},Inches:{metersPerUnit:1/39.37,suffix:`in`},Feet:{metersPerUnit:1/3.28084,suffix:`ft`}};function nz(e){let t=e&&tz[e]||tz.Meters;return e=>{let n=e/t.metersPerUnit,r=Math.abs(n),i=r===0?0:Math.min(6,Math.max(0,2-Math.floor(Math.log10(r))));return`${n.toFixed(i)} ${t.suffix}`}}function rz(e){return(t,n)=>{let r=t*1e-6,i=[`x`,`y`,`z`].filter(e=>n[e]>r);return i.length<2?e(t):`${e(t)}\n${i.map(t=>`Δ${t} ${e(n[t])}`).join(` `)}`}}function iz(e,t){if(e.isOrthographicCamera){let t=e;return Math.abs(t.top-t.bottom)/(t.zoom||1)*ZR}return((t?e.position.distanceTo(t):e.position.length())||1)*ZR}function az(e){let t=e.object,n=t.geometry;if(!n)return null;if(t.isLineSegments2){let t=n.attributes.instanceStart,r=n.attributes.instanceEnd,i=e.faceIndex;return!t||!r||i==null||i>=t.count?null:[new Z().fromBufferAttribute(t,i),new Z().fromBufferAttribute(r,i)]}let r=n.attributes.position;if(!r)return null;let i=e=>e.filter(e=>e<r.count).map(e=>new Z().fromBufferAttribute(r,e));if(t instanceof wx)return e.face?i([e.face.a,e.face.b,e.face.c]):null;if(t instanceof Yx)return e.index==null?null:i([e.index]);if(t instanceof Hx){if(e.index==null)return null;let t=n.index;return t?e.index+1>=t.count?null:i([t.getX(e.index),t.getX(e.index+1)]):i([e.index,e.index+1])}return null}function oz(e,t,n){let r=e.clone().project(t);return new X((r.x+1)/2*n.width,(1-r.y)/2*n.height)}function sz(e){return e.pointOnLine??e.point}function cz(e,t,n,r){let i=sz(e).clone(),a=az(e);if(!a)return{point:i,snapped:!1};let o=oz(i,t,n),s={point:i,snapped:!1},c=r;for(let r of a){let i=r.applyMatrix4(e.object.matrixWorld),a=oz(i,t,n).distanceTo(o);a<c&&(c=a,s={point:i,snapped:!0})}return s}function lz(e){let{canvas:t,scene:n,getActiveCamera:r,getViewTarget:i,labelLayer:a,options:o={}}=e,s=e.requestRender??(()=>{}),c=o.snapPixels??YR,l=new Q(o.color??XR),u=o.format??rz(nz(o.displayUnit)),d=new GC,f=new X,p=!1,m=null,h=[],g=new Wx({color:l,size:8,sizeAttenuation:!1,depthTest:!1}),_=new Wx({color:l,size:12,sizeAttenuation:!1,depthTest:!1}),v=new Wx({color:l,size:7,sizeAttenuation:!1,depthTest:!1,transparent:!0,opacity:.6}),y=(e,t)=>(e.renderOrder=t,e.userData.id=`measure`,e.raycast=()=>{},e.frustumCulled=!1,e),b=(...e)=>{let t=new Pb;t.setAttribute(`position`,new Sb(e.flatMap(e=>[e.x,e.y,e.z]),3));let r=y(new Yx(t,g),$R);return n.add(r),r},x=(e,t,r=1)=>{let i=new dO;i.setPositions([e.x,e.y,e.z,t.x,t.y,t.z]);let a=new GD({color:l,transparent:r<1,opacity:r});a.linewidth=2,a.depthTest=!1;let o=y(new fO(i,a),QR);return n.add(o),o},S=(e,t,n)=>{let r=e.geometry.attributes.instanceStart.data;r.array.set([t.x,t.y,t.z,n.x,n.y,n.z]),r.needsUpdate=!0},C=e=>{e.geometry.dispose(),e.material.dispose(),e.removeFromParent()},w=e=>{e.geometry.dispose(),e.removeFromParent()},T=(e,t)=>{let n=new Z(Math.abs(t.x-e.x),Math.abs(t.y-e.y),Math.abs(t.z-e.z));return u(e.distanceTo(t),n)},E=(e,t)=>e.clone().add(t).multiplyScalar(.5),D=null,O=null,k=null,A=()=>{D&&(D.visible=!1),O&&(O.visible=!1),k?.remove(),k=null},j=e=>{if(!e){A();return}if(D||(D=b(new Z),D.renderOrder=ez),D.material=e.snapped?_:v,D.position.copy(e.point),D.visible=!0,!m){O&&(O.visible=!1),k?.remove(),k=null;return}O||=x(m.point,e.point,.7),S(O,m.point,e.point),O.visible=!0;let t=T(m.point,e.point),n=E(m.point,e.point);k?(k.setText(t),k.setPosition(n)):k=a.addLabel(t,n,o.labelClassName)},M=e=>{let a=t.getBoundingClientRect(),o=e.clientX-a.left,s=e.clientY-a.top;f.x=o/a.width*2-1,f.y=-(s/a.height)*2+1;let l=r();d.setFromCamera(f,l);let u=iz(l,i?.())*2;d.params.Line.threshold=u,d.params.Points.threshold=u,d.params.Line2={threshold:c/2};let p={width:a.width,height:a.height},m=new X(o,s);for(let e of qR(n,d))if(!(!(e.object.isMesh&&e.face!=null)&&oz(sz(e),l,p).distanceTo(m)>c))return cz(e,l,p,c);return null},N=null,P=0,ee=()=>{P&&=(cancelAnimationFrame(P),0),N=null},te=e=>{p&&(N=e,!P&&(P=requestAnimationFrame(()=>{P=0;let e=N;N=null,p&&e&&(j(M(e)),s())})))},ne=()=>{ee(),A(),s()},re=()=>{m&&=(w(m.marker),null)},ie=()=>{re();for(let e of h)w(e.markers),C(e.line),e.label.remove();h.length=0,A(),s()},ae=()=>{m?(re(),A(),s()):ie()},oe=e=>{if(!p)return!1;ee();let t=M(e);if(!t)return!0;if(!m)m={point:t.point,marker:b(t.point)};else if(!t.point.equals(m.point)){let e=m.point,n=t.point;re(),h.push({markers:b(e,n),line:x(e,n),label:a.addLabel(T(e,n),E(e,n),o.labelClassName)})}return j(t),s(),!0},se=e=>{e.key===`Escape`&&(e.target?.closest?.(`input, textarea, select, [contenteditable]`)||ae())},ce=``,le=null,ue=e=>{e!==p&&(p=e,e?(ce=t.style.cursor,t.style.cursor=`crosshair`,t.addEventListener(`mouseleave`,ne),window.addEventListener(`keydown`,se),le=JR(n)):(t.style.cursor=ce,t.removeEventListener(`mouseleave`,ne),window.removeEventListener(`keydown`,se),le?.(),le=null,ee(),ie()))};return{setEnabled:ue,isEnabled:()=>p,handleClick:oe,handleMove:te,cancel:ae,clear:ie,dispose:()=>{ue(!1),ie(),D&&w(D),O&&C(O),D=null,O=null,g.dispose(),_.dispose(),v.dispose()}}}var uz=.5,dz=.01,fz=.05,pz=256,mz=[];function hz({camera:e,scene:t,groundNormals:n=()=>mz}){let r=e.near,i=e.near,a=gz();return{update:()=>{e.near!==i&&(r=e.near);let o=a.measure(t,e),s=r;if(o!==null){let t=o;for(let r of n())t=Math.min(t,Math.abs(e.position.dot(r)));s=Ov.clamp(t*uz,r,e.far*dz)}Math.abs(s-i)>i*fz&&(e.near=s,e.updateProjectionMatrix(),i=s)}}}function gz(){let e=new WeakMap,t=new jx,n=new $v,r=new Z,i=new Xy,a=new Float64Array(20),o=new Float64Array(20),s=new Float32Array(6),c=new Float64Array(21),l=new Float64Array(21),u=1/0,d=!1,f=(t,n)=>{let r=n.getAttribute(`position`),i=n.getIndex(),a=e.get(n);if(a&&a.position===r&&a.positionVersion===vz(r)&&a.index===i&&a.indexVersion===(i?.version??-1))return a;let o={...bz(r,i,yz(t)),position:r,positionVersion:vz(r),index:i,indexVersion:i?.version??-1};return e.set(n,o),o},p=(e,t,n)=>{let{position:r,index:i}=e,a=i?.array,o=1/0;for(let i=e.ranges[t*2];i<e.ranges[t*2+1];i++){for(let e=0;e<3;e++){let t=a?a[i*3+e]:i*3+e;c[e*3]=r.getX(t),c[e*3+1]=r.getY(t),c[e*3+2]=r.getZ(t)}let e=3;for(let t=0;t<16&&e>0;t+=4){let r=n[t],i=n[t+1],a=n[t+2],o=n[t+3],s=0;for(let t=0;t<e;t++){let n=(t+1)%e,u=c[t*3],d=c[t*3+1],f=c[t*3+2],p=c[n*3],m=c[n*3+1],h=c[n*3+2],g=r*u+i*d+a*f+o,_=r*p+i*m+a*h+o;if(g>=0&&(l[s*3]=u,l[s*3+1]=d,l[s*3+2]=f,s++),g>=0!=_>=0){let e=g/(g-_);l[s*3]=u+(p-u)*e,l[s*3+1]=d+(m-d)*e,l[s*3+2]=f+(h-f)*e,s++}}[c,l]=[l,c],e=s}for(let t=0;t<e;t++){let e=n[16]*c[t*3]+n[17]*c[t*3+1]+n[18]*c[t*3+2]+n[19];e<o&&(o=e)}}return o},m=e=>{let t=e.elements;for(let e=0;e<20;e+=4){let n=a[e],r=a[e+1],i=a[e+2];o[e]=t[0]*n+t[1]*r+t[2]*i,o[e+1]=t[4]*n+t[5]*r+t[6]*i,o[e+2]=t[8]*n+t[9]*r+t[10]*i,o[e+3]=n*t[12]+r*t[13]+i*t[14]+a[e+3]}return o},h=(e,t,n)=>{outer:for(let r=0;r<e.length;r+=6){let i=e[r],a=e[r+1],o=e[r+2],s=e[r+3],c=e[r+4],l=e[r+5];for(let e=0;e<16;e+=4){let n=t[e],r=t[e+1],u=t[e+2];if(n*(n>0?s:i)+r*(r>0?c:a)+u*(u>0?l:o)+t[e+3]<0)continue outer}let d=t[16],f=t[17],m=t[18],h=d*(d>0?i:s)+f*(f>0?a:c)+m*(m>0?o:l)+t[19];h>=u||(u=n?Math.min(u,p(n,r/6,t)):h)}},g=e=>{let t=e.geometry;if(!t?.getAttribute?.(`position`))return;if(d=!0,_z(e)){let n=f(e,t);h(n.boxes,m(e.matrixWorld),n);return}let n=e;n.isInstancedMesh?(n.boundingBox||n.computeBoundingBox(),i.copy(n.boundingBox)):(t.boundingBox||t.computeBoundingBox(),i.copy(t.boundingBox)),!i.isEmpty()&&(s[0]=i.min.x,s[1]=i.min.y,s[2]=i.min.z,s[3]=i.max.x,s[4]=i.max.y,s[5]=i.max.z,h(s,m(e.matrixWorld)))},_=e=>{if(e.visible&&!_L(e)&&e.userData.kind!==`edge-overlay`){g(e);for(let t of e.children)_(t)}};return{measure:(e,i)=>{e.updateMatrixWorld(),i.updateMatrixWorld(),n.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),t.setFromProjectionMatrix(n);for(let e=0;e<4;e++){let n=t.planes[e];a[e*4]=n.normal.x,a[e*4+1]=n.normal.y,a[e*4+2]=n.normal.z,a[e*4+3]=n.constant}i.getWorldDirection(r),a[16]=r.x,a[17]=r.y,a[18]=r.z,a[19]=-r.dot(i.position),u=1/0,d=!1;for(let t of e.children)_(t);return d?u:null}}}function _z(e){let t=e;if(!t.isMesh||t.isInstancedMesh||t.isSkinnedMesh)return!1;let n=t.geometry;return!n.isInstancedBufferGeometry&&Object.keys(n.morphAttributes).length===0}function vz(e){return e.isInterleavedBufferAttribute?e.data.version:e.version}function yz(e){let t=[];for(let n of sR(e)??[])n.indexStart!==void 0&&t.push(n.indexStart/3);return t.sort((e,t)=>e-t)}function bz(e,t,n){let r=Math.floor((t?t.count:e.count)/3),i=[],a=0;for(let e=0;e<r;){for(;a<n.length&&n[a]<=e;)a++;let t=Math.min(r,e+pz,n[a]??r);i.push(e,t),e=t}let o=i.length/2,s=new Float32Array(o*6),c=!e.isInterleavedBufferAttribute,l=e.array,u=c&&e.itemSize===3&&!e.normalized,d=t?.array;for(let t=0;t<o;t++){let n=1/0,r=1/0,a=1/0,o=-1/0,c=-1/0,f=-1/0,p=i[t*2+1]*3;for(let s=i[t*2]*3;s<p;s++){let t=d?d[s]:s,i=u?l[t*3]:e.getX(t),p=u?l[t*3+1]:e.getY(t),m=u?l[t*3+2]:e.getZ(t);i<n&&(n=i),p<r&&(r=p),m<a&&(a=m),i>o&&(o=i),p>c&&(c=p),m>f&&(f=m)}let m=t*6;s[m]=n,s[m+1]=r,s[m+2]=a,s[m+3]=o,s[m+4]=c,s[m+5]=f}return{boxes:s,ranges:Uint32Array.from(i)}}function xz(){let e=[],t=null,n=()=>e.sort((e,t)=>t.priority-e.priority),r=t=>e.findIndex(e=>e.id===t),i=n=>{let i=r(n);i!==-1&&(e.splice(i,1),t===n&&(t=null))};return{register:({id:t,tool:r,priority:a=0})=>(i(t),e.push({id:t,tool:r,priority:a}),n(),()=>i(t)),unregister:i,get:t=>e[r(t)]?.tool??null,setActive:n=>{t=n;for(let t of e)t.tool.setEnabled?.(t.id===n)},getActive:()=>t,handleClick:t=>{for(let n of[...e])if(n.tool.handleClick(t))return!0;return!1},handleMove:t=>{for(let n of[...e])n.tool.handleMove?.(t)}}}function Sz(e){let{camera:t,domElement:n,controller:r}=e,i=new bF(t,n);i.setLabels(`X`,`Y`,`Z`);let a=!0,o=new GC,s=new bC(-2,2,2,-2,0,4);s.position.set(0,0,2),s.updateMatrixWorld();let c={posX:new Z(1,0,0),negX:new Z(-1,0,0),posY:new Z(0,1,0),negY:new Z(0,-1,0),posZ:new Z(0,0,1),negZ:new Z(0,0,-1)},l=e=>{let r=n.getBoundingClientRect(),a=r.left+n.offsetWidth-128-i.location.right,l=r.top+n.offsetHeight-128-i.location.bottom,u=new X((e.clientX-a)/128*2-1,-((e.clientY-l)/128)*2+1);if(Math.abs(u.x)>1||Math.abs(u.y)>1)return null;i.quaternion.copy(t.quaternion).invert(),i.updateMatrixWorld(),o.setFromCamera(u,s);let d=o.intersectObjects(i.children,!1);for(let e of d){let t=e.object.userData?.type;if(typeof t==`string`&&t in c)return t}return null};return{render:e=>{if(!a)return;let t=e.autoClear;e.autoClear=!1,i.render(e),e.autoClear=t},handleClick:e=>{if(!a)return!1;let t=l(e);return t?(r.getProjection()===`orthographic`&&r.setProjection(`perspective`),r.setViewDirection(c[t],!1),!0):!1},setVisible:e=>{a=e},isVisible:()=>a,dispose:()=>i.dispose()}}function Cz(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m=!0,h){let g=null,_=performance.now(),v=!0,y=0,b=new $v,x=new $v,S=null,C=()=>{v=!0},w=e=>{e.updateMatrixWorld();let t=S!==e||!b.equals(e.matrixWorld)||!x.equals(e.projectionMatrix);return t&&(S=e,b.copy(e.matrixWorld),x.copy(e.projectionMatrix)),t},T=e.domElement,E=[`pointerdown`,`pointerup`,`wheel`];if(m)for(let e of E)T.addEventListener(e,C,{passive:!0});let D=()=>{let{width:t,height:r}=o();if(t===0||r===0)return;let a=s(),c=Math.floor(t*a),l=Math.floor(r*a);(e.domElement.width!==c||e.domElement.height!==l)&&(e.setPixelRatio(a),e.setSize(t,r,!1),n.aspect=t/r,n.updateProjectionMatrix(),i.updateAspect(t,r),d?.()?.setSize(t,r,a),f?.setSize(t,r),C())},O=n=>{f&&f.render(t,n),u&&u.render(e)},k=(n,r)=>{let i=d?.();i?(i.setCamera(n),i.render(r)):e.render(t,n),O(n)},A=()=>{let e=r();h?.present()?O(e):k(e,0)},j=function(){g=requestAnimationFrame(j);let e=performance.now(),t=(e-_)/1e3;_=e,D(),(a.enableDamping||a.autoRotate)&&a.update(),l&&l.update(r().position),p&&p.update(),c?.(t);let n=r();if(m){let r=w(n);r&&h?.moving(t*1e3);let i=v||r;if(!i&&h?.wants(e)){h.step(n),O(n);return}let a=e-y>=500;if(!i&&!a||(y=e,!i&&h?.isHolding()))return;v=!1,h?.reset(e)}k(n,t)};return{animate:j,dispose:()=>{if(g!==null&&(cancelAnimationFrame(g),g=null),m)for(let e of E)T.removeEventListener(e,C)},invalidate:C,renderNow:A}}var wz=3,Tz=2,Ez=1024,Dz=1/3,Oz=.05,kz=160/(4*Math.PI)*.005,Az=.07,jz=7,Mz=.15;function Nz(e){let t=pM(e);return t?.userData.selvaEmissive?t:null}function Pz(e){let t=sR(e);if(!t)return[new Xy().setFromObject(e)];let n=fM(e);return t.filter((e,t)=>!n.has(t)).map(t=>dR(e,t)).filter(e=>!e.isEmpty())}function Fz(e,t){let n=e=>e.getSize(new Z).length(),r=Math.max(n(e),n(t))*Oz;return e.clone().expandByScalar(r).intersectsBox(t)}function Iz(e,t){let n=[];for(let r of e){let i={bounds:r.bounds.clone(),meshes:new Set([r.mesh])},a=[];for(let e of n)if(Fz(e.bounds,r.bounds)){i.bounds.union(e.bounds);for(let t of e.meshes)i.meshes.add(t)}else a.push(e);if(n=[...a,i],n.length>t){let t=new Xy;for(let n of e)t.union(n.bounds);return[{bounds:t,meshes:new Set(e.map(e=>e.mesh))}]}}return n}function Lz(e,t){let n=new Map;for(let t of e){let{emissive:e,emissiveIntensity:r,userData:i}=t.material,a=`${e.getHexString()}|${r}|${i[wD]}`,o=n.get(a);o?o.push(t):n.set(a,[t])}return[...n.values()].flatMap(e=>{let{emissive:n,emissiveIntensity:r,userData:i}=e[0].material;return Iz(e,t).map(e=>({...e,color:n,strength:r,light:i[wD]}))})}function Rz(e,t=wz){let n=Math.max(0,...e.map(e=>e.strength));return e.filter(e=>e.strength>=n*Dz).sort((e,t)=>t.strength-e.strength).slice(0,t)}function zz(e){let t=[],n=new Set,r=new Z,i=n=>{let r=new yC(16777215,1,0,2),i=new yC(16777215,1,0,1);n&&(r.castShadow=!0,r.shadow.mapSize.setScalar(Ez),r.shadow.radius=jz,r.shadow.autoUpdate=!1);let a={key:r,bounce:i,home:new Z,size:new Z};return t.push(a),e.add(r,i),a},a=()=>{let t=new Xy,n=[];return e.traverseVisible(e=>{let r=e;if(!r.isMesh||e.userData.source!==`compute`)return;t.union(new Xy().setFromObject(r));let i=Nz(r);if(i)for(let e of Pz(r))n.push({mesh:r,material:i,bounds:e})}),{parts:n,radius:t.getSize(new Z).length()/2}},o=(e,r)=>{for(let{mesh:i,bounds:a}of e)r.some((e,n)=>e.meshes.has(i)||a.containsPoint(t[n].key.position))&&i.castShadow&&(i.castShadow=!1,n.add(i))},s=(r,s=wz,c=1)=>{for(let e of n)e.castShadow=!0;n.clear();let{parts:l,radius:u}=r?a():{parts:[],radius:0},d=Rz(Lz(l,s),s);for(d.forEach((e,n)=>{let{key:r,bounce:a,home:o,size:s}=t[n]??i(n<Tz),l=(e.light??e.strength*kz)*c;r.color.copy(e.color);let d=e.bounds.getSize(new Z).length()/2/u;r.intensity=!e.light&&d>Mz?0:l,e.bounds.getCenter(r.position),o.copy(r.position),e.bounds.getSize(s),a.color.copy(e.color),a.intensity=l*Az/u,a.position.copy(r.position),r.castShadow&&(r.shadow.camera.near=u*.005,r.shadow.camera.far=u*4,r.shadow.camera.updateProjectionMatrix(),r.shadow.bias=-.002,r.shadow.normalBias=u*.002,r.shadow.needsUpdate=!0)});t.length>d.length;){let{key:n,bounce:r}=t.pop();e.remove(n,r),n.dispose(),r.dispose()}o(l,d)},c=e=>{for(let{key:n,home:r,size:i}of t)n.position.copy(e(r,i)),n.castShadow&&(n.shadow.needsUpdate=!0)};return{sync:s,jitter:e=>c((t,n)=>r.set(rL(e,2)-.5,rL(e,3)-.5,rL(e,5)-.5).multiply(n).add(t)),settle:()=>c(e=>e),dispose:()=>s(!1)}}var Bz=`__selvaLookBaseline`;function Vz(e,t){e.color?.setHex(t.color),e.metalness!==void 0&&(e.metalness=t.metalness),e.roughness!==void 0&&(e.roughness=t.roughness),e.emissiveIntensity!==void 0&&(e.emissiveIntensity=t.emissiveIntensity),e.opacity=t.opacity,e.transparent=t.transparent,e.depthWrite=t.depthWrite,e.wireframe!==void 0&&(e.wireframe=t.wireframe),e.side=t.side}function Hz(e){let t=e[Bz];t&&(Vz(e,t),delete e[Bz])}function Uz(e,t){let n=e;t?(n[Bz]?Vz(n,n[Bz]):n[Bz]={color:n.color?.getHex()??16777215,metalness:n.metalness??0,roughness:n.roughness??1,emissiveIntensity:n.emissiveIntensity??0,opacity:n.opacity,transparent:n.transparent,depthWrite:n.depthWrite,wireframe:n.wireframe??!1,side:n.side},t.color!==void 0&&n.color?.setHex(t.color),t.metalness!==void 0&&n.metalness!==void 0&&(n.metalness=t.metalness),t.roughness!==void 0&&n.roughness!==void 0&&(n.roughness=t.roughness),t.emissiveIntensity!==void 0&&n.userData.selvaEmissive&&(n.emissiveIntensity=t.emissiveIntensity),t.opacity!==void 0&&(n.opacity=t.opacity,n.transparent=t.opacity<1),t.depthWrite!==void 0&&(n.depthWrite=t.depthWrite),t.wireframe!==void 0&&n.wireframe!==void 0&&(n.wireframe=t.wireframe),t.side!==void 0&&(n.side=t.side),n.needsUpdate=!0):(Hz(n),n.needsUpdate=!0)}function Wz(e,t){if(t.materialOverride)return t.envMapIntensity;let n=e.userData[TD];if(n!=null)return n;let r=e,i=r[Bz]?.metalness??r.metalness??0;return ED(t.envMapIntensity,i,t.metalReflection)}function Gz(e,t){return Math.min(e,t.maxPixelRatio??e)}function Kz(e){let{scene:t,renderer:n,lights:r,config:i,pipeline:a,fullPixelRatio:o,requestRender:s}=e,c=e=>SD(e,i.render.lowPower),l=i.look,u=zz(t),d=n.shadowMap.type,f=e=>{let t=e.emissiveLights?1:d;n.shadowMap.type!==t&&(n.shadowMap.type=t,n.shadowMap.needsUpdate=!0)},p,m=e=>{e.background===void 0?(p!==void 0&&(t.background=p),p=void 0):(p??=t.background,t.background=new Q(e.background))};m(c(l)),f(c(l));let h=e=>{e.ambientIntensity!==void 0&&(r.ambient.intensity=e.ambientIntensity),e.hemisphereIntensity!==void 0&&!r.hemisphere&&e.hemisphereIntensity>0&&(r.hemisphere=new aC(e.hemisphereSkyColor??i.lighting.hemisphereSkyColor,e.hemisphereGroundColor??i.lighting.hemisphereGroundColor,e.hemisphereIntensity),r.hemisphere.position.copy(i.environment.sceneUp??ZI),t.add(r.hemisphere)),r.hemisphere&&(e.hemisphereIntensity!==void 0&&(r.hemisphere.intensity=e.hemisphereIntensity),e.hemisphereSkyColor!==void 0&&r.hemisphere.color.set(e.hemisphereSkyColor),e.hemisphereGroundColor!==void 0&&r.hemisphere.groundColor.set(e.hemisphereGroundColor)),s()},g=e=>{i.environment.environmentIntensity=e,t.environmentIntensity=e,s()},_=e=>{i.render.toneMappingExposure=e,n.toneMappingExposure=e,a.get()&&a.rebuild()},v=e=>{i.render.aoIntensity=e,a.get()&&a.rebuild()},y=()=>{let{emissiveLights:e,maxEmissiveLights:t,emissiveLightScale:n}=c(l);u.sync(!!e,t,n),s()};return{setFillLights:h,setEnvironmentIntensity:g,setToneMappingExposure:_,setAoIntensity:v,setLook:(e,s)=>{let u=c(e);l=e,n.toneMapping=u.toneMapping,n.toneMappingExposure=u.toneMappingExposure,i.render.toneMapping=u.toneMapping,i.render.toneMappingExposure=u.toneMappingExposure,h({hemisphereIntensity:u.hemisphereIntensity,ambientIntensity:u.ambientIntensity}),g(u.environmentIntensity),r.sun&&(r.sun.intensity=u.sunlightIntensity,i.lighting.sunlightIntensity=u.sunlightIntensity),m(u),f(u),i.render.bloom=u.bloom,i.render.pixelRatio=Gz(o,u),a.setAmbientOcclusion(u.ambientOcclusion),t.traverse(e=>{if(e.userData.source!==`compute`)return;let t=e,n=Array.isArray(t.material)?t.material:t.material?[t.material]:[];for(let e of n)`envMapIntensity`in e&&(e.envMapIntensity=Wz(e,u)),Uz(e,u.materialOverride)}),GI(t,t),s?.deferEmissiveLights||y()},syncEmissiveLights:y,jitterEmissiveLights:u.jitter,settleEmissiveLights:u.settle,getMaterialAppearance:()=>DD(l)}}function qz(e,t){let n=t.parentElement,r=n?n.clientWidth:window.innerWidth,i=n?n.clientHeight:window.innerHeight,a=new _C(e.camera.fov,r/i,e.camera.near,e.camera.far),o=e.camera.position;return o&&a.position.set(o.x,o.y,o.z),a}function Jz(e){let t=new Fy;return t.background=(typeof e.environment.backgroundColor==`string`?new Q(e.environment.backgroundColor):e.environment.backgroundColor)||null,t}function Yz(e,t){BD(e,t),e.environment?.dispose(),WI(e),e.background instanceof qv&&e.background.dispose()}var Xz={uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},uResolution:{value:new X(1,1)},uColor:{value:new Q(2236962)},uOpacity:{value:1},uNormalThreshold:{value:.4},uDepthThreshold:{value:.02},uThickness:{value:1},uNear:{value:.1},uFar:{value:1e3},uPerspective:{value:1}},vertexShader:`
|
|
6099
|
+
`;function LR(e={}){let{cellSize:t=1,majorEvery:n=10,cellColor:r=8947848,majorColor:i=4473924,fadeDistance:a=100,plane:o=`y`}=e,s=o===`y`?new X(0,2):o===`z`?new X(0,1):new X(1,2),c=2.5,l=new lS(1,1);o===`y`?l.rotateX(-Math.PI/2):o===`x`&&l.rotateY(Math.PI/2);let u=new bS({vertexShader:FR,fragmentShader:IR,transparent:!0,depthWrite:!1,side:2,uniforms:{uAxes:{value:s},uCell:{value:t},uMajor:{value:n},uCellColor:{value:new Q(r)},uMajorColor:{value:new Q(i)},uCenter:{value:new Z},uFade:{value:a}}}),d=new wx(l,u);d.name=`grid`,d.userData.id=`grid`,d.renderOrder=-1;let f=a,p=a*c,m=new Z;return{object:d,update:e=>{o===`y`?(d.position.set(e.x,0,e.z),m.set(e.x,0,e.z)):o===`z`?(d.position.set(e.x,e.y,0),m.set(e.x,e.y,0)):(d.position.set(0,e.y,e.z),m.set(0,e.y,e.z)),u.uniforms.uCenter.value.copy(m),d.scale.setScalar(p)},fitToContent:e=>{if(e.isEmpty())return;let t=e.getSize(new Z),n=(e,t)=>t===0?e.x:t===1?e.y:e.z,r=Math.max(n(t,s.x),n(t,s.y));r>0&&Number.isFinite(r)&&(u.uniforms.uCell.value=PR(r/20),f=r*2,u.uniforms.uFade.value=f,p=f*c)},setVisible:e=>{d.visible=e},dispose:()=>{d.removeFromParent(),l.dispose(),u.dispose()}}}function RR(e,t){let n=new wM,r=n.domElement;r.style.position=`absolute`,r.style.top=`0`,r.style.left=`0`,r.style.overflow=`hidden`,r.style.pointerEvents=`none`,r.style.zIndex=`30`,getComputedStyle(e).position===`static`&&(e.style.position=`relative`),e.appendChild(r);let i={width:e.clientWidth||1,height:e.clientHeight||1};n.setSize(i.width,i.height);let a=new Dy;a.name=`label-layer`,a.userData.id=`label-layer`,t.add(a);let o=new Set;return{addLabel:(e,t,n)=>{let r=document.createElement(`div`);r.textContent=e,n?r.className=n:Object.assign(r.style,{padding:`2px 6px`,borderRadius:`4px`,background:`rgba(20, 20, 20, 0.78)`,color:`#fff`,font:`12px/1.3 system-ui, sans-serif`,whiteSpace:`pre`,textAlign:`center`,userSelect:`none`}),r.style.pointerEvents=`none`;let i=new vM(r);return i.position.copy(t),a.add(i),o.add(i),{object:i,setPosition:e=>i.position.copy(e),setText:e=>{r.textContent=e},remove:()=>{i.removeFromParent(),r.remove(),o.delete(i)}}},render:(e,t)=>n.render(e,t),setSize:(e,t)=>n.setSize(e,t),dispose:()=>{o.forEach(e=>{e.removeFromParent(),e.element.remove()}),o.clear(),a.removeFromParent(),r.remove()}}}var zR=new WeakMap;function BR(e){return e?.version??0}function VR(e){let t=e.attributes.position;if(!t||t.count===0)return null;let n=e.index,r=n??t,i=zR.get(r);if(i===null)return null;if(i&&i.position===t&&i.positionVersion===BR(t)&&i.indexVersion===BR(n))return i.bvh;let a=new Pb;a.setAttribute(`position`,t),n&&a.setIndex(n);try{let e=new yF(a,{indirect:!0});return zR.set(r,{position:t,positionVersion:BR(t),indexVersion:BR(n),bvh:e}),e}catch{return zR.set(r,null),null}}function HR(e){let t=e;return t.isMesh===!0&&!t.isInstancedMesh&&!t.isSkinnedMesh&&!t.isBatchedMesh&&!t.isLineSegments2&&!e.morphTargetInfluences?.length}function UR(e,t=[]){for(let n of e.children)!n.visible||_L(n)||ER(n)||(t.push(n),UR(n,t));return t}function WR(e){let{groups:t}=e.geometry;if(!Array.isArray(e.material)||t.length===0)return null;let n=e.material;return t.filter(e=>n[e.materialIndex??0]?.visible!==!1).map(e=>({start:e.start,end:e.start+e.count}))}var GR=new $v,KR=new dx,qR=new Eb;function JR(e,t,n){GR.copy(e.matrixWorld).invert(),KR.copy(n.ray).applyMatrix4(GR);let r=WR(e),i=null;if(!r)i=t.raycastFirst(KR,2);else for(let e of t.raycast(KR,2)){let t=(e.faceIndex??0)*3;r.some(e=>t>=e.start&&t<e.end)&&(!i||e.distance<i.distance)&&(i=e)}return!i||(i.point.applyMatrix4(e.matrixWorld),i.distance=i.point.distanceTo(n.ray.origin),i.object=e,i.distance<n.near||i.distance>n.far)?null:i}function YR(e,t){let n=[];for(let r of UR(e))if(r.layers.test(t.layers)){if(HR(r)){let{geometry:e}=r;if(e.boundingSphere||e.computeBoundingSphere(),!e.boundingSphere||(qR.copy(e.boundingSphere).applyMatrix4(r.matrixWorld),!t.ray.intersectsSphere(qR)))continue;let i=VR(e);if(i){let e=JR(r,i,t);e&&n.push(e);continue}}r.raycast(t,n)}return n.sort((e,t)=>e.distance-t.distance)}function XR(e){let t=UR(e).filter(HR),n=typeof requestIdleCallback==`function`?e=>requestIdleCallback(e,{timeout:500}):e=>setTimeout(e,16),r=typeof cancelIdleCallback==`function`?cancelIdleCallback:e=>clearTimeout(e),i=0,a=!1,o=()=>{if(a)return;let e=t.shift();e&&(VR(e.geometry),i=n(o))};return i=n(o),()=>{a=!0,r(i)}}var ZR=12,QR=16763904,$R=.015,ez=998,tz=999,nz=1e3,rz={Millimeters:{metersPerUnit:1/1e3,suffix:`mm`},Centimeters:{metersPerUnit:1/100,suffix:`cm`},Meters:{metersPerUnit:1,suffix:`m`},Inches:{metersPerUnit:1/39.37,suffix:`in`},Feet:{metersPerUnit:1/3.28084,suffix:`ft`}};function iz(e){let t=e&&rz[e]||rz.Meters;return e=>{let n=e/t.metersPerUnit,r=Math.abs(n),i=r===0?0:Math.min(6,Math.max(0,2-Math.floor(Math.log10(r))));return`${n.toFixed(i)} ${t.suffix}`}}function az(e){return(t,n)=>{let r=t*1e-6,i=[`x`,`y`,`z`].filter(e=>n[e]>r);return i.length<2?e(t):`${e(t)}\n${i.map(t=>`Δ${t} ${e(n[t])}`).join(` `)}`}}function oz(e,t){if(e.isOrthographicCamera){let t=e;return Math.abs(t.top-t.bottom)/(t.zoom||1)*$R}return((t?e.position.distanceTo(t):e.position.length())||1)*$R}function sz(e){let t=e.object,n=t.geometry;if(!n)return null;if(t.isLineSegments2){let t=n.attributes.instanceStart,r=n.attributes.instanceEnd,i=e.faceIndex;return!t||!r||i==null||i>=t.count?null:[new Z().fromBufferAttribute(t,i),new Z().fromBufferAttribute(r,i)]}let r=n.attributes.position;if(!r)return null;let i=e=>e.filter(e=>e<r.count).map(e=>new Z().fromBufferAttribute(r,e));if(t instanceof wx)return e.face?i([e.face.a,e.face.b,e.face.c]):null;if(t instanceof Yx)return e.index==null?null:i([e.index]);if(t instanceof Hx){if(e.index==null)return null;let t=n.index;return t?e.index+1>=t.count?null:i([t.getX(e.index),t.getX(e.index+1)]):i([e.index,e.index+1])}return null}function cz(e,t,n){let r=e.clone().project(t);return new X((r.x+1)/2*n.width,(1-r.y)/2*n.height)}function lz(e){return e.pointOnLine??e.point}function uz(e,t,n,r){let i=lz(e).clone(),a=sz(e);if(!a)return{point:i,snapped:!1};let o=cz(i,t,n),s={point:i,snapped:!1},c=r;for(let r of a){let i=r.applyMatrix4(e.object.matrixWorld),a=cz(i,t,n).distanceTo(o);a<c&&(c=a,s={point:i,snapped:!0})}return s}function dz(e){let{canvas:t,scene:n,getActiveCamera:r,getViewTarget:i,labelLayer:a,options:o={}}=e,s=e.requestRender??(()=>{}),c=o.snapPixels??ZR,l=new Q(o.color??QR),u=o.format??az(iz(o.displayUnit)),d=new GC,f=new X,p=!1,m=null,h=[],g=new Wx({color:l,size:8,sizeAttenuation:!1,depthTest:!1}),_=new Wx({color:l,size:12,sizeAttenuation:!1,depthTest:!1}),v=new Wx({color:l,size:7,sizeAttenuation:!1,depthTest:!1,transparent:!0,opacity:.6}),y=(e,t)=>(e.renderOrder=t,e.userData.id=`measure`,e.raycast=()=>{},e.frustumCulled=!1,e),b=(...e)=>{let t=new Pb;t.setAttribute(`position`,new Sb(e.flatMap(e=>[e.x,e.y,e.z]),3));let r=y(new Yx(t,g),tz);return n.add(r),r},x=(e,t,r=1)=>{let i=new dO;i.setPositions([e.x,e.y,e.z,t.x,t.y,t.z]);let a=new GD({color:l,transparent:r<1,opacity:r});a.linewidth=2,a.depthTest=!1;let o=y(new fO(i,a),ez);return n.add(o),o},S=(e,t,n)=>{let r=e.geometry.attributes.instanceStart.data;r.array.set([t.x,t.y,t.z,n.x,n.y,n.z]),r.needsUpdate=!0},C=e=>{e.geometry.dispose(),e.material.dispose(),e.removeFromParent()},w=e=>{e.geometry.dispose(),e.removeFromParent()},T=(e,t)=>{let n=new Z(Math.abs(t.x-e.x),Math.abs(t.y-e.y),Math.abs(t.z-e.z));return u(e.distanceTo(t),n)},E=(e,t)=>e.clone().add(t).multiplyScalar(.5),D=null,O=null,k=null,A=()=>{D&&(D.visible=!1),O&&(O.visible=!1),k?.remove(),k=null},j=e=>{if(!e){A();return}if(D||(D=b(new Z),D.renderOrder=nz),D.material=e.snapped?_:v,D.position.copy(e.point),D.visible=!0,!m){O&&(O.visible=!1),k?.remove(),k=null;return}O||=x(m.point,e.point,.7),S(O,m.point,e.point),O.visible=!0;let t=T(m.point,e.point),n=E(m.point,e.point);k?(k.setText(t),k.setPosition(n)):k=a.addLabel(t,n,o.labelClassName)},M=e=>{let a=t.getBoundingClientRect(),o=e.clientX-a.left,s=e.clientY-a.top;f.x=o/a.width*2-1,f.y=-(s/a.height)*2+1;let l=r();d.setFromCamera(f,l);let u=oz(l,i?.())*2;d.params.Line.threshold=u,d.params.Points.threshold=u,d.params.Line2={threshold:c/2};let p={width:a.width,height:a.height},m=new X(o,s);for(let e of YR(n,d))if(!(!(e.object.isMesh&&e.face!=null)&&cz(lz(e),l,p).distanceTo(m)>c))return uz(e,l,p,c);return null},N=null,P=0,ee=()=>{P&&=(cancelAnimationFrame(P),0),N=null},te=e=>{p&&(N=e,!P&&(P=requestAnimationFrame(()=>{P=0;let e=N;N=null,p&&e&&(j(M(e)),s())})))},ne=()=>{ee(),A(),s()},re=()=>{m&&=(w(m.marker),null)},ie=()=>{re();for(let e of h)w(e.markers),C(e.line),e.label.remove();h.length=0,A(),s()},ae=()=>{m?(re(),A(),s()):ie()},oe=e=>{if(!p)return!1;ee();let t=M(e);if(!t)return!0;if(!m)m={point:t.point,marker:b(t.point)};else if(!t.point.equals(m.point)){let e=m.point,n=t.point;re(),h.push({markers:b(e,n),line:x(e,n),label:a.addLabel(T(e,n),E(e,n),o.labelClassName)})}return j(t),s(),!0},se=e=>{e.key===`Escape`&&(e.target?.closest?.(`input, textarea, select, [contenteditable]`)||ae())},ce=``,le=null,ue=e=>{e!==p&&(p=e,e?(ce=t.style.cursor,t.style.cursor=`crosshair`,t.addEventListener(`mouseleave`,ne),window.addEventListener(`keydown`,se),le=XR(n)):(t.style.cursor=ce,t.removeEventListener(`mouseleave`,ne),window.removeEventListener(`keydown`,se),le?.(),le=null,ee(),ie()))};return{setEnabled:ue,isEnabled:()=>p,handleClick:oe,handleMove:te,cancel:ae,clear:ie,dispose:()=>{ue(!1),ie(),D&&w(D),O&&C(O),D=null,O=null,g.dispose(),_.dispose(),v.dispose()}}}var fz=.5,pz=.01,mz=.05,hz=256,gz=[];function _z({camera:e,scene:t,groundNormals:n=()=>gz}){let r=e.near,i=e.near,a=vz();return{update:()=>{e.near!==i&&(r=e.near);let o=a.measure(t,e),s=r;if(o!==null){let t=o;for(let r of n())t=Math.min(t,Math.abs(e.position.dot(r)));s=Ov.clamp(t*fz,r,e.far*pz)}Math.abs(s-i)>i*mz&&(e.near=s,e.updateProjectionMatrix(),i=s)}}}function vz(){let e=new WeakMap,t=new jx,n=new $v,r=new Z,i=new Xy,a=new Float64Array(20),o=new Float64Array(20),s=new Float32Array(6),c=new Float64Array(21),l=new Float64Array(21),u=1/0,d=!1,f=(t,n)=>{let r=n.getAttribute(`position`),i=n.getIndex(),a=e.get(n);if(a&&a.position===r&&a.positionVersion===bz(r)&&a.index===i&&a.indexVersion===(i?.version??-1))return a;let o={...Sz(r,i,xz(t)),position:r,positionVersion:bz(r),index:i,indexVersion:i?.version??-1};return e.set(n,o),o},p=(e,t,n)=>{let{position:r,index:i}=e,a=i?.array,o=1/0;for(let i=e.ranges[t*2];i<e.ranges[t*2+1];i++){for(let e=0;e<3;e++){let t=a?a[i*3+e]:i*3+e;c[e*3]=r.getX(t),c[e*3+1]=r.getY(t),c[e*3+2]=r.getZ(t)}let e=3;for(let t=0;t<16&&e>0;t+=4){let r=n[t],i=n[t+1],a=n[t+2],o=n[t+3],s=0;for(let t=0;t<e;t++){let n=(t+1)%e,u=c[t*3],d=c[t*3+1],f=c[t*3+2],p=c[n*3],m=c[n*3+1],h=c[n*3+2],g=r*u+i*d+a*f+o,_=r*p+i*m+a*h+o;if(g>=0&&(l[s*3]=u,l[s*3+1]=d,l[s*3+2]=f,s++),g>=0!=_>=0){let e=g/(g-_);l[s*3]=u+(p-u)*e,l[s*3+1]=d+(m-d)*e,l[s*3+2]=f+(h-f)*e,s++}}[c,l]=[l,c],e=s}for(let t=0;t<e;t++){let e=n[16]*c[t*3]+n[17]*c[t*3+1]+n[18]*c[t*3+2]+n[19];e<o&&(o=e)}}return o},m=e=>{let t=e.elements;for(let e=0;e<20;e+=4){let n=a[e],r=a[e+1],i=a[e+2];o[e]=t[0]*n+t[1]*r+t[2]*i,o[e+1]=t[4]*n+t[5]*r+t[6]*i,o[e+2]=t[8]*n+t[9]*r+t[10]*i,o[e+3]=n*t[12]+r*t[13]+i*t[14]+a[e+3]}return o},h=(e,t,n)=>{outer:for(let r=0;r<e.length;r+=6){let i=e[r],a=e[r+1],o=e[r+2],s=e[r+3],c=e[r+4],l=e[r+5];for(let e=0;e<16;e+=4){let n=t[e],r=t[e+1],u=t[e+2];if(n*(n>0?s:i)+r*(r>0?c:a)+u*(u>0?l:o)+t[e+3]<0)continue outer}let d=t[16],f=t[17],m=t[18],h=d*(d>0?i:s)+f*(f>0?a:c)+m*(m>0?o:l)+t[19];h>=u||(u=n?Math.min(u,p(n,r/6,t)):h)}},g=e=>{let t=e.geometry;if(!t?.getAttribute?.(`position`))return;if(d=!0,yz(e)){let n=f(e,t);h(n.boxes,m(e.matrixWorld),n);return}let n=e;n.isInstancedMesh?(n.boundingBox||n.computeBoundingBox(),i.copy(n.boundingBox)):(t.boundingBox||t.computeBoundingBox(),i.copy(t.boundingBox)),!i.isEmpty()&&(s[0]=i.min.x,s[1]=i.min.y,s[2]=i.min.z,s[3]=i.max.x,s[4]=i.max.y,s[5]=i.max.z,h(s,m(e.matrixWorld)))},_=e=>{if(e.visible&&!_L(e)&&e.userData.kind!==`edge-overlay`){g(e);for(let t of e.children)_(t)}};return{measure:(e,i)=>{e.updateMatrixWorld(),i.updateMatrixWorld(),n.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),t.setFromProjectionMatrix(n);for(let e=0;e<4;e++){let n=t.planes[e];a[e*4]=n.normal.x,a[e*4+1]=n.normal.y,a[e*4+2]=n.normal.z,a[e*4+3]=n.constant}i.getWorldDirection(r),a[16]=r.x,a[17]=r.y,a[18]=r.z,a[19]=-r.dot(i.position),u=1/0,d=!1;for(let t of e.children)_(t);return d?u:null}}}function yz(e){let t=e;if(!t.isMesh||t.isInstancedMesh||t.isSkinnedMesh)return!1;let n=t.geometry;return!n.isInstancedBufferGeometry&&Object.keys(n.morphAttributes).length===0}function bz(e){return e.isInterleavedBufferAttribute?e.data.version:e.version}function xz(e){let t=[];for(let n of lR(e)??[])n.indexStart!==void 0&&t.push(n.indexStart/3);return t.sort((e,t)=>e-t)}function Sz(e,t,n){let r=Math.floor((t?t.count:e.count)/3),i=[],a=0;for(let e=0;e<r;){for(;a<n.length&&n[a]<=e;)a++;let t=Math.min(r,e+hz,n[a]??r);i.push(e,t),e=t}let o=i.length/2,s=new Float32Array(o*6),c=!e.isInterleavedBufferAttribute,l=e.array,u=c&&e.itemSize===3&&!e.normalized,d=t?.array;for(let t=0;t<o;t++){let n=1/0,r=1/0,a=1/0,o=-1/0,c=-1/0,f=-1/0,p=i[t*2+1]*3;for(let s=i[t*2]*3;s<p;s++){let t=d?d[s]:s,i=u?l[t*3]:e.getX(t),p=u?l[t*3+1]:e.getY(t),m=u?l[t*3+2]:e.getZ(t);i<n&&(n=i),p<r&&(r=p),m<a&&(a=m),i>o&&(o=i),p>c&&(c=p),m>f&&(f=m)}let m=t*6;s[m]=n,s[m+1]=r,s[m+2]=a,s[m+3]=o,s[m+4]=c,s[m+5]=f}return{boxes:s,ranges:Uint32Array.from(i)}}function Cz(){let e=[],t=null,n=()=>e.sort((e,t)=>t.priority-e.priority),r=t=>e.findIndex(e=>e.id===t),i=n=>{let i=r(n);i!==-1&&(e.splice(i,1),t===n&&(t=null))};return{register:({id:t,tool:r,priority:a=0})=>(i(t),e.push({id:t,tool:r,priority:a}),n(),()=>i(t)),unregister:i,get:t=>e[r(t)]?.tool??null,setActive:n=>{t=n;for(let t of e)t.tool.setEnabled?.(t.id===n)},getActive:()=>t,handleClick:t=>{for(let n of[...e])if(n.tool.handleClick(t))return!0;return!1},handleMove:t=>{for(let n of[...e])n.tool.handleMove?.(t)}}}function wz(e){let{camera:t,domElement:n,controller:r}=e,i=new bF(t,n);i.setLabels(`X`,`Y`,`Z`);let a=!0,o=new GC,s=new bC(-2,2,2,-2,0,4);s.position.set(0,0,2),s.updateMatrixWorld();let c={posX:new Z(1,0,0),negX:new Z(-1,0,0),posY:new Z(0,1,0),negY:new Z(0,-1,0),posZ:new Z(0,0,1),negZ:new Z(0,0,-1)},l=e=>{let r=n.getBoundingClientRect(),a=r.left+n.offsetWidth-128-i.location.right,l=r.top+n.offsetHeight-128-i.location.bottom,u=new X((e.clientX-a)/128*2-1,-((e.clientY-l)/128)*2+1);if(Math.abs(u.x)>1||Math.abs(u.y)>1)return null;i.quaternion.copy(t.quaternion).invert(),i.updateMatrixWorld(),o.setFromCamera(u,s);let d=o.intersectObjects(i.children,!1);for(let e of d){let t=e.object.userData?.type;if(typeof t==`string`&&t in c)return t}return null};return{render:e=>{if(!a)return;let t=e.autoClear;e.autoClear=!1,i.render(e),e.autoClear=t},handleClick:e=>{if(!a)return!1;let t=l(e);return t?(r.getProjection()===`orthographic`&&r.setProjection(`perspective`),r.setViewDirection(c[t],!1),!0):!1},setVisible:e=>{a=e},isVisible:()=>a,dispose:()=>i.dispose()}}function Tz(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m=!0,h){let g=null,_=performance.now(),v=!0,y=0,b=new $v,x=new $v,S=null,C=()=>{v=!0},w=e=>{e.updateMatrixWorld();let t=S!==e||!b.equals(e.matrixWorld)||!x.equals(e.projectionMatrix);return t&&(S=e,b.copy(e.matrixWorld),x.copy(e.projectionMatrix)),t},T=e.domElement,E=[`pointerdown`,`pointerup`,`wheel`];if(m)for(let e of E)T.addEventListener(e,C,{passive:!0});let D=()=>{let{width:t,height:r}=o();if(t===0||r===0)return;let a=s(),c=Math.floor(t*a),l=Math.floor(r*a);(e.domElement.width!==c||e.domElement.height!==l)&&(e.setPixelRatio(a),e.setSize(t,r,!1),n.aspect=t/r,n.updateProjectionMatrix(),i.updateAspect(t,r),d?.()?.setSize(t,r,a),f?.setSize(t,r),C())},O=n=>{f&&f.render(t,n),u&&u.render(e)},k=(n,r)=>{let i=d?.();i?(i.setCamera(n),i.render(r)):e.render(t,n),O(n)},A=()=>{let e=r();h?.present()?O(e):k(e,0)},j=function(){g=requestAnimationFrame(j);let e=performance.now(),t=(e-_)/1e3;_=e,D(),(a.enableDamping||a.autoRotate)&&a.update(),l&&l.update(r().position),p&&p.update(),c?.(t);let n=r();if(m){let r=w(n);r&&h?.moving(t*1e3);let i=v||r;if(!i&&h?.wants(e)){h.step(n),O(n);return}let a=e-y>=500;if(!i&&!a||(y=e,!i&&h?.isHolding()))return;v=!1,h?.reset(e)}k(n,t)};return{animate:j,dispose:()=>{if(g!==null&&(cancelAnimationFrame(g),g=null),m)for(let e of E)T.removeEventListener(e,C)},invalidate:C,renderNow:A}}var Ez=3,Dz=2,Oz=1024,kz=1/3,Az=.05,jz=160/(4*Math.PI)*.005,Mz=.07,Nz=7,Pz=.15;function Fz(e){let t=pM(e);return t?.userData.selvaEmissive?t:null}function Iz(e){let t=lR(e);if(!t)return[new Xy().setFromObject(e)];let n=fM(e);return t.filter((e,t)=>!n.has(t)).map(t=>pR(e,t)).filter(e=>!e.isEmpty())}function Lz(e,t){let n=e=>e.getSize(new Z).length(),r=Math.max(n(e),n(t))*Az;return e.clone().expandByScalar(r).intersectsBox(t)}function Rz(e,t){let n=[];for(let r of e){let i={bounds:r.bounds.clone(),meshes:new Set([r.mesh])},a=[];for(let e of n)if(Lz(e.bounds,r.bounds)){i.bounds.union(e.bounds);for(let t of e.meshes)i.meshes.add(t)}else a.push(e);if(n=[...a,i],n.length>t){let t=new Xy;for(let n of e)t.union(n.bounds);return[{bounds:t,meshes:new Set(e.map(e=>e.mesh))}]}}return n}function zz(e,t){let n=new Map;for(let t of e){let{emissive:e,emissiveIntensity:r,userData:i}=t.material,a=`${e.getHexString()}|${r}|${i[wD]}`,o=n.get(a);o?o.push(t):n.set(a,[t])}return[...n.values()].flatMap(e=>{let{emissive:n,emissiveIntensity:r,userData:i}=e[0].material;return Rz(e,t).map(e=>({...e,color:n,strength:r,light:i[wD]}))})}function Bz(e,t=Ez){let n=Math.max(0,...e.map(e=>e.strength));return e.filter(e=>e.strength>=n*kz).sort((e,t)=>t.strength-e.strength).slice(0,t)}function Vz(e){let t=[],n=new Set,r=new Z,i=n=>{let r=new yC(16777215,1,0,2),i=new yC(16777215,1,0,1);n&&(r.castShadow=!0,r.shadow.mapSize.setScalar(Oz),r.shadow.radius=Nz,r.shadow.autoUpdate=!1);let a={key:r,bounce:i,home:new Z,size:new Z};return t.push(a),e.add(r,i),a},a=()=>{let t=new Xy,n=[];return e.traverseVisible(e=>{let r=e;if(!r.isMesh||e.userData.source!==`compute`)return;t.union(new Xy().setFromObject(r));let i=Fz(r);if(i)for(let e of Iz(r))n.push({mesh:r,material:i,bounds:e})}),{parts:n,radius:t.getSize(new Z).length()/2}},o=(e,r)=>{for(let{mesh:i,bounds:a}of e)r.some((e,n)=>e.meshes.has(i)||a.containsPoint(t[n].key.position))&&i.castShadow&&(i.castShadow=!1,n.add(i))},s=(r,s=Ez,c=1)=>{for(let e of n)e.castShadow=!0;n.clear();let{parts:l,radius:u}=r?a():{parts:[],radius:0},d=Bz(zz(l,s),s);for(d.forEach((e,n)=>{let{key:r,bounce:a,home:o,size:s}=t[n]??i(n<Dz),l=(e.light??e.strength*jz)*c;r.color.copy(e.color);let d=e.bounds.getSize(new Z).length()/2/u;r.intensity=!e.light&&d>Pz?0:l,e.bounds.getCenter(r.position),o.copy(r.position),e.bounds.getSize(s),a.color.copy(e.color),a.intensity=l*Mz/u,a.position.copy(r.position),r.castShadow&&(r.shadow.camera.near=u*.005,r.shadow.camera.far=u*4,r.shadow.camera.updateProjectionMatrix(),r.shadow.bias=-.002,r.shadow.normalBias=u*.002,r.shadow.needsUpdate=!0)});t.length>d.length;){let{key:n,bounce:r}=t.pop();e.remove(n,r),n.dispose(),r.dispose()}o(l,d)},c=e=>{for(let{key:n,home:r,size:i}of t)n.position.copy(e(r,i)),n.castShadow&&(n.shadow.needsUpdate=!0)};return{sync:s,jitter:e=>c((t,n)=>r.set(rL(e,2)-.5,rL(e,3)-.5,rL(e,5)-.5).multiply(n).add(t)),settle:()=>c(e=>e),dispose:()=>s(!1)}}var Hz=`__selvaLookBaseline`;function Uz(e,t){e.color?.setHex(t.color),e.metalness!==void 0&&(e.metalness=t.metalness),e.roughness!==void 0&&(e.roughness=t.roughness),e.emissiveIntensity!==void 0&&(e.emissiveIntensity=t.emissiveIntensity),e.opacity=t.opacity,e.transparent=t.transparent,e.depthWrite=t.depthWrite,e.wireframe!==void 0&&(e.wireframe=t.wireframe),e.side=t.side}function Wz(e){let t=e[Hz];t&&(Uz(e,t),delete e[Hz])}function Gz(e,t){let n=e;t?(n[Hz]?Uz(n,n[Hz]):n[Hz]={color:n.color?.getHex()??16777215,metalness:n.metalness??0,roughness:n.roughness??1,emissiveIntensity:n.emissiveIntensity??0,opacity:n.opacity,transparent:n.transparent,depthWrite:n.depthWrite,wireframe:n.wireframe??!1,side:n.side},t.color!==void 0&&n.color?.setHex(t.color),t.metalness!==void 0&&n.metalness!==void 0&&(n.metalness=t.metalness),t.roughness!==void 0&&n.roughness!==void 0&&(n.roughness=t.roughness),t.emissiveIntensity!==void 0&&n.userData.selvaEmissive&&(n.emissiveIntensity=t.emissiveIntensity),t.opacity!==void 0&&(n.opacity=t.opacity,n.transparent=t.opacity<1),t.depthWrite!==void 0&&(n.depthWrite=t.depthWrite),t.wireframe!==void 0&&n.wireframe!==void 0&&(n.wireframe=t.wireframe),t.side!==void 0&&(n.side=t.side),n.needsUpdate=!0):(Wz(n),n.needsUpdate=!0)}function Kz(e,t){if(t.materialOverride)return t.envMapIntensity;let n=e.userData[TD];if(n!=null)return n;let r=e,i=r[Hz]?.metalness??r.metalness??0;return ED(t.envMapIntensity,i,t.metalReflection)}function qz(e,t){return Math.min(e,t.maxPixelRatio??e)}function Jz(e){let{scene:t,renderer:n,lights:r,config:i,pipeline:a,fullPixelRatio:o,requestRender:s}=e,c=e=>SD(e,i.render.lowPower),l=i.look,u=Vz(t),d=n.shadowMap.type,f=e=>{let t=e.emissiveLights?1:d;n.shadowMap.type!==t&&(n.shadowMap.type=t,n.shadowMap.needsUpdate=!0)},p,m=e=>{e.background===void 0?(p!==void 0&&(t.background=p),p=void 0):(p??=t.background,t.background=new Q(e.background))};m(c(l)),f(c(l));let h=e=>{e.ambientIntensity!==void 0&&(r.ambient.intensity=e.ambientIntensity),e.hemisphereIntensity!==void 0&&!r.hemisphere&&e.hemisphereIntensity>0&&(r.hemisphere=new aC(e.hemisphereSkyColor??i.lighting.hemisphereSkyColor,e.hemisphereGroundColor??i.lighting.hemisphereGroundColor,e.hemisphereIntensity),r.hemisphere.position.copy(i.environment.sceneUp??ZI),t.add(r.hemisphere)),r.hemisphere&&(e.hemisphereIntensity!==void 0&&(r.hemisphere.intensity=e.hemisphereIntensity),e.hemisphereSkyColor!==void 0&&r.hemisphere.color.set(e.hemisphereSkyColor),e.hemisphereGroundColor!==void 0&&r.hemisphere.groundColor.set(e.hemisphereGroundColor)),s()},g=e=>{i.environment.environmentIntensity=e,t.environmentIntensity=e,s()},_=e=>{i.render.toneMappingExposure=e,n.toneMappingExposure=e,a.get()&&a.rebuild()},v=e=>{i.render.aoIntensity=e,a.get()&&a.rebuild()},y=()=>{let{emissiveLights:e,maxEmissiveLights:t,emissiveLightScale:n}=c(l);u.sync(!!e,t,n),s()};return{setFillLights:h,setEnvironmentIntensity:g,setToneMappingExposure:_,setAoIntensity:v,setLook:(e,s)=>{let u=c(e);l=e,n.toneMapping=u.toneMapping,n.toneMappingExposure=u.toneMappingExposure,i.render.toneMapping=u.toneMapping,i.render.toneMappingExposure=u.toneMappingExposure,h({hemisphereIntensity:u.hemisphereIntensity,ambientIntensity:u.ambientIntensity}),g(u.environmentIntensity),r.sun&&(r.sun.intensity=u.sunlightIntensity,i.lighting.sunlightIntensity=u.sunlightIntensity),m(u),f(u),i.render.bloom=u.bloom,i.render.pixelRatio=qz(o,u),a.setAmbientOcclusion(u.ambientOcclusion),t.traverse(e=>{if(e.userData.source!==`compute`)return;let t=e,n=Array.isArray(t.material)?t.material:t.material?[t.material]:[];for(let e of n)`envMapIntensity`in e&&(e.envMapIntensity=Kz(e,u)),Gz(e,u.materialOverride)}),GI(t,t),s?.deferEmissiveLights||y()},syncEmissiveLights:y,jitterEmissiveLights:u.jitter,settleEmissiveLights:u.settle,getMaterialAppearance:()=>DD(l)}}function Yz(e,t){let n=t.parentElement,r=n?n.clientWidth:window.innerWidth,i=n?n.clientHeight:window.innerHeight,a=new _C(e.camera.fov,r/i,e.camera.near,e.camera.far),o=e.camera.position;return o&&a.position.set(o.x,o.y,o.z),a}function Xz(e){let t=new Fy;return t.background=(typeof e.environment.backgroundColor==`string`?new Q(e.environment.backgroundColor):e.environment.backgroundColor)||null,t}function Zz(e,t){BD(e,t),e.environment?.dispose(),WI(e),e.background instanceof qv&&e.background.dispose()}var Qz={uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},uResolution:{value:new X(1,1)},uColor:{value:new Q(2236962)},uOpacity:{value:1},uNormalThreshold:{value:.4},uDepthThreshold:{value:.02},uThickness:{value:1},uNear:{value:.1},uFar:{value:1e3},uPerspective:{value:1}},vertexShader:`
|
|
6100
6100
|
varying vec2 vUv;
|
|
6101
6101
|
void main() {
|
|
6102
6102
|
vUv = uv;
|
|
@@ -6150,7 +6150,7 @@ ${nj}`))})}function ij(e,t){let n=Math.min(1,t.transmission);if(e.userData[FD]=!
|
|
|
6150
6150
|
float edge = max(depthEdge, normalEdge) * uOpacity;
|
|
6151
6151
|
gl_FragColor = vec4(mix(color.rgb, uColor, edge), color.a);
|
|
6152
6152
|
}
|
|
6153
|
-
`}
|
|
6153
|
+
`},$z=class extends SF{camera;scene;normalMaterial;edgeMaterial;fsQuad;normalTarget=null;width;height;constructor(e,t,n,r,i={}){super(),this.scene=e,this.camera=t,this.width=Math.max(1,n),this.height=Math.max(1,r),this.normalMaterial=new wS,this.normalMaterial.blending=0,this.edgeMaterial=new bS({uniforms:_S.clone(Qz.uniforms),vertexShader:Qz.vertexShader,fragmentShader:Qz.fragmentShader});let a=this.edgeMaterial.uniforms;a.uColor.value=new Q(i.color??2236962),a.uOpacity.value=i.opacity??1,a.uNormalThreshold.value=i.normalThreshold??.4,a.uDepthThreshold.value=i.depthThreshold??.02,a.uThickness.value=i.thickness??1,this.fsQuad=new TF(this.edgeMaterial),this.needsSwap=!0}acquireNormalTarget(){if(!this.normalTarget){let e=new $x(this.width,this.height);this.normalTarget=new Xv(this.width,this.height,{minFilter:gg,magFilter:gg,depthTexture:e})}return this.normalTarget}setSize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.normalTarget?.setSize(this.width,this.height)}render(e,t,n){let r=this.acquireNormalTarget(),i=e.getRenderTarget(),a=e.autoClear,o=e.getClearColor(new Q),s=e.getClearAlpha(),c=this.scene.overrideMaterial;e.setRenderTarget(r),e.setClearColor(7829503,1),e.autoClear=!0,this.scene.overrideMaterial=this.normalMaterial;let l=LD(this.scene);e.render(this.scene,this.camera),l(),this.scene.overrideMaterial=c,e.setClearColor(o,s),e.autoClear=a;let u=this.edgeMaterial.uniforms;u.tDiffuse.value=n.texture,u.tNormal.value=r.texture,u.tDepth.value=r.depthTexture,u.uResolution.value.set(this.width,this.height);let d=this.camera;u.uPerspective.value=+!!d.isPerspectiveCamera,u.uNear.value=this.camera.near??.1,u.uFar.value=this.camera.far??1e3,e.setRenderTarget(this.renderToScreen?null:t),this.fsQuad.render(e),e.setRenderTarget(i)}dispose(){this.normalTarget?.dispose(),this.normalMaterial.dispose(),this.edgeMaterial.dispose(),this.fsQuad.dispose()}},eB={name:`HdrClamp`,uniforms:{tDiffuse:{value:null}},vertexShader:`
|
|
6154
6154
|
varying vec2 vUv;
|
|
6155
6155
|
void main() {
|
|
6156
6156
|
vUv = uv;
|
|
@@ -6165,7 +6165,7 @@ ${nj}`))})}function ij(e,t){let n=Math.min(1,t.transmission);if(e.userData[FD]=!
|
|
|
6165
6165
|
void main() {
|
|
6166
6166
|
vec4 color = texture2D(tDiffuse, vUv);
|
|
6167
6167
|
gl_FragColor = vec4(safe(color.r), safe(color.g), safe(color.b), color.a);
|
|
6168
|
-
}`}
|
|
6168
|
+
}`},tB={vertexShader:`
|
|
6169
6169
|
varying vec2 vUv;
|
|
6170
6170
|
void main() {
|
|
6171
6171
|
vUv = uv;
|
|
@@ -6175,8 +6175,8 @@ ${nj}`))})}function ij(e,t){let n=Math.min(1,t.transmission);if(e.userData[FD]=!
|
|
|
6175
6175
|
varying vec2 vUv;
|
|
6176
6176
|
void main() {
|
|
6177
6177
|
gl_FragColor = texture2D(tFrame, vUv);
|
|
6178
|
-
}`};function eB(e){let t=new Xv(1,1,{type:kg,depthBuffer:!1}),n=new bS({...$z,uniforms:{tFrame:{value:null}},depthTest:!1,depthWrite:!1,toneMapped:!1,blending:5,blendSrc:213,blendDst:214}),r=new TF(n),i=(t,i)=>{n.uniforms.tFrame.value=t,n.blendAlpha=i;let a=e.autoClear;e.autoClear=!1,r.render(e),e.autoClear=a},a=()=>{e.setRenderTarget(null),i(t.texture,1)};return{add:(n,r,o,s)=>{(t.width!==o||t.height!==s)&&t.setSize(o,s),e.setRenderTarget(t),i(n,1/(r+1)),a()},present:a,dispose:()=>{t.dispose(),n.dispose(),r.dispose()}}}function tB(e){return e>=2?0:4}function nB(e){let t=e,n=t._overrideVisibility.bind(e),r=t._restoreVisibility.bind(e),i=()=>{};t._overrideVisibility=()=>{n(),i=LD(e.scene)},t._restoreVisibility=()=>{i(),r()}}function rB(e,t,n,r,i,a){let o=new Xv(r,i,{type:kg}),s=new kF(e,o);s.renderTarget2.samples=0;let c=e=>{s.readBuffer=o,s.writeBuffer=s.renderTarget2,s.render(e)},l=new AF(t,n);s.addPass(l);let u=null;(a.ambientOcclusion??!0)&&(u=new BF(t,n,r,i),u.blendIntensity=a.aoIntensity??1,u.updateGtaoMaterial({screenSpaceRadius:!0}),nB(u),s.addPass(u));let d=null,f=null;if(a.bloom){let{strength:e,radius:t,threshold:n}=a.bloom;d=new EF(Qz),s.addPass(d),f=new JF(new X(r,i),e,t,n),s.addPass(f)}let p=new Zz(t,n,r,i,typeof a.edgeDetection==`object`?a.edgeDetection:{});p.enabled=!!a.edgeDetection,s.addPass(p);let m=new WF;s.addPass(m);let h=new KF;s.addPass(h),e.toneMapping=a.toneMapping,e.toneMappingExposure=a.toneMappingExposure;let g=null,_=a.aoPixelRatio??1,v=1;if(u){let e=u.setSize.bind(u);u.setSize=(t,n)=>e(Math.max(1,Math.round(t*v)),Math.max(1,Math.round(n*v)))}let y=e=>{v=Math.min(e,_)/e;let t=tB(e);o.samples!==t&&(o.samples=t,o.dispose()),s.setPixelRatio(e)};return y(e.getPixelRatio()),s.setSize(r,i),{render:c,setSize:(e,t,n)=>{y(n),s.setSize(e,t)},setCamera:e=>{if(l.camera=e,p.camera=e,!u)return;u.camera=e;let t=+!!e.isPerspectiveCamera;u.gtaoMaterial.defines.PERSPECTIVE_CAMERA!==t&&(u.gtaoMaterial.defines.PERSPECTIVE_CAMERA=t,u.gtaoMaterial.needsUpdate=!0)},setEdgeDetection:e=>{p.enabled=e},edgeDetectionEnabled:()=>p.enabled,accumulate:t=>{s.renderToScreen=!1,c(0),s.renderToScreen=!0,g??=eB(e);let{texture:n,width:r,height:i}=s.readBuffer;g.add(n,t,r,i)},presentAccumulated:()=>g?.present(),setAoWeight:e=>{u&&(u.enabled=e>0,u.blendIntensity=(a.aoIntensity??1)*e)},dispose:()=>{s.dispose(),g?.dispose(),u?.dispose(),d?.dispose(),f?.dispose(),p.dispose(),m.dispose(),h.dispose()}}}function iB(e){let{renderer:t,scene:n,getActiveCamera:r,getCanvasSize:i,config:a,requestRender:o}=e,s=null,c=!!a.render.ambientOcclusion,l=!1,u=()=>({ambientOcclusion:c,bloom:a.render.bloom,toneMapping:a.render.toneMapping,toneMappingExposure:a.render.toneMappingExposure}),d=u(),f=()=>{let e=u();return e.ambientOcclusion!==d.ambientOcclusion||e.bloom!==d.bloom||e.toneMapping!==d.toneMapping||e.toneMappingExposure!==d.toneMappingExposure},p=()=>{let{width:e,height:o}=i(),s=rB(t,n,r(),Math.max(1,e),Math.max(1,o),{toneMapping:a.render.toneMapping??7,toneMappingExposure:a.render.toneMappingExposure??1,ambientOcclusion:c,aoIntensity:a.render.aoIntensity,aoPixelRatio:a.render.aoPixelRatio,bloom:a.render.bloom,edgeDetection:!1});return s.setSize(Math.max(1,e),Math.max(1,o),a.render.pixelRatio),s},m=()=>{c||l||a.render.bloom?((!s||f())&&(s?.dispose(),s=p(),d=u()),s.setEdgeDetection(l),o()):(s?.dispose(),s=null,o())};return{get:()=>s,sync:m,rebuild:()=>{s?.dispose(),s=null,m()},setAmbientOcclusion:e=>{c=e,m()},setEdgeFallback:e=>{e!==l&&(l=e,m())},isEdgeFallbackActive:()=>l,dispose:()=>{s?.dispose(),s=null}}}function aB(e,t,n){let r=new aI(e,t),i=n.camera.target;return i&&r.target.set(i.x,i.y,i.z),r.enableDamping=n.controls.enableDamping||!1,r.dampingFactor=n.controls.dampingFactor||.05,r.autoRotate=n.controls.autoRotate||!1,r.autoRotateSpeed=n.controls.autoRotateSpeed||.5,r.enableZoom=n.controls.enableZoom??!0,r.enablePan=n.controls.enablePan??!0,r.minDistance=n.controls.minDistance||.001,r.maxDistance=n.controls.maxDistance||1/0,r.screenSpacePanning=!1,r.maxPolarAngle=Math.PI,r.update(),r}function oB(e,t,n,r){if(n.environment.enableEnvironmentLighting){if(HI(e,t,YI(n.environment.sceneUp??ZI)),n.environment.hdrPath===!1){n.events.onReady?.();return}new vI().load(n.environment.hdrPath||`/baseHDR.hdr`,function(i){if(r()){i.dispose();return}if(!i?.image){bD().warn(`HDR loaded without image data; skipping environment map.`),i?.dispose(),n.events.onReady?.();return}i.mapping=303;let a=new Dw(t);a.compileEquirectangularShader();let o=a.fromEquirectangular(i).texture;a.dispose(),e.environment=o,e.environmentIntensity=n.environment.environmentIntensity??1;let s=YI(n.environment.sceneUp??ZI);e.environmentRotation.copy(s),n.environment.showEnvironment?(e.background=i,e.backgroundRotation.copy(s)):i.dispose(),n.events.onReady?.()},void 0,function(e){r()||(bD().warn(`HDR texture could not be loaded, falling back to basic lighting:`,e),n.events.onReady?.())})}else n.events.onReady?.()}function sB(e,t){let n=t.floor.size,r=new wx(new lS(n,n),new SS({color:typeof t.floor.color==`string`?new Q(t.floor.color):t.floor.color,roughness:t.floor.roughness,metalness:t.floor.metalness,side:2}));r.userData.id=`floor`,r.name=`floor`;let i=(t.environment?.sceneUp||ZI).clone().normalize();r.quaternion.setFromUnitVectors(new Z(0,0,1),i),r.position.set(0,0,0),t.floor.receiveShadow&&t.render.enableShadows&&(r.receiveShadow=!0),e.add(r)}var cB=.75,lB=.6,uB=.2,dB=1,fB=`#ffb020`,pB=[8,16],mB=8,hB=300,gB=30,_B=.35,vB=new Q(`#2f7bff`);function yB(e,t){let n=e.color;return n&&Math.hypot(n.r-t.r,n.g-t.g,n.b-t.b)<_B?vB:t}function bB(e,t,n){let r=yB(e,t);if(n&&`emissive`in e){let t=e;t.emissive=r.clone(),t.emissiveIntensity=lB,t.color.lerp(r,cB),t.metalness=Math.min(t.metalness,uB),t.opacity<dB&&(t.opacity=dB,t.transparent=!1,t.depthWrite=!0)}else`color`in e&&(e.color=r.clone())}function xB(e,t,n,r,i){let a=new Set,o=new Map,s=[],c=null,l=!1,u=new GC,d=new X,f=()=>n.getActiveCamera(),p=()=>{let e=yL(t);e.isEmpty()?bD().warn(`No objects to fit to view`):n.frameBounds(e,!1)},m=typeof r.events.selectionColor==`string`?new Q(r.events.selectionColor):r.events.selectionColor instanceof Q?r.events.selectionColor:new Q(`#ff0000`),h=new Q(fB),g=[],_=[],v=(e,n)=>{let r=e;for(;r.parent;)r=r.parent;r!==t&&(n instanceof Wb?n.dispose():n.forEach(e=>e.dispose()))},y=()=>{for(let{restore:e,material:t}of _)e(),t.dispose();_.length=0;for(let{object:e,original:t}of g){let n=e.material;n instanceof Wb&&n.dispose(),e.material=t,v(e,t)}g.length=0},b=e=>{let t=[],n=new Map;for(let{object:r,memberIndex:i}of e){if(i===null){t.push(r);continue}let e=n.get(r);e||n.set(r,e=new Set),e.add(i)}return{whole:t,membersByMesh:n}},x=(e,t=null)=>{if(y(),!e)return;let n=e instanceof Ey?[{object:e,memberIndex:t}]:e,{whole:r,membersByMesh:i}=b(n);for(let[e,t]of i){if(!(e instanceof wx)){r.push(e);continue}let n=pM(e).clone();bB(n,h,!0),_.push({restore:fR(e,t,n,`hover`),material:n})}for(let e of r){if(a.has(e))continue;let t=e;if(!(t.material instanceof Wb))continue;let n=mM(t.material);bB(n,h,e instanceof wx),g.push({object:t,original:t.material}),t.material=n}},S=()=>{for(let{restore:e,material:t}of s)e(),t.dispose();s.length=0,a.forEach(e=>{let t=e;if(o.has(e)){let n=o.get(e),r=t.material;r instanceof Wb?r.dispose():Array.isArray(r)&&r.forEach(e=>e.dispose()),t.material=n,o.delete(e),v(e,n)}}),a.clear(),c=null,l=!1},C=(e,t)=>{if(t&&e instanceof wx){let n=pM(e).clone();return bB(n,m,!0),s.push({restore:fR(e,t,n),material:n}),!0}let n=e;if(!(n.material instanceof Wb))return!1;let r=mM(n.material);return bB(r,m,e instanceof wx),o.set(e,n.material),n.material=r,!0},w=e=>{let{whole:t,membersByMesh:n}=b(e);for(let e of t)a.add(e),C(e,null);for(let[e,t]of n)a.add(e),C(e,t)},T=e=>{(e.length!==0||l)&&(y(),S(),w(e),l=e.length>0)},E=null,D=-1,O=()=>{if(E===null||t.children.length!==D){let e=yL(t);E=e.isEmpty()?1:e.getSize(new Z).length(),D=t.children.length}u.params.Points.threshold=E*.01},k=(t,n)=>{let r=e.getBoundingClientRect();d.x=(t-r.left)/r.width*2-1,d.y=-((n-r.top)/r.height)*2+1},A=(e,n)=>(k(e,n),O(),u.setFromCamera(d,f()),qR(t,u)[0]??null),j=(e,t,n)=>{let r=A(e,t);if(r||!n)return r;for(let n of pB){let r=null;for(let i=0;i<mB;i++){let a=i/mB*Math.PI*2,o=A(e+Math.cos(a)*n,t+Math.sin(a)*n);o&&(!r||o.distance<r.distance)&&(r=o)}if(r)return r}return null},M=null,N=e=>{let t=M;if(M={time:e.timeStamp,x:e.clientX,y:e.clientY},!t)return!1;let n=e.timeStamp-t.time<=hB&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<=gB;return n&&(M=null),n},P=e=>{if(!i.wasTap())return;let n=i.pointerType()!==`mouse`;if(n&&N(e)){te(e.clientX,e.clientY,!0);return}let a=j(e.clientX,e.clientY,n);if(!a){S(),k(e.clientX,e.clientY),r.events?.onBackgroundClicked?.({x:d.x,y:d.y});return}let o=a.object,s=cR(a),u=s?.index??null;(l||c?.object!==o||c.memberIndex!==u)&&(y(),S(),c={object:o,memberIndex:u},w(uR(t,a)),r.events?.onObjectSelected?.(o),s?r.events?.onMeshMetadataClicked?.({source:o.userData?.source,name:s.member.name,layer:s.member.layer,trackingKey:s.member.trackingKey,metadata:s.member.metadata}):o instanceof wx&&Object.keys(o.userData).length>0&&r.events?.onMeshMetadataClicked?.(o.userData))},ee=e=>{i.wasTap()&&i.pointerType()===`mouse`&&te(e.clientX,e.clientY,!1)},te=(e,i,a)=>{let o=j(e,i,a);if(!o){r.events?.enableDoubleClickZoom&&n.frameBounds(yL(t),!0);return}let s=o.object;if(r.events?.onMeshDoubleClicked?.(s),!r.events?.enableDoubleClickZoom)return;let c=new Xy;for(let{object:e,memberIndex:n}of uR(t,o)){let t=n===null?null:sR(e)?.[n];c.union(t&&e instanceof wx?dR(e,t):new Xy().setFromObject(e))}c.isEmpty()||n.frameBounds(c,!0)},ne=e=>{if(r.events?.enableKeyboardControls)switch(e.key.toLowerCase()){case`f`:e.preventDefault(),p();break;case`escape`:e.preventDefault(),S();break;case` `:e.preventDefault(),p()}};return r.events?.enableClickToFocus&&(e.addEventListener(`click`,P),e.addEventListener(`dblclick`,ee)),r.events?.enableKeyboardControls&&(e.setAttribute(`tabindex`,`0`),e.addEventListener(`keydown`,ne)),{dispose:()=>{e.removeEventListener(`click`,P),e.removeEventListener(`dblclick`,ee),e.removeEventListener(`keydown`,ne),y(),S()},fitToView:p,clearSelection:S,selectEntries:T,setHover:x}}var SB=5,CB=10,wB=500;function TB(e){let t=new Map,n=`mouse`,r=0,i=0,a=0,o=!1,s=!1,c=e=>{let n=t.get(e.pointerId);n&&(a=Math.max(a,Math.hypot(e.clientX-n.x,e.clientY-n.y)))},l=e=>{t.size===0&&(n=e.pointerType,r=e.timeStamp,i=0,a=0,o=!1),t.set(e.pointerId,{x:e.clientX,y:e.clientY}),i=Math.max(i,t.size)},u=e=>c(e),d=e=>{if(!t.has(e.pointerId)||(c(e),e.type===`pointercancel`&&(o=!0),t.delete(e.pointerId),t.size>0))return;let l=n===`mouse`;s=!o&&i===1&&a<=(l?SB:CB)&&(l||e.timeStamp-r<=wB)},f={capture:!0,passive:!0};return e.addEventListener(`pointerdown`,l,f),e.addEventListener(`pointermove`,u,f),e.addEventListener(`pointerup`,d,f),e.addEventListener(`pointercancel`,d,f),{wasTap:()=>s,pointerType:()=>n,dispose:()=>{e.removeEventListener(`pointerdown`,l,f),e.removeEventListener(`pointermove`,u,f),e.removeEventListener(`pointerup`,d,f),e.removeEventListener(`pointercancel`,d,f)}}}function EB(e,t,n){let r=new gD({antialias:t.render.antialias,canvas:e,alpha:!0,powerPreference:`high-performance`,preserveDrawingBuffer:t.render.preserveDrawingBuffer,logarithmicDepthBuffer:!1}),i=e.parentElement,a=i?i.clientWidth:window.innerWidth,o=i?i.clientHeight:window.innerHeight;return i&&(e.style.width=`100%`,e.style.height=`100%`,e.style.display=`block`),r.setSize(a,o,!1),r.setPixelRatio(n),t.render.enableShadows&&(r.shadowMap.enabled=!0,r.shadowMap.type=3),r.toneMapping=t.render.toneMapping,r.toneMappingExposure=t.render.toneMappingExposure??1,r.outputColorSpace=F_,r.sortObjects=!0,r}var DB=function(e,t){let n=$I(t||{}),r=n.environment?.sceneUp||ZI,i=n.render.pixelRatio??Math.min(window.devicePixelRatio,2),a=Gz(i,SD(n.look,n.render.lowPower));n.render.pixelRatio=a;let o=Jz(n),s=qz(n,e);s.up.copy(r);let c=EB(e,n,a);ND(c.capabilities.getMaxAnisotropy()),t?.onMaxAnisotropy?.(c.capabilities.getMaxAnisotropy());let l=aB(s,e,n),u=wL({scene:o,perspective:s,controls:l,onActiveCameraChange:()=>{},up:r}),d=()=>u.getActiveCamera(),f=!1;oB(o,c,n,()=>f);let p=dL(o,n),m=p.sun,h=()=>{m&&pL(m,yL(o))};n.floor?.enabled&&sB(o,n);let g=n.floor?.enabled?o.children.find(e=>e.userData.id===`floor`)??null:null,_=n.grid.enabled?FR({cellSize:n.grid.cellSize,majorEvery:n.grid.majorEvery,cellColor:n.grid.cellColor,majorColor:n.grid.majorColor,fadeDistance:n.grid.fadeDistance,plane:n.grid.plane}):null;_&&o.add(_.object);let v=()=>{_&&_.fitToContent(yL(o))},y=n.gizmo.enabled?Sz({camera:s,domElement:e,controller:u}):null,b=n.grid.plane??XI(r),x=new Z(+(b===`x`),+(b===`y`),+(b===`z`)),S=r.clone().normalize(),C=n.camera.dynamicNear?hz({camera:s,scene:o,groundNormals:()=>{let e=[];return _?.object.visible&&e.push(x),n.floor.enabled&&g?.visible&&e.push(S),e}}):null,w=IR(e.parentElement??e,o),T=n.measure.enabled?lz({canvas:e,scene:o,getActiveCamera:d,getViewTarget:()=>l.target,requestRender:()=>j(),labelLayer:w,options:{snapPixels:n.measure.snapPixels,color:n.measure.color,labelClassName:n.measure.labelClassName,displayUnit:n.measure.displayUnit,format:n.measure.format}}):null,E=TB(e),D=n.events.enableEventHandlers===!1?{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{},selectEntries:()=>{},setHover:()=>{}}:xB(e,o,u,n,E),O=xz();T&&O.register({id:`measure`,tool:T,priority:0}),y&&O.register({id:`gizmo`,tool:y,priority:-100});let k=e=>{E.wasTap()&&O.handleClick(e)&&e.stopImmediatePropagation()};e.addEventListener(`click`,k,{capture:!0});let A=e=>O.handleMove(e);e.addEventListener(`mousemove`,A,{passive:!0});let j=()=>{},M=(e,t)=>{AR(e,{color:n.edges.color,darken:n.edges.darken,width:n.edges.width,thresholdAngle:n.edges.thresholdAngle,distanceFade:n.edges.distanceFade,maxTriangles:n.edges.maxTriangles,maxSegments:n.edges.maxSegments,maxOverlays:n.edges.maxOverlays,...t}).then(()=>{N(e),j()})},N=e=>{if(n.edges.screenSpaceFallback===!1)return;let t=!1;e.traverse(e=>{let n=e.userData?.edgesSkipped;(n===`triangle-cap`||n===`overlay-budget`)&&(t=!0)}),ne.setEdgeFallback(t)},P=e=>{jR(e),ne.setEdgeFallback(!1),j()},ee=e.parentElement,te=()=>ee?{width:ee.clientWidth,height:ee.clientHeight}:{width:window.innerWidth,height:window.innerHeight},ne=iB({renderer:c,scene:o,getActiveCamera:d,getCanvasSize:te,config:n,requestRender:()=>j()});ne.sync();let re=Kz({scene:o,renderer:c,lights:p,config:n,pipeline:ne,fullPixelRatio:i,requestRender:()=>j()}),ie,ae=aL({scene:o,renderer:c,getPipeline:()=>ne.get(),frames:n.render.idleRefineFrames,lightOrbitFrameMs:n.render.lightOrbitFrameMs,jitterLights:e=>{m&&(ie=fL(m,e)),re.jitterEmissiveLights(e)},restoreLights:()=>{ie?.(),re.settleEmissiveLights()}}),{animate:oe,dispose:se,invalidate:ce,renderNow:le}=Cz(c,o,s,d,u,l,te,()=>n.render.pixelRatio,n.events.onFrame,_,y,()=>ne.get(),w,C,n.render.onDemand??!0,ae);return j=ce,oe(),o.up.set(r.x,r.y,r.z),h(),v(),{scene:o,camera:s,controls:l,renderer:c,cameraController:u,grid:_,gizmo:y,measureTool:T,labelLayer:w,tools:O,applyEdges:M,clearEdges:P,invalidate:ce,captureImage:(e=`image/png`,t)=>(le(),new Promise(n=>c.domElement.toBlob(n,e,t))),setAmbientOcclusion:ne.setAmbientOcclusion,setLook:re.setLook,syncEmissiveLights:re.syncEmissiveLights,setFillLights:re.setFillLights,setEnvironmentIntensity:re.setEnvironmentIntensity,setToneMappingExposure:re.setToneMappingExposure,setAoIntensity:re.setAoIntensity,getMaterialAppearance:re.getMaterialAppearance,updateShadowBounds:h,updateGridScale:v,dispose:()=>{f||(f=!0,se(),D.dispose(),E.dispose(),e.removeEventListener(`click`,k,{capture:!0}),e.removeEventListener(`mousemove`,A),T?.dispose(),w?.dispose(),y?.dispose(),_?.dispose(),ne.dispose(),u.dispose(),l.dispose(),c.dispose(),c.forceContextLoss(),Yz(o))},fitToView:D.fitToView,clearSelection:D.clearSelection,selectEntries:e=>{D.selectEntries(e),ce()},setHover:(e,t)=>{D.setHover(e,t),ce()},addUserGeometry:(e,t)=>{e.userData.source=t===void 0?bI:SI(t),o.add(e),j()},removeUserGeometry:e=>{e.removeFromParent(),BD(e),j()},clearUserGeometry:e=>{o.children.filter(t=>TI(t,e)).forEach(e=>{e.removeFromParent(),BD(e)}),j()}}},OB=`selva/solve-view`;function kB(e){e&&(e.theme&&Zh(e.theme),e.styles?.variables&&Qh(e.styles.variables),e.styles?.css?.fonts&&$h(e.styles.css.fonts))}async function AB(e,t){let n=new tg(e);return n.addEventListener(`hostcontextchanged`,kB),t?.(n),await n.connect(),kB(n.getHostContext()),n}function jB(e){return(e.content??[]).flatMap(e=>{let t=e;return t.type===`text`&&t.text?[t.text]:[]}).join(`
|
|
6179
|
-
`)}function
|
|
6178
|
+
}`};function nB(e){let t=new Xv(1,1,{type:kg,depthBuffer:!1}),n=new bS({...tB,uniforms:{tFrame:{value:null}},depthTest:!1,depthWrite:!1,toneMapped:!1,blending:5,blendSrc:213,blendDst:214}),r=new TF(n),i=(t,i)=>{n.uniforms.tFrame.value=t,n.blendAlpha=i;let a=e.autoClear;e.autoClear=!1,r.render(e),e.autoClear=a},a=()=>{e.setRenderTarget(null),i(t.texture,1)};return{add:(n,r,o,s)=>{(t.width!==o||t.height!==s)&&t.setSize(o,s),e.setRenderTarget(t),i(n,1/(r+1)),a()},present:a,dispose:()=>{t.dispose(),n.dispose(),r.dispose()}}}function rB(e){return e>=2?0:4}function iB(e){let t=e,n=t._overrideVisibility.bind(e),r=t._restoreVisibility.bind(e),i=()=>{};t._overrideVisibility=()=>{n(),i=LD(e.scene)},t._restoreVisibility=()=>{i(),r()}}function aB(e,t,n,r,i,a){let o=new Xv(r,i,{type:kg}),s=new kF(e,o);s.renderTarget2.samples=0;let c=e=>{s.readBuffer=o,s.writeBuffer=s.renderTarget2,s.render(e)},l=new AF(t,n);s.addPass(l);let u=null;(a.ambientOcclusion??!0)&&(u=new BF(t,n,r,i),u.blendIntensity=a.aoIntensity??1,u.updateGtaoMaterial({screenSpaceRadius:!0}),iB(u),s.addPass(u));let d=null,f=null;if(a.bloom){let{strength:e,radius:t,threshold:n}=a.bloom;d=new EF(eB),s.addPass(d),f=new JF(new X(r,i),e,t,n),s.addPass(f)}let p=new $z(t,n,r,i,typeof a.edgeDetection==`object`?a.edgeDetection:{});p.enabled=!!a.edgeDetection,s.addPass(p);let m=new WF;s.addPass(m);let h=new KF;s.addPass(h),e.toneMapping=a.toneMapping,e.toneMappingExposure=a.toneMappingExposure;let g=null,_=a.aoPixelRatio??1,v=1;if(u){let e=u.setSize.bind(u);u.setSize=(t,n)=>e(Math.max(1,Math.round(t*v)),Math.max(1,Math.round(n*v)))}let y=e=>{v=Math.min(e,_)/e;let t=rB(e);o.samples!==t&&(o.samples=t,o.dispose()),s.setPixelRatio(e)};return y(e.getPixelRatio()),s.setSize(r,i),{render:c,setSize:(e,t,n)=>{y(n),s.setSize(e,t)},setCamera:e=>{if(l.camera=e,p.camera=e,!u)return;u.camera=e;let t=+!!e.isPerspectiveCamera;u.gtaoMaterial.defines.PERSPECTIVE_CAMERA!==t&&(u.gtaoMaterial.defines.PERSPECTIVE_CAMERA=t,u.gtaoMaterial.needsUpdate=!0)},setEdgeDetection:e=>{p.enabled=e},edgeDetectionEnabled:()=>p.enabled,accumulate:t=>{s.renderToScreen=!1,c(0),s.renderToScreen=!0,g??=nB(e);let{texture:n,width:r,height:i}=s.readBuffer;g.add(n,t,r,i)},presentAccumulated:()=>g?.present(),setAoWeight:e=>{u&&(u.enabled=e>0,u.blendIntensity=(a.aoIntensity??1)*e)},dispose:()=>{s.dispose(),g?.dispose(),u?.dispose(),d?.dispose(),f?.dispose(),p.dispose(),m.dispose(),h.dispose()}}}function oB(e){let{renderer:t,scene:n,getActiveCamera:r,getCanvasSize:i,config:a,requestRender:o}=e,s=null,c=!!a.render.ambientOcclusion,l=!1,u=()=>({ambientOcclusion:c,bloom:a.render.bloom,toneMapping:a.render.toneMapping,toneMappingExposure:a.render.toneMappingExposure}),d=u(),f=()=>{let e=u();return e.ambientOcclusion!==d.ambientOcclusion||e.bloom!==d.bloom||e.toneMapping!==d.toneMapping||e.toneMappingExposure!==d.toneMappingExposure},p=()=>{let{width:e,height:o}=i(),s=aB(t,n,r(),Math.max(1,e),Math.max(1,o),{toneMapping:a.render.toneMapping??7,toneMappingExposure:a.render.toneMappingExposure??1,ambientOcclusion:c,aoIntensity:a.render.aoIntensity,aoPixelRatio:a.render.aoPixelRatio,bloom:a.render.bloom,edgeDetection:!1});return s.setSize(Math.max(1,e),Math.max(1,o),a.render.pixelRatio),s},m=()=>{c||l||a.render.bloom?((!s||f())&&(s?.dispose(),s=p(),d=u()),s.setEdgeDetection(l),o()):(s?.dispose(),s=null,o())};return{get:()=>s,sync:m,rebuild:()=>{s?.dispose(),s=null,m()},setAmbientOcclusion:e=>{c=e,m()},setEdgeFallback:e=>{e!==l&&(l=e,m())},isEdgeFallbackActive:()=>l,dispose:()=>{s?.dispose(),s=null}}}function sB(e,t,n){let r=new aI(e,t),i=n.camera.target;return i&&r.target.set(i.x,i.y,i.z),r.enableDamping=n.controls.enableDamping||!1,r.dampingFactor=n.controls.dampingFactor||.05,r.autoRotate=n.controls.autoRotate||!1,r.autoRotateSpeed=n.controls.autoRotateSpeed||.5,r.enableZoom=n.controls.enableZoom??!0,r.enablePan=n.controls.enablePan??!0,r.minDistance=n.controls.minDistance||.001,r.maxDistance=n.controls.maxDistance||1/0,r.screenSpacePanning=!1,r.maxPolarAngle=Math.PI,r.update(),r}function cB(e,t,n,r){if(n.environment.enableEnvironmentLighting){if(HI(e,t,YI(n.environment.sceneUp??ZI)),n.environment.hdrPath===!1){n.events.onReady?.();return}new vI().load(n.environment.hdrPath||`/baseHDR.hdr`,function(i){if(r()){i.dispose();return}if(!i?.image){bD().warn(`HDR loaded without image data; skipping environment map.`),i?.dispose(),n.events.onReady?.();return}i.mapping=303;let a=new Dw(t);a.compileEquirectangularShader();let o=a.fromEquirectangular(i).texture;a.dispose(),e.environment=o,e.environmentIntensity=n.environment.environmentIntensity??1;let s=YI(n.environment.sceneUp??ZI);e.environmentRotation.copy(s),n.environment.showEnvironment?(e.background=i,e.backgroundRotation.copy(s)):i.dispose(),n.events.onReady?.()},void 0,function(e){r()||(bD().warn(`HDR texture could not be loaded, falling back to basic lighting:`,e),n.events.onReady?.())})}else n.events.onReady?.()}function lB(e,t){let n=t.floor.size,r=new wx(new lS(n,n),new SS({color:typeof t.floor.color==`string`?new Q(t.floor.color):t.floor.color,roughness:t.floor.roughness,metalness:t.floor.metalness,side:2}));r.userData.id=`floor`,r.name=`floor`;let i=(t.environment?.sceneUp||ZI).clone().normalize();r.quaternion.setFromUnitVectors(new Z(0,0,1),i),r.position.set(0,0,0),t.floor.receiveShadow&&t.render.enableShadows&&(r.receiveShadow=!0),e.add(r)}var uB=.75,dB=.6,fB=.2,pB=1,mB=`#ffb020`,hB=[8,16],gB=8,_B=300,vB=30,yB=.35,bB=new Q(`#2f7bff`);function xB(e,t){let n=e.color;return n&&Math.hypot(n.r-t.r,n.g-t.g,n.b-t.b)<yB?bB:t}function SB(e,t,n){let r=xB(e,t);if(n&&`emissive`in e){let t=e;t.emissive=r.clone(),t.emissiveIntensity=dB,t.color.lerp(r,uB),t.metalness=Math.min(t.metalness,fB),t.opacity<pB&&(t.opacity=pB,t.transparent=!1,t.depthWrite=!0)}else`color`in e&&(e.color=r.clone())}function CB(e,t,n,r,i){let a=new Set,o=new Map,s=[],c=null,l=!1,u=new GC,d=new X,f=()=>n.getActiveCamera(),p=()=>{let e=yL(t);e.isEmpty()?bD().warn(`No objects to fit to view`):n.frameBounds(e,!1)},m=typeof r.events.selectionColor==`string`?new Q(r.events.selectionColor):r.events.selectionColor instanceof Q?r.events.selectionColor:new Q(`#ff0000`),h=new Q(mB),g=[],_=[],v=(e,n)=>{let r=e;for(;r.parent;)r=r.parent;r!==t&&(n instanceof Wb?n.dispose():n.forEach(e=>e.dispose()))},y=()=>{for(let{restore:e,material:t}of _)e(),t.dispose();_.length=0;for(let{object:e,original:t}of g){let n=e.material;n instanceof Wb&&n.dispose(),e.material=t,v(e,t)}g.length=0},b=e=>{let t=[],n=new Map;for(let{object:r,memberIndex:i}of e){if(i===null){t.push(r);continue}let e=n.get(r);e||n.set(r,e=new Set),e.add(i)}return{whole:t,membersByMesh:n}},x=(e,t=null)=>{if(y(),!e)return;let n=e instanceof Ey?[{object:e,memberIndex:t}]:e,{whole:r,membersByMesh:i}=b(n);for(let[e,t]of i){if(!(e instanceof wx)){r.push(e);continue}let n=pM(e).clone();SB(n,h,!0),_.push({restore:mR(e,t,n,`hover`),material:n})}for(let e of r){if(a.has(e))continue;let t=e;if(!(t.material instanceof Wb))continue;let n=mM(t.material);SB(n,h,e instanceof wx),g.push({object:t,original:t.material}),t.material=n}},S=()=>{for(let{restore:e,material:t}of s)e(),t.dispose();s.length=0,a.forEach(e=>{let t=e;if(o.has(e)){let n=o.get(e),r=t.material;r instanceof Wb?r.dispose():Array.isArray(r)&&r.forEach(e=>e.dispose()),t.material=n,o.delete(e),v(e,n)}}),a.clear(),c=null,l=!1},C=(e,t)=>{if(t&&e instanceof wx){let n=pM(e).clone();return SB(n,m,!0),s.push({restore:mR(e,t,n),material:n}),!0}let n=e;if(!(n.material instanceof Wb))return!1;let r=mM(n.material);return SB(r,m,e instanceof wx),o.set(e,n.material),n.material=r,!0},w=e=>{let{whole:t,membersByMesh:n}=b(e);for(let e of t)a.add(e),C(e,null);for(let[e,t]of n)a.add(e),C(e,t)},T=e=>{(e.length!==0||l)&&(y(),S(),w(e),l=e.length>0)},E=null,D=-1,O=()=>{if(E===null||t.children.length!==D){let e=yL(t);E=e.isEmpty()?1:e.getSize(new Z).length(),D=t.children.length}u.params.Points.threshold=E*.01},k=(t,n)=>{let r=e.getBoundingClientRect();d.x=(t-r.left)/r.width*2-1,d.y=-((n-r.top)/r.height)*2+1},A=(e,n)=>(k(e,n),O(),u.setFromCamera(d,f()),YR(t,u)[0]??null),j=(e,t,n)=>{let r=A(e,t);if(r||!n)return r;for(let n of hB){let r=null;for(let i=0;i<gB;i++){let a=i/gB*Math.PI*2,o=A(e+Math.cos(a)*n,t+Math.sin(a)*n);o&&(!r||o.distance<r.distance)&&(r=o)}if(r)return r}return null},M=null,N=e=>{let t=M;if(M={time:e.timeStamp,x:e.clientX,y:e.clientY},!t)return!1;let n=e.timeStamp-t.time<=_B&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<=vB;return n&&(M=null),n},P=e=>{if(!i.wasTap())return;let n=i.pointerType()!==`mouse`;if(n&&N(e)){te(e.clientX,e.clientY,!0);return}let a=j(e.clientX,e.clientY,n);if(!a){S(),k(e.clientX,e.clientY),r.events?.onBackgroundClicked?.({x:d.x,y:d.y});return}let o=a.object,s=uR(a),u=s?.index??null;(l||c?.object!==o||c.memberIndex!==u)&&(y(),S(),c={object:o,memberIndex:u},w(fR(t,a)),r.events?.onObjectSelected?.(o),s?r.events?.onMeshMetadataClicked?.({source:o.userData?.source,name:s.member.name,layer:s.member.layer,trackingKey:s.member.trackingKey,metadata:s.member.metadata}):o instanceof wx&&Object.keys(o.userData).length>0&&r.events?.onMeshMetadataClicked?.(o.userData))},ee=e=>{i.wasTap()&&i.pointerType()===`mouse`&&te(e.clientX,e.clientY,!1)},te=(e,i,a)=>{let o=j(e,i,a);if(!o){r.events?.enableDoubleClickZoom&&n.frameBounds(yL(t),!0);return}let s=o.object;if(r.events?.onMeshDoubleClicked?.(s),!r.events?.enableDoubleClickZoom)return;let c=new Xy;for(let{object:e,memberIndex:n}of fR(t,o)){let t=n===null?null:lR(e)?.[n];c.union(t&&e instanceof wx?pR(e,t):new Xy().setFromObject(e))}c.isEmpty()||n.frameBounds(c,!0)},ne=e=>{if(r.events?.enableKeyboardControls)switch(e.key.toLowerCase()){case`f`:e.preventDefault(),p();break;case`escape`:e.preventDefault(),S();break;case` `:e.preventDefault(),p()}};return r.events?.enableClickToFocus&&(e.addEventListener(`click`,P),e.addEventListener(`dblclick`,ee)),r.events?.enableKeyboardControls&&(e.setAttribute(`tabindex`,`0`),e.addEventListener(`keydown`,ne)),{dispose:()=>{e.removeEventListener(`click`,P),e.removeEventListener(`dblclick`,ee),e.removeEventListener(`keydown`,ne),y(),S()},fitToView:p,clearSelection:S,selectEntries:T,setHover:x}}var wB=5,TB=10,EB=500;function DB(e){let t=new Map,n=`mouse`,r=0,i=0,a=0,o=!1,s=!1,c=e=>{let n=t.get(e.pointerId);n&&(a=Math.max(a,Math.hypot(e.clientX-n.x,e.clientY-n.y)))},l=e=>{t.size===0&&(n=e.pointerType,r=e.timeStamp,i=0,a=0,o=!1),t.set(e.pointerId,{x:e.clientX,y:e.clientY}),i=Math.max(i,t.size)},u=e=>c(e),d=e=>{if(!t.has(e.pointerId)||(c(e),e.type===`pointercancel`&&(o=!0),t.delete(e.pointerId),t.size>0))return;let l=n===`mouse`;s=!o&&i===1&&a<=(l?wB:TB)&&(l||e.timeStamp-r<=EB)},f={capture:!0,passive:!0};return e.addEventListener(`pointerdown`,l,f),e.addEventListener(`pointermove`,u,f),e.addEventListener(`pointerup`,d,f),e.addEventListener(`pointercancel`,d,f),{wasTap:()=>s,pointerType:()=>n,dispose:()=>{e.removeEventListener(`pointerdown`,l,f),e.removeEventListener(`pointermove`,u,f),e.removeEventListener(`pointerup`,d,f),e.removeEventListener(`pointercancel`,d,f)}}}function OB(e,t,n){let r=new gD({antialias:t.render.antialias,canvas:e,alpha:!0,powerPreference:`high-performance`,preserveDrawingBuffer:t.render.preserveDrawingBuffer,logarithmicDepthBuffer:!1}),i=e.parentElement,a=i?i.clientWidth:window.innerWidth,o=i?i.clientHeight:window.innerHeight;return i&&(e.style.width=`100%`,e.style.height=`100%`,e.style.display=`block`),r.setSize(a,o,!1),r.setPixelRatio(n),t.render.enableShadows&&(r.shadowMap.enabled=!0,r.shadowMap.type=3),r.toneMapping=t.render.toneMapping,r.toneMappingExposure=t.render.toneMappingExposure??1,r.outputColorSpace=F_,r.sortObjects=!0,r}var kB=function(e,t){let n=$I(t||{}),r=n.environment?.sceneUp||ZI,i=n.render.pixelRatio??Math.min(window.devicePixelRatio,2),a=qz(i,SD(n.look,n.render.lowPower));n.render.pixelRatio=a;let o=Xz(n),s=Yz(n,e);s.up.copy(r);let c=OB(e,n,a);ND(c.capabilities.getMaxAnisotropy()),t?.onMaxAnisotropy?.(c.capabilities.getMaxAnisotropy());let l=sB(s,e,n),u=wL({scene:o,perspective:s,controls:l,onActiveCameraChange:()=>{},up:r}),d=()=>u.getActiveCamera(),f=!1;cB(o,c,n,()=>f);let p=dL(o,n),m=p.sun,h=()=>{m&&pL(m,yL(o))};n.floor?.enabled&&lB(o,n);let g=n.floor?.enabled?o.children.find(e=>e.userData.id===`floor`)??null:null,_=n.grid.enabled?LR({cellSize:n.grid.cellSize,majorEvery:n.grid.majorEvery,cellColor:n.grid.cellColor,majorColor:n.grid.majorColor,fadeDistance:n.grid.fadeDistance,plane:n.grid.plane}):null;_&&o.add(_.object);let v=()=>{_&&_.fitToContent(yL(o))},y=n.gizmo.enabled?wz({camera:s,domElement:e,controller:u}):null,b=n.grid.plane??XI(r),x=new Z(+(b===`x`),+(b===`y`),+(b===`z`)),S=r.clone().normalize(),C=n.camera.dynamicNear?_z({camera:s,scene:o,groundNormals:()=>{let e=[];return _?.object.visible&&e.push(x),n.floor.enabled&&g?.visible&&e.push(S),e}}):null,w=RR(e.parentElement??e,o),T=n.measure.enabled?dz({canvas:e,scene:o,getActiveCamera:d,getViewTarget:()=>l.target,requestRender:()=>j(),labelLayer:w,options:{snapPixels:n.measure.snapPixels,color:n.measure.color,labelClassName:n.measure.labelClassName,displayUnit:n.measure.displayUnit,format:n.measure.format}}):null,E=DB(e),D=n.events.enableEventHandlers===!1?{dispose:()=>{},fitToView:()=>{},clearSelection:()=>{},selectEntries:()=>{},setHover:()=>{}}:CB(e,o,u,n,E),O=Cz();T&&O.register({id:`measure`,tool:T,priority:0}),y&&O.register({id:`gizmo`,tool:y,priority:-100});let k=e=>{E.wasTap()&&O.handleClick(e)&&e.stopImmediatePropagation()};e.addEventListener(`click`,k,{capture:!0});let A=e=>O.handleMove(e);e.addEventListener(`mousemove`,A,{passive:!0});let j=()=>{},M=(e,t)=>{MR(e,{color:n.edges.color,darken:n.edges.darken,width:n.edges.width,thresholdAngle:n.edges.thresholdAngle,distanceFade:n.edges.distanceFade,maxTriangles:n.edges.maxTriangles,maxSegments:n.edges.maxSegments,maxOverlays:n.edges.maxOverlays,...t}).then(()=>{N(e),j()})},N=e=>{if(n.edges.screenSpaceFallback===!1)return;let t=!1;e.traverse(e=>{let n=e.userData?.edgesSkipped;(n===`triangle-cap`||n===`overlay-budget`)&&(t=!0)}),ne.setEdgeFallback(t)},P=e=>{NR(e),ne.setEdgeFallback(!1),j()},ee=e.parentElement,te=()=>ee?{width:ee.clientWidth,height:ee.clientHeight}:{width:window.innerWidth,height:window.innerHeight},ne=oB({renderer:c,scene:o,getActiveCamera:d,getCanvasSize:te,config:n,requestRender:()=>j()});ne.sync();let re=Jz({scene:o,renderer:c,lights:p,config:n,pipeline:ne,fullPixelRatio:i,requestRender:()=>j()}),ie,ae=aL({scene:o,renderer:c,getPipeline:()=>ne.get(),frames:n.render.idleRefineFrames,lightOrbitFrameMs:n.render.lightOrbitFrameMs,jitterLights:e=>{m&&(ie=fL(m,e)),re.jitterEmissiveLights(e)},restoreLights:()=>{ie?.(),re.settleEmissiveLights()}}),{animate:oe,dispose:se,invalidate:ce,renderNow:le}=Tz(c,o,s,d,u,l,te,()=>n.render.pixelRatio,n.events.onFrame,_,y,()=>ne.get(),w,C,n.render.onDemand??!0,ae);return j=ce,oe(),o.up.set(r.x,r.y,r.z),h(),v(),{scene:o,camera:s,controls:l,renderer:c,cameraController:u,grid:_,gizmo:y,measureTool:T,labelLayer:w,tools:O,applyEdges:M,clearEdges:P,invalidate:ce,captureImage:(e=`image/png`,t)=>(le(),new Promise(n=>c.domElement.toBlob(n,e,t))),setAmbientOcclusion:ne.setAmbientOcclusion,setLook:re.setLook,syncEmissiveLights:re.syncEmissiveLights,setFillLights:re.setFillLights,setEnvironmentIntensity:re.setEnvironmentIntensity,setToneMappingExposure:re.setToneMappingExposure,setAoIntensity:re.setAoIntensity,getMaterialAppearance:re.getMaterialAppearance,updateShadowBounds:h,updateGridScale:v,dispose:()=>{f||(f=!0,se(),D.dispose(),E.dispose(),e.removeEventListener(`click`,k,{capture:!0}),e.removeEventListener(`mousemove`,A),T?.dispose(),w?.dispose(),y?.dispose(),_?.dispose(),ne.dispose(),u.dispose(),l.dispose(),c.dispose(),c.forceContextLoss(),Zz(o))},fitToView:D.fitToView,clearSelection:D.clearSelection,selectEntries:e=>{D.selectEntries(e),ce()},setHover:(e,t)=>{D.setHover(e,t),ce()},addUserGeometry:(e,t)=>{e.userData.source=t===void 0?bI:SI(t),o.add(e),j()},removeUserGeometry:e=>{e.removeFromParent(),BD(e),j()},clearUserGeometry:e=>{o.children.filter(t=>TI(t,e)).forEach(e=>{e.removeFromParent(),BD(e)}),j()}}},AB=`selva/solve-view`;function jB(e){e&&(e.theme&&Zh(e.theme),e.styles?.variables&&Qh(e.styles.variables),e.styles?.css?.fonts&&$h(e.styles.css.fonts))}async function MB(e,t){let n=new tg(e);return n.addEventListener(`hostcontextchanged`,jB),t?.(n),await n.connect(),jB(n.getHostContext()),n}function NB(e){return(e.content??[]).flatMap(e=>{let t=e;return t.type===`text`&&t.text?[t.text]:[]}).join(`
|
|
6179
|
+
`)}function PB(e){return e._meta?.[AB]}async function FB(e,t){if(t.response!==void 0)return t.response;if(!t.load)return;let n=await e.callServerTool({name:t.load.tool,arguments:t.load.arguments??{}});if(n.isError)throw Error(NB(n)||`${t.load.tool} failed`);return PB(n)?.response}function IB(e){return yI.includes(e)?e:`technical`}function LB(e,t={}){let n=document.createElement(`canvas`);n.style.cssText=`display:block;width:100%;height:100%;touch-action:none`,e.append(n);let r=IB(t.look),i=kB(n,{look:r,onMaxAnisotropy:TA,environment:{hdrPath:!1,...t.background&&{backgroundColor:t.background}}}),a=!1,o=()=>{i.updateShadowBounds(),i.syncEmissiveLights(),i.invalidate()};return{async show(e){let n=await qj(e,{parsing:{material:i.getMaterialAppearance()}});return hL(i.scene,n,i.camera,i.controls,a),!a&&n.length>0&&t.camera&&i.cameraController.setCameraView(t.camera),a||=n.length>0,i.setLook(r,{deferEmissiveLights:!0}),i.updateGridScale(),o(),n.length},setLook(e){r=e,i.setLook(e),o()},redraw:()=>i.invalidate(),fitToView:()=>i.fitToView(),dispose(){i.dispose(),xj(),n.remove()}}}function RB(e,t,n){e.replaceChildren();let r=[],i=[];for(let n of t.inputs){let t=document.createElement(`label`);t.className=`field`;let a=document.createElement(`span`);a.className=`name`,a.textContent=n.unit?`${n.name} (${n.unit})`:n.name,n.description&&(t.title=n.description),t.append(a);let o;if(n.kind===`choice`){let e=document.createElement(`select`);typeof n.value!=`string`&&e.add(new Option(``,``));for(let t of n.options??[])e.add(new Option(t,t));e.value=typeof n.value==`string`?n.value:``,o=e,r.push(()=>e.value===``?void 0:[n.name,e.value])}else if(n.kind===`boolean`){let e=document.createElement(`input`);e.type=`checkbox`,e.checked=n.value===!0,o=e,r.push(()=>[n.name,e.checked]),t.classList.add(`inline`)}else{let e=document.createElement(`input`);e.type=n.kind===`number`?`number`:`text`,n.min!==void 0&&(e.min=String(n.min)),n.max!==void 0&&(e.max=String(n.max)),e.step=n.step===void 0?`any`:String(n.step);let t=n.value!==void 0&&n.value!==null?String(n.value):``;e.value=t,o=e,r.push(()=>n.kind===`number`?e.value===``?void 0:[n.name,Number(e.value)]:e.value===``&&t===``?void 0:[n.name,e.value])}i.push(o),t.append(o),e.append(t)}let a=document.createElement(`button`);a.type=`button`,a.className=`solve`,a.textContent=`Solve`,i.push(a),e.append(a);let o=()=>Object.fromEntries(r.map(e=>e()).filter(e=>e!==void 0));return a.addEventListener(`click`,()=>n(o())),e.addEventListener(`keydown`,e=>{e.key===`Enter`&&!a.disabled&&n(o())}),{values:o,setBusy(e){for(let t of i)t.disabled=e;a.textContent=e?`Solving…`:`Solve`}}}var zB=e=>document.getElementById(e),BB=zB(`title`),VB=zB(`status`),HB=VB.querySelector(`span`),UB=zB(`fit`),WB=zB(`fullscreen`),GB=zB(`form`),KB=zB(`inputs`),qB=zB(`look`);for(let e of yI)qB.add(new Option(e[0].toUpperCase()+e.slice(1),e));var JB=e=>{HB.textContent=e,VB.hidden=e===``},YB=e=>e instanceof Error?e.message:String(e),XB=`selva-solve-view:inputs`,ZB=!0;try{ZB=localStorage.getItem(XB)!==`hidden`}catch{}var QB,$B=!1,eV=0,tV=await MB({name:`Selva solve view`,version:`1.0.0`},e=>e.addEventListener(`toolresult`,t=>void nV(e,t)));async function nV(e,t){let n=++eV,r=()=>n===eV,i=PB(t);if(BB.textContent=i?.title??``,i?.form&&rV(e,i.form),t.isError)JB(NB(t)||`The solve failed.`);else if(!i)JB(NB(t)||`This result has no geometry.`);else{JB(`Loading geometry…`);try{let t=await FB(e,i);if(!r())return;if(t===void 0){JB(`This result has no geometry.`);return}$B||(qB.value=IB(i.look)),QB??=LB(zB(`stage`),{look:qB.value,background:i.background,camera:i.camera});let n=await QB.show(t);if(!r())return;JB(n>0?``:`The solve drew nothing.`),UB.hidden=n===0,qB.hidden=n===0}catch(e){r()&&JB(`Could not draw the solve: ${YB(e)}`)}}}function rV(e,t){KB.hidden=t.inputs.length===0,GB.hidden=t.inputs.length===0||!ZB;let n=RB(GB,t,r=>{n.setBusy(!0),JB(`Solving…`),e.callServerTool({name:t.tool,arguments:{...t.arguments,[t.valuesKey]:r}}).then(async t=>{await nV(e,t);let n=NB(t);await e.updateModelContext({content:[{type:`text`,text:`The user solved again from the 3D view with ${JSON.stringify(r)}.\n${n}`}]}).catch(()=>{})}).catch(e=>JB(`Could not solve: ${YB(e)}`)).finally(()=>n.setBusy(!1))})}UB.addEventListener(`click`,()=>QB?.fitToView());var iV=e=>{ZB=e,GB.hidden=!e||GB.childElementCount===0,KB.setAttribute(`aria-pressed`,String(e)),KB.textContent=e?`Hide inputs`:`Show inputs`,QB?.redraw()};iV(ZB),KB.addEventListener(`click`,()=>{iV(!ZB);try{localStorage.setItem(XB,ZB?`shown`:`hidden`)}catch{}}),qB.addEventListener(`change`,()=>{$B=!0,QB?.setLook(IB(qB.value))});var aV=e=>{document.body.classList.toggle(`fullscreen`,e===`fullscreen`),WB.textContent=e===`fullscreen`?`Exit fullscreen`:`Fullscreen`},oV=()=>{let e=tV.getHostContext();WB.hidden=!(e?.availableDisplayModes??[]).includes(`fullscreen`),e?.displayMode&&aV(e.displayMode)};oV(),tV.addEventListener(`hostcontextchanged`,oV),WB.addEventListener(`click`,()=>{let e=document.body.classList.contains(`fullscreen`)?`inline`:`fullscreen`;tV.requestDisplayMode({mode:e}).then(({mode:e})=>aV(e),e=>JB(`Could not change the display: ${YB(e)}`))});</script>
|
|
6180
6180
|
</head>
|
|
6181
6181
|
<body>
|
|
6182
6182
|
<header>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@selvajs/mcp",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.5",
|
|
4
4
|
"description": "MCP server machinery for Selva hosts: tools over a host's /api/v1, with key auth, error mapping and annotations from its OpenAPI document",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "VektorNode",
|
|
@@ -66,14 +66,14 @@
|
|
|
66
66
|
"vite-plugin-singlefile": "^2.3.4",
|
|
67
67
|
"vitest": "^5.0.5",
|
|
68
68
|
"@selvajs/config": "0.0.4",
|
|
69
|
-
"@selvajs/visualization": "1.8.0-beta.
|
|
69
|
+
"@selvajs/visualization": "1.8.0-beta.6",
|
|
70
70
|
"@selvajs/server": "3.0.0-beta.14"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"@modelcontextprotocol/ext-apps": "^2.0.4",
|
|
74
74
|
"playwright-core": "^1.64.1",
|
|
75
75
|
"three": ">=0.179.0",
|
|
76
|
-
"@selvajs/visualization": "^1.8.0-beta.
|
|
76
|
+
"@selvajs/visualization": "^1.8.0-beta.6"
|
|
77
77
|
},
|
|
78
78
|
"peerDependenciesMeta": {
|
|
79
79
|
"@modelcontextprotocol/ext-apps": {
|