1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[20947],{947(e,t,r){let s,n,i,a;r.d(t,{A:()=>Z});var o=r(9451),l=r(4808),u=r(5349),c=Object.defineProperty,p=(e,t,r)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,h=(e,t,r)=>p(e,"symbol"!=typeof t?t+"":t,r);function m(e,t=1/0,r=null){n||(n=new o.bdM(2,2,1,1)),i||(i=new o.BKk({uniforms:{blitTexture:new o.nc$(e)},vertexShader:` 2 varying vec2 vUv; 3 void main(){ 4 vUv = uv; 5 gl_Position = vec4(position.xy * 1.0,0.,.999999); 6 }`,fragmentShader:` 7 uniform sampler2D blitTexture; 8 varying vec2 vUv; 9 10 void main(){ 11 gl_FragColor = vec4(vUv.xy, 0, 1); 12 13 #ifdef IS_SRGB 14 gl_FragColor = LinearTosRGB( texture2D( blitTexture, vUv) ); 15 #else 16 gl_FragColor = texture2D( blitTexture, vUv); 17 #endif 18 }`})),i.uniforms.blitTexture.value=e,i.defines.IS_SRGB=e.colorSpace==o.er$,i.needsUpdate=!0,a||((a=new o.eaF(n,i)).frustumCulled=!1);let l=new o.ubm,u=new o.Z58;u.add(a),null===r&&(r=s=new o.JeP({antialias:!1}));let c=Math.min(e.image.width,t),p=Math.min(e.image.height,t);r.setSize(c,p),r.clear(),r.render(u,l);let h=document.createElement("canvas"),f=h.getContext("2d");h.width=c,h.height=p,f.drawImage(r.domElement,0,0,c,p);let d=new o.GOR(h);return d.minFilter=e.minFilter,d.magFilter=e.magFilter,d.wrapS=e.wrapS,d.wrapT=e.wrapT,d.name=e.name,s&&(s.forceContextLoss(),s.dispose(),s=null),d}let f={POSITION:["byte","byte normalized","unsigned byte","unsigned byte normalized","short","short normalized","unsigned short","unsigned short normalized"],NORMAL:["byte normalized","short normalized"],TANGENT:["byte normalized","short normalized"],TEXCOORD:["byte","byte normalized","unsigned byte","short","short normalized","unsigned short"]};class d{constructor(){this.pluginCallbacks=[],this.register(function(e){return new _(e)}),this.register(function(e){return new v(e)}),this.register(function(e){return new C(e)}),this.register(function(e){return new L(e)}),this.register(function(e){return new U(e)}),this.register(function(e){return new k(e)}),this.register(function(e){return new S(e)}),this.register(function(e){return new N(e)}),this.register(function(e){return new O(e)}),this.register(function(e){return new $(e)}),this.register(function(e){return new F(e)}),this.register(function(e){return new P(e)}),this.register(function(e){return new D(e)})}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,r,s){let n=new I,i=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)i.push(this.pluginCallbacks[e](n));n.setPlugins(i),n.write(e,t,s).catch(r)}parseAsync(e,t){let r=this;return new Promise(function(s,n){r.parse(e,s,n,t)})}}let g={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},x="KHR_mesh_quantization",T={};T[o.hxR]=g.NEAREST,T[o.pHI]=g.NEAREST_MIPMAP_NEAREST,T[o.Cfg]=g.NEAREST_MIPMAP_LINEAR,T[o.k6q]=g.LINEAR,T[o.kRr]=g.LINEAR_MIPMAP_NEAREST,T[o.$_I]=g.LINEAR_MIPMAP_LINEAR,T[o.ghU]=g.CLAMP_TO_EDGE,T[o.GJx]=g.REPEAT,T[o.kTW]=g.MIRRORED_REPEAT;let y={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},M=new o.Q1f;function w(e,t){return e.length===t.length&&e.every(function(e,r){return e===t[r]})}function b(e){return 4*Math.ceil(e/4)}function E(e,t=0){let r=b(e.byteLength);if(r!==e.byteLength){let s=new Uint8Array(r);if(s.set(new Uint8Array(e)),0!==t)for(let n=e.byteLength;n<r;n++)s[n]=t;return s.buffer}return e}function A(){return typeof document>"u"&&"u">typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas")}function R(e,t){let r;return void 0!==e.toBlob?new Promise(r=>e.toBlob(r,t)):("image/jpeg"===t?r=.92:"image/webp"===t&&(r=.8),e.convertToBlob({type:t,quality:r}))}class I{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,r={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},r),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);let s=this.buffers,n=this.json;r=this.options;let i=this.extensionsUsed,a=this.extensionsRequired,o=new Blob(s,{type:"application/octet-stream"}),l=Object.keys(i),u=Object.keys(a);if(l.length>0&&(n.extensionsUsed=l),u.length>0&&(n.extensionsRequired=u),n.buffers&&n.buffers.length>0&&(n.buffers[0].byteLength=o.size),!0===r.binary){let e=new FileReader;e.readAsArrayBuffer(o),e.onloadend=function(){var r;let s=E(e.result),i=new DataView(new ArrayBuffer(8));i.setUint32(0,s.byteLength,!0),i.setUint32(4,5130562,!0);let a=E((r=JSON.stringify(n),new TextEncoder().encode(r).buffer),32),o=new DataView(new ArrayBuffer(8));o.setUint32(0,a.byteLength,!0),o.setUint32(4,0x4e4f534a,!0);let l=new ArrayBuffer(12),u=new DataView(l);u.setUint32(0,0x46546c67,!0),u.setUint32(4,2,!0);let c=12+o.byteLength+a.byteLength+i.byteLength+s.byteLength;u.setUint32(8,c,!0);let p=new Blob([l,o,a,i,s],{type:"application/octet-stream"}),h=new FileReader;h.readAsArrayBuffer(p),h.onloadend=function(){t(h.result)}}}else if(n.buffers&&n.buffers.length>0){let e=new FileReader;
18e.readAsDataURL(o),e.onloadend=function(){let r=e.result;n.buffers[0].uri=r,t(n)}}else t(n)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;let r=this.options,s=this.extensionsUsed;try{let n=JSON.parse(JSON.stringify(e.userData));if(r.includeCustomExtensions&&n.gltfExtensions){for(let e in void 0===t.extensions&&(t.extensions={}),n.gltfExtensions)t.extensions[e]=n.gltfExtensions[e],s[e]=!0;delete n.gltfExtensions}Object.keys(n).length>0&&(t.extras=n)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e,t=!1){if(!1===this.uids.has(e)){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let t=new o.Pq0;for(let r=0,s=e.count;r<s;r++)if(Math.abs(t.fromBufferAttribute(e,r).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);let r=e.clone(),s=new o.Pq0;for(let e=0,t=r.count;e<t;e++)s.fromBufferAttribute(r,e),0===s.x&&0===s.y&&0===s.z?s.setX(1):s.normalize(),r.setXYZ(e,s.x,s.y,s.z);return t.attributesNormalized.set(e,r),r}applyTextureTransform(e,t){let r=!1,s={};(0!==t.offset.x||0!==t.offset.y)&&(s.offset=t.offset.toArray(),r=!0),0!==t.rotation&&(s.rotation=t.rotation,r=!0),(1!==t.repeat.x||1!==t.repeat.y)&&(s.scale=t.repeat.toArray(),r=!0),r&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=s,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function r(e){return e.colorSpace===o.er$?function(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}:function(e){return e}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof o.FvD&&(e=m(e)),t instanceof o.FvD&&(t=m(t));let s=e?e.image:null,n=t?t.image:null,i=Math.max(s?s.width:0,n?n.width:0),a=Math.max(s?s.height:0,n?n.height:0),l=A();l.width=i,l.height=a;let u=l.getContext("2d");u.fillStyle="#00ffff",u.fillRect(0,0,i,a);let c=u.getImageData(0,0,i,a);if(s){u.drawImage(s,0,0,i,a);let t=r(e),n=u.getImageData(0,0,i,a).data;for(let e=2;e<n.length;e+=4)c.data[e]=256*t(n[e]/256)}if(n){u.drawImage(n,0,0,i,a);let e=r(t),s=u.getImageData(0,0,i,a).data;for(let t=1;t<s.length;t+=4)c.data[t]=256*e(s[t]/256)}u.putImageData(c,0,0);let p=(e||t).clone();return p.source=new o.kLi(l),p.colorSpace=o.jf0,p.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),p}processBuffer(e){let t=this.json,r=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),r.push(e),0}processBufferView(e,t,r,s,n){let i;let a=this.json;switch(a.bufferViews||(a.bufferViews=[]),t){case g.BYTE:case g.UNSIGNED_BYTE:i=1;break;case g.SHORT:case g.UNSIGNED_SHORT:i=2;break;default:i=4}let l=e.itemSize*i;n===g.ARRAY_BUFFER&&(l=4*Math.ceil(l/4));let u=b(s*l),c=new DataView(new ArrayBuffer(u)),p=0;for(let n=r;n<r+s;n++){for(let r=0;r<e.itemSize;r++){let s;e.itemSize>4?s=e.array[n*e.itemSize+r]:(0===r?s=e.getX(n):1===r?s=e.getY(n):2===r?s=e.getZ(n):3===r&&(s=e.getW(n)),!0===e.normalized&&(s=o.cj9.normalize(s,e.array))),t===g.FLOAT?c.setFloat32(p,s,!0):t===g.INT?c.setInt32(p,s,!0):t===g.UNSIGNED_INT?c.setUint32(p,s,!0):t===g.SHORT?c.setInt16(p,s,!0):t===g.UNSIGNED_SHORT?c.setUint16(p,s,!0):t===g.BYTE?c.setInt8(p,s):t===g.UNSIGNED_BYTE&&c.setUint8(p,s),p+=i}p%l!=0&&(p+=l-p%l)}let h={buffer:this.processBuffer(c.buffer),byteOffset:this.byteOffset,byteLength:u};return void 0!==n&&(h.target=n),n===g.ARRAY_BUFFER&&(h.byteStride=l),this.byteOffset+=u,a.bufferViews.push(h),{id:a.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,r=t.json;return r.bufferViews||(r.bufferViews=[]),new Promise(function(s){let n=new FileReader;n.readAsArrayBuffer(e),n.onloadend=function(){let e=E(n.result),i={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,s(r.bufferViews.push(i)-1)}})}processAccessor(e,t,r,s){let n,i;let a=this.json;if(e.array.constructor===Float32Array)n=g.FLOAT;else if(e.array.constructor===Int32Array)n=g.INT;else if(e.array.constructor===Uint32Array)n=g.UNSIGNED_INT;else if(e.array.constructor===Int16Array)n=g.SHORT;else if(e.array.constructor===Uint16Array)n=g.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)n=g.BYTE;else if(e.array.constructor===Uint8Array)n=g.UNSIGNED_BYTE;else throw Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(void 0===r&&(r=0),(void 0===s||s===1/0)&&(s=e.count),0===s)return null;let l=function(e,t,r){let s={min:Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let n=t;n<t+r;n++)for(let t=0;t<e.itemSize;t++){let r;e.itemSize>4?r=e.array[n*e.itemSize+t]:(0===t?r=e.getX(n):1===t?r=e.getY(n):2===t?r=e.getZ(n):3===t&&(r=e.getW(n)),!0===e.normalized&&(r=o.cj9.normalize(r,e.array))),s.min[t]=Math.min(s.min[t],r),s.max[t]=Math.max(s.max[t],r)}return s}(e,r,s);void 0!==t&&(i=e===t.index?g.ELEMENT_ARRAY_BUFFER:g.ARRAY_BUFFER);let u=this.processBufferView(e,n,r,s,i),c={bufferView:u.id,byteOffset:u.byteOffset,componentType:n,count:s,max:l.max,min:l.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(c.normalized=!0),a.accessors||(a.accessors=[]),a.accessors.push(c)-1}processImage(e,t,r,s="image/png"){if(null!==e){let n=this,i=n.cache,a=n.json,l=n.options,u=n.pending;i.images.has(e)||i.images.set(e,{});let c=i.images.get(e),p=s+":flipY/"+r.toString();if(void 0!==c[p])return c[p];a.images||(a.images=[]);let h={mimeType:s},m=A();m.width=Math.min(e.width,l.maxTextureSize),m.height=Math.min(e.height,l.maxTextureSize);let f=m.getContext("2d");if(!0===r&&(f.translate(0,m.height),f.scale(1,-1)),void 0!==e.data){t!==o.GWd&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>l.maxTextureSize||e.height>
18l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let r=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<r.length;t+=4)r[t+0]=e.data[t+0],r[t+1]=e.data[t+1],r[t+2]=e.data[t+2],r[t+3]=e.data[t+3];f.putImageData(new ImageData(r,e.width,e.height),0,0)}else if("u">typeof HTMLImageElement&&e instanceof HTMLImageElement||"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"u">typeof ImageBitmap&&e instanceof ImageBitmap||"u">typeof OffscreenCanvas&&e instanceof OffscreenCanvas)f.drawImage(e,0,0,m.width,m.height);else throw Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");!0===l.binary?u.push(R(m,s).then(e=>n.processBufferViewImage(e)).then(e=>{h.bufferView=e})):void 0!==m.toDataURL?h.uri=m.toDataURL(s):u.push(R(m,s).then(e=>new FileReader().readAsDataURL(e)).then(e=>{h.uri=e}));let d=a.images.push(h)-1;return c[p]=d,d}throw Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let t=this.json;t.samplers||(t.samplers=[]);let r={magFilter:T[e.magFilter],minFilter:T[e.minFilter],wrapS:T[e.wrapS],wrapT:T[e.wrapT]};return t.samplers.push(r)-1}processTexture(e){let t=this.options,r=this.cache,s=this.json;if(r.textures.has(e))return r.textures.get(e);s.textures||(s.textures=[]),e instanceof o.FvD&&(e=m(e,t.maxTextureSize));let n=e.userData.mimeType;"image/webp"===n&&(n="image/png");let i={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,n)};e.name&&(i.name=e.name),this._invokeAll(function(t){t.writeTexture&&t.writeTexture(e,i)});let a=s.textures.push(i)-1;return r.textures.set(e,a),a}processMaterial(e){let t=this.cache,r=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;r.materials||(r.materials=[]);let s={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let n=e.color.toArray().concat([e.opacity]);if(w(n,[1,1,1,1])||(s.pbrMetallicRoughness.baseColorFactor=n),e.isMeshStandardMaterial?(s.pbrMetallicRoughness.metallicFactor=e.metalness,s.pbrMetallicRoughness.roughnessFactor=e.roughness):(s.pbrMetallicRoughness.metallicFactor=.5,s.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){let t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),r
18={index:this.processTexture(t),channel:t.channel};this.applyTextureTransform(r,t),s.pbrMetallicRoughness.metallicRoughnessTexture=r}if(e.map){let t={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),s.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(s.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let t={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),s.emissiveTexture=t}}if(e.normalMap){let t={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),s.normalTexture=t}if(e.aoMap){let t={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),s.occlusionTexture=t}e.transparent?s.alphaMode="BLEND":e.alphaTest>0&&(s.alphaMode="MASK",s.alphaCutoff=e.alphaTest),e.side===o.$EB&&(s.doubleSided=!0),""!==e.name&&(s.name=e.name),this.serializeUserData(e,s),this._invokeAll(function(t){t.writeMaterial&&t.writeMaterial(e,s)});let i=r.materials.push(s)-1;return t.materials.set(e,i),i}processMesh(e){let t;let r=this.cache,s=this.json,n=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,r=e.material.length;t<r;t++)n.push(e.material[t].uuid);else n.push(e.material.uuid);let i=n.join(":");if(r.meshes.has(i))return r.meshes.get(i);let a=e.geometry;t=e.isLineSegments?g.LINES:e.isLineLoop?g.LINE_LOOP:e.isLine?g.LINE_STRIP:e.isPoints?g.POINTS:e.material.wireframe?g.LINES:g.TRIANGLES;let l={},u={},c=[],p=[],h={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},m=a.getAttribute("normal");void 0===m||this.isNormalizedNormalAttribute(m)||(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),a.setAttribute("normal",this.createNormalizedNormalAttribute(m)));let f=null;for(let e in a.attributes){if("morph"===e.slice(0,5))continue;let t=a.attributes[e];if(e=h[e]||e.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(e)||(e="_"+e),r.attributes.has(this.getUID(t))){u[e]=r.attributes.get(this.getUID(t));continue}f=null;let s=t.array;"JOINTS_0"!==e||s instanceof Uint16Array||s instanceof Uint8Array||(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),f=new o.THS(new Uint16Array(s),t.itemSize,t.normalized));let n=this.processAccessor(f||t,a);null!==n&&(e.startsWith("_")||this.detectMeshQuantization(e,t),u[e]=n,r.attributes.set(this.getUID(t),n))}if(void 0!==m&&a.setAttribute("normal",m),0===Object.keys(u).length)return null;if(void 0!==e.morphTargetInfluences&&e.morphTargetInfluences.length>0){let t=[],s=[],n={};if(void 0!==e.morphTargetDictionary)for(let t in e.morphTargetDictionary)n[e.morphTargetDictionary[t]]=t;for(let i=0;i<e.morphTargetInfluences.length;++i){let o={},l=!1;for(let e in a.morphAttributes){if("position"!==e&&"normal"!==e){l||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),l=!0);continue}let t=a.morphAttributes[e][i],s=e.toUpperCase(),n=a.attributes[e];if(r.attributes.has(this.getUID(t,!0))){o[s]=r.attributes.get(this.getUID(t,!0));continue}let u=t.clone();if(!a.morphTargetsRelative)for(let e=0,r=t.count;e<r;e++)for(let r=0;r<t.itemSize;r++)0===r&&u.setX(e,t.getX(e)-n.getX(e)),1===r&&u.setY(e,t.getY(e)-n.getY(e)),2===r&&u.setZ(e,t.getZ(e)-n.getZ(e)),3===r&&u.setW(e,t.getW(e)-n.getW(e));o[s]=this.processAccessor(u,a),r.attributes.set(this.getUID(n,!0),o[s])}p.push(o),t.push(e.morphTargetInfluences[i]),void 0!==e.morphTargetDictionary&&s.push(n[i])}l.weights=t,s.length>0&&(l.extras={},l.extras.targetNames=s)}let d=Array.isArray(e.material);if(d&&0===a.groups.length)return null;let x=!1;if(d&&null===a.index){let e=[];for(let t=0,r=a.attributes.position.count;t<r;t++)e[t]=t;a.setIndex(e),x=!0}let T=d?e.material:[e.material],y=d?a.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,s=y.length;e<s;e++){let s={mode:t,attributes:u};if(this.serializeUserData(a,s),p.length>0&&(s.targets=p),null!==a.index){let t=this.getUID(a.index);(void 0!==y[e].start||void 0!==y[e].count)&&(t+=":"+y[e].start+":"+y[e].count),r.attributes.has(t)?s.indices=r.attributes.get(t):(s.indices=this.processAccessor(a.index,a,y[e].start,y[e].count),r.attributes.set(t,s.indices)),null===s.indices&&delete s.indices}let n=this.processMaterial(T[y[e].materialIndex]);null!==n&&(s.material=n),c.push(s)}!0===x&&a.setIndex(null),l.primitives=c,s.meshes||(s.meshes=[]),this._invokeAll(function(t){t.writeMesh&&t.writeMesh(e,l)});let M=s.meshes.push(l)-1;return r.meshes.set(i,M),M}detectMeshQuantization(e,t){let r;if(this.extensionsUsed[x])return;switch(t.array.constructor){case Int8Array:r="byte";break;case Uint8Array:r="unsigned byte";break;case Int16Array:r="short";break;case Uint16Array:r="unsigned short";break;default:return}t.normalized&&(r+=" normalized");let s=e.split("_",1)[0];f[s]&&f[s].includes(r)&&(this.extensionsUsed[x]=!0,this.extensionsRequired[x]=!0)}processCamera(e){let t=this.json;t.cameras||(t.cameras=[]);let r=e.isOrthographicCamera,s={type:r?"orthographic":"perspective"};return r?s.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:s.perspective={aspectRatio:e.aspect,yfov:o.cj9.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(s.name=e.type),t.cameras.push(s)-1}processAnimation(e,t){let r=this.json,s=this.nodeMap;r.animations||(r.animations=[]);let n=(e=d.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,i=[],a=[];for(let e=0;e<n.length;++e){let r;let l=n[e],u=o.Nwf.parseTrackName(l.name),c=o.Nwf.findNode(t,u.nodeName),p=y[u.propertyName];if("bones"===u.objectName&&(c=!0===c.isSkinnedMesh?c.skeleton.getBoneByName(u.objectIndex):void 0),!c||!p)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',l.name),null;let h=l.values.length/l.times.length;p===y.morphTargetInfluences&&(h/=c.morphTargetInfluences.length),!0===l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(r="CUBICSPLINE",h/=3):r=l.getInterpolation()===o.ljd?"STEP":"LINEAR",a.push({input:this.processAccessor(new o.THS(l.times,1)),output:this.processAccessor(new o.THS(l.values,h)),interpolation:r}),i.push({sampler:a.length-1,target:{node:s.get(c),path:p}})}return r.animations.push({name:e.name||"clip_"+r.animations.length,samplers:a,channels:i}),r.animations.length-1}processSkin(e){let t=this.json,r=this.nodeMap,s=t.nodes[r.get(e)],n=e.skeleton;if(void 0===n)return null;let i=e.skeleton.bones[0];if(void 0===i)return null;let a=[],l=new Float32Array(16*n.bones.length),u=new o.kn4;for(let t=0;t<n.bones.length;++t)a.push(r.get(n.bones[t])),u.copy(n.boneInverses[t]),u.multiply(e.bindMatrix).toArray(l,16*t);return void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new o.THS(l,16)),joints:a,skeleton:r.get(i)}),s.skin=t.skins.length-1}processNode(e){let t=this.json,r=this.options,s=this.nodeMap;
18t.nodes||(t.nodes=[]);let n={};if(r.trs){let t=e.quaternion.toArray(),r=e.position.toArray(),s=e.scale.toArray();w(t,[0,0,0,1])||(n.rotation=t),w(r,[0,0,0])||(n.translation=r),w(s,[1,1,1])||(n.scale=s)}else e.matrixAutoUpdate&&e.updateMatrix(),!1===w(e.matrix.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])&&(n.matrix=e.matrix.elements);if(""!==e.name&&(n.name=String(e.name)),this.serializeUserData(e,n),e.isMesh||e.isLine||e.isPoints){let t=this.processMesh(e);null!==t&&(n.mesh=t)}else e.isCamera&&(n.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){let t=[];for(let s=0,n=e.children.length;s<n;s++){let n=e.children[s];if(n.visible||!1===r.onlyVisible){let e=this.processNode(n);null!==e&&t.push(e)}}t.length>0&&(n.children=t)}this._invokeAll(function(t){t.writeNode&&t.writeNode(e,n)});let i=t.nodes.push(n)-1;return s.set(e,i),i}processScene(e){let t=this.json,r=this.options;t.scenes||(t.scenes=[],t.scene=0);let s={};""!==e.name&&(s.name=e.name),t.scenes.push(s);let n=[];for(let t=0,s=e.children.length;t<s;t++){let s=e.children[t];if(s.visible||!1===r.onlyVisible){let e=this.processNode(s);null!==e&&n.push(e)}}n.length>0&&(s.nodes=n),this.serializeUserData(e,s)}processObjects(e){let t=new o.Z58;t.name="AuxScene";for(let r=0;r<e.length;r++)t.children.push(e[r]);this.processScene(t)}processInput(e){let t=this.options;e=e instanceof Array?e:[e],this._invokeAll(function(t){t.beforeParse&&t.beforeParse(e)});let r=[];for(let t=0;t<e.length;t++)e[t]instanceof o.Z58?this.processScene(e[t]):r.push(e[t]);r.length>0&&this.processObjects(r);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);for(let r=0;r<t.animations.length;++r)this.processAnimation(t.animations[r],e[0]);this._invokeAll(function(t){t.afterParse&&t.afterParse(e)})}_invokeAll(e){for(let t=0,r=this.plugins.length;t<r;t++)e(this.plugins[t])}}class _{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);return}let r=this.writer,s=r.json,n=r.extensionsUsed,i={};e.name&&(i.name=e.name),i.color=e.color.toArray(),i.intensity=e.intensity,e.isDirectionalLight?i.type="directional":e.isPointLight?(i.type="point",e.distance>0&&(i.range=e.distance)):e.isSpotLight&&(i.type="spot",e.distance>0&&(i.range=e.distance),i.spot={},i.spot.innerConeAngle=(1-e.penumbra)*e.angle,i.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||0!==e.target.position.x||0!==e.target.position.y||-1!==e.target.position.z)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),n[this.name]||(s.extensions=s.extensions||{},s.extensions[this.name]={lights:[]},n[this.name]=!0);let a=s.extensions[this.name].lights;a.push(i),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}}class v{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let r=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},r[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class S{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.clearcoat)return;let r=this.writer,s=r.extensionsUsed,n={};if(n.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:r.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};r.applyTextureTransform(t,e.clearcoatMap),n.clearcoatTexture=t}if(n.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:r.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};r.applyTextureTransform(t,e.clearcoatRoughnessMap),n.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:r.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};r.applyTextureTransform(t,e.clearcoatNormalMap),n.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=n,s[this.name]=!0}}class N{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.iridescence)return;let r=this.writer,s=r.extensionsUsed,n={};if(n.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:r.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};r.applyTextureTransform(t,e.iridescenceMap),n.iridescenceTexture=t}if(n.iridescenceIor=e.iridescenceIOR,n.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],n.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let t={index:r.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};r.applyTextureTransform(t,e.iridescenceThicknessMap),n.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=n,s[this.name]=!0}}class C{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let r=this.writer,s=r.extensionsUsed,n={};if(n.transmissionFactor=e.transmission,e.transmissionMap){let t={index:r.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};r.applyTextureTransform(t,e.transmissionMap),n.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=n,s[this.name]=!0}}class L{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;let r=this.writer,s=r.extensionsUsed,n={};if(n.thicknessFactor=e.thickness,e.thicknessMap){let t={index:r.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};r.applyTextureTransform(t,e.thicknessMap),n.thicknessTexture=t}n.attenuationDistance=e.attenuationDistance,n.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=n,s[this.name]=!0}}class U{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1.5===e.ior)return;let r=this.writer.extensionsUsed,s={};s.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}}class k{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||1===e.specularIntensity&&e.specularColor.equals(M)&&!e.specularIntensityMap&&!e.specularColorMap)return;let r=this.writer,s=r.extensionsUsed,n={};if(e.specularIntensityMap){let t={index:r.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};r.applyTextureTransform(t,e.specularIntensityMap),n.specularTexture=t}if(e.specularColorMap){let t={index:r.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};r.applyTextureTransform(t,e.specularColorMap),n.specularColorTexture=t}n.specularFactor=e.specularIntensity,n.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=n,s[this.name]=!0}}class O{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.sheen)return;let r=this.writer,s=r.extensionsUsed,n={};if(e.sheenRoughnessMap){let t={index:r.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};r.applyTextureTransform(t,e.sheenRoughnessMap),n.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:r.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};r.applyTextureTransform(t,e.sheenColorMap),n.sheenColorTexture=t}n.sheenRoughnessFactor=e.sheenRoughness,n.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=n,s[this.name]=!0}}class ${constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0==e.anisotropy)return;let r=this.writer,s=r.extensionsUsed,n={};if(e.anisotropyMap){let t={index:r.processTexture(e.anisotropyMap)};r.applyTextureTransform(t,e.anisotropyMap),n.anisotropyTexture=t}n.anisotropyStrength=e.anisotropy,n.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=n,s[this.name]=!0}}class F{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||1===e.emissiveIntensity)return;let r=this.writer.extensionsUsed,s={};s.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}}class P{constructor(e){this.writer=e,this.name="EXT_materials_bump"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||1===e.bumpScale&&!e.bumpMap)return;let r=this.writer,s=r.extensionsUsed,n={};if(e.bumpMap){let t={index:r.processTexture(e.bumpMap),texCoord:e.bumpMap.channel};r.applyTextureTransform(t,e.bumpMap),n.bumpTexture=t}n.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=n,s[this.name]=!0}}class D{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;let r=this.writer,s=new Float32Array(3*e.count),n=new Float32Array(4*e.count),i=new Float32Array(3*e.count),a=new o.kn4,l=new o.Pq0,u=new o.PTz,c=new o.Pq0;for(let t=0;t<e.count;t++)e.getMatrixAt(t,a),a.decompose(l,u,c),l.toArray(s,3*t),u.toArray(n,4*t),c.toArray(i,3*t);let p={TRANSLATION:r.processAccessor(new o.THS(s,3)),ROTATION:r.processAccessor(new o.THS(n,4)),SCALE:r.processAccessor(new o.THS(i,3))};e.instanceColor&&(p._COLOR_0=r.processAccessor(e.instanceColor)),t.extensions=t.extensions||{},t.extensions[this.name]={attributes:p},r.extensionsUsed[this.name]=!0,r.extensionsRequired[this.name]=!0}}d.Utils={insertKeyframe:function(e,t){let r;let s=e.getValueSize(),n=new e.TimeBufferType(e.times.length+1),i=new e.ValueBufferType(e.values.length+s),a=e.createInterpolant(new e.ValueBufferType(s));
18if(0===e.times.length){n[0]=t;for(let e=0;e<s;e++)i[e]=0;r=0}else if(t<e.times[0]){if(.001>Math.abs(e.times[0]-t))return 0;n[0]=t,n.set(e.times,1),i.set(a.evaluate(t),0),i.set(e.values,s),r=0}else if(t>e.times[e.times.length-1]){if(.001>Math.abs(e.times[e.times.length-1]-t))return e.times.length-1;n[n.length-1]=t,n.set(e.times,0),i.set(e.values,0),i.set(a.evaluate(t),e.values.length),r=n.length-1}else for(let o=0;o<e.times.length;o++){if(.001>Math.abs(e.times[o]-t))return o;if(e.times[o]<t&&e.times[o+1]>t){n.set(e.times.slice(0,o+1),0),n[o+1]=t,n.set(e.times.slice(o+1),o+2),i.set(e.values.slice(0,(o+1)*s),0),i.set(a.evaluate(t),(o+1)*s),i.set(e.values.slice((o+1)*s),(o+2)*s),r=o+1;break}}return e.times=n,e.values=i,r},mergeMorphTargetTracks:function(e,t){let r=[],s={},n=e.tracks;for(let e=0;e<n.length;++e){let i,a=n[e],l=o.Nwf.parseTrackName(a.name),u=o.Nwf.findNode(t,l.nodeName);if("morphTargetInfluences"!==l.propertyName||void 0===l.propertyIndex){r.push(a);continue}if(a.createInterpolant!==a.InterpolantFactoryMethodDiscrete&&a.createInterpolant!==a.InterpolantFactoryMethodLinear){if(a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),(a=a.clone()).setInterpolation(o.PJ3)}let c=u.morphTargetInfluences.length,p=u.morphTargetDictionary[l.propertyIndex];if(void 0===p)throw Error("THREE.GLTFExporter: Morph target name not found: "+l.propertyIndex);if(void 0===s[u.uuid]){let e=new(i=a.clone()).ValueBufferType(c*i.times.length);for(let t=0;t<i.times.length;t++)e[t*c+p]=i.values[t];i.name=(l.nodeName||"")+".morphTargetInfluences",i.values=e,s[u.uuid]=i,r.push(i);continue}let h=a.createInterpolant(new a.ValueBufferType(1));i=s[u.uuid];for(let e=0;e<i.times.length;e++)i.values[e*c+p]=h.evaluate(i.times[e]);for(let e=0;e<a.times.length;e++){let t=this.insertKeyframe(i,a.times[e]);i.values[t*c+p]=a.values[e]}}return e.tracks=r,e}};class z{async parse(e,t={}){var r;t=Object.assign({ar:{anchoring:{type:"plane"},planeAnchoring:{alignment:"horizontal"}},quickLookCompatible:!1,maxTextureSize:1024},t);let s={},n="model.usda";s[n]=null;let i=B();i+=(r=t,`def Xform "Root" 19{ 20 def Scope "Scenes" ( 21 kind = "sceneLibrary" 22 ) 23 { 24 def Xform "Scene" ( 25 customData = { 26 bool preliminary_collidesWithEnvironment = 0 27 string sceneName = "Scene" 28 } 29 sceneName = "Scene" 30 ) 31 { 32 token preliminary:anchoring:type = "${r.ar.anchoring.type}" 33 token preliminary:planeAnchoring:alignment = "${r.ar.planeAnchoring.alignment}" 34 35`);let a={},u={};for(let r in e.traverseVisible(e=>{if(e.isMesh){let n=e.geometry,o=e.material;if(o.isMeshStandardMaterial){let u="geometries/Geometry_"+n.id+".usda";if(!(u in s)){var t,r;let e;let i=(t=n,` 36def "Geometry" 37{ 38${function(e){var t;let r=e.attributes,s=r.position.count;return` 39 def Mesh "Geometry" 40 { 41 int[] faceVertexCounts = [${Array((null!==(t=e).index?t.index.count:t.attributes.position.count)/3).fill(3).join(", ")}] 42 int[] faceVertexIndices = [${function(e){let t=e.index,r=[];if(null!==t)for(let e=0;e<t.count;e++)r.push(t.getX(e));else{let t=e.attributes.position.count;for(let e=0;e<t;e++)r.push(e)}return r.join(", ")}(e)}] 43 normal3f[] normals = [${j(r.normal,s)}] ( 44 interpolation = "vertex" 45 ) 46 point3f[] points = [${j(r.position,s)}] 47${function(e){let t="";for(let r=0;r<4;r++){let s=r>0?r:"",n=e["uv"+s];void 0!==n&&(t+=` 48 texCoord2f[] primvars:st${s} = [${function(e){let t=[];for(let r=0;r<e.count;r++){let s=e.getX(r),n=e.getY(r);t.push(`(${s.toPrecision(7)}, ${1-n.toPrecision(7)})`)}return t.join(", ")}(n)}] ( 49 interpolation = "vertex" 50 )`)}let r=e.color;if(void 0!==r){let e=r.count;t+=` 51 color3f[] primvars:displayColor = [${j(r,e)}] ( 52 interpolation = "vertex" 53 )`}return t}(r)} 54 uniform token subdivisionScheme = "none" 55 } 56`}(t)} 57} 58`);s[u]=(r=i,e=B()+r,(0,l.s)(e))}o.uuid in a||(a[o.uuid]=o),i+=function(e,t,r){let s="Object_"+e.id,n=H(e.matrixWorld);return 0>e.matrixWorld.determinant()&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",e),`def Xform "${s}" (
59 prepend references = @./geometries/Geometry_${t.id}.usda@</Geometry> 60 prepend apiSchemas = ["MaterialBindingAPI"] 61) 62{ 63 matrix4d xformOp:transform = ${n} 64 uniform token[] xformOpOrder = ["xformOp:transform"] 65 66 rel material:binding = </Materials/Material_${r.id}> 67} 68 69`}(e,n,o)}else console.warn("THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)",e)}else e.isCamera&&(i+=function(e){let t=e.name?e.name:"Camera_"+e.id,r=H(e.matrixWorld);return 0>e.matrixWorld.determinant()&&console.warn("THREE.USDZExporter: USDZ does not support negative scales",e),e.isOrthographicCamera?`def Camera "${t}" 70 { 71 matrix4d xformOp:transform = ${r} 72 uniform token[] xformOpOrder = ["xformOp:transform"] 73 74 float2 clippingRange = (${e.near.toPrecision(7)}, ${e.far.toPrecision(7)}) 75 float horizontalAperture = ${((Math.abs(e.left)+Math.abs(e.right))*10).toPrecision(7)} 76 float verticalAperture = ${((Math.abs(e.top)+Math.abs(e.bottom))*10).toPrecision(7)} 77 token projection = "orthographic" 78 } 79 80 `:`def Camera "${t}" 81 { 82 matrix4d xformOp:transform = ${r} 83 uniform token[] xformOpOrder = ["xformOp:transform"] 84 85 float2 clippingRange = (${e.near.toPrecision(7)}, ${e.far.toPrecision(7)}) 86 float focalLength = ${e.getFocalLength().toPrecision(7)} 87 float focusDistance = ${e.focus.toPrecision(7)} 88 float horizontalAperture = ${e.getFilmWidth().toPrecision(7)} 89 token projection = "perspective" 90 float verticalAperture = ${e.getFilmHeight().toPrecision(7)} 91 } 92 93 `}(e))}),i+=` 94 } 95 } 96} 97 98`,i+=function(e,t,r=!1){let s=[];for(let n in e){let i=e[n];s.push(function(e,t,r=!1){let s=[],n=[];function i(s,n,i){var a;let l=s.source.id+"_"+s.flipY;t[l]=s;let u=s.channel>0?"st"+s.channel:"st",c={1e3:"repeat",1001:"clamp",1002:"mirror"},p=s.repeat.clone(),h=s.offset.clone(),m=s.rotation,f=Math.sin(m),d=Math.cos(m);return h.y=1-h.y-p.y,r?(h.x=h.x/p.x,h.y=h.y/p.y,h.x+=f/p.x,h.y+=d-1):(h.x+=f*p.x,h.y+=(1-d)*p.y),` 99 def Shader "PrimvarReader_${n}"
100 { 101 uniform token info:id = "UsdPrimvarReader_float2" 102 float2 inputs:fallback = (0.0, 0.0) 103 token inputs:varname = "${u}" 104 float2 outputs:result 105 } 106 107 def Shader "Transform2d_${n}" 108 { 109 uniform token info:id = "UsdTransform2d" 110 token inputs:in.connect = </Materials/Material_${e.id}/PrimvarReader_${n}.outputs:result> 111 float inputs:rotation = ${(180/Math.PI*m).toFixed(7)} 112 float2 inputs:scale = ${Y(p)} 113 float2 inputs:translation = ${Y(h)} 114 float2 outputs:result 115 } 116 117 def Shader "Texture_${s.id}_${n}" 118 { 119 uniform token info:id = "UsdUVTexture" 120 asset inputs:file = @textures/Texture_${l}.png@ 121 float2 inputs:st.connect = </Materials/Material_${e.id}/Transform2d_${n}.outputs:result> 122 ${void 0!==i?"float4 inputs:scale = "+(a=i,`(${a.r}, ${a.g}, ${a.b}, 1.0)`):""} 123 token inputs:sourceColorSpace = "${s.colorSpace===o.jf0?"raw":"sRGB"}" 124 token inputs:wrapS = "${c[s.wrapS]}" 125 token inputs:wrapT = "${c[s.wrapT]}" 126 float outputs:r 127 float outputs:g 128 float outputs:b 129 float3 outputs:rgb 130 ${e.transparent||e.alphaTest>0?"float outputs:a":""} 131 }`}return e.side===o.$EB&&console.warn("THREE.USDZExporter: USDZ does not support double sided materials",e),null!==e.map?(s.push(` color3f inputs:diffuseColor.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:rgb>`),e.transparent?s.push(` float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:a>`):e.alphaTest>0&&(s.push(` float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.map.id}_diffuse.outputs:a>`),s.push(` float inputs:opacityThreshold = ${e.alphaTest}`)),n.push(i(e.map,"diffuse",e.color))):s.push(` color3f inputs:diffuseColor = ${V(e.color)}`),null!==e.emissiveMap?(s.push(` color3f inputs:emissiveColor.connect = </Materials/Material_${e.id}/Texture_${e.emissiveMap.id}_emissive.outputs:rgb>`),n.push(i(e.emissiveMap,"emissive"))):e.emissive.getHex()>0&&s.push(` color3f inputs:emissiveColor = ${V(e.emissive)}`),null!==e.normalMap&&(s.push(` normal3f inputs:normal.connect = </Materials/Material_${e.id}/Texture_${e.normalMap.id}_normal.outputs:rgb>`),n.push(i(e.normalMap,"normal"))),null!==e.aoMap&&(s.push(` float inputs:occlusion.connect = </Materials/Material_${e.id}/Texture_${e.aoMap.id}_occlusion.outputs:r>`),n.push(i(e.aoMap,"occlusion"))),null!==e.roughnessMap&&1===e.roughness?(s.push(` float inputs:roughness.connect = </Materials/Material_${e.id}/Texture_${e.roughnessMap.id}_roughness.outputs:g>`),n.push(i(e.roughnessMap,"roughness"))):s.push(` float inputs:roughness = ${e.roughness}`),null!==e.metalnessMap&&1===e.metalness?(s.push(` float inputs:metallic.connect = </Materials/Material_${e.id}/Texture_${e.metalnessMap.id}_metallic.outputs:b>`),n.push(i(e.metalnessMap,"metallic"))):s.push(` float inputs:metallic = ${e.metalness}`),null!==e.alphaMap?(s.push(` float inputs:opacity.connect = </Materials/Material_${e.id}/Texture_${e.alphaMap.id}_opacity.outputs:r>`),s.push(` float inputs:opacityThreshold = 0.0001`),n.push(i(e.alphaMap,"opacity"))):s.push(` float inputs:opacity = ${e.opacity}`),e.isMeshPhysicalMaterial&&(s.push(` float inputs:clearcoat = ${e.clearcoat}`),s.push(` float inputs:clearcoatRoughness = ${e.clearcoatRoughness}`),s.push(` float inputs:ior = ${e.ior}`)),` 132 def Material "Material_${e.id}" 133 { 134 def Shader "PreviewSurface" 135 { 136 uniform token info:id = "UsdPreviewSurface" 137${s.join(` 138`)} 139 int inputs:useSpecularWorkflow = 0 140 token outputs:surface 141 } 142 143 token outputs:surface.connect = </Materials/Material_${e.id}/PreviewSurface.outputs:surface> 144 145${n.join(` 146`)} 147 148 } 149`}(i,t,r))}return`def "Materials" 150{ 151${s.join("")} 152} 153 154`}(a,u,t.quickLookCompatible),s[n]=(0,l.s)(i),i=null,u){let e=u[r];!0===e.isCompressedTexture&&(e=m(e));let n=function(e,t,r){if("u">typeof HTMLImageElement&&e instanceof HTMLImageElement||"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"u">typeof OffscreenCanvas&&e instanceof OffscreenCanvas||"u">typeof ImageBitmap&&e instanceof ImageBitmap){let s=r/Math.max(e.width,e.height),n=document.createElement("canvas");n.width=e.width*Math.min(1,s),n.height=e.height*Math.min(1,s);let i=n.getContext("2d");return!0===t&&(i.translate(0,n.height),i.scale(1,-1)),i.drawImage(e,0,0,n.width,n.height),n}throw Error("THREE.USDZExporter: No valid image data found. Unable to process texture.")}(e.image,e.flipY,t.maxTextureSize),i=await new Promise(e=>
154n.toBlob(e,"image/png",1));s[`textures/Texture_${r}.png`]=new Uint8Array(await i.arrayBuffer())}let c=0;for(let e in s){let t=s[e],r=63&(c+=34+e.length);if(4!==r){let n=new Uint8Array(64-r);s[e]=[t,{extra:{12345:n}}]}c=t.length}return(0,l.z)(s,{level:0})}}function B(){return`#usda 1.0 155( 156 customLayerData = { 157 string creator = "Three.js USDZExporter" 158 } 159 defaultPrim = "Root" 160 metersPerUnit = 1 161 upAxis = "Y" 162) 163 164`}function H(e){let t=e.elements;return`( ${G(t,0)}, ${G(t,4)}, ${G(t,8)}, ${G(t,12)} )`}function G(e,t){return`(${e[t+0]}, ${e[t+1]}, ${e[t+2]}, ${e[t+3]})`}function j(e,t){if(void 0===e)return console.warn("USDZExporter: Normals missing."),Array(t).fill("(0, 0, 0)").join(", ");let r=[];for(let t=0;t<e.count;t++){let s=e.getX(t),n=e.getY(t),i=e.getZ(t);r.push(`(${s.toPrecision(7)}, ${n.toPrecision(7)}, ${i.toPrecision(7)})`)}return r.join(", ")}function V(e){return`(${e.r}, ${e.g}, ${e.b})`}function Y(e){return`(${e.x}, ${e.y})`}class Z{constructor(){h(this,"_gltfExporter"),h(this,"_usdzExporter"),this._gltfExporter=new d,this._usdzExporter=new z}async export(e,t,r){switch(this._computeNormals(e),t){case"glb":return this._exportGlb(e,r);case"gltf":return this._exportGltf(e,r);case"usdz":return this._exportUsdz(e,r);default:throw new u.F(`Unsupported file type: ${t}`,t)}}async _exportGlb(e,t){try{let r=await this._gltfExporter.parseAsync(e,{animations:e.animations.length>0?e.animations:void 0,...t,binary:!0});if(r instanceof ArrayBuffer)return r;throw new u.P("Failed to export GLB: expected ArrayBuffer")}catch(e){throw e instanceof u.P?e:new u.P("Failed to export GLB",e)}}async _exportGltf(e,t){try{let r=await this._gltfExporter.parseAsync(e,{animations:e.animations.length>0?e.animations:void 0,...t,binary:!1}),s=JSON.stringify(r);return new TextEncoder().encode(s).buffer}catch(e){throw e instanceof u.P?e:new u.P("Failed to export GLTF",e)}}async _exportUsdz(e,t){try{return(await this._usdzExporter.parse(e,t)).buffer}catch(e){throw e instanceof u.P?e:new u.P("Failed to export USDZ",e)}}_computeNormals(e){e.traverse(e=>{e instanceof o.eaF&&e.geometry&&(e.geometry.getAttribute("normal")||e.geometry.computeVertexNormals())})}}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.