vendor: 12,515 bytes, line 1
1import{Color as ee,Matrix4 as j,Vector3 as z,Quaternion as se,BufferAttribute as b,REVISION as te,CompressedTexture as O,Source as K,NoColorSpace as ne,MathUtils as V,RGBAFormat as ie,ImageUtils as re,DoubleSide as oe,PropertyBinding as B,InterpolateDiscrete as ae,Scene as q,SRGBColorSpace as ce,NearestFilter as le,NearestMipmapNearestFilter as ue,NearestMipmapLinearFilter as he,LinearFilter as fe,LinearMipmapNearestFilter as pe,LinearMipmapLinearFilter as de,ClampToEdgeWrapping as xe,RepeatWrapping as ye,MirroredRepeatWrapping as ge,InterpolateLinear as Te}from"./PDSP0dbZ.js";const W={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.textureUtils=null,this.pluginCallbacks=[],this.register(function(e){return new _e(e)}),this.register(function(e){return new be(e)}),this.register(function(e){return new ve(e)}),this.register(function(e){return new Oe(e)}),this.register(function(e){return new De(e)}),this.register(function(e){return new ze(e)}),this.register(function(e){return new Ce(e)}),this.register(function(e){return new Ue(e)}),this.register(function(e){return new Fe(e)}),this.register(function(e){return new Be(e)}),this.register(function(e){return new Pe(e)}),this.register(function(e){return new Ge(e)}),this.register(function(e){return new ke(e)}),this.register(function(e){return new He(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){const t=new Se,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){const r=this;return new Promise(function(i,t){r.parse(e,i,t,s)})}}const T={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},G="KHR_mesh_quantization",N={};N[le]=T.NEAREST;N[ue]=T.NEAREST_MIPMAP_NEAREST;N[he]=T.NEAREST_MIPMAP_LINEAR;N[fe]=T.LINEAR;N[pe]=T.LINEAR_MIPMAP_NEAREST;N[de]=T.LINEAR_MIPMAP_LINEAR;N[xe]=T.CLAMP_TO_EDGE;N[ye]=T.REPEAT;N[ge]=T.MIRRORED_REPEAT;const X={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},we=new ee,J=12,me=1179937895,Ae=2,Z=8,Me=1313821514,Ee=5130562;function S(c,e){return c.length===e.length&&c.every(function(s,r){return s===e[r]})}function Ie(c){return new TextEncoder().encode(c).buffer}function Re(c){return S(c.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Ne(c,e,s){const 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=V.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 Q(c){return Math.ceil(c/4)*4}function k(c,e=0){const s=Q(c.byteLength);if(s!==c.byteLength){const 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 H(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function Le(c,e){if(typeof OffscreenCanvas<"u"&&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))}class Se{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"+te}},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);const i=this,t=i.buffers,n=i.json;r=i.options;const o=i.extensionsUsed,a=i.extensionsRequired,h=new Blob(t,{type:"application/octet-stream"}),l=Object.keys(o),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=h.size),r.binary===!0){const x=new FileReader;x.readAsArrayBuffer(h),x.onloadend=function(){const f=k(x.result),d=new DataView(new ArrayBuffer(Z));d.setUint32(0,f.byteLength,!0),d.setUint32(4,Ee,!0);const p=k(Ie(JSON.stringify(n)),32),y=new DataView(new ArrayBuffer(Z));y.setUint32(0,p.byteLength,!0),y.setUint32(4,Me,!0);const m=new ArrayBuffer(J),M=new DataView(m);M.setUint32(0,me,!0),M.setUint32(4,Ae,!0);const _=J+y.byteLength+p.byteLength+d.byteLength+f.byteLength;M.setUint32(8,_,!0);const g=new Blob([m,y,p,d,f],{type:"application/octet-stream"}),w=new FileReader;w.readAsArrayBuffer(g),w.onloadend=function(){s(w.result)}}}else if(n.buffers&&n.buffers.length>0){const x=new FileReader;x.readAsDataURL(h),x.onloadend=function(){const f=x.result;n.buffers[0].uri=f,s(n)}}else s(n)}serializeUserData(e,s){if(Object.keys(e.userData).length===0)return;const r=this.options,i=this.extensionsUsed;try{const t=JSON.parse(JSON.stringify(e.userData));if(r.includeCustomExtensions&&t.gltfExtensions){s.extensions===void 0&&(s.extensions={});for(const 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){const 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;const 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){const s=this.cache;if(s.attributesNormalized.has(e))return s.attributesNormalized.get(e);const 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;const 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===ce?function(p){return p<.04045?p*.0773993808:Math.pow(p*.9478672986+.0521327014,2.4)}:function(p){return p}}e instanceof O&&(e=await this.decompressTextureAsync(e)),s instanceof O&&(s=await this.decompressTextureAsync(s));const 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=H();a.width=n,a.height=o;const h=a.getContext("2d",{willReadFrequently:!0});h.fillStyle="#00ffff",h.fillRect(0,0,n,o);const l=h.getImageData(0,0,n,o);if(i){h.drawImage(i,0,0,n,o);const f=r(e),d=h.getImageData(0,0,n,o).data;for(let p=2;p<d.length;p+=4)l.data[p]=f(d[p]/256)*256}if(t){h.drawImage(t,0,0,n,o);const f=r(s),d=h.getImageData(0,0,n,o).data;for(let p=1;p<d.length;p+=4)l.data[p]=f(d[p]/256)*256}h.putImageData(l,0,0);const x=(e||s).clone();return x.source=new K(a),x.colorSpace=ne,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 O&&(e=await this.decompressTextureAsync(e));const i=e.image,t=H();t.width=i.width,t.height=i.height;const n=t.getContext("2d",{willReadFrequently:!0});n.drawImage(i,0,0,t.width,t.height);const o=n.getImageData(0,0,t.width,t.height),a=o.data;for(let l=0;l<a.length;l+=4)s&&(a[l+0]=255-a[l+0]),r&&(a[l+1]=255-a[l+1]);n.putImageData(o,0,0);const h=e.clone();return h.source=new K(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){const s=this.json,r=this.buffers;return s.buffers||(s.buffers=[{byteLength:0}]),r.push(e),0}processBufferView(e,s,r,i,t){const n=this.json;n.bufferViews||(n.bufferViews=[]);let o;switch(s){case T.BYTE:case T.UNSIGNED_BYTE:o=1;break;case T.SHORT:case T.UNSIGNED_SHORT:o=2;break;default:o=4}let a=e.itemSize*o;t===T.ARRAY_BUFFER&&(a=Math.ceil(a/4)*4);const h=Q(i*a),l=new DataView(new ArrayBuffer(h));let u=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=V.normalize(y,e.array))),s===T.FLOAT?l.setFloat32(u,y,!0):s===T.INT?l.setInt32(u,y,!0):s===T.UNSIGNED_INT?l.setUint32(u,y,!0):s===T.SHORT?l.setInt16(u,y,!0):s===T.UNSIGNED_SHORT?l.setUint16(u,y,!0):s===T.BYTE?l.setInt8(u,y):s===T.UNSIGNED_BYTE&&l.setUint8(u,y),u+=o}u%a!==0&&(u+=a-u%a)}const x={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:h};return t!==void 0&&(x.target=t),t===T.ARRAY_BUFFER&&(x.byteStride=a),this.byteOffset+=h,n.bufferViews.push(x),{id:n.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const s=this,r=s.json;return r.bufferViews||(r.bufferViews=[]),new Promise(function(i){const t=new FileReader;t.readAsArrayBuffer(e),t.onloadend=function(){const 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){const t=this.json,n={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"};let o;if(e.array.constructor===Float32Array)o=T.FLOAT;else if(e.array.constructor===Int32Array)o=T.INT;else if(e.array.constructor===Uint32Array)o=T.UNSIGNED_INT;else if(e.array.constructor===Int16Array)o=T.SHORT;else if(e.array.constructor===Uint16Array)o=T.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)o=T.BYTE;else if(e.array.constructor===Uint8Array)o=T.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;const a=Ne(e,r,i);let h;s!==void 0&&(h=e===s.index?T.ELEMENT_ARRAY_BUFFER:T.ARRAY_BUFFER);const l=this.processBufferView(e,o,r,i,h),u={bufferView:l.id,byteOffset:l.byteOffset,componentType:o,count:i,max:a.max,min:a.min,type:n[e.itemSize]};return e.normalized===!0&&(u.normalized=!0),t.accessors||(t.accessors=[]),t.accessors.push(u)-1}processImage(e,s,r,i="image/png"){if(e!==null){const t=this,n=t.cache,o=t.json,a=t.options,h=t.pending;n.images.has(e)||n.images.set(e,{});const l=n.images.get(e),u=i+":flipY/"+r.toString();if(l[u]!==void 0)return l[u];o.images||(o.images=[]);const x={mimeType:i},f=H();f.width=Math.min(e.width,a.maxTextureSize),f.height=Math.min(e.height,a.maxTextureSize);const d=f.getContext("2d",{willReadFrequently:!0});if(r===!0&&(d.translate(0,f.height),d.scale(1,-1)),e.data!==void 0){s!==ie&&console.error("GLTFExporter: Only RGBAFormat is supported.",s),(e.width>a.maxTextureSize||e.height>
1a.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const 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<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&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(Le(f,i).then(y=>t.processBufferViewImage(y)).then(y=>{x.bufferView=y})):x.uri=re.getDataURL(f,i);const p=o.images.push(x)-1;return l[u]=p,p}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const s=this.json;s.samplers||(s.samplers=[]);const 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){const 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 O&&(e=await this.decompressTextureAsync(e,r.maxTextureSize));const 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(l){l.writeTexture&&await l.writeTexture(e,a)});const h=t.textures.push(a)-1;return i.textures.set(e,h),h}async processMaterialAsync(e,s){const 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=[]);const o={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const 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){const l=await this.buildMetalRoughTextureAsync(e.metalnessMap,e.roughnessMap),u={index:await this.processTextureAsync(l),texCoord:l.channel};this.applyTextureTransform(u,l),o.pbrMetallicRoughness.metallicRoughnessTexture=u}if(e.map){const l={index:await this.processTextureAsync(e.map),texCoord:e.map.channel};this.applyTextureTransform(l,e.map),o.pbrMetallicRoughness.baseColorTexture=l}if(e.emissive){const l=e.emissive;if(Math.max(l.r,l.g,l.b)>0&&(o.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const x={index:await this.processTextureAsync(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(x,e.emissiveMap),o.emissiveTexture=x}}if(e.normalMap){const l=e.normalScale,u=l.x<0,x=t?l.y<0:l.y>0;let f=e.normalMap;(u||x)&&(f=await this.buildNormalMapTextureAsync(e.normalMap,u,x));const d={index:await this.processTextureAsync(f),texCoord:e.normalMap.channel};Math.abs(l.x)!==1&&(d.scale=Math.abs(l.x)),this.applyTextureTransform(d,e.normalMap),o.normalTexture=d}if(e.aoMap){const l={index:await this.processTextureAsync(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(l.strength=e.aoMapIntensity),this.applyTextureTransform(l,e.aoMap),o.occlusionTexture=l}e.transparent?o.alphaMode="BLEND":e.alphaTest>0&&(o.alphaMode="MASK",o.alphaCutoff=e.alphaTest),e.side===oe&&(o.doubleSided=!0),e.name!==""&&(o.name=e.name),this.serializeUserData(e,o),await this._invokeAllAsync(async function(l){l.writeMaterialAsync&&await l.writeMaterialAsync(e,o)});const h=i.materials.push(o)-1;return r.materials.set(n,h),h}async processMeshAsync(e){const s=this.cache,r=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let g=0,w=e.material.length;g<w;g++)i.push(e.material[g].uuid);else i.push(e.material.uuid);const t=i.join(":");if(s.meshes.has(t))return s.meshes.get(t);const n=e.geometry;let o;e.isLineSegments?o=T.LINES:e.isLineLoop?o=T.LINE_LOOP:e.isLine?o=T.LINE_STRIP:e.isPoints?o=T.POINTS:o=e.material.wireframe?T.LINES:T.TRIANGLES;const a={},h={},l=[],u=[],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,967 bytes, line 1
1for(let g in n.attributes){if(g.slice(0,5)==="morph")continue;const w=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(w))){h[g]=s.attributes.get(this.getUID(w));continue}d=null;const A=w.array;g==="JOINTS_0"&&!(A instanceof Uint16Array)&&!(A instanceof Uint8Array)?(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),d=D.Utils.toTypedBufferAttribute(w,Uint16Array)):(A instanceof Uint32Array||A instanceof Int32Array)&&!g.startsWith("_")&&(console.warn(`GLTFExporter: Attribute "${g}" converted to type FLOAT.`),d=D.Utils.toTypedBufferAttribute(w,Float32Array));const R=this.processAccessor(d||w,n);R!==null&&(g.startsWith("_")||this.detectMeshQuantization(g,w),h[g]=R,s.attributes.set(this.getUID(w),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){const g=[],w=[],E={};if(e.morphTargetDictionary!==void 0)for(const A in e.morphTargetDictionary)E[e.morphTargetDictionary[A]]=A;for(let A=0;A<e.morphTargetInfluences.length;++A){const R={};let Y=!1;for(const U in n.morphAttributes){if(U!=="position"&&U!=="normal"){Y||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),Y=!0);continue}const L=n.morphAttributes[U][A],P=U.toUpperCase(),F=n.attributes[U];if(s.attributes.has(this.getUID(L,!0))){R[P]=s.attributes.get(this.getUID(L,!0));continue}const v=L.clone();if(!n.morphTargetsRelative)for(let I=0,$=L.count;I<$;I++)for(let C=0;C<L.itemSize;C++)C===0&&v.setX(I,L.getX(I)-F.getX(I)),C===1&&v.setY(I,L.getY(I)-F.getY(I)),C===2&&v.setZ(I,L.getZ(I)-F.getZ(I)),C===3&&v.setW(I,L.getW(I)-F.getW(I));R[P]=this.processAccessor(v,n),s.attributes.set(this.getUID(F,!0),R[P])}u.push(R),g.push(e.morphTargetInfluences[A]),e.morphTargetDictionary!==void 0&&w.push(E[A])}a.weights=g,w.length>0&&(a.extras={},a.extras.targetNames=w)}const p=Array.isArray(e.material);if(p&&n.groups.length===0)return null;let y=!1;if(p&&n.index===null){const g=[];for(let w=0,E=n.attributes.position.count;w<E;w++)g[w]=w;n.setIndex(g),y=!0}const m=p?e.material:[e.material],M=p?n.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let g=0,w=M.length;g<w;g++){const E={mode:o,attributes:h};if(this.serializeUserData(n,E),u.length>0&&(E.targets=u),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)?E.indices=s.attributes.get(R):(E.indices=this.processAccessor(n.index,n,M[g].start,M[g].count),s.attributes.set(R,E.indices)),E.indices===null&&delete E.indices}const A=await this.processMaterialAsync(m[M[g].materialIndex],n);A!==null&&(E.material=A),l.push(E)}y===!0&&n.setIndex(null),a.primitives=l,r.meshes||(r.meshes=[]),await this._invokeAllAsync(function(g){g.writeMesh&&g.writeMesh(e,a)});const _=r.meshes.push(a)-1;return s.meshes.set(t,_),_}detectMeshQuantization(e,s){if(this.extensionsUsed[G])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");const i=e.split("_",1)[0];W[i]&&W[i].includes(r)&&(this.extensionsUsed[G]=!0,this.extensionsRequired[G]=!0)}processCamera(e){const s=this.json;s.cameras||(s.cameras=[]);const 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:V.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){const r=this.json,i=this.nodeMap;r.animations||(r.animations=[]),e=D.Utils.mergeMorphTargetTracks(e.clone(),s);const t=e.tracks,n=[],o=[];for(let h=0;h<t.length;++h){const l=t[h],u=B.parseTrackName(l.name);let x=B.findNode(s,u.nodeName);const f=X[u.propertyName];if(u.objectName==="bones"&&(x.isSkinnedMesh===!0?x=x.skeleton.getBoneByName(u.objectIndex):x=void 0),!x||!f){console.warn('THREE.GLTFExporter: Could not export animation track "%s".',l.name);continue}const d=1;let p=l.values.length/l.times.length;f===X.morphTargetInfluences&&(p/=x.morphTargetInfluences.length);let y;l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(y="CUBICSPLINE",p/=3):l.getInterpolation()===ae?y="STEP":y="LINEAR",o.push({input:this.processAccessor(new b(l.times,d)),output:this.processAccessor(new b(l.values,p)),interpolation:y}),n.push({sampler:o.length-1,target:{node:i.get(x),path:f}})}const 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){const s=this.json,r=this.nodeMap,i=s.nodes[r.get(e)],t=e.skeleton;if(t===void 0)return null;const n=e.skeleton.bones[0];if(n===void 0)return null;const o=[],a=new Float32Array(t.bones.length*16),h=new j;for(let u=0;u<t.bones.length;++u)o.push(r.get(t.bones[u])),h.copy(t.boneInverses[u]),h.multiply(e.bindMatrix).toArray(a,u*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){const s=this.json,r=this.options,i=this.nodeMap;if(s.nodes||(s.nodes=[]),e.pivot!==null)return await this._processNodeWithPivotAsync(e);const t={};if(r.trs){const 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(),Re(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){const o=await this.processMeshAsync(e);o!==null&&(t.mesh=o)}else e.isCamera&&(t.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);const n=s.nodes.push(t)-1;if(i.set(e,n),e.children.length>0){const o=[];for(let a=0,h=e.children.length;a<h;a++){const l=e.children[a];if(l.visible||r.onlyVisible===!1){const u=await this.processNodeAsync(l);u!==null&&o.push(u)}}o.length>0&&(t.children=o)}return await this._invokeAllAsync(function(o){o.writeNode&&o.writeNode(e,t)}),n}async _processNodeWithPivotAsync(e){const 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);const l=s.nodes.push(n)-1;i.set(e,l);const u={},x=[-t.x,-t.y,-t.z];if(S(x,[0,0,0])||(u.translation=x),e.isMesh||e.isLine||e.isPoints){const p=await this.processMeshAsync(e);p!==null&&(u.mesh=p)}else e.isCamera&&(u.camera=this.processCamera(e));e.isSkinnedMesh&&this.skins.push(e);const d=[s.nodes.push(u)-1];if(e.children.length>0){const p=[];for(let y=0,m=e.children.length;y<m;y++){const M=e.children[y];if(M.visible||r.onlyVisible===!1){const _=await this.processNodeAsync(M);_!==null&&p.push(_)}}p.length>0&&(u.children=p)}return n.children=d,await this._invokeAllAsync(function(p){p.writeNode&&p.writeNode(e,n)}),l}async processSceneAsync(e){const s=this.json,r=this.options;s.scenes||(s.scenes=[],s.scene=0);const i={};e.name!==""&&(i.name=e.name),s.scenes.push(i);const t=[];for(let n=0,o=e.children.length;n<o;n++){const a=e.children[n];if(a.visible||r.onlyVisible===!1){const h=await this.processNodeAsync(a);h!==null&&t.push(h)}}t.length>0&&(i.nodes=t),this.serializeUserData(e,i)}async processObjectsAsync(e){const s=new q;s.name="AuxScene";for(let r=0;r<e.length;r++)s.children.push(e[r]);await this.processSceneAsync(s)}async processInputAsync(e){const s=this.options;e=e instanceof Array?e:[e],await this._invokeAllAsync(function(i){i.beforeParse&&i.beforeParse(e)});const r=[];for(let i=0;i<e.length;i++)e[i]instanceof q?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++){const 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])}}class _e{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}const 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);const o=i.extensions[this.name].lights;o.push(n),s.extensions=s.extensions||{},s.extensions[this.name]={light:o.length-1}}}class be{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}async writeMaterialAsync(e,s){if(!e.isMeshBasicMaterial)return;const i=this.writer.extensionsUsed;s.extensions=s.extensions||{},s.extensions[this.name]={},i[this.name]=!0,s.pbrMetallicRoughness.metallicFactor=0,s.pbrMetallicRoughness.roughnessFactor=.9}}class Ce{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;const r=this.writer,i=r.extensionsUsed,t={};if(t.clearcoatFactor=e.clearcoat,e.clearcoatMap){const 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){const n={index:await r.processTextureAsync(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};r.applyTextureTransform(n,e.clearcoatRoughnessMap),t.clearcoatRoughnessTexture=n}if(e.clearcoatNormalMap){const 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}}class Ue{constructor(e){this.writer=e,this.name="KHR_materials_dispersion"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.dispersion===0)return;const i=this.writer.extensionsUsed,t={};t.dispersion=e.dispersion,s.extensions=s.extensions||{},s.extensions[this.name]=t,i[this.name]=!0}}class Fe{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;const r=this.writer,i=r.extensionsUsed,t={};if(t.iridescenceFactor=e.iridescence,e.iridescenceMap){const 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){const 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 ve{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const r=this.writer,i=r.extensionsUsed,t={};if(t.transmissionFactor=e.transmission,e.transmissionMap){const 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}}class Oe{constructor(e){this.writer=e,this.name="KHR_materials_volume"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const r=this.writer,i=r.extensionsUsed,t={};if(t.thicknessFactor=e.thickness,e.thicknessMap){const 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}}class De{constructor(e){this.writer=e,this.name="KHR_materials_ior"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;const i=this.writer.extensionsUsed,t={};t.ior=e.ior,s.extensions=s.extensions||{},s.extensions[this.name]=t,i[this.name]=!0}}class ze{constructor(e){this.writer=e,this.name="KHR_materials_specular"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(we)&&!e.specularIntensityMap&&!e.specularColorMap)return;const r=this.writer,i=r.extensionsUsed,t={};if(e.specularIntensityMap){const n={index:await r.processTextureAsync(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};r.applyTextureTransform(n,e.specularIntensityMap),t.specularTexture=n}if(e.specularColorMap){const 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}}class Be{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;const r=this.writer,i=r.extensionsUsed,t={};if(e.sheenRoughnessMap){const n={index:await r.processTextureAsync(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};r.applyTextureTransform(n,e.sheenRoughnessMap),t.sheenRoughnessTexture=n}if(e.sheenColorMap){const 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}}class Pe{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}async writeMaterialAsync(e,s){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;const r=this.writer,i=r.extensionsUsed,t={};if(e.anisotropyMap){const 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}}class Ge{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}async writeMaterialAsync(e,s){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;const i=this.writer.extensionsUsed,t={};t.emissiveStrength=e.emissiveIntensity,s.extensions=s.extensions||{},s.extensions[this.name]=t,i[this.name]=!0}}class ke{constructor(e){this.writer=e,this.name="EXT_materials_bump"}async writeMaterialAsync(e,s){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;const r=this.writer,i=r.extensionsUsed,t={};if(e.bumpMap){const 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}}class He{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,s){if(!e.isInstancedMesh)return;const 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 j,h=new z,l=new se,u=new z;for(let f=0;f<i.count;f++)i.getMatrixAt(f,a),a.decompose(h,l,u),h.toArray(t,f*3),l.toArray(n,f*4),u.toArray(o,f*3);const 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}}D.Utils={insertKeyframe:function(c,e){const 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));let 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){const s=[],r={},i=c.tracks;for(let t=0;t<i.length;++t){let n=i[t];const o=B.parseTrackName(n.name),a=B.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(Te)}const h=a.morphTargetInfluences.length,l=a.morphTargetDictionary[o.propertyIndex];if(l===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+o.propertyIndex);let u;if(r[a.uuid]===void 0){u=n.clone();const f=new u.ValueBufferType(h*u.times.length);for(let d=0;d<u.times.length;d++)f[d*h+l]=u.values[d];u.name=(o.nodeName||"")+".morphTargetInfluences",u.values=f,r[a.uuid]=u,s.push(u);continue}const x=n.createInterpolant(new n.ValueBufferType(1));u=r[a.uuid];for(let f=0;f<u.times.length;f++)u.values[f*h+l]=x.evaluate(u.times[f]);for(let f=0;f<n.times.length;f++){const d=this.insertKeyframe(u,n.times[f]);u.values[d*h+l]=n.values[f]}}return c.tracks=s,c},toTypedBufferAttribute:function(c,e){const 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{D 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.