@limrun/ui 0.22.1 → 0.22.3
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 +13 -7
- package/dist/{BufferGeometryUtils-B2-bJqFj.js → BufferGeometryUtils-CMbyl1DL.js} +1 -1
- package/dist/{BufferGeometryUtils-BcXIkYhS.mjs → BufferGeometryUtils-DEy5W2hb.mjs} +1 -1
- package/dist/{GLTFLoader-BQvr_TBF.mjs → GLTFLoader-B3xbM8m1.mjs} +2 -2
- package/dist/{GLTFLoader-CsxjkQ8a.js → GLTFLoader-CfPNHfJQ.js} +1 -1
- package/dist/components/macbook-geometry.d.ts +5 -5
- package/dist/components/model-source.d.ts +4 -1
- package/dist/components/remote-control.d.ts +3 -2
- package/dist/{duo-frame-CyoWZakh.mjs → duo-frame-BCmB9_5p.mjs} +4 -4
- package/dist/{duo-frame-B04_gIge.js → duo-frame-Bm0hprn9.js} +2 -2
- package/dist/{duo-view-DJEQ3Q74.mjs → duo-view-C07GD_5E.mjs} +2 -2
- package/dist/{duo-view-BHwnQmx_.js → duo-view-tUJbbWoS.js} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +2 -2
- package/dist/lite.cjs +1 -1
- package/dist/lite.js +1 -1
- package/dist/macbook-frame-BxJfxUcU.js +2 -0
- package/dist/macbook-frame-Dm6ko0j9.mjs +340 -0
- package/dist/macbook-model-B4t8BSHX.js +1 -0
- package/dist/macbook-model-BYrio_FY.mjs +4 -0
- package/dist/{model-source-BAZAKTcr.mjs → model-source-CN_i4mVy.mjs} +57 -47
- package/dist/{model-source-DbYJQWkh.js → model-source-D3_k9qRK.js} +1 -1
- package/dist/{remote-control-PGtDEDgm.mjs → remote-control-BX6dzHtt.mjs} +686 -720
- package/dist/remote-control-CEVcOPQZ.js +1 -0
- package/package.json +1 -1
- package/dist/macbook-frame-Be0dCliH.js +0 -3
- package/dist/macbook-frame-DzwIHHCA.mjs +0 -344
- package/dist/macbook-model-BiMxLpmf.mjs +0 -4
- package/dist/macbook-model-BpUdvtlU.js +0 -1
- package/dist/remote-control-Db6ssV0S.js +0 -1
package/README.md
CHANGED
|
@@ -20,16 +20,22 @@ logo is omitted. Pass your own images through the `assets` prop if you want fram
|
|
|
20
20
|
|
|
21
21
|
A macOS guest streams inside a MacBook Pro. The default entry draws it with an image rendered from a
|
|
22
22
|
3D model, with the stream in the screen's opening; `@limrun/ui/lite` draws a plainer one in CSS.
|
|
23
|
-
Neither draws it when `showFrame` is false.
|
|
23
|
+
Neither draws it when `showFrame` is false. The stream starts at the top of the screen, so the notch
|
|
24
|
+
covers the top of the guest's menu bar as it does on a MacBook. A guest with the 16-inch panel's
|
|
25
|
+
shape, such as the 1728 × 1116 that Limrun's macOS instances draw, fills the screen; a guest of
|
|
26
|
+
another shape keeps its own, with black glass where it falls short.
|
|
24
27
|
|
|
25
28
|
A 2D and 3D switch above the MacBook turns it into a 3D model, like the iPhone Duo's, with the
|
|
26
29
|
stream on its screen. The 3D MacBook opens its lid when it appears; set `animateLid={false}` to show
|
|
27
|
-
it open from the start. The default entry bundles the 3D model, about 1.
|
|
28
|
-
Your bundler splits it out with three.js, and a browser downloads them only when a
|
|
29
|
-
so the 2D stream's first frame never waits for them. The
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
it open from the start. The default entry bundles the 3D model, about 3.3 MB or 1.3 MB gzipped, in a
|
|
31
|
+
chunk of its own. Your bundler splits it out with three.js, and a browser downloads them only when a
|
|
32
|
+
viewer picks 3D, so the 2D stream's first frame never waits for them. The model needs no
|
|
33
|
+
WebAssembly, so it loads under a content security policy without `'wasm-unsafe-eval'`. The lite
|
|
34
|
+
entry has no model and draws a simpler built-in MacBook in 3D.
|
|
35
|
+
|
|
36
|
+
To serve the model yourself, or another prepared one, pass its URL as `macbookModelUrl`. A model
|
|
37
|
+
compressed with `EXT_meshopt_compression` also loads, but its decoder is WebAssembly, so the page's
|
|
38
|
+
policy must allow `'wasm-unsafe-eval'`.
|
|
33
39
|
`scripts/prepare-macbook-model.mjs` makes one from the source model and lists the nodes the 3D
|
|
34
40
|
MacBook expects, and `scripts/render-macbook-frame.ts` renders the 2D image from it.
|
|
35
41
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const r=require("./model-source-
|
|
1
|
+
"use strict";const r=require("./model-source-D3_k9qRK.js");function I(n,a){if(a===r.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),n;if(a===r.TriangleFanDrawMode||a===r.TriangleStripDrawMode){let o=n.getIndex();if(o===null){const e=[],m=n.getAttribute("position");if(m!==void 0){for(let c=0;c<m.count;c++)e.push(c);n.setIndex(e),o=n.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),n}const f=o.count-2,t=[];if(a===r.TriangleFanDrawMode)for(let e=1;e<=f;e++)t.push(o.getX(0)),t.push(o.getX(e)),t.push(o.getX(e+1));else for(let e=0;e<f;e++)e%2===0?(t.push(o.getX(e)),t.push(o.getX(e+1)),t.push(o.getX(e+2))):(t.push(o.getX(e+2)),t.push(o.getX(e+1)),t.push(o.getX(e)));t.length/3!==f&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const u=n.clone();return u.setIndex(t),u.clearGroups(),u}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",a),n}function N(n,a=Math.PI/3){const o=Math.cos(a),f=(1+1e-10)*100,t=[new r.Vector3,new r.Vector3,new r.Vector3],u=new r.Vector3,e=new r.Vector3,m=new r.Vector3,c=new r.Vector3;function D(s){const p=~~(s.x*f),i=~~(s.y*f),w=~~(s.z*f);return`${p},${i},${w}`}const T=n.index?n.toNonIndexed():n,l=T.attributes.position,V={};for(let s=0,p=l.count/3;s<p;s++){const i=3*s,w=t[0].fromBufferAttribute(l,i+0),b=t[1].fromBufferAttribute(l,i+1),A=t[2].fromBufferAttribute(l,i+2);u.subVectors(A,b),e.subVectors(w,b);const d=new r.Vector3().crossVectors(u,e).normalize();for(let g=0;g<3;g++){const x=t[g],h=D(x);h in V||(V[h]=[]),V[h].push(d)}}const E=new Float32Array(l.count*3),M=new r.BufferAttribute(E,3,!1);for(let s=0,p=l.count/3;s<p;s++){const i=3*s,w=t[0].fromBufferAttribute(l,i+0),b=t[1].fromBufferAttribute(l,i+1),A=t[2].fromBufferAttribute(l,i+2);u.subVectors(A,b),e.subVectors(w,b),m.crossVectors(u,e).normalize();for(let d=0;d<3;d++){const g=t[d],x=D(g),h=V[x];c.set(0,0,0);for(let B=0,G=h.length;B<G;B++){const X=h[B];m.dot(X)>o&&c.add(X)}c.normalize(),M.setXYZ(i+d,c.x,c.y,c.z)}}return T.setAttribute("normal",M),T}exports.toCreasedNormals=N;exports.toTrianglesDrawMode=I;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as u, j as U, k as z, m as G, n as N } from "./model-source-
|
|
1
|
+
import { d as u, j as U, k as z, m as G, n as N } from "./model-source-CN_i4mVy.mjs";
|
|
2
2
|
function y(n, l) {
|
|
3
3
|
if (l === z)
|
|
4
4
|
return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), n;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as Ae, p as G, F as fe, f as w, h as he, C as F, q as b, S as U, r as Le, s as Me, t as Se, v as K, d as C, w as ye, Q as de, x as we, O as pe, y as be, z as Ne, j as V, I as Ie, A as me, N as Oe, E as Ce, H as Fe, L as Q, J as ge, K as J, U as Pe, W as ke, X as He, Y as z, Z as De, e as Te, D as ve, M as v, _ as Ge, B as Ue, $ as Ke, b as Be, a0 as je, a1 as Ve, a2 as ze, a3 as Xe, G as X, P as qe, i as We, a4 as Ye, a5 as Qe, a6 as Je, a7 as Ze, a8 as $e, a9 as Re, a as en, T as ee, aa as ne, ab as te, ac as se, ad as ie, ae as nn, af as tn, g as sn, ag as rn, n as on, m as an } from "./model-source-
|
|
2
|
-
import { t as re } from "./BufferGeometryUtils-
|
|
1
|
+
import { o as Ae, p as G, F as fe, f as w, h as he, C as F, q as b, S as U, r as Le, s as Me, t as Se, v as K, d as C, w as ye, Q as de, x as we, O as pe, y as be, z as Ne, j as V, I as Ie, A as me, N as Oe, E as Ce, H as Fe, L as Q, J as ge, K as J, U as Pe, W as ke, X as He, Y as z, Z as De, e as Te, D as ve, M as v, _ as Ge, B as Ue, $ as Ke, b as Be, a0 as je, a1 as Ve, a2 as ze, a3 as Xe, G as X, P as qe, i as We, a4 as Ye, a5 as Qe, a6 as Je, a7 as Ze, a8 as $e, a9 as Re, a as en, T as ee, aa as ne, ab as te, ac as se, ad as ie, ae as nn, af as tn, g as sn, ag as rn, n as on, m as an } from "./model-source-CN_i4mVy.mjs";
|
|
2
|
+
import { t as re } from "./BufferGeometryUtils-DEy5W2hb.mjs";
|
|
3
3
|
function cn(h) {
|
|
4
4
|
const n = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), t = h.clone();
|
|
5
5
|
return Ee(h, t, function(s, i) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./model-source-DbYJQWkh.js"),K=require("./BufferGeometryUtils-B2-bJqFj.js");function J(d){const t=new Map,e=new Map,n=d.clone();return W(d,n,function(s,r){t.set(r,s),e.set(s,r)}),n.traverse(function(s){if(!s.isSkinnedMesh)return;const r=s,o=t.get(s),a=o.skeleton.bones;r.skeleton=o.skeleton.clone(),r.bindMatrix.copy(o.bindMatrix),r.skeleton.bones=a.map(function(i){return e.get(i)}),r.bind(r.skeleton,r.bindMatrix)}),n}function W(d,t,e){e(d,t);for(let n=0;n<d.children.length;n++)W(d.children[n],t.children[n],e)}class Z extends h.Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new se(e)}),this.register(function(e){return new re(e)}),this.register(function(e){return new de(e)}),this.register(function(e){return new pe(e)}),this.register(function(e){return new me(e)}),this.register(function(e){return new oe(e)}),this.register(function(e){return new ae(e)}),this.register(function(e){return new ce(e)}),this.register(function(e){return new le(e)}),this.register(function(e){return new ne(e)}),this.register(function(e){return new ue(e)}),this.register(function(e){return new ie(e)}),this.register(function(e){return new fe(e)}),this.register(function(e){return new he(e)}),this.register(function(e){return new ee(e)}),this.register(function(e){return new j(e,T.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new j(e,T.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new ge(e)})}load(t,e,n,s){const r=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=h.LoaderUtils.extractUrlBase(t);o=h.LoaderUtils.resolveURL(c,this.path)}else o=h.LoaderUtils.extractUrlBase(t);this.manager.itemStart(t);const a=function(c){s?s(c):console.error(c),r.manager.itemError(t),r.manager.itemEnd(t)},i=new h.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(t,function(c){try{r.parse(c,o,function(u){e(u),r.manager.itemEnd(t)},a)}catch(u){a(u)}},n,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,n,s){let r;const o={},a={},i=new TextDecoder;if(typeof t=="string")r=JSON.parse(t);else if(t instanceof ArrayBuffer)if(i.decode(new Uint8Array(t,0,4))===Y){try{o[T.KHR_BINARY_GLTF]=new Te(t)}catch(l){s&&s(l);return}r=JSON.parse(o[T.KHR_BINARY_GLTF].content)}else r=JSON.parse(i.decode(t));else r=t;if(r.asset===void 0||r.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new Ie(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const l=this.pluginCallbacks[u](c);l.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[l.name]=l,o[l.name]=!0}if(r.extensionsUsed)for(let u=0;u<r.extensionsUsed.length;++u){const l=r.extensionsUsed[u],f=r.extensionsRequired||[];switch(l){case T.KHR_MATERIALS_UNLIT:o[l]=new te;break;case T.KHR_DRACO_MESH_COMPRESSION:o[l]=new Re(r,this.dracoLoader);break;case T.KHR_TEXTURE_TRANSFORM:o[l]=new Me;break;case T.KHR_MESH_QUANTIZATION:o[l]=new Ee;break;default:f.indexOf(l)>=0&&a[l]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+l+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,s)}parseAsync(t,e){const n=this;return new Promise(function(s,r){n.parse(t,e,s,r)})}}function $(){let d={};return{get:function(t){return d[t]},add:function(t,e){d[t]=e},remove:function(t){delete d[t]},removeAll:function(){d={}}}}function _(d,t,e){const n=d.json.materials[t];return n.extensions&&n.extensions[e]?n.extensions[e]:null}const T={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ee{constructor(t){this.parser=t,this.name=T.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let n=0,s=e.length;n<s;n++){const r=e[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&t._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(t){const e=this.parser,n="light:"+t;let s=e.cache.get(n);if(s)return s;const r=e.json,i=((r.extensions&&r.extensions[this.name]||{}).lights||[])[t];let c;const u=new h.Color(16777215);i.color!==void 0&&u.setRGB(i.color[0],i.color[1],i.color[2],h.LinearSRGBColorSpace);const l=i.range!==void 0?i.range:0;switch(i.type){case"directional":c=new h.DirectionalLight(u),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new h.PointLight(u),c.distance=l;break;case"spot":c=new h.SpotLight(u),c.distance=l,i.spot=i.spot||{},i.spot.innerConeAngle=i.spot.innerConeAngle!==void 0?i.spot.innerConeAngle:0,i.spot.outerConeAngle=i.spot.outerConeAngle!==void 0?i.spot.outerConeAngle:Math.PI/4,c.angle=i.spot.outerConeAngle,c.penumbra=1-i.spot.innerConeAngle/i.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+i.type)}return c.position.set(0,0,0),w(c,i),i.intensity!==void 0&&(c.intensity=i.intensity),c.name=e.createUniqueName(i.name||"light_"+t),s=Promise.resolve(c),e.cache.add(n,s),s}getDependency(t,e){if(t==="light")return this._loadLight(e)}createNodeAttachment(t){const e=this,n=this.parser,r=n.json.nodes[t],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(i){return n._getNodeRef(e.cache,a,i)})}}class te{constructor(){this.name=T.KHR_MATERIALS_UNLIT}getMaterialType(){return h.MeshBasicMaterial}extendParams(t,e,n){const s=[];t.color=new h.Color(1,1,1),t.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const o=r.baseColorFactor;t.color.setRGB(o[0],o[1],o[2],h.LinearSRGBColorSpace),t.opacity=o[3]}r.baseColorTexture!==void 0&&s.push(n.assignTexture(t,"map",r.baseColorTexture,h.SRGBColorSpace))}return Promise.all(s)}}class ne{constructor(t){this.parser=t,this.name=T.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);return n===null||n.emissiveStrength!==void 0&&(e.emissiveIntensity=n.emissiveStrength),Promise.resolve()}}class se{constructor(t){this.parser=t,this.name=T.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){return _(this.parser,t,this.name)!==null?h.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);if(n===null)return Promise.resolve();const s=[];if(n.clearcoatFactor!==void 0&&(e.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&s.push(this.parser.assignTexture(e,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(e,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(s.push(this.parser.assignTexture(e,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){const r=n.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new h.Vector2(r,r)}return Promise.all(s)}}class re{constructor(t){this.parser=t,this.name=T.KHR_MATERIALS_DISPERSION}getMaterialType(t){return _(this.parser,t,this.name)!==null?h.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);return n===null||(e.dispersion=n.dispersion!==void 0?n.dispersion:0),Promise.resolve()}}class ie{constructor(t){this.parser=t,this.name=T.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){return _(this.parser,t,this.name)!==null?h.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);if(n===null)return Promise.resolve();const s=[];return n.iridescenceFactor!==void 0&&(e.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&s.push(this.parser.assignTexture(e,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==void 0&&(e.iridescenceIOR=n.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&s.push(this.parser.assignTexture(e,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(s)}}class oe{constructor(t){this.parser=t,this.name=T.KHR_MATERIALS_SHEEN}getMaterialType(t){return _(this.parser,t,this.name)!==null?h.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);if(n===null)return Promise.resolve();const s=[];if(e.sheenColor=new h.Color(0,0,0),e.sheenRoughness=0,e.sheen=1,n.sheenColorFactor!==void 0){const r=n.sheenColorFactor;e.sheenColor.setRGB(r[0],r[1],r[2],h.LinearSRGBColorSpace)}return n.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&s.push(this.parser.assignTexture(e,"sheenColorMap",n.sheenColorTexture,h.SRGBColorSpace)),n.sheenRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(e,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(s)}}class ae{constructor(t){this.parser=t,this.name=T.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){return _(this.parser,t,this.name)!==null?h.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);if(n===null)return Promise.resolve();const s=[];return n.transmissionFactor!==void 0&&(e.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&s.push(this.parser.assignTexture(e,"transmissionMap",n.transmissionTexture)),Promise.all(s)}}class ce{constructor(t){this.parser=t,this.name=T.KHR_MATERIALS_VOLUME}getMaterialType(t){return _(this.parser,t,this.name)!==null?h.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);if(n===null)return Promise.resolve();const s=[];e.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&s.push(this.parser.assignTexture(e,"thicknessMap",n.thicknessTexture)),e.attenuationDistance=n.attenuationDistance||1/0;const r=n.attenuationColor||[1,1,1];return e.attenuationColor=new h.Color().setRGB(r[0],r[1],r[2],h.LinearSRGBColorSpace),Promise.all(s)}}class le{constructor(t){this.parser=t,this.name=T.KHR_MATERIALS_IOR}getMaterialType(t){return _(this.parser,t,this.name)!==null?h.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);return n===null||(e.ior=n.ior!==void 0?n.ior:1.5),Promise.resolve()}}class ue{constructor(t){this.parser=t,this.name=T.KHR_MATERIALS_SPECULAR}getMaterialType(t){return _(this.parser,t,this.name)!==null?h.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);if(n===null)return Promise.resolve();const s=[];e.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&s.push(this.parser.assignTexture(e,"specularIntensityMap",n.specularTexture));const r=n.specularColorFactor||[1,1,1];return e.specularColor=new h.Color().setRGB(r[0],r[1],r[2],h.LinearSRGBColorSpace),n.specularColorTexture!==void 0&&s.push(this.parser.assignTexture(e,"specularColorMap",n.specularColorTexture,h.SRGBColorSpace)),Promise.all(s)}}class he{constructor(t){this.parser=t,this.name=T.EXT_MATERIALS_BUMP}getMaterialType(t){return _(this.parser,t,this.name)!==null?h.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);if(n===null)return Promise.resolve();const s=[];return e.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0&&s.push(this.parser.assignTexture(e,"bumpMap",n.bumpTexture)),Promise.all(s)}}class fe{constructor(t){this.parser=t,this.name=T.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){return _(this.parser,t,this.name)!==null?h.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);if(n===null)return Promise.resolve();const s=[];return n.anisotropyStrength!==void 0&&(e.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(e.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&s.push(this.parser.assignTexture(e,"anisotropyMap",n.anisotropyTexture)),Promise.all(s)}}class de{constructor(t){this.parser=t,this.name=T.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,n=e.json,s=n.textures[t];if(!s.extensions||!s.extensions[this.name])return null;const r=s.extensions[this.name],o=e.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,o)}}class pe{constructor(t){this.parser=t,this.name=T.EXT_TEXTURE_WEBP}loadTexture(t){const e=this.name,n=this.parser,s=n.json,r=s.textures[t];if(!r.extensions||!r.extensions[e])return null;const o=r.extensions[e],a=s.images[o.source];let i=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(i=c)}return n.loadTextureImage(t,o.source,i)}}class me{constructor(t){this.parser=t,this.name=T.EXT_TEXTURE_AVIF}loadTexture(t){const e=this.name,n=this.parser,s=n.json,r=s.textures[t];if(!r.extensions||!r.extensions[e])return null;const o=r.extensions[e],a=s.images[o.source];let i=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(i=c)}return n.loadTextureImage(t,o.source,i)}}class j{constructor(t,e){this.name=e,this.parser=t}loadBufferView(t){const e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const s=n.extensions[this.name],r=this.parser.getDependency("buffer",s.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const i=s.byteOffset||0,c=s.byteLength||0,u=s.count,l=s.byteStride,f=new Uint8Array(a,i,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,l,f,s.mode,s.filter).then(function(p){return p.buffer}):o.ready.then(function(){const p=new ArrayBuffer(u*l);return o.decodeGltfBuffer(new Uint8Array(p),u,l,f,s.mode,s.filter),p})})}else return null}}class ge{constructor(t){this.name=T.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,n=e.nodes[t];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const s=e.meshes[n.mesh];for(const c of s.primitives)if(c.mode!==S.TRIANGLES&&c.mode!==S.TRIANGLE_STRIP&&c.mode!==S.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=n.extensions[this.name].attributes,a=[],i={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(u=>(i[c]=u,i[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(t)),Promise.all(a).then(c=>{const u=c.pop(),l=u.isGroup?u.children:[u],f=c[0].count,p=[];for(const m of l){const M=new h.Matrix4,g=new h.Vector3,R=new h.Quaternion,A=new h.Vector3(1,1,1),x=new h.InstancedMesh(m.geometry,m.material,f);for(let E=0;E<f;E++)i.TRANSLATION&&g.fromBufferAttribute(i.TRANSLATION,E),i.ROTATION&&R.fromBufferAttribute(i.ROTATION,E),i.SCALE&&A.fromBufferAttribute(i.SCALE,E),x.setMatrixAt(E,M.compose(g,R,A));for(const E in i)if(E==="_COLOR_0"){const L=i[E];x.instanceColor=new h.InstancedBufferAttribute(L.array,L.itemSize,L.normalized)}else E!=="TRANSLATION"&&E!=="ROTATION"&&E!=="SCALE"&&m.geometry.setAttribute(E,i[E]);h.Object3D.prototype.copy.call(x,m),this.parser.assignFinalMaterial(x),p.push(x)}return u.isGroup?(u.clear(),u.add(...p),u):p[0]}))}}const Y="glTF",F=12,V={JSON:1313821514,BIN:5130562};class Te{constructor(t){this.name=T.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,F),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==Y)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-F,r=new DataView(t,F);let o=0;for(;o<s;){const a=r.getUint32(o,!0);o+=4;const i=r.getUint32(o,!0);if(o+=4,i===V.JSON){const c=new Uint8Array(t,F+o,a);this.content=n.decode(c)}else if(i===V.BIN){const c=F+o;this.body=t.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Re{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=T.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const n=this.json,s=this.dracoLoader,r=t.extensions[this.name].bufferView,o=t.extensions[this.name].attributes,a={},i={},c={};for(const u in o){const l=B[u]||u.toLowerCase();a[l]=o[u]}for(const u in t.attributes){const l=B[u]||u.toLowerCase();if(o[u]!==void 0){const f=n.accessors[t.attributes[u]],p=O[f.componentType];c[l]=p.name,i[l]=f.normalized===!0}}return e.getDependency("bufferView",r).then(function(u){return new Promise(function(l,f){s.decodeDracoFile(u,function(p){for(const m in p.attributes){const M=p.attributes[m],g=i[m];g!==void 0&&(M.normalized=g)}l(p)},a,c,h.LinearSRGBColorSpace,f)})})}}class Me{constructor(){this.name=T.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return(e.texCoord===void 0||e.texCoord===t.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(t=t.clone(),e.texCoord!==void 0&&(t.channel=e.texCoord),e.offset!==void 0&&t.offset.fromArray(e.offset),e.rotation!==void 0&&(t.rotation=e.rotation),e.scale!==void 0&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class Ee{constructor(){this.name=T.KHR_MESH_QUANTIZATION}}class Q extends h.Interpolant{constructor(t,e,n,s){super(t,e,n,s)}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=t*s*3+s;for(let o=0;o!==s;o++)e[o]=n[r+o];return e}interpolate_(t,e,n,s){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,i=a*2,c=a*3,u=s-e,l=(n-e)/u,f=l*l,p=f*l,m=t*c,M=m-c,g=-2*p+3*f,R=p-f,A=1-g,x=R-f+l;for(let E=0;E!==a;E++){const L=o[M+E+a],b=o[M+E+i]*u,y=o[m+E+a],P=o[m+E]*u;r[E]=A*L+x*b+g*y+R*P}return r}}const xe=new h.Quaternion;class Ae extends Q{interpolate_(t,e,n,s){const r=super.interpolate_(t,e,n,s);return xe.fromArray(r).normalize().toArray(r),r}}const S={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},O={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},z={9728:h.NearestFilter,9729:h.LinearFilter,9984:h.NearestMipmapNearestFilter,9985:h.LinearMipmapNearestFilter,9986:h.NearestMipmapLinearFilter,9987:h.LinearMipmapLinearFilter},X={33071:h.ClampToEdgeWrapping,33648:h.MirroredRepeatWrapping,10497:h.RepeatWrapping},D={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},B={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},N={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},_e={CUBICSPLINE:void 0,LINEAR:h.InterpolateLinear,STEP:h.InterpolateDiscrete},G={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Le(d){return d.DefaultMaterial===void 0&&(d.DefaultMaterial=new h.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:h.FrontSide})),d.DefaultMaterial}function I(d,t,e){for(const n in e.extensions)d[n]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=e.extensions[n])}function w(d,t){t.extras!==void 0&&(typeof t.extras=="object"?Object.assign(d.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Se(d,t,e){let n=!1,s=!1,r=!1;for(let c=0,u=t.length;c<u;c++){const l=t[c];if(l.POSITION!==void 0&&(n=!0),l.NORMAL!==void 0&&(s=!0),l.COLOR_0!==void 0&&(r=!0),n&&s&&r)break}if(!n&&!s&&!r)return Promise.resolve(d);const o=[],a=[],i=[];for(let c=0,u=t.length;c<u;c++){const l=t[c];if(n){const f=l.POSITION!==void 0?e.getDependency("accessor",l.POSITION):d.attributes.position;o.push(f)}if(s){const f=l.NORMAL!==void 0?e.getDependency("accessor",l.NORMAL):d.attributes.normal;a.push(f)}if(r){const f=l.COLOR_0!==void 0?e.getDependency("accessor",l.COLOR_0):d.attributes.color;i.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(i)]).then(function(c){const u=c[0],l=c[1],f=c[2];return n&&(d.morphAttributes.position=u),s&&(d.morphAttributes.normal=l),r&&(d.morphAttributes.color=f),d.morphTargetsRelative=!0,d})}function ye(d,t){if(d.updateMorphTargets(),t.weights!==void 0)for(let e=0,n=t.weights.length;e<n;e++)d.morphTargetInfluences[e]=t.weights[e];if(t.extras&&Array.isArray(t.extras.targetNames)){const e=t.extras.targetNames;if(d.morphTargetInfluences.length===e.length){d.morphTargetDictionary={};for(let n=0,s=e.length;n<s;n++)d.morphTargetDictionary[e[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function we(d){let t;const e=d.extensions&&d.extensions[T.KHR_DRACO_MESH_COMPRESSION];if(e?t="draco:"+e.bufferView+":"+e.indices+":"+v(e.attributes):t=d.indices+":"+v(d.attributes)+":"+d.mode,d.targets!==void 0)for(let n=0,s=d.targets.length;n<s;n++)t+=":"+v(d.targets[n]);return t}function v(d){let t="";const e=Object.keys(d).sort();for(let n=0,s=e.length;n<s;n++)t+=e[n]+":"+d[e[n]]+";";return t}function U(d){switch(d){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function be(d){return d.search(/\.jpe?g($|\?)/i)>0||d.search(/^data\:image\/jpeg/)===0?"image/jpeg":d.search(/\.webp($|\?)/i)>0||d.search(/^data\:image\/webp/)===0?"image/webp":d.search(/\.ktx2($|\?)/i)>0||d.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Ne=new h.Matrix4;class Ie{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new $,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,s=-1,r=!1,o=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;const i=a.match(/Version\/(\d+)/);s=n&&i?parseInt(i[1],10):-1,r=a.indexOf("Firefox")>-1,o=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&s<17||r&&o<98?this.textureLoader=new h.TextureLoader(this.options.manager):this.textureLoader=new h.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new h.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const n=this,s=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][s.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:s.asset,parser:n,userData:{}};return I(r,a,s),w(a,s),Promise.all(n._invokeAll(function(i){return i.afterRoot&&i.afterRoot(a)})).then(function(){for(const i of a.scenes)i.updateMatrixWorld();t(a)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let s=0,r=e.length;s<r;s++){const o=e[s].joints;for(let a=0,i=o.length;a<i;a++)t[o[a]].isBone=!0}for(let s=0,r=t.length;s<r;s++){const o=t[s];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(t,e){e!==void 0&&(t.refs[e]===void 0&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,n){if(t.refs[e]<=1)return n;const s=n.clone(),r=(o,a)=>{const i=this.associations.get(o);i!=null&&this.associations.set(a,i);for(const[c,u]of o.children.entries())r(u,a.children[c])};return r(n,s),s.name+="_instance_"+t.uses[e]++,s}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let n=0;n<e.length;n++){const s=t(e[n]);if(s)return s}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const n=[];for(let s=0;s<e.length;s++){const r=t(e[s]);r&&n.push(r)}return n}getDependency(t,e){const n=t+":"+e;let s=this.cache.get(n);if(!s){switch(t){case"scene":s=this.loadScene(e);break;case"node":s=this._invokeOne(function(r){return r.loadNode&&r.loadNode(e)});break;case"mesh":s=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(e)});break;case"accessor":s=this.loadAccessor(e);break;case"bufferView":s=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(e)});break;case"buffer":s=this.loadBuffer(e);break;case"material":s=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(e)});break;case"texture":s=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(e)});break;case"skin":s=this.loadSkin(e);break;case"animation":s=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(e)});break;case"camera":s=this.loadCamera(e);break;default:if(s=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(t,e)}),!s)throw new Error("Unknown type: "+t);break}this.cache.add(n,s)}return s}getDependencies(t){let e=this.cache.get(t);if(!e){const n=this,s=this.json[t+(t==="mesh"?"es":"s")]||[];e=Promise.all(s.map(function(r,o){return n.getDependency(t,o)})),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],n=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&t===0)return Promise.resolve(this.extensions[T.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(r,o){n.load(h.LoaderUtils.resolveURL(e.uri,s.path),r,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(n){const s=e.byteLength||0,r=e.byteOffset||0;return n.slice(r,r+s)})}loadAccessor(t){const e=this,n=this.json,s=this.json.accessors[t];if(s.bufferView===void 0&&s.sparse===void 0){const o=D[s.type],a=O[s.componentType],i=s.normalized===!0,c=new a(s.count*o);return Promise.resolve(new h.BufferAttribute(c,o,i))}const r=[];return s.bufferView!==void 0?r.push(this.getDependency("bufferView",s.bufferView)):r.push(null),s.sparse!==void 0&&(r.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(r).then(function(o){const a=o[0],i=D[s.type],c=O[s.componentType],u=c.BYTES_PER_ELEMENT,l=u*i,f=s.byteOffset||0,p=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,m=s.normalized===!0;let M,g;if(p&&p!==l){const R=Math.floor(f/p),A="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+R+":"+s.count;let x=e.cache.get(A);x||(M=new c(a,R*p,s.count*p/u),x=new h.InterleavedBuffer(M,p/u),e.cache.add(A,x)),g=new h.InterleavedBufferAttribute(x,i,f%p/u,m)}else a===null?M=new c(s.count*i):M=new c(a,f,s.count*i),g=new h.BufferAttribute(M,i,m);if(s.sparse!==void 0){const R=D.SCALAR,A=O[s.sparse.indices.componentType],x=s.sparse.indices.byteOffset||0,E=s.sparse.values.byteOffset||0,L=new A(o[1],x,s.sparse.count*R),b=new c(o[2],E,s.sparse.count*i);a!==null&&(g=new h.BufferAttribute(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let y=0,P=L.length;y<P;y++){const C=L[y];if(g.setX(C,b[y*i]),i>=2&&g.setY(C,b[y*i+1]),i>=3&&g.setZ(C,b[y*i+2]),i>=4&&g.setW(C,b[y*i+3]),i>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=m}return g})}loadTexture(t){const e=this.json,n=this.options,r=e.textures[t].source,o=e.images[r];let a=this.textureLoader;if(o.uri){const i=n.manager.getHandler(o.uri);i!==null&&(a=i)}return this.loadTextureImage(t,r,a)}loadTextureImage(t,e,n){const s=this,r=this.json,o=r.textures[t],a=r.images[e],i=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[i])return this.textureCache[i];const c=this.loadImageSource(e,n).then(function(u){u.flipY=!1,u.name=o.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const f=(r.samplers||{})[o.sampler]||{};return u.magFilter=z[f.magFilter]||h.LinearFilter,u.minFilter=z[f.minFilter]||h.LinearMipmapLinearFilter,u.wrapS=X[f.wrapS]||h.RepeatWrapping,u.wrapT=X[f.wrapT]||h.RepeatWrapping,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==h.NearestFilter&&u.minFilter!==h.LinearFilter,s.associations.set(u,{textures:t}),u}).catch(function(){return null});return this.textureCache[i]=c,c}loadImageSource(t,e){const n=this,s=this.json,r=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(l=>l.clone());const o=s.images[t],a=self.URL||self.webkitURL;let i=o.uri||"",c=!1;if(o.bufferView!==void 0)i=n.getDependency("bufferView",o.bufferView).then(function(l){c=!0;const f=new Blob([l],{type:o.mimeType});return i=a.createObjectURL(f),i});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const u=Promise.resolve(i).then(function(l){return new Promise(function(f,p){let m=f;e.isImageBitmapLoader===!0&&(m=function(M){const g=new h.Texture(M);g.needsUpdate=!0,f(g)}),e.load(h.LoaderUtils.resolveURL(l,r.path),m,void 0,p)})}).then(function(l){return c===!0&&a.revokeObjectURL(i),w(l,o),l.userData.mimeType=o.mimeType||be(o.uri),l}).catch(function(l){throw console.error("THREE.GLTFLoader: Couldn't load texture",i),l});return this.sourceCache[t]=u,u}assignTexture(t,e,n,s){const r=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),r.extensions[T.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[T.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const i=r.associations.get(o);o=r.extensions[T.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,i)}}return s!==void 0&&(o.colorSpace=s),t[e]=o,o})}assignFinalMaterial(t){const e=t.geometry;let n=t.material;const s=e.attributes.tangent===void 0,r=e.attributes.color!==void 0,o=e.attributes.normal===void 0;if(t.isPoints){const a="PointsMaterial:"+n.uuid;let i=this.cache.get(a);i||(i=new h.PointsMaterial,h.Material.prototype.copy.call(i,n),i.color.copy(n.color),i.map=n.map,i.sizeAttenuation=!1,this.cache.add(a,i)),n=i}else if(t.isLine){const a="LineBasicMaterial:"+n.uuid;let i=this.cache.get(a);i||(i=new h.LineBasicMaterial,h.Material.prototype.copy.call(i,n),i.color.copy(n.color),i.map=n.map,this.cache.add(a,i)),n=i}if(s||r||o){let a="ClonedMaterial:"+n.uuid+":";s&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let i=this.cache.get(a);i||(i=n.clone(),r&&(i.vertexColors=!0),o&&(i.flatShading=!0),s&&(i.normalScale&&(i.normalScale.y*=-1),i.clearcoatNormalScale&&(i.clearcoatNormalScale.y*=-1)),this.cache.add(a,i),this.associations.set(i,this.associations.get(n))),n=i}t.material=n}getMaterialType(){return h.MeshStandardMaterial}loadMaterial(t){const e=this,n=this.json,s=this.extensions,r=n.materials[t];let o;const a={},i=r.extensions||{},c=[];if(i[T.KHR_MATERIALS_UNLIT]){const l=s[T.KHR_MATERIALS_UNLIT];o=l.getMaterialType(),c.push(l.extendParams(a,r,e))}else{const l=r.pbrMetallicRoughness||{};if(a.color=new h.Color(1,1,1),a.opacity=1,Array.isArray(l.baseColorFactor)){const f=l.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],h.LinearSRGBColorSpace),a.opacity=f[3]}l.baseColorTexture!==void 0&&c.push(e.assignTexture(a,"map",l.baseColorTexture,h.SRGBColorSpace)),a.metalness=l.metallicFactor!==void 0?l.metallicFactor:1,a.roughness=l.roughnessFactor!==void 0?l.roughnessFactor:1,l.metallicRoughnessTexture!==void 0&&(c.push(e.assignTexture(a,"metalnessMap",l.metallicRoughnessTexture)),c.push(e.assignTexture(a,"roughnessMap",l.metallicRoughnessTexture))),o=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(t)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(t,a)})))}r.doubleSided===!0&&(a.side=h.DoubleSide);const u=r.alphaMode||G.OPAQUE;if(u===G.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===G.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==h.MeshBasicMaterial&&(c.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new h.Vector2(1,1),r.normalTexture.scale!==void 0)){const l=r.normalTexture.scale;a.normalScale.set(l,l)}if(r.occlusionTexture!==void 0&&o!==h.MeshBasicMaterial&&(c.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==h.MeshBasicMaterial){const l=r.emissiveFactor;a.emissive=new h.Color().setRGB(l[0],l[1],l[2],h.LinearSRGBColorSpace)}return r.emissiveTexture!==void 0&&o!==h.MeshBasicMaterial&&c.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,h.SRGBColorSpace)),Promise.all(c).then(function(){const l=new o(a);return r.name&&(l.name=r.name),w(l,r),e.associations.set(l,{materials:t}),r.extensions&&I(s,l,r),l})}createUniqueName(t){const e=h.PropertyBinding.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,n=this.extensions,s=this.primitiveCache;function r(a){return n[T.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(i){return q(i,a,e)})}const o=[];for(let a=0,i=t.length;a<i;a++){const c=t[a],u=we(c),l=s[u];if(l)o.push(l.promise);else{let f;c.extensions&&c.extensions[T.KHR_DRACO_MESH_COMPRESSION]?f=r(c):f=q(new h.BufferGeometry,c,e),s[u]={primitive:c,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(t){const e=this,n=this.json,s=this.extensions,r=n.meshes[t],o=r.primitives,a=[];for(let i=0,c=o.length;i<c;i++){const u=o[i].material===void 0?Le(this.cache):this.getDependency("material",o[i].material);a.push(u)}return a.push(e.loadGeometries(o)),Promise.all(a).then(function(i){const c=i.slice(0,i.length-1),u=i[i.length-1],l=[];for(let p=0,m=u.length;p<m;p++){const M=u[p],g=o[p];let R;const A=c[p];if(g.mode===S.TRIANGLES||g.mode===S.TRIANGLE_STRIP||g.mode===S.TRIANGLE_FAN||g.mode===void 0)R=r.isSkinnedMesh===!0?new h.SkinnedMesh(M,A):new h.Mesh(M,A),R.isSkinnedMesh===!0&&R.normalizeSkinWeights(),g.mode===S.TRIANGLE_STRIP?R.geometry=K.toTrianglesDrawMode(R.geometry,h.TriangleStripDrawMode):g.mode===S.TRIANGLE_FAN&&(R.geometry=K.toTrianglesDrawMode(R.geometry,h.TriangleFanDrawMode));else if(g.mode===S.LINES)R=new h.LineSegments(M,A);else if(g.mode===S.LINE_STRIP)R=new h.Line(M,A);else if(g.mode===S.LINE_LOOP)R=new h.LineLoop(M,A);else if(g.mode===S.POINTS)R=new h.Points(M,A);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(R.geometry.morphAttributes).length>0&&ye(R,r),R.name=e.createUniqueName(r.name||"mesh_"+t),w(R,r),g.extensions&&I(s,R,g),e.assignFinalMaterial(R),l.push(R)}for(let p=0,m=l.length;p<m;p++)e.associations.set(l[p],{meshes:t,primitives:p});if(l.length===1)return r.extensions&&I(s,l[0],r),l[0];const f=new h.Group;r.extensions&&I(s,f,r),e.associations.set(f,{meshes:t});for(let p=0,m=l.length;p<m;p++)f.add(l[p]);return f})}loadCamera(t){let e;const n=this.json.cameras[t],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?e=new h.PerspectiveCamera(h.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(e=new h.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(e.name=this.createUniqueName(n.name)),w(e,n),Promise.resolve(e)}loadSkin(t){const e=this.json.skins[t],n=[];for(let s=0,r=e.joints.length;s<r;s++)n.push(this._loadNodeShallow(e.joints[s]));return e.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",e.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){const r=s.pop(),o=s,a=[],i=[];for(let c=0,u=o.length;c<u;c++){const l=o[c];if(l){a.push(l);const f=new h.Matrix4;r!==null&&f.fromArray(r.array,c*16),i.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[c])}return new h.Skeleton(a,i)})}loadAnimation(t){const e=this.json,n=this,s=e.animations[t],r=s.name?s.name:"animation_"+t,o=[],a=[],i=[],c=[],u=[];for(let l=0,f=s.channels.length;l<f;l++){const p=s.channels[l],m=s.samplers[p.sampler],M=p.target,g=M.node,R=s.parameters!==void 0?s.parameters[m.input]:m.input,A=s.parameters!==void 0?s.parameters[m.output]:m.output;M.node!==void 0&&(o.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",R)),i.push(this.getDependency("accessor",A)),c.push(m),u.push(M))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(i),Promise.all(c),Promise.all(u)]).then(function(l){const f=l[0],p=l[1],m=l[2],M=l[3],g=l[4],R=[];for(let x=0,E=f.length;x<E;x++){const L=f[x],b=p[x],y=m[x],P=M[x],C=g[x];if(L===void 0)continue;L.updateMatrix&&L.updateMatrix();const k=n._createAnimationTracks(L,b,y,P,C);if(k)for(let H=0;H<k.length;H++)R.push(k[H])}const A=new h.AnimationClip(r,void 0,R);return w(A,s),A})}createNodeMesh(t){const e=this.json,n=this,s=e.nodes[t];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(r){const o=n._getNodeRef(n.meshCache,s.mesh,r);return s.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let i=0,c=s.weights.length;i<c;i++)a.morphTargetInfluences[i]=s.weights[i]}),o})}loadNode(t){const e=this.json,n=this,s=e.nodes[t],r=n._loadNodeShallow(t),o=[],a=s.children||[];for(let c=0,u=a.length;c<u;c++)o.push(n.getDependency("node",a[c]));const i=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([r,Promise.all(o),i]).then(function(c){const u=c[0],l=c[1],f=c[2];f!==null&&u.traverse(function(p){p.isSkinnedMesh&&p.bind(f,Ne)});for(let p=0,m=l.length;p<m;p++)u.add(l[p]);if(u.userData.pivot!==void 0&&l.length>0){const p=u.userData.pivot,m=l[0];u.pivot=new h.Vector3().fromArray(p),u.position.x-=p[0],u.position.y-=p[1],u.position.z-=p[2],m.position.set(0,0,0),delete u.userData.pivot}return u})}_loadNodeShallow(t){const e=this.json,n=this.extensions,s=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];const r=e.nodes[t],o=r.name?s.createUniqueName(r.name):"",a=[],i=s._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(t)});return i&&a.push(i),r.camera!==void 0&&a.push(s.getDependency("camera",r.camera).then(function(c){return s._getNodeRef(s.cameraCache,r.camera,c)})),s._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(t)}).forEach(function(c){a.push(c)}),this.nodeCache[t]=Promise.all(a).then(function(c){let u;if(r.isBone===!0?u=new h.Bone:c.length>1?u=new h.Group:c.length===1?u=c[0]:u=new h.Object3D,u!==c[0])for(let l=0,f=c.length;l<f;l++)u.add(c[l]);if(r.name&&(u.userData.name=r.name,u.name=o),w(u,r),r.extensions&&I(n,u,r),r.matrix!==void 0){const l=new h.Matrix4;l.fromArray(r.matrix),u.applyMatrix4(l)}else r.translation!==void 0&&u.position.fromArray(r.translation),r.rotation!==void 0&&u.quaternion.fromArray(r.rotation),r.scale!==void 0&&u.scale.fromArray(r.scale);if(!s.associations.has(u))s.associations.set(u,{});else if(r.mesh!==void 0&&s.meshCache.refs[r.mesh]>1){const l=s.associations.get(u);s.associations.set(u,{...l})}return s.associations.get(u).nodes=t,u}),this.nodeCache[t]}loadScene(t){const e=this.extensions,n=this.json.scenes[t],s=this,r=new h.Group;n.name&&(r.name=s.createUniqueName(n.name)),w(r,n),n.extensions&&I(e,r,n);const o=n.nodes||[],a=[];for(let i=0,c=o.length;i<c;i++)a.push(s.getDependency("node",o[i]));return Promise.all(a).then(function(i){for(let u=0,l=i.length;u<l;u++){const f=i[u];f.parent!==null?r.add(J(f)):r.add(f)}const c=u=>{const l=new Map;for(const[f,p]of s.associations)(f instanceof h.Material||f instanceof h.Texture)&&l.set(f,p);return u.traverse(f=>{const p=s.associations.get(f);p!=null&&l.set(f,p)}),l};return s.associations=c(r),r})}_createAnimationTracks(t,e,n,s,r){const o=[],a=t.name?t.name:t.uuid,i=[];N[r.path]===N.weights?t.traverse(function(f){f.morphTargetInfluences&&i.push(f.name?f.name:f.uuid)}):i.push(a);let c;switch(N[r.path]){case N.weights:c=h.NumberKeyframeTrack;break;case N.rotation:c=h.QuaternionKeyframeTrack;break;case N.translation:case N.scale:c=h.VectorKeyframeTrack;break;default:n.itemSize===1?c=h.NumberKeyframeTrack:c=h.VectorKeyframeTrack;break}const u=s.interpolation!==void 0?_e[s.interpolation]:h.InterpolateLinear,l=this._getArrayFromAccessor(n);for(let f=0,p=i.length;f<p;f++){const m=new c(i[f]+"."+N[r.path],e.array,l,u);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),o.push(m)}return o}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const n=U(e.constructor),s=new Float32Array(e.length);for(let r=0,o=e.length;r<o;r++)s[r]=e[r]*n;e=s}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(n){const s=this instanceof h.QuaternionKeyframeTrack?Ae:Q;return new s(this.times,this.values,this.getValueSize()/3,n)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Ce(d,t,e){const n=t.attributes,s=new h.Box3;if(n.POSITION!==void 0){const a=e.json.accessors[n.POSITION],i=a.min,c=a.max;if(i!==void 0&&c!==void 0){if(s.set(new h.Vector3(i[0],i[1],i[2]),new h.Vector3(c[0],c[1],c[2])),a.normalized){const u=U(O[a.componentType]);s.min.multiplyScalar(u),s.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=t.targets;if(r!==void 0){const a=new h.Vector3,i=new h.Vector3;for(let c=0,u=r.length;c<u;c++){const l=r[c];if(l.POSITION!==void 0){const f=e.json.accessors[l.POSITION],p=f.min,m=f.max;if(p!==void 0&&m!==void 0){if(i.setX(Math.max(Math.abs(p[0]),Math.abs(m[0]))),i.setY(Math.max(Math.abs(p[1]),Math.abs(m[1]))),i.setZ(Math.max(Math.abs(p[2]),Math.abs(m[2]))),f.normalized){const M=U(O[f.componentType]);i.multiplyScalar(M)}a.max(i)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(a)}d.boundingBox=s;const o=new h.Sphere;s.getCenter(o.center),o.radius=s.min.distanceTo(s.max)/2,d.boundingSphere=o}function q(d,t,e){const n=t.attributes,s=[];function r(o,a){return e.getDependency("accessor",o).then(function(i){d.setAttribute(a,i)})}for(const o in n){const a=B[o]||o.toLowerCase();a in d.attributes||s.push(r(n[o],a))}if(t.indices!==void 0&&!d.index){const o=e.getDependency("accessor",t.indices).then(function(a){d.setIndex(a)});s.push(o)}return h.ColorManagement.workingColorSpace!==h.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${h.ColorManagement.workingColorSpace}" not supported.`),w(d,t),Ce(d,t,e),Promise.all(s).then(function(){return t.targets!==void 0?Se(d,t.targets,e):d})}exports.GLTFLoader=Z;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./model-source-D3_k9qRK.js"),K=require("./BufferGeometryUtils-CMbyl1DL.js");function J(d){const t=new Map,e=new Map,n=d.clone();return W(d,n,function(s,r){t.set(r,s),e.set(s,r)}),n.traverse(function(s){if(!s.isSkinnedMesh)return;const r=s,o=t.get(s),a=o.skeleton.bones;r.skeleton=o.skeleton.clone(),r.bindMatrix.copy(o.bindMatrix),r.skeleton.bones=a.map(function(i){return e.get(i)}),r.bind(r.skeleton,r.bindMatrix)}),n}function W(d,t,e){e(d,t);for(let n=0;n<d.children.length;n++)W(d.children[n],t.children[n],e)}class Z extends h.Loader{constructor(t){super(t),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new se(e)}),this.register(function(e){return new re(e)}),this.register(function(e){return new de(e)}),this.register(function(e){return new pe(e)}),this.register(function(e){return new me(e)}),this.register(function(e){return new oe(e)}),this.register(function(e){return new ae(e)}),this.register(function(e){return new ce(e)}),this.register(function(e){return new le(e)}),this.register(function(e){return new ne(e)}),this.register(function(e){return new ue(e)}),this.register(function(e){return new ie(e)}),this.register(function(e){return new fe(e)}),this.register(function(e){return new he(e)}),this.register(function(e){return new ee(e)}),this.register(function(e){return new j(e,T.EXT_MESHOPT_COMPRESSION)}),this.register(function(e){return new j(e,T.KHR_MESHOPT_COMPRESSION)}),this.register(function(e){return new ge(e)})}load(t,e,n,s){const r=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=h.LoaderUtils.extractUrlBase(t);o=h.LoaderUtils.resolveURL(c,this.path)}else o=h.LoaderUtils.extractUrlBase(t);this.manager.itemStart(t);const a=function(c){s?s(c):console.error(c),r.manager.itemError(t),r.manager.itemEnd(t)},i=new h.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(t,function(c){try{r.parse(c,o,function(u){e(u),r.manager.itemEnd(t)},a)}catch(u){a(u)}},n,a)}setDRACOLoader(t){return this.dracoLoader=t,this}setKTX2Loader(t){return this.ktx2Loader=t,this}setMeshoptDecoder(t){return this.meshoptDecoder=t,this}register(t){return this.pluginCallbacks.indexOf(t)===-1&&this.pluginCallbacks.push(t),this}unregister(t){return this.pluginCallbacks.indexOf(t)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(t),1),this}parse(t,e,n,s){let r;const o={},a={},i=new TextDecoder;if(typeof t=="string")r=JSON.parse(t);else if(t instanceof ArrayBuffer)if(i.decode(new Uint8Array(t,0,4))===Y){try{o[T.KHR_BINARY_GLTF]=new Te(t)}catch(l){s&&s(l);return}r=JSON.parse(o[T.KHR_BINARY_GLTF].content)}else r=JSON.parse(i.decode(t));else r=t;if(r.asset===void 0||r.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new Ie(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const l=this.pluginCallbacks[u](c);l.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[l.name]=l,o[l.name]=!0}if(r.extensionsUsed)for(let u=0;u<r.extensionsUsed.length;++u){const l=r.extensionsUsed[u],f=r.extensionsRequired||[];switch(l){case T.KHR_MATERIALS_UNLIT:o[l]=new te;break;case T.KHR_DRACO_MESH_COMPRESSION:o[l]=new Re(r,this.dracoLoader);break;case T.KHR_TEXTURE_TRANSFORM:o[l]=new Me;break;case T.KHR_MESH_QUANTIZATION:o[l]=new Ee;break;default:f.indexOf(l)>=0&&a[l]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+l+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,s)}parseAsync(t,e){const n=this;return new Promise(function(s,r){n.parse(t,e,s,r)})}}function $(){let d={};return{get:function(t){return d[t]},add:function(t,e){d[t]=e},remove:function(t){delete d[t]},removeAll:function(){d={}}}}function _(d,t,e){const n=d.json.materials[t];return n.extensions&&n.extensions[e]?n.extensions[e]:null}const T={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ee{constructor(t){this.parser=t,this.name=T.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let n=0,s=e.length;n<s;n++){const r=e[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&t._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(t){const e=this.parser,n="light:"+t;let s=e.cache.get(n);if(s)return s;const r=e.json,i=((r.extensions&&r.extensions[this.name]||{}).lights||[])[t];let c;const u=new h.Color(16777215);i.color!==void 0&&u.setRGB(i.color[0],i.color[1],i.color[2],h.LinearSRGBColorSpace);const l=i.range!==void 0?i.range:0;switch(i.type){case"directional":c=new h.DirectionalLight(u),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new h.PointLight(u),c.distance=l;break;case"spot":c=new h.SpotLight(u),c.distance=l,i.spot=i.spot||{},i.spot.innerConeAngle=i.spot.innerConeAngle!==void 0?i.spot.innerConeAngle:0,i.spot.outerConeAngle=i.spot.outerConeAngle!==void 0?i.spot.outerConeAngle:Math.PI/4,c.angle=i.spot.outerConeAngle,c.penumbra=1-i.spot.innerConeAngle/i.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+i.type)}return c.position.set(0,0,0),w(c,i),i.intensity!==void 0&&(c.intensity=i.intensity),c.name=e.createUniqueName(i.name||"light_"+t),s=Promise.resolve(c),e.cache.add(n,s),s}getDependency(t,e){if(t==="light")return this._loadLight(e)}createNodeAttachment(t){const e=this,n=this.parser,r=n.json.nodes[t],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(i){return n._getNodeRef(e.cache,a,i)})}}class te{constructor(){this.name=T.KHR_MATERIALS_UNLIT}getMaterialType(){return h.MeshBasicMaterial}extendParams(t,e,n){const s=[];t.color=new h.Color(1,1,1),t.opacity=1;const r=e.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const o=r.baseColorFactor;t.color.setRGB(o[0],o[1],o[2],h.LinearSRGBColorSpace),t.opacity=o[3]}r.baseColorTexture!==void 0&&s.push(n.assignTexture(t,"map",r.baseColorTexture,h.SRGBColorSpace))}return Promise.all(s)}}class ne{constructor(t){this.parser=t,this.name=T.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);return n===null||n.emissiveStrength!==void 0&&(e.emissiveIntensity=n.emissiveStrength),Promise.resolve()}}class se{constructor(t){this.parser=t,this.name=T.KHR_MATERIALS_CLEARCOAT}getMaterialType(t){return _(this.parser,t,this.name)!==null?h.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);if(n===null)return Promise.resolve();const s=[];if(n.clearcoatFactor!==void 0&&(e.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&s.push(this.parser.assignTexture(e,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(e.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(e,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(s.push(this.parser.assignTexture(e,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){const r=n.clearcoatNormalTexture.scale;e.clearcoatNormalScale=new h.Vector2(r,r)}return Promise.all(s)}}class re{constructor(t){this.parser=t,this.name=T.KHR_MATERIALS_DISPERSION}getMaterialType(t){return _(this.parser,t,this.name)!==null?h.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);return n===null||(e.dispersion=n.dispersion!==void 0?n.dispersion:0),Promise.resolve()}}class ie{constructor(t){this.parser=t,this.name=T.KHR_MATERIALS_IRIDESCENCE}getMaterialType(t){return _(this.parser,t,this.name)!==null?h.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);if(n===null)return Promise.resolve();const s=[];return n.iridescenceFactor!==void 0&&(e.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&s.push(this.parser.assignTexture(e,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==void 0&&(e.iridescenceIOR=n.iridescenceIor),e.iridescenceThicknessRange===void 0&&(e.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(e.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(e.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&s.push(this.parser.assignTexture(e,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(s)}}class oe{constructor(t){this.parser=t,this.name=T.KHR_MATERIALS_SHEEN}getMaterialType(t){return _(this.parser,t,this.name)!==null?h.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);if(n===null)return Promise.resolve();const s=[];if(e.sheenColor=new h.Color(0,0,0),e.sheenRoughness=0,e.sheen=1,n.sheenColorFactor!==void 0){const r=n.sheenColorFactor;e.sheenColor.setRGB(r[0],r[1],r[2],h.LinearSRGBColorSpace)}return n.sheenRoughnessFactor!==void 0&&(e.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&s.push(this.parser.assignTexture(e,"sheenColorMap",n.sheenColorTexture,h.SRGBColorSpace)),n.sheenRoughnessTexture!==void 0&&s.push(this.parser.assignTexture(e,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(s)}}class ae{constructor(t){this.parser=t,this.name=T.KHR_MATERIALS_TRANSMISSION}getMaterialType(t){return _(this.parser,t,this.name)!==null?h.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);if(n===null)return Promise.resolve();const s=[];return n.transmissionFactor!==void 0&&(e.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&s.push(this.parser.assignTexture(e,"transmissionMap",n.transmissionTexture)),Promise.all(s)}}class ce{constructor(t){this.parser=t,this.name=T.KHR_MATERIALS_VOLUME}getMaterialType(t){return _(this.parser,t,this.name)!==null?h.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);if(n===null)return Promise.resolve();const s=[];e.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&s.push(this.parser.assignTexture(e,"thicknessMap",n.thicknessTexture)),e.attenuationDistance=n.attenuationDistance||1/0;const r=n.attenuationColor||[1,1,1];return e.attenuationColor=new h.Color().setRGB(r[0],r[1],r[2],h.LinearSRGBColorSpace),Promise.all(s)}}class le{constructor(t){this.parser=t,this.name=T.KHR_MATERIALS_IOR}getMaterialType(t){return _(this.parser,t,this.name)!==null?h.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);return n===null||(e.ior=n.ior!==void 0?n.ior:1.5),Promise.resolve()}}class ue{constructor(t){this.parser=t,this.name=T.KHR_MATERIALS_SPECULAR}getMaterialType(t){return _(this.parser,t,this.name)!==null?h.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);if(n===null)return Promise.resolve();const s=[];e.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&s.push(this.parser.assignTexture(e,"specularIntensityMap",n.specularTexture));const r=n.specularColorFactor||[1,1,1];return e.specularColor=new h.Color().setRGB(r[0],r[1],r[2],h.LinearSRGBColorSpace),n.specularColorTexture!==void 0&&s.push(this.parser.assignTexture(e,"specularColorMap",n.specularColorTexture,h.SRGBColorSpace)),Promise.all(s)}}class he{constructor(t){this.parser=t,this.name=T.EXT_MATERIALS_BUMP}getMaterialType(t){return _(this.parser,t,this.name)!==null?h.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);if(n===null)return Promise.resolve();const s=[];return e.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0&&s.push(this.parser.assignTexture(e,"bumpMap",n.bumpTexture)),Promise.all(s)}}class fe{constructor(t){this.parser=t,this.name=T.KHR_MATERIALS_ANISOTROPY}getMaterialType(t){return _(this.parser,t,this.name)!==null?h.MeshPhysicalMaterial:null}extendMaterialParams(t,e){const n=_(this.parser,t,this.name);if(n===null)return Promise.resolve();const s=[];return n.anisotropyStrength!==void 0&&(e.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(e.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&s.push(this.parser.assignTexture(e,"anisotropyMap",n.anisotropyTexture)),Promise.all(s)}}class de{constructor(t){this.parser=t,this.name=T.KHR_TEXTURE_BASISU}loadTexture(t){const e=this.parser,n=e.json,s=n.textures[t];if(!s.extensions||!s.extensions[this.name])return null;const r=s.extensions[this.name],o=e.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,o)}}class pe{constructor(t){this.parser=t,this.name=T.EXT_TEXTURE_WEBP}loadTexture(t){const e=this.name,n=this.parser,s=n.json,r=s.textures[t];if(!r.extensions||!r.extensions[e])return null;const o=r.extensions[e],a=s.images[o.source];let i=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(i=c)}return n.loadTextureImage(t,o.source,i)}}class me{constructor(t){this.parser=t,this.name=T.EXT_TEXTURE_AVIF}loadTexture(t){const e=this.name,n=this.parser,s=n.json,r=s.textures[t];if(!r.extensions||!r.extensions[e])return null;const o=r.extensions[e],a=s.images[o.source];let i=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(i=c)}return n.loadTextureImage(t,o.source,i)}}class j{constructor(t,e){this.name=e,this.parser=t}loadBufferView(t){const e=this.parser.json,n=e.bufferViews[t];if(n.extensions&&n.extensions[this.name]){const s=n.extensions[this.name],r=this.parser.getDependency("buffer",s.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const i=s.byteOffset||0,c=s.byteLength||0,u=s.count,l=s.byteStride,f=new Uint8Array(a,i,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,l,f,s.mode,s.filter).then(function(p){return p.buffer}):o.ready.then(function(){const p=new ArrayBuffer(u*l);return o.decodeGltfBuffer(new Uint8Array(p),u,l,f,s.mode,s.filter),p})})}else return null}}class ge{constructor(t){this.name=T.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,n=e.nodes[t];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const s=e.meshes[n.mesh];for(const c of s.primitives)if(c.mode!==S.TRIANGLES&&c.mode!==S.TRIANGLE_STRIP&&c.mode!==S.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=n.extensions[this.name].attributes,a=[],i={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(u=>(i[c]=u,i[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(t)),Promise.all(a).then(c=>{const u=c.pop(),l=u.isGroup?u.children:[u],f=c[0].count,p=[];for(const m of l){const M=new h.Matrix4,g=new h.Vector3,R=new h.Quaternion,A=new h.Vector3(1,1,1),x=new h.InstancedMesh(m.geometry,m.material,f);for(let E=0;E<f;E++)i.TRANSLATION&&g.fromBufferAttribute(i.TRANSLATION,E),i.ROTATION&&R.fromBufferAttribute(i.ROTATION,E),i.SCALE&&A.fromBufferAttribute(i.SCALE,E),x.setMatrixAt(E,M.compose(g,R,A));for(const E in i)if(E==="_COLOR_0"){const L=i[E];x.instanceColor=new h.InstancedBufferAttribute(L.array,L.itemSize,L.normalized)}else E!=="TRANSLATION"&&E!=="ROTATION"&&E!=="SCALE"&&m.geometry.setAttribute(E,i[E]);h.Object3D.prototype.copy.call(x,m),this.parser.assignFinalMaterial(x),p.push(x)}return u.isGroup?(u.clear(),u.add(...p),u):p[0]}))}}const Y="glTF",F=12,V={JSON:1313821514,BIN:5130562};class Te{constructor(t){this.name=T.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,F),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==Y)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-F,r=new DataView(t,F);let o=0;for(;o<s;){const a=r.getUint32(o,!0);o+=4;const i=r.getUint32(o,!0);if(o+=4,i===V.JSON){const c=new Uint8Array(t,F+o,a);this.content=n.decode(c)}else if(i===V.BIN){const c=F+o;this.body=t.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Re{constructor(t,e){if(!e)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=T.KHR_DRACO_MESH_COMPRESSION,this.json=t,this.dracoLoader=e,this.dracoLoader.preload()}decodePrimitive(t,e){const n=this.json,s=this.dracoLoader,r=t.extensions[this.name].bufferView,o=t.extensions[this.name].attributes,a={},i={},c={};for(const u in o){const l=B[u]||u.toLowerCase();a[l]=o[u]}for(const u in t.attributes){const l=B[u]||u.toLowerCase();if(o[u]!==void 0){const f=n.accessors[t.attributes[u]],p=O[f.componentType];c[l]=p.name,i[l]=f.normalized===!0}}return e.getDependency("bufferView",r).then(function(u){return new Promise(function(l,f){s.decodeDracoFile(u,function(p){for(const m in p.attributes){const M=p.attributes[m],g=i[m];g!==void 0&&(M.normalized=g)}l(p)},a,c,h.LinearSRGBColorSpace,f)})})}}class Me{constructor(){this.name=T.KHR_TEXTURE_TRANSFORM}extendTexture(t,e){return(e.texCoord===void 0||e.texCoord===t.channel)&&e.offset===void 0&&e.rotation===void 0&&e.scale===void 0||(t=t.clone(),e.texCoord!==void 0&&(t.channel=e.texCoord),e.offset!==void 0&&t.offset.fromArray(e.offset),e.rotation!==void 0&&(t.rotation=e.rotation),e.scale!==void 0&&t.repeat.fromArray(e.scale),t.needsUpdate=!0),t}}class Ee{constructor(){this.name=T.KHR_MESH_QUANTIZATION}}class Q extends h.Interpolant{constructor(t,e,n,s){super(t,e,n,s)}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=t*s*3+s;for(let o=0;o!==s;o++)e[o]=n[r+o];return e}interpolate_(t,e,n,s){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,i=a*2,c=a*3,u=s-e,l=(n-e)/u,f=l*l,p=f*l,m=t*c,M=m-c,g=-2*p+3*f,R=p-f,A=1-g,x=R-f+l;for(let E=0;E!==a;E++){const L=o[M+E+a],b=o[M+E+i]*u,y=o[m+E+a],P=o[m+E]*u;r[E]=A*L+x*b+g*y+R*P}return r}}const xe=new h.Quaternion;class Ae extends Q{interpolate_(t,e,n,s){const r=super.interpolate_(t,e,n,s);return xe.fromArray(r).normalize().toArray(r),r}}const S={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},O={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},z={9728:h.NearestFilter,9729:h.LinearFilter,9984:h.NearestMipmapNearestFilter,9985:h.LinearMipmapNearestFilter,9986:h.NearestMipmapLinearFilter,9987:h.LinearMipmapLinearFilter},X={33071:h.ClampToEdgeWrapping,33648:h.MirroredRepeatWrapping,10497:h.RepeatWrapping},D={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},B={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},N={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},_e={CUBICSPLINE:void 0,LINEAR:h.InterpolateLinear,STEP:h.InterpolateDiscrete},G={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Le(d){return d.DefaultMaterial===void 0&&(d.DefaultMaterial=new h.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:h.FrontSide})),d.DefaultMaterial}function I(d,t,e){for(const n in e.extensions)d[n]===void 0&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=e.extensions[n])}function w(d,t){t.extras!==void 0&&(typeof t.extras=="object"?Object.assign(d.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Se(d,t,e){let n=!1,s=!1,r=!1;for(let c=0,u=t.length;c<u;c++){const l=t[c];if(l.POSITION!==void 0&&(n=!0),l.NORMAL!==void 0&&(s=!0),l.COLOR_0!==void 0&&(r=!0),n&&s&&r)break}if(!n&&!s&&!r)return Promise.resolve(d);const o=[],a=[],i=[];for(let c=0,u=t.length;c<u;c++){const l=t[c];if(n){const f=l.POSITION!==void 0?e.getDependency("accessor",l.POSITION):d.attributes.position;o.push(f)}if(s){const f=l.NORMAL!==void 0?e.getDependency("accessor",l.NORMAL):d.attributes.normal;a.push(f)}if(r){const f=l.COLOR_0!==void 0?e.getDependency("accessor",l.COLOR_0):d.attributes.color;i.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(i)]).then(function(c){const u=c[0],l=c[1],f=c[2];return n&&(d.morphAttributes.position=u),s&&(d.morphAttributes.normal=l),r&&(d.morphAttributes.color=f),d.morphTargetsRelative=!0,d})}function ye(d,t){if(d.updateMorphTargets(),t.weights!==void 0)for(let e=0,n=t.weights.length;e<n;e++)d.morphTargetInfluences[e]=t.weights[e];if(t.extras&&Array.isArray(t.extras.targetNames)){const e=t.extras.targetNames;if(d.morphTargetInfluences.length===e.length){d.morphTargetDictionary={};for(let n=0,s=e.length;n<s;n++)d.morphTargetDictionary[e[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function we(d){let t;const e=d.extensions&&d.extensions[T.KHR_DRACO_MESH_COMPRESSION];if(e?t="draco:"+e.bufferView+":"+e.indices+":"+v(e.attributes):t=d.indices+":"+v(d.attributes)+":"+d.mode,d.targets!==void 0)for(let n=0,s=d.targets.length;n<s;n++)t+=":"+v(d.targets[n]);return t}function v(d){let t="";const e=Object.keys(d).sort();for(let n=0,s=e.length;n<s;n++)t+=e[n]+":"+d[e[n]]+";";return t}function U(d){switch(d){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function be(d){return d.search(/\.jpe?g($|\?)/i)>0||d.search(/^data\:image\/jpeg/)===0?"image/jpeg":d.search(/\.webp($|\?)/i)>0||d.search(/^data\:image\/webp/)===0?"image/webp":d.search(/\.ktx2($|\?)/i)>0||d.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Ne=new h.Matrix4;class Ie{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new $,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,s=-1,r=!1,o=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"u"){const a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;const i=a.match(/Version\/(\d+)/);s=n&&i?parseInt(i[1],10):-1,r=a.indexOf("Firefox")>-1,o=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&s<17||r&&o<98?this.textureLoader=new h.TextureLoader(this.options.manager):this.textureLoader=new h.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new h.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const n=this,s=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][s.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:s.asset,parser:n,userData:{}};return I(r,a,s),w(a,s),Promise.all(n._invokeAll(function(i){return i.afterRoot&&i.afterRoot(a)})).then(function(){for(const i of a.scenes)i.updateMatrixWorld();t(a)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],n=this.json.meshes||[];for(let s=0,r=e.length;s<r;s++){const o=e[s].joints;for(let a=0,i=o.length;a<i;a++)t[o[a]].isBone=!0}for(let s=0,r=t.length;s<r;s++){const o=t[s];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(t,e){e!==void 0&&(t.refs[e]===void 0&&(t.refs[e]=t.uses[e]=0),t.refs[e]++)}_getNodeRef(t,e,n){if(t.refs[e]<=1)return n;const s=n.clone(),r=(o,a)=>{const i=this.associations.get(o);i!=null&&this.associations.set(a,i);for(const[c,u]of o.children.entries())r(u,a.children[c])};return r(n,s),s.name+="_instance_"+t.uses[e]++,s}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let n=0;n<e.length;n++){const s=t(e[n]);if(s)return s}return null}_invokeAll(t){const e=Object.values(this.plugins);e.unshift(this);const n=[];for(let s=0;s<e.length;s++){const r=t(e[s]);r&&n.push(r)}return n}getDependency(t,e){const n=t+":"+e;let s=this.cache.get(n);if(!s){switch(t){case"scene":s=this.loadScene(e);break;case"node":s=this._invokeOne(function(r){return r.loadNode&&r.loadNode(e)});break;case"mesh":s=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(e)});break;case"accessor":s=this.loadAccessor(e);break;case"bufferView":s=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(e)});break;case"buffer":s=this.loadBuffer(e);break;case"material":s=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(e)});break;case"texture":s=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(e)});break;case"skin":s=this.loadSkin(e);break;case"animation":s=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(e)});break;case"camera":s=this.loadCamera(e);break;default:if(s=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(t,e)}),!s)throw new Error("Unknown type: "+t);break}this.cache.add(n,s)}return s}getDependencies(t){let e=this.cache.get(t);if(!e){const n=this,s=this.json[t+(t==="mesh"?"es":"s")]||[];e=Promise.all(s.map(function(r,o){return n.getDependency(t,o)})),this.cache.add(t,e)}return e}loadBuffer(t){const e=this.json.buffers[t],n=this.fileLoader;if(e.type&&e.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+e.type+" buffer type is not supported.");if(e.uri===void 0&&t===0)return Promise.resolve(this.extensions[T.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(r,o){n.load(h.LoaderUtils.resolveURL(e.uri,s.path),r,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+e.uri+'".'))})})}loadBufferView(t){const e=this.json.bufferViews[t];return this.getDependency("buffer",e.buffer).then(function(n){const s=e.byteLength||0,r=e.byteOffset||0;return n.slice(r,r+s)})}loadAccessor(t){const e=this,n=this.json,s=this.json.accessors[t];if(s.bufferView===void 0&&s.sparse===void 0){const o=D[s.type],a=O[s.componentType],i=s.normalized===!0,c=new a(s.count*o);return Promise.resolve(new h.BufferAttribute(c,o,i))}const r=[];return s.bufferView!==void 0?r.push(this.getDependency("bufferView",s.bufferView)):r.push(null),s.sparse!==void 0&&(r.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(r).then(function(o){const a=o[0],i=D[s.type],c=O[s.componentType],u=c.BYTES_PER_ELEMENT,l=u*i,f=s.byteOffset||0,p=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,m=s.normalized===!0;let M,g;if(p&&p!==l){const R=Math.floor(f/p),A="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+R+":"+s.count;let x=e.cache.get(A);x||(M=new c(a,R*p,s.count*p/u),x=new h.InterleavedBuffer(M,p/u),e.cache.add(A,x)),g=new h.InterleavedBufferAttribute(x,i,f%p/u,m)}else a===null?M=new c(s.count*i):M=new c(a,f,s.count*i),g=new h.BufferAttribute(M,i,m);if(s.sparse!==void 0){const R=D.SCALAR,A=O[s.sparse.indices.componentType],x=s.sparse.indices.byteOffset||0,E=s.sparse.values.byteOffset||0,L=new A(o[1],x,s.sparse.count*R),b=new c(o[2],E,s.sparse.count*i);a!==null&&(g=new h.BufferAttribute(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let y=0,P=L.length;y<P;y++){const C=L[y];if(g.setX(C,b[y*i]),i>=2&&g.setY(C,b[y*i+1]),i>=3&&g.setZ(C,b[y*i+2]),i>=4&&g.setW(C,b[y*i+3]),i>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=m}return g})}loadTexture(t){const e=this.json,n=this.options,r=e.textures[t].source,o=e.images[r];let a=this.textureLoader;if(o.uri){const i=n.manager.getHandler(o.uri);i!==null&&(a=i)}return this.loadTextureImage(t,r,a)}loadTextureImage(t,e,n){const s=this,r=this.json,o=r.textures[t],a=r.images[e],i=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[i])return this.textureCache[i];const c=this.loadImageSource(e,n).then(function(u){u.flipY=!1,u.name=o.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const f=(r.samplers||{})[o.sampler]||{};return u.magFilter=z[f.magFilter]||h.LinearFilter,u.minFilter=z[f.minFilter]||h.LinearMipmapLinearFilter,u.wrapS=X[f.wrapS]||h.RepeatWrapping,u.wrapT=X[f.wrapT]||h.RepeatWrapping,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==h.NearestFilter&&u.minFilter!==h.LinearFilter,s.associations.set(u,{textures:t}),u}).catch(function(){return null});return this.textureCache[i]=c,c}loadImageSource(t,e){const n=this,s=this.json,r=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(l=>l.clone());const o=s.images[t],a=self.URL||self.webkitURL;let i=o.uri||"",c=!1;if(o.bufferView!==void 0)i=n.getDependency("bufferView",o.bufferView).then(function(l){c=!0;const f=new Blob([l],{type:o.mimeType});return i=a.createObjectURL(f),i});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const u=Promise.resolve(i).then(function(l){return new Promise(function(f,p){let m=f;e.isImageBitmapLoader===!0&&(m=function(M){const g=new h.Texture(M);g.needsUpdate=!0,f(g)}),e.load(h.LoaderUtils.resolveURL(l,r.path),m,void 0,p)})}).then(function(l){return c===!0&&a.revokeObjectURL(i),w(l,o),l.userData.mimeType=o.mimeType||be(o.uri),l}).catch(function(l){throw console.error("THREE.GLTFLoader: Couldn't load texture",i),l});return this.sourceCache[t]=u,u}assignTexture(t,e,n,s){const r=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),r.extensions[T.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[T.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const i=r.associations.get(o);o=r.extensions[T.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,i)}}return s!==void 0&&(o.colorSpace=s),t[e]=o,o})}assignFinalMaterial(t){const e=t.geometry;let n=t.material;const s=e.attributes.tangent===void 0,r=e.attributes.color!==void 0,o=e.attributes.normal===void 0;if(t.isPoints){const a="PointsMaterial:"+n.uuid;let i=this.cache.get(a);i||(i=new h.PointsMaterial,h.Material.prototype.copy.call(i,n),i.color.copy(n.color),i.map=n.map,i.sizeAttenuation=!1,this.cache.add(a,i)),n=i}else if(t.isLine){const a="LineBasicMaterial:"+n.uuid;let i=this.cache.get(a);i||(i=new h.LineBasicMaterial,h.Material.prototype.copy.call(i,n),i.color.copy(n.color),i.map=n.map,this.cache.add(a,i)),n=i}if(s||r||o){let a="ClonedMaterial:"+n.uuid+":";s&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let i=this.cache.get(a);i||(i=n.clone(),r&&(i.vertexColors=!0),o&&(i.flatShading=!0),s&&(i.normalScale&&(i.normalScale.y*=-1),i.clearcoatNormalScale&&(i.clearcoatNormalScale.y*=-1)),this.cache.add(a,i),this.associations.set(i,this.associations.get(n))),n=i}t.material=n}getMaterialType(){return h.MeshStandardMaterial}loadMaterial(t){const e=this,n=this.json,s=this.extensions,r=n.materials[t];let o;const a={},i=r.extensions||{},c=[];if(i[T.KHR_MATERIALS_UNLIT]){const l=s[T.KHR_MATERIALS_UNLIT];o=l.getMaterialType(),c.push(l.extendParams(a,r,e))}else{const l=r.pbrMetallicRoughness||{};if(a.color=new h.Color(1,1,1),a.opacity=1,Array.isArray(l.baseColorFactor)){const f=l.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],h.LinearSRGBColorSpace),a.opacity=f[3]}l.baseColorTexture!==void 0&&c.push(e.assignTexture(a,"map",l.baseColorTexture,h.SRGBColorSpace)),a.metalness=l.metallicFactor!==void 0?l.metallicFactor:1,a.roughness=l.roughnessFactor!==void 0?l.roughnessFactor:1,l.metallicRoughnessTexture!==void 0&&(c.push(e.assignTexture(a,"metalnessMap",l.metallicRoughnessTexture)),c.push(e.assignTexture(a,"roughnessMap",l.metallicRoughnessTexture))),o=this._invokeOne(function(f){return f.getMaterialType&&f.getMaterialType(t)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(t,a)})))}r.doubleSided===!0&&(a.side=h.DoubleSide);const u=r.alphaMode||G.OPAQUE;if(u===G.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===G.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==h.MeshBasicMaterial&&(c.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new h.Vector2(1,1),r.normalTexture.scale!==void 0)){const l=r.normalTexture.scale;a.normalScale.set(l,l)}if(r.occlusionTexture!==void 0&&o!==h.MeshBasicMaterial&&(c.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==h.MeshBasicMaterial){const l=r.emissiveFactor;a.emissive=new h.Color().setRGB(l[0],l[1],l[2],h.LinearSRGBColorSpace)}return r.emissiveTexture!==void 0&&o!==h.MeshBasicMaterial&&c.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,h.SRGBColorSpace)),Promise.all(c).then(function(){const l=new o(a);return r.name&&(l.name=r.name),w(l,r),e.associations.set(l,{materials:t}),r.extensions&&I(s,l,r),l})}createUniqueName(t){const e=h.PropertyBinding.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,n=this.extensions,s=this.primitiveCache;function r(a){return n[T.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(i){return q(i,a,e)})}const o=[];for(let a=0,i=t.length;a<i;a++){const c=t[a],u=we(c),l=s[u];if(l)o.push(l.promise);else{let f;c.extensions&&c.extensions[T.KHR_DRACO_MESH_COMPRESSION]?f=r(c):f=q(new h.BufferGeometry,c,e),s[u]={primitive:c,promise:f},o.push(f)}}return Promise.all(o)}loadMesh(t){const e=this,n=this.json,s=this.extensions,r=n.meshes[t],o=r.primitives,a=[];for(let i=0,c=o.length;i<c;i++){const u=o[i].material===void 0?Le(this.cache):this.getDependency("material",o[i].material);a.push(u)}return a.push(e.loadGeometries(o)),Promise.all(a).then(function(i){const c=i.slice(0,i.length-1),u=i[i.length-1],l=[];for(let p=0,m=u.length;p<m;p++){const M=u[p],g=o[p];let R;const A=c[p];if(g.mode===S.TRIANGLES||g.mode===S.TRIANGLE_STRIP||g.mode===S.TRIANGLE_FAN||g.mode===void 0)R=r.isSkinnedMesh===!0?new h.SkinnedMesh(M,A):new h.Mesh(M,A),R.isSkinnedMesh===!0&&R.normalizeSkinWeights(),g.mode===S.TRIANGLE_STRIP?R.geometry=K.toTrianglesDrawMode(R.geometry,h.TriangleStripDrawMode):g.mode===S.TRIANGLE_FAN&&(R.geometry=K.toTrianglesDrawMode(R.geometry,h.TriangleFanDrawMode));else if(g.mode===S.LINES)R=new h.LineSegments(M,A);else if(g.mode===S.LINE_STRIP)R=new h.Line(M,A);else if(g.mode===S.LINE_LOOP)R=new h.LineLoop(M,A);else if(g.mode===S.POINTS)R=new h.Points(M,A);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(R.geometry.morphAttributes).length>0&&ye(R,r),R.name=e.createUniqueName(r.name||"mesh_"+t),w(R,r),g.extensions&&I(s,R,g),e.assignFinalMaterial(R),l.push(R)}for(let p=0,m=l.length;p<m;p++)e.associations.set(l[p],{meshes:t,primitives:p});if(l.length===1)return r.extensions&&I(s,l[0],r),l[0];const f=new h.Group;r.extensions&&I(s,f,r),e.associations.set(f,{meshes:t});for(let p=0,m=l.length;p<m;p++)f.add(l[p]);return f})}loadCamera(t){let e;const n=this.json.cameras[t],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?e=new h.PerspectiveCamera(h.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(e=new h.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(e.name=this.createUniqueName(n.name)),w(e,n),Promise.resolve(e)}loadSkin(t){const e=this.json.skins[t],n=[];for(let s=0,r=e.joints.length;s<r;s++)n.push(this._loadNodeShallow(e.joints[s]));return e.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",e.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){const r=s.pop(),o=s,a=[],i=[];for(let c=0,u=o.length;c<u;c++){const l=o[c];if(l){a.push(l);const f=new h.Matrix4;r!==null&&f.fromArray(r.array,c*16),i.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',e.joints[c])}return new h.Skeleton(a,i)})}loadAnimation(t){const e=this.json,n=this,s=e.animations[t],r=s.name?s.name:"animation_"+t,o=[],a=[],i=[],c=[],u=[];for(let l=0,f=s.channels.length;l<f;l++){const p=s.channels[l],m=s.samplers[p.sampler],M=p.target,g=M.node,R=s.parameters!==void 0?s.parameters[m.input]:m.input,A=s.parameters!==void 0?s.parameters[m.output]:m.output;M.node!==void 0&&(o.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",R)),i.push(this.getDependency("accessor",A)),c.push(m),u.push(M))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(i),Promise.all(c),Promise.all(u)]).then(function(l){const f=l[0],p=l[1],m=l[2],M=l[3],g=l[4],R=[];for(let x=0,E=f.length;x<E;x++){const L=f[x],b=p[x],y=m[x],P=M[x],C=g[x];if(L===void 0)continue;L.updateMatrix&&L.updateMatrix();const k=n._createAnimationTracks(L,b,y,P,C);if(k)for(let H=0;H<k.length;H++)R.push(k[H])}const A=new h.AnimationClip(r,void 0,R);return w(A,s),A})}createNodeMesh(t){const e=this.json,n=this,s=e.nodes[t];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(r){const o=n._getNodeRef(n.meshCache,s.mesh,r);return s.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let i=0,c=s.weights.length;i<c;i++)a.morphTargetInfluences[i]=s.weights[i]}),o})}loadNode(t){const e=this.json,n=this,s=e.nodes[t],r=n._loadNodeShallow(t),o=[],a=s.children||[];for(let c=0,u=a.length;c<u;c++)o.push(n.getDependency("node",a[c]));const i=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([r,Promise.all(o),i]).then(function(c){const u=c[0],l=c[1],f=c[2];f!==null&&u.traverse(function(p){p.isSkinnedMesh&&p.bind(f,Ne)});for(let p=0,m=l.length;p<m;p++)u.add(l[p]);if(u.userData.pivot!==void 0&&l.length>0){const p=u.userData.pivot,m=l[0];u.pivot=new h.Vector3().fromArray(p),u.position.x-=p[0],u.position.y-=p[1],u.position.z-=p[2],m.position.set(0,0,0),delete u.userData.pivot}return u})}_loadNodeShallow(t){const e=this.json,n=this.extensions,s=this;if(this.nodeCache[t]!==void 0)return this.nodeCache[t];const r=e.nodes[t],o=r.name?s.createUniqueName(r.name):"",a=[],i=s._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(t)});return i&&a.push(i),r.camera!==void 0&&a.push(s.getDependency("camera",r.camera).then(function(c){return s._getNodeRef(s.cameraCache,r.camera,c)})),s._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(t)}).forEach(function(c){a.push(c)}),this.nodeCache[t]=Promise.all(a).then(function(c){let u;if(r.isBone===!0?u=new h.Bone:c.length>1?u=new h.Group:c.length===1?u=c[0]:u=new h.Object3D,u!==c[0])for(let l=0,f=c.length;l<f;l++)u.add(c[l]);if(r.name&&(u.userData.name=r.name,u.name=o),w(u,r),r.extensions&&I(n,u,r),r.matrix!==void 0){const l=new h.Matrix4;l.fromArray(r.matrix),u.applyMatrix4(l)}else r.translation!==void 0&&u.position.fromArray(r.translation),r.rotation!==void 0&&u.quaternion.fromArray(r.rotation),r.scale!==void 0&&u.scale.fromArray(r.scale);if(!s.associations.has(u))s.associations.set(u,{});else if(r.mesh!==void 0&&s.meshCache.refs[r.mesh]>1){const l=s.associations.get(u);s.associations.set(u,{...l})}return s.associations.get(u).nodes=t,u}),this.nodeCache[t]}loadScene(t){const e=this.extensions,n=this.json.scenes[t],s=this,r=new h.Group;n.name&&(r.name=s.createUniqueName(n.name)),w(r,n),n.extensions&&I(e,r,n);const o=n.nodes||[],a=[];for(let i=0,c=o.length;i<c;i++)a.push(s.getDependency("node",o[i]));return Promise.all(a).then(function(i){for(let u=0,l=i.length;u<l;u++){const f=i[u];f.parent!==null?r.add(J(f)):r.add(f)}const c=u=>{const l=new Map;for(const[f,p]of s.associations)(f instanceof h.Material||f instanceof h.Texture)&&l.set(f,p);return u.traverse(f=>{const p=s.associations.get(f);p!=null&&l.set(f,p)}),l};return s.associations=c(r),r})}_createAnimationTracks(t,e,n,s,r){const o=[],a=t.name?t.name:t.uuid,i=[];N[r.path]===N.weights?t.traverse(function(f){f.morphTargetInfluences&&i.push(f.name?f.name:f.uuid)}):i.push(a);let c;switch(N[r.path]){case N.weights:c=h.NumberKeyframeTrack;break;case N.rotation:c=h.QuaternionKeyframeTrack;break;case N.translation:case N.scale:c=h.VectorKeyframeTrack;break;default:n.itemSize===1?c=h.NumberKeyframeTrack:c=h.VectorKeyframeTrack;break}const u=s.interpolation!==void 0?_e[s.interpolation]:h.InterpolateLinear,l=this._getArrayFromAccessor(n);for(let f=0,p=i.length;f<p;f++){const m=new c(i[f]+"."+N[r.path],e.array,l,u);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),o.push(m)}return o}_getArrayFromAccessor(t){let e=t.array;if(t.normalized){const n=U(e.constructor),s=new Float32Array(e.length);for(let r=0,o=e.length;r<o;r++)s[r]=e[r]*n;e=s}return e}_createCubicSplineTrackInterpolant(t){t.createInterpolant=function(n){const s=this instanceof h.QuaternionKeyframeTrack?Ae:Q;return new s(this.times,this.values,this.getValueSize()/3,n)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Ce(d,t,e){const n=t.attributes,s=new h.Box3;if(n.POSITION!==void 0){const a=e.json.accessors[n.POSITION],i=a.min,c=a.max;if(i!==void 0&&c!==void 0){if(s.set(new h.Vector3(i[0],i[1],i[2]),new h.Vector3(c[0],c[1],c[2])),a.normalized){const u=U(O[a.componentType]);s.min.multiplyScalar(u),s.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=t.targets;if(r!==void 0){const a=new h.Vector3,i=new h.Vector3;for(let c=0,u=r.length;c<u;c++){const l=r[c];if(l.POSITION!==void 0){const f=e.json.accessors[l.POSITION],p=f.min,m=f.max;if(p!==void 0&&m!==void 0){if(i.setX(Math.max(Math.abs(p[0]),Math.abs(m[0]))),i.setY(Math.max(Math.abs(p[1]),Math.abs(m[1]))),i.setZ(Math.max(Math.abs(p[2]),Math.abs(m[2]))),f.normalized){const M=U(O[f.componentType]);i.multiplyScalar(M)}a.max(i)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(a)}d.boundingBox=s;const o=new h.Sphere;s.getCenter(o.center),o.radius=s.min.distanceTo(s.max)/2,d.boundingSphere=o}function q(d,t,e){const n=t.attributes,s=[];function r(o,a){return e.getDependency("accessor",o).then(function(i){d.setAttribute(a,i)})}for(const o in n){const a=B[o]||o.toLowerCase();a in d.attributes||s.push(r(n[o],a))}if(t.indices!==void 0&&!d.index){const o=e.getDependency("accessor",t.indices).then(function(a){d.setIndex(a)});s.push(o)}return h.ColorManagement.workingColorSpace!==h.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${h.ColorManagement.workingColorSpace}" not supported.`),w(d,t),Ce(d,t,e),Promise.all(s).then(function(){return t.targets!==void 0?Se(d,t.targets,e):d})}exports.GLTFLoader=Z;
|
|
@@ -54,11 +54,11 @@ export declare function lidEase(progress: number): number;
|
|
|
54
54
|
*/
|
|
55
55
|
export declare function macbookMeshes(aspect: number): MacbookMesh[];
|
|
56
56
|
/**
|
|
57
|
-
* How a stream fills a display of another shape: the texture transform that keeps its shape,
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
57
|
+
* How a stream fills a display of another shape: the texture transform that keeps its shape, with
|
|
58
|
+
* black bars on the sides it does not reach. Texture coordinates outside 0 to 1 after it are the
|
|
59
|
+
* bars. The stream is centered, except on a display with a notch, the share of its height `notch`
|
|
60
|
+
* gives: there it starts at the top, so the notch covers the top of the guest's menu bar as it
|
|
61
|
+
* does on a MacBook, and any bar is at the bottom.
|
|
62
62
|
*/
|
|
63
63
|
export declare function streamFit(videoAspect: number, screenAspect: number, notch?: number): {
|
|
64
64
|
readonly repeat: readonly [number, number];
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { GLTF, GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
|
|
2
|
+
import { MeshoptDecoder } from 'three/addons/libs/meshopt_decoder.module.js';
|
|
2
3
|
import { RemoteControlModel } from './remote-control';
|
|
4
|
+
export declare const lazyMeshoptDecoder: typeof MeshoptDecoder;
|
|
3
5
|
/**
|
|
4
6
|
* Loads a 3D device's model from a URL, or from the function that resolves to one. A bundled model
|
|
5
7
|
* arrives as a data URL, which is decoded here rather than fetched, so a page whose content
|
|
6
|
-
* security policy limits connect-src still loads it.
|
|
8
|
+
* security policy limits connect-src still loads it. A meshopt-compressed model decodes too, where
|
|
9
|
+
* the page allows WebAssembly.
|
|
7
10
|
*/
|
|
8
11
|
export declare function loadModel(loader: GLTFLoader, source: RemoteControlModel): Promise<GLTF>;
|
|
@@ -255,8 +255,9 @@ export type RemoteControlPlatformAssets = {
|
|
|
255
255
|
/**
|
|
256
256
|
* Where a macOS frame image's screen opening sits, as fractions of the image's width and height
|
|
257
257
|
* from its top left. A macOS `frame` needs it; without both, the MacBook is drawn in CSS. `notch`
|
|
258
|
-
* is the share of the opening's height a notch takes at its top: the stream
|
|
259
|
-
*
|
|
258
|
+
* is the share of the opening's height a notch takes at its top: the stream then starts at the
|
|
259
|
+
* top of the opening, so the notch the image draws covers the top of its menu bar, as on a
|
|
260
|
+
* MacBook.
|
|
260
261
|
*/
|
|
261
262
|
screen?: {
|
|
262
263
|
left: number;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsxs as Rt, jsx as pt } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as ut, useState as oe, useEffect as Zt } from "react";
|
|
3
|
-
import { ah as ae, d as K, G as Pt, f as Xt, M as jt, e as Yt, D as ce, ai as le, aj as _t, ak as qt, B as Jt, j as Ft, al as Qt, i as wt, l as ue, b as bt, T as de, g as $t, am as fe, an as pe, ao as ge, ap as he, h as ne, u as me, a4 as ye, c as be, V as te, S as ve, L as ee, R as xe } from "./model-source-
|
|
4
|
-
import { a as we } from "./BufferGeometryUtils-
|
|
3
|
+
import { ah as ae, d as K, G as Pt, f as Xt, M as jt, e as Yt, D as ce, ai as le, aj as _t, ak as qt, B as Jt, j as Ft, al as Qt, i as wt, l as ue, b as bt, T as de, g as $t, am as fe, an as pe, ao as ge, ap as he, h as ne, u as me, a4 as ye, c as be, V as te, S as ve, L as ee, R as xe } from "./model-source-CN_i4mVy.mjs";
|
|
4
|
+
import { a as we } from "./BufferGeometryUtils-DEy5W2hb.mjs";
|
|
5
5
|
import { D as Me, k as Se, l as Ut, m as De, p as Be } from "./core-nbvkIrvp.mjs";
|
|
6
|
-
import { h as ke, u as Ie, D as Ae, a as Ee, f as ze } from "./duo-view-
|
|
6
|
+
import { h as ke, u as Ie, D as Ae, a as Ee, f as ze } from "./duo-view-C07GD_5E.mjs";
|
|
7
7
|
const zt = new K();
|
|
8
8
|
function et(h, b, g, i, w, n) {
|
|
9
9
|
const f = 2 * Math.PI * w / 4, k = Math.max(n - 2 * w, 0), B = Math.PI / 4;
|
|
@@ -324,7 +324,7 @@ function Le(h, b, g) {
|
|
|
324
324
|
},
|
|
325
325
|
// Imported appearances replace the rigid body while live screens and the hinge remain under our control.
|
|
326
326
|
loadAppearance: async (o) => {
|
|
327
|
-
const { GLTFLoader: s } = await import("./GLTFLoader-
|
|
327
|
+
const { GLTFLoader: s } = await import("./GLTFLoader-B3xbM8m1.mjs"), { scene: e } = await ue(new s(), o), u = /* @__PURE__ */ new Set();
|
|
328
328
|
if (e.traverse((a) => {
|
|
329
329
|
if (a instanceof bt) {
|
|
330
330
|
u.add(a.geometry);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ie=require("react/jsx-runtime"),K=require("react"),e=require("./model-source-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ie=require("react/jsx-runtime"),K=require("react"),e=require("./model-source-D3_k9qRK.js"),Ge=require("./BufferGeometryUtils-CMbyl1DL.js"),fe=require("./core-BCBQrYsk.js"),Pe=require("./duo-view-tUJbbWoS.js"),Ee=new e.Vector3;function oe(m,v,g,a,w,r){const p=2*Math.PI*w/4,I=Math.max(r-2*w,0),k=Math.PI/4;Ee.copy(v),Ee[a]=0,Ee.normalize();const i=.5*p/(p+I),L=1-Ee.angleTo(m)/k;return Math.sign(Ee[g])===1?L*i:I/(p+I)+i+i*(1-L)}class Xe extends e.BoxGeometry{constructor(v=1,g=1,a=1,w=2,r=.1){const p=w*2+1;if(r=Math.min(v/2,g/2,a/2,r),super(1,1,1,p,p,p),this.type="RoundedBoxGeometry",this.parameters={width:v,height:g,depth:a,segments:w,radius:r},p===1)return;const I=this.toNonIndexed();this.index=null,this.attributes.position=I.attributes.position,this.attributes.normal=I.attributes.normal,this.attributes.uv=I.attributes.uv;const k=new e.Vector3,i=new e.Vector3,L=new e.Vector3(v,g,a).divideScalar(2).subScalar(r),E=this.attributes.position.array,F=this.attributes.normal.array,B=this.attributes.uv.array,j=E.length/6,x=new e.Vector3,J=.5/p;for(let P=0,T=0;P<E.length;P+=3,T+=2)switch(k.fromArray(E,P),i.copy(k),i.x-=Math.sign(i.x)*J,i.y-=Math.sign(i.y)*J,i.z-=Math.sign(i.z)*J,i.normalize(),E[P+0]=L.x*Math.sign(k.x)+i.x*r,E[P+1]=L.y*Math.sign(k.y)+i.y*r,E[P+2]=L.z*Math.sign(k.z)+i.z*r,F[P+0]=i.x,F[P+1]=i.y,F[P+2]=i.z,Math.floor(P/j)){case 0:x.set(1,0,0),B[T+0]=oe(x,i,"z","y",r,a),B[T+1]=1-oe(x,i,"y","z",r,g);break;case 1:x.set(-1,0,0),B[T+0]=1-oe(x,i,"z","y",r,a),B[T+1]=1-oe(x,i,"y","z",r,g);break;case 2:x.set(0,1,0),B[T+0]=1-oe(x,i,"x","z",r,v),B[T+1]=oe(x,i,"z","x",r,a);break;case 3:x.set(0,-1,0),B[T+0]=1-oe(x,i,"x","z",r,v),B[T+1]=1-oe(x,i,"z","x",r,a);break;case 4:x.set(0,0,1),B[T+0]=1-oe(x,i,"x","y",r,v),B[T+1]=1-oe(x,i,"y","x",r,g);break;case 5:x.set(0,0,-1),B[T+0]=oe(x,i,"x","y",r,v),B[T+1]=1-oe(x,i,"y","x",r,g);break}}static fromJSON(v){return new Xe(v.width,v.height,v.depth,v.segments,v.radius)}}const{width:We,height:$,depth:z}=fe.DUO_DIMENSIONS,V=We/2,ve=(11.3-z*2)/2,xe=157.5,Re=110.8,ge=1.1,Ce=.14;function je(m,v){m.envMap=v??null,m.envMapIntensity=1,m.onBeforeCompile=g=>{g.vertexShader=`varying vec3 vDuoStudioPosition;
|
|
2
2
|
${g.vertexShader}`.replace("#include <worldpos_vertex>",`#include <worldpos_vertex>
|
|
3
3
|
vDuoStudioPosition = (modelMatrix * vec4(transformed, 1.0)).xyz;`),g.fragmentShader=`
|
|
4
4
|
varying vec3 vDuoStudioPosition;
|
|
@@ -8,4 +8,4 @@ vDuoStudioPosition = (modelMatrix * vec4(transformed, 1.0)).xyz;`),g.fragmentSha
|
|
|
8
8
|
float distance = -along + sqrt(max(0.0, along * along + radius * radius - dot(vDuoStudioPosition, vDuoStudioPosition)));
|
|
9
9
|
return normalize(vDuoStudioPosition + direction * distance);
|
|
10
10
|
}
|
|
11
|
-
${g.fragmentShader}`.replace("#include <envmap_physical_pars_fragment>",e.ShaderChunk.envmap_physical_pars_fragment.replace("envMapRotation * reflectVec","envMapRotation * duoStudioReflection(reflectVec)"))},m.customProgramCacheKey=()=>"duo-polished-silver-v1"}function Ve(m,v,g,a){const w=new e.Shape,r=-m/2,p=-v/2;return w.moveTo(r+g,p),w.lineTo(r+m-a,p),a&&w.absarc(r+m-a,p+a,a,-Math.PI/2,0,!1),w.lineTo(r+m,p+v-a),a&&w.absarc(r+m-a,p+v-a,a,0,Math.PI/2,!1),w.lineTo(r+g,p+v),g&&w.absarc(r+g,p+v-g,g,Math.PI/2,Math.PI,!1),w.lineTo(r,p+g),g&&w.absarc(r+g,p+g,g,Math.PI,Math.PI*1.5,!1),w}function _e(m,v,g){const a=new e.Group,w=new e.Group,r=new e.Group;a.add(w,r);const p=[],I=new Map,k=new Map,i=new Map;let L,E=!1,F=!1;const B=[],j=[],x=new e.MeshPhysicalMaterial({color:15264750,metalness:1,roughness:.055,clearcoat:1,clearcoatRoughness:.055,envMapIntensity:1.15}),J=new e.MeshPhysicalMaterial({color:15987179,metalness:.04,roughness:.2,clearcoat:1,clearcoatRoughness:.08}),P=x.clone();P.roughness=.085,je(x,g),je(P,g);const T=new e.MeshBasicMaterial({color:526860}),ae=new e.MeshStandardMaterial({color:10790304,roughness:.55}),me=new e.MeshPhysicalMaterial({color:198157,envMap:g??null,envMapIntensity:.05,metalness:1,roughness:.22}),Me=new e.MeshPhysicalMaterial({color:1057079,envMap:g??null,envMapIntensity:.04,metalness:1,roughness:.3}),pe=new e.MeshStandardMaterial({color:15723220,roughness:.35}),l=new e.MeshStandardMaterial({color:12632252,metalness:.6,roughness:.25,side:e.DoubleSide}),_=new e.MeshBasicMaterial({map:m,toneMapped:!1}),he=new e.MeshBasicMaterial({map:v,toneMapped:!1});j.push(x,J,P,T,ae,me,Me,pe,l,_,he);const O=(n,s)=>{j.push(n);const o=new e.Mesh(n,s);return p.push(o),o},ce=(n,s,o,d,b,h,D=.12)=>O(Ge.toCreasedNormals(new e.ExtrudeGeometry(Ve(n,s,d,b),{depth:o,bevelEnabled:D>0,bevelSize:D,bevelThickness:D,bevelSegments:3,steps:1,curveSegments:20}),Math.PI/3),h),ne=(n,s,o,d,b)=>O(new Xe(n,s,o,3,d),b);for(const[n,s]of[[w,-1],[r,1]]){const o=s===-1?8.6:.55,d=s===1?8.6:.55,b=ce(V-.3,$-.3,z-.8,o,d,x,.35);b.position.set(s*V/2,0,-z+.4),n.add(b);const h=ce(V-1.25,$-1.25,.2,o-.3,d-.3,J);h.position.set(s*V/2,0,-z-.02),n.add(h);const D=ce(V-.8,$-.8,.1,o-.2,d-.2,T,.05);D.position.set(s*V/2,0,-.06),n.add(D);for(const S of[-$/2+13,$/2-13]){const c=ne(.22,.65,z-.8,.08,ae);c.position.set(s*(V+.04),S,-z/2),n.add(c)}}const de=(n,s,o,d,b,h=0)=>{const D=b==="outer"?Ve(o,d,.8,6.6):Ve(o,d,h===0?5.3:0,h===1?5.3:0),S=new e.ShapeGeometry(D,24),c=S.getAttribute("position"),y=S.getAttribute("uv");for(let M=0;M<c.count;M++){const X=(c.getX(M)+o/2)/o,C=(c.getY(M)+d/2)/d;if(b==="inner"){const G=c.getX(M)+s;y.setXY(M,1-C,(G+xe/2)/xe)}else y.setXY(M,X,C)}const u=O(S,b==="inner"?he:_);u.name=b==="outer"?"cover-display":`inner-display-${h}`,u.position.set(s,0,b==="inner"?Ce:-z-.25),b==="outer"&&(u.rotation.y=Math.PI),u.userData.display=b,n.add(u)},we=xe/2-ge;de(w,-79.85/2,we,Re,"inner",0),de(r,(xe/2+ge)/2,we,Re,"inner",1);const Q=ce(V-.85,$-.9,.08,8.1,.3,T,.04);Q.position.set(-V/2,0,-z-.15),w.add(Q),de(w,-V/2,77.1,112.2,"outer");const N=$/2-15,ye=ce(57,20,1.6,10,10,J,.28);ye.position.set(V/2+2,N,-z-1.8),r.add(ye);const ee=(n,s,o,d,b)=>{const h=O(new e.CircleGeometry(n,48),s);return h.rotation.y=Math.PI,h.position.set(o,d,b),r.add(h),h};for(const n of[V/2+19,V/2-1]){const s=O(new e.CylinderGeometry(8.05,8.05,1.7,64),x);s.rotation.x=Math.PI/2,s.position.set(n,N,-z-2.55),r.add(s),ee(7.35,T,n,N,-z-3.43),ee(6.65,me,n,N,-z-3.46),ee(2.5,Me,n,N,-z-3.48),ee(1.9,me,n,N,-z-3.5);const o=ee(.7,Me,n-1.1,N+1.15,-z-3.52);o.scale.y=.55}ee(2.2,x,V/2-18,N-3,-z-2.11),ee(1.8,pe,V/2-18,N-3,-z-2.15),ee(.65,T,V/2-18,N+3.2,-z-2.15);const q=new e.Shape;q.moveTo(0,3.2),q.bezierCurveTo(-1.5,4.2,-3.5,4.3,-4.8,2.6),q.bezierCurveTo(-6.4,.3,-4.4,-4.6,-2.5,-5.4),q.bezierCurveTo(-1.4,-5.9,-.8,-5,0,-5),q.bezierCurveTo(1,-5,1.7,-5.9,2.8,-5.3),q.bezierCurveTo(3.8,-4.5,4.6,-3.1,4.9,-2.1),q.bezierCurveTo(2.3,-1.2,2.1,1.5,4.1,2.8),q.bezierCurveTo(3,4.3,1.5,4,0,3.2);const R=new e.Shape;R.moveTo(-.2,4),R.bezierCurveTo(-.3,5.7,1,6.9,2.5,7.1),R.bezierCurveTo(2.6,5.6,1.2,4,-.2,4);const be=O(new e.ShapeGeometry([q,R],20),l);be.rotation.y=Math.PI,be.position.set(V/2,-3,-z-.16),r.add(be);const re=(n,s,o,d,b)=>{const h=x.clone();j.push(h);const D=ne(s,o,2.5,.27,h);D.name=`button-${n}`,D.userData.button=n,D.position.set(d,b,-z/2),r.add(D),I.set(n,D),k.set(n,D.position.clone());const S=ne(s<o?4.5:s,s<o?o:4.5,z,.1,h);p.splice(p.indexOf(S),1),S.position.set(d+(s<o?2:0),b+(s<o?0:2),-z/2),S.userData.button=n,S.visible=!1,S.updateMatrix(),B.push(S)};re("side",.7,13,V+.15,21),re("volumeUp",9.5,.65,V-25,$/2+.12),re("volumeDown",9.5,.65,V-37,$/2+.12);const Se=ne(.35,12,2.5,.15,ae);Se.position.set(V-.08,-12,-z/2),r.add(Se);const te=32,U=(n,s=!1)=>{const o=new e.BufferGeometry,d=new Float32Array((te+1)*2*3),b=new Float32Array((te+1)*2*2),h=[];for(let S=0;S<=te;S++){const c=(xe/2-ge+2*ge*S/te)/xe;if(b.set([1,c,0,c],S*4),S<te){const y=S*2;h.push(y,y+2,y+1,y+2,y+3,y+1)}}o.setAttribute("position",new e.BufferAttribute(d,3).setUsage(e.DynamicDrawUsage)),o.setAttribute("uv",new e.BufferAttribute(b,2)),o.setIndex(h);const D=O(o,n);return s&&(D.userData.display="inner"),a.add(D),o},H=U(T),Be=U(he,!0),ue=U(P),De=[-1,1].map(n=>{const s=new e.BufferGeometry;s.setAttribute("position",new e.BufferAttribute(new Float32Array((te+1)*2*3),3).setUsage(e.DynamicDrawUsage));const o=[];for(let b=0;b<te;b++){const h=b*2;o.push(...n===1?[h,h+1,h+2,h+1,h+3,h+2]:[h,h+2,h+1,h+1,h+2,h+3])}s.setIndex(o);const d=O(s,P);return d.name=`hinge-cap-${n}`,a.add(d),{geometry:s,edge:n}});ue.setIndex(Array.from(ue.getIndex().array).reverse());let ke;const le=n=>{if(ke===n)return;ke=n;const s=e.MathUtils.degToRad((180-n)/2),o=Math.sin(s),d=Math.cos(s);for(const[u,M]of[[w,1],[r,-1]])u.rotation.y=M*s,u.position.set(-M*ve*o,0,ve*(1-d));const b=ge*d+(ve-Ce)*o,h=ge*o+Ce*d+ve*(1-d),D=2*ge/3,S=.45*d+(z+ve)*o,c=.45*o-z*d+ve*(1-d),y=-z*(1-o)-.8*o;for(let u=0;u<=te;u++){const M=u/te,X=1-M,C=X*X*X*-b+3*X*X*M*(-b+d*D)+3*X*M*M*(b-d*D)+M*M*M*b,G=h-3*X*M*o*D,se=Math.PI*M;for(let W=0;W<2;W++)Be.getAttribute("position").setXYZ(u*2+W,C,(W-.5)*Re,G),H.getAttribute("position").setXYZ(u*2+W,C,(W-.5)*($-.9),G-.07),ue.getAttribute("position").setXYZ(u*2+W,-S*Math.cos(se),(W-.5)*($-.9),c+(y-c)*Math.sin(se));for(const{geometry:W,edge:Te}of De){const t=W.getAttribute("position");t.setXYZ(u*2,C,Te*($/2-.45),G-.07),t.setXYZ(u*2+1,-S*Math.cos(se),Te*($/2-.45),c+(y-c)*Math.sin(se))}}for(const u of[H,Be,ue,...De.map(M=>M.geometry)])u.getAttribute("position").needsUpdate=!0,u.computeVertexNormals(),u.computeBoundingSphere(),u.computeBoundingBox();a.updateMatrixWorld(!0)};return le(180),{device:a,hitObjects:p,setAngle:le,buttonAnchors:()=>[...k].map(([n,s])=>({button:n,point:s.clone().applyMatrix4(r.matrixWorld),outward:s.clone().add(n==="side"?new e.Vector3(10,0,0):new e.Vector3(0,10,0)).applyMatrix4(r.matrixWorld)})),getBounds:n=>{n.makeEmpty();const s=new e.Box3;for(const o of p)!(o instanceof e.Mesh)||o.userData.button||(o.geometry.boundingBox||o.geometry.computeBoundingBox(),s.copy(o.geometry.boundingBox).applyMatrix4(o.matrixWorld),n.union(s));return n},pick:n=>{const s=n.intersectObjects(p,!1)[0];if(s?.object.userData.display||s?.object.userData.button)return s;for(const d of B)d.matrixWorld.multiplyMatrices(r.matrixWorld,d.matrix);const o=n.intersectObjects(B,!1)[0];return o&&(!s||o.distance<=s.distance)?o:s},loadAppearance:async n=>{const{GLTFLoader:s}=await Promise.resolve().then(()=>require("./GLTFLoader-CsxjkQ8a.js")),{scene:o}=await e.loadModel(new s,n),d=new Set;if(o.traverse(c=>{if(c instanceof e.Mesh){d.add(c.geometry);for(const y of Array.isArray(c.material)?c.material:[c.material]){d.add(y),y instanceof e.MeshStandardMaterial&&y.userData.finish==="polished-silver"&&je(y,g);for(const u of Object.values(y))u instanceof e.Texture&&u!==g&&d.add(u)}}}),F){d.forEach(c=>c.dispose());return}const b=o.getObjectByName("folding-half"),h=o.getObjectByName("stationary-half"),D=new Set;if(h?.traverse(c=>{c instanceof e.Mesh&&c.userData.button&&D.add(c.userData.button)}),!b||!h||!["side","volumeUp","volumeDown"].every(c=>D.has(c)))throw d.forEach(c=>c.dispose()),new Error("Duo appearance requires both body halves and side, volumeUp, and volumeDown button meshes.");j.push(...d);const S=b.children.find(c=>c instanceof e.Mesh&&(c.userData.sourceDisplay==="outer"||c.material.name==="cover-screen"));if(S){const c=a.getObjectByName("cover-display"),y=S.geometry.clone().scale(10,10,10);y.computeBoundingBox();const u=y.boundingBox,M=y.getAttribute("position"),X=new e.BufferAttribute(new Float32Array(M.count*2),2);for(let C=0;C<M.count;C++)X.setXY(C,(u.max.x-M.getX(C))/(u.max.x-u.min.x),(M.getY(C)-u.min.y)/(u.max.y-u.min.y));y.setAttribute("uv",X),c.geometry=y,c.position.copy(S.position).multiplyScalar(10),c.rotation.copy(S.rotation),c.scale.copy(S.scale),j.push(y)}for(const c of[w,r])for(const y of[...c.children]){if(y.userData.display)continue;c.remove(y);const u=p.indexOf(y);u!==-1&&p.splice(u,1)}I.clear(),B.length=0,k.clear(),i.clear();for(const c of["side","volumeUp","volumeDown"]){const y=new e.Group;y.name=`button-${c}`,I.set(c,y),r.add(y)}for(const[c,y]of[[b,w],[h,r]])for(const u of[...c.children]){if(!(u instanceof e.Mesh)||u.userData.sourceDisplay||["inner-screen","cover-screen"].includes(u.material.name))continue;u.geometry.scale(10,10,10),u.position.multiplyScalar(10),u.geometry.computeBoundingBox();const M=u.userData.button;M&&I.has(M)?I.get(M).add(u):y.add(u),p.push(u)}for(const[c,y]of I){const u=new e.Box3;for(const G of y.children){const se=G;se.updateMatrix(),u.union(se.geometry.boundingBox.clone().applyMatrix4(se.matrix))}const M=u.getCenter(new e.Vector3);for(const G of y.children)G.position.sub(M);y.position.copy(M),k.set(c,M);const X=u.getSize(new e.Vector3),C=ne(c==="side"?5:X.x,c==="side"?X.y:5,z,.1,x);p.splice(p.indexOf(C),1),C.position.copy(M).add(new e.Vector3(c==="side"?2:0,c==="side"?0:2,0)),C.userData.button=c,C.visible=!1,C.updateMatrix(),B.push(C)}a.updateMatrixWorld(!0)},highlightButton:(n,s=!1)=>{L=n,E=s},animateButtons:n=>{let s=!1;for(const[o,d]of I){const b=k.get(o),h=o===L?E?0:.5:.16;let D=e.MathUtils.damp(i.get(o)??.16,h,22,n);Math.abs(D-h)<.001?D=h:s=!0,i.set(o,D),d.position.copy(b),d.position[o==="side"?"x":"y"]+=D}return s},dispose:()=>{F=!0,j.forEach(n=>n.dispose())}}}function Ue(m,v,g){const a=Math.min(2.5,Math.max(0,g)),w=a<=.625?a*.8:a<=1.875?.5+(a-.625)*.2:.75+(a-1.875)*.4;return m+(v-m)*w}function qe(m,v,g,a,w){const r=i=>{const L=i.clone().project(g);return new e.Vector2((L.x+1)*a/2,(1-L.y)*w/2)},p=new e.Box2;for(const i of[v.min.x,v.max.x])for(const L of[v.min.y,v.max.y])for(const E of[v.min.z,v.max.z])p.expandByPoint(r(new e.Vector3(i,L,E)));const I=m.map(({button:i,point:L,outward:E})=>{const F=r(L),B=r(E).sub(F),j=Math.abs(B.y)>=Math.abs(B.x),x=j?B.y<0?"top":"bottom":B.x<0?"left":"right";return{button:i,edge:x,x:j?F.x:x==="left"?p.min.x-28:p.max.x+28,y:j?x==="top"?p.min.y-28:p.max.y+28:F.y}}),k=I.filter(i=>i.button!=="side");if(k.length===2&&k[0].edge===k[1].edge){const i=k[0].edge==="top"||k[0].edge==="bottom"?"x":"y";if(k.sort((L,E)=>L[i]-E[i]),k[1][i]-k[0][i]<48){const L=(k[0][i]+k[1][i])/2;k[0][i]=L-24,k[1][i]=L+24}}return{guides:I,rect:p,iconSize:Pe.hardwareIconSize(p)}}function He(m,v,g){const a=K.useRef(void 0),w=K.useRef(0),[r,p]=K.useState(),I=Pe.useDuoHinge(m,v,E=>{E!==void 0&&i(),g(E)}),k=K.useRef(I);k.current=I;const i=()=>{a.current&&(cancelAnimationFrame(w.current),a.current=void 0,I.interacting.current=!1,p(void 0))},L=()=>{const E=performance.now(),F=a.current,B=F?Ue(F.from,F.target,(E-F.startedAt)/1e3):I.angle,j=(F?.target??I.angle)<90?180:0;i();const x={from:B,target:j,startedAt:E};a.current=x,I.interacting.current=!0,p(j);let J=-1/0;const P=T=>{if(a.current!==x)return;const ae=Ue(B,j,(T-E)/1e3);(T-J>=1e3/30||ae===j)&&(J=T,k.current.changeAngle(ae)),ae===j?i():w.current=requestAnimationFrame(P)};w.current=requestAnimationFrame(P)};return K.useEffect(()=>()=>{cancelAnimationFrame(w.current),a.current=void 0,k.current.interacting.current=!1},[]),{...I,motion:a,target:r,fold:L,cancelFold:i,changeAngle:E=>{i(),I.changeAngle(E)}}}const Ze={environment:.4,hemisphere:1.1,key:{intensity:2.4,position:[-100,180,260]},rim:{intensity:.8,position:[200,-40,-200]}};function $e(m){const v=K.useRef(null),g=K.useRef(new Map),a=K.useRef(m);a.current=m;const[w,r]=K.useState(),{angle:p,changeAngle:I,interacting:k,motion:i,target:L,fold:E,cancelFold:F}=He(m.state.angleDegrees,m.setAngle,r),B=K.useRef(p);B.current=p;const{view:j,viewRef:x,chooseView:J,locked:P,lockedRef:T,setLocked:ae,orbit:me,drag:Me}=e.useStageView("front"),pe=K.useRef(()=>{});return K.useEffect(()=>{pe.current()},[p,L,j,P,m.state.orientation]),K.useEffect(()=>{const l=v.current,_=m.outer,he=m.inner;if(!l||!_||!he)return;const O=new e.OrthographicCamera(-150,150,150,-150,1,2e3);let ce=1;O.position.set(0,0,340);const ne=e.createDeviceStage({container:l,videos:[_,he],maxPixelRatio:1.5,lighting:Ze,resize:(t,f)=>{ce=t/f,O.updateProjectionMatrix()},frame:(t,f)=>Te(t,f)});if(!ne){r("3D rendering is unavailable in this browser. Enable WebGL to use the folding frame."),a.current.onReady?.();return}const{renderer:de,scene:we,invalidate:Q}=ne,N=new e.Group,ye=new e.VideoTexture(_),ee=new e.VideoTexture(he);for(const t of[ye,ee])t.colorSpace=e.SRGBColorSpace,t.minFilter=e.LinearFilter,t.magFilter=e.LinearFilter;let q=!1;const R=_e(ye,ee,ne.environment),{device:be}=R;m.model?R.loadAppearance(m.model).then(()=>Q()).catch(t=>{q||r(String(t))}).finally(()=>{q||a.current.onReady?.()}):a.current.onReady?.();const re=new fe.DuoButtonSender((t,f)=>a.current.button(t,f),t=>r(String(t)));N.add(be),we.add(N);const Se=new e.Raycaster,te=new e.Vector2;let U,H=B.current,Be=H,ue=H,De=0,ke=!1,le=0;pe.current=Q;let n,s;const o=t=>t instanceof Element?t.closest("[data-duo-button]"):null,d=t=>{s=t;for(const f of n?.guides??[]){const A=g.current.get(f.button);A&&(A.dataset.visible=String(f.edge===t))}},b=t=>{if(a.current.watchOnly)return;const f=o(t.target);if(f)return{button:f.dataset.duoButton};const A=de.domElement.getBoundingClientRect();te.set((t.clientX-A.left)/A.width*2-1,1-(t.clientY-A.top)/A.height*2),Se.setFromCamera(te,O);const Z=R.pick(Se),Y=Z?.object.userData.button;if(Y)return{button:Y};if(!Z?.object.userData.display||!Z.uv)return;const Ie=a.current.state.displays.find(ze=>ze.id===Z.object.userData.display);if(Ie)return{screenId:Ie.screenId,...fe.panelTouch(Z.uv.x,Z.uv.y)}},h=t=>{if(Q(),U||t.button!==0)return;o(t.target)||l.focus({preventScroll:!0});const f=b(t),A=f&&"button"in f?f.button:void 0,Z=fe.duoPointerMode(T.current,!!f&&!A,t.altKey);if(Z==="ignore"&&!A)return;const Y=Z==="touch"&&f&&"screenId"in f?f:void 0;U={pointer:t.pointerId,button:A,...Y,x:Y?.x??0,y:Y?.y??0,clientX:t.clientX,clientY:t.clientY},l.setPointerCapture(t.pointerId),A?(r(void 0),re.press(A),R.highlightButton(A,!0)):Y&&a.current.touch(0,Y.screenId,Y.x,Y.y)},D=t=>{if(Q(),!U){const f=b(t),A=f&&"button"in f?f.button:void 0,Z=l.getBoundingClientRect();d(A?n?.guides.find(Y=>Y.button===A)?.edge:n&&Pe.flatHoverEdge(t.clientX-Z.left,t.clientY-Z.top,n.rect)),de.domElement.style.cursor=A?"pointer":"",de.domElement.title=A?fe.DUO_BUTTONS[A]:"",R.highlightButton(A);return}if(!(U.pointer!==t.pointerId||U.button)){if(U.screenId){const f=b(t);f&&"screenId"in f&&f.screenId===U.screenId&&(U.x=f.x,U.y=f.y,a.current.touch(2,f.screenId,f.x,f.y))}else T.current||Me(t.clientX-U.clientX,t.clientY-U.clientY,1.4);U.clientX=t.clientX,U.clientY=t.clientY}},S=t=>{Q(),!(!U||t&&U.pointer!==t.pointerId)&&(U.button?(re.release(),R.highlightButton()):U.screenId&&a.current.touch(1,U.screenId,U.x,U.y),U=void 0,t&&D(t))},c=()=>{Q(),U||(R.highlightButton(),d(void 0))},y=t=>{Q();const f=o(t.target);if(!f||a.current.watchOnly||(t.stopPropagation(),t.code!=="Space"&&t.code!=="Enter")||(t.preventDefault(),t.repeat))return;const A=f.dataset.duoButton;re.press(A),R.highlightButton(A,!0),f.dataset.pressed="true"},u=t=>{Q();const f=o(t.target);!f||a.current.watchOnly||(t.stopPropagation(),!(t.code!=="Space"&&t.code!=="Enter")&&(t.preventDefault(),re.release(),R.highlightButton(f.dataset.duoButton),f.dataset.pressed="false"))},M=t=>{const f=o(t.target);f&&d(n?.guides.find(A=>A.button===f.dataset.duoButton)?.edge)},X=()=>{Q(),S(),re.release(),R.highlightButton(),d(void 0),g.current.forEach(t=>{t.dataset.pressed="false"})},C=t=>{l.contains(t.relatedTarget)?o(t.target)&&(re.release(),R.highlightButton()):X()};l.addEventListener("pointerleave",c),l.addEventListener("pointerdown",h),l.addEventListener("pointermove",D),l.addEventListener("pointerup",S),l.addEventListener("pointercancel",S),l.addEventListener("lostpointercapture",S),l.addEventListener("keydown",y),l.addEventListener("keyup",u),l.addEventListener("focusin",M),l.addEventListener("focusout",C),window.addEventListener("blur",X);const G=new e.Box3,se=new e.Vector3,W=new e.Vector3,Te=(t,f)=>{ue!==B.current&&(Be=H,ue=B.current,De=t,ke=k.current);const A=i.current;H=A?Ue(A.from,A.target,(t-A.startedAt)/1e3):ke?e.MathUtils.damp(H,ue,18,f):Ue(Be,ue,(t-De)/1e3),Math.abs(H-B.current)<.001&&(H=B.current),R.setAngle(H);const Y=(1-e.MathUtils.smoothstep(H,15,110))*Math.PI/2+(x.current==="back"?Math.PI:0);le=e.MathUtils.damp(le,Y,12,f),Math.abs(le-Y)<.001&&(le=Y),N.rotation.set(me.pitch+(x.current==="table"?-.35:x.current==="book"?.2:0),me.yaw+(x.current==="book"?-.2:0),0),be.rotation.set(0,le,{portrait:0,pud:Math.PI,"landscape-left":Math.PI/2,"landscape-right":-Math.PI/2}[a.current.state.orientation]??0,"ZYX"),N.position.set(0,0,0),N.updateMatrixWorld(!0),R.getBounds(G).getCenter(se),G.getSize(W),N.position.copy(se).negate();const Ie=l.clientWidth,ze=l.clientHeight,Fe=Math.max(.4,1-108/Ie),Ne=Math.min(.8,Math.max(.35,1-108/ze)),Le=Math.max(W.y/(2*Ne),W.x/(2*ce*Fe));O.top=e.MathUtils.damp(O.top,Le,14,f),Math.abs(O.top-Le)<.001&&(O.top=Le),O.bottom=-O.top,O.left=-O.top*ce,O.right=O.top*ce,O.updateProjectionMatrix();const Ye=R.animateButtons(f);de.render(we,O),R.getBounds(G),n=qe(R.buttonAnchors(),G,O,Ie,ze);for(const Oe of n.guides){const Ae=g.current.get(Oe.button);Ae&&(Ae.style.left=`${Oe.x}px`,Ae.style.top=`${Oe.y}px`,Ae.style.setProperty("--duo-hardware-icon-size",`${n.iconSize}px`),Ae.dataset.visible=String(Oe.edge===s))}return!!i.current||H!==B.current||le!==Y||O.top!==Le||Ye};return ne.start(),()=>{q=!0,pe.current=()=>{},S(),re.release(),window.removeEventListener("blur",X),l.removeEventListener("pointerleave",c),l.removeEventListener("pointerdown",h),l.removeEventListener("pointermove",D),l.removeEventListener("pointerup",S),l.removeEventListener("pointercancel",S),l.removeEventListener("lostpointercapture",S),l.removeEventListener("keydown",y),l.removeEventListener("keyup",u),l.removeEventListener("focusin",M),l.removeEventListener("focusout",C),R.dispose(),ye.dispose(),ee.dispose(),ne.dispose()}},[m.outer,m.inner,m.model]),ie.jsxs("div",{className:"rc-duo",children:[ie.jsx("div",{ref:v,className:"rc-duo-stage","data-position-locked":P,tabIndex:0,role:"application","aria-label":"iPhone Duo simulator. Touch the screen to control iOS. Drag the frame or background to rotate when position is unlocked.",onKeyDown:m.onKeyDown,onKeyUp:m.onKeyUp,children:Object.keys(fe.DUO_BUTTONS).map(l=>ie.jsx("button",{disabled:m.watchOnly,ref:_=>{_?g.current.set(l,_):g.current.delete(l)},type:"button",className:"rc-duo-hardware","data-duo-button":l,"data-visible":"false","aria-label":fe.DUO_BUTTONS[l],title:fe.DUO_BUTTONS[l],children:ie.jsx(Pe.DuoHardwareIcon,{button:l})},l))}),ie.jsxs(Pe.DuoControls,{watchOnly:m.watchOnly,angle:p,onFold:E,foldTarget:L,onHingeDrag:F,changeAngle:I,interacting:k,rotate:()=>{m.setOrientation(m.state.orientation==="portrait"?"landscape-left":"portrait").catch(l=>r(String(l)))},children:[["front","book","table","back"].map(l=>ie.jsx("button",{disabled:m.watchOnly&&(l==="book"||l==="table"),"aria-pressed":j===l,onClick:()=>{J(l),pe.current(),l==="book"&&m.setOrientation("portrait").then(()=>I(110)).catch(_=>r(String(_))),l==="table"&&m.setOrientation("landscape-left").then(()=>I(110)).catch(_=>r(String(_)))},children:l==="table"?"Laptop view":l[0].toUpperCase()+l.slice(1)},l)),ie.jsxs("button",{className:"rc-duo-lock","aria-label":"Lock position","aria-pressed":P,title:P?"Position is locked. Screen touches still control iOS.":"Drag the frame or background to rotate. Alt-drag rotates from the screen.",onClick:()=>ae(!P),children:[ie.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[ie.jsx("rect",{x:"4",y:"9",width:"12",height:"9",rx:"2",stroke:"currentColor",strokeWidth:"1.6"}),ie.jsx("path",{d:P?"M6 9V6a4 4 0 0 1 8 0v3":"M6 9V6a4 4 0 0 1 8 0",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]}),P?"Position locked":"Lock position"]})]}),w&&ie.jsx("div",{role:"alert",className:"rc-duo-error",children:w})]})}exports.default=$e;
|
|
11
|
+
${g.fragmentShader}`.replace("#include <envmap_physical_pars_fragment>",e.ShaderChunk.envmap_physical_pars_fragment.replace("envMapRotation * reflectVec","envMapRotation * duoStudioReflection(reflectVec)"))},m.customProgramCacheKey=()=>"duo-polished-silver-v1"}function Ve(m,v,g,a){const w=new e.Shape,r=-m/2,p=-v/2;return w.moveTo(r+g,p),w.lineTo(r+m-a,p),a&&w.absarc(r+m-a,p+a,a,-Math.PI/2,0,!1),w.lineTo(r+m,p+v-a),a&&w.absarc(r+m-a,p+v-a,a,0,Math.PI/2,!1),w.lineTo(r+g,p+v),g&&w.absarc(r+g,p+v-g,g,Math.PI/2,Math.PI,!1),w.lineTo(r,p+g),g&&w.absarc(r+g,p+g,g,Math.PI,Math.PI*1.5,!1),w}function _e(m,v,g){const a=new e.Group,w=new e.Group,r=new e.Group;a.add(w,r);const p=[],I=new Map,k=new Map,i=new Map;let L,E=!1,F=!1;const B=[],j=[],x=new e.MeshPhysicalMaterial({color:15264750,metalness:1,roughness:.055,clearcoat:1,clearcoatRoughness:.055,envMapIntensity:1.15}),J=new e.MeshPhysicalMaterial({color:15987179,metalness:.04,roughness:.2,clearcoat:1,clearcoatRoughness:.08}),P=x.clone();P.roughness=.085,je(x,g),je(P,g);const T=new e.MeshBasicMaterial({color:526860}),ae=new e.MeshStandardMaterial({color:10790304,roughness:.55}),me=new e.MeshPhysicalMaterial({color:198157,envMap:g??null,envMapIntensity:.05,metalness:1,roughness:.22}),Me=new e.MeshPhysicalMaterial({color:1057079,envMap:g??null,envMapIntensity:.04,metalness:1,roughness:.3}),pe=new e.MeshStandardMaterial({color:15723220,roughness:.35}),l=new e.MeshStandardMaterial({color:12632252,metalness:.6,roughness:.25,side:e.DoubleSide}),_=new e.MeshBasicMaterial({map:m,toneMapped:!1}),he=new e.MeshBasicMaterial({map:v,toneMapped:!1});j.push(x,J,P,T,ae,me,Me,pe,l,_,he);const O=(n,s)=>{j.push(n);const o=new e.Mesh(n,s);return p.push(o),o},ce=(n,s,o,d,b,h,D=.12)=>O(Ge.toCreasedNormals(new e.ExtrudeGeometry(Ve(n,s,d,b),{depth:o,bevelEnabled:D>0,bevelSize:D,bevelThickness:D,bevelSegments:3,steps:1,curveSegments:20}),Math.PI/3),h),ne=(n,s,o,d,b)=>O(new Xe(n,s,o,3,d),b);for(const[n,s]of[[w,-1],[r,1]]){const o=s===-1?8.6:.55,d=s===1?8.6:.55,b=ce(V-.3,$-.3,z-.8,o,d,x,.35);b.position.set(s*V/2,0,-z+.4),n.add(b);const h=ce(V-1.25,$-1.25,.2,o-.3,d-.3,J);h.position.set(s*V/2,0,-z-.02),n.add(h);const D=ce(V-.8,$-.8,.1,o-.2,d-.2,T,.05);D.position.set(s*V/2,0,-.06),n.add(D);for(const S of[-$/2+13,$/2-13]){const c=ne(.22,.65,z-.8,.08,ae);c.position.set(s*(V+.04),S,-z/2),n.add(c)}}const de=(n,s,o,d,b,h=0)=>{const D=b==="outer"?Ve(o,d,.8,6.6):Ve(o,d,h===0?5.3:0,h===1?5.3:0),S=new e.ShapeGeometry(D,24),c=S.getAttribute("position"),y=S.getAttribute("uv");for(let M=0;M<c.count;M++){const X=(c.getX(M)+o/2)/o,C=(c.getY(M)+d/2)/d;if(b==="inner"){const G=c.getX(M)+s;y.setXY(M,1-C,(G+xe/2)/xe)}else y.setXY(M,X,C)}const u=O(S,b==="inner"?he:_);u.name=b==="outer"?"cover-display":`inner-display-${h}`,u.position.set(s,0,b==="inner"?Ce:-z-.25),b==="outer"&&(u.rotation.y=Math.PI),u.userData.display=b,n.add(u)},we=xe/2-ge;de(w,-79.85/2,we,Re,"inner",0),de(r,(xe/2+ge)/2,we,Re,"inner",1);const Q=ce(V-.85,$-.9,.08,8.1,.3,T,.04);Q.position.set(-V/2,0,-z-.15),w.add(Q),de(w,-V/2,77.1,112.2,"outer");const N=$/2-15,ye=ce(57,20,1.6,10,10,J,.28);ye.position.set(V/2+2,N,-z-1.8),r.add(ye);const ee=(n,s,o,d,b)=>{const h=O(new e.CircleGeometry(n,48),s);return h.rotation.y=Math.PI,h.position.set(o,d,b),r.add(h),h};for(const n of[V/2+19,V/2-1]){const s=O(new e.CylinderGeometry(8.05,8.05,1.7,64),x);s.rotation.x=Math.PI/2,s.position.set(n,N,-z-2.55),r.add(s),ee(7.35,T,n,N,-z-3.43),ee(6.65,me,n,N,-z-3.46),ee(2.5,Me,n,N,-z-3.48),ee(1.9,me,n,N,-z-3.5);const o=ee(.7,Me,n-1.1,N+1.15,-z-3.52);o.scale.y=.55}ee(2.2,x,V/2-18,N-3,-z-2.11),ee(1.8,pe,V/2-18,N-3,-z-2.15),ee(.65,T,V/2-18,N+3.2,-z-2.15);const q=new e.Shape;q.moveTo(0,3.2),q.bezierCurveTo(-1.5,4.2,-3.5,4.3,-4.8,2.6),q.bezierCurveTo(-6.4,.3,-4.4,-4.6,-2.5,-5.4),q.bezierCurveTo(-1.4,-5.9,-.8,-5,0,-5),q.bezierCurveTo(1,-5,1.7,-5.9,2.8,-5.3),q.bezierCurveTo(3.8,-4.5,4.6,-3.1,4.9,-2.1),q.bezierCurveTo(2.3,-1.2,2.1,1.5,4.1,2.8),q.bezierCurveTo(3,4.3,1.5,4,0,3.2);const R=new e.Shape;R.moveTo(-.2,4),R.bezierCurveTo(-.3,5.7,1,6.9,2.5,7.1),R.bezierCurveTo(2.6,5.6,1.2,4,-.2,4);const be=O(new e.ShapeGeometry([q,R],20),l);be.rotation.y=Math.PI,be.position.set(V/2,-3,-z-.16),r.add(be);const re=(n,s,o,d,b)=>{const h=x.clone();j.push(h);const D=ne(s,o,2.5,.27,h);D.name=`button-${n}`,D.userData.button=n,D.position.set(d,b,-z/2),r.add(D),I.set(n,D),k.set(n,D.position.clone());const S=ne(s<o?4.5:s,s<o?o:4.5,z,.1,h);p.splice(p.indexOf(S),1),S.position.set(d+(s<o?2:0),b+(s<o?0:2),-z/2),S.userData.button=n,S.visible=!1,S.updateMatrix(),B.push(S)};re("side",.7,13,V+.15,21),re("volumeUp",9.5,.65,V-25,$/2+.12),re("volumeDown",9.5,.65,V-37,$/2+.12);const Se=ne(.35,12,2.5,.15,ae);Se.position.set(V-.08,-12,-z/2),r.add(Se);const te=32,U=(n,s=!1)=>{const o=new e.BufferGeometry,d=new Float32Array((te+1)*2*3),b=new Float32Array((te+1)*2*2),h=[];for(let S=0;S<=te;S++){const c=(xe/2-ge+2*ge*S/te)/xe;if(b.set([1,c,0,c],S*4),S<te){const y=S*2;h.push(y,y+2,y+1,y+2,y+3,y+1)}}o.setAttribute("position",new e.BufferAttribute(d,3).setUsage(e.DynamicDrawUsage)),o.setAttribute("uv",new e.BufferAttribute(b,2)),o.setIndex(h);const D=O(o,n);return s&&(D.userData.display="inner"),a.add(D),o},H=U(T),Be=U(he,!0),ue=U(P),De=[-1,1].map(n=>{const s=new e.BufferGeometry;s.setAttribute("position",new e.BufferAttribute(new Float32Array((te+1)*2*3),3).setUsage(e.DynamicDrawUsage));const o=[];for(let b=0;b<te;b++){const h=b*2;o.push(...n===1?[h,h+1,h+2,h+1,h+3,h+2]:[h,h+2,h+1,h+1,h+2,h+3])}s.setIndex(o);const d=O(s,P);return d.name=`hinge-cap-${n}`,a.add(d),{geometry:s,edge:n}});ue.setIndex(Array.from(ue.getIndex().array).reverse());let ke;const le=n=>{if(ke===n)return;ke=n;const s=e.MathUtils.degToRad((180-n)/2),o=Math.sin(s),d=Math.cos(s);for(const[u,M]of[[w,1],[r,-1]])u.rotation.y=M*s,u.position.set(-M*ve*o,0,ve*(1-d));const b=ge*d+(ve-Ce)*o,h=ge*o+Ce*d+ve*(1-d),D=2*ge/3,S=.45*d+(z+ve)*o,c=.45*o-z*d+ve*(1-d),y=-z*(1-o)-.8*o;for(let u=0;u<=te;u++){const M=u/te,X=1-M,C=X*X*X*-b+3*X*X*M*(-b+d*D)+3*X*M*M*(b-d*D)+M*M*M*b,G=h-3*X*M*o*D,se=Math.PI*M;for(let W=0;W<2;W++)Be.getAttribute("position").setXYZ(u*2+W,C,(W-.5)*Re,G),H.getAttribute("position").setXYZ(u*2+W,C,(W-.5)*($-.9),G-.07),ue.getAttribute("position").setXYZ(u*2+W,-S*Math.cos(se),(W-.5)*($-.9),c+(y-c)*Math.sin(se));for(const{geometry:W,edge:Te}of De){const t=W.getAttribute("position");t.setXYZ(u*2,C,Te*($/2-.45),G-.07),t.setXYZ(u*2+1,-S*Math.cos(se),Te*($/2-.45),c+(y-c)*Math.sin(se))}}for(const u of[H,Be,ue,...De.map(M=>M.geometry)])u.getAttribute("position").needsUpdate=!0,u.computeVertexNormals(),u.computeBoundingSphere(),u.computeBoundingBox();a.updateMatrixWorld(!0)};return le(180),{device:a,hitObjects:p,setAngle:le,buttonAnchors:()=>[...k].map(([n,s])=>({button:n,point:s.clone().applyMatrix4(r.matrixWorld),outward:s.clone().add(n==="side"?new e.Vector3(10,0,0):new e.Vector3(0,10,0)).applyMatrix4(r.matrixWorld)})),getBounds:n=>{n.makeEmpty();const s=new e.Box3;for(const o of p)!(o instanceof e.Mesh)||o.userData.button||(o.geometry.boundingBox||o.geometry.computeBoundingBox(),s.copy(o.geometry.boundingBox).applyMatrix4(o.matrixWorld),n.union(s));return n},pick:n=>{const s=n.intersectObjects(p,!1)[0];if(s?.object.userData.display||s?.object.userData.button)return s;for(const d of B)d.matrixWorld.multiplyMatrices(r.matrixWorld,d.matrix);const o=n.intersectObjects(B,!1)[0];return o&&(!s||o.distance<=s.distance)?o:s},loadAppearance:async n=>{const{GLTFLoader:s}=await Promise.resolve().then(()=>require("./GLTFLoader-CfPNHfJQ.js")),{scene:o}=await e.loadModel(new s,n),d=new Set;if(o.traverse(c=>{if(c instanceof e.Mesh){d.add(c.geometry);for(const y of Array.isArray(c.material)?c.material:[c.material]){d.add(y),y instanceof e.MeshStandardMaterial&&y.userData.finish==="polished-silver"&&je(y,g);for(const u of Object.values(y))u instanceof e.Texture&&u!==g&&d.add(u)}}}),F){d.forEach(c=>c.dispose());return}const b=o.getObjectByName("folding-half"),h=o.getObjectByName("stationary-half"),D=new Set;if(h?.traverse(c=>{c instanceof e.Mesh&&c.userData.button&&D.add(c.userData.button)}),!b||!h||!["side","volumeUp","volumeDown"].every(c=>D.has(c)))throw d.forEach(c=>c.dispose()),new Error("Duo appearance requires both body halves and side, volumeUp, and volumeDown button meshes.");j.push(...d);const S=b.children.find(c=>c instanceof e.Mesh&&(c.userData.sourceDisplay==="outer"||c.material.name==="cover-screen"));if(S){const c=a.getObjectByName("cover-display"),y=S.geometry.clone().scale(10,10,10);y.computeBoundingBox();const u=y.boundingBox,M=y.getAttribute("position"),X=new e.BufferAttribute(new Float32Array(M.count*2),2);for(let C=0;C<M.count;C++)X.setXY(C,(u.max.x-M.getX(C))/(u.max.x-u.min.x),(M.getY(C)-u.min.y)/(u.max.y-u.min.y));y.setAttribute("uv",X),c.geometry=y,c.position.copy(S.position).multiplyScalar(10),c.rotation.copy(S.rotation),c.scale.copy(S.scale),j.push(y)}for(const c of[w,r])for(const y of[...c.children]){if(y.userData.display)continue;c.remove(y);const u=p.indexOf(y);u!==-1&&p.splice(u,1)}I.clear(),B.length=0,k.clear(),i.clear();for(const c of["side","volumeUp","volumeDown"]){const y=new e.Group;y.name=`button-${c}`,I.set(c,y),r.add(y)}for(const[c,y]of[[b,w],[h,r]])for(const u of[...c.children]){if(!(u instanceof e.Mesh)||u.userData.sourceDisplay||["inner-screen","cover-screen"].includes(u.material.name))continue;u.geometry.scale(10,10,10),u.position.multiplyScalar(10),u.geometry.computeBoundingBox();const M=u.userData.button;M&&I.has(M)?I.get(M).add(u):y.add(u),p.push(u)}for(const[c,y]of I){const u=new e.Box3;for(const G of y.children){const se=G;se.updateMatrix(),u.union(se.geometry.boundingBox.clone().applyMatrix4(se.matrix))}const M=u.getCenter(new e.Vector3);for(const G of y.children)G.position.sub(M);y.position.copy(M),k.set(c,M);const X=u.getSize(new e.Vector3),C=ne(c==="side"?5:X.x,c==="side"?X.y:5,z,.1,x);p.splice(p.indexOf(C),1),C.position.copy(M).add(new e.Vector3(c==="side"?2:0,c==="side"?0:2,0)),C.userData.button=c,C.visible=!1,C.updateMatrix(),B.push(C)}a.updateMatrixWorld(!0)},highlightButton:(n,s=!1)=>{L=n,E=s},animateButtons:n=>{let s=!1;for(const[o,d]of I){const b=k.get(o),h=o===L?E?0:.5:.16;let D=e.MathUtils.damp(i.get(o)??.16,h,22,n);Math.abs(D-h)<.001?D=h:s=!0,i.set(o,D),d.position.copy(b),d.position[o==="side"?"x":"y"]+=D}return s},dispose:()=>{F=!0,j.forEach(n=>n.dispose())}}}function Ue(m,v,g){const a=Math.min(2.5,Math.max(0,g)),w=a<=.625?a*.8:a<=1.875?.5+(a-.625)*.2:.75+(a-1.875)*.4;return m+(v-m)*w}function qe(m,v,g,a,w){const r=i=>{const L=i.clone().project(g);return new e.Vector2((L.x+1)*a/2,(1-L.y)*w/2)},p=new e.Box2;for(const i of[v.min.x,v.max.x])for(const L of[v.min.y,v.max.y])for(const E of[v.min.z,v.max.z])p.expandByPoint(r(new e.Vector3(i,L,E)));const I=m.map(({button:i,point:L,outward:E})=>{const F=r(L),B=r(E).sub(F),j=Math.abs(B.y)>=Math.abs(B.x),x=j?B.y<0?"top":"bottom":B.x<0?"left":"right";return{button:i,edge:x,x:j?F.x:x==="left"?p.min.x-28:p.max.x+28,y:j?x==="top"?p.min.y-28:p.max.y+28:F.y}}),k=I.filter(i=>i.button!=="side");if(k.length===2&&k[0].edge===k[1].edge){const i=k[0].edge==="top"||k[0].edge==="bottom"?"x":"y";if(k.sort((L,E)=>L[i]-E[i]),k[1][i]-k[0][i]<48){const L=(k[0][i]+k[1][i])/2;k[0][i]=L-24,k[1][i]=L+24}}return{guides:I,rect:p,iconSize:Pe.hardwareIconSize(p)}}function He(m,v,g){const a=K.useRef(void 0),w=K.useRef(0),[r,p]=K.useState(),I=Pe.useDuoHinge(m,v,E=>{E!==void 0&&i(),g(E)}),k=K.useRef(I);k.current=I;const i=()=>{a.current&&(cancelAnimationFrame(w.current),a.current=void 0,I.interacting.current=!1,p(void 0))},L=()=>{const E=performance.now(),F=a.current,B=F?Ue(F.from,F.target,(E-F.startedAt)/1e3):I.angle,j=(F?.target??I.angle)<90?180:0;i();const x={from:B,target:j,startedAt:E};a.current=x,I.interacting.current=!0,p(j);let J=-1/0;const P=T=>{if(a.current!==x)return;const ae=Ue(B,j,(T-E)/1e3);(T-J>=1e3/30||ae===j)&&(J=T,k.current.changeAngle(ae)),ae===j?i():w.current=requestAnimationFrame(P)};w.current=requestAnimationFrame(P)};return K.useEffect(()=>()=>{cancelAnimationFrame(w.current),a.current=void 0,k.current.interacting.current=!1},[]),{...I,motion:a,target:r,fold:L,cancelFold:i,changeAngle:E=>{i(),I.changeAngle(E)}}}const Ze={environment:.4,hemisphere:1.1,key:{intensity:2.4,position:[-100,180,260]},rim:{intensity:.8,position:[200,-40,-200]}};function $e(m){const v=K.useRef(null),g=K.useRef(new Map),a=K.useRef(m);a.current=m;const[w,r]=K.useState(),{angle:p,changeAngle:I,interacting:k,motion:i,target:L,fold:E,cancelFold:F}=He(m.state.angleDegrees,m.setAngle,r),B=K.useRef(p);B.current=p;const{view:j,viewRef:x,chooseView:J,locked:P,lockedRef:T,setLocked:ae,orbit:me,drag:Me}=e.useStageView("front"),pe=K.useRef(()=>{});return K.useEffect(()=>{pe.current()},[p,L,j,P,m.state.orientation]),K.useEffect(()=>{const l=v.current,_=m.outer,he=m.inner;if(!l||!_||!he)return;const O=new e.OrthographicCamera(-150,150,150,-150,1,2e3);let ce=1;O.position.set(0,0,340);const ne=e.createDeviceStage({container:l,videos:[_,he],maxPixelRatio:1.5,lighting:Ze,resize:(t,f)=>{ce=t/f,O.updateProjectionMatrix()},frame:(t,f)=>Te(t,f)});if(!ne){r("3D rendering is unavailable in this browser. Enable WebGL to use the folding frame."),a.current.onReady?.();return}const{renderer:de,scene:we,invalidate:Q}=ne,N=new e.Group,ye=new e.VideoTexture(_),ee=new e.VideoTexture(he);for(const t of[ye,ee])t.colorSpace=e.SRGBColorSpace,t.minFilter=e.LinearFilter,t.magFilter=e.LinearFilter;let q=!1;const R=_e(ye,ee,ne.environment),{device:be}=R;m.model?R.loadAppearance(m.model).then(()=>Q()).catch(t=>{q||r(String(t))}).finally(()=>{q||a.current.onReady?.()}):a.current.onReady?.();const re=new fe.DuoButtonSender((t,f)=>a.current.button(t,f),t=>r(String(t)));N.add(be),we.add(N);const Se=new e.Raycaster,te=new e.Vector2;let U,H=B.current,Be=H,ue=H,De=0,ke=!1,le=0;pe.current=Q;let n,s;const o=t=>t instanceof Element?t.closest("[data-duo-button]"):null,d=t=>{s=t;for(const f of n?.guides??[]){const A=g.current.get(f.button);A&&(A.dataset.visible=String(f.edge===t))}},b=t=>{if(a.current.watchOnly)return;const f=o(t.target);if(f)return{button:f.dataset.duoButton};const A=de.domElement.getBoundingClientRect();te.set((t.clientX-A.left)/A.width*2-1,1-(t.clientY-A.top)/A.height*2),Se.setFromCamera(te,O);const Z=R.pick(Se),Y=Z?.object.userData.button;if(Y)return{button:Y};if(!Z?.object.userData.display||!Z.uv)return;const Ie=a.current.state.displays.find(ze=>ze.id===Z.object.userData.display);if(Ie)return{screenId:Ie.screenId,...fe.panelTouch(Z.uv.x,Z.uv.y)}},h=t=>{if(Q(),U||t.button!==0)return;o(t.target)||l.focus({preventScroll:!0});const f=b(t),A=f&&"button"in f?f.button:void 0,Z=fe.duoPointerMode(T.current,!!f&&!A,t.altKey);if(Z==="ignore"&&!A)return;const Y=Z==="touch"&&f&&"screenId"in f?f:void 0;U={pointer:t.pointerId,button:A,...Y,x:Y?.x??0,y:Y?.y??0,clientX:t.clientX,clientY:t.clientY},l.setPointerCapture(t.pointerId),A?(r(void 0),re.press(A),R.highlightButton(A,!0)):Y&&a.current.touch(0,Y.screenId,Y.x,Y.y)},D=t=>{if(Q(),!U){const f=b(t),A=f&&"button"in f?f.button:void 0,Z=l.getBoundingClientRect();d(A?n?.guides.find(Y=>Y.button===A)?.edge:n&&Pe.flatHoverEdge(t.clientX-Z.left,t.clientY-Z.top,n.rect)),de.domElement.style.cursor=A?"pointer":"",de.domElement.title=A?fe.DUO_BUTTONS[A]:"",R.highlightButton(A);return}if(!(U.pointer!==t.pointerId||U.button)){if(U.screenId){const f=b(t);f&&"screenId"in f&&f.screenId===U.screenId&&(U.x=f.x,U.y=f.y,a.current.touch(2,f.screenId,f.x,f.y))}else T.current||Me(t.clientX-U.clientX,t.clientY-U.clientY,1.4);U.clientX=t.clientX,U.clientY=t.clientY}},S=t=>{Q(),!(!U||t&&U.pointer!==t.pointerId)&&(U.button?(re.release(),R.highlightButton()):U.screenId&&a.current.touch(1,U.screenId,U.x,U.y),U=void 0,t&&D(t))},c=()=>{Q(),U||(R.highlightButton(),d(void 0))},y=t=>{Q();const f=o(t.target);if(!f||a.current.watchOnly||(t.stopPropagation(),t.code!=="Space"&&t.code!=="Enter")||(t.preventDefault(),t.repeat))return;const A=f.dataset.duoButton;re.press(A),R.highlightButton(A,!0),f.dataset.pressed="true"},u=t=>{Q();const f=o(t.target);!f||a.current.watchOnly||(t.stopPropagation(),!(t.code!=="Space"&&t.code!=="Enter")&&(t.preventDefault(),re.release(),R.highlightButton(f.dataset.duoButton),f.dataset.pressed="false"))},M=t=>{const f=o(t.target);f&&d(n?.guides.find(A=>A.button===f.dataset.duoButton)?.edge)},X=()=>{Q(),S(),re.release(),R.highlightButton(),d(void 0),g.current.forEach(t=>{t.dataset.pressed="false"})},C=t=>{l.contains(t.relatedTarget)?o(t.target)&&(re.release(),R.highlightButton()):X()};l.addEventListener("pointerleave",c),l.addEventListener("pointerdown",h),l.addEventListener("pointermove",D),l.addEventListener("pointerup",S),l.addEventListener("pointercancel",S),l.addEventListener("lostpointercapture",S),l.addEventListener("keydown",y),l.addEventListener("keyup",u),l.addEventListener("focusin",M),l.addEventListener("focusout",C),window.addEventListener("blur",X);const G=new e.Box3,se=new e.Vector3,W=new e.Vector3,Te=(t,f)=>{ue!==B.current&&(Be=H,ue=B.current,De=t,ke=k.current);const A=i.current;H=A?Ue(A.from,A.target,(t-A.startedAt)/1e3):ke?e.MathUtils.damp(H,ue,18,f):Ue(Be,ue,(t-De)/1e3),Math.abs(H-B.current)<.001&&(H=B.current),R.setAngle(H);const Y=(1-e.MathUtils.smoothstep(H,15,110))*Math.PI/2+(x.current==="back"?Math.PI:0);le=e.MathUtils.damp(le,Y,12,f),Math.abs(le-Y)<.001&&(le=Y),N.rotation.set(me.pitch+(x.current==="table"?-.35:x.current==="book"?.2:0),me.yaw+(x.current==="book"?-.2:0),0),be.rotation.set(0,le,{portrait:0,pud:Math.PI,"landscape-left":Math.PI/2,"landscape-right":-Math.PI/2}[a.current.state.orientation]??0,"ZYX"),N.position.set(0,0,0),N.updateMatrixWorld(!0),R.getBounds(G).getCenter(se),G.getSize(W),N.position.copy(se).negate();const Ie=l.clientWidth,ze=l.clientHeight,Fe=Math.max(.4,1-108/Ie),Ne=Math.min(.8,Math.max(.35,1-108/ze)),Le=Math.max(W.y/(2*Ne),W.x/(2*ce*Fe));O.top=e.MathUtils.damp(O.top,Le,14,f),Math.abs(O.top-Le)<.001&&(O.top=Le),O.bottom=-O.top,O.left=-O.top*ce,O.right=O.top*ce,O.updateProjectionMatrix();const Ye=R.animateButtons(f);de.render(we,O),R.getBounds(G),n=qe(R.buttonAnchors(),G,O,Ie,ze);for(const Oe of n.guides){const Ae=g.current.get(Oe.button);Ae&&(Ae.style.left=`${Oe.x}px`,Ae.style.top=`${Oe.y}px`,Ae.style.setProperty("--duo-hardware-icon-size",`${n.iconSize}px`),Ae.dataset.visible=String(Oe.edge===s))}return!!i.current||H!==B.current||le!==Y||O.top!==Le||Ye};return ne.start(),()=>{q=!0,pe.current=()=>{},S(),re.release(),window.removeEventListener("blur",X),l.removeEventListener("pointerleave",c),l.removeEventListener("pointerdown",h),l.removeEventListener("pointermove",D),l.removeEventListener("pointerup",S),l.removeEventListener("pointercancel",S),l.removeEventListener("lostpointercapture",S),l.removeEventListener("keydown",y),l.removeEventListener("keyup",u),l.removeEventListener("focusin",M),l.removeEventListener("focusout",C),R.dispose(),ye.dispose(),ee.dispose(),ne.dispose()}},[m.outer,m.inner,m.model]),ie.jsxs("div",{className:"rc-duo",children:[ie.jsx("div",{ref:v,className:"rc-duo-stage","data-position-locked":P,tabIndex:0,role:"application","aria-label":"iPhone Duo simulator. Touch the screen to control iOS. Drag the frame or background to rotate when position is unlocked.",onKeyDown:m.onKeyDown,onKeyUp:m.onKeyUp,children:Object.keys(fe.DUO_BUTTONS).map(l=>ie.jsx("button",{disabled:m.watchOnly,ref:_=>{_?g.current.set(l,_):g.current.delete(l)},type:"button",className:"rc-duo-hardware","data-duo-button":l,"data-visible":"false","aria-label":fe.DUO_BUTTONS[l],title:fe.DUO_BUTTONS[l],children:ie.jsx(Pe.DuoHardwareIcon,{button:l})},l))}),ie.jsxs(Pe.DuoControls,{watchOnly:m.watchOnly,angle:p,onFold:E,foldTarget:L,onHingeDrag:F,changeAngle:I,interacting:k,rotate:()=>{m.setOrientation(m.state.orientation==="portrait"?"landscape-left":"portrait").catch(l=>r(String(l)))},children:[["front","book","table","back"].map(l=>ie.jsx("button",{disabled:m.watchOnly&&(l==="book"||l==="table"),"aria-pressed":j===l,onClick:()=>{J(l),pe.current(),l==="book"&&m.setOrientation("portrait").then(()=>I(110)).catch(_=>r(String(_))),l==="table"&&m.setOrientation("landscape-left").then(()=>I(110)).catch(_=>r(String(_)))},children:l==="table"?"Laptop view":l[0].toUpperCase()+l.slice(1)},l)),ie.jsxs("button",{className:"rc-duo-lock","aria-label":"Lock position","aria-pressed":P,title:P?"Position is locked. Screen touches still control iOS.":"Drag the frame or background to rotate. Alt-drag rotates from the screen.",onClick:()=>ae(!P),children:[ie.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[ie.jsx("rect",{x:"4",y:"9",width:"12",height:"9",rx:"2",stroke:"currentColor",strokeWidth:"1.6"}),ie.jsx("path",{d:P?"M6 9V6a4 4 0 0 1 8 0v3":"M6 9V6a4 4 0 0 1 8 0",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]}),P?"Position locked":"Lock position"]})]}),w&&ie.jsx("div",{role:"alert",className:"rc-duo-error",children:w})]})}exports.default=$e;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as o, jsxs as x, Fragment as R } from "react/jsx-runtime";
|
|
2
2
|
import ot, { useId as J, useState as S, useRef as M, useEffect as T, useCallback as at, useLayoutEffect as it, Suspense as st, lazy as ct } from "react";
|
|
3
|
-
import { u as dt, D as ut } from "./remote-control-
|
|
3
|
+
import { u as dt, D as ut } from "./remote-control-BX6dzHtt.mjs";
|
|
4
4
|
import { H as lt, D as A, h as ht, i as ft, j as mt, k as pt, l as j } from "./core-nbvkIrvp.mjs";
|
|
5
5
|
function gt(t, n, r) {
|
|
6
6
|
const [s, i] = S(t), a = M({ nativeAngle: t, send: n, failed: r });
|
|
@@ -419,7 +419,7 @@ function kt({ motion: t, onFinish: n }) {
|
|
|
419
419
|
)
|
|
420
420
|
] });
|
|
421
421
|
}
|
|
422
|
-
const Pt = ct(() => import("./duo-frame-
|
|
422
|
+
const Pt = ct(() => import("./duo-frame-BCmB9_5p.mjs"));
|
|
423
423
|
function Ft(t) {
|
|
424
424
|
const n = dt();
|
|
425
425
|
return /* @__PURE__ */ x("div", { className: "rc-duo-view", children: [
|