@limrun/ui 0.21.0 → 0.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +36 -8
  2. package/dist/BufferGeometryUtils-B2-bJqFj.js +1 -0
  3. package/dist/BufferGeometryUtils-BcXIkYhS.mjs +64 -0
  4. package/dist/{GLTFLoader-D4AITfgZ.mjs → GLTFLoader-BQvr_TBF.mjs} +138 -137
  5. package/dist/GLTFLoader-CsxjkQ8a.js +1 -0
  6. package/dist/components/device-stage.d.ts +61 -0
  7. package/dist/components/device-view.d.ts +29 -0
  8. package/dist/components/duo-frame.d.ts +5 -1
  9. package/dist/components/duo-model.d.ts +2 -1
  10. package/dist/components/macbook-frame.d.ts +30 -0
  11. package/dist/components/macbook-geometry.d.ts +77 -0
  12. package/dist/components/model-source.d.ts +8 -0
  13. package/dist/components/remote-control.d.ts +40 -1
  14. package/dist/components/studio-environment.d.ts +6 -0
  15. package/dist/core/mac-pointer.d.ts +56 -0
  16. package/dist/{core-CRIachT9.mjs → core-nbvkIrvp.mjs} +24 -24
  17. package/dist/core.js +12 -12
  18. package/dist/duo-frame-B04_gIge.js +11 -0
  19. package/dist/duo-frame-CyoWZakh.mjs +748 -0
  20. package/dist/duo-model-BYgtCaCR.mjs +4 -0
  21. package/dist/duo-model-CDWgmLRF.js +1 -0
  22. package/dist/duo-model.d.ts +2 -0
  23. package/dist/duo-view-BHwnQmx_.js +1 -0
  24. package/dist/{duo-view-BeqYIqfQ.mjs → duo-view-DJEQ3Q74.mjs} +84 -86
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.css +1 -1
  27. package/dist/index.js +32 -25
  28. package/dist/lite.cjs +1 -1
  29. package/dist/lite.js +2 -2
  30. package/dist/macbook-frame-Be0dCliH.js +3 -0
  31. package/dist/macbook-frame-DzwIHHCA.mjs +344 -0
  32. package/dist/macbook-model-BiMxLpmf.mjs +4 -0
  33. package/dist/macbook-model-BpUdvtlU.js +1 -0
  34. package/dist/macbook-model.d.ts +2 -0
  35. package/dist/meshopt_decoder.module-C4Z_evpr.mjs +217 -0
  36. package/dist/meshopt_decoder.module-DxJdu6ez.js +1 -0
  37. package/dist/{duo-frame-D1JK_cRk.mjs → model-source-BAZAKTcr.mjs} +6184 -6894
  38. package/dist/model-source-DbYJQWkh.js +4049 -0
  39. package/dist/remote-control-Db6ssV0S.js +1 -0
  40. package/dist/remote-control-PGtDEDgm.mjs +1746 -0
  41. package/package.json +1 -1
  42. package/dist/GLTFLoader-C25N9Y4j.js +0 -1
  43. package/dist/duo-frame-B1NXSk6a.js +0 -4059
  44. package/dist/duo-view-PsR5b045.js +0 -1
  45. package/dist/remote-control-DNr0Pyrx.js +0 -1
  46. package/dist/remote-control-rdm3mDtI.mjs +0 -1299
@@ -0,0 +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;
@@ -0,0 +1,61 @@
1
+ import * as THREE from 'three';
2
+ /** A device's studio light: the environment's strength, a sky fill, a key light and a rim light. */
3
+ export interface StageLighting {
4
+ environment: number;
5
+ hemisphere: number;
6
+ key: {
7
+ intensity: number;
8
+ position: [number, number, number];
9
+ };
10
+ rim: {
11
+ intensity: number;
12
+ position: [number, number, number];
13
+ };
14
+ }
15
+ export interface DeviceStageOptions {
16
+ /** The element the canvas fills. */
17
+ container: HTMLElement;
18
+ /** The streams on the device's screens: a new frame of any of them draws the scene again. */
19
+ videos: HTMLVideoElement[];
20
+ maxPixelRatio: number;
21
+ lighting: StageLighting;
22
+ /** The container changed size, in CSS pixels. */
23
+ resize(width: number, height: number): void;
24
+ /** Draws one frame, `dt` seconds after the last, and says whether anything still moves. */
25
+ frame(time: number, dt: number): boolean;
26
+ }
27
+ /**
28
+ * A 3D device frame's stage: the WebGL canvas, its studio light, and a render loop that draws only
29
+ * when something changes, a stream's new frame included, and never while the stage is out of view
30
+ * or the page hidden. The iPhone Duo and the MacBook each put their model and camera on one.
31
+ */
32
+ export interface DeviceStage {
33
+ renderer: THREE.WebGLRenderer;
34
+ scene: THREE.Scene;
35
+ /** The studio environment, for materials that reflect it explicitly. */
36
+ environment: THREE.Texture;
37
+ /** Asks for a frame. */
38
+ invalidate(): void;
39
+ /** Starts sizing and drawing, once the device's own state exists. */
40
+ start(): void;
41
+ dispose(): void;
42
+ }
43
+ /** Creates a stage, or returns undefined where the browser has no WebGL. */
44
+ export declare function createDeviceStage(options: DeviceStageOptions): DeviceStage | undefined;
45
+ /**
46
+ * A 3D frame's view presets, its position lock, and the turn the viewer has dragged it to on top of
47
+ * the preset. Picking a preset clears the drag, so the preset shows as designed.
48
+ */
49
+ export declare function useStageView<View extends string>(initial: View): {
50
+ view: View;
51
+ viewRef: import('react').RefObject<View>;
52
+ chooseView: (next: View) => void;
53
+ locked: boolean;
54
+ lockedRef: import('react').RefObject<boolean>;
55
+ setLocked: import('react').Dispatch<import('react').SetStateAction<boolean>>;
56
+ orbit: {
57
+ yaw: number;
58
+ pitch: number;
59
+ };
60
+ drag: (dx: number, dy: number, limit: number) => void;
61
+ };
@@ -0,0 +1,29 @@
1
+ export type DeviceViewMode = '2d' | '3d';
2
+ /** The 2D and 3D choice of a device frame, the iPhone Duo's or the MacBook's. */
3
+ export interface DeviceView {
4
+ /** What the viewer picked. */
5
+ mode: DeviceViewMode;
6
+ /**
7
+ * What is on screen and takes input. 3D shows only once the 3D view says it is ready, so the 2D
8
+ * view stays until then.
9
+ */
10
+ shown: DeviceViewMode;
11
+ /** The viewer picked 3D and its code and model are still on their way. */
12
+ loading: boolean;
13
+ choose(mode: DeviceViewMode): void;
14
+ /**
15
+ * The 3D view is ready. Each pick of 3D gets its own callback, so one left from an earlier pick,
16
+ * such as a load that finished after the viewer went back to 2D, changes nothing.
17
+ */
18
+ onReady(): void;
19
+ }
20
+ /**
21
+ * useDeviceView keeps a device frame's 2D and 3D choice. `onShow3d` runs as the 3D view takes over
22
+ * from the 2D one, before the 2D view stops taking input, so it can let go of what the 2D view holds.
23
+ */
24
+ export declare function useDeviceView(onShow3d?: () => void): DeviceView;
25
+ /** The 2D and 3D switch above a device frame. The 3D button spins while 3D downloads. */
26
+ export declare function DeviceModeToggle({ view, label }: {
27
+ view: DeviceView;
28
+ label: string;
29
+ }): import("react").JSX.Element;
@@ -1,8 +1,10 @@
1
1
  import { default as React } from 'react';
2
+ import { RemoteControlModel } from './remote-control';
2
3
  import { DuoButton, DuoState, DuoOrientation } from '../core/duo';
3
4
  export interface DuoFrameProps {
4
5
  watchOnly?: boolean;
5
- modelUrl?: string;
6
+ /** The prepared Duo appearance to draw over the built-in body. */
7
+ model?: RemoteControlModel;
6
8
  outer: HTMLVideoElement | null;
7
9
  inner: HTMLVideoElement | null;
8
10
  state: DuoState;
@@ -12,6 +14,8 @@ export interface DuoFrameProps {
12
14
  touch: (action: number, screenId: number, x: number, y: number) => void;
13
15
  onKeyDown: React.KeyboardEventHandler<HTMLDivElement>;
14
16
  onKeyUp: React.KeyboardEventHandler<HTMLDivElement>;
17
+ /** The appearance has loaded, or failed to and left the built-in body, or there is none to load. */
18
+ onReady?: () => void;
15
19
  }
16
20
  /** A procedural titanium frame. Each glass panel carries its own native video texture. */
17
21
  export default function DuoFrame(props: DuoFrameProps): React.JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import { DuoButton } from '../core/duo';
2
+ import { RemoteControlModel } from './remote-control';
2
3
  import * as THREE from 'three';
3
4
  /** Independent of WebGL so fold geometry and touch occlusion can be tested directly. */
4
5
  export declare function createDuoModel(outerTexture: THREE.Texture, innerTexture: THREE.Texture, environment?: THREE.Texture): {
@@ -12,7 +13,7 @@ export declare function createDuoModel(outerTexture: THREE.Texture, innerTexture
12
13
  }[];
13
14
  getBounds: (bounds: THREE.Box3) => THREE.Box3;
14
15
  pick: (ray: THREE.Raycaster) => THREE.Intersection<THREE.Object3D<THREE.Object3DEventMap>>;
15
- loadAppearance: (url: string) => Promise<void>;
16
+ loadAppearance: (source: RemoteControlModel) => Promise<void>;
16
17
  highlightButton: (name?: DuoButton, pressed?: boolean) => void;
17
18
  animateButtons: (dt: number) => boolean;
18
19
  dispose: () => void;
@@ -0,0 +1,30 @@
1
+ import { default as React } from 'react';
2
+ import { RemoteControlModel } from './remote-control';
3
+ export interface MacbookFrameProps {
4
+ video: HTMLVideoElement | null;
5
+ /** The screen's aspect ratio, which the stream sets. */
6
+ aspect: number;
7
+ watchOnly?: boolean;
8
+ /** A desktop pointer event at a point of the screen, 0 to 1 from its top left. */
9
+ pointer: (action: 'down' | 'move' | 'up', x: number, y: number, buttons: number) => void;
10
+ /** A scroll at a point of the screen, in CSS pixels as WheelEvent reports them. */
11
+ scroll: (x: number, y: number, deltaX: number, deltaY: number) => void;
12
+ onKeyDown: React.KeyboardEventHandler<HTMLDivElement>;
13
+ onKeyUp: React.KeyboardEventHandler<HTMLDivElement>;
14
+ /** The stage lost focus, so every key the guest holds must go up. */
15
+ onBlur: () => void;
16
+ /**
17
+ * A prepared MacBook model to draw instead of the built-in one; scripts/prepare-macbook-model.mjs
18
+ * describes the nodes it must have.
19
+ */
20
+ model?: RemoteControlModel;
21
+ /** Opens the lid when the MacBook appears, unless the viewer prefers reduced motion. */
22
+ animateLid?: boolean;
23
+ /**
24
+ * The MacBook has drawn its first frame, or the reason it cannot is on screen. Until then the
25
+ * stage is unseen, so the host can keep showing what it had.
26
+ */
27
+ onReady?: () => void;
28
+ }
29
+ /** The MacBook in 3D with the stream on its screen. The screen takes the guest's pointer. */
30
+ export default function MacbookFrame(props: MacbookFrameProps): React.JSX.Element;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The MacBook Pro drawn around a macOS guest. Lengths are hundredths of the screen's width, so
3
+ * the model fits any guest display: only the screen's height, and with it the lid's height and
4
+ * the base's depth, follows the stream's aspect ratio.
5
+ *
6
+ * The CSS frame (`.rc-macbook` in remote-control.css), the WebGL lid opening and the three.js
7
+ * 3D mode all draw this one shape. Seen straight on with the lid upright, the 3D model covers
8
+ * exactly the CSS frame, so either hands over to the other without a jump.
9
+ */
10
+ export declare const MACBOOK: {
11
+ sideBezel: number;
12
+ topBezel: number;
13
+ chin: number;
14
+ baseHeight: number;
15
+ baseOverhang: number;
16
+ screenRadius: number;
17
+ lidThickness: number;
18
+ };
19
+ export declare const MACBOOK_LID_WIDTH: number;
20
+ export declare const MACBOOK_WIDTH: number;
21
+ export declare const MACBOOK_EXTRA_HEIGHT: number;
22
+ export declare const MACBOOK_SCREEN_RAISE: number;
23
+ export type MacbookPart = 'lid' | 'base';
24
+ export type MacbookKind = 'shell' | 'glass' | 'screen' | 'camera' | 'well' | 'keys' | 'trackpad' | 'scoop';
25
+ /** Interleaved position (3), normal (3) and texture coordinate (2) per vertex, in triangles. */
26
+ export type MacbookMesh = {
27
+ part: MacbookPart;
28
+ kind: MacbookKind;
29
+ vertices: Float32Array;
30
+ };
31
+ export declare const MACBOOK_VERTEX_FLOATS = 8;
32
+ /**
33
+ * The model's coordinates: x to the right, y up, z toward the viewer. The hinge is the x axis.
34
+ * Lid parts are given upright, standing on the base with the screen facing +z; turning them by
35
+ * `macbookLidAngle` about the hinge closes the lid. The base's top is y = 0, and it reaches from
36
+ * just behind the lid to the front edge at z = `depth`.
37
+ */
38
+ export declare function macbookDimensions(aspect: number): {
39
+ screenHeight: number;
40
+ lidHeight: number;
41
+ depth: number;
42
+ };
43
+ export declare const MACBOOK_LID_CLOSED: number;
44
+ export declare const MACBOOK_LID_MAX_DEGREES = 135;
45
+ export declare const MACBOOK_LID_OPEN_DEGREES = 100;
46
+ export declare const MACBOOK_LID_OPENING_MS = 2400;
47
+ /** The lid's turn about the hinge, in radians, for an opening in degrees from closed. */
48
+ export declare function lidRotation(degrees: number): number;
49
+ /** A lid's progress through a move, 0 to 1: it starts fast and slows to a stop, as one pushed does. */
50
+ export declare function lidEase(progress: number): number;
51
+ /**
52
+ * Builds the model for a screen of the given aspect ratio. The screen's texture coordinates put
53
+ * (0, 0) at its bottom left, as WebGL and three.js expect for an upright image.
54
+ */
55
+ export declare function macbookMeshes(aspect: number): MacbookMesh[];
56
+ /**
57
+ * How a stream fills a display of another shape: the texture transform that keeps its shape,
58
+ * centered, with black bars on the sides it does not reach. Texture coordinates outside 0 to 1
59
+ * after it are the bars. A display with a notch keeps the stream below it, in the band macOS keeps
60
+ * clear of the notch, right under it, so the strip beside the notch can show the stream's menu bar
61
+ * reaching up; `notch` is the share of the display's height the notch takes at its top.
62
+ */
63
+ export declare function streamFit(videoAspect: number, screenAspect: number, notch?: number): {
64
+ readonly repeat: readonly [number, number];
65
+ readonly offset: readonly [number, number];
66
+ };
67
+ /**
68
+ * The stream's point, 0 to 1 from its top left, at a point of the display given as texture
69
+ * coordinates from its bottom left; undefined on a black bar.
70
+ */
71
+ export declare function streamPoint(u: number, v: number, fit: {
72
+ repeat: readonly number[];
73
+ offset: readonly number[];
74
+ }): {
75
+ x: number;
76
+ y: number;
77
+ } | undefined;
@@ -0,0 +1,8 @@
1
+ import { GLTF, GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
2
+ import { RemoteControlModel } from './remote-control';
3
+ /**
4
+ * Loads a 3D device's model from a URL, or from the function that resolves to one. A bundled model
5
+ * 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.
7
+ */
8
+ export declare function loadModel(loader: GLTFLoader, source: RemoteControlModel): Promise<GLTF>;
@@ -24,13 +24,28 @@ export interface RemoteControlProps {
24
24
  sessionId?: string;
25
25
  openUrl?: string;
26
26
  showFrame?: boolean;
27
+ /**
28
+ * Opens a macOS guest's MacBook's lid, with the stream on its screen, each time the 3D MacBook
29
+ * appears. Defaults to true. It never plays for a viewer who prefers reduced motion, and other
30
+ * platforms and the 2D frame ignore it.
31
+ */
32
+ animateLid?: boolean;
27
33
  /**
28
34
  * The iOS model behind the stream. iphone-duo enables the official iPhone Duo's native displays and
29
35
  * interactive folding frame; iphone-se and iphone-17e pick their own device frames.
30
36
  */
31
37
  deviceModel?: RemoteControlDeviceModel;
32
- /** Optional prepared Duo GLB, supplied and licensed by the host application. */
38
+ /**
39
+ * A prepared iPhone Duo GLB for the 3D Duo, in place of the one the default entry bundles.
40
+ * Without either, as with the lite entry, a simpler built-in Duo is drawn.
41
+ */
33
42
  duoModelUrl?: string;
43
+ /**
44
+ * A prepared MacBook GLB for a macOS guest's 3D MacBook, in place of the one the default entry
45
+ * bundles. scripts/prepare-macbook-model.mjs makes one. Without either, as with the lite entry,
46
+ * a simpler built-in MacBook is drawn.
47
+ */
48
+ macbookModelUrl?: string;
34
49
  autoReconnect?: boolean;
35
50
  /**
36
51
  * Preferred playback jitter buffer duration in milliseconds (0–4000), for
@@ -237,7 +252,31 @@ export type RemoteControlPlatformAssets = {
237
252
  frame: string;
238
253
  frameLandscape: string;
239
254
  }>>;
255
+ /**
256
+ * Where a macOS frame image's screen opening sits, as fractions of the image's width and height
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 sits below it, and
259
+ * the strip either side of the notch shows the stream's top row, as if its menu bar reached up.
260
+ */
261
+ screen?: {
262
+ left: number;
263
+ top: number;
264
+ width: number;
265
+ height: number;
266
+ notch?: number;
267
+ };
268
+ /**
269
+ * The prepared GLB the platform's 3D device draws: the iPhone Duo for iOS, and the MacBook for
270
+ * macOS, whose nodes scripts/prepare-macbook-model.mjs describes. The default entry's load only
271
+ * when the 3D view appears.
272
+ */
273
+ model?: RemoteControlModel;
240
274
  loadingLogo?: string;
241
275
  };
276
+ /**
277
+ * A prepared 3D model, as a URL or a function that resolves to one when the 3D view first needs it.
278
+ * A function keeps a large model out of the page until then; pass the same function each render.
279
+ */
280
+ export type RemoteControlModel = string | (() => Promise<string>);
242
281
  export type RemoteControlAssets = Partial<Record<DevicePlatform, RemoteControlPlatformAssets>>;
243
282
  export declare const RemoteControl: React.ForwardRefExoticComponent<RemoteControlProps & React.RefAttributes<RemoteControlHandle>>;
@@ -0,0 +1,6 @@
1
+ import * as THREE from 'three';
2
+ /**
3
+ * A procedural studio for the 3D device frames to reflect. Continuous light-to-dark sweeps give
4
+ * broad metal faces reflections at every viewing angle. The caller disposes the returned target.
5
+ */
6
+ export declare function createStudioEnvironment(renderer: THREE.WebGLRenderer): THREE.WebGLRenderTarget;
@@ -0,0 +1,56 @@
1
+ /** A point on a macOS guest's screen, in its pixels, with the screen's size. */
2
+ export interface MacScreenPoint {
3
+ x: number;
4
+ y: number;
5
+ width: number;
6
+ height: number;
7
+ }
8
+ /** Where a touch screen's fingers land on the guest's screen, from client coordinates. */
9
+ export interface MacTouchScreen {
10
+ /** The guest's point under a client point. */
11
+ map(x: number, y: number): MacScreenPoint | undefined;
12
+ /** Whether a client point is on the guest's screen, not on a frame or a letterbox bar. */
13
+ contains(x: number, y: number): boolean;
14
+ /** Guest pixels per CSS pixel, so content follows the fingers. */
15
+ scale: number;
16
+ }
17
+ export type MacTouchType = 'touchstart' | 'touchmove' | 'touchend' | 'touchcancel';
18
+ export declare const MAC_TOUCH_HOLD_MS = 150;
19
+ export declare const MAC_TOUCH_SLOP = 8;
20
+ /**
21
+ * MacPointer is the one sender of a macOS guest's pointer. Every view sends its mouse, touch and
22
+ * scroll input through it, so it knows which button the guest holds and can let go of it when input
23
+ * moves to another view, the stream goes away, or input is blocked.
24
+ *
25
+ * A touch screen has no hover and no wheel. One finger presses the left button and drags with it
26
+ * held, and lets go where it lifts; limacvm rests the pointer at a new spot before a press, as macOS
27
+ * needs. The press waits until the finger moves, holds still a moment, or lifts as a tap, so a second
28
+ * finger landing just after it scrolls without a click. Two fingers scroll, content following them
29
+ * as on a trackpad. A gesture that becomes a scroll lets its press go first, and stays a scroll until
30
+ * every finger lifts. A cancelled touch, which the system took for its own gesture, is no tap.
31
+ */
32
+ export declare class MacPointer {
33
+ private send;
34
+ /** Input is blocked, as in inspect's select mode. A release of a button the guest holds still goes out. */
35
+ private blocked;
36
+ private last;
37
+ private gesture;
38
+ private screen;
39
+ constructor(send: (data: ArrayBuffer) => void,
40
+ /** Input is blocked, as in inspect's select mode. A release of a button the guest holds still goes out. */
41
+ blocked?: () => boolean);
42
+ pointer(action: number, point: MacScreenPoint, buttons: number): void;
43
+ scroll(point: MacScreenPoint, deltaX: number, deltaY: number): void;
44
+ /**
45
+ * A touch event, its fingers in client coordinates. Returns true when a finger lands on the screen
46
+ * and starts a gesture, so the caller can give the screen the keyboard.
47
+ */
48
+ touch(type: MacTouchType, touches: {
49
+ x: number;
50
+ y: number;
51
+ }[], screen: MacTouchScreen): boolean;
52
+ /** Drops a pending touch and lets go of any button the guest holds, where it was pressed. */
53
+ release(): void;
54
+ private press;
55
+ private lift;
56
+ }
@@ -2286,14 +2286,14 @@ function tr(t) {
2286
2286
  const kn = (t) => typeof t.message == "string" ? t.message : typeof t.error == "string" ? t.error : null, Pn = (t) => typeof t.dataUri == "string" ? { dataUri: t.dataUri } : typeof t.base64 == "string" ? t.base64.startsWith("data:") ? { dataUri: t.base64 } : { dataUri: `data:${t.base64.startsWith("/9j/") ? "image/jpeg" : "image/png"};base64,${t.base64}` } : null;
2287
2287
  export {
2288
2288
  ot as A,
2289
- qn as B,
2290
- Qt as C,
2289
+ it as B,
2290
+ o as C,
2291
2291
  $n as D,
2292
- Xn as E,
2293
- jn as F,
2294
- Jn as G,
2292
+ Gt as E,
2293
+ Ht as F,
2294
+ je as G,
2295
2295
  Gn as H,
2296
- Hn as I,
2296
+ Bn as I,
2297
2297
  ee as J,
2298
2298
  en as K,
2299
2299
  zt as L,
@@ -2305,23 +2305,23 @@ export {
2305
2305
  un as e,
2306
2306
  Qn as f,
2307
2307
  an as g,
2308
- fn as h,
2309
- bn as i,
2310
- Xt as j,
2311
- tr as k,
2312
- Wn as l,
2313
- xn as m,
2308
+ Vn as h,
2309
+ qn as i,
2310
+ Qt as j,
2311
+ Xn as k,
2312
+ jn as l,
2313
+ Jn as m,
2314
2314
  ln as n,
2315
- le as o,
2316
- y as p,
2317
- Tt as q,
2318
- jt as r,
2319
- F as s,
2320
- it as t,
2321
- o as u,
2322
- Gt as v,
2323
- Ht as w,
2324
- je as x,
2325
- Bn as y,
2326
- Vn as z
2315
+ xn as o,
2316
+ Hn as p,
2317
+ Wn as q,
2318
+ fn as r,
2319
+ bn as s,
2320
+ Xt as t,
2321
+ F as u,
2322
+ tr as v,
2323
+ le as w,
2324
+ y as x,
2325
+ Tt as y,
2326
+ jt as z
2327
2327
  };
package/dist/core.js CHANGED
@@ -1,4 +1,4 @@
1
- import { x as s, u as o, A as r, J as t, z as l, H as n, a as c, b as u, c as T, d as i, e as E, f as m, k as p, K as A, t as g, r as x, v as D, y as S, C as d, L as h, B as y, n as M, g as C, I } from "./core-CRIachT9.mjs";
1
+ import { G as s, C as o, A as r, J as t, h as l, H as n, a as c, b as i, c as E, d as T, e as u, f as m, v as p, K as A, B as g, z as D, E as S, I as h, j as x, L as d, i as M, n as y, g as C, p as I } from "./core-nbvkIrvp.mjs";
2
2
  export {
3
3
  s as AMOTION_EVENT,
4
4
  o as ANDROID_KEYS,
@@ -7,21 +7,21 @@ export {
7
7
  l as DuoTouchController,
8
8
  n as HingeSender,
9
9
  c as axElementAtPoint,
10
- u as axElementSelectorExpression,
11
- T as axElementSummary,
12
- i as axElementsEqual,
13
- E as axSnapshotsEqual,
10
+ i as axElementSelectorExpression,
11
+ E as axElementSummary,
12
+ T as axElementsEqual,
13
+ u as axSnapshotsEqual,
14
14
  m as clampAxFrameForScreen,
15
15
  p as createDeviceStream,
16
16
  A as createDisplayTouchMessage,
17
17
  g as createInjectKeycodeMessage,
18
- x as createSetClipboardMessage,
19
- D as createTouchControlMessage,
20
- S as createTwoFingerTouchControlMessage,
21
- d as duoDisplayTurns,
22
- h as flatDisplayTouch,
23
- y as getDuoDisplay,
24
- M as normalizeAndroidTree,
18
+ D as createSetClipboardMessage,
19
+ S as createTouchControlMessage,
20
+ h as createTwoFingerTouchControlMessage,
21
+ x as duoDisplayTurns,
22
+ d as flatDisplayTouch,
23
+ M as getDuoDisplay,
24
+ y as normalizeAndroidTree,
25
25
  C as normalizeIosTree,
26
26
  I as panelTouch
27
27
  };