vendor: 12,059 bytes, line 1
1import{$ as B,A as pe,B as de,C as xe,D as ye,E as ge,F as we,G as Te,Jb as P,L as me,R as Ae,Ra as D,S as Me,W as Ie,X as Ee,a as ue,ba as Re,ca as z,ea as Ne,fa as H,h as le,ja as G,na as _e,pa as V,sa as b,y as he,z as fe}from"./chunk-RALJFSNX.js";import"./chunk-JJ75YLVJ.js";var Se={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"]},L=class{constructor(){this.textureUtils=null,this.pluginCallbacks=[],this.register(function(e){return new W(e)}),this.register(function(e){return new J(e)}),this.register(function(e){return new $(e)}),this.register(function(e){return new ee(e)}),this.register(function(e){return new se(e)}),this.register(function(e){return new te(e)}),this.register(function(e){return new Z(e)}),this.register(function(e){return new j(e)}),this.register(function(e){return new Q(e)}),this.register(function(e){return new ne(e)}),this.register(function(e){return new ie(e)}),this.register(function(e){return new re(e)}),this.register(function(e){return new oe(e)}),this.register(function(e){return new ae(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}setTextureUtils(e){return this.textureUtils=e,this}parse(e,s,r,i){let t=new X,n=[];for(let o=0,a=this.pluginCallbacks.length;o<a;o++)n.push(this.pluginCallbacks[o](t));t.setPlugins(n),t.setTextureUtils(this.textureUtils),t.writeAsync(e,s,i).catch(r)}parseAsync(e,s){let r=this;return new Promise(function(i,t){r.parse(e,i,t,s)})}},w={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,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},Y="KHR_mesh_quantization",N={};N[de]=w.NEAREST;N[xe]=w.NEAREST_MIPMAP_NEAREST;N[ye]=w.NEAREST_MIPMAP_LINEAR;N[ge]=w.LINEAR;N[we]=w.LINEAR_MIPMAP_NEAREST;N[Te]=w.LINEAR_MIPMAP_LINEAR;N[fe]=w.CLAMP_TO_EDGE;N[he]=w.REPEAT;N[pe]=w.MIRRORED_REPEAT;var be={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},Oe=new _e,Ce=12,Fe=1179937895,ze=2,Ue=8,De=1313821514,Pe=5130562;function S(c,e){return c.length===e.length&&c.every(function(s,r){return s===e[r]})}function Be(c){return new TextEncoder().encode(c).buffer}function ke(c){return S(c.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function He(c,e,s){let r={min:new Array(c.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(c.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let i=e;i<e+s;i++)for(let t=0;t<c.itemSize;t++){let n;c.itemSize>4?n=c.array[i*c.itemSize+t]:(t===0?n=c.getX(i):t===1?n=c.getY(i):t===2?n=c.getZ(i):t===3&&(n=c.getW(i)),c.normalized===!0&&(n=B.normalize(n,c.array))),r.min[t]=Math.min(r.min[t],n),r.max[t]=Math.max(r.max[t],n)}return r}function Le(c){return Math.ceil(c/4)*4}function K(c,e=0){let s=Le(c.byteLength);if(s!==c.byteLength){let r=new Uint8Array(s);if(r.set(new Uint8Array(c)),e!==0)for(let i=c.byteLength;i<s;i++)r[i]=e;return r.buffer}return c}function q(){return typeof document=="undefined"&&typeof OffscreenCanvas!="undefined"?new OffscreenCanvas(1,1):document.createElement("canvas")}function Ge(c,e){if(typeof OffscreenCanvas!="undefined"&&c instanceof OffscreenCanvas){let s;return e==="image/jpeg"?s=.92:e==="image/webp"&&(s=.8),c.convertToBlob({type:e,quality:s})}else return new Promise(s=>c.toBlob(s,e))}var X=class{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 r"+ue}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map},this.textureUtils=null}setPlugins(e){this.plugins=e}setTextureUtils(e){this.textureUtils=e}async writeAsync(e,s,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),await this.processInputAsync(e),await Promise.all(this.pending);let i=this,t=i.buffers,n=i.json;r=i.options;let o=i.extensionsUsed,a=i.extensionsRequired,h=new Blob(t,{type:"application/octet-stream"}),u=Object.keys(o),l=Object.keys(a);if(u.length>0&&(n.extensionsUsed=u),l.length>0&&(n.extensionsRequired=l),n.buffers&&n.buffers.length>0&&(n.buffers[0].byteLength=h.size),r.binary===!0){let x=new FileReader;x.readAsArrayBuffer(h),x.onloadend=function(){let f=K(x.result),d=new DataView(new ArrayBuffer(Ue));d.setUint32(0,f.byteLength,!0),d.setUint32(4,Pe,!0);let p=K(Be(JSON.stringify(n)),32),y=new DataView(new ArrayBuffer(Ue));y.setUint32(0,p.byteLength,!0),y.setUint32(4,De,!0);let m=new ArrayBuffer(Ce),M=new DataView(m);M.setUint32(0,Fe,!0),M.setUint32(4,ze,!0);let C=Ce+y.byteLength+p.byteLength+d.byteLength+f.byteLength;M.setUint32(8,C,!0);let g=new Blob([m,y,p,d,f],{type:"application/octet-stream"}),T=new FileReader;T.readAsArrayBuffer(g),T.onloadend=function(){s(T.result)}}}else if(n.buffers&&n.buffers.length>0){let x=new FileReader;x.readAsDataURL(h),x.onloadend=function(){let f=x.result;n.buffers[0].uri=f,s(n)}}else s(n)}serializeUserData(e,s){if(Object.keys(e.userData).length===0)return;let r=this.options,i=this.extensionsUsed;try{let t=JSON.parse(JSON.stringify(e.userData));if(r.includeCustomExtensions&&t.gltfExtensions){s.extensions===void 0&&(s.extensions={});for(let n in t.gltfExtensions)s.extensions[n]=t.gltfExtensions[n],i[n]=!0;delete t.gltfExtensions}Object.keys(t).length>0&&(s.extras=t)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e,s=!1){if(this.uids.has(e)===!1){let i=new Map;i.set(!0,this.uid++),i.set(!1,this.uid++),this.uids.set(e,i)}return this.uids.get(e).get(s)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let r=new z;for(let i=0,t=e.count;i<t;i++)if(Math.abs(r.fromBufferAttribute(e,i).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let s=this.cache;if(s.attributesNormalized.has(e))return s.attributesNormalized.get(e);let r=e.clone(),i=new z;for(let t=0,n=r.count;t<n;t++)i.fromBufferAttribute(r,t),i.x===0&&i.y===0&&i.z===0?i.setX(1):i.normalize(),r.setXYZ(t,i.x,i.y,i.z);return s.attributesNormalized.set(e,r),r}applyTextureTransform(e,s){let r=!1,i={};(s.offset.x!==0||s.offset.y!==0)&&(i.offset=s.offset.toArray(),r=!0),s.rotation!==0&&(i.rotation=s.rotation,r=!0),(s.repeat.x!==1||s.repeat.y!==1)&&(i.scale=s.repeat.toArray(),r=!0),r&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=i,this.extensionsUsed.KHR_texture_transform=!0)}async buildMetalRoughTextureAsync(e,s){if(e===s)return e;function r(f){return f.colorSpace===Ee?function(p){return p<.04045?p*.0773993808:Math.pow(p*.9478672986+.0521327014,2.4)}:function(p){return p}}e instanceof D&&(e=await this.decompressTextureAsync(e)),s instanceof D&&(s=await this.decompressTextureAsync(s));let i=e?e.image:null,t=s?s.image:null,n=Math.max(i?i.width:0,t?t.width:0),o=Math.max(i?i.height:0,t?t.height:0),a=q();a.width=n,a.height=o;let h=a.getContext("2d",{willReadFrequently:!0});h.fillStyle="#00ffff",h.fillRect(0,0,n,o);let u=h.getImageData(0,0,n,o);if(i){h.drawImage(i,0,0,n,o);let f=r(e),d=h.getImageData(0,0,n,o).data;for(let p=2;p<d.length;p+=4)u.data[p]=f(d[p]/256)*256}if(t){h.drawImage(t,0,0,n,o);let f=r(s),d=h.getImageData(0,0,n,o).data;for(let p=1;p<d.length;p+=4)u.data[p]=f(d[p]/256)*256}h.putImageData(u,0,0);let x=(e||s).clone();return x.source=new H(a),x.colorSpace=Ie,x.channel=(e||s).channel,e&&s&&e.channel!==s.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),x}async buildNormalMapTextureAsync(e,s,r){e instanceof D&&(e=await this.decompressTextureAsync(e));let i=e.image,t=q();t.width=i.width,t.height=i.height;let n=t.getContext("2d",{willReadFrequently:!0});n.drawImage(i,0,0,t.width,t.height);let o=n.getImageData(0,0,t.width,t.height),a=o.data;for(let u=0;u<a.length;u+=4)s&&(a[u+0]=255-a[u+0]),r&&(a[u+1]=255-a[u+1]);n.putImageData(o,0,0);let h=e.clone();return h.source=new H(t),h}async decompressTextureAsync(e,s=1/0){if(this.textureUtils===null)throw new Error("THREE.GLTFExporter: setTextureUtils() must be called to process compressed textures.");return await this.textureUtils.decompress(e,s)}processBuffer(e){let s=this.json,r=this.buffers;return s.buffers||(s.buffers=[{byteLength:0}]),r.push(e),0}processBufferView(e,s,r,i,t){let n=this.json;n.bufferViews||(n.bufferViews=[]);let o;switch(s){case w.BYTE:case w.UNSIGNED_BYTE:o=1;break;case w.SHORT:case w.UNSIGNED_SHORT:o=2;break;default:o=4}let a=e.itemSize*o;t===w.ARRAY_BUFFER&&(a=Math.ceil(a/4)*4);let h=Le(i*a),u=new DataView(new ArrayBuffer(h)),l=0;for(let d=r;d<r+i;d++){for(let p=0;p<e.itemSize;p++){let y;e.itemSize>4?y=e.array[d*e.itemSize+p]:(p===0?y=e.getX(d):p===1?y=e.getY(d):p===2?y=e.getZ(d):p===3&&(y=e.getW(d)),e.normalized===!0&&(y=B.normalize(y,e.array))),s===w.FLOAT?u.setFloat32(l,y,!0):s===w.INT?u.setInt32(l,y,!0):s===w.UNSIGNED_INT?u.setUint32(l,y,!0):s===w.SHORT?u.setInt16(l,y,!0):s===w.UNSIGNED_SHORT?u.setUint16(l,y,!0):s===w.BYTE?u.setInt8(l,y):s===w.UNSIGNED_BYTE&&u.setUint8(l,y),l+=o}l%a!==0&&(l+=a-l%a)}let x={buffer:this.processBuffer(u.buffer),byteOffset:this.byteOffset,byteLength:h};return t!==void 0&&(x.target=t),t===w.ARRAY_BUFFER&&(x.byteStride=a),this.byteOffset+=h,n.bufferViews.push(x),{id:n.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let s=this,r=s.json;return r.bufferViews||(r.bufferViews=[]),new Promise(function(i){let t=new FileReader;t.readAsArrayBuffer(e),t.onloadend=function(){let n=K(t.result),o={buffer:s.processBuffer(n),byteOffset:s.byteOffset,byteLength:n.byteLength};s.byteOffset+=n.byteLength,i(r.bufferViews.push(o)-1)}})}processAccessor(e,s,r,i){let t=this.json,n={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"},o;if(e.array.constructor===Float32Array)o=w.FLOAT;else if(e.array.constructor===Int32Array)o=w.INT;else if(e.array.constructor===Uint32Array)o=w.UNSIGNED_INT;else if(e.array.constructor===Int16Array)o=w.SHORT;else if(e.array.constructor===Uint16Array)o=w.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)o=w.BYTE;else if(e.array.constructor===Uint8Array)o=w.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(r===void 0&&(r=0),(i===void 0||i===1/0)&&(i=e.count),i===0)return null;let a=He(e,r,i),h;s!==void 0&&(h=e===s.index?w.ELEMENT_ARRAY_BUFFER:w.ARRAY_BUFFER);let u=this.processBufferView(e,o,r,i,h),l={bufferView:u.id,byteOffset:u.byteOffset,componentType:o,count:i,max:a.max,min:a.min,type:n[e.itemSize]};return e.normalized===!0&&(l.normalized=!0),t.accessors||(t.accessors=[]),t.accessors.push(l)-1}processImage(e,s,r,i="image/png"){if(e!==null){let t=this,n=t.cache,o=t.json,a=t.options,h=t.pending;n.images.has(e)||n.images.set(e,{});let u=n.images.get(e),l=i+":flipY/"+r.toString();if(u[l]!==void 0)return u[l];o.images||(o.images=[]);let x={mimeType:i},f=q();f.width=Math.min(e.width,a.maxTextureSize),f.height=Math.min(e.height,a.maxTextureSize);let d=f.getContext("2d",{willReadFrequently:!0});if(r===!0&&(d.translate(0,f.height),d.scale(1,-1)),e.data!==void 0){s!==me&&c
1onsole.error("GLTFExporter: Only RGBAFormat is supported.",s),(e.width>a.maxTextureSize||e.height>a.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);let y=new Uint8ClampedArray(e.height*e.width*4);for(let m=0;m<y.length;m+=4)y[m+0]=e.data[m+0],y[m+1]=e.data[m+1],y[m+2]=e.data[m+2],y[m+3]=e.data[m+3];d.putImageData(new ImageData(y,e.width,e.height),0,0)}else if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap||typeof OffscreenCanvas!="undefined"&&e instanceof OffscreenCanvas)d.drawImage(e,0,0,f.width,f.height);else throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");a.binary===!0?h.push(Ge(f,i).then(y=>t.processBufferViewImage(y)).then(y=>{x.bufferView=y})):x.uri=Ne.getDataURL(f,i);let p=o.images.push(x)-1;return u[l]=p,p}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){let s=this.json;s.samplers||(s.samplers=[]);let r={magFilter:N[e.magFilter],minFilter:N[e.minFilter],wrapS:N[e.wrapS],wrapT:N[e.wrapT]};return s.samplers.push(r)-1}async processTextureAsync(e){let r=this.options,i=this.cache,t=this.json;if(i.textures.has(e))return i.textures.get(e);t.textures||(t.textures=[]),e instanceof D&&(e=await this.decompressTextureAsync(e,r.maxTextureSize));let n=e.userData.mimeType,o=this.processImage(e.image,e.format,e.flipY,n),a={sampler:this.processSampler(e)};n==="image/webp"?(a.extensions=a.extensions||{},a.extensions.EXT_texture_webp={source:o},this.extensionsUsed.EXT_texture_webp=!0,this.extensionsRequired.EXT_texture_webp=!0):a.source=o,e.name&&(a.name=e.name),await this._invokeAllAsync(async function(u){u.writeTexture&&await u.writeTexture(e,a)});let h=t.textures.push(a)-1;return i.textures.set(e,h),h}async processMaterialAsync(e,s){let r=this.cache,i=this.json,t=s!==void 0&&s.hasAttribute("tangent"),n=e.normalMap?e.uuid+":"+t:e.uuid;if(r.materials.has(n))return r.materials.get(n);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;i.materials||(i.materials=[]);let o={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");let a=e.color.toArray().concat([e.opacity]);if(S(a,[1,1,1,1])||(o.pbrMetallicRoughness.baseColorFactor=a),e.isMeshStandardMaterial?(o.pbrMetallicRoughness.metallicFactor=e.metalness,o.pbrMetallicRoughness.roughnessFactor=e.roughness):(o.pbrMetallicRoughness.metallicFactor=0,o.pbrMetallicRoughness.roughnessFactor=1),e.metalnessMap||e.roughnessMap){let u=await this.buildMetalRoughTextureAsync(e.metalnessMap,e.roughnessMap),l={index:await this.processTextureAsync(u),texCoord:u.channel};this.applyTextureTransform(l,u),o.pbrMetallicRoughness.metallicRoughnessTexture=l}if(e.map){let u={index:await this.processTextureAsync(e.map),texCoord:e.map.channel};this.applyTextureTransform(u,e.map),o.pbrMetallicRoughness.baseColorTexture=u}if(e.emissive){let u=e.emissive;if(Math.max(u.r,u.g,u.b)>0&&(o.emissiveFactor=e.emissive.toArray()),e.emissiveMap){let x={index:await this.processTextureAsync(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(x,e.emissiveMap),o.emissiveTexture=x}}if(e.normalMap){let u=e.normalScale,l=u.x<0,x=t?u.y<0:u.y>0,f=e.normalMap;(l||x)&&(f=await this.buildNormalMapTextureAsync(e.normalMap,l,x));let d={index:await this.processTextureAsync(f),texCoord:e.normalMap.channel};Math.abs(u.x)!==1&&(d.scale=Math.abs(u.x)),this.applyTextureTransform(d,e.normalMap),o.normalTexture=d}if(e.aoMap){let u={index:await this.processTextureAsync(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(u.strength=e.aoMapIntensity),this.applyTextureTransform(u,e.aoMap),o.occlusionTexture=u}e.transparent?o.alphaMode="BLEND":e.alphaTest>0&&(o.alphaMode="MASK",o.alphaCutoff=e.alphaTest),e.side===le&&(o.doubleSided=!0),e.name!==""&&(o.name=e.name),this.serializeUserData(e,o),await this._invokeAllAsync(async function(u){u.writeMaterialAsync&&await u.writeMaterialAsync(e,o)});let h=i.materials.push(o)-1;return r.materials.set(n,h),h}async processMeshAsync(e){let s=this.cache,r=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let g=0,T=e.material.length;g<T;g++)i.push(e.material[g].uuid);else i.push(e.material.uuid);let t=i.join(":");if(s.meshes.has(t))return s.meshes.get(t);let n=e.geometry,o;e.isLineSegments?o=w.LINES:e.isLineLoop?o=w.LINE_LOOP:e.isLine?o=w.LINE_STRIP:e.isPoints?o=w.POINTS:o=e.material.wireframe?w.LINES:w.TRIANGLES;let a={},h={},u=[],l=[],x={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},f=n.getAttribute("normal");f!==void 0&&!this.isNormalizedNormalAttribute(f)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),n.setAttribute("normal",this.createNormalizedNormalAttribute(f)));let d=null;
vendor: 19,783 bytes, line 1
1for(let g in n.attributes){if(g.slice(0,5)==="morph")continue;let T=n.attributes[g];if(g=x[g]||g.toUpperCase(),!/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(g)&&!g.startsWith("_")&&(g="_"+g),s.attributes.has(this.getUID(T))){h[g]=s.attributes.get(this.getUID(T));continue}d=null;let A=T.array;g==="JOINTS_0"&&!(A instanceof Uint16Array)&&!(A instanceof Uint8Array)?(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),d=L.Utils.toTypedBufferAttribute(T,Uint16Array)):(A instanceof Uint32Array||A instanceof Int32Array)&&!g.startsWith("_")&&(console.warn(`GLTFExporter: Attribute "${g}" converted to type FLOAT.`),d=L.Utils.toTypedBufferAttribute(T,Float32Array));let R=this.processAccessor(d||T,n);R!==null&&(g.startsWith("_")||this.detectMeshQuantization(g,T),h[g]=R,s.attributes.set(this.getUID(T),R))}if(f!==void 0&&n.setAttribute("normal",f),Object.keys(h).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){let g=[],T=[],I={};if(e.morphTargetDictionary!==void 0)for(let A in e.morphTargetDictionary)I[e.morphTargetDictionary[A]]=A;for(let A=0;A<e.morphTargetInfluences.length;++A){let R={},ce=!1;for(let v in n.morphAttributes){if(v!=="position"&&v!=="normal"){ce||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),ce=!0);continue}let _=n.morphAttributes[v][A],k=v.toUpperCase(),O=n.attributes[v];if(s.attributes.has(this.getUID(_,!0))){R[k]=s.attributes.get(this.getUID(_,!0));continue}let F=_.clone();if(!n.morphTargetsRelative)for(let E=0,ve=_.count;E<ve;E++)for(let U=0;U<_.itemSize;U++)U===0&&F.setX(E,_.getX(E)-O.getX(E)),U===1&&F.setY(E,_.getY(E)-O.getY(E)),U===2&&F.setZ(E,_.getZ(E)-O.getZ(E)),U===3&&F.setW(E,_.getW(E)-O.getW(E));R[k]=this.processAccessor(F,n),s.attributes.set(this.getUID(O,!0),R[k])}l.push(R),g.push(e.morphTargetInfluences[A]),e.morphTargetDictionary!==void 0&&T.push(I[A])}a.weights=g,T.length>0&&(a.extras={},a.extras.targetNames=T)}let p=Array.isArray(e.material);if(p&&n.groups.length===0)return null;let y=!1;if(p&&n.index===null){let g=[];for(let T=0,I=n.attributes.position.count;T<I;T++)g[T]=T;n.setIndex(g),y=!0}let m=p?e.material:[e.material],M=p?n.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let g=0,T=M.length;g<T;g++){let I={mode:o,attributes:h};if(this.serializeUserData(n,I),l.length>0&&(I.targets=l),n.index!==null){let R=this.getUID(n.index);(M[g].start!==void 0||M[g].count!==void 0)&&(R+=":"+M[g].start+":"+M[g].count),s.attributes.has(R)?I.indices=s.attributes.get(R):(I.indices=this.processAccessor(n.index,n,M[g].start,M[g].count),s.attributes.set(R,I.indices)),I.indices===null&&delete I.indices}let A=await this.processMaterialAsync(m[M[g].materialIndex],n);A!==null&&(I.material=A),u.push(I)}y===!0&&n.setIndex(null),a.primitives=u,r.meshes||(r.meshes=[]),await this._invokeAllAsync(function(g){g.writeMesh&&g.writeMesh(e,a)});let C=r.meshes.push(a)-1;return s.meshes.set(t,C),C}detectMeshQuantization(e,s){if(this.extensionsUsed[Y])return;let r;switch(s.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}s.normalized&&(r+=" normalized");let i=e.split("_",1)[0];Se[i]&&Se[i].includes(r)&&(this.extensionsUsed[Y]=!0,this.extensionsRequired[Y]=!0)}processCamera(e){let s=this.json;s.cameras||(s.cameras=[]);let r=e.isOrthographicCamera,i={type:r?"orthographic":"perspective"};return r?i.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:B.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(i.name=e.type),s.cameras.push(i)-1}processAnimation(e,s){let r=this.json,i=this.nodeMap;r.animations||(r.animations=[]),e=L.Utils.mergeMorphTargetTracks(e.clone(),s);let t=e.tracks,n=[],o=[];for(let h=0;h<t.length;++h){let u=t[h],l=P.parseTrackName(u.name),x=P.findNode(s,l.nodeName),f=be[l.propertyName];if(l.objectName==="bones"&&(x.isSkinnedMesh===!0?x=x.skeleton.getBoneByName(l.objectIndex):x=void 0),!x||!f){console.warn('THREE.GLTFExporter: Could not export animation track "%s".',u.name);continue}let d=1,p=u.values.length/u.times.length;f===be.morphTargetInfluences&&(p/=x.morphTargetInfluences.length);let y;u.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(y="CUBICSPLINE",p/=3):u.getInterpolation()===Ae?y="STEP":y="LINEAR",o.push({input:this.processAccessor(new b(u.times,d)),output:this.processAccessor(new b(u.values,p)),interpolation:y}),n.push({sampler:o.length-1,target:{node:i.get(x),path:f}})}let a={name:e.name||"clip_"+r.animations.length,samplers:o,channels:n};return this.serializeUserData(e,a),r.animations.push(a),r.animations.length-1}processSkin(e){let s=this.json,r=this.nodeMap,i=s.nodes[r.get(e)],t=e.skeleton;if(t===void 0)return null;let n=e.skeleton.bones[0];if(n===void 0)return null;let o=[],a=new Float32Array(t.bones.length*16),h=new G;for(let l=0;l<t.bones.length;++l)o.push(r.get(t.bones[l])),h.copy(t.boneInverses[l]),h.multiply(e.bindMatrix).toArray(a,l*16);return s.skins===void 0&&(s.skins=[]),s.skins.push({inverseBindMatrices:this.processAccessor(new b(a,16)),joints:o,skeleton:r.get(n)}),i.skin=s.skins.length-1}async processNodeAsync(e){let s=this.json,r=this.options,i=this.nodeMap;if(s.nodes||(s.nodes=[]),e.pivot!==null)return await this._processNodeWithPivotAsync(e);let t={};if(r.trs){let o=e.quaternion.toArray(),a=e.position.toArray(),h=e.scale.toArray();S(o,[0,0,0,1])||(t.rotation=o),S(a,[0,0,0])||(t.translation=a),S(h,[1,1,1])||(t.scale=h)}else e.matrixAutoUpdate&&e.updateMatrix(),ke(e.matrix)===!1&&(t.matrix=e.matrix.elements);if(e.name!==""&&(t.name=String(e.name)),this.serializeUserData(e,t),e.isMesh||e.isLine||e.isPoints){let o=await this.processMeshAsync(e);o!==null&&(t.mesh=o)}else e.isCamera&&(t.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);let n=s.nodes.push(t)-1;if(i.set(e,n),e.children.length>0){let o=[];for(let a=0,h=e.children.length;a<h;a++){let u=e.children[a];if(u.visible||r.onlyVisible===!1){let l=await this.processNodeAsync(u);l!==null&&o.push(l)}}o.length>0&&(t.children=o)}return await this._invokeAllAsync(function(o){o.writeNode&&o.writeNode(e,t)}),n}async _processNodeWithPivotAsync(e){let s=this.json,r=this.options,i=this.nodeMap,t=e.pivot,n={},o=e.quaternion.toArray(),a=[e.position.x+t.x,e.position.y+t.y,e.position.z+t.z],h=e.scale.toArray();S(o,[0,0,0,1])||(n.rotation=o),S(a,[0,0,0])||(n.translation=a),S(h,[1,1,1])||(n.scale=h),n.extras={pivot:t.toArray()},e.name!==""&&(n.name=String(e.name)),this.serializeUserData(e,n);let u=s.nodes.push(n)-1;i.set(e,u);let l={},x=[-t.x,-t.y,-t.z];if(S(x,[0,0,0])||(l.translation=x),e.isMesh||e.isLine||e.isPoints){let p=await this.processMeshAsync(e);p!==null&&(l.mesh=p)}else e.isCamera&&(l.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);let d=[s.nodes.push(l)-1];if(e.children.length>0){let p=[];for(let y=0,m=e.children.length;y<m;y++){let M=e.children[y];if(M.visible||r.onlyVisible===!1){let C=await this.processNodeAsync(M);C!==null&&p.push(C)}}p.length>0&&(l.children=p)}return n.children=d,await this._invokeAllAsync(function(p){p.writeNode&&p.writeNode(e,n)}),u}async processSceneAsync(e){let s=this.json,r=this.options;s.scenes||(s.scenes=[],s.scene=0);let i={};e.name!==""&&(i.name=e.name),s.scenes.push(i);let t=[];for(let n=0,o=e.children.length;n<o;n++){let a=e.children[n];if(a.visible||r.onlyVisible===!1){let h=await this.processNodeAsync(a);h!==null&&t.push(h)}}t.length>0&&(i.nodes=t),this.serializeUserData(e,i)}async processObjectsAsync(e){let s=new V;s.name="AuxScene";for(let r=0;r<e.length;r++)s.children.push(e[r]);await this.processSceneAsync(s)}async processInputAsync(e){let s=this.options;e=e instanceof Array?e:[e],await this._invokeAllAsync(function(i){i.beforeParse&&i.beforeParse(e)});let r=[];for(let i=0;i<e.length;i++)e[i]instanceof V?await this.processSceneAsync(e[i]):r.push(e[i]);r.length>0&&await this.processObjectsAsync(r);for(let i=0;i<this.skins.length;++i)this.processSkin(this.skins[i]);if(e.length===1)for(let i=0;i<s.animations.length;++i)this.processAnimation(s.animations[i],e[0]);else for(let i=0;i<e.length;i++){let t=s.animations[i]||[];for(let n=0;n<t.length;++n)this.processAnimation(t[n],e[i])}await this._invokeAllAsync(function(i){i.afterParse&&i.afterParse(e)})}async _invokeAllAsync(e){for(let s=0,r=this.plugins.length;s<r;s++)await e(this.plugins[s])}},W=class{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,s){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,i=r.json,t=r.extensionsUsed,n={};e.name&&(n.name=e.name),n.color=e.color.toArray(),n.intensity=e.intensity,e.isDirectionalLight?n.type="directional":e.isPointLight?(n.type="point",e.distance>0&&(n.range=e.distance)):e.isSpotLight&&(n.type="spot",e.distance>0&&(n.range=e.distance),n.spot={},n.spot.innerConeAngle=(1-e.penumbra)*e.angle,n.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&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."),t[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},t[this.name]=!0);let o=i.extensions[this.name].lights;o.push(n),s.extensions=s.extensions||{},s.extensions[this.name]={light:o.length-1}}},J=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}async writeMaterialAsync(e,s){if(!e.isMeshBasicMaterial)return;let i=this.writer.extensionsUsed;s.extensions=s.extensions||{},s.extensions[this.name]={},i[this.name]=!0,s.pbrMetallicRoughness.metallicFactor=0,s.pbrMetallicRoughness.roughnessFactor=.9}},Z=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;let r=this.writer,i=r.extensionsUsed,t={};if(t.clearcoatFactor=e.clearcoat,e.clearcoatMap){let n={index:await r.processTextureAsync(e.clearcoatMap),texCoord:e.clearcoatMap.channel};r.applyTextureTransform(n,e.clearcoatMap),t.clearcoatTexture=n}if(t.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let n={index:await r.processTextureAsync(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};r.applyTextureTransform(n,e.clearcoatRoughnessMap),t.clearcoatRoughnessTexture=n}if(e.clearcoatNormalMap){let n={index:await r.processTextureAsync(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};e.clearcoatNormalScale.x!==1&&(n.scale=e.clearcoatNormalScale.x),r.applyTextureTransform(n,e.clearcoatNormalMap),t.clearcoatNormalTexture=n}s.extensions=s.extensions||{},s.extensions[this.name]=t,i[this.name]=!0}},j=class{constructor(e){this.writer=e,this.name="KHR_materials_dispersion"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.dispersion===0)return;let i=this.writer.extensionsUsed,t={};t.dispersion=e.dispersion,s.extensions=s.extensions||{},s.extensions[this.name]=t,i[this.name]=!0}},Q=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;let r=this.writer,i=r.extensionsUsed,t={};if(t.iridescenceFactor=e.iridescence,e.iridescenceMap){let n={index:await r.processTextureAsync(e.iridescenceMap),texCoord:e.iridescenceMap.channel};r.applyTextureTransform(n,e.iridescenceMap),t.iridescenceTexture=n}if(t.iridescenceIor=e.iridescenceIOR,t.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],t.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let n={index:await r.processTextureAsync(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};r.applyTextureTransform(n,e.iridescenceThicknessMap),t.iridescenceThicknessTexture=n}s.extensions=s.extensions||{},s.extensions[this.name]=t,i[this.name]=!0}},$=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let r=this.writer,i=r.extensionsUsed,t={};if(t.transmissionFactor=e.transmission,e.transmissionMap){let n={index:await r.processTextureAsync(e.transmissionMap),texCoord:e.transmissionMap.channel};r.applyTextureTransform(n,e.transmissionMap),t.transmissionTexture=n}s.extensions=s.extensions||{},s.extensions[this.name]=t,i[this.name]=!0}},ee=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let r=this.writer,i=r.extensionsUsed,t={};if(t.thicknessFactor=e.thickness,e.thicknessMap){let n={index:await r.processTextureAsync(e.thicknessMap),texCoord:e.thicknessMap.channel};r.applyTextureTransform(n,e.thicknessMap),t.thicknessTexture=n}e.attenuationDistance!==1/0&&(t.attenuationDistance=e.attenuationDistance),t.attenuationColor=e.attenuationColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=t,i[this.name]=!0}},se=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;let i=this.writer.extensionsUsed,t={};t.ior=e.ior,s.extensions=s.extensions||{},s.extensions[this.name]=t,i[this.name]=!0}},te=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(Oe)&&!e.specularIntensityMap&&!e.specularColorMap)return;let r=this.writer,i=r.extensionsUsed,t={};if(e.specularIntensityMap){let n={index:await r.processTextureAsync(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};r.applyTextureTransform(n,e.specularIntensityMap),t.specularTexture=n}if(e.specularColorMap){let n={index:await r.processTextureAsync(e.specularColorMap),texCoord:e.specularColorMap.channel};r.applyTextureTransform(n,e.specularColorMap),t.specularColorTexture=n}t.specularFactor=e.specularIntensity,t.specularColorFactor=e.specularColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=t,i[this.name]=!0}},ne=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;let r=this.writer,i=r.extensionsUsed,t={};if(e.sheenRoughnessMap){let n={index:await r.processTextureAsync(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};r.applyTextureTransform(n,e.sheenRoughnessMap),t.sheenRoughnessTexture=n}if(e.sheenColorMap){let n={index:await r.processTextureAsync(e.sheenColorMap),texCoord:e.sheenColorMap.channel};r.applyTextureTransform(n,e.sheenColorMap),t.sheenColorTexture=n}t.sheenRoughnessFactor=e.sheenRoughness,t.sheenColorFactor=e.sheenColor.toArray(),s.extensions=s.extensions||{},s.extensions[this.name]=t,i[this.name]=!0}},ie=class{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;let r=this.writer,i=r.extensionsUsed,t={};if(e.anisotropyMap){let n={index:await r.processTextureAsync(e.anisotropyMap)};r.applyTextureTransform(n,e.anisotropyMap),t.anisotropyTexture=n}t.anisotropyStrength=e.anisotropy,t.anisotropyRotation=e.anisotropyRotation,s.extensions=s.extensions||{},s.extensions[this.name]=t,i[this.name]=!0}},re=class{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(e,s){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;let i=this.writer.extensionsUsed,t={};t.emissiveStrength=e.emissiveIntensity,s.extensions=s.extensions||{},s.extensions[this.name]=t,i[this.name]=!0}},oe=class{constructor(e){this.writer=e,this.name="EXT_materials_bump"}async writeMaterialAsync(e,s){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;let r=this.writer,i=r.extensionsUsed,t={};if(e.bumpMap){let n={index:await r.processTextureAsync(e.bumpMap),texCoord:e.bumpMap.channel};r.applyTextureTransform(n,e.bumpMap),t.bumpTexture=n}t.bumpFactor=e.bumpScale,s.extensions=s.extensions||{},s.extensions[this.name]=t,i[this.name]=!0}},ae=class{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,s){if(!e.isInstancedMesh)return;let r=this.writer,i=e,t=new Float32Array(i.count*3),n=new Float32Array(i.count*4),o=new Float32Array(i.count*3),a=new G,h=new z,u=new Re,l=new z;for(let f=0;f<i.count;f++)i.getMatrixAt(f,a),a.decompose(h,u,l),h.toArray(t,f*3),u.toArray(n,f*4),l.toArray(o,f*3);let x={TRANSLATION:r.processAccessor(new b(t,3)),ROTATION:r.processAccessor(new b(n,4)),SCALE:r.processAccessor(new b(o,3))};i.instanceColor&&(x._COLOR_0=r.processAccessor(i.instanceColor)),s.extensions=s.extensions||{},s.extensions[this.name]={attributes:x},r.extensionsUsed[this.name]=!0,r.extensionsRequired[this.name]=!0}};L.Utils={insertKeyframe:function(c,e){let r=c.getValueSize(),i=new c.TimeBufferType(c.times.length+1),t=new c.ValueBufferType(c.values.length+r),n=c.createInterpolant(new c.ValueBufferType(r)),o;if(c.times.length===0){i[0]=e;for(let a=0;a<r;a++)t[a]=0;o=0}else if(e<c.times[0]){if(Math.abs(c.times[0]-e)<.001)return 0;i[0]=e,i.set(c.times,1),t.set(n.evaluate(e),0),t.set(c.values,r),o=0}else if(e>c.times[c.times.length-1]){if(Math.abs(c.times[c.times.length-1]-e)<.001)return c.times.length-1;i[i.length-1]=e,i.set(c.times,0),t.set(c.values,0),t.set(n.evaluate(e),c.values.length),o=i.length-1}else for(let a=0;a<c.times.length;a++){if(Math.abs(c.times[a]-e)<.001)return a;if(c.times[a]<e&&c.times[a+1]>e){i.set(c.times.slice(0,a+1),0),i[a+1]=e,i.set(c.times.slice(a+1),a+2),t.set(c.values.slice(0,(a+1)*r),0),t.set(n.evaluate(e),(a+1)*r),t.set(c.values.slice((a+1)*r),(a+2)*r),o=a+1;break}}return c.times=i,c.values=t,o},mergeMorphTargetTracks:function(c,e){let s=[],r={},i=c.tracks;for(let t=0;t<i.length;++t){let n=i[t],o=P.parseTrackName(n.name),a=P.findNode(e,o.nodeName);if(o.propertyName!=="morphTargetInfluences"||o.propertyIndex===void 0){s.push(n);continue}if(n.createInterpolant!==n.InterpolantFactoryMethodDiscrete&&n.createInterpolant!==n.InterpolantFactoryMethodLinear){if(n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),n=n.clone(),n.setInterpolation(Me)}let h=a.morphTargetInfluences.length,u=a.morphTargetDictionary[o.propertyIndex];if(u===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+o.propertyIndex);let l;if(r[a.uuid]===void 0){l=n.clone();let f=new l.ValueBufferType(h*l.times.length);for(let d=0;d<l.times.length;d++)f[d*h+u]=l.values[d];l.name=(o.nodeName||"")+".morphTargetInfluences",l.values=f,r[a.uuid]=l,s.push(l);continue}let x=n.createInterpolant(new n.ValueBufferType(1));l=r[a.uuid];for(let f=0;f<l.times.length;f++)l.values[f*h+u]=x.evaluate(l.times[f]);for(let f=0;f<n.times.length;f++){let d=this.insertKeyframe(l,n.times[f]);l.values[d*h+u]=n.values[f]}}return c.tracks=s,c},toTypedBufferAttribute:function(c,e){let s=new b(new e(c.count*c.itemSize),c.itemSize,!1);if(!c.normalized&&!c.isInterleavedBufferAttribute)return s.array.set(c.array),s;for(let r=0,i=c.count;r<i;r++)for(let t=0;t<c.itemSize;t++)s.setComponent(r,t,c.getComponent(r,t));return s}};export{L as GLTFExporter};
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.