@tresjs/cientos 3.9.0 → 4.0.0-next.1
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/composables/useOnDemandInvalidation.d.ts +3 -0
- package/dist/core/abstractions/AnimatedSprite/Atlas.d.ts +38 -0
- package/dist/core/abstractions/AnimatedSprite/AtlasAnimationDefinitionParser.d.ts +10 -0
- package/dist/core/abstractions/AnimatedSprite/StringOps.d.ts +2 -0
- package/dist/core/abstractions/AnimatedSprite/component.vue.d.ts +130 -0
- package/dist/core/abstractions/Lensflare/component.vue.d.ts +4 -4
- package/dist/core/abstractions/Levioso.vue.d.ts +15 -13
- package/dist/core/abstractions/MouseParallax.vue.d.ts +6 -6
- package/dist/core/abstractions/Reflector.vue.d.ts +9 -7
- package/dist/core/abstractions/Text3D.vue.d.ts +7 -5
- package/dist/core/abstractions/index.d.ts +2 -1
- package/dist/core/abstractions/useFBO/component.vue.d.ts +2 -2
- package/dist/core/abstractions/useFBO/index.d.ts +2 -2
- package/dist/core/abstractions/useSurfaceSampler/component.vue.d.ts +6 -4
- package/dist/core/abstractions/useSurfaceSampler/index.d.ts +161 -133
- package/dist/core/controls/CameraControls.vue.d.ts +1593 -1473
- package/dist/core/controls/KeyboardControls.vue.d.ts +39 -85
- package/dist/core/controls/MapControls.vue.d.ts +9495 -2
- package/dist/core/controls/OrbitControls.vue.d.ts +1366 -1262
- package/dist/core/controls/PointerLockControls.vue.d.ts +1 -1
- package/dist/core/controls/ScrollControls.vue.d.ts +19 -15
- package/dist/core/controls/TransformControls.vue.d.ts +6 -2
- package/dist/core/index.d.ts +0 -1
- package/dist/core/loaders/SVG/component.vue.d.ts +2 -2
- package/dist/core/loaders/useFBX/component.vue.d.ts +5 -5
- package/dist/core/loaders/useGLTF/component.vue.d.ts +9 -9
- package/dist/core/loaders/useGLTF/index.d.ts +41 -0
- package/dist/core/materials/customShaderMaterial/index.vue.d.ts +4 -2
- package/dist/core/materials/holographicMaterial/index.vue.d.ts +22 -22
- package/dist/core/materials/meshGlassMaterial/index.vue.d.ts +1 -1
- package/dist/core/materials/{blurPass.d.ts → meshReflectionMaterial/BlurPass.d.ts} +6 -5
- package/dist/core/materials/meshReflectionMaterial/index.vue.d.ts +170 -40
- package/dist/core/materials/meshReflectionMaterial/material.d.ts +31 -34
- package/dist/core/materials/meshWobbleMaterial/index.vue.d.ts +7 -5
- package/dist/core/misc/html/HTML.vue.d.ts +8 -4
- package/dist/core/misc/index.d.ts +1 -2
- package/dist/core/shapes/Box.vue.d.ts +9 -7
- package/dist/core/shapes/CatmullRomCurve3.vue.d.ts +3 -1
- package/dist/core/shapes/Circle.vue.d.ts +9 -7
- package/dist/core/shapes/Cone.vue.d.ts +9 -7
- package/dist/core/shapes/Cylinder.vue.d.ts +60 -0
- package/dist/core/shapes/Dodecahedron.vue.d.ts +9 -7
- package/dist/core/shapes/Icosahedron.vue.d.ts +9 -7
- package/dist/core/shapes/Line2.vue.d.ts +4 -2
- package/dist/core/shapes/Octahedron.vue.d.ts +9 -7
- package/dist/core/shapes/Plane.vue.d.ts +9 -7
- package/dist/core/shapes/Ring.vue.d.ts +9 -7
- package/dist/core/shapes/RoundedBox.vue.d.ts +9 -7
- package/dist/core/shapes/Sphere.vue.d.ts +9 -7
- package/dist/core/shapes/Superformula.vue.d.ts +8 -6
- package/dist/core/shapes/Tetrahedron.vue.d.ts +9 -7
- package/dist/core/shapes/Torus.vue.d.ts +9 -7
- package/dist/core/shapes/TorusKnot.vue.d.ts +9 -7
- package/dist/core/shapes/Tube.vue.d.ts +10 -8
- package/dist/core/shapes/index.d.ts +2 -1
- package/dist/core/staging/Backdrop.vue.d.ts +9 -5
- package/dist/core/staging/ContactShadows.vue.d.ts +173 -0
- package/dist/core/staging/Fit.vue.d.ts +9 -6
- package/dist/core/staging/Ocean.vue.d.ts +11 -9
- package/dist/core/staging/Precipitation.vue.d.ts +6 -4
- package/dist/core/staging/Sky.vue.d.ts +2 -2
- package/dist/core/staging/Smoke.vue.d.ts +3 -3
- package/dist/core/staging/Sparkles/ShaderDataBuilder.d.ts +3 -3
- package/dist/core/staging/Sparkles/component.vue.d.ts +10 -8
- package/dist/core/staging/Stars.vue.d.ts +4 -4
- package/dist/core/staging/useEnvironment/component.vue.d.ts +8 -6
- package/dist/core/staging/useEnvironment/lightformer/index.vue.d.ts +11 -11
- package/dist/trescientos.js +6517 -6177
- package/dist/trescientos.umd.cjs +455 -440
- package/package.json +20 -24
- package/dist/core/directives/index.d.ts +0 -6
- package/dist/core/directives/vAlwaysLookAt.d.ts +0 -5
- package/dist/core/directives/vDistanceTo.d.ts +0 -4
- package/dist/core/directives/vLightHelper.d.ts +0 -7
- package/dist/core/directives/vLog.d.ts +0 -3
- package/dist/core/misc/useTweakPane/index.d.ts +0 -11
- /package/dist/core/materials/{convolutionMaterial.d.ts → meshReflectionMaterial/ConvolutionMaterial.d.ts} +0 -0
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.1
|
|
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,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("three"),require("vue"),require("@tresjs/core")):typeof define=="function"&&define.amd?define(["exports","three","vue","@tresjs/core"],l):(se=typeof globalThis<"u"?globalThis:se||self,l(se.trescientos={},se.Three,se.Vue,se.TresjsCore))})(this,function(se,l,u,te){"use strict";var sp=Object.defineProperty;var ip=(se,l,u)=>l in se?sp(se,l,{enumerable:!0,configurable:!0,writable:!0,value:u}):se[l]=u;var ue=(se,l,u)=>ip(se,typeof l!="symbol"?l+"":l,u);function ao(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 Jr=ao(l);function Hr(o,e){if(e===l.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),o;if(e===l.TriangleFanDrawMode||e===l.TriangleStripDrawMode){let t=o.getIndex();if(t===null){const i=[],a=o.getAttribute("position");if(a!==void 0){for(let c=0;c<a.count;c++)i.push(c);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===l.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 xn=parseInt(l.REVISION.replace(/\D+/g,""));var lo=Object.defineProperty,co=(o,e,t)=>e in o?lo(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,uo=(o,e,t)=>(co(o,e+"",t),t);async function $r(o){const e=await o.arrayBuffer(),t=btoa(String.fromCharCode(...new Uint8Array(e)));return`data:${o.type||""};base64,${t}`}let wn,Kn,Nt,bn;function qn(o,e=1/0,t=null){Kn||(Kn=new l.PlaneGeometry(2,2,1,1)),Nt||(Nt=new l.ShaderMaterial({uniforms:{blitTexture:new l.Uniform(o)},vertexShader:`
|
|
9
9
|
varying vec2 vUv;
|
|
10
10
|
void main(){
|
|
11
11
|
vUv = uv;
|
|
@@ -24,7 +24,304 @@
|
|
|
24
24
|
gl_FragColor = texture2D( blitTexture, vUv);
|
|
25
25
|
#endif
|
|
26
26
|
}
|
|
27
|
-
`})),Ft.uniforms.blitTexture.value=o,Ft.defines.IS_SRGB="colorSpace"in o?o.colorSpace==="srgb":o.encoding===3001,Ft.needsUpdate=!0,xn||(xn=new l.Mesh(Xn,Ft),xn.frustrumCulled=!1);const n=new l.PerspectiveCamera,r=new l.Scene;r.add(xn),t||(t=_n=new l.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 l.Texture(t.domElement);return s.minFilter=o.minFilter,s.magFilter=o.magFilter,s.wrapS=o.wrapS,s.wrapT=o.wrapT,s.name=o.name,_n&&(_n.dispose(),_n=null),s}const $r={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 qn{constructor(){this.pluginCallbacks=[],this.register(function(e){return new po(e)}),this.register(function(e){return new mo(e)}),this.register(function(e){return new vo(e)}),this.register(function(e){return new _o(e)}),this.register(function(e){return new xo(e)}),this.register(function(e){return new wo(e)}),this.register(function(e){return new go(e)}),this.register(function(e){return new yo(e)}),this.register(function(e){return new bo(e)}),this.register(function(e){return new Mo(e)}),this.register(function(e){return new So(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 fo,i=[];for(let a=0,c=this.pluginCallbacks.length;a<c;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)})}}ro(qn,"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 c=0;c<n;c++)s[c]=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 c=0;c<o.times.length;c++){if(Math.abs(o.times[c]-e)<.001)return c;if(o.times[c]<e&&o.times[c+1]>e){r.set(o.times.slice(0,c+1),0),r[c+1]=e,r.set(o.times.slice(c+1),c+2),s.set(o.values.slice(0,(c+1)*n),0),s.set(i.evaluate(e),(c+1)*n),s.set(o.values.slice((c+1)*n),(c+2)*n),a=c+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=l.PropertyBinding.parseTrackName(i.name),c=l.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(l.InterpolateLinear)}const h=c.morphTargetInfluences.length,f=c.morphTargetDictionary[a.propertyIndex];if(f===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let d;if(n[c.uuid]===void 0){d=i.clone();const g=new d.ValueBufferType(h*d.times.length);for(let x=0;x<d.times.length;x++)g[x*h+f]=d.values[x];d.name=(a.nodeName||"")+".morphTargetInfluences",d.values=g,n[c.uuid]=d,t.push(d);continue}const p=i.createInterpolant(new i.ValueBufferType(1));d=n[c.uuid];for(let g=0;g<d.times.length;g++)d.values[g*h+f]=p.evaluate(d.times[g]);for(let g=0;g<i.times.length;g++){const x=this.insertKeyframe(d,i.times[g]);d.values[x*h+f]=i.values[g]}}return o.tracks=t,o}});const xe={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},Kn="KHR_mesh_quantization",Ee={};Ee[l.NearestFilter]=xe.NEAREST,Ee[l.NearestMipmapNearestFilter]=xe.NEAREST_MIPMAP_NEAREST,Ee[l.NearestMipmapLinearFilter]=xe.NEAREST_MIPMAP_LINEAR,Ee[l.LinearFilter]=xe.LINEAR,Ee[l.LinearMipmapNearestFilter]=xe.LINEAR_MIPMAP_NEAREST,Ee[l.LinearMipmapLinearFilter]=xe.LINEAR_MIPMAP_LINEAR,Ee[l.ClampToEdgeWrapping]=xe.CLAMP_TO_EDGE,Ee[l.RepeatWrapping]=xe.REPEAT,Ee[l.MirroredRepeatWrapping]=xe.MIRRORED_REPEAT;const es={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},so=new l.Color,ts=12,io=1179937895,oo=2,ns=8,ao=1313821514,lo=5130562;function Kt(o,e){return o.length===e.length&&o.every(function(t,n){return t===e[n]})}function co(o){return new TextEncoder().encode(o).buffer}function uo(o){return Kt(o.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function ho(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=l.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 rs(o){return Math.ceil(o/4)*4}function Qn(o,e=0){const t=rs(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 ss(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function is(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 fo{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,c=r.extensionsRequired,h=new Blob(s,{type:"application/octet-stream"}),f=Object.keys(a),d=Object.keys(c);f.length>0&&(i.extensionsUsed=f),d.length>0&&(i.extensionsRequired=d),i.buffers&&i.buffers.length>0&&(i.buffers[0].byteLength=h.size),n.binary===!0?h.arrayBuffer().then(p=>{const g=Qn(p),x=new DataView(new ArrayBuffer(ns));x.setUint32(0,g.byteLength,!0),x.setUint32(4,lo,!0);const v=Qn(co(JSON.stringify(i)),32),_=new DataView(new ArrayBuffer(ns));_.setUint32(0,v.byteLength,!0),_.setUint32(4,ao,!0);const m=new ArrayBuffer(ts),M=new DataView(m);M.setUint32(0,io,!0),M.setUint32(4,oo,!0);const b=ts+_.byteLength+v.byteLength+x.byteLength+g.byteLength;M.setUint32(8,b,!0),new Blob([m,_,v,x,g],{type:"application/octet-stream"}).arrayBuffer().then(t)}):i.buffers&&i.buffers.length>0?Hr(h).then(p=>{i.buffers[0].uri=p,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 l.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 l.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(g){return("colorSpace"in g?g.colorSpace==="srgb":g.encoding===3001)?function(v){return v<.04045?v*.0773993808:Math.pow(v*.9478672986+.0521327014,2.4)}:function(v){return v}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof l.CompressedTexture&&(e=Zn(e)),t instanceof l.CompressedTexture&&(t=Zn(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),c=ss();c.width=i,c.height=a;const h=c.getContext("2d");h.fillStyle="#00ffff",h.fillRect(0,0,i,a);const f=h.getImageData(0,0,i,a);if(r){h.drawImage(r,0,0,i,a);const g=n(e),x=h.getImageData(0,0,i,a).data;for(let v=2;v<x.length;v+=4)f.data[v]=g(x[v]/256)*256}if(s){h.drawImage(s,0,0,i,a);const g=n(t),x=h.getImageData(0,0,i,a).data;for(let v=1;v<x.length;v+=4)f.data[v]=g(x[v]/256)*256}h.putImageData(f,0,0);const p=(e||t).clone();return p.source=new l.Texture(c).source,"colorSpace"in p?p.colorSpace="":p.encoding=3e3,p.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),p}processBuffer(e){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 xe.BYTE:case xe.UNSIGNED_BYTE:a=1;break;case xe.SHORT:case xe.UNSIGNED_SHORT:a=2;break;default:a=4}const c=rs(r*e.itemSize*a),h=new DataView(new ArrayBuffer(c));let f=0;for(let g=n;g<n+r;g++)for(let x=0;x<e.itemSize;x++){let v;e.itemSize>4?v=e.array[g*e.itemSize+x]:(x===0?v=e.getX(g):x===1?v=e.getY(g):x===2?v=e.getZ(g):x===3&&(v=e.getW(g)),e.normalized===!0&&(v=l.MathUtils.normalize(v,e.array))),t===xe.FLOAT?h.setFloat32(f,v,!0):t===xe.INT?h.setInt32(f,v,!0):t===xe.UNSIGNED_INT?h.setUint32(f,v,!0):t===xe.SHORT?h.setInt16(f,v,!0):t===xe.UNSIGNED_SHORT?h.setUint16(f,v,!0):t===xe.BYTE?h.setInt8(f,v):t===xe.UNSIGNED_BYTE&&h.setUint8(f,v),f+=a}const d={buffer:this.processBuffer(h.buffer),byteOffset:this.byteOffset,byteLength:c};return s!==void 0&&(d.target=s),s===xe.ARRAY_BUFFER&&(d.byteStride=e.itemSize*a),this.byteOffset+=c,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=Qn(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=xe.FLOAT;else if(e.array.constructor===Int32Array)a=xe.INT;else if(e.array.constructor===Uint32Array)a=xe.UNSIGNED_INT;else if(e.array.constructor===Int16Array)a=xe.SHORT;else if(e.array.constructor===Uint16Array)a=xe.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)a=xe.BYTE;else if(e.array.constructor===Uint8Array)a=xe.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 c=ho(e,n,r);let h;t!==void 0&&(h=e===t.index?xe.ELEMENT_ARRAY_BUFFER:xe.ARRAY_BUFFER);const f=this.processBufferView(e,a,n,r,h),d={bufferView:f.id,byteOffset:f.byteOffset,componentType:a,count:r,max:c.max,min:c.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,c=s.options,h=s.pending;i.images.has(e)||i.images.set(e,{});const f=i.images.get(e),d=r+":flipY/"+n.toString();if(f[d]!==void 0)return f[d];a.images||(a.images=[]);const p={mimeType:r},g=ss();g.width=Math.min(e.width,c.maxTextureSize),g.height=Math.min(e.height,c.maxTextureSize);const x=g.getContext("2d");if(n===!0&&(x.translate(0,g.height),x.scale(1,-1)),e.data!==void 0){t!==l.RGBAFormat&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>c.maxTextureSize||e.height>c.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const _=new Uint8ClampedArray(e.height*e.width*4);for(let m=0;m<_.length;m+=4)_[m+0]=e.data[m+0],_[m+1]=e.data[m+1],_[m+2]=e.data[m+2],_[m+3]=e.data[m+3];x.putImageData(new ImageData(_,e.width,e.height),0,0)}else x.drawImage(e,0,0,g.width,g.height);c.binary===!0?h.push(is(g,r).then(_=>s.processBufferViewImage(_)).then(_=>{p.bufferView=_})):g.toDataURL!==void 0?p.uri=g.toDataURL(r):h.push(is(g,r).then(Hr).then(_=>{p.uri=_}));const v=a.images.push(p)-1;return f[d]=v,v}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 l.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(h){h.writeTexture&&h.writeTexture(e,a)});const c=s.textures.push(a)-1;return r.textures.set(e,c),c}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(Kt(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),c={index:this.processTexture(a),channel:a.channel};this.applyTextureTransform(c,a),r.pbrMetallicRoughness.metallicRoughnessTexture=c}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 h={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(h,e.emissiveMap),r.emissiveTexture=h}}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===l.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 b=0,S=e.material.length;b<S;b++)r.push(e.material[b].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=xe.LINES:e.isLineLoop?a=xe.LINE_LOOP:e.isLine?a=xe.LINE_STRIP:e.isPoints?a=xe.POINTS:a=e.material.wireframe?xe.LINES:xe.TRIANGLES;const c={},h={},f=[],d=[],p={...Jr>=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 b in i.attributes){if(b.slice(0,5)==="morph")continue;const S=i.attributes[b];if(b=p[b]||b.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(b)||(b="_"+b),t.attributes.has(this.getUID(S))){h[b]=t.attributes.get(this.getUID(S));continue}x=null;const P=S.array;b==="JOINTS_0"&&!(P instanceof Uint16Array)&&!(P instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),x=new l.BufferAttribute(new Uint16Array(P),S.itemSize,S.normalized));const T=this.processAccessor(x||S,i);T!==null&&(b.startsWith("_")||this.detectMeshQuantization(b,S),h[b]=T,t.attributes.set(this.getUID(S),T))}if(g!==void 0&&i.setAttribute("normal",g),Object.keys(h).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const b=[],S=[],L={};if(e.morphTargetDictionary!==void 0)for(const P in e.morphTargetDictionary)L[e.morphTargetDictionary[P]]=P;for(let P=0;P<e.morphTargetInfluences.length;++P){const T={};let y=!1;for(const A in i.morphAttributes){if(A!=="position"&&A!=="normal"){y||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),y=!0);continue}const w=i.morphAttributes[A][P],D=A.toUpperCase(),k=i.attributes[A];if(t.attributes.has(this.getUID(w,!0))){T[D]=t.attributes.get(this.getUID(w,!0));continue}const R=w.clone();if(!i.morphTargetsRelative)for(let V=0,Y=w.count;V<Y;V++)for(let G=0;G<w.itemSize;G++)G===0&&R.setX(V,w.getX(V)-k.getX(V)),G===1&&R.setY(V,w.getY(V)-k.getY(V)),G===2&&R.setZ(V,w.getZ(V)-k.getZ(V)),G===3&&R.setW(V,w.getW(V)-k.getW(V));T[D]=this.processAccessor(R,i),t.attributes.set(this.getUID(k,!0),T[D])}d.push(T),b.push(e.morphTargetInfluences[P]),e.morphTargetDictionary!==void 0&&S.push(L[P])}c.weights=b,S.length>0&&(c.extras={},c.extras.targetNames=S)}const v=Array.isArray(e.material);if(v&&i.groups.length===0)return null;const _=v?e.material:[e.material],m=v?i.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let b=0,S=m.length;b<S;b++){const L={mode:a,attributes:h};if(this.serializeUserData(i,L),d.length>0&&(L.targets=d),i.index!==null){let T=this.getUID(i.index);(m[b].start!==void 0||m[b].count!==void 0)&&(T+=":"+m[b].start+":"+m[b].count),t.attributes.has(T)?L.indices=t.attributes.get(T):(L.indices=this.processAccessor(i.index,i,m[b].start,m[b].count),t.attributes.set(T,L.indices)),L.indices===null&&delete L.indices}const P=this.processMaterial(_[m[b].materialIndex]);P!==null&&(L.material=P),f.push(L)}c.primitives=f,n.meshes||(n.meshes=[]),this._invokeAll(function(b){b.writeMesh&&b.writeMesh(e,c)});const M=n.meshes.push(c)-1;return t.meshes.set(s,M),M}detectMeshQuantization(e,t){if(this.extensionsUsed[Kn])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];$r[r]&&$r[r].includes(n)&&(this.extensionsUsed[Kn]=!0,this.extensionsRequired[Kn]=!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:l.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=qn.Utils.mergeMorphTargetTracks(e.clone(),t);const s=e.tracks,i=[],a=[];for(let c=0;c<s.length;++c){const h=s[c],f=l.PropertyBinding.parseTrackName(h.name);let d=l.PropertyBinding.findNode(t,f.nodeName);const p=es[f.propertyName];if(f.objectName==="bones"&&(d.isSkinnedMesh===!0?d=d.skeleton.getBoneByName(f.objectIndex):d=void 0),!d||!p)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',h.name),null;const g=1;let x=h.values.length/h.times.length;p===es.morphTargetInfluences&&(x/=d.morphTargetInfluences.length);let v;h.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(v="CUBICSPLINE",x/=3):h.getInterpolation()===l.InterpolateDiscrete?v="STEP":v="LINEAR",a.push({input:this.processAccessor(new l.BufferAttribute(h.times,g)),output:this.processAccessor(new l.BufferAttribute(h.values,x)),interpolation:v}),i.push({sampler:a.length-1,target:{node:r.get(d),path:p}})}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=[],c=new Float32Array(s.bones.length*16),h=new l.Matrix4;for(let d=0;d<s.bones.length;++d)a.push(n.get(s.bones[d])),h.copy(s.boneInverses[d]),h.multiply(e.bindMatrix).toArray(c,d*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new l.BufferAttribute(c,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(),c=e.position.toArray(),h=e.scale.toArray();Kt(a,[0,0,0,1])||(s.rotation=a),Kt(c,[0,0,0])||(s.translation=c),Kt(h,[1,1,1])||(s.scale=h)}else e.matrixAutoUpdate&&e.updateMatrix(),uo(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 c=0,h=e.children.length;c<h;c++){const f=e.children[c];if(f.visible||n.onlyVisible===!1){const d=this.processNode(f);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 c=e.children[i];if(c.visible||n.onlyVisible===!1){const h=this.processNode(c);h!==null&&s.push(h)}}s.length>0&&(r.nodes=s),this.serializeUserData(e,r)}processObjects(e){const t=new l.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 l.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 po{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 mo=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}},go=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}},yo=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}},vo=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}},_o=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}},xo=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}},wo=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(so)&&!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}},bo=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}},Mo=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}},So=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 qe=Uint8Array,mt=Uint16Array,Jn=Uint32Array,os=new qe([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]),as=new qe([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]),Ao=new qe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ls=function(o,e){for(var t=new mt(31),n=0;n<31;++n)t[n]=e+=1<<o[n-1];for(var r=new Jn(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]},cs=ls(os,2),us=cs[0],Co=cs[1];us[28]=258,Co[258]=28;for(var Po=ls(as,0),To=Po[0],Hn=new mt(32768),Pe=0;Pe<32768;++Pe){var gt=(Pe&43690)>>>1|(Pe&21845)<<1;gt=(gt&52428)>>>2|(gt&13107)<<2,gt=(gt&61680)>>>4|(gt&3855)<<4,Hn[Pe]=((gt&65280)>>>8|(gt&255)<<8)>>>1}for(var Qt=function(o,e,t){for(var n=o.length,r=0,s=new mt(e);r<n;++r)++s[o[r]-1];var i=new mt(e);for(r=0;r<e;++r)i[r]=i[r-1]+s[r-1]<<1;var a;if(t){a=new mt(1<<e);var c=15-e;for(r=0;r<n;++r)if(o[r])for(var h=r<<4|o[r],f=e-o[r],d=i[o[r]-1]++<<f,p=d|(1<<f)-1;d<=p;++d)a[Hn[d]>>>c]=h}else for(a=new mt(n),r=0;r<n;++r)o[r]&&(a[r]=Hn[i[o[r]-1]++]>>>15-o[r]);return a},Jt=new qe(288),Pe=0;Pe<144;++Pe)Jt[Pe]=8;for(var Pe=144;Pe<256;++Pe)Jt[Pe]=9;for(var Pe=256;Pe<280;++Pe)Jt[Pe]=7;for(var Pe=280;Pe<288;++Pe)Jt[Pe]=8;for(var hs=new qe(32),Pe=0;Pe<32;++Pe)hs[Pe]=5;var Io=Qt(Jt,9,1),Lo=Qt(hs,5,1),$n=function(o){for(var e=o[0],t=1;t<o.length;++t)o[t]>e&&(e=o[t]);return e},$e=function(o,e,t){var n=e/8|0;return(o[n]|o[n+1]<<8)>>(e&7)&t},er=function(o,e){var t=e/8|0;return(o[t]|o[t+1]<<8|o[t+2]<<16)>>(e&7)},Oo=function(o){return(o/8|0)+(o&7&&1)},Do=function(o,e,t){(t==null||t>o.length)&&(t=o.length);var n=new(o instanceof mt?mt:o instanceof Jn?Jn:qe)(t-e);return n.set(o.subarray(e,t)),n},ko=function(o,e,t){var n=o.length;if(!n||t&&!t.l&&n<5)return e||new qe(0);var r=!e||t,s=!t||t.i;t||(t={}),e||(e=new qe(n*3));var i=function(U){var F=e.length;if(U>F){var j=new qe(Math.max(F*2,U));j.set(e),e=j}},a=t.f||0,c=t.p||0,h=t.b||0,f=t.l,d=t.d,p=t.m,g=t.n,x=n*8;do{if(!f){t.f=a=$e(o,c,1);var v=$e(o,c+1,3);if(c+=3,v)if(v==1)f=Io,d=Lo,p=9,g=5;else if(v==2){var b=$e(o,c,31)+257,S=$e(o,c+10,15)+4,L=b+$e(o,c+5,31)+1;c+=14;for(var P=new qe(L),T=new qe(19),y=0;y<S;++y)T[Ao[y]]=$e(o,c+y*3,7);c+=S*3;for(var A=$n(T),w=(1<<A)-1,D=Qt(T,A,1),y=0;y<L;){var k=D[$e(o,c,w)];c+=k&15;var _=k>>>4;if(_<16)P[y++]=_;else{var R=0,V=0;for(_==16?(V=3+$e(o,c,3),c+=2,R=P[y-1]):_==17?(V=3+$e(o,c,7),c+=3):_==18&&(V=11+$e(o,c,127),c+=7);V--;)P[y++]=R}}var Y=P.subarray(0,b),G=P.subarray(b);p=$n(Y),g=$n(G),f=Qt(Y,p,1),d=Qt(G,g,1)}else throw"invalid block type";else{var _=Oo(c)+4,m=o[_-4]|o[_-3]<<8,M=_+m;if(M>n){if(s)throw"unexpected EOF";break}r&&i(h+m),e.set(o.subarray(_,M),h),t.b=h+=m,t.p=c=M*8;continue}if(c>x){if(s)throw"unexpected EOF";break}}r&&i(h+131072);for(var Q=(1<<p)-1,K=(1<<g)-1,ne=c;;ne=c){var R=f[er(o,c)&Q],ee=R>>>4;if(c+=R&15,c>x){if(s)throw"unexpected EOF";break}if(!R)throw"invalid length/literal";if(ee<256)e[h++]=ee;else if(ee==256){ne=c,f=null;break}else{var le=ee-254;if(ee>264){var y=ee-257,he=os[y];le=$e(o,c,(1<<he)-1)+us[y],c+=he}var de=d[er(o,c)&K],O=de>>>4;if(!de)throw"invalid distance";c+=de&15;var G=To[O];if(O>3){var he=as[O];G+=er(o,c)&(1<<he)-1,c+=he}if(c>x){if(s)throw"unexpected EOF";break}r&&i(h+131072);for(var z=h+le;h<z;h+=4)e[h]=e[h-G],e[h+1]=e[h+1-G],e[h+2]=e[h+2-G],e[h+3]=e[h+3-G];h=z}}t.l=f,t.p=ne,t.b=h,f&&(a=1,t.m=p,t.d=d,t.n=g)}while(!a);return h==e.length?e:Do(e,0,h)},Bo=new qe(0),Fo=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 Uo(o,e){return ko((Fo(o),o.subarray(2,-4)),e)}var No=typeof TextDecoder<"u"&&new TextDecoder,Vo=0;try{No.decode(Bo,{stream:!0}),Vo=1}catch{}const Fe=new l.Triangle,wn=new l.Vector3;class zo{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)),Fe.a.fromBufferAttribute(e,s),Fe.b.fromBufferAttribute(e,s+1),Fe.c.fromBufferAttribute(e,s+2),i*=Fe.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),Fe.a.fromBufferAttribute(this.positionAttribute,e*3),Fe.b.fromBufferAttribute(this.positionAttribute,e*3+1),Fe.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Fe.a,s).addScaledVector(Fe.b,i).addScaledVector(Fe.c,1-(s+i)),n!==void 0&&Fe.getNormal(n),r!==void 0&&this.colorAttribute!==void 0&&(Fe.a.fromBufferAttribute(this.colorAttribute,e*3),Fe.b.fromBufferAttribute(this.colorAttribute,e*3+1),Fe.c.fromBufferAttribute(this.colorAttribute,e*3+2),wn.set(0,0,0).addScaledVector(Fe.a,s).addScaledVector(Fe.b,i).addScaledVector(Fe.c,1-(s+i)),r.r=wn.x,r.g=wn.y,r.b=wn.z),this}}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,J=(o,e,t)=>(jo(o,typeof e!="symbol"?e+"":e,t),t);class Ro extends l.Object3D{constructor(e,t){super(),J(this,"isTransformControls",!0),J(this,"visible",!1),J(this,"domElement"),J(this,"raycaster",new l.Raycaster),J(this,"gizmo"),J(this,"plane"),J(this,"tempVector",new l.Vector3),J(this,"tempVector2",new l.Vector3),J(this,"tempQuaternion",new l.Quaternion),J(this,"unit",{X:new l.Vector3(1,0,0),Y:new l.Vector3(0,1,0),Z:new l.Vector3(0,0,1)}),J(this,"pointStart",new l.Vector3),J(this,"pointEnd",new l.Vector3),J(this,"offset",new l.Vector3),J(this,"rotationAxis",new l.Vector3),J(this,"startNorm",new l.Vector3),J(this,"endNorm",new l.Vector3),J(this,"rotationAngle",0),J(this,"cameraPosition",new l.Vector3),J(this,"cameraQuaternion",new l.Quaternion),J(this,"cameraScale",new l.Vector3),J(this,"parentPosition",new l.Vector3),J(this,"parentQuaternion",new l.Quaternion),J(this,"parentQuaternionInv",new l.Quaternion),J(this,"parentScale",new l.Vector3),J(this,"worldPositionStart",new l.Vector3),J(this,"worldQuaternionStart",new l.Quaternion),J(this,"worldScaleStart",new l.Vector3),J(this,"worldPosition",new l.Vector3),J(this,"worldQuaternion",new l.Quaternion),J(this,"worldQuaternionInv",new l.Quaternion),J(this,"worldScale",new l.Vector3),J(this,"eye",new l.Vector3),J(this,"positionStart",new l.Vector3),J(this,"quaternionStart",new l.Quaternion),J(this,"scaleStart",new l.Vector3),J(this,"camera"),J(this,"object"),J(this,"enabled",!0),J(this,"axis",null),J(this,"mode","translate"),J(this,"translationSnap",null),J(this,"rotationSnap",null),J(this,"scaleSnap",null),J(this,"space","world"),J(this,"size",1),J(this,"dragging",!1),J(this,"showX",!0),J(this,"showY",!0),J(this,"showZ",!0),J(this,"changeEvent",{type:"change"}),J(this,"mouseDownEvent",{type:"mouseDown",mode:this.mode}),J(this,"mouseUpEvent",{type:"mouseUp",mode:this.mode}),J(this,"objectChangeEvent",{type:"objectChange"}),J(this,"intersectObjectWithRay",(r,s,i)=>{const a=s.intersectObject(r,!0);for(let c=0;c<a.length;c++)if(a[c].object.visible||i)return a[c];return!1}),J(this,"attach",r=>(this.object=r,this.visible=!0,this)),J(this,"detach",()=>(this.object=void 0,this.visible=!1,this.axis=null,this)),J(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),J(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()}),J(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}),J(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)}}),J(this,"pointerMove",r=>{const s=this.axis,i=this.mode,a=this.object;let c=this.space;if(i==="scale"?c="local":(s==="E"||s==="XYZE"||s==="XYZ")&&(c="world"),a===void 0||s===null||this.dragging===!1||r.button!==-1)return;this.raycaster.setFromCamera(r,this.camera);const h=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(h){if(this.pointEnd.copy(h.point).sub(this.worldPositionStart),i==="translate")this.offset.copy(this.pointEnd).sub(this.pointStart),c==="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),c==="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&&(c==="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)),c==="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 f=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(f*=-1),this.tempVector2.set(f,f,f)}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 f=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))*f):(s==="X"||s==="Y"||s==="Z")&&(this.rotationAxis.copy(this.unit[s]),this.tempVector.copy(this.unit[s]),c==="local"&&this.tempVector.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.offset.dot(this.tempVector.cross(this.eye).normalize())*f),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),c==="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)}}),J(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)}),J(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}}}),J(this,"onPointerHover",r=>{if(this.enabled)switch(r.pointerType){case"mouse":case"pen":this.pointerHover(this.getPointer(r));break}}),J(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)))}),J(this,"onPointerMove",r=>{this.enabled&&this.pointerMove(this.getPointer(r))}),J(this,"onPointerUp",r=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="",this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.pointerUp(this.getPointer(r)))}),J(this,"getMode",()=>this.mode),J(this,"setMode",r=>{this.mode=r}),J(this,"setTranslationSnap",r=>{this.translationSnap=r}),J(this,"setRotationSnap",r=>{this.rotationSnap=r}),J(this,"setScaleSnap",r=>{this.scaleSnap=r}),J(this,"setSize",r=>{this.size=r}),J(this,"setSpace",r=>{this.space=r}),J(this,"update",()=>{console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}),J(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)}),J(this,"dispose",()=>{var r,s,i,a,c,h;(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),(h=(c=this.domElement)==null?void 0:c.ownerDocument)==null||h.removeEventListener("pointerup",this.onPointerUp),this.traverse(f=>{const d=f;d.geometry&&d.geometry.dispose(),d.material&&d.material.dispose()})}),this.domElement=t,this.camera=e,this.gizmo=new Wo,this.add(this.gizmo),this.plane=new Yo,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 Wo extends l.Object3D{constructor(){super(),J(this,"isTransformControlsGizmo",!0),J(this,"type","TransformControlsGizmo"),J(this,"tempVector",new l.Vector3(0,0,0)),J(this,"tempEuler",new l.Euler),J(this,"alignVector",new l.Vector3(0,1,0)),J(this,"zeroVector",new l.Vector3(0,0,0)),J(this,"lookAtMatrix",new l.Matrix4),J(this,"tempQuaternion",new l.Quaternion),J(this,"tempQuaternion2",new l.Quaternion),J(this,"identityQuaternion",new l.Quaternion),J(this,"unitX",new l.Vector3(1,0,0)),J(this,"unitY",new l.Vector3(0,1,0)),J(this,"unitZ",new l.Vector3(0,0,1)),J(this,"gizmo"),J(this,"picker"),J(this,"helper"),J(this,"rotationAxis",new l.Vector3),J(this,"cameraPosition",new l.Vector3),J(this,"worldPositionStart",new l.Vector3),J(this,"worldQuaternionStart",new l.Quaternion),J(this,"worldPosition",new l.Vector3),J(this,"worldQuaternion",new l.Quaternion),J(this,"eye",new l.Vector3),J(this,"camera",null),J(this,"enabled",!0),J(this,"axis",null),J(this,"mode","translate"),J(this,"space","world"),J(this,"size",1),J(this,"dragging",!1),J(this,"showX",!0),J(this,"showY",!0),J(this,"showZ",!0),J(this,"updateMatrixWorld",()=>{let ee=this.space;this.mode==="scale"&&(ee="local");const le=ee==="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 he=[];he=he.concat(this.picker[this.mode].children),he=he.concat(this.gizmo[this.mode].children),he=he.concat(this.helper[this.mode].children);for(let de=0;de<he.length;de++){const O=he[de];O.visible=!0,O.rotation.set(0,0,0),O.position.copy(this.worldPosition);let z;if(this.camera.isOrthographicCamera?z=(this.camera.top-this.camera.bottom)/this.camera.zoom:z=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),O.scale.set(1,1,1).multiplyScalar(z*this.size/7),O.tag==="helper"){O.visible=!1,O.name==="AXIS"?(O.position.copy(this.worldPositionStart),O.visible=!!this.axis,this.axis==="X"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,0)),O.quaternion.copy(le).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(le).dot(this.eye))>.9&&(O.visible=!1)),this.axis==="Y"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),O.quaternion.copy(le).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(le).dot(this.eye))>.9&&(O.visible=!1)),this.axis==="Z"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),O.quaternion.copy(le).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(le).dot(this.eye))>.9&&(O.visible=!1)),this.axis==="XYZE"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),O.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),O.quaternion.multiply(this.tempQuaternion),O.visible=this.dragging),this.axis==="E"&&(O.visible=!1)):O.name==="START"?(O.position.copy(this.worldPositionStart),O.visible=this.dragging):O.name==="END"?(O.position.copy(this.worldPosition),O.visible=this.dragging):O.name==="DELTA"?(O.position.copy(this.worldPositionStart),O.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()),O.scale.copy(this.tempVector),O.visible=this.dragging):(O.quaternion.copy(le),this.dragging?O.position.copy(this.worldPositionStart):O.position.copy(this.worldPosition),this.axis&&(O.visible=this.axis.search(O.name)!==-1));continue}O.quaternion.copy(le),this.mode==="translate"||this.mode==="scale"?((O.name==="X"||O.name==="XYZX")&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(le).dot(this.eye))>.99&&(O.scale.set(1e-10,1e-10,1e-10),O.visible=!1),(O.name==="Y"||O.name==="XYZY")&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(le).dot(this.eye))>.99&&(O.scale.set(1e-10,1e-10,1e-10),O.visible=!1),(O.name==="Z"||O.name==="XYZZ")&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(le).dot(this.eye))>.99&&(O.scale.set(1e-10,1e-10,1e-10),O.visible=!1),O.name==="XY"&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(le).dot(this.eye))<.2&&(O.scale.set(1e-10,1e-10,1e-10),O.visible=!1),O.name==="YZ"&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(le).dot(this.eye))<.2&&(O.scale.set(1e-10,1e-10,1e-10),O.visible=!1),O.name==="XZ"&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(le).dot(this.eye))<.2&&(O.scale.set(1e-10,1e-10,1e-10),O.visible=!1),O.name.search("X")!==-1&&(this.alignVector.copy(this.unitX).applyQuaternion(le).dot(this.eye)<0?O.tag==="fwd"?O.visible=!1:O.scale.x*=-1:O.tag==="bwd"&&(O.visible=!1)),O.name.search("Y")!==-1&&(this.alignVector.copy(this.unitY).applyQuaternion(le).dot(this.eye)<0?O.tag==="fwd"?O.visible=!1:O.scale.y*=-1:O.tag==="bwd"&&(O.visible=!1)),O.name.search("Z")!==-1&&(this.alignVector.copy(this.unitZ).applyQuaternion(le).dot(this.eye)<0?O.tag==="fwd"?O.visible=!1:O.scale.z*=-1:O.tag==="bwd"&&(O.visible=!1))):this.mode==="rotate"&&(this.tempQuaternion2.copy(le),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(le).invert()),O.name.search("E")!==-1&&O.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),O.name==="X"&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),O.quaternion.copy(this.tempQuaternion)),O.name==="Y"&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),O.quaternion.copy(this.tempQuaternion)),O.name==="Z"&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),O.quaternion.copy(this.tempQuaternion))),O.visible=O.visible&&(O.name.indexOf("X")===-1||this.showX),O.visible=O.visible&&(O.name.indexOf("Y")===-1||this.showY),O.visible=O.visible&&(O.name.indexOf("Z")===-1||this.showZ),O.visible=O.visible&&(O.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),O.material.tempOpacity=O.material.tempOpacity||O.material.opacity,O.material.tempColor=O.material.tempColor||O.material.color.clone(),O.material.color.copy(O.material.tempColor),O.material.opacity=O.material.tempOpacity,this.enabled?this.axis&&(O.name===this.axis?(O.material.opacity=1,O.material.color.lerp(new l.Color(1,1,1),.5)):this.axis.split("").some(function(U){return O.name===U})?(O.material.opacity=1,O.material.color.lerp(new l.Color(1,1,1),.5)):(O.material.opacity*=.25,O.material.color.lerp(new l.Color(1,1,1),.5))):(O.material.opacity*=.5,O.material.color.lerp(new l.Color(1,1,1),.5))}super.updateMatrixWorld()});const e=new l.MeshBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,side:l.DoubleSide,fog:!1,toneMapped:!1}),t=new l.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 c=e.clone();c.opacity=.25;const h=c.clone();h.color.set(16776960);const f=c.clone();f.color.set(65535);const d=c.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 v=t.clone();v.color.set(255);const _=t.clone();_.color.set(65535);const m=t.clone();m.color.set(16711935);const M=t.clone();M.color.set(16776960);const b=t.clone();b.color.set(7895160);const S=M.clone();S.opacity=.25;const L=new l.CylinderGeometry(0,.05,.2,12,1,!1),P=new l.BoxGeometry(.125,.125,.125),T=new l.BufferGeometry;T.setAttribute("position",new l.Float32BufferAttribute([0,0,0,1,0,0],3));const y=(ee,le)=>{const he=new l.BufferGeometry,de=[];for(let O=0;O<=64*le;++O)de.push(0,Math.cos(O/32*Math.PI)*ee,Math.sin(O/32*Math.PI)*ee);return he.setAttribute("position",new l.Float32BufferAttribute(de,3)),he},A=()=>{const ee=new l.BufferGeometry;return ee.setAttribute("position",new l.Float32BufferAttribute([0,0,0,1,1,1],3)),ee},w={X:[[new l.Mesh(L,s),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new l.Mesh(L,s),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new l.Line(T,g)]],Y:[[new l.Mesh(L,i),[0,1,0],null,null,"fwd"],[new l.Mesh(L,i),[0,1,0],[Math.PI,0,0],null,"bwd"],[new l.Line(T,x),null,[0,0,Math.PI/2]]],Z:[[new l.Mesh(L,a),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new l.Mesh(L,a),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new l.Line(T,v),null,[0,-Math.PI/2,0]]],XYZ:[[new l.Mesh(new l.OctahedronGeometry(.1,0),c.clone()),[0,0,0],[0,0,0]]],XY:[[new l.Mesh(new l.PlaneGeometry(.295,.295),h.clone()),[.15,.15,0]],[new l.Line(T,M),[.18,.3,0],null,[.125,1,1]],[new l.Line(T,M),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new l.Mesh(new l.PlaneGeometry(.295,.295),f.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new l.Line(T,_),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new l.Line(T,_),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new l.Mesh(new l.PlaneGeometry(.295,.295),d.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new l.Line(T,m),[.18,0,.3],null,[.125,1,1]],[new l.Line(T,m),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},D={X:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[0,.6,0]]],Z:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new l.Mesh(new l.OctahedronGeometry(.2,0),n)]],XY:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[.2,.2,0]]],YZ:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[.2,0,.2],[-Math.PI/2,0,0]]]},k={START:[[new l.Mesh(new l.OctahedronGeometry(.01,2),r),null,null,null,"helper"]],END:[[new l.Mesh(new l.OctahedronGeometry(.01,2),r),null,null,null,"helper"]],DELTA:[[new l.Line(A(),r),null,null,null,"helper"]],X:[[new l.Line(T,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new l.Line(T,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new l.Line(T,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},R={X:[[new l.Line(y(1,.5),g)],[new l.Mesh(new l.OctahedronGeometry(.04,0),s),[0,0,.99],null,[1,3,1]]],Y:[[new l.Line(y(1,.5),x),null,[0,0,-Math.PI/2]],[new l.Mesh(new l.OctahedronGeometry(.04,0),i),[0,0,.99],null,[3,1,1]]],Z:[[new l.Line(y(1,.5),v),null,[0,Math.PI/2,0]],[new l.Mesh(new l.OctahedronGeometry(.04,0),a),[.99,0,0],null,[1,3,1]]],E:[[new l.Line(y(1.25,1),S),null,[0,Math.PI/2,0]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),S),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),S),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),S),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),S),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new l.Line(y(1,1),b),null,[0,Math.PI/2,0]]]},V={AXIS:[[new l.Line(T,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},Y={X:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new l.Mesh(new l.TorusGeometry(1.25,.1,2,24),n)]],XYZE:[[new l.Mesh(new l.SphereGeometry(.7,10,8),n)]]},G={X:[[new l.Mesh(P,s),[.8,0,0],[0,0,-Math.PI/2]],[new l.Line(T,g),null,null,[.8,1,1]]],Y:[[new l.Mesh(P,i),[0,.8,0]],[new l.Line(T,x),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new l.Mesh(P,a),[0,0,.8],[Math.PI/2,0,0]],[new l.Line(T,v),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new l.Mesh(P,h),[.85,.85,0],null,[2,2,.2]],[new l.Line(T,M),[.855,.98,0],null,[.125,1,1]],[new l.Line(T,M),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new l.Mesh(P,f),[0,.85,.85],null,[.2,2,2]],[new l.Line(T,_),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new l.Line(T,_),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new l.Mesh(P,d),[.85,0,.85],null,[2,.2,2]],[new l.Line(T,m),[.855,0,.98],null,[.125,1,1]],[new l.Line(T,m),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),c.clone()),[1.1,0,0]]],XYZY:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),c.clone()),[0,1.1,0]]],XYZZ:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),c.clone()),[0,0,1.1]]]},Q={X:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,.5,0]]],Z:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new l.Mesh(P,n),[.85,.85,0],null,[3,3,.2]]],YZ:[[new l.Mesh(P,n),[0,.85,.85],null,[.2,3,3]]],XZ:[[new l.Mesh(P,n),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[1.1,0,0]]],XYZY:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[0,1.1,0]]],XYZZ:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[0,0,1.1]]]},K={X:[[new l.Line(T,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new l.Line(T,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new l.Line(T,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},ne=ee=>{const le=new l.Object3D;for(let he in ee)for(let de=ee[he].length;de--;){const O=ee[he][de][0].clone(),z=ee[he][de][1],U=ee[he][de][2],F=ee[he][de][3],j=ee[he][de][4];O.name=he,O.tag=j,z&&O.position.set(z[0],z[1],z[2]),U&&O.rotation.set(U[0],U[1],U[2]),F&&O.scale.set(F[0],F[1],F[2]),O.updateMatrix();const C=O.geometry.clone();C.applyMatrix4(O.matrix),O.geometry=C,O.renderOrder=1/0,O.position.set(0,0,0),O.rotation.set(0,0,0),O.scale.set(1,1,1),le.add(O)}return le};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=ne(w)),this.add(this.gizmo.rotate=ne(R)),this.add(this.gizmo.scale=ne(G)),this.add(this.picker.translate=ne(D)),this.add(this.picker.rotate=ne(Y)),this.add(this.picker.scale=ne(Q)),this.add(this.helper.translate=ne(k)),this.add(this.helper.rotate=ne(V)),this.add(this.helper.scale=ne(K)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}}class Yo extends l.Mesh{constructor(){super(new l.PlaneGeometry(1e5,1e5,2,2),new l.MeshBasicMaterial({visible:!1,wireframe:!0,side:l.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),J(this,"isTransformControlsPlane",!0),J(this,"type","TransformControlsPlane"),J(this,"unitX",new l.Vector3(1,0,0)),J(this,"unitY",new l.Vector3(0,1,0)),J(this,"unitZ",new l.Vector3(0,0,1)),J(this,"tempVector",new l.Vector3),J(this,"dirVector",new l.Vector3),J(this,"alignVector",new l.Vector3),J(this,"tempMatrix",new l.Matrix4),J(this,"identityQuaternion",new l.Quaternion),J(this,"cameraQuaternion",new l.Quaternion),J(this,"worldPosition",new l.Vector3),J(this,"worldQuaternion",new l.Quaternion),J(this,"eye",new l.Vector3),J(this,"axis",null),J(this,"mode","translate"),J(this,"space","world"),J(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 Eo=Object.defineProperty,Xo=(o,e,t)=>e in o?Eo(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,ke=(o,e,t)=>(Xo(o,typeof e!="symbol"?e+"":e,t),t);const Ut=new l.Euler(0,0,0,"YXZ"),Nt=new l.Vector3,Zo={type:"change"},qo={type:"lock"},Ko={type:"unlock"},fs=Math.PI/2;class tr extends l.EventDispatcher{constructor(e,t){super(),ke(this,"camera"),ke(this,"domElement"),ke(this,"isLocked"),ke(this,"minPolarAngle"),ke(this,"maxPolarAngle"),ke(this,"pointerSpeed"),ke(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;Ut.setFromQuaternion(this.camera.quaternion),Ut.y-=r*.002*this.pointerSpeed,Ut.x-=s*.002*this.pointerSpeed,Ut.x=Math.max(fs-this.maxPolarAngle,Math.min(fs-this.minPolarAngle,Ut.x)),this.camera.quaternion.setFromEuler(Ut),this.dispatchEvent(Zo)}),ke(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(qo),this.isLocked=!0):(this.dispatchEvent(Ko),this.isLocked=!1))}),ke(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),ke(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))}),ke(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))}),ke(this,"dispose",()=>{this.disconnect()}),ke(this,"getObject",()=>this.camera),ke(this,"direction",new l.Vector3(0,0,-1)),ke(this,"getDirection",n=>n.copy(this.direction).applyQuaternion(this.camera.quaternion)),ke(this,"moveForward",n=>{Nt.setFromMatrixColumn(this.camera.matrix,0),Nt.crossVectors(this.camera.up,Nt),this.camera.position.addScaledVector(Nt,n)}),ke(this,"moveRight",n=>{Nt.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(Nt,n)}),ke(this,"lock",()=>{this.domElement&&this.domElement.requestPointerLock()}),ke(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 Qo=Object.defineProperty,Jo=(o,e,t)=>e in o?Qo(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,pe=(o,e,t)=>(Jo(o,typeof e!="symbol"?e+"":e,t),t);const bn=new l.Ray,ds=new l.Plane,Ho=Math.cos(70*(Math.PI/180)),ps=(o,e)=>(o%e+e)%e;class ms extends l.EventDispatcher{constructor(e,t){super(),pe(this,"object"),pe(this,"domElement"),pe(this,"enabled",!0),pe(this,"target",new l.Vector3),pe(this,"minDistance",0),pe(this,"maxDistance",1/0),pe(this,"minZoom",0),pe(this,"maxZoom",1/0),pe(this,"minPolarAngle",0),pe(this,"maxPolarAngle",Math.PI),pe(this,"minAzimuthAngle",-1/0),pe(this,"maxAzimuthAngle",1/0),pe(this,"enableDamping",!1),pe(this,"dampingFactor",.05),pe(this,"enableZoom",!0),pe(this,"zoomSpeed",1),pe(this,"enableRotate",!0),pe(this,"rotateSpeed",1),pe(this,"enablePan",!0),pe(this,"panSpeed",1),pe(this,"screenSpacePanning",!0),pe(this,"keyPanSpeed",7),pe(this,"zoomToCursor",!1),pe(this,"autoRotate",!1),pe(this,"autoRotateSpeed",2),pe(this,"reverseOrbit",!1),pe(this,"reverseHorizontalOrbit",!1),pe(this,"reverseVerticalOrbit",!1),pe(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),pe(this,"mouseButtons",{LEFT:l.MOUSE.ROTATE,MIDDLE:l.MOUSE.DOLLY,RIGHT:l.MOUSE.PAN}),pe(this,"touches",{ONE:l.TOUCH.ROTATE,TWO:l.TOUCH.DOLLY_PAN}),pe(this,"target0"),pe(this,"position0"),pe(this,"zoom0"),pe(this,"_domElementKeyEvents",null),pe(this,"getPolarAngle"),pe(this,"getAzimuthalAngle"),pe(this,"setPolarAngle"),pe(this,"setAzimuthalAngle"),pe(this,"getDistance"),pe(this,"listenToKeyEvents"),pe(this,"stopListenToKeyEvents"),pe(this,"saveState"),pe(this,"reset"),pe(this,"update"),pe(this,"connect"),pe(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=()=>f.phi,this.getAzimuthalAngle=()=>f.theta,this.setPolarAngle=q=>{let oe=ps(q,2*Math.PI),ge=f.phi;ge<0&&(ge+=2*Math.PI),oe<0&&(oe+=2*Math.PI);let Me=Math.abs(oe-ge);2*Math.PI-Me<Me&&(oe<ge?oe+=2*Math.PI:ge+=2*Math.PI),d.phi=oe-ge,n.update()},this.setAzimuthalAngle=q=>{let oe=ps(q,2*Math.PI),ge=f.theta;ge<0&&(ge+=2*Math.PI),oe<0&&(oe+=2*Math.PI);let Me=Math.abs(oe-ge);2*Math.PI-Me<Me&&(oe<ge?oe+=2*Math.PI:ge+=2*Math.PI),d.theta=oe-ge,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=q=>{q.addEventListener("keydown",Pt),this._domElementKeyEvents=q},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",Pt),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(),c=a.NONE},this.update=(()=>{const q=new l.Vector3,oe=new l.Vector3(0,1,0),ge=new l.Quaternion().setFromUnitVectors(e.up,oe),Me=ge.clone().invert(),Be=new l.Vector3,ft=new l.Quaternion,Tt=2*Math.PI;return function(){const Hi=n.object.position;ge.setFromUnitVectors(e.up,oe),Me.copy(ge).invert(),q.copy(Hi).sub(n.target),q.applyQuaternion(ge),f.setFromVector3(q),n.autoRotate&&c===a.NONE&&V(k()),n.enableDamping?(f.theta+=d.theta*n.dampingFactor,f.phi+=d.phi*n.dampingFactor):(f.theta+=d.theta,f.phi+=d.phi);let dt=n.minAzimuthAngle,pt=n.maxAzimuthAngle;isFinite(dt)&&isFinite(pt)&&(dt<-Math.PI?dt+=Tt:dt>Math.PI&&(dt-=Tt),pt<-Math.PI?pt+=Tt:pt>Math.PI&&(pt-=Tt),dt<=pt?f.theta=Math.max(dt,Math.min(pt,f.theta)):f.theta=f.theta>(dt+pt)/2?Math.max(dt,f.theta):Math.min(pt,f.theta)),f.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,f.phi)),f.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(g,n.dampingFactor):n.target.add(g),n.zoomToCursor&&A||n.object.isOrthographicCamera?f.radius=he(f.radius):f.radius=he(f.radius*p),q.setFromSpherical(f),q.applyQuaternion(Me),Hi.copy(n.target).add(q),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 gn=!1;if(n.zoomToCursor&&A){let yn=null;if(n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera){const vn=q.length();yn=he(vn*p);const En=vn-yn;n.object.position.addScaledVector(T,En),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const vn=new l.Vector3(y.x,y.y,0);vn.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/p)),n.object.updateProjectionMatrix(),gn=!0;const En=new l.Vector3(y.x,y.y,0);En.unproject(n.object),n.object.position.sub(En).add(vn),n.object.updateMatrixWorld(),yn=q.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;yn!==null&&(n.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(yn).add(n.object.position):(bn.origin.copy(n.object.position),bn.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(bn.direction))<Ho?e.lookAt(n.target):(ds.setFromNormalAndCoplanarPoint(n.object.up,n.target),bn.intersectPlane(ds,n.target))))}else n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera&&(gn=p!==1,gn&&(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/p)),n.object.updateProjectionMatrix()));return p=1,A=!1,gn||Be.distanceToSquared(n.object.position)>h||8*(1-ft.dot(n.object.quaternion))>h?(n.dispatchEvent(r),Be.copy(n.object.position),ft.copy(n.object.quaternion),gn=!1,!0):!1}})(),this.connect=q=>{q===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),n.domElement=q,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",mn),n.domElement.addEventListener("pointerdown",ue),n.domElement.addEventListener("pointercancel",Te),n.domElement.addEventListener("wheel",Ze,{passive:!0})},this.dispose=()=>{var q,oe,ge,Me,Be,ft;n.domElement&&(n.domElement.style.touchAction="auto"),(q=n.domElement)==null||q.removeEventListener("contextmenu",mn),(oe=n.domElement)==null||oe.removeEventListener("pointerdown",ue),(ge=n.domElement)==null||ge.removeEventListener("pointercancel",Te),(Me=n.domElement)==null||Me.removeEventListener("wheel",Ze),(Be=n.domElement)==null||Be.ownerDocument.removeEventListener("pointermove",ve),(ft=n.domElement)==null||ft.ownerDocument.removeEventListener("pointerup",Oe),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",Pt)};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 c=a.NONE;const h=1e-6,f=new l.Spherical,d=new l.Spherical;let p=1;const g=new l.Vector3,x=new l.Vector2,v=new l.Vector2,_=new l.Vector2,m=new l.Vector2,M=new l.Vector2,b=new l.Vector2,S=new l.Vector2,L=new l.Vector2,P=new l.Vector2,T=new l.Vector3,y=new l.Vector2;let A=!1;const w=[],D={};function k(){return 2*Math.PI/60/60*n.autoRotateSpeed}function R(){return Math.pow(.95,n.zoomSpeed)}function V(q){n.reverseOrbit||n.reverseHorizontalOrbit?d.theta+=q:d.theta-=q}function Y(q){n.reverseOrbit||n.reverseVerticalOrbit?d.phi+=q:d.phi-=q}const G=(()=>{const q=new l.Vector3;return function(ge,Me){q.setFromMatrixColumn(Me,0),q.multiplyScalar(-ge),g.add(q)}})(),Q=(()=>{const q=new l.Vector3;return function(ge,Me){n.screenSpacePanning===!0?q.setFromMatrixColumn(Me,1):(q.setFromMatrixColumn(Me,0),q.crossVectors(n.object.up,q)),q.multiplyScalar(ge),g.add(q)}})(),K=(()=>{const q=new l.Vector3;return function(ge,Me){const Be=n.domElement;if(Be&&n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera){const ft=n.object.position;q.copy(ft).sub(n.target);let Tt=q.length();Tt*=Math.tan(n.object.fov/2*Math.PI/180),G(2*ge*Tt/Be.clientHeight,n.object.matrix),Q(2*Me*Tt/Be.clientHeight,n.object.matrix)}else Be&&n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?(G(ge*(n.object.right-n.object.left)/n.object.zoom/Be.clientWidth,n.object.matrix),Q(Me*(n.object.top-n.object.bottom)/n.object.zoom/Be.clientHeight,n.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),n.enablePan=!1)}})();function ne(q){n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera||n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?p/=q:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ee(q){n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera||n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?p*=q:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function le(q){if(!n.zoomToCursor||!n.domElement)return;A=!0;const oe=n.domElement.getBoundingClientRect(),ge=q.clientX-oe.left,Me=q.clientY-oe.top,Be=oe.width,ft=oe.height;y.x=ge/Be*2-1,y.y=-(Me/ft)*2+1,T.set(y.x,y.y,1).unproject(n.object).sub(n.object.position).normalize()}function he(q){return Math.max(n.minDistance,Math.min(n.maxDistance,q))}function de(q){x.set(q.clientX,q.clientY)}function O(q){le(q),S.set(q.clientX,q.clientY)}function z(q){m.set(q.clientX,q.clientY)}function U(q){v.set(q.clientX,q.clientY),_.subVectors(v,x).multiplyScalar(n.rotateSpeed);const oe=n.domElement;oe&&(V(2*Math.PI*_.x/oe.clientHeight),Y(2*Math.PI*_.y/oe.clientHeight)),x.copy(v),n.update()}function F(q){L.set(q.clientX,q.clientY),P.subVectors(L,S),P.y>0?ne(R()):P.y<0&&ee(R()),S.copy(L),n.update()}function j(q){M.set(q.clientX,q.clientY),b.subVectors(M,m).multiplyScalar(n.panSpeed),K(b.x,b.y),m.copy(M),n.update()}function C(q){le(q),q.deltaY<0?ee(R()):q.deltaY>0&&ne(R()),n.update()}function I(q){let oe=!1;switch(q.code){case n.keys.UP:K(0,n.keyPanSpeed),oe=!0;break;case n.keys.BOTTOM:K(0,-n.keyPanSpeed),oe=!0;break;case n.keys.LEFT:K(n.keyPanSpeed,0),oe=!0;break;case n.keys.RIGHT:K(-n.keyPanSpeed,0),oe=!0;break}oe&&(q.preventDefault(),n.update())}function B(){if(w.length==1)x.set(w[0].pageX,w[0].pageY);else{const q=.5*(w[0].pageX+w[1].pageX),oe=.5*(w[0].pageY+w[1].pageY);x.set(q,oe)}}function Z(){if(w.length==1)m.set(w[0].pageX,w[0].pageY);else{const q=.5*(w[0].pageX+w[1].pageX),oe=.5*(w[0].pageY+w[1].pageY);m.set(q,oe)}}function X(){const q=w[0].pageX-w[1].pageX,oe=w[0].pageY-w[1].pageY,ge=Math.sqrt(q*q+oe*oe);S.set(0,ge)}function W(){n.enableZoom&&X(),n.enablePan&&Z()}function $(){n.enableZoom&&X(),n.enableRotate&&B()}function re(q){if(w.length==1)v.set(q.pageX,q.pageY);else{const ge=qr(q),Me=.5*(q.pageX+ge.x),Be=.5*(q.pageY+ge.y);v.set(Me,Be)}_.subVectors(v,x).multiplyScalar(n.rotateSpeed);const oe=n.domElement;oe&&(V(2*Math.PI*_.x/oe.clientHeight),Y(2*Math.PI*_.y/oe.clientHeight)),x.copy(v)}function se(q){if(w.length==1)M.set(q.pageX,q.pageY);else{const oe=qr(q),ge=.5*(q.pageX+oe.x),Me=.5*(q.pageY+oe.y);M.set(ge,Me)}b.subVectors(M,m).multiplyScalar(n.panSpeed),K(b.x,b.y),m.copy(M)}function E(q){const oe=qr(q),ge=q.pageX-oe.x,Me=q.pageY-oe.y,Be=Math.sqrt(ge*ge+Me*Me);L.set(0,Be),P.set(0,Math.pow(L.y/S.y,n.zoomSpeed)),ne(P.y),S.copy(L)}function N(q){n.enableZoom&&E(q),n.enablePan&&se(q)}function ae(q){n.enableZoom&&E(q),n.enableRotate&&re(q)}function ue(q){var oe,ge;n.enabled!==!1&&(w.length===0&&((oe=n.domElement)==null||oe.ownerDocument.addEventListener("pointermove",ve),(ge=n.domElement)==null||ge.ownerDocument.addEventListener("pointerup",Oe)),Rn(q),q.pointerType==="touch"?pn(q):He(q))}function ve(q){n.enabled!==!1&&(q.pointerType==="touch"?Zt(q):Ct(q))}function Oe(q){var oe,ge,Me;Wn(q),w.length===0&&((oe=n.domElement)==null||oe.releasePointerCapture(q.pointerId),(ge=n.domElement)==null||ge.ownerDocument.removeEventListener("pointermove",ve),(Me=n.domElement)==null||Me.ownerDocument.removeEventListener("pointerup",Oe)),n.dispatchEvent(i),c=a.NONE}function Te(q){Wn(q)}function He(q){let oe;switch(q.button){case 0:oe=n.mouseButtons.LEFT;break;case 1:oe=n.mouseButtons.MIDDLE;break;case 2:oe=n.mouseButtons.RIGHT;break;default:oe=-1}switch(oe){case l.MOUSE.DOLLY:if(n.enableZoom===!1)return;O(q),c=a.DOLLY;break;case l.MOUSE.ROTATE:if(q.ctrlKey||q.metaKey||q.shiftKey){if(n.enablePan===!1)return;z(q),c=a.PAN}else{if(n.enableRotate===!1)return;de(q),c=a.ROTATE}break;case l.MOUSE.PAN:if(q.ctrlKey||q.metaKey||q.shiftKey){if(n.enableRotate===!1)return;de(q),c=a.ROTATE}else{if(n.enablePan===!1)return;z(q),c=a.PAN}break;default:c=a.NONE}c!==a.NONE&&n.dispatchEvent(s)}function Ct(q){if(n.enabled!==!1)switch(c){case a.ROTATE:if(n.enableRotate===!1)return;U(q);break;case a.DOLLY:if(n.enableZoom===!1)return;F(q);break;case a.PAN:if(n.enablePan===!1)return;j(q);break}}function Ze(q){n.enabled===!1||n.enableZoom===!1||c!==a.NONE&&c!==a.ROTATE||(n.dispatchEvent(s),C(q),n.dispatchEvent(i))}function Pt(q){n.enabled===!1||n.enablePan===!1||I(q)}function pn(q){switch(Yn(q),w.length){case 1:switch(n.touches.ONE){case l.TOUCH.ROTATE:if(n.enableRotate===!1)return;B(),c=a.TOUCH_ROTATE;break;case l.TOUCH.PAN:if(n.enablePan===!1)return;Z(),c=a.TOUCH_PAN;break;default:c=a.NONE}break;case 2:switch(n.touches.TWO){case l.TOUCH.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;W(),c=a.TOUCH_DOLLY_PAN;break;case l.TOUCH.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;$(),c=a.TOUCH_DOLLY_ROTATE;break;default:c=a.NONE}break;default:c=a.NONE}c!==a.NONE&&n.dispatchEvent(s)}function Zt(q){switch(Yn(q),c){case a.TOUCH_ROTATE:if(n.enableRotate===!1)return;re(q),n.update();break;case a.TOUCH_PAN:if(n.enablePan===!1)return;se(q),n.update();break;case a.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;N(q),n.update();break;case a.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;ae(q),n.update();break;default:c=a.NONE}}function mn(q){n.enabled!==!1&&q.preventDefault()}function Rn(q){w.push(q)}function Wn(q){delete D[q.pointerId];for(let oe=0;oe<w.length;oe++)if(w[oe].pointerId==q.pointerId){w.splice(oe,1);return}}function Yn(q){let oe=D[q.pointerId];oe===void 0&&(oe=new l.Vector2,D[q.pointerId]=oe),oe.set(q.pageX,q.pageY)}function qr(q){const oe=q.pointerId===w[0].pointerId?w[1]:w[0];return D[oe.pointerId]}t!==void 0&&this.connect(t),this.update()}}class $o extends ms{constructor(e,t){super(e,t),this.screenSpacePanning=!1,this.mouseButtons.LEFT=l.MOUSE.PAN,this.mouseButtons.RIGHT=l.MOUSE.ROTATE,this.touches.ONE=l.TOUCH.PAN,this.touches.TWO=l.TOUCH.DOLLY_ROTATE}}class ea extends l.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new ia(t)}),this.register(function(t){return new da(t)}),this.register(function(t){return new pa(t)}),this.register(function(t){return new ma(t)}),this.register(function(t){return new aa(t)}),this.register(function(t){return new la(t)}),this.register(function(t){return new ca(t)}),this.register(function(t){return new ua(t)}),this.register(function(t){return new sa(t)}),this.register(function(t){return new ha(t)}),this.register(function(t){return new oa(t)}),this.register(function(t){return new fa(t)}),this.register(function(t){return new na(t)}),this.register(function(t){return new ga(t)}),this.register(function(t){return new ya(t)})}load(e,t,n,r){const s=this;let i;this.resourcePath!==""?i=this.resourcePath:this.path!==""?i=this.path:i=l.LoaderUtils.extractUrlBase(e),this.manager.itemStart(e);const a=function(h){r?r(h):console.error(h),s.manager.itemError(e),s.manager.itemEnd(e)},c=new l.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(h){try{s.parse(h,i,function(f){t(f),s.manager.itemEnd(e)},a)}catch(f){a(f)}},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(l.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4)))===gs){try{i[we.KHR_BINARY_GLTF]=new va(e)}catch(f){r&&r(f);return}s=JSON.parse(i[we.KHR_BINARY_GLTF].content)}else s=JSON.parse(l.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 c=new Oa(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const f=this.pluginCallbacks[h](c);a[f.name]=f,i[f.name]=!0}if(s.extensionsUsed)for(let h=0;h<s.extensionsUsed.length;++h){const f=s.extensionsUsed[h],d=s.extensionsRequired||[];switch(f){case we.KHR_MATERIALS_UNLIT:i[f]=new ra;break;case we.KHR_DRACO_MESH_COMPRESSION:i[f]=new _a(s,this.dracoLoader);break;case we.KHR_TEXTURE_TRANSFORM:i[f]=new xa;break;case we.KHR_MESH_QUANTIZATION:i[f]=new wa;break;default:d.indexOf(f)>=0&&a[f]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+f+'".')}}c.setExtensions(i),c.setPlugins(a),c.parse(n,r)}parseAsync(e,t){const n=this;return new Promise(function(r,s){n.parse(e,t,r,s)})}}function ta(){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 we={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 na{constructor(e){this.parser=e,this.name=we.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,c=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let h;const f=new l.Color(16777215);c.color!==void 0&&f.fromArray(c.color);const d=c.range!==void 0?c.range:0;switch(c.type){case"directional":h=new l.DirectionalLight(f),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new l.PointLight(f),h.distance=d;break;case"spot":h=new l.SpotLight(f),h.distance=d,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,h.angle=c.spot.outerConeAngle,h.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return h.position.set(0,0,0),h.decay=2,vt(h,c),c.intensity!==void 0&&(h.intensity=c.intensity),h.name=t.createUniqueName(c.name||"light_"+e),r=Promise.resolve(h),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(c){return n._getNodeRef(t.cache,a,c)})}}class ra{constructor(){this.name=we.KHR_MATERIALS_UNLIT}getMaterialType(){return l.MeshBasicMaterial}extendParams(e,t,n){const r=[];e.color=new l.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 sa{constructor(e){this.parser=e,this.name=we.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 ia{constructor(e){this.parser=e,this.name=we.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.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 l.Vector2(a,a)}return Promise.all(s)}}class oa{constructor(e){this.parser=e,this.name=we.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.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 aa{constructor(e){this.parser=e,this.name=we.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.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 l.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 la{constructor(e){this.parser=e,this.name=we.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.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 ca{constructor(e){this.parser=e,this.name=we.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.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 l.Color(a[0],a[1],a[2]),Promise.all(s)}}class ua{constructor(e){this.parser=e,this.name=we.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.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 ha{constructor(e){this.parser=e,this.name=we.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.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 l.Color(a[0],a[1],a[2]),i.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",i.specularColorTexture,3001)),Promise.all(s)}}class fa{constructor(e){this.parser=e,this.name=we.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.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 da{constructor(e){this.parser=e,this.name=we.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 pa{constructor(e){this.parser=e,this.name=we.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 c=n.textureLoader;if(a.uri){const h=n.options.manager.getHandler(a.uri);h!==null&&(c=h)}return this.detectSupport().then(function(h){if(h)return n.loadTextureImage(e,i.source,c);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 ma{constructor(e){this.parser=e,this.name=we.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 c=n.textureLoader;if(a.uri){const h=n.options.manager.getHandler(a.uri);h!==null&&(c=h)}return this.detectSupport().then(function(h){if(h)return n.loadTextureImage(e,i.source,c);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 ga{constructor(e){this.name=we.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 c=r.byteOffset||0,h=r.byteLength||0,f=r.count,d=r.byteStride,p=new Uint8Array(a,c,h);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(f,d,p,r.mode,r.filter).then(function(g){return g.buffer}):i.ready.then(function(){const g=new ArrayBuffer(f*d);return i.decodeGltfBuffer(new Uint8Array(g),f,d,p,r.mode,r.filter),g})})}else return null}}class ya{constructor(e){this.name=we.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 h of r.primitives)if(h.mode!==Ke.TRIANGLES&&h.mode!==Ke.TRIANGLE_STRIP&&h.mode!==Ke.TRIANGLE_FAN&&h.mode!==void 0)return null;const i=n.extensions[this.name].attributes,a=[],c={};for(const h in i)a.push(this.parser.getDependency("accessor",i[h]).then(f=>(c[h]=f,c[h])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(h=>{const f=h.pop(),d=f.isGroup?f.children:[f],p=h[0].count,g=[];for(const x of d){const v=new l.Matrix4,_=new l.Vector3,m=new l.Quaternion,M=new l.Vector3(1,1,1),b=new l.InstancedMesh(x.geometry,x.material,p);for(let S=0;S<p;S++)c.TRANSLATION&&_.fromBufferAttribute(c.TRANSLATION,S),c.ROTATION&&m.fromBufferAttribute(c.ROTATION,S),c.SCALE&&M.fromBufferAttribute(c.SCALE,S),b.setMatrixAt(S,v.compose(_,m,M));for(const S in c)S!=="TRANSLATION"&&S!=="ROTATION"&&S!=="SCALE"&&x.geometry.setAttribute(S,c[S]);l.Object3D.prototype.copy.call(b,x),this.parser.assignFinalMaterial(b),g.push(b)}return f.isGroup?(f.clear(),f.add(...g),f):g[0]}))}}const gs="glTF",Ht=12,ys={JSON:1313821514,BIN:5130562};class va{constructor(e){this.name=we.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Ht);if(this.header={magic:l.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==gs)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-Ht,r=new DataView(e,Ht);let s=0;for(;s<n;){const i=r.getUint32(s,!0);s+=4;const a=r.getUint32(s,!0);if(s+=4,a===ys.JSON){const c=new Uint8Array(e,Ht+s,i);this.content=l.LoaderUtils.decodeText(c)}else if(a===ys.BIN){const c=Ht+s;this.body=e.slice(c,c+i)}s+=i}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class _a{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=we.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={},c={},h={};for(const f in i){const d=rr[f]||f.toLowerCase();a[d]=i[f]}for(const f in e.attributes){const d=rr[f]||f.toLowerCase();if(i[f]!==void 0){const p=n.accessors[e.attributes[f]],g=Vt[p.componentType];h[d]=g.name,c[d]=p.normalized===!0}}return t.getDependency("bufferView",s).then(function(f){return new Promise(function(d){r.decodeDracoFile(f,function(p){for(const g in p.attributes){const x=p.attributes[g],v=c[g];v!==void 0&&(x.normalized=v)}d(p)},a,h)})})}}class xa{constructor(){this.name=we.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 wa{constructor(){this.name=we.KHR_MESH_QUANTIZATION}}class vs extends l.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,c=a*2,h=a*3,f=r-t,d=(n-t)/f,p=d*d,g=p*d,x=e*h,v=x-h,_=-2*g+3*p,m=g-p,M=1-_,b=m-p+d;for(let S=0;S!==a;S++){const L=i[v+S+a],P=i[v+S+c]*f,T=i[x+S+a],y=i[x+S]*f;s[S]=M*L+b*P+_*T+m*y}return s}}const ba=new l.Quaternion;class Ma extends vs{interpolate_(e,t,n,r){const s=super.interpolate_(e,t,n,r);return ba.fromArray(s).normalize().toArray(s),s}}const Ke={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},Vt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},_s={9728:l.NearestFilter,9729:l.LinearFilter,9984:l.NearestMipmapNearestFilter,9985:l.LinearMipmapNearestFilter,9986:l.NearestMipmapLinearFilter,9987:l.LinearMipmapLinearFilter},xs={33071:l.ClampToEdgeWrapping,33648:l.MirroredRepeatWrapping,10497:l.RepeatWrapping},nr={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},rr={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...Jr>=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"},yt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Sa={CUBICSPLINE:void 0,LINEAR:l.InterpolateLinear,STEP:l.InterpolateDiscrete},sr={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Aa(o){return o.DefaultMaterial===void 0&&(o.DefaultMaterial=new l.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:l.FrontSide})),o.DefaultMaterial}function It(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 vt(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 Ca(o,e,t){let n=!1,r=!1,s=!1;for(let h=0,f=e.length;h<f;h++){const d=e[h];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=[],c=[];for(let h=0,f=e.length;h<f;h++){const d=e[h];if(n){const p=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):o.attributes.position;i.push(p)}if(r){const p=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):o.attributes.normal;a.push(p)}if(s){const p=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):o.attributes.color;c.push(p)}}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(c)]).then(function(h){const f=h[0],d=h[1],p=h[2];return n&&(o.morphAttributes.position=f),r&&(o.morphAttributes.normal=d),s&&(o.morphAttributes.color=p),o.morphTargetsRelative=!0,o})}function Pa(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 Ta(o){let e;const t=o.extensions&&o.extensions[we.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+ir(t.attributes):e=o.indices+":"+ir(o.attributes)+":"+o.mode,o.targets!==void 0)for(let n=0,r=o.targets.length;n<r;n++)e+=":"+ir(o.targets[n]);return e}function ir(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 or(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 Ia(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 La=new l.Matrix4;class Oa{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new ta,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 l.TextureLoader(this.options.manager):this.textureLoader=new l.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new l.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:{}};It(s,a,r),vt(a,r),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.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,c=i.length;a<c;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 c=this.associations.get(i);c!=null&&this.associations.set(a,c);for(const[h,f]of i.children.entries())s(f,a.children[h])};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[we.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(s,i){n.load(l.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=nr[r.type],a=Vt[r.componentType],c=r.normalized===!0,h=new a(r.count*i);return Promise.resolve(new l.BufferAttribute(h,i,c))}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],c=nr[r.type],h=Vt[r.componentType],f=h.BYTES_PER_ELEMENT,d=f*c,p=r.byteOffset||0,g=r.bufferView!==void 0?n.bufferViews[r.bufferView].byteStride:void 0,x=r.normalized===!0;let v,_;if(g&&g!==d){const m=Math.floor(p/g),M="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+m+":"+r.count;let b=t.cache.get(M);b||(v=new h(a,m*g,r.count*g/f),b=new l.InterleavedBuffer(v,g/f),t.cache.add(M,b)),_=new l.InterleavedBufferAttribute(b,c,p%g/f,x)}else a===null?v=new h(r.count*c):v=new h(a,p,r.count*c),_=new l.BufferAttribute(v,c,x);if(r.sparse!==void 0){const m=nr.SCALAR,M=Vt[r.sparse.indices.componentType],b=r.sparse.indices.byteOffset||0,S=r.sparse.values.byteOffset||0,L=new M(i[1],b,r.sparse.count*m),P=new h(i[2],S,r.sparse.count*c);a!==null&&(_=new l.BufferAttribute(_.array.slice(),_.itemSize,_.normalized));for(let T=0,y=L.length;T<y;T++){const A=L[T];if(_.setX(A,P[T*c]),c>=2&&_.setY(A,P[T*c+1]),c>=3&&_.setZ(A,P[T*c+2]),c>=4&&_.setW(A,P[T*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return _})}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 c=n.manager.getHandler(i.uri);c!==null&&(a=c)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){const r=this,s=this.json,i=s.textures[e],a=s.images[t],c=(a.uri||a.bufferView)+":"+i.sampler;if(this.textureCache[c])return this.textureCache[c];const h=this.loadImageSource(t,n).then(function(f){f.flipY=!1,f.name=i.name||a.name||"",f.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(f.name=a.uri);const p=(s.samplers||{})[i.sampler]||{};return f.magFilter=_s[p.magFilter]||l.LinearFilter,f.minFilter=_s[p.minFilter]||l.LinearMipmapLinearFilter,f.wrapS=xs[p.wrapS]||l.RepeatWrapping,f.wrapT=xs[p.wrapT]||l.RepeatWrapping,r.associations.set(f,{textures:e}),f}).catch(function(){return null});return this.textureCache[c]=h,h}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 c=i.uri||"",h=!1;if(i.bufferView!==void 0)c=n.getDependency("bufferView",i.bufferView).then(function(d){h=!0;const p=new Blob([d],{type:i.mimeType});return c=a.createObjectURL(p),c});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const f=Promise.resolve(c).then(function(d){return new Promise(function(p,g){let x=p;t.isImageBitmapLoader===!0&&(x=function(v){const _=new l.Texture(v);_.needsUpdate=!0,p(_)}),t.load(l.LoaderUtils.resolveURL(d,s.path),x,void 0,g)})}).then(function(d){return h===!0&&a.revokeObjectURL(c),d.userData.mimeType=i.mimeType||Ia(i.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),d});return this.sourceCache[e]=f,f}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[we.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[we.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const c=s.associations.get(i);i=s.extensions[we.KHR_TEXTURE_TRANSFORM].extendTexture(i,a),s.associations.set(i,c)}}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 c=this.cache.get(a);c||(c=new l.PointsMaterial,l.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(a,c)),n=c}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let c=this.cache.get(a);c||(c=new l.LineBasicMaterial,l.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(a,c)),n=c}if(r||s||i){let a="ClonedMaterial:"+n.uuid+":";r&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),i&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=n.clone(),s&&(c.vertexColors=!0),i&&(c.flatShading=!0),r&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return l.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,r=this.extensions,s=n.materials[e];let i;const a={},c=s.extensions||{},h=[];if(c[we.KHR_MATERIALS_UNLIT]){const d=r[we.KHR_MATERIALS_UNLIT];i=d.getMaterialType(),h.push(d.extendParams(a,s,t))}else{const d=s.pbrMetallicRoughness||{};if(a.color=new l.Color(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const p=d.baseColorFactor;a.color.fromArray(p),a.opacity=p[3]}d.baseColorTexture!==void 0&&h.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&&(h.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),h.push(t.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),i=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=l.DoubleSide);const f=s.alphaMode||sr.OPAQUE;if(f===sr.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,f===sr.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&i!==l.MeshBasicMaterial&&(h.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new l.Vector2(1,1),s.normalTexture.scale!==void 0)){const d=s.normalTexture.scale;a.normalScale.set(d,d)}return s.occlusionTexture!==void 0&&i!==l.MeshBasicMaterial&&(h.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&i!==l.MeshBasicMaterial&&(a.emissive=new l.Color().fromArray(s.emissiveFactor)),s.emissiveTexture!==void 0&&i!==l.MeshBasicMaterial&&h.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,3001)),Promise.all(h).then(function(){const d=new i(a);return s.name&&(d.name=s.name),vt(d,s),t.associations.set(d,{materials:e}),s.extensions&&It(r,d,s),d})}createUniqueName(e){const t=l.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[we.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return ws(c,a,t)})}const i=[];for(let a=0,c=e.length;a<c;a++){const h=e[a],f=Ta(h),d=r[f];if(d)i.push(d.promise);else{let p;h.extensions&&h.extensions[we.KHR_DRACO_MESH_COMPRESSION]?p=s(h):p=ws(new l.BufferGeometry,h,t),r[f]={primitive:h,promise:p},i.push(p)}}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 c=0,h=i.length;c<h;c++){const f=i[c].material===void 0?Aa(this.cache):this.getDependency("material",i[c].material);a.push(f)}return a.push(t.loadGeometries(i)),Promise.all(a).then(function(c){const h=c.slice(0,c.length-1),f=c[c.length-1],d=[];for(let g=0,x=f.length;g<x;g++){const v=f[g],_=i[g];let m;const M=h[g];if(_.mode===Ke.TRIANGLES||_.mode===Ke.TRIANGLE_STRIP||_.mode===Ke.TRIANGLE_FAN||_.mode===void 0)m=s.isSkinnedMesh===!0?new l.SkinnedMesh(v,M):new l.Mesh(v,M),m.isSkinnedMesh===!0&&m.normalizeSkinWeights(),_.mode===Ke.TRIANGLE_STRIP?m.geometry=Qr(m.geometry,l.TriangleStripDrawMode):_.mode===Ke.TRIANGLE_FAN&&(m.geometry=Qr(m.geometry,l.TriangleFanDrawMode));else if(_.mode===Ke.LINES)m=new l.LineSegments(v,M);else if(_.mode===Ke.LINE_STRIP)m=new l.Line(v,M);else if(_.mode===Ke.LINE_LOOP)m=new l.LineLoop(v,M);else if(_.mode===Ke.POINTS)m=new l.Points(v,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+_.mode);Object.keys(m.geometry.morphAttributes).length>0&&Pa(m,s),m.name=t.createUniqueName(s.name||"mesh_"+e),vt(m,s),_.extensions&&It(r,m,_),t.assignFinalMaterial(m),d.push(m)}for(let g=0,x=d.length;g<x;g++)t.associations.set(d[g],{meshes:e,primitives:g});if(d.length===1)return s.extensions&&It(r,d[0],s),d[0];const p=new l.Group;s.extensions&&It(r,p,s),t.associations.set(p,{meshes:e});for(let g=0,x=d.length;g<x;g++)p.add(d[g]);return p})}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 l.PerspectiveCamera(l.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type==="orthographic"&&(t=new l.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),vt(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=[],c=[];for(let h=0,f=i.length;h<f;h++){const d=i[h];if(d){a.push(d);const p=new l.Matrix4;s!==null&&p.fromArray(s.array,h*16),c.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new l.Skeleton(a,c)})}loadAnimation(e){const n=this.json.animations[e],r=n.name?n.name:"animation_"+e,s=[],i=[],a=[],c=[],h=[];for(let f=0,d=n.channels.length;f<d;f++){const p=n.channels[f],g=n.samplers[p.sampler],x=p.target,v=x.node,_=n.parameters!==void 0?n.parameters[g.input]:g.input,m=n.parameters!==void 0?n.parameters[g.output]:g.output;x.node!==void 0&&(s.push(this.getDependency("node",v)),i.push(this.getDependency("accessor",_)),a.push(this.getDependency("accessor",m)),c.push(g),h.push(x))}return Promise.all([Promise.all(s),Promise.all(i),Promise.all(a),Promise.all(c),Promise.all(h)]).then(function(f){const d=f[0],p=f[1],g=f[2],x=f[3],v=f[4],_=[];for(let m=0,M=d.length;m<M;m++){const b=d[m],S=p[m],L=g[m],P=x[m],T=v[m];if(b===void 0)continue;b.updateMatrix();let y;switch(yt[T.path]){case yt.weights:y=l.NumberKeyframeTrack;break;case yt.rotation:y=l.QuaternionKeyframeTrack;break;case yt.position:case yt.scale:default:y=l.VectorKeyframeTrack;break}const A=b.name?b.name:b.uuid,w=P.interpolation!==void 0?Sa[P.interpolation]:l.InterpolateLinear,D=[];yt[T.path]===yt.weights?b.traverse(function(R){R.morphTargetInfluences&&D.push(R.name?R.name:R.uuid)}):D.push(A);let k=L.array;if(L.normalized){const R=or(k.constructor),V=new Float32Array(k.length);for(let Y=0,G=k.length;Y<G;Y++)V[Y]=k[Y]*R;k=V}for(let R=0,V=D.length;R<V;R++){const Y=new y(D[R]+"."+yt[T.path],S.array,k,w);P.interpolation==="CUBICSPLINE"&&(Y.createInterpolant=function(Q){const K=this instanceof l.QuaternionKeyframeTrack?Ma:vs;return new K(this.times,this.values,this.getValueSize()/3,Q)},Y.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),_.push(Y)}}return new l.AnimationClip(r,void 0,_)})}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 c=0,h=r.weights.length;c<h;c++)a.morphTargetInfluences[c]=r.weights[c]}),i})}loadNode(e){const t=this.json,n=this,r=t.nodes[e],s=n._loadNodeShallow(e),i=[],a=r.children||[];for(let h=0,f=a.length;h<f;h++)i.push(n.getDependency("node",a[h]));const c=r.skin===void 0?Promise.resolve(null):n.getDependency("skin",r.skin);return Promise.all([s,Promise.all(i),c]).then(function(h){const f=h[0],d=h[1],p=h[2];p!==null&&f.traverse(function(g){g.isSkinnedMesh&&g.bind(p,La)});for(let g=0,x=d.length;g<x;g++)f.add(d[g]);return f})}_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=[],c=r._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return c&&a.push(c),s.camera!==void 0&&a.push(r.getDependency("camera",s.camera).then(function(h){return r._getNodeRef(r.cameraCache,s.camera,h)})),r._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){a.push(h)}),this.nodeCache[e]=Promise.all(a).then(function(h){let f;if(s.isBone===!0?f=new l.Bone:h.length>1?f=new l.Group:h.length===1?f=h[0]:f=new l.Object3D,f!==h[0])for(let d=0,p=h.length;d<p;d++)f.add(h[d]);if(s.name&&(f.userData.name=s.name,f.name=i),vt(f,s),s.extensions&&It(n,f,s),s.matrix!==void 0){const d=new l.Matrix4;d.fromArray(s.matrix),f.applyMatrix4(d)}else s.translation!==void 0&&f.position.fromArray(s.translation),s.rotation!==void 0&&f.quaternion.fromArray(s.rotation),s.scale!==void 0&&f.scale.fromArray(s.scale);return r.associations.has(f)||r.associations.set(f,{}),r.associations.get(f).nodes=e,f}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],r=this,s=new l.Group;n.name&&(s.name=r.createUniqueName(n.name)),vt(s,n),n.extensions&&It(t,s,n);const i=n.nodes||[],a=[];for(let c=0,h=i.length;c<h;c++)a.push(r.getDependency("node",i[c]));return Promise.all(a).then(function(c){for(let f=0,d=c.length;f<d;f++)s.add(c[f]);const h=f=>{const d=new Map;for(const[p,g]of r.associations)(p instanceof l.Material||p instanceof l.Texture)&&d.set(p,g);return f.traverse(p=>{const g=r.associations.get(p);g!=null&&d.set(p,g)}),d};return r.associations=h(s),s})}}function Da(o,e,t){const n=e.attributes,r=new l.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],c=a.min,h=a.max;if(c!==void 0&&h!==void 0){if(r.set(new l.Vector3(c[0],c[1],c[2]),new l.Vector3(h[0],h[1],h[2])),a.normalized){const f=or(Vt[a.componentType]);r.min.multiplyScalar(f),r.max.multiplyScalar(f)}}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 l.Vector3,c=new l.Vector3;for(let h=0,f=s.length;h<f;h++){const d=s[h];if(d.POSITION!==void 0){const p=t.json.accessors[d.POSITION],g=p.min,x=p.max;if(g!==void 0&&x!==void 0){if(c.setX(Math.max(Math.abs(g[0]),Math.abs(x[0]))),c.setY(Math.max(Math.abs(g[1]),Math.abs(x[1]))),c.setZ(Math.max(Math.abs(g[2]),Math.abs(x[2]))),p.normalized){const v=or(Vt[p.componentType]);c.multiplyScalar(v)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}o.boundingBox=r;const i=new l.Sphere;r.getCenter(i.center),i.radius=r.min.distanceTo(r.max)/2,o.boundingSphere=i}function ws(o,e,t){const n=e.attributes,r=[];function s(i,a){return t.getDependency("accessor",i).then(function(c){o.setAttribute(a,c)})}for(const i in n){const a=rr[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 vt(o,e),Da(o,e,t),Promise.all(r).then(function(){return e.targets!==void 0?Ca(o,e.targets,t):o})}const $t=new l.Vector3;function Qe(o,e,t,n,r,s){const i=2*Math.PI*r/4,a=Math.max(s-2*r,0),c=Math.PI/4;$t.copy(e),$t[n]=0,$t.normalize();const h=.5*i/(i+a),f=1-$t.angleTo(o)/c;return Math.sign($t[t])===1?f*h:a/(i+a)+h+h*(1-f)}class ka extends l.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 l.Vector3,c=new l.Vector3,h=new l.Vector3(e,t,n).divideScalar(2).subScalar(s),f=this.attributes.position.array,d=this.attributes.normal.array,p=this.attributes.uv.array,g=f.length/6,x=new l.Vector3,v=.5/r;for(let _=0,m=0;_<f.length;_+=3,m+=2)switch(a.fromArray(f,_),c.copy(a),c.x-=Math.sign(c.x)*v,c.y-=Math.sign(c.y)*v,c.z-=Math.sign(c.z)*v,c.normalize(),f[_+0]=h.x*Math.sign(a.x)+c.x*s,f[_+1]=h.y*Math.sign(a.y)+c.y*s,f[_+2]=h.z*Math.sign(a.z)+c.z*s,d[_+0]=c.x,d[_+1]=c.y,d[_+2]=c.z,Math.floor(_/g)){case 0:x.set(1,0,0),p[m+0]=Qe(x,c,"z","y",s,n),p[m+1]=1-Qe(x,c,"y","z",s,t);break;case 1:x.set(-1,0,0),p[m+0]=1-Qe(x,c,"z","y",s,n),p[m+1]=1-Qe(x,c,"y","z",s,t);break;case 2:x.set(0,1,0),p[m+0]=1-Qe(x,c,"x","z",s,e),p[m+1]=Qe(x,c,"z","x",s,n);break;case 3:x.set(0,-1,0),p[m+0]=1-Qe(x,c,"x","z",s,e),p[m+1]=1-Qe(x,c,"z","x",s,n);break;case 4:x.set(0,0,1),p[m+0]=1-Qe(x,c,"x","y",s,e),p[m+1]=1-Qe(x,c,"y","x",s,t);break;case 5:x.set(0,0,-1),p[m+0]=Qe(x,c,"x","y",s,e),p[m+1]=1-Qe(x,c,"y","x",s,t);break}}}class bs extends l.ExtrudeGeometry{constructor(e,t={}){const{bevelEnabled:n=!1,bevelSize:r=8,bevelThickness:s=10,font:i,height:a=50,size:c=100,lineHeight:h=1,letterSpacing:f=0,...d}=t;if(i===void 0)super();else{const p=i.generateShapes(e,c,{lineHeight:h,letterSpacing:f});super(p,{...d,bevelEnabled:n,bevelSize:r,bevelThickness:s,depth:a})}this.type="TextGeometry"}}const Ba={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
|
|
27
|
+
`})),Nt.uniforms.blitTexture.value=o,Nt.defines.IS_SRGB="colorSpace"in o?o.colorSpace==="srgb":o.encoding===3001,Nt.needsUpdate=!0,bn||(bn=new l.Mesh(Kn,Nt),bn.frustrumCulled=!1);const n=new l.PerspectiveCamera,r=new l.Scene;r.add(bn),t||(t=wn=new l.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 l.Texture(t.domElement);return s.minFilter=o.minFilter,s.magFilter=o.magFilter,s.wrapS=o.wrapS,s.wrapT=o.wrapT,s.name=o.name,wn&&(wn.dispose(),wn=null),s}const es={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 Qn{constructor(){this.pluginCallbacks=[],this.register(function(e){return new wo(e)}),this.register(function(e){return new bo(e)}),this.register(function(e){return new Ao(e)}),this.register(function(e){return new Co(e)}),this.register(function(e){return new Po(e)}),this.register(function(e){return new To(e)}),this.register(function(e){return new Mo(e)}),this.register(function(e){return new So(e)}),this.register(function(e){return new Io(e)}),this.register(function(e){return new Oo(e)}),this.register(function(e){return new Do(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 xo,i=[];for(let a=0,c=this.pluginCallbacks.length;a<c;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)})}}uo(Qn,"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 c=0;c<n;c++)s[c]=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 c=0;c<o.times.length;c++){if(Math.abs(o.times[c]-e)<.001)return c;if(o.times[c]<e&&o.times[c+1]>e){r.set(o.times.slice(0,c+1),0),r[c+1]=e,r.set(o.times.slice(c+1),c+2),s.set(o.values.slice(0,(c+1)*n),0),s.set(i.evaluate(e),(c+1)*n),s.set(o.values.slice((c+1)*n),(c+2)*n),a=c+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=l.PropertyBinding.parseTrackName(i.name),c=l.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(l.InterpolateLinear)}const h=c.morphTargetInfluences.length,d=c.morphTargetDictionary[a.propertyIndex];if(d===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let f;if(n[c.uuid]===void 0){f=i.clone();const m=new f.ValueBufferType(h*f.times.length);for(let _=0;_<f.times.length;_++)m[_*h+d]=f.values[_];f.name=(a.nodeName||"")+".morphTargetInfluences",f.values=m,n[c.uuid]=f,t.push(f);continue}const p=i.createInterpolant(new i.ValueBufferType(1));f=n[c.uuid];for(let m=0;m<f.times.length;m++)f.values[m*h+d]=p.evaluate(f.times[m]);for(let m=0;m<i.times.length;m++){const _=this.insertKeyframe(f,i.times[m]);f.values[_*h+d]=i.values[m]}}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",Ke={};Ke[l.NearestFilter]=we.NEAREST,Ke[l.NearestMipmapNearestFilter]=we.NEAREST_MIPMAP_NEAREST,Ke[l.NearestMipmapLinearFilter]=we.NEAREST_MIPMAP_LINEAR,Ke[l.LinearFilter]=we.LINEAR,Ke[l.LinearMipmapNearestFilter]=we.LINEAR_MIPMAP_NEAREST,Ke[l.LinearMipmapLinearFilter]=we.LINEAR_MIPMAP_LINEAR,Ke[l.ClampToEdgeWrapping]=we.CLAMP_TO_EDGE,Ke[l.RepeatWrapping]=we.REPEAT,Ke[l.MirroredRepeatWrapping]=we.MIRRORED_REPEAT;const ts={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},ho=new l.Color,ns=12,fo=1179937895,po=2,rs=8,mo=1313821514,go=5130562;function Qt(o,e){return o.length===e.length&&o.every(function(t,n){return t===e[n]})}function yo(o){return new TextEncoder().encode(o).buffer}function _o(o){return Qt(o.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function vo(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=l.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 ss(o){return Math.ceil(o/4)*4}function Hn(o,e=0){const t=ss(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 is(){return typeof document>"u"&&typeof OffscreenCanvas<"u"?new OffscreenCanvas(1,1):document.createElement("canvas")}function os(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 xo{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,c=r.extensionsRequired,h=new Blob(s,{type:"application/octet-stream"}),d=Object.keys(a),f=Object.keys(c);d.length>0&&(i.extensionsUsed=d),f.length>0&&(i.extensionsRequired=f),i.buffers&&i.buffers.length>0&&(i.buffers[0].byteLength=h.size),n.binary===!0?h.arrayBuffer().then(p=>{const m=Hn(p),_=new DataView(new ArrayBuffer(rs));_.setUint32(0,m.byteLength,!0),_.setUint32(4,go,!0);const v=Hn(yo(JSON.stringify(i)),32),y=new DataView(new ArrayBuffer(rs));y.setUint32(0,v.byteLength,!0),y.setUint32(4,mo,!0);const g=new ArrayBuffer(ns),M=new DataView(g);M.setUint32(0,fo,!0),M.setUint32(4,po,!0);const b=ns+y.byteLength+v.byteLength+_.byteLength+m.byteLength;M.setUint32(8,b,!0),new Blob([g,y,v,_,m],{type:"application/octet-stream"}).arrayBuffer().then(t)}):i.buffers&&i.buffers.length>0?$r(h).then(p=>{i.buffers[0].uri=p,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 l.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 l.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(m){return("colorSpace"in m?m.colorSpace==="srgb":m.encoding===3001)?function(v){return v<.04045?v*.0773993808:Math.pow(v*.9478672986+.0521327014,2.4)}:function(v){return v}}console.warn("THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures."),e instanceof l.CompressedTexture&&(e=qn(e)),t instanceof l.CompressedTexture&&(t=qn(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),c=is();c.width=i,c.height=a;const h=c.getContext("2d");h.fillStyle="#00ffff",h.fillRect(0,0,i,a);const d=h.getImageData(0,0,i,a);if(r){h.drawImage(r,0,0,i,a);const m=n(e),_=h.getImageData(0,0,i,a).data;for(let v=2;v<_.length;v+=4)d.data[v]=m(_[v]/256)*256}if(s){h.drawImage(s,0,0,i,a);const m=n(t),_=h.getImageData(0,0,i,a).data;for(let v=1;v<_.length;v+=4)d.data[v]=m(_[v]/256)*256}h.putImageData(d,0,0);const p=(e||t).clone();return p.source=new l.Texture(c).source,"colorSpace"in p?p.colorSpace="":p.encoding=3e3,p.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn("THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match."),p}processBuffer(e){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 c=ss(r*e.itemSize*a),h=new DataView(new ArrayBuffer(c));let d=0;for(let m=n;m<n+r;m++)for(let _=0;_<e.itemSize;_++){let v;e.itemSize>4?v=e.array[m*e.itemSize+_]:(_===0?v=e.getX(m):_===1?v=e.getY(m):_===2?v=e.getZ(m):_===3&&(v=e.getW(m)),e.normalized===!0&&(v=l.MathUtils.normalize(v,e.array))),t===we.FLOAT?h.setFloat32(d,v,!0):t===we.INT?h.setInt32(d,v,!0):t===we.UNSIGNED_INT?h.setUint32(d,v,!0):t===we.SHORT?h.setInt16(d,v,!0):t===we.UNSIGNED_SHORT?h.setUint16(d,v,!0):t===we.BYTE?h.setInt8(d,v):t===we.UNSIGNED_BYTE&&h.setUint8(d,v),d+=a}const f={buffer:this.processBuffer(h.buffer),byteOffset:this.byteOffset,byteLength:c};return s!==void 0&&(f.target=s),s===we.ARRAY_BUFFER&&(f.byteStride=e.itemSize*a),this.byteOffset+=c,i.bufferViews.push(f),{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=Hn(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 c=vo(e,n,r);let h;t!==void 0&&(h=e===t.index?we.ELEMENT_ARRAY_BUFFER:we.ARRAY_BUFFER);const d=this.processBufferView(e,a,n,r,h),f={bufferView:d.id,byteOffset:d.byteOffset,componentType:a,count:r,max:c.max,min:c.min,type:i[e.itemSize]};return e.normalized===!0&&(f.normalized=!0),s.accessors||(s.accessors=[]),s.accessors.push(f)-1}processImage(e,t,n,r="image/png"){if(e!==null){const s=this,i=s.cache,a=s.json,c=s.options,h=s.pending;i.images.has(e)||i.images.set(e,{});const d=i.images.get(e),f=r+":flipY/"+n.toString();if(d[f]!==void 0)return d[f];a.images||(a.images=[]);const p={mimeType:r},m=is();m.width=Math.min(e.width,c.maxTextureSize),m.height=Math.min(e.height,c.maxTextureSize);const _=m.getContext("2d");if(n===!0&&(_.translate(0,m.height),_.scale(1,-1)),e.data!==void 0){t!==l.RGBAFormat&&console.error("GLTFExporter: Only RGBAFormat is supported.",t),(e.width>c.maxTextureSize||e.height>c.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const y=new Uint8ClampedArray(e.height*e.width*4);for(let g=0;g<y.length;g+=4)y[g+0]=e.data[g+0],y[g+1]=e.data[g+1],y[g+2]=e.data[g+2],y[g+3]=e.data[g+3];_.putImageData(new ImageData(y,e.width,e.height),0,0)}else _.drawImage(e,0,0,m.width,m.height);c.binary===!0?h.push(os(m,r).then(y=>s.processBufferViewImage(y)).then(y=>{p.bufferView=y})):m.toDataURL!==void 0?p.uri=m.toDataURL(r):h.push(os(m,r).then($r).then(y=>{p.uri=y}));const v=a.images.push(p)-1;return d[f]=v,v}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:Ke[e.magFilter],minFilter:Ke[e.minFilter],wrapS:Ke[e.wrapS],wrapT:Ke[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 l.CompressedTexture&&(e=qn(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(h){h.writeTexture&&h.writeTexture(e,a)});const c=s.textures.push(a)-1;return r.textures.set(e,c),c}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(Qt(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),c={index:this.processTexture(a),channel:a.channel};this.applyTextureTransform(c,a),r.pbrMetallicRoughness.metallicRoughnessTexture=c}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 h={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(h,e.emissiveMap),r.emissiveTexture=h}}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===l.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 b=0,S=e.material.length;b<S;b++)r.push(e.material[b].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 c={},h={},d=[],f=[],p={...xn>=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"},m=i.getAttribute("normal");m!==void 0&&!this.isNormalizedNormalAttribute(m)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),i.setAttribute("normal",this.createNormalizedNormalAttribute(m)));let _=null;for(let b in i.attributes){if(b.slice(0,5)==="morph")continue;const S=i.attributes[b];if(b=p[b]||b.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(b)||(b="_"+b),t.attributes.has(this.getUID(S))){h[b]=t.attributes.get(this.getUID(S));continue}_=null;const T=S.array;b==="JOINTS_0"&&!(T instanceof Uint16Array)&&!(T instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),_=new l.BufferAttribute(new Uint16Array(T),S.itemSize,S.normalized));const C=this.processAccessor(_||S,i);C!==null&&(b.startsWith("_")||this.detectMeshQuantization(b,S),h[b]=C,t.attributes.set(this.getUID(S),C))}if(m!==void 0&&i.setAttribute("normal",m),Object.keys(h).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const b=[],S=[],O={};if(e.morphTargetDictionary!==void 0)for(const T in e.morphTargetDictionary)O[e.morphTargetDictionary[T]]=T;for(let T=0;T<e.morphTargetInfluences.length;++T){const C={};let w=!1;for(const A in i.morphAttributes){if(A!=="position"&&A!=="normal"){w||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),w=!0);continue}const x=i.morphAttributes[A][T],D=A.toUpperCase(),L=i.attributes[A];if(t.attributes.has(this.getUID(x,!0))){C[D]=t.attributes.get(this.getUID(x,!0));continue}const V=x.clone();if(!i.morphTargetsRelative)for(let R=0,X=x.count;R<X;R++)for(let Y=0;Y<x.itemSize;Y++)Y===0&&V.setX(R,x.getX(R)-L.getX(R)),Y===1&&V.setY(R,x.getY(R)-L.getY(R)),Y===2&&V.setZ(R,x.getZ(R)-L.getZ(R)),Y===3&&V.setW(R,x.getW(R)-L.getW(R));C[D]=this.processAccessor(V,i),t.attributes.set(this.getUID(L,!0),C[D])}f.push(C),b.push(e.morphTargetInfluences[T]),e.morphTargetDictionary!==void 0&&S.push(O[T])}c.weights=b,S.length>0&&(c.extras={},c.extras.targetNames=S)}const v=Array.isArray(e.material);if(v&&i.groups.length===0)return null;const y=v?e.material:[e.material],g=v?i.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let b=0,S=g.length;b<S;b++){const O={mode:a,attributes:h};if(this.serializeUserData(i,O),f.length>0&&(O.targets=f),i.index!==null){let C=this.getUID(i.index);(g[b].start!==void 0||g[b].count!==void 0)&&(C+=":"+g[b].start+":"+g[b].count),t.attributes.has(C)?O.indices=t.attributes.get(C):(O.indices=this.processAccessor(i.index,i,g[b].start,g[b].count),t.attributes.set(C,O.indices)),O.indices===null&&delete O.indices}const T=this.processMaterial(y[g[b].materialIndex]);T!==null&&(O.material=T),d.push(O)}c.primitives=d,n.meshes||(n.meshes=[]),this._invokeAll(function(b){b.writeMesh&&b.writeMesh(e,c)});const M=n.meshes.push(c)-1;return t.meshes.set(s,M),M}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];es[r]&&es[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:l.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=Qn.Utils.mergeMorphTargetTracks(e.clone(),t);const s=e.tracks,i=[],a=[];for(let c=0;c<s.length;++c){const h=s[c],d=l.PropertyBinding.parseTrackName(h.name);let f=l.PropertyBinding.findNode(t,d.nodeName);const p=ts[d.propertyName];if(d.objectName==="bones"&&(f.isSkinnedMesh===!0?f=f.skeleton.getBoneByName(d.objectIndex):f=void 0),!f||!p)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',h.name),null;const m=1;let _=h.values.length/h.times.length;p===ts.morphTargetInfluences&&(_/=f.morphTargetInfluences.length);let v;h.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(v="CUBICSPLINE",_/=3):h.getInterpolation()===l.InterpolateDiscrete?v="STEP":v="LINEAR",a.push({input:this.processAccessor(new l.BufferAttribute(h.times,m)),output:this.processAccessor(new l.BufferAttribute(h.values,_)),interpolation:v}),i.push({sampler:a.length-1,target:{node:r.get(f),path:p}})}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=[],c=new Float32Array(s.bones.length*16),h=new l.Matrix4;for(let f=0;f<s.bones.length;++f)a.push(n.get(s.bones[f])),h.copy(s.boneInverses[f]),h.multiply(e.bindMatrix).toArray(c,f*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new l.BufferAttribute(c,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(),c=e.position.toArray(),h=e.scale.toArray();Qt(a,[0,0,0,1])||(s.rotation=a),Qt(c,[0,0,0])||(s.translation=c),Qt(h,[1,1,1])||(s.scale=h)}else e.matrixAutoUpdate&&e.updateMatrix(),_o(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 c=0,h=e.children.length;c<h;c++){const d=e.children[c];if(d.visible||n.onlyVisible===!1){const f=this.processNode(d);f!==null&&a.push(f)}}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 c=e.children[i];if(c.visible||n.onlyVisible===!1){const h=this.processNode(c);h!==null&&s.push(h)}}s.length>0&&(r.nodes=s),this.serializeUserData(e,r)}processObjects(e){const t=new l.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 l.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 wo{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 bo=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}},Mo=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}},So=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}},Ao=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}},Po=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}},To=class{constructor(e){this.writer=e,this.name="KHR_materials_specular"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(ho)&&!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}},Io=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}},Oo=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}},Do=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 qe=Uint8Array,yt=Uint16Array,$n=Uint32Array,as=new qe([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]),ls=new qe([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]),Lo=new qe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),cs=function(o,e){for(var t=new yt(31),n=0;n<31;++n)t[n]=e+=1<<o[n-1];for(var r=new $n(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]},us=cs(as,2),hs=us[0],ko=us[1];hs[28]=258,ko[258]=28;for(var Bo=cs(ls,0),Fo=Bo[0],er=new yt(32768),Te=0;Te<32768;++Te){var _t=(Te&43690)>>>1|(Te&21845)<<1;_t=(_t&52428)>>>2|(_t&13107)<<2,_t=(_t&61680)>>>4|(_t&3855)<<4,er[Te]=((_t&65280)>>>8|(_t&255)<<8)>>>1}for(var Jt=function(o,e,t){for(var n=o.length,r=0,s=new yt(e);r<n;++r)++s[o[r]-1];var i=new yt(e);for(r=0;r<e;++r)i[r]=i[r-1]+s[r-1]<<1;var a;if(t){a=new yt(1<<e);var c=15-e;for(r=0;r<n;++r)if(o[r])for(var h=r<<4|o[r],d=e-o[r],f=i[o[r]-1]++<<d,p=f|(1<<d)-1;f<=p;++f)a[er[f]>>>c]=h}else for(a=new yt(n),r=0;r<n;++r)o[r]&&(a[r]=er[i[o[r]-1]++]>>>15-o[r]);return a},Ht=new qe(288),Te=0;Te<144;++Te)Ht[Te]=8;for(var Te=144;Te<256;++Te)Ht[Te]=9;for(var Te=256;Te<280;++Te)Ht[Te]=7;for(var Te=280;Te<288;++Te)Ht[Te]=8;for(var fs=new qe(32),Te=0;Te<32;++Te)fs[Te]=5;var Uo=Jt(Ht,9,1),No=Jt(fs,5,1),tr=function(o){for(var e=o[0],t=1;t<o.length;++t)o[t]>e&&(e=o[t]);return e},et=function(o,e,t){var n=e/8|0;return(o[n]|o[n+1]<<8)>>(e&7)&t},nr=function(o,e){var t=e/8|0;return(o[t]|o[t+1]<<8|o[t+2]<<16)>>(e&7)},zo=function(o){return(o/8|0)+(o&7&&1)},Vo=function(o,e,t){(t==null||t>o.length)&&(t=o.length);var n=new(o instanceof yt?yt:o instanceof $n?$n:qe)(t-e);return n.set(o.subarray(e,t)),n},Ro=function(o,e,t){var n=o.length;if(!n||t&&!t.l&&n<5)return e||new qe(0);var r=!e||t,s=!t||t.i;t||(t={}),e||(e=new qe(n*3));var i=function(F){var B=e.length;if(F>B){var G=new qe(Math.max(B*2,F));G.set(e),e=G}},a=t.f||0,c=t.p||0,h=t.b||0,d=t.l,f=t.d,p=t.m,m=t.n,_=n*8;do{if(!d){t.f=a=et(o,c,1);var v=et(o,c+1,3);if(c+=3,v)if(v==1)d=Uo,f=No,p=9,m=5;else if(v==2){var b=et(o,c,31)+257,S=et(o,c+10,15)+4,O=b+et(o,c+5,31)+1;c+=14;for(var T=new qe(O),C=new qe(19),w=0;w<S;++w)C[Lo[w]]=et(o,c+w*3,7);c+=S*3;for(var A=tr(C),x=(1<<A)-1,D=Jt(C,A,1),w=0;w<O;){var L=D[et(o,c,x)];c+=L&15;var y=L>>>4;if(y<16)T[w++]=y;else{var V=0,R=0;for(y==16?(R=3+et(o,c,3),c+=2,V=T[w-1]):y==17?(R=3+et(o,c,7),c+=3):y==18&&(R=11+et(o,c,127),c+=7);R--;)T[w++]=V}}var X=T.subarray(0,b),Y=T.subarray(b);p=tr(X),m=tr(Y),d=Jt(X,p,1),f=Jt(Y,m,1)}else throw"invalid block type";else{var y=zo(c)+4,g=o[y-4]|o[y-3]<<8,M=y+g;if(M>n){if(s)throw"unexpected EOF";break}r&&i(h+g),e.set(o.subarray(y,M),h),t.b=h+=g,t.p=c=M*8;continue}if(c>_){if(s)throw"unexpected EOF";break}}r&&i(h+131072);for(var J=(1<<p)-1,q=(1<<m)-1,re=c;;re=c){var V=d[nr(o,c)&J],ee=V>>>4;if(c+=V&15,c>_){if(s)throw"unexpected EOF";break}if(!V)throw"invalid length/literal";if(ee<256)e[h++]=ee;else if(ee==256){re=c,d=null;break}else{var ce=ee-254;if(ee>264){var w=ee-257,le=as[w];ce=et(o,c,(1<<le)-1)+hs[w],c+=le}var me=f[nr(o,c)&q],k=me>>>4;if(!me)throw"invalid distance";c+=me&15;var Y=Fo[k];if(k>3){var le=ls[k];Y+=nr(o,c)&(1<<le)-1,c+=le}if(c>_){if(s)throw"unexpected EOF";break}r&&i(h+131072);for(var z=h+ce;h<z;h+=4)e[h]=e[h-Y],e[h+1]=e[h+1-Y],e[h+2]=e[h+2-Y],e[h+3]=e[h+3-Y];h=z}}t.l=d,t.p=re,t.b=h,d&&(a=1,t.m=p,t.d=f,t.n=m)}while(!a);return h==e.length?e:Vo(e,0,h)},Go=new qe(0),jo=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 Eo(o,e){return Ro((jo(o),o.subarray(2,-4)),e)}var Yo=typeof TextDecoder<"u"&&new TextDecoder,Wo=0;try{Yo.decode(Go,{stream:!0}),Wo=1}catch{}var Xo=Object.defineProperty,Zo=(o,e,t)=>e in o?Xo(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,Ko=(o,e,t)=>(Zo(o,e+"",t),t);const ds=class extends l.Mesh{constructor(o,e={}){super(o),this.isReflector=!0,this.type="Reflector",this.camera=new l.PerspectiveCamera;const t=this,n=e.color!==void 0?new l.Color(e.color):new l.Color(8355711),r=e.textureWidth||512,s=e.textureHeight||512,i=e.clipBias||0,a=e.shader||ds.ReflectorShader,c=e.multisample!==void 0?e.multisample:4,h=new l.Plane,d=new l.Vector3,f=new l.Vector3,p=new l.Vector3,m=new l.Matrix4,_=new l.Vector3(0,0,-1),v=new l.Vector4,y=new l.Vector3,g=new l.Vector3,M=new l.Vector4,b=new l.Matrix4,S=this.camera,O=new l.WebGLRenderTarget(r,s,{samples:c,type:l.HalfFloatType}),T=new l.ShaderMaterial({uniforms:l.UniformsUtils.clone(a.uniforms),fragmentShader:a.fragmentShader,vertexShader:a.vertexShader});T.uniforms.tDiffuse.value=O.texture,T.uniforms.color.value=n,T.uniforms.textureMatrix.value=b,this.material=T,this.onBeforeRender=function(C,w,A){if(f.setFromMatrixPosition(t.matrixWorld),p.setFromMatrixPosition(A.matrixWorld),m.extractRotation(t.matrixWorld),d.set(0,0,1),d.applyMatrix4(m),y.subVectors(f,p),y.dot(d)>0)return;y.reflect(d).negate(),y.add(f),m.extractRotation(A.matrixWorld),_.set(0,0,-1),_.applyMatrix4(m),_.add(p),g.subVectors(f,_),g.reflect(d).negate(),g.add(f),S.position.copy(y),S.up.set(0,1,0),S.up.applyMatrix4(m),S.up.reflect(d),S.lookAt(g),S.far=A.far,S.updateMatrixWorld(),S.projectionMatrix.copy(A.projectionMatrix),b.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),b.multiply(S.projectionMatrix),b.multiply(S.matrixWorldInverse),b.multiply(t.matrixWorld),h.setFromNormalAndCoplanarPoint(d,f),h.applyMatrix4(S.matrixWorldInverse),v.set(h.normal.x,h.normal.y,h.normal.z,h.constant);const x=S.projectionMatrix;M.x=(Math.sign(v.x)+x.elements[8])/x.elements[0],M.y=(Math.sign(v.y)+x.elements[9])/x.elements[5],M.z=-1,M.w=(1+x.elements[10])/x.elements[14],v.multiplyScalar(2/v.dot(M)),x.elements[2]=v.x,x.elements[6]=v.y,x.elements[10]=v.z+1-i,x.elements[14]=v.w,t.visible=!1;const D=C.getRenderTarget(),L=C.xr.enabled,V=C.shadowMap.autoUpdate,R=C.toneMapping;let X=!1;"outputColorSpace"in C?X=C.outputColorSpace==="srgb":X=C.outputEncoding===3001,C.xr.enabled=!1,C.shadowMap.autoUpdate=!1,"outputColorSpace"in C?C.outputColorSpace="srgb-linear":C.outputEncoding=3e3,C.toneMapping=l.NoToneMapping,C.setRenderTarget(O),C.state.buffers.depth.setMask(!0),C.autoClear===!1&&C.clear(),C.render(w,S),C.xr.enabled=L,C.shadowMap.autoUpdate=V,C.toneMapping=R,"outputColorSpace"in C?C.outputColorSpace=X?"srgb":"srgb-linear":C.outputEncoding=X?3001:3e3,C.setRenderTarget(D);const Y=A.viewport;Y!==void 0&&C.state.viewport(Y),t.visible=!0},this.getRenderTarget=function(){return O},this.dispose=function(){O.dispose(),t.material.dispose()}}};let rr=ds;Ko(rr,"ReflectorShader",{uniforms:{color:{value:null},tDiffuse:{value:null},textureMatrix:{value:null}},vertexShader:`
|
|
28
|
+
uniform mat4 textureMatrix;
|
|
29
|
+
varying vec4 vUv;
|
|
30
|
+
|
|
31
|
+
#include <common>
|
|
32
|
+
#include <logdepthbuf_pars_vertex>
|
|
33
|
+
|
|
34
|
+
void main() {
|
|
35
|
+
|
|
36
|
+
vUv = textureMatrix * vec4( position, 1.0 );
|
|
37
|
+
|
|
38
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
39
|
+
|
|
40
|
+
#include <logdepthbuf_vertex>
|
|
41
|
+
|
|
42
|
+
}`,fragmentShader:`
|
|
43
|
+
uniform vec3 color;
|
|
44
|
+
uniform sampler2D tDiffuse;
|
|
45
|
+
varying vec4 vUv;
|
|
46
|
+
|
|
47
|
+
#include <logdepthbuf_pars_fragment>
|
|
48
|
+
|
|
49
|
+
float blendOverlay( float base, float blend ) {
|
|
50
|
+
|
|
51
|
+
return( base < 0.5 ? ( 2.0 * base * blend ) : ( 1.0 - 2.0 * ( 1.0 - base ) * ( 1.0 - blend ) ) );
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
vec3 blendOverlay( vec3 base, vec3 blend ) {
|
|
56
|
+
|
|
57
|
+
return vec3( blendOverlay( base.r, blend.r ), blendOverlay( base.g, blend.g ), blendOverlay( base.b, blend.b ) );
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
void main() {
|
|
62
|
+
|
|
63
|
+
#include <logdepthbuf_fragment>
|
|
64
|
+
|
|
65
|
+
vec4 base = texture2DProj( tDiffuse, vUv );
|
|
66
|
+
gl_FragColor = vec4( blendOverlay( base.rgb, color ), 1.0 );
|
|
67
|
+
|
|
68
|
+
#include <tonemapping_fragment>
|
|
69
|
+
#include <${xn>=154?"colorspace_fragment":"encodings_fragment"}>
|
|
70
|
+
|
|
71
|
+
}`});class qo extends l.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,c=t.time!==void 0?t.time:0,h=t.waterNormals!==void 0?t.waterNormals:null,d=t.sunDirection!==void 0?t.sunDirection:new l.Vector3(.70707,.70707,0),f=new l.Color(t.sunColor!==void 0?t.sunColor:16777215),p=new l.Color(t.waterColor!==void 0?t.waterColor:8355711),m=t.eye!==void 0?t.eye:new l.Vector3(0,0,0),_=t.distortionScale!==void 0?t.distortionScale:20,v=t.side!==void 0?t.side:l.FrontSide,y=t.fog!==void 0?t.fog:!1,g=new l.Plane,M=new l.Vector3,b=new l.Vector3,S=new l.Vector3,O=new l.Matrix4,T=new l.Vector3(0,0,-1),C=new l.Vector4,w=new l.Vector3,A=new l.Vector3,x=new l.Vector4,D=new l.Matrix4,L=new l.PerspectiveCamera,V=new l.WebGLRenderTarget(r,s),R={uniforms:l.UniformsUtils.merge([l.UniformsLib.fog,l.UniformsLib.lights,{normalSampler:{value:null},mirrorSampler:{value:null},alpha:{value:1},time:{value:0},size:{value:1},distortionScale:{value:20},textureMatrix:{value:new l.Matrix4},sunColor:{value:new l.Color(8355711)},sunDirection:{value:new l.Vector3(.70707,.70707,0)},eye:{value:new l.Vector3},waterColor:{value:new l.Color(5592405)}}]),vertexShader:`
|
|
72
|
+
uniform mat4 textureMatrix;
|
|
73
|
+
uniform float time;
|
|
74
|
+
|
|
75
|
+
varying vec4 mirrorCoord;
|
|
76
|
+
varying vec4 worldPosition;
|
|
77
|
+
|
|
78
|
+
#include <common>
|
|
79
|
+
#include <fog_pars_vertex>
|
|
80
|
+
#include <shadowmap_pars_vertex>
|
|
81
|
+
#include <logdepthbuf_pars_vertex>
|
|
82
|
+
|
|
83
|
+
void main() {
|
|
84
|
+
mirrorCoord = modelMatrix * vec4( position, 1.0 );
|
|
85
|
+
worldPosition = mirrorCoord.xyzw;
|
|
86
|
+
mirrorCoord = textureMatrix * mirrorCoord;
|
|
87
|
+
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
88
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
89
|
+
|
|
90
|
+
#include <beginnormal_vertex>
|
|
91
|
+
#include <defaultnormal_vertex>
|
|
92
|
+
#include <logdepthbuf_vertex>
|
|
93
|
+
#include <fog_vertex>
|
|
94
|
+
#include <shadowmap_vertex>
|
|
95
|
+
}`,fragmentShader:`
|
|
96
|
+
uniform sampler2D mirrorSampler;
|
|
97
|
+
uniform float alpha;
|
|
98
|
+
uniform float time;
|
|
99
|
+
uniform float size;
|
|
100
|
+
uniform float distortionScale;
|
|
101
|
+
uniform sampler2D normalSampler;
|
|
102
|
+
uniform vec3 sunColor;
|
|
103
|
+
uniform vec3 sunDirection;
|
|
104
|
+
uniform vec3 eye;
|
|
105
|
+
uniform vec3 waterColor;
|
|
106
|
+
|
|
107
|
+
varying vec4 mirrorCoord;
|
|
108
|
+
varying vec4 worldPosition;
|
|
109
|
+
|
|
110
|
+
vec4 getNoise( vec2 uv ) {
|
|
111
|
+
vec2 uv0 = ( uv / 103.0 ) + vec2(time / 17.0, time / 29.0);
|
|
112
|
+
vec2 uv1 = uv / 107.0-vec2( time / -19.0, time / 31.0 );
|
|
113
|
+
vec2 uv2 = uv / vec2( 8907.0, 9803.0 ) + vec2( time / 101.0, time / 97.0 );
|
|
114
|
+
vec2 uv3 = uv / vec2( 1091.0, 1027.0 ) - vec2( time / 109.0, time / -113.0 );
|
|
115
|
+
vec4 noise = texture2D( normalSampler, uv0 ) +
|
|
116
|
+
texture2D( normalSampler, uv1 ) +
|
|
117
|
+
texture2D( normalSampler, uv2 ) +
|
|
118
|
+
texture2D( normalSampler, uv3 );
|
|
119
|
+
return noise * 0.5 - 1.0;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
void sunLight( const vec3 surfaceNormal, const vec3 eyeDirection, float shiny, float spec, float diffuse, inout vec3 diffuseColor, inout vec3 specularColor ) {
|
|
123
|
+
vec3 reflection = normalize( reflect( -sunDirection, surfaceNormal ) );
|
|
124
|
+
float direction = max( 0.0, dot( eyeDirection, reflection ) );
|
|
125
|
+
specularColor += pow( direction, shiny ) * sunColor * spec;
|
|
126
|
+
diffuseColor += max( dot( sunDirection, surfaceNormal ), 0.0 ) * sunColor * diffuse;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
#include <common>
|
|
130
|
+
#include <packing>
|
|
131
|
+
#include <bsdfs>
|
|
132
|
+
#include <fog_pars_fragment>
|
|
133
|
+
#include <logdepthbuf_pars_fragment>
|
|
134
|
+
#include <lights_pars_begin>
|
|
135
|
+
#include <shadowmap_pars_fragment>
|
|
136
|
+
#include <shadowmask_pars_fragment>
|
|
137
|
+
|
|
138
|
+
void main() {
|
|
139
|
+
|
|
140
|
+
#include <logdepthbuf_fragment>
|
|
141
|
+
vec4 noise = getNoise( worldPosition.xz * size );
|
|
142
|
+
vec3 surfaceNormal = normalize( noise.xzy * vec3( 1.5, 1.0, 1.5 ) );
|
|
143
|
+
|
|
144
|
+
vec3 diffuseLight = vec3(0.0);
|
|
145
|
+
vec3 specularLight = vec3(0.0);
|
|
146
|
+
|
|
147
|
+
vec3 worldToEye = eye-worldPosition.xyz;
|
|
148
|
+
vec3 eyeDirection = normalize( worldToEye );
|
|
149
|
+
sunLight( surfaceNormal, eyeDirection, 100.0, 2.0, 0.5, diffuseLight, specularLight );
|
|
150
|
+
|
|
151
|
+
float distance = length(worldToEye);
|
|
152
|
+
|
|
153
|
+
vec2 distortion = surfaceNormal.xz * ( 0.001 + 1.0 / distance ) * distortionScale;
|
|
154
|
+
vec3 reflectionSample = vec3( texture2D( mirrorSampler, mirrorCoord.xy / mirrorCoord.w + distortion ) );
|
|
155
|
+
|
|
156
|
+
float theta = max( dot( eyeDirection, surfaceNormal ), 0.0 );
|
|
157
|
+
float rf0 = 0.3;
|
|
158
|
+
float reflectance = rf0 + ( 1.0 - rf0 ) * pow( ( 1.0 - theta ), 5.0 );
|
|
159
|
+
vec3 scatter = max( 0.0, dot( surfaceNormal, eyeDirection ) ) * waterColor;
|
|
160
|
+
vec3 albedo = mix( ( sunColor * diffuseLight * 0.3 + scatter ) * getShadowMask(), ( vec3( 0.1 ) + reflectionSample * 0.9 + reflectionSample * specularLight ), reflectance);
|
|
161
|
+
vec3 outgoingLight = albedo;
|
|
162
|
+
gl_FragColor = vec4( outgoingLight, alpha );
|
|
163
|
+
|
|
164
|
+
#include <tonemapping_fragment>
|
|
165
|
+
#include <${parseInt(l.REVISION.replace(/\D+/g,""))>=154?"colorspace_fragment":"encodings_fragment"}>
|
|
166
|
+
#include <fog_fragment>
|
|
167
|
+
}`},X=new l.ShaderMaterial({fragmentShader:R.fragmentShader,vertexShader:R.vertexShader,uniforms:l.UniformsUtils.clone(R.uniforms),lights:!0,side:v,fog:y});X.uniforms.mirrorSampler.value=V.texture,X.uniforms.textureMatrix.value=D,X.uniforms.alpha.value=a,X.uniforms.time.value=c,X.uniforms.normalSampler.value=h,X.uniforms.sunColor.value=f,X.uniforms.waterColor.value=p,X.uniforms.sunDirection.value=d,X.uniforms.distortionScale.value=_,X.uniforms.eye.value=m,n.material=X,n.onBeforeRender=function(Y,J,q){if(b.setFromMatrixPosition(n.matrixWorld),S.setFromMatrixPosition(q.matrixWorld),O.extractRotation(n.matrixWorld),M.set(0,0,1),M.applyMatrix4(O),w.subVectors(b,S),w.dot(M)>0)return;w.reflect(M).negate(),w.add(b),O.extractRotation(q.matrixWorld),T.set(0,0,-1),T.applyMatrix4(O),T.add(S),A.subVectors(b,T),A.reflect(M).negate(),A.add(b),L.position.copy(w),L.up.set(0,1,0),L.up.applyMatrix4(O),L.up.reflect(M),L.lookAt(A),L.far=q.far,L.updateMatrixWorld(),L.projectionMatrix.copy(q.projectionMatrix),D.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),D.multiply(L.projectionMatrix),D.multiply(L.matrixWorldInverse),g.setFromNormalAndCoplanarPoint(M,b),g.applyMatrix4(L.matrixWorldInverse),C.set(g.normal.x,g.normal.y,g.normal.z,g.constant);const re=L.projectionMatrix;x.x=(Math.sign(C.x)+re.elements[8])/re.elements[0],x.y=(Math.sign(C.y)+re.elements[9])/re.elements[5],x.z=-1,x.w=(1+re.elements[10])/re.elements[14],C.multiplyScalar(2/C.dot(x)),re.elements[2]=C.x,re.elements[6]=C.y,re.elements[10]=C.z+1-i,re.elements[14]=C.w,m.setFromMatrixPosition(q.matrixWorld);const ee=Y.getRenderTarget(),ce=Y.xr.enabled,le=Y.shadowMap.autoUpdate;n.visible=!1,Y.xr.enabled=!1,Y.shadowMap.autoUpdate=!1,Y.setRenderTarget(V),Y.state.buffers.depth.setMask(!0),Y.autoClear===!1&&Y.clear(),Y.render(J,L),n.visible=!0,Y.xr.enabled=ce,Y.shadowMap.autoUpdate=le,Y.setRenderTarget(ee);const me=q.viewport;me!==void 0&&Y.state.viewport(me)}}}var Qo=Object.defineProperty,Jo=(o,e,t)=>e in o?Qo(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,ps=(o,e,t)=>(Jo(o,typeof e!="symbol"?e+"":e,t),t);const Mn={uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new l.Vector3},up:{value:new l.Vector3(0,1,0)}},vertexShader:`
|
|
168
|
+
uniform vec3 sunPosition;
|
|
169
|
+
uniform float rayleigh;
|
|
170
|
+
uniform float turbidity;
|
|
171
|
+
uniform float mieCoefficient;
|
|
172
|
+
uniform vec3 up;
|
|
173
|
+
|
|
174
|
+
varying vec3 vWorldPosition;
|
|
175
|
+
varying vec3 vSunDirection;
|
|
176
|
+
varying float vSunfade;
|
|
177
|
+
varying vec3 vBetaR;
|
|
178
|
+
varying vec3 vBetaM;
|
|
179
|
+
varying float vSunE;
|
|
180
|
+
|
|
181
|
+
// constants for atmospheric scattering
|
|
182
|
+
const float e = 2.71828182845904523536028747135266249775724709369995957;
|
|
183
|
+
const float pi = 3.141592653589793238462643383279502884197169;
|
|
184
|
+
|
|
185
|
+
// wavelength of used primaries, according to preetham
|
|
186
|
+
const vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );
|
|
187
|
+
// this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:
|
|
188
|
+
// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))
|
|
189
|
+
const vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );
|
|
190
|
+
|
|
191
|
+
// mie stuff
|
|
192
|
+
// K coefficient for the primaries
|
|
193
|
+
const float v = 4.0;
|
|
194
|
+
const vec3 K = vec3( 0.686, 0.678, 0.666 );
|
|
195
|
+
// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K
|
|
196
|
+
const vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );
|
|
197
|
+
|
|
198
|
+
// earth shadow hack
|
|
199
|
+
// cutoffAngle = pi / 1.95;
|
|
200
|
+
const float cutoffAngle = 1.6110731556870734;
|
|
201
|
+
const float steepness = 1.5;
|
|
202
|
+
const float EE = 1000.0;
|
|
203
|
+
|
|
204
|
+
float sunIntensity( float zenithAngleCos ) {
|
|
205
|
+
zenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );
|
|
206
|
+
return EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
vec3 totalMie( float T ) {
|
|
210
|
+
float c = ( 0.2 * T ) * 10E-18;
|
|
211
|
+
return 0.434 * c * MieConst;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
void main() {
|
|
215
|
+
|
|
216
|
+
vec4 worldPosition = modelMatrix * vec4( position, 1.0 );
|
|
217
|
+
vWorldPosition = worldPosition.xyz;
|
|
218
|
+
|
|
219
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
220
|
+
gl_Position.z = gl_Position.w; // set z to camera.far
|
|
221
|
+
|
|
222
|
+
vSunDirection = normalize( sunPosition );
|
|
223
|
+
|
|
224
|
+
vSunE = sunIntensity( dot( vSunDirection, up ) );
|
|
225
|
+
|
|
226
|
+
vSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );
|
|
227
|
+
|
|
228
|
+
float rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );
|
|
229
|
+
|
|
230
|
+
// extinction (absorbtion + out scattering)
|
|
231
|
+
// rayleigh coefficients
|
|
232
|
+
vBetaR = totalRayleigh * rayleighCoefficient;
|
|
233
|
+
|
|
234
|
+
// mie coefficients
|
|
235
|
+
vBetaM = totalMie( turbidity ) * mieCoefficient;
|
|
236
|
+
|
|
237
|
+
}
|
|
238
|
+
`,fragmentShader:`
|
|
239
|
+
varying vec3 vWorldPosition;
|
|
240
|
+
varying vec3 vSunDirection;
|
|
241
|
+
varying float vSunfade;
|
|
242
|
+
varying vec3 vBetaR;
|
|
243
|
+
varying vec3 vBetaM;
|
|
244
|
+
varying float vSunE;
|
|
245
|
+
|
|
246
|
+
uniform float mieDirectionalG;
|
|
247
|
+
uniform vec3 up;
|
|
248
|
+
|
|
249
|
+
const vec3 cameraPos = vec3( 0.0, 0.0, 0.0 );
|
|
250
|
+
|
|
251
|
+
// constants for atmospheric scattering
|
|
252
|
+
const float pi = 3.141592653589793238462643383279502884197169;
|
|
253
|
+
|
|
254
|
+
const float n = 1.0003; // refractive index of air
|
|
255
|
+
const float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)
|
|
256
|
+
|
|
257
|
+
// optical length at zenith for molecules
|
|
258
|
+
const float rayleighZenithLength = 8.4E3;
|
|
259
|
+
const float mieZenithLength = 1.25E3;
|
|
260
|
+
// 66 arc seconds -> degrees, and the cosine of that
|
|
261
|
+
const float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;
|
|
262
|
+
|
|
263
|
+
// 3.0 / ( 16.0 * pi )
|
|
264
|
+
const float THREE_OVER_SIXTEENPI = 0.05968310365946075;
|
|
265
|
+
// 1.0 / ( 4.0 * pi )
|
|
266
|
+
const float ONE_OVER_FOURPI = 0.07957747154594767;
|
|
267
|
+
|
|
268
|
+
float rayleighPhase( float cosTheta ) {
|
|
269
|
+
return THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
float hgPhase( float cosTheta, float g ) {
|
|
273
|
+
float g2 = pow( g, 2.0 );
|
|
274
|
+
float inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );
|
|
275
|
+
return ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
void main() {
|
|
279
|
+
|
|
280
|
+
vec3 direction = normalize( vWorldPosition - cameraPos );
|
|
281
|
+
|
|
282
|
+
// optical length
|
|
283
|
+
// cutoff angle at 90 to avoid singularity in next formula.
|
|
284
|
+
float zenithAngle = acos( max( 0.0, dot( up, direction ) ) );
|
|
285
|
+
float inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );
|
|
286
|
+
float sR = rayleighZenithLength * inverse;
|
|
287
|
+
float sM = mieZenithLength * inverse;
|
|
288
|
+
|
|
289
|
+
// combined extinction factor
|
|
290
|
+
vec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );
|
|
291
|
+
|
|
292
|
+
// in scattering
|
|
293
|
+
float cosTheta = dot( direction, vSunDirection );
|
|
294
|
+
|
|
295
|
+
float rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );
|
|
296
|
+
vec3 betaRTheta = vBetaR * rPhase;
|
|
297
|
+
|
|
298
|
+
float mPhase = hgPhase( cosTheta, mieDirectionalG );
|
|
299
|
+
vec3 betaMTheta = vBetaM * mPhase;
|
|
300
|
+
|
|
301
|
+
vec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );
|
|
302
|
+
Lin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );
|
|
303
|
+
|
|
304
|
+
// nightsky
|
|
305
|
+
float theta = acos( direction.y ); // elevation --> y-axis, [-pi/2, pi/2]
|
|
306
|
+
float phi = atan( direction.z, direction.x ); // azimuth --> x-axis [-pi/2, pi/2]
|
|
307
|
+
vec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );
|
|
308
|
+
vec3 L0 = vec3( 0.1 ) * Fex;
|
|
309
|
+
|
|
310
|
+
// composition + solar disc
|
|
311
|
+
float sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );
|
|
312
|
+
L0 += ( vSunE * 19000.0 * Fex ) * sundisk;
|
|
313
|
+
|
|
314
|
+
vec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );
|
|
315
|
+
|
|
316
|
+
vec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );
|
|
317
|
+
|
|
318
|
+
gl_FragColor = vec4( retColor, 1.0 );
|
|
319
|
+
|
|
320
|
+
#include <tonemapping_fragment>
|
|
321
|
+
#include <${xn>=154?"colorspace_fragment":"encodings_fragment"}>
|
|
322
|
+
|
|
323
|
+
}
|
|
324
|
+
`},ms=new l.ShaderMaterial({name:"SkyShader",fragmentShader:Mn.fragmentShader,vertexShader:Mn.vertexShader,uniforms:l.UniformsUtils.clone(Mn.uniforms),side:l.BackSide,depthWrite:!1});class sr extends l.Mesh{constructor(){super(new l.BoxGeometry(1,1,1),ms)}}ps(sr,"SkyShader",Mn),ps(sr,"material",ms);const Ue=new l.Triangle,Sn=new l.Vector3;class Ho{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)),Ue.a.fromBufferAttribute(e,s),Ue.b.fromBufferAttribute(e,s+1),Ue.c.fromBufferAttribute(e,s+2),i*=Ue.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),Ue.a.fromBufferAttribute(this.positionAttribute,e*3),Ue.b.fromBufferAttribute(this.positionAttribute,e*3+1),Ue.c.fromBufferAttribute(this.positionAttribute,e*3+2),t.set(0,0,0).addScaledVector(Ue.a,s).addScaledVector(Ue.b,i).addScaledVector(Ue.c,1-(s+i)),n!==void 0&&Ue.getNormal(n),r!==void 0&&this.colorAttribute!==void 0&&(Ue.a.fromBufferAttribute(this.colorAttribute,e*3),Ue.b.fromBufferAttribute(this.colorAttribute,e*3+1),Ue.c.fromBufferAttribute(this.colorAttribute,e*3+2),Sn.set(0,0,0).addScaledVector(Ue.a,s).addScaledVector(Ue.b,i).addScaledVector(Ue.c,1-(s+i)),r.r=Sn.x,r.g=Sn.y,r.b=Sn.z),this}}var $o=Object.defineProperty,ea=(o,e,t)=>e in o?$o(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,Q=(o,e,t)=>(ea(o,typeof e!="symbol"?e+"":e,t),t);class ta extends l.Object3D{constructor(e,t){super(),Q(this,"isTransformControls",!0),Q(this,"visible",!1),Q(this,"domElement"),Q(this,"raycaster",new l.Raycaster),Q(this,"gizmo"),Q(this,"plane"),Q(this,"tempVector",new l.Vector3),Q(this,"tempVector2",new l.Vector3),Q(this,"tempQuaternion",new l.Quaternion),Q(this,"unit",{X:new l.Vector3(1,0,0),Y:new l.Vector3(0,1,0),Z:new l.Vector3(0,0,1)}),Q(this,"pointStart",new l.Vector3),Q(this,"pointEnd",new l.Vector3),Q(this,"offset",new l.Vector3),Q(this,"rotationAxis",new l.Vector3),Q(this,"startNorm",new l.Vector3),Q(this,"endNorm",new l.Vector3),Q(this,"rotationAngle",0),Q(this,"cameraPosition",new l.Vector3),Q(this,"cameraQuaternion",new l.Quaternion),Q(this,"cameraScale",new l.Vector3),Q(this,"parentPosition",new l.Vector3),Q(this,"parentQuaternion",new l.Quaternion),Q(this,"parentQuaternionInv",new l.Quaternion),Q(this,"parentScale",new l.Vector3),Q(this,"worldPositionStart",new l.Vector3),Q(this,"worldQuaternionStart",new l.Quaternion),Q(this,"worldScaleStart",new l.Vector3),Q(this,"worldPosition",new l.Vector3),Q(this,"worldQuaternion",new l.Quaternion),Q(this,"worldQuaternionInv",new l.Quaternion),Q(this,"worldScale",new l.Vector3),Q(this,"eye",new l.Vector3),Q(this,"positionStart",new l.Vector3),Q(this,"quaternionStart",new l.Quaternion),Q(this,"scaleStart",new l.Vector3),Q(this,"camera"),Q(this,"object"),Q(this,"enabled",!0),Q(this,"axis",null),Q(this,"mode","translate"),Q(this,"translationSnap",null),Q(this,"rotationSnap",null),Q(this,"scaleSnap",null),Q(this,"space","world"),Q(this,"size",1),Q(this,"dragging",!1),Q(this,"showX",!0),Q(this,"showY",!0),Q(this,"showZ",!0),Q(this,"changeEvent",{type:"change"}),Q(this,"mouseDownEvent",{type:"mouseDown",mode:this.mode}),Q(this,"mouseUpEvent",{type:"mouseUp",mode:this.mode}),Q(this,"objectChangeEvent",{type:"objectChange"}),Q(this,"intersectObjectWithRay",(r,s,i)=>{const a=s.intersectObject(r,!0);for(let c=0;c<a.length;c++)if(a[c].object.visible||i)return a[c];return!1}),Q(this,"attach",r=>(this.object=r,this.visible=!0,this)),Q(this,"detach",()=>(this.object=void 0,this.visible=!1,this.axis=null,this)),Q(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),Q(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()}),Q(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}),Q(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)}}),Q(this,"pointerMove",r=>{const s=this.axis,i=this.mode,a=this.object;let c=this.space;if(i==="scale"?c="local":(s==="E"||s==="XYZE"||s==="XYZ")&&(c="world"),a===void 0||s===null||this.dragging===!1||r.button!==-1)return;this.raycaster.setFromCamera(r,this.camera);const h=this.intersectObjectWithRay(this.plane,this.raycaster,!0);if(h){if(this.pointEnd.copy(h.point).sub(this.worldPositionStart),i==="translate")this.offset.copy(this.pointEnd).sub(this.pointStart),c==="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),c==="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&&(c==="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)),c==="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 d=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(d*=-1),this.tempVector2.set(d,d,d)}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 d=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))*d):(s==="X"||s==="Y"||s==="Z")&&(this.rotationAxis.copy(this.unit[s]),this.tempVector.copy(this.unit[s]),c==="local"&&this.tempVector.applyQuaternion(this.worldQuaternion),this.rotationAngle=this.offset.dot(this.tempVector.cross(this.eye).normalize())*d),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),c==="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)}}),Q(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)}),Q(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}}}),Q(this,"onPointerHover",r=>{if(this.enabled)switch(r.pointerType){case"mouse":case"pen":this.pointerHover(this.getPointer(r));break}}),Q(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)))}),Q(this,"onPointerMove",r=>{this.enabled&&this.pointerMove(this.getPointer(r))}),Q(this,"onPointerUp",r=>{!this.enabled||!this.domElement||(this.domElement.style.touchAction="",this.domElement.ownerDocument.removeEventListener("pointermove",this.onPointerMove),this.pointerUp(this.getPointer(r)))}),Q(this,"getMode",()=>this.mode),Q(this,"setMode",r=>{this.mode=r}),Q(this,"setTranslationSnap",r=>{this.translationSnap=r}),Q(this,"setRotationSnap",r=>{this.rotationSnap=r}),Q(this,"setScaleSnap",r=>{this.scaleSnap=r}),Q(this,"setSize",r=>{this.size=r}),Q(this,"setSpace",r=>{this.space=r}),Q(this,"update",()=>{console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}),Q(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)}),Q(this,"dispose",()=>{var r,s,i,a,c,h;(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),(h=(c=this.domElement)==null?void 0:c.ownerDocument)==null||h.removeEventListener("pointerup",this.onPointerUp),this.traverse(d=>{const f=d;f.geometry&&f.geometry.dispose(),f.material&&f.material.dispose()})}),this.domElement=t,this.camera=e,this.gizmo=new na,this.add(this.gizmo),this.plane=new ra,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 na extends l.Object3D{constructor(){super(),Q(this,"isTransformControlsGizmo",!0),Q(this,"type","TransformControlsGizmo"),Q(this,"tempVector",new l.Vector3(0,0,0)),Q(this,"tempEuler",new l.Euler),Q(this,"alignVector",new l.Vector3(0,1,0)),Q(this,"zeroVector",new l.Vector3(0,0,0)),Q(this,"lookAtMatrix",new l.Matrix4),Q(this,"tempQuaternion",new l.Quaternion),Q(this,"tempQuaternion2",new l.Quaternion),Q(this,"identityQuaternion",new l.Quaternion),Q(this,"unitX",new l.Vector3(1,0,0)),Q(this,"unitY",new l.Vector3(0,1,0)),Q(this,"unitZ",new l.Vector3(0,0,1)),Q(this,"gizmo"),Q(this,"picker"),Q(this,"helper"),Q(this,"rotationAxis",new l.Vector3),Q(this,"cameraPosition",new l.Vector3),Q(this,"worldPositionStart",new l.Vector3),Q(this,"worldQuaternionStart",new l.Quaternion),Q(this,"worldPosition",new l.Vector3),Q(this,"worldQuaternion",new l.Quaternion),Q(this,"eye",new l.Vector3),Q(this,"camera",null),Q(this,"enabled",!0),Q(this,"axis",null),Q(this,"mode","translate"),Q(this,"space","world"),Q(this,"size",1),Q(this,"dragging",!1),Q(this,"showX",!0),Q(this,"showY",!0),Q(this,"showZ",!0),Q(this,"updateMatrixWorld",()=>{let ee=this.space;this.mode==="scale"&&(ee="local");const ce=ee==="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 le=[];le=le.concat(this.picker[this.mode].children),le=le.concat(this.gizmo[this.mode].children),le=le.concat(this.helper[this.mode].children);for(let me=0;me<le.length;me++){const k=le[me];k.visible=!0,k.rotation.set(0,0,0),k.position.copy(this.worldPosition);let z;if(this.camera.isOrthographicCamera?z=(this.camera.top-this.camera.bottom)/this.camera.zoom:z=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),k.scale.set(1,1,1).multiplyScalar(z*this.size/7),k.tag==="helper"){k.visible=!1,k.name==="AXIS"?(k.position.copy(this.worldPositionStart),k.visible=!!this.axis,this.axis==="X"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,0)),k.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))>.9&&(k.visible=!1)),this.axis==="Y"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,0,Math.PI/2)),k.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))>.9&&(k.visible=!1)),this.axis==="Z"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),k.quaternion.copy(ce).multiply(this.tempQuaternion),Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))>.9&&(k.visible=!1)),this.axis==="XYZE"&&(this.tempQuaternion.setFromEuler(this.tempEuler.set(0,Math.PI/2,0)),this.alignVector.copy(this.rotationAxis),k.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.zeroVector,this.alignVector,this.unitY)),k.quaternion.multiply(this.tempQuaternion),k.visible=this.dragging),this.axis==="E"&&(k.visible=!1)):k.name==="START"?(k.position.copy(this.worldPositionStart),k.visible=this.dragging):k.name==="END"?(k.position.copy(this.worldPosition),k.visible=this.dragging):k.name==="DELTA"?(k.position.copy(this.worldPositionStart),k.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()),k.scale.copy(this.tempVector),k.visible=this.dragging):(k.quaternion.copy(ce),this.dragging?k.position.copy(this.worldPositionStart):k.position.copy(this.worldPosition),this.axis&&(k.visible=this.axis.search(k.name)!==-1));continue}k.quaternion.copy(ce),this.mode==="translate"||this.mode==="scale"?((k.name==="X"||k.name==="XYZX")&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))>.99&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),(k.name==="Y"||k.name==="XYZY")&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))>.99&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),(k.name==="Z"||k.name==="XYZZ")&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))>.99&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),k.name==="XY"&&Math.abs(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye))<.2&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),k.name==="YZ"&&Math.abs(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye))<.2&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),k.name==="XZ"&&Math.abs(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye))<.2&&(k.scale.set(1e-10,1e-10,1e-10),k.visible=!1),k.name.search("X")!==-1&&(this.alignVector.copy(this.unitX).applyQuaternion(ce).dot(this.eye)<0?k.tag==="fwd"?k.visible=!1:k.scale.x*=-1:k.tag==="bwd"&&(k.visible=!1)),k.name.search("Y")!==-1&&(this.alignVector.copy(this.unitY).applyQuaternion(ce).dot(this.eye)<0?k.tag==="fwd"?k.visible=!1:k.scale.y*=-1:k.tag==="bwd"&&(k.visible=!1)),k.name.search("Z")!==-1&&(this.alignVector.copy(this.unitZ).applyQuaternion(ce).dot(this.eye)<0?k.tag==="fwd"?k.visible=!1:k.scale.z*=-1:k.tag==="bwd"&&(k.visible=!1))):this.mode==="rotate"&&(this.tempQuaternion2.copy(ce),this.alignVector.copy(this.eye).applyQuaternion(this.tempQuaternion.copy(ce).invert()),k.name.search("E")!==-1&&k.quaternion.setFromRotationMatrix(this.lookAtMatrix.lookAt(this.eye,this.zeroVector,this.unitY)),k.name==="X"&&(this.tempQuaternion.setFromAxisAngle(this.unitX,Math.atan2(-this.alignVector.y,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),k.quaternion.copy(this.tempQuaternion)),k.name==="Y"&&(this.tempQuaternion.setFromAxisAngle(this.unitY,Math.atan2(this.alignVector.x,this.alignVector.z)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),k.quaternion.copy(this.tempQuaternion)),k.name==="Z"&&(this.tempQuaternion.setFromAxisAngle(this.unitZ,Math.atan2(this.alignVector.y,this.alignVector.x)),this.tempQuaternion.multiplyQuaternions(this.tempQuaternion2,this.tempQuaternion),k.quaternion.copy(this.tempQuaternion))),k.visible=k.visible&&(k.name.indexOf("X")===-1||this.showX),k.visible=k.visible&&(k.name.indexOf("Y")===-1||this.showY),k.visible=k.visible&&(k.name.indexOf("Z")===-1||this.showZ),k.visible=k.visible&&(k.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),k.material.tempOpacity=k.material.tempOpacity||k.material.opacity,k.material.tempColor=k.material.tempColor||k.material.color.clone(),k.material.color.copy(k.material.tempColor),k.material.opacity=k.material.tempOpacity,this.enabled?this.axis&&(k.name===this.axis?(k.material.opacity=1,k.material.color.lerp(new l.Color(1,1,1),.5)):this.axis.split("").some(function(F){return k.name===F})?(k.material.opacity=1,k.material.color.lerp(new l.Color(1,1,1),.5)):(k.material.opacity*=.25,k.material.color.lerp(new l.Color(1,1,1),.5))):(k.material.opacity*=.5,k.material.color.lerp(new l.Color(1,1,1),.5))}super.updateMatrixWorld()});const e=new l.MeshBasicMaterial({depthTest:!1,depthWrite:!1,transparent:!0,side:l.DoubleSide,fog:!1,toneMapped:!1}),t=new l.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 c=e.clone();c.opacity=.25;const h=c.clone();h.color.set(16776960);const d=c.clone();d.color.set(65535);const f=c.clone();f.color.set(16711935),e.clone().color.set(16776960);const m=t.clone();m.color.set(16711680);const _=t.clone();_.color.set(65280);const v=t.clone();v.color.set(255);const y=t.clone();y.color.set(65535);const g=t.clone();g.color.set(16711935);const M=t.clone();M.color.set(16776960);const b=t.clone();b.color.set(7895160);const S=M.clone();S.opacity=.25;const O=new l.CylinderGeometry(0,.05,.2,12,1,!1),T=new l.BoxGeometry(.125,.125,.125),C=new l.BufferGeometry;C.setAttribute("position",new l.Float32BufferAttribute([0,0,0,1,0,0],3));const w=(ee,ce)=>{const le=new l.BufferGeometry,me=[];for(let k=0;k<=64*ce;++k)me.push(0,Math.cos(k/32*Math.PI)*ee,Math.sin(k/32*Math.PI)*ee);return le.setAttribute("position",new l.Float32BufferAttribute(me,3)),le},A=()=>{const ee=new l.BufferGeometry;return ee.setAttribute("position",new l.Float32BufferAttribute([0,0,0,1,1,1],3)),ee},x={X:[[new l.Mesh(O,s),[1,0,0],[0,0,-Math.PI/2],null,"fwd"],[new l.Mesh(O,s),[1,0,0],[0,0,Math.PI/2],null,"bwd"],[new l.Line(C,m)]],Y:[[new l.Mesh(O,i),[0,1,0],null,null,"fwd"],[new l.Mesh(O,i),[0,1,0],[Math.PI,0,0],null,"bwd"],[new l.Line(C,_),null,[0,0,Math.PI/2]]],Z:[[new l.Mesh(O,a),[0,0,1],[Math.PI/2,0,0],null,"fwd"],[new l.Mesh(O,a),[0,0,1],[-Math.PI/2,0,0],null,"bwd"],[new l.Line(C,v),null,[0,-Math.PI/2,0]]],XYZ:[[new l.Mesh(new l.OctahedronGeometry(.1,0),c.clone()),[0,0,0],[0,0,0]]],XY:[[new l.Mesh(new l.PlaneGeometry(.295,.295),h.clone()),[.15,.15,0]],[new l.Line(C,M),[.18,.3,0],null,[.125,1,1]],[new l.Line(C,M),[.3,.18,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new l.Mesh(new l.PlaneGeometry(.295,.295),d.clone()),[0,.15,.15],[0,Math.PI/2,0]],[new l.Line(C,y),[0,.18,.3],[0,0,Math.PI/2],[.125,1,1]],[new l.Line(C,y),[0,.3,.18],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new l.Mesh(new l.PlaneGeometry(.295,.295),f.clone()),[.15,0,.15],[-Math.PI/2,0,0]],[new l.Line(C,g),[.18,0,.3],null,[.125,1,1]],[new l.Line(C,g),[.3,0,.18],[0,-Math.PI/2,0],[.125,1,1]]]},D={X:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[.6,0,0],[0,0,-Math.PI/2]]],Y:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[0,.6,0]]],Z:[[new l.Mesh(new l.CylinderGeometry(.2,0,1,4,1,!1),n),[0,0,.6],[Math.PI/2,0,0]]],XYZ:[[new l.Mesh(new l.OctahedronGeometry(.2,0),n)]],XY:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[.2,.2,0]]],YZ:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[0,.2,.2],[0,Math.PI/2,0]]],XZ:[[new l.Mesh(new l.PlaneGeometry(.4,.4),n),[.2,0,.2],[-Math.PI/2,0,0]]]},L={START:[[new l.Mesh(new l.OctahedronGeometry(.01,2),r),null,null,null,"helper"]],END:[[new l.Mesh(new l.OctahedronGeometry(.01,2),r),null,null,null,"helper"]],DELTA:[[new l.Line(A(),r),null,null,null,"helper"]],X:[[new l.Line(C,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new l.Line(C,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new l.Line(C,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},V={X:[[new l.Line(w(1,.5),m)],[new l.Mesh(new l.OctahedronGeometry(.04,0),s),[0,0,.99],null,[1,3,1]]],Y:[[new l.Line(w(1,.5),_),null,[0,0,-Math.PI/2]],[new l.Mesh(new l.OctahedronGeometry(.04,0),i),[0,0,.99],null,[3,1,1]]],Z:[[new l.Line(w(1,.5),v),null,[0,Math.PI/2,0]],[new l.Mesh(new l.OctahedronGeometry(.04,0),a),[.99,0,0],null,[1,3,1]]],E:[[new l.Line(w(1.25,1),S),null,[0,Math.PI/2,0]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),S),[1.17,0,0],[0,0,-Math.PI/2],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),S),[-1.17,0,0],[0,0,Math.PI/2],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),S),[0,-1.17,0],[Math.PI,0,0],[1,1,.001]],[new l.Mesh(new l.CylinderGeometry(.03,0,.15,4,1,!1),S),[0,1.17,0],[0,0,0],[1,1,.001]]],XYZE:[[new l.Line(w(1,1),b),null,[0,Math.PI/2,0]]]},R={AXIS:[[new l.Line(C,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},X={X:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new l.Mesh(new l.TorusGeometry(1,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new l.Mesh(new l.TorusGeometry(1.25,.1,2,24),n)]],XYZE:[[new l.Mesh(new l.SphereGeometry(.7,10,8),n)]]},Y={X:[[new l.Mesh(T,s),[.8,0,0],[0,0,-Math.PI/2]],[new l.Line(C,m),null,null,[.8,1,1]]],Y:[[new l.Mesh(T,i),[0,.8,0]],[new l.Line(C,_),null,[0,0,Math.PI/2],[.8,1,1]]],Z:[[new l.Mesh(T,a),[0,0,.8],[Math.PI/2,0,0]],[new l.Line(C,v),null,[0,-Math.PI/2,0],[.8,1,1]]],XY:[[new l.Mesh(T,h),[.85,.85,0],null,[2,2,.2]],[new l.Line(C,M),[.855,.98,0],null,[.125,1,1]],[new l.Line(C,M),[.98,.855,0],[0,0,Math.PI/2],[.125,1,1]]],YZ:[[new l.Mesh(T,d),[0,.85,.85],null,[.2,2,2]],[new l.Line(C,y),[0,.855,.98],[0,0,Math.PI/2],[.125,1,1]],[new l.Line(C,y),[0,.98,.855],[0,-Math.PI/2,0],[.125,1,1]]],XZ:[[new l.Mesh(T,f),[.85,0,.85],null,[2,.2,2]],[new l.Line(C,g),[.855,0,.98],null,[.125,1,1]],[new l.Line(C,g),[.98,0,.855],[0,-Math.PI/2,0],[.125,1,1]]],XYZX:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),c.clone()),[1.1,0,0]]],XYZY:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),c.clone()),[0,1.1,0]]],XYZZ:[[new l.Mesh(new l.BoxGeometry(.125,.125,.125),c.clone()),[0,0,1.1]]]},J={X:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[.5,0,0],[0,0,-Math.PI/2]]],Y:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,.5,0]]],Z:[[new l.Mesh(new l.CylinderGeometry(.2,0,.8,4,1,!1),n),[0,0,.5],[Math.PI/2,0,0]]],XY:[[new l.Mesh(T,n),[.85,.85,0],null,[3,3,.2]]],YZ:[[new l.Mesh(T,n),[0,.85,.85],null,[.2,3,3]]],XZ:[[new l.Mesh(T,n),[.85,0,.85],null,[3,.2,3]]],XYZX:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[1.1,0,0]]],XYZY:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[0,1.1,0]]],XYZZ:[[new l.Mesh(new l.BoxGeometry(.2,.2,.2),n),[0,0,1.1]]]},q={X:[[new l.Line(C,r.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new l.Line(C,r.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new l.Line(C,r.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},re=ee=>{const ce=new l.Object3D;for(let le in ee)for(let me=ee[le].length;me--;){const k=ee[le][me][0].clone(),z=ee[le][me][1],F=ee[le][me][2],B=ee[le][me][3],G=ee[le][me][4];k.name=le,k.tag=G,z&&k.position.set(z[0],z[1],z[2]),F&&k.rotation.set(F[0],F[1],F[2]),B&&k.scale.set(B[0],B[1],B[2]),k.updateMatrix();const P=k.geometry.clone();P.applyMatrix4(k.matrix),k.geometry=P,k.renderOrder=1/0,k.position.set(0,0,0),k.rotation.set(0,0,0),k.scale.set(1,1,1),ce.add(k)}return ce};this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=re(x)),this.add(this.gizmo.rotate=re(V)),this.add(this.gizmo.scale=re(Y)),this.add(this.picker.translate=re(D)),this.add(this.picker.rotate=re(X)),this.add(this.picker.scale=re(J)),this.add(this.helper.translate=re(L)),this.add(this.helper.rotate=re(R)),this.add(this.helper.scale=re(q)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}}class ra extends l.Mesh{constructor(){super(new l.PlaneGeometry(1e5,1e5,2,2),new l.MeshBasicMaterial({visible:!1,wireframe:!0,side:l.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),Q(this,"isTransformControlsPlane",!0),Q(this,"type","TransformControlsPlane"),Q(this,"unitX",new l.Vector3(1,0,0)),Q(this,"unitY",new l.Vector3(0,1,0)),Q(this,"unitZ",new l.Vector3(0,0,1)),Q(this,"tempVector",new l.Vector3),Q(this,"dirVector",new l.Vector3),Q(this,"alignVector",new l.Vector3),Q(this,"tempMatrix",new l.Matrix4),Q(this,"identityQuaternion",new l.Quaternion),Q(this,"cameraQuaternion",new l.Quaternion),Q(this,"worldPosition",new l.Vector3),Q(this,"worldQuaternion",new l.Quaternion),Q(this,"eye",new l.Vector3),Q(this,"axis",null),Q(this,"mode","translate"),Q(this,"space","world"),Q(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 sa=Object.defineProperty,ia=(o,e,t)=>e in o?sa(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,Be=(o,e,t)=>(ia(o,typeof e!="symbol"?e+"":e,t),t);const zt=new l.Euler(0,0,0,"YXZ"),Vt=new l.Vector3,oa={type:"change"},aa={type:"lock"},la={type:"unlock"},gs=Math.PI/2;class ys extends l.EventDispatcher{constructor(e,t){super(),Be(this,"camera"),Be(this,"domElement"),Be(this,"isLocked"),Be(this,"minPolarAngle"),Be(this,"maxPolarAngle"),Be(this,"pointerSpeed"),Be(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;zt.setFromQuaternion(this.camera.quaternion),zt.y-=r*.002*this.pointerSpeed,zt.x-=s*.002*this.pointerSpeed,zt.x=Math.max(gs-this.maxPolarAngle,Math.min(gs-this.minPolarAngle,zt.x)),this.camera.quaternion.setFromEuler(zt),this.dispatchEvent(oa)}),Be(this,"onPointerlockChange",()=>{this.domElement&&(this.domElement.ownerDocument.pointerLockElement===this.domElement?(this.dispatchEvent(aa),this.isLocked=!0):(this.dispatchEvent(la),this.isLocked=!1))}),Be(this,"onPointerlockError",()=>{console.error("THREE.PointerLockControls: Unable to use Pointer Lock API")}),Be(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))}),Be(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))}),Be(this,"dispose",()=>{this.disconnect()}),Be(this,"getObject",()=>this.camera),Be(this,"direction",new l.Vector3(0,0,-1)),Be(this,"getDirection",n=>n.copy(this.direction).applyQuaternion(this.camera.quaternion)),Be(this,"moveForward",n=>{Vt.setFromMatrixColumn(this.camera.matrix,0),Vt.crossVectors(this.camera.up,Vt),this.camera.position.addScaledVector(Vt,n)}),Be(this,"moveRight",n=>{Vt.setFromMatrixColumn(this.camera.matrix,0),this.camera.position.addScaledVector(Vt,n)}),Be(this,"lock",()=>{this.domElement&&this.domElement.requestPointerLock()}),Be(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 ca=Object.defineProperty,ua=(o,e,t)=>e in o?ca(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,fe=(o,e,t)=>(ua(o,typeof e!="symbol"?e+"":e,t),t);const An=new l.Ray,_s=new l.Plane,ha=Math.cos(70*(Math.PI/180)),vs=(o,e)=>(o%e+e)%e;class xs extends l.EventDispatcher{constructor(e,t){super(),fe(this,"object"),fe(this,"domElement"),fe(this,"enabled",!0),fe(this,"target",new l.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:l.MOUSE.ROTATE,MIDDLE:l.MOUSE.DOLLY,RIGHT:l.MOUSE.PAN}),fe(this,"touches",{ONE:l.TOUCH.ROTATE,TWO:l.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=()=>d.phi,this.getAzimuthalAngle=()=>d.theta,this.setPolarAngle=K=>{let oe=vs(K,2*Math.PI),ge=d.phi;ge<0&&(ge+=2*Math.PI),oe<0&&(oe+=2*Math.PI);let Me=Math.abs(oe-ge);2*Math.PI-Me<Me&&(oe<ge?oe+=2*Math.PI:ge+=2*Math.PI),f.phi=oe-ge,n.update()},this.setAzimuthalAngle=K=>{let oe=vs(K,2*Math.PI),ge=d.theta;ge<0&&(ge+=2*Math.PI),oe<0&&(oe+=2*Math.PI);let Me=Math.abs(oe-ge);2*Math.PI-Me<Me&&(oe<ge?oe+=2*Math.PI:ge+=2*Math.PI),f.theta=oe-ge,n.update()},this.getDistance=()=>n.object.position.distanceTo(n.target),this.listenToKeyEvents=K=>{K.addEventListener("keydown",Tt),this._domElementKeyEvents=K},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",Tt),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(),c=a.NONE},this.update=(()=>{const K=new l.Vector3,oe=new l.Vector3(0,1,0),ge=new l.Quaternion().setFromUnitVectors(e.up,oe),Me=ge.clone().invert(),Fe=new l.Vector3,pt=new l.Quaternion,It=2*Math.PI;return function(){const oo=n.object.position;ge.setFromUnitVectors(e.up,oe),Me.copy(ge).invert(),K.copy(oo).sub(n.target),K.applyQuaternion(ge),d.setFromVector3(K),n.autoRotate&&c===a.NONE&&R(L()),n.enableDamping?(d.theta+=f.theta*n.dampingFactor,d.phi+=f.phi*n.dampingFactor):(d.theta+=f.theta,d.phi+=f.phi);let mt=n.minAzimuthAngle,gt=n.maxAzimuthAngle;isFinite(mt)&&isFinite(gt)&&(mt<-Math.PI?mt+=It:mt>Math.PI&&(mt-=It),gt<-Math.PI?gt+=It:gt>Math.PI&&(gt-=It),mt<=gt?d.theta=Math.max(mt,Math.min(gt,d.theta)):d.theta=d.theta>(mt+gt)/2?Math.max(mt,d.theta):Math.min(gt,d.theta)),d.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,d.phi)),d.makeSafe(),n.enableDamping===!0?n.target.addScaledVector(m,n.dampingFactor):n.target.add(m),n.zoomToCursor&&A||n.object.isOrthographicCamera?d.radius=le(d.radius):d.radius=le(d.radius*p),K.setFromSpherical(d),K.applyQuaternion(Me),oo.copy(n.target).add(K),n.object.matrixAutoUpdate||n.object.updateMatrix(),n.object.lookAt(n.target),n.enableDamping===!0?(f.theta*=1-n.dampingFactor,f.phi*=1-n.dampingFactor,m.multiplyScalar(1-n.dampingFactor)):(f.set(0,0,0),m.set(0,0,0));let yn=!1;if(n.zoomToCursor&&A){let _n=null;if(n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera){const vn=K.length();_n=le(vn*p);const Zn=vn-_n;n.object.position.addScaledVector(C,Zn),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){const vn=new l.Vector3(w.x,w.y,0);vn.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/p)),n.object.updateProjectionMatrix(),yn=!0;const Zn=new l.Vector3(w.x,w.y,0);Zn.unproject(n.object),n.object.position.sub(Zn).add(vn),n.object.updateMatrixWorld(),_n=K.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),n.zoomToCursor=!1;_n!==null&&(n.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(_n).add(n.object.position):(An.origin.copy(n.object.position),An.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(An.direction))<ha?e.lookAt(n.target):(_s.setFromNormalAndCoplanarPoint(n.object.up,n.target),An.intersectPlane(_s,n.target))))}else n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera&&(yn=p!==1,yn&&(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/p)),n.object.updateProjectionMatrix()));return p=1,A=!1,yn||Fe.distanceToSquared(n.object.position)>h||8*(1-pt.dot(n.object.quaternion))>h?(n.dispatchEvent(r),Fe.copy(n.object.position),pt.copy(n.object.quaternion),yn=!1,!0):!1}})(),this.connect=K=>{K===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),n.domElement=K,n.domElement.style.touchAction="none",n.domElement.addEventListener("contextmenu",Ut),n.domElement.addEventListener("pointerdown",he),n.domElement.addEventListener("pointercancel",Oe),n.domElement.addEventListener("wheel",dt)},this.dispose=()=>{var K,oe,ge,Me,Fe,pt;n.domElement&&(n.domElement.style.touchAction="auto"),(K=n.domElement)==null||K.removeEventListener("contextmenu",Ut),(oe=n.domElement)==null||oe.removeEventListener("pointerdown",he),(ge=n.domElement)==null||ge.removeEventListener("pointercancel",Oe),(Me=n.domElement)==null||Me.removeEventListener("wheel",dt),(Fe=n.domElement)==null||Fe.ownerDocument.removeEventListener("pointermove",_e),(pt=n.domElement)==null||pt.ownerDocument.removeEventListener("pointerup",Oe),n._domElementKeyEvents!==null&&n._domElementKeyEvents.removeEventListener("keydown",Tt)};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 c=a.NONE;const h=1e-6,d=new l.Spherical,f=new l.Spherical;let p=1;const m=new l.Vector3,_=new l.Vector2,v=new l.Vector2,y=new l.Vector2,g=new l.Vector2,M=new l.Vector2,b=new l.Vector2,S=new l.Vector2,O=new l.Vector2,T=new l.Vector2,C=new l.Vector3,w=new l.Vector2;let A=!1;const x=[],D={};function L(){return 2*Math.PI/60/60*n.autoRotateSpeed}function V(){return Math.pow(.95,n.zoomSpeed)}function R(K){n.reverseOrbit||n.reverseHorizontalOrbit?f.theta+=K:f.theta-=K}function X(K){n.reverseOrbit||n.reverseVerticalOrbit?f.phi+=K:f.phi-=K}const Y=(()=>{const K=new l.Vector3;return function(ge,Me){K.setFromMatrixColumn(Me,0),K.multiplyScalar(-ge),m.add(K)}})(),J=(()=>{const K=new l.Vector3;return function(ge,Me){n.screenSpacePanning===!0?K.setFromMatrixColumn(Me,1):(K.setFromMatrixColumn(Me,0),K.crossVectors(n.object.up,K)),K.multiplyScalar(ge),m.add(K)}})(),q=(()=>{const K=new l.Vector3;return function(ge,Me){const Fe=n.domElement;if(Fe&&n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera){const pt=n.object.position;K.copy(pt).sub(n.target);let It=K.length();It*=Math.tan(n.object.fov/2*Math.PI/180),Y(2*ge*It/Fe.clientHeight,n.object.matrix),J(2*Me*It/Fe.clientHeight,n.object.matrix)}else Fe&&n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?(Y(ge*(n.object.right-n.object.left)/n.object.zoom/Fe.clientWidth,n.object.matrix),J(Me*(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 re(K){n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera||n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?p/=K:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ee(K){n.object instanceof l.PerspectiveCamera&&n.object.isPerspectiveCamera||n.object instanceof l.OrthographicCamera&&n.object.isOrthographicCamera?p*=K:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),n.enableZoom=!1)}function ce(K){if(!n.zoomToCursor||!n.domElement)return;A=!0;const oe=n.domElement.getBoundingClientRect(),ge=K.clientX-oe.left,Me=K.clientY-oe.top,Fe=oe.width,pt=oe.height;w.x=ge/Fe*2-1,w.y=-(Me/pt)*2+1,C.set(w.x,w.y,1).unproject(n.object).sub(n.object.position).normalize()}function le(K){return Math.max(n.minDistance,Math.min(n.maxDistance,K))}function me(K){_.set(K.clientX,K.clientY)}function k(K){ce(K),S.set(K.clientX,K.clientY)}function z(K){g.set(K.clientX,K.clientY)}function F(K){v.set(K.clientX,K.clientY),y.subVectors(v,_).multiplyScalar(n.rotateSpeed);const oe=n.domElement;oe&&(R(2*Math.PI*y.x/oe.clientHeight),X(2*Math.PI*y.y/oe.clientHeight)),_.copy(v),n.update()}function B(K){O.set(K.clientX,K.clientY),T.subVectors(O,S),T.y>0?re(V()):T.y<0&&ee(V()),S.copy(O),n.update()}function G(K){M.set(K.clientX,K.clientY),b.subVectors(M,g).multiplyScalar(n.panSpeed),q(b.x,b.y),g.copy(M),n.update()}function P(K){ce(K),K.deltaY<0?ee(V()):K.deltaY>0&&re(V()),n.update()}function I(K){let oe=!1;switch(K.code){case n.keys.UP:q(0,n.keyPanSpeed),oe=!0;break;case n.keys.BOTTOM:q(0,-n.keyPanSpeed),oe=!0;break;case n.keys.LEFT:q(n.keyPanSpeed,0),oe=!0;break;case n.keys.RIGHT:q(-n.keyPanSpeed,0),oe=!0;break}oe&&(K.preventDefault(),n.update())}function U(){if(x.length==1)_.set(x[0].pageX,x[0].pageY);else{const K=.5*(x[0].pageX+x[1].pageX),oe=.5*(x[0].pageY+x[1].pageY);_.set(K,oe)}}function E(){if(x.length==1)g.set(x[0].pageX,x[0].pageY);else{const K=.5*(x[0].pageX+x[1].pageX),oe=.5*(x[0].pageY+x[1].pageY);g.set(K,oe)}}function Z(){const K=x[0].pageX-x[1].pageX,oe=x[0].pageY-x[1].pageY,ge=Math.sqrt(K*K+oe*oe);S.set(0,ge)}function j(){n.enableZoom&&Z(),n.enablePan&&E()}function $(){n.enableZoom&&Z(),n.enableRotate&&U()}function ne(K){if(x.length==1)v.set(K.pageX,K.pageY);else{const ge=gn(K),Me=.5*(K.pageX+ge.x),Fe=.5*(K.pageY+ge.y);v.set(Me,Fe)}y.subVectors(v,_).multiplyScalar(n.rotateSpeed);const oe=n.domElement;oe&&(R(2*Math.PI*y.x/oe.clientHeight),X(2*Math.PI*y.y/oe.clientHeight)),_.copy(v)}function ie(K){if(x.length==1)M.set(K.pageX,K.pageY);else{const oe=gn(K),ge=.5*(K.pageX+oe.x),Me=.5*(K.pageY+oe.y);M.set(ge,Me)}b.subVectors(M,g).multiplyScalar(n.panSpeed),q(b.x,b.y),g.copy(M)}function W(K){const oe=gn(K),ge=K.pageX-oe.x,Me=K.pageY-oe.y,Fe=Math.sqrt(ge*ge+Me*Me);O.set(0,Fe),T.set(0,Math.pow(O.y/S.y,n.zoomSpeed)),re(T.y),S.copy(O)}function N(K){n.enableZoom&&W(K),n.enablePan&&ie(K)}function ae(K){n.enableZoom&&W(K),n.enableRotate&&ne(K)}function he(K){var oe,ge;n.enabled!==!1&&(x.length===0&&((oe=n.domElement)==null||oe.ownerDocument.addEventListener("pointermove",_e),(ge=n.domElement)==null||ge.ownerDocument.addEventListener("pointerup",Oe)),Yn(K),K.pointerType==="touch"?Ze(K):De(K))}function _e(K){n.enabled!==!1&&(K.pointerType==="touch"?mn(K):$e(K))}function Oe(K){var oe,ge,Me;Wn(K),x.length===0&&((oe=n.domElement)==null||oe.releasePointerCapture(K.pointerId),(ge=n.domElement)==null||ge.ownerDocument.removeEventListener("pointermove",_e),(Me=n.domElement)==null||Me.ownerDocument.removeEventListener("pointerup",Oe)),n.dispatchEvent(i),c=a.NONE}function De(K){let oe;switch(K.button){case 0:oe=n.mouseButtons.LEFT;break;case 1:oe=n.mouseButtons.MIDDLE;break;case 2:oe=n.mouseButtons.RIGHT;break;default:oe=-1}switch(oe){case l.MOUSE.DOLLY:if(n.enableZoom===!1)return;k(K),c=a.DOLLY;break;case l.MOUSE.ROTATE:if(K.ctrlKey||K.metaKey||K.shiftKey){if(n.enablePan===!1)return;z(K),c=a.PAN}else{if(n.enableRotate===!1)return;me(K),c=a.ROTATE}break;case l.MOUSE.PAN:if(K.ctrlKey||K.metaKey||K.shiftKey){if(n.enableRotate===!1)return;me(K),c=a.ROTATE}else{if(n.enablePan===!1)return;z(K),c=a.PAN}break;default:c=a.NONE}c!==a.NONE&&n.dispatchEvent(s)}function $e(K){if(n.enabled!==!1)switch(c){case a.ROTATE:if(n.enableRotate===!1)return;F(K);break;case a.DOLLY:if(n.enableZoom===!1)return;B(K);break;case a.PAN:if(n.enablePan===!1)return;G(K);break}}function dt(K){n.enabled===!1||n.enableZoom===!1||c!==a.NONE&&c!==a.ROTATE||(K.preventDefault(),n.dispatchEvent(s),P(K),n.dispatchEvent(i))}function Tt(K){n.enabled===!1||n.enablePan===!1||I(K)}function Ze(K){switch(Xn(K),x.length){case 1:switch(n.touches.ONE){case l.TOUCH.ROTATE:if(n.enableRotate===!1)return;U(),c=a.TOUCH_ROTATE;break;case l.TOUCH.PAN:if(n.enablePan===!1)return;E(),c=a.TOUCH_PAN;break;default:c=a.NONE}break;case 2:switch(n.touches.TWO){case l.TOUCH.DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;j(),c=a.TOUCH_DOLLY_PAN;break;case l.TOUCH.DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;$(),c=a.TOUCH_DOLLY_ROTATE;break;default:c=a.NONE}break;default:c=a.NONE}c!==a.NONE&&n.dispatchEvent(s)}function mn(K){switch(Xn(K),c){case a.TOUCH_ROTATE:if(n.enableRotate===!1)return;ne(K),n.update();break;case a.TOUCH_PAN:if(n.enablePan===!1)return;ie(K),n.update();break;case a.TOUCH_DOLLY_PAN:if(n.enableZoom===!1&&n.enablePan===!1)return;N(K),n.update();break;case a.TOUCH_DOLLY_ROTATE:if(n.enableZoom===!1&&n.enableRotate===!1)return;ae(K),n.update();break;default:c=a.NONE}}function Ut(K){n.enabled!==!1&&K.preventDefault()}function Yn(K){x.push(K)}function Wn(K){delete D[K.pointerId];for(let oe=0;oe<x.length;oe++)if(x[oe].pointerId==K.pointerId){x.splice(oe,1);return}}function Xn(K){let oe=D[K.pointerId];oe===void 0&&(oe=new l.Vector2,D[K.pointerId]=oe),oe.set(K.pageX,K.pageY)}function gn(K){const oe=K.pointerId===x[0].pointerId?x[1]:x[0];return D[oe.pointerId]}t!==void 0&&this.connect(t),this.update()}}class fa extends xs{constructor(e,t){super(e,t),this.screenSpacePanning=!1,this.mouseButtons.LEFT=l.MOUSE.PAN,this.mouseButtons.RIGHT=l.MOUSE.ROTATE,this.touches.ONE=l.TOUCH.PAN,this.touches.TWO=l.TOUCH.DOLLY_ROTATE}}function Rt(o){if(typeof TextDecoder<"u")return new TextDecoder().decode(o);let e="";for(let t=0,n=o.length;t<n;t++)e+=String.fromCharCode(o[t]);try{return decodeURIComponent(escape(e))}catch{return e}}const Ot="srgb",ct="srgb-linear",ws=3001,da=3e3;class pa extends l.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new va(t)}),this.register(function(t){return new xa(t)}),this.register(function(t){return new Ia(t)}),this.register(function(t){return new Oa(t)}),this.register(function(t){return new Da(t)}),this.register(function(t){return new ba(t)}),this.register(function(t){return new Ma(t)}),this.register(function(t){return new Sa(t)}),this.register(function(t){return new Aa(t)}),this.register(function(t){return new _a(t)}),this.register(function(t){return new Ca(t)}),this.register(function(t){return new wa(t)}),this.register(function(t){return new Ta(t)}),this.register(function(t){return new Pa(t)}),this.register(function(t){return new ga(t)}),this.register(function(t){return new La(t)}),this.register(function(t){return new ka(t)})}load(e,t,n,r){const s=this;let i;if(this.resourcePath!=="")i=this.resourcePath;else if(this.path!==""){const h=l.LoaderUtils.extractUrlBase(e);i=l.LoaderUtils.resolveURL(h,this.path)}else i=l.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(h){r?r(h):console.error(h),s.manager.itemError(e),s.manager.itemEnd(e)},c=new l.FileLoader(this.manager);c.setPath(this.path),c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(h){try{s.parse(h,i,function(d){t(d),s.manager.itemEnd(e)},a)}catch(d){a(d)}},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(Rt(new Uint8Array(e.slice(0,4)))===bs){try{i[ve.KHR_BINARY_GLTF]=new Ba(e)}catch(d){r&&r(d);return}s=JSON.parse(i[ve.KHR_BINARY_GLTF].content)}else s=JSON.parse(Rt(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 c=new Za(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const d=this.pluginCallbacks[h](c);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[d.name]=d,i[d.name]=!0}if(s.extensionsUsed)for(let h=0;h<s.extensionsUsed.length;++h){const d=s.extensionsUsed[h],f=s.extensionsRequired||[];switch(d){case ve.KHR_MATERIALS_UNLIT:i[d]=new ya;break;case ve.KHR_DRACO_MESH_COMPRESSION:i[d]=new Fa(s,this.dracoLoader);break;case ve.KHR_TEXTURE_TRANSFORM:i[d]=new Ua;break;case ve.KHR_MESH_QUANTIZATION:i[d]=new Na;break;default:f.indexOf(d)>=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(i),c.setPlugins(a),c.parse(n,r)}parseAsync(e,t){const n=this;return new Promise(function(r,s){n.parse(e,t,r,s)})}}function ma(){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 ve={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_DISPERSION:"KHR_materials_dispersion",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_MATERIALS_BUMP:"EXT_materials_bump",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 ga{constructor(e){this.parser=e,this.name=ve.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,c=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let h;const d=new l.Color(16777215);c.color!==void 0&&d.setRGB(c.color[0],c.color[1],c.color[2],ct);const f=c.range!==void 0?c.range:0;switch(c.type){case"directional":h=new l.DirectionalLight(d),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new l.PointLight(d),h.distance=f;break;case"spot":h=new l.SpotLight(d),h.distance=f,c.spot=c.spot||{},c.spot.innerConeAngle=c.spot.innerConeAngle!==void 0?c.spot.innerConeAngle:0,c.spot.outerConeAngle=c.spot.outerConeAngle!==void 0?c.spot.outerConeAngle:Math.PI/4,h.angle=c.spot.outerConeAngle,h.penumbra=1-c.spot.innerConeAngle/c.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+c.type)}return h.position.set(0,0,0),h.decay=2,ut(h,c),c.intensity!==void 0&&(h.intensity=c.intensity),h.name=t.createUniqueName(c.name||"light_"+e),r=Promise.resolve(h),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(c){return n._getNodeRef(t.cache,a,c)})}}class ya{constructor(){this.name=ve.KHR_MATERIALS_UNLIT}getMaterialType(){return l.MeshBasicMaterial}extendParams(e,t,n){const r=[];e.color=new l.Color(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const i=s.baseColorFactor;e.color.setRGB(i[0],i[1],i[2],ct),e.opacity=i[3]}s.baseColorTexture!==void 0&&r.push(n.assignTexture(e,"map",s.baseColorTexture,Ot))}return Promise.all(r)}}class _a{constructor(e){this.parser=e,this.name=ve.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 va{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.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 l.Vector2(a,a)}return Promise.all(s)}}class xa{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.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.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}}class wa{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.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 ba{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.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 l.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const i=r.extensions[this.name];if(i.sheenColorFactor!==void 0){const a=i.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],ct)}return i.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=i.sheenRoughnessFactor),i.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",i.sheenColorTexture,Ot)),i.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(s)}}class Ma{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.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 Sa{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.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 l.Color().setRGB(a[0],a[1],a[2],ct),Promise.all(s)}}class Aa{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.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 Ca{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.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 l.Color().setRGB(a[0],a[1],a[2],ct),i.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",i.specularColorTexture,Ot)),Promise.all(s)}}class Pa{constructor(e){this.parser=e,this.name=ve.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.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 t.bumpScale=i.bumpFactor!==void 0?i.bumpFactor:1,i.bumpTexture!==void 0&&s.push(n.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(s)}}class Ta{constructor(e){this.parser=e,this.name=ve.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:l.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 Ia{constructor(e){this.parser=e,this.name=ve.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 Oa{constructor(e){this.parser=e,this.name=ve.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 c=n.textureLoader;if(a.uri){const h=n.options.manager.getHandler(a.uri);h!==null&&(c=h)}return this.detectSupport().then(function(h){if(h)return n.loadTextureImage(e,i.source,c);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 Da{constructor(e){this.parser=e,this.name=ve.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 c=n.textureLoader;if(a.uri){const h=n.options.manager.getHandler(a.uri);h!==null&&(c=h)}return this.detectSupport().then(function(h){if(h)return n.loadTextureImage(e,i.source,c);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 La{constructor(e){this.name=ve.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 c=r.byteOffset||0,h=r.byteLength||0,d=r.count,f=r.byteStride,p=new Uint8Array(a,c,h);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(d,f,p,r.mode,r.filter).then(function(m){return m.buffer}):i.ready.then(function(){const m=new ArrayBuffer(d*f);return i.decodeGltfBuffer(new Uint8Array(m),d,f,p,r.mode,r.filter),m})})}else return null}}class ka{constructor(e){this.name=ve.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 h of r.primitives)if(h.mode!==Qe.TRIANGLES&&h.mode!==Qe.TRIANGLE_STRIP&&h.mode!==Qe.TRIANGLE_FAN&&h.mode!==void 0)return null;const i=n.extensions[this.name].attributes,a=[],c={};for(const h in i)a.push(this.parser.getDependency("accessor",i[h]).then(d=>(c[h]=d,c[h])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(h=>{const d=h.pop(),f=d.isGroup?d.children:[d],p=h[0].count,m=[];for(const _ of f){const v=new l.Matrix4,y=new l.Vector3,g=new l.Quaternion,M=new l.Vector3(1,1,1),b=new l.InstancedMesh(_.geometry,_.material,p);for(let S=0;S<p;S++)c.TRANSLATION&&y.fromBufferAttribute(c.TRANSLATION,S),c.ROTATION&&g.fromBufferAttribute(c.ROTATION,S),c.SCALE&&M.fromBufferAttribute(c.SCALE,S),b.setMatrixAt(S,v.compose(y,g,M));for(const S in c)if(S==="_COLOR_0"){const O=c[S];b.instanceColor=new l.InstancedBufferAttribute(O.array,O.itemSize,O.normalized)}else S!=="TRANSLATION"&&S!=="ROTATION"&&S!=="SCALE"&&_.geometry.setAttribute(S,c[S]);l.Object3D.prototype.copy.call(b,_),this.parser.assignFinalMaterial(b),m.push(b)}return d.isGroup?(d.clear(),d.add(...m),d):m[0]}))}}const bs="glTF",$t=12,Ms={JSON:1313821514,BIN:5130562};class Ba{constructor(e){this.name=ve.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,$t);if(this.header={magic:Rt(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==bs)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-$t,r=new DataView(e,$t);let s=0;for(;s<n;){const i=r.getUint32(s,!0);s+=4;const a=r.getUint32(s,!0);if(s+=4,a===Ms.JSON){const c=new Uint8Array(e,$t+s,i);this.content=Rt(c)}else if(a===Ms.BIN){const c=$t+s;this.body=e.slice(c,c+i)}s+=i}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Fa{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ve.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={},c={},h={};for(const d in i){const f=or[d]||d.toLowerCase();a[f]=i[d]}for(const d in e.attributes){const f=or[d]||d.toLowerCase();if(i[d]!==void 0){const p=n.accessors[e.attributes[d]],m=Gt[p.componentType];h[f]=m.name,c[f]=p.normalized===!0}}return t.getDependency("bufferView",s).then(function(d){return new Promise(function(f,p){r.decodeDracoFile(d,function(m){for(const _ in m.attributes){const v=m.attributes[_],y=c[_];y!==void 0&&(v.normalized=y)}f(m)},a,h,ct,p)})})}}class Ua{constructor(){this.name=ve.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 Na{constructor(){this.name=ve.KHR_MESH_QUANTIZATION}}class Ss extends l.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,c=a*2,h=a*3,d=r-t,f=(n-t)/d,p=f*f,m=p*f,_=e*h,v=_-h,y=-2*m+3*p,g=m-p,M=1-y,b=g-p+f;for(let S=0;S!==a;S++){const O=i[v+S+a],T=i[v+S+c]*d,C=i[_+S+a],w=i[_+S]*d;s[S]=M*O+b*T+y*C+g*w}return s}}const za=new l.Quaternion;class Va extends Ss{interpolate_(e,t,n,r){const s=super.interpolate_(e,t,n,r);return za.fromArray(s).normalize().toArray(s),s}}const Qe={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},Gt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},As={9728:l.NearestFilter,9729:l.LinearFilter,9984:l.NearestMipmapNearestFilter,9985:l.LinearMipmapNearestFilter,9986:l.NearestMipmapLinearFilter,9987:l.LinearMipmapLinearFilter},Cs={33071:l.ClampToEdgeWrapping,33648:l.MirroredRepeatWrapping,10497:l.RepeatWrapping},ir={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},or={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...xn>=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"},vt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Ra={CUBICSPLINE:void 0,LINEAR:l.InterpolateLinear,STEP:l.InterpolateDiscrete},ar={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Ga(o){return o.DefaultMaterial===void 0&&(o.DefaultMaterial=new l.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:l.FrontSide})),o.DefaultMaterial}function Dt(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 ut(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 ja(o,e,t){let n=!1,r=!1,s=!1;for(let h=0,d=e.length;h<d;h++){const f=e[h];if(f.POSITION!==void 0&&(n=!0),f.NORMAL!==void 0&&(r=!0),f.COLOR_0!==void 0&&(s=!0),n&&r&&s)break}if(!n&&!r&&!s)return Promise.resolve(o);const i=[],a=[],c=[];for(let h=0,d=e.length;h<d;h++){const f=e[h];if(n){const p=f.POSITION!==void 0?t.getDependency("accessor",f.POSITION):o.attributes.position;i.push(p)}if(r){const p=f.NORMAL!==void 0?t.getDependency("accessor",f.NORMAL):o.attributes.normal;a.push(p)}if(s){const p=f.COLOR_0!==void 0?t.getDependency("accessor",f.COLOR_0):o.attributes.color;c.push(p)}}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(c)]).then(function(h){const d=h[0],f=h[1],p=h[2];return n&&(o.morphAttributes.position=d),r&&(o.morphAttributes.normal=f),s&&(o.morphAttributes.color=p),o.morphTargetsRelative=!0,o})}function Ea(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 Ya(o){let e;const t=o.extensions&&o.extensions[ve.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+lr(t.attributes):e=o.indices+":"+lr(o.attributes)+":"+o.mode,o.targets!==void 0)for(let n=0,r=o.targets.length;n<r;n++)e+=":"+lr(o.targets[n]);return e}function lr(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 cr(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 Wa(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 Xa=new l.Matrix4;class Za{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new ma,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 l.TextureLoader(this.options.manager):this.textureLoader=new l.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new l.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:{}};return Dt(s,a,r),ut(a,r),Promise.all(n._invokeAll(function(c){return c.afterRoot&&c.afterRoot(a)})).then(function(){for(const c of a.scenes)c.updateMatrixWorld();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,c=i.length;a<c;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 c=this.associations.get(i);c!=null&&this.associations.set(a,c);for(const[h,d]of i.children.entries())s(d,a.children[h])};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[ve.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(s,i){n.load(l.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=ir[r.type],a=Gt[r.componentType],c=r.normalized===!0,h=new a(r.count*i);return Promise.resolve(new l.BufferAttribute(h,i,c))}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],c=ir[r.type],h=Gt[r.componentType],d=h.BYTES_PER_ELEMENT,f=d*c,p=r.byteOffset||0,m=r.bufferView!==void 0?n.bufferViews[r.bufferView].byteStride:void 0,_=r.normalized===!0;let v,y;if(m&&m!==f){const g=Math.floor(p/m),M="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+g+":"+r.count;let b=t.cache.get(M);b||(v=new h(a,g*m,r.count*m/d),b=new l.InterleavedBuffer(v,m/d),t.cache.add(M,b)),y=new l.InterleavedBufferAttribute(b,c,p%m/d,_)}else a===null?v=new h(r.count*c):v=new h(a,p,r.count*c),y=new l.BufferAttribute(v,c,_);if(r.sparse!==void 0){const g=ir.SCALAR,M=Gt[r.sparse.indices.componentType],b=r.sparse.indices.byteOffset||0,S=r.sparse.values.byteOffset||0,O=new M(i[1],b,r.sparse.count*g),T=new h(i[2],S,r.sparse.count*c);a!==null&&(y=new l.BufferAttribute(y.array.slice(),y.itemSize,y.normalized));for(let C=0,w=O.length;C<w;C++){const A=O[C];if(y.setX(A,T[C*c]),c>=2&&y.setY(A,T[C*c+1]),c>=3&&y.setZ(A,T[C*c+2]),c>=4&&y.setW(A,T[C*c+3]),c>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return y})}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 c=n.manager.getHandler(i.uri);c!==null&&(a=c)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){const r=this,s=this.json,i=s.textures[e],a=s.images[t],c=(a.uri||a.bufferView)+":"+i.sampler;if(this.textureCache[c])return this.textureCache[c];const h=this.loadImageSource(t,n).then(function(d){d.flipY=!1,d.name=i.name||a.name||"",d.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(d.name=a.uri);const p=(s.samplers||{})[i.sampler]||{};return d.magFilter=As[p.magFilter]||l.LinearFilter,d.minFilter=As[p.minFilter]||l.LinearMipmapLinearFilter,d.wrapS=Cs[p.wrapS]||l.RepeatWrapping,d.wrapT=Cs[p.wrapT]||l.RepeatWrapping,r.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[c]=h,h}loadImageSource(e,t){const n=this,r=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());const i=r.images[e],a=self.URL||self.webkitURL;let c=i.uri||"",h=!1;if(i.bufferView!==void 0)c=n.getDependency("bufferView",i.bufferView).then(function(f){h=!0;const p=new Blob([f],{type:i.mimeType});return c=a.createObjectURL(p),c});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(c).then(function(f){return new Promise(function(p,m){let _=p;t.isImageBitmapLoader===!0&&(_=function(v){const y=new l.Texture(v);y.needsUpdate=!0,p(y)}),t.load(l.LoaderUtils.resolveURL(f,s.path),_,void 0,m)})}).then(function(f){return h===!0&&a.revokeObjectURL(c),ut(f,i),f.userData.mimeType=i.mimeType||Wa(i.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",c),f});return this.sourceCache[e]=d,d}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[ve.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[ve.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const c=s.associations.get(i);i=s.extensions[ve.KHR_TEXTURE_TRANSFORM].extendTexture(i,a),s.associations.set(i,c)}}return r!==void 0&&(typeof r=="number"&&(r=r===ws?Ot:ct),"colorSpace"in i?i.colorSpace=r:i.encoding=r===Ot?ws:da),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 c=this.cache.get(a);c||(c=new l.PointsMaterial,l.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,c.sizeAttenuation=!1,this.cache.add(a,c)),n=c}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let c=this.cache.get(a);c||(c=new l.LineBasicMaterial,l.Material.prototype.copy.call(c,n),c.color.copy(n.color),c.map=n.map,this.cache.add(a,c)),n=c}if(r||s||i){let a="ClonedMaterial:"+n.uuid+":";r&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),i&&(a+="flat-shading:");let c=this.cache.get(a);c||(c=n.clone(),s&&(c.vertexColors=!0),i&&(c.flatShading=!0),r&&(c.normalScale&&(c.normalScale.y*=-1),c.clearcoatNormalScale&&(c.clearcoatNormalScale.y*=-1)),this.cache.add(a,c),this.associations.set(c,this.associations.get(n))),n=c}e.material=n}getMaterialType(){return l.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,r=this.extensions,s=n.materials[e];let i;const a={},c=s.extensions||{},h=[];if(c[ve.KHR_MATERIALS_UNLIT]){const f=r[ve.KHR_MATERIALS_UNLIT];i=f.getMaterialType(),h.push(f.extendParams(a,s,t))}else{const f=s.pbrMetallicRoughness||{};if(a.color=new l.Color(1,1,1),a.opacity=1,Array.isArray(f.baseColorFactor)){const p=f.baseColorFactor;a.color.setRGB(p[0],p[1],p[2],ct),a.opacity=p[3]}f.baseColorTexture!==void 0&&h.push(t.assignTexture(a,"map",f.baseColorTexture,Ot)),a.metalness=f.metallicFactor!==void 0?f.metallicFactor:1,a.roughness=f.roughnessFactor!==void 0?f.roughnessFactor:1,f.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(a,"metalnessMap",f.metallicRoughnessTexture)),h.push(t.assignTexture(a,"roughnessMap",f.metallicRoughnessTexture))),i=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=l.DoubleSide);const d=s.alphaMode||ar.OPAQUE;if(d===ar.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,d===ar.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&i!==l.MeshBasicMaterial&&(h.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new l.Vector2(1,1),s.normalTexture.scale!==void 0)){const f=s.normalTexture.scale;a.normalScale.set(f,f)}if(s.occlusionTexture!==void 0&&i!==l.MeshBasicMaterial&&(h.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&i!==l.MeshBasicMaterial){const f=s.emissiveFactor;a.emissive=new l.Color().setRGB(f[0],f[1],f[2],ct)}return s.emissiveTexture!==void 0&&i!==l.MeshBasicMaterial&&h.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,Ot)),Promise.all(h).then(function(){const f=new i(a);return s.name&&(f.name=s.name),ut(f,s),t.associations.set(f,{materials:e}),s.extensions&&Dt(r,f,s),f})}createUniqueName(e){const t=l.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[ve.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(c){return Ps(c,a,t)})}const i=[];for(let a=0,c=e.length;a<c;a++){const h=e[a],d=Ya(h),f=r[d];if(f)i.push(f.promise);else{let p;h.extensions&&h.extensions[ve.KHR_DRACO_MESH_COMPRESSION]?p=s(h):p=Ps(new l.BufferGeometry,h,t),r[d]={primitive:h,promise:p},i.push(p)}}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 c=0,h=i.length;c<h;c++){const d=i[c].material===void 0?Ga(this.cache):this.getDependency("material",i[c].material);a.push(d)}return a.push(t.loadGeometries(i)),Promise.all(a).then(function(c){const h=c.slice(0,c.length-1),d=c[c.length-1],f=[];for(let m=0,_=d.length;m<_;m++){const v=d[m],y=i[m];let g;const M=h[m];if(y.mode===Qe.TRIANGLES||y.mode===Qe.TRIANGLE_STRIP||y.mode===Qe.TRIANGLE_FAN||y.mode===void 0)g=s.isSkinnedMesh===!0?new l.SkinnedMesh(v,M):new l.Mesh(v,M),g.isSkinnedMesh===!0&&g.normalizeSkinWeights(),y.mode===Qe.TRIANGLE_STRIP?g.geometry=Hr(g.geometry,l.TriangleStripDrawMode):y.mode===Qe.TRIANGLE_FAN&&(g.geometry=Hr(g.geometry,l.TriangleFanDrawMode));else if(y.mode===Qe.LINES)g=new l.LineSegments(v,M);else if(y.mode===Qe.LINE_STRIP)g=new l.Line(v,M);else if(y.mode===Qe.LINE_LOOP)g=new l.LineLoop(v,M);else if(y.mode===Qe.POINTS)g=new l.Points(v,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+y.mode);Object.keys(g.geometry.morphAttributes).length>0&&Ea(g,s),g.name=t.createUniqueName(s.name||"mesh_"+e),ut(g,s),y.extensions&&Dt(r,g,y),t.assignFinalMaterial(g),f.push(g)}for(let m=0,_=f.length;m<_;m++)t.associations.set(f[m],{meshes:e,primitives:m});if(f.length===1)return s.extensions&&Dt(r,f[0],s),f[0];const p=new l.Group;s.extensions&&Dt(r,p,s),t.associations.set(p,{meshes:e});for(let m=0,_=f.length;m<_;m++)p.add(f[m]);return p})}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 l.PerspectiveCamera(l.MathUtils.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):n.type==="orthographic"&&(t=new l.OrthographicCamera(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),ut(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=[],c=[];for(let h=0,d=i.length;h<d;h++){const f=i[h];if(f){a.push(f);const p=new l.Matrix4;s!==null&&p.fromArray(s.array,h*16),c.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new l.Skeleton(a,c)})}loadAnimation(e){const t=this.json,n=this,r=t.animations[e],s=r.name?r.name:"animation_"+e,i=[],a=[],c=[],h=[],d=[];for(let f=0,p=r.channels.length;f<p;f++){const m=r.channels[f],_=r.samplers[m.sampler],v=m.target,y=v.node,g=r.parameters!==void 0?r.parameters[_.input]:_.input,M=r.parameters!==void 0?r.parameters[_.output]:_.output;v.node!==void 0&&(i.push(this.getDependency("node",y)),a.push(this.getDependency("accessor",g)),c.push(this.getDependency("accessor",M)),h.push(_),d.push(v))}return Promise.all([Promise.all(i),Promise.all(a),Promise.all(c),Promise.all(h),Promise.all(d)]).then(function(f){const p=f[0],m=f[1],_=f[2],v=f[3],y=f[4],g=[];for(let M=0,b=p.length;M<b;M++){const S=p[M],O=m[M],T=_[M],C=v[M],w=y[M];if(S===void 0)continue;S.updateMatrix&&S.updateMatrix();const A=n._createAnimationTracks(S,O,T,C,w);if(A)for(let x=0;x<A.length;x++)g.push(A[x])}return new l.AnimationClip(s,void 0,g)})}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 c=0,h=r.weights.length;c<h;c++)a.morphTargetInfluences[c]=r.weights[c]}),i})}loadNode(e){const t=this.json,n=this,r=t.nodes[e],s=n._loadNodeShallow(e),i=[],a=r.children||[];for(let h=0,d=a.length;h<d;h++)i.push(n.getDependency("node",a[h]));const c=r.skin===void 0?Promise.resolve(null):n.getDependency("skin",r.skin);return Promise.all([s,Promise.all(i),c]).then(function(h){const d=h[0],f=h[1],p=h[2];p!==null&&d.traverse(function(m){m.isSkinnedMesh&&m.bind(p,Xa)});for(let m=0,_=f.length;m<_;m++)d.add(f[m]);return d})}_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=[],c=r._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return c&&a.push(c),s.camera!==void 0&&a.push(r.getDependency("camera",s.camera).then(function(h){return r._getNodeRef(r.cameraCache,s.camera,h)})),r._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){a.push(h)}),this.nodeCache[e]=Promise.all(a).then(function(h){let d;if(s.isBone===!0?d=new l.Bone:h.length>1?d=new l.Group:h.length===1?d=h[0]:d=new l.Object3D,d!==h[0])for(let f=0,p=h.length;f<p;f++)d.add(h[f]);if(s.name&&(d.userData.name=s.name,d.name=i),ut(d,s),s.extensions&&Dt(n,d,s),s.matrix!==void 0){const f=new l.Matrix4;f.fromArray(s.matrix),d.applyMatrix4(f)}else s.translation!==void 0&&d.position.fromArray(s.translation),s.rotation!==void 0&&d.quaternion.fromArray(s.rotation),s.scale!==void 0&&d.scale.fromArray(s.scale);return r.associations.has(d)||r.associations.set(d,{}),r.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],r=this,s=new l.Group;n.name&&(s.name=r.createUniqueName(n.name)),ut(s,n),n.extensions&&Dt(t,s,n);const i=n.nodes||[],a=[];for(let c=0,h=i.length;c<h;c++)a.push(r.getDependency("node",i[c]));return Promise.all(a).then(function(c){for(let d=0,f=c.length;d<f;d++)s.add(c[d]);const h=d=>{const f=new Map;for(const[p,m]of r.associations)(p instanceof l.Material||p instanceof l.Texture)&&f.set(p,m);return d.traverse(p=>{const m=r.associations.get(p);m!=null&&f.set(p,m)}),f};return r.associations=h(s),s})}_createAnimationTracks(e,t,n,r,s){const i=[],a=e.name?e.name:e.uuid,c=[];vt[s.path]===vt.weights?e.traverse(function(p){p.morphTargetInfluences&&c.push(p.name?p.name:p.uuid)}):c.push(a);let h;switch(vt[s.path]){case vt.weights:h=l.NumberKeyframeTrack;break;case vt.rotation:h=l.QuaternionKeyframeTrack;break;case vt.position:case vt.scale:h=l.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:h=l.NumberKeyframeTrack;break;case 2:case 3:default:h=l.VectorKeyframeTrack;break}break}const d=r.interpolation!==void 0?Ra[r.interpolation]:l.InterpolateLinear,f=this._getArrayFromAccessor(n);for(let p=0,m=c.length;p<m;p++){const _=new h(c[p]+"."+vt[s.path],t.array,f,d);r.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(_),i.push(_)}return i}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=cr(t.constructor),r=new Float32Array(t.length);for(let s=0,i=t.length;s<i;s++)r[s]=t[s]*n;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const r=this instanceof l.QuaternionKeyframeTrack?Va:Ss;return new r(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Ka(o,e,t){const n=e.attributes,r=new l.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],c=a.min,h=a.max;if(c!==void 0&&h!==void 0){if(r.set(new l.Vector3(c[0],c[1],c[2]),new l.Vector3(h[0],h[1],h[2])),a.normalized){const d=cr(Gt[a.componentType]);r.min.multiplyScalar(d),r.max.multiplyScalar(d)}}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 l.Vector3,c=new l.Vector3;for(let h=0,d=s.length;h<d;h++){const f=s[h];if(f.POSITION!==void 0){const p=t.json.accessors[f.POSITION],m=p.min,_=p.max;if(m!==void 0&&_!==void 0){if(c.setX(Math.max(Math.abs(m[0]),Math.abs(_[0]))),c.setY(Math.max(Math.abs(m[1]),Math.abs(_[1]))),c.setZ(Math.max(Math.abs(m[2]),Math.abs(_[2]))),p.normalized){const v=cr(Gt[p.componentType]);c.multiplyScalar(v)}a.max(c)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}r.expandByVector(a)}o.boundingBox=r;const i=new l.Sphere;r.getCenter(i.center),i.radius=r.min.distanceTo(r.max)/2,o.boundingSphere=i}function Ps(o,e,t){const n=e.attributes,r=[];function s(i,a){return t.getDependency("accessor",i).then(function(c){o.setAttribute(a,c)})}for(const i in n){const a=or[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 ut(o,e),Ka(o,e,t),Promise.all(r).then(function(){return e.targets!==void 0?ja(o,e.targets,t):o})}const en=new l.Vector3;function Je(o,e,t,n,r,s){const i=2*Math.PI*r/4,a=Math.max(s-2*r,0),c=Math.PI/4;en.copy(e),en[n]=0,en.normalize();const h=.5*i/(i+a),d=1-en.angleTo(o)/c;return Math.sign(en[t])===1?d*h:a/(i+a)+h+h*(1-d)}class qa extends l.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 l.Vector3,c=new l.Vector3,h=new l.Vector3(e,t,n).divideScalar(2).subScalar(s),d=this.attributes.position.array,f=this.attributes.normal.array,p=this.attributes.uv.array,m=d.length/6,_=new l.Vector3,v=.5/r;for(let y=0,g=0;y<d.length;y+=3,g+=2)switch(a.fromArray(d,y),c.copy(a),c.x-=Math.sign(c.x)*v,c.y-=Math.sign(c.y)*v,c.z-=Math.sign(c.z)*v,c.normalize(),d[y+0]=h.x*Math.sign(a.x)+c.x*s,d[y+1]=h.y*Math.sign(a.y)+c.y*s,d[y+2]=h.z*Math.sign(a.z)+c.z*s,f[y+0]=c.x,f[y+1]=c.y,f[y+2]=c.z,Math.floor(y/m)){case 0:_.set(1,0,0),p[g+0]=Je(_,c,"z","y",s,n),p[g+1]=1-Je(_,c,"y","z",s,t);break;case 1:_.set(-1,0,0),p[g+0]=1-Je(_,c,"z","y",s,n),p[g+1]=1-Je(_,c,"y","z",s,t);break;case 2:_.set(0,1,0),p[g+0]=1-Je(_,c,"x","z",s,e),p[g+1]=Je(_,c,"z","x",s,n);break;case 3:_.set(0,-1,0),p[g+0]=1-Je(_,c,"x","z",s,e),p[g+1]=1-Je(_,c,"z","x",s,n);break;case 4:_.set(0,0,1),p[g+0]=1-Je(_,c,"x","y",s,e),p[g+1]=1-Je(_,c,"y","x",s,t);break;case 5:_.set(0,0,-1),p[g+0]=Je(_,c,"x","y",s,e),p[g+1]=1-Je(_,c,"y","x",s,t);break}}}class Ts extends l.ExtrudeGeometry{constructor(e,t={}){const{bevelEnabled:n=!1,bevelSize:r=8,bevelThickness:s=10,font:i,height:a=50,size:c=100,lineHeight:h=1,letterSpacing:d=0,...f}=t;if(i===void 0)super();else{const p=i.generateShapes(e,c,{lineHeight:h,letterSpacing:d});super(p,{...f,bevelEnabled:n,bevelSize:r,bevelThickness:s,depth:a})}this.type="TextGeometry"}}const Qa={uniforms:{tDiffuse:{value:null},h:{value:1/512}},vertexShader:`
|
|
28
325
|
varying vec2 vUv;
|
|
29
326
|
|
|
30
327
|
void main() {
|
|
@@ -56,7 +353,7 @@
|
|
|
56
353
|
gl_FragColor = sum;
|
|
57
354
|
|
|
58
355
|
}
|
|
59
|
-
`},
|
|
356
|
+
`},Ja={uniforms:{tDiffuse:{value:null},v:{value:1/512}},vertexShader:`
|
|
60
357
|
varying vec2 vUv;
|
|
61
358
|
|
|
62
359
|
void main() {
|
|
@@ -89,57 +386,13 @@
|
|
|
89
386
|
gl_FragColor = sum;
|
|
90
387
|
|
|
91
388
|
}
|
|
92
|
-
`};function Ms(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 Ua(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 c=0;for(let h=0;h<a;++h){const f=i[h+1],d=s[a-h],p=r[h]/(f+d);r[h]=c+f*p,c=d*p}r[a]=c}return r}function Na(o,e,t,n){const r=Ms(o,n,e),s=Ua(r,n,o,e),i=new l.Vector4(0,0,0,0);for(let a=0;a<=o;++a){const c=t[r-o+a],h=s[a],f=c.w*h;i.x+=c.x*f,i.y+=c.y*f,i.z+=c.z*f,i.w+=c.w*h}return i}function Va(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 c=s.slice(0),h=s.slice(0);for(let d=1;d<=t;++d){c[d]=e-r[o+1-d],h[d]=r[o+d]-e;let p=0;for(let g=0;g<d;++g){const x=h[g+1],v=c[d-g];a[d][g]=x+v;const _=a[g][d-1]/a[d][g];a[g][d]=p+x*_,p=v*_}a[d][d]=p}for(let d=0;d<=t;++d)i[0][d]=a[d][t];for(let d=0;d<=t;++d){let p=0,g=1;const x=[];for(let v=0;v<=t;++v)x[v]=s.slice(0);x[0][0]=1;for(let v=1;v<=n;++v){let _=0;const m=d-v,M=t-v;d>=v&&(x[g][0]=x[p][0]/a[M+1][m],_=x[g][0]*a[m][M]);const b=m>=-1?1:-m,S=d-1<=M?v-1:t-d;for(let P=b;P<=S;++P)x[g][P]=(x[p][P]-x[p][P-1])/a[M+1][m+P],_+=x[g][P]*a[m+P][M];d<=M&&(x[g][v]=-x[p][v-1]/a[M+1][d],_+=x[g][v]*a[d][M]),i[v][d]=_;const L=p;p=g,g=L}}let f=t;for(let d=1;d<=n;++d){for(let p=0;p<=t;++p)i[d][p]*=f;f*=t-d}return i}function za(o,e,t,n,r){const s=r<o?r:o,i=[],a=Ms(o,n,e),c=Va(a,n,o,s,e),h=[];for(let f=0;f<t.length;++f){const d=t[f].clone(),p=d.w;d.x*=p,d.y*=p,d.z*=p,h[f]=d}for(let f=0;f<=s;++f){const d=h[a-o].clone().multiplyScalar(c[f][0]);for(let p=1;p<=o;++p)d.add(h[a-o+p].clone().multiplyScalar(c[f][p]));i[f]=d}for(let f=s+1;f<=r+1;++f)i[f]=new l.Vector4(0,0,0);return i}function Ga(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 ja(o){const e=o.length,t=[],n=[];for(let s=0;s<e;++s){const i=o[s];t[s]=new l.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(Ga(s,a)*n[a]));r[s]=i.divideScalar(n[0])}return r}function Ra(o,e,t,n,r){const s=za(o,e,t,n,r);return ja(s)}class Ss extends l.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 l.Vector4(a.x,a.y,a.z,a.w)}}getPoint(e,t){const n=t||new l.Vector3,r=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),s=Na(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 l.Vector3,r=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),s=Ra(this.degree,this.knots,this.controlPoints,r,1);return n.copy(s[1]).normalize(),n}}let _e,De,je;class Wa extends l.Loader{constructor(e){super(e)}load(e,t,n,r){const s=this,i=s.path===""?l.LoaderUtils.extractUrlBase(e):s.path,a=new l.FileLoader(this.manager);a.setPath(s.path),a.setResponseType("arraybuffer"),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(c){try{t(s.parse(c,i))}catch(h){r?r(h):console.error(h),s.manager.itemError(e)}},n,r)}parse(e,t){if(Ka(e))_e=new qa().parse(e);else{const r=Ls(e);if(!Qa(r))throw new Error("THREE.FBXLoader: Unknown format.");if(Ps(r)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Ps(r));_e=new Za().parse(r)}const n=new l.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new Ya(n,this.manager).parse(_e)}}class Ya{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 Ea().parse(r);return this.parseScene(r,s,n),je}parseConnections(){const e=new Map;return"Connections"in _e&&_e.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 c={ID:r,relationship:i};e.get(s).children.push(c)}),e}parseImages(){const e={},t={};if("Video"in _e.Objects){const n=_e.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,c=typeof s.Content=="string"&&s.Content!=="";if(a||c){const h=this.parseImage(n[r]);t[s.RelativeFilename||s.Filename]=h}}}}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 _e.Objects){const n=_e.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?l.RepeatWrapping:l.ClampToEdgeWrapping,n.wrapT=a===0?l.RepeatWrapping:l.ClampToEdgeWrapping,"Scaling"in e){const c=e.Scaling.value;n.repeat.x=c[0],n.repeat.y=c[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 c=this.manager.getHandler(".tga");c===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),i=new l.Texture):(c.setPath(this.textureLoader.path),i=c.load(n))}else a==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),i=new l.Texture):i=this.textureLoader.load(n);return this.textureLoader.setPath(r),i}parseMaterials(e){const t=new Map;if("Material"in _e.Objects){const n=_e.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 l.MeshPhongMaterial;break;case"lambert":a=new l.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),a=new l.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 l.Color().fromArray(e.Diffuse.value):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(r.color=new l.Color().fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(r.displacementScale=e.DisplacementFactor.value),e.Emissive?r.emissive=new l.Color().fromArray(e.Emissive.value):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(r.emissive=new l.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 l.Color().fromArray(e.Specular.value):e.SpecularColor&&e.SpecularColor.type==="Color"&&(r.specular=new l.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=l.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 _e.Objects&&t in _e.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 _e.Objects){const n=_e.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 l.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(c){return c.relationship===void 0})[0].ID,n.push(a)}return n}parseScene(e,t,n){je=new l.Group;const r=this.parseModels(e.skeletons,t,n),s=_e.Objects.Model,i=this;r.forEach(function(c){const h=s[c.ID];i.setLookAtProperties(c,h),De.get(c.ID).parents.forEach(function(d){const p=r.get(d.ID);p!==void 0&&p.add(c)}),c.parent===null&&je.add(c)}),this.bindSkeleton(e.skeletons,t,r),this.createAmbientLight(),je.traverse(function(c){if(c.userData.transformData){c.parent&&(c.userData.transformData.parentMatrix=c.parent.matrix,c.userData.transformData.parentMatrixWorld=c.parent.matrixWorld);const h=Ts(c.userData.transformData);c.applyMatrix4(h),c.updateWorldMatrix()}});const a=new Xa().parse();je.children.length===1&&je.children[0].isGroup&&(je.children[0].animations=a,je=je.children[0]),je.animations=a}parseModels(e,t,n){const r=new Map,s=_e.Objects.Model;for(const i in s){const a=parseInt(i),c=s[i],h=De.get(a);let f=this.buildSkeleton(h,e,a,c.attrName);if(!f){switch(c.attrType){case"Camera":f=this.createCamera(h);break;case"Light":f=this.createLight(h);break;case"Mesh":f=this.createMesh(h,t,n);break;case"NurbsCurve":f=this.createCurve(h,t);break;case"LimbNode":case"Root":f=new l.Bone;break;case"Null":default:f=new l.Group;break}f.name=c.attrName?l.PropertyBinding.sanitizeNodeName(c.attrName):"",f.ID=a}this.getTransformData(f,c),r.set(a,f)}return r}buildSkeleton(e,t,n,r){let s=null;return e.parents.forEach(function(i){for(const a in t){const c=t[a];c.rawBones.forEach(function(h,f){if(h.ID===i.ID){const d=s;s=new l.Bone,s.matrixWorld.copy(h.transformLink),s.name=r?l.PropertyBinding.sanitizeNodeName(r):"",s.ID=n,c.bones[f]=s,d!==null&&s.add(d)}})}}),s}createCamera(e){let t,n;if(e.children.forEach(function(r){const s=_e.Objects.NodeAttribute[r.ID];s!==void 0&&(n=s)}),n===void 0)t=new l.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,c=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(a=n.AspectWidth.value,c=n.AspectHeight.value);const h=a/c;let f=45;n.FieldOfView!==void 0&&(f=n.FieldOfView.value);const d=n.FocalLength?n.FocalLength.value:null;switch(r){case 0:t=new l.PerspectiveCamera(f,h,s,i),d!==null&&t.setFocalLength(d);break;case 1:t=new l.OrthographicCamera(-a/2,a/2,c/2,-c/2,s,i);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+r+"."),t=new l.Object3D;break}}return t}createLight(e){let t,n;if(e.children.forEach(function(r){const s=_e.Objects.NodeAttribute[r.ID];s!==void 0&&(n=s)}),n===void 0)t=new l.Object3D;else{let r;n.LightType===void 0?r=0:r=n.LightType.value;let s=16777215;n.Color!==void 0&&(s=new l.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 c=1;switch(r){case 0:t=new l.PointLight(s,i,a,c);break;case 1:t=new l.DirectionalLight(s,i);break;case 2:let h=Math.PI/3;n.InnerAngle!==void 0&&(h=l.MathUtils.degToRad(n.InnerAngle.value));let f=0;n.OuterAngle!==void 0&&(f=l.MathUtils.degToRad(n.OuterAngle.value),f=Math.max(f,1)),t=new l.SpotLight(s,i,a,h,f,c);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new l.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(c){t.has(c.ID)&&(s=t.get(c.ID)),n.has(c.ID)&&a.push(n.get(c.ID))}),a.length>1?i=a:a.length>0?i=a[0]:(i=new l.MeshPhongMaterial({color:13421772}),a.push(i)),"color"in s.attributes&&a.forEach(function(c){c.vertexColors=!0}),s.FBX_Deformer?(r=new l.SkinnedMesh(s,i),r.normalizeSkinWeights()):r=new l.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 l.LineBasicMaterial({color:3342591,linewidth:1});return new l.Line(n,r)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=Is(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=_e.Objects.Model[r.ID];if("Lcl_Translation"in s){const i=s.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(i),je.add(e.target)):e.lookAt(new l.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(c){if(t.has(c.ID)){const h=c.ID;De.get(h).parents.forEach(function(d){n.has(d.ID)&&n.get(d.ID).bind(new l.Skeleton(i.bones),r[d.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in _e.Objects){const t=_e.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 l.Matrix4().fromArray(s.Matrix.a)}):e[r.Node]=new l.Matrix4().fromArray(r.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in _e&&"AmbientColor"in _e.GlobalSettings){const e=_e.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],r=e[2];if(t!==0||n!==0||r!==0){const s=new l.Color(t,n,r);je.add(new l.AmbientLight(s,1))}}}}class Ea{parse(e){const t=new Map;if("Geometry"in _e.Objects){const n=_e.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 _e.Objects.Model[d.ID]});if(i.length===0)return;const a=e.children.reduce(function(d,p){return r[p.ID]!==void 0&&(d=r[p.ID]),d},null);e.children.forEach(function(d){n.morphTargets[d.ID]!==void 0&&s.push(n.morphTargets[d.ID])});const c=i[0],h={};"RotationOrder"in c&&(h.eulerOrder=Is(c.RotationOrder.value)),"InheritType"in c&&(h.inheritType=parseInt(c.InheritType.value)),"GeometricTranslation"in c&&(h.translation=c.GeometricTranslation.value),"GeometricRotation"in c&&(h.rotation=c.GeometricRotation.value),"GeometricScaling"in c&&(h.scale=c.GeometricScaling.value);const f=Ts(h);return this.genGeometry(t,a,s,f)}genGeometry(e,t,n,r){const s=new l.BufferGeometry;e.attrName&&(s.name=e.attrName);const i=this.parseGeoNode(e,t),a=this.genBuffers(i),c=new l.Float32BufferAttribute(a.vertex,3);if(c.applyMatrix4(r),s.setAttribute("position",c),a.colors.length>0&&s.setAttribute("color",new l.Float32BufferAttribute(a.colors,3)),t&&(s.setAttribute("skinIndex",new l.Uint16BufferAttribute(a.weightsIndices,4)),s.setAttribute("skinWeight",new l.Float32BufferAttribute(a.vertexWeights,4)),s.FBX_Deformer=t),a.normal.length>0){const h=new l.Matrix3().getNormalMatrix(r),f=new l.Float32BufferAttribute(a.normal,3);f.applyNormalMatrix(h),s.setAttribute("normal",f)}if(a.uvs.forEach(function(h,f){let d="uv"+(f+1).toString();f===0&&(d="uv"),s.setAttribute(d,new l.Float32BufferAttribute(a.uvs[f],2))}),i.material&&i.material.mappingType!=="AllSame"){let h=a.materialIndex[0],f=0;if(a.materialIndex.forEach(function(d,p){d!==h&&(s.addGroup(f,p-f,h),h=d,f=p)}),s.groups.length>0){const d=s.groups[s.groups.length-1],p=d.start+d.count;p!==a.materialIndex.length&&s.addGroup(p,a.materialIndex.length-p,h)}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=[],c=[],h=[],f=[],d=[];const p=this;return e.vertexIndices.forEach(function(g,x){let v,_=!1;g<0&&(g=g^-1,_=!0);let m=[],M=[];if(i.push(g*3,g*3+1,g*3+2),e.color){const b=Mn(x,n,g,e.color);c.push(b[0],b[1],b[2])}if(e.skeleton){if(e.weightTable[g]!==void 0&&e.weightTable[g].forEach(function(b){M.push(b.weight),m.push(b.id)}),M.length>4){s||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),s=!0);const b=[0,0,0,0],S=[0,0,0,0];M.forEach(function(L,P){let T=L,y=m[P];S.forEach(function(A,w,D){if(T>A){D[w]=T,T=A;const k=b[w];b[w]=y,y=k}})}),m=b,M=S}for(;M.length<4;)M.push(0),m.push(0);for(let b=0;b<4;++b)f.push(M[b]),d.push(m[b])}if(e.normal){const b=Mn(x,n,g,e.normal);a.push(b[0],b[1],b[2])}e.material&&e.material.mappingType!=="AllSame"&&(v=Mn(x,n,g,e.material)[0]),e.uv&&e.uv.forEach(function(b,S){const L=Mn(x,n,g,b);h[S]===void 0&&(h[S]=[]),h[S].push(L[0]),h[S].push(L[1])}),r++,_&&(p.genFace(t,e,i,v,a,c,h,f,d,r),n++,r=0,i=[],a=[],c=[],h=[],f=[],d=[])}),t}genFace(e,t,n,r,s,i,a,c,h,f){for(let d=2;d<f;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(c[0]),e.vertexWeights.push(c[1]),e.vertexWeights.push(c[2]),e.vertexWeights.push(c[3]),e.vertexWeights.push(c[(d-1)*4]),e.vertexWeights.push(c[(d-1)*4+1]),e.vertexWeights.push(c[(d-1)*4+2]),e.vertexWeights.push(c[(d-1)*4+3]),e.vertexWeights.push(c[d*4]),e.vertexWeights.push(c[d*4+1]),e.vertexWeights.push(c[d*4+2]),e.vertexWeights.push(c[d*4+3]),e.weightsIndices.push(h[0]),e.weightsIndices.push(h[1]),e.weightsIndices.push(h[2]),e.weightsIndices.push(h[3]),e.weightsIndices.push(h[(d-1)*4]),e.weightsIndices.push(h[(d-1)*4+1]),e.weightsIndices.push(h[(d-1)*4+2]),e.weightsIndices.push(h[(d-1)*4+3]),e.weightsIndices.push(h[d*4]),e.weightsIndices.push(h[d*4+1]),e.weightsIndices.push(h[d*4+2]),e.weightsIndices.push(h[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(p,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,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 c=_e.Objects.Geometry[a.geoID];c!==void 0&&s.genMorphGeometry(e,t,c,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:[],c=n.Indexes!==void 0?n.Indexes.a:[],h=e.attributes.position.count*3,f=new Float32Array(h);for(let x=0;x<c.length;x++){const v=c[x]*3;f[v]=a[x*3],f[v+1]=a[x*3+1],f[v+2]=a[x*3+2]}const d={vertexIndices:i,vertexPositions:f},p=this.genBuffers(d),g=new l.Float32BufferAttribute(p.vertex,3);g.name=s||n.attrName,g.applyMatrix4(r),e.morphAttributes.position.push(g)}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(Ss===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 l.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 l.BufferGeometry;const n=t-1,r=e.KnotVector.a,s=[],i=e.Points.a;for(let d=0,p=i.length;d<p;d+=4)s.push(new l.Vector4().fromArray(i,d));let a,c;if(e.Form==="Closed")s.push(s[0]);else if(e.Form==="Periodic"){a=n,c=r.length-1-a;for(let d=0;d<n;++d)s.push(s[d])}const f=new Ss(n,r,s,a,c).getPoints(s.length*12);return new l.BufferGeometry().setFromPoints(f)}}class Xa{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(_e.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=_e.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=_e.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=_e.Objects.AnimationLayer,n=new Map;for(const r in t){const s=[],i=De.get(parseInt(r));i!==void 0&&(i.children.forEach(function(c,h){if(e.has(c.ID)){const f=e.get(c.ID);if(f.curves.x!==void 0||f.curves.y!==void 0||f.curves.z!==void 0){if(s[h]===void 0){const d=De.get(c.ID).parents.filter(function(p){return p.relationship!==void 0})[0].ID;if(d!==void 0){const p=_e.Objects.Model[d.toString()];if(p===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",c);return}const g={modelName:p.attrName?l.PropertyBinding.sanitizeNodeName(p.attrName):"",ID:p.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};je.traverse(function(x){x.ID===p.id&&(g.transform=x.matrix,x.userData.transformData&&(g.eulerOrder=x.userData.transformData.eulerOrder))}),g.transform||(g.transform=new l.Matrix4),"PreRotation"in p&&(g.preRotation=p.PreRotation.value),"PostRotation"in p&&(g.postRotation=p.PostRotation.value),s[h]=g}}s[h]&&(s[h][f.attr]=f)}else if(f.curves.morph!==void 0){if(s[h]===void 0){const d=De.get(c.ID).parents.filter(function(m){return m.relationship!==void 0})[0].ID,p=De.get(d).parents[0].ID,g=De.get(p).parents[0].ID,x=De.get(g).parents[0].ID,v=_e.Objects.Model[x],_={modelName:v.attrName?l.PropertyBinding.sanitizeNodeName(v.attrName):"",morphName:_e.Objects.Deformer[d].attrName};s[h]=_}s[h][f.attr]=f}}}),n.set(parseInt(r),s))}return n}parseAnimStacks(e){const t=_e.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 l.AnimationClip(e.name,-1,t)}generateTracks(e){const t=[];let n=new l.Vector3,r=new l.Quaternion,s=new l.Vector3;if(e.transform&&e.transform.decompose(n,r,s),n=n.toArray(),r=new l.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 l.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(l.MathUtils.degToRad)),t.y!==void 0&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(l.MathUtils.degToRad)),t.z!==void 0&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(l.MathUtils.degToRad));const a=this.getTimesForAllAxes(t),c=this.getKeyframeTrackValues(a,t,n);r!==void 0&&(r=r.map(l.MathUtils.degToRad),r.push(i),r=new l.Euler().fromArray(r),r=new l.Quaternion().setFromEuler(r)),s!==void 0&&(s=s.map(l.MathUtils.degToRad),s.push(i),s=new l.Euler().fromArray(s),s=new l.Quaternion().setFromEuler(s).invert());const h=new l.Quaternion,f=new l.Euler,d=[];for(let p=0;p<c.length;p+=3)f.set(c[p],c[p+1],c[p+2],i),h.setFromEuler(f),r!==void 0&&h.premultiply(r),s!==void 0&&h.multiply(s),h.toArray(d,p/3*4);return new l.QuaternionKeyframeTrack(e+".quaternion",a,d)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(s){return s/100}),r=je.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new l.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,c=-1;return e.forEach(function(h){if(t.x&&(i=t.x.times.indexOf(h)),t.y&&(a=t.y.times.indexOf(h)),t.z&&(c=t.z.times.indexOf(h)),i!==-1){const f=t.x.values[i];s.push(f),r[0]=f}else s.push(r[0]);if(a!==-1){const f=t.y.values[a];s.push(f),r[1]=f}else s.push(r[1]);if(c!==-1){const f=t.z.values[c];s.push(f),r[2]=f}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 c=n+a;const h=e.times[t-1],d=(e.times[t]-h)/i;let p=h+d;const g=[],x=[];for(;p<e.times[t];)g.push(p),p+=d,x.push(c),c+=a;e.times=Os(e.times,t,g),e.values=Os(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 Cs,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 c=r.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),h=r.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),f=r.match("^\\t{"+(t.currentIndent-1)+"}}");c?t.parseNodeBegin(r,c):h?t.parseNodeProperty(r,h,n[++s]):f?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(c){return c.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 c=s.split(",").slice(1),h=parseInt(c[0]),f=parseInt(c[1]);let d=s.split(",").slice(3);d=d.map(function(p){return p.trim().replace(/^"/,"")}),r="connections",s=[h,f],$a(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=lr(s))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=lr(t.a))}parseNodeSpecialProperty(e,t,n){const r=n.split('",').map(function(f){return f.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=r[0],i=r[1],a=r[2],c=r[3];let h=r[4];switch(i){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":h=parseFloat(h);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":h=lr(h);break}this.getPrevNode()[s]={type:i,type2:a,flag:c,value:h},this.setCurrentProp(this.getPrevNode(),s)}}class qa{parse(e){const t=new As(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 Cs;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 c=[];for(let p=0;p<s;p++)c.push(this.parseProperty(e));const h=c.length>0?c[0]:"",f=c.length>1?c[1]:"",d=c.length>2?c[2]:"";for(n.singleProperty=s===1&&e.getOffset()===r;r>e.getOffset();){const p=this.parseNode(e,t);p!==null&&this.parseSubNode(a,n,p)}return n.propertyList=c,typeof h=="number"&&(n.id=h),f!==""&&(n.attrName=f),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 c;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?c=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:c=n.propertyList[4],t[r]={type:s,type2:i,flag:a,value:c}}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=Uo(new Uint8Array(e.getArrayBuffer(i))),c=new As(a.buffer);switch(t){case"b":case"c":return c.getBooleanArray(r);case"d":return c.getFloat64Array(r);case"f":return c.getFloat32Array(r);case"i":return c.getInt32Array(r);case"l":return c.getInt64Array(r)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class As{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)),l.LoaderUtils.decodeText(new Uint8Array(t))}}class Cs{add(e,t){this[e]=t}}function Ka(o){const e="Kaydara FBX Binary \0";return o.byteLength>=e.length&&e===Ls(o,0,e.length)}function Qa(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 Ps(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 Ha=[];function Mn(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 el(Ha,n.buffer,s,i)}const ar=new l.Euler,zt=new l.Vector3;function Ts(o){const e=new l.Matrix4,t=new l.Matrix4,n=new l.Matrix4,r=new l.Matrix4,s=new l.Matrix4,i=new l.Matrix4,a=new l.Matrix4,c=new l.Matrix4,h=new l.Matrix4,f=new l.Matrix4,d=new l.Matrix4,p=new l.Matrix4,g=o.inheritType?o.inheritType:0;if(o.translation&&e.setPosition(zt.fromArray(o.translation)),o.preRotation){const w=o.preRotation.map(l.MathUtils.degToRad);w.push(o.eulerOrder),t.makeRotationFromEuler(ar.fromArray(w))}if(o.rotation){const w=o.rotation.map(l.MathUtils.degToRad);w.push(o.eulerOrder),n.makeRotationFromEuler(ar.fromArray(w))}if(o.postRotation){const w=o.postRotation.map(l.MathUtils.degToRad);w.push(o.eulerOrder),r.makeRotationFromEuler(ar.fromArray(w)),r.invert()}o.scale&&s.scale(zt.fromArray(o.scale)),o.scalingOffset&&a.setPosition(zt.fromArray(o.scalingOffset)),o.scalingPivot&&i.setPosition(zt.fromArray(o.scalingPivot)),o.rotationOffset&&c.setPosition(zt.fromArray(o.rotationOffset)),o.rotationPivot&&h.setPosition(zt.fromArray(o.rotationPivot)),o.parentMatrixWorld&&(d.copy(o.parentMatrix),f.copy(o.parentMatrixWorld));const x=t.clone().multiply(n).multiply(r),v=new l.Matrix4;v.extractRotation(f);const _=new l.Matrix4;_.copyPosition(f);const m=_.clone().invert().multiply(f),M=v.clone().invert().multiply(m),b=s,S=new l.Matrix4;if(g===0)S.copy(v).multiply(x).multiply(M).multiply(b);else if(g===1)S.copy(v).multiply(M).multiply(x).multiply(b);else{const D=new l.Matrix4().scale(new l.Vector3().setFromMatrixScale(d)).clone().invert(),k=M.clone().multiply(D);S.copy(v).multiply(x).multiply(k).multiply(b)}const L=h.clone().invert(),P=i.clone().invert();let T=e.clone().multiply(c).multiply(h).multiply(t).multiply(n).multiply(r).multiply(L).multiply(a).multiply(i).multiply(s).multiply(P);const y=new l.Matrix4().copyPosition(T),A=f.clone().multiply(y);return p.copyPosition(A),T=p.clone().multiply(S),T.premultiply(f.invert()),T}function Is(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 lr(o){return o.split(",").map(function(t){return parseFloat(t)})}function Ls(o,e,t){return e===void 0&&(e=0),t===void 0&&(t=o.byteLength),l.LoaderUtils.decodeText(new Uint8Array(o,e,t))}function $a(o,e){for(let t=0,n=o.length,r=e.length;t<r;t++,n++)o[n]=e[t]}function el(o,e,t,n){for(let r=t,s=0;r<n;r++,s++)o[s]=e[r];return o}function Os(o,e,t){return o.slice(0,e).concat(t).concat(o.slice(e))}var tl=Object.defineProperty,nl=(o,e,t)=>e in o?tl(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,cr=(o,e,t)=>(nl(o,typeof e!="symbol"?e+"":e,t),t);class rl extends l.Loader{constructor(e){super(e)}load(e,t,n,r){const s=new l.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),c=this.parse(a);t&&t(c)},n,r)}loadAsync(e,t){return super.loadAsync(e,t)}parse(e){return new ur(e)}}class ur{constructor(e){cr(this,"data"),this.data=e}generateShapes(e,t=100,n){const r=[],s={letterSpacing:0,lineHeight:1,...n},i=sl(e,t,this.data,s);for(let a=0,c=i.length;a<c;a++)Array.prototype.push.apply(r,i[a].toShapes(!1));return r}}cr(ur,"isFont"),cr(ur,"type");function sl(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 c=0,h=0;for(let f=0;f<r.length;f++){const d=r[f];if(d===`
|
|
93
|
-
`)c=0,h-=i*n.lineHeight;else{const p=
|
|
94
|
-
`,
|
|
95
|
-
`;
|
|
96
|
-
`,
|
|
97
|
-
`;continue}if((G=Y.match(w))&&(V.gamma=parseFloat(G[1])),(G=Y.match(D))&&(V.exposure=parseFloat(G[1])),(G=Y.match(k))&&(V.valid|=2,V.format=G[1]),(G=Y.match(R))&&(V.valid|=4,V.height=parseInt(G[1],10),V.width=parseInt(G[2],10)),V.valid&2&&V.valid&4)break}return V.valid&2||i(3,"missing format specifier"),V.valid&4||i(3,"missing image size specifier"),V},g=function(y,A,w){const D=A;if(D<8||D>32767||y[0]!==2||y[1]!==2||y[2]&128)return new Uint8Array(y);D!==(y[2]<<8|y[3])&&i(3,"wrong scanline width");const k=new Uint8Array(4*A*w);k.length||i(4,"unable to allocate buffer space");let R=0,V=0;const Y=4*D,G=new Uint8Array(4),Q=new Uint8Array(Y);let K=w;for(;K>0&&V<y.byteLength;){V+4>y.byteLength&&i(1),G[0]=y[V++],G[1]=y[V++],G[2]=y[V++],G[3]=y[V++],(G[0]!=2||G[1]!=2||(G[2]<<8|G[3])!=D)&&i(3,"bad rgbe scanline format");let ne=0,ee;for(;ne<Y&&V<y.byteLength;){ee=y[V++];const he=ee>128;if(he&&(ee-=128),(ee===0||ne+ee>Y)&&i(3,"bad scanline data"),he){const de=y[V++];for(let O=0;O<ee;O++)Q[ne++]=de}else Q.set(y.subarray(V,V+ee),ne),ne+=ee,V+=ee}const le=D;for(let he=0;he<le;he++){let de=0;k[R]=Q[he+de],de+=D,k[R+1]=Q[he+de],de+=D,k[R+2]=Q[he+de],de+=D,k[R+3]=Q[he+de],R+=4}K--}return k},x=function(y,A,w,D){const k=y[A+3],R=Math.pow(2,k-128)/255;w[D+0]=y[A+0]*R,w[D+1]=y[A+1]*R,w[D+2]=y[A+2]*R,w[D+3]=1},v=function(y,A,w,D){const k=y[A+3],R=Math.pow(2,k-128)/255;w[D+0]=l.DataUtils.toHalfFloat(Math.min(y[A+0]*R,65504)),w[D+1]=l.DataUtils.toHalfFloat(Math.min(y[A+1]*R,65504)),w[D+2]=l.DataUtils.toHalfFloat(Math.min(y[A+2]*R,65504)),w[D+3]=l.DataUtils.toHalfFloat(1)},_=new Uint8Array(e);_.pos=0;const m=p(_),M=m.width,b=m.height,S=g(_.subarray(_.pos),M,b);let L,P,T;switch(this.type){case l.FloatType:T=S.length/4;const y=new Float32Array(T*4);for(let w=0;w<T;w++)x(S,w*4,y,w*4);L=y,P=l.FloatType;break;case l.HalfFloatType:T=S.length/4;const A=new Uint16Array(T*4);for(let w=0;w<T;w++)v(S,w*4,A,w*4);L=A,P=l.HalfFloatType;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:M,height:b,data:L,header:m.string,gamma:m.gamma,exposure:m.exposure,type:P}}setDataType(e){return this.type=e,this}load(e,t,n,r){function s(i,a){switch(i.type){case l.FloatType:case l.HalfFloatType:"colorSpace"in i?i.colorSpace="srgb-linear":i.encoding=3e3,i.minFilter=l.LinearFilter,i.magFilter=l.LinearFilter,i.generateMipmaps=!1,i.flipY=!0;break}t&&t(i,a)}return super.load(e,s,n,r)}}const ol="srgb";class en extends l.Loader{constructor(e){super(e),this.defaultDPI=90,this.defaultUnit="px"}load(e,t,n,r){const s=this,i=new l.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(c){r?r(c):console.error(c),s.manager.itemError(e)}},n,r)}parse(e){const t=this;function n(O,z){if(O.nodeType!==1)return;const U=S(O);let F=!1,j=null;switch(O.nodeName){case"svg":z=x(O,z);break;case"style":s(O);break;case"g":z=x(O,z);break;case"path":z=x(O,z),O.hasAttribute("d")&&(j=r(O));break;case"rect":z=x(O,z),j=c(O);break;case"polygon":z=x(O,z),j=h(O);break;case"polyline":z=x(O,z),j=f(O);break;case"circle":z=x(O,z),j=d(O);break;case"ellipse":z=x(O,z),j=p(O);break;case"line":z=x(O,z),j=g(O);break;case"defs":F=!0;break;case"use":z=x(O,z);const B=(O.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),Z=O.viewportElement.getElementById(B);Z?n(Z,z):console.warn("SVGLoader: 'use node' references non-existent node id: "+B);break}j&&(z.fill!==void 0&&z.fill!=="none"&&j.color.setStyle(z.fill,ol),P(j,le),k.push(j),j.userData={node:O,style:z});const C=O.childNodes;for(let I=0;I<C.length;I++){const B=C[I];F&&B.nodeName!=="style"&&B.nodeName!=="defs"||n(B,z)}U&&(V.pop(),V.length>0?le.copy(V[V.length-1]):le.identity())}function r(O){const z=new l.ShapePath,U=new l.Vector2,F=new l.Vector2,j=new l.Vector2;let C=!0,I=!1;const B=O.getAttribute("d");if(B===""||B==="none")return null;const Z=B.match(/[a-df-z][^a-df-z]*/gi);for(let X=0,W=Z.length;X<W;X++){const $=Z[X],re=$.charAt(0),se=$.slice(1).trim();C===!0&&(I=!0,C=!1);let E;switch(re){case"M":E=_(se);for(let N=0,ae=E.length;N<ae;N+=2)U.x=E[N+0],U.y=E[N+1],F.x=U.x,F.y=U.y,N===0?z.moveTo(U.x,U.y):z.lineTo(U.x,U.y),N===0&&j.copy(U);break;case"H":E=_(se);for(let N=0,ae=E.length;N<ae;N++)U.x=E[N],F.x=U.x,F.y=U.y,z.lineTo(U.x,U.y),N===0&&I===!0&&j.copy(U);break;case"V":E=_(se);for(let N=0,ae=E.length;N<ae;N++)U.y=E[N],F.x=U.x,F.y=U.y,z.lineTo(U.x,U.y),N===0&&I===!0&&j.copy(U);break;case"L":E=_(se);for(let N=0,ae=E.length;N<ae;N+=2)U.x=E[N+0],U.y=E[N+1],F.x=U.x,F.y=U.y,z.lineTo(U.x,U.y),N===0&&I===!0&&j.copy(U);break;case"C":E=_(se);for(let N=0,ae=E.length;N<ae;N+=6)z.bezierCurveTo(E[N+0],E[N+1],E[N+2],E[N+3],E[N+4],E[N+5]),F.x=E[N+2],F.y=E[N+3],U.x=E[N+4],U.y=E[N+5],N===0&&I===!0&&j.copy(U);break;case"S":E=_(se);for(let N=0,ae=E.length;N<ae;N+=4)z.bezierCurveTo(v(U.x,F.x),v(U.y,F.y),E[N+0],E[N+1],E[N+2],E[N+3]),F.x=E[N+0],F.y=E[N+1],U.x=E[N+2],U.y=E[N+3],N===0&&I===!0&&j.copy(U);break;case"Q":E=_(se);for(let N=0,ae=E.length;N<ae;N+=4)z.quadraticCurveTo(E[N+0],E[N+1],E[N+2],E[N+3]),F.x=E[N+0],F.y=E[N+1],U.x=E[N+2],U.y=E[N+3],N===0&&I===!0&&j.copy(U);break;case"T":E=_(se);for(let N=0,ae=E.length;N<ae;N+=2){const ue=v(U.x,F.x),ve=v(U.y,F.y);z.quadraticCurveTo(ue,ve,E[N+0],E[N+1]),F.x=ue,F.y=ve,U.x=E[N+0],U.y=E[N+1],N===0&&I===!0&&j.copy(U)}break;case"A":E=_(se,[3,4],7);for(let N=0,ae=E.length;N<ae;N+=7){if(E[N+5]==U.x&&E[N+6]==U.y)continue;const ue=U.clone();U.x=E[N+5],U.y=E[N+6],F.x=U.x,F.y=U.y,i(z,E[N],E[N+1],E[N+2],E[N+3],E[N+4],ue,U),N===0&&I===!0&&j.copy(U)}break;case"m":E=_(se);for(let N=0,ae=E.length;N<ae;N+=2)U.x+=E[N+0],U.y+=E[N+1],F.x=U.x,F.y=U.y,N===0?z.moveTo(U.x,U.y):z.lineTo(U.x,U.y),N===0&&j.copy(U);break;case"h":E=_(se);for(let N=0,ae=E.length;N<ae;N++)U.x+=E[N],F.x=U.x,F.y=U.y,z.lineTo(U.x,U.y),N===0&&I===!0&&j.copy(U);break;case"v":E=_(se);for(let N=0,ae=E.length;N<ae;N++)U.y+=E[N],F.x=U.x,F.y=U.y,z.lineTo(U.x,U.y),N===0&&I===!0&&j.copy(U);break;case"l":E=_(se);for(let N=0,ae=E.length;N<ae;N+=2)U.x+=E[N+0],U.y+=E[N+1],F.x=U.x,F.y=U.y,z.lineTo(U.x,U.y),N===0&&I===!0&&j.copy(U);break;case"c":E=_(se);for(let N=0,ae=E.length;N<ae;N+=6)z.bezierCurveTo(U.x+E[N+0],U.y+E[N+1],U.x+E[N+2],U.y+E[N+3],U.x+E[N+4],U.y+E[N+5]),F.x=U.x+E[N+2],F.y=U.y+E[N+3],U.x+=E[N+4],U.y+=E[N+5],N===0&&I===!0&&j.copy(U);break;case"s":E=_(se);for(let N=0,ae=E.length;N<ae;N+=4)z.bezierCurveTo(v(U.x,F.x),v(U.y,F.y),U.x+E[N+0],U.y+E[N+1],U.x+E[N+2],U.y+E[N+3]),F.x=U.x+E[N+0],F.y=U.y+E[N+1],U.x+=E[N+2],U.y+=E[N+3],N===0&&I===!0&&j.copy(U);break;case"q":E=_(se);for(let N=0,ae=E.length;N<ae;N+=4)z.quadraticCurveTo(U.x+E[N+0],U.y+E[N+1],U.x+E[N+2],U.y+E[N+3]),F.x=U.x+E[N+0],F.y=U.y+E[N+1],U.x+=E[N+2],U.y+=E[N+3],N===0&&I===!0&&j.copy(U);break;case"t":E=_(se);for(let N=0,ae=E.length;N<ae;N+=2){const ue=v(U.x,F.x),ve=v(U.y,F.y);z.quadraticCurveTo(ue,ve,U.x+E[N+0],U.y+E[N+1]),F.x=ue,F.y=ve,U.x=U.x+E[N+0],U.y=U.y+E[N+1],N===0&&I===!0&&j.copy(U)}break;case"a":E=_(se,[3,4],7);for(let N=0,ae=E.length;N<ae;N+=7){if(E[N+5]==0&&E[N+6]==0)continue;const ue=U.clone();U.x+=E[N+5],U.y+=E[N+6],F.x=U.x,F.y=U.y,i(z,E[N],E[N+1],E[N+2],E[N+3],E[N+4],ue,U),N===0&&I===!0&&j.copy(U)}break;case"Z":case"z":z.currentPath.autoClose=!0,z.currentPath.curves.length>0&&(U.copy(j),z.currentPath.currentPoint.copy(U),C=!0);break;default:console.warn($)}I=!1}return z}function s(O){if(!(!O.sheet||!O.sheet.cssRules||!O.sheet.cssRules.length))for(let z=0;z<O.sheet.cssRules.length;z++){const U=O.sheet.cssRules[z];if(U.type!==1)continue;const F=U.selectorText.split(/,/gm).filter(Boolean).map(j=>j.trim());for(let j=0;j<F.length;j++){const C=Object.fromEntries(Object.entries(U.style).filter(([,I])=>I!==""));R[F[j]]=Object.assign(R[F[j]]||{},C)}}}function i(O,z,U,F,j,C,I,B){if(z==0||U==0){O.lineTo(B.x,B.y);return}F=F*Math.PI/180,z=Math.abs(z),U=Math.abs(U);const Z=(I.x-B.x)/2,X=(I.y-B.y)/2,W=Math.cos(F)*Z+Math.sin(F)*X,$=-Math.sin(F)*Z+Math.cos(F)*X;let re=z*z,se=U*U;const E=W*W,N=$*$,ae=E/re+N/se;if(ae>1){const Zt=Math.sqrt(ae);z=Zt*z,U=Zt*U,re=z*z,se=U*U}const ue=re*N+se*E,ve=(re*se-ue)/ue;let Oe=Math.sqrt(Math.max(0,ve));j===C&&(Oe=-Oe);const Te=Oe*z*$/U,He=-Oe*U*W/z,Ct=Math.cos(F)*Te-Math.sin(F)*He+(I.x+B.x)/2,Ze=Math.sin(F)*Te+Math.cos(F)*He+(I.y+B.y)/2,Pt=a(1,0,(W-Te)/z,($-He)/U),pn=a((W-Te)/z,($-He)/U,(-W-Te)/z,(-$-He)/U)%(Math.PI*2);O.currentPath.absellipse(Ct,Ze,z,U,Pt,Pt+pn,C===0,F)}function a(O,z,U,F){const j=O*U+z*F,C=Math.sqrt(O*O+z*z)*Math.sqrt(U*U+F*F);let I=Math.acos(Math.max(-1,Math.min(1,j/C)));return O*F-z*U<0&&(I=-I),I}function c(O){const z=b(O.getAttribute("x")||0),U=b(O.getAttribute("y")||0),F=b(O.getAttribute("rx")||O.getAttribute("ry")||0),j=b(O.getAttribute("ry")||O.getAttribute("rx")||0),C=b(O.getAttribute("width")),I=b(O.getAttribute("height")),B=1-.551915024494,Z=new l.ShapePath;return Z.moveTo(z+F,U),Z.lineTo(z+C-F,U),(F!==0||j!==0)&&Z.bezierCurveTo(z+C-F*B,U,z+C,U+j*B,z+C,U+j),Z.lineTo(z+C,U+I-j),(F!==0||j!==0)&&Z.bezierCurveTo(z+C,U+I-j*B,z+C-F*B,U+I,z+C-F,U+I),Z.lineTo(z+F,U+I),(F!==0||j!==0)&&Z.bezierCurveTo(z+F*B,U+I,z,U+I-j*B,z,U+I-j),Z.lineTo(z,U+j),(F!==0||j!==0)&&Z.bezierCurveTo(z,U+j*B,z+F*B,U,z+F,U),Z}function h(O){function z(C,I,B){const Z=b(I),X=b(B);j===0?F.moveTo(Z,X):F.lineTo(Z,X),j++}const U=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,F=new l.ShapePath;let j=0;return O.getAttribute("points").replace(U,z),F.currentPath.autoClose=!0,F}function f(O){function z(C,I,B){const Z=b(I),X=b(B);j===0?F.moveTo(Z,X):F.lineTo(Z,X),j++}const U=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,F=new l.ShapePath;let j=0;return O.getAttribute("points").replace(U,z),F.currentPath.autoClose=!1,F}function d(O){const z=b(O.getAttribute("cx")||0),U=b(O.getAttribute("cy")||0),F=b(O.getAttribute("r")||0),j=new l.Path;j.absarc(z,U,F,0,Math.PI*2);const C=new l.ShapePath;return C.subPaths.push(j),C}function p(O){const z=b(O.getAttribute("cx")||0),U=b(O.getAttribute("cy")||0),F=b(O.getAttribute("rx")||0),j=b(O.getAttribute("ry")||0),C=new l.Path;C.absellipse(z,U,F,j,0,Math.PI*2);const I=new l.ShapePath;return I.subPaths.push(C),I}function g(O){const z=b(O.getAttribute("x1")||0),U=b(O.getAttribute("y1")||0),F=b(O.getAttribute("x2")||0),j=b(O.getAttribute("y2")||0),C=new l.ShapePath;return C.moveTo(z,U),C.lineTo(F,j),C.currentPath.autoClose=!1,C}function x(O,z){z=Object.assign({},z);let U={};if(O.hasAttribute("class")){const I=O.getAttribute("class").split(/\s/).filter(Boolean).map(B=>B.trim());for(let B=0;B<I.length;B++)U=Object.assign(U,R["."+I[B]])}O.hasAttribute("id")&&(U=Object.assign(U,R["#"+O.getAttribute("id")]));function F(I,B,Z){Z===void 0&&(Z=function(W){return W.startsWith("url")&&console.warn("SVGLoader: url access in attributes is not implemented."),W}),O.hasAttribute(I)&&(z[B]=Z(O.getAttribute(I))),U[I]&&(z[B]=Z(U[I])),O.style&&O.style[I]!==""&&(z[B]=Z(O.style[I]))}function j(I){return Math.max(0,Math.min(1,b(I)))}function C(I){return Math.max(0,b(I))}return F("fill","fill"),F("fill-opacity","fillOpacity",j),F("fill-rule","fillRule"),F("opacity","opacity",j),F("stroke","stroke"),F("stroke-opacity","strokeOpacity",j),F("stroke-width","strokeWidth",C),F("stroke-linejoin","strokeLineJoin"),F("stroke-linecap","strokeLineCap"),F("stroke-miterlimit","strokeMiterLimit",C),F("visibility","visibility"),z}function v(O,z){return O-(z-O)}function _(O,z,U){if(typeof O!="string")throw new TypeError("Invalid input: "+typeof O);const F={SEPARATOR:/[ \t\r\n\,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/[\d]/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/},j=0,C=1,I=2,B=3;let Z=j,X=!0,W="",$="";const re=[];function se(ue,ve,Oe){const Te=new SyntaxError('Unexpected character "'+ue+'" at index '+ve+".");throw Te.partial=Oe,Te}function E(){W!==""&&($===""?re.push(Number(W)):re.push(Number(W)*Math.pow(10,Number($)))),W="",$=""}let N;const ae=O.length;for(let ue=0;ue<ae;ue++){if(N=O[ue],Array.isArray(z)&&z.includes(re.length%U)&&F.FLAGS.test(N)){Z=C,W=N,E();continue}if(Z===j){if(F.WHITESPACE.test(N))continue;if(F.DIGIT.test(N)||F.SIGN.test(N)){Z=C,W=N;continue}if(F.POINT.test(N)){Z=I,W=N;continue}F.COMMA.test(N)&&(X&&se(N,ue,re),X=!0)}if(Z===C){if(F.DIGIT.test(N)){W+=N;continue}if(F.POINT.test(N)){W+=N,Z=I;continue}if(F.EXP.test(N)){Z=B;continue}F.SIGN.test(N)&&W.length===1&&F.SIGN.test(W[0])&&se(N,ue,re)}if(Z===I){if(F.DIGIT.test(N)){W+=N;continue}if(F.EXP.test(N)){Z=B;continue}F.POINT.test(N)&&W[W.length-1]==="."&&se(N,ue,re)}if(Z===B){if(F.DIGIT.test(N)){$+=N;continue}if(F.SIGN.test(N)){if($===""){$+=N;continue}$.length===1&&F.SIGN.test($)&&se(N,ue,re)}}F.WHITESPACE.test(N)?(E(),Z=j,X=!1):F.COMMA.test(N)?(E(),Z=j,X=!0):F.SIGN.test(N)?(E(),Z=C,W=N):F.POINT.test(N)?(E(),Z=I,W=N):se(N,ue,re)}return E(),re}const m=["mm","cm","in","pt","pc","px"],M={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 b(O){let z="px";if(typeof O=="string"||O instanceof String)for(let F=0,j=m.length;F<j;F++){const C=m[F];if(O.endsWith(C)){z=C,O=O.substring(0,O.length-C.length);break}}let U;return z==="px"&&t.defaultUnit!=="px"?U=M.in[t.defaultUnit]/t.defaultDPI:(U=M[z][t.defaultUnit],U<0&&(U=M[z].in*t.defaultDPI)),U*parseFloat(O)}function S(O){if(!(O.hasAttribute("transform")||O.nodeName==="use"&&(O.hasAttribute("x")||O.hasAttribute("y"))))return null;const z=L(O);return V.length>0&&z.premultiply(V[V.length-1]),le.copy(z),V.push(z),z}function L(O){const z=new l.Matrix3,U=Y;if(O.nodeName==="use"&&(O.hasAttribute("x")||O.hasAttribute("y"))){const F=b(O.getAttribute("x")),j=b(O.getAttribute("y"));z.translate(F,j)}if(O.hasAttribute("transform")){const F=O.getAttribute("transform").split(")");for(let j=F.length-1;j>=0;j--){const C=F[j].trim();if(C==="")continue;const I=C.indexOf("("),B=C.length;if(I>0&&I<B){const Z=C.slice(0,I),X=_(C.slice(I+1));switch(U.identity(),Z){case"translate":if(X.length>=1){const W=X[0];let $=0;X.length>=2&&($=X[1]),U.translate(W,$)}break;case"rotate":if(X.length>=1){let W=0,$=0,re=0;W=X[0]*Math.PI/180,X.length>=3&&($=X[1],re=X[2]),G.makeTranslation(-$,-re),Q.makeRotation(W),K.multiplyMatrices(Q,G),G.makeTranslation($,re),U.multiplyMatrices(G,K)}break;case"scale":if(X.length>=1){const W=X[0];let $=W;X.length>=2&&($=X[1]),U.scale(W,$)}break;case"skewX":X.length===1&&U.set(1,Math.tan(X[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":X.length===1&&U.set(1,0,0,Math.tan(X[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":X.length===6&&U.set(X[0],X[2],X[4],X[1],X[3],X[5],0,0,1);break}}z.premultiply(U)}}return z}function P(O,z){function U(I){ee.set(I.x,I.y,1).applyMatrix3(z),I.set(ee.x,ee.y)}function F(I){const B=I.xRadius,Z=I.yRadius,X=Math.cos(I.aRotation),W=Math.sin(I.aRotation),$=new l.Vector3(B*X,B*W,0),re=new l.Vector3(-Z*W,Z*X,0),se=$.applyMatrix3(z),E=re.applyMatrix3(z),N=Y.set(se.x,E.x,0,se.y,E.y,0,0,0,1),ae=G.copy(N).invert(),Oe=Q.copy(ae).transpose().multiply(ae).elements,Te=D(Oe[0],Oe[1],Oe[4]),He=Math.sqrt(Te.rt1),Ct=Math.sqrt(Te.rt2);if(I.xRadius=1/He,I.yRadius=1/Ct,I.aRotation=Math.atan2(Te.sn,Te.cs),!((I.aEndAngle-I.aStartAngle)%(2*Math.PI)<Number.EPSILON)){const Pt=G.set(He,0,0,0,Ct,0,0,0,1),pn=Q.set(Te.cs,Te.sn,0,-Te.sn,Te.cs,0,0,0,1),Zt=Pt.multiply(pn).multiply(N),mn=Rn=>{const{x:Wn,y:Yn}=new l.Vector3(Math.cos(Rn),Math.sin(Rn),0).applyMatrix3(Zt);return Math.atan2(Yn,Wn)};I.aStartAngle=mn(I.aStartAngle),I.aEndAngle=mn(I.aEndAngle),T(z)&&(I.aClockwise=!I.aClockwise)}}function j(I){const B=A(z),Z=w(z);I.xRadius*=B,I.yRadius*=Z;const X=B>Number.EPSILON?Math.atan2(z.elements[1],z.elements[0]):Math.atan2(-z.elements[3],z.elements[4]);I.aRotation+=X,T(z)&&(I.aStartAngle*=-1,I.aEndAngle*=-1,I.aClockwise=!I.aClockwise)}const C=O.subPaths;for(let I=0,B=C.length;I<B;I++){const X=C[I].curves;for(let W=0;W<X.length;W++){const $=X[W];$.isLineCurve?(U($.v1),U($.v2)):$.isCubicBezierCurve?(U($.v0),U($.v1),U($.v2),U($.v3)):$.isQuadraticBezierCurve?(U($.v0),U($.v1),U($.v2)):$.isEllipseCurve&&(ne.set($.aX,$.aY),U(ne),$.aX=ne.x,$.aY=ne.y,y(z)?F($):j($))}}}function T(O){const z=O.elements;return z[0]*z[4]-z[1]*z[3]<0}function y(O){const z=O.elements,U=z[0]*z[3]+z[1]*z[4];if(U===0)return!1;const F=A(O),j=w(O);return Math.abs(U/(F*j))>Number.EPSILON}function A(O){const z=O.elements;return Math.sqrt(z[0]*z[0]+z[1]*z[1])}function w(O){const z=O.elements;return Math.sqrt(z[3]*z[3]+z[4]*z[4])}function D(O,z,U){let F,j,C,I,B;const Z=O+U,X=O-U,W=Math.sqrt(X*X+4*z*z);return Z>0?(F=.5*(Z+W),B=1/F,j=O*B*U-z*B*z):Z<0?j=.5*(Z-W):(F=.5*W,j=-.5*W),X>0?C=X+W:C=X-W,Math.abs(C)>2*Math.abs(z)?(B=-2*z/C,I=1/Math.sqrt(1+B*B),C=B*I):Math.abs(z)===0?(C=1,I=0):(B=-.5*C/z,C=1/Math.sqrt(1+B*B),I=B*C),X>0&&(B=C,C=-I,I=B),{rt1:F,rt2:j,cs:C,sn:I}}const k=[],R={},V=[],Y=new l.Matrix3,G=new l.Matrix3,Q=new l.Matrix3,K=new l.Matrix3,ne=new l.Vector2,ee=new l.Vector3,le=new l.Matrix3,he=new DOMParser().parseFromString(e,"image/svg+xml");return n(he.documentElement,{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4}),{paths:k,xml:he.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,_,m,M){const b=v.x,S=_.x,L=m.x,P=M.x,T=v.y,y=_.y,A=m.y,w=M.y,D=(P-L)*(T-A)-(w-A)*(b-L),k=(S-b)*(T-A)-(y-T)*(b-L),R=(w-A)*(S-b)-(P-L)*(y-T),V=D/R,Y=k/R;if(R===0&&D!==0||V<=0||V>=1||Y<0||Y>1)return null;if(D===0&&R===0){for(let G=0;G<2;G++)if(i(G===0?m:M,v,_),r.loc==n.ORIGIN){const Q=G===0?m:M;return{x:Q.x,y:Q.y,t:r.t}}else if(r.loc==n.BETWEEN){const Q=+(b+r.t*(S-b)).toPrecision(10),K=+(T+r.t*(y-T)).toPrecision(10);return{x:Q,y:K,t:r.t}}return null}else{for(let K=0;K<2;K++)if(i(K===0?m:M,v,_),r.loc==n.ORIGIN){const ne=K===0?m:M;return{x:ne.x,y:ne.y,t:r.t}}const G=+(b+V*(S-b)).toPrecision(10),Q=+(T+V*(y-T)).toPrecision(10);return{x:G,y:Q,t:V}}}function i(v,_,m){const M=m.x-_.x,b=m.y-_.y,S=v.x-_.x,L=v.y-_.y,P=M*L-S*b;if(v.x===_.x&&v.y===_.y){r.loc=n.ORIGIN,r.t=0;return}if(v.x===m.x&&v.y===m.y){r.loc=n.DESTINATION,r.t=1;return}if(P<-Number.EPSILON){r.loc=n.LEFT;return}if(P>Number.EPSILON){r.loc=n.RIGHT;return}if(M*S<0||b*L<0){r.loc=n.BEHIND;return}if(Math.sqrt(M*M+b*b)<Math.sqrt(S*S+L*L)){r.loc=n.BEYOND;return}let T;M!==0?T=S/M:T=L/b,r.loc=n.BETWEEN,r.t=T}function a(v,_){const m=[],M=[];for(let b=1;b<v.length;b++){const S=v[b-1],L=v[b];for(let P=1;P<_.length;P++){const T=_[P-1],y=_[P],A=s(S,L,T,y);A!==null&&m.find(w=>w.t<=A.t+Number.EPSILON&&w.t>=A.t-Number.EPSILON)===void 0&&(m.push(A),M.push(new l.Vector2(A.x,A.y)))}}return M}function c(v,_,m){const M=new l.Vector2;_.getCenter(M);const b=[];return m.forEach(S=>{S.boundingBox.containsPoint(M)&&a(v,S.points).forEach(P=>{b.push({identifier:S.identifier,isCW:S.isCW,point:P})})}),b.sort((S,L)=>S.point.x-L.point.x),b}function h(v,_,m,M,b){(b==null||b==="")&&(b="nonzero");const S=new l.Vector2;v.boundingBox.getCenter(S);const L=[new l.Vector2(m,S.y),new l.Vector2(M,S.y)],P=c(L,v.boundingBox,_);P.sort((k,R)=>k.point.x-R.point.x);const T=[],y=[];P.forEach(k=>{k.identifier===v.identifier?T.push(k):y.push(k)});const A=T[0].point.x,w=[];let D=0;for(;D<y.length&&y[D].point.x<A;)w.length>0&&w[w.length-1]===y[D].identifier?w.pop():w.push(y[D].identifier),D++;if(w.push(v.identifier),b==="evenodd"){const k=w.length%2===0,R=w[w.length-2];return{identifier:v.identifier,isHole:k,for:R}}else if(b==="nonzero"){let k=!0,R=null,V=null;for(let Y=0;Y<w.length;Y++){const G=w[Y];k?(V=_[G].isCW,k=!1,R=G):V!==_[G].isCW&&(V=_[G].isCW,k=!0)}return{identifier:v.identifier,isHole:k,for:R}}else console.warn('fill-rule: "'+b+'" is currently not implemented.')}let f=999999999,d=-999999999,p=e.subPaths.map(v=>{const _=v.getPoints();let m=-999999999,M=999999999,b=-999999999,S=999999999;for(let L=0;L<_.length;L++){const P=_[L];P.y>m&&(m=P.y),P.y<M&&(M=P.y),P.x>b&&(b=P.x),P.x<S&&(S=P.x)}return d<=b&&(d=b+1),f>=S&&(f=S-1),{curves:v.curves,points:_,isCW:l.ShapeUtils.isClockWise(_),identifier:-1,boundingBox:new l.Box2(new l.Vector2(S,M),new l.Vector2(b,m))}});p=p.filter(v=>v.points.length>1);for(let v=0;v<p.length;v++)p[v].identifier=v;const g=p.map(v=>h(v,p,f,d,e.userData?e.userData.style.fillRule:void 0)),x=[];return p.forEach(v=>{if(!g[v.identifier].isHole){const m=new l.Shape;m.curves=v.curves,g.filter(b=>b.isHole&&b.for===v.identifier).forEach(b=>{const S=p[b.identifier],L=new l.Path;L.curves=S.curves,m.holes.push(L)}),x.push(m)}}),x}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(en.pointsToStrokeWithBuffers(e,t,n,r,s,i,a)===0)return null;const c=new l.BufferGeometry;return c.setAttribute("position",new l.Float32BufferAttribute(s,3)),c.setAttribute("normal",new l.Float32BufferAttribute(i,3)),c.setAttribute("uv",new l.Float32BufferAttribute(a,2)),c}static pointsToStrokeWithBuffers(e,t,n,r,s,i,a,c){const h=new l.Vector2,f=new l.Vector2,d=new l.Vector2,p=new l.Vector2,g=new l.Vector2,x=new l.Vector2,v=new l.Vector2,_=new l.Vector2,m=new l.Vector2,M=new l.Vector2,b=new l.Vector2,S=new l.Vector2,L=new l.Vector2,P=new l.Vector2,T=new l.Vector2,y=new l.Vector2,A=new l.Vector2;n=n!==void 0?n:12,r=r!==void 0?r:.001,c=c!==void 0?c:0,e=X(e);const w=e.length;if(w<2)return 0;const D=e[0].equals(e[w-1]);let k,R=e[0],V;const Y=t.strokeWidth/2,G=1/(w-1);let Q=0,K,ne,ee,le,he=!1,de=0,O=c*3,z=c*2;U(e[0],e[1],h).multiplyScalar(Y),_.copy(e[0]).sub(h),m.copy(e[0]).add(h),M.copy(_),b.copy(m);for(let W=1;W<w;W++){k=e[W],W===w-1?D?V=e[1]:V=void 0:V=e[W+1];const $=h;if(U(R,k,$),d.copy($).multiplyScalar(Y),S.copy(k).sub(d),L.copy(k).add(d),K=Q+G,ne=!1,V!==void 0){U(k,V,f),d.copy(f).multiplyScalar(Y),P.copy(k).sub(d),T.copy(k).add(d),ee=!0,d.subVectors(V,R),$.dot(d)<0&&(ee=!1),W===1&&(he=ee),d.subVectors(V,k),d.normalize();const re=Math.abs($.dot(d));if(re>Number.EPSILON){const se=Y/re;d.multiplyScalar(-se),p.subVectors(k,R),g.copy(p).setLength(se).add(d),y.copy(g).negate();const E=g.length(),N=p.length();p.divideScalar(N),x.subVectors(V,k);const ae=x.length();switch(x.divideScalar(ae),p.dot(y)<N&&x.dot(y)<ae&&(ne=!0),A.copy(g).add(k),y.add(k),le=!1,ne?ee?(T.copy(y),L.copy(y)):(P.copy(y),S.copy(y)):C(),t.strokeLineJoin){case"bevel":I(ee,ne,K);break;case"round":B(ee,ne),ee?j(k,S,P,K,0):j(k,T,L,K,1);break;case"miter":case"miter-clip":default:const ue=Y*t.strokeMiterLimit/E;if(ue<1)if(t.strokeLineJoin!=="miter-clip"){I(ee,ne,K);break}else B(ee,ne),ee?(x.subVectors(A,S).multiplyScalar(ue).add(S),v.subVectors(A,P).multiplyScalar(ue).add(P),F(S,K,0),F(x,K,0),F(k,K,.5),F(k,K,.5),F(x,K,0),F(v,K,0),F(k,K,.5),F(v,K,0),F(P,K,0)):(x.subVectors(A,L).multiplyScalar(ue).add(L),v.subVectors(A,T).multiplyScalar(ue).add(T),F(L,K,1),F(x,K,1),F(k,K,.5),F(k,K,.5),F(x,K,1),F(v,K,1),F(k,K,.5),F(v,K,1),F(T,K,1));else ne?(ee?(F(m,Q,1),F(_,Q,0),F(A,K,0),F(m,Q,1),F(A,K,0),F(y,K,1)):(F(m,Q,1),F(_,Q,0),F(A,K,1),F(_,Q,0),F(y,K,0),F(A,K,1)),ee?P.copy(A):T.copy(A)):ee?(F(S,K,0),F(A,K,0),F(k,K,.5),F(k,K,.5),F(A,K,0),F(P,K,0)):(F(L,K,1),F(A,K,1),F(k,K,.5),F(k,K,.5),F(A,K,1),F(T,K,1)),le=!0;break}}else C()}else C();!D&&W===w-1&&Z(e[0],M,b,ee,!0,Q),Q=K,R=k,_.copy(P),m.copy(T)}if(!D)Z(k,S,L,ee,!1,K);else if(ne&&s){let W=A,$=y;he!==ee&&(W=y,$=A),ee?(le||he)&&($.toArray(s,0*3),$.toArray(s,3*3),le&&W.toArray(s,1*3)):(le||!he)&&($.toArray(s,1*3),$.toArray(s,3*3),le&&W.toArray(s,0*3))}return de;function U(W,$,re){return re.subVectors($,W),re.set(-re.y,re.x).normalize()}function F(W,$,re){s&&(s[O]=W.x,s[O+1]=W.y,s[O+2]=0,i&&(i[O]=0,i[O+1]=0,i[O+2]=1),O+=3,a&&(a[z]=$,a[z+1]=re,z+=2)),de+=3}function j(W,$,re,se,E){h.copy($).sub(W).normalize(),f.copy(re).sub(W).normalize();let N=Math.PI;const ae=h.dot(f);Math.abs(ae)<1&&(N=Math.abs(Math.acos(ae))),N/=n,d.copy($);for(let ue=0,ve=n-1;ue<ve;ue++)p.copy(d).rotateAround(W,N),F(d,se,E),F(p,se,E),F(W,se,.5),d.copy(p);F(p,se,E),F(re,se,E),F(W,se,.5)}function C(){F(m,Q,1),F(_,Q,0),F(S,K,0),F(m,Q,1),F(S,K,0),F(L,K,1)}function I(W,$,re){$?W?(F(m,Q,1),F(_,Q,0),F(S,K,0),F(m,Q,1),F(S,K,0),F(y,K,1),F(S,re,0),F(P,re,0),F(y,re,.5)):(F(m,Q,1),F(_,Q,0),F(L,K,1),F(_,Q,0),F(y,K,0),F(L,K,1),F(L,re,1),F(y,re,0),F(T,re,1)):W?(F(S,re,0),F(P,re,0),F(k,re,.5)):(F(L,re,1),F(T,re,0),F(k,re,.5))}function B(W,$){$&&(W?(F(m,Q,1),F(_,Q,0),F(S,K,0),F(m,Q,1),F(S,K,0),F(y,K,1),F(S,Q,0),F(k,K,.5),F(y,K,1),F(k,K,.5),F(P,Q,0),F(y,K,1)):(F(m,Q,1),F(_,Q,0),F(L,K,1),F(_,Q,0),F(y,K,0),F(L,K,1),F(L,Q,1),F(y,K,0),F(k,K,.5),F(k,K,.5),F(y,K,0),F(T,Q,1)))}function Z(W,$,re,se,E,N){switch(t.strokeLineCap){case"round":E?j(W,re,$,N,.5):j(W,$,re,N,.5);break;case"square":if(E)h.subVectors($,W),f.set(h.y,-h.x),d.addVectors(h,f).add(W),p.subVectors(f,h).add(W),se?(d.toArray(s,1*3),p.toArray(s,0*3),p.toArray(s,3*3)):(d.toArray(s,1*3),a[3*2+1]===1?p.toArray(s,3*3):d.toArray(s,3*3),p.toArray(s,0*3));else{h.subVectors(re,W),f.set(h.y,-h.x),d.addVectors(h,f).add(W),p.subVectors(f,h).add(W);const ae=s.length;se?(d.toArray(s,ae-1*3),p.toArray(s,ae-2*3),p.toArray(s,ae-4*3)):(p.toArray(s,ae-2*3),d.toArray(s,ae-1*3),p.toArray(s,ae-4*3))}break}}function X(W){let $=!1;for(let se=1,E=W.length-1;se<E;se++)if(W[se].distanceTo(W[se+1])<r){$=!0;break}if(!$)return W;const re=[];re.push(W[0]);for(let se=1,E=W.length-1;se<E;se++)W[se].distanceTo(W[se+1])>=r&&re.push(W[se]);return re.push(W[W.length-1]),re}}}const hr=new WeakMap;class al extends l.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 l.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 c in t.attributeTypes){const h=t.attributeTypes[c];h.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[c]=h.name)}const n=JSON.stringify(t);if(hr.has(e)){const c=hr.get(e);if(c.key===n)return c.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(c=>(r=c,new Promise((h,f)=>{r._callbacks[s]={resolve:h,reject:f},r.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return a.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),hr.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new l.BufferGeometry;e.index&&t.setIndex(new l.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 l.BufferAttribute(i,a))}return t}_loadLibrary(e,t){const n=new l.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=ll.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 ll(){let o,e;onmessage=function(i){const a=i.data;switch(a.type){case"init":o=a.decoderConfig,e=new Promise(function(f){o.onModuleLoaded=function(d){f({draco:d})},DracoDecoderModule(o)});break;case"decode":const c=a.buffer,h=a.taskConfig;e.then(f=>{const d=f.draco,p=new d.Decoder,g=new d.DecoderBuffer;g.Init(new Int8Array(c),c.byteLength);try{const x=t(d,p,g,h),v=x.attributes.map(_=>_.array.buffer);x.index&&v.push(x.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:x},v)}catch(x){console.error(x),self.postMessage({type:"error",id:a.id,error:x.message})}finally{d.destroy(g),d.destroy(p)}});break}};function t(i,a,c,h){const f=h.attributeIDs,d=h.attributeTypes;let p,g;const x=a.GetEncodedGeometryType(c);if(x===i.TRIANGULAR_MESH)p=new i.Mesh,g=a.DecodeBufferToMesh(c,p);else if(x===i.POINT_CLOUD)p=new i.PointCloud,g=a.DecodeBufferToPointCloud(c,p);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!g.ok()||p.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+g.error_msg());const v={index:null,attributes:[]};for(const _ in f){const m=self[d[_]];let M,b;if(h.useUniqueIDs)b=f[_],M=a.GetAttributeByUniqueId(p,b);else{if(b=a.GetAttributeId(p,i[f[_]]),b===-1)continue;M=a.GetAttribute(p,b)}v.attributes.push(r(i,a,p,_,m,M))}return x===i.TRIANGULAR_MESH&&(v.index=n(i,a,p)),i.destroy(p),v}function n(i,a,c){const f=c.num_faces()*3,d=f*4,p=i._malloc(d);a.GetTrianglesUInt32Array(c,d,p);const g=new Uint32Array(i.HEAPF32.buffer,p,f).slice();return i._free(p),{array:g,itemSize:1}}function r(i,a,c,h,f,d){const p=d.num_components(),x=c.num_points()*p,v=x*f.BYTES_PER_ELEMENT,_=s(i,f),m=i._malloc(v);a.GetAttributeDataArrayForAllPoints(c,d,_,v,m);const M=new f(i.HEAPF32.buffer,m,x).slice();return i._free(m),{name:h,array:M,itemSize:p}}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 ks extends l.Line{constructor(e,t){const n=[1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],r=new l.BufferGeometry;r.setAttribute("position",new l.Float32BufferAttribute(n,3)),r.computeBoundingSphere();const s=new l.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 l.BufferGeometry;a.setAttribute("position",new l.Float32BufferAttribute(i,3)),a.computeBoundingSphere(),this.add(new l.Mesh(a,new l.MeshBasicMaterial({side:l.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 cl=["args","center"],ul=u.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:c,size:h,height:f,curveSegments:d,bevelEnabled:p,bevelThickness:g,bevelSize:x,bevelOffset:v,bevelSegments:_}=u.toRefs(r),{extend:m}=ie.useTresContext();m({TextGeometry:bs});const M=new rl,b=u.useSlots(),S=u.computed(()=>{var y;return a!=null&&a.value?a.value:b.default?(y=b.default()[0].children)==null?void 0:y.trim():c.value?"":"TresJS"}),L=u.shallowRef();e({value:L});const P=([t,n]=u.withAsyncContext(()=>new Promise((y,A)=>{try{typeof i.value=="string"?M.load(i.value,w=>{y(w)}):y(i.value)}catch(w){A(console.error("cientos",w))}})),t=await t,n(),t),T=u.computed(()=>({font:P,size:u.toValue(h),height:u.toValue(f),curveSegments:u.toValue(d),bevelEnabled:u.toValue(p),bevelThickness:u.toValue(g),bevelSize:u.toValue(x),bevelOffset:u.toValue(v),bevelSegments:u.toValue(_)}));return u.watchEffect(()=>{L.value&&c.value&&(L.value.geometry.dispose(),L.value.geometry=new bs(S.value,T.value),s.value&&L.value.geometry.center())}),(y,A)=>u.unref(i)?(u.openBlock(),u.createElementBlock("TresMesh",{key:0,ref_key:"text3DRef",ref:L},[S.value?(u.openBlock(),u.createElementBlock("TresTextGeometry",{key:0,args:[S.value,T.value],center:u.unref(s)},null,8,cl)):u.createCommentVNode("",!0),u.renderSlot(y.$slots,"default")],512)):u.createCommentVNode("",!0)}});function hl(o,e){const t=u.ref(e),n=new l.AnimationMixer(t.value),r=u.shallowReactive({});o.forEach(i=>{const a=n.clipAction(i,t.value);r[i.name]=a});const{onLoop:s}=ie.useRenderLoop();return s(({delta:i})=>{n.update(i)}),{actions:r,mixer:n}}const fl=u.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=u.shallowRef();e({value:n});{const c=Math.random()*1e4,{onLoop:h}=ie.useRenderLoop();let f=c;h(({delta:d})=>{if(!n.value)return;f+=d*t.speed;const p=f*.25,g=n.value;g.rotation.x=Math.cos(p)*.125*t.rotationFactor,g.rotation.y=Math.sin(p)*.125*t.rotationFactor,g.rotation.z=Math.sin(p)*.05*t.rotationFactor,g.position.y=l.MathUtils.mapLinear(Math.sin(p),-1,1,t.range[0],t.range[1])*t.floatFactor})}return(r,s)=>(u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps(r.$attrs,{ref_key:"groupRef",ref:n}),[u.renderSlot(r.$slots,"default")],16))}});class tn extends l.Mesh{constructor(e,t={}){super(e),this.isReflector=!0,this.type="Reflector",this.camera=new l.PerspectiveCamera;const n=this,r=t.color!==void 0?new l.Color(t.color):new l.Color(8355711),s=t.textureWidth||512,i=t.textureHeight||512,a=t.clipBias||0,c=t.shader||tn.ReflectorShader,h=t.multisample!==void 0?t.multisample:4,f=new l.Plane,d=new l.Vector3,p=new l.Vector3,g=new l.Vector3,x=new l.Matrix4,v=new l.Vector3(0,0,-1),_=new l.Vector4,m=new l.Vector3,M=new l.Vector3,b=new l.Vector4,S=new l.Matrix4,L=this.camera,P=new l.WebGLRenderTarget(s,i,{samples:h,type:l.HalfFloatType}),T=new l.ShaderMaterial({name:c.name!==void 0?c.name:"unspecified",uniforms:l.UniformsUtils.clone(c.uniforms),fragmentShader:c.fragmentShader,vertexShader:c.vertexShader});T.uniforms.tDiffuse.value=P.texture,T.uniforms.color.value=r,T.uniforms.textureMatrix.value=S,this.material=T,this.onBeforeRender=function(y,A,w){if(p.setFromMatrixPosition(n.matrixWorld),g.setFromMatrixPosition(w.matrixWorld),x.extractRotation(n.matrixWorld),d.set(0,0,1),d.applyMatrix4(x),m.subVectors(p,g),m.dot(d)>0)return;m.reflect(d).negate(),m.add(p),x.extractRotation(w.matrixWorld),v.set(0,0,-1),v.applyMatrix4(x),v.add(g),M.subVectors(p,v),M.reflect(d).negate(),M.add(p),L.position.copy(m),L.up.set(0,1,0),L.up.applyMatrix4(x),L.up.reflect(d),L.lookAt(M),L.far=w.far,L.updateMatrixWorld(),L.projectionMatrix.copy(w.projectionMatrix),S.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),S.multiply(L.projectionMatrix),S.multiply(L.matrixWorldInverse),S.multiply(n.matrixWorld),f.setFromNormalAndCoplanarPoint(d,p),f.applyMatrix4(L.matrixWorldInverse),_.set(f.normal.x,f.normal.y,f.normal.z,f.constant);const D=L.projectionMatrix;b.x=(Math.sign(_.x)+D.elements[8])/D.elements[0],b.y=(Math.sign(_.y)+D.elements[9])/D.elements[5],b.z=-1,b.w=(1+D.elements[10])/D.elements[14],_.multiplyScalar(2/_.dot(b)),D.elements[2]=_.x,D.elements[6]=_.y,D.elements[10]=_.z+1-a,D.elements[14]=_.w,n.visible=!1;const k=y.getRenderTarget(),R=y.xr.enabled,V=y.shadowMap.autoUpdate;y.xr.enabled=!1,y.shadowMap.autoUpdate=!1,y.setRenderTarget(P),y.state.buffers.depth.setMask(!0),y.autoClear===!1&&y.clear(),y.render(A,L),y.xr.enabled=R,y.shadowMap.autoUpdate=V,y.setRenderTarget(k);const Y=w.viewport;Y!==void 0&&y.state.viewport(Y),n.visible=!0},this.getRenderTarget=function(){return P},this.dispose=function(){P.dispose(),n.material.dispose()}}}tn.ReflectorShader={name:"ReflectorShader",uniforms:{color:{value:null},tDiffuse:{value:null},textureMatrix:{value:null}},vertexShader:`
|
|
99
|
-
uniform mat4 textureMatrix;
|
|
100
|
-
varying vec4 vUv;
|
|
101
|
-
|
|
102
|
-
#include <common>
|
|
103
|
-
#include <logdepthbuf_pars_vertex>
|
|
104
|
-
|
|
105
|
-
void main() {
|
|
106
|
-
|
|
107
|
-
vUv = textureMatrix * vec4( position, 1.0 );
|
|
108
|
-
|
|
109
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
110
|
-
|
|
111
|
-
#include <logdepthbuf_vertex>
|
|
112
|
-
|
|
113
|
-
}`,fragmentShader:`
|
|
114
|
-
uniform vec3 color;
|
|
115
|
-
uniform sampler2D tDiffuse;
|
|
116
|
-
varying vec4 vUv;
|
|
117
|
-
|
|
118
|
-
#include <logdepthbuf_pars_fragment>
|
|
119
|
-
|
|
120
|
-
float blendOverlay( float base, float blend ) {
|
|
121
|
-
|
|
122
|
-
return( base < 0.5 ? ( 2.0 * base * blend ) : ( 1.0 - 2.0 * ( 1.0 - base ) * ( 1.0 - blend ) ) );
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
vec3 blendOverlay( vec3 base, vec3 blend ) {
|
|
127
|
-
|
|
128
|
-
return vec3( blendOverlay( base.r, blend.r ), blendOverlay( base.g, blend.g ), blendOverlay( base.b, blend.b ) );
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
void main() {
|
|
133
|
-
|
|
134
|
-
#include <logdepthbuf_fragment>
|
|
135
|
-
|
|
136
|
-
vec4 base = texture2DProj( tDiffuse, vUv );
|
|
137
|
-
gl_FragColor = vec4( blendOverlay( base.rgb, color ), 1.0 );
|
|
138
|
-
|
|
139
|
-
#include <tonemapping_fragment>
|
|
140
|
-
#include <colorspace_fragment>
|
|
141
|
-
|
|
142
|
-
}`};const dl=["args","material-uniforms-color-value"],pl=u.createElementVNode("TresPlaneGeometry",{args:[5,5]},null,-1),ml=u.defineComponent({__name:"Reflector",props:{color:{default:"#333"},textureWidth:{default:512},textureHeight:{default:512},clipBias:{default:0},multisample:{default:4},shader:{default:tn.ReflectorShader}},setup(o,{expose:e}){const t=o,{extend:n}=ie.useTresContext(),r=u.shallowRef();n({Reflector:tn});const{color:s,textureWidth:i,textureHeight:a,clipBias:c,multisample:h,shader:f}=u.toRefs(t);return e({reflectorRef:r}),(d,p)=>(u.openBlock(),u.createElementBlock("TresReflector",{ref_key:"reflectorRef",ref:r,args:[void 0,{textureWidth:u.unref(i),textureHeight:u.unref(a),clipBias:u.unref(c),multisample:u.unref(h),shader:u.unref(f)}],"material-uniforms-color-value":u.unref(s)},[u.renderSlot(d.$slots,"default",{},()=>[pl])],8,dl))}});function fr(o){return u.getCurrentScope()?(u.onScopeDispose(o),!0):!1}function Xe(o){return typeof o=="function"?o():u.unref(o)}const gl=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const yl=Object.prototype.toString,vl=o=>yl.call(o)==="[object Object]",Lt=()=>{};function dr(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 _l=o=>o();function xl(o,e={}){let t,n,r=Lt;const s=a=>{clearTimeout(a),r(),r=Lt};return a=>{const c=Xe(o),h=Xe(e.maxWait);return t&&s(t),c<=0||h!==void 0&&h<=0?(n&&(s(n),n=null),Promise.resolve(a())):new Promise((f,d)=>{r=e.rejectOnCancel?d:f,h&&!n&&(n=setTimeout(()=>{t&&s(t),n=null,f(a())},h)),t=setTimeout(()=>{n&&s(n),n=null,f(a())},c)})}}function Bs(...o){let e=0,t,n=!0,r=Lt,s,i,a,c,h;!u.isRef(o[0])&&typeof o[0]=="object"?{delay:i,trailing:a=!0,leading:c=!0,rejectOnCancel:h=!1}=o[0]:[i,a=!0,c=!0,h=!1]=o;const f=()=>{t&&(clearTimeout(t),t=void 0,r(),r=Lt)};return p=>{const g=Xe(i),x=Date.now()-e,v=()=>s=p();return f(),g<=0?(e=Date.now(),v()):(x>g&&(c||!n)?(e=Date.now(),v()):a&&(s=new Promise((_,m)=>{r=h?m:_,t=setTimeout(()=>{e=Date.now(),n=!0,_(v()),f()},Math.max(0,g-x))})),!c&&!t&&(t=setTimeout(()=>n=!0,g)),n=!1,s)}}function wl(o){return u.getCurrentInstance()}function bl(o,e=200,t={}){return dr(xl(e,t),o)}function Ml(o,e=200,t=!1,n=!0,r=!1){return dr(Bs(e,t,n,r),o)}function Sl(o,e,t={}){const{eventFilter:n=_l,...r}=t;return u.watch(o,dr(n,e),r)}function pr(o,e=!0,t){wl()?u.onMounted(o,t):e?o():u.nextTick(o)}function Al(o,e,t={}){const{throttle:n=0,trailing:r=!0,leading:s=!0,...i}=t;return Sl(o,e,{...i,eventFilter:Bs(n,r,s)})}function _t(o){var e;const t=Xe(o);return(e=t==null?void 0:t.$el)!=null?e:t}const lt=gl?window:void 0;function Ie(...o){let e,t,n,r;if(typeof o[0]=="string"||Array.isArray(o[0])?([t,n,r]=o,e=lt):[e,t,n,r]=o,!e)return Lt;Array.isArray(t)||(t=[t]),Array.isArray(n)||(n=[n]);const s=[],i=()=>{s.forEach(f=>f()),s.length=0},a=(f,d,p,g)=>(f.addEventListener(d,p,g),()=>f.removeEventListener(d,p,g)),c=u.watch(()=>[_t(e),Xe(r)],([f,d])=>{if(i(),!f)return;const p=vl(d)?{...d}:d;s.push(...t.flatMap(g=>n.map(x=>a(f,g,x,p))))},{immediate:!0,flush:"post"}),h=()=>{c(),i()};return fr(h),h}function Cl(o){return typeof o=="function"?o:typeof o=="string"?e=>e.key===o:Array.isArray(o)?e=>o.includes(e.key):()=>!0}function Ot(...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=lt,eventName:s="keydown",passive:i=!1,dedupe:a=!1}=n,c=Cl(e);return Ie(r,s,f=>{f.repeat&&Xe(a)||c(f)&&t(f)},i)}function Pl(){const o=u.ref(!1),e=u.getCurrentInstance();return e&&u.onMounted(()=>{o.value=!0},e),o}function Fs(o){const e=Pl();return u.computed(()=>(e.value,!!o()))}function Tl(o,e={}){const{window:t=lt}=e,n=Fs(()=>t&&"matchMedia"in t&&typeof t.matchMedia=="function");let r;const s=u.ref(!1),i=h=>{s.value=h.matches},a=()=>{r&&("removeEventListener"in r?r.removeEventListener("change",i):r.removeListener(i))},c=u.watchEffect(()=>{n.value&&(a(),r=t.matchMedia(Xe(o)),"addEventListener"in r?r.addEventListener("change",i):r.addListener(i),s.value=r.matches)});return fr(()=>{c(),a(),r=void 0}),s}function Il(o,e,t={}){const{window:n=lt,...r}=t;let s;const i=Fs(()=>n&&"ResizeObserver"in n),a=()=>{s&&(s.disconnect(),s=void 0)},c=u.computed(()=>Array.isArray(o)?o.map(d=>_t(d)):[_t(o)]),h=u.watch(c,d=>{if(a(),i.value&&n){s=new ResizeObserver(e);for(const p of d)p&&s.observe(p,r)}},{immediate:!0,flush:"post"}),f=()=>{a(),h()};return fr(f),{isSupported:i,stop:f}}function Ll(o,e={width:0,height:0},t={}){const{window:n=lt,box:r="content-box"}=t,s=u.computed(()=>{var d,p;return(p=(d=_t(o))==null?void 0:d.namespaceURI)==null?void 0:p.includes("svg")}),i=u.ref(e.width),a=u.ref(e.height),{stop:c}=Il(o,([d])=>{const p=r==="border-box"?d.borderBoxSize:r==="content-box"?d.contentBoxSize:d.devicePixelContentBoxSize;if(n&&s.value){const g=_t(o);if(g){const x=n.getComputedStyle(g);i.value=Number.parseFloat(x.width),a.value=Number.parseFloat(x.height)}}else if(p){const g=Array.isArray(p)?p:[p];i.value=g.reduce((x,{inlineSize:v})=>x+v,0),a.value=g.reduce((x,{blockSize:v})=>x+v,0)}else i.value=d.contentRect.width,a.value=d.contentRect.height},t);pr(()=>{const d=_t(o);d&&(i.value="offsetWidth"in d?d.offsetWidth:e.width,a.value="offsetHeight"in d?d.offsetHeight:e.height)});const h=u.watch(()=>_t(o),d=>{i.value=d?e.width:0,a.value=d?e.height:0});function f(){c(),h()}return{width:i,height:a,stop:f}}const Us=1;function Ol(o,e={}){const{throttle:t=0,idle:n=200,onStop:r=Lt,onScroll:s=Lt,offset:i={left:0,right:0,top:0,bottom:0},eventListenerOptions:a={capture:!1,passive:!0},behavior:c="auto",window:h=lt,onError:f=T=>{console.error(T)}}=e,d=u.ref(0),p=u.ref(0),g=u.computed({get(){return d.value},set(T){v(T,void 0)}}),x=u.computed({get(){return p.value},set(T){v(void 0,T)}});function v(T,y){var A,w,D;if(!h)return;const k=Xe(o);k&&((D=k instanceof Document?h.document.body:k)==null||D.scrollTo({top:(A=Xe(y))!=null?A:x.value,left:(w=Xe(T))!=null?w:g.value,behavior:Xe(c)}))}const _=u.ref(!1),m=u.reactive({left:!0,right:!1,top:!0,bottom:!1}),M=u.reactive({left:!1,right:!1,top:!1,bottom:!1}),b=T=>{_.value&&(_.value=!1,M.left=!1,M.right=!1,M.top=!1,M.bottom=!1,r(T))},S=bl(b,t+n),L=T=>{var y;if(!h)return;const A=((y=T==null?void 0:T.document)==null?void 0:y.documentElement)||(T==null?void 0:T.documentElement)||_t(T),{display:w,flexDirection:D}=getComputedStyle(A),k=A.scrollLeft;M.left=k<d.value,M.right=k>d.value;const R=Math.abs(k)<=(i.left||0),V=Math.abs(k)+A.clientWidth>=A.scrollWidth-(i.right||0)-Us;w==="flex"&&D==="row-reverse"?(m.left=V,m.right=R):(m.left=R,m.right=V),d.value=k;let Y=A.scrollTop;T===h.document&&!Y&&(Y=h.document.body.scrollTop),M.top=Y<p.value,M.bottom=Y>p.value;const G=Math.abs(Y)<=(i.top||0),Q=Math.abs(Y)+A.clientHeight>=A.scrollHeight-(i.bottom||0)-Us;w==="flex"&&D==="column-reverse"?(m.top=Q,m.bottom=G):(m.top=G,m.bottom=Q),p.value=Y},P=T=>{var y;if(!h)return;const A=(y=T.target.documentElement)!=null?y:T.target;L(A),_.value=!0,S(T),s(T)};return Ie(o,"scroll",t?Ml(P,t,!0,!1):P,a),pr(()=>{try{const T=Xe(o);if(!T)return;L(T)}catch(T){f(T)}}),Ie(o,"scrollend",b,a),{x:g,y:x,isScrolling:_,arrivedState:m,directions:M,measure(){const T=Xe(o);h&&T&&L(T)}}}const Dl={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 kl(o={}){const{type:e="page",touch:t=!0,resetOnTouchEnds:n=!1,initialValue:r={x:0,y:0},window:s=lt,target:i=s,scroll:a=!0,eventFilter:c}=o;let h=null;const f=u.ref(r.x),d=u.ref(r.y),p=u.ref(null),g=typeof e=="function"?e:Dl[e],x=L=>{const P=g(L);h=L,P&&([f.value,d.value]=P,p.value="mouse")},v=L=>{if(L.touches.length>0){const P=g(L.touches[0]);P&&([f.value,d.value]=P,p.value="touch")}},_=()=>{if(!h||!s)return;const L=g(h);h instanceof MouseEvent&&L&&(f.value=L[0]+s.scrollX,d.value=L[1]+s.scrollY)},m=()=>{f.value=r.x,d.value=r.y},M=c?L=>c(()=>x(L),{}):L=>x(L),b=c?L=>c(()=>v(L),{}):L=>v(L),S=c?()=>c(()=>_(),{}):()=>_();if(i){const L={passive:!0};Ie(i,["mousemove","dragover"],M,L),t&&e!=="movement"&&(Ie(i,["touchstart","touchmove"],b,L),n&&Ie(i,"touchend",m,L)),a&&e==="page"&&Ie(s,"scroll",S,{passive:!0})}return{x:f,y:d,sourceType:p}}function Bl(o={}){const{window:e=lt,behavior:t="auto"}=o;if(!e)return{x:u.ref(0),y:u.ref(0)};const n=u.ref(e.scrollX),r=u.ref(e.scrollY),s=u.computed({get(){return n.value},set(a){scrollTo({left:a,behavior:t})}}),i=u.computed({get(){return r.value},set(a){scrollTo({top:a,behavior:t})}});return Ie(e,"scroll",()=>{n.value=e.scrollX,r.value=e.scrollY},{capture:!1,passive:!0}),{x:s,y:i}}function Ns(o={}){const{window:e=lt,initialWidth:t=Number.POSITIVE_INFINITY,initialHeight:n=Number.POSITIVE_INFINITY,listenOrientation:r=!0,includeScrollbar:s=!0}=o,i=u.ref(t),a=u.ref(n),c=()=>{e&&(s?(i.value=e.innerWidth,a.value=e.innerHeight):(i.value=e.document.documentElement.clientWidth,a.value=e.document.documentElement.clientHeight))};if(c(),pr(c),Ie("resize",c,{passive:!0}),r){const h=Tl("(orientation: portrait)");u.watch(h,()=>c())}return{width:i,height:a}}const Fl=u.defineComponent({__name:"MouseParallax",props:{disabled:{type:Boolean,default:!1},factor:{default:2.5},ease:{default:.1},local:{type:Boolean,default:!1}},setup(o){const e=o,{camera:t,renderer:n}=ie.useTresContext(),{disabled:r,factor:s,ease:i,local:a}=u.toRefs(e),c={};a.value&&(c.target=n.value.domElement,c.type="client");const{x:h,y:f}=kl(c),{width:d,height:p}=a.value?Ll(n.value.domElement):Ns(),g=u.ref(),x=u.computed(()=>(h.value/d.value-.5)*s.value),v=u.computed(()=>-(f.value/p.value-.5)*s.value),{onLoop:_}=ie.useRenderLoop();return _(({delta:m})=>{r.value||!g.value||Number.isNaN(x.value)||Number.isNaN(v.value)||(g.value.position.x+=(x.value-g.value.position.x)*i.value*m,g.value.position.y+=(v.value-g.value.position.y)*i.value*m)}),u.watch(()=>g.value,m=>m==null?void 0:m.add(t.value)),(m,M)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"cameraGroupRef",ref:g},null,512))}}),Ul=u.defineComponent({name:"GlobalAudio",props:["src","loop","volume","playbackRate","playTrigger","stopTrigger"],async setup(o,{expose:e,emit:t}){var d;const{camera:n,renderer:r}=ie.useTresContext(),s=new l.AudioListener;(d=n.value)==null||d.add(s);const i=new l.Audio(s),a=new l.AudioLoader;e({sound:i}),u.onUnmounted(()=>{i&&i.disconnect()}),u.watch(()=>[o.playbackRate],()=>i.setPlaybackRate(o.playbackRate??1),{immediate:!0}),u.watch(()=>[o.volume],()=>i.setVolume(o.volume??.5),{immediate:!0}),u.watch(()=>[o.loop],()=>i.setLoop(o.loop??!1),{immediate:!0}),u.watch(()=>[o.src],async()=>{const p=await a.loadAsync(o.src);i.setBuffer(p)},{immediate:!0});const h=document.getElementById(o.playTrigger??"")||r.value.domElement;Ie(h,"click",()=>{i.isPlaying?i.pause():i.play(),t("isPlaying",i.isPlaying)});const f=document.getElementById(o.stopTrigger??"");return f&&Ie(f,"click",()=>{i.stop(),t("isPlaying",i.isPlaying)}),null}});class nn extends l.Mesh{constructor(){super(nn.Geometry,new l.MeshBasicMaterial({opacity:0,transparent:!0})),this.isLensflare=!0,this.type="Lensflare",this.frustumCulled=!1,this.renderOrder=1/0;const e=new l.Vector3,t=new l.Vector3,n=new l.FramebufferTexture(16,16),r=new l.FramebufferTexture(16,16);let s=l.UnsignedByteType;const i=nn.Geometry,a=new l.RawShaderMaterial({uniforms:{scale:{value:null},screenPosition:{value:null}},vertexShader:`
|
|
389
|
+
`};function Is(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 Ha(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 c=0;for(let h=0;h<a;++h){const d=i[h+1],f=s[a-h],p=r[h]/(d+f);r[h]=c+d*p,c=f*p}r[a]=c}return r}function $a(o,e,t,n){const r=Is(o,n,e),s=Ha(r,n,o,e),i=new l.Vector4(0,0,0,0);for(let a=0;a<=o;++a){const c=t[r-o+a],h=s[a],d=c.w*h;i.x+=c.x*d,i.y+=c.y*d,i.z+=c.z*d,i.w+=c.w*h}return i}function el(o,e,t,n,r){const s=[];for(let f=0;f<=t;++f)s[f]=0;const i=[];for(let f=0;f<=n;++f)i[f]=s.slice(0);const a=[];for(let f=0;f<=t;++f)a[f]=s.slice(0);a[0][0]=1;const c=s.slice(0),h=s.slice(0);for(let f=1;f<=t;++f){c[f]=e-r[o+1-f],h[f]=r[o+f]-e;let p=0;for(let m=0;m<f;++m){const _=h[m+1],v=c[f-m];a[f][m]=_+v;const y=a[m][f-1]/a[f][m];a[m][f]=p+_*y,p=v*y}a[f][f]=p}for(let f=0;f<=t;++f)i[0][f]=a[f][t];for(let f=0;f<=t;++f){let p=0,m=1;const _=[];for(let v=0;v<=t;++v)_[v]=s.slice(0);_[0][0]=1;for(let v=1;v<=n;++v){let y=0;const g=f-v,M=t-v;f>=v&&(_[m][0]=_[p][0]/a[M+1][g],y=_[m][0]*a[g][M]);const b=g>=-1?1:-g,S=f-1<=M?v-1:t-f;for(let T=b;T<=S;++T)_[m][T]=(_[p][T]-_[p][T-1])/a[M+1][g+T],y+=_[m][T]*a[g+T][M];f<=M&&(_[m][v]=-_[p][v-1]/a[M+1][f],y+=_[m][v]*a[f][M]),i[v][f]=y;const O=p;p=m,m=O}}let d=t;for(let f=1;f<=n;++f){for(let p=0;p<=t;++p)i[f][p]*=d;d*=t-f}return i}function tl(o,e,t,n,r){const s=r<o?r:o,i=[],a=Is(o,n,e),c=el(a,n,o,s,e),h=[];for(let d=0;d<t.length;++d){const f=t[d].clone(),p=f.w;f.x*=p,f.y*=p,f.z*=p,h[d]=f}for(let d=0;d<=s;++d){const f=h[a-o].clone().multiplyScalar(c[d][0]);for(let p=1;p<=o;++p)f.add(h[a-o+p].clone().multiplyScalar(c[d][p]));i[d]=f}for(let d=s+1;d<=r+1;++d)i[d]=new l.Vector4(0,0,0);return i}function nl(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 rl(o){const e=o.length,t=[],n=[];for(let s=0;s<e;++s){const i=o[s];t[s]=new l.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(nl(s,a)*n[a]));r[s]=i.divideScalar(n[0])}return r}function sl(o,e,t,n,r){const s=tl(o,e,t,n,r);return rl(s)}class Os extends l.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 l.Vector4(a.x,a.y,a.z,a.w)}}getPoint(e,t){const n=t||new l.Vector3,r=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),s=$a(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 l.Vector3,r=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),s=sl(this.degree,this.knots,this.controlPoints,r,1);return n.copy(s[1]).normalize(),n}}let xe,ke,je;class il extends l.Loader{constructor(e){super(e)}load(e,t,n,r){const s=this,i=s.path===""?l.LoaderUtils.extractUrlBase(e):s.path,a=new l.FileLoader(this.manager);a.setPath(s.path),a.setResponseType("arraybuffer"),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(e,function(c){try{t(s.parse(c,i))}catch(h){r?r(h):console.error(h),s.manager.itemError(e)}},n,r)}parse(e,t){if(hl(e))xe=new ul().parse(e);else{const r=Us(e);if(!fl(r))throw new Error("THREE.FBXLoader: Unknown format.");if(ks(r)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+ks(r));xe=new cl().parse(r)}const n=new l.TextureLoader(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new ol(n,this.manager).parse(xe)}}class ol{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){ke=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),r=this.parseDeformers(),s=new al().parse(r);return this.parseScene(r,s,n),je}parseConnections(){const e=new Map;return"Connections"in xe&&xe.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 c={ID:r,relationship:i};e.get(s).children.push(c)}),e}parseImages(){const e={},t={};if("Video"in xe.Objects){const n=xe.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,c=typeof s.Content=="string"&&s.Content!=="";if(a||c){const h=this.parseImage(n[r]);t[s.RelativeFilename||s.Filename]=h}}}}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 xe.Objects){const n=xe.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?l.RepeatWrapping:l.ClampToEdgeWrapping,n.wrapT=a===0?l.RepeatWrapping:l.ClampToEdgeWrapping,"Scaling"in e){const c=e.Scaling.value;n.repeat.x=c[0],n.repeat.y=c[1]}return n}loadTexture(e,t){let n;const r=this.textureLoader.path,s=ke.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 c=this.manager.getHandler(".tga");c===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),i=new l.Texture):(c.setPath(this.textureLoader.path),i=c.load(n))}else a==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),i=new l.Texture):i=this.textureLoader.load(n);return this.textureLoader.setPath(r),i}parseMaterials(e){const t=new Map;if("Material"in xe.Objects){const n=xe.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),!ke.has(n))return null;const i=this.parseParameters(e,t,n);let a;switch(s.toLowerCase()){case"phong":a=new l.MeshPhongMaterial;break;case"lambert":a=new l.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),a=new l.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 l.Color().fromArray(e.Diffuse.value):e.DiffuseColor&&(e.DiffuseColor.type==="Color"||e.DiffuseColor.type==="ColorRGB")&&(r.color=new l.Color().fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(r.displacementScale=e.DisplacementFactor.value),e.Emissive?r.emissive=new l.Color().fromArray(e.Emissive.value):e.EmissiveColor&&(e.EmissiveColor.type==="Color"||e.EmissiveColor.type==="ColorRGB")&&(r.emissive=new l.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 l.Color().fromArray(e.Specular.value):e.SpecularColor&&e.SpecularColor.type==="Color"&&(r.specular=new l.Color().fromArray(e.SpecularColor.value));const s=this;return ke.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=l.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 xe.Objects&&t in xe.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=ke.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in xe.Objects){const n=xe.Objects.Deformer;for(const r in n){const s=n[r],i=ke.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 l.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=ke.get(parseInt(s.ID)).children.filter(function(c){return c.relationship===void 0})[0].ID,n.push(a)}return n}parseScene(e,t,n){je=new l.Group;const r=this.parseModels(e.skeletons,t,n),s=xe.Objects.Model,i=this;r.forEach(function(c){const h=s[c.ID];i.setLookAtProperties(c,h),ke.get(c.ID).parents.forEach(function(f){const p=r.get(f.ID);p!==void 0&&p.add(c)}),c.parent===null&&je.add(c)}),this.bindSkeleton(e.skeletons,t,r),this.createAmbientLight(),je.traverse(function(c){if(c.userData.transformData){c.parent&&(c.userData.transformData.parentMatrix=c.parent.matrix,c.userData.transformData.parentMatrixWorld=c.parent.matrixWorld);const h=Bs(c.userData.transformData);c.applyMatrix4(h),c.updateWorldMatrix()}});const a=new ll().parse();je.children.length===1&&je.children[0].isGroup&&(je.children[0].animations=a,je=je.children[0]),je.animations=a}parseModels(e,t,n){const r=new Map,s=xe.Objects.Model;for(const i in s){const a=parseInt(i),c=s[i],h=ke.get(a);let d=this.buildSkeleton(h,e,a,c.attrName);if(!d){switch(c.attrType){case"Camera":d=this.createCamera(h);break;case"Light":d=this.createLight(h);break;case"Mesh":d=this.createMesh(h,t,n);break;case"NurbsCurve":d=this.createCurve(h,t);break;case"LimbNode":case"Root":d=new l.Bone;break;case"Null":default:d=new l.Group;break}d.name=c.attrName?l.PropertyBinding.sanitizeNodeName(c.attrName):"",d.ID=a}this.getTransformData(d,c),r.set(a,d)}return r}buildSkeleton(e,t,n,r){let s=null;return e.parents.forEach(function(i){for(const a in t){const c=t[a];c.rawBones.forEach(function(h,d){if(h.ID===i.ID){const f=s;s=new l.Bone,s.matrixWorld.copy(h.transformLink),s.name=r?l.PropertyBinding.sanitizeNodeName(r):"",s.ID=n,c.bones[d]=s,f!==null&&s.add(f)}})}}),s}createCamera(e){let t,n;if(e.children.forEach(function(r){const s=xe.Objects.NodeAttribute[r.ID];s!==void 0&&(n=s)}),n===void 0)t=new l.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,c=window.innerHeight;n.AspectWidth!==void 0&&n.AspectHeight!==void 0&&(a=n.AspectWidth.value,c=n.AspectHeight.value);const h=a/c;let d=45;n.FieldOfView!==void 0&&(d=n.FieldOfView.value);const f=n.FocalLength?n.FocalLength.value:null;switch(r){case 0:t=new l.PerspectiveCamera(d,h,s,i),f!==null&&t.setFocalLength(f);break;case 1:t=new l.OrthographicCamera(-a/2,a/2,c/2,-c/2,s,i);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+r+"."),t=new l.Object3D;break}}return t}createLight(e){let t,n;if(e.children.forEach(function(r){const s=xe.Objects.NodeAttribute[r.ID];s!==void 0&&(n=s)}),n===void 0)t=new l.Object3D;else{let r;n.LightType===void 0?r=0:r=n.LightType.value;let s=16777215;n.Color!==void 0&&(s=new l.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 c=1;switch(r){case 0:t=new l.PointLight(s,i,a,c);break;case 1:t=new l.DirectionalLight(s,i);break;case 2:let h=Math.PI/3;n.InnerAngle!==void 0&&(h=l.MathUtils.degToRad(n.InnerAngle.value));let d=0;n.OuterAngle!==void 0&&(d=l.MathUtils.degToRad(n.OuterAngle.value),d=Math.max(d,1)),t=new l.SpotLight(s,i,a,h,d,c);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new l.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(c){t.has(c.ID)&&(s=t.get(c.ID)),n.has(c.ID)&&a.push(n.get(c.ID))}),a.length>1?i=a:a.length>0?i=a[0]:(i=new l.MeshPhongMaterial({color:13421772}),a.push(i)),"color"in s.attributes&&a.forEach(function(c){c.vertexColors=!0}),s.FBX_Deformer?(r=new l.SkinnedMesh(s,i),r.normalizeSkinWeights()):r=new l.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 l.LineBasicMaterial({color:3342591,linewidth:1});return new l.Line(n,r)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),"RotationOrder"in t?n.eulerOrder=Fs(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&&ke.get(e.ID).children.forEach(function(r){if(r.relationship==="LookAtProperty"){const s=xe.Objects.Model[r.ID];if("Lcl_Translation"in s){const i=s.Lcl_Translation.value;e.target!==void 0?(e.target.position.fromArray(i),je.add(e.target)):e.lookAt(new l.Vector3().fromArray(i))}}})}bindSkeleton(e,t,n){const r=this.parsePoseNodes();for(const s in e){const i=e[s];ke.get(parseInt(i.ID)).parents.forEach(function(c){if(t.has(c.ID)){const h=c.ID;ke.get(h).parents.forEach(function(f){n.has(f.ID)&&n.get(f.ID).bind(new l.Skeleton(i.bones),r[f.ID])})}})}}parsePoseNodes(){const e={};if("Pose"in xe.Objects){const t=xe.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 l.Matrix4().fromArray(s.Matrix.a)}):e[r.Node]=new l.Matrix4().fromArray(r.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in xe&&"AmbientColor"in xe.GlobalSettings){const e=xe.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],r=e[2];if(t!==0||n!==0||r!==0){const s=new l.Color(t,n,r);je.add(new l.AmbientLight(s,1))}}}}class al{parse(e){const t=new Map;if("Geometry"in xe.Objects){const n=xe.Objects.Geometry;for(const r in n){const s=ke.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(f){return xe.Objects.Model[f.ID]});if(i.length===0)return;const a=e.children.reduce(function(f,p){return r[p.ID]!==void 0&&(f=r[p.ID]),f},null);e.children.forEach(function(f){n.morphTargets[f.ID]!==void 0&&s.push(n.morphTargets[f.ID])});const c=i[0],h={};"RotationOrder"in c&&(h.eulerOrder=Fs(c.RotationOrder.value)),"InheritType"in c&&(h.inheritType=parseInt(c.InheritType.value)),"GeometricTranslation"in c&&(h.translation=c.GeometricTranslation.value),"GeometricRotation"in c&&(h.rotation=c.GeometricRotation.value),"GeometricScaling"in c&&(h.scale=c.GeometricScaling.value);const d=Bs(h);return this.genGeometry(t,a,s,d)}genGeometry(e,t,n,r){const s=new l.BufferGeometry;e.attrName&&(s.name=e.attrName);const i=this.parseGeoNode(e,t),a=this.genBuffers(i),c=new l.Float32BufferAttribute(a.vertex,3);if(c.applyMatrix4(r),s.setAttribute("position",c),a.colors.length>0&&s.setAttribute("color",new l.Float32BufferAttribute(a.colors,3)),t&&(s.setAttribute("skinIndex",new l.Uint16BufferAttribute(a.weightsIndices,4)),s.setAttribute("skinWeight",new l.Float32BufferAttribute(a.vertexWeights,4)),s.FBX_Deformer=t),a.normal.length>0){const h=new l.Matrix3().getNormalMatrix(r),d=new l.Float32BufferAttribute(a.normal,3);d.applyNormalMatrix(h),s.setAttribute("normal",d)}if(a.uvs.forEach(function(h,d){let f="uv"+(d+1).toString();d===0&&(f="uv"),s.setAttribute(f,new l.Float32BufferAttribute(a.uvs[d],2))}),i.material&&i.material.mappingType!=="AllSame"){let h=a.materialIndex[0],d=0;if(a.materialIndex.forEach(function(f,p){f!==h&&(s.addGroup(d,p-d,h),h=f,d=p)}),s.groups.length>0){const f=s.groups[s.groups.length-1],p=f.start+f.count;p!==a.materialIndex.length&&s.addGroup(p,a.materialIndex.length-p,h)}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=[],c=[],h=[],d=[],f=[];const p=this;return e.vertexIndices.forEach(function(m,_){let v,y=!1;m<0&&(m=m^-1,y=!0);let g=[],M=[];if(i.push(m*3,m*3+1,m*3+2),e.color){const b=Cn(_,n,m,e.color);c.push(b[0],b[1],b[2])}if(e.skeleton){if(e.weightTable[m]!==void 0&&e.weightTable[m].forEach(function(b){M.push(b.weight),g.push(b.id)}),M.length>4){s||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),s=!0);const b=[0,0,0,0],S=[0,0,0,0];M.forEach(function(O,T){let C=O,w=g[T];S.forEach(function(A,x,D){if(C>A){D[x]=C,C=A;const L=b[x];b[x]=w,w=L}})}),g=b,M=S}for(;M.length<4;)M.push(0),g.push(0);for(let b=0;b<4;++b)d.push(M[b]),f.push(g[b])}if(e.normal){const b=Cn(_,n,m,e.normal);a.push(b[0],b[1],b[2])}e.material&&e.material.mappingType!=="AllSame"&&(v=Cn(_,n,m,e.material)[0]),e.uv&&e.uv.forEach(function(b,S){const O=Cn(_,n,m,b);h[S]===void 0&&(h[S]=[]),h[S].push(O[0]),h[S].push(O[1])}),r++,y&&(p.genFace(t,e,i,v,a,c,h,d,f,r),n++,r=0,i=[],a=[],c=[],h=[],d=[],f=[])}),t}genFace(e,t,n,r,s,i,a,c,h,d){for(let f=2;f<d;f++)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[(f-1)*3]]),e.vertex.push(t.vertexPositions[n[(f-1)*3+1]]),e.vertex.push(t.vertexPositions[n[(f-1)*3+2]]),e.vertex.push(t.vertexPositions[n[f*3]]),e.vertex.push(t.vertexPositions[n[f*3+1]]),e.vertex.push(t.vertexPositions[n[f*3+2]]),t.skeleton&&(e.vertexWeights.push(c[0]),e.vertexWeights.push(c[1]),e.vertexWeights.push(c[2]),e.vertexWeights.push(c[3]),e.vertexWeights.push(c[(f-1)*4]),e.vertexWeights.push(c[(f-1)*4+1]),e.vertexWeights.push(c[(f-1)*4+2]),e.vertexWeights.push(c[(f-1)*4+3]),e.vertexWeights.push(c[f*4]),e.vertexWeights.push(c[f*4+1]),e.vertexWeights.push(c[f*4+2]),e.vertexWeights.push(c[f*4+3]),e.weightsIndices.push(h[0]),e.weightsIndices.push(h[1]),e.weightsIndices.push(h[2]),e.weightsIndices.push(h[3]),e.weightsIndices.push(h[(f-1)*4]),e.weightsIndices.push(h[(f-1)*4+1]),e.weightsIndices.push(h[(f-1)*4+2]),e.weightsIndices.push(h[(f-1)*4+3]),e.weightsIndices.push(h[f*4]),e.weightsIndices.push(h[f*4+1]),e.weightsIndices.push(h[f*4+2]),e.weightsIndices.push(h[f*4+3])),t.color&&(e.colors.push(i[0]),e.colors.push(i[1]),e.colors.push(i[2]),e.colors.push(i[(f-1)*3]),e.colors.push(i[(f-1)*3+1]),e.colors.push(i[(f-1)*3+2]),e.colors.push(i[f*3]),e.colors.push(i[f*3+1]),e.colors.push(i[f*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[(f-1)*3]),e.normal.push(s[(f-1)*3+1]),e.normal.push(s[(f-1)*3+2]),e.normal.push(s[f*3]),e.normal.push(s[f*3+1]),e.normal.push(s[f*3+2])),t.uv&&t.uv.forEach(function(p,m){e.uvs[m]===void 0&&(e.uvs[m]=[]),e.uvs[m].push(a[m][0]),e.uvs[m].push(a[m][1]),e.uvs[m].push(a[m][(f-1)*2]),e.uvs[m].push(a[m][(f-1)*2+1]),e.uvs[m].push(a[m][f*2]),e.uvs[m].push(a[m][f*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 c=xe.Objects.Geometry[a.geoID];c!==void 0&&s.genMorphGeometry(e,t,c,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:[],c=n.Indexes!==void 0?n.Indexes.a:[],h=e.attributes.position.count*3,d=new Float32Array(h);for(let _=0;_<c.length;_++){const v=c[_]*3;d[v]=a[_*3],d[v+1]=a[_*3+1],d[v+2]=a[_*3+2]}const f={vertexIndices:i,vertexPositions:d},p=this.genBuffers(f),m=new l.Float32BufferAttribute(p.vertex,3);m.name=s||n.attrName,m.applyMatrix4(r),e.morphAttributes.position.push(m)}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(Os===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 l.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 l.BufferGeometry;const n=t-1,r=e.KnotVector.a,s=[],i=e.Points.a;for(let f=0,p=i.length;f<p;f+=4)s.push(new l.Vector4().fromArray(i,f));let a,c;if(e.Form==="Closed")s.push(s[0]);else if(e.Form==="Periodic"){a=n,c=r.length-1-a;for(let f=0;f<n;++f)s.push(s[f])}const d=new Os(n,r,s,a,c).getPoints(s.length*12);return new l.BufferGeometry().setFromPoints(d)}}class ll{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(xe.Objects.AnimationCurve===void 0)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=xe.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=xe.Objects.AnimationCurve;for(const n in t){const r={id:t[n].id,times:t[n].KeyTime.a.map(dl),values:t[n].KeyValueFloat.a},s=ke.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=xe.Objects.AnimationLayer,n=new Map;for(const r in t){const s=[],i=ke.get(parseInt(r));i!==void 0&&(i.children.forEach(function(c,h){if(e.has(c.ID)){const d=e.get(c.ID);if(d.curves.x!==void 0||d.curves.y!==void 0||d.curves.z!==void 0){if(s[h]===void 0){const f=ke.get(c.ID).parents.filter(function(p){return p.relationship!==void 0})[0].ID;if(f!==void 0){const p=xe.Objects.Model[f.toString()];if(p===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",c);return}const m={modelName:p.attrName?l.PropertyBinding.sanitizeNodeName(p.attrName):"",ID:p.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};je.traverse(function(_){_.ID===p.id&&(m.transform=_.matrix,_.userData.transformData&&(m.eulerOrder=_.userData.transformData.eulerOrder))}),m.transform||(m.transform=new l.Matrix4),"PreRotation"in p&&(m.preRotation=p.PreRotation.value),"PostRotation"in p&&(m.postRotation=p.PostRotation.value),s[h]=m}}s[h]&&(s[h][d.attr]=d)}else if(d.curves.morph!==void 0){if(s[h]===void 0){const f=ke.get(c.ID).parents.filter(function(g){return g.relationship!==void 0})[0].ID,p=ke.get(f).parents[0].ID,m=ke.get(p).parents[0].ID,_=ke.get(m).parents[0].ID,v=xe.Objects.Model[_],y={modelName:v.attrName?l.PropertyBinding.sanitizeNodeName(v.attrName):"",morphName:xe.Objects.Deformer[f].attrName};s[h]=y}s[h][d.attr]=d}}}),n.set(parseInt(r),s))}return n}parseAnimStacks(e){const t=xe.Objects.AnimationStack,n={};for(const r in t){const s=ke.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 l.AnimationClip(e.name,-1,t)}generateTracks(e){const t=[];let n=new l.Vector3,r=new l.Quaternion,s=new l.Vector3;if(e.transform&&e.transform.decompose(n,r,s),n=n.toArray(),r=new l.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 l.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(l.MathUtils.degToRad)),t.y!==void 0&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(l.MathUtils.degToRad)),t.z!==void 0&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(l.MathUtils.degToRad));const a=this.getTimesForAllAxes(t),c=this.getKeyframeTrackValues(a,t,n);r!==void 0&&(r=r.map(l.MathUtils.degToRad),r.push(i),r=new l.Euler().fromArray(r),r=new l.Quaternion().setFromEuler(r)),s!==void 0&&(s=s.map(l.MathUtils.degToRad),s.push(i),s=new l.Euler().fromArray(s),s=new l.Quaternion().setFromEuler(s).invert());const h=new l.Quaternion,d=new l.Euler,f=[];for(let p=0;p<c.length;p+=3)d.set(c[p],c[p+1],c[p+2],i),h.setFromEuler(d),r!==void 0&&h.premultiply(r),s!==void 0&&h.multiply(s),h.toArray(f,p/3*4);return new l.QuaternionKeyframeTrack(e+".quaternion",a,f)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(s){return s/100}),r=je.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new l.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,c=-1;return e.forEach(function(h){if(t.x&&(i=t.x.times.indexOf(h)),t.y&&(a=t.y.times.indexOf(h)),t.z&&(c=t.z.times.indexOf(h)),i!==-1){const d=t.x.values[i];s.push(d),r[0]=d}else s.push(r[0]);if(a!==-1){const d=t.y.values[a];s.push(d),r[1]=d}else s.push(r[1]);if(c!==-1){const d=t.z.values[c];s.push(d),r[2]=d}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 c=n+a;const h=e.times[t-1],f=(e.times[t]-h)/i;let p=h+f;const m=[],_=[];for(;p<e.times[t];)m.push(p),p+=f,_.push(c),c+=a;e.times=Ns(e.times,t,m),e.values=Ns(e.values,t,_)}}}}class cl{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 Ls,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 c=r.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),h=r.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),d=r.match("^\\t{"+(t.currentIndent-1)+"}}");c?t.parseNodeBegin(r,c):h?t.parseNodeProperty(r,h,n[++s]):d?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(c){return c.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 c=s.split(",").slice(1),h=parseInt(c[0]),d=parseInt(c[1]);let f=s.split(",").slice(3);f=f.map(function(p){return p.trim().replace(/^"/,"")}),r="connections",s=[h,d],ml(s,f),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=hr(s))}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,e.slice(-1)!==","&&(t.a=hr(t.a))}parseNodeSpecialProperty(e,t,n){const r=n.split('",').map(function(d){return d.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=r[0],i=r[1],a=r[2],c=r[3];let h=r[4];switch(i){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":h=parseFloat(h);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":h=hr(h);break}this.getPrevNode()[s]={type:i,type2:a,flag:c,value:h},this.setCurrentProp(this.getPrevNode(),s)}}class ul{parse(e){const t=new Ds(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 Ls;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 c=[];for(let p=0;p<s;p++)c.push(this.parseProperty(e));const h=c.length>0?c[0]:"",d=c.length>1?c[1]:"",f=c.length>2?c[2]:"";for(n.singleProperty=s===1&&e.getOffset()===r;r>e.getOffset();){const p=this.parseNode(e,t);p!==null&&this.parseSubNode(a,n,p)}return n.propertyList=c,typeof h=="number"&&(n.id=h),d!==""&&(n.attrName=d),f!==""&&(n.attrType=f),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 c;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?c=[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:c=n.propertyList[4],t[r]={type:s,type2:i,flag:a,value:c}}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=Eo(new Uint8Array(e.getArrayBuffer(i))),c=new Ds(a.buffer);switch(t){case"b":case"c":return c.getBooleanArray(r);case"d":return c.getFloat64Array(r);case"f":return c.getFloat32Array(r);case"i":return c.getInt32Array(r);case"l":return c.getInt64Array(r)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class Ds{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)),Rt(new Uint8Array(t))}}class Ls{add(e,t){this[e]=t}}function hl(o){const e="Kaydara FBX Binary \0";return o.byteLength>=e.length&&e===Us(o,0,e.length)}function fl(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 ks(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 dl(o){return o/46186158e3}const pl=[];function Cn(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 gl(pl,n.buffer,s,i)}const ur=new l.Euler,jt=new l.Vector3;function Bs(o){const e=new l.Matrix4,t=new l.Matrix4,n=new l.Matrix4,r=new l.Matrix4,s=new l.Matrix4,i=new l.Matrix4,a=new l.Matrix4,c=new l.Matrix4,h=new l.Matrix4,d=new l.Matrix4,f=new l.Matrix4,p=new l.Matrix4,m=o.inheritType?o.inheritType:0;if(o.translation&&e.setPosition(jt.fromArray(o.translation)),o.preRotation){const x=o.preRotation.map(l.MathUtils.degToRad);x.push(o.eulerOrder),t.makeRotationFromEuler(ur.fromArray(x))}if(o.rotation){const x=o.rotation.map(l.MathUtils.degToRad);x.push(o.eulerOrder),n.makeRotationFromEuler(ur.fromArray(x))}if(o.postRotation){const x=o.postRotation.map(l.MathUtils.degToRad);x.push(o.eulerOrder),r.makeRotationFromEuler(ur.fromArray(x)),r.invert()}o.scale&&s.scale(jt.fromArray(o.scale)),o.scalingOffset&&a.setPosition(jt.fromArray(o.scalingOffset)),o.scalingPivot&&i.setPosition(jt.fromArray(o.scalingPivot)),o.rotationOffset&&c.setPosition(jt.fromArray(o.rotationOffset)),o.rotationPivot&&h.setPosition(jt.fromArray(o.rotationPivot)),o.parentMatrixWorld&&(f.copy(o.parentMatrix),d.copy(o.parentMatrixWorld));const _=t.clone().multiply(n).multiply(r),v=new l.Matrix4;v.extractRotation(d);const y=new l.Matrix4;y.copyPosition(d);const g=y.clone().invert().multiply(d),M=v.clone().invert().multiply(g),b=s,S=new l.Matrix4;if(m===0)S.copy(v).multiply(_).multiply(M).multiply(b);else if(m===1)S.copy(v).multiply(M).multiply(_).multiply(b);else{const D=new l.Matrix4().scale(new l.Vector3().setFromMatrixScale(f)).clone().invert(),L=M.clone().multiply(D);S.copy(v).multiply(_).multiply(L).multiply(b)}const O=h.clone().invert(),T=i.clone().invert();let C=e.clone().multiply(c).multiply(h).multiply(t).multiply(n).multiply(r).multiply(O).multiply(a).multiply(i).multiply(s).multiply(T);const w=new l.Matrix4().copyPosition(C),A=d.clone().multiply(w);return p.copyPosition(A),C=p.clone().multiply(S),C.premultiply(d.invert()),C}function Fs(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 hr(o){return o.split(",").map(function(t){return parseFloat(t)})}function Us(o,e,t){return e===void 0&&(e=0),t===void 0&&(t=o.byteLength),Rt(new Uint8Array(o,e,t))}function ml(o,e){for(let t=0,n=o.length,r=e.length;t<r;t++,n++)o[n]=e[t]}function gl(o,e,t,n){for(let r=t,s=0;r<n;r++,s++)o[s]=e[r];return o}function Ns(o,e,t){return o.slice(0,e).concat(t).concat(o.slice(e))}var yl=Object.defineProperty,_l=(o,e,t)=>e in o?yl(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,fr=(o,e,t)=>(_l(o,typeof e!="symbol"?e+"":e,t),t);class vl extends l.Loader{constructor(e){super(e)}load(e,t,n,r){const s=new l.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),c=this.parse(a);t&&t(c)},n,r)}loadAsync(e,t){return super.loadAsync(e,t)}parse(e){return new dr(e)}}class dr{constructor(e){fr(this,"data"),this.data=e}generateShapes(e,t=100,n){const r=[],s={letterSpacing:0,lineHeight:1,...n},i=xl(e,t,this.data,s);for(let a=0,c=i.length;a<c;a++)Array.prototype.push.apply(r,i[a].toShapes(!1));return r}}fr(dr,"isFont"),fr(dr,"type");function xl(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 c=0,h=0;for(let d=0;d<r.length;d++){const f=r[d];if(f===`
|
|
390
|
+
`)c=0,h-=i*n.lineHeight;else{const p=wl(f,s,c,h,t);p&&(c+=p.offsetX+n.letterSpacing,a.push(p.path))}}return a}function wl(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 l.ShapePath;let a,c,h,d,f,p,m,_;if(s.o){const v=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let y=0,g=v.length;y<g;)switch(v[y++]){case"m":a=parseInt(v[y++])*e+t,c=parseInt(v[y++])*e+n,i.moveTo(a,c);break;case"l":a=parseInt(v[y++])*e+t,c=parseInt(v[y++])*e+n,i.lineTo(a,c);break;case"q":h=parseInt(v[y++])*e+t,d=parseInt(v[y++])*e+n,f=parseInt(v[y++])*e+t,p=parseInt(v[y++])*e+n,i.quadraticCurveTo(f,p,h,d);break;case"b":h=parseInt(v[y++])*e+t,d=parseInt(v[y++])*e+n,f=parseInt(v[y++])*e+t,p=parseInt(v[y++])*e+n,m=parseInt(v[y++])*e+t,_=parseInt(v[y++])*e+n,i.bezierCurveTo(f,p,m,_,h,d);break}}return{offsetX:s.ha*e,path:i}}class zs extends l.DataTextureLoader{constructor(e){super(e),this.type=l.HalfFloatType}parse(e){const i=function(w,A){switch(w){case 1:throw new Error("THREE.RGBELoader: Read Error: "+(A||""));case 2:throw new Error("THREE.RGBELoader: Write Error: "+(A||""));case 3:throw new Error("THREE.RGBELoader: Bad File Format: "+(A||""));default:case 4:throw new Error("THREE.RGBELoader: Memory Error: "+(A||""))}},d=`
|
|
391
|
+
`,f=function(w,A,x){A=A||1024;let L=w.pos,V=-1,R=0,X="",Y=String.fromCharCode.apply(null,new Uint16Array(w.subarray(L,L+128)));for(;0>(V=Y.indexOf(d))&&R<A&&L<w.byteLength;)X+=Y,R+=Y.length,L+=128,Y+=String.fromCharCode.apply(null,new Uint16Array(w.subarray(L,L+128)));return-1<V?(w.pos+=R+V+1,X+Y.slice(0,V)):!1},p=function(w){const A=/^#\?(\S+)/,x=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,D=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,L=/^\s*FORMAT=(\S+)\s*$/,V=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,R={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let X,Y;for((w.pos>=w.byteLength||!(X=f(w)))&&i(1,"no header found"),(Y=X.match(A))||i(3,"bad initial token"),R.valid|=1,R.programtype=Y[1],R.string+=X+`
|
|
392
|
+
`;X=f(w),X!==!1;){if(R.string+=X+`
|
|
393
|
+
`,X.charAt(0)==="#"){R.comments+=X+`
|
|
394
|
+
`;continue}if((Y=X.match(x))&&(R.gamma=parseFloat(Y[1])),(Y=X.match(D))&&(R.exposure=parseFloat(Y[1])),(Y=X.match(L))&&(R.valid|=2,R.format=Y[1]),(Y=X.match(V))&&(R.valid|=4,R.height=parseInt(Y[1],10),R.width=parseInt(Y[2],10)),R.valid&2&&R.valid&4)break}return R.valid&2||i(3,"missing format specifier"),R.valid&4||i(3,"missing image size specifier"),R},m=function(w,A,x){const D=A;if(D<8||D>32767||w[0]!==2||w[1]!==2||w[2]&128)return new Uint8Array(w);D!==(w[2]<<8|w[3])&&i(3,"wrong scanline width");const L=new Uint8Array(4*A*x);L.length||i(4,"unable to allocate buffer space");let V=0,R=0;const X=4*D,Y=new Uint8Array(4),J=new Uint8Array(X);let q=x;for(;q>0&&R<w.byteLength;){R+4>w.byteLength&&i(1),Y[0]=w[R++],Y[1]=w[R++],Y[2]=w[R++],Y[3]=w[R++],(Y[0]!=2||Y[1]!=2||(Y[2]<<8|Y[3])!=D)&&i(3,"bad rgbe scanline format");let re=0,ee;for(;re<X&&R<w.byteLength;){ee=w[R++];const le=ee>128;if(le&&(ee-=128),(ee===0||re+ee>X)&&i(3,"bad scanline data"),le){const me=w[R++];for(let k=0;k<ee;k++)J[re++]=me}else J.set(w.subarray(R,R+ee),re),re+=ee,R+=ee}const ce=D;for(let le=0;le<ce;le++){let me=0;L[V]=J[le+me],me+=D,L[V+1]=J[le+me],me+=D,L[V+2]=J[le+me],me+=D,L[V+3]=J[le+me],V+=4}q--}return L},_=function(w,A,x,D){const L=w[A+3],V=Math.pow(2,L-128)/255;x[D+0]=w[A+0]*V,x[D+1]=w[A+1]*V,x[D+2]=w[A+2]*V,x[D+3]=1},v=function(w,A,x,D){const L=w[A+3],V=Math.pow(2,L-128)/255;x[D+0]=l.DataUtils.toHalfFloat(Math.min(w[A+0]*V,65504)),x[D+1]=l.DataUtils.toHalfFloat(Math.min(w[A+1]*V,65504)),x[D+2]=l.DataUtils.toHalfFloat(Math.min(w[A+2]*V,65504)),x[D+3]=l.DataUtils.toHalfFloat(1)},y=new Uint8Array(e);y.pos=0;const g=p(y),M=g.width,b=g.height,S=m(y.subarray(y.pos),M,b);let O,T,C;switch(this.type){case l.FloatType:C=S.length/4;const w=new Float32Array(C*4);for(let x=0;x<C;x++)_(S,x*4,w,x*4);O=w,T=l.FloatType;break;case l.HalfFloatType:C=S.length/4;const A=new Uint16Array(C*4);for(let x=0;x<C;x++)v(S,x*4,A,x*4);O=A,T=l.HalfFloatType;break;default:throw new Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:M,height:b,data:O,header:g.string,gamma:g.gamma,exposure:g.exposure,type:T}}setDataType(e){return this.type=e,this}load(e,t,n,r){function s(i,a){switch(i.type){case l.FloatType:case l.HalfFloatType:"colorSpace"in i?i.colorSpace="srgb-linear":i.encoding=3e3,i.minFilter=l.LinearFilter,i.magFilter=l.LinearFilter,i.generateMipmaps=!1,i.flipY=!0;break}t&&t(i,a)}return super.load(e,s,n,r)}}const bl="srgb";class tn extends l.Loader{constructor(e){super(e),this.defaultDPI=90,this.defaultUnit="px"}load(e,t,n,r){const s=this,i=new l.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(c){r?r(c):console.error(c),s.manager.itemError(e)}},n,r)}parse(e){const t=this;function n(k,z){if(k.nodeType!==1)return;const F=S(k);let B=!1,G=null;switch(k.nodeName){case"svg":z=_(k,z);break;case"style":s(k);break;case"g":z=_(k,z);break;case"path":z=_(k,z),k.hasAttribute("d")&&(G=r(k));break;case"rect":z=_(k,z),G=c(k);break;case"polygon":z=_(k,z),G=h(k);break;case"polyline":z=_(k,z),G=d(k);break;case"circle":z=_(k,z),G=f(k);break;case"ellipse":z=_(k,z),G=p(k);break;case"line":z=_(k,z),G=m(k);break;case"defs":B=!0;break;case"use":z=_(k,z);const U=(k.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),E=k.viewportElement.getElementById(U);E?n(E,z):console.warn("SVGLoader: 'use node' references non-existent node id: "+U);break}G&&(z.fill!==void 0&&z.fill!=="none"&&G.color.setStyle(z.fill,bl),T(G,ce),L.push(G),G.userData={node:k,style:z});const P=k.childNodes;for(let I=0;I<P.length;I++){const U=P[I];B&&U.nodeName!=="style"&&U.nodeName!=="defs"||n(U,z)}F&&(R.pop(),R.length>0?ce.copy(R[R.length-1]):ce.identity())}function r(k){const z=new l.ShapePath,F=new l.Vector2,B=new l.Vector2,G=new l.Vector2;let P=!0,I=!1;const U=k.getAttribute("d");if(U===""||U==="none")return null;const E=U.match(/[a-df-z][^a-df-z]*/gi);for(let Z=0,j=E.length;Z<j;Z++){const $=E[Z],ne=$.charAt(0),ie=$.slice(1).trim();P===!0&&(I=!0,P=!1);let W;switch(ne){case"M":W=y(ie);for(let N=0,ae=W.length;N<ae;N+=2)F.x=W[N+0],F.y=W[N+1],B.x=F.x,B.y=F.y,N===0?z.moveTo(F.x,F.y):z.lineTo(F.x,F.y),N===0&&G.copy(F);break;case"H":W=y(ie);for(let N=0,ae=W.length;N<ae;N++)F.x=W[N],B.x=F.x,B.y=F.y,z.lineTo(F.x,F.y),N===0&&I===!0&&G.copy(F);break;case"V":W=y(ie);for(let N=0,ae=W.length;N<ae;N++)F.y=W[N],B.x=F.x,B.y=F.y,z.lineTo(F.x,F.y),N===0&&I===!0&&G.copy(F);break;case"L":W=y(ie);for(let N=0,ae=W.length;N<ae;N+=2)F.x=W[N+0],F.y=W[N+1],B.x=F.x,B.y=F.y,z.lineTo(F.x,F.y),N===0&&I===!0&&G.copy(F);break;case"C":W=y(ie);for(let N=0,ae=W.length;N<ae;N+=6)z.bezierCurveTo(W[N+0],W[N+1],W[N+2],W[N+3],W[N+4],W[N+5]),B.x=W[N+2],B.y=W[N+3],F.x=W[N+4],F.y=W[N+5],N===0&&I===!0&&G.copy(F);break;case"S":W=y(ie);for(let N=0,ae=W.length;N<ae;N+=4)z.bezierCurveTo(v(F.x,B.x),v(F.y,B.y),W[N+0],W[N+1],W[N+2],W[N+3]),B.x=W[N+0],B.y=W[N+1],F.x=W[N+2],F.y=W[N+3],N===0&&I===!0&&G.copy(F);break;case"Q":W=y(ie);for(let N=0,ae=W.length;N<ae;N+=4)z.quadraticCurveTo(W[N+0],W[N+1],W[N+2],W[N+3]),B.x=W[N+0],B.y=W[N+1],F.x=W[N+2],F.y=W[N+3],N===0&&I===!0&&G.copy(F);break;case"T":W=y(ie);for(let N=0,ae=W.length;N<ae;N+=2){const he=v(F.x,B.x),_e=v(F.y,B.y);z.quadraticCurveTo(he,_e,W[N+0],W[N+1]),B.x=he,B.y=_e,F.x=W[N+0],F.y=W[N+1],N===0&&I===!0&&G.copy(F)}break;case"A":W=y(ie,[3,4],7);for(let N=0,ae=W.length;N<ae;N+=7){if(W[N+5]==F.x&&W[N+6]==F.y)continue;const he=F.clone();F.x=W[N+5],F.y=W[N+6],B.x=F.x,B.y=F.y,i(z,W[N],W[N+1],W[N+2],W[N+3],W[N+4],he,F),N===0&&I===!0&&G.copy(F)}break;case"m":W=y(ie);for(let N=0,ae=W.length;N<ae;N+=2)F.x+=W[N+0],F.y+=W[N+1],B.x=F.x,B.y=F.y,N===0?z.moveTo(F.x,F.y):z.lineTo(F.x,F.y),N===0&&G.copy(F);break;case"h":W=y(ie);for(let N=0,ae=W.length;N<ae;N++)F.x+=W[N],B.x=F.x,B.y=F.y,z.lineTo(F.x,F.y),N===0&&I===!0&&G.copy(F);break;case"v":W=y(ie);for(let N=0,ae=W.length;N<ae;N++)F.y+=W[N],B.x=F.x,B.y=F.y,z.lineTo(F.x,F.y),N===0&&I===!0&&G.copy(F);break;case"l":W=y(ie);for(let N=0,ae=W.length;N<ae;N+=2)F.x+=W[N+0],F.y+=W[N+1],B.x=F.x,B.y=F.y,z.lineTo(F.x,F.y),N===0&&I===!0&&G.copy(F);break;case"c":W=y(ie);for(let N=0,ae=W.length;N<ae;N+=6)z.bezierCurveTo(F.x+W[N+0],F.y+W[N+1],F.x+W[N+2],F.y+W[N+3],F.x+W[N+4],F.y+W[N+5]),B.x=F.x+W[N+2],B.y=F.y+W[N+3],F.x+=W[N+4],F.y+=W[N+5],N===0&&I===!0&&G.copy(F);break;case"s":W=y(ie);for(let N=0,ae=W.length;N<ae;N+=4)z.bezierCurveTo(v(F.x,B.x),v(F.y,B.y),F.x+W[N+0],F.y+W[N+1],F.x+W[N+2],F.y+W[N+3]),B.x=F.x+W[N+0],B.y=F.y+W[N+1],F.x+=W[N+2],F.y+=W[N+3],N===0&&I===!0&&G.copy(F);break;case"q":W=y(ie);for(let N=0,ae=W.length;N<ae;N+=4)z.quadraticCurveTo(F.x+W[N+0],F.y+W[N+1],F.x+W[N+2],F.y+W[N+3]),B.x=F.x+W[N+0],B.y=F.y+W[N+1],F.x+=W[N+2],F.y+=W[N+3],N===0&&I===!0&&G.copy(F);break;case"t":W=y(ie);for(let N=0,ae=W.length;N<ae;N+=2){const he=v(F.x,B.x),_e=v(F.y,B.y);z.quadraticCurveTo(he,_e,F.x+W[N+0],F.y+W[N+1]),B.x=he,B.y=_e,F.x=F.x+W[N+0],F.y=F.y+W[N+1],N===0&&I===!0&&G.copy(F)}break;case"a":W=y(ie,[3,4],7);for(let N=0,ae=W.length;N<ae;N+=7){if(W[N+5]==0&&W[N+6]==0)continue;const he=F.clone();F.x+=W[N+5],F.y+=W[N+6],B.x=F.x,B.y=F.y,i(z,W[N],W[N+1],W[N+2],W[N+3],W[N+4],he,F),N===0&&I===!0&&G.copy(F)}break;case"Z":case"z":z.currentPath.autoClose=!0,z.currentPath.curves.length>0&&(F.copy(G),z.currentPath.currentPoint.copy(F),P=!0);break;default:console.warn($)}I=!1}return z}function s(k){if(!(!k.sheet||!k.sheet.cssRules||!k.sheet.cssRules.length))for(let z=0;z<k.sheet.cssRules.length;z++){const F=k.sheet.cssRules[z];if(F.type!==1)continue;const B=F.selectorText.split(/,/gm).filter(Boolean).map(G=>G.trim());for(let G=0;G<B.length;G++){const P=Object.fromEntries(Object.entries(F.style).filter(([,I])=>I!==""));V[B[G]]=Object.assign(V[B[G]]||{},P)}}}function i(k,z,F,B,G,P,I,U){if(z==0||F==0){k.lineTo(U.x,U.y);return}B=B*Math.PI/180,z=Math.abs(z),F=Math.abs(F);const E=(I.x-U.x)/2,Z=(I.y-U.y)/2,j=Math.cos(B)*E+Math.sin(B)*Z,$=-Math.sin(B)*E+Math.cos(B)*Z;let ne=z*z,ie=F*F;const W=j*j,N=$*$,ae=W/ne+N/ie;if(ae>1){const Ut=Math.sqrt(ae);z=Ut*z,F=Ut*F,ne=z*z,ie=F*F}const he=ne*N+ie*W,_e=(ne*ie-he)/he;let Oe=Math.sqrt(Math.max(0,_e));G===P&&(Oe=-Oe);const De=Oe*z*$/F,$e=-Oe*F*j/z,dt=Math.cos(B)*De-Math.sin(B)*$e+(I.x+U.x)/2,Tt=Math.sin(B)*De+Math.cos(B)*$e+(I.y+U.y)/2,Ze=a(1,0,(j-De)/z,($-$e)/F),mn=a((j-De)/z,($-$e)/F,(-j-De)/z,(-$-$e)/F)%(Math.PI*2);k.currentPath.absellipse(dt,Tt,z,F,Ze,Ze+mn,P===0,B)}function a(k,z,F,B){const G=k*F+z*B,P=Math.sqrt(k*k+z*z)*Math.sqrt(F*F+B*B);let I=Math.acos(Math.max(-1,Math.min(1,G/P)));return k*B-z*F<0&&(I=-I),I}function c(k){const z=b(k.getAttribute("x")||0),F=b(k.getAttribute("y")||0),B=b(k.getAttribute("rx")||k.getAttribute("ry")||0),G=b(k.getAttribute("ry")||k.getAttribute("rx")||0),P=b(k.getAttribute("width")),I=b(k.getAttribute("height")),U=1-.551915024494,E=new l.ShapePath;return E.moveTo(z+B,F),E.lineTo(z+P-B,F),(B!==0||G!==0)&&E.bezierCurveTo(z+P-B*U,F,z+P,F+G*U,z+P,F+G),E.lineTo(z+P,F+I-G),(B!==0||G!==0)&&E.bezierCurveTo(z+P,F+I-G*U,z+P-B*U,F+I,z+P-B,F+I),E.lineTo(z+B,F+I),(B!==0||G!==0)&&E.bezierCurveTo(z+B*U,F+I,z,F+I-G*U,z,F+I-G),E.lineTo(z,F+G),(B!==0||G!==0)&&E.bezierCurveTo(z,F+G*U,z+B*U,F,z+B,F),E}function h(k){function z(P,I,U){const E=b(I),Z=b(U);G===0?B.moveTo(E,Z):B.lineTo(E,Z),G++}const F=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,B=new l.ShapePath;let G=0;return k.getAttribute("points").replace(F,z),B.currentPath.autoClose=!0,B}function d(k){function z(P,I,U){const E=b(I),Z=b(U);G===0?B.moveTo(E,Z):B.lineTo(E,Z),G++}const F=/([+-]?\d*\.?\d+(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g,B=new l.ShapePath;let G=0;return k.getAttribute("points").replace(F,z),B.currentPath.autoClose=!1,B}function f(k){const z=b(k.getAttribute("cx")||0),F=b(k.getAttribute("cy")||0),B=b(k.getAttribute("r")||0),G=new l.Path;G.absarc(z,F,B,0,Math.PI*2);const P=new l.ShapePath;return P.subPaths.push(G),P}function p(k){const z=b(k.getAttribute("cx")||0),F=b(k.getAttribute("cy")||0),B=b(k.getAttribute("rx")||0),G=b(k.getAttribute("ry")||0),P=new l.Path;P.absellipse(z,F,B,G,0,Math.PI*2);const I=new l.ShapePath;return I.subPaths.push(P),I}function m(k){const z=b(k.getAttribute("x1")||0),F=b(k.getAttribute("y1")||0),B=b(k.getAttribute("x2")||0),G=b(k.getAttribute("y2")||0),P=new l.ShapePath;return P.moveTo(z,F),P.lineTo(B,G),P.currentPath.autoClose=!1,P}function _(k,z){z=Object.assign({},z);let F={};if(k.hasAttribute("class")){const I=k.getAttribute("class").split(/\s/).filter(Boolean).map(U=>U.trim());for(let U=0;U<I.length;U++)F=Object.assign(F,V["."+I[U]])}k.hasAttribute("id")&&(F=Object.assign(F,V["#"+k.getAttribute("id")]));function B(I,U,E){E===void 0&&(E=function(j){return j.startsWith("url")&&console.warn("SVGLoader: url access in attributes is not implemented."),j}),k.hasAttribute(I)&&(z[U]=E(k.getAttribute(I))),F[I]&&(z[U]=E(F[I])),k.style&&k.style[I]!==""&&(z[U]=E(k.style[I]))}function G(I){return Math.max(0,Math.min(1,b(I)))}function P(I){return Math.max(0,b(I))}return B("fill","fill"),B("fill-opacity","fillOpacity",G),B("fill-rule","fillRule"),B("opacity","opacity",G),B("stroke","stroke"),B("stroke-opacity","strokeOpacity",G),B("stroke-width","strokeWidth",P),B("stroke-linejoin","strokeLineJoin"),B("stroke-linecap","strokeLineCap"),B("stroke-miterlimit","strokeMiterLimit",P),B("visibility","visibility"),z}function v(k,z){return k-(z-k)}function y(k,z,F){if(typeof k!="string")throw new TypeError("Invalid input: "+typeof k);const B={SEPARATOR:/[ \t\r\n\,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/[\d]/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/},G=0,P=1,I=2,U=3;let E=G,Z=!0,j="",$="";const ne=[];function ie(he,_e,Oe){const De=new SyntaxError('Unexpected character "'+he+'" at index '+_e+".");throw De.partial=Oe,De}function W(){j!==""&&($===""?ne.push(Number(j)):ne.push(Number(j)*Math.pow(10,Number($)))),j="",$=""}let N;const ae=k.length;for(let he=0;he<ae;he++){if(N=k[he],Array.isArray(z)&&z.includes(ne.length%F)&&B.FLAGS.test(N)){E=P,j=N,W();continue}if(E===G){if(B.WHITESPACE.test(N))continue;if(B.DIGIT.test(N)||B.SIGN.test(N)){E=P,j=N;continue}if(B.POINT.test(N)){E=I,j=N;continue}B.COMMA.test(N)&&(Z&&ie(N,he,ne),Z=!0)}if(E===P){if(B.DIGIT.test(N)){j+=N;continue}if(B.POINT.test(N)){j+=N,E=I;continue}if(B.EXP.test(N)){E=U;continue}B.SIGN.test(N)&&j.length===1&&B.SIGN.test(j[0])&&ie(N,he,ne)}if(E===I){if(B.DIGIT.test(N)){j+=N;continue}if(B.EXP.test(N)){E=U;continue}B.POINT.test(N)&&j[j.length-1]==="."&&ie(N,he,ne)}if(E===U){if(B.DIGIT.test(N)){$+=N;continue}if(B.SIGN.test(N)){if($===""){$+=N;continue}$.length===1&&B.SIGN.test($)&&ie(N,he,ne)}}B.WHITESPACE.test(N)?(W(),E=G,Z=!1):B.COMMA.test(N)?(W(),E=G,Z=!0):B.SIGN.test(N)?(W(),E=P,j=N):B.POINT.test(N)?(W(),E=I,j=N):ie(N,he,ne)}return W(),ne}const g=["mm","cm","in","pt","pc","px"],M={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 b(k){let z="px";if(typeof k=="string"||k instanceof String)for(let B=0,G=g.length;B<G;B++){const P=g[B];if(k.endsWith(P)){z=P,k=k.substring(0,k.length-P.length);break}}let F;return z==="px"&&t.defaultUnit!=="px"?F=M.in[t.defaultUnit]/t.defaultDPI:(F=M[z][t.defaultUnit],F<0&&(F=M[z].in*t.defaultDPI)),F*parseFloat(k)}function S(k){if(!(k.hasAttribute("transform")||k.nodeName==="use"&&(k.hasAttribute("x")||k.hasAttribute("y"))))return null;const z=O(k);return R.length>0&&z.premultiply(R[R.length-1]),ce.copy(z),R.push(z),z}function O(k){const z=new l.Matrix3,F=X;if(k.nodeName==="use"&&(k.hasAttribute("x")||k.hasAttribute("y"))){const B=b(k.getAttribute("x")),G=b(k.getAttribute("y"));z.translate(B,G)}if(k.hasAttribute("transform")){const B=k.getAttribute("transform").split(")");for(let G=B.length-1;G>=0;G--){const P=B[G].trim();if(P==="")continue;const I=P.indexOf("("),U=P.length;if(I>0&&I<U){const E=P.slice(0,I),Z=y(P.slice(I+1));switch(F.identity(),E){case"translate":if(Z.length>=1){const j=Z[0];let $=0;Z.length>=2&&($=Z[1]),F.translate(j,$)}break;case"rotate":if(Z.length>=1){let j=0,$=0,ne=0;j=Z[0]*Math.PI/180,Z.length>=3&&($=Z[1],ne=Z[2]),Y.makeTranslation(-$,-ne),J.makeRotation(j),q.multiplyMatrices(J,Y),Y.makeTranslation($,ne),F.multiplyMatrices(Y,q)}break;case"scale":if(Z.length>=1){const j=Z[0];let $=j;Z.length>=2&&($=Z[1]),F.scale(j,$)}break;case"skewX":Z.length===1&&F.set(1,Math.tan(Z[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":Z.length===1&&F.set(1,0,0,Math.tan(Z[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":Z.length===6&&F.set(Z[0],Z[2],Z[4],Z[1],Z[3],Z[5],0,0,1);break}}z.premultiply(F)}}return z}function T(k,z){function F(I){ee.set(I.x,I.y,1).applyMatrix3(z),I.set(ee.x,ee.y)}function B(I){const U=I.xRadius,E=I.yRadius,Z=Math.cos(I.aRotation),j=Math.sin(I.aRotation),$=new l.Vector3(U*Z,U*j,0),ne=new l.Vector3(-E*j,E*Z,0),ie=$.applyMatrix3(z),W=ne.applyMatrix3(z),N=X.set(ie.x,W.x,0,ie.y,W.y,0,0,0,1),ae=Y.copy(N).invert(),Oe=J.copy(ae).transpose().multiply(ae).elements,De=D(Oe[0],Oe[1],Oe[4]),$e=Math.sqrt(De.rt1),dt=Math.sqrt(De.rt2);if(I.xRadius=1/$e,I.yRadius=1/dt,I.aRotation=Math.atan2(De.sn,De.cs),!((I.aEndAngle-I.aStartAngle)%(2*Math.PI)<Number.EPSILON)){const Ze=Y.set($e,0,0,0,dt,0,0,0,1),mn=J.set(De.cs,De.sn,0,-De.sn,De.cs,0,0,0,1),Ut=Ze.multiply(mn).multiply(N),Yn=Wn=>{const{x:Xn,y:gn}=new l.Vector3(Math.cos(Wn),Math.sin(Wn),0).applyMatrix3(Ut);return Math.atan2(gn,Xn)};I.aStartAngle=Yn(I.aStartAngle),I.aEndAngle=Yn(I.aEndAngle),C(z)&&(I.aClockwise=!I.aClockwise)}}function G(I){const U=A(z),E=x(z);I.xRadius*=U,I.yRadius*=E;const Z=U>Number.EPSILON?Math.atan2(z.elements[1],z.elements[0]):Math.atan2(-z.elements[3],z.elements[4]);I.aRotation+=Z,C(z)&&(I.aStartAngle*=-1,I.aEndAngle*=-1,I.aClockwise=!I.aClockwise)}const P=k.subPaths;for(let I=0,U=P.length;I<U;I++){const Z=P[I].curves;for(let j=0;j<Z.length;j++){const $=Z[j];$.isLineCurve?(F($.v1),F($.v2)):$.isCubicBezierCurve?(F($.v0),F($.v1),F($.v2),F($.v3)):$.isQuadraticBezierCurve?(F($.v0),F($.v1),F($.v2)):$.isEllipseCurve&&(re.set($.aX,$.aY),F(re),$.aX=re.x,$.aY=re.y,w(z)?B($):G($))}}}function C(k){const z=k.elements;return z[0]*z[4]-z[1]*z[3]<0}function w(k){const z=k.elements,F=z[0]*z[3]+z[1]*z[4];if(F===0)return!1;const B=A(k),G=x(k);return Math.abs(F/(B*G))>Number.EPSILON}function A(k){const z=k.elements;return Math.sqrt(z[0]*z[0]+z[1]*z[1])}function x(k){const z=k.elements;return Math.sqrt(z[3]*z[3]+z[4]*z[4])}function D(k,z,F){let B,G,P,I,U;const E=k+F,Z=k-F,j=Math.sqrt(Z*Z+4*z*z);return E>0?(B=.5*(E+j),U=1/B,G=k*U*F-z*U*z):E<0?G=.5*(E-j):(B=.5*j,G=-.5*j),Z>0?P=Z+j:P=Z-j,Math.abs(P)>2*Math.abs(z)?(U=-2*z/P,I=1/Math.sqrt(1+U*U),P=U*I):Math.abs(z)===0?(P=1,I=0):(U=-.5*P/z,P=1/Math.sqrt(1+U*U),I=U*P),Z>0&&(U=P,P=-I,I=U),{rt1:B,rt2:G,cs:P,sn:I}}const L=[],V={},R=[],X=new l.Matrix3,Y=new l.Matrix3,J=new l.Matrix3,q=new l.Matrix3,re=new l.Vector2,ee=new l.Vector3,ce=new l.Matrix3,le=new DOMParser().parseFromString(e,"image/svg+xml");return n(le.documentElement,{fill:"#000",fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeLineJoin:"miter",strokeLineCap:"butt",strokeMiterLimit:4}),{paths:L,xml:le.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,y,g,M){const b=v.x,S=y.x,O=g.x,T=M.x,C=v.y,w=y.y,A=g.y,x=M.y,D=(T-O)*(C-A)-(x-A)*(b-O),L=(S-b)*(C-A)-(w-C)*(b-O),V=(x-A)*(S-b)-(T-O)*(w-C),R=D/V,X=L/V;if(V===0&&D!==0||R<=0||R>=1||X<0||X>1)return null;if(D===0&&V===0){for(let Y=0;Y<2;Y++)if(i(Y===0?g:M,v,y),r.loc==n.ORIGIN){const J=Y===0?g:M;return{x:J.x,y:J.y,t:r.t}}else if(r.loc==n.BETWEEN){const J=+(b+r.t*(S-b)).toPrecision(10),q=+(C+r.t*(w-C)).toPrecision(10);return{x:J,y:q,t:r.t}}return null}else{for(let q=0;q<2;q++)if(i(q===0?g:M,v,y),r.loc==n.ORIGIN){const re=q===0?g:M;return{x:re.x,y:re.y,t:r.t}}const Y=+(b+R*(S-b)).toPrecision(10),J=+(C+R*(w-C)).toPrecision(10);return{x:Y,y:J,t:R}}}function i(v,y,g){const M=g.x-y.x,b=g.y-y.y,S=v.x-y.x,O=v.y-y.y,T=M*O-S*b;if(v.x===y.x&&v.y===y.y){r.loc=n.ORIGIN,r.t=0;return}if(v.x===g.x&&v.y===g.y){r.loc=n.DESTINATION,r.t=1;return}if(T<-Number.EPSILON){r.loc=n.LEFT;return}if(T>Number.EPSILON){r.loc=n.RIGHT;return}if(M*S<0||b*O<0){r.loc=n.BEHIND;return}if(Math.sqrt(M*M+b*b)<Math.sqrt(S*S+O*O)){r.loc=n.BEYOND;return}let C;M!==0?C=S/M:C=O/b,r.loc=n.BETWEEN,r.t=C}function a(v,y){const g=[],M=[];for(let b=1;b<v.length;b++){const S=v[b-1],O=v[b];for(let T=1;T<y.length;T++){const C=y[T-1],w=y[T],A=s(S,O,C,w);A!==null&&g.find(x=>x.t<=A.t+Number.EPSILON&&x.t>=A.t-Number.EPSILON)===void 0&&(g.push(A),M.push(new l.Vector2(A.x,A.y)))}}return M}function c(v,y,g){const M=new l.Vector2;y.getCenter(M);const b=[];return g.forEach(S=>{S.boundingBox.containsPoint(M)&&a(v,S.points).forEach(T=>{b.push({identifier:S.identifier,isCW:S.isCW,point:T})})}),b.sort((S,O)=>S.point.x-O.point.x),b}function h(v,y,g,M,b){(b==null||b==="")&&(b="nonzero");const S=new l.Vector2;v.boundingBox.getCenter(S);const O=[new l.Vector2(g,S.y),new l.Vector2(M,S.y)],T=c(O,v.boundingBox,y);T.sort((L,V)=>L.point.x-V.point.x);const C=[],w=[];T.forEach(L=>{L.identifier===v.identifier?C.push(L):w.push(L)});const A=C[0].point.x,x=[];let D=0;for(;D<w.length&&w[D].point.x<A;)x.length>0&&x[x.length-1]===w[D].identifier?x.pop():x.push(w[D].identifier),D++;if(x.push(v.identifier),b==="evenodd"){const L=x.length%2===0,V=x[x.length-2];return{identifier:v.identifier,isHole:L,for:V}}else if(b==="nonzero"){let L=!0,V=null,R=null;for(let X=0;X<x.length;X++){const Y=x[X];L?(R=y[Y].isCW,L=!1,V=Y):R!==y[Y].isCW&&(R=y[Y].isCW,L=!0)}return{identifier:v.identifier,isHole:L,for:V}}else console.warn('fill-rule: "'+b+'" is currently not implemented.')}let d=999999999,f=-999999999,p=e.subPaths.map(v=>{const y=v.getPoints();let g=-999999999,M=999999999,b=-999999999,S=999999999;for(let O=0;O<y.length;O++){const T=y[O];T.y>g&&(g=T.y),T.y<M&&(M=T.y),T.x>b&&(b=T.x),T.x<S&&(S=T.x)}return f<=b&&(f=b+1),d>=S&&(d=S-1),{curves:v.curves,points:y,isCW:l.ShapeUtils.isClockWise(y),identifier:-1,boundingBox:new l.Box2(new l.Vector2(S,M),new l.Vector2(b,g))}});p=p.filter(v=>v.points.length>1);for(let v=0;v<p.length;v++)p[v].identifier=v;const m=p.map(v=>h(v,p,d,f,e.userData?e.userData.style.fillRule:void 0)),_=[];return p.forEach(v=>{if(!m[v.identifier].isHole){const g=new l.Shape;g.curves=v.curves,m.filter(b=>b.isHole&&b.for===v.identifier).forEach(b=>{const S=p[b.identifier],O=new l.Path;O.curves=S.curves,g.holes.push(O)}),_.push(g)}}),_}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(tn.pointsToStrokeWithBuffers(e,t,n,r,s,i,a)===0)return null;const c=new l.BufferGeometry;return c.setAttribute("position",new l.Float32BufferAttribute(s,3)),c.setAttribute("normal",new l.Float32BufferAttribute(i,3)),c.setAttribute("uv",new l.Float32BufferAttribute(a,2)),c}static pointsToStrokeWithBuffers(e,t,n,r,s,i,a,c){const h=new l.Vector2,d=new l.Vector2,f=new l.Vector2,p=new l.Vector2,m=new l.Vector2,_=new l.Vector2,v=new l.Vector2,y=new l.Vector2,g=new l.Vector2,M=new l.Vector2,b=new l.Vector2,S=new l.Vector2,O=new l.Vector2,T=new l.Vector2,C=new l.Vector2,w=new l.Vector2,A=new l.Vector2;n=n!==void 0?n:12,r=r!==void 0?r:.001,c=c!==void 0?c:0,e=Z(e);const x=e.length;if(x<2)return 0;const D=e[0].equals(e[x-1]);let L,V=e[0],R;const X=t.strokeWidth/2,Y=1/(x-1);let J=0,q,re,ee,ce,le=!1,me=0,k=c*3,z=c*2;F(e[0],e[1],h).multiplyScalar(X),y.copy(e[0]).sub(h),g.copy(e[0]).add(h),M.copy(y),b.copy(g);for(let j=1;j<x;j++){L=e[j],j===x-1?D?R=e[1]:R=void 0:R=e[j+1];const $=h;if(F(V,L,$),f.copy($).multiplyScalar(X),S.copy(L).sub(f),O.copy(L).add(f),q=J+Y,re=!1,R!==void 0){F(L,R,d),f.copy(d).multiplyScalar(X),T.copy(L).sub(f),C.copy(L).add(f),ee=!0,f.subVectors(R,V),$.dot(f)<0&&(ee=!1),j===1&&(le=ee),f.subVectors(R,L),f.normalize();const ne=Math.abs($.dot(f));if(ne>Number.EPSILON){const ie=X/ne;f.multiplyScalar(-ie),p.subVectors(L,V),m.copy(p).setLength(ie).add(f),w.copy(m).negate();const W=m.length(),N=p.length();p.divideScalar(N),_.subVectors(R,L);const ae=_.length();switch(_.divideScalar(ae),p.dot(w)<N&&_.dot(w)<ae&&(re=!0),A.copy(m).add(L),w.add(L),ce=!1,re?ee?(C.copy(w),O.copy(w)):(T.copy(w),S.copy(w)):P(),t.strokeLineJoin){case"bevel":I(ee,re,q);break;case"round":U(ee,re),ee?G(L,S,T,q,0):G(L,C,O,q,1);break;case"miter":case"miter-clip":default:const he=X*t.strokeMiterLimit/W;if(he<1)if(t.strokeLineJoin!=="miter-clip"){I(ee,re,q);break}else U(ee,re),ee?(_.subVectors(A,S).multiplyScalar(he).add(S),v.subVectors(A,T).multiplyScalar(he).add(T),B(S,q,0),B(_,q,0),B(L,q,.5),B(L,q,.5),B(_,q,0),B(v,q,0),B(L,q,.5),B(v,q,0),B(T,q,0)):(_.subVectors(A,O).multiplyScalar(he).add(O),v.subVectors(A,C).multiplyScalar(he).add(C),B(O,q,1),B(_,q,1),B(L,q,.5),B(L,q,.5),B(_,q,1),B(v,q,1),B(L,q,.5),B(v,q,1),B(C,q,1));else re?(ee?(B(g,J,1),B(y,J,0),B(A,q,0),B(g,J,1),B(A,q,0),B(w,q,1)):(B(g,J,1),B(y,J,0),B(A,q,1),B(y,J,0),B(w,q,0),B(A,q,1)),ee?T.copy(A):C.copy(A)):ee?(B(S,q,0),B(A,q,0),B(L,q,.5),B(L,q,.5),B(A,q,0),B(T,q,0)):(B(O,q,1),B(A,q,1),B(L,q,.5),B(L,q,.5),B(A,q,1),B(C,q,1)),ce=!0;break}}else P()}else P();!D&&j===x-1&&E(e[0],M,b,ee,!0,J),J=q,V=L,y.copy(T),g.copy(C)}if(!D)E(L,S,O,ee,!1,q);else if(re&&s){let j=A,$=w;le!==ee&&(j=w,$=A),ee?(ce||le)&&($.toArray(s,0*3),$.toArray(s,3*3),ce&&j.toArray(s,1*3)):(ce||!le)&&($.toArray(s,1*3),$.toArray(s,3*3),ce&&j.toArray(s,0*3))}return me;function F(j,$,ne){return ne.subVectors($,j),ne.set(-ne.y,ne.x).normalize()}function B(j,$,ne){s&&(s[k]=j.x,s[k+1]=j.y,s[k+2]=0,i&&(i[k]=0,i[k+1]=0,i[k+2]=1),k+=3,a&&(a[z]=$,a[z+1]=ne,z+=2)),me+=3}function G(j,$,ne,ie,W){h.copy($).sub(j).normalize(),d.copy(ne).sub(j).normalize();let N=Math.PI;const ae=h.dot(d);Math.abs(ae)<1&&(N=Math.abs(Math.acos(ae))),N/=n,f.copy($);for(let he=0,_e=n-1;he<_e;he++)p.copy(f).rotateAround(j,N),B(f,ie,W),B(p,ie,W),B(j,ie,.5),f.copy(p);B(p,ie,W),B(ne,ie,W),B(j,ie,.5)}function P(){B(g,J,1),B(y,J,0),B(S,q,0),B(g,J,1),B(S,q,0),B(O,q,1)}function I(j,$,ne){$?j?(B(g,J,1),B(y,J,0),B(S,q,0),B(g,J,1),B(S,q,0),B(w,q,1),B(S,ne,0),B(T,ne,0),B(w,ne,.5)):(B(g,J,1),B(y,J,0),B(O,q,1),B(y,J,0),B(w,q,0),B(O,q,1),B(O,ne,1),B(w,ne,0),B(C,ne,1)):j?(B(S,ne,0),B(T,ne,0),B(L,ne,.5)):(B(O,ne,1),B(C,ne,0),B(L,ne,.5))}function U(j,$){$&&(j?(B(g,J,1),B(y,J,0),B(S,q,0),B(g,J,1),B(S,q,0),B(w,q,1),B(S,J,0),B(L,q,.5),B(w,q,1),B(L,q,.5),B(T,J,0),B(w,q,1)):(B(g,J,1),B(y,J,0),B(O,q,1),B(y,J,0),B(w,q,0),B(O,q,1),B(O,J,1),B(w,q,0),B(L,q,.5),B(L,q,.5),B(w,q,0),B(C,J,1)))}function E(j,$,ne,ie,W,N){switch(t.strokeLineCap){case"round":W?G(j,ne,$,N,.5):G(j,$,ne,N,.5);break;case"square":if(W)h.subVectors($,j),d.set(h.y,-h.x),f.addVectors(h,d).add(j),p.subVectors(d,h).add(j),ie?(f.toArray(s,1*3),p.toArray(s,0*3),p.toArray(s,3*3)):(f.toArray(s,1*3),a[3*2+1]===1?p.toArray(s,3*3):f.toArray(s,3*3),p.toArray(s,0*3));else{h.subVectors(ne,j),d.set(h.y,-h.x),f.addVectors(h,d).add(j),p.subVectors(d,h).add(j);const ae=s.length;ie?(f.toArray(s,ae-1*3),p.toArray(s,ae-2*3),p.toArray(s,ae-4*3)):(p.toArray(s,ae-2*3),f.toArray(s,ae-1*3),p.toArray(s,ae-4*3))}break}}function Z(j){let $=!1;for(let ie=1,W=j.length-1;ie<W;ie++)if(j[ie].distanceTo(j[ie+1])<r){$=!0;break}if(!$)return j;const ne=[];ne.push(j[0]);for(let ie=1,W=j.length-1;ie<W;ie++)j[ie].distanceTo(j[ie+1])>=r&&ne.push(j[ie]);return ne.push(j[j.length-1]),ne}}}const pr=new WeakMap;class Ml extends l.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 l.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 c in t.attributeTypes){const h=t.attributeTypes[c];h.BYTES_PER_ELEMENT!==void 0&&(t.attributeTypes[c]=h.name)}const n=JSON.stringify(t);if(pr.has(e)){const c=pr.get(e);if(c.key===n)return c.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(c=>(r=c,new Promise((h,d)=>{r._callbacks[s]={resolve:h,reject:d},r.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(c=>this._createGeometry(c.geometry));return a.catch(()=>!0).then(()=>{r&&s&&this._releaseTask(r,s)}),pr.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new l.BufferGeometry;e.index&&t.setIndex(new l.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 l.BufferAttribute(i,a))}return t}_loadLibrary(e,t){const n=new l.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=Sl.toString(),i=["/* draco decoder */",r,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
395
|
+
`);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 Sl(){let o,e;onmessage=function(i){const a=i.data;switch(a.type){case"init":o=a.decoderConfig,e=new Promise(function(d){o.onModuleLoaded=function(f){d({draco:f})},DracoDecoderModule(o)});break;case"decode":const c=a.buffer,h=a.taskConfig;e.then(d=>{const f=d.draco,p=new f.Decoder,m=new f.DecoderBuffer;m.Init(new Int8Array(c),c.byteLength);try{const _=t(f,p,m,h),v=_.attributes.map(y=>y.array.buffer);_.index&&v.push(_.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:_},v)}catch(_){console.error(_),self.postMessage({type:"error",id:a.id,error:_.message})}finally{f.destroy(m),f.destroy(p)}});break}};function t(i,a,c,h){const d=h.attributeIDs,f=h.attributeTypes;let p,m;const _=a.GetEncodedGeometryType(c);if(_===i.TRIANGULAR_MESH)p=new i.Mesh,m=a.DecodeBufferToMesh(c,p);else if(_===i.POINT_CLOUD)p=new i.PointCloud,m=a.DecodeBufferToPointCloud(c,p);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!m.ok()||p.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+m.error_msg());const v={index:null,attributes:[]};for(const y in d){const g=self[f[y]];let M,b;if(h.useUniqueIDs)b=d[y],M=a.GetAttributeByUniqueId(p,b);else{if(b=a.GetAttributeId(p,i[d[y]]),b===-1)continue;M=a.GetAttribute(p,b)}v.attributes.push(r(i,a,p,y,g,M))}return _===i.TRIANGULAR_MESH&&(v.index=n(i,a,p)),i.destroy(p),v}function n(i,a,c){const d=c.num_faces()*3,f=d*4,p=i._malloc(f);a.GetTrianglesUInt32Array(c,f,p);const m=new Uint32Array(i.HEAPF32.buffer,p,d).slice();return i._free(p),{array:m,itemSize:1}}function r(i,a,c,h,d,f){const p=f.num_components(),_=c.num_points()*p,v=_*d.BYTES_PER_ELEMENT,y=s(i,d),g=i._malloc(v);a.GetAttributeDataArrayForAllPoints(c,f,y,v,g);const M=new d(i.HEAPF32.buffer,g,_).slice();return i._free(g),{name:h,array:M,itemSize:p}}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}}}function Ie(o){const{render:e,invalidate:t}=te.useTresContext();function n(){e.mode.value==="on-demand"&&t()}return u.watch(o,()=>{n()}),{invalidateOnDemand:n}}const Al=["args","center"],Cl=u.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:c,size:h,height:d,curveSegments:f,bevelEnabled:p,bevelThickness:m,bevelSize:_,bevelOffset:v,bevelSegments:y}=u.toRefs(r);Ie(r);const{extend:g}=te.useTresContext();g({TextGeometry:Ts});const M=new vl,b=u.useSlots(),S=u.computed(()=>{var w;return a!=null&&a.value?a.value:b.default?(w=b.default()[0].children)==null?void 0:w.trim():c.value?"":"TresJS"}),O=u.shallowRef();e({instance:O});const T=([t,n]=u.withAsyncContext(()=>new Promise((w,A)=>{try{typeof i.value=="string"?M.load(i.value,x=>{w(x)}):w(i.value)}catch(x){A(console.error("cientos",x))}})),t=await t,n(),t),C=u.computed(()=>({font:T,size:u.toValue(h),height:u.toValue(d),curveSegments:u.toValue(f),bevelEnabled:u.toValue(p),bevelThickness:u.toValue(m),bevelSize:u.toValue(_),bevelOffset:u.toValue(v),bevelSegments:u.toValue(y)}));return u.watchEffect(()=>{O.value&&c.value&&(O.value.geometry.dispose(),O.value.geometry=new Ts(S.value,C.value),s.value&&O.value.geometry.center())}),(w,A)=>u.unref(i)?(u.openBlock(),u.createElementBlock("TresMesh",{key:0,ref_key:"text3DRef",ref:O},[S.value?(u.openBlock(),u.createElementBlock("TresTextGeometry",{key:0,args:[S.value,C.value],center:u.unref(s)},null,8,Al)):u.createCommentVNode("",!0),u.renderSlot(w.$slots,"default")],512)):u.createCommentVNode("",!0)}});function Pl(o,e){const t=u.ref(e),n=new l.AnimationMixer(t.value),r=u.shallowReactive({});o.forEach(i=>{const a=n.clipAction(i,t.value);r[i.name]=a});const{onBeforeRender:s}=te.useLoop();return s(({delta:i})=>{n.update(i)}),{actions:r,mixer:n}}const Tl=u.defineComponent({__name:"Levioso",props:{speed:{default:1},rotationFactor:{default:1},floatFactor:{default:1},range:{default:()=>[-.1,.1]}},setup(o,{expose:e}){const t=o,{invalidateOnDemand:n}=Ie(t),r=u.shallowRef();e({instance:r});{const h=Math.random()*1e4,{onBeforeRender:d}=te.useLoop();let f=h;d(({delta:p})=>{if(!r.value)return;f+=p*t.speed;const m=f*.25,_=r.value;_.rotation.x=Math.cos(m)*.125*t.rotationFactor,_.rotation.y=Math.sin(m)*.125*t.rotationFactor,_.rotation.z=Math.sin(m)*.05*t.rotationFactor,_.position.y=l.MathUtils.mapLinear(Math.sin(m),-1,1,t.range[0],t.range[1])*t.floatFactor,n()})}return(s,i)=>(u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps(s.$attrs,{ref_key:"groupRef",ref:r}),[u.renderSlot(s.$slots,"default")],16))}}),Il=["args","material-uniforms-color-value"],Ol=u.createElementVNode("TresPlaneGeometry",{args:[5,5]},null,-1),Dl=u.defineComponent({__name:"Reflector",props:{color:{default:"#333"},textureWidth:{default:512},textureHeight:{default:512},clipBias:{default:0},multisample:{default:4},shader:{default:rr.ReflectorShader}},setup(o,{expose:e}){const t=o,{extend:n}=te.useTresContext(),r=u.shallowRef();n({Reflector:rr});const{color:s,textureWidth:i,textureHeight:a,clipBias:c,multisample:h,shader:d}=u.toRefs(t);return Ie(t),e({instance:r}),(f,p)=>(u.openBlock(),u.createElementBlock("TresReflector",{ref_key:"reflectorRef",ref:r,args:[void 0,{textureWidth:u.unref(i),textureHeight:u.unref(a),clipBias:u.unref(c),multisample:u.unref(h),shader:u.unref(d)}],"material-uniforms-color-value":u.unref(s)},[u.renderSlot(f.$slots,"default",{},()=>[Ol])],8,Il))}});function mr(o){return u.getCurrentScope()?(u.onScopeDispose(o),!0):!1}function Ee(o){return typeof o=="function"?o():u.unref(o)}const Ll=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const kl=Object.prototype.toString,Bl=o=>kl.call(o)==="[object Object]",xt=()=>{};function gr(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 Fl=o=>o();function Ul(o,e={}){let t,n,r=xt;const s=a=>{clearTimeout(a),r(),r=xt};return a=>{const c=Ee(o),h=Ee(e.maxWait);return t&&s(t),c<=0||h!==void 0&&h<=0?(n&&(s(n),n=null),Promise.resolve(a())):new Promise((d,f)=>{r=e.rejectOnCancel?f:d,h&&!n&&(n=setTimeout(()=>{t&&s(t),n=null,d(a())},h)),t=setTimeout(()=>{n&&s(n),n=null,d(a())},c)})}}function Vs(...o){let e=0,t,n=!0,r=xt,s,i,a,c,h;!u.isRef(o[0])&&typeof o[0]=="object"?{delay:i,trailing:a=!0,leading:c=!0,rejectOnCancel:h=!1}=o[0]:[i,a=!0,c=!0,h=!1]=o;const d=()=>{t&&(clearTimeout(t),t=void 0,r(),r=xt)};return p=>{const m=Ee(i),_=Date.now()-e,v=()=>s=p();return d(),m<=0?(e=Date.now(),v()):(_>m&&(c||!n)?(e=Date.now(),v()):a&&(s=new Promise((y,g)=>{r=h?g:y,t=setTimeout(()=>{e=Date.now(),n=!0,y(v()),d()},Math.max(0,m-_))})),!c&&!t&&(t=setTimeout(()=>n=!0,m)),n=!1,s)}}function Nl(o){return u.getCurrentInstance()}function zl(o,e=200,t={}){return gr(Ul(e,t),o)}function Vl(o,e=200,t=!1,n=!0,r=!1){return gr(Vs(e,t,n,r),o)}function Rl(o,e,t={}){const{eventFilter:n=Fl,...r}=t;return u.watch(o,gr(n,e),r)}function yr(o,e=!0,t){Nl()?u.onMounted(o,t):e?o():u.nextTick(o)}function Gl(o,e,t={}){const{throttle:n=0,trailing:r=!0,leading:s=!0,...i}=t;return Rl(o,e,{...i,eventFilter:Vs(n,r,s)})}function wt(o){var e;const t=Ee(o);return(e=t==null?void 0:t.$el)!=null?e:t}const ht=Ll?window:void 0;function Ce(...o){let e,t,n,r;if(typeof o[0]=="string"||Array.isArray(o[0])?([t,n,r]=o,e=ht):[e,t,n,r]=o,!e)return xt;Array.isArray(t)||(t=[t]),Array.isArray(n)||(n=[n]);const s=[],i=()=>{s.forEach(d=>d()),s.length=0},a=(d,f,p,m)=>(d.addEventListener(f,p,m),()=>d.removeEventListener(f,p,m)),c=u.watch(()=>[wt(e),Ee(r)],([d,f])=>{if(i(),!d)return;const p=Bl(f)?{...f}:f;s.push(...t.flatMap(m=>n.map(_=>a(d,m,_,p))))},{immediate:!0,flush:"post"}),h=()=>{c(),i()};return mr(h),h}function jl(){const o=u.ref(!1),e=u.getCurrentInstance();return e&&u.onMounted(()=>{o.value=!0},e),o}function Rs(o){const e=jl();return u.computed(()=>(e.value,!!o()))}function El(o,e={}){const{window:t=ht}=e,n=Rs(()=>t&&"matchMedia"in t&&typeof t.matchMedia=="function");let r;const s=u.ref(!1),i=h=>{s.value=h.matches},a=()=>{r&&("removeEventListener"in r?r.removeEventListener("change",i):r.removeListener(i))},c=u.watchEffect(()=>{n.value&&(a(),r=t.matchMedia(Ee(o)),"addEventListener"in r?r.addEventListener("change",i):r.addListener(i),s.value=r.matches)});return mr(()=>{c(),a(),r=void 0}),s}function Yl(o,e,t={}){const{window:n=ht,...r}=t;let s;const i=Rs(()=>n&&"ResizeObserver"in n),a=()=>{s&&(s.disconnect(),s=void 0)},c=u.computed(()=>Array.isArray(o)?o.map(f=>wt(f)):[wt(o)]),h=u.watch(c,f=>{if(a(),i.value&&n){s=new ResizeObserver(e);for(const p of f)p&&s.observe(p,r)}},{immediate:!0,flush:"post"}),d=()=>{a(),h()};return mr(d),{isSupported:i,stop:d}}function Wl(o,e={width:0,height:0},t={}){const{window:n=ht,box:r="content-box"}=t,s=u.computed(()=>{var f,p;return(p=(f=wt(o))==null?void 0:f.namespaceURI)==null?void 0:p.includes("svg")}),i=u.ref(e.width),a=u.ref(e.height),{stop:c}=Yl(o,([f])=>{const p=r==="border-box"?f.borderBoxSize:r==="content-box"?f.contentBoxSize:f.devicePixelContentBoxSize;if(n&&s.value){const m=wt(o);if(m){const _=m.getBoundingClientRect();i.value=_.width,a.value=_.height}}else if(p){const m=Array.isArray(p)?p:[p];i.value=m.reduce((_,{inlineSize:v})=>_+v,0),a.value=m.reduce((_,{blockSize:v})=>_+v,0)}else i.value=f.contentRect.width,a.value=f.contentRect.height},t);yr(()=>{const f=wt(o);f&&(i.value="offsetWidth"in f?f.offsetWidth:e.width,a.value="offsetHeight"in f?f.offsetHeight:e.height)});const h=u.watch(()=>wt(o),f=>{i.value=f?e.width:0,a.value=f?e.height:0});function d(){c(),h()}return{width:i,height:a,stop:d}}const Gs=1;function Xl(o,e={}){const{throttle:t=0,idle:n=200,onStop:r=xt,onScroll:s=xt,offset:i={left:0,right:0,top:0,bottom:0},eventListenerOptions:a={capture:!1,passive:!0},behavior:c="auto",window:h=ht,onError:d=C=>{console.error(C)}}=e,f=u.ref(0),p=u.ref(0),m=u.computed({get(){return f.value},set(C){v(C,void 0)}}),_=u.computed({get(){return p.value},set(C){v(void 0,C)}});function v(C,w){var A,x,D,L;if(!h)return;const V=Ee(o);if(!V)return;(D=V instanceof Document?h.document.body:V)==null||D.scrollTo({top:(A=Ee(w))!=null?A:_.value,left:(x=Ee(C))!=null?x:m.value,behavior:Ee(c)});const R=((L=V==null?void 0:V.document)==null?void 0:L.documentElement)||(V==null?void 0:V.documentElement)||V;m!=null&&(f.value=R.scrollLeft),_!=null&&(p.value=R.scrollTop)}const y=u.ref(!1),g=u.reactive({left:!0,right:!1,top:!0,bottom:!1}),M=u.reactive({left:!1,right:!1,top:!1,bottom:!1}),b=C=>{y.value&&(y.value=!1,M.left=!1,M.right=!1,M.top=!1,M.bottom=!1,r(C))},S=zl(b,t+n),O=C=>{var w;if(!h)return;const A=((w=C==null?void 0:C.document)==null?void 0:w.documentElement)||(C==null?void 0:C.documentElement)||wt(C),{display:x,flexDirection:D}=getComputedStyle(A),L=A.scrollLeft;M.left=L<f.value,M.right=L>f.value;const V=Math.abs(L)<=(i.left||0),R=Math.abs(L)+A.clientWidth>=A.scrollWidth-(i.right||0)-Gs;x==="flex"&&D==="row-reverse"?(g.left=R,g.right=V):(g.left=V,g.right=R),f.value=L;let X=A.scrollTop;C===h.document&&!X&&(X=h.document.body.scrollTop),M.top=X<p.value,M.bottom=X>p.value;const Y=Math.abs(X)<=(i.top||0),J=Math.abs(X)+A.clientHeight>=A.scrollHeight-(i.bottom||0)-Gs;x==="flex"&&D==="column-reverse"?(g.top=J,g.bottom=Y):(g.top=Y,g.bottom=J),p.value=X},T=C=>{var w;if(!h)return;const A=(w=C.target.documentElement)!=null?w:C.target;O(A),y.value=!0,S(C),s(C)};return Ce(o,"scroll",t?Vl(T,t,!0,!1):T,a),yr(()=>{try{const C=Ee(o);if(!C)return;O(C)}catch(C){d(C)}}),Ce(o,"scrollend",b,a),{x:m,y:_,isScrolling:y,arrivedState:g,directions:M,measure(){const C=Ee(o);h&&C&&O(C)}}}const Zl={ctrl:"control",command:"meta",cmd:"meta",option:"alt",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright"};function Kl(o={}){const{reactive:e=!1,target:t=ht,aliasMap:n=Zl,passive:r=!0,onEventFired:s=xt}=o,i=u.reactive(new Set),a={toJSON(){return{}},current:i},c=e?u.reactive(a):a,h=new Set,d=new Set;function f(v,y){v in c&&(e?c[v]=y:c[v].value=y)}function p(){i.clear();for(const v of d)f(v,!1)}function m(v,y){var g,M;const b=(g=v.key)==null?void 0:g.toLowerCase(),O=[(M=v.code)==null?void 0:M.toLowerCase(),b].filter(Boolean);b&&(y?i.add(b):i.delete(b));for(const T of O)d.add(T),f(T,y);b==="meta"&&!y?(h.forEach(T=>{i.delete(T),f(T,!1)}),h.clear()):typeof v.getModifierState=="function"&&v.getModifierState("Meta")&&y&&[...i,...O].forEach(T=>h.add(T))}Ce(t,"keydown",v=>(m(v,!0),s(v)),{passive:r}),Ce(t,"keyup",v=>(m(v,!1),s(v)),{passive:r}),Ce("blur",p,{passive:!0}),Ce("focus",p,{passive:!0});const _=new Proxy(c,{get(v,y,g){if(typeof y!="string")return Reflect.get(v,y,g);if(y=y.toLowerCase(),y in n&&(y=n[y]),!(y in c))if(/[+_-]/.test(y)){const b=y.split(/[+_-]/g).map(S=>S.trim());c[y]=u.computed(()=>b.every(S=>Ee(_[S])))}else c[y]=u.ref(!1);const M=Reflect.get(v,y,g);return e?Ee(M):M}});return _}const ql={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 Ql(o={}){const{type:e="page",touch:t=!0,resetOnTouchEnds:n=!1,initialValue:r={x:0,y:0},window:s=ht,target:i=s,scroll:a=!0,eventFilter:c}=o;let h=null;const d=u.ref(r.x),f=u.ref(r.y),p=u.ref(null),m=typeof e=="function"?e:ql[e],_=O=>{const T=m(O);h=O,T&&([d.value,f.value]=T,p.value="mouse")},v=O=>{if(O.touches.length>0){const T=m(O.touches[0]);T&&([d.value,f.value]=T,p.value="touch")}},y=()=>{if(!h||!s)return;const O=m(h);h instanceof MouseEvent&&O&&(d.value=O[0]+s.scrollX,f.value=O[1]+s.scrollY)},g=()=>{d.value=r.x,f.value=r.y},M=c?O=>c(()=>_(O),{}):O=>_(O),b=c?O=>c(()=>v(O),{}):O=>v(O),S=c?()=>c(()=>y(),{}):()=>y();if(i){const O={passive:!0};Ce(i,["mousemove","dragover"],M,O),t&&e!=="movement"&&(Ce(i,["touchstart","touchmove"],b,O),n&&Ce(i,"touchend",g,O)),a&&e==="page"&&Ce(s,"scroll",S,{passive:!0})}return{x:d,y:f,sourceType:p}}function Jl(o={}){const{window:e=ht,behavior:t="auto"}=o;if(!e)return{x:u.ref(0),y:u.ref(0)};const n=u.ref(e.scrollX),r=u.ref(e.scrollY),s=u.computed({get(){return n.value},set(a){scrollTo({left:a,behavior:t})}}),i=u.computed({get(){return r.value},set(a){scrollTo({top:a,behavior:t})}});return Ce(e,"scroll",()=>{n.value=e.scrollX,r.value=e.scrollY},{capture:!1,passive:!0}),{x:s,y:i}}function js(o={}){const{window:e=ht,initialWidth:t=Number.POSITIVE_INFINITY,initialHeight:n=Number.POSITIVE_INFINITY,listenOrientation:r=!0,includeScrollbar:s=!0}=o,i=u.ref(t),a=u.ref(n),c=()=>{e&&(s?(i.value=e.innerWidth,a.value=e.innerHeight):(i.value=e.document.documentElement.clientWidth,a.value=e.document.documentElement.clientHeight))};if(c(),yr(c),Ce("resize",c,{passive:!0}),r){const h=El("(orientation: portrait)");u.watch(h,()=>c())}return{width:i,height:a}}const Hl=u.defineComponent({__name:"MouseParallax",props:{disabled:{type:Boolean,default:!1},factor:{default:2.5},ease:{default:.1},local:{type:Boolean,default:!1}},setup(o){const e=o,{invalidateOnDemand:t}=Ie(e),{camera:n,renderer:r}=te.useTresContext(),{disabled:s,factor:i,ease:a,local:c}=u.toRefs(e),h={};c.value&&(h.target=r.value.domElement,h.type="client");const{x:d,y:f}=Ql(h),{width:p,height:m}=c.value?Wl(r.value.domElement):js(),_=u.shallowRef(),v=u.ref(),y=u.ref();u.watch([i,a],()=>{v.value=Array.isArray(i.value)?i.value:[i.value,i.value],y.value=Array.isArray(a.value)?a.value:[a.value,a.value]},{immediate:!0});const g=u.computed(()=>(d.value/p.value-.5)*v.value[0]),M=u.computed(()=>-(f.value/m.value-.5)*v.value[1]),{onBeforeRender:b}=te.useLoop();return b(({delta:S})=>{s.value||!_.value||Number.isNaN(g.value)||Number.isNaN(M.value)||(_.value.position.x+=(g.value-_.value.position.x)*y.value[0]*S,_.value.position.y+=(M.value-_.value.position.y)*y.value[1]*S,t())}),u.watch(()=>_.value,S=>S==null?void 0:S.add(n.value)),(S,O)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"cameraGroupRef",ref:_},null,512))}}),$l=u.defineComponent({name:"GlobalAudio",props:["src","loop","volume","playbackRate","playTrigger","stopTrigger"],async setup(o,{expose:e,emit:t}){var f;const{camera:n,renderer:r}=te.useTresContext(),s=new l.AudioListener;(f=n.value)==null||f.add(s);const i=new l.Audio(s),a=new l.AudioLoader;e({instance:i}),u.onUnmounted(()=>{i&&i.disconnect()}),u.watch(()=>[o.playbackRate],()=>i.setPlaybackRate(o.playbackRate??1),{immediate:!0}),u.watch(()=>[o.volume],()=>i.setVolume(o.volume??.5),{immediate:!0}),u.watch(()=>[o.loop],()=>i.setLoop(o.loop??!1),{immediate:!0}),u.watch(()=>[o.src],async()=>{const p=await a.loadAsync(o.src);i.setBuffer(p)},{immediate:!0});const h=document.getElementById(o.playTrigger??"")||r.value.domElement;Ce(h,"click",()=>{i.isPlaying?i.pause():i.play(),t("isPlaying",i.isPlaying)});const d=document.getElementById(o.stopTrigger??"");return d&&Ce(d,"click",()=>{i.stop(),t("isPlaying",i.isPlaying)}),null}});class nn extends l.Mesh{constructor(){super(nn.Geometry,new l.MeshBasicMaterial({opacity:0,transparent:!0})),this.isLensflare=!0,this.type="Lensflare",this.frustumCulled=!1,this.renderOrder=1/0;const e=new l.Vector3,t=new l.Vector3,n=new l.FramebufferTexture(16,16),r=new l.FramebufferTexture(16,16);let s=l.UnsignedByteType;const i=nn.Geometry,a=new l.RawShaderMaterial({uniforms:{scale:{value:null},screenPosition:{value:null}},vertexShader:`
|
|
143
396
|
|
|
144
397
|
precision highp float;
|
|
145
398
|
|
|
@@ -190,7 +443,7 @@
|
|
|
190
443
|
|
|
191
444
|
gl_FragColor = texture2D( map, vUV );
|
|
192
445
|
|
|
193
|
-
}`,depthTest:!1,depthWrite:!1,transparent:!1}),h=new l.Mesh(i,a),
|
|
446
|
+
}`,depthTest:!1,depthWrite:!1,transparent:!1}),h=new l.Mesh(i,a),d=[],f=Es.Shader,p=new l.RawShaderMaterial({name:f.name,uniforms:{map:{value:null},occlusionMap:{value:r},color:{value:new l.Color(16777215)},scale:{value:new l.Vector2},screenPosition:{value:new l.Vector3}},vertexShader:f.vertexShader,fragmentShader:f.fragmentShader,blending:l.AdditiveBlending,transparent:!0,depthWrite:!1}),m=new l.Mesh(i,p);this.addElement=function(M){d.push(M)};const _=new l.Vector2,v=new l.Vector2,y=new l.Box2,g=new l.Vector4;this.onBeforeRender=function(M,b,S){M.getCurrentViewport(g);const O=M.getRenderTarget(),T=O!==null?O.texture.type:l.UnsignedByteType;s!==T&&(n.dispose(),r.dispose(),n.type=r.type=T,s=T);const C=g.w/g.z,w=g.z/2,A=g.w/2;let x=16/g.w;if(_.set(x*C,x),y.min.set(g.x,g.y),y.max.set(g.x+(g.z-16),g.y+(g.w-16)),t.setFromMatrixPosition(this.matrixWorld),t.applyMatrix4(S.matrixWorldInverse),!(t.z>0)&&(e.copy(t).applyMatrix4(S.projectionMatrix),v.x=g.x+e.x*w+w-8,v.y=g.y+e.y*A+A-8,y.containsPoint(v))){M.copyFramebufferToTexture(n,v);let D=a.uniforms;D.scale.value=_,D.screenPosition.value=e,M.renderBufferDirect(S,null,i,a,h,null),M.copyFramebufferToTexture(r,v),D=c.uniforms,D.scale.value=_,D.screenPosition.value=e,M.renderBufferDirect(S,null,i,c,h,null);const L=-e.x*2,V=-e.y*2;for(let R=0,X=d.length;R<X;R++){const Y=d[R],J=p.uniforms;J.color.value.copy(Y.color),J.map.value=Y.texture,J.screenPosition.value.x=e.x+L*Y.distance,J.screenPosition.value.y=e.y+V*Y.distance,x=Y.size/g.w;const q=g.w/g.z;J.scale.value.set(x*q,x),p.uniformsNeedUpdate=!0,M.renderBufferDirect(S,null,i,p,m,null)}}},this.dispose=function(){a.dispose(),c.dispose(),p.dispose(),n.dispose(),r.dispose();for(let M=0,b=d.length;M<b;M++)d[M].texture.dispose()}}}class Es{constructor(e,t=1,n=0,r=new l.Color(16777215)){this.texture=e,this.size=t,this.distance=n,this.color=r}}Es.Shader={name:"LensflareElementShader",uniforms:{map:{value:null},occlusionMap:{value:null},color:{value:null},scale:{value:null},screenPosition:{value:null}},vertexShader:`
|
|
194
447
|
|
|
195
448
|
precision highp float;
|
|
196
449
|
|
|
@@ -244,12 +497,20 @@
|
|
|
244
497
|
gl_FragColor = texture;
|
|
245
498
|
gl_FragColor.rgb *= color;
|
|
246
499
|
|
|
247
|
-
}`},nn.Geometry=function(){const o=new l.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 l.InterleavedBuffer(e,5);return o.setIndex([0,1,2,0,2,3]),o.setAttribute("position",new l.InterleavedBufferAttribute(t,3,0,!1)),o.setAttribute("uv",new l.InterleavedBufferAttribute(t,2,3,!1)),o}();function Nl(o){return o}function Vl(o){return o*o*o}function zl(o){return o<.5?4*o*o*o:1-(-2*o+2)**3/2}function Gl(o){return o*o*o*o}function jl(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 zs=l.MathUtils.clamp;class Gs{constructor(e=0,t){ce(this,"_getNext");ce(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=zs(t,0,r-1),n=zs(n??r-1,0,r-1);const s=this.int(t,n),i=this.shuffle(e.map((c,h)=>h)),a=Math.min(e.length,s);return i.slice(0,a).sort().map(c=>e[c])}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 e>0&&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 ct="https://raw.githubusercontent.com/Tresjs/assets/93976c7d63ac83d4a254a41a10b2362bc17e90c9/textures/lensflare/",mr=`${ct}circle.png`,Sn=`${ct}circleBlur.png`,Rl=`${ct}circleRainbow.png`,Wl=`${ct}line.png`,js=`${ct}poly6.png`,Rs=`${ct}polyStroke6.png`,Yl=`${ct}rays.png`,An=`${ct}ring.png`,El=`${ct}starThin6.png`,Xl={texture:[Wl,An],color:["white"],distance:[0,0],size:[750,1024],length:[0,2]},Zl={texture:[Sn],color:["white"],distance:[0,0],size:[180,512],length:[1,1]},ql={texture:[Yl],color:["white"],distance:[0,0],size:[180,512],length:[1,1]},Kl={texture:[mr,Rl,An,El],color:["white"],distance:[0,0],size:[180,512],length:[2,3]},[Ws,Ys]=[3679071,132442],gr=[Xl,Zl,ql,Kl,{texture:[Sn,mr,An,js,Rs],color:["dimgray","gray","darkgray",Ws,Ys],distance:[.5,2.5],size:[20,180],length:[5,21]},{texture:[Sn,mr,An,js,Rs],color:["dimgray","gray","darkgray",Ws,Ys],distance:[-.6,-.1],size:[180,360],length:[0,5]}],Cn={color:"white",distance:0,size:512,texture:Sn},Ql=[Nl,Vl,zl,Gl,jl],Es=l.MathUtils.lerp,Xs=(o=0,e=gr)=>{const n=new Gs(o).choice(Ql);return e.map((r,s)=>{const i=new Gs(o*(s*7907+1)+(typeof r.seed=="number"?r.seed:0)),a=i.int(r.length[0],r.length[1]);return Array.from({length:a}).fill(0).map(()=>{const c=n(i.rand());return{texture:i.defaultChoice(r.texture,Cn.texture),size:Es(r.size[0],r.size[1],n(1-c)),distance:Es(r.distance[0],r.distance[1],c),color:i.defaultChoice(r.color,Cn.color)}})}).flat()},Zs=(o,e,t=void 0,n=void 0,r=Cn)=>{if(o!==void 0&&o.length>0&&(typeof t=="number"||typeof n<"u")){const a=Xs(t??0,n??gr),c=a.length,h=o.length;return c>=h?a.map((f,d)=>Object.assign(f,e,d<h?o[d]:{})):o.map((f,d)=>Object.assign({},r,d<c?a[d]:{},e,f))}if(o!==void 0&&o.length>0){const a=Object.assign({},r,e);return o.map(c=>Object.assign({},a,c))}const s=n===void 0||n.length===0?gr:n;return Xs(t??0,s).map(a=>Object.assign({},a,e))};function Jl(o){return Hl(o,(e,t)=>t in Cn&&e!==void 0)}function Hl(o,e){const t={};return Object.keys(o).forEach(n=>{e(o[n],n)&&(t[n]=o[n])}),t}const $l=u.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=u.shallowRef(),r=u.shallowRef([]),s=u.shallowRef(Jl(t));e({value:n});const i=new l.TextureLoader,a=new nn,c=[],h=()=>{var g,x,v;for(;c.length;)c.pop();(g=n.value)==null||g.children.forEach(_=>{"dispose"in _&&_.dispose()}),(x=n.value)==null||x.remove(...n.value.children),(v=n.value)==null||v.dispose()},f=g=>{if(typeof g.texture=="string"){const x=g.texture;g.texture=i.load(x),g.texture.name=x}return g.color=ie.normalizeColor(g.color),g},d=()=>{for(let g=r.value.length-1;g<c.length;g++)c[g].size=0;r.value.forEach((g,x)=>{c[x].size=g.size*t.scale})},p=()=>{for(;r.value.length>c.length;){const x={...f(r.value[c.length])};c.push(x),a.addElement(x)}r.value.forEach((g,x)=>{const v=c[x],{texture:_,size:m,distance:M,color:b}=g;if(typeof _=="string"){if(v.texture.name!==_){v.texture.dispose();const S=_;v.texture=i.load(S),v.texture.name=S}}else v.texture!==_&&(v.texture.dispose(),v.texture=_);v.size=m,v.distance=M,v.color=ie.normalizeColor(b)}),d()};return u.onUnmounted(()=>{h()}),u.onMounted(()=>{var g;(g=n.value)==null||g.add(a),r.value=Zs(t.elements,s.value,t.seed,t.seedProps)}),u.watch(()=>[t.color,t.distance,t.size,t.texture],()=>{s.value={color:t.color,distance:t.distance,size:t.size,texture:t.texture}}),u.watch(()=>[s.value,t.elements,t.seed,t.seedProps],()=>{r.value=Zs(t.elements,s.value,t.seed,t.seedProps)}),u.watch(()=>t.scale,()=>{d()}),u.watch(()=>r.value,()=>{p()}),(g,x)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"lensflareRef",ref:n},null,512))}});function qs(o){const e=u.ref(null),{height:t,width:n,settings:r,depth:s}=u.isReactive(o)?u.toRefs(o):u.toRefs(u.reactive(o)),{onLoop:i}=ie.useRenderLoop(),{camera:a,renderer:c,scene:h,sizes:f}=ie.useTresContext();return u.watchEffect(()=>{var d;(d=e.value)==null||d.dispose(),e.value=new l.WebGLRenderTarget((n==null?void 0:n.value)||f.width.value,(t==null?void 0:t.value)||f.height.value,{minFilter:l.LinearFilter,magFilter:l.LinearFilter,type:l.HalfFloatType,...r==null?void 0:r.value}),s!=null&&s.value&&(e.value.depthTexture=new l.DepthTexture((n==null?void 0:n.value)||f.width.value,(t==null?void 0:t.value)||f.height.value,l.FloatType))}),i(()=>{c.value.setRenderTarget(e.value),c.value.clear(),c.value.render(h.value,a.value),c.value.setRenderTarget(null)}),u.onBeforeUnmount(()=>{var d;(d=e.value)==null||d.dispose()}),e}const ec=u.defineComponent({__name:"component",props:{width:{},height:{},depth:{type:Boolean,default:!1},settings:{default:void 0}},setup(o,{expose:e}){const n=qs(o);return e({value:n}),()=>{}}}),Ks=(o,e=16,t,n,r)=>{const s=new Float32Array(e*16),i=u.ref(new l.InterleavedBuffer(s,16));return(()=>{if(!o)return;const c=new zo(o);n&&c.setWeightAttribute(n),c.build();const h=new l.Vector3,f=new l.Vector3,d=new l.Color,p=new l.Object3D;o.updateMatrixWorld(!0);for(let g=0;g<e;g++)c.sample(h,f,d),typeof r=="function"?r({dummy:p,sampledMesh:o,position:h,normal:f,color:d},g):p.position.copy(h),p.updateMatrix(),t&&t.setMatrixAt(g,p.matrix),p.matrix.toArray(i.value.array,g*16);t&&(t.instanceMatrix.needsUpdate=!0),i.value.needsUpdate=!0})(),{buffer:i}},tc=u.defineComponent({__name:"component",props:{transform:{type:Function},weight:{},count:{},mesh:{},instanceMesh:{}},setup(o,{expose:e}){const t=o,n=u.ref(),r=u.ref(),s=u.ref();return u.watchEffect(()=>{var i,a;r.value=t.instanceMesh??((i=n.value)==null?void 0:i.children.find(c=>Object.prototype.hasOwnProperty.call(c,"instanceMatrix"))),s.value=t.mesh??((a=n.value)==null?void 0:a.children.find(c=>c.type==="Mesh")),Ks(s.value,t.count,r.value,t.weight,t.transform)}),e({samplerRef:n}),(i,a)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"samplerRef",ref:n},[u.renderSlot(i.$slots,"default")],512))}});class nc extends l.Line{constructor(e,t=1,n=16,r=2){const s=new l.BufferGeometry,i=n+r*2,a=new Float32Array((i*3+3)*3);s.setAttribute("position",new l.BufferAttribute(a,3));const c=new l.LineBasicMaterial({color:65280}),h=new l.LineBasicMaterial({color:16776960});super(s,[h,c]),this.audio=e,this.range=t,this.divisionsInnerAngle=n,this.divisionsOuterAngle=r,this.type="PositionalAudioHelper",this.update()}update(){const e=this.audio,t=this.range,n=this.divisionsInnerAngle,r=this.divisionsOuterAngle,s=l.MathUtils.degToRad(e.panner.coneInnerAngle),i=l.MathUtils.degToRad(e.panner.coneOuterAngle),a=s/2,c=i/2;let h=0,f=0,d,p;const g=this.geometry,x=g.attributes.position;g.clearGroups();function v(_,m,M,b){const S=(m-_)/M;for(x.setXYZ(h,0,0,0),f++,d=_;d<m;d+=S)p=h+f,x.setXYZ(p,Math.sin(d)*t,0,Math.cos(d)*t),x.setXYZ(p+1,Math.sin(Math.min(d+S,m))*t,0,Math.cos(Math.min(d+S,m))*t),x.setXYZ(p+2,0,0,0),f+=3;g.addGroup(h,f,b),h+=f,f=0}v(-c,-a,r,0),v(-a,a,n,1),v(a,c,r,0),x.needsUpdate=!0,s===i&&(this.material[0].visible=!1)}dispose(){this.geometry.dispose(),this.material[0].dispose(),this.material[1].dispose()}}const rc=["args"],sc=u.defineComponent({__name:"PositionalAudio",props:{ready:{type:Boolean,default:!1},url:{},distance:{default:2},helper:{type:Boolean,default:!1},loop:{type:Boolean,default:!1},autoplay:{type:Boolean,default:!1},innerAngle:{default:360},outerAngle:{default:360},outerGain:{default:0}},emits:["isPlaying"],async setup(o,{expose:e,emit:t}){let n,r;const s=o,i=t,{ready:a,url:c,distance:h,helper:f,loop:d,autoplay:p,innerAngle:g,outerAngle:x,outerGain:v}=u.toRefs(s),{camera:_}=ie.useTresContext(),m=u.shallowRef(null),M=u.shallowRef(null),b=u.shallowRef(null),S=u.shallowReactive(new l.AudioListener),L=()=>{var R,V,Y;(R=m==null?void 0:m.value)!=null&&R.isPlaying||((V=m==null?void 0:m.value)==null||V.play(),i("isPlaying",(Y=m==null?void 0:m.value)==null?void 0:Y.isPlaying))},P=()=>{var R,V;(R=m==null?void 0:m.value)!=null&&R.isPlaying&&(m.value.pause(),i("isPlaying",(V=m==null?void 0:m.value)==null?void 0:V.isPlaying))},T=()=>{var R;m.value&&(m.value.stop(),i("isPlaying",(R=m==null?void 0:m.value)==null?void 0:R.isPlaying))},y=()=>{if(!(m!=null&&m.value))return;T();const R=m.value;R.source&&R.disconnect()},A=()=>{var R,V;!(m!=null&&m.value)||!(M!=null&&M.value)||((R=M==null?void 0:M.value)==null||R.dispose(),(V=m==null?void 0:m.value)==null||V.remove(M==null?void 0:M.value))},w=()=>{var R;if(m.value&&(m.value.setBuffer(b.value),m.value.setRefDistance(h.value),m.value.setLoop(d.value),m.value.setDirectionalCone(g.value,x.value,v.value),(R=M==null?void 0:M.value)==null||R.update(),M!=null&&M.value)){const V=M.value.material[0];!V.visible&&x.value!==g.value&&(V.visible=!0)}},D=()=>{var G,Q;w();const R=(G=m.value)==null?void 0:G.parent,V=new l.Box3().setFromObject(R),Y=(V.max.z-V.min.z)*2;M.value=new nc(m.value,Y,32,16),(Q=m==null?void 0:m.value)==null||Q.add(M.value),M.value.update()},k=()=>{var R;(R=_==null?void 0:_.value)==null||R.remove(S),y(),A()};return e({root:m,play:L,stop:T,pause:P,dispose:k}),b.value=([n,r]=u.withAsyncContext(()=>ie.useLoader(l.AudioLoader,c.value)),n=await n,r(),n),u.watch(m,()=>{m!=null&&m.value&&(f.value&&D(),a.value&&p&&L())}),u.watch(f,()=>{f.value?D():A()}),u.watch(a,()=>{a.value&&w(),p.value&&a.value&&L(),!p.value&&a.value&&T()}),u.watch([h,d,b,g,x,v,p],()=>{w()}),u.onMounted(()=>{var R;(R=_==null?void 0:_.value)==null||R.add(S)}),u.onBeforeUnmount(()=>{k()}),(R,V)=>(u.openBlock(),u.createElementBlock("TresPositionalAudio",u.mergeProps({ref_key:"positionalAudioRef",ref:m,args:[u.unref(S)]},R.$attrs),null,16,rc))}}),Pn={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"},ic="https://raw.githubusercontent.com/Tresjs/assets/main/textures/hdr/";async function Qs(o,e){const{scene:t}=ie.useTresContext(),{preset:n,blur:r,files:s=[],path:i="",background:a}=u.toRefs(o),c=u.ref(),h=u.computed(()=>Array.isArray(s.value)),f=u.computed(()=>h.value?l.CubeTextureLoader:Ds),d=u.ref(null);return u.watch(()=>[s,i],async([p,g])=>{if(p.value.length>0&&!n.value){try{d.value=await ie.useLoader(u.unref(f),h.value?[u.unref(p)]:u.unref(p),x=>{g.value&&x.setPath(u.unref(g))})}catch(x){throw new Error(`Failed to load environment map: ${x}`)}d.value&&(c.value=h.value?d.value[0]:d.value,c.value.mapping=h.value?l.CubeReflectionMapping:l.EquirectangularReflectionMapping)}},{immediate:!0}),u.watch(()=>c.value,p=>{t.value&&(t.value.environment=p)},{immediate:!0}),u.watch(()=>[a.value,c.value],([p,g])=>{if(t.value){const x=e!=null&&e.value?e.value.texture:g;t.value.background=p?x:void 0}},{immediate:!0}),u.watch(()=>r==null?void 0:r.value,p=>{t.value&&(t.value.backgroundBlurriness=p)},{immediate:!0}),u.watch(n,async p=>{if(p&&p in Pn){const g=ic,x=Pn[p];try{d.value=await ie.useLoader(Ds,x,v=>{g&&v.setPath(g)})}catch(v){throw new Error(`Failed to load environment map: ${v}`)}d.value&&(c.value=d.value,c.value.mapping=l.EquirectangularReflectionMapping)}else if(p&&!(p in Pn))throw new Error(`Preset must be one of: ${Object.keys(Pn).join(", ")}`)},{immediate:!0}),{texture:c}}let xt=null;function oc(o,e){return t=>{e&&e(t),o.draco&&(xt||(xt=new al),xt.setDecoderPath(o.decoderPath||"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),t.setDRACOLoader(xt))}}async function Js(o,e={draco:!1},t){const n=await ie.useLoader(ea,o,oc(e,t));return xt==null||xt.dispose(),xt=null,n}const ac=["object"],lc=u.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=u.ref();e({value:s});const{scene:i}=([t,n]=u.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,c)=>(u.openBlock(),u.createElementBlock("primitive",u.mergeProps({ref_key:"modelRef",ref:s,object:u.unref(i)},a.$attrs),null,16,ac))}});async function Hs(o){return await ie.useLoader(Wa,o)}const cc=["object"],uc=u.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=u.ref();e({value:s});const i=([t,n]=u.withAsyncContext(()=>Hs(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,c)=>(u.openBlock(),u.createElementBlock("primitive",u.mergeProps({ref_key:"modelRef",ref:s,object:u.unref(i)},a.$attrs),null,16,cc))}}),hc=["geometry","render-order"],fc=u.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:c,strokeMeshProps:h,depth:f}=u.toRefs(t),d=u.shallowRef(),p=u.shallowRef([]),g=u.shallowRef([]);e({value:d}),u.watchEffect(async()=>x(n.value).then(m=>g.value=m.paths)),u.watch([s,r,i,a,g],_);async function x(m){const M=m.startsWith("<svg")?encodeURI(`data:image/svg+xml;utf8,${m}`):m;return ie.useLoader(en,M)}u.onUnmounted(v);function v(){p.value.forEach(m=>m.geometry.dispose())}function _(){var L,P,T;v();const m=[],[M,b]=(()=>{const y={flat:!1,renderOrder:!1,offsetZ:!0},A={flat:0,renderOrder:0,offsetZ:.025},w=f.value;return typeof w=="number"?[!0,w]:[y[w],A[w]]})();let S=0;for(const y of g.value){const A=((L=y.userData)==null?void 0:L.style)??{},w=Object.assign({color:A.fill,opacity:A.fillOpacity,transparent:!0,side:l.DoubleSide,depthWrite:M},t.fillMaterial);if(!s.value&&A.fill!==void 0&&A.fill!=="none")for(const D of en.createShapes(y)){const k=new l.ShapeGeometry(D);k.scale(1,-1,1),b&&k.translate(0,0,S++*b),m.push({geometry:k,material:w,isStroke:!1})}if(!r.value&&A.stroke!==void 0&&A.stroke!=="none"){const D=Object.assign({color:(P=y.userData)==null?void 0:P.style.stroke,opacity:(T=y.userData)==null?void 0:T.style.strokeOpacity,transparent:!0,side:l.DoubleSide,depthWrite:M},t.strokeMaterial);for(const k of y.subPaths){const R=k.getPoints().map(Y=>new l.Vector2(Y.x,-Y.y)),V=en.pointsToStroke(R,A||"none");b&&V.translate(0,0,S++*b),m.push({geometry:V,material:D,isStroke:!0})}}}p.value=m}return(m,M)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"svgRef",ref:d},[(u.openBlock(!0),u.createElementBlock(u.Fragment,null,u.renderList(p.value,({geometry:b,material:S,isStroke:L},P)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({key:`${P}`,ref_for:!0},L?u.unref(h):u.unref(c),{geometry:b,"render-order":u.unref(f)==="renderOrder"?P:0}),[u.createElementVNode("TresMeshBasicMaterial",u.mergeProps({ref_for:!0},S),null,16)],16,hc))),128))],512))}}),$s="[TresJS - Cientos ▲ ■ ♥] ";function yr(){function o(n,r){console.error(`${$s} ${n}`,r||"")}function e(n){console.warn(`${$s} ${n}`)}function t(n,r){}return{logError:o,logWarning:e,logMessage:t}}let vr=0;function dc(){const o=u.ref(!1),e=u.ref(0),t=u.ref([]),{logError:n}=yr();return new Promise(r=>{l.DefaultLoadingManager.onStart=()=>{o.value=!1},l.DefaultLoadingManager.onLoad=()=>{o.value=!0},l.DefaultLoadingManager.onProgress=(s,i,a)=>{i===a&&(vr=a,o.value=!0,t.value.push(s)),e.value=Math.round((i-vr)/(a-vr)*100||100,2)},l.DefaultLoadingManager.onError=s=>{n("Error loading assets",new Error(s)),o.value=!0},r({items:t,hasFinishLoading:o,progress:e})})}async function pc(o,e){const{logError:t}=yr();if(!o)return t("Error no path provided");const{unsuspend:n,start:r,crossOrigin:s,muted:i,loop:a,...c}={unsuspend:"loadedmetadata",crossOrigin:"Anonymous",muted:!0,loop:!0,start:!0,playsInline:!0,...e};function h(){return new Promise((f,d)=>{const p=Object.assign(document.createElement("video"),{src:typeof o=="string"&&o||void 0,crossOrigin:s,loop:a,muted:i,autoplay:!0,...c}),g=new l.VideoTexture(p);return p.addEventListener(n,()=>f(g)),p.addEventListener("error",()=>d(new Error("Error loading video"))),g})}try{const f=await h();return r&&f.image&&f.image.play(),f}catch{t("Error loading resource")}}const mc=["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"],gc=u.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:Number.POSITIVE_INFINITY},minAzimuthAngle:{default:Number.NEGATIVE_INFINITY},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:Number.POSITIVE_INFINITY},minZoom:{default:0},maxZoom:{default:Number.POSITIVE_INFINITY},touches:{default:()=>({ONE:l.TOUCH.ROTATE,TWO:l.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:c,dampingFactor:h,enablePan:f,keyPanSpeed:d,maxAzimuthAngle:p,minAzimuthAngle:g,maxPolarAngle:x,minPolarAngle:v,minDistance:_,maxDistance:m,minZoom:M,maxZoom:b,enableZoom:S,zoomSpeed:L,enableRotate:P,touches:T,rotateSpeed:y,target:A}=u.toRefs(n),{camera:w,renderer:D,extend:k,controls:R}=ie.useTresContext(),V=u.ref(null);k({OrbitControls:ms}),u.watch(V,Q=>{Y(),Q&&s.value?R.value=Q:R.value=null});function Y(){Ie(V.value,"change",()=>r("change",V.value)),Ie(V.value,"start",()=>r("start",V.value)),Ie(V.value,"end",()=>r("end",V.value))}const{onLoop:G}=ie.useRenderLoop();return G(()=>{V.value&&(c.value||i.value)&&V.value.update()}),u.onUnmounted(()=>{V.value&&V.value.dispose()}),e({value:V}),(Q,K)=>(Q.camera||u.unref(w))&&(Q.domElement||u.unref(D))?(u.openBlock(),u.createElementBlock("TresOrbitControls",{key:0,ref_key:"controlsRef",ref:V,target:u.unref(A),"auto-rotate":u.unref(i),"auto-rotate-speed":u.unref(a),"enable-damping":u.unref(c),"damping-factor":u.unref(h),"enable-pan":u.unref(f),"key-pan-speed":u.unref(d),keys:Q.keys,"max-azimuth-angle":u.unref(p),"min-azimuth-angle":u.unref(g),"max-polar-angle":u.unref(x),"min-polar-angle":u.unref(v),"min-distance":u.unref(_),"max-distance":u.unref(m),"min-zoom":u.unref(M),"max-zoom":u.unref(b),touches:u.unref(T),"enable-zoom":u.unref(S),"zoom-speed":u.unref(L),"enable-rotate":u.unref(P),"rotate-speed":u.unref(y),args:[Q.camera||u.unref(w),Q.domElement||u.unref(D).domElement]},null,8,mc)):u.createCommentVNode("",!0)}}),yc=5,vc=6,_c=.3,xc=u.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 w;const e=o,{forward:t,back:n,left:r,right:s,jump:i,gravity:a,moveSpeed:c,headBobbing:h,is2D:f}=u.toRefs(e),{camera:d,controls:p}=ie.useTresContext(),g=u.ref(0),x=u.ref(0),v=u.ref(!1),_=u.ref(!1),m=u.ref(0),M=u.shallowRef(),b=f.value?"y":"z",S=((w=d.value.position)==null?void 0:w.y)||0;Ot(t.value,()=>{v.value=!0,x.value=c.value},{eventName:"keydown"}),Ot(n.value,()=>{v.value=!0,x.value=-c.value},{eventName:"keydown"}),Ot([...t.value,...n.value],()=>{v.value=!1,x.value=0},{eventName:"keyup"}),Ot(r.value,()=>{v.value=!0,g.value=-c.value},{eventName:"keydown"}),Ot(s.value,()=>{v.value=!0,g.value=c.value},{eventName:"keydown"}),Ot([...r.value,...s.value],()=>{v.value=!1,g.value=0},{eventName:"keyup"}),Ot(i.value,()=>{_.value||(m.value=Date.now()),_.value=!0});const L=D=>v.value?Math.sin(D*yc)*_c+S:S,P=()=>(Date.now()-m.value)/1e3*3,T=D=>S+vc*D-.5*a.value*D**2,y=()=>{if(_.value){const D=T(P());return D<=S&&(_.value=!1),D}return 0},{onLoop:A}=ie.useRenderLoop();return A(({elapsed:D})=>{var k;p.value instanceof tr&&((k=p.value)!=null&&k.isLocked)?(p.value.moveForward(x.value),p.value.moveRight(g.value),d.value.position&&(d.value.position.y=h.value?L(D):S,d.value.position.y+=y())):M.value.children.length>0&&!(p.value instanceof tr)&&(M.value.position.x+=g.value,M.value.position[b]+=f.value?x.value:-x.value)}),(D,k)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:M},[u.renderSlot(D.$slots,"default")],512))}}),wc=["object","args","mode","enabled","axis","translation-snap","rotation-snap","scale-snap","space","size","show-x","show-y","show-z"],bc=u.defineComponent({__name:"TransformControls",props:{object:{},camera:{},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:c,rotationSnap:h,scaleSnap:f,space:d,size:p,showX:g,showY:x,showZ:v}=u.toRefs(t),_=u.shallowRef(),{controls:m,camera:M,renderer:b,extend:S}=ie.useTresContext();S({TransformControls:Ro});const L=T=>{m.value&&(m.value.enabled=!T.value),n("dragging",T.value)};function P(){Ie(_.value,"change",()=>n("change")),Ie(_.value,"dragging-changed",L),Ie(_.value,"mouseDown",()=>n("mouseDown")),Ie(_.value,"mouseUp",()=>n("mouseUp")),Ie(_.value,"objectChange",()=>n("objectChange"))}return u.watchEffect(()=>{_.value&&P()}),u.onUnmounted(()=>{_.value&&_.value.dispose()}),(T,y)=>{var A;return(T.camera||u.unref(M))&&u.unref(b)?(u.openBlock(),u.createElementBlock("TresTransformControls",{ref_key:"controlsRef",ref:_,key:(A=T.camera||u.unref(M))==null?void 0:A.uuid,object:u.unref(r),args:[T.camera||u.unref(M),u.unref(b).domElement],mode:u.unref(s),enabled:u.unref(i),axis:u.unref(a),"translation-snap":u.unref(c),"rotation-snap":u.unref(h),"scale-snap":u.unref(f),space:u.unref(d),size:u.unref(p),"show-x":u.unref(g),"show-y":u.unref(x),"show-z":u.unref(v),visible:!0},null,8,wc)):u.createCommentVNode("",!0)}}}),Mc=["args"],Sc=u.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:c}=ie.useTresContext(),h=u.ref(null);let f;a({PointerLockControls:tr});const d=p=>{r("isLock",p)};return u.watch(h,p=>{p&&n.makeDefault?c.value=p:c.value=null,f=document.getElementById(n.selector||"")||i.value.domElement,Ie(c.value,"change",()=>r("change",c.value)),Ie(f,"click",()=>{var x,v,_;(x=c.value)==null||x.lock(),(v=c.value)==null||v.addEventListener("lock",()=>d(!0)),(_=c.value)==null||_.addEventListener("unlock",()=>d(!1))})}),u.onUnmounted(()=>{var p,g;(p=c.value)==null||p.removeEventListener("lock",()=>d(!0)),(g=c.value)==null||g.removeEventListener("unlock",()=>d(!1)),h.value&&h.value.dispose()}),e({value:c}),(p,g)=>(p.camera||u.unref(s))&&(p.domElement||u.unref(i))?(u.openBlock(),u.createElementBlock("TresPointerLockControls",{key:0,ref_key:"controlsRef",ref:h,args:[p.camera||u.unref(s),p.domElement||u.unref(i).domElement]},null,8,Mc)):u.createCommentVNode("",!0)}}),Ac=["args"],Cc=u.defineComponent({__name:"MapControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{}},setup(o){const e=o,{camera:t,renderer:n,extend:r,controls:s}=ie.useTresContext(),i=u.ref(null);return r({MapControls:$o}),u.watch(s,a=>{a&&e.makeDefault?s.value=a:s.value=null}),u.onUnmounted(()=>{i.value&&i.value.dispose()}),(a,c)=>(a.camera||u.unref(t))&&(a.domElement||u.unref(n))?(u.openBlock(),u.createElementBlock("TresMapControls",{key:0,ref_key:"controlsRef",ref:i,args:[a.camera||u.unref(t),a.domElement||u.unref(n).domElement]},null,8,Ac)):u.createCommentVNode("",!0)}}),Pc=u.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}=ie.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}=ie.useTresContext(),c=u.shallowRef(),h=document.createElement("div"),{y:f}=Bl(),{x:d,y:p,isScrolling:g}=Ol(h),{height:x,width:v}=Ns();let _=0;const m=u.ref(!1),M=u.ref(0),b=u.ref(0),S=u.ref(0),L=t.horizontal?"x":"y",P=u.watch(s,y=>{if(m.value){P();return}_=t.horizontal?(y==null?void 0:y.position.x)||0:(y==null?void 0:y.position.y)||0,m.value=!0},{immediate:!0});u.watch(g,y=>{i.value&&(i.value.enabled=!y)},{immediate:!0}),u.watch(f,y=>{!g.value&&!t.htmlScroll||(b.value=y/x.value/(S.value/x.value-1),M.value=-1*b.value,n("update:modelValue",b.value))}),u.watch(p,y=>{b.value=y/x.value/(S.value/x.value),M.value=-1*b.value,n("update:modelValue",b.value)}),u.watch(d,y=>{b.value=y/v.value/(S.value/v.value-1),M.value=+b.value,n("update:modelValue",b.value)}),u.watch(a,y=>{var w,D;const A=y==null?void 0:y.domElement;if(t.htmlScroll&&(y!=null&&y.domElement))A!=null&&A.style.width&&(A!=null&&A.style.position)&&(A!=null&&A.style.top)&&(A!=null&&A.style.left)&&(A.style.width="100%",A.style.position="fixed",A.style.zIndex=" -99999",A.style.top="0",A.style.left="0"),S.value=document.body.scrollHeight;else{const k=document.createElement("div"),R=document.createElement("div");h.style[t.horizontal?"overflowX":"overflowY"]="auto",h.style[t.horizontal?"overflowY":"overflowX"]="hidden",h.style.position="absolute",h.style.width="100%",h.style.height=" 100%",h.style.top="0",h.style.left="0",h.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",h.appendChild(k),R.style.height=t.horizontal?"100%":`${x.value*t.pages}px`,R.style.width=t.horizontal?`${v.value*t.pages}px`:"100vw",R.style.pointerEvents="none",A.style.position="fixed",A.style.zIndex="0",A!=null&&A.style.width&&(A.style.width="100%"),h.appendChild(R),y.domElement.parentNode.style.position="relative",(D=(w=y==null?void 0:y.domElement)==null?void 0:w.parentNode)==null||D.appendChild(h),S.value=t.horizontal?v.value*t.pages:x.value*t.pages}},{immediate:!0});const{onLoop:T}=ie.useRenderLoop();return T(()=>{var y;if((y=s.value)!=null&&y.position){const A=(M.value*t.distance-s.value.position[L]+_)*t.smoothScroll;s.value.position[L]+=A,c.value.children.length>0&&(c.value.position[L]+=A)}}),(y,A)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:c},[u.renderSlot(y.$slots,"default")],512))}});/*!
|
|
500
|
+
}`},nn.Geometry=function(){const o=new l.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 l.InterleavedBuffer(e,5);return o.setIndex([0,1,2,0,2,3]),o.setAttribute("position",new l.InterleavedBufferAttribute(t,3,0,!1)),o.setAttribute("uv",new l.InterleavedBufferAttribute(t,2,3,!1)),o}();function ec(o){return o}function tc(o){return o*o*o}function nc(o){return o<.5?4*o*o*o:1-(-2*o+2)**3/2}function rc(o){return o*o*o*o}function sc(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 Ys=l.MathUtils.clamp;class Ws{constructor(e=0,t){ue(this,"_getNext");ue(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=Ys(t,0,r-1),n=Ys(n??r-1,0,r-1);const s=this.int(t,n),i=this.shuffle(e.map((c,h)=>h)),a=Math.min(e.length,s);return i.slice(0,a).sort().map(c=>e[c])}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 e>0&&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 ft="https://raw.githubusercontent.com/Tresjs/assets/93976c7d63ac83d4a254a41a10b2362bc17e90c9/textures/lensflare/",_r=`${ft}circle.png`,Pn=`${ft}circleBlur.png`,ic=`${ft}circleRainbow.png`,oc=`${ft}line.png`,Xs=`${ft}poly6.png`,Zs=`${ft}polyStroke6.png`,ac=`${ft}rays.png`,Tn=`${ft}ring.png`,lc=`${ft}starThin6.png`,cc={texture:[oc,Tn],color:["white"],distance:[0,0],size:[750,1024],length:[0,2]},uc={texture:[Pn],color:["white"],distance:[0,0],size:[180,512],length:[1,1]},hc={texture:[ac],color:["white"],distance:[0,0],size:[180,512],length:[1,1]},fc={texture:[_r,ic,Tn,lc],color:["white"],distance:[0,0],size:[180,512],length:[2,3]},[Ks,qs]=[3679071,132442],vr=[cc,uc,hc,fc,{texture:[Pn,_r,Tn,Xs,Zs],color:["dimgray","gray","darkgray",Ks,qs],distance:[.5,2.5],size:[20,180],length:[5,21]},{texture:[Pn,_r,Tn,Xs,Zs],color:["dimgray","gray","darkgray",Ks,qs],distance:[-.6,-.1],size:[180,360],length:[0,5]}],In={color:"white",distance:0,size:512,texture:Pn},dc=[ec,tc,nc,rc,sc],Qs=l.MathUtils.lerp,Js=(o=0,e=vr)=>{const n=new Ws(o).choice(dc);return e.map((r,s)=>{const i=new Ws(o*(s*7907+1)+(typeof r.seed=="number"?r.seed:0)),a=i.int(r.length[0],r.length[1]);return Array.from({length:a}).fill(0).map(()=>{const c=n(i.rand());return{texture:i.defaultChoice(r.texture,In.texture),size:Qs(r.size[0],r.size[1],n(1-c)),distance:Qs(r.distance[0],r.distance[1],c),color:i.defaultChoice(r.color,In.color)}})}).flat()},Hs=(o,e,t=void 0,n=void 0,r=In)=>{if(o!==void 0&&o.length>0&&(typeof t=="number"||typeof n<"u")){const a=Js(t??0,n??vr),c=a.length,h=o.length;return c>=h?a.map((d,f)=>Object.assign(d,e,f<h?o[f]:{})):o.map((d,f)=>Object.assign({},r,f<c?a[f]:{},e,d))}if(o!==void 0&&o.length>0){const a=Object.assign({},r,e);return o.map(c=>Object.assign({},a,c))}const s=n===void 0||n.length===0?vr:n;return Js(t??0,s).map(a=>Object.assign({},a,e))};function pc(o){return mc(o,(e,t)=>t in In&&e!==void 0)}function mc(o,e){const t={};return Object.keys(o).forEach(n=>{e(o[n],n)&&(t[n]=o[n])}),t}const gc=u.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=u.shallowRef(),r=u.shallowRef([]),s=u.shallowRef(pc(t));e({instance:n});const i=new l.TextureLoader,a=new nn,c=[],h=()=>{var m,_,v;for(;c.length;)c.pop();(m=n.value)==null||m.children.forEach(y=>{"dispose"in y&&y.dispose()}),(_=n.value)==null||_.remove(...n.value.children),(v=n.value)==null||v.dispose()},d=m=>{if(typeof m.texture=="string"){const _=m.texture;m.texture=i.load(_),m.texture.name=_}return m.color=te.normalizeColor(m.color),m},f=()=>{for(let m=r.value.length-1;m<c.length;m++)c[m].size=0;r.value.forEach((m,_)=>{c[_].size=m.size*t.scale})},p=()=>{for(;r.value.length>c.length;){const _={...d(r.value[c.length])};c.push(_),a.addElement(_)}r.value.forEach((m,_)=>{const v=c[_],{texture:y,size:g,distance:M,color:b}=m;if(typeof y=="string"){if(v.texture.name!==y){v.texture.dispose();const S=y;v.texture=i.load(S),v.texture.name=S}}else v.texture!==y&&(v.texture.dispose(),v.texture=y);v.size=g,v.distance=M,v.color=te.normalizeColor(b)}),f()};return u.onUnmounted(()=>{h()}),u.onMounted(()=>{var m;(m=n.value)==null||m.add(a),r.value=Hs(t.elements,s.value,t.seed,t.seedProps)}),u.watch(()=>[t.color,t.distance,t.size,t.texture],()=>{s.value={color:t.color,distance:t.distance,size:t.size,texture:t.texture}}),u.watch(()=>[s.value,t.elements,t.seed,t.seedProps],()=>{r.value=Hs(t.elements,s.value,t.seed,t.seedProps)}),u.watch(()=>t.scale,()=>{f()}),u.watch(()=>r.value,()=>{p()}),(m,_)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"lensflareRef",ref:n},null,512))}});function $s(o){const e=u.ref(null),{height:t,width:n,settings:r,depth:s}=u.isReactive(o)?u.toRefs(o):u.toRefs(u.reactive(o)),{invalidateOnDemand:i}=Ie(o),{onBeforeRender:a}=te.useLoop(),{camera:c,renderer:h,scene:d,sizes:f}=te.useTresContext();return u.watch(()=>[n==null?void 0:n.value,f.width.value,t==null?void 0:t.value,f.height.value],()=>{var p;(p=e.value)==null||p.dispose(),e.value=new l.WebGLRenderTarget((n==null?void 0:n.value)||f.width.value,(t==null?void 0:t.value)||f.height.value,{minFilter:l.LinearFilter,magFilter:l.LinearFilter,type:l.HalfFloatType,...r==null?void 0:r.value}),s!=null&&s.value&&(e.value.depthTexture=new l.DepthTexture((n==null?void 0:n.value)||f.width.value,(t==null?void 0:t.value)||f.height.value,l.FloatType)),i()},{immediate:!0}),a(()=>{h.value.setRenderTarget(e.value),h.value.clear(),h.value.render(d.value,c.value),h.value.setRenderTarget(null)},Number.POSITIVE_INFINITY),u.onBeforeUnmount(()=>{var p;(p=e.value)==null||p.dispose()}),e}const yc=u.defineComponent({__name:"component",props:{width:{},height:{},depth:{type:Boolean,default:!1},settings:{default:void 0}},setup(o,{expose:e}){const n=$s(o);return e({instance:n}),()=>{}}}),ei=(o,e=16,t,n,r)=>{const s=new Float32Array(e*16),i=u.ref(new l.InterleavedBuffer(s,16));return(()=>{if(!o)return;const c=new Ho(o);n&&c.setWeightAttribute(n),c.build();const h=new l.Vector3,d=new l.Vector3,f=new l.Color,p=new l.Object3D;o.updateMatrixWorld(!0);for(let m=0;m<e;m++)c.sample(h,d,f),typeof r=="function"?r({dummy:p,sampledMesh:o,position:h,normal:d,color:f},m):p.position.copy(h),p.updateMatrix(),t&&t.setMatrixAt(m,p.matrix),p.matrix.toArray(i.value.array,m*16);t&&(t.instanceMatrix.needsUpdate=!0),i.value.needsUpdate=!0})(),{buffer:i}},_c=u.defineComponent({__name:"component",props:{transform:{type:Function},weight:{},count:{},mesh:{},instanceMesh:{}},setup(o,{expose:e}){const t=o,n=u.ref(),r=u.ref(),s=u.ref();return Ie(t),u.watchEffect(()=>{var i,a;r.value=t.instanceMesh??((i=n.value)==null?void 0:i.children.find(c=>Object.prototype.hasOwnProperty.call(c,"instanceMatrix"))),s.value=t.mesh??((a=n.value)==null?void 0:a.children.find(c=>c.type==="Mesh")),ei(s.value,t.count,r.value,t.weight,t.transform)}),e({samplerRef:n}),(i,a)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"samplerRef",ref:n},[u.renderSlot(i.$slots,"default")],512))}}),vc=/\d*$/,xc=/_*\d*$/;function wc(o){return o.replace(xc,"")}function bc(o){const e=o.match(vc);return e?Number.parseInt(e[e.length-1]):null}function Mc(o){const e=Sc(o),t=[];for(const{startFrame:n,endFrame:r,duration:s}of e)if(!(s<=0))if(r<0||n===r){for(let i=0;i<s;i++)t.push(n);continue}else{const i=Math.sign(r-n);for(let a=n;a!==r+i;a+=i)for(let c=0;c<s;c++)t.push(a)}return t}function Sc(o){let e="START_FRAME_IN";const t=[];for(const{name:n,value:r,startI:s}of Ac(o))e==="START_FRAME_IN"?n==="NUMBER"?(t.push({startFrame:r,endFrame:r,duration:1}),e="START_FRAME_OUT"):Lt("number",n,o,s):e==="START_FRAME_OUT"?n==="COMMA"?e="START_FRAME_IN":n==="HYPHEN"?e="END_FRAME_IN":n==="OPEN_PAREN"?e="DURATION_IN":Lt('",", "-", "("',n,o,s):e==="END_FRAME_IN"?n==="NUMBER"?(t[t.length-1].endFrame=r,e="END_FRAME_OUT"):Lt("number",n,o,s):e==="END_FRAME_OUT"?n==="COMMA"?e="START_FRAME_IN":n==="OPEN_PAREN"?e="DURATION_IN":Lt("',' or '('",n,o,s):e==="DURATION_IN"?n==="NUMBER"?(t[t.length-1].duration=r,e="DURATION_OUT"):Lt("number",n,o,s):e==="DURATION_OUT"?n==="CLOSE_PAREN"?e="NEXT_OR_DONE":Lt('"("',n,o,s):e==="NEXT_OR_DONE"&&(n==="COMMA"?e="START_FRAME_IN":Lt('","',n,o,s));return t}function Ac(o){const e=[];let t=0;for(;t<o.length;){const n=o[t];if("0123456789".includes(n))e.length&&e[e.length-1].name==="NUMBER"?(e[e.length-1].value*=10,e[e.length-1].value+=Number.parseInt(n)):e.push({name:"NUMBER",value:Number.parseInt(n),startI:t});else{if(n===" ")continue;n===","?e.push({name:"COMMA",value:-1,startI:t}):n==="("?e.push({name:"OPEN_PAREN",value:-1,startI:t}):n===")"?e.push({name:"CLOSE_PAREN",value:-1,startI:t}):n==="-"?e.push({name:"HYPHEN",value:-1,startI:t}):Cc("0123456789,-()",n,o,t)}t++}return e}function Cc(o,e,t,n){te.useLogger().logError(`Cientos AnimationDefinitionParser: Unexpected character while processing animation definition: expected ${o}, got ${e}.
|
|
501
|
+
${t}
|
|
502
|
+
${Array(n+1).join(" ")}^`)}function Lt(o,e,t,n){te.useLogger().logError(`Cientos AnimationDefinitionParser: Syntax error while processing animation definition: expected ${o}, got ${e}.
|
|
503
|
+
${t}
|
|
504
|
+
${Array(n+1).join(" ")}^`)}async function Pc(o,e){const t=te.useLoader(l.TextureLoader,o),n=typeof e!="string"?new Promise(r=>r(e)):fetch(e).then(r=>r.json()).catch(r=>te.useLogger().logError(`Cientos Atlas - ${r}`));return Promise.all([t,n]).then(([r,s])=>{const i=Tc(s,r.image.width,r.image.height);return[r,i]})}function Tc(o,e,t){const n=typeof o=="number"||Array.isArray(o)?Lc(o,e,t):Ic(o,e,t);return{frames:n,animations:ni(n)}}function rn(o,e,t){let n;return typeof e=="string"?n=Bc(o,e):typeof e=="number"?n=ti(o,e,e):n=ti(o,e[0],e[1]),t?n.toReversed():n}function xr(){return{name:"null",width:0,height:0,offsetX:0,offsetY:0,repeatX:0,repeatY:0}}function Ic(o,e,t){return Array.isArray(o.frames)?Oc(o,e,t):Dc(o,e,t)}function Oc(o,e,t){const n=1/e,r=1/t;return o.frames.map(s=>({name:s.filename,offsetX:s.frame.x*n,offsetY:1-(s.frame.y+s.frame.h)*r,repeatX:s.frame.w*n,repeatY:s.frame.h*r,width:s.frame.w,height:s.frame.h}))}function Dc(o,e,t){const n=1/e,r=1/t;return Object.entries(o.frames).map(([s,i])=>({name:s,offsetX:i.frame.x*n,offsetY:1-(i.frame.y+i.frame.h)*r,repeatX:i.frame.w*n,repeatY:i.frame.h*r,width:i.frame.w,height:i.frame.h}))}function Lc(o,e,t,n="default"){const[r,s]=Array.isArray(o)?o:[o,1],i=e/r,a=t/s,c=(r*s).toString().length,h=1/r,d=1/s,f=[];let p=0;for(let m=s-1;m>=0;m--)for(let _=0;_<r;_++)p++,f.push({name:n+String(p).padStart(c,"0"),offsetX:_*h,offsetY:m*d,repeatX:h,repeatY:d,width:i,height:a});return f}function kc(o,e={}){const t=ni(o.frames);for(const[n,r]of Object.entries(e)){const s=rn(o,n,!1),i=Mc(r);for(const a of i)(a<0||s.length<=a)&&te.useLogger().logError(`Cientos Atlas: Attempting to access frame index ${a} in animation ${n}, but it does not exist.`);t[n]=i.map(a=>s[a])}o.animations=t}function Bc(o,e){return e in o.animations?o.animations[e]:(te.useLogger().logError(`Cientos Atlas: getAtlasFramesByAnimationName
|
|
505
|
+
The animation name "${e}" does not exist in this atlas.
|
|
506
|
+
Available names:
|
|
507
|
+
${Object.keys(o.animations).map(t=>`* ${t}
|
|
508
|
+
`).join("")}`),[xr()])}function ti(o,e,t){if(e<0||o.frames.length<=e||t<0||o.frames.length<=t)return te.useLogger().logError(`Cientos Atlas: getFramesByIndex – [${e}, ${t}] is out of bounds.`),[xr()];const n=[],r=Math.sign(t-e);if(r===0)return[o.frames[e]];for(let s=e;s!==t+r;s+=r)n.push(o.frames[s]);return n}function ni(o){const e={};for(const t of o)if(bc(t.name)!==null){const n=wc(t.name);Object.prototype.hasOwnProperty.call(e,n)?e[n].push(t):e[n]=[t]}for(const t of Object.values(e))t.sort((n,r)=>n.name.localeCompare(r.name));return e}const Fc=["scale","position"],Uc=["map","alphaTest"],Nc=["scale","position"],zc=u.createElementVNode("TresPlaneGeometry",{args:[1,1]},null,-1),Vc=["side","map","alphaTest","depthWrite","depthTest"],On=.01,Rc=u.defineComponent({__name:"component",props:{image:{},atlas:{},definitions:{},fps:{default:30},loop:{type:Boolean,default:!0},animation:{default:0},paused:{type:Boolean,default:!1},reversed:{type:Boolean,default:!1},flipX:{type:Boolean,default:!1},resetOnEnd:{type:Boolean,default:!1},asSprite:{type:Boolean,default:!0},center:{default:()=>[.5,.5]},alphaTest:{default:0},depthTest:{type:Boolean,default:!0},depthWrite:{type:Boolean,default:!0}},emits:["frame","end","loop","click"],async setup(o,{expose:e,emit:t}){let n,r;const s=o,i=t;Ie(s);const a=u.ref(0),c=u.ref(0),h=u.ref(0),d=u.ref(0),f=u.shallowRef();e({instance:f});const[p,m]=([n,r]=u.withAsyncContext(()=>Pc(s.image,s.atlas)),n=await n,r(),n);p.matrixAutoUpdate=!1;let _=rn(m,s.animation,s.reversed),v=.5,y=.5,g=1,M=xr(),b=null,S=0,O=!1,T=!0;te.useLoop().onBeforeRender(({delta:w})=>{for(!s.paused&&!O&&(g-=w*s.fps);g<=0;)g++,S++,s.loop?(S>=_.length&&i("loop",_[_.length-1].name),S%=_.length):S>=_.length&&(O=!0,S=s.resetOnEnd?0:_.length-1,i("end",_[_.length-1].name));_[S]!==M&&(M=_[S],b=M.name,C()),T&&(T=!1,p.offset.x=M.offsetX+(s.flipX?M.repeatX:0),p.offset.y=M.offsetY,p.repeat.x=M.repeatX*(s.flipX?-1:1),p.repeat.y=M.repeatY,p.updateMatrix(),h.value=M.width*On,d.value=M.height*On,a.value=(.5-v)*M.width*On,c.value=(.5-y)*M.height*On),b&&(i("frame",b),b=null)});function C(){T=!0}return u.watch(()=>s.animation,(w,A)=>{JSON.stringify(w)!==JSON.stringify(A)&&(_=rn(m,s.animation,s.reversed),S=0,g=1,O=!1,C())},{immediate:!0}),u.watch(()=>s.reversed,()=>{S=(_.length-S-1)%_.length,_=rn(m,s.animation,s.reversed),O&&(S=s.resetOnEnd?0:_.length-1),C()}),u.watch(()=>s.paused,()=>{O=!1}),u.watch(()=>s.loop,()=>{O&&s.loop&&(O=!1)}),u.watch(()=>s.resetOnEnd,()=>{O&&(S=s.resetOnEnd?0:_.length-1,C())}),u.watch(()=>s.flipX,C),u.watch(()=>[s.center],()=>{[v,y]=te.normalizeVectorFlexibleParam(s.center),C()},{immediate:!0}),u.watch(()=>[s.definitions],()=>{kc(m,s.definitions),_=rn(m,s.animation,s.reversed),g=1,S=0,C()},{immediate:!0}),u.onUnmounted(()=>{p.dispose()}),(w,A)=>(u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps({ref_key:"groupRef",ref:f},w.$attrs),[s.asSprite?(u.openBlock(),u.createElementBlock("TresSprite",{key:0,scale:[h.value,d.value,1],position:[a.value,c.value,0]},[u.createElementVNode("TresSpriteMaterial",{toneMapped:!1,map:u.unref(p),transparent:!0,alphaTest:s.alphaTest},null,8,Uc)],8,Fc)):(u.openBlock(),u.createElementBlock("TresMesh",{key:1,scale:[h.value,d.value,1],position:[a.value,c.value,0]},[zc,u.createElementVNode("TresMeshBasicMaterial",{toneMapped:!1,side:u.unref(l.DoubleSide),map:u.unref(p),transparent:!0,alphaTest:s.alphaTest,depthWrite:s.depthWrite,depthTest:s.depthTest},null,8,Vc)],8,Nc)),u.renderSlot(w.$slots,"default")],16))}});class Gc extends l.Line{constructor(e,t=1,n=16,r=2){const s=new l.BufferGeometry,i=n+r*2,a=new Float32Array((i*3+3)*3);s.setAttribute("position",new l.BufferAttribute(a,3));const c=new l.LineBasicMaterial({color:65280}),h=new l.LineBasicMaterial({color:16776960});super(s,[h,c]),this.audio=e,this.range=t,this.divisionsInnerAngle=n,this.divisionsOuterAngle=r,this.type="PositionalAudioHelper",this.update()}update(){const e=this.audio,t=this.range,n=this.divisionsInnerAngle,r=this.divisionsOuterAngle,s=l.MathUtils.degToRad(e.panner.coneInnerAngle),i=l.MathUtils.degToRad(e.panner.coneOuterAngle),a=s/2,c=i/2;let h=0,d=0,f,p;const m=this.geometry,_=m.attributes.position;m.clearGroups();function v(y,g,M,b){const S=(g-y)/M;for(_.setXYZ(h,0,0,0),d++,f=y;f<g;f+=S)p=h+d,_.setXYZ(p,Math.sin(f)*t,0,Math.cos(f)*t),_.setXYZ(p+1,Math.sin(Math.min(f+S,g))*t,0,Math.cos(Math.min(f+S,g))*t),_.setXYZ(p+2,0,0,0),d+=3;m.addGroup(h,d,b),h+=d,d=0}v(-c,-a,r,0),v(-a,a,n,1),v(a,c,r,0),_.needsUpdate=!0,s===i&&(this.material[0].visible=!1)}dispose(){this.geometry.dispose(),this.material[0].dispose(),this.material[1].dispose()}}const jc=["args"],Ec=u.defineComponent({__name:"PositionalAudio",props:{ready:{type:Boolean,default:!1},url:{},distance:{default:2},helper:{type:Boolean,default:!1},loop:{type:Boolean,default:!1},autoplay:{type:Boolean,default:!1},innerAngle:{default:360},outerAngle:{default:360},outerGain:{default:0}},emits:["isPlaying"],async setup(o,{expose:e,emit:t}){let n,r;const s=o,i=t,{ready:a,url:c,distance:h,helper:d,loop:f,autoplay:p,innerAngle:m,outerAngle:_,outerGain:v}=u.toRefs(s),{camera:y}=te.useTresContext(),g=u.shallowRef(null),M=u.shallowRef(null),b=u.shallowRef(null),S=u.shallowReactive(new l.AudioListener),O=()=>{var V,R,X;(V=g==null?void 0:g.value)!=null&&V.isPlaying||((R=g==null?void 0:g.value)==null||R.play(),i("isPlaying",(X=g==null?void 0:g.value)==null?void 0:X.isPlaying))},T=()=>{var V,R;(V=g==null?void 0:g.value)!=null&&V.isPlaying&&(g.value.pause(),i("isPlaying",(R=g==null?void 0:g.value)==null?void 0:R.isPlaying))},C=()=>{var V;g.value&&(g.value.stop(),i("isPlaying",(V=g==null?void 0:g.value)==null?void 0:V.isPlaying))},w=()=>{if(!(g!=null&&g.value))return;C();const V=g.value;V.source&&V.disconnect()},A=()=>{var V,R;!(g!=null&&g.value)||!(M!=null&&M.value)||((V=M==null?void 0:M.value)==null||V.dispose(),(R=g==null?void 0:g.value)==null||R.remove(M==null?void 0:M.value))},x=()=>{var V;if(g.value&&(g.value.setBuffer(b.value),g.value.setRefDistance(h.value),g.value.setLoop(f.value),g.value.setDirectionalCone(m.value,_.value,v.value),(V=M==null?void 0:M.value)==null||V.update(),M!=null&&M.value)){const R=M.value.material[0];!R.visible&&_.value!==m.value&&(R.visible=!0)}},D=()=>{var Y,J;x();const V=(Y=g.value)==null?void 0:Y.parent,R=new l.Box3().setFromObject(V),X=(R.max.z-R.min.z)*2;M.value=new Gc(g.value,X,32,16),(J=g==null?void 0:g.value)==null||J.add(M.value),M.value.update()},L=()=>{var V;(V=y==null?void 0:y.value)==null||V.remove(S),w(),A()};return e({root:g,play:O,stop:C,pause:T,dispose:L}),b.value=([n,r]=u.withAsyncContext(()=>te.useLoader(l.AudioLoader,c.value)),n=await n,r(),n),u.watch(g,()=>{g!=null&&g.value&&(d.value&&D(),a.value&&p&&O())}),u.watch(d,()=>{d.value?D():A()}),u.watch(a,()=>{a.value&&x(),p.value&&a.value&&O(),!p.value&&a.value&&C()}),u.watch([h,f,b,m,_,v,p],()=>{x()}),u.onMounted(()=>{var V;(V=y==null?void 0:y.value)==null||V.add(S)}),u.onBeforeUnmount(()=>{L()}),(V,R)=>(u.openBlock(),u.createElementBlock("TresPositionalAudio",u.mergeProps({ref_key:"positionalAudioRef",ref:g,args:[u.unref(S)]},V.$attrs),null,16,jc))}}),Dn={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"},Yc="https://raw.githubusercontent.com/Tresjs/assets/main/textures/hdr/";async function ri(o,e){const{scene:t}=te.useTresContext(),{preset:n,blur:r,files:s=[],path:i="",background:a}=u.toRefs(o),{invalidateOnDemand:c}=Ie(o),h=u.ref(),d=u.computed(()=>Array.isArray(s.value)),f=u.computed(()=>d.value?l.CubeTextureLoader:zs),p=u.ref(null);return u.watch(()=>[s,i],async([m,_])=>{if(m.value.length>0&&!n.value){try{p.value=await te.useLoader(u.unref(f),d.value?[u.unref(m)]:u.unref(m),v=>{_.value&&v.setPath(u.unref(_))})}catch(v){throw new Error(`Failed to load environment map: ${v}`)}p.value&&(h.value=d.value?p.value[0]:p.value,h.value.mapping=d.value?l.CubeReflectionMapping:l.EquirectangularReflectionMapping)}},{immediate:!0}),u.watch(()=>h.value,m=>{t.value&&(t.value.environment=m)},{immediate:!0}),u.watch(()=>[a.value,h.value],([m,_])=>{if(t.value){const v=e!=null&&e.value?e.value.texture:_;t.value.background=m?v:void 0}},{immediate:!0}),u.watch(()=>r==null?void 0:r.value,m=>{t.value&&(t.value.backgroundBlurriness=m)},{immediate:!0}),u.watch(n,async m=>{if(m&&m in Dn){const _=Yc,v=Dn[m];try{p.value=await te.useLoader(zs,v,y=>{_&&y.setPath(_)})}catch(y){throw new Error(`Failed to load environment map: ${y}`)}p.value&&(h.value=p.value,h.value.mapping=l.EquirectangularReflectionMapping),c()}else if(m&&!(m in Dn))throw new Error(`Preset must be one of: ${Object.keys(Dn).join(", ")}`)},{immediate:!0}),{texture:h}}let bt=null;function Wc(o,e){return t=>{e&&e(t),o.draco&&(bt||(bt=new Ml),bt.setDecoderPath(o.decoderPath||"https://www.gstatic.com/draco/versioned/decoders/1.4.3/"),t.setDRACOLoader&&t.setDRACOLoader(bt))}}async function si(o,e={draco:!1},t){const n=await te.useLoader(pa,o,Wc(e,t));return bt==null||bt.dispose(),bt=null,n}const Xc=["object"],Zc=u.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=u.ref();e({instance:s});const{scene:i}=([t,n]=u.withAsyncContext(()=>si(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,c)=>(u.openBlock(),u.createElementBlock("primitive",u.mergeProps({ref_key:"modelRef",ref:s,object:u.unref(i)},a.$attrs),null,16,Xc))}});async function ii(o){return await te.useLoader(il,o)}const Kc=["object"],qc=u.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=u.ref();e({instance:s});const i=([t,n]=u.withAsyncContext(()=>ii(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,c)=>(u.openBlock(),u.createElementBlock("primitive",u.mergeProps({ref_key:"modelRef",ref:s,object:u.unref(i)},a.$attrs),null,16,Kc))}}),Qc=["geometry","render-order"],Jc=u.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:c,strokeMeshProps:h,depth:d}=u.toRefs(t),f=u.shallowRef(),p=u.shallowRef([]),m=u.shallowRef([]);e({instance:f}),u.watchEffect(async()=>_(n.value).then(g=>m.value=g.paths)),u.watch([s,r,i,a,m],y);async function _(g){const M=g.startsWith("<svg")?encodeURI(`data:image/svg+xml;utf8,${g}`):g;return te.useLoader(tn,M)}u.onUnmounted(v);function v(){p.value.forEach(g=>g.geometry.dispose())}function y(){var O,T,C;v();const g=[],[M,b]=(()=>{const w={flat:!1,renderOrder:!1,offsetZ:!0},A={flat:0,renderOrder:0,offsetZ:.025},x=d.value;return typeof x=="number"?[!0,x]:[w[x],A[x]]})();let S=0;for(const w of m.value){const A=((O=w.userData)==null?void 0:O.style)??{},x=Object.assign({color:A.fill,opacity:A.fillOpacity,transparent:!0,side:l.DoubleSide,depthWrite:M},t.fillMaterial);if(!s.value&&A.fill!==void 0&&A.fill!=="none")for(const D of tn.createShapes(w)){const L=new l.ShapeGeometry(D);L.scale(1,-1,1),b&&L.translate(0,0,S++*b),g.push({geometry:L,material:x,isStroke:!1})}if(!r.value&&A.stroke!==void 0&&A.stroke!=="none"){const D=Object.assign({color:(T=w.userData)==null?void 0:T.style.stroke,opacity:(C=w.userData)==null?void 0:C.style.strokeOpacity,transparent:!0,side:l.DoubleSide,depthWrite:M},t.strokeMaterial);for(const L of w.subPaths){const V=L.getPoints().map(X=>new l.Vector2(X.x,-X.y)),R=tn.pointsToStroke(V,A||"none");b&&R.translate(0,0,S++*b),g.push({geometry:R,material:D,isStroke:!0})}}}p.value=g}return(g,M)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"svgRef",ref:f},[(u.openBlock(!0),u.createElementBlock(u.Fragment,null,u.renderList(p.value,({geometry:b,material:S,isStroke:O},T)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({key:`${T}`,ref_for:!0},O?u.unref(h):u.unref(c),{geometry:b,"render-order":u.unref(d)==="renderOrder"?T:0}),[u.createElementVNode("TresMeshBasicMaterial",u.mergeProps({ref_for:!0},S),null,16)],16,Qc))),128))],512))}}),oi="[TresJS - Cientos ▲ ■ ♥] ";function ai(){function o(n,r){console.error(`${oi} ${n}`,r||"")}function e(n){console.warn(`${oi} ${n}`)}function t(n,r){}return{logError:o,logWarning:e,logMessage:t}}let wr=0;function Hc(){const o=u.ref(!1),e=u.ref(0),t=u.ref([]),{logError:n}=ai();return new Promise(r=>{l.DefaultLoadingManager.onStart=()=>{o.value=!1},l.DefaultLoadingManager.onLoad=()=>{o.value=!0},l.DefaultLoadingManager.onProgress=(s,i,a)=>{i===a&&(wr=a,o.value=!0,t.value.push(s)),e.value=Math.round((i-wr)/(a-wr)*100||100,2)},l.DefaultLoadingManager.onError=s=>{n("Error loading assets",new Error(s)),o.value=!0},r({items:t,hasFinishLoading:o,progress:e})})}async function $c(o,e){const{logError:t}=ai();if(!o)return t("Error no path provided");const{unsuspend:n,start:r,crossOrigin:s,muted:i,loop:a,...c}={unsuspend:"loadedmetadata",crossOrigin:"Anonymous",muted:!0,loop:!0,start:!0,playsInline:!0,...e};function h(){return new Promise((d,f)=>{const p=Object.assign(document.createElement("video"),{src:typeof o=="string"&&o||void 0,crossOrigin:s,loop:a,muted:i,autoplay:!0,...c}),m=new l.VideoTexture(p);return p.addEventListener(n,()=>d(m)),p.addEventListener("error",()=>f(new Error("Error loading video"))),m})}try{const d=await h();return r&&d.image&&d.image.play(),d}catch{t("Error loading resource")}}const eu=["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"],tu=u.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:Number.POSITIVE_INFINITY},minAzimuthAngle:{default:Number.NEGATIVE_INFINITY},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:Number.POSITIVE_INFINITY},minZoom:{default:0},maxZoom:{default:Number.POSITIVE_INFINITY},touches:{default:()=>({ONE:l.TOUCH.ROTATE,TWO:l.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:c,dampingFactor:h,enablePan:d,keyPanSpeed:f,maxAzimuthAngle:p,minAzimuthAngle:m,maxPolarAngle:_,minPolarAngle:v,minDistance:y,maxDistance:g,minZoom:M,maxZoom:b,enableZoom:S,zoomSpeed:O,enableRotate:T,touches:C,rotateSpeed:w,target:A}=u.toRefs(n),{invalidateOnDemand:x}=Ie(n),{camera:D,renderer:L,extend:V,controls:R}=te.useTresContext(),X=u.ref(null);V({OrbitControls:xs}),u.watch(X,q=>{Y(),q&&s.value?R.value=q:R.value=null});function Y(){Ce(X.value,"change",()=>{r("change",X.value),x()}),Ce(X.value,"start",()=>r("start",X.value)),Ce(X.value,"end",()=>r("end",X.value))}const{onBeforeRender:J}=te.useLoop();return J(()=>{X.value&&(c.value||i.value)&&(X.value.update(),i.value&&x())}),u.onUnmounted(()=>{X.value&&X.value.dispose()}),e({instance:X}),(q,re)=>(q.camera||u.unref(D))&&(q.domElement||u.unref(L))?(u.openBlock(),u.createElementBlock("TresOrbitControls",{key:0,ref_key:"controlsRef",ref:X,target:u.unref(A),"auto-rotate":u.unref(i),"auto-rotate-speed":u.unref(a),"enable-damping":u.unref(c),"damping-factor":u.unref(h),"enable-pan":u.unref(d),"key-pan-speed":u.unref(f),keys:q.keys,"max-azimuth-angle":u.unref(p),"min-azimuth-angle":u.unref(m),"max-polar-angle":u.unref(_),"min-polar-angle":u.unref(v),"min-distance":u.unref(y),"max-distance":u.unref(g),"min-zoom":u.unref(M),"max-zoom":u.unref(b),touches:u.unref(C),"enable-zoom":u.unref(S),"zoom-speed":u.unref(O),"enable-rotate":u.unref(T),"rotate-speed":u.unref(w),args:[q.camera||u.unref(D),q.domElement||u.unref(L).domElement]},null,8,eu)):u.createCommentVNode("",!0)}}),nu=u.defineComponent({__name:"KeyboardControls",props:{makeDefault:{type:Boolean,default:!0},camera:{},domElement:{},moveSpeed:{default:.2},selector:{}},emits:["isLock","change"],setup(o,{expose:e,emit:t}){const n=o,r=t,{moveSpeed:s}=u.toRefs(n),{invalidateOnDemand:i}=Ie(n),{camera:a,controls:c,renderer:h}=te.useTresContext(),d=u.ref(0),f=u.ref(0),{w:p,s:m,a:_,d:v,Up:y,Down:g,Left:M,Right:b}=Kl();u.watchEffect(()=>{_.value||M.value?d.value=-s.value:v.value||b.value?d.value=s.value:d.value=0,p.value||y.value?f.value=s.value:m.value||g.value?f.value=-s.value:f.value=0}),e({instance:c});const S=D=>r("isLock",D),O=D=>r("change",D),T=new l.Vector3,C=new l.Vector3,w=new l.Quaternion,A=(D,L)=>{var X;if(!((X=a.value)!=null&&X.position)&&!T)return;const V=a.value,R=D*.001;V==null||V.translateZ(-L),w.set(C.x*R,C.y*R,C.z*R,1).normalize(),V==null||V.quaternion.multiply(w),(d.value||f.value)&&r("change",c.value)},{onBeforeRender:x}=te.useLoop();return x(({delta:D})=>{var L;c.value instanceof ys&&((L=c.value)!=null&&L.isLocked)&&(A(D,f.value),c.value.moveRight(d.value),i())}),(D,L)=>(u.openBlock(),u.createBlock(u.unref(li),{selector:D.selector,"make-default":D.makeDefault,camera:D.camera||u.unref(a),"dom-element":D.domElement||u.unref(h).domElement,onIsLock:S,onChange:O},null,8,["selector","make-default","camera","dom-element"]))}}),ru=["object","args","mode","enabled","axis","translation-snap","rotation-snap","scale-snap","space","size","show-x","show-y","show-z"],su=u.defineComponent({__name:"TransformControls",props:{object:{},camera:{},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,{expose:e,emit:t}){const n=o,r=t,{object:s,mode:i,enabled:a,axis:c,translationSnap:h,rotationSnap:d,scaleSnap:f,space:p,size:m,showX:_,showY:v,showZ:y}=u.toRefs(n),{invalidateOnDemand:g}=Ie(n),M=u.shallowRef(),{controls:b,camera:S,renderer:O,extend:T}=te.useTresContext();T({TransformControls:ta});const C=()=>{g(),r("change")},w=V=>{b.value&&(b.value.enabled=!V.value),g(),r("dragging",V.value)},A=()=>{g(),r("mouseDown")},x=()=>{g(),r("mouseDown")},D=()=>{g(),r("objectChange")};function L(){Ce(M.value,"change",C),Ce(M.value,"dragging-changed",w),Ce(M.value,"mouseDown",A),Ce(M.value,"mouseUp",x),Ce(M.value,"objectChange",D)}return u.watchEffect(()=>{M.value&&L()}),u.onUnmounted(()=>{M.value&&M.value.dispose()}),e({instance:M}),(V,R)=>{var X;return(V.camera||u.unref(S))&&u.unref(O)?(u.openBlock(),u.createElementBlock("TresTransformControls",{ref_key:"controlsRef",ref:M,key:(X=V.camera||u.unref(S))==null?void 0:X.uuid,object:u.unref(s),args:[V.camera||u.unref(S),u.unref(O).domElement],mode:u.unref(i),enabled:u.unref(a),axis:u.unref(c),"translation-snap":u.unref(h),"rotation-snap":u.unref(d),"scale-snap":u.unref(f),space:u.unref(p),size:u.unref(m),"show-x":u.unref(_),"show-y":u.unref(v),"show-z":u.unref(y),visible:!0},null,8,ru)):u.createCommentVNode("",!0)}}}),iu=["args"],li=u.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,{invalidateOnDemand:s}=Ie(n),{camera:i,renderer:a,extend:c,controls:h}=te.useTresContext(),d=u.ref(null);let f;c({PointerLockControls:ys});const p=m=>{r("isLock",m)};return u.watch(d,m=>{m&&n.makeDefault?h.value=m:h.value=null,f=document.getElementById(n.selector||"")||a.value.domElement,Ce(h.value,"change",()=>{r("change",h.value),s()}),Ce(f,"click",()=>{var v,y,g;(v=h.value)==null||v.lock(),(y=h.value)==null||y.addEventListener("lock",()=>p(!0)),(g=h.value)==null||g.addEventListener("unlock",()=>p(!1)),s()})}),u.onUnmounted(()=>{var m,_;(m=h.value)==null||m.removeEventListener("lock",()=>p(!0)),(_=h.value)==null||_.removeEventListener("unlock",()=>p(!1)),d.value&&d.value.dispose()}),e({instance:h}),(m,_)=>(m.camera||u.unref(i))&&(m.domElement||u.unref(a))?(u.openBlock(),u.createElementBlock("TresPointerLockControls",{key:0,ref_key:"controlsRef",ref:d,args:[m.camera||u.unref(i),m.domElement||u.unref(a).domElement]},null,8,iu)):u.createCommentVNode("",!0)}}),ou=["args","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","enable-zoom","zoom-speed","enable-rotate","rotate-speed"],au=u.defineComponent({__name:"MapControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},target:{},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:Number.POSITIVE_INFINITY},minAzimuthAngle:{default:Number.NEGATIVE_INFINITY},maxPolarAngle:{default:Math.PI},minPolarAngle:{default:0},minDistance:{default:0},maxDistance:{default:Number.POSITIVE_INFINITY},minZoom:{default:0},maxZoom:{default:Number.POSITIVE_INFINITY},touches:{},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,{invalidateOnDemand:r}=Ie(n),{autoRotate:s,autoRotateSpeed:i,enableDamping:a,dampingFactor:c,enablePan:h,keyPanSpeed:d,maxAzimuthAngle:f,minAzimuthAngle:p,maxPolarAngle:m,minPolarAngle:_,minDistance:v,maxDistance:y,minZoom:g,maxZoom:M,enableZoom:b,zoomSpeed:S,enableRotate:O,rotateSpeed:T}=u.toRefs(n),{camera:C,renderer:w,extend:A,controls:x}=te.useTresContext(),D=u.ref(null);A({MapControls:fa}),u.watch(x,V=>{V&&n.makeDefault?x.value=V:x.value=null});const{onBeforeRender:L}=te.useLoop();return L(()=>{D.value&&(a.value||s.value)&&(D.value.update(),r())}),u.onUnmounted(()=>{D.value&&D.value.dispose()}),e({instance:D}),(V,R)=>(V.camera||u.unref(C))&&(V.domElement||u.unref(w))?(u.openBlock(),u.createElementBlock("TresMapControls",{key:0,ref_key:"controlsRef",ref:D,args:[V.camera||u.unref(C),V.domElement||u.unref(w).domElement],"auto-rotate":u.unref(s),"auto-rotate-speed":u.unref(i),"enable-damping":u.unref(a),"damping-factor":u.unref(c),"enable-pan":u.unref(h),"key-pan-speed":u.unref(d),keys:V.keys,"max-azimuth-angle":u.unref(f),"min-azimuth-angle":u.unref(p),"max-polar-angle":u.unref(m),"min-polar-angle":u.unref(_),"min-distance":u.unref(v),"max-distance":u.unref(y),"min-zoom":u.unref(g),"max-zoom":u.unref(M),"enable-zoom":u.unref(b),"zoom-speed":u.unref(S),"enable-rotate":u.unref(O),"rotate-speed":u.unref(T)},null,8,ou)):u.createCommentVNode("",!0)}}),lu=u.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,{expose:e,emit:t}){const n=o,r=t,{invalidateOnDemand:s}=Ie(n),{logWarning:i}=te.useLogger();n.smoothScroll<0&&i("SmoothControl must be greater than zero"),n.pages<0&&i("Pages must be greater than zero");const{camera:a,controls:c,renderer:h}=te.useTresContext(),d=u.shallowRef(),f=document.createElement("div"),{y:p}=Jl(),{x:m,y:_,isScrolling:v}=Xl(f),{height:y,width:g}=js();let M=0;const b=u.ref(!1),S=u.ref(0),O=u.ref(0),T=u.ref(0),C=n.horizontal?"x":"y",w=u.watch(a,x=>{if(b.value){w();return}M=n.horizontal?(x==null?void 0:x.position.x)||0:(x==null?void 0:x.position.y)||0,b.value=!0},{immediate:!0});u.watch(v,x=>{c.value&&(c.value.enabled=!x)},{immediate:!0}),u.watch(p,x=>{!v.value&&!n.htmlScroll||(O.value=x/y.value/(T.value/y.value-1),S.value=-1*O.value,r("update:modelValue",O.value))}),u.watch(_,x=>{O.value=x/y.value/(T.value/y.value),S.value=-1*O.value,r("update:modelValue",O.value)}),u.watch(m,x=>{O.value=x/g.value/(T.value/g.value-1),S.value=+O.value,r("update:modelValue",O.value)}),u.watch(h,x=>{var L,V;const D=x==null?void 0:x.domElement;if(n.htmlScroll&&(x!=null&&x.domElement))D!=null&&D.style.width&&(D!=null&&D.style.position)&&(D!=null&&D.style.top)&&(D!=null&&D.style.left)&&(D.style.width="100%",D.style.position="fixed",D.style.zIndex=" -99999",D.style.top="0",D.style.left="0"),T.value=document.body.scrollHeight;else{const R=document.createElement("div"),X=document.createElement("div");f.style[n.horizontal?"overflowX":"overflowY"]="auto",f.style[n.horizontal?"overflowY":"overflowX"]="hidden",f.style.position="absolute",f.style.width="100%",f.style.height=" 100%",f.style.top="0",f.style.left="0",f.classList.add("scrollContainer"),R.style.position="sticky",R.style.top="0px",R.style.left="0px",R.style.width="100%",R.style.height="100%",R.style.overflow="hidden",f.appendChild(R),X.style.height=n.horizontal?"100%":`${y.value*n.pages}px`,X.style.width=n.horizontal?`${g.value*n.pages}px`:"100vw",X.style.pointerEvents="none",D.style.position="fixed",D.style.zIndex="0",D!=null&&D.style.width&&(D.style.width="100%"),f.appendChild(X),x.domElement.parentNode.style.position="relative",(V=(L=x==null?void 0:x.domElement)==null?void 0:L.parentNode)==null||V.appendChild(f),T.value=n.horizontal?g.value*n.pages:y.value*n.pages}},{immediate:!0});const{onBeforeRender:A}=te.useLoop();return A(()=>{var x;if((x=a.value)!=null&&x.position){const D=(S.value*n.distance-a.value.position[C]+M)*n.smoothScroll;a.value.position[C]+=D,d.value.children.length>0&&(d.value.position[C]+=D),s()}}),e({instance:d}),(x,D)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"wrapperRef",ref:d},[u.renderSlot(x.$slots,"default")],512))}});/*!
|
|
248
509
|
* camera-controls
|
|
249
510
|
* https://github.com/yomotsu/camera-controls
|
|
250
511
|
* (c) 2017 @yomotsu
|
|
251
512
|
* Released under the MIT License.
|
|
252
|
-
*/const Le={LEFT:1,RIGHT:2,MIDDLE:4},H=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}),Gt={NONE:0,IN:1,OUT:-1};function Dt(o){return o.isPerspectiveCamera}function wt(o){return o.isOrthographicCamera}const jt=Math.PI*2,ei=Math.PI/2,ti=1e-5,rn=Math.PI/180;function et(o,e,t){return Math.max(e,Math.min(t,o))}function Ce(o,e=ti){return Math.abs(o)<e}function Se(o,e,t=ti){return Ce(o-e,t)}function ni(o,e){return Math.round(o/e)*e}function sn(o){return isFinite(o)?o:o<0?-Number.MAX_VALUE:Number.MAX_VALUE}function on(o){return Math.abs(o)<Number.MAX_VALUE?o:o*(1/0)}function Tn(o,e,t,n,r=1/0,s){n=Math.max(1e-4,n);const i=2/n,a=i*s,c=1/(1+a+.48*a*a+.235*a*a*a);let h=o-e;const f=e,d=r*n;h=et(h,-d,d),e=o-h;const p=(t.value+i*h)*s;t.value=(t.value-i*p)*c;let g=e+(h+p)*c;return f-o>0==g>f&&(g=f,t.value=(g-f)/s),g}function ri(o,e,t,n,r=1/0,s,i){n=Math.max(1e-4,n);const a=2/n,c=a*s,h=1/(1+c+.48*c*c+.235*c*c*c);let f=e.x,d=e.y,p=e.z,g=o.x-f,x=o.y-d,v=o.z-p;const _=f,m=d,M=p,b=r*n,S=b*b,L=g*g+x*x+v*v;if(L>S){const Y=Math.sqrt(L);g=g/Y*b,x=x/Y*b,v=v/Y*b}f=o.x-g,d=o.y-x,p=o.z-v;const P=(t.x+a*g)*s,T=(t.y+a*x)*s,y=(t.z+a*v)*s;t.x=(t.x-a*P)*h,t.y=(t.y-a*T)*h,t.z=(t.z-a*y)*h,i.x=f+(g+P)*h,i.y=d+(x+T)*h,i.z=p+(v+y)*h;const A=_-o.x,w=m-o.y,D=M-o.z,k=i.x-_,R=i.y-m,V=i.z-M;return A*k+w*R+D*V>0&&(i.x=_,i.y=m,i.z=M,t.x=(i.x-_)/s,t.y=(i.y-m)/s,t.z=(i.z-M)/s),i}function _r(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 xr(o,e){return wt(o)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class Tc{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)}}}var wr;const Ic="2.8.3",In=1/8,Lc=/Mac/.test((wr=globalThis==null?void 0:globalThis.navigator)===null||wr===void 0?void 0:wr.platform);let fe,si,Ln,br,Re,ye,be,Rt,an,rt,st,kt,ii,oi,Je,ln,Wt,ai,Mr,li,Sr,Ar,On;class Ue extends Tc{static install(e){fe=e.THREE,si=Object.freeze(new fe.Vector3(0,0,0)),Ln=Object.freeze(new fe.Vector3(0,1,0)),br=Object.freeze(new fe.Vector3(0,0,1)),Re=new fe.Vector2,ye=new fe.Vector3,be=new fe.Vector3,Rt=new fe.Vector3,an=new fe.Vector3,rt=new fe.Vector3,st=new fe.Vector3,kt=new fe.Vector3,ii=new fe.Vector3,oi=new fe.Vector3,Je=new fe.Spherical,ln=new fe.Spherical,Wt=new fe.Box3,ai=new fe.Box3,Mr=new fe.Sphere,li=new fe.Quaternion,Sr=new fe.Quaternion,Ar=new fe.Matrix4,On=new fe.Raycaster}static get ACTION(){return H}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=H.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=Gt.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new fe.Vector3,this._focalOffsetVelocity=new fe.Vector3,this._zoomVelocity={value:0},this._truckInternal=(m,M,b)=>{let S,L;if(Dt(this._camera)){const P=ye.copy(this._camera.position).sub(this._target),T=this._camera.getEffectiveFOV()*rn,y=P.length()*Math.tan(T*.5);S=this.truckSpeed*m*y/this._elementRect.height,L=this.truckSpeed*M*y/this._elementRect.height}else if(wt(this._camera)){const P=this._camera;S=m*(P.right-P.left)/P.zoom/this._elementRect.width,L=M*(P.top-P.bottom)/P.zoom/this._elementRect.height}else return;this.verticalDragToForward?(b?this.setFocalOffset(this._focalOffsetEnd.x+S,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(S,0,!0),this.forward(-L,!0)):b?this.setFocalOffset(this._focalOffsetEnd.x+S,this._focalOffsetEnd.y+L,this._focalOffsetEnd.z,!0):this.truck(S,L,!0)},this._rotateInternal=(m,M)=>{const b=jt*this.azimuthRotateSpeed*m/this._elementRect.height,S=jt*this.polarRotateSpeed*M/this._elementRect.height;this.rotate(b,S,!0)},this._dollyInternal=(m,M,b)=>{const S=Math.pow(.95,-m*this.dollySpeed),L=this._sphericalEnd.radius,P=this._sphericalEnd.radius*S,T=et(P,this.minDistance,this.maxDistance),y=T-P;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(P,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(y,!0),this._dollyToNoClamp(T,!0)):this._dollyToNoClamp(T,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?P:T)-L,this._dollyControlCoord.set(M,b)),this._lastDollyDirection=Math.sign(-m)},this._zoomInternal=(m,M,b)=>{const S=Math.pow(.95,m*this.dollySpeed),L=this._zoom,P=this._zoom*S;this.zoomTo(P,!0),this.dollyToCursor&&(this._changedZoom+=P-L,this._dollyControlCoord.set(M,b))},typeof fe>"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 fe.Quaternion().setFromUnitVectors(this._camera.up,Ln),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=H.NONE,this._target=new fe.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new fe.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new fe.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 fe.Vector3,new fe.Vector3,new fe.Vector3,new fe.Vector3],this._updateNearPlaneCorners(),this._boundary=new fe.Box3(new fe.Vector3(-1/0,-1/0,-1/0),new fe.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 fe.Vector2,this.mouseButtons={left:H.ROTATE,middle:H.DOLLY,right:H.TRUCK,wheel:Dt(this._camera)?H.DOLLY:wt(this._camera)?H.ZOOM:H.NONE},this.touches={one:H.TOUCH_ROTATE,two:Dt(this._camera)?H.TOUCH_DOLLY_TRUCK:wt(this._camera)?H.TOUCH_ZOOM_TRUCK:H.NONE,three:H.TOUCH_TRUCK};const n=new fe.Vector2,r=new fe.Vector2,s=new fe.Vector2,i=m=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const S=this._domElement.getBoundingClientRect(),L=m.clientX/S.width,P=m.clientY/S.height;if(L<this._interactiveArea.left||L>this._interactiveArea.right||P<this._interactiveArea.top||P>this._interactiveArea.bottom)return}const M=m.pointerType!=="mouse"?null:(m.buttons&Le.LEFT)===Le.LEFT?Le.LEFT:(m.buttons&Le.MIDDLE)===Le.MIDDLE?Le.MIDDLE:(m.buttons&Le.RIGHT)===Le.RIGHT?Le.RIGHT:null;if(M!==null){const S=this._findPointerByMouseButton(M);S&&this._disposePointer(S)}if((m.buttons&Le.LEFT)===Le.LEFT&&this._lockedPointer)return;const b={pointerId:m.pointerId,clientX:m.clientX,clientY:m.clientY,deltaX:0,deltaY:0,mouseButton:M};this._activePointers.push(b),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",c),this._isDragging=!0,p(m)},a=m=>{m.cancelable&&m.preventDefault();const M=m.pointerId,b=this._lockedPointer||this._findPointerById(M);if(b){if(b.clientX=m.clientX,b.clientY=m.clientY,b.deltaX=m.movementX,b.deltaY=m.movementY,this._state=0,m.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&&(m.buttons&Le.LEFT)===Le.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(m.buttons&Le.MIDDLE)===Le.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(m.buttons&Le.RIGHT)===Le.RIGHT&&(this._state=this._state|this.mouseButtons.right);g()}},c=m=>{const M=this._findPointerById(m.pointerId);if(!(M&&M===this._lockedPointer)){if(M&&this._disposePointer(M),m.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=H.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=H.NONE;x()}};let h=-1;const f=m=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===H.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const P=this._domElement.getBoundingClientRect(),T=m.clientX/P.width,y=m.clientY/P.height;if(T<this._interactiveArea.left||T>this._interactiveArea.right||y<this._interactiveArea.top||y>this._interactiveArea.bottom)return}if(m.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===H.ROTATE||this.mouseButtons.wheel===H.TRUCK){const P=performance.now();h-P<1e3&&this._getClientRect(this._elementRect),h=P}const M=Lc?-1:-3,b=m.deltaMode===1?m.deltaY/M:m.deltaY/(M*10),S=this.dollyToCursor?(m.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,L=this.dollyToCursor?(m.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case H.ROTATE:{this._rotateInternal(m.deltaX,m.deltaY),this._isUserControllingRotate=!0;break}case H.TRUCK:{this._truckInternal(m.deltaX,m.deltaY,!1),this._isUserControllingTruck=!0;break}case H.OFFSET:{this._truckInternal(m.deltaX,m.deltaY,!0),this._isUserControllingOffset=!0;break}case H.DOLLY:{this._dollyInternal(-b,S,L),this._isUserControllingDolly=!0;break}case H.ZOOM:{this._zoomInternal(-b,S,L),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},d=m=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Ue.ACTION.NONE){const M=m instanceof PointerEvent?m.pointerId:0,b=this._findPointerById(M);b&&this._disposePointer(b),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c);return}m.preventDefault()}},p=m=>{if(!this._enabled)return;if(_r(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,S=Re.y-this._activePointers[1].clientY,L=Math.sqrt(b*b+S*S);s.set(0,L);const P=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,T=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;r.set(P,T)}if(this._state=0,!m)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in m&&m.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&&(m.buttons&Le.LEFT)===Le.LEFT&&(this._state=this._state|this.mouseButtons.left),(m.buttons&Le.MIDDLE)===Le.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(m.buttons&Le.RIGHT)===Le.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&H.ROTATE)===H.ROTATE||(this._state&H.TOUCH_ROTATE)===H.TOUCH_ROTATE||(this._state&H.TOUCH_DOLLY_ROTATE)===H.TOUCH_DOLLY_ROTATE||(this._state&H.TOUCH_ZOOM_ROTATE)===H.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&H.TRUCK)===H.TRUCK||(this._state&H.TOUCH_TRUCK)===H.TOUCH_TRUCK||(this._state&H.TOUCH_DOLLY_TRUCK)===H.TOUCH_DOLLY_TRUCK||(this._state&H.TOUCH_ZOOM_TRUCK)===H.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&H.DOLLY)===H.DOLLY||(this._state&H.TOUCH_DOLLY)===H.TOUCH_DOLLY||(this._state&H.TOUCH_DOLLY_TRUCK)===H.TOUCH_DOLLY_TRUCK||(this._state&H.TOUCH_DOLLY_OFFSET)===H.TOUCH_DOLLY_OFFSET||(this._state&H.TOUCH_DOLLY_ROTATE)===H.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&H.ZOOM)===H.ZOOM||(this._state&H.TOUCH_ZOOM)===H.TOUCH_ZOOM||(this._state&H.TOUCH_ZOOM_TRUCK)===H.TOUCH_ZOOM_TRUCK||(this._state&H.TOUCH_ZOOM_OFFSET)===H.TOUCH_ZOOM_OFFSET||(this._state&H.TOUCH_ZOOM_ROTATE)===H.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&H.OFFSET)===H.OFFSET||(this._state&H.TOUCH_OFFSET)===H.TOUCH_OFFSET||(this._state&H.TOUCH_DOLLY_OFFSET)===H.TOUCH_DOLLY_OFFSET||(this._state&H.TOUCH_ZOOM_OFFSET)===H.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},g=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,_r(this._activePointers,Re);const M=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,b=M?-M.deltaX:r.x-Re.x,S=M?-M.deltaY:r.y-Re.y;if(r.copy(Re),((this._state&H.ROTATE)===H.ROTATE||(this._state&H.TOUCH_ROTATE)===H.TOUCH_ROTATE||(this._state&H.TOUCH_DOLLY_ROTATE)===H.TOUCH_DOLLY_ROTATE||(this._state&H.TOUCH_ZOOM_ROTATE)===H.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(b,S),this._isUserControllingRotate=!0),(this._state&H.DOLLY)===H.DOLLY||(this._state&H.ZOOM)===H.ZOOM){const L=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,P=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0,T=this.dollyDragInverted?-1:1;(this._state&H.DOLLY)===H.DOLLY?(this._dollyInternal(T*S*In,L,P),this._isUserControllingDolly=!0):(this._zoomInternal(T*S*In,L,P),this._isUserControllingZoom=!0)}if((this._state&H.TOUCH_DOLLY)===H.TOUCH_DOLLY||(this._state&H.TOUCH_ZOOM)===H.TOUCH_ZOOM||(this._state&H.TOUCH_DOLLY_TRUCK)===H.TOUCH_DOLLY_TRUCK||(this._state&H.TOUCH_ZOOM_TRUCK)===H.TOUCH_ZOOM_TRUCK||(this._state&H.TOUCH_DOLLY_OFFSET)===H.TOUCH_DOLLY_OFFSET||(this._state&H.TOUCH_ZOOM_OFFSET)===H.TOUCH_ZOOM_OFFSET||(this._state&H.TOUCH_DOLLY_ROTATE)===H.TOUCH_DOLLY_ROTATE||(this._state&H.TOUCH_ZOOM_ROTATE)===H.TOUCH_ZOOM_ROTATE){const L=Re.x-this._activePointers[1].clientX,P=Re.y-this._activePointers[1].clientY,T=Math.sqrt(L*L+P*P),y=s.y-T;s.set(0,T);const A=this.dollyToCursor?(r.x-this._elementRect.x)/this._elementRect.width*2-1:0,w=this.dollyToCursor?(r.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&H.TOUCH_DOLLY)===H.TOUCH_DOLLY||(this._state&H.TOUCH_DOLLY_ROTATE)===H.TOUCH_DOLLY_ROTATE||(this._state&H.TOUCH_DOLLY_TRUCK)===H.TOUCH_DOLLY_TRUCK||(this._state&H.TOUCH_DOLLY_OFFSET)===H.TOUCH_DOLLY_OFFSET?(this._dollyInternal(y*In,A,w),this._isUserControllingDolly=!0):(this._zoomInternal(y*In,A,w),this._isUserControllingZoom=!0)}((this._state&H.TRUCK)===H.TRUCK||(this._state&H.TOUCH_TRUCK)===H.TOUCH_TRUCK||(this._state&H.TOUCH_DOLLY_TRUCK)===H.TOUCH_DOLLY_TRUCK||(this._state&H.TOUCH_ZOOM_TRUCK)===H.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(b,S,!1),this._isUserControllingTruck=!0),((this._state&H.OFFSET)===H.OFFSET||(this._state&H.TOUCH_OFFSET)===H.TOUCH_OFFSET||(this._state&H.TOUCH_DOLLY_OFFSET)===H.TOUCH_DOLLY_OFFSET||(this._state&H.TOUCH_ZOOM_OFFSET)===H.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(b,S,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},x=()=>{_r(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",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),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",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",v),this._domElement.ownerDocument.addEventListener("pointerlockerror",_),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",c),p())},this.unlockPointer=()=>{var m,M,b;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(m=this._domElement)===null||m===void 0||m.ownerDocument.exitPointerLock(),(M=this._domElement)===null||M===void 0||M.ownerDocument.removeEventListener("pointerlockchange",v),(b=this._domElement)===null||b===void 0||b.ownerDocument.removeEventListener("pointerlockerror",_),this.cancel()};const v=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},_=()=>{this.unlockPointer()};this._addAllEventListeners=m=>{this._domElement=m,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",i),this._domElement.addEventListener("pointercancel",c),this._domElement.addEventListener("wheel",f,{passive:!1}),this._domElement.addEventListener("contextmenu",d)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",i),this._domElement.removeEventListener("pointercancel",c),this._domElement.removeEventListener("wheel",f,{passive:!1}),this._domElement.removeEventListener("contextmenu",d),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.ownerDocument.removeEventListener("pointerlockchange",v),this._domElement.ownerDocument.removeEventListener("pointerlockerror",_))},this.cancel=()=>{this._state!==H.NONE&&(this._state=H.NONE,this._activePointers.length=0,x())},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=et(e.width,0,1),this._interactiveArea.height=et(e.height,0,1),this._interactiveArea.x=et(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=et(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=et(e,this.minAzimuthAngle,this.maxAzimuthAngle),s=et(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||Se(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Se(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=Gt.NONE,this._changedDolly=0,this._dollyToNoClamp(et(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=Se(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||Se(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(s)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(an).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const n=!t||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(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=et(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const n=!t||Se(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(),rt.setFromMatrixColumn(this._camera.matrix,0),st.setFromMatrixColumn(this._camera.matrix,1),rt.multiplyScalar(e),st.multiplyScalar(-t);const r=ye.copy(rt).add(st),s=be.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=be.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||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(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 c=[],h=e.isBox3?Wt.copy(e):Wt.setFromObject(e);h.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const f=ni(this._sphericalEnd.theta,ei),d=ni(this._sphericalEnd.phi,ei);c.push(this.rotateTo(f,d,t));const p=ye.setFromSpherical(this._sphericalEnd).normalize(),g=li.setFromUnitVectors(p,br),x=Se(Math.abs(p.y),1);x&&g.multiply(Sr.setFromAxisAngle(Ln,f)),g.multiply(this._yAxisUpSpaceInverse);const v=ai.makeEmpty();be.copy(h.min).applyQuaternion(g),v.expandByPoint(be),be.copy(h.min).setX(h.max.x).applyQuaternion(g),v.expandByPoint(be),be.copy(h.min).setY(h.max.y).applyQuaternion(g),v.expandByPoint(be),be.copy(h.max).setZ(h.min.z).applyQuaternion(g),v.expandByPoint(be),be.copy(h.min).setZ(h.max.z).applyQuaternion(g),v.expandByPoint(be),be.copy(h.max).setY(h.min.y).applyQuaternion(g),v.expandByPoint(be),be.copy(h.max).setX(h.min.x).applyQuaternion(g),v.expandByPoint(be),be.copy(h.max).applyQuaternion(g),v.expandByPoint(be),v.min.x-=r,v.min.y-=i,v.max.x+=s,v.max.y+=a,g.setFromUnitVectors(br,p),x&&g.premultiply(Sr.invert()),g.premultiply(this._yAxisUpSpace);const _=v.getSize(ye),m=v.getCenter(be).applyQuaternion(g);if(Dt(this._camera)){const M=this.getDistanceToFitBox(_.x,_.y,_.z,n);c.push(this.moveTo(m.x,m.y,m.z,t)),c.push(this.dollyTo(M,t)),c.push(this.setFocalOffset(0,0,0,t))}else if(wt(this._camera)){const M=this._camera,b=M.right-M.left,S=M.top-M.bottom,L=n?Math.max(b/_.x,S/_.y):Math.min(b/_.x,S/_.y);c.push(this.moveTo(m.x,m.y,m.z,t)),c.push(this.zoomTo(L,t)),c.push(this.setFocalOffset(0,0,0,t))}return Promise.all(c)}fitToSphere(e,t){const n=[],s=e instanceof fe.Sphere?Mr.copy(e):Ue.createBoundingSphere(e,Mr);if(n.push(this.moveTo(s.center.x,s.center.y,s.center.z,t)),Dt(this._camera)){const i=this.getDistanceToFitSphere(s.radius);n.push(this.dollyTo(i,t))}else if(wt(this._camera)){const i=this._camera.right-this._camera.left,a=this._camera.top-this._camera.bottom,c=2*s.radius,h=Math.min(i/c,a/c);n.push(this.zoomTo(h,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=Gt.NONE,this._changedDolly=0;const c=be.set(r,s,i),h=ye.set(e,t,n);this._targetEnd.copy(c),this._sphericalEnd.setFromVector3(h.sub(c).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,a||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const f=!a||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(this._target.z,this._targetEnd.z,this.restThreshold)&&Se(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Se(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Se(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(f)}lerpLookAt(e,t,n,r,s,i,a,c,h,f,d,p,g,x=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Gt.NONE,this._changedDolly=0;const v=ye.set(r,s,i),_=be.set(e,t,n);Je.setFromVector3(_.sub(v).applyQuaternion(this._yAxisUpSpace));const m=Rt.set(f,d,p),M=be.set(a,c,h);ln.setFromVector3(M.sub(m).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(v.lerp(m,g));const b=ln.theta-Je.theta,S=ln.phi-Je.phi,L=ln.radius-Je.radius;this._sphericalEnd.set(Je.radius+L*g,Je.phi+S*g,Je.theta+b*g),this.normalizeRotations(),this._needsUpdate=!0,x||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const P=!x||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(this._target.z,this._targetEnd.z,this.restThreshold)&&Se(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Se(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Se(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(P)}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=et(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||Se(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Se(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Se(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),rt.setFromMatrixColumn(this._camera.matrixWorldInverse,0),st.setFromMatrixColumn(this._camera.matrixWorldInverse,1),kt.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const r=ye.set(e,t,n),s=r.distanceTo(this._camera.position),i=r.sub(this._camera.position);rt.multiplyScalar(i.x),st.multiplyScalar(i.y),kt.multiplyScalar(i.z),ye.copy(rt).add(st).add(kt),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 fe.Vector4,typeof e=="number"?this._viewport.set(e,t,n,r):this._viewport.copy(e)}getDistanceToFitBox(e,t,n,r=!1){if(xr(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const s=e/t,i=this._camera.getEffectiveFOV()*rn,a=this._camera.aspect;return((r?s>a:s<a)?t:e/a)*.5/Math.tan(i*.5)+n*.5}getDistanceToFitSphere(e){if(xr(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*rn,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 fe.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new fe.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e&&e instanceof fe.Spherical?e:new fe.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new fe.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%jt,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=jt),this._spherical.theta+=jt*Math.round((this._sphericalEnd.theta-this._spherical.theta)/jt)}reset(e=!1){if(!Se(this._camera.up.x,this._cameraUp0.x)||!Se(this._camera.up.y,this._cameraUp0.y)||!Se(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,Ln),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=ye.subVectors(this._target,this._camera.position).normalize(),t=be.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=ii.subVectors(this._targetEnd,this._target),i=oi.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=Tn(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=Tn(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=Tn(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;ri(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;ri(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=Tn(this._zoom,this._zoomEnd,this._zoomVelocity,d,1/0,e)}if(this.dollyToCursor){if(Dt(this._camera)&&this._changedDolly!==0){const d=this._spherical.radius-this._lastDistance,p=this._camera,g=this._getCameraDirection(an),x=ye.copy(g).cross(p.up).normalize();x.lengthSq()===0&&(x.x=1);const v=be.crossVectors(x,g),_=this._sphericalEnd.radius*Math.tan(p.getEffectiveFOV()*rn*.5),M=(this._sphericalEnd.radius-d-this._sphericalEnd.radius)/this._sphericalEnd.radius,b=Rt.copy(this._targetEnd).add(x.multiplyScalar(this._dollyControlCoord.x*_*p.aspect)).add(v.multiplyScalar(this._dollyControlCoord.y*_)),S=ye.copy(this._targetEnd).lerp(b,M),L=this._lastDollyDirection===Gt.IN&&this._spherical.radius<=this.minDistance,P=this._lastDollyDirection===Gt.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(L||P)){this._sphericalEnd.radius-=d,this._spherical.radius-=d;const y=be.copy(g).multiplyScalar(-d);S.add(y)}this._boundary.clampPoint(S,S);const T=be.subVectors(S,this._targetEnd);this._targetEnd.copy(S),this._target.add(T),this._changedDolly-=d,Ce(this._changedDolly)&&(this._changedDolly=0)}else if(wt(this._camera)&&this._changedZoom!==0){const d=this._zoom-this._lastZoom,p=this._camera,g=ye.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(p.near+p.far)/(p.near-p.far)).unproject(p),x=be.set(0,0,-1).applyQuaternion(p.quaternion),v=Rt.copy(g).add(x.multiplyScalar(-g.dot(p.up))),m=-(this._zoom-d-this._zoom)/this._zoom,M=this._getCameraDirection(an),b=this._targetEnd.dot(M),S=ye.copy(this._targetEnd).lerp(v,m),L=S.dot(M),P=M.multiplyScalar(L-b);S.sub(P),this._boundary.clampPoint(S,S);const T=be.subVectors(S,this._targetEnd);this._targetEnd.copy(S),this._target.add(T),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 c=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,c),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(),rt.setFromMatrixColumn(this._camera.matrix,0),st.setFromMatrixColumn(this._camera.matrix,1),kt.setFromMatrixColumn(this._camera.matrix,2),rt.multiplyScalar(this._focalOffset.x),st.multiplyScalar(-this._focalOffset.y),kt.multiplyScalar(this._focalOffset.z),ye.copy(rt).add(st).add(kt),this._camera.position.add(ye)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),ye.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const f=this._needsUpdate;return f&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):f?(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"}))):!f&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=f,this._needsUpdate=!1,f}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:sn(this.maxDistance),minZoom:this.minZoom,maxZoom:sn(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:sn(this.maxPolarAngle),minAzimuthAngle:sn(this.minAzimuthAngle),maxAzimuthAngle:sn(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=on(n.maxDistance),this.minZoom=n.minZoom,this.maxZoom=on(n.maxZoom),this.minPolarAngle=n.minPolarAngle,this.maxPolarAngle=on(n.maxPolarAngle),this.minAzimuthAngle=on(n.minAzimuthAngle),this.maxAzimuthAngle=on(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),Je.setFromVector3(ye.fromArray(n.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Je.theta,Je.phi,t),this.dollyTo(Je.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",Ic),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=be.copy(t).add(e),a=this._boundary.clampPoint(s,Rt).sub(s),c=a.lengthSq();if(c===0)return e.add(t);if(c===r)return e;if(n===0)return e.add(t).add(a);{const h=1+n*c/t.dot(a);return e.add(be.copy(t).multiplyScalar(h)).add(a.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(Dt(this._camera)){const e=this._camera,t=e.near,n=e.getEffectiveFOV()*rn,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(wt(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)||xr(this._camera,"_collisionTest"))return e;const n=this._getTargetDirection(an);Ar.lookAt(si,n,this._camera.up);for(let r=0;r<4;r++){const s=be.copy(this._nearPlaneCorners[r]);s.applyMatrix4(Ar);const i=Rt.addVectors(this._target,s);On.set(i,n),On.far=this._spherical.radius+1;const a=On.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 fe.Sphere){const n=t,r=n.center;Wt.makeEmpty(),e.traverseVisible(i=>{i.isMesh&&Wt.expandByObject(i)}),Wt.getCenter(r);let s=0;return e.traverseVisible(i=>{if(!i.isMesh)return;const a=i,c=a.geometry.clone();c.applyMatrix4(a.matrixWorld);const f=c.attributes.position;for(let d=0,p=f.count;d<p;d++)ye.fromBufferAttribute(f,d),s=Math.max(s,r.distanceToSquared(ye))}),n.radius=Math.sqrt(s),n}}const ci=o=>!!(o&&o.isPerspectiveCamera),ui=o=>!!(o&&o.isOrthographicCamera),Oc=["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","mouse-buttons","touches"],hi=(o,e)=>({left:Ue.ACTION.ROTATE,middle:Ue.ACTION.DOLLY,right:Ue.ACTION.TRUCK,wheel:ci(o)?Ue.ACTION.DOLLY:ui(o)?Ue.ACTION.ZOOM:Ue.ACTION.NONE,...e}),fi=(o,e)=>({one:Ue.ACTION.TOUCH_ROTATE,two:ci(o)?Ue.ACTION.TOUCH_DOLLY_TRUCK:ui(o)?Ue.ACTION.TOUCH_ZOOM_TRUCK:Ue.ACTION.NONE,three:Ue.ACTION.TOUCH_TRUCK,...e}),Dc=u.defineComponent({__name:"CameraControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},minPolarAngle:{default:0},maxPolarAngle:{default:Math.PI},minAzimuthAngle:{default:Number.NEGATIVE_INFINITY},maxAzimuthAngle:{default:Number.POSITIVE_INFINITY},distance:{default:()=>ie.useTresContext().camera.value.position.z},minDistance:{default:Number.EPSILON},maxDistance:{default:Number.POSITIVE_INFINITY},infinityDolly:{type:Boolean,default:!1},minZoom:{default:.01},maxZoom:{default:Number.POSITIVE_INFINITY},smoothTime:{default:.25},draggingSmoothTime:{default:.125},maxSpeed:{default:Number.POSITIVE_INFINITY},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:{default:()=>hi(ie.useTresContext().camera.value)},touches:{default:()=>fi(ie.useTresContext().camera.value)}},emits:["change","start","end"],setup(o,{expose:e,emit:t}){const n=o,r=t,{makeDefault:s,minPolarAngle:i,maxPolarAngle:a,minAzimuthAngle:c,maxAzimuthAngle:h,distance:f,minDistance:d,maxDistance:p,infinityDolly:g,minZoom:x,maxZoom:v,smoothTime:_,draggingSmoothTime:m,maxSpeed:M,azimuthRotateSpeed:b,polarRotateSpeed:S,dollySpeed:L,dollyDragInverted:P,truckSpeed:T,dollyToCursor:y,dragToOffset:A,verticalDragToForward:w,boundaryFriction:D,restThreshold:k,colliderMeshes:R}=u.toRefs(n),V={Box3:l.Box3,MathUtils:{clamp:l.MathUtils.clamp},Matrix4:l.Matrix4,Quaternion:l.Quaternion,Raycaster:l.Raycaster,Sphere:l.Sphere,Spherical:l.Spherical,Vector2:l.Vector2,Vector3:l.Vector3,Vector4:l.Vector4};Ue.install({THREE:V});const{camera:Y,renderer:G,extend:Q,controls:K}=ie.useTresContext(),ne=u.computed(()=>hi(n.camera||Y.value,n.mouseButtons)),ee=u.computed(()=>fi(n.camera||Y.value,n.touches)),le=u.ref(null);Q({CameraControls:Ue}),u.watchEffect(()=>{he(),le.value&&s.value?K.value=le.value:K.value=null});function he(){Ie(le.value,"update",()=>r("change",le.value)),Ie(le.value,"controlend",()=>r("end",le.value)),Ie(le.value,"controlstart",()=>r("start",le.value))}const{onLoop:de}=ie.useRenderLoop();return de(({delta:O})=>{var z,U;(z=le.value)!=null&&z.enabled&&((U=le.value)==null||U.update(O))}),u.onUnmounted(()=>{le.value&&le.value.disconnect()}),e({value:le}),(O,z)=>(O.camera||u.unref(Y))&&(O.domElement||u.unref(G))?(u.openBlock(),u.createElementBlock("TresCameraControls",{key:0,ref_key:"controlsRef",ref:le,"min-polar-angle":u.unref(i),"max-polar-angle":u.unref(a),"min-azimuth-angle":u.unref(c),"max-azimuth-angle":u.unref(h),distance:u.unref(f),"min-distance":u.unref(d),"max-distance":u.unref(p),"infinity-dolly":u.unref(g),"min-zoom":u.unref(x),"max-zoom":u.unref(v),"smooth-time":u.unref(_),"dragging-smooth-time":u.unref(m),"max-speed":u.unref(M),"azimuth-rotate-speed":u.unref(b),"polar-rotate-speed":u.unref(S),"dolly-speed":u.unref(L),"dolly-drag-inverted":u.unref(P),"truck-speed":u.unref(T),"dolly-to-cursor":u.unref(y),"drag-to-offset":u.unref(A),"vertical-drag-to-forward":u.unref(w),"boundary-friction":u.unref(D),"rest-threshold":u.unref(k),"collider-meshes":u.unref(R),args:[O.camera||u.unref(Y),O.domElement||u.unref(G).domElement],"mouse-buttons":ne.value,touches:ee.value},null,8,Oc)):u.createCommentVNode("",!0)}});class kc extends l.MeshStandardMaterial{constructor(t={}){super(t);ce(this,"_time");ce(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=`
|
|
513
|
+
*/const Le={LEFT:1,RIGHT:2,MIDDLE:4},H=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}),Et={NONE:0,IN:1,OUT:-1};function kt(o){return o.isPerspectiveCamera}function Mt(o){return o.isOrthographicCamera}const Yt=Math.PI*2,ci=Math.PI/2,ui=1e-5,sn=Math.PI/180;function tt(o,e,t){return Math.max(e,Math.min(t,o))}function Pe(o,e=ui){return Math.abs(o)<e}function Se(o,e,t=ui){return Pe(o-e,t)}function hi(o,e){return Math.round(o/e)*e}function on(o){return isFinite(o)?o:o<0?-Number.MAX_VALUE:Number.MAX_VALUE}function an(o){return Math.abs(o)<Number.MAX_VALUE?o:o*(1/0)}function Ln(o,e,t,n,r=1/0,s){n=Math.max(1e-4,n);const i=2/n,a=i*s,c=1/(1+a+.48*a*a+.235*a*a*a);let h=o-e;const d=e,f=r*n;h=tt(h,-f,f),e=o-h;const p=(t.value+i*h)*s;t.value=(t.value-i*p)*c;let m=e+(h+p)*c;return d-o>0==m>d&&(m=d,t.value=(m-d)/s),m}function fi(o,e,t,n,r=1/0,s,i){n=Math.max(1e-4,n);const a=2/n,c=a*s,h=1/(1+c+.48*c*c+.235*c*c*c);let d=e.x,f=e.y,p=e.z,m=o.x-d,_=o.y-f,v=o.z-p;const y=d,g=f,M=p,b=r*n,S=b*b,O=m*m+_*_+v*v;if(O>S){const X=Math.sqrt(O);m=m/X*b,_=_/X*b,v=v/X*b}d=o.x-m,f=o.y-_,p=o.z-v;const T=(t.x+a*m)*s,C=(t.y+a*_)*s,w=(t.z+a*v)*s;t.x=(t.x-a*T)*h,t.y=(t.y-a*C)*h,t.z=(t.z-a*w)*h,i.x=d+(m+T)*h,i.y=f+(_+C)*h,i.z=p+(v+w)*h;const A=y-o.x,x=g-o.y,D=M-o.z,L=i.x-y,V=i.y-g,R=i.z-M;return A*L+x*V+D*R>0&&(i.x=y,i.y=g,i.z=M,t.x=(i.x-y)/s,t.y=(i.y-g)/s,t.z=(i.z-M)/s),i}function br(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 Mr(o,e){return Mt(o)?(console.warn(`${e} is not supported in OrthographicCamera`),!0):!1}class cu{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)}}}var Sr;const uu="2.8.5",kn=1/8,hu=/Mac/.test((Sr=globalThis==null?void 0:globalThis.navigator)===null||Sr===void 0?void 0:Sr.platform);let de,di,Bn,Ar,Ye,ye,be,Wt,ln,st,it,Bt,pi,mi,He,cn,Xt,gi,Cr,yi,Pr,Tr,Fn;class Ne extends cu{static install(e){de=e.THREE,di=Object.freeze(new de.Vector3(0,0,0)),Bn=Object.freeze(new de.Vector3(0,1,0)),Ar=Object.freeze(new de.Vector3(0,0,1)),Ye=new de.Vector2,ye=new de.Vector3,be=new de.Vector3,Wt=new de.Vector3,ln=new de.Vector3,st=new de.Vector3,it=new de.Vector3,Bt=new de.Vector3,pi=new de.Vector3,mi=new de.Vector3,He=new de.Spherical,cn=new de.Spherical,Xt=new de.Box3,gi=new de.Box3,Cr=new de.Sphere,yi=new de.Quaternion,Pr=new de.Quaternion,Tr=new de.Matrix4,Fn=new de.Raycaster}static get ACTION(){return H}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=H.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=Et.NONE,this._thetaVelocity={value:0},this._phiVelocity={value:0},this._radiusVelocity={value:0},this._targetVelocity=new de.Vector3,this._focalOffsetVelocity=new de.Vector3,this._zoomVelocity={value:0},this._truckInternal=(g,M,b)=>{let S,O;if(kt(this._camera)){const T=ye.copy(this._camera.position).sub(this._target),C=this._camera.getEffectiveFOV()*sn,w=T.length()*Math.tan(C*.5);S=this.truckSpeed*g*w/this._elementRect.height,O=this.truckSpeed*M*w/this._elementRect.height}else if(Mt(this._camera)){const T=this._camera;S=g*(T.right-T.left)/T.zoom/this._elementRect.width,O=M*(T.top-T.bottom)/T.zoom/this._elementRect.height}else return;this.verticalDragToForward?(b?this.setFocalOffset(this._focalOffsetEnd.x+S,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(S,0,!0),this.forward(-O,!0)):b?this.setFocalOffset(this._focalOffsetEnd.x+S,this._focalOffsetEnd.y+O,this._focalOffsetEnd.z,!0):this.truck(S,O,!0)},this._rotateInternal=(g,M)=>{const b=Yt*this.azimuthRotateSpeed*g/this._elementRect.height,S=Yt*this.polarRotateSpeed*M/this._elementRect.height;this.rotate(b,S,!0)},this._dollyInternal=(g,M,b)=>{const S=Math.pow(.95,-g*this.dollySpeed),O=this._sphericalEnd.radius,T=this._sphericalEnd.radius*S,C=tt(T,this.minDistance,this.maxDistance),w=C-T;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(T,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(w,!0),this._dollyToNoClamp(C,!0)):this._dollyToNoClamp(C,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?T:C)-O,this._dollyControlCoord.set(M,b)),this._lastDollyDirection=Math.sign(-g)},this._zoomInternal=(g,M,b)=>{const S=Math.pow(.95,g*this.dollySpeed),O=this._zoom,T=this._zoom*S;this.zoomTo(T,!0),this.dollyToCursor&&(this._changedZoom+=T-O,this._dollyControlCoord.set(M,b))},typeof de>"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 de.Quaternion().setFromUnitVectors(this._camera.up,Bn),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=H.NONE,this._target=new de.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new de.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new de.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 de.Vector3,new de.Vector3,new de.Vector3,new de.Vector3],this._updateNearPlaneCorners(),this._boundary=new de.Box3(new de.Vector3(-1/0,-1/0,-1/0),new de.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 de.Vector2,this.mouseButtons={left:H.ROTATE,middle:H.DOLLY,right:H.TRUCK,wheel:kt(this._camera)?H.DOLLY:Mt(this._camera)?H.ZOOM:H.NONE},this.touches={one:H.TOUCH_ROTATE,two:kt(this._camera)?H.TOUCH_DOLLY_TRUCK:Mt(this._camera)?H.TOUCH_ZOOM_TRUCK:H.NONE,three:H.TOUCH_TRUCK};const n=new de.Vector2,r=new de.Vector2,s=new de.Vector2,i=g=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const S=this._domElement.getBoundingClientRect(),O=g.clientX/S.width,T=g.clientY/S.height;if(O<this._interactiveArea.left||O>this._interactiveArea.right||T<this._interactiveArea.top||T>this._interactiveArea.bottom)return}const M=g.pointerType!=="mouse"?null:(g.buttons&Le.LEFT)===Le.LEFT?Le.LEFT:(g.buttons&Le.MIDDLE)===Le.MIDDLE?Le.MIDDLE:(g.buttons&Le.RIGHT)===Le.RIGHT?Le.RIGHT:null;if(M!==null){const S=this._findPointerByMouseButton(M);S&&this._disposePointer(S)}if((g.buttons&Le.LEFT)===Le.LEFT&&this._lockedPointer)return;const b={pointerId:g.pointerId,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:M};this._activePointers.push(b),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",c),this._isDragging=!0,p(g)},a=g=>{g.cancelable&&g.preventDefault();const M=g.pointerId,b=this._lockedPointer||this._findPointerById(M);if(b){if(b.clientX=g.clientX,b.clientY=g.clientY,b.deltaX=g.movementX,b.deltaY=g.movementY,this._state=0,g.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&&(g.buttons&Le.LEFT)===Le.LEFT)&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&(g.buttons&Le.MIDDLE)===Le.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&(g.buttons&Le.RIGHT)===Le.RIGHT&&(this._state=this._state|this.mouseButtons.right);m()}},c=g=>{const M=this._findPointerById(g.pointerId);if(!(M&&M===this._lockedPointer)){if(M&&this._disposePointer(M),g.pointerType==="touch")switch(this._activePointers.length){case 0:this._state=H.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=H.NONE;_()}};let h=-1;const d=g=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===H.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){const T=this._domElement.getBoundingClientRect(),C=g.clientX/T.width,w=g.clientY/T.height;if(C<this._interactiveArea.left||C>this._interactiveArea.right||w<this._interactiveArea.top||w>this._interactiveArea.bottom)return}if(g.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===H.ROTATE||this.mouseButtons.wheel===H.TRUCK){const T=performance.now();h-T<1e3&&this._getClientRect(this._elementRect),h=T}const M=hu?-1:-3,b=g.deltaMode===1?g.deltaY/M:g.deltaY/(M*10),S=this.dollyToCursor?(g.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,O=this.dollyToCursor?(g.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(this.mouseButtons.wheel){case H.ROTATE:{this._rotateInternal(g.deltaX,g.deltaY),this._isUserControllingRotate=!0;break}case H.TRUCK:{this._truckInternal(g.deltaX,g.deltaY,!1),this._isUserControllingTruck=!0;break}case H.OFFSET:{this._truckInternal(g.deltaX,g.deltaY,!0),this._isUserControllingOffset=!0;break}case H.DOLLY:{this._dollyInternal(-b,S,O),this._isUserControllingDolly=!0;break}case H.ZOOM:{this._zoomInternal(-b,S,O),this._isUserControllingZoom=!0;break}}this.dispatchEvent({type:"control"})},f=g=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===Ne.ACTION.NONE){const M=g instanceof PointerEvent?g.pointerId:0,b=this._findPointerById(M);b&&this._disposePointer(b),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c);return}g.preventDefault()}},p=g=>{if(!this._enabled)return;if(br(this._activePointers,Ye),this._getClientRect(this._elementRect),n.copy(Ye),r.copy(Ye),this._activePointers.length>=2){const b=Ye.x-this._activePointers[1].clientX,S=Ye.y-this._activePointers[1].clientY,O=Math.sqrt(b*b+S*S);s.set(0,O);const T=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,C=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;r.set(T,C)}if(this._state=0,!g)this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);else if("pointerType"in g&&g.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&&(g.buttons&Le.LEFT)===Le.LEFT&&(this._state=this._state|this.mouseButtons.left),(g.buttons&Le.MIDDLE)===Le.MIDDLE&&(this._state=this._state|this.mouseButtons.middle),(g.buttons&Le.RIGHT)===Le.RIGHT&&(this._state=this._state|this.mouseButtons.right);((this._state&H.ROTATE)===H.ROTATE||(this._state&H.TOUCH_ROTATE)===H.TOUCH_ROTATE||(this._state&H.TOUCH_DOLLY_ROTATE)===H.TOUCH_DOLLY_ROTATE||(this._state&H.TOUCH_ZOOM_ROTATE)===H.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&H.TRUCK)===H.TRUCK||(this._state&H.TOUCH_TRUCK)===H.TOUCH_TRUCK||(this._state&H.TOUCH_DOLLY_TRUCK)===H.TOUCH_DOLLY_TRUCK||(this._state&H.TOUCH_ZOOM_TRUCK)===H.TOUCH_ZOOM_TRUCK)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&H.DOLLY)===H.DOLLY||(this._state&H.TOUCH_DOLLY)===H.TOUCH_DOLLY||(this._state&H.TOUCH_DOLLY_TRUCK)===H.TOUCH_DOLLY_TRUCK||(this._state&H.TOUCH_DOLLY_OFFSET)===H.TOUCH_DOLLY_OFFSET||(this._state&H.TOUCH_DOLLY_ROTATE)===H.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&H.ZOOM)===H.ZOOM||(this._state&H.TOUCH_ZOOM)===H.TOUCH_ZOOM||(this._state&H.TOUCH_ZOOM_TRUCK)===H.TOUCH_ZOOM_TRUCK||(this._state&H.TOUCH_ZOOM_OFFSET)===H.TOUCH_ZOOM_OFFSET||(this._state&H.TOUCH_ZOOM_ROTATE)===H.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&H.OFFSET)===H.OFFSET||(this._state&H.TOUCH_OFFSET)===H.TOUCH_OFFSET||(this._state&H.TOUCH_DOLLY_OFFSET)===H.TOUCH_DOLLY_OFFSET||(this._state&H.TOUCH_ZOOM_OFFSET)===H.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})},m=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,br(this._activePointers,Ye);const M=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,b=M?-M.deltaX:r.x-Ye.x,S=M?-M.deltaY:r.y-Ye.y;if(r.copy(Ye),((this._state&H.ROTATE)===H.ROTATE||(this._state&H.TOUCH_ROTATE)===H.TOUCH_ROTATE||(this._state&H.TOUCH_DOLLY_ROTATE)===H.TOUCH_DOLLY_ROTATE||(this._state&H.TOUCH_ZOOM_ROTATE)===H.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(b,S),this._isUserControllingRotate=!0),(this._state&H.DOLLY)===H.DOLLY||(this._state&H.ZOOM)===H.ZOOM){const O=this.dollyToCursor?(n.x-this._elementRect.x)/this._elementRect.width*2-1:0,T=this.dollyToCursor?(n.y-this._elementRect.y)/this._elementRect.height*-2+1:0,C=this.dollyDragInverted?-1:1;(this._state&H.DOLLY)===H.DOLLY?(this._dollyInternal(C*S*kn,O,T),this._isUserControllingDolly=!0):(this._zoomInternal(C*S*kn,O,T),this._isUserControllingZoom=!0)}if((this._state&H.TOUCH_DOLLY)===H.TOUCH_DOLLY||(this._state&H.TOUCH_ZOOM)===H.TOUCH_ZOOM||(this._state&H.TOUCH_DOLLY_TRUCK)===H.TOUCH_DOLLY_TRUCK||(this._state&H.TOUCH_ZOOM_TRUCK)===H.TOUCH_ZOOM_TRUCK||(this._state&H.TOUCH_DOLLY_OFFSET)===H.TOUCH_DOLLY_OFFSET||(this._state&H.TOUCH_ZOOM_OFFSET)===H.TOUCH_ZOOM_OFFSET||(this._state&H.TOUCH_DOLLY_ROTATE)===H.TOUCH_DOLLY_ROTATE||(this._state&H.TOUCH_ZOOM_ROTATE)===H.TOUCH_ZOOM_ROTATE){const O=Ye.x-this._activePointers[1].clientX,T=Ye.y-this._activePointers[1].clientY,C=Math.sqrt(O*O+T*T),w=s.y-C;s.set(0,C);const A=this.dollyToCursor?(r.x-this._elementRect.x)/this._elementRect.width*2-1:0,x=this.dollyToCursor?(r.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&H.TOUCH_DOLLY)===H.TOUCH_DOLLY||(this._state&H.TOUCH_DOLLY_ROTATE)===H.TOUCH_DOLLY_ROTATE||(this._state&H.TOUCH_DOLLY_TRUCK)===H.TOUCH_DOLLY_TRUCK||(this._state&H.TOUCH_DOLLY_OFFSET)===H.TOUCH_DOLLY_OFFSET?(this._dollyInternal(w*kn,A,x),this._isUserControllingDolly=!0):(this._zoomInternal(w*kn,A,x),this._isUserControllingZoom=!0)}((this._state&H.TRUCK)===H.TRUCK||(this._state&H.TOUCH_TRUCK)===H.TOUCH_TRUCK||(this._state&H.TOUCH_DOLLY_TRUCK)===H.TOUCH_DOLLY_TRUCK||(this._state&H.TOUCH_ZOOM_TRUCK)===H.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(b,S,!1),this._isUserControllingTruck=!0),((this._state&H.OFFSET)===H.OFFSET||(this._state&H.TOUCH_OFFSET)===H.TOUCH_OFFSET||(this._state&H.TOUCH_DOLLY_OFFSET)===H.TOUCH_DOLLY_OFFSET||(this._state&H.TOUCH_ZOOM_OFFSET)===H.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(b,S,!0),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},_=()=>{br(this._activePointers,Ye),r.copy(Ye),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",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),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",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",v),this._domElement.ownerDocument.addEventListener("pointerlockerror",y),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",c),p())},this.unlockPointer=()=>{var g,M,b;this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),(g=this._domElement)===null||g===void 0||g.ownerDocument.exitPointerLock(),(M=this._domElement)===null||M===void 0||M.ownerDocument.removeEventListener("pointerlockchange",v),(b=this._domElement)===null||b===void 0||b.ownerDocument.removeEventListener("pointerlockerror",y),this.cancel()};const v=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},y=()=>{this.unlockPointer()};this._addAllEventListeners=g=>{this._domElement=g,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",i),this._domElement.addEventListener("pointercancel",c),this._domElement.addEventListener("wheel",d,{passive:!1}),this._domElement.addEventListener("contextmenu",f)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",i),this._domElement.removeEventListener("pointercancel",c),this._domElement.removeEventListener("wheel",d,{passive:!1}),this._domElement.removeEventListener("contextmenu",f),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",c),this._domElement.ownerDocument.removeEventListener("pointerlockchange",v),this._domElement.ownerDocument.removeEventListener("pointerlockerror",y))},this.cancel=()=>{this._state!==H.NONE&&(this._state=H.NONE,this._activePointers.length=0,_())},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=tt(e.width,0,1),this._interactiveArea.height=tt(e.height,0,1),this._interactiveArea.x=tt(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=tt(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=tt(e,this.minAzimuthAngle,this.maxAzimuthAngle),s=tt(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||Se(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Se(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=Et.NONE,this._changedDolly=0,this._dollyToNoClamp(tt(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=Se(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||Se(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(s)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(ln).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const n=!t||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(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=tt(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const n=!t||Se(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(),st.setFromMatrixColumn(this._camera.matrix,0),it.setFromMatrixColumn(this._camera.matrix,1),st.multiplyScalar(e),it.multiplyScalar(-t);const r=ye.copy(st).add(it),s=be.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=be.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||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(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 c=[],h=e.isBox3?Xt.copy(e):Xt.setFromObject(e);h.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const d=hi(this._sphericalEnd.theta,ci),f=hi(this._sphericalEnd.phi,ci);c.push(this.rotateTo(d,f,t));const p=ye.setFromSpherical(this._sphericalEnd).normalize(),m=yi.setFromUnitVectors(p,Ar),_=Se(Math.abs(p.y),1);_&&m.multiply(Pr.setFromAxisAngle(Bn,d)),m.multiply(this._yAxisUpSpaceInverse);const v=gi.makeEmpty();be.copy(h.min).applyQuaternion(m),v.expandByPoint(be),be.copy(h.min).setX(h.max.x).applyQuaternion(m),v.expandByPoint(be),be.copy(h.min).setY(h.max.y).applyQuaternion(m),v.expandByPoint(be),be.copy(h.max).setZ(h.min.z).applyQuaternion(m),v.expandByPoint(be),be.copy(h.min).setZ(h.max.z).applyQuaternion(m),v.expandByPoint(be),be.copy(h.max).setY(h.min.y).applyQuaternion(m),v.expandByPoint(be),be.copy(h.max).setX(h.min.x).applyQuaternion(m),v.expandByPoint(be),be.copy(h.max).applyQuaternion(m),v.expandByPoint(be),v.min.x-=r,v.min.y-=i,v.max.x+=s,v.max.y+=a,m.setFromUnitVectors(Ar,p),_&&m.premultiply(Pr.invert()),m.premultiply(this._yAxisUpSpace);const y=v.getSize(ye),g=v.getCenter(be).applyQuaternion(m);if(kt(this._camera)){const M=this.getDistanceToFitBox(y.x,y.y,y.z,n);c.push(this.moveTo(g.x,g.y,g.z,t)),c.push(this.dollyTo(M,t)),c.push(this.setFocalOffset(0,0,0,t))}else if(Mt(this._camera)){const M=this._camera,b=M.right-M.left,S=M.top-M.bottom,O=n?Math.max(b/y.x,S/y.y):Math.min(b/y.x,S/y.y);c.push(this.moveTo(g.x,g.y,g.z,t)),c.push(this.zoomTo(O,t)),c.push(this.setFocalOffset(0,0,0,t))}return Promise.all(c)}fitToSphere(e,t){const n=[],s="isObject3D"in e?Ne.createBoundingSphere(e,Cr):Cr.copy(e);if(n.push(this.moveTo(s.center.x,s.center.y,s.center.z,t)),kt(this._camera)){const i=this.getDistanceToFitSphere(s.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,c=2*s.radius,h=Math.min(i/c,a/c);n.push(this.zoomTo(h,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=Et.NONE,this._changedDolly=0;const c=be.set(r,s,i),h=ye.set(e,t,n);this._targetEnd.copy(c),this._sphericalEnd.setFromVector3(h.sub(c).applyQuaternion(this._yAxisUpSpace)),this.normalizeRotations(),this._needsUpdate=!0,a||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const d=!a||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(this._target.z,this._targetEnd.z,this.restThreshold)&&Se(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Se(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Se(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(d)}lerpLookAt(e,t,n,r,s,i,a,c,h,d,f,p,m,_=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=Et.NONE,this._changedDolly=0;const v=ye.set(r,s,i),y=be.set(e,t,n);He.setFromVector3(y.sub(v).applyQuaternion(this._yAxisUpSpace));const g=Wt.set(d,f,p),M=be.set(a,c,h);cn.setFromVector3(M.sub(g).applyQuaternion(this._yAxisUpSpace)),this._targetEnd.copy(v.lerp(g,m));const b=cn.theta-He.theta,S=cn.phi-He.phi,O=cn.radius-He.radius;this._sphericalEnd.set(He.radius+O*m,He.phi+S*m,He.theta+b*m),this.normalizeRotations(),this._needsUpdate=!0,_||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const T=!_||Se(this._target.x,this._targetEnd.x,this.restThreshold)&&Se(this._target.y,this._targetEnd.y,this.restThreshold)&&Se(this._target.z,this._targetEnd.z,this.restThreshold)&&Se(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Se(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Se(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(T)}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=tt(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||Se(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Se(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Se(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(s)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),st.setFromMatrixColumn(this._camera.matrixWorldInverse,0),it.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Bt.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const r=ye.set(e,t,n),s=r.distanceTo(this._camera.position),i=r.sub(this._camera.position);st.multiplyScalar(i.x),it.multiplyScalar(i.y),Bt.multiplyScalar(i.z),ye.copy(st).add(it).add(Bt),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 de.Vector4,typeof e=="number"?this._viewport.set(e,t,n,r):this._viewport.copy(e)}getDistanceToFitBox(e,t,n,r=!1){if(Mr(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const s=e/t,i=this._camera.getEffectiveFOV()*sn,a=this._camera.aspect;return((r?s>a:s<a)?t:e/a)*.5/Math.tan(i*.5)+n*.5}getDistanceToFitSphere(e){if(Mr(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*sn,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 de.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new de.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new de.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new de.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){this._sphericalEnd.theta=this._sphericalEnd.theta%Yt,this._sphericalEnd.theta<0&&(this._sphericalEnd.theta+=Yt),this._spherical.theta+=Yt*Math.round((this._sphericalEnd.theta-this._spherical.theta)/Yt)}reset(e=!1){if(!Se(this._camera.up.x,this._cameraUp0.x)||!Se(this._camera.up.y,this._cameraUp0.y)||!Se(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,Bn),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=ye.subVectors(this._target,this._camera.position).normalize(),t=be.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=pi.subVectors(this._targetEnd,this._target),i=mi.subVectors(this._focalOffsetEnd,this._focalOffset),a=this._zoomEnd-this._zoom;if(Pe(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{const f=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Ln(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,f,1/0,e),this._needsUpdate=!0}if(Pe(n))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{const f=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Ln(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,f,1/0,e),this._needsUpdate=!0}if(Pe(r))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{const f=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Ln(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,f,this.maxSpeed,e),this._needsUpdate=!0}if(Pe(s.x)&&Pe(s.y)&&Pe(s.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{const f=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;fi(this._target,this._targetEnd,this._targetVelocity,f,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(Pe(i.x)&&Pe(i.y)&&Pe(i.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{const f=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;fi(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,f,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(Pe(a))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{const f=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Ln(this._zoom,this._zoomEnd,this._zoomVelocity,f,1/0,e)}if(this.dollyToCursor){if(kt(this._camera)&&this._changedDolly!==0){const f=this._spherical.radius-this._lastDistance,p=this._camera,m=this._getCameraDirection(ln),_=ye.copy(m).cross(p.up).normalize();_.lengthSq()===0&&(_.x=1);const v=be.crossVectors(_,m),y=this._sphericalEnd.radius*Math.tan(p.getEffectiveFOV()*sn*.5),M=(this._sphericalEnd.radius-f-this._sphericalEnd.radius)/this._sphericalEnd.radius,b=Wt.copy(this._targetEnd).add(_.multiplyScalar(this._dollyControlCoord.x*y*p.aspect)).add(v.multiplyScalar(this._dollyControlCoord.y*y)),S=ye.copy(this._targetEnd).lerp(b,M),O=this._lastDollyDirection===Et.IN&&this._spherical.radius<=this.minDistance,T=this._lastDollyDirection===Et.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(O||T)){this._sphericalEnd.radius-=f,this._spherical.radius-=f;const w=be.copy(m).multiplyScalar(-f);S.add(w)}this._boundary.clampPoint(S,S);const C=be.subVectors(S,this._targetEnd);this._targetEnd.copy(S),this._target.add(C),this._changedDolly-=f,Pe(this._changedDolly)&&(this._changedDolly=0)}else if(Mt(this._camera)&&this._changedZoom!==0){const f=this._zoom-this._lastZoom,p=this._camera,m=ye.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(p.near+p.far)/(p.near-p.far)).unproject(p),_=be.set(0,0,-1).applyQuaternion(p.quaternion),v=Wt.copy(m).add(_.multiplyScalar(-m.dot(p.up))),g=-(this._zoom-f-this._zoom)/this._zoom,M=this._getCameraDirection(ln),b=this._targetEnd.dot(M),S=ye.copy(this._targetEnd).lerp(v,g),O=S.dot(M),T=M.multiplyScalar(O-b);S.sub(T),this._boundary.clampPoint(S,S);const C=be.subVectors(S,this._targetEnd);this._targetEnd.copy(S),this._target.add(C),this._changedZoom-=f,Pe(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 c=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,c),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!Pe(this._focalOffset.x)||!Pe(this._focalOffset.y)||!Pe(this._focalOffset.z))&&(this._camera.updateMatrixWorld(),st.setFromMatrixColumn(this._camera.matrix,0),it.setFromMatrixColumn(this._camera.matrix,1),Bt.setFromMatrixColumn(this._camera.matrix,2),st.multiplyScalar(this._focalOffset.x),it.multiplyScalar(-this._focalOffset.y),Bt.multiplyScalar(this._focalOffset.z),ye.copy(st).add(it).add(Bt),this._camera.position.add(ye)),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),ye.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const d=this._needsUpdate;return d&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):d?(this.dispatchEvent({type:"update"}),Pe(t,this.restThreshold)&&Pe(n,this.restThreshold)&&Pe(r,this.restThreshold)&&Pe(s.x,this.restThreshold)&&Pe(s.y,this.restThreshold)&&Pe(s.z,this.restThreshold)&&Pe(i.x,this.restThreshold)&&Pe(i.y,this.restThreshold)&&Pe(i.z,this.restThreshold)&&Pe(a,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!d&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=d,this._needsUpdate=!1,d}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:on(this.maxDistance),minZoom:this.minZoom,maxZoom:on(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:on(this.maxPolarAngle),minAzimuthAngle:on(this.minAzimuthAngle),maxAzimuthAngle:on(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=an(n.maxDistance),this.minZoom=n.minZoom,this.maxZoom=an(n.maxZoom),this.minPolarAngle=n.minPolarAngle,this.maxPolarAngle=an(n.maxPolarAngle),this.minAzimuthAngle=an(n.minAzimuthAngle),this.maxAzimuthAngle=an(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),He.setFromVector3(ye.fromArray(n.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(He.theta,He.phi,t),this.dollyTo(He.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",uu),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=be.copy(t).add(e),a=this._boundary.clampPoint(s,Wt).sub(s),c=a.lengthSq();if(c===0)return e.add(t);if(c===r)return e;if(n===0)return e.add(t).add(a);{const h=1+n*c/t.dot(a);return e.add(be.copy(t).multiplyScalar(h)).add(a.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(kt(this._camera)){const e=this._camera,t=e.near,n=e.getEffectiveFOV()*sn,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(Mt(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)||Mr(this._camera,"_collisionTest"))return e;const n=this._getTargetDirection(ln);Tr.lookAt(di,n,this._camera.up);for(let r=0;r<4;r++){const s=be.copy(this._nearPlaneCorners[r]);s.applyMatrix4(Tr);const i=Wt.addVectors(this._target,s);Fn.set(i,n),Fn.far=this._spherical.radius+1;const a=Fn.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 de.Sphere){const n=t,r=n.center;Xt.makeEmpty(),e.traverseVisible(i=>{i.isMesh&&Xt.expandByObject(i)}),Xt.getCenter(r);let s=0;return e.traverseVisible(i=>{if(!i.isMesh)return;const a=i,c=a.geometry.clone();c.applyMatrix4(a.matrixWorld);const d=c.attributes.position;for(let f=0,p=d.count;f<p;f++)ye.fromBufferAttribute(d,f),s=Math.max(s,r.distanceToSquared(ye))}),n.radius=Math.sqrt(s),n}}const _i=o=>!!(o&&o.isPerspectiveCamera),vi=o=>!!(o&&o.isOrthographicCamera),fu=["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","mouse-buttons","touches"],xi=(o,e)=>({left:Ne.ACTION.ROTATE,middle:Ne.ACTION.DOLLY,right:Ne.ACTION.TRUCK,wheel:_i(o)?Ne.ACTION.DOLLY:vi(o)?Ne.ACTION.ZOOM:Ne.ACTION.NONE,...e}),wi=(o,e)=>({one:Ne.ACTION.TOUCH_ROTATE,two:_i(o)?Ne.ACTION.TOUCH_DOLLY_TRUCK:vi(o)?Ne.ACTION.TOUCH_ZOOM_TRUCK:Ne.ACTION.NONE,three:Ne.ACTION.TOUCH_TRUCK,...e}),du=u.defineComponent({__name:"CameraControls",props:{makeDefault:{type:Boolean,default:!1},camera:{},domElement:{},minPolarAngle:{default:0},maxPolarAngle:{default:Math.PI},minAzimuthAngle:{default:Number.NEGATIVE_INFINITY},maxAzimuthAngle:{default:Number.POSITIVE_INFINITY},distance:{default:()=>te.useTresContext().camera.value.position.z},minDistance:{default:Number.EPSILON},maxDistance:{default:Number.POSITIVE_INFINITY},infinityDolly:{type:Boolean,default:!1},minZoom:{default:.01},maxZoom:{default:Number.POSITIVE_INFINITY},smoothTime:{default:.25},draggingSmoothTime:{default:.125},maxSpeed:{default:Number.POSITIVE_INFINITY},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:{default:()=>xi(te.useTresContext().camera.value)},touches:{default:()=>wi(te.useTresContext().camera.value)}},emits:["change","start","end"],setup(o,{expose:e,emit:t}){const n=o,r=t,{makeDefault:s,minPolarAngle:i,maxPolarAngle:a,minAzimuthAngle:c,maxAzimuthAngle:h,distance:d,minDistance:f,maxDistance:p,infinityDolly:m,minZoom:_,maxZoom:v,smoothTime:y,draggingSmoothTime:g,maxSpeed:M,azimuthRotateSpeed:b,polarRotateSpeed:S,dollySpeed:O,dollyDragInverted:T,truckSpeed:C,dollyToCursor:w,dragToOffset:A,verticalDragToForward:x,boundaryFriction:D,restThreshold:L,colliderMeshes:V}=u.toRefs(n),{invalidateOnDemand:R}=Ie(n),X={Box3:l.Box3,MathUtils:{clamp:l.MathUtils.clamp},Matrix4:l.Matrix4,Quaternion:l.Quaternion,Raycaster:l.Raycaster,Sphere:l.Sphere,Spherical:l.Spherical,Vector2:l.Vector2,Vector3:l.Vector3,Vector4:l.Vector4};Ne.install({THREE:X});const{camera:Y,renderer:J,extend:q,controls:re}=te.useTresContext(),ee=u.computed(()=>xi(n.camera||Y.value,n.mouseButtons)),ce=u.computed(()=>wi(n.camera||Y.value,n.touches)),le=u.ref(null);q({CameraControls:Ne}),u.watchEffect(()=>{me(),le.value&&s.value?re.value=le.value:re.value=null});function me(){Ce(le.value,"update",()=>{r("change",le.value),R()}),Ce(le.value,"controlend",()=>r("end",le.value)),Ce(le.value,"controlstart",()=>r("start",le.value))}const{onBeforeRender:k}=te.useLoop();return k(({delta:z})=>{var F,B;(F=le.value)!=null&&F.enabled&&((B=le.value)==null||B.update(z))}),u.onUnmounted(()=>{le.value&&le.value.disconnect()}),e({instance:le}),(z,F)=>(z.camera||u.unref(Y))&&(z.domElement||u.unref(J))?(u.openBlock(),u.createElementBlock("TresCameraControls",{key:0,ref_key:"controlsRef",ref:le,"min-polar-angle":u.unref(i),"max-polar-angle":u.unref(a),"min-azimuth-angle":u.unref(c),"max-azimuth-angle":u.unref(h),distance:u.unref(d),"min-distance":u.unref(f),"max-distance":u.unref(p),"infinity-dolly":u.unref(m),"min-zoom":u.unref(_),"max-zoom":u.unref(v),"smooth-time":u.unref(y),"dragging-smooth-time":u.unref(g),"max-speed":u.unref(M),"azimuth-rotate-speed":u.unref(b),"polar-rotate-speed":u.unref(S),"dolly-speed":u.unref(O),"dolly-drag-inverted":u.unref(T),"truck-speed":u.unref(C),"dolly-to-cursor":u.unref(w),"drag-to-offset":u.unref(A),"vertical-drag-to-forward":u.unref(x),"boundary-friction":u.unref(D),"rest-threshold":u.unref(L),"collider-meshes":u.unref(V),args:[z.camera||u.unref(Y),z.domElement||u.unref(J).domElement],"mouse-buttons":ee.value,touches:ce.value},null,8,fu)):u.createCommentVNode("",!0)}});class pu extends l.MeshStandardMaterial{constructor(t={}){super(t);ue(this,"_time");ue(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
514
|
uniform float time;
|
|
254
515
|
uniform float factor;
|
|
255
516
|
${t.vertexShader}
|
|
@@ -258,68 +519,68 @@
|
|
|
258
519
|
float s = sin( theta );
|
|
259
520
|
mat3 m = mat3( c, 0, s, 0, 1, 0, -s, 0, c );
|
|
260
521
|
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 Bc=["factor"],Fc=u.defineComponent({__name:"index",props:{speed:{default:1},factor:{default:1}},setup(o){const e=o,t=u.shallowRef(),{extend:n}=ie.useTresContext();n({MeshWobbleMaterial:kc});const{onLoop:r}=ie.useRenderLoop();return r(({elapsed:s})=>{t.value&&(t.value.time=s*(e==null?void 0:e.speed))}),(s,i)=>(u.openBlock(),u.createElementBlock("TresMeshWobbleMaterial",u.mergeProps({ref_key:"materialRef",ref:t,factor:s.factor},s.$attrs),null,16,Bc))}});function bt(o,e,t){return Math.max(e,Math.min(t,o))}function Uc(o,e){return(o%e+e)%e}function Nc(o,e,t,n,r){return n+(o-e)*(r-n)/(t-e)}function Cr(o,e,t){return(1-t)*o+t*e}class Pr{constructor(e=0,t=0){Pr.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(bt(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 Vc="",Mt="srgb",Tr="srgb-linear",zc="display-p3",di="display-p3-linear",Ir="linear",pi="srgb",mi="rec709",gi="p3";class cn{constructor(e,t,n,r,s,i,a,c,h){cn.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,c,h)}set(e,t,n,r,s,i,a,c,h){const f=this.elements;return f[0]=e,f[1]=r,f[2]=a,f[3]=t,f[4]=s,f[5]=c,f[6]=n,f[7]=i,f[8]=h,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],c=n[6],h=n[1],f=n[4],d=n[7],p=n[2],g=n[5],x=n[8],v=r[0],_=r[3],m=r[6],M=r[1],b=r[4],S=r[7],L=r[2],P=r[5],T=r[8];return s[0]=i*v+a*M+c*L,s[3]=i*_+a*b+c*P,s[6]=i*m+a*S+c*T,s[1]=h*v+f*M+d*L,s[4]=h*_+f*b+d*P,s[7]=h*m+f*S+d*T,s[2]=p*v+g*M+x*L,s[5]=p*_+g*b+x*P,s[8]=p*m+g*S+x*T,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],c=e[6],h=e[7],f=e[8];return t*i*f-t*a*h-n*s*f+n*a*c+r*s*h-r*i*c}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],i=e[4],a=e[5],c=e[6],h=e[7],f=e[8],d=f*i-a*h,p=a*c-f*s,g=h*s-i*c,x=t*d+n*p+r*g;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/x;return e[0]=d*v,e[1]=(r*h-f*n)*v,e[2]=(a*n-r*i)*v,e[3]=p*v,e[4]=(f*t-r*c)*v,e[5]=(r*s-a*t)*v,e[6]=g*v,e[7]=(n*c-h*t)*v,e[8]=(i*t-n*s)*v,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 c=Math.cos(s),h=Math.sin(s);return this.set(n*c,n*h,-n*(c*i+h*a)+i+e,-r*h,r*c,-r*(-h*i+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(Lr.makeScale(e,t)),this}rotate(e){return this.premultiply(Lr.makeRotation(-e)),this}translate(e,t){return this.premultiply(Lr.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 Lr=new cn,yi=new cn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),vi=new cn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Dn={[Tr]:{transfer:Ir,primaries:mi,toReference:o=>o,fromReference:o=>o},[Mt]:{transfer:pi,primaries:mi,toReference:o=>o.convertSRGBToLinear(),fromReference:o=>o.convertLinearToSRGB()},[di]:{transfer:Ir,primaries:gi,toReference:o=>o.applyMatrix3(vi),fromReference:o=>o.applyMatrix3(yi)},[zc]:{transfer:pi,primaries:gi,toReference:o=>o.convertSRGBToLinear().applyMatrix3(vi),fromReference:o=>o.applyMatrix3(yi).convertLinearToSRGB()}},Gc=new Set([Tr,di]),tt={enabled:!0,_workingColorSpace:Tr,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(o){if(!Gc.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=Dn[e].toReference,r=Dn[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 Dn[o].primaries},getTransfer:function(o){return o===Vc?Ir:Dn[o].transfer}};function Or(o){return o<.04045?o*.0773993808:Math.pow(o*.9478672986+.0521327014,2.4)}function Dr(o){return o<.0031308?o*12.92:1.055*Math.pow(o,.41666)-.055}const _i={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},St={h:0,s:0,l:0},kn={h:0,s:0,l:0};function kr(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 Bn{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=Mt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,tt.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=tt.workingColorSpace){return this.r=e,this.g=t,this.b=n,tt.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=tt.workingColorSpace){if(e=Uc(e,1),t=bt(t,0,1),n=bt(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=kr(i,s,e+1/3),this.g=kr(i,s,e),this.b=kr(i,s,e-1/3)}return tt.toWorkingColorSpace(this,r),this}setStyle(e,t=Mt){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=Mt){const n=_i[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=Or(e.r),this.g=Or(e.g),this.b=Or(e.b),this}copyLinearToSRGB(e){return this.r=Dr(e.r),this.g=Dr(e.g),this.b=Dr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Mt){return tt.fromWorkingColorSpace(Ge.copy(this),e),Math.round(bt(Ge.r*255,0,255))*65536+Math.round(bt(Ge.g*255,0,255))*256+Math.round(bt(Ge.b*255,0,255))}getHexString(e=Mt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=tt.workingColorSpace){tt.fromWorkingColorSpace(Ge.copy(this),t);const n=Ge.r,r=Ge.g,s=Ge.b,i=Math.max(n,r,s),a=Math.min(n,r,s);let c,h;const f=(a+i)/2;if(a===i)c=0,h=0;else{const d=i-a;switch(h=f<=.5?d/(i+a):d/(2-i-a),i){case n:c=(r-s)/d+(r<s?6:0);break;case r:c=(s-n)/d+2;break;case s:c=(n-r)/d+4;break}c/=6}return e.h=c,e.s=h,e.l=f,e}getRGB(e,t=tt.workingColorSpace){return tt.fromWorkingColorSpace(Ge.copy(this),t),e.r=Ge.r,e.g=Ge.g,e.b=Ge.b,e}getStyle(e=Mt){tt.fromWorkingColorSpace(Ge.copy(this),e);const t=Ge.r,n=Ge.g,r=Ge.b;return e!==Mt?`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(St),this.setHSL(St.h+e,St.s+t,St.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(St),e.getHSL(kn);const n=Cr(St.h,kn.h,t),r=Cr(St.s,kn.s,t),s=Cr(St.l,kn.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 Ge=new Bn;Bn.NAMES=_i;class jc extends l.MeshStandardMaterial{constructor(t={}){super();ce(this,"isMeshPhysicalMaterial");ce(this,"clearcoatMap");ce(this,"clearcoatRoughness");ce(this,"clearcoatRoughnessMap");ce(this,"clearcoatNormalScale");ce(this,"clearcoatNormalMap");ce(this,"ior");ce(this,"transmissionMap");ce(this,"thickness");ce(this,"thicknessMap");ce(this,"attenuationDistance");ce(this,"attenuationColor");ce(this,"specularIntensity");ce(this,"specularIntensityMap");ce(this,"specularColor");ce(this,"specularColorMap");ce(this,"_clearcoat");ce(this,"_transmission");this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Pr(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get(){return bt(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=Number.POSITIVE_INFINITY,this.attenuationColor=new Bn(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Bn(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 Rc=u.defineComponent({__name:"index",setup(o,{expose:e}){const t=u.shallowRef(),{extend:n}=ie.useTresContext();return n({MeshGlassMaterial:jc}),e({MeshGlassMaterialClass:t}),(r,s)=>(u.openBlock(),u.createElementBlock("TresMeshGlassMaterial",{ref_key:"MeshGlassMaterialClass",ref:t},null,512))}});var Wc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function un(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function Fn(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 xi={exports:{}};(function(o,e){(function(t){o.exports=t()})(function(){return function t(n,r,s){function i(h,f){if(!r[h]){if(!n[h]){var d=typeof Fn=="function"&&Fn;if(!f&&d)return d(h,!0);if(a)return a(h,!0);throw new Error("Cannot find module '"+h+"'")}f=r[h]={exports:{}},n[h][0].call(f.exports,function(p){var g=n[h][1][p];return i(g||p)},f,f.exports,t,n,r,s)}return r[h].exports}for(var a=typeof Fn=="function"&&Fn,c=0;c<s.length;c++)i(s[c]);return i}({1:[function(t,n,r){(function(s,i,a,c,h,f,d,p,g){var x=t("crypto");function v(P,T){T=M(P,T);var y;return(y=T.algorithm!=="passthrough"?x.createHash(T.algorithm):new L).write===void 0&&(y.write=y.update,y.end=y.update),S(T,y).dispatch(P),y.update||y.end(""),y.digest?y.digest(T.encoding==="buffer"?void 0:T.encoding):(P=y.read(),T.encoding!=="buffer"?P.toString(T.encoding):P)}(r=n.exports=v).sha1=function(P){return v(P)},r.keys=function(P){return v(P,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},r.MD5=function(P){return v(P,{algorithm:"md5",encoding:"hex"})},r.keysMD5=function(P){return v(P,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var _=x.getHashes?x.getHashes().slice():["sha1","md5"],m=(_.push("passthrough"),["buffer","hex","binary","base64"]);function M(P,T){var y={};if(y.algorithm=(T=T||{}).algorithm||"sha1",y.encoding=T.encoding||"hex",y.excludeValues=!!T.excludeValues,y.algorithm=y.algorithm.toLowerCase(),y.encoding=y.encoding.toLowerCase(),y.ignoreUnknown=T.ignoreUnknown===!0,y.respectType=T.respectType!==!1,y.respectFunctionNames=T.respectFunctionNames!==!1,y.respectFunctionProperties=T.respectFunctionProperties!==!1,y.unorderedArrays=T.unorderedArrays===!0,y.unorderedSets=T.unorderedSets!==!1,y.unorderedObjects=T.unorderedObjects!==!1,y.replacer=T.replacer||void 0,y.excludeKeys=T.excludeKeys||void 0,P===void 0)throw new Error("Object argument required.");for(var A=0;A<_.length;++A)_[A].toLowerCase()===y.algorithm.toLowerCase()&&(y.algorithm=_[A]);if(_.indexOf(y.algorithm)===-1)throw new Error('Algorithm "'+y.algorithm+'" not supported. supported values: '+_.join(", "));if(m.indexOf(y.encoding)===-1&&y.algorithm!=="passthrough")throw new Error('Encoding "'+y.encoding+'" not supported. supported values: '+m.join(", "));return y}function b(P){if(typeof P=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(P))!=null}function S(P,T,y){y=y||[];function A(w){return T.update?T.update(w,"utf8"):T.write(w,"utf8")}return{dispatch:function(w){return this["_"+((w=P.replacer?P.replacer(w):w)===null?"null":typeof w)](w)},_object:function(w){var D,k=Object.prototype.toString.call(w),R=/\[object (.*)\]/i.exec(k);if(R=(R=R?R[1]:"unknown:["+k+"]").toLowerCase(),0<=(k=y.indexOf(w)))return this.dispatch("[CIRCULAR:"+k+"]");if(y.push(w),a!==void 0&&a.isBuffer&&a.isBuffer(w))return A("buffer:"),A(w);if(R==="object"||R==="function"||R==="asyncfunction")return k=Object.keys(w),P.unorderedObjects&&(k=k.sort()),P.respectType===!1||b(w)||k.splice(0,0,"prototype","__proto__","constructor"),P.excludeKeys&&(k=k.filter(function(V){return!P.excludeKeys(V)})),A("object:"+k.length+":"),D=this,k.forEach(function(V){D.dispatch(V),A(":"),P.excludeValues||D.dispatch(w[V]),A(",")});if(!this["_"+R]){if(P.ignoreUnknown)return A("["+R+"]");throw new Error('Unknown object type "'+R+'"')}this["_"+R](w)},_array:function(w,V){V=V!==void 0?V:P.unorderedArrays!==!1;var k=this;if(A("array:"+w.length+":"),!V||w.length<=1)return w.forEach(function(Y){return k.dispatch(Y)});var R=[],V=w.map(function(Y){var G=new L,Q=y.slice();return S(P,G,Q).dispatch(Y),R=R.concat(Q.slice(y.length)),G.read().toString()});return y=y.concat(R),V.sort(),this._array(V,!1)},_date:function(w){return A("date:"+w.toJSON())},_symbol:function(w){return A("symbol:"+w.toString())},_error:function(w){return A("error:"+w.toString())},_boolean:function(w){return A("bool:"+w.toString())},_string:function(w){A("string:"+w.length+":"),A(w.toString())},_function:function(w){A("fn:"),b(w)?this.dispatch("[native]"):this.dispatch(w.toString()),P.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(w.name)),P.respectFunctionProperties&&this._object(w)},_number:function(w){return A("number:"+w.toString())},_xml:function(w){return A("xml:"+w.toString())},_null:function(){return A("Null")},_undefined:function(){return A("Undefined")},_regexp:function(w){return A("regex:"+w.toString())},_uint8array:function(w){return A("uint8array:"),this.dispatch(Array.prototype.slice.call(w))},_uint8clampedarray:function(w){return A("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(w))},_int8array:function(w){return A("int8array:"),this.dispatch(Array.prototype.slice.call(w))},_uint16array:function(w){return A("uint16array:"),this.dispatch(Array.prototype.slice.call(w))},_int16array:function(w){return A("int16array:"),this.dispatch(Array.prototype.slice.call(w))},_uint32array:function(w){return A("uint32array:"),this.dispatch(Array.prototype.slice.call(w))},_int32array:function(w){return A("int32array:"),this.dispatch(Array.prototype.slice.call(w))},_float32array:function(w){return A("float32array:"),this.dispatch(Array.prototype.slice.call(w))},_float64array:function(w){return A("float64array:"),this.dispatch(Array.prototype.slice.call(w))},_arraybuffer:function(w){return A("arraybuffer:"),this.dispatch(new Uint8Array(w))},_url:function(w){return A("url:"+w.toString())},_map:function(w){return A("map:"),w=Array.from(w),this._array(w,P.unorderedSets!==!1)},_set:function(w){return A("set:"),w=Array.from(w),this._array(w,P.unorderedSets!==!1)},_file:function(w){return A("file:"),this.dispatch([w.name,w.size,w.type,w.lastModfied])},_blob:function(){if(P.ignoreUnknown)return A("[blob]");throw Error(`Hashing Blob objects is currently not supported
|
|
522
|
+
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 mu=["factor"],gu=u.defineComponent({__name:"index",props:{speed:{default:1},factor:{default:1}},setup(o,{expose:e}){const t=o,{invalidateOnDemand:n}=Ie(t),r=u.shallowRef(),{extend:s}=te.useTresContext();s({MeshWobbleMaterial:pu});const{onBeforeRender:i}=te.useLoop();return i(({elapsed:a})=>{r.value&&(r.value.time=a*(t==null?void 0:t.speed),n())}),e({instance:r}),(a,c)=>(u.openBlock(),u.createElementBlock("TresMeshWobbleMaterial",u.mergeProps({ref_key:"materialRef",ref:r,factor:a.factor},a.$attrs),null,16,mu))}});function St(o,e,t){return Math.max(e,Math.min(t,o))}function yu(o,e){return(o%e+e)%e}function _u(o,e,t,n,r){return n+(o-e)*(r-n)/(t-e)}function Ir(o,e,t){return(1-t)*o+t*e}class Or{constructor(e=0,t=0){Or.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(St(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 vu="",At="srgb",Dr="srgb-linear",xu="display-p3",bi="display-p3-linear",Lr="linear",Mi="srgb",Si="rec709",Ai="p3";class un{constructor(e,t,n,r,s,i,a,c,h){un.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,c,h)}set(e,t,n,r,s,i,a,c,h){const d=this.elements;return d[0]=e,d[1]=r,d[2]=a,d[3]=t,d[4]=s,d[5]=c,d[6]=n,d[7]=i,d[8]=h,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],c=n[6],h=n[1],d=n[4],f=n[7],p=n[2],m=n[5],_=n[8],v=r[0],y=r[3],g=r[6],M=r[1],b=r[4],S=r[7],O=r[2],T=r[5],C=r[8];return s[0]=i*v+a*M+c*O,s[3]=i*y+a*b+c*T,s[6]=i*g+a*S+c*C,s[1]=h*v+d*M+f*O,s[4]=h*y+d*b+f*T,s[7]=h*g+d*S+f*C,s[2]=p*v+m*M+_*O,s[5]=p*y+m*b+_*T,s[8]=p*g+m*S+_*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],c=e[6],h=e[7],d=e[8];return t*i*d-t*a*h-n*s*d+n*a*c+r*s*h-r*i*c}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],s=e[3],i=e[4],a=e[5],c=e[6],h=e[7],d=e[8],f=d*i-a*h,p=a*c-d*s,m=h*s-i*c,_=t*f+n*p+r*m;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/_;return e[0]=f*v,e[1]=(r*h-d*n)*v,e[2]=(a*n-r*i)*v,e[3]=p*v,e[4]=(d*t-r*c)*v,e[5]=(r*s-a*t)*v,e[6]=m*v,e[7]=(n*c-h*t)*v,e[8]=(i*t-n*s)*v,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 c=Math.cos(s),h=Math.sin(s);return this.set(n*c,n*h,-n*(c*i+h*a)+i+e,-r*h,r*c,-r*(-h*i+c*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(kr.makeScale(e,t)),this}rotate(e){return this.premultiply(kr.makeRotation(-e)),this}translate(e,t){return this.premultiply(kr.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 kr=new un,Ci=new un().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Pi=new un().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),Un={[Dr]:{transfer:Lr,primaries:Si,toReference:o=>o,fromReference:o=>o},[At]:{transfer:Mi,primaries:Si,toReference:o=>o.convertSRGBToLinear(),fromReference:o=>o.convertLinearToSRGB()},[bi]:{transfer:Lr,primaries:Ai,toReference:o=>o.applyMatrix3(Pi),fromReference:o=>o.applyMatrix3(Ci)},[xu]:{transfer:Mi,primaries:Ai,toReference:o=>o.convertSRGBToLinear().applyMatrix3(Pi),fromReference:o=>o.applyMatrix3(Ci).convertLinearToSRGB()}},wu=new Set([Dr,bi]),nt={enabled:!0,_workingColorSpace:Dr,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(o){if(!wu.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=Un[e].toReference,r=Un[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 Un[o].primaries},getTransfer:function(o){return o===vu?Lr:Un[o].transfer}};function Br(o){return o<.04045?o*.0773993808:Math.pow(o*.9478672986+.0521327014,2.4)}function Fr(o){return o<.0031308?o*12.92:1.055*Math.pow(o,.41666)-.055}const Ti={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},Ct={h:0,s:0,l:0},Nn={h:0,s:0,l:0};function Ur(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 zn{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=At){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,nt.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=nt.workingColorSpace){return this.r=e,this.g=t,this.b=n,nt.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=nt.workingColorSpace){if(e=yu(e,1),t=St(t,0,1),n=St(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=Ur(i,s,e+1/3),this.g=Ur(i,s,e),this.b=Ur(i,s,e-1/3)}return nt.toWorkingColorSpace(this,r),this}setStyle(e,t=At){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=At){const n=Ti[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=Br(e.r),this.g=Br(e.g),this.b=Br(e.b),this}copyLinearToSRGB(e){return this.r=Fr(e.r),this.g=Fr(e.g),this.b=Fr(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=At){return nt.fromWorkingColorSpace(Ge.copy(this),e),Math.round(St(Ge.r*255,0,255))*65536+Math.round(St(Ge.g*255,0,255))*256+Math.round(St(Ge.b*255,0,255))}getHexString(e=At){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=nt.workingColorSpace){nt.fromWorkingColorSpace(Ge.copy(this),t);const n=Ge.r,r=Ge.g,s=Ge.b,i=Math.max(n,r,s),a=Math.min(n,r,s);let c,h;const d=(a+i)/2;if(a===i)c=0,h=0;else{const f=i-a;switch(h=d<=.5?f/(i+a):f/(2-i-a),i){case n:c=(r-s)/f+(r<s?6:0);break;case r:c=(s-n)/f+2;break;case s:c=(n-r)/f+4;break}c/=6}return e.h=c,e.s=h,e.l=d,e}getRGB(e,t=nt.workingColorSpace){return nt.fromWorkingColorSpace(Ge.copy(this),t),e.r=Ge.r,e.g=Ge.g,e.b=Ge.b,e}getStyle(e=At){nt.fromWorkingColorSpace(Ge.copy(this),e);const t=Ge.r,n=Ge.g,r=Ge.b;return e!==At?`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(Ct),this.setHSL(Ct.h+e,Ct.s+t,Ct.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(Ct),e.getHSL(Nn);const n=Ir(Ct.h,Nn.h,t),r=Ir(Ct.s,Nn.s,t),s=Ir(Ct.l,Nn.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 Ge=new zn;zn.NAMES=Ti;class bu extends l.MeshStandardMaterial{constructor(t={}){super();ue(this,"isMeshPhysicalMaterial");ue(this,"clearcoatMap");ue(this,"clearcoatRoughness");ue(this,"clearcoatRoughnessMap");ue(this,"clearcoatNormalScale");ue(this,"clearcoatNormalMap");ue(this,"ior");ue(this,"transmissionMap");ue(this,"thickness");ue(this,"thicknessMap");ue(this,"attenuationDistance");ue(this,"attenuationColor");ue(this,"specularIntensity");ue(this,"specularIntensityMap");ue(this,"specularColor");ue(this,"specularColorMap");ue(this,"_clearcoat");ue(this,"_transmission");this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Or(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get(){return St(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=Number.POSITIVE_INFINITY,this.attenuationColor=new zn(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new zn(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 Mu=u.defineComponent({__name:"index",setup(o,{expose:e}){const t=u.shallowRef(),{extend:n}=te.useTresContext();return n({MeshGlassMaterial:bu}),e({instance:t}),(r,s)=>(u.openBlock(),u.createElementBlock("TresMeshGlassMaterial",{ref_key:"MeshGlassMaterialClass",ref:t},null,512))}});var Su=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function hn(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function Vn(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 Ii={exports:{}};(function(o,e){(function(t){o.exports=t()})(function(){return function t(n,r,s){function i(h,d){if(!r[h]){if(!n[h]){var f=typeof Vn=="function"&&Vn;if(!d&&f)return f(h,!0);if(a)return a(h,!0);throw new Error("Cannot find module '"+h+"'")}d=r[h]={exports:{}},n[h][0].call(d.exports,function(p){var m=n[h][1][p];return i(m||p)},d,d.exports,t,n,r,s)}return r[h].exports}for(var a=typeof Vn=="function"&&Vn,c=0;c<s.length;c++)i(s[c]);return i}({1:[function(t,n,r){(function(s,i,a,c,h,d,f,p,m){var _=t("crypto");function v(T,C){C=M(T,C);var w;return(w=C.algorithm!=="passthrough"?_.createHash(C.algorithm):new O).write===void 0&&(w.write=w.update,w.end=w.update),S(C,w).dispatch(T),w.update||w.end(""),w.digest?w.digest(C.encoding==="buffer"?void 0:C.encoding):(T=w.read(),C.encoding!=="buffer"?T.toString(C.encoding):T)}(r=n.exports=v).sha1=function(T){return v(T)},r.keys=function(T){return v(T,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},r.MD5=function(T){return v(T,{algorithm:"md5",encoding:"hex"})},r.keysMD5=function(T){return v(T,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var y=_.getHashes?_.getHashes().slice():["sha1","md5"],g=(y.push("passthrough"),["buffer","hex","binary","base64"]);function M(T,C){var w={};if(w.algorithm=(C=C||{}).algorithm||"sha1",w.encoding=C.encoding||"hex",w.excludeValues=!!C.excludeValues,w.algorithm=w.algorithm.toLowerCase(),w.encoding=w.encoding.toLowerCase(),w.ignoreUnknown=C.ignoreUnknown===!0,w.respectType=C.respectType!==!1,w.respectFunctionNames=C.respectFunctionNames!==!1,w.respectFunctionProperties=C.respectFunctionProperties!==!1,w.unorderedArrays=C.unorderedArrays===!0,w.unorderedSets=C.unorderedSets!==!1,w.unorderedObjects=C.unorderedObjects!==!1,w.replacer=C.replacer||void 0,w.excludeKeys=C.excludeKeys||void 0,T===void 0)throw new Error("Object argument required.");for(var A=0;A<y.length;++A)y[A].toLowerCase()===w.algorithm.toLowerCase()&&(w.algorithm=y[A]);if(y.indexOf(w.algorithm)===-1)throw new Error('Algorithm "'+w.algorithm+'" not supported. supported values: '+y.join(", "));if(g.indexOf(w.encoding)===-1&&w.algorithm!=="passthrough")throw new Error('Encoding "'+w.encoding+'" not supported. supported values: '+g.join(", "));return w}function b(T){if(typeof T=="function")return/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(T))!=null}function S(T,C,w){w=w||[];function A(x){return C.update?C.update(x,"utf8"):C.write(x,"utf8")}return{dispatch:function(x){return this["_"+((x=T.replacer?T.replacer(x):x)===null?"null":typeof x)](x)},_object:function(x){var D,L=Object.prototype.toString.call(x),V=/\[object (.*)\]/i.exec(L);if(V=(V=V?V[1]:"unknown:["+L+"]").toLowerCase(),0<=(L=w.indexOf(x)))return this.dispatch("[CIRCULAR:"+L+"]");if(w.push(x),a!==void 0&&a.isBuffer&&a.isBuffer(x))return A("buffer:"),A(x);if(V==="object"||V==="function"||V==="asyncfunction")return L=Object.keys(x),T.unorderedObjects&&(L=L.sort()),T.respectType===!1||b(x)||L.splice(0,0,"prototype","__proto__","constructor"),T.excludeKeys&&(L=L.filter(function(R){return!T.excludeKeys(R)})),A("object:"+L.length+":"),D=this,L.forEach(function(R){D.dispatch(R),A(":"),T.excludeValues||D.dispatch(x[R]),A(",")});if(!this["_"+V]){if(T.ignoreUnknown)return A("["+V+"]");throw new Error('Unknown object type "'+V+'"')}this["_"+V](x)},_array:function(x,R){R=R!==void 0?R:T.unorderedArrays!==!1;var L=this;if(A("array:"+x.length+":"),!R||x.length<=1)return x.forEach(function(X){return L.dispatch(X)});var V=[],R=x.map(function(X){var Y=new O,J=w.slice();return S(T,Y,J).dispatch(X),V=V.concat(J.slice(w.length)),Y.read().toString()});return w=w.concat(V),R.sort(),this._array(R,!1)},_date:function(x){return A("date:"+x.toJSON())},_symbol:function(x){return A("symbol:"+x.toString())},_error:function(x){return A("error:"+x.toString())},_boolean:function(x){return A("bool:"+x.toString())},_string:function(x){A("string:"+x.length+":"),A(x.toString())},_function:function(x){A("fn:"),b(x)?this.dispatch("[native]"):this.dispatch(x.toString()),T.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(x.name)),T.respectFunctionProperties&&this._object(x)},_number:function(x){return A("number:"+x.toString())},_xml:function(x){return A("xml:"+x.toString())},_null:function(){return A("Null")},_undefined:function(){return A("Undefined")},_regexp:function(x){return A("regex:"+x.toString())},_uint8array:function(x){return A("uint8array:"),this.dispatch(Array.prototype.slice.call(x))},_uint8clampedarray:function(x){return A("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(x))},_int8array:function(x){return A("int8array:"),this.dispatch(Array.prototype.slice.call(x))},_uint16array:function(x){return A("uint16array:"),this.dispatch(Array.prototype.slice.call(x))},_int16array:function(x){return A("int16array:"),this.dispatch(Array.prototype.slice.call(x))},_uint32array:function(x){return A("uint32array:"),this.dispatch(Array.prototype.slice.call(x))},_int32array:function(x){return A("int32array:"),this.dispatch(Array.prototype.slice.call(x))},_float32array:function(x){return A("float32array:"),this.dispatch(Array.prototype.slice.call(x))},_float64array:function(x){return A("float64array:"),this.dispatch(Array.prototype.slice.call(x))},_arraybuffer:function(x){return A("arraybuffer:"),this.dispatch(new Uint8Array(x))},_url:function(x){return A("url:"+x.toString())},_map:function(x){return A("map:"),x=Array.from(x),this._array(x,T.unorderedSets!==!1)},_set:function(x){return A("set:"),x=Array.from(x),this._array(x,T.unorderedSets!==!1)},_file:function(x){return A("file:"),this.dispatch([x.name,x.size,x.type,x.lastModfied])},_blob:function(){if(T.ignoreUnknown)return A("[blob]");throw Error(`Hashing Blob objects is currently not supported
|
|
262
523
|
(see https://github.com/puleos/object-hash/issues/26)
|
|
263
524
|
Use "options.replacer" or "options.ignoreUnknown"
|
|
264
|
-
`)},_domwindow:function(){return A("domwindow")},_bigint:function(
|
|
265
|
-
list should be an Array.`),C.length===0)return new _(0);if(C.length===1)return C[0];if(typeof I!="number")for(X=I=0;X<C.length;X++)I+=C[X].length;for(var B=new _(I),Z=0,X=0;X<C.length;X++){var W=C[X];W.copy(B,Z),Z+=W.length}return B},_.prototype.write=function(C,I,B,Z){isFinite(I)?isFinite(B)||(Z=B,B=void 0):(se=Z,Z=I,I=B,B=se),I=Number(I)||0;var X,W,$,re,se=this.length-I;switch((!B||se<(B=Number(B)))&&(B=se),Z=String(Z||"utf8").toLowerCase()){case"hex":X=function(E,N,ae,ue){ae=Number(ae)||0;var ve=E.length-ae;(!ue||ve<(ue=Number(ue)))&&(ue=ve),j((ve=N.length)%2==0,"Invalid hex string"),ve/2<ue&&(ue=ve/2);for(var Oe=0;Oe<ue;Oe++){var Te=parseInt(N.substr(2*Oe,2),16);j(!isNaN(Te),"Invalid hex string"),E[ae+Oe]=Te}return _._charsWritten=2*Oe,Oe}(this,C,I,B);break;case"utf8":case"utf-8":W=this,$=I,re=B,X=_._charsWritten=de(le(C),W,$,re);break;case"ascii":case"binary":X=m(this,C,I,B);break;case"base64":W=this,$=I,re=B,X=_._charsWritten=de(he(C),W,$,re);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":X=M(this,C,I,B);break;default:throw new Error("Unknown encoding")}return X},_.prototype.toString=function(C,I,B){var Z,X,W,$,re=this;if(C=String(C||"utf8").toLowerCase(),I=Number(I)||0,(B=B!==void 0?Number(B):re.length)===I)return"";switch(C){case"hex":Z=function(se,E,N){var ae=se.length;(!E||E<0)&&(E=0),(!N||N<0||ae<N)&&(N=ae);for(var ue="",ve=E;ve<N;ve++)ue+=ee(se[ve]);return ue}(re,I,B);break;case"utf8":case"utf-8":Z=function(se,E,N){var ae="",ue="";N=Math.min(se.length,N);for(var ve=E;ve<N;ve++)se[ve]<=127?(ae+=O(ue)+String.fromCharCode(se[ve]),ue=""):ue+="%"+se[ve].toString(16);return ae+O(ue)}(re,I,B);break;case"ascii":case"binary":Z=b(re,I,B);break;case"base64":X=re,$=B,Z=(W=I)===0&&$===X.length?x.fromByteArray(X):x.fromByteArray(X.slice(W,$));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":Z=function(se,E,N){for(var ae=se.slice(E,N),ue="",ve=0;ve<ae.length;ve+=2)ue+=String.fromCharCode(ae[ve]+256*ae[ve+1]);return ue}(re,I,B);break;default:throw new Error("Unknown encoding")}return Z},_.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},_.prototype.copy=function(C,I,B,Z){if(I=I||0,(Z=Z||Z===0?Z:this.length)!==(B=B||0)&&C.length!==0&&this.length!==0){j(B<=Z,"sourceEnd < sourceStart"),j(0<=I&&I<C.length,"targetStart out of bounds"),j(0<=B&&B<this.length,"sourceStart out of bounds"),j(0<=Z&&Z<=this.length,"sourceEnd out of bounds"),Z>this.length&&(Z=this.length);var X=(Z=C.length-I<Z-B?C.length-I+B:Z)-B;if(X<100||!_._useTypedArrays)for(var W=0;W<X;W++)C[W+I]=this[W+B];else C._set(this.subarray(B,B+X),I)}},_.prototype.slice=function(C,I){var B=this.length;if(C=Q(C,B,0),I=Q(I,B,B),_._useTypedArrays)return _._augment(this.subarray(C,I));for(var Z=I-C,X=new _(Z,void 0,!0),W=0;W<Z;W++)X[W]=this[W+C];return X},_.prototype.get=function(C){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(C)},_.prototype.set=function(C,I){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(C,I)},_.prototype.readUInt8=function(C,I){if(I||(j(C!=null,"missing offset"),j(C<this.length,"Trying to read beyond buffer length")),!(C>=this.length))return this[C]},_.prototype.readUInt16LE=function(C,I){return S(this,C,!0,I)},_.prototype.readUInt16BE=function(C,I){return S(this,C,!1,I)},_.prototype.readUInt32LE=function(C,I){return L(this,C,!0,I)},_.prototype.readUInt32BE=function(C,I){return L(this,C,!1,I)},_.prototype.readInt8=function(C,I){if(I||(j(C!=null,"missing offset"),j(C<this.length,"Trying to read beyond buffer length")),!(C>=this.length))return 128&this[C]?-1*(255-this[C]+1):this[C]},_.prototype.readInt16LE=function(C,I){return P(this,C,!0,I)},_.prototype.readInt16BE=function(C,I){return P(this,C,!1,I)},_.prototype.readInt32LE=function(C,I){return T(this,C,!0,I)},_.prototype.readInt32BE=function(C,I){return T(this,C,!1,I)},_.prototype.readFloatLE=function(C,I){return y(this,C,!0,I)},_.prototype.readFloatBE=function(C,I){return y(this,C,!1,I)},_.prototype.readDoubleLE=function(C,I){return A(this,C,!0,I)},_.prototype.readDoubleBE=function(C,I){return A(this,C,!1,I)},_.prototype.writeUInt8=function(C,I,B){B||(j(C!=null,"missing value"),j(I!=null,"missing offset"),j(I<this.length,"trying to write beyond buffer length"),z(C,255)),I>=this.length||(this[I]=C)},_.prototype.writeUInt16LE=function(C,I,B){w(this,C,I,!0,B)},_.prototype.writeUInt16BE=function(C,I,B){w(this,C,I,!1,B)},_.prototype.writeUInt32LE=function(C,I,B){D(this,C,I,!0,B)},_.prototype.writeUInt32BE=function(C,I,B){D(this,C,I,!1,B)},_.prototype.writeInt8=function(C,I,B){B||(j(C!=null,"missing value"),j(I!=null,"missing offset"),j(I<this.length,"Trying to write beyond buffer length"),U(C,127,-128)),I>=this.length||(0<=C?this.writeUInt8(C,I,B):this.writeUInt8(255+C+1,I,B))},_.prototype.writeInt16LE=function(C,I,B){k(this,C,I,!0,B)},_.prototype.writeInt16BE=function(C,I,B){k(this,C,I,!1,B)},_.prototype.writeInt32LE=function(C,I,B){R(this,C,I,!0,B)},_.prototype.writeInt32BE=function(C,I,B){R(this,C,I,!1,B)},_.prototype.writeFloatLE=function(C,I,B){V(this,C,I,!0,B)},_.prototype.writeFloatBE=function(C,I,B){V(this,C,I,!1,B)},_.prototype.writeDoubleLE=function(C,I,B){Y(this,C,I,!0,B)},_.prototype.writeDoubleBE=function(C,I,B){Y(this,C,I,!1,B)},_.prototype.fill=function(C,I,B){if(I=I||0,B=B||this.length,j(typeof(C=typeof(C=C||0)=="string"?C.charCodeAt(0):C)=="number"&&!isNaN(C),"value is not a number"),j(I<=B,"end < start"),B!==I&&this.length!==0){j(0<=I&&I<this.length,"start out of bounds"),j(0<=B&&B<=this.length,"end out of bounds");for(var Z=I;Z<B;Z++)this[Z]=C}},_.prototype.inspect=function(){for(var C=[],I=this.length,B=0;B<I;B++)if(C[B]=ee(this[B]),B===r.INSPECT_MAX_BYTES){C[B+1]="...";break}return"<Buffer "+C.join(" ")+">"},_.prototype.toArrayBuffer=function(){if(typeof Uint8Array>"u")throw new Error("Buffer.toArrayBuffer not supported in this browser");if(_._useTypedArrays)return new _(this).buffer;for(var C=new Uint8Array(this.length),I=0,B=C.length;I<B;I+=1)C[I]=this[I];return C.buffer};var G=_.prototype;function Q(C,I,B){return typeof C!="number"?B:I<=(C=~~C)?I:0<=C||0<=(C+=I)?C:0}function K(C){return(C=~~Math.ceil(+C))<0?0:C}function ne(C){return(Array.isArray||function(I){return Object.prototype.toString.call(I)==="[object Array]"})(C)}function ee(C){return C<16?"0"+C.toString(16):C.toString(16)}function le(C){for(var I=[],B=0;B<C.length;B++){var Z=C.charCodeAt(B);if(Z<=127)I.push(C.charCodeAt(B));else for(var X=B,W=(55296<=Z&&Z<=57343&&B++,encodeURIComponent(C.slice(X,B+1)).substr(1).split("%")),$=0;$<W.length;$++)I.push(parseInt(W[$],16))}return I}function he(C){return x.toByteArray(C)}function de(C,I,B,Z){for(var X=0;X<Z&&!(X+B>=I.length||X>=C.length);X++)I[X+B]=C[X];return X}function O(C){try{return decodeURIComponent(C)}catch{return"�"}}function z(C,I){j(typeof C=="number","cannot write a non-number as a number"),j(0<=C,"specified a negative value for writing an unsigned value"),j(C<=I,"value is larger than maximum value for type"),j(Math.floor(C)===C,"value has a fractional component")}function U(C,I,B){j(typeof C=="number","cannot write a non-number as a number"),j(C<=I,"value larger than maximum allowed value"),j(B<=C,"value smaller than minimum allowed value"),j(Math.floor(C)===C,"value has a fractional component")}function F(C,I,B){j(typeof C=="number","cannot write a non-number as a number"),j(C<=I,"value larger than maximum allowed value"),j(B<=C,"value smaller than minimum allowed value")}function j(C,I){if(!C)throw new Error(I||"Failed assertion")}_._augment=function(C){return C._isBuffer=!0,C._get=C.get,C._set=C.set,C.get=G.get,C.set=G.set,C.write=G.write,C.toString=G.toString,C.toLocaleString=G.toString,C.toJSON=G.toJSON,C.copy=G.copy,C.slice=G.slice,C.readUInt8=G.readUInt8,C.readUInt16LE=G.readUInt16LE,C.readUInt16BE=G.readUInt16BE,C.readUInt32LE=G.readUInt32LE,C.readUInt32BE=G.readUInt32BE,C.readInt8=G.readInt8,C.readInt16LE=G.readInt16LE,C.readInt16BE=G.readInt16BE,C.readInt32LE=G.readInt32LE,C.readInt32BE=G.readInt32BE,C.readFloatLE=G.readFloatLE,C.readFloatBE=G.readFloatBE,C.readDoubleLE=G.readDoubleLE,C.readDoubleBE=G.readDoubleBE,C.writeUInt8=G.writeUInt8,C.writeUInt16LE=G.writeUInt16LE,C.writeUInt16BE=G.writeUInt16BE,C.writeUInt32LE=G.writeUInt32LE,C.writeUInt32BE=G.writeUInt32BE,C.writeInt8=G.writeInt8,C.writeInt16LE=G.writeInt16LE,C.writeInt16BE=G.writeInt16BE,C.writeInt32LE=G.writeInt32LE,C.writeInt32BE=G.writeInt32BE,C.writeFloatLE=G.writeFloatLE,C.writeFloatBE=G.writeFloatBE,C.writeDoubleLE=G.writeDoubleLE,C.writeDoubleBE=G.writeDoubleBE,C.fill=G.fill,C.inspect=G.inspect,C.toArrayBuffer=G.toArrayBuffer,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/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,c,h,f,d,p,g){var x=t("buffer").Buffer,v=4,_=new x(v);_.fill(0),n.exports={hash:function(m,M,b,S){for(var L=M(function(w,D){w.length%v!=0&&(k=w.length+(v-w.length%v),w=x.concat([w,_],k));for(var k,R=[],V=D?w.readInt32BE:w.readInt32LE,Y=0;Y<w.length;Y+=v)R.push(V.call(w,Y));return R}(m=x.isBuffer(m)?m:new x(m),S),8*m.length),M=S,P=new x(b),T=M?P.writeInt32BE:P.writeInt32LE,y=0;y<L.length;y++)T.call(P,L[y],4*y,!0);return P}}}).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,c,h,f,d,p,g){var x=t("buffer").Buffer,v=t("./sha"),_=t("./sha256"),m=t("./rng"),M={sha1:v,sha256:_,md5:t("./md5")},b=64,S=new x(b);function L(w,D){var k=M[w=w||"sha1"],R=[];return k||P("algorithm:",w,"is not yet supported"),{update:function(V){return x.isBuffer(V)||(V=new x(V)),R.push(V),V.length,this},digest:function(V){var Y=x.concat(R),Y=D?function(G,Q,K){x.isBuffer(Q)||(Q=new x(Q)),x.isBuffer(K)||(K=new x(K)),Q.length>b?Q=G(Q):Q.length<b&&(Q=x.concat([Q,S],b));for(var ne=new x(b),ee=new x(b),le=0;le<b;le++)ne[le]=54^Q[le],ee[le]=92^Q[le];return K=G(x.concat([ne,K])),G(x.concat([ee,K]))}(k,D,Y):k(Y);return R=null,V?Y.toString(V):Y}}}function P(){var w=[].slice.call(arguments).join(" ");throw new Error([w,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join(`
|
|
266
|
-
`))}S.fill(0),r.createHash=function(w){return L(w)},r.createHmac=L,r.randomBytes=function(w,D){if(!D||!D.call)return new x(m(w));try{D.call(this,void 0,new x(m(w)))}catch(k){D(k)}};var T,y=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],A=function(w){r[w]=function(){P("sorry,",w,"is not implemented yet")}};for(T in y)A(y[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/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,c,h,f,d,p,g){var x=t("./helpers");function v(P,T){P[T>>5]|=128<<T%32,P[14+(T+64>>>9<<4)]=T;for(var y=1732584193,A=-271733879,w=-1732584194,D=271733878,k=0;k<P.length;k+=16){var R=y,V=A,Y=w,G=D,y=m(y,A,w,D,P[k+0],7,-680876936),D=m(D,y,A,w,P[k+1],12,-389564586),w=m(w,D,y,A,P[k+2],17,606105819),A=m(A,w,D,y,P[k+3],22,-1044525330);y=m(y,A,w,D,P[k+4],7,-176418897),D=m(D,y,A,w,P[k+5],12,1200080426),w=m(w,D,y,A,P[k+6],17,-1473231341),A=m(A,w,D,y,P[k+7],22,-45705983),y=m(y,A,w,D,P[k+8],7,1770035416),D=m(D,y,A,w,P[k+9],12,-1958414417),w=m(w,D,y,A,P[k+10],17,-42063),A=m(A,w,D,y,P[k+11],22,-1990404162),y=m(y,A,w,D,P[k+12],7,1804603682),D=m(D,y,A,w,P[k+13],12,-40341101),w=m(w,D,y,A,P[k+14],17,-1502002290),y=M(y,A=m(A,w,D,y,P[k+15],22,1236535329),w,D,P[k+1],5,-165796510),D=M(D,y,A,w,P[k+6],9,-1069501632),w=M(w,D,y,A,P[k+11],14,643717713),A=M(A,w,D,y,P[k+0],20,-373897302),y=M(y,A,w,D,P[k+5],5,-701558691),D=M(D,y,A,w,P[k+10],9,38016083),w=M(w,D,y,A,P[k+15],14,-660478335),A=M(A,w,D,y,P[k+4],20,-405537848),y=M(y,A,w,D,P[k+9],5,568446438),D=M(D,y,A,w,P[k+14],9,-1019803690),w=M(w,D,y,A,P[k+3],14,-187363961),A=M(A,w,D,y,P[k+8],20,1163531501),y=M(y,A,w,D,P[k+13],5,-1444681467),D=M(D,y,A,w,P[k+2],9,-51403784),w=M(w,D,y,A,P[k+7],14,1735328473),y=b(y,A=M(A,w,D,y,P[k+12],20,-1926607734),w,D,P[k+5],4,-378558),D=b(D,y,A,w,P[k+8],11,-2022574463),w=b(w,D,y,A,P[k+11],16,1839030562),A=b(A,w,D,y,P[k+14],23,-35309556),y=b(y,A,w,D,P[k+1],4,-1530992060),D=b(D,y,A,w,P[k+4],11,1272893353),w=b(w,D,y,A,P[k+7],16,-155497632),A=b(A,w,D,y,P[k+10],23,-1094730640),y=b(y,A,w,D,P[k+13],4,681279174),D=b(D,y,A,w,P[k+0],11,-358537222),w=b(w,D,y,A,P[k+3],16,-722521979),A=b(A,w,D,y,P[k+6],23,76029189),y=b(y,A,w,D,P[k+9],4,-640364487),D=b(D,y,A,w,P[k+12],11,-421815835),w=b(w,D,y,A,P[k+15],16,530742520),y=S(y,A=b(A,w,D,y,P[k+2],23,-995338651),w,D,P[k+0],6,-198630844),D=S(D,y,A,w,P[k+7],10,1126891415),w=S(w,D,y,A,P[k+14],15,-1416354905),A=S(A,w,D,y,P[k+5],21,-57434055),y=S(y,A,w,D,P[k+12],6,1700485571),D=S(D,y,A,w,P[k+3],10,-1894986606),w=S(w,D,y,A,P[k+10],15,-1051523),A=S(A,w,D,y,P[k+1],21,-2054922799),y=S(y,A,w,D,P[k+8],6,1873313359),D=S(D,y,A,w,P[k+15],10,-30611744),w=S(w,D,y,A,P[k+6],15,-1560198380),A=S(A,w,D,y,P[k+13],21,1309151649),y=S(y,A,w,D,P[k+4],6,-145523070),D=S(D,y,A,w,P[k+11],10,-1120210379),w=S(w,D,y,A,P[k+2],15,718787259),A=S(A,w,D,y,P[k+9],21,-343485551),y=L(y,R),A=L(A,V),w=L(w,Y),D=L(D,G)}return Array(y,A,w,D)}function _(P,T,y,A,w,D){return L((T=L(L(T,P),L(A,D)))<<w|T>>>32-w,y)}function m(P,T,y,A,w,D,k){return _(T&y|~T&A,P,T,w,D,k)}function M(P,T,y,A,w,D,k){return _(T&A|y&~A,P,T,w,D,k)}function b(P,T,y,A,w,D,k){return _(T^y^A,P,T,w,D,k)}function S(P,T,y,A,w,D,k){return _(y^(T|~A),P,T,w,D,k)}function L(P,T){var y=(65535&P)+(65535&T);return(P>>16)+(T>>16)+(y>>16)<<16|65535&y}n.exports=function(P){return x.hash(P,v,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,c,h,f,d,p,g){n.exports=function(x){for(var v,_=new Array(x),m=0;m<x;m++)!(3&m)&&(v=4294967296*Math.random()),_[m]=v>>>((3&m)<<3)&255;return _}}).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,c,h,f,d,p,g){var x=t("./helpers");function v(M,b){M[b>>5]|=128<<24-b%32,M[15+(b+64>>9<<4)]=b;for(var S,L,P,T=Array(80),y=1732584193,A=-271733879,w=-1732584194,D=271733878,k=-1009589776,R=0;R<M.length;R+=16){for(var V=y,Y=A,G=w,Q=D,K=k,ne=0;ne<80;ne++){T[ne]=ne<16?M[R+ne]:m(T[ne-3]^T[ne-8]^T[ne-14]^T[ne-16],1);var ee=_(_(m(y,5),(ee=A,L=w,P=D,(S=ne)<20?ee&L|~ee&P:!(S<40)&&S<60?ee&L|ee&P|L&P:ee^L^P)),_(_(k,T[ne]),(S=ne)<20?1518500249:S<40?1859775393:S<60?-1894007588:-899497514)),k=D,D=w,w=m(A,30),A=y,y=ee}y=_(y,V),A=_(A,Y),w=_(w,G),D=_(D,Q),k=_(k,K)}return Array(y,A,w,D,k)}function _(M,b){var S=(65535&M)+(65535&b);return(M>>16)+(b>>16)+(S>>16)<<16|65535&S}function m(M,b){return M<<b|M>>>32-b}n.exports=function(M){return x.hash(M,v,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,c,h,f,d,p,g){function x(b,S){var L=(65535&b)+(65535&S);return(b>>16)+(S>>16)+(L>>16)<<16|65535&L}function v(b,S){var L,P=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),T=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),y=new Array(64);b[S>>5]|=128<<24-S%32,b[15+(S+64>>9<<4)]=S;for(var A,w,D=0;D<b.length;D+=16){for(var k=T[0],R=T[1],V=T[2],Y=T[3],G=T[4],Q=T[5],K=T[6],ne=T[7],ee=0;ee<64;ee++)y[ee]=ee<16?b[ee+D]:x(x(x((w=y[ee-2],m(w,17)^m(w,19)^M(w,10)),y[ee-7]),(w=y[ee-15],m(w,7)^m(w,18)^M(w,3))),y[ee-16]),L=x(x(x(x(ne,m(w=G,6)^m(w,11)^m(w,25)),G&Q^~G&K),P[ee]),y[ee]),A=x(m(A=k,2)^m(A,13)^m(A,22),k&R^k&V^R&V),ne=K,K=Q,Q=G,G=x(Y,L),Y=V,V=R,R=k,k=x(L,A);T[0]=x(k,T[0]),T[1]=x(R,T[1]),T[2]=x(V,T[2]),T[3]=x(Y,T[3]),T[4]=x(G,T[4]),T[5]=x(Q,T[5]),T[6]=x(K,T[6]),T[7]=x(ne,T[7])}return T}var _=t("./helpers"),m=function(b,S){return b>>>S|b<<32-S},M=function(b,S){return b>>>S};n.exports=function(b){return _.hash(b,v,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,c,h,f,d,p,g){r.read=function(x,v,_,m,D){var b,S,L=8*D-m-1,P=(1<<L)-1,T=P>>1,y=-7,A=_?D-1:0,w=_?-1:1,D=x[v+A];for(A+=w,b=D&(1<<-y)-1,D>>=-y,y+=L;0<y;b=256*b+x[v+A],A+=w,y-=8);for(S=b&(1<<-y)-1,b>>=-y,y+=m;0<y;S=256*S+x[v+A],A+=w,y-=8);if(b===0)b=1-T;else{if(b===P)return S?NaN:1/0*(D?-1:1);S+=Math.pow(2,m),b-=T}return(D?-1:1)*S*Math.pow(2,b-m)},r.write=function(x,v,_,m,M,k){var S,L,P=8*k-M-1,T=(1<<P)-1,y=T>>1,A=M===23?Math.pow(2,-24)-Math.pow(2,-77):0,w=m?0:k-1,D=m?1:-1,k=v<0||v===0&&1/v<0?1:0;for(v=Math.abs(v),isNaN(v)||v===1/0?(L=isNaN(v)?1:0,S=T):(S=Math.floor(Math.log(v)/Math.LN2),v*(m=Math.pow(2,-S))<1&&(S--,m*=2),2<=(v+=1<=S+y?A/m:A*Math.pow(2,1-y))*m&&(S++,m/=2),T<=S+y?(L=0,S=T):1<=S+y?(L=(v*m-1)*Math.pow(2,M),S+=y):(L=v*Math.pow(2,y-1)*Math.pow(2,M),S=0));8<=M;x[_+w]=255&L,w+=D,L/=256,M-=8);for(S=S<<M|L,P+=M;0<P;x[_+w]=255&S,w+=D,S/=256,P-=8);x[_+w-D]|=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,c,h,f,d,p,g){var x,v,_;function m(){}(s=n.exports={}).nextTick=(v=typeof window<"u"&&window.setImmediate,_=typeof window<"u"&&window.postMessage&&window.addEventListener,v?function(M){return window.setImmediate(M)}:_?(x=[],window.addEventListener("message",function(M){var b=M.source;b!==window&&b!==null||M.data!=="process-tick"||(M.stopPropagation(),0<x.length&&x.shift()())},!0),function(M){x.push(M),window.postMessage("process-tick","*")}):function(M){setTimeout(M,0)}),s.title="browser",s.browser=!0,s.env={},s.argv=[],s.on=m,s.addListener=m,s.once=m,s.off=m,s.removeListener=m,s.removeAllListeners=m,s.emit=m,s.binding=function(M){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(M){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)})})(xi);var Yc=xi.exports;const Ec=un(Yc);var wi=["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"],Xc=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"],bi=["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"],Zc=wi,qc=Zc.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"]),Br=bi;Br=Br.slice().filter(function(o){return!/^(gl\_|texture)/.test(o)});var Kc=Br.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"]),Qc=ou,Jc=wi,Mi=Xc,Hc=bi,$c=qc,eu=Kc,nt=999,Si=9999,Fr=0,Ur=1,Ai=2,Ci=3,Pi=4,hn=5,tu=6,nu=7,ru=8,Ti=9,su=10,Ii=11,iu=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"];function ou(o){var e=0,t=0,n=nt,r,s,i=[],a=[],c=1,h=0,f=0,d=!1,p=!1,g="",x;o=o||{};var v=Hc,_=Jc;o.version==="300 es"&&(v=eu,_=$c);for(var m={},M={},e=0;e<v.length;e++)m[v[e]]=!0;for(var e=0;e<_.length;e++)M[_[e]]=!0;return function(Q){return a=[],Q!==null?S(Q):L()};function b(Q){Q.length&&a.push({type:iu[n],data:Q,position:f,line:c,column:h})}function S(Q){e=0,Q.toString&&(Q=Q.toString()),g+=Q.replace(/\r\n/g,`
|
|
267
|
-
`),
|
|
268
|
-
`:h=0,++c;break;default:++h;break}}return t+=e,
|
|
269
|
-
`)&&s!=="\\"?(b(i.join("")),n=
|
|
270
|
-
vec3 objectNormal = `.concat(
|
|
525
|
+
`)},_domwindow:function(){return A("domwindow")},_bigint:function(x){return A("bigint:"+x.toString())},_process:function(){return A("process")},_timer:function(){return A("timer")},_pipe:function(){return A("pipe")},_tcp:function(){return A("tcp")},_udp:function(){return A("udp")},_tty:function(){return A("tty")},_statwatcher:function(){return A("statwatcher")},_securecontext:function(){return A("securecontext")},_connection:function(){return A("connection")},_zlib:function(){return A("zlib")},_context:function(){return A("context")},_nodescript:function(){return A("nodescript")},_httpparser:function(){return A("httpparser")},_dataview:function(){return A("dataview")},_signal:function(){return A("signal")},_fsevent:function(){return A("fsevent")},_tlswrap:function(){return A("tlswrap")}}}function O(){return{buf:"",write:function(T){this.buf+=T},end:function(T){this.buf+=T},read:function(){return this.buf}}}r.writeToStream=function(T,C,w){return w===void 0&&(w=C,C={}),S(C=M(T,C),w).dispatch(T)}}).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,c,h,d,f,p,m){(function(_){var v=typeof Uint8Array<"u"?Uint8Array:Array,y=43,g=47,M=48,b=97,S=65,O=45,T=95;function C(w){return w=w.charCodeAt(0),w===y||w===O?62:w===g||w===T?63:w<M?-1:w<M+10?w-M+26+26:w<S+26?w-S:w<b+26?w-b+26:void 0}_.toByteArray=function(w){var A,x;if(0<w.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var D=w.length,D=w.charAt(D-2)==="="?2:w.charAt(D-1)==="="?1:0,L=new v(3*w.length/4-D),V=0<D?w.length-4:w.length,R=0;function X(Y){L[R++]=Y}for(A=0;A<V;A+=4,0)X((16711680&(x=C(w.charAt(A))<<18|C(w.charAt(A+1))<<12|C(w.charAt(A+2))<<6|C(w.charAt(A+3))))>>16),X((65280&x)>>8),X(255&x);return D==2?X(255&(x=C(w.charAt(A))<<2|C(w.charAt(A+1))>>4)):D==1&&(X((x=C(w.charAt(A))<<10|C(w.charAt(A+1))<<4|C(w.charAt(A+2))>>2)>>8&255),X(255&x)),L},_.fromByteArray=function(w){var A,x,D,L,V=w.length%3,R="";function X(Y){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(Y)}for(A=0,D=w.length-V;A<D;A+=3)x=(w[A]<<16)+(w[A+1]<<8)+w[A+2],R+=X((L=x)>>18&63)+X(L>>12&63)+X(L>>6&63)+X(63&L);switch(V){case 1:R=(R+=X((x=w[w.length-1])>>2))+X(x<<4&63)+"==";break;case 2:R=(R=(R+=X((x=(w[w.length-2]<<8)+w[w.length-1])>>10))+X(x>>4&63))+X(x<<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,y,c,h,d,f,p,m){var _=t("base64-js"),v=t("ieee754");function y(P,I,U){if(!(this instanceof y))return new y(P,I,U);var E,Z,j,$,ne=typeof P;if(I==="base64"&&ne=="string")for(P=($=P).trim?$.trim():$.replace(/^\s+|\s+$/g,"");P.length%4!=0;)P+="=";if(ne=="number")E=q(P);else if(ne=="string")E=y.byteLength(P,I);else{if(ne!="object")throw new Error("First argument needs to be a number, array or string.");E=q(P.length)}if(y._useTypedArrays?Z=y._augment(new Uint8Array(E)):((Z=this).length=E,Z._isBuffer=!0),y._useTypedArrays&&typeof P.byteLength=="number")Z._set(P);else if(re($=P)||y.isBuffer($)||$&&typeof $=="object"&&typeof $.length=="number")for(j=0;j<E;j++)y.isBuffer(P)?Z[j]=P.readUInt8(j):Z[j]=P[j];else if(ne=="string")Z.write(P,0,I);else if(ne=="number"&&!y._useTypedArrays&&!U)for(j=0;j<E;j++)Z[j]=0;return Z}function g(P,I,U,E){return y._charsWritten=me(function(Z){for(var j=[],$=0;$<Z.length;$++)j.push(255&Z.charCodeAt($));return j}(I),P,U,E)}function M(P,I,U,E){return y._charsWritten=me(function(Z){for(var j,$,ne=[],ie=0;ie<Z.length;ie++)$=Z.charCodeAt(ie),j=$>>8,$=$%256,ne.push($),ne.push(j);return ne}(I),P,U,E)}function b(P,I,U){var E="";U=Math.min(P.length,U);for(var Z=I;Z<U;Z++)E+=String.fromCharCode(P[Z]);return E}function S(P,I,U,j){j||(G(typeof U=="boolean","missing or invalid endian"),G(I!=null,"missing offset"),G(I+1<P.length,"Trying to read beyond buffer length"));var Z,j=P.length;if(!(j<=I))return U?(Z=P[I],I+1<j&&(Z|=P[I+1]<<8)):(Z=P[I]<<8,I+1<j&&(Z|=P[I+1])),Z}function O(P,I,U,j){j||(G(typeof U=="boolean","missing or invalid endian"),G(I!=null,"missing offset"),G(I+3<P.length,"Trying to read beyond buffer length"));var Z,j=P.length;if(!(j<=I))return U?(I+2<j&&(Z=P[I+2]<<16),I+1<j&&(Z|=P[I+1]<<8),Z|=P[I],I+3<j&&(Z+=P[I+3]<<24>>>0)):(I+1<j&&(Z=P[I+1]<<16),I+2<j&&(Z|=P[I+2]<<8),I+3<j&&(Z|=P[I+3]),Z+=P[I]<<24>>>0),Z}function T(P,I,U,E){if(E||(G(typeof U=="boolean","missing or invalid endian"),G(I!=null,"missing offset"),G(I+1<P.length,"Trying to read beyond buffer length")),!(P.length<=I))return E=S(P,I,U,!0),32768&E?-1*(65535-E+1):E}function C(P,I,U,E){if(E||(G(typeof U=="boolean","missing or invalid endian"),G(I!=null,"missing offset"),G(I+3<P.length,"Trying to read beyond buffer length")),!(P.length<=I))return E=O(P,I,U,!0),2147483648&E?-1*(4294967295-E+1):E}function w(P,I,U,E){return E||(G(typeof U=="boolean","missing or invalid endian"),G(I+3<P.length,"Trying to read beyond buffer length")),v.read(P,I,U,23,4)}function A(P,I,U,E){return E||(G(typeof U=="boolean","missing or invalid endian"),G(I+7<P.length,"Trying to read beyond buffer length")),v.read(P,I,U,52,8)}function x(P,I,U,E,Z){if(Z||(G(I!=null,"missing value"),G(typeof E=="boolean","missing or invalid endian"),G(U!=null,"missing offset"),G(U+1<P.length,"trying to write beyond buffer length"),z(I,65535)),Z=P.length,!(Z<=U))for(var j=0,$=Math.min(Z-U,2);j<$;j++)P[U+j]=(I&255<<8*(E?j:1-j))>>>8*(E?j:1-j)}function D(P,I,U,E,Z){if(Z||(G(I!=null,"missing value"),G(typeof E=="boolean","missing or invalid endian"),G(U!=null,"missing offset"),G(U+3<P.length,"trying to write beyond buffer length"),z(I,4294967295)),Z=P.length,!(Z<=U))for(var j=0,$=Math.min(Z-U,4);j<$;j++)P[U+j]=I>>>8*(E?j:3-j)&255}function L(P,I,U,E,Z){Z||(G(I!=null,"missing value"),G(typeof E=="boolean","missing or invalid endian"),G(U!=null,"missing offset"),G(U+1<P.length,"Trying to write beyond buffer length"),F(I,32767,-32768)),P.length<=U||x(P,0<=I?I:65535+I+1,U,E,Z)}function V(P,I,U,E,Z){Z||(G(I!=null,"missing value"),G(typeof E=="boolean","missing or invalid endian"),G(U!=null,"missing offset"),G(U+3<P.length,"Trying to write beyond buffer length"),F(I,2147483647,-2147483648)),P.length<=U||D(P,0<=I?I:4294967295+I+1,U,E,Z)}function R(P,I,U,E,Z){Z||(G(I!=null,"missing value"),G(typeof E=="boolean","missing or invalid endian"),G(U!=null,"missing offset"),G(U+3<P.length,"Trying to write beyond buffer length"),B(I,34028234663852886e22,-34028234663852886e22)),P.length<=U||v.write(P,I,U,E,23,4)}function X(P,I,U,E,Z){Z||(G(I!=null,"missing value"),G(typeof E=="boolean","missing or invalid endian"),G(U!=null,"missing offset"),G(U+7<P.length,"Trying to write beyond buffer length"),B(I,17976931348623157e292,-17976931348623157e292)),P.length<=U||v.write(P,I,U,E,52,8)}r.Buffer=y,r.SlowBuffer=y,r.INSPECT_MAX_BYTES=50,y.poolSize=8192,y._useTypedArrays=function(){try{var P=new ArrayBuffer(0),I=new Uint8Array(P);return I.foo=function(){return 42},I.foo()===42&&typeof I.subarray=="function"}catch{return!1}}(),y.isEncoding=function(P){switch(String(P).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}},y.isBuffer=function(P){return!(P==null||!P._isBuffer)},y.byteLength=function(P,I){var U;switch(P+="",I||"utf8"){case"hex":U=P.length/2;break;case"utf8":case"utf-8":U=ce(P).length;break;case"ascii":case"binary":case"raw":U=P.length;break;case"base64":U=le(P).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":U=2*P.length;break;default:throw new Error("Unknown encoding")}return U},y.concat=function(P,I){if(G(re(P),`Usage: Buffer.concat(list, [totalLength])
|
|
526
|
+
list should be an Array.`),P.length===0)return new y(0);if(P.length===1)return P[0];if(typeof I!="number")for(Z=I=0;Z<P.length;Z++)I+=P[Z].length;for(var U=new y(I),E=0,Z=0;Z<P.length;Z++){var j=P[Z];j.copy(U,E),E+=j.length}return U},y.prototype.write=function(P,I,U,E){isFinite(I)?isFinite(U)||(E=U,U=void 0):(ie=E,E=I,I=U,U=ie),I=Number(I)||0;var Z,j,$,ne,ie=this.length-I;switch((!U||ie<(U=Number(U)))&&(U=ie),E=String(E||"utf8").toLowerCase()){case"hex":Z=function(W,N,ae,he){ae=Number(ae)||0;var _e=W.length-ae;(!he||_e<(he=Number(he)))&&(he=_e),G((_e=N.length)%2==0,"Invalid hex string"),_e/2<he&&(he=_e/2);for(var Oe=0;Oe<he;Oe++){var De=parseInt(N.substr(2*Oe,2),16);G(!isNaN(De),"Invalid hex string"),W[ae+Oe]=De}return y._charsWritten=2*Oe,Oe}(this,P,I,U);break;case"utf8":case"utf-8":j=this,$=I,ne=U,Z=y._charsWritten=me(ce(P),j,$,ne);break;case"ascii":case"binary":Z=g(this,P,I,U);break;case"base64":j=this,$=I,ne=U,Z=y._charsWritten=me(le(P),j,$,ne);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":Z=M(this,P,I,U);break;default:throw new Error("Unknown encoding")}return Z},y.prototype.toString=function(P,I,U){var E,Z,j,$,ne=this;if(P=String(P||"utf8").toLowerCase(),I=Number(I)||0,(U=U!==void 0?Number(U):ne.length)===I)return"";switch(P){case"hex":E=function(ie,W,N){var ae=ie.length;(!W||W<0)&&(W=0),(!N||N<0||ae<N)&&(N=ae);for(var he="",_e=W;_e<N;_e++)he+=ee(ie[_e]);return he}(ne,I,U);break;case"utf8":case"utf-8":E=function(ie,W,N){var ae="",he="";N=Math.min(ie.length,N);for(var _e=W;_e<N;_e++)ie[_e]<=127?(ae+=k(he)+String.fromCharCode(ie[_e]),he=""):he+="%"+ie[_e].toString(16);return ae+k(he)}(ne,I,U);break;case"ascii":case"binary":E=b(ne,I,U);break;case"base64":Z=ne,$=U,E=(j=I)===0&&$===Z.length?_.fromByteArray(Z):_.fromByteArray(Z.slice(j,$));break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":E=function(ie,W,N){for(var ae=ie.slice(W,N),he="",_e=0;_e<ae.length;_e+=2)he+=String.fromCharCode(ae[_e]+256*ae[_e+1]);return he}(ne,I,U);break;default:throw new Error("Unknown encoding")}return E},y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},y.prototype.copy=function(P,I,U,E){if(I=I||0,(E=E||E===0?E:this.length)!==(U=U||0)&&P.length!==0&&this.length!==0){G(U<=E,"sourceEnd < sourceStart"),G(0<=I&&I<P.length,"targetStart out of bounds"),G(0<=U&&U<this.length,"sourceStart out of bounds"),G(0<=E&&E<=this.length,"sourceEnd out of bounds"),E>this.length&&(E=this.length);var Z=(E=P.length-I<E-U?P.length-I+U:E)-U;if(Z<100||!y._useTypedArrays)for(var j=0;j<Z;j++)P[j+I]=this[j+U];else P._set(this.subarray(U,U+Z),I)}},y.prototype.slice=function(P,I){var U=this.length;if(P=J(P,U,0),I=J(I,U,U),y._useTypedArrays)return y._augment(this.subarray(P,I));for(var E=I-P,Z=new y(E,void 0,!0),j=0;j<E;j++)Z[j]=this[j+P];return Z},y.prototype.get=function(P){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(P)},y.prototype.set=function(P,I){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(P,I)},y.prototype.readUInt8=function(P,I){if(I||(G(P!=null,"missing offset"),G(P<this.length,"Trying to read beyond buffer length")),!(P>=this.length))return this[P]},y.prototype.readUInt16LE=function(P,I){return S(this,P,!0,I)},y.prototype.readUInt16BE=function(P,I){return S(this,P,!1,I)},y.prototype.readUInt32LE=function(P,I){return O(this,P,!0,I)},y.prototype.readUInt32BE=function(P,I){return O(this,P,!1,I)},y.prototype.readInt8=function(P,I){if(I||(G(P!=null,"missing offset"),G(P<this.length,"Trying to read beyond buffer length")),!(P>=this.length))return 128&this[P]?-1*(255-this[P]+1):this[P]},y.prototype.readInt16LE=function(P,I){return T(this,P,!0,I)},y.prototype.readInt16BE=function(P,I){return T(this,P,!1,I)},y.prototype.readInt32LE=function(P,I){return C(this,P,!0,I)},y.prototype.readInt32BE=function(P,I){return C(this,P,!1,I)},y.prototype.readFloatLE=function(P,I){return w(this,P,!0,I)},y.prototype.readFloatBE=function(P,I){return w(this,P,!1,I)},y.prototype.readDoubleLE=function(P,I){return A(this,P,!0,I)},y.prototype.readDoubleBE=function(P,I){return A(this,P,!1,I)},y.prototype.writeUInt8=function(P,I,U){U||(G(P!=null,"missing value"),G(I!=null,"missing offset"),G(I<this.length,"trying to write beyond buffer length"),z(P,255)),I>=this.length||(this[I]=P)},y.prototype.writeUInt16LE=function(P,I,U){x(this,P,I,!0,U)},y.prototype.writeUInt16BE=function(P,I,U){x(this,P,I,!1,U)},y.prototype.writeUInt32LE=function(P,I,U){D(this,P,I,!0,U)},y.prototype.writeUInt32BE=function(P,I,U){D(this,P,I,!1,U)},y.prototype.writeInt8=function(P,I,U){U||(G(P!=null,"missing value"),G(I!=null,"missing offset"),G(I<this.length,"Trying to write beyond buffer length"),F(P,127,-128)),I>=this.length||(0<=P?this.writeUInt8(P,I,U):this.writeUInt8(255+P+1,I,U))},y.prototype.writeInt16LE=function(P,I,U){L(this,P,I,!0,U)},y.prototype.writeInt16BE=function(P,I,U){L(this,P,I,!1,U)},y.prototype.writeInt32LE=function(P,I,U){V(this,P,I,!0,U)},y.prototype.writeInt32BE=function(P,I,U){V(this,P,I,!1,U)},y.prototype.writeFloatLE=function(P,I,U){R(this,P,I,!0,U)},y.prototype.writeFloatBE=function(P,I,U){R(this,P,I,!1,U)},y.prototype.writeDoubleLE=function(P,I,U){X(this,P,I,!0,U)},y.prototype.writeDoubleBE=function(P,I,U){X(this,P,I,!1,U)},y.prototype.fill=function(P,I,U){if(I=I||0,U=U||this.length,G(typeof(P=typeof(P=P||0)=="string"?P.charCodeAt(0):P)=="number"&&!isNaN(P),"value is not a number"),G(I<=U,"end < start"),U!==I&&this.length!==0){G(0<=I&&I<this.length,"start out of bounds"),G(0<=U&&U<=this.length,"end out of bounds");for(var E=I;E<U;E++)this[E]=P}},y.prototype.inspect=function(){for(var P=[],I=this.length,U=0;U<I;U++)if(P[U]=ee(this[U]),U===r.INSPECT_MAX_BYTES){P[U+1]="...";break}return"<Buffer "+P.join(" ")+">"},y.prototype.toArrayBuffer=function(){if(typeof Uint8Array>"u")throw new Error("Buffer.toArrayBuffer not supported in this browser");if(y._useTypedArrays)return new y(this).buffer;for(var P=new Uint8Array(this.length),I=0,U=P.length;I<U;I+=1)P[I]=this[I];return P.buffer};var Y=y.prototype;function J(P,I,U){return typeof P!="number"?U:I<=(P=~~P)?I:0<=P||0<=(P+=I)?P:0}function q(P){return(P=~~Math.ceil(+P))<0?0:P}function re(P){return(Array.isArray||function(I){return Object.prototype.toString.call(I)==="[object Array]"})(P)}function ee(P){return P<16?"0"+P.toString(16):P.toString(16)}function ce(P){for(var I=[],U=0;U<P.length;U++){var E=P.charCodeAt(U);if(E<=127)I.push(P.charCodeAt(U));else for(var Z=U,j=(55296<=E&&E<=57343&&U++,encodeURIComponent(P.slice(Z,U+1)).substr(1).split("%")),$=0;$<j.length;$++)I.push(parseInt(j[$],16))}return I}function le(P){return _.toByteArray(P)}function me(P,I,U,E){for(var Z=0;Z<E&&!(Z+U>=I.length||Z>=P.length);Z++)I[Z+U]=P[Z];return Z}function k(P){try{return decodeURIComponent(P)}catch{return"�"}}function z(P,I){G(typeof P=="number","cannot write a non-number as a number"),G(0<=P,"specified a negative value for writing an unsigned value"),G(P<=I,"value is larger than maximum value for type"),G(Math.floor(P)===P,"value has a fractional component")}function F(P,I,U){G(typeof P=="number","cannot write a non-number as a number"),G(P<=I,"value larger than maximum allowed value"),G(U<=P,"value smaller than minimum allowed value"),G(Math.floor(P)===P,"value has a fractional component")}function B(P,I,U){G(typeof P=="number","cannot write a non-number as a number"),G(P<=I,"value larger than maximum allowed value"),G(U<=P,"value smaller than minimum allowed value")}function G(P,I){if(!P)throw new Error(I||"Failed assertion")}y._augment=function(P){return P._isBuffer=!0,P._get=P.get,P._set=P.set,P.get=Y.get,P.set=Y.set,P.write=Y.write,P.toString=Y.toString,P.toLocaleString=Y.toString,P.toJSON=Y.toJSON,P.copy=Y.copy,P.slice=Y.slice,P.readUInt8=Y.readUInt8,P.readUInt16LE=Y.readUInt16LE,P.readUInt16BE=Y.readUInt16BE,P.readUInt32LE=Y.readUInt32LE,P.readUInt32BE=Y.readUInt32BE,P.readInt8=Y.readInt8,P.readInt16LE=Y.readInt16LE,P.readInt16BE=Y.readInt16BE,P.readInt32LE=Y.readInt32LE,P.readInt32BE=Y.readInt32BE,P.readFloatLE=Y.readFloatLE,P.readFloatBE=Y.readFloatBE,P.readDoubleLE=Y.readDoubleLE,P.readDoubleBE=Y.readDoubleBE,P.writeUInt8=Y.writeUInt8,P.writeUInt16LE=Y.writeUInt16LE,P.writeUInt16BE=Y.writeUInt16BE,P.writeUInt32LE=Y.writeUInt32LE,P.writeUInt32BE=Y.writeUInt32BE,P.writeInt8=Y.writeInt8,P.writeInt16LE=Y.writeInt16LE,P.writeInt16BE=Y.writeInt16BE,P.writeInt32LE=Y.writeInt32LE,P.writeInt32BE=Y.writeInt32BE,P.writeFloatLE=Y.writeFloatLE,P.writeFloatBE=Y.writeFloatBE,P.writeDoubleLE=Y.writeDoubleLE,P.writeDoubleBE=Y.writeDoubleBE,P.fill=Y.fill,P.inspect=Y.inspect,P.toArrayBuffer=Y.toArrayBuffer,P}}).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,_,c,h,d,f,p,m){var _=t("buffer").Buffer,v=4,y=new _(v);y.fill(0),n.exports={hash:function(g,M,b,S){for(var O=M(function(x,D){x.length%v!=0&&(L=x.length+(v-x.length%v),x=_.concat([x,y],L));for(var L,V=[],R=D?x.readInt32BE:x.readInt32LE,X=0;X<x.length;X+=v)V.push(R.call(x,X));return V}(g=_.isBuffer(g)?g:new _(g),S),8*g.length),M=S,T=new _(b),C=M?T.writeInt32BE:T.writeInt32LE,w=0;w<O.length;w++)C.call(T,O[w],4*w,!0);return 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/crypto-browserify/helpers.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:11}],5:[function(t,n,r){(function(s,i,_,c,h,d,f,p,m){var _=t("buffer").Buffer,v=t("./sha"),y=t("./sha256"),g=t("./rng"),M={sha1:v,sha256:y,md5:t("./md5")},b=64,S=new _(b);function O(x,D){var L=M[x=x||"sha1"],V=[];return L||T("algorithm:",x,"is not yet supported"),{update:function(R){return _.isBuffer(R)||(R=new _(R)),V.push(R),R.length,this},digest:function(R){var X=_.concat(V),X=D?function(Y,J,q){_.isBuffer(J)||(J=new _(J)),_.isBuffer(q)||(q=new _(q)),J.length>b?J=Y(J):J.length<b&&(J=_.concat([J,S],b));for(var re=new _(b),ee=new _(b),ce=0;ce<b;ce++)re[ce]=54^J[ce],ee[ce]=92^J[ce];return q=Y(_.concat([re,q])),Y(_.concat([ee,q]))}(L,D,X):L(X);return V=null,R?X.toString(R):X}}}function T(){var x=[].slice.call(arguments).join(" ");throw new Error([x,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join(`
|
|
527
|
+
`))}S.fill(0),r.createHash=function(x){return O(x)},r.createHmac=O,r.randomBytes=function(x,D){if(!D||!D.call)return new _(g(x));try{D.call(this,void 0,new _(g(x)))}catch(L){D(L)}};var C,w=["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],A=function(x){r[x]=function(){T("sorry,",x,"is not implemented yet")}};for(C in w)A(w[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,c,h,d,f,p,m){var _=t("./helpers");function v(T,C){T[C>>5]|=128<<C%32,T[14+(C+64>>>9<<4)]=C;for(var w=1732584193,A=-271733879,x=-1732584194,D=271733878,L=0;L<T.length;L+=16){var V=w,R=A,X=x,Y=D,w=g(w,A,x,D,T[L+0],7,-680876936),D=g(D,w,A,x,T[L+1],12,-389564586),x=g(x,D,w,A,T[L+2],17,606105819),A=g(A,x,D,w,T[L+3],22,-1044525330);w=g(w,A,x,D,T[L+4],7,-176418897),D=g(D,w,A,x,T[L+5],12,1200080426),x=g(x,D,w,A,T[L+6],17,-1473231341),A=g(A,x,D,w,T[L+7],22,-45705983),w=g(w,A,x,D,T[L+8],7,1770035416),D=g(D,w,A,x,T[L+9],12,-1958414417),x=g(x,D,w,A,T[L+10],17,-42063),A=g(A,x,D,w,T[L+11],22,-1990404162),w=g(w,A,x,D,T[L+12],7,1804603682),D=g(D,w,A,x,T[L+13],12,-40341101),x=g(x,D,w,A,T[L+14],17,-1502002290),w=M(w,A=g(A,x,D,w,T[L+15],22,1236535329),x,D,T[L+1],5,-165796510),D=M(D,w,A,x,T[L+6],9,-1069501632),x=M(x,D,w,A,T[L+11],14,643717713),A=M(A,x,D,w,T[L+0],20,-373897302),w=M(w,A,x,D,T[L+5],5,-701558691),D=M(D,w,A,x,T[L+10],9,38016083),x=M(x,D,w,A,T[L+15],14,-660478335),A=M(A,x,D,w,T[L+4],20,-405537848),w=M(w,A,x,D,T[L+9],5,568446438),D=M(D,w,A,x,T[L+14],9,-1019803690),x=M(x,D,w,A,T[L+3],14,-187363961),A=M(A,x,D,w,T[L+8],20,1163531501),w=M(w,A,x,D,T[L+13],5,-1444681467),D=M(D,w,A,x,T[L+2],9,-51403784),x=M(x,D,w,A,T[L+7],14,1735328473),w=b(w,A=M(A,x,D,w,T[L+12],20,-1926607734),x,D,T[L+5],4,-378558),D=b(D,w,A,x,T[L+8],11,-2022574463),x=b(x,D,w,A,T[L+11],16,1839030562),A=b(A,x,D,w,T[L+14],23,-35309556),w=b(w,A,x,D,T[L+1],4,-1530992060),D=b(D,w,A,x,T[L+4],11,1272893353),x=b(x,D,w,A,T[L+7],16,-155497632),A=b(A,x,D,w,T[L+10],23,-1094730640),w=b(w,A,x,D,T[L+13],4,681279174),D=b(D,w,A,x,T[L+0],11,-358537222),x=b(x,D,w,A,T[L+3],16,-722521979),A=b(A,x,D,w,T[L+6],23,76029189),w=b(w,A,x,D,T[L+9],4,-640364487),D=b(D,w,A,x,T[L+12],11,-421815835),x=b(x,D,w,A,T[L+15],16,530742520),w=S(w,A=b(A,x,D,w,T[L+2],23,-995338651),x,D,T[L+0],6,-198630844),D=S(D,w,A,x,T[L+7],10,1126891415),x=S(x,D,w,A,T[L+14],15,-1416354905),A=S(A,x,D,w,T[L+5],21,-57434055),w=S(w,A,x,D,T[L+12],6,1700485571),D=S(D,w,A,x,T[L+3],10,-1894986606),x=S(x,D,w,A,T[L+10],15,-1051523),A=S(A,x,D,w,T[L+1],21,-2054922799),w=S(w,A,x,D,T[L+8],6,1873313359),D=S(D,w,A,x,T[L+15],10,-30611744),x=S(x,D,w,A,T[L+6],15,-1560198380),A=S(A,x,D,w,T[L+13],21,1309151649),w=S(w,A,x,D,T[L+4],6,-145523070),D=S(D,w,A,x,T[L+11],10,-1120210379),x=S(x,D,w,A,T[L+2],15,718787259),A=S(A,x,D,w,T[L+9],21,-343485551),w=O(w,V),A=O(A,R),x=O(x,X),D=O(D,Y)}return Array(w,A,x,D)}function y(T,C,w,A,x,D){return O((C=O(O(C,T),O(A,D)))<<x|C>>>32-x,w)}function g(T,C,w,A,x,D,L){return y(C&w|~C&A,T,C,x,D,L)}function M(T,C,w,A,x,D,L){return y(C&A|w&~A,T,C,x,D,L)}function b(T,C,w,A,x,D,L){return y(C^w^A,T,C,x,D,L)}function S(T,C,w,A,x,D,L){return y(w^(C|~A),T,C,x,D,L)}function O(T,C){var w=(65535&T)+(65535&C);return(T>>16)+(C>>16)+(w>>16)<<16|65535&w}n.exports=function(T){return _.hash(T,v,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,c,h,d,f,p,m){n.exports=function(_){for(var v,y=new Array(_),g=0;g<_;g++)!(3&g)&&(v=4294967296*Math.random()),y[g]=v>>>((3&g)<<3)&255;return y}}).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,c,h,d,f,p,m){var _=t("./helpers");function v(M,b){M[b>>5]|=128<<24-b%32,M[15+(b+64>>9<<4)]=b;for(var S,O,T,C=Array(80),w=1732584193,A=-271733879,x=-1732584194,D=271733878,L=-1009589776,V=0;V<M.length;V+=16){for(var R=w,X=A,Y=x,J=D,q=L,re=0;re<80;re++){C[re]=re<16?M[V+re]:g(C[re-3]^C[re-8]^C[re-14]^C[re-16],1);var ee=y(y(g(w,5),(ee=A,O=x,T=D,(S=re)<20?ee&O|~ee&T:!(S<40)&&S<60?ee&O|ee&T|O&T:ee^O^T)),y(y(L,C[re]),(S=re)<20?1518500249:S<40?1859775393:S<60?-1894007588:-899497514)),L=D,D=x,x=g(A,30),A=w,w=ee}w=y(w,R),A=y(A,X),x=y(x,Y),D=y(D,J),L=y(L,q)}return Array(w,A,x,D,L)}function y(M,b){var S=(65535&M)+(65535&b);return(M>>16)+(b>>16)+(S>>16)<<16|65535&S}function g(M,b){return M<<b|M>>>32-b}n.exports=function(M){return _.hash(M,v,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,c,h,d,f,p,m){function _(b,S){var O=(65535&b)+(65535&S);return(b>>16)+(S>>16)+(O>>16)<<16|65535&O}function v(b,S){var O,T=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),w=new Array(64);b[S>>5]|=128<<24-S%32,b[15+(S+64>>9<<4)]=S;for(var A,x,D=0;D<b.length;D+=16){for(var L=C[0],V=C[1],R=C[2],X=C[3],Y=C[4],J=C[5],q=C[6],re=C[7],ee=0;ee<64;ee++)w[ee]=ee<16?b[ee+D]:_(_(_((x=w[ee-2],g(x,17)^g(x,19)^M(x,10)),w[ee-7]),(x=w[ee-15],g(x,7)^g(x,18)^M(x,3))),w[ee-16]),O=_(_(_(_(re,g(x=Y,6)^g(x,11)^g(x,25)),Y&J^~Y&q),T[ee]),w[ee]),A=_(g(A=L,2)^g(A,13)^g(A,22),L&V^L&R^V&R),re=q,q=J,J=Y,Y=_(X,O),X=R,R=V,V=L,L=_(O,A);C[0]=_(L,C[0]),C[1]=_(V,C[1]),C[2]=_(R,C[2]),C[3]=_(X,C[3]),C[4]=_(Y,C[4]),C[5]=_(J,C[5]),C[6]=_(q,C[6]),C[7]=_(re,C[7])}return C}var y=t("./helpers"),g=function(b,S){return b>>>S|b<<32-S},M=function(b,S){return b>>>S};n.exports=function(b){return y.hash(b,v,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,c,h,d,f,p,m){r.read=function(_,v,y,g,D){var b,S,O=8*D-g-1,T=(1<<O)-1,C=T>>1,w=-7,A=y?D-1:0,x=y?-1:1,D=_[v+A];for(A+=x,b=D&(1<<-w)-1,D>>=-w,w+=O;0<w;b=256*b+_[v+A],A+=x,w-=8);for(S=b&(1<<-w)-1,b>>=-w,w+=g;0<w;S=256*S+_[v+A],A+=x,w-=8);if(b===0)b=1-C;else{if(b===T)return S?NaN:1/0*(D?-1:1);S+=Math.pow(2,g),b-=C}return(D?-1:1)*S*Math.pow(2,b-g)},r.write=function(_,v,y,g,M,L){var S,O,T=8*L-M-1,C=(1<<T)-1,w=C>>1,A=M===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=g?0:L-1,D=g?1:-1,L=v<0||v===0&&1/v<0?1:0;for(v=Math.abs(v),isNaN(v)||v===1/0?(O=isNaN(v)?1:0,S=C):(S=Math.floor(Math.log(v)/Math.LN2),v*(g=Math.pow(2,-S))<1&&(S--,g*=2),2<=(v+=1<=S+w?A/g:A*Math.pow(2,1-w))*g&&(S++,g/=2),C<=S+w?(O=0,S=C):1<=S+w?(O=(v*g-1)*Math.pow(2,M),S+=w):(O=v*Math.pow(2,w-1)*Math.pow(2,M),S=0));8<=M;_[y+x]=255&O,x+=D,O/=256,M-=8);for(S=S<<M|O,T+=M;0<T;_[y+x]=255&S,x+=D,S/=256,T-=8);_[y+x-D]|=128*L}}).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,c,h,d,f,p,m){var _,v,y;function g(){}(s=n.exports={}).nextTick=(v=typeof window<"u"&&window.setImmediate,y=typeof window<"u"&&window.postMessage&&window.addEventListener,v?function(M){return window.setImmediate(M)}:y?(_=[],window.addEventListener("message",function(M){var b=M.source;b!==window&&b!==null||M.data!=="process-tick"||(M.stopPropagation(),0<_.length&&_.shift()())},!0),function(M){_.push(M),window.postMessage("process-tick","*")}):function(M){setTimeout(M,0)}),s.title="browser",s.browser=!0,s.env={},s.argv=[],s.on=g,s.addListener=g,s.once=g,s.off=g,s.removeListener=g,s.removeAllListeners=g,s.emit=g,s.binding=function(M){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(M){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)})})(Ii);var Au=Ii.exports;const Cu=hn(Au);var Oi=["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"],Pu=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"],Di=["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"],Tu=Oi,Iu=Tu.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"]),Nr=Di;Nr=Nr.slice().filter(function(o){return!/^(gl\_|texture)/.test(o)});var Ou=Nr.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"]),Du=Gu,Lu=Oi,Li=Pu,ku=Di,Bu=Iu,Fu=Ou,rt=999,ki=9999,zr=0,Vr=1,Bi=2,Fi=3,Ui=4,fn=5,Uu=6,Nu=7,zu=8,Ni=9,Vu=10,zi=11,Ru=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"];function Gu(o){var e=0,t=0,n=rt,r,s,i=[],a=[],c=1,h=0,d=0,f=!1,p=!1,m="",_;o=o||{};var v=ku,y=Lu;o.version==="300 es"&&(v=Fu,y=Bu);for(var g={},M={},e=0;e<v.length;e++)g[v[e]]=!0;for(var e=0;e<y.length;e++)M[y[e]]=!0;return function(J){return a=[],J!==null?S(J):O()};function b(J){J.length&&a.push({type:Ru[n],data:J,position:d,line:c,column:h})}function S(J){e=0,J.toString&&(J=J.toString()),m+=J.replace(/\r\n/g,`
|
|
528
|
+
`),_=m.length;for(var q;r=m[e],e<_;){switch(q=e,n){case zr:e=x();break;case Vr:e=A();break;case Bi:e=w();break;case Fi:e=D();break;case Ui:e=R();break;case zi:e=V();break;case fn:e=X();break;case ki:e=Y();break;case Ni:e=C();break;case rt:e=T();break}if(q!==e)switch(m[q]){case`
|
|
529
|
+
`:h=0,++c;break;default:++h;break}}return t+=e,m=m.slice(e),a}function O(J){return i.length&&b(i.join("")),n=Vu,b("(eof)"),a}function T(){return i=i.length?[]:i,s==="/"&&r==="*"?(d=t+e-1,n=zr,s=r,e+1):s==="/"&&r==="/"?(d=t+e-1,n=Vr,s=r,e+1):r==="#"?(n=Bi,d=t+e,e):/\s/.test(r)?(n=Ni,d=t+e,e):(f=/\d/.test(r),p=/[^\w_]/.test(r),d=t+e,n=f?Ui:p?Fi:ki,e)}function C(){return/[^\s]/g.test(r)?(b(i.join("")),n=rt,e):(i.push(r),s=r,e+1)}function w(){return(r==="\r"||r===`
|
|
530
|
+
`)&&s!=="\\"?(b(i.join("")),n=rt,e):(i.push(r),s=r,e+1)}function A(){return w()}function x(){return r==="/"&&s==="*"?(i.push(r),b(i.join("")),n=rt,e+1):(i.push(r),s=r,e+1)}function D(){if(s==="."&&/\d/.test(r))return n=fn,e;if(s==="/"&&r==="*")return n=zr,e;if(s==="/"&&r==="/")return n=Vr,e;if(r==="."&&i.length){for(;L(i););return n=fn,e}if(r===";"||r===")"||r==="("){if(i.length)for(;L(i););return b(r),n=rt,e+1}var J=i.length===2&&r!=="=";if(/[\w_\d\s]/.test(r)||J){for(;L(i););return n=rt,e}return i.push(r),s=r,e+1}function L(J){var q=0,re,ee;do{if(re=Li.indexOf(J.slice(0,J.length+q).join("")),ee=Li[re],re===-1){if(q--+J.length>0)continue;ee=J.slice(0,1).join("")}return b(ee),d+=ee.length,i=i.slice(ee.length),i.length}while(!0)}function V(){return/[^a-fA-F0-9]/.test(r)?(b(i.join("")),n=rt,e):(i.push(r),s=r,e+1)}function R(){return r==="."||/[eE]/.test(r)?(i.push(r),n=fn,s=r,e+1):r==="x"&&i.length===1&&i[0]==="0"?(n=zi,i.push(r),s=r,e+1):/[^\d]/.test(r)?(b(i.join("")),n=rt,e):(i.push(r),s=r,e+1)}function X(){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)?(b(i.join("")),n=rt,e):(i.push(r),s=r,e+1)}function Y(){if(/[^\d\w_]/.test(r)){var J=i.join("");return M[J]?n=zu:g[J]?n=Nu:n=Uu,b(i.join("")),n=rt,e}return i.push(r),s=r,e+1}}var ju=Du,Eu=Yu;function Yu(o,e){var t=ju(e),n=[];return n=n.concat(t(o)),n=n.concat(t(null)),n}const Wu=hn(Eu);var Xu=Zu;function Zu(o){for(var e=[],t=0;t<o.length;t++)o[t].type!=="eof"&&e.push(o[t].data);return e.join("")}const Vi=hn(Xu);var Ku=qu;function qu(o){var e=null,t=null,n=0,r=0,s=0,i=0,a=0,c=[],h,d,f;for(h=0,d;h<o.length;h++)if(f=o[h],f.data==="{"){if(n&&n++||(d=m(h,Pt(")"),Pt()),d<0)||(i=d,d=m(d,Pt("("),Pt(")")),d<0)||(a=d,d=m(d,dn),d<0)||o[d].type!=="ident"||(t=o[d].data,d=m(d,dn),d<0))continue;n=1,r=h,e=o[d].data,s=d;var p=m(d,dn);switch(o[p]&&o[p].data){case"lowp":case"highp":case"mediump":s=p}}else if(n&&f.data==="}"){if(--n)continue;c.push({name:t,type:e,body:[r+1,h],args:[a,i+1],outer:[s,h+1]})}for(h=0;h<o.length;h++)if(f=o[h],f.data===";"){if(d=m(h,Pt(")"),Pt()),d<0||(i=d,d=m(d,Pt("("),Pt(")")),d<0)||(a=d,d=m(d,dn),d<0)||o[d].type!=="ident"||(t=o[d].data,d=m(d,dn),d<0)||o[d].type==="operator"||o[d].data==="return")continue;e=o[d].data,c.push({name:t,type:e,body:!1,args:[a,i+1],outer:[d,h+1]})}return c.sort(function(_,v){return _.outer[0]-v.outer[0]});function m(_,v,y){for(var g=_-1;g>=0;g--){if(v(o[g]))return g;if(y&&y(o[g]))return-1}return-1}}function Pt(o){return function(e){return e.type==="operator"&&(!o||e.data===o)}}function dn(o){return o.type!=="whitespace"}const Qu=hn(Ku);function Ju(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 Ri(o){var e=Ju(o,"string");return typeof e=="symbol"?e:String(e)}function Ae(o,e,t){return e=Ri(e),e in o?Object.defineProperty(o,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):o[e]=t,o}function Gi(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?Gi(Object(t),!0).forEach(function(n){Ae(o,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(t)):Gi(Object(t)).forEach(function(n){Object.defineProperty(o,n,Object.getOwnPropertyDescriptor(t,n))})}return o}function Hu(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 $u(o,e){if(o==null)return{};var t=Hu(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 eh(o,e){if(!(o instanceof e))throw new TypeError("Cannot call a class as a function")}function th(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,Ri(n.key),n)}}function nh(o,e,t){return e&&th(o.prototype,e),Object.defineProperty(o,"prototype",{writable:!1}),o}function ji(o){if(o===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return o}function Rr(o,e){return Rr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},Rr(o,e)}function rh(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&&Rr(o,e)}function Rn(o){return Rn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Rn(o)}function sh(){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 ih(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 ji(o)}function oh(o){var e=sh();return function(){var n=Rn(o),r;if(e){var s=Rn(this).constructor;r=Reflect.construct(n,arguments,s)}else r=n.apply(this,arguments);return ih(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"},We,Kt,ah=(We={},Ae(We,"".concat(pe.normal),{"#include <beginnormal_vertex>":`
|
|
531
|
+
vec3 objectNormal = `.concat(pe.normal,`;
|
|
271
532
|
#ifdef USE_TANGENT
|
|
272
533
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
273
534
|
#endif
|
|
274
|
-
`)}),Ae(We,"".concat(
|
|
275
|
-
vec3 transformed = `.concat(
|
|
276
|
-
`)}),Ae(We,"".concat(
|
|
277
|
-
vec4 csm_internal_positionUnprojected = `.concat(
|
|
535
|
+
`)}),Ae(We,"".concat(pe.position),{"#include <begin_vertex>":`
|
|
536
|
+
vec3 transformed = `.concat(pe.position,`;
|
|
537
|
+
`)}),Ae(We,"".concat(pe.positionRaw),{"#include <begin_vertex>":`
|
|
538
|
+
vec4 csm_internal_positionUnprojected = `.concat(pe.positionRaw,`;
|
|
278
539
|
mat4x4 csm_internal_unprojectMatrix = projectionMatrix * modelViewMatrix;
|
|
279
540
|
#ifdef USE_INSTANCING
|
|
280
541
|
csm_internal_unprojectMatrix = csm_internal_unprojectMatrix * instanceMatrix;
|
|
281
542
|
#endif
|
|
282
543
|
csm_internal_positionUnprojected = inverse(csm_internal_unprojectMatrix) * csm_internal_positionUnprojected;
|
|
283
544
|
vec3 transformed = csm_internal_positionUnprojected.xyz;
|
|
284
|
-
`)}),Ae(We,"".concat(
|
|
285
|
-
gl_PointSize = `.concat(
|
|
286
|
-
`)}),Ae(We,"".concat(
|
|
545
|
+
`)}),Ae(We,"".concat(pe.pointSize),{"gl_PointSize = size;":`
|
|
546
|
+
gl_PointSize = `.concat(pe.pointSize,`;
|
|
547
|
+
`)}),Ae(We,"".concat(pe.diffuseColor),{"#include <color_fragment>":`
|
|
287
548
|
#include <color_fragment>
|
|
288
|
-
diffuseColor = `.concat(
|
|
289
|
-
`)}),Ae(We,"".concat(
|
|
549
|
+
diffuseColor = `.concat(pe.diffuseColor,`;
|
|
550
|
+
`)}),Ae(We,"".concat(pe.fragColor),{"#include <dithering_fragment>":`
|
|
290
551
|
#include <dithering_fragment>
|
|
291
|
-
gl_FragColor = `.concat(
|
|
292
|
-
`)}),Ae(We,"".concat(
|
|
293
|
-
vec3 totalEmissiveRadiance = `.concat(
|
|
294
|
-
`)}),Ae(We,"".concat(
|
|
552
|
+
gl_FragColor = `.concat(pe.fragColor,`;
|
|
553
|
+
`)}),Ae(We,"".concat(pe.emissive),{"vec3 totalEmissiveRadiance = emissive;":`
|
|
554
|
+
vec3 totalEmissiveRadiance = `.concat(pe.emissive,`;
|
|
555
|
+
`)}),Ae(We,"".concat(pe.roughness),{"#include <roughnessmap_fragment>":`
|
|
295
556
|
#include <roughnessmap_fragment>
|
|
296
|
-
roughnessFactor = `.concat(
|
|
297
|
-
`)}),Ae(We,"".concat(
|
|
557
|
+
roughnessFactor = `.concat(pe.roughness,`;
|
|
558
|
+
`)}),Ae(We,"".concat(pe.metalness),{"#include <metalnessmap_fragment>":`
|
|
298
559
|
#include <metalnessmap_fragment>
|
|
299
|
-
metalnessFactor = `.concat(
|
|
300
|
-
`)}),Ae(We,"".concat(
|
|
560
|
+
metalnessFactor = `.concat(pe.metalness,`;
|
|
561
|
+
`)}),Ae(We,"".concat(pe.ao),{"#include <aomap_fragment>":`
|
|
301
562
|
#include <aomap_fragment>
|
|
302
|
-
reflectedLight.indirectDiffuse *= 1. - `.concat(
|
|
303
|
-
`)}),Ae(We,"".concat(
|
|
563
|
+
reflectedLight.indirectDiffuse *= 1. - `.concat(pe.ao,`;
|
|
564
|
+
`)}),Ae(We,"".concat(pe.bump),{"#include <normal_fragment_maps>":`
|
|
304
565
|
#include <normal_fragment_maps>
|
|
305
566
|
|
|
306
|
-
vec3 csm_internal_orthogonal = `.concat(
|
|
567
|
+
vec3 csm_internal_orthogonal = `.concat(pe.bump," - (dot(").concat(pe.bump,`, normal) * normal);
|
|
307
568
|
vec3 csm_internal_projectedbump = mat3(csm_internal_vModelViewMatrix) * csm_internal_orthogonal;
|
|
308
569
|
normal = normalize(normal - csm_internal_projectedbump);
|
|
309
|
-
`)}),Ae(We,"".concat(
|
|
310
|
-
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity * `.concat(
|
|
570
|
+
`)}),Ae(We,"".concat(pe.depthAlpha),{"gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );":`
|
|
571
|
+
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity * `.concat(pe.depthAlpha,` );
|
|
311
572
|
`),"gl_FragColor = packDepthToRGBA( fragCoordZ );":`
|
|
312
573
|
gl_FragColor = packDepthToRGBA( fragCoordZ );
|
|
313
|
-
gl_FragColor.a *= `.concat(
|
|
314
|
-
`)}),We),
|
|
315
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( `.concat(
|
|
316
|
-
`)}),Ae(
|
|
317
|
-
gl_Position = `.concat(
|
|
318
|
-
`)}),Ae(
|
|
319
|
-
gl_FragColor = `.concat(
|
|
320
|
-
`)}),Ae(
|
|
321
|
-
gl_FragColor = `.concat(
|
|
322
|
-
`)}),
|
|
574
|
+
gl_FragColor.a *= `.concat(pe.depthAlpha,`;
|
|
575
|
+
`)}),We),lh=(Kt={},Ae(Kt,"".concat(pe.position),{"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );":`
|
|
576
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( `.concat(pe.position,`, 1.0 );
|
|
577
|
+
`)}),Ae(Kt,"".concat(pe.positionRaw),{"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );":`
|
|
578
|
+
gl_Position = `.concat(pe.position,`;
|
|
579
|
+
`)}),Ae(Kt,"".concat(pe.diffuseColor),{"gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );":`
|
|
580
|
+
gl_FragColor = `.concat(pe.diffuseColor,`;
|
|
581
|
+
`)}),Ae(Kt,"".concat(pe.fragColor),{"gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );":`
|
|
582
|
+
gl_FragColor = `.concat(pe.fragColor,`;
|
|
583
|
+
`)}),Kt),ch=`
|
|
323
584
|
|
|
324
585
|
#ifdef IS_VERTEX
|
|
325
586
|
// csm_Position & csm_PositionRaw
|
|
@@ -378,18 +639,18 @@ list should be an Array.`),C.length===0)return new _(0);if(C.length===1)return C
|
|
|
378
639
|
|
|
379
640
|
float csm_DepthAlpha = 1.0;
|
|
380
641
|
#endif
|
|
381
|
-
`,
|
|
642
|
+
`,uh=`
|
|
382
643
|
varying mat4 csm_internal_vModelViewMatrix;
|
|
383
|
-
`,
|
|
644
|
+
`,hh=`
|
|
384
645
|
csm_internal_vModelViewMatrix = modelViewMatrix;
|
|
385
|
-
`,
|
|
646
|
+
`,fh=`
|
|
386
647
|
varying mat4 csm_internal_vModelViewMatrix;
|
|
387
|
-
`,
|
|
648
|
+
`,dh=`
|
|
388
649
|
|
|
389
|
-
`,
|
|
390
|
-
`+v,
|
|
650
|
+
`,Xe,ph=(Xe={},Ae(Xe,"".concat(pe.position),"*"),Ae(Xe,"".concat(pe.positionRaw),"*"),Ae(Xe,"".concat(pe.normal),"*"),Ae(Xe,"".concat(pe.pointSize),["PointsMaterial"]),Ae(Xe,"".concat(pe.diffuseColor),"*"),Ae(Xe,"".concat(pe.fragColor),"*"),Ae(Xe,"".concat(pe.emissive),["MeshStandardMaterial","MeshPhysicalMaterial"]),Ae(Xe,"".concat(pe.roughness),["MeshStandardMaterial","MeshPhysicalMaterial"]),Ae(Xe,"".concat(pe.metalness),["MeshStandardMaterial","MeshPhysicalMaterial"]),Ae(Xe,"".concat(pe.ao),["MeshStandardMaterial","MeshPhysicalMaterial","MeshBasicMaterial","MeshLambertMaterial","MeshPhongMaterial","MeshToonMaterial"]),Ae(Xe,"".concat(pe.bump),["MeshLambertMaterial","MeshMatcapMaterial","MeshNormalMaterial","MeshPhongMaterial","MeshPhysicalMaterial","MeshStandardMaterial","MeshToonMaterial","ShadowMaterial"]),Ae(Xe,"".concat(pe.depthAlpha),"*"),Xe),mh=["baseMaterial","fragmentShader","vertexShader","uniforms","patchMap","cacheKey","silent"],gh=function(e,t,n){return e.split(t).join(n)},yh=function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")},_h=function(e,t){return new RegExp("\\b".concat(yh(t),"\\b")).test(e)};function vh(o){try{new o}catch(e){if(e.message.indexOf("is not a constructor")>=0)return!1}return!0}function xh(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",c=r[0]==="constructor";return(s||i||a)&&!c}).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 wh(o){var e=o.toString().trim(),t=e.substring(e.indexOf("{")+1,e.lastIndexOf("}"));return t.trim().length===0}function Ei(o){return o.replace(/\s/g,"")}function bh(o,e,t){var n=o.lastIndexOf(e);return n===-1?o:o.substring(0,n)+t+o.substring(n+e.length)}var Mh=function(o){rh(t,o);var e=oh(t);function t(n){var r,s=n.baseMaterial,i=n.fragmentShader,a=n.vertexShader,c=n.uniforms,h=n.patchMap,d=n.cacheKey,f=n.silent,p=$u(n,mh);eh(this,t);var m;if(vh(s)?m=new s(p):(m=s,Object.assign(m,p)),m.type==="RawShaderMaterial")throw new Error("CustomShaderMaterial does not support RawShaderMaterial");r=e.call(this),xh(ji(r),m,f),r.__csm={patchMap:h||{},fragmentShader:i||"",vertexShader:a||"",cacheKey:d,baseMaterial:s,instanceID:Jr.MathUtils.generateUUID(),type:m.type,isAlreadyExtended:!wh(m.onBeforeCompile),cacheHash:"",silent:f},r.uniforms=Zt(Zt({},r.uniforms||{}),c||{});{var _=r.__csm,v=_.fragmentShader,y=_.vertexShader,g=r.uniforms;r.__csm.cacheHash=r.getCacheHash(),r.generateMaterial(v,y,g)}return r}return nh(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,c=this.uniforms,h=this.getCacheHash();this.__csm.cacheHash=h,this.generateMaterial(i,a,c)}},{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,c=Object.values(a).reduce(function(d,f){var p=f.value;return d+JSON.stringify(p)},""),h=Ei(s)+Ei(i)+c;return h.trim().length>0?Cu(h):this.customProgramCacheKey()}},{key:"generateMaterial",value:function(r,s,i){var a=this,c=this.parseShader(r),h=this.parseShader(s);this.uniforms=i||{},this.customProgramCacheKey=function(){return a.__csm.cacheHash};var d=function(m){try{if(c){var _=a.patchShader(c,m.fragmentShader,!0);m.fragmentShader=a.getMaterialDefine()+_}if(h){var v=a.patchShader(h,m.vertexShader);m.vertexShader=`#define IS_VERTEX;
|
|
651
|
+
`+v,m.vertexShader=a.getMaterialDefine()+m.vertexShader}m.uniforms=Zt(Zt({},m.uniforms),a.uniforms),a.uniforms=m.uniforms}catch(y){console.error(y)}};if(this.__csm.isAlreadyExtended){var f=this.onBeforeCompile;this.onBeforeCompile=function(p,m){f(p,m),d(p)}}else this.onBeforeCompile=d;this.needsUpdate=!0}},{key:"patchShader",value:function(r,s,i){var a=this,c=s,h=Zt(Zt({},this.getPatchMapForMaterial()),this.__csm.patchMap);Object.keys(h).forEach(function(p){Object.keys(h[p]).forEach(function(m){var _=ph[p],v=a.__csm.type;if(p==="*"||_h(r.main,p))if(!_||Array.isArray(_)&&_.includes(v)||_==="*")c=gh(c,m,h[p][m]);else throw new Error("CSM: ".concat(p," is not available in ").concat(v,". Shader cannot compile."))})}),c=c.replace("void main() {",`
|
|
391
652
|
#ifndef CSM_IS_HEAD_DEFAULTS_DEFINED
|
|
392
|
-
`.concat(i?
|
|
653
|
+
`.concat(i?fh:uh,`
|
|
393
654
|
#define CSM_IS_HEAD_DEFAULTS_DEFINED 1
|
|
394
655
|
#endif
|
|
395
656
|
|
|
@@ -397,17 +658,17 @@ list should be an Array.`),C.length===0)return new _(0);if(C.length===1)return C
|
|
|
397
658
|
|
|
398
659
|
void main() {
|
|
399
660
|
#ifndef CSM_IS_DEFAULTS_DEFINED
|
|
400
|
-
`).concat(
|
|
661
|
+
`).concat(ch,`
|
|
401
662
|
#define CSM_IS_DEFAULTS_DEFINED 1
|
|
402
663
|
#endif
|
|
403
664
|
|
|
404
665
|
#ifndef CSM_IS_MAIN_DEFAULTS_DEFINED
|
|
405
|
-
`).concat(i?
|
|
666
|
+
`).concat(i?dh:hh,`
|
|
406
667
|
#define CSM_IS_MAIN_DEFAULTS_DEFINED 1
|
|
407
668
|
#endif
|
|
408
669
|
|
|
409
670
|
// CSM_START
|
|
410
|
-
`));var
|
|
671
|
+
`));var d=this.__csm.isAlreadyExtended,f=c.includes("// CSM_END");return d&&f?c=bh(c,"// CSM_END",`
|
|
411
672
|
// CSM_END
|
|
412
673
|
`.concat(r.main,`
|
|
413
674
|
// CSM_END
|
|
@@ -415,18 +676,18 @@ list should be an Array.`),C.length===0)return new _(0);if(C.length===1)return C
|
|
|
415
676
|
// CSM_START
|
|
416
677
|
`.concat(r.main,`
|
|
417
678
|
// CSM_END
|
|
418
|
-
`)),c=r.defines+c,c}},{key:"parseShader",value:function(r){if(r){var s=r.replace(/\/\*\*(.*?)\*\/|\/\/(.*?)\n/gm,""),i=
|
|
679
|
+
`)),c=r.defines+c,c}},{key:"parseShader",value:function(r){if(r){var s=r.replace(/\/\*\*(.*?)\*\/|\/\/(.*?)\n/gm,""),i=Wu(s),a=Qu(i),c=a.map(function(f){return f.name}).indexOf("main"),h=Vi(i.slice(0,c>=0?a[c].outer[0]:void 0)),d=c>=0?this.getShaderFromIndex(i,a[c].body):"";return{defines:"",header:h,main:d}}}},{key:"getMaterialDefine",value:function(){var r=this.__csm.type;return r?"#define IS_".concat(r.toUpperCase(),`;
|
|
419
680
|
`):`#define IS_UNKNOWN;
|
|
420
|
-
`}},{key:"getPatchMapForMaterial",value:function(){switch(this.__csm.type){case"ShaderMaterial":return
|
|
681
|
+
`}},{key:"getPatchMapForMaterial",value:function(){switch(this.__csm.type){case"ShaderMaterial":return lh;default:return ah}}},{key:"getShaderFromIndex",value:function(r,s){return Vi(r.slice(s[0],s[1]))}}]),t}(Jr.Material);const Sh=["args"],Ah=u.defineComponent({__name:"index",props:{baseMaterial:{},vertexShader:{},fragmentShader:{},silent:{type:Boolean},uniforms:{}},setup(o,{expose:e}){const t=o;Ie(t);const n=u.shallowRef(null),{extend:r}=te.useTresContext();return r({CustomShaderMaterial:Mh}),e({instance:n}),(s,i)=>(u.openBlock(),u.createElementBlock("TresCustomShaderMaterial",{ref_key:"customShaderMaterialClass",ref:n,args:[t]},null,8,Sh))}}),Ch=Number.parseInt(l.REVISION.replace(/\D+/g,""));class Ph extends l.ShaderMaterial{constructor(t=new l.Vector2){super({uniforms:{inputBuffer:new l.Uniform(null),depthBuffer:new l.Uniform(null),resolution:new l.Uniform(new l.Vector2),texelSize:new l.Uniform(new l.Vector2),halfTexelSize:new l.Uniform(new l.Vector2),kernel:new l.Uniform(0),scale:new l.Uniform(1),cameraNear:new l.Uniform(0),cameraFar:new l.Uniform(1),depthEdge0:new l.Uniform(0),depthEdge1:new l.Uniform(1),depthScale:new l.Uniform(0),depthBias:new l.Uniform(.25)},fragmentShader:`#include <common>
|
|
421
682
|
#include <dithering_pars_fragment>
|
|
422
683
|
uniform sampler2D inputBuffer;
|
|
423
684
|
uniform sampler2D depthBuffer;
|
|
424
685
|
uniform float cameraNear;
|
|
425
686
|
uniform float cameraFar;
|
|
426
|
-
uniform float
|
|
427
|
-
uniform float
|
|
687
|
+
uniform float depthEdge0;
|
|
688
|
+
uniform float depthEdge1;
|
|
428
689
|
uniform float depthScale;
|
|
429
|
-
uniform float
|
|
690
|
+
uniform float depthBias;
|
|
430
691
|
varying vec2 vUv;
|
|
431
692
|
varying vec2 vUv0;
|
|
432
693
|
varying vec2 vUv1;
|
|
@@ -438,20 +699,23 @@ list should be an Array.`),C.length===0)return new _(0);if(C.length===1)return C
|
|
|
438
699
|
|
|
439
700
|
#ifdef USE_DEPTH
|
|
440
701
|
vec4 depth = texture2D(depthBuffer, vUv);
|
|
441
|
-
depthFactor = smoothstep(
|
|
442
|
-
|
|
443
|
-
|
|
702
|
+
depthFactor = smoothstep(
|
|
703
|
+
1.0 - depthEdge1, 1.0 - depthEdge0,
|
|
704
|
+
1.0 - (depth.r * depth.a) + depthBias
|
|
705
|
+
);
|
|
706
|
+
depthFactor = clamp(depthScale * depthFactor + 0.25, 0.0, 1.0);
|
|
444
707
|
#endif
|
|
445
|
-
|
|
446
|
-
vec4 sum = texture2D(inputBuffer, mix(vUv0, vUv, depthFactor));
|
|
447
|
-
sum += texture2D(inputBuffer, mix(vUv1, vUv, depthFactor));
|
|
448
|
-
sum += texture2D(inputBuffer, mix(vUv2, vUv, depthFactor));
|
|
449
|
-
sum += texture2D(inputBuffer, mix(vUv3, vUv, depthFactor));
|
|
450
|
-
gl_FragColor = sum * 0.25 ;
|
|
451
708
|
|
|
709
|
+
gl_FragColor = 0.25 * (
|
|
710
|
+
texture2D(inputBuffer, mix(vUv0, vUv, depthFactor))
|
|
711
|
+
+ texture2D(inputBuffer, mix(vUv1, vUv, depthFactor))
|
|
712
|
+
+ texture2D(inputBuffer, mix(vUv2, vUv, depthFactor))
|
|
713
|
+
+ texture2D(inputBuffer, mix(vUv3, vUv, depthFactor))
|
|
714
|
+
);
|
|
715
|
+
|
|
452
716
|
#include <dithering_fragment>
|
|
453
717
|
#include <tonemapping_fragment>
|
|
454
|
-
#include <${
|
|
718
|
+
#include <${Ch>=154?"colorspace_fragment":"encodings_fragment"}>
|
|
455
719
|
}`,vertexShader:`uniform vec2 texelSize;
|
|
456
720
|
uniform vec2 halfTexelSize;
|
|
457
721
|
uniform float kernel;
|
|
@@ -473,93 +737,93 @@ list should be an Array.`),C.length===0)return new _(0);if(C.length===1)return C
|
|
|
473
737
|
vUv3 = vec2(uv.x - dUv.x, uv.y - dUv.y);
|
|
474
738
|
|
|
475
739
|
gl_Position = vec4(position.xy, 1.0, 1.0);
|
|
476
|
-
}`,blending:l.NoBlending,depthWrite:!1,depthTest:!1});
|
|
740
|
+
}`,blending:l.NoBlending,depthWrite:!1,depthTest:!1});ue(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 Th{constructor({resolution:e,width:t=500,height:n=500,depthEdge0:r=0,depthEdge1:s=1,depthScale:i=0,depthBias:a=.25}){ue(this,"renderTargetA");ue(this,"renderTargetB");ue(this,"convolutionMaterial");ue(this,"scene");ue(this,"camera");ue(this,"screen");ue(this,"renderToScreen",!1);this.renderTargetA=new l.WebGLRenderTarget(e,e,{minFilter:l.LinearFilter,magFilter:l.LinearFilter,stencilBuffer:!1,depthBuffer:!1,type:l.HalfFloatType}),this.renderTargetB=this.renderTargetA.clone(),this.convolutionMaterial=new Ph,this.convolutionMaterial.setTexelSize(1/t,1/n),this.convolutionMaterial.setResolution(new l.Vector2(t,n)),this.scene=new l.Scene,this.camera=new l.Camera,this.convolutionMaterial.uniforms.depthEdge0.value=r,this.convolutionMaterial.uniforms.depthEdge1.value=s,this.convolutionMaterial.uniforms.depthScale.value=i,this.convolutionMaterial.uniforms.depthBias.value=a,this.convolutionMaterial.defines.USE_DEPTH=i>0;const c=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),h=new Float32Array([0,0,2,0,0,2]),d=new l.BufferGeometry;d.setAttribute("position",new l.BufferAttribute(c,3)),d.setAttribute("uv",new l.BufferAttribute(h,2)),this.screen=new l.Mesh(d,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,c=this.convolutionMaterial,h=c.uniforms;h.depthBuffer.value=t.depthTexture;const d=c.kernel;let f=t,p,m,_;for(m=0,_=d.length-1;m<_;++m)p=m&1?a:i,h.kernel.value=d[m],h.inputBuffer.value=f.texture,e.setRenderTarget(p),e.render(r,s),f=p;h.kernel.value=d[m],h.inputBuffer.value=f.texture,e.setRenderTarget(this.renderToScreen?null:n),e.render(r,s)}dispose(){this.screen.material.dispose(),this.screen.geometry.dispose(),this.renderTargetA.dispose(),this.renderTargetB.dispose(),this.convolutionMaterial.dispose()}}class Ih extends l.MeshStandardMaterial{constructor(t={}){super(t);ue(this,"_tDepth",{value:null});ue(this,"_distortionMap",{value:null});ue(this,"_tSharp",{value:null});ue(this,"_tBlur",{value:null});ue(this,"_textureMatrix",{value:null});ue(this,"_mix",{value:.5});ue(this,"_sharpMix",{value:0});ue(this,"_blurMixSmooth",{value:0});ue(this,"_blurMixRough",{value:0});ue(this,"_sharpDepthEdgeMin",{value:.9});ue(this,"_sharpDepthEdgeMax",{value:1});ue(this,"_sharpDepthScale",{value:0});ue(this,"_sharpDepthBias",{value:0});ue(this,"_distortion",{value:1});this.setValues(t)}onBeforeCompile(t){var n;(n=t.defines)!=null&&n.USE_UV||(t.defines.USE_UV="");for(const r of Object.keys(t.defines))t.defines[r.toUpperCase()]=t.defines[r];t.uniforms.tSharp=this._tSharp,t.uniforms.tDepth=this._tDepth,t.uniforms.tBlur=this._tBlur,t.uniforms.distortionMap=this._distortionMap,t.uniforms.textureMatrix=this._textureMatrix,t.uniforms.mixMain=this._mix,t.uniforms.sharpMix=this._sharpMix,t.uniforms.sharpDepthScale=this._sharpDepthScale,t.uniforms.sharpDepthEdgeMin=this._sharpDepthEdgeMin,t.uniforms.sharpDepthEdgeMax=this._sharpDepthEdgeMax,t.uniforms.sharpDepthBias=this._sharpDepthBias,t.uniforms.blurMixSmooth=this._blurMixSmooth,t.uniforms.blurMixRough=this._blurMixRough,t.uniforms.distortion=this._distortion,t.vertexShader=`
|
|
477
741
|
uniform mat4 textureMatrix;
|
|
478
742
|
varying vec4 my_vUv;
|
|
479
743
|
${t.vertexShader}`,t.vertexShader=t.vertexShader.replace("#include <project_vertex>",`#include <project_vertex>
|
|
480
744
|
my_vUv = textureMatrix * vec4( position, 1.0 );
|
|
481
745
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );`),t.fragmentShader=`
|
|
482
|
-
uniform sampler2D
|
|
483
|
-
uniform sampler2D
|
|
746
|
+
uniform sampler2D tSharp;
|
|
747
|
+
uniform sampler2D tBlur;
|
|
484
748
|
uniform sampler2D tDepth;
|
|
485
749
|
uniform sampler2D distortionMap;
|
|
486
750
|
uniform float distortion;
|
|
487
751
|
uniform float cameraNear;
|
|
488
752
|
uniform float cameraFar;
|
|
489
|
-
uniform
|
|
490
|
-
uniform float
|
|
491
|
-
uniform float
|
|
492
|
-
uniform float
|
|
493
|
-
uniform float
|
|
494
|
-
uniform float
|
|
495
|
-
uniform float
|
|
496
|
-
uniform float
|
|
497
|
-
uniform float depthToBlurRatioBias;
|
|
753
|
+
uniform float mixMain;
|
|
754
|
+
uniform float sharpMix;
|
|
755
|
+
uniform float blurMixSmooth;
|
|
756
|
+
uniform float blurMixRough;
|
|
757
|
+
uniform float sharpDepthScale;
|
|
758
|
+
uniform float sharpDepthBias;
|
|
759
|
+
uniform float sharpDepthEdgeMin;
|
|
760
|
+
uniform float sharpDepthEdgeMax;
|
|
498
761
|
varying vec4 my_vUv;
|
|
499
762
|
${t.fragmentShader}`,t.fragmentShader=t.fragmentShader.replace("#include <emissivemap_fragment>",`#include <emissivemap_fragment>
|
|
500
763
|
|
|
501
|
-
float distortionFactor = 0.0;
|
|
502
|
-
#ifdef USE_DISTORTION
|
|
503
|
-
distortionFactor = texture2D(distortionMap, vUv).r * distortion;
|
|
504
|
-
#endif
|
|
505
|
-
|
|
506
764
|
vec4 new_vUv = my_vUv;
|
|
507
|
-
new_vUv.x += distortionFactor;
|
|
508
|
-
new_vUv.y += distortionFactor;
|
|
509
|
-
|
|
510
|
-
vec4 base = texture2DProj(tDiffuse, new_vUv);
|
|
511
|
-
vec4 blur = texture2DProj(tDiffuseBlur, new_vUv);
|
|
512
765
|
|
|
513
|
-
|
|
766
|
+
#ifdef USE_DISTORTION
|
|
767
|
+
float distortionFactor = (texture(distortionMap, vUv).r - 0.5) * distortion;
|
|
768
|
+
new_vUv.x += distortionFactor;
|
|
769
|
+
new_vUv.y += distortionFactor;
|
|
770
|
+
#endif
|
|
514
771
|
|
|
515
772
|
#ifdef USE_NORMALMAP
|
|
516
|
-
|
|
517
|
-
vec4 normalColor =
|
|
773
|
+
|
|
774
|
+
vec4 normalColor = texture(normalMap, vUv * normalScale);
|
|
518
775
|
vec3 my_normal = normalize( vec3( normalColor.r * 2.0 - 1.0, normalColor.b, normalColor.g * 2.0 - 1.0 ) );
|
|
519
776
|
vec3 coord = new_vUv.xyz / new_vUv.w;
|
|
520
|
-
normal_uv = coord.xy + coord.z * my_normal.xz * 0.05;
|
|
521
|
-
vec4 base_normal = texture2D(tDiffuse, normal_uv);
|
|
522
|
-
vec4 blur_normal = texture2D(tDiffuseBlur, normal_uv);
|
|
523
|
-
merge = base_normal;
|
|
524
|
-
blur = blur_normal;
|
|
525
|
-
#endif
|
|
777
|
+
vec2 normal_uv = coord.xy + coord.z * my_normal.xz * 0.05;
|
|
526
778
|
|
|
527
|
-
|
|
528
|
-
float blurFactor = 0.0;
|
|
779
|
+
vec4 sharp = texture(tSharp, normal_uv);
|
|
529
780
|
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
781
|
+
#ifdef USE_BLUR
|
|
782
|
+
vec4 blur = texture(tBlur, normal_uv);
|
|
783
|
+
#endif
|
|
784
|
+
|
|
785
|
+
#ifdef USE_DEPTH
|
|
786
|
+
vec4 depth = texture(tDepth, normal_uv);
|
|
787
|
+
#endif
|
|
788
|
+
|
|
789
|
+
#else
|
|
790
|
+
|
|
791
|
+
vec4 sharp = textureProj(tSharp, new_vUv);
|
|
535
792
|
|
|
536
793
|
#ifdef USE_BLUR
|
|
537
|
-
blur =
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
794
|
+
vec4 blur = textureProj(tBlur, new_vUv);
|
|
795
|
+
#endif
|
|
796
|
+
|
|
797
|
+
#ifdef USE_DEPTH
|
|
798
|
+
vec4 depth = textureProj(tDepth, new_vUv);
|
|
541
799
|
#endif
|
|
542
800
|
|
|
543
801
|
#endif
|
|
544
802
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
803
|
+
#ifdef USE_DEPTH
|
|
804
|
+
float depthFactor = smoothstep(
|
|
805
|
+
1.0 - sharpDepthEdgeMax, 1.0 - sharpDepthEdgeMin,
|
|
806
|
+
1.0 - (depth.r * depth.a) + sharpDepthBias
|
|
807
|
+
);
|
|
808
|
+
depthFactor = clamp(sharpDepthScale * depthFactor, 0.0, 1.0);
|
|
809
|
+
|
|
810
|
+
sharp *= depthFactor;
|
|
549
811
|
#endif
|
|
550
812
|
|
|
813
|
+
sharp *= (1.0 - roughnessFactor);
|
|
814
|
+
`),t.fragmentShader=t.fragmentShader.replace("#include <opaque_fragment>",`
|
|
815
|
+
|
|
551
816
|
#ifdef USE_BLUR
|
|
552
|
-
|
|
553
|
-
|
|
817
|
+
outgoingLight += mixMain * (
|
|
818
|
+
vec3(sharp) * sharpMix
|
|
819
|
+
+ vec3(blur) * (blurMixSmooth * (1.0 - roughnessFactor) + blurMixRough * roughnessFactor)
|
|
820
|
+
);
|
|
821
|
+
#else
|
|
822
|
+
outgoingLight += mixMain * vec3(sharp) * sharpMix;
|
|
554
823
|
#endif
|
|
555
824
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
newMerge.g = (merge.g - 0.5) * mixContrast + 0.5;
|
|
559
|
-
newMerge.b = (merge.b - 0.5) * mixContrast + 0.5;
|
|
560
|
-
|
|
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","distortion-map","mix-contrast","defines-USE_BLUR","defines-USE_DEPTH","defines-USE_DISTORTION"],Qu=u.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(Y,G){let Q;return Y.traverse(K=>{K.isMesh&&K.material&&K.material.uuid===G&&(Q=K)}),Q}const n={reflectorPlane:new l.Plane,normal:new l.Vector3,reflectorWorldPosition:new l.Vector3,cameraWorldPosition:new l.Vector3,rotationMatrix:new l.Matrix4,lookAtPosition:new l.Vector3(0,0,-1),clipPlane:new l.Vector4,view:new l.Vector3,target:new l.Vector3,q:new l.Vector4,virtualCamera:new l.PerspectiveCamera,textureMatrix:new l.Matrix4},{resolution:r,minDepthThreshold:s,maxDepthThreshold:i,depthScale:a,depthToBlurRatioBias:c,blur:h,mirror:f,mixBlur:d,mixStrength:p,distortion:g,distortionMap:x,mixContrast:v}=u.toRefs(e),{camera:_,scene:m,renderer:M,extend:b}=ie.useTresContext();b({MeshReflectorMaterial:qu});const S=u.shallowRef(),L=u.shallowRef(),P=u.shallowRef(),T=u.shallowRef(),y=u.computed(()=>typeof h.value=="number"?[h.value,h.value]:h.value),A=u.computed(()=>y.value[0]>0||y.value[1]>0);function w(Y){var Q,K;if(n.reflectorWorldPosition.setFromMatrixPosition(Y.matrixWorld),n.cameraWorldPosition.setFromMatrixPosition((Q=_.value)==null?void 0:Q.matrixWorld),n.rotationMatrix.extractRotation(Y.matrixWorld),n.normal.set(0,0,1),n.normal.applyMatrix4(n.rotationMatrix),n.reflectorWorldPosition.addScaledVector(n.normal,e.reflectorOffset),n.view.subVectors(n.reflectorWorldPosition,n.cameraWorldPosition),n.view.dot(n.normal)>0)return;n.view.reflect(n.normal).negate(),n.view.add(n.reflectorWorldPosition),n.rotationMatrix.extractRotation((K=_.value)==null?void 0:K.matrixWorld),n.lookAtPosition.set(0,0,-1),n.lookAtPosition.applyMatrix4(n.rotationMatrix),n.lookAtPosition.add(n.cameraWorldPosition),n.target.subVectors(n.reflectorWorldPosition,n.lookAtPosition),n.target.reflect(n.normal).negate(),n.target.add(n.reflectorWorldPosition),n.virtualCamera.position.copy(n.view),n.virtualCamera.up.set(0,1,0),n.virtualCamera.up.applyMatrix4(n.rotationMatrix),n.virtualCamera.up.reflect(n.normal),n.virtualCamera.lookAt(n.target),n.virtualCamera.far=(_==null?void 0:_.value).far,n.virtualCamera.updateMatrixWorld(),n.virtualCamera.projectionMatrix.copy((_==null?void 0:_.value).projectionMatrix),n.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.textureMatrix.multiply(n.virtualCamera.projectionMatrix),n.textureMatrix.multiply(n.virtualCamera.matrixWorldInverse),n.textureMatrix.multiply(Y.matrixWorld),n.reflectorPlane.setFromNormalAndCoplanarPoint(n.normal,n.reflectorWorldPosition),n.reflectorPlane.applyMatrix4(n.virtualCamera.matrixWorldInverse),n.clipPlane.set(n.reflectorPlane.normal.x,n.reflectorPlane.normal.y,n.reflectorPlane.normal.z,n.reflectorPlane.constant);const G=n.virtualCamera.projectionMatrix;n.q.x=(Math.sign(n.clipPlane.x)+G.elements[8])/G.elements[0],n.q.y=(Math.sign(n.clipPlane.y)+G.elements[9])/G.elements[5],n.q.z=-1,n.q.w=(1+G.elements[10])/G.elements[14],n.clipPlane.multiplyScalar(2/n.clipPlane.dot(n.q)),G.elements[2]=n.clipPlane.x,G.elements[6]=n.clipPlane.y,G.elements[10]=n.clipPlane.z+1,G.elements[14]=n.clipPlane.w}u.watchEffect(()=>{var G;(G=S.value)==null||G.texture.dispose();const Y={minFilter:l.LinearFilter,magFilter:l.LinearFilter,type:l.HalfFloatType};S.value=new l.WebGLRenderTarget(r.value,r.value,{...Y,depthBuffer:!0,depthTexture:new l.DepthTexture(r.value,r.value,l.DepthFormat,l.UnsignedShortType)}),L.value=new l.WebGLRenderTarget(r.value,r.value,Y),P.value=new Zu({resolution:r.value,width:y.value[0],height:y.value[1],minDepthThreshold:s.value,maxDepthThreshold:i.value,depthScale:a.value,depthToBlurRatioBias:c.value}),T.value={mirror:f,textureMatrix:n.textureMatrix,mixBlur:d,tDiffuse:S.value.texture,tDepth:S.value.depthTexture,tDiffuseBlur:S.value.texture,hasBlur:A,mixStrength:p,minDepthThreshold:s,maxDepthThreshold:i,depthScale:a,depthToBlurRatioBias:c,distortion:g,distortionMap:x.value,mixContrast:v,"defines-USE_BLUR":A.value?"":void 0,"defines-USE_DEPTH":a.value>0?"":void 0,"defines-USE_DISTORTION":x.value?"":void 0}});const D=u.shallowRef(),{onLoop:k}=ie.useRenderLoop();k(()=>{var K;if(!D.value||!M.value||!S.value||!_.value)return;const Y=t(m.value,D.value.uuid);if(!Y)return;Y.visible=!1;const G=M.value.xr.enabled,Q=M.value.shadowMap.autoUpdate;w(Y),M.value.shadowMap.autoUpdate=!1,M.value.setRenderTarget(S.value),M.value.autoClear||M.value.clear(),M.value.render(m.value,n.virtualCamera),(K=P==null?void 0:P.value)==null||K.render(M.value,S.value,L.value),M.value.xr.enabled=G,M.value.shadowMap.autoUpdate=Q,Y.visible=!0,M.value.setRenderTarget(null)});const R=u.useAttrs(),V=u.computed(()=>{const Y={};return Object.assign(Y,e),Object.assign(Y,R.value),Y});return u.onBeforeUnmount(()=>{var Y,G;(Y=S==null?void 0:S.value)==null||Y.dispose(),(G=L==null?void 0:L.value)==null||G.dispose()}),(Y,G)=>{var Q,K,ne;return u.openBlock(),u.createElementBlock("TresMeshReflectorMaterial",u.mergeProps({key:`key${T.value["defines-USE_BLUR"]}${T.value["defines-USE_DEPTH"]}${T.value["defines-USE_DISTORTION"]}`,ref_key:"materialRef",ref:D},V.value,{"texture-matrix":n.textureMatrix,mirror:u.unref(f),"t-diffuse":(Q=S.value)==null?void 0:Q.texture,"t-depth":(K=S.value)==null?void 0:K.depthTexture,"t-diffuse-blur":(ne=L.value)==null?void 0:ne.texture,"has-blur":A.value,"mix-strength":u.unref(p),"min-depth-threshold":u.unref(s),"max-depth-threshold":u.unref(i),"depth-scale":u.unref(a),"depth-to-blur-ratio-bias":u.unref(c),distortion:u.unref(g),"distortion-map":u.unref(x),"mix-contrast":u.unref(v),"defines-USE_BLUR":A.value?"":void 0,"defines-USE_DEPTH":u.unref(a)>0?"":void 0,"defines-USE_DISTORTION":u.unref(x)?"":void 0}),null,16,Ku)}}});class Fi extends l.ShaderMaterial{constructor(e={}){super(),this.vertexShader=`
|
|
825
|
+
#include <opaque_fragment>
|
|
826
|
+
`)}get tSharp(){return this._tSharp.value}set tSharp(t){this._tSharp.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 tBlur(){return this._tBlur.value}set tBlur(t){this._tBlur.value=t}get textureMatrix(){return this._textureMatrix.value}set textureMatrix(t){this._textureMatrix.value=t}get sharpMix(){return this._sharpMix.value}set sharpMix(t){this._sharpMix.value=t}get blurMixSmooth(){return this._blurMixSmooth.value}set blurMixSmooth(t){this._blurMixSmooth.value=t}get blurMixRough(){return this._blurMixRough.value}set blurMixRough(t){this._blurMixRough.value=t}get mix(){return this._mix.value}set mix(t){this._mix.value=t}get sharpDepthScale(){return this._sharpDepthScale.value}set sharpDepthScale(t){this._sharpDepthScale.value=t}get sharpDepthBias(){return this._sharpDepthBias.value}set sharpDepthBias(t){this._sharpDepthBias.value=t}get sharpDepthEdgeMin(){return this._sharpDepthEdgeMin.value}set sharpDepthEdgeMin(t){this._sharpDepthEdgeMin.value=t}get sharpDepthEdgeMax(){return this._sharpDepthEdgeMax.value}set sharpDepthEdgeMax(t){this._sharpDepthEdgeMax.value=t}get distortion(){return this._distortion.value}set distortion(t){this._distortion.value=t}}const Oh=["texture-matrix","t-sharp","t-depth","t-blur","defines-USE_BLUR","defines-USE_DEPTH","defines-USE_DISTORTION"],Dh=u.defineComponent({__name:"index",props:{resolution:{default:256},mix:{default:1},sharpMix:{default:1},sharpDepthScale:{default:1},sharpDepthBias:{default:0},sharpDepthEdgeMin:{default:0},sharpDepthEdgeMax:{default:.2},blurMixSmooth:{default:1},blurMixRough:{default:1},blurDepthScale:{default:1},blurDepthBias:{default:0},blurDepthEdgeMin:{default:0},blurDepthEdgeMax:{default:.2},blurSize:{default:()=>[0,0]},distortionMap:{},distortion:{default:0},reflectorOffset:{default:0},color:{default:()=>new l.Color(3355443)},roughness:{default:1},metalness:{default:0},map:{},lightMap:{},lightMapIntensity:{default:1},aoMap:{},aoMapIntensity:{default:1},emissive:{default:()=>new l.Color(0)},emissiveIntensity:{default:1},emissiveMap:{},bumpMap:{},bumpScale:{default:1},normalMap:{},normalMapType:{default:l.TangentSpaceNormalMap},normalScale:{default:()=>new l.Vector2(1,1)},displacementMap:{},displacementScale:{default:1},displacementBias:{default:0},roughnessMap:{default:null},metalnessMap:{},alphaMap:{},envMap:{},envMapRotation:{default:()=>new l.Euler},envMapIntensity:{default:1},wireframe:{type:Boolean,default:!1},wireframeLinewidth:{default:1},wireframeLinecap:{default:"round"},wireframeLinejoin:{default:"round"},flatShading:{type:Boolean,default:!1},fog:{type:Boolean,default:!0}},setup(o,{expose:e}){const t=o,{invalidateOnDemand:n}=Ie(t),r=u.computed(()=>500-(Array.isArray(t.blurSize)?t.blurSize[0]:t.blurSize)),s=u.computed(()=>500-(Array.isArray(t.blurSize)?t.blurSize[1]:t.blurSize)),i=u.computed(()=>r.value>0||s.value>0),a=u.computed(()=>t.sharpDepthScale>0||t.blurDepthScale>0),c=u.computed(()=>!!t.distortionMap),h=u.computed(()=>!!t.roughnessMap),d=u.shallowRef();let f;const p={reflectorPlane:new l.Plane,normal:new l.Vector3,reflectorWorldPosition:new l.Vector3,cameraWorldPosition:new l.Vector3,rotationMatrix:new l.Matrix4,lookAtPosition:new l.Vector3(0,0,-1),clipPlane:new l.Vector4,view:new l.Vector3,target:new l.Vector3,q:new l.Vector4,virtualCamera:new l.PerspectiveCamera,textureMatrix:new l.Matrix4},m=new l.WebGLRenderTarget(t.resolution,t.resolution,{minFilter:l.LinearFilter,magFilter:l.LinearFilter,type:l.HalfFloatType,depthBuffer:!0,depthTexture:new l.DepthTexture(t.resolution,t.resolution,l.DepthFormat,l.UnsignedShortType)}),_=new l.WebGLRenderTarget(t.resolution,t.resolution,{minFilter:l.LinearFilter,magFilter:l.LinearFilter,type:l.HalfFloatType});function v(y,g,M,b,S){const O=y.xr.enabled,T=y.shadowMap.autoUpdate;if(p.reflectorWorldPosition.setFromMatrixPosition(S.matrixWorld),p.cameraWorldPosition.setFromMatrixPosition(M.matrixWorld),p.rotationMatrix.extractRotation(S.matrixWorld),p.normal.set(0,0,1),p.normal.applyMatrix4(p.rotationMatrix),p.reflectorWorldPosition.addScaledVector(p.normal,t.reflectorOffset),p.view.subVectors(p.reflectorWorldPosition,p.cameraWorldPosition),p.view.dot(p.normal)>0)return;S.visible=!1,p.view.reflect(p.normal).negate(),p.view.add(p.reflectorWorldPosition),p.rotationMatrix.extractRotation(M.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=M.far,p.virtualCamera.updateMatrixWorld(),p.virtualCamera.projectionMatrix.copy(M.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(S.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 C=p.virtualCamera.projectionMatrix;p.q.x=(Math.sign(p.clipPlane.x)+C.elements[8])/C.elements[0],p.q.y=(Math.sign(p.clipPlane.y)+C.elements[9])/C.elements[5],p.q.z=-1,p.q.w=(1+C.elements[10])/C.elements[14],p.clipPlane.multiplyScalar(2/p.clipPlane.dot(p.q)),C.elements[2]=p.clipPlane.x,C.elements[6]=p.clipPlane.y,C.elements[10]=p.clipPlane.z+1,C.elements[14]=p.clipPlane.w,y.shadowMap.autoUpdate=!1,y.setRenderTarget(m),y.autoClear||y.clear(),y.render(g,p.virtualCamera),f.render(y,m,_),y.xr.enabled=O,y.shadowMap.autoUpdate=T,S.visible=!0,y.setRenderTarget(null),n()}return u.watch(()=>[t.resolution],()=>{m.setSize(t.resolution,t.resolution),_.setSize(t.resolution,t.resolution)}),u.watch(()=>[t.resolution,r.value,s.value,t.blurDepthEdgeMin,t.blurDepthEdgeMax,t.blurDepthScale,t.blurDepthBias],()=>{f==null||f.dispose(),f=new Th({resolution:t.resolution,width:r.value,height:s.value,depthEdge0:t.blurDepthEdgeMin,depthEdge1:t.blurDepthEdgeMax,depthScale:t.blurDepthScale,depthBias:t.blurDepthBias})},{immediate:!0}),u.watch(d,()=>{d.value&&(d.value.onBeforeRender=v)}),u.watch(()=>[i.value],()=>{te.useLogger().logWarning("MeshReflectionMaterial: Setting blurMixRough or blurMixSmooth to 0, then non-zero triggers a recompile.The TresJS core cannot currently handle recompiled materials.")}),u.watch(a,()=>{te.useLogger().logWarning("MeshReflectionMaterial: Setting depthScale to 0, then non-zero triggers a recompile.The TresJS core cannot currently handle recompiled materials.")}),u.watch(c,()=>{te.useLogger().logWarning("MeshReflectionMaterial: Toggling distortionMap triggers a recompile.The TresJS core cannot currently handle recompiled materials.")}),u.watch(h,()=>{te.useLogger().logWarning("MeshReflectionMaterial: Toggling roughnessMap triggers a recompile.The TresJS core cannot currently handle recompiled materials.")}),u.watch(()=>[t.normalMap],()=>{te.useLogger().logWarning("MeshReflectionMaterial: Toggling normalMap triggers a recompile.The TresJS core cannot currently handle recompiled materials.")}),u.onBeforeUnmount(()=>{m.dispose(),_.dispose(),f.dispose()}),te.useTresContext().extend({MeshReflectionMaterial:Ih}),e({instance:d}),(y,g)=>{var M,b,S;return u.openBlock(),u.createElementBlock("TresMeshReflectionMaterial",u.mergeProps({key:`key${i.value?"0":"1"}${a.value?"0":"1"}${c.value?"0":"1"}${h.value?"0":"1"}`,ref_key:"materialRef",ref:d},t,{"texture-matrix":p.textureMatrix,"t-sharp":(M=u.unref(m))==null?void 0:M.texture,"t-depth":(b=u.unref(m))==null?void 0:b.depthTexture,"t-blur":(S=u.unref(_))==null?void 0:S.texture,"defines-USE_BLUR":i.value?"":void 0,"defines-USE_DEPTH":a.value?"":void 0,"defines-USE_DISTORTION":c.value?"":void 0}),null,16,Oh)}}});class Yi extends l.ShaderMaterial{constructor(e={}){super(),this.vertexShader=`
|
|
563
827
|
#define STANDARD
|
|
564
828
|
varying vec3 vViewPosition;
|
|
565
829
|
#ifdef USE_TRANSMISSION
|
|
@@ -682,7 +946,7 @@ list should be an Array.`),C.length===0)return new _(0);if(C.length===1)return C
|
|
|
682
946
|
|
|
683
947
|
gl_FragColor = vec4( finalColor, hologramOpacity);
|
|
684
948
|
|
|
685
|
-
}`,this.uniforms={time:new l.Uniform(0),fresnelOpacity:new l.Uniform(e.fresnelOpacity!==void 0?e.fresnelOpacity:1),fresnelAmount:new l.Uniform(e.fresnelAmount!==void 0?e.fresnelAmount:.45),scanlineSize:new l.Uniform(e.scanlineSize!==void 0?e.scanlineSize:8),hologramBrightness:new l.Uniform(e.hologramBrightness!==void 0?e.hologramBrightness:1),signalSpeed:new l.Uniform(e.signalSpeed!==void 0?e.signalSpeed:1),hologramColor:new l.Uniform(e.hologramColor!==void 0?new l.Color(e.hologramColor):new l.Color("#00d5ff")),enableBlinking:new l.Uniform(e.enableBlinking!==void 0?e.enableBlinking:!0),blinkFresnelOnly:new l.Uniform(e.blinkFresnelOnly!==void 0?e.blinkFresnelOnly:!0),hologramOpacity:new l.Uniform(e.hologramOpacity!==void 0?e.hologramOpacity:1)},this.clock=new l.Clock,this.setValues(e),this.depthTest=e.depthTest!==void 0?e.depthTest:!1,this.blending=e.blendMode!==void 0?e.blendMode:l.AdditiveBlending,this.transparent=!0,this.side=e.side!==void 0?e.side:l.FrontSide}update(){this.uniforms.time.value=this.clock.getElapsedTime()}}const
|
|
949
|
+
}`,this.uniforms={time:new l.Uniform(0),fresnelOpacity:new l.Uniform(e.fresnelOpacity!==void 0?e.fresnelOpacity:1),fresnelAmount:new l.Uniform(e.fresnelAmount!==void 0?e.fresnelAmount:.45),scanlineSize:new l.Uniform(e.scanlineSize!==void 0?e.scanlineSize:8),hologramBrightness:new l.Uniform(e.hologramBrightness!==void 0?e.hologramBrightness:1),signalSpeed:new l.Uniform(e.signalSpeed!==void 0?e.signalSpeed:1),hologramColor:new l.Uniform(e.hologramColor!==void 0?new l.Color(e.hologramColor):new l.Color("#00d5ff")),enableBlinking:new l.Uniform(e.enableBlinking!==void 0?e.enableBlinking:!0),blinkFresnelOnly:new l.Uniform(e.blinkFresnelOnly!==void 0?e.blinkFresnelOnly:!0),hologramOpacity:new l.Uniform(e.hologramOpacity!==void 0?e.hologramOpacity:1)},this.clock=new l.Clock,this.setValues(e),this.depthTest=e.depthTest!==void 0?e.depthTest:!1,this.blending=e.blendMode!==void 0?e.blendMode:l.AdditiveBlending,this.transparent=!0,this.side=e.side!==void 0?e.side:l.FrontSide}update(){this.uniforms.time.value=this.clock.getElapsedTime()}}const Lh=["uniforms-fresnelAmount-value","uniforms-enableBlinking-value","uniforms-fresnelOpacity-value","uniforms-hologramBrightness-value","uniforms-scanlineSize-value","uniforms-signalSpeed-value","uniforms-hologramColor-value","uniforms-hologramOpacity-value","uniforms-blinkFresnelOnly-value","enableAdditive","side"],kh=u.defineComponent({__name:"index",props:{fresnelAmount:{default:.45},fresnelOpacity:{default:1},blinkFresnelOnly:{type:Boolean,default:!0},enableBlinking:{type:Boolean,default:!0},enableAdditive:{type:Boolean,default:!0},hologramBrightness:{default:.7},scanlineSize:{default:8},signalSpeed:{default:.45},hologramOpacity:{default:1},hologramColor:{default:"#00d5ff"},side:{default:l.FrontSide}},setup(o,{expose:e}){const t=o,{invalidateOnDemand:n}=Ie(t),r=u.shallowRef(),{extend:s}=te.useTresContext();s({HolographicMaterial:Yi}),e({root:r,constructor:Yi});const{onBeforeRender:i}=te.useLoop();return i(()=>{var a;(a=r.value)==null||a.update(),n()}),(a,c)=>(u.openBlock(),u.createElementBlock("TresHolographicMaterial",{ref_key:"MeshHolographicMaterialClass",ref:r,"uniforms-fresnelAmount-value":t.fresnelAmount,"uniforms-enableBlinking-value":t.enableBlinking,"uniforms-fresnelOpacity-value":t.fresnelOpacity,"uniforms-hologramBrightness-value":t.hologramBrightness,"uniforms-scanlineSize-value":t.scanlineSize,"uniforms-signalSpeed-value":t.signalSpeed,"uniforms-hologramColor-value":t.hologramColor,"uniforms-hologramOpacity-value":t.hologramOpacity,"uniforms-blinkFresnelOnly-value":t.blinkFresnelOnly,enableAdditive:t.enableAdditive,side:t.side},null,8,Lh))}}),Bh=["args"],Fh=["color"],Uh=u.defineComponent({__name:"Box",props:{args:{default:()=>[1,1,1]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({instance:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"boxRef",ref:s},i.$attrs),[u.createElementVNode("TresBoxGeometry",{args:u.unref(n)},null,8,Bh),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,Fh)])],16))}}),Wi=new l.Box3,Gn=new l.Vector3;class Xi extends l.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 l.Float32BufferAttribute(e,3)),this.setAttribute("uv",new l.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 l.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceStart",new l.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceEnd",new l.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 l.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceColorStart",new l.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceColorEnd",new l.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 l.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 l.Box3);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),Wi.setFromBufferAttribute(t),this.boundingBox.union(Wi))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new l.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++)Gn.fromBufferAttribute(e,s),r=Math.max(r,n.distanceToSquared(Gn)),Gn.fromBufferAttribute(t,s),r=Math.max(r,n.distanceToSquared(Gn));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)}}l.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new l.Vector2(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},l.ShaderLib.line={uniforms:l.UniformsUtils.merge([l.UniformsLib.common,l.UniformsLib.fog,l.UniformsLib.line]),vertexShader:`
|
|
686
950
|
#include <common>
|
|
687
951
|
#include <color_pars_vertex>
|
|
688
952
|
#include <fog_pars_vertex>
|
|
@@ -1052,162 +1316,9 @@ list should be an Array.`),C.length===0)return new _(0);if(C.length===1)return C
|
|
|
1052
1316
|
#include <premultiplied_alpha_fragment>
|
|
1053
1317
|
|
|
1054
1318
|
}
|
|
1055
|
-
`};class Vr extends l.ShaderMaterial{constructor(e){super({type:"LineMaterial",uniforms:l.UniformsUtils.clone(l.ShaderLib.line.uniforms),vertexShader:l.ShaderLib.line.vertexShader,fragmentShader:l.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="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const Vi=new l.Vector3,zi=new l.Vector3,Ne=new l.Vector4,Ve=new l.Vector4,it=new l.Vector4,zr=new l.Vector3,Gr=new l.Matrix4,ze=new l.Line3,Gi=new l.Vector3,Vn=new l.Box3,zn=new l.Sphere,ot=new l.Vector4;let at,Bt;function ji(o,e,t){return ot.set(0,0,-e,1).applyMatrix4(o.projectionMatrix),ot.multiplyScalar(1/ot.w),ot.x=Bt/t.width,ot.y=Bt/t.height,ot.applyMatrix4(o.projectionMatrixInverse),ot.multiplyScalar(1/ot.w),Math.abs(Math.max(ot.x,ot.y))}function nh(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,c=i;a<c;a++){ze.start.fromBufferAttribute(r,a),ze.end.fromBufferAttribute(s,a),ze.applyMatrix4(t);const h=new l.Vector3,f=new l.Vector3;at.distanceSqToSegment(ze.start,ze.end,f,h),f.distanceTo(h)<Bt*.5&&e.push({point:f,pointOnLine:h,distance:at.origin.distanceTo(f),object:o,face:null,faceIndex:a,uv:null,uv1:null})}}function rh(o,e,t){const n=e.projectionMatrix,s=o.material.resolution,i=o.matrixWorld,a=o.geometry,c=a.attributes.instanceStart,h=a.attributes.instanceEnd,f=Math.min(a.instanceCount,c.count),d=-e.near;at.at(1,it),it.w=1,it.applyMatrix4(e.matrixWorldInverse),it.applyMatrix4(n),it.multiplyScalar(1/it.w),it.x*=s.x/2,it.y*=s.y/2,it.z=0,zr.copy(it),Gr.multiplyMatrices(e.matrixWorldInverse,i);for(let p=0,g=f;p<g;p++){if(Ne.fromBufferAttribute(c,p),Ve.fromBufferAttribute(h,p),Ne.w=1,Ve.w=1,Ne.applyMatrix4(Gr),Ve.applyMatrix4(Gr),Ne.z>d&&Ve.z>d)continue;if(Ne.z>d){const b=Ne.z-Ve.z,S=(Ne.z-d)/b;Ne.lerp(Ve,S)}else if(Ve.z>d){const b=Ve.z-Ne.z,S=(Ve.z-d)/b;Ve.lerp(Ne,S)}Ne.applyMatrix4(n),Ve.applyMatrix4(n),Ne.multiplyScalar(1/Ne.w),Ve.multiplyScalar(1/Ve.w),Ne.x*=s.x/2,Ne.y*=s.y/2,Ve.x*=s.x/2,Ve.y*=s.y/2,ze.start.copy(Ne),ze.start.z=0,ze.end.copy(Ve),ze.end.z=0;const v=ze.closestPointToPointParameter(zr,!0);ze.at(v,Gi);const _=l.MathUtils.lerp(Ne.z,Ve.z,v),m=_>=-1&&_<=1,M=zr.distanceTo(Gi)<Bt*.5;if(m&&M){ze.start.fromBufferAttribute(c,p),ze.end.fromBufferAttribute(h,p),ze.start.applyMatrix4(i),ze.end.applyMatrix4(i);const b=new l.Vector3,S=new l.Vector3;at.distanceSqToSegment(ze.start,ze.end,S,b),t.push({point:S,pointOnLine:b,distance:at.origin.distanceTo(S),object:o,face:null,faceIndex:p,uv:null,uv1:null})}}}class sh extends l.Mesh{constructor(e=new Ni,t=new Vr({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,c=t.count;i<c;i++,a+=2)Vi.fromBufferAttribute(t,i),zi.fromBufferAttribute(n,i),r[a]=a===0?0:r[a-1],r[a+1]=r[a]+Vi.distanceTo(zi);const s=new l.InstancedInterleavedBuffer(r,2,1);return e.setAttribute("instanceDistanceStart",new l.InterleavedBufferAttribute(s,1,0)),e.setAttribute("instanceDistanceEnd",new l.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;at=e.ray;const i=this.matrixWorld,a=this.geometry,c=this.material;Bt=c.linewidth+s,a.boundingSphere===null&&a.computeBoundingSphere(),zn.copy(a.boundingSphere).applyMatrix4(i);let h;if(n)h=Bt*.5;else{const d=Math.max(r.near,zn.distanceToPoint(at.origin));h=ji(r,d,c.resolution)}if(zn.radius+=h,at.intersectsSphere(zn)===!1)return;a.boundingBox===null&&a.computeBoundingBox(),Vn.copy(a.boundingBox).applyMatrix4(i);let f;if(n)f=Bt*.5;else{const d=Math.max(r.near,Vn.distanceToPoint(at.origin));f=ji(r,d,c.resolution)}Vn.expandByScalar(f),at.intersectsBox(Vn)!==!1&&(n?nh(this,t):rh(this,r,t))}}class Ri extends Ni{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 ih extends sh{constructor(e=new Ri,t=new Vr({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type="Line2"}}const oh=["object"],Wi=u.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(f,d){if(!f||f.length===0)return Array.from({length:d}).fill(ie.normalizeColor(e.color));if(f.length===1)return Array.from({length:d}).fill(ie.normalizeColor(f[0]));if(f.length===d)return f.map(ie.normalizeColor);const p=d-1,g=f.map(ie.normalizeColor);closed&&g.push(g[0].clone());const x=[g[0]],v=p/(g.length-1);for(let _=1;_<p;_++){const m=_%v/v,M=Math.floor(_/v);x.push(g[M].clone().lerp(g[M+1],m))}return x.push(g[g.length-1]),x}const n=new Vr,r=new Ri,s=new ih(r,n),i=ie.useTresContext().sizes,a=u.computed(()=>Array.isArray(e.vertexColors));function c(f,d){f.color=ie.normalizeColor(d.color),f.linewidth=d.lineWidth,f.alphaToCoverage=d.alphaToCoverage,f.worldUnits=d.worldUnits,f.vertexColors=Array.isArray(d.vertexColors),f.dashed=d.dashed,f.dashScale=d.dashScale,f.dashSize=d.dashSize,f.dashOffset=d.dashOffset,f.gapSize=d.gapSize,f.needsUpdate=!0}function h(f,d,p){const g=d.map(v=>v instanceof l.Vector3?[v.x,v.y,v.z]:v instanceof l.Vector2?[v.x,v.y,0]:Array.isArray(v)&&v.length===2?[v[0],v[1],0]:v).flat();f.setPositions(g.flat());const x=t(p,d.length).map(v=>v.toArray()).flat();f.setColors(x),s.computeLineDistances()}return c(n,e),h(r,e.points,e.vertexColors),s.computeLineDistances(),u.watch(()=>[e.color,e.lineWidth,e.alphaToCoverage,e.worldUnits,a,e.dashed,e.dashScale,e.dashSize,e.dashOffset],()=>c(n,e)),u.watch([e.points,e.vertexColors],()=>h(r,e.points,e.vertexColors)),u.watch(()=>e.vertexColors,()=>h(r,e.points,e.vertexColors)),u.watch(()=>e.points,()=>h(r,e.points,e.vertexColors)),u.watch([i.height,i.width],()=>n.resolution=new l.Vector2(i.width.value,i.height.value)),u.onUnmounted(()=>{r.dispose(),n.dispose()}),(f,d)=>(u.openBlock(),u.createElementBlock("primitive",{object:u.unref(s)},null,8,oh))}}),ah=u.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,c,h){const f=i.map(d=>d instanceof l.Vector3?d:new l.Vector3(...d));return new l.CatmullRomCurve3(f,a,c,h)}function n(i,a){return i.getPoints(a)}const r=u.computed(()=>t(e.points,e.closed,e.curveType,e.tension)),s=u.computed(()=>n(r.value,e.segments));return(i,a)=>(u.openBlock(),u.createBlock(Wi,{points:s.value,"vertex-colors":e.vertexColors,color:e.color,"line-width":e.lineWidth,"alpha-to-coverage":e.alphaToCoverage,dashed:e.dashed,"dash-size":e.dashSize,"dash-scale":e.dashScale,"dash-offset":e.dashOffset,"gap-size":e.gapSize,"world-units":e.worldUnits},null,8,["points","vertex-colors","color","line-width","alpha-to-coverage","dashed","dash-size","dash-scale","dash-offset","gap-size","world-units"]))}}),lh=["args"],ch=["color"],uh=u.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}=u.toRefs(t),s=u.shallowRef();return e({value:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"circleRef",ref:s},i.$attrs),[u.createElementVNode("TresCircleGeometry",{args:u.unref(n)},null,8,lh),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,ch)])],16))}}),hh=["args"],fh=["color"],dh=u.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}=u.toRefs(t),s=u.shallowRef();return e({value:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"coneRef",ref:s},i.$attrs),[u.createElementVNode("TresConeGeometry",{args:u.unref(n)},null,8,hh),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,fh)])],16))}}),ph=["args"],mh=["color"],gh=u.defineComponent({__name:"Dodecahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({value:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"dodecahedronRef",ref:s},i.$attrs),[u.createElementVNode("TresDodecahedronGeometry",{args:u.unref(n)},null,8,ph),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,mh)])],16))}}),yh=["args"],vh=["color"],_h=u.defineComponent({__name:"Icosahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({value:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"icosahedronRef",ref:s},i.$attrs),[u.createElementVNode("TresIcosahedronGeometry",{args:u.unref(n)},null,8,yh),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,vh)])],16))}}),xh=["args"],wh=["color"],bh=u.defineComponent({__name:"Octahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({value:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"octahedronRef",ref:s},i.$attrs),[u.createElementVNode("TresOctahedronGeometry",{args:u.unref(n)},null,8,xh),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,wh)])],16))}}),Mh=["rotation"],Sh=["args"],Ah=["color"],Ch=u.defineComponent({__name:"Plane",props:{args:{default:()=>[1,1]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({value:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"planeRef",ref:s,rotation:[-Math.PI/2,0,0]},i.$attrs),[u.createElementVNode("TresPlaneGeometry",{args:u.unref(n)},null,8,Sh),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,Ah)])],16,Mh))}}),Ph=["args"],Th=["color"],Ih=u.defineComponent({__name:"Ring",props:{args:{default:()=>[.5,1,32]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({value:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"ringRef",ref:s},i.$attrs),[u.createElementVNode("TresRingGeometry",{args:u.unref(n)},null,8,Ph),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,Th)])],16))}}),Lh=["args"],Oh=["color"],Dh=u.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}=u.toRefs(t),{extend:s}=ie.useTresContext();s({RoundedBoxGeometry:ka});const i=u.shallowRef();return e({value:i}),(a,c)=>(u.openBlock(),u.createElementBlock("TresMesh",{ref_key:"roundedBoxRef",ref:i},[u.createElementVNode("TresRoundedBoxGeometry",{args:u.unref(n)},null,8,Lh),u.renderSlot(a.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,Oh)])],512))}}),kh=["args"],Bh=["color"],Fh=u.defineComponent({__name:"Sphere",props:{args:{default:()=>[2,32,16]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({value:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"sphereRef",ref:s},i.$attrs),[u.createElementVNode("TresSphereGeometry",{args:u.unref(n)},null,8,kh),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,Bh)])],16))}}),Uh=["geometry"],Nh=["color"],Vh=u.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=u.shallowRef(),a=u.shallowRef(t.color);function c(p,g){const x=new l.BufferGeometry,v=p*g,_=new Float32Array(Array.from({length:3*v}).fill(0)),m=new Float32Array(Array.from({length:3*v}).fill(0)),M=[];for(let b=0;b<g-1;b++){for(let y=0;y<p-1;y++){const A=b*p+y,w=A+1,D=A+p,k=w+p;M.push(A,D,w),M.push(D,k,w)}const S=b*p+p-1,L=b*p,P=S+p,T=L+p;M.push(S,P,L),M.push(P,T,L)}return x.setIndex(M),x.setAttribute("position",new l.BufferAttribute(_,3)),x.setAttribute("normal",new l.BufferAttribute(m,3)),x}function h(p,g,x,v,_){return(s(n(g*p*.25))**v+s(r(g*p*.25))**_)**(-1/x)}function f(p,g,x,v,_,m,M,b,S,L,P){const T=2*Math.PI/L,y=-Math.PI,A=Math.PI/(P-1),w=-.5*Math.PI,D=p.getAttribute("position");let k=0,R=0,V=w;for(let Y=0;Y<P;Y++){R=y;for(let G=0;G<L;G++){const Q=h(R,g,x,v,_),K=h(V,m,M,b,S);D.setXYZ(k,Q*n(R)*K*n(V),K*r(V),Q*r(R)*K*n(V)),k++,R+=T}V+=A}D.needsUpdate=!0,p.computeVertexNormals()}u.watch(()=>t.color,()=>a.value=t.color),u.watch(()=>[t.widthSegments,t.heightSegments],()=>{i.value&&i.value.dispose(),i.value=c(t.widthSegments,t.heightSegments)},{immediate:!0}),u.watch(()=>[t.numArmsA,t.expA[0],t.expA[1],t.expA[2],t.numArmsB,t.expB[0],t.expB[1],t.expB[2]],()=>f(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}),u.onUnmounted(()=>{i.value&&i.value.dispose()});const d=u.shallowRef();return e({value:d}),(p,g)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"superformulaRef",ref:d},p.$attrs,{geometry:i.value}),[u.renderSlot(p.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:a.value},null,8,Nh)])],16,Uh))}}),zh=["rotation"],Gh=["args"],jh=["color"],Rh=u.defineComponent({__name:"Tetrahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({value:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"tetrahedronRef",ref:s,rotation:[-Math.PI/2,0,0]},i.$attrs),[u.createElementVNode("TresTetrahedronGeometry",{args:u.unref(n)},null,8,Gh),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,jh)])],16,zh))}}),Wh=["args"],Yh=["color"],Eh=u.defineComponent({__name:"Torus",props:{args:{default:()=>[1,1,16,80]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({value:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"torusRef",ref:s},i.$attrs),[u.createElementVNode("TresTorusGeometry",{args:u.unref(n)},null,8,Wh),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,Yh)])],16))}}),Xh=["args"],Zh=["color"],qh=u.defineComponent({__name:"TorusKnot",props:{args:{default:()=>[1,.4,64,8]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({value:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"torusKnotRef",ref:s},i.$attrs),[u.createElementVNode("TresTorusKnotGeometry",{args:u.unref(n)},null,8,Xh),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,Zh)])],16))}}),Kh=["args"],Qh=["color"],Jh=u.defineComponent({__name:"Tube",props:{args:{default:()=>[new l.QuadraticBezierCurve3(new l.Vector3(-1,0,0),new l.Vector3(0,1,0),new l.Vector3(1,0,0)),20,.2,8,!1]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({value:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"tubeRef",ref:s},i.$attrs),[u.createElementVNode("TresTubeGeometry",{args:u.unref(n)},null,8,Kh),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,Qh)])],16))}});class Hh extends l.Object3D{constructor(){super();ce(this,"virtualScene",null);this.virtualScene=new l.Scene}add(...t){return this.virtualScene.add(...t),this}destructor(){this.virtualScene.traverse(t=>{t instanceof l.Mesh&&(t.geometry.dispose(),t.material.dispose(),t.material.map&&t.material.map.dispose(),this.virtualScene.remove(t))}),this.virtualScene=null}}const $h=u.defineComponent({__name:"component",props:{background:{type:[Boolean,String],default:!1},blur:{default:0},files:{default:[]},path:{default:""},preset:{default:void 0},resolution:{default:256},near:{default:1},far:{default:1e3},frames:{default:Number.POSITIVE_INFINITY}},async setup(o,{expose:e}){let t,n;const r=o,s=u.ref(null);e({texture:s});const{extend:i,renderer:a,scene:c}=ie.useTresContext();let h=null;const f=u.ref(null);let d=null;const p=u.ref(null);u.onUnmounted(()=>{var m,M;(m=p.value)==null||m.destructor(),(M=f.value)==null||M.dispose()});const{onBeforeLoop:g}=ie.useRenderLoop();let x=1;g(()=>{d&&p.value&&f.value&&(r.frames===Number.POSITIVE_INFINITY||x<r.frames)&&(d.update(a.value,u.toRaw(p.value.virtualScene)),x++)});const v=([t,n]=u.withAsyncContext(()=>Qs(r,f)),t=await t,n(),t).texture,_=m=>{m?(c.value.environment=m.texture,r.background&&(c.value.background=m.texture)):(c.value.environment=v.value,r.background&&(c.value.background=v.value))};return u.watch(v,()=>{f.value&&_(f.value)},{immediate:!0,deep:!0}),u.watch(u.useSlots().default,m=>{var M,b;if(m&&(h=m,Array.isArray(h)&&h.length>0&&typeof((M=h[0])==null?void 0:M.type)!="symbol")){i({EnvSence:Hh}),f.value=new l.WebGLCubeRenderTarget(r.resolution),f.value.texture.type=l.HalfFloatType,d=new l.CubeCamera(r.near,r.far,f.value),_(f.value);return}(b=f.value)==null||b.dispose(),f.value=null,_()},{immediate:!0,deep:!0}),s.value=v,(m,M)=>f.value?(u.openBlock(),u.createElementBlock("TresEnvSence",{key:0,ref_key:"envSence",ref:p},[u.renderSlot(m.$slots,"default")],512)):u.createCommentVNode("",!0)}}),ef={key:0,args:[0,1,64]},tf={key:1,args:[.5,1,64]},nf={key:2},rf=["tone-mapped","map","side","color"],sf=u.defineComponent({__name:"index",props:{args:{default:null},from:{default:"rect"},toneMapped:{type:Boolean,default:!1},map:{default:null},intensity:{default:1},color:{default:new l.Color(16777215)}},setup(o){const e=o,t=u.ref();return u.watchEffect(()=>{t.value&&(t.value.color.multiplyScalar(e.intensity),t.value.needsUpdate=!0)}),(n,r)=>(u.openBlock(),u.createElementBlock("TresMesh",null,[n.from==="circle"?(u.openBlock(),u.createElementBlock("TresRingGeometry",ef)):n.from==="ring"?(u.openBlock(),u.createElementBlock("TresRingGeometry",tf)):n.from==="rect"?(u.openBlock(),u.createElementBlock("TresPlaneGeometry",nf)):(u.openBlock(),u.createBlock(e.from,{key:3,args:e})),u.createElementVNode("TresMeshBasicMaterial",{ref_key:"material",ref:t,"tone-mapped":n.toneMapped,map:n.map,side:u.unref(l.DoubleSide),color:n.color},null,8,rf)]))}}),of=["receive-shadow","rotation"],af=["args"],lf=u.createElementVNode("TresMeshStandardMaterial",{color:8421504,side:2},null,-1),cf=u.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}=u.toRefs(e),i=u.ref(null);return u.watch(()=>[r.value,n.value,i.value],([a,c,h])=>{if(!h||a===null)return;let f=0;const d=a/a/2,p=h.attributes.position;for(let g=0;g<a+1;g++)for(let x=0;x<a+1;x++)p.setXYZ(f++,g/a-d+(g===0?-c:0),x/a-d,t(g/a));p.needsUpdate=!0,h.computeVertexNormals()}),(a,c)=>(u.openBlock(),u.createElementBlock("TresGroup",u.normalizeProps(u.guardReactiveProps(a.$attrs)),[u.createElementVNode("TresMesh",{"receive-shadow":u.unref(s),rotation:[-Math.PI/2,0,Math.PI/2]},[u.createElementVNode("TresPlaneGeometry",{ref_key:"planeRef",ref:i,args:[1,1,u.unref(r),u.unref(r)]},null,8,af),u.renderSlot(a.$slots,"default",{},()=>[lf])],8,of)],16))}}),uf=["geometry"],hf=["map","opacity","depth-write"],ff=["object"],df=["args"],pf=["rotation","args"],mf=u.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:Number.POSITIVE_INFINITY},scale:{default:10},color:{default:"#000000"},depthWrite:{type:Boolean,default:!1},helper:{type:Boolean,default:!1}},setup(o,{expose:e}){const t=o,n=u.shallowRef(),r=u.shallowRef();e(n);let s,i,a,c,h;const{renderer:f,scene:d}=ie.useTresContext(),p=u.computed(()=>t.width*(Array.isArray(t.scale)?t.scale[0]:t.scale||1)),g=u.computed(()=>t.height*(Array.isArray(t.scale)?t.scale[1]:t.scale||1));u.watchEffect(()=>{s&&s.dispose(),i&&i.dispose(),a&&a.dispose(),c&&c.geometry.dispose(),s=new l.WebGLRenderTarget(t.resolution,t.resolution),i=new l.WebGLRenderTarget(t.resolution,t.resolution),i.texture.generateMipmaps=s.texture.generateMipmaps=!1,r.value=new l.OrthographicCamera(-p.value/2,p.value/2,g.value/2,-g.value/2,0,t.far),a=new l.PlaneGeometry(p.value,g.value).rotateX(Math.PI/2),c=new l.Mesh(a),c.visible=!1}),u.watchEffect(()=>{t.color&&(h&&h.dispose(),h=new l.MeshDepthMaterial,h.depthTest=h.depthWrite=!1,h.onBeforeCompile=L=>{L.uniforms={...L.uniforms,ucolor:{value:t.color?new l.Color(t.color):new l.Color}},L.fragmentShader=L.fragmentShader.replace("void main() {",`uniform vec3 ucolor;
|
|
1319
|
+
`};class Gr extends l.ShaderMaterial{constructor(e){super({type:"LineMaterial",uniforms:l.UniformsUtils.clone(l.ShaderLib.line.uniforms),vertexShader:l.ShaderLib.line.vertexShader,fragmentShader:l.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="":delete this.defines.USE_ALPHA_TO_COVERAGE)}}const jr=new l.Vector4,Zi=new l.Vector3,Ki=new l.Vector3,ze=new l.Vector4,Ve=new l.Vector4,ot=new l.Vector4,Er=new l.Vector3,Yr=new l.Matrix4,Re=new l.Line3,qi=new l.Vector3,jn=new l.Box3,En=new l.Sphere,at=new l.Vector4;let lt,Ft;function Qi(o,e,t){return at.set(0,0,-e,1).applyMatrix4(o.projectionMatrix),at.multiplyScalar(1/at.w),at.x=Ft/t.width,at.y=Ft/t.height,at.applyMatrix4(o.projectionMatrixInverse),at.multiplyScalar(1/at.w),Math.abs(Math.max(at.x,at.y))}function Nh(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,c=i;a<c;a++){Re.start.fromBufferAttribute(r,a),Re.end.fromBufferAttribute(s,a),Re.applyMatrix4(t);const h=new l.Vector3,d=new l.Vector3;lt.distanceSqToSegment(Re.start,Re.end,d,h),d.distanceTo(h)<Ft*.5&&e.push({point:d,pointOnLine:h,distance:lt.origin.distanceTo(d),object:o,face:null,faceIndex:a,uv:null,uv1:null})}}function zh(o,e,t){const n=e.projectionMatrix,s=o.material.resolution,i=o.matrixWorld,a=o.geometry,c=a.attributes.instanceStart,h=a.attributes.instanceEnd,d=Math.min(a.instanceCount,c.count),f=-e.near;lt.at(1,ot),ot.w=1,ot.applyMatrix4(e.matrixWorldInverse),ot.applyMatrix4(n),ot.multiplyScalar(1/ot.w),ot.x*=s.x/2,ot.y*=s.y/2,ot.z=0,Er.copy(ot),Yr.multiplyMatrices(e.matrixWorldInverse,i);for(let p=0,m=d;p<m;p++){if(ze.fromBufferAttribute(c,p),Ve.fromBufferAttribute(h,p),ze.w=1,Ve.w=1,ze.applyMatrix4(Yr),Ve.applyMatrix4(Yr),ze.z>f&&Ve.z>f)continue;if(ze.z>f){const b=ze.z-Ve.z,S=(ze.z-f)/b;ze.lerp(Ve,S)}else if(Ve.z>f){const b=Ve.z-ze.z,S=(Ve.z-f)/b;Ve.lerp(ze,S)}ze.applyMatrix4(n),Ve.applyMatrix4(n),ze.multiplyScalar(1/ze.w),Ve.multiplyScalar(1/Ve.w),ze.x*=s.x/2,ze.y*=s.y/2,Ve.x*=s.x/2,Ve.y*=s.y/2,Re.start.copy(ze),Re.start.z=0,Re.end.copy(Ve),Re.end.z=0;const v=Re.closestPointToPointParameter(Er,!0);Re.at(v,qi);const y=l.MathUtils.lerp(ze.z,Ve.z,v),g=y>=-1&&y<=1,M=Er.distanceTo(qi)<Ft*.5;if(g&&M){Re.start.fromBufferAttribute(c,p),Re.end.fromBufferAttribute(h,p),Re.start.applyMatrix4(i),Re.end.applyMatrix4(i);const b=new l.Vector3,S=new l.Vector3;lt.distanceSqToSegment(Re.start,Re.end,S,b),t.push({point:S,pointOnLine:b,distance:lt.origin.distanceTo(S),object:o,face:null,faceIndex:p,uv:null,uv1:null})}}}class Vh extends l.Mesh{constructor(e=new Xi,t=new Gr({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,c=t.count;i<c;i++,a+=2)Zi.fromBufferAttribute(t,i),Ki.fromBufferAttribute(n,i),r[a]=a===0?0:r[a-1],r[a+1]=r[a]+Zi.distanceTo(Ki);const s=new l.InstancedInterleavedBuffer(r,2,1);return e.setAttribute("instanceDistanceStart",new l.InterleavedBufferAttribute(s,1,0)),e.setAttribute("instanceDistanceEnd",new l.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;lt=e.ray;const i=this.matrixWorld,a=this.geometry,c=this.material;Ft=c.linewidth+s,a.boundingSphere===null&&a.computeBoundingSphere(),En.copy(a.boundingSphere).applyMatrix4(i);let h;if(n)h=Ft*.5;else{const f=Math.max(r.near,En.distanceToPoint(lt.origin));h=Qi(r,f,c.resolution)}if(En.radius+=h,lt.intersectsSphere(En)===!1)return;a.boundingBox===null&&a.computeBoundingBox(),jn.copy(a.boundingBox).applyMatrix4(i);let d;if(n)d=Ft*.5;else{const f=Math.max(r.near,jn.distanceToPoint(lt.origin));d=Qi(r,f,c.resolution)}jn.expandByScalar(d),lt.intersectsBox(jn)!==!1&&(n?Nh(this,t):zh(this,r,t))}onBeforeRender(e){const t=this.material.uniforms;t&&t.resolution&&(e.getViewport(jr),this.material.uniforms.resolution.value.set(jr.z,jr.w))}}class Ji extends Xi{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 Rh extends Vh{constructor(e=new Ji,t=new Gr({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type="Line2"}}const Gh=["object"],Hi=u.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,{expose:e}){const t=o;function n(p,m){if(!p||p.length===0)return Array.from({length:m}).fill(te.normalizeColor(t.color));if(p.length===1)return Array.from({length:m}).fill(te.normalizeColor(p[0]));if(p.length===m)return p.map(te.normalizeColor);const _=m-1,v=p.map(te.normalizeColor);closed&&v.push(v[0].clone());const y=[v[0]],g=_/(v.length-1);for(let M=1;M<_;M++){const b=M%g/g,S=Math.floor(M/g);y.push(v[S].clone().lerp(v[S+1],b))}return y.push(v[v.length-1]),y}const r=new Gr,s=new Ji,i=new Rh(s,r),a=te.useTresContext().sizes,c=u.computed(()=>Array.isArray(t.vertexColors));function h(p,m){p.color=te.normalizeColor(m.color),p.linewidth=m.lineWidth,p.alphaToCoverage=m.alphaToCoverage,p.worldUnits=m.worldUnits,p.vertexColors=Array.isArray(m.vertexColors),p.dashed=m.dashed,p.dashScale=m.dashScale,p.dashSize=m.dashSize,p.dashOffset=m.dashOffset,p.gapSize=m.gapSize,p.needsUpdate=!0}function d(p,m,_){const v=m.map(g=>g instanceof l.Vector3?[g.x,g.y,g.z]:g instanceof l.Vector2?[g.x,g.y,0]:Array.isArray(g)&&g.length===2?[g[0],g[1],0]:g).flat();p.setPositions(v.flat());const y=n(_,m.length).map(g=>g.toArray()).flat();p.setColors(y),i.computeLineDistances()}h(r,t),d(s,t.points,t.vertexColors),i.computeLineDistances(),u.watch(()=>[t.color,t.lineWidth,t.alphaToCoverage,t.worldUnits,c,t.dashed,t.dashScale,t.dashSize,t.dashOffset],()=>h(r,t)),u.watch([t.points,t.vertexColors],()=>d(s,t.points,t.vertexColors)),u.watch(()=>t.vertexColors,()=>d(s,t.points,t.vertexColors)),u.watch(()=>t.points,()=>d(s,t.points,t.vertexColors)),u.watch([a.height,a.width],()=>r.resolution=new l.Vector2(a.width.value,a.height.value)),u.onUnmounted(()=>{s.dispose(),r.dispose()});const f=u.shallowRef();return e({instance:f}),(p,m)=>(u.openBlock(),u.createElementBlock("primitive",{ref:f.value,object:u.unref(i)},null,8,Gh))}}),jh=u.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,{expose:e}){const t=o;function n(c,h,d,f){const p=c.map(m=>m instanceof l.Vector3?m:new l.Vector3(...m));return new l.CatmullRomCurve3(p,h,d,f)}function r(c,h){return c.getPoints(h)}const s=u.computed(()=>n(t.points,t.closed,t.curveType,t.tension)),i=u.computed(()=>r(s.value,t.segments)),a=u.shallowRef();return e({instance:a}),(c,h)=>(u.openBlock(),u.createBlock(Hi,{ref:a.value,points:i.value,"vertex-colors":t.vertexColors,color:t.color,"line-width":t.lineWidth,"alpha-to-coverage":t.alphaToCoverage,dashed:t.dashed,"dash-size":t.dashSize,"dash-scale":t.dashScale,"dash-offset":t.dashOffset,"gap-size":t.gapSize,"world-units":t.worldUnits},null,8,["points","vertex-colors","color","line-width","alpha-to-coverage","dashed","dash-size","dash-scale","dash-offset","gap-size","world-units"]))}}),Eh=["args"],Yh=["color"],Wh=u.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}=u.toRefs(t),s=u.shallowRef();return e({instance:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"circleRef",ref:s},i.$attrs),[u.createElementVNode("TresCircleGeometry",{args:u.unref(n)},null,8,Eh),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,Yh)])],16))}}),Xh=["args"],Zh=["color"],Kh=u.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}=u.toRefs(t),s=u.shallowRef();return e({instance:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"coneRef",ref:s},i.$attrs),[u.createElementVNode("TresConeGeometry",{args:u.unref(n)},null,8,Xh),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,Zh)])],16))}}),qh=["args"],Qh=["color"],Jh=u.defineComponent({__name:"Cylinder",props:{args:{default:()=>[1,1,1,32,1,!1,0,Math.PI*2]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({instance:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"cylinderRef",ref:s},i.$attrs),[u.createElementVNode("TresCylinderGeometry",{args:u.unref(n)},null,8,qh),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,Qh)])],16))}}),Hh=["args"],$h=["color"],ef=u.defineComponent({__name:"Dodecahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({instance:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"dodecahedronRef",ref:s},i.$attrs),[u.createElementVNode("TresDodecahedronGeometry",{args:u.unref(n)},null,8,Hh),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,$h)])],16))}}),tf=["args"],nf=["color"],rf=u.defineComponent({__name:"Icosahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({instance:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"icosahedronRef",ref:s},i.$attrs),[u.createElementVNode("TresIcosahedronGeometry",{args:u.unref(n)},null,8,tf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,nf)])],16))}}),sf=["args"],of=["color"],af=u.defineComponent({__name:"Octahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({instance:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"octahedronRef",ref:s},i.$attrs),[u.createElementVNode("TresOctahedronGeometry",{args:u.unref(n)},null,8,sf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,of)])],16))}}),lf=["rotation"],cf=["args"],uf=["color"],hf=u.defineComponent({__name:"Plane",props:{args:{default:()=>[1,1]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({instance:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"planeRef",ref:s,rotation:[-Math.PI/2,0,0]},i.$attrs),[u.createElementVNode("TresPlaneGeometry",{args:u.unref(n)},null,8,cf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,uf)])],16,lf))}}),ff=["args"],df=["color"],pf=u.defineComponent({__name:"Ring",props:{args:{default:()=>[.5,1,32]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({instance:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"ringRef",ref:s},i.$attrs),[u.createElementVNode("TresRingGeometry",{args:u.unref(n)},null,8,ff),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,df)])],16))}}),mf=["args"],gf=["color"],yf=u.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}=u.toRefs(t),{extend:s}=te.useTresContext();s({RoundedBoxGeometry:qa});const i=u.shallowRef();return e({instance:i}),(a,c)=>(u.openBlock(),u.createElementBlock("TresMesh",{ref_key:"roundedBoxRef",ref:i},[u.createElementVNode("TresRoundedBoxGeometry",{args:u.unref(n)},null,8,mf),u.renderSlot(a.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,gf)])],512))}}),_f=["args"],vf=["color"],xf=u.defineComponent({__name:"Sphere",props:{args:{default:()=>[2,32,16]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({instance:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"sphereRef",ref:s},i.$attrs),[u.createElementVNode("TresSphereGeometry",{args:u.unref(n)},null,8,_f),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,vf)])],16))}}),wf=["geometry"],bf=["color"],Mf=u.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=u.shallowRef(),a=u.shallowRef(t.color);function c(p,m){const _=new l.BufferGeometry,v=p*m,y=new Float32Array(Array.from({length:3*v}).fill(0)),g=new Float32Array(Array.from({length:3*v}).fill(0)),M=[];for(let b=0;b<m-1;b++){for(let w=0;w<p-1;w++){const A=b*p+w,x=A+1,D=A+p,L=x+p;M.push(A,D,x),M.push(D,L,x)}const S=b*p+p-1,O=b*p,T=S+p,C=O+p;M.push(S,T,O),M.push(T,C,O)}return _.setIndex(M),_.setAttribute("position",new l.BufferAttribute(y,3)),_.setAttribute("normal",new l.BufferAttribute(g,3)),_}function h(p,m,_,v,y){return(s(n(m*p*.25))**v+s(r(m*p*.25))**y)**(-1/_)}function d(p,m,_,v,y,g,M,b,S,O,T){const C=2*Math.PI/O,w=-Math.PI,A=Math.PI/(T-1),x=-.5*Math.PI,D=p.getAttribute("position");let L=0,V=0,R=x;for(let X=0;X<T;X++){V=w;for(let Y=0;Y<O;Y++){const J=h(V,m,_,v,y),q=h(R,g,M,b,S);D.setXYZ(L,J*n(V)*q*n(R),q*r(R),J*r(V)*q*n(R)),L++,V+=C}R+=A}D.needsUpdate=!0,p.computeVertexNormals()}u.watch(()=>t.color,()=>a.value=t.color),u.watch(()=>[t.widthSegments,t.heightSegments],()=>{i.value&&i.value.dispose(),i.value=c(t.widthSegments,t.heightSegments)},{immediate:!0}),u.watch(()=>[t.numArmsA,t.expA[0],t.expA[1],t.expA[2],t.numArmsB,t.expB[0],t.expB[1],t.expB[2]],()=>d(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}),u.onUnmounted(()=>{i.value&&i.value.dispose()});const f=u.shallowRef();return e({instance:f}),(p,m)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"superformulaRef",ref:f},p.$attrs,{geometry:i.value}),[u.renderSlot(p.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:a.value},null,8,bf)])],16,wf))}}),Sf=["rotation"],Af=["args"],Cf=["color"],Pf=u.defineComponent({__name:"Tetrahedron",props:{args:{default:()=>[1,0]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({instance:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"tetrahedronRef",ref:s,rotation:[-Math.PI/2,0,0]},i.$attrs),[u.createElementVNode("TresTetrahedronGeometry",{args:u.unref(n)},null,8,Af),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,Cf)])],16,Sf))}}),Tf=["args"],If=["color"],Of=u.defineComponent({__name:"Torus",props:{args:{default:()=>[1,1,16,80]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({instance:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"torusRef",ref:s},i.$attrs),[u.createElementVNode("TresTorusGeometry",{args:u.unref(n)},null,8,Tf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,If)])],16))}}),Df=["args"],Lf=["color"],kf=u.defineComponent({__name:"TorusKnot",props:{args:{default:()=>[1,.4,64,8]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({instance:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"torusKnotRef",ref:s},i.$attrs),[u.createElementVNode("TresTorusKnotGeometry",{args:u.unref(n)},null,8,Df),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,Lf)])],16))}}),Bf=["args"],Ff=["color"],Uf=u.defineComponent({__name:"Tube",props:{args:{default:()=>[new l.QuadraticBezierCurve3(new l.Vector3(-1,0,0),new l.Vector3(0,1,0),new l.Vector3(1,0,0)),20,.2,8,!1]},color:{default:"#ffffff"}},setup(o,{expose:e}){const t=o,{args:n,color:r}=u.toRefs(t),s=u.shallowRef();return e({instance:s}),(i,a)=>(u.openBlock(),u.createElementBlock("TresMesh",u.mergeProps({ref_key:"tubeRef",ref:s},i.$attrs),[u.createElementVNode("TresTubeGeometry",{args:u.unref(n)},null,8,Bf),u.renderSlot(i.$slots,"default",{},()=>[u.createElementVNode("TresMeshBasicMaterial",{color:u.unref(r)},null,8,Ff)])],16))}});class Nf extends l.Object3D{constructor(){super();ue(this,"virtualScene",null);this.virtualScene=new l.Scene}add(...t){return this.virtualScene.add(...t),this}destructor(){this.virtualScene.traverse(t=>{t instanceof l.Mesh&&(t.geometry.dispose(),t.material.dispose(),t.material.map&&t.material.map.dispose(),this.virtualScene.remove(t))}),this.virtualScene=null}}const zf=u.defineComponent({__name:"component",props:{background:{type:[Boolean,String],default:!1},blur:{default:0},files:{default:[]},path:{default:""},preset:{default:void 0},resolution:{default:256},near:{default:1},far:{default:1e3},frames:{default:Number.POSITIVE_INFINITY}},async setup(o,{expose:e}){let t,n;const r=o,s=u.ref(null);e({texture:s});const{extend:i,renderer:a,scene:c}=te.useTresContext();let h=null;const d=u.ref(null);let f=null;const p=u.ref(null),{onBeforeRender:m}=te.useLoop();let _=1;m(()=>{f&&p.value&&d.value&&(r.frames===Number.POSITIVE_INFINITY||_<r.frames)&&(f.update(a.value,u.toRaw(p.value.virtualScene)),_++)},-1);const v=([t,n]=u.withAsyncContext(()=>ri(r,d)),t=await t,n(),t).texture,y=g=>{g?(c.value.environment=g.texture,r.background&&(c.value.background=g.texture)):(c.value.environment=v.value,r.background&&(c.value.background=v.value))};return u.watch(v,()=>{d.value&&y(d.value)},{immediate:!0,deep:!0}),u.watch(u.useSlots().default,g=>{var M,b;if(g&&(h=g,Array.isArray(h)&&h.length>0&&typeof((M=h[0])==null?void 0:M.type)!="symbol")){i({EnvSence:Nf}),d.value=new l.WebGLCubeRenderTarget(r.resolution),d.value.texture.type=l.HalfFloatType,f=new l.CubeCamera(r.near,r.far,d.value),y(d.value);return}(b=d.value)==null||b.dispose(),d.value=null,y()},{immediate:!0,deep:!0}),s.value=v,u.onUnmounted(()=>{var g,M;(g=p.value)==null||g.destructor(),(M=d.value)==null||M.dispose()}),(g,M)=>d.value?(u.openBlock(),u.createElementBlock("TresEnvSence",{key:0,ref_key:"envSence",ref:p},[u.renderSlot(g.$slots,"default")],512)):u.createCommentVNode("",!0)}}),Vf={key:0,args:[0,1,64]},Rf={key:1,args:[.5,1,64]},Gf={key:2},jf=["tone-mapped","map","side","color"],Ef=u.defineComponent({__name:"index",props:{args:{default:null},from:{default:"rect"},toneMapped:{type:Boolean,default:!1},map:{default:null},intensity:{default:1},color:{default:new l.Color(16777215)}},setup(o){const e=o,t=u.ref();return u.watchEffect(()=>{t.value&&(t.value.color.multiplyScalar(e.intensity),t.value.needsUpdate=!0)}),(n,r)=>(u.openBlock(),u.createElementBlock("TresMesh",null,[n.from==="circle"?(u.openBlock(),u.createElementBlock("TresRingGeometry",Vf)):n.from==="ring"?(u.openBlock(),u.createElementBlock("TresRingGeometry",Rf)):n.from==="rect"?(u.openBlock(),u.createElementBlock("TresPlaneGeometry",Gf)):(u.openBlock(),u.createBlock(e.from,{key:3,args:e})),u.createElementVNode("TresMeshBasicMaterial",{ref_key:"material",ref:t,"tone-mapped":n.toneMapped,map:n.map,side:u.unref(l.DoubleSide),color:n.color},null,8,jf)]))}}),Yf=["receive-shadow","rotation"],Wf=["args"],Xf=u.createElementVNode("TresMeshStandardMaterial",{color:8421504,side:2},null,-1),Zf=u.defineComponent({__name:"Backdrop",props:{floor:{default:.25},segments:{default:20},receiveShadow:{type:Boolean,default:!1}},setup(o,{expose:e}){const t=o,n=h=>h===0?0:2**(10*h-10),{floor:r,segments:s,receiveShadow:i}=u.toRefs(t),a=u.ref(null);u.watch(()=>[s.value,r.value,a.value],([h,d,f])=>{if(!f||h===null)return;let p=0;const m=h/h/2,_=f.attributes.position;for(let v=0;v<h+1;v++)for(let y=0;y<h+1;y++)_.setXYZ(p++,v/h-m+(v===0?-d:0),y/h-m,n(v/h));_.needsUpdate=!0,f.computeVertexNormals()});const c=u.shallowRef();return e({instance:c}),(h,d)=>(u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps({ref_key:"backdropRef",ref:c},h.$attrs),[u.createElementVNode("TresMesh",{"receive-shadow":u.unref(i),rotation:[-Math.PI/2,0,Math.PI/2]},[u.createElementVNode("TresPlaneGeometry",{ref_key:"planeRef",ref:a,args:[1,1,u.unref(s),u.unref(s)]},null,8,Wf),u.renderSlot(h.$slots,"default",{},()=>[Xf])],8,Yf)],16))}}),Kf=["geometry"],qf=["map","opacity","depth-write"],Qf=["object"],Jf=["args"],Hf=["rotation","args"],$f=u.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:Number.POSITIVE_INFINITY},scale:{default:10},color:{default:"#000000"},depthWrite:{type:Boolean,default:!1},helper:{type:Boolean,default:!1}},setup(o,{expose:e}){const t=o,n=u.shallowRef(),r=u.shallowRef();e({instance:n});let s,i,a,c,h;const{renderer:d,scene:f}=te.useTresContext(),p=u.computed(()=>t.width*(Array.isArray(t.scale)?t.scale[0]:t.scale||1)),m=u.computed(()=>t.height*(Array.isArray(t.scale)?t.scale[1]:t.scale||1));u.watchEffect(()=>{s&&s.dispose(),i&&i.dispose(),a&&a.dispose(),c&&c.geometry.dispose(),s=new l.WebGLRenderTarget(t.resolution,t.resolution),i=new l.WebGLRenderTarget(t.resolution,t.resolution),i.texture.generateMipmaps=s.texture.generateMipmaps=!1,r.value=new l.OrthographicCamera(-p.value/2,p.value/2,m.value/2,-m.value/2,0,t.far),a=new l.PlaneGeometry(p.value,m.value).rotateX(Math.PI/2),c=new l.Mesh(a),c.visible=!1}),u.watchEffect(()=>{t.color&&(h&&h.dispose(),h=new l.MeshDepthMaterial,h.depthTest=h.depthWrite=!1,h.onBeforeCompile=O=>{O.uniforms={...O.uniforms,ucolor:{value:t.color?new l.Color(t.color):new l.Color}},O.fragmentShader=O.fragmentShader.replace("void main() {",`uniform vec3 ucolor;
|
|
1056
1320
|
void main() {
|
|
1057
|
-
`),L.fragmentShader=L.fragmentShader.replace("vec4( vec3( 1.0 - fragCoordZ ), opacity );","vec4( ucolor * fragCoordZ * 2.0, ( 1.0 - fragCoordZ ) * 1.0 );")})});const x=new l.ShaderMaterial(Ba),v=new l.ShaderMaterial(Fa);v.depthTest=x.depthTest=!1;function _(L){!f.value||!r.value||(c.visible=!0,c.material=x,x.uniforms.tDiffuse.value=s.texture,x.uniforms.h.value=L/256,f.value.setRenderTarget(i),f.value.render(c,r.value),c.material=v,v.uniforms.tDiffuse.value=i.texture,v.uniforms.v.value=L/256,f.value.setRenderTarget(s),f.value.render(c,r.value),c.visible=!1)}const{onLoop:m}=ie.useRenderLoop();let M=0,b,S;return m(()=>{!r.value||d.value===void 0||f.value===void 0||(t.frames===Number.POSITIVE_INFINITY||M<t.frames)&&(M++,b=d.value.background,S=d.value.overrideMaterial,n.value.visible=!1,d.value.background=null,d.value.overrideMaterial=h,f.value.setRenderTarget(s),f.value.render(d.value,r.value),_(t.blur),t.smooth&&_(t.blur*.4),f.value.setRenderTarget(null),n.value.visible=!0,d.value.background=b,d.value.overrideMaterial=S)}),(L,P)=>(u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps({ref_key:"groupRef",ref:n},L.$attrs),[u.createElementVNode("TresMesh",{scale:[1,-1,1],geometry:u.unref(a)},[u.createElementVNode("TresMeshBasicMaterial",{map:u.unref(s).texture,opacity:L.opacity,"depth-write":L.depthWrite,transparent:!0},null,8,hf)],8,uf),u.createElementVNode("primitive",{object:u.unref(c)},null,8,ff),r.value&&L.helper?(u.openBlock(),u.createElementBlock("TresCameraHelper",{key:0,args:[r.value]},null,8,df)):u.createCommentVNode("",!0),u.createElementVNode("TresOrthographicCamera",{ref_key:"shadowCamera",ref:r,position:[0,0,0],rotation:[Math.PI/2,0,0],args:[-p.value/2,p.value/2,g.value/2,-g.value/2,0,L.far]},null,8,pf)],16))}}),gf=u.defineComponent({__name:"Fit",props:{into:{default:()=>new l.Box3(new l.Vector3(-.5,-.5,-.5),new l.Vector3(.5,.5,.5))},precise:{type:Boolean,default:!1}},setup(o,{expose:e}){const t=o,n=u.shallowRef(new l.Group),r=u.shallowRef(new l.Group);function s(c,h){if(n.value.position.set(0,0,0),n.value.updateMatrixWorld(),r.value.scale.set(1,1,1),r.value.updateMatrixWorld(),!r.value.children.length||c===null)return;const{box3:f,use:d}=i(c,h),p=new l.Box3;r.value.children.forEach(m=>p.expandByObject(m,h));const g=p.getSize(new l.Vector3),x=f.getSize(new l.Vector3),v=Math.min(x.x/g.x,x.y/g.y,x.z/g.z);r.value.scale.setScalar(v===Number.POSITIVE_INFINITY?1:v),r.value.updateMatrixWorld();const _=n.value.worldToLocal(p.getCenter(new l.Vector3));if(d.position){const m=n.value.worldToLocal(f.getCenter(new l.Vector3));n.value.position.copy(m.sub(_.multiplyScalar(v)))}else n.value.position.copy(_.sub(_.multiplyScalar(v)))}function i(c,h){return typeof c=="number"?c=new l.Vector3(c,c,c):Array.isArray(c)&&(c=new l.Vector3(...c)),c&&"isVector3"in c&&c.isVector3?{box3:new l.Box3(new l.Vector3(0,0,0),c),use:{position:!1}}:c&&"isBox3"in c&&c.isBox3?{box3:c,use:{position:!0}}:c&&"isObject3D"in c&&c.isObject3D?{box3:new l.Box3().setFromObject(c,h??!1),use:{position:!0}}:{box3:new l.Box3(new l.Vector3(-.5,-.5,-.5),new l.Vector3(.5,.5,.5)),use:{position:!0}}}u.watch(()=>[t.into,t.precise],()=>s(t.into,t.precise)),u.onMounted(()=>{s(t.into,t.precise),u.nextTick().then(()=>{s(t.into,t.precise)})});const a=u.shallowRef();return e({instance:a,fit:(c=new l.Box3(new l.Vector3(-.5,-.5,-.5),new l.Vector3(.5,.5,.5)),h=!1)=>{s(c,h)},update:()=>s(t.into,t.precise)}),(c,h)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"outer",ref:a},[u.createElementVNode("TresGroup",{ref_key:"middle",ref:n},[u.createElementVNode("TresGroup",{ref_key:"inner",ref:r},[u.renderSlot(c.$slots,"default")],512)],512)],512))}}),yf=["size","color","alpha-map","map","opacity","alpha-test","depth-write","transparent","size-attenuation"],vf=["position","velocity"],_f=u.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:c,depthWrite:h,transparent:f,sizeAttenuation:d,count:p,speed:g,randomness:x}=u.toRefs(e),v=u.shallowRef();let _=[],m=[];const M=()=>{_=new Float32Array(p.value*3);for(let L=0;L<p.value;L++){const P=L*3;_[P]=(Math.random()-.5)*n.value[0],_[P+1]=(Math.random()-.5)*n.value[1],_[P+2]=(Math.random()-.5)*n.value[2]}},b=()=>{m=new Float32Array(p.value*2);for(let L=0;L<p.value*2;L+=2)m[L]=(Math.random()-.5)/5*g.value*x.value,m[L+1]=Math.random()/5*g.value+.01};b(),M(),u.watchEffect(()=>{b(),M()});const{onLoop:S}=ie.useRenderLoop();return S(()=>{var L,P;if((L=v.value)!=null&&L.attributes.position.array&&((P=v.value)!=null&&P.attributes.position.count)){const T=v.value.attributes.position.array;for(let y=0;y<v.value.attributes.position.count;y++){const A=m[y*2],w=m[y*2+1];T[y*3]+=A,T[y*3+1]-=w,(T[y*3]<=-n.value[0]/2||T[y*3]>=n.value[0]/2)&&(T[y*3]=T[y*3]*-1),(T[y*3+1]<=-n.value[1]/2||T[y*3+1]>=n.value[1]/2)&&(T[y*3+1]=T[y*3+1]*-1)}v.value.attributes.position.needsUpdate=!0}}),(L,P)=>(u.openBlock(),u.createElementBlock("TresPoints",null,[u.createElementVNode("TresPointsMaterial",{size:u.unref(t),color:u.unref(r),"alpha-map":u.unref(s),map:u.unref(i),opacity:u.unref(a),"alpha-test":u.unref(c),"depth-write":u.unref(h),transparent:u.unref(f),"size-attenuation":u.unref(d)},null,8,yf),u.createElementVNode("TresBufferGeometry",{ref_key:"geometryRef",ref:v,position:[u.unref(_),3],velocity:[u.unref(m)]},null,8,vf)]))}});class Gn extends l.Mesh{constructor(){const e=Gn.SkyShader,t=new l.ShaderMaterial({name:e.name,uniforms:l.UniformsUtils.clone(e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,side:l.BackSide,depthWrite:!1});super(new l.BoxGeometry(1,1,1),t),this.isSky=!0}}Gn.SkyShader={name:"SkyShader",uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new l.Vector3},up:{value:new l.Vector3(0,1,0)}},vertexShader:`
|
|
1058
|
-
uniform vec3 sunPosition;
|
|
1059
|
-
uniform float rayleigh;
|
|
1060
|
-
uniform float turbidity;
|
|
1061
|
-
uniform float mieCoefficient;
|
|
1062
|
-
uniform vec3 up;
|
|
1063
|
-
|
|
1064
|
-
varying vec3 vWorldPosition;
|
|
1065
|
-
varying vec3 vSunDirection;
|
|
1066
|
-
varying float vSunfade;
|
|
1067
|
-
varying vec3 vBetaR;
|
|
1068
|
-
varying vec3 vBetaM;
|
|
1069
|
-
varying float vSunE;
|
|
1070
|
-
|
|
1071
|
-
// constants for atmospheric scattering
|
|
1072
|
-
const float e = 2.71828182845904523536028747135266249775724709369995957;
|
|
1073
|
-
const float pi = 3.141592653589793238462643383279502884197169;
|
|
1074
|
-
|
|
1075
|
-
// wavelength of used primaries, according to preetham
|
|
1076
|
-
const vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );
|
|
1077
|
-
// this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:
|
|
1078
|
-
// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))
|
|
1079
|
-
const vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );
|
|
1080
|
-
|
|
1081
|
-
// mie stuff
|
|
1082
|
-
// K coefficient for the primaries
|
|
1083
|
-
const float v = 4.0;
|
|
1084
|
-
const vec3 K = vec3( 0.686, 0.678, 0.666 );
|
|
1085
|
-
// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K
|
|
1086
|
-
const vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );
|
|
1087
|
-
|
|
1088
|
-
// earth shadow hack
|
|
1089
|
-
// cutoffAngle = pi / 1.95;
|
|
1090
|
-
const float cutoffAngle = 1.6110731556870734;
|
|
1091
|
-
const float steepness = 1.5;
|
|
1092
|
-
const float EE = 1000.0;
|
|
1093
|
-
|
|
1094
|
-
float sunIntensity( float zenithAngleCos ) {
|
|
1095
|
-
zenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );
|
|
1096
|
-
return EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
vec3 totalMie( float T ) {
|
|
1100
|
-
float c = ( 0.2 * T ) * 10E-18;
|
|
1101
|
-
return 0.434 * c * MieConst;
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
void main() {
|
|
1105
|
-
|
|
1106
|
-
vec4 worldPosition = modelMatrix * vec4( position, 1.0 );
|
|
1107
|
-
vWorldPosition = worldPosition.xyz;
|
|
1108
|
-
|
|
1109
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
1110
|
-
gl_Position.z = gl_Position.w; // set z to camera.far
|
|
1111
|
-
|
|
1112
|
-
vSunDirection = normalize( sunPosition );
|
|
1113
|
-
|
|
1114
|
-
vSunE = sunIntensity( dot( vSunDirection, up ) );
|
|
1115
|
-
|
|
1116
|
-
vSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );
|
|
1117
|
-
|
|
1118
|
-
float rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );
|
|
1119
|
-
|
|
1120
|
-
// extinction (absorbtion + out scattering)
|
|
1121
|
-
// rayleigh coefficients
|
|
1122
|
-
vBetaR = totalRayleigh * rayleighCoefficient;
|
|
1123
|
-
|
|
1124
|
-
// mie coefficients
|
|
1125
|
-
vBetaM = totalMie( turbidity ) * mieCoefficient;
|
|
1126
|
-
|
|
1127
|
-
}`,fragmentShader:`
|
|
1128
|
-
varying vec3 vWorldPosition;
|
|
1129
|
-
varying vec3 vSunDirection;
|
|
1130
|
-
varying float vSunfade;
|
|
1131
|
-
varying vec3 vBetaR;
|
|
1132
|
-
varying vec3 vBetaM;
|
|
1133
|
-
varying float vSunE;
|
|
1134
|
-
|
|
1135
|
-
uniform float mieDirectionalG;
|
|
1136
|
-
uniform vec3 up;
|
|
1137
|
-
|
|
1138
|
-
// constants for atmospheric scattering
|
|
1139
|
-
const float pi = 3.141592653589793238462643383279502884197169;
|
|
1140
|
-
|
|
1141
|
-
const float n = 1.0003; // refractive index of air
|
|
1142
|
-
const float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)
|
|
1143
|
-
|
|
1144
|
-
// optical length at zenith for molecules
|
|
1145
|
-
const float rayleighZenithLength = 8.4E3;
|
|
1146
|
-
const float mieZenithLength = 1.25E3;
|
|
1147
|
-
// 66 arc seconds -> degrees, and the cosine of that
|
|
1148
|
-
const float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;
|
|
1149
|
-
|
|
1150
|
-
// 3.0 / ( 16.0 * pi )
|
|
1151
|
-
const float THREE_OVER_SIXTEENPI = 0.05968310365946075;
|
|
1152
|
-
// 1.0 / ( 4.0 * pi )
|
|
1153
|
-
const float ONE_OVER_FOURPI = 0.07957747154594767;
|
|
1154
|
-
|
|
1155
|
-
float rayleighPhase( float cosTheta ) {
|
|
1156
|
-
return THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
float hgPhase( float cosTheta, float g ) {
|
|
1160
|
-
float g2 = pow( g, 2.0 );
|
|
1161
|
-
float inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );
|
|
1162
|
-
return ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );
|
|
1163
|
-
}
|
|
1164
|
-
|
|
1165
|
-
void main() {
|
|
1166
|
-
|
|
1167
|
-
vec3 direction = normalize( vWorldPosition - cameraPosition );
|
|
1168
|
-
|
|
1169
|
-
// optical length
|
|
1170
|
-
// cutoff angle at 90 to avoid singularity in next formula.
|
|
1171
|
-
float zenithAngle = acos( max( 0.0, dot( up, direction ) ) );
|
|
1172
|
-
float inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );
|
|
1173
|
-
float sR = rayleighZenithLength * inverse;
|
|
1174
|
-
float sM = mieZenithLength * inverse;
|
|
1175
|
-
|
|
1176
|
-
// combined extinction factor
|
|
1177
|
-
vec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );
|
|
1178
|
-
|
|
1179
|
-
// in scattering
|
|
1180
|
-
float cosTheta = dot( direction, vSunDirection );
|
|
1181
|
-
|
|
1182
|
-
float rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );
|
|
1183
|
-
vec3 betaRTheta = vBetaR * rPhase;
|
|
1184
|
-
|
|
1185
|
-
float mPhase = hgPhase( cosTheta, mieDirectionalG );
|
|
1186
|
-
vec3 betaMTheta = vBetaM * mPhase;
|
|
1187
|
-
|
|
1188
|
-
vec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );
|
|
1189
|
-
Lin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );
|
|
1190
|
-
|
|
1191
|
-
// nightsky
|
|
1192
|
-
float theta = acos( direction.y ); // elevation --> y-axis, [-pi/2, pi/2]
|
|
1193
|
-
float phi = atan( direction.z, direction.x ); // azimuth --> x-axis [-pi/2, pi/2]
|
|
1194
|
-
vec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );
|
|
1195
|
-
vec3 L0 = vec3( 0.1 ) * Fex;
|
|
1196
|
-
|
|
1197
|
-
// composition + solar disc
|
|
1198
|
-
float sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );
|
|
1199
|
-
L0 += ( vSunE * 19000.0 * Fex ) * sundisk;
|
|
1200
|
-
|
|
1201
|
-
vec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );
|
|
1202
|
-
|
|
1203
|
-
vec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );
|
|
1204
|
-
|
|
1205
|
-
gl_FragColor = vec4( retColor, 1.0 );
|
|
1206
|
-
|
|
1207
|
-
#include <tonemapping_fragment>
|
|
1208
|
-
#include <colorspace_fragment>
|
|
1209
|
-
|
|
1210
|
-
}`};const xf=["object","material-uniforms-turbidity-value","material-uniforms-rayleigh-value","material-uniforms-mie-coefficient-value","material-uniforms-mie-directional-g-value","material-uniforms-sun-position-value","scale"],wf=u.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=u.shallowRef(),r=new Gn,s=u.computed(()=>i(t.azimuth,t.elevation));function i(a,c){const h=l.MathUtils.degToRad(90-c),f=l.MathUtils.degToRad(a);return new l.Vector3().setFromSphericalCoords(1,h,f)}return e({root:n,sunPosition:s.value}),(a,c)=>(u.openBlock(),u.createElementBlock("primitive",{ref_key:"skyRef",ref:n,object:u.unref(r),"material-uniforms-turbidity-value":t.turbidity,"material-uniforms-rayleigh-value":t.rayleigh,"material-uniforms-mie-coefficient-value":t.mieCoefficient,"material-uniforms-mie-directional-g-value":t.mieDirectionalG,"material-uniforms-sun-position-value":s.value,scale:t.distance},null,8,xf))}}),bf=["position"],Mf=["position"],Sf=["scale"],Af=["map","depth-test","color-space","color","opacity"],Cf=u.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:c,color:h,depthTest:f,opacity:d,speed:p}=u.toRefs(r),g=u.shallowRef(),x=u.shallowRef();e({value:g});const v=[a].map((P,T)=>({x:s.value/2-Math.random()*s.value,y:s.value/2-Math.random()*s.value,scale:.4+Math.sin((T+1)/a.value*Math.PI)*((.2+Math.random())*10),density:Math.max(.2,Math.random()),rotation:Math.max(.002,.005*Math.random())*p.value})),_=(P,T)=>P/6*T*d.value,{map:m}=([t,n]=u.withAsyncContext(()=>ie.useTexture({map:c.value})),t=await t,n(),t),{renderer:M,camera:b}=ie.useTresContext(),S=u.computed(()=>{var P;return(P=M.value)==null?void 0:P.outputColorSpace}),{onLoop:L}=ie.useRenderLoop();return L(()=>{var P,T;g.value&&b.value&&x.value&&((P=x.value)==null||P.children.forEach((y,A)=>{y.rotation.z+=v[A].rotation}),g.value.lookAt((T=b.value)==null?void 0:T.position))}),(P,T)=>(u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps({ref_key:"smokeRef",ref:g},P.$attrs),[u.createElementVNode("TresGroup",{ref_key:"groupRef",ref:x,position:[0,0,u.unref(a)/2*u.unref(i)]},[(u.openBlock(!0),u.createElementBlock(u.Fragment,null,u.renderList(u.unref(v),({scale:y,x:A,y:w,density:D},k)=>(u.openBlock(),u.createElementBlock("TresMesh",{key:`${k}`,position:[A,w,-k*u.unref(i)]},[u.createElementVNode("TresPlaneGeometry",{scale:[y,y,y],rotation:[0,0,0]},null,8,Sf),u.createElementVNode("TresMeshStandardMaterial",{map:u.unref(m),"depth-test":u.unref(f),"color-space":S.value,color:u.unref(h),"depth-write":!1,transparent:"",opacity:_(y,D)},null,8,Af)],8,Mf))),128))],8,bf)],16))}});function Pf(o){return Rr(o,{normalizeValue:e=>ie.normalizeColor(e),getDefaultValue:()=>new l.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 jr(o){return"isVector3"in o||Array.isArray(o)&&o.length>0&&o.every(e=>typeof e=="number")}function Tf(o){return Rr(o,{normalizeValue:e=>ie.normalizeVectorFlexibleParam(e),getDefaultValue:()=>[0,0,0],isSingleValue:e=>jr(e),isMultipleValues:e=>Array.isArray(e)&&e.length>0&&jr(e[0]),isMultipleValuesWithStops:e=>Array.isArray(e)&&e.length>0&&Array.isArray(e[0])&&e[0].length===2&&jr(e[0][1]),isEmpty:e=>Array.isArray(e)&&e.length===0})}function If(o){return Rr(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 Rr(o,e){const{normalizeValue:t,getDefaultValue:n,isEmpty:r}=e,s=c=>e.isSingleValue(c),i=c=>e.isMultipleValues(c),a=c=>e.isMultipleValuesWithStops(c);if(r(o))return[[0,n()]];if(s(o))return[[0,t(o)]];if(i(o)){const c=o.length>1?1/(o.length-1):1;return o.map((h,f)=>[c*f,t(h)])}else if(a(o))return o.map(([c,h],f)=>[c,t(h)]);return[[0,n()]]}class Lf{constructor(e,t){ce(this,"entries");ce(this,"resolution");this.entries=e,this.resolution=t}useTexture(){return new kf(this.entries,this.resolution).use()}}class Wr{constructor(e,t,n,r,s,i){ce(this,"data");ce(this,"ref");ce(this,"name");ce(this,"valueMin");ce(this,"valueMax");ce(this,"suffix");ce(this,"renderToCanvasGradient");this.data=u.isRef(e)?e.value:e,this.ref=u.isRef(e)?e:null,this.name=t,this.valueMin=n,this.valueMax=r,this.suffix=s,this.renderToCanvasGradient=i}}class Of extends Wr{constructor(e,t="color",n=0,r=1,s="rgba",i=Bf){super(e,t,n,r,s,i)}}class Yi extends Wr{constructor(e,t="scalar",n=0,r=1,s="x",i=Ff){super(e,t,n,r,s,i)}}class Df extends Wr{constructor(e,t="scalar3",n=0,r=1,s="xyz",i=Uf){super(e,t,n,r,s,i)}}class kf{constructor(e,t){ce(this,"entries");ce(this,"size");ce(this,"dirty",u.shallowRef(0));ce(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=u.shallowRef(e);for(const n of this.entries)n.ref&&u.watch(n.ref,()=>{var r;n.data=(r=n.ref)==null?void 0:r.value,u.triggerRef(this.dirty)});return Al(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 l.DataTexture(this.context.getImageData(0,0,this.size,this.size).data,this.size,this.size,l.RGBAFormat,l.UnsignedByteType,l.UVMapping,l.ClampToEdgeWrapping,l.ClampToEdgeWrapping);return t.needsUpdate=!0,t}}function Ei(o,e,t,n,r){return Nc(bt(o,e,t),e,t,n,r)}function Bf(o,e){return Pf(e.data).forEach(([t,n])=>o.addColorStop(t,`rgb(${n.r*255}, ${n.g*255}, ${n.b*255})`))}function Ff(o,e){return If(e.data).forEach(([t,n])=>{o.addColorStop(t,`rgb(${Ei(n,e.valueMin,e.valueMax,0,255)}, 0, 0)`)})}function Uf(o,e){return Tf(e.data).forEach(([t,n])=>o.addColorStop(t,`rgb(${n.map(r=>Ei(r,e.valueMin,e.valueMax,0,255))})`))}class Nf{constructor(e=256){ce(this,"entries");ce(this,"resolution");this.resolution=e,this.entries=[]}withResolution(e){return this.resolution=e,this}get add(){return new zf(e=>this.onAdd(e))}build(){return new Lf(this.entries,this.resolution)}onAdd(e){return this.entries.push(e),new Vf(e,this)}}class Vf{constructor(e,t){ce(this,"entry");ce(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 zf{constructor(e){ce(this,"onAdd");this.onAdd=e}GradientTresColor(e){return this.onAdd(new Of(e))}Gradient01(e){return this.onAdd(new Yi(e,"zeroOne",0,1))}GradientScalar(e,t,n){return this.onAdd(new Yi(e,"scalar",t,n))}GradientXyz(e,t,n){return this.onAdd(new Df(e,"position",t,n))}}let Yr=null;function Gf(){return Yr===null&&(Yr=new l.DataTexture(new Uint8Array([0,0,0,0]),1,1)),Yr}const jf=["object"],Rf=u.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:l.AdditiveBlending},transparent:{type:Boolean,default:!0},depthWrite:{type:Boolean,default:!1}},setup(o){const e=o,t=Number.parseInt(l.REVISION.replace(/\D+/g,"")),n=u.toRefs(e),r=typeof e.map=="string"?Gf():e.map,{texture:s,yFor:i}=new Nf(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 l.Uniform(r),uPixelRatio:new l.Uniform(1),uNormal:new l.Uniform(l.Object3D.DEFAULT_UP),uNormalThreshold:new l.Uniform(e.normalThreshold),uTime:new l.Uniform(0),uCooldownRatio:new l.Uniform(1),uSize:new l.Uniform(e.size),uAlpha:new l.Uniform(e.alpha),uOffset:new l.Uniform(e.offset),uSurfaceDistance:new l.Uniform(e.surfaceDistance),uNoiseScale:new l.Uniform(e.noiseScale),uScaleNoise:new l.Uniform(e.scaleNoise),uOffsetNoise:new l.Uniform(e.offsetNoise),uLifetimeNoise:new l.Uniform(e.lifetimeNoise),uMixColor:new l.Uniform(e.mixColor),uMixAlpha:new l.Uniform(e.mixAlpha),uMixOffset:new l.Uniform(e.mixOffset),uMixSize:new l.Uniform(e.mixSize),uMixSurfaceDistance:new l.Uniform(e.mixSurfaceDistance),uMixNoise:new l.Uniform(e.mixNoise),uInfoTexture:new l.Uniform(s.value)},vertexShader:`
|
|
1321
|
+
`),O.fragmentShader=O.fragmentShader.replace("vec4( vec3( 1.0 - fragCoordZ ), opacity );","vec4( ucolor * fragCoordZ * 2.0, ( 1.0 - fragCoordZ ) * 1.0 );")})});const _=new l.ShaderMaterial(Qa),v=new l.ShaderMaterial(Ja);v.depthTest=_.depthTest=!1;function y(O){!d.value||!r.value||(c.visible=!0,c.material=_,_.uniforms.tDiffuse.value=s.texture,_.uniforms.h.value=O/256,d.value.setRenderTarget(i),d.value.render(c,r.value),c.material=v,v.uniforms.tDiffuse.value=i.texture,v.uniforms.v.value=O/256,d.value.setRenderTarget(s),d.value.render(c,r.value),c.visible=!1)}const{onBeforeRender:g}=te.useLoop();let M=0,b,S;return g(()=>{!r.value||f.value===void 0||d.value===void 0||(t.frames===Number.POSITIVE_INFINITY||M<t.frames)&&(M++,b=f.value.background,S=f.value.overrideMaterial,n.value.visible=!1,f.value.background=null,f.value.overrideMaterial=h,d.value.setRenderTarget(s),d.value.render(f.value,r.value),y(t.blur),t.smooth&&y(t.blur*.4),d.value.setRenderTarget(null),n.value.visible=!0,f.value.background=b,f.value.overrideMaterial=S)}),(O,T)=>(u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps({ref_key:"groupRef",ref:n},O.$attrs),[u.createElementVNode("TresMesh",{scale:[1,-1,1],geometry:u.unref(a)},[u.createElementVNode("TresMeshBasicMaterial",{map:u.unref(s).texture,opacity:O.opacity,"depth-write":O.depthWrite,transparent:!0},null,8,qf)],8,Kf),u.createElementVNode("primitive",{object:u.unref(c)},null,8,Qf),r.value&&O.helper?(u.openBlock(),u.createElementBlock("TresCameraHelper",{key:0,args:[r.value]},null,8,Jf)):u.createCommentVNode("",!0),u.createElementVNode("TresOrthographicCamera",{ref_key:"shadowCamera",ref:r,position:[0,0,0],rotation:[Math.PI/2,0,0],args:[-p.value/2,p.value/2,m.value/2,-m.value/2,0,O.far]},null,8,Hf)],16))}}),ed=u.defineComponent({__name:"Fit",props:{into:{default:()=>new l.Box3(new l.Vector3(-.5,-.5,-.5),new l.Vector3(.5,.5,.5))},precise:{type:Boolean,default:!1}},setup(o,{expose:e}){const t=o;Ie(t);const n=u.shallowRef(new l.Group),r=u.shallowRef(new l.Group);function s(c,h){if(n.value.position.set(0,0,0),n.value.updateMatrixWorld(),r.value.scale.set(1,1,1),r.value.updateMatrixWorld(),!r.value.children.length||c===null)return;const{box3:d,use:f}=i(c,h),p=new l.Box3;r.value.children.forEach(g=>p.expandByObject(g,h));const m=p.getSize(new l.Vector3),_=d.getSize(new l.Vector3),v=Math.min(_.x/m.x,_.y/m.y,_.z/m.z);r.value.scale.setScalar(v===Number.POSITIVE_INFINITY?1:v),r.value.updateMatrixWorld();const y=n.value.worldToLocal(p.getCenter(new l.Vector3));if(f.position){const g=n.value.worldToLocal(d.getCenter(new l.Vector3));n.value.position.copy(g.sub(y.multiplyScalar(v)))}else n.value.position.copy(y.sub(y.multiplyScalar(v)))}function i(c,h){return typeof c=="number"?c=new l.Vector3(c,c,c):Array.isArray(c)&&(c=new l.Vector3(...c)),c&&"isVector3"in c&&c.isVector3?{box3:new l.Box3(new l.Vector3(0,0,0),c),use:{position:!1}}:c&&"isBox3"in c&&c.isBox3?{box3:c,use:{position:!0}}:c&&"isObject3D"in c&&c.isObject3D?{box3:new l.Box3().setFromObject(c,h??!1),use:{position:!0}}:{box3:new l.Box3(new l.Vector3(-.5,-.5,-.5),new l.Vector3(.5,.5,.5)),use:{position:!0}}}u.watch(()=>[t.into,t.precise],()=>s(t.into,t.precise)),u.onMounted(()=>{s(t.into,t.precise),u.nextTick().then(()=>{s(t.into,t.precise)})});const a=u.shallowRef();return e({instance:a,fit:(c=new l.Box3(new l.Vector3(-.5,-.5,-.5),new l.Vector3(.5,.5,.5)),h=!1)=>{s(c,h)},update:()=>s(t.into,t.precise)}),(c,h)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"outer",ref:a},[u.createElementVNode("TresGroup",{ref_key:"middle",ref:n},[u.createElementVNode("TresGroup",{ref_key:"inner",ref:r},[u.renderSlot(c.$slots,"default")],512)],512)],512))}}),td=["size","color","alpha-map","map","opacity","alpha-test","depth-write","transparent","size-attenuation"],nd=["position","velocity"],rd=u.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,{expose:e}){const t=o,{size:n,area:r,color:s,alphaMap:i,map:a,opacity:c,alphaTest:h,depthWrite:d,transparent:f,sizeAttenuation:p,count:m,speed:_,randomness:v}=u.toRefs(t),{invalidateOnDemand:y}=Ie(t),g=u.shallowRef();let M=[],b=[];const S=()=>{M=new Float32Array(m.value*3);for(let w=0;w<m.value;w++){const A=w*3;M[A]=(Math.random()-.5)*r.value[0],M[A+1]=(Math.random()-.5)*r.value[1],M[A+2]=(Math.random()-.5)*r.value[2]}},O=()=>{b=new Float32Array(m.value*2);for(let w=0;w<m.value*2;w+=2)b[w]=(Math.random()-.5)/5*_.value*v.value,b[w+1]=Math.random()/5*_.value};O(),S(),u.watchEffect(()=>{O(),S()});const{onBeforeRender:T}=te.useLoop();T(()=>{var w,A;if((w=g.value)!=null&&w.attributes.position.array&&((A=g.value)!=null&&A.attributes.position.count)){const x=g.value.attributes.position.array;for(let D=0;D<g.value.attributes.position.count;D++){const L=b[D*2],V=b[D*2+1];x[D*3]+=L,x[D*3+1]-=V,(x[D*3]<=-r.value[0]/2||x[D*3]>=r.value[0]/2)&&(x[D*3]=x[D*3]*-1),(x[D*3+1]<=-r.value[1]/2||x[D*3+1]>=r.value[1]/2)&&(x[D*3+1]=x[D*3+1]*-1)}g.value.attributes.position.needsUpdate=!0,y()}});const C=u.shallowRef();return e({instance:C}),(w,A)=>(u.openBlock(),u.createElementBlock("TresPoints",{ref_key:"pointsRef",ref:C},[u.createElementVNode("TresPointsMaterial",{size:u.unref(n),color:u.unref(s),"alpha-map":u.unref(i),map:u.unref(a),opacity:u.unref(c),"alpha-test":u.unref(h),"depth-write":u.unref(d),transparent:u.unref(f),"size-attenuation":u.unref(p)},null,8,td),u.createElementVNode("TresBufferGeometry",{ref_key:"geometryRef",ref:g,position:[u.unref(M),3],velocity:[u.unref(b)]},null,8,nd)],512))}}),sd=["object","material-uniforms-turbidity-value","material-uniforms-rayleigh-value","material-uniforms-mieCoefficient-value","material-uniforms-mieDirectionalG-value","material-uniforms-sunPosition-value","scale"],id=u.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;Ie(t);const n=u.shallowRef(),r=new sr,s=u.computed(()=>i(t.azimuth,t.elevation));function i(a,c){const h=l.MathUtils.degToRad(90-c),d=l.MathUtils.degToRad(a);return new l.Vector3().setFromSphericalCoords(1,h,d)}return e({instance:n,sunPosition:s.value}),(a,c)=>(u.openBlock(),u.createElementBlock("primitive",{ref_key:"skyRef",ref:n,object:u.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,sd))}}),od=["position"],ad=["position"],ld=["scale"],cd=["map","depth-test","color-space","color","opacity"],ud=u.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:c,color:h,depthTest:d,opacity:f,speed:p}=u.toRefs(r),{invalidateOnDemand:m}=Ie(r),_=u.shallowRef(),v=u.shallowRef();e({instance:_});const y=[a].map((C,w)=>({x:s.value/2-Math.random()*s.value,y:s.value/2-Math.random()*s.value,scale:.4+Math.sin((w+1)/a.value*Math.PI)*((.2+Math.random())*10),density:Math.max(.2,Math.random()),rotation:Math.max(.002,.005*Math.random())*p.value})),g=(C,w)=>C/6*w*f.value,{map:M}=([t,n]=u.withAsyncContext(()=>te.useTexture({map:c.value})),t=await t,n(),t),{renderer:b,camera:S}=te.useTresContext(),O=u.computed(()=>{var C;return(C=b.value)==null?void 0:C.outputColorSpace}),{onBeforeRender:T}=te.useLoop();return T(()=>{var C,w;_.value&&S.value&&v.value&&((C=v.value)==null||C.children.forEach((A,x)=>{A.rotation.z+=y[x].rotation}),_.value.lookAt((w=S.value)==null?void 0:w.position),m())}),(C,w)=>(u.openBlock(),u.createElementBlock("TresGroup",u.mergeProps({ref_key:"smokeRef",ref:_},C.$attrs),[u.createElementVNode("TresGroup",{ref_key:"groupRef",ref:v,position:[0,0,u.unref(a)/2*u.unref(i)]},[(u.openBlock(!0),u.createElementBlock(u.Fragment,null,u.renderList(u.unref(y),({scale:A,x,y:D,density:L},V)=>(u.openBlock(),u.createElementBlock("TresMesh",{key:`${V}`,position:[x,D,-V*u.unref(i)]},[u.createElementVNode("TresPlaneGeometry",{scale:[A,A,A],rotation:[0,0,0]},null,8,ld),u.createElementVNode("TresMeshStandardMaterial",{map:u.unref(M),"depth-test":u.unref(d),"color-space":O.value,color:u.unref(h),"depth-write":!1,transparent:"",opacity:g(A,L)},null,8,cd)],8,ad))),128))],8,od)],16))}});function hd(o){return Xr(o,{normalizeValue:e=>te.normalizeColor(e),getDefaultValue:()=>new l.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 Wr(o){return"isVector3"in o||Array.isArray(o)&&o.length>0&&o.every(e=>typeof e=="number")}function fd(o){return Xr(o,{normalizeValue:e=>te.normalizeVectorFlexibleParam(e),getDefaultValue:()=>[0,0,0],isSingleValue:e=>Wr(e),isMultipleValues:e=>Array.isArray(e)&&e.length>0&&Wr(e[0]),isMultipleValuesWithStops:e=>Array.isArray(e)&&e.length>0&&Array.isArray(e[0])&&e[0].length===2&&Wr(e[0][1]),isEmpty:e=>Array.isArray(e)&&e.length===0})}function dd(o){return Xr(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 Xr(o,e){const{normalizeValue:t,getDefaultValue:n,isEmpty:r}=e,s=c=>e.isSingleValue(c),i=c=>e.isMultipleValues(c),a=c=>e.isMultipleValuesWithStops(c);if(r(o))return[[0,n()]];if(s(o))return[[0,t(o)]];if(i(o)){const c=o.length>1?1/(o.length-1):1;return o.map((h,d)=>[c*d,t(h)])}else if(a(o))return o.map(([c,h],d)=>[c,t(h)]);return[[0,n()]]}class pd{constructor(e,t){ue(this,"entries");ue(this,"resolution");this.entries=e,this.resolution=t}useTexture(){return new yd(this.entries,this.resolution).use()}}class Zr{constructor(e,t,n,r,s,i){ue(this,"data");ue(this,"ref");ue(this,"name");ue(this,"valueMin");ue(this,"valueMax");ue(this,"suffix");ue(this,"renderToCanvasGradient");this.data=u.isRef(e)?e.value:e,this.ref=u.isRef(e)?e:null,this.name=t,this.valueMin=n,this.valueMax=r,this.suffix=s,this.renderToCanvasGradient=i}}class md extends Zr{constructor(e,t="color",n=0,r=1,s="rgba",i=_d){super(e,t,n,r,s,i)}}class $i extends Zr{constructor(e,t="scalar",n=0,r=1,s="x",i=vd){super(e,t,n,r,s,i)}}class gd extends Zr{constructor(e,t="scalar3",n=0,r=1,s="xyz",i=xd){super(e,t,n,r,s,i)}}class yd{constructor(e,t){ue(this,"entries");ue(this,"size");ue(this,"dirty",u.shallowRef(0));ue(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=u.shallowRef(e);for(const n of this.entries)n.ref&&u.watch(n.ref,()=>{var r;n.data=(r=n.ref)==null?void 0:r.value,u.triggerRef(this.dirty)});return Gl(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 l.DataTexture(this.context.getImageData(0,0,this.size,this.size).data,this.size,this.size,l.RGBAFormat,l.UnsignedByteType,l.UVMapping,l.ClampToEdgeWrapping,l.ClampToEdgeWrapping);return t.needsUpdate=!0,t}}function eo(o,e,t,n,r){return _u(St(o,e,t),e,t,n,r)}function _d(o,e){return hd(e.data).forEach(([t,n])=>o.addColorStop(t,`rgb(${n.r*255}, ${n.g*255}, ${n.b*255})`))}function vd(o,e){return dd(e.data).forEach(([t,n])=>{o.addColorStop(t,`rgb(${eo(n,e.valueMin,e.valueMax,0,255)}, 0, 0)`)})}function xd(o,e){return fd(e.data).forEach(([t,n])=>o.addColorStop(t,`rgb(${n.map(r=>eo(r,e.valueMin,e.valueMax,0,255))})`))}class wd{constructor(e=256){ue(this,"entries");ue(this,"resolution");this.resolution=e,this.entries=[]}withResolution(e){return this.resolution=e,this}get add(){return new Md(e=>this.onAdd(e))}build(){return new pd(this.entries,this.resolution)}onAdd(e){return this.entries.push(e),new bd(e,this)}}class bd{constructor(e,t){ue(this,"entry");ue(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 Md{constructor(e){ue(this,"onAdd");this.onAdd=e}GradientTresColor(e){return this.onAdd(new md(e))}Gradient01(e){return this.onAdd(new $i(e,"zeroOne",0,1))}GradientScalar(e,t,n){return this.onAdd(new $i(e,"scalar",t,n))}GradientXyz(e,t,n){return this.onAdd(new gd(e,"position",t,n))}}let Kr=null;function Sd(){return Kr===null&&(Kr=new l.DataTexture(new Uint8Array([0,0,0,0]),1,1)),Kr}const Ad=["object"],Cd=u.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:l.AdditiveBlending},transparent:{type:Boolean,default:!0},depthWrite:{type:Boolean,default:!1}},setup(o,{expose:e}){const t=o,n=Number.parseInt(l.REVISION.replace(/\D+/g,"")),r=u.toRefs(t),s=typeof t.map=="string"?Sd():t.map,{texture:i,yFor:a}=new wd(256).add.GradientTresColor(r.sequenceColor).id("sequenceColor").add.Gradient01(r.sequenceAlpha).id("sequenceAlpha").add.Gradient01(r.sequenceSurfaceDistance).id("sequenceSurfaceDistance").add.Gradient01(r.sequenceSize).id("sequenceSize").add.GradientXyz(r.sequenceOffset,-1,1).id("sequenceOffset").add.GradientXyz(r.sequenceNoise,0,1).id("sequenceNoise").build().useTexture(),c={blending:t.blending,transparent:t.transparent,depthWrite:t.depthWrite,uniforms:{uMap:new l.Uniform(s),uPixelRatio:new l.Uniform(1),uNormal:new l.Uniform(l.Object3D.DEFAULT_UP),uNormalThreshold:new l.Uniform(t.normalThreshold),uTime:new l.Uniform(0),uCooldownRatio:new l.Uniform(1),uSize:new l.Uniform(t.size),uAlpha:new l.Uniform(t.alpha),uOffset:new l.Uniform(t.offset),uSurfaceDistance:new l.Uniform(t.surfaceDistance),uNoiseScale:new l.Uniform(t.noiseScale),uScaleNoise:new l.Uniform(t.scaleNoise),uOffsetNoise:new l.Uniform(t.offsetNoise),uLifetimeNoise:new l.Uniform(t.lifetimeNoise),uMixColor:new l.Uniform(t.mixColor),uMixAlpha:new l.Uniform(t.mixAlpha),uMixOffset:new l.Uniform(t.mixOffset),uMixSize:new l.Uniform(t.mixSize),uMixSurfaceDistance:new l.Uniform(t.mixSurfaceDistance),uMixNoise:new l.Uniform(t.mixNoise),uInfoTexture:new l.Uniform(i.value)},vertexShader:`
|
|
1211
1322
|
uniform float uPixelRatio;
|
|
1212
1323
|
uniform vec3 uNormal;
|
|
1213
1324
|
uniform float uNormalThreshold;
|
|
@@ -1242,15 +1353,15 @@ list should be an Array.`),C.length===0)return new _(0);if(C.length===1)return C
|
|
|
1242
1353
|
float lifetimeP = max(-0.0001, mix(-uCooldownRatio, 1. + cos(t) * lifetimeNoise, fract(t)));
|
|
1243
1354
|
float surfaceDistance = texture2D(uInfoTexture, vec2(
|
|
1244
1355
|
mix(normalP, lifetimeP, uMixSurfaceDistance),
|
|
1245
|
-
${
|
|
1356
|
+
${a.sequenceSurfaceDistance})).x * uSurfaceDistance;
|
|
1246
1357
|
|
|
1247
1358
|
vec4 modelPosition = modelMatrix * (vec4(position, 1.0) + vec4(normal * surfaceDistance, 0.0));
|
|
1248
1359
|
vec3 noise = texture2D(uInfoTexture, vec2(
|
|
1249
1360
|
mix(normalP, lifetimeP, uMixNoise),
|
|
1250
|
-
${
|
|
1361
|
+
${a.sequenceNoise})).xyz;
|
|
1251
1362
|
vec3 offset = uOffset * (texture2D(uInfoTexture, vec2(
|
|
1252
1363
|
mix(normalP, lifetimeP, uMixOffset),
|
|
1253
|
-
${
|
|
1364
|
+
${a.sequenceOffset})).xyz * 2.0 - vec3(1.0, 1.0, 1.0));
|
|
1254
1365
|
modelPosition.x += cos(t * uNoiseScale * 10.0) * 0.2 * uOffsetNoise * noise.x + offset.x;
|
|
1255
1366
|
modelPosition.y += sin(t * uNoiseScale * 10.0) * 0.2 * uOffsetNoise * noise.y + offset.y;
|
|
1256
1367
|
modelPosition.z += cos(t * uNoiseScale * 10.0) * 0.2 * uOffsetNoise * noise.z + offset.z;
|
|
@@ -1260,14 +1371,14 @@ list should be an Array.`),C.length===0)return new _(0);if(C.length===1)return C
|
|
|
1260
1371
|
gl_Position = projectionPostion;
|
|
1261
1372
|
|
|
1262
1373
|
gl_PointSize = 2.
|
|
1263
|
-
* texture2D(uInfoTexture, vec2(mix(normalP, lifetimeP, uMixSize), ${
|
|
1374
|
+
* texture2D(uInfoTexture, vec2(mix(normalP, lifetimeP, uMixSize), ${a.sequenceSize})).x
|
|
1264
1375
|
* mix(1., abs(sin(t * uNoiseScale + position.x * 13.9 + position.y * 73.1)), uScaleNoise)
|
|
1265
1376
|
* uSize * (100.0 / -viewPosition.z) * uPixelRatio;
|
|
1266
1377
|
|
|
1267
1378
|
if (gl_PointSize < 0.6 || lifetimeP < 0.0) { gl_Position = vec4(2, 2, 2, 1); }
|
|
1268
1379
|
|
|
1269
|
-
vColor = texture2D(uInfoTexture, vec2(mix(normalP, lifetimeP, uMixColor), ${
|
|
1270
|
-
* texture2D(uInfoTexture, vec2(mix(normalP, lifetimeP, uMixAlpha), ${
|
|
1380
|
+
vColor = texture2D(uInfoTexture, vec2(mix(normalP, lifetimeP, uMixColor), ${a.sequenceColor}))
|
|
1381
|
+
* texture2D(uInfoTexture, vec2(mix(normalP, lifetimeP, uMixAlpha), ${a.sequenceAlpha})).x * uAlpha;
|
|
1271
1382
|
}`,fragmentShader:`
|
|
1272
1383
|
varying vec4 vColor;
|
|
1273
1384
|
|
|
@@ -1277,104 +1388,8 @@ list should be an Array.`),C.length===0)return new _(0);if(C.length===1)return C
|
|
|
1277
1388
|
void main() {
|
|
1278
1389
|
gl_FragColor = vColor * texture2D(uMap, gl_PointCoord);
|
|
1279
1390
|
#include <tonemapping_fragment>
|
|
1280
|
-
#include <${
|
|
1281
|
-
}`},c=new l.ShaderMaterial(a),h=new l.Points(void 0,c),f=c.uniforms,d={immediate:!0};[[f.uPixelRatio,ie.useTresContext().sizes.aspectRatio],[f.uSize,n.size],[f.uNormalThreshold,n.normalThreshold],[f.uAlpha,n.alpha],[f.uOffset,n.offset],[f.uOffsetNoise,n.offsetNoise],[f.uMixColor,n.mixColor],[f.uMixAlpha,n.mixAlpha],[f.uMixOffset,n.mixOffset],[f.uMixSize,n.mixSize],[f.uMixSurfaceDistance,n.mixSurfaceDistance],[f.uMixNoise,n.mixNoise],[f.uInfoTexture,s]].forEach(([M,b])=>u.watch(b,()=>{M.value=b.value},d)),u.watch([n.noiseScale,n.lifetimeSec],()=>{f.uNoiseScale.value=n.noiseScale.value*n.lifetimeSec.value},d),u.watch([n.lifetimeSec,n.cooldownSec],()=>{f.uCooldownRatio.value=n.cooldownSec.value/n.lifetimeSec.value},d),u.watch(n.map,()=>{typeof n.map.value=="string"?ie.useTexture([n.map.value]).then(M=>c.uniforms.uMap.value=M):c.uniforms.uMap.value=n.map.value});const g=new l.Quaternion,x=new l.Vector3;ie.useRenderLoop().onLoop(({elapsed:M})=>{h.getWorldQuaternion(g),x.copy(e.directionalLight?e.directionalLight.position:l.Object3D.DEFAULT_UP).normalize(),x.applyQuaternion(g.invert()),c.uniforms.uNormal.value=x,c.uniforms.uTime.value=M/(e.cooldownSec+e.lifetimeSec)});function v(M){return M&&"isObject3D"in M}function _(M){return M&&"isBufferGeometry"in M}u.onMounted(()=>{e.geometry?_(e.geometry)?h.geometry.copy(e.geometry):v(e.geometry)&&"geometry"in e.geometry&&_(e.geometry.geometry)&&h.geometry.copy(e.geometry.geometry):v(h.parent)&&"geometry"in h.parent&&_(h.parent.geometry)?h.geometry.copy(h.parent.geometry):h.geometry=new l.IcosahedronGeometry(1,16),typeof e.map=="string"&&ie.useTexture([e.map]).then(M=>c.uniforms.uMap.value=M)}),u.onUnmounted(()=>{var M;(M=c.uniforms.uMap.value)==null||M.dispose(),s.value.dispose(),c.dispose()});const m=u.shallowRef();return(M,b)=>(u.openBlock(),u.createElementBlock("primitive",{ref_key:"sparkleRef",ref:m,object:u.unref(h)},null,8,jf))}}),Wf=["position","a-scale"],Yf=["size","size-attenuation","transparent","alpha-test","alpha-map"],Ef=u.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=u.ref(),r=u.ref(),{radius:s,depth:i,count:a,size:c,sizeAttenuation:h,transparent:f,alphaMap:d,alphaTest:p}=u.toRefs(t),g=()=>{let v=s.value+i.value;const _=u.computed(()=>i.value/a.value),m=[],M=Array.from({length:a.value},()=>(.5+.5*Math.random())*4),b=S=>new l.Vector3().setFromSpherical(new l.Spherical(S,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)).toArray();for(let S=0;S<a.value;S++)v-=_.value*Math.random(),m.push(...b(v));n.value=new Float32Array(m),r.value=new Float32Array(M)};u.watchEffect(()=>{g()});const x=u.shallowRef();return e({value:x}),(v,_)=>(u.openBlock(),u.createElementBlock("TresPoints",{ref_key:"starsRef",ref:x},[u.createElementVNode("TresBufferGeometry",{position:[n.value,3],"a-scale":[r.value,1]},null,8,Wf),u.createElementVNode("TresPointsMaterial",{size:u.unref(c),"size-attenuation":u.unref(h),transparent:u.unref(f),"alpha-test":u.unref(p),"alpha-map":u.unref(d)},null,8,Yf)],512))}});class Xf extends l.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,c=t.time!==void 0?t.time:0,h=t.waterNormals!==void 0?t.waterNormals:null,f=t.sunDirection!==void 0?t.sunDirection:new l.Vector3(.70707,.70707,0),d=new l.Color(t.sunColor!==void 0?t.sunColor:16777215),p=new l.Color(t.waterColor!==void 0?t.waterColor:8355711),g=t.eye!==void 0?t.eye:new l.Vector3(0,0,0),x=t.distortionScale!==void 0?t.distortionScale:20,v=t.side!==void 0?t.side:l.FrontSide,_=t.fog!==void 0?t.fog:!1,m=new l.Plane,M=new l.Vector3,b=new l.Vector3,S=new l.Vector3,L=new l.Matrix4,P=new l.Vector3(0,0,-1),T=new l.Vector4,y=new l.Vector3,A=new l.Vector3,w=new l.Vector4,D=new l.Matrix4,k=new l.PerspectiveCamera,R=new l.WebGLRenderTarget(r,s),V={name:"MirrorShader",uniforms:l.UniformsUtils.merge([l.UniformsLib.fog,l.UniformsLib.lights,{normalSampler:{value:null},mirrorSampler:{value:null},alpha:{value:1},time:{value:0},size:{value:1},distortionScale:{value:20},textureMatrix:{value:new l.Matrix4},sunColor:{value:new l.Color(8355711)},sunDirection:{value:new l.Vector3(.70707,.70707,0)},eye:{value:new l.Vector3},waterColor:{value:new l.Color(5592405)}}]),vertexShader:`
|
|
1282
|
-
uniform mat4 textureMatrix;
|
|
1283
|
-
uniform float time;
|
|
1284
|
-
|
|
1285
|
-
varying vec4 mirrorCoord;
|
|
1286
|
-
varying vec4 worldPosition;
|
|
1287
|
-
|
|
1288
|
-
#include <common>
|
|
1289
|
-
#include <fog_pars_vertex>
|
|
1290
|
-
#include <shadowmap_pars_vertex>
|
|
1291
|
-
#include <logdepthbuf_pars_vertex>
|
|
1292
|
-
|
|
1293
|
-
void main() {
|
|
1294
|
-
mirrorCoord = modelMatrix * vec4( position, 1.0 );
|
|
1295
|
-
worldPosition = mirrorCoord.xyzw;
|
|
1296
|
-
mirrorCoord = textureMatrix * mirrorCoord;
|
|
1297
|
-
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
1298
|
-
gl_Position = projectionMatrix * mvPosition;
|
|
1299
|
-
|
|
1300
|
-
#include <beginnormal_vertex>
|
|
1301
|
-
#include <defaultnormal_vertex>
|
|
1302
|
-
#include <logdepthbuf_vertex>
|
|
1303
|
-
#include <fog_vertex>
|
|
1304
|
-
#include <shadowmap_vertex>
|
|
1305
|
-
}`,fragmentShader:`
|
|
1306
|
-
uniform sampler2D mirrorSampler;
|
|
1307
|
-
uniform float alpha;
|
|
1308
|
-
uniform float time;
|
|
1309
|
-
uniform float size;
|
|
1310
|
-
uniform float distortionScale;
|
|
1311
|
-
uniform sampler2D normalSampler;
|
|
1312
|
-
uniform vec3 sunColor;
|
|
1313
|
-
uniform vec3 sunDirection;
|
|
1314
|
-
uniform vec3 eye;
|
|
1315
|
-
uniform vec3 waterColor;
|
|
1316
|
-
|
|
1317
|
-
varying vec4 mirrorCoord;
|
|
1318
|
-
varying vec4 worldPosition;
|
|
1319
|
-
|
|
1320
|
-
vec4 getNoise( vec2 uv ) {
|
|
1321
|
-
vec2 uv0 = ( uv / 103.0 ) + vec2(time / 17.0, time / 29.0);
|
|
1322
|
-
vec2 uv1 = uv / 107.0-vec2( time / -19.0, time / 31.0 );
|
|
1323
|
-
vec2 uv2 = uv / vec2( 8907.0, 9803.0 ) + vec2( time / 101.0, time / 97.0 );
|
|
1324
|
-
vec2 uv3 = uv / vec2( 1091.0, 1027.0 ) - vec2( time / 109.0, time / -113.0 );
|
|
1325
|
-
vec4 noise = texture2D( normalSampler, uv0 ) +
|
|
1326
|
-
texture2D( normalSampler, uv1 ) +
|
|
1327
|
-
texture2D( normalSampler, uv2 ) +
|
|
1328
|
-
texture2D( normalSampler, uv3 );
|
|
1329
|
-
return noise * 0.5 - 1.0;
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
void sunLight( const vec3 surfaceNormal, const vec3 eyeDirection, float shiny, float spec, float diffuse, inout vec3 diffuseColor, inout vec3 specularColor ) {
|
|
1333
|
-
vec3 reflection = normalize( reflect( -sunDirection, surfaceNormal ) );
|
|
1334
|
-
float direction = max( 0.0, dot( eyeDirection, reflection ) );
|
|
1335
|
-
specularColor += pow( direction, shiny ) * sunColor * spec;
|
|
1336
|
-
diffuseColor += max( dot( sunDirection, surfaceNormal ), 0.0 ) * sunColor * diffuse;
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
#include <common>
|
|
1340
|
-
#include <packing>
|
|
1341
|
-
#include <bsdfs>
|
|
1342
|
-
#include <fog_pars_fragment>
|
|
1343
|
-
#include <logdepthbuf_pars_fragment>
|
|
1344
|
-
#include <lights_pars_begin>
|
|
1345
|
-
#include <shadowmap_pars_fragment>
|
|
1346
|
-
#include <shadowmask_pars_fragment>
|
|
1347
|
-
|
|
1348
|
-
void main() {
|
|
1349
|
-
|
|
1350
|
-
#include <logdepthbuf_fragment>
|
|
1351
|
-
vec4 noise = getNoise( worldPosition.xz * size );
|
|
1352
|
-
vec3 surfaceNormal = normalize( noise.xzy * vec3( 1.5, 1.0, 1.5 ) );
|
|
1353
|
-
|
|
1354
|
-
vec3 diffuseLight = vec3(0.0);
|
|
1355
|
-
vec3 specularLight = vec3(0.0);
|
|
1356
|
-
|
|
1357
|
-
vec3 worldToEye = eye-worldPosition.xyz;
|
|
1358
|
-
vec3 eyeDirection = normalize( worldToEye );
|
|
1359
|
-
sunLight( surfaceNormal, eyeDirection, 100.0, 2.0, 0.5, diffuseLight, specularLight );
|
|
1360
|
-
|
|
1361
|
-
float distance = length(worldToEye);
|
|
1362
|
-
|
|
1363
|
-
vec2 distortion = surfaceNormal.xz * ( 0.001 + 1.0 / distance ) * distortionScale;
|
|
1364
|
-
vec3 reflectionSample = vec3( texture2D( mirrorSampler, mirrorCoord.xy / mirrorCoord.w + distortion ) );
|
|
1365
|
-
|
|
1366
|
-
float theta = max( dot( eyeDirection, surfaceNormal ), 0.0 );
|
|
1367
|
-
float rf0 = 0.3;
|
|
1368
|
-
float reflectance = rf0 + ( 1.0 - rf0 ) * pow( ( 1.0 - theta ), 5.0 );
|
|
1369
|
-
vec3 scatter = max( 0.0, dot( surfaceNormal, eyeDirection ) ) * waterColor;
|
|
1370
|
-
vec3 albedo = mix( ( sunColor * diffuseLight * 0.3 + scatter ) * getShadowMask(), ( vec3( 0.1 ) + reflectionSample * 0.9 + reflectionSample * specularLight ), reflectance);
|
|
1371
|
-
vec3 outgoingLight = albedo;
|
|
1372
|
-
gl_FragColor = vec4( outgoingLight, alpha );
|
|
1373
|
-
|
|
1374
|
-
#include <tonemapping_fragment>
|
|
1375
|
-
#include <colorspace_fragment>
|
|
1376
|
-
#include <fog_fragment>
|
|
1377
|
-
}`},Y=new l.ShaderMaterial({name:V.name,uniforms:l.UniformsUtils.clone(V.uniforms),vertexShader:V.vertexShader,fragmentShader:V.fragmentShader,lights:!0,side:v,fog:_});Y.uniforms.mirrorSampler.value=R.texture,Y.uniforms.textureMatrix.value=D,Y.uniforms.alpha.value=a,Y.uniforms.time.value=c,Y.uniforms.normalSampler.value=h,Y.uniforms.sunColor.value=d,Y.uniforms.waterColor.value=p,Y.uniforms.sunDirection.value=f,Y.uniforms.distortionScale.value=x,Y.uniforms.eye.value=g,n.material=Y,n.onBeforeRender=function(G,Q,K){if(b.setFromMatrixPosition(n.matrixWorld),S.setFromMatrixPosition(K.matrixWorld),L.extractRotation(n.matrixWorld),M.set(0,0,1),M.applyMatrix4(L),y.subVectors(b,S),y.dot(M)>0)return;y.reflect(M).negate(),y.add(b),L.extractRotation(K.matrixWorld),P.set(0,0,-1),P.applyMatrix4(L),P.add(S),A.subVectors(b,P),A.reflect(M).negate(),A.add(b),k.position.copy(y),k.up.set(0,1,0),k.up.applyMatrix4(L),k.up.reflect(M),k.lookAt(A),k.far=K.far,k.updateMatrixWorld(),k.projectionMatrix.copy(K.projectionMatrix),D.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),D.multiply(k.projectionMatrix),D.multiply(k.matrixWorldInverse),m.setFromNormalAndCoplanarPoint(M,b),m.applyMatrix4(k.matrixWorldInverse),T.set(m.normal.x,m.normal.y,m.normal.z,m.constant);const ne=k.projectionMatrix;w.x=(Math.sign(T.x)+ne.elements[8])/ne.elements[0],w.y=(Math.sign(T.y)+ne.elements[9])/ne.elements[5],w.z=-1,w.w=(1+ne.elements[10])/ne.elements[14],T.multiplyScalar(2/T.dot(w)),ne.elements[2]=T.x,ne.elements[6]=T.y,ne.elements[10]=T.z+1-i,ne.elements[14]=T.w,g.setFromMatrixPosition(K.matrixWorld);const ee=G.getRenderTarget(),le=G.xr.enabled,he=G.shadowMap.autoUpdate;n.visible=!1,G.xr.enabled=!1,G.shadowMap.autoUpdate=!1,G.setRenderTarget(R),G.state.buffers.depth.setMask(!0),G.autoClear===!1&&G.clear(),G.render(Q,k),n.visible=!0,G.xr.enabled=le,G.shadowMap.autoUpdate=he,G.setRenderTarget(ee);const de=K.viewport;de!==void 0&&G.state.viewport(de)}}}const Zf=["rotation-x","args"],qf=u.createElementVNode("TresPlaneGeometry",{args:[1e4,1e4]},null,-1),Kf=u.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 l.Vector3},sunColor:{default:16777215},waterColor:{default:7695},distortionScale:{default:3.7},size:{default:1},clipBias:{default:0},alpha:{default:1},side:{default:l.FrontSide}},async setup(o,{expose:e}){let t,n;const r=o,{textureWidth:s,textureHeight:i,waterNormals:a,sunDirection:c,sunColor:h,waterColor:f,distortionScale:d,size:p,clipBias:g,alpha:x,side:v}=u.toRefs(r),{extend:_,scene:m}=ie.useTresContext();_({Water:Xf});const M=u.shallowRef(),b=u.shallowRef(),S=m.value.fog!==void 0;e({root:M}),m.value.traverse(T=>{Object.prototype.hasOwnProperty.call(T,"isSky")&&(b.value=T)}),u.onMounted(async()=>{if(await u.nextTick(),b.value){const T=b.value.material.uniforms.sunPosition.value;M.value.material.uniforms.sunDirection.value.copy(T)}});const{normalMap:L}=([t,n]=u.withAsyncContext(()=>ie.useTexture({normalMap:a.value})),t=await t,n(),t);L.wrapS=L.wrapT=l.RepeatWrapping;const{onLoop:P}=ie.useRenderLoop();return P(({delta:T})=>{M.value.material.uniforms.time.value+=T}),(T,y)=>(u.openBlock(),u.createElementBlock("TresWater",{ref_key:"waterRef",ref:M,"rotation-x":-Math.PI/2,args:[void 0,{textureWidth:u.unref(s),textureHeight:u.unref(i),waterNormals:u.unref(L),sunDirection:u.unref(c),sunColor:u.unref(h),waterColor:u.unref(f),distortionScale:u.unref(d),fog:S,size:u.unref(p),clipBias:u.unref(g),alpha:u.unref(x),side:u.unref(v)}]},[u.renderSlot(T.$slots,"default",{},()=>[qf])],8,Zf))}});let ut;const Qf=(o="body")=>{ut||(ut=new $i.Pane({container:document.querySelector(o)}),ut.element.style.position="absolute",ut.element.style.top="1rem",ut.element.style.right="1rem",ut.element.style.zIndex="9999");const{logWarning:e}=yr();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(){ut&&ut.dispose()}return u.onMounted(()=>{const{resume:n}=ie.useRenderLoop();n()}),u.onUnmounted(()=>{t()}),{pane:ut,disposeTweakPane:t}};var Xi={exports:{}};(function(o,e){(function(t,n){o.exports=n()})(Wc,function(){var t=function(){function n(g){return i.appendChild(g.dom),g}function r(g){for(var x=0;x<i.children.length;x++)i.children[x].style.display=x===g?"block":"none";s=g}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(g){g.preventDefault(),r(++s%i.children.length)},!1);var a=(performance||Date).now(),c=a,h=0,f=n(new t.Panel("FPS","#0ff","#002")),d=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var p=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(){h++;var g=(performance||Date).now();if(d.update(g-a,200),g>c+1e3&&(f.update(1e3*h/(g-c),100),c=g,h=0,p)){var x=performance.memory;p.update(x.usedJSHeapSize/1048576,x.jsHeapSizeLimit/1048576)}return g},update:function(){a=this.end()},domElement:i,setMode:r}};return t.Panel=function(n,r,s){var i=1/0,a=0,c=Math.round,h=c(window.devicePixelRatio||1),f=80*h,d=48*h,p=3*h,g=2*h,x=3*h,v=15*h,_=74*h,m=30*h,M=document.createElement("canvas");M.width=f,M.height=d,M.style.cssText="width:80px;height:48px";var b=M.getContext("2d");return b.font="bold "+9*h+"px Helvetica,Arial,sans-serif",b.textBaseline="top",b.fillStyle=s,b.fillRect(0,0,f,d),b.fillStyle=r,b.fillText(n,p,g),b.fillRect(x,v,_,m),b.fillStyle=s,b.globalAlpha=.9,b.fillRect(x,v,_,m),{dom:M,update:function(S,L){i=Math.min(i,S),a=Math.max(a,S),b.fillStyle=s,b.globalAlpha=1,b.fillRect(0,0,f,v),b.fillStyle=r,b.fillText(c(S)+" "+n+" ("+c(i)+"-"+c(a)+")",p,g),b.drawImage(M,x+h,v,_-h,m,x,v,_-h,m),b.fillRect(x+_-h,v,h,m),b.fillStyle=s,b.globalAlpha=.9,b.fillRect(x+_-h,v,h,c((1-S/L)*m))}}},t})})(Xi);var Jf=Xi.exports;const Hf=un(Jf),$f=u.defineComponent({name:"Stats",props:{showPanel:{type:Number,default:0}},setup(o,{expose:e}){const t=new Hf;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}=ie.useRenderLoop();i(),r(()=>t.begin()),s(()=>t.end()),u.onUnmounted(()=>{n==null||n.removeChild(t.dom)})}});class ed{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 Zi=class qt{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.totalGpuDurationCompute=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.averageGpuCompute={logs:[],graph:[]},this.queryCreated=!1,this.fpsPanel=this.addPanel(new qt.Panel("FPS","#0ff","#002"),0),this.msPanel=this.addPanel(new qt.Panel("CPU","#0f0","#020"),1),this.gpuPanel=null,this.gpuPanelCompute=null,this.samplesLog=t,this.samplesGraph=n,this.precision=r,this.logsPerSecond=e,this.minimal?(this.dom.addEventListener("click",c=>{c.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),this.gpuPanelCompute&&this.resizePanel(this.gpuPanelCompute,3)})}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}async 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()}else!this.gl&&e instanceof WebGL2RenderingContext&&(this.gl=e);if(e.isWebGPURenderer){e.backend.trackTimestamp=!0,await e.hasFeatureAsync("timestamp-query")&&(this.gpuPanel=this.addPanel(new qt.Panel("GPU","#ff0","#220"),2),this.gpuPanelCompute=this.addPanel(new qt.Panel("CPT","#e1e1e1","#212121"),3),this.info=e.info);return}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 qt.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.info===void 0?this.processGpuQueries():(this.totalGpuDuration=this.info.render.timestamp,this.totalGpuDurationCompute=this.info.compute.timestamp,this.addToAverage(this.totalGpuDurationCompute,this.averageGpuCompute)),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.beginProfiling("cpu-started"),this.totalCpuDuration=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.gpuPanelCompute&&this.updatePanel(this.gpuPanelCompute,this.averageGpuCompute),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}};Zi.Panel=ed;let td=Zi;const nd=u.defineComponent({name:"StatsGl",props:["logsPerSecond","samplesLog","samplesGraph","precision","horizontal","minimal","mode"],async setup(o,{expose:e}){const t=new td({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}=ie.useTresContext(),{onAfterLoop:i,resume:a}=ie.useRenderLoop();t.init(s.value),a(),i(()=>{t.update()}),u.onUnmounted(()=>{n==null||n.removeChild(r)})}}),rd=u.defineComponent({name:"BakeShadows",setup(){const{renderer:o}=ie.useTresContext();u.watchEffect(()=>{o.value.shadowMap.autoUpdate=!1,o.value.shadowMap.needsUpdate=!0})}});var sd=`#include <common>
|
|
1391
|
+
#include <${n>=154?"colorspace_fragment":"encodings_fragment"}>
|
|
1392
|
+
}`},h=new l.ShaderMaterial(c),d=new l.Points(void 0,h),f=h.uniforms,p={immediate:!0};[[f.uPixelRatio,te.useTresContext().sizes.aspectRatio],[f.uSize,r.size],[f.uNormalThreshold,r.normalThreshold],[f.uAlpha,r.alpha],[f.uOffset,r.offset],[f.uOffsetNoise,r.offsetNoise],[f.uMixColor,r.mixColor],[f.uMixAlpha,r.mixAlpha],[f.uMixOffset,r.mixOffset],[f.uMixSize,r.mixSize],[f.uMixSurfaceDistance,r.mixSurfaceDistance],[f.uMixNoise,r.mixNoise],[f.uInfoTexture,i]].forEach(([b,S])=>u.watch(S,()=>{b.value=S.value},p)),u.watch([r.noiseScale,r.lifetimeSec],()=>{f.uNoiseScale.value=r.noiseScale.value*r.lifetimeSec.value},p),u.watch([r.lifetimeSec,r.cooldownSec],()=>{f.uCooldownRatio.value=r.cooldownSec.value/r.lifetimeSec.value},p),u.watch(r.map,()=>{typeof r.map.value=="string"?te.useTexture([r.map.value]).then(b=>h.uniforms.uMap.value=b):h.uniforms.uMap.value=r.map.value});const _=new l.Quaternion,v=new l.Vector3;te.useLoop().onBeforeRender(({elapsed:b})=>{d.getWorldQuaternion(_),v.copy(t.directionalLight?t.directionalLight.position:l.Object3D.DEFAULT_UP).normalize(),v.applyQuaternion(_.invert()),h.uniforms.uNormal.value=v,h.uniforms.uTime.value=b/(t.cooldownSec+t.lifetimeSec)});function y(b){return b&&"isObject3D"in b}function g(b){return b&&"isBufferGeometry"in b}u.onMounted(()=>{t.geometry?g(t.geometry)?d.geometry.copy(t.geometry):y(t.geometry)&&"geometry"in t.geometry&&g(t.geometry.geometry)&&d.geometry.copy(t.geometry.geometry):y(d.parent)&&"geometry"in d.parent&&g(d.parent.geometry)?d.geometry.copy(d.parent.geometry):d.geometry=new l.IcosahedronGeometry(1,16),typeof t.map=="string"&&te.useTexture([t.map]).then(b=>h.uniforms.uMap.value=b)}),u.onUnmounted(()=>{var b;(b=h.uniforms.uMap.value)==null||b.dispose(),i.value.dispose(),h.dispose()});const M=u.shallowRef();return e({instance:M}),(b,S)=>(u.openBlock(),u.createElementBlock("primitive",{ref_key:"sparkleRef",ref:M,object:u.unref(d)},null,8,Ad))}}),Pd=["position","a-scale"],Td=["size","size-attenuation","transparent","alpha-test","alpha-map"],Id=u.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=u.ref(),r=u.ref(),{radius:s,depth:i,count:a,size:c,sizeAttenuation:h,transparent:d,alphaMap:f,alphaTest:p}=u.toRefs(t);Ie(t);const m=()=>{let v=s.value+i.value;const y=u.computed(()=>i.value/a.value),g=[],M=Array.from({length:a.value},()=>(.5+.5*Math.random())*4),b=S=>new l.Vector3().setFromSpherical(new l.Spherical(S,Math.acos(1-Math.random()*2),Math.random()*2*Math.PI)).toArray();for(let S=0;S<a.value;S++)v-=y.value*Math.random(),g.push(...b(v));n.value=new Float32Array(g),r.value=new Float32Array(M)};u.watchEffect(()=>{m()});const _=u.shallowRef();return e({instance:_}),(v,y)=>(u.openBlock(),u.createElementBlock("TresPoints",{ref_key:"starsRef",ref:_},[u.createElementVNode("TresBufferGeometry",{position:[n.value,3],"a-scale":[r.value,1]},null,8,Pd),u.createElementVNode("TresPointsMaterial",{size:u.unref(c),"size-attenuation":u.unref(h),transparent:u.unref(d),"alpha-test":u.unref(p),"alpha-map":u.unref(f)},null,8,Td)],512))}}),Od=["rotation-x","args"],Dd=u.createElementVNode("TresPlaneGeometry",{args:[1e4,1e4]},null,-1),Ld=u.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 l.Vector3},sunColor:{default:16777215},waterColor:{default:7695},distortionScale:{default:3.7},size:{default:1},clipBias:{default:0},alpha:{default:1},side:{default:l.FrontSide}},async setup(o,{expose:e}){let t,n;const r=o,{textureWidth:s,textureHeight:i,waterNormals:a,sunDirection:c,sunColor:h,waterColor:d,distortionScale:f,size:p,clipBias:m,alpha:_,side:v}=u.toRefs(r),{invalidateOnDemand:y}=Ie(r),{extend:g,scene:M}=te.useTresContext();g({Water:qo});const b=u.shallowRef(),S=u.shallowRef(),O=M.value.fog!==void 0;e({instance:b}),M.value.traverse(w=>{Object.prototype.hasOwnProperty.call(w,"isSky")&&(S.value=w)}),u.onMounted(async()=>{if(await u.nextTick(),S.value){const w=S.value.material.uniforms.sunPosition.value;b.value.material.uniforms.sunDirection.value.copy(w)}});const{normalMap:T}=([t,n]=u.withAsyncContext(()=>te.useTexture({normalMap:a.value})),t=await t,n(),t);T.wrapS=T.wrapT=l.RepeatWrapping;const{onBeforeRender:C}=te.useLoop();return C(({delta:w})=>{b.value.material.uniforms.time.value+=w,y()}),(w,A)=>(u.openBlock(),u.createElementBlock("TresWater",{ref_key:"waterRef",ref:b,"rotation-x":-Math.PI/2,args:[void 0,{textureWidth:u.unref(s),textureHeight:u.unref(i),waterNormals:u.unref(T),sunDirection:u.unref(c),sunColor:u.unref(h),waterColor:u.unref(d),distortionScale:u.unref(f),fog:O,size:u.unref(p),clipBias:u.unref(m),alpha:u.unref(_),side:u.unref(v)}]},[u.renderSlot(w.$slots,"default",{},()=>[Dd])],8,Od))}});var to={exports:{}};(function(o,e){(function(t,n){o.exports=n()})(Su,function(){var t=function(){function n(m){return i.appendChild(m.dom),m}function r(m){for(var _=0;_<i.children.length;_++)i.children[_].style.display=_===m?"block":"none";s=m}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(m){m.preventDefault(),r(++s%i.children.length)},!1);var a=(performance||Date).now(),c=a,h=0,d=n(new t.Panel("FPS","#0ff","#002")),f=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var p=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(){h++;var m=(performance||Date).now();if(f.update(m-a,200),m>c+1e3&&(d.update(1e3*h/(m-c),100),c=m,h=0,p)){var _=performance.memory;p.update(_.usedJSHeapSize/1048576,_.jsHeapSizeLimit/1048576)}return m},update:function(){a=this.end()},domElement:i,setMode:r}};return t.Panel=function(n,r,s){var i=1/0,a=0,c=Math.round,h=c(window.devicePixelRatio||1),d=80*h,f=48*h,p=3*h,m=2*h,_=3*h,v=15*h,y=74*h,g=30*h,M=document.createElement("canvas");M.width=d,M.height=f,M.style.cssText="width:80px;height:48px";var b=M.getContext("2d");return b.font="bold "+9*h+"px Helvetica,Arial,sans-serif",b.textBaseline="top",b.fillStyle=s,b.fillRect(0,0,d,f),b.fillStyle=r,b.fillText(n,p,m),b.fillRect(_,v,y,g),b.fillStyle=s,b.globalAlpha=.9,b.fillRect(_,v,y,g),{dom:M,update:function(S,O){i=Math.min(i,S),a=Math.max(a,S),b.fillStyle=s,b.globalAlpha=1,b.fillRect(0,0,d,v),b.fillStyle=r,b.fillText(c(S)+" "+n+" ("+c(i)+"-"+c(a)+")",p,m),b.drawImage(M,_+h,v,y-h,g,_,v,y-h,g),b.fillRect(_+y-h,v,h,g),b.fillStyle=s,b.globalAlpha=.9,b.fillRect(_+y-h,v,h,c((1-S/O)*g))}}},t})})(to);var kd=to.exports;const Bd=hn(kd),Fd=u.defineComponent({name:"Stats",props:{showPanel:{type:Number,default:0}},setup(o,{expose:e}){const t=new Bd;e({instance:t});const n=document.body;t.showPanel(o.showPanel||0),n==null||n.appendChild(t.dom);const{onBeforeRender:r,onAfterRender:s}=te.useLoop();r(()=>t.begin(),Number.NEGATIVE_INFINITY),s(()=>t.end(),Number.POSITIVE_INFINITY),u.onUnmounted(()=>{n==null||n.removeChild(t.dom)})}});class Ud{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 no=class qt{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.totalGpuDurationCompute=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.averageGpuCompute={logs:[],graph:[]},this.queryCreated=!1,this.fpsPanel=this.addPanel(new qt.Panel("FPS","#0ff","#002"),0),this.msPanel=this.addPanel(new qt.Panel("CPU","#0f0","#020"),1),this.gpuPanel=null,this.gpuPanelCompute=null,this.samplesLog=t,this.samplesGraph=n,this.precision=r,this.logsPerSecond=e,this.minimal?(this.dom.addEventListener("click",c=>{c.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),this.gpuPanelCompute&&this.resizePanel(this.gpuPanelCompute,3)})}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}async 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()}else!this.gl&&e instanceof WebGL2RenderingContext&&(this.gl=e);if(e.isWebGPURenderer){e.backend.trackTimestamp=!0,await e.hasFeatureAsync("timestamp-query")&&(this.gpuPanel=this.addPanel(new qt.Panel("GPU","#ff0","#220"),2),this.gpuPanelCompute=this.addPanel(new qt.Panel("CPT","#e1e1e1","#212121"),3),this.info=e.info);return}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 qt.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.info===void 0?this.processGpuQueries():(this.totalGpuDuration=this.info.render.timestamp,this.totalGpuDurationCompute=this.info.compute.timestamp,this.addToAverage(this.totalGpuDurationCompute,this.averageGpuCompute)),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.beginProfiling("cpu-started"),this.totalCpuDuration=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.gpuPanelCompute&&this.updatePanel(this.gpuPanelCompute,this.averageGpuCompute),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}};no.Panel=Ud;let Nd=no;const zd=u.defineComponent({name:"StatsGl",props:["logsPerSecond","samplesLog","samplesGraph","precision","horizontal","minimal","mode"],setup(o,{expose:e}){const t=new Nd({logsPerSecond:o.logsPerSecond,samplesLog:o.samplesLog,samplesGraph:o.samplesGraph,precision:o.precision,horizontal:o.horizontal,minimal:o.minimal,mode:o.mode});e({instance:t});const n=document.body,r=t.dom||t.container;n==null||n.appendChild(r);const{renderer:s}=te.useTresContext(),{onAfterRender:i}=te.useLoop();t.init(s.value),i(()=>t.update(),Number.POSITIVE_INFINITY),u.onUnmounted(()=>{n==null||n.removeChild(r)})}}),Vd=u.defineComponent({name:"BakeShadows",setup(){const{renderer:o}=te.useTresContext();u.watchEffect(()=>{o.value.shadowMap.autoUpdate=!1,o.value.shadowMap.needsUpdate=!0})}});var Rd=`#include <common>
|
|
1378
1393
|
|
|
1379
1394
|
void main() {
|
|
1380
1395
|
vec2 center = vec2(0., 1.);
|
|
@@ -1399,6 +1414,6 @@ void main() {
|
|
|
1399
1414
|
mvPosition.xy += rotatedPosition;
|
|
1400
1415
|
|
|
1401
1416
|
gl_Position = projectionMatrix * mvPosition;
|
|
1402
|
-
}`,
|
|
1417
|
+
}`,Gd=`void main() {
|
|
1403
1418
|
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
|
|
1404
|
-
}`;const dn=new l.Vector3(0,0,0),Er=new l.Vector3(0,0,0),od=new l.Vector3(0,0,0);function qi(o,e,t){const n=dn.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 ad(o,e){const t=dn.setFromMatrixPosition(o.matrixWorld),n=Er.setFromMatrixPosition(e.matrixWorld),r=t.sub(n),s=e.getWorldDirection(od);return r.angleTo(s)>Math.PI/2}function ld(o,e,t,n){const r=dn.setFromMatrixPosition(o.matrixWorld),s=r.clone();s.project(e),t.setFromCamera(new l.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 cd(o,e){if(e instanceof l.OrthographicCamera)return e.zoom;if(e instanceof l.PerspectiveCamera){const t=dn.setFromMatrixPosition(o.matrixWorld),n=Er.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 ud(o,e,t){if(e instanceof l.PerspectiveCamera||e instanceof l.OrthographicCamera){const n=dn.setFromMatrixPosition(o.matrixWorld),r=Er.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 Xr=o=>Math.abs(o)<1e-10?0:o;function Ki(o,e,t=""){let n="matrix3d(";for(let r=0;r!==16;r++)n+=Xr(e[r]*o.elements[r])+(r!==15?",":")");return t+n}const hd=(o=>e=>Ki(e,o))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),fd=(o=>(e,t)=>Ki(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]),dd=["geometry","material"],pd=u.defineComponent({__name:"HTML",props:{geometry:{default:new l.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=u.useSlots(),s=u.useAttrs(),i=u.ref(),a=u.ref(),{geometry:c,material:h,as:f,transform:d,portal:p,wrapperClass:g,eps:x,distanceFactor:v,fullscreen:_,center:m,pointerEvents:M,sprite:b,occlude:S,zIndexRange:L}=u.toRefs(t),{renderer:P,scene:T,camera:y,raycaster:A,sizes:w}=ie.useTresContext(),D=u.computed(()=>document.createElement(f.value)),k=u.ref([0,0]),R=u.ref(0),V=u.ref(),Y=u.computed(()=>d.value?{position:"absolute",top:0,left:0,width:`${w.width.value}px`,height:`${w.height.value}px`,transformStyle:"preserve-3d",pointerEvents:"none",zIndex:2,willChange:"transform"}:{position:"absolute",transform:m.value?"translate3d(-50%,-50%,0)":"none",..._.value&&{top:-w.height.value/2,left:-w.width.value/2,width:`${w.width.value}px`,height:`${w.height.value}px`},zIndex:2,...s.style,willChange:"transform"}),G=u.computed(()=>({position:"absolute",pointerEvents:M.value})),Q=u.ref(null),K=u.ref(!1),ne=u.computed(()=>(S==null?void 0:S.value)&&(S==null?void 0:S.value)!=="blending"||Array.isArray(S==null?void 0:S.value)&&(S==null?void 0:S.value.length)&&u.isRef(S.value[0]));u.watch(()=>S,O=>{O&&O==="blending"?(D.value.style.zIndex=`${Math.floor(L.value[0]/2)}`,D.value.style.position="absolute",D.value.style.pointerEvents="none"):(D.value.style.zIndex=null,D.value.style.position=null,D.value.style.pointerEvents=null)}),u.watch(()=>{var O;return[i.value,P.value,w.width.value,w.height.value,(O=r.default)==null?void 0:O.call(r)]},([O,z])=>{var U,F,j,C,I,B;if(O&&z){const Z=(p==null?void 0:p.value)||z.domElement;if((U=T.value)==null||U.updateMatrixWorld(),d.value)D.value.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const X=qi(O,y.value,{width:w.width.value,height:w.height.value});D.value.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${X[0]}px,${X[1]}px,0);transform-origin:0 0;`}Z&&!D.value.parentNode&&((F=Z.parentNode)==null||F.appendChild(D.value)),d.value?V.value=u.createVNode("div",{id:"outer",style:Y.value},[u.createVNode("div",{id:"inner",style:G.value},[u.createVNode("div",{key:(j=a.value)==null?void 0:j.uuid,id:T==null?void 0:T.value.uuid,class:s.class,style:s.style},(C=r.default)==null?void 0:C.call(r))])]):V.value=u.createVNode("div",{key:(I=a.value)==null?void 0:I.uuid,id:T==null?void 0:T.value.uuid,style:Y.value},(B=r.default)==null?void 0:B.call(r)),u.render(V.value,D.value)}}),u.watchEffect(()=>{g!=null&&g.value&&(D.value.className=g.value)});const ee=u.ref(!0),{onLoop:le}=ie.useRenderLoop();le(()=>{var O,z,U,F,j,C,I;if(i.value&&y.value&&P.value){(O=y.value)==null||O.updateMatrixWorld(),i.value.updateWorldMatrix(!0,!1);const B=d.value?k.value:qi(i.value,y.value,{width:w.width.value||0,height:w.height.value||0});if(d.value||Math.abs(R.value-y.value.zoom)>x.value||Math.abs(k.value[0]-B[0])>x.value||Math.abs(k.value[1]-B[1])>x.value){const Z=ad(i.value,y.value);let X=!1;ne.value&&(Array.isArray(S==null?void 0:S.value)?X=S==null?void 0:S.value:(S==null?void 0:S.value)!=="blending"&&(X=[T.value]));const W=ee.value;if(X){const se=ld(i.value,y.value,A.value,X);ee.value=se&&!Z}else ee.value=!Z;W!==ee.value&&(n("onOcclude",!ee.value),D.value.style.display=ee.value?"block":"none");const $=Math.floor(L.value[0]/2),re=S!=null&&S.value?ne.value?[L.value[0],$]:[$-1,0]:L.value;if(D.value.style.zIndex=`${ud(i.value,y.value,re)}`,D.value.style.willChange="transform",d.value){const[se,E]=[w.width.value/2,w.height.value/2],N=y.value.projectionMatrix.elements[5]*E,{isOrthographicCamera:ae,top:ue,left:ve,bottom:Oe,right:Te}=y.value,He=hd(y.value.matrixWorldInverse),Ct=ae?`scale(${N})translate(${Xr(-(Te+ve)/2)}px,${Xr((ue+Oe)/2)}px)`:`translateZ(${N}px)`;let Ze=i.value.matrixWorld;b.value&&(Ze=y.value.matrixWorldInverse.clone().transpose().copyPosition(Ze).scale(i.value.scale),Ze.elements[3]=Ze.elements[7]=Ze.elements[11]=0,Ze.elements[15]=1),D.value.style.width=`${w.width.value}px`,D.value.style.height=`${w.height.value}px`,D.value.style.perspective=ae?"":`${N}px`,(z=V.value)!=null&&z.el&&((U=V.value)!=null&&U.children)&&(V.value.el.style.willChange="transform",V.value.el.style.transform=`${Ct}${He}translate(${se}px,${E}px)`,V.value.children[0].willChange="transform",V.value.children[0].el.style.transform=fd(Ze,1/(((v==null?void 0:v.value)||10)/400)))}else{const se=(v==null?void 0:v.value)===void 0?1:cd(i.value,y.value)*(v==null?void 0:v.value);D.value.style.transform=`translate3d(${B[0]}px,${B[1]}px,0) scale(${se})`}}k.value=B,R.value=y.value.zoom}if(!ne.value&&a.value&&!K.value)if(d.value){if((F=V.value)!=null&&F.el&&((j=V.value)!=null&&j.children)){const B=(C=V.value)==null?void 0:C.children[0];if(B!=null&&B.clientWidth&&(B!=null&&B.clientHeight)){const{isOrthographicCamera:Z}=y.value;if(Z||c)s.scale&&(Array.isArray(s.scale)?s.scale instanceof l.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 X=((v==null?void 0:v.value)||10)/400,W=B.clientWidth*X,$=B.clientHeight*X;a.value.scale.set(W,$,1)}K.value=!0}}}else{const B=D.value.children[0];if(B!=null&&B.clientWidth&&(B!=null&&B.clientHeight)){const X=B.clientWidth*1,W=B.clientHeight*1;a.value.scale.set(X,W,1),K.value=!0}Q.value.lookAt((I=y.value)==null?void 0:I.position)}});const he=u.computed(()=>({vertexShader:d.value?void 0:sd,fragmentShader:id})),de=u.computed(()=>{const O=he.value;return h.value||new l.ShaderMaterial({vertexShader:O.vertexShader,fragmentShader:O.fragmentShader,side:l.DoubleSide})});return u.onUnmounted(()=>{de.value&&de.value.dispose(),D.value.remove()}),(O,z)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"groupRef",ref:i},[u.unref(S)&&!ne.value?(u.openBlock(),u.createElementBlock("TresMesh",{key:0,ref_key:"meshRef",ref:a,geometry:u.unref(c),material:de.value},null,8,dd)):u.createCommentVNode("",!0)],512))}}),{logError:md}=ie.useLogger();async function gd(o,e){const t=new qn,n=(e==null?void 0:e.fileName)||"scene";t.parse(o,r=>{if(r instanceof ArrayBuffer)vd(r,`${n}.glb`);else{const s=JSON.stringify(r,null,2);yd(s,`${n}.gltf`)}},r=>{md("An error happened while exporting the GLTF",r)},e)}function yd(o,e){Qi(new Blob([o],{type:"text/plain"}),e)}function vd(o,e){Qi(new Blob([o],{type:"application/octet-stream"}),e)}function Qi(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 _d={mounted:(o,e)=>{if(e.arg){console.log(`v-log:${e.arg}`,o[e.arg]);return}console.log("v-log",o)}},{logWarning:Ji}=ie.useLogger();let jn,Xt;const xd={DirectionalLight:l.DirectionalLightHelper,PointLight:l.PointLightHelper,SpotLight:l.SpotLightHelper,HemisphereLight:l.HemisphereLightHelper,RectAreaLight:ks},wd={mounted:o=>{var e;if(!o.isLight){Ji(`${o.type} is not a light`);return}jn=xd[o.type],(e=o==null?void 0:o.parent)==null||e.add(new jn(o,o.intensity))},updated:o=>{Xt=o.parent.children.find(e=>e instanceof jn),!(Xt instanceof ks)&&Xt.update()},unmounted:o=>{if(!o.isLight){Ji(`${o.type} is not a light`);return}Xt=o.parent.children.find(e=>e instanceof jn),Xt.dispose(),o.parent.remove(Xt)}};function bd(o,e){const t={};for(const n of e)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n]);return t}function Md(o,e){const t=`set${e[0].toUpperCase()}${e.slice(1)}`;return o[t]!==void 0}function Zr(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 l.Vector3(...e)),e}const{logWarning:Sd}=ie.useLogger(),Ad={updated:(o,e)=>{const t=Zr(e);if(!t){Sd(`v-always-look-at: problem with binding value: ${e.value}`);return}const{onLoop:n}=ie.useRenderLoop();n(()=>{o.lookAt(t)})}},{logWarning:Cd}=ie.useLogger();let ht=null;const Pd={updated:(o,e)=>{var r;const t=Zr(e);if(!t){Cd(`v-distance-to: problem with binding value: ${e.value}`);return}ht&&(ht.dispose(),o.parent.remove(ht));const n=t.clone().sub(o.position);n.normalize(),ht=new l.ArrowHelper(n,o.position,o.position.distanceTo(t)/1.5,16776960),o.parent.add(ht),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=>{ht==null||ht.dispose(),o.parent.remove(ht)}};te.Backdrop=cf,te.BakeShadows=rd,te.BaseCameraControls=Ue,te.Box=th,te.CameraControls=Dc,te.CatmullRomCurve3=ah,te.Circle=uh,te.Cone=dh,te.ContactShadows=mf,te.CustomShaderMaterial=Yu,te.Dodecahedron=gh,te.Environment=$h,te.FBXModel=uc,te.Fbo=ec,te.Fit=gf,te.GLTFModel=lc,te.GlobalAudio=Ul,te.HolographicMaterial=Hu,te.Html=pd,te.Icosahedron=_h,te.KeyboardControls=xc,te.Lensflare=$l,te.Levioso=fl,te.Lightformer=sf,te.Line2=Wi,te.MapControls=Cc,te.MeshGlassMaterial=Rc,te.MeshReflectionMaterial=Qu,te.MeshWobbleMaterial=Fc,te.MouseParallax=Fl,te.Ocean=Kf,te.Octahedron=bh,te.OrbitControls=gc,te.Plane=Ch,te.PointerLockControls=Sc,te.PositionalAudio=sc,te.Precipitation=_f,te.Reflector=ml,te.Ring=Ih,te.RoundedBox=Dh,te.SVG=fc,te.Sampler=tc,te.ScrollControls=Pc,te.Sky=wf,te.Smoke=Cf,te.Sparkles=Rf,te.Sphere=Fh,te.Stars=Ef,te.Stats=$f,te.StatsGl=nd,te.Superformula=Vh,te.Tetrahedron=Rh,te.Text3D=ul,te.Torus=Eh,te.TorusKnot=qh,te.TransformControls=bc,te.Tube=Jh,te.extractBindingPosition=Zr,te.hasSetter=Md,te.pick=bd,te.useAnimations=hl,te.useEnvironment=Qs,te.useFBO=qs,te.useFBX=Hs,te.useGLTF=Js,te.useGLTFExporter=gd,te.useProgress=dc,te.useSurfaceSampler=Ks,te.useTweakPane=Qf,te.useVideoTexture=pc,te.vAlwaysLookAt=Ad,te.vDistanceTo=Pd,te.vLightHelper=wd,te.vLog=_d,Object.defineProperty(te,Symbol.toStringTag,{value:"Module"})});
|
|
1419
|
+
}`;const pn=new l.Vector3(0,0,0),qr=new l.Vector3(0,0,0),jd=new l.Vector3(0,0,0);function ro(o,e,t){const n=pn.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 Ed(o,e){const t=pn.setFromMatrixPosition(o.matrixWorld),n=qr.setFromMatrixPosition(e.matrixWorld),r=t.sub(n),s=e.getWorldDirection(jd);return r.angleTo(s)>Math.PI/2}function Yd(o,e,t,n){const r=pn.setFromMatrixPosition(o.matrixWorld),s=r.clone();s.project(e),t.setFromCamera(new l.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 Wd(o,e){if(e instanceof l.OrthographicCamera)return e.zoom;if(e instanceof l.PerspectiveCamera){const t=pn.setFromMatrixPosition(o.matrixWorld),n=qr.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 Xd(o,e,t){if(e instanceof l.PerspectiveCamera||e instanceof l.OrthographicCamera){const n=pn.setFromMatrixPosition(o.matrixWorld),r=qr.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 Qr=o=>Math.abs(o)<1e-10?0:o;function so(o,e,t=""){let n="matrix3d(";for(let r=0;r!==16;r++)n+=Qr(e[r]*o.elements[r])+(r!==15?",":")");return t+n}const Zd=(o=>e=>so(e,o))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),Kd=(o=>(e,t)=>so(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]),qd=["geometry","material"],Qd=u.defineComponent({__name:"HTML",props:{geometry:{default:new l.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,{expose:e,emit:t}){const n=o,r=t,s=u.useSlots(),i=u.useAttrs(),a=u.ref(),c=u.ref(),{geometry:h,material:d,as:f,transform:p,portal:m,wrapperClass:_,eps:v,distanceFactor:y,fullscreen:g,center:M,pointerEvents:b,sprite:S,occlude:O,zIndexRange:T}=u.toRefs(n),{renderer:C,scene:w,camera:A,raycaster:x,sizes:D}=te.useTresContext(),L=u.computed(()=>document.createElement(f.value)),V=u.ref([0,0]),R=u.ref(0),X=u.ref(),Y=u.computed(()=>p.value?{position:"absolute",top:0,left:0,width:`${D.width.value}px`,height:`${D.height.value}px`,transformStyle:"preserve-3d",pointerEvents:"none",zIndex:2,willChange:"transform"}:{position:"absolute",transform:M.value?"translate3d(-50%,-50%,0)":"none",...g.value&&{top:-D.height.value/2,left:-D.width.value/2,width:`${D.width.value}px`,height:`${D.height.value}px`},zIndex:2,...i.style,willChange:"transform"}),J=u.computed(()=>({position:"absolute",pointerEvents:b.value})),q=u.ref(null),re=u.ref(!1),ee=u.computed(()=>(O==null?void 0:O.value)&&(O==null?void 0:O.value)!=="blending"||Array.isArray(O==null?void 0:O.value)&&(O==null?void 0:O.value.length)&&u.isRef(O.value[0]));u.watch(()=>O,z=>{z&&z==="blending"?(L.value.style.zIndex=`${Math.floor(T.value[0]/2)}`,L.value.style.position="absolute",L.value.style.pointerEvents="none"):(L.value.style.zIndex=null,L.value.style.position=null,L.value.style.pointerEvents=null)}),u.watch(()=>{var z;return[a.value,C.value,D.width.value,D.height.value,(z=s.default)==null?void 0:z.call(s)]},([z,F])=>{var B,G,P,I,U,E;if(z&&F){const Z=(m==null?void 0:m.value)||F.domElement;if((B=w.value)==null||B.updateMatrixWorld(),p.value)L.value.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const j=ro(z,A.value,{width:D.width.value,height:D.height.value});L.value.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${j[0]}px,${j[1]}px,0);transform-origin:0 0;`}Z&&!L.value.parentNode&&((G=Z.parentNode)==null||G.appendChild(L.value)),p.value?X.value=u.createVNode("div",{id:"outer",style:Y.value},[u.createVNode("div",{id:"inner",style:J.value},[u.createVNode("div",{key:(P=c.value)==null?void 0:P.uuid,id:w==null?void 0:w.value.uuid,class:i.class,style:i.style},(I=s.default)==null?void 0:I.call(s))])]):X.value=u.createVNode("div",{key:(U=c.value)==null?void 0:U.uuid,id:w==null?void 0:w.value.uuid,style:Y.value},(E=s.default)==null?void 0:E.call(s)),u.render(X.value,L.value)}}),u.watchEffect(()=>{_!=null&&_.value&&(L.value.className=_.value)});const ce=u.ref(!0),{onBeforeRender:le}=te.useLoop();le(()=>{var z,F,B,G,P,I,U;if(a.value&&A.value&&C.value){(z=A.value)==null||z.updateMatrixWorld(),a.value.updateWorldMatrix(!0,!1);const E=p.value?V.value:ro(a.value,A.value,{width:D.width.value||0,height:D.height.value||0});if(p.value||Math.abs(R.value-A.value.zoom)>v.value||Math.abs(V.value[0]-E[0])>v.value||Math.abs(V.value[1]-E[1])>v.value){const Z=Ed(a.value,A.value);let j=!1;ee.value&&(Array.isArray(O==null?void 0:O.value)?j=O==null?void 0:O.value:(O==null?void 0:O.value)!=="blending"&&(j=[w.value]));const $=ce.value;if(j){const W=Yd(a.value,A.value,x.value,j);ce.value=W&&!Z}else ce.value=!Z;$!==ce.value&&(r("onOcclude",!ce.value),L.value.style.display=ce.value?"block":"none");const ne=Math.floor(T.value[0]/2),ie=O!=null&&O.value?ee.value?[T.value[0],ne]:[ne-1,0]:T.value;if(L.value.style.zIndex=`${Xd(a.value,A.value,ie)}`,L.value.style.willChange="transform",p.value){const[W,N]=[D.width.value/2,D.height.value/2],ae=A.value.projectionMatrix.elements[5]*N,{isOrthographicCamera:he,top:_e,left:Oe,bottom:De,right:$e}=A.value,dt=Zd(A.value.matrixWorldInverse),Tt=he?`scale(${ae})translate(${Qr(-($e+Oe)/2)}px,${Qr((_e+De)/2)}px)`:`translateZ(${ae}px)`;let Ze=a.value.matrixWorld;S.value&&(Ze=A.value.matrixWorldInverse.clone().transpose().copyPosition(Ze).scale(a.value.scale),Ze.elements[3]=Ze.elements[7]=Ze.elements[11]=0,Ze.elements[15]=1),L.value.style.width=`${D.width.value}px`,L.value.style.height=`${D.height.value}px`,L.value.style.perspective=he?"":`${ae}px`,(F=X.value)!=null&&F.el&&((B=X.value)!=null&&B.children)&&(X.value.el.style.willChange="transform",X.value.el.style.transform=`${Tt}${dt}translate(${W}px,${N}px)`,X.value.children[0].willChange="transform",X.value.children[0].el.style.transform=Kd(Ze,1/(((y==null?void 0:y.value)||10)/400)))}else{const W=(y==null?void 0:y.value)===void 0?1:Wd(a.value,A.value)*(y==null?void 0:y.value);L.value.style.transform=`translate3d(${E[0]}px,${E[1]}px,0) scale(${W})`}}V.value=E,R.value=A.value.zoom}if(!ee.value&&c.value&&!re.value)if(p.value){if((G=X.value)!=null&&G.el&&((P=X.value)!=null&&P.children)){const E=(I=X.value)==null?void 0:I.children[0];if(E!=null&&E.clientWidth&&(E!=null&&E.clientHeight)){const{isOrthographicCamera:Z}=A.value;if(Z||h)i.scale&&(Array.isArray(i.scale)?i.scale instanceof l.Vector3?c.value.scale.copy(i.scale.clone().divideScalar(1)):c.value.scale.set(1/i.scale[0],1/i.scale[1],1/i.scale[2]):c.value.scale.setScalar(1/i.scale));else{const j=((y==null?void 0:y.value)||10)/400,$=E.clientWidth*j,ne=E.clientHeight*j;c.value.scale.set($,ne,1)}re.value=!0}}}else{const E=L.value.children[0];if(E!=null&&E.clientWidth&&(E!=null&&E.clientHeight)){const j=E.clientWidth*1,$=E.clientHeight*1;c.value.scale.set(j,$,1),re.value=!0}q.value.lookAt((U=A.value)==null?void 0:U.position)}});const me=u.computed(()=>({vertexShader:p.value?void 0:Rd,fragmentShader:Gd})),k=u.computed(()=>{const z=me.value;return d.value||new l.ShaderMaterial({vertexShader:z.vertexShader,fragmentShader:z.fragmentShader,side:l.DoubleSide})});return u.onUnmounted(()=>{k.value&&k.value.dispose(),L.value.remove()}),e({instance:a}),(z,F)=>(u.openBlock(),u.createElementBlock("TresGroup",{ref_key:"groupRef",ref:a},[u.unref(O)&&!ee.value?(u.openBlock(),u.createElementBlock("TresMesh",{key:0,ref_key:"meshRef",ref:c,geometry:u.unref(h),material:k.value},null,8,qd)):u.createCommentVNode("",!0)],512))}}),{logError:Jd}=te.useLogger();async function Hd(o,e){const t=new Qn,n=(e==null?void 0:e.fileName)||"scene";t.parse(o,r=>{if(r instanceof ArrayBuffer)ep(r,`${n}.glb`);else{const s=JSON.stringify(r,null,2);$d(s,`${n}.gltf`)}},r=>{Jd("An error happened while exporting the GLTF",r)},e)}function $d(o,e){io(new Blob([o],{type:"text/plain"}),e)}function ep(o,e){io(new Blob([o],{type:"application/octet-stream"}),e)}function io(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()}function tp(o,e){const t={};for(const n of e)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n]);return t}function np(o,e){const t=`set${e[0].toUpperCase()}${e.slice(1)}`;return o[t]!==void 0}function rp(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 l.Vector3(...e)),e}se.AnimatedSprite=Rc,se.Backdrop=Zf,se.BakeShadows=Vd,se.BaseCameraControls=Ne,se.Box=Uh,se.CameraControls=du,se.CatmullRomCurve3=jh,se.Circle=Wh,se.Cone=Kh,se.ContactShadows=$f,se.CustomShaderMaterial=Ah,se.Cylinder=Jh,se.Dodecahedron=ef,se.Environment=zf,se.FBXModel=qc,se.Fbo=yc,se.Fit=ed,se.GLTFModel=Zc,se.GlobalAudio=$l,se.HolographicMaterial=kh,se.Html=Qd,se.Icosahedron=rf,se.KeyboardControls=nu,se.Lensflare=gc,se.Levioso=Tl,se.Lightformer=Ef,se.Line2=Hi,se.MapControls=au,se.MeshGlassMaterial=Mu,se.MeshReflectionMaterial=Dh,se.MeshWobbleMaterial=gu,se.MouseParallax=Hl,se.Ocean=Ld,se.Octahedron=af,se.OrbitControls=tu,se.Plane=hf,se.PointerLockControls=li,se.PositionalAudio=Ec,se.Precipitation=rd,se.Reflector=Dl,se.Ring=pf,se.RoundedBox=yf,se.SVG=Jc,se.Sampler=_c,se.ScrollControls=lu,se.Sky=id,se.Smoke=ud,se.Sparkles=Cd,se.Sphere=xf,se.Stars=Id,se.Stats=Fd,se.StatsGl=zd,se.Superformula=Mf,se.Tetrahedron=Pf,se.Text3D=Cl,se.Torus=Of,se.TorusKnot=kf,se.TransformControls=su,se.Tube=Uf,se.extractBindingPosition=rp,se.hasSetter=np,se.pick=tp,se.useAnimations=Pl,se.useEnvironment=ri,se.useFBO=$s,se.useFBX=ii,se.useGLTF=si,se.useGLTFExporter=Hd,se.useProgress=Hc,se.useSurfaceSampler=ei,se.useVideoTexture=$c,Object.defineProperty(se,Symbol.toStringTag,{value:"Module"})});
|