@codefluss/plugin-configurator-3d 0.0.1-alpha.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.
package/dist/index.mjs ADDED
@@ -0,0 +1,14 @@
1
+ import{jsxs as e,jsx as t,Fragment as s}from"react/jsx-runtime";import{lazy as r,Suspense as n}from"react";import{Box as o}from"lucide-react";import{createStore as i}from"zustand/vanilla";import*as a from"three";import{TrianglesDrawMode as l,TriangleFanDrawMode as c,TriangleStripDrawMode as d,Loader as u,LoaderUtils as h,FileLoader as m,MeshPhysicalMaterial as p,Vector2 as f,Color as g,LinearSRGBColorSpace as T,SRGBColorSpace as y,SpotLight as b,PointLight as x,DirectionalLight as v,Matrix4 as R,Vector3 as w,Quaternion as _,InstancedMesh as A,InstancedBufferAttribute as E,Object3D as L,TextureLoader as M,ImageBitmapLoader as I,BufferAttribute as P,InterleavedBuffer as S,InterleavedBufferAttribute as C,LinearMipmapLinearFilter as k,NearestMipmapLinearFilter as O,LinearMipmapNearestFilter as N,NearestMipmapNearestFilter as D,LinearFilter as H,NearestFilter as F,RepeatWrapping as U,MirroredRepeatWrapping as G,ClampToEdgeWrapping as j,PointsMaterial as K,Material as B,LineBasicMaterial as V,MeshStandardMaterial as z,DoubleSide as X,MeshBasicMaterial as q,PropertyBinding as W,BufferGeometry as Z,SkinnedMesh as Y,Mesh as J,LineSegments as $,Line as Q,LineLoop as ee,Points as te,Group as se,PerspectiveCamera as re,MathUtils as ne,OrthographicCamera as oe,Skeleton as ie,AnimationClip as ae,Bone as le,InterpolateDiscrete as ce,InterpolateLinear as de,Texture as ue,VectorKeyframeTrack as he,NumberKeyframeTrack as me,QuaternionKeyframeTrack as pe,ColorManagement as fe,FrontSide as ge,Interpolant as Te,Box3 as ye,Sphere as be}from"three";const xe=r(()=>import("./model-viewer-Bh6JoFYA.mjs"));function ve({data:s,elementId:r,isEditorMode:o=!1}){/* @__PURE__ */
2
+ return e("div",{className:"configurator-3d-wrapper",style:{width:"100%",height:s.layout?.height||"600px",position:s.layout?.position||"relative",overflow:"hidden"},children:[
3
+ /* @__PURE__ */t(Re,{data:s}),
4
+ /* @__PURE__ */t(n,{fallback:/* @__PURE__ */t(we,{}),children:/* @__PURE__ */t(xe,{instanceId:r,data:s,isEditorMode:o})})]})}function Re({data:r}){/* @__PURE__ */
5
+ return e(s,{children:[
6
+ /* @__PURE__ */t("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify({"@context":"https://schema.org","@type":"3DModel",name:"3D Product Configurator",description:r.model?.description||"Interactive 3D model configurator",interactionType:"Interactive",technology:"WebGL",keywords:r.model?.keywords||[]})}}),
7
+ /* @__PURE__ */e("div",{className:"sr-only","aria-hidden":"true",children:[
8
+ /* @__PURE__ */t("h2",{children:"3D Product Configurator"}),
9
+ /* @__PURE__ */t("p",{children:r.model?.description||"Interactive 3D model configurator"}),r.model?.keywords&&/* @__PURE__ */t("meta",{name:"keywords",content:r.model.keywords.join(", ")})]})]})}function we(){/* @__PURE__ */
10
+ return e("div",{style:{width:"100%",height:"100%",background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",position:"absolute",top:0,left:0,color:"white"},role:"img","aria-label":"3D Model Loading",children:[
11
+ /* @__PURE__ */t("div",{style:{width:"60px",height:"60px",border:"6px solid rgba(255, 255, 255, 0.3)",borderTop:"6px solid white",borderRadius:"50%",animation:"spin 1s linear infinite"}}),
12
+ /* @__PURE__ */t("p",{style:{marginTop:"20px",fontSize:"14px"},children:"Loading 3D Model..."}),
13
+ /* @__PURE__ */t("style",{children:"\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n "})]})}const _e={id:"configurator-3d",name:"Configurator 3D",version:"0.0.2",category:"advanced",icon:o,component:ve,capabilities:{supportsChildren:!1,isRootComponent:!1,requiresParent:!0,childrenType:null,allowedChildPlugins:[],maxChildren:null,minChildren:0},ssr:!1,responsive:!0,properties:[{key:"model.url",label:"Model URL",type:"text",category:"content",default:"",ui:{control:"input",input:{placeholder:"https://example.com/model.glb"}}},{key:"model.scale",label:"Model Scale",type:"range",category:"style",default:1,ui:{control:"slider",slider:{min:.1,max:10,step:.1,showValue:!0}}},{key:"model.position",label:"Model Position",type:"text",category:"advanced",default:"0,0,0",ui:{control:"input",input:{placeholder:"x,y,z"}}},{key:"model.rotation",label:"Model Rotation",type:"text",category:"advanced",default:"0,0,0",ui:{control:"input",input:{placeholder:"x,y,z (radians)"}}},{key:"pois.enabled",label:"Enable POI Markers",type:"toggle",category:"content",default:!1,ui:{control:"toggle"}},{key:"camera.fov",label:"Camera FOV",type:"range",category:"advanced",default:50,ui:{control:"slider",slider:{min:20,max:120,step:1,showValue:!0}}},{key:"camera.enableOrbit",label:"Enable Orbit Controls",type:"toggle",category:"content",default:!0,ui:{control:"toggle"}},{key:"camera.enableZoom",label:"Enable Zoom",type:"toggle",category:"content",default:!0,ui:{control:"toggle"}},{key:"camera.enablePan",label:"Enable Pan",type:"toggle",category:"content",default:!0,ui:{control:"toggle"}},{key:"camera.near",label:"Camera Near Plane",type:"range",category:"advanced",default:.1,ui:{control:"slider",slider:{min:.01,max:10,step:.01,showValue:!0}}},{key:"camera.far",label:"Camera Far Plane",type:"range",category:"advanced",default:1e3,ui:{control:"slider",slider:{min:100,max:1e4,step:100,showValue:!0}}},{key:"lighting.ambientIntensity",label:"Ambient Light Intensity",type:"range",category:"style",default:.5,ui:{control:"slider",slider:{min:0,max:2,step:.1,showValue:!0}}},{key:"lighting.directionalIntensity",label:"Directional Light Intensity",type:"range",category:"style",default:1,ui:{control:"slider",slider:{min:0,max:3,step:.1,showValue:!0}}},{key:"lighting.directionalPosition",label:"Directional Light Position",type:"text",category:"style",default:"10,10,5",ui:{control:"input",input:{placeholder:"x,y,z"}}},{key:"lighting.enableShadows",label:"Enable Shadows",type:"toggle",category:"style",default:!0,ui:{control:"toggle"}},{key:"layout.height",label:"Container Height",type:"text",category:"layout",default:"600px",ui:{control:"input",input:{placeholder:"600px, 100vh, 50%"}}},{key:"layout.position",label:"Position Type",type:"select",category:"layout",default:"relative",ui:{control:"select",select:{options:[{value:"relative",label:"Relative"},{value:"absolute",label:"Absolute"},{value:"fixed",label:"Fixed"},{value:"sticky",label:"Sticky"}]}}},{key:"model.description",label:"Description (SEO)",type:"text",category:"advanced",default:"",ui:{control:"textarea",textarea:{rows:3,placeholder:"Description for search engines and accessibility"}}},{key:"model.keywords",label:"Keywords (SEO)",type:"text",category:"advanced",default:"",ui:{control:"input",input:{placeholder:"3D, product, configurator"}}}],defaults:{model:{url:"",scale:1,position:"0,0,0",rotation:"0,0,0",description:"Interactive 3D model configurator",keywords:"3D,configurator,interactive"},pois:{enabled:!1,markers:[]},camera:{fov:50,enableOrbit:!0,enableZoom:!0,enablePan:!0,near:.1,far:1e3,presets:[]},lighting:{ambientIntensity:.5,directionalIntensity:1,directionalPosition:"10,10,5",enableShadows:!0},layout:{height:"600px",position:"relative"}},locales:{en:{plugin:{name:"Configurator 3D",description:"Interactive 3D product configurator with GLTF models"},properties:{"model.url":{label:"Model URL",placeholder:"https://example.com/model.glb",description:"URL to 3D model (GLB/GLTF)"},"model.scale":{label:"Model Scale",description:"Model scaling factor"},"model.position":{label:"Model Position",placeholder:"x,y,z",description:"3D position of the model"},"model.rotation":{label:"Model Rotation",placeholder:"x,y,z (radians)",description:"3D rotation of the model"},"pois.enabled":{label:"Enable POI Markers",description:"Enable Point of Interest markers"},"camera.fov":{label:"Camera FOV",description:"Camera field of view"},"camera.enableOrbit":{label:"Enable Orbit Controls",description:"Enable camera orbit controls"},"camera.enableZoom":{label:"Enable Zoom",description:"Enable camera zoom"},"camera.enablePan":{label:"Enable Pan",description:"Enable camera panning"},"camera.near":{label:"Camera Near Plane",description:"Camera near plane distance"},"camera.far":{label:"Camera Far Plane",description:"Camera far plane distance"},"lighting.ambientIntensity":{label:"Ambient Light Intensity",description:"Ambient light intensity"}},categories:{content:"Content",style:"Style",layout:"Layout",advanced:"Advanced"}},de:{plugin:{name:"Konfigurator 3D",description:"Interaktiver 3D-Produkt-Konfigurator mit GLTF-Modellen"},properties:{"model.url":{label:"Modell-URL",placeholder:"https://example.com/model.glb",description:"URL zum 3D-Modell (GLB/GLTF)"},"model.scale":{label:"Modell-Skalierung",description:"Skalierungsfaktor des Modells"},"model.position":{label:"Modell-Position",placeholder:"x,y,z",description:"3D-Position des Modells"},"model.rotation":{label:"Modell-Rotation",placeholder:"x,y,z (radians)",description:"3D-Rotation des Modells"},"pois.enabled":{label:"POI-Marker aktivieren",description:"Point of Interest Marker aktivieren"},"camera.fov":{label:"Kamera-FOV",description:"Kamera-Sichtfeld (Field of View)"},"camera.enableOrbit":{label:"Orbit-Steuerung aktivieren",description:"Kamera-Orbit-Steuerung aktivieren"},"camera.enableZoom":{label:"Zoom aktivieren",description:"Kamera-Zoom aktivieren"},"camera.enablePan":{label:"Schwenken aktivieren",description:"Kamera-Schwenken aktivieren"},"camera.near":{label:"Kamera Nahebene",description:"Kamera Near Plane"},"camera.far":{label:"Kamera Fernebene",description:"Kamera Far Plane"},"lighting.ambientIntensity":{label:"Umgebungslicht-Intensität",description:"Intensität des Umgebungslichts"}},categories:{content:"Inhalt",style:"Stil",layout:"Layout",advanced:"Erweitert"}},fr:{plugin:{name:"Configurateur 3D",description:"Configurateur de produits 3D interactif avec modèles GLTF"},properties:{"model.url":{label:"URL du Modèle",placeholder:"https://example.com/model.glb",description:"URL vers le modèle 3D (GLB/GLTF)"},"model.scale":{label:"Échelle du Modèle",description:"Facteur d'échelle du modèle"},"model.position":{label:"Position du Modèle",placeholder:"x,y,z",description:"Position 3D du modèle"},"model.rotation":{label:"Rotation du Modèle",placeholder:"x,y,z (radians)",description:"Rotation 3D du modèle"},"pois.enabled":{label:"Activer Marqueurs POI",description:"Activer les marqueurs de Point d'Intérêt"},"camera.fov":{label:"FOV Caméra",description:"Champ de vision de la caméra"},"camera.enableOrbit":{label:"Activer Contrôles Orbital",description:"Activer les contrôles orbitaux de la caméra"},"camera.enableZoom":{label:"Activer Zoom",description:"Activer le zoom de la caméra"},"camera.enablePan":{label:"Activer Déplacement",description:"Activer le déplacement de la caméra"},"camera.near":{label:"Plan Proche Caméra",description:"Distance du plan proche"},"camera.far":{label:"Plan Lointain Caméra",description:"Distance du plan lointain"},"lighting.ambientIntensity":{label:"Intensité Lumière Ambiante",description:"Intensité de la lumière ambiante"}},categories:{content:"Contenu",style:"Style",layout:"Disposition",advanced:"Avancé"}},es:{plugin:{name:"Configurador 3D",description:"Configurador de productos 3D interactivo con modelos GLTF"},properties:{"model.url":{label:"URL del Modelo",placeholder:"https://example.com/model.glb",description:"URL al modelo 3D (GLB/GLTF)"},"model.scale":{label:"Escala del Modelo",description:"Factor de escala del modelo"},"model.position":{label:"Posición del Modelo",placeholder:"x,y,z",description:"Posición 3D del modelo"},"model.rotation":{label:"Rotación del Modelo",placeholder:"x,y,z (radianes)",description:"Rotación 3D del modelo"},"pois.enabled":{label:"Activar Marcadores POI",description:"Activar marcadores de Punto de Interés"},"camera.fov":{label:"FOV de Cámara",description:"Campo de visión de la cámara"},"camera.enableOrbit":{label:"Activar Controles Orbital",description:"Activar controles orbitales de cámara"},"camera.enableZoom":{label:"Activar Zoom",description:"Activar zoom de cámara"},"camera.enablePan":{label:"Activar Desplazamiento",description:"Activar desplazamiento de cámara"},"camera.near":{label:"Plano Cercano de Cámara",description:"Distancia del plano cercano"},"camera.far":{label:"Plano Lejano de Cámara",description:"Distancia del plano lejano"},"lighting.ambientIntensity":{label:"Intensidad Luz Ambiente",description:"Intensidad de la luz ambiente"}},categories:{content:"Contenido",style:"Estilo",layout:"Diseño",advanced:"Avanzado"}},it:{plugin:{name:"Configuratore 3D",description:"Configuratore prodotti 3D interattivo con modelli GLTF"},properties:{"model.url":{label:"URL del Modello",placeholder:"https://example.com/model.glb",description:"URL al modello 3D (GLB/GLTF)"},"model.scale":{label:"Scala del Modello",description:"Fattore di scala del modello"},"model.position":{label:"Posizione del Modello",placeholder:"x,y,z",description:"Posizione 3D del modello"},"model.rotation":{label:"Rotazione del Modello",placeholder:"x,y,z (radianti)",description:"Rotazione 3D del modello"},"pois.enabled":{label:"Attiva Marcatori POI",description:"Attiva marcatori Punto di Interesse"},"camera.fov":{label:"FOV Fotocamera",description:"Campo visivo della fotocamera"},"camera.enableOrbit":{label:"Attiva Controlli Orbitali",description:"Attiva controlli orbitali fotocamera"},"camera.enableZoom":{label:"Attiva Zoom",description:"Attiva zoom fotocamera"},"camera.enablePan":{label:"Attiva Spostamento",description:"Attiva spostamento fotocamera"},"camera.near":{label:"Piano Vicino Fotocamera",description:"Distanza piano vicino"},"camera.far":{label:"Piano Lontano Fotocamera",description:"Distanza piano lontano"},"lighting.ambientIntensity":{label:"Intensità Luce Ambiente",description:"Intensità della luce ambiente"}},categories:{content:"Contenuto",style:"Stile",layout:"Layout",advanced:"Avanzato"}}},meta:{description:"3D product configurator with GLTF models, material variants, POI markers, and camera presets",tags:["3d","configurator","gltf","poi","materials","threejs"]}};function Ae(e,t){if(t===l)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===c||t===d){let s=e.getIndex();if(null===s){const t=[],r=e.getAttribute("position");if(void 0===r)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),s=e.getIndex()}const r=s.count-2,n=[];if(t===c)for(let e=1;e<=r;e++)n.push(s.getX(0)),n.push(s.getX(e)),n.push(s.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(n.push(s.getX(e)),n.push(s.getX(e+1)),n.push(s.getX(e+2))):(n.push(s.getX(e+2)),n.push(s.getX(e+1)),n.push(s.getX(e)));n.length/3!==r&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=e.clone();return o.setIndex(n),o.clearGroups(),o}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e}class Ee extends u{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new Ce(e)}),this.register(function(e){return new ke(e)}),this.register(function(e){return new Ke(e)}),this.register(function(e){return new Be(e)}),this.register(function(e){return new Ve(e)}),this.register(function(e){return new Ne(e)}),this.register(function(e){return new De(e)}),this.register(function(e){return new He(e)}),this.register(function(e){return new Fe(e)}),this.register(function(e){return new Se(e)}),this.register(function(e){return new Ue(e)}),this.register(function(e){return new Oe(e)}),this.register(function(e){return new je(e)}),this.register(function(e){return new Ge(e)}),this.register(function(e){return new Ie(e)}),this.register(function(e){return new ze(e)}),this.register(function(e){return new Xe(e)})}load(e,t,s,r){const n=this;let o;if(""!==this.resourcePath)o=this.resourcePath;else if(""!==this.path){const t=h.extractUrlBase(e);o=h.resolveURL(t,this.path)}else o=h.extractUrlBase(e);this.manager.itemStart(e);const i=function(t){r?r(t):console.error(t),n.manager.itemError(e),n.manager.itemEnd(e)},a=new m(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(s){try{n.parse(s,o,function(s){t(s),n.manager.itemEnd(e)},i)}catch(r){i(r)}},s,i)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,r){let n;const o={},i={},a=new TextDecoder;if("string"==typeof e)n=JSON.parse(e);else if(e instanceof ArrayBuffer){if(a.decode(new Uint8Array(e,0,4))===qe){try{o[Me.KHR_BINARY_GLTF]=new Ye(e)}catch(c){return void(r&&r(c))}n=JSON.parse(o[Me.KHR_BINARY_GLTF].content)}else n=JSON.parse(a.decode(e))}else n=e;if(void 0===n.asset||n.asset.version[0]<2)return void(r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new Rt(n,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let d=0;d<this.pluginCallbacks.length;d++){const e=this.pluginCallbacks[d](l);e.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),i[e.name]=e,o[e.name]=!0}if(n.extensionsUsed)for(let d=0;d<n.extensionsUsed.length;++d){const e=n.extensionsUsed[d],t=n.extensionsRequired||[];switch(e){case Me.KHR_MATERIALS_UNLIT:o[e]=new Pe;break;case Me.KHR_DRACO_MESH_COMPRESSION:o[e]=new Je(n,this.dracoLoader);break;case Me.KHR_TEXTURE_TRANSFORM:o[e]=new $e;break;case Me.KHR_MESH_QUANTIZATION:o[e]=new Qe;break;default:t.indexOf(e)>=0&&void 0===i[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}l.setExtensions(o),l.setPlugins(i),l.parse(s,r)}parseAsync(e,t){const s=this;return new Promise(function(r,n){s.parse(e,t,r,n)})}}function Le(){let e={};return{get:function(t){return e[t]},add:function(t,s){e[t]=s},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const Me={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",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Ie{constructor(e){this.parser=e,this.name=Me.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,r=t.length;s<r;s++){const r=t[s];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let r=t.cache.get(s);if(r)return r;const n=t.json,o=((n.extensions&&n.extensions[this.name]||{}).lights||[])[e];let i;const a=new g(16777215);void 0!==o.color&&a.setRGB(o.color[0],o.color[1],o.color[2],T);const l=void 0!==o.range?o.range:0;switch(o.type){case"directional":i=new v(a),i.target.position.set(0,0,-1),i.add(i.target);break;case"point":i=new x(a),i.distance=l;break;case"spot":i=new b(a),i.distance=l,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,i.angle=o.spot.outerConeAngle,i.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,i.target.position.set(0,0,-1),i.add(i.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return i.position.set(0,0,0),gt(i,o),void 0!==o.intensity&&(i.intensity=o.intensity),i.name=t.createUniqueName(o.name||"light_"+e),r=Promise.resolve(i),t.cache.add(s,r),r}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,r=s.json.nodes[e],n=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===n?null:this._loadLight(n).then(function(e){return s._getNodeRef(t.cache,n,e)})}}class Pe{constructor(){this.name=Me.KHR_MATERIALS_UNLIT}getMaterialType(){return q}extendParams(e,t,s){const r=[];e.color=new g(1,1,1),e.opacity=1;const n=t.pbrMetallicRoughness;if(n){if(Array.isArray(n.baseColorFactor)){const t=n.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],T),e.opacity=t[3]}void 0!==n.baseColorTexture&&r.push(s.assignTexture(e,"map",n.baseColorTexture,y))}return Promise.all(r)}}class Se{constructor(e){this.parser=e,this.name=Me.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name].emissiveStrength;return void 0!==r&&(t.emissiveIntensity=r),Promise.resolve()}}class Ce{constructor(e){this.parser=e,this.name=Me.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?p:null}extendMaterialParams(e,t){const s=this.parser,r=s.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const n=[],o=r.extensions[this.name];if(void 0!==o.clearcoatFactor&&(t.clearcoat=o.clearcoatFactor),void 0!==o.clearcoatTexture&&n.push(s.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),void 0!==o.clearcoatRoughnessFactor&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),void 0!==o.clearcoatRoughnessTexture&&n.push(s.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),void 0!==o.clearcoatNormalTexture&&(n.push(s.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),void 0!==o.clearcoatNormalTexture.scale)){const e=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new f(e,e)}return Promise.all(n)}}class ke{constructor(e){this.parser=e,this.name=Me.KHR_MATERIALS_DISPERSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?p:null}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name];return t.dispersion=void 0!==r.dispersion?r.dispersion:0,Promise.resolve()}}class Oe{constructor(e){this.parser=e,this.name=Me.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?p:null}extendMaterialParams(e,t){const s=this.parser,r=s.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const n=[],o=r.extensions[this.name];return void 0!==o.iridescenceFactor&&(t.iridescence=o.iridescenceFactor),void 0!==o.iridescenceTexture&&n.push(s.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),void 0!==o.iridescenceIor&&(t.iridescenceIOR=o.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==o.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),void 0!==o.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),void 0!==o.iridescenceThicknessTexture&&n.push(s.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(n)}}class Ne{constructor(e){this.parser=e,this.name=Me.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?p:null}extendMaterialParams(e,t){const s=this.parser,r=s.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const n=[];t.sheenColor=new g(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=r.extensions[this.name];if(void 0!==o.sheenColorFactor){const e=o.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],T)}return void 0!==o.sheenRoughnessFactor&&(t.sheenRoughness=o.sheenRoughnessFactor),void 0!==o.sheenColorTexture&&n.push(s.assignTexture(t,"sheenColorMap",o.sheenColorTexture,y)),void 0!==o.sheenRoughnessTexture&&n.push(s.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(n)}}class De{constructor(e){this.parser=e,this.name=Me.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?p:null}extendMaterialParams(e,t){const s=this.parser,r=s.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const n=[],o=r.extensions[this.name];return void 0!==o.transmissionFactor&&(t.transmission=o.transmissionFactor),void 0!==o.transmissionTexture&&n.push(s.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(n)}}class He{constructor(e){this.parser=e,this.name=Me.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?p:null}extendMaterialParams(e,t){const s=this.parser,r=s.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const n=[],o=r.extensions[this.name];t.thickness=void 0!==o.thicknessFactor?o.thicknessFactor:0,void 0!==o.thicknessTexture&&n.push(s.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const i=o.attenuationColor||[1,1,1];return t.attenuationColor=(new g).setRGB(i[0],i[1],i[2],T),Promise.all(n)}}class Fe{constructor(e){this.parser=e,this.name=Me.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?p:null}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name];return t.ior=void 0!==r.ior?r.ior:1.5,Promise.resolve()}}class Ue{constructor(e){this.parser=e,this.name=Me.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?p:null}extendMaterialParams(e,t){const s=this.parser,r=s.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const n=[],o=r.extensions[this.name];t.specularIntensity=void 0!==o.specularFactor?o.specularFactor:1,void 0!==o.specularTexture&&n.push(s.assignTexture(t,"specularIntensityMap",o.specularTexture));const i=o.specularColorFactor||[1,1,1];return t.specularColor=(new g).setRGB(i[0],i[1],i[2],T),void 0!==o.specularColorTexture&&n.push(s.assignTexture(t,"specularColorMap",o.specularColorTexture,y)),Promise.all(n)}}class Ge{constructor(e){this.parser=e,this.name=Me.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?p:null}extendMaterialParams(e,t){const s=this.parser,r=s.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const n=[],o=r.extensions[this.name];return t.bumpScale=void 0!==o.bumpFactor?o.bumpFactor:1,void 0!==o.bumpTexture&&n.push(s.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(n)}}class je{constructor(e){this.parser=e,this.name=Me.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?p:null}extendMaterialParams(e,t){const s=this.parser,r=s.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const n=[],o=r.extensions[this.name];return void 0!==o.anisotropyStrength&&(t.anisotropy=o.anisotropyStrength),void 0!==o.anisotropyRotation&&(t.anisotropyRotation=o.anisotropyRotation),void 0!==o.anisotropyTexture&&n.push(s.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(n)}}class Ke{constructor(e){this.parser=e,this.name=Me.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,r=s.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const n=r.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,n.source,o)}}class Be{constructor(e){this.parser=e,this.name=Me.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,s=this.parser,r=s.json,n=r.textures[e];if(!n.extensions||!n.extensions[t])return null;const o=n.extensions[t],i=r.images[o.source];let a=s.textureLoader;if(i.uri){const e=s.options.manager.getHandler(i.uri);null!==e&&(a=e)}return s.loadTextureImage(e,o.source,a)}}class Ve{constructor(e){this.parser=e,this.name=Me.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,s=this.parser,r=s.json,n=r.textures[e];if(!n.extensions||!n.extensions[t])return null;const o=n.extensions[t],i=r.images[o.source];let a=s.textureLoader;if(i.uri){const e=s.options.manager.getHandler(i.uri);null!==e&&(a=e)}return s.loadTextureImage(e,o.source,a)}}class ze{constructor(e){this.name=Me.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const e=s.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(t){const s=e.byteOffset||0,r=e.byteLength||0,o=e.count,i=e.byteStride,a=new Uint8Array(t,s,r);return n.decodeGltfBufferAsync?n.decodeGltfBufferAsync(o,i,a,e.mode,e.filter).then(function(e){return e.buffer}):n.ready.then(function(){const t=new ArrayBuffer(o*i);return n.decodeGltfBuffer(new Uint8Array(t),o,i,a,e.mode,e.filter),t})})}return null}}class Xe{constructor(e){this.name=Me.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||void 0===s.mesh)return null;const r=t.meshes[s.mesh];for(const a of r.primitives)if(a.mode!==rt.TRIANGLES&&a.mode!==rt.TRIANGLE_STRIP&&a.mode!==rt.TRIANGLE_FAN&&void 0!==a.mode)return null;const n=s.extensions[this.name].attributes,o=[],i={};for(const a in n)o.push(this.parser.getDependency("accessor",n[a]).then(e=>(i[a]=e,i[a])));return o.length<1?null:(o.push(this.parser.createNodeMesh(e)),Promise.all(o).then(e=>{const t=e.pop(),s=t.isGroup?t.children:[t],r=e[0].count,n=[];for(const o of s){const e=new R,t=new w,s=new _,a=new w(1,1,1),l=new A(o.geometry,o.material,r);for(let n=0;n<r;n++)i.TRANSLATION&&t.fromBufferAttribute(i.TRANSLATION,n),i.ROTATION&&s.fromBufferAttribute(i.ROTATION,n),i.SCALE&&a.fromBufferAttribute(i.SCALE,n),l.setMatrixAt(n,e.compose(t,s,a));for(const r in i)if("_COLOR_0"===r){const e=i[r];l.instanceColor=new E(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==r&&"ROTATION"!==r&&"SCALE"!==r&&o.geometry.setAttribute(r,i[r]);L.prototype.copy.call(l,o),this.parser.assignFinalMaterial(l),n.push(l)}return t.isGroup?(t.clear(),t.add(...n),t):n[0]}))}}const qe="glTF",We=1313821514,Ze=5130562;class Ye{constructor(e){this.name=Me.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==qe)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-12,n=new DataView(e,12);let o=0;for(;o<r;){const t=n.getUint32(o,!0);o+=4;const r=n.getUint32(o,!0);if(o+=4,r===We){const r=new Uint8Array(e,12+o,t);this.content=s.decode(r)}else if(r===Ze){const s=12+o;this.body=e.slice(s,s+t)}o+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Je{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Me.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,r=this.dracoLoader,n=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,i={},a={},l={};for(const c in o){const e=lt[c]||c.toLowerCase();i[e]=o[c]}for(const c in e.attributes){const t=lt[c]||c.toLowerCase();if(void 0!==o[c]){const r=s.accessors[e.attributes[c]],n=nt[r.componentType];l[t]=n.name,a[t]=!0===r.normalized}}return t.getDependency("bufferView",n).then(function(e){return new Promise(function(t,s){r.decodeDracoFile(e,function(e){for(const t in e.attributes){const s=e.attributes[t],r=a[t];void 0!==r&&(s.normalized=r)}t(e)},i,l,T,s)})})}}class $e{constructor(){this.name=Me.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&t.texCoord!==e.channel||void 0!==t.offset||void 0!==t.rotation||void 0!==t.scale?(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0,e):e}}class Qe{constructor(){this.name=Me.KHR_MESH_QUANTIZATION}}class et extends Te{constructor(e,t,s,r){super(e,t,s,r)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,r=this.valueSize,n=e*r*3+r;for(let o=0;o!==r;o++)t[o]=s[n+o];return t}interpolate_(e,t,s,r){const n=this.resultBuffer,o=this.sampleValues,i=this.valueSize,a=2*i,l=3*i,c=r-t,d=(s-t)/c,u=d*d,h=u*d,m=e*l,p=m-l,f=-2*h+3*u,g=h-u,T=1-f,y=g-u+d;for(let b=0;b!==i;b++){const e=o[p+b+i],t=o[p+b+a]*c,s=o[m+b+i],r=o[m+b]*c;n[b]=T*e+y*t+f*s+g*r}return n}}const tt=new _;class st extends et{interpolate_(e,t,s,r){const n=super.interpolate_(e,t,s,r);return tt.fromArray(n).normalize().toArray(n),n}}const rt={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},nt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ot={9728:F,9729:H,9984:D,9985:N,9986:O,9987:k},it={33071:j,33648:G,10497:U},at={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},lt={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"},ct={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},dt={CUBICSPLINE:void 0,LINEAR:de,STEP:ce},ut="OPAQUE",ht="MASK",mt="BLEND";function pt(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new z({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:ge})),e.DefaultMaterial}function ft(e,t,s){for(const r in s.extensions)void 0===e[r]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=s.extensions[r])}function gt(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Tt(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let s=0,r=t.weights.length;s<r;s++)e.morphTargetInfluences[s]=t.weights[s];if(t.extras&&Array.isArray(t.extras.targetNames)){const s=t.extras.targetNames;if(e.morphTargetInfluences.length===s.length){e.morphTargetDictionary={};for(let t=0,r=s.length;t<r;t++)e.morphTargetDictionary[s[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function yt(e){let t;const s=e.extensions&&e.extensions[Me.KHR_DRACO_MESH_COMPRESSION];if(t=s?"draco:"+s.bufferView+":"+s.indices+":"+bt(s.attributes):e.indices+":"+bt(e.attributes)+":"+e.mode,void 0!==e.targets)for(let r=0,n=e.targets.length;r<n;r++)t+=":"+bt(e.targets[r]);return t}function bt(e){let t="";const s=Object.keys(e).sort();for(let r=0,n=s.length;r<n;r++)t+=s[r]+":"+e[s[r]]+";";return t}function xt(e){switch(e){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.")}}const vt=new R;class Rt{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Le,this.associations=/* @__PURE__ */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 s=!1,r=-1,n=!1,o=-1;if("undefined"!=typeof navigator){const e=navigator.userAgent;s=!0===/^((?!chrome|android).)*safari/i.test(e);const t=e.match(/Version\/(\d+)/);r=s&&t?parseInt(t[1],10):-1,n=e.indexOf("Firefox")>-1,o=n?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||s&&r<17||n&&o<98?this.textureLoader=new M(this.options.manager):this.textureLoader=new I(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new m(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,r=this.json,n=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(e){return e._markDefs&&e._markDefs()}),Promise.all(this._invokeAll(function(e){return e.beforeRoot&&e.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(t){const o={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:s,userData:{}};return ft(n,o,r),gt(o,r),Promise.all(s._invokeAll(function(e){return e.afterRoot&&e.afterRoot(o)})).then(function(){for(const e of o.scenes)e.updateMatrixWorld();e(o)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let r=0,n=t.length;r<n;r++){const s=t[r].joints;for(let t=0,r=s.length;t<r;t++)e[s[t]].isBone=!0}for(let r=0,n=e.length;r<n;r++){const t=e[r];void 0!==t.mesh&&(this._addNodeRef(this.meshCache,t.mesh),void 0!==t.skin&&(s[t.mesh].isSkinnedMesh=!0)),void 0!==t.camera&&this._addNodeRef(this.cameraCache,t.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const r=s.clone(),n=(e,t)=>{const s=this.associations.get(e);null!=s&&this.associations.set(t,s);for(const[r,o]of e.children.entries())n(o,t.children[r])};return n(s,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const r=e(t[s]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let r=0;r<t.length;r++){const n=e(t[r]);n&&s.push(n)}return s}getDependency(e,t){const s=e+":"+t;let r=this.cache.get(s);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case"mesh":r=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e)}this.cache.add(s,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,r=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(r.map(function(t,r){return s.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[Me.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(e,n){s.load(h.resolveURL(t.uri,r.path),e,void 0,function(){n(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(e){const s=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+s)})}loadAccessor(e){const t=this,s=this.json,r=this.json.accessors[e];if(void 0===r.bufferView&&void 0===r.sparse){const e=at[r.type],t=nt[r.componentType],s=!0===r.normalized,n=new t(r.count*e);return Promise.resolve(new P(n,e,s))}const n=[];return void 0!==r.bufferView?n.push(this.getDependency("bufferView",r.bufferView)):n.push(null),void 0!==r.sparse&&(n.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),n.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(n).then(function(e){const n=e[0],o=at[r.type],i=nt[r.componentType],a=i.BYTES_PER_ELEMENT,l=a*o,c=r.byteOffset||0,d=void 0!==r.bufferView?s.bufferViews[r.bufferView].byteStride:void 0,u=!0===r.normalized;let h,m;if(d&&d!==l){const e=Math.floor(c/d),s="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+e+":"+r.count;let l=t.cache.get(s);l||(h=new i(n,e*d,r.count*d/a),l=new S(h,d/a),t.cache.add(s,l)),m=new C(l,o,c%d/a,u)}else h=null===n?new i(r.count*o):new i(n,c,r.count*o),m=new P(h,o,u);if(void 0!==r.sparse){const t=at.SCALAR,s=nt[r.sparse.indices.componentType],a=r.sparse.indices.byteOffset||0,l=r.sparse.values.byteOffset||0,c=new s(e[1],a,r.sparse.count*t),d=new i(e[2],l,r.sparse.count*o);null!==n&&(m=new P(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let e=0,r=c.length;e<r;e++){const t=c[e];if(m.setX(t,d[e*o]),o>=2&&m.setY(t,d[e*o+1]),o>=3&&m.setZ(t,d[e*o+2]),o>=4&&m.setW(t,d[e*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=u}return m})}loadTexture(e){const t=this.json,s=this.options,r=t.textures[e].source,n=t.images[r];let o=this.textureLoader;if(n.uri){const e=s.manager.getHandler(n.uri);null!==e&&(o=e)}return this.loadTextureImage(e,r,o)}loadTextureImage(e,t,s){const r=this,n=this.json,o=n.textures[e],i=n.images[t],a=(i.uri||i.bufferView)+":"+o.sampler;if(this.textureCache[a])return this.textureCache[a];const l=this.loadImageSource(t,s).then(function(t){t.flipY=!1,t.name=o.name||i.name||"",""===t.name&&"string"==typeof i.uri&&!1===i.uri.startsWith("data:image/")&&(t.name=i.uri);const s=(n.samplers||{})[o.sampler]||{};return t.magFilter=ot[s.magFilter]||H,t.minFilter=ot[s.minFilter]||k,t.wrapS=it[s.wrapS]||U,t.wrapT=it[s.wrapT]||U,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==F&&t.minFilter!==H,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[a]=l,l}loadImageSource(e,t){const s=this,r=this.json,n=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());const o=r.images[e],i=self.URL||self.webkitURL;let a=o.uri||"",l=!1;if(void 0!==o.bufferView)a=s.getDependency("bufferView",o.bufferView).then(function(e){l=!0;const t=new Blob([e],{type:o.mimeType});return a=i.createObjectURL(t),a});else if(void 0===o.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(a).then(function(e){return new Promise(function(s,r){let o=s;!0===t.isImageBitmapLoader&&(o=function(e){const t=new ue(e);t.needsUpdate=!0,s(t)}),t.load(h.resolveURL(e,n.path),o,void 0,r)})}).then(function(e){var t;return!0===l&&i.revokeObjectURL(a),gt(e,o),e.userData.mimeType=o.mimeType||((t=o.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":t.search(/\.ktx2($|\?)/i)>0||0===t.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),e}).catch(function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e});return this.sourceCache[e]=c,c}assignTexture(e,t,s,r){const n=this;return this.getDependency("texture",s.index).then(function(o){if(!o)return null;if(void 0!==s.texCoord&&s.texCoord>0&&((o=o.clone()).channel=s.texCoord),n.extensions[Me.KHR_TEXTURE_TRANSFORM]){const e=void 0!==s.extensions?s.extensions[Me.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=n.associations.get(o);o=n.extensions[Me.KHR_TEXTURE_TRANSFORM].extendTexture(o,e),n.associations.set(o,t)}}return void 0!==r&&(o.colorSpace=r),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const r=void 0===t.attributes.tangent,n=void 0!==t.attributes.color,o=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new K,B.prototype.copy.call(t,s),t.color.copy(s.color),t.map=s.map,t.sizeAttenuation=!1,this.cache.add(e,t)),s=t}else if(e.isLine){const e="LineBasicMaterial:"+s.uuid;let t=this.cache.get(e);t||(t=new V,B.prototype.copy.call(t,s),t.color.copy(s.color),t.map=s.map,this.cache.add(e,t)),s=t}if(r||n||o){let e="ClonedMaterial:"+s.uuid+":";r&&(e+="derivative-tangents:"),n&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=s.clone(),n&&(t.vertexColors=!0),o&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(s))),s=t}e.material=s}getMaterialType(){return z}loadMaterial(e){const t=this,s=this.json,r=this.extensions,n=s.materials[e];let o;const i={},a=[];if((n.extensions||{})[Me.KHR_MATERIALS_UNLIT]){const e=r[Me.KHR_MATERIALS_UNLIT];o=e.getMaterialType(),a.push(e.extendParams(i,n,t))}else{const s=n.pbrMetallicRoughness||{};if(i.color=new g(1,1,1),i.opacity=1,Array.isArray(s.baseColorFactor)){const e=s.baseColorFactor;i.color.setRGB(e[0],e[1],e[2],T),i.opacity=e[3]}void 0!==s.baseColorTexture&&a.push(t.assignTexture(i,"map",s.baseColorTexture,y)),i.metalness=void 0!==s.metallicFactor?s.metallicFactor:1,i.roughness=void 0!==s.roughnessFactor?s.roughnessFactor:1,void 0!==s.metallicRoughnessTexture&&(a.push(t.assignTexture(i,"metalnessMap",s.metallicRoughnessTexture)),a.push(t.assignTexture(i,"roughnessMap",s.metallicRoughnessTexture))),o=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),a.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,i)})))}!0===n.doubleSided&&(i.side=X);const l=n.alphaMode||ut;if(l===mt?(i.transparent=!0,i.depthWrite=!1):(i.transparent=!1,l===ht&&(i.alphaTest=void 0!==n.alphaCutoff?n.alphaCutoff:.5)),void 0!==n.normalTexture&&o!==q&&(a.push(t.assignTexture(i,"normalMap",n.normalTexture)),i.normalScale=new f(1,1),void 0!==n.normalTexture.scale)){const e=n.normalTexture.scale;i.normalScale.set(e,e)}if(void 0!==n.occlusionTexture&&o!==q&&(a.push(t.assignTexture(i,"aoMap",n.occlusionTexture)),void 0!==n.occlusionTexture.strength&&(i.aoMapIntensity=n.occlusionTexture.strength)),void 0!==n.emissiveFactor&&o!==q){const e=n.emissiveFactor;i.emissive=(new g).setRGB(e[0],e[1],e[2],T)}return void 0!==n.emissiveTexture&&o!==q&&a.push(t.assignTexture(i,"emissiveMap",n.emissiveTexture,y)),Promise.all(a).then(function(){const s=new o(i);return n.name&&(s.name=n.name),gt(s,n),t.associations.set(s,{materials:e}),n.extensions&&ft(r,s,n),s})}createUniqueName(e){const t=W.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,r=this.primitiveCache;function n(e){return s[Me.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(s){return wt(s,e,t)})}const o=[];for(let i=0,a=e.length;i<a;i++){const s=e[i],a=yt(s),l=r[a];if(l)o.push(l.promise);else{let e;e=s.extensions&&s.extensions[Me.KHR_DRACO_MESH_COMPRESSION]?n(s):wt(new Z,s,t),r[a]={primitive:s,promise:e},o.push(e)}}return Promise.all(o)}loadMesh(e){const t=this,s=this.json,r=this.extensions,n=s.meshes[e],o=n.primitives,i=[];for(let a=0,l=o.length;a<l;a++){const e=void 0===o[a].material?pt(this.cache):this.getDependency("material",o[a].material);i.push(e)}return i.push(t.loadGeometries(o)),Promise.all(i).then(function(s){const i=s.slice(0,s.length-1),a=s[s.length-1],l=[];for(let h=0,m=a.length;h<m;h++){const s=a[h],u=o[h];let m;const p=i[h];if(u.mode===rt.TRIANGLES||u.mode===rt.TRIANGLE_STRIP||u.mode===rt.TRIANGLE_FAN||void 0===u.mode)m=!0===n.isSkinnedMesh?new Y(s,p):new J(s,p),!0===m.isSkinnedMesh&&m.normalizeSkinWeights(),u.mode===rt.TRIANGLE_STRIP?m.geometry=Ae(m.geometry,d):u.mode===rt.TRIANGLE_FAN&&(m.geometry=Ae(m.geometry,c));else if(u.mode===rt.LINES)m=new $(s,p);else if(u.mode===rt.LINE_STRIP)m=new Q(s,p);else if(u.mode===rt.LINE_LOOP)m=new ee(s,p);else{if(u.mode!==rt.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);m=new te(s,p)}Object.keys(m.geometry.morphAttributes).length>0&&Tt(m,n),m.name=t.createUniqueName(n.name||"mesh_"+e),gt(m,n),u.extensions&&ft(r,m,u),t.assignFinalMaterial(m),l.push(m)}for(let r=0,n=l.length;r<n;r++)t.associations.set(l[r],{meshes:e,primitives:r});if(1===l.length)return n.extensions&&ft(r,l[0],n),l[0];const u=new se;n.extensions&&ft(r,u,n),t.associations.set(u,{meshes:e});for(let e=0,t=l.length;e<t;e++)u.add(l[e]);return u})}loadCamera(e){let t;const s=this.json.cameras[e],r=s[s.type];if(r)return"perspective"===s.type?t=new re(ne.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===s.type&&(t=new oe(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),gt(t,s),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],s=[];for(let r=0,n=t.joints.length;r<n;r++)s.push(this._loadNodeShallow(t.joints[r]));return void 0!==t.inverseBindMatrices?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(e){const s=e.pop(),r=e,n=[],o=[];for(let i=0,a=r.length;i<a;i++){const e=r[i];if(e){n.push(e);const t=new R;null!==s&&t.fromArray(s.array,16*i),o.push(t)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[i])}return new ie(n,o)})}loadAnimation(e){const t=this.json,s=this,r=t.animations[e],n=r.name?r.name:"animation_"+e,o=[],i=[],a=[],l=[],c=[];for(let d=0,u=r.channels.length;d<u;d++){const e=r.channels[d],t=r.samplers[e.sampler],s=e.target,n=s.node,u=void 0!==r.parameters?r.parameters[t.input]:t.input,h=void 0!==r.parameters?r.parameters[t.output]:t.output;void 0!==s.node&&(o.push(this.getDependency("node",n)),i.push(this.getDependency("accessor",u)),a.push(this.getDependency("accessor",h)),l.push(t),c.push(s))}return Promise.all([Promise.all(o),Promise.all(i),Promise.all(a),Promise.all(l),Promise.all(c)]).then(function(e){const t=e[0],o=e[1],i=e[2],a=e[3],l=e[4],c=[];for(let r=0,n=t.length;r<n;r++){const e=t[r],n=o[r],d=i[r],u=a[r],h=l[r];if(void 0===e)continue;e.updateMatrix&&e.updateMatrix();const m=s._createAnimationTracks(e,n,d,u,h);if(m)for(let t=0;t<m.length;t++)c.push(m[t])}const d=new ae(n,void 0,c);return gt(d,r),d})}createNodeMesh(e){const t=this.json,s=this,r=t.nodes[e];return void 0===r.mesh?null:s.getDependency("mesh",r.mesh).then(function(e){const t=s._getNodeRef(s.meshCache,r.mesh,e);return void 0!==r.weights&&t.traverse(function(e){if(e.isMesh)for(let t=0,s=r.weights.length;t<s;t++)e.morphTargetInfluences[t]=r.weights[t]}),t})}loadNode(e){const t=this,s=this.json.nodes[e],r=t._loadNodeShallow(e),n=[],o=s.children||[];for(let a=0,l=o.length;a<l;a++)n.push(t.getDependency("node",o[a]));const i=void 0===s.skin?Promise.resolve(null):t.getDependency("skin",s.skin);return Promise.all([r,Promise.all(n),i]).then(function(e){const t=e[0],s=e[1],r=e[2];null!==r&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(r,vt)});for(let n=0,o=s.length;n<o;n++)t.add(s[n]);return t})}_loadNodeShallow(e){const t=this.json,s=this.extensions,r=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const n=t.nodes[e],o=n.name?r.createUniqueName(n.name):"",i=[],a=r._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return a&&i.push(a),void 0!==n.camera&&i.push(r.getDependency("camera",n.camera).then(function(e){return r._getNodeRef(r.cameraCache,n.camera,e)})),r._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){i.push(e)}),this.nodeCache[e]=Promise.all(i).then(function(t){let i;if(i=!0===n.isBone?new le:t.length>1?new se:1===t.length?t[0]:new L,i!==t[0])for(let e=0,s=t.length;e<s;e++)i.add(t[e]);if(n.name&&(i.userData.name=n.name,i.name=o),gt(i,n),n.extensions&&ft(s,i,n),void 0!==n.matrix){const e=new R;e.fromArray(n.matrix),i.applyMatrix4(e)}else void 0!==n.translation&&i.position.fromArray(n.translation),void 0!==n.rotation&&i.quaternion.fromArray(n.rotation),void 0!==n.scale&&i.scale.fromArray(n.scale);if(r.associations.has(i)){if(void 0!==n.mesh&&r.meshCache.refs[n.mesh]>1){const e=r.associations.get(i);r.associations.set(i,{...e})}}else r.associations.set(i,{});return r.associations.get(i).nodes=e,i}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],r=this,n=new se;s.name&&(n.name=r.createUniqueName(s.name)),gt(n,s),s.extensions&&ft(t,n,s);const o=s.nodes||[],i=[];for(let a=0,l=o.length;a<l;a++)i.push(r.getDependency("node",o[a]));return Promise.all(i).then(function(e){for(let t=0,s=e.length;t<s;t++)n.add(e[t]);return r.associations=(e=>{const t=/* @__PURE__ */new Map;for(const[s,n]of r.associations)(s instanceof B||s instanceof ue)&&t.set(s,n);return e.traverse(e=>{const s=r.associations.get(e);null!=s&&t.set(e,s)}),t})(n),n})}_createAnimationTracks(e,t,s,r,n){const o=[],i=e.name?e.name:e.uuid,a=[];let l;switch(ct[n.path]===ct.weights?e.traverse(function(e){e.morphTargetInfluences&&a.push(e.name?e.name:e.uuid)}):a.push(i),ct[n.path]){case ct.weights:l=me;break;case ct.rotation:l=pe;break;case ct.translation:case ct.scale:l=he;break;default:if(1===s.itemSize)l=me;else l=he}const c=void 0!==r.interpolation?dt[r.interpolation]:de,d=this._getArrayFromAccessor(s);for(let u=0,h=a.length;u<h;u++){const e=new l(a[u]+"."+ct[n.path],t.array,d,c);"CUBICSPLINE"===r.interpolation&&this._createCubicSplineTrackInterpolant(e),o.push(e)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=xt(t.constructor),s=new Float32Array(t.length);for(let r=0,n=t.length;r<n;r++)s[r]=t[r]*e;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof pe?st:et)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function wt(e,t,s){const r=t.attributes,n=[];function o(t,r){return s.getDependency("accessor",t).then(function(t){e.setAttribute(r,t)})}for(const i in r){const t=lt[i]||i.toLowerCase();t in e.attributes||n.push(o(r[i],t))}if(void 0!==t.indices&&!e.index){const r=s.getDependency("accessor",t.indices).then(function(t){e.setIndex(t)});n.push(r)}return fe.workingColorSpace!==T&&"COLOR_0"in r&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${fe.workingColorSpace}" not supported.`),gt(e,t),function(e,t,s){const r=t.attributes,n=new ye;if(void 0===r.POSITION)return;{const e=s.json.accessors[r.POSITION],t=e.min,o=e.max;if(void 0===t||void 0===o)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(n.set(new w(t[0],t[1],t[2]),new w(o[0],o[1],o[2])),e.normalized){const t=xt(nt[e.componentType]);n.min.multiplyScalar(t),n.max.multiplyScalar(t)}}const o=t.targets;if(void 0!==o){const e=new w,t=new w;for(let r=0,n=o.length;r<n;r++){const n=o[r];if(void 0!==n.POSITION){const r=s.json.accessors[n.POSITION],o=r.min,i=r.max;if(void 0!==o&&void 0!==i){if(t.setX(Math.max(Math.abs(o[0]),Math.abs(i[0]))),t.setY(Math.max(Math.abs(o[1]),Math.abs(i[1]))),t.setZ(Math.max(Math.abs(o[2]),Math.abs(i[2]))),r.normalized){const e=xt(nt[r.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(e)}e.boundingBox=n;const i=new be;n.getCenter(i.center),i.radius=n.min.distanceTo(n.max)/2,e.boundingSphere=i}(e,t,s),Promise.all(n).then(function(){return void 0!==t.targets?function(e,t,s){let r=!1,n=!1,o=!1;for(let c=0,d=t.length;c<d;c++){const e=t[c];if(void 0!==e.POSITION&&(r=!0),void 0!==e.NORMAL&&(n=!0),void 0!==e.COLOR_0&&(o=!0),r&&n&&o)break}if(!r&&!n&&!o)return Promise.resolve(e);const i=[],a=[],l=[];for(let c=0,d=t.length;c<d;c++){const d=t[c];if(r){const t=void 0!==d.POSITION?s.getDependency("accessor",d.POSITION):e.attributes.position;i.push(t)}if(n){const t=void 0!==d.NORMAL?s.getDependency("accessor",d.NORMAL):e.attributes.normal;a.push(t)}if(o){const t=void 0!==d.COLOR_0?s.getDependency("accessor",d.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(l)]).then(function(t){const s=t[0],i=t[1],a=t[2];return r&&(e.morphAttributes.position=s),n&&(e.morphAttributes.normal=i),o&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e})}(e,t.targets,s):e})}const _t=/* @__PURE__ */new WeakMap;class At extends u{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,s,r){const n=new m(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(e,e=>{this.parse(e,t,r)},s,r)}parse(e,t,s=()=>{}){this.decodeDracoFile(e,t,null,null,y,s).catch(s)}decodeDracoFile(e,t,s,r,n=T,o=()=>{}){const i={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!s,vertexColorSpace:n};return this.decodeGeometry(e,i).then(t).catch(o)}decodeGeometry(e,t){const s=JSON.stringify(t);if(_t.has(e)){const t=_t.get(e);if(t.key===s)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const n=this.workerNextTaskID++,o=e.byteLength,i=this._getWorker(n,o).then(s=>(r=s,new Promise((s,o)=>{r._callbacks[n]={resolve:s,reject:o},r.postMessage({type:"decode",id:n,taskConfig:t,buffer:e},[e])}))).then(e=>this._createGeometry(e.geometry));return i.catch(()=>!0).then(()=>{r&&n&&this._releaseTask(r,n)}),_t.set(e,{key:s,promise:i}),i}_createGeometry(e){const t=new Z;e.index&&t.setIndex(new P(e.index.array,1));for(let s=0;s<e.attributes.length;s++){const{name:r,array:n,itemSize:o,stride:i,vertexColorSpace:a}=e.attributes[s];let l;if(o===i)l=new P(n,o);else{const e=new S(n,i);l=new C(e,o,0)}"color"===r&&(this._assignVertexColorSpace(l,a),l.normalized=n instanceof Float32Array==!1),t.setAttribute(r,l)}return t}_assignVertexColorSpace(e,t){if(t!==y)return;const s=new g;for(let r=0,n=e.count;r<n;r++)s.fromBufferAttribute(e,r),fe.colorSpaceToWorking(s,y),e.setXYZ(r,s.r,s.g,s.b)}_loadLibrary(e,t){const s=new m(this.manager);return s.setPath(this.decoderPath),s.setResponseType(t),s.setWithCredentials(this.withCredentials),new Promise((t,r)=>{s.load(e,t,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(t=>{const s=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const r=Et.toString(),n=["/* draco decoder */",s,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([n]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const s=t.data;switch(s.type){case"decode":e._callbacks[s.id].resolve(s);break;case"error":e._callbacks[s.id].reject(s);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+s.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort(function(e,t){return e._taskLoad>t._taskLoad?-1:1});const s=this.workerPool[this.workerPool.length-1];return s._taskCosts[e]=t,s._taskLoad+=t,s})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,""!==this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}}function Et(){let e,t;function s(e,t,s,r,n,o){const i=s.num_points(),a=o.num_components(),l=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,n),c=a*n.BYTES_PER_ELEMENT,d=4*Math.ceil(c/4),u=d/n.BYTES_PER_ELEMENT,h=i*c,m=i*d,p=e._malloc(h);t.GetAttributeDataArrayForAllPoints(s,o,l,h,p);const f=new n(e.HEAPF32.buffer,p,h/n.BYTES_PER_ELEMENT);let g;if(c===d)g=f.slice();else{g=new n(m/n.BYTES_PER_ELEMENT);let e=0;for(let t=0,s=f.length;t<s;t++){for(let s=0;s<a;s++)g[e+s]=f[t*a+s];e+=u}}return e._free(p),{name:r,count:i,itemSize:a,array:g,stride:u}}onmessage=function(r){const n=r.data;switch(n.type){case"init":e=n.decoderConfig,t=new Promise(function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)});break;case"decode":const r=n.buffer,o=n.taskConfig;t.then(e=>{const t=e.draco,i=new t.Decoder;try{const e=function(e,t,r,n){const o=n.attributeIDs,i=n.attributeTypes;let a,l;const c=t.GetEncodedGeometryType(r);if(c===e.TRIANGULAR_MESH)a=new e.Mesh,l=t.DecodeArrayToMesh(r,r.byteLength,a);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new e.PointCloud,l=t.DecodeArrayToPointCloud(r,r.byteLength,a)}if(!l.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const d={index:null,attributes:[]};for(const u in o){const r=self[i[u]];let l,c;if(n.useUniqueIDs)c=o[u],l=t.GetAttributeByUniqueId(a,c);else{if(c=t.GetAttributeId(a,e[o[u]]),-1===c)continue;l=t.GetAttribute(a,c)}const h=s(e,t,a,u,r,l);"color"===u&&(h.vertexColorSpace=n.vertexColorSpace),d.attributes.push(h)}c===e.TRIANGULAR_MESH&&(d.index=function(e,t,s){const r=s.num_faces(),n=3*r,o=4*n,i=e._malloc(o);t.GetTrianglesUInt32Array(s,o,i);const a=new Uint32Array(e.HEAPF32.buffer,i,n).slice();return e._free(i),{array:a,itemSize:1}}(e,t,a));return e.destroy(a),d}(t,i,new Int8Array(r),o),a=e.attributes.map(e=>e.array.buffer);e.index&&a.push(e.index.array.buffer),self.postMessage({type:"decode",id:n.id,geometry:e},a)}catch(a){console.error(a),self.postMessage({type:"error",id:n.id,error:a.message})}finally{t.destroy(i)}})}}}function Lt(e){return i()((t,s)=>({instanceId:e,gltf:null,fallbackGeometry:"box",isLoading:!1,loadingProgress:0,error:null,isReady:!0,pois:[],activePOI:null,materialVariants:[],activeMaterialVariant:null,cameraPresets:[],activeCameraPreset:null,cameraTarget:void 0,cameraDistance:void 0,setFallbackGeometry:e=>{t({fallbackGeometry:e})},loadModel:async(e,s)=>{t({isLoading:!0,error:null,loadingProgress:0});try{const r=new Ee,n=new At;n.setDecoderPath("/draco/"),r.setDRACOLoader(n);const o=await new Promise((n,o)=>{r.load(e,e=>n(e),e=>{if(e.lengthComputable){const r=e.loaded/e.total*100;t({loadingProgress:r}),s?.(r)}},e=>o(e))});return o.scene.traverse(e=>{e instanceof a.Mesh&&(e.castShadow=!0,e.receiveShadow=!0)}),t({gltf:o,isLoading:!1,isReady:!0,loadingProgress:100}),o}catch(r){throw t({error:r instanceof Error?r.message:"Failed to load model",isLoading:!1,isReady:!1}),r}},addPOI:e=>{const s=`poi-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,r={...e,id:s};return t(e=>({pois:[...e.pois,r]})),s},updatePOI:(e,s)=>{t(t=>({pois:t.pois.map(t=>t.id===e?{...t,...s}:t)}))},removePOI:e=>{t(t=>({pois:t.pois.filter(t=>t.id!==e),activePOI:t.activePOI===e?null:t.activePOI}))},setActivePOI:e=>{t({activePOI:e})},setMaterialVariant:e=>{const{gltf:r,materialVariants:n}=s();if(!r)return;const o=n.find(t=>t.id===e);o&&(r.scene.traverse(e=>{if(e instanceof a.Mesh&&e.material){const t=e.material;if(t.name===o.materialName||!o.materialName){if(o.properties.color&&(t.color=new a.Color(o.properties.color)),void 0!==o.properties.metalness&&(t.metalness=o.properties.metalness),void 0!==o.properties.roughness&&(t.roughness=o.properties.roughness),o.properties.emissive&&(t.emissive=new a.Color(o.properties.emissive)),void 0!==o.properties.emissiveIntensity&&(t.emissiveIntensity=o.properties.emissiveIntensity),o.properties.map){(new a.TextureLoader).load(o.properties.map,e=>{t.map=e,t.needsUpdate=!0})}t.needsUpdate=!0}}}),t({activeMaterialVariant:e}))},addMaterialVariant:e=>{t(t=>({materialVariants:[...t.materialVariants,e]}))},setCameraPreset:e=>{t({activeCameraPreset:e})},addCameraPreset:e=>{t(t=>({cameraPresets:[...t.cameraPresets,e]}))},dispose:()=>{const{gltf:e}=s();e&&e.scene.traverse(e=>{if(e instanceof a.Mesh){e.geometry?.dispose();(Array.isArray(e.material)?e.material:[e.material]).forEach(e=>{e&&(e.map&&e.map.dispose(),e.lightMap&&e.lightMap.dispose(),e.bumpMap&&e.bumpMap.dispose(),e.normalMap&&e.normalMap.dispose(),e.specularMap&&e.specularMap.dispose(),e.envMap&&e.envMap.dispose(),e.aoMap&&e.aoMap.dispose(),e.emissiveMap&&e.emissiveMap.dispose(),e.metalnessMap&&e.metalnessMap.dispose(),e.roughnessMap&&e.roughnessMap.dispose(),e.dispose())})}}),t({gltf:null,isReady:!1,isLoading:!1,loadingProgress:0,error:null,pois:[],activePOI:null,materialVariants:[],activeMaterialVariant:null,cameraPresets:[],activeCameraPreset:null,cameraTarget:void 0,cameraDistance:void 0})}}))}export{ve as Configurator3DComponent,_e as configurator3DConfig,Lt as createConfiguratorInstance};
14
+ //# sourceMappingURL=index.mjs.map