@tresjs/cientos 3.8.0 → 4.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/shapes/RoundedBox.vue.d.ts +58 -0
- package/dist/core/shapes/index.d.ts +2 -1
- package/dist/core/staging/Ocean.vue.d.ts +163 -0
- package/dist/core/staging/Sky.vue.d.ts +6 -1
- package/dist/core/staging/Sparkles/component.vue.d.ts +1 -1
- package/dist/core/staging/index.d.ts +2 -1
- package/dist/trescientos.js +4474 -4173
- package/dist/trescientos.umd.cjs +147 -51
- package/package.json +2 -3
package/dist/trescientos.umd.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/cientos
|
|
3
|
-
* version:
|
|
3
|
+
* version: v4.0.0-next.0
|
|
4
4
|
* (c) 2024
|
|
5
5
|
* description: Collection of useful helpers and fully functional, ready-made abstractions for Tres
|
|
6
6
|
* author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
|
|
7
7
|
*/
|
|
8
|
-
(function(
|
|
8
|
+
(function(se,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("three"),require("vue"),require("@tresjs/core"),require("tweakpane")):typeof define=="function"&&define.amd?define(["exports","three","vue","@tresjs/core","tweakpane"],c):(se=typeof globalThis<"u"?globalThis:se||self,c(se.trescientos={},se.Three,se.Vue,se.TresjsCore,se.tweakpane))})(this,function(se,c,f,ae,Wi){"use strict";var ud=Object.defineProperty;var hd=(se,c,f)=>c in se?ud(se,c,{enumerable:!0,configurable:!0,writable:!0,value:f}):se[c]=f;var le=(se,c,f)=>(hd(se,typeof c!="symbol"?c+"":c,f),f);function Yi(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const Vr=Yi(c);function Rr(o,e){if(e===c.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),o;if(e===c.TriangleFanDrawMode||e===c.TriangleStripDrawMode){let t=o.getIndex();if(t===null){const i=[],a=o.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)i.push(l);o.setIndex(i),t=o.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),o}const n=t.count-2,r=[];if(t)if(e===c.TriangleFanDrawMode)for(let i=1;i<=n;i++)r.push(t.getX(0)),r.push(t.getX(i)),r.push(t.getX(i+1));else for(let i=0;i<n;i++)i%2===0?(r.push(t.getX(i)),r.push(t.getX(i+1)),r.push(t.getX(i+2))):(r.push(t.getX(i+2)),r.push(t.getX(i+1)),r.push(t.getX(i)));r.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=o.clone();return s.setIndex(r),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),o}const Gr=parseInt(c.REVISION.replace(/\D+/g,""));var Xi=Object.defineProperty,Zi=(o,e,t)=>e in o?Xi(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,Ki=(o,e,t)=>(Zi(o,typeof e!="symbol"?e+"":e,t),t);async function jr(o){const e=await o.arrayBuffer(),t=btoa(String.fromCharCode(...new Uint8Array(e)));return`data:${o.type||""};base64,${t}`}let dn,Vn,Lt,pn;function Rn(o,e=1/0,t=null){Vn||(Vn=new c.PlaneGeometry(2,2,1,1)),Lt||(Lt=new c.ShaderMaterial({uniforms:{blitTexture:new c.Uniform(o)},vertexShader:`
|
|
9
9
|
varying vec2 vUv;
|
|
10
10
|
void main(){
|
|
11
11
|
vUv = uv;
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
gl_FragColor = texture2D( blitTexture, vUv);
|
|
25
25
|
#endif
|
|
26
26
|
}
|
|
27
|
-
`})),Tt.uniforms.blitTexture.value=o,Tt.defines.IS_SRGB="colorSpace"in o?o.colorSpace==="srgb":o.encoding===3001,Tt.needsUpdate=!0,fn||(fn=new c.Mesh(Nn,Tt),fn.frustrumCulled=!1);const n=new c.PerspectiveCamera,s=new c.Scene;s.add(fn),t||(t=hn=new c.WebGLRenderer({antialias:!1})),t.setSize(Math.min(o.image.width,e),Math.min(o.image.height,e)),t.clear(),t.render(s,n);const r=new c.Texture(t.domElement);return r.minFilter=o.minFilter,r.magFilter=o.magFilter,r.wrapS=o.wrapS,r.wrapT=o.wrapT,r.name=o.name,hn&&(hn.dispose(),hn=null),r}const Gs={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 Vn{constructor(){this.pluginCallbacks=[],this.register(function(e){return new no(e)}),this.register(function(e){return new so(e)}),this.register(function(e){return new oo(e)}),this.register(function(e){return new ao(e)}),this.register(function(e){return new lo(e)}),this.register(function(e){return new co(e)}),this.register(function(e){return new ro(e)}),this.register(function(e){return new io(e)}),this.register(function(e){return new uo(e)}),this.register(function(e){return new ho(e)}),this.register(function(e){return new fo(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,n,s){const r=new to,i=[];for(let a=0,l=this.pluginCallbacks.length;a<l;a++)i.push(this.pluginCallbacks[a](r));r.setPlugins(i),r.write(e,t,s).catch(n)}parseAsync(e,t){const n=this;return new Promise(function(s,r){n.parse(e,s,r,t)})}}Wi(Vn,"Utils",{insertKeyframe:function(o,e){const n=o.getValueSize(),s=new o.TimeBufferType(o.times.length+1),r=new o.ValueBufferType(o.values.length+n),i=o.createInterpolant(new o.ValueBufferType(n));let a;if(o.times.length===0){s[0]=e;for(let l=0;l<n;l++)r[l]=0;a=0}else if(e<o.times[0]){if(Math.abs(o.times[0]-e)<.001)return 0;s[0]=e,s.set(o.times,1),r.set(i.evaluate(e),0),r.set(o.values,n),a=0}else if(e>o.times[o.times.length-1]){if(Math.abs(o.times[o.times.length-1]-e)<.001)return o.times.length-1;s[s.length-1]=e,s.set(o.times,0),r.set(o.values,0),r.set(i.evaluate(e),o.values.length),a=s.length-1}else for(let l=0;l<o.times.length;l++){if(Math.abs(o.times[l]-e)<.001)return l;if(o.times[l]<e&&o.times[l+1]>e){s.set(o.times.slice(0,l+1),0),s[l+1]=e,s.set(o.times.slice(l+1),l+2),r.set(o.values.slice(0,(l+1)*n),0),r.set(i.evaluate(e),(l+1)*n),r.set(o.values.slice((l+1)*n),(l+2)*n),a=l+1;break}}return o.times=s,o.values=r,a},mergeMorphTargetTracks:function(o,e){const t=[],n={},s=o.tracks;for(let r=0;r<s.length;++r){let i=s[r];const a=c.PropertyBinding.parseTrackName(i.name),l=c.PropertyBinding.findNode(e,a.nodeName);if(a.propertyName!=="morphTargetInfluences"||a.propertyIndex===void 0){t.push(i);continue}if(i.createInterpolant!==i.InterpolantFactoryMethodDiscrete&&i.createInterpolant!==i.InterpolantFactoryMethodLinear){if(i.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."),i=i.clone(),i.setInterpolation(c.InterpolateLinear)}const u=l.morphTargetInfluences.length,h=l.morphTargetDictionary[a.propertyIndex];if(h===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let d;if(n[l.uuid]===void 0){d=i.clone();const g=new d.ValueBufferType(u*d.times.length);for(let x=0;x<d.times.length;x++)g[x*u+h]=d.values[x];d.name=(a.nodeName||"")+".morphTargetInfluences",d.values=g,n[l.uuid]=d,t.push(d);continue}const y=i.createInterpolant(new i.ValueBufferType(1));d=n[l.uuid];for(let g=0;g<d.times.length;g++)d.values[g*u+h]=y.evaluate(d.times[g]);for(let g=0;g<i.times.length;g++){const x=this.insertKeyframe(d,i.times[g]);d.values[x*u+h]=i.values[g]}}return o.tracks=t,o}});const we={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},Rn="KHR_mesh_quantization",Ee={};Ee[c.NearestFilter]=we.NEAREST,Ee[c.NearestMipmapNearestFilter]=we.NEAREST_MIPMAP_NEAREST,Ee[c.NearestMipmapLinearFilter]=we.NEAREST_MIPMAP_LINEAR,Ee[c.LinearFilter]=we.LINEAR,Ee[c.LinearMipmapNearestFilter]=we.LINEAR_MIPMAP_NEAREST,Ee[c.LinearMipmapLinearFilter]=we.LINEAR_MIPMAP_LINEAR,Ee[c.ClampToEdgeWrapping]=we.CLAMP_TO_EDGE,Ee[c.RepeatWrapping]=we.REPEAT,Ee[c.MirroredRepeatWrapping]=we.MIRRORED_REPEAT;const js={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},Zi=new c.Color,Es=12,Ki=1179937895,qi=2,Ys=8,Qi=1313821514,Ji=5130562;function jt(o,e){return o.length===e.length&&o.every(function(t,n){return t===e[n]})}function Hi(o){return new TextEncoder().encode(o).buffer}function $i(o){return jt(o.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function eo(o,e,t){const n={min:new Array(o.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(o.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let s=e;s<e+t;s++)for(let r=0;r<o.itemSize;r++){let i;o.itemSize>4?i=o.array[s*o.itemSize+r]:(r===0?i=o.getX(s):r===1?i=o.getY(s):r===2?i=o.getZ(s):r===3&&(i=o.getW(s)),o.normalized===!0&&(i=c.MathUtils.normalize(i,o.array))),n.min[r]=Math.min(n.min[r],i),n.max[r]=Math.max(n.max[r],i)}return n}function Xs(o){return Math.ceil(o/4)*4}function Gn(o,e=0){const t=Xs(o.byteLength);if(t!==o.byteLength){const n=new Uint8Array(t);if(n.set(new Uint8Array(o)),e!==0)for(let s=o.byteLength;s<t;s++)n[s]=e;return n.buffer}return o}function Ws(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function Zs(o,e){if(o.toBlob!==void 0)return new Promise(n=>o.toBlob(n,e));let t;return e==="image/jpeg"?t=.92:e==="image/webp"&&(t=.8),o.convertToBlob({type:e,quality:t})}class to{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);const s=this,r=s.buffers,i=s.json;n=s.options;const a=s.extensionsUsed,l=s.extensionsRequired,u=new Blob(r,{type:"application/octet-stream"}),h=Object.keys(a),d=Object.keys(l);h.length>0&&(i.extensionsUsed=h),d.length>0&&(i.extensionsRequired=d),i.buffers&&i.buffers.length>0&&(i.buffers[0].byteLength=u.size),n.binary===!0?u.arrayBuffer().then(y=>{const g=Gn(y),x=new DataView(new ArrayBuffer(Ys));x.setUint32(0,g.byteLength,!0),x.setUint32(4,Ji,!0);const w=Gn(Hi(JSON.stringify(i)),32),v=new DataView(new ArrayBuffer(Ys));v.setUint32(0,w.byteLength,!0),v.setUint32(4,Qi,!0);const P=new ArrayBuffer(Es),D=new DataView(P);D.setUint32(0,Ki,!0),D.setUint32(4,qi,!0);const S=Es+v.byteLength+w.byteLength+x.byteLength+g.byteLength;D.setUint32(8,S,!0),new Blob([P,v,w,x,g],{type:"application/octet-stream"}).arrayBuffer().then(t)}):i.buffers&&i.buffers.length>0?Rs(u).then(y=>{i.buffers[0].uri=y,t(i)}):t(i)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;const n=this.options,s=this.extensionsUsed;try{const r=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&r.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(const i in r.gltfExtensions)t.extensions[i]=r.gltfExtensions[i],s[i]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(t.extras=r)}catch(r){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+r.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 n=new c.Vector3;for(let s=0,r=e.count;s<r;s++)if(Math.abs(n.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 n=e.clone(),s=new c.Vector3;for(let r=0,i=n.count;r<i;r++)s.fromBufferAttribute(n,r),s.x===0&&s.y===0&&s.z===0?s.setX(1):s.normalize(),n.setXYZ(r,s.x,s.y,s.z);return t.attributesNormalized.set(e,n),n}applyTextureTransform(e,t){let n=!1;const s={};(t.offset.x!==0||t.offset.y!==0)&&(s.offset=t.offset.toArray(),n=!0),t.rotation!==0&&(s.rotation=t.rotation,n=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(s.scale=t.repeat.toArray(),n=!0),n&&(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 n(g){return("colorSpace"in g?g.colorSpace==="srgb":g.encoding===3001)?function(w){return w<.04045?w*.0773993808:Math.pow(w*.9478672986+.0521327014,2.4)}:function(w){return w}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof c.CompressedTexture&&(e=zn(e)),t instanceof c.CompressedTexture&&(t=zn(t));const s=e?e.image:null,r=t?t.image:null,i=Math.max(s?s.width:0,r?r.width:0),a=Math.max(s?s.height:0,r?r.height:0),l=Ws();l.width=i,l.height=a;const u=l.getContext("2d");u.fillStyle="#00ffff",u.fillRect(0,0,i,a);const h=u.getImageData(0,0,i,a);if(s){u.drawImage(s,0,0,i,a);const g=n(e),x=u.getImageData(0,0,i,a).data;for(let w=2;w<x.length;w+=4)h.data[w]=g(x[w]/256)*256}if(r){u.drawImage(r,0,0,i,a);const g=n(t),x=u.getImageData(0,0,i,a).data;for(let w=1;w<x.length;w+=4)h.data[w]=g(x[w]/256)*256}u.putImageData(h,0,0);const y=(e||t).clone();return y.source=new c.Texture(l).source,"colorSpace"in y?y.colorSpace="":y.encoding=3e3,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,n=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,t,n,s,r){const i=this.json;i.bufferViews||(i.bufferViews=[]);let a;switch(t){case we.BYTE:case we.UNSIGNED_BYTE:a=1;break;case we.SHORT:case we.UNSIGNED_SHORT:a=2;break;default:a=4}const l=Xs(s*e.itemSize*a),u=new DataView(new ArrayBuffer(l));let h=0;for(let g=n;g<n+s;g++)for(let x=0;x<e.itemSize;x++){let w;e.itemSize>4?w=e.array[g*e.itemSize+x]:(x===0?w=e.getX(g):x===1?w=e.getY(g):x===2?w=e.getZ(g):x===3&&(w=e.getW(g)),e.normalized===!0&&(w=c.MathUtils.normalize(w,e.array))),t===we.FLOAT?u.setFloat32(h,w,!0):t===we.INT?u.setInt32(h,w,!0):t===we.UNSIGNED_INT?u.setUint32(h,w,!0):t===we.SHORT?u.setInt16(h,w,!0):t===we.UNSIGNED_SHORT?u.setUint16(h,w,!0):t===we.BYTE?u.setInt8(h,w):t===we.UNSIGNED_BYTE&&u.setUint8(h,w),h+=a}const d={buffer:this.processBuffer(u.buffer),byteOffset:this.byteOffset,byteLength:l};return r!==void 0&&(d.target=r),r===we.ARRAY_BUFFER&&(d.byteStride=e.itemSize*a),this.byteOffset+=l,i.bufferViews.push(d),{id:i.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),e.arrayBuffer().then(s=>{const r=Gn(s),i={buffer:t.processBuffer(r),byteOffset:t.byteOffset,byteLength:r.byteLength};return t.byteOffset+=r.byteLength,n.bufferViews.push(i)-1})}processAccessor(e,t,n,s){const r=this.json,i={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"};let a;if(e.array.constructor===Float32Array)a=we.FLOAT;else if(e.array.constructor===Int32Array)a=we.INT;else if(e.array.constructor===Uint32Array)a=we.UNSIGNED_INT;else if(e.array.constructor===Int16Array)a=we.SHORT;else if(e.array.constructor===Uint16Array)a=we.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)a=we.BYTE;else if(e.array.constructor===Uint8Array)a=we.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(n===void 0&&(n=0),s===void 0&&(s=e.count),s===0)return null;const l=eo(e,n,s);let u;t!==void 0&&(u=e===t.index?we.ELEMENT_ARRAY_BUFFER:we.ARRAY_BUFFER);const h=this.processBufferView(e,a,n,s,u),d={bufferView:h.id,byteOffset:h.byteOffset,componentType:a,count:s,max:l.max,min:l.min,type:i[e.itemSize]};return e.normalized===!0&&(d.normalized=!0),r.accessors||(r.accessors=[]),r.accessors.push(d)-1}processImage(e,t,n,s="image/png"){if(e!==null){const r=this,i=r.cache,a=r.json,l=r.options,u=r.pending;i.images.has(e)||i.images.set(e,{});const h=i.images.get(e),d=s+":flipY/"+n.toString();if(h[d]!==void 0)return h[d];a.images||(a.images=[]);const y={mimeType:s},g=Ws();g.width=Math.min(e.width,l.maxTextureSize),g.height=Math.min(e.height,l.maxTextureSize);const x=g.getContext("2d");if(n===!0&&(x.translate(0,g.height),x.scale(1,-1)),e.data!==void 0){t!==c.RGBAFormat&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const v=new Uint8ClampedArray(e.height*e.width*4);for(let P=0;P<v.length;P+=4)v[P+0]=e.data[P+0],v[P+1]=e.data[P+1],v[P+2]=e.data[P+2],v[P+3]=e.data[P+3];x.putImageData(new ImageData(v,e.width,e.height),0,0)}else x.drawImage(e,0,0,g.width,g.height);l.binary===!0?u.push(Zs(g,s).then(v=>r.processBufferViewImage(v)).then(v=>{y.bufferView=v})):g.toDataURL!==void 0?y.uri=g.toDataURL(s):u.push(Zs(g,s).then(Rs).then(v=>{y.uri=v}));const w=a.images.push(y)-1;return h[d]=w,w}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 n={magFilter:Ee[e.magFilter],minFilter:Ee[e.minFilter],wrapS:Ee[e.wrapS],wrapT:Ee[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){const n=this.options,s=this.cache,r=this.json;if(s.textures.has(e))return s.textures.get(e);r.textures||(r.textures=[]),e instanceof c.CompressedTexture&&(e=zn(e,n.maxTextureSize));let i=e.userData.mimeType;i==="image/webp"&&(i="image/png");const a={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,i)};e.name&&(a.name=e.name),this._invokeAll(function(u){u.writeTexture&&u.writeTexture(e,a)});const l=r.textures.push(a)-1;return s.textures.set(e,l),l}processMaterial(e){const t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);const s={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const r=e.color.toArray().concat([e.opacity]);if(jt(r,[1,1,1,1])||(s.pbrMetallicRoughness.baseColorFactor=r),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 a=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),l={index:this.processTexture(a),channel:a.channel};this.applyTextureTransform(l,a),s.pbrMetallicRoughness.metallicRoughnessTexture=l}if(e.map){const a={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(a,e.map),s.pbrMetallicRoughness.baseColorTexture=a}if(e.emissive){const a=e.emissive;if(Math.max(a.r,a.g,a.b)>0&&(s.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const u={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(u,e.emissiveMap),s.emissiveTexture=u}}if(e.normalMap){const a={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(a.scale=e.normalScale.x),this.applyTextureTransform(a,e.normalMap),s.normalTexture=a}if(e.aoMap){const a={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(a.strength=e.aoMapIntensity),this.applyTextureTransform(a,e.aoMap),s.occlusionTexture=a}e.transparent?s.alphaMode="BLEND":e.alphaTest>0&&(s.alphaMode="MASK",s.alphaCutoff=e.alphaTest),e.side===c.DoubleSide&&(s.doubleSided=!0),e.name!==""&&(s.name=e.name),this.serializeUserData(e,s),this._invokeAll(function(a){a.writeMaterial&&a.writeMaterial(e,s)});const i=n.materials.push(s)-1;return t.materials.set(e,i),i}processMesh(e){const t=this.cache,n=this.json,s=[e.geometry.uuid];if(Array.isArray(e.material))for(let S=0,_=e.material.length;S<_;S++)s.push(e.material[S].uuid);else s.push(e.material.uuid);const r=s.join(":");if(t.meshes.has(r))return t.meshes.get(r);const i=e.geometry;let a;e.isLineSegments?a=we.LINES:e.isLineLoop?a=we.LINE_LOOP:e.isLine?a=we.LINE_STRIP:e.isPoints?a=we.POINTS:a=e.material.wireframe?we.LINES:we.TRIANGLES;const l={},u={},h=[],d=[],y={...Vs>=152?{uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3"}:{uv:"TEXCOORD_0",uv2:"TEXCOORD_1"},color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},g=i.getAttribute("normal");g!==void 0&&!this.isNormalizedNormalAttribute(g)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),i.setAttribute("normal",this.createNormalizedNormalAttribute(g)));let x=null;for(let S in i.attributes){if(S.slice(0,5)==="morph")continue;const _=i.attributes[S];if(S=y[S]||S.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(S)||(S="_"+S),t.attributes.has(this.getUID(_))){u[S]=t.attributes.get(this.getUID(_));continue}x=null;const b=_.array;S==="JOINTS_0"&&!(b instanceof Uint16Array)&&!(b instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),x=new c.BufferAttribute(new Uint16Array(b),_.itemSize,_.normalized));const C=this.processAccessor(x||_,i);C!==null&&(S.startsWith("_")||this.detectMeshQuantization(S,_),u[S]=C,t.attributes.set(this.getUID(_),C))}if(g!==void 0&&i.setAttribute("normal",g),Object.keys(u).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const S=[],_=[],L={};if(e.morphTargetDictionary!==void 0)for(const b in e.morphTargetDictionary)L[e.morphTargetDictionary[b]]=b;for(let b=0;b<e.morphTargetInfluences.length;++b){const C={};let m=!1;for(const M in i.morphAttributes){if(M!=="position"&&M!=="normal"){m||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),m=!0);continue}const p=i.morphAttributes[M][b],I=M.toUpperCase(),F=i.attributes[M];if(t.attributes.has(this.getUID(p,!0))){C[I]=t.attributes.get(this.getUID(p,!0));continue}const J=p.clone();if(!i.morphTargetsRelative)for(let G=0,Q=p.count;G<Q;G++)for(let K=0;K<p.itemSize;K++)K===0&&J.setX(G,p.getX(G)-F.getX(G)),K===1&&J.setY(G,p.getY(G)-F.getY(G)),K===2&&J.setZ(G,p.getZ(G)-F.getZ(G)),K===3&&J.setW(G,p.getW(G)-F.getW(G));C[I]=this.processAccessor(J,i),t.attributes.set(this.getUID(F,!0),C[I])}d.push(C),S.push(e.morphTargetInfluences[b]),e.morphTargetDictionary!==void 0&&_.push(L[b])}l.weights=S,_.length>0&&(l.extras={},l.extras.targetNames=_)}const w=Array.isArray(e.material);if(w&&i.groups.length===0)return null;const v=w?e.material:[e.material],P=w?i.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let S=0,_=P.length;S<_;S++){const L={mode:a,attributes:u};if(this.serializeUserData(i,L),d.length>0&&(L.targets=d),i.index!==null){let C=this.getUID(i.index);(P[S].start!==void 0||P[S].count!==void 0)&&(C+=":"+P[S].start+":"+P[S].count),t.attributes.has(C)?L.indices=t.attributes.get(C):(L.indices=this.processAccessor(i.index,i,P[S].start,P[S].count),t.attributes.set(C,L.indices)),L.indices===null&&delete L.indices}const b=this.processMaterial(v[P[S].materialIndex]);b!==null&&(L.material=b),h.push(L)}l.primitives=h,n.meshes||(n.meshes=[]),this._invokeAll(function(S){S.writeMesh&&S.writeMesh(e,l)});const D=n.meshes.push(l)-1;return t.meshes.set(r,D),D}detectMeshQuantization(e,t){if(this.extensionsUsed[Rn])return;let n;switch(t.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}t.normalized&&(n+=" normalized");const s=e.split("_",1)[0];Gs[s]&&Gs[s].includes(n)&&(this.extensionsUsed[Rn]=!0,this.extensionsRequired[Rn]=!0)}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const n=e.isOrthographicCamera,s={type:n?"orthographic":"perspective"};return n?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:c.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 n=this.json,s=this.nodeMap;n.animations||(n.animations=[]),e=Vn.Utils.mergeMorphTargetTracks(e.clone(),t);const r=e.tracks,i=[],a=[];for(let l=0;l<r.length;++l){const u=r[l],h=c.PropertyBinding.parseTrackName(u.name);let d=c.PropertyBinding.findNode(t,h.nodeName);const y=js[h.propertyName];if(h.objectName==="bones"&&(d.isSkinnedMesh===!0?d=d.skeleton.getBoneByName(h.objectIndex):d=void 0),!d||!y)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',u.name),null;const g=1;let x=u.values.length/u.times.length;y===js.morphTargetInfluences&&(x/=d.morphTargetInfluences.length);let w;u.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(w="CUBICSPLINE",x/=3):u.getInterpolation()===c.InterpolateDiscrete?w="STEP":w="LINEAR",a.push({input:this.processAccessor(new c.BufferAttribute(u.times,g)),output:this.processAccessor(new c.BufferAttribute(u.values,x)),interpolation:w}),i.push({sampler:a.length-1,target:{node:s.get(d),path:y}})}return n.animations.push({name:e.name||"clip_"+n.animations.length,samplers:a,channels:i}),n.animations.length-1}processSkin(e){const t=this.json,n=this.nodeMap,s=t.nodes[n.get(e)],r=e.skeleton;if(r===void 0)return null;const i=e.skeleton.bones[0];if(i===void 0)return null;const a=[],l=new Float32Array(r.bones.length*16),u=new c.Matrix4;for(let d=0;d<r.bones.length;++d)a.push(n.get(r.bones[d])),u.copy(r.boneInverses[d]),u.multiply(e.bindMatrix).toArray(l,d*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new c.BufferAttribute(l,16)),joints:a,skeleton:n.get(i)}),s.skin=t.skins.length-1}processNode(e){const t=this.json,n=this.options,s=this.nodeMap;t.nodes||(t.nodes=[]);const r={};if(n.trs){const a=e.quaternion.toArray(),l=e.position.toArray(),u=e.scale.toArray();jt(a,[0,0,0,1])||(r.rotation=a),jt(l,[0,0,0])||(r.translation=l),jt(u,[1,1,1])||(r.scale=u)}else e.matrixAutoUpdate&&e.updateMatrix(),$i(e.matrix)===!1&&(r.matrix=e.matrix.elements);if(e.name!==""&&(r.name=String(e.name)),this.serializeUserData(e,r),e.isMesh||e.isLine||e.isPoints){const a=this.processMesh(e);a!==null&&(r.mesh=a)}else e.isCamera&&(r.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const a=[];for(let l=0,u=e.children.length;l<u;l++){const h=e.children[l];if(h.visible||n.onlyVisible===!1){const d=this.processNode(h);d!==null&&a.push(d)}}a.length>0&&(r.children=a)}this._invokeAll(function(a){a.writeNode&&a.writeNode(e,r)});const i=t.nodes.push(r)-1;return s.set(e,i),i}processScene(e){const t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);const s={};e.name!==""&&(s.name=e.name),t.scenes.push(s);const r=[];for(let i=0,a=e.children.length;i<a;i++){const l=e.children[i];if(l.visible||n.onlyVisible===!1){const u=this.processNode(l);u!==null&&r.push(u)}}r.length>0&&(s.nodes=r),this.serializeUserData(e,s)}processObjects(e){const t=new c.Scene;t.name="AuxScene";for(let n=0;n<e.length;n++)t.children.push(e[n]);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 n=[];for(let s=0;s<e.length;s++)e[s]instanceof c.Scene?this.processScene(e[s]):n.push(e[s]);n.length>0&&this.processObjects(n);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,n=this.plugins.length;t<n;t++)e(this.plugins[t])}}class no{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 n=this.writer,s=n.json,r=n.extensionsUsed,i={};e.name&&(i.name=e.name),i.color=e.color.toArray(),i.intensity=e.intensity,e.isDirectionalLight?i.type="directional":e.isPointLight?(i.type="point",e.distance>0&&(i.range=e.distance)):e.isSpotLight&&(i.type="spot",e.distance>0&&(i.range=e.distance),i.spot={},i.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,i.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."),r[this.name]||(s.extensions=s.extensions||{},s.extensions[this.name]={lights:[]},r[this.name]=!0);const a=s.extensions[this.name].lights;a.push(i),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}}let so=class{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}},ro=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;const n=this.writer,s=n.extensionsUsed,r={};if(r.clearcoatFactor=e.clearcoat,e.clearcoatMap){const i={index:n.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(i,e.clearcoatMap),r.clearcoatTexture=i}if(r.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const i={index:n.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(i,e.clearcoatRoughnessMap),r.clearcoatRoughnessTexture=i}if(e.clearcoatNormalMap){const i={index:n.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};n.applyTextureTransform(i,e.clearcoatNormalMap),r.clearcoatNormalTexture=i}t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},io=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;const n=this.writer,s=n.extensionsUsed,r={};if(r.iridescenceFactor=e.iridescence,e.iridescenceMap){const i={index:n.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(i,e.iridescenceMap),r.iridescenceTexture=i}if(r.iridescenceIor=e.iridescenceIOR,r.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],r.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const i={index:n.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(i,e.iridescenceThicknessMap),r.iridescenceThicknessTexture=i}t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},oo=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,s=n.extensionsUsed,r={};if(r.transmissionFactor=e.transmission,e.transmissionMap){const i={index:n.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(i,e.transmissionMap),r.transmissionTexture=i}t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},ao=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,s=n.extensionsUsed,r={};if(r.thicknessFactor=e.thickness,e.thicknessMap){const i={index:n.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(i,e.thicknessMap),r.thicknessTexture=i}r.attenuationDistance=e.attenuationDistance,r.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},lo=class{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,r={};r.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},co=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(Zi)&&!e.specularIntensityMap&&!e.specularColorTexture)return;const n=this.writer,s=n.extensionsUsed,r={};if(e.specularIntensityMap){const i={index:n.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(i,e.specularIntensityMap),r.specularTexture=i}if(e.specularColorMap){const i={index:n.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(i,e.specularColorMap),r.specularColorTexture=i}r.specularFactor=e.specularIntensity,r.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},uo=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;const n=this.writer,s=n.extensionsUsed,r={};if(e.sheenRoughnessMap){const i={index:n.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(i,e.sheenRoughnessMap),r.sheenRoughnessTexture=i}if(e.sheenColorMap){const i={index:n.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(i,e.sheenColorMap),r.sheenColorTexture=i}r.sheenRoughnessFactor=e.sheenRoughness,r.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},ho=class{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;const n=this.writer,s=n.extensionsUsed,r={};if(e.anisotropyMap){const i={index:n.processTexture(e.anisotropyMap)};n.applyTextureTransform(i,e.anisotropyMap),r.anisotropyTexture=i}r.anisotropyStrength=e.anisotropy,r.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}},fo=class{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,r={};r.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=r,s[this.name]=!0}};var Xe=Uint8Array,ht=Uint16Array,jn=Uint32Array,Ks=new Xe([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),qs=new Xe([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),po=new Xe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Qs=function(o,e){for(var t=new ht(31),n=0;n<31;++n)t[n]=e+=1<<o[n-1];for(var s=new jn(t[30]),n=1;n<30;++n)for(var r=t[n];r<t[n+1];++r)s[r]=r-t[n]<<5|n;return[t,s]},Js=Qs(Ks,2),Hs=Js[0],mo=Js[1];Hs[28]=258,mo[258]=28;for(var go=Qs(qs,0),yo=go[0],En=new ht(32768),Te=0;Te<32768;++Te){var ft=(Te&43690)>>>1|(Te&21845)<<1;ft=(ft&52428)>>>2|(ft&13107)<<2,ft=(ft&61680)>>>4|(ft&3855)<<4,En[Te]=((ft&65280)>>>8|(ft&255)<<8)>>>1}for(var Et=function(o,e,t){for(var n=o.length,s=0,r=new ht(e);s<n;++s)++r[o[s]-1];var i=new ht(e);for(s=0;s<e;++s)i[s]=i[s-1]+r[s-1]<<1;var a;if(t){a=new ht(1<<e);var l=15-e;for(s=0;s<n;++s)if(o[s])for(var u=s<<4|o[s],h=e-o[s],d=i[o[s]-1]++<<h,y=d|(1<<h)-1;d<=y;++d)a[En[d]>>>l]=u}else for(a=new ht(n),s=0;s<n;++s)o[s]&&(a[s]=En[i[o[s]-1]++]>>>15-o[s]);return a},Yt=new Xe(288),Te=0;Te<144;++Te)Yt[Te]=8;for(var Te=144;Te<256;++Te)Yt[Te]=9;for(var Te=256;Te<280;++Te)Yt[Te]=7;for(var Te=280;Te<288;++Te)Yt[Te]=8;for(var $s=new Xe(32),Te=0;Te<32;++Te)$s[Te]=5;var _o=Et(Yt,9,1),vo=Et($s,5,1),Yn=function(o){for(var e=o[0],t=1;t<o.length;++t)o[t]>e&&(e=o[t]);return e},qe=function(o,e,t){var n=e/8|0;return(o[n]|o[n+1]<<8)>>(e&7)&t},Xn=function(o,e){var t=e/8|0;return(o[t]|o[t+1]<<8|o[t+2]<<16)>>(e&7)},xo=function(o){return(o/8|0)+(o&7&&1)},wo=function(o,e,t){(e==null||e<0)&&(e=0),(t==null||t>o.length)&&(t=o.length);var n=new(o instanceof ht?ht:o instanceof jn?jn:Xe)(t-e);return n.set(o.subarray(e,t)),n},bo=function(o,e,t){var n=o.length;if(!n||t&&!t.l&&n<5)return e||new Xe(0);var s=!e||t,r=!t||t.i;t||(t={}),e||(e=new Xe(n*3));var i=function(ee){var N=e.length;if(ee>N){var R=new Xe(Math.max(N*2,ee));R.set(e),e=R}},a=t.f||0,l=t.p||0,u=t.b||0,h=t.l,d=t.d,y=t.m,g=t.n,x=n*8;do{if(!h){t.f=a=qe(o,l,1);var w=qe(o,l+1,3);if(l+=3,w)if(w==1)h=_o,d=vo,y=9,g=5;else if(w==2){var S=qe(o,l,31)+257,_=qe(o,l+10,15)+4,L=S+qe(o,l+5,31)+1;l+=14;for(var b=new Xe(L),C=new Xe(19),m=0;m<_;++m)C[po[m]]=qe(o,l+m*3,7);l+=_*3;for(var M=Yn(C),p=(1<<M)-1,I=Et(C,M,1),m=0;m<L;){var F=I[qe(o,l,p)];l+=F&15;var v=F>>>4;if(v<16)b[m++]=v;else{var J=0,G=0;for(v==16?(G=3+qe(o,l,3),l+=2,J=b[m-1]):v==17?(G=3+qe(o,l,7),l+=3):v==18&&(G=11+qe(o,l,127),l+=7);G--;)b[m++]=J}}var Q=b.subarray(0,S),K=b.subarray(S);y=Yn(Q),g=Yn(K),h=Et(Q,y,1),d=Et(K,g,1)}else throw"invalid block type";else{var v=xo(l)+4,P=o[v-4]|o[v-3]<<8,D=v+P;if(D>n){if(r)throw"unexpected EOF";break}s&&i(u+P),e.set(o.subarray(v,D),u),t.b=u+=P,t.p=l=D*8;continue}if(l>x){if(r)throw"unexpected EOF";break}}s&&i(u+131072);for(var Z=(1<<y)-1,X=(1<<g)-1,ne=l;;ne=l){var J=h[Xn(o,l)&Z],se=J>>>4;if(l+=J&15,l>x){if(r)throw"unexpected EOF";break}if(!J)throw"invalid length/literal";if(se<256)e[u++]=se;else if(se==256){ne=l,h=null;break}else{var ue=se-254;if(se>264){var m=se-257,j=Ks[m];ue=qe(o,l,(1<<j)-1)+Hs[m],l+=j}var z=d[Xn(o,l)&X],A=z>>>4;if(!z)throw"invalid distance";l+=z&15;var K=yo[A];if(A>3){var j=qs[A];K+=Xn(o,l)&(1<<j)-1,l+=j}if(l>x){if(r)throw"unexpected EOF";break}s&&i(u+131072);for(var V=u+ue;u<V;u+=4)e[u]=e[u-K],e[u+1]=e[u+1-K],e[u+2]=e[u+2-K],e[u+3]=e[u+3-K];u=V}}t.l=h,t.p=ne,t.b=u,h&&(a=1,t.m=y,t.d=d,t.n=g)}while(!a);return u==e.length?e:wo(e,0,u)},Mo=new Xe(0),So=function(o){if((o[0]&15)!=8||o[0]>>>4>7||(o[0]<<8|o[1])%31)throw"invalid zlib data";if(o[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Ao(o,e){return bo((So(o),o.subarray(2,-4)),e)}var Po=typeof TextDecoder<"u"&&new TextDecoder,Co=0;try{Po.decode(Mo,{stream:!0}),Co=1}catch{}const ke=new c.Triangle,dn=new c.Vector3;class To{constructor(e){let t=e.geometry;t.index&&(console.warn("THREE.MeshSurfaceSampler: Converting geometry to non-indexed BufferGeometry."),t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.colorAttribute=this.geometry.getAttribute("color"),this.weightAttribute=null,this.distribution=null}setWeightAttribute(e){return this.weightAttribute=e?this.geometry.getAttribute(e):null,this}build(){const e=this.positionAttribute,t=this.weightAttribute,n=new Float32Array(e.count/3);for(let r=0;r<e.count;r+=3){let i=1;t&&(i=t.getX(r)+t.getX(r+1)+t.getX(r+2)),ke.a.fromBufferAttribute(e,r),ke.b.fromBufferAttribute(e,r+1),ke.c.fromBufferAttribute(e,r+2),i*=ke.getArea(),n[r/3]=i}this.distribution=new Float32Array(e.count/3);let s=0;for(let r=0;r<n.length;r++)s+=n[r],this.distribution[r]=s;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t,n){const s=this.sampleFaceIndex();return this.sampleFace(s,e,t,n)}sampleFaceIndex(){const e=this.distribution[this.distribution.length-1];return this.binarySearch(this.randomFunction()*e)}binarySearch(e){const t=this.distribution;let n=0,s=t.length-1,r=-1;for(;n<=s;){const i=Math.ceil((n+s)/2);if(i===0||t[i-1]<=e&&t[i]>e){r=i;break}else e<t[i]?s=i-1:n=i+1}return r}sampleFace(e,t,n,s){let r=this.randomFunction(),i=this.randomFunction();return r+i>1&&(r=1-r,i=1-i),ke.a.fromBufferAttribute(this.positionAttribute,e*3),ke.b.fromBufferAttribute(this.positionAttribute,e*3+1),ke.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(ke.a,r).addScaledVector(ke.b,i).addScaledVector(ke.c,1-(r+i)),n!==void 0&&ke.getNormal(n),s!==void 0&&this.colorAttribute!==void 0&&(ke.a.fromBufferAttribute(this.colorAttribute,e*3),ke.b.fromBufferAttribute(this.colorAttribute,e*3+1),ke.c.fromBufferAttribute(this.colorAttribute,e*3+2),dn.set(0,0,0).addScaledVector(ke.a,r).addScaledVector(ke.b,i).addScaledVector(ke.c,1-(r+i)),s.r=dn.x,s.g=dn.y,s.b=dn.z),this}}var Lo=Object.defineProperty,Io=(o,e,t)=>e in o?Lo(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,H=(o,e,t)=>(Io(o,typeof e!="symbol"?e+"":e,t),t);class Do extends c.Object3D{constructor(e,t){super(),H(this,"isTransformControls",!0),H(this,"visible",!1),H(this,"domElement"),H(this,"raycaster",new c.Raycaster),H(this,"gizmo"),H(this,"plane"),H(this,"tempVector",new c.Vector3),H(this,"tempVector2",new c.Vector3),H(this,"tempQuaternion",new c.Quaternion),H(this,"unit",{X:new c.Vector3(1,0,0),Y:new c.Vector3(0,1,0),Z:new c.Vector3(0,0,1)}),H(this,"pointStart",new c.Vector3),H(this,"pointEnd",new c.Vector3),H(this,"offset",new c.Vector3),H(this,"rotationAxis",new c.Vector3),H(this,"startNorm",new c.Vector3),H(this,"endNorm",new c.Vector3),H(this,"rotationAngle",0),H(this,"cameraPosition",new c.Vector3),H(this,"cameraQuaternion",new c.Quaternion),H(this,"cameraScale",new c.Vector3),H(this,"parentPosition",new c.Vector3),H(this,"parentQuaternion",new c.Quaternion),H(this,"parentQuaternionInv",new c.Quaternion),H(this,"parentScale",new c.Vector3),H(this,"worldPositionStart",new c.Vector3),H(this,"worldQuaternionStart",new c.Quaternion),H(this,"worldScaleStart",new c.Vector3),H(this,"worldPosition",new c.Vector3),H(this,"worldQuaternion",new c.Quaternion),H(this,"worldQuaternionInv",new c.Quaternion),H(this,"worldScale",new c.Vector3),H(this,"eye",new c.Vector3),H(this,"positionStart",new c.Vector3),H(this,"quaternionStart",new c.Quaternion),H(this,"scaleStart",new c.Vector3),H(this,"camera"),H(this,"object"),H(this,"enabled",!0),H(this,"axis",null),H(this,"mode","translate"),H(this,"translationSnap",null),H(this,"rotationSnap",null),H(this,"scaleSnap",null),H(this,"space","world"),H(this,"size",1),H(this,"dragging",!1),H(this,"showX",!0),H(this,"showY",!0),H(this,"showZ",!0),H(this,"changeEvent",{type:"change"}),H(this,"mouseDownEvent",{type:"mouseDown",mode:this.mode}),H(this,"mouseUpEvent",{type:"mouseUp",mode:this.mode}),H(this,"objectChangeEvent",{type:"objectChange"}),H(this,"intersectObjectWithRay",(s,r,i)=>{const a=r.intersectObject(s,!0);for(let l=0;l<a.length;l++)if(a[l].object.visible||i)return a[l];return!1}),H(this,"attach",s=>(this.object=s,this.visible=!0,this)),H(this,"detach",()=>(this.object=void 0,this.visible=!1,this.axis=null,this)),H(this,"reset",()=>this.enabled?(this.dragging&&this.object!==void 0&&(this.object.position.copy(this.positionStart),this.object.quaternion.copy(this.quaternionStart),this.object.scale.copy(this.scaleStart),this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent),this.pointStart.copy(this.pointEnd)),this):this),H(this,"updateMatrixWorld",()=>{this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this.parentPosition,this.parentQuaternion,this.parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this.worldScale),this.parentQuaternionInv.copy(this.parentQuaternion).invert(),this.worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this.cameraScale),this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld()}),H(this,"pointerHover",s=>{if(this.object===void 0||this.dragging===!0)return;this.raycaster.setFromCamera(s,this.camera);const r=this.intersectObjectWithRay(this.gizmo.picker[this.mode],this.raycaster);r?this.axis=r.object.name:this.axis=null}),H(this,"pointerDown",s=>{if(!(this.object===void 0||this.dragging===!0||s.button!==0)&&this.axis!==null){this.raycaster.setFromCamera(s,this.camera);const r=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(r){let i=this.space;if(this.mode==="scale"?i="local":(this.axis==="E"||this.axis==="XYZE"||this.axis==="XYZ")&&(i="world"),i==="local"&&this.mode==="rotate"){const a=this.rotationSnap;this.axis==="X"&&a&&(this.object.rotation.x=Math.round(this.object.rotation.x/a)*a),this.axis==="Y"&&a&&(this.object.rotation.y=Math.round(this.object.rotation.y/a)*a),this.axis==="Z"&&a&&(this.object.rotation.z=Math.round(this.object.rotation.z/a)*a)}this.object.updateMatrixWorld(),this.object.parent&&this.object.parent.updateMatrixWorld(),this.positionStart.copy(this.object.position),this.quaternionStart.copy(this.object.quaternion),this.scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this.worldScaleStart),this.pointStart.copy(r.point).sub(this.worldPositionStart)}this.dragging=!0,this.mouseDownEvent.mode=this.mode,this.dispatchEvent(this.mouseDownEvent)}}),H(this,"pointerMove",s=>{const r=this.axis,i=this.mode,a=this.object;let l=this.space;if(i==="scale"?l="local":(r==="E"||r==="XYZE"||r==="XYZ")&&(l="world"),a===void 0||r===null||this.dragging===!1||s.button!==-1)return;this.raycaster.setFromCamera(s,this.camera);const u=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(u){if(this.pointEnd.copy(u.point).sub(this.worldPositionStart),i==="translate")this.offset.copy(this.pointEnd).sub(this.pointStart),l==="local"&&r!=="XYZ"&&this.offset.applyQuaternion(this.worldQuaternionInv),r.indexOf("X")===-1&&(this.offset.x=0),r.indexOf("Y")===-1&&(this.offset.y=0),r.indexOf("Z")===-1&&(this.offset.z=0),l==="local"&&r!=="XYZ"?this.offset.applyQuaternion(this.quaternionStart).divide(this.parentScale):this.offset.applyQuaternion(this.parentQuaternionInv).divide(this.parentScale),a.position.copy(this.offset).add(this.positionStart),this.translationSnap&&(l==="local"&&(a.position.applyQuaternion(this.tempQuaternion.copy(this.quaternionStart).invert()),r.search("X")!==-1&&(a.position.x=Math.round(a.position.x/this.translationSnap)*this.translationSnap),r.search("Y")!==-1&&(a.position.y=Math.round(a.position.y/this.translationSnap)*this.translationSnap),r.search("Z")!==-1&&(a.position.z=Math.round(a.position.z/this.translationSnap)*this.translationSnap),a.position.applyQuaternion(this.quaternionStart)),l==="world"&&(a.parent&&a.position.add(this.tempVector.setFromMatrixPosition(a.parent.matrixWorld)),r.search("X")!==-1&&(a.position.x=Math.round(a.position.x/this.translationSnap)*this.translationSnap),r.search("Y")!==-1&&(a.position.y=Math.round(a.position.y/this.translationSnap)*this.translationSnap),r.search("Z")!==-1&&(a.position.z=Math.round(a.position.z/this.translationSnap)*this.translationSnap),a.parent&&a.position.sub(this.tempVector.setFromMatrixPosition(a.parent.matrixWorld))));else if(i==="scale"){if(r.search("XYZ")!==-1){let h=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(h*=-1),this.tempVector2.set(h,h,h)}else this.tempVector.copy(this.pointStart),this.tempVector2.copy(this.pointEnd),this.tempVector.applyQuaternion(this.worldQuaternionInv),this.tempVector2.applyQuaternion(this.worldQuaternionInv),this.tempVector2.divide(this.tempVector),r.search("X")===-1&&(this.tempVector2.x=1),r.search("Y")===-1&&(this.tempVector2.y=1),r.search("Z")===-1&&(this.tempVector2.z=1);a.scale.copy(this.scaleStart).multiply(this.tempVector2),this.scaleSnap&&this.object&&(r.search("X")!==-1&&(this.object.scale.x=Math.round(a.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),r.search("Y")!==-1&&(a.scale.y=Math.round(a.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),r.search("Z")!==-1&&(a.scale.z=Math.round(a.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this.offset.copy(this.pointEnd).sub(this.pointStart);const h=20/this.worldPosition.distanceTo(this.tempVector.setFromMatrixPosition(this.camera.matrixWorld));r==="E"?(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this.startNorm.copy(this.pointStart).normalize(),this.endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this.endNorm.cross(this.startNorm).dot(this.eye)<0?1:-1):r==="XYZE"?(this.rotationAxis.copy(this.offset).cross(this.eye).normalize(),this.rotationAngle=this.offset.dot(this.tempVector.copy(this.rotationAxis).cross(this.eye))*h):(r==="X"||r==="Y"||r==="Z")&&(this.rotationAxis.copy(this.unit[r]),this.tempVector.copy(this.unit[r]),l==="local"&&this.tempVector.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.offset.dot(this.tempVector.cross(this.eye).normalize())*h),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),l==="local"&&r!=="E"&&r!=="XYZE"?(a.quaternion.copy(this.quaternionStart),a.quaternion.multiply(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this.parentQuaternionInv),a.quaternion.copy(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),a.quaternion.multiply(this.quaternionStart).normalize())}this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent)}}),H(this,"pointerUp",s=>{s.button===0&&(this.dragging&&this.axis!==null&&(this.mouseUpEvent.mode=this.mode,this.dispatchEvent(this.mouseUpEvent)),this.dragging=!1,this.axis=null)}),H(this,"getPointer",s=>{var r;if(this.domElement&&((r=this.domElement.ownerDocument)!=null&&r.pointerLockElement))return{x:0,y:0,button:s.button};{const i=s.changedTouches?s.changedTouches[0]:s,a=this.domElement.getBoundingClientRect();return{x:(i.clientX-a.left)/a.width*2-1,y:-(i.clientY-a.top)/a.height*2+1,button:s.button}}}),H(this,"onPointerHover",s=>{if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this.getPointer(s));break}}),H(this,"onPointerDown",s=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="none",this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.pointerHover(this.getPointer(s)),this.pointerDown(this.getPointer(s)))}),H(this,"onPointerMove",s=>{this.enabled&&this.pointerMove(this.getPointer(s))}),H(this,"onPointerUp",s=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="",this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.pointerUp(this.getPointer(s)))}),H(this,"getMode",()=>this.mode),H(this,"setMode",s=>{this.mode=s}),H(this,"setTranslationSnap",s=>{this.translationSnap=s}),H(this,"setRotationSnap",s=>{this.rotationSnap=s}),H(this,"setScaleSnap",s=>{this.scaleSnap=s}),H(this,"setSize",s=>{this.size=s}),H(this,"setSpace",s=>{this.space=s}),H(this,"update",()=>{console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}),H(this,"connect",s=>{s===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.domElement=s,this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerHover),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)}),H(this,"dispose",()=>{var s,r,i,a,l,u;(s=this.domElement)==null||s.removeEventListener("pointerdown",this.onPointerDown),(r=this.domElement)==null||r.removeEventListener("pointermove",this.onPointerHover),(a=(i=this.domElement)==null?void 0:i.ownerDocument)==null||a.removeEventListener("pointermove",this.onPointerMove),(u=(l=this.domElement)==null?void 0:l.ownerDocument)==null||u.removeEventListener("pointerup",this.onPointerUp),this.traverse(h=>{const d=h;d.geometry&&d.geometry.dispose(),d.material&&d.material.dispose()})}),this.domElement=t,this.camera=e,this.gizmo=new Oo,this.add(this.gizmo),this.plane=new Fo,this.add(this.plane);const n=(s,r)=>{let i=r;Object.defineProperty(this,s,{get:function(){return i!==void 0?i:r},set:function(a){i!==a&&(i=a,this.plane[s]=a,this.gizmo[s]=a,this.dispatchEvent({type:s+"-changed",value:a}),this.dispatchEvent(this.changeEvent))}}),this[s]=r,this.plane[s]=r,this.gizmo[s]=r};n("camera",this.camera),n("object",this.object),n("enabled",this.enabled),n("axis",this.axis),n("mode",this.mode),n("translationSnap",this.translationSnap),n("rotationSnap",this.rotationSnap),n("scaleSnap",this.scaleSnap),n("space",this.space),n("size",this.size),n("dragging",this.dragging),n("showX",this.showX),n("showY",this.showY),n("showZ",this.showZ),n("worldPosition",this.worldPosition),n("worldPositionStart",this.worldPositionStart),n("worldQuaternion",this.worldQuaternion),n("worldQuaternionStart",this.worldQuaternionStart),n("cameraPosition",this.cameraPosition),n("cameraQuaternion",this.cameraQuaternion),n("pointStart",this.pointStart),n("pointEnd",this.pointEnd),n("rotationAxis",this.rotationAxis),n("rotationAngle",this.rotationAngle),n("eye",this.eye),t!==void 0&&this.connect(t)}}class Oo extends c.Object3D{constructor(){super(),H(this,"isTransformControlsGizmo",!0),H(this,"type","TransformControlsGizmo"),H(this,"tempVector",new c.Vector3(0,0,0)),H(this,"tempEuler",new c.Euler),H(this,"alignVector",new c.Vector3(0,1,0)),H(this,"zeroVector",new c.Vector3(0,0,0)),H(this,"lookAtMatrix",new c.Matrix4),H(this,"tempQuaternion",new c.Quaternion),H(this,"tempQuaternion2",new c.Quaternion),H(this,"identityQuaternion",new c.Quaternion),H(this,"unitX",new c.Vector3(1,0,0)),H(this,"unitY",new c.Vector3(0,1,0)),H(this,"unitZ",new c.Vector3(0,0,1)),H(this,"gizmo"),H(this,"picker"),H(this,"helper"),H(this,"rotationAxis",new c.Vector3),H(this,"cameraPosition",new c.Vector3),H(this,"worldPositionStart",new c.Vector3),H(this,"worldQuaternionStart",new c.Quaternion),H(this,"worldPosition",new c.Vector3),H(this,"worldQuaternion",new c.Quaternion),H(this,"eye",new c.Vector3),H(this,"camera",null),H(this,"enabled",!0),H(this,"axis",null),H(this,"mode","translate"),H(this,"space","world"),H(this,"size",1),H(this,"dragging",!1),H(this,"showX",!0),H(this,"showY",!0),H(this,"showZ",!0),H(this,"updateMatrixWorld",()=>{let se=this.space;this.mode==="scale"&&(se="local");const ue=se==="local"?this.worldQuaternion:this.identityQuaternion;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let j=[];j=j.concat(this.picker[this.mode].children),j=j.concat(this.gizmo[this.mode].children),j=j.concat(this.helper[this.mode].children);for(let z=0;z<j.length;z++){const A=j[z];A.visible=!0,A.rotation.set(0,0,0),A.position.copy(this.worldPosition);let V;if(this.camera.isOrthographicCamera?V=(this.camera.top-this.camera.bottom)/this.camera.zoom:V=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),A.scale.set(1,1,1).multiplyScalar(V*this.size/7),A.tag==="helper"){A.visible=!1,A.name==="AXIS"?(A.position.copy(this.worldPositionStart),A.visible=!!this.axis,this.axis==="X"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,0)),A.quaternion.copy(ue).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ue).dot(this.eye))>.9&&(A.visible=!1)),this.axis==="Y"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),A.quaternion.copy(ue).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ue).dot(this.eye))>.9&&(A.visible=!1)),this.axis==="Z"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),A.quaternion.copy(ue).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ue).dot(this.eye))>.9&&(A.visible=!1)),this.axis==="XYZE"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),A.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),A.quaternion.multiply(this.tempQuaternion),A.visible=this.dragging),this.axis==="E"&&(A.visible=!1)):A.name==="START"?(A.position.copy(this.worldPositionStart),A.visible=this.dragging):A.name==="END"?(A.position.copy(this.worldPosition),A.visible=this.dragging):A.name==="DELTA"?(A.position.copy(this.worldPositionStart),A.quaternion.copy(this.worldQuaternionStart),this.tempVector.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),this.tempVector.applyQuaternion(this.worldQuaternionStart.clone().invert()),A.scale.copy(this.tempVector),A.visible=this.dragging):(A.quaternion.copy(ue),this.dragging?A.position.copy(this.worldPositionStart):A.position.copy(this.worldPosition),this.axis&&(A.visible=this.axis.search(A.name)!==-1));continue}A.quaternion.copy(ue),this.mode==="translate"||this.mode==="scale"?((A.name==="X"||A.name==="XYZX")&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ue).dot(this.eye))>.99&&(A.scale.set(1e-10,1e-10,1e-10),A.visible=!1),(A.name==="Y"||A.name==="XYZY")&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ue).dot(this.eye))>.99&&(A.scale.set(1e-10,1e-10,1e-10),A.visible=!1),(A.name==="Z"||A.name==="XYZZ")&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ue).dot(this.eye))>.99&&(A.scale.set(1e-10,1e-10,1e-10),A.visible=!1),A.name==="XY"&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ue).dot(this.eye))<.2&&(A.scale.set(1e-10,1e-10,1e-10),A.visible=!1),A.name==="YZ"&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ue).dot(this.eye))<.2&&(A.scale.set(1e-10,1e-10,1e-10),A.visible=!1),A.name==="XZ"&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ue).dot(this.eye))<.2&&(A.scale.set(1e-10,1e-10,1e-10),A.visible=!1),A.name.search("X")!==-1&&(this.alignVector.copy(this.unitX).applyQuaternion(ue).dot(this.eye)<0?A.tag==="fwd"?A.visible=!1:A.scale.x*=-1:A.tag==="bwd"&&(A.visible=!1)),A.name.search("Y")!==-1&&(this.alignVector.copy(this.unitY).applyQuaternion(ue).dot(this.eye)<0?A.tag==="fwd"?A.visible=!1:A.scale.y*=-1:A.tag==="bwd"&&(A.visible=!1)),A.name.search("Z")!==-1&&(this.alignVector.copy(this.unitZ).applyQuaternion(ue).dot(this.eye)<0?A.tag==="fwd"?A.visible=!1:A.scale.z*=-1:A.tag==="bwd"&&(A.visible=!1))):this.mode==="rotate"&&(this.tempQuaternion2.copy(ue),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(ue).invert()),A.name.search("E")!==-1&&A.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),A.name==="X"&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),A.quaternion.copy(this.tempQuaternion)),A.name==="Y"&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),A.quaternion.copy(this.tempQuaternion)),A.name==="Z"&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),A.quaternion.copy(this.tempQuaternion))),A.visible=A.visible&&(A.name.indexOf("X")===-1||this.showX),A.visible=A.visible&&(A.name.indexOf("Y")===-1||this.showY),A.visible=A.visible&&(A.name.indexOf("Z")===-1||this.showZ),A.visible=A.visible&&(A.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),A.material.tempOpacity=A.material.tempOpacity||A.material.opacity,A.material.tempColor=A.material.tempColor||A.material.color.clone(),A.material.color.copy(A.material.tempColor),A.material.opacity=A.material.tempOpacity,this.enabled?this.axis&&(A.name===this.axis?(A.material.opacity=1,A.material.color.lerp(new c.Color(1,1,1),.5)):this.axis.split("").some(function(ee){return A.name===ee})?(A.material.opacity=1,A.material.color.lerp(new c.Color(1,1,1),.5)):(A.material.opacity*=.25,A.material.color.lerp(new c.Color(1,1,1),.5))):(A.material.opacity*=.5,A.material.color.lerp(new c.Color(1,1,1),.5))}super.updateMatrixWorld()});const e=new c.MeshBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,side:c.DoubleSide,fog:!1,toneMapped:!1}),t=new c.LineBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,linewidth:1,fog:!1,toneMapped:!1}),n=e.clone();n.opacity=.15;const s=e.clone();s.opacity=.33;const r=e.clone();r.color.set(16711680);const i=e.clone();i.color.set(65280);const a=e.clone();a.color.set(255);const l=e.clone();l.opacity=.25;const u=l.clone();u.color.set(16776960);const h=l.clone();h.color.set(65535);const d=l.clone();d.color.set(16711935),e.clone().color.set(16776960);const g=t.clone();g.color.set(16711680);const x=t.clone();x.color.set(65280);const w=t.clone();w.color.set(255);const v=t.clone();v.color.set(65535);const P=t.clone();P.color.set(16711935);const D=t.clone();D.color.set(16776960);const S=t.clone();S.color.set(7895160);const _=D.clone();_.opacity=.25;const L=new c.CylinderGeometry(0,.05,.2,12,1,!1),b=new c.BoxGeometry(.125,.125,.125),C=new c.BufferGeometry;C.setAttribute("position",new c.Float32BufferAttribute([0,0,0,1,0,0],3));const m=(se,ue)=>{const j=new c.BufferGeometry,z=[];for(let A=0;A<=64*ue;++A)z.push(0,Math.cos(A/32*Math.PI)*se,Math.sin(A/32*Math.PI)*se);return j.setAttribute("position",new c.Float32BufferAttribute(z,3)),j},M=()=>{const se=new c.BufferGeometry;return se.setAttribute("position",new c.Float32BufferAttribute([0,0,0,1,1,1],3)),se},p={X:[[new c.Mesh(L,r),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new c.Mesh(L,r),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new c.Line(C,g)]],Y:[[new c.Mesh(L,i),[0,1,0],null,null,"fwd"],[new c.Mesh(L,i),[0,1,0],[Math.PI,0,0],null,"bwd"],[new c.Line(C,x),null,[0,0,Math.PI/2]]],Z:[[new c.Mesh(L,a),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new c.Mesh(L,a),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new c.Line(C,w),null,[0,-Math.PI/2,0]]],XYZ:[[new c.Mesh(new c.OctahedronGeometry(.1,0),l.clone()),[0,0,0],[0,0,0]]],XY:[[new c.Mesh(new c.PlaneGeometry(.295,.295),u.clone()),[.15,.15,0]],[new c.Line(C,D),[.18,.3,0],null,[.125,1,1]],[new c.Line(C,D),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new c.Mesh(new c.PlaneGeometry(.295,.295),h.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new c.Line(C,v),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new c.Line(C,v),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new c.Mesh(new c.PlaneGeometry(.295,.295),d.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new c.Line(C,P),[.18,0,.3],null,[.125,1,1]],[new c.Line(C,P),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},I={X:[[new c.Mesh(new c.CylinderGeometry(.2,0,1,4,1,!1),n),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new c.Mesh(new c.CylinderGeometry(.2,0,1,4,1,!1),n),[0,.6,0]]],Z:[[new c.Mesh(new c.CylinderGeometry(.2,0,1,4,1,!1),n),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new c.Mesh(new c.OctahedronGeometry(.2,0),n)]],XY:[[new c.Mesh(new c.PlaneGeometry(.4,.4),n),[.2,.2,0]]],YZ:[[new c.Mesh(new c.PlaneGeometry(.4,.4),n),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new c.Mesh(new c.PlaneGeometry(.4,.4),n),[.2,0,.2],[-Math.PI/2,0,0]]]},F={START:[[new c.Mesh(new c.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],END:[[new c.Mesh(new c.OctahedronGeometry(.01,2),s),null,null,null,"helper"]],DELTA:[[new c.Line(M(),s),null,null,null,"helper"]],X:[[new c.Line(C,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new c.Line(C,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new c.Line(C,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},J={X:[[new c.Line(m(1,.5),g)],[new c.Mesh(new c.OctahedronGeometry(.04,0),r),[0,0,.99],null,[1,3,1]]],Y:[[new c.Line(m(1,.5),x),null,[0,0,-Math.PI/2]],[new c.Mesh(new c.OctahedronGeometry(.04,0),i),[0,0,.99],null,[3,1,1]]],Z:[[new c.Line(m(1,.5),w),null,[0,Math.PI/2,0]],[new c.Mesh(new c.OctahedronGeometry(.04,0),a),[.99,0,0],null,[1,3,1]]],E:[[new c.Line(m(1.25,1),_),null,[0,Math.PI/2,0]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),_),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),_),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),_),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),_),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new c.Line(m(1,1),S),null,[0,Math.PI/2,0]]]},G={AXIS:[[new c.Line(C,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},Q={X:[[new c.Mesh(new c.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new c.Mesh(new c.TorusGeometry(1,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new c.Mesh(new c.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new c.Mesh(new c.TorusGeometry(1.25,.1,2,24),n)]],XYZE:[[new c.Mesh(new c.SphereGeometry(.7,10,8),n)]]},K={X:[[new c.Mesh(b,r),[.8,0,0],[0,0,-Math.PI/2]],[new c.Line(C,g),null,null,[.8,1,1]]],Y:[[new c.Mesh(b,i),[0,.8,0]],[new c.Line(C,x),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new c.Mesh(b,a),[0,0,.8],[Math.PI/2,0,0]],[new c.Line(C,w),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new c.Mesh(b,u),[.85,.85,0],null,[2,2,.2]],[new c.Line(C,D),[.855,.98,0],null,[.125,1,1]],[new c.Line(C,D),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new c.Mesh(b,h),[0,.85,.85],null,[.2,2,2]],[new c.Line(C,v),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new c.Line(C,v),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new c.Mesh(b,d),[.85,0,.85],null,[2,.2,2]],[new c.Line(C,P),[.855,0,.98],null,[.125,1,1]],[new c.Line(C,P),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new c.Mesh(new c.BoxGeometry(.125,.125,.125),l.clone()),[1.1,0,0]]],XYZY:[[new c.Mesh(new c.BoxGeometry(.125,.125,.125),l.clone()),[0,1.1,0]]],XYZZ:[[new c.Mesh(new c.BoxGeometry(.125,.125,.125),l.clone()),[0,0,1.1]]]},Z={X:[[new c.Mesh(new c.CylinderGeometry(.2,0,.8,4,1,!1),n),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new c.Mesh(new c.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,.5,0]]],Z:[[new c.Mesh(new c.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new c.Mesh(b,n),[.85,.85,0],null,[3,3,.2]]],YZ:[[new c.Mesh(b,n),[0,.85,.85],null,[.2,3,3]]],XZ:[[new c.Mesh(b,n),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new c.Mesh(new c.BoxGeometry(.2,.2,.2),n),[1.1,0,0]]],XYZY:[[new c.Mesh(new c.BoxGeometry(.2,.2,.2),n),[0,1.1,0]]],XYZZ:[[new c.Mesh(new c.BoxGeometry(.2,.2,.2),n),[0,0,1.1]]]},X={X:[[new c.Line(C,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new c.Line(C,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new c.Line(C,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},ne=se=>{const ue=new c.Object3D;for(let j in se)for(let z=se[j].length;z--;){const A=se[j][z][0].clone(),V=se[j][z][1],ee=se[j][z][2],N=se[j][z][3],R=se[j][z][4];A.name=j,A.tag=R,V&&A.position.set(V[0],V[1],V[2]),ee&&A.rotation.set(ee[0],ee[1],ee[2]),N&&A.scale.set(N[0],N[1],N[2]),A.updateMatrix();const T=A.geometry.clone();T.applyMatrix4(A.matrix),A.geometry=T,A.renderOrder=1/0,A.position.set(0,0,0),A.rotation.set(0,0,0),A.scale.set(1,1,1),ue.add(A)}return ue};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=ne(p)),this.add(this.gizmo.rotate=ne(J)),this.add(this.gizmo.scale=ne(K)),this.add(this.picker.translate=ne(I)),this.add(this.picker.rotate=ne(Q)),this.add(this.picker.scale=ne(Z)),this.add(this.helper.translate=ne(F)),this.add(this.helper.rotate=ne(G)),this.add(this.helper.scale=ne(X)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}}class Fo extends c.Mesh{constructor(){super(new c.PlaneGeometry(1e5,1e5,2,2),new c.MeshBasicMaterial({visible:!1,wireframe:!0,side:c.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),H(this,"isTransformControlsPlane",!0),H(this,"type","TransformControlsPlane"),H(this,"unitX",new c.Vector3(1,0,0)),H(this,"unitY",new c.Vector3(0,1,0)),H(this,"unitZ",new c.Vector3(0,0,1)),H(this,"tempVector",new c.Vector3),H(this,"dirVector",new c.Vector3),H(this,"alignVector",new c.Vector3),H(this,"tempMatrix",new c.Matrix4),H(this,"identityQuaternion",new c.Quaternion),H(this,"cameraQuaternion",new c.Quaternion),H(this,"worldPosition",new c.Vector3),H(this,"worldQuaternion",new c.Quaternion),H(this,"eye",new c.Vector3),H(this,"axis",null),H(this,"mode","translate"),H(this,"space","world"),H(this,"updateMatrixWorld",()=>{let e=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(e="local"),this.unitX.set(1,0,0).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.unitY.set(0,1,0).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.unitZ.set(0,0,1).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.alignVector.copy(this.unitY),this.mode){case"translate":case"scale":switch(this.axis){case"X":this.alignVector.copy(this.eye).cross(this.unitX),this.dirVector.copy(this.unitX).cross(this.alignVector);break;case"Y":this.alignVector.copy(this.eye).cross(this.unitY),this.dirVector.copy(this.unitY).cross(this.alignVector);break;case"Z":this.alignVector.copy(this.eye).cross(this.unitZ),this.dirVector.copy(this.unitZ).cross(this.alignVector);break;case"XY":this.dirVector.copy(this.unitZ);break;case"YZ":this.dirVector.copy(this.unitX);break;case"XZ":this.alignVector.copy(this.unitZ),this.dirVector.copy(this.unitY);break;case"XYZ":case"E":this.dirVector.set(0,0,0);break}break;case"rotate":default:this.dirVector.set(0,0,0)}this.dirVector.length()===0?this.quaternion.copy(this.cameraQuaternion):(this.tempMatrix.lookAt(this.tempVector.set(0,0,0),this.dirVector,this.alignVector),this.quaternion.setFromRotationMatrix(this.tempMatrix)),super.updateMatrixWorld()})}}var ko=Object.defineProperty,Bo=(o,e,t)=>e in o?ko(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,De=(o,e,t)=>(Bo(o,typeof e!="symbol"?e+"":e,t),t);const Lt=new c.Euler(0,0,0,"YXZ"),It=new c.Vector3,Uo={type:"change"},No={type:"lock"},zo={type:"unlock"},er=Math.PI/2;class Wn extends c.EventDispatcher{constructor(e,t){super(),De(this,"camera"),De(this,"domElement"),De(this,"isLocked"),De(this,"minPolarAngle"),De(this,"maxPolarAngle"),De(this,"pointerSpeed"),De(this,"onMouseMove",n=>{if(!this.domElement||this.isLocked===!1)return;const s=n.movementX||n.mozMovementX||n.webkitMovementX||0,r=n.movementY||n.mozMovementY||n.webkitMovementY||0;Lt.setFromQuaternion(this.camera.quaternion),Lt.y-=s*.002*this.pointerSpeed,Lt.x-=r*.002*this.pointerSpeed,Lt.x=Math.max(er-this.maxPolarAngle,Math.min(er-this.minPolarAngle,Lt.x)),this.camera.quaternion.setFromEuler(Lt),this.dispatchEvent(Uo)}),De(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(No),this.isLocked=!0):(this.dispatchEvent(zo),this.isLocked=!1))}),De(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),De(this,"connect",n=>{this.domElement=n||this.domElement,this.domElement&&(this.domElement.ownerDocument.addEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError))}),De(this,"disconnect",()=>{this.domElement&&(this.domElement.ownerDocument.removeEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError))}),De(this,"dispose",()=>{this.disconnect()}),De(this,"getObject",()=>this.camera),De(this,"direction",new c.Vector3(0,0,-1)),De(this,"getDirection",n=>n.copy(this.direction).applyQuaternion(this.camera.quaternion)),De(this,"moveForward",n=>{It.setFromMatrixColumn(this.camera.matrix,0),It.crossVectors(this.camera.up,It),this.camera.position.addScaledVector(It,n)}),De(this,"moveRight",n=>{It.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(It,n)}),De(this,"lock",()=>{this.domElement&&this.domElement.requestPointerLock()}),De(this,"unlock",()=>{this.domElement&&this.domElement.ownerDocument.exitPointerLock()}),this.camera=e,this.domElement=t,this.isLocked=!1,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.pointerSpeed=1,t&&this.connect(t)}}var Vo=Object.defineProperty,Ro=(o,e,t)=>e in o?Vo(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,fe=(o,e,t)=>(Ro(o,typeof e!="symbol"?e+"":e,t),t);const pn=new c.Ray,tr=new c.Plane,Go=Math.cos(70*(Math.PI/180)),nr=(o,e)=>(o%e+e)%e;class sr extends c.EventDispatcher{constructor(e,t){super(),fe(this,"object"),fe(this,"domElement"),fe(this,"enabled",!0),fe(this,"target",new c.Vector3),fe(this,"minDistance",0),fe(this,"maxDistance",1/0),fe(this,"minZoom",0),fe(this,"maxZoom",1/0),fe(this,"minPolarAngle",0),fe(this,"maxPolarAngle",Math.PI),fe(this,"minAzimuthAngle",-1/0),fe(this,"maxAzimuthAngle",1/0),fe(this,"enableDamping",!1),fe(this,"dampingFactor",.05),fe(this,"enableZoom",!0),fe(this,"zoomSpeed",1),fe(this,"enableRotate",!0),fe(this,"rotateSpeed",1),fe(this,"enablePan",!0),fe(this,"panSpeed",1),fe(this,"screenSpacePanning",!0),fe(this,"keyPanSpeed",7),fe(this,"zoomToCursor",!1),fe(this,"autoRotate",!1),fe(this,"autoRotateSpeed",2),fe(this,"reverseOrbit",!1),fe(this,"reverseHorizontalOrbit",!1),fe(this,"reverseVerticalOrbit",!1),fe(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),fe(this,"mouseButtons",{LEFT:c.MOUSE.ROTATE,MIDDLE:c.MOUSE.DOLLY,RIGHT:c.MOUSE.PAN}),fe(this,"touches",{ONE:c.TOUCH.ROTATE,TWO:c.TOUCH.DOLLY_PAN}),fe(this,"target0"),fe(this,"position0"),fe(this,"zoom0"),fe(this,"_domElementKeyEvents",null),fe(this,"getPolarAngle"),fe(this,"getAzimuthalAngle"),fe(this,"setPolarAngle"),fe(this,"setAzimuthalAngle"),fe(this,"getDistance"),fe(this,"listenToKeyEvents"),fe(this,"stopListenToKeyEvents"),fe(this,"saveState"),fe(this,"reset"),fe(this,"update"),fe(this,"connect"),fe(this,"dispose"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>h.phi,this.getAzimuthalAngle=()=>h.theta,this.setPolarAngle=Y=>{let ie=nr(Y,2*Math.PI),me=h.phi;me<0&&(me+=2*Math.PI),ie<0&&(ie+=2*Math.PI);let Se=Math.abs(ie-me);2*Math.PI-Se<Se&&(ie<me?ie+=2*Math.PI:me+=2*Math.PI),d.phi=ie-me,n.update()},this.setAzimuthalAngle=Y=>{let ie=nr(Y,2*Math.PI),me=h.theta;me<0&&(me+=2*Math.PI),ie<0&&(ie+=2*Math.PI);let Se=Math.abs(ie-me);2*Math.PI-Se<Se&&(ie<me?ie+=2*Math.PI:me+=2*Math.PI),d.theta=ie-me,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=Y=>{Y.addEventListener("keydown",Gt),this._domElementKeyEvents=Y},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",Gt),this._domElementKeyEvents=null},this.saveState=()=>{n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(s),n.update(),l=a.NONE},this.update=(()=>{const Y=new c.Vector3,ie=new c.Vector3(0,1,0),me=new c.Quaternion().setFromUnitVectors(e.up,ie),Se=me.clone().invert(),Fe=new c.Vector3,lt=new c.Quaternion,xt=2*Math.PI;return function(){const Gi=n.object.position;me.setFromUnitVectors(e.up,ie),Se.copy(me).invert(),Y.copy(Gi).sub(n.target),Y.applyQuaternion(me),h.setFromVector3(Y),n.autoRotate&&l===a.NONE&&G(F()),n.enableDamping?(h.theta+=d.theta*n.dampingFactor,h.phi+=d.phi*n.dampingFactor):(h.theta+=d.theta,h.phi+=d.phi);let ct=n.minAzimuthAngle,ut=n.maxAzimuthAngle;isFinite(ct)&&isFinite(ut)&&(ct<-Math.PI?ct+=xt:ct>Math.PI&&(ct-=xt),ut<-Math.PI?ut+=xt:ut>Math.PI&&(ut-=xt),ct<=ut?h.theta=Math.max(ct,Math.min(ut,h.theta)):h.theta=h.theta>(ct+ut)/2?Math.max(ct,h.theta):Math.min(ut,h.theta)),h.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,h.phi)),h.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(g,n.dampingFactor):n.target.add(g),n.zoomToCursor&&M||n.object.isOrthographicCamera?h.radius=j(h.radius):h.radius=j(h.radius*y),Y.setFromSpherical(h),Y.applyQuaternion(Se),Gi.copy(n.target).add(Y),n.object.matrixAutoUpdate||n.object.updateMatrix(),n.object.lookAt(n.target),n.enableDamping===!0?(d.theta*=1-n.dampingFactor,d.phi*=1-n.dampingFactor,g.multiplyScalar(1-n.dampingFactor)):(d.set(0,0,0),g.set(0,0,0));let ln=!1;if(n.zoomToCursor&&M){let cn=null;if(n.object instanceof c.PerspectiveCamera&&n.object.isPerspectiveCamera){const un=Y.length();cn=j(un*y);const Bn=un-cn;n.object.position.addScaledVector(C,Bn),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const un=new c.Vector3(m.x,m.y,0);un.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/y)),n.object.updateProjectionMatrix(),ln=!0;const Bn=new c.Vector3(m.x,m.y,0);Bn.unproject(n.object),n.object.position.sub(Bn).add(un),n.object.updateMatrixWorld(),cn=Y.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;cn!==null&&(n.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(cn).add(n.object.position):(pn.origin.copy(n.object.position),pn.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(pn.direction))<Go?e.lookAt(n.target):(tr.setFromNormalAndCoplanarPoint(n.object.up,n.target),pn.intersectPlane(tr,n.target))))}else n.object instanceof c.OrthographicCamera&&n.object.isOrthographicCamera&&(ln=y!==1,ln&&(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/y)),n.object.updateProjectionMatrix()));return y=1,M=!1,ln||Fe.distanceToSquared(n.object.position)>u||8*(1-lt.dot(n.object.quaternion))>u?(n.dispatchEvent(s),Fe.copy(n.object.position),lt.copy(n.object.quaternion),ln=!1,!0):!1}})(),this.connect=Y=>{Y===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),n.domElement=Y,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",zi),n.domElement.addEventListener("pointerdown",_e),n.domElement.addEventListener("pointercancel",at),n.domElement.addEventListener("wheel",Ke)},this.dispose=()=>{var Y,ie,me,Se,Fe,lt;(Y=n.domElement)==null||Y.removeEventListener("contextmenu",zi),(ie=n.domElement)==null||ie.removeEventListener("pointerdown",_e),(me=n.domElement)==null||me.removeEventListener("pointercancel",at),(Se=n.domElement)==null||Se.removeEventListener("wheel",Ke),(Fe=n.domElement)==null||Fe.ownerDocument.removeEventListener("pointermove",xe),(lt=n.domElement)==null||lt.ownerDocument.removeEventListener("pointerup",Oe),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",Gt)};const n=this,s={type:"change"},r={type:"start"},i={type:"end"},a={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let l=a.NONE;const u=1e-6,h=new c.Spherical,d=new c.Spherical;let y=1;const g=new c.Vector3,x=new c.Vector2,w=new c.Vector2,v=new c.Vector2,P=new c.Vector2,D=new c.Vector2,S=new c.Vector2,_=new c.Vector2,L=new c.Vector2,b=new c.Vector2,C=new c.Vector3,m=new c.Vector2;let M=!1;const p=[],I={};function F(){return 2*Math.PI/60/60*n.autoRotateSpeed}function J(){return Math.pow(.95,n.zoomSpeed)}function G(Y){n.reverseOrbit||n.reverseHorizontalOrbit?d.theta+=Y:d.theta-=Y}function Q(Y){n.reverseOrbit||n.reverseVerticalOrbit?d.phi+=Y:d.phi-=Y}const K=(()=>{const Y=new c.Vector3;return function(me,Se){Y.setFromMatrixColumn(Se,0),Y.multiplyScalar(-me),g.add(Y)}})(),Z=(()=>{const Y=new c.Vector3;return function(me,Se){n.screenSpacePanning===!0?Y.setFromMatrixColumn(Se,1):(Y.setFromMatrixColumn(Se,0),Y.crossVectors(n.object.up,Y)),Y.multiplyScalar(me),g.add(Y)}})(),X=(()=>{const Y=new c.Vector3;return function(me,Se){const Fe=n.domElement;if(Fe&&n.object instanceof c.PerspectiveCamera&&n.object.isPerspectiveCamera){const lt=n.object.position;Y.copy(lt).sub(n.target);let xt=Y.length();xt*=Math.tan(n.object.fov/2*Math.PI/180),K(2*me*xt/Fe.clientHeight,n.object.matrix),Z(2*Se*xt/Fe.clientHeight,n.object.matrix)}else Fe&&n.object instanceof c.OrthographicCamera&&n.object.isOrthographicCamera?(K(me*(n.object.right-n.object.left)/n.object.zoom/Fe.clientWidth,n.object.matrix),Z(Se*(n.object.top-n.object.bottom)/n.object.zoom/Fe.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function ne(Y){n.object instanceof c.PerspectiveCamera&&n.object.isPerspectiveCamera||n.object instanceof c.OrthographicCamera&&n.object.isOrthographicCamera?y/=Y:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function se(Y){n.object instanceof c.PerspectiveCamera&&n.object.isPerspectiveCamera||n.object instanceof c.OrthographicCamera&&n.object.isOrthographicCamera?y*=Y:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ue(Y){if(!n.zoomToCursor||!n.domElement)return;M=!0;const ie=n.domElement.getBoundingClientRect(),me=Y.clientX-ie.left,Se=Y.clientY-ie.top,Fe=ie.width,lt=ie.height;m.x=me/Fe*2-1,m.y=-(Se/lt)*2+1,C.set(m.x,m.y,1).unproject(n.object).sub(n.object.position).normalize()}function j(Y){return Math.max(n.minDistance,Math.min(n.maxDistance,Y))}function z(Y){x.set(Y.clientX,Y.clientY)}function A(Y){ue(Y),_.set(Y.clientX,Y.clientY)}function V(Y){P.set(Y.clientX,Y.clientY)}function ee(Y){w.set(Y.clientX,Y.clientY),v.subVectors(w,x).multiplyScalar(n.rotateSpeed);const ie=n.domElement;ie&&(G(2*Math.PI*v.x/ie.clientHeight),Q(2*Math.PI*v.y/ie.clientHeight)),x.copy(w),n.update()}function N(Y){L.set(Y.clientX,Y.clientY),b.subVectors(L,_),b.y>0?ne(J()):b.y<0&&se(J()),_.copy(L),n.update()}function R(Y){D.set(Y.clientX,Y.clientY),S.subVectors(D,P).multiplyScalar(n.panSpeed),X(S.x,S.y),P.copy(D),n.update()}function T(Y){ue(Y),Y.deltaY<0?se(J()):Y.deltaY>0&&ne(J()),n.update()}function O(Y){let ie=!1;switch(Y.code){case n.keys.UP:X(0,n.keyPanSpeed),ie=!0;break;case n.keys.BOTTOM:X(0,-n.keyPanSpeed),ie=!0;break;case n.keys.LEFT:X(n.keyPanSpeed,0),ie=!0;break;case n.keys.RIGHT:X(-n.keyPanSpeed,0),ie=!0;break}ie&&(Y.preventDefault(),n.update())}function k(){if(p.length==1)x.set(p[0].pageX,p[0].pageY);else{const Y=.5*(p[0].pageX+p[1].pageX),ie=.5*(p[0].pageY+p[1].pageY);x.set(Y,ie)}}function E(){if(p.length==1)P.set(p[0].pageX,p[0].pageY);else{const Y=.5*(p[0].pageX+p[1].pageX),ie=.5*(p[0].pageY+p[1].pageY);P.set(Y,ie)}}function q(){const Y=p[0].pageX-p[1].pageX,ie=p[0].pageY-p[1].pageY,me=Math.sqrt(Y*Y+ie*ie);_.set(0,me)}function W(){n.enableZoom&&q(),n.enablePan&&E()}function te(){n.enableZoom&&q(),n.enableRotate&&k()}function U(Y){if(p.length==1)w.set(Y.pageX,Y.pageY);else{const me=Us(Y),Se=.5*(Y.pageX+me.x),Fe=.5*(Y.pageY+me.y);w.set(Se,Fe)}v.subVectors(w,x).multiplyScalar(n.rotateSpeed);const ie=n.domElement;ie&&(G(2*Math.PI*v.x/ie.clientHeight),Q(2*Math.PI*v.y/ie.clientHeight)),x.copy(w)}function B(Y){if(p.length==1)D.set(Y.pageX,Y.pageY);else{const ie=Us(Y),me=.5*(Y.pageX+ie.x),Se=.5*(Y.pageY+ie.y);D.set(me,Se)}S.subVectors(D,P).multiplyScalar(n.panSpeed),X(S.x,S.y),P.copy(D)}function oe(Y){const ie=Us(Y),me=Y.pageX-ie.x,Se=Y.pageY-ie.y,Fe=Math.sqrt(me*me+Se*Se);L.set(0,Fe),b.set(0,Math.pow(L.y/_.y,n.zoomSpeed)),ne(b.y),_.copy(L)}function ce(Y){n.enableZoom&&oe(Y),n.enablePan&&B(Y)}function ge(Y){n.enableZoom&&oe(Y),n.enableRotate&&U(Y)}function _e(Y){var ie,me;n.enabled!==!1&&(p.length===0&&((ie=n.domElement)==null||ie.ownerDocument.addEventListener("pointermove",xe),(me=n.domElement)==null||me.ownerDocument.addEventListener("pointerup",Oe)),$f(Y),Y.pointerType==="touch"?Jf(Y):an(Y))}function xe(Y){n.enabled!==!1&&(Y.pointerType==="touch"?Hf(Y):Rt(Y))}function Oe(Y){var ie,me,Se;Vi(Y),p.length===0&&((ie=n.domElement)==null||ie.releasePointerCapture(Y.pointerId),(me=n.domElement)==null||me.ownerDocument.removeEventListener("pointermove",xe),(Se=n.domElement)==null||Se.ownerDocument.removeEventListener("pointerup",Oe)),n.dispatchEvent(i),l=a.NONE}function at(Y){Vi(Y)}function an(Y){let ie;switch(Y.button){case 0:ie=n.mouseButtons.LEFT;break;case 1:ie=n.mouseButtons.MIDDLE;break;case 2:ie=n.mouseButtons.RIGHT;break;default:ie=-1}switch(ie){case c.MOUSE.DOLLY:if(n.enableZoom===!1)return;A(Y),l=a.DOLLY;break;case c.MOUSE.ROTATE:if(Y.ctrlKey||Y.metaKey||Y.shiftKey){if(n.enablePan===!1)return;V(Y),l=a.PAN}else{if(n.enableRotate===!1)return;z(Y),l=a.ROTATE}break;case c.MOUSE.PAN:if(Y.ctrlKey||Y.metaKey||Y.shiftKey){if(n.enableRotate===!1)return;z(Y),l=a.ROTATE}else{if(n.enablePan===!1)return;V(Y),l=a.PAN}break;default:l=a.NONE}l!==a.NONE&&n.dispatchEvent(r)}function Rt(Y){if(n.enabled!==!1)switch(l){case a.ROTATE:if(n.enableRotate===!1)return;ee(Y);break;case a.DOLLY:if(n.enableZoom===!1)return;N(Y);break;case a.PAN:if(n.enablePan===!1)return;R(Y);break}}function Ke(Y){n.enabled===!1||n.enableZoom===!1||l!==a.NONE&&l!==a.ROTATE||(Y.preventDefault(),n.dispatchEvent(r),T(Y),n.dispatchEvent(i))}function Gt(Y){n.enabled===!1||n.enablePan===!1||O(Y)}function Jf(Y){switch(Ri(Y),p.length){case 1:switch(n.touches.ONE){case c.TOUCH.ROTATE:if(n.enableRotate===!1)return;k(),l=a.TOUCH_ROTATE;break;case c.TOUCH.PAN:if(n.enablePan===!1)return;E(),l=a.TOUCH_PAN;break;default:l=a.NONE}break;case 2:switch(n.touches.TWO){case c.TOUCH.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;W(),l=a.TOUCH_DOLLY_PAN;break;case c.TOUCH.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;te(),l=a.TOUCH_DOLLY_ROTATE;break;default:l=a.NONE}break;default:l=a.NONE}l!==a.NONE&&n.dispatchEvent(r)}function Hf(Y){switch(Ri(Y),l){case a.TOUCH_ROTATE:if(n.enableRotate===!1)return;U(Y),n.update();break;case a.TOUCH_PAN:if(n.enablePan===!1)return;B(Y),n.update();break;case a.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;ce(Y),n.update();break;case a.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;ge(Y),n.update();break;default:l=a.NONE}}function zi(Y){n.enabled!==!1&&Y.preventDefault()}function $f(Y){p.push(Y)}function Vi(Y){delete I[Y.pointerId];for(let ie=0;ie<p.length;ie++)if(p[ie].pointerId==Y.pointerId){p.splice(ie,1);return}}function Ri(Y){let ie=I[Y.pointerId];ie===void 0&&(ie=new c.Vector2,I[Y.pointerId]=ie),ie.set(Y.pageX,Y.pageY)}function Us(Y){const ie=Y.pointerId===p[0].pointerId?p[1]:p[0];return I[ie.pointerId]}t!==void 0&&this.connect(t),this.update()}}class jo extends sr{constructor(e,t){super(e,t),this.screenSpacePanning=!1,this.mouseButtons.LEFT=c.MOUSE.PAN,this.mouseButtons.RIGHT=c.MOUSE.ROTATE,this.touches.ONE=c.TOUCH.PAN,this.touches.TWO=c.TOUCH.DOLLY_ROTATE}}class Eo extends c.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Ko(t)}),this.register(function(t){return new na(t)}),this.register(function(t){return new sa(t)}),this.register(function(t){return new ra(t)}),this.register(function(t){return new Qo(t)}),this.register(function(t){return new Jo(t)}),this.register(function(t){return new Ho(t)}),this.register(function(t){return new $o(t)}),this.register(function(t){return new Zo(t)}),this.register(function(t){return new ea(t)}),this.register(function(t){return new qo(t)}),this.register(function(t){return new ta(t)}),this.register(function(t){return new Xo(t)}),this.register(function(t){return new ia(t)}),this.register(function(t){return new oa(t)})}load(e,t,n,s){const r=this;let i;this.resourcePath!==""?i=this.resourcePath:this.path!==""?i=this.path:i=c.LoaderUtils.extractUrlBase(e),this.manager.itemStart(e);const a=function(u){s?s(u):console.error(u),r.manager.itemError(e),r.manager.itemEnd(e)},l=new c.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(u){try{r.parse(u,i,function(h){t(h),r.manager.itemEnd(e)},a)}catch(h){a(h)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}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,n,s){let r;const i={},a={};if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4)))===rr){try{i[be.KHR_BINARY_GLTF]=new aa(e)}catch(h){s&&s(h);return}r=JSON.parse(i[be.KHR_BINARY_GLTF].content)}else r=JSON.parse(c.LoaderUtils.decodeText(new Uint8Array(e)));else r=e;if(r.asset===void 0||r.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new xa(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const h=this.pluginCallbacks[u](l);a[h.name]=h,i[h.name]=!0}if(r.extensionsUsed)for(let u=0;u<r.extensionsUsed.length;++u){const h=r.extensionsUsed[u],d=r.extensionsRequired||[];switch(h){case be.KHR_MATERIALS_UNLIT:i[h]=new Wo;break;case be.KHR_DRACO_MESH_COMPRESSION:i[h]=new la(r,this.dracoLoader);break;case be.KHR_TEXTURE_TRANSFORM:i[h]=new ca;break;case be.KHR_MESH_QUANTIZATION:i[h]=new ua;break;default:d.indexOf(h)>=0&&a[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(i),l.setPlugins(a),l.parse(n,s)}parseAsync(e,t){const n=this;return new Promise(function(s,r){n.parse(e,t,s,r)})}}function Yo(){let o={};return{get:function(e){return o[e]},add:function(e,t){o[e]=t},remove:function(e){delete o[e]},removeAll:function(){o={}}}}const be={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Xo{constructor(e){this.parser=e,this.name=be.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,s=t.length;n<s;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let s=t.cache.get(n);if(s)return s;const r=t.json,l=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let u;const h=new c.Color(16777215);l.color!==void 0&&h.fromArray(l.color);const d=l.range!==void 0?l.range:0;switch(l.type){case"directional":u=new c.DirectionalLight(h),u.target.position.set(0,0,-1),u.add(u.target);break;case"point":u=new c.PointLight(h),u.distance=d;break;case"spot":u=new c.SpotLight(h),u.distance=d,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,u.angle=l.spot.outerConeAngle,u.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,u.target.position.set(0,0,-1),u.add(u.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return u.position.set(0,0,0),u.decay=2,pt(u,l),l.intensity!==void 0&&(u.intensity=l.intensity),u.name=t.createUniqueName(l.name||"light_"+e),s=Promise.resolve(u),t.cache.add(n,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return n._getNodeRef(t.cache,a,l)})}}class Wo{constructor(){this.name=be.KHR_MATERIALS_UNLIT}getMaterialType(){return c.MeshBasicMaterial}extendParams(e,t,n){const s=[];e.color=new c.Color(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const i=r.baseColorFactor;e.color.fromArray(i),e.opacity=i[3]}r.baseColorTexture!==void 0&&s.push(n.assignTexture(e,"map",r.baseColorTexture,3001))}return Promise.all(s)}}class Zo{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}}class Ko{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],i=s.extensions[this.name];if(i.clearcoatFactor!==void 0&&(t.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(r.push(n.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){const a=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new c.Vector2(a,a)}return Promise.all(r)}}class qo{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],i=s.extensions[this.name];return i.iridescenceFactor!==void 0&&(t.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),i.iridescenceIor!==void 0&&(t.iridescenceIOR=i.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),i.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),i.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),i.iridescenceThicknessTexture!==void 0&&r.push(n.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(r)}}class Qo{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new c.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const i=s.extensions[this.name];return i.sheenColorFactor!==void 0&&t.sheenColor.fromArray(i.sheenColorFactor),i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&r.push(n.assignTexture(t,"sheenColorMap",i.sheenColorTexture,3001)),i.sheenRoughnessTexture!==void 0&&r.push(n.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(r)}}class Jo{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],i=s.extensions[this.name];return i.transmissionFactor!==void 0&&(t.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&r.push(n.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(r)}}class Ho{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],i=s.extensions[this.name];t.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&r.push(n.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const a=i.attenuationColor||[1,1,1];return t.attenuationColor=new c.Color(a[0],a[1],a[2]),Promise.all(r)}}class $o{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=s.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class ea{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],i=s.extensions[this.name];t.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&r.push(n.assignTexture(t,"specularIntensityMap",i.specularTexture));const a=i.specularColorFactor||[1,1,1];return t.specularColor=new c.Color(a[0],a[1],a[2]),i.specularColorTexture!==void 0&&r.push(n.assignTexture(t,"specularColorMap",i.specularColorTexture,3001)),Promise.all(r)}}class ta{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const r=[],i=s.extensions[this.name];return i.anisotropyStrength!==void 0&&(t.anisotropy=i.anisotropyStrength),i.anisotropyRotation!==void 0&&(t.anisotropyRotation=i.anisotropyRotation),i.anisotropyTexture!==void 0&&r.push(n.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(r)}}class na{constructor(e){this.parser=e,this.name=be.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const r=s.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,i)}}class sa{constructor(e){this.parser=e,this.name=be.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,s=n.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const i=r.extensions[t],a=s.images[i.source];let l=n.textureLoader;if(a.uri){const u=n.options.manager.getHandler(a.uri);u!==null&&(l=u)}return this.detectSupport().then(function(u){if(u)return n.loadTextureImage(e,i.source,l);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class ra{constructor(e){this.parser=e,this.name=be.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,s=n.json,r=s.textures[e];if(!r.extensions||!r.extensions[t])return null;const i=r.extensions[t],a=s.images[i.source];let l=n.textureLoader;if(a.uri){const u=n.options.manager.getHandler(a.uri);u!==null&&(l=u)}return this.detectSupport().then(function(u){if(u)return n.loadTextureImage(e,i.source,l);if(s.extensionsRequired&&s.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class ia{constructor(e){this.name=be.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const s=n.extensions[this.name],r=this.parser.getDependency("buffer",s.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const l=s.byteOffset||0,u=s.byteLength||0,h=s.count,d=s.byteStride,y=new Uint8Array(a,l,u);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(h,d,y,s.mode,s.filter).then(function(g){return g.buffer}):i.ready.then(function(){const g=new ArrayBuffer(h*d);return i.decodeGltfBuffer(new Uint8Array(g),h,d,y,s.mode,s.filter),g})})}else return null}}class oa{constructor(e){this.name=be.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const s=t.meshes[n.mesh];for(const u of s.primitives)if(u.mode!==We.TRIANGLES&&u.mode!==We.TRIANGLE_STRIP&&u.mode!==We.TRIANGLE_FAN&&u.mode!==void 0)return null;const i=n.extensions[this.name].attributes,a=[],l={};for(const u in i)a.push(this.parser.getDependency("accessor",i[u]).then(h=>(l[u]=h,l[u])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(u=>{const h=u.pop(),d=h.isGroup?h.children:[h],y=u[0].count,g=[];for(const x of d){const w=new c.Matrix4,v=new c.Vector3,P=new c.Quaternion,D=new c.Vector3(1,1,1),S=new c.InstancedMesh(x.geometry,x.material,y);for(let _=0;_<y;_++)l.TRANSLATION&&v.fromBufferAttribute(l.TRANSLATION,_),l.ROTATION&&P.fromBufferAttribute(l.ROTATION,_),l.SCALE&&D.fromBufferAttribute(l.SCALE,_),S.setMatrixAt(_,w.compose(v,P,D));for(const _ in l)_!=="TRANSLATION"&&_!=="ROTATION"&&_!=="SCALE"&&x.geometry.setAttribute(_,l[_]);c.Object3D.prototype.copy.call(S,x),this.parser.assignFinalMaterial(S),g.push(S)}return h.isGroup?(h.clear(),h.add(...g),h):g[0]}))}}const rr="glTF",Xt=12,ir={JSON:1313821514,BIN:5130562};class aa{constructor(e){this.name=be.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Xt);if(this.header={magic:c.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==rr)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-Xt,s=new DataView(e,Xt);let r=0;for(;r<n;){const i=s.getUint32(r,!0);r+=4;const a=s.getUint32(r,!0);if(r+=4,a===ir.JSON){const l=new Uint8Array(e,Xt+r,i);this.content=c.LoaderUtils.decodeText(l)}else if(a===ir.BIN){const l=Xt+r;this.body=e.slice(l,l+i)}r+=i}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class la{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=be.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,s=this.dracoLoader,r=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,a={},l={},u={};for(const h in i){const d=Kn[h]||h.toLowerCase();a[d]=i[h]}for(const h in e.attributes){const d=Kn[h]||h.toLowerCase();if(i[h]!==void 0){const y=n.accessors[e.attributes[h]],g=Dt[y.componentType];u[d]=g.name,l[d]=y.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(d){s.decodeDracoFile(h,function(y){for(const g in y.attributes){const x=y.attributes[g],w=l[g];w!==void 0&&(x.normalized=w)}d(y)},a,u)})})}}class ca{constructor(){this.name=be.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class ua{constructor(){this.name=be.KHR_MESH_QUANTIZATION}}class or extends c.Interpolant{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,r=e*s*3+s;for(let i=0;i!==s;i++)t[i]=n[r+i];return t}interpolate_(e,t,n,s){const r=this.resultBuffer,i=this.sampleValues,a=this.valueSize,l=a*2,u=a*3,h=s-t,d=(n-t)/h,y=d*d,g=y*d,x=e*u,w=x-u,v=-2*g+3*y,P=g-y,D=1-v,S=P-y+d;for(let _=0;_!==a;_++){const L=i[w+_+a],b=i[w+_+l]*h,C=i[x+_+a],m=i[x+_]*h;r[_]=D*L+S*b+v*C+P*m}return r}}const ha=new c.Quaternion;class fa extends or{interpolate_(e,t,n,s){const r=super.interpolate_(e,t,n,s);return ha.fromArray(r).normalize().toArray(r),r}}const We={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Dt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ar={9728:c.NearestFilter,9729:c.LinearFilter,9984:c.NearestMipmapNearestFilter,9985:c.LinearMipmapNearestFilter,9986:c.NearestMipmapLinearFilter,9987:c.LinearMipmapLinearFilter},lr={33071:c.ClampToEdgeWrapping,33648:c.MirroredRepeatWrapping,10497:c.RepeatWrapping},Zn={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Kn={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...Vs>=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},dt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},da={CUBICSPLINE:void 0,LINEAR:c.InterpolateLinear,STEP:c.InterpolateDiscrete},qn={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function pa(o){return o.DefaultMaterial===void 0&&(o.DefaultMaterial=new c.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:c.FrontSide})),o.DefaultMaterial}function wt(o,e,t){for(const n in t.extensions)o[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function pt(o,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(o.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function ma(o,e,t){let n=!1,s=!1,r=!1;for(let u=0,h=e.length;u<h;u++){const d=e[u];if(d.POSITION!==void 0&&(n=!0),d.NORMAL!==void 0&&(s=!0),d.COLOR_0!==void 0&&(r=!0),n&&s&&r)break}if(!n&&!s&&!r)return Promise.resolve(o);const i=[],a=[],l=[];for(let u=0,h=e.length;u<h;u++){const d=e[u];if(n){const y=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):o.attributes.position;i.push(y)}if(s){const y=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):o.attributes.normal;a.push(y)}if(r){const y=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):o.attributes.color;l.push(y)}}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(l)]).then(function(u){const h=u[0],d=u[1],y=u[2];return n&&(o.morphAttributes.position=h),s&&(o.morphAttributes.normal=d),r&&(o.morphAttributes.color=y),o.morphTargetsRelative=!0,o})}function ga(o,e){if(o.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)o.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(o.morphTargetInfluences.length===t.length){o.morphTargetDictionary={};for(let n=0,s=t.length;n<s;n++)o.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function ya(o){let e;const t=o.extensions&&o.extensions[be.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Qn(t.attributes):e=o.indices+":"+Qn(o.attributes)+":"+o.mode,o.targets!==void 0)for(let n=0,s=o.targets.length;n<s;n++)e+=":"+Qn(o.targets[n]);return e}function Qn(o){let e="";const t=Object.keys(o).sort();for(let n=0,s=t.length;n<s;n++)e+=t[n]+":"+o[t[n]]+";";return e}function Jn(o){switch(o){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function _a(o){return o.search(/\.jpe?g($|\?)/i)>0||o.search(/^data\:image\/jpeg/)===0?"image/jpeg":o.search(/\.webp($|\?)/i)>0||o.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const va=new c.Matrix4;class xa{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Yo,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,s=!1,r=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,s=navigator.userAgent.indexOf("Firefox")>-1,r=s?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||s&&r<98?this.textureLoader=new c.TextureLoader(this.options.manager):this.textureLoader=new c.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new c.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,s=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(i){const a={scene:i[0][s.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:s.asset,parser:n,userData:{}};wt(r,a,s),pt(a,s),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,r=t.length;s<r;s++){const i=t[s].joints;for(let a=0,l=i.length;a<l;a++)e[i[a]].isBone=!0}for(let s=0,r=e.length;s<r;s++){const i=e[s];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(n[i.mesh].isSkinnedMesh=!0)),i.camera!==void 0&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const s=n.clone(),r=(i,a)=>{const l=this.associations.get(i);l!=null&&this.associations.set(a,l);for(const[u,h]of i.children.entries())r(h,a.children[u])};return r(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const s=e(t[n]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let s=0;s<t.length;s++){const r=e(t[s]);r&&n.push(r)}return n}getDependency(e,t){const n=e+":"+t;let s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":s=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(r,i){return n.getDependency(e,i)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[be.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(r,i){n.load(c.LoaderUtils.resolveURL(t.uri,s.path),r,void 0,function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const s=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+s)})}loadAccessor(e){const t=this,n=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const i=Zn[s.type],a=Dt[s.componentType],l=s.normalized===!0,u=new a(s.count*i);return Promise.resolve(new c.BufferAttribute(u,i,l))}const r=[];return s.bufferView!==void 0?r.push(this.getDependency("bufferView",s.bufferView)):r.push(null),s.sparse!==void 0&&(r.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(r).then(function(i){const a=i[0],l=Zn[s.type],u=Dt[s.componentType],h=u.BYTES_PER_ELEMENT,d=h*l,y=s.byteOffset||0,g=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,x=s.normalized===!0;let w,v;if(g&&g!==d){const P=Math.floor(y/g),D="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+P+":"+s.count;let S=t.cache.get(D);S||(w=new u(a,P*g,s.count*g/h),S=new c.InterleavedBuffer(w,g/h),t.cache.add(D,S)),v=new c.InterleavedBufferAttribute(S,l,y%g/h,x)}else a===null?w=new u(s.count*l):w=new u(a,y,s.count*l),v=new c.BufferAttribute(w,l,x);if(s.sparse!==void 0){const P=Zn.SCALAR,D=Dt[s.sparse.indices.componentType],S=s.sparse.indices.byteOffset||0,_=s.sparse.values.byteOffset||0,L=new D(i[1],S,s.sparse.count*P),b=new u(i[2],_,s.sparse.count*l);a!==null&&(v=new c.BufferAttribute(v.array.slice(),v.itemSize,v.normalized));for(let C=0,m=L.length;C<m;C++){const M=L[C];if(v.setX(M,b[C*l]),l>=2&&v.setY(M,b[C*l+1]),l>=3&&v.setZ(M,b[C*l+2]),l>=4&&v.setW(M,b[C*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return v})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r];let a=this.textureLoader;if(i.uri){const l=n.manager.getHandler(i.uri);l!==null&&(a=l)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){const s=this,r=this.json,i=r.textures[e],a=r.images[t],l=(a.uri||a.bufferView)+":"+i.sampler;if(this.textureCache[l])return this.textureCache[l];const u=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=i.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const y=(r.samplers||{})[i.sampler]||{};return h.magFilter=ar[y.magFilter]||c.LinearFilter,h.minFilter=ar[y.minFilter]||c.LinearMipmapLinearFilter,h.wrapS=lr[y.wrapS]||c.RepeatWrapping,h.wrapT=lr[y.wrapT]||c.RepeatWrapping,s.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=u,u}loadImageSource(e,t){const n=this,s=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const i=s.images[e],a=self.URL||self.webkitURL;let l=i.uri||"",u=!1;if(i.bufferView!==void 0)l=n.getDependency("bufferView",i.bufferView).then(function(d){u=!0;const y=new Blob([d],{type:i.mimeType});return l=a.createObjectURL(y),l});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(l).then(function(d){return new Promise(function(y,g){let x=y;t.isImageBitmapLoader===!0&&(x=function(w){const v=new c.Texture(w);v.needsUpdate=!0,y(v)}),t.load(c.LoaderUtils.resolveURL(d,r.path),x,void 0,g)})}).then(function(d){return u===!0&&a.revokeObjectURL(l),d.userData.mimeType=i.mimeType||_a(i.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),d});return this.sourceCache[e]=h,h}assignTexture(e,t,n,s){const r=this;return this.getDependency("texture",n.index).then(function(i){if(!i)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(i=i.clone(),i.channel=n.texCoord),r.extensions[be.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[be.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=r.associations.get(i);i=r.extensions[be.KHR_TEXTURE_TRANSFORM].extendTexture(i,a),r.associations.set(i,l)}}return s!==void 0&&("colorSpace"in i?i.colorSpace=s===3001?"srgb":"srgb-linear":i.encoding=s),e[t]=i,i})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const s=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,i=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new c.PointsMaterial,c.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new c.LineBasicMaterial,c.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(s||r||i){let a="ClonedMaterial:"+n.uuid+":";s&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),i&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),r&&(l.vertexColors=!0),i&&(l.flatShading=!0),s&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return c.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,s=this.extensions,r=n.materials[e];let i;const a={},l=r.extensions||{},u=[];if(l[be.KHR_MATERIALS_UNLIT]){const d=s[be.KHR_MATERIALS_UNLIT];i=d.getMaterialType(),u.push(d.extendParams(a,r,t))}else{const d=r.pbrMetallicRoughness||{};if(a.color=new c.Color(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const y=d.baseColorFactor;a.color.fromArray(y),a.opacity=y[3]}d.baseColorTexture!==void 0&&u.push(t.assignTexture(a,"map",d.baseColorTexture,3001)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(u.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),u.push(t.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),i=this._invokeOne(function(y){return y.getMaterialType&&y.getMaterialType(e)}),u.push(Promise.all(this._invokeAll(function(y){return y.extendMaterialParams&&y.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=c.DoubleSide);const h=r.alphaMode||qn.OPAQUE;if(h===qn.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===qn.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&i!==c.MeshBasicMaterial&&(u.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new c.Vector2(1,1),r.normalTexture.scale!==void 0)){const d=r.normalTexture.scale;a.normalScale.set(d,d)}return r.occlusionTexture!==void 0&&i!==c.MeshBasicMaterial&&(u.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&i!==c.MeshBasicMaterial&&(a.emissive=new c.Color().fromArray(r.emissiveFactor)),r.emissiveTexture!==void 0&&i!==c.MeshBasicMaterial&&u.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,3001)),Promise.all(u).then(function(){const d=new i(a);return r.name&&(d.name=r.name),pt(d,r),t.associations.set(d,{materials:e}),r.extensions&&wt(s,d,r),d})}createUniqueName(e){const t=c.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,s=this.primitiveCache;function r(a){return n[be.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return cr(l,a,t)})}const i=[];for(let a=0,l=e.length;a<l;a++){const u=e[a],h=ya(u),d=s[h];if(d)i.push(d.promise);else{let y;u.extensions&&u.extensions[be.KHR_DRACO_MESH_COMPRESSION]?y=r(u):y=cr(new c.BufferGeometry,u,t),s[h]={primitive:u,promise:y},i.push(y)}}return Promise.all(i)}loadMesh(e){const t=this,n=this.json,s=this.extensions,r=n.meshes[e],i=r.primitives,a=[];for(let l=0,u=i.length;l<u;l++){const h=i[l].material===void 0?pa(this.cache):this.getDependency("material",i[l].material);a.push(h)}return a.push(t.loadGeometries(i)),Promise.all(a).then(function(l){const u=l.slice(0,l.length-1),h=l[l.length-1],d=[];for(let g=0,x=h.length;g<x;g++){const w=h[g],v=i[g];let P;const D=u[g];if(v.mode===We.TRIANGLES||v.mode===We.TRIANGLE_STRIP||v.mode===We.TRIANGLE_FAN||v.mode===void 0)P=r.isSkinnedMesh===!0?new c.SkinnedMesh(w,D):new c.Mesh(w,D),P.isSkinnedMesh===!0&&P.normalizeSkinWeights(),v.mode===We.TRIANGLE_STRIP?P.geometry=zs(P.geometry,c.TriangleStripDrawMode):v.mode===We.TRIANGLE_FAN&&(P.geometry=zs(P.geometry,c.TriangleFanDrawMode));else if(v.mode===We.LINES)P=new c.LineSegments(w,D);else if(v.mode===We.LINE_STRIP)P=new c.Line(w,D);else if(v.mode===We.LINE_LOOP)P=new c.LineLoop(w,D);else if(v.mode===We.POINTS)P=new c.Points(w,D);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+v.mode);Object.keys(P.geometry.morphAttributes).length>0&&ga(P,r),P.name=t.createUniqueName(r.name||"mesh_"+e),pt(P,r),v.extensions&&wt(s,P,v),t.assignFinalMaterial(P),d.push(P)}for(let g=0,x=d.length;g<x;g++)t.associations.set(d[g],{meshes:e,primitives:g});if(d.length===1)return r.extensions&&wt(s,d[0],r),d[0];const y=new c.Group;r.extensions&&wt(s,y,r),t.associations.set(y,{meshes:e});for(let g=0,x=d.length;g<x;g++)y.add(d[g]);return y})}loadCamera(e){let t;const n=this.json.cameras[e],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new c.PerspectiveCamera(c.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(t=new c.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),pt(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let s=0,r=t.joints.length;s<r;s++)n.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){const r=s.pop(),i=s,a=[],l=[];for(let u=0,h=i.length;u<h;u++){const d=i[u];if(d){a.push(d);const y=new c.Matrix4;r!==null&&y.fromArray(r.array,u*16),l.push(y)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[u])}return new c.Skeleton(a,l)})}loadAnimation(e){const n=this.json.animations[e],s=n.name?n.name:"animation_"+e,r=[],i=[],a=[],l=[],u=[];for(let h=0,d=n.channels.length;h<d;h++){const y=n.channels[h],g=n.samplers[y.sampler],x=y.target,w=x.node,v=n.parameters!==void 0?n.parameters[g.input]:g.input,P=n.parameters!==void 0?n.parameters[g.output]:g.output;x.node!==void 0&&(r.push(this.getDependency("node",w)),i.push(this.getDependency("accessor",v)),a.push(this.getDependency("accessor",P)),l.push(g),u.push(x))}return Promise.all([Promise.all(r),Promise.all(i),Promise.all(a),Promise.all(l),Promise.all(u)]).then(function(h){const d=h[0],y=h[1],g=h[2],x=h[3],w=h[4],v=[];for(let P=0,D=d.length;P<D;P++){const S=d[P],_=y[P],L=g[P],b=x[P],C=w[P];if(S===void 0)continue;S.updateMatrix();let m;switch(dt[C.path]){case dt.weights:m=c.NumberKeyframeTrack;break;case dt.rotation:m=c.QuaternionKeyframeTrack;break;case dt.position:case dt.scale:default:m=c.VectorKeyframeTrack;break}const M=S.name?S.name:S.uuid,p=b.interpolation!==void 0?da[b.interpolation]:c.InterpolateLinear,I=[];dt[C.path]===dt.weights?S.traverse(function(J){J.morphTargetInfluences&&I.push(J.name?J.name:J.uuid)}):I.push(M);let F=L.array;if(L.normalized){const J=Jn(F.constructor),G=new Float32Array(F.length);for(let Q=0,K=F.length;Q<K;Q++)G[Q]=F[Q]*J;F=G}for(let J=0,G=I.length;J<G;J++){const Q=new m(I[J]+"."+dt[C.path],_.array,F,p);b.interpolation==="CUBICSPLINE"&&(Q.createInterpolant=function(Z){const X=this instanceof c.QuaternionKeyframeTrack?fa:or;return new X(this.times,this.values,this.getValueSize()/3,Z)},Q.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),v.push(Q)}}return new c.AnimationClip(s,void 0,v)})}createNodeMesh(e){const t=this.json,n=this,s=t.nodes[e];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(r){const i=n._getNodeRef(n.meshCache,s.mesh,r);return s.weights!==void 0&&i.traverse(function(a){if(a.isMesh)for(let l=0,u=s.weights.length;l<u;l++)a.morphTargetInfluences[l]=s.weights[l]}),i})}loadNode(e){const t=this.json,n=this,s=t.nodes[e],r=n._loadNodeShallow(e),i=[],a=s.children||[];for(let u=0,h=a.length;u<h;u++)i.push(n.getDependency("node",a[u]));const l=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([r,Promise.all(i),l]).then(function(u){const h=u[0],d=u[1],y=u[2];y!==null&&h.traverse(function(g){g.isSkinnedMesh&&g.bind(y,va)});for(let g=0,x=d.length;g<x;g++)h.add(d[g]);return h})}_loadNodeShallow(e){const t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],i=r.name?s.createUniqueName(r.name):"",a=[],l=s._invokeOne(function(u){return u.createNodeMesh&&u.createNodeMesh(e)});return l&&a.push(l),r.camera!==void 0&&a.push(s.getDependency("camera",r.camera).then(function(u){return s._getNodeRef(s.cameraCache,r.camera,u)})),s._invokeAll(function(u){return u.createNodeAttachment&&u.createNodeAttachment(e)}).forEach(function(u){a.push(u)}),this.nodeCache[e]=Promise.all(a).then(function(u){let h;if(r.isBone===!0?h=new c.Bone:u.length>1?h=new c.Group:u.length===1?h=u[0]:h=new c.Object3D,h!==u[0])for(let d=0,y=u.length;d<y;d++)h.add(u[d]);if(r.name&&(h.userData.name=r.name,h.name=i),pt(h,r),r.extensions&&wt(n,h,r),r.matrix!==void 0){const d=new c.Matrix4;d.fromArray(r.matrix),h.applyMatrix4(d)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);return s.associations.has(h)||s.associations.set(h,{}),s.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],s=this,r=new c.Group;n.name&&(r.name=s.createUniqueName(n.name)),pt(r,n),n.extensions&&wt(t,r,n);const i=n.nodes||[],a=[];for(let l=0,u=i.length;l<u;l++)a.push(s.getDependency("node",i[l]));return Promise.all(a).then(function(l){for(let h=0,d=l.length;h<d;h++)r.add(l[h]);const u=h=>{const d=new Map;for(const[y,g]of s.associations)(y instanceof c.Material||y instanceof c.Texture)&&d.set(y,g);return h.traverse(y=>{const g=s.associations.get(y);g!=null&&d.set(y,g)}),d};return s.associations=u(r),r})}}function wa(o,e,t){const n=e.attributes,s=new c.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],l=a.min,u=a.max;if(l!==void 0&&u!==void 0){if(s.set(new c.Vector3(l[0],l[1],l[2]),new c.Vector3(u[0],u[1],u[2])),a.normalized){const h=Jn(Dt[a.componentType]);s.min.multiplyScalar(h),s.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const a=new c.Vector3,l=new c.Vector3;for(let u=0,h=r.length;u<h;u++){const d=r[u];if(d.POSITION!==void 0){const y=t.json.accessors[d.POSITION],g=y.min,x=y.max;if(g!==void 0&&x!==void 0){if(l.setX(Math.max(Math.abs(g[0]),Math.abs(x[0]))),l.setY(Math.max(Math.abs(g[1]),Math.abs(x[1]))),l.setZ(Math.max(Math.abs(g[2]),Math.abs(x[2]))),y.normalized){const w=Jn(Dt[y.componentType]);l.multiplyScalar(w)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(a)}o.boundingBox=s;const i=new c.Sphere;s.getCenter(i.center),i.radius=s.min.distanceTo(s.max)/2,o.boundingSphere=i}function cr(o,e,t){const n=e.attributes,s=[];function r(i,a){return t.getDependency("accessor",i).then(function(l){o.setAttribute(a,l)})}for(const i in n){const a=Kn[i]||i.toLowerCase();a in o.attributes||s.push(r(n[i],a))}if(e.indices!==void 0&&!o.index){const i=t.getDependency("accessor",e.indices).then(function(a){o.setIndex(a)});s.push(i)}return pt(o,e),wa(o,e,t),Promise.all(s).then(function(){return e.targets!==void 0?ma(o,e.targets,t):o})}class ur extends c.ExtrudeGeometry{constructor(e,t={}){const{bevelEnabled:n=!1,bevelSize:s=8,bevelThickness:r=10,font:i,height:a=50,size:l=100,lineHeight:u=1,letterSpacing:h=0,...d}=t;if(i===void 0)super();else{const y=i.generateShapes(e,l,{lineHeight:u,letterSpacing:h});super(y,{...d,bevelEnabled:n,bevelSize:s,bevelThickness:r,depth:a})}this.type="TextGeometry"}}const ba={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
|
|
27
|
+
`})),Lt.uniforms.blitTexture.value=o,Lt.defines.IS_SRGB="colorSpace"in o?o.colorSpace==="srgb":o.encoding===3001,Lt.needsUpdate=!0,pn||(pn=new c.Mesh(Vn,Lt),pn.frustrumCulled=!1);const n=new c.PerspectiveCamera,r=new c.Scene;r.add(pn),t||(t=dn=new c.WebGLRenderer({antialias:!1})),t.setSize(Math.min(o.image.width,e),Math.min(o.image.height,e)),t.clear(),t.render(r,n);const s=new c.Texture(t.domElement);return s.minFilter=o.minFilter,s.magFilter=o.magFilter,s.wrapS=o.wrapS,s.wrapT=o.wrapT,s.name=o.name,dn&&(dn.dispose(),dn=null),s}const Er={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 Gn{constructor(){this.pluginCallbacks=[],this.register(function(e){return new so(e)}),this.register(function(e){return new io(e)}),this.register(function(e){return new lo(e)}),this.register(function(e){return new co(e)}),this.register(function(e){return new uo(e)}),this.register(function(e){return new ho(e)}),this.register(function(e){return new oo(e)}),this.register(function(e){return new ao(e)}),this.register(function(e){return new fo(e)}),this.register(function(e){return new po(e)}),this.register(function(e){return new mo(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,n,r){const s=new ro,i=[];for(let a=0,l=this.pluginCallbacks.length;a<l;a++)i.push(this.pluginCallbacks[a](s));s.setPlugins(i),s.write(e,t,r).catch(n)}parseAsync(e,t){const n=this;return new Promise(function(r,s){n.parse(e,r,s,t)})}}Ki(Gn,"Utils",{insertKeyframe:function(o,e){const n=o.getValueSize(),r=new o.TimeBufferType(o.times.length+1),s=new o.ValueBufferType(o.values.length+n),i=o.createInterpolant(new o.ValueBufferType(n));let a;if(o.times.length===0){r[0]=e;for(let l=0;l<n;l++)s[l]=0;a=0}else if(e<o.times[0]){if(Math.abs(o.times[0]-e)<.001)return 0;r[0]=e,r.set(o.times,1),s.set(i.evaluate(e),0),s.set(o.values,n),a=0}else if(e>o.times[o.times.length-1]){if(Math.abs(o.times[o.times.length-1]-e)<.001)return o.times.length-1;r[r.length-1]=e,r.set(o.times,0),s.set(o.values,0),s.set(i.evaluate(e),o.values.length),a=r.length-1}else for(let l=0;l<o.times.length;l++){if(Math.abs(o.times[l]-e)<.001)return l;if(o.times[l]<e&&o.times[l+1]>e){r.set(o.times.slice(0,l+1),0),r[l+1]=e,r.set(o.times.slice(l+1),l+2),s.set(o.values.slice(0,(l+1)*n),0),s.set(i.evaluate(e),(l+1)*n),s.set(o.values.slice((l+1)*n),(l+2)*n),a=l+1;break}}return o.times=r,o.values=s,a},mergeMorphTargetTracks:function(o,e){const t=[],n={},r=o.tracks;for(let s=0;s<r.length;++s){let i=r[s];const a=c.PropertyBinding.parseTrackName(i.name),l=c.PropertyBinding.findNode(e,a.nodeName);if(a.propertyName!=="morphTargetInfluences"||a.propertyIndex===void 0){t.push(i);continue}if(i.createInterpolant!==i.InterpolantFactoryMethodDiscrete&&i.createInterpolant!==i.InterpolantFactoryMethodLinear){if(i.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."),i=i.clone(),i.setInterpolation(c.InterpolateLinear)}const u=l.morphTargetInfluences.length,h=l.morphTargetDictionary[a.propertyIndex];if(h===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let d;if(n[l.uuid]===void 0){d=i.clone();const y=new d.ValueBufferType(u*d.times.length);for(let x=0;x<d.times.length;x++)y[x*u+h]=d.values[x];d.name=(a.nodeName||"")+".morphTargetInfluences",d.values=y,n[l.uuid]=d,t.push(d);continue}const g=i.createInterpolant(new i.ValueBufferType(1));d=n[l.uuid];for(let y=0;y<d.times.length;y++)d.values[y*u+h]=g.evaluate(d.times[y]);for(let y=0;y<i.times.length;y++){const x=this.insertKeyframe(d,i.times[y]);d.values[x*u+h]=i.values[y]}}return o.tracks=t,o}});const we={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},jn="KHR_mesh_quantization",Ee={};Ee[c.NearestFilter]=we.NEAREST,Ee[c.NearestMipmapNearestFilter]=we.NEAREST_MIPMAP_NEAREST,Ee[c.NearestMipmapLinearFilter]=we.NEAREST_MIPMAP_LINEAR,Ee[c.LinearFilter]=we.LINEAR,Ee[c.LinearMipmapNearestFilter]=we.LINEAR_MIPMAP_NEAREST,Ee[c.LinearMipmapLinearFilter]=we.LINEAR_MIPMAP_LINEAR,Ee[c.ClampToEdgeWrapping]=we.CLAMP_TO_EDGE,Ee[c.RepeatWrapping]=we.REPEAT,Ee[c.MirroredRepeatWrapping]=we.MIRRORED_REPEAT;const Wr={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},qi=new c.Color,Yr=12,Qi=1179937895,Ji=2,Xr=8,Hi=1313821514,$i=5130562;function Et(o,e){return o.length===e.length&&o.every(function(t,n){return t===e[n]})}function eo(o){return new TextEncoder().encode(o).buffer}function to(o){return Et(o.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function no(o,e,t){const n={min:new Array(o.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(o.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let r=e;r<e+t;r++)for(let s=0;s<o.itemSize;s++){let i;o.itemSize>4?i=o.array[r*o.itemSize+s]:(s===0?i=o.getX(r):s===1?i=o.getY(r):s===2?i=o.getZ(r):s===3&&(i=o.getW(r)),o.normalized===!0&&(i=c.MathUtils.normalize(i,o.array))),n.min[s]=Math.min(n.min[s],i),n.max[s]=Math.max(n.max[s],i)}return n}function Zr(o){return Math.ceil(o/4)*4}function En(o,e=0){const t=Zr(o.byteLength);if(t!==o.byteLength){const n=new Uint8Array(t);if(n.set(new Uint8Array(o)),e!==0)for(let r=o.byteLength;r<t;r++)n[r]=e;return n.buffer}return o}function Kr(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function qr(o,e){if(o.toBlob!==void 0)return new Promise(n=>o.toBlob(n,e));let t;return e==="image/jpeg"?t=.92:e==="image/webp"&&(t=.8),o.convertToBlob({type:e,quality:t})}class ro{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);const r=this,s=r.buffers,i=r.json;n=r.options;const a=r.extensionsUsed,l=r.extensionsRequired,u=new Blob(s,{type:"application/octet-stream"}),h=Object.keys(a),d=Object.keys(l);h.length>0&&(i.extensionsUsed=h),d.length>0&&(i.extensionsRequired=d),i.buffers&&i.buffers.length>0&&(i.buffers[0].byteLength=u.size),n.binary===!0?u.arrayBuffer().then(g=>{const y=En(g),x=new DataView(new ArrayBuffer(Xr));x.setUint32(0,y.byteLength,!0),x.setUint32(4,$i,!0);const w=En(eo(JSON.stringify(i)),32),v=new DataView(new ArrayBuffer(Xr));v.setUint32(0,w.byteLength,!0),v.setUint32(4,Hi,!0);const A=new ArrayBuffer(Yr),D=new DataView(A);D.setUint32(0,Qi,!0),D.setUint32(4,Ji,!0);const M=Yr+v.byteLength+w.byteLength+x.byteLength+y.byteLength;D.setUint32(8,M,!0),new Blob([A,v,w,x,y],{type:"application/octet-stream"}).arrayBuffer().then(t)}):i.buffers&&i.buffers.length>0?jr(u).then(g=>{i.buffers[0].uri=g,t(i)}):t(i)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;const n=this.options,r=this.extensionsUsed;try{const s=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&s.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(const i in s.gltfExtensions)t.extensions[i]=s.gltfExtensions[i],r[i]=!0;delete s.gltfExtensions}Object.keys(s).length>0&&(t.extras=s)}catch(s){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+s.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){const r=new Map;r.set(!0,this.uid++),r.set(!1,this.uid++),this.uids.set(e,r)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const n=new c.Vector3;for(let r=0,s=e.count;r<s;r++)if(Math.abs(n.fromBufferAttribute(e,r).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 n=e.clone(),r=new c.Vector3;for(let s=0,i=n.count;s<i;s++)r.fromBufferAttribute(n,s),r.x===0&&r.y===0&&r.z===0?r.setX(1):r.normalize(),n.setXYZ(s,r.x,r.y,r.z);return t.attributesNormalized.set(e,n),n}applyTextureTransform(e,t){let n=!1;const r={};(t.offset.x!==0||t.offset.y!==0)&&(r.offset=t.offset.toArray(),n=!0),t.rotation!==0&&(r.rotation=t.rotation,n=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(r.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=r,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function n(y){return("colorSpace"in y?y.colorSpace==="srgb":y.encoding===3001)?function(w){return w<.04045?w*.0773993808:Math.pow(w*.9478672986+.0521327014,2.4)}:function(w){return w}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof c.CompressedTexture&&(e=Rn(e)),t instanceof c.CompressedTexture&&(t=Rn(t));const r=e?e.image:null,s=t?t.image:null,i=Math.max(r?r.width:0,s?s.width:0),a=Math.max(r?r.height:0,s?s.height:0),l=Kr();l.width=i,l.height=a;const u=l.getContext("2d");u.fillStyle="#00ffff",u.fillRect(0,0,i,a);const h=u.getImageData(0,0,i,a);if(r){u.drawImage(r,0,0,i,a);const y=n(e),x=u.getImageData(0,0,i,a).data;for(let w=2;w<x.length;w+=4)h.data[w]=y(x[w]/256)*256}if(s){u.drawImage(s,0,0,i,a);const y=n(t),x=u.getImageData(0,0,i,a).data;for(let w=1;w<x.length;w+=4)h.data[w]=y(x[w]/256)*256}u.putImageData(h,0,0);const g=(e||t).clone();return g.source=new c.Texture(l).source,"colorSpace"in g?g.colorSpace="":g.encoding=3e3,g.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),g}processBuffer(e){const t=this.json,n=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,t,n,r,s){const i=this.json;i.bufferViews||(i.bufferViews=[]);let a;switch(t){case we.BYTE:case we.UNSIGNED_BYTE:a=1;break;case we.SHORT:case we.UNSIGNED_SHORT:a=2;break;default:a=4}const l=Zr(r*e.itemSize*a),u=new DataView(new ArrayBuffer(l));let h=0;for(let y=n;y<n+r;y++)for(let x=0;x<e.itemSize;x++){let w;e.itemSize>4?w=e.array[y*e.itemSize+x]:(x===0?w=e.getX(y):x===1?w=e.getY(y):x===2?w=e.getZ(y):x===3&&(w=e.getW(y)),e.normalized===!0&&(w=c.MathUtils.normalize(w,e.array))),t===we.FLOAT?u.setFloat32(h,w,!0):t===we.INT?u.setInt32(h,w,!0):t===we.UNSIGNED_INT?u.setUint32(h,w,!0):t===we.SHORT?u.setInt16(h,w,!0):t===we.UNSIGNED_SHORT?u.setUint16(h,w,!0):t===we.BYTE?u.setInt8(h,w):t===we.UNSIGNED_BYTE&&u.setUint8(h,w),h+=a}const d={buffer:this.processBuffer(u.buffer),byteOffset:this.byteOffset,byteLength:l};return s!==void 0&&(d.target=s),s===we.ARRAY_BUFFER&&(d.byteStride=e.itemSize*a),this.byteOffset+=l,i.bufferViews.push(d),{id:i.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),e.arrayBuffer().then(r=>{const s=En(r),i={buffer:t.processBuffer(s),byteOffset:t.byteOffset,byteLength:s.byteLength};return t.byteOffset+=s.byteLength,n.bufferViews.push(i)-1})}processAccessor(e,t,n,r){const s=this.json,i={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",9:"MAT3",16:"MAT4"};let a;if(e.array.constructor===Float32Array)a=we.FLOAT;else if(e.array.constructor===Int32Array)a=we.INT;else if(e.array.constructor===Uint32Array)a=we.UNSIGNED_INT;else if(e.array.constructor===Int16Array)a=we.SHORT;else if(e.array.constructor===Uint16Array)a=we.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)a=we.BYTE;else if(e.array.constructor===Uint8Array)a=we.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type: "+e.array.constructor.name);if(n===void 0&&(n=0),r===void 0&&(r=e.count),r===0)return null;const l=no(e,n,r);let u;t!==void 0&&(u=e===t.index?we.ELEMENT_ARRAY_BUFFER:we.ARRAY_BUFFER);const h=this.processBufferView(e,a,n,r,u),d={bufferView:h.id,byteOffset:h.byteOffset,componentType:a,count:r,max:l.max,min:l.min,type:i[e.itemSize]};return e.normalized===!0&&(d.normalized=!0),s.accessors||(s.accessors=[]),s.accessors.push(d)-1}processImage(e,t,n,r="image/png"){if(e!==null){const s=this,i=s.cache,a=s.json,l=s.options,u=s.pending;i.images.has(e)||i.images.set(e,{});const h=i.images.get(e),d=r+":flipY/"+n.toString();if(h[d]!==void 0)return h[d];a.images||(a.images=[]);const g={mimeType:r},y=Kr();y.width=Math.min(e.width,l.maxTextureSize),y.height=Math.min(e.height,l.maxTextureSize);const x=y.getContext("2d");if(n===!0&&(x.translate(0,y.height),x.scale(1,-1)),e.data!==void 0){t!==c.RGBAFormat&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>l.maxTextureSize||e.height>l.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const v=new Uint8ClampedArray(e.height*e.width*4);for(let A=0;A<v.length;A+=4)v[A+0]=e.data[A+0],v[A+1]=e.data[A+1],v[A+2]=e.data[A+2],v[A+3]=e.data[A+3];x.putImageData(new ImageData(v,e.width,e.height),0,0)}else x.drawImage(e,0,0,y.width,y.height);l.binary===!0?u.push(qr(y,r).then(v=>s.processBufferViewImage(v)).then(v=>{g.bufferView=v})):y.toDataURL!==void 0?g.uri=y.toDataURL(r):u.push(qr(y,r).then(jr).then(v=>{g.uri=v}));const w=a.images.push(g)-1;return h[d]=w,w}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 n={magFilter:Ee[e.magFilter],minFilter:Ee[e.minFilter],wrapS:Ee[e.wrapS],wrapT:Ee[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){const n=this.options,r=this.cache,s=this.json;if(r.textures.has(e))return r.textures.get(e);s.textures||(s.textures=[]),e instanceof c.CompressedTexture&&(e=Rn(e,n.maxTextureSize));let i=e.userData.mimeType;i==="image/webp"&&(i="image/png");const a={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,i)};e.name&&(a.name=e.name),this._invokeAll(function(u){u.writeTexture&&u.writeTexture(e,a)});const l=s.textures.push(a)-1;return r.textures.set(e,l),l}processMaterial(e){const t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);const r={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const s=e.color.toArray().concat([e.opacity]);if(Et(s,[1,1,1,1])||(r.pbrMetallicRoughness.baseColorFactor=s),e.isMeshStandardMaterial?(r.pbrMetallicRoughness.metallicFactor=e.metalness,r.pbrMetallicRoughness.roughnessFactor=e.roughness):(r.pbrMetallicRoughness.metallicFactor=.5,r.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const a=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),l={index:this.processTexture(a),channel:a.channel};this.applyTextureTransform(l,a),r.pbrMetallicRoughness.metallicRoughnessTexture=l}if(e.map){const a={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(a,e.map),r.pbrMetallicRoughness.baseColorTexture=a}if(e.emissive){const a=e.emissive;if(Math.max(a.r,a.g,a.b)>0&&(r.emissiveFactor=e.emissive.toArray()),e.emissiveMap){const u={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(u,e.emissiveMap),r.emissiveTexture=u}}if(e.normalMap){const a={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(a.scale=e.normalScale.x),this.applyTextureTransform(a,e.normalMap),r.normalTexture=a}if(e.aoMap){const a={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(a.strength=e.aoMapIntensity),this.applyTextureTransform(a,e.aoMap),r.occlusionTexture=a}e.transparent?r.alphaMode="BLEND":e.alphaTest>0&&(r.alphaMode="MASK",r.alphaCutoff=e.alphaTest),e.side===c.DoubleSide&&(r.doubleSided=!0),e.name!==""&&(r.name=e.name),this.serializeUserData(e,r),this._invokeAll(function(a){a.writeMaterial&&a.writeMaterial(e,r)});const i=n.materials.push(r)-1;return t.materials.set(e,i),i}processMesh(e){const t=this.cache,n=this.json,r=[e.geometry.uuid];if(Array.isArray(e.material))for(let M=0,_=e.material.length;M<_;M++)r.push(e.material[M].uuid);else r.push(e.material.uuid);const s=r.join(":");if(t.meshes.has(s))return t.meshes.get(s);const i=e.geometry;let a;e.isLineSegments?a=we.LINES:e.isLineLoop?a=we.LINE_LOOP:e.isLine?a=we.LINE_STRIP:e.isPoints?a=we.POINTS:a=e.material.wireframe?we.LINES:we.TRIANGLES;const l={},u={},h=[],d=[],g={...Gr>=152?{uv:"TEXCOORD_0",uv1:"TEXCOORD_1",uv2:"TEXCOORD_2",uv3:"TEXCOORD_3"}:{uv:"TEXCOORD_0",uv2:"TEXCOORD_1"},color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},y=i.getAttribute("normal");y!==void 0&&!this.isNormalizedNormalAttribute(y)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),i.setAttribute("normal",this.createNormalizedNormalAttribute(y)));let x=null;for(let M in i.attributes){if(M.slice(0,5)==="morph")continue;const _=i.attributes[M];if(M=g[M]||M.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(M)||(M="_"+M),t.attributes.has(this.getUID(_))){u[M]=t.attributes.get(this.getUID(_));continue}x=null;const b=_.array;M==="JOINTS_0"&&!(b instanceof Uint16Array)&&!(b instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),x=new c.BufferAttribute(new Uint16Array(b),_.itemSize,_.normalized));const C=this.processAccessor(x||_,i);C!==null&&(M.startsWith("_")||this.detectMeshQuantization(M,_),u[M]=C,t.attributes.set(this.getUID(_),C))}if(y!==void 0&&i.setAttribute("normal",y),Object.keys(u).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const M=[],_=[],L={};if(e.morphTargetDictionary!==void 0)for(const b in e.morphTargetDictionary)L[e.morphTargetDictionary[b]]=b;for(let b=0;b<e.morphTargetInfluences.length;++b){const C={};let m=!1;for(const S in i.morphAttributes){if(S!=="position"&&S!=="normal"){m||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),m=!0);continue}const p=i.morphAttributes[S][b],I=S.toUpperCase(),k=i.attributes[S];if(t.attributes.has(this.getUID(p,!0))){C[I]=t.attributes.get(this.getUID(p,!0));continue}const J=p.clone();if(!i.morphTargetsRelative)for(let R=0,Z=p.count;R<Z;R++)for(let X=0;X<p.itemSize;X++)X===0&&J.setX(R,p.getX(R)-k.getX(R)),X===1&&J.setY(R,p.getY(R)-k.getY(R)),X===2&&J.setZ(R,p.getZ(R)-k.getZ(R)),X===3&&J.setW(R,p.getW(R)-k.getW(R));C[I]=this.processAccessor(J,i),t.attributes.set(this.getUID(k,!0),C[I])}d.push(C),M.push(e.morphTargetInfluences[b]),e.morphTargetDictionary!==void 0&&_.push(L[b])}l.weights=M,_.length>0&&(l.extras={},l.extras.targetNames=_)}const w=Array.isArray(e.material);if(w&&i.groups.length===0)return null;const v=w?e.material:[e.material],A=w?i.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let M=0,_=A.length;M<_;M++){const L={mode:a,attributes:u};if(this.serializeUserData(i,L),d.length>0&&(L.targets=d),i.index!==null){let C=this.getUID(i.index);(A[M].start!==void 0||A[M].count!==void 0)&&(C+=":"+A[M].start+":"+A[M].count),t.attributes.has(C)?L.indices=t.attributes.get(C):(L.indices=this.processAccessor(i.index,i,A[M].start,A[M].count),t.attributes.set(C,L.indices)),L.indices===null&&delete L.indices}const b=this.processMaterial(v[A[M].materialIndex]);b!==null&&(L.material=b),h.push(L)}l.primitives=h,n.meshes||(n.meshes=[]),this._invokeAll(function(M){M.writeMesh&&M.writeMesh(e,l)});const D=n.meshes.push(l)-1;return t.meshes.set(s,D),D}detectMeshQuantization(e,t){if(this.extensionsUsed[jn])return;let n;switch(t.array.constructor){case Int8Array:n="byte";break;case Uint8Array:n="unsigned byte";break;case Int16Array:n="short";break;case Uint16Array:n="unsigned short";break;default:return}t.normalized&&(n+=" normalized");const r=e.split("_",1)[0];Er[r]&&Er[r].includes(n)&&(this.extensionsUsed[jn]=!0,this.extensionsRequired[jn]=!0)}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const n=e.isOrthographicCamera,r={type:n?"orthographic":"perspective"};return n?r.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:c.MathUtils.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(r.name=e.type),t.cameras.push(r)-1}processAnimation(e,t){const n=this.json,r=this.nodeMap;n.animations||(n.animations=[]),e=Gn.Utils.mergeMorphTargetTracks(e.clone(),t);const s=e.tracks,i=[],a=[];for(let l=0;l<s.length;++l){const u=s[l],h=c.PropertyBinding.parseTrackName(u.name);let d=c.PropertyBinding.findNode(t,h.nodeName);const g=Wr[h.propertyName];if(h.objectName==="bones"&&(d.isSkinnedMesh===!0?d=d.skeleton.getBoneByName(h.objectIndex):d=void 0),!d||!g)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',u.name),null;const y=1;let x=u.values.length/u.times.length;g===Wr.morphTargetInfluences&&(x/=d.morphTargetInfluences.length);let w;u.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(w="CUBICSPLINE",x/=3):u.getInterpolation()===c.InterpolateDiscrete?w="STEP":w="LINEAR",a.push({input:this.processAccessor(new c.BufferAttribute(u.times,y)),output:this.processAccessor(new c.BufferAttribute(u.values,x)),interpolation:w}),i.push({sampler:a.length-1,target:{node:r.get(d),path:g}})}return n.animations.push({name:e.name||"clip_"+n.animations.length,samplers:a,channels:i}),n.animations.length-1}processSkin(e){const t=this.json,n=this.nodeMap,r=t.nodes[n.get(e)],s=e.skeleton;if(s===void 0)return null;const i=e.skeleton.bones[0];if(i===void 0)return null;const a=[],l=new Float32Array(s.bones.length*16),u=new c.Matrix4;for(let d=0;d<s.bones.length;++d)a.push(n.get(s.bones[d])),u.copy(s.boneInverses[d]),u.multiply(e.bindMatrix).toArray(l,d*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new c.BufferAttribute(l,16)),joints:a,skeleton:n.get(i)}),r.skin=t.skins.length-1}processNode(e){const t=this.json,n=this.options,r=this.nodeMap;t.nodes||(t.nodes=[]);const s={};if(n.trs){const a=e.quaternion.toArray(),l=e.position.toArray(),u=e.scale.toArray();Et(a,[0,0,0,1])||(s.rotation=a),Et(l,[0,0,0])||(s.translation=l),Et(u,[1,1,1])||(s.scale=u)}else e.matrixAutoUpdate&&e.updateMatrix(),to(e.matrix)===!1&&(s.matrix=e.matrix.elements);if(e.name!==""&&(s.name=String(e.name)),this.serializeUserData(e,s),e.isMesh||e.isLine||e.isPoints){const a=this.processMesh(e);a!==null&&(s.mesh=a)}else e.isCamera&&(s.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const a=[];for(let l=0,u=e.children.length;l<u;l++){const h=e.children[l];if(h.visible||n.onlyVisible===!1){const d=this.processNode(h);d!==null&&a.push(d)}}a.length>0&&(s.children=a)}this._invokeAll(function(a){a.writeNode&&a.writeNode(e,s)});const i=t.nodes.push(s)-1;return r.set(e,i),i}processScene(e){const t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);const r={};e.name!==""&&(r.name=e.name),t.scenes.push(r);const s=[];for(let i=0,a=e.children.length;i<a;i++){const l=e.children[i];if(l.visible||n.onlyVisible===!1){const u=this.processNode(l);u!==null&&s.push(u)}}s.length>0&&(r.nodes=s),this.serializeUserData(e,r)}processObjects(e){const t=new c.Scene;t.name="AuxScene";for(let n=0;n<e.length;n++)t.children.push(e[n]);this.processScene(t)}processInput(e){const t=this.options;e=e instanceof Array?e:[e],this._invokeAll(function(r){r.beforeParse&&r.beforeParse(e)});const n=[];for(let r=0;r<e.length;r++)e[r]instanceof c.Scene?this.processScene(e[r]):n.push(e[r]);n.length>0&&this.processObjects(n);for(let r=0;r<this.skins.length;++r)this.processSkin(this.skins[r]);for(let r=0;r<t.animations.length;++r)this.processAnimation(t.animations[r],e[0]);this._invokeAll(function(r){r.afterParse&&r.afterParse(e)})}_invokeAll(e){for(let t=0,n=this.plugins.length;t<n;t++)e(this.plugins[t])}}class so{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 n=this.writer,r=n.json,s=n.extensionsUsed,i={};e.name&&(i.name=e.name),i.color=e.color.toArray(),i.intensity=e.intensity,e.isDirectionalLight?i.type="directional":e.isPointLight?(i.type="point",e.distance>0&&(i.range=e.distance)):e.isSpotLight&&(i.type="spot",e.distance>0&&(i.range=e.distance),i.spot={},i.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,i.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."),s[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},s[this.name]=!0);const a=r.extensions[this.name].lights;a.push(i),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}}let io=class{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const r=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},r[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},oo=class{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;const n=this.writer,r=n.extensionsUsed,s={};if(s.clearcoatFactor=e.clearcoat,e.clearcoatMap){const i={index:n.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(i,e.clearcoatMap),s.clearcoatTexture=i}if(s.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const i={index:n.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(i,e.clearcoatRoughnessMap),s.clearcoatRoughnessTexture=i}if(e.clearcoatNormalMap){const i={index:n.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};n.applyTextureTransform(i,e.clearcoatNormalMap),s.clearcoatNormalTexture=i}t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},ao=class{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;const n=this.writer,r=n.extensionsUsed,s={};if(s.iridescenceFactor=e.iridescence,e.iridescenceMap){const i={index:n.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(i,e.iridescenceMap),s.iridescenceTexture=i}if(s.iridescenceIor=e.iridescenceIOR,s.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],s.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const i={index:n.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(i,e.iridescenceThicknessMap),s.iridescenceThicknessTexture=i}t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},lo=class{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,r=n.extensionsUsed,s={};if(s.transmissionFactor=e.transmission,e.transmissionMap){const i={index:n.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(i,e.transmissionMap),s.transmissionTexture=i}t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},co=class{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;const n=this.writer,r=n.extensionsUsed,s={};if(s.thicknessFactor=e.thickness,e.thicknessMap){const i={index:n.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(i,e.thicknessMap),s.thicknessTexture=i}s.attenuationDistance=e.attenuationDistance,s.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},uo=class{constructor(e){this.writer=e,this.name="KHR_materials_ior"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;const r=this.writer.extensionsUsed,s={};s.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},ho=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(qi)&&!e.specularIntensityMap&&!e.specularColorTexture)return;const n=this.writer,r=n.extensionsUsed,s={};if(e.specularIntensityMap){const i={index:n.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(i,e.specularIntensityMap),s.specularTexture=i}if(e.specularColorMap){const i={index:n.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(i,e.specularColorMap),s.specularColorTexture=i}s.specularFactor=e.specularIntensity,s.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},fo=class{constructor(e){this.writer=e,this.name="KHR_materials_sheen"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;const n=this.writer,r=n.extensionsUsed,s={};if(e.sheenRoughnessMap){const i={index:n.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(i,e.sheenRoughnessMap),s.sheenRoughnessTexture=i}if(e.sheenColorMap){const i={index:n.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(i,e.sheenColorMap),s.sheenColorTexture=i}s.sheenRoughnessFactor=e.sheenRoughness,s.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},po=class{constructor(e){this.writer=e,this.name="KHR_materials_anisotropy"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;const n=this.writer,r=n.extensionsUsed,s={};if(e.anisotropyMap){const i={index:n.processTexture(e.anisotropyMap)};n.applyTextureTransform(i,e.anisotropyMap),s.anisotropyTexture=i}s.anisotropyStrength=e.anisotropy,s.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}},mo=class{constructor(e){this.writer=e,this.name="KHR_materials_emissive_strength"}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;const r=this.writer.extensionsUsed,s={};s.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=s,r[this.name]=!0}};var Ye=Uint8Array,ft=Uint16Array,Wn=Uint32Array,Qr=new Ye([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Jr=new Ye([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),go=new Ye([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Hr=function(o,e){for(var t=new ft(31),n=0;n<31;++n)t[n]=e+=1<<o[n-1];for(var r=new Wn(t[30]),n=1;n<30;++n)for(var s=t[n];s<t[n+1];++s)r[s]=s-t[n]<<5|n;return[t,r]},$r=Hr(Qr,2),es=$r[0],yo=$r[1];es[28]=258,yo[258]=28;for(var _o=Hr(Jr,0),vo=_o[0],Yn=new ft(32768),Te=0;Te<32768;++Te){var dt=(Te&43690)>>>1|(Te&21845)<<1;dt=(dt&52428)>>>2|(dt&13107)<<2,dt=(dt&61680)>>>4|(dt&3855)<<4,Yn[Te]=((dt&65280)>>>8|(dt&255)<<8)>>>1}for(var Wt=function(o,e,t){for(var n=o.length,r=0,s=new ft(e);r<n;++r)++s[o[r]-1];var i=new ft(e);for(r=0;r<e;++r)i[r]=i[r-1]+s[r-1]<<1;var a;if(t){a=new ft(1<<e);var l=15-e;for(r=0;r<n;++r)if(o[r])for(var u=r<<4|o[r],h=e-o[r],d=i[o[r]-1]++<<h,g=d|(1<<h)-1;d<=g;++d)a[Yn[d]>>>l]=u}else for(a=new ft(n),r=0;r<n;++r)o[r]&&(a[r]=Yn[i[o[r]-1]++]>>>15-o[r]);return a},Yt=new Ye(288),Te=0;Te<144;++Te)Yt[Te]=8;for(var Te=144;Te<256;++Te)Yt[Te]=9;for(var Te=256;Te<280;++Te)Yt[Te]=7;for(var Te=280;Te<288;++Te)Yt[Te]=8;for(var ts=new Ye(32),Te=0;Te<32;++Te)ts[Te]=5;var xo=Wt(Yt,9,1),wo=Wt(ts,5,1),Xn=function(o){for(var e=o[0],t=1;t<o.length;++t)o[t]>e&&(e=o[t]);return e},Qe=function(o,e,t){var n=e/8|0;return(o[n]|o[n+1]<<8)>>(e&7)&t},Zn=function(o,e){var t=e/8|0;return(o[t]|o[t+1]<<8|o[t+2]<<16)>>(e&7)},bo=function(o){return(o/8|0)+(o&7&&1)},Mo=function(o,e,t){(e==null||e<0)&&(e=0),(t==null||t>o.length)&&(t=o.length);var n=new(o instanceof ft?ft:o instanceof Wn?Wn:Ye)(t-e);return n.set(o.subarray(e,t)),n},So=function(o,e,t){var n=o.length;if(!n||t&&!t.l&&n<5)return e||new Ye(0);var r=!e||t,s=!t||t.i;t||(t={}),e||(e=new Ye(n*3));var i=function(ee){var N=e.length;if(ee>N){var G=new Ye(Math.max(N*2,ee));G.set(e),e=G}},a=t.f||0,l=t.p||0,u=t.b||0,h=t.l,d=t.d,g=t.m,y=t.n,x=n*8;do{if(!h){t.f=a=Qe(o,l,1);var w=Qe(o,l+1,3);if(l+=3,w)if(w==1)h=xo,d=wo,g=9,y=5;else if(w==2){var M=Qe(o,l,31)+257,_=Qe(o,l+10,15)+4,L=M+Qe(o,l+5,31)+1;l+=14;for(var b=new Ye(L),C=new Ye(19),m=0;m<_;++m)C[go[m]]=Qe(o,l+m*3,7);l+=_*3;for(var S=Xn(C),p=(1<<S)-1,I=Wt(C,S,1),m=0;m<L;){var k=I[Qe(o,l,p)];l+=k&15;var v=k>>>4;if(v<16)b[m++]=v;else{var J=0,R=0;for(v==16?(R=3+Qe(o,l,3),l+=2,J=b[m-1]):v==17?(R=3+Qe(o,l,7),l+=3):v==18&&(R=11+Qe(o,l,127),l+=7);R--;)b[m++]=J}}var Z=b.subarray(0,M),X=b.subarray(M);g=Xn(Z),y=Xn(X),h=Wt(Z,g,1),d=Wt(X,y,1)}else throw"invalid block type";else{var v=bo(l)+4,A=o[v-4]|o[v-3]<<8,D=v+A;if(D>n){if(s)throw"unexpected EOF";break}r&&i(u+A),e.set(o.subarray(v,D),u),t.b=u+=A,t.p=l=D*8;continue}if(l>x){if(s)throw"unexpected EOF";break}}r&&i(u+131072);for(var q=(1<<g)-1,Y=(1<<y)-1,te=l;;te=l){var J=h[Zn(o,l)&q],re=J>>>4;if(l+=J&15,l>x){if(s)throw"unexpected EOF";break}if(!J)throw"invalid length/literal";if(re<256)e[u++]=re;else if(re==256){te=l,h=null;break}else{var ce=re-254;if(re>264){var m=re-257,j=Qr[m];ce=Qe(o,l,(1<<j)-1)+es[m],l+=j}var z=d[Zn(o,l)&Y],P=z>>>4;if(!z)throw"invalid distance";l+=z&15;var X=vo[P];if(P>3){var j=Jr[P];X+=Zn(o,l)&(1<<j)-1,l+=j}if(l>x){if(s)throw"unexpected EOF";break}r&&i(u+131072);for(var V=u+ce;u<V;u+=4)e[u]=e[u-X],e[u+1]=e[u+1-X],e[u+2]=e[u+2-X],e[u+3]=e[u+3-X];u=V}}t.l=h,t.p=te,t.b=u,h&&(a=1,t.m=g,t.d=d,t.n=y)}while(!a);return u==e.length?e:Mo(e,0,u)},Ao=new Ye(0),Po=function(o){if((o[0]&15)!=8||o[0]>>>4>7||(o[0]<<8|o[1])%31)throw"invalid zlib data";if(o[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Co(o,e){return So((Po(o),o.subarray(2,-4)),e)}var To=typeof TextDecoder<"u"&&new TextDecoder,Lo=0;try{To.decode(Ao,{stream:!0}),Lo=1}catch{}const Be=new c.Triangle,mn=new c.Vector3;class Do{constructor(e){let t=e.geometry;t.index&&(console.warn("THREE.MeshSurfaceSampler: Converting geometry to non-indexed BufferGeometry."),t=t.toNonIndexed()),this.geometry=t,this.randomFunction=Math.random,this.positionAttribute=this.geometry.getAttribute("position"),this.colorAttribute=this.geometry.getAttribute("color"),this.weightAttribute=null,this.distribution=null}setWeightAttribute(e){return this.weightAttribute=e?this.geometry.getAttribute(e):null,this}build(){const e=this.positionAttribute,t=this.weightAttribute,n=new Float32Array(e.count/3);for(let s=0;s<e.count;s+=3){let i=1;t&&(i=t.getX(s)+t.getX(s+1)+t.getX(s+2)),Be.a.fromBufferAttribute(e,s),Be.b.fromBufferAttribute(e,s+1),Be.c.fromBufferAttribute(e,s+2),i*=Be.getArea(),n[s/3]=i}this.distribution=new Float32Array(e.count/3);let r=0;for(let s=0;s<n.length;s++)r+=n[s],this.distribution[s]=r;return this}setRandomGenerator(e){return this.randomFunction=e,this}sample(e,t,n){const r=this.sampleFaceIndex();return this.sampleFace(r,e,t,n)}sampleFaceIndex(){const e=this.distribution[this.distribution.length-1];return this.binarySearch(this.randomFunction()*e)}binarySearch(e){const t=this.distribution;let n=0,r=t.length-1,s=-1;for(;n<=r;){const i=Math.ceil((n+r)/2);if(i===0||t[i-1]<=e&&t[i]>e){s=i;break}else e<t[i]?r=i-1:n=i+1}return s}sampleFace(e,t,n,r){let s=this.randomFunction(),i=this.randomFunction();return s+i>1&&(s=1-s,i=1-i),Be.a.fromBufferAttribute(this.positionAttribute,e*3),Be.b.fromBufferAttribute(this.positionAttribute,e*3+1),Be.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Be.a,s).addScaledVector(Be.b,i).addScaledVector(Be.c,1-(s+i)),n!==void 0&&Be.getNormal(n),r!==void 0&&this.colorAttribute!==void 0&&(Be.a.fromBufferAttribute(this.colorAttribute,e*3),Be.b.fromBufferAttribute(this.colorAttribute,e*3+1),Be.c.fromBufferAttribute(this.colorAttribute,e*3+2),mn.set(0,0,0).addScaledVector(Be.a,s).addScaledVector(Be.b,i).addScaledVector(Be.c,1-(s+i)),r.r=mn.x,r.g=mn.y,r.b=mn.z),this}}var Io=Object.defineProperty,Oo=(o,e,t)=>e in o?Io(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,H=(o,e,t)=>(Oo(o,typeof e!="symbol"?e+"":e,t),t);class ko extends c.Object3D{constructor(e,t){super(),H(this,"isTransformControls",!0),H(this,"visible",!1),H(this,"domElement"),H(this,"raycaster",new c.Raycaster),H(this,"gizmo"),H(this,"plane"),H(this,"tempVector",new c.Vector3),H(this,"tempVector2",new c.Vector3),H(this,"tempQuaternion",new c.Quaternion),H(this,"unit",{X:new c.Vector3(1,0,0),Y:new c.Vector3(0,1,0),Z:new c.Vector3(0,0,1)}),H(this,"pointStart",new c.Vector3),H(this,"pointEnd",new c.Vector3),H(this,"offset",new c.Vector3),H(this,"rotationAxis",new c.Vector3),H(this,"startNorm",new c.Vector3),H(this,"endNorm",new c.Vector3),H(this,"rotationAngle",0),H(this,"cameraPosition",new c.Vector3),H(this,"cameraQuaternion",new c.Quaternion),H(this,"cameraScale",new c.Vector3),H(this,"parentPosition",new c.Vector3),H(this,"parentQuaternion",new c.Quaternion),H(this,"parentQuaternionInv",new c.Quaternion),H(this,"parentScale",new c.Vector3),H(this,"worldPositionStart",new c.Vector3),H(this,"worldQuaternionStart",new c.Quaternion),H(this,"worldScaleStart",new c.Vector3),H(this,"worldPosition",new c.Vector3),H(this,"worldQuaternion",new c.Quaternion),H(this,"worldQuaternionInv",new c.Quaternion),H(this,"worldScale",new c.Vector3),H(this,"eye",new c.Vector3),H(this,"positionStart",new c.Vector3),H(this,"quaternionStart",new c.Quaternion),H(this,"scaleStart",new c.Vector3),H(this,"camera"),H(this,"object"),H(this,"enabled",!0),H(this,"axis",null),H(this,"mode","translate"),H(this,"translationSnap",null),H(this,"rotationSnap",null),H(this,"scaleSnap",null),H(this,"space","world"),H(this,"size",1),H(this,"dragging",!1),H(this,"showX",!0),H(this,"showY",!0),H(this,"showZ",!0),H(this,"changeEvent",{type:"change"}),H(this,"mouseDownEvent",{type:"mouseDown",mode:this.mode}),H(this,"mouseUpEvent",{type:"mouseUp",mode:this.mode}),H(this,"objectChangeEvent",{type:"objectChange"}),H(this,"intersectObjectWithRay",(r,s,i)=>{const a=s.intersectObject(r,!0);for(let l=0;l<a.length;l++)if(a[l].object.visible||i)return a[l];return!1}),H(this,"attach",r=>(this.object=r,this.visible=!0,this)),H(this,"detach",()=>(this.object=void 0,this.visible=!1,this.axis=null,this)),H(this,"reset",()=>this.enabled?(this.dragging&&this.object!==void 0&&(this.object.position.copy(this.positionStart),this.object.quaternion.copy(this.quaternionStart),this.object.scale.copy(this.scaleStart),this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent),this.pointStart.copy(this.pointEnd)),this):this),H(this,"updateMatrixWorld",()=>{this.object!==void 0&&(this.object.updateMatrixWorld(),this.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this.parentPosition,this.parentQuaternion,this.parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this.worldScale),this.parentQuaternionInv.copy(this.parentQuaternion).invert(),this.worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this.cameraScale),this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld()}),H(this,"pointerHover",r=>{if(this.object===void 0||this.dragging===!0)return;this.raycaster.setFromCamera(r,this.camera);const s=this.intersectObjectWithRay(this.gizmo.picker[this.mode],this.raycaster);s?this.axis=s.object.name:this.axis=null}),H(this,"pointerDown",r=>{if(!(this.object===void 0||this.dragging===!0||r.button!==0)&&this.axis!==null){this.raycaster.setFromCamera(r,this.camera);const s=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(s){let i=this.space;if(this.mode==="scale"?i="local":(this.axis==="E"||this.axis==="XYZE"||this.axis==="XYZ")&&(i="world"),i==="local"&&this.mode==="rotate"){const a=this.rotationSnap;this.axis==="X"&&a&&(this.object.rotation.x=Math.round(this.object.rotation.x/a)*a),this.axis==="Y"&&a&&(this.object.rotation.y=Math.round(this.object.rotation.y/a)*a),this.axis==="Z"&&a&&(this.object.rotation.z=Math.round(this.object.rotation.z/a)*a)}this.object.updateMatrixWorld(),this.object.parent&&this.object.parent.updateMatrixWorld(),this.positionStart.copy(this.object.position),this.quaternionStart.copy(this.object.quaternion),this.scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this.worldScaleStart),this.pointStart.copy(s.point).sub(this.worldPositionStart)}this.dragging=!0,this.mouseDownEvent.mode=this.mode,this.dispatchEvent(this.mouseDownEvent)}}),H(this,"pointerMove",r=>{const s=this.axis,i=this.mode,a=this.object;let l=this.space;if(i==="scale"?l="local":(s==="E"||s==="XYZE"||s==="XYZ")&&(l="world"),a===void 0||s===null||this.dragging===!1||r.button!==-1)return;this.raycaster.setFromCamera(r,this.camera);const u=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(u){if(this.pointEnd.copy(u.point).sub(this.worldPositionStart),i==="translate")this.offset.copy(this.pointEnd).sub(this.pointStart),l==="local"&&s!=="XYZ"&&this.offset.applyQuaternion(this.worldQuaternionInv),s.indexOf("X")===-1&&(this.offset.x=0),s.indexOf("Y")===-1&&(this.offset.y=0),s.indexOf("Z")===-1&&(this.offset.z=0),l==="local"&&s!=="XYZ"?this.offset.applyQuaternion(this.quaternionStart).divide(this.parentScale):this.offset.applyQuaternion(this.parentQuaternionInv).divide(this.parentScale),a.position.copy(this.offset).add(this.positionStart),this.translationSnap&&(l==="local"&&(a.position.applyQuaternion(this.tempQuaternion.copy(this.quaternionStart).invert()),s.search("X")!==-1&&(a.position.x=Math.round(a.position.x/this.translationSnap)*this.translationSnap),s.search("Y")!==-1&&(a.position.y=Math.round(a.position.y/this.translationSnap)*this.translationSnap),s.search("Z")!==-1&&(a.position.z=Math.round(a.position.z/this.translationSnap)*this.translationSnap),a.position.applyQuaternion(this.quaternionStart)),l==="world"&&(a.parent&&a.position.add(this.tempVector.setFromMatrixPosition(a.parent.matrixWorld)),s.search("X")!==-1&&(a.position.x=Math.round(a.position.x/this.translationSnap)*this.translationSnap),s.search("Y")!==-1&&(a.position.y=Math.round(a.position.y/this.translationSnap)*this.translationSnap),s.search("Z")!==-1&&(a.position.z=Math.round(a.position.z/this.translationSnap)*this.translationSnap),a.parent&&a.position.sub(this.tempVector.setFromMatrixPosition(a.parent.matrixWorld))));else if(i==="scale"){if(s.search("XYZ")!==-1){let h=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(h*=-1),this.tempVector2.set(h,h,h)}else this.tempVector.copy(this.pointStart),this.tempVector2.copy(this.pointEnd),this.tempVector.applyQuaternion(this.worldQuaternionInv),this.tempVector2.applyQuaternion(this.worldQuaternionInv),this.tempVector2.divide(this.tempVector),s.search("X")===-1&&(this.tempVector2.x=1),s.search("Y")===-1&&(this.tempVector2.y=1),s.search("Z")===-1&&(this.tempVector2.z=1);a.scale.copy(this.scaleStart).multiply(this.tempVector2),this.scaleSnap&&this.object&&(s.search("X")!==-1&&(this.object.scale.x=Math.round(a.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),s.search("Y")!==-1&&(a.scale.y=Math.round(a.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),s.search("Z")!==-1&&(a.scale.z=Math.round(a.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(i==="rotate"){this.offset.copy(this.pointEnd).sub(this.pointStart);const h=20/this.worldPosition.distanceTo(this.tempVector.setFromMatrixPosition(this.camera.matrixWorld));s==="E"?(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this.startNorm.copy(this.pointStart).normalize(),this.endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this.endNorm.cross(this.startNorm).dot(this.eye)<0?1:-1):s==="XYZE"?(this.rotationAxis.copy(this.offset).cross(this.eye).normalize(),this.rotationAngle=this.offset.dot(this.tempVector.copy(this.rotationAxis).cross(this.eye))*h):(s==="X"||s==="Y"||s==="Z")&&(this.rotationAxis.copy(this.unit[s]),this.tempVector.copy(this.unit[s]),l==="local"&&this.tempVector.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.offset.dot(this.tempVector.cross(this.eye).normalize())*h),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),l==="local"&&s!=="E"&&s!=="XYZE"?(a.quaternion.copy(this.quaternionStart),a.quaternion.multiply(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this.parentQuaternionInv),a.quaternion.copy(this.tempQuaternion.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),a.quaternion.multiply(this.quaternionStart).normalize())}this.dispatchEvent(this.changeEvent),this.dispatchEvent(this.objectChangeEvent)}}),H(this,"pointerUp",r=>{r.button===0&&(this.dragging&&this.axis!==null&&(this.mouseUpEvent.mode=this.mode,this.dispatchEvent(this.mouseUpEvent)),this.dragging=!1,this.axis=null)}),H(this,"getPointer",r=>{var s;if(this.domElement&&((s=this.domElement.ownerDocument)!=null&&s.pointerLockElement))return{x:0,y:0,button:r.button};{const i=r.changedTouches?r.changedTouches[0]:r,a=this.domElement.getBoundingClientRect();return{x:(i.clientX-a.left)/a.width*2-1,y:-(i.clientY-a.top)/a.height*2+1,button:r.button}}}),H(this,"onPointerHover",r=>{if(this.enabled)switch(r.pointerType){case"mouse":case"pen":this.pointerHover(this.getPointer(r));break}}),H(this,"onPointerDown",r=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="none",this.domElement.ownerDocument.addEventListener("pointermove",this.onPointerMove),this.pointerHover(this.getPointer(r)),this.pointerDown(this.getPointer(r)))}),H(this,"onPointerMove",r=>{this.enabled&&this.pointerMove(this.getPointer(r))}),H(this,"onPointerUp",r=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="",this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.pointerUp(this.getPointer(r)))}),H(this,"getMode",()=>this.mode),H(this,"setMode",r=>{this.mode=r}),H(this,"setTranslationSnap",r=>{this.translationSnap=r}),H(this,"setRotationSnap",r=>{this.rotationSnap=r}),H(this,"setScaleSnap",r=>{this.scaleSnap=r}),H(this,"setSize",r=>{this.size=r}),H(this,"setSpace",r=>{this.space=r}),H(this,"update",()=>{console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}),H(this,"connect",r=>{r===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.domElement=r,this.domElement.addEventListener("pointerdown",this.onPointerDown),this.domElement.addEventListener("pointermove",this.onPointerHover),this.domElement.ownerDocument.addEventListener("pointerup",this.onPointerUp)}),H(this,"dispose",()=>{var r,s,i,a,l,u;(r=this.domElement)==null||r.removeEventListener("pointerdown",this.onPointerDown),(s=this.domElement)==null||s.removeEventListener("pointermove",this.onPointerHover),(a=(i=this.domElement)==null?void 0:i.ownerDocument)==null||a.removeEventListener("pointermove",this.onPointerMove),(u=(l=this.domElement)==null?void 0:l.ownerDocument)==null||u.removeEventListener("pointerup",this.onPointerUp),this.traverse(h=>{const d=h;d.geometry&&d.geometry.dispose(),d.material&&d.material.dispose()})}),this.domElement=t,this.camera=e,this.gizmo=new Bo,this.add(this.gizmo),this.plane=new Fo,this.add(this.plane);const n=(r,s)=>{let i=s;Object.defineProperty(this,r,{get:function(){return i!==void 0?i:s},set:function(a){i!==a&&(i=a,this.plane[r]=a,this.gizmo[r]=a,this.dispatchEvent({type:r+"-changed",value:a}),this.dispatchEvent(this.changeEvent))}}),this[r]=s,this.plane[r]=s,this.gizmo[r]=s};n("camera",this.camera),n("object",this.object),n("enabled",this.enabled),n("axis",this.axis),n("mode",this.mode),n("translationSnap",this.translationSnap),n("rotationSnap",this.rotationSnap),n("scaleSnap",this.scaleSnap),n("space",this.space),n("size",this.size),n("dragging",this.dragging),n("showX",this.showX),n("showY",this.showY),n("showZ",this.showZ),n("worldPosition",this.worldPosition),n("worldPositionStart",this.worldPositionStart),n("worldQuaternion",this.worldQuaternion),n("worldQuaternionStart",this.worldQuaternionStart),n("cameraPosition",this.cameraPosition),n("cameraQuaternion",this.cameraQuaternion),n("pointStart",this.pointStart),n("pointEnd",this.pointEnd),n("rotationAxis",this.rotationAxis),n("rotationAngle",this.rotationAngle),n("eye",this.eye),t!==void 0&&this.connect(t)}}class Bo extends c.Object3D{constructor(){super(),H(this,"isTransformControlsGizmo",!0),H(this,"type","TransformControlsGizmo"),H(this,"tempVector",new c.Vector3(0,0,0)),H(this,"tempEuler",new c.Euler),H(this,"alignVector",new c.Vector3(0,1,0)),H(this,"zeroVector",new c.Vector3(0,0,0)),H(this,"lookAtMatrix",new c.Matrix4),H(this,"tempQuaternion",new c.Quaternion),H(this,"tempQuaternion2",new c.Quaternion),H(this,"identityQuaternion",new c.Quaternion),H(this,"unitX",new c.Vector3(1,0,0)),H(this,"unitY",new c.Vector3(0,1,0)),H(this,"unitZ",new c.Vector3(0,0,1)),H(this,"gizmo"),H(this,"picker"),H(this,"helper"),H(this,"rotationAxis",new c.Vector3),H(this,"cameraPosition",new c.Vector3),H(this,"worldPositionStart",new c.Vector3),H(this,"worldQuaternionStart",new c.Quaternion),H(this,"worldPosition",new c.Vector3),H(this,"worldQuaternion",new c.Quaternion),H(this,"eye",new c.Vector3),H(this,"camera",null),H(this,"enabled",!0),H(this,"axis",null),H(this,"mode","translate"),H(this,"space","world"),H(this,"size",1),H(this,"dragging",!1),H(this,"showX",!0),H(this,"showY",!0),H(this,"showZ",!0),H(this,"updateMatrixWorld",()=>{let re=this.space;this.mode==="scale"&&(re="local");const ce=re==="local"?this.worldQuaternion:this.identityQuaternion;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let j=[];j=j.concat(this.picker[this.mode].children),j=j.concat(this.gizmo[this.mode].children),j=j.concat(this.helper[this.mode].children);for(let z=0;z<j.length;z++){const P=j[z];P.visible=!0,P.rotation.set(0,0,0),P.position.copy(this.worldPosition);let V;if(this.camera.isOrthographicCamera?V=(this.camera.top-this.camera.bottom)/this.camera.zoom:V=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),P.scale.set(1,1,1).multiplyScalar(V*this.size/7),P.tag==="helper"){P.visible=!1,P.name==="AXIS"?(P.position.copy(this.worldPositionStart),P.visible=!!this.axis,this.axis==="X"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,0)),P.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))>.9&&(P.visible=!1)),this.axis==="Y"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),P.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))>.9&&(P.visible=!1)),this.axis==="Z"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),P.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))>.9&&(P.visible=!1)),this.axis==="XYZE"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),P.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),P.quaternion.multiply(this.tempQuaternion),P.visible=this.dragging),this.axis==="E"&&(P.visible=!1)):P.name==="START"?(P.position.copy(this.worldPositionStart),P.visible=this.dragging):P.name==="END"?(P.position.copy(this.worldPosition),P.visible=this.dragging):P.name==="DELTA"?(P.position.copy(this.worldPositionStart),P.quaternion.copy(this.worldQuaternionStart),this.tempVector.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),this.tempVector.applyQuaternion(this.worldQuaternionStart.clone().invert()),P.scale.copy(this.tempVector),P.visible=this.dragging):(P.quaternion.copy(ce),this.dragging?P.position.copy(this.worldPositionStart):P.position.copy(this.worldPosition),this.axis&&(P.visible=this.axis.search(P.name)!==-1));continue}P.quaternion.copy(ce),this.mode==="translate"||this.mode==="scale"?((P.name==="X"||P.name==="XYZX")&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))>.99&&(P.scale.set(1e-10,1e-10,1e-10),P.visible=!1),(P.name==="Y"||P.name==="XYZY")&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))>.99&&(P.scale.set(1e-10,1e-10,1e-10),P.visible=!1),(P.name==="Z"||P.name==="XYZZ")&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))>.99&&(P.scale.set(1e-10,1e-10,1e-10),P.visible=!1),P.name==="XY"&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))<.2&&(P.scale.set(1e-10,1e-10,1e-10),P.visible=!1),P.name==="YZ"&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))<.2&&(P.scale.set(1e-10,1e-10,1e-10),P.visible=!1),P.name==="XZ"&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))<.2&&(P.scale.set(1e-10,1e-10,1e-10),P.visible=!1),P.name.search("X")!==-1&&(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye)<0?P.tag==="fwd"?P.visible=!1:P.scale.x*=-1:P.tag==="bwd"&&(P.visible=!1)),P.name.search("Y")!==-1&&(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye)<0?P.tag==="fwd"?P.visible=!1:P.scale.y*=-1:P.tag==="bwd"&&(P.visible=!1)),P.name.search("Z")!==-1&&(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye)<0?P.tag==="fwd"?P.visible=!1:P.scale.z*=-1:P.tag==="bwd"&&(P.visible=!1))):this.mode==="rotate"&&(this.tempQuaternion2.copy(ce),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(ce).invert()),P.name.search("E")!==-1&&P.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),P.name==="X"&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),P.quaternion.copy(this.tempQuaternion)),P.name==="Y"&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),P.quaternion.copy(this.tempQuaternion)),P.name==="Z"&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),P.quaternion.copy(this.tempQuaternion))),P.visible=P.visible&&(P.name.indexOf("X")===-1||this.showX),P.visible=P.visible&&(P.name.indexOf("Y")===-1||this.showY),P.visible=P.visible&&(P.name.indexOf("Z")===-1||this.showZ),P.visible=P.visible&&(P.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),P.material.tempOpacity=P.material.tempOpacity||P.material.opacity,P.material.tempColor=P.material.tempColor||P.material.color.clone(),P.material.color.copy(P.material.tempColor),P.material.opacity=P.material.tempOpacity,this.enabled?this.axis&&(P.name===this.axis?(P.material.opacity=1,P.material.color.lerp(new c.Color(1,1,1),.5)):this.axis.split("").some(function(ee){return P.name===ee})?(P.material.opacity=1,P.material.color.lerp(new c.Color(1,1,1),.5)):(P.material.opacity*=.25,P.material.color.lerp(new c.Color(1,1,1),.5))):(P.material.opacity*=.5,P.material.color.lerp(new c.Color(1,1,1),.5))}super.updateMatrixWorld()});const e=new c.MeshBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,side:c.DoubleSide,fog:!1,toneMapped:!1}),t=new c.LineBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,linewidth:1,fog:!1,toneMapped:!1}),n=e.clone();n.opacity=.15;const r=e.clone();r.opacity=.33;const s=e.clone();s.color.set(16711680);const i=e.clone();i.color.set(65280);const a=e.clone();a.color.set(255);const l=e.clone();l.opacity=.25;const u=l.clone();u.color.set(16776960);const h=l.clone();h.color.set(65535);const d=l.clone();d.color.set(16711935),e.clone().color.set(16776960);const y=t.clone();y.color.set(16711680);const x=t.clone();x.color.set(65280);const w=t.clone();w.color.set(255);const v=t.clone();v.color.set(65535);const A=t.clone();A.color.set(16711935);const D=t.clone();D.color.set(16776960);const M=t.clone();M.color.set(7895160);const _=D.clone();_.opacity=.25;const L=new c.CylinderGeometry(0,.05,.2,12,1,!1),b=new c.BoxGeometry(.125,.125,.125),C=new c.BufferGeometry;C.setAttribute("position",new c.Float32BufferAttribute([0,0,0,1,0,0],3));const m=(re,ce)=>{const j=new c.BufferGeometry,z=[];for(let P=0;P<=64*ce;++P)z.push(0,Math.cos(P/32*Math.PI)*re,Math.sin(P/32*Math.PI)*re);return j.setAttribute("position",new c.Float32BufferAttribute(z,3)),j},S=()=>{const re=new c.BufferGeometry;return re.setAttribute("position",new c.Float32BufferAttribute([0,0,0,1,1,1],3)),re},p={X:[[new c.Mesh(L,s),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new c.Mesh(L,s),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new c.Line(C,y)]],Y:[[new c.Mesh(L,i),[0,1,0],null,null,"fwd"],[new c.Mesh(L,i),[0,1,0],[Math.PI,0,0],null,"bwd"],[new c.Line(C,x),null,[0,0,Math.PI/2]]],Z:[[new c.Mesh(L,a),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new c.Mesh(L,a),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new c.Line(C,w),null,[0,-Math.PI/2,0]]],XYZ:[[new c.Mesh(new c.OctahedronGeometry(.1,0),l.clone()),[0,0,0],[0,0,0]]],XY:[[new c.Mesh(new c.PlaneGeometry(.295,.295),u.clone()),[.15,.15,0]],[new c.Line(C,D),[.18,.3,0],null,[.125,1,1]],[new c.Line(C,D),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new c.Mesh(new c.PlaneGeometry(.295,.295),h.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new c.Line(C,v),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new c.Line(C,v),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new c.Mesh(new c.PlaneGeometry(.295,.295),d.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new c.Line(C,A),[.18,0,.3],null,[.125,1,1]],[new c.Line(C,A),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},I={X:[[new c.Mesh(new c.CylinderGeometry(.2,0,1,4,1,!1),n),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new c.Mesh(new c.CylinderGeometry(.2,0,1,4,1,!1),n),[0,.6,0]]],Z:[[new c.Mesh(new c.CylinderGeometry(.2,0,1,4,1,!1),n),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new c.Mesh(new c.OctahedronGeometry(.2,0),n)]],XY:[[new c.Mesh(new c.PlaneGeometry(.4,.4),n),[.2,.2,0]]],YZ:[[new c.Mesh(new c.PlaneGeometry(.4,.4),n),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new c.Mesh(new c.PlaneGeometry(.4,.4),n),[.2,0,.2],[-Math.PI/2,0,0]]]},k={START:[[new c.Mesh(new c.OctahedronGeometry(.01,2),r),null,null,null,"helper"]],END:[[new c.Mesh(new c.OctahedronGeometry(.01,2),r),null,null,null,"helper"]],DELTA:[[new c.Line(S(),r),null,null,null,"helper"]],X:[[new c.Line(C,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new c.Line(C,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new c.Line(C,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},J={X:[[new c.Line(m(1,.5),y)],[new c.Mesh(new c.OctahedronGeometry(.04,0),s),[0,0,.99],null,[1,3,1]]],Y:[[new c.Line(m(1,.5),x),null,[0,0,-Math.PI/2]],[new c.Mesh(new c.OctahedronGeometry(.04,0),i),[0,0,.99],null,[3,1,1]]],Z:[[new c.Line(m(1,.5),w),null,[0,Math.PI/2,0]],[new c.Mesh(new c.OctahedronGeometry(.04,0),a),[.99,0,0],null,[1,3,1]]],E:[[new c.Line(m(1.25,1),_),null,[0,Math.PI/2,0]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),_),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),_),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),_),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new c.Mesh(new c.CylinderGeometry(.03,0,.15,4,1,!1),_),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new c.Line(m(1,1),M),null,[0,Math.PI/2,0]]]},R={AXIS:[[new c.Line(C,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},Z={X:[[new c.Mesh(new c.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new c.Mesh(new c.TorusGeometry(1,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new c.Mesh(new c.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new c.Mesh(new c.TorusGeometry(1.25,.1,2,24),n)]],XYZE:[[new c.Mesh(new c.SphereGeometry(.7,10,8),n)]]},X={X:[[new c.Mesh(b,s),[.8,0,0],[0,0,-Math.PI/2]],[new c.Line(C,y),null,null,[.8,1,1]]],Y:[[new c.Mesh(b,i),[0,.8,0]],[new c.Line(C,x),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new c.Mesh(b,a),[0,0,.8],[Math.PI/2,0,0]],[new c.Line(C,w),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new c.Mesh(b,u),[.85,.85,0],null,[2,2,.2]],[new c.Line(C,D),[.855,.98,0],null,[.125,1,1]],[new c.Line(C,D),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new c.Mesh(b,h),[0,.85,.85],null,[.2,2,2]],[new c.Line(C,v),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new c.Line(C,v),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new c.Mesh(b,d),[.85,0,.85],null,[2,.2,2]],[new c.Line(C,A),[.855,0,.98],null,[.125,1,1]],[new c.Line(C,A),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new c.Mesh(new c.BoxGeometry(.125,.125,.125),l.clone()),[1.1,0,0]]],XYZY:[[new c.Mesh(new c.BoxGeometry(.125,.125,.125),l.clone()),[0,1.1,0]]],XYZZ:[[new c.Mesh(new c.BoxGeometry(.125,.125,.125),l.clone()),[0,0,1.1]]]},q={X:[[new c.Mesh(new c.CylinderGeometry(.2,0,.8,4,1,!1),n),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new c.Mesh(new c.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,.5,0]]],Z:[[new c.Mesh(new c.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new c.Mesh(b,n),[.85,.85,0],null,[3,3,.2]]],YZ:[[new c.Mesh(b,n),[0,.85,.85],null,[.2,3,3]]],XZ:[[new c.Mesh(b,n),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new c.Mesh(new c.BoxGeometry(.2,.2,.2),n),[1.1,0,0]]],XYZY:[[new c.Mesh(new c.BoxGeometry(.2,.2,.2),n),[0,1.1,0]]],XYZZ:[[new c.Mesh(new c.BoxGeometry(.2,.2,.2),n),[0,0,1.1]]]},Y={X:[[new c.Line(C,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new c.Line(C,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new c.Line(C,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},te=re=>{const ce=new c.Object3D;for(let j in re)for(let z=re[j].length;z--;){const P=re[j][z][0].clone(),V=re[j][z][1],ee=re[j][z][2],N=re[j][z][3],G=re[j][z][4];P.name=j,P.tag=G,V&&P.position.set(V[0],V[1],V[2]),ee&&P.rotation.set(ee[0],ee[1],ee[2]),N&&P.scale.set(N[0],N[1],N[2]),P.updateMatrix();const T=P.geometry.clone();T.applyMatrix4(P.matrix),P.geometry=T,P.renderOrder=1/0,P.position.set(0,0,0),P.rotation.set(0,0,0),P.scale.set(1,1,1),ce.add(P)}return ce};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=te(p)),this.add(this.gizmo.rotate=te(J)),this.add(this.gizmo.scale=te(X)),this.add(this.picker.translate=te(I)),this.add(this.picker.rotate=te(Z)),this.add(this.picker.scale=te(q)),this.add(this.helper.translate=te(k)),this.add(this.helper.rotate=te(R)),this.add(this.helper.scale=te(Y)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}}class Fo extends c.Mesh{constructor(){super(new c.PlaneGeometry(1e5,1e5,2,2),new c.MeshBasicMaterial({visible:!1,wireframe:!0,side:c.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),H(this,"isTransformControlsPlane",!0),H(this,"type","TransformControlsPlane"),H(this,"unitX",new c.Vector3(1,0,0)),H(this,"unitY",new c.Vector3(0,1,0)),H(this,"unitZ",new c.Vector3(0,0,1)),H(this,"tempVector",new c.Vector3),H(this,"dirVector",new c.Vector3),H(this,"alignVector",new c.Vector3),H(this,"tempMatrix",new c.Matrix4),H(this,"identityQuaternion",new c.Quaternion),H(this,"cameraQuaternion",new c.Quaternion),H(this,"worldPosition",new c.Vector3),H(this,"worldQuaternion",new c.Quaternion),H(this,"eye",new c.Vector3),H(this,"axis",null),H(this,"mode","translate"),H(this,"space","world"),H(this,"updateMatrixWorld",()=>{let e=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(e="local"),this.unitX.set(1,0,0).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.unitY.set(0,1,0).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.unitZ.set(0,0,1).applyQuaternion(e==="local"?this.worldQuaternion:this.identityQuaternion),this.alignVector.copy(this.unitY),this.mode){case"translate":case"scale":switch(this.axis){case"X":this.alignVector.copy(this.eye).cross(this.unitX),this.dirVector.copy(this.unitX).cross(this.alignVector);break;case"Y":this.alignVector.copy(this.eye).cross(this.unitY),this.dirVector.copy(this.unitY).cross(this.alignVector);break;case"Z":this.alignVector.copy(this.eye).cross(this.unitZ),this.dirVector.copy(this.unitZ).cross(this.alignVector);break;case"XY":this.dirVector.copy(this.unitZ);break;case"YZ":this.dirVector.copy(this.unitX);break;case"XZ":this.alignVector.copy(this.unitZ),this.dirVector.copy(this.unitY);break;case"XYZ":case"E":this.dirVector.set(0,0,0);break}break;case"rotate":default:this.dirVector.set(0,0,0)}this.dirVector.length()===0?this.quaternion.copy(this.cameraQuaternion):(this.tempMatrix.lookAt(this.tempVector.set(0,0,0),this.dirVector,this.alignVector),this.quaternion.setFromRotationMatrix(this.tempMatrix)),super.updateMatrixWorld()})}}var Uo=Object.defineProperty,No=(o,e,t)=>e in o?Uo(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,Ie=(o,e,t)=>(No(o,typeof e!="symbol"?e+"":e,t),t);const Dt=new c.Euler(0,0,0,"YXZ"),It=new c.Vector3,zo={type:"change"},Vo={type:"lock"},Ro={type:"unlock"},ns=Math.PI/2;class Kn extends c.EventDispatcher{constructor(e,t){super(),Ie(this,"camera"),Ie(this,"domElement"),Ie(this,"isLocked"),Ie(this,"minPolarAngle"),Ie(this,"maxPolarAngle"),Ie(this,"pointerSpeed"),Ie(this,"onMouseMove",n=>{if(!this.domElement||this.isLocked===!1)return;const r=n.movementX||n.mozMovementX||n.webkitMovementX||0,s=n.movementY||n.mozMovementY||n.webkitMovementY||0;Dt.setFromQuaternion(this.camera.quaternion),Dt.y-=r*.002*this.pointerSpeed,Dt.x-=s*.002*this.pointerSpeed,Dt.x=Math.max(ns-this.maxPolarAngle,Math.min(ns-this.minPolarAngle,Dt.x)),this.camera.quaternion.setFromEuler(Dt),this.dispatchEvent(zo)}),Ie(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(Vo),this.isLocked=!0):(this.dispatchEvent(Ro),this.isLocked=!1))}),Ie(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),Ie(this,"connect",n=>{this.domElement=n||this.domElement,this.domElement&&(this.domElement.ownerDocument.addEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.addEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.addEventListener("pointerlockerror",this.onPointerlockError))}),Ie(this,"disconnect",()=>{this.domElement&&(this.domElement.ownerDocument.removeEventListener("mousemove",this.onMouseMove),this.domElement.ownerDocument.removeEventListener("pointerlockchange",this.onPointerlockChange),this.domElement.ownerDocument.removeEventListener("pointerlockerror",this.onPointerlockError))}),Ie(this,"dispose",()=>{this.disconnect()}),Ie(this,"getObject",()=>this.camera),Ie(this,"direction",new c.Vector3(0,0,-1)),Ie(this,"getDirection",n=>n.copy(this.direction).applyQuaternion(this.camera.quaternion)),Ie(this,"moveForward",n=>{It.setFromMatrixColumn(this.camera.matrix,0),It.crossVectors(this.camera.up,It),this.camera.position.addScaledVector(It,n)}),Ie(this,"moveRight",n=>{It.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(It,n)}),Ie(this,"lock",()=>{this.domElement&&this.domElement.requestPointerLock()}),Ie(this,"unlock",()=>{this.domElement&&this.domElement.ownerDocument.exitPointerLock()}),this.camera=e,this.domElement=t,this.isLocked=!1,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.pointerSpeed=1,t&&this.connect(t)}}var Go=Object.defineProperty,jo=(o,e,t)=>e in o?Go(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,fe=(o,e,t)=>(jo(o,typeof e!="symbol"?e+"":e,t),t);const gn=new c.Ray,rs=new c.Plane,Eo=Math.cos(70*(Math.PI/180)),ss=(o,e)=>(o%e+e)%e;class is extends c.EventDispatcher{constructor(e,t){super(),fe(this,"object"),fe(this,"domElement"),fe(this,"enabled",!0),fe(this,"target",new c.Vector3),fe(this,"minDistance",0),fe(this,"maxDistance",1/0),fe(this,"minZoom",0),fe(this,"maxZoom",1/0),fe(this,"minPolarAngle",0),fe(this,"maxPolarAngle",Math.PI),fe(this,"minAzimuthAngle",-1/0),fe(this,"maxAzimuthAngle",1/0),fe(this,"enableDamping",!1),fe(this,"dampingFactor",.05),fe(this,"enableZoom",!0),fe(this,"zoomSpeed",1),fe(this,"enableRotate",!0),fe(this,"rotateSpeed",1),fe(this,"enablePan",!0),fe(this,"panSpeed",1),fe(this,"screenSpacePanning",!0),fe(this,"keyPanSpeed",7),fe(this,"zoomToCursor",!1),fe(this,"autoRotate",!1),fe(this,"autoRotateSpeed",2),fe(this,"reverseOrbit",!1),fe(this,"reverseHorizontalOrbit",!1),fe(this,"reverseVerticalOrbit",!1),fe(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),fe(this,"mouseButtons",{LEFT:c.MOUSE.ROTATE,MIDDLE:c.MOUSE.DOLLY,RIGHT:c.MOUSE.PAN}),fe(this,"touches",{ONE:c.TOUCH.ROTATE,TWO:c.TOUCH.DOLLY_PAN}),fe(this,"target0"),fe(this,"position0"),fe(this,"zoom0"),fe(this,"_domElementKeyEvents",null),fe(this,"getPolarAngle"),fe(this,"getAzimuthalAngle"),fe(this,"setPolarAngle"),fe(this,"setAzimuthalAngle"),fe(this,"getDistance"),fe(this,"listenToKeyEvents"),fe(this,"stopListenToKeyEvents"),fe(this,"saveState"),fe(this,"reset"),fe(this,"update"),fe(this,"connect"),fe(this,"dispose"),this.object=e,this.domElement=t,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>h.phi,this.getAzimuthalAngle=()=>h.theta,this.setPolarAngle=W=>{let ie=ss(W,2*Math.PI),me=h.phi;me<0&&(me+=2*Math.PI),ie<0&&(ie+=2*Math.PI);let Se=Math.abs(ie-me);2*Math.PI-Se<Se&&(ie<me?ie+=2*Math.PI:me+=2*Math.PI),d.phi=ie-me,n.update()},this.setAzimuthalAngle=W=>{let ie=ss(W,2*Math.PI),me=h.theta;me<0&&(me+=2*Math.PI),ie<0&&(ie+=2*Math.PI);let Se=Math.abs(ie-me);2*Math.PI-Se<Se&&(ie<me?ie+=2*Math.PI:me+=2*Math.PI),d.theta=ie-me,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=W=>{W.addEventListener("keydown",jt),this._domElementKeyEvents=W},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",jt),this._domElementKeyEvents=null},this.saveState=()=>{n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=()=>{n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(r),n.update(),l=a.NONE},this.update=(()=>{const W=new c.Vector3,ie=new c.Vector3(0,1,0),me=new c.Quaternion().setFromUnitVectors(e.up,ie),Se=me.clone().invert(),ke=new c.Vector3,ct=new c.Quaternion,wt=2*Math.PI;return function(){const Ei=n.object.position;me.setFromUnitVectors(e.up,ie),Se.copy(me).invert(),W.copy(Ei).sub(n.target),W.applyQuaternion(me),h.setFromVector3(W),n.autoRotate&&l===a.NONE&&R(k()),n.enableDamping?(h.theta+=d.theta*n.dampingFactor,h.phi+=d.phi*n.dampingFactor):(h.theta+=d.theta,h.phi+=d.phi);let ut=n.minAzimuthAngle,ht=n.maxAzimuthAngle;isFinite(ut)&&isFinite(ht)&&(ut<-Math.PI?ut+=wt:ut>Math.PI&&(ut-=wt),ht<-Math.PI?ht+=wt:ht>Math.PI&&(ht-=wt),ut<=ht?h.theta=Math.max(ut,Math.min(ht,h.theta)):h.theta=h.theta>(ut+ht)/2?Math.max(ut,h.theta):Math.min(ht,h.theta)),h.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,h.phi)),h.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(y,n.dampingFactor):n.target.add(y),n.zoomToCursor&&S||n.object.isOrthographicCamera?h.radius=j(h.radius):h.radius=j(h.radius*g),W.setFromSpherical(h),W.applyQuaternion(Se),Ei.copy(n.target).add(W),n.object.matrixAutoUpdate||n.object.updateMatrix(),n.object.lookAt(n.target),n.enableDamping===!0?(d.theta*=1-n.dampingFactor,d.phi*=1-n.dampingFactor,y.multiplyScalar(1-n.dampingFactor)):(d.set(0,0,0),y.set(0,0,0));let un=!1;if(n.zoomToCursor&&S){let hn=null;if(n.object instanceof c.PerspectiveCamera&&n.object.isPerspectiveCamera){const fn=W.length();hn=j(fn*g);const Nn=fn-hn;n.object.position.addScaledVector(C,Nn),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const fn=new c.Vector3(m.x,m.y,0);fn.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/g)),n.object.updateProjectionMatrix(),un=!0;const Nn=new c.Vector3(m.x,m.y,0);Nn.unproject(n.object),n.object.position.sub(Nn).add(fn),n.object.updateMatrixWorld(),hn=W.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;hn!==null&&(n.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(hn).add(n.object.position):(gn.origin.copy(n.object.position),gn.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(gn.direction))<Eo?e.lookAt(n.target):(rs.setFromNormalAndCoplanarPoint(n.object.up,n.target),gn.intersectPlane(rs,n.target))))}else n.object instanceof c.OrthographicCamera&&n.object.isOrthographicCamera&&(un=g!==1,un&&(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/g)),n.object.updateProjectionMatrix()));return g=1,S=!1,un||ke.distanceToSquared(n.object.position)>u||8*(1-ct.dot(n.object.quaternion))>u?(n.dispatchEvent(r),ke.copy(n.object.position),ct.copy(n.object.quaternion),un=!1,!0):!1}})(),this.connect=W=>{W===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),n.domElement=W,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",Ri),n.domElement.addEventListener("pointerdown",_e),n.domElement.addEventListener("pointercancel",lt),n.domElement.addEventListener("wheel",qe)},this.dispose=()=>{var W,ie,me,Se,ke,ct;(W=n.domElement)==null||W.removeEventListener("contextmenu",Ri),(ie=n.domElement)==null||ie.removeEventListener("pointerdown",_e),(me=n.domElement)==null||me.removeEventListener("pointercancel",lt),(Se=n.domElement)==null||Se.removeEventListener("wheel",qe),(ke=n.domElement)==null||ke.ownerDocument.removeEventListener("pointermove",xe),(ct=n.domElement)==null||ct.ownerDocument.removeEventListener("pointerup",Oe),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",jt)};const n=this,r={type:"change"},s={type:"start"},i={type:"end"},a={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let l=a.NONE;const u=1e-6,h=new c.Spherical,d=new c.Spherical;let g=1;const y=new c.Vector3,x=new c.Vector2,w=new c.Vector2,v=new c.Vector2,A=new c.Vector2,D=new c.Vector2,M=new c.Vector2,_=new c.Vector2,L=new c.Vector2,b=new c.Vector2,C=new c.Vector3,m=new c.Vector2;let S=!1;const p=[],I={};function k(){return 2*Math.PI/60/60*n.autoRotateSpeed}function J(){return Math.pow(.95,n.zoomSpeed)}function R(W){n.reverseOrbit||n.reverseHorizontalOrbit?d.theta+=W:d.theta-=W}function Z(W){n.reverseOrbit||n.reverseVerticalOrbit?d.phi+=W:d.phi-=W}const X=(()=>{const W=new c.Vector3;return function(me,Se){W.setFromMatrixColumn(Se,0),W.multiplyScalar(-me),y.add(W)}})(),q=(()=>{const W=new c.Vector3;return function(me,Se){n.screenSpacePanning===!0?W.setFromMatrixColumn(Se,1):(W.setFromMatrixColumn(Se,0),W.crossVectors(n.object.up,W)),W.multiplyScalar(me),y.add(W)}})(),Y=(()=>{const W=new c.Vector3;return function(me,Se){const ke=n.domElement;if(ke&&n.object instanceof c.PerspectiveCamera&&n.object.isPerspectiveCamera){const ct=n.object.position;W.copy(ct).sub(n.target);let wt=W.length();wt*=Math.tan(n.object.fov/2*Math.PI/180),X(2*me*wt/ke.clientHeight,n.object.matrix),q(2*Se*wt/ke.clientHeight,n.object.matrix)}else ke&&n.object instanceof c.OrthographicCamera&&n.object.isOrthographicCamera?(X(me*(n.object.right-n.object.left)/n.object.zoom/ke.clientWidth,n.object.matrix),q(Se*(n.object.top-n.object.bottom)/n.object.zoom/ke.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function te(W){n.object instanceof c.PerspectiveCamera&&n.object.isPerspectiveCamera||n.object instanceof c.OrthographicCamera&&n.object.isOrthographicCamera?g/=W:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function re(W){n.object instanceof c.PerspectiveCamera&&n.object.isPerspectiveCamera||n.object instanceof c.OrthographicCamera&&n.object.isOrthographicCamera?g*=W:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ce(W){if(!n.zoomToCursor||!n.domElement)return;S=!0;const ie=n.domElement.getBoundingClientRect(),me=W.clientX-ie.left,Se=W.clientY-ie.top,ke=ie.width,ct=ie.height;m.x=me/ke*2-1,m.y=-(Se/ct)*2+1,C.set(m.x,m.y,1).unproject(n.object).sub(n.object.position).normalize()}function j(W){return Math.max(n.minDistance,Math.min(n.maxDistance,W))}function z(W){x.set(W.clientX,W.clientY)}function P(W){ce(W),_.set(W.clientX,W.clientY)}function V(W){A.set(W.clientX,W.clientY)}function ee(W){w.set(W.clientX,W.clientY),v.subVectors(w,x).multiplyScalar(n.rotateSpeed);const ie=n.domElement;ie&&(R(2*Math.PI*v.x/ie.clientHeight),Z(2*Math.PI*v.y/ie.clientHeight)),x.copy(w),n.update()}function N(W){L.set(W.clientX,W.clientY),b.subVectors(L,_),b.y>0?te(J()):b.y<0&&re(J()),_.copy(L),n.update()}function G(W){D.set(W.clientX,W.clientY),M.subVectors(D,A).multiplyScalar(n.panSpeed),Y(M.x,M.y),A.copy(D),n.update()}function T(W){ce(W),W.deltaY<0?re(J()):W.deltaY>0&&te(J()),n.update()}function O(W){let ie=!1;switch(W.code){case n.keys.UP:Y(0,n.keyPanSpeed),ie=!0;break;case n.keys.BOTTOM:Y(0,-n.keyPanSpeed),ie=!0;break;case n.keys.LEFT:Y(n.keyPanSpeed,0),ie=!0;break;case n.keys.RIGHT:Y(-n.keyPanSpeed,0),ie=!0;break}ie&&(W.preventDefault(),n.update())}function B(){if(p.length==1)x.set(p[0].pageX,p[0].pageY);else{const W=.5*(p[0].pageX+p[1].pageX),ie=.5*(p[0].pageY+p[1].pageY);x.set(W,ie)}}function E(){if(p.length==1)A.set(p[0].pageX,p[0].pageY);else{const W=.5*(p[0].pageX+p[1].pageX),ie=.5*(p[0].pageY+p[1].pageY);A.set(W,ie)}}function Q(){const W=p[0].pageX-p[1].pageX,ie=p[0].pageY-p[1].pageY,me=Math.sqrt(W*W+ie*ie);_.set(0,me)}function K(){n.enableZoom&&Q(),n.enablePan&&E()}function ne(){n.enableZoom&&Q(),n.enableRotate&&B()}function U(W){if(p.length==1)w.set(W.pageX,W.pageY);else{const me=zr(W),Se=.5*(W.pageX+me.x),ke=.5*(W.pageY+me.y);w.set(Se,ke)}v.subVectors(w,x).multiplyScalar(n.rotateSpeed);const ie=n.domElement;ie&&(R(2*Math.PI*v.x/ie.clientHeight),Z(2*Math.PI*v.y/ie.clientHeight)),x.copy(w)}function F(W){if(p.length==1)D.set(W.pageX,W.pageY);else{const ie=zr(W),me=.5*(W.pageX+ie.x),Se=.5*(W.pageY+ie.y);D.set(me,Se)}M.subVectors(D,A).multiplyScalar(n.panSpeed),Y(M.x,M.y),A.copy(D)}function oe(W){const ie=zr(W),me=W.pageX-ie.x,Se=W.pageY-ie.y,ke=Math.sqrt(me*me+Se*Se);L.set(0,ke),b.set(0,Math.pow(L.y/_.y,n.zoomSpeed)),te(b.y),_.copy(L)}function ue(W){n.enableZoom&&oe(W),n.enablePan&&F(W)}function ge(W){n.enableZoom&&oe(W),n.enableRotate&&U(W)}function _e(W){var ie,me;n.enabled!==!1&&(p.length===0&&((ie=n.domElement)==null||ie.ownerDocument.addEventListener("pointermove",xe),(me=n.domElement)==null||me.ownerDocument.addEventListener("pointerup",Oe)),cd(W),W.pointerType==="touch"?ad(W):cn(W))}function xe(W){n.enabled!==!1&&(W.pointerType==="touch"?ld(W):Gt(W))}function Oe(W){var ie,me,Se;Gi(W),p.length===0&&((ie=n.domElement)==null||ie.releasePointerCapture(W.pointerId),(me=n.domElement)==null||me.ownerDocument.removeEventListener("pointermove",xe),(Se=n.domElement)==null||Se.ownerDocument.removeEventListener("pointerup",Oe)),n.dispatchEvent(i),l=a.NONE}function lt(W){Gi(W)}function cn(W){let ie;switch(W.button){case 0:ie=n.mouseButtons.LEFT;break;case 1:ie=n.mouseButtons.MIDDLE;break;case 2:ie=n.mouseButtons.RIGHT;break;default:ie=-1}switch(ie){case c.MOUSE.DOLLY:if(n.enableZoom===!1)return;P(W),l=a.DOLLY;break;case c.MOUSE.ROTATE:if(W.ctrlKey||W.metaKey||W.shiftKey){if(n.enablePan===!1)return;V(W),l=a.PAN}else{if(n.enableRotate===!1)return;z(W),l=a.ROTATE}break;case c.MOUSE.PAN:if(W.ctrlKey||W.metaKey||W.shiftKey){if(n.enableRotate===!1)return;z(W),l=a.ROTATE}else{if(n.enablePan===!1)return;V(W),l=a.PAN}break;default:l=a.NONE}l!==a.NONE&&n.dispatchEvent(s)}function Gt(W){if(n.enabled!==!1)switch(l){case a.ROTATE:if(n.enableRotate===!1)return;ee(W);break;case a.DOLLY:if(n.enableZoom===!1)return;N(W);break;case a.PAN:if(n.enablePan===!1)return;G(W);break}}function qe(W){n.enabled===!1||n.enableZoom===!1||l!==a.NONE&&l!==a.ROTATE||(W.preventDefault(),n.dispatchEvent(s),T(W),n.dispatchEvent(i))}function jt(W){n.enabled===!1||n.enablePan===!1||O(W)}function ad(W){switch(ji(W),p.length){case 1:switch(n.touches.ONE){case c.TOUCH.ROTATE:if(n.enableRotate===!1)return;B(),l=a.TOUCH_ROTATE;break;case c.TOUCH.PAN:if(n.enablePan===!1)return;E(),l=a.TOUCH_PAN;break;default:l=a.NONE}break;case 2:switch(n.touches.TWO){case c.TOUCH.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;K(),l=a.TOUCH_DOLLY_PAN;break;case c.TOUCH.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;ne(),l=a.TOUCH_DOLLY_ROTATE;break;default:l=a.NONE}break;default:l=a.NONE}l!==a.NONE&&n.dispatchEvent(s)}function ld(W){switch(ji(W),l){case a.TOUCH_ROTATE:if(n.enableRotate===!1)return;U(W),n.update();break;case a.TOUCH_PAN:if(n.enablePan===!1)return;F(W),n.update();break;case a.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;ue(W),n.update();break;case a.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;ge(W),n.update();break;default:l=a.NONE}}function Ri(W){n.enabled!==!1&&W.preventDefault()}function cd(W){p.push(W)}function Gi(W){delete I[W.pointerId];for(let ie=0;ie<p.length;ie++)if(p[ie].pointerId==W.pointerId){p.splice(ie,1);return}}function ji(W){let ie=I[W.pointerId];ie===void 0&&(ie=new c.Vector2,I[W.pointerId]=ie),ie.set(W.pageX,W.pageY)}function zr(W){const ie=W.pointerId===p[0].pointerId?p[1]:p[0];return I[ie.pointerId]}t!==void 0&&this.connect(t),this.update()}}class Wo extends is{constructor(e,t){super(e,t),this.screenSpacePanning=!1,this.mouseButtons.LEFT=c.MOUSE.PAN,this.mouseButtons.RIGHT=c.MOUSE.ROTATE,this.touches.ONE=c.TOUCH.PAN,this.touches.TWO=c.TOUCH.DOLLY_ROTATE}}class Yo extends c.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Qo(t)}),this.register(function(t){return new sa(t)}),this.register(function(t){return new ia(t)}),this.register(function(t){return new oa(t)}),this.register(function(t){return new Ho(t)}),this.register(function(t){return new $o(t)}),this.register(function(t){return new ea(t)}),this.register(function(t){return new ta(t)}),this.register(function(t){return new qo(t)}),this.register(function(t){return new na(t)}),this.register(function(t){return new Jo(t)}),this.register(function(t){return new ra(t)}),this.register(function(t){return new Zo(t)}),this.register(function(t){return new aa(t)}),this.register(function(t){return new la(t)})}load(e,t,n,r){const s=this;let i;this.resourcePath!==""?i=this.resourcePath:this.path!==""?i=this.path:i=c.LoaderUtils.extractUrlBase(e),this.manager.itemStart(e);const a=function(u){r?r(u):console.error(u),s.manager.itemError(e),s.manager.itemEnd(e)},l=new c.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(u){try{s.parse(u,i,function(h){t(h),s.manager.itemEnd(e)},a)}catch(h){a(h)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}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,n,r){let s;const i={},a={};if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(c.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4)))===os){try{i[be.KHR_BINARY_GLTF]=new ca(e)}catch(h){r&&r(h);return}s=JSON.parse(i[be.KHR_BINARY_GLTF].content)}else s=JSON.parse(c.LoaderUtils.decodeText(new Uint8Array(e)));else s=e;if(s.asset===void 0||s.asset.version[0]<2){r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new ba(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const h=this.pluginCallbacks[u](l);a[h.name]=h,i[h.name]=!0}if(s.extensionsUsed)for(let u=0;u<s.extensionsUsed.length;++u){const h=s.extensionsUsed[u],d=s.extensionsRequired||[];switch(h){case be.KHR_MATERIALS_UNLIT:i[h]=new Ko;break;case be.KHR_DRACO_MESH_COMPRESSION:i[h]=new ua(s,this.dracoLoader);break;case be.KHR_TEXTURE_TRANSFORM:i[h]=new ha;break;case be.KHR_MESH_QUANTIZATION:i[h]=new fa;break;default:d.indexOf(h)>=0&&a[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(i),l.setPlugins(a),l.parse(n,r)}parseAsync(e,t){const n=this;return new Promise(function(r,s){n.parse(e,t,r,s)})}}function Xo(){let o={};return{get:function(e){return o[e]},add:function(e,t){o[e]=t},remove:function(e){delete o[e]},removeAll:function(){o={}}}}const be={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Zo{constructor(e){this.parser=e,this.name=be.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){const s=t[n];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let r=t.cache.get(n);if(r)return r;const s=t.json,l=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let u;const h=new c.Color(16777215);l.color!==void 0&&h.fromArray(l.color);const d=l.range!==void 0?l.range:0;switch(l.type){case"directional":u=new c.DirectionalLight(h),u.target.position.set(0,0,-1),u.add(u.target);break;case"point":u=new c.PointLight(h),u.distance=d;break;case"spot":u=new c.SpotLight(h),u.distance=d,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,u.angle=l.spot.outerConeAngle,u.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,u.target.position.set(0,0,-1),u.add(u.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return u.position.set(0,0,0),u.decay=2,mt(u,l),l.intensity!==void 0&&(u.intensity=l.intensity),u.name=t.createUniqueName(l.name||"light_"+e),r=Promise.resolve(u),t.cache.add(n,r),r}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,s=n.json.nodes[e],a=(s.extensions&&s.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return n._getNodeRef(t.cache,a,l)})}}class Ko{constructor(){this.name=be.KHR_MATERIALS_UNLIT}getMaterialType(){return c.MeshBasicMaterial}extendParams(e,t,n){const r=[];e.color=new c.Color(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const i=s.baseColorFactor;e.color.fromArray(i),e.opacity=i[3]}s.baseColorTexture!==void 0&&r.push(n.assignTexture(e,"map",s.baseColorTexture,3001))}return Promise.all(r)}}class qo{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=r.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}}class Qo{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],i=r.extensions[this.name];if(i.clearcoatFactor!==void 0&&(t.clearcoat=i.clearcoatFactor),i.clearcoatTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),i.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),i.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),i.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),i.clearcoatNormalTexture.scale!==void 0)){const a=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new c.Vector2(a,a)}return Promise.all(s)}}class Jo{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],i=r.extensions[this.name];return i.iridescenceFactor!==void 0&&(t.iridescence=i.iridescenceFactor),i.iridescenceTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),i.iridescenceIor!==void 0&&(t.iridescenceIOR=i.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),i.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),i.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),i.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(s)}}class Ho{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new c.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const i=r.extensions[this.name];return i.sheenColorFactor!==void 0&&t.sheenColor.fromArray(i.sheenColorFactor),i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",i.sheenColorTexture,3001)),i.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(s)}}class $o{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],i=r.extensions[this.name];return i.transmissionFactor!==void 0&&(t.transmission=i.transmissionFactor),i.transmissionTexture!==void 0&&s.push(n.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(s)}}class ea{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],i=r.extensions[this.name];t.thickness=i.thicknessFactor!==void 0?i.thicknessFactor:0,i.thicknessTexture!==void 0&&s.push(n.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const a=i.attenuationColor||[1,1,1];return t.attenuationColor=new c.Color(a[0],a[1],a[2]),Promise.all(s)}}class ta{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=r.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}}class na{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],i=r.extensions[this.name];t.specularIntensity=i.specularFactor!==void 0?i.specularFactor:1,i.specularTexture!==void 0&&s.push(n.assignTexture(t,"specularIntensityMap",i.specularTexture));const a=i.specularColorFactor||[1,1,1];return t.specularColor=new c.Color(a[0],a[1],a[2]),i.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",i.specularColorTexture,3001)),Promise.all(s)}}class ra{constructor(e){this.parser=e,this.name=be.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:c.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],i=r.extensions[this.name];return i.anisotropyStrength!==void 0&&(t.anisotropy=i.anisotropyStrength),i.anisotropyRotation!==void 0&&(t.anisotropyRotation=i.anisotropyRotation),i.anisotropyTexture!==void 0&&s.push(n.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(s)}}class sa{constructor(e){this.parser=e,this.name=be.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const s=r.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,i)}}class ia{constructor(e){this.parser=e,this.name=be.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;const i=s.extensions[t],a=r.images[i.source];let l=n.textureLoader;if(a.uri){const u=n.options.manager.getHandler(a.uri);u!==null&&(l=u)}return this.detectSupport().then(function(u){if(u)return n.loadTextureImage(e,i.source,l);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class oa{constructor(e){this.parser=e,this.name=be.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;const i=s.extensions[t],a=r.images[i.source];let l=n.textureLoader;if(a.uri){const u=n.options.manager.getHandler(a.uri);u!==null&&(l=u)}return this.detectSupport().then(function(u){if(u)return n.loadTextureImage(e,i.source,l);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class aa{constructor(e){this.name=be.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const r=n.extensions[this.name],s=this.parser.getDependency("buffer",r.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){const l=r.byteOffset||0,u=r.byteLength||0,h=r.count,d=r.byteStride,g=new Uint8Array(a,l,u);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(h,d,g,r.mode,r.filter).then(function(y){return y.buffer}):i.ready.then(function(){const y=new ArrayBuffer(h*d);return i.decodeGltfBuffer(new Uint8Array(y),h,d,g,r.mode,r.filter),y})})}else return null}}class la{constructor(e){this.name=be.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const r=t.meshes[n.mesh];for(const u of r.primitives)if(u.mode!==Xe.TRIANGLES&&u.mode!==Xe.TRIANGLE_STRIP&&u.mode!==Xe.TRIANGLE_FAN&&u.mode!==void 0)return null;const i=n.extensions[this.name].attributes,a=[],l={};for(const u in i)a.push(this.parser.getDependency("accessor",i[u]).then(h=>(l[u]=h,l[u])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(u=>{const h=u.pop(),d=h.isGroup?h.children:[h],g=u[0].count,y=[];for(const x of d){const w=new c.Matrix4,v=new c.Vector3,A=new c.Quaternion,D=new c.Vector3(1,1,1),M=new c.InstancedMesh(x.geometry,x.material,g);for(let _=0;_<g;_++)l.TRANSLATION&&v.fromBufferAttribute(l.TRANSLATION,_),l.ROTATION&&A.fromBufferAttribute(l.ROTATION,_),l.SCALE&&D.fromBufferAttribute(l.SCALE,_),M.setMatrixAt(_,w.compose(v,A,D));for(const _ in l)_!=="TRANSLATION"&&_!=="ROTATION"&&_!=="SCALE"&&x.geometry.setAttribute(_,l[_]);c.Object3D.prototype.copy.call(M,x),this.parser.assignFinalMaterial(M),y.push(M)}return h.isGroup?(h.clear(),h.add(...y),h):y[0]}))}}const os="glTF",Xt=12,as={JSON:1313821514,BIN:5130562};class ca{constructor(e){this.name=be.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Xt);if(this.header={magic:c.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==os)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-Xt,r=new DataView(e,Xt);let s=0;for(;s<n;){const i=r.getUint32(s,!0);s+=4;const a=r.getUint32(s,!0);if(s+=4,a===as.JSON){const l=new Uint8Array(e,Xt+s,i);this.content=c.LoaderUtils.decodeText(l)}else if(a===as.BIN){const l=Xt+s;this.body=e.slice(l,l+i)}s+=i}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class ua{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=be.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,r=this.dracoLoader,s=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,a={},l={},u={};for(const h in i){const d=Qn[h]||h.toLowerCase();a[d]=i[h]}for(const h in e.attributes){const d=Qn[h]||h.toLowerCase();if(i[h]!==void 0){const g=n.accessors[e.attributes[h]],y=Ot[g.componentType];u[d]=y.name,l[d]=g.normalized===!0}}return t.getDependency("bufferView",s).then(function(h){return new Promise(function(d){r.decodeDracoFile(h,function(g){for(const y in g.attributes){const x=g.attributes[y],w=l[y];w!==void 0&&(x.normalized=w)}d(g)},a,u)})})}}class ha{constructor(){this.name=be.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class fa{constructor(){this.name=be.KHR_MESH_QUANTIZATION}}class ls extends c.Interpolant{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=e*r*3+r;for(let i=0;i!==r;i++)t[i]=n[s+i];return t}interpolate_(e,t,n,r){const s=this.resultBuffer,i=this.sampleValues,a=this.valueSize,l=a*2,u=a*3,h=r-t,d=(n-t)/h,g=d*d,y=g*d,x=e*u,w=x-u,v=-2*y+3*g,A=y-g,D=1-v,M=A-g+d;for(let _=0;_!==a;_++){const L=i[w+_+a],b=i[w+_+l]*h,C=i[x+_+a],m=i[x+_]*h;s[_]=D*L+M*b+v*C+A*m}return s}}const da=new c.Quaternion;class pa extends ls{interpolate_(e,t,n,r){const s=super.interpolate_(e,t,n,r);return da.fromArray(s).normalize().toArray(s),s}}const Xe={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Ot={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},cs={9728:c.NearestFilter,9729:c.LinearFilter,9984:c.NearestMipmapNearestFilter,9985:c.LinearMipmapNearestFilter,9986:c.NearestMipmapLinearFilter,9987:c.LinearMipmapLinearFilter},us={33071:c.ClampToEdgeWrapping,33648:c.MirroredRepeatWrapping,10497:c.RepeatWrapping},qn={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Qn={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...Gr>=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},pt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},ma={CUBICSPLINE:void 0,LINEAR:c.InterpolateLinear,STEP:c.InterpolateDiscrete},Jn={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function ga(o){return o.DefaultMaterial===void 0&&(o.DefaultMaterial=new c.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:c.FrontSide})),o.DefaultMaterial}function bt(o,e,t){for(const n in t.extensions)o[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function mt(o,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(o.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function ya(o,e,t){let n=!1,r=!1,s=!1;for(let u=0,h=e.length;u<h;u++){const d=e[u];if(d.POSITION!==void 0&&(n=!0),d.NORMAL!==void 0&&(r=!0),d.COLOR_0!==void 0&&(s=!0),n&&r&&s)break}if(!n&&!r&&!s)return Promise.resolve(o);const i=[],a=[],l=[];for(let u=0,h=e.length;u<h;u++){const d=e[u];if(n){const g=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):o.attributes.position;i.push(g)}if(r){const g=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):o.attributes.normal;a.push(g)}if(s){const g=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):o.attributes.color;l.push(g)}}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(l)]).then(function(u){const h=u[0],d=u[1],g=u[2];return n&&(o.morphAttributes.position=h),r&&(o.morphAttributes.normal=d),s&&(o.morphAttributes.color=g),o.morphTargetsRelative=!0,o})}function _a(o,e){if(o.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)o.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(o.morphTargetInfluences.length===t.length){o.morphTargetDictionary={};for(let n=0,r=t.length;n<r;n++)o.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function va(o){let e;const t=o.extensions&&o.extensions[be.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Hn(t.attributes):e=o.indices+":"+Hn(o.attributes)+":"+o.mode,o.targets!==void 0)for(let n=0,r=o.targets.length;n<r;n++)e+=":"+Hn(o.targets[n]);return e}function Hn(o){let e="";const t=Object.keys(o).sort();for(let n=0,r=t.length;n<r;n++)e+=t[n]+":"+o[t[n]]+";";return e}function $n(o){switch(o){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function xa(o){return o.search(/\.jpe?g($|\?)/i)>0||o.search(/^data\:image\/jpeg/)===0?"image/jpeg":o.search(/\.webp($|\?)/i)>0||o.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const wa=new c.Matrix4;class ba{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Xo,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,r=!1,s=-1;typeof navigator<"u"&&typeof navigator.userAgent<"u"&&(n=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,r=navigator.userAgent.indexOf("Firefox")>-1,s=r?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||n||r&&s<98?this.textureLoader=new c.TextureLoader(this.options.manager):this.textureLoader=new c.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new c.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,r=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(i){const a={scene:i[0][r.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:r.asset,parser:n,userData:{}};bt(s,a,r),mt(a,r),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let r=0,s=t.length;r<s;r++){const i=t[r].joints;for(let a=0,l=i.length;a<l;a++)e[i[a]].isBone=!0}for(let r=0,s=e.length;r<s;r++){const i=e[r];i.mesh!==void 0&&(this._addNodeRef(this.meshCache,i.mesh),i.skin!==void 0&&(n[i.mesh].isSkinnedMesh=!0)),i.camera!==void 0&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const r=n.clone(),s=(i,a)=>{const l=this.associations.get(i);l!=null&&this.associations.set(a,l);for(const[u,h]of i.children.entries())s(h,a.children[u])};return s(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const r=e(t[n]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let r=0;r<t.length;r++){const s=e(t[r]);s&&n.push(s)}return n}getDependency(e,t){const n=e+":"+t;let r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":r=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e);break}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,r=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(r.map(function(s,i){return n.getDependency(e,i)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[be.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(s,i){n.load(c.LoaderUtils.resolveURL(t.uri,r.path),s,void 0,function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const r=t.byteLength||0,s=t.byteOffset||0;return n.slice(s,s+r)})}loadAccessor(e){const t=this,n=this.json,r=this.json.accessors[e];if(r.bufferView===void 0&&r.sparse===void 0){const i=qn[r.type],a=Ot[r.componentType],l=r.normalized===!0,u=new a(r.count*i);return Promise.resolve(new c.BufferAttribute(u,i,l))}const s=[];return r.bufferView!==void 0?s.push(this.getDependency("bufferView",r.bufferView)):s.push(null),r.sparse!==void 0&&(s.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(s).then(function(i){const a=i[0],l=qn[r.type],u=Ot[r.componentType],h=u.BYTES_PER_ELEMENT,d=h*l,g=r.byteOffset||0,y=r.bufferView!==void 0?n.bufferViews[r.bufferView].byteStride:void 0,x=r.normalized===!0;let w,v;if(y&&y!==d){const A=Math.floor(g/y),D="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+A+":"+r.count;let M=t.cache.get(D);M||(w=new u(a,A*y,r.count*y/h),M=new c.InterleavedBuffer(w,y/h),t.cache.add(D,M)),v=new c.InterleavedBufferAttribute(M,l,g%y/h,x)}else a===null?w=new u(r.count*l):w=new u(a,g,r.count*l),v=new c.BufferAttribute(w,l,x);if(r.sparse!==void 0){const A=qn.SCALAR,D=Ot[r.sparse.indices.componentType],M=r.sparse.indices.byteOffset||0,_=r.sparse.values.byteOffset||0,L=new D(i[1],M,r.sparse.count*A),b=new u(i[2],_,r.sparse.count*l);a!==null&&(v=new c.BufferAttribute(v.array.slice(),v.itemSize,v.normalized));for(let C=0,m=L.length;C<m;C++){const S=L[C];if(v.setX(S,b[C*l]),l>=2&&v.setY(S,b[C*l+1]),l>=3&&v.setZ(S,b[C*l+2]),l>=4&&v.setW(S,b[C*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return v})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,i=t.images[s];let a=this.textureLoader;if(i.uri){const l=n.manager.getHandler(i.uri);l!==null&&(a=l)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){const r=this,s=this.json,i=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+i.sampler;if(this.textureCache[l])return this.textureCache[l];const u=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=i.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const g=(s.samplers||{})[i.sampler]||{};return h.magFilter=cs[g.magFilter]||c.LinearFilter,h.minFilter=cs[g.minFilter]||c.LinearMipmapLinearFilter,h.wrapS=us[g.wrapS]||c.RepeatWrapping,h.wrapT=us[g.wrapT]||c.RepeatWrapping,r.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=u,u}loadImageSource(e,t){const n=this,r=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const i=r.images[e],a=self.URL||self.webkitURL;let l=i.uri||"",u=!1;if(i.bufferView!==void 0)l=n.getDependency("bufferView",i.bufferView).then(function(d){u=!0;const g=new Blob([d],{type:i.mimeType});return l=a.createObjectURL(g),l});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(l).then(function(d){return new Promise(function(g,y){let x=g;t.isImageBitmapLoader===!0&&(x=function(w){const v=new c.Texture(w);v.needsUpdate=!0,g(v)}),t.load(c.LoaderUtils.resolveURL(d,s.path),x,void 0,y)})}).then(function(d){return u===!0&&a.revokeObjectURL(l),d.userData.mimeType=i.mimeType||xa(i.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),d});return this.sourceCache[e]=h,h}assignTexture(e,t,n,r){const s=this;return this.getDependency("texture",n.index).then(function(i){if(!i)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(i=i.clone(),i.channel=n.texCoord),s.extensions[be.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[be.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=s.associations.get(i);i=s.extensions[be.KHR_TEXTURE_TRANSFORM].extendTexture(i,a),s.associations.set(i,l)}}return r!==void 0&&("colorSpace"in i?i.colorSpace=r===3001?"srgb":"srgb-linear":i.encoding=r),e[t]=i,i})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const r=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,i=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new c.PointsMaterial,c.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new c.LineBasicMaterial,c.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(r||s||i){let a="ClonedMaterial:"+n.uuid+":";r&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),i&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),s&&(l.vertexColors=!0),i&&(l.flatShading=!0),r&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return c.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,r=this.extensions,s=n.materials[e];let i;const a={},l=s.extensions||{},u=[];if(l[be.KHR_MATERIALS_UNLIT]){const d=r[be.KHR_MATERIALS_UNLIT];i=d.getMaterialType(),u.push(d.extendParams(a,s,t))}else{const d=s.pbrMetallicRoughness||{};if(a.color=new c.Color(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const g=d.baseColorFactor;a.color.fromArray(g),a.opacity=g[3]}d.baseColorTexture!==void 0&&u.push(t.assignTexture(a,"map",d.baseColorTexture,3001)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(u.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),u.push(t.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),i=this._invokeOne(function(g){return g.getMaterialType&&g.getMaterialType(e)}),u.push(Promise.all(this._invokeAll(function(g){return g.extendMaterialParams&&g.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=c.DoubleSide);const h=s.alphaMode||Jn.OPAQUE;if(h===Jn.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===Jn.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&i!==c.MeshBasicMaterial&&(u.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new c.Vector2(1,1),s.normalTexture.scale!==void 0)){const d=s.normalTexture.scale;a.normalScale.set(d,d)}return s.occlusionTexture!==void 0&&i!==c.MeshBasicMaterial&&(u.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&i!==c.MeshBasicMaterial&&(a.emissive=new c.Color().fromArray(s.emissiveFactor)),s.emissiveTexture!==void 0&&i!==c.MeshBasicMaterial&&u.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,3001)),Promise.all(u).then(function(){const d=new i(a);return s.name&&(d.name=s.name),mt(d,s),t.associations.set(d,{materials:e}),s.extensions&&bt(r,d,s),d})}createUniqueName(e){const t=c.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,r=this.primitiveCache;function s(a){return n[be.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return hs(l,a,t)})}const i=[];for(let a=0,l=e.length;a<l;a++){const u=e[a],h=va(u),d=r[h];if(d)i.push(d.promise);else{let g;u.extensions&&u.extensions[be.KHR_DRACO_MESH_COMPRESSION]?g=s(u):g=hs(new c.BufferGeometry,u,t),r[h]={primitive:u,promise:g},i.push(g)}}return Promise.all(i)}loadMesh(e){const t=this,n=this.json,r=this.extensions,s=n.meshes[e],i=s.primitives,a=[];for(let l=0,u=i.length;l<u;l++){const h=i[l].material===void 0?ga(this.cache):this.getDependency("material",i[l].material);a.push(h)}return a.push(t.loadGeometries(i)),Promise.all(a).then(function(l){const u=l.slice(0,l.length-1),h=l[l.length-1],d=[];for(let y=0,x=h.length;y<x;y++){const w=h[y],v=i[y];let A;const D=u[y];if(v.mode===Xe.TRIANGLES||v.mode===Xe.TRIANGLE_STRIP||v.mode===Xe.TRIANGLE_FAN||v.mode===void 0)A=s.isSkinnedMesh===!0?new c.SkinnedMesh(w,D):new c.Mesh(w,D),A.isSkinnedMesh===!0&&A.normalizeSkinWeights(),v.mode===Xe.TRIANGLE_STRIP?A.geometry=Rr(A.geometry,c.TriangleStripDrawMode):v.mode===Xe.TRIANGLE_FAN&&(A.geometry=Rr(A.geometry,c.TriangleFanDrawMode));else if(v.mode===Xe.LINES)A=new c.LineSegments(w,D);else if(v.mode===Xe.LINE_STRIP)A=new c.Line(w,D);else if(v.mode===Xe.LINE_LOOP)A=new c.LineLoop(w,D);else if(v.mode===Xe.POINTS)A=new c.Points(w,D);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+v.mode);Object.keys(A.geometry.morphAttributes).length>0&&_a(A,s),A.name=t.createUniqueName(s.name||"mesh_"+e),mt(A,s),v.extensions&&bt(r,A,v),t.assignFinalMaterial(A),d.push(A)}for(let y=0,x=d.length;y<x;y++)t.associations.set(d[y],{meshes:e,primitives:y});if(d.length===1)return s.extensions&&bt(r,d[0],s),d[0];const g=new c.Group;s.extensions&&bt(r,g,s),t.associations.set(g,{meshes:e});for(let y=0,x=d.length;y<x;y++)g.add(d[y]);return g})}loadCamera(e){let t;const n=this.json.cameras[e],r=n[n.type];if(!r){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new c.PerspectiveCamera(c.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type==="orthographic"&&(t=new c.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),mt(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let r=0,s=t.joints.length;r<s;r++)n.push(this._loadNodeShallow(t.joints[r]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(r){const s=r.pop(),i=r,a=[],l=[];for(let u=0,h=i.length;u<h;u++){const d=i[u];if(d){a.push(d);const g=new c.Matrix4;s!==null&&g.fromArray(s.array,u*16),l.push(g)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[u])}return new c.Skeleton(a,l)})}loadAnimation(e){const n=this.json.animations[e],r=n.name?n.name:"animation_"+e,s=[],i=[],a=[],l=[],u=[];for(let h=0,d=n.channels.length;h<d;h++){const g=n.channels[h],y=n.samplers[g.sampler],x=g.target,w=x.node,v=n.parameters!==void 0?n.parameters[y.input]:y.input,A=n.parameters!==void 0?n.parameters[y.output]:y.output;x.node!==void 0&&(s.push(this.getDependency("node",w)),i.push(this.getDependency("accessor",v)),a.push(this.getDependency("accessor",A)),l.push(y),u.push(x))}return Promise.all([Promise.all(s),Promise.all(i),Promise.all(a),Promise.all(l),Promise.all(u)]).then(function(h){const d=h[0],g=h[1],y=h[2],x=h[3],w=h[4],v=[];for(let A=0,D=d.length;A<D;A++){const M=d[A],_=g[A],L=y[A],b=x[A],C=w[A];if(M===void 0)continue;M.updateMatrix();let m;switch(pt[C.path]){case pt.weights:m=c.NumberKeyframeTrack;break;case pt.rotation:m=c.QuaternionKeyframeTrack;break;case pt.position:case pt.scale:default:m=c.VectorKeyframeTrack;break}const S=M.name?M.name:M.uuid,p=b.interpolation!==void 0?ma[b.interpolation]:c.InterpolateLinear,I=[];pt[C.path]===pt.weights?M.traverse(function(J){J.morphTargetInfluences&&I.push(J.name?J.name:J.uuid)}):I.push(S);let k=L.array;if(L.normalized){const J=$n(k.constructor),R=new Float32Array(k.length);for(let Z=0,X=k.length;Z<X;Z++)R[Z]=k[Z]*J;k=R}for(let J=0,R=I.length;J<R;J++){const Z=new m(I[J]+"."+pt[C.path],_.array,k,p);b.interpolation==="CUBICSPLINE"&&(Z.createInterpolant=function(q){const Y=this instanceof c.QuaternionKeyframeTrack?pa:ls;return new Y(this.times,this.values,this.getValueSize()/3,q)},Z.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),v.push(Z)}}return new c.AnimationClip(r,void 0,v)})}createNodeMesh(e){const t=this.json,n=this,r=t.nodes[e];return r.mesh===void 0?null:n.getDependency("mesh",r.mesh).then(function(s){const i=n._getNodeRef(n.meshCache,r.mesh,s);return r.weights!==void 0&&i.traverse(function(a){if(a.isMesh)for(let l=0,u=r.weights.length;l<u;l++)a.morphTargetInfluences[l]=r.weights[l]}),i})}loadNode(e){const t=this.json,n=this,r=t.nodes[e],s=n._loadNodeShallow(e),i=[],a=r.children||[];for(let u=0,h=a.length;u<h;u++)i.push(n.getDependency("node",a[u]));const l=r.skin===void 0?Promise.resolve(null):n.getDependency("skin",r.skin);return Promise.all([s,Promise.all(i),l]).then(function(u){const h=u[0],d=u[1],g=u[2];g!==null&&h.traverse(function(y){y.isSkinnedMesh&&y.bind(g,wa)});for(let y=0,x=d.length;y<x;y++)h.add(d[y]);return h})}_loadNodeShallow(e){const t=this.json,n=this.extensions,r=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],i=s.name?r.createUniqueName(s.name):"",a=[],l=r._invokeOne(function(u){return u.createNodeMesh&&u.createNodeMesh(e)});return l&&a.push(l),s.camera!==void 0&&a.push(r.getDependency("camera",s.camera).then(function(u){return r._getNodeRef(r.cameraCache,s.camera,u)})),r._invokeAll(function(u){return u.createNodeAttachment&&u.createNodeAttachment(e)}).forEach(function(u){a.push(u)}),this.nodeCache[e]=Promise.all(a).then(function(u){let h;if(s.isBone===!0?h=new c.Bone:u.length>1?h=new c.Group:u.length===1?h=u[0]:h=new c.Object3D,h!==u[0])for(let d=0,g=u.length;d<g;d++)h.add(u[d]);if(s.name&&(h.userData.name=s.name,h.name=i),mt(h,s),s.extensions&&bt(n,h,s),s.matrix!==void 0){const d=new c.Matrix4;d.fromArray(s.matrix),h.applyMatrix4(d)}else s.translation!==void 0&&h.position.fromArray(s.translation),s.rotation!==void 0&&h.quaternion.fromArray(s.rotation),s.scale!==void 0&&h.scale.fromArray(s.scale);return r.associations.has(h)||r.associations.set(h,{}),r.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],r=this,s=new c.Group;n.name&&(s.name=r.createUniqueName(n.name)),mt(s,n),n.extensions&&bt(t,s,n);const i=n.nodes||[],a=[];for(let l=0,u=i.length;l<u;l++)a.push(r.getDependency("node",i[l]));return Promise.all(a).then(function(l){for(let h=0,d=l.length;h<d;h++)s.add(l[h]);const u=h=>{const d=new Map;for(const[g,y]of r.associations)(g instanceof c.Material||g instanceof c.Texture)&&d.set(g,y);return h.traverse(g=>{const y=r.associations.get(g);y!=null&&d.set(g,y)}),d};return r.associations=u(s),s})}}function Ma(o,e,t){const n=e.attributes,r=new c.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],l=a.min,u=a.max;if(l!==void 0&&u!==void 0){if(r.set(new c.Vector3(l[0],l[1],l[2]),new c.Vector3(u[0],u[1],u[2])),a.normalized){const h=$n(Ot[a.componentType]);r.min.multiplyScalar(h),r.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const a=new c.Vector3,l=new c.Vector3;for(let u=0,h=s.length;u<h;u++){const d=s[u];if(d.POSITION!==void 0){const g=t.json.accessors[d.POSITION],y=g.min,x=g.max;if(y!==void 0&&x!==void 0){if(l.setX(Math.max(Math.abs(y[0]),Math.abs(x[0]))),l.setY(Math.max(Math.abs(y[1]),Math.abs(x[1]))),l.setZ(Math.max(Math.abs(y[2]),Math.abs(x[2]))),g.normalized){const w=$n(Ot[g.componentType]);l.multiplyScalar(w)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}o.boundingBox=r;const i=new c.Sphere;r.getCenter(i.center),i.radius=r.min.distanceTo(r.max)/2,o.boundingSphere=i}function hs(o,e,t){const n=e.attributes,r=[];function s(i,a){return t.getDependency("accessor",i).then(function(l){o.setAttribute(a,l)})}for(const i in n){const a=Qn[i]||i.toLowerCase();a in o.attributes||r.push(s(n[i],a))}if(e.indices!==void 0&&!o.index){const i=t.getDependency("accessor",e.indices).then(function(a){o.setIndex(a)});r.push(i)}return mt(o,e),Ma(o,e,t),Promise.all(r).then(function(){return e.targets!==void 0?ya(o,e.targets,t):o})}const Zt=new c.Vector3;function Ze(o,e,t,n,r,s){const i=2*Math.PI*r/4,a=Math.max(s-2*r,0),l=Math.PI/4;Zt.copy(e),Zt[n]=0,Zt.normalize();const u=.5*i/(i+a),h=1-Zt.angleTo(o)/l;return Math.sign(Zt[t])===1?h*u:a/(i+a)+u+u*(1-h)}class Sa extends c.BoxGeometry{constructor(e=1,t=1,n=1,r=2,s=.1){if(r=r*2+1,s=Math.min(e/2,t/2,n/2,s),super(1,1,1,r,r,r),r===1)return;const i=this.toNonIndexed();this.index=null,this.attributes.position=i.attributes.position,this.attributes.normal=i.attributes.normal,this.attributes.uv=i.attributes.uv;const a=new c.Vector3,l=new c.Vector3,u=new c.Vector3(e,t,n).divideScalar(2).subScalar(s),h=this.attributes.position.array,d=this.attributes.normal.array,g=this.attributes.uv.array,y=h.length/6,x=new c.Vector3,w=.5/r;for(let v=0,A=0;v<h.length;v+=3,A+=2)switch(a.fromArray(h,v),l.copy(a),l.x-=Math.sign(l.x)*w,l.y-=Math.sign(l.y)*w,l.z-=Math.sign(l.z)*w,l.normalize(),h[v+0]=u.x*Math.sign(a.x)+l.x*s,h[v+1]=u.y*Math.sign(a.y)+l.y*s,h[v+2]=u.z*Math.sign(a.z)+l.z*s,d[v+0]=l.x,d[v+1]=l.y,d[v+2]=l.z,Math.floor(v/y)){case 0:x.set(1,0,0),g[A+0]=Ze(x,l,"z","y",s,n),g[A+1]=1-Ze(x,l,"y","z",s,t);break;case 1:x.set(-1,0,0),g[A+0]=1-Ze(x,l,"z","y",s,n),g[A+1]=1-Ze(x,l,"y","z",s,t);break;case 2:x.set(0,1,0),g[A+0]=1-Ze(x,l,"x","z",s,e),g[A+1]=Ze(x,l,"z","x",s,n);break;case 3:x.set(0,-1,0),g[A+0]=1-Ze(x,l,"x","z",s,e),g[A+1]=1-Ze(x,l,"z","x",s,n);break;case 4:x.set(0,0,1),g[A+0]=1-Ze(x,l,"x","y",s,e),g[A+1]=1-Ze(x,l,"y","x",s,t);break;case 5:x.set(0,0,-1),g[A+0]=Ze(x,l,"x","y",s,e),g[A+1]=1-Ze(x,l,"y","x",s,t);break}}}class fs extends c.ExtrudeGeometry{constructor(e,t={}){const{bevelEnabled:n=!1,bevelSize:r=8,bevelThickness:s=10,font:i,height:a=50,size:l=100,lineHeight:u=1,letterSpacing:h=0,...d}=t;if(i===void 0)super();else{const g=i.generateShapes(e,l,{lineHeight:u,letterSpacing:h});super(g,{...d,bevelEnabled:n,bevelSize:r,bevelThickness:s,depth:a})}this.type="TextGeometry"}}const Aa={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
|
|
28
28
|
varying vec2 vUv;
|
|
29
29
|
|
|
30
30
|
void main() {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
gl_FragColor = sum;
|
|
57
57
|
|
|
58
58
|
}
|
|
59
|
-
`},
|
|
59
|
+
`},Pa={uniforms:{tDiffuse:{value:null},v:{value:1/512}},vertexShader:`
|
|
60
60
|
varying vec2 vUv;
|
|
61
61
|
|
|
62
62
|
void main() {
|
|
@@ -89,13 +89,13 @@
|
|
|
89
89
|
gl_FragColor = sum;
|
|
90
90
|
|
|
91
91
|
}
|
|
92
|
-
`};function hr(o,e,t){const n=t.length-o-1;if(e>=t[n])return n-1;if(e<=t[o])return o;let s=o,r=n,i=Math.floor((s+r)/2);for(;e<t[i]||e>=t[i+1];)e<t[i]?r=i:s=i,i=Math.floor((s+r)/2);return i}function Sa(o,e,t,n){const s=[],r=[],i=[];s[0]=1;for(let a=1;a<=t;++a){r[a]=e-n[o+1-a],i[a]=n[o+a]-e;let l=0;for(let u=0;u<a;++u){const h=i[u+1],d=r[a-u],y=s[u]/(h+d);s[u]=l+h*y,l=d*y}s[a]=l}return s}function Aa(o,e,t,n){const s=hr(o,n,e),r=Sa(s,n,o,e),i=new c.Vector4(0,0,0,0);for(let a=0;a<=o;++a){const l=t[s-o+a],u=r[a],h=l.w*u;i.x+=l.x*h,i.y+=l.y*h,i.z+=l.z*h,i.w+=l.w*u}return i}function Pa(o,e,t,n,s){const r=[];for(let d=0;d<=t;++d)r[d]=0;const i=[];for(let d=0;d<=n;++d)i[d]=r.slice(0);const a=[];for(let d=0;d<=t;++d)a[d]=r.slice(0);a[0][0]=1;const l=r.slice(0),u=r.slice(0);for(let d=1;d<=t;++d){l[d]=e-s[o+1-d],u[d]=s[o+d]-e;let y=0;for(let g=0;g<d;++g){const x=u[g+1],w=l[d-g];a[d][g]=x+w;const v=a[g][d-1]/a[d][g];a[g][d]=y+x*v,y=w*v}a[d][d]=y}for(let d=0;d<=t;++d)i[0][d]=a[d][t];for(let d=0;d<=t;++d){let y=0,g=1;const x=[];for(let w=0;w<=t;++w)x[w]=r.slice(0);x[0][0]=1;for(let w=1;w<=n;++w){let v=0;const P=d-w,D=t-w;d>=w&&(x[g][0]=x[y][0]/a[D+1][P],v=x[g][0]*a[P][D]);const S=P>=-1?1:-P,_=d-1<=D?w-1:t-d;for(let b=S;b<=_;++b)x[g][b]=(x[y][b]-x[y][b-1])/a[D+1][P+b],v+=x[g][b]*a[P+b][D];d<=D&&(x[g][w]=-x[y][w-1]/a[D+1][d],v+=x[g][w]*a[d][D]),i[w][d]=v;const L=y;y=g,g=L}}let h=t;for(let d=1;d<=n;++d){for(let y=0;y<=t;++y)i[d][y]*=h;h*=t-d}return i}function Ca(o,e,t,n,s){const r=s<o?s:o,i=[],a=hr(o,n,e),l=Pa(a,n,o,r,e),u=[];for(let h=0;h<t.length;++h){const d=t[h].clone(),y=d.w;d.x*=y,d.y*=y,d.z*=y,u[h]=d}for(let h=0;h<=r;++h){const d=u[a-o].clone().multiplyScalar(l[h][0]);for(let y=1;y<=o;++y)d.add(u[a-o+y].clone().multiplyScalar(l[h][y]));i[h]=d}for(let h=r+1;h<=s+1;++h)i[h]=new c.Vector4(0,0,0);return i}function Ta(o,e){let t=1;for(let s=2;s<=o;++s)t*=s;let n=1;for(let s=2;s<=e;++s)n*=s;for(let s=2;s<=o-e;++s)n*=s;return t/n}function La(o){const e=o.length,t=[],n=[];for(let r=0;r<e;++r){const i=o[r];t[r]=new c.Vector3(i.x,i.y,i.z),n[r]=i.w}const s=[];for(let r=0;r<e;++r){const i=t[r].clone();for(let a=1;a<=r;++a)i.sub(s[r-a].clone().multiplyScalar(Ta(r,a)*n[a]));s[r]=i.divideScalar(n[0])}return s}function Ia(o,e,t,n,s){const r=Ca(o,e,t,n,s);return La(r)}class fr extends c.Curve{constructor(e,t,n,s,r){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=s||0,this.endKnot=r||this.knots.length-1;for(let i=0;i<n.length;++i){const a=n[i];this.controlPoints[i]=new c.Vector4(a.x,a.y,a.z,a.w)}}getPoint(e,t){const n=t||new c.Vector3,s=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),r=Aa(this.degree,this.knots,this.controlPoints,s);return r.w!=1&&r.divideScalar(r.w),n.set(r.x,r.y,r.z)}getTangent(e,t){const n=t||new c.Vector3,s=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),r=Ia(this.degree,this.knots,this.controlPoints,s,1);return n.copy(r[1]).normalize(),n}}let ve,Ie,Ve;class Da extends c.Loader{constructor(e){super(e)}load(e,t,n,s){const r=this,i=r.path===""?c.LoaderUtils.extractUrlBase(e):r.path,a=new c.FileLoader(this.manager);a.setPath(r.path),a.setResponseType("arraybuffer"),a.setRequestHeader(r.requestHeader),a.setWithCredentials(r.withCredentials),a.load(e,function(l){try{t(r.parse(l,i))}catch(u){s?s(u):console.error(u),r.manager.itemError(e)}},n,s)}parse(e,t){if(Na(e))ve=new Ua().parse(e);else{const s=_r(e);if(!za(s))throw new Error("THREE.FBXLoader: Unknown format.");if(mr(s)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+mr(s));ve=new Ba().parse(s)}const n=new c.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new Oa(n,this.manager).parse(ve)}}class Oa{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){Ie=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),s=this.parseDeformers(),r=new Fa().parse(s);return this.parseScene(s,r,n),Ve}parseConnections(){const e=new Map;return"Connections"in ve&&ve.Connections.connections.forEach(function(n){const s=n[0],r=n[1],i=n[2];e.has(s)||e.set(s,{parents:[],children:[]});const a={ID:r,relationship:i};e.get(s).parents.push(a),e.has(r)||e.set(r,{parents:[],children:[]});const l={ID:s,relationship:i};e.get(r).children.push(l)}),e}parseImages(){const e={},t={};if("Video"in ve.Objects){const n=ve.Objects.Video;for(const s in n){const r=n[s],i=parseInt(s);if(e[i]=r.RelativeFilename||r.Filename,"Content"in r){const a=r.Content instanceof ArrayBuffer&&r.Content.byteLength>0,l=typeof r.Content=="string"&&r.Content!=="";if(a||l){const u=this.parseImage(n[s]);t[r.RelativeFilename||r.Filename]=u}}}}for(const n in e){const s=e[n];t[s]!==void 0?e[n]=t[s]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,s=n.slice(n.lastIndexOf(".")+1).toLowerCase();let r;switch(s){case"bmp":r="image/bmp";break;case"jpg":case"jpeg":r="image/jpeg";break;case"png":r="image/png";break;case"tif":r="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),r="image/tga";break;default:console.warn('FBXLoader: Image type "'+s+'" is not supported.');return}if(typeof t=="string")return"data:"+r+";base64,"+t;{const i=new Uint8Array(t);return window.URL.createObjectURL(new Blob([i],{type:r}))}}parseTextures(e){const t=new Map;if("Texture"in ve.Objects){const n=ve.Objects.Texture;for(const s in n){const r=this.parseTexture(n[s],e);t.set(parseInt(s),r)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const s=e.WrapModeU,r=e.WrapModeV,i=s!==void 0?s.value:0,a=r!==void 0?r.value:0;if(n.wrapS=i===0?c.RepeatWrapping:c.ClampToEdgeWrapping,n.wrapT=a===0?c.RepeatWrapping:c.ClampToEdgeWrapping,"Scaling"in e){const l=e.Scaling.value;n.repeat.x=l[0],n.repeat.y=l[1]}return n}loadTexture(e,t){let n;const s=this.textureLoader.path,r=Ie.get(e.id).children;r!==void 0&&r.length>0&&t[r[0].ID]!==void 0&&(n=t[r[0].ID],(n.indexOf("blob:")===0||n.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let i;const a=e.FileName.slice(-3).toLowerCase();if(a==="tga"){const l=this.manager.getHandler(".tga");l===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),i=new c.Texture):(l.setPath(this.textureLoader.path),i=l.load(n))}else a==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),i=new c.Texture):i=this.textureLoader.load(n);return this.textureLoader.setPath(s),i}parseMaterials(e){const t=new Map;if("Material"in ve.Objects){const n=ve.Objects.Material;for(const s in n){const r=this.parseMaterial(n[s],e);r!==null&&t.set(parseInt(s),r)}}return t}parseMaterial(e,t){const n=e.id,s=e.attrName;let r=e.ShadingModel;if(typeof r=="object"&&(r=r.value),!Ie.has(n))return null;const i=this.parseParameters(e,t,n);let a;switch(r.toLowerCase()){case"phong":a=new c.MeshPhongMaterial;break;case"lambert":a=new c.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',r),a=new c.MeshPhongMaterial;break}return a.setValues(i),a.name=s,a}parseParameters(e,t,n){const s={};e.BumpFactor&&(s.bumpScale=e.BumpFactor.value),e.Diffuse?s.color=new c.Color().fromArray(e.Diffuse.value):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(s.color=new c.Color().fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(s.displacementScale=e.DisplacementFactor.value),e.Emissive?s.emissive=new c.Color().fromArray(e.Emissive.value):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(s.emissive=new c.Color().fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(s.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(s.opacity=parseFloat(e.Opacity.value)),s.opacity<1&&(s.transparent=!0),e.ReflectionFactor&&(s.reflectivity=e.ReflectionFactor.value),e.Shininess&&(s.shininess=e.Shininess.value),e.Specular?s.specular=new c.Color().fromArray(e.Specular.value):e.SpecularColor&&e.SpecularColor.type==="Color"&&(s.specular=new c.Color().fromArray(e.SpecularColor.value));const r=this;return Ie.get(n).children.forEach(function(i){const a=i.relationship;switch(a){case"Bump":s.bumpMap=r.getTexture(t,i.ID);break;case"Maya|TEX_ao_map":s.aoMap=r.getTexture(t,i.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":s.map=r.getTexture(t,i.ID),s.map!==void 0&&("colorSpace"in s.map?s.map.colorSpace="srgb":s.map.encoding=3001);break;case"DisplacementColor":s.displacementMap=r.getTexture(t,i.ID);break;case"EmissiveColor":s.emissiveMap=r.getTexture(t,i.ID),s.emissiveMap!==void 0&&("colorSpace"in s.emissiveMap?s.emissiveMap.colorSpace="srgb":s.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":s.normalMap=r.getTexture(t,i.ID);break;case"ReflectionColor":s.envMap=r.getTexture(t,i.ID),s.envMap!==void 0&&(s.envMap.mapping=c.EquirectangularReflectionMapping,"colorSpace"in s.envMap?s.envMap.colorSpace="srgb":s.envMap.encoding=3001);break;case"SpecularColor":s.specularMap=r.getTexture(t,i.ID),s.specularMap!==void 0&&("colorSpace"in s.specularMap?s.specularMap.colorSpace="srgb":s.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":s.alphaMap=r.getTexture(t,i.ID),s.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",a);break}}),s}getTexture(e,t){return"LayeredTexture"in ve.Objects&&t in ve.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=Ie.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in ve.Objects){const n=ve.Objects.Deformer;for(const s in n){const r=n[s],i=Ie.get(parseInt(s));if(r.attrType==="Skin"){const a=this.parseSkeleton(i,n);a.ID=s,i.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),a.geometryID=i.parents[0].ID,e[s]=a}else if(r.attrType==="BlendShape"){const a={id:s};a.rawTargets=this.parseMorphTargets(i,n),a.id=s,i.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[s]=a}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(s){const r=t[s.ID];if(r.attrType!=="Cluster")return;const i={ID:s.ID,indices:[],weights:[],transformLink:new c.Matrix4().fromArray(r.TransformLink.a)};"Indexes"in r&&(i.indices=r.Indexes.a,i.weights=r.Weights.a),n.push(i)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let s=0;s<e.children.length;s++){const r=e.children[s],i=t[r.ID],a={name:i.attrName,initialWeight:i.DeformPercent,id:i.id,fullWeights:i.FullWeights.a};if(i.attrType!=="BlendShapeChannel")return;a.geoID=Ie.get(parseInt(r.ID)).children.filter(function(l){return l.relationship===void 0})[0].ID,n.push(a)}return n}parseScene(e,t,n){Ve=new c.Group;const s=this.parseModels(e.skeletons,t,n),r=ve.Objects.Model,i=this;s.forEach(function(l){const u=r[l.ID];i.setLookAtProperties(l,u),Ie.get(l.ID).parents.forEach(function(d){const y=s.get(d.ID);y!==void 0&&y.add(l)}),l.parent===null&&Ve.add(l)}),this.bindSkeleton(e.skeletons,t,s),this.createAmbientLight(),Ve.traverse(function(l){if(l.userData.transformData){l.parent&&(l.userData.transformData.parentMatrix=l.parent.matrix,l.userData.transformData.parentMatrixWorld=l.parent.matrixWorld);const u=gr(l.userData.transformData);l.applyMatrix4(u),l.updateWorldMatrix()}});const a=new ka().parse();Ve.children.length===1&&Ve.children[0].isGroup&&(Ve.children[0].animations=a,Ve=Ve.children[0]),Ve.animations=a}parseModels(e,t,n){const s=new Map,r=ve.Objects.Model;for(const i in r){const a=parseInt(i),l=r[i],u=Ie.get(a);let h=this.buildSkeleton(u,e,a,l.attrName);if(!h){switch(l.attrType){case"Camera":h=this.createCamera(u);break;case"Light":h=this.createLight(u);break;case"Mesh":h=this.createMesh(u,t,n);break;case"NurbsCurve":h=this.createCurve(u,t);break;case"LimbNode":case"Root":h=new c.Bone;break;case"Null":default:h=new c.Group;break}h.name=l.attrName?c.PropertyBinding.sanitizeNodeName(l.attrName):"",h.ID=a}this.getTransformData(h,l),s.set(a,h)}return s}buildSkeleton(e,t,n,s){let r=null;return e.parents.forEach(function(i){for(const a in t){const l=t[a];l.rawBones.forEach(function(u,h){if(u.ID===i.ID){const d=r;r=new c.Bone,r.matrixWorld.copy(u.transformLink),r.name=s?c.PropertyBinding.sanitizeNodeName(s):"",r.ID=n,l.bones[h]=r,d!==null&&r.add(d)}})}}),r}createCamera(e){let t,n;if(e.children.forEach(function(s){const r=ve.Objects.NodeAttribute[s.ID];r!==void 0&&(n=r)}),n===void 0)t=new c.Object3D;else{let s=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(s=1);let r=1;n.NearPlane!==void 0&&(r=n.NearPlane.value/1e3);let i=1e3;n.FarPlane!==void 0&&(i=n.FarPlane.value/1e3);let a=window.innerWidth,l=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(a=n.AspectWidth.value,l=n.AspectHeight.value);const u=a/l;let h=45;n.FieldOfView!==void 0&&(h=n.FieldOfView.value);const d=n.FocalLength?n.FocalLength.value:null;switch(s){case 0:t=new c.PerspectiveCamera(h,u,r,i),d!==null&&t.setFocalLength(d);break;case 1:t=new c.OrthographicCamera(-a/2,a/2,l/2,-l/2,r,i);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+s+"."),t=new c.Object3D;break}}return t}createLight(e){let t,n;if(e.children.forEach(function(s){const r=ve.Objects.NodeAttribute[s.ID];r!==void 0&&(n=r)}),n===void 0)t=new c.Object3D;else{let s;n.LightType===void 0?s=0:s=n.LightType.value;let r=16777215;n.Color!==void 0&&(r=new c.Color().fromArray(n.Color.value));let i=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(i=0);let a=0;n.FarAttenuationEnd!==void 0&&(n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?a=0:a=n.FarAttenuationEnd.value);const l=1;switch(s){case 0:t=new c.PointLight(r,i,a,l);break;case 1:t=new c.DirectionalLight(r,i);break;case 2:let u=Math.PI/3;n.InnerAngle!==void 0&&(u=c.MathUtils.degToRad(n.InnerAngle.value));let h=0;n.OuterAngle!==void 0&&(h=c.MathUtils.degToRad(n.OuterAngle.value),h=Math.max(h,1)),t=new c.SpotLight(r,i,a,u,h,l);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new c.PointLight(r,i);break}n.CastShadows!==void 0&&n.CastShadows.value===1&&(t.castShadow=!0)}return t}createMesh(e,t,n){let s,r=null,i=null;const a=[];return e.children.forEach(function(l){t.has(l.ID)&&(r=t.get(l.ID)),n.has(l.ID)&&a.push(n.get(l.ID))}),a.length>1?i=a:a.length>0?i=a[0]:(i=new c.MeshPhongMaterial({color:13421772}),a.push(i)),"color"in r.attributes&&a.forEach(function(l){l.vertexColors=!0}),r.FBX_Deformer?(s=new c.SkinnedMesh(r,i),s.normalizeSkinWeights()):s=new c.Mesh(r,i),s}createCurve(e,t){const n=e.children.reduce(function(r,i){return t.has(i.ID)&&(r=t.get(i.ID)),r},null),s=new c.LineBasicMaterial({color:3342591,linewidth:1});return new c.Line(n,s)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=yr(t.RotationOrder.value):n.eulerOrder="ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&Ie.get(e.ID).children.forEach(function(s){if(s.relationship==="LookAtProperty"){const r=ve.Objects.Model[s.ID];if("Lcl_Translation"in r){const i=r.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(i),Ve.add(e.target)):e.lookAt(new c.Vector3().fromArray(i))}}})}bindSkeleton(e,t,n){const s=this.parsePoseNodes();for(const r in e){const i=e[r];Ie.get(parseInt(i.ID)).parents.forEach(function(l){if(t.has(l.ID)){const u=l.ID;Ie.get(u).parents.forEach(function(d){n.has(d.ID)&&n.get(d.ID).bind(new c.Skeleton(i.bones),s[d.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in ve.Objects){const t=ve.Objects.Pose;for(const n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){const s=t[n].PoseNode;Array.isArray(s)?s.forEach(function(r){e[r.Node]=new c.Matrix4().fromArray(r.Matrix.a)}):e[s.Node]=new c.Matrix4().fromArray(s.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in ve&&"AmbientColor"in ve.GlobalSettings){const e=ve.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],s=e[2];if(t!==0||n!==0||s!==0){const r=new c.Color(t,n,s);Ve.add(new c.AmbientLight(r,1))}}}}class Fa{parse(e){const t=new Map;if("Geometry"in ve.Objects){const n=ve.Objects.Geometry;for(const s in n){const r=Ie.get(parseInt(s)),i=this.parseGeometry(r,n[s],e);t.set(parseInt(s),i)}}return t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const s=n.skeletons,r=[],i=e.parents.map(function(d){return ve.Objects.Model[d.ID]});if(i.length===0)return;const a=e.children.reduce(function(d,y){return s[y.ID]!==void 0&&(d=s[y.ID]),d},null);e.children.forEach(function(d){n.morphTargets[d.ID]!==void 0&&r.push(n.morphTargets[d.ID])});const l=i[0],u={};"RotationOrder"in l&&(u.eulerOrder=yr(l.RotationOrder.value)),"InheritType"in l&&(u.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(u.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(u.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(u.scale=l.GeometricScaling.value);const h=gr(u);return this.genGeometry(t,a,r,h)}genGeometry(e,t,n,s){const r=new c.BufferGeometry;e.attrName&&(r.name=e.attrName);const i=this.parseGeoNode(e,t),a=this.genBuffers(i),l=new c.Float32BufferAttribute(a.vertex,3);if(l.applyMatrix4(s),r.setAttribute("position",l),a.colors.length>0&&r.setAttribute("color",new c.Float32BufferAttribute(a.colors,3)),t&&(r.setAttribute("skinIndex",new c.Uint16BufferAttribute(a.weightsIndices,4)),r.setAttribute("skinWeight",new c.Float32BufferAttribute(a.vertexWeights,4)),r.FBX_Deformer=t),a.normal.length>0){const u=new c.Matrix3().getNormalMatrix(s),h=new c.Float32BufferAttribute(a.normal,3);h.applyNormalMatrix(u),r.setAttribute("normal",h)}if(a.uvs.forEach(function(u,h){let d="uv"+(h+1).toString();h===0&&(d="uv"),r.setAttribute(d,new c.Float32BufferAttribute(a.uvs[h],2))}),i.material&&i.material.mappingType!=="AllSame"){let u=a.materialIndex[0],h=0;if(a.materialIndex.forEach(function(d,y){d!==u&&(r.addGroup(h,y-h,u),u=d,h=y)}),r.groups.length>0){const d=r.groups[r.groups.length-1],y=d.start+d.count;y!==a.materialIndex.length&&r.addGroup(y,a.materialIndex.length-y,u)}r.groups.length===0&&r.addGroup(0,a.materialIndex.length,a.materialIndex[0])}return this.addMorphTargets(r,e,n,s),r}parseGeoNode(e,t){const n={};if(n.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],n.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let s=0;for(;e.LayerElementUV[s];)e.LayerElementUV[s].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[s])),s++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(s,r){s.indices.forEach(function(i,a){n.weightTable[i]===void 0&&(n.weightTable[i]=[]),n.weightTable[i].push({id:r,weight:s.weights[a]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,s=0,r=!1,i=[],a=[],l=[],u=[],h=[],d=[];const y=this;return e.vertexIndices.forEach(function(g,x){let w,v=!1;g<0&&(g=g^-1,v=!0);let P=[],D=[];if(i.push(g*3,g*3+1,g*3+2),e.color){const S=mn(x,n,g,e.color);l.push(S[0],S[1],S[2])}if(e.skeleton){if(e.weightTable[g]!==void 0&&e.weightTable[g].forEach(function(S){D.push(S.weight),P.push(S.id)}),D.length>4){r||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),r=!0);const S=[0,0,0,0],_=[0,0,0,0];D.forEach(function(L,b){let C=L,m=P[b];_.forEach(function(M,p,I){if(C>M){I[p]=C,C=M;const F=S[p];S[p]=m,m=F}})}),P=S,D=_}for(;D.length<4;)D.push(0),P.push(0);for(let S=0;S<4;++S)h.push(D[S]),d.push(P[S])}if(e.normal){const S=mn(x,n,g,e.normal);a.push(S[0],S[1],S[2])}e.material&&e.material.mappingType!=="AllSame"&&(w=mn(x,n,g,e.material)[0]),e.uv&&e.uv.forEach(function(S,_){const L=mn(x,n,g,S);u[_]===void 0&&(u[_]=[]),u[_].push(L[0]),u[_].push(L[1])}),s++,v&&(y.genFace(t,e,i,w,a,l,u,h,d,s),n++,s=0,i=[],a=[],l=[],u=[],h=[],d=[])}),t}genFace(e,t,n,s,r,i,a,l,u,h){for(let d=2;d<h;d++)e.vertex.push(t.vertexPositions[n[0]]),e.vertex.push(t.vertexPositions[n[1]]),e.vertex.push(t.vertexPositions[n[2]]),e.vertex.push(t.vertexPositions[n[(d-1)*3]]),e.vertex.push(t.vertexPositions[n[(d-1)*3+1]]),e.vertex.push(t.vertexPositions[n[(d-1)*3+2]]),e.vertex.push(t.vertexPositions[n[d*3]]),e.vertex.push(t.vertexPositions[n[d*3+1]]),e.vertex.push(t.vertexPositions[n[d*3+2]]),t.skeleton&&(e.vertexWeights.push(l[0]),e.vertexWeights.push(l[1]),e.vertexWeights.push(l[2]),e.vertexWeights.push(l[3]),e.vertexWeights.push(l[(d-1)*4]),e.vertexWeights.push(l[(d-1)*4+1]),e.vertexWeights.push(l[(d-1)*4+2]),e.vertexWeights.push(l[(d-1)*4+3]),e.vertexWeights.push(l[d*4]),e.vertexWeights.push(l[d*4+1]),e.vertexWeights.push(l[d*4+2]),e.vertexWeights.push(l[d*4+3]),e.weightsIndices.push(u[0]),e.weightsIndices.push(u[1]),e.weightsIndices.push(u[2]),e.weightsIndices.push(u[3]),e.weightsIndices.push(u[(d-1)*4]),e.weightsIndices.push(u[(d-1)*4+1]),e.weightsIndices.push(u[(d-1)*4+2]),e.weightsIndices.push(u[(d-1)*4+3]),e.weightsIndices.push(u[d*4]),e.weightsIndices.push(u[d*4+1]),e.weightsIndices.push(u[d*4+2]),e.weightsIndices.push(u[d*4+3])),t.color&&(e.colors.push(i[0]),e.colors.push(i[1]),e.colors.push(i[2]),e.colors.push(i[(d-1)*3]),e.colors.push(i[(d-1)*3+1]),e.colors.push(i[(d-1)*3+2]),e.colors.push(i[d*3]),e.colors.push(i[d*3+1]),e.colors.push(i[d*3+2])),t.material&&t.material.mappingType!=="AllSame"&&(e.materialIndex.push(s),e.materialIndex.push(s),e.materialIndex.push(s)),t.normal&&(e.normal.push(r[0]),e.normal.push(r[1]),e.normal.push(r[2]),e.normal.push(r[(d-1)*3]),e.normal.push(r[(d-1)*3+1]),e.normal.push(r[(d-1)*3+2]),e.normal.push(r[d*3]),e.normal.push(r[d*3+1]),e.normal.push(r[d*3+2])),t.uv&&t.uv.forEach(function(y,g){e.uvs[g]===void 0&&(e.uvs[g]=[]),e.uvs[g].push(a[g][0]),e.uvs[g].push(a[g][1]),e.uvs[g].push(a[g][(d-1)*2]),e.uvs[g].push(a[g][(d-1)*2+1]),e.uvs[g].push(a[g][d*2]),e.uvs[g].push(a[g][d*2+1])})}addMorphTargets(e,t,n,s){if(n.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const r=this;n.forEach(function(i){i.rawTargets.forEach(function(a){const l=ve.Objects.Geometry[a.geoID];l!==void 0&&r.genMorphGeometry(e,t,l,s,a.name)})})}genMorphGeometry(e,t,n,s,r){const i=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],a=n.Vertices!==void 0?n.Vertices.a:[],l=n.Indexes!==void 0?n.Indexes.a:[],u=e.attributes.position.count*3,h=new Float32Array(u);for(let x=0;x<l.length;x++){const w=l[x]*3;h[w]=a[x*3],h[w+1]=a[x*3+1],h[w+2]=a[x*3+2]}const d={vertexIndices:i,vertexPositions:h},y=this.genBuffers(d),g=new c.Float32BufferAttribute(y.vertex,3);g.name=r||n.attrName,g.applyMatrix4(s),e.morphAttributes.position.push(g)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,s=e.Normals.a;let r=[];return n==="IndexToDirect"&&("NormalIndex"in e?r=e.NormalIndex.a:"NormalsIndex"in e&&(r=e.NormalsIndex.a)),{dataSize:3,buffer:s,indices:r,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,s=e.UV.a;let r=[];return n==="IndexToDirect"&&(r=e.UVIndex.a),{dataSize:2,buffer:s,indices:r,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,s=e.Colors.a;let r=[];return n==="IndexToDirect"&&(r=e.ColorIndex.a),{dataSize:4,buffer:s,indices:r,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if(t==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const s=e.Materials.a,r=[];for(let i=0;i<s.length;++i)r.push(i);return{dataSize:1,buffer:s,indices:r,mappingType:t,referenceType:n}}parseNurbsGeometry(e){if(fr===void 0)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new c.BufferGeometry;const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new c.BufferGeometry;const n=t-1,s=e.KnotVector.a,r=[],i=e.Points.a;for(let d=0,y=i.length;d<y;d+=4)r.push(new c.Vector4().fromArray(i,d));let a,l;if(e.Form==="Closed")r.push(r[0]);else if(e.Form==="Periodic"){a=n,l=s.length-1-a;for(let d=0;d<n;++d)r.push(r[d])}const h=new fr(n,s,r,a,l).getPoints(r.length*12);return new c.BufferGeometry().setFromPoints(h)}}class ka{parse(){const e=[],t=this.parseClips();if(t!==void 0)for(const n in t){const s=t[n],r=this.addClip(s);e.push(r)}return e}parseClips(){if(ve.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=ve.Objects.AnimationCurveNode,t=new Map;for(const n in e){const s=e[n];if(s.attrName.match(/S|R|T|DeformPercent/)!==null){const r={id:s.id,attr:s.attrName,curves:{}};t.set(r.id,r)}}return t}parseAnimationCurves(e){const t=ve.Objects.AnimationCurve;for(const n in t){const s={id:t[n].id,times:t[n].KeyTime.a.map(Va),values:t[n].KeyValueFloat.a},r=Ie.get(s.id);if(r!==void 0){const i=r.parents[0].ID,a=r.parents[0].relationship;a.match(/X/)?e.get(i).curves.x=s:a.match(/Y/)?e.get(i).curves.y=s:a.match(/Z/)?e.get(i).curves.z=s:a.match(/d|DeformPercent/)&&e.has(i)&&(e.get(i).curves.morph=s)}}}parseAnimationLayers(e){const t=ve.Objects.AnimationLayer,n=new Map;for(const s in t){const r=[],i=Ie.get(parseInt(s));i!==void 0&&(i.children.forEach(function(l,u){if(e.has(l.ID)){const h=e.get(l.ID);if(h.curves.x!==void 0||h.curves.y!==void 0||h.curves.z!==void 0){if(r[u]===void 0){const d=Ie.get(l.ID).parents.filter(function(y){return y.relationship!==void 0})[0].ID;if(d!==void 0){const y=ve.Objects.Model[d.toString()];if(y===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",l);return}const g={modelName:y.attrName?c.PropertyBinding.sanitizeNodeName(y.attrName):"",ID:y.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};Ve.traverse(function(x){x.ID===y.id&&(g.transform=x.matrix,x.userData.transformData&&(g.eulerOrder=x.userData.transformData.eulerOrder))}),g.transform||(g.transform=new c.Matrix4),"PreRotation"in y&&(g.preRotation=y.PreRotation.value),"PostRotation"in y&&(g.postRotation=y.PostRotation.value),r[u]=g}}r[u]&&(r[u][h.attr]=h)}else if(h.curves.morph!==void 0){if(r[u]===void 0){const d=Ie.get(l.ID).parents.filter(function(P){return P.relationship!==void 0})[0].ID,y=Ie.get(d).parents[0].ID,g=Ie.get(y).parents[0].ID,x=Ie.get(g).parents[0].ID,w=ve.Objects.Model[x],v={modelName:w.attrName?c.PropertyBinding.sanitizeNodeName(w.attrName):"",morphName:ve.Objects.Deformer[d].attrName};r[u]=v}r[u][h.attr]=h}}}),n.set(parseInt(s),r))}return n}parseAnimStacks(e){const t=ve.Objects.AnimationStack,n={};for(const s in t){const r=Ie.get(parseInt(s)).children;r.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const i=e.get(r[0].ID);n[s]={name:t[s].attrName,layer:i}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach(function(s){t=t.concat(n.generateTracks(s))}),new c.AnimationClip(e.name,-1,t)}generateTracks(e){const t=[];let n=new c.Vector3,s=new c.Quaternion,r=new c.Vector3;if(e.transform&&e.transform.decompose(n,s,r),n=n.toArray(),s=new c.Euler().setFromQuaternion(s,e.eulerOrder).toArray(),r=r.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const i=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");i!==void 0&&t.push(i)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const i=this.generateRotationTrack(e.modelName,e.R.curves,s,e.preRotation,e.postRotation,e.eulerOrder);i!==void 0&&t.push(i)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const i=this.generateVectorTrack(e.modelName,e.S.curves,r,"scale");i!==void 0&&t.push(i)}if(e.DeformPercent!==void 0){const i=this.generateMorphTrack(e);i!==void 0&&t.push(i)}return t}generateVectorTrack(e,t,n,s){const r=this.getTimesForAllAxes(t),i=this.getKeyframeTrackValues(r,t,n);return new c.VectorKeyframeTrack(e+"."+s,r,i)}generateRotationTrack(e,t,n,s,r,i){t.x!==void 0&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(c.MathUtils.degToRad)),t.y!==void 0&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(c.MathUtils.degToRad)),t.z!==void 0&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(c.MathUtils.degToRad));const a=this.getTimesForAllAxes(t),l=this.getKeyframeTrackValues(a,t,n);s!==void 0&&(s=s.map(c.MathUtils.degToRad),s.push(i),s=new c.Euler().fromArray(s),s=new c.Quaternion().setFromEuler(s)),r!==void 0&&(r=r.map(c.MathUtils.degToRad),r.push(i),r=new c.Euler().fromArray(r),r=new c.Quaternion().setFromEuler(r).invert());const u=new c.Quaternion,h=new c.Euler,d=[];for(let y=0;y<l.length;y+=3)h.set(l[y],l[y+1],l[y+2],i),u.setFromEuler(h),s!==void 0&&u.premultiply(s),r!==void 0&&u.multiply(r),u.toArray(d,y/3*4);return new c.QuaternionKeyframeTrack(e+".quaternion",a,d)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(r){return r/100}),s=Ve.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new c.NumberKeyframeTrack(e.modelName+".morphTargetInfluences["+s+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(n,s){return n-s}),t.length>1){let n=1,s=t[0];for(let r=1;r<t.length;r++){const i=t[r];i!==s&&(t[n]=i,s=i,n++)}t=t.slice(0,n)}return t}getKeyframeTrackValues(e,t,n){const s=n,r=[];let i=-1,a=-1,l=-1;return e.forEach(function(u){if(t.x&&(i=t.x.times.indexOf(u)),t.y&&(a=t.y.times.indexOf(u)),t.z&&(l=t.z.times.indexOf(u)),i!==-1){const h=t.x.values[i];r.push(h),s[0]=h}else r.push(s[0]);if(a!==-1){const h=t.y.values[a];r.push(h),s[1]=h}else r.push(s[1]);if(l!==-1){const h=t.z.values[l];r.push(h),s[2]=h}else r.push(s[2])}),r}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const n=e.values[t-1],s=e.values[t]-n,r=Math.abs(s);if(r>=180){const i=r/180,a=s/i;let l=n+a;const u=e.times[t-1],d=(e.times[t]-u)/i;let y=u+d;const g=[],x=[];for(;y<e.times[t];)g.push(y),y+=d,x.push(l),l+=a;e.times=vr(e.times,t,g),e.values=vr(e.values,t,x)}}}}class Ba{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new pr,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach(function(s,r){const i=s.match(/^[\s\t]*;/),a=s.match(/^[\s\t]*$/);if(i||a)return;const l=s.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),u=s.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),h=s.match("^\\t{"+(t.currentIndent-1)+"}}");l?t.parseNodeBegin(s,l):u?t.parseNodeProperty(s,u,n[++r]):h?t.popStack():s.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(s)}),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),s=t[2].split(",").map(function(l){return l.trim().replace(/^"/,"").replace(/"$/,"")}),r={name:n},i=this.parseNodeAttr(s),a=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,r):n in a?(n==="PoseNode"?a.PoseNode.push(r):a[n].id!==void 0&&(a[n]={},a[n][a[n].id]=a[n]),i.id!==""&&(a[n][i.id]=r)):typeof i.id=="number"?(a[n]={},a[n][i.id]=r):n!=="Properties70"&&(n==="PoseNode"?a[n]=[r]:a[n]=r),typeof i.id=="number"&&(r.id=i.id),i.name!==""&&(r.attrName=i.name),i.type!==""&&(r.attrType=i.type),this.pushStack(r)}parseNodeAttr(e){let t=e[0];e[0]!==""&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",s="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),s=e[2]),{id:t,name:n,type:s}}parseNodeProperty(e,t,n){let s=t[1].replace(/^"/,"").replace(/"$/,"").trim(),r=t[2].replace(/^"/,"").replace(/"$/,"").trim();s==="Content"&&r===","&&(r=n.replace(/"/g,"").replace(/,$/,"").trim());const i=this.getCurrentNode();if(i.name==="Properties70"){this.parseNodeSpecialProperty(e,s,r);return}if(s==="C"){const l=r.split(",").slice(1),u=parseInt(l[0]),h=parseInt(l[1]);let d=r.split(",").slice(3);d=d.map(function(y){return y.trim().replace(/^"/,"")}),s="connections",r=[u,h],Ga(r,d),i[s]===void 0&&(i[s]=[])}s==="Node"&&(i.id=r),s in i&&Array.isArray(i[s])?i[s].push(r):s!=="a"?i[s]=r:i.a=r,this.setCurrentProp(i,s),s==="a"&&r.slice(-1)!==","&&(i.a=$n(r))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=$n(t.a))}parseNodeSpecialProperty(e,t,n){const s=n.split('",').map(function(h){return h.trim().replace(/^\"/,"").replace(/\s/,"_")}),r=s[0],i=s[1],a=s[2],l=s[3];let u=s[4];switch(i){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":u=parseFloat(u);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":u=$n(u);break}this.getPrevNode()[r]={type:i,type2:a,flag:l,value:u},this.setCurrentProp(this.getPrevNode(),r)}}class Ua{parse(e){const t=new dr(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const s=new pr;for(;!this.endOfContent(t);){const r=this.parseNode(t,n);r!==null&&s.add(r.name,r)}return s}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},s=t>=7500?e.getUint64():e.getUint32(),r=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const i=e.getUint8(),a=e.getString(i);if(s===0)return null;const l=[];for(let y=0;y<r;y++)l.push(this.parseProperty(e));const u=l.length>0?l[0]:"",h=l.length>1?l[1]:"",d=l.length>2?l[2]:"";for(n.singleProperty=r===1&&e.getOffset()===s;s>e.getOffset();){const y=this.parseNode(e,t);y!==null&&this.parseSubNode(a,n,y)}return n.propertyList=l,typeof u=="number"&&(n.id=u),h!==""&&(n.attrName=h),d!==""&&(n.attrType=d),a!==""&&(n.name=a),n}parseSubNode(e,t,n){if(n.singleProperty===!0){const s=n.propertyList[0];Array.isArray(s)?(t[n.name]=n,n.a=s):t[n.name]=s}else if(e==="Connections"&&n.name==="C"){const s=[];n.propertyList.forEach(function(r,i){i!==0&&s.push(r)}),t.connections===void 0&&(t.connections=[]),t.connections.push(s)}else if(n.name==="Properties70")Object.keys(n).forEach(function(r){t[r]=n[r]});else if(e==="Properties70"&&n.name==="P"){let s=n.propertyList[0],r=n.propertyList[1];const i=n.propertyList[2],a=n.propertyList[3];let l;s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),r.indexOf("Lcl ")===0&&(r=r.replace("Lcl ","Lcl_")),r==="Color"||r==="ColorRGB"||r==="Vector"||r==="Vector3D"||r.indexOf("Lcl_")===0?l=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:l=n.propertyList[4],t[s]={type:r,type2:i,flag:a,value:l}}else t[n.name]===void 0?typeof n.id=="number"?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name==="PoseNode"?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const s=e.getUint32(),r=e.getUint32(),i=e.getUint32();if(r===0)switch(t){case"b":case"c":return e.getBooleanArray(s);case"d":return e.getFloat64Array(s);case"f":return e.getFloat32Array(s);case"i":return e.getInt32Array(s);case"l":return e.getInt64Array(s)}const a=Ao(new Uint8Array(e.getArrayBuffer(i))),l=new dr(a.buffer);switch(t){case"b":case"c":return l.getBooleanArray(s);case"d":return l.getFloat64Array(s);case"f":return l.getFloat32Array(s);case"i":return l.getInt32Array(s);case"l":return l.getInt64Array(s)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class dr{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t*4294967296+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=[];for(let s=0;s<e;s++)t[s]=this.getUint8();const n=t.indexOf(0);return n>=0&&(t=t.slice(0,n)),c.LoaderUtils.decodeText(new Uint8Array(t))}}class pr{add(e,t){this[e]=t}}function Na(o){const e="Kaydara FBX Binary \0";return o.byteLength>=e.length&&e===_r(o,0,e.length)}function za(o){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function n(s){const r=o[s-1];return o=o.slice(t+s),t++,r}for(let s=0;s<e.length;++s)if(n(1)===e[s])return!1;return!0}function mr(o){const e=/FBXVersion: (\d+)/,t=o.match(e);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function Va(o){return o/46186158e3}const Ra=[];function mn(o,e,t,n){let s;switch(n.mappingType){case"ByPolygonVertex":s=o;break;case"ByPolygon":s=e;break;case"ByVertice":s=t;break;case"AllSame":s=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}n.referenceType==="IndexToDirect"&&(s=n.indices[s]);const r=s*n.dataSize,i=r+n.dataSize;return ja(Ra,n.buffer,r,i)}const Hn=new c.Euler,Ot=new c.Vector3;function gr(o){const e=new c.Matrix4,t=new c.Matrix4,n=new c.Matrix4,s=new c.Matrix4,r=new c.Matrix4,i=new c.Matrix4,a=new c.Matrix4,l=new c.Matrix4,u=new c.Matrix4,h=new c.Matrix4,d=new c.Matrix4,y=new c.Matrix4,g=o.inheritType?o.inheritType:0;if(o.translation&&e.setPosition(Ot.fromArray(o.translation)),o.preRotation){const p=o.preRotation.map(c.MathUtils.degToRad);p.push(o.eulerOrder),t.makeRotationFromEuler(Hn.fromArray(p))}if(o.rotation){const p=o.rotation.map(c.MathUtils.degToRad);p.push(o.eulerOrder),n.makeRotationFromEuler(Hn.fromArray(p))}if(o.postRotation){const p=o.postRotation.map(c.MathUtils.degToRad);p.push(o.eulerOrder),s.makeRotationFromEuler(Hn.fromArray(p)),s.invert()}o.scale&&r.scale(Ot.fromArray(o.scale)),o.scalingOffset&&a.setPosition(Ot.fromArray(o.scalingOffset)),o.scalingPivot&&i.setPosition(Ot.fromArray(o.scalingPivot)),o.rotationOffset&&l.setPosition(Ot.fromArray(o.rotationOffset)),o.rotationPivot&&u.setPosition(Ot.fromArray(o.rotationPivot)),o.parentMatrixWorld&&(d.copy(o.parentMatrix),h.copy(o.parentMatrixWorld));const x=t.clone().multiply(n).multiply(s),w=new c.Matrix4;w.extractRotation(h);const v=new c.Matrix4;v.copyPosition(h);const P=v.clone().invert().multiply(h),D=w.clone().invert().multiply(P),S=r,_=new c.Matrix4;if(g===0)_.copy(w).multiply(x).multiply(D).multiply(S);else if(g===1)_.copy(w).multiply(D).multiply(x).multiply(S);else{const I=new c.Matrix4().scale(new c.Vector3().setFromMatrixScale(d)).clone().invert(),F=D.clone().multiply(I);_.copy(w).multiply(x).multiply(F).multiply(S)}const L=u.clone().invert(),b=i.clone().invert();let C=e.clone().multiply(l).multiply(u).multiply(t).multiply(n).multiply(s).multiply(L).multiply(a).multiply(i).multiply(r).multiply(b);const m=new c.Matrix4().copyPosition(C),M=h.clone().multiply(m);return y.copyPosition(M),C=y.clone().multiply(_),C.premultiply(h.invert()),C}function yr(o){o=o||0;const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return o===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[o]}function $n(o){return o.split(",").map(function(t){return parseFloat(t)})}function _r(o,e,t){return e===void 0&&(e=0),t===void 0&&(t=o.byteLength),c.LoaderUtils.decodeText(new Uint8Array(o,e,t))}function Ga(o,e){for(let t=0,n=o.length,s=e.length;t<s;t++,n++)o[n]=e[t]}function ja(o,e,t,n){for(let s=t,r=0;s<n;s++,r++)o[r]=e[s];return o}function vr(o,e,t){return o.slice(0,e).concat(t).concat(o.slice(e))}var Ea=Object.defineProperty,Ya=(o,e,t)=>e in o?Ea(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,es=(o,e,t)=>(Ya(o,typeof e!="symbol"?e+"":e,t),t);class Xa extends c.Loader{constructor(e){super(e)}load(e,t,n,s){const r=new c.FileLoader(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,i=>{if(typeof i!="string")throw new Error("unsupported data type");const a=JSON.parse(i),l=this.parse(a);t&&t(l)},n,s)}loadAsync(e,t){return super.loadAsync(e,t)}parse(e){return new ts(e)}}class ts{constructor(e){es(this,"data"),this.data=e}generateShapes(e,t=100,n){const s=[],r={letterSpacing:0,lineHeight:1,...n},i=Wa(e,t,this.data,r);for(let a=0,l=i.length;a<l;a++)Array.prototype.push.apply(s,i[a].toShapes(!1));return s}}es(ts,"isFont"),es(ts,"type");function Wa(o,e,t,n){const s=Array.from(o),r=e/t.resolution,i=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*r,a=[];let l=0,u=0;for(let h=0;h<s.length;h++){const d=s[h];if(d===`
|
|
93
|
-
`)l=0,u-=i*n.lineHeight;else{const
|
|
94
|
-
`,
|
|
95
|
-
`;p=
|
|
96
|
-
`,p.charAt(0)==="#"){
|
|
97
|
-
`;continue}if((I=p.match(L))&&(M.gamma=parseFloat(I[1])),(I=p.match(b))&&(M.exposure=parseFloat(I[1])),(I=p.match(C))&&(M.valid|=2,M.format=I[1]),(I=p.match(m))&&(M.valid|=4,M.height=parseInt(I[1],10),M.width=parseInt(I[2],10)),M.valid&2&&M.valid&4)break}return M.valid&2?M.valid&4?M:a(3,"missing image size specifier"):a(3,"missing format specifier")},x=function(S,_,L){const b=_;if(b<8||b>32767||S[0]!==2||S[1]!==2||S[2]&128)return new Uint8Array(S);if(b!==(S[2]<<8|S[3]))return a(3,"wrong scanline width");const C=new Uint8Array(4*_*L);if(!C.length)return a(4,"unable to allocate buffer space");let m=0,M=0;const p=4*b,I=new Uint8Array(4),F=new Uint8Array(p);let J=L;for(;J>0&&M<S.byteLength;){if(M+4>S.byteLength)return a(1);if(I[0]=S[M++],I[1]=S[M++],I[2]=S[M++],I[3]=S[M++],I[0]!=2||I[1]!=2||(I[2]<<8|I[3])!=b)return a(3,"bad rgbe scanline format");let G=0,Q;for(;G<p&&M<S.byteLength;){Q=S[M++];const Z=Q>128;if(Z&&(Q-=128),Q===0||G+Q>p)return a(3,"bad scanline data");if(Z){const X=S[M++];for(let ne=0;ne<Q;ne++)F[G++]=X}else F.set(S.subarray(M,M+Q),G),G+=Q,M+=Q}const K=b;for(let Z=0;Z<K;Z++){let X=0;C[m]=F[Z+X],X+=b,C[m+1]=F[Z+X],X+=b,C[m+2]=F[Z+X],X+=b,C[m+3]=F[Z+X],m+=4}J--}return C},w=function(S,_,L,b){const C=S[_+3],m=Math.pow(2,C-128)/255;L[b+0]=S[_+0]*m,L[b+1]=S[_+1]*m,L[b+2]=S[_+2]*m,L[b+3]=1},v=function(S,_,L,b){const C=S[_+3],m=Math.pow(2,C-128)/255;L[b+0]=c.DataUtils.toHalfFloat(Math.min(S[_+0]*m,65504)),L[b+1]=c.DataUtils.toHalfFloat(Math.min(S[_+1]*m,65504)),L[b+2]=c.DataUtils.toHalfFloat(Math.min(S[_+2]*m,65504)),L[b+3]=c.DataUtils.toHalfFloat(1)},P=new Uint8Array(e);P.pos=0;const D=g(P);if(D!==-1){const S=D.width,_=D.height,L=x(P.subarray(P.pos),S,_);if(L!==-1){let b,C,m;switch(this.type){case c.FloatType:m=L.length/4;const M=new Float32Array(m*4);for(let I=0;I<m;I++)w(L,I*4,M,I*4);b=M,C=c.FloatType;break;case c.HalfFloatType:m=L.length/4;const p=new Uint16Array(m*4);for(let I=0;I<m;I++)v(L,I*4,p,I*4);b=p,C=c.HalfFloatType;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type);break}return{width:S,height:_,data:b,header:D.string,gamma:D.gamma,exposure:D.exposure,type:C}}}return null}setDataType(e){return this.type=e,this}load(e,t,n,s){function r(i,a){switch(i.type){case c.FloatType:case c.HalfFloatType:"colorSpace"in i?i.colorSpace="srgb-linear":i.encoding=3e3,i.minFilter=c.LinearFilter,i.magFilter=c.LinearFilter,i.generateMipmaps=!1,i.flipY=!0;break}t&&t(i,a)}return super.load(e,r,n,s)}}class Wt extends c.Loader{constructor(e){super(e),this.defaultDPI=90,this.defaultUnit="px"}load(e,t,n,s){const r=this,i=new c.FileLoader(r.manager);i.setPath(r.path),i.setRequestHeader(r.requestHeader),i.setWithCredentials(r.withCredentials),i.load(e,function(a){try{t(r.parse(a))}catch(l){s?s(l):console.error(l),r.manager.itemError(e)}},n,s)}parse(e){const t=this;function n(j,z){if(j.nodeType!==1)return;const A=_(j);let V=!0,ee=null;switch(j.nodeName){case"svg":break;case"style":r(j);break;case"g":z=x(j,z);break;case"path":z=x(j,z),j.hasAttribute("d")&&(ee=s(j));break;case"rect":z=x(j,z),ee=l(j);break;case"polygon":z=x(j,z),ee=u(j);break;case"polyline":z=x(j,z),ee=h(j);break;case"circle":z=x(j,z),ee=d(j);break;case"ellipse":z=x(j,z),ee=y(j);break;case"line":z=x(j,z),ee=g(j);break;case"defs":V=!1;break;case"mask":V=!1;break;case"use":z=x(j,z);const N=j.href.baseVal.substring(1),R=j.viewportElement.getElementById(N);R?n(R,z):console.warn("SVGLoader: 'use node' references non-existent node id: "+N);break}if(ee&&(z.fill!==void 0&&z.fill!=="none"&&ee.color.setStyle(z.fill),b(ee,ne),p.push(ee),ee.userData={node:j,style:z}),V){const N=j.childNodes;for(let R=0;R<N.length;R++)n(N[R],z)}A&&(F.pop(),F.length>0?ne.copy(F[F.length-1]):ne.identity())}function s(j){const z=new c.ShapePath,A=new c.Vector2,V=new c.Vector2,ee=new c.Vector2;let N=!0,R=!1;const O=j.getAttribute("d").match(/[a-df-z][^a-df-z]*/gi);for(let k=0,E=O.length;k<E;k++){const q=O[k],W=q.charAt(0),te=q.substr(1).trim();N===!0&&(R=!0,N=!1);let U;switch(W){case"M":U=v(te);for(let B=0,oe=U.length;B<oe;B+=2)A.x=U[B+0],A.y=U[B+1],V.x=A.x,V.y=A.y,B===0?z.moveTo(A.x,A.y):z.lineTo(A.x,A.y),B===0&&ee.copy(A);break;case"H":U=v(te);for(let B=0,oe=U.length;B<oe;B++)A.x=U[B],V.x=A.x,V.y=A.y,z.lineTo(A.x,A.y),B===0&&R===!0&&ee.copy(A);break;case"V":U=v(te);for(let B=0,oe=U.length;B<oe;B++)A.y=U[B],V.x=A.x,V.y=A.y,z.lineTo(A.x,A.y),B===0&&R===!0&&ee.copy(A);break;case"L":U=v(te);for(let B=0,oe=U.length;B<oe;B+=2)A.x=U[B+0],A.y=U[B+1],V.x=A.x,V.y=A.y,z.lineTo(A.x,A.y),B===0&&R===!0&&ee.copy(A);break;case"C":U=v(te);for(let B=0,oe=U.length;B<oe;B+=6)z.bezierCurveTo(U[B+0],U[B+1],U[B+2],U[B+3],U[B+4],U[B+5]),V.x=U[B+2],V.y=U[B+3],A.x=U[B+4],A.y=U[B+5],B===0&&R===!0&&ee.copy(A);break;case"S":U=v(te);for(let B=0,oe=U.length;B<oe;B+=4)z.bezierCurveTo(w(A.x,V.x),w(A.y,V.y),U[B+0],U[B+1],U[B+2],U[B+3]),V.x=U[B+0],V.y=U[B+1],A.x=U[B+2],A.y=U[B+3],B===0&&R===!0&&ee.copy(A);break;case"Q":U=v(te);for(let B=0,oe=U.length;B<oe;B+=4)z.quadraticCurveTo(U[B+0],U[B+1],U[B+2],U[B+3]),V.x=U[B+0],V.y=U[B+1],A.x=U[B+2],A.y=U[B+3],B===0&&R===!0&&ee.copy(A);break;case"T":U=v(te);for(let B=0,oe=U.length;B<oe;B+=2){const ce=w(A.x,V.x),ge=w(A.y,V.y);z.quadraticCurveTo(ce,ge,U[B+0],U[B+1]),V.x=ce,V.y=ge,A.x=U[B+0],A.y=U[B+1],B===0&&R===!0&&ee.copy(A)}break;case"A":U=v(te,[3,4],7);for(let B=0,oe=U.length;B<oe;B+=7){if(U[B+5]==A.x&&U[B+6]==A.y)continue;const ce=A.clone();A.x=U[B+5],A.y=U[B+6],V.x=A.x,V.y=A.y,i(z,U[B],U[B+1],U[B+2],U[B+3],U[B+4],ce,A),B===0&&R===!0&&ee.copy(A)}break;case"m":U=v(te);for(let B=0,oe=U.length;B<oe;B+=2)A.x+=U[B+0],A.y+=U[B+1],V.x=A.x,V.y=A.y,B===0?z.moveTo(A.x,A.y):z.lineTo(A.x,A.y),B===0&&ee.copy(A);break;case"h":U=v(te);for(let B=0,oe=U.length;B<oe;B++)A.x+=U[B],V.x=A.x,V.y=A.y,z.lineTo(A.x,A.y),B===0&&R===!0&&ee.copy(A);break;case"v":U=v(te);for(let B=0,oe=U.length;B<oe;B++)A.y+=U[B],V.x=A.x,V.y=A.y,z.lineTo(A.x,A.y),B===0&&R===!0&&ee.copy(A);break;case"l":U=v(te);for(let B=0,oe=U.length;B<oe;B+=2)A.x+=U[B+0],A.y+=U[B+1],V.x=A.x,V.y=A.y,z.lineTo(A.x,A.y),B===0&&R===!0&&ee.copy(A);break;case"c":U=v(te);for(let B=0,oe=U.length;B<oe;B+=6)z.bezierCurveTo(A.x+U[B+0],A.y+U[B+1],A.x+U[B+2],A.y+U[B+3],A.x+U[B+4],A.y+U[B+5]),V.x=A.x+U[B+2],V.y=A.y+U[B+3],A.x+=U[B+4],A.y+=U[B+5],B===0&&R===!0&&ee.copy(A);break;case"s":U=v(te);for(let B=0,oe=U.length;B<oe;B+=4)z.bezierCurveTo(w(A.x,V.x),w(A.y,V.y),A.x+U[B+0],A.y+U[B+1],A.x+U[B+2],A.y+U[B+3]),V.x=A.x+U[B+0],V.y=A.y+U[B+1],A.x+=U[B+2],A.y+=U[B+3],B===0&&R===!0&&ee.copy(A);break;case"q":U=v(te);for(let B=0,oe=U.length;B<oe;B+=4)z.quadraticCurveTo(A.x+U[B+0],A.y+U[B+1],A.x+U[B+2],A.y+U[B+3]),V.x=A.x+U[B+0],V.y=A.y+U[B+1],A.x+=U[B+2],A.y+=U[B+3],B===0&&R===!0&&ee.copy(A);break;case"t":U=v(te);for(let B=0,oe=U.length;B<oe;B+=2){const ce=w(A.x,V.x),ge=w(A.y,V.y);z.quadraticCurveTo(ce,ge,A.x+U[B+0],A.y+U[B+1]),V.x=ce,V.y=ge,A.x=A.x+U[B+0],A.y=A.y+U[B+1],B===0&&R===!0&&ee.copy(A)}break;case"a":U=v(te,[3,4],7);for(let B=0,oe=U.length;B<oe;B+=7){if(U[B+5]==0&&U[B+6]==0)continue;const ce=A.clone();A.x+=U[B+5],A.y+=U[B+6],V.x=A.x,V.y=A.y,i(z,U[B],U[B+1],U[B+2],U[B+3],U[B+4],ce,A),B===0&&R===!0&&ee.copy(A)}break;case"Z":case"z":z.currentPath.autoClose=!0,z.currentPath.curves.length>0&&(A.copy(ee),z.currentPath.currentPoint.copy(A),N=!0);break;default:console.warn(q)}R=!1}return z}function r(j){if(!(!j.sheet||!j.sheet.cssRules||!j.sheet.cssRules.length))for(let z=0;z<j.sheet.cssRules.length;z++){const A=j.sheet.cssRules[z];if(A.type!==1)continue;const V=A.selectorText.split(/,/gm).filter(Boolean).map(ee=>ee.trim());for(let ee=0;ee<V.length;ee++)I[V[ee]]=Object.assign(I[V[ee]]||{},A.style)}}function i(j,z,A,V,ee,N,R,T){if(z==0||A==0){j.lineTo(T.x,T.y);return}V=V*Math.PI/180,z=Math.abs(z),A=Math.abs(A);const O=(R.x-T.x)/2,k=(R.y-T.y)/2,E=Math.cos(V)*O+Math.sin(V)*k,q=-Math.sin(V)*O+Math.cos(V)*k;let W=z*z,te=A*A;const U=E*E,B=q*q,oe=U/W+B/te;if(oe>1){const Gt=Math.sqrt(oe);z=Gt*z,A=Gt*A,W=z*z,te=A*A}const ce=W*B+te*U,ge=(W*te-ce)/ce;let _e=Math.sqrt(Math.max(0,ge));ee===N&&(_e=-_e);const xe=_e*z*q/A,Oe=-_e*A*E/z,at=Math.cos(V)*xe-Math.sin(V)*Oe+(R.x+T.x)/2,an=Math.sin(V)*xe+Math.cos(V)*Oe+(R.y+T.y)/2,Rt=a(1,0,(E-xe)/z,(q-Oe)/A),Ke=a((E-xe)/z,(q-Oe)/A,(-E-xe)/z,(-q-Oe)/A)%(Math.PI*2);j.currentPath.absellipse(at,an,z,A,Rt,Rt+Ke,N===0,V)}function a(j,z,A,V){const ee=j*A+z*V,N=Math.sqrt(j*j+z*z)*Math.sqrt(A*A+V*V);let R=Math.acos(Math.max(-1,Math.min(1,ee/N)));return j*V-z*A<0&&(R=-R),R}function l(j){const z=S(j.getAttribute("x")||0),A=S(j.getAttribute("y")||0),V=S(j.getAttribute("rx")||j.getAttribute("ry")||0),ee=S(j.getAttribute("ry")||j.getAttribute("rx")||0),N=S(j.getAttribute("width")),R=S(j.getAttribute("height")),T=1-.551915024494,O=new c.ShapePath;return O.moveTo(z+V,A),O.lineTo(z+N-V,A),(V!==0||ee!==0)&&O.bezierCurveTo(z+N-V*T,A,z+N,A+ee*T,z+N,A+ee),O.lineTo(z+N,A+R-ee),(V!==0||ee!==0)&&O.bezierCurveTo(z+N,A+R-ee*T,z+N-V*T,A+R,z+N-V,A+R),O.lineTo(z+V,A+R),(V!==0||ee!==0)&&O.bezierCurveTo(z+V*T,A+R,z,A+R-ee*T,z,A+R-ee),O.lineTo(z,A+ee),(V!==0||ee!==0)&&O.bezierCurveTo(z,A+ee*T,z+V*T,A,z+V,A),O}function u(j){function z(N,R,T){const O=S(R),k=S(T);ee===0?V.moveTo(O,k):V.lineTo(O,k),ee++}const A=/(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g,V=new c.ShapePath;let ee=0;return j.getAttribute("points").replace(A,z),V.currentPath.autoClose=!0,V}function h(j){function z(N,R,T){const O=S(R),k=S(T);ee===0?V.moveTo(O,k):V.lineTo(O,k),ee++}const A=/(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g,V=new c.ShapePath;let ee=0;return j.getAttribute("points").replace(A,z),V.currentPath.autoClose=!1,V}function d(j){const z=S(j.getAttribute("cx")||0),A=S(j.getAttribute("cy")||0),V=S(j.getAttribute("r")||0),ee=new c.Path;ee.absarc(z,A,V,0,Math.PI*2);const N=new c.ShapePath;return N.subPaths.push(ee),N}function y(j){const z=S(j.getAttribute("cx")||0),A=S(j.getAttribute("cy")||0),V=S(j.getAttribute("rx")||0),ee=S(j.getAttribute("ry")||0),N=new c.Path;N.absellipse(z,A,V,ee,0,Math.PI*2);const R=new c.ShapePath;return R.subPaths.push(N),R}function g(j){const z=S(j.getAttribute("x1")||0),A=S(j.getAttribute("y1")||0),V=S(j.getAttribute("x2")||0),ee=S(j.getAttribute("y2")||0),N=new c.ShapePath;return N.moveTo(z,A),N.lineTo(V,ee),N.currentPath.autoClose=!1,N}function x(j,z){z=Object.assign({},z);let A={};if(j.hasAttribute("class")){const R=j.getAttribute("class").split(/\s/).filter(Boolean).map(T=>T.trim());for(let T=0;T<R.length;T++)A=Object.assign(A,I["."+R[T]])}j.hasAttribute("id")&&(A=Object.assign(A,I["#"+j.getAttribute("id")]));function V(R,T,O){O===void 0&&(O=function(E){return E.startsWith("url")&&console.warn("SVGLoader: url access in attributes is not implemented."),E}),j.hasAttribute(R)&&(z[T]=O(j.getAttribute(R))),A[R]&&(z[T]=O(A[R])),j.style&&j.style[R]!==""&&(z[T]=O(j.style[R]))}function ee(R){return Math.max(0,Math.min(1,S(R)))}function N(R){return Math.max(0,S(R))}return V("fill","fill"),V("fill-opacity","fillOpacity",ee),V("fill-rule","fillRule"),V("opacity","opacity",ee),V("stroke","stroke"),V("stroke-opacity","strokeOpacity",ee),V("stroke-width","strokeWidth",N),V("stroke-linejoin","strokeLineJoin"),V("stroke-linecap","strokeLineCap"),V("stroke-miterlimit","strokeMiterLimit",N),V("visibility","visibility"),z}function w(j,z){return j-(z-j)}function v(j,z,A){if(typeof j!="string")throw new TypeError("Invalid input: "+typeof j);const V={SEPARATOR:/[ \t\r\n\,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/[\d]/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/},ee=0,N=1,R=2,T=3;let O=ee,k=!0,E="",q="";const W=[];function te(ce,ge,_e){const xe=new SyntaxError('Unexpected character "'+ce+'" at index '+ge+".");throw xe.partial=_e,xe}function U(){E!==""&&(q===""?W.push(Number(E)):W.push(Number(E)*Math.pow(10,Number(q)))),E="",q=""}let B;const oe=j.length;for(let ce=0;ce<oe;ce++){if(B=j[ce],Array.isArray(z)&&z.includes(W.length%A)&&V.FLAGS.test(B)){O=N,E=B,U();continue}if(O===ee){if(V.WHITESPACE.test(B))continue;if(V.DIGIT.test(B)||V.SIGN.test(B)){O=N,E=B;continue}if(V.POINT.test(B)){O=R,E=B;continue}V.COMMA.test(B)&&(k&&te(B,ce,W),k=!0)}if(O===N){if(V.DIGIT.test(B)){E+=B;continue}if(V.POINT.test(B)){E+=B,O=R;continue}if(V.EXP.test(B)){O=T;continue}V.SIGN.test(B)&&E.length===1&&V.SIGN.test(E[0])&&te(B,ce,W)}if(O===R){if(V.DIGIT.test(B)){E+=B;continue}if(V.EXP.test(B)){O=T;continue}V.POINT.test(B)&&E[E.length-1]==="."&&te(B,ce,W)}if(O===T){if(V.DIGIT.test(B)){q+=B;continue}if(V.SIGN.test(B)){if(q===""){q+=B;continue}q.length===1&&V.SIGN.test(q)&&te(B,ce,W)}}V.WHITESPACE.test(B)?(U(),O=ee,k=!1):V.COMMA.test(B)?(U(),O=ee,k=!0):V.SIGN.test(B)?(U(),O=N,E=B):V.POINT.test(B)?(U(),O=R,E=B):te(B,ce,W)}return U(),W}const P=["mm","cm","in","pt","pc","px"],D={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function S(j){let z="px";if(typeof j=="string"||j instanceof String)for(let V=0,ee=P.length;V<ee;V++){const N=P[V];if(j.endsWith(N)){z=N,j=j.substring(0,j.length-N.length);break}}let A;return z==="px"&&t.defaultUnit!=="px"?A=D.in[t.defaultUnit]/t.defaultDPI:(A=D[z][t.defaultUnit],A<0&&(A=D[z].in*t.defaultDPI)),A*parseFloat(j)}function _(j){if(!(j.hasAttribute("transform")||j.nodeName==="use"&&(j.hasAttribute("x")||j.hasAttribute("y"))))return null;const z=L(j);return F.length>0&&z.premultiply(F[F.length-1]),ne.copy(z),F.push(z),z}function L(j){const z=new c.Matrix3,A=J;if(j.nodeName==="use"&&(j.hasAttribute("x")||j.hasAttribute("y"))){const V=S(j.getAttribute("x")),ee=S(j.getAttribute("y"));z.translate(V,ee)}if(j.hasAttribute("transform")){const V=j.getAttribute("transform").split(")");for(let ee=V.length-1;ee>=0;ee--){const N=V[ee].trim();if(N==="")continue;const R=N.indexOf("("),T=N.length;if(R>0&&R<T){const O=N.substr(0,R),k=v(N.substr(R+1,T-R-1));switch(A.identity(),O){case"translate":if(k.length>=1){const E=k[0];let q=E;k.length>=2&&(q=k[1]),A.translate(E,q)}break;case"rotate":if(k.length>=1){let E=0,q=0,W=0;E=-k[0]*Math.PI/180,k.length>=3&&(q=k[1],W=k[2]),G.identity().translate(-q,-W),Q.identity().rotate(E),K.multiplyMatrices(Q,G),G.identity().translate(q,W),A.multiplyMatrices(G,K)}break;case"scale":if(k.length>=1){const E=k[0];let q=E;k.length>=2&&(q=k[1]),A.scale(E,q)}break;case"skewX":k.length===1&&A.set(1,Math.tan(k[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":k.length===1&&A.set(1,0,0,Math.tan(k[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":k.length===6&&A.set(k[0],k[2],k[4],k[1],k[3],k[5],0,0,1);break}}z.premultiply(A)}}return z}function b(j,z){function A(N){X.set(N.x,N.y,1).applyMatrix3(z),N.set(X.x,X.y)}const V=C(z),ee=j.subPaths;for(let N=0,R=ee.length;N<R;N++){const O=ee[N].curves;for(let k=0;k<O.length;k++){const E=O[k];E.isLineCurve?(A(E.v1),A(E.v2)):E.isCubicBezierCurve?(A(E.v0),A(E.v1),A(E.v2),A(E.v3)):E.isQuadraticBezierCurve?(A(E.v0),A(E.v1),A(E.v2)):E.isEllipseCurve&&(V&&console.warn("SVGLoader: Elliptic arc or ellipse rotation or skewing is not implemented."),Z.set(E.aX,E.aY),A(Z),E.aX=Z.x,E.aY=Z.y,E.xRadius*=m(z),E.yRadius*=M(z))}}}function C(j){return j.elements[1]!==0||j.elements[3]!==0}function m(j){const z=j.elements;return Math.sqrt(z[0]*z[0]+z[1]*z[1])}function M(j){const z=j.elements;return Math.sqrt(z[3]*z[3]+z[4]*z[4])}const p=[],I={},F=[],J=new c.Matrix3,G=new c.Matrix3,Q=new c.Matrix3,K=new c.Matrix3,Z=new c.Vector2,X=new c.Vector3,ne=new c.Matrix3,se=new DOMParser().parseFromString(e,"image/svg+xml");return n(se.documentElement,{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4}),{paths:p,xml:se.documentElement}}static createShapes(e){const n={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},s={loc:n.ORIGIN,t:0};function r(v,P,D,S){const _=v.x,L=P.x,b=D.x,C=S.x,m=v.y,M=P.y,p=D.y,I=S.y,F=(C-b)*(m-p)-(I-p)*(_-b),J=(L-_)*(m-p)-(M-m)*(_-b),G=(I-p)*(L-_)-(C-b)*(M-m),Q=F/G,K=J/G;if(G===0&&F!==0||Q<=0||Q>=1||K<0||K>1)return null;if(F===0&&G===0){for(let Z=0;Z<2;Z++)if(i(Z===0?D:S,v,P),s.loc==n.ORIGIN){const X=Z===0?D:S;return{x:X.x,y:X.y,t:s.t}}else if(s.loc==n.BETWEEN){const X=+(_+s.t*(L-_)).toPrecision(10),ne=+(m+s.t*(M-m)).toPrecision(10);return{x:X,y:ne,t:s.t}}return null}else{for(let ne=0;ne<2;ne++)if(i(ne===0?D:S,v,P),s.loc==n.ORIGIN){const se=ne===0?D:S;return{x:se.x,y:se.y,t:s.t}}const Z=+(_+Q*(L-_)).toPrecision(10),X=+(m+Q*(M-m)).toPrecision(10);return{x:Z,y:X,t:Q}}}function i(v,P,D){const S=D.x-P.x,_=D.y-P.y,L=v.x-P.x,b=v.y-P.y,C=S*b-L*_;if(v.x===P.x&&v.y===P.y){s.loc=n.ORIGIN,s.t=0;return}if(v.x===D.x&&v.y===D.y){s.loc=n.DESTINATION,s.t=1;return}if(C<-Number.EPSILON){s.loc=n.LEFT;return}if(C>Number.EPSILON){s.loc=n.RIGHT;return}if(S*L<0||_*b<0){s.loc=n.BEHIND;return}if(Math.sqrt(S*S+_*_)<Math.sqrt(L*L+b*b)){s.loc=n.BEYOND;return}let m;S!==0?m=L/S:m=b/_,s.loc=n.BETWEEN,s.t=m}function a(v,P){const D=[],S=[];for(let _=1;_<v.length;_++){const L=v[_-1],b=v[_];for(let C=1;C<P.length;C++){const m=P[C-1],M=P[C],p=r(L,b,m,M);p!==null&&D.find(I=>I.t<=p.t+Number.EPSILON&&I.t>=p.t-Number.EPSILON)===void 0&&(D.push(p),S.push(new c.Vector2(p.x,p.y)))}}return S}function l(v,P,D){const S=new c.Vector2;P.getCenter(S);const _=[];return D.forEach(L=>{L.boundingBox.containsPoint(S)&&a(v,L.points).forEach(C=>{_.push({identifier:L.identifier,isCW:L.isCW,point:C})})}),_.sort((L,b)=>L.point.x-b.point.x),_}function u(v,P,D,S,_){(_==null||_==="")&&(_="nonzero");const L=new c.Vector2;v.boundingBox.getCenter(L);const b=[new c.Vector2(D,L.y),new c.Vector2(S,L.y)],C=l(b,v.boundingBox,P);C.sort((J,G)=>J.point.x-G.point.x);const m=[],M=[];C.forEach(J=>{J.identifier===v.identifier?m.push(J):M.push(J)});const p=m[0].point.x,I=[];let F=0;for(;F<M.length&&M[F].point.x<p;)I.length>0&&I[I.length-1]===M[F].identifier?I.pop():I.push(M[F].identifier),F++;if(I.push(v.identifier),_==="evenodd"){const J=I.length%2===0,G=I[I.length-2];return{identifier:v.identifier,isHole:J,for:G}}else if(_==="nonzero"){let J=!0,G=null,Q=null;for(let K=0;K<I.length;K++){const Z=I[K];J?(Q=P[Z].isCW,J=!1,G=Z):Q!==P[Z].isCW&&(Q=P[Z].isCW,J=!0)}return{identifier:v.identifier,isHole:J,for:G}}else console.warn('fill-rule: "'+_+'" is currently not implemented.')}let h=0,d=999999999,y=-999999999,g=e.subPaths.map(v=>{const P=v.getPoints();let D=-999999999,S=999999999,_=-999999999,L=999999999;for(let b=0;b<P.length;b++){const C=P[b];C.y>D&&(D=C.y),C.y<S&&(S=C.y),C.x>_&&(_=C.x),C.x<L&&(L=C.x)}return y<=_&&(y=_+1),d>=L&&(d=L-1),{curves:v.curves,points:P,isCW:c.ShapeUtils.isClockWise(P),identifier:h++,boundingBox:new c.Box2(new c.Vector2(L,S),new c.Vector2(_,D))}});g=g.filter(v=>v.points.length>1);const x=g.map(v=>u(v,g,d,y,e.userData.style.fillRule)),w=[];return g.forEach(v=>{if(!x[v.identifier].isHole){const D=new c.Shape;D.curves=v.curves,x.filter(_=>_.isHole&&_.for===v.identifier).forEach(_=>{const L=g[_.identifier],b=new c.Path;b.curves=L.curves,D.holes.push(b)}),w.push(D)}}),w}static getStrokeStyle(e,t,n,s,r){return e=e!==void 0?e:1,t=t!==void 0?t:"#000",n=n!==void 0?n:"miter",s=s!==void 0?s:"butt",r=r!==void 0?r:4,{strokeColor:t,strokeWidth:e,strokeLineJoin:n,strokeLineCap:s,strokeMiterLimit:r}}static pointsToStroke(e,t,n,s){const r=[],i=[],a=[];if(Wt.pointsToStrokeWithBuffers(e,t,n,s,r,i,a)===0)return null;const l=new c.BufferGeometry;return l.setAttribute("position",new c.Float32BufferAttribute(r,3)),l.setAttribute("normal",new c.Float32BufferAttribute(i,3)),l.setAttribute("uv",new c.Float32BufferAttribute(a,2)),l}static pointsToStrokeWithBuffers(e,t,n,s,r,i,a,l){const u=new c.Vector2,h=new c.Vector2,d=new c.Vector2,y=new c.Vector2,g=new c.Vector2,x=new c.Vector2,w=new c.Vector2,v=new c.Vector2,P=new c.Vector2,D=new c.Vector2,S=new c.Vector2,_=new c.Vector2,L=new c.Vector2,b=new c.Vector2,C=new c.Vector2,m=new c.Vector2,M=new c.Vector2;n=n!==void 0?n:12,s=s!==void 0?s:.001,l=l!==void 0?l:0,e=q(e);const p=e.length;if(p<2)return 0;const I=e[0].equals(e[p-1]);let F,J=e[0],G;const Q=t.strokeWidth/2,K=1/(p-1);let Z=0,X,ne,se,ue,j=!1,z=0,A=l*3,V=l*2;ee(e[0],e[1],u).multiplyScalar(Q),v.copy(e[0]).sub(u),P.copy(e[0]).add(u),D.copy(v),S.copy(P);for(let W=1;W<p;W++){F=e[W],W===p-1?I?G=e[1]:G=void 0:G=e[W+1];const te=u;if(ee(J,F,te),d.copy(te).multiplyScalar(Q),_.copy(F).sub(d),L.copy(F).add(d),X=Z+K,ne=!1,G!==void 0){ee(F,G,h),d.copy(h).multiplyScalar(Q),b.copy(F).sub(d),C.copy(F).add(d),se=!0,d.subVectors(G,J),te.dot(d)<0&&(se=!1),W===1&&(j=se),d.subVectors(G,F),d.normalize();const U=Math.abs(te.dot(d));if(U!==0){const B=Q/U;d.multiplyScalar(-B),y.subVectors(F,J),g.copy(y).setLength(B).add(d),m.copy(g).negate();const oe=g.length(),ce=y.length();y.divideScalar(ce),x.subVectors(G,F);const ge=x.length();switch(x.divideScalar(ge),y.dot(m)<ce&&x.dot(m)<ge&&(ne=!0),M.copy(g).add(F),m.add(F),ue=!1,ne?se?(C.copy(m),L.copy(m)):(b.copy(m),_.copy(m)):T(),t.strokeLineJoin){case"bevel":O(se,ne,X);break;case"round":k(se,ne),se?R(F,_,b,X,0):R(F,C,L,X,1);break;case"miter":case"miter-clip":default:const _e=Q*t.strokeMiterLimit/oe;if(_e<1)if(t.strokeLineJoin!=="miter-clip"){O(se,ne,X);break}else k(se,ne),se?(x.subVectors(M,_).multiplyScalar(_e).add(_),w.subVectors(M,b).multiplyScalar(_e).add(b),N(_,X,0),N(x,X,0),N(F,X,.5),N(F,X,.5),N(x,X,0),N(w,X,0),N(F,X,.5),N(w,X,0),N(b,X,0)):(x.subVectors(M,L).multiplyScalar(_e).add(L),w.subVectors(M,C).multiplyScalar(_e).add(C),N(L,X,1),N(x,X,1),N(F,X,.5),N(F,X,.5),N(x,X,1),N(w,X,1),N(F,X,.5),N(w,X,1),N(C,X,1));else ne?(se?(N(P,Z,1),N(v,Z,0),N(M,X,0),N(P,Z,1),N(M,X,0),N(m,X,1)):(N(P,Z,1),N(v,Z,0),N(M,X,1),N(v,Z,0),N(m,X,0),N(M,X,1)),se?b.copy(M):C.copy(M)):se?(N(_,X,0),N(M,X,0),N(F,X,.5),N(F,X,.5),N(M,X,0),N(b,X,0)):(N(L,X,1),N(M,X,1),N(F,X,.5),N(F,X,.5),N(M,X,1),N(C,X,1)),ue=!0;break}}else T()}else T();!I&&W===p-1&&E(e[0],D,S,se,!0,Z),Z=X,J=F,v.copy(b),P.copy(C)}if(!I)E(F,_,L,se,!1,X);else if(ne&&r){let W=M,te=m;j!==se&&(W=m,te=M),se?(ue||j)&&(te.toArray(r,0*3),te.toArray(r,3*3),ue&&W.toArray(r,1*3)):(ue||!j)&&(te.toArray(r,1*3),te.toArray(r,3*3),ue&&W.toArray(r,0*3))}return z;function ee(W,te,U){return U.subVectors(te,W),U.set(-U.y,U.x).normalize()}function N(W,te,U){r&&(r[A]=W.x,r[A+1]=W.y,r[A+2]=0,i&&(i[A]=0,i[A+1]=0,i[A+2]=1),A+=3,a&&(a[V]=te,a[V+1]=U,V+=2)),z+=3}function R(W,te,U,B,oe){u.copy(te).sub(W).normalize(),h.copy(U).sub(W).normalize();let ce=Math.PI;const ge=u.dot(h);Math.abs(ge)<1&&(ce=Math.abs(Math.acos(ge))),ce/=n,d.copy(te);for(let _e=0,xe=n-1;_e<xe;_e++)y.copy(d).rotateAround(W,ce),N(d,B,oe),N(y,B,oe),N(W,B,.5),d.copy(y);N(y,B,oe),N(U,B,oe),N(W,B,.5)}function T(){N(P,Z,1),N(v,Z,0),N(_,X,0),N(P,Z,1),N(_,X,1),N(L,X,0)}function O(W,te,U){te?W?(N(P,Z,1),N(v,Z,0),N(_,X,0),N(P,Z,1),N(_,X,0),N(m,X,1),N(_,U,0),N(b,U,0),N(m,U,.5)):(N(P,Z,1),N(v,Z,0),N(L,X,1),N(v,Z,0),N(m,X,0),N(L,X,1),N(L,U,1),N(C,U,0),N(m,U,.5)):W?(N(_,U,0),N(b,U,0),N(F,U,.5)):(N(L,U,1),N(C,U,0),N(F,U,.5))}function k(W,te){te&&(W?(N(P,Z,1),N(v,Z,0),N(_,X,0),N(P,Z,1),N(_,X,0),N(m,X,1),N(_,Z,0),N(F,X,.5),N(m,X,1),N(F,X,.5),N(b,Z,0),N(m,X,1)):(N(P,Z,1),N(v,Z,0),N(L,X,1),N(v,Z,0),N(m,X,0),N(L,X,1),N(L,Z,1),N(m,X,0),N(F,X,.5),N(F,X,.5),N(m,X,0),N(C,Z,1)))}function E(W,te,U,B,oe,ce){switch(t.strokeLineCap){case"round":oe?R(W,U,te,ce,.5):R(W,te,U,ce,.5);break;case"square":if(oe)u.subVectors(te,W),h.set(u.y,-u.x),d.addVectors(u,h).add(W),y.subVectors(h,u).add(W),B?(d.toArray(r,1*3),y.toArray(r,0*3),y.toArray(r,3*3)):(d.toArray(r,1*3),d.toArray(r,3*3),y.toArray(r,0*3));else{u.subVectors(U,W),h.set(u.y,-u.x),d.addVectors(u,h).add(W),y.subVectors(h,u).add(W);const ge=r.length;B?(d.toArray(r,ge-1*3),y.toArray(r,ge-2*3),y.toArray(r,ge-4*3)):(d.toArray(r,ge-2*3),y.toArray(r,ge-1*3),y.toArray(r,ge-4*3))}break}}function q(W){let te=!1;for(let B=1,oe=W.length-1;B<oe;B++)if(W[B].distanceTo(W[B+1])<s){te=!0;break}if(!te)return W;const U=[];U.push(W[0]);for(let B=1,oe=W.length-1;B<oe;B++)W[B].distanceTo(W[B+1])>=s&&U.push(W[B]);return U.push(W[W.length-1]),U}}}const ns=new WeakMap;class Ka extends c.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,s){const r=new c.FileLoader(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,i=>{const a={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(i,a).then(t).catch(s)},n,s)}decodeDracoFile(e,t,n,s){const r={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:s||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,r).then(t)}decodeGeometry(e,t){for(const l in t.attributeTypes){const u=t.attributeTypes[l];u.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[l]=u.name)}const n=JSON.stringify(t);if(ns.has(e)){const l=ns.get(e);if(l.key===n)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let s;const r=this.workerNextTaskID++,i=e.byteLength,a=this._getWorker(r,i).then(l=>(s=l,new Promise((u,h)=>{s._callbacks[r]={resolve:u,reject:h},s.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{s&&r&&this._releaseTask(s,r)}),ns.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new c.BufferGeometry;e.index&&t.setIndex(new c.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const s=e.attributes[n],r=s.name,i=s.array,a=s.itemSize;t.setAttribute(r,new c.BufferAttribute(i,a))}return t}_loadLibrary(e,t){const n=new c.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((s,r)=>{n.load(e,s,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const s=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const r=qa.toString(),i=["/* draco decoder */",s,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
|
|
98
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const
|
|
92
|
+
`};function ds(o,e,t){const n=t.length-o-1;if(e>=t[n])return n-1;if(e<=t[o])return o;let r=o,s=n,i=Math.floor((r+s)/2);for(;e<t[i]||e>=t[i+1];)e<t[i]?s=i:r=i,i=Math.floor((r+s)/2);return i}function Ca(o,e,t,n){const r=[],s=[],i=[];r[0]=1;for(let a=1;a<=t;++a){s[a]=e-n[o+1-a],i[a]=n[o+a]-e;let l=0;for(let u=0;u<a;++u){const h=i[u+1],d=s[a-u],g=r[u]/(h+d);r[u]=l+h*g,l=d*g}r[a]=l}return r}function Ta(o,e,t,n){const r=ds(o,n,e),s=Ca(r,n,o,e),i=new c.Vector4(0,0,0,0);for(let a=0;a<=o;++a){const l=t[r-o+a],u=s[a],h=l.w*u;i.x+=l.x*h,i.y+=l.y*h,i.z+=l.z*h,i.w+=l.w*u}return i}function La(o,e,t,n,r){const s=[];for(let d=0;d<=t;++d)s[d]=0;const i=[];for(let d=0;d<=n;++d)i[d]=s.slice(0);const a=[];for(let d=0;d<=t;++d)a[d]=s.slice(0);a[0][0]=1;const l=s.slice(0),u=s.slice(0);for(let d=1;d<=t;++d){l[d]=e-r[o+1-d],u[d]=r[o+d]-e;let g=0;for(let y=0;y<d;++y){const x=u[y+1],w=l[d-y];a[d][y]=x+w;const v=a[y][d-1]/a[d][y];a[y][d]=g+x*v,g=w*v}a[d][d]=g}for(let d=0;d<=t;++d)i[0][d]=a[d][t];for(let d=0;d<=t;++d){let g=0,y=1;const x=[];for(let w=0;w<=t;++w)x[w]=s.slice(0);x[0][0]=1;for(let w=1;w<=n;++w){let v=0;const A=d-w,D=t-w;d>=w&&(x[y][0]=x[g][0]/a[D+1][A],v=x[y][0]*a[A][D]);const M=A>=-1?1:-A,_=d-1<=D?w-1:t-d;for(let b=M;b<=_;++b)x[y][b]=(x[g][b]-x[g][b-1])/a[D+1][A+b],v+=x[y][b]*a[A+b][D];d<=D&&(x[y][w]=-x[g][w-1]/a[D+1][d],v+=x[y][w]*a[d][D]),i[w][d]=v;const L=g;g=y,y=L}}let h=t;for(let d=1;d<=n;++d){for(let g=0;g<=t;++g)i[d][g]*=h;h*=t-d}return i}function Da(o,e,t,n,r){const s=r<o?r:o,i=[],a=ds(o,n,e),l=La(a,n,o,s,e),u=[];for(let h=0;h<t.length;++h){const d=t[h].clone(),g=d.w;d.x*=g,d.y*=g,d.z*=g,u[h]=d}for(let h=0;h<=s;++h){const d=u[a-o].clone().multiplyScalar(l[h][0]);for(let g=1;g<=o;++g)d.add(u[a-o+g].clone().multiplyScalar(l[h][g]));i[h]=d}for(let h=s+1;h<=r+1;++h)i[h]=new c.Vector4(0,0,0);return i}function Ia(o,e){let t=1;for(let r=2;r<=o;++r)t*=r;let n=1;for(let r=2;r<=e;++r)n*=r;for(let r=2;r<=o-e;++r)n*=r;return t/n}function Oa(o){const e=o.length,t=[],n=[];for(let s=0;s<e;++s){const i=o[s];t[s]=new c.Vector3(i.x,i.y,i.z),n[s]=i.w}const r=[];for(let s=0;s<e;++s){const i=t[s].clone();for(let a=1;a<=s;++a)i.sub(r[s-a].clone().multiplyScalar(Ia(s,a)*n[a]));r[s]=i.divideScalar(n[0])}return r}function ka(o,e,t,n,r){const s=Da(o,e,t,n,r);return Oa(s)}class ps extends c.Curve{constructor(e,t,n,r,s){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=r||0,this.endKnot=s||this.knots.length-1;for(let i=0;i<n.length;++i){const a=n[i];this.controlPoints[i]=new c.Vector4(a.x,a.y,a.z,a.w)}}getPoint(e,t){const n=t||new c.Vector3,r=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),s=Ta(this.degree,this.knots,this.controlPoints,r);return s.w!=1&&s.divideScalar(s.w),n.set(s.x,s.y,s.z)}getTangent(e,t){const n=t||new c.Vector3,r=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),s=ka(this.degree,this.knots,this.controlPoints,r,1);return n.copy(s[1]).normalize(),n}}let ve,De,Ve;class Ba extends c.Loader{constructor(e){super(e)}load(e,t,n,r){const s=this,i=s.path===""?c.LoaderUtils.extractUrlBase(e):s.path,a=new c.FileLoader(this.manager);a.setPath(s.path),a.setResponseType("arraybuffer"),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(l){try{t(s.parse(l,i))}catch(u){r?r(u):console.error(u),s.manager.itemError(e)}},n,r)}parse(e,t){if(Ra(e))ve=new Va().parse(e);else{const r=xs(e);if(!Ga(r))throw new Error("THREE.FBXLoader: Unknown format.");if(ys(r)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+ys(r));ve=new za().parse(r)}const n=new c.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new Fa(n,this.manager).parse(ve)}}class Fa{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){De=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),r=this.parseDeformers(),s=new Ua().parse(r);return this.parseScene(r,s,n),Ve}parseConnections(){const e=new Map;return"Connections"in ve&&ve.Connections.connections.forEach(function(n){const r=n[0],s=n[1],i=n[2];e.has(r)||e.set(r,{parents:[],children:[]});const a={ID:s,relationship:i};e.get(r).parents.push(a),e.has(s)||e.set(s,{parents:[],children:[]});const l={ID:r,relationship:i};e.get(s).children.push(l)}),e}parseImages(){const e={},t={};if("Video"in ve.Objects){const n=ve.Objects.Video;for(const r in n){const s=n[r],i=parseInt(r);if(e[i]=s.RelativeFilename||s.Filename,"Content"in s){const a=s.Content instanceof ArrayBuffer&&s.Content.byteLength>0,l=typeof s.Content=="string"&&s.Content!=="";if(a||l){const u=this.parseImage(n[r]);t[s.RelativeFilename||s.Filename]=u}}}}for(const n in e){const r=e[n];t[r]!==void 0?e[n]=t[r]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,r=n.slice(n.lastIndexOf(".")+1).toLowerCase();let s;switch(r){case"bmp":s="image/bmp";break;case"jpg":case"jpeg":s="image/jpeg";break;case"png":s="image/png";break;case"tif":s="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",n),s="image/tga";break;default:console.warn('FBXLoader: Image type "'+r+'" is not supported.');return}if(typeof t=="string")return"data:"+s+";base64,"+t;{const i=new Uint8Array(t);return window.URL.createObjectURL(new Blob([i],{type:s}))}}parseTextures(e){const t=new Map;if("Texture"in ve.Objects){const n=ve.Objects.Texture;for(const r in n){const s=this.parseTexture(n[r],e);t.set(parseInt(r),s)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const r=e.WrapModeU,s=e.WrapModeV,i=r!==void 0?r.value:0,a=s!==void 0?s.value:0;if(n.wrapS=i===0?c.RepeatWrapping:c.ClampToEdgeWrapping,n.wrapT=a===0?c.RepeatWrapping:c.ClampToEdgeWrapping,"Scaling"in e){const l=e.Scaling.value;n.repeat.x=l[0],n.repeat.y=l[1]}return n}loadTexture(e,t){let n;const r=this.textureLoader.path,s=De.get(e.id).children;s!==void 0&&s.length>0&&t[s[0].ID]!==void 0&&(n=t[s[0].ID],(n.indexOf("blob:")===0||n.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let i;const a=e.FileName.slice(-3).toLowerCase();if(a==="tga"){const l=this.manager.getHandler(".tga");l===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),i=new c.Texture):(l.setPath(this.textureLoader.path),i=l.load(n))}else a==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),i=new c.Texture):i=this.textureLoader.load(n);return this.textureLoader.setPath(r),i}parseMaterials(e){const t=new Map;if("Material"in ve.Objects){const n=ve.Objects.Material;for(const r in n){const s=this.parseMaterial(n[r],e);s!==null&&t.set(parseInt(r),s)}}return t}parseMaterial(e,t){const n=e.id,r=e.attrName;let s=e.ShadingModel;if(typeof s=="object"&&(s=s.value),!De.has(n))return null;const i=this.parseParameters(e,t,n);let a;switch(s.toLowerCase()){case"phong":a=new c.MeshPhongMaterial;break;case"lambert":a=new c.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),a=new c.MeshPhongMaterial;break}return a.setValues(i),a.name=r,a}parseParameters(e,t,n){const r={};e.BumpFactor&&(r.bumpScale=e.BumpFactor.value),e.Diffuse?r.color=new c.Color().fromArray(e.Diffuse.value):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(r.color=new c.Color().fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(r.displacementScale=e.DisplacementFactor.value),e.Emissive?r.emissive=new c.Color().fromArray(e.Emissive.value):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(r.emissive=new c.Color().fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(r.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(r.opacity=parseFloat(e.Opacity.value)),r.opacity<1&&(r.transparent=!0),e.ReflectionFactor&&(r.reflectivity=e.ReflectionFactor.value),e.Shininess&&(r.shininess=e.Shininess.value),e.Specular?r.specular=new c.Color().fromArray(e.Specular.value):e.SpecularColor&&e.SpecularColor.type==="Color"&&(r.specular=new c.Color().fromArray(e.SpecularColor.value));const s=this;return De.get(n).children.forEach(function(i){const a=i.relationship;switch(a){case"Bump":r.bumpMap=s.getTexture(t,i.ID);break;case"Maya|TEX_ao_map":r.aoMap=s.getTexture(t,i.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":r.map=s.getTexture(t,i.ID),r.map!==void 0&&("colorSpace"in r.map?r.map.colorSpace="srgb":r.map.encoding=3001);break;case"DisplacementColor":r.displacementMap=s.getTexture(t,i.ID);break;case"EmissiveColor":r.emissiveMap=s.getTexture(t,i.ID),r.emissiveMap!==void 0&&("colorSpace"in r.emissiveMap?r.emissiveMap.colorSpace="srgb":r.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":r.normalMap=s.getTexture(t,i.ID);break;case"ReflectionColor":r.envMap=s.getTexture(t,i.ID),r.envMap!==void 0&&(r.envMap.mapping=c.EquirectangularReflectionMapping,"colorSpace"in r.envMap?r.envMap.colorSpace="srgb":r.envMap.encoding=3001);break;case"SpecularColor":r.specularMap=s.getTexture(t,i.ID),r.specularMap!==void 0&&("colorSpace"in r.specularMap?r.specularMap.colorSpace="srgb":r.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":r.alphaMap=s.getTexture(t,i.ID),r.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",a);break}}),r}getTexture(e,t){return"LayeredTexture"in ve.Objects&&t in ve.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=De.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in ve.Objects){const n=ve.Objects.Deformer;for(const r in n){const s=n[r],i=De.get(parseInt(r));if(s.attrType==="Skin"){const a=this.parseSkeleton(i,n);a.ID=r,i.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),a.geometryID=i.parents[0].ID,e[r]=a}else if(s.attrType==="BlendShape"){const a={id:r};a.rawTargets=this.parseMorphTargets(i,n),a.id=r,i.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[r]=a}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(r){const s=t[r.ID];if(s.attrType!=="Cluster")return;const i={ID:r.ID,indices:[],weights:[],transformLink:new c.Matrix4().fromArray(s.TransformLink.a)};"Indexes"in s&&(i.indices=s.Indexes.a,i.weights=s.Weights.a),n.push(i)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let r=0;r<e.children.length;r++){const s=e.children[r],i=t[s.ID],a={name:i.attrName,initialWeight:i.DeformPercent,id:i.id,fullWeights:i.FullWeights.a};if(i.attrType!=="BlendShapeChannel")return;a.geoID=De.get(parseInt(s.ID)).children.filter(function(l){return l.relationship===void 0})[0].ID,n.push(a)}return n}parseScene(e,t,n){Ve=new c.Group;const r=this.parseModels(e.skeletons,t,n),s=ve.Objects.Model,i=this;r.forEach(function(l){const u=s[l.ID];i.setLookAtProperties(l,u),De.get(l.ID).parents.forEach(function(d){const g=r.get(d.ID);g!==void 0&&g.add(l)}),l.parent===null&&Ve.add(l)}),this.bindSkeleton(e.skeletons,t,r),this.createAmbientLight(),Ve.traverse(function(l){if(l.userData.transformData){l.parent&&(l.userData.transformData.parentMatrix=l.parent.matrix,l.userData.transformData.parentMatrixWorld=l.parent.matrixWorld);const u=_s(l.userData.transformData);l.applyMatrix4(u),l.updateWorldMatrix()}});const a=new Na().parse();Ve.children.length===1&&Ve.children[0].isGroup&&(Ve.children[0].animations=a,Ve=Ve.children[0]),Ve.animations=a}parseModels(e,t,n){const r=new Map,s=ve.Objects.Model;for(const i in s){const a=parseInt(i),l=s[i],u=De.get(a);let h=this.buildSkeleton(u,e,a,l.attrName);if(!h){switch(l.attrType){case"Camera":h=this.createCamera(u);break;case"Light":h=this.createLight(u);break;case"Mesh":h=this.createMesh(u,t,n);break;case"NurbsCurve":h=this.createCurve(u,t);break;case"LimbNode":case"Root":h=new c.Bone;break;case"Null":default:h=new c.Group;break}h.name=l.attrName?c.PropertyBinding.sanitizeNodeName(l.attrName):"",h.ID=a}this.getTransformData(h,l),r.set(a,h)}return r}buildSkeleton(e,t,n,r){let s=null;return e.parents.forEach(function(i){for(const a in t){const l=t[a];l.rawBones.forEach(function(u,h){if(u.ID===i.ID){const d=s;s=new c.Bone,s.matrixWorld.copy(u.transformLink),s.name=r?c.PropertyBinding.sanitizeNodeName(r):"",s.ID=n,l.bones[h]=s,d!==null&&s.add(d)}})}}),s}createCamera(e){let t,n;if(e.children.forEach(function(r){const s=ve.Objects.NodeAttribute[r.ID];s!==void 0&&(n=s)}),n===void 0)t=new c.Object3D;else{let r=0;n.CameraProjectionType!==void 0&&n.CameraProjectionType.value===1&&(r=1);let s=1;n.NearPlane!==void 0&&(s=n.NearPlane.value/1e3);let i=1e3;n.FarPlane!==void 0&&(i=n.FarPlane.value/1e3);let a=window.innerWidth,l=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(a=n.AspectWidth.value,l=n.AspectHeight.value);const u=a/l;let h=45;n.FieldOfView!==void 0&&(h=n.FieldOfView.value);const d=n.FocalLength?n.FocalLength.value:null;switch(r){case 0:t=new c.PerspectiveCamera(h,u,s,i),d!==null&&t.setFocalLength(d);break;case 1:t=new c.OrthographicCamera(-a/2,a/2,l/2,-l/2,s,i);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+r+"."),t=new c.Object3D;break}}return t}createLight(e){let t,n;if(e.children.forEach(function(r){const s=ve.Objects.NodeAttribute[r.ID];s!==void 0&&(n=s)}),n===void 0)t=new c.Object3D;else{let r;n.LightType===void 0?r=0:r=n.LightType.value;let s=16777215;n.Color!==void 0&&(s=new c.Color().fromArray(n.Color.value));let i=n.Intensity===void 0?1:n.Intensity.value/100;n.CastLightOnObject!==void 0&&n.CastLightOnObject.value===0&&(i=0);let a=0;n.FarAttenuationEnd!==void 0&&(n.EnableFarAttenuation!==void 0&&n.EnableFarAttenuation.value===0?a=0:a=n.FarAttenuationEnd.value);const l=1;switch(r){case 0:t=new c.PointLight(s,i,a,l);break;case 1:t=new c.DirectionalLight(s,i);break;case 2:let u=Math.PI/3;n.InnerAngle!==void 0&&(u=c.MathUtils.degToRad(n.InnerAngle.value));let h=0;n.OuterAngle!==void 0&&(h=c.MathUtils.degToRad(n.OuterAngle.value),h=Math.max(h,1)),t=new c.SpotLight(s,i,a,u,h,l);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new c.PointLight(s,i);break}n.CastShadows!==void 0&&n.CastShadows.value===1&&(t.castShadow=!0)}return t}createMesh(e,t,n){let r,s=null,i=null;const a=[];return e.children.forEach(function(l){t.has(l.ID)&&(s=t.get(l.ID)),n.has(l.ID)&&a.push(n.get(l.ID))}),a.length>1?i=a:a.length>0?i=a[0]:(i=new c.MeshPhongMaterial({color:13421772}),a.push(i)),"color"in s.attributes&&a.forEach(function(l){l.vertexColors=!0}),s.FBX_Deformer?(r=new c.SkinnedMesh(s,i),r.normalizeSkinWeights()):r=new c.Mesh(s,i),r}createCurve(e,t){const n=e.children.reduce(function(s,i){return t.has(i.ID)&&(s=t.get(i.ID)),s},null),r=new c.LineBasicMaterial({color:3342591,linewidth:1});return new c.Line(n,r)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=vs(t.RotationOrder.value):n.eulerOrder="ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){"LookAtProperty"in t&&De.get(e.ID).children.forEach(function(r){if(r.relationship==="LookAtProperty"){const s=ve.Objects.Model[r.ID];if("Lcl_Translation"in s){const i=s.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(i),Ve.add(e.target)):e.lookAt(new c.Vector3().fromArray(i))}}})}bindSkeleton(e,t,n){const r=this.parsePoseNodes();for(const s in e){const i=e[s];De.get(parseInt(i.ID)).parents.forEach(function(l){if(t.has(l.ID)){const u=l.ID;De.get(u).parents.forEach(function(d){n.has(d.ID)&&n.get(d.ID).bind(new c.Skeleton(i.bones),r[d.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in ve.Objects){const t=ve.Objects.Pose;for(const n in t)if(t[n].attrType==="BindPose"&&t[n].NbPoseNodes>0){const r=t[n].PoseNode;Array.isArray(r)?r.forEach(function(s){e[s.Node]=new c.Matrix4().fromArray(s.Matrix.a)}):e[r.Node]=new c.Matrix4().fromArray(r.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in ve&&"AmbientColor"in ve.GlobalSettings){const e=ve.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],r=e[2];if(t!==0||n!==0||r!==0){const s=new c.Color(t,n,r);Ve.add(new c.AmbientLight(s,1))}}}}class Ua{parse(e){const t=new Map;if("Geometry"in ve.Objects){const n=ve.Objects.Geometry;for(const r in n){const s=De.get(parseInt(r)),i=this.parseGeometry(s,n[r],e);t.set(parseInt(r),i)}}return t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const r=n.skeletons,s=[],i=e.parents.map(function(d){return ve.Objects.Model[d.ID]});if(i.length===0)return;const a=e.children.reduce(function(d,g){return r[g.ID]!==void 0&&(d=r[g.ID]),d},null);e.children.forEach(function(d){n.morphTargets[d.ID]!==void 0&&s.push(n.morphTargets[d.ID])});const l=i[0],u={};"RotationOrder"in l&&(u.eulerOrder=vs(l.RotationOrder.value)),"InheritType"in l&&(u.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(u.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(u.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(u.scale=l.GeometricScaling.value);const h=_s(u);return this.genGeometry(t,a,s,h)}genGeometry(e,t,n,r){const s=new c.BufferGeometry;e.attrName&&(s.name=e.attrName);const i=this.parseGeoNode(e,t),a=this.genBuffers(i),l=new c.Float32BufferAttribute(a.vertex,3);if(l.applyMatrix4(r),s.setAttribute("position",l),a.colors.length>0&&s.setAttribute("color",new c.Float32BufferAttribute(a.colors,3)),t&&(s.setAttribute("skinIndex",new c.Uint16BufferAttribute(a.weightsIndices,4)),s.setAttribute("skinWeight",new c.Float32BufferAttribute(a.vertexWeights,4)),s.FBX_Deformer=t),a.normal.length>0){const u=new c.Matrix3().getNormalMatrix(r),h=new c.Float32BufferAttribute(a.normal,3);h.applyNormalMatrix(u),s.setAttribute("normal",h)}if(a.uvs.forEach(function(u,h){let d="uv"+(h+1).toString();h===0&&(d="uv"),s.setAttribute(d,new c.Float32BufferAttribute(a.uvs[h],2))}),i.material&&i.material.mappingType!=="AllSame"){let u=a.materialIndex[0],h=0;if(a.materialIndex.forEach(function(d,g){d!==u&&(s.addGroup(h,g-h,u),u=d,h=g)}),s.groups.length>0){const d=s.groups[s.groups.length-1],g=d.start+d.count;g!==a.materialIndex.length&&s.addGroup(g,a.materialIndex.length-g,u)}s.groups.length===0&&s.addGroup(0,a.materialIndex.length,a.materialIndex[0])}return this.addMorphTargets(s,e,n,r),s}parseGeoNode(e,t){const n={};if(n.vertexPositions=e.Vertices!==void 0?e.Vertices.a:[],n.vertexIndices=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let r=0;for(;e.LayerElementUV[r];)e.LayerElementUV[r].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[r])),r++}return n.weightTable={},t!==null&&(n.skeleton=t,t.rawBones.forEach(function(r,s){r.indices.forEach(function(i,a){n.weightTable[i]===void 0&&(n.weightTable[i]=[]),n.weightTable[i].push({id:s,weight:r.weights[a]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,r=0,s=!1,i=[],a=[],l=[],u=[],h=[],d=[];const g=this;return e.vertexIndices.forEach(function(y,x){let w,v=!1;y<0&&(y=y^-1,v=!0);let A=[],D=[];if(i.push(y*3,y*3+1,y*3+2),e.color){const M=yn(x,n,y,e.color);l.push(M[0],M[1],M[2])}if(e.skeleton){if(e.weightTable[y]!==void 0&&e.weightTable[y].forEach(function(M){D.push(M.weight),A.push(M.id)}),D.length>4){s||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),s=!0);const M=[0,0,0,0],_=[0,0,0,0];D.forEach(function(L,b){let C=L,m=A[b];_.forEach(function(S,p,I){if(C>S){I[p]=C,C=S;const k=M[p];M[p]=m,m=k}})}),A=M,D=_}for(;D.length<4;)D.push(0),A.push(0);for(let M=0;M<4;++M)h.push(D[M]),d.push(A[M])}if(e.normal){const M=yn(x,n,y,e.normal);a.push(M[0],M[1],M[2])}e.material&&e.material.mappingType!=="AllSame"&&(w=yn(x,n,y,e.material)[0]),e.uv&&e.uv.forEach(function(M,_){const L=yn(x,n,y,M);u[_]===void 0&&(u[_]=[]),u[_].push(L[0]),u[_].push(L[1])}),r++,v&&(g.genFace(t,e,i,w,a,l,u,h,d,r),n++,r=0,i=[],a=[],l=[],u=[],h=[],d=[])}),t}genFace(e,t,n,r,s,i,a,l,u,h){for(let d=2;d<h;d++)e.vertex.push(t.vertexPositions[n[0]]),e.vertex.push(t.vertexPositions[n[1]]),e.vertex.push(t.vertexPositions[n[2]]),e.vertex.push(t.vertexPositions[n[(d-1)*3]]),e.vertex.push(t.vertexPositions[n[(d-1)*3+1]]),e.vertex.push(t.vertexPositions[n[(d-1)*3+2]]),e.vertex.push(t.vertexPositions[n[d*3]]),e.vertex.push(t.vertexPositions[n[d*3+1]]),e.vertex.push(t.vertexPositions[n[d*3+2]]),t.skeleton&&(e.vertexWeights.push(l[0]),e.vertexWeights.push(l[1]),e.vertexWeights.push(l[2]),e.vertexWeights.push(l[3]),e.vertexWeights.push(l[(d-1)*4]),e.vertexWeights.push(l[(d-1)*4+1]),e.vertexWeights.push(l[(d-1)*4+2]),e.vertexWeights.push(l[(d-1)*4+3]),e.vertexWeights.push(l[d*4]),e.vertexWeights.push(l[d*4+1]),e.vertexWeights.push(l[d*4+2]),e.vertexWeights.push(l[d*4+3]),e.weightsIndices.push(u[0]),e.weightsIndices.push(u[1]),e.weightsIndices.push(u[2]),e.weightsIndices.push(u[3]),e.weightsIndices.push(u[(d-1)*4]),e.weightsIndices.push(u[(d-1)*4+1]),e.weightsIndices.push(u[(d-1)*4+2]),e.weightsIndices.push(u[(d-1)*4+3]),e.weightsIndices.push(u[d*4]),e.weightsIndices.push(u[d*4+1]),e.weightsIndices.push(u[d*4+2]),e.weightsIndices.push(u[d*4+3])),t.color&&(e.colors.push(i[0]),e.colors.push(i[1]),e.colors.push(i[2]),e.colors.push(i[(d-1)*3]),e.colors.push(i[(d-1)*3+1]),e.colors.push(i[(d-1)*3+2]),e.colors.push(i[d*3]),e.colors.push(i[d*3+1]),e.colors.push(i[d*3+2])),t.material&&t.material.mappingType!=="AllSame"&&(e.materialIndex.push(r),e.materialIndex.push(r),e.materialIndex.push(r)),t.normal&&(e.normal.push(s[0]),e.normal.push(s[1]),e.normal.push(s[2]),e.normal.push(s[(d-1)*3]),e.normal.push(s[(d-1)*3+1]),e.normal.push(s[(d-1)*3+2]),e.normal.push(s[d*3]),e.normal.push(s[d*3+1]),e.normal.push(s[d*3+2])),t.uv&&t.uv.forEach(function(g,y){e.uvs[y]===void 0&&(e.uvs[y]=[]),e.uvs[y].push(a[y][0]),e.uvs[y].push(a[y][1]),e.uvs[y].push(a[y][(d-1)*2]),e.uvs[y].push(a[y][(d-1)*2+1]),e.uvs[y].push(a[y][d*2]),e.uvs[y].push(a[y][d*2+1])})}addMorphTargets(e,t,n,r){if(n.length===0)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const s=this;n.forEach(function(i){i.rawTargets.forEach(function(a){const l=ve.Objects.Geometry[a.geoID];l!==void 0&&s.genMorphGeometry(e,t,l,r,a.name)})})}genMorphGeometry(e,t,n,r,s){const i=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],a=n.Vertices!==void 0?n.Vertices.a:[],l=n.Indexes!==void 0?n.Indexes.a:[],u=e.attributes.position.count*3,h=new Float32Array(u);for(let x=0;x<l.length;x++){const w=l[x]*3;h[w]=a[x*3],h[w+1]=a[x*3+1],h[w+2]=a[x*3+2]}const d={vertexIndices:i,vertexPositions:h},g=this.genBuffers(d),y=new c.Float32BufferAttribute(g.vertex,3);y.name=s||n.attrName,y.applyMatrix4(r),e.morphAttributes.position.push(y)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Normals.a;let s=[];return n==="IndexToDirect"&&("NormalIndex"in e?s=e.NormalIndex.a:"NormalsIndex"in e&&(s=e.NormalsIndex.a)),{dataSize:3,buffer:r,indices:s,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.UV.a;let s=[];return n==="IndexToDirect"&&(s=e.UVIndex.a),{dataSize:2,buffer:r,indices:s,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Colors.a;let s=[];return n==="IndexToDirect"&&(s=e.ColorIndex.a),{dataSize:4,buffer:r,indices:s,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if(t==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const r=e.Materials.a,s=[];for(let i=0;i<r.length;++i)s.push(i);return{dataSize:1,buffer:r,indices:s,mappingType:t,referenceType:n}}parseNurbsGeometry(e){if(ps===void 0)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new c.BufferGeometry;const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new c.BufferGeometry;const n=t-1,r=e.KnotVector.a,s=[],i=e.Points.a;for(let d=0,g=i.length;d<g;d+=4)s.push(new c.Vector4().fromArray(i,d));let a,l;if(e.Form==="Closed")s.push(s[0]);else if(e.Form==="Periodic"){a=n,l=r.length-1-a;for(let d=0;d<n;++d)s.push(s[d])}const h=new ps(n,r,s,a,l).getPoints(s.length*12);return new c.BufferGeometry().setFromPoints(h)}}class Na{parse(){const e=[],t=this.parseClips();if(t!==void 0)for(const n in t){const r=t[n],s=this.addClip(r);e.push(s)}return e}parseClips(){if(ve.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=ve.Objects.AnimationCurveNode,t=new Map;for(const n in e){const r=e[n];if(r.attrName.match(/S|R|T|DeformPercent/)!==null){const s={id:r.id,attr:r.attrName,curves:{}};t.set(s.id,s)}}return t}parseAnimationCurves(e){const t=ve.Objects.AnimationCurve;for(const n in t){const r={id:t[n].id,times:t[n].KeyTime.a.map(ja),values:t[n].KeyValueFloat.a},s=De.get(r.id);if(s!==void 0){const i=s.parents[0].ID,a=s.parents[0].relationship;a.match(/X/)?e.get(i).curves.x=r:a.match(/Y/)?e.get(i).curves.y=r:a.match(/Z/)?e.get(i).curves.z=r:a.match(/d|DeformPercent/)&&e.has(i)&&(e.get(i).curves.morph=r)}}}parseAnimationLayers(e){const t=ve.Objects.AnimationLayer,n=new Map;for(const r in t){const s=[],i=De.get(parseInt(r));i!==void 0&&(i.children.forEach(function(l,u){if(e.has(l.ID)){const h=e.get(l.ID);if(h.curves.x!==void 0||h.curves.y!==void 0||h.curves.z!==void 0){if(s[u]===void 0){const d=De.get(l.ID).parents.filter(function(g){return g.relationship!==void 0})[0].ID;if(d!==void 0){const g=ve.Objects.Model[d.toString()];if(g===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",l);return}const y={modelName:g.attrName?c.PropertyBinding.sanitizeNodeName(g.attrName):"",ID:g.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};Ve.traverse(function(x){x.ID===g.id&&(y.transform=x.matrix,x.userData.transformData&&(y.eulerOrder=x.userData.transformData.eulerOrder))}),y.transform||(y.transform=new c.Matrix4),"PreRotation"in g&&(y.preRotation=g.PreRotation.value),"PostRotation"in g&&(y.postRotation=g.PostRotation.value),s[u]=y}}s[u]&&(s[u][h.attr]=h)}else if(h.curves.morph!==void 0){if(s[u]===void 0){const d=De.get(l.ID).parents.filter(function(A){return A.relationship!==void 0})[0].ID,g=De.get(d).parents[0].ID,y=De.get(g).parents[0].ID,x=De.get(y).parents[0].ID,w=ve.Objects.Model[x],v={modelName:w.attrName?c.PropertyBinding.sanitizeNodeName(w.attrName):"",morphName:ve.Objects.Deformer[d].attrName};s[u]=v}s[u][h.attr]=h}}}),n.set(parseInt(r),s))}return n}parseAnimStacks(e){const t=ve.Objects.AnimationStack,n={};for(const r in t){const s=De.get(parseInt(r)).children;s.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const i=e.get(s[0].ID);n[r]={name:t[r].attrName,layer:i}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach(function(r){t=t.concat(n.generateTracks(r))}),new c.AnimationClip(e.name,-1,t)}generateTracks(e){const t=[];let n=new c.Vector3,r=new c.Quaternion,s=new c.Vector3;if(e.transform&&e.transform.decompose(n,r,s),n=n.toArray(),r=new c.Euler().setFromQuaternion(r,e.eulerOrder).toArray(),s=s.toArray(),e.T!==void 0&&Object.keys(e.T.curves).length>0){const i=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");i!==void 0&&t.push(i)}if(e.R!==void 0&&Object.keys(e.R.curves).length>0){const i=this.generateRotationTrack(e.modelName,e.R.curves,r,e.preRotation,e.postRotation,e.eulerOrder);i!==void 0&&t.push(i)}if(e.S!==void 0&&Object.keys(e.S.curves).length>0){const i=this.generateVectorTrack(e.modelName,e.S.curves,s,"scale");i!==void 0&&t.push(i)}if(e.DeformPercent!==void 0){const i=this.generateMorphTrack(e);i!==void 0&&t.push(i)}return t}generateVectorTrack(e,t,n,r){const s=this.getTimesForAllAxes(t),i=this.getKeyframeTrackValues(s,t,n);return new c.VectorKeyframeTrack(e+"."+r,s,i)}generateRotationTrack(e,t,n,r,s,i){t.x!==void 0&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(c.MathUtils.degToRad)),t.y!==void 0&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(c.MathUtils.degToRad)),t.z!==void 0&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(c.MathUtils.degToRad));const a=this.getTimesForAllAxes(t),l=this.getKeyframeTrackValues(a,t,n);r!==void 0&&(r=r.map(c.MathUtils.degToRad),r.push(i),r=new c.Euler().fromArray(r),r=new c.Quaternion().setFromEuler(r)),s!==void 0&&(s=s.map(c.MathUtils.degToRad),s.push(i),s=new c.Euler().fromArray(s),s=new c.Quaternion().setFromEuler(s).invert());const u=new c.Quaternion,h=new c.Euler,d=[];for(let g=0;g<l.length;g+=3)h.set(l[g],l[g+1],l[g+2],i),u.setFromEuler(h),r!==void 0&&u.premultiply(r),s!==void 0&&u.multiply(s),u.toArray(d,g/3*4);return new c.QuaternionKeyframeTrack(e+".quaternion",a,d)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(s){return s/100}),r=Ve.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new c.NumberKeyframeTrack(e.modelName+".morphTargetInfluences["+r+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(e.x!==void 0&&(t=t.concat(e.x.times)),e.y!==void 0&&(t=t.concat(e.y.times)),e.z!==void 0&&(t=t.concat(e.z.times)),t=t.sort(function(n,r){return n-r}),t.length>1){let n=1,r=t[0];for(let s=1;s<t.length;s++){const i=t[s];i!==r&&(t[n]=i,r=i,n++)}t=t.slice(0,n)}return t}getKeyframeTrackValues(e,t,n){const r=n,s=[];let i=-1,a=-1,l=-1;return e.forEach(function(u){if(t.x&&(i=t.x.times.indexOf(u)),t.y&&(a=t.y.times.indexOf(u)),t.z&&(l=t.z.times.indexOf(u)),i!==-1){const h=t.x.values[i];s.push(h),r[0]=h}else s.push(r[0]);if(a!==-1){const h=t.y.values[a];s.push(h),r[1]=h}else s.push(r[1]);if(l!==-1){const h=t.z.values[l];s.push(h),r[2]=h}else s.push(r[2])}),s}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const n=e.values[t-1],r=e.values[t]-n,s=Math.abs(r);if(s>=180){const i=s/180,a=r/i;let l=n+a;const u=e.times[t-1],d=(e.times[t]-u)/i;let g=u+d;const y=[],x=[];for(;g<e.times[t];)y.push(g),g+=d,x.push(l),l+=a;e.times=ws(e.times,t,y),e.values=ws(e.values,t,x)}}}}class za{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new gs,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach(function(r,s){const i=r.match(/^[\s\t]*;/),a=r.match(/^[\s\t]*$/);if(i||a)return;const l=r.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),u=r.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),h=r.match("^\\t{"+(t.currentIndent-1)+"}}");l?t.parseNodeBegin(r,l):u?t.parseNodeProperty(r,u,n[++s]):h?t.popStack():r.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(r)}),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),r=t[2].split(",").map(function(l){return l.trim().replace(/^"/,"").replace(/"$/,"")}),s={name:n},i=this.parseNodeAttr(r),a=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(n,s):n in a?(n==="PoseNode"?a.PoseNode.push(s):a[n].id!==void 0&&(a[n]={},a[n][a[n].id]=a[n]),i.id!==""&&(a[n][i.id]=s)):typeof i.id=="number"?(a[n]={},a[n][i.id]=s):n!=="Properties70"&&(n==="PoseNode"?a[n]=[s]:a[n]=s),typeof i.id=="number"&&(s.id=i.id),i.name!==""&&(s.attrName=i.name),i.type!==""&&(s.attrType=i.type),this.pushStack(s)}parseNodeAttr(e){let t=e[0];e[0]!==""&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",r="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),r=e[2]),{id:t,name:n,type:r}}parseNodeProperty(e,t,n){let r=t[1].replace(/^"/,"").replace(/"$/,"").trim(),s=t[2].replace(/^"/,"").replace(/"$/,"").trim();r==="Content"&&s===","&&(s=n.replace(/"/g,"").replace(/,$/,"").trim());const i=this.getCurrentNode();if(i.name==="Properties70"){this.parseNodeSpecialProperty(e,r,s);return}if(r==="C"){const l=s.split(",").slice(1),u=parseInt(l[0]),h=parseInt(l[1]);let d=s.split(",").slice(3);d=d.map(function(g){return g.trim().replace(/^"/,"")}),r="connections",s=[u,h],Wa(s,d),i[r]===void 0&&(i[r]=[])}r==="Node"&&(i.id=s),r in i&&Array.isArray(i[r])?i[r].push(s):r!=="a"?i[r]=s:i.a=s,this.setCurrentProp(i,r),r==="a"&&s.slice(-1)!==","&&(i.a=tr(s))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=tr(t.a))}parseNodeSpecialProperty(e,t,n){const r=n.split('",').map(function(h){return h.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=r[0],i=r[1],a=r[2],l=r[3];let u=r[4];switch(i){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":u=parseFloat(u);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":u=tr(u);break}this.getPrevNode()[s]={type:i,type2:a,flag:l,value:u},this.setCurrentProp(this.getPrevNode(),s)}}class Va{parse(e){const t=new ms(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const r=new gs;for(;!this.endOfContent(t);){const s=this.parseNode(t,n);s!==null&&r.add(s.name,s)}return r}endOfContent(e){return e.size()%16===0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},r=t>=7500?e.getUint64():e.getUint32(),s=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const i=e.getUint8(),a=e.getString(i);if(r===0)return null;const l=[];for(let g=0;g<s;g++)l.push(this.parseProperty(e));const u=l.length>0?l[0]:"",h=l.length>1?l[1]:"",d=l.length>2?l[2]:"";for(n.singleProperty=s===1&&e.getOffset()===r;r>e.getOffset();){const g=this.parseNode(e,t);g!==null&&this.parseSubNode(a,n,g)}return n.propertyList=l,typeof u=="number"&&(n.id=u),h!==""&&(n.attrName=h),d!==""&&(n.attrType=d),a!==""&&(n.name=a),n}parseSubNode(e,t,n){if(n.singleProperty===!0){const r=n.propertyList[0];Array.isArray(r)?(t[n.name]=n,n.a=r):t[n.name]=r}else if(e==="Connections"&&n.name==="C"){const r=[];n.propertyList.forEach(function(s,i){i!==0&&r.push(s)}),t.connections===void 0&&(t.connections=[]),t.connections.push(r)}else if(n.name==="Properties70")Object.keys(n).forEach(function(s){t[s]=n[s]});else if(e==="Properties70"&&n.name==="P"){let r=n.propertyList[0],s=n.propertyList[1];const i=n.propertyList[2],a=n.propertyList[3];let l;r.indexOf("Lcl ")===0&&(r=r.replace("Lcl ","Lcl_")),s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),s==="Color"||s==="ColorRGB"||s==="Vector"||s==="Vector3D"||s.indexOf("Lcl_")===0?l=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:l=n.propertyList[4],t[r]={type:s,type2:i,flag:a,value:l}}else t[n.name]===void 0?typeof n.id=="number"?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:n.name==="PoseNode"?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):t[n.name][n.id]===void 0&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const r=e.getUint32(),s=e.getUint32(),i=e.getUint32();if(s===0)switch(t){case"b":case"c":return e.getBooleanArray(r);case"d":return e.getFloat64Array(r);case"f":return e.getFloat32Array(r);case"i":return e.getInt32Array(r);case"l":return e.getInt64Array(r)}const a=Co(new Uint8Array(e.getArrayBuffer(i))),l=new ms(a.buffer);switch(t){case"b":case"c":return l.getBooleanArray(r);case"d":return l.getFloat64Array(r);case"f":return l.getFloat32Array(r);case"i":return l.getInt32Array(r);case"l":return l.getInt64Array(r)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class ms{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=t!==void 0?t:!0}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t&2147483648?(t=~t&4294967295,e=~e&4294967295,e===4294967295&&(t=t+1&4294967295),e=e+1&4294967295,-(t*4294967296+e)):t*4294967296+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),t*4294967296+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=[];for(let r=0;r<e;r++)t[r]=this.getUint8();const n=t.indexOf(0);return n>=0&&(t=t.slice(0,n)),c.LoaderUtils.decodeText(new Uint8Array(t))}}class gs{add(e,t){this[e]=t}}function Ra(o){const e="Kaydara FBX Binary \0";return o.byteLength>=e.length&&e===xs(o,0,e.length)}function Ga(o){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let t=0;function n(r){const s=o[r-1];return o=o.slice(t+r),t++,s}for(let r=0;r<e.length;++r)if(n(1)===e[r])return!1;return!0}function ys(o){const e=/FBXVersion: (\d+)/,t=o.match(e);if(t)return parseInt(t[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function ja(o){return o/46186158e3}const Ea=[];function yn(o,e,t,n){let r;switch(n.mappingType){case"ByPolygonVertex":r=o;break;case"ByPolygon":r=e;break;case"ByVertice":r=t;break;case"AllSame":r=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}n.referenceType==="IndexToDirect"&&(r=n.indices[r]);const s=r*n.dataSize,i=s+n.dataSize;return Ya(Ea,n.buffer,s,i)}const er=new c.Euler,kt=new c.Vector3;function _s(o){const e=new c.Matrix4,t=new c.Matrix4,n=new c.Matrix4,r=new c.Matrix4,s=new c.Matrix4,i=new c.Matrix4,a=new c.Matrix4,l=new c.Matrix4,u=new c.Matrix4,h=new c.Matrix4,d=new c.Matrix4,g=new c.Matrix4,y=o.inheritType?o.inheritType:0;if(o.translation&&e.setPosition(kt.fromArray(o.translation)),o.preRotation){const p=o.preRotation.map(c.MathUtils.degToRad);p.push(o.eulerOrder),t.makeRotationFromEuler(er.fromArray(p))}if(o.rotation){const p=o.rotation.map(c.MathUtils.degToRad);p.push(o.eulerOrder),n.makeRotationFromEuler(er.fromArray(p))}if(o.postRotation){const p=o.postRotation.map(c.MathUtils.degToRad);p.push(o.eulerOrder),r.makeRotationFromEuler(er.fromArray(p)),r.invert()}o.scale&&s.scale(kt.fromArray(o.scale)),o.scalingOffset&&a.setPosition(kt.fromArray(o.scalingOffset)),o.scalingPivot&&i.setPosition(kt.fromArray(o.scalingPivot)),o.rotationOffset&&l.setPosition(kt.fromArray(o.rotationOffset)),o.rotationPivot&&u.setPosition(kt.fromArray(o.rotationPivot)),o.parentMatrixWorld&&(d.copy(o.parentMatrix),h.copy(o.parentMatrixWorld));const x=t.clone().multiply(n).multiply(r),w=new c.Matrix4;w.extractRotation(h);const v=new c.Matrix4;v.copyPosition(h);const A=v.clone().invert().multiply(h),D=w.clone().invert().multiply(A),M=s,_=new c.Matrix4;if(y===0)_.copy(w).multiply(x).multiply(D).multiply(M);else if(y===1)_.copy(w).multiply(D).multiply(x).multiply(M);else{const I=new c.Matrix4().scale(new c.Vector3().setFromMatrixScale(d)).clone().invert(),k=D.clone().multiply(I);_.copy(w).multiply(x).multiply(k).multiply(M)}const L=u.clone().invert(),b=i.clone().invert();let C=e.clone().multiply(l).multiply(u).multiply(t).multiply(n).multiply(r).multiply(L).multiply(a).multiply(i).multiply(s).multiply(b);const m=new c.Matrix4().copyPosition(C),S=h.clone().multiply(m);return g.copyPosition(S),C=g.clone().multiply(_),C.premultiply(h.invert()),C}function vs(o){o=o||0;const e=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return o===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),e[0]):e[o]}function tr(o){return o.split(",").map(function(t){return parseFloat(t)})}function xs(o,e,t){return e===void 0&&(e=0),t===void 0&&(t=o.byteLength),c.LoaderUtils.decodeText(new Uint8Array(o,e,t))}function Wa(o,e){for(let t=0,n=o.length,r=e.length;t<r;t++,n++)o[n]=e[t]}function Ya(o,e,t,n){for(let r=t,s=0;r<n;r++,s++)o[s]=e[r];return o}function ws(o,e,t){return o.slice(0,e).concat(t).concat(o.slice(e))}var Xa=Object.defineProperty,Za=(o,e,t)=>e in o?Xa(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,nr=(o,e,t)=>(Za(o,typeof e!="symbol"?e+"":e,t),t);class Ka extends c.Loader{constructor(e){super(e)}load(e,t,n,r){const s=new c.FileLoader(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,i=>{if(typeof i!="string")throw new Error("unsupported data type");const a=JSON.parse(i),l=this.parse(a);t&&t(l)},n,r)}loadAsync(e,t){return super.loadAsync(e,t)}parse(e){return new rr(e)}}class rr{constructor(e){nr(this,"data"),this.data=e}generateShapes(e,t=100,n){const r=[],s={letterSpacing:0,lineHeight:1,...n},i=qa(e,t,this.data,s);for(let a=0,l=i.length;a<l;a++)Array.prototype.push.apply(r,i[a].toShapes(!1));return r}}nr(rr,"isFont"),nr(rr,"type");function qa(o,e,t,n){const r=Array.from(o),s=e/t.resolution,i=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*s,a=[];let l=0,u=0;for(let h=0;h<r.length;h++){const d=r[h];if(d===`
|
|
93
|
+
`)l=0,u-=i*n.lineHeight;else{const g=Qa(d,s,l,u,t);g&&(l+=g.offsetX+n.letterSpacing,a.push(g.path))}}return a}function Qa(o,e,t,n,r){const s=r.glyphs[o]||r.glyphs["?"];if(!s){console.error('THREE.Font: character "'+o+'" does not exists in font family '+r.familyName+".");return}const i=new c.ShapePath;let a,l,u,h,d,g,y,x;if(s.o){const w=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let v=0,A=w.length;v<A;)switch(w[v++]){case"m":a=parseInt(w[v++])*e+t,l=parseInt(w[v++])*e+n,i.moveTo(a,l);break;case"l":a=parseInt(w[v++])*e+t,l=parseInt(w[v++])*e+n,i.lineTo(a,l);break;case"q":u=parseInt(w[v++])*e+t,h=parseInt(w[v++])*e+n,d=parseInt(w[v++])*e+t,g=parseInt(w[v++])*e+n,i.quadraticCurveTo(d,g,u,h);break;case"b":u=parseInt(w[v++])*e+t,h=parseInt(w[v++])*e+n,d=parseInt(w[v++])*e+t,g=parseInt(w[v++])*e+n,y=parseInt(w[v++])*e+t,x=parseInt(w[v++])*e+n,i.bezierCurveTo(d,g,y,x,u,h);break}}return{offsetX:s.ha*e,path:i}}class bs extends c.DataTextureLoader{constructor(e){super(e),this.type=c.HalfFloatType}parse(e){const a=function(M,_){switch(M){case 1:console.error("THREE.RGBELoader Read Error: "+(_||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(_||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(_||""));break;default:case 4:console.error("THREE.RGBELoader: Error: "+(_||""))}return-1},d=`
|
|
94
|
+
`,g=function(M,_,L){_=_||1024;let C=M.pos,m=-1,S=0,p="",I=String.fromCharCode.apply(null,new Uint16Array(M.subarray(C,C+128)));for(;0>(m=I.indexOf(d))&&S<_&&C<M.byteLength;)p+=I,S+=I.length,C+=128,I+=String.fromCharCode.apply(null,new Uint16Array(M.subarray(C,C+128)));return-1<m?(L!==!1&&(M.pos+=S+m+1),p+I.slice(0,m)):!1},y=function(M){const _=/^#\?(\S+)/,L=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,b=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,C=/^\s*FORMAT=(\S+)\s*$/,m=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,S={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let p,I;if(M.pos>=M.byteLength||!(p=g(M)))return a(1,"no header found");if(!(I=p.match(_)))return a(3,"bad initial token");for(S.valid|=1,S.programtype=I[1],S.string+=p+`
|
|
95
|
+
`;p=g(M),p!==!1;){if(S.string+=p+`
|
|
96
|
+
`,p.charAt(0)==="#"){S.comments+=p+`
|
|
97
|
+
`;continue}if((I=p.match(L))&&(S.gamma=parseFloat(I[1])),(I=p.match(b))&&(S.exposure=parseFloat(I[1])),(I=p.match(C))&&(S.valid|=2,S.format=I[1]),(I=p.match(m))&&(S.valid|=4,S.height=parseInt(I[1],10),S.width=parseInt(I[2],10)),S.valid&2&&S.valid&4)break}return S.valid&2?S.valid&4?S:a(3,"missing image size specifier"):a(3,"missing format specifier")},x=function(M,_,L){const b=_;if(b<8||b>32767||M[0]!==2||M[1]!==2||M[2]&128)return new Uint8Array(M);if(b!==(M[2]<<8|M[3]))return a(3,"wrong scanline width");const C=new Uint8Array(4*_*L);if(!C.length)return a(4,"unable to allocate buffer space");let m=0,S=0;const p=4*b,I=new Uint8Array(4),k=new Uint8Array(p);let J=L;for(;J>0&&S<M.byteLength;){if(S+4>M.byteLength)return a(1);if(I[0]=M[S++],I[1]=M[S++],I[2]=M[S++],I[3]=M[S++],I[0]!=2||I[1]!=2||(I[2]<<8|I[3])!=b)return a(3,"bad rgbe scanline format");let R=0,Z;for(;R<p&&S<M.byteLength;){Z=M[S++];const q=Z>128;if(q&&(Z-=128),Z===0||R+Z>p)return a(3,"bad scanline data");if(q){const Y=M[S++];for(let te=0;te<Z;te++)k[R++]=Y}else k.set(M.subarray(S,S+Z),R),R+=Z,S+=Z}const X=b;for(let q=0;q<X;q++){let Y=0;C[m]=k[q+Y],Y+=b,C[m+1]=k[q+Y],Y+=b,C[m+2]=k[q+Y],Y+=b,C[m+3]=k[q+Y],m+=4}J--}return C},w=function(M,_,L,b){const C=M[_+3],m=Math.pow(2,C-128)/255;L[b+0]=M[_+0]*m,L[b+1]=M[_+1]*m,L[b+2]=M[_+2]*m,L[b+3]=1},v=function(M,_,L,b){const C=M[_+3],m=Math.pow(2,C-128)/255;L[b+0]=c.DataUtils.toHalfFloat(Math.min(M[_+0]*m,65504)),L[b+1]=c.DataUtils.toHalfFloat(Math.min(M[_+1]*m,65504)),L[b+2]=c.DataUtils.toHalfFloat(Math.min(M[_+2]*m,65504)),L[b+3]=c.DataUtils.toHalfFloat(1)},A=new Uint8Array(e);A.pos=0;const D=y(A);if(D!==-1){const M=D.width,_=D.height,L=x(A.subarray(A.pos),M,_);if(L!==-1){let b,C,m;switch(this.type){case c.FloatType:m=L.length/4;const S=new Float32Array(m*4);for(let I=0;I<m;I++)w(L,I*4,S,I*4);b=S,C=c.FloatType;break;case c.HalfFloatType:m=L.length/4;const p=new Uint16Array(m*4);for(let I=0;I<m;I++)v(L,I*4,p,I*4);b=p,C=c.HalfFloatType;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type);break}return{width:M,height:_,data:b,header:D.string,gamma:D.gamma,exposure:D.exposure,type:C}}}return null}setDataType(e){return this.type=e,this}load(e,t,n,r){function s(i,a){switch(i.type){case c.FloatType:case c.HalfFloatType:"colorSpace"in i?i.colorSpace="srgb-linear":i.encoding=3e3,i.minFilter=c.LinearFilter,i.magFilter=c.LinearFilter,i.generateMipmaps=!1,i.flipY=!0;break}t&&t(i,a)}return super.load(e,s,n,r)}}class Kt extends c.Loader{constructor(e){super(e),this.defaultDPI=90,this.defaultUnit="px"}load(e,t,n,r){const s=this,i=new c.FileLoader(s.manager);i.setPath(s.path),i.setRequestHeader(s.requestHeader),i.setWithCredentials(s.withCredentials),i.load(e,function(a){try{t(s.parse(a))}catch(l){r?r(l):console.error(l),s.manager.itemError(e)}},n,r)}parse(e){const t=this;function n(j,z){if(j.nodeType!==1)return;const P=_(j);let V=!0,ee=null;switch(j.nodeName){case"svg":break;case"style":s(j);break;case"g":z=x(j,z);break;case"path":z=x(j,z),j.hasAttribute("d")&&(ee=r(j));break;case"rect":z=x(j,z),ee=l(j);break;case"polygon":z=x(j,z),ee=u(j);break;case"polyline":z=x(j,z),ee=h(j);break;case"circle":z=x(j,z),ee=d(j);break;case"ellipse":z=x(j,z),ee=g(j);break;case"line":z=x(j,z),ee=y(j);break;case"defs":V=!1;break;case"mask":V=!1;break;case"use":z=x(j,z);const N=j.href.baseVal.substring(1),G=j.viewportElement.getElementById(N);G?n(G,z):console.warn("SVGLoader: 'use node' references non-existent node id: "+N);break}if(ee&&(z.fill!==void 0&&z.fill!=="none"&&ee.color.setStyle(z.fill),b(ee,te),p.push(ee),ee.userData={node:j,style:z}),V){const N=j.childNodes;for(let G=0;G<N.length;G++)n(N[G],z)}P&&(k.pop(),k.length>0?te.copy(k[k.length-1]):te.identity())}function r(j){const z=new c.ShapePath,P=new c.Vector2,V=new c.Vector2,ee=new c.Vector2;let N=!0,G=!1;const O=j.getAttribute("d").match(/[a-df-z][^a-df-z]*/gi);for(let B=0,E=O.length;B<E;B++){const Q=O[B],K=Q.charAt(0),ne=Q.substr(1).trim();N===!0&&(G=!0,N=!1);let U;switch(K){case"M":U=v(ne);for(let F=0,oe=U.length;F<oe;F+=2)P.x=U[F+0],P.y=U[F+1],V.x=P.x,V.y=P.y,F===0?z.moveTo(P.x,P.y):z.lineTo(P.x,P.y),F===0&&ee.copy(P);break;case"H":U=v(ne);for(let F=0,oe=U.length;F<oe;F++)P.x=U[F],V.x=P.x,V.y=P.y,z.lineTo(P.x,P.y),F===0&&G===!0&&ee.copy(P);break;case"V":U=v(ne);for(let F=0,oe=U.length;F<oe;F++)P.y=U[F],V.x=P.x,V.y=P.y,z.lineTo(P.x,P.y),F===0&&G===!0&&ee.copy(P);break;case"L":U=v(ne);for(let F=0,oe=U.length;F<oe;F+=2)P.x=U[F+0],P.y=U[F+1],V.x=P.x,V.y=P.y,z.lineTo(P.x,P.y),F===0&&G===!0&&ee.copy(P);break;case"C":U=v(ne);for(let F=0,oe=U.length;F<oe;F+=6)z.bezierCurveTo(U[F+0],U[F+1],U[F+2],U[F+3],U[F+4],U[F+5]),V.x=U[F+2],V.y=U[F+3],P.x=U[F+4],P.y=U[F+5],F===0&&G===!0&&ee.copy(P);break;case"S":U=v(ne);for(let F=0,oe=U.length;F<oe;F+=4)z.bezierCurveTo(w(P.x,V.x),w(P.y,V.y),U[F+0],U[F+1],U[F+2],U[F+3]),V.x=U[F+0],V.y=U[F+1],P.x=U[F+2],P.y=U[F+3],F===0&&G===!0&&ee.copy(P);break;case"Q":U=v(ne);for(let F=0,oe=U.length;F<oe;F+=4)z.quadraticCurveTo(U[F+0],U[F+1],U[F+2],U[F+3]),V.x=U[F+0],V.y=U[F+1],P.x=U[F+2],P.y=U[F+3],F===0&&G===!0&&ee.copy(P);break;case"T":U=v(ne);for(let F=0,oe=U.length;F<oe;F+=2){const ue=w(P.x,V.x),ge=w(P.y,V.y);z.quadraticCurveTo(ue,ge,U[F+0],U[F+1]),V.x=ue,V.y=ge,P.x=U[F+0],P.y=U[F+1],F===0&&G===!0&&ee.copy(P)}break;case"A":U=v(ne,[3,4],7);for(let F=0,oe=U.length;F<oe;F+=7){if(U[F+5]==P.x&&U[F+6]==P.y)continue;const ue=P.clone();P.x=U[F+5],P.y=U[F+6],V.x=P.x,V.y=P.y,i(z,U[F],U[F+1],U[F+2],U[F+3],U[F+4],ue,P),F===0&&G===!0&&ee.copy(P)}break;case"m":U=v(ne);for(let F=0,oe=U.length;F<oe;F+=2)P.x+=U[F+0],P.y+=U[F+1],V.x=P.x,V.y=P.y,F===0?z.moveTo(P.x,P.y):z.lineTo(P.x,P.y),F===0&&ee.copy(P);break;case"h":U=v(ne);for(let F=0,oe=U.length;F<oe;F++)P.x+=U[F],V.x=P.x,V.y=P.y,z.lineTo(P.x,P.y),F===0&&G===!0&&ee.copy(P);break;case"v":U=v(ne);for(let F=0,oe=U.length;F<oe;F++)P.y+=U[F],V.x=P.x,V.y=P.y,z.lineTo(P.x,P.y),F===0&&G===!0&&ee.copy(P);break;case"l":U=v(ne);for(let F=0,oe=U.length;F<oe;F+=2)P.x+=U[F+0],P.y+=U[F+1],V.x=P.x,V.y=P.y,z.lineTo(P.x,P.y),F===0&&G===!0&&ee.copy(P);break;case"c":U=v(ne);for(let F=0,oe=U.length;F<oe;F+=6)z.bezierCurveTo(P.x+U[F+0],P.y+U[F+1],P.x+U[F+2],P.y+U[F+3],P.x+U[F+4],P.y+U[F+5]),V.x=P.x+U[F+2],V.y=P.y+U[F+3],P.x+=U[F+4],P.y+=U[F+5],F===0&&G===!0&&ee.copy(P);break;case"s":U=v(ne);for(let F=0,oe=U.length;F<oe;F+=4)z.bezierCurveTo(w(P.x,V.x),w(P.y,V.y),P.x+U[F+0],P.y+U[F+1],P.x+U[F+2],P.y+U[F+3]),V.x=P.x+U[F+0],V.y=P.y+U[F+1],P.x+=U[F+2],P.y+=U[F+3],F===0&&G===!0&&ee.copy(P);break;case"q":U=v(ne);for(let F=0,oe=U.length;F<oe;F+=4)z.quadraticCurveTo(P.x+U[F+0],P.y+U[F+1],P.x+U[F+2],P.y+U[F+3]),V.x=P.x+U[F+0],V.y=P.y+U[F+1],P.x+=U[F+2],P.y+=U[F+3],F===0&&G===!0&&ee.copy(P);break;case"t":U=v(ne);for(let F=0,oe=U.length;F<oe;F+=2){const ue=w(P.x,V.x),ge=w(P.y,V.y);z.quadraticCurveTo(ue,ge,P.x+U[F+0],P.y+U[F+1]),V.x=ue,V.y=ge,P.x=P.x+U[F+0],P.y=P.y+U[F+1],F===0&&G===!0&&ee.copy(P)}break;case"a":U=v(ne,[3,4],7);for(let F=0,oe=U.length;F<oe;F+=7){if(U[F+5]==0&&U[F+6]==0)continue;const ue=P.clone();P.x+=U[F+5],P.y+=U[F+6],V.x=P.x,V.y=P.y,i(z,U[F],U[F+1],U[F+2],U[F+3],U[F+4],ue,P),F===0&&G===!0&&ee.copy(P)}break;case"Z":case"z":z.currentPath.autoClose=!0,z.currentPath.curves.length>0&&(P.copy(ee),z.currentPath.currentPoint.copy(P),N=!0);break;default:console.warn(Q)}G=!1}return z}function s(j){if(!(!j.sheet||!j.sheet.cssRules||!j.sheet.cssRules.length))for(let z=0;z<j.sheet.cssRules.length;z++){const P=j.sheet.cssRules[z];if(P.type!==1)continue;const V=P.selectorText.split(/,/gm).filter(Boolean).map(ee=>ee.trim());for(let ee=0;ee<V.length;ee++)I[V[ee]]=Object.assign(I[V[ee]]||{},P.style)}}function i(j,z,P,V,ee,N,G,T){if(z==0||P==0){j.lineTo(T.x,T.y);return}V=V*Math.PI/180,z=Math.abs(z),P=Math.abs(P);const O=(G.x-T.x)/2,B=(G.y-T.y)/2,E=Math.cos(V)*O+Math.sin(V)*B,Q=-Math.sin(V)*O+Math.cos(V)*B;let K=z*z,ne=P*P;const U=E*E,F=Q*Q,oe=U/K+F/ne;if(oe>1){const jt=Math.sqrt(oe);z=jt*z,P=jt*P,K=z*z,ne=P*P}const ue=K*F+ne*U,ge=(K*ne-ue)/ue;let _e=Math.sqrt(Math.max(0,ge));ee===N&&(_e=-_e);const xe=_e*z*Q/P,Oe=-_e*P*E/z,lt=Math.cos(V)*xe-Math.sin(V)*Oe+(G.x+T.x)/2,cn=Math.sin(V)*xe+Math.cos(V)*Oe+(G.y+T.y)/2,Gt=a(1,0,(E-xe)/z,(Q-Oe)/P),qe=a((E-xe)/z,(Q-Oe)/P,(-E-xe)/z,(-Q-Oe)/P)%(Math.PI*2);j.currentPath.absellipse(lt,cn,z,P,Gt,Gt+qe,N===0,V)}function a(j,z,P,V){const ee=j*P+z*V,N=Math.sqrt(j*j+z*z)*Math.sqrt(P*P+V*V);let G=Math.acos(Math.max(-1,Math.min(1,ee/N)));return j*V-z*P<0&&(G=-G),G}function l(j){const z=M(j.getAttribute("x")||0),P=M(j.getAttribute("y")||0),V=M(j.getAttribute("rx")||j.getAttribute("ry")||0),ee=M(j.getAttribute("ry")||j.getAttribute("rx")||0),N=M(j.getAttribute("width")),G=M(j.getAttribute("height")),T=1-.551915024494,O=new c.ShapePath;return O.moveTo(z+V,P),O.lineTo(z+N-V,P),(V!==0||ee!==0)&&O.bezierCurveTo(z+N-V*T,P,z+N,P+ee*T,z+N,P+ee),O.lineTo(z+N,P+G-ee),(V!==0||ee!==0)&&O.bezierCurveTo(z+N,P+G-ee*T,z+N-V*T,P+G,z+N-V,P+G),O.lineTo(z+V,P+G),(V!==0||ee!==0)&&O.bezierCurveTo(z+V*T,P+G,z,P+G-ee*T,z,P+G-ee),O.lineTo(z,P+ee),(V!==0||ee!==0)&&O.bezierCurveTo(z,P+ee*T,z+V*T,P,z+V,P),O}function u(j){function z(N,G,T){const O=M(G),B=M(T);ee===0?V.moveTo(O,B):V.lineTo(O,B),ee++}const P=/(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g,V=new c.ShapePath;let ee=0;return j.getAttribute("points").replace(P,z),V.currentPath.autoClose=!0,V}function h(j){function z(N,G,T){const O=M(G),B=M(T);ee===0?V.moveTo(O,B):V.lineTo(O,B),ee++}const P=/(-?[\d\.?]+)[,|\s](-?[\d\.?]+)/g,V=new c.ShapePath;let ee=0;return j.getAttribute("points").replace(P,z),V.currentPath.autoClose=!1,V}function d(j){const z=M(j.getAttribute("cx")||0),P=M(j.getAttribute("cy")||0),V=M(j.getAttribute("r")||0),ee=new c.Path;ee.absarc(z,P,V,0,Math.PI*2);const N=new c.ShapePath;return N.subPaths.push(ee),N}function g(j){const z=M(j.getAttribute("cx")||0),P=M(j.getAttribute("cy")||0),V=M(j.getAttribute("rx")||0),ee=M(j.getAttribute("ry")||0),N=new c.Path;N.absellipse(z,P,V,ee,0,Math.PI*2);const G=new c.ShapePath;return G.subPaths.push(N),G}function y(j){const z=M(j.getAttribute("x1")||0),P=M(j.getAttribute("y1")||0),V=M(j.getAttribute("x2")||0),ee=M(j.getAttribute("y2")||0),N=new c.ShapePath;return N.moveTo(z,P),N.lineTo(V,ee),N.currentPath.autoClose=!1,N}function x(j,z){z=Object.assign({},z);let P={};if(j.hasAttribute("class")){const G=j.getAttribute("class").split(/\s/).filter(Boolean).map(T=>T.trim());for(let T=0;T<G.length;T++)P=Object.assign(P,I["."+G[T]])}j.hasAttribute("id")&&(P=Object.assign(P,I["#"+j.getAttribute("id")]));function V(G,T,O){O===void 0&&(O=function(E){return E.startsWith("url")&&console.warn("SVGLoader: url access in attributes is not implemented."),E}),j.hasAttribute(G)&&(z[T]=O(j.getAttribute(G))),P[G]&&(z[T]=O(P[G])),j.style&&j.style[G]!==""&&(z[T]=O(j.style[G]))}function ee(G){return Math.max(0,Math.min(1,M(G)))}function N(G){return Math.max(0,M(G))}return V("fill","fill"),V("fill-opacity","fillOpacity",ee),V("fill-rule","fillRule"),V("opacity","opacity",ee),V("stroke","stroke"),V("stroke-opacity","strokeOpacity",ee),V("stroke-width","strokeWidth",N),V("stroke-linejoin","strokeLineJoin"),V("stroke-linecap","strokeLineCap"),V("stroke-miterlimit","strokeMiterLimit",N),V("visibility","visibility"),z}function w(j,z){return j-(z-j)}function v(j,z,P){if(typeof j!="string")throw new TypeError("Invalid input: "+typeof j);const V={SEPARATOR:/[ \t\r\n\,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/[\d]/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/},ee=0,N=1,G=2,T=3;let O=ee,B=!0,E="",Q="";const K=[];function ne(ue,ge,_e){const xe=new SyntaxError('Unexpected character "'+ue+'" at index '+ge+".");throw xe.partial=_e,xe}function U(){E!==""&&(Q===""?K.push(Number(E)):K.push(Number(E)*Math.pow(10,Number(Q)))),E="",Q=""}let F;const oe=j.length;for(let ue=0;ue<oe;ue++){if(F=j[ue],Array.isArray(z)&&z.includes(K.length%P)&&V.FLAGS.test(F)){O=N,E=F,U();continue}if(O===ee){if(V.WHITESPACE.test(F))continue;if(V.DIGIT.test(F)||V.SIGN.test(F)){O=N,E=F;continue}if(V.POINT.test(F)){O=G,E=F;continue}V.COMMA.test(F)&&(B&&ne(F,ue,K),B=!0)}if(O===N){if(V.DIGIT.test(F)){E+=F;continue}if(V.POINT.test(F)){E+=F,O=G;continue}if(V.EXP.test(F)){O=T;continue}V.SIGN.test(F)&&E.length===1&&V.SIGN.test(E[0])&&ne(F,ue,K)}if(O===G){if(V.DIGIT.test(F)){E+=F;continue}if(V.EXP.test(F)){O=T;continue}V.POINT.test(F)&&E[E.length-1]==="."&&ne(F,ue,K)}if(O===T){if(V.DIGIT.test(F)){Q+=F;continue}if(V.SIGN.test(F)){if(Q===""){Q+=F;continue}Q.length===1&&V.SIGN.test(Q)&&ne(F,ue,K)}}V.WHITESPACE.test(F)?(U(),O=ee,B=!1):V.COMMA.test(F)?(U(),O=ee,B=!0):V.SIGN.test(F)?(U(),O=N,E=F):V.POINT.test(F)?(U(),O=G,E=F):ne(F,ue,K)}return U(),K}const A=["mm","cm","in","pt","pc","px"],D={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function M(j){let z="px";if(typeof j=="string"||j instanceof String)for(let V=0,ee=A.length;V<ee;V++){const N=A[V];if(j.endsWith(N)){z=N,j=j.substring(0,j.length-N.length);break}}let P;return z==="px"&&t.defaultUnit!=="px"?P=D.in[t.defaultUnit]/t.defaultDPI:(P=D[z][t.defaultUnit],P<0&&(P=D[z].in*t.defaultDPI)),P*parseFloat(j)}function _(j){if(!(j.hasAttribute("transform")||j.nodeName==="use"&&(j.hasAttribute("x")||j.hasAttribute("y"))))return null;const z=L(j);return k.length>0&&z.premultiply(k[k.length-1]),te.copy(z),k.push(z),z}function L(j){const z=new c.Matrix3,P=J;if(j.nodeName==="use"&&(j.hasAttribute("x")||j.hasAttribute("y"))){const V=M(j.getAttribute("x")),ee=M(j.getAttribute("y"));z.translate(V,ee)}if(j.hasAttribute("transform")){const V=j.getAttribute("transform").split(")");for(let ee=V.length-1;ee>=0;ee--){const N=V[ee].trim();if(N==="")continue;const G=N.indexOf("("),T=N.length;if(G>0&&G<T){const O=N.substr(0,G),B=v(N.substr(G+1,T-G-1));switch(P.identity(),O){case"translate":if(B.length>=1){const E=B[0];let Q=E;B.length>=2&&(Q=B[1]),P.translate(E,Q)}break;case"rotate":if(B.length>=1){let E=0,Q=0,K=0;E=-B[0]*Math.PI/180,B.length>=3&&(Q=B[1],K=B[2]),R.identity().translate(-Q,-K),Z.identity().rotate(E),X.multiplyMatrices(Z,R),R.identity().translate(Q,K),P.multiplyMatrices(R,X)}break;case"scale":if(B.length>=1){const E=B[0];let Q=E;B.length>=2&&(Q=B[1]),P.scale(E,Q)}break;case"skewX":B.length===1&&P.set(1,Math.tan(B[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":B.length===1&&P.set(1,0,0,Math.tan(B[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":B.length===6&&P.set(B[0],B[2],B[4],B[1],B[3],B[5],0,0,1);break}}z.premultiply(P)}}return z}function b(j,z){function P(N){Y.set(N.x,N.y,1).applyMatrix3(z),N.set(Y.x,Y.y)}const V=C(z),ee=j.subPaths;for(let N=0,G=ee.length;N<G;N++){const O=ee[N].curves;for(let B=0;B<O.length;B++){const E=O[B];E.isLineCurve?(P(E.v1),P(E.v2)):E.isCubicBezierCurve?(P(E.v0),P(E.v1),P(E.v2),P(E.v3)):E.isQuadraticBezierCurve?(P(E.v0),P(E.v1),P(E.v2)):E.isEllipseCurve&&(V&&console.warn("SVGLoader: Elliptic arc or ellipse rotation or skewing is not implemented."),q.set(E.aX,E.aY),P(q),E.aX=q.x,E.aY=q.y,E.xRadius*=m(z),E.yRadius*=S(z))}}}function C(j){return j.elements[1]!==0||j.elements[3]!==0}function m(j){const z=j.elements;return Math.sqrt(z[0]*z[0]+z[1]*z[1])}function S(j){const z=j.elements;return Math.sqrt(z[3]*z[3]+z[4]*z[4])}const p=[],I={},k=[],J=new c.Matrix3,R=new c.Matrix3,Z=new c.Matrix3,X=new c.Matrix3,q=new c.Vector2,Y=new c.Vector3,te=new c.Matrix3,re=new DOMParser().parseFromString(e,"image/svg+xml");return n(re.documentElement,{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4}),{paths:p,xml:re.documentElement}}static createShapes(e){const n={ORIGIN:0,DESTINATION:1,BETWEEN:2,LEFT:3,RIGHT:4,BEHIND:5,BEYOND:6},r={loc:n.ORIGIN,t:0};function s(v,A,D,M){const _=v.x,L=A.x,b=D.x,C=M.x,m=v.y,S=A.y,p=D.y,I=M.y,k=(C-b)*(m-p)-(I-p)*(_-b),J=(L-_)*(m-p)-(S-m)*(_-b),R=(I-p)*(L-_)-(C-b)*(S-m),Z=k/R,X=J/R;if(R===0&&k!==0||Z<=0||Z>=1||X<0||X>1)return null;if(k===0&&R===0){for(let q=0;q<2;q++)if(i(q===0?D:M,v,A),r.loc==n.ORIGIN){const Y=q===0?D:M;return{x:Y.x,y:Y.y,t:r.t}}else if(r.loc==n.BETWEEN){const Y=+(_+r.t*(L-_)).toPrecision(10),te=+(m+r.t*(S-m)).toPrecision(10);return{x:Y,y:te,t:r.t}}return null}else{for(let te=0;te<2;te++)if(i(te===0?D:M,v,A),r.loc==n.ORIGIN){const re=te===0?D:M;return{x:re.x,y:re.y,t:r.t}}const q=+(_+Z*(L-_)).toPrecision(10),Y=+(m+Z*(S-m)).toPrecision(10);return{x:q,y:Y,t:Z}}}function i(v,A,D){const M=D.x-A.x,_=D.y-A.y,L=v.x-A.x,b=v.y-A.y,C=M*b-L*_;if(v.x===A.x&&v.y===A.y){r.loc=n.ORIGIN,r.t=0;return}if(v.x===D.x&&v.y===D.y){r.loc=n.DESTINATION,r.t=1;return}if(C<-Number.EPSILON){r.loc=n.LEFT;return}if(C>Number.EPSILON){r.loc=n.RIGHT;return}if(M*L<0||_*b<0){r.loc=n.BEHIND;return}if(Math.sqrt(M*M+_*_)<Math.sqrt(L*L+b*b)){r.loc=n.BEYOND;return}let m;M!==0?m=L/M:m=b/_,r.loc=n.BETWEEN,r.t=m}function a(v,A){const D=[],M=[];for(let _=1;_<v.length;_++){const L=v[_-1],b=v[_];for(let C=1;C<A.length;C++){const m=A[C-1],S=A[C],p=s(L,b,m,S);p!==null&&D.find(I=>I.t<=p.t+Number.EPSILON&&I.t>=p.t-Number.EPSILON)===void 0&&(D.push(p),M.push(new c.Vector2(p.x,p.y)))}}return M}function l(v,A,D){const M=new c.Vector2;A.getCenter(M);const _=[];return D.forEach(L=>{L.boundingBox.containsPoint(M)&&a(v,L.points).forEach(C=>{_.push({identifier:L.identifier,isCW:L.isCW,point:C})})}),_.sort((L,b)=>L.point.x-b.point.x),_}function u(v,A,D,M,_){(_==null||_==="")&&(_="nonzero");const L=new c.Vector2;v.boundingBox.getCenter(L);const b=[new c.Vector2(D,L.y),new c.Vector2(M,L.y)],C=l(b,v.boundingBox,A);C.sort((J,R)=>J.point.x-R.point.x);const m=[],S=[];C.forEach(J=>{J.identifier===v.identifier?m.push(J):S.push(J)});const p=m[0].point.x,I=[];let k=0;for(;k<S.length&&S[k].point.x<p;)I.length>0&&I[I.length-1]===S[k].identifier?I.pop():I.push(S[k].identifier),k++;if(I.push(v.identifier),_==="evenodd"){const J=I.length%2===0,R=I[I.length-2];return{identifier:v.identifier,isHole:J,for:R}}else if(_==="nonzero"){let J=!0,R=null,Z=null;for(let X=0;X<I.length;X++){const q=I[X];J?(Z=A[q].isCW,J=!1,R=q):Z!==A[q].isCW&&(Z=A[q].isCW,J=!0)}return{identifier:v.identifier,isHole:J,for:R}}else console.warn('fill-rule: "'+_+'" is currently not implemented.')}let h=0,d=999999999,g=-999999999,y=e.subPaths.map(v=>{const A=v.getPoints();let D=-999999999,M=999999999,_=-999999999,L=999999999;for(let b=0;b<A.length;b++){const C=A[b];C.y>D&&(D=C.y),C.y<M&&(M=C.y),C.x>_&&(_=C.x),C.x<L&&(L=C.x)}return g<=_&&(g=_+1),d>=L&&(d=L-1),{curves:v.curves,points:A,isCW:c.ShapeUtils.isClockWise(A),identifier:h++,boundingBox:new c.Box2(new c.Vector2(L,M),new c.Vector2(_,D))}});y=y.filter(v=>v.points.length>1);const x=y.map(v=>u(v,y,d,g,e.userData.style.fillRule)),w=[];return y.forEach(v=>{if(!x[v.identifier].isHole){const D=new c.Shape;D.curves=v.curves,x.filter(_=>_.isHole&&_.for===v.identifier).forEach(_=>{const L=y[_.identifier],b=new c.Path;b.curves=L.curves,D.holes.push(b)}),w.push(D)}}),w}static getStrokeStyle(e,t,n,r,s){return e=e!==void 0?e:1,t=t!==void 0?t:"#000",n=n!==void 0?n:"miter",r=r!==void 0?r:"butt",s=s!==void 0?s:4,{strokeColor:t,strokeWidth:e,strokeLineJoin:n,strokeLineCap:r,strokeMiterLimit:s}}static pointsToStroke(e,t,n,r){const s=[],i=[],a=[];if(Kt.pointsToStrokeWithBuffers(e,t,n,r,s,i,a)===0)return null;const l=new c.BufferGeometry;return l.setAttribute("position",new c.Float32BufferAttribute(s,3)),l.setAttribute("normal",new c.Float32BufferAttribute(i,3)),l.setAttribute("uv",new c.Float32BufferAttribute(a,2)),l}static pointsToStrokeWithBuffers(e,t,n,r,s,i,a,l){const u=new c.Vector2,h=new c.Vector2,d=new c.Vector2,g=new c.Vector2,y=new c.Vector2,x=new c.Vector2,w=new c.Vector2,v=new c.Vector2,A=new c.Vector2,D=new c.Vector2,M=new c.Vector2,_=new c.Vector2,L=new c.Vector2,b=new c.Vector2,C=new c.Vector2,m=new c.Vector2,S=new c.Vector2;n=n!==void 0?n:12,r=r!==void 0?r:.001,l=l!==void 0?l:0,e=Q(e);const p=e.length;if(p<2)return 0;const I=e[0].equals(e[p-1]);let k,J=e[0],R;const Z=t.strokeWidth/2,X=1/(p-1);let q=0,Y,te,re,ce,j=!1,z=0,P=l*3,V=l*2;ee(e[0],e[1],u).multiplyScalar(Z),v.copy(e[0]).sub(u),A.copy(e[0]).add(u),D.copy(v),M.copy(A);for(let K=1;K<p;K++){k=e[K],K===p-1?I?R=e[1]:R=void 0:R=e[K+1];const ne=u;if(ee(J,k,ne),d.copy(ne).multiplyScalar(Z),_.copy(k).sub(d),L.copy(k).add(d),Y=q+X,te=!1,R!==void 0){ee(k,R,h),d.copy(h).multiplyScalar(Z),b.copy(k).sub(d),C.copy(k).add(d),re=!0,d.subVectors(R,J),ne.dot(d)<0&&(re=!1),K===1&&(j=re),d.subVectors(R,k),d.normalize();const U=Math.abs(ne.dot(d));if(U!==0){const F=Z/U;d.multiplyScalar(-F),g.subVectors(k,J),y.copy(g).setLength(F).add(d),m.copy(y).negate();const oe=y.length(),ue=g.length();g.divideScalar(ue),x.subVectors(R,k);const ge=x.length();switch(x.divideScalar(ge),g.dot(m)<ue&&x.dot(m)<ge&&(te=!0),S.copy(y).add(k),m.add(k),ce=!1,te?re?(C.copy(m),L.copy(m)):(b.copy(m),_.copy(m)):T(),t.strokeLineJoin){case"bevel":O(re,te,Y);break;case"round":B(re,te),re?G(k,_,b,Y,0):G(k,C,L,Y,1);break;case"miter":case"miter-clip":default:const _e=Z*t.strokeMiterLimit/oe;if(_e<1)if(t.strokeLineJoin!=="miter-clip"){O(re,te,Y);break}else B(re,te),re?(x.subVectors(S,_).multiplyScalar(_e).add(_),w.subVectors(S,b).multiplyScalar(_e).add(b),N(_,Y,0),N(x,Y,0),N(k,Y,.5),N(k,Y,.5),N(x,Y,0),N(w,Y,0),N(k,Y,.5),N(w,Y,0),N(b,Y,0)):(x.subVectors(S,L).multiplyScalar(_e).add(L),w.subVectors(S,C).multiplyScalar(_e).add(C),N(L,Y,1),N(x,Y,1),N(k,Y,.5),N(k,Y,.5),N(x,Y,1),N(w,Y,1),N(k,Y,.5),N(w,Y,1),N(C,Y,1));else te?(re?(N(A,q,1),N(v,q,0),N(S,Y,0),N(A,q,1),N(S,Y,0),N(m,Y,1)):(N(A,q,1),N(v,q,0),N(S,Y,1),N(v,q,0),N(m,Y,0),N(S,Y,1)),re?b.copy(S):C.copy(S)):re?(N(_,Y,0),N(S,Y,0),N(k,Y,.5),N(k,Y,.5),N(S,Y,0),N(b,Y,0)):(N(L,Y,1),N(S,Y,1),N(k,Y,.5),N(k,Y,.5),N(S,Y,1),N(C,Y,1)),ce=!0;break}}else T()}else T();!I&&K===p-1&&E(e[0],D,M,re,!0,q),q=Y,J=k,v.copy(b),A.copy(C)}if(!I)E(k,_,L,re,!1,Y);else if(te&&s){let K=S,ne=m;j!==re&&(K=m,ne=S),re?(ce||j)&&(ne.toArray(s,0*3),ne.toArray(s,3*3),ce&&K.toArray(s,1*3)):(ce||!j)&&(ne.toArray(s,1*3),ne.toArray(s,3*3),ce&&K.toArray(s,0*3))}return z;function ee(K,ne,U){return U.subVectors(ne,K),U.set(-U.y,U.x).normalize()}function N(K,ne,U){s&&(s[P]=K.x,s[P+1]=K.y,s[P+2]=0,i&&(i[P]=0,i[P+1]=0,i[P+2]=1),P+=3,a&&(a[V]=ne,a[V+1]=U,V+=2)),z+=3}function G(K,ne,U,F,oe){u.copy(ne).sub(K).normalize(),h.copy(U).sub(K).normalize();let ue=Math.PI;const ge=u.dot(h);Math.abs(ge)<1&&(ue=Math.abs(Math.acos(ge))),ue/=n,d.copy(ne);for(let _e=0,xe=n-1;_e<xe;_e++)g.copy(d).rotateAround(K,ue),N(d,F,oe),N(g,F,oe),N(K,F,.5),d.copy(g);N(g,F,oe),N(U,F,oe),N(K,F,.5)}function T(){N(A,q,1),N(v,q,0),N(_,Y,0),N(A,q,1),N(_,Y,1),N(L,Y,0)}function O(K,ne,U){ne?K?(N(A,q,1),N(v,q,0),N(_,Y,0),N(A,q,1),N(_,Y,0),N(m,Y,1),N(_,U,0),N(b,U,0),N(m,U,.5)):(N(A,q,1),N(v,q,0),N(L,Y,1),N(v,q,0),N(m,Y,0),N(L,Y,1),N(L,U,1),N(C,U,0),N(m,U,.5)):K?(N(_,U,0),N(b,U,0),N(k,U,.5)):(N(L,U,1),N(C,U,0),N(k,U,.5))}function B(K,ne){ne&&(K?(N(A,q,1),N(v,q,0),N(_,Y,0),N(A,q,1),N(_,Y,0),N(m,Y,1),N(_,q,0),N(k,Y,.5),N(m,Y,1),N(k,Y,.5),N(b,q,0),N(m,Y,1)):(N(A,q,1),N(v,q,0),N(L,Y,1),N(v,q,0),N(m,Y,0),N(L,Y,1),N(L,q,1),N(m,Y,0),N(k,Y,.5),N(k,Y,.5),N(m,Y,0),N(C,q,1)))}function E(K,ne,U,F,oe,ue){switch(t.strokeLineCap){case"round":oe?G(K,U,ne,ue,.5):G(K,ne,U,ue,.5);break;case"square":if(oe)u.subVectors(ne,K),h.set(u.y,-u.x),d.addVectors(u,h).add(K),g.subVectors(h,u).add(K),F?(d.toArray(s,1*3),g.toArray(s,0*3),g.toArray(s,3*3)):(d.toArray(s,1*3),d.toArray(s,3*3),g.toArray(s,0*3));else{u.subVectors(U,K),h.set(u.y,-u.x),d.addVectors(u,h).add(K),g.subVectors(h,u).add(K);const ge=s.length;F?(d.toArray(s,ge-1*3),g.toArray(s,ge-2*3),g.toArray(s,ge-4*3)):(d.toArray(s,ge-2*3),g.toArray(s,ge-1*3),g.toArray(s,ge-4*3))}break}}function Q(K){let ne=!1;for(let F=1,oe=K.length-1;F<oe;F++)if(K[F].distanceTo(K[F+1])<r){ne=!0;break}if(!ne)return K;const U=[];U.push(K[0]);for(let F=1,oe=K.length-1;F<oe;F++)K[F].distanceTo(K[F+1])>=r&&U.push(K[F]);return U.push(K[K.length-1]),U}}}const sr=new WeakMap;class Ja extends c.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,r){const s=new c.FileLoader(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,i=>{const a={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(i,a).then(t).catch(r)},n,r)}decodeDracoFile(e,t,n,r){const s={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,s).then(t)}decodeGeometry(e,t){for(const l in t.attributeTypes){const u=t.attributeTypes[l];u.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[l]=u.name)}const n=JSON.stringify(t);if(sr.has(e)){const l=sr.get(e);if(l.key===n)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const s=this.workerNextTaskID++,i=e.byteLength,a=this._getWorker(s,i).then(l=>(r=l,new Promise((u,h)=>{r._callbacks[s]={resolve:u,reject:h},r.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),sr.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new c.BufferGeometry;e.index&&t.setIndex(new c.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const r=e.attributes[n],s=r.name,i=r.array,a=r.itemSize;t.setAttribute(s,new c.BufferAttribute(i,a))}return t}_loadLibrary(e,t){const n=new c.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((r,s)=>{n.load(e,r,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const r=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const s=Ha.toString(),i=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
98
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([i]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const r=new Worker(this.workerSourceURL);r._callbacks={},r._taskCosts={},r._taskLoad=0,r.postMessage({type:"init",decoderConfig:this.decoderConfig}),r.onmessage=function(s){const i=s.data;switch(i.type){case"decode":r._callbacks[i.id].resolve(i);break;case"error":r._callbacks[i.id].reject(i);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+i.type+'"')}},this.workerPool.push(r)}else this.workerPool.sort(function(r,s){return r._taskLoad>s._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function Ha(){let o,e;onmessage=function(i){const a=i.data;switch(a.type){case"init":o=a.decoderConfig,e=new Promise(function(h){o.onModuleLoaded=function(d){h({draco:d})},DracoDecoderModule(o)});break;case"decode":const l=a.buffer,u=a.taskConfig;e.then(h=>{const d=h.draco,g=new d.Decoder,y=new d.DecoderBuffer;y.Init(new Int8Array(l),l.byteLength);try{const x=t(d,g,y,u),w=x.attributes.map(v=>v.array.buffer);x.index&&w.push(x.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:x},w)}catch(x){console.error(x),self.postMessage({type:"error",id:a.id,error:x.message})}finally{d.destroy(y),d.destroy(g)}});break}};function t(i,a,l,u){const h=u.attributeIDs,d=u.attributeTypes;let g,y;const x=a.GetEncodedGeometryType(l);if(x===i.TRIANGULAR_MESH)g=new i.Mesh,y=a.DecodeBufferToMesh(l,g);else if(x===i.POINT_CLOUD)g=new i.PointCloud,y=a.DecodeBufferToPointCloud(l,g);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!y.ok()||g.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+y.error_msg());const w={index:null,attributes:[]};for(const v in h){const A=self[d[v]];let D,M;if(u.useUniqueIDs)M=h[v],D=a.GetAttributeByUniqueId(g,M);else{if(M=a.GetAttributeId(g,i[h[v]]),M===-1)continue;D=a.GetAttribute(g,M)}w.attributes.push(r(i,a,g,v,A,D))}return x===i.TRIANGULAR_MESH&&(w.index=n(i,a,g)),i.destroy(g),w}function n(i,a,l){const h=l.num_faces()*3,d=h*4,g=i._malloc(d);a.GetTrianglesUInt32Array(l,d,g);const y=new Uint32Array(i.HEAPF32.buffer,g,h).slice();return i._free(g),{array:y,itemSize:1}}function r(i,a,l,u,h,d){const g=d.num_components(),x=l.num_points()*g,w=x*h.BYTES_PER_ELEMENT,v=s(i,h),A=i._malloc(w);a.GetAttributeDataArrayForAllPoints(l,d,v,w,A);const D=new h(i.HEAPF32.buffer,A,x).slice();return i._free(A),{name:u,array:D,itemSize:g}}function s(i,a){switch(a){case Float32Array:return i.DT_FLOAT32;case Int8Array:return i.DT_INT8;case Int16Array:return i.DT_INT16;case Int32Array:return i.DT_INT32;case Uint8Array:return i.DT_UINT8;case Uint16Array:return i.DT_UINT16;case Uint32Array:return i.DT_UINT32}}}class Ms extends c.Line{constructor(e,t){const n=[1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],r=new c.BufferGeometry;r.setAttribute("position",new c.Float32BufferAttribute(n,3)),r.computeBoundingSphere();const s=new c.LineBasicMaterial({fog:!1});super(r,s),this.light=e,this.color=t,this.type="RectAreaLightHelper";const i=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],a=new c.BufferGeometry;a.setAttribute("position",new c.Float32BufferAttribute(i,3)),a.computeBoundingSphere(),this.add(new c.Mesh(a,new c.MeshBasicMaterial({side:c.BackSide,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),this.color!==void 0)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const $a=["args","center"],el=f.defineComponent({__name:"Text3D",props:{font:{},text:{},size:{default:.5},height:{default:.2},curveSegments:{default:5},bevelEnabled:{type:Boolean,default:!0},bevelThickness:{default:.05},bevelSize:{default:.02},bevelOffset:{default:0},bevelSegments:{default:4},center:{type:Boolean,default:!1},needUpdates:{type:Boolean,default:!1}},async setup(o,{expose:e}){let t,n;const r=o,{center:s,font:i,text:a,needUpdates:l,size:u,height:h,curveSegments:d,bevelEnabled:g,bevelThickness:y,bevelSize:x,bevelOffset:w,bevelSegments:v}=f.toRefs(r),{extend:A}=ae.useTresContext();A({TextGeometry:fs});const D=new Ka,M=f.useSlots(),_=f.computed(()=>{var m;return a!=null&&a.value?a.value:M.default?(m=M.default()[0].children)==null?void 0:m.trim():l.value?"":"TresJS"}),L=f.shallowRef();e({value:L});const b=([t,n]=f.withAsyncContext(()=>new Promise((m,S)=>{try{typeof i.value=="string"?D.load(i.value,p=>{m(p)}):m(i.value)}catch(p){S(console.error("cientos",p))}})),t=await t,n(),t),C=f.computed(()=>({font:b,size:f.toValue(u),height:f.toValue(h),curveSegments:f.toValue(d),bevelEnabled:f.toValue(g),bevelThickness:f.toValue(y),bevelSize:f.toValue(x),bevelOffset:f.toValue(w),bevelSegments:f.toValue(v)}));return f.watchEffect(()=>{L.value&&l.value&&(L.value.geometry.dispose(),L.value.geometry=new fs(_.value,C.value),s.value&&L.value.geometry.center())}),(m,S)=>f.unref(i)?(f.openBlock(),f.createElementBlock("TresMesh",{key:0,ref_key:"text3DRef",ref:L},[_.value?(f.openBlock(),f.createElementBlock("TresTextGeometry",{key:0,args:[_.value,C.value],center:f.unref(s)},null,8,$a)):f.createCommentVNode("",!0),f.renderSlot(m.$slots,"default")],512)):f.createCommentVNode("",!0)}});function tl(o,e){const t=f.ref(e),n=new c.AnimationMixer(t.value),r=f.shallowReactive({});o.forEach(i=>{const a=n.clipAction(i,t.value);r[i.name]=a});const{onLoop:s}=ae.useRenderLoop();return s(({delta:i})=>{n.update(i)}),{actions:r,mixer:n}}const nl=f.defineComponent({__name:"Levioso",props:{speed:{default:1},rotationFactor:{default:1},floatFactor:{default:1},range:{default:()=>[-.1,.1]}},setup(o,{expose:e}){const t=o,n=f.shallowRef();e({value:n});{const l=Math.random()*1e4,{onLoop:u}=ae.useRenderLoop();let h=l;u(({delta:d})=>{if(!n.value)return;h+=d*t.speed;const g=h*.25,y=n.value;y.rotation.x=Math.cos(g)*.125*t.rotationFactor,y.rotation.y=Math.sin(g)*.125*t.rotationFactor,y.rotation.z=Math.sin(g)*.05*t.rotationFactor,y.position.y=c.MathUtils.mapLinear(Math.sin(g),-1,1,t.range[0],t.range[1])*t.floatFactor})}return(r,s)=>(f.openBlock(),f.createElementBlock("TresGroup",f.mergeProps(r.$attrs,{ref_key:"groupRef",ref:n}),[f.renderSlot(r.$slots,"default")],16))}});class qt extends c.Mesh{constructor(e,t={}){super(e),this.isReflector=!0,this.type="Reflector",this.camera=new c.PerspectiveCamera;const n=this,r=t.color!==void 0?new c.Color(t.color):new c.Color(8355711),s=t.textureWidth||512,i=t.textureHeight||512,a=t.clipBias||0,l=t.shader||qt.ReflectorShader,u=t.multisample!==void 0?t.multisample:4,h=new c.Plane,d=new c.Vector3,g=new c.Vector3,y=new c.Vector3,x=new c.Matrix4,w=new c.Vector3(0,0,-1),v=new c.Vector4,A=new c.Vector3,D=new c.Vector3,M=new c.Vector4,_=new c.Matrix4,L=this.camera,b=new c.WebGLRenderTarget(s,i,{samples:u,type:c.HalfFloatType}),C=new c.ShaderMaterial({name:l.name!==void 0?l.name:"unspecified",uniforms:c.UniformsUtils.clone(l.uniforms),fragmentShader:l.fragmentShader,vertexShader:l.vertexShader});C.uniforms.tDiffuse.value=b.texture,C.uniforms.color.value=r,C.uniforms.textureMatrix.value=_,this.material=C,this.onBeforeRender=function(m,S,p){if(g.setFromMatrixPosition(n.matrixWorld),y.setFromMatrixPosition(p.matrixWorld),x.extractRotation(n.matrixWorld),d.set(0,0,1),d.applyMatrix4(x),A.subVectors(g,y),A.dot(d)>0)return;A.reflect(d).negate(),A.add(g),x.extractRotation(p.matrixWorld),w.set(0,0,-1),w.applyMatrix4(x),w.add(y),D.subVectors(g,w),D.reflect(d).negate(),D.add(g),L.position.copy(A),L.up.set(0,1,0),L.up.applyMatrix4(x),L.up.reflect(d),L.lookAt(D),L.far=p.far,L.updateMatrixWorld(),L.projectionMatrix.copy(p.projectionMatrix),_.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),_.multiply(L.projectionMatrix),_.multiply(L.matrixWorldInverse),_.multiply(n.matrixWorld),h.setFromNormalAndCoplanarPoint(d,g),h.applyMatrix4(L.matrixWorldInverse),v.set(h.normal.x,h.normal.y,h.normal.z,h.constant);const I=L.projectionMatrix;M.x=(Math.sign(v.x)+I.elements[8])/I.elements[0],M.y=(Math.sign(v.y)+I.elements[9])/I.elements[5],M.z=-1,M.w=(1+I.elements[10])/I.elements[14],v.multiplyScalar(2/v.dot(M)),I.elements[2]=v.x,I.elements[6]=v.y,I.elements[10]=v.z+1-a,I.elements[14]=v.w,n.visible=!1;const k=m.getRenderTarget(),J=m.xr.enabled,R=m.shadowMap.autoUpdate;m.xr.enabled=!1,m.shadowMap.autoUpdate=!1,m.setRenderTarget(b),m.state.buffers.depth.setMask(!0),m.autoClear===!1&&m.clear(),m.render(S,L),m.xr.enabled=J,m.shadowMap.autoUpdate=R,m.setRenderTarget(k);const Z=p.viewport;Z!==void 0&&m.state.viewport(Z),n.visible=!0},this.getRenderTarget=function(){return b},this.dispose=function(){b.dispose(),n.material.dispose()}}}qt.ReflectorShader={name:"ReflectorShader",uniforms:{color:{value:null},tDiffuse:{value:null},textureMatrix:{value:null}},vertexShader:`
|
|
99
99
|
uniform mat4 textureMatrix;
|
|
100
100
|
varying vec4 vUv;
|
|
101
101
|
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
#include <tonemapping_fragment>
|
|
140
140
|
#include <colorspace_fragment>
|
|
141
141
|
|
|
142
|
-
}`};const
|
|
142
|
+
}`};const rl=["args","material-uniforms-color-value"],sl=f.createElementVNode("TresPlaneGeometry",{args:[5,5]},null,-1),il=f.defineComponent({__name:"Reflector",props:{color:{default:"#333"},textureWidth:{default:512},textureHeight:{default:512},clipBias:{default:0},multisample:{default:4},shader:{default:qt.ReflectorShader}},setup(o,{expose:e}){const t=o,{extend:n}=ae.useTresContext(),r=f.shallowRef();n({Reflector:qt});const{color:s,textureWidth:i,textureHeight:a,clipBias:l,multisample:u,shader:h}=f.toRefs(t);return e({reflectorRef:r}),(d,g)=>(f.openBlock(),f.createElementBlock("TresReflector",{ref_key:"reflectorRef",ref:r,args:[void 0,{textureWidth:f.unref(i),textureHeight:f.unref(a),clipBias:f.unref(l),multisample:f.unref(u),shader:f.unref(h)}],"material-uniforms-color-value":f.unref(s)},[f.renderSlot(d.$slots,"default",{},()=>[sl])],8,rl))}});function Ss(o){return f.getCurrentScope()?(f.onScopeDispose(o),!0):!1}function We(o){return typeof o=="function"?o():f.unref(o)}const ol=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const al=Object.prototype.toString,ll=o=>al.call(o)==="[object Object]",Mt=()=>{};function ir(o,e){function t(...n){return new Promise((r,s)=>{Promise.resolve(o(()=>e.apply(this,n),{fn:e,thisArg:this,args:n})).then(r).catch(s)})}return t}const cl=o=>o();function ul(o,e={}){let t,n,r=Mt;const s=a=>{clearTimeout(a),r(),r=Mt};return a=>{const l=We(o),u=We(e.maxWait);return t&&s(t),l<=0||u!==void 0&&u<=0?(n&&(s(n),n=null),Promise.resolve(a())):new Promise((h,d)=>{r=e.rejectOnCancel?d:h,u&&!n&&(n=setTimeout(()=>{t&&s(t),n=null,h(a())},u)),t=setTimeout(()=>{n&&s(n),n=null,h(a())},l)})}}function As(o,e=!0,t=!0,n=!1){let r=0,s,i=!0,a=Mt,l;const u=()=>{s&&(clearTimeout(s),s=void 0,a(),a=Mt)};return d=>{const g=We(o),y=Date.now()-r,x=()=>l=d();return u(),g<=0?(r=Date.now(),x()):(y>g&&(t||!i)?(r=Date.now(),x()):e&&(l=new Promise((w,v)=>{a=n?v:w,s=setTimeout(()=>{r=Date.now(),i=!0,w(x()),u()},Math.max(0,g-y))})),!t&&!s&&(s=setTimeout(()=>i=!0,g)),i=!1,l)}}function hl(o){return o||f.getCurrentInstance()}function fl(o,e=200,t={}){return ir(ul(e,t),o)}function dl(o,e=200,t=!1,n=!0,r=!1){return ir(As(e,t,n,r),o)}function pl(o,e,t={}){const{eventFilter:n=cl,...r}=t;return f.watch(o,ir(n,e),r)}function Ps(o,e=!0,t){hl()?f.onMounted(o,t):e?o():f.nextTick(o)}function ml(o,e,t={}){const{throttle:n=0,trailing:r=!0,leading:s=!0,...i}=t;return pl(o,e,{...i,eventFilter:As(n,r,s)})}function gl(o){var e;const t=We(o);return(e=t==null?void 0:t.$el)!=null?e:t}const St=ol?window:void 0;function Le(...o){let e,t,n,r;if(typeof o[0]=="string"||Array.isArray(o[0])?([t,n,r]=o,e=St):[e,t,n,r]=o,!e)return Mt;Array.isArray(t)||(t=[t]),Array.isArray(n)||(n=[n]);const s=[],i=()=>{s.forEach(h=>h()),s.length=0},a=(h,d,g,y)=>(h.addEventListener(d,g,y),()=>h.removeEventListener(d,g,y)),l=f.watch(()=>[gl(e),We(r)],([h,d])=>{if(i(),!h)return;const g=ll(d)?{...d}:d;s.push(...t.flatMap(y=>n.map(x=>a(h,y,x,g))))},{immediate:!0,flush:"post"}),u=()=>{l(),i()};return Ss(u),u}function yl(o){return typeof o=="function"?o:typeof o=="string"?e=>e.key===o:Array.isArray(o)?e=>o.includes(e.key):()=>!0}function At(...o){let e,t,n={};o.length===3?(e=o[0],t=o[1],n=o[2]):o.length===2?typeof o[1]=="object"?(e=!0,t=o[0],n=o[1]):(e=o[0],t=o[1]):(e=!0,t=o[0]);const{target:r=St,eventName:s="keydown",passive:i=!1,dedupe:a=!1}=n,l=yl(e);return Le(r,s,h=>{h.repeat&&We(a)||l(h)&&t(h)},i)}function _l(){const o=f.ref(!1);return f.getCurrentInstance()&&f.onMounted(()=>{o.value=!0}),o}function vl(o){const e=_l();return f.computed(()=>(e.value,!!o()))}function xl(o,e={}){const{window:t=St}=e,n=vl(()=>t&&"matchMedia"in t&&typeof t.matchMedia=="function");let r;const s=f.ref(!1),i=u=>{s.value=u.matches},a=()=>{r&&("removeEventListener"in r?r.removeEventListener("change",i):r.removeListener(i))},l=f.watchEffect(()=>{n.value&&(a(),r=t.matchMedia(We(o)),"addEventListener"in r?r.addEventListener("change",i):r.addListener(i),s.value=r.matches)});return Ss(()=>{l(),a(),r=void 0}),s}const Cs=1;function wl(o,e={}){const{throttle:t=0,idle:n=200,onStop:r=Mt,onScroll:s=Mt,offset:i={left:0,right:0,top:0,bottom:0},eventListenerOptions:a={capture:!1,passive:!0},behavior:l="auto",window:u=St}=e,h=f.ref(0),d=f.ref(0),g=f.computed({get(){return h.value},set(b){x(b,void 0)}}),y=f.computed({get(){return d.value},set(b){x(void 0,b)}});function x(b,C){var m,S,p;if(!u)return;const I=We(o);I&&((p=I instanceof Document?u.document.body:I)==null||p.scrollTo({top:(m=We(C))!=null?m:y.value,left:(S=We(b))!=null?S:g.value,behavior:We(l)}))}const w=f.ref(!1),v=f.reactive({left:!0,right:!1,top:!0,bottom:!1}),A=f.reactive({left:!1,right:!1,top:!1,bottom:!1}),D=b=>{w.value&&(w.value=!1,A.left=!1,A.right=!1,A.top=!1,A.bottom=!1,r(b))},M=fl(D,t+n),_=b=>{var C;if(!u)return;const m=b.document?b.document.documentElement:(C=b.documentElement)!=null?C:b,{display:S,flexDirection:p}=getComputedStyle(m),I=m.scrollLeft;A.left=I<h.value,A.right=I>h.value;const k=Math.abs(I)<=0+(i.left||0),J=Math.abs(I)+m.clientWidth>=m.scrollWidth-(i.right||0)-Cs;S==="flex"&&p==="row-reverse"?(v.left=J,v.right=k):(v.left=k,v.right=J),h.value=I;let R=m.scrollTop;b===u.document&&!R&&(R=u.document.body.scrollTop),A.top=R<d.value,A.bottom=R>d.value;const Z=Math.abs(R)<=0+(i.top||0),X=Math.abs(R)+m.clientHeight>=m.scrollHeight-(i.bottom||0)-Cs;S==="flex"&&p==="column-reverse"?(v.top=X,v.bottom=Z):(v.top=Z,v.bottom=X),d.value=R},L=b=>{var C;if(!u)return;const m=(C=b.target.documentElement)!=null?C:b.target;_(m),w.value=!0,M(b),s(b)};return Le(o,"scroll",t?dl(L,t,!0,!1):L,a),Ps(()=>{const b=We(o);b&&_(b)}),Le(o,"scrollend",D,a),{x:g,y,isScrolling:w,arrivedState:v,directions:A,measure(){const b=We(o);u&&b&&_(b)}}}const bl={page:o=>[o.pageX,o.pageY],client:o=>[o.clientX,o.clientY],screen:o=>[o.screenX,o.screenY],movement:o=>o instanceof Touch?null:[o.movementX,o.movementY]};function Ml(o={}){const{type:e="page",touch:t=!0,resetOnTouchEnds:n=!1,initialValue:r={x:0,y:0},window:s=St,target:i=s,scroll:a=!0,eventFilter:l}=o;let u=null;const h=f.ref(r.x),d=f.ref(r.y),g=f.ref(null),y=typeof e=="function"?e:bl[e],x=L=>{const b=y(L);u=L,b&&([h.value,d.value]=b,g.value="mouse")},w=L=>{if(L.touches.length>0){const b=y(L.touches[0]);b&&([h.value,d.value]=b,g.value="touch")}},v=()=>{if(!u||!s)return;const L=y(u);u instanceof MouseEvent&&L&&(h.value=L[0]+s.scrollX,d.value=L[1]+s.scrollY)},A=()=>{h.value=r.x,d.value=r.y},D=l?L=>l(()=>x(L),{}):L=>x(L),M=l?L=>l(()=>w(L),{}):L=>w(L),_=l?()=>l(()=>v(),{}):()=>v();if(i){const L={passive:!0};Le(i,["mousemove","dragover"],D,L),t&&e!=="movement"&&(Le(i,["touchstart","touchmove"],M,L),n&&Le(i,"touchend",A,L)),a&&e==="page"&&Le(s,"scroll",_,{passive:!0})}return{x:h,y:d,sourceType:g}}function Sl(o={}){const{window:e=St,behavior:t="auto"}=o;if(!e)return{x:f.ref(0),y:f.ref(0)};const n=f.ref(e.scrollX),r=f.ref(e.scrollY),s=f.computed({get(){return n.value},set(a){scrollTo({left:a,behavior:t})}}),i=f.computed({get(){return r.value},set(a){scrollTo({top:a,behavior:t})}});return Le(e,"scroll",()=>{n.value=e.scrollX,r.value=e.scrollY},{capture:!1,passive:!0}),{x:s,y:i}}function Ts(o={}){const{window:e=St,initialWidth:t=Number.POSITIVE_INFINITY,initialHeight:n=Number.POSITIVE_INFINITY,listenOrientation:r=!0,includeScrollbar:s=!0}=o,i=f.ref(t),a=f.ref(n),l=()=>{e&&(s?(i.value=e.innerWidth,a.value=e.innerHeight):(i.value=e.document.documentElement.clientWidth,a.value=e.document.documentElement.clientHeight))};if(l(),Ps(l),Le("resize",l,{passive:!0}),r){const u=xl("(orientation: portrait)");f.watch(u,()=>l())}return{width:i,height:a}}const Al=f.defineComponent({__name:"MouseParallax",props:{disabled:{type:Boolean,default:!1},factor:{default:2.5},ease:{default:.1}},setup(o){const e=o,{camera:t}=ae.useTresContext(),{disabled:n,factor:r,ease:s}=f.toRefs(e),{x:i,y:a}=Ml(),{width:l,height:u}=Ts(),h=f.ref(),d=f.computed(()=>(i.value/l.value-.5)*r.value),g=f.computed(()=>-(a.value/u.value-.5)*r.value),{onLoop:y}=ae.useRenderLoop();return y(({delta:x})=>{n.value||!h.value||(h.value.position.x+=(d.value-h.value.position.x)*s.value*x,h.value.position.y+=(g.value-h.value.position.y)*s.value*x)}),f.watch(()=>h.value,x=>x==null?void 0:x.add(t.value)),(x,w)=>(f.openBlock(),f.createElementBlock("TresGroup",{ref_key:"cameraGroupRef",ref:h},null,512))}}),Pl=f.defineComponent({name:"GlobalAudio",props:["src","loop","volume","playbackRate","playTrigger","stopTrigger"],async setup(o,{expose:e,emit:t}){var d;const{camera:n,renderer:r}=ae.useTresContext(),s=new c.AudioListener;(d=n.value)==null||d.add(s);const i=new c.Audio(s),a=new c.AudioLoader;e({sound:i}),f.onUnmounted(()=>{i&&i.disconnect()}),f.watch(()=>[o.playbackRate],()=>i.setPlaybackRate(o.playbackRate??1),{immediate:!0}),f.watch(()=>[o.volume],()=>i.setVolume(o.volume??.5),{immediate:!0}),f.watch(()=>[o.loop],()=>i.setLoop(o.loop??!1),{immediate:!0}),f.watch(()=>[o.src],async()=>{const g=await a.loadAsync(o.src);i.setBuffer(g)},{immediate:!0});const l=document.getElementById(o.playTrigger??""),u=l||r.value.domElement;Le(u,"click",()=>{i.isPlaying?i.pause():i.play(),t("isPlaying",i.isPlaying)});const h=document.getElementById(o.stopTrigger??"");return h&&Le(h,"click",()=>{i.stop(),t("isPlaying",i.isPlaying)}),null}});class Qt extends c.Mesh{constructor(){super(Qt.Geometry,new c.MeshBasicMaterial({opacity:0,transparent:!0})),this.isLensflare=!0,this.type="Lensflare",this.frustumCulled=!1,this.renderOrder=1/0;const e=new c.Vector3,t=new c.Vector3,n=new c.FramebufferTexture(16,16),r=new c.FramebufferTexture(16,16);let s=c.UnsignedByteType;const i=Qt.Geometry,a=new c.RawShaderMaterial({uniforms:{scale:{value:null},screenPosition:{value:null}},vertexShader:`
|
|
143
143
|
|
|
144
144
|
precision highp float;
|
|
145
145
|
|
|
@@ -190,7 +190,7 @@
|
|
|
190
190
|
|
|
191
191
|
gl_FragColor = texture2D( map, vUV );
|
|
192
192
|
|
|
193
|
-
}`,depthTest:!1,depthWrite:!1,transparent:!1}),u=new c.Mesh(i,a),h=[],d=
|
|
193
|
+
}`,depthTest:!1,depthWrite:!1,transparent:!1}),u=new c.Mesh(i,a),h=[],d=Ls.Shader,g=new c.RawShaderMaterial({name:d.name,uniforms:{map:{value:null},occlusionMap:{value:r},color:{value:new c.Color(16777215)},scale:{value:new c.Vector2},screenPosition:{value:new c.Vector3}},vertexShader:d.vertexShader,fragmentShader:d.fragmentShader,blending:c.AdditiveBlending,transparent:!0,depthWrite:!1}),y=new c.Mesh(i,g);this.addElement=function(D){h.push(D)};const x=new c.Vector2,w=new c.Vector2,v=new c.Box2,A=new c.Vector4;this.onBeforeRender=function(D,M,_){D.getCurrentViewport(A);const L=D.getRenderTarget(),b=L!==null?L.texture.type:c.UnsignedByteType;s!==b&&(n.dispose(),r.dispose(),n.type=r.type=b,s=b);const C=A.w/A.z,m=A.z/2,S=A.w/2;let p=16/A.w;if(x.set(p*C,p),v.min.set(A.x,A.y),v.max.set(A.x+(A.z-16),A.y+(A.w-16)),t.setFromMatrixPosition(this.matrixWorld),t.applyMatrix4(_.matrixWorldInverse),!(t.z>0)&&(e.copy(t).applyMatrix4(_.projectionMatrix),w.x=A.x+e.x*m+m-8,w.y=A.y+e.y*S+S-8,v.containsPoint(w))){D.copyFramebufferToTexture(w,n);let I=a.uniforms;I.scale.value=x,I.screenPosition.value=e,D.renderBufferDirect(_,null,i,a,u,null),D.copyFramebufferToTexture(w,r),I=l.uniforms,I.scale.value=x,I.screenPosition.value=e,D.renderBufferDirect(_,null,i,l,u,null);const k=-e.x*2,J=-e.y*2;for(let R=0,Z=h.length;R<Z;R++){const X=h[R],q=g.uniforms;q.color.value.copy(X.color),q.map.value=X.texture,q.screenPosition.value.x=e.x+k*X.distance,q.screenPosition.value.y=e.y+J*X.distance,p=X.size/A.w;const Y=A.w/A.z;q.scale.value.set(p*Y,p),g.uniformsNeedUpdate=!0,D.renderBufferDirect(_,null,i,g,y,null)}}},this.dispose=function(){a.dispose(),l.dispose(),g.dispose(),n.dispose(),r.dispose();for(let D=0,M=h.length;D<M;D++)h[D].texture.dispose()}}}class Ls{constructor(e,t=1,n=0,r=new c.Color(16777215)){this.texture=e,this.size=t,this.distance=n,this.color=r}}Ls.Shader={name:"LensflareElementShader",uniforms:{map:{value:null},occlusionMap:{value:null},color:{value:null},scale:{value:null},screenPosition:{value:null}},vertexShader:`
|
|
194
194
|
|
|
195
195
|
precision highp float;
|
|
196
196
|
|
|
@@ -244,12 +244,12 @@
|
|
|
244
244
|
gl_FragColor = texture;
|
|
245
245
|
gl_FragColor.rgb *= color;
|
|
246
246
|
|
|
247
|
-
}`},Kt.Geometry=function(){const o=new c.BufferGeometry,e=new Float32Array([-1,-1,0,0,0,1,-1,0,1,0,1,1,0,1,1,-1,1,0,0,1]),t=new c.InterleavedBuffer(e,5);return o.setIndex([0,1,2,0,2,3]),o.setAttribute("position",new c.InterleavedBufferAttribute(t,3,0,!1)),o.setAttribute("uv",new c.InterleavedBufferAttribute(t,2,3,!1)),o}();function Sl(o){return o}function Al(o){return o*o*o}function Pl(o){return o<.5?4*o*o*o:1-(-2*o+2)**3/2}function Cl(o){return o*o*o*o}function Tl(o){return o<1/2.75?7.5625*o*o:o<2/2.75?7.5625*(o-=1.5/2.75)*o+.75:o<2.5/2.75?7.5625*(o-=2.25/2.75)*o+.9375:7.5625*(o-=2.625/2.75)*o+.984375}const Tr=c.MathUtils.clamp;class Lr{constructor(e=0,t){le(this,"_getNext");le(this,"_getGenerator");this._getGenerator=t??this.getMulberry32,this._getNext=this._getGenerator(e)}seed(e){this._getNext=this._getGenerator(e)}rand(){return this._getNext()}float(e,t){return e+this._getNext()*(t-e)}floatSpread(e){return this.float(-.5*e,.5*e)}int(e,t){return e+Math.floor(this._getNext()*(t-e+1))}choice(e){return e.length?e[Math.floor(this._getNext()*e.length)]:null}defaultChoice(e,t){return e.length?e[Math.floor(this._getNext()*e.length)]:t}sample(e,t,n){const s=e.length;t=Tr(t,0,s-1),n=Tr(n??s-1,0,s-1);const r=this.int(t,n),i=this.shuffle(e.map((l,u)=>u)),a=Math.min(e.length,r);return i.slice(0,a).sort().map(l=>e[l])}shuffle(e){return e.map(t=>({value:t,sort:this._getNext()})).sort((t,n)=>t.sort-n.sort).map(({value:t})=>t)}getMulberry32(e=0){return 0<e&&e<1&&(e=Math.floor(e*2**16)),()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}}const rt="https://raw.githubusercontent.com/Tresjs/assets/93976c7d63ac83d4a254a41a10b2362bc17e90c9/textures/lensflare/",rs=`${rt}circle.png`,gn=`${rt}circleBlur.png`,Ll=`${rt}circleRainbow.png`,Il=`${rt}line.png`,Ir=`${rt}poly6.png`,Dr=`${rt}polyStroke6.png`,Dl=`${rt}rays.png`,yn=`${rt}ring.png`,Ol=`${rt}starThin6.png`,Fl={texture:[Il,yn],color:["white"],distance:[0,0],size:[750,1024],length:[0,2]},kl={texture:[gn],color:["white"],distance:[0,0],size:[180,512],length:[1,1]},Bl={texture:[Dl],color:["white"],distance:[0,0],size:[180,512],length:[1,1]},Ul={texture:[rs,Ll,yn,Ol],color:["white"],distance:[0,0],size:[180,512],length:[2,3]},[Or,Fr]=[3679071,132442],is=[Fl,kl,Bl,Ul,{texture:[gn,rs,yn,Ir,Dr],color:["dimgray","gray","darkgray",Or,Fr],distance:[.5,2.5],size:[20,180],length:[5,21]},{texture:[gn,rs,yn,Ir,Dr],color:["dimgray","gray","darkgray",Or,Fr],distance:[-.6,-.1],size:[180,360],length:[0,5]}],_n={color:"white",distance:0,size:512,texture:gn},kr=(o,e,t=void 0,n=void 0,s=_n)=>{if(o!==void 0&&o.length>0&&(typeof t=="number"||typeof n<"u")){const a=Ur(t??0,n??is),l=a.length,u=o.length;return l>=u?a.map((h,d)=>Object.assign(h,e,d<u?o[d]:{})):o.map((h,d)=>Object.assign({},s,d<l?a[d]:{},e,h))}if(o!==void 0&&o.length>0){const a=Object.assign({},s,e);return o.map(l=>Object.assign({},a,l))}const r=n===void 0||n.length===0?is:n;return Ur(t??0,r).map(a=>Object.assign({},a,e))},Nl=[Sl,Al,Pl,Cl,Tl],Br=c.MathUtils.lerp,Ur=(o=0,e=is)=>{const n=new Lr(o).choice(Nl);return e.map((s,r)=>{const i=new Lr(o*(r*7907+1)+(typeof s.seed=="number"?s.seed:0)),a=i.int(s.length[0],s.length[1]);return new Array(a).fill(0).map(()=>{const l=n(i.rand());return{texture:i.defaultChoice(s.texture,_n.texture),size:Br(s.size[0],s.size[1],n(1-l)),distance:Br(s.distance[0],s.distance[1],l),color:i.defaultChoice(s.color,_n.color)}})}).flat()};function zl(o){return Vl(o,(e,t)=>t in _n&&e!==void 0)}function Vl(o,e){const t={};return Object.keys(o).forEach(n=>{e(o[n],n)&&(t[n]=o[n])}),t}const Rl=f.defineComponent({__name:"component",props:{scale:{default:1},elements:{default:void 0},seed:{default:void 0},seedProps:{default:void 0},color:{default:void 0},distance:{default:void 0},size:{default:void 0},texture:{default:void 0}},setup(o,{expose:e}){const t=o,n=f.shallowRef(),s=f.shallowRef([]),r=f.shallowRef(zl(t));e({value:n});const i=new c.TextureLoader,a=new Kt,l=[],u=()=>{var g,x,w;for(;l.length;)l.pop();(g=n.value)==null||g.children.forEach(v=>{"dispose"in v&&v.dispose()}),(x=n.value)==null||x.remove(...n.value.children),(w=n.value)==null||w.dispose()},h=g=>{if(typeof g.texture=="string"){const x=g.texture;g.texture=i.load(x),g.texture.name=x}return g.color=ae.normalizeColor(g.color),g},d=()=>{for(;s.value.length>l.length;){const x={...h(s.value[l.length])};l.push(x),a.addElement(x)}s.value.forEach((g,x)=>{const w=l[x],{texture:v,size:P,distance:D,color:S}=g;if(typeof v=="string"){if(w.texture.name!==v){w.texture.dispose();const _=v;w.texture=i.load(_),w.texture.name=_}}else w.texture!==v&&(w.texture.dispose(),w.texture=v);w.size=P,w.distance=D,w.color=ae.normalizeColor(S)}),y()},y=()=>{for(let g=s.value.length-1;g<l.length;g++)l[g].size=0;s.value.forEach((g,x)=>{l[x].size=g.size*t.scale})};return f.onUnmounted(()=>{u()}),f.onMounted(()=>{var g;(g=n.value)==null||g.add(a),s.value=kr(t.elements,r.value,t.seed,t.seedProps)}),f.watch(()=>[t.color,t.distance,t.size,t.texture],()=>{r.value={color:t.color,distance:t.distance,size:t.size,texture:t.texture}}),f.watch(()=>[r.value,t.elements,t.seed,t.seedProps],()=>{s.value=kr(t.elements,r.value,t.seed,t.seedProps)}),f.watch(()=>t.scale,()=>{y()}),f.watch(()=>s.value,()=>{d()}),(g,x)=>(f.openBlock(),f.createElementBlock("TresGroup",{ref_key:"lensflareRef",ref:n},null,512))}});function Nr(o){const e=f.ref(null),{height:t,width:n,settings:s,depth:r}=f.isReactive(o)?f.toRefs(o):f.toRefs(f.reactive(o)),{onLoop:i}=ae.useRenderLoop(),{camera:a,renderer:l,scene:u,sizes:h}=ae.useTresContext();return f.watchEffect(()=>{var d;(d=e.value)==null||d.dispose(),e.value=new c.WebGLRenderTarget((n==null?void 0:n.value)||h.width.value,(t==null?void 0:t.value)||h.height.value,{minFilter:c.LinearFilter,magFilter:c.LinearFilter,type:c.HalfFloatType,...s==null?void 0:s.value}),r!=null&&r.value&&(e.value.depthTexture=new c.DepthTexture((n==null?void 0:n.value)||h.width.value,(t==null?void 0:t.value)||h.height.value,c.FloatType))}),i(()=>{l.value.setRenderTarget(e.value),l.value.clear(),l.value.render(u.value,a.value),l.value.setRenderTarget(null)}),f.onBeforeUnmount(()=>{var d;(d=e.value)==null||d.dispose()}),e}const Gl=f.defineComponent({__name:"component",props:{width:{},height:{},depth:{type:Boolean,default:!1},settings:{default:void 0}},setup(o,{expose:e}){const n=Nr(o);return e({value:n}),()=>{}}}),zr=(o,e=16,t,n,s)=>{const r=new Float32Array(e*16),i=f.ref(new c.InterleavedBuffer(r,16));return(()=>{if(!o)return;const l=new To(o);n&&l.setWeightAttribute(n),l.build();const u=new c.Vector3,h=new c.Vector3,d=new c.Color,y=new c.Object3D;o.updateMatrixWorld(!0);for(let g=0;g<e;g++)l.sample(u,h,d),typeof s=="function"?s({dummy:y,sampledMesh:o,position:u,normal:h,color:d},g):y.position.copy(u),y.updateMatrix(),t&&t.setMatrixAt(g,y.matrix),y.matrix.toArray(i.value.array,g*16);t&&(t.instanceMatrix.needsUpdate=!0),i.value.needsUpdate=!0})(),{buffer:i}},jl=f.defineComponent({__name:"component",props:{transform:{type:Function},weight:{},count:{},mesh:{},instanceMesh:{}},setup(o,{expose:e}){const t=o,n=f.ref(),s=f.ref(),r=f.ref();return f.watchEffect(()=>{var i,a;s.value=t.instanceMesh??((i=n.value)==null?void 0:i.children.find(l=>l.hasOwnProperty("instanceMatrix"))),r.value=t.mesh??((a=n.value)==null?void 0:a.children.find(l=>l.type==="Mesh")),zr(r.value,t.count,s.value,t.weight,t.transform)}),e({samplerRef:n}),(i,a)=>(f.openBlock(),f.createElementBlock("TresGroup",{ref_key:"samplerRef",ref:n},[f.renderSlot(i.$slots,"default")],512))}}),vn={sunset:"venice/venice_sunset_1k.hdr",studio:"studio/poly_haven_studio_1k.hdr",city:"city/canary_wharf_1k.hdr",umbrellas:"outdoor/outdoor_umbrellas_1k.hdr",night:"outdoor/satara_night_1k.hdr",forest:"outood/mossy_forest_1k.hdr",snow:"outdoor/snowy_forest_path_01_1k.hdr",dawn:"kiara/kiara_1_dawn_1k.hdr",hangar:"indoor/small_hangar_01_1k.hdr",urban:"indoor/abandoned_games_room_02_1k.hdr",modern:"city/modern_buildings_2_1k.hdr",shangai:"city/shanghai_bund_1k.hdr"},El="https://raw.githubusercontent.com/Tresjs/assets/main/textures/hdr/";async function Vr(o){const{scene:e}=ae.useTresContext(),{preset:t,blur:n,files:s=[],path:r="",background:i}=f.toRefs(o),a=f.ref(),l=f.computed(()=>Array.isArray(s.value)),u=f.computed(()=>l.value?c.CubeTextureLoader:xr),h=f.ref(null);return f.watch(()=>[s,r],async([d,y])=>{if(d.value.length>0&&!t.value){try{h.value=await ae.useLoader(f.unref(u),l.value?[f.unref(d)]:f.unref(d),g=>{y.value&&g.setPath(f.unref(y))})}catch(g){throw new Error(`Failed to load environment map: ${g}`)}h.value&&(a.value=l.value?h.value[0]:h.value,a.value.mapping=l.value?c.CubeReflectionMapping:c.EquirectangularReflectionMapping)}},{immediate:!0}),f.watch(()=>a.value,d=>{e.value&&(e.value.environment=d)},{immediate:!0}),f.watch(()=>[i.value,a.value],([d,y])=>{e.value&&(e.value.background=d?y:void 0)},{immediate:!0}),f.watch(()=>n==null?void 0:n.value,d=>{e.value&&(e.value.backgroundBlurriness=d)},{immediate:!0}),f.watch(t,async d=>{if(d&&d in vn){const y=El,g=vn[d];try{h.value=await ae.useLoader(xr,g,x=>{y&&x.setPath(y)})}catch(x){throw new Error(`Failed to load environment map: ${x}`)}h.value&&(a.value=h.value,a.value.mapping=c.EquirectangularReflectionMapping)}else if(d&&!(d in vn))throw new Error(`Preset must be one of: ${Object.keys(vn).join(", ")}`)},{immediate:!0}),{texture:a}}let xn=null;function Yl(o,e){return t=>{e&&e(t),o.draco&&(xn||(xn=new Ka),xn.setDecoderPath(o.decoderPath||"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),t.setDRACOLoader(xn))}}async function Rr(o,e={draco:!1},t){return await ae.useLoader(Eo,o,Yl(e,t))}const Xl=["object"],Wl=f.defineComponent({__name:"component",props:{path:{},draco:{type:Boolean,default:!1},decoderPath:{default:"https://www.gstatic.com/draco/versioned/decoders/1.4.1/"},castShadow:{type:Boolean,default:!1},receiveShadow:{type:Boolean,default:!1}},async setup(o,{expose:e}){let t,n;const s=o,r=f.ref();e({value:r});const{scene:i}=([t,n]=f.withAsyncContext(()=>Rr(s.path,{draco:s.draco,decoderPath:s.decoderPath})),t=await t,n(),t);return(s.castShadow||s.receiveShadow)&&i.traverse(a=>{a.isMesh&&(a.castShadow=s.castShadow,a.receiveShadow=s.receiveShadow)}),(a,l)=>(f.openBlock(),f.createElementBlock("primitive",f.mergeProps({ref_key:"modelRef",ref:r,object:f.unref(i)},a.$attrs),null,16,Xl))}});async function Gr(o){return await ae.useLoader(Da,o)}const Zl=["object"],Kl=f.defineComponent({__name:"component",props:{path:{},castShadow:{type:Boolean,default:!1},receiveShadow:{type:Boolean,default:!1}},async setup(o,{expose:e}){let t,n;const s=o,r=f.ref();e({value:r});const i=([t,n]=f.withAsyncContext(()=>Gr(s.path)),t=await t,n(),t);return(s.castShadow||s.receiveShadow)&&i.traverse(a=>{a.isMesh&&(a.castShadow=s.castShadow,a.receiveShadow=s.receiveShadow)}),(a,l)=>(f.openBlock(),f.createElementBlock("primitive",f.mergeProps({ref_key:"modelRef",ref:r,object:f.unref(i)},a.$attrs),null,16,Zl))}}),ql=["geometry","render-order"],Ql=f.defineComponent({__name:"component",props:{src:{},skipStrokes:{type:Boolean,default:!1},skipFills:{type:Boolean,default:!1},fillMaterial:{},strokeMaterial:{},fillMeshProps:{},strokeMeshProps:{},depth:{default:"renderOrder"}},setup(o,{expose:e}){const t=o,{src:n,skipStrokes:s,skipFills:r,fillMaterial:i,strokeMaterial:a,fillMeshProps:l,strokeMeshProps:u,depth:h}=f.toRefs(t),d=f.shallowRef(),y=f.shallowRef([]),g=f.shallowRef([]);e({value:d}),f.watchEffect(async()=>x(n.value).then(P=>g.value=P.paths)),f.watch([r,s,i,a,g],v);async function x(P){const D=P.startsWith("<svg")?encodeURI(`data:image/svg+xml;utf8,${P}`):P;return ae.useLoader(Wt,D)}f.onUnmounted(w);function w(){y.value.forEach(P=>P.geometry.dispose())}function v(){var L,b,C;w();const P=[],[D,S]=(()=>{const m={flat:!1,renderOrder:!1,offsetZ:!0},M={flat:0,renderOrder:0,offsetZ:.025},p=h.value;return typeof p=="number"?[!0,p]:[m[p],M[p]]})();let _=0;for(const m of g.value){const M=((L=m.userData)==null?void 0:L.style)??{},p=Object.assign({color:M.fill,opacity:M.fillOpacity,transparent:!0,side:c.DoubleSide,depthWrite:D},t.fillMaterial);if(!r.value&&M.fill!==void 0&&M.fill!=="none")for(const I of Wt.createShapes(m)){const F=new c.ShapeGeometry(I);F.scale(1,-1,1),S&&F.translate(0,0,_++*S),P.push({geometry:F,material:p,isStroke:!1})}if(!s.value&&M.stroke!==void 0&&M.stroke!=="none"){const I=Object.assign({color:(b=m.userData)==null?void 0:b.style.stroke,opacity:(C=m.userData)==null?void 0:C.style.strokeOpacity,transparent:!0,side:c.DoubleSide,depthWrite:D},t.strokeMaterial);for(const F of m.subPaths){const J=F.getPoints().map(Q=>new c.Vector2(Q.x,-Q.y)),G=Wt.pointsToStroke(J,M||"none");S&&G.translate(0,0,_++*S),P.push({geometry:G,material:I,isStroke:!0})}}}y.value=P}return(P,D)=>(f.openBlock(),f.createElementBlock("TresGroup",{ref_key:"svgRef",ref:d},[(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(y.value,({geometry:S,material:_,isStroke:L},b)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({key:`${b}`},L?f.unref(u):f.unref(l),{geometry:S,"render-order":f.unref(h)==="renderOrder"?b:0}),[f.createElementVNode("TresMeshBasicMaterial",f.normalizeProps(f.guardReactiveProps(_)),null,16)],16,ql))),128))],512))}}),jr="[TresJS - Cientos ▲ ■ ♥] ";function os(){function o(n,s){console.error(`${jr} ${n}`,s||"")}function e(n){console.warn(`${jr} ${n}`)}function t(n,s){}return{logError:o,logWarning:e,logMessage:t}}let as=0;function Jl(){const o=f.ref(!1),e=f.ref(0),t=f.ref([]),{logError:n}=os();return new Promise(s=>{c.DefaultLoadingManager.onStart=()=>{o.value=!1},c.DefaultLoadingManager.onLoad=()=>{o.value=!0},c.DefaultLoadingManager.onProgress=(r,i,a)=>{i===a&&(as=a,o.value=!0,t.value.push(r)),e.value=Math.round((i-as)/(a-as)*100||100,2)},c.DefaultLoadingManager.onError=r=>{n("Error loading assets",new Error(r)),o.value=!0},s({items:t,hasFinishLoading:o,progress:e})})}async function Hl(o,e){const{logError:t}=os();if(!o)return t("Error no path provided");const{unsuspend:n,start:s,crossOrigin:r,muted:i,loop:a,...l}={unsuspend:"loadedmetadata",crossOrigin:"Anonymous",muted:!0,loop:!0,start:!0,playsInline:!0,...e};function u(){return new Promise((h,d)=>{const y=Object.assign(document.createElement("video"),{src:typeof o=="string"&&o||void 0,crossOrigin:r,loop:a,muted:i,autoplay:!0,...l}),g=new c.VideoTexture(y);return y.addEventListener(n,()=>h(g)),y.addEventListener("error",()=>d()),g})}try{const h=await u();return s&&h.image&&h.image.play(),h}catch{t("Error loading resource")}}const $l=["target","auto-rotate","auto-rotate-speed","enable-damping","damping-factor","enable-pan","key-pan-speed","keys","max-azimuth-angle","min-azimuth-angle","max-polar-angle","min-polar-angle","min-distance","max-distance","min-zoom","max-zoom","touches","enable-zoom","zoom-speed","enable-rotate","rotate-speed","args"],ec=f.defineComponent({__name:"OrbitControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},target:{default:()=>[0,0,0]},enableDamping:{type:Boolean,default:!0},dampingFactor:{default:.05},autoRotate:{type:Boolean,default:!1},autoRotateSpeed:{default:2},enablePan:{type:Boolean,default:!0},keyPanSpeed:{default:7},keys:{},maxAzimuthAngle:{default:1/0},minAzimuthAngle:{default:-1/0},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:1/0},minZoom:{default:0},maxZoom:{default:1/0},touches:{default:()=>({ONE:c.TOUCH.ROTATE,TWO:c.TOUCH.DOLLY_PAN})},enableZoom:{type:Boolean,default:!0},zoomSpeed:{default:1},enableRotate:{type:Boolean,default:!0},rotateSpeed:{default:1}},emits:["change","start","end"],setup(o,{expose:e,emit:t}){const n=o,s=t,{makeDefault:r,autoRotate:i,autoRotateSpeed:a,enableDamping:l,dampingFactor:u,enablePan:h,keyPanSpeed:d,maxAzimuthAngle:y,minAzimuthAngle:g,maxPolarAngle:x,minPolarAngle:w,minDistance:v,maxDistance:P,minZoom:D,maxZoom:S,enableZoom:_,zoomSpeed:L,enableRotate:b,touches:C,rotateSpeed:m,target:M}=f.toRefs(n),{camera:p,renderer:I,extend:F,controls:J}=ae.useTresContext(),G=f.ref(null);F({OrbitControls:sr}),f.watch(G,Z=>{Q(),Z&&r.value?J.value=Z:J.value=null});function Q(){Le(G.value,"change",()=>s("change",G.value)),Le(G.value,"start",()=>s("start",G.value)),Le(G.value,"end",()=>s("end",G.value))}const{onLoop:K}=ae.useRenderLoop();return K(()=>{G.value&&(l.value||i.value)&&G.value.update()}),f.onUnmounted(()=>{G.value&&G.value.dispose()}),e({value:G}),(Z,X)=>(Z.camera||f.unref(p))&&(Z.domElement||f.unref(I))?(f.openBlock(),f.createElementBlock("TresOrbitControls",{key:0,ref_key:"controlsRef",ref:G,target:f.unref(M),"auto-rotate":f.unref(i),"auto-rotate-speed":f.unref(a),"enable-damping":f.unref(l),"damping-factor":f.unref(u),"enable-pan":f.unref(h),"key-pan-speed":f.unref(d),keys:Z.keys,"max-azimuth-angle":f.unref(y),"min-azimuth-angle":f.unref(g),"max-polar-angle":f.unref(x),"min-polar-angle":f.unref(w),"min-distance":f.unref(v),"max-distance":f.unref(P),"min-zoom":f.unref(D),"max-zoom":f.unref(S),touches:f.unref(C),"enable-zoom":f.unref(_),"zoom-speed":f.unref(L),"enable-rotate":f.unref(b),"rotate-speed":f.unref(m),args:[Z.camera||f.unref(p),Z.domElement||f.unref(I).domElement]},null,8,$l)):f.createCommentVNode("",!0)}}),tc=5,nc=6,sc=.3,rc=f.defineComponent({__name:"KeyboardControls",props:{forward:{default:()=>["w","W"]},back:{default:()=>["s","S"]},left:{default:()=>["a","A"]},right:{default:()=>["d","D"]},jump:{default:()=>[" "]},gravity:{default:9.8},moveSpeed:{default:.1},headBobbing:{type:Boolean,default:!1},is2D:{type:Boolean,default:!1}},setup(o){var p;const e=o,{forward:t,back:n,left:s,right:r,jump:i,gravity:a,moveSpeed:l,headBobbing:u,is2D:h}=f.toRefs(e),{camera:d,controls:y}=ae.useTresContext(),g=f.ref(0),x=f.ref(0),w=f.ref(!1),v=f.ref(!1),P=f.ref(0),D=f.shallowRef(),S=h.value?"y":"z",_=((p=d.value.position)==null?void 0:p.y)||0;St(t.value,()=>{w.value=!0,x.value=l.value},{eventName:"keydown"}),St(n.value,()=>{w.value=!0,x.value=-l.value},{eventName:"keydown"}),St([...t.value,...n.value],()=>{w.value=!1,x.value=0},{eventName:"keyup"}),St(s.value,()=>{w.value=!0,g.value=-l.value},{eventName:"keydown"}),St(r.value,()=>{w.value=!0,g.value=l.value},{eventName:"keydown"}),St([...s.value,...r.value],()=>{w.value=!1,g.value=0},{eventName:"keyup"}),St(i.value,()=>{v.value||(P.value=Date.now()),v.value=!0});const L=I=>w.value?Math.sin(I*tc)*sc+_:_,b=()=>(Date.now()-P.value)/1e3*3,C=I=>_+nc*I-.5*a.value*I**2,m=()=>{if(v.value){const I=C(b());return I<=_&&(v.value=!1),I}return 0},{onLoop:M}=ae.useRenderLoop();return M(({elapsed:I})=>{var F;y.value instanceof Wn&&((F=y.value)!=null&&F.isLocked)?(y.value.moveForward(x.value),y.value.moveRight(g.value),d.value.position&&(d.value.position.y=u.value?L(I):_,d.value.position.y+=m())):D.value.children.length>0&&!(y.value instanceof Wn)&&(D.value.position.x+=g.value,D.value.position[S]+=h.value?x.value:-x.value)}),(I,F)=>(f.openBlock(),f.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:D},[f.renderSlot(I.$slots,"default")],512))}}),ic=["object","args","mode","enabled","axis","translation-snap","rotation-snap","scale-snap","space","size","show-x","show-y","show-z"],oc=f.defineComponent({__name:"TransformControls",props:{object:{},mode:{default:"translate"},enabled:{type:Boolean,default:!0},axis:{default:"XYZ"},translationSnap:{},rotationSnap:{},scaleSnap:{},space:{default:"world"},size:{default:1},showX:{type:Boolean,default:!0},showY:{type:Boolean,default:!0},showZ:{type:Boolean,default:!0}},emits:["dragging","change","mouseDown","mouseUp","objectChange"],setup(o,{emit:e}){const t=o,n=e,{object:s,mode:r,enabled:i,axis:a,translationSnap:l,rotationSnap:u,scaleSnap:h,space:d,size:y,showX:g,showY:x,showZ:w}=f.toRefs(t),v=f.shallowRef(),{controls:P,camera:D,renderer:S,extend:_}=ae.useTresContext();_({TransformControls:Do});const L=C=>{P.value&&(P.value.enabled=!C.value),n("dragging",C.value)};function b(){Le(v.value,"change",()=>n("change")),Le(v.value,"dragging-changed",L),Le(v.value,"mouseDown",()=>n("mouseDown")),Le(v.value,"mouseUp",()=>n("mouseUp")),Le(v.value,"objectChange",()=>n("objectChange"))}return f.watchEffect(()=>{v.value&&b()}),f.onUnmounted(()=>{v.value&&v.value.dispose()}),(C,m)=>f.unref(D)&&f.unref(S)?(f.openBlock(),f.createElementBlock("TresTransformControls",{key:0,ref_key:"controlsRef",ref:v,object:f.unref(s),args:[f.unref(D),f.unref(S).domElement],mode:f.unref(r),enabled:f.unref(i),axis:f.unref(a),"translation-snap":f.unref(l),"rotation-snap":f.unref(u),"scale-snap":f.unref(h),space:f.unref(d),size:f.unref(y),"show-x":f.unref(g),"show-y":f.unref(x),"show-z":f.unref(w),visible:!0},null,8,ic)):f.createCommentVNode("",!0)}}),ac=["args"],lc=f.defineComponent({__name:"PointerLockControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},selector:{}},emits:["isLock","change"],setup(o,{expose:e,emit:t}){const n=o,s=t,{camera:r,renderer:i,extend:a,controls:l}=ae.useTresContext(),u=f.ref(null);let h;a({PointerLockControls:Wn});const d=y=>{s("isLock",y)};return f.watch(u,y=>{y&&n.makeDefault?l.value=y:l.value=null;const g=document.getElementById(n.selector||"");h=g||i.value.domElement,Le(l.value,"change",()=>s("change",l.value)),Le(h,"click",()=>{var x,w,v;(x=l.value)==null||x.lock(),(w=l.value)==null||w.addEventListener("lock",()=>d(!0)),(v=l.value)==null||v.addEventListener("unlock",()=>d(!1))})}),f.onUnmounted(()=>{var y,g;(y=l.value)==null||y.removeEventListener("lock",()=>d(!0)),(g=l.value)==null||g.removeEventListener("unlock",()=>d(!1)),u.value&&u.value.dispose()}),e({value:l}),(y,g)=>(y.camera||f.unref(r))&&(y.domElement||f.unref(i))?(f.openBlock(),f.createElementBlock("TresPointerLockControls",{key:0,ref_key:"controlsRef",ref:u,args:[y.camera||f.unref(r),y.domElement||f.unref(i).domElement]},null,8,ac)):f.createCommentVNode("",!0)}}),cc=["args"],uc=f.defineComponent({__name:"MapControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{}},setup(o){const e=o,{camera:t,renderer:n,extend:s,controls:r}=ae.useTresContext(),i=f.ref(null);return s({MapControls:jo}),f.watch(r,a=>{a&&e.makeDefault?r.value=a:r.value=null}),f.onUnmounted(()=>{i.value&&i.value.dispose()}),(a,l)=>(a.camera||f.unref(t))&&(a.domElement||f.unref(n))?(f.openBlock(),f.createElementBlock("TresMapControls",{key:0,ref_key:"controlsRef",ref:i,args:[a.camera||f.unref(t),a.domElement||f.unref(n).domElement]},null,8,cc)):f.createCommentVNode("",!0)}}),hc=f.defineComponent({__name:"ScrollControls",props:{pages:{default:4},distance:{default:4},smoothScroll:{default:.1},horizontal:{type:Boolean,default:!1},htmlScroll:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(o,{emit:e}){const t=o,n=e,{logWarning:s}=ae.useLogger();t.smoothScroll<0&&s("SmoothControl must be greater than zero"),t.pages<0&&s("Pages must be greater than zero");const{camera:r,controls:i,renderer:a}=ae.useTresContext(),l=f.shallowRef(),u=document.createElement("div"),{y:h}=wl(),{x:d,y,isScrolling:g}=_l(u),{height:x,width:w}=Pr();let v=0;const P=f.ref(!1),D=f.ref(0),S=f.ref(0),_=f.ref(0),L=t.horizontal?"x":"y",b=f.watch(r,m=>{if(P.value){b();return}v=t.horizontal?(m==null?void 0:m.position.x)||0:(m==null?void 0:m.position.y)||0,P.value=!0},{immediate:!0});f.watch(g,m=>{i.value&&(i.value.enabled=!m)},{immediate:!0}),f.watch(h,m=>{!g.value&&!t.htmlScroll||(S.value=m/x.value/(_.value/x.value-1),D.value=-1*S.value,n("update:modelValue",S.value))}),f.watch(y,m=>{S.value=m/x.value/(_.value/x.value),D.value=-1*S.value,n("update:modelValue",S.value)}),f.watch(d,m=>{S.value=m/w.value/(_.value/w.value-1),D.value=+S.value,n("update:modelValue",S.value)}),f.watch(a,m=>{var p,I;const M=m==null?void 0:m.domElement;if(t.htmlScroll&&(m!=null&&m.domElement))M!=null&&M.style.width&&(M!=null&&M.style.position)&&(M!=null&&M.style.top)&&(M!=null&&M.style.left)&&(M.style.width="100%",M.style.position="fixed",M.style.zIndex=" -99999",M.style.top="0",M.style.left="0"),_.value=document.body.scrollHeight;else{const F=document.createElement("div"),J=document.createElement("div");u.style[t.horizontal?"overflowX":"overflowY"]="auto",u.style[t.horizontal?"overflowY":"overflowX"]="hidden",u.style.position="absolute",u.style.width="100%",u.style.height=" 100%",u.style.top="0",u.style.left="0",u.classList.add("scrollContainer"),F.style.position="sticky",F.style.top="0px",F.style.left="0px",F.style.width="100%",F.style.height="100%",F.style.overflow="hidden",u.appendChild(F),J.style.height=t.horizontal?"100%":`${x.value*t.pages}px`,J.style.width=t.horizontal?`${w.value*t.pages}px`:"100vw",J.style.pointerEvents="none",M.style.position="fixed",M.style.zIndex="0",M!=null&&M.style.width&&(M.style.width="100%"),u.appendChild(J),m.domElement.parentNode.style.position="relative",(I=(p=m==null?void 0:m.domElement)==null?void 0:p.parentNode)==null||I.appendChild(u),_.value=t.horizontal?w.value*t.pages:x.value*t.pages}},{immediate:!0});const{onLoop:C}=ae.useRenderLoop();return C(()=>{var m;if((m=r.value)!=null&&m.position){const M=(D.value*t.distance-r.value.position[L]+v)*t.smoothScroll;r.value.position[L]+=M,l.value.children.length>0&&(l.value.position[L]+=M)}}),(m,M)=>(f.openBlock(),f.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:l},[f.renderSlot(m.$slots,"default")],512))}});/*!
|
|
247
|
+
}`},Qt.Geometry=function(){const o=new c.BufferGeometry,e=new Float32Array([-1,-1,0,0,0,1,-1,0,1,0,1,1,0,1,1,-1,1,0,0,1]),t=new c.InterleavedBuffer(e,5);return o.setIndex([0,1,2,0,2,3]),o.setAttribute("position",new c.InterleavedBufferAttribute(t,3,0,!1)),o.setAttribute("uv",new c.InterleavedBufferAttribute(t,2,3,!1)),o}();function Cl(o){return o}function Tl(o){return o*o*o}function Ll(o){return o<.5?4*o*o*o:1-(-2*o+2)**3/2}function Dl(o){return o*o*o*o}function Il(o){return o<1/2.75?7.5625*o*o:o<2/2.75?7.5625*(o-=1.5/2.75)*o+.75:o<2.5/2.75?7.5625*(o-=2.25/2.75)*o+.9375:7.5625*(o-=2.625/2.75)*o+.984375}const Ds=c.MathUtils.clamp;class Is{constructor(e=0,t){le(this,"_getNext");le(this,"_getGenerator");this._getGenerator=t??this.getMulberry32,this._getNext=this._getGenerator(e)}seed(e){this._getNext=this._getGenerator(e)}rand(){return this._getNext()}float(e,t){return e+this._getNext()*(t-e)}floatSpread(e){return this.float(-.5*e,.5*e)}int(e,t){return e+Math.floor(this._getNext()*(t-e+1))}choice(e){return e.length?e[Math.floor(this._getNext()*e.length)]:null}defaultChoice(e,t){return e.length?e[Math.floor(this._getNext()*e.length)]:t}sample(e,t,n){const r=e.length;t=Ds(t,0,r-1),n=Ds(n??r-1,0,r-1);const s=this.int(t,n),i=this.shuffle(e.map((l,u)=>u)),a=Math.min(e.length,s);return i.slice(0,a).sort().map(l=>e[l])}shuffle(e){return e.map(t=>({value:t,sort:this._getNext()})).sort((t,n)=>t.sort-n.sort).map(({value:t})=>t)}getMulberry32(e=0){return 0<e&&e<1&&(e=Math.floor(e*2**16)),()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}}const it="https://raw.githubusercontent.com/Tresjs/assets/93976c7d63ac83d4a254a41a10b2362bc17e90c9/textures/lensflare/",or=`${it}circle.png`,_n=`${it}circleBlur.png`,Ol=`${it}circleRainbow.png`,kl=`${it}line.png`,Os=`${it}poly6.png`,ks=`${it}polyStroke6.png`,Bl=`${it}rays.png`,vn=`${it}ring.png`,Fl=`${it}starThin6.png`,Ul={texture:[kl,vn],color:["white"],distance:[0,0],size:[750,1024],length:[0,2]},Nl={texture:[_n],color:["white"],distance:[0,0],size:[180,512],length:[1,1]},zl={texture:[Bl],color:["white"],distance:[0,0],size:[180,512],length:[1,1]},Vl={texture:[or,Ol,vn,Fl],color:["white"],distance:[0,0],size:[180,512],length:[2,3]},[Bs,Fs]=[3679071,132442],ar=[Ul,Nl,zl,Vl,{texture:[_n,or,vn,Os,ks],color:["dimgray","gray","darkgray",Bs,Fs],distance:[.5,2.5],size:[20,180],length:[5,21]},{texture:[_n,or,vn,Os,ks],color:["dimgray","gray","darkgray",Bs,Fs],distance:[-.6,-.1],size:[180,360],length:[0,5]}],xn={color:"white",distance:0,size:512,texture:_n},Us=(o,e,t=void 0,n=void 0,r=xn)=>{if(o!==void 0&&o.length>0&&(typeof t=="number"||typeof n<"u")){const a=zs(t??0,n??ar),l=a.length,u=o.length;return l>=u?a.map((h,d)=>Object.assign(h,e,d<u?o[d]:{})):o.map((h,d)=>Object.assign({},r,d<l?a[d]:{},e,h))}if(o!==void 0&&o.length>0){const a=Object.assign({},r,e);return o.map(l=>Object.assign({},a,l))}const s=n===void 0||n.length===0?ar:n;return zs(t??0,s).map(a=>Object.assign({},a,e))},Rl=[Cl,Tl,Ll,Dl,Il],Ns=c.MathUtils.lerp,zs=(o=0,e=ar)=>{const n=new Is(o).choice(Rl);return e.map((r,s)=>{const i=new Is(o*(s*7907+1)+(typeof r.seed=="number"?r.seed:0)),a=i.int(r.length[0],r.length[1]);return new Array(a).fill(0).map(()=>{const l=n(i.rand());return{texture:i.defaultChoice(r.texture,xn.texture),size:Ns(r.size[0],r.size[1],n(1-l)),distance:Ns(r.distance[0],r.distance[1],l),color:i.defaultChoice(r.color,xn.color)}})}).flat()};function Gl(o){return jl(o,(e,t)=>t in xn&&e!==void 0)}function jl(o,e){const t={};return Object.keys(o).forEach(n=>{e(o[n],n)&&(t[n]=o[n])}),t}const El=f.defineComponent({__name:"component",props:{scale:{default:1},elements:{default:void 0},seed:{default:void 0},seedProps:{default:void 0},color:{default:void 0},distance:{default:void 0},size:{default:void 0},texture:{default:void 0}},setup(o,{expose:e}){const t=o,n=f.shallowRef(),r=f.shallowRef([]),s=f.shallowRef(Gl(t));e({value:n});const i=new c.TextureLoader,a=new Qt,l=[],u=()=>{var y,x,w;for(;l.length;)l.pop();(y=n.value)==null||y.children.forEach(v=>{"dispose"in v&&v.dispose()}),(x=n.value)==null||x.remove(...n.value.children),(w=n.value)==null||w.dispose()},h=y=>{if(typeof y.texture=="string"){const x=y.texture;y.texture=i.load(x),y.texture.name=x}return y.color=ae.normalizeColor(y.color),y},d=()=>{for(;r.value.length>l.length;){const x={...h(r.value[l.length])};l.push(x),a.addElement(x)}r.value.forEach((y,x)=>{const w=l[x],{texture:v,size:A,distance:D,color:M}=y;if(typeof v=="string"){if(w.texture.name!==v){w.texture.dispose();const _=v;w.texture=i.load(_),w.texture.name=_}}else w.texture!==v&&(w.texture.dispose(),w.texture=v);w.size=A,w.distance=D,w.color=ae.normalizeColor(M)}),g()},g=()=>{for(let y=r.value.length-1;y<l.length;y++)l[y].size=0;r.value.forEach((y,x)=>{l[x].size=y.size*t.scale})};return f.onUnmounted(()=>{u()}),f.onMounted(()=>{var y;(y=n.value)==null||y.add(a),r.value=Us(t.elements,s.value,t.seed,t.seedProps)}),f.watch(()=>[t.color,t.distance,t.size,t.texture],()=>{s.value={color:t.color,distance:t.distance,size:t.size,texture:t.texture}}),f.watch(()=>[s.value,t.elements,t.seed,t.seedProps],()=>{r.value=Us(t.elements,s.value,t.seed,t.seedProps)}),f.watch(()=>t.scale,()=>{g()}),f.watch(()=>r.value,()=>{d()}),(y,x)=>(f.openBlock(),f.createElementBlock("TresGroup",{ref_key:"lensflareRef",ref:n},null,512))}});function Vs(o){const e=f.ref(null),{height:t,width:n,settings:r,depth:s}=f.isReactive(o)?f.toRefs(o):f.toRefs(f.reactive(o)),{onLoop:i}=ae.useRenderLoop(),{camera:a,renderer:l,scene:u,sizes:h}=ae.useTresContext();return f.watchEffect(()=>{var d;(d=e.value)==null||d.dispose(),e.value=new c.WebGLRenderTarget((n==null?void 0:n.value)||h.width.value,(t==null?void 0:t.value)||h.height.value,{minFilter:c.LinearFilter,magFilter:c.LinearFilter,type:c.HalfFloatType,...r==null?void 0:r.value}),s!=null&&s.value&&(e.value.depthTexture=new c.DepthTexture((n==null?void 0:n.value)||h.width.value,(t==null?void 0:t.value)||h.height.value,c.FloatType))}),i(()=>{l.value.setRenderTarget(e.value),l.value.clear(),l.value.render(u.value,a.value),l.value.setRenderTarget(null)}),f.onBeforeUnmount(()=>{var d;(d=e.value)==null||d.dispose()}),e}const Wl=f.defineComponent({__name:"component",props:{width:{},height:{},depth:{type:Boolean,default:!1},settings:{default:void 0}},setup(o,{expose:e}){const n=Vs(o);return e({value:n}),()=>{}}}),Rs=(o,e=16,t,n,r)=>{const s=new Float32Array(e*16),i=f.ref(new c.InterleavedBuffer(s,16));return(()=>{if(!o)return;const l=new Do(o);n&&l.setWeightAttribute(n),l.build();const u=new c.Vector3,h=new c.Vector3,d=new c.Color,g=new c.Object3D;o.updateMatrixWorld(!0);for(let y=0;y<e;y++)l.sample(u,h,d),typeof r=="function"?r({dummy:g,sampledMesh:o,position:u,normal:h,color:d},y):g.position.copy(u),g.updateMatrix(),t&&t.setMatrixAt(y,g.matrix),g.matrix.toArray(i.value.array,y*16);t&&(t.instanceMatrix.needsUpdate=!0),i.value.needsUpdate=!0})(),{buffer:i}},Yl=f.defineComponent({__name:"component",props:{transform:{type:Function},weight:{},count:{},mesh:{},instanceMesh:{}},setup(o,{expose:e}){const t=o,n=f.ref(),r=f.ref(),s=f.ref();return f.watchEffect(()=>{var i,a;r.value=t.instanceMesh??((i=n.value)==null?void 0:i.children.find(l=>l.hasOwnProperty("instanceMatrix"))),s.value=t.mesh??((a=n.value)==null?void 0:a.children.find(l=>l.type==="Mesh")),Rs(s.value,t.count,r.value,t.weight,t.transform)}),e({samplerRef:n}),(i,a)=>(f.openBlock(),f.createElementBlock("TresGroup",{ref_key:"samplerRef",ref:n},[f.renderSlot(i.$slots,"default")],512))}}),wn={sunset:"venice/venice_sunset_1k.hdr",studio:"studio/poly_haven_studio_1k.hdr",city:"city/canary_wharf_1k.hdr",umbrellas:"outdoor/outdoor_umbrellas_1k.hdr",night:"outdoor/satara_night_1k.hdr",forest:"outood/mossy_forest_1k.hdr",snow:"outdoor/snowy_forest_path_01_1k.hdr",dawn:"kiara/kiara_1_dawn_1k.hdr",hangar:"indoor/small_hangar_01_1k.hdr",urban:"indoor/abandoned_games_room_02_1k.hdr",modern:"city/modern_buildings_2_1k.hdr",shangai:"city/shanghai_bund_1k.hdr"},Xl="https://raw.githubusercontent.com/Tresjs/assets/main/textures/hdr/";async function Gs(o){const{scene:e}=ae.useTresContext(),{preset:t,blur:n,files:r=[],path:s="",background:i}=f.toRefs(o),a=f.ref(),l=f.computed(()=>Array.isArray(r.value)),u=f.computed(()=>l.value?c.CubeTextureLoader:bs),h=f.ref(null);return f.watch(()=>[r,s],async([d,g])=>{if(d.value.length>0&&!t.value){try{h.value=await ae.useLoader(f.unref(u),l.value?[f.unref(d)]:f.unref(d),y=>{g.value&&y.setPath(f.unref(g))})}catch(y){throw new Error(`Failed to load environment map: ${y}`)}h.value&&(a.value=l.value?h.value[0]:h.value,a.value.mapping=l.value?c.CubeReflectionMapping:c.EquirectangularReflectionMapping)}},{immediate:!0}),f.watch(()=>a.value,d=>{e.value&&(e.value.environment=d)},{immediate:!0}),f.watch(()=>[i.value,a.value],([d,g])=>{e.value&&(e.value.background=d?g:void 0)},{immediate:!0}),f.watch(()=>n==null?void 0:n.value,d=>{e.value&&(e.value.backgroundBlurriness=d)},{immediate:!0}),f.watch(t,async d=>{if(d&&d in wn){const g=Xl,y=wn[d];try{h.value=await ae.useLoader(bs,y,x=>{g&&x.setPath(g)})}catch(x){throw new Error(`Failed to load environment map: ${x}`)}h.value&&(a.value=h.value,a.value.mapping=c.EquirectangularReflectionMapping)}else if(d&&!(d in wn))throw new Error(`Preset must be one of: ${Object.keys(wn).join(", ")}`)},{immediate:!0}),{texture:a}}let bn=null;function Zl(o,e){return t=>{e&&e(t),o.draco&&(bn||(bn=new Ja),bn.setDecoderPath(o.decoderPath||"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),t.setDRACOLoader(bn))}}async function js(o,e={draco:!1},t){return await ae.useLoader(Yo,o,Zl(e,t))}const Kl=["object"],ql=f.defineComponent({__name:"component",props:{path:{},draco:{type:Boolean,default:!1},decoderPath:{default:"https://www.gstatic.com/draco/versioned/decoders/1.4.1/"},castShadow:{type:Boolean,default:!1},receiveShadow:{type:Boolean,default:!1}},async setup(o,{expose:e}){let t,n;const r=o,s=f.ref();e({value:s});const{scene:i}=([t,n]=f.withAsyncContext(()=>js(r.path,{draco:r.draco,decoderPath:r.decoderPath})),t=await t,n(),t);return(r.castShadow||r.receiveShadow)&&i.traverse(a=>{a.isMesh&&(a.castShadow=r.castShadow,a.receiveShadow=r.receiveShadow)}),(a,l)=>(f.openBlock(),f.createElementBlock("primitive",f.mergeProps({ref_key:"modelRef",ref:s,object:f.unref(i)},a.$attrs),null,16,Kl))}});async function Es(o){return await ae.useLoader(Ba,o)}const Ql=["object"],Jl=f.defineComponent({__name:"component",props:{path:{},castShadow:{type:Boolean,default:!1},receiveShadow:{type:Boolean,default:!1}},async setup(o,{expose:e}){let t,n;const r=o,s=f.ref();e({value:s});const i=([t,n]=f.withAsyncContext(()=>Es(r.path)),t=await t,n(),t);return(r.castShadow||r.receiveShadow)&&i.traverse(a=>{a.isMesh&&(a.castShadow=r.castShadow,a.receiveShadow=r.receiveShadow)}),(a,l)=>(f.openBlock(),f.createElementBlock("primitive",f.mergeProps({ref_key:"modelRef",ref:s,object:f.unref(i)},a.$attrs),null,16,Ql))}}),Hl=["geometry","render-order"],$l=f.defineComponent({__name:"component",props:{src:{},skipStrokes:{type:Boolean,default:!1},skipFills:{type:Boolean,default:!1},fillMaterial:{},strokeMaterial:{},fillMeshProps:{},strokeMeshProps:{},depth:{default:"renderOrder"}},setup(o,{expose:e}){const t=o,{src:n,skipStrokes:r,skipFills:s,fillMaterial:i,strokeMaterial:a,fillMeshProps:l,strokeMeshProps:u,depth:h}=f.toRefs(t),d=f.shallowRef(),g=f.shallowRef([]),y=f.shallowRef([]);e({value:d}),f.watchEffect(async()=>x(n.value).then(A=>y.value=A.paths)),f.watch([s,r,i,a,y],v);async function x(A){const D=A.startsWith("<svg")?encodeURI(`data:image/svg+xml;utf8,${A}`):A;return ae.useLoader(Kt,D)}f.onUnmounted(w);function w(){g.value.forEach(A=>A.geometry.dispose())}function v(){var L,b,C;w();const A=[],[D,M]=(()=>{const m={flat:!1,renderOrder:!1,offsetZ:!0},S={flat:0,renderOrder:0,offsetZ:.025},p=h.value;return typeof p=="number"?[!0,p]:[m[p],S[p]]})();let _=0;for(const m of y.value){const S=((L=m.userData)==null?void 0:L.style)??{},p=Object.assign({color:S.fill,opacity:S.fillOpacity,transparent:!0,side:c.DoubleSide,depthWrite:D},t.fillMaterial);if(!s.value&&S.fill!==void 0&&S.fill!=="none")for(const I of Kt.createShapes(m)){const k=new c.ShapeGeometry(I);k.scale(1,-1,1),M&&k.translate(0,0,_++*M),A.push({geometry:k,material:p,isStroke:!1})}if(!r.value&&S.stroke!==void 0&&S.stroke!=="none"){const I=Object.assign({color:(b=m.userData)==null?void 0:b.style.stroke,opacity:(C=m.userData)==null?void 0:C.style.strokeOpacity,transparent:!0,side:c.DoubleSide,depthWrite:D},t.strokeMaterial);for(const k of m.subPaths){const J=k.getPoints().map(Z=>new c.Vector2(Z.x,-Z.y)),R=Kt.pointsToStroke(J,S||"none");M&&R.translate(0,0,_++*M),A.push({geometry:R,material:I,isStroke:!0})}}}g.value=A}return(A,D)=>(f.openBlock(),f.createElementBlock("TresGroup",{ref_key:"svgRef",ref:d},[(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(g.value,({geometry:M,material:_,isStroke:L},b)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({key:`${b}`},L?f.unref(u):f.unref(l),{geometry:M,"render-order":f.unref(h)==="renderOrder"?b:0}),[f.createElementVNode("TresMeshBasicMaterial",f.normalizeProps(f.guardReactiveProps(_)),null,16)],16,Hl))),128))],512))}}),Ws="[TresJS - Cientos ▲ ■ ♥] ";function lr(){function o(n,r){console.error(`${Ws} ${n}`,r||"")}function e(n){console.warn(`${Ws} ${n}`)}function t(n,r){}return{logError:o,logWarning:e,logMessage:t}}let cr=0;function ec(){const o=f.ref(!1),e=f.ref(0),t=f.ref([]),{logError:n}=lr();return new Promise(r=>{c.DefaultLoadingManager.onStart=()=>{o.value=!1},c.DefaultLoadingManager.onLoad=()=>{o.value=!0},c.DefaultLoadingManager.onProgress=(s,i,a)=>{i===a&&(cr=a,o.value=!0,t.value.push(s)),e.value=Math.round((i-cr)/(a-cr)*100||100,2)},c.DefaultLoadingManager.onError=s=>{n("Error loading assets",new Error(s)),o.value=!0},r({items:t,hasFinishLoading:o,progress:e})})}async function tc(o,e){const{logError:t}=lr();if(!o)return t("Error no path provided");const{unsuspend:n,start:r,crossOrigin:s,muted:i,loop:a,...l}={unsuspend:"loadedmetadata",crossOrigin:"Anonymous",muted:!0,loop:!0,start:!0,playsInline:!0,...e};function u(){return new Promise((h,d)=>{const g=Object.assign(document.createElement("video"),{src:typeof o=="string"&&o||void 0,crossOrigin:s,loop:a,muted:i,autoplay:!0,...l}),y=new c.VideoTexture(g);return g.addEventListener(n,()=>h(y)),g.addEventListener("error",()=>d()),y})}try{const h=await u();return r&&h.image&&h.image.play(),h}catch{t("Error loading resource")}}const nc=["target","auto-rotate","auto-rotate-speed","enable-damping","damping-factor","enable-pan","key-pan-speed","keys","max-azimuth-angle","min-azimuth-angle","max-polar-angle","min-polar-angle","min-distance","max-distance","min-zoom","max-zoom","touches","enable-zoom","zoom-speed","enable-rotate","rotate-speed","args"],rc=f.defineComponent({__name:"OrbitControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},target:{default:()=>[0,0,0]},enableDamping:{type:Boolean,default:!0},dampingFactor:{default:.05},autoRotate:{type:Boolean,default:!1},autoRotateSpeed:{default:2},enablePan:{type:Boolean,default:!0},keyPanSpeed:{default:7},keys:{},maxAzimuthAngle:{default:1/0},minAzimuthAngle:{default:-1/0},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:1/0},minZoom:{default:0},maxZoom:{default:1/0},touches:{default:()=>({ONE:c.TOUCH.ROTATE,TWO:c.TOUCH.DOLLY_PAN})},enableZoom:{type:Boolean,default:!0},zoomSpeed:{default:1},enableRotate:{type:Boolean,default:!0},rotateSpeed:{default:1}},emits:["change","start","end"],setup(o,{expose:e,emit:t}){const n=o,r=t,{makeDefault:s,autoRotate:i,autoRotateSpeed:a,enableDamping:l,dampingFactor:u,enablePan:h,keyPanSpeed:d,maxAzimuthAngle:g,minAzimuthAngle:y,maxPolarAngle:x,minPolarAngle:w,minDistance:v,maxDistance:A,minZoom:D,maxZoom:M,enableZoom:_,zoomSpeed:L,enableRotate:b,touches:C,rotateSpeed:m,target:S}=f.toRefs(n),{camera:p,renderer:I,extend:k,controls:J}=ae.useTresContext(),R=f.ref(null);k({OrbitControls:is}),f.watch(R,q=>{Z(),q&&s.value?J.value=q:J.value=null});function Z(){Le(R.value,"change",()=>r("change",R.value)),Le(R.value,"start",()=>r("start",R.value)),Le(R.value,"end",()=>r("end",R.value))}const{onLoop:X}=ae.useRenderLoop();return X(()=>{R.value&&(l.value||i.value)&&R.value.update()}),f.onUnmounted(()=>{R.value&&R.value.dispose()}),e({value:R}),(q,Y)=>(q.camera||f.unref(p))&&(q.domElement||f.unref(I))?(f.openBlock(),f.createElementBlock("TresOrbitControls",{key:0,ref_key:"controlsRef",ref:R,target:f.unref(S),"auto-rotate":f.unref(i),"auto-rotate-speed":f.unref(a),"enable-damping":f.unref(l),"damping-factor":f.unref(u),"enable-pan":f.unref(h),"key-pan-speed":f.unref(d),keys:q.keys,"max-azimuth-angle":f.unref(g),"min-azimuth-angle":f.unref(y),"max-polar-angle":f.unref(x),"min-polar-angle":f.unref(w),"min-distance":f.unref(v),"max-distance":f.unref(A),"min-zoom":f.unref(D),"max-zoom":f.unref(M),touches:f.unref(C),"enable-zoom":f.unref(_),"zoom-speed":f.unref(L),"enable-rotate":f.unref(b),"rotate-speed":f.unref(m),args:[q.camera||f.unref(p),q.domElement||f.unref(I).domElement]},null,8,nc)):f.createCommentVNode("",!0)}}),sc=5,ic=6,oc=.3,ac=f.defineComponent({__name:"KeyboardControls",props:{forward:{default:()=>["w","W"]},back:{default:()=>["s","S"]},left:{default:()=>["a","A"]},right:{default:()=>["d","D"]},jump:{default:()=>[" "]},gravity:{default:9.8},moveSpeed:{default:.1},headBobbing:{type:Boolean,default:!1},is2D:{type:Boolean,default:!1}},setup(o){var p;const e=o,{forward:t,back:n,left:r,right:s,jump:i,gravity:a,moveSpeed:l,headBobbing:u,is2D:h}=f.toRefs(e),{camera:d,controls:g}=ae.useTresContext(),y=f.ref(0),x=f.ref(0),w=f.ref(!1),v=f.ref(!1),A=f.ref(0),D=f.shallowRef(),M=h.value?"y":"z",_=((p=d.value.position)==null?void 0:p.y)||0;At(t.value,()=>{w.value=!0,x.value=l.value},{eventName:"keydown"}),At(n.value,()=>{w.value=!0,x.value=-l.value},{eventName:"keydown"}),At([...t.value,...n.value],()=>{w.value=!1,x.value=0},{eventName:"keyup"}),At(r.value,()=>{w.value=!0,y.value=-l.value},{eventName:"keydown"}),At(s.value,()=>{w.value=!0,y.value=l.value},{eventName:"keydown"}),At([...r.value,...s.value],()=>{w.value=!1,y.value=0},{eventName:"keyup"}),At(i.value,()=>{v.value||(A.value=Date.now()),v.value=!0});const L=I=>w.value?Math.sin(I*sc)*oc+_:_,b=()=>(Date.now()-A.value)/1e3*3,C=I=>_+ic*I-.5*a.value*I**2,m=()=>{if(v.value){const I=C(b());return I<=_&&(v.value=!1),I}return 0},{onLoop:S}=ae.useRenderLoop();return S(({elapsed:I})=>{var k;g.value instanceof Kn&&((k=g.value)!=null&&k.isLocked)?(g.value.moveForward(x.value),g.value.moveRight(y.value),d.value.position&&(d.value.position.y=u.value?L(I):_,d.value.position.y+=m())):D.value.children.length>0&&!(g.value instanceof Kn)&&(D.value.position.x+=y.value,D.value.position[M]+=h.value?x.value:-x.value)}),(I,k)=>(f.openBlock(),f.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:D},[f.renderSlot(I.$slots,"default")],512))}}),lc=["object","args","mode","enabled","axis","translation-snap","rotation-snap","scale-snap","space","size","show-x","show-y","show-z"],cc=f.defineComponent({__name:"TransformControls",props:{object:{},mode:{default:"translate"},enabled:{type:Boolean,default:!0},axis:{default:"XYZ"},translationSnap:{},rotationSnap:{},scaleSnap:{},space:{default:"world"},size:{default:1},showX:{type:Boolean,default:!0},showY:{type:Boolean,default:!0},showZ:{type:Boolean,default:!0}},emits:["dragging","change","mouseDown","mouseUp","objectChange"],setup(o,{emit:e}){const t=o,n=e,{object:r,mode:s,enabled:i,axis:a,translationSnap:l,rotationSnap:u,scaleSnap:h,space:d,size:g,showX:y,showY:x,showZ:w}=f.toRefs(t),v=f.shallowRef(),{controls:A,camera:D,renderer:M,extend:_}=ae.useTresContext();_({TransformControls:ko});const L=C=>{A.value&&(A.value.enabled=!C.value),n("dragging",C.value)};function b(){Le(v.value,"change",()=>n("change")),Le(v.value,"dragging-changed",L),Le(v.value,"mouseDown",()=>n("mouseDown")),Le(v.value,"mouseUp",()=>n("mouseUp")),Le(v.value,"objectChange",()=>n("objectChange"))}return f.watchEffect(()=>{v.value&&b()}),f.onUnmounted(()=>{v.value&&v.value.dispose()}),(C,m)=>f.unref(D)&&f.unref(M)?(f.openBlock(),f.createElementBlock("TresTransformControls",{key:0,ref_key:"controlsRef",ref:v,object:f.unref(r),args:[f.unref(D),f.unref(M).domElement],mode:f.unref(s),enabled:f.unref(i),axis:f.unref(a),"translation-snap":f.unref(l),"rotation-snap":f.unref(u),"scale-snap":f.unref(h),space:f.unref(d),size:f.unref(g),"show-x":f.unref(y),"show-y":f.unref(x),"show-z":f.unref(w),visible:!0},null,8,lc)):f.createCommentVNode("",!0)}}),uc=["args"],hc=f.defineComponent({__name:"PointerLockControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},selector:{}},emits:["isLock","change"],setup(o,{expose:e,emit:t}){const n=o,r=t,{camera:s,renderer:i,extend:a,controls:l}=ae.useTresContext(),u=f.ref(null);let h;a({PointerLockControls:Kn});const d=g=>{r("isLock",g)};return f.watch(u,g=>{g&&n.makeDefault?l.value=g:l.value=null;const y=document.getElementById(n.selector||"");h=y||i.value.domElement,Le(l.value,"change",()=>r("change",l.value)),Le(h,"click",()=>{var x,w,v;(x=l.value)==null||x.lock(),(w=l.value)==null||w.addEventListener("lock",()=>d(!0)),(v=l.value)==null||v.addEventListener("unlock",()=>d(!1))})}),f.onUnmounted(()=>{var g,y;(g=l.value)==null||g.removeEventListener("lock",()=>d(!0)),(y=l.value)==null||y.removeEventListener("unlock",()=>d(!1)),u.value&&u.value.dispose()}),e({value:l}),(g,y)=>(g.camera||f.unref(s))&&(g.domElement||f.unref(i))?(f.openBlock(),f.createElementBlock("TresPointerLockControls",{key:0,ref_key:"controlsRef",ref:u,args:[g.camera||f.unref(s),g.domElement||f.unref(i).domElement]},null,8,uc)):f.createCommentVNode("",!0)}}),fc=["args"],dc=f.defineComponent({__name:"MapControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{}},setup(o){const e=o,{camera:t,renderer:n,extend:r,controls:s}=ae.useTresContext(),i=f.ref(null);return r({MapControls:Wo}),f.watch(s,a=>{a&&e.makeDefault?s.value=a:s.value=null}),f.onUnmounted(()=>{i.value&&i.value.dispose()}),(a,l)=>(a.camera||f.unref(t))&&(a.domElement||f.unref(n))?(f.openBlock(),f.createElementBlock("TresMapControls",{key:0,ref_key:"controlsRef",ref:i,args:[a.camera||f.unref(t),a.domElement||f.unref(n).domElement]},null,8,fc)):f.createCommentVNode("",!0)}}),pc=f.defineComponent({__name:"ScrollControls",props:{pages:{default:4},distance:{default:4},smoothScroll:{default:.1},horizontal:{type:Boolean,default:!1},htmlScroll:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(o,{emit:e}){const t=o,n=e,{logWarning:r}=ae.useLogger();t.smoothScroll<0&&r("SmoothControl must be greater than zero"),t.pages<0&&r("Pages must be greater than zero");const{camera:s,controls:i,renderer:a}=ae.useTresContext(),l=f.shallowRef(),u=document.createElement("div"),{y:h}=Sl(),{x:d,y:g,isScrolling:y}=wl(u),{height:x,width:w}=Ts();let v=0;const A=f.ref(!1),D=f.ref(0),M=f.ref(0),_=f.ref(0),L=t.horizontal?"x":"y",b=f.watch(s,m=>{if(A.value){b();return}v=t.horizontal?(m==null?void 0:m.position.x)||0:(m==null?void 0:m.position.y)||0,A.value=!0},{immediate:!0});f.watch(y,m=>{i.value&&(i.value.enabled=!m)},{immediate:!0}),f.watch(h,m=>{!y.value&&!t.htmlScroll||(M.value=m/x.value/(_.value/x.value-1),D.value=-1*M.value,n("update:modelValue",M.value))}),f.watch(g,m=>{M.value=m/x.value/(_.value/x.value),D.value=-1*M.value,n("update:modelValue",M.value)}),f.watch(d,m=>{M.value=m/w.value/(_.value/w.value-1),D.value=+M.value,n("update:modelValue",M.value)}),f.watch(a,m=>{var p,I;const S=m==null?void 0:m.domElement;if(t.htmlScroll&&(m!=null&&m.domElement))S!=null&&S.style.width&&(S!=null&&S.style.position)&&(S!=null&&S.style.top)&&(S!=null&&S.style.left)&&(S.style.width="100%",S.style.position="fixed",S.style.zIndex=" -99999",S.style.top="0",S.style.left="0"),_.value=document.body.scrollHeight;else{const k=document.createElement("div"),J=document.createElement("div");u.style[t.horizontal?"overflowX":"overflowY"]="auto",u.style[t.horizontal?"overflowY":"overflowX"]="hidden",u.style.position="absolute",u.style.width="100%",u.style.height=" 100%",u.style.top="0",u.style.left="0",u.classList.add("scrollContainer"),k.style.position="sticky",k.style.top="0px",k.style.left="0px",k.style.width="100%",k.style.height="100%",k.style.overflow="hidden",u.appendChild(k),J.style.height=t.horizontal?"100%":`${x.value*t.pages}px`,J.style.width=t.horizontal?`${w.value*t.pages}px`:"100vw",J.style.pointerEvents="none",S.style.position="fixed",S.style.zIndex="0",S!=null&&S.style.width&&(S.style.width="100%"),u.appendChild(J),m.domElement.parentNode.style.position="relative",(I=(p=m==null?void 0:m.domElement)==null?void 0:p.parentNode)==null||I.appendChild(u),_.value=t.horizontal?w.value*t.pages:x.value*t.pages}},{immediate:!0});const{onLoop:C}=ae.useRenderLoop();return C(()=>{var m;if((m=s.value)!=null&&m.position){const S=(D.value*t.distance-s.value.position[L]+v)*t.smoothScroll;s.value.position[L]+=S,l.value.children.length>0&&(l.value.position[L]+=S)}}),(m,S)=>(f.openBlock(),f.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:l},[f.renderSlot(m.$slots,"default")],512))}});/*!
|
|
248
248
|
* camera-controls
|
|
249
249
|
* https://github.com/yomotsu/camera-controls
|
|
250
250
|
* (c) 2017 @yomotsu
|
|
251
251
|
* Released under the MIT License.
|
|
252
|
-
*/const de={LEFT:1,RIGHT:2,MIDDLE:4},$=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768}),Ft={NONE:0,IN:1,OUT:-1};function At(o){return o.isPerspectiveCamera}function mt(o){return o.isOrthographicCamera}const kt=Math.PI*2,Er=Math.PI/2,Yr=1e-5,qt=Math.PI/180;function Qe(o,e,t){return Math.max(e,Math.min(t,o))}function Ce(o,e=Yr){return Math.abs(o)<e}function Ae(o,e,t=Yr){return Ce(o-e,t)}function Xr(o,e){return Math.round(o/e)*e}function Qt(o){return isFinite(o)?o:o<0?-Number.MAX_VALUE:Number.MAX_VALUE}function Jt(o){return Math.abs(o)<Number.MAX_VALUE?o:o*(1/0)}function wn(o,e,t,n,s=1/0,r){n=Math.max(1e-4,n);const i=2/n,a=i*r,l=1/(1+a+.48*a*a+.235*a*a*a);let u=o-e;const h=e,d=s*n;u=Qe(u,-d,d),e=o-u;const y=(t.value+i*u)*r;t.value=(t.value-i*y)*l;let g=e+(u+y)*l;return h-o>0==g>h&&(g=h,t.value=(g-h)/r),g}function Wr(o,e,t,n,s=1/0,r,i){n=Math.max(1e-4,n);const a=2/n,l=a*r,u=1/(1+l+.48*l*l+.235*l*l*l);let h=e.x,d=e.y,y=e.z,g=o.x-h,x=o.y-d,w=o.z-y;const v=h,P=d,D=y,S=s*n,_=S*S,L=g*g+x*x+w*w;if(L>_){const Q=Math.sqrt(L);g=g/Q*S,x=x/Q*S,w=w/Q*S}h=o.x-g,d=o.y-x,y=o.z-w;const b=(t.x+a*g)*r,C=(t.y+a*x)*r,m=(t.z+a*w)*r;t.x=(t.x-a*b)*u,t.y=(t.y-a*C)*u,t.z=(t.z-a*m)*u,i.x=h+(g+b)*u,i.y=d+(x+C)*u,i.z=y+(w+m)*u;const M=v-o.x,p=P-o.y,I=D-o.z,F=i.x-v,J=i.y-P,G=i.z-D;return M*F+p*J+I*G>0&&(i.x=v,i.y=P,i.z=D,t.x=(i.x-v)/r,t.y=(i.y-P)/r,t.z=(i.z-D)/r),i}function ls(o,e){e.set(0,0),o.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=o.length,e.y/=o.length}function cs(o,e){return mt(o)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class fc{constructor(){this._listeners={}}addEventListener(e,t){const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const s=this._listeners[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const n=this._listeners[e.type];if(n!==void 0){e.target=this;const s=n.slice(0);for(let r=0,i=s.length;r<i;r++)s[r].call(this,e)}}}const dc="2.7.4",bn=1/8,Zr=typeof window<"u",pc=Zr&&/Mac/.test(navigator.platform),mc=!(Zr&&"PointerEvent"in window);let he,Kr,Mn,us,Re,ye,Me,Bt,Ht,$e,et,Pt,qr,Qr,Ze,$t,Ut,Jr,hs,Hr,fs,ds,Sn;class en extends fc{static install(e){he=e.THREE,Kr=Object.freeze(new he.Vector3(0,0,0)),Mn=Object.freeze(new he.Vector3(0,1,0)),us=Object.freeze(new he.Vector3(0,0,1)),Re=new he.Vector2,ye=new he.Vector3,Me=new he.Vector3,Bt=new he.Vector3,Ht=new he.Vector3,$e=new he.Vector3,et=new he.Vector3,Pt=new he.Vector3,qr=new he.Vector3,Qr=new he.Vector3,Ze=new he.Spherical,$t=new he.Spherical,Ut=new he.Box3,Jr=new he.Box3,hs=new he.Sphere,Hr=new he.Quaternion,fs=new he.Quaternion,ds=new he.Matrix4,Sn=new he.Raycaster}static get ACTION(){return $}constructor(e,t){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.verticalDragToForward=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=$.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=Ft.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new he.Vector3,this._focalOffsetVelocity=new he.Vector3,this._zoomVelocity={value:0},this._truckInternal=(_,L,b)=>{let C,m;if(At(this._camera)){const M=ye.copy(this._camera.position).sub(this._target),p=this._camera.getEffectiveFOV()*qt,I=M.length()*Math.tan(p*.5);C=this.truckSpeed*_*I/this._elementRect.height,m=this.truckSpeed*L*I/this._elementRect.height}else if(mt(this._camera)){const M=this._camera;C=_*(M.right-M.left)/M.zoom/this._elementRect.width,m=L*(M.top-M.bottom)/M.zoom/this._elementRect.height}else return;this.verticalDragToForward?(b?this.setFocalOffset(this._focalOffsetEnd.x+C,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(C,0,!0),this.forward(-m,!0)):b?this.setFocalOffset(this._focalOffsetEnd.x+C,this._focalOffsetEnd.y+m,this._focalOffsetEnd.z,!0):this.truck(C,m,!0)},this._rotateInternal=(_,L)=>{const b=kt*this.azimuthRotateSpeed*_/this._elementRect.height,C=kt*this.polarRotateSpeed*L/this._elementRect.height;this.rotate(b,C,!0)},this._dollyInternal=(_,L,b)=>{const C=Math.pow(.95,-_*this.dollySpeed),m=this._sphericalEnd.radius,M=this._sphericalEnd.radius*C,p=Qe(M,this.minDistance,this.maxDistance),I=p-M;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(M,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(I,!0),this._dollyToNoClamp(p,!0)):this._dollyToNoClamp(p,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?M:p)-m,this._dollyControlCoord.set(L,b)),this._lastDollyDirection=Math.sign(-_)},this._zoomInternal=(_,L,b)=>{const C=Math.pow(.95,_*this.dollySpeed),m=this._zoom,M=this._zoom*C;this.zoomTo(M,!0),this.dollyToCursor&&(this._changedZoom+=M-m,this._dollyControlCoord.set(L,b))},typeof he>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=new he.Quaternion().setFromUnitVectors(this._camera.up,Mn),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=$.NONE,this._target=new he.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new he.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new he.Spherical().setFromVector3(ye.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new he.Vector3,new he.Vector3,new he.Vector3,new he.Vector3],this._updateNearPlaneCorners(),this._boundary=new he.Box3(new he.Vector3(-1/0,-1/0,-1/0),new he.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new he.Vector2,this.mouseButtons={left:$.ROTATE,middle:$.DOLLY,right:$.TRUCK,wheel:At(this._camera)?$.DOLLY:mt(this._camera)?$.ZOOM:$.NONE},this.touches={one:$.TOUCH_ROTATE,two:At(this._camera)?$.TOUCH_DOLLY_TRUCK:mt(this._camera)?$.TOUCH_ZOOM_TRUCK:$.NONE,three:$.TOUCH_TRUCK};const n=new he.Vector2,s=new he.Vector2,r=new he.Vector2,i=_=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const C=this._domElement.getBoundingClientRect(),m=_.clientX/C.width,M=_.clientY/C.height;if(m<this._interactiveArea.left||m>this._interactiveArea.right||M<this._interactiveArea.top||M>this._interactiveArea.bottom)return}const L=_.pointerType!=="mouse"?null:(_.buttons&de.LEFT)===de.LEFT?de.LEFT:(_.buttons&de.MIDDLE)===de.MIDDLE?de.MIDDLE:(_.buttons&de.RIGHT)===de.RIGHT?de.RIGHT:null;if(L!==null){const C=this._findPointerByMouseButton(L);C&&this._disposePointer(C)}if((_.buttons&de.LEFT)===de.LEFT&&this._lockedPointer)return;const b={pointerId:_.pointerId,clientX:_.clientX,clientY:_.clientY,deltaX:0,deltaY:0,mouseButton:L};this._activePointers.push(b),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.addEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),this._isDragging=!0,w(_)},a=_=>{if(!this._enabled||!this._domElement||this._lockedPointer)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const C=this._domElement.getBoundingClientRect(),m=_.clientX/C.width,M=_.clientY/C.height;if(m<this._interactiveArea.left||m>this._interactiveArea.right||M<this._interactiveArea.top||M>this._interactiveArea.bottom)return}const L=(_.buttons&de.LEFT)===de.LEFT?de.LEFT:(_.buttons&de.MIDDLE)===de.MIDDLE?de.MIDDLE:(_.buttons&de.RIGHT)===de.RIGHT?de.RIGHT:null;if(L!==null){const C=this._findPointerByMouseButton(L);C&&this._disposePointer(C)}const b={pointerId:1,clientX:_.clientX,clientY:_.clientY,deltaX:0,deltaY:0,mouseButton:(_.buttons&de.LEFT)===de.LEFT?de.LEFT:(_.buttons&de.MIDDLE)===de.LEFT?de.MIDDLE:(_.buttons&de.RIGHT)===de.LEFT?de.RIGHT:null};this._activePointers.push(b),this._domElement.ownerDocument.removeEventListener("mousemove",u),this._domElement.ownerDocument.removeEventListener("mouseup",d),this._domElement.ownerDocument.addEventListener("mousemove",u),this._domElement.ownerDocument.addEventListener("mouseup",d),this._isDragging=!0,w(_)},l=_=>{_.cancelable&&_.preventDefault();const L=_.pointerId,b=this._lockedPointer||this._findPointerById(L);if(b){if(b.clientX=_.clientX,b.clientY=_.clientY,b.deltaX=_.movementX,b.deltaY=_.movementY,this._state=0,_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(_.buttons&de.LEFT)===de.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(_.buttons&de.MIDDLE)===de.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(_.buttons&de.RIGHT)===de.RIGHT&&(this._state=this._state|this.mouseButtons.right);v()}},u=_=>{const L=this._lockedPointer||this._findPointerById(1);L&&(L.clientX=_.clientX,L.clientY=_.clientY,L.deltaX=_.movementX,L.deltaY=_.movementY,this._state=0,(this._lockedPointer||(_.buttons&de.LEFT)===de.LEFT)&&(this._state=this._state|this.mouseButtons.left),(_.buttons&de.MIDDLE)===de.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(_.buttons&de.RIGHT)===de.RIGHT&&(this._state=this._state|this.mouseButtons.right),v())},h=_=>{const L=this._findPointerById(_.pointerId);if(!(L&&L===this._lockedPointer)){if(L&&this._disposePointer(L),_.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=$.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=$.NONE;P()}},d=()=>{const _=this._findPointerById(1);_&&_===this._lockedPointer||(_&&this._disposePointer(_),this._state=$.NONE,P())};let y=-1;const g=_=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===$.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const M=this._domElement.getBoundingClientRect(),p=_.clientX/M.width,I=_.clientY/M.height;if(p<this._interactiveArea.left||p>this._interactiveArea.right||I<this._interactiveArea.top||I>this._interactiveArea.bottom)return}if(_.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===$.ROTATE||this.mouseButtons.wheel===$.TRUCK){const M=performance.now();y-M<1e3&&this._getClientRect(this._elementRect),y=M}const L=pc?-1:-3,b=_.deltaMode===1?_.deltaY/L:_.deltaY/(L*10),C=this.dollyToCursor?(_.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,m=this.dollyToCursor?(_.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case $.ROTATE:{this._rotateInternal(_.deltaX,_.deltaY),this._isUserControllingRotate=!0;break}case $.TRUCK:{this._truckInternal(_.deltaX,_.deltaY,!1),this._isUserControllingTruck=!0;break}case $.OFFSET:{this._truckInternal(_.deltaX,_.deltaY,!0),this._isUserControllingOffset=!0;break}case $.DOLLY:{this._dollyInternal(-b,C,m),this._isUserControllingDolly=!0;break}case $.ZOOM:{this._zoomInternal(-b,C,m),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},x=_=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===en.ACTION.NONE){const L=_ instanceof PointerEvent?_.pointerId:(_ instanceof MouseEvent,0),b=this._findPointerById(L);b&&this._disposePointer(b),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("mousemove",u),this._domElement.ownerDocument.removeEventListener("mouseup",d);return}_.preventDefault()}},w=_=>{if(!this._enabled)return;if(ls(this._activePointers,Re),this._getClientRect(this._elementRect),n.copy(Re),s.copy(Re),this._activePointers.length>=2){const b=Re.x-this._activePointers[1].clientX,C=Re.y-this._activePointers[1].clientY,m=Math.sqrt(b*b+C*C);r.set(0,m);const M=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,p=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;s.set(M,p)}if(this._state=0,!_)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in _&&_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(_.buttons&de.LEFT)===de.LEFT&&(this._state=this._state|this.mouseButtons.left),(_.buttons&de.MIDDLE)===de.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(_.buttons&de.RIGHT)===de.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&$.ROTATE)===$.ROTATE||(this._state&$.TOUCH_ROTATE)===$.TOUCH_ROTATE||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&$.TRUCK)===$.TRUCK||(this._state&$.TOUCH_TRUCK)===$.TOUCH_TRUCK||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&$.DOLLY)===$.DOLLY||(this._state&$.TOUCH_DOLLY)===$.TOUCH_DOLLY||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&$.ZOOM)===$.ZOOM||(this._state&$.TOUCH_ZOOM)===$.TOUCH_ZOOM||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&$.OFFSET)===$.OFFSET||(this._state&$.TOUCH_OFFSET)===$.TOUCH_OFFSET||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},v=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,ls(this._activePointers,Re);const L=this._domElement&&document.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,b=L?-L.deltaX:s.x-Re.x,C=L?-L.deltaY:s.y-Re.y;if(s.copy(Re),((this._state&$.ROTATE)===$.ROTATE||(this._state&$.TOUCH_ROTATE)===$.TOUCH_ROTATE||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(b,C),this._isUserControllingRotate=!0),(this._state&$.DOLLY)===$.DOLLY||(this._state&$.ZOOM)===$.ZOOM){const m=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,M=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0,p=this.dollyDragInverted?-1:1;(this._state&$.DOLLY)===$.DOLLY?(this._dollyInternal(p*C*bn,m,M),this._isUserControllingDolly=!0):(this._zoomInternal(p*C*bn,m,M),this._isUserControllingZoom=!0)}if((this._state&$.TOUCH_DOLLY)===$.TOUCH_DOLLY||(this._state&$.TOUCH_ZOOM)===$.TOUCH_ZOOM||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE){const m=Re.x-this._activePointers[1].clientX,M=Re.y-this._activePointers[1].clientY,p=Math.sqrt(m*m+M*M),I=r.y-p;r.set(0,p);const F=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,J=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&$.TOUCH_DOLLY)===$.TOUCH_DOLLY||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET?(this._dollyInternal(I*bn,F,J),this._isUserControllingDolly=!0):(this._zoomInternal(I*bn,F,J),this._isUserControllingZoom=!0)}((this._state&$.TRUCK)===$.TRUCK||(this._state&$.TOUCH_TRUCK)===$.TOUCH_TRUCK||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(b,C,!1),this._isUserControllingTruck=!0),((this._state&$.OFFSET)===$.OFFSET||(this._state&$.TOUCH_OFFSET)===$.TOUCH_OFFSET||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(b,C,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},P=()=>{ls(this._activePointers,Re),s.copy(Re),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",u),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("mouseup",d),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",D),this._domElement.ownerDocument.addEventListener("pointerlockerror",S),this._domElement.ownerDocument.addEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),w())},this.unlockPointer=()=>{this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),document.exitPointerLock(),this.cancel(),this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointerlockchange",D),this._domElement.ownerDocument.removeEventListener("pointerlockerror",S))};const D=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},S=()=>{this.unlockPointer()};this._addAllEventListeners=_=>{this._domElement=_,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",i),mc&&this._domElement.addEventListener("mousedown",a),this._domElement.addEventListener("pointercancel",h),this._domElement.addEventListener("wheel",g,{passive:!1}),this._domElement.addEventListener("contextmenu",x)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",i),this._domElement.removeEventListener("mousedown",a),this._domElement.removeEventListener("pointercancel",h),this._domElement.removeEventListener("wheel",g,{passive:!1}),this._domElement.removeEventListener("contextmenu",x),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",u),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("mouseup",d),this._domElement.ownerDocument.removeEventListener("pointerlockchange",D),this._domElement.ownerDocument.removeEventListener("pointerlockerror",S))},this.cancel=()=>{this._state!==$.NONE&&(this._state=$.NONE,this._activePointers.length=0,P())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=Qe(e.width,0,1),this._interactiveArea.height=Qe(e.height,0,1),this._interactiveArea.x=Qe(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=Qe(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,n=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,n)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,n=!1){this._isUserControllingRotate=!1;const s=Qe(e,this.minAzimuthAngle,this.maxAzimuthAngle),r=Qe(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=s,this._sphericalEnd.phi=r,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const i=!n||Ae(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Ae(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(i)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Ft.NONE,this._changedDolly=0,this._dollyToNoClamp(Qe(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const n=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const i=this._collisionTest(),a=Ae(i,this._spherical.radius);if(!(n>e)&&a)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,i)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const r=!t||Ae(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(r)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(Ht).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const n=!t||Ae(this._target.x,this._targetEnd.x,this.restThreshold)&&Ae(this._target.y,this._targetEnd.y,this.restThreshold)&&Ae(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=Qe(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const n=!t||Ae(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(n)}pan(e,t,n=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,n)}truck(e,t,n=!1){this._camera.updateMatrix(),$e.setFromMatrixColumn(this._camera.matrix,0),et.setFromMatrixColumn(this._camera.matrix,1),$e.multiplyScalar(e),et.multiplyScalar(-t);const s=ye.copy($e).add(et),r=Me.copy(this._targetEnd).add(s);return this.moveTo(r.x,r.y,r.z,n)}forward(e,t=!1){ye.setFromMatrixColumn(this._camera.matrix,0),ye.crossVectors(this._camera.up,ye),ye.multiplyScalar(e);const n=Me.copy(this._targetEnd).add(ye);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return ye.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+ye.x,this._targetEnd.y+ye.y,this._targetEnd.z+ye.z,t)}moveTo(e,t,n,s=!1){this._isUserControllingTruck=!1;const r=ye.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,r,this.boundaryFriction),this._needsUpdate=!0,s||this._target.copy(this._targetEnd);const i=!s||Ae(this._target.x,this._targetEnd.x,this.restThreshold)&&Ae(this._target.y,this._targetEnd.y,this.restThreshold)&&Ae(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}lookInDirectionOf(e,t,n,s=!1){const a=ye.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(a.x,a.y,a.z,s)}fitToBox(e,t,{cover:n=!1,paddingLeft:s=0,paddingRight:r=0,paddingBottom:i=0,paddingTop:a=0}={}){const l=[],u=e.isBox3?Ut.copy(e):Ut.setFromObject(e);u.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const h=Xr(this._sphericalEnd.theta,Er),d=Xr(this._sphericalEnd.phi,Er);l.push(this.rotateTo(h,d,t));const y=ye.setFromSpherical(this._sphericalEnd).normalize(),g=Hr.setFromUnitVectors(y,us),x=Ae(Math.abs(y.y),1);x&&g.multiply(fs.setFromAxisAngle(Mn,h)),g.multiply(this._yAxisUpSpaceInverse);const w=Jr.makeEmpty();Me.copy(u.min).applyQuaternion(g),w.expandByPoint(Me),Me.copy(u.min).setX(u.max.x).applyQuaternion(g),w.expandByPoint(Me),Me.copy(u.min).setY(u.max.y).applyQuaternion(g),w.expandByPoint(Me),Me.copy(u.max).setZ(u.min.z).applyQuaternion(g),w.expandByPoint(Me),Me.copy(u.min).setZ(u.max.z).applyQuaternion(g),w.expandByPoint(Me),Me.copy(u.max).setY(u.min.y).applyQuaternion(g),w.expandByPoint(Me),Me.copy(u.max).setX(u.min.x).applyQuaternion(g),w.expandByPoint(Me),Me.copy(u.max).applyQuaternion(g),w.expandByPoint(Me),w.min.x-=s,w.min.y-=i,w.max.x+=r,w.max.y+=a,g.setFromUnitVectors(us,y),x&&g.premultiply(fs.invert()),g.premultiply(this._yAxisUpSpace);const v=w.getSize(ye),P=w.getCenter(Me).applyQuaternion(g);if(At(this._camera)){const D=this.getDistanceToFitBox(v.x,v.y,v.z,n);l.push(this.moveTo(P.x,P.y,P.z,t)),l.push(this.dollyTo(D,t)),l.push(this.setFocalOffset(0,0,0,t))}else if(mt(this._camera)){const D=this._camera,S=D.right-D.left,_=D.top-D.bottom,L=n?Math.max(S/v.x,_/v.y):Math.min(S/v.x,_/v.y);l.push(this.moveTo(P.x,P.y,P.z,t)),l.push(this.zoomTo(L,t)),l.push(this.setFocalOffset(0,0,0,t))}return Promise.all(l)}fitToSphere(e,t){const n=[],r=e instanceof he.Sphere?hs.copy(e):en.createBoundingSphere(e,hs);if(n.push(this.moveTo(r.center.x,r.center.y,r.center.z,t)),At(this._camera)){const i=this.getDistanceToFitSphere(r.radius);n.push(this.dollyTo(i,t))}else if(mt(this._camera)){const i=this._camera.right-this._camera.left,a=this._camera.top-this._camera.bottom,l=2*r.radius,u=Math.min(i/l,a/l);n.push(this.zoomTo(u,t))}return n.push(this.setFocalOffset(0,0,0,t)),Promise.all(n)}setLookAt(e,t,n,s,r,i,a=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ft.NONE,this._changedDolly=0;const l=Me.set(s,r,i),u=ye.set(e,t,n);this._targetEnd.copy(l),this._sphericalEnd.setFromVector3(u.sub(l).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,a||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const h=!a||Ae(this._target.x,this._targetEnd.x,this.restThreshold)&&Ae(this._target.y,this._targetEnd.y,this.restThreshold)&&Ae(this._target.z,this._targetEnd.z,this.restThreshold)&&Ae(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Ae(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Ae(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(h)}lerpLookAt(e,t,n,s,r,i,a,l,u,h,d,y,g,x=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Ft.NONE,this._changedDolly=0;const w=ye.set(s,r,i),v=Me.set(e,t,n);Ze.setFromVector3(v.sub(w).applyQuaternion(this._yAxisUpSpace));const P=Bt.set(h,d,y),D=Me.set(a,l,u);$t.setFromVector3(D.sub(P).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(w.lerp(P,g));const S=$t.theta-Ze.theta,_=$t.phi-Ze.phi,L=$t.radius-Ze.radius;this._sphericalEnd.set(Ze.radius+L*g,Ze.phi+_*g,Ze.theta+S*g),this.normalizeRotations(),this._needsUpdate=!0,x||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const b=!x||Ae(this._target.x,this._targetEnd.x,this.restThreshold)&&Ae(this._target.y,this._targetEnd.y,this.restThreshold)&&Ae(this._target.z,this._targetEnd.z,this.restThreshold)&&Ae(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Ae(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Ae(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(b)}setPosition(e,t,n,s=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,s)}setTarget(e,t,n,s=!1){const r=this.getPosition(ye),i=this.setLookAt(r.x,r.y,r.z,e,t,n,s);return this._sphericalEnd.phi=Qe(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),i}setFocalOffset(e,t,n,s=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,s||this._focalOffset.copy(this._focalOffsetEnd);const r=!s||Ae(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Ae(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Ae(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),$e.setFromMatrixColumn(this._camera.matrixWorldInverse,0),et.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Pt.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const s=ye.set(e,t,n),r=s.distanceTo(this._camera.position),i=s.sub(this._camera.position);$e.multiplyScalar(i.x),et.multiplyScalar(i.y),Pt.multiplyScalar(i.z),ye.copy($e).add(et).add(Pt),ye.z=ye.z+r,this.dollyTo(r,!1),this.setFocalOffset(-ye.x,ye.y,-ye.z,!1),this.moveTo(e,t,n,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,n,s){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new he.Vector4,typeof e=="number"?this._viewport.set(e,t,n,s):this._viewport.copy(e)}getDistanceToFitBox(e,t,n,s=!1){if(cs(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const r=e/t,i=this._camera.getEffectiveFOV()*qt,a=this._camera.aspect;return((s?r>a:r<a)?t:e/a)*.5/Math.tan(i*.5)+n*.5}getDistanceToFitSphere(e){if(cs(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*qt,n=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,s=1<this._camera.aspect?t:n;return e/Math.sin(s*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new he.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new he.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e&&e instanceof he.Spherical?e:new he.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new he.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%kt,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=kt),this._spherical.theta+=kt*Math.round((this._sphericalEnd.theta-this._spherical.theta)/kt)}reset(e=!1){if(!Ae(this._camera.up.x,this._cameraUp0.x)||!Ae(this._camera.up.y,this._cameraUp0.y)||!Ae(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const n=this.getPosition(ye);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,Mn),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=ye.subVectors(this._target,this._camera.position).normalize(),t=Me.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const n=this.getPosition(ye);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,n=this._sphericalEnd.phi-this._spherical.phi,s=this._sphericalEnd.radius-this._spherical.radius,r=qr.subVectors(this._targetEnd,this._target),i=Qr.subVectors(this._focalOffsetEnd,this._focalOffset),a=this._zoomEnd-this._zoom;if(Ce(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const d=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=wn(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,d,1/0,e),this._needsUpdate=!0}if(Ce(n))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const d=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=wn(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,d,1/0,e),this._needsUpdate=!0}if(Ce(s))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const d=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=wn(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,d,this.maxSpeed,e),this._needsUpdate=!0}if(Ce(r.x)&&Ce(r.y)&&Ce(r.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const d=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Wr(this._target,this._targetEnd,this._targetVelocity,d,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(Ce(i.x)&&Ce(i.y)&&Ce(i.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const d=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Wr(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,d,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(Ce(a))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const d=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=wn(this._zoom,this._zoomEnd,this._zoomVelocity,d,1/0,e)}if(this.dollyToCursor){if(At(this._camera)&&this._changedDolly!==0){const d=this._spherical.radius-this._lastDistance,y=this._camera,g=this._getCameraDirection(Ht),x=ye.copy(g).cross(y.up).normalize();x.lengthSq()===0&&(x.x=1);const w=Me.crossVectors(x,g),v=this._sphericalEnd.radius*Math.tan(y.getEffectiveFOV()*qt*.5),D=(this._sphericalEnd.radius-d-this._sphericalEnd.radius)/this._sphericalEnd.radius,S=Bt.copy(this._targetEnd).add(x.multiplyScalar(this._dollyControlCoord.x*v*y.aspect)).add(w.multiplyScalar(this._dollyControlCoord.y*v)),_=ye.copy(this._targetEnd).lerp(S,D),L=this._lastDollyDirection===Ft.IN&&this._spherical.radius<=this.minDistance,b=this._lastDollyDirection===Ft.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(L||b)){this._sphericalEnd.radius-=d,this._spherical.radius-=d;const m=Me.copy(g).multiplyScalar(-d);_.add(m)}this._boundary.clampPoint(_,_);const C=Me.subVectors(_,this._targetEnd);this._targetEnd.copy(_),this._target.add(C),this._changedDolly-=d,Ce(this._changedDolly)&&(this._changedDolly=0)}else if(mt(this._camera)&&this._changedZoom!==0){const d=this._zoom-this._lastZoom,y=this._camera,g=ye.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(y.near+y.far)/(y.near-y.far)).unproject(y),x=Me.set(0,0,-1).applyQuaternion(y.quaternion),w=Bt.copy(g).add(x.multiplyScalar(-g.dot(y.up))),P=-(this._zoom-d-this._zoom)/this._zoom,D=this._getCameraDirection(Ht),S=this._targetEnd.dot(D),_=ye.copy(this._targetEnd).lerp(w,P),L=_.dot(D),b=D.multiplyScalar(L-S);_.sub(b),this._boundary.clampPoint(_,_);const C=Me.subVectors(_,this._targetEnd);this._targetEnd.copy(_),this._target.add(C),this._changedZoom-=d,Ce(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const l=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,l),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!Ce(this._focalOffset.x)||!Ce(this._focalOffset.y)||!Ce(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),$e.setFromMatrixColumn(this._camera.matrix,0),et.setFromMatrixColumn(this._camera.matrix,1),Pt.setFromMatrixColumn(this._camera.matrix,2),$e.multiplyScalar(this._focalOffset.x),et.multiplyScalar(-this._focalOffset.y),Pt.multiplyScalar(this._focalOffset.z),ye.copy($e).add(et).add(Pt),this._camera.position.add(ye)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),ye.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const h=this._needsUpdate;return h&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):h?(this.dispatchEvent({type:"update"}),Ce(t,this.restThreshold)&&Ce(n,this.restThreshold)&&Ce(s,this.restThreshold)&&Ce(r.x,this.restThreshold)&&Ce(r.y,this.restThreshold)&&Ce(r.z,this.restThreshold)&&Ce(i.x,this.restThreshold)&&Ce(i.y,this.restThreshold)&&Ce(i.z,this.restThreshold)&&Ce(a,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!h&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=h,this._needsUpdate=!1,h}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:Qt(this.maxDistance),minZoom:this.minZoom,maxZoom:Qt(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:Qt(this.maxPolarAngle),minAzimuthAngle:Qt(this.minAzimuthAngle),maxAzimuthAngle:Qt(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,verticalDragToForward:this.verticalDragToForward,target:this._targetEnd.toArray(),position:ye.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){const n=JSON.parse(e);this.enabled=n.enabled,this.minDistance=n.minDistance,this.maxDistance=Jt(n.maxDistance),this.minZoom=n.minZoom,this.maxZoom=Jt(n.maxZoom),this.minPolarAngle=n.minPolarAngle,this.maxPolarAngle=Jt(n.maxPolarAngle),this.minAzimuthAngle=Jt(n.minAzimuthAngle),this.maxAzimuthAngle=Jt(n.maxAzimuthAngle),this.smoothTime=n.smoothTime,this.draggingSmoothTime=n.draggingSmoothTime,this.dollySpeed=n.dollySpeed,this.truckSpeed=n.truckSpeed,this.dollyToCursor=n.dollyToCursor,this.verticalDragToForward=n.verticalDragToForward,this._target0.fromArray(n.target0),this._position0.fromArray(n.position0),this._zoom0=n.zoom0,this._focalOffset0.fromArray(n.focalOffset0),this.moveTo(n.target[0],n.target[1],n.target[2],t),Ze.setFromVector3(ye.fromArray(n.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Ze.theta,Ze.phi,t),this.dollyTo(Ze.radius,t),this.zoomTo(n.zoom,t),this.setFocalOffset(n.focalOffset[0],n.focalOffset[1],n.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn("camera-controls is already connected.");return}e.setAttribute("data-camera-controls-version",dc),this._addAllEventListeners(e),this._getClientRect(this._elementRect)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,n){const s=t.lengthSq();if(s===0)return e;const r=Me.copy(t).add(e),a=this._boundary.clampPoint(r,Bt).sub(r),l=a.lengthSq();if(l===0)return e.add(t);if(l===s)return e;if(n===0)return e.add(t).add(a);{const u=1+n*l/t.dot(a);return e.add(Me.copy(t).multiplyScalar(u)).add(a.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(At(this._camera)){const e=this._camera,t=e.near,n=e.getEffectiveFOV()*qt,s=Math.tan(n*.5)*t,r=s*e.aspect;this._nearPlaneCorners[0].set(-r,-s,0),this._nearPlaneCorners[1].set(r,-s,0),this._nearPlaneCorners[2].set(r,s,0),this._nearPlaneCorners[3].set(-r,s,0)}else if(mt(this._camera)){const e=this._camera,t=1/e.zoom,n=e.left*t,s=e.right*t,r=e.top*t,i=e.bottom*t;this._nearPlaneCorners[0].set(n,r,0),this._nearPlaneCorners[1].set(s,r,0),this._nearPlaneCorners[2].set(s,i,0),this._nearPlaneCorners[3].set(n,i,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||cs(this._camera,"_collisionTest"))return e;const n=this._getTargetDirection(Ht);ds.lookAt(Kr,n,this._camera.up);for(let s=0;s<4;s++){const r=Me.copy(this._nearPlaneCorners[s]);r.applyMatrix4(ds);const i=Bt.addVectors(this._target,r);Sn.set(i,n),Sn.far=this._spherical.radius+1;const a=Sn.intersectObjects(this.colliderMeshes);a.length!==0&&a[0].distance<e&&(e=a[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const n=()=>{this.removeEventListener("rest",n),t()};this.addEventListener("rest",n)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new he.Sphere){const n=t,s=n.center;Ut.makeEmpty(),e.traverseVisible(i=>{i.isMesh&&Ut.expandByObject(i)}),Ut.getCenter(s);let r=0;return e.traverseVisible(i=>{if(!i.isMesh)return;const a=i,l=a.geometry.clone();l.applyMatrix4(a.matrixWorld);const h=l.attributes.position;for(let d=0,y=h.count;d<y;d++)ye.fromBufferAttribute(h,d),r=Math.max(r,s.distanceToSquared(ye))}),n.radius=Math.sqrt(r),n}}const gc=["min-polar-angle","max-polar-angle","min-azimuth-angle","max-azimuth-angle","distance","min-distance","max-distance","infinity-dolly","min-zoom","max-zoom","smooth-time","dragging-smooth-time","max-speed","azimuth-rotate-speed","polar-rotate-speed","dolly-speed","dolly-drag-inverted","truck-speed","dolly-to-cursor","drag-to-offset","vertical-drag-to-forward","boundary-friction","rest-threshold","collider-meshes","args"],yc=f.defineComponent({__name:"CameraControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},minPolarAngle:{default:0},maxPolarAngle:{default:Math.PI},minAzimuthAngle:{default:-1/0},maxAzimuthAngle:{default:1/0},distance:{default:()=>ae.useTresContext().camera.value.position.z},minDistance:{default:Number.EPSILON},maxDistance:{default:1/0},infinityDolly:{type:Boolean,default:!1},minZoom:{default:.01},maxZoom:{default:1/0},smoothTime:{default:.25},draggingSmoothTime:{default:.125},maxSpeed:{default:1/0},azimuthRotateSpeed:{default:1},polarRotateSpeed:{default:1},dollySpeed:{default:1},dollyDragInverted:{type:Boolean,default:!1},truckSpeed:{default:2},dollyToCursor:{type:Boolean,default:!1},dragToOffset:{type:Boolean,default:!1},verticalDragToForward:{type:Boolean,default:!1},boundaryFriction:{default:0},restThreshold:{default:.01},colliderMeshes:{default:()=>[]},mouseButtons:{},touches:{}},emits:["change","start","end"],setup(o,{expose:e,emit:t}){const n=o,s=t,{makeDefault:r,minPolarAngle:i,maxPolarAngle:a,minAzimuthAngle:l,maxAzimuthAngle:u,distance:h,minDistance:d,maxDistance:y,infinityDolly:g,minZoom:x,maxZoom:w,smoothTime:v,draggingSmoothTime:P,maxSpeed:D,azimuthRotateSpeed:S,polarRotateSpeed:_,dollySpeed:L,dollyDragInverted:b,truckSpeed:C,dollyToCursor:m,dragToOffset:M,verticalDragToForward:p,boundaryFriction:I,restThreshold:F,colliderMeshes:J}=f.toRefs(n),G={Box3:c.Box3,MathUtils:{clamp:c.MathUtils.clamp},Matrix4:c.Matrix4,Quaternion:c.Quaternion,Raycaster:c.Raycaster,Sphere:c.Sphere,Spherical:c.Spherical,Vector2:c.Vector2,Vector3:c.Vector3,Vector4:c.Vector4};en.install({THREE:G});const{camera:Q,renderer:K,extend:Z,controls:X}=ae.useTresContext(),ne=f.ref(null);Z({CameraControls:en}),f.watchEffect(()=>{se(),ne.value&&r.value?X.value=ne.value:X.value=null});function se(){Le(ne.value,"update",()=>s("change",ne.value)),Le(ne.value,"controlend",()=>s("end",ne.value)),Le(ne.value,"controlstart",()=>s("start",ne.value))}const{onLoop:ue}=ae.useRenderLoop();return ue(({delta:j})=>{var z,A;(z=ne.value)!=null&&z.enabled&&((A=ne.value)==null||A.update(j))}),f.onUnmounted(()=>{ne.value&&ne.value.disconnect()}),e({value:ne}),(j,z)=>(j.camera||f.unref(Q))&&(j.domElement||f.unref(K))?(f.openBlock(),f.createElementBlock("TresCameraControls",{key:0,ref_key:"controlsRef",ref:ne,"min-polar-angle":f.unref(i),"max-polar-angle":f.unref(a),"min-azimuth-angle":f.unref(l),"max-azimuth-angle":f.unref(u),distance:f.unref(h),"min-distance":f.unref(d),"max-distance":f.unref(y),"infinity-dolly":f.unref(g),"min-zoom":f.unref(x),"max-zoom":f.unref(w),"smooth-time":f.unref(v),"dragging-smooth-time":f.unref(P),"max-speed":f.unref(D),"azimuth-rotate-speed":f.unref(S),"polar-rotate-speed":f.unref(_),"dolly-speed":f.unref(L),"dolly-drag-inverted":f.unref(b),"truck-speed":f.unref(C),"dolly-to-cursor":f.unref(m),"drag-to-offset":f.unref(M),"vertical-drag-to-forward":f.unref(p),"boundary-friction":f.unref(I),"rest-threshold":f.unref(F),"collider-meshes":f.unref(J),args:[j.camera||f.unref(Q),j.domElement||f.unref(K).domElement]},null,8,gc)):f.createCommentVNode("",!0)}});class _c extends c.MeshStandardMaterial{constructor(t={}){super(t);le(this,"_time");le(this,"_factor");this.setValues(t),this._time={value:0},this._factor={value:1}}onBeforeCompile(t){t.uniforms||(t.uniforms={}),t.uniforms.time=this._time,t.uniforms.factor=this._factor,t.vertexShader=`
|
|
252
|
+
*/const de={LEFT:1,RIGHT:2,MIDDLE:4},$=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,OFFSET:4,DOLLY:8,ZOOM:16,TOUCH_ROTATE:32,TOUCH_TRUCK:64,TOUCH_OFFSET:128,TOUCH_DOLLY:256,TOUCH_ZOOM:512,TOUCH_DOLLY_TRUCK:1024,TOUCH_DOLLY_OFFSET:2048,TOUCH_DOLLY_ROTATE:4096,TOUCH_ZOOM_TRUCK:8192,TOUCH_ZOOM_OFFSET:16384,TOUCH_ZOOM_ROTATE:32768}),Bt={NONE:0,IN:1,OUT:-1};function Pt(o){return o.isPerspectiveCamera}function gt(o){return o.isOrthographicCamera}const Ft=Math.PI*2,Ys=Math.PI/2,Xs=1e-5,Jt=Math.PI/180;function Je(o,e,t){return Math.max(e,Math.min(t,o))}function Ce(o,e=Xs){return Math.abs(o)<e}function Ae(o,e,t=Xs){return Ce(o-e,t)}function Zs(o,e){return Math.round(o/e)*e}function Ht(o){return isFinite(o)?o:o<0?-Number.MAX_VALUE:Number.MAX_VALUE}function $t(o){return Math.abs(o)<Number.MAX_VALUE?o:o*(1/0)}function Mn(o,e,t,n,r=1/0,s){n=Math.max(1e-4,n);const i=2/n,a=i*s,l=1/(1+a+.48*a*a+.235*a*a*a);let u=o-e;const h=e,d=r*n;u=Je(u,-d,d),e=o-u;const g=(t.value+i*u)*s;t.value=(t.value-i*g)*l;let y=e+(u+g)*l;return h-o>0==y>h&&(y=h,t.value=(y-h)/s),y}function Ks(o,e,t,n,r=1/0,s,i){n=Math.max(1e-4,n);const a=2/n,l=a*s,u=1/(1+l+.48*l*l+.235*l*l*l);let h=e.x,d=e.y,g=e.z,y=o.x-h,x=o.y-d,w=o.z-g;const v=h,A=d,D=g,M=r*n,_=M*M,L=y*y+x*x+w*w;if(L>_){const Z=Math.sqrt(L);y=y/Z*M,x=x/Z*M,w=w/Z*M}h=o.x-y,d=o.y-x,g=o.z-w;const b=(t.x+a*y)*s,C=(t.y+a*x)*s,m=(t.z+a*w)*s;t.x=(t.x-a*b)*u,t.y=(t.y-a*C)*u,t.z=(t.z-a*m)*u,i.x=h+(y+b)*u,i.y=d+(x+C)*u,i.z=g+(w+m)*u;const S=v-o.x,p=A-o.y,I=D-o.z,k=i.x-v,J=i.y-A,R=i.z-D;return S*k+p*J+I*R>0&&(i.x=v,i.y=A,i.z=D,t.x=(i.x-v)/s,t.y=(i.y-A)/s,t.z=(i.z-D)/s),i}function ur(o,e){e.set(0,0),o.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=o.length,e.y/=o.length}function hr(o,e){return gt(o)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class mc{constructor(){this._listeners={}}addEventListener(e,t){const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const r=this._listeners[e];if(r!==void 0){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){const n=this._listeners[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let s=0,i=r.length;s<i;s++)r[s].call(this,e)}}}const gc="2.7.4",Sn=1/8,qs=typeof window<"u",yc=qs&&/Mac/.test(navigator.platform),_c=!(qs&&"PointerEvent"in window);let he,Qs,An,fr,Re,ye,Me,Ut,en,et,tt,Ct,Js,Hs,Ke,tn,Nt,$s,dr,ei,pr,mr,Pn;class nn extends mc{static install(e){he=e.THREE,Qs=Object.freeze(new he.Vector3(0,0,0)),An=Object.freeze(new he.Vector3(0,1,0)),fr=Object.freeze(new he.Vector3(0,0,1)),Re=new he.Vector2,ye=new he.Vector3,Me=new he.Vector3,Ut=new he.Vector3,en=new he.Vector3,et=new he.Vector3,tt=new he.Vector3,Ct=new he.Vector3,Js=new he.Vector3,Hs=new he.Vector3,Ke=new he.Spherical,tn=new he.Spherical,Nt=new he.Box3,$s=new he.Box3,dr=new he.Sphere,ei=new he.Quaternion,pr=new he.Quaternion,mr=new he.Matrix4,Pn=new he.Raycaster}static get ACTION(){return $}constructor(e,t){super(),this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.minDistance=Number.EPSILON,this.maxDistance=1/0,this.infinityDolly=!1,this.minZoom=.01,this.maxZoom=1/0,this.smoothTime=.25,this.draggingSmoothTime=.125,this.maxSpeed=1/0,this.azimuthRotateSpeed=1,this.polarRotateSpeed=1,this.dollySpeed=1,this.dollyDragInverted=!1,this.truckSpeed=2,this.dollyToCursor=!1,this.dragToOffset=!1,this.verticalDragToForward=!1,this.boundaryFriction=0,this.restThreshold=.01,this.colliderMeshes=[],this.cancel=()=>{},this._enabled=!0,this._state=$.NONE,this._viewport=null,this._changedDolly=0,this._changedZoom=0,this._hasRested=!0,this._boundaryEnclosesCamera=!1,this._needsUpdate=!0,this._updatedLastTime=!1,this._elementRect=new DOMRect,this._isDragging=!1,this._dragNeedsUpdate=!0,this._activePointers=[],this._lockedPointer=null,this._interactiveArea=new DOMRect(0,0,1,1),this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._isUserControllingOffset=!1,this._isUserControllingZoom=!1,this._lastDollyDirection=Bt.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new he.Vector3,this._focalOffsetVelocity=new he.Vector3,this._zoomVelocity={value:0},this._truckInternal=(_,L,b)=>{let C,m;if(Pt(this._camera)){const S=ye.copy(this._camera.position).sub(this._target),p=this._camera.getEffectiveFOV()*Jt,I=S.length()*Math.tan(p*.5);C=this.truckSpeed*_*I/this._elementRect.height,m=this.truckSpeed*L*I/this._elementRect.height}else if(gt(this._camera)){const S=this._camera;C=_*(S.right-S.left)/S.zoom/this._elementRect.width,m=L*(S.top-S.bottom)/S.zoom/this._elementRect.height}else return;this.verticalDragToForward?(b?this.setFocalOffset(this._focalOffsetEnd.x+C,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(C,0,!0),this.forward(-m,!0)):b?this.setFocalOffset(this._focalOffsetEnd.x+C,this._focalOffsetEnd.y+m,this._focalOffsetEnd.z,!0):this.truck(C,m,!0)},this._rotateInternal=(_,L)=>{const b=Ft*this.azimuthRotateSpeed*_/this._elementRect.height,C=Ft*this.polarRotateSpeed*L/this._elementRect.height;this.rotate(b,C,!0)},this._dollyInternal=(_,L,b)=>{const C=Math.pow(.95,-_*this.dollySpeed),m=this._sphericalEnd.radius,S=this._sphericalEnd.radius*C,p=Je(S,this.minDistance,this.maxDistance),I=p-S;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(S,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(I,!0),this._dollyToNoClamp(p,!0)):this._dollyToNoClamp(p,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?S:p)-m,this._dollyControlCoord.set(L,b)),this._lastDollyDirection=Math.sign(-_)},this._zoomInternal=(_,L,b)=>{const C=Math.pow(.95,_*this.dollySpeed),m=this._zoom,S=this._zoom*C;this.zoomTo(S,!0),this.dollyToCursor&&(this._changedZoom+=S-m,this._dollyControlCoord.set(L,b))},typeof he>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=new he.Quaternion().setFromUnitVectors(this._camera.up,An),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=$.NONE,this._target=new he.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new he.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new he.Spherical().setFromVector3(ye.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new he.Vector3,new he.Vector3,new he.Vector3,new he.Vector3],this._updateNearPlaneCorners(),this._boundary=new he.Box3(new he.Vector3(-1/0,-1/0,-1/0),new he.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new he.Vector2,this.mouseButtons={left:$.ROTATE,middle:$.DOLLY,right:$.TRUCK,wheel:Pt(this._camera)?$.DOLLY:gt(this._camera)?$.ZOOM:$.NONE},this.touches={one:$.TOUCH_ROTATE,two:Pt(this._camera)?$.TOUCH_DOLLY_TRUCK:gt(this._camera)?$.TOUCH_ZOOM_TRUCK:$.NONE,three:$.TOUCH_TRUCK};const n=new he.Vector2,r=new he.Vector2,s=new he.Vector2,i=_=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const C=this._domElement.getBoundingClientRect(),m=_.clientX/C.width,S=_.clientY/C.height;if(m<this._interactiveArea.left||m>this._interactiveArea.right||S<this._interactiveArea.top||S>this._interactiveArea.bottom)return}const L=_.pointerType!=="mouse"?null:(_.buttons&de.LEFT)===de.LEFT?de.LEFT:(_.buttons&de.MIDDLE)===de.MIDDLE?de.MIDDLE:(_.buttons&de.RIGHT)===de.RIGHT?de.RIGHT:null;if(L!==null){const C=this._findPointerByMouseButton(L);C&&this._disposePointer(C)}if((_.buttons&de.LEFT)===de.LEFT&&this._lockedPointer)return;const b={pointerId:_.pointerId,clientX:_.clientX,clientY:_.clientY,deltaX:0,deltaY:0,mouseButton:L};this._activePointers.push(b),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.addEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),this._isDragging=!0,w(_)},a=_=>{if(!this._enabled||!this._domElement||this._lockedPointer)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const C=this._domElement.getBoundingClientRect(),m=_.clientX/C.width,S=_.clientY/C.height;if(m<this._interactiveArea.left||m>this._interactiveArea.right||S<this._interactiveArea.top||S>this._interactiveArea.bottom)return}const L=(_.buttons&de.LEFT)===de.LEFT?de.LEFT:(_.buttons&de.MIDDLE)===de.MIDDLE?de.MIDDLE:(_.buttons&de.RIGHT)===de.RIGHT?de.RIGHT:null;if(L!==null){const C=this._findPointerByMouseButton(L);C&&this._disposePointer(C)}const b={pointerId:1,clientX:_.clientX,clientY:_.clientY,deltaX:0,deltaY:0,mouseButton:(_.buttons&de.LEFT)===de.LEFT?de.LEFT:(_.buttons&de.MIDDLE)===de.LEFT?de.MIDDLE:(_.buttons&de.RIGHT)===de.LEFT?de.RIGHT:null};this._activePointers.push(b),this._domElement.ownerDocument.removeEventListener("mousemove",u),this._domElement.ownerDocument.removeEventListener("mouseup",d),this._domElement.ownerDocument.addEventListener("mousemove",u),this._domElement.ownerDocument.addEventListener("mouseup",d),this._isDragging=!0,w(_)},l=_=>{_.cancelable&&_.preventDefault();const L=_.pointerId,b=this._lockedPointer||this._findPointerById(L);if(b){if(b.clientX=_.clientX,b.clientY=_.clientY,b.deltaX=_.movementX,b.deltaY=_.movementY,this._state=0,_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else(!this._isDragging&&this._lockedPointer||this._isDragging&&(_.buttons&de.LEFT)===de.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(_.buttons&de.MIDDLE)===de.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(_.buttons&de.RIGHT)===de.RIGHT&&(this._state=this._state|this.mouseButtons.right);v()}},u=_=>{const L=this._lockedPointer||this._findPointerById(1);L&&(L.clientX=_.clientX,L.clientY=_.clientY,L.deltaX=_.movementX,L.deltaY=_.movementY,this._state=0,(this._lockedPointer||(_.buttons&de.LEFT)===de.LEFT)&&(this._state=this._state|this.mouseButtons.left),(_.buttons&de.MIDDLE)===de.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(_.buttons&de.RIGHT)===de.RIGHT&&(this._state=this._state|this.mouseButtons.right),v())},h=_=>{const L=this._findPointerById(_.pointerId);if(!(L&&L===this._lockedPointer)){if(L&&this._disposePointer(L),_.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=$.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=$.NONE;A()}},d=()=>{const _=this._findPointerById(1);_&&_===this._lockedPointer||(_&&this._disposePointer(_),this._state=$.NONE,A())};let g=-1;const y=_=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===$.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const S=this._domElement.getBoundingClientRect(),p=_.clientX/S.width,I=_.clientY/S.height;if(p<this._interactiveArea.left||p>this._interactiveArea.right||I<this._interactiveArea.top||I>this._interactiveArea.bottom)return}if(_.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===$.ROTATE||this.mouseButtons.wheel===$.TRUCK){const S=performance.now();g-S<1e3&&this._getClientRect(this._elementRect),g=S}const L=yc?-1:-3,b=_.deltaMode===1?_.deltaY/L:_.deltaY/(L*10),C=this.dollyToCursor?(_.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,m=this.dollyToCursor?(_.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case $.ROTATE:{this._rotateInternal(_.deltaX,_.deltaY),this._isUserControllingRotate=!0;break}case $.TRUCK:{this._truckInternal(_.deltaX,_.deltaY,!1),this._isUserControllingTruck=!0;break}case $.OFFSET:{this._truckInternal(_.deltaX,_.deltaY,!0),this._isUserControllingOffset=!0;break}case $.DOLLY:{this._dollyInternal(-b,C,m),this._isUserControllingDolly=!0;break}case $.ZOOM:{this._zoomInternal(-b,C,m),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},x=_=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===nn.ACTION.NONE){const L=_ instanceof PointerEvent?_.pointerId:(_ instanceof MouseEvent,0),b=this._findPointerById(L);b&&this._disposePointer(b),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("mousemove",u),this._domElement.ownerDocument.removeEventListener("mouseup",d);return}_.preventDefault()}},w=_=>{if(!this._enabled)return;if(ur(this._activePointers,Re),this._getClientRect(this._elementRect),n.copy(Re),r.copy(Re),this._activePointers.length>=2){const b=Re.x-this._activePointers[1].clientX,C=Re.y-this._activePointers[1].clientY,m=Math.sqrt(b*b+C*C);s.set(0,m);const S=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,p=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;r.set(S,p)}if(this._state=0,!_)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in _&&_.pointerType==="touch")switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else!this._lockedPointer&&(_.buttons&de.LEFT)===de.LEFT&&(this._state=this._state|this.mouseButtons.left),(_.buttons&de.MIDDLE)===de.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(_.buttons&de.RIGHT)===de.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&$.ROTATE)===$.ROTATE||(this._state&$.TOUCH_ROTATE)===$.TOUCH_ROTATE||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&$.TRUCK)===$.TRUCK||(this._state&$.TOUCH_TRUCK)===$.TOUCH_TRUCK||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&$.DOLLY)===$.DOLLY||(this._state&$.TOUCH_DOLLY)===$.TOUCH_DOLLY||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&$.ZOOM)===$.ZOOM||(this._state&$.TOUCH_ZOOM)===$.TOUCH_ZOOM||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&$.OFFSET)===$.OFFSET||(this._state&$.TOUCH_OFFSET)===$.TOUCH_OFFSET||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},v=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,ur(this._activePointers,Re);const L=this._domElement&&document.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,b=L?-L.deltaX:r.x-Re.x,C=L?-L.deltaY:r.y-Re.y;if(r.copy(Re),((this._state&$.ROTATE)===$.ROTATE||(this._state&$.TOUCH_ROTATE)===$.TOUCH_ROTATE||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(b,C),this._isUserControllingRotate=!0),(this._state&$.DOLLY)===$.DOLLY||(this._state&$.ZOOM)===$.ZOOM){const m=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,S=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0,p=this.dollyDragInverted?-1:1;(this._state&$.DOLLY)===$.DOLLY?(this._dollyInternal(p*C*Sn,m,S),this._isUserControllingDolly=!0):(this._zoomInternal(p*C*Sn,m,S),this._isUserControllingZoom=!0)}if((this._state&$.TOUCH_DOLLY)===$.TOUCH_DOLLY||(this._state&$.TOUCH_ZOOM)===$.TOUCH_ZOOM||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_ZOOM_ROTATE)===$.TOUCH_ZOOM_ROTATE){const m=Re.x-this._activePointers[1].clientX,S=Re.y-this._activePointers[1].clientY,p=Math.sqrt(m*m+S*S),I=s.y-p;s.set(0,p);const k=this.dollyToCursor?(r.x-this._elementRect.x)/this._elementRect.width*2-1:0,J=this.dollyToCursor?(r.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&$.TOUCH_DOLLY)===$.TOUCH_DOLLY||(this._state&$.TOUCH_DOLLY_ROTATE)===$.TOUCH_DOLLY_ROTATE||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET?(this._dollyInternal(I*Sn,k,J),this._isUserControllingDolly=!0):(this._zoomInternal(I*Sn,k,J),this._isUserControllingZoom=!0)}((this._state&$.TRUCK)===$.TRUCK||(this._state&$.TOUCH_TRUCK)===$.TOUCH_TRUCK||(this._state&$.TOUCH_DOLLY_TRUCK)===$.TOUCH_DOLLY_TRUCK||(this._state&$.TOUCH_ZOOM_TRUCK)===$.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(b,C,!1),this._isUserControllingTruck=!0),((this._state&$.OFFSET)===$.OFFSET||(this._state&$.TOUCH_OFFSET)===$.TOUCH_OFFSET||(this._state&$.TOUCH_DOLLY_OFFSET)===$.TOUCH_DOLLY_OFFSET||(this._state&$.TOUCH_ZOOM_OFFSET)===$.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(b,C,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},A=()=>{ur(this._activePointers,Re),r.copy(Re),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",u),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("mouseup",d),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",D),this._domElement.ownerDocument.addEventListener("pointerlockerror",M),this._domElement.ownerDocument.addEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",h),w())},this.unlockPointer=()=>{this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),document.exitPointerLock(),this.cancel(),this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointerlockchange",D),this._domElement.ownerDocument.removeEventListener("pointerlockerror",M))};const D=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},M=()=>{this.unlockPointer()};this._addAllEventListeners=_=>{this._domElement=_,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",i),_c&&this._domElement.addEventListener("mousedown",a),this._domElement.addEventListener("pointercancel",h),this._domElement.addEventListener("wheel",y,{passive:!1}),this._domElement.addEventListener("contextmenu",x)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",i),this._domElement.removeEventListener("mousedown",a),this._domElement.removeEventListener("pointercancel",h),this._domElement.removeEventListener("wheel",y,{passive:!1}),this._domElement.removeEventListener("contextmenu",x),this._domElement.ownerDocument.removeEventListener("pointermove",l,{passive:!1}),this._domElement.ownerDocument.removeEventListener("mousemove",u),this._domElement.ownerDocument.removeEventListener("pointerup",h),this._domElement.ownerDocument.removeEventListener("mouseup",d),this._domElement.ownerDocument.removeEventListener("pointerlockchange",D),this._domElement.ownerDocument.removeEventListener("pointerlockerror",M))},this.cancel=()=>{this._state!==$.NONE&&(this._state=$.NONE,this._activePointers.length=0,A())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=Je(e.width,0,1),this._interactiveArea.height=Je(e.height,0,1),this._interactiveArea.x=Je(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=Je(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,n=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,n)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,n=!1){this._isUserControllingRotate=!1;const r=Je(e,this.minAzimuthAngle,this.maxAzimuthAngle),s=Je(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=r,this._sphericalEnd.phi=s,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const i=!n||Ae(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Ae(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(i)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=Bt.NONE,this._changedDolly=0,this._dollyToNoClamp(Je(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const n=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const i=this._collisionTest(),a=Ae(i,this._spherical.radius);if(!(n>e)&&a)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,i)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const s=!t||Ae(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(s)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(en).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const n=!t||Ae(this._target.x,this._targetEnd.x,this.restThreshold)&&Ae(this._target.y,this._targetEnd.y,this.restThreshold)&&Ae(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=Je(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const n=!t||Ae(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(n)}pan(e,t,n=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,n)}truck(e,t,n=!1){this._camera.updateMatrix(),et.setFromMatrixColumn(this._camera.matrix,0),tt.setFromMatrixColumn(this._camera.matrix,1),et.multiplyScalar(e),tt.multiplyScalar(-t);const r=ye.copy(et).add(tt),s=Me.copy(this._targetEnd).add(r);return this.moveTo(s.x,s.y,s.z,n)}forward(e,t=!1){ye.setFromMatrixColumn(this._camera.matrix,0),ye.crossVectors(this._camera.up,ye),ye.multiplyScalar(e);const n=Me.copy(this._targetEnd).add(ye);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return ye.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+ye.x,this._targetEnd.y+ye.y,this._targetEnd.z+ye.z,t)}moveTo(e,t,n,r=!1){this._isUserControllingTruck=!1;const s=ye.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,s,this.boundaryFriction),this._needsUpdate=!0,r||this._target.copy(this._targetEnd);const i=!r||Ae(this._target.x,this._targetEnd.x,this.restThreshold)&&Ae(this._target.y,this._targetEnd.y,this.restThreshold)&&Ae(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}lookInDirectionOf(e,t,n,r=!1){const a=ye.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(a.x,a.y,a.z,r)}fitToBox(e,t,{cover:n=!1,paddingLeft:r=0,paddingRight:s=0,paddingBottom:i=0,paddingTop:a=0}={}){const l=[],u=e.isBox3?Nt.copy(e):Nt.setFromObject(e);u.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const h=Zs(this._sphericalEnd.theta,Ys),d=Zs(this._sphericalEnd.phi,Ys);l.push(this.rotateTo(h,d,t));const g=ye.setFromSpherical(this._sphericalEnd).normalize(),y=ei.setFromUnitVectors(g,fr),x=Ae(Math.abs(g.y),1);x&&y.multiply(pr.setFromAxisAngle(An,h)),y.multiply(this._yAxisUpSpaceInverse);const w=$s.makeEmpty();Me.copy(u.min).applyQuaternion(y),w.expandByPoint(Me),Me.copy(u.min).setX(u.max.x).applyQuaternion(y),w.expandByPoint(Me),Me.copy(u.min).setY(u.max.y).applyQuaternion(y),w.expandByPoint(Me),Me.copy(u.max).setZ(u.min.z).applyQuaternion(y),w.expandByPoint(Me),Me.copy(u.min).setZ(u.max.z).applyQuaternion(y),w.expandByPoint(Me),Me.copy(u.max).setY(u.min.y).applyQuaternion(y),w.expandByPoint(Me),Me.copy(u.max).setX(u.min.x).applyQuaternion(y),w.expandByPoint(Me),Me.copy(u.max).applyQuaternion(y),w.expandByPoint(Me),w.min.x-=r,w.min.y-=i,w.max.x+=s,w.max.y+=a,y.setFromUnitVectors(fr,g),x&&y.premultiply(pr.invert()),y.premultiply(this._yAxisUpSpace);const v=w.getSize(ye),A=w.getCenter(Me).applyQuaternion(y);if(Pt(this._camera)){const D=this.getDistanceToFitBox(v.x,v.y,v.z,n);l.push(this.moveTo(A.x,A.y,A.z,t)),l.push(this.dollyTo(D,t)),l.push(this.setFocalOffset(0,0,0,t))}else if(gt(this._camera)){const D=this._camera,M=D.right-D.left,_=D.top-D.bottom,L=n?Math.max(M/v.x,_/v.y):Math.min(M/v.x,_/v.y);l.push(this.moveTo(A.x,A.y,A.z,t)),l.push(this.zoomTo(L,t)),l.push(this.setFocalOffset(0,0,0,t))}return Promise.all(l)}fitToSphere(e,t){const n=[],s=e instanceof he.Sphere?dr.copy(e):nn.createBoundingSphere(e,dr);if(n.push(this.moveTo(s.center.x,s.center.y,s.center.z,t)),Pt(this._camera)){const i=this.getDistanceToFitSphere(s.radius);n.push(this.dollyTo(i,t))}else if(gt(this._camera)){const i=this._camera.right-this._camera.left,a=this._camera.top-this._camera.bottom,l=2*s.radius,u=Math.min(i/l,a/l);n.push(this.zoomTo(u,t))}return n.push(this.setFocalOffset(0,0,0,t)),Promise.all(n)}setLookAt(e,t,n,r,s,i,a=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Bt.NONE,this._changedDolly=0;const l=Me.set(r,s,i),u=ye.set(e,t,n);this._targetEnd.copy(l),this._sphericalEnd.setFromVector3(u.sub(l).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,a||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const h=!a||Ae(this._target.x,this._targetEnd.x,this.restThreshold)&&Ae(this._target.y,this._targetEnd.y,this.restThreshold)&&Ae(this._target.z,this._targetEnd.z,this.restThreshold)&&Ae(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Ae(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Ae(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(h)}lerpLookAt(e,t,n,r,s,i,a,l,u,h,d,g,y,x=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Bt.NONE,this._changedDolly=0;const w=ye.set(r,s,i),v=Me.set(e,t,n);Ke.setFromVector3(v.sub(w).applyQuaternion(this._yAxisUpSpace));const A=Ut.set(h,d,g),D=Me.set(a,l,u);tn.setFromVector3(D.sub(A).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(w.lerp(A,y));const M=tn.theta-Ke.theta,_=tn.phi-Ke.phi,L=tn.radius-Ke.radius;this._sphericalEnd.set(Ke.radius+L*y,Ke.phi+_*y,Ke.theta+M*y),this.normalizeRotations(),this._needsUpdate=!0,x||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const b=!x||Ae(this._target.x,this._targetEnd.x,this.restThreshold)&&Ae(this._target.y,this._targetEnd.y,this.restThreshold)&&Ae(this._target.z,this._targetEnd.z,this.restThreshold)&&Ae(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Ae(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Ae(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(b)}setPosition(e,t,n,r=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,r)}setTarget(e,t,n,r=!1){const s=this.getPosition(ye),i=this.setLookAt(s.x,s.y,s.z,e,t,n,r);return this._sphericalEnd.phi=Je(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),i}setFocalOffset(e,t,n,r=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,r||this._focalOffset.copy(this._focalOffsetEnd);const s=!r||Ae(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Ae(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Ae(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),et.setFromMatrixColumn(this._camera.matrixWorldInverse,0),tt.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Ct.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const r=ye.set(e,t,n),s=r.distanceTo(this._camera.position),i=r.sub(this._camera.position);et.multiplyScalar(i.x),tt.multiplyScalar(i.y),Ct.multiplyScalar(i.z),ye.copy(et).add(tt).add(Ct),ye.z=ye.z+s,this.dollyTo(s,!1),this.setFocalOffset(-ye.x,ye.y,-ye.z,!1),this.moveTo(e,t,n,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,n,r){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new he.Vector4,typeof e=="number"?this._viewport.set(e,t,n,r):this._viewport.copy(e)}getDistanceToFitBox(e,t,n,r=!1){if(hr(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const s=e/t,i=this._camera.getEffectiveFOV()*Jt,a=this._camera.aspect;return((r?s>a:s<a)?t:e/a)*.5/Math.tan(i*.5)+n*.5}getDistanceToFitSphere(e){if(hr(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*Jt,n=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,r=1<this._camera.aspect?t:n;return e/Math.sin(r*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new he.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new he.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e&&e instanceof he.Spherical?e:new he.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new he.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%Ft,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=Ft),this._spherical.theta+=Ft*Math.round((this._sphericalEnd.theta-this._spherical.theta)/Ft)}reset(e=!1){if(!Ae(this._camera.up.x,this._cameraUp0.x)||!Ae(this._camera.up.y,this._cameraUp0.y)||!Ae(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const n=this.getPosition(ye);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,An),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=ye.subVectors(this._target,this._camera.position).normalize(),t=Me.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const n=this.getPosition(ye);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,n=this._sphericalEnd.phi-this._spherical.phi,r=this._sphericalEnd.radius-this._spherical.radius,s=Js.subVectors(this._targetEnd,this._target),i=Hs.subVectors(this._focalOffsetEnd,this._focalOffset),a=this._zoomEnd-this._zoom;if(Ce(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const d=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Mn(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,d,1/0,e),this._needsUpdate=!0}if(Ce(n))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const d=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Mn(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,d,1/0,e),this._needsUpdate=!0}if(Ce(r))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const d=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Mn(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,d,this.maxSpeed,e),this._needsUpdate=!0}if(Ce(s.x)&&Ce(s.y)&&Ce(s.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const d=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Ks(this._target,this._targetEnd,this._targetVelocity,d,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(Ce(i.x)&&Ce(i.y)&&Ce(i.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const d=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Ks(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,d,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(Ce(a))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const d=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Mn(this._zoom,this._zoomEnd,this._zoomVelocity,d,1/0,e)}if(this.dollyToCursor){if(Pt(this._camera)&&this._changedDolly!==0){const d=this._spherical.radius-this._lastDistance,g=this._camera,y=this._getCameraDirection(en),x=ye.copy(y).cross(g.up).normalize();x.lengthSq()===0&&(x.x=1);const w=Me.crossVectors(x,y),v=this._sphericalEnd.radius*Math.tan(g.getEffectiveFOV()*Jt*.5),D=(this._sphericalEnd.radius-d-this._sphericalEnd.radius)/this._sphericalEnd.radius,M=Ut.copy(this._targetEnd).add(x.multiplyScalar(this._dollyControlCoord.x*v*g.aspect)).add(w.multiplyScalar(this._dollyControlCoord.y*v)),_=ye.copy(this._targetEnd).lerp(M,D),L=this._lastDollyDirection===Bt.IN&&this._spherical.radius<=this.minDistance,b=this._lastDollyDirection===Bt.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(L||b)){this._sphericalEnd.radius-=d,this._spherical.radius-=d;const m=Me.copy(y).multiplyScalar(-d);_.add(m)}this._boundary.clampPoint(_,_);const C=Me.subVectors(_,this._targetEnd);this._targetEnd.copy(_),this._target.add(C),this._changedDolly-=d,Ce(this._changedDolly)&&(this._changedDolly=0)}else if(gt(this._camera)&&this._changedZoom!==0){const d=this._zoom-this._lastZoom,g=this._camera,y=ye.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(g.near+g.far)/(g.near-g.far)).unproject(g),x=Me.set(0,0,-1).applyQuaternion(g.quaternion),w=Ut.copy(y).add(x.multiplyScalar(-y.dot(g.up))),A=-(this._zoom-d-this._zoom)/this._zoom,D=this._getCameraDirection(en),M=this._targetEnd.dot(D),_=ye.copy(this._targetEnd).lerp(w,A),L=_.dot(D),b=D.multiplyScalar(L-M);_.sub(b),this._boundary.clampPoint(_,_);const C=Me.subVectors(_,this._targetEnd);this._targetEnd.copy(_),this._target.add(C),this._changedZoom-=d,Ce(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const l=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,l),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!Ce(this._focalOffset.x)||!Ce(this._focalOffset.y)||!Ce(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),et.setFromMatrixColumn(this._camera.matrix,0),tt.setFromMatrixColumn(this._camera.matrix,1),Ct.setFromMatrixColumn(this._camera.matrix,2),et.multiplyScalar(this._focalOffset.x),tt.multiplyScalar(-this._focalOffset.y),Ct.multiplyScalar(this._focalOffset.z),ye.copy(et).add(tt).add(Ct),this._camera.position.add(ye)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),ye.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const h=this._needsUpdate;return h&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):h?(this.dispatchEvent({type:"update"}),Ce(t,this.restThreshold)&&Ce(n,this.restThreshold)&&Ce(r,this.restThreshold)&&Ce(s.x,this.restThreshold)&&Ce(s.y,this.restThreshold)&&Ce(s.z,this.restThreshold)&&Ce(i.x,this.restThreshold)&&Ce(i.y,this.restThreshold)&&Ce(i.z,this.restThreshold)&&Ce(a,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!h&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=h,this._needsUpdate=!1,h}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:Ht(this.maxDistance),minZoom:this.minZoom,maxZoom:Ht(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:Ht(this.maxPolarAngle),minAzimuthAngle:Ht(this.minAzimuthAngle),maxAzimuthAngle:Ht(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,verticalDragToForward:this.verticalDragToForward,target:this._targetEnd.toArray(),position:ye.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){const n=JSON.parse(e);this.enabled=n.enabled,this.minDistance=n.minDistance,this.maxDistance=$t(n.maxDistance),this.minZoom=n.minZoom,this.maxZoom=$t(n.maxZoom),this.minPolarAngle=n.minPolarAngle,this.maxPolarAngle=$t(n.maxPolarAngle),this.minAzimuthAngle=$t(n.minAzimuthAngle),this.maxAzimuthAngle=$t(n.maxAzimuthAngle),this.smoothTime=n.smoothTime,this.draggingSmoothTime=n.draggingSmoothTime,this.dollySpeed=n.dollySpeed,this.truckSpeed=n.truckSpeed,this.dollyToCursor=n.dollyToCursor,this.verticalDragToForward=n.verticalDragToForward,this._target0.fromArray(n.target0),this._position0.fromArray(n.position0),this._zoom0=n.zoom0,this._focalOffset0.fromArray(n.focalOffset0),this.moveTo(n.target[0],n.target[1],n.target[2],t),Ke.setFromVector3(ye.fromArray(n.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Ke.theta,Ke.phi,t),this.dollyTo(Ke.radius,t),this.zoomTo(n.zoom,t),this.setFocalOffset(n.focalOffset[0],n.focalOffset[1],n.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn("camera-controls is already connected.");return}e.setAttribute("data-camera-controls-version",gc),this._addAllEventListeners(e),this._getClientRect(this._elementRect)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,n){const r=t.lengthSq();if(r===0)return e;const s=Me.copy(t).add(e),a=this._boundary.clampPoint(s,Ut).sub(s),l=a.lengthSq();if(l===0)return e.add(t);if(l===r)return e;if(n===0)return e.add(t).add(a);{const u=1+n*l/t.dot(a);return e.add(Me.copy(t).multiplyScalar(u)).add(a.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(Pt(this._camera)){const e=this._camera,t=e.near,n=e.getEffectiveFOV()*Jt,r=Math.tan(n*.5)*t,s=r*e.aspect;this._nearPlaneCorners[0].set(-s,-r,0),this._nearPlaneCorners[1].set(s,-r,0),this._nearPlaneCorners[2].set(s,r,0),this._nearPlaneCorners[3].set(-s,r,0)}else if(gt(this._camera)){const e=this._camera,t=1/e.zoom,n=e.left*t,r=e.right*t,s=e.top*t,i=e.bottom*t;this._nearPlaneCorners[0].set(n,s,0),this._nearPlaneCorners[1].set(r,s,0),this._nearPlaneCorners[2].set(r,i,0),this._nearPlaneCorners[3].set(n,i,0)}}_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||hr(this._camera,"_collisionTest"))return e;const n=this._getTargetDirection(en);mr.lookAt(Qs,n,this._camera.up);for(let r=0;r<4;r++){const s=Me.copy(this._nearPlaneCorners[r]);s.applyMatrix4(mr);const i=Ut.addVectors(this._target,s);Pn.set(i,n),Pn.far=this._spherical.radius+1;const a=Pn.intersectObjects(this.colliderMeshes);a.length!==0&&a[0].distance<e&&(e=a[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const n=()=>{this.removeEventListener("rest",n),t()};this.addEventListener("rest",n)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new he.Sphere){const n=t,r=n.center;Nt.makeEmpty(),e.traverseVisible(i=>{i.isMesh&&Nt.expandByObject(i)}),Nt.getCenter(r);let s=0;return e.traverseVisible(i=>{if(!i.isMesh)return;const a=i,l=a.geometry.clone();l.applyMatrix4(a.matrixWorld);const h=l.attributes.position;for(let d=0,g=h.count;d<g;d++)ye.fromBufferAttribute(h,d),s=Math.max(s,r.distanceToSquared(ye))}),n.radius=Math.sqrt(s),n}}const vc=["min-polar-angle","max-polar-angle","min-azimuth-angle","max-azimuth-angle","distance","min-distance","max-distance","infinity-dolly","min-zoom","max-zoom","smooth-time","dragging-smooth-time","max-speed","azimuth-rotate-speed","polar-rotate-speed","dolly-speed","dolly-drag-inverted","truck-speed","dolly-to-cursor","drag-to-offset","vertical-drag-to-forward","boundary-friction","rest-threshold","collider-meshes","args"],xc=f.defineComponent({__name:"CameraControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},minPolarAngle:{default:0},maxPolarAngle:{default:Math.PI},minAzimuthAngle:{default:-1/0},maxAzimuthAngle:{default:1/0},distance:{default:()=>ae.useTresContext().camera.value.position.z},minDistance:{default:Number.EPSILON},maxDistance:{default:1/0},infinityDolly:{type:Boolean,default:!1},minZoom:{default:.01},maxZoom:{default:1/0},smoothTime:{default:.25},draggingSmoothTime:{default:.125},maxSpeed:{default:1/0},azimuthRotateSpeed:{default:1},polarRotateSpeed:{default:1},dollySpeed:{default:1},dollyDragInverted:{type:Boolean,default:!1},truckSpeed:{default:2},dollyToCursor:{type:Boolean,default:!1},dragToOffset:{type:Boolean,default:!1},verticalDragToForward:{type:Boolean,default:!1},boundaryFriction:{default:0},restThreshold:{default:.01},colliderMeshes:{default:()=>[]},mouseButtons:{},touches:{}},emits:["change","start","end"],setup(o,{expose:e,emit:t}){const n=o,r=t,{makeDefault:s,minPolarAngle:i,maxPolarAngle:a,minAzimuthAngle:l,maxAzimuthAngle:u,distance:h,minDistance:d,maxDistance:g,infinityDolly:y,minZoom:x,maxZoom:w,smoothTime:v,draggingSmoothTime:A,maxSpeed:D,azimuthRotateSpeed:M,polarRotateSpeed:_,dollySpeed:L,dollyDragInverted:b,truckSpeed:C,dollyToCursor:m,dragToOffset:S,verticalDragToForward:p,boundaryFriction:I,restThreshold:k,colliderMeshes:J}=f.toRefs(n),R={Box3:c.Box3,MathUtils:{clamp:c.MathUtils.clamp},Matrix4:c.Matrix4,Quaternion:c.Quaternion,Raycaster:c.Raycaster,Sphere:c.Sphere,Spherical:c.Spherical,Vector2:c.Vector2,Vector3:c.Vector3,Vector4:c.Vector4};nn.install({THREE:R});const{camera:Z,renderer:X,extend:q,controls:Y}=ae.useTresContext(),te=f.ref(null);q({CameraControls:nn}),f.watchEffect(()=>{re(),te.value&&s.value?Y.value=te.value:Y.value=null});function re(){Le(te.value,"update",()=>r("change",te.value)),Le(te.value,"controlend",()=>r("end",te.value)),Le(te.value,"controlstart",()=>r("start",te.value))}const{onLoop:ce}=ae.useRenderLoop();return ce(({delta:j})=>{var z,P;(z=te.value)!=null&&z.enabled&&((P=te.value)==null||P.update(j))}),f.onUnmounted(()=>{te.value&&te.value.disconnect()}),e({value:te}),(j,z)=>(j.camera||f.unref(Z))&&(j.domElement||f.unref(X))?(f.openBlock(),f.createElementBlock("TresCameraControls",{key:0,ref_key:"controlsRef",ref:te,"min-polar-angle":f.unref(i),"max-polar-angle":f.unref(a),"min-azimuth-angle":f.unref(l),"max-azimuth-angle":f.unref(u),distance:f.unref(h),"min-distance":f.unref(d),"max-distance":f.unref(g),"infinity-dolly":f.unref(y),"min-zoom":f.unref(x),"max-zoom":f.unref(w),"smooth-time":f.unref(v),"dragging-smooth-time":f.unref(A),"max-speed":f.unref(D),"azimuth-rotate-speed":f.unref(M),"polar-rotate-speed":f.unref(_),"dolly-speed":f.unref(L),"dolly-drag-inverted":f.unref(b),"truck-speed":f.unref(C),"dolly-to-cursor":f.unref(m),"drag-to-offset":f.unref(S),"vertical-drag-to-forward":f.unref(p),"boundary-friction":f.unref(I),"rest-threshold":f.unref(k),"collider-meshes":f.unref(J),args:[j.camera||f.unref(Z),j.domElement||f.unref(X).domElement]},null,8,vc)):f.createCommentVNode("",!0)}});class wc extends c.MeshStandardMaterial{constructor(t={}){super(t);le(this,"_time");le(this,"_factor");this.setValues(t),this._time={value:0},this._factor={value:1}}onBeforeCompile(t){t.uniforms||(t.uniforms={}),t.uniforms.time=this._time,t.uniforms.factor=this._factor,t.vertexShader=`
|
|
253
253
|
uniform float time;
|
|
254
254
|
uniform float factor;
|
|
255
255
|
${t.vertexShader}
|
|
@@ -258,15 +258,15 @@
|
|
|
258
258
|
float s = sin( theta );
|
|
259
259
|
mat3 m = mat3( c, 0, s, 0, 1, 0, -s, 0, c );
|
|
260
260
|
vec3 transformed = vec3( position ) * m;
|
|
261
|
-
vNormal = vNormal * m;`)}get time(){return this._time.value}set time(t){this._time.value=t}get factor(){return this._factor.value}set factor(t){this._factor.value=t}}const vc=["factor"],xc=f.defineComponent({__name:"index",props:{speed:{default:1},factor:{default:1}},setup(o){const e=o,t=f.shallowRef(),{extend:n}=ae.useTresContext();n({MeshWobbleMaterial:_c});const{onLoop:s}=ae.useRenderLoop();return s(({elapsed:r})=>{t.value&&(t.value.time=r*(e==null?void 0:e.speed))}),(r,i)=>(f.openBlock(),f.createElementBlock("TresMeshWobbleMaterial",f.mergeProps({ref_key:"materialRef",ref:t,factor:r.factor},r.$attrs),null,16,vc))}});function gt(o,e,t){return Math.max(e,Math.min(t,o))}function wc(o,e){return(o%e+e)%e}function bc(o,e,t,n,s){return n+(o-e)*(s-n)/(t-e)}function ps(o,e,t){return(1-t)*o+t*e}class ms{constructor(e=0,t=0){ms.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(gt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,i=this.y-e.y;return this.x=r*n-i*s+e.x,this.y=r*s+i*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}const Mc="",yt="srgb",gs="srgb-linear",Sc="display-p3",$r="display-p3-linear",ys="linear",ei="srgb",ti="rec709",ni="p3";class tn{constructor(e,t,n,s,r,i,a,l,u){tn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,i,a,l,u)}set(e,t,n,s,r,i,a,l,u){const h=this.elements;return h[0]=e,h[1]=s,h[2]=a,h[3]=t,h[4]=r,h[5]=l,h[6]=n,h[7]=i,h[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,r=this.elements,i=n[0],a=n[3],l=n[6],u=n[1],h=n[4],d=n[7],y=n[2],g=n[5],x=n[8],w=s[0],v=s[3],P=s[6],D=s[1],S=s[4],_=s[7],L=s[2],b=s[5],C=s[8];return r[0]=i*w+a*D+l*L,r[3]=i*v+a*S+l*b,r[6]=i*P+a*_+l*C,r[1]=u*w+h*D+d*L,r[4]=u*v+h*S+d*b,r[7]=u*P+h*_+d*C,r[2]=y*w+g*D+x*L,r[5]=y*v+g*S+x*b,r[8]=y*P+g*_+x*C,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],i=e[4],a=e[5],l=e[6],u=e[7],h=e[8];return t*i*h-t*a*u-n*r*h+n*a*l+s*r*u-s*i*l}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],i=e[4],a=e[5],l=e[6],u=e[7],h=e[8],d=h*i-a*u,y=a*l-h*r,g=u*r-i*l,x=t*d+n*y+s*g;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const w=1/x;return e[0]=d*w,e[1]=(s*u-h*n)*w,e[2]=(a*n-s*i)*w,e[3]=y*w,e[4]=(h*t-s*l)*w,e[5]=(s*r-a*t)*w,e[6]=g*w,e[7]=(n*l-u*t)*w,e[8]=(i*t-n*r)*w,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,s,r,i,a){const l=Math.cos(r),u=Math.sin(r);return this.set(n*l,n*u,-n*(l*i+u*a)+i+e,-s*u,s*l,-s*(-u*i+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(_s.makeScale(e,t)),this}rotate(e){return this.premultiply(_s.makeRotation(-e)),this}translate(e,t){return this.premultiply(_s.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const _s=new tn,si=new tn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),ri=new tn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),An={[gs]:{transfer:ys,primaries:ti,toReference:o=>o,fromReference:o=>o},[yt]:{transfer:ei,primaries:ti,toReference:o=>o.convertSRGBToLinear(),fromReference:o=>o.convertLinearToSRGB()},[$r]:{transfer:ys,primaries:ni,toReference:o=>o.applyMatrix3(ri),fromReference:o=>o.applyMatrix3(si)},[Sc]:{transfer:ei,primaries:ni,toReference:o=>o.convertSRGBToLinear().applyMatrix3(ri),fromReference:o=>o.applyMatrix3(si).convertLinearToSRGB()}},Ac=new Set([gs,$r]),Je={enabled:!0,_workingColorSpace:gs,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(o){if(!Ac.has(o))throw new Error(`Unsupported working color space, "${o}".`);this._workingColorSpace=o},convert:function(o,e,t){if(this.enabled===!1||e===t||!e||!t)return o;const n=An[e].toReference,s=An[t].fromReference;return s(n(o))},fromWorkingColorSpace:function(o,e){return this.convert(o,this._workingColorSpace,e)},toWorkingColorSpace:function(o,e){return this.convert(o,e,this._workingColorSpace)},getPrimaries:function(o){return An[o].primaries},getTransfer:function(o){return o===Mc?ys:An[o].transfer}};function vs(o){return o<.04045?o*.0773993808:Math.pow(o*.9478672986+.0521327014,2.4)}function xs(o){return o<.0031308?o*12.92:1.055*Math.pow(o,.41666)-.055}const ii={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},_t={h:0,s:0,l:0},Pn={h:0,s:0,l:0};function ws(o,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?o+(e-o)*6*t:t<1/2?e:t<2/3?o+(e-o)*6*(2/3-t):o}class Cn{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=yt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Je.toWorkingColorSpace(this,t),this}setRGB(e,t,n,s=Je.workingColorSpace){return this.r=e,this.g=t,this.b=n,Je.toWorkingColorSpace(this,s),this}setHSL(e,t,n,s=Je.workingColorSpace){if(e=wc(e,1),t=gt(t,0,1),n=gt(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=ws(i,r,e+1/3),this.g=ws(i,r,e),this.b=ws(i,r,e-1/3)}return Je.toWorkingColorSpace(this,s),this}setStyle(e,t=yt){function n(r){r!==void 0&&parseFloat(r)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const i=s[1],a=s[2];switch(i){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],i=r.length;if(i===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(r,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=yt){const n=ii[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=vs(e.r),this.g=vs(e.g),this.b=vs(e.b),this}copyLinearToSRGB(e){return this.r=xs(e.r),this.g=xs(e.g),this.b=xs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=yt){return Je.fromWorkingColorSpace(ze.copy(this),e),Math.round(gt(ze.r*255,0,255))*65536+Math.round(gt(ze.g*255,0,255))*256+Math.round(gt(ze.b*255,0,255))}getHexString(e=yt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Je.workingColorSpace){Je.fromWorkingColorSpace(ze.copy(this),t);const n=ze.r,s=ze.g,r=ze.b,i=Math.max(n,s,r),a=Math.min(n,s,r);let l,u;const h=(a+i)/2;if(a===i)l=0,u=0;else{const d=i-a;switch(u=h<=.5?d/(i+a):d/(2-i-a),i){case n:l=(s-r)/d+(s<r?6:0);break;case s:l=(r-n)/d+2;break;case r:l=(n-s)/d+4;break}l/=6}return e.h=l,e.s=u,e.l=h,e}getRGB(e,t=Je.workingColorSpace){return Je.fromWorkingColorSpace(ze.copy(this),t),e.r=ze.r,e.g=ze.g,e.b=ze.b,e}getStyle(e=yt){Je.fromWorkingColorSpace(ze.copy(this),e);const t=ze.r,n=ze.g,s=ze.b;return e!==yt?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(_t),this.setHSL(_t.h+e,_t.s+t,_t.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(_t),e.getHSL(Pn);const n=ps(_t.h,Pn.h,t),s=ps(_t.s,Pn.s,t),r=ps(_t.l,Pn.l,t);return this.setHSL(n,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*s,this.g=r[1]*t+r[4]*n+r[7]*s,this.b=r[2]*t+r[5]*n+r[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const ze=new Cn;Cn.NAMES=ii;class Pc extends c.MeshStandardMaterial{constructor(t={}){super();le(this,"isMeshPhysicalMaterial");le(this,"clearcoatMap");le(this,"clearcoatRoughness");le(this,"clearcoatRoughnessMap");le(this,"clearcoatNormalScale");le(this,"clearcoatNormalMap");le(this,"ior");le(this,"transmissionMap");le(this,"thickness");le(this,"thicknessMap");le(this,"attenuationDistance");le(this,"attenuationColor");le(this,"specularIntensity");le(this,"specularIntensityMap");le(this,"specularColor");le(this,"specularColorMap");le(this,"_clearcoat");le(this,"_transmission");this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new ms(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get(){return gt(2.5*(this.ior-1)/(this.ior+1),0,1)},set(n){this.ior=(1+.4*n)/(1-.4*n)}}),this.roughness=0,this.transmissionMap=null,this.thickness=.5,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Cn(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Cn(1,1,1),this.specularColorMap=null,this._clearcoat=.5,this._transmission=1,this.setValues(t)}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.ior=t.ior,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}const Cc=Pc,Tc=f.defineComponent({__name:"index",setup(o,{expose:e}){const t=f.shallowRef(),{extend:n}=ae.useTresContext();return n({MeshGlassMaterial:Cc}),e({MeshGlassMaterialClass:t}),(s,r)=>(f.openBlock(),f.createElementBlock("TresMeshGlassMaterial",{ref_key:"MeshGlassMaterialClass",ref:t},null,512))}});var Lc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function nn(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function Tn(o){throw new Error('Could not dynamically require "'+o+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var oi={exports:{}};(function(o,e){(function(t){o.exports=t()})(function(){return function t(n,s,r){function i(u,h){if(!s[u]){if(!n[u]){var d=typeof Tn=="function"&&Tn;if(!h&&d)return d(u,!0);if(a)return a(u,!0);throw new Error("Cannot find module '"+u+"'")}h=s[u]={exports:{}},n[u][0].call(h.exports,function(y){var g=n[u][1][y];return i(g||y)},h,h.exports,t,n,s,r)}return s[u].exports}for(var a=typeof Tn=="function"&&Tn,l=0;l<r.length;l++)i(r[l]);return i}({1:[function(t,n,s){(function(r,i,a,l,u,h,d,y,g){var x=t("crypto");function w(b,C){C=D(b,C);var m;return(m=C.algorithm!=="passthrough"?x.createHash(C.algorithm):new L).write===void 0&&(m.write=m.update,m.end=m.update),_(C,m).dispatch(b),m.update||m.end(""),m.digest?m.digest(C.encoding==="buffer"?void 0:C.encoding):(b=m.read(),C.encoding!=="buffer"?b.toString(C.encoding):b)}(s=n.exports=w).sha1=function(b){return w(b)},s.keys=function(b){return w(b,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},s.MD5=function(b){return w(b,{algorithm:"md5",encoding:"hex"})},s.keysMD5=function(b){return w(b,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var v=x.getHashes?x.getHashes().slice():["sha1","md5"],P=(v.push("passthrough"),["buffer","hex","binary","base64"]);function D(b,C){var m={};if(m.algorithm=(C=C||{}).algorithm||"sha1",m.encoding=C.encoding||"hex",m.excludeValues=!!C.excludeValues,m.algorithm=m.algorithm.toLowerCase(),m.encoding=m.encoding.toLowerCase(),m.ignoreUnknown=C.ignoreUnknown===!0,m.respectType=C.respectType!==!1,m.respectFunctionNames=C.respectFunctionNames!==!1,m.respectFunctionProperties=C.respectFunctionProperties!==!1,m.unorderedArrays=C.unorderedArrays===!0,m.unorderedSets=C.unorderedSets!==!1,m.unorderedObjects=C.unorderedObjects!==!1,m.replacer=C.replacer||void 0,m.excludeKeys=C.excludeKeys||void 0,b===void 0)throw new Error("Object argument required.");for(var M=0;M<v.length;++M)v[M].toLowerCase()===m.algorithm.toLowerCase()&&(m.algorithm=v[M]);if(v.indexOf(m.algorithm)===-1)throw new Error('Algorithm "'+m.algorithm+'" not supported. supported values: '+v.join(", "));if(P.indexOf(m.encoding)===-1&&m.algorithm!=="passthrough")throw new Error('Encoding "'+m.encoding+'" not supported. supported values: '+P.join(", "));return m}function S(b){if(typeof b=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(b))!=null}function _(b,C,m){m=m||[];function M(p){return C.update?C.update(p,"utf8"):C.write(p,"utf8")}return{dispatch:function(p){return this["_"+((p=b.replacer?b.replacer(p):p)===null?"null":typeof p)](p)},_object:function(p){var I,F=Object.prototype.toString.call(p),J=/\[object (.*)\]/i.exec(F);if(J=(J=J?J[1]:"unknown:["+F+"]").toLowerCase(),0<=(F=m.indexOf(p)))return this.dispatch("[CIRCULAR:"+F+"]");if(m.push(p),a!==void 0&&a.isBuffer&&a.isBuffer(p))return M("buffer:"),M(p);if(J==="object"||J==="function"||J==="asyncfunction")return F=Object.keys(p),b.unorderedObjects&&(F=F.sort()),b.respectType===!1||S(p)||F.splice(0,0,"prototype","__proto__","constructor"),b.excludeKeys&&(F=F.filter(function(G){return!b.excludeKeys(G)})),M("object:"+F.length+":"),I=this,F.forEach(function(G){I.dispatch(G),M(":"),b.excludeValues||I.dispatch(p[G]),M(",")});if(!this["_"+J]){if(b.ignoreUnknown)return M("["+J+"]");throw new Error('Unknown object type "'+J+'"')}this["_"+J](p)},_array:function(p,G){G=G!==void 0?G:b.unorderedArrays!==!1;var F=this;if(M("array:"+p.length+":"),!G||p.length<=1)return p.forEach(function(Q){return F.dispatch(Q)});var J=[],G=p.map(function(Q){var K=new L,Z=m.slice();return _(b,K,Z).dispatch(Q),J=J.concat(Z.slice(m.length)),K.read().toString()});return m=m.concat(J),G.sort(),this._array(G,!1)},_date:function(p){return M("date:"+p.toJSON())},_symbol:function(p){return M("symbol:"+p.toString())},_error:function(p){return M("error:"+p.toString())},_boolean:function(p){return M("bool:"+p.toString())},_string:function(p){M("string:"+p.length+":"),M(p.toString())},_function:function(p){M("fn:"),S(p)?this.dispatch("[native]"):this.dispatch(p.toString()),b.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(p.name)),b.respectFunctionProperties&&this._object(p)},_number:function(p){return M("number:"+p.toString())},_xml:function(p){return M("xml:"+p.toString())},_null:function(){return M("Null")},_undefined:function(){return M("Undefined")},_regexp:function(p){return M("regex:"+p.toString())},_uint8array:function(p){return M("uint8array:"),this.dispatch(Array.prototype.slice.call(p))},_uint8clampedarray:function(p){return M("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(p))},_int8array:function(p){return M("int8array:"),this.dispatch(Array.prototype.slice.call(p))},_uint16array:function(p){return M("uint16array:"),this.dispatch(Array.prototype.slice.call(p))},_int16array:function(p){return M("int16array:"),this.dispatch(Array.prototype.slice.call(p))},_uint32array:function(p){return M("uint32array:"),this.dispatch(Array.prototype.slice.call(p))},_int32array:function(p){return M("int32array:"),this.dispatch(Array.prototype.slice.call(p))},_float32array:function(p){return M("float32array:"),this.dispatch(Array.prototype.slice.call(p))},_float64array:function(p){return M("float64array:"),this.dispatch(Array.prototype.slice.call(p))},_arraybuffer:function(p){return M("arraybuffer:"),this.dispatch(new Uint8Array(p))},_url:function(p){return M("url:"+p.toString())},_map:function(p){return M("map:"),p=Array.from(p),this._array(p,b.unorderedSets!==!1)},_set:function(p){return M("set:"),p=Array.from(p),this._array(p,b.unorderedSets!==!1)},_file:function(p){return M("file:"),this.dispatch([p.name,p.size,p.type,p.lastModfied])},_blob:function(){if(b.ignoreUnknown)return M("[blob]");throw Error(`Hashing Blob objects is currently not supported
|
|
261
|
+
vNormal = vNormal * m;`)}get time(){return this._time.value}set time(t){this._time.value=t}get factor(){return this._factor.value}set factor(t){this._factor.value=t}}const bc=["factor"],Mc=f.defineComponent({__name:"index",props:{speed:{default:1},factor:{default:1}},setup(o){const e=o,t=f.shallowRef(),{extend:n}=ae.useTresContext();n({MeshWobbleMaterial:wc});const{onLoop:r}=ae.useRenderLoop();return r(({elapsed:s})=>{t.value&&(t.value.time=s*(e==null?void 0:e.speed))}),(s,i)=>(f.openBlock(),f.createElementBlock("TresMeshWobbleMaterial",f.mergeProps({ref_key:"materialRef",ref:t,factor:s.factor},s.$attrs),null,16,bc))}});function yt(o,e,t){return Math.max(e,Math.min(t,o))}function Sc(o,e){return(o%e+e)%e}function Ac(o,e,t,n,r){return n+(o-e)*(r-n)/(t-e)}function gr(o,e,t){return(1-t)*o+t*e}class yr{constructor(e=0,t=0){yr.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(yt(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),s=this.x-e.x,i=this.y-e.y;return this.x=s*n-i*r+e.x,this.y=s*r+i*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}const Pc="",_t="srgb",_r="srgb-linear",Cc="display-p3",ti="display-p3-linear",vr="linear",ni="srgb",ri="rec709",si="p3";class rn{constructor(e,t,n,r,s,i,a,l,u){rn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,s,i,a,l,u)}set(e,t,n,r,s,i,a,l,u){const h=this.elements;return h[0]=e,h[1]=r,h[2]=a,h[3]=t,h[4]=s,h[5]=l,h[6]=n,h[7]=i,h[8]=u,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,s=this.elements,i=n[0],a=n[3],l=n[6],u=n[1],h=n[4],d=n[7],g=n[2],y=n[5],x=n[8],w=r[0],v=r[3],A=r[6],D=r[1],M=r[4],_=r[7],L=r[2],b=r[5],C=r[8];return s[0]=i*w+a*D+l*L,s[3]=i*v+a*M+l*b,s[6]=i*A+a*_+l*C,s[1]=u*w+h*D+d*L,s[4]=u*v+h*M+d*b,s[7]=u*A+h*_+d*C,s[2]=g*w+y*D+x*L,s[5]=g*v+y*M+x*b,s[8]=g*A+y*_+x*C,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],i=e[4],a=e[5],l=e[6],u=e[7],h=e[8];return t*i*h-t*a*u-n*s*h+n*a*l+r*s*u-r*i*l}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],i=e[4],a=e[5],l=e[6],u=e[7],h=e[8],d=h*i-a*u,g=a*l-h*s,y=u*s-i*l,x=t*d+n*g+r*y;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const w=1/x;return e[0]=d*w,e[1]=(r*u-h*n)*w,e[2]=(a*n-r*i)*w,e[3]=g*w,e[4]=(h*t-r*l)*w,e[5]=(r*s-a*t)*w,e[6]=y*w,e[7]=(n*l-u*t)*w,e[8]=(i*t-n*s)*w,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,s,i,a){const l=Math.cos(s),u=Math.sin(s);return this.set(n*l,n*u,-n*(l*i+u*a)+i+e,-r*u,r*l,-r*(-u*i+l*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(xr.makeScale(e,t)),this}rotate(e){return this.premultiply(xr.makeRotation(-e)),this}translate(e,t){return this.premultiply(xr.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const xr=new rn,ii=new rn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),oi=new rn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Cn={[_r]:{transfer:vr,primaries:ri,toReference:o=>o,fromReference:o=>o},[_t]:{transfer:ni,primaries:ri,toReference:o=>o.convertSRGBToLinear(),fromReference:o=>o.convertLinearToSRGB()},[ti]:{transfer:vr,primaries:si,toReference:o=>o.applyMatrix3(oi),fromReference:o=>o.applyMatrix3(ii)},[Cc]:{transfer:ni,primaries:si,toReference:o=>o.convertSRGBToLinear().applyMatrix3(oi),fromReference:o=>o.applyMatrix3(ii).convertLinearToSRGB()}},Tc=new Set([_r,ti]),He={enabled:!0,_workingColorSpace:_r,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(o){if(!Tc.has(o))throw new Error(`Unsupported working color space, "${o}".`);this._workingColorSpace=o},convert:function(o,e,t){if(this.enabled===!1||e===t||!e||!t)return o;const n=Cn[e].toReference,r=Cn[t].fromReference;return r(n(o))},fromWorkingColorSpace:function(o,e){return this.convert(o,this._workingColorSpace,e)},toWorkingColorSpace:function(o,e){return this.convert(o,e,this._workingColorSpace)},getPrimaries:function(o){return Cn[o].primaries},getTransfer:function(o){return o===Pc?vr:Cn[o].transfer}};function wr(o){return o<.04045?o*.0773993808:Math.pow(o*.9478672986+.0521327014,2.4)}function br(o){return o<.0031308?o*12.92:1.055*Math.pow(o,.41666)-.055}const ai={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},vt={h:0,s:0,l:0},Tn={h:0,s:0,l:0};function Mr(o,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?o+(e-o)*6*t:t<1/2?e:t<2/3?o+(e-o)*6*(2/3-t):o}class Ln{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=_t){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,He.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=He.workingColorSpace){return this.r=e,this.g=t,this.b=n,He.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=He.workingColorSpace){if(e=Sc(e,1),t=yt(t,0,1),n=yt(n,0,1),t===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+t):n+t-n*t,i=2*n-s;this.r=Mr(i,s,e+1/3),this.g=Mr(i,s,e),this.b=Mr(i,s,e-1/3)}return He.toWorkingColorSpace(this,r),this}setStyle(e,t=_t){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let s;const i=r[1],a=r[2];switch(i){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,t);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,t);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=r[1],i=s.length;if(i===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=_t){const n=ai[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=wr(e.r),this.g=wr(e.g),this.b=wr(e.b),this}copyLinearToSRGB(e){return this.r=br(e.r),this.g=br(e.g),this.b=br(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=_t){return He.fromWorkingColorSpace(ze.copy(this),e),Math.round(yt(ze.r*255,0,255))*65536+Math.round(yt(ze.g*255,0,255))*256+Math.round(yt(ze.b*255,0,255))}getHexString(e=_t){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=He.workingColorSpace){He.fromWorkingColorSpace(ze.copy(this),t);const n=ze.r,r=ze.g,s=ze.b,i=Math.max(n,r,s),a=Math.min(n,r,s);let l,u;const h=(a+i)/2;if(a===i)l=0,u=0;else{const d=i-a;switch(u=h<=.5?d/(i+a):d/(2-i-a),i){case n:l=(r-s)/d+(r<s?6:0);break;case r:l=(s-n)/d+2;break;case s:l=(n-r)/d+4;break}l/=6}return e.h=l,e.s=u,e.l=h,e}getRGB(e,t=He.workingColorSpace){return He.fromWorkingColorSpace(ze.copy(this),t),e.r=ze.r,e.g=ze.g,e.b=ze.b,e}getStyle(e=_t){He.fromWorkingColorSpace(ze.copy(this),e);const t=ze.r,n=ze.g,r=ze.b;return e!==_t?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(vt),this.setHSL(vt.h+e,vt.s+t,vt.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(vt),e.getHSL(Tn);const n=gr(vt.h,Tn.h,t),r=gr(vt.s,Tn.s,t),s=gr(vt.l,Tn.l,t);return this.setHSL(n,r,s),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,s=e.elements;return this.r=s[0]*t+s[3]*n+s[6]*r,this.g=s[1]*t+s[4]*n+s[7]*r,this.b=s[2]*t+s[5]*n+s[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const ze=new Ln;Ln.NAMES=ai;class Lc extends c.MeshStandardMaterial{constructor(t={}){super();le(this,"isMeshPhysicalMaterial");le(this,"clearcoatMap");le(this,"clearcoatRoughness");le(this,"clearcoatRoughnessMap");le(this,"clearcoatNormalScale");le(this,"clearcoatNormalMap");le(this,"ior");le(this,"transmissionMap");le(this,"thickness");le(this,"thicknessMap");le(this,"attenuationDistance");le(this,"attenuationColor");le(this,"specularIntensity");le(this,"specularIntensityMap");le(this,"specularColor");le(this,"specularColorMap");le(this,"_clearcoat");le(this,"_transmission");this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new yr(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get(){return yt(2.5*(this.ior-1)/(this.ior+1),0,1)},set(n){this.ior=(1+.4*n)/(1-.4*n)}}),this.roughness=0,this.transmissionMap=null,this.thickness=.5,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Ln(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Ln(1,1,1),this.specularColorMap=null,this._clearcoat=.5,this._transmission=1,this.setValues(t)}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.ior=t.ior,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}const Dc=Lc,Ic=f.defineComponent({__name:"index",setup(o,{expose:e}){const t=f.shallowRef(),{extend:n}=ae.useTresContext();return n({MeshGlassMaterial:Dc}),e({MeshGlassMaterialClass:t}),(r,s)=>(f.openBlock(),f.createElementBlock("TresMeshGlassMaterial",{ref_key:"MeshGlassMaterialClass",ref:t},null,512))}});var Oc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function sn(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function Dn(o){throw new Error('Could not dynamically require "'+o+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var li={exports:{}};(function(o,e){(function(t){o.exports=t()})(function(){return function t(n,r,s){function i(u,h){if(!r[u]){if(!n[u]){var d=typeof Dn=="function"&&Dn;if(!h&&d)return d(u,!0);if(a)return a(u,!0);throw new Error("Cannot find module '"+u+"'")}h=r[u]={exports:{}},n[u][0].call(h.exports,function(g){var y=n[u][1][g];return i(y||g)},h,h.exports,t,n,r,s)}return r[u].exports}for(var a=typeof Dn=="function"&&Dn,l=0;l<s.length;l++)i(s[l]);return i}({1:[function(t,n,r){(function(s,i,a,l,u,h,d,g,y){var x=t("crypto");function w(b,C){C=D(b,C);var m;return(m=C.algorithm!=="passthrough"?x.createHash(C.algorithm):new L).write===void 0&&(m.write=m.update,m.end=m.update),_(C,m).dispatch(b),m.update||m.end(""),m.digest?m.digest(C.encoding==="buffer"?void 0:C.encoding):(b=m.read(),C.encoding!=="buffer"?b.toString(C.encoding):b)}(r=n.exports=w).sha1=function(b){return w(b)},r.keys=function(b){return w(b,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},r.MD5=function(b){return w(b,{algorithm:"md5",encoding:"hex"})},r.keysMD5=function(b){return w(b,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var v=x.getHashes?x.getHashes().slice():["sha1","md5"],A=(v.push("passthrough"),["buffer","hex","binary","base64"]);function D(b,C){var m={};if(m.algorithm=(C=C||{}).algorithm||"sha1",m.encoding=C.encoding||"hex",m.excludeValues=!!C.excludeValues,m.algorithm=m.algorithm.toLowerCase(),m.encoding=m.encoding.toLowerCase(),m.ignoreUnknown=C.ignoreUnknown===!0,m.respectType=C.respectType!==!1,m.respectFunctionNames=C.respectFunctionNames!==!1,m.respectFunctionProperties=C.respectFunctionProperties!==!1,m.unorderedArrays=C.unorderedArrays===!0,m.unorderedSets=C.unorderedSets!==!1,m.unorderedObjects=C.unorderedObjects!==!1,m.replacer=C.replacer||void 0,m.excludeKeys=C.excludeKeys||void 0,b===void 0)throw new Error("Object argument required.");for(var S=0;S<v.length;++S)v[S].toLowerCase()===m.algorithm.toLowerCase()&&(m.algorithm=v[S]);if(v.indexOf(m.algorithm)===-1)throw new Error('Algorithm "'+m.algorithm+'" not supported. supported values: '+v.join(", "));if(A.indexOf(m.encoding)===-1&&m.algorithm!=="passthrough")throw new Error('Encoding "'+m.encoding+'" not supported. supported values: '+A.join(", "));return m}function M(b){if(typeof b=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(b))!=null}function _(b,C,m){m=m||[];function S(p){return C.update?C.update(p,"utf8"):C.write(p,"utf8")}return{dispatch:function(p){return this["_"+((p=b.replacer?b.replacer(p):p)===null?"null":typeof p)](p)},_object:function(p){var I,k=Object.prototype.toString.call(p),J=/\[object (.*)\]/i.exec(k);if(J=(J=J?J[1]:"unknown:["+k+"]").toLowerCase(),0<=(k=m.indexOf(p)))return this.dispatch("[CIRCULAR:"+k+"]");if(m.push(p),a!==void 0&&a.isBuffer&&a.isBuffer(p))return S("buffer:"),S(p);if(J==="object"||J==="function"||J==="asyncfunction")return k=Object.keys(p),b.unorderedObjects&&(k=k.sort()),b.respectType===!1||M(p)||k.splice(0,0,"prototype","__proto__","constructor"),b.excludeKeys&&(k=k.filter(function(R){return!b.excludeKeys(R)})),S("object:"+k.length+":"),I=this,k.forEach(function(R){I.dispatch(R),S(":"),b.excludeValues||I.dispatch(p[R]),S(",")});if(!this["_"+J]){if(b.ignoreUnknown)return S("["+J+"]");throw new Error('Unknown object type "'+J+'"')}this["_"+J](p)},_array:function(p,R){R=R!==void 0?R:b.unorderedArrays!==!1;var k=this;if(S("array:"+p.length+":"),!R||p.length<=1)return p.forEach(function(Z){return k.dispatch(Z)});var J=[],R=p.map(function(Z){var X=new L,q=m.slice();return _(b,X,q).dispatch(Z),J=J.concat(q.slice(m.length)),X.read().toString()});return m=m.concat(J),R.sort(),this._array(R,!1)},_date:function(p){return S("date:"+p.toJSON())},_symbol:function(p){return S("symbol:"+p.toString())},_error:function(p){return S("error:"+p.toString())},_boolean:function(p){return S("bool:"+p.toString())},_string:function(p){S("string:"+p.length+":"),S(p.toString())},_function:function(p){S("fn:"),M(p)?this.dispatch("[native]"):this.dispatch(p.toString()),b.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(p.name)),b.respectFunctionProperties&&this._object(p)},_number:function(p){return S("number:"+p.toString())},_xml:function(p){return S("xml:"+p.toString())},_null:function(){return S("Null")},_undefined:function(){return S("Undefined")},_regexp:function(p){return S("regex:"+p.toString())},_uint8array:function(p){return S("uint8array:"),this.dispatch(Array.prototype.slice.call(p))},_uint8clampedarray:function(p){return S("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(p))},_int8array:function(p){return S("int8array:"),this.dispatch(Array.prototype.slice.call(p))},_uint16array:function(p){return S("uint16array:"),this.dispatch(Array.prototype.slice.call(p))},_int16array:function(p){return S("int16array:"),this.dispatch(Array.prototype.slice.call(p))},_uint32array:function(p){return S("uint32array:"),this.dispatch(Array.prototype.slice.call(p))},_int32array:function(p){return S("int32array:"),this.dispatch(Array.prototype.slice.call(p))},_float32array:function(p){return S("float32array:"),this.dispatch(Array.prototype.slice.call(p))},_float64array:function(p){return S("float64array:"),this.dispatch(Array.prototype.slice.call(p))},_arraybuffer:function(p){return S("arraybuffer:"),this.dispatch(new Uint8Array(p))},_url:function(p){return S("url:"+p.toString())},_map:function(p){return S("map:"),p=Array.from(p),this._array(p,b.unorderedSets!==!1)},_set:function(p){return S("set:"),p=Array.from(p),this._array(p,b.unorderedSets!==!1)},_file:function(p){return S("file:"),this.dispatch([p.name,p.size,p.type,p.lastModfied])},_blob:function(){if(b.ignoreUnknown)return S("[blob]");throw Error(`Hashing Blob objects is currently not supported
|
|
262
262
|
(see https://github.com/puleos/object-hash/issues/26)
|
|
263
263
|
Use "options.replacer" or "options.ignoreUnknown"
|
|
264
|
-
`)},_domwindow:function(){return
|
|
265
|
-
list should be an Array.`),T.length===0)return new v(0);if(T.length===1)return T[0];if(typeof O!="number")for(q=O=0;q<T.length;q++)O+=T[q].length;for(var k=new v(O),E=0,q=0;q<T.length;q++){var W=T[q];W.copy(k,E),E+=W.length}return k},v.prototype.write=function(T,O,k,E){isFinite(O)?isFinite(k)||(E=k,k=void 0):(B=E,E=O,O=k,k=B),O=Number(O)||0;var q,W,te,U,B=this.length-O;switch((!k||B<(k=Number(k)))&&(k=B),E=String(E||"utf8").toLowerCase()){case"hex":q=function(oe,ce,ge,_e){ge=Number(ge)||0;var xe=oe.length-ge;(!_e||xe<(_e=Number(_e)))&&(_e=xe),R((xe=ce.length)%2==0,"Invalid hex string"),xe/2<_e&&(_e=xe/2);for(var Oe=0;Oe<_e;Oe++){var at=parseInt(ce.substr(2*Oe,2),16);R(!isNaN(at),"Invalid hex string"),oe[ge+Oe]=at}return v._charsWritten=2*Oe,Oe}(this,T,O,k);break;case"utf8":case"utf-8":W=this,te=O,U=k,q=v._charsWritten=z(ue(T),W,te,U);break;case"ascii":case"binary":q=P(this,T,O,k);break;case"base64":W=this,te=O,U=k,q=v._charsWritten=z(j(T),W,te,U);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":q=D(this,T,O,k);break;default:throw new Error("Unknown encoding")}return q},v.prototype.toString=function(T,O,k){var E,q,W,te,U=this;if(T=String(T||"utf8").toLowerCase(),O=Number(O)||0,(k=k!==void 0?Number(k):U.length)===O)return"";switch(T){case"hex":E=function(B,oe,ce){var ge=B.length;(!oe||oe<0)&&(oe=0),(!ce||ce<0||ge<ce)&&(ce=ge);for(var _e="",xe=oe;xe<ce;xe++)_e+=se(B[xe]);return _e}(U,O,k);break;case"utf8":case"utf-8":E=function(B,oe,ce){var ge="",_e="";ce=Math.min(B.length,ce);for(var xe=oe;xe<ce;xe++)B[xe]<=127?(ge+=A(_e)+String.fromCharCode(B[xe]),_e=""):_e+="%"+B[xe].toString(16);return ge+A(_e)}(U,O,k);break;case"ascii":case"binary":E=S(U,O,k);break;case"base64":q=U,te=k,E=(W=O)===0&&te===q.length?x.fromByteArray(q):x.fromByteArray(q.slice(W,te));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":E=function(B,oe,ce){for(var ge=B.slice(oe,ce),_e="",xe=0;xe<ge.length;xe+=2)_e+=String.fromCharCode(ge[xe]+256*ge[xe+1]);return _e}(U,O,k);break;default:throw new Error("Unknown encoding")}return E},v.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},v.prototype.copy=function(T,O,k,E){if(O=O||0,(E=E||E===0?E:this.length)!==(k=k||0)&&T.length!==0&&this.length!==0){R(k<=E,"sourceEnd < sourceStart"),R(0<=O&&O<T.length,"targetStart out of bounds"),R(0<=k&&k<this.length,"sourceStart out of bounds"),R(0<=E&&E<=this.length,"sourceEnd out of bounds"),E>this.length&&(E=this.length);var q=(E=T.length-O<E-k?T.length-O+k:E)-k;if(q<100||!v._useTypedArrays)for(var W=0;W<q;W++)T[W+O]=this[W+k];else T._set(this.subarray(k,k+q),O)}},v.prototype.slice=function(T,O){var k=this.length;if(T=Z(T,k,0),O=Z(O,k,k),v._useTypedArrays)return v._augment(this.subarray(T,O));for(var E=O-T,q=new v(E,void 0,!0),W=0;W<E;W++)q[W]=this[W+T];return q},v.prototype.get=function(T){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(T)},v.prototype.set=function(T,O){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(T,O)},v.prototype.readUInt8=function(T,O){if(O||(R(T!=null,"missing offset"),R(T<this.length,"Trying to read beyond buffer length")),!(T>=this.length))return this[T]},v.prototype.readUInt16LE=function(T,O){return _(this,T,!0,O)},v.prototype.readUInt16BE=function(T,O){return _(this,T,!1,O)},v.prototype.readUInt32LE=function(T,O){return L(this,T,!0,O)},v.prototype.readUInt32BE=function(T,O){return L(this,T,!1,O)},v.prototype.readInt8=function(T,O){if(O||(R(T!=null,"missing offset"),R(T<this.length,"Trying to read beyond buffer length")),!(T>=this.length))return 128&this[T]?-1*(255-this[T]+1):this[T]},v.prototype.readInt16LE=function(T,O){return b(this,T,!0,O)},v.prototype.readInt16BE=function(T,O){return b(this,T,!1,O)},v.prototype.readInt32LE=function(T,O){return C(this,T,!0,O)},v.prototype.readInt32BE=function(T,O){return C(this,T,!1,O)},v.prototype.readFloatLE=function(T,O){return m(this,T,!0,O)},v.prototype.readFloatBE=function(T,O){return m(this,T,!1,O)},v.prototype.readDoubleLE=function(T,O){return M(this,T,!0,O)},v.prototype.readDoubleBE=function(T,O){return M(this,T,!1,O)},v.prototype.writeUInt8=function(T,O,k){k||(R(T!=null,"missing value"),R(O!=null,"missing offset"),R(O<this.length,"trying to write beyond buffer length"),V(T,255)),O>=this.length||(this[O]=T)},v.prototype.writeUInt16LE=function(T,O,k){p(this,T,O,!0,k)},v.prototype.writeUInt16BE=function(T,O,k){p(this,T,O,!1,k)},v.prototype.writeUInt32LE=function(T,O,k){I(this,T,O,!0,k)},v.prototype.writeUInt32BE=function(T,O,k){I(this,T,O,!1,k)},v.prototype.writeInt8=function(T,O,k){k||(R(T!=null,"missing value"),R(O!=null,"missing offset"),R(O<this.length,"Trying to write beyond buffer length"),ee(T,127,-128)),O>=this.length||(0<=T?this.writeUInt8(T,O,k):this.writeUInt8(255+T+1,O,k))},v.prototype.writeInt16LE=function(T,O,k){F(this,T,O,!0,k)},v.prototype.writeInt16BE=function(T,O,k){F(this,T,O,!1,k)},v.prototype.writeInt32LE=function(T,O,k){J(this,T,O,!0,k)},v.prototype.writeInt32BE=function(T,O,k){J(this,T,O,!1,k)},v.prototype.writeFloatLE=function(T,O,k){G(this,T,O,!0,k)},v.prototype.writeFloatBE=function(T,O,k){G(this,T,O,!1,k)},v.prototype.writeDoubleLE=function(T,O,k){Q(this,T,O,!0,k)},v.prototype.writeDoubleBE=function(T,O,k){Q(this,T,O,!1,k)},v.prototype.fill=function(T,O,k){if(O=O||0,k=k||this.length,R(typeof(T=typeof(T=T||0)=="string"?T.charCodeAt(0):T)=="number"&&!isNaN(T),"value is not a number"),R(O<=k,"end < start"),k!==O&&this.length!==0){R(0<=O&&O<this.length,"start out of bounds"),R(0<=k&&k<=this.length,"end out of bounds");for(var E=O;E<k;E++)this[E]=T}},v.prototype.inspect=function(){for(var T=[],O=this.length,k=0;k<O;k++)if(T[k]=se(this[k]),k===s.INSPECT_MAX_BYTES){T[k+1]="...";break}return"<Buffer "+T.join(" ")+">"},v.prototype.toArrayBuffer=function(){if(typeof Uint8Array>"u")throw new Error("Buffer.toArrayBuffer not supported in this browser");if(v._useTypedArrays)return new v(this).buffer;for(var T=new Uint8Array(this.length),O=0,k=T.length;O<k;O+=1)T[O]=this[O];return T.buffer};var K=v.prototype;function Z(T,O,k){return typeof T!="number"?k:O<=(T=~~T)?O:0<=T||0<=(T+=O)?T:0}function X(T){return(T=~~Math.ceil(+T))<0?0:T}function ne(T){return(Array.isArray||function(O){return Object.prototype.toString.call(O)==="[object Array]"})(T)}function se(T){return T<16?"0"+T.toString(16):T.toString(16)}function ue(T){for(var O=[],k=0;k<T.length;k++){var E=T.charCodeAt(k);if(E<=127)O.push(T.charCodeAt(k));else for(var q=k,W=(55296<=E&&E<=57343&&k++,encodeURIComponent(T.slice(q,k+1)).substr(1).split("%")),te=0;te<W.length;te++)O.push(parseInt(W[te],16))}return O}function j(T){return x.toByteArray(T)}function z(T,O,k,E){for(var q=0;q<E&&!(q+k>=O.length||q>=T.length);q++)O[q+k]=T[q];return q}function A(T){try{return decodeURIComponent(T)}catch{return"�"}}function V(T,O){R(typeof T=="number","cannot write a non-number as a number"),R(0<=T,"specified a negative value for writing an unsigned value"),R(T<=O,"value is larger than maximum value for type"),R(Math.floor(T)===T,"value has a fractional component")}function ee(T,O,k){R(typeof T=="number","cannot write a non-number as a number"),R(T<=O,"value larger than maximum allowed value"),R(k<=T,"value smaller than minimum allowed value"),R(Math.floor(T)===T,"value has a fractional component")}function N(T,O,k){R(typeof T=="number","cannot write a non-number as a number"),R(T<=O,"value larger than maximum allowed value"),R(k<=T,"value smaller than minimum allowed value")}function R(T,O){if(!T)throw new Error(O||"Failed assertion")}v._augment=function(T){return T._isBuffer=!0,T._get=T.get,T._set=T.set,T.get=K.get,T.set=K.set,T.write=K.write,T.toString=K.toString,T.toLocaleString=K.toString,T.toJSON=K.toJSON,T.copy=K.copy,T.slice=K.slice,T.readUInt8=K.readUInt8,T.readUInt16LE=K.readUInt16LE,T.readUInt16BE=K.readUInt16BE,T.readUInt32LE=K.readUInt32LE,T.readUInt32BE=K.readUInt32BE,T.readInt8=K.readInt8,T.readInt16LE=K.readInt16LE,T.readInt16BE=K.readInt16BE,T.readInt32LE=K.readInt32LE,T.readInt32BE=K.readInt32BE,T.readFloatLE=K.readFloatLE,T.readFloatBE=K.readFloatBE,T.readDoubleLE=K.readDoubleLE,T.readDoubleBE=K.readDoubleBE,T.writeUInt8=K.writeUInt8,T.writeUInt16LE=K.writeUInt16LE,T.writeUInt16BE=K.writeUInt16BE,T.writeUInt32LE=K.writeUInt32LE,T.writeUInt32BE=K.writeUInt32BE,T.writeInt8=K.writeInt8,T.writeInt16LE=K.writeInt16LE,T.writeInt16BE=K.writeInt16BE,T.writeInt32LE=K.writeInt32LE,T.writeInt32BE=K.writeInt32BE,T.writeFloatLE=K.writeFloatLE,T.writeFloatBE=K.writeFloatBE,T.writeDoubleLE=K.writeDoubleLE,T.writeDoubleBE=K.writeDoubleBE,T.fill=K.fill,T.inspect=K.inspect,T.toArrayBuffer=K.toArrayBuffer,T}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/buffer/index.js","/node_modules/gulp-browserify/node_modules/buffer")},{"base64-js":2,buffer:3,ieee754:10,lYpoI2:11}],4:[function(t,n,s){(function(r,i,x,l,u,h,d,y,g){var x=t("buffer").Buffer,w=4,v=new x(w);v.fill(0),n.exports={hash:function(P,D,S,_){for(var L=D(function(p,I){p.length%w!=0&&(F=p.length+(w-p.length%w),p=x.concat([p,v],F));for(var F,J=[],G=I?p.readInt32BE:p.readInt32LE,Q=0;Q<p.length;Q+=w)J.push(G.call(p,Q));return J}(P=x.isBuffer(P)?P:new x(P),_),8*P.length),D=_,b=new x(S),C=D?b.writeInt32BE:b.writeInt32LE,m=0;m<L.length;m++)C.call(b,L[m],4*m,!0);return b}}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/helpers.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],5:[function(t,n,s){(function(r,i,x,l,u,h,d,y,g){var x=t("buffer").Buffer,w=t("./sha"),v=t("./sha256"),P=t("./rng"),D={sha1:w,sha256:v,md5:t("./md5")},S=64,_=new x(S);function L(p,I){var F=D[p=p||"sha1"],J=[];return F||b("algorithm:",p,"is not yet supported"),{update:function(G){return x.isBuffer(G)||(G=new x(G)),J.push(G),G.length,this},digest:function(G){var Q=x.concat(J),Q=I?function(K,Z,X){x.isBuffer(Z)||(Z=new x(Z)),x.isBuffer(X)||(X=new x(X)),Z.length>S?Z=K(Z):Z.length<S&&(Z=x.concat([Z,_],S));for(var ne=new x(S),se=new x(S),ue=0;ue<S;ue++)ne[ue]=54^Z[ue],se[ue]=92^Z[ue];return X=K(x.concat([ne,X])),K(x.concat([se,X]))}(F,I,Q):F(Q);return J=null,G?Q.toString(G):Q}}}function b(){var p=[].slice.call(arguments).join(" ");throw new Error([p,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join(`
|
|
266
|
-
`))}_.fill(0),s.createHash=function(p){return L(p)},s.createHmac=L,s.randomBytes=function(p,I){if(!I||!I.call)return new x(P(p));try{I.call(this,void 0,new x(P(p)))}catch(F){I(F)}};var C,m=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],M=function(p){s[p]=function(){b("sorry,",p,"is not implemented yet")}};for(C in m)M(m[C])}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/index.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./md5":6,"./rng":7,"./sha":8,"./sha256":9,buffer:3,lYpoI2:11}],6:[function(t,n,s){(function(r,i,a,l,u,h,d,y,g){var x=t("./helpers");function w(b,C){b[C>>5]|=128<<C%32,b[14+(C+64>>>9<<4)]=C;for(var m=1732584193,M=-271733879,p=-1732584194,I=271733878,F=0;F<b.length;F+=16){var J=m,G=M,Q=p,K=I,m=P(m,M,p,I,b[F+0],7,-680876936),I=P(I,m,M,p,b[F+1],12,-389564586),p=P(p,I,m,M,b[F+2],17,606105819),M=P(M,p,I,m,b[F+3],22,-1044525330);m=P(m,M,p,I,b[F+4],7,-176418897),I=P(I,m,M,p,b[F+5],12,1200080426),p=P(p,I,m,M,b[F+6],17,-1473231341),M=P(M,p,I,m,b[F+7],22,-45705983),m=P(m,M,p,I,b[F+8],7,1770035416),I=P(I,m,M,p,b[F+9],12,-1958414417),p=P(p,I,m,M,b[F+10],17,-42063),M=P(M,p,I,m,b[F+11],22,-1990404162),m=P(m,M,p,I,b[F+12],7,1804603682),I=P(I,m,M,p,b[F+13],12,-40341101),p=P(p,I,m,M,b[F+14],17,-1502002290),m=D(m,M=P(M,p,I,m,b[F+15],22,1236535329),p,I,b[F+1],5,-165796510),I=D(I,m,M,p,b[F+6],9,-1069501632),p=D(p,I,m,M,b[F+11],14,643717713),M=D(M,p,I,m,b[F+0],20,-373897302),m=D(m,M,p,I,b[F+5],5,-701558691),I=D(I,m,M,p,b[F+10],9,38016083),p=D(p,I,m,M,b[F+15],14,-660478335),M=D(M,p,I,m,b[F+4],20,-405537848),m=D(m,M,p,I,b[F+9],5,568446438),I=D(I,m,M,p,b[F+14],9,-1019803690),p=D(p,I,m,M,b[F+3],14,-187363961),M=D(M,p,I,m,b[F+8],20,1163531501),m=D(m,M,p,I,b[F+13],5,-1444681467),I=D(I,m,M,p,b[F+2],9,-51403784),p=D(p,I,m,M,b[F+7],14,1735328473),m=S(m,M=D(M,p,I,m,b[F+12],20,-1926607734),p,I,b[F+5],4,-378558),I=S(I,m,M,p,b[F+8],11,-2022574463),p=S(p,I,m,M,b[F+11],16,1839030562),M=S(M,p,I,m,b[F+14],23,-35309556),m=S(m,M,p,I,b[F+1],4,-1530992060),I=S(I,m,M,p,b[F+4],11,1272893353),p=S(p,I,m,M,b[F+7],16,-155497632),M=S(M,p,I,m,b[F+10],23,-1094730640),m=S(m,M,p,I,b[F+13],4,681279174),I=S(I,m,M,p,b[F+0],11,-358537222),p=S(p,I,m,M,b[F+3],16,-722521979),M=S(M,p,I,m,b[F+6],23,76029189),m=S(m,M,p,I,b[F+9],4,-640364487),I=S(I,m,M,p,b[F+12],11,-421815835),p=S(p,I,m,M,b[F+15],16,530742520),m=_(m,M=S(M,p,I,m,b[F+2],23,-995338651),p,I,b[F+0],6,-198630844),I=_(I,m,M,p,b[F+7],10,1126891415),p=_(p,I,m,M,b[F+14],15,-1416354905),M=_(M,p,I,m,b[F+5],21,-57434055),m=_(m,M,p,I,b[F+12],6,1700485571),I=_(I,m,M,p,b[F+3],10,-1894986606),p=_(p,I,m,M,b[F+10],15,-1051523),M=_(M,p,I,m,b[F+1],21,-2054922799),m=_(m,M,p,I,b[F+8],6,1873313359),I=_(I,m,M,p,b[F+15],10,-30611744),p=_(p,I,m,M,b[F+6],15,-1560198380),M=_(M,p,I,m,b[F+13],21,1309151649),m=_(m,M,p,I,b[F+4],6,-145523070),I=_(I,m,M,p,b[F+11],10,-1120210379),p=_(p,I,m,M,b[F+2],15,718787259),M=_(M,p,I,m,b[F+9],21,-343485551),m=L(m,J),M=L(M,G),p=L(p,Q),I=L(I,K)}return Array(m,M,p,I)}function v(b,C,m,M,p,I){return L((C=L(L(C,b),L(M,I)))<<p|C>>>32-p,m)}function P(b,C,m,M,p,I,F){return v(C&m|~C&M,b,C,p,I,F)}function D(b,C,m,M,p,I,F){return v(C&M|m&~M,b,C,p,I,F)}function S(b,C,m,M,p,I,F){return v(C^m^M,b,C,p,I,F)}function _(b,C,m,M,p,I,F){return v(m^(C|~M),b,C,p,I,F)}function L(b,C){var m=(65535&b)+(65535&C);return(b>>16)+(C>>16)+(m>>16)<<16|65535&m}n.exports=function(b){return x.hash(b,w,16)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],7:[function(t,n,s){(function(r,i,a,l,u,h,d,y,g){n.exports=function(x){for(var w,v=new Array(x),P=0;P<x;P++)!(3&P)&&(w=4294967296*Math.random()),v[P]=w>>>((3&P)<<3)&255;return v}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],8:[function(t,n,s){(function(r,i,a,l,u,h,d,y,g){var x=t("./helpers");function w(D,S){D[S>>5]|=128<<24-S%32,D[15+(S+64>>9<<4)]=S;for(var _,L,b,C=Array(80),m=1732584193,M=-271733879,p=-1732584194,I=271733878,F=-1009589776,J=0;J<D.length;J+=16){for(var G=m,Q=M,K=p,Z=I,X=F,ne=0;ne<80;ne++){C[ne]=ne<16?D[J+ne]:P(C[ne-3]^C[ne-8]^C[ne-14]^C[ne-16],1);var se=v(v(P(m,5),(se=M,L=p,b=I,(_=ne)<20?se&L|~se&b:!(_<40)&&_<60?se&L|se&b|L&b:se^L^b)),v(v(F,C[ne]),(_=ne)<20?1518500249:_<40?1859775393:_<60?-1894007588:-899497514)),F=I,I=p,p=P(M,30),M=m,m=se}m=v(m,G),M=v(M,Q),p=v(p,K),I=v(I,Z),F=v(F,X)}return Array(m,M,p,I,F)}function v(D,S){var _=(65535&D)+(65535&S);return(D>>16)+(S>>16)+(_>>16)<<16|65535&_}function P(D,S){return D<<S|D>>>32-S}n.exports=function(D){return x.hash(D,w,20,!0)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],9:[function(t,n,s){(function(r,i,a,l,u,h,d,y,g){function x(S,_){var L=(65535&S)+(65535&_);return(S>>16)+(_>>16)+(L>>16)<<16|65535&L}function w(S,_){var L,b=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),C=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),m=new Array(64);S[_>>5]|=128<<24-_%32,S[15+(_+64>>9<<4)]=_;for(var M,p,I=0;I<S.length;I+=16){for(var F=C[0],J=C[1],G=C[2],Q=C[3],K=C[4],Z=C[5],X=C[6],ne=C[7],se=0;se<64;se++)m[se]=se<16?S[se+I]:x(x(x((p=m[se-2],P(p,17)^P(p,19)^D(p,10)),m[se-7]),(p=m[se-15],P(p,7)^P(p,18)^D(p,3))),m[se-16]),L=x(x(x(x(ne,P(p=K,6)^P(p,11)^P(p,25)),K&Z^~K&X),b[se]),m[se]),M=x(P(M=F,2)^P(M,13)^P(M,22),F&J^F&G^J&G),ne=X,X=Z,Z=K,K=x(Q,L),Q=G,G=J,J=F,F=x(L,M);C[0]=x(F,C[0]),C[1]=x(J,C[1]),C[2]=x(G,C[2]),C[3]=x(Q,C[3]),C[4]=x(K,C[4]),C[5]=x(Z,C[5]),C[6]=x(X,C[6]),C[7]=x(ne,C[7])}return C}var v=t("./helpers"),P=function(S,_){return S>>>_|S<<32-_},D=function(S,_){return S>>>_};n.exports=function(S){return v.hash(S,w,32,!0)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],10:[function(t,n,s){(function(r,i,a,l,u,h,d,y,g){s.read=function(x,w,v,P,I){var S,_,L=8*I-P-1,b=(1<<L)-1,C=b>>1,m=-7,M=v?I-1:0,p=v?-1:1,I=x[w+M];for(M+=p,S=I&(1<<-m)-1,I>>=-m,m+=L;0<m;S=256*S+x[w+M],M+=p,m-=8);for(_=S&(1<<-m)-1,S>>=-m,m+=P;0<m;_=256*_+x[w+M],M+=p,m-=8);if(S===0)S=1-C;else{if(S===b)return _?NaN:1/0*(I?-1:1);_+=Math.pow(2,P),S-=C}return(I?-1:1)*_*Math.pow(2,S-P)},s.write=function(x,w,v,P,D,F){var _,L,b=8*F-D-1,C=(1<<b)-1,m=C>>1,M=D===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=P?0:F-1,I=P?1:-1,F=w<0||w===0&&1/w<0?1:0;for(w=Math.abs(w),isNaN(w)||w===1/0?(L=isNaN(w)?1:0,_=C):(_=Math.floor(Math.log(w)/Math.LN2),w*(P=Math.pow(2,-_))<1&&(_--,P*=2),2<=(w+=1<=_+m?M/P:M*Math.pow(2,1-m))*P&&(_++,P/=2),C<=_+m?(L=0,_=C):1<=_+m?(L=(w*P-1)*Math.pow(2,D),_+=m):(L=w*Math.pow(2,m-1)*Math.pow(2,D),_=0));8<=D;x[v+p]=255&L,p+=I,L/=256,D-=8);for(_=_<<D|L,b+=D;0<b;x[v+p]=255&_,p+=I,_/=256,b-=8);x[v+p-I]|=128*F}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/ieee754/index.js","/node_modules/gulp-browserify/node_modules/ieee754")},{buffer:3,lYpoI2:11}],11:[function(t,n,s){(function(r,i,a,l,u,h,d,y,g){var x,w,v;function P(){}(r=n.exports={}).nextTick=(w=typeof window<"u"&&window.setImmediate,v=typeof window<"u"&&window.postMessage&&window.addEventListener,w?function(D){return window.setImmediate(D)}:v?(x=[],window.addEventListener("message",function(D){var S=D.source;S!==window&&S!==null||D.data!=="process-tick"||(D.stopPropagation(),0<x.length&&x.shift()())},!0),function(D){x.push(D),window.postMessage("process-tick","*")}):function(D){setTimeout(D,0)}),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=P,r.addListener=P,r.once=P,r.off=P,r.removeListener=P,r.removeAllListeners=P,r.emit=P,r.binding=function(D){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(D){throw new Error("process.chdir is not supported")}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/process/browser.js","/node_modules/gulp-browserify/node_modules/process")},{buffer:3,lYpoI2:11}]},{},[1])(1)})})(oi);var Ic=oi.exports;const Dc=nn(Ic);var ai=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","uint","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"],Oc=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"],li=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT"],Fc=ai,kc=Fc.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray"]),bs=li;bs=bs.slice().filter(function(o){return!/^(gl\_|texture)/.test(o)});var Bc=bs.concat(["gl_VertexID","gl_InstanceID","gl_Position","gl_PointSize","gl_FragCoord","gl_FrontFacing","gl_FragDepth","gl_PointCoord","gl_MaxVertexAttribs","gl_MaxVertexUniformVectors","gl_MaxVertexOutputVectors","gl_MaxFragmentInputVectors","gl_MaxVertexTextureImageUnits","gl_MaxCombinedTextureImageUnits","gl_MaxTextureImageUnits","gl_MaxFragmentUniformVectors","gl_MaxDrawBuffers","gl_MinProgramTexelOffset","gl_MaxProgramTexelOffset","gl_DepthRangeParameters","gl_DepthRange","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"]),Uc=Wc,Nc=ai,ci=Oc,zc=li,Vc=kc,Rc=Bc,He=999,ui=9999,Ms=0,Ss=1,hi=2,fi=3,di=4,sn=5,Gc=6,jc=7,Ec=8,pi=9,Yc=10,mi=11,Xc=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"];function Wc(o){var e=0,t=0,n=He,s,r,i=[],a=[],l=1,u=0,h=0,d=!1,y=!1,g="",x;o=o||{};var w=zc,v=Nc;o.version==="300 es"&&(w=Rc,v=Vc);for(var P={},D={},e=0;e<w.length;e++)P[w[e]]=!0;for(var e=0;e<v.length;e++)D[v[e]]=!0;return function(Z){return a=[],Z!==null?_(Z):L()};function S(Z){Z.length&&a.push({type:Xc[n],data:Z,position:h,line:l,column:u})}function _(Z){e=0,Z.toString&&(Z=Z.toString()),g+=Z.replace(/\r\n/g,`
|
|
267
|
-
`),x=
|
|
268
|
-
`:u=0,++l;break;default:++u;break}}return t+=e,
|
|
269
|
-
`)&&
|
|
264
|
+
`)},_domwindow:function(){return S("domwindow")},_bigint:function(p){return S("bigint:"+p.toString())},_process:function(){return S("process")},_timer:function(){return S("timer")},_pipe:function(){return S("pipe")},_tcp:function(){return S("tcp")},_udp:function(){return S("udp")},_tty:function(){return S("tty")},_statwatcher:function(){return S("statwatcher")},_securecontext:function(){return S("securecontext")},_connection:function(){return S("connection")},_zlib:function(){return S("zlib")},_context:function(){return S("context")},_nodescript:function(){return S("nodescript")},_httpparser:function(){return S("httpparser")},_dataview:function(){return S("dataview")},_signal:function(){return S("signal")},_fsevent:function(){return S("fsevent")},_tlswrap:function(){return S("tlswrap")}}}function L(){return{buf:"",write:function(b){this.buf+=b},end:function(b){this.buf+=b},read:function(){return this.buf}}}r.writeToStream=function(b,C,m){return m===void 0&&(m=C,C={}),_(C=D(b,C),m).dispatch(b)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_9a5aa49d.js","/")},{buffer:3,crypto:5,lYpoI2:11}],2:[function(t,n,r){(function(s,i,a,l,u,h,d,g,y){(function(x){var w=typeof Uint8Array<"u"?Uint8Array:Array,v=43,A=47,D=48,M=97,_=65,L=45,b=95;function C(m){return m=m.charCodeAt(0),m===v||m===L?62:m===A||m===b?63:m<D?-1:m<D+10?m-D+26+26:m<_+26?m-_:m<M+26?m-M+26:void 0}x.toByteArray=function(m){var S,p;if(0<m.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var I=m.length,I=m.charAt(I-2)==="="?2:m.charAt(I-1)==="="?1:0,k=new w(3*m.length/4-I),J=0<I?m.length-4:m.length,R=0;function Z(X){k[R++]=X}for(S=0;S<J;S+=4,0)Z((16711680&(p=C(m.charAt(S))<<18|C(m.charAt(S+1))<<12|C(m.charAt(S+2))<<6|C(m.charAt(S+3))))>>16),Z((65280&p)>>8),Z(255&p);return I==2?Z(255&(p=C(m.charAt(S))<<2|C(m.charAt(S+1))>>4)):I==1&&(Z((p=C(m.charAt(S))<<10|C(m.charAt(S+1))<<4|C(m.charAt(S+2))>>2)>>8&255),Z(255&p)),k},x.fromByteArray=function(m){var S,p,I,k,J=m.length%3,R="";function Z(X){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(X)}for(S=0,I=m.length-J;S<I;S+=3)p=(m[S]<<16)+(m[S+1]<<8)+m[S+2],R+=Z((k=p)>>18&63)+Z(k>>12&63)+Z(k>>6&63)+Z(63&k);switch(J){case 1:R=(R+=Z((p=m[m.length-1])>>2))+Z(p<<4&63)+"==";break;case 2:R=(R=(R+=Z((p=(m[m.length-2]<<8)+m[m.length-1])>>10))+Z(p>>4&63))+Z(p<<2&63)+"="}return R}})(r===void 0?this.base64js={}:r)}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:11}],3:[function(t,n,r){(function(s,i,v,l,u,h,d,g,y){var x=t("base64-js"),w=t("ieee754");function v(T,O,B){if(!(this instanceof v))return new v(T,O,B);var E,Q,K,ne,U=typeof T;if(O==="base64"&&U=="string")for(T=(ne=T).trim?ne.trim():ne.replace(/^\s+|\s+$/g,"");T.length%4!=0;)T+="=";if(U=="number")E=Y(T);else if(U=="string")E=v.byteLength(T,O);else{if(U!="object")throw new Error("First argument needs to be a number, array or string.");E=Y(T.length)}if(v._useTypedArrays?Q=v._augment(new Uint8Array(E)):((Q=this).length=E,Q._isBuffer=!0),v._useTypedArrays&&typeof T.byteLength=="number")Q._set(T);else if(te(ne=T)||v.isBuffer(ne)||ne&&typeof ne=="object"&&typeof ne.length=="number")for(K=0;K<E;K++)v.isBuffer(T)?Q[K]=T.readUInt8(K):Q[K]=T[K];else if(U=="string")Q.write(T,0,O);else if(U=="number"&&!v._useTypedArrays&&!B)for(K=0;K<E;K++)Q[K]=0;return Q}function A(T,O,B,E){return v._charsWritten=z(function(Q){for(var K=[],ne=0;ne<Q.length;ne++)K.push(255&Q.charCodeAt(ne));return K}(O),T,B,E)}function D(T,O,B,E){return v._charsWritten=z(function(Q){for(var K,ne,U=[],F=0;F<Q.length;F++)ne=Q.charCodeAt(F),K=ne>>8,ne=ne%256,U.push(ne),U.push(K);return U}(O),T,B,E)}function M(T,O,B){var E="";B=Math.min(T.length,B);for(var Q=O;Q<B;Q++)E+=String.fromCharCode(T[Q]);return E}function _(T,O,B,K){K||(G(typeof B=="boolean","missing or invalid endian"),G(O!=null,"missing offset"),G(O+1<T.length,"Trying to read beyond buffer length"));var Q,K=T.length;if(!(K<=O))return B?(Q=T[O],O+1<K&&(Q|=T[O+1]<<8)):(Q=T[O]<<8,O+1<K&&(Q|=T[O+1])),Q}function L(T,O,B,K){K||(G(typeof B=="boolean","missing or invalid endian"),G(O!=null,"missing offset"),G(O+3<T.length,"Trying to read beyond buffer length"));var Q,K=T.length;if(!(K<=O))return B?(O+2<K&&(Q=T[O+2]<<16),O+1<K&&(Q|=T[O+1]<<8),Q|=T[O],O+3<K&&(Q+=T[O+3]<<24>>>0)):(O+1<K&&(Q=T[O+1]<<16),O+2<K&&(Q|=T[O+2]<<8),O+3<K&&(Q|=T[O+3]),Q+=T[O]<<24>>>0),Q}function b(T,O,B,E){if(E||(G(typeof B=="boolean","missing or invalid endian"),G(O!=null,"missing offset"),G(O+1<T.length,"Trying to read beyond buffer length")),!(T.length<=O))return E=_(T,O,B,!0),32768&E?-1*(65535-E+1):E}function C(T,O,B,E){if(E||(G(typeof B=="boolean","missing or invalid endian"),G(O!=null,"missing offset"),G(O+3<T.length,"Trying to read beyond buffer length")),!(T.length<=O))return E=L(T,O,B,!0),2147483648&E?-1*(4294967295-E+1):E}function m(T,O,B,E){return E||(G(typeof B=="boolean","missing or invalid endian"),G(O+3<T.length,"Trying to read beyond buffer length")),w.read(T,O,B,23,4)}function S(T,O,B,E){return E||(G(typeof B=="boolean","missing or invalid endian"),G(O+7<T.length,"Trying to read beyond buffer length")),w.read(T,O,B,52,8)}function p(T,O,B,E,Q){if(Q||(G(O!=null,"missing value"),G(typeof E=="boolean","missing or invalid endian"),G(B!=null,"missing offset"),G(B+1<T.length,"trying to write beyond buffer length"),V(O,65535)),Q=T.length,!(Q<=B))for(var K=0,ne=Math.min(Q-B,2);K<ne;K++)T[B+K]=(O&255<<8*(E?K:1-K))>>>8*(E?K:1-K)}function I(T,O,B,E,Q){if(Q||(G(O!=null,"missing value"),G(typeof E=="boolean","missing or invalid endian"),G(B!=null,"missing offset"),G(B+3<T.length,"trying to write beyond buffer length"),V(O,4294967295)),Q=T.length,!(Q<=B))for(var K=0,ne=Math.min(Q-B,4);K<ne;K++)T[B+K]=O>>>8*(E?K:3-K)&255}function k(T,O,B,E,Q){Q||(G(O!=null,"missing value"),G(typeof E=="boolean","missing or invalid endian"),G(B!=null,"missing offset"),G(B+1<T.length,"Trying to write beyond buffer length"),ee(O,32767,-32768)),T.length<=B||p(T,0<=O?O:65535+O+1,B,E,Q)}function J(T,O,B,E,Q){Q||(G(O!=null,"missing value"),G(typeof E=="boolean","missing or invalid endian"),G(B!=null,"missing offset"),G(B+3<T.length,"Trying to write beyond buffer length"),ee(O,2147483647,-2147483648)),T.length<=B||I(T,0<=O?O:4294967295+O+1,B,E,Q)}function R(T,O,B,E,Q){Q||(G(O!=null,"missing value"),G(typeof E=="boolean","missing or invalid endian"),G(B!=null,"missing offset"),G(B+3<T.length,"Trying to write beyond buffer length"),N(O,34028234663852886e22,-34028234663852886e22)),T.length<=B||w.write(T,O,B,E,23,4)}function Z(T,O,B,E,Q){Q||(G(O!=null,"missing value"),G(typeof E=="boolean","missing or invalid endian"),G(B!=null,"missing offset"),G(B+7<T.length,"Trying to write beyond buffer length"),N(O,17976931348623157e292,-17976931348623157e292)),T.length<=B||w.write(T,O,B,E,52,8)}r.Buffer=v,r.SlowBuffer=v,r.INSPECT_MAX_BYTES=50,v.poolSize=8192,v._useTypedArrays=function(){try{var T=new ArrayBuffer(0),O=new Uint8Array(T);return O.foo=function(){return 42},O.foo()===42&&typeof O.subarray=="function"}catch{return!1}}(),v.isEncoding=function(T){switch(String(T).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},v.isBuffer=function(T){return!(T==null||!T._isBuffer)},v.byteLength=function(T,O){var B;switch(T+="",O||"utf8"){case"hex":B=T.length/2;break;case"utf8":case"utf-8":B=ce(T).length;break;case"ascii":case"binary":case"raw":B=T.length;break;case"base64":B=j(T).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":B=2*T.length;break;default:throw new Error("Unknown encoding")}return B},v.concat=function(T,O){if(G(te(T),`Usage: Buffer.concat(list, [totalLength])
|
|
265
|
+
list should be an Array.`),T.length===0)return new v(0);if(T.length===1)return T[0];if(typeof O!="number")for(Q=O=0;Q<T.length;Q++)O+=T[Q].length;for(var B=new v(O),E=0,Q=0;Q<T.length;Q++){var K=T[Q];K.copy(B,E),E+=K.length}return B},v.prototype.write=function(T,O,B,E){isFinite(O)?isFinite(B)||(E=B,B=void 0):(F=E,E=O,O=B,B=F),O=Number(O)||0;var Q,K,ne,U,F=this.length-O;switch((!B||F<(B=Number(B)))&&(B=F),E=String(E||"utf8").toLowerCase()){case"hex":Q=function(oe,ue,ge,_e){ge=Number(ge)||0;var xe=oe.length-ge;(!_e||xe<(_e=Number(_e)))&&(_e=xe),G((xe=ue.length)%2==0,"Invalid hex string"),xe/2<_e&&(_e=xe/2);for(var Oe=0;Oe<_e;Oe++){var lt=parseInt(ue.substr(2*Oe,2),16);G(!isNaN(lt),"Invalid hex string"),oe[ge+Oe]=lt}return v._charsWritten=2*Oe,Oe}(this,T,O,B);break;case"utf8":case"utf-8":K=this,ne=O,U=B,Q=v._charsWritten=z(ce(T),K,ne,U);break;case"ascii":case"binary":Q=A(this,T,O,B);break;case"base64":K=this,ne=O,U=B,Q=v._charsWritten=z(j(T),K,ne,U);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":Q=D(this,T,O,B);break;default:throw new Error("Unknown encoding")}return Q},v.prototype.toString=function(T,O,B){var E,Q,K,ne,U=this;if(T=String(T||"utf8").toLowerCase(),O=Number(O)||0,(B=B!==void 0?Number(B):U.length)===O)return"";switch(T){case"hex":E=function(F,oe,ue){var ge=F.length;(!oe||oe<0)&&(oe=0),(!ue||ue<0||ge<ue)&&(ue=ge);for(var _e="",xe=oe;xe<ue;xe++)_e+=re(F[xe]);return _e}(U,O,B);break;case"utf8":case"utf-8":E=function(F,oe,ue){var ge="",_e="";ue=Math.min(F.length,ue);for(var xe=oe;xe<ue;xe++)F[xe]<=127?(ge+=P(_e)+String.fromCharCode(F[xe]),_e=""):_e+="%"+F[xe].toString(16);return ge+P(_e)}(U,O,B);break;case"ascii":case"binary":E=M(U,O,B);break;case"base64":Q=U,ne=B,E=(K=O)===0&&ne===Q.length?x.fromByteArray(Q):x.fromByteArray(Q.slice(K,ne));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":E=function(F,oe,ue){for(var ge=F.slice(oe,ue),_e="",xe=0;xe<ge.length;xe+=2)_e+=String.fromCharCode(ge[xe]+256*ge[xe+1]);return _e}(U,O,B);break;default:throw new Error("Unknown encoding")}return E},v.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},v.prototype.copy=function(T,O,B,E){if(O=O||0,(E=E||E===0?E:this.length)!==(B=B||0)&&T.length!==0&&this.length!==0){G(B<=E,"sourceEnd < sourceStart"),G(0<=O&&O<T.length,"targetStart out of bounds"),G(0<=B&&B<this.length,"sourceStart out of bounds"),G(0<=E&&E<=this.length,"sourceEnd out of bounds"),E>this.length&&(E=this.length);var Q=(E=T.length-O<E-B?T.length-O+B:E)-B;if(Q<100||!v._useTypedArrays)for(var K=0;K<Q;K++)T[K+O]=this[K+B];else T._set(this.subarray(B,B+Q),O)}},v.prototype.slice=function(T,O){var B=this.length;if(T=q(T,B,0),O=q(O,B,B),v._useTypedArrays)return v._augment(this.subarray(T,O));for(var E=O-T,Q=new v(E,void 0,!0),K=0;K<E;K++)Q[K]=this[K+T];return Q},v.prototype.get=function(T){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(T)},v.prototype.set=function(T,O){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(T,O)},v.prototype.readUInt8=function(T,O){if(O||(G(T!=null,"missing offset"),G(T<this.length,"Trying to read beyond buffer length")),!(T>=this.length))return this[T]},v.prototype.readUInt16LE=function(T,O){return _(this,T,!0,O)},v.prototype.readUInt16BE=function(T,O){return _(this,T,!1,O)},v.prototype.readUInt32LE=function(T,O){return L(this,T,!0,O)},v.prototype.readUInt32BE=function(T,O){return L(this,T,!1,O)},v.prototype.readInt8=function(T,O){if(O||(G(T!=null,"missing offset"),G(T<this.length,"Trying to read beyond buffer length")),!(T>=this.length))return 128&this[T]?-1*(255-this[T]+1):this[T]},v.prototype.readInt16LE=function(T,O){return b(this,T,!0,O)},v.prototype.readInt16BE=function(T,O){return b(this,T,!1,O)},v.prototype.readInt32LE=function(T,O){return C(this,T,!0,O)},v.prototype.readInt32BE=function(T,O){return C(this,T,!1,O)},v.prototype.readFloatLE=function(T,O){return m(this,T,!0,O)},v.prototype.readFloatBE=function(T,O){return m(this,T,!1,O)},v.prototype.readDoubleLE=function(T,O){return S(this,T,!0,O)},v.prototype.readDoubleBE=function(T,O){return S(this,T,!1,O)},v.prototype.writeUInt8=function(T,O,B){B||(G(T!=null,"missing value"),G(O!=null,"missing offset"),G(O<this.length,"trying to write beyond buffer length"),V(T,255)),O>=this.length||(this[O]=T)},v.prototype.writeUInt16LE=function(T,O,B){p(this,T,O,!0,B)},v.prototype.writeUInt16BE=function(T,O,B){p(this,T,O,!1,B)},v.prototype.writeUInt32LE=function(T,O,B){I(this,T,O,!0,B)},v.prototype.writeUInt32BE=function(T,O,B){I(this,T,O,!1,B)},v.prototype.writeInt8=function(T,O,B){B||(G(T!=null,"missing value"),G(O!=null,"missing offset"),G(O<this.length,"Trying to write beyond buffer length"),ee(T,127,-128)),O>=this.length||(0<=T?this.writeUInt8(T,O,B):this.writeUInt8(255+T+1,O,B))},v.prototype.writeInt16LE=function(T,O,B){k(this,T,O,!0,B)},v.prototype.writeInt16BE=function(T,O,B){k(this,T,O,!1,B)},v.prototype.writeInt32LE=function(T,O,B){J(this,T,O,!0,B)},v.prototype.writeInt32BE=function(T,O,B){J(this,T,O,!1,B)},v.prototype.writeFloatLE=function(T,O,B){R(this,T,O,!0,B)},v.prototype.writeFloatBE=function(T,O,B){R(this,T,O,!1,B)},v.prototype.writeDoubleLE=function(T,O,B){Z(this,T,O,!0,B)},v.prototype.writeDoubleBE=function(T,O,B){Z(this,T,O,!1,B)},v.prototype.fill=function(T,O,B){if(O=O||0,B=B||this.length,G(typeof(T=typeof(T=T||0)=="string"?T.charCodeAt(0):T)=="number"&&!isNaN(T),"value is not a number"),G(O<=B,"end < start"),B!==O&&this.length!==0){G(0<=O&&O<this.length,"start out of bounds"),G(0<=B&&B<=this.length,"end out of bounds");for(var E=O;E<B;E++)this[E]=T}},v.prototype.inspect=function(){for(var T=[],O=this.length,B=0;B<O;B++)if(T[B]=re(this[B]),B===r.INSPECT_MAX_BYTES){T[B+1]="...";break}return"<Buffer "+T.join(" ")+">"},v.prototype.toArrayBuffer=function(){if(typeof Uint8Array>"u")throw new Error("Buffer.toArrayBuffer not supported in this browser");if(v._useTypedArrays)return new v(this).buffer;for(var T=new Uint8Array(this.length),O=0,B=T.length;O<B;O+=1)T[O]=this[O];return T.buffer};var X=v.prototype;function q(T,O,B){return typeof T!="number"?B:O<=(T=~~T)?O:0<=T||0<=(T+=O)?T:0}function Y(T){return(T=~~Math.ceil(+T))<0?0:T}function te(T){return(Array.isArray||function(O){return Object.prototype.toString.call(O)==="[object Array]"})(T)}function re(T){return T<16?"0"+T.toString(16):T.toString(16)}function ce(T){for(var O=[],B=0;B<T.length;B++){var E=T.charCodeAt(B);if(E<=127)O.push(T.charCodeAt(B));else for(var Q=B,K=(55296<=E&&E<=57343&&B++,encodeURIComponent(T.slice(Q,B+1)).substr(1).split("%")),ne=0;ne<K.length;ne++)O.push(parseInt(K[ne],16))}return O}function j(T){return x.toByteArray(T)}function z(T,O,B,E){for(var Q=0;Q<E&&!(Q+B>=O.length||Q>=T.length);Q++)O[Q+B]=T[Q];return Q}function P(T){try{return decodeURIComponent(T)}catch{return"�"}}function V(T,O){G(typeof T=="number","cannot write a non-number as a number"),G(0<=T,"specified a negative value for writing an unsigned value"),G(T<=O,"value is larger than maximum value for type"),G(Math.floor(T)===T,"value has a fractional component")}function ee(T,O,B){G(typeof T=="number","cannot write a non-number as a number"),G(T<=O,"value larger than maximum allowed value"),G(B<=T,"value smaller than minimum allowed value"),G(Math.floor(T)===T,"value has a fractional component")}function N(T,O,B){G(typeof T=="number","cannot write a non-number as a number"),G(T<=O,"value larger than maximum allowed value"),G(B<=T,"value smaller than minimum allowed value")}function G(T,O){if(!T)throw new Error(O||"Failed assertion")}v._augment=function(T){return T._isBuffer=!0,T._get=T.get,T._set=T.set,T.get=X.get,T.set=X.set,T.write=X.write,T.toString=X.toString,T.toLocaleString=X.toString,T.toJSON=X.toJSON,T.copy=X.copy,T.slice=X.slice,T.readUInt8=X.readUInt8,T.readUInt16LE=X.readUInt16LE,T.readUInt16BE=X.readUInt16BE,T.readUInt32LE=X.readUInt32LE,T.readUInt32BE=X.readUInt32BE,T.readInt8=X.readInt8,T.readInt16LE=X.readInt16LE,T.readInt16BE=X.readInt16BE,T.readInt32LE=X.readInt32LE,T.readInt32BE=X.readInt32BE,T.readFloatLE=X.readFloatLE,T.readFloatBE=X.readFloatBE,T.readDoubleLE=X.readDoubleLE,T.readDoubleBE=X.readDoubleBE,T.writeUInt8=X.writeUInt8,T.writeUInt16LE=X.writeUInt16LE,T.writeUInt16BE=X.writeUInt16BE,T.writeUInt32LE=X.writeUInt32LE,T.writeUInt32BE=X.writeUInt32BE,T.writeInt8=X.writeInt8,T.writeInt16LE=X.writeInt16LE,T.writeInt16BE=X.writeInt16BE,T.writeInt32LE=X.writeInt32LE,T.writeInt32BE=X.writeInt32BE,T.writeFloatLE=X.writeFloatLE,T.writeFloatBE=X.writeFloatBE,T.writeDoubleLE=X.writeDoubleLE,T.writeDoubleBE=X.writeDoubleBE,T.fill=X.fill,T.inspect=X.inspect,T.toArrayBuffer=X.toArrayBuffer,T}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/buffer/index.js","/node_modules/gulp-browserify/node_modules/buffer")},{"base64-js":2,buffer:3,ieee754:10,lYpoI2:11}],4:[function(t,n,r){(function(s,i,x,l,u,h,d,g,y){var x=t("buffer").Buffer,w=4,v=new x(w);v.fill(0),n.exports={hash:function(A,D,M,_){for(var L=D(function(p,I){p.length%w!=0&&(k=p.length+(w-p.length%w),p=x.concat([p,v],k));for(var k,J=[],R=I?p.readInt32BE:p.readInt32LE,Z=0;Z<p.length;Z+=w)J.push(R.call(p,Z));return J}(A=x.isBuffer(A)?A:new x(A),_),8*A.length),D=_,b=new x(M),C=D?b.writeInt32BE:b.writeInt32LE,m=0;m<L.length;m++)C.call(b,L[m],4*m,!0);return b}}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/helpers.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],5:[function(t,n,r){(function(s,i,x,l,u,h,d,g,y){var x=t("buffer").Buffer,w=t("./sha"),v=t("./sha256"),A=t("./rng"),D={sha1:w,sha256:v,md5:t("./md5")},M=64,_=new x(M);function L(p,I){var k=D[p=p||"sha1"],J=[];return k||b("algorithm:",p,"is not yet supported"),{update:function(R){return x.isBuffer(R)||(R=new x(R)),J.push(R),R.length,this},digest:function(R){var Z=x.concat(J),Z=I?function(X,q,Y){x.isBuffer(q)||(q=new x(q)),x.isBuffer(Y)||(Y=new x(Y)),q.length>M?q=X(q):q.length<M&&(q=x.concat([q,_],M));for(var te=new x(M),re=new x(M),ce=0;ce<M;ce++)te[ce]=54^q[ce],re[ce]=92^q[ce];return Y=X(x.concat([te,Y])),X(x.concat([re,Y]))}(k,I,Z):k(Z);return J=null,R?Z.toString(R):Z}}}function b(){var p=[].slice.call(arguments).join(" ");throw new Error([p,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join(`
|
|
266
|
+
`))}_.fill(0),r.createHash=function(p){return L(p)},r.createHmac=L,r.randomBytes=function(p,I){if(!I||!I.call)return new x(A(p));try{I.call(this,void 0,new x(A(p)))}catch(k){I(k)}};var C,m=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],S=function(p){r[p]=function(){b("sorry,",p,"is not implemented yet")}};for(C in m)S(m[C])}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/index.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./md5":6,"./rng":7,"./sha":8,"./sha256":9,buffer:3,lYpoI2:11}],6:[function(t,n,r){(function(s,i,a,l,u,h,d,g,y){var x=t("./helpers");function w(b,C){b[C>>5]|=128<<C%32,b[14+(C+64>>>9<<4)]=C;for(var m=1732584193,S=-271733879,p=-1732584194,I=271733878,k=0;k<b.length;k+=16){var J=m,R=S,Z=p,X=I,m=A(m,S,p,I,b[k+0],7,-680876936),I=A(I,m,S,p,b[k+1],12,-389564586),p=A(p,I,m,S,b[k+2],17,606105819),S=A(S,p,I,m,b[k+3],22,-1044525330);m=A(m,S,p,I,b[k+4],7,-176418897),I=A(I,m,S,p,b[k+5],12,1200080426),p=A(p,I,m,S,b[k+6],17,-1473231341),S=A(S,p,I,m,b[k+7],22,-45705983),m=A(m,S,p,I,b[k+8],7,1770035416),I=A(I,m,S,p,b[k+9],12,-1958414417),p=A(p,I,m,S,b[k+10],17,-42063),S=A(S,p,I,m,b[k+11],22,-1990404162),m=A(m,S,p,I,b[k+12],7,1804603682),I=A(I,m,S,p,b[k+13],12,-40341101),p=A(p,I,m,S,b[k+14],17,-1502002290),m=D(m,S=A(S,p,I,m,b[k+15],22,1236535329),p,I,b[k+1],5,-165796510),I=D(I,m,S,p,b[k+6],9,-1069501632),p=D(p,I,m,S,b[k+11],14,643717713),S=D(S,p,I,m,b[k+0],20,-373897302),m=D(m,S,p,I,b[k+5],5,-701558691),I=D(I,m,S,p,b[k+10],9,38016083),p=D(p,I,m,S,b[k+15],14,-660478335),S=D(S,p,I,m,b[k+4],20,-405537848),m=D(m,S,p,I,b[k+9],5,568446438),I=D(I,m,S,p,b[k+14],9,-1019803690),p=D(p,I,m,S,b[k+3],14,-187363961),S=D(S,p,I,m,b[k+8],20,1163531501),m=D(m,S,p,I,b[k+13],5,-1444681467),I=D(I,m,S,p,b[k+2],9,-51403784),p=D(p,I,m,S,b[k+7],14,1735328473),m=M(m,S=D(S,p,I,m,b[k+12],20,-1926607734),p,I,b[k+5],4,-378558),I=M(I,m,S,p,b[k+8],11,-2022574463),p=M(p,I,m,S,b[k+11],16,1839030562),S=M(S,p,I,m,b[k+14],23,-35309556),m=M(m,S,p,I,b[k+1],4,-1530992060),I=M(I,m,S,p,b[k+4],11,1272893353),p=M(p,I,m,S,b[k+7],16,-155497632),S=M(S,p,I,m,b[k+10],23,-1094730640),m=M(m,S,p,I,b[k+13],4,681279174),I=M(I,m,S,p,b[k+0],11,-358537222),p=M(p,I,m,S,b[k+3],16,-722521979),S=M(S,p,I,m,b[k+6],23,76029189),m=M(m,S,p,I,b[k+9],4,-640364487),I=M(I,m,S,p,b[k+12],11,-421815835),p=M(p,I,m,S,b[k+15],16,530742520),m=_(m,S=M(S,p,I,m,b[k+2],23,-995338651),p,I,b[k+0],6,-198630844),I=_(I,m,S,p,b[k+7],10,1126891415),p=_(p,I,m,S,b[k+14],15,-1416354905),S=_(S,p,I,m,b[k+5],21,-57434055),m=_(m,S,p,I,b[k+12],6,1700485571),I=_(I,m,S,p,b[k+3],10,-1894986606),p=_(p,I,m,S,b[k+10],15,-1051523),S=_(S,p,I,m,b[k+1],21,-2054922799),m=_(m,S,p,I,b[k+8],6,1873313359),I=_(I,m,S,p,b[k+15],10,-30611744),p=_(p,I,m,S,b[k+6],15,-1560198380),S=_(S,p,I,m,b[k+13],21,1309151649),m=_(m,S,p,I,b[k+4],6,-145523070),I=_(I,m,S,p,b[k+11],10,-1120210379),p=_(p,I,m,S,b[k+2],15,718787259),S=_(S,p,I,m,b[k+9],21,-343485551),m=L(m,J),S=L(S,R),p=L(p,Z),I=L(I,X)}return Array(m,S,p,I)}function v(b,C,m,S,p,I){return L((C=L(L(C,b),L(S,I)))<<p|C>>>32-p,m)}function A(b,C,m,S,p,I,k){return v(C&m|~C&S,b,C,p,I,k)}function D(b,C,m,S,p,I,k){return v(C&S|m&~S,b,C,p,I,k)}function M(b,C,m,S,p,I,k){return v(C^m^S,b,C,p,I,k)}function _(b,C,m,S,p,I,k){return v(m^(C|~S),b,C,p,I,k)}function L(b,C){var m=(65535&b)+(65535&C);return(b>>16)+(C>>16)+(m>>16)<<16|65535&m}n.exports=function(b){return x.hash(b,w,16)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],7:[function(t,n,r){(function(s,i,a,l,u,h,d,g,y){n.exports=function(x){for(var w,v=new Array(x),A=0;A<x;A++)!(3&A)&&(w=4294967296*Math.random()),v[A]=w>>>((3&A)<<3)&255;return v}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],8:[function(t,n,r){(function(s,i,a,l,u,h,d,g,y){var x=t("./helpers");function w(D,M){D[M>>5]|=128<<24-M%32,D[15+(M+64>>9<<4)]=M;for(var _,L,b,C=Array(80),m=1732584193,S=-271733879,p=-1732584194,I=271733878,k=-1009589776,J=0;J<D.length;J+=16){for(var R=m,Z=S,X=p,q=I,Y=k,te=0;te<80;te++){C[te]=te<16?D[J+te]:A(C[te-3]^C[te-8]^C[te-14]^C[te-16],1);var re=v(v(A(m,5),(re=S,L=p,b=I,(_=te)<20?re&L|~re&b:!(_<40)&&_<60?re&L|re&b|L&b:re^L^b)),v(v(k,C[te]),(_=te)<20?1518500249:_<40?1859775393:_<60?-1894007588:-899497514)),k=I,I=p,p=A(S,30),S=m,m=re}m=v(m,R),S=v(S,Z),p=v(p,X),I=v(I,q),k=v(k,Y)}return Array(m,S,p,I,k)}function v(D,M){var _=(65535&D)+(65535&M);return(D>>16)+(M>>16)+(_>>16)<<16|65535&_}function A(D,M){return D<<M|D>>>32-M}n.exports=function(D){return x.hash(D,w,20,!0)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],9:[function(t,n,r){(function(s,i,a,l,u,h,d,g,y){function x(M,_){var L=(65535&M)+(65535&_);return(M>>16)+(_>>16)+(L>>16)<<16|65535&L}function w(M,_){var L,b=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),C=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),m=new Array(64);M[_>>5]|=128<<24-_%32,M[15+(_+64>>9<<4)]=_;for(var S,p,I=0;I<M.length;I+=16){for(var k=C[0],J=C[1],R=C[2],Z=C[3],X=C[4],q=C[5],Y=C[6],te=C[7],re=0;re<64;re++)m[re]=re<16?M[re+I]:x(x(x((p=m[re-2],A(p,17)^A(p,19)^D(p,10)),m[re-7]),(p=m[re-15],A(p,7)^A(p,18)^D(p,3))),m[re-16]),L=x(x(x(x(te,A(p=X,6)^A(p,11)^A(p,25)),X&q^~X&Y),b[re]),m[re]),S=x(A(S=k,2)^A(S,13)^A(S,22),k&J^k&R^J&R),te=Y,Y=q,q=X,X=x(Z,L),Z=R,R=J,J=k,k=x(L,S);C[0]=x(k,C[0]),C[1]=x(J,C[1]),C[2]=x(R,C[2]),C[3]=x(Z,C[3]),C[4]=x(X,C[4]),C[5]=x(q,C[5]),C[6]=x(Y,C[6]),C[7]=x(te,C[7])}return C}var v=t("./helpers"),A=function(M,_){return M>>>_|M<<32-_},D=function(M,_){return M>>>_};n.exports=function(M){return v.hash(M,w,32,!0)}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:11}],10:[function(t,n,r){(function(s,i,a,l,u,h,d,g,y){r.read=function(x,w,v,A,I){var M,_,L=8*I-A-1,b=(1<<L)-1,C=b>>1,m=-7,S=v?I-1:0,p=v?-1:1,I=x[w+S];for(S+=p,M=I&(1<<-m)-1,I>>=-m,m+=L;0<m;M=256*M+x[w+S],S+=p,m-=8);for(_=M&(1<<-m)-1,M>>=-m,m+=A;0<m;_=256*_+x[w+S],S+=p,m-=8);if(M===0)M=1-C;else{if(M===b)return _?NaN:1/0*(I?-1:1);_+=Math.pow(2,A),M-=C}return(I?-1:1)*_*Math.pow(2,M-A)},r.write=function(x,w,v,A,D,k){var _,L,b=8*k-D-1,C=(1<<b)-1,m=C>>1,S=D===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=A?0:k-1,I=A?1:-1,k=w<0||w===0&&1/w<0?1:0;for(w=Math.abs(w),isNaN(w)||w===1/0?(L=isNaN(w)?1:0,_=C):(_=Math.floor(Math.log(w)/Math.LN2),w*(A=Math.pow(2,-_))<1&&(_--,A*=2),2<=(w+=1<=_+m?S/A:S*Math.pow(2,1-m))*A&&(_++,A/=2),C<=_+m?(L=0,_=C):1<=_+m?(L=(w*A-1)*Math.pow(2,D),_+=m):(L=w*Math.pow(2,m-1)*Math.pow(2,D),_=0));8<=D;x[v+p]=255&L,p+=I,L/=256,D-=8);for(_=_<<D|L,b+=D;0<b;x[v+p]=255&_,p+=I,_/=256,b-=8);x[v+p-I]|=128*k}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/ieee754/index.js","/node_modules/gulp-browserify/node_modules/ieee754")},{buffer:3,lYpoI2:11}],11:[function(t,n,r){(function(s,i,a,l,u,h,d,g,y){var x,w,v;function A(){}(s=n.exports={}).nextTick=(w=typeof window<"u"&&window.setImmediate,v=typeof window<"u"&&window.postMessage&&window.addEventListener,w?function(D){return window.setImmediate(D)}:v?(x=[],window.addEventListener("message",function(D){var M=D.source;M!==window&&M!==null||D.data!=="process-tick"||(D.stopPropagation(),0<x.length&&x.shift()())},!0),function(D){x.push(D),window.postMessage("process-tick","*")}):function(D){setTimeout(D,0)}),s.title="browser",s.browser=!0,s.env={},s.argv=[],s.on=A,s.addListener=A,s.once=A,s.off=A,s.removeListener=A,s.removeAllListeners=A,s.emit=A,s.binding=function(D){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(D){throw new Error("process.chdir is not supported")}}).call(this,t("lYpoI2"),typeof self<"u"?self:typeof window<"u"?window:{},t("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/process/browser.js","/node_modules/gulp-browserify/node_modules/process")},{buffer:3,lYpoI2:11}]},{},[1])(1)})})(li);var kc=li.exports;const Bc=sn(kc);var ci=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","uint","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"],Fc=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"],ui=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT"],Uc=ci,Nc=Uc.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray"]),Sr=ui;Sr=Sr.slice().filter(function(o){return!/^(gl\_|texture)/.test(o)});var zc=Sr.concat(["gl_VertexID","gl_InstanceID","gl_Position","gl_PointSize","gl_FragCoord","gl_FrontFacing","gl_FragDepth","gl_PointCoord","gl_MaxVertexAttribs","gl_MaxVertexUniformVectors","gl_MaxVertexOutputVectors","gl_MaxFragmentInputVectors","gl_MaxVertexTextureImageUnits","gl_MaxCombinedTextureImageUnits","gl_MaxTextureImageUnits","gl_MaxFragmentUniformVectors","gl_MaxDrawBuffers","gl_MinProgramTexelOffset","gl_MaxProgramTexelOffset","gl_DepthRangeParameters","gl_DepthRange","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"]),Vc=qc,Rc=ci,hi=Fc,Gc=ui,jc=Nc,Ec=zc,$e=999,fi=9999,Ar=0,Pr=1,di=2,pi=3,mi=4,on=5,Wc=6,Yc=7,Xc=8,gi=9,Zc=10,yi=11,Kc=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"];function qc(o){var e=0,t=0,n=$e,r,s,i=[],a=[],l=1,u=0,h=0,d=!1,g=!1,y="",x;o=o||{};var w=Gc,v=Rc;o.version==="300 es"&&(w=Ec,v=jc);for(var A={},D={},e=0;e<w.length;e++)A[w[e]]=!0;for(var e=0;e<v.length;e++)D[v[e]]=!0;return function(q){return a=[],q!==null?_(q):L()};function M(q){q.length&&a.push({type:Kc[n],data:q,position:h,line:l,column:u})}function _(q){e=0,q.toString&&(q=q.toString()),y+=q.replace(/\r\n/g,`
|
|
267
|
+
`),x=y.length;for(var Y;r=y[e],e<x;){switch(Y=e,n){case Ar:e=p();break;case Pr:e=S();break;case di:e=m();break;case pi:e=I();break;case mi:e=R();break;case yi:e=J();break;case on:e=Z();break;case fi:e=X();break;case gi:e=C();break;case $e:e=b();break}if(Y!==e)switch(y[Y]){case`
|
|
268
|
+
`:u=0,++l;break;default:++u;break}}return t+=e,y=y.slice(e),a}function L(q){return i.length&&M(i.join("")),n=Zc,M("(eof)"),a}function b(){return i=i.length?[]:i,s==="/"&&r==="*"?(h=t+e-1,n=Ar,s=r,e+1):s==="/"&&r==="/"?(h=t+e-1,n=Pr,s=r,e+1):r==="#"?(n=di,h=t+e,e):/\s/.test(r)?(n=gi,h=t+e,e):(d=/\d/.test(r),g=/[^\w_]/.test(r),h=t+e,n=d?mi:g?pi:fi,e)}function C(){return/[^\s]/g.test(r)?(M(i.join("")),n=$e,e):(i.push(r),s=r,e+1)}function m(){return(r==="\r"||r===`
|
|
269
|
+
`)&&s!=="\\"?(M(i.join("")),n=$e,e):(i.push(r),s=r,e+1)}function S(){return m()}function p(){return r==="/"&&s==="*"?(i.push(r),M(i.join("")),n=$e,e+1):(i.push(r),s=r,e+1)}function I(){if(s==="."&&/\d/.test(r))return n=on,e;if(s==="/"&&r==="*")return n=Ar,e;if(s==="/"&&r==="/")return n=Pr,e;if(r==="."&&i.length){for(;k(i););return n=on,e}if(r===";"||r===")"||r==="("){if(i.length)for(;k(i););return M(r),n=$e,e+1}var q=i.length===2&&r!=="=";if(/[\w_\d\s]/.test(r)||q){for(;k(i););return n=$e,e}return i.push(r),s=r,e+1}function k(q){var Y=0,te,re;do{if(te=hi.indexOf(q.slice(0,q.length+Y).join("")),re=hi[te],te===-1){if(Y--+q.length>0)continue;re=q.slice(0,1).join("")}return M(re),h+=re.length,i=i.slice(re.length),i.length}while(!0)}function J(){return/[^a-fA-F0-9]/.test(r)?(M(i.join("")),n=$e,e):(i.push(r),s=r,e+1)}function R(){return r==="."||/[eE]/.test(r)?(i.push(r),n=on,s=r,e+1):r==="x"&&i.length===1&&i[0]==="0"?(n=yi,i.push(r),s=r,e+1):/[^\d]/.test(r)?(M(i.join("")),n=$e,e):(i.push(r),s=r,e+1)}function Z(){return r==="f"&&(i.push(r),s=r,e+=1),/[eE]/.test(r)||(r==="-"||r==="+")&&/[eE]/.test(s)?(i.push(r),s=r,e+1):/[^\d]/.test(r)?(M(i.join("")),n=$e,e):(i.push(r),s=r,e+1)}function X(){if(/[^\d\w_]/.test(r)){var q=i.join("");return D[q]?n=Xc:A[q]?n=Yc:n=Wc,M(i.join("")),n=$e,e}return i.push(r),s=r,e+1}}var Qc=Vc,Jc=Hc;function Hc(o,e){var t=Qc(e),n=[];return n=n.concat(t(o)),n=n.concat(t(null)),n}const $c=sn(Jc);var eu=tu;function tu(o){for(var e=[],t=0;t<o.length;t++)o[t].type!=="eof"&&e.push(o[t].data);return e.join("")}const _i=sn(eu);var nu=ru;function ru(o){var e=null,t=null,n=0,r=0,s=0,i=0,a=0,l=[],u,h,d;for(u=0,h;u<o.length;u++)if(d=o[u],d.data==="{"){if(n&&n++||(h=y(u,xt(")"),xt()),h<0)||(i=h,h=y(h,xt("("),xt(")")),h<0)||(a=h,h=y(h,an),h<0)||o[h].type!=="ident"||(t=o[h].data,h=y(h,an),h<0))continue;n=1,r=u,e=o[h].data,s=h;var g=y(h,an);switch(o[g]&&o[g].data){case"lowp":case"highp":case"mediump":s=g}}else if(n&&d.data==="}"){if(--n)continue;l.push({name:t,type:e,body:[r+1,u],args:[a,i+1],outer:[s,u+1]})}for(u=0;u<o.length;u++)if(d=o[u],d.data===";"){if(h=y(u,xt(")"),xt()),h<0||(i=h,h=y(h,xt("("),xt(")")),h<0)||(a=h,h=y(h,an),h<0)||o[h].type!=="ident"||(t=o[h].data,h=y(h,an),h<0)||o[h].type==="operator"||o[h].data==="return")continue;e=o[h].data,l.push({name:t,type:e,body:!1,args:[a,i+1],outer:[h,u+1]})}return l.sort(function(x,w){return x.outer[0]-w.outer[0]});function y(x,w,v){for(var A=x-1;A>=0;A--){if(w(o[A]))return A;if(v&&v(o[A]))return-1}return-1}}function xt(o){return function(e){return e.type==="operator"&&(!o||e.data===o)}}function an(o){return o.type!=="whitespace"}const su=sn(nu);function iu(o,e){if(typeof o!="object"||o===null)return o;var t=o[Symbol.toPrimitive];if(t!==void 0){var n=t.call(o,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(o)}function vi(o){var e=iu(o,"string");return typeof e=="symbol"?e:String(e)}function Pe(o,e,t){return e=vi(e),e in o?Object.defineProperty(o,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):o[e]=t,o}function xi(o,e){var t=Object.keys(o);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(o);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(o,r).enumerable})),t.push.apply(t,n)}return t}function zt(o){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?xi(Object(t),!0).forEach(function(n){Pe(o,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(t)):xi(Object(t)).forEach(function(n){Object.defineProperty(o,n,Object.getOwnPropertyDescriptor(t,n))})}return o}function ou(o,e){if(o==null)return{};var t={},n=Object.keys(o),r,s;for(s=0;s<n.length;s++)r=n[s],!(e.indexOf(r)>=0)&&(t[r]=o[r]);return t}function au(o,e){if(o==null)return{};var t=ou(o,e),n,r;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(o);for(r=0;r<s.length;r++)n=s[r],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(o,n)&&(t[n]=o[n])}return t}function lu(o,e){if(!(o instanceof e))throw new TypeError("Cannot call a class as a function")}function wi(o,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(o,vi(n.key),n)}}function cu(o,e,t){return e&&wi(o.prototype,e),t&&wi(o,t),Object.defineProperty(o,"prototype",{writable:!1}),o}function bi(o){if(o===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return o}function Cr(o,e){return Cr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Cr(o,e)}function uu(o,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");o.prototype=Object.create(e&&e.prototype,{constructor:{value:o,writable:!0,configurable:!0}}),Object.defineProperty(o,"prototype",{writable:!1}),e&&Cr(o,e)}function In(o){return In=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},In(o)}function hu(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function fu(o,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return bi(o)}function du(o){var e=hu();return function(){var n=In(o),r;if(e){var s=In(this).constructor;r=Reflect.construct(n,arguments,s)}else r=n.apply(this,arguments);return fu(this,r)}}var pe={position:"csm_Position",positionRaw:"csm_PositionRaw",pointSize:"csm_PointSize",fragColor:"csm_FragColor",diffuseColor:"csm_DiffuseColor",normal:"csm_Normal",roughness:"csm_Roughness",metalness:"csm_Metalness",emissive:"csm_Emissive",ao:"csm_AO",bump:"csm_Bump",depthAlpha:"csm_DepthAlpha"},Ge,Vt,pu=(Ge={},Pe(Ge,"".concat(pe.normal),{"#include <beginnormal_vertex>":`
|
|
270
270
|
vec3 objectNormal = `.concat(pe.normal,`;
|
|
271
271
|
#ifdef USE_TANGENT
|
|
272
272
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
@@ -311,15 +311,15 @@ list should be an Array.`),T.length===0)return new v(0);if(T.length===1)return T
|
|
|
311
311
|
`),"gl_FragColor = packDepthToRGBA( fragCoordZ );":`
|
|
312
312
|
gl_FragColor = packDepthToRGBA( fragCoordZ );
|
|
313
313
|
gl_FragColor.a *= `.concat(pe.depthAlpha,`;
|
|
314
|
-
`)}),Ge),
|
|
314
|
+
`)}),Ge),mu=(Vt={},Pe(Vt,"".concat(pe.position),{"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );":`
|
|
315
315
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( `.concat(pe.position,`, 1.0 );
|
|
316
|
-
`)}),Pe(
|
|
316
|
+
`)}),Pe(Vt,"".concat(pe.positionRaw),{"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );":`
|
|
317
317
|
gl_Position = `.concat(pe.position,`;
|
|
318
|
-
`)}),Pe(
|
|
318
|
+
`)}),Pe(Vt,"".concat(pe.diffuseColor),{"gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );":`
|
|
319
319
|
gl_FragColor = `.concat(pe.diffuseColor,`;
|
|
320
|
-
`)}),Pe(
|
|
320
|
+
`)}),Pe(Vt,"".concat(pe.fragColor),{"gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );":`
|
|
321
321
|
gl_FragColor = `.concat(pe.fragColor,`;
|
|
322
|
-
`)}),
|
|
322
|
+
`)}),Vt),gu=`
|
|
323
323
|
|
|
324
324
|
#ifdef IS_VERTEX
|
|
325
325
|
// csm_Position & csm_PositionRaw
|
|
@@ -378,46 +378,46 @@ list should be an Array.`),T.length===0)return new v(0);if(T.length===1)return T
|
|
|
378
378
|
|
|
379
379
|
float csm_DepthAlpha = 1.0;
|
|
380
380
|
#endif
|
|
381
|
-
`,
|
|
381
|
+
`,yu=`
|
|
382
382
|
varying mat4 csm_internal_vModelViewMatrix;
|
|
383
|
-
`,
|
|
383
|
+
`,_u=`
|
|
384
384
|
csm_internal_vModelViewMatrix = modelViewMatrix;
|
|
385
|
-
`,
|
|
385
|
+
`,vu=`
|
|
386
386
|
varying mat4 csm_internal_vModelViewMatrix;
|
|
387
|
-
`,
|
|
387
|
+
`,xu=`
|
|
388
388
|
|
|
389
|
-
`,je,
|
|
390
|
-
`+w,
|
|
389
|
+
`,je,wu=(je={},Pe(je,"".concat(pe.position),"*"),Pe(je,"".concat(pe.positionRaw),"*"),Pe(je,"".concat(pe.normal),"*"),Pe(je,"".concat(pe.pointSize),["PointsMaterial"]),Pe(je,"".concat(pe.diffuseColor),"*"),Pe(je,"".concat(pe.fragColor),"*"),Pe(je,"".concat(pe.emissive),["MeshStandardMaterial","MeshPhysicalMaterial"]),Pe(je,"".concat(pe.roughness),["MeshStandardMaterial","MeshPhysicalMaterial"]),Pe(je,"".concat(pe.metalness),["MeshStandardMaterial","MeshPhysicalMaterial"]),Pe(je,"".concat(pe.ao),["MeshStandardMaterial","MeshPhysicalMaterial","MeshBasicMaterial","MeshLambertMaterial","MeshPhongMaterial","MeshToonMaterial"]),Pe(je,"".concat(pe.bump),["MeshLambertMaterial","MeshMatcapMaterial","MeshNormalMaterial","MeshPhongMaterial","MeshPhysicalMaterial","MeshStandardMaterial","MeshToonMaterial","ShadowMaterial"]),Pe(je,"".concat(pe.depthAlpha),"*"),je),bu=["baseMaterial","fragmentShader","vertexShader","uniforms","patchMap","cacheKey","silent"],Mu=function(e,t,n){return e.split(t).join(n)},Su=function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")},Au=function(e,t){return new RegExp("\\b".concat(Su(t),"\\b")).test(e)};function Pu(o){try{new o}catch(e){if(e.message.indexOf("is not a constructor")>=0)return!1}return!0}function Cu(o,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;Object.assign(o,e);var n=Object.getPrototypeOf(e);Object.entries(Object.getOwnPropertyDescriptors(n)).filter(function(r){var s=typeof r[1].get=="function",i=typeof r[1].set=="function",a=typeof r[1].value=="function",l=r[0]==="constructor";return(s||i||a)&&!l}).forEach(function(r){if(typeof o[r[0]]=="function"){t||console.warn("Function ".concat(r[0]," already exists on CSM, renaming to base_").concat(r[0]));var s="base_".concat(r[0]);o[s]=r[1].value.bind(o);return}Object.defineProperty(o,r[0],r[1])})}function Tu(o){var e=o.toString().trim(),t=e.substring(e.indexOf("{")+1,e.lastIndexOf("}"));return t.trim().length===0}function Mi(o){return o.replace(/\s/g,"")}function Lu(o,e,t){var n=o.lastIndexOf(e);return n===-1?o:o.substring(0,n)+t+o.substring(n+e.length)}var Du=function(o){uu(t,o);var e=du(t);function t(n){var r,s=n.baseMaterial,i=n.fragmentShader,a=n.vertexShader,l=n.uniforms,u=n.patchMap,h=n.cacheKey,d=n.silent,g=au(n,bu);lu(this,t);var y;if(Pu(s)?y=new s(g):(y=s,Object.assign(y,g)),y.type==="RawShaderMaterial")throw new Error("CustomShaderMaterial does not support RawShaderMaterial");r=e.call(this),Cu(bi(r),y,d),r.__csm={patchMap:u||{},fragmentShader:i||"",vertexShader:a||"",cacheKey:h,baseMaterial:s,instanceID:Vr.MathUtils.generateUUID(),type:y.type,isAlreadyExtended:!Tu(y.onBeforeCompile),cacheHash:"",silent:d},r.uniforms=zt(zt({},r.uniforms||{}),l||{});{var x=r.__csm,w=x.fragmentShader,v=x.vertexShader,A=r.uniforms;r.__csm.cacheHash=r.getCacheHash(),r.generateMaterial(w,v,A)}return r}return cu(t,[{key:"update",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.uniforms=r.uniforms||this.uniforms,Object.assign(this.__csm,r);var s=this.__csm,i=s.fragmentShader,a=s.vertexShader,l=this.uniforms,u=this.getCacheHash();this.__csm.cacheHash=u,this.generateMaterial(i,a,l)}},{key:"clone",value:function(){var r={baseMaterial:this.__csm.baseMaterial,fragmentShader:this.__csm.fragmentShader,vertexShader:this.__csm.vertexShader,uniforms:this.uniforms,silent:this.__csm.silent,patchMap:this.__csm.patchMap,cacheKey:this.__csm.cacheKey},s=new this.constructor(r);return Object.assign(this,s),s}},{key:"getCacheHash",value:function(){var r=this.__csm,s=r.fragmentShader,i=r.vertexShader,a=this.uniforms,l=Object.values(a).reduce(function(h,d){var g=d.value;return h+JSON.stringify(g)},""),u=Mi(s)+Mi(i)+l;return u.trim().length>0?Bc(u):this.customProgramCacheKey()}},{key:"generateMaterial",value:function(r,s,i){var a=this,l=this.parseShader(r),u=this.parseShader(s);this.uniforms=i||{},this.customProgramCacheKey=function(){return a.__csm.cacheHash};var h=function(y){try{if(l){var x=a.patchShader(l,y.fragmentShader,!0);y.fragmentShader=a.getMaterialDefine()+x}if(u){var w=a.patchShader(u,y.vertexShader);y.vertexShader=`#define IS_VERTEX;
|
|
390
|
+
`+w,y.vertexShader=a.getMaterialDefine()+y.vertexShader}y.uniforms=zt(zt({},y.uniforms),a.uniforms),a.uniforms=y.uniforms}catch(v){console.error(v)}};if(this.__csm.isAlreadyExtended){var d=this.onBeforeCompile;this.onBeforeCompile=function(g,y){d(g,y),h(g)}}else this.onBeforeCompile=h;this.needsUpdate=!0}},{key:"patchShader",value:function(r,s,i){var a=this,l=s,u=zt(zt({},this.getPatchMapForMaterial()),this.__csm.patchMap);Object.keys(u).forEach(function(g){Object.keys(u[g]).forEach(function(y){var x=wu[g],w=a.__csm.type;if(g==="*"||Au(r.main,g))if(!x||Array.isArray(x)&&x.includes(w)||x==="*")l=Mu(l,y,u[g][y]);else throw new Error("CSM: ".concat(g," is not available in ").concat(w,". Shader cannot compile."))})}),l=l.replace("void main() {",`
|
|
391
391
|
#ifndef CSM_IS_HEAD_DEFAULTS_DEFINED
|
|
392
|
-
`.concat(i?
|
|
392
|
+
`.concat(i?vu:yu,`
|
|
393
393
|
#define CSM_IS_HEAD_DEFAULTS_DEFINED 1
|
|
394
394
|
#endif
|
|
395
395
|
|
|
396
|
-
`).concat(
|
|
396
|
+
`).concat(r.header,`
|
|
397
397
|
|
|
398
398
|
void main() {
|
|
399
399
|
#ifndef CSM_IS_DEFAULTS_DEFINED
|
|
400
|
-
`).concat(
|
|
400
|
+
`).concat(gu,`
|
|
401
401
|
#define CSM_IS_DEFAULTS_DEFINED 1
|
|
402
402
|
#endif
|
|
403
403
|
|
|
404
404
|
#ifndef CSM_IS_MAIN_DEFAULTS_DEFINED
|
|
405
|
-
`).concat(i?
|
|
405
|
+
`).concat(i?xu:_u,`
|
|
406
406
|
#define CSM_IS_MAIN_DEFAULTS_DEFINED 1
|
|
407
407
|
#endif
|
|
408
408
|
|
|
409
409
|
// CSM_START
|
|
410
|
-
`));var h=this.__csm.isAlreadyExtended,d=l.includes("// CSM_END");return h&&d?l=
|
|
410
|
+
`));var h=this.__csm.isAlreadyExtended,d=l.includes("// CSM_END");return h&&d?l=Lu(l,"// CSM_END",`
|
|
411
411
|
// CSM_END
|
|
412
|
-
`.concat(
|
|
412
|
+
`.concat(r.main,`
|
|
413
413
|
// CSM_END
|
|
414
414
|
`)):l=l.replace("// CSM_START",`
|
|
415
415
|
// CSM_START
|
|
416
|
-
`.concat(
|
|
416
|
+
`.concat(r.main,`
|
|
417
417
|
// CSM_END
|
|
418
|
-
`)),l=
|
|
418
|
+
`)),l=r.defines+l,l}},{key:"parseShader",value:function(r){if(r){var s=r.replace(/\/\*\*(.*?)\*\/|\/\/(.*?)\n/gm,""),i=$c(s),a=su(i),l=a.map(function(d){return d.name}).indexOf("main"),u=_i(i.slice(0,l>=0?a[l].outer[0]:void 0)),h=l>=0?this.getShaderFromIndex(i,a[l].body):"";return{defines:"",header:u,main:h}}}},{key:"getMaterialDefine",value:function(){var r=this.__csm.type;return r?"#define IS_".concat(r.toUpperCase(),`;
|
|
419
419
|
`):`#define IS_UNKNOWN;
|
|
420
|
-
`}},{key:"getPatchMapForMaterial",value:function(){switch(this.__csm.type){case"ShaderMaterial":return
|
|
420
|
+
`}},{key:"getPatchMapForMaterial",value:function(){switch(this.__csm.type){case"ShaderMaterial":return mu;default:return pu}}},{key:"getShaderFromIndex",value:function(r,s){return _i(r.slice(s[0],s[1]))}}]),t}(Vr.Material);const Iu=["args"],Ou=f.defineComponent({__name:"index",props:{baseMaterial:{type:Function},vertexShader:{},fragmentShader:{},silent:{type:Boolean},uniforms:{}},setup(o,{expose:e}){const t=o,n=f.shallowRef(null),{extend:r}=ae.useTresContext();return r({CustomShaderMaterial:Du}),e({value:n}),(s,i)=>(f.openBlock(),f.createElementBlock("TresCustomShaderMaterial",{ref_key:"customShaderMaterialClass",ref:n,args:[t]},null,8,Iu))}}),ku=parseInt(c.REVISION.replace(/\D+/g,""));class Bu extends c.ShaderMaterial{constructor(t=new c.Vector2){super({uniforms:{inputBuffer:new c.Uniform(null),depthBuffer:new c.Uniform(null),resolution:new c.Uniform(new c.Vector2),texelSize:new c.Uniform(new c.Vector2),halfTexelSize:new c.Uniform(new c.Vector2),kernel:new c.Uniform(0),scale:new c.Uniform(1),cameraNear:new c.Uniform(0),cameraFar:new c.Uniform(1),minDepthThreshold:new c.Uniform(0),maxDepthThreshold:new c.Uniform(1),depthScale:new c.Uniform(0),depthToBlurRatioBias:new c.Uniform(.25)},fragmentShader:`#include <common>
|
|
421
421
|
#include <dithering_pars_fragment>
|
|
422
422
|
uniform sampler2D inputBuffer;
|
|
423
423
|
uniform sampler2D depthBuffer;
|
|
@@ -451,7 +451,7 @@ list should be an Array.`),T.length===0)return new v(0);if(T.length===1)return T
|
|
|
451
451
|
|
|
452
452
|
#include <dithering_fragment>
|
|
453
453
|
#include <tonemapping_fragment>
|
|
454
|
-
#include <${
|
|
454
|
+
#include <${ku>=154?"colorspace_fragment":"encodings_fragment"}>
|
|
455
455
|
}`,vertexShader:`uniform vec2 texelSize;
|
|
456
456
|
uniform vec2 halfTexelSize;
|
|
457
457
|
uniform float kernel;
|
|
@@ -473,7 +473,7 @@ list should be an Array.`),T.length===0)return new v(0);if(T.length===1)return T
|
|
|
473
473
|
vUv3 = vec2(uv.x - dUv.x, uv.y - dUv.y);
|
|
474
474
|
|
|
475
475
|
gl_Position = vec4(position.xy, 1.0, 1.0);
|
|
476
|
-
}`,blending:c.NoBlending,depthWrite:!1,depthTest:!1});le(this,"kernel");this.toneMapped=!1,this.setTexelSize(t.x,t.y),this.kernel=new Float32Array([0,1,2,2,3])}setTexelSize(t,n){this.uniforms.texelSize.value.set(t,n),this.uniforms.halfTexelSize.value.set(t,n).multiplyScalar(.5)}setResolution(t){this.uniforms.resolution.value.copy(t)}}class
|
|
476
|
+
}`,blending:c.NoBlending,depthWrite:!1,depthTest:!1});le(this,"kernel");this.toneMapped=!1,this.setTexelSize(t.x,t.y),this.kernel=new Float32Array([0,1,2,2,3])}setTexelSize(t,n){this.uniforms.texelSize.value.set(t,n),this.uniforms.halfTexelSize.value.set(t,n).multiplyScalar(.5)}setResolution(t){this.uniforms.resolution.value.copy(t)}}class Fu{constructor({resolution:e,width:t=500,height:n=500,minDepthThreshold:r=0,maxDepthThreshold:s=1,depthScale:i=0,depthToBlurRatioBias:a=.25}){le(this,"renderTargetA");le(this,"renderTargetB");le(this,"convolutionMaterial");le(this,"scene");le(this,"camera");le(this,"screen");le(this,"renderToScreen",!1);this.renderTargetA=new c.WebGLRenderTarget(e,e,{minFilter:c.LinearFilter,magFilter:c.LinearFilter,stencilBuffer:!1,depthBuffer:!1,type:c.HalfFloatType}),this.renderTargetB=this.renderTargetA.clone(),this.convolutionMaterial=new Bu,this.convolutionMaterial.setTexelSize(1/t,1/n),this.convolutionMaterial.setResolution(new c.Vector2(t,n)),this.scene=new c.Scene,this.camera=new c.Camera,this.convolutionMaterial.uniforms.minDepthThreshold.value=r,this.convolutionMaterial.uniforms.maxDepthThreshold.value=s,this.convolutionMaterial.uniforms.depthScale.value=i,this.convolutionMaterial.uniforms.depthToBlurRatioBias.value=a,this.convolutionMaterial.defines.USE_DEPTH=i>0;const l=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),u=new Float32Array([0,0,2,0,0,2]),h=new c.BufferGeometry;h.setAttribute("position",new c.BufferAttribute(l,3)),h.setAttribute("uv",new c.BufferAttribute(u,2)),this.screen=new c.Mesh(h,this.convolutionMaterial),this.screen.frustumCulled=!1,this.scene.add(this.screen)}render(e,t,n){const r=this.scene,s=this.camera,i=this.renderTargetA,a=this.renderTargetB,l=this.convolutionMaterial,u=l.uniforms;u.depthBuffer.value=t.depthTexture;const h=l.kernel;let d=t,g,y,x;for(y=0,x=h.length-1;y<x;++y)g=y&1?a:i,u.kernel.value=h[y],u.inputBuffer.value=d.texture,e.setRenderTarget(g),e.render(r,s),d=g;u.kernel.value=h[y],u.inputBuffer.value=d.texture,e.setRenderTarget(this.renderToScreen?null:n),e.render(r,s)}}class Uu extends c.MeshStandardMaterial{constructor(t={}){super(t);le(this,"_tDepth",{value:null});le(this,"_distortionMap",{value:null});le(this,"_tDiffuse",{value:null});le(this,"_tDiffuseBlur",{value:null});le(this,"_textureMatrix",{value:null});le(this,"_hasBlur",{value:!1});le(this,"_mirror",{value:0});le(this,"_mixBlur",{value:0});le(this,"_blurStrength",{value:.5});le(this,"_minDepthThreshold",{value:.9});le(this,"_maxDepthThreshold",{value:1});le(this,"_depthScale",{value:0});le(this,"_depthToBlurRatioBias",{value:.25});le(this,"_distortion",{value:1});le(this,"_mixContrast",{value:1});this.setValues(t)}onBeforeCompile(t){var n;(n=t.defines)!=null&&n.USE_UV||(t.defines.USE_UV=""),t.uniforms.hasBlur=this._hasBlur,t.uniforms.tDiffuse=this._tDiffuse,t.uniforms.tDepth=this._tDepth,t.uniforms.distortionMap=this._distortionMap,t.uniforms.tDiffuseBlur=this._tDiffuseBlur,t.uniforms.textureMatrix=this._textureMatrix,t.uniforms.mirror=this._mirror,t.uniforms.mixBlur=this._mixBlur,t.uniforms.mixStrength=this._blurStrength,t.uniforms.minDepthThreshold=this._minDepthThreshold,t.uniforms.maxDepthThreshold=this._maxDepthThreshold,t.uniforms.depthScale=this._depthScale,t.uniforms.depthToBlurRatioBias=this._depthToBlurRatioBias,t.uniforms.distortion=this._distortion,t.uniforms.mixContrast=this._mixContrast,t.vertexShader=`
|
|
477
477
|
uniform mat4 textureMatrix;
|
|
478
478
|
varying vec4 my_vUv;
|
|
479
479
|
${t.vertexShader}`,t.vertexShader=t.vertexShader.replace("#include <project_vertex>",`#include <project_vertex>
|
|
@@ -559,7 +559,7 @@ list should be an Array.`),T.length===0)return new v(0);if(T.length===1)return T
|
|
|
559
559
|
newMerge.b = (merge.b - 0.5) * mixContrast + 0.5;
|
|
560
560
|
|
|
561
561
|
diffuseColor.rgb = diffuseColor.rgb * ((1.0 - min(1.0, mirror)) + newMerge.rgb * mixStrength);
|
|
562
|
-
`)}get tDiffuse(){return this._tDiffuse.value}set tDiffuse(t){this._tDiffuse.value=t}get tDepth(){return this._tDepth.value}set tDepth(t){this._tDepth.value=t}get distortionMap(){return this._distortionMap.value}set distortionMap(t){this._distortionMap.value=t}get tDiffuseBlur(){return this._tDiffuseBlur.value}set tDiffuseBlur(t){this._tDiffuseBlur.value=t}get textureMatrix(){return this._textureMatrix.value}set textureMatrix(t){this._textureMatrix.value=t}get hasBlur(){return this._hasBlur.value}set hasBlur(t){this._hasBlur.value=t}get mirror(){return this._mirror.value}set mirror(t){this._mirror.value=t}get mixBlur(){return this._mixBlur.value}set mixBlur(t){this._mixBlur.value=t}get mixStrength(){return this._blurStrength.value}set mixStrength(t){this._blurStrength.value=t}get minDepthThreshold(){return this._minDepthThreshold.value}set minDepthThreshold(t){this._minDepthThreshold.value=t}get maxDepthThreshold(){return this._maxDepthThreshold.value}set maxDepthThreshold(t){this._maxDepthThreshold.value=t}get depthScale(){return this._depthScale.value}set depthScale(t){this._depthScale.value=t}get depthToBlurRatioBias(){return this._depthToBlurRatioBias.value}set depthToBlurRatioBias(t){this._depthToBlurRatioBias.value=t}get distortion(){return this._distortion.value}set distortion(t){this._distortion.value=t}get mixContrast(){return this._mixContrast.value}set mixContrast(t){this._mixContrast.value=t}}const ku=["texture-matrix","mirror","t-diffuse","t-depth","t-diffuse-blur","has-blur","mix-strength","min-depth-threshold","max-depth-threshold","depth-scale","depth-to-blur-ratio-bias","distortion","distortionMap","mix-contrast","defines-USE_BLUR","defines-USE_DEPTH","defines-USE_DISTORTION"],Bu=f.defineComponent({__name:"index",props:{resolution:{default:256},mixBlur:{default:0},mixStrength:{default:1},blur:{default:()=>[0,0]},mirror:{default:0},minDepthThreshold:{default:.9},maxDepthThreshold:{default:1},depthScale:{default:0},depthToBlurRatioBias:{default:.25},distortionMap:{},distortion:{default:1},mixContrast:{default:1},reflectorOffset:{default:0}},setup(o){const e=o;function t(Q,K){let Z;return Q.traverse(X=>{X.isMesh&&X.material&&X.material.uuid===K&&(Z=X)}),Z}function n(Q){var Z,X;if(p.reflectorWorldPosition.setFromMatrixPosition(Q.matrixWorld),p.cameraWorldPosition.setFromMatrixPosition((Z=v.value)==null?void 0:Z.matrixWorld),p.rotationMatrix.extractRotation(Q.matrixWorld),p.normal.set(0,0,1),p.normal.applyMatrix4(p.rotationMatrix),p.reflectorWorldPosition.addScaledVector(p.normal,e.reflectorOffset),p.view.subVectors(p.reflectorWorldPosition,p.cameraWorldPosition),p.view.dot(p.normal)>0)return;p.view.reflect(p.normal).negate(),p.view.add(p.reflectorWorldPosition),p.rotationMatrix.extractRotation((X=v.value)==null?void 0:X.matrixWorld),p.lookAtPosition.set(0,0,-1),p.lookAtPosition.applyMatrix4(p.rotationMatrix),p.lookAtPosition.add(p.cameraWorldPosition),p.target.subVectors(p.reflectorWorldPosition,p.lookAtPosition),p.target.reflect(p.normal).negate(),p.target.add(p.reflectorWorldPosition),p.virtualCamera.position.copy(p.view),p.virtualCamera.up.set(0,1,0),p.virtualCamera.up.applyMatrix4(p.rotationMatrix),p.virtualCamera.up.reflect(p.normal),p.virtualCamera.lookAt(p.target),p.virtualCamera.far=(v==null?void 0:v.value).far,p.virtualCamera.updateMatrixWorld(),p.virtualCamera.projectionMatrix.copy((v==null?void 0:v.value).projectionMatrix),p.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),p.textureMatrix.multiply(p.virtualCamera.projectionMatrix),p.textureMatrix.multiply(p.virtualCamera.matrixWorldInverse),p.textureMatrix.multiply(Q.matrixWorld),p.reflectorPlane.setFromNormalAndCoplanarPoint(p.normal,p.reflectorWorldPosition),p.reflectorPlane.applyMatrix4(p.virtualCamera.matrixWorldInverse),p.clipPlane.set(p.reflectorPlane.normal.x,p.reflectorPlane.normal.y,p.reflectorPlane.normal.z,p.reflectorPlane.constant);const K=p.virtualCamera.projectionMatrix;p.q.x=(Math.sign(p.clipPlane.x)+K.elements[8])/K.elements[0],p.q.y=(Math.sign(p.clipPlane.y)+K.elements[9])/K.elements[5],p.q.z=-1,p.q.w=(1+K.elements[10])/K.elements[14],p.clipPlane.multiplyScalar(2/p.clipPlane.dot(p.q)),K.elements[2]=p.clipPlane.x,K.elements[6]=p.clipPlane.y,K.elements[10]=p.clipPlane.z+1,K.elements[14]=p.clipPlane.w}const{resolution:s,minDepthThreshold:r,maxDepthThreshold:i,depthScale:a,depthToBlurRatioBias:l,blur:u,mirror:h,mixBlur:d,mixStrength:y,distortion:g,distortionMap:x,mixContrast:w}=f.toRefs(e),{camera:v,scene:P,renderer:D,extend:S}=ae.useTresContext();S({MeshReflectorMaterial:Fu});const _=f.shallowRef(),L=f.shallowRef(),b=f.shallowRef(),C=f.shallowRef(),m=f.computed(()=>typeof u.value=="number"?[u.value,u.value]:u.value),M=f.computed(()=>m.value[0]>0||m.value[1]>0),p={reflectorPlane:new c.Plane,normal:new c.Vector3,reflectorWorldPosition:new c.Vector3,cameraWorldPosition:new c.Vector3,rotationMatrix:new c.Matrix4,lookAtPosition:new c.Vector3(0,0,-1),clipPlane:new c.Vector4,view:new c.Vector3,target:new c.Vector3,q:new c.Vector4,virtualCamera:new c.PerspectiveCamera,textureMatrix:new c.Matrix4};f.watchEffect(()=>{var K;(K=_.value)==null||K.texture.dispose();const Q={minFilter:c.LinearFilter,magFilter:c.LinearFilter,type:c.HalfFloatType};_.value=new c.WebGLRenderTarget(s.value,s.value,{...Q,depthBuffer:!0,depthTexture:new c.DepthTexture(s.value,s.value,c.DepthFormat,c.UnsignedShortType)}),L.value=new c.WebGLRenderTarget(s.value,s.value,Q),b.value=new Ou({resolution:s.value,width:m.value[0],height:m.value[1],minDepthThreshold:r.value,maxDepthThreshold:i.value,depthScale:a.value,depthToBlurRatioBias:l.value}),C.value={mirror:h,textureMatrix:p.textureMatrix,mixBlur:d,tDiffuse:_.value.texture,tDepth:_.value.depthTexture,tDiffuseBlur:_.value.texture,hasBlur:M,mixStrength:y,minDepthThreshold:r,maxDepthThreshold:i,depthScale:a,depthToBlurRatioBias:l,distortion:g,distortionMap:x.value,mixContrast:w,"defines-USE_BLUR":M.value?"":void 0,"defines-USE_DEPTH":a.value>0?"":void 0,"defines-USE_DISTORTION":x.value?"":void 0}});const I=f.shallowRef(),{onLoop:F}=ae.useRenderLoop();F(()=>{var X;if(!I.value||!D.value||!_.value||!v.value)return;const Q=t(P.value,I.value.uuid);if(!Q)return;Q.visible=!1;const K=D.value.xr.enabled,Z=D.value.shadowMap.autoUpdate;n(Q),D.value.shadowMap.autoUpdate=!1,D.value.setRenderTarget(_.value),D.value.autoClear||D.value.clear(),D.value.render(P.value,p.virtualCamera),(X=b==null?void 0:b.value)==null||X.render(D.value,_.value,L.value),D.value.xr.enabled=K,D.value.shadowMap.autoUpdate=Z,Q.visible=!0,D.value.setRenderTarget(null)});const J=f.useAttrs(),G=f.computed(()=>{const Q={};return Object.assign(Q,e),Object.assign(Q,J.value),Q});return f.onBeforeUnmount(()=>{var Q,K;(Q=_==null?void 0:_.value)==null||Q.dispose(),(K=L==null?void 0:L.value)==null||K.dispose()}),(Q,K)=>{var Z,X,ne;return f.openBlock(),f.createElementBlock("TresMeshReflectorMaterial",f.mergeProps({key:`key${C.value["defines-USE_BLUR"]}${C.value["defines-USE_DEPTH"]}${C.value["defines-USE_DISTORTION"]}`,ref_key:"materialRef",ref:I},G.value,{"texture-matrix":p.textureMatrix,mirror:f.unref(h),"t-diffuse":(Z=_.value)==null?void 0:Z.texture,"t-depth":(X=_.value)==null?void 0:X.depthTexture,"t-diffuse-blur":(ne=L.value)==null?void 0:ne.texture,"has-blur":M.value,"mix-strength":f.unref(y),"min-depth-threshold":f.unref(r),"max-depth-threshold":f.unref(i),"depth-scale":f.unref(a),"depth-to-blur-ratio-bias":f.unref(l),distortion:f.unref(g),distortionMap:f.unref(x),"mix-contrast":f.unref(w),"defines-USE_BLUR":M.value?"":void 0,"defines-USE_DEPTH":f.unref(a)>0?"":void 0,"defines-USE_DISTORTION":f.unref(x)?"":void 0}),null,16,ku)}}}),Uu=["args"],Nu=["color"],zu=f.defineComponent({__name:"Box",props:{args:{default:()=>[1,1,1]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:s}=f.toRefs(t),r=f.shallowRef();return e({value:r}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"boxRef",ref:r},i.$attrs),[f.createElementVNode("TresBoxGeometry",{args:f.unref(n)},null,8,Uu),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(s)},null,8,Nu)])],16))}}),bi=new c.Box3,In=new c.Vector3;class Mi extends c.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new c.Float32BufferAttribute(e,3)),this.setAttribute("uv",new c.Float32BufferAttribute(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new c.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceStart",new c.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceEnd",new c.InterleavedBufferAttribute(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new c.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceColorStart",new c.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceColorEnd",new c.InterleavedBufferAttribute(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new c.WireframeGeometry(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new c.Box3);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),bi.setFromBufferAttribute(t),this.boundingBox.union(bi))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new c.Sphere),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let s=0;for(let r=0,i=e.count;r<i;r++)In.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(In)),In.fromBufferAttribute(t,r),s=Math.max(s,n.distanceToSquared(In));this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}c.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new c.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},c.ShaderLib.line={uniforms:c.UniformsUtils.merge([c.UniformsLib.common,c.UniformsLib.fog,c.UniformsLib.line]),vertexShader:`
|
|
562
|
+
`)}get tDiffuse(){return this._tDiffuse.value}set tDiffuse(t){this._tDiffuse.value=t}get tDepth(){return this._tDepth.value}set tDepth(t){this._tDepth.value=t}get distortionMap(){return this._distortionMap.value}set distortionMap(t){this._distortionMap.value=t}get tDiffuseBlur(){return this._tDiffuseBlur.value}set tDiffuseBlur(t){this._tDiffuseBlur.value=t}get textureMatrix(){return this._textureMatrix.value}set textureMatrix(t){this._textureMatrix.value=t}get hasBlur(){return this._hasBlur.value}set hasBlur(t){this._hasBlur.value=t}get mirror(){return this._mirror.value}set mirror(t){this._mirror.value=t}get mixBlur(){return this._mixBlur.value}set mixBlur(t){this._mixBlur.value=t}get mixStrength(){return this._blurStrength.value}set mixStrength(t){this._blurStrength.value=t}get minDepthThreshold(){return this._minDepthThreshold.value}set minDepthThreshold(t){this._minDepthThreshold.value=t}get maxDepthThreshold(){return this._maxDepthThreshold.value}set maxDepthThreshold(t){this._maxDepthThreshold.value=t}get depthScale(){return this._depthScale.value}set depthScale(t){this._depthScale.value=t}get depthToBlurRatioBias(){return this._depthToBlurRatioBias.value}set depthToBlurRatioBias(t){this._depthToBlurRatioBias.value=t}get distortion(){return this._distortion.value}set distortion(t){this._distortion.value=t}get mixContrast(){return this._mixContrast.value}set mixContrast(t){this._mixContrast.value=t}}const Nu=["texture-matrix","mirror","t-diffuse","t-depth","t-diffuse-blur","has-blur","mix-strength","min-depth-threshold","max-depth-threshold","depth-scale","depth-to-blur-ratio-bias","distortion","distortionMap","mix-contrast","defines-USE_BLUR","defines-USE_DEPTH","defines-USE_DISTORTION"],zu=f.defineComponent({__name:"index",props:{resolution:{default:256},mixBlur:{default:0},mixStrength:{default:1},blur:{default:()=>[0,0]},mirror:{default:0},minDepthThreshold:{default:.9},maxDepthThreshold:{default:1},depthScale:{default:0},depthToBlurRatioBias:{default:.25},distortionMap:{},distortion:{default:1},mixContrast:{default:1},reflectorOffset:{default:0}},setup(o){const e=o;function t(Z,X){let q;return Z.traverse(Y=>{Y.isMesh&&Y.material&&Y.material.uuid===X&&(q=Y)}),q}function n(Z){var q,Y;if(p.reflectorWorldPosition.setFromMatrixPosition(Z.matrixWorld),p.cameraWorldPosition.setFromMatrixPosition((q=v.value)==null?void 0:q.matrixWorld),p.rotationMatrix.extractRotation(Z.matrixWorld),p.normal.set(0,0,1),p.normal.applyMatrix4(p.rotationMatrix),p.reflectorWorldPosition.addScaledVector(p.normal,e.reflectorOffset),p.view.subVectors(p.reflectorWorldPosition,p.cameraWorldPosition),p.view.dot(p.normal)>0)return;p.view.reflect(p.normal).negate(),p.view.add(p.reflectorWorldPosition),p.rotationMatrix.extractRotation((Y=v.value)==null?void 0:Y.matrixWorld),p.lookAtPosition.set(0,0,-1),p.lookAtPosition.applyMatrix4(p.rotationMatrix),p.lookAtPosition.add(p.cameraWorldPosition),p.target.subVectors(p.reflectorWorldPosition,p.lookAtPosition),p.target.reflect(p.normal).negate(),p.target.add(p.reflectorWorldPosition),p.virtualCamera.position.copy(p.view),p.virtualCamera.up.set(0,1,0),p.virtualCamera.up.applyMatrix4(p.rotationMatrix),p.virtualCamera.up.reflect(p.normal),p.virtualCamera.lookAt(p.target),p.virtualCamera.far=(v==null?void 0:v.value).far,p.virtualCamera.updateMatrixWorld(),p.virtualCamera.projectionMatrix.copy((v==null?void 0:v.value).projectionMatrix),p.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),p.textureMatrix.multiply(p.virtualCamera.projectionMatrix),p.textureMatrix.multiply(p.virtualCamera.matrixWorldInverse),p.textureMatrix.multiply(Z.matrixWorld),p.reflectorPlane.setFromNormalAndCoplanarPoint(p.normal,p.reflectorWorldPosition),p.reflectorPlane.applyMatrix4(p.virtualCamera.matrixWorldInverse),p.clipPlane.set(p.reflectorPlane.normal.x,p.reflectorPlane.normal.y,p.reflectorPlane.normal.z,p.reflectorPlane.constant);const X=p.virtualCamera.projectionMatrix;p.q.x=(Math.sign(p.clipPlane.x)+X.elements[8])/X.elements[0],p.q.y=(Math.sign(p.clipPlane.y)+X.elements[9])/X.elements[5],p.q.z=-1,p.q.w=(1+X.elements[10])/X.elements[14],p.clipPlane.multiplyScalar(2/p.clipPlane.dot(p.q)),X.elements[2]=p.clipPlane.x,X.elements[6]=p.clipPlane.y,X.elements[10]=p.clipPlane.z+1,X.elements[14]=p.clipPlane.w}const{resolution:r,minDepthThreshold:s,maxDepthThreshold:i,depthScale:a,depthToBlurRatioBias:l,blur:u,mirror:h,mixBlur:d,mixStrength:g,distortion:y,distortionMap:x,mixContrast:w}=f.toRefs(e),{camera:v,scene:A,renderer:D,extend:M}=ae.useTresContext();M({MeshReflectorMaterial:Uu});const _=f.shallowRef(),L=f.shallowRef(),b=f.shallowRef(),C=f.shallowRef(),m=f.computed(()=>typeof u.value=="number"?[u.value,u.value]:u.value),S=f.computed(()=>m.value[0]>0||m.value[1]>0),p={reflectorPlane:new c.Plane,normal:new c.Vector3,reflectorWorldPosition:new c.Vector3,cameraWorldPosition:new c.Vector3,rotationMatrix:new c.Matrix4,lookAtPosition:new c.Vector3(0,0,-1),clipPlane:new c.Vector4,view:new c.Vector3,target:new c.Vector3,q:new c.Vector4,virtualCamera:new c.PerspectiveCamera,textureMatrix:new c.Matrix4};f.watchEffect(()=>{var X;(X=_.value)==null||X.texture.dispose();const Z={minFilter:c.LinearFilter,magFilter:c.LinearFilter,type:c.HalfFloatType};_.value=new c.WebGLRenderTarget(r.value,r.value,{...Z,depthBuffer:!0,depthTexture:new c.DepthTexture(r.value,r.value,c.DepthFormat,c.UnsignedShortType)}),L.value=new c.WebGLRenderTarget(r.value,r.value,Z),b.value=new Fu({resolution:r.value,width:m.value[0],height:m.value[1],minDepthThreshold:s.value,maxDepthThreshold:i.value,depthScale:a.value,depthToBlurRatioBias:l.value}),C.value={mirror:h,textureMatrix:p.textureMatrix,mixBlur:d,tDiffuse:_.value.texture,tDepth:_.value.depthTexture,tDiffuseBlur:_.value.texture,hasBlur:S,mixStrength:g,minDepthThreshold:s,maxDepthThreshold:i,depthScale:a,depthToBlurRatioBias:l,distortion:y,distortionMap:x.value,mixContrast:w,"defines-USE_BLUR":S.value?"":void 0,"defines-USE_DEPTH":a.value>0?"":void 0,"defines-USE_DISTORTION":x.value?"":void 0}});const I=f.shallowRef(),{onLoop:k}=ae.useRenderLoop();k(()=>{var Y;if(!I.value||!D.value||!_.value||!v.value)return;const Z=t(A.value,I.value.uuid);if(!Z)return;Z.visible=!1;const X=D.value.xr.enabled,q=D.value.shadowMap.autoUpdate;n(Z),D.value.shadowMap.autoUpdate=!1,D.value.setRenderTarget(_.value),D.value.autoClear||D.value.clear(),D.value.render(A.value,p.virtualCamera),(Y=b==null?void 0:b.value)==null||Y.render(D.value,_.value,L.value),D.value.xr.enabled=X,D.value.shadowMap.autoUpdate=q,Z.visible=!0,D.value.setRenderTarget(null)});const J=f.useAttrs(),R=f.computed(()=>{const Z={};return Object.assign(Z,e),Object.assign(Z,J.value),Z});return f.onBeforeUnmount(()=>{var Z,X;(Z=_==null?void 0:_.value)==null||Z.dispose(),(X=L==null?void 0:L.value)==null||X.dispose()}),(Z,X)=>{var q,Y,te;return f.openBlock(),f.createElementBlock("TresMeshReflectorMaterial",f.mergeProps({key:`key${C.value["defines-USE_BLUR"]}${C.value["defines-USE_DEPTH"]}${C.value["defines-USE_DISTORTION"]}`,ref_key:"materialRef",ref:I},R.value,{"texture-matrix":p.textureMatrix,mirror:f.unref(h),"t-diffuse":(q=_.value)==null?void 0:q.texture,"t-depth":(Y=_.value)==null?void 0:Y.depthTexture,"t-diffuse-blur":(te=L.value)==null?void 0:te.texture,"has-blur":S.value,"mix-strength":f.unref(g),"min-depth-threshold":f.unref(s),"max-depth-threshold":f.unref(i),"depth-scale":f.unref(a),"depth-to-blur-ratio-bias":f.unref(l),distortion:f.unref(y),distortionMap:f.unref(x),"mix-contrast":f.unref(w),"defines-USE_BLUR":S.value?"":void 0,"defines-USE_DEPTH":f.unref(a)>0?"":void 0,"defines-USE_DISTORTION":f.unref(x)?"":void 0}),null,16,Nu)}}}),Vu=["args"],Ru=["color"],Gu=f.defineComponent({__name:"Box",props:{args:{default:()=>[1,1,1]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=f.toRefs(t),s=f.shallowRef();return e({value:s}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"boxRef",ref:s},i.$attrs),[f.createElementVNode("TresBoxGeometry",{args:f.unref(n)},null,8,Vu),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(r)},null,8,Ru)])],16))}}),Si=new c.Box3,On=new c.Vector3;class Ai extends c.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],n=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(n),this.setAttribute("position",new c.Float32BufferAttribute(e,3)),this.setAttribute("uv",new c.Float32BufferAttribute(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new c.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceStart",new c.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceEnd",new c.InterleavedBufferAttribute(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const n=new c.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceColorStart",new c.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceColorEnd",new c.InterleavedBufferAttribute(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new c.WireframeGeometry(e.geometry)),this}fromLineSegments(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new c.Box3);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),Si.setFromBufferAttribute(t),this.boundingBox.union(Si))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new c.Sphere),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let s=0,i=e.count;s<i;s++)On.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(On)),On.fromBufferAttribute(t,s),r=Math.max(r,n.distanceToSquared(On));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}c.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new c.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},c.ShaderLib.line={uniforms:c.UniformsUtils.merge([c.UniformsLib.common,c.UniformsLib.fog,c.UniformsLib.line]),vertexShader:`
|
|
563
563
|
#include <common>
|
|
564
564
|
#include <color_pars_vertex>
|
|
565
565
|
#include <fog_pars_vertex>
|
|
@@ -929,9 +929,9 @@ list should be an Array.`),T.length===0)return new v(0);if(T.length===1)return T
|
|
|
929
929
|
#include <premultiplied_alpha_fragment>
|
|
930
930
|
|
|
931
931
|
}
|
|
932
|
-
`};class Ps extends c.ShaderMaterial{constructor(e){super({type:"LineMaterial",uniforms:c.UniformsUtils.clone(c.ShaderLib.line.uniforms),vertexShader:c.ShaderLib.line.vertexShader,fragmentShader:c.ShaderLib.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1))}}const Si=new c.Vector3,Ai=new c.Vector3,Be=new c.Vector4,Ue=new c.Vector4,tt=new c.Vector4,Cs=new c.Vector3,Ts=new c.Matrix4,Ne=new c.Line3,Pi=new c.Vector3,Dn=new c.Box3,On=new c.Sphere,nt=new c.Vector4;let st,Ct;function Ci(o,e,t){return nt.set(0,0,-e,1).applyMatrix4(o.projectionMatrix),nt.multiplyScalar(1/nt.w),nt.x=Ct/t.width,nt.y=Ct/t.height,nt.applyMatrix4(o.projectionMatrixInverse),nt.multiplyScalar(1/nt.w),Math.abs(Math.max(nt.x,nt.y))}function Vu(o,e){const t=o.matrixWorld,n=o.geometry,s=n.attributes.instanceStart,r=n.attributes.instanceEnd,i=Math.min(n.instanceCount,s.count);for(let a=0,l=i;a<l;a++){Ne.start.fromBufferAttribute(s,a),Ne.end.fromBufferAttribute(r,a),Ne.applyMatrix4(t);const u=new c.Vector3,h=new c.Vector3;st.distanceSqToSegment(Ne.start,Ne.end,h,u),h.distanceTo(u)<Ct*.5&&e.push({point:h,pointOnLine:u,distance:st.origin.distanceTo(h),object:o,face:null,faceIndex:a,uv:null,uv1:null})}}function Ru(o,e,t){const n=e.projectionMatrix,r=o.material.resolution,i=o.matrixWorld,a=o.geometry,l=a.attributes.instanceStart,u=a.attributes.instanceEnd,h=Math.min(a.instanceCount,l.count),d=-e.near;st.at(1,tt),tt.w=1,tt.applyMatrix4(e.matrixWorldInverse),tt.applyMatrix4(n),tt.multiplyScalar(1/tt.w),tt.x*=r.x/2,tt.y*=r.y/2,tt.z=0,Cs.copy(tt),Ts.multiplyMatrices(e.matrixWorldInverse,i);for(let y=0,g=h;y<g;y++){if(Be.fromBufferAttribute(l,y),Ue.fromBufferAttribute(u,y),Be.w=1,Ue.w=1,Be.applyMatrix4(Ts),Ue.applyMatrix4(Ts),Be.z>d&&Ue.z>d)continue;if(Be.z>d){const S=Be.z-Ue.z,_=(Be.z-d)/S;Be.lerp(Ue,_)}else if(Ue.z>d){const S=Ue.z-Be.z,_=(Ue.z-d)/S;Ue.lerp(Be,_)}Be.applyMatrix4(n),Ue.applyMatrix4(n),Be.multiplyScalar(1/Be.w),Ue.multiplyScalar(1/Ue.w),Be.x*=r.x/2,Be.y*=r.y/2,Ue.x*=r.x/2,Ue.y*=r.y/2,Ne.start.copy(Be),Ne.start.z=0,Ne.end.copy(Ue),Ne.end.z=0;const w=Ne.closestPointToPointParameter(Cs,!0);Ne.at(w,Pi);const v=c.MathUtils.lerp(Be.z,Ue.z,w),P=v>=-1&&v<=1,D=Cs.distanceTo(Pi)<Ct*.5;if(P&&D){Ne.start.fromBufferAttribute(l,y),Ne.end.fromBufferAttribute(u,y),Ne.start.applyMatrix4(i),Ne.end.applyMatrix4(i);const S=new c.Vector3,_=new c.Vector3;st.distanceSqToSegment(Ne.start,Ne.end,_,S),t.push({point:_,pointOnLine:S,distance:st.origin.distanceTo(_),object:o,face:null,faceIndex:y,uv:null,uv1:null})}}}class Gu extends c.Mesh{constructor(e=new Mi,t=new Ps({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,s=new Float32Array(2*t.count);for(let i=0,a=0,l=t.count;i<l;i++,a+=2)Si.fromBufferAttribute(t,i),Ai.fromBufferAttribute(n,i),s[a]=a===0?0:s[a-1],s[a+1]=s[a]+Si.distanceTo(Ai);const r=new c.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new c.InterleavedBufferAttribute(r,1,0)),e.setAttribute("instanceDistanceEnd",new c.InterleavedBufferAttribute(r,1,1)),this}raycast(e,t){const n=this.material.worldUnits,s=e.camera;s===null&&!n&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const r=e.params.Line2!==void 0&&e.params.Line2.threshold||0;st=e.ray;const i=this.matrixWorld,a=this.geometry,l=this.material;Ct=l.linewidth+r,a.boundingSphere===null&&a.computeBoundingSphere(),On.copy(a.boundingSphere).applyMatrix4(i);let u;if(n)u=Ct*.5;else{const d=Math.max(s.near,On.distanceToPoint(st.origin));u=Ci(s,d,l.resolution)}if(On.radius+=u,st.intersectsSphere(On)===!1)return;a.boundingBox===null&&a.computeBoundingBox(),Dn.copy(a.boundingBox).applyMatrix4(i);let h;if(n)h=Ct*.5;else{const d=Math.max(s.near,Dn.distanceToPoint(st.origin));h=Ci(s,d,l.resolution)}Dn.expandByScalar(h),st.intersectsBox(Dn)!==!1&&(n?Vu(this,t):Ru(this,s,t))}}class Ti extends Mi{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const t=e.length-3,n=new Float32Array(2*t);for(let s=0;s<t;s+=3)n[2*s]=e[s],n[2*s+1]=e[s+1],n[2*s+2]=e[s+2],n[2*s+3]=e[s+3],n[2*s+4]=e[s+4],n[2*s+5]=e[s+5];return super.setPositions(n),this}setColors(e){const t=e.length-3,n=new Float32Array(2*t);for(let s=0;s<t;s+=3)n[2*s]=e[s],n[2*s+1]=e[s+1],n[2*s+2]=e[s+2],n[2*s+3]=e[s+3],n[2*s+4]=e[s+4],n[2*s+5]=e[s+5];return super.setColors(n),this}fromLine(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}}class ju extends Gu{constructor(e=new Ti,t=new Ps({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type="Line2"}}const Eu=["object"],Li=f.defineComponent({__name:"Line2",props:{points:{},vertexColors:{default:null},color:{default:"white"},lineWidth:{default:1},worldUnits:{type:Boolean,default:!1},alphaToCoverage:{type:Boolean,default:!1},dashed:{type:Boolean,default:!1},dashSize:{default:1},gapSize:{default:1},dashScale:{default:1},dashOffset:{default:0}},setup(o){const e=o;function t(h,d){if(!h||h.length===0)return new Array(d).fill(ae.normalizeColor(e.color));if(h.length===1)return new Array(d).fill(ae.normalizeColor(h[0]));if(h.length===d)return h.map(ae.normalizeColor);const y=d-1,g=h.map(ae.normalizeColor);closed&&g.push(g[0].clone());const x=[g[0]],w=y/(g.length-1);for(let v=1;v<y;v++){const P=v%w/w,D=Math.floor(v/w);x.push(g[D].clone().lerp(g[D+1],P))}return x.push(g[g.length-1]),x}function n(h,d,y){const g=d.map(w=>w instanceof c.Vector3?[w.x,w.y,w.z]:w instanceof c.Vector2?[w.x,w.y,0]:Array.isArray(w)&&w.length===2?[w[0],w[1],0]:w).flat();h.setPositions(g.flat());const x=t(y,d.length).map(w=>w.toArray()).flat();h.setColors(x),a.computeLineDistances()}function s(h,d){h.color=ae.normalizeColor(d.color),h.linewidth=d.lineWidth,h.alphaToCoverage=d.alphaToCoverage,h.worldUnits=d.worldUnits,h.vertexColors=Array.isArray(d.vertexColors),h.dashed=d.dashed,h.dashScale=d.dashScale,h.dashSize=d.dashSize,h.dashOffset=d.dashOffset,h.gapSize=d.gapSize,h.needsUpdate=!0}const r=new Ps,i=new Ti,a=new ju(i,r),l=ae.useTresContext().sizes,u=f.computed(()=>Array.isArray(e.vertexColors));return s(r,e),n(i,e.points,e.vertexColors),a.computeLineDistances(),f.watch(()=>[e.color,e.lineWidth,e.alphaToCoverage,e.worldUnits,u,e.dashed,e.dashScale,e.dashSize,e.dashOffset],()=>s(r,e)),f.watch([e.points,e.vertexColors],()=>n(i,e.points,e.vertexColors)),f.watch(()=>e.vertexColors,()=>n(i,e.points,e.vertexColors)),f.watch(()=>e.points,()=>n(i,e.points,e.vertexColors)),f.watch([l.height,l.width],()=>r.resolution=new c.Vector2(l.width.value,l.height.value)),f.onUnmounted(()=>{i.dispose(),r.dispose()}),(h,d)=>(f.openBlock(),f.createElementBlock("primitive",{object:f.unref(a)},null,8,Eu))}}),Yu=f.defineComponent({__name:"CatmullRomCurve3",props:{segments:{default:20},closed:{type:Boolean,default:!1},curveType:{default:"centripetal"},tension:{default:.5},points:{},vertexColors:{},color:{},lineWidth:{},alphaToCoverage:{type:Boolean},dashed:{type:Boolean},dashSize:{},dashScale:{},dashOffset:{},gapSize:{},worldUnits:{type:Boolean}},setup(o){const e=o;function t(i,a,l,u){const h=i.map(d=>d instanceof c.Vector3?d:new c.Vector3(...d));return new c.CatmullRomCurve3(h,a,l,u)}function n(i,a){return i.getPoints(a)}const s=f.computed(()=>t(e.points,e.closed,e.curveType,e.tension)),r=f.computed(()=>n(s.value,e.segments));return(i,a)=>(f.openBlock(),f.createBlock(Li,{points:r.value,"vertex-colors":e.vertexColors,color:e.color,lineWidth:e.lineWidth,alphaToCoverage:e.alphaToCoverage,dashed:e.dashed,dashSize:e.dashSize,dashScale:e.dashScale,dashOffset:e.dashOffset,gapSize:e.gapSize,worldUnits:e.worldUnits},null,8,["points","vertex-colors","color","lineWidth","alphaToCoverage","dashed","dashSize","dashScale","dashOffset","gapSize","worldUnits"]))}}),Xu=["args"],Wu=["color"],Zu=f.defineComponent({__name:"Circle",props:{args:{default:()=>[1,32,0,Math.PI*2]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:s}=f.toRefs(t),r=f.shallowRef();return e({value:r}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"circleRef",ref:r},i.$attrs),[f.createElementVNode("TresCircleGeometry",{args:f.unref(n)},null,8,Xu),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(s)},null,8,Wu)])],16))}}),Ku=["args"],qu=["color"],Qu=f.defineComponent({__name:"Cone",props:{args:{default:()=>[1,1,12,12,!1,0,Math.PI*2]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:s}=f.toRefs(t),r=f.shallowRef();return e({value:r}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"coneRef",ref:r},i.$attrs),[f.createElementVNode("TresConeGeometry",{args:f.unref(n)},null,8,Ku),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(s)},null,8,qu)])],16))}}),Ju=["args"],Hu=["color"],$u=f.defineComponent({__name:"Dodecahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:s}=f.toRefs(t),r=f.shallowRef();return e({value:r}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"dodecahedronRef",ref:r},i.$attrs),[f.createElementVNode("TresDodecahedronGeometry",{args:f.unref(n)},null,8,Ju),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(s)},null,8,Hu)])],16))}}),eh=["args"],th=["color"],nh=f.defineComponent({__name:"Icosahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:s}=f.toRefs(t),r=f.shallowRef();return e({value:r}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"icosahedronRef",ref:r},i.$attrs),[f.createElementVNode("TresIcosahedronGeometry",{args:f.unref(n)},null,8,eh),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(s)},null,8,th)])],16))}}),sh=["args"],rh=["color"],ih=f.defineComponent({__name:"Octahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:s}=f.toRefs(t),r=f.shallowRef();return e({value:r}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"octahedronRef",ref:r},i.$attrs),[f.createElementVNode("TresOctahedronGeometry",{args:f.unref(n)},null,8,sh),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(s)},null,8,rh)])],16))}}),oh=["rotation"],ah=["args"],lh=["color"],ch=f.defineComponent({__name:"Plane",props:{args:{default:()=>[1,1]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:s}=f.toRefs(t),r=f.shallowRef();return e({value:r}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"planeRef",ref:r,rotation:[-Math.PI/2,0,0]},i.$attrs),[f.createElementVNode("TresPlaneGeometry",{args:f.unref(n)},null,8,ah),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(s)},null,8,lh)])],16,oh))}}),uh=["args"],hh=["color"],fh=f.defineComponent({__name:"Ring",props:{args:{default:()=>[.5,1,32]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:s}=f.toRefs(t),r=f.shallowRef();return e({value:r}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"ringRef",ref:r},i.$attrs),[f.createElementVNode("TresRingGeometry",{args:f.unref(n)},null,8,uh),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(s)},null,8,hh)])],16))}}),dh=["args"],ph=["color"],mh=f.defineComponent({__name:"Sphere",props:{args:{default:()=>[2,32,16]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:s}=f.toRefs(t),r=f.shallowRef();return e({value:r}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"sphereRef",ref:r},i.$attrs),[f.createElementVNode("TresSphereGeometry",{args:f.unref(n)},null,8,dh),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(s)},null,8,ph)])],16))}}),gh=["geometry"],yh=["color"],_h=f.defineComponent({__name:"Superformula",props:{widthSegments:{default:32},heightSegments:{default:32},numArmsA:{default:4},expA:{default:()=>[40,1.3,.9]},numArmsB:{default:4},expB:{default:()=>[40,1.3,.9]},color:{default:"white"}},setup(o,{expose:e}){const t=o,{cos:n,sin:s,abs:r}=Math,i=f.shallowRef(),a=f.shallowRef(t.color);function l(y,g){const x=new c.BufferGeometry,w=y*g,v=new Float32Array(new Array(3*w).fill(0)),P=new Float32Array(new Array(3*w).fill(0)),D=[];for(let S=0;S<g-1;S++){for(let m=0;m<y-1;m++){const M=S*y+m,p=M+1,I=M+y,F=p+y;D.push(M,I,p),D.push(I,F,p)}const _=S*y+y-1,L=S*y,b=_+y,C=L+y;D.push(_,b,L),D.push(b,C,L)}return x.setIndex(D),x.setAttribute("position",new c.BufferAttribute(v,3)),x.setAttribute("normal",new c.BufferAttribute(P,3)),x}function u(y,g,x,w,v){return(r(n(g*y*.25))**w+r(s(g*y*.25))**v)**(-1/x)}function h(y,g,x,w,v,P,D,S,_,L,b){const C=2*Math.PI/L,m=-Math.PI,M=Math.PI/(b-1),p=-.5*Math.PI,I=y.getAttribute("position");let F=0,J=0,G=p;for(let Q=0;Q<b;Q++){J=m;for(let K=0;K<L;K++){const Z=u(J,g,x,w,v),X=u(G,P,D,S,_);I.setXYZ(F,Z*n(J)*X*n(G),X*s(G),Z*s(J)*X*n(G)),F++,J+=C}G+=M}I.needsUpdate=!0,y.computeVertexNormals()}f.watch(()=>t.color,()=>a.value=t.color),f.watch(()=>[t.widthSegments,t.heightSegments],()=>{i.value&&i.value.dispose(),i.value=l(t.widthSegments,t.heightSegments)},{immediate:!0}),f.watch(()=>[t.numArmsA,t.expA[0],t.expA[1],t.expA[2],t.numArmsB,t.expB[0],t.expB[1],t.expB[2]],()=>h(i.value,t.numArmsA,t.expA[0],t.expA[1],t.expA[2],t.numArmsB,t.expB[0],t.expB[1],t.expB[2],t.widthSegments,t.heightSegments),{immediate:!0}),f.onUnmounted(()=>{i.value&&i.value.dispose()});const d=f.shallowRef();return e({value:d}),(y,g)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"superformulaRef",ref:d},y.$attrs,{geometry:i.value}),[f.renderSlot(y.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:a.value},null,8,yh)])],16,gh))}}),vh=["rotation"],xh=["args"],wh=["color"],bh=f.defineComponent({__name:"Tetrahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:s}=f.toRefs(t),r=f.shallowRef();return e({value:r}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"tetrahedronRef",ref:r,rotation:[-Math.PI/2,0,0]},i.$attrs),[f.createElementVNode("TresTetrahedronGeometry",{args:f.unref(n)},null,8,xh),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(s)},null,8,wh)])],16,vh))}}),Mh=["args"],Sh=["color"],Ah=f.defineComponent({__name:"Torus",props:{args:{default:()=>[1,1,16,80]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:s}=f.toRefs(t),r=f.shallowRef();return e({value:r}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"torusRef",ref:r},i.$attrs),[f.createElementVNode("TresTorusGeometry",{args:f.unref(n)},null,8,Mh),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(s)},null,8,Sh)])],16))}}),Ph=["args"],Ch=["color"],Th=f.defineComponent({__name:"TorusKnot",props:{args:{default:()=>[1,.4,64,8]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:s}=f.toRefs(t),r=f.shallowRef();return e({value:r}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"torusKnotRef",ref:r},i.$attrs),[f.createElementVNode("TresTorusKnotGeometry",{args:f.unref(n)},null,8,Ph),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(s)},null,8,Ch)])],16))}}),Lh=["args"],Ih=["color"],Dh=f.defineComponent({__name:"Tube",props:{args:{default:()=>[new c.QuadraticBezierCurve3(new c.Vector3(-1,0,0),new c.Vector3(0,1,0),new c.Vector3(1,0,0)),20,.2,8,!1]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:s}=f.toRefs(t),r=f.shallowRef();return e({value:r}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"tubeRef",ref:r},i.$attrs),[f.createElementVNode("TresTubeGeometry",{args:f.unref(n)},null,8,Lh),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(s)},null,8,Ih)])],16))}}),Oh=f.defineComponent({__name:"component",props:{background:{type:[Boolean,String],default:!1},blur:{default:0},files:{default:[]},path:{default:""},preset:{default:void 0}},async setup(o,{expose:e}){let t,n;const s=o,r=f.ref(null);return e(r),r.value=([t,n]=f.withAsyncContext(()=>Vr(s).texture),t=await t,n(),t),()=>{}}}),Fh=["receive-shadow","rotation"],kh=["args"],Bh=f.createElementVNode("TresMeshStandardMaterial",{color:8421504,side:2},null,-1),Uh=f.defineComponent({__name:"Backdrop",props:{floor:{default:.25},segments:{default:20},receiveShadow:{type:Boolean,default:!1}},setup(o){const e=o,t=a=>a===0?0:2**(10*a-10),{floor:n,segments:s,receiveShadow:r}=f.toRefs(e),i=f.ref(null);return f.watch(()=>[s.value,n.value,i.value],([a,l,u])=>{if(!u||a===null)return;let h=0;const d=a/a/2,y=u.attributes.position;for(let g=0;g<a+1;g++)for(let x=0;x<a+1;x++)y.setXYZ(h++,g/a-d+(g===0?-l:0),x/a-d,t(g/a));y.needsUpdate=!0,u.computeVertexNormals()}),(a,l)=>(f.openBlock(),f.createElementBlock("TresGroup",f.normalizeProps(f.guardReactiveProps(a.$attrs)),[f.createElementVNode("TresMesh",{"receive-shadow":f.unref(r),rotation:[-Math.PI/2,0,Math.PI/2]},[f.createElementVNode("TresPlaneGeometry",{ref_key:"planeRef",ref:i,args:[1,1,f.unref(s),f.unref(s)]},null,8,kh),f.renderSlot(a.$slots,"default",{},()=>[Bh])],8,Fh)],16))}}),Nh=["geometry"],zh=["map","opacity","depth-write"],Vh=["object"],Rh=["args"],Gh=["rotation","args"],jh=f.defineComponent({__name:"ContactShadows",props:{opacity:{default:1},width:{default:1},height:{default:1},blur:{default:1},far:{default:10},smooth:{type:Boolean,default:!0},resolution:{default:512},frames:{default:1/0},scale:{default:10},color:{default:"#000000"},depthWrite:{type:Boolean,default:!1},helper:{type:Boolean,default:!1}},setup(o,{expose:e}){const t=o,n=f.shallowRef(),s=f.shallowRef();e(n);let r,i,a,l,u;const{renderer:h,scene:d}=ae.useTresContext(),y=f.computed(()=>t.width*(Array.isArray(t.scale)?t.scale[0]:t.scale||1)),g=f.computed(()=>t.height*(Array.isArray(t.scale)?t.scale[1]:t.scale||1));f.watchEffect(()=>{r&&r.dispose(),i&&i.dispose(),a&&a.dispose(),l&&l.geometry.dispose(),r=new c.WebGLRenderTarget(t.resolution,t.resolution),i=new c.WebGLRenderTarget(t.resolution,t.resolution),i.texture.generateMipmaps=r.texture.generateMipmaps=!1,s.value=new c.OrthographicCamera(-y.value/2,y.value/2,g.value/2,-g.value/2,0,t.far),a=new c.PlaneGeometry(y.value,g.value).rotateX(Math.PI/2),l=new c.Mesh(a),l.visible=!1}),f.watchEffect(()=>{t.color&&(u&&u.dispose(),u=new c.MeshDepthMaterial,u.depthTest=u.depthWrite=!1,u.onBeforeCompile=L=>{L.uniforms={...L.uniforms,ucolor:{value:t.color?new c.Color(t.color):new c.Color}},L.fragmentShader=L.fragmentShader.replace("void main() {",`uniform vec3 ucolor;
|
|
932
|
+
`};class Tr extends c.ShaderMaterial{constructor(e){super({type:"LineMaterial",uniforms:c.UniformsUtils.clone(c.ShaderLib.line.uniforms),vertexShader:c.ShaderLib.line.vertexShader,fragmentShader:c.ShaderLib.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1))}}const Pi=new c.Vector3,Ci=new c.Vector3,Fe=new c.Vector4,Ue=new c.Vector4,nt=new c.Vector4,Lr=new c.Vector3,Dr=new c.Matrix4,Ne=new c.Line3,Ti=new c.Vector3,kn=new c.Box3,Bn=new c.Sphere,rt=new c.Vector4;let st,Tt;function Li(o,e,t){return rt.set(0,0,-e,1).applyMatrix4(o.projectionMatrix),rt.multiplyScalar(1/rt.w),rt.x=Tt/t.width,rt.y=Tt/t.height,rt.applyMatrix4(o.projectionMatrixInverse),rt.multiplyScalar(1/rt.w),Math.abs(Math.max(rt.x,rt.y))}function ju(o,e){const t=o.matrixWorld,n=o.geometry,r=n.attributes.instanceStart,s=n.attributes.instanceEnd,i=Math.min(n.instanceCount,r.count);for(let a=0,l=i;a<l;a++){Ne.start.fromBufferAttribute(r,a),Ne.end.fromBufferAttribute(s,a),Ne.applyMatrix4(t);const u=new c.Vector3,h=new c.Vector3;st.distanceSqToSegment(Ne.start,Ne.end,h,u),h.distanceTo(u)<Tt*.5&&e.push({point:h,pointOnLine:u,distance:st.origin.distanceTo(h),object:o,face:null,faceIndex:a,uv:null,uv1:null})}}function Eu(o,e,t){const n=e.projectionMatrix,s=o.material.resolution,i=o.matrixWorld,a=o.geometry,l=a.attributes.instanceStart,u=a.attributes.instanceEnd,h=Math.min(a.instanceCount,l.count),d=-e.near;st.at(1,nt),nt.w=1,nt.applyMatrix4(e.matrixWorldInverse),nt.applyMatrix4(n),nt.multiplyScalar(1/nt.w),nt.x*=s.x/2,nt.y*=s.y/2,nt.z=0,Lr.copy(nt),Dr.multiplyMatrices(e.matrixWorldInverse,i);for(let g=0,y=h;g<y;g++){if(Fe.fromBufferAttribute(l,g),Ue.fromBufferAttribute(u,g),Fe.w=1,Ue.w=1,Fe.applyMatrix4(Dr),Ue.applyMatrix4(Dr),Fe.z>d&&Ue.z>d)continue;if(Fe.z>d){const M=Fe.z-Ue.z,_=(Fe.z-d)/M;Fe.lerp(Ue,_)}else if(Ue.z>d){const M=Ue.z-Fe.z,_=(Ue.z-d)/M;Ue.lerp(Fe,_)}Fe.applyMatrix4(n),Ue.applyMatrix4(n),Fe.multiplyScalar(1/Fe.w),Ue.multiplyScalar(1/Ue.w),Fe.x*=s.x/2,Fe.y*=s.y/2,Ue.x*=s.x/2,Ue.y*=s.y/2,Ne.start.copy(Fe),Ne.start.z=0,Ne.end.copy(Ue),Ne.end.z=0;const w=Ne.closestPointToPointParameter(Lr,!0);Ne.at(w,Ti);const v=c.MathUtils.lerp(Fe.z,Ue.z,w),A=v>=-1&&v<=1,D=Lr.distanceTo(Ti)<Tt*.5;if(A&&D){Ne.start.fromBufferAttribute(l,g),Ne.end.fromBufferAttribute(u,g),Ne.start.applyMatrix4(i),Ne.end.applyMatrix4(i);const M=new c.Vector3,_=new c.Vector3;st.distanceSqToSegment(Ne.start,Ne.end,_,M),t.push({point:_,pointOnLine:M,distance:st.origin.distanceTo(_),object:o,face:null,faceIndex:g,uv:null,uv1:null})}}}class Wu extends c.Mesh{constructor(e=new Ai,t=new Tr({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,r=new Float32Array(2*t.count);for(let i=0,a=0,l=t.count;i<l;i++,a+=2)Pi.fromBufferAttribute(t,i),Ci.fromBufferAttribute(n,i),r[a]=a===0?0:r[a-1],r[a+1]=r[a]+Pi.distanceTo(Ci);const s=new c.InstancedInterleavedBuffer(r,2,1);return e.setAttribute("instanceDistanceStart",new c.InterleavedBufferAttribute(s,1,0)),e.setAttribute("instanceDistanceEnd",new c.InterleavedBufferAttribute(s,1,1)),this}raycast(e,t){const n=this.material.worldUnits,r=e.camera;r===null&&!n&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const s=e.params.Line2!==void 0&&e.params.Line2.threshold||0;st=e.ray;const i=this.matrixWorld,a=this.geometry,l=this.material;Tt=l.linewidth+s,a.boundingSphere===null&&a.computeBoundingSphere(),Bn.copy(a.boundingSphere).applyMatrix4(i);let u;if(n)u=Tt*.5;else{const d=Math.max(r.near,Bn.distanceToPoint(st.origin));u=Li(r,d,l.resolution)}if(Bn.radius+=u,st.intersectsSphere(Bn)===!1)return;a.boundingBox===null&&a.computeBoundingBox(),kn.copy(a.boundingBox).applyMatrix4(i);let h;if(n)h=Tt*.5;else{const d=Math.max(r.near,kn.distanceToPoint(st.origin));h=Li(r,d,l.resolution)}kn.expandByScalar(h),st.intersectsBox(kn)!==!1&&(n?ju(this,t):Eu(this,r,t))}}class Di extends Ai{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}setPositions(e){const t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setPositions(n),this}setColors(e){const t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setColors(n),this}fromLine(e){const t=e.geometry;return this.setPositions(t.attributes.position.array),this}}class Yu extends Wu{constructor(e=new Di,t=new Tr({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type="Line2"}}const Xu=["object"],Ii=f.defineComponent({__name:"Line2",props:{points:{},vertexColors:{default:null},color:{default:"white"},lineWidth:{default:1},worldUnits:{type:Boolean,default:!1},alphaToCoverage:{type:Boolean,default:!1},dashed:{type:Boolean,default:!1},dashSize:{default:1},gapSize:{default:1},dashScale:{default:1},dashOffset:{default:0}},setup(o){const e=o;function t(h,d){if(!h||h.length===0)return new Array(d).fill(ae.normalizeColor(e.color));if(h.length===1)return new Array(d).fill(ae.normalizeColor(h[0]));if(h.length===d)return h.map(ae.normalizeColor);const g=d-1,y=h.map(ae.normalizeColor);closed&&y.push(y[0].clone());const x=[y[0]],w=g/(y.length-1);for(let v=1;v<g;v++){const A=v%w/w,D=Math.floor(v/w);x.push(y[D].clone().lerp(y[D+1],A))}return x.push(y[y.length-1]),x}function n(h,d,g){const y=d.map(w=>w instanceof c.Vector3?[w.x,w.y,w.z]:w instanceof c.Vector2?[w.x,w.y,0]:Array.isArray(w)&&w.length===2?[w[0],w[1],0]:w).flat();h.setPositions(y.flat());const x=t(g,d.length).map(w=>w.toArray()).flat();h.setColors(x),a.computeLineDistances()}function r(h,d){h.color=ae.normalizeColor(d.color),h.linewidth=d.lineWidth,h.alphaToCoverage=d.alphaToCoverage,h.worldUnits=d.worldUnits,h.vertexColors=Array.isArray(d.vertexColors),h.dashed=d.dashed,h.dashScale=d.dashScale,h.dashSize=d.dashSize,h.dashOffset=d.dashOffset,h.gapSize=d.gapSize,h.needsUpdate=!0}const s=new Tr,i=new Di,a=new Yu(i,s),l=ae.useTresContext().sizes,u=f.computed(()=>Array.isArray(e.vertexColors));return r(s,e),n(i,e.points,e.vertexColors),a.computeLineDistances(),f.watch(()=>[e.color,e.lineWidth,e.alphaToCoverage,e.worldUnits,u,e.dashed,e.dashScale,e.dashSize,e.dashOffset],()=>r(s,e)),f.watch([e.points,e.vertexColors],()=>n(i,e.points,e.vertexColors)),f.watch(()=>e.vertexColors,()=>n(i,e.points,e.vertexColors)),f.watch(()=>e.points,()=>n(i,e.points,e.vertexColors)),f.watch([l.height,l.width],()=>s.resolution=new c.Vector2(l.width.value,l.height.value)),f.onUnmounted(()=>{i.dispose(),s.dispose()}),(h,d)=>(f.openBlock(),f.createElementBlock("primitive",{object:f.unref(a)},null,8,Xu))}}),Zu=f.defineComponent({__name:"CatmullRomCurve3",props:{segments:{default:20},closed:{type:Boolean,default:!1},curveType:{default:"centripetal"},tension:{default:.5},points:{},vertexColors:{},color:{},lineWidth:{},alphaToCoverage:{type:Boolean},dashed:{type:Boolean},dashSize:{},dashScale:{},dashOffset:{},gapSize:{},worldUnits:{type:Boolean}},setup(o){const e=o;function t(i,a,l,u){const h=i.map(d=>d instanceof c.Vector3?d:new c.Vector3(...d));return new c.CatmullRomCurve3(h,a,l,u)}function n(i,a){return i.getPoints(a)}const r=f.computed(()=>t(e.points,e.closed,e.curveType,e.tension)),s=f.computed(()=>n(r.value,e.segments));return(i,a)=>(f.openBlock(),f.createBlock(Ii,{points:s.value,"vertex-colors":e.vertexColors,color:e.color,lineWidth:e.lineWidth,alphaToCoverage:e.alphaToCoverage,dashed:e.dashed,dashSize:e.dashSize,dashScale:e.dashScale,dashOffset:e.dashOffset,gapSize:e.gapSize,worldUnits:e.worldUnits},null,8,["points","vertex-colors","color","lineWidth","alphaToCoverage","dashed","dashSize","dashScale","dashOffset","gapSize","worldUnits"]))}}),Ku=["args"],qu=["color"],Qu=f.defineComponent({__name:"Circle",props:{args:{default:()=>[1,32,0,Math.PI*2]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=f.toRefs(t),s=f.shallowRef();return e({value:s}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"circleRef",ref:s},i.$attrs),[f.createElementVNode("TresCircleGeometry",{args:f.unref(n)},null,8,Ku),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(r)},null,8,qu)])],16))}}),Ju=["args"],Hu=["color"],$u=f.defineComponent({__name:"Cone",props:{args:{default:()=>[1,1,12,12,!1,0,Math.PI*2]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=f.toRefs(t),s=f.shallowRef();return e({value:s}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"coneRef",ref:s},i.$attrs),[f.createElementVNode("TresConeGeometry",{args:f.unref(n)},null,8,Ju),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(r)},null,8,Hu)])],16))}}),eh=["args"],th=["color"],nh=f.defineComponent({__name:"Dodecahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=f.toRefs(t),s=f.shallowRef();return e({value:s}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"dodecahedronRef",ref:s},i.$attrs),[f.createElementVNode("TresDodecahedronGeometry",{args:f.unref(n)},null,8,eh),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(r)},null,8,th)])],16))}}),rh=["args"],sh=["color"],ih=f.defineComponent({__name:"Icosahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=f.toRefs(t),s=f.shallowRef();return e({value:s}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"icosahedronRef",ref:s},i.$attrs),[f.createElementVNode("TresIcosahedronGeometry",{args:f.unref(n)},null,8,rh),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(r)},null,8,sh)])],16))}}),oh=["args"],ah=["color"],lh=f.defineComponent({__name:"Octahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=f.toRefs(t),s=f.shallowRef();return e({value:s}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"octahedronRef",ref:s},i.$attrs),[f.createElementVNode("TresOctahedronGeometry",{args:f.unref(n)},null,8,oh),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(r)},null,8,ah)])],16))}}),ch=["rotation"],uh=["args"],hh=["color"],fh=f.defineComponent({__name:"Plane",props:{args:{default:()=>[1,1]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=f.toRefs(t),s=f.shallowRef();return e({value:s}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"planeRef",ref:s,rotation:[-Math.PI/2,0,0]},i.$attrs),[f.createElementVNode("TresPlaneGeometry",{args:f.unref(n)},null,8,uh),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(r)},null,8,hh)])],16,ch))}}),dh=["args"],ph=["color"],mh=f.defineComponent({__name:"Ring",props:{args:{default:()=>[.5,1,32]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=f.toRefs(t),s=f.shallowRef();return e({value:s}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"ringRef",ref:s},i.$attrs),[f.createElementVNode("TresRingGeometry",{args:f.unref(n)},null,8,dh),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(r)},null,8,ph)])],16))}}),gh=["args"],yh=["color"],_h=f.defineComponent({__name:"RoundedBox",props:{args:{default:()=>[1,1,1,2,.1]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=f.toRefs(t),{extend:s}=ae.useTresContext();s({RoundedBoxGeometry:Sa});const i=f.shallowRef();return e({value:i}),(a,l)=>(f.openBlock(),f.createElementBlock("TresMesh",{ref_key:"roundedBoxRef",ref:i},[f.createElementVNode("TresRoundedBoxGeometry",{args:f.unref(n)},null,8,gh),f.renderSlot(a.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(r)},null,8,yh)])],512))}}),vh=["args"],xh=["color"],wh=f.defineComponent({__name:"Sphere",props:{args:{default:()=>[2,32,16]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=f.toRefs(t),s=f.shallowRef();return e({value:s}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"sphereRef",ref:s},i.$attrs),[f.createElementVNode("TresSphereGeometry",{args:f.unref(n)},null,8,vh),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(r)},null,8,xh)])],16))}}),bh=["geometry"],Mh=["color"],Sh=f.defineComponent({__name:"Superformula",props:{widthSegments:{default:32},heightSegments:{default:32},numArmsA:{default:4},expA:{default:()=>[40,1.3,.9]},numArmsB:{default:4},expB:{default:()=>[40,1.3,.9]},color:{default:"white"}},setup(o,{expose:e}){const t=o,{cos:n,sin:r,abs:s}=Math,i=f.shallowRef(),a=f.shallowRef(t.color);function l(g,y){const x=new c.BufferGeometry,w=g*y,v=new Float32Array(new Array(3*w).fill(0)),A=new Float32Array(new Array(3*w).fill(0)),D=[];for(let M=0;M<y-1;M++){for(let m=0;m<g-1;m++){const S=M*g+m,p=S+1,I=S+g,k=p+g;D.push(S,I,p),D.push(I,k,p)}const _=M*g+g-1,L=M*g,b=_+g,C=L+g;D.push(_,b,L),D.push(b,C,L)}return x.setIndex(D),x.setAttribute("position",new c.BufferAttribute(v,3)),x.setAttribute("normal",new c.BufferAttribute(A,3)),x}function u(g,y,x,w,v){return(s(n(y*g*.25))**w+s(r(y*g*.25))**v)**(-1/x)}function h(g,y,x,w,v,A,D,M,_,L,b){const C=2*Math.PI/L,m=-Math.PI,S=Math.PI/(b-1),p=-.5*Math.PI,I=g.getAttribute("position");let k=0,J=0,R=p;for(let Z=0;Z<b;Z++){J=m;for(let X=0;X<L;X++){const q=u(J,y,x,w,v),Y=u(R,A,D,M,_);I.setXYZ(k,q*n(J)*Y*n(R),Y*r(R),q*r(J)*Y*n(R)),k++,J+=C}R+=S}I.needsUpdate=!0,g.computeVertexNormals()}f.watch(()=>t.color,()=>a.value=t.color),f.watch(()=>[t.widthSegments,t.heightSegments],()=>{i.value&&i.value.dispose(),i.value=l(t.widthSegments,t.heightSegments)},{immediate:!0}),f.watch(()=>[t.numArmsA,t.expA[0],t.expA[1],t.expA[2],t.numArmsB,t.expB[0],t.expB[1],t.expB[2]],()=>h(i.value,t.numArmsA,t.expA[0],t.expA[1],t.expA[2],t.numArmsB,t.expB[0],t.expB[1],t.expB[2],t.widthSegments,t.heightSegments),{immediate:!0}),f.onUnmounted(()=>{i.value&&i.value.dispose()});const d=f.shallowRef();return e({value:d}),(g,y)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"superformulaRef",ref:d},g.$attrs,{geometry:i.value}),[f.renderSlot(g.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:a.value},null,8,Mh)])],16,bh))}}),Ah=["rotation"],Ph=["args"],Ch=["color"],Th=f.defineComponent({__name:"Tetrahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=f.toRefs(t),s=f.shallowRef();return e({value:s}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"tetrahedronRef",ref:s,rotation:[-Math.PI/2,0,0]},i.$attrs),[f.createElementVNode("TresTetrahedronGeometry",{args:f.unref(n)},null,8,Ph),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(r)},null,8,Ch)])],16,Ah))}}),Lh=["args"],Dh=["color"],Ih=f.defineComponent({__name:"Torus",props:{args:{default:()=>[1,1,16,80]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=f.toRefs(t),s=f.shallowRef();return e({value:s}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"torusRef",ref:s},i.$attrs),[f.createElementVNode("TresTorusGeometry",{args:f.unref(n)},null,8,Lh),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(r)},null,8,Dh)])],16))}}),Oh=["args"],kh=["color"],Bh=f.defineComponent({__name:"TorusKnot",props:{args:{default:()=>[1,.4,64,8]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=f.toRefs(t),s=f.shallowRef();return e({value:s}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"torusKnotRef",ref:s},i.$attrs),[f.createElementVNode("TresTorusKnotGeometry",{args:f.unref(n)},null,8,Oh),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(r)},null,8,kh)])],16))}}),Fh=["args"],Uh=["color"],Nh=f.defineComponent({__name:"Tube",props:{args:{default:()=>[new c.QuadraticBezierCurve3(new c.Vector3(-1,0,0),new c.Vector3(0,1,0),new c.Vector3(1,0,0)),20,.2,8,!1]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=f.toRefs(t),s=f.shallowRef();return e({value:s}),(i,a)=>(f.openBlock(),f.createElementBlock("TresMesh",f.mergeProps({ref_key:"tubeRef",ref:s},i.$attrs),[f.createElementVNode("TresTubeGeometry",{args:f.unref(n)},null,8,Fh),f.renderSlot(i.$slots,"default",{},()=>[f.createElementVNode("TresMeshBasicMaterial",{color:f.unref(r)},null,8,Uh)])],16))}}),zh=f.defineComponent({__name:"component",props:{background:{type:[Boolean,String],default:!1},blur:{default:0},files:{default:[]},path:{default:""},preset:{default:void 0}},async setup(o,{expose:e}){let t,n;const r=o,s=f.ref(null);return e(s),s.value=([t,n]=f.withAsyncContext(()=>Gs(r).texture),t=await t,n(),t),()=>{}}}),Vh=["receive-shadow","rotation"],Rh=["args"],Gh=f.createElementVNode("TresMeshStandardMaterial",{color:8421504,side:2},null,-1),jh=f.defineComponent({__name:"Backdrop",props:{floor:{default:.25},segments:{default:20},receiveShadow:{type:Boolean,default:!1}},setup(o){const e=o,t=a=>a===0?0:2**(10*a-10),{floor:n,segments:r,receiveShadow:s}=f.toRefs(e),i=f.ref(null);return f.watch(()=>[r.value,n.value,i.value],([a,l,u])=>{if(!u||a===null)return;let h=0;const d=a/a/2,g=u.attributes.position;for(let y=0;y<a+1;y++)for(let x=0;x<a+1;x++)g.setXYZ(h++,y/a-d+(y===0?-l:0),x/a-d,t(y/a));g.needsUpdate=!0,u.computeVertexNormals()}),(a,l)=>(f.openBlock(),f.createElementBlock("TresGroup",f.normalizeProps(f.guardReactiveProps(a.$attrs)),[f.createElementVNode("TresMesh",{"receive-shadow":f.unref(s),rotation:[-Math.PI/2,0,Math.PI/2]},[f.createElementVNode("TresPlaneGeometry",{ref_key:"planeRef",ref:i,args:[1,1,f.unref(r),f.unref(r)]},null,8,Rh),f.renderSlot(a.$slots,"default",{},()=>[Gh])],8,Vh)],16))}}),Eh=["geometry"],Wh=["map","opacity","depth-write"],Yh=["object"],Xh=["args"],Zh=["rotation","args"],Kh=f.defineComponent({__name:"ContactShadows",props:{opacity:{default:1},width:{default:1},height:{default:1},blur:{default:1},far:{default:10},smooth:{type:Boolean,default:!0},resolution:{default:512},frames:{default:1/0},scale:{default:10},color:{default:"#000000"},depthWrite:{type:Boolean,default:!1},helper:{type:Boolean,default:!1}},setup(o,{expose:e}){const t=o,n=f.shallowRef(),r=f.shallowRef();e(n);let s,i,a,l,u;const{renderer:h,scene:d}=ae.useTresContext(),g=f.computed(()=>t.width*(Array.isArray(t.scale)?t.scale[0]:t.scale||1)),y=f.computed(()=>t.height*(Array.isArray(t.scale)?t.scale[1]:t.scale||1));f.watchEffect(()=>{s&&s.dispose(),i&&i.dispose(),a&&a.dispose(),l&&l.geometry.dispose(),s=new c.WebGLRenderTarget(t.resolution,t.resolution),i=new c.WebGLRenderTarget(t.resolution,t.resolution),i.texture.generateMipmaps=s.texture.generateMipmaps=!1,r.value=new c.OrthographicCamera(-g.value/2,g.value/2,y.value/2,-y.value/2,0,t.far),a=new c.PlaneGeometry(g.value,y.value).rotateX(Math.PI/2),l=new c.Mesh(a),l.visible=!1}),f.watchEffect(()=>{t.color&&(u&&u.dispose(),u=new c.MeshDepthMaterial,u.depthTest=u.depthWrite=!1,u.onBeforeCompile=L=>{L.uniforms={...L.uniforms,ucolor:{value:t.color?new c.Color(t.color):new c.Color}},L.fragmentShader=L.fragmentShader.replace("void main() {",`uniform vec3 ucolor;
|
|
933
933
|
void main() {
|
|
934
|
-
`),L.fragmentShader=L.fragmentShader.replace("vec4( vec3( 1.0 - fragCoordZ ), opacity );","vec4( ucolor * fragCoordZ * 2.0, ( 1.0 - fragCoordZ ) * 1.0 );")})});const x=new c.ShaderMaterial(
|
|
934
|
+
`),L.fragmentShader=L.fragmentShader.replace("vec4( vec3( 1.0 - fragCoordZ ), opacity );","vec4( ucolor * fragCoordZ * 2.0, ( 1.0 - fragCoordZ ) * 1.0 );")})});const x=new c.ShaderMaterial(Aa),w=new c.ShaderMaterial(Pa);w.depthTest=x.depthTest=!1;function v(L){!h.value||!r.value||(l.visible=!0,l.material=x,x.uniforms.tDiffuse.value=s.texture,x.uniforms.h.value=L/256,h.value.setRenderTarget(i),h.value.render(l,r.value),l.material=w,w.uniforms.tDiffuse.value=i.texture,w.uniforms.v.value=L/256,h.value.setRenderTarget(s),h.value.render(l,r.value),l.visible=!1)}const{onLoop:A}=ae.useRenderLoop();let D=0,M,_;return A(()=>{!r.value||d.value===void 0||h.value===void 0||(t.frames===1/0||D<t.frames)&&(D++,M=d.value.background,_=d.value.overrideMaterial,n.value.visible=!1,d.value.background=null,d.value.overrideMaterial=u,h.value.setRenderTarget(s),h.value.render(d.value,r.value),v(t.blur),t.smooth&&v(t.blur*.4),h.value.setRenderTarget(null),n.value.visible=!0,d.value.background=M,d.value.overrideMaterial=_)}),(L,b)=>(f.openBlock(),f.createElementBlock("TresGroup",f.mergeProps({ref_key:"groupRef",ref:n},L.$attrs),[f.createElementVNode("TresMesh",{scale:[1,-1,1],geometry:f.unref(a)},[f.createElementVNode("TresMeshBasicMaterial",{map:f.unref(s).texture,opacity:L.opacity,"depth-write":L.depthWrite,transparent:!0},null,8,Wh)],8,Eh),f.createElementVNode("primitive",{object:f.unref(l)},null,8,Yh),r.value&&L.helper?(f.openBlock(),f.createElementBlock("TresCameraHelper",{key:0,args:[r.value]},null,8,Xh)):f.createCommentVNode("",!0),f.createElementVNode("TresOrthographicCamera",{ref_key:"shadowCamera",ref:r,position:[0,0,0],rotation:[Math.PI/2,0,0],args:[-g.value/2,g.value/2,y.value/2,-y.value/2,0,L.far]},null,8,Zh)],16))}}),qh=["size","color","alpha-map","map","opacity","alpha-test","depth-write","transparent","size-attenuation"],Qh=["position","velocity"],Jh=f.defineComponent({__name:"Precipitation",props:{size:{default:.1},area:{default:()=>[10,10,20]},color:{default:16777215},map:{},alphaMap:{},alphaTest:{default:.01},opacity:{default:.8},count:{default:5e3},speed:{default:.1},randomness:{default:.5},depthWrite:{type:Boolean,default:!1},transparent:{type:Boolean,default:!0},sizeAttenuation:{type:Boolean,default:!0}},setup(o){const e=o,{size:t,area:n,color:r,alphaMap:s,map:i,opacity:a,alphaTest:l,depthWrite:u,transparent:h,sizeAttenuation:d,count:g,speed:y,randomness:x}=f.toRefs(e),w=f.shallowRef();let v=[],A=[];const D=()=>{v=new Float32Array(g.value*3);for(let L=0;L<g.value;L++){const b=L*3;v[b]=(Math.random()-.5)*n.value[0],v[b+1]=(Math.random()-.5)*n.value[1],v[b+2]=(Math.random()-.5)*n.value[2]}},M=()=>{A=new Float32Array(g.value*2);for(let L=0;L<g.value*2;L+=2)A[L]=(Math.random()-.5)/5*y.value*x.value,A[L+1]=Math.random()/5*y.value+.01};M(),D(),f.watchEffect(()=>{M(),D()});const{onLoop:_}=ae.useRenderLoop();return _(()=>{var L,b;if((L=w.value)!=null&&L.attributes.position.array&&((b=w.value)!=null&&b.attributes.position.count)){const C=w.value.attributes.position.array;for(let m=0;m<w.value.attributes.position.count;m++){const S=A[m*2],p=A[m*2+1];C[m*3]+=S,C[m*3+1]-=p,(C[m*3]<=-n.value[0]/2||C[m*3]>=n.value[0]/2)&&(C[m*3]=C[m*3]*-1),(C[m*3+1]<=-n.value[1]/2||C[m*3+1]>=n.value[1]/2)&&(C[m*3+1]=C[m*3+1]*-1)}w.value.attributes.position.needsUpdate=!0}}),(L,b)=>(f.openBlock(),f.createElementBlock("TresPoints",null,[f.createElementVNode("TresPointsMaterial",{size:f.unref(t),color:f.unref(r),"alpha-map":f.unref(s),map:f.unref(i),opacity:f.unref(a),"alpha-test":f.unref(l),"depth-write":f.unref(u),transparent:f.unref(h),"size-attenuation":f.unref(d)},null,8,qh),f.createElementVNode("TresBufferGeometry",{ref_key:"geometryRef",ref:w,position:[f.unref(v),3],velocity:[f.unref(A)]},null,8,Qh)]))}});class Fn extends c.Mesh{constructor(){const e=Fn.SkyShader,t=new c.ShaderMaterial({name:e.name,uniforms:c.UniformsUtils.clone(e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,side:c.BackSide,depthWrite:!1});super(new c.BoxGeometry(1,1,1),t),this.isSky=!0}}Fn.SkyShader={name:"SkyShader",uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new c.Vector3},up:{value:new c.Vector3(0,1,0)}},vertexShader:`
|
|
935
935
|
uniform vec3 sunPosition;
|
|
936
936
|
uniform float rayleigh;
|
|
937
937
|
uniform float turbidity;
|
|
@@ -1084,7 +1084,7 @@ list should be an Array.`),T.length===0)return new v(0);if(T.length===1)return T
|
|
|
1084
1084
|
#include <tonemapping_fragment>
|
|
1085
1085
|
#include <colorspace_fragment>
|
|
1086
1086
|
|
|
1087
|
-
}`};const Wh=["object","material-uniforms-turbidity-value","material-uniforms-rayleigh-value","material-uniforms-mieCoefficient-value","material-uniforms-mieDirectionalG-value","material-uniforms-sunPosition-value","scale"],Zh=f.defineComponent({__name:"Sky",props:{turbidity:{default:3.4},rayleigh:{default:3},mieCoefficient:{default:.005},mieDirectionalG:{default:.7},elevation:{default:.6},azimuth:{default:180},distance:{default:45e4}},setup(o){const e=o,t=new Fn,n=f.computed(()=>s(e.azimuth,e.elevation));function s(r,i){const a=c.MathUtils.degToRad(90-i),l=c.MathUtils.degToRad(r);return new c.Vector3().setFromSphericalCoords(1,a,l)}return(r,i)=>(f.openBlock(),f.createElementBlock("primitive",{object:f.unref(t),"material-uniforms-turbidity-value":e.turbidity,"material-uniforms-rayleigh-value":e.rayleigh,"material-uniforms-mieCoefficient-value":e.mieCoefficient,"material-uniforms-mieDirectionalG-value":e.mieDirectionalG,"material-uniforms-sunPosition-value":n.value,scale:e.distance},null,8,Wh))}}),Kh=["position"],qh=["position"],Qh=["scale"],Jh=["map","depth-test","color-space","color","opacity"],Hh=f.defineComponent({__name:"Smoke",props:{color:{default:"#ffffff"},opacity:{default:.5},speed:{default:.4},width:{default:10},depth:{default:1.5},segments:{default:20},texture:{default:"https://raw.githubusercontent.com/Tresjs/assets/main/textures/clouds/defaultCloud.png"},depthTest:{type:Boolean,default:!0}},async setup(o,{expose:e}){let t,n;const s=o,{width:r,depth:i,segments:a,texture:l,color:u,depthTest:h,opacity:d,speed:y}=f.toRefs(s),g=f.shallowRef(),x=f.shallowRef();e({value:g});const w=[...new Array(a)].map((b,C)=>({x:r.value/2-Math.random()*r.value,y:r.value/2-Math.random()*r.value,scale:.4+Math.sin((C+1)/a.value*Math.PI)*((.2+Math.random())*10),density:Math.max(.2,Math.random()),rotation:Math.max(.002,.005*Math.random())*y.value})),v=(b,C)=>b/6*C*d.value,{map:P}=([t,n]=f.withAsyncContext(()=>ae.useTexture({map:l.value})),t=await t,n(),t),{renderer:D,camera:S}=ae.useTresContext(),_=f.computed(()=>{var b;return(b=D.value)==null?void 0:b.outputColorSpace}),{onLoop:L}=ae.useRenderLoop();return L(()=>{var b,C;g.value&&S.value&&x.value&&((b=x.value)==null||b.children.forEach((m,M)=>{m.rotation.z+=w[M].rotation}),g.value.lookAt((C=S.value)==null?void 0:C.position))}),(b,C)=>(f.openBlock(),f.createElementBlock("TresGroup",f.mergeProps({ref_key:"smokeRef",ref:g},b.$attrs),[f.createElementVNode("TresGroup",{ref_key:"groupRef",ref:x,position:[0,0,f.unref(a)/2*f.unref(i)]},[(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(f.unref(w),({scale:m,x:M,y:p,density:I},F)=>(f.openBlock(),f.createElementBlock("TresMesh",{key:`${F}`,position:[M,p,-F*f.unref(i)]},[f.createElementVNode("TresPlaneGeometry",{scale:[m,m,m],rotation:[0,0,0]},null,8,Qh),f.createElementVNode("TresMeshStandardMaterial",{map:f.unref(P),"depth-test":f.unref(h),"color-space":_.value,color:f.unref(u),"depth-write":!1,transparent:"",opacity:v(m,I)},null,8,Jh)],8,qh))),128))],8,Kh)],16))}});function $h(o){return Is(o,{normalizeValue:e=>ae.normalizeColor(e),getDefaultValue:()=>new c.Color(0,0,0),isSingleValue:e=>!Array.isArray(e),isMultipleValues:e=>Array.isArray(e)&&(e.length===0||!Array.isArray(e[0])),isMultipleValuesWithStops:e=>Array.isArray(e)&&e.length>0&&Array.isArray(e[0]),isEmpty:e=>Array.isArray(e)&&e.length===0})}function Ls(o){return"isVector3"in o||Array.isArray(o)&&o.length>0&&o.every(e=>typeof e=="number")}function ef(o){return Is(o,{normalizeValue:e=>ae.normalizeVectorFlexibleParam(e),getDefaultValue:()=>[0,0,0],isSingleValue:e=>Ls(e),isMultipleValues:e=>Array.isArray(e)&&e.length>0&&Ls(e[0]),isMultipleValuesWithStops:e=>Array.isArray(e)&&e.length>0&&Array.isArray(e[0])&&e[0].length===2&&Ls(e[0][1]),isEmpty:e=>Array.isArray(e)&&e.length===0})}function tf(o){return Is(o,{normalizeValue:e=>e,getDefaultValue:()=>1,isSingleValue:e=>!Array.isArray(e)&&typeof e<"u",isMultipleValues:e=>Array.isArray(e)&&(e.length===0||!Array.isArray(e[0])),isMultipleValuesWithStops:e=>Array.isArray(e)&&e.length>0&&Array.isArray(e[0]),isEmpty:e=>Array.isArray(e)&&e.length===0})}function Is(o,e){const{normalizeValue:t,getDefaultValue:n,isEmpty:s}=e,r=l=>e.isSingleValue(l),i=l=>e.isMultipleValues(l),a=l=>e.isMultipleValuesWithStops(l);if(s(o))return[[0,n()]];if(r(o))return[[0,t(o)]];if(i(o)){const l=o.length>1?1/(o.length-1):1;return o.map((u,h)=>[l*h,t(u)])}else if(a(o))return o.map(([l,u],h)=>[l,t(u)]);return[[0,n()]]}class nf{constructor(e,t){le(this,"entries");le(this,"resolution");this.entries=e,this.resolution=t}useTexture(){return new of(this.entries,this.resolution).use()}}class Ds{constructor(e,t,n,s,r,i){le(this,"data");le(this,"ref");le(this,"name");le(this,"valueMin");le(this,"valueMax");le(this,"suffix");le(this,"renderToCanvasGradient");this.data=f.isRef(e)?e.value:e,this.ref=f.isRef(e)?e:null,this.name=t,this.valueMin=n,this.valueMax=s,this.suffix=r,this.renderToCanvasGradient=i}}class sf extends Ds{constructor(e,t="color",n=0,s=1,r="rgba",i=af){super(e,t,n,s,r,i)}}class Ii extends Ds{constructor(e,t="scalar",n=0,s=1,r="x",i=lf){super(e,t,n,s,r,i)}}class rf extends Ds{constructor(e,t="scalar3",n=0,s=1,r="xyz",i=cf){super(e,t,n,s,r,i)}}class of{constructor(e,t){le(this,"entries");le(this,"size");le(this,"dirty",f.shallowRef(0));le(this,"context");this.entries=e,this.size=Math.max(t,e.length);const n=document.createElement("canvas");n.height=this.size,n.width=this.size,this.context=n.getContext("2d")}use(){const e=this.build(),t=f.shallowRef(e);for(const n of this.entries)n.ref&&f.watch(n.ref,()=>{var s;n.data=(s=n.ref)==null?void 0:s.value,f.triggerRef(this.dirty)});return fl(this.dirty,()=>{this.build(e),t.value=e},{throttle:1e3/60}),{texture:t,dispose:()=>e.dispose(),yFor:this.entries.reduce((n,s,r)=>(n[s.name]=(r+.5)/this.size,n),{})}}build(e){this.entries.forEach((n,s)=>{const r=this.context.createLinearGradient(0,s,this.size,s);n.renderToCanvasGradient(r,n),this.context.fillStyle=r,this.context.fillRect(0,s,this.size,1)}),e&&(e.source.data=this.context.getImageData(0,0,this.size,this.size));const t=e??new c.DataTexture(this.context.getImageData(0,0,this.size,this.size).data,this.size,this.size,c.RGBAFormat,c.UnsignedByteType,c.UVMapping,c.ClampToEdgeWrapping,c.ClampToEdgeWrapping);return t.needsUpdate=!0,t}}function Di(o,e,t,n,s){return bc(gt(o,e,t),e,t,n,s)}function af(o,e){return $h(e.data).forEach(([t,n])=>o.addColorStop(t,`rgb(${n.r*255}, ${n.g*255}, ${n.b*255})`))}function lf(o,e){return tf(e.data).forEach(([t,n])=>{o.addColorStop(t,`rgb(${Di(n,e.valueMin,e.valueMax,0,255)}, 0, 0)`)})}function cf(o,e){return ef(e.data).forEach(([t,n])=>o.addColorStop(t,`rgb(${n.map(s=>Di(s,e.valueMin,e.valueMax,0,255))})`))}class uf{constructor(e=256){le(this,"entries");le(this,"resolution");this.resolution=e,this.entries=[]}withResolution(e){return this.resolution=e,this}get add(){return new ff(e=>this.onAdd(e))}build(){return new nf(this.entries,this.resolution)}onAdd(e){return this.entries.push(e),new hf(e,this)}}class hf{constructor(e,t){le(this,"entry");le(this,"parent");this.entry=e,this.parent=t}id(e){return this.entry.name=e,this}range(e,t){return this.entry.valueMin=e,this.entry.valueMax=t,this}suffix(e){return this.entry.suffix=e,this}canvasGradientRenderer(e){return this.entry.renderToCanvasGradient=e,this}get add(){return this.parent.add}build(){return this.parent.build()}}class ff{constructor(e){le(this,"onAdd");this.onAdd=e}GradientTresColor(e){return this.onAdd(new sf(e))}Gradient01(e){return this.onAdd(new Ii(e,"zeroOne",0,1))}GradientScalar(e,t,n){return this.onAdd(new Ii(e,"scalar",t,n))}GradientXyz(e,t,n){return this.onAdd(new rf(e,"position",t,n))}}let Os=null;function df(){return Os===null&&(Os=new c.DataTexture(new Uint8Array([0,0,0,0]),1,1)),Os}const pf=["object"],mf=f.defineComponent({__name:"component",props:{map:{default:"https://raw.githubusercontent.com/Tresjs/assets/e41a93c56ec7cb5ac2d241f309e23582a5fe1fc6/textures/sparkles/particle.png"},geometry:{default:void 0},directionalLight:{default:void 0},lifetimeSec:{default:.4},cooldownSec:{default:2},normalThreshold:{default:.7},noiseScale:{default:3},scaleNoise:{default:1},offsetNoise:{default:.1},lifetimeNoise:{default:0},size:{default:1},alpha:{default:1},offset:{default:1},surfaceDistance:{default:1},sequenceColor:{default:()=>[[.7,"#82dbc5"],[.8,"#fbb03b"]]},sequenceAlpha:{default:()=>[[0,0],[.1,1],[.5,1],[.9,0]]},sequenceOffset:{default:()=>[0,0,0]},sequenceNoise:{default:()=>[.1,.1,.1]},sequenceSize:{default:()=>[0,1]},sequenceSurfaceDistance:{default:()=>[.05,.08,.1]},mixColor:{default:.5},mixAlpha:{default:1},mixOffset:{default:1},mixSize:{default:0},mixSurfaceDistance:{default:1},mixNoise:{default:1},blending:{default:c.AdditiveBlending},transparent:{type:Boolean,default:!0},depthWrite:{type:Boolean,default:!1}},setup(o){const e=o,t=parseInt(c.REVISION.replace(/\D+/g,"")),n=f.toRefs(e),s=typeof e.map=="string"?df():e.map,{texture:r,yFor:i}=new uf(256).add.GradientTresColor(n.sequenceColor).id("sequenceColor").add.Gradient01(n.sequenceAlpha).id("sequenceAlpha").add.Gradient01(n.sequenceSurfaceDistance).id("sequenceSurfaceDistance").add.Gradient01(n.sequenceSize).id("sequenceSize").add.GradientXyz(n.sequenceOffset,-1,1).id("sequenceOffset").add.GradientXyz(n.sequenceNoise,0,1).id("sequenceNoise").build().useTexture(),a={blending:e.blending,transparent:e.transparent,depthWrite:e.depthWrite,uniforms:{uMap:new c.Uniform(s),uPixelRatio:new c.Uniform(1),uNormal:new c.Uniform(c.Object3D.DEFAULT_UP),uNormalThreshold:new c.Uniform(e.normalThreshold),uTime:new c.Uniform(0),uCooldownRatio:new c.Uniform(1),uSize:new c.Uniform(e.size),uAlpha:new c.Uniform(e.alpha),uOffset:new c.Uniform(e.offset),uSurfaceDistance:new c.Uniform(e.surfaceDistance),uNoiseScale:new c.Uniform(e.noiseScale),uScaleNoise:new c.Uniform(e.scaleNoise),uOffsetNoise:new c.Uniform(e.offsetNoise),uLifetimeNoise:new c.Uniform(e.lifetimeNoise),uMixColor:new c.Uniform(e.mixColor),uMixAlpha:new c.Uniform(e.mixAlpha),uMixOffset:new c.Uniform(e.mixOffset),uMixSize:new c.Uniform(e.mixSize),uMixSurfaceDistance:new c.Uniform(e.mixSurfaceDistance),uMixNoise:new c.Uniform(e.mixNoise),uInfoTexture:new c.Uniform(r.value)},vertexShader:`
|
|
1087
|
+
}`};const Hh=["object","material-uniforms-turbidity-value","material-uniforms-rayleigh-value","material-uniforms-mieCoefficient-value","material-uniforms-mieDirectionalG-value","material-uniforms-sunPosition-value","scale"],$h=f.defineComponent({__name:"Sky",props:{turbidity:{default:3.4},rayleigh:{default:3},mieCoefficient:{default:.005},mieDirectionalG:{default:.7},elevation:{default:.6},azimuth:{default:180},distance:{default:45e4}},setup(o,{expose:e}){const t=o,n=f.shallowRef(),r=new Fn,s=f.computed(()=>i(t.azimuth,t.elevation));function i(a,l){const u=c.MathUtils.degToRad(90-l),h=c.MathUtils.degToRad(a);return new c.Vector3().setFromSphericalCoords(1,u,h)}return e({root:n,sunPosition:s.value}),(a,l)=>(f.openBlock(),f.createElementBlock("primitive",{ref_key:"skyRef",ref:n,object:f.unref(r),"material-uniforms-turbidity-value":t.turbidity,"material-uniforms-rayleigh-value":t.rayleigh,"material-uniforms-mieCoefficient-value":t.mieCoefficient,"material-uniforms-mieDirectionalG-value":t.mieDirectionalG,"material-uniforms-sunPosition-value":s.value,scale:t.distance},null,8,Hh))}}),ef=["position"],tf=["position"],nf=["scale"],rf=["map","depth-test","color-space","color","opacity"],sf=f.defineComponent({__name:"Smoke",props:{color:{default:"#ffffff"},opacity:{default:.5},speed:{default:.4},width:{default:10},depth:{default:1.5},segments:{default:20},texture:{default:"https://raw.githubusercontent.com/Tresjs/assets/main/textures/clouds/defaultCloud.png"},depthTest:{type:Boolean,default:!0}},async setup(o,{expose:e}){let t,n;const r=o,{width:s,depth:i,segments:a,texture:l,color:u,depthTest:h,opacity:d,speed:g}=f.toRefs(r),y=f.shallowRef(),x=f.shallowRef();e({value:y});const w=[...new Array(a)].map((b,C)=>({x:s.value/2-Math.random()*s.value,y:s.value/2-Math.random()*s.value,scale:.4+Math.sin((C+1)/a.value*Math.PI)*((.2+Math.random())*10),density:Math.max(.2,Math.random()),rotation:Math.max(.002,.005*Math.random())*g.value})),v=(b,C)=>b/6*C*d.value,{map:A}=([t,n]=f.withAsyncContext(()=>ae.useTexture({map:l.value})),t=await t,n(),t),{renderer:D,camera:M}=ae.useTresContext(),_=f.computed(()=>{var b;return(b=D.value)==null?void 0:b.outputColorSpace}),{onLoop:L}=ae.useRenderLoop();return L(()=>{var b,C;y.value&&M.value&&x.value&&((b=x.value)==null||b.children.forEach((m,S)=>{m.rotation.z+=w[S].rotation}),y.value.lookAt((C=M.value)==null?void 0:C.position))}),(b,C)=>(f.openBlock(),f.createElementBlock("TresGroup",f.mergeProps({ref_key:"smokeRef",ref:y},b.$attrs),[f.createElementVNode("TresGroup",{ref_key:"groupRef",ref:x,position:[0,0,f.unref(a)/2*f.unref(i)]},[(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(f.unref(w),({scale:m,x:S,y:p,density:I},k)=>(f.openBlock(),f.createElementBlock("TresMesh",{key:`${k}`,position:[S,p,-k*f.unref(i)]},[f.createElementVNode("TresPlaneGeometry",{scale:[m,m,m],rotation:[0,0,0]},null,8,nf),f.createElementVNode("TresMeshStandardMaterial",{map:f.unref(A),"depth-test":f.unref(h),"color-space":_.value,color:f.unref(u),"depth-write":!1,transparent:"",opacity:v(m,I)},null,8,rf)],8,tf))),128))],8,ef)],16))}});function of(o){return Or(o,{normalizeValue:e=>ae.normalizeColor(e),getDefaultValue:()=>new c.Color(0,0,0),isSingleValue:e=>!Array.isArray(e),isMultipleValues:e=>Array.isArray(e)&&(e.length===0||!Array.isArray(e[0])),isMultipleValuesWithStops:e=>Array.isArray(e)&&e.length>0&&Array.isArray(e[0]),isEmpty:e=>Array.isArray(e)&&e.length===0})}function Ir(o){return"isVector3"in o||Array.isArray(o)&&o.length>0&&o.every(e=>typeof e=="number")}function af(o){return Or(o,{normalizeValue:e=>ae.normalizeVectorFlexibleParam(e),getDefaultValue:()=>[0,0,0],isSingleValue:e=>Ir(e),isMultipleValues:e=>Array.isArray(e)&&e.length>0&&Ir(e[0]),isMultipleValuesWithStops:e=>Array.isArray(e)&&e.length>0&&Array.isArray(e[0])&&e[0].length===2&&Ir(e[0][1]),isEmpty:e=>Array.isArray(e)&&e.length===0})}function lf(o){return Or(o,{normalizeValue:e=>e,getDefaultValue:()=>1,isSingleValue:e=>!Array.isArray(e)&&typeof e<"u",isMultipleValues:e=>Array.isArray(e)&&(e.length===0||!Array.isArray(e[0])),isMultipleValuesWithStops:e=>Array.isArray(e)&&e.length>0&&Array.isArray(e[0]),isEmpty:e=>Array.isArray(e)&&e.length===0})}function Or(o,e){const{normalizeValue:t,getDefaultValue:n,isEmpty:r}=e,s=l=>e.isSingleValue(l),i=l=>e.isMultipleValues(l),a=l=>e.isMultipleValuesWithStops(l);if(r(o))return[[0,n()]];if(s(o))return[[0,t(o)]];if(i(o)){const l=o.length>1?1/(o.length-1):1;return o.map((u,h)=>[l*h,t(u)])}else if(a(o))return o.map(([l,u],h)=>[l,t(u)]);return[[0,n()]]}class cf{constructor(e,t){le(this,"entries");le(this,"resolution");this.entries=e,this.resolution=t}useTexture(){return new ff(this.entries,this.resolution).use()}}class kr{constructor(e,t,n,r,s,i){le(this,"data");le(this,"ref");le(this,"name");le(this,"valueMin");le(this,"valueMax");le(this,"suffix");le(this,"renderToCanvasGradient");this.data=f.isRef(e)?e.value:e,this.ref=f.isRef(e)?e:null,this.name=t,this.valueMin=n,this.valueMax=r,this.suffix=s,this.renderToCanvasGradient=i}}class uf extends kr{constructor(e,t="color",n=0,r=1,s="rgba",i=df){super(e,t,n,r,s,i)}}class Oi extends kr{constructor(e,t="scalar",n=0,r=1,s="x",i=pf){super(e,t,n,r,s,i)}}class hf extends kr{constructor(e,t="scalar3",n=0,r=1,s="xyz",i=mf){super(e,t,n,r,s,i)}}class ff{constructor(e,t){le(this,"entries");le(this,"size");le(this,"dirty",f.shallowRef(0));le(this,"context");this.entries=e,this.size=Math.max(t,e.length);const n=document.createElement("canvas");n.height=this.size,n.width=this.size,this.context=n.getContext("2d")}use(){const e=this.build(),t=f.shallowRef(e);for(const n of this.entries)n.ref&&f.watch(n.ref,()=>{var r;n.data=(r=n.ref)==null?void 0:r.value,f.triggerRef(this.dirty)});return ml(this.dirty,()=>{this.build(e),t.value=e},{throttle:1e3/60}),{texture:t,dispose:()=>e.dispose(),yFor:this.entries.reduce((n,r,s)=>(n[r.name]=(s+.5)/this.size,n),{})}}build(e){this.entries.forEach((n,r)=>{const s=this.context.createLinearGradient(0,r,this.size,r);n.renderToCanvasGradient(s,n),this.context.fillStyle=s,this.context.fillRect(0,r,this.size,1)}),e&&(e.source.data=this.context.getImageData(0,0,this.size,this.size));const t=e??new c.DataTexture(this.context.getImageData(0,0,this.size,this.size).data,this.size,this.size,c.RGBAFormat,c.UnsignedByteType,c.UVMapping,c.ClampToEdgeWrapping,c.ClampToEdgeWrapping);return t.needsUpdate=!0,t}}function ki(o,e,t,n,r){return Ac(yt(o,e,t),e,t,n,r)}function df(o,e){return of(e.data).forEach(([t,n])=>o.addColorStop(t,`rgb(${n.r*255}, ${n.g*255}, ${n.b*255})`))}function pf(o,e){return lf(e.data).forEach(([t,n])=>{o.addColorStop(t,`rgb(${ki(n,e.valueMin,e.valueMax,0,255)}, 0, 0)`)})}function mf(o,e){return af(e.data).forEach(([t,n])=>o.addColorStop(t,`rgb(${n.map(r=>ki(r,e.valueMin,e.valueMax,0,255))})`))}class gf{constructor(e=256){le(this,"entries");le(this,"resolution");this.resolution=e,this.entries=[]}withResolution(e){return this.resolution=e,this}get add(){return new _f(e=>this.onAdd(e))}build(){return new cf(this.entries,this.resolution)}onAdd(e){return this.entries.push(e),new yf(e,this)}}class yf{constructor(e,t){le(this,"entry");le(this,"parent");this.entry=e,this.parent=t}id(e){return this.entry.name=e,this}range(e,t){return this.entry.valueMin=e,this.entry.valueMax=t,this}suffix(e){return this.entry.suffix=e,this}canvasGradientRenderer(e){return this.entry.renderToCanvasGradient=e,this}get add(){return this.parent.add}build(){return this.parent.build()}}class _f{constructor(e){le(this,"onAdd");this.onAdd=e}GradientTresColor(e){return this.onAdd(new uf(e))}Gradient01(e){return this.onAdd(new Oi(e,"zeroOne",0,1))}GradientScalar(e,t,n){return this.onAdd(new Oi(e,"scalar",t,n))}GradientXyz(e,t,n){return this.onAdd(new hf(e,"position",t,n))}}let Br=null;function vf(){return Br===null&&(Br=new c.DataTexture(new Uint8Array([0,0,0,0]),1,1)),Br}const xf=["object"],wf=f.defineComponent({__name:"component",props:{map:{default:"https://raw.githubusercontent.com/Tresjs/assets/e41a93c56ec7cb5ac2d241f309e23582a5fe1fc6/textures/sparkles/particle.png"},geometry:{default:void 0},directionalLight:{default:void 0},lifetimeSec:{default:.4},cooldownSec:{default:2},normalThreshold:{default:.7},noiseScale:{default:3},scaleNoise:{default:1},offsetNoise:{default:.1},lifetimeNoise:{default:0},size:{default:1},alpha:{default:1},offset:{default:1},surfaceDistance:{default:1},sequenceColor:{default:()=>[[.7,"#82dbc5"],[.8,"#fbb03b"]]},sequenceAlpha:{default:()=>[[0,0],[.1,1],[.5,1],[.9,0]]},sequenceOffset:{default:()=>[0,0,0]},sequenceNoise:{default:()=>[.1,.1,.1]},sequenceSize:{default:()=>[0,1]},sequenceSurfaceDistance:{default:()=>[.05,.08,.1]},mixColor:{default:.5},mixAlpha:{default:1},mixOffset:{default:1},mixSize:{default:0},mixSurfaceDistance:{default:1},mixNoise:{default:1},blending:{default:c.AdditiveBlending},transparent:{type:Boolean,default:!0},depthWrite:{type:Boolean,default:!1}},setup(o){const e=o,t=parseInt(c.REVISION.replace(/\D+/g,"")),n=f.toRefs(e),r=typeof e.map=="string"?vf():e.map,{texture:s,yFor:i}=new gf(256).add.GradientTresColor(n.sequenceColor).id("sequenceColor").add.Gradient01(n.sequenceAlpha).id("sequenceAlpha").add.Gradient01(n.sequenceSurfaceDistance).id("sequenceSurfaceDistance").add.Gradient01(n.sequenceSize).id("sequenceSize").add.GradientXyz(n.sequenceOffset,-1,1).id("sequenceOffset").add.GradientXyz(n.sequenceNoise,0,1).id("sequenceNoise").build().useTexture(),a={blending:e.blending,transparent:e.transparent,depthWrite:e.depthWrite,uniforms:{uMap:new c.Uniform(r),uPixelRatio:new c.Uniform(1),uNormal:new c.Uniform(c.Object3D.DEFAULT_UP),uNormalThreshold:new c.Uniform(e.normalThreshold),uTime:new c.Uniform(0),uCooldownRatio:new c.Uniform(1),uSize:new c.Uniform(e.size),uAlpha:new c.Uniform(e.alpha),uOffset:new c.Uniform(e.offset),uSurfaceDistance:new c.Uniform(e.surfaceDistance),uNoiseScale:new c.Uniform(e.noiseScale),uScaleNoise:new c.Uniform(e.scaleNoise),uOffsetNoise:new c.Uniform(e.offsetNoise),uLifetimeNoise:new c.Uniform(e.lifetimeNoise),uMixColor:new c.Uniform(e.mixColor),uMixAlpha:new c.Uniform(e.mixAlpha),uMixOffset:new c.Uniform(e.mixOffset),uMixSize:new c.Uniform(e.mixSize),uMixSurfaceDistance:new c.Uniform(e.mixSurfaceDistance),uMixNoise:new c.Uniform(e.mixNoise),uInfoTexture:new c.Uniform(s.value)},vertexShader:`
|
|
1088
1088
|
uniform float uPixelRatio;
|
|
1089
1089
|
uniform vec3 uNormal;
|
|
1090
1090
|
uniform float uNormalThreshold;
|
|
@@ -1155,7 +1155,103 @@ list should be an Array.`),T.length===0)return new v(0);if(T.length===1)return T
|
|
|
1155
1155
|
gl_FragColor = vColor * texture2D(uMap, gl_PointCoord);
|
|
1156
1156
|
#include <tonemapping_fragment>
|
|
1157
1157
|
#include <${t>=154?"colorspace_fragment":"encodings_fragment"}>
|
|
1158
|
-
}`},l=new c.ShaderMaterial(a),u=new c.Points(void 0,l),h=l.uniforms,d={immediate:!0};[[h.uPixelRatio,ae.useTresContext().sizes.aspectRatio],[h.uSize,n.size],[h.uNormalThreshold,n.normalThreshold],[h.uAlpha,n.alpha],[h.uOffset,n.offset],[h.uOffsetNoise,n.offsetNoise],[h.uMixColor,n.mixColor],[h.uMixAlpha,n.mixAlpha],[h.uMixOffset,n.mixOffset],[h.uMixSize,n.mixSize],[h.uMixSurfaceDistance,n.mixSurfaceDistance],[h.uMixNoise,n.mixNoise],[h.uInfoTexture,r]].forEach(([D,S])=>f.watch(S,()=>{D.value=S.value},d)),f.watch([n.noiseScale,n.lifetimeSec],()=>{h.uNoiseScale.value=n.noiseScale.value*n.lifetimeSec.value},d),f.watch([n.lifetimeSec,n.cooldownSec],()=>{h.uCooldownRatio.value=n.cooldownSec.value/n.lifetimeSec.value},d),f.watch(n.map,()=>{typeof n.map.value=="string"?ae.useTexture([n.map.value]).then(D=>l.uniforms.uMap.value=D):l.uniforms.uMap.value=n.map.value});const g=new c.Quaternion,x=new c.Vector3;ae.useRenderLoop().onLoop(({elapsed:D})=>{u.getWorldQuaternion(g),x.copy(e.directionalLight?e.directionalLight.position:c.Object3D.DEFAULT_UP).normalize(),x.applyQuaternion(g.invert()),l.uniforms.uNormal.value=x,l.uniforms.uTime.value=D/(e.cooldownSec+e.lifetimeSec)});function w(D){return D&&"isObject3D"in D}function v(D){return D&&"isBufferGeometry"in D}f.onMounted(()=>{e.geometry?v(e.geometry)?u.geometry.copy(e.geometry):w(e.geometry)&&"geometry"in e.geometry&&v(e.geometry.geometry)&&u.geometry.copy(e.geometry.geometry):w(u.parent)&&"geometry"in u.parent&&v(u.parent.geometry)?u.geometry.copy(u.parent.geometry):u.geometry=new c.IcosahedronGeometry(1,16),typeof e.map=="string"&&ae.useTexture([e.map]).then(D=>l.uniforms.uMap.value=D)}),f.onUnmounted(()=>{var D;(D=l.uniforms.uMap.value)==null||D.dispose(),r.value.dispose(),l.dispose()});const P=f.shallowRef();return(D,S)=>(f.openBlock(),f.createElementBlock("primitive",{ref_key:"sparkleRef",ref:P,object:f.unref(u)},null,8,pf))}}),gf=["position","a-scale"],yf=["size","size-attenuation","transparent","alpha-test","alpha-map"],_f=f.defineComponent({__name:"Stars",props:{size:{default:.1},sizeAttenuation:{type:Boolean,default:!0},transparent:{type:Boolean,default:!0},alphaTest:{default:.01},count:{default:5e3},depth:{default:50},radius:{default:100},alphaMap:{default:null}},setup(o,{expose:e}){const t=o,n=f.ref(),s=f.ref(),{radius:r,depth:i,count:a,size:l,sizeAttenuation:u,transparent:h,alphaMap:d,alphaTest:y}=f.toRefs(t),g=()=>{let w=r.value+i.value;const v=f.computed(()=>i.value/a.value),P=[],D=Array.from({length:a.value},()=>(.5+.5*Math.random())*4),S=_=>new c.Vector3().setFromSpherical(new c.Spherical(_,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)).toArray();for(let _=0;_<a.value;_++)w-=v.value*Math.random(),P.push(...S(w));n.value=new Float32Array(P),s.value=new Float32Array(D)};f.watchEffect(()=>{g()});const x=f.shallowRef();return e({value:x}),(w,v)=>(f.openBlock(),f.createElementBlock("TresPoints",{ref_key:"starsRef",ref:x},[f.createElementVNode("TresBufferGeometry",{position:[n.value,3],"a-scale":[s.value,1]},null,8,gf),f.createElementVNode("TresPointsMaterial",{size:f.unref(l),"size-attenuation":f.unref(u),transparent:f.unref(h),"alpha-test":f.unref(y),"alpha-map":f.unref(d)},null,8,yf)],512))}});let it;const vf=(o="body")=>{it||(it=new ji.Pane({container:document.querySelector(o)}),it.element.style.position="absolute",it.element.style.top="1rem",it.element.style.right="1rem",it.element.style.zIndex="9999");const{logWarning:e}=os();e("useTweakPane is deprecated as of Cientos v3.7.0 and will no longer be part of this package. Please migrate to @tresjs/leches package https://github.com/Tresjs/leches or v-tweakpane https://github.com/vinayakkulkarni/v-tweakpane instead.");function t(){it&&it.dispose()}return f.onMounted(()=>{const{resume:n}=ae.useRenderLoop();n()}),f.onUnmounted(()=>{t()}),{pane:it,disposeTweakPane:t}};var Oi={exports:{}};(function(o,e){(function(t,n){o.exports=n()})(Lc,function(){var t=function(){function n(g){return i.appendChild(g.dom),g}function s(g){for(var x=0;x<i.children.length;x++)i.children[x].style.display=x===g?"block":"none";r=g}var r=0,i=document.createElement("div");i.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",i.addEventListener("click",function(g){g.preventDefault(),s(++r%i.children.length)},!1);var a=(performance||Date).now(),l=a,u=0,h=n(new t.Panel("FPS","#0ff","#002")),d=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var y=n(new t.Panel("MB","#f08","#201"));return s(0),{REVISION:16,dom:i,addPanel:n,showPanel:s,begin:function(){a=(performance||Date).now()},end:function(){u++;var g=(performance||Date).now();if(d.update(g-a,200),g>l+1e3&&(h.update(1e3*u/(g-l),100),l=g,u=0,y)){var x=performance.memory;y.update(x.usedJSHeapSize/1048576,x.jsHeapSizeLimit/1048576)}return g},update:function(){a=this.end()},domElement:i,setMode:s}};return t.Panel=function(n,s,r){var i=1/0,a=0,l=Math.round,u=l(window.devicePixelRatio||1),h=80*u,d=48*u,y=3*u,g=2*u,x=3*u,w=15*u,v=74*u,P=30*u,D=document.createElement("canvas");D.width=h,D.height=d,D.style.cssText="width:80px;height:48px";var S=D.getContext("2d");return S.font="bold "+9*u+"px Helvetica,Arial,sans-serif",S.textBaseline="top",S.fillStyle=r,S.fillRect(0,0,h,d),S.fillStyle=s,S.fillText(n,y,g),S.fillRect(x,w,v,P),S.fillStyle=r,S.globalAlpha=.9,S.fillRect(x,w,v,P),{dom:D,update:function(_,L){i=Math.min(i,_),a=Math.max(a,_),S.fillStyle=r,S.globalAlpha=1,S.fillRect(0,0,h,w),S.fillStyle=s,S.fillText(l(_)+" "+n+" ("+l(i)+"-"+l(a)+")",y,g),S.drawImage(D,x+u,w,v-u,P,x,w,v-u,P),S.fillRect(x+v-u,w,u,P),S.fillStyle=r,S.globalAlpha=.9,S.fillRect(x+v-u,w,u,l((1-_/L)*P))}}},t})})(Oi);var xf=Oi.exports;const wf=nn(xf),bf=f.defineComponent({name:"Stats",props:{showPanel:{type:Number,default:0}},setup(o,{expose:e}){const t=new wf;e({stats:t});const n=document.body;t.showPanel(o.showPanel||0),n==null||n.appendChild(t.dom);const{onBeforeLoop:s,onAfterLoop:r,resume:i}=ae.useRenderLoop();i(),s(()=>t.begin()),r(()=>t.end()),f.onUnmounted(()=>{n==null||n.removeChild(t.dom)})}});class Mf{constructor(e,t,n){this.name=e,this.fg=t,this.bg=n,this.PR=Math.round(window.devicePixelRatio||1),this.WIDTH=90*this.PR,this.HEIGHT=48*this.PR,this.TEXT_X=3*this.PR,this.TEXT_Y=2*this.PR,this.GRAPH_X=3*this.PR,this.GRAPH_Y=15*this.PR,this.GRAPH_WIDTH=84*this.PR,this.GRAPH_HEIGHT=30*this.PR,this.canvas=document.createElement("canvas"),this.canvas.width=90*this.PR,this.canvas.height=48*this.PR,this.canvas.style.width="90px",this.canvas.style.position="absolute",this.canvas.style.height="48px",this.canvas.style.cssText="width:90px;height:48px",this.context=this.canvas.getContext("2d"),this.context&&(this.context.font="bold "+9*this.PR+"px Helvetica,Arial,sans-serif",this.context.textBaseline="top",this.context.fillStyle=this.bg,this.context.fillRect(0,0,this.WIDTH,this.HEIGHT),this.context.fillStyle=this.fg,this.context.fillText(this.name,this.TEXT_X,this.TEXT_Y),this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT),this.context.fillStyle=this.bg,this.context.globalAlpha=.9,this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT))}update(e,t,n,s,r=0){let i=1/0,a=0;this.context&&(i=Math.min(i,e),a=Math.max(n,e),s=Math.max(s,t),this.context.fillStyle=this.bg,this.context.globalAlpha=1,this.context.fillRect(0,0,this.WIDTH,this.GRAPH_Y),this.context.fillStyle=this.fg,this.context.fillText(e.toFixed(r)+" "+this.name+" ("+i.toFixed(r)+"-"+parseFloat(a.toFixed(r))+")",this.TEXT_X,this.TEXT_Y),this.context.drawImage(this.canvas,this.GRAPH_X+this.PR,this.GRAPH_Y,this.GRAPH_WIDTH-this.PR,this.GRAPH_HEIGHT,this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH-this.PR,this.GRAPH_HEIGHT),this.context.fillRect(this.GRAPH_X+this.GRAPH_WIDTH-this.PR,this.GRAPH_Y,this.PR,this.GRAPH_HEIGHT),this.context.fillStyle=this.bg,this.context.globalAlpha=.9,this.context.fillRect(this.GRAPH_X+this.GRAPH_WIDTH-this.PR,this.GRAPH_Y,this.PR,(1-t/s)*this.GRAPH_HEIGHT))}}const Fi=class Un{constructor({logsPerSecond:e=20,samplesLog:t=100,samplesGraph:n=10,precision:s=2,minimal:r=!1,horizontal:i=!0,mode:a=0}={}){this.totalCpuDuration=0,this.totalGpuDuration=0,this.totalFps=0,this.activeQuery=null,this.gpuQueries=[],this.renderCount=0,this.mode=a,this.horizontal=i,this.dom=document.createElement("div"),this.dom.style.cssText="position:fixed;top:0;left:0;opacity:0.9;z-index:10000;",r&&(this.dom.style.cssText+="cursor:pointer"),this.gl=null,this.query=null,this.isRunningCPUProfiling=!1,this.minimal=r,this.beginTime=(performance||Date).now(),this.prevTime=this.beginTime,this.prevCpuTime=this.beginTime,this.frames=0,this.renderCount=0,this.threeRendererPatched=!1,this.averageCpu={logs:[],graph:[]},this.averageGpu={logs:[],graph:[]},this.queryCreated=!1,this.fpsPanel=this.addPanel(new Un.Panel("FPS","#0ff","#002"),0),this.msPanel=this.addPanel(new Un.Panel("CPU","#0f0","#020"),1),this.gpuPanel=null,this.samplesLog=t,this.samplesGraph=n,this.precision=s,this.logsPerSecond=e,this.minimal?(this.dom.addEventListener("click",l=>{l.preventDefault(),this.showPanel(++this.mode%this.dom.children.length)},!1),this.mode=a,this.showPanel(this.mode)):window.addEventListener("resize",()=>{this.resizePanel(this.fpsPanel,0),this.resizePanel(this.msPanel,1),this.gpuPanel&&this.resizePanel(this.gpuPanel,2)})}patchThreeRenderer(e){const t=e.render,n=this;e.render=function(s,r){n.begin(),t.call(this,s,r),n.end()},this.threeRendererPatched=!0}resizePanel(e,t){e.canvas.style.position="absolute",this.minimal?e.canvas.style.display="none":(e.canvas.style.display="block",this.horizontal?(e.canvas.style.top="0px",e.canvas.style.left=t*e.WIDTH/e.PR+"px"):(e.canvas.style.left="0px",e.canvas.style.top=t*e.HEIGHT/e.PR+"px"))}addPanel(e,t){return e.canvas&&(this.dom.appendChild(e.canvas),this.resizePanel(e,t)),e}showPanel(e){for(let t=0;t<this.dom.children.length;t++){const n=this.dom.children[t];n.style.display=t===e?"block":"none"}this.mode=e}init(e){if(!e){console.error('Stats: The "canvas" parameter is undefined.');return}if(e.isWebGLRenderer&&!this.threeRendererPatched){const t=e;this.patchThreeRenderer(t),this.gl=t.getContext()}if(!this.gl&&e instanceof WebGL2RenderingContext)this.gl=e;else if(!this.gl&&e instanceof HTMLCanvasElement||e instanceof OffscreenCanvas){if(this.gl=e.getContext("webgl2"),!this.gl){console.error("Stats: Unable to obtain WebGL2 context.");return}}else if(!this.gl){console.error("Stats: Invalid input type. Expected WebGL2RenderingContext, HTMLCanvasElement, or OffscreenCanvas.");return}this.ext=this.gl.getExtension("EXT_disjoint_timer_query_webgl2"),this.ext&&(this.gpuPanel=this.addPanel(new Un.Panel("GPU","#ff0","#220"),2))}begin(){this.isRunningCPUProfiling||this.beginProfiling("cpu-started"),!(!this.gl||!this.ext)&&this.gl&&this.ext&&(this.activeQuery&&this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.activeQuery=this.gl.createQuery(),this.activeQuery!==null&&this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,this.activeQuery))}end(){this.renderCount++,this.gl&&this.ext&&this.activeQuery&&(this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.gpuQueries.push({query:this.activeQuery}),this.activeQuery=null)}processGpuQueries(){!this.gl||!this.ext||(this.totalGpuDuration=0,this.gpuQueries.forEach((e,t)=>{if(this.gl){const n=this.gl.getQueryParameter(e.query,this.gl.QUERY_RESULT_AVAILABLE),s=this.gl.getParameter(this.ext.GPU_DISJOINT_EXT);if(n&&!s){const i=this.gl.getQueryParameter(e.query,this.gl.QUERY_RESULT)*1e-6;this.totalGpuDuration+=i,this.gl.deleteQuery(e.query),this.gpuQueries.splice(t,1)}}}))}update(){this.processGpuQueries(),this.endProfiling("cpu-started","cpu-finished","cpu-duration"),this.addToAverage(this.totalCpuDuration,this.averageCpu),this.addToAverage(this.totalGpuDuration,this.averageGpu),this.renderCount=0,this.totalCpuDuration=0,this.totalGpuDuration=0,this.totalFps=0,this.beginTime=this.endInternal()}endInternal(){this.frames++;const e=(performance||Date).now();if(e>=this.prevCpuTime+1e3/this.logsPerSecond&&(this.updatePanel(this.msPanel,this.averageCpu),this.updatePanel(this.gpuPanel,this.averageGpu),this.prevCpuTime=e),e>=this.prevTime+1e3){const t=this.frames*1e3/(e-this.prevTime);this.fpsPanel.update(t,t,100,100,0),this.prevTime=e,this.frames=0}return e}addToAverage(e,t){t.logs.push(e),t.logs.length>this.samplesLog&&t.logs.shift(),t.graph.push(e),t.graph.length>this.samplesGraph&&t.graph.shift()}beginProfiling(e){window.performance&&(window.performance.mark(e),this.isRunningCPUProfiling=!0)}endProfiling(e,t,n){if(window.performance&&t&&this.isRunningCPUProfiling){window.performance.mark(t);const s=performance.measure(n,e,t);this.totalCpuDuration+=s.duration,this.isRunningCPUProfiling=!1}}updatePanel(e,t){if(t.logs.length>0){let n=0,s=.01;for(let a=0;a<t.logs.length;a++)n+=t.logs[a],t.logs[a]>s&&(s=t.logs[a]);let r=0,i=.01;for(let a=0;a<t.graph.length;a++)r+=t.graph[a],t.graph[a]>i&&(i=t.graph[a]);e&&e.update(n/Math.min(t.logs.length,this.samplesLog),r/Math.min(t.graph.length,this.samplesGraph),s,i,this.precision)}}get domElement(){return this.dom}get container(){return console.warn("Stats: Deprecated! this.container as been replaced to this.dom "),this.dom}};Fi.Panel=Mf;let Sf=Fi;const Af=f.defineComponent({name:"StatsGl",props:["logsPerSecond","samplesLog","samplesGraph","precision","horizontal","minimal","mode"],async setup(o,{expose:e}){const t=new Sf({logsPerSecond:o.logsPerSecond,samplesLog:o.samplesLog,samplesGraph:o.samplesGraph,precision:o.precision,horizontal:o.horizontal,minimal:o.minimal,mode:o.mode});e({statsGl:t});const n=document.body,s=t.dom||t.container;n==null||n.appendChild(s);const{renderer:r}=ae.useTresContext(),{onAfterLoop:i,resume:a}=ae.useRenderLoop();t.init(r.value),a(),i(()=>{t.update()}),f.onUnmounted(()=>{n==null||n.removeChild(s)})}}),Pf=f.defineComponent({name:"BakeShadows",setup(){const{renderer:o}=ae.useTresContext();f.watchEffect(()=>{o.value.shadowMap.autoUpdate=!1,o.value.shadowMap.needsUpdate=!0})}});var Cf=`#include <common>
|
|
1158
|
+
}`},l=new c.ShaderMaterial(a),u=new c.Points(void 0,l),h=l.uniforms,d={immediate:!0};[[h.uPixelRatio,ae.useTresContext().sizes.aspectRatio],[h.uSize,n.size],[h.uNormalThreshold,n.normalThreshold],[h.uAlpha,n.alpha],[h.uOffset,n.offset],[h.uOffsetNoise,n.offsetNoise],[h.uMixColor,n.mixColor],[h.uMixAlpha,n.mixAlpha],[h.uMixOffset,n.mixOffset],[h.uMixSize,n.mixSize],[h.uMixSurfaceDistance,n.mixSurfaceDistance],[h.uMixNoise,n.mixNoise],[h.uInfoTexture,s]].forEach(([D,M])=>f.watch(M,()=>{D.value=M.value},d)),f.watch([n.noiseScale,n.lifetimeSec],()=>{h.uNoiseScale.value=n.noiseScale.value*n.lifetimeSec.value},d),f.watch([n.lifetimeSec,n.cooldownSec],()=>{h.uCooldownRatio.value=n.cooldownSec.value/n.lifetimeSec.value},d),f.watch(n.map,()=>{typeof n.map.value=="string"?ae.useTexture([n.map.value]).then(D=>l.uniforms.uMap.value=D):l.uniforms.uMap.value=n.map.value});const y=new c.Quaternion,x=new c.Vector3;ae.useRenderLoop().onLoop(({elapsed:D})=>{u.getWorldQuaternion(y),x.copy(e.directionalLight?e.directionalLight.position:c.Object3D.DEFAULT_UP).normalize(),x.applyQuaternion(y.invert()),l.uniforms.uNormal.value=x,l.uniforms.uTime.value=D/(e.cooldownSec+e.lifetimeSec)});function w(D){return D&&"isObject3D"in D}function v(D){return D&&"isBufferGeometry"in D}f.onMounted(()=>{e.geometry?v(e.geometry)?u.geometry.copy(e.geometry):w(e.geometry)&&"geometry"in e.geometry&&v(e.geometry.geometry)&&u.geometry.copy(e.geometry.geometry):w(u.parent)&&"geometry"in u.parent&&v(u.parent.geometry)?u.geometry.copy(u.parent.geometry):u.geometry=new c.IcosahedronGeometry(1,16),typeof e.map=="string"&&ae.useTexture([e.map]).then(D=>l.uniforms.uMap.value=D)}),f.onUnmounted(()=>{var D;(D=l.uniforms.uMap.value)==null||D.dispose(),s.value.dispose(),l.dispose()});const A=f.shallowRef();return(D,M)=>(f.openBlock(),f.createElementBlock("primitive",{ref_key:"sparkleRef",ref:A,object:f.unref(u)},null,8,xf))}}),bf=["position","a-scale"],Mf=["size","size-attenuation","transparent","alpha-test","alpha-map"],Sf=f.defineComponent({__name:"Stars",props:{size:{default:.1},sizeAttenuation:{type:Boolean,default:!0},transparent:{type:Boolean,default:!0},alphaTest:{default:.01},count:{default:5e3},depth:{default:50},radius:{default:100},alphaMap:{default:null}},setup(o,{expose:e}){const t=o,n=f.ref(),r=f.ref(),{radius:s,depth:i,count:a,size:l,sizeAttenuation:u,transparent:h,alphaMap:d,alphaTest:g}=f.toRefs(t),y=()=>{let w=s.value+i.value;const v=f.computed(()=>i.value/a.value),A=[],D=Array.from({length:a.value},()=>(.5+.5*Math.random())*4),M=_=>new c.Vector3().setFromSpherical(new c.Spherical(_,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)).toArray();for(let _=0;_<a.value;_++)w-=v.value*Math.random(),A.push(...M(w));n.value=new Float32Array(A),r.value=new Float32Array(D)};f.watchEffect(()=>{y()});const x=f.shallowRef();return e({value:x}),(w,v)=>(f.openBlock(),f.createElementBlock("TresPoints",{ref_key:"starsRef",ref:x},[f.createElementVNode("TresBufferGeometry",{position:[n.value,3],"a-scale":[r.value,1]},null,8,bf),f.createElementVNode("TresPointsMaterial",{size:f.unref(l),"size-attenuation":f.unref(u),transparent:f.unref(h),"alpha-test":f.unref(g),"alpha-map":f.unref(d)},null,8,Mf)],512))}});class Af extends c.Mesh{constructor(e,t={}){super(e),this.isWater=!0;const n=this,r=t.textureWidth!==void 0?t.textureWidth:512,s=t.textureHeight!==void 0?t.textureHeight:512,i=t.clipBias!==void 0?t.clipBias:0,a=t.alpha!==void 0?t.alpha:1,l=t.time!==void 0?t.time:0,u=t.waterNormals!==void 0?t.waterNormals:null,h=t.sunDirection!==void 0?t.sunDirection:new c.Vector3(.70707,.70707,0),d=new c.Color(t.sunColor!==void 0?t.sunColor:16777215),g=new c.Color(t.waterColor!==void 0?t.waterColor:8355711),y=t.eye!==void 0?t.eye:new c.Vector3(0,0,0),x=t.distortionScale!==void 0?t.distortionScale:20,w=t.side!==void 0?t.side:c.FrontSide,v=t.fog!==void 0?t.fog:!1,A=new c.Plane,D=new c.Vector3,M=new c.Vector3,_=new c.Vector3,L=new c.Matrix4,b=new c.Vector3(0,0,-1),C=new c.Vector4,m=new c.Vector3,S=new c.Vector3,p=new c.Vector4,I=new c.Matrix4,k=new c.PerspectiveCamera,J=new c.WebGLRenderTarget(r,s),R={name:"MirrorShader",uniforms:c.UniformsUtils.merge([c.UniformsLib.fog,c.UniformsLib.lights,{normalSampler:{value:null},mirrorSampler:{value:null},alpha:{value:1},time:{value:0},size:{value:1},distortionScale:{value:20},textureMatrix:{value:new c.Matrix4},sunColor:{value:new c.Color(8355711)},sunDirection:{value:new c.Vector3(.70707,.70707,0)},eye:{value:new c.Vector3},waterColor:{value:new c.Color(5592405)}}]),vertexShader:`
|
|
1159
|
+
uniform mat4 textureMatrix;
|
|
1160
|
+
uniform float time;
|
|
1161
|
+
|
|
1162
|
+
varying vec4 mirrorCoord;
|
|
1163
|
+
varying vec4 worldPosition;
|
|
1164
|
+
|
|
1165
|
+
#include <common>
|
|
1166
|
+
#include <fog_pars_vertex>
|
|
1167
|
+
#include <shadowmap_pars_vertex>
|
|
1168
|
+
#include <logdepthbuf_pars_vertex>
|
|
1169
|
+
|
|
1170
|
+
void main() {
|
|
1171
|
+
mirrorCoord = modelMatrix * vec4( position, 1.0 );
|
|
1172
|
+
worldPosition = mirrorCoord.xyzw;
|
|
1173
|
+
mirrorCoord = textureMatrix * mirrorCoord;
|
|
1174
|
+
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
1175
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
1176
|
+
|
|
1177
|
+
#include <beginnormal_vertex>
|
|
1178
|
+
#include <defaultnormal_vertex>
|
|
1179
|
+
#include <logdepthbuf_vertex>
|
|
1180
|
+
#include <fog_vertex>
|
|
1181
|
+
#include <shadowmap_vertex>
|
|
1182
|
+
}`,fragmentShader:`
|
|
1183
|
+
uniform sampler2D mirrorSampler;
|
|
1184
|
+
uniform float alpha;
|
|
1185
|
+
uniform float time;
|
|
1186
|
+
uniform float size;
|
|
1187
|
+
uniform float distortionScale;
|
|
1188
|
+
uniform sampler2D normalSampler;
|
|
1189
|
+
uniform vec3 sunColor;
|
|
1190
|
+
uniform vec3 sunDirection;
|
|
1191
|
+
uniform vec3 eye;
|
|
1192
|
+
uniform vec3 waterColor;
|
|
1193
|
+
|
|
1194
|
+
varying vec4 mirrorCoord;
|
|
1195
|
+
varying vec4 worldPosition;
|
|
1196
|
+
|
|
1197
|
+
vec4 getNoise( vec2 uv ) {
|
|
1198
|
+
vec2 uv0 = ( uv / 103.0 ) + vec2(time / 17.0, time / 29.0);
|
|
1199
|
+
vec2 uv1 = uv / 107.0-vec2( time / -19.0, time / 31.0 );
|
|
1200
|
+
vec2 uv2 = uv / vec2( 8907.0, 9803.0 ) + vec2( time / 101.0, time / 97.0 );
|
|
1201
|
+
vec2 uv3 = uv / vec2( 1091.0, 1027.0 ) - vec2( time / 109.0, time / -113.0 );
|
|
1202
|
+
vec4 noise = texture2D( normalSampler, uv0 ) +
|
|
1203
|
+
texture2D( normalSampler, uv1 ) +
|
|
1204
|
+
texture2D( normalSampler, uv2 ) +
|
|
1205
|
+
texture2D( normalSampler, uv3 );
|
|
1206
|
+
return noise * 0.5 - 1.0;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
void sunLight( const vec3 surfaceNormal, const vec3 eyeDirection, float shiny, float spec, float diffuse, inout vec3 diffuseColor, inout vec3 specularColor ) {
|
|
1210
|
+
vec3 reflection = normalize( reflect( -sunDirection, surfaceNormal ) );
|
|
1211
|
+
float direction = max( 0.0, dot( eyeDirection, reflection ) );
|
|
1212
|
+
specularColor += pow( direction, shiny ) * sunColor * spec;
|
|
1213
|
+
diffuseColor += max( dot( sunDirection, surfaceNormal ), 0.0 ) * sunColor * diffuse;
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
#include <common>
|
|
1217
|
+
#include <packing>
|
|
1218
|
+
#include <bsdfs>
|
|
1219
|
+
#include <fog_pars_fragment>
|
|
1220
|
+
#include <logdepthbuf_pars_fragment>
|
|
1221
|
+
#include <lights_pars_begin>
|
|
1222
|
+
#include <shadowmap_pars_fragment>
|
|
1223
|
+
#include <shadowmask_pars_fragment>
|
|
1224
|
+
|
|
1225
|
+
void main() {
|
|
1226
|
+
|
|
1227
|
+
#include <logdepthbuf_fragment>
|
|
1228
|
+
vec4 noise = getNoise( worldPosition.xz * size );
|
|
1229
|
+
vec3 surfaceNormal = normalize( noise.xzy * vec3( 1.5, 1.0, 1.5 ) );
|
|
1230
|
+
|
|
1231
|
+
vec3 diffuseLight = vec3(0.0);
|
|
1232
|
+
vec3 specularLight = vec3(0.0);
|
|
1233
|
+
|
|
1234
|
+
vec3 worldToEye = eye-worldPosition.xyz;
|
|
1235
|
+
vec3 eyeDirection = normalize( worldToEye );
|
|
1236
|
+
sunLight( surfaceNormal, eyeDirection, 100.0, 2.0, 0.5, diffuseLight, specularLight );
|
|
1237
|
+
|
|
1238
|
+
float distance = length(worldToEye);
|
|
1239
|
+
|
|
1240
|
+
vec2 distortion = surfaceNormal.xz * ( 0.001 + 1.0 / distance ) * distortionScale;
|
|
1241
|
+
vec3 reflectionSample = vec3( texture2D( mirrorSampler, mirrorCoord.xy / mirrorCoord.w + distortion ) );
|
|
1242
|
+
|
|
1243
|
+
float theta = max( dot( eyeDirection, surfaceNormal ), 0.0 );
|
|
1244
|
+
float rf0 = 0.3;
|
|
1245
|
+
float reflectance = rf0 + ( 1.0 - rf0 ) * pow( ( 1.0 - theta ), 5.0 );
|
|
1246
|
+
vec3 scatter = max( 0.0, dot( surfaceNormal, eyeDirection ) ) * waterColor;
|
|
1247
|
+
vec3 albedo = mix( ( sunColor * diffuseLight * 0.3 + scatter ) * getShadowMask(), ( vec3( 0.1 ) + reflectionSample * 0.9 + reflectionSample * specularLight ), reflectance);
|
|
1248
|
+
vec3 outgoingLight = albedo;
|
|
1249
|
+
gl_FragColor = vec4( outgoingLight, alpha );
|
|
1250
|
+
|
|
1251
|
+
#include <tonemapping_fragment>
|
|
1252
|
+
#include <colorspace_fragment>
|
|
1253
|
+
#include <fog_fragment>
|
|
1254
|
+
}`},Z=new c.ShaderMaterial({name:R.name,uniforms:c.UniformsUtils.clone(R.uniforms),vertexShader:R.vertexShader,fragmentShader:R.fragmentShader,lights:!0,side:w,fog:v});Z.uniforms.mirrorSampler.value=J.texture,Z.uniforms.textureMatrix.value=I,Z.uniforms.alpha.value=a,Z.uniforms.time.value=l,Z.uniforms.normalSampler.value=u,Z.uniforms.sunColor.value=d,Z.uniforms.waterColor.value=g,Z.uniforms.sunDirection.value=h,Z.uniforms.distortionScale.value=x,Z.uniforms.eye.value=y,n.material=Z,n.onBeforeRender=function(X,q,Y){if(M.setFromMatrixPosition(n.matrixWorld),_.setFromMatrixPosition(Y.matrixWorld),L.extractRotation(n.matrixWorld),D.set(0,0,1),D.applyMatrix4(L),m.subVectors(M,_),m.dot(D)>0)return;m.reflect(D).negate(),m.add(M),L.extractRotation(Y.matrixWorld),b.set(0,0,-1),b.applyMatrix4(L),b.add(_),S.subVectors(M,b),S.reflect(D).negate(),S.add(M),k.position.copy(m),k.up.set(0,1,0),k.up.applyMatrix4(L),k.up.reflect(D),k.lookAt(S),k.far=Y.far,k.updateMatrixWorld(),k.projectionMatrix.copy(Y.projectionMatrix),I.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),I.multiply(k.projectionMatrix),I.multiply(k.matrixWorldInverse),A.setFromNormalAndCoplanarPoint(D,M),A.applyMatrix4(k.matrixWorldInverse),C.set(A.normal.x,A.normal.y,A.normal.z,A.constant);const te=k.projectionMatrix;p.x=(Math.sign(C.x)+te.elements[8])/te.elements[0],p.y=(Math.sign(C.y)+te.elements[9])/te.elements[5],p.z=-1,p.w=(1+te.elements[10])/te.elements[14],C.multiplyScalar(2/C.dot(p)),te.elements[2]=C.x,te.elements[6]=C.y,te.elements[10]=C.z+1-i,te.elements[14]=C.w,y.setFromMatrixPosition(Y.matrixWorld);const re=X.getRenderTarget(),ce=X.xr.enabled,j=X.shadowMap.autoUpdate;n.visible=!1,X.xr.enabled=!1,X.shadowMap.autoUpdate=!1,X.setRenderTarget(J),X.state.buffers.depth.setMask(!0),X.autoClear===!1&&X.clear(),X.render(q,k),n.visible=!0,X.xr.enabled=ce,X.shadowMap.autoUpdate=j,X.setRenderTarget(re);const z=Y.viewport;z!==void 0&&X.state.viewport(z)}}}const Pf=["rotation-x","args"],Cf=f.createElementVNode("TresPlaneGeometry",{args:[1e4,1e4]},null,-1),Tf=f.defineComponent({__name:"Ocean",props:{textureWidth:{default:512},textureHeight:{default:512},waterNormals:{default:"https://raw.githubusercontent.com/Tresjs/assets/main/textures/water-normals/Water_1_M_Normal.jpg"},sunDirection:{default:()=>new c.Vector3},sunColor:{default:16777215},waterColor:{default:7695},distortionScale:{default:3.7},size:{default:1},clipBias:{default:0},alpha:{default:1},side:{default:c.FrontSide}},async setup(o,{expose:e}){let t,n;const r=o,{textureWidth:s,textureHeight:i,waterNormals:a,sunDirection:l,sunColor:u,waterColor:h,distortionScale:d,size:g,clipBias:y,alpha:x,side:w}=f.toRefs(r),{extend:v,scene:A}=ae.useTresContext();v({Water:Af});const D=f.shallowRef(),M=f.shallowRef(),_=A.value.fog!==void 0;e({root:D}),A.value.traverse(C=>{C.hasOwnProperty("isSky")&&(M.value=C)}),f.onMounted(async()=>{if(await f.nextTick(),M.value){const C=M.value.material.uniforms.sunPosition.value;D.value.material.uniforms.sunDirection.value.copy(C)}});const{normalMap:L}=([t,n]=f.withAsyncContext(()=>ae.useTexture({normalMap:a.value})),t=await t,n(),t);L.wrapS=L.wrapT=c.RepeatWrapping;const{onLoop:b}=ae.useRenderLoop();return b(({delta:C})=>{D.value.material.uniforms.time.value+=C}),(C,m)=>(f.openBlock(),f.createElementBlock("TresWater",{ref_key:"waterRef",ref:D,"rotation-x":-Math.PI/2,args:[void 0,{textureWidth:f.unref(s),textureHeight:f.unref(i),waterNormals:f.unref(L),sunDirection:f.unref(l),sunColor:f.unref(u),waterColor:f.unref(h),distortionScale:f.unref(d),fog:_,size:f.unref(g),clipBias:f.unref(y),alpha:f.unref(x),side:f.unref(w)}]},[f.renderSlot(C.$slots,"default",{},()=>[Cf])],8,Pf))}});let ot;const Lf=(o="body")=>{ot||(ot=new Wi.Pane({container:document.querySelector(o)}),ot.element.style.position="absolute",ot.element.style.top="1rem",ot.element.style.right="1rem",ot.element.style.zIndex="9999");const{logWarning:e}=lr();e("useTweakPane is deprecated as of Cientos v3.7.0 and will no longer be part of this package. Please migrate to @tresjs/leches package https://github.com/Tresjs/leches or v-tweakpane https://github.com/vinayakkulkarni/v-tweakpane instead.");function t(){ot&&ot.dispose()}return f.onMounted(()=>{const{resume:n}=ae.useRenderLoop();n()}),f.onUnmounted(()=>{t()}),{pane:ot,disposeTweakPane:t}};var Bi={exports:{}};(function(o,e){(function(t,n){o.exports=n()})(Oc,function(){var t=function(){function n(y){return i.appendChild(y.dom),y}function r(y){for(var x=0;x<i.children.length;x++)i.children[x].style.display=x===y?"block":"none";s=y}var s=0,i=document.createElement("div");i.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",i.addEventListener("click",function(y){y.preventDefault(),r(++s%i.children.length)},!1);var a=(performance||Date).now(),l=a,u=0,h=n(new t.Panel("FPS","#0ff","#002")),d=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var g=n(new t.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:i,addPanel:n,showPanel:r,begin:function(){a=(performance||Date).now()},end:function(){u++;var y=(performance||Date).now();if(d.update(y-a,200),y>l+1e3&&(h.update(1e3*u/(y-l),100),l=y,u=0,g)){var x=performance.memory;g.update(x.usedJSHeapSize/1048576,x.jsHeapSizeLimit/1048576)}return y},update:function(){a=this.end()},domElement:i,setMode:r}};return t.Panel=function(n,r,s){var i=1/0,a=0,l=Math.round,u=l(window.devicePixelRatio||1),h=80*u,d=48*u,g=3*u,y=2*u,x=3*u,w=15*u,v=74*u,A=30*u,D=document.createElement("canvas");D.width=h,D.height=d,D.style.cssText="width:80px;height:48px";var M=D.getContext("2d");return M.font="bold "+9*u+"px Helvetica,Arial,sans-serif",M.textBaseline="top",M.fillStyle=s,M.fillRect(0,0,h,d),M.fillStyle=r,M.fillText(n,g,y),M.fillRect(x,w,v,A),M.fillStyle=s,M.globalAlpha=.9,M.fillRect(x,w,v,A),{dom:D,update:function(_,L){i=Math.min(i,_),a=Math.max(a,_),M.fillStyle=s,M.globalAlpha=1,M.fillRect(0,0,h,w),M.fillStyle=r,M.fillText(l(_)+" "+n+" ("+l(i)+"-"+l(a)+")",g,y),M.drawImage(D,x+u,w,v-u,A,x,w,v-u,A),M.fillRect(x+v-u,w,u,A),M.fillStyle=s,M.globalAlpha=.9,M.fillRect(x+v-u,w,u,l((1-_/L)*A))}}},t})})(Bi);var Df=Bi.exports;const If=sn(Df),Of=f.defineComponent({name:"Stats",props:{showPanel:{type:Number,default:0}},setup(o,{expose:e}){const t=new If;e({stats:t});const n=document.body;t.showPanel(o.showPanel||0),n==null||n.appendChild(t.dom);const{onBeforeLoop:r,onAfterLoop:s,resume:i}=ae.useRenderLoop();i(),r(()=>t.begin()),s(()=>t.end()),f.onUnmounted(()=>{n==null||n.removeChild(t.dom)})}});class kf{constructor(e,t,n){this.name=e,this.fg=t,this.bg=n,this.PR=Math.round(window.devicePixelRatio||1),this.WIDTH=90*this.PR,this.HEIGHT=48*this.PR,this.TEXT_X=3*this.PR,this.TEXT_Y=2*this.PR,this.GRAPH_X=3*this.PR,this.GRAPH_Y=15*this.PR,this.GRAPH_WIDTH=84*this.PR,this.GRAPH_HEIGHT=30*this.PR,this.canvas=document.createElement("canvas"),this.canvas.width=90*this.PR,this.canvas.height=48*this.PR,this.canvas.style.width="90px",this.canvas.style.position="absolute",this.canvas.style.height="48px",this.canvas.style.cssText="width:90px;height:48px",this.context=this.canvas.getContext("2d"),this.context&&(this.context.font="bold "+9*this.PR+"px Helvetica,Arial,sans-serif",this.context.textBaseline="top",this.context.fillStyle=this.bg,this.context.fillRect(0,0,this.WIDTH,this.HEIGHT),this.context.fillStyle=this.fg,this.context.fillText(this.name,this.TEXT_X,this.TEXT_Y),this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT),this.context.fillStyle=this.bg,this.context.globalAlpha=.9,this.context.fillRect(this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH,this.GRAPH_HEIGHT))}update(e,t,n,r,s=0){let i=1/0,a=0;this.context&&(i=Math.min(i,e),a=Math.max(n,e),r=Math.max(r,t),this.context.fillStyle=this.bg,this.context.globalAlpha=1,this.context.fillRect(0,0,this.WIDTH,this.GRAPH_Y),this.context.fillStyle=this.fg,this.context.fillText(e.toFixed(s)+" "+this.name+" ("+i.toFixed(s)+"-"+parseFloat(a.toFixed(s))+")",this.TEXT_X,this.TEXT_Y),this.context.drawImage(this.canvas,this.GRAPH_X+this.PR,this.GRAPH_Y,this.GRAPH_WIDTH-this.PR,this.GRAPH_HEIGHT,this.GRAPH_X,this.GRAPH_Y,this.GRAPH_WIDTH-this.PR,this.GRAPH_HEIGHT),this.context.fillRect(this.GRAPH_X+this.GRAPH_WIDTH-this.PR,this.GRAPH_Y,this.PR,this.GRAPH_HEIGHT),this.context.fillStyle=this.bg,this.context.globalAlpha=.9,this.context.fillRect(this.GRAPH_X+this.GRAPH_WIDTH-this.PR,this.GRAPH_Y,this.PR,(1-t/r)*this.GRAPH_HEIGHT))}}const Fi=class zn{constructor({logsPerSecond:e=20,samplesLog:t=100,samplesGraph:n=10,precision:r=2,minimal:s=!1,horizontal:i=!0,mode:a=0}={}){this.totalCpuDuration=0,this.totalGpuDuration=0,this.totalFps=0,this.activeQuery=null,this.gpuQueries=[],this.renderCount=0,this.mode=a,this.horizontal=i,this.dom=document.createElement("div"),this.dom.style.cssText="position:fixed;top:0;left:0;opacity:0.9;z-index:10000;",s&&(this.dom.style.cssText+="cursor:pointer"),this.gl=null,this.query=null,this.isRunningCPUProfiling=!1,this.minimal=s,this.beginTime=(performance||Date).now(),this.prevTime=this.beginTime,this.prevCpuTime=this.beginTime,this.frames=0,this.renderCount=0,this.threeRendererPatched=!1,this.averageCpu={logs:[],graph:[]},this.averageGpu={logs:[],graph:[]},this.queryCreated=!1,this.fpsPanel=this.addPanel(new zn.Panel("FPS","#0ff","#002"),0),this.msPanel=this.addPanel(new zn.Panel("CPU","#0f0","#020"),1),this.gpuPanel=null,this.samplesLog=t,this.samplesGraph=n,this.precision=r,this.logsPerSecond=e,this.minimal?(this.dom.addEventListener("click",l=>{l.preventDefault(),this.showPanel(++this.mode%this.dom.children.length)},!1),this.mode=a,this.showPanel(this.mode)):window.addEventListener("resize",()=>{this.resizePanel(this.fpsPanel,0),this.resizePanel(this.msPanel,1),this.gpuPanel&&this.resizePanel(this.gpuPanel,2)})}patchThreeRenderer(e){const t=e.render,n=this;e.render=function(r,s){n.begin(),t.call(this,r,s),n.end()},this.threeRendererPatched=!0}resizePanel(e,t){e.canvas.style.position="absolute",this.minimal?e.canvas.style.display="none":(e.canvas.style.display="block",this.horizontal?(e.canvas.style.top="0px",e.canvas.style.left=t*e.WIDTH/e.PR+"px"):(e.canvas.style.left="0px",e.canvas.style.top=t*e.HEIGHT/e.PR+"px"))}addPanel(e,t){return e.canvas&&(this.dom.appendChild(e.canvas),this.resizePanel(e,t)),e}showPanel(e){for(let t=0;t<this.dom.children.length;t++){const n=this.dom.children[t];n.style.display=t===e?"block":"none"}this.mode=e}init(e){if(!e){console.error('Stats: The "canvas" parameter is undefined.');return}if(e.isWebGLRenderer&&!this.threeRendererPatched){const t=e;this.patchThreeRenderer(t),this.gl=t.getContext()}if(!this.gl&&e instanceof WebGL2RenderingContext)this.gl=e;else if(!this.gl&&e instanceof HTMLCanvasElement||e instanceof OffscreenCanvas){if(this.gl=e.getContext("webgl2"),!this.gl){console.error("Stats: Unable to obtain WebGL2 context.");return}}else if(!this.gl){console.error("Stats: Invalid input type. Expected WebGL2RenderingContext, HTMLCanvasElement, or OffscreenCanvas.");return}this.ext=this.gl.getExtension("EXT_disjoint_timer_query_webgl2"),this.ext&&(this.gpuPanel=this.addPanel(new zn.Panel("GPU","#ff0","#220"),2))}begin(){this.isRunningCPUProfiling||this.beginProfiling("cpu-started"),!(!this.gl||!this.ext)&&this.gl&&this.ext&&(this.activeQuery&&this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.activeQuery=this.gl.createQuery(),this.activeQuery!==null&&this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,this.activeQuery))}end(){this.renderCount++,this.gl&&this.ext&&this.activeQuery&&(this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.gpuQueries.push({query:this.activeQuery}),this.activeQuery=null)}processGpuQueries(){!this.gl||!this.ext||(this.totalGpuDuration=0,this.gpuQueries.forEach((e,t)=>{if(this.gl){const n=this.gl.getQueryParameter(e.query,this.gl.QUERY_RESULT_AVAILABLE),r=this.gl.getParameter(this.ext.GPU_DISJOINT_EXT);if(n&&!r){const i=this.gl.getQueryParameter(e.query,this.gl.QUERY_RESULT)*1e-6;this.totalGpuDuration+=i,this.gl.deleteQuery(e.query),this.gpuQueries.splice(t,1)}}}))}update(){this.processGpuQueries(),this.endProfiling("cpu-started","cpu-finished","cpu-duration"),this.addToAverage(this.totalCpuDuration,this.averageCpu),this.addToAverage(this.totalGpuDuration,this.averageGpu),this.renderCount=0,this.totalCpuDuration=0,this.totalGpuDuration=0,this.totalFps=0,this.beginTime=this.endInternal()}endInternal(){this.frames++;const e=(performance||Date).now();if(e>=this.prevCpuTime+1e3/this.logsPerSecond&&(this.updatePanel(this.msPanel,this.averageCpu),this.updatePanel(this.gpuPanel,this.averageGpu),this.prevCpuTime=e),e>=this.prevTime+1e3){const t=this.frames*1e3/(e-this.prevTime);this.fpsPanel.update(t,t,100,100,0),this.prevTime=e,this.frames=0}return e}addToAverage(e,t){t.logs.push(e),t.logs.length>this.samplesLog&&t.logs.shift(),t.graph.push(e),t.graph.length>this.samplesGraph&&t.graph.shift()}beginProfiling(e){window.performance&&(window.performance.mark(e),this.isRunningCPUProfiling=!0)}endProfiling(e,t,n){if(window.performance&&t&&this.isRunningCPUProfiling){window.performance.mark(t);const r=performance.measure(n,e,t);this.totalCpuDuration+=r.duration,this.isRunningCPUProfiling=!1}}updatePanel(e,t){if(t.logs.length>0){let n=0,r=.01;for(let a=0;a<t.logs.length;a++)n+=t.logs[a],t.logs[a]>r&&(r=t.logs[a]);let s=0,i=.01;for(let a=0;a<t.graph.length;a++)s+=t.graph[a],t.graph[a]>i&&(i=t.graph[a]);e&&e.update(n/Math.min(t.logs.length,this.samplesLog),s/Math.min(t.graph.length,this.samplesGraph),r,i,this.precision)}}get domElement(){return this.dom}get container(){return console.warn("Stats: Deprecated! this.container as been replaced to this.dom "),this.dom}};Fi.Panel=kf;let Bf=Fi;const Ff=f.defineComponent({name:"StatsGl",props:["logsPerSecond","samplesLog","samplesGraph","precision","horizontal","minimal","mode"],async setup(o,{expose:e}){const t=new Bf({logsPerSecond:o.logsPerSecond,samplesLog:o.samplesLog,samplesGraph:o.samplesGraph,precision:o.precision,horizontal:o.horizontal,minimal:o.minimal,mode:o.mode});e({statsGl:t});const n=document.body,r=t.dom||t.container;n==null||n.appendChild(r);const{renderer:s}=ae.useTresContext(),{onAfterLoop:i,resume:a}=ae.useRenderLoop();t.init(s.value),a(),i(()=>{t.update()}),f.onUnmounted(()=>{n==null||n.removeChild(r)})}}),Uf=f.defineComponent({name:"BakeShadows",setup(){const{renderer:o}=ae.useTresContext();f.watchEffect(()=>{o.value.shadowMap.autoUpdate=!1,o.value.shadowMap.needsUpdate=!0})}});var Nf=`#include <common>
|
|
1159
1255
|
|
|
1160
1256
|
void main() {
|
|
1161
1257
|
vec2 center = vec2(0., 1.);
|
|
@@ -1180,6 +1276,6 @@ void main() {
|
|
|
1180
1276
|
mvPosition.xy += rotatedPosition;
|
|
1181
1277
|
|
|
1182
1278
|
gl_Position = projectionMatrix * mvPosition;
|
|
1183
|
-
}`,
|
|
1279
|
+
}`,zf=`void main() {
|
|
1184
1280
|
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
|
1185
|
-
}`;const on=new c.Vector3(0,0,0),Fs=new c.Vector3(0,0,0),Lf=new c.Vector3(0,0,0);function ki(o,e,t){const n=on.setFromMatrixPosition(o.matrixWorld);n.project(e);const s=t.width/2,r=t.height/2;return[(Number.isNaN(n.x)?0:n.x)*s+s,-(n.y*r)+r]}function If(o,e){const t=on.setFromMatrixPosition(o.matrixWorld),n=Fs.setFromMatrixPosition(e.matrixWorld),s=t.sub(n),r=e.getWorldDirection(Lf);return s.angleTo(r)>Math.PI/2}function Df(o,e,t,n){const s=on.setFromMatrixPosition(o.matrixWorld),r=s.clone();r.project(e),t.setFromCamera(new c.Vector2(r.x,r.y),e);const i=t.intersectObjects(n,!0);if(i.length>0){const a=i[0].distance;return s.distanceTo(t.ray.origin)<a}return!0}function Of(o,e){if(e instanceof c.OrthographicCamera)return e.zoom;if(e instanceof c.PerspectiveCamera){const t=on.setFromMatrixPosition(o.matrixWorld),n=Fs.setFromMatrixPosition(e.matrixWorld),s=e.fov*Math.PI/180,r=t.distanceTo(n);return 1/(2*Math.tan(s/2)*r)}else return 1}function Ff(o,e,t){if(e instanceof c.PerspectiveCamera||e instanceof c.OrthographicCamera){const n=on.setFromMatrixPosition(o.matrixWorld),s=Fs.setFromMatrixPosition(e.matrixWorld),r=n.distanceTo(s),i=(t[1]-t[0])/(e.far-e.near),a=t[1]-i*e.far;return Math.round(i*r+a)}}const ks=o=>Math.abs(o)<1e-10?0:o;function Bi(o,e,t=""){let n="matrix3d(";for(let s=0;s!==16;s++)n+=ks(e[s]*o.elements[s])+(s!==15?",":")");return t+n}const kf=(o=>e=>Bi(e,o))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),Bf=(o=>(e,t)=>Bi(e,o(t),"translate(-50%,-50%)"))(o=>[1/o,1/o,1/o,1,-1/o,-1/o,-1/o,-1,1/o,1/o,1/o,1,1,1,1,1]),Uf=["geometry","material"],Nf=f.defineComponent({__name:"HTML",props:{geometry:{default:new c.PlaneGeometry},material:{},as:{default:"div"},transform:{type:Boolean,default:!1},portal:{},wrapperClass:{},eps:{default:1e-4},distanceFactor:{},fullscreen:{type:Boolean},center:{type:Boolean},pointerEvents:{default:"auto"},sprite:{type:Boolean,default:!1},zIndexRange:{default:()=>[16777271,0]},occlude:{type:[Array,Boolean,String]}},emits:["onOcclude"],setup(o,{emit:e}){const t=o,n=e,s=f.useAttrs(),r=f.useSlots(),i=f.ref(),a=f.ref(),{geometry:l,material:u,as:h,transform:d,portal:y,wrapperClass:g,eps:x,distanceFactor:w,fullscreen:v,center:P,pointerEvents:D,sprite:S,occlude:_,zIndexRange:L}=f.toRefs(t),{renderer:b,scene:C,camera:m,raycaster:M,sizes:p}=ae.useTresContext(),I=f.computed(()=>document.createElement(h.value)),F=f.ref([0,0]),J=f.ref(0),G=f.ref(),Q=f.computed(()=>d.value?{position:"absolute",top:0,left:0,width:`${p.width.value}px`,height:`${p.height.value}px`,transformStyle:"preserve-3d",pointerEvents:"none",zIndex:2,willChange:"transform"}:{position:"absolute",transform:P.value?"translate3d(-50%,-50%,0)":"none",...v.value&&{top:-p.height.value/2,left:-p.width.value/2,width:`${p.width.value}px`,height:`${p.height.value}px`},zIndex:2,...s.style,willChange:"transform"}),K=f.computed(()=>({position:"absolute",pointerEvents:D.value})),Z=f.ref(null),X=f.ref(!1),ne=f.computed(()=>(_==null?void 0:_.value)&&(_==null?void 0:_.value)!=="blending"||Array.isArray(_==null?void 0:_.value)&&(_==null?void 0:_.value.length)&&f.isRef(_.value[0]));f.watch(()=>_,A=>{A&&A==="blending"?(I.value.style.zIndex=`${Math.floor(L.value[0]/2)}`,I.value.style.position="absolute",I.value.style.pointerEvents="none"):(I.value.style.zIndex=null,I.value.style.position=null,I.value.style.pointerEvents=null)}),f.watch(()=>{var A;return[i.value,b.value,p.width.value,p.height.value,(A=r.default)==null?void 0:A.call(r)]},([A,V])=>{var ee,N,R,T,O,k;if(A&&V){const E=(y==null?void 0:y.value)||V.domElement;if((ee=C.value)==null||ee.updateMatrixWorld(),d.value)I.value.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const q=ki(A,m.value,{width:p.width.value,height:p.height.value});I.value.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${q[0]}px,${q[1]}px,0);transform-origin:0 0;`}E&&!I.value.parentNode&&((N=E.parentNode)==null||N.appendChild(I.value)),d.value?G.value=f.createVNode("div",{id:"outer",style:Q.value},[f.createVNode("div",{id:"inner",style:K.value},[f.createVNode("div",{key:(R=a.value)==null?void 0:R.uuid,id:C==null?void 0:C.value.uuid,class:s.class,style:s.style},(T=r.default)==null?void 0:T.call(r))])]):G.value=f.createVNode("div",{key:(O=a.value)==null?void 0:O.uuid,id:C==null?void 0:C.value.uuid,style:Q.value},(k=r.default)==null?void 0:k.call(r)),f.render(G.value,I.value)}}),f.watchEffect(()=>{g!=null&&g.value&&(I.value.className=g.value)});const se=f.ref(!0),{onLoop:ue}=ae.useRenderLoop();ue(()=>{var A,V,ee,N,R,T,O;if(i.value&&m.value&&b.value){(A=m.value)==null||A.updateMatrixWorld(),i.value.updateWorldMatrix(!0,!1);const k=d.value?F.value:ki(i.value,m.value,{width:p.width.value||0,height:p.height.value||0});if(d.value||Math.abs(J.value-m.value.zoom)>x.value||Math.abs(F.value[0]-k[0])>x.value||Math.abs(F.value[1]-k[1])>x.value){const E=If(i.value,m.value);let q=!1;ne.value&&(Array.isArray(_==null?void 0:_.value)?q=_==null?void 0:_.value:(_==null?void 0:_.value)!=="blending"&&(q=[C.value]));const W=se.value;if(q){const B=Df(i.value,m.value,M.value,q);se.value=B&&!E}else se.value=!E;W!==se.value&&(n("onOcclude",!se.value),I.value.style.display=se.value?"block":"none");const te=Math.floor(L.value[0]/2),U=_!=null&&_.value?ne.value?[L.value[0],te]:[te-1,0]:L.value;if(I.value.style.zIndex=`${Ff(i.value,m.value,U)}`,I.value.style.willChange="transform",d.value){const[B,oe]=[p.width.value/2,p.height.value/2],ce=m.value.projectionMatrix.elements[5]*oe,{isOrthographicCamera:ge,top:_e,left:xe,bottom:Oe,right:at}=m.value,an=kf(m.value.matrixWorldInverse),Rt=ge?`scale(${ce})translate(${ks(-(at+xe)/2)}px,${ks((_e+Oe)/2)}px)`:`translateZ(${ce}px)`;let Ke=i.value.matrixWorld;S.value&&(Ke=m.value.matrixWorldInverse.clone().transpose().copyPosition(Ke).scale(i.value.scale),Ke.elements[3]=Ke.elements[7]=Ke.elements[11]=0,Ke.elements[15]=1),I.value.style.width=`${p.width.value}px`,I.value.style.height=`${p.height.value}px`,I.value.style.perspective=ge?"":`${ce}px`,(V=G.value)!=null&&V.el&&((ee=G.value)!=null&&ee.children)&&(G.value.el.style.willChange="transform",G.value.el.style.transform=`${Rt}${an}translate(${B}px,${oe}px)`,G.value.children[0].willChange="transform",G.value.children[0].el.style.transform=Bf(Ke,1/(((w==null?void 0:w.value)||10)/400)))}else{const B=(w==null?void 0:w.value)===void 0?1:Of(i.value,m.value)*(w==null?void 0:w.value);I.value.style.transform=`translate3d(${k[0]}px,${k[1]}px,0) scale(${B})`}}F.value=k,J.value=m.value.zoom}if(!ne.value&&a.value&&!X.value)if(d.value){if((N=G.value)!=null&&N.el&&((R=G.value)!=null&&R.children)){const k=(T=G.value)==null?void 0:T.children[0];if(k!=null&&k.clientWidth&&(k!=null&&k.clientHeight)){const{isOrthographicCamera:E}=m.value;if(E||l)s.scale&&(Array.isArray(s.scale)?s.scale instanceof c.Vector3?a.value.scale.copy(s.scale.clone().divideScalar(1)):a.value.scale.set(1/s.scale[0],1/s.scale[1],1/s.scale[2]):a.value.scale.setScalar(1/s.scale));else{const q=((w==null?void 0:w.value)||10)/400,W=k.clientWidth*q,te=k.clientHeight*q;a.value.scale.set(W,te,1)}X.value=!0}}}else{const k=I.value.children[0];if(k!=null&&k.clientWidth&&(k!=null&&k.clientHeight)){const q=k.clientWidth*1,W=k.clientHeight*1;a.value.scale.set(q,W,1),X.value=!0}Z.value.lookAt((O=m.value)==null?void 0:O.position)}});const j=f.computed(()=>({vertexShader:d.value?void 0:Cf,fragmentShader:Tf})),z=f.computed(()=>{const A=j.value;return u.value||new c.ShaderMaterial({vertexShader:A.vertexShader,fragmentShader:A.fragmentShader,side:c.DoubleSide})});return f.onUnmounted(()=>{z.value&&z.value.dispose(),I.value.remove()}),(A,V)=>(f.openBlock(),f.createElementBlock("TresGroup",{ref_key:"groupRef",ref:i},[f.unref(_)&&!ne.value?(f.openBlock(),f.createElementBlock("TresMesh",{key:0,ref_key:"meshRef",ref:a,geometry:f.unref(l),material:z.value},null,8,Uf)):f.createCommentVNode("",!0)],512))}}),{logError:zf}=ae.useLogger();async function Vf(o,e){const t=new Vn,n=(e==null?void 0:e.fileName)||"scene";t.parse(o,s=>{if(s instanceof ArrayBuffer)Gf(s,`${n}.glb`);else{const r=JSON.stringify(s,null,2);Rf(r,`${n}.gltf`)}},s=>{zf("An error happened while exporting the GLTF",s)},e)}function Rf(o,e){Ui(new Blob([o],{type:"text/plain"}),e)}function Gf(o,e){Ui(new Blob([o],{type:"application/octet-stream"}),e)}function Ui(o,e){const t=document.createElement("a");t.style.display="none",document.body.appendChild(t),t.href=URL.createObjectURL(o),t.download=e,t.click(),t.remove()}const jf={mounted:(o,e)=>{if(e.arg){console.log(`v-log:${e.arg}`,o[e.arg]);return}console.log("v-log",o)}},{logWarning:Ni}=ae.useLogger(),Ef={mounted:o=>{if(!o.isLight){Ni(`${o.type} is not a light`);return}kn=Yf[o.type],o.parent.add(new kn(o))},updated:o=>{Vt=o.parent.children.find(e=>e instanceof kn),!(Vt instanceof wr)&&Vt.update()},unmounted:o=>{if(!o.isLight){Ni(`${o.type} is not a light`);return}Vt=o.parent.children.find(e=>e instanceof kn),Vt.dispose(),o.parent.remove(Vt)}};let kn,Vt;const Yf={DirectionalLight:c.DirectionalLightHelper,PointLight:c.PointLightHelper,SpotLight:c.SpotLightHelper,HemisphereLight:c.HemisphereLightHelper,RectAreaLight:wr};function Xf(o,e){const t={};for(const n of e)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n]);return t}function Wf(o,e){const t=`set${e[0].toUpperCase()}${e.slice(1)}`;return o[t]!==void 0}function Bs(o){var t,n;let e=o.value;return o.value&&((n=(t=o.value)==null?void 0:t.value)!=null&&n.isMesh)&&(e=o.value.value.position),Array.isArray(o.value)&&(e=new c.Vector3(...e)),e}const{logWarning:Zf}=ae.useLogger(),Kf={updated:(o,e)=>{const t=Bs(e);if(!t){Zf(`v-always-look-at: problem with binding value: ${e.value}`);return}const{onLoop:n}=ae.useRenderLoop();n(()=>{o.lookAt(t)})}},{logWarning:qf}=ae.useLogger(),Qf={updated:(o,e)=>{var s;const t=Bs(e);if(!t){qf(`v-distance-to: problem with binding value: ${e.value}`);return}ot&&(ot.dispose(),o.parent.remove(ot));const n=t.clone().sub(o.position);n.normalize(),ot=new c.ArrowHelper(n,o.position,o.position.distanceTo(t)/1.5,16776960),o.parent.add(ot),console.table([["Distance:",o.position.distanceTo(t)],[`origin: ${o.name||o.type}`,`x:${o.position.x}, y:${o.position.y}, z:${(s=o.position)==null?void 0:s.z}`],[`Destiny: ${o.name||o.type}`,`x:${t.x}, y:${t.y}, z:${t==null?void 0:t.z}`]])},unmounted:o=>{ot==null||ot.dispose(),o.parent.remove(ot)}};let ot=null;re.Backdrop=Uh,re.BakeShadows=Pf,re.Box=zu,re.CameraControls=yc,re.CatmullRomCurve3=Yu,re.Circle=Zu,re.Cone=Qu,re.ContactShadows=jh,re.CustomShaderMaterial=Lu,re.Dodecahedron=$u,re.Environment=Oh,re.FBXModel=Kl,re.Fbo=Gl,re.GLTFModel=Wl,re.GlobalAudio=Ml,re.Html=Nf,re.Icosahedron=nh,re.KeyboardControls=rc,re.Lensflare=Rl,re.Levioso=$a,re.Line2=Li,re.MapControls=uc,re.MeshGlassMaterial=Tc,re.MeshReflectionMaterial=Bu,re.MeshWobbleMaterial=xc,re.MouseParallax=bl,re.Octahedron=ih,re.OrbitControls=ec,re.Plane=ch,re.PointerLockControls=lc,re.Precipitation=Xh,re.Reflector=nl,re.Ring=fh,re.SVG=Ql,re.Sampler=jl,re.ScrollControls=hc,re.Sky=Zh,re.Smoke=Hh,re.Sparkles=mf,re.Sphere=mh,re.Stars=_f,re.Stats=bf,re.StatsGl=Af,re.Superformula=_h,re.Tetrahedron=bh,re.Text3D=Ja,re.Torus=Ah,re.TorusKnot=Th,re.TransformControls=oc,re.Tube=Dh,re.extractBindingPosition=Bs,re.hasSetter=Wf,re.pick=Xf,re.useAnimations=Ha,re.useEnvironment=Vr,re.useFBO=Nr,re.useFBX=Gr,re.useGLTF=Rr,re.useGLTFExporter=Vf,re.useProgress=Jl,re.useSurfaceSampler=zr,re.useTweakPane=vf,re.useVideoTexture=Hl,re.vAlwaysLookAt=Kf,re.vDistanceTo=Qf,re.vLightHelper=Ef,re.vLog=jf,Object.defineProperty(re,Symbol.toStringTag,{value:"Module"})});
|
|
1281
|
+
}`;const ln=new c.Vector3(0,0,0),Fr=new c.Vector3(0,0,0),Vf=new c.Vector3(0,0,0);function Ui(o,e,t){const n=ln.setFromMatrixPosition(o.matrixWorld);n.project(e);const r=t.width/2,s=t.height/2;return[(Number.isNaN(n.x)?0:n.x)*r+r,-(n.y*s)+s]}function Rf(o,e){const t=ln.setFromMatrixPosition(o.matrixWorld),n=Fr.setFromMatrixPosition(e.matrixWorld),r=t.sub(n),s=e.getWorldDirection(Vf);return r.angleTo(s)>Math.PI/2}function Gf(o,e,t,n){const r=ln.setFromMatrixPosition(o.matrixWorld),s=r.clone();s.project(e),t.setFromCamera(new c.Vector2(s.x,s.y),e);const i=t.intersectObjects(n,!0);if(i.length>0){const a=i[0].distance;return r.distanceTo(t.ray.origin)<a}return!0}function jf(o,e){if(e instanceof c.OrthographicCamera)return e.zoom;if(e instanceof c.PerspectiveCamera){const t=ln.setFromMatrixPosition(o.matrixWorld),n=Fr.setFromMatrixPosition(e.matrixWorld),r=e.fov*Math.PI/180,s=t.distanceTo(n);return 1/(2*Math.tan(r/2)*s)}else return 1}function Ef(o,e,t){if(e instanceof c.PerspectiveCamera||e instanceof c.OrthographicCamera){const n=ln.setFromMatrixPosition(o.matrixWorld),r=Fr.setFromMatrixPosition(e.matrixWorld),s=n.distanceTo(r),i=(t[1]-t[0])/(e.far-e.near),a=t[1]-i*e.far;return Math.round(i*s+a)}}const Ur=o=>Math.abs(o)<1e-10?0:o;function Ni(o,e,t=""){let n="matrix3d(";for(let r=0;r!==16;r++)n+=Ur(e[r]*o.elements[r])+(r!==15?",":")");return t+n}const Wf=(o=>e=>Ni(e,o))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),Yf=(o=>(e,t)=>Ni(e,o(t),"translate(-50%,-50%)"))(o=>[1/o,1/o,1/o,1,-1/o,-1/o,-1/o,-1,1/o,1/o,1/o,1,1,1,1,1]),Xf=["geometry","material"],Zf=f.defineComponent({__name:"HTML",props:{geometry:{default:new c.PlaneGeometry},material:{},as:{default:"div"},transform:{type:Boolean,default:!1},portal:{},wrapperClass:{},eps:{default:1e-4},distanceFactor:{},fullscreen:{type:Boolean},center:{type:Boolean},pointerEvents:{default:"auto"},sprite:{type:Boolean,default:!1},zIndexRange:{default:()=>[16777271,0]},occlude:{type:[Array,Boolean,String]}},emits:["onOcclude"],setup(o,{emit:e}){const t=o,n=e,r=f.useAttrs(),s=f.useSlots(),i=f.ref(),a=f.ref(),{geometry:l,material:u,as:h,transform:d,portal:g,wrapperClass:y,eps:x,distanceFactor:w,fullscreen:v,center:A,pointerEvents:D,sprite:M,occlude:_,zIndexRange:L}=f.toRefs(t),{renderer:b,scene:C,camera:m,raycaster:S,sizes:p}=ae.useTresContext(),I=f.computed(()=>document.createElement(h.value)),k=f.ref([0,0]),J=f.ref(0),R=f.ref(),Z=f.computed(()=>d.value?{position:"absolute",top:0,left:0,width:`${p.width.value}px`,height:`${p.height.value}px`,transformStyle:"preserve-3d",pointerEvents:"none",zIndex:2,willChange:"transform"}:{position:"absolute",transform:A.value?"translate3d(-50%,-50%,0)":"none",...v.value&&{top:-p.height.value/2,left:-p.width.value/2,width:`${p.width.value}px`,height:`${p.height.value}px`},zIndex:2,...r.style,willChange:"transform"}),X=f.computed(()=>({position:"absolute",pointerEvents:D.value})),q=f.ref(null),Y=f.ref(!1),te=f.computed(()=>(_==null?void 0:_.value)&&(_==null?void 0:_.value)!=="blending"||Array.isArray(_==null?void 0:_.value)&&(_==null?void 0:_.value.length)&&f.isRef(_.value[0]));f.watch(()=>_,P=>{P&&P==="blending"?(I.value.style.zIndex=`${Math.floor(L.value[0]/2)}`,I.value.style.position="absolute",I.value.style.pointerEvents="none"):(I.value.style.zIndex=null,I.value.style.position=null,I.value.style.pointerEvents=null)}),f.watch(()=>{var P;return[i.value,b.value,p.width.value,p.height.value,(P=s.default)==null?void 0:P.call(s)]},([P,V])=>{var ee,N,G,T,O,B;if(P&&V){const E=(g==null?void 0:g.value)||V.domElement;if((ee=C.value)==null||ee.updateMatrixWorld(),d.value)I.value.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const Q=Ui(P,m.value,{width:p.width.value,height:p.height.value});I.value.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${Q[0]}px,${Q[1]}px,0);transform-origin:0 0;`}E&&!I.value.parentNode&&((N=E.parentNode)==null||N.appendChild(I.value)),d.value?R.value=f.createVNode("div",{id:"outer",style:Z.value},[f.createVNode("div",{id:"inner",style:X.value},[f.createVNode("div",{key:(G=a.value)==null?void 0:G.uuid,id:C==null?void 0:C.value.uuid,class:r.class,style:r.style},(T=s.default)==null?void 0:T.call(s))])]):R.value=f.createVNode("div",{key:(O=a.value)==null?void 0:O.uuid,id:C==null?void 0:C.value.uuid,style:Z.value},(B=s.default)==null?void 0:B.call(s)),f.render(R.value,I.value)}}),f.watchEffect(()=>{y!=null&&y.value&&(I.value.className=y.value)});const re=f.ref(!0),{onLoop:ce}=ae.useRenderLoop();ce(()=>{var P,V,ee,N,G,T,O;if(i.value&&m.value&&b.value){(P=m.value)==null||P.updateMatrixWorld(),i.value.updateWorldMatrix(!0,!1);const B=d.value?k.value:Ui(i.value,m.value,{width:p.width.value||0,height:p.height.value||0});if(d.value||Math.abs(J.value-m.value.zoom)>x.value||Math.abs(k.value[0]-B[0])>x.value||Math.abs(k.value[1]-B[1])>x.value){const E=Rf(i.value,m.value);let Q=!1;te.value&&(Array.isArray(_==null?void 0:_.value)?Q=_==null?void 0:_.value:(_==null?void 0:_.value)!=="blending"&&(Q=[C.value]));const K=re.value;if(Q){const F=Gf(i.value,m.value,S.value,Q);re.value=F&&!E}else re.value=!E;K!==re.value&&(n("onOcclude",!re.value),I.value.style.display=re.value?"block":"none");const ne=Math.floor(L.value[0]/2),U=_!=null&&_.value?te.value?[L.value[0],ne]:[ne-1,0]:L.value;if(I.value.style.zIndex=`${Ef(i.value,m.value,U)}`,I.value.style.willChange="transform",d.value){const[F,oe]=[p.width.value/2,p.height.value/2],ue=m.value.projectionMatrix.elements[5]*oe,{isOrthographicCamera:ge,top:_e,left:xe,bottom:Oe,right:lt}=m.value,cn=Wf(m.value.matrixWorldInverse),Gt=ge?`scale(${ue})translate(${Ur(-(lt+xe)/2)}px,${Ur((_e+Oe)/2)}px)`:`translateZ(${ue}px)`;let qe=i.value.matrixWorld;M.value&&(qe=m.value.matrixWorldInverse.clone().transpose().copyPosition(qe).scale(i.value.scale),qe.elements[3]=qe.elements[7]=qe.elements[11]=0,qe.elements[15]=1),I.value.style.width=`${p.width.value}px`,I.value.style.height=`${p.height.value}px`,I.value.style.perspective=ge?"":`${ue}px`,(V=R.value)!=null&&V.el&&((ee=R.value)!=null&&ee.children)&&(R.value.el.style.willChange="transform",R.value.el.style.transform=`${Gt}${cn}translate(${F}px,${oe}px)`,R.value.children[0].willChange="transform",R.value.children[0].el.style.transform=Yf(qe,1/(((w==null?void 0:w.value)||10)/400)))}else{const F=(w==null?void 0:w.value)===void 0?1:jf(i.value,m.value)*(w==null?void 0:w.value);I.value.style.transform=`translate3d(${B[0]}px,${B[1]}px,0) scale(${F})`}}k.value=B,J.value=m.value.zoom}if(!te.value&&a.value&&!Y.value)if(d.value){if((N=R.value)!=null&&N.el&&((G=R.value)!=null&&G.children)){const B=(T=R.value)==null?void 0:T.children[0];if(B!=null&&B.clientWidth&&(B!=null&&B.clientHeight)){const{isOrthographicCamera:E}=m.value;if(E||l)r.scale&&(Array.isArray(r.scale)?r.scale instanceof c.Vector3?a.value.scale.copy(r.scale.clone().divideScalar(1)):a.value.scale.set(1/r.scale[0],1/r.scale[1],1/r.scale[2]):a.value.scale.setScalar(1/r.scale));else{const Q=((w==null?void 0:w.value)||10)/400,K=B.clientWidth*Q,ne=B.clientHeight*Q;a.value.scale.set(K,ne,1)}Y.value=!0}}}else{const B=I.value.children[0];if(B!=null&&B.clientWidth&&(B!=null&&B.clientHeight)){const Q=B.clientWidth*1,K=B.clientHeight*1;a.value.scale.set(Q,K,1),Y.value=!0}q.value.lookAt((O=m.value)==null?void 0:O.position)}});const j=f.computed(()=>({vertexShader:d.value?void 0:Nf,fragmentShader:zf})),z=f.computed(()=>{const P=j.value;return u.value||new c.ShaderMaterial({vertexShader:P.vertexShader,fragmentShader:P.fragmentShader,side:c.DoubleSide})});return f.onUnmounted(()=>{z.value&&z.value.dispose(),I.value.remove()}),(P,V)=>(f.openBlock(),f.createElementBlock("TresGroup",{ref_key:"groupRef",ref:i},[f.unref(_)&&!te.value?(f.openBlock(),f.createElementBlock("TresMesh",{key:0,ref_key:"meshRef",ref:a,geometry:f.unref(l),material:z.value},null,8,Xf)):f.createCommentVNode("",!0)],512))}}),{logError:Kf}=ae.useLogger();async function qf(o,e){const t=new Gn,n=(e==null?void 0:e.fileName)||"scene";t.parse(o,r=>{if(r instanceof ArrayBuffer)Jf(r,`${n}.glb`);else{const s=JSON.stringify(r,null,2);Qf(s,`${n}.gltf`)}},r=>{Kf("An error happened while exporting the GLTF",r)},e)}function Qf(o,e){zi(new Blob([o],{type:"text/plain"}),e)}function Jf(o,e){zi(new Blob([o],{type:"application/octet-stream"}),e)}function zi(o,e){const t=document.createElement("a");t.style.display="none",document.body.appendChild(t),t.href=URL.createObjectURL(o),t.download=e,t.click(),t.remove()}const Hf={mounted:(o,e)=>{if(e.arg){console.log(`v-log:${e.arg}`,o[e.arg]);return}console.log("v-log",o)}},{logWarning:Vi}=ae.useLogger(),$f={mounted:o=>{if(!o.isLight){Vi(`${o.type} is not a light`);return}Un=ed[o.type],o.parent.add(new Un(o))},updated:o=>{Rt=o.parent.children.find(e=>e instanceof Un),!(Rt instanceof Ms)&&Rt.update()},unmounted:o=>{if(!o.isLight){Vi(`${o.type} is not a light`);return}Rt=o.parent.children.find(e=>e instanceof Un),Rt.dispose(),o.parent.remove(Rt)}};let Un,Rt;const ed={DirectionalLight:c.DirectionalLightHelper,PointLight:c.PointLightHelper,SpotLight:c.SpotLightHelper,HemisphereLight:c.HemisphereLightHelper,RectAreaLight:Ms};function td(o,e){const t={};for(const n of e)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n]);return t}function nd(o,e){const t=`set${e[0].toUpperCase()}${e.slice(1)}`;return o[t]!==void 0}function Nr(o){var t,n;let e=o.value;return o.value&&((n=(t=o.value)==null?void 0:t.value)!=null&&n.isMesh)&&(e=o.value.value.position),Array.isArray(o.value)&&(e=new c.Vector3(...e)),e}const{logWarning:rd}=ae.useLogger(),sd={updated:(o,e)=>{const t=Nr(e);if(!t){rd(`v-always-look-at: problem with binding value: ${e.value}`);return}const{onLoop:n}=ae.useRenderLoop();n(()=>{o.lookAt(t)})}},{logWarning:id}=ae.useLogger(),od={updated:(o,e)=>{var r;const t=Nr(e);if(!t){id(`v-distance-to: problem with binding value: ${e.value}`);return}at&&(at.dispose(),o.parent.remove(at));const n=t.clone().sub(o.position);n.normalize(),at=new c.ArrowHelper(n,o.position,o.position.distanceTo(t)/1.5,16776960),o.parent.add(at),console.table([["Distance:",o.position.distanceTo(t)],[`origin: ${o.name||o.type}`,`x:${o.position.x}, y:${o.position.y}, z:${(r=o.position)==null?void 0:r.z}`],[`Destiny: ${o.name||o.type}`,`x:${t.x}, y:${t.y}, z:${t==null?void 0:t.z}`]])},unmounted:o=>{at==null||at.dispose(),o.parent.remove(at)}};let at=null;se.Backdrop=jh,se.BakeShadows=Uf,se.Box=Gu,se.CameraControls=xc,se.CatmullRomCurve3=Zu,se.Circle=Qu,se.Cone=$u,se.ContactShadows=Kh,se.CustomShaderMaterial=Ou,se.Dodecahedron=nh,se.Environment=zh,se.FBXModel=Jl,se.Fbo=Wl,se.GLTFModel=ql,se.GlobalAudio=Pl,se.Html=Zf,se.Icosahedron=ih,se.KeyboardControls=ac,se.Lensflare=El,se.Levioso=nl,se.Line2=Ii,se.MapControls=dc,se.MeshGlassMaterial=Ic,se.MeshReflectionMaterial=zu,se.MeshWobbleMaterial=Mc,se.MouseParallax=Al,se.Ocean=Tf,se.Octahedron=lh,se.OrbitControls=rc,se.Plane=fh,se.PointerLockControls=hc,se.Precipitation=Jh,se.Reflector=il,se.Ring=mh,se.RoundedBox=_h,se.SVG=$l,se.Sampler=Yl,se.ScrollControls=pc,se.Sky=$h,se.Smoke=sf,se.Sparkles=wf,se.Sphere=wh,se.Stars=Sf,se.Stats=Of,se.StatsGl=Ff,se.Superformula=Sh,se.Tetrahedron=Th,se.Text3D=el,se.Torus=Ih,se.TorusKnot=Bh,se.TransformControls=cc,se.Tube=Nh,se.extractBindingPosition=Nr,se.hasSetter=nd,se.pick=td,se.useAnimations=tl,se.useEnvironment=Gs,se.useFBO=Vs,se.useFBX=Es,se.useGLTF=js,se.useGLTFExporter=qf,se.useProgress=ec,se.useSurfaceSampler=Rs,se.useTweakPane=Lf,se.useVideoTexture=tc,se.vAlwaysLookAt=sd,se.vDistanceTo=od,se.vLightHelper=$f,se.vLog=Hf,Object.defineProperty(se,Symbol.toStringTag,{value:"Module"})});
|