efficient-shell 16.3.0 → 16.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/{Browser-FO7ICGJP.js → Browser-UMVLMXZ2.js} +13 -13
  2. package/dist/{Files-XUGJSFME.js → Files-EQXMKPJF.js} +28 -28
  3. package/dist/{Notepad-Q3YNHSWM.js → Notepad-CK5LKAVY.js} +6 -6
  4. package/dist/{Preview-56C2XB7V.js → Preview-WD7WYHFF.js} +11 -11
  5. package/dist/apps/index.js +1 -1
  6. package/dist/attributes-CseTvqC-.d.ts +49 -0
  7. package/dist/bin/browser-check.js +1 -1
  8. package/dist/bin/media-host-check.js +1 -1
  9. package/dist/bin/ui-check.js +1 -1
  10. package/dist/chunk-4N24K3UX.js +1 -0
  11. package/dist/{chunk-5L7II37P.js → chunk-5MJO7RMB.js} +3 -3
  12. package/dist/chunk-74SCWPQF.js +1 -0
  13. package/dist/chunk-7TGDGFHO.js +1 -0
  14. package/dist/{chunk-HOSLX3ST.js → chunk-B2AKIOF3.js} +2 -2
  15. package/dist/chunk-KT57MRN4.js +1 -0
  16. package/dist/chunk-OMOAD5LL.js +1 -0
  17. package/dist/{chunk-EF75NNOR.js → chunk-UBUOPMCR.js} +1 -1
  18. package/dist/chunk-WS4C6Z22.js +1 -0
  19. package/dist/engine-T4D3AZOO.js +1 -0
  20. package/dist/forms/MediaLibrary.js +1 -1
  21. package/dist/icons/brands.node.js +1 -1
  22. package/dist/icons/efficient-glyphs.js +1 -1
  23. package/dist/icons/efficient-looks.js +1 -1
  24. package/dist/icons/efficient.js +1 -1
  25. package/dist/icons/looks/map.js +1 -1
  26. package/dist/icons/sets.js +1 -1
  27. package/dist/index.js +82 -82
  28. package/dist/model-stage/index.d.ts +154 -0
  29. package/dist/model-stage/index.js +4 -0
  30. package/dist/model-viewer/index.d.ts +3 -49
  31. package/dist/model-viewer/index.js +6 -6
  32. package/dist/routine-index.json +1 -1
  33. package/dist/telemetry/index.js +1 -1
  34. package/dist/ui/index.js +1 -1
  35. package/dist/value-index.json +1 -1
  36. package/dist/version.js +1 -1
  37. package/package.json +13 -3
  38. package/dist/chunk-CLFXMTD2.js +0 -1
  39. package/dist/chunk-EV5BEEVO.js +0 -1
  40. package/dist/chunk-FHNQC2MA.js +0 -1
@@ -0,0 +1,154 @@
1
+ import * as react from 'react';
2
+ export { f as fieldOfViewFor } from '../attributes-CseTvqC-.js';
3
+
4
+ /**
5
+ * Where the stage's camera sits: orbit angles to a position, the distance
6
+ * that frames a model through a given lens, and the lens itself. Pure.
7
+ *
8
+ * Angles follow `efficient-shell/model-viewer`'s convention, so a design's
9
+ * saved angles mean the same on either: `theta` round the model (0 = in
10
+ * front, positive = the camera to the right), `phi` down from straight above
11
+ * (90 = level, above 90 = below the model).
12
+ */
13
+
14
+ interface Orbit {
15
+ theta: number;
16
+ phi: number;
17
+ }
18
+ /** A turn folded into -180…180: dragging round keeps adding up. */
19
+ declare function wrapTurn(theta: number): number;
20
+ /** The camera offset from the target for an orbit, at `distance`. +Y is up,
21
+ * +Z is in front (the model's face looks along +Z). */
22
+ declare function orbitOffset({ theta, phi }: Orbit, distance: number): [number, number, number];
23
+ /** The orbit of a camera offset (the inverse of `orbitOffset`). */
24
+ declare function orbitOf([x, y, z]: readonly [number, number, number]): Orbit;
25
+ /** The camera distance that fits a sphere of `radius` in a square frame seen
26
+ * through a vertical field of view `fovDeg`, with `margin` to spare. */
27
+ declare function framingDistance(radius: number, fovDeg: number, margin?: number): number;
28
+ /** The shortest way from one orbit to another: `to` with its theta moved by
29
+ * whole turns to within half a turn of `from`. */
30
+ declare function shortestOrbit(from: Orbit, to: Orbit): Orbit;
31
+
32
+ /**
33
+ * The model stage's public shapes, kept apart from the engine so a host's
34
+ * types never reach three.js (an optional peer a host may not have types for).
35
+ */
36
+
37
+ type StageEnvironment = 'studio' | 'daylight' | 'showroom' | 'garage';
38
+ type StageBackground = 'white' | 'light' | 'mid' | 'dark' | 'transparent';
39
+ /** One layer's look, already resolved to PBR numbers by the host. */
40
+ interface StageMaterial {
41
+ color: string;
42
+ metallic: number;
43
+ roughness: number;
44
+ clearcoat?: number;
45
+ clearcoatRoughness?: number;
46
+ }
47
+ interface StageScene {
48
+ environment: StageEnvironment;
49
+ /** Degrees, 0–359. */
50
+ environmentRotation: number;
51
+ /** Percent, 50–150. */
52
+ brightness: number;
53
+ background: StageBackground;
54
+ groundShadow: boolean;
55
+ /** Percent, 0–100. */
56
+ shadowSoftness: number;
57
+ groundReflection: boolean;
58
+ /** 35 mm-equivalent focal length, mm. */
59
+ focalLength: number;
60
+ }
61
+ interface StageCamera extends Orbit {
62
+ userInteraction: boolean;
63
+ }
64
+
65
+ /** Where a stage is: fetching three.js or the model, drawing it, or showing
66
+ * its fallback (no WebGL, or the model failed to load). */
67
+ type ModelStageStatus = 'loading' | 'ready' | 'still' | 'failed';
68
+ interface ModelStageProps {
69
+ /** A surface model: a meshopt GLB whose vertices carry `_SURFACE`. */
70
+ src: string;
71
+ /** How many CAD surfaces it has (its manifest's `surface_count`). */
72
+ surfaceCount: number;
73
+ /** What the model is, for a screen reader. */
74
+ alt: string;
75
+ /** The layers in draw order — each the surface ids it covers — with the
76
+ * LAST being Rest (every surface the others leave; its own list is not
77
+ * read). Pass a new array when membership changes. */
78
+ layers: readonly (readonly number[])[];
79
+ /** One look per layer, same order. */
80
+ materials: readonly StageMaterial[];
81
+ /** Surfaces drawn highlighted (a selection in progress). */
82
+ selected?: ReadonlySet<number>;
83
+ scene: StageScene;
84
+ /** The camera's starting orbit. */
85
+ initialOrbit: Orbit;
86
+ /** Drag to turn and scroll to zoom; off, only `goTo` moves the camera. */
87
+ interactive?: boolean;
88
+ /** Click picks surfaces (`onPickSurface`) instead of nothing. */
89
+ selectMode?: boolean;
90
+ /** Turn slowly, round and round. */
91
+ turntable?: boolean;
92
+ onPickSurface?: (surface: number | null, event: {
93
+ shiftKey: boolean;
94
+ }) => void;
95
+ onCameraChange?: (camera: StageCamera) => void;
96
+ onStatusChange?: (status: ModelStageStatus) => void;
97
+ className?: string;
98
+ }
99
+ /** What a host can ask of a stage it holds a ref to. */
100
+ interface ModelStageHandle {
101
+ /** Turn to an orbit from a clean start: centred, zoom back to the lens,
102
+ * the short way round. */
103
+ goTo(orbit: Orbit, animate?: boolean): void;
104
+ /** A square PNG of the current view at `size` pixels. */
105
+ renderImage(size: number, options?: {
106
+ transparent?: boolean;
107
+ }): Promise<Blob>;
108
+ }
109
+ /**
110
+ * The live configurator's 3D stage: a surface model whose CAD surfaces are
111
+ * painted by layer, picked by click, lit by a studio scene and exported as
112
+ * PNG — on three.js, fetched only when a stage mounts. With no WebGL the
113
+ * engine is never fetched and the stage says why.
114
+ */
115
+ declare const ModelStage: react.ForwardRefExoticComponent<ModelStageProps & react.RefAttributes<ModelStageHandle>>;
116
+
117
+ /**
118
+ * Turning a surface model's per-vertex surface ids into draw groups: one
119
+ * group per (layer, selected) pair, so the whole wheel is one geometry drawn
120
+ * with one material per layer and a highlighted twin of each for the
121
+ * surfaces a person has selected. Pure, so a spec checks it without a GPU.
122
+ *
123
+ * A surface model (backend `products/visualizer_convert.py`) carries the id
124
+ * of its CAD surface on every vertex (`_SURFACE`); every vertex of a
125
+ * triangle is on the same surface, so a triangle's surface is its first
126
+ * vertex's.
127
+ */
128
+ /** The surface of each triangle. `index` null = a non-indexed geometry. */
129
+ declare function triangleSurfaces(surfaceOfVertex: ArrayLike<number>, index: ArrayLike<number> | null, triangleCount: number): Int32Array;
130
+ /**
131
+ * The layer index of every surface: each layer's ids claim their surfaces in
132
+ * order (a surface named twice keeps its first layer), and a surface no
133
+ * layer names goes to `restIndex`.
134
+ */
135
+ declare function layerOfSurfaces(surfaceCount: number, layers: readonly (readonly number[])[], restIndex: number): Int32Array;
136
+ interface DrawGroup {
137
+ /** First index (triangle × 3) of the group in the rebuilt index buffer. */
138
+ start: number;
139
+ /** Indices in the group (triangles × 3). */
140
+ count: number;
141
+ /** `layer * 2`, plus 1 for the selected twin. */
142
+ materialIndex: number;
143
+ }
144
+ /**
145
+ * The index buffer reordered so each (layer, selected) run is contiguous,
146
+ * and the groups over it. `index` null = a non-indexed geometry (vertex
147
+ * `3t, 3t+1, 3t+2` per triangle).
148
+ */
149
+ declare function buildDrawGroups(index: ArrayLike<number> | null, triSurface: Int32Array, layerOfSurface: Int32Array, selected: ReadonlySet<number>, layerCount: number): {
150
+ index: Uint32Array;
151
+ groups: DrawGroup[];
152
+ };
153
+
154
+ export { type DrawGroup, ModelStage, type ModelStageHandle, type ModelStageProps, type ModelStageStatus, type Orbit, type StageBackground, type StageCamera, type StageEnvironment, type StageMaterial, type StageScene, buildDrawGroups, framingDistance, layerOfSurfaces, orbitOf, orbitOffset, shortestOrbit, triangleSurfaces, wrapTurn };
@@ -0,0 +1,4 @@
1
+ "use client";
2
+ export{buildDrawGroups,framingDistance,layerOfSurfaces,orbitOf,orbitOffset,shortestOrbit,triangleSurfaces,wrapTurn}from"../chunk-KT57MRN4.js";import{webglAvailable as e}from"../chunk-WS4C6Z22.js";export{fieldOfViewFor}from"../chunk-4N24K3UX.js";import{useShellStrings as r}from"../chunk-NRHG4R2Q.js";import"../chunk-C3QOHMR6.js";import{forwardRef as t,useRef as n,useState as i,useEffect as a,useImperativeHandle as o}from"react";import{jsxs as c,jsx as l}from"react/jsx-runtime";var s=(...e)=>e.filter(Boolean).join(" "),u=t(function({src:t,surfaceCount:u,alt:d,layers:f,materials:m,selected:g,scene:h,initialOrbit:p,interactive:b=!0,selectMode:C=!1,turntable:v=!1,onPickSurface:S,onCameraChange:O,onStatusChange:w,className:k},y){const j=r().modelViewer,x=n(null),M=n(null),N=n(null),[T,E]=i("loading"),[L,P]=i(!1),R=n({onPickSurface:S,onCameraChange:O,onStatusChange:w,selectMode:C,initialOrbit:p});R.current={onPickSurface:S,onCameraChange:O,onStatusChange:w,selectMode:C,initialOrbit:p};const K=n(/* @__PURE__ */new Set);a(()=>{R.current.onStatusChange?.(T)},[T]),o(y,()=>({goTo(e,r=!0){N.current?.goTo(e,r)},renderImage:(e,r)=>N.current?N.current.renderImage(e,Boolean(r?.transparent)):Promise.reject(new Error(j.loading))}),[j.loading]),a(()=>{if(!e())return void E("still");let r=!0,t=null;return import("../engine-T4D3AZOO.js").then(({StageEngine:e})=>{r&&M.current&&(t=new e(M.current),t.onCameraChange=e=>R.current.onCameraChange?.(e),N.current=t,P(!0))}).catch(()=>{r&&E("failed")}),()=>{r=!1,t?.dispose(),N.current=null}},[]),a(()=>{const e=x.current;if(!L||!e)return;const r=()=>N.current?.resize(e.clientWidth,e.clientHeight);r();const t=new ResizeObserver(r);return t.observe(e),()=>t.disconnect()},[L]),a(()=>{const e=N.current;if(!L||!e)return;let r=!0;return E("loading"),e.load(t,u).then(()=>{r&&(e.goTo(R.current.initialOrbit,!1),E("ready"))}).catch(()=>{r&&E("failed")}),()=>{r=!1}},[L,t,u]),a(()=>{L&&N.current?.setLayers(f,m,g??K.current)},[L,T,f,m,g]),a(()=>{L&&N.current?.setScene(h)},[L,T,h]),a(()=>{L&&N.current?.setInteractive(b)},[L,b]),a(()=>{L&&N.current?.setTurntable(v)},[L,v]),a(()=>{const e=M.current;if(!L||!e)return;let r=null;const t=e=>{r={x:e.clientX,y:e.clientY}},n=e=>{if(!r||!R.current.selectMode)return;const t=Math.hypot(e.clientX-r.x,e.clientY-r.y);r=null,t>4||R.current.onPickSurface?.(N.current?.pick(e.clientX,e.clientY)??null,{shiftKey:e.shiftKey})};return e.addEventListener("pointerdown",t),e.addEventListener("pointerup",n),()=>{e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",n)}},[L]);const X="still"===T||"failed"===T;/* @__PURE__ */
3
+ return c("div",{ref:x,className:s("relative overflow-hidden",k),"data-model-stage":T,children:[
4
+ /* @__PURE__ */l("canvas",{ref:M,role:"img","aria-label":d,className:s("absolute inset-0 h-full w-full",C?"cursor-crosshair":b&&"cursor-grab"),hidden:X}),"loading"===T&&/* @__PURE__ */l("p",{role:"status",className:"sr-only",children:j.loading}),X&&/* @__PURE__ */l("p",{className:"absolute inset-0 grid place-items-center p-4 text-center text-sm text-ink-faint",children:"still"===T?j.noWebgl:j.failed})]})});export{u as ModelStage};
@@ -1,52 +1,6 @@
1
1
  import * as react from 'react';
2
-
3
- /**
4
- * The `<model-viewer>` attributes a `ModelViewer` sets, from its props. Pure,
5
- * so a spec can check them without a browser that draws.
6
- */
7
- /**
8
- * The light a model is shown in. `studio` is soft and even — the product-render
9
- * look — `daylight` brighter and warmer, `showroom` bright with harder shadows. Each is model-viewer's own
10
- * built-in environment, so no picture is fetched from anywhere.
11
- */
12
- type ModelViewerLighting = 'studio' | 'daylight' | 'showroom';
13
- declare const MODEL_VIEWER_LIGHTING: Record<ModelViewerLighting, {
14
- environment: 'neutral' | 'legacy';
15
- exposure: string;
16
- shadowIntensity: string;
17
- shadowSoftness: string;
18
- /** Khronos PBR Neutral keeps a product's colours true; AgX rolls bright
19
- * highlights off the way film does. */
20
- toneMapping: 'neutral' | 'agx';
21
- }>;
22
- interface ModelViewerAttributeProps {
23
- src: string;
24
- alt: string;
25
- poster?: string | null;
26
- autoRotate?: boolean;
27
- cameraOrbit?: string;
28
- /** The closest the camera may turn, model-viewer's `min-camera-orbit`,
29
- * e.g. `'auto 20deg auto'` keeps it from going over the top. */
30
- minCameraOrbit?: string;
31
- /** The furthest it may turn, `max-camera-orbit`, e.g. `'auto 100deg auto'`
32
- * keeps it from going underneath. */
33
- maxCameraOrbit?: string;
34
- lighting?: ModelViewerLighting;
35
- /** The lens, as a 35 mm-equivalent focal length in millimetres: 50 is a
36
- * normal lens, 200 a telephoto with little perspective distortion (the
37
- * product-shot look). Sets model-viewer's `field-of-view`, and lets zoom
38
- * run from four times closer to two and a half times further out. Default: model-viewer's. */
39
- focalLength?: number;
40
- /** Keep the model centred: a right-click or two-finger drag no longer
41
- * slides it across the frame. Turning and zooming still work. */
42
- disablePan?: boolean;
43
- /** Let a person drag to turn and scroll to zoom. On by default; off, the
44
- * camera moves only when the host turns it (a set of fixed angles). */
45
- cameraControls?: boolean;
46
- }
47
- /** The vertical field of view, in degrees, of a 35 mm-equivalent focal length. */
48
- declare function fieldOfViewFor(focalLengthMm: number): number;
49
- declare function modelViewerAttributes(props: ModelViewerAttributeProps): Record<string, string>;
2
+ import { M as ModelViewerLighting } from '../attributes-CseTvqC-.js';
3
+ export { a as MODEL_VIEWER_LIGHTING, b as ModelViewerAttributeProps, f as fieldOfViewFor, m as modelViewerAttributes } from '../attributes-CseTvqC-.js';
50
4
 
51
5
  /**
52
6
  * Recolouring a loaded model's materials by name — what a configurator does
@@ -226,4 +180,4 @@ declare const MODEL_VIEWER_CSP_SOURCES: {
226
180
  readonly script: readonly ["'wasm-unsafe-eval'"];
227
181
  };
228
182
 
229
- export { type LoadModelViewerOptions, MODEL_VIEWER_CSP_SOURCES, MODEL_VIEWER_DECODER_ORIGIN, MODEL_VIEWER_DRACO_DECODER_URL, MODEL_VIEWER_LIGHTING, ModelViewer, type ModelViewerAttributeProps, type ModelViewerCamera, type ModelViewerHandle, type ModelViewerLighting, type ModelViewerMaterial, type ModelViewerMaterials, type ModelViewerProps, type ModelViewerStatus, type SceneMaterial, applyMaterials, arQuickLookSupported, fieldOfViewFor, loadModelViewer, modelViewerAttributes, openArQuickLook, webglAvailable };
183
+ export { type LoadModelViewerOptions, MODEL_VIEWER_CSP_SOURCES, MODEL_VIEWER_DECODER_ORIGIN, MODEL_VIEWER_DRACO_DECODER_URL, ModelViewer, type ModelViewerCamera, type ModelViewerHandle, ModelViewerLighting, type ModelViewerMaterial, type ModelViewerMaterials, type ModelViewerProps, type ModelViewerStatus, type SceneMaterial, applyMaterials, arQuickLookSupported, loadModelViewer, openArQuickLook, webglAvailable };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
- import{useShellStrings as e}from"../chunk-NRHG4R2Q.js";import"../chunk-C3QOHMR6.js";import{forwardRef as t,useRef as r,useImperativeHandle as a,useState as n,useEffect as o}from"react";import{jsxs as i,jsx as s}from"react/jsx-runtime";var l={studio:{environment:"neutral",exposure:"1.1",shadowIntensity:"1",shadowSoftness:"1",toneMapping:"neutral"},daylight:{environment:"legacy",exposure:"1",shadowIntensity:"1",shadowSoftness:"0.8",toneMapping:"agx"},showroom:{environment:"neutral",exposure:"1.4",shadowIntensity:"1.2",shadowSoftness:"0.4",toneMapping:"agx"}};function c(e){return 2*Math.atan(24/(2*e))*180/Math.PI}var m=e=>Math.round(100*e)/100+"deg",u=["src","alt","poster","camera-controls","touch-action","shadow-intensity","auto-rotate","camera-orbit","interaction-prompt","min-camera-orbit","max-camera-orbit","environment-image","exposure","shadow-softness","field-of-view","min-field-of-view","max-field-of-view","disable-pan","tone-mapping"];function d(e){const t={src:e.src,alt:e.alt,"shadow-intensity":"1"};if(!1!==e.cameraControls&&(t["camera-controls"]="",t["touch-action"]="pan-y",t["interaction-prompt"]="auto"),e.poster&&(t.poster=e.poster),e.autoRotate&&(t["auto-rotate"]=""),e.cameraOrbit&&(t["camera-orbit"]=e.cameraOrbit),e.minCameraOrbit&&(t["min-camera-orbit"]=e.minCameraOrbit),e.maxCameraOrbit&&(t["max-camera-orbit"]=e.maxCameraOrbit),e.focalLength&&e.focalLength>0){const r=c(e.focalLength);t["field-of-view"]=m(r),t["min-field-of-view"]=m(r/4),t["max-field-of-view"]=m(2.5*r)}if(e.disablePan&&(t["disable-pan"]=""),e.lighting){const r=l[e.lighting];t["environment-image"]=r.environment,t.exposure=r.exposure,t["shadow-intensity"]=r.shadowIntensity,t["shadow-softness"]=r.shadowSoftness,t["tone-mapping"]=r.toneMapping}return t}var h=e=>Math.min(1,Math.max(0,e)),f=/^#[0-9a-f]{6}$/i;function g(e,t){const r=[];for(const a of e){const e=t[a.name]??t["*"];e&&(f.test(e.color)&&a.pbrMetallicRoughness.setBaseColorFactor(e.color),a.pbrMetallicRoughness.setMetallicFactor(h(e.metallic)),a.pbrMetallicRoughness.setRoughnessFactor(h(e.roughness)),a.setClearcoatFactor?.(h(e.clearcoat??0)),a.setClearcoatRoughnessFactor?.(h(e.clearcoatRoughness??0)),r.push(a.name))}return r}var p="https://www.gstatic.com",b=`${p}/draco/versioned/decoders/1.5.6/`,v={connect:[p],worker:["blob:"],script:["'wasm-unsafe-eval'"]},w=null;function x(e={}){return w??=Promise.resolve().then(()=>{const t=globalThis;return t.ModelViewerElement={...t.ModelViewerElement,dracoDecoderLocation:e.dracoDecoderUrl??b},import("@google/model-viewer")}).then(()=>{}).catch(e=>{throw w=null,e}),w}var C=null;function y(e=globalThis.document){if(!e)return!1;if(null!==C&&e===globalThis.document)return C;let t=!1;try{const r=e.createElement("canvas");t=Boolean(r.getContext("webgl2")??r.getContext("webgl"))}catch{t=!1}return e===globalThis.document&&(C=t),t}var M=/CriOS\/|EdgiOS\/|FxiOS\/|GSA\/|DuckDuckGo\//;function O(e=globalThis.document){if(!e)return!1;const t=e.defaultView?.navigator;if(!t||!function(e){return/iPad|iPhone|iPod/.test(e.userAgent)||"MacIntel"===e.platform&&e.maxTouchPoints>1}(t))return!1;if(M.test(t.userAgent))return!0;const r=e.createElement("a");return Boolean(r.relList?.supports?.("ar"))}function P(e,t=globalThis.document){const r=t.createElement("a");r.setAttribute("rel","ar"),r.setAttribute("href",new URL(e,t.baseURI).toString()),r.style.display="none",r.appendChild(t.createElement("img")),t.body.appendChild(r);try{r.click()}finally{r.remove()}}var E=180/Math.PI,L=(...e)=>e.filter(Boolean).join(" "),R=t(function({src:t,alt:l,poster:c,autoRotate:m,cameraOrbit:h,minCameraOrbit:f,maxCameraOrbit:p,lighting:b,focalLength:v,disablePan:w,cameraControls:C,materials:M,onCameraChange:O,dracoDecoderUrl:P,className:R,onStatusChange:I},T){const A=e().modelViewer,S=r(null),j=r(null),N=r(O);N.current=O;const k=r(M);k.current=M,a(T,()=>({goTo(e){const t=j.current;if(!t)return;const r=t.getCameraOrbit?.(),a=/^(-?[\d.]+)deg\b/.exec(e.trim());if(r&&a&&t.jumpCameraToGoal){const e=parseFloat(a[1])*Math.PI/180,n=2*Math.PI,o=e+((r.theta-e)%n+n+Math.PI)%n-Math.PI;t.cameraOrbit=`${o}rad ${r.phi}rad ${r.radius}m`,t.jumpCameraToGoal()}t.cameraTarget="auto auto auto",t.fieldOfView=t.getAttribute("field-of-view")??"auto",t.cameraOrbit=e}}),[]);const[D,F]=n("loading"),[V,G]=n(!1),U=r(I);U.current=I,o(()=>{U.current?.(D)},[D]),o(()=>{if(!y())return void F("still");let e=!0;return x({dracoDecoderUrl:P}).then(()=>{e&&G(!0)}).catch(()=>{e&&F("failed")}),()=>{e=!1}},[]),o(()=>{const e=S.current;if(!V||!e)return;const t=e.ownerDocument.createElement("model-viewer");t.style.width="100%",t.style.height="100%",t.style.setProperty("--poster-color","transparent");const r=()=>{k.current&&t.model&&g(t.model.materials,k.current),F("ready")},a=()=>F("failed"),n=e=>{const r=t.getCameraOrbit?.();if(!r||!N.current)return;const a=e.detail?.source;N.current({theta:r.theta*E,phi:r.phi*E,userInteraction:"user-interaction"===a})};return t.addEventListener("load",r),t.addEventListener("error",a),t.addEventListener("camera-change",n),e.appendChild(t),j.current=t,()=>{t.removeEventListener("load",r),t.removeEventListener("error",a),t.removeEventListener("camera-change",n),t.remove(),j.current=null}},[V]),o(()=>{const e=j.current;if(!e)return;const r=d({src:t,alt:l,poster:c,autoRotate:m,cameraOrbit:h,minCameraOrbit:f,maxCameraOrbit:p,lighting:b,focalLength:v,disablePan:w,cameraControls:C});for(const t of u)t in r||e.removeAttribute(t);const a=e.getAttribute("src")!==r.src;for(const[t,a]of Object.entries(r))e.getAttribute(t)!==a&&e.setAttribute(t,a);a&&F("loading")},[V,t,l,c,m,h,f,p,b,v,w,C]),o(()=>{const e=j.current;"ready"===D&&e?.model&&M&&g(e.model.materials,M)},[D,M]);const $="still"===D||"failed"===D;/* @__PURE__ */
3
- return i("div",{className:L("relative overflow-hidden rounded-lg border border-line bg-surface",R),"data-model-viewer":D,children:[
4
- /* @__PURE__ */s("div",{ref:S,className:"absolute inset-0",hidden:$}),"loading"===D&&c&&
5
- /* @__PURE__ */s("img",{src:c,alt:"",className:"pointer-events-none absolute inset-0 h-full w-full object-contain"}),"loading"===D&&/* @__PURE__ */s("p",{role:"status",className:"sr-only",children:A.loading}),$&&
6
- /* @__PURE__ */i("div",{className:"absolute inset-0 flex flex-col",children:[c&&/* @__PURE__ */s("img",{src:c,alt:l,className:"min-h-0 w-full flex-1 object-contain"}),
7
- /* @__PURE__ */s("p",{className:L("shrink-0 p-4 text-center text-sm text-ink-faint",!c&&"grid flex-1 place-items-center"),children:"still"===D?A.noWebgl:A.failed})]})]})});export{v as MODEL_VIEWER_CSP_SOURCES,p as MODEL_VIEWER_DECODER_ORIGIN,b as MODEL_VIEWER_DRACO_DECODER_URL,l as MODEL_VIEWER_LIGHTING,R as ModelViewer,g as applyMaterials,O as arQuickLookSupported,c as fieldOfViewFor,x as loadModelViewer,d as modelViewerAttributes,P as openArQuickLook,y as webglAvailable};
2
+ import{webglAvailable as e}from"../chunk-WS4C6Z22.js";export{arQuickLookSupported,openArQuickLook,webglAvailable}from"../chunk-WS4C6Z22.js";import{modelViewerAttributes as t,MANAGED_ATTRIBUTES as r}from"../chunk-4N24K3UX.js";export{MODEL_VIEWER_LIGHTING,fieldOfViewFor,modelViewerAttributes}from"../chunk-4N24K3UX.js";import{useShellStrings as o}from"../chunk-NRHG4R2Q.js";import"../chunk-C3QOHMR6.js";import{forwardRef as a,useRef as n,useImperativeHandle as c,useState as l,useEffect as i}from"react";import{jsxs as s,jsx as m}from"react/jsx-runtime";var u=e=>Math.min(1,Math.max(0,e)),d=/^#[0-9a-f]{6}$/i;function h(e,t){const r=[];for(const o of e){const e=t[o.name]??t["*"];e&&(d.test(e.color)&&o.pbrMetallicRoughness.setBaseColorFactor(e.color),o.pbrMetallicRoughness.setMetallicFactor(u(e.metallic)),o.pbrMetallicRoughness.setRoughnessFactor(u(e.roughness)),o.setClearcoatFactor?.(u(e.clearcoat??0)),o.setClearcoatRoughnessFactor?.(u(e.clearcoatRoughness??0)),r.push(o.name))}return r}var f="https://www.gstatic.com",g=`${f}/draco/versioned/decoders/1.5.6/`,b={connect:[f],worker:["blob:"],script:["'wasm-unsafe-eval'"]},p=null;function v(e={}){return p??=Promise.resolve().then(()=>{const t=globalThis;return t.ModelViewerElement={...t.ModelViewerElement,dracoDecoderLocation:e.dracoDecoderUrl??g},import("@google/model-viewer")}).then(()=>{}).catch(e=>{throw p=null,e}),p}var w=180/Math.PI,C=(...e)=>e.filter(Boolean).join(" "),M=a(function({src:a,alt:u,poster:d,autoRotate:f,cameraOrbit:g,minCameraOrbit:b,maxCameraOrbit:p,lighting:M,focalLength:x,disablePan:O,cameraControls:j,materials:k,onCameraChange:L,dracoDecoderUrl:E,className:N,onStatusChange:R},I){const P=o().modelViewer,A=n(null),V=n(null),y=n(L);y.current=L;const F=n(k);F.current=k,c(I,()=>({goTo(e){const t=V.current;if(!t)return;const r=t.getCameraOrbit?.(),o=/^(-?[\d.]+)deg\b/.exec(e.trim());if(r&&o&&t.jumpCameraToGoal){const e=parseFloat(o[1])*Math.PI/180,a=2*Math.PI,n=e+((r.theta-e)%a+a+Math.PI)%a-Math.PI;t.cameraOrbit=`${n}rad ${r.phi}rad ${r.radius}m`,t.jumpCameraToGoal()}t.cameraTarget="auto auto auto",t.fieldOfView=t.getAttribute("field-of-view")??"auto",t.cameraOrbit=e}}),[]);const[D,T]=l("loading"),[G,U]=l(!1),$=n(R);$.current=R,i(()=>{$.current?.(D)},[D]),i(()=>{if(!e())return void T("still");let t=!0;return v({dracoDecoderUrl:E}).then(()=>{t&&U(!0)}).catch(()=>{t&&T("failed")}),()=>{t=!1}},[]),i(()=>{const e=A.current;if(!G||!e)return;const t=e.ownerDocument.createElement("model-viewer");t.style.width="100%",t.style.height="100%",t.style.setProperty("--poster-color","transparent");const r=()=>{F.current&&t.model&&h(t.model.materials,F.current),T("ready")},o=()=>T("failed"),a=e=>{const r=t.getCameraOrbit?.();if(!r||!y.current)return;const o=e.detail?.source;y.current({theta:r.theta*w,phi:r.phi*w,userInteraction:"user-interaction"===o})};return t.addEventListener("load",r),t.addEventListener("error",o),t.addEventListener("camera-change",a),e.appendChild(t),V.current=t,()=>{t.removeEventListener("load",r),t.removeEventListener("error",o),t.removeEventListener("camera-change",a),t.remove(),V.current=null}},[G]),i(()=>{const e=V.current;if(!e)return;const o=t({src:a,alt:u,poster:d,autoRotate:f,cameraOrbit:g,minCameraOrbit:b,maxCameraOrbit:p,lighting:M,focalLength:x,disablePan:O,cameraControls:j});for(const t of r)t in o||e.removeAttribute(t);const n=e.getAttribute("src")!==o.src;for(const[t,r]of Object.entries(o))e.getAttribute(t)!==r&&e.setAttribute(t,r);n&&T("loading")},[G,a,u,d,f,g,b,p,M,x,O,j]),i(()=>{const e=V.current;"ready"===D&&e?.model&&k&&h(e.model.materials,k)},[D,k]);const Q="still"===D||"failed"===D;/* @__PURE__ */
3
+ return s("div",{className:C("relative overflow-hidden rounded-lg border border-line bg-surface",N),"data-model-viewer":D,children:[
4
+ /* @__PURE__ */m("div",{ref:A,className:"absolute inset-0",hidden:Q}),"loading"===D&&d&&
5
+ /* @__PURE__ */m("img",{src:d,alt:"",className:"pointer-events-none absolute inset-0 h-full w-full object-contain"}),"loading"===D&&/* @__PURE__ */m("p",{role:"status",className:"sr-only",children:P.loading}),Q&&
6
+ /* @__PURE__ */s("div",{className:"absolute inset-0 flex flex-col",children:[d&&/* @__PURE__ */m("img",{src:d,alt:u,className:"min-h-0 w-full flex-1 object-contain"}),
7
+ /* @__PURE__ */m("p",{className:C("shrink-0 p-4 text-center text-sm text-ink-faint",!d&&"grid flex-1 place-items-center"),children:"still"===D?P.noWebgl:P.failed})]})]})});export{b as MODEL_VIEWER_CSP_SOURCES,f as MODEL_VIEWER_DECODER_ORIGIN,g as MODEL_VIEWER_DRACO_DECODER_URL,M as ModelViewer,h as applyMaterials,v as loadModelViewer};