@vctrl/hooks 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{_commonjsHelpers-DZAafUiT.cjs → _commonjsHelpers-BKV1RZto.cjs} +2 -2
- package/{_commonjsHelpers-CT5_WOk_.js → _commonjsHelpers-BbdAOH3u.js} +18 -18
- package/index.cjs.js +1 -1
- package/index.es.js +2 -2
- package/model-context-BmfXsk0j.cjs +9 -0
- package/{model-context-Bvjdyghq.js → model-context-qjRd1gfd.js} +358 -353
- package/package.json +11 -1
- package/use-export-model.cjs.js +1 -1
- package/use-export-model.es.js +1 -1
- package/use-load-model.cjs.js +1 -1
- package/use-load-model.es.js +1 -1
- package/use-optimize-model-BXIlJ5Yx.cjs +20 -0
- package/use-optimize-model-BpcR9d1L.js +10037 -0
- package/use-optimize-model.cjs.js +1 -1
- package/use-optimize-model.es.js +1 -1
- package/model-context-BBYdA-gO.cjs +0 -9
- package/three.module-7bSgh1t6.js +0 -16071
- package/three.module-C5-FOeun.cjs +0 -3841
- package/use-optimize-model-DMZVYv9U.cjs +0 -20
- package/use-optimize-model-DRrg3MLA.js +0 -9954
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const f=require("
|
|
1
|
+
"use strict";const f=require("three");let v,P,_,G;function z(a,e=1/0,t=null){P||(P=new f.PlaneGeometry(2,2,1,1)),_||(_=new f.ShaderMaterial({uniforms:{blitTexture:new f.Uniform(a)},vertexShader:`
|
|
2
2
|
varying vec2 vUv;
|
|
3
3
|
void main(){
|
|
4
4
|
vUv = uv;
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
#else
|
|
16
16
|
gl_FragColor = texture2D( blitTexture, vUv);
|
|
17
17
|
#endif
|
|
18
|
-
}`})),_.uniforms.blitTexture.value=a,_.defines.IS_SRGB=a.colorSpace==f.SRGBColorSpace,_.needsUpdate=!0,G||(G=new f.Mesh(D,_),G.frustumCulled=!1);const r=new f.PerspectiveCamera,s=new f.Scene;s.add(G),t===null&&(t=v=new f.WebGLRenderer({antialias:!1}));const i=Math.min(a.image.width,e),n=Math.min(a.image.height,e);t.setSize(i,n),t.clear(),t.render(s,r);const o=document.createElement("canvas"),c=o.getContext("2d");o.width=i,o.height=n,c.drawImage(t.domElement,0,0,i,n);const l=new f.CanvasTexture(o);return l.minFilter=a.minFilter,l.magFilter=a.magFilter,l.wrapS=a.wrapS,l.wrapT=a.wrapT,l.name=a.name,v&&(v.forceContextLoss(),v.dispose(),v=null),l}const Y={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 V{constructor(){this.pluginCallbacks=[],this.register(function(e){return new ce(e)}),this.register(function(e){return new le(e)}),this.register(function(e){return new pe(e)}),this.register(function(e){return new de(e)}),this.register(function(e){return new xe(e)}),this.register(function(e){return new ge(e)}),this.register(function(e){return new ue(e)}),this.register(function(e){return new fe(e)}),this.register(function(e){return new he(e)}),this.register(function(e){return new Te(e)}),this.register(function(e){return new me(e)}),this.register(function(e){return new ye(e)}),this.register(function(e){return new Me(e)}),this.register(function(e){return new we(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}parse(e,t,r,s){const i=new ae,n=[];for(let o=0,c=this.pluginCallbacks.length;o<c;o++)n.push(this.pluginCallbacks[o](i));i.setPlugins(n),i.write(e,t,s).catch(r)}parseAsync(e,t){const r=this;return new Promise(function(s,i){r.parse(e,s,i,t)})}}const m={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},k="KHR_mesh_quantization",b={};b[f.NearestFilter]=m.NEAREST;b[f.NearestMipmapNearestFilter]=m.NEAREST_MIPMAP_NEAREST;b[f.NearestMipmapLinearFilter]=m.NEAREST_MIPMAP_LINEAR;b[f.LinearFilter]=m.LINEAR;b[f.LinearMipmapNearestFilter]=m.LINEAR_MIPMAP_NEAREST;b[f.LinearMipmapLinearFilter]=m.LINEAR_MIPMAP_LINEAR;b[f.ClampToEdgeWrapping]=m.CLAMP_TO_EDGE;b[f.RepeatWrapping]=m.REPEAT;b[f.MirroredRepeatWrapping]=m.MIRRORED_REPEAT;const K={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},$=new f.Color,q=12,ee=1179937895,te=2,W=8,se=1313821514,ne=5130562;function O(a,e){return a.length===e.length&&a.every(function(t,r){return t===e[r]})}function ie(a){return new TextEncoder().encode(a).buffer}function re(a){return O(a.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function oe(a,e,t){const r={min:new Array(a.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(a.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let s=e;s<e+t;s++)for(let i=0;i<a.itemSize;i++){let n;a.itemSize>4?n=a.array[s*a.itemSize+i]:(i===0?n=a.getX(s):i===1?n=a.getY(s):i===2?n=a.getZ(s):i===3&&(n=a.getW(s)),a.normalized===!0&&(n=f.MathUtils.normalize(n,a.array))),r.min[i]=Math.min(r.min[i],n),r.max[i]=Math.max(r.max[i],n)}return r}function Q(a){return Math.ceil(a/4)*4}function H(a,e=0){const t=Q(a.byteLength);if(t!==a.byteLength){const r=new Uint8Array(t);if(r.set(new Uint8Array(a)),e!==0)for(let s=a.byteLength;s<t;s++)r[s]=e;return r.buffer}return a}function X(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function J(a,e){if(a.toBlob!==void 0)return new Promise(r=>a.toBlob(r,e));let t;return e==="image/jpeg"?t=.92:e==="image/webp"&&(t=.8),a.convertToBlob({type:e,quality:t})}class ae{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"+f.REVISION}},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);const s=this,i=s.buffers,n=s.json;r=s.options;const o=s.extensionsUsed,c=s.extensionsRequired,l=new Blob(i,{type:"application/octet-stream"}),p=Object.keys(o),u=Object.keys(c);if(p.length>0&&(n.extensionsUsed=p),u.length>0&&(n.extensionsRequired=u),n.buffers&&n.buffers.length>0&&(n.buffers[0].byteLength=l.size),r.binary===!0){const y=new FileReader;y.readAsArrayBuffer(l),y.onloadend=function(){const h=H(y.result),d=new DataView(new ArrayBuffer(W));d.setUint32(0,h.byteLength,!0),d.setUint32(4,ne,!0);const x=H(ie(JSON.stringify(n)),32),T=new DataView(new ArrayBuffer(W));T.setUint32(0,x.byteLength,!0),T.setUint32(4,se,!0);const w=new ArrayBuffer(q),N=new DataView(w);N.setUint32(0,ee,!0),N.setUint32(4,te,!0);const B=q+T.byteLength+x.byteLength+d.byteLength+h.byteLength;N.setUint32(8,B,!0);const g=new Blob([w,T,x,d,h],{type:"application/octet-stream"}),M=new FileReader;M.readAsArrayBuffer(g),M.onloadend=function(){t(M.result)}}}else if(n.buffers&&n.buffers.length>0){const y=new FileReader;y.readAsDataURL(l),y.onloadend=function(){const h=y.result;n.buffers[0].uri=h,t(n)}}else t(n)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;const r=this.options,s=this.extensionsUsed;try{const i=JSON.parse(JSON.stringify(e.userData));if(r.includeCustomExtensions&&i.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(const n in i.gltfExtensions)t.extensions[n]=i.gltfExtensions[n],s[n]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.extras=i)}catch(i){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+i.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){const s=new Map;s.set(!0,this.uid++),s.set(!1,this.uid++),this.uids.set(e,s)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const r=new f.Vector3;for(let s=0,i=e.count;s<i;s++)if(Math.abs(r.fromBufferAttribute(e,s).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const r=e.clone(),s=new f.Vector3;for(let i=0,n=r.count;i<n;i++)s.fromBufferAttribute(r,i),s.x===0&&s.y===0&&s.z===0?s.setX(1):s.normalize(),r.setXYZ(i,s.x,s.y,s.z);return t.attributesNormalized.set(e,r),r}applyTextureTransform(e,t){let r=!1;const s={};(t.offset.x!==0||t.offset.y!==0)&&(s.offset=t.offset.toArray(),r=!0),t.rotation!==0&&(s.rotation=t.rotation,r=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(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(h){return h.colorSpace===f.SRGBColorSpace?function(x){return x<.04045?x*.0773993808:Math.pow(x*.9478672986+.0521327014,2.4)}:function(x){return x}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof f.CompressedTexture&&(e=z(e)),t instanceof f.CompressedTexture&&(t=z(t));const s=e?e.image:null,i=t?t.image:null,n=Math.max(s?s.width:0,i?i.width:0),o=Math.max(s?s.height:0,i?i.height:0),c=X();c.width=n,c.height=o;const l=c.getContext("2d",{willReadFrequently:!0});l.fillStyle="#00ffff",l.fillRect(0,0,n,o);const p=l.getImageData(0,0,n,o);if(s){l.drawImage(s,0,0,n,o);const h=r(e),d=l.getImageData(0,0,n,o).data;for(let x=2;x<d.length;x+=4)p.data[x]=h(d[x]/256)*256}if(i){l.drawImage(i,0,0,n,o);const h=r(t),d=l.getImageData(0,0,n,o).data;for(let x=1;x<d.length;x+=4)p.data[x]=h(d[x]/256)*256}l.putImageData(p,0,0);const y=(e||t).clone();return y.source=new f.Source(c),y.colorSpace=f.NoColorSpace,y.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),y}processBuffer(e){const t=this.json,r=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),r.push(e),0}processBufferView(e,t,r,s,i){const n=this.json;n.bufferViews||(n.bufferViews=[]);let o;switch(t){case m.BYTE:case m.UNSIGNED_BYTE:o=1;break;case m.SHORT:case m.UNSIGNED_SHORT:o=2;break;default:o=4}let c=e.itemSize*o;i===m.ARRAY_BUFFER&&(c=Math.ceil(c/4)*4);const l=Q(s*c),p=new DataView(new ArrayBuffer(l));let u=0;for(let d=r;d<r+s;d++){for(let x=0;x<e.itemSize;x++){let T;e.itemSize>4?T=e.array[d*e.itemSize+x]:(x===0?T=e.getX(d):x===1?T=e.getY(d):x===2?T=e.getZ(d):x===3&&(T=e.getW(d)),e.normalized===!0&&(T=f.MathUtils.normalize(T,e.array))),t===m.FLOAT?p.setFloat32(u,T,!0):t===m.INT?p.setInt32(u,T,!0):t===m.UNSIGNED_INT?p.setUint32(u,T,!0):t===m.SHORT?p.setInt16(u,T,!0):t===m.UNSIGNED_SHORT?p.setUint16(u,T,!0):t===m.BYTE?p.setInt8(u,T):t===m.UNSIGNED_BYTE&&p.setUint8(u,T),u+=o}u%c!==0&&(u+=c-u%c)}const y={buffer:this.processBuffer(p.buffer),byteOffset:this.byteOffset,byteLength:l};return i!==void 0&&(y.target=i),i===m.ARRAY_BUFFER&&(y.byteStride=c),this.byteOffset+=l,n.bufferViews.push(y),{id:n.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,r=t.json;return r.bufferViews||(r.bufferViews=[]),new Promise(function(s){const i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){const n=H(i.result),o={buffer:t.processBuffer(n),byteOffset:t.byteOffset,byteLength:n.byteLength};t.byteOffset+=n.byteLength,s(r.bufferViews.push(o)-1)}})}processAccessor(e,t,r,s){const i=this.json,n={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"};let o;if(e.array.constructor===Float32Array)o=m.FLOAT;else if(e.array.constructor===Int32Array)o=m.INT;else if(e.array.constructor===Uint32Array)o=m.UNSIGNED_INT;else if(e.array.constructor===Int16Array)o=m.SHORT;else if(e.array.constructor===Uint16Array)o=m.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)o=m.BYTE;else if(e.array.constructor===Uint8Array)o=m.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(r===void 0&&(r=0),(s===void 0||s===1/0)&&(s=e.count),s===0)return null;const c=oe(e,r,s);let l;t!==void 0&&(l=e===t.index?m.ELEMENT_ARRAY_BUFFER:m.ARRAY_BUFFER);const p=this.processBufferView(e,o,r,s,l),u={bufferView:p.id,byteOffset:p.byteOffset,componentType:o,count:s,max:c.max,min:c.min,type:n[e.itemSize]};return e.normalized===!0&&(u.normalized=!0),i.accessors||(i.accessors=[]),i.accessors.push(u)-1}processImage(e,t,r,s="image/png"){if(e!==null){const i=this,n=i.cache,o=i.json,c=i.options,l=i.pending;n.images.has(e)||n.images.set(e,{});const p=n.images.get(e),u=s+":flipY/"+r.toString();if(p[u]!==void 0)return p[u];o.images||(o.images=[]);const y={mimeType:s},h=X();h.width=Math.min(e.width,c.maxTextureSize),h.height=Math.min(e.height,c.maxTextureSize);const d=h.getContext("2d",{willReadFrequently:!0});if(r===!0&&(d.translate(0,h.height),d.scale(1,-1)),e.data!==void 0){t!==f.RGBAFormat&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>c.maxTextureSize||e.height>c.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const T=new Uint8ClampedArray(e.height*e.width*4);for(let w=0;w<T.length;w+=4)T[w+0]=e.data[w+0],T[w+1]=e.data[w+1],T[w+2]=e.data[w+2],T[w+3]=e.data[w+3];d.putImageData(new ImageData(T,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,h.width,h.height);else throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");c.binary===!0?l.push(J(h,s).then(T=>i.processBufferViewImage(T)).then(T=>{y.bufferView=T})):h.toDataURL!==void 0?y.uri=h.toDataURL(s):l.push(J(h,s).then(T=>new FileReader().readAsDataURL(T)).then(T=>{y.uri=T}));const x=o.images.push(y)-1;return p[u]=x,x}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const r={magFilter:b[e.magFilter],minFilter:b[e.minFilter],wrapS:b[e.wrapS],wrapT:b[e.wrapT]};return t.samplers.push(r)-1}processTexture(e){const r=this.options,s=this.cache,i=this.json;if(s.textures.has(e))return s.textures.get(e);i.textures||(i.textures=[]),e instanceof f.CompressedTexture&&(e=z(e,r.maxTextureSize));let n=e.userData.mimeType;n==="image/webp"&&(n="image/png");const o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,n)};e.name&&(o.name=e.name),this._invokeAll(function(l){l.writeTexture&&l.writeTexture(e,o)});const c=i.textures.push(o)-1;return s.textures.set(e,c),c}processMaterial(e){const 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=[]);const s={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const i=e.color.toArray().concat([e.opacity]);if(O(i,[1,1,1,1])||(s.pbrMetallicRoughness.baseColorFactor=i),e.isMeshStandardMaterial?(s.pbrMetallicRoughness.metallicFactor=e.metalness,s.pbrMetallicRoughness.roughnessFactor=e.roughness):(s.pbrMetallicRoughness.metallicFactor=.5,s.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const o=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),c={index:this.processTexture(o),channel:o.channel};this.applyTextureTransform(c,o),s.pbrMetallicRoughness.metallicRoughnessTexture=c}if(e.map){const o={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(o,e.map),s.pbrMetallicRoughness.baseColorTexture=o}if(e.emissive){const o=e.emissive;if(Math.max(o.r,o.g,o.b)>0&&(s.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const l={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(l,e.emissiveMap),s.emissiveTexture=l}}if(e.normalMap){const o={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(o.scale=e.normalScale.x),this.applyTextureTransform(o,e.normalMap),s.normalTexture=o}if(e.aoMap){const o={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(o.strength=e.aoMapIntensity),this.applyTextureTransform(o,e.aoMap),s.occlusionTexture=o}e.transparent?s.alphaMode="BLEND":e.alphaTest>0&&(s.alphaMode="MASK",s.alphaCutoff=e.alphaTest),e.side===f.DoubleSide&&(s.doubleSided=!0),e.name!==""&&(s.name=e.name),this.serializeUserData(e,s),this._invokeAll(function(o){o.writeMaterial&&o.writeMaterial(e,s)});const n=r.materials.push(s)-1;return t.materials.set(e,n),n}processMesh(e){const t=this.cache,r=this.json,s=[e.geometry.uuid];if(Array.isArray(e.material))for(let g=0,M=e.material.length;g<M;g++)s.push(e.material[g].uuid);else s.push(e.material.uuid);const i=s.join(":");if(t.meshes.has(i))return t.meshes.get(i);const n=e.geometry;let o;e.isLineSegments?o=m.LINES:e.isLineLoop?o=m.LINE_LOOP:e.isLine?o=m.LINE_STRIP:e.isPoints?o=m.POINTS:o=e.material.wireframe?m.LINES:m.TRIANGLES;const c={},l={},p=[],u=[],y={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},h=n.getAttribute("normal");h!==void 0&&!this.isNormalizedNormalAttribute(h)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),n.setAttribute("normal",this.createNormalizedNormalAttribute(h)));let d=null;for(let g in n.attributes){if(g.slice(0,5)==="morph")continue;const M=n.attributes[g];if(g=y[g]||g.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(g)||(g="_"+g),t.attributes.has(this.getUID(M))){l[g]=t.attributes.get(this.getUID(M));continue}d=null;const I=M.array;g==="JOINTS_0"&&!(I instanceof Uint16Array)&&!(I instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),d=new f.BufferAttribute(new Uint16Array(I),M.itemSize,M.normalized));const R=this.processAccessor(d||M,n);R!==null&&(g.startsWith("_")||this.detectMeshQuantization(g,M),l[g]=R,t.attributes.set(this.getUID(M),R))}if(h!==void 0&&n.setAttribute("normal",h),Object.keys(l).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const g=[],M=[],E={};if(e.morphTargetDictionary!==void 0)for(const I in e.morphTargetDictionary)E[e.morphTargetDictionary[I]]=I;for(let I=0;I<e.morphTargetInfluences.length;++I){const R={};let j=!1;for(const C in n.morphAttributes){if(C!=="position"&&C!=="normal"){j||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),j=!0);continue}const S=n.morphAttributes[C][I],P=C.toUpperCase(),U=n.attributes[C];if(t.attributes.has(this.getUID(S,!0))){R[P]=t.attributes.get(this.getUID(S,!0));continue}const F=S.clone();if(!n.morphTargetsRelative)for(let A=0,Z=S.count;A<Z;A++)for(let L=0;L<S.itemSize;L++)L===0&&F.setX(A,S.getX(A)-U.getX(A)),L===1&&F.setY(A,S.getY(A)-U.getY(A)),L===2&&F.setZ(A,S.getZ(A)-U.getZ(A)),L===3&&F.setW(A,S.getW(A)-U.getW(A));R[P]=this.processAccessor(F,n),t.attributes.set(this.getUID(U,!0),R[P])}u.push(R),g.push(e.morphTargetInfluences[I]),e.morphTargetDictionary!==void 0&&M.push(E[I])}c.weights=g,M.length>0&&(c.extras={},c.extras.targetNames=M)}const x=Array.isArray(e.material);if(x&&n.groups.length===0)return null;let T=!1;if(x&&n.index===null){const g=[];for(let M=0,E=n.attributes.position.count;M<E;M++)g[M]=M;n.setIndex(g),T=!0}const w=x?e.material:[e.material],N=x?n.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let g=0,M=N.length;g<M;g++){const E={mode:o,attributes:l};if(this.serializeUserData(n,E),u.length>0&&(E.targets=u),n.index!==null){let R=this.getUID(n.index);(N[g].start!==void 0||N[g].count!==void 0)&&(R+=":"+N[g].start+":"+N[g].count),t.attributes.has(R)?E.indices=t.attributes.get(R):(E.indices=this.processAccessor(n.index,n,N[g].start,N[g].count),t.attributes.set(R,E.indices)),E.indices===null&&delete E.indices}const I=this.processMaterial(w[N[g].materialIndex]);I!==null&&(E.material=I),p.push(E)}T===!0&&n.setIndex(null),c.primitives=p,r.meshes||(r.meshes=[]),this._invokeAll(function(g){g.writeMesh&&g.writeMesh(e,c)});const B=r.meshes.push(c)-1;return t.meshes.set(i,B),B}detectMeshQuantization(e,t){if(this.extensionsUsed[k])return;let r;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");const s=e.split("_",1)[0];Y[s]&&Y[s].includes(r)&&(this.extensionsUsed[k]=!0,this.extensionsRequired[k]=!0)}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const r=e.isOrthographicCamera,s={type:r?"orthographic":"perspective"};return r?s.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:s.perspective={aspectRatio:e.aspect,yfov:f.MathUtils.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){const r=this.json,s=this.nodeMap;r.animations||(r.animations=[]),e=V.Utils.mergeMorphTargetTracks(e.clone(),t);const i=e.tracks,n=[],o=[];for(let c=0;c<i.length;++c){const l=i[c],p=f.PropertyBinding.parseTrackName(l.name);let u=f.PropertyBinding.findNode(t,p.nodeName);const y=K[p.propertyName];if(p.objectName==="bones"&&(u.isSkinnedMesh===!0?u=u.skeleton.getBoneByName(p.objectIndex):u=void 0),!u||!y){console.warn('THREE.GLTFExporter: Could not export animation track "%s".',l.name);continue}const h=1;let d=l.values.length/l.times.length;y===K.morphTargetInfluences&&(d/=u.morphTargetInfluences.length);let x;l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(x="CUBICSPLINE",d/=3):l.getInterpolation()===f.InterpolateDiscrete?x="STEP":x="LINEAR",o.push({input:this.processAccessor(new f.BufferAttribute(l.times,h)),output:this.processAccessor(new f.BufferAttribute(l.values,d)),interpolation:x}),n.push({sampler:o.length-1,target:{node:s.get(u),path:y}})}return r.animations.push({name:e.name||"clip_"+r.animations.length,samplers:o,channels:n}),r.animations.length-1}processSkin(e){const t=this.json,r=this.nodeMap,s=t.nodes[r.get(e)],i=e.skeleton;if(i===void 0)return null;const n=e.skeleton.bones[0];if(n===void 0)return null;const o=[],c=new Float32Array(i.bones.length*16),l=new f.Matrix4;for(let u=0;u<i.bones.length;++u)o.push(r.get(i.bones[u])),l.copy(i.boneInverses[u]),l.multiply(e.bindMatrix).toArray(c,u*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new f.BufferAttribute(c,16)),joints:o,skeleton:r.get(n)}),s.skin=t.skins.length-1}processNode(e){const t=this.json,r=this.options,s=this.nodeMap;t.nodes||(t.nodes=[]);const i={};if(r.trs){const o=e.quaternion.toArray(),c=e.position.toArray(),l=e.scale.toArray();O(o,[0,0,0,1])||(i.rotation=o),O(c,[0,0,0])||(i.translation=c),O(l,[1,1,1])||(i.scale=l)}else e.matrixAutoUpdate&&e.updateMatrix(),re(e.matrix)===!1&&(i.matrix=e.matrix.elements);if(e.name!==""&&(i.name=String(e.name)),this.serializeUserData(e,i),e.isMesh||e.isLine||e.isPoints){const o=this.processMesh(e);o!==null&&(i.mesh=o)}else e.isCamera&&(i.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const o=[];for(let c=0,l=e.children.length;c<l;c++){const p=e.children[c];if(p.visible||r.onlyVisible===!1){const u=this.processNode(p);u!==null&&o.push(u)}}o.length>0&&(i.children=o)}this._invokeAll(function(o){o.writeNode&&o.writeNode(e,i)});const n=t.nodes.push(i)-1;return s.set(e,n),n}processScene(e){const t=this.json,r=this.options;t.scenes||(t.scenes=[],t.scene=0);const s={};e.name!==""&&(s.name=e.name),t.scenes.push(s);const i=[];for(let n=0,o=e.children.length;n<o;n++){const c=e.children[n];if(c.visible||r.onlyVisible===!1){const l=this.processNode(c);l!==null&&i.push(l)}}i.length>0&&(s.nodes=i),this.serializeUserData(e,s)}processObjects(e){const t=new f.Scene;t.name="AuxScene";for(let r=0;r<e.length;r++)t.children.push(e[r]);this.processScene(t)}processInput(e){const t=this.options;e=e instanceof Array?e:[e],this._invokeAll(function(s){s.beforeParse&&s.beforeParse(e)});const r=[];for(let s=0;s<e.length;s++)e[s]instanceof f.Scene?this.processScene(e[s]):r.push(e[s]);r.length>0&&this.processObjects(r);for(let s=0;s<this.skins.length;++s)this.processSkin(this.skins[s]);for(let s=0;s<t.animations.length;++s)this.processAnimation(t.animations[s],e[0]);this._invokeAll(function(s){s.afterParse&&s.afterParse(e)})}_invokeAll(e){for(let t=0,r=this.plugins.length;t<r;t++)e(this.plugins[t])}}class ce{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}const r=this.writer,s=r.json,i=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."),i[this.name]||(s.extensions=s.extensions||{},s.extensions[this.name]={lights:[]},i[this.name]=!0);const o=s.extensions[this.name].lights;o.push(n),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}}class le{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const s=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},s[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class ue{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;const r=this.writer,s=r.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){const n={index:r.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};r.applyTextureTransform(n,e.clearcoatMap),i.clearcoatTexture=n}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const n={index:r.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};r.applyTextureTransform(n,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=n}if(e.clearcoatNormalMap){const n={index:r.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};e.clearcoatNormalScale.x!==1&&(n.scale=e.clearcoatNormalScale.x),r.applyTextureTransform(n,e.clearcoatNormalMap),i.clearcoatNormalTexture=n}t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class fe{constructor(e){this.writer=e,this.name="KHR_materials_dispersion"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.dispersion===0)return;const s=this.writer.extensionsUsed,i={};i.dispersion=e.dispersion,t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class he{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;const r=this.writer,s=r.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){const n={index:r.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};r.applyTextureTransform(n,e.iridescenceMap),i.iridescenceTexture=n}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const n={index:r.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};r.applyTextureTransform(n,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=n}t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class pe{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const r=this.writer,s=r.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){const n={index:r.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};r.applyTextureTransform(n,e.transmissionMap),i.transmissionTexture=n}t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class de{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const r=this.writer,s=r.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){const n={index:r.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};r.applyTextureTransform(n,e.thicknessMap),i.thicknessTexture=n}i.attenuationDistance=e.attenuationDistance,i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class xe{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;const s=this.writer.extensionsUsed,i={};i.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class ge{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals($)&&!e.specularIntensityMap&&!e.specularColorMap)return;const r=this.writer,s=r.extensionsUsed,i={};if(e.specularIntensityMap){const n={index:r.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};r.applyTextureTransform(n,e.specularIntensityMap),i.specularTexture=n}if(e.specularColorMap){const n={index:r.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};r.applyTextureTransform(n,e.specularColorMap),i.specularColorTexture=n}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class Te{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;const r=this.writer,s=r.extensionsUsed,i={};if(e.sheenRoughnessMap){const n={index:r.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};r.applyTextureTransform(n,e.sheenRoughnessMap),i.sheenRoughnessTexture=n}if(e.sheenColorMap){const n={index:r.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};r.applyTextureTransform(n,e.sheenColorMap),i.sheenColorTexture=n}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class me{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;const r=this.writer,s=r.extensionsUsed,i={};if(e.anisotropyMap){const n={index:r.processTexture(e.anisotropyMap)};r.applyTextureTransform(n,e.anisotropyMap),i.anisotropyTexture=n}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class ye{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;const s=this.writer.extensionsUsed,i={};i.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class Me{constructor(e){this.writer=e,this.name="EXT_materials_bump"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;const r=this.writer,s=r.extensionsUsed,i={};if(e.bumpMap){const n={index:r.processTexture(e.bumpMap),texCoord:e.bumpMap.channel};r.applyTextureTransform(n,e.bumpMap),i.bumpTexture=n}i.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class we{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;const r=this.writer,s=e,i=new Float32Array(s.count*3),n=new Float32Array(s.count*4),o=new Float32Array(s.count*3),c=new f.Matrix4,l=new f.Vector3,p=new f.Quaternion,u=new f.Vector3;for(let h=0;h<s.count;h++)s.getMatrixAt(h,c),c.decompose(l,p,u),l.toArray(i,h*3),p.toArray(n,h*4),u.toArray(o,h*3);const y={TRANSLATION:r.processAccessor(new f.BufferAttribute(i,3)),ROTATION:r.processAccessor(new f.BufferAttribute(n,4)),SCALE:r.processAccessor(new f.BufferAttribute(o,3))};s.instanceColor&&(y._COLOR_0=r.processAccessor(s.instanceColor)),t.extensions=t.extensions||{},t.extensions[this.name]={attributes:y},r.extensionsUsed[this.name]=!0,r.extensionsRequired[this.name]=!0}}V.Utils={insertKeyframe:function(a,e){const r=a.getValueSize(),s=new a.TimeBufferType(a.times.length+1),i=new a.ValueBufferType(a.values.length+r),n=a.createInterpolant(new a.ValueBufferType(r));let o;if(a.times.length===0){s[0]=e;for(let c=0;c<r;c++)i[c]=0;o=0}else if(e<a.times[0]){if(Math.abs(a.times[0]-e)<.001)return 0;s[0]=e,s.set(a.times,1),i.set(n.evaluate(e),0),i.set(a.values,r),o=0}else if(e>a.times[a.times.length-1]){if(Math.abs(a.times[a.times.length-1]-e)<.001)return a.times.length-1;s[s.length-1]=e,s.set(a.times,0),i.set(a.values,0),i.set(n.evaluate(e),a.values.length),o=s.length-1}else for(let c=0;c<a.times.length;c++){if(Math.abs(a.times[c]-e)<.001)return c;if(a.times[c]<e&&a.times[c+1]>e){s.set(a.times.slice(0,c+1),0),s[c+1]=e,s.set(a.times.slice(c+1),c+2),i.set(a.values.slice(0,(c+1)*r),0),i.set(n.evaluate(e),(c+1)*r),i.set(a.values.slice((c+1)*r),(c+2)*r),o=c+1;break}}return a.times=s,a.values=i,o},mergeMorphTargetTracks:function(a,e){const t=[],r={},s=a.tracks;for(let i=0;i<s.length;++i){let n=s[i];const o=f.PropertyBinding.parseTrackName(n.name),c=f.PropertyBinding.findNode(e,o.nodeName);if(o.propertyName!=="morphTargetInfluences"||o.propertyIndex===void 0){t.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(f.InterpolateLinear)}const l=c.morphTargetInfluences.length,p=c.morphTargetDictionary[o.propertyIndex];if(p===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+o.propertyIndex);let u;if(r[c.uuid]===void 0){u=n.clone();const h=new u.ValueBufferType(l*u.times.length);for(let d=0;d<u.times.length;d++)h[d*l+p]=u.values[d];u.name=(o.nodeName||"")+".morphTargetInfluences",u.values=h,r[c.uuid]=u,t.push(u);continue}const y=n.createInterpolant(new n.ValueBufferType(1));u=r[c.uuid];for(let h=0;h<u.times.length;h++)u.values[h*l+p]=y.evaluate(u.times[h]);for(let h=0;h<n.times.length;h++){const d=this.insertKeyframe(u,n.times[h]);u.values[d*l+p]=n.values[h]}}return a.tracks=t,a}};var Ee=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ie(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}exports.GLTFExporter=V;exports.commonjsGlobal=Ee;exports.getDefaultExportFromCjs=Ie;
|
|
18
|
+
}`})),_.uniforms.blitTexture.value=a,_.defines.IS_SRGB=a.colorSpace==f.SRGBColorSpace,_.needsUpdate=!0,G||(G=new f.Mesh(P,_),G.frustumCulled=!1);const r=new f.PerspectiveCamera,s=new f.Scene;s.add(G),t===null&&(t=v=new f.WebGLRenderer({antialias:!1}));const i=Math.min(a.image.width,e),n=Math.min(a.image.height,e);t.setSize(i,n),t.clear(),t.render(s,r);const o=document.createElement("canvas"),c=o.getContext("2d");o.width=i,o.height=n,c.drawImage(t.domElement,0,0,i,n);const l=new f.CanvasTexture(o);return l.minFilter=a.minFilter,l.magFilter=a.magFilter,l.wrapS=a.wrapS,l.wrapT=a.wrapT,l.name=a.name,v&&(v.forceContextLoss(),v.dispose(),v=null),l}const Y={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 V{constructor(){this.pluginCallbacks=[],this.register(function(e){return new ce(e)}),this.register(function(e){return new le(e)}),this.register(function(e){return new pe(e)}),this.register(function(e){return new de(e)}),this.register(function(e){return new xe(e)}),this.register(function(e){return new ge(e)}),this.register(function(e){return new ue(e)}),this.register(function(e){return new fe(e)}),this.register(function(e){return new he(e)}),this.register(function(e){return new Te(e)}),this.register(function(e){return new me(e)}),this.register(function(e){return new ye(e)}),this.register(function(e){return new Me(e)}),this.register(function(e){return new we(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}parse(e,t,r,s){const i=new ae,n=[];for(let o=0,c=this.pluginCallbacks.length;o<c;o++)n.push(this.pluginCallbacks[o](i));i.setPlugins(n),i.write(e,t,s).catch(r)}parseAsync(e,t){const r=this;return new Promise(function(s,i){r.parse(e,s,i,t)})}}const m={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},k="KHR_mesh_quantization",b={};b[f.NearestFilter]=m.NEAREST;b[f.NearestMipmapNearestFilter]=m.NEAREST_MIPMAP_NEAREST;b[f.NearestMipmapLinearFilter]=m.NEAREST_MIPMAP_LINEAR;b[f.LinearFilter]=m.LINEAR;b[f.LinearMipmapNearestFilter]=m.LINEAR_MIPMAP_NEAREST;b[f.LinearMipmapLinearFilter]=m.LINEAR_MIPMAP_LINEAR;b[f.ClampToEdgeWrapping]=m.CLAMP_TO_EDGE;b[f.RepeatWrapping]=m.REPEAT;b[f.MirroredRepeatWrapping]=m.MIRRORED_REPEAT;const K={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},$=new f.Color,q=12,ee=1179937895,te=2,W=8,se=1313821514,ne=5130562;function O(a,e){return a.length===e.length&&a.every(function(t,r){return t===e[r]})}function ie(a){return new TextEncoder().encode(a).buffer}function re(a){return O(a.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function oe(a,e,t){const r={min:new Array(a.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(a.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let s=e;s<e+t;s++)for(let i=0;i<a.itemSize;i++){let n;a.itemSize>4?n=a.array[s*a.itemSize+i]:(i===0?n=a.getX(s):i===1?n=a.getY(s):i===2?n=a.getZ(s):i===3&&(n=a.getW(s)),a.normalized===!0&&(n=f.MathUtils.normalize(n,a.array))),r.min[i]=Math.min(r.min[i],n),r.max[i]=Math.max(r.max[i],n)}return r}function Q(a){return Math.ceil(a/4)*4}function H(a,e=0){const t=Q(a.byteLength);if(t!==a.byteLength){const r=new Uint8Array(t);if(r.set(new Uint8Array(a)),e!==0)for(let s=a.byteLength;s<t;s++)r[s]=e;return r.buffer}return a}function X(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function J(a,e){if(a.toBlob!==void 0)return new Promise(r=>a.toBlob(r,e));let t;return e==="image/jpeg"?t=.92:e==="image/webp"&&(t=.8),a.convertToBlob({type:e,quality:t})}class ae{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"+f.REVISION}},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);const s=this,i=s.buffers,n=s.json;r=s.options;const o=s.extensionsUsed,c=s.extensionsRequired,l=new Blob(i,{type:"application/octet-stream"}),p=Object.keys(o),u=Object.keys(c);if(p.length>0&&(n.extensionsUsed=p),u.length>0&&(n.extensionsRequired=u),n.buffers&&n.buffers.length>0&&(n.buffers[0].byteLength=l.size),r.binary===!0){const y=new FileReader;y.readAsArrayBuffer(l),y.onloadend=function(){const h=H(y.result),d=new DataView(new ArrayBuffer(W));d.setUint32(0,h.byteLength,!0),d.setUint32(4,ne,!0);const x=H(ie(JSON.stringify(n)),32),T=new DataView(new ArrayBuffer(W));T.setUint32(0,x.byteLength,!0),T.setUint32(4,se,!0);const w=new ArrayBuffer(q),N=new DataView(w);N.setUint32(0,ee,!0),N.setUint32(4,te,!0);const B=q+T.byteLength+x.byteLength+d.byteLength+h.byteLength;N.setUint32(8,B,!0);const g=new Blob([w,T,x,d,h],{type:"application/octet-stream"}),M=new FileReader;M.readAsArrayBuffer(g),M.onloadend=function(){t(M.result)}}}else if(n.buffers&&n.buffers.length>0){const y=new FileReader;y.readAsDataURL(l),y.onloadend=function(){const h=y.result;n.buffers[0].uri=h,t(n)}}else t(n)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;const r=this.options,s=this.extensionsUsed;try{const i=JSON.parse(JSON.stringify(e.userData));if(r.includeCustomExtensions&&i.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(const n in i.gltfExtensions)t.extensions[n]=i.gltfExtensions[n],s[n]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.extras=i)}catch(i){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+i.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){const s=new Map;s.set(!0,this.uid++),s.set(!1,this.uid++),this.uids.set(e,s)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const r=new f.Vector3;for(let s=0,i=e.count;s<i;s++)if(Math.abs(r.fromBufferAttribute(e,s).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const r=e.clone(),s=new f.Vector3;for(let i=0,n=r.count;i<n;i++)s.fromBufferAttribute(r,i),s.x===0&&s.y===0&&s.z===0?s.setX(1):s.normalize(),r.setXYZ(i,s.x,s.y,s.z);return t.attributesNormalized.set(e,r),r}applyTextureTransform(e,t){let r=!1;const s={};(t.offset.x!==0||t.offset.y!==0)&&(s.offset=t.offset.toArray(),r=!0),t.rotation!==0&&(s.rotation=t.rotation,r=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(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(h){return h.colorSpace===f.SRGBColorSpace?function(x){return x<.04045?x*.0773993808:Math.pow(x*.9478672986+.0521327014,2.4)}:function(x){return x}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof f.CompressedTexture&&(e=z(e)),t instanceof f.CompressedTexture&&(t=z(t));const s=e?e.image:null,i=t?t.image:null,n=Math.max(s?s.width:0,i?i.width:0),o=Math.max(s?s.height:0,i?i.height:0),c=X();c.width=n,c.height=o;const l=c.getContext("2d",{willReadFrequently:!0});l.fillStyle="#00ffff",l.fillRect(0,0,n,o);const p=l.getImageData(0,0,n,o);if(s){l.drawImage(s,0,0,n,o);const h=r(e),d=l.getImageData(0,0,n,o).data;for(let x=2;x<d.length;x+=4)p.data[x]=h(d[x]/256)*256}if(i){l.drawImage(i,0,0,n,o);const h=r(t),d=l.getImageData(0,0,n,o).data;for(let x=1;x<d.length;x+=4)p.data[x]=h(d[x]/256)*256}l.putImageData(p,0,0);const y=(e||t).clone();return y.source=new f.Source(c),y.colorSpace=f.NoColorSpace,y.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),y}processBuffer(e){const t=this.json,r=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),r.push(e),0}processBufferView(e,t,r,s,i){const n=this.json;n.bufferViews||(n.bufferViews=[]);let o;switch(t){case m.BYTE:case m.UNSIGNED_BYTE:o=1;break;case m.SHORT:case m.UNSIGNED_SHORT:o=2;break;default:o=4}let c=e.itemSize*o;i===m.ARRAY_BUFFER&&(c=Math.ceil(c/4)*4);const l=Q(s*c),p=new DataView(new ArrayBuffer(l));let u=0;for(let d=r;d<r+s;d++){for(let x=0;x<e.itemSize;x++){let T;e.itemSize>4?T=e.array[d*e.itemSize+x]:(x===0?T=e.getX(d):x===1?T=e.getY(d):x===2?T=e.getZ(d):x===3&&(T=e.getW(d)),e.normalized===!0&&(T=f.MathUtils.normalize(T,e.array))),t===m.FLOAT?p.setFloat32(u,T,!0):t===m.INT?p.setInt32(u,T,!0):t===m.UNSIGNED_INT?p.setUint32(u,T,!0):t===m.SHORT?p.setInt16(u,T,!0):t===m.UNSIGNED_SHORT?p.setUint16(u,T,!0):t===m.BYTE?p.setInt8(u,T):t===m.UNSIGNED_BYTE&&p.setUint8(u,T),u+=o}u%c!==0&&(u+=c-u%c)}const y={buffer:this.processBuffer(p.buffer),byteOffset:this.byteOffset,byteLength:l};return i!==void 0&&(y.target=i),i===m.ARRAY_BUFFER&&(y.byteStride=c),this.byteOffset+=l,n.bufferViews.push(y),{id:n.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,r=t.json;return r.bufferViews||(r.bufferViews=[]),new Promise(function(s){const i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){const n=H(i.result),o={buffer:t.processBuffer(n),byteOffset:t.byteOffset,byteLength:n.byteLength};t.byteOffset+=n.byteLength,s(r.bufferViews.push(o)-1)}})}processAccessor(e,t,r,s){const i=this.json,n={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"};let o;if(e.array.constructor===Float32Array)o=m.FLOAT;else if(e.array.constructor===Int32Array)o=m.INT;else if(e.array.constructor===Uint32Array)o=m.UNSIGNED_INT;else if(e.array.constructor===Int16Array)o=m.SHORT;else if(e.array.constructor===Uint16Array)o=m.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)o=m.BYTE;else if(e.array.constructor===Uint8Array)o=m.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(r===void 0&&(r=0),(s===void 0||s===1/0)&&(s=e.count),s===0)return null;const c=oe(e,r,s);let l;t!==void 0&&(l=e===t.index?m.ELEMENT_ARRAY_BUFFER:m.ARRAY_BUFFER);const p=this.processBufferView(e,o,r,s,l),u={bufferView:p.id,byteOffset:p.byteOffset,componentType:o,count:s,max:c.max,min:c.min,type:n[e.itemSize]};return e.normalized===!0&&(u.normalized=!0),i.accessors||(i.accessors=[]),i.accessors.push(u)-1}processImage(e,t,r,s="image/png"){if(e!==null){const i=this,n=i.cache,o=i.json,c=i.options,l=i.pending;n.images.has(e)||n.images.set(e,{});const p=n.images.get(e),u=s+":flipY/"+r.toString();if(p[u]!==void 0)return p[u];o.images||(o.images=[]);const y={mimeType:s},h=X();h.width=Math.min(e.width,c.maxTextureSize),h.height=Math.min(e.height,c.maxTextureSize);const d=h.getContext("2d",{willReadFrequently:!0});if(r===!0&&(d.translate(0,h.height),d.scale(1,-1)),e.data!==void 0){t!==f.RGBAFormat&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>c.maxTextureSize||e.height>c.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const T=new Uint8ClampedArray(e.height*e.width*4);for(let w=0;w<T.length;w+=4)T[w+0]=e.data[w+0],T[w+1]=e.data[w+1],T[w+2]=e.data[w+2],T[w+3]=e.data[w+3];d.putImageData(new ImageData(T,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,h.width,h.height);else throw new Error("THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.");c.binary===!0?l.push(J(h,s).then(T=>i.processBufferViewImage(T)).then(T=>{y.bufferView=T})):h.toDataURL!==void 0?y.uri=h.toDataURL(s):l.push(J(h,s).then(T=>new FileReader().readAsDataURL(T)).then(T=>{y.uri=T}));const x=o.images.push(y)-1;return p[u]=x,x}else throw new Error("THREE.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const r={magFilter:b[e.magFilter],minFilter:b[e.minFilter],wrapS:b[e.wrapS],wrapT:b[e.wrapT]};return t.samplers.push(r)-1}processTexture(e){const r=this.options,s=this.cache,i=this.json;if(s.textures.has(e))return s.textures.get(e);i.textures||(i.textures=[]),e instanceof f.CompressedTexture&&(e=z(e,r.maxTextureSize));let n=e.userData.mimeType;n==="image/webp"&&(n="image/png");const o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,n)};e.name&&(o.name=e.name),this._invokeAll(function(l){l.writeTexture&&l.writeTexture(e,o)});const c=i.textures.push(o)-1;return s.textures.set(e,c),c}processMaterial(e){const 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=[]);const s={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const i=e.color.toArray().concat([e.opacity]);if(O(i,[1,1,1,1])||(s.pbrMetallicRoughness.baseColorFactor=i),e.isMeshStandardMaterial?(s.pbrMetallicRoughness.metallicFactor=e.metalness,s.pbrMetallicRoughness.roughnessFactor=e.roughness):(s.pbrMetallicRoughness.metallicFactor=.5,s.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const o=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),c={index:this.processTexture(o),channel:o.channel};this.applyTextureTransform(c,o),s.pbrMetallicRoughness.metallicRoughnessTexture=c}if(e.map){const o={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(o,e.map),s.pbrMetallicRoughness.baseColorTexture=o}if(e.emissive){const o=e.emissive;if(Math.max(o.r,o.g,o.b)>0&&(s.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const l={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(l,e.emissiveMap),s.emissiveTexture=l}}if(e.normalMap){const o={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(o.scale=e.normalScale.x),this.applyTextureTransform(o,e.normalMap),s.normalTexture=o}if(e.aoMap){const o={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(o.strength=e.aoMapIntensity),this.applyTextureTransform(o,e.aoMap),s.occlusionTexture=o}e.transparent?s.alphaMode="BLEND":e.alphaTest>0&&(s.alphaMode="MASK",s.alphaCutoff=e.alphaTest),e.side===f.DoubleSide&&(s.doubleSided=!0),e.name!==""&&(s.name=e.name),this.serializeUserData(e,s),this._invokeAll(function(o){o.writeMaterial&&o.writeMaterial(e,s)});const n=r.materials.push(s)-1;return t.materials.set(e,n),n}processMesh(e){const t=this.cache,r=this.json,s=[e.geometry.uuid];if(Array.isArray(e.material))for(let g=0,M=e.material.length;g<M;g++)s.push(e.material[g].uuid);else s.push(e.material.uuid);const i=s.join(":");if(t.meshes.has(i))return t.meshes.get(i);const n=e.geometry;let o;e.isLineSegments?o=m.LINES:e.isLineLoop?o=m.LINE_LOOP:e.isLine?o=m.LINE_STRIP:e.isPoints?o=m.POINTS:o=e.material.wireframe?m.LINES:m.TRIANGLES;const c={},l={},p=[],u=[],y={uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},h=n.getAttribute("normal");h!==void 0&&!this.isNormalizedNormalAttribute(h)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),n.setAttribute("normal",this.createNormalizedNormalAttribute(h)));let d=null;for(let g in n.attributes){if(g.slice(0,5)==="morph")continue;const M=n.attributes[g];if(g=y[g]||g.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(g)||(g="_"+g),t.attributes.has(this.getUID(M))){l[g]=t.attributes.get(this.getUID(M));continue}d=null;const I=M.array;g==="JOINTS_0"&&!(I instanceof Uint16Array)&&!(I instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),d=new f.BufferAttribute(new Uint16Array(I),M.itemSize,M.normalized));const R=this.processAccessor(d||M,n);R!==null&&(g.startsWith("_")||this.detectMeshQuantization(g,M),l[g]=R,t.attributes.set(this.getUID(M),R))}if(h!==void 0&&n.setAttribute("normal",h),Object.keys(l).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const g=[],M=[],E={};if(e.morphTargetDictionary!==void 0)for(const I in e.morphTargetDictionary)E[e.morphTargetDictionary[I]]=I;for(let I=0;I<e.morphTargetInfluences.length;++I){const R={};let j=!1;for(const C in n.morphAttributes){if(C!=="position"&&C!=="normal"){j||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),j=!0);continue}const S=n.morphAttributes[C][I],D=C.toUpperCase(),U=n.attributes[C];if(t.attributes.has(this.getUID(S,!0))){R[D]=t.attributes.get(this.getUID(S,!0));continue}const F=S.clone();if(!n.morphTargetsRelative)for(let A=0,Z=S.count;A<Z;A++)for(let L=0;L<S.itemSize;L++)L===0&&F.setX(A,S.getX(A)-U.getX(A)),L===1&&F.setY(A,S.getY(A)-U.getY(A)),L===2&&F.setZ(A,S.getZ(A)-U.getZ(A)),L===3&&F.setW(A,S.getW(A)-U.getW(A));R[D]=this.processAccessor(F,n),t.attributes.set(this.getUID(U,!0),R[D])}u.push(R),g.push(e.morphTargetInfluences[I]),e.morphTargetDictionary!==void 0&&M.push(E[I])}c.weights=g,M.length>0&&(c.extras={},c.extras.targetNames=M)}const x=Array.isArray(e.material);if(x&&n.groups.length===0)return null;let T=!1;if(x&&n.index===null){const g=[];for(let M=0,E=n.attributes.position.count;M<E;M++)g[M]=M;n.setIndex(g),T=!0}const w=x?e.material:[e.material],N=x?n.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let g=0,M=N.length;g<M;g++){const E={mode:o,attributes:l};if(this.serializeUserData(n,E),u.length>0&&(E.targets=u),n.index!==null){let R=this.getUID(n.index);(N[g].start!==void 0||N[g].count!==void 0)&&(R+=":"+N[g].start+":"+N[g].count),t.attributes.has(R)?E.indices=t.attributes.get(R):(E.indices=this.processAccessor(n.index,n,N[g].start,N[g].count),t.attributes.set(R,E.indices)),E.indices===null&&delete E.indices}const I=this.processMaterial(w[N[g].materialIndex]);I!==null&&(E.material=I),p.push(E)}T===!0&&n.setIndex(null),c.primitives=p,r.meshes||(r.meshes=[]),this._invokeAll(function(g){g.writeMesh&&g.writeMesh(e,c)});const B=r.meshes.push(c)-1;return t.meshes.set(i,B),B}detectMeshQuantization(e,t){if(this.extensionsUsed[k])return;let r;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");const s=e.split("_",1)[0];Y[s]&&Y[s].includes(r)&&(this.extensionsUsed[k]=!0,this.extensionsRequired[k]=!0)}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const r=e.isOrthographicCamera,s={type:r?"orthographic":"perspective"};return r?s.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:s.perspective={aspectRatio:e.aspect,yfov:f.MathUtils.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){const r=this.json,s=this.nodeMap;r.animations||(r.animations=[]),e=V.Utils.mergeMorphTargetTracks(e.clone(),t);const i=e.tracks,n=[],o=[];for(let c=0;c<i.length;++c){const l=i[c],p=f.PropertyBinding.parseTrackName(l.name);let u=f.PropertyBinding.findNode(t,p.nodeName);const y=K[p.propertyName];if(p.objectName==="bones"&&(u.isSkinnedMesh===!0?u=u.skeleton.getBoneByName(p.objectIndex):u=void 0),!u||!y){console.warn('THREE.GLTFExporter: Could not export animation track "%s".',l.name);continue}const h=1;let d=l.values.length/l.times.length;y===K.morphTargetInfluences&&(d/=u.morphTargetInfluences.length);let x;l.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(x="CUBICSPLINE",d/=3):l.getInterpolation()===f.InterpolateDiscrete?x="STEP":x="LINEAR",o.push({input:this.processAccessor(new f.BufferAttribute(l.times,h)),output:this.processAccessor(new f.BufferAttribute(l.values,d)),interpolation:x}),n.push({sampler:o.length-1,target:{node:s.get(u),path:y}})}return r.animations.push({name:e.name||"clip_"+r.animations.length,samplers:o,channels:n}),r.animations.length-1}processSkin(e){const t=this.json,r=this.nodeMap,s=t.nodes[r.get(e)],i=e.skeleton;if(i===void 0)return null;const n=e.skeleton.bones[0];if(n===void 0)return null;const o=[],c=new Float32Array(i.bones.length*16),l=new f.Matrix4;for(let u=0;u<i.bones.length;++u)o.push(r.get(i.bones[u])),l.copy(i.boneInverses[u]),l.multiply(e.bindMatrix).toArray(c,u*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new f.BufferAttribute(c,16)),joints:o,skeleton:r.get(n)}),s.skin=t.skins.length-1}processNode(e){const t=this.json,r=this.options,s=this.nodeMap;t.nodes||(t.nodes=[]);const i={};if(r.trs){const o=e.quaternion.toArray(),c=e.position.toArray(),l=e.scale.toArray();O(o,[0,0,0,1])||(i.rotation=o),O(c,[0,0,0])||(i.translation=c),O(l,[1,1,1])||(i.scale=l)}else e.matrixAutoUpdate&&e.updateMatrix(),re(e.matrix)===!1&&(i.matrix=e.matrix.elements);if(e.name!==""&&(i.name=String(e.name)),this.serializeUserData(e,i),e.isMesh||e.isLine||e.isPoints){const o=this.processMesh(e);o!==null&&(i.mesh=o)}else e.isCamera&&(i.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const o=[];for(let c=0,l=e.children.length;c<l;c++){const p=e.children[c];if(p.visible||r.onlyVisible===!1){const u=this.processNode(p);u!==null&&o.push(u)}}o.length>0&&(i.children=o)}this._invokeAll(function(o){o.writeNode&&o.writeNode(e,i)});const n=t.nodes.push(i)-1;return s.set(e,n),n}processScene(e){const t=this.json,r=this.options;t.scenes||(t.scenes=[],t.scene=0);const s={};e.name!==""&&(s.name=e.name),t.scenes.push(s);const i=[];for(let n=0,o=e.children.length;n<o;n++){const c=e.children[n];if(c.visible||r.onlyVisible===!1){const l=this.processNode(c);l!==null&&i.push(l)}}i.length>0&&(s.nodes=i),this.serializeUserData(e,s)}processObjects(e){const t=new f.Scene;t.name="AuxScene";for(let r=0;r<e.length;r++)t.children.push(e[r]);this.processScene(t)}processInput(e){const t=this.options;e=e instanceof Array?e:[e],this._invokeAll(function(s){s.beforeParse&&s.beforeParse(e)});const r=[];for(let s=0;s<e.length;s++)e[s]instanceof f.Scene?this.processScene(e[s]):r.push(e[s]);r.length>0&&this.processObjects(r);for(let s=0;s<this.skins.length;++s)this.processSkin(this.skins[s]);for(let s=0;s<t.animations.length;++s)this.processAnimation(t.animations[s],e[0]);this._invokeAll(function(s){s.afterParse&&s.afterParse(e)})}_invokeAll(e){for(let t=0,r=this.plugins.length;t<r;t++)e(this.plugins[t])}}class ce{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}const r=this.writer,s=r.json,i=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."),i[this.name]||(s.extensions=s.extensions||{},s.extensions[this.name]={lights:[]},i[this.name]=!0);const o=s.extensions[this.name].lights;o.push(n),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}}class le{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const s=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},s[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class ue{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;const r=this.writer,s=r.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){const n={index:r.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};r.applyTextureTransform(n,e.clearcoatMap),i.clearcoatTexture=n}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const n={index:r.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};r.applyTextureTransform(n,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=n}if(e.clearcoatNormalMap){const n={index:r.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};e.clearcoatNormalScale.x!==1&&(n.scale=e.clearcoatNormalScale.x),r.applyTextureTransform(n,e.clearcoatNormalMap),i.clearcoatNormalTexture=n}t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class fe{constructor(e){this.writer=e,this.name="KHR_materials_dispersion"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.dispersion===0)return;const s=this.writer.extensionsUsed,i={};i.dispersion=e.dispersion,t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class he{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;const r=this.writer,s=r.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){const n={index:r.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};r.applyTextureTransform(n,e.iridescenceMap),i.iridescenceTexture=n}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const n={index:r.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};r.applyTextureTransform(n,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=n}t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class pe{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const r=this.writer,s=r.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){const n={index:r.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};r.applyTextureTransform(n,e.transmissionMap),i.transmissionTexture=n}t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class de{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const r=this.writer,s=r.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){const n={index:r.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};r.applyTextureTransform(n,e.thicknessMap),i.thicknessTexture=n}e.attenuationDistance!==1/0&&(i.attenuationDistance=e.attenuationDistance),i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class xe{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;const s=this.writer.extensionsUsed,i={};i.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class ge{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals($)&&!e.specularIntensityMap&&!e.specularColorMap)return;const r=this.writer,s=r.extensionsUsed,i={};if(e.specularIntensityMap){const n={index:r.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};r.applyTextureTransform(n,e.specularIntensityMap),i.specularTexture=n}if(e.specularColorMap){const n={index:r.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};r.applyTextureTransform(n,e.specularColorMap),i.specularColorTexture=n}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class Te{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;const r=this.writer,s=r.extensionsUsed,i={};if(e.sheenRoughnessMap){const n={index:r.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};r.applyTextureTransform(n,e.sheenRoughnessMap),i.sheenRoughnessTexture=n}if(e.sheenColorMap){const n={index:r.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};r.applyTextureTransform(n,e.sheenColorMap),i.sheenColorTexture=n}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class me{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;const r=this.writer,s=r.extensionsUsed,i={};if(e.anisotropyMap){const n={index:r.processTexture(e.anisotropyMap)};r.applyTextureTransform(n,e.anisotropyMap),i.anisotropyTexture=n}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class ye{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;const s=this.writer.extensionsUsed,i={};i.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class Me{constructor(e){this.writer=e,this.name="EXT_materials_bump"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;const r=this.writer,s=r.extensionsUsed,i={};if(e.bumpMap){const n={index:r.processTexture(e.bumpMap),texCoord:e.bumpMap.channel};r.applyTextureTransform(n,e.bumpMap),i.bumpTexture=n}i.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=i,s[this.name]=!0}}class we{constructor(e){this.writer=e,this.name="EXT_mesh_gpu_instancing"}writeNode(e,t){if(!e.isInstancedMesh)return;const r=this.writer,s=e,i=new Float32Array(s.count*3),n=new Float32Array(s.count*4),o=new Float32Array(s.count*3),c=new f.Matrix4,l=new f.Vector3,p=new f.Quaternion,u=new f.Vector3;for(let h=0;h<s.count;h++)s.getMatrixAt(h,c),c.decompose(l,p,u),l.toArray(i,h*3),p.toArray(n,h*4),u.toArray(o,h*3);const y={TRANSLATION:r.processAccessor(new f.BufferAttribute(i,3)),ROTATION:r.processAccessor(new f.BufferAttribute(n,4)),SCALE:r.processAccessor(new f.BufferAttribute(o,3))};s.instanceColor&&(y._COLOR_0=r.processAccessor(s.instanceColor)),t.extensions=t.extensions||{},t.extensions[this.name]={attributes:y},r.extensionsUsed[this.name]=!0,r.extensionsRequired[this.name]=!0}}V.Utils={insertKeyframe:function(a,e){const r=a.getValueSize(),s=new a.TimeBufferType(a.times.length+1),i=new a.ValueBufferType(a.values.length+r),n=a.createInterpolant(new a.ValueBufferType(r));let o;if(a.times.length===0){s[0]=e;for(let c=0;c<r;c++)i[c]=0;o=0}else if(e<a.times[0]){if(Math.abs(a.times[0]-e)<.001)return 0;s[0]=e,s.set(a.times,1),i.set(n.evaluate(e),0),i.set(a.values,r),o=0}else if(e>a.times[a.times.length-1]){if(Math.abs(a.times[a.times.length-1]-e)<.001)return a.times.length-1;s[s.length-1]=e,s.set(a.times,0),i.set(a.values,0),i.set(n.evaluate(e),a.values.length),o=s.length-1}else for(let c=0;c<a.times.length;c++){if(Math.abs(a.times[c]-e)<.001)return c;if(a.times[c]<e&&a.times[c+1]>e){s.set(a.times.slice(0,c+1),0),s[c+1]=e,s.set(a.times.slice(c+1),c+2),i.set(a.values.slice(0,(c+1)*r),0),i.set(n.evaluate(e),(c+1)*r),i.set(a.values.slice((c+1)*r),(c+2)*r),o=c+1;break}}return a.times=s,a.values=i,o},mergeMorphTargetTracks:function(a,e){const t=[],r={},s=a.tracks;for(let i=0;i<s.length;++i){let n=s[i];const o=f.PropertyBinding.parseTrackName(n.name),c=f.PropertyBinding.findNode(e,o.nodeName);if(o.propertyName!=="morphTargetInfluences"||o.propertyIndex===void 0){t.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(f.InterpolateLinear)}const l=c.morphTargetInfluences.length,p=c.morphTargetDictionary[o.propertyIndex];if(p===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+o.propertyIndex);let u;if(r[c.uuid]===void 0){u=n.clone();const h=new u.ValueBufferType(l*u.times.length);for(let d=0;d<u.times.length;d++)h[d*l+p]=u.values[d];u.name=(o.nodeName||"")+".morphTargetInfluences",u.values=h,r[c.uuid]=u,t.push(u);continue}const y=n.createInterpolant(new n.ValueBufferType(1));u=r[c.uuid];for(let h=0;h<u.times.length;h++)u.values[h*l+p]=y.evaluate(u.times[h]);for(let h=0;h<n.times.length;h++){const d=this.insertKeyframe(u,n.times[h]);u.values[d*l+p]=n.values[h]}}return a.tracks=t,a}};var Ee=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ie(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}exports.GLTFExporter=V;exports.commonjsGlobal=Ee;exports.getDefaultExportFromCjs=Ie;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PlaneGeometry as oe, ShaderMaterial as ae, Uniform as ce, SRGBColorSpace as se, Mesh as le, PerspectiveCamera as ue, Scene as K, WebGLRenderer as fe, CanvasTexture as he, Color as pe, REVISION as de, Vector3 as P, CompressedTexture as k, Source as xe, NoColorSpace as ge, MathUtils as q, RGBAFormat as Te, DoubleSide as me, BufferAttribute as S, PropertyBinding as B, InterpolateDiscrete as ye, Matrix4 as te, Quaternion as Me, InterpolateLinear as we, NearestFilter as Ee, NearestMipmapNearestFilter as Ie, NearestMipmapLinearFilter as Re, LinearFilter as Ae, LinearMipmapNearestFilter as be, LinearMipmapLinearFilter as Ne, ClampToEdgeWrapping as Se, RepeatWrapping as Le, MirroredRepeatWrapping as _e } from "three";
|
|
2
2
|
let F, H, _, D;
|
|
3
3
|
function V(a, e = 1 / 0, s = null) {
|
|
4
4
|
H || (H = new oe(2, 2, 1, 1)), _ || (_ = new ae({
|
|
@@ -145,15 +145,15 @@ const T = {
|
|
|
145
145
|
MIRRORED_REPEAT: 33648,
|
|
146
146
|
REPEAT: 10497
|
|
147
147
|
}, j = "KHR_mesh_quantization", A = {};
|
|
148
|
-
A[
|
|
149
|
-
A[
|
|
150
|
-
A[
|
|
151
|
-
A[
|
|
152
|
-
A[
|
|
153
|
-
A[
|
|
154
|
-
A[
|
|
155
|
-
A[
|
|
156
|
-
A[
|
|
148
|
+
A[Ee] = T.NEAREST;
|
|
149
|
+
A[Ie] = T.NEAREST_MIPMAP_NEAREST;
|
|
150
|
+
A[Re] = T.NEAREST_MIPMAP_LINEAR;
|
|
151
|
+
A[Ae] = T.LINEAR;
|
|
152
|
+
A[be] = T.LINEAR_MIPMAP_NEAREST;
|
|
153
|
+
A[Ne] = T.LINEAR_MIPMAP_LINEAR;
|
|
154
|
+
A[Se] = T.CLAMP_TO_EDGE;
|
|
155
|
+
A[Le] = T.REPEAT;
|
|
156
|
+
A[_e] = T.MIRRORED_REPEAT;
|
|
157
157
|
const J = {
|
|
158
158
|
scale: "scale",
|
|
159
159
|
position: "translation",
|
|
@@ -320,7 +320,7 @@ class Be {
|
|
|
320
320
|
*/
|
|
321
321
|
isNormalizedNormalAttribute(e) {
|
|
322
322
|
if (this.cache.attributesNormalized.has(e)) return !1;
|
|
323
|
-
const r = new
|
|
323
|
+
const r = new P();
|
|
324
324
|
for (let t = 0, i = e.count; t < i; t++)
|
|
325
325
|
if (Math.abs(r.fromBufferAttribute(e, t).length() - 1) > 5e-4) return !1;
|
|
326
326
|
return !0;
|
|
@@ -335,7 +335,7 @@ class Be {
|
|
|
335
335
|
createNormalizedNormalAttribute(e) {
|
|
336
336
|
const s = this.cache;
|
|
337
337
|
if (s.attributesNormalized.has(e)) return s.attributesNormalized.get(e);
|
|
338
|
-
const r = e.clone(), t = new
|
|
338
|
+
const r = e.clone(), t = new P();
|
|
339
339
|
for (let i = 0, n = r.count; i < n; i++)
|
|
340
340
|
t.fromBufferAttribute(r, i), t.x === 0 && t.y === 0 && t.z === 0 ? t.setX(1) : t.normalize(), r.setXYZ(i, t.x, t.y, t.z);
|
|
341
341
|
return s.attributesNormalized.set(e, r), r;
|
|
@@ -818,8 +818,8 @@ class Be {
|
|
|
818
818
|
r.animations || (r.animations = []), e = ne.Utils.mergeMorphTargetTracks(e.clone(), s);
|
|
819
819
|
const i = e.tracks, n = [], o = [];
|
|
820
820
|
for (let c = 0; c < i.length; ++c) {
|
|
821
|
-
const l = i[c], h =
|
|
822
|
-
let u =
|
|
821
|
+
const l = i[c], h = B.parseTrackName(l.name);
|
|
822
|
+
let u = B.findNode(s, h.nodeName);
|
|
823
823
|
const m = J[h.propertyName];
|
|
824
824
|
if (h.objectName === "bones" && (u.isSkinnedMesh === !0 ? u = u.skeleton.getBoneByName(h.objectIndex) : u = void 0), !u || !m) {
|
|
825
825
|
console.warn('THREE.GLTFExporter: Could not export animation track "%s".', l.name);
|
|
@@ -1077,7 +1077,7 @@ class Ke {
|
|
|
1077
1077
|
};
|
|
1078
1078
|
r.applyTextureTransform(n, e.thicknessMap), i.thicknessTexture = n;
|
|
1079
1079
|
}
|
|
1080
|
-
i.attenuationDistance = e.attenuationDistance, i.attenuationColor = e.attenuationColor.toArray(), s.extensions = s.extensions || {}, s.extensions[this.name] = i, t[this.name] = !0;
|
|
1080
|
+
e.attenuationDistance !== 1 / 0 && (i.attenuationDistance = e.attenuationDistance), i.attenuationColor = e.attenuationColor.toArray(), s.extensions = s.extensions || {}, s.extensions[this.name] = i, t[this.name] = !0;
|
|
1081
1081
|
}
|
|
1082
1082
|
}
|
|
1083
1083
|
class qe {
|
|
@@ -1185,7 +1185,7 @@ class $e {
|
|
|
1185
1185
|
}
|
|
1186
1186
|
writeNode(e, s) {
|
|
1187
1187
|
if (!e.isInstancedMesh) return;
|
|
1188
|
-
const r = this.writer, t = e, i = new Float32Array(t.count * 3), n = new Float32Array(t.count * 4), o = new Float32Array(t.count * 3), c = new te(), l = new
|
|
1188
|
+
const r = this.writer, t = e, i = new Float32Array(t.count * 3), n = new Float32Array(t.count * 4), o = new Float32Array(t.count * 3), c = new te(), l = new P(), h = new Me(), u = new P();
|
|
1189
1189
|
for (let f = 0; f < t.count; f++)
|
|
1190
1190
|
t.getMatrixAt(f, c), c.decompose(l, h, u), l.toArray(i, f * 3), h.toArray(n, f * 4), u.toArray(o, f * 3);
|
|
1191
1191
|
const m = {
|
|
@@ -1226,7 +1226,7 @@ ne.Utils = {
|
|
|
1226
1226
|
const s = [], r = {}, t = a.tracks;
|
|
1227
1227
|
for (let i = 0; i < t.length; ++i) {
|
|
1228
1228
|
let n = t[i];
|
|
1229
|
-
const o =
|
|
1229
|
+
const o = B.parseTrackName(n.name), c = B.findNode(e, o.nodeName);
|
|
1230
1230
|
if (o.propertyName !== "morphTargetInfluences" || o.propertyIndex === void 0) {
|
|
1231
1231
|
s.push(n);
|
|
1232
1232
|
continue;
|
|
@@ -1234,7 +1234,7 @@ ne.Utils = {
|
|
|
1234
1234
|
if (n.createInterpolant !== n.InterpolantFactoryMethodDiscrete && n.createInterpolant !== n.InterpolantFactoryMethodLinear) {
|
|
1235
1235
|
if (n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)
|
|
1236
1236
|
throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");
|
|
1237
|
-
console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."), n = n.clone(), n.setInterpolation(
|
|
1237
|
+
console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."), n = n.clone(), n.setInterpolation(we);
|
|
1238
1238
|
}
|
|
1239
1239
|
const l = c.morphTargetInfluences.length, h = c.morphTargetDictionary[o.propertyIndex];
|
|
1240
1240
|
if (h === void 0)
|
package/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./model-context-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./model-context-BmfXsk0j.cjs"),o=require("./use-optimize-model-BXIlJ5Yx.cjs");exports.ModelContext=e.ModelContext;exports.ModelFileTypes=e.ModelFileTypes;exports.ModelProvider=e.ModelProvider;exports.useLoadModel=e.useLoadModel;exports.useModelContext=e.useModelContext;exports.useOptimizeModel=o.useOptimizeModel;
|
package/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as s, M as a, b as d, u as l, c as t } from "./model-context-
|
|
2
|
-
import { u as r } from "./use-optimize-model-
|
|
1
|
+
import { a as s, M as a, b as d, u as l, c as t } from "./model-context-qjRd1gfd.js";
|
|
2
|
+
import { u as r } from "./use-optimize-model-BpcR9d1L.js";
|
|
3
3
|
export {
|
|
4
4
|
s as ModelContext,
|
|
5
5
|
a as ModelFileTypes,
|