From d9d72203a06fa7834707e2ca101df8c6f39df0b4 Mon Sep 17 00:00:00 2001 From: gkjohnson Date: Thu, 10 Oct 2024 00:06:28 +0000 Subject: [PATCH] update builds --- example/bundle/assets/B3DMLoader-B0T2UZ_1.js | 1 + example/bundle/assets/CMPTLoader-CXF13c0w.js | 1 + .../CameraTransitionManager-C9mHScp9.js | 1 + .../assets/CesiumIonAuthPlugin-CBH0S8UR.js | 1 + example/bundle/assets/DRACOLoader-CQ2RnL8Q.js | 2 + .../assets/EllipsoidRegionHelper-7avvRq-k.js | 1 + .../assets/EnvironmentControls-CTZuopjd.js | 45 + .../assets/FlyOrbitControls-D1sYBrL1.js | 1 + .../assets/GLTFExtensionLoader-Qt9Ghhze.js | 1 + example/bundle/assets/GLTFLoader-C77rxX9H.js | 1 + .../assets/GoogleCloudAuthPlugin-CXITux-L.js | 1 + .../assets/GoogleTilesRenderer-CVSgZtW5.js | 1 + example/bundle/assets/I3DMLoader-C4TPl3Dp.js | 1 + example/bundle/assets/LoaderBase-CVSPpjX2.js | 1 + .../bundle/assets/OrbitControls-bHRTZZ2i.js | 1 + example/bundle/assets/PNTSLoader-BUgecSBY.js | 1 + .../assets/TileCompressionPlugin-DurGWH0s.js | 1 + .../bundle/assets/TilesFadePlugin-BuMLsouQ.js | 47 + .../bundle/assets/TilesRenderer-DQOLA18N.js | 1 + .../assets/UpdateOnChangePlugin-Bk7zjKKd.js | 1 + example/bundle/assets/b3dmExample-Lr1Y1eRi.js | 20 + example/bundle/assets/cmptExample-wgaV4NtR.js | 1 + .../bundle/assets/customMaterial-CImIqP10.js | 70 + example/bundle/assets/ellipsoid-Bg7ZWI-T.js | 1 + example/bundle/assets/fadingTiles-BXDMvUPL.js | 1 + example/bundle/assets/gltf-DH4GV6NL.js | 1 + .../assets/googleMapsAerial-D8mOXWrx.js | 2 + .../assets/googleMapsExample-Ds1phUl0.js | 2 + example/bundle/assets/i3dmExample-BFcAUGcX.js | 1 + example/bundle/assets/index-C1L6PbuO.js | 3 + example/bundle/assets/ionExample-D7rqEgko.js | 1 + example/bundle/assets/ionLunar-BvwO-oQm.js | 1 + .../assets/landformSiteOverlay-xmaE93tZ.js | 29 + .../assets/lil-gui.module.min-NsHmRZWc.js | 10 + example/bundle/assets/mars-CdP0FE2w.js | 1 + example/bundle/assets/metadata-DAMo4GlH.js | 187 + .../assets/offscreenShadows-D7kVepRj.js | 1 + example/bundle/assets/pntsExample-De5Eup2L.js | 1 + .../bundle/assets/readMagicBytes-Da5ueiou.js | 1 + .../bundle/assets/stats.module--VATS4Kh.js | 1 + .../bundle/assets/three.module-C94OeYjd.js | 3818 +++++++++++++++++ example/bundle/assets/vr-150MxVPa.js | 1 + example/bundle/b3dmExample.html | 46 + example/bundle/cmptExample.html | 39 + example/bundle/customMaterial.html | 43 + example/bundle/ellipsoid.html | 44 + example/bundle/fadingTiles.html | 66 + example/bundle/gltf.html | 36 + example/bundle/googleMapsAerial.html | 83 + example/bundle/googleMapsExample.html | 87 + example/bundle/i3dmExample.html | 36 + example/bundle/index.html | 46 + example/bundle/ionExample.html | 68 + example/bundle/ionLunar.html | 70 + example/bundle/landformSiteOverlay.html | 66 + example/bundle/mars.html | 68 + example/bundle/metadata.html | 96 + example/bundle/offscreenShadows.html | 43 + example/bundle/pntsExample.html | 35 + example/bundle/vr.html | 40 + 60 files changed, 5277 insertions(+) create mode 100644 example/bundle/assets/B3DMLoader-B0T2UZ_1.js create mode 100644 example/bundle/assets/CMPTLoader-CXF13c0w.js create mode 100644 example/bundle/assets/CameraTransitionManager-C9mHScp9.js create mode 100644 example/bundle/assets/CesiumIonAuthPlugin-CBH0S8UR.js create mode 100644 example/bundle/assets/DRACOLoader-CQ2RnL8Q.js create mode 100644 example/bundle/assets/EllipsoidRegionHelper-7avvRq-k.js create mode 100644 example/bundle/assets/EnvironmentControls-CTZuopjd.js create mode 100644 example/bundle/assets/FlyOrbitControls-D1sYBrL1.js create mode 100644 example/bundle/assets/GLTFExtensionLoader-Qt9Ghhze.js create mode 100644 example/bundle/assets/GLTFLoader-C77rxX9H.js create mode 100644 example/bundle/assets/GoogleCloudAuthPlugin-CXITux-L.js create mode 100644 example/bundle/assets/GoogleTilesRenderer-CVSgZtW5.js create mode 100644 example/bundle/assets/I3DMLoader-C4TPl3Dp.js create mode 100644 example/bundle/assets/LoaderBase-CVSPpjX2.js create mode 100644 example/bundle/assets/OrbitControls-bHRTZZ2i.js create mode 100644 example/bundle/assets/PNTSLoader-BUgecSBY.js create mode 100644 example/bundle/assets/TileCompressionPlugin-DurGWH0s.js create mode 100644 example/bundle/assets/TilesFadePlugin-BuMLsouQ.js create mode 100644 example/bundle/assets/TilesRenderer-DQOLA18N.js create mode 100644 example/bundle/assets/UpdateOnChangePlugin-Bk7zjKKd.js create mode 100644 example/bundle/assets/b3dmExample-Lr1Y1eRi.js create mode 100644 example/bundle/assets/cmptExample-wgaV4NtR.js create mode 100644 example/bundle/assets/customMaterial-CImIqP10.js create mode 100644 example/bundle/assets/ellipsoid-Bg7ZWI-T.js create mode 100644 example/bundle/assets/fadingTiles-BXDMvUPL.js create mode 100644 example/bundle/assets/gltf-DH4GV6NL.js create mode 100644 example/bundle/assets/googleMapsAerial-D8mOXWrx.js create mode 100644 example/bundle/assets/googleMapsExample-Ds1phUl0.js create mode 100644 example/bundle/assets/i3dmExample-BFcAUGcX.js create mode 100644 example/bundle/assets/index-C1L6PbuO.js create mode 100644 example/bundle/assets/ionExample-D7rqEgko.js create mode 100644 example/bundle/assets/ionLunar-BvwO-oQm.js create mode 100644 example/bundle/assets/landformSiteOverlay-xmaE93tZ.js create mode 100644 example/bundle/assets/lil-gui.module.min-NsHmRZWc.js create mode 100644 example/bundle/assets/mars-CdP0FE2w.js create mode 100644 example/bundle/assets/metadata-DAMo4GlH.js create mode 100644 example/bundle/assets/offscreenShadows-D7kVepRj.js create mode 100644 example/bundle/assets/pntsExample-De5Eup2L.js create mode 100644 example/bundle/assets/readMagicBytes-Da5ueiou.js create mode 100644 example/bundle/assets/stats.module--VATS4Kh.js create mode 100644 example/bundle/assets/three.module-C94OeYjd.js create mode 100644 example/bundle/assets/vr-150MxVPa.js create mode 100644 example/bundle/b3dmExample.html create mode 100644 example/bundle/cmptExample.html create mode 100644 example/bundle/customMaterial.html create mode 100644 example/bundle/ellipsoid.html create mode 100644 example/bundle/fadingTiles.html create mode 100644 example/bundle/gltf.html create mode 100644 example/bundle/googleMapsAerial.html create mode 100644 example/bundle/googleMapsExample.html create mode 100644 example/bundle/i3dmExample.html create mode 100644 example/bundle/index.html create mode 100644 example/bundle/ionExample.html create mode 100644 example/bundle/ionLunar.html create mode 100644 example/bundle/landformSiteOverlay.html create mode 100644 example/bundle/mars.html create mode 100644 example/bundle/metadata.html create mode 100644 example/bundle/offscreenShadows.html create mode 100644 example/bundle/pntsExample.html create mode 100644 example/bundle/vr.html diff --git a/example/bundle/assets/B3DMLoader-B0T2UZ_1.js b/example/bundle/assets/B3DMLoader-B0T2UZ_1.js new file mode 100644 index 000000000..e60b2b8b0 --- /dev/null +++ b/example/bundle/assets/B3DMLoader-B0T2UZ_1.js @@ -0,0 +1 @@ +import{r as B,F as m,B as y}from"./readMagicBytes-Da5ueiou.js";import{L}from"./LoaderBase-CVSPpjX2.js";import{p as w,aH as x}from"./three.module-C94OeYjd.js";import{G as U}from"./GLTFLoader-C77rxX9H.js";class C extends L{parse(s){const t=new DataView(s),T=B(t);console.assert(T==="b3dm");const b=t.getUint32(4,!0);console.assert(b===1);const h=t.getUint32(8,!0);console.assert(h===s.byteLength);const o=t.getUint32(12,!0),a=t.getUint32(16,!0),n=t.getUint32(20,!0),r=t.getUint32(24,!0),g=28,e=s.slice(g,g+o+a),u=new m(e,0,o,a),c=g+o+a,i=s.slice(c,c+n+r),l=new y(i,u.getData("BATCH_LENGTH"),0,n,r),f=c+n+r,d=new Uint8Array(s,f,h-f);return{version:b,featureTable:u,batchTable:l,glbBytes:d}}}class S extends C{constructor(s=x){super(),this.manager=s,this.adjustmentTransform=new w}parse(s){const t=super.parse(s),T=t.glbBytes.slice().buffer;return new Promise((b,h)=>{const o=this.manager,a=this.fetchOptions,n=o.getHandler("path.gltf")||new U(o);a.credentials==="include"&&a.mode==="cors"&&n.setCrossOrigin("use-credentials"),"credentials"in a&&n.setWithCredentials(a.credentials==="include"),a.headers&&n.setRequestHeader(a.headers);let r=this.workingPath;!/[\\/]$/.test(r)&&r.length&&(r+="/");const g=this.adjustmentTransform;n.parse(T,r,e=>{const{batchTable:u,featureTable:c}=t,{scene:i}=e,l=c.getData("RTC_CENTER");l&&(i.position.x+=l[0],i.position.y+=l[1],i.position.z+=l[2]),e.scene.updateMatrix(),e.scene.matrix.multiply(g),e.scene.matrix.decompose(e.scene.position,e.scene.quaternion,e.scene.scale),e.batchTable=u,e.featureTable=c,i.batchTable=u,i.featureTable=c,b(e)},h)})}}export{S as B}; diff --git a/example/bundle/assets/CMPTLoader-CXF13c0w.js b/example/bundle/assets/CMPTLoader-CXF13c0w.js new file mode 100644 index 000000000..d908b72bf --- /dev/null +++ b/example/bundle/assets/CMPTLoader-CXF13c0w.js @@ -0,0 +1 @@ +import{p as g,aH as w,G as L}from"./three.module-C94OeYjd.js";import{L as P}from"./LoaderBase-CVSPpjX2.js";import{r as m}from"./readMagicBytes-Da5ueiou.js";import{B as T}from"./B3DMLoader-B0T2UZ_1.js";import{P as b}from"./PNTSLoader-BUgecSBY.js";import{I as M}from"./I3DMLoader-C4TPl3Dp.js";class y extends P{parse(s){const o=new DataView(s),h=m(o);console.assert(h==="cmpt",'CMPTLoader: The magic bytes equal "cmpt".');const p=o.getUint32(4,!0);console.assert(p===1,'CMPTLoader: The version listed in the header is "1".');const i=o.getUint32(8,!0);console.assert(i===s.byteLength,"CMPTLoader: The contents buffer length listed in the header matches the file.");const c=o.getUint32(12,!0),n=[];let t=16;for(let r=0;r{const n=new L;return c.forEach(t=>{n.add(t.scene)}),{tiles:c,scene:n}})}}export{D as C}; diff --git a/example/bundle/assets/CameraTransitionManager-C9mHScp9.js b/example/bundle/assets/CameraTransitionManager-C9mHScp9.js new file mode 100644 index 000000000..2c1e234da --- /dev/null +++ b/example/bundle/assets/CameraTransitionManager-C9mHScp9.js @@ -0,0 +1 @@ +import{k as m,E as w,a as u,o as E,O as F,n as c}from"./three.module-C94OeYjd.js";const e=new m,s=new m,v=new m;class W extends w{get animating(){return this._alpha!==0&&this._alpha!==1}get camera(){return this._alpha===0?this.perspectiveCamera:this._alpha===1?this.orthographicCamera:this.transitionCamera}constructor(a=new u,o=new F){super(),this.perspectiveCamera=a,this.orthographicCamera=o,this.transitionCamera=new u,this.orthographicPositionalZoom=!0,this.orthographicOffset=50,this.fixedPoint=new m,this.duration=200,this._target=0,this._alpha=0,this._clock=new E}toggle(){this._target=this._target===1?0:1}update(){const{perspectiveCamera:a,orthographicCamera:o,transitionCamera:t,camera:n}=this,h=this._clock.getDelta()*1e3;if(this._syncCameras(),this._alpha!==this._target){const d=Math.sign(this._target-this._alpha)*h/this.duration;this._alpha=c.clamp(this._alpha+d,0,1),this.dispatchEvent({type:"change"})}const p=n;let r=null;this._alpha===0?r=a:this._alpha===1?r=o:(r=t,this._updateTransitionCamera()),p!==r&&this.dispatchEvent({type:"camera-changed",camera:r,prevCamera:p})}_syncCameras(){const a=this._getFromCamera(),{perspectiveCamera:o,orthographicCamera:t,transitionCamera:n,fixedPoint:i}=this;if(e.set(0,0,-1).transformDirection(a.matrixWorld).normalize(),a.isPerspectiveCamera){if(this.orthographicPositionalZoom)t.position.copy(o.position).addScaledVector(e,-this.orthographicOffset),t.rotation.copy(o.rotation),t.updateMatrixWorld();else{const l=s.subVectors(i,t.position).dot(e),d=s.subVectors(i,o.position).dot(e);s.copy(o.position).addScaledVector(e,d),t.rotation.copy(o.rotation),t.position.copy(s).addScaledVector(e,-l),t.updateMatrixWorld()}const h=Math.abs(s.subVectors(o.position,i).dot(e)),p=2*Math.tan(c.DEG2RAD*o.fov*.5)*h,r=t.top-t.bottom;t.zoom=r/p,t.updateProjectionMatrix()}else{const h=Math.abs(s.subVectors(t.position,i).dot(e)),r=(t.top-t.bottom)/t.zoom*.5/Math.tan(c.DEG2RAD*o.fov*.5);o.rotation.copy(t.rotation),o.position.copy(t.position).addScaledVector(e,h).addScaledVector(e,-r),o.updateMatrixWorld(),this.orthographicPositionalZoom&&(t.position.copy(o.position).addScaledVector(e,-this.orthographicOffset),t.updateMatrixWorld())}n.position.copy(o.position),n.rotation.copy(o.rotation)}_getTransitionDirection(){return Math.sign(this._target-this._alpha)}_getToCamera(){const a=this._getTransitionDirection();return a===0?this._target===0?this.perspectiveCamera:this.orthographicCamera:a>0?this.orthographicCamera:this.perspectiveCamera}_getFromCamera(){const a=this._getTransitionDirection();return a===0?this._target===0?this.perspectiveCamera:this.orthographicCamera:a>0?this.perspectiveCamera:this.orthographicCamera}_updateTransitionCamera(){const{perspectiveCamera:a,orthographicCamera:o,transitionCamera:t,fixedPoint:n}=this,i=this._alpha;e.set(0,0,-1).transformDirection(a.matrixWorld).normalize();const h=Math.abs(s.subVectors(a.position,n).dot(e)),p=2*Math.tan(c.DEG2RAD*a.fov*.5)*h,r=c.lerp(a.fov,1,i),l=p*.5/Math.tan(c.DEG2RAD*r*.5),d=0,P=o.far-o.near;v.copy(o.position).addScaledVector(e,o.near);const g=Math.abs(s.subVectors(a.position,n).dot(e)),C=Math.abs(s.subVectors(v,n).dot(e)),D=g-a.near,M=C-d,y=c.lerp(D,M,i),V=g-a.far,x=C-P,b=c.lerp(V,x,i),f=l-y,_=l-b,T=_-f;t.aspect=a.aspect,t.fov=r,t.near=Math.max(f,T*1e-5),t.far=_,t.position.copy(a.position).addScaledVector(e,g-l),t.rotation.copy(a.rotation),t.updateProjectionMatrix(),t.updateMatrixWorld()}}export{W as C}; diff --git a/example/bundle/assets/CesiumIonAuthPlugin-CBH0S8UR.js b/example/bundle/assets/CesiumIonAuthPlugin-CBH0S8UR.js new file mode 100644 index 000000000..841e3d66c --- /dev/null +++ b/example/bundle/assets/CesiumIonAuthPlugin-CBH0S8UR.js @@ -0,0 +1 @@ +import{G as n}from"./GoogleCloudAuthPlugin-CXITux-L.js";class a{constructor({apiToken:e,assetId:i=null,autoRefreshToken:t=!1}){this.name="CESIUM_ION_AUTH_PLUGIN",this.apiToken=e,this.assetId=i,this.autoRefreshToken=t,this.tiles=null,this.endpointURL=null,this._bearerToken=null,this._tileSetVersion=-1,this._tokenRefreshPromise=null}init(e){this.assetId!==null&&(e.rootURL=`https://api.cesium.com/v1/assets/${this.assetId}/endpoint`),this.tiles=e,this.endpointURL=e.rootURL}loadRootTileSet(){return this._refreshToken().then(()=>this.tiles.loadRootTileSet())}preprocessURL(e){return e=new URL(e),/^http/.test(e.protocol)&&this._tileSetVersion!=-1&&e.searchParams.append("v",this._tileSetVersion),e.toString()}fetchData(e,i){return this.tiles.getPluginByName("GOOGLE_CLOUD_AUTH_PLUGIN")!==null?null:Promise.resolve().then(async()=>{this._tokenRefreshPromise!==null&&(await this._tokenRefreshPromise,e=this.preprocessURL(e));const s=await fetch(e,i);return s.status>=400&&s.status<=499&&this.autoRefreshToken?(await this._refreshToken(i),fetch(this.preprocessURL(e),i)):s})}_refreshToken(e){if(this._tokenRefreshPromise===null){const i=new URL(this.endpointURL);i.searchParams.append("access_token",this.apiToken),this._tokenRefreshPromise=fetch(i,e).then(t=>t.json()).then(t=>{const s=this.tiles;if("externalType"in t){const r=new URL(t.options.url);s.rootURL=t.options.url,s.registerPlugin(new n({apiToken:r.searchParams.get("key")}))}else{if(s.rootURL=t.url,s.fetchOptions.headers=s.fetchOptions.headers||{},s.fetchOptions.headers.Authorization=`Bearer ${t.accessToken}`,i.searchParams.has("v")&&this._tileSetVersion===-1){const r=new URL(t.url);this._tileSetVersion=r.searchParams.get("v")}this._bearerToken=t.accessToken}return this._tokenRefreshPromise=null,t})}return this._tokenRefreshPromise}}export{a as C}; diff --git a/example/bundle/assets/DRACOLoader-CQ2RnL8Q.js b/example/bundle/assets/DRACOLoader-CQ2RnL8Q.js new file mode 100644 index 000000000..a6686eb3d --- /dev/null +++ b/example/bundle/assets/DRACOLoader-CQ2RnL8Q.js @@ -0,0 +1,2 @@ +import{q as C,F as A,a1 as L,a2 as P,ae as D,af as T,C as R}from"./three.module-C94OeYjd.js";const k=new WeakMap;class U extends C{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,o,s,r){const n=new A(this.manager);n.setPath(this.path),n.setResponseType("arraybuffer"),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(e,t=>{this.parse(t,o,r)},s,r)}parse(e,o,s=()=>{}){this.decodeDracoFile(e,o,null,null,L,s).catch(s)}decodeDracoFile(e,o,s,r,n=P,t=()=>{}){const i={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!s,vertexColorSpace:n};return this.decodeGeometry(e,i).then(o).catch(t)}decodeGeometry(e,o){const s=JSON.stringify(o);if(k.has(e)){const a=k.get(e);if(a.key===s)return a.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 n=this.workerNextTaskID++,t=e.byteLength,i=this._getWorker(n,t).then(a=>(r=a,new Promise((h,d)=>{r._callbacks[n]={resolve:h,reject:d},r.postMessage({type:"decode",id:n,taskConfig:o,buffer:e},[e])}))).then(a=>this._createGeometry(a.geometry));return i.catch(()=>!0).then(()=>{r&&n&&this._releaseTask(r,n)}),k.set(e,{key:s,promise:i}),i}_createGeometry(e){const o=new D;e.index&&o.setIndex(new T(e.index.array,1));for(let s=0;s{s.load(e,r,void 0,n)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",o=[];return e?o.push(this._loadLibrary("draco_decoder.js","text")):(o.push(this._loadLibrary("draco_wasm_wrapper.js","text")),o.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(o).then(s=>{const r=s[0];e||(this.decoderConfig.wasmBinary=s[1]);const n=I.toString(),t=["/* draco decoder */",r,"","/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join(` +`);this.workerSourceURL=URL.createObjectURL(new Blob([t]))}),this.decoderPending}_getWorker(e,o){return this._initDecoder().then(()=>{if(this.workerPool.lengthn._taskLoad?-1:1});const s=this.workerPool[this.workerPool.length-1];return s._taskCosts[e]=o,s._taskLoad+=o,s})}_releaseTask(e,o){e._taskLoad-=e._taskCosts[o],delete e._callbacks[o],delete e._taskCosts[o]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e{const u=d.draco,c=new u.Decoder;try{const l=o(u,c,new Int8Array(a),h),f=l.attributes.map(y=>y.array.buffer);l.index&&f.push(l.index.array.buffer),self.postMessage({type:"decode",id:i.id,geometry:l},f)}catch(l){console.error(l),self.postMessage({type:"error",id:i.id,error:l.message})}finally{u.destroy(c)}});break}};function o(t,i,a,h){const d=h.attributeIDs,u=h.attributeTypes;let c,l;const f=i.GetEncodedGeometryType(a);if(f===t.TRIANGULAR_MESH)c=new t.Mesh,l=i.DecodeArrayToMesh(a,a.byteLength,c);else if(f===t.POINT_CLOUD)c=new t.PointCloud,l=i.DecodeArrayToPointCloud(a,a.byteLength,c);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!l.ok()||c.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const y={index:null,attributes:[]};for(const p in d){const m=self[u[p]];let g,b;if(h.useUniqueIDs)b=d[p],g=i.GetAttributeByUniqueId(c,b);else{if(b=i.GetAttributeId(c,t[d[p]]),b===-1)continue;g=i.GetAttribute(c,b)}const w=r(t,i,c,p,m,g);p==="color"&&(w.vertexColorSpace=h.vertexColorSpace),y.attributes.push(w)}return f===t.TRIANGULAR_MESH&&(y.index=s(t,i,c)),t.destroy(c),y}function s(t,i,a){const d=a.num_faces()*3,u=d*4,c=t._malloc(u);i.GetTrianglesUInt32Array(a,u,c);const l=new Uint32Array(t.HEAPF32.buffer,c,d).slice();return t._free(c),{array:l,itemSize:1}}function r(t,i,a,h,d,u){const c=u.num_components(),f=a.num_points()*c,y=f*d.BYTES_PER_ELEMENT,p=n(t,d),m=t._malloc(y);i.GetAttributeDataArrayForAllPoints(a,u,p,y,m);const g=new d(t.HEAPF32.buffer,m,f).slice();return t._free(m),{name:h,array:g,itemSize:c}}function n(t,i){switch(i){case Float32Array:return t.DT_FLOAT32;case Int8Array:return t.DT_INT8;case Int16Array:return t.DT_INT16;case Int32Array:return t.DT_INT32;case Uint8Array:return t.DT_UINT8;case Uint16Array:return t.DT_UINT16;case Uint32Array:return t.DT_UINT32}}}export{U as D}; diff --git a/example/bundle/assets/EllipsoidRegionHelper-7avvRq-k.js b/example/bundle/assets/EllipsoidRegionHelper-7avvRq-k.js new file mode 100644 index 000000000..ad7096c42 --- /dev/null +++ b/example/bundle/assets/EllipsoidRegionHelper-7avvRq-k.js @@ -0,0 +1 @@ +import{k as m,al as S,ae as G,af as b,am as _,an as z,g as N,ao as R,n as y}from"./three.module-C94OeYjd.js";import{a as I}from"./lil-gui.module.min-NsHmRZWc.js";const n=new m,B=["x","y","z"];class F extends S{constructor(t,e=16776960,a=40){const p=new G,h=[];for(let c=0;c<3;c++){const u=B[c],f=B[(c+1)%3];n.set(0,0,0);for(let i=0;i.1&&(l.z>0&&w.multiplyScalar(-1),f.setXYZ(r,...w))}return u}class T extends S{constructor(t=new I,e=16776960){super(),this.ellipsoidRegion=t,this.material.color.set(e),this.update()}update(){const t=L(this.ellipsoidRegion);this.geometry.dispose(),this.geometry=new z(t,80)}dispose(){this.geometry.dispose(),this.material.dispose()}}class V extends N{constructor(t=new I,e=16776960){super(),this.ellipsoidRegion=t,this.material.color.set(e),this.update()}update(){this.geometry.dispose();const t=L(this.ellipsoidRegion),{lonStart:e,lonEnd:a}=this;a-e>=2*Math.PI?(t.groups.splice(2,2),this.geometry=H(t)):this.geometry=t}dispose(){this.geometry.dispose(),this.material.dispose()}}export{V as E,F as S,T as a}; diff --git a/example/bundle/assets/EnvironmentControls-CTZuopjd.js b/example/bundle/assets/EnvironmentControls-CTZuopjd.js new file mode 100644 index 000000000..7e5e0adc5 --- /dev/null +++ b/example/bundle/assets/EnvironmentControls-CTZuopjd.js @@ -0,0 +1,45 @@ +import{g as rt,ay as at,b as ct,V as g,p as st,i as ht,k as f,j as ot,E as lt,R as pt,o as dt,Q as nt,n as ut}from"./three.module-C94OeYjd.js";class mt extends rt{constructor(){super(new at(0,0),new ft),this.renderOrder=1/0}onBeforeRender(t){const e=this.material.uniforms;t.getSize(e.resolution.value)}updateMatrixWorld(){this.matrixWorld.makeTranslation(this.position)}dispose(){this.geometry.dispose(),this.material.dispose()}}class ft extends ct{constructor(){super({depthWrite:!1,depthTest:!1,transparent:!0,uniforms:{resolution:{value:new g},size:{value:15},thickness:{value:2},opacity:{value:1}},vertexShader:` + + uniform float pixelRatio; + uniform float size; + uniform float thickness; + uniform vec2 resolution; + varying vec2 vUv; + + void main() { + + vUv = uv; + + float aspect = resolution.x / resolution.y; + vec2 offset = uv * 2.0 - vec2( 1.0 ); + offset.y *= aspect; + + vec4 screenPoint = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + screenPoint.xy += offset * ( size + thickness ) * screenPoint.w / resolution.x; + + gl_Position = screenPoint; + + } + `,fragmentShader:` + + uniform float size; + uniform float thickness; + uniform float opacity; + + varying vec2 vUv; + void main() { + + float ht = 0.5 * thickness; + float planeDim = size + thickness; + float offset = ( planeDim - ht - 2.0 ) / planeDim; + float texelThickness = ht / planeDim; + + vec2 vec = vUv * 2.0 - vec2( 1.0 ); + float dist = abs( length( vec ) - offset ); + float fw = fwidth( dist ) * 0.5; + float a = smoothstep( texelThickness - fw, texelThickness + fw, dist ); + + gl_FragColor = vec4( 1, 1, 1, opacity * ( 1.0 - a ) ); + + } + `})}}const Q=new g,Y=new g;class Pt{constructor(){this.domElement=null,this.buttons=0,this.pointerType=null,this.pointerOrder=[],this.previousPositions={},this.pointerPositions={},this.startPositions={},this.pointerSetThisFrame={},this.hoverPosition=new g,this.hoverSet=!1}reset(){this.buttons=0,this.pointerType=null,this.pointerOrder=[],this.previousPositions={},this.pointerPositions={},this.startPositions={},this.pointerSetThisFrame={},this.hoverPosition=new g,this.hoverSet=!1}updateFrame(){const{previousPositions:t,pointerPositions:e}=this;for(const i in e)t[i].copy(e[i])}setHoverEvent(t){(t.pointerType==="mouse"||t.type==="wheel")&&(this.getAdjustedPointer(t,this.hoverPosition),this.hoverSet=!0)}getLatestPoint(t){return this.pointerType!==null?(this.getCenterPoint(t),t):this.hoverSet?(t.copy(this.hoverPosition),t):null}getAdjustedPointer(t,e){const s=(this.domElement?this.domElement:t.target).getBoundingClientRect(),r=t.clientX-s.left,c=t.clientY-s.top;e.set(r,c)}addPointer(t){const e=t.pointerId,i=new g;this.getAdjustedPointer(t,i),this.pointerOrder.push(e),this.pointerPositions[e]=i,this.previousPositions[e]=i.clone(),this.startPositions[e]=i.clone(),this.getPointerCount()===1&&(this.pointerType=t.pointerType,this.buttons=t.buttons)}updatePointer(t){const e=t.pointerId;return e in this.pointerPositions?(this.getAdjustedPointer(t,this.pointerPositions[e]),!0):!1}deletePointer(t){const e=t.pointerId,i=this.pointerOrder;i.splice(i.indexOf(e),1),delete this.pointerPositions[e],delete this.previousPositions[e],delete this.startPositions[e],this.getPointerCount.length===0&&(this.buttons=0,this.pointerType=null)}getPointerCount(){return this.pointerOrder.length}getCenterPoint(t,e=this.pointerPositions){const i=this.pointerOrder;if(this.getPointerCount()===1||this.getPointerType()==="mouse"){const s=i[0];return t.copy(e[s]),t}else if(this.getPointerCount()===2){const s=this.pointerOrder[0],r=this.pointerOrder[1],c=e[s],p=e[r];return t.addVectors(c,p).multiplyScalar(.5),t}return null}getPreviousCenterPoint(t){return this.getCenterPoint(t,this.previousPositions)}getStartCenterPoint(t){return this.getCenterPoint(t,this.startPositions)}getMoveDistance(){return this.getCenterPoint(Q),this.getPreviousCenterPoint(Y),Q.sub(Y).length()}getTouchPointerDistance(t=this.pointerPositions){if(this.getPointerCount()<=1||this.getPointerType()==="mouse")return 0;const{pointerOrder:e}=this,i=e[0],s=e[1],r=t[i],c=t[s];return r.distanceTo(c)}getPreviousTouchPointerDistance(){return this.getTouchPointerDistance(this.previousPositions)}getStartTouchPointerDistance(){return this.getTouchPointerDistance(this.startPositions)}getPointerType(){return this.pointerType}isPointerTouch(){return this.getPointerType()==="touch"}getPointerButtons(){return this.buttons}isLeftClicked(){return!!(this.buttons&1)}isRightClicked(){return!!(this.buttons&2)}}const M=new st,$=new ht,N=new f;function L(l,t,e){return e.makeTranslation(-l.x,-l.y,-l.z),M.makeRotationFromQuaternion(t),e.premultiply(M),M.makeTranslation(l.x,l.y,l.z),e.premultiply(M),e}function O(l,t,e,i){i.x=(l-e.offsetLeft)/e.clientWidth*2-1,i.y=-((t-e.offsetTop)/e.clientHeight)*2+1,i.isVector3&&(i.z=0)}function St(l,t,e){return t.intersectRay(l,e)?e:(M.makeScale(...t.radius).invert(),$.copy(l).applyMatrix4(M),N.set(0,0,0),$.closestPointToPoint(N,e).normalize(),M.makeScale(...t.radius),e.applyMatrix4(M))}function _t(l,t,e){const i=l.origin.length(),s=Math.acos(t/i);e.copy(l.origin).multiplyScalar(-1).normalize();const r=N.crossVectors(e,l.direction).normalize();e.multiplyScalar(-1).applyAxisAngle(r,-s).normalize().multiplyScalar(t)}function W(l,t,e){const{origin:i,direction:s}=l.ray;i.set(t.x,t.y,-1).unproject(e),s.set(t.x,t.y,1).unproject(e).sub(i),l.near=0,l.far=s.length(),l.camera=e,s.normalize()}const _=0,E=1,w=2,I=3,F=4,H=.05,Z=.025,D=new st,U=new f,y=new f,j=new f,X=new f,z=new f,x=new nt,J=new ot,S=new f,V=new f,B=new f,vt=new nt,A=new g,u=new g,K=new g,T=new g,q=new g,tt=new g,yt={type:"change"},et={type:"start"},it={type:"end"};class Dt extends lt{get enabled(){return this._enabled}set enabled(t){t!==this.enabled&&(this._enabled=t,this.resetState(),this.pointerTracker.reset(),this.enabled||(this.dragInertia.set(0,0,0),this.rotationInertia.set(0,0)))}constructor(t=null,e=null,i=null,s=null){super(),this.domElement=null,this.camera=null,this.scene=null,this.tilesRenderer=null,this._enabled=!0,this.cameraRadius=5,this.rotationSpeed=1,this.minAltitude=0,this.maxAltitude=.45*Math.PI,this.minDistance=10,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.zoomSpeed=1,this.adjustHeight=!0,this.enableDamping=!1,this.dampingFactor=.15,this.reorientOnDrag=!0,this.scaleZoomOrientationAtEdges=!1,this.state=_,this.pointerTracker=new Pt,this.needsUpdate=!1,this.actionHeightOffset=0,this.pivotPoint=new f,this.zoomDirectionSet=!1,this.zoomPointSet=!1,this.zoomDirection=new f,this.zoomPoint=new f,this.zoomDelta=0,this.rotationInertia=new g,this.dragInertia=new f,this.pivotMesh=new mt,this.pivotMesh.raycast=()=>{},this.pivotMesh.scale.setScalar(.25),this.raycaster=new pt,this.raycaster.firstHitOnly=!0,this.up=new f(0,1,0),this.clock=new dt,this.fallbackPlane=new ot(new f(0,1,0),0),this.useFallbackPlane=!0,this._detachCallback=null,this._upInitialized=!1,this._lastUsedState=_,this._zoomPointWasSet=!1,this._tilesOnChangeCallback=()=>this.zoomPointSet=!1,i&&this.attach(i),e&&this.setCamera(e),t&&this.setScene(t),s&&this.setTilesRenderer(s)}setScene(t){this.scene=t}setCamera(t){this.camera=t,this._upInitialized=!1,this.zoomDirectionSet=!1,this.zoomPointSet=!1,this.needsUpdate=!0,this.resetState()}setTilesRenderer(t){this.tilesRenderer&&this.tilesRenderer.removeEventListener("tile-visibility-change",this._tilesOnChangeCallback),this.tilesRenderer=t,this.tilesRenderer!==null&&(this.tilesRenderer.addEventListener("tile-visibility-change",this._tilesOnChangeCallback),this.scene===null&&this.setScene(this.tilesRenderer.group))}attach(t){if(this.domElement)throw new Error("EnvironmentControls: Controls already attached to element");this.domElement=t,this.pointerTracker.domElement=t,t.style.touchAction="none";let e=!1;const i=o=>{o.preventDefault()},s=o=>{o.key==="Shift"&&(e=!0)},r=o=>{o.key==="Shift"&&(e=!1)},c=o=>{o.preventDefault();const{camera:n,raycaster:m,domElement:C,up:k,pivotMesh:b,pointerTracker:v}=this;if(v.addPointer(o),this.needsUpdate=!0,v.isPointerTouch()){if(b.visible=!1,v.getPointerCount()===0)C.setPointerCapture(o.pointerId);else if(v.getPointerCount()>2){this.resetState();return}}v.getCenterPoint(u),O(u.x,u.y,C,u),W(m,u,n);const G=Math.abs(m.ray.direction.dot(k));if(G{o.preventDefault(),this.zoomDirectionSet=!1,this.zoomPointSet=!1,this.state!==_&&(this.needsUpdate=!0);const{pointerTracker:n}=this;n.setHoverEvent(o),n.updatePointer(o)&&n.isPointerTouch()&&n.getPointerCount()===2&&(p||(p=!0,queueMicrotask(()=>{p=!1,n.getCenterPoint(q);const m=n.getStartTouchPointerDistance(),C=n.getTouchPointerDistance(),k=C-m;if(this.state===_||this.state===F){n.getCenterPoint(q),n.getStartCenterPoint(tt);const b=2*window.devicePixelRatio,v=q.distanceTo(tt);(Math.abs(k)>b||v>b)&&(Math.abs(k)>v?(this.setState(I),this.zoomDirectionSet=!1):this.setState(w))}if(this.state===I){const b=n.getPreviousTouchPointerDistance();this.zoomDelta+=C-b}else this.state===w&&(this.pivotMesh.visible=this.enabled)})))},h=o=>{const{pointerTracker:n}=this;n.deletePointer(o),n.getPointerType()==="touch"&&n.getPointerCount()===0&&t.releasePointerCapture(o.pointerId),this.resetState(),this.needsUpdate=!0},P=o=>{o.preventDefault();const{pointerTracker:n}=this;n.setHoverEvent(o),n.updatePointer(o),this.dispatchEvent(et);let m;switch(o.deltaMode){case 2:m=o.deltaY*100;break;case 1:m=o.deltaY*16;break;case 0:m=o.deltaY;break}const C=Math.sign(m),k=Math.log(Math.abs(m)+1);this.zoomDelta-=3*C*k,this.needsUpdate=!0,this._lastUsedState=I,this.dispatchEvent(it)},a=o=>{const{pointerTracker:n}=this;e=!1,o.buttons!==n.getPointerButtons()&&(n.deletePointer(o),this.resetState())};t.addEventListener("contextmenu",i),t.addEventListener("keydown",s),t.addEventListener("keyup",r),t.addEventListener("pointerdown",c),t.addEventListener("pointermove",d),t.addEventListener("pointerup",h),t.addEventListener("wheel",P),t.addEventListener("pointerenter",a),this._detachCallback=()=>{t.removeEventListener("contextmenu",i),t.removeEventListener("keydown",s),t.removeEventListener("keyup",r),t.removeEventListener("pointerdown",c),t.removeEventListener("pointermove",d),t.removeEventListener("pointerup",h),t.removeEventListener("wheel",P),t.removeEventListener("pointerenter",a)}}getUpDirection(t,e){e.copy(this.up)}getCameraUpDirection(t){this.getUpDirection(this.camera.position,t)}getPivotPoint(t){return this._lastUsedState===I?this._zoomPointWasSet?(t.copy(this.zoomPoint),t):null:this._lastUsedState===w||this._lastUsedState===E?(t.copy(this.pivotPoint),t):null}detach(){this.domElement=null,this._detachCallback&&(this._detachCallback(),this._detachCallback=null,this.pointerTracker.reset())}resetState(){this.state!==_&&this.dispatchEvent(it),this.state=_,this.pivotMesh.removeFromParent(),this.pivotMesh.visible=this.enabled,this.actionHeightOffset=0}setState(t=this.state,e=!0){this.state!==t&&(this.state===_&&e&&this.dispatchEvent(et),this.pivotMesh.visible=this.enabled,this.dragInertia.set(0,0,0),this.rotationInertia.set(0,0),this.state=t,t!==_&&t!==F&&(this._lastUsedState=t))}update(t=Math.min(this.clock.getDelta(),64/1e3)){if(!this.enabled||!this.camera||t===0)return;const{camera:e,cameraRadius:i,pivotPoint:s,up:r,state:c,adjustHeight:p}=this;e.updateMatrixWorld(),this.getCameraUpDirection(S),this._upInitialized||(this._upInitialized=!0,this.up.copy(S));const d=this._inertiaNeedsUpdate();if(this.needsUpdate||d){const a=this.zoomDelta;(c===I||a!==0)&&(this._updateZoom(),this.rotationInertia.set(0,0),this.dragInertia.set(0,0,0)),this._updatePosition(t),this._updateRotation(t),(c!==_||a!==0||d)&&this.dispatchEvent(yt),this.needsUpdate=!1}d&&this._updateInertiaDamping(t);const h=e.isOrthographicCamera?null:p&&this._getPointBelowCamera()||null,P=e.isOrthographicCamera?s:h&&h.point||null;if(this.getCameraUpDirection(S),this._setFrame(S,P),(this.state===E||this.state===w)&&this.actionHeightOffset!==0){const{actionHeightOffset:a}=this;e.position.addScaledVector(r,-a),s.addScaledVector(r,-a),h&&(h.distance-=a)}if(this.actionHeightOffset=0,h){const a=h.distance;if(a0?1/Math.abs(o):o;i.zoom=Math.max(d,Math.min(h,i.zoom*n*P)),i.updateProjectionMatrix(),O(u.x,u.y,p,B),B.unproject(i),i.position.sub(B).add(V),i.updateMatrixWorld()}else{const o=Math.pow(.95,Math.abs(a*.05)),n=a>0?1/Math.abs(o):o;i.zoom=Math.max(d,Math.min(h,i.zoom*n*P)),i.updateProjectionMatrix()}else{this._updateZoomDirection();const o=y.copy(e);if(this.zoomPointSet||this._updateZoomPoint()){const n=t.distanceTo(i.position);if(a<0){const m=Math.min(0,n-r);a=a*n*P*.0025,a=Math.max(a,m)}else{const m=Math.max(0,n-s);a=a*(n-s)*P*.0025,a=Math.min(a,m)}i.position.addScaledVector(e,a),i.updateMatrixWorld()}else{const n=this._getPointBelowCamera();if(n){const m=n.distance;o.set(0,0,-1).transformDirection(i.matrixWorld),i.position.addScaledVector(o,a*m*.01),i.updateMatrixWorld()}}}}_updateZoomDirection(){if(this.zoomDirectionSet)return;const{domElement:t,raycaster:e,camera:i,zoomDirection:s,pointerTracker:r}=this;r.getLatestPoint(u),O(u.x,u.y,t,V),W(e,V,i),s.copy(e.ray.direction).normalize(),this.zoomDirectionSet=!0}_updateZoomPoint(){const{camera:t,zoomDirectionSet:e,zoomDirection:i,raycaster:s,zoomPoint:r,pointerTracker:c,domElement:p}=this;if(this._zoomPointWasSet=!1,!e)return!1;t.isOrthographicCamera&&c.getLatestPoint(A)?(O(A.x,A.y,p,A),W(s,A,t)):(s.ray.origin.copy(t.position),s.ray.direction.copy(i),s.near=0,s.far=1/0);const d=this._raycast(s);return d?(r.copy(d.point),this.zoomPointSet=!0,this._zoomPointWasSet=!0,!0):!1}_getPointBelowCamera(){const{camera:t,raycaster:e,up:i}=this;e.ray.direction.copy(i).multiplyScalar(-1),e.ray.origin.copy(t.position).addScaledVector(i,1e5),e.near=0,e.far=1/0;const s=this._raycast(e);return s&&(s.distance-=1e5),s}_updatePosition(t){const{raycaster:e,camera:i,pivotPoint:s,up:r,pointerTracker:c,domElement:p,state:d,dragInertia:h,enableDamping:P}=this;if(d===E){if(c.getCenterPoint(u),O(u.x,u.y,p,u),J.setFromNormalAndCoplanarPoint(r,s),W(e,u,i),Math.abs(e.ray.direction.dot(r))0?(h=Math.min(a-r-.01,h),h=Math.max(0,h)):(h=Math.max(a-c,h),h=Math.min(0,h)),x.setFromAxisAngle(S,d),L(i,x,D),s.matrixWorld.premultiply(D),z.set(-1,0,0).transformDirection(s.matrixWorld),x.setFromAxisAngle(z,h),L(i,x,D),s.matrixWorld.premultiply(D),s.matrixWorld.decompose(s.position,s.quaternion,y)}_setFrame(t,e){const{up:i,camera:s,state:r,zoomPoint:c,zoomDirection:p,zoomDirectionSet:d,zoomPointSet:h,reorientOnDrag:P,scaleZoomOrientationAtEdges:a}=this;s.updateMatrixWorld(),x.setFromUnitVectors(i,t);const o=r;if(d&&(h||this._updateZoomPoint())){if(this.getUpDirection(c,y),a){let n=Math.max(y.dot(i)-.6,0)/.4;n=ut.mapLinear(n,0,.5,0,1),n=Math.min(n,1),s.isOrthographicCamera&&(n*=.1),x.slerp(vt,1-n)}L(c,x,D),s.matrixWorld.premultiply(D),s.matrixWorld.decompose(s.position,s.quaternion,y),this.zoomDirectionSet=!1,this._updateZoomDirection()}else o===E&&P&&e&&(L(e,x,D),s.matrixWorld.premultiply(D),s.matrixWorld.decompose(s.position,s.quaternion,y));i.copy(t),s.updateMatrixWorld()}_raycast(t){const{scene:e,useFallbackPlane:i,fallbackPlane:s}=this,r=t.intersectObject(e)[0]||null;if(r)return r;if(i){const c=s;if(t.ray.intersectPlane(c,y))return{point:y.clone(),distance:t.ray.origin.distanceTo(y)}}return null}}export{E as D,Dt as E,_ as N,O as a,_t as b,St as c,L as m,W as s}; diff --git a/example/bundle/assets/FlyOrbitControls-D1sYBrL1.js b/example/bundle/assets/FlyOrbitControls-D1sYBrL1.js new file mode 100644 index 000000000..e71a89c92 --- /dev/null +++ b/example/bundle/assets/FlyOrbitControls-D1sYBrL1.js @@ -0,0 +1 @@ +import{G as _,aj as N,M as F,f as V,d as I,C as P,k as U,ak as W,o as z}from"./three.module-C94OeYjd.js";import{S as j,a as q}from"./EllipsoidRegionHelper-7avvRq-k.js";import{O as J}from"./OrbitControls-bHRTZZ2i.js";const E=Symbol("ORIGINAL_MATERIAL"),k=Symbol("HAS_RANDOM_COLOR"),M=Symbol("HAS_RANDOM_NODE_COLOR"),v=Symbol("LOAD_TIME"),O=new I,L=()=>{},G={};function R(x){if(!G[x]){const e=Math.random(),t=.5+Math.random()*.5,i=.375+Math.random()*.25;G[x]=new P().setHSL(e,t,i)}return G[x]}const C=0,Q=1,X=2,Y=3,Z=4,$=5,ee=6,S=7,w=8,te=9,A=10;class le{constructor(e){e={displayBoxBounds:!1,displaySphereBounds:!1,displayRegionBounds:!1,colorMode:C,maxDebugDepth:-1,maxDebugDistance:-1,maxDebugError:-1,customColorCallback:null,...e},this.name="DEBUG_TILES_PLUGIN",this.tiles=null,this.extremeDebugDepth=-1,this.extremeDebugError=-1,this.boxGroup=null,this.sphereGroup=null,this.regionGroup=null,this.displayBoxBounds=e.displayBoxBounds,this.displaySphereBounds=e.displaySphereBounds,this.displayRegionBounds=e.displayRegionBounds,this.colorMode=e.colorMode,this.maxDebugDepth=e.maxDebugDepth,this.maxDebugDistance=e.maxDebugDistance,this.maxDebugError=e.maxDebugError,this.customColorCallback=e.customColorCallback,this.getDebugColor=(t,i)=>{i.setRGB(t,t,t)}}init(e){this.tiles=e;const t=e.group;this.boxGroup=new _,this.boxGroup.name="DebugTilesRenderer.boxGroup",t.add(this.boxGroup),this.boxGroup.updateMatrixWorld(),this.sphereGroup=new _,this.sphereGroup.name="DebugTilesRenderer.sphereGroup",t.add(this.sphereGroup),this.sphereGroup.updateMatrixWorld(),this.regionGroup=new _,this.regionGroup.name="DebugTilesRenderer.regionGroup",t.add(this.regionGroup),this.regionGroup.updateMatrixWorld(),this._onLoadTileSetCB=()=>{this._initExtremes()},this._onLoadModelCB=({scene:i,tile:a})=>{this._onLoadModel(i,a)},this._onDisposeModelCB=({tile:i})=>{this._onDisposeModel(i)},this._onUpdateAfterCB=()=>{this._onUpdateAfter()},this._onTileVisibilityChangeCB=({scene:i,tile:a,visible:h})=>{this._onTileVisibilityChange(a,h)},e.addEventListener("load-tile-set",this._onLoadTileSetCB),e.addEventListener("load-model",this._onLoadModelCB),e.addEventListener("dispose-model",this._onDisposeModelCB),e.addEventListener("update-after",this._onUpdateAfterCB),e.addEventListener("tile-visibility-change",this._onTileVisibilityChangeCB),e.traverse(i=>{i.cached.scene&&this._onLoadModel(i.cached.scene,i)}),e.visibleTiles.forEach(i=>{this._onTileVisibilityChange(i,!0)})}getTileInformationFromActiveObject(e){let t=null;return this.tiles.activeTiles.forEach(a=>{if(t)return!0;const h=a.cached.scene;h&&h.traverse(n=>{n===e&&(t=a)})}),t?{distanceToCamera:t.__distanceFromCamera,geometricError:t.geometricError,screenSpaceError:t.__error,depth:t.__depth,isLeaf:t.__isLeaf}:null}_initExtremes(){let e=-1;this.tiles.traverse(i=>{e=Math.max(e,i.__depth)});let t=-1;this.tiles.traverse(i=>{t=Math.max(t,i.geometricError)}),this.extremeDebugDepth=e,this.extremeDebugError=t}_onUpdateAfter(){const e=this.tiles;if(!e.root)return;this.boxGroup.visible=this.displayBoxBounds,this.sphereGroup.visible=this.displaySphereBounds,this.regionGroup.visible=this.displayRegionBounds;let t=-1;this.maxDebugDepth===-1?t=this.extremeDebugDepth:t=this.maxDebugDepth;let i=-1;this.maxDebugError===-1?i=this.extremeDebugError:i=this.maxDebugError;let a=-1;this.maxDebugDistance===-1?(e.getBoundingSphere(O),a=O.radius):a=this.maxDebugDistance;const h=this.errorTarget,n=this.colorMode,d=e.visibleTiles;let s;n===A&&(s=Array.from(d).sort((r,u)=>r[v]-u[v])),d.forEach(r=>{const u=r.cached.scene;let b,f,g;n===S&&(b=Math.random(),f=.5+Math.random()*.5,g=.375+Math.random()*.25),u.traverse(o=>{n===w&&(b=Math.random(),f=.5+Math.random()*.5,g=.375+Math.random()*.25);const D=o.material;if(D){const y=o[E];if(n===C&&D!==y)o.material.dispose(),o.material=o[E];else if(n!==C&&D===y)if(o.isPoints){const l=new N;l.size=y.size,l.sizeAttenuation=y.sizeAttenuation,o.material=l}else o.material=new F,o.material.flatShading=!0;switch(n!==S&&delete o.material[k],n!==w&&delete o.material[M],n){case Z:{const l=r.__depth/t;this.getDebugColor(l,o.material.color);break}case $:{const l=r.__depthFromRenderedParent/t;this.getDebugColor(l,o.material.color);break}case Q:{const l=r.__error/h;l>1?o.material.color.setRGB(1,0,0):this.getDebugColor(l,o.material.color);break}case X:{const l=Math.min(r.geometricError/i,1);this.getDebugColor(l,o.material.color);break}case Y:{const l=Math.min(r.__distanceFromCamera/a,1);this.getDebugColor(l,o.material.color);break}case ee:{!r.children||r.children.length===0?this.getDebugColor(1,o.material.color):this.getDebugColor(0,o.material.color);break}case w:{o.material[M]||(o.material.color.setHSL(b,f,g),o.material[M]=!0);break}case S:{o.material[k]||(o.material.color.setHSL(b,f,g),o.material[k]=!0);break}case te:{this.customColorCallback?this.customColorCallback(r,o):console.warn("DebugTilesRenderer: customColorCallback not defined");break}case A:{const l=s.indexOf(r);this.getDebugColor(l/(s.length-1),o.material.color);break}}}})})}_onTileVisibilityChange(e,t){const i=e.cached,a=this.sphereGroup,h=this.boxGroup,n=this.regionGroup,d=i.boxHelperGroup,s=i.sphereHelper,r=i.regionHelper;t?(d&&(h.add(d),d.updateMatrixWorld(!0)),s&&(a.add(s),s.updateMatrixWorld(!0)),r&&(n.add(r),r.updateMatrixWorld(!0))):(d&&h.remove(d),s&&a.remove(s),r&&n.remove(r))}_onLoadModel(e,t){t[v]=performance.now();const i=this.tiles,a=t.cached,{sphere:h,obb:n,region:d}=a.boundingVolume;if(n){const s=new _;s.name="DebugTilesRenderer.boxHelperGroup",s.matrix.copy(n.transform),s.matrixAutoUpdate=!1;const r=new V(n.box,R(t.__depth));r.raycast=L,s.add(r),a.boxHelperGroup=s,i.visibleTiles.has(t)&&this.displayBoxBounds&&(this.boxGroup.add(s),s.updateMatrixWorld(!0))}if(h){const s=new j(h,R(t.__depth));s.raycast=L,a.sphereHelper=s,i.visibleTiles.has(t)&&this.displaySphereBounds&&(this.sphereGroup.add(s),s.updateMatrixWorld(!0))}if(d){const s=new q(d,R(t.__depth));s.raycast=L;const r=new I;d.getBoundingSphere(r),s.position.copy(r.center),r.center.multiplyScalar(-1),s.geometry.translate(...r.center),a.regionHelper=s,i.visibleTiles.has(t)&&this.displayRegionBounds&&(this.regionGroup.add(s),s.updateMatrixWorld(!0))}e.traverse(s=>{const r=s.material;r&&(s[E]=r)})}_onDisposeModel(e){const t=e.cached;t.boxHelperGroup&&(t.boxHelperGroup.children[0].geometry.dispose(),delete t.boxHelperGroup),t.sphereHelper&&(t.sphereHelper.geometry.dispose(),delete t.sphereHelper),t.regionHelper&&(t.regionHelper.geometry.dispose(),delete t.regionHelper)}dispose(){const e=this.tiles;e.removeEventListener("load-tile-set",this._onLoadTileSetCB),e.removeEventListener("load-model",this._onLoadModelCB),e.removeEventListener("dispose-model",this._onDisposeModelCB),e.removeEventListener("update-after",this._onUpdateAfterCB),this.colorMode=C,this._onUpdateAfter(),e.traverse(t=>{this._onDisposeModel(t)}),this.boxGroup.removeFromParent(),this.sphereGroup.removeFromParent(),this.regionGroup.removeFromParent()}}const se={type:"fly-change"},re={type:"fly-start"},ie={type:"fly-end"},p=new W(0,0,0,0);class he extends J{constructor(e,t){const i=c=>{this.enabled&&Object.defineProperty(c,"shiftKey",{get(){return!1}})};t.addEventListener("pointerdown",i),super(e,t),this.enableKeys=!1,this.enableFlight=!0,this.baseSpeed=1,this.fastSpeed=4,this.forwardKey="w",this.backKey="s",this.leftKey="a",this.rightKey="d",this.upKey="q",this.downKey="e",this.fastKey="shift";let a=!1,h=!1,n=!1,d=!1,s=!1,r=!1,u=!1,b=0,f=0,g=0,o=-1;const D=new U,y=new z,l=()=>{if(o!==-1){cancelAnimationFrame(o),o=-1,this.minDistance=f,this.maxDistance=g;const c=Math.min(b,e.position.distanceTo(D));p.set(0,0,-1,0).applyMatrix4(e.matrixWorld),this.target.copy(e.position).addScaledVector(p,c),this.dispatchEvent(ie)}},H=()=>{if(!this.enabled||!this.enableFlight)return;o=requestAnimationFrame(H),p.set(0,0,0,0),h&&(p.z-=1),n&&(p.z+=1),d&&(p.x-=1),s&&(p.x+=1),r&&(p.y+=1),u&&(p.y-=1),p.applyMatrix4(e.matrixWorld);const c=60*y.getDelta(),m=a?this.fastSpeed:this.baseSpeed;e.position.addScaledVector(p,m*c),this.target.addScaledVector(p,m*c),this.dispatchEvent(se)},T=c=>{const m=c.key.toLowerCase();switch(o===-1&&(g=this.maxDistance,f=this.minDistance,b=e.position.distanceTo(this.target),D.copy(this.target)),m){case this.forwardKey:h=!0;break;case this.backKey:n=!0;break;case this.leftKey:d=!0;break;case this.rightKey:s=!0;break;case this.upKey:r=!0;break;case this.downKey:u=!0;break;case this.fastKey:a=!0;break}switch(m){case this.fastKey:case this.forwardKey:case this.backKey:case this.leftKey:case this.rightKey:case this.upKey:case this.downKey:c.stopPropagation(),c.preventDefault()}(h||n||d||s||r||u||a)&&(this.minDistance=.01,this.maxDistance=.01,p.set(0,0,-1,0).applyMatrix4(e.matrixWorld),this.target.copy(e.position).addScaledVector(p,.01),o===-1&&(this.dispatchEvent(re),y.getDelta(),H()))},B=c=>{const m=c.key.toLowerCase();switch(m){case this.fastKey:case this.forwardKey:case this.backKey:case this.leftKey:case this.rightKey:case this.upKey:case this.downKey:c.stopPropagation(),c.preventDefault()}switch(m){case this.forwardKey:h=!1;break;case this.backKey:n=!1;break;case this.leftKey:d=!1;break;case this.rightKey:s=!1;break;case this.upKey:r=!1;break;case this.downKey:u=!1;break;case this.fastKey:a=!1;break}h||n||d||s||r||u||a||l()},K=()=>{l()};this.blurCallback=K,this.keyDownCallback=T,this.keyUpCallback=B,this.disableShiftKeyCallback=i,this.domElement.addEventListener("blur",K),this.domElement.addEventListener("keydown",T),this.domElement.addEventListener("keyup",B)}dispose(){super.dispose(),this.domElement.removeEventListener("blur",this.blurCallback),this.domElement.removeEventListener("keydown",this.keyDownCallback),this.domElement.removeEventListener("keyup",this.keyUpCallback),this.domElement.removeEventListener("pointerdown",this.disableShiftKeyCallback)}}export{te as C,Y as D,he as F,X as G,ee as I,A as L,C as N,$ as R,Q as S,Z as a,S as b,w as c,le as d}; diff --git a/example/bundle/assets/GLTFExtensionLoader-Qt9Ghhze.js b/example/bundle/assets/GLTFExtensionLoader-Qt9Ghhze.js new file mode 100644 index 000000000..5cc14aeaa --- /dev/null +++ b/example/bundle/assets/GLTFExtensionLoader-Qt9Ghhze.js @@ -0,0 +1 @@ +import{aH as d}from"./three.module-C94OeYjd.js";import{G as l}from"./GLTFLoader-C77rxX9H.js";import{L as p}from"./LoaderBase-CVSPpjX2.js";class h{constructor(){this.name="CESIUM_RTC"}afterRoot(e){if(e.parser.json.extensions&&e.parser.json.extensions.CESIUM_RTC){const{center:t}=e.parser.json.extensions.CESIUM_RTC;t&&(e.scene.position.x+=t[0],e.scene.position.y+=t[1],e.scene.position.z+=t[2])}}}class u extends p{constructor(e=d){super(),this.manager=e}parse(e){return new Promise((t,o)=>{const a=this.manager,n=this.fetchOptions;let s=a.getHandler("path.gltf")||a.getHandler("path.glb");s||(s=new l(a),s.register(()=>new h)),n.credentials==="include"&&n.mode==="cors"&&s.setCrossOrigin("use-credentials"),"credentials"in n&&s.setWithCredentials(n.credentials==="include"),n.headers&&s.setRequestHeader(n.headers);let r=s.resourcePath||s.path||this.workingPath;!/[\\/]$/.test(r)&&r.length&&(r+="/"),s.parse(e,r,c=>{t(c)},o)})}}export{u as G,h as a}; diff --git a/example/bundle/assets/GLTFLoader-C77rxX9H.js b/example/bundle/assets/GLTFLoader-C77rxX9H.js new file mode 100644 index 000000000..ceab8f896 --- /dev/null +++ b/example/bundle/assets/GLTFLoader-C77rxX9H.js @@ -0,0 +1 @@ +import{aJ as Re,aK as W,aL as ce,q as Ee,aM as G,F as ue,C,a2 as y,aN as xe,aO as _e,D as Le,aa as k,a1 as B,aP as M,V as le,k as F,aI as Se,aQ as Me,az as fe,ah as be,ag as ye,af as j,aR as we,v as de,w as he,aS as Y,aj as Ne,aT as K,am as Ie,M as pe,aU as Oe,aV as Ce,ae as Fe,aW as De,g as Pe,al as He,aD as ke,aX as Ge,aY as Be,G as V,a as Ue,n as ve,O as je,aZ as Ke,a_ as Ve,a$ as Xe,b0 as me,b1 as J,p as U,Q as Ae,b2 as ze,b3 as qe,b4 as We,b5 as Ye,b6 as Qe,b7 as Ze,b8 as Je,b9 as $e,ba as et,bb as $,bc as ee,bd as te,be as ne,B as tt,d as nt,bf as st}from"./three.module-C94OeYjd.js";function Bt(f){let t=0;for(const i in f.attributes){const n=f.getAttribute(i);t+=n.count*n.itemSize*n.array.BYTES_PER_ELEMENT}const e=f.getIndex();return t+=e?e.count*e.itemSize*e.array.BYTES_PER_ELEMENT:0,t}function se(f,t){if(t===Re)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),f;if(t===W||t===ce){let e=f.getIndex();if(e===null){const s=[],a=f.getAttribute("position");if(a!==void 0){for(let o=0;o=2.0 are supported."));return}const c=new Ht(r,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(s),c.setPlugins(a),c.parse(i,n)}parseAsync(t,e){const i=this;return new Promise(function(n,r){i.parse(t,e,n,r)})}}function rt(){let f={};return{get:function(t){return f[t]},add:function(t,e){f[t]=e},remove:function(t){delete f[t]},removeAll:function(){f={}}}}const A={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 it{constructor(t){this.parser=t,this.name=A.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let i=0,n=e.length;i=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,r.source,s)}}class Rt{constructor(t){this.parser=t,this.name=A.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,i=this.parser,n=i.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=n.images[s.source];let o=i.textureLoader;if(a.uri){const c=i.options.manager.getHandler(a.uri);c!==null&&(o=c)}return this.detectSupport().then(function(c){if(c)return i.loadTextureImage(t,s.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class Et{constructor(t){this.parser=t,this.name=A.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(t){const e=this.name,i=this.parser,n=i.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const s=r.extensions[e],a=n.images[s.source];let o=i.textureLoader;if(a.uri){const c=i.options.manager.getHandler(a.uri);c!==null&&(o=c)}return this.detectSupport().then(function(c){if(c)return i.loadTextureImage(t,s.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return i.loadTexture(t)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(t){const e=new Image;e.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",e.onload=e.onerror=function(){t(e.height===1)}})),this.isSupported}}class xt{constructor(t){this.name=A.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,i=e.bufferViews[t];if(i.extensions&&i.extensions[this.name]){const n=i.extensions[this.name],r=this.parser.getDependency("buffer",n.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported){if(e.extensionsRequired&&e.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const o=n.byteOffset||0,c=n.byteLength||0,l=n.count,u=n.byteStride,d=new Uint8Array(a,o,c);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(l,u,d,n.mode,n.filter).then(function(h){return h.buffer}):s.ready.then(function(){const h=new ArrayBuffer(l*u);return s.decodeGltfBuffer(new Uint8Array(h),l,u,d,n.mode,n.filter),h})})}else return null}}class _t{constructor(t){this.name=A.EXT_MESH_GPU_INSTANCING,this.parser=t}createNodeMesh(t){const e=this.parser.json,i=e.nodes[t];if(!i.extensions||!i.extensions[this.name]||i.mesh===void 0)return null;const n=e.meshes[i.mesh];for(const c of n.primitives)if(c.mode!==_.TRIANGLES&&c.mode!==_.TRIANGLE_STRIP&&c.mode!==_.TRIANGLE_FAN&&c.mode!==void 0)return null;const s=i.extensions[this.name].attributes,a=[],o={};for(const c in s)a.push(this.parser.getDependency("accessor",s[c]).then(l=>(o[c]=l,o[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(t)),Promise.all(a).then(c=>{const l=c.pop(),u=l.isGroup?l.children:[l],d=c[0].count,h=[];for(const p of u){const T=new U,m=new F,g=new Ae,E=new F(1,1,1),x=new Se(p.geometry,p.material,d);for(let R=0;R0||f.search(/^data\:image\/jpeg/)===0?"image/jpeg":f.search(/\.webp($|\?)/i)>0||f.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const Pt=new U;class Ht{constructor(t={},e={}){this.json=t,this.extensions={},this.plugins={},this.options=e,this.cache=new rt,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 i=!1,n=-1,r=!1,s=-1;if(typeof navigator<"u"){const a=navigator.userAgent;i=/^((?!chrome|android).)*safari/i.test(a)===!0;const o=a.match(/Version\/(\d+)/);n=i&&o?parseInt(o[1],10):-1,r=a.indexOf("Firefox")>-1,s=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||i&&n<17||r&&s<98?this.textureLoader=new be(this.options.manager):this.textureLoader=new ye(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new ue(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(t){this.extensions=t}setPlugins(t){this.plugins=t}parse(t,e){const i=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([i.getDependencies("scene"),i.getDependencies("animation"),i.getDependencies("camera")])}).then(function(s){const a={scene:s[0][n.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:n.asset,parser:i,userData:{}};return O(r,a,n),b(a,n),Promise.all(i._invokeAll(function(o){return o.afterRoot&&o.afterRoot(a)})).then(function(){for(const o of a.scenes)o.updateMatrixWorld();t(a)})}).catch(e)}_markDefs(){const t=this.json.nodes||[],e=this.json.skins||[],i=this.json.meshes||[];for(let n=0,r=e.length;n{const o=this.associations.get(s);o!=null&&this.associations.set(a,o);for(const[c,l]of s.children.entries())r(l,a.children[c])};return r(i,n),n.name+="_instance_"+t.uses[e]++,n}_invokeOne(t){const e=Object.values(this.plugins);e.push(this);for(let i=0;i=2&&m.setY(N,w[L*o+1]),o>=3&&m.setZ(N,w[L*o+2]),o>=4&&m.setW(N,w[L*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return m})}loadTexture(t){const e=this.json,i=this.options,r=e.textures[t].source,s=e.images[r];let a=this.textureLoader;if(s.uri){const o=i.manager.getHandler(s.uri);o!==null&&(a=o)}return this.loadTextureImage(t,r,a)}loadTextureImage(t,e,i){const n=this,r=this.json,s=r.textures[t],a=r.images[e],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const c=this.loadImageSource(e,i).then(function(l){l.flipY=!1,l.name=s.name||a.name||"",l.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(l.name=a.uri);const d=(r.samplers||{})[s.sampler]||{};return l.magFilter=ie[d.magFilter]||de,l.minFilter=ie[d.minFilter]||he,l.wrapS=oe[d.wrapS]||Y,l.wrapT=oe[d.wrapT]||Y,n.associations.set(l,{textures:t}),l}).catch(function(){return null});return this.textureCache[o]=c,c}loadImageSource(t,e){const i=this,n=this.json,r=this.options;if(this.sourceCache[t]!==void 0)return this.sourceCache[t].then(u=>u.clone());const s=n.images[t],a=self.URL||self.webkitURL;let o=s.uri||"",c=!1;if(s.bufferView!==void 0)o=i.getDependency("bufferView",s.bufferView).then(function(u){c=!0;const d=new Blob([u],{type:s.mimeType});return o=a.createObjectURL(d),o});else if(s.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const l=Promise.resolve(o).then(function(u){return new Promise(function(d,h){let p=d;e.isImageBitmapLoader===!0&&(p=function(T){const m=new $(T);m.needsUpdate=!0,d(m)}),e.load(G.resolveURL(u,r.path),p,void 0,h)})}).then(function(u){return c===!0&&a.revokeObjectURL(o),b(u,s),u.userData.mimeType=s.mimeType||Dt(s.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),u});return this.sourceCache[t]=l,l}assignTexture(t,e,i,n){const r=this;return this.getDependency("texture",i.index).then(function(s){if(!s)return null;if(i.texCoord!==void 0&&i.texCoord>0&&(s=s.clone(),s.channel=i.texCoord),r.extensions[A.KHR_TEXTURE_TRANSFORM]){const a=i.extensions!==void 0?i.extensions[A.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const o=r.associations.get(s);s=r.extensions[A.KHR_TEXTURE_TRANSFORM].extendTexture(s,a),r.associations.set(s,o)}}return n!==void 0&&(s.colorSpace=n),t[e]=s,s})}assignFinalMaterial(t){const e=t.geometry;let i=t.material;const n=e.attributes.tangent===void 0,r=e.attributes.color!==void 0,s=e.attributes.normal===void 0;if(t.isPoints){const a="PointsMaterial:"+i.uuid;let o=this.cache.get(a);o||(o=new Ne,K.prototype.copy.call(o,i),o.color.copy(i.color),o.map=i.map,o.sizeAttenuation=!1,this.cache.add(a,o)),i=o}else if(t.isLine){const a="LineBasicMaterial:"+i.uuid;let o=this.cache.get(a);o||(o=new Ie,K.prototype.copy.call(o,i),o.color.copy(i.color),o.map=i.map,this.cache.add(a,o)),i=o}if(n||r||s){let a="ClonedMaterial:"+i.uuid+":";n&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),s&&(a+="flat-shading:");let o=this.cache.get(a);o||(o=i.clone(),r&&(o.vertexColors=!0),s&&(o.flatShading=!0),n&&(o.normalScale&&(o.normalScale.y*=-1),o.clearcoatNormalScale&&(o.clearcoatNormalScale.y*=-1)),this.cache.add(a,o),this.associations.set(o,this.associations.get(i))),i=o}t.material=i}getMaterialType(){return pe}loadMaterial(t){const e=this,i=this.json,n=this.extensions,r=i.materials[t];let s;const a={},o=r.extensions||{},c=[];if(o[A.KHR_MATERIALS_UNLIT]){const u=n[A.KHR_MATERIALS_UNLIT];s=u.getMaterialType(),c.push(u.extendParams(a,r,e))}else{const u=r.pbrMetallicRoughness||{};if(a.color=new C(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const d=u.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],y),a.opacity=d[3]}u.baseColorTexture!==void 0&&c.push(e.assignTexture(a,"map",u.baseColorTexture,B)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(e.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(e.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),s=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(t)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(t,a)})))}r.doubleSided===!0&&(a.side=Oe);const l=r.alphaMode||z.OPAQUE;if(l===z.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===z.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&s!==k&&(c.push(e.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new le(1,1),r.normalTexture.scale!==void 0)){const u=r.normalTexture.scale;a.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&s!==k&&(c.push(e.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&s!==k){const u=r.emissiveFactor;a.emissive=new C().setRGB(u[0],u[1],u[2],y)}return r.emissiveTexture!==void 0&&s!==k&&c.push(e.assignTexture(a,"emissiveMap",r.emissiveTexture,B)),Promise.all(c).then(function(){const u=new s(a);return r.name&&(u.name=r.name),b(u,r),e.associations.set(u,{materials:t}),r.extensions&&O(n,u,r),u})}createUniqueName(t){const e=Ce.sanitizeNodeName(t||"");return e in this.nodeNamesUsed?e+"_"+ ++this.nodeNamesUsed[e]:(this.nodeNamesUsed[e]=0,e)}loadGeometries(t){const e=this,i=this.extensions,n=this.primitiveCache;function r(a){return i[A.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,e).then(function(o){return ae(o,a,e)})}const s=[];for(let a=0,o=t.length;a0&&Ct(g,r),g.name=e.createUniqueName(r.name||"mesh_"+t),b(g,r),m.extensions&&O(n,g,m),e.assignFinalMaterial(g),u.push(g)}for(let h=0,p=u.length;h1?l=new V:c.length===1?l=c[0]:l=new fe,l!==c[0])for(let u=0,d=c.length;u{const u=new Map;for(const[d,h]of n.associations)(d instanceof K||d instanceof $)&&u.set(d,h);return l.traverse(d=>{const h=n.associations.get(d);h!=null&&u.set(d,h)}),u};return n.associations=c(r),r})}_createAnimationTracks(t,e,i,n,r){const s=[],a=t.name?t.name:t.uuid,o=[];I[r.path]===I.weights?t.traverse(function(d){d.morphTargetInfluences&&o.push(d.name?d.name:d.uuid)}):o.push(a);let c;switch(I[r.path]){case I.weights:c=te;break;case I.rotation:c=ne;break;case I.position:case I.scale:c=ee;break;default:switch(i.itemSize){case 1:c=te;break;case 2:case 3:default:c=ee;break}break}const l=n.interpolation!==void 0?Nt[n.interpolation]:me,u=this._getArrayFromAccessor(i);for(let d=0,h=o.length;d{const i=s[1];return e[1]-i}).map(s=>s[0]).join("; ")}}function a(r){let t=null;return l(r,s=>{if(s.content&&s.content.uri){const[,e]=s.content.uri.split("?");return t=new URLSearchParams(e).get("session"),!0}return!1}),t}class b{constructor({apiToken:t,autoRefreshToken:s=!1,logoUrl:e=null}){this.name="GOOGLE_CLOUD_AUTH_PLUGIN",this.apiToken=t,this.autoRefreshToken=s,this.logoUrl=e,this.sessionToken=null,this.tiles=null,this._onLoadCallback=null,this._visibilityChangeCallback=null,this._tokenRefreshPromise=null,this._attributionsManager=new u,this._logoAttribution={value:"",type:"image"},this._attribution={value:"",type:"string"}}init(t){this.tiles=t,this._onLoadCallback=({tileSet:s})=>{this.sessionToken=a(s.root),t.removeEventListener("load-tile-set",this._onLoadCallback)},this._visibilityChangeCallback=({tile:s,visible:e})=>{const i=s.cached.metadata.asset.copyright||"";e?this._attributionsManager.addAttributions(i):this._attributionsManager.removeAttributions(i)},t.addEventListener("load-tile-set",this._onLoadCallback),t.addEventListener("tile-visibility-change",this._visibilityChangeCallback)}getAttributions(t){this.tiles.visibleTiles.size>0&&(this.logoUrl&&(this._logoAttribution.value=this.logoUrl,t.push(this._logoAttribution)),this._attribution.value=this._attributionsManager.toString(),t.push(this._attribution))}preprocessURL(t){return t=new URL(t),/^http/.test(t.protocol)&&(t.searchParams.append("key",this.apiToken),this.sessionToken!==null&&t.searchParams.append("session",this.sessionToken)),t.toString()}dispose(){const{tiles:t}=this;t.removeEventListener("load-tile-set",this._onLoadCallback),t.removeEventListener("tile-visibility-change",this._visibilityChangeCallback)}async fetchData(t,s){this._tokenRefreshPromise!==null&&(await this._tokenRefreshPromise,t=this.preprocessURL(t));const e=await fetch(t,s);return e.status>=400&&e.status<=499&&this.autoRefreshToken?(await this._refreshToken(s),fetch(this.preprocessURL(t),s)):e}_refreshToken(t){if(this._tokenRefreshPromise===null){const s=new URL(this.tiles.rootURL);s.searchParams.append("key",this.apiToken),this._tokenRefreshPromise=fetch(s,t).then(e=>e.json()).then(e=>{this.sessionToken=a(e.root),this._tokenRefreshPromise=null})}return this._tokenRefreshPromise}}export{b as G}; diff --git a/example/bundle/assets/GoogleTilesRenderer-CVSgZtW5.js b/example/bundle/assets/GoogleTilesRenderer-CVSgZtW5.js new file mode 100644 index 000000000..f22bda31e --- /dev/null +++ b/example/bundle/assets/GoogleTilesRenderer-CVSgZtW5.js @@ -0,0 +1 @@ +import{T as o}from"./TilesRenderer-DQOLA18N.js";const s="https://tile.googleapis.com",r=`${s}/v1/3dtiles/root.json`,i=e=>class extends e{constructor(t=r){super(t),this.parseQueue.maxJobs=10,this.downloadQueue.maxJobs=30,this.errorTarget=40}getCreditsString(){return console.warn('GooglePhotorealisticTilesRenderer: "getCreditsString" function is deprecated. Use "getAttributions", instead.'),this.getAttributions()[0].value}},l=i(o);export{l as G}; diff --git a/example/bundle/assets/I3DMLoader-C4TPl3Dp.js b/example/bundle/assets/I3DMLoader-C4TPl3Dp.js new file mode 100644 index 000000000..84afb167c --- /dev/null +++ b/example/bundle/assets/I3DMLoader-C4TPl3Dp.js @@ -0,0 +1 @@ +import{r as H,F as v,B as G,a as k}from"./readMagicBytes-Da5ueiou.js";import{L as Q}from"./LoaderBase-CVSPpjX2.js";import{k as d,p as B,aH as j,aI as W,Q as $}from"./three.module-C94OeYjd.js";import{G as z}from"./GLTFLoader-C77rxX9H.js";class Z extends Q{parse(r){const s=new DataView(r),a=H(s);console.assert(a==="i3dm");const E=s.getUint32(4,!0);console.assert(E===1);const U=s.getUint32(8,!0);console.assert(U===r.byteLength);const b=s.getUint32(12,!0),A=s.getUint32(16,!0),o=s.getUint32(20,!0),p=s.getUint32(24,!0),f=s.getUint32(28,!0),u=32,y=r.slice(u,u+b+A),n=new v(y,0,b,A),e=u+b+A,c=r.slice(e,e+o+p),L=new G(c,n.getData("INSTANCES_LENGTH"),0,o,p),m=e+o+p,h=new Uint8Array(r,m,U-m);let O=null,l=null,i=null;if(f)O=h,l=Promise.resolve();else{const T=this.resolveExternalURL(k(h)),w=T.split(/[\\/]/g);w.pop(),i=w.join("/"),l=fetch(T,this.fetchOptions).then(t=>{if(!t.ok)throw new Error(`I3DMLoaderBase : Failed to load file "${T}" with status ${t.status} : ${t.statusText}`);return t.arrayBuffer()}).then(t=>{O=new Uint8Array(t)})}return l.then(()=>({version:E,featureTable:n,batchTable:L,glbBytes:O,gltfWorkingPath:i}))}}const D=new d,R=new d,_=new d,F=new d,C=new $,M=new d,S=new B,x=new B;class Y extends Z{constructor(r=j){super(),this.manager=r,this.adjustmentTransform=new B}resolveExternalURL(r){return this.manager.resolveURL(super.resolveExternalURL(r))}parse(r){return super.parse(r).then(s=>{const{featureTable:a,batchTable:E}=s,U=s.glbBytes.slice().buffer;return new Promise((b,A)=>{const o=this.fetchOptions,p=this.manager,f=p.getHandler("path.gltf")||new z(p);o.credentials==="include"&&o.mode==="cors"&&f.setCrossOrigin("use-credentials"),"credentials"in o&&f.setWithCredentials(o.credentials==="include"),o.headers&&f.setRequestHeader(o.headers);let u=s.gltfWorkingPath??this.workingPath;/[\\/]$/.test(u)||(u+="/");const y=this.adjustmentTransform;f.parse(U,u,n=>{const e=a.getData("INSTANCES_LENGTH"),c=a.getData("POSITION",e,"FLOAT","VEC3"),L=a.getData("NORMAL_UP",e,"FLOAT","VEC3"),m=a.getData("NORMAL_RIGHT",e,"FLOAT","VEC3"),h=a.getData("SCALE_NON_UNIFORM",e,"FLOAT","VEC3"),O=a.getData("SCALE",e,"FLOAT","SCALAR"),l=a.getData("RTC_CENTER");["QUANTIZED_VOLUME_OFFSET","QUANTIZED_VOLUME_SCALE","EAST_NORTH_UP","POSITION_QUANTIZED","NORMAL_UP_OCT32P","NORMAL_RIGHT_OCT32P"].forEach(t=>{t in a.header&&console.warn(`I3DMLoader: Unsupported FeatureTable feature "${t}" detected.`)});const i=new d;for(let t=0;t{if(t.isMesh){w.push(t);const{geometry:N,material:I}=t,g=new W(N,I,e);g.position.copy(i),l&&(g.position.x+=l[0],g.position.y+=l[1],g.position.z+=l[2]),T.push(g)}});for(let t=0;t{if(!r.ok)throw new Error(`Failed to load file "${t}" with status ${r.status} : ${r.statusText}`);return r.arrayBuffer()}).then(r=>(this.workingPath===""&&(this.workingPath=this.workingPathForURL(t)),this.parse(r)))}resolveExternalURL(t){return/^[^\\/]/.test(t)&&!/^http/.test(t)?this.workingPath+"/"+t:t}workingPathForURL(t){const r=t.split(/[\\/]/g);return r.pop(),r.join("/")+"/"}parse(t){throw new Error("LoaderBase: Parse not implemented.")}}export{n as L}; diff --git a/example/bundle/assets/OrbitControls-bHRTZZ2i.js b/example/bundle/assets/OrbitControls-bHRTZZ2i.js new file mode 100644 index 000000000..254349791 --- /dev/null +++ b/example/bundle/assets/OrbitControls-bHRTZZ2i.js @@ -0,0 +1 @@ +import{i as Ve,j as We,E as Ge,k as u,l as N,T as S,Q as Pe,m as Te,V as m,n as qe}from"./three.module-C94OeYjd.js";const Oe={type:"change"},J={type:"start"},we={type:"end"},X=new Ve,Me=new We,Be=Math.cos(70*qe.DEG2RAD);class et extends Ge{constructor(F,je){super(),this.object=F,this.domElement=je,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new u,this.cursor=new u,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:N.ROTATE,MIDDLE:N.DOLLY,RIGHT:N.PAN},this.touches={ONE:S.ROTATE,TWO:S.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return s.phi},this.getAzimuthalAngle=function(){return s.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(t){t.addEventListener("keydown",v),this._domElementKeyEvents=t},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",v),this._domElementKeyEvents=null},this.saveState=function(){e.target0.copy(e.target),e.position0.copy(e.object.position),e.zoom0=e.object.zoom},this.reset=function(){e.target.copy(e.target0),e.object.position.copy(e.position0),e.object.zoom=e.zoom0,e.object.updateProjectionMatrix(),e.dispatchEvent(Oe),e.update(),r=a.NONE},this.update=function(){const t=new u,o=new Pe().setFromUnitVectors(F.up,new u(0,1,0)),n=o.clone().invert(),i=new u,l=new Pe,g=new u,d=2*Math.PI;return function(Fe=null){const ge=e.object.position;t.copy(ge).sub(e.target),t.applyQuaternion(o),s.setFromVector3(t),e.autoRotate&&r===a.NONE&&C(Ae(Fe)),e.enableDamping?(s.theta+=p.theta*e.dampingFactor,s.phi+=p.phi*e.dampingFactor):(s.theta+=p.theta,s.phi+=p.phi);let h=e.minAzimuthAngle,f=e.maxAzimuthAngle;isFinite(h)&&isFinite(f)&&(h<-Math.PI?h+=d:h>Math.PI&&(h-=d),f<-Math.PI?f+=d:f>Math.PI&&(f-=d),h<=f?s.theta=Math.max(h,Math.min(f,s.theta)):s.theta=s.theta>(h+f)/2?Math.max(h,s.theta):Math.min(f,s.theta)),s.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,s.phi)),s.makeSafe(),e.enableDamping===!0?e.target.addScaledVector(j,e.dampingFactor):e.target.add(j),e.target.sub(e.cursor),e.target.clampLength(e.minTargetRadius,e.maxTargetRadius),e.target.add(e.cursor);let z=!1;if(e.zoomToCursor&&K||e.object.isOrthographicCamera)s.radius=B(s.radius);else{const b=s.radius;s.radius=B(s.radius*E),z=b!=s.radius}if(t.setFromSpherical(s),t.applyQuaternion(n),ge.copy(e.target).add(t),e.object.lookAt(e.target),e.enableDamping===!0?(p.theta*=1-e.dampingFactor,p.phi*=1-e.dampingFactor,j.multiplyScalar(1-e.dampingFactor)):(p.set(0,0,0),j.set(0,0,0)),e.zoomToCursor&&K){let b=null;if(e.object.isPerspectiveCamera){const _=t.length();b=B(_*E);const Z=_-b;e.object.position.addScaledVector($,Z),e.object.updateMatrixWorld(),z=!!Z}else if(e.object.isOrthographicCamera){const _=new u(y.x,y.y,0);_.unproject(e.object);const Z=e.object.zoom;e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/E)),e.object.updateProjectionMatrix(),z=Z!==e.object.zoom;const Ee=new u(y.x,y.y,0);Ee.unproject(e.object),e.object.position.sub(Ee).add(_),e.object.updateMatrixWorld(),b=t.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),e.zoomToCursor=!1;b!==null&&(this.screenSpacePanning?e.target.set(0,0,-1).transformDirection(e.object.matrix).multiplyScalar(b).add(e.object.position):(X.origin.copy(e.object.position),X.direction.set(0,0,-1).transformDirection(e.object.matrix),Math.abs(e.object.up.dot(X.direction))V||8*(1-l.dot(e.object.quaternion))>V||g.distanceToSquared(e.target)>V?(e.dispatchEvent(Oe),i.copy(e.object.position),l.copy(e.object.quaternion),g.copy(e.target),!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",be),e.domElement.removeEventListener("pointerdown",de),e.domElement.removeEventListener("pointercancel",Y),e.domElement.removeEventListener("wheel",me),e.domElement.removeEventListener("pointermove",Q),e.domElement.removeEventListener("pointerup",Y),e.domElement.getRootNode().removeEventListener("keydown",pe,{capture:!0}),e._domElementKeyEvents!==null&&(e._domElementKeyEvents.removeEventListener("keydown",v),e._domElementKeyEvents=null)};const e=this,a={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let r=a.NONE;const V=1e-6,s=new Te,p=new Te;let E=1;const j=new u,P=new m,T=new m,A=new m,O=new m,w=new m,L=new m,D=new m,R=new m,M=new m,$=new u,y=new m;let K=!1;const c=[],I={};let W=!1;function Ae(t){return t!==null?2*Math.PI/60*e.autoRotateSpeed*t:2*Math.PI/60/60*e.autoRotateSpeed}function H(t){const o=Math.abs(t*.01);return Math.pow(.95,e.zoomSpeed*o)}function C(t){p.theta-=t}function U(t){p.phi-=t}const ee=function(){const t=new u;return function(n,i){t.setFromMatrixColumn(i,0),t.multiplyScalar(-n),j.add(t)}}(),te=function(){const t=new u;return function(n,i){e.screenSpacePanning===!0?t.setFromMatrixColumn(i,1):(t.setFromMatrixColumn(i,0),t.crossVectors(e.object.up,t)),t.multiplyScalar(n),j.add(t)}}(),x=function(){const t=new u;return function(n,i){const l=e.domElement;if(e.object.isPerspectiveCamera){const g=e.object.position;t.copy(g).sub(e.target);let d=t.length();d*=Math.tan(e.object.fov/2*Math.PI/180),ee(2*n*d/l.clientHeight,e.object.matrix),te(2*i*d/l.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(ee(n*(e.object.right-e.object.left)/e.object.zoom/l.clientWidth,e.object.matrix),te(i*(e.object.top-e.object.bottom)/e.object.zoom/l.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function G(t){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?E/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function oe(t){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?E*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function q(t,o){if(!e.zoomToCursor)return;K=!0;const n=e.domElement.getBoundingClientRect(),i=t-n.left,l=o-n.top,g=n.width,d=n.height;y.x=i/g*2-1,y.y=-(l/d)*2+1,$.set(y.x,y.y,1).unproject(e.object).sub(e.object.position).normalize()}function B(t){return Math.max(e.minDistance,Math.min(e.maxDistance,t))}function ne(t){P.set(t.clientX,t.clientY)}function Le(t){q(t.clientX,t.clientX),D.set(t.clientX,t.clientY)}function ae(t){O.set(t.clientX,t.clientY)}function De(t){T.set(t.clientX,t.clientY),A.subVectors(T,P).multiplyScalar(e.rotateSpeed);const o=e.domElement;C(2*Math.PI*A.x/o.clientHeight),U(2*Math.PI*A.y/o.clientHeight),P.copy(T),e.update()}function Re(t){R.set(t.clientX,t.clientY),M.subVectors(R,D),M.y>0?G(H(M.y)):M.y<0&&oe(H(M.y)),D.copy(R),e.update()}function xe(t){w.set(t.clientX,t.clientY),L.subVectors(w,O).multiplyScalar(e.panSpeed),x(L.x,L.y),O.copy(w),e.update()}function ke(t){q(t.clientX,t.clientY),t.deltaY<0?oe(H(t.deltaY)):t.deltaY>0&&G(H(t.deltaY)),e.update()}function Ne(t){let o=!1;switch(t.code){case e.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?U(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):x(0,e.keyPanSpeed),o=!0;break;case e.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?U(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):x(0,-e.keyPanSpeed),o=!0;break;case e.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?C(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):x(e.keyPanSpeed,0),o=!0;break;case e.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?C(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):x(-e.keyPanSpeed,0),o=!0;break}o&&(t.preventDefault(),e.update())}function ie(t){if(c.length===1)P.set(t.pageX,t.pageY);else{const o=k(t),n=.5*(t.pageX+o.x),i=.5*(t.pageY+o.y);P.set(n,i)}}function se(t){if(c.length===1)O.set(t.pageX,t.pageY);else{const o=k(t),n=.5*(t.pageX+o.x),i=.5*(t.pageY+o.y);O.set(n,i)}}function re(t){const o=k(t),n=t.pageX-o.x,i=t.pageY-o.y,l=Math.sqrt(n*n+i*i);D.set(0,l)}function Se(t){e.enableZoom&&re(t),e.enablePan&&se(t)}function Ie(t){e.enableZoom&&re(t),e.enableRotate&&ie(t)}function ce(t){if(c.length==1)T.set(t.pageX,t.pageY);else{const n=k(t),i=.5*(t.pageX+n.x),l=.5*(t.pageY+n.y);T.set(i,l)}A.subVectors(T,P).multiplyScalar(e.rotateSpeed);const o=e.domElement;C(2*Math.PI*A.x/o.clientHeight),U(2*Math.PI*A.y/o.clientHeight),P.copy(T)}function le(t){if(c.length===1)w.set(t.pageX,t.pageY);else{const o=k(t),n=.5*(t.pageX+o.x),i=.5*(t.pageY+o.y);w.set(n,i)}L.subVectors(w,O).multiplyScalar(e.panSpeed),x(L.x,L.y),O.copy(w)}function ue(t){const o=k(t),n=t.pageX-o.x,i=t.pageY-o.y,l=Math.sqrt(n*n+i*i);R.set(0,l),M.set(0,Math.pow(R.y/D.y,e.zoomSpeed)),G(M.y),D.copy(R);const g=(t.pageX+o.x)*.5,d=(t.pageY+o.y)*.5;q(g,d)}function Ce(t){e.enableZoom&&ue(t),e.enablePan&&le(t)}function Ye(t){e.enableZoom&&ue(t),e.enableRotate&&ce(t)}function de(t){e.enabled!==!1&&(c.length===0&&(e.domElement.setPointerCapture(t.pointerId),e.domElement.addEventListener("pointermove",Q),e.domElement.addEventListener("pointerup",Y)),!Xe(t)&&(Ue(t),t.pointerType==="touch"?fe(t):ze(t)))}function Q(t){e.enabled!==!1&&(t.pointerType==="touch"?He(t):_e(t))}function Y(t){switch(Ze(t),c.length){case 0:e.domElement.releasePointerCapture(t.pointerId),e.domElement.removeEventListener("pointermove",Q),e.domElement.removeEventListener("pointerup",Y),e.dispatchEvent(we),r=a.NONE;break;case 1:const o=c[0],n=I[o];fe({pointerId:o,pageX:n.x,pageY:n.y});break}}function ze(t){let o;switch(t.button){case 0:o=e.mouseButtons.LEFT;break;case 1:o=e.mouseButtons.MIDDLE;break;case 2:o=e.mouseButtons.RIGHT;break;default:o=-1}switch(o){case N.DOLLY:if(e.enableZoom===!1)return;Le(t),r=a.DOLLY;break;case N.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(e.enablePan===!1)return;ae(t),r=a.PAN}else{if(e.enableRotate===!1)return;ne(t),r=a.ROTATE}break;case N.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(e.enableRotate===!1)return;ne(t),r=a.ROTATE}else{if(e.enablePan===!1)return;ae(t),r=a.PAN}break;default:r=a.NONE}r!==a.NONE&&e.dispatchEvent(J)}function _e(t){switch(r){case a.ROTATE:if(e.enableRotate===!1)return;De(t);break;case a.DOLLY:if(e.enableZoom===!1)return;Re(t);break;case a.PAN:if(e.enablePan===!1)return;xe(t);break}}function me(t){e.enabled===!1||e.enableZoom===!1||r!==a.NONE||(t.preventDefault(),e.dispatchEvent(J),ke(Ke(t)),e.dispatchEvent(we))}function Ke(t){const o=t.deltaMode,n={clientX:t.clientX,clientY:t.clientY,deltaY:t.deltaY};switch(o){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return t.ctrlKey&&!W&&(n.deltaY*=10),n}function pe(t){t.key==="Control"&&(W=!0,e.domElement.getRootNode().addEventListener("keyup",he,{passive:!0,capture:!0}))}function he(t){t.key==="Control"&&(W=!1,e.domElement.getRootNode().removeEventListener("keyup",he,{passive:!0,capture:!0}))}function v(t){e.enabled===!1||e.enablePan===!1||Ne(t)}function fe(t){switch(ye(t),c.length){case 1:switch(e.touches.ONE){case S.ROTATE:if(e.enableRotate===!1)return;ie(t),r=a.TOUCH_ROTATE;break;case S.PAN:if(e.enablePan===!1)return;se(t),r=a.TOUCH_PAN;break;default:r=a.NONE}break;case 2:switch(e.touches.TWO){case S.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;Se(t),r=a.TOUCH_DOLLY_PAN;break;case S.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;Ie(t),r=a.TOUCH_DOLLY_ROTATE;break;default:r=a.NONE}break;default:r=a.NONE}r!==a.NONE&&e.dispatchEvent(J)}function He(t){switch(ye(t),r){case a.TOUCH_ROTATE:if(e.enableRotate===!1)return;ce(t),e.update();break;case a.TOUCH_PAN:if(e.enablePan===!1)return;le(t),e.update();break;case a.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;Ce(t),e.update();break;case a.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;Ye(t),e.update();break;default:r=a.NONE}}function be(t){e.enabled!==!1&&t.preventDefault()}function Ue(t){c.push(t.pointerId)}function Ze(t){delete I[t.pointerId];for(let o=0;o>11,t=L>>5&63,o=L&31,g=Math.round(s/31*255),n=Math.round(t/63*255),c=Math.round(o/31*255);return[g,n,c]}const D={RGB:"color",POSITION:"position"};class Q extends x{constructor(s=w){super(),this.manager=s}parse(s){return super.parse(s).then(async t=>{const{featureTable:o,batchTable:g}=t,n=new G,c=o.header.extensions,l=new P;let a;if(c&&c["3DTILES_draco_point_compression"]){const{byteOffset:e,byteLength:u,properties:i}=c["3DTILES_draco_point_compression"],f=this.manager.getHandler("draco.drc");if(f==null)throw new Error("PNTSLoader: dracoLoader not available.");const b={};for(const p in i)if(p in D&&p in i){const S=D[p];b[S]=i[p]}const N={attributeIDs:b,attributeTypes:{position:"Float32Array",color:"Uint8Array"},useUniqueIDs:!0},B=o.getBuffer(e,u);a=await f.decodeGeometry(B,N),a.attributes.color&&(n.vertexColors=!0)}else{const e=o.getData("POINTS_LENGTH"),u=o.getData("POSITION",e,"FLOAT","VEC3"),i=o.getData("RGB",e,"UNSIGNED_BYTE","VEC3"),f=o.getData("RGBA",e,"UNSIGNED_BYTE","VEC4"),b=o.getData("RGB565",e,"UNSIGNED_SHORT","SCALAR"),N=o.getData("CONSTANT_RGBA",e,"UNSIGNED_BYTE","VEC4"),B=o.getData("POSITION_QUANTIZED",e,"UNSIGNED_SHORT","VEC3"),p=o.getData("QUANTIZED_VOLUME_SCALE",e,"FLOAT","VEC3"),S=o.getData("QUANTIZED_VOLUME_OFFSET",e,"FLOAT","VEC3");if(a=new R,B){const E=new Float32Array(e*3);for(let r=0;r{e in o.header&&console.warn(`PNTSLoader: Unsupported FeatureTable feature "${e}" detected.`)});const O=new V(a,n);O.position.copy(l),t.scene=O,t.scene.featureTable=o,t.scene.batchTable=g;const T=o.getData("RTC_CENTER");return T&&(t.scene.position.x+=T[0],t.scene.position.y+=T[1],t.scene.position.z+=T[2]),t})}}export{Q as P}; diff --git a/example/bundle/assets/TileCompressionPlugin-DurGWH0s.js b/example/bundle/assets/TileCompressionPlugin-DurGWH0s.js new file mode 100644 index 000000000..354636afc --- /dev/null +++ b/example/bundle/assets/TileCompressionPlugin-DurGWH0s.js @@ -0,0 +1 @@ +import{k as w,af as z,n as S}from"./three.module-C94OeYjd.js";const I=new w;function A(t,o){if(t.isInterleavedBufferAttribute||t.array instanceof o)return t;const f=o===Int8Array||o===Int16Array||o===Int32Array?-1:0,s=new o(t.count*t.itemSize),y=new z(s,t.itemSize,!0),d=t.itemSize,v=t.count;for(let c=0;c{if(r.material&&s){const a=r.material;for(const e in a){const n=a[e];n&&n.isTexture&&(n.generateMipmaps=!1)}}if(r.geometry){const a=r.geometry,e=a.attributes;if(d){const{uv:n,uv1:m,uv2:l,uv3:p}=e;n&&(e.uv=A(n,i)),m&&(e.uv1=A(m,i)),l&&(e.uv2=A(l,i)),p&&(e.uv3=A(p,i))}if(f&&!e.normals&&a.computeVertexNormals(),v&&e.normals&&(e.normals=A(e.normals,u)),c&&B(r,x),y&&a.index){const n=e.position.count,m=a.index,l=n>65535?Uint32Array:n>255?Uint16Array:Uint8Array;if(!(m.array instanceof l)){const p=new l(a.index.count);p.set(m.array);const b=new z(p,1);a.setIndex(b)}}}})}}export{C as T}; diff --git a/example/bundle/assets/TilesFadePlugin-BuMLsouQ.js b/example/bundle/assets/TilesFadePlugin-BuMLsouQ.js new file mode 100644 index 000000000..e9eb7d58d --- /dev/null +++ b/example/bundle/assets/TilesFadePlugin-BuMLsouQ.js @@ -0,0 +1,47 @@ +import{n as P,k as _,G as I,p as O,Q as y}from"./three.module-C94OeYjd.js";const{clamp:p}=P;class b{constructor(){this.duration=250,this.fadeCount=0,this._lastTick=-1,this._fadeState=new Map,this._fadeParams=new WeakMap,this.onFadeComplete=null,this.onFadeStart=null,this.onFadeSetComplete=null,this.onFadeSetStart=null}prepareObject(e){e.traverse(a=>{a.material&&this.prepareMaterial(a.material)})}deleteObject(e){if(!e)return;this.completeFade(e);const a=this._fadeParams;e.traverse(i=>{const t=i.material;t&&(a.delete(t),t.onBeforeCompile=null,t.needsUpdate=!0)})}prepareMaterial(e){const a=this._fadeParams;if(a.has(e))return;const i={fadeIn:{value:0},fadeOut:{value:0}};e.defines={FEATURE_FADE:0},e.onBeforeCompile=t=>{t.uniforms={...t.uniforms,...i},t.fragmentShader=t.fragmentShader.replace(/void main\(/,r=>` + #if FEATURE_FADE + + // adapted from https://www.shadertoy.com/view/Mlt3z8 + float bayerDither2x2( vec2 v ) { + + return mod( 3.0 * v.y + 2.0 * v.x, 4.0 ); + + } + + float bayerDither4x4( vec2 v ) { + + vec2 P1 = mod( v, 2.0 ); + vec2 P2 = floor( 0.5 * mod( v, 4.0 ) ); + return 4.0 * bayerDither2x2( P1 ) + bayerDither2x2( P2 ); + + } + + uniform float fadeIn; + uniform float fadeOut; + #endif + + ${r} + `).replace(/#include /,r=>` + + ${r} + + #if FEATURE_FADE + + float bayerValue = bayerDither4x4( floor( mod( gl_FragCoord.xy, 4.0 ) ) ); + float bayerBins = 16.0; + float dither = ( 0.5 + bayerValue ) / bayerBins; + if ( dither >= fadeIn ) { + + discard; + + } + + if ( dither < fadeOut ) { + + discard; + + } + + #endif + + `)},a.set(e,i)}guaranteeState(e){const a=this._fadeState;if(a.has(e))return!1;const i={fadeInTarget:0,fadeOutTarget:0,fadeIn:0,fadeOut:0};a.set(e,i);const t=this._fadeParams;return e.traverse(r=>{const d=r.material;if(d&&t.has(d)){const f=t.get(d);f.fadeIn.value=0,f.fadeOut.value=0}}),!0}completeFade(e){const a=this._fadeState;a.has(e)&&(a.delete(e),e.traverse(i=>{const t=i.material;t&&t.defines.FEATURE_FADE!==0&&(t.defines.FEATURE_FADE=0,t.needsUpdate=!0)}),this.fadeCount--,this.onFadeComplete&&this.onFadeComplete(e),this.fadeCount===0&&this.onFadeSetComplete&&this.onFadeSetComplete())}completeAllFades(){this._fadeState.forEach((e,a)=>{this.completeFade(a)})}forEachObject(e){this._fadeState.forEach((a,i)=>e(i))}fadeIn(e){const a=this.guaranteeState(e),i=this._fadeState.get(e);i.fadeInTarget=1,i.fadeOutTarget=0,i.fadeOut=0,a&&(this.fadeCount++,this.fadeCount===1&&this.onFadeSetStart&&this.onFadeSetStart(),this.onFadeStart&&this.onFadeStart(e))}fadeOut(e){const a=this.guaranteeState(e),i=this._fadeState.get(e);i.fadeOutTarget=1,a&&(i.fadeInTarget=1,i.fadeIn=1,this.fadeCount++,this.fadeCount===1&&this.onFadeSetStart&&this.onFadeSetStart(),this.onFadeStart&&this.onFadeStart(e))}update(){const e=window.performance.now();this._lastTick===-1&&(this._lastTick=e);const a=p((e-this._lastTick)/this.duration,0,1);this._lastTick=e;const i=this._fadeState,t=this._fadeParams;i.forEach((r,d)=>{const{fadeOutTarget:f,fadeInTarget:h}=r;let{fadeOut:o,fadeIn:n}=r;const c=Math.sign(h-n);n=p(n+c*a,0,1);const m=Math.sign(f-o);o=p(o+m*a,0,1),r.fadeIn=n,r.fadeOut=o;const u=+(o!==f||n!==h);d.traverse(D=>{const l=D.material;if(l&&t.has(l)){const T=t.get(l);T.fadeIn.value=n,T.fadeOut.value=o,u!==l.defines.FEATURE_FADE&&(l.defines.FEATURE_FADE=u,l.needsUpdate=!0)}}),((o===1||o===0)&&(n===1||n===0)||o>=n)&&this.completeFade(d)})}}const E=Symbol("HAS_POPPED_IN"),F=new _,C=new _,M=new y,S=new y,A=new _;function L(s,e,a){s.visible=!0,a?e.__depthFromRenderedParent===1?((e[E]||this.fadeRootTiles)&&this._fadeManager.fadeIn(s),e[E]=!0):this._fadeManager.fadeIn(s):(this._fadeGroup.add(s),this._fadeManager.fadeOut(s))}function U(s,e){this._fadeManager.prepareObject(s),this._tileMap.set(s,e)}function w(s){this._fadeManager.deleteObject(s)}function x(s){s.parent===this._fadeGroup&&this._fadeGroup.remove(s)}function R(s){this._prevCameraTransforms.set(s,new O)}function G(s){this._prevCameraTransforms.delete(s)}function B(){const s=this._fadeManager,e=this.tiles;this._fadingBefore=s.fadeCount,this._displayActiveTiles=e.displayActiveTiles,e.displayActiveTiles=!0}function k(){const s=this._fadeManager,e=this._fadeGroup,a=this._displayActiveTiles,i=this._fadingBefore,t=this.tiles,r=this._prevCameraTransforms,d=this._tileMap,f=t.lruCache,h=t.cameras;t.displayActiveTiles=a,s.update();const o=s.fadeCount;if(i!==0&&o!==0&&t.dispatchEvent({type:"fade-change"}),a||t.visibleTiles.forEach(n=>{n.cached.scene.visible=n.__inFrustum}),this.maximumFadeOutTiles{if(!r.has(c))return;const m=c.matrixWorld,u=r.get(c);m.decompose(C,S,A),u.decompose(F,M,A);const v=S.angleTo(M),g=C.distanceTo(F);n=n&&(v>.25||g>.1)}),n&&s.completeAllFades()}h.forEach(n=>{r.get(n).copy(n.matrixWorld)}),s.forEachObject(n=>{f.markUsed(d.get(n))})}class N{get fadeDuration(){return this._fadeManager.duration}set fadeDuration(e){this._fadeManager.duration=Number(e)}get fadingTiles(){return this._fadeManager.fadeCount}constructor(e){e={maximumFadeOutTiles:50,fadeRootTiles:!1,fadeDuration:250,...e},this.name="FADE_TILES_PLUGIN",this.tiles=null,this._fadeManager=new b,this._prevCameraTransforms=null,this._fadeGroup=null,this._tileMap=null,this.maximumFadeOutTiles=e.maximumFadeOutTiles,this.fadeRootTiles=e.fadeRootTiles,this.fadeDuration=e.fadeDuration}init(e){const a=new I;a.name="TilesFadeGroup",e.group.add(a);const i=this._fadeManager;i.onFadeSetStart=()=>e.dispatchEvent({type:"fade-start"}),i.onFadeSetComplete=()=>e.dispatchEvent({type:"fade-end"}),i.onFadeComplete=x.bind(this),this.tiles=e,this._fadeManager=i,this._fadeGroup=a,this._tileMap=new Map,this._prevCameraTransforms=new Map,e.cameras.forEach(t=>{this._prevCameraTransforms.set(t,new O)}),this._onLoadModel=t=>U.call(this,t.scene,t.tile),this._onDisposeModel=t=>w.call(this,t.scene),this._onTileVisibilityChange=t=>L.call(this,t.scene,t.tile,t.visible),this._onAddCamera=t=>R.call(this,t.camera),this._onDeleteCamera=t=>G.call(this,t.camera),this._onUpdateBefore=()=>B.call(this),this._onUpdateAfter=()=>k.call(this),e.addEventListener("load-model",this._onLoadModel),e.addEventListener("dispose-model",this._onDisposeModel),e.addEventListener("tile-visibility-change",this._onTileVisibilityChange),e.addEventListener("add-camera",this._onAddCamera),e.addEventListener("delete-camera",this._onDeleteCamera),e.addEventListener("update-before",this._onUpdateBefore),e.addEventListener("update-after",this._onUpdateAfter)}dispose(){const e=this.tiles;e.removeEventListener("load-model",this._onLoadModel),e.removeEventListener("dispose-model",this._onDisposeModel),e.removeEventListener("tile-visibility-change",this._onTileVisibilityChange),e.removeEventListener("add-camera",this._onAddCamera),e.removeEventListener("delete-camera",this._onDeleteCamera),e.removeEventListener("update-before",this._onUpdateBefore),e.removeEventListener("update-after",this._onUpdateAfter),e.forEachLoadedModel(a=>{this._fadeManager.deleteObject(a)})}}export{N as T}; diff --git a/example/bundle/assets/TilesRenderer-DQOLA18N.js b/example/bundle/assets/TilesRenderer-DQOLA18N.js new file mode 100644 index 000000000..d6b14fd64 --- /dev/null +++ b/example/bundle/assets/TilesRenderer-DQOLA18N.js @@ -0,0 +1 @@ +import{B as Ee}from"./B3DMLoader-B0T2UZ_1.js";import{P as Be}from"./PNTSLoader-BUgecSBY.js";import{I as De}from"./I3DMLoader-C4TPl3Dp.js";import{C as Ve}from"./CMPTLoader-CXF13c0w.js";import{G as Oe}from"./GLTFExtensionLoader-Qt9Ghhze.js";import{p as w,G as Ne,i as _e,k as y,av as ge,j as ze,B as qe,d as We,ap as je,aE as Ge,aF as Je,V as be,E as He,aG as Qe,L as $e}from"./three.module-C94OeYjd.js";import{r as Ye}from"./readMagicBytes-Da5ueiou.js";import{a as Xe,E as ye}from"./lil-gui.module.min-NsHmRZWc.js";import{e as Ze}from"./GLTFLoader-C77rxX9H.js";function ne(i){let e;try{e=new URL(i,"http://fakehost.com/")}catch{return null}const t=e.pathname.split("/").pop(),s=t.lastIndexOf(".");return s===-1||s===t.length-1?null:t.substring(s+1)}const ie=2**30;class Ke{get unloadPriorityCallback(){return this._unloadPriorityCallback}set unloadPriorityCallback(e){e.length===1?(console.warn('LRUCache: "unloadPriorityCallback" function has been changed to take two arguments.'),this._unloadPriorityCallback=(t,s)=>{const n=e(t),o=e(s);return no?1:0}):this._unloadPriorityCallback=e}constructor(){this.minSize=6e3,this.maxSize=8e3,this.minBytesSize=.3*ie,this.maxBytesSize=.4*ie,this.unloadPercent=.05,this.itemSet=new Map,this.itemList=[],this.usedSet=new Set,this.callbacks=new Map,this.markUnusedQueued=!1,this.unloadingHandle=-1,this.cachedBytes=0,this.bytesMap=new Map,this.loadedSet=new Set,this._unloadPriorityCallback=null,this.computeMemoryUsageCallback=()=>null;const e=this.itemSet;this.defaultPriorityCallback=t=>e.get(t)}isFull(){return this.itemSet.size>=this.maxSize||this.cachedBytes>=this.maxBytesSize}getMemoryUsage(e){return this.bytesMap.get(e)??null}add(e,t){this.markUnusedQueued&&this.markAllUnused();const s=this.itemSet;if(s.has(e)||this.isFull())return!1;const n=this.usedSet,o=this.itemList,r=this.callbacks,a=this.bytesMap;o.push(e),n.add(e),s.set(e,Date.now()),r.set(e,t);const l=this.computeMemoryUsageCallback(e);return this.cachedBytes+=l||0,a.set(e,l),!0}remove(e){const t=this.usedSet,s=this.itemSet,n=this.itemList,o=this.bytesMap,r=this.callbacks,a=this.loadedSet;if(s.has(e)){this.cachedBytes-=o.get(e)||0,o.delete(e),r.get(e)(e);const l=n.indexOf(e);return n.splice(l,1),t.delete(e),s.delete(e),r.delete(e),a.delete(e),!0}return!1}setLoaded(e,t){const{itemSet:s,loadedSet:n}=this;s.has(e)&&(t===!0?n.add(e):n.delete(e))}updateMemoryUsage(e){const t=this.itemSet,s=this.bytesMap;if(!t.has(e))return;this.cachedBytes-=s.get(e)||0;const n=this.computeMemoryUsageCallback(e);s.set(e,n),this.cachedBytes+=n}markUsed(e){this.markUnusedQueued&&this.markAllUnused();const t=this.itemSet,s=this.usedSet;t.has(e)&&!s.has(e)&&(t.set(e,Date.now()),s.add(e))}markAllUnused(){this.usedSet.clear(),this.markUnusedQueued=!1,this.unloadingHandle!==-1&&(cancelAnimationFrame(this.unloadingHandle),this.unloadingHandle=-1)}unloadUnusedContent(){const{unloadPercent:e,minSize:t,maxSize:s,itemList:n,itemSet:o,usedSet:r,loadedSet:a,callbacks:l,bytesMap:c,minBytesSize:h,maxBytesSize:f}=this,p=n.length-r.size,m=n.length-a.size,d=Math.max(Math.min(n.length-t,p),0),_=this.cachedBytes-h,v=this.unloadPriorityCallback||this.defaultPriorityCallback;let g=!1;const F=d>0&&p>0||m&&n.length>s;if(p&&this.cachedBytes>h||m&&this.cachedBytes>f||F){n.sort((b,C)=>{const te=r.has(b),Ae=r.has(C);if(te===Ae){const se=a.has(b),Ie=a.has(C);return se===Ie?-v(b,C):se?1:-1}else return te?1:-1});const I=Math.max(t*e,d*e),L=Math.ceil(Math.min(I,p,d)),u=Math.max(e*_,e*h),U=Math.min(u,_);let x=0,T=0;for(;this.cachedBytes-T>f||n.length-x>s;){const b=n[x],C=c.get(b)||0;if(r.has(b)&&a.has(b)||this.cachedBytes-T-C=L)break;T+=C,x++}n.splice(0,x).forEach(b=>{this.cachedBytes-=c.get(b)||0,l.get(b)(b),c.delete(b),o.delete(b),l.delete(b),a.delete(b),r.delete(b)}),g=x0}g&&(this.unloadingHandle=requestAnimationFrame(()=>this.scheduleUnload()))}scheduleUnload(){this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.unloadUnusedContent(),this.markUnusedQueued=!0}))}}class oe{constructor(){this.maxJobs=6,this.items=[],this.callbacks=new Map,this.currJobs=0,this.scheduled=!1,this.autoUpdate=!0,this.priorityCallback=()=>{throw new Error("PriorityQueue: PriorityCallback function not defined.")},this.schedulingCallback=e=>{requestAnimationFrame(e)},this._runjobs=()=>{this.tryRunJobs(),this.scheduled=!1}}sort(){const e=this.priorityCallback;this.items.sort(e)}add(e,t){return new Promise((s,n)=>{const o=(...l)=>t(...l).then(s).catch(n),r=this.items,a=this.callbacks;r.push(e),a.set(e,o),this.autoUpdate&&this.scheduleJobRun()})}remove(e){const t=this.items,s=this.callbacks,n=t.indexOf(e);n!==-1&&(t.splice(n,1),s.delete(e))}tryRunJobs(){this.sort();const e=this.items,t=this.callbacks,s=this.maxJobs;let n=this.currJobs;for(;s>n&&e.length>0;){n++;const o=e.pop(),r=t.get(o);t.delete(o),r(o).then(()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()}).catch(()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()})}this.currJobs=n}scheduleJobRun(){this.scheduled||(this.schedulingCallback(this._runjobs),this.scheduled=!0)}}const W=-1,E=0,B=1,Q=2,J=3,j=6378137,et=1/298.257223563,tt=-(et*j-j),st=1736*1e3,re=1738.1*1e3;function K(i){return i===J||i===W}function k(i,e){return i.__lastFrameVisited===e&&i.__used}function ee(i,e){i.__lastFrameVisited!==e.frameCount&&(i.__lastFrameVisited=e.frameCount,i.__used=!1,i.__inFrustum=!1,i.__isLeaf=!1,i.__visible=!1,i.__active=!1,i.__error=1/0,i.__distanceFromCamera=1/0,i.__childrenWereVisible=!1,i.__allChildrenLoaded=!1,i.__inFrustum=e.tileInView(i),e.calculateError(i))}function xe(i,e){if(e.ensureChildrenArePreprocessed(i),ee(i,e),Z(i,e),!i.__hasRenderableContent){const t=i.children;for(let s=0,n=t.length;s0&&i.__depth+1>=e.maxDepth)}function Se(i,e=null,t=null,s=null,n=0){if(e&&e(i,s,n)){t&&t(i,s,n);return}const o=i.children;for(let r=0,a=o.length;ri.__depthFromRenderedParent!==e.__depthFromRenderedParent?i.__depthFromRenderedParent>e.__depthFromRenderedParent?-1:1:i.__inFrustum!==e.__inFrustum?i.__inFrustum?1:-1:i.__used!==e.__used?i.__used?1:-1:i.__error!==e.__error?i.__error>e.__error?1:-1:i.__distanceFromCamera!==e.__distanceFromCamera?i.__distanceFromCamera>e.__distanceFromCamera?-1:1:0,it=(i,e)=>i.__depthFromRenderedParent!==e.__depthFromRenderedParent?i.__depthFromRenderedParent>e.__depthFromRenderedParent?1:-1:i.__loadingState!==e.__loadingState?i.__loadingState>e.__loadingState?-1:1:i.__lastFrameVisited!==e.__lastFrameVisited?i.__lastFrameVisited>e.__lastFrameVisited?-1:1:i.__hasUnrenderableContent!==e.__hasUnrenderableContent?i.__hasUnrenderableContent?-1:1:i.__error!==e.__error?i.__error>e.__error?-1:1:0;class ot{get root(){const e=this.rootTileSet;return e?e.root:null}set loadSiblings(e){console.warn('TilesRenderer: "loadSiblings" option has been removed.')}set stopAtEmptyTiles(e){console.warn('TilesRenderer: "stopAtEmptyTiles" option has been removed.')}set preprocessURL(e){console.warn('TilesRendererBase: The "preprocessURL" callback has been deprecated. Use a plugin, instead.'),this._preprocessURL=e}get preprocessURL(){return this._preprocessURL}constructor(e=null){this.rootTileSetTriggered=!1,this.rootTileSet=null,this.rootURL=e,this.fetchOptions={},this.plugins=[],this.queuedTiles=[],this._preprocessURL=null;const t=new Ke;t.unloadPriorityCallback=it;const s=new oe;s.maxJobs=4,s.priorityCallback=le;const n=new oe;n.maxJobs=1,n.priorityCallback=le,this.lruCache=t,this.downloadQueue=s,this.parseQueue=n,this.stats={parsing:0,downloading:0,failed:0,inFrustum:0,used:0,active:0,visible:0},this.frameCount=0,this.errorTarget=6,this.errorThreshold=1/0,this.displayActiveTiles=!1,this.maxDepth=1/0}registerPlugin(e){if(e[ae]===!0)throw new Error("TilesRendererBase: A plugin can only be registered to a single tile set");this.plugins.push(e),e[ae]=!0,e.init&&e.init(this)}unregisterPlugin(e){const t=this.plugins;if(typeof e=="string"&&(e=this.getPluginByName(name)),t.includes(e)){const s=t.indexOf(e);return t.splice(s,1),e.dispose&&e.dispose(),!0}return!1}getPluginByName(e){return this.plugins.find(t=>t.name===e)||null}traverse(e,t){this.root&&Se(this.root,(s,...n)=>(this.ensureChildrenArePreprocessed(s),e?e(s,...n):!1),t)}queueTileForDownload(e){this.queuedTiles.push(e)}update(){const e=this.stats,t=this.lruCache;if(this.rootTileSetTriggered||(this.rootTileSetTriggered=!0,this.invokeOnePlugin(o=>o.loadRootTileSet&&o.loadRootTileSet())),!this.root)return;const s=this.root;e.inFrustum=0,e.used=0,e.active=0,e.visible=0,this.frameCount++,Te(s,this),we(s,this),Ce(s,this),Re(s,this);const n=this.queuedTiles;n.sort(t.unloadPriorityCallback);for(let o=0,r=n.length;o{t.__loadingState===W&&(t.__loadingState=E)}),e.failed=0)}dispose(){this.invokeAllPlugins(s=>{s!==this&&s.dispose&&s.dispose()});const e=this.lruCache,t=[];this.traverse(s=>(t.push(s),!1));for(let s=0,n=t.length;s{o!==this&&o.preprocessNode&&o.preprocessNode(e,t,s)})}setTileActive(e,t){}setTileVisible(e,t){}calculateError(e){return 0}tileInView(e){return!0}ensureChildrenArePreprocessed(e){const t=e.children;for(let s=0,n=t.length;sparseInt(l));console.assert(o<=1,"TilesRenderer: asset.version is expected to be a 1.x or a compatible version."),o===1&&r>0&&console.warn("TilesRenderer: tiles versions at 1.1 or higher have limited support. Some new extensions and features may not be supported.");let a=t.replace(/\/[^/]*\/?$/,"");a=new URL(a,window.location.href).toString(),this.preprocessNode(e.root,a,s)}loadRootTileSet(){let e=this.rootURL;this.invokeAllPlugins(s=>e=s.preprocessURL?s.preprocessURL(e,null):e);const t=this.invokeOnePlugin(s=>s.fetchData&&s.fetchData(e,this.fetchOptions)).then(s=>{if(s.ok)return s.json();throw new Error(`TilesRenderer: Failed to load tileset "${e}" with status ${s.status} : ${s.statusText}`)}).then(s=>{this.preprocessTileSet(s,e),this.rootTileSet=s});return t.catch(s=>{console.error(s),this.rootTileSet=null}),t}requestTileContents(e){if(e.__loadingState!==E)return;let t=!1,s=new URL(e.content.uri,e.__basePath+"/").toString();this.invokeAllPlugins(d=>s=d.preprocessURL?d.preprocessURL(s,e):s);const n=this.stats,o=this.lruCache,r=this.downloadQueue,a=this.parseQueue,l=ne(s);if(!o.add(e,d=>{d.__loadingState===B?(d.__loadAbort.abort(),d.__loadAbort=null):t?d.children.length=0:this.invokeAllPlugins(_=>{_.disposeTile&&_.disposeTile(d)}),d.__loadingState===B?n.downloading--:d.__loadingState===Q&&n.parsing--,d.__loadingState=E,d.__loadIndex++,a.remove(d),r.remove(d)}))return;e.__loadIndex++;const h=e.__loadIndex,f=new AbortController,p=f.signal;n.downloading++,e.__loadAbort=f,e.__loadingState=B;const m=d=>{e.__loadIndex===h&&(d.name!=="AbortError"?(a.remove(e),r.remove(e),e.__loadingState===Q?n.parsing--:e.__loadingState===B&&n.downloading--,n.failed++,console.error(`TilesRenderer : Failed to load tile at url "${e.content.uri}".`),console.error(d),e.__loadingState=W,o.setLoaded(e,!0)):o.remove(e))};return r.add(e,d=>d.__loadIndex!==h?Promise.resolve():this.invokeOnePlugin(_=>_.fetchData&&_.fetchData(s,{...this.fetchOptions,signal:p}))).then(d=>{if(e.__loadIndex===h){if(d.ok)return l==="json"?d.json():d.arrayBuffer();throw new Error(`Failed to load model with error code ${d.status}`)}}).then(d=>{if(e.__loadIndex===h)return n.downloading--,n.parsing++,e.__loadAbort=null,e.__loadingState=Q,a.add(e,_=>_.__loadIndex!==h?Promise.resolve():l==="json"&&d.root?(this.preprocessTileSet(d,s,e),e.children.push(d.root),t=!0,Promise.resolve()):this.invokeOnePlugin(v=>v.parseTile&&v.parseTile(d,_,l,s)))}).then(()=>{e.__loadIndex===h&&(n.parsing--,e.__loadingState=J,o.setLoaded(e,!0),o.getMemoryUsage(e)===null&&(o.isFull()&&o.computeMemoryUsageCallback(e)>0?o.remove(e):o.updateMemoryUsage(e)))}).catch(m)}getAttributions(e=[]){return this.invokeAllPlugins(t=>t!==this&&t.getAttributions&&t.getAttributions(e)),e}invokeOnePlugin(e){const t=[...this.plugins,this];for(let s=0;sNumber.EPSILON){n=!0;break}}if(n){this.matrixWorld.copy(D);const o=this.children;for(let r=0,a=o.length;r{Object.getPrototypeOf(s).raycast.call(s,e,t)}),q.sort(Me)):e.intersectObject(i,!0,t)}function lt(i,e){ke(i,e,q);const t=q[0]||null;return q.length=0,t}function Ue(i,e,t,s=null){const{group:n,activeTiles:o}=i;i.ensureChildrenArePreprocessed(e),s===null&&(s=Pe,G.copy(n.matrixWorld).invert(),s.copy(t.ray).applyMatrix4(G));const r=[],a=e.children;for(let h=0,f=a.length;hc)break;const _=Ue(i,d,t,s);if(_){const v=_.distance*_.distance;vnew y),this.planes=new Array(6).fill().map(()=>new ze)}clampPoint(e,t){return t.copy(e).applyMatrix4(this.inverseTransform).clamp(this.box.min,this.box.max).applyMatrix4(this.transform)}distanceToPoint(e){return this.clampPoint(e,S).distanceTo(e)}containsPoint(e){return S.copy(e).applyMatrix4(this.inverseTransform),this.box.containsPoint(S)}intersectsRay(e){return N.copy(e).applyMatrix4(this.inverseTransform),N.intersectsBox(this.box)}intersectRay(e,t){return N.copy(e).applyMatrix4(this.inverseTransform),N.intersectBox(this.box,t)?(t.applyMatrix4(this.transform),t):null}update(){const{points:e,inverseTransform:t,transform:s,box:n}=this;t.copy(s).invert();const{min:o,max:r}=n;let a=0;for(let l=-1;l<=1;l+=2)for(let c=-1;c<=1;c+=2)for(let h=-1;h<=1;h+=2)e[a].set(l<0?o.x:r.x,c<0?o.y:r.y,h<0?o.z:r.z).applyMatrix4(s),a++;this.updatePlanes()}updatePlanes(){V.copy(this.box.min).applyMatrix4(this.transform),O.copy(this.box.max).applyMatrix4(this.transform),S.set(0,0,1).transformDirection(this.transform),this.planes[0].setFromNormalAndCoplanarPoint(S,V),this.planes[1].setFromNormalAndCoplanarPoint(S,O).negate(),S.set(0,1,0).transformDirection(this.transform),this.planes[2].setFromNormalAndCoplanarPoint(S,V),this.planes[3].setFromNormalAndCoplanarPoint(S,O).negate(),S.set(1,0,0).transformDirection(this.transform),this.planes[4].setFromNormalAndCoplanarPoint(S,V),this.planes[5].setFromNormalAndCoplanarPoint(S,O).negate()}intersectsFrustum(e){const{points:t}=this,{planes:s}=e;for(let n=0;n<6;n++){const o=s[n];let r=-1/0;for(let a=0;a<8;a++){const l=t[a],c=o.distanceToPoint(l);r=ro?n:o}intersectsFrustum(e){const t=this.obb||this.regionObb,s=this.sphere;return s&&!e.intersectsSphere(s)||t&&!t.intersectsFrustum(e)?!1:!!(s||t)}getOBB(e,t){const s=this.obb||this.regionObb;s?(e.copy(s.box),t.copy(s.transform)):(this.getAABB(e),t.identity())}getAABB(e){if(this.sphere)this.sphere.getBoundingBox(e);else{const t=this.obb||this.regionObb;e.copy(t.box).applyMatrix4(t.transform)}}getSphere(e){if(this.sphere)e.copy(this.sphere);else if(this.region)this.region.getBoundingSphere(e);else{const t=this.obb||this.regionObb;t.box.getBoundingSphere(e),e.applyMatrix4(t.transform)}}setObbData(e,t){const s=new ce;R.set(e[3],e[4],e[5]),P.set(e[6],e[7],e[8]),M.set(e[9],e[10],e[11]);const n=R.length(),o=P.length(),r=M.length();R.normalize(),P.normalize(),M.normalize(),n===0&&R.crossVectors(P,M),o===0&&P.crossVectors(R,M),r===0&&M.crossVectors(R,P),s.transform.set(R.x,P.x,M.x,e[0],R.y,P.y,M.y,e[1],R.z,P.z,M.z,e[2],0,0,0,1).premultiply(t),s.box.min.set(-n,-o,-r),s.box.max.set(n,o,r),s.update(),this.obb=s}setSphereData(e,t,s,n,o){const r=new We;r.center.set(e,t,s),r.radius=n,r.applyMatrix4(o),this.sphere=r}setRegionData(e,t,s,n,o,r,a){const l=new Xe(...e.radius,s,o,t,n,r,a),c=new ce;l.getBoundingBox(c.box,c.transform),c.update(),this.region=l,this.regionObb=c}}const ht=new je;function dt(i,e,t,s){const n=ht.set(i.normal.x,i.normal.y,i.normal.z,e.normal.x,e.normal.y,e.normal.z,t.normal.x,t.normal.y,t.normal.z);return s.set(-i.constant,-e.constant,-t.constant),s.applyMatrix3(n.invert()),s}class ut extends Ge{constructor(){super(),this.points=Array(8).fill().map(()=>new y)}setFromProjectionMatrix(e,t){super.setFromProjectionMatrix(e,t),this.calculateFrustumPoints()}calculateFrustumPoints(){const{planes:e,points:t}=this;[[e[0],e[3],e[4]],[e[1],e[3],e[4]],[e[0],e[2],e[4]],[e[1],e[2],e[4]],[e[0],e[3],e[5]],[e[1],e[3],e[5]],[e[0],e[2],e[5]],[e[1],e[2],e[5]]].forEach((n,o)=>{dt(n[0],n[1],n[2],t[o])})}}function ft(i){const{TextureUtils:e}=Je;if(!e)return 0;const t=new Set;let s=0;return i.traverse(n=>{if(n.geometry&&!t.has(n.geometry)&&(s+=Ze(n.geometry),t.add(n.geometry)),n.material){const o=n.material;for(const r in o){const a=o[r];if(a&&a.isTexture&&!t.has(a)){const{format:l,type:c,image:h}=a,{width:f,height:p}=h,m=e.getByteLength(f,p,l,c);s+=a.generateMipmaps?m*4/3:m,t.add(a)}}}}),s}const pt=new ye(j,j,tt),Pt=new ye(re,re,st),ue=new w,fe=new Qe,pe=parseInt(ge)<165,Le=Symbol("INITIAL_FRUSTUM_CULLED"),z=new w,Y=new w,A=new y,X=new be,mt=new y(1,0,0),_t=new y(0,1,0);function me(i,e){i.traverse(t=>{t.frustumCulled=t[Le]&&e})}class gt extends ot{get autoDisableRendererCulling(){return this._autoDisableRendererCulling}set autoDisableRendererCulling(e){this._autoDisableRendererCulling!==e&&(super._autoDisableRendererCulling=e,this.forEachLoadedModel(t=>{me(t,!e)}))}constructor(...e){super(...e),this.group=new rt(this),this.ellipsoid=pt.clone(),this.cameras=[],this.cameraMap=new Map,this.cameraInfo=[],this.activeTiles=new Set,this.visibleTiles=new Set,this.optimizeRaycast=!0,this._eventDispatcher=new He,this._upRotationMatrix=new w,this.lruCache.computeMemoryUsageCallback=s=>s.cached.bytesUsed??null,this._autoDisableRendererCulling=!0,this._loadingTiles=!1;const t=new $e;if(t.setURLModifier(s=>this.preprocessURL?this.preprocessURL(s):s),this.manager=t,pe){const s=this;this._overridenRaycast=function(n,o){s.optimizeRaycast||Object.getPrototypeOf(this).raycast.call(this,n,o)}}}addEventListener(...e){this._eventDispatcher.addEventListener(...e)}hasEventListener(...e){this._eventDispatcher.hasEventListener(...e)}removeEventListener(...e){this._eventDispatcher.removeEventListener(...e)}dispatchEvent(...e){this._eventDispatcher.dispatchEvent(...e)}getBounds(...e){return console.warn("TilesRenderer: getBounds has been renamed to getBoundingBox."),this.getBoundingBox(...e)}getOrientedBounds(...e){return console.warn("TilesRenderer: getOrientedBounds has been renamed to getOrientedBoundingBox."),this.getOrientedBoundingBox(...e)}getBoundingBox(e){if(!this.root)return!1;const t=this.root.cached.boundingVolume;return t?(t.getAABB(e),!0):!1}getOrientedBoundingBox(e,t){if(!this.root)return!1;const s=this.root.cached.boundingVolume;return s?(s.getOBB(e,t),!0):!1}getBoundingSphere(e){if(!this.root)return!1;const t=this.root.cached.boundingVolume;return t?(t.getSphere(e),!0):!1}forEachLoadedModel(e){this.traverse(t=>{const s=t.cached.scene;s&&e(s,t)})}raycast(e,t){if(this.root)if(e.firstHitOnly){const s=Ue(this,this.root,e);s&&t.push(s)}else Fe(this,this.root,e,t)}hasCamera(e){return this.cameraMap.has(e)}setCamera(e){const t=this.cameras,s=this.cameraMap;return s.has(e)?!1:(s.set(e,new be),t.push(e),this.dispatchEvent({type:"add-camera",camera:e}),!0)}setResolution(e,t,s){const n=this.cameraMap;if(!n.has(e))return!1;const o=t.isVector2?t.x:t,r=t.isVector2?t.y:s,a=n.get(e);return(a.width!==o||a.height!==r)&&(a.set(o,r),this.dispatchEvent({type:"camera-resolution-change"})),!0}setResolutionFromRenderer(e,t){return t.getSize(X).multiplyScalar(t.getPixelRatio()),this.setResolution(e,X.x,X.y)}deleteCamera(e){const t=this.cameras,s=this.cameraMap;if(s.has(e)){const n=t.indexOf(e);return t.splice(n,1),s.delete(e),this.dispatchEvent({type:"delete-camera",camera:e}),!0}return!1}preprocessTileSet(e,t,s){super.preprocessTileSet(e,t,s),queueMicrotask(()=>{this.dispatchEvent({type:"load-tile-set",tileSet:e,url:t})})}loadRootTileSet(...e){return super.loadRootTileSet(...e).then(()=>{switch((this.rootTileSet.asset&&this.rootTileSet.asset.gltfUpAxis||"y").toLowerCase()){case"x":this._upRotationMatrix.makeRotationAxis(_t,-Math.PI/2);break;case"y":this._upRotationMatrix.makeRotationAxis(mt,Math.PI/2);break}this.dispatchEvent({type:"load-content"})}).catch(()=>{})}update(){let e=null;if(this.invokeAllPlugins(r=>{if(r.doTilesNeedUpdate){const a=r.doTilesNeedUpdate();e=e===null?a:e||a}}),e===!1){this.dispatchEvent({type:"update-before"}),this.dispatchEvent({type:"update-after"});return}this.dispatchEvent({type:"update-before"});const t=this.group,s=this.cameras,n=this.cameraMap,o=this.cameraInfo;if(s.length===0){console.warn("TilesRenderer: no cameras defined. Cannot update 3d tiles.");return}for(;o.length>s.length;)o.pop();for(;o.length1e-6&&console.warn("ThreeTilesRenderer : Non uniform scale used for tile which may cause issues when calculating screen space error.");for(let r=0,a=o.length;rU.scene);break}case"gltf":case"glb":{const u=new Oe(c);u.workingPath=a,u.fetchOptions=l,f=u.parse(e);break}default:console.warn(`TilesRenderer: Content type "${d}" not supported.`),f=Promise.resolve(null);break}const _=this.stats;this._loadingTiles===!1&&_.parsing+_.downloading>0&&(this.dispatchEvent({type:"tiles-load-start"}),this._loadingTiles=!0);const v=await f;let g,F;if(v.isObject3D?(g=v,F=null):(g=v.scene,F=v),await this.invokeAllPlugins(u=>u.processTileModel&&u.processTileModel(g,t)),o._loadIndex!==h)return;g.updateMatrix(),(d==="glb"||d==="gltf")&&g.matrix.multiply(m),g.matrix.premultiply(p),g.matrix.decompose(g.position,g.quaternion,g.scale),g.traverse(u=>{u[Le]=u.frustumCulled}),me(g,!this.autoDisableRendererCulling),pe&&g.traverse(u=>{u.raycast=this._overridenRaycast});const H=[],I=[],L=[];g.traverse(u=>{if(u.geometry&&I.push(u.geometry),u.material){const U=u.material;H.push(u.material);for(const x in U){const T=U[x];T&&T.isTexture&&L.push(T)}}}),o.materials=H,o.geometry=I,o.textures=L,o.scene=g,o.metadata=F,o.bytesUsed=ft(g),this.dispatchEvent({type:"load-model",scene:g,tile:t}),this._loadingTiles===!0&&_.parsing+_.downloading===1&&(this.dispatchEvent({type:"tiles-load-end"}),this._loadingTiles=!1)}disposeTile(e){super.disposeTile(e);const t=e.cached;if(t.scene){const s=t.materials,n=t.geometry,o=t.textures,r=t.scene.parent;t.scene.traverse(a=>{a.userData.meshFeatures&&a.userData.meshFeatures.dispose(),a.userData.structuralMetadata&&a.userData.structuralMetadata.dispose()});for(let a=0,l=n.length;a{const t=Symbol(i);Object.defineProperty(gt.prototype,i,{get(){return this[t]||null},set(s){console.warn(`TilesRenderer: "${i}" has been deprecated in favor of the "${e}" event.`),this[t]&&this.removeEventListener(e,this[t]),this[t]=s,this.addEventListener(e,s)}})});export{Pt as L,oe as P,gt as T,pt as W,Se as t}; diff --git a/example/bundle/assets/UpdateOnChangePlugin-Bk7zjKKd.js b/example/bundle/assets/UpdateOnChangePlugin-Bk7zjKKd.js new file mode 100644 index 000000000..671e481dd --- /dev/null +++ b/example/bundle/assets/UpdateOnChangePlugin-Bk7zjKKd.js @@ -0,0 +1 @@ +import{p as E,k as D,i as k,V as O,Q as Z,n as c}from"./three.module-C94OeYjd.js";import{E as H,c as T,N as I,D as j,m as P,a as A,s as Q,b as B}from"./EnvironmentControls-CTZuopjd.js";import{E as J}from"./lil-gui.module.min-NsHmRZWc.js";const u=new E,x=new E,C=new D,s=new D,f=new D,R=new D,p=new D,W=new D,U=new D,F=new D,l=new Z,G=new D,w=new D,N={},y=new k,V=new J,M=new O,v=new O,z=new O,K=400;class tt extends H{get ellipsoid(){return this.tilesRenderer?this.tilesRenderer.ellipsoid:null}get tilesGroup(){return this.tilesRenderer?this.tilesRenderer.group:null}constructor(t=null,e=null,i=null,r=null){super(t,e,i),this._dragMode=0,this._rotationMode=0,this.maxZoom=.01,this.useFallbackPlane=!1,this.reorientOnDrag=!1,this.inertiaAxis=new D,this.dragQuaternion=new Z,this.inertiaDragMode=0,this.allowNegativeNearPlanes=!0,this.setTilesRenderer(r)}setScene(t){t===null&&this.tilesRenderer!==null?super.setScene(this.tilesRenderer.group):super.setScene(t)}getPivotPoint(t){const{camera:e,tilesGroup:i,ellipsoid:r}=this;return p.set(0,0,-1).transformDirection(e.matrixWorld),u.copy(i.matrixWorld).invert(),y.origin.copy(e.position),y.direction.copy(p),y.applyMatrix4(u),T(y,r,s),s.applyMatrix4(i.matrixWorld),(super.getPivotPoint(t)===null||t.distanceTo(y.origin)>s.distanceTo(y.origin))&&t.copy(s),t}getVectorToCenter(t){const{tilesGroup:e,camera:i}=this;return t.setFromMatrixPosition(e.matrixWorld).sub(i.position)}getDistanceToCenter(){return this.getVectorToCenter(s).length()}getUpDirection(t,e){const{tilesGroup:i,ellipsoid:r}=this;u.copy(i.matrixWorld).invert(),s.copy(t).applyMatrix4(u),r.getPositionToNormal(s,e),e.transformDirection(i.matrixWorld)}getCameraUpDirection(t){const{tilesGroup:e,ellipsoid:i,camera:r}=this;r.isOrthographicCamera?(this._getVirtualOrthoCameraPosition(s),u.copy(e.matrixWorld).invert(),s.applyMatrix4(u),i.getPositionToNormal(s,t),t.transformDirection(e.matrixWorld)):this.getUpDirection(r.position,t)}update(t=Math.min(this.clock.getDelta(),64/1e3)){if(!this.enabled||!this.tilesGroup||!this.camera||t===0)return;const{camera:e,tilesGroup:i,pivotMesh:r}=this;if(this._isNearControls()?this.scaleZoomOrientationAtEdges=this.zoomDelta<0:(this.state!==I&&this._dragMode!==1&&this._rotationMode!==1&&(r.visible=!1),this.scaleZoomOrientationAtEdges=!1),super.update(t),e.isPerspectiveCamera){let o=this.getDistanceToCenter();const n=this._getMaxPerspectiveDistance();o>n&&(s.setFromMatrixPosition(i.matrixWorld).sub(e.position).normalize().multiplyScalar(-1),e.position.setFromMatrixPosition(i.matrixWorld).addScaledVector(s,n),e.updateMatrixWorld(),o=n)}this.updateCameraClipPlanes(e)}updateCameraClipPlanes(t){const{tilesGroup:e,ellipsoid:i}=this;if(t.isPerspectiveCamera){const r=s.setFromMatrixPosition(e.matrixWorld).sub(t.position).length(),o=Math.max(...i.radius),n=.25*o,a=c.clamp((r-o)/n,0,1),d=c.lerp(1,1e3,a);t.near=Math.max(d,r-o-n);const m=u.copy(e.matrixWorld).invert();C.copy(t.position).applyMatrix4(m),i.getPositionToCartographic(C,N);const h=Math.max(i.getPositionElevation(C),K),g=i.calculateHorizonDistance(N.lat,h);t.far=g*2.5+.1,t.updateProjectionMatrix()}else{this._getVirtualOrthoCameraPosition(t.position,t),t.updateMatrixWorld(),u.copy(t.matrixWorld).invert(),s.setFromMatrixPosition(e.matrixWorld).applyMatrix4(u);const r=-s.z;t.near=r-Math.max(...i.radius)*1.1,t.far=r+.1,!this.allowNegativeNearPlanes&&t.near<0&&(t.position.addScaledVector(p,t.near),t.far-=t.near,t.near=0),t.updateProjectionMatrix(),t.updateMatrixWorld()}}resetState(){super.resetState(),this._dragMode=0,this._rotationMode=0}_updatePosition(t){if(this.state!==j){const{enableDamping:e,inertiaDragMode:i,tilesGroup:r,dragQuaternion:o,dragInertia:n,camera:a}=this;e&&(i===1?(o.w===1&&(o.x!==0||o.y!==0||o.z!==0)&&(o.w=Math.min(o.w,1-1e-9)),f.setFromMatrixPosition(r.matrixWorld),l.identity().slerp(o,n.x*t),P(f,l,x),a.matrixWorld.premultiply(x),a.matrixWorld.decompose(a.position,a.quaternion,s)):i===-1&&this._applyZoomedOutRotation(n.x*t,n.y*t))}else if(this._dragMode===1||this._isNearControls()){this._dragMode=1;const{raycaster:e,camera:i,pivotPoint:r,pointerTracker:o,domElement:n,tilesGroup:a}=this,d=C,m=U;o.getCenterPoint(M),A(M.x,M.y,n,M),Q(e,M,i),u.copy(a.matrixWorld).invert(),e.ray.applyMatrix4(u);const h=s.copy(r).applyMatrix4(u).length();V.radius.setScalar(h),i.isPerspectiveCamera?V.intersectRay(e.ray,s)||B(e.ray,h,s):T(e.ray,V,s),s.applyMatrix4(a.matrixWorld),f.setFromMatrixPosition(a.matrixWorld),d.subVectors(r,f).normalize(),m.subVectors(s,f).normalize(),l.setFromUnitVectors(m,d),P(f,l,x),i.matrixWorld.premultiply(x),i.matrixWorld.decompose(i.position,i.quaternion,s),this.inertiaDragMode=1;const{dragInertia:g,dragQuaternion:_}=this;o.getMoveDistance()/t<2*window.devicePixelRatio?(_.slerp(l,.5),g.set(1/t,0,0)):(_.copy(l),g.set(1/t,0,0))}else{this._dragMode=-1;const{pointerTracker:e,rotationSpeed:i,camera:r,pivotMesh:o,tilesGroup:n,ellipsoid:a,domElement:d}=this;let m;if(r.isPerspectiveCamera){e.getCenterPoint(M),e.getPreviousCenterPoint(v),A(M.x,M.y,d,M),A(v.x,v.y,d,v),s.set(M.x,M.y,-1).unproject(r),C.set(v.x,v.y,-1).unproject(r),s.sub(C);const _=Math.max(...a.radius),b=this.getDistanceToCenter()-_,q=s.distanceTo(C)*b/r.near;m=7.5*1e-4*q/_}else m=c.mapLinear(r.zoom,this._getOrthographicTransitionZoom(),this._getMinOrthographicZoom(),.001,.005);e.getCenterPoint(M),e.getPreviousCenterPoint(v),z.subVectors(M,v).multiplyScalar(m);const h=-z.x*i,g=-z.y*i;f.setFromMatrixPosition(n.matrixWorld),W.set(1,0,0).transformDirection(r.matrixWorld),R.set(0,1,0).transformDirection(r.matrixWorld),l.setFromAxisAngle(W,g),r.quaternion.premultiply(l),P(f,l,x),r.matrixWorld.premultiply(x),l.setFromAxisAngle(R,h),r.quaternion.premultiply(l),P(f,l,x),r.matrixWorld.premultiply(x),r.matrixWorld.decompose(r.position,r.quaternion,s),o.visible=!1,this.inertiaDragMode=-1,z.multiplyScalar(1/t),e.getMoveDistance()/t<2*window.devicePixelRatio?this.dragInertia.lerp(z,.5):this.dragInertia.copy(z)}this._alignCameraUp(this.up)}_applyZoomedOutRotation(t,e){const{rotationSpeed:i,tilesGroup:r,camera:o}=this,n=-t*i,a=-e*i;o.updateMatrixWorld(),f.setFromMatrixPosition(r.matrixWorld),W.set(1,0,0).transformDirection(o.matrixWorld),R.set(0,1,0).transformDirection(o.matrixWorld),l.setFromAxisAngle(W,a),o.quaternion.premultiply(l),P(f,l,x),o.matrixWorld.premultiply(x),l.setFromAxisAngle(R,n),o.quaternion.premultiply(l),P(f,l,x),o.matrixWorld.premultiply(x),o.matrixWorld.decompose(o.position,o.quaternion,s)}_updateRotation(...t){this._rotationMode===1||this._isNearControls()?(this._rotationMode=1,super._updateRotation(...t)):(this.pivotMesh.visible=!1,this._rotationMode=-1),this._alignCameraUp(this.up)}_updateZoom(){const{zoomDelta:t,ellipsoid:e,zoomSpeed:i,zoomPoint:r,camera:o,maxZoom:n}=this,a=c.clamp(c.mapLinear(Math.abs(t),0,20,0,1),0,1);if(this._isNearControls()||t>0){if(this._updateZoomDirection(),t<0&&(this.zoomPointSet||this._updateZoomPoint())){p.set(0,0,-1).transformDirection(o.matrixWorld).normalize(),w.copy(this.up).multiplyScalar(-1),this.getUpDirection(r,G);const d=c.clamp(c.mapLinear(-G.dot(w),1,.95,0,1),0,1),m=1-p.dot(w),h=o.isOrthographicCamera?.05:1,g=c.clamp(a*3,0,1),_=Math.min(d*m*h*g,.1);w.lerpVectors(p,w,_).normalize(),l.setFromUnitVectors(p,w),P(r,l,x),o.matrixWorld.premultiply(x),o.matrixWorld.decompose(o.position,o.quaternion,w),this.zoomDirection.subVectors(r,o.position).normalize()}super._updateZoom()}else if(o.isPerspectiveCamera){const d=this._getPerspectiveTransitionDistance(),m=this._getMaxPerspectiveDistance(),h=c.mapLinear(this.getDistanceToCenter(),d,m,0,1);this._tiltTowardsCenter(c.lerp(0,.4,h*a)),this._alignCameraUpToNorth(c.lerp(0,.2,h*a));const g=this.getDistanceToCenter()-e.radius.x,_=t*g*i*.0025;this.getVectorToCenter(s).normalize(),this.camera.position.addScaledVector(s,_),this.camera.updateMatrixWorld(),this.zoomDelta=0}else{const d=this._getOrthographicTransitionZoom(),m=this._getMinOrthographicZoom(),h=c.mapLinear(o.zoom,d,m,0,1);this._tiltTowardsCenter(c.lerp(0,.4,h*a)),this._alignCameraUpToNorth(c.lerp(0,.2,h*a));const g=this.zoomDelta,_=Math.pow(.95,Math.abs(g*.05)),b=g>0?1/Math.abs(_):_;o.zoom=Math.max(this._getMinOrthographicZoom(),Math.min(n,o.zoom*b*i)),o.updateProjectionMatrix(),this.zoomDelta=0,this.zoomDirectionSet=!1}}_alignCameraUpToNorth(t){const{tilesGroup:e}=this;F.set(0,0,1).transformDirection(e.matrixWorld),this._alignCameraUp(F,t)}_alignCameraUp(t,e=null){const{camera:i}=this;p.set(0,0,-1).transformDirection(i.matrixWorld),W.set(-1,0,0).transformDirection(i.matrixWorld),U.crossVectors(t,p),e===null&&(e=1-Math.abs(p.dot(t)),e=c.mapLinear(e,0,1,-.01,1),e=c.clamp(e,0,1)**2),U.lerp(W,1-e).normalize(),l.setFromUnitVectors(W,U),i.quaternion.premultiply(l),i.updateMatrixWorld()}_tiltTowardsCenter(t){const{camera:e,tilesGroup:i}=this;p.set(0,0,-1).transformDirection(e.matrixWorld).normalize(),s.setFromMatrixPosition(i.matrixWorld).sub(e.position).normalize(),s.lerp(p,1-t).normalize(),l.setFromUnitVectors(p,s),e.quaternion.premultiply(l),e.updateMatrixWorld()}_getPerspectiveTransitionDistance(){const{camera:t,ellipsoid:e}=this;if(!t.isPerspectiveCamera)throw new Error;const i=Math.max(...e.radius),r=2*Math.atan(Math.tan(c.DEG2RAD*t.fov*.5)*t.aspect),o=i/Math.tan(c.DEG2RAD*t.fov*.5),n=i/Math.tan(r*.5);return Math.max(o,n)}_getMaxPerspectiveDistance(){const{camera:t,ellipsoid:e}=this;if(!t.isPerspectiveCamera)throw new Error;const i=Math.max(...e.radius),r=2*Math.atan(Math.tan(c.DEG2RAD*t.fov*.5)*t.aspect),o=i/Math.tan(c.DEG2RAD*t.fov*.5),n=i/Math.tan(r*.5);return 2*Math.max(o,n)}_getOrthographicTransitionZoom(){const{camera:t,ellipsoid:e}=this;if(!t.isOrthographicCamera)throw new Error;const i=t.top-t.bottom,r=t.right-t.left,o=Math.max(i,r),a=2*Math.max(...e.radius);return 2*o/a}_getMinOrthographicZoom(){const{camera:t,ellipsoid:e}=this;if(!t.isOrthographicCamera)throw new Error;const i=t.top-t.bottom,r=t.right-t.left,o=Math.min(i,r),a=2*Math.max(...e.radius);return .5*o/a}_getVirtualOrthoCameraPosition(t,e=this.camera){const{tilesGroup:i,ellipsoid:r}=this;if(!e.isOrthographicCamera)throw new Error;u.copy(i.matrixWorld).invert(),y.origin.copy(e.position),y.direction.set(0,0,-1).transformDirection(e.matrixWorld),y.applyMatrix4(u),T(y,r,C),C.applyMatrix4(i.matrixWorld);const o=e.top-e.bottom,n=e.right-e.left,a=Math.max(o,n)/e.zoom;p.set(0,0,-1).transformDirection(e.matrixWorld);const d=C.sub(e.position).dot(p);t.copy(e.position).addScaledVector(p,d-a*4)}_isNearControls(){const{camera:t}=this;return t.isPerspectiveCamera?this.getDistanceToCenter()this._getOrthographicTransitionZoom()}}const S=new E;class et{constructor(){this.tiles=null,this.needsUpdate=!1,this.cameraMatrices=new Map}init(t){this.tiles=t,this._needsUpdateCallback=()=>{this.needsUpdate=!0},this._onCameraAdd=({camera:e})=>{this.needsUpdate=!0,this.cameraMatrices.set(e,new E)},this._onCameraDelete=({camera:e})=>{this.needsUpdate=!0,this.cameraMatrices.delete(e)},t.addEventListener("camera-resolution-change",this._needsUpdateCallback),t.addEventListener("load-content",this._needsUpdateCallback),t.addEventListener("add-camera",this._onCameraAdd),t.addEventListener("delete-camera",this._onCameraDelete)}doTilesNeedUpdate(){const t=this.tiles;let e=!1;this.cameraMatrices.forEach((r,o)=>{S.copy(t.group.matrixWorld).premultiply(o.matrixWorldInverse).premultiply(o.projectionMatrixInverse),e=e||!S.equals(r),r.copy(S)});const i=this.needsUpdate;return this.needsUpdate=!1,i||e}dispose(){const t=this.tiles;t.removeEventListener("camera-resolution-change",this._needsUpdateCallback),t.removeEventListener("content-load",this._needsUpdateCallback),t.removeEventListener("camera-add",this._onCameraAdd),t.removeEventListener("camera-delete",this._onCameraDelete)}}export{tt as G,et as U}; diff --git a/example/bundle/assets/b3dmExample-Lr1Y1eRi.js b/example/bundle/assets/b3dmExample-Lr1Y1eRi.js new file mode 100644 index 000000000..146ff6203 --- /dev/null +++ b/example/bundle/assets/b3dmExample-Lr1Y1eRi.js @@ -0,0 +1,20 @@ +import{S as M,W as D,P as L,a as T,D as P,A as R,G as F,b as _,C as A,U as E,B as H,c as I,R as W,V as j}from"./three.module-C94OeYjd.js";import{O as G}from"./OrbitControls-bHRTZZ2i.js";import{B as z}from"./B3DMLoader-B0T2UZ_1.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./GLTFLoader-C77rxX9H.js";let s,m,c,t,f,r,b,a,d,u;$();C();function O(i){const e={...i};return e.uniforms={highlightedBatchId:{value:-1},highlightColor:{value:new A(16761095).convertSRGBToLinear()},...E.clone(i.uniforms)},e.extensions={derivatives:!0},e.lights=!0,e.vertexShader=` + attribute float _batchid; + varying float batchid; + `+e.vertexShader.replace(/#include /,` + #include + batchid = _batchid; + `),e.fragmentShader=` + varying float batchid; + uniform float highlightedBatchId; + uniform vec3 highlightColor; + `+e.fragmentShader.replace(/vec4 diffuseColor = vec4\( diffuse, opacity \);/,` + vec4 diffuseColor = + abs( batchid - highlightedBatchId ) < 0.5 ? + vec4( highlightColor, opacity ) : + vec4( diffuse, opacity ); + `),e}function $(){u=document.getElementById("info"),c=new M,t=new D({antialias:!0}),t.setPixelRatio(window.devicePixelRatio),t.setSize(window.innerWidth,window.innerHeight),t.setClearColor(1383455),t.shadowMap.enabled=!0,t.shadowMap.type=L,document.body.appendChild(t.domElement),s=new T(60,window.innerWidth/window.innerHeight,1,4e3),s.position.set(400,400,400),m=new G(s,t.domElement),m.screenSpacePanning=!1,m.minDistance=1,m.maxDistance=2e3,r=new P(16777215,1.25),r.position.set(1,2,3).multiplyScalar(40),r.castShadow=!0,r.shadow.bias=-.01,r.shadow.mapSize.setScalar(2048);const i=r.shadow.camera;i.left=-200,i.bottom=-200,i.right=200,i.top=200,i.updateProjectionMatrix(),c.add(r);const e=new R(16777215,.05);c.add(e),f=new F,c.add(f),new z().loadAsync("https://raw.githubusercontent.com/CesiumGS/cesium/main/Apps/SampleData/Cesium3DTiles/Hierarchy/BatchTableHierarchy/tile.b3dm").then(h=>{console.log(h),d=h.scene,f.add(d);const n=new H;n.setFromObject(d),n.getCenter(f.position).multiplyScalar(-1),d.traverse(o=>{o.isMesh&&(o.material=new _(O(I.standard)))})}),b=new W,a=new j,y(),window.addEventListener("resize",y,!1),t.domElement.addEventListener("mousemove",U,!1)}function U(i){const e=this.getBoundingClientRect();a.x=i.clientX-e.x,a.y=i.clientY-e.y,a.x=a.x/e.width*2-1,a.y=-(a.y/e.height)*2+1,b.setFromCamera(a,s);const h=b.intersectObject(c,!0);let n=-1;if(h.length){const{face:o,object:p}=h[0],v=p.geometry.getAttribute("_batchid");if(v){let l=p;for(;!l.batchTable;)l=l.parent;const B=l.batchTable;n=v.getX(o.a);const w=B.getDataFromId(n);u.innerText=`_batchid : ${n} +Area : ${w.height.toFixed(3)} +Height : ${w.height.toFixed(3)} +`;const g=w["3DTILES_batch_table_hierarchy"];for(const x in g)for(const S in g[x])u.innerText+=`${S} : ${g[x][S]} +`}}else u.innerText="";d&&d.traverse(o=>{o.isMesh&&(o.material.uniforms.highlightedBatchId.value=n)})}function y(){s.aspect=window.innerWidth/window.innerHeight,t.setPixelRatio(window.devicePixelRatio),t.setSize(window.innerWidth,window.innerHeight),s.updateProjectionMatrix()}function C(){requestAnimationFrame(C),V()}function V(){t.render(c,s)} diff --git a/example/bundle/assets/cmptExample-wgaV4NtR.js b/example/bundle/assets/cmptExample-wgaV4NtR.js new file mode 100644 index 000000000..f98ccff25 --- /dev/null +++ b/example/bundle/assets/cmptExample-wgaV4NtR.js @@ -0,0 +1 @@ +import{S as m,W as c,P as l,a as p,D as f,A as h}from"./three.module-C94OeYjd.js";import{O as u}from"./OrbitControls-bHRTZZ2i.js";import{C as g}from"./CMPTLoader-CXF13c0w.js";import"./LoaderBase-CVSPpjX2.js";import"./readMagicBytes-Da5ueiou.js";import"./B3DMLoader-B0T2UZ_1.js";import"./GLTFLoader-C77rxX9H.js";import"./PNTSLoader-BUgecSBY.js";import"./I3DMLoader-C4TPl3Dp.js";let n,o,a,e,i;P();d();function P(){a=new m,e=new c({antialias:!0}),e.setPixelRatio(window.devicePixelRatio),e.setSize(window.innerWidth,window.innerHeight),e.setClearColor(1383455),e.shadowMap.enabled=!0,e.shadowMap.type=l,document.body.appendChild(e.domElement),n=new p(60,window.innerWidth/window.innerHeight,1,4e3),n.position.set(400,400,400),o=new u(n,e.domElement),o.screenSpacePanning=!1,o.minDistance=1,o.maxDistance=2e3,i=new f(16777215,1.25),i.position.set(1,2,3).multiplyScalar(40),i.castShadow=!0,i.shadow.bias=-.01,i.shadow.mapSize.setScalar(2048);const t=i.shadow.camera;t.left=-200,t.bottom=-200,t.right=200,t.top=200,t.updateProjectionMatrix(),a.add(i);const s=new h(16777215,.05);a.add(s),new g().loadAsync("...").then(w=>{console.log(w)}),r(),window.addEventListener("resize",r,!1)}function r(){n.aspect=window.innerWidth/window.innerHeight,e.setPixelRatio(window.devicePixelRatio),e.setSize(window.innerWidth,window.innerHeight),n.updateProjectionMatrix()}function d(){requestAnimationFrame(d),S()}function S(){e.render(a,n)} diff --git a/example/bundle/assets/customMaterial-CImIqP10.js b/example/bundle/assets/customMaterial-CImIqP10.js new file mode 100644 index 000000000..d60460798 --- /dev/null +++ b/example/bundle/assets/customMaterial-CImIqP10.js @@ -0,0 +1,70 @@ +import{S as k,W as F,P as L,a as R,O as z,D as E,A as T,G as W,M as I,b as v,B as V,d as G}from"./three.module-C94OeYjd.js";import{O as H}from"./OrbitControls-bHRTZZ2i.js";import{g as A}from"./lil-gui.module.min-NsHmRZWc.js";import{S as D}from"./stats.module--VATS4Kh.js";import{T as N}from"./TilesRenderer-DQOLA18N.js";import"./B3DMLoader-B0T2UZ_1.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./GLTFLoader-C77rxX9H.js";import"./PNTSLoader-BUgecSBY.js";import"./I3DMLoader-C4TPl3Dp.js";import"./CMPTLoader-CXF13c0w.js";import"./GLTFExtensionLoader-Qt9Ghhze.js";let n,c,p,o,t,a,m,h,f,d,s,w;const g=0,x=1,y=2,S=3,l={material:g,orthographic:!1,rebuild:M},O={vertexShader:` + varying vec3 wPosition; + void main() { + + #include + #include + wPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz; + + } + `,fragmentShader:` + varying vec3 wPosition; + void main() { + + float minVal = - 30.0; + float maxVal = 30.0; + + float val = ( wPosition.y - minVal ) / ( maxVal - minVal ); + + vec4 color1 = vec4( 0.149, 0.196, 0.219, 1.0 ) * 0.5; + vec4 color2 = vec4( 1.0 ); + + gl_FragColor = mix( color1, color2, val ); + + } + `},_={extensions:{derivatives:!0},vertexShader:` + varying vec3 wPosition; + varying vec3 vViewPosition; + void main() { + + #include + #include + wPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz; + vViewPosition = - mvPosition.xyz; + + } + `,fragmentShader:` + varying vec3 wPosition; + varying vec3 vViewPosition; + void main() { + + // lighting + vec3 fdx = vec3( dFdx( wPosition.x ), dFdx( wPosition.y ), dFdx( wPosition.z ) ); + vec3 fdy = vec3( dFdy( wPosition.x ), dFdy( wPosition.y ), dFdy( wPosition.z ) ); + vec3 worldNormal = normalize( cross( fdx, fdy ) ); + + float lighting = + 0.4 + + clamp( dot( worldNormal, vec3( 1.0, 1.0, 1.0 ) ), 0.0, 1.0 ) * 0.5 + + clamp( dot( worldNormal, vec3( - 1.0, 1.0, - 1.0 ) ), 0.0, 1.0 ) * 0.3; + + // thickness scale + float upwardness = dot( worldNormal, vec3( 0.0, 1.0, 0.0 ) ); + float yInv = clamp( 1.0 - abs( upwardness ), 0.0, 1.0 ); + float thicknessScale = pow( yInv, 0.4 ); + thicknessScale *= 0.25 + 0.5 * ( vViewPosition.z + 1.0 ) / 2.0; + + // thickness + float thickness = 0.01 * thicknessScale; + float thickness2 = thickness / 2.0; + float m = mod( wPosition.y, 3.0 ); + + // soften edge + float center = thickness2; + float dist = clamp( abs( m - thickness2 ) / thickness2, 0.0, 1.0 ); + + vec4 topoColor = vec4( 0.149, 0.196, 0.219, 1.0 ) * 0.5; + gl_FragColor = mix( topoColor * lighting, vec4( lighting ), dist ); + + } + `};$();b();function P(i){const r=parseFloat(l.material);i.traverse(e=>{if(e.isMesh)switch(e.material.dispose(),r){case g:e.material=e.originalMaterial,e.material.side=2,e.receiveShadow=!1,e.castShadow=!1;break;case x:e.material=new v(O),e.material.side=2,e.receiveShadow=!1,e.castShadow=!1;break;case y:e.material=new v(_),e.material.side=2,e.material.flatShading=!0,e.receiveShadow=!1,e.castShadow=!1;break;case S:e.material=new I,e.material.side=2,e.receiveShadow=!0,e.castShadow=!0}})}function j({scene:i}){i.traverse(r=>{r.isMesh&&(r.originalMaterial=r.material)}),P(i)}function B({scene:i}){i.traverse(r=>{r.isMesh&&r.material.dispose()})}function M(){t&&(t.group.parent.remove(t.group),t.dispose());const i=window.location.hash.replace(/^#/,"")||"../data/tileset.json";t=new N(i),t.errorTarget=2,t.addEventListener("load-model",j),t.addEventListener("dispose-model",B),m.add(t.group)}function $(){p=new k,o=new F({antialias:!0}),o.setPixelRatio(window.devicePixelRatio),o.setSize(window.innerWidth,window.innerHeight),o.setClearColor(1383455),o.shadowMap.enabled=!0,o.shadowMap.type=L,document.body.appendChild(o.domElement),n=new R(60,window.innerWidth/window.innerHeight,1,4e3),n.position.set(400,400,400),a=new z,c=new H(n,o.domElement),c.screenSpacePanning=!1,c.minDistance=1,c.maxDistance=2e3,d=new E(16777215,1.25),d.position.set(1,2,3).multiplyScalar(40),d.castShadow=!0,d.shadow.bias=-.01,d.shadow.mapSize.setScalar(2048);const i=d.shadow.camera;i.left=-200,i.bottom=-200,i.right=200,i.top=200,i.updateProjectionMatrix(),p.add(d);const r=new T(16777215,.05);p.add(r),h=new V,f=new G,m=new W,p.add(m),M(),u(),window.addEventListener("resize",u,!1);const e=new A;e.width=300,e.add(l,"orthographic"),e.add(l,"material",{DEFAULT:g,GRADIENT:x,TOPOGRAPHIC_LINES:y,LIGHTING:S}).onChange(()=>{t.forEachLoadedModel(P)}),e.add(l,"rebuild"),e.open(),w=new D,w.showPanel(0),document.body.appendChild(w.dom),s=document.createElement("div"),s.style.position="absolute",s.style.top=0,s.style.left=0,s.style.color="white",s.style.width="100%",s.style.textAlign="center",s.style.padding="5px",s.style.pointerEvents="none",s.style.lineHeight="1.5em",document.body.appendChild(s)}function u(){n.aspect=window.innerWidth/window.innerHeight,o.setPixelRatio(window.devicePixelRatio),o.setSize(window.innerWidth,window.innerHeight),n.updateProjectionMatrix(),C()}function C(){a.position.copy(n.position),a.rotation.copy(n.rotation);const i=n.position.distanceTo(c.target)/2,r=window.innerWidth/window.innerHeight;a.left=-r*i,a.right=r*i,a.bottom=-i,a.top=i,a.near=n.near,a.far=n.far,a.updateProjectionMatrix()}function b(){requestAnimationFrame(b),l.orthographic?(t.deleteCamera(n),t.setCamera(a),t.setResolutionFromRenderer(a,o)):(t.deleteCamera(a),t.setCamera(n),t.setResolutionFromRenderer(n,o)),m.rotation.set(0,0,0),l.up==="-Z"&&(m.rotation.x=Math.PI/2),m.updateMatrixWorld(!0),t.getBoundingBox(h)?(h.getCenter(t.group.position),t.group.position.multiplyScalar(-1)):t.getBoundingSphere(f)&&(t.group.position.copy(f.center),t.group.position.multiplyScalar(-1)),window.tiles=t,n.updateMatrixWorld(),a.updateMatrixWorld(),t.update(),q(),w.update()}function q(){C(),s.innerText=`Geometries: ${o.info.memory.geometries} Textures: ${o.info.memory.textures} Programs: ${o.info.programs.length} `,o.render(p,l.orthographic?a:n)} diff --git a/example/bundle/assets/ellipsoid-Bg7ZWI-T.js b/example/bundle/assets/ellipsoid-Bg7ZWI-T.js new file mode 100644 index 000000000..73baf705d --- /dev/null +++ b/example/bundle/assets/ellipsoid-Bg7ZWI-T.js @@ -0,0 +1 @@ +import{S as C,W as M,a as E,G as x,e as S,d as v,f as B,B as I,D as L,A as W,g as G,h as z}from"./three.module-C94OeYjd.js";import{O as F}from"./OrbitControls-bHRTZZ2i.js";import{g as O}from"./lil-gui.module.min-NsHmRZWc.js";import{E as y,a as A,S as D}from"./EllipsoidRegionHelper-7avvRq-k.js";let l,w,p,o,r,P,c,u,e,g,f,a;const t=[];let m;const s={displaySphereHelper:!1,displayBoxHelper:!1,displayPoints:!1};q();b();function q(){p=new C,o=new M({antialias:!0}),o.setPixelRatio(window.devicePixelRatio),o.setSize(window.innerWidth,window.innerHeight),o.setClearColor(1383455),o.shadowMap.enabled=!0,document.body.appendChild(o.domElement),l=new E(60,window.innerWidth/window.innerHeight,.1,100),l.position.set(3,1.5,1),r=new x,r.rotation.x=-Math.PI/2,p.add(r),m=new x,r.add(m),e=new y,e.material=new S({polygonOffset:!0,polygonOffsetFactor:1,polygonOffsetUnits:1}),e.ellipsoidRegion.radius.z=.95,e.ellipsoidRegion.heightStart=-.05,e.ellipsoidRegion.heightEnd=.05,e.ellipsoidRegion.latStart=0,e.ellipsoidRegion.latEnd=Math.PI/4,e.ellipsoidRegion.lonStart=0,e.ellipsoidRegion.lonEnd=Math.PI/4,g=new y,g.material=new S({opacity:.1,transparent:!0,depthWrite:!1}),f=new A(e.ellipsoidRegion),f.material.color.set(1383455).convertSRGBToLinear(),c=new D(new v),a=new x,u=new B(new I),a.add(u),r.add(e,g,f,c,a),n(),w=new F(l,o.domElement),w.screenSpacePanning=!1,w.minDistance=1,w.maxDistance=2e3,P=new L(16777215,1.25),P.position.set(1,2,3).multiplyScalar(40),p.add(P);const h=new W(16777215,.15);p.add(h);const i=new O;i.add(s,"displayBoxHelper"),i.add(s,"displaySphereHelper"),i.add(s,"displayPoints");const R=i.addFolder("radius");R.add(e.ellipsoidRegion.radius,"x",.1,2).onChange(n),R.add(e.ellipsoidRegion.radius,"y",.1,2).onChange(n),R.add(e.ellipsoidRegion.radius,"z",.1,2).onChange(n);const d=i.addFolder("region");d.add(e.ellipsoidRegion,"latStart",-Math.PI/2,Math.PI/2).onChange(n),d.add(e.ellipsoidRegion,"latEnd",-Math.PI/2,Math.PI/2).onChange(n),d.add(e.ellipsoidRegion,"lonStart",0,2*Math.PI).onChange(n),d.add(e.ellipsoidRegion,"lonEnd",0,2*Math.PI).onChange(n),d.add(e.ellipsoidRegion,"heightStart",-.25,.25).onChange(n),d.add(e.ellipsoidRegion,"heightEnd",-.25,.25).onChange(n),H(),window.addEventListener("resize",H,!1)}function n(){g.ellipsoidRegion.radius.copy(e.ellipsoidRegion.radius),e.update(),g.update(),f.update(),e.ellipsoidRegion.getBoundingSphere(c.sphere),e.ellipsoidRegion.getBoundingBox(u.box,a.matrix),a.matrix.decompose(a.position,a.quaternion,a.scale);const h=e.ellipsoidRegion._getPoints();t.forEach(i=>i.visible=!1);for(let i=0;i{r.deleteCamera(u),e.deleteCamera(u),r.setCamera(l),e.setCamera(l),d.setCamera(l)}),d=new x(m,a.camera,s.domElement),d.minZoomDistance=2,d.cameraRadius=1,c=new D,c.rotation.set(Math.PI/2,0,0),m.add(c),f(),w(),window.addEventListener("resize",w,!1);const o=new S,n=o.addFolder("camera");n.add(t,"orthographic").onChange(l=>{a.fixedPoint.copy(d.pivotPoint),a.toggle()}),n.add(t,"transitionDuration",0,1.5);const i=o.addFolder("fade");i.add(t,"useFade"),i.add(t,"fadeRootTiles"),i.add(t,"errorTarget",0,1e3),i.add(t,"fadeDuration",0,5),i.add(t,"renderScale",.1,1,.05).onChange(l=>s.setPixelRatio(l*window.devicePixelRatio));const _=i.add(t,"fadingGroundTiles").listen().disable();_.domElement.style.opacity=1,o.add(t,"reinstantiateTiles"),o.open()}function f(){e&&(e.dispose(),r.dispose()),e=new g("https://raw.githubusercontent.com/NASA-AMMOS/3DTilesSampleData/master/msl-dingo-gap/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_colorize_tileset.json"),e.fetchOptions.mode="cors",e.lruCache.minSize=900,e.lruCache.maxSize=1300,e.errorTarget=12,e.registerPlugin(new p),e.setCamera(a.camera),r=new g("https://raw.githubusercontent.com/NASA-AMMOS/3DTilesSampleData/master/msl-dingo-gap/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_sky/0528_0260184_to_s64o256_sky_tileset.json"),r.fetchOptions.mode="cors",r.lruCache=e.lruCache,r.registerPlugin(new p),r.setCamera(a.camera),c.add(e.group,r.group)}function w(){const{perspectiveCamera:o,orthographicCamera:n}=a,i=window.innerWidth/window.innerHeight;n.bottom=-40,n.top=40,n.left=-40*i,n.right=40*i,n.updateProjectionMatrix(),o.aspect=i,o.updateProjectionMatrix(),s.setSize(window.innerWidth,window.innerHeight)}function h(){requestAnimationFrame(h),d.enabled=!a.animating,d.update(),a.duration=1e3*t.transitionDuration,a.update();const o=a.camera;o.updateMatrixWorld();const n=e.getPluginByName("FADE_TILES_PLUGIN");n.fadeRootTiles=t.fadeRootTiles,n.fadeDuration=t.useFade?t.fadeDuration*1e3:0,e.errorTarget=t.errorTarget,e.setCamera(o),e.setResolutionFromRenderer(o,s),e.update();const i=r.getPluginByName("FADE_TILES_PLUGIN");i.fadeRootTiles=t.fadeRootTiles,i.fadeDuration=t.useFade?t.fadeDuration*1e3:0,r.setCamera(o),r.setResolutionFromRenderer(o,s),r.update(),s.render(m,o),t.fadingGroundTiles=n.fadingTiles+" tiles"} diff --git a/example/bundle/assets/gltf-DH4GV6NL.js b/example/bundle/assets/gltf-DH4GV6NL.js new file mode 100644 index 000000000..43b18a32b --- /dev/null +++ b/example/bundle/assets/gltf-DH4GV6NL.js @@ -0,0 +1 @@ +import{S as k,W as M,P as L,a as b,D as C,A as F,L as P}from"./three.module-C94OeYjd.js";import{O as S}from"./OrbitControls-bHRTZZ2i.js";import{D as x}from"./DRACOLoader-CQ2RnL8Q.js";import{G}from"./GLTFLoader-C77rxX9H.js";import{G as g}from"./GLTFExtensionLoader-Qt9Ghhze.js";import"./LoaderBase-CVSPpjX2.js";let s,t,r,e,i;R();h();function R(){r=new k,e=new M({antialias:!0}),e.setPixelRatio(window.devicePixelRatio),e.setSize(window.innerWidth,window.innerHeight),e.setClearColor(1383455),e.shadowMap.enabled=!0,e.shadowMap.type=L,document.body.appendChild(e.domElement),s=new b(60,window.innerWidth/window.innerHeight,1,4e3),s.position.set(3,10,20),t=new S(s,e.domElement),t.screenSpacePanning=!1,t.minDistance=1,t.maxDistance=2e3,i=new C(16777215,1.25),i.position.set(1,2,3).multiplyScalar(40),i.castShadow=!0,i.shadow.bias=-.01,i.shadow.mapSize.setScalar(2048);const d=i.shadow.camera;d.left=-200,d.bottom=-200,d.right=200,d.top=200,d.updateProjectionMatrix(),r.add(i);const p=new F(16777215,.05);r.add(p);let c=0;const f=["https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/CesiumMilkTruck/glTF-Binary/CesiumMilkTruck.glb","https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/CesiumMilkTruck/glTF-Embedded/CesiumMilkTruck.gltf","https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/CesiumMilkTruck/glTF/CesiumMilkTruck.gltf"];for(const o of f){const n=new g;n.workingPath=n.workingPathForURL(o),n.loadAsync(o).then(a=>{a.scene.position.set(c+=5,0,0),t.target.set(c/2,0,0),t.update(),console.log("default loader:",{gltf:a,url:o}),r.add(a.scene)})}const T=["https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/CesiumMilkTruck/glTF-Draco/CesiumMilkTruck.gltf","https://raw.githubusercontent.com/KhronosGroup/glTF-Sample-Models/master/2.0/Box/glTF-Binary/Box.glb"],l=new P,m=new G(l),w=new x(l);w.setDecoderPath("https://unpkg.com/three@0.153.0/examples/jsm/libs/draco/gltf/"),m.setDRACOLoader(w),l.addHandler(/\.gltf$/,m),l.addHandler(/\.glb$/,m);for(const o of T){const n=new g(l);n.workingPath=n.workingPathForURL(o),n.loadAsync(o).then(a=>{a.scene.position.set(c+=5,0,0),t.target.set(c/2,0,0),t.update(),console.log("custom loader:",{gltf:a,url:o}),r.add(a.scene)})}u(),window.addEventListener("resize",u,!1)}function u(){s.aspect=window.innerWidth/window.innerHeight,e.setPixelRatio(window.devicePixelRatio),e.setSize(window.innerWidth,window.innerHeight),s.updateProjectionMatrix()}function h(){requestAnimationFrame(h),D()}function D(){e.render(r,s)} diff --git a/example/bundle/assets/googleMapsAerial-D8mOXWrx.js b/example/bundle/assets/googleMapsAerial-D8mOXWrx.js new file mode 100644 index 000000000..6927722a0 --- /dev/null +++ b/example/bundle/assets/googleMapsAerial-D8mOXWrx.js @@ -0,0 +1,2 @@ +import{i as Be,j as Qe,E as $e,k as u,l as k,T as Y,Q as Ae,m as Me,V as f,n as U,S as Je,W as et,a as tt,R as nt}from"./three.module-C94OeYjd.js";import{G as ot}from"./GLTFLoader-C77rxX9H.js";import{D as at}from"./DRACOLoader-CQ2RnL8Q.js";import{g as it,t as st}from"./lil-gui.module.min-NsHmRZWc.js";import{T as rt}from"./TileCompressionPlugin-DurGWH0s.js";import{T as lt}from"./TilesFadePlugin-BuMLsouQ.js";import{G as ct}from"./GoogleTilesRenderer-CVSgZtW5.js";import{G as mt}from"./GoogleCloudAuthPlugin-CXITux-L.js";import{W as pt}from"./TilesRenderer-DQOLA18N.js";import"./B3DMLoader-B0T2UZ_1.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./PNTSLoader-BUgecSBY.js";import"./I3DMLoader-C4TPl3Dp.js";import"./CMPTLoader-CXF13c0w.js";import"./GLTFExtensionLoader-Qt9Ghhze.js";const De={type:"change"},ae={type:"start"},Le={type:"end"},B=new Be,Re=new Qe,ut=Math.cos(70*U.DEG2RAD);class dt extends $e{constructor(m,O){super();const e=this;this.panPlane=new u(0,1,0),this.object=m,this.domElement=O,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new u,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:k.ROTATE,MIDDLE:k.DOLLY,RIGHT:k.PAN},this.touches={ONE:Y.ROTATE,TWO:Y.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return r.phi},this.getAzimuthalAngle=function(){return r.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(t){t.addEventListener("keydown",ne),this._domElementKeyEvents=t},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",ne),this._domElementKeyEvents=null},this.saveState=function(){e.target0.copy(e.target),e.position0.copy(e.object.position),e.zoom0=e.object.zoom},this.reset=function(){e.target.copy(e.target0),e.object.position.copy(e.position0),e.object.zoom=e.zoom0,e.object.updateProjectionMatrix(),e.dispatchEvent(De),e.update(),i=o.NONE},this.update=function(){const t=new u,n=new Ae().setFromUnitVectors(e.panPlane,new u(0,1,0)),l=n.clone().invert(),c=new u,p=new Ae,X=new u,T=2*Math.PI;return function(){const Oe=e.object.position;t.copy(Oe).sub(e.target),t.applyQuaternion(n),r.setFromVector3(t),e.autoRotate&&i===o.NONE&&H(Ce()),e.enableDamping?(r.theta+=b.theta*e.dampingFactor,r.phi+=b.phi*e.dampingFactor):(r.theta+=b.theta,r.phi+=b.phi);let y=e.minAzimuthAngle,E=e.maxAzimuthAngle;isFinite(y)&&isFinite(E)&&(y<-Math.PI?y+=T:y>Math.PI&&(y-=T),E<-Math.PI?E+=T:E>Math.PI&&(E-=T),y<=E?r.theta=Math.max(y,Math.min(E,r.theta)):r.theta=r.theta>(y+E)/2?Math.max(y,r.theta):Math.min(E,r.theta)),r.phi=Math.max(e.minPolarAngle,Math.min(e.maxPolarAngle,r.phi)),r.makeSafe(),e.enableDamping===!0?e.target.addScaledVector(x,e.dampingFactor):e.target.add(x),e.zoomToCursor&&W||e.object.isOrthographicCamera?r.radius=ee(r.radius):r.radius=ee(r.radius*A),t.setFromSpherical(r),t.applyQuaternion(l),Oe.copy(e.target).add(t),e.object.lookAt(e.target),e.enableDamping===!0?(b.theta*=1-e.dampingFactor,b.phi*=1-e.dampingFactor,x.multiplyScalar(1-e.dampingFactor)):(b.set(0,0,0),x.set(0,0,0));let V=!1;if(e.zoomToCursor&&W){let z=null;if(e.object.isPerspectiveCamera){const F=t.length();z=ee(F*A);const q=F-z;e.object.position.addScaledVector(se,q),e.object.updateMatrixWorld()}else if(e.object.isOrthographicCamera){const F=new u(w.x,w.y,0);F.unproject(e.object),e.object.zoom=Math.max(e.minZoom,Math.min(e.maxZoom,e.object.zoom/A)),e.object.updateProjectionMatrix(),V=!0;const q=new u(w.x,w.y,0);q.unproject(e.object),e.object.position.sub(q).add(F),e.object.updateMatrixWorld(),z=t.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),e.zoomToCursor=!1;z!==null&&(this.screenSpacePanning?e.target.set(0,0,-1).transformDirection(e.object.matrix).multiplyScalar(z).add(e.object.position):(B.origin.copy(e.object.position),B.direction.set(0,0,-1).transformDirection(e.object.matrix),Math.abs(e.panPlane.dot(B.direction))ie||8*(1-p.dot(e.object.quaternion))>ie||X.distanceToSquared(e.target)>0?(e.dispatchEvent(De),c.copy(e.object.position),p.copy(e.object.quaternion),X.copy(e.target),V=!1,!0):!1}}(),this.dispose=function(){e.domElement.removeEventListener("contextmenu",we),e.domElement.removeEventListener("pointerdown",Ee),e.domElement.removeEventListener("pointercancel",_),e.domElement.removeEventListener("wheel",Pe),e.domElement.removeEventListener("pointermove",te),e.domElement.removeEventListener("pointerup",_),e._domElementKeyEvents!==null&&(e._domElementKeyEvents.removeEventListener("keydown",ne),e._domElementKeyEvents=null)};const o={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let i=o.NONE;const ie=1e-6,r=new Me,b=new Me;let A=1;const x=new u,M=new f,D=new f,S=new f,L=new f,R=new f,j=new f,N=new f,C=new f,K=new f,se=new u,w=new f;let W=!1;const a=[],Z={};function Ce(){return 2*Math.PI/60/60*e.autoRotateSpeed}function v(){return Math.pow(.95,e.zoomSpeed)}function H(t){b.theta-=t}function G(t){b.phi-=t}const re=function(){const t=new u;return function(l,c){t.setFromMatrixColumn(c,0),t.multiplyScalar(-l),x.add(t)}}(),le=function(){const t=new u;return function(l,c){e.screenSpacePanning===!0?t.setFromMatrixColumn(c,1):(t.setFromMatrixColumn(c,0),t.crossVectors(e.panPlane,t)),t.multiplyScalar(l),x.add(t)}}(),I=function(){const t=new u;return function(l,c){const p=e.domElement;if(e.object.isPerspectiveCamera){const X=e.object.position;t.copy(X).sub(e.target);let T=t.length();T*=Math.tan(e.object.fov/2*Math.PI/180),re(2*l*T/p.clientHeight,e.object.matrix),le(2*c*T/p.clientHeight,e.object.matrix)}else e.object.isOrthographicCamera?(re(l*(e.object.right-e.object.left)/e.object.zoom/p.clientWidth,e.object.matrix),le(c*(e.object.top-e.object.bottom)/e.object.zoom/p.clientHeight,e.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),e.enablePan=!1)}}();function J(t){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?A/=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function ce(t){e.object.isPerspectiveCamera||e.object.isOrthographicCamera?A*=t:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),e.enableZoom=!1)}function me(t){if(!e.zoomToCursor)return;W=!0;const n=t.clientX-e.domElement.clientLeft,l=t.clientY-e.domElement.clientTop,c=e.domElement.clientWidth,p=e.domElement.clientHeight;w.x=n/c*2-1,w.y=-(l/p)*2+1,se.set(w.x,w.y,1).unproject(m).sub(m.position).normalize()}function ee(t){return Math.max(e.minDistance,Math.min(e.maxDistance,t))}function pe(t){M.set(t.clientX,t.clientY)}function Ie(t){me(t),N.set(t.clientX,t.clientY)}function ue(t){L.set(t.clientX,t.clientY)}function ke(t){D.set(t.clientX,t.clientY),S.subVectors(D,M).multiplyScalar(e.rotateSpeed);const n=e.domElement;H(2*Math.PI*S.x/n.clientHeight),G(2*Math.PI*S.y/n.clientHeight),M.copy(D),e.update()}function Ye(t){C.set(t.clientX,t.clientY),K.subVectors(C,N),K.y>0?J(v()):K.y<0&&ce(v()),N.copy(C),e.update()}function Ke(t){R.set(t.clientX,t.clientY),j.subVectors(R,L).multiplyScalar(e.panSpeed),I(j.x,j.y),L.copy(R),e.update()}function He(t){me(t),t.deltaY<0?ce(v()):t.deltaY>0&&J(v()),e.update()}function _e(t){let n=!1;switch(t.code){case e.keys.UP:t.ctrlKey||t.metaKey||t.shiftKey?G(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):I(0,e.keyPanSpeed),n=!0;break;case e.keys.BOTTOM:t.ctrlKey||t.metaKey||t.shiftKey?G(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):I(0,-e.keyPanSpeed),n=!0;break;case e.keys.LEFT:t.ctrlKey||t.metaKey||t.shiftKey?H(2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):I(e.keyPanSpeed,0),n=!0;break;case e.keys.RIGHT:t.ctrlKey||t.metaKey||t.shiftKey?H(-2*Math.PI*e.rotateSpeed/e.domElement.clientHeight):I(-e.keyPanSpeed,0),n=!0;break}n&&(t.preventDefault(),e.update())}function de(){if(a.length===1)M.set(a[0].pageX,a[0].pageY);else{const t=.5*(a[0].pageX+a[1].pageX),n=.5*(a[0].pageY+a[1].pageY);M.set(t,n)}}function he(){if(a.length===1)L.set(a[0].pageX,a[0].pageY);else{const t=.5*(a[0].pageX+a[1].pageX),n=.5*(a[0].pageY+a[1].pageY);L.set(t,n)}}function fe(){const t=a[0].pageX-a[1].pageX,n=a[0].pageY-a[1].pageY,l=Math.sqrt(t*t+n*n);N.set(0,l)}function ze(){e.enableZoom&&fe(),e.enablePan&&he()}function Fe(){e.enableZoom&&fe(),e.enableRotate&&de()}function ge(t){if(a.length==1)D.set(t.pageX,t.pageY);else{const l=oe(t),c=.5*(t.pageX+l.x),p=.5*(t.pageY+l.y);D.set(c,p)}S.subVectors(D,M).multiplyScalar(e.rotateSpeed);const n=e.domElement;H(2*Math.PI*S.x/n.clientHeight),G(2*Math.PI*S.y/n.clientHeight),M.copy(D)}function be(t){if(a.length===1)R.set(t.pageX,t.pageY);else{const n=oe(t),l=.5*(t.pageX+n.x),c=.5*(t.pageY+n.y);R.set(l,c)}j.subVectors(R,L).multiplyScalar(e.panSpeed),I(j.x,j.y),L.copy(R)}function ye(t){const n=oe(t),l=t.pageX-n.x,c=t.pageY-n.y,p=Math.sqrt(l*l+c*c);C.set(0,p),K.set(0,Math.pow(C.y/N.y,e.zoomSpeed)),J(K.y),N.copy(C)}function Ue(t){e.enableZoom&&ye(t),e.enablePan&&be(t)}function We(t){e.enableZoom&&ye(t),e.enableRotate&&ge(t)}function Ee(t){e.enabled!==!1&&(a.length===0&&(e.domElement.setPointerCapture(t.pointerId),e.domElement.addEventListener("pointermove",te),e.domElement.addEventListener("pointerup",_)),Ve(t),t.pointerType==="touch"?Ge(t):Ze(t))}function te(t){e.enabled!==!1&&(t.pointerType==="touch"?Xe(t):ve(t))}function _(t){qe(t),a.length===0&&(e.domElement.releasePointerCapture(t.pointerId),e.domElement.removeEventListener("pointermove",te),e.domElement.removeEventListener("pointerup",_)),e.dispatchEvent(Le),i=o.NONE}function Ze(t){let n;switch(t.button){case 0:n=e.mouseButtons.LEFT;break;case 1:n=e.mouseButtons.MIDDLE;break;case 2:n=e.mouseButtons.RIGHT;break;default:n=-1}switch(n){case k.DOLLY:if(e.enableZoom===!1)return;Ie(t),i=o.DOLLY;break;case k.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(e.enablePan===!1)return;ue(t),i=o.PAN}else{if(e.enableRotate===!1)return;pe(t),i=o.ROTATE}break;case k.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(e.enableRotate===!1)return;pe(t),i=o.ROTATE}else{if(e.enablePan===!1)return;ue(t),i=o.PAN}break;default:i=o.NONE}i!==o.NONE&&e.dispatchEvent(ae)}function ve(t){switch(i){case o.ROTATE:if(e.enableRotate===!1)return;ke(t);break;case o.DOLLY:if(e.enableZoom===!1)return;Ye(t);break;case o.PAN:if(e.enablePan===!1)return;Ke(t);break}}function Pe(t){e.enabled===!1||e.enableZoom===!1||i!==o.NONE||(t.preventDefault(),e.dispatchEvent(ae),He(t),e.dispatchEvent(Le))}function ne(t){e.enabled===!1||e.enablePan===!1||_e(t)}function Ge(t){switch(Te(t),a.length){case 1:switch(e.touches.ONE){case Y.ROTATE:if(e.enableRotate===!1)return;de(),i=o.TOUCH_ROTATE;break;case Y.PAN:if(e.enablePan===!1)return;he(),i=o.TOUCH_PAN;break;default:i=o.NONE}break;case 2:switch(e.touches.TWO){case Y.DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;ze(),i=o.TOUCH_DOLLY_PAN;break;case Y.DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;Fe(),i=o.TOUCH_DOLLY_ROTATE;break;default:i=o.NONE}break;default:i=o.NONE}i!==o.NONE&&e.dispatchEvent(ae)}function Xe(t){switch(Te(t),i){case o.TOUCH_ROTATE:if(e.enableRotate===!1)return;ge(t),e.update();break;case o.TOUCH_PAN:if(e.enablePan===!1)return;be(t),e.update();break;case o.TOUCH_DOLLY_PAN:if(e.enableZoom===!1&&e.enablePan===!1)return;Ue(t),e.update();break;case o.TOUCH_DOLLY_ROTATE:if(e.enableZoom===!1&&e.enableRotate===!1)return;We(t),e.update();break;default:i=o.NONE}}function we(t){e.enabled!==!1&&t.preventDefault()}function Ve(t){a.push(t)}function qe(t){delete Z[t.pointerId];for(let n=0;nparseFloat(o));if(m.length!==2||m.findIndex(o=>Number.isNaN(o))!==-1)return;const[O,e]=m;s.setLatLonToYUp(O*U.DEG2RAD,e*U.DEG2RAD)}function Ne(){requestAnimationFrame(Ne),s&&(g.update(),s.setResolutionFromRenderer(d,P),s.setCamera(d),d.updateMatrixWorld(),s.update(),bt())}function bt(){if(P.render(Q,d),s){const h=s.group.matrixWorld.clone().invert(),m=d.position.clone().applyMatrix4(h),O={};pt.getPositionToCartographic(m,O),document.getElementById("credits").innerText=st(O.lat,O.lon)+` +`+s.getAttributions()[0].value}} diff --git a/example/bundle/assets/googleMapsExample-Ds1phUl0.js b/example/bundle/assets/googleMapsExample-Ds1phUl0.js new file mode 100644 index 000000000..661d4ccc6 --- /dev/null +++ b/example/bundle/assets/googleMapsExample-Ds1phUl0.js @@ -0,0 +1,2 @@ +import{W as A,S as v,a as F,O as G,n as s}from"./three.module-C94OeYjd.js";import{G as T,e as b}from"./GLTFLoader-C77rxX9H.js";import{D as M}from"./DRACOLoader-CQ2RnL8Q.js";import{g as S,C as P,t as W}from"./lil-gui.module.min-NsHmRZWc.js";import{S as L}from"./stats.module--VATS4Kh.js";import{C as z}from"./CameraTransitionManager-C9mHScp9.js";import{T as $}from"./TileCompressionPlugin-DurGWH0s.js";import{G as H,U as I}from"./UpdateOnChangePlugin-Bk7zjKKd.js";import{T as O}from"./TilesFadePlugin-BuMLsouQ.js";import{G as K}from"./GoogleCloudAuthPlugin-CXITux-L.js";import{W as g}from"./TilesRenderer-DQOLA18N.js";import{G as k}from"./GoogleTilesRenderer-CVSgZtW5.js";import"./EnvironmentControls-CTZuopjd.js";import"./B3DMLoader-B0T2UZ_1.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./PNTSLoader-BUgecSBY.js";import"./I3DMLoader-C4TPl3Dp.js";import"./CMPTLoader-CXF13c0w.js";import"./GLTFExtensionLoader-Qt9Ghhze.js";let p,u,d,e,r,C,f;const U=localStorage.getItem("googleApiKey")??"put-your-api-key-here",c={orthographic:!1,enableCacheDisplay:!1,enableRendererStats:!1,apiKey:U,reload:y};j();E();function y(){e&&(u.remove(e.group),e.dispose(),e=null),localStorage.setItem("googleApiKey",c.apiKey),e=new k,e.registerPlugin(new K({apiToken:c.apiKey,autoRefreshToken:!0})),e.registerPlugin(new $),e.registerPlugin(new I),e.registerPlugin(new O),e.group.rotation.x=-Math.PI/2,e.errorTarget=50;const o=new M;o.setDecoderPath("https://unpkg.com/three@0.153.0/examples/jsm/libs/draco/gltf/");const t=new T(e.manager);t.setDRACOLoader(o),e.manager.addHandler(/\.gltf$/,t),u.add(e.group),e.setResolutionFromRenderer(r.camera,d),e.setCamera(r.camera),p.setTilesRenderer(e)}function j(){d=new A({antialias:!0}),d.setClearColor(1383455),document.body.appendChild(d.domElement),u=new v,r=new z(new F(60,window.innerWidth/window.innerHeight,1,16e7),new G(-1,1,1,-1,1,16e7)),r.perspectiveCamera.position.set(48e5,257e4,1472e4),r.perspectiveCamera.lookAt(0,0,0),r.addEventListener("camera-changed",({camera:n,prevCamera:l})=>{e.deleteCamera(l),e.setCamera(n),p.setCamera(n)}),r.orthographicPositionalZoom=!1,p=new H(u,r.camera,d.domElement,null),p.enableDamping=!0,y(),R(),window.addEventListener("resize",R,!1),window.addEventListener("hashchange",D);const o=new S;o.width=300,o.add(c,"orthographic").onChange(n=>{p.getPivotPoint(r.fixedPoint),p.updateCameraClipPlanes(r.perspectiveCamera),p.updateCameraClipPlanes(r.orthographicCamera),r.toggle()});const t=o.addFolder("Google Tiles");t.add(c,"apiKey"),t.add(c,"reload");const a=o.addFolder("Example Options");a.add(c,"enableCacheDisplay"),a.add(c,"enableRendererStats"),C=document.createElement("div"),document.getElementById("info").appendChild(C),f=new L,f.showPanel(0),document.body.appendChild(f.dom),D(),setInterval(B,100)}function R(){const{perspectiveCamera:o,orthographicCamera:t}=r,a=window.innerWidth/window.innerHeight;o.aspect=a,o.updateProjectionMatrix(),t.left=-t.top*a,t.right=-t.left,t.updateProjectionMatrix(),d.setSize(window.innerWidth,window.innerHeight),d.setPixelRatio(window.devicePixelRatio)}function B(){if(!e)return;const o=r.camera,t={},a={},n=e.group.matrixWorld.clone().invert(),l=o.position.clone().applyMatrix4(n),m=o.matrixWorld.clone().premultiply(n);g.getPositionToCartographic(l,t),g.getAzElRollFromRotationMatrix(t.lat,t.lon,m,a,P),a.azimuth*=s.RAD2DEG,a.elevation*=s.RAD2DEG,t.lat*=s.RAD2DEG,t.lon*=s.RAD2DEG;const i=new URLSearchParams;i.set("lat",t.lat.toFixed(4)),i.set("lon",t.lon.toFixed(4)),i.set("height",t.height.toFixed(2)),i.set("az",a.azimuth.toFixed(2)),i.set("el",a.elevation.toFixed(2)),window.history.replaceState(void 0,void 0,`#${i}`)}function D(){const o=window.location.hash.replace(/^#/,""),t=new URLSearchParams(o);if(!t.has("lat")&&!t.has("lon"))return;e.group.updateMatrixWorld();const a=r.camera,n=parseFloat(t.get("lat")),l=parseFloat(t.get("lon")),m=parseFloat(t.get("height"))||1e3;if(t.has("az")&&t.has("el")){const i=parseFloat(t.get("az")),h=parseFloat(t.get("el"));g.getRotationMatrixFromAzElRoll(n*s.DEG2RAD,l*s.DEG2RAD,i*s.DEG2RAD,h*s.DEG2RAD,0,a.matrixWorld,P),a.matrixWorld.premultiply(e.group.matrixWorld),a.matrixWorld.decompose(a.position,a.quaternion,a.scale),g.getCartographicToPosition(n*s.DEG2RAD,l*s.DEG2RAD,m,a.position),a.position.applyMatrix4(e.group.matrixWorld)}else g.getCartographicToPosition(n*s.DEG2RAD,l*s.DEG2RAD,m,a.position),a.position.applyMatrix4(e.group.matrixWorld),a.lookAt(0,0,0)}function E(){if(requestAnimationFrame(E),!e)return;p.enabled=!r.animating,p.update(),r.update();const o=r.camera;e.setResolutionFromRenderer(o,d),e.setCamera(o),o.updateMatrixWorld(),e.update(),d.render(u,o),f.update(),q()}function q(){const o=e.lruCache.itemList.length/e.lruCache.maxSize;let t="";if(c.enableCacheDisplay){t+=`Downloading: ${e.stats.downloading} Parsing: ${e.stats.parsing} Visible: ${e.visibleTiles.size}
`;const m=new Set;e.traverse(h=>{const w=h.cached.scene;w&&w.traverse(x=>{x.geometry&&m.add(x.geometry)})});let i=0;m.forEach(h=>{i+=b(h)}),t+=`Cache: ${(100*o).toFixed(2)}% ~${(i/1e3/1e3).toFixed(2)}mb
`}if(c.enableRendererStats){const m=d.info.memory,i=d.info.programs.length;t+=`Geometries: ${m.geometries} Textures: ${m.textures} Programs: ${i}`}C.innerHTML!==t&&(C.innerHTML=t);const a=e.group.matrixWorld.clone().invert(),n=r.camera.position.clone().applyMatrix4(a),l={};g.getPositionToCartographic(n,l),document.getElementById("credits").innerText=W(l.lat,l.lon)+` +`+e.getAttributions()[0].value} diff --git a/example/bundle/assets/i3dmExample-BFcAUGcX.js b/example/bundle/assets/i3dmExample-BFcAUGcX.js new file mode 100644 index 000000000..84e88470d --- /dev/null +++ b/example/bundle/assets/i3dmExample-BFcAUGcX.js @@ -0,0 +1 @@ +import{S,W as P,P as b,a as M,D as W,A as C,k as m,Q as v,p as L}from"./three.module-C94OeYjd.js";import{O as y}from"./OrbitControls-bHRTZZ2i.js";import{I as R}from"./I3DMLoader-C4TPl3Dp.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./GLTFLoader-C77rxX9H.js";let n,a,s,e,i;z();f();function z(){s=new S,e=new P({antialias:!0}),e.setPixelRatio(window.devicePixelRatio),e.setSize(window.innerWidth,window.innerHeight),e.setClearColor(1383455),e.shadowMap.enabled=!0,e.shadowMap.type=b,document.body.appendChild(e.domElement),n=new M(60,window.innerWidth/window.innerHeight,1,4e3),n.position.set(100,100,100),a=new y(n,e.domElement),a.screenSpacePanning=!1,a.minDistance=1,a.maxDistance=2e3,i=new W(16777215,1.25),i.position.set(1,2,3).multiplyScalar(40),i.castShadow=!0,i.shadow.bias=-.01,i.shadow.mapSize.setScalar(2048);const o=i.shadow.camera;o.left=-200,o.bottom=-200,o.right=200,o.top=200,o.updateProjectionMatrix(),s.add(i);const h=new C(16777215,.05);s.add(h),new R().loadAsync("https://raw.githubusercontent.com/CesiumGS/3d-tiles-samples/main/1.0/TilesetWithTreeBillboards/tree.i3dm").then(d=>{let t=null;if(d.scene.traverse(r=>{!t&&r.isInstancedMesh&&(t=r)}),t){d.scene.updateMatrixWorld(!0);const r=new m,u=new v,g=new m,w=new L,c=new m;for(let l=0,x=t.count;l>Math.log2(t),k=g[l];if(!this.getBit(I._tileAvailability,s)){B.push(void 0);continue}const n=this.deriveChildTile(I,k,s,a);k.children.push(n),B.push(n)}g=B,B=[]}return g}deriveChildTile(A,I,g,B){const e=new PA(I,B);e.boundingVolume=this.getTileBoundingVolume(e),e.geometricError=this.getGeometricError(e);for(let t=0;A&&t=A.lengthBits)throw new Error("Bit index out of bounds.");if(A.constant!==void 0)return A.constant;const g=I>>3,B=I%8;return(new Uint8Array(A.bitstream)[g]>>B&1)===1}getTileBoundingVolume(A){const I={};if(this.rootTile.boundingVolume.region){const g=[...this.rootTile.boundingVolume.region],B=g[0],e=g[2],t=g[1],C=g[3],o=(e-B)/Math.pow(2,A.__level),a=(C-t)/Math.pow(2,A.__level);g[0]=B+o*A.__x,g[2]=B+o*(A.__x+1),g[1]=t+a*A.__y,g[3]=t+a*(A.__y+1);for(let s=0;s<4;s++){const l=g[s];l<-Math.PI?g[s]+=2*Math.PI:l>Math.PI&&(g[s]-=2*Math.PI)}if(fA(A)){const s=g[4],k=(g[5]-s)/Math.pow(2,A.__level);g[4]=s+k*A.__z,g[5]=s+k*(A.__z+1)}I.region=g}if(this.rootTile.boundingVolume.box){const g=[...this.rootTile.boundingVolume.box],B=2**A.__level-1,e=Math.pow(2,-A.__level),t=fA(A)?3:2;for(let C=0;C{const B=this._getIdleWorker();B!==-1?(this._initWorker(B),this.workerStatus|=1<A.terminate()),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const yg=0,OA=2,Fg=1,vA=2,Gg=0,pg=1,Sg=10,Rg=0,II=9,gI=15,BI=16,eI=22,iI=37,tI=43,CI=76,QI=83,EI=97,oI=100,sI=103,aI=109,nI=165,rI=166;class mg{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}}class AA{constructor(A,I,g,B){this._dataView=new DataView(A.buffer,A.byteOffset+I,g),this._littleEndian=B,this._offset=0}_nextUint8(){const A=this._dataView.getUint8(this._offset);return this._offset+=1,A}_nextUint16(){const A=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,A}_nextUint32(){const A=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,A}_nextUint64(){const A=this._dataView.getUint32(this._offset,this._littleEndian)+4294967296*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,A}_nextInt32(){const A=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,A}_skip(A){return this._offset+=A,this}_scan(A,I=0){const g=this._offset;let B=0;for(;this._dataView.getUint8(this._offset)!==I&&BA.arrayBuffer()).then(A=>WebAssembly.instantiate(A,UA)).then(this._init):WebAssembly.instantiate(Buffer.from(WA,"base64"),UA).then(this._init),uA)}_init(A){b=A.instance,UA.env.emscripten_notify_memory_growth(0)}decode(A,I=0){if(!b)throw new Error("ZSTDDecoder: Await .init() before decoding.");const g=A.byteLength,B=b.exports.malloc(g);xA.set(A,B),I=I||Number(b.exports.ZSTD_findDecompressedSize(B,g));const e=b.exports.malloc(I),t=b.exports.ZSTD_decompress(e,I,B,g),C=xA.slice(e,e+t);return b.exports.free(B),b.exports.free(e),C}}const WA="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IAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQh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ASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigC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C0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdB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IAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY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wOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEE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",LA=new WeakMap;let NA=0,kA;class H extends yI{constructor(A){super(A),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new fg,this.workerSourceURL="",this.workerConfig=null,typeof MSC_TRANSCODER<"u"&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(A){return this.transcoderPath=A,this}setWorkerLimit(A){return this.workerPool.setWorkerLimit(A),this}async detectSupportAsync(A){return this.workerConfig={astcSupported:await A.hasFeatureAsync("texture-compression-astc"),etc1Supported:await A.hasFeatureAsync("texture-compression-etc1"),etc2Supported:await A.hasFeatureAsync("texture-compression-etc2"),dxtSupported:await A.hasFeatureAsync("texture-compression-bc"),bptcSupported:await A.hasFeatureAsync("texture-compression-bptc"),pvrtcSupported:await A.hasFeatureAsync("texture-compression-pvrtc")},this}detectSupport(A){return A.isWebGPURenderer===!0?this.workerConfig={astcSupported:A.hasFeature("texture-compression-astc"),etc1Supported:A.hasFeature("texture-compression-etc1"),etc2Supported:A.hasFeature("texture-compression-etc2"),dxtSupported:A.hasFeature("texture-compression-bc"),bptcSupported:A.hasFeature("texture-compression-bptc"),pvrtcSupported:A.hasFeature("texture-compression-pvrtc")}:this.workerConfig={astcSupported:A.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:A.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:A.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:A.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:A.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:A.extensions.has("WEBGL_compressed_texture_pvrtc")||A.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},this}init(){if(!this.transcoderPending){const A=new yA(this.manager);A.setPath(this.transcoderPath),A.setWithCredentials(this.withCredentials);const I=A.loadAsync("basis_transcoder.js"),g=new yA(this.manager);g.setPath(this.transcoderPath),g.setResponseType("arraybuffer"),g.setWithCredentials(this.withCredentials);const B=g.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([I,B]).then(([e,t])=>{const C=H.BasisWorker.toString(),o=["/* constants */","let _EngineFormat = "+JSON.stringify(H.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(H.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(H.BasisFormat),"/* basis_transcoder.js */",e,"/* worker */",C.substring(C.indexOf("{")+1,C.lastIndexOf("}"))].join(` +`);this.workerSourceURL=URL.createObjectURL(new Blob([o])),this.transcoderBinary=t,this.workerPool.setWorkerCreator(()=>{const a=new Worker(this.workerSourceURL),s=this.transcoderBinary.slice(0);return a.postMessage({type:"init",config:this.workerConfig,transcoderBinary:s},[s]),a})}),NA>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),NA++}return this.transcoderPending}load(A,I,g,B){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const e=new yA(this.manager);e.setResponseType("arraybuffer"),e.setWithCredentials(this.withCredentials),e.load(A,t=>{if(LA.has(t))return LA.get(t).promise.then(I).catch(B);this._createTexture(t).then(C=>I?I(C):null).catch(B)},g,B)}_createTextureFrom(A,I){const{faces:g,width:B,height:e,format:t,type:C,error:o,dfdFlags:a}=A;if(C==="error")return Promise.reject(o);let s;if(I.faceCount===6)s=new FI(g,t,x);else{const l=g[0].mipmaps;s=I.layerCount>1?new GI(l,B,e,I.layerCount,t,x):new AI(l,B,e,t,x)}return s.minFilter=g[0].mipmaps.length===1?TA:pI,s.magFilter=TA,s.generateMipmaps=!1,s.needsUpdate=!0,s.colorSpace=hI(I),s.premultiplyAlpha=!!(a&Fg),s}async _createTexture(A,I={}){const g=ug(new Uint8Array(A));if(g.vkFormat!==Rg)return Ng(g);const B=I,e=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:A,taskConfig:B},[A])).then(t=>this._createTextureFrom(t.data,g));return LA.set(A,{promise:e}),e}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),NA--,this}}H.BasisFormat={ETC1S:0,UASTC_4x4:1};H.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16};H.EngineFormat={RGBAFormat:X,RGBA_ASTC_4x4_Format:SI,RGBA_BPTC_Format:RI,RGBA_ETC2_EAC_Format:mI,RGBA_PVRTC_4BPPV1_Format:uI,RGBA_S3TC_DXT5_Format:UI,RGB_ETC1_Format:LI,RGB_ETC2_Format:NI,RGB_PVRTC_4BPPV1_Format:kI,RGBA_S3TC_DXT1_Format:MI};H.BasisWorker=function(){let i,A,I;const g=_EngineFormat,B=_TranscoderFormat,e=_BasisFormat;self.addEventListener("message",function(h){const r=h.data;switch(r.type){case"init":i=r.config,t(r.transcoderBinary);break;case"transcode":A.then(()=>{try{const{faces:c,buffers:d,width:D,height:G,hasAlpha:T,format:M,dfdFlags:u}=C(r.buffer);self.postMessage({type:"transcode",id:r.id,faces:c,width:D,height:G,hasAlpha:T,format:M,dfdFlags:u},d)}catch(c){console.error(c),self.postMessage({type:"error",id:r.id,error:c.message})}});break}});function t(h){A=new Promise(r=>{I={wasmBinary:h,onRuntimeInitialized:r},BASIS(I)}).then(()=>{I.initializeBasis(),I.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function C(h){const r=new I.KTX2File(new Uint8Array(h));function c(){r.close(),r.delete()}if(!r.isValid())throw c(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");const d=r.isUASTC()?e.UASTC_4x4:e.ETC1S,D=r.getWidth(),G=r.getHeight(),T=r.getLayers()||1,M=r.getLevels(),u=r.getFaces(),QA=r.getHasAlpha(),EA=r.getDFDFlags(),{transcoderFormat:Z,engineFormat:j}=l(d,D,G,QA);if(!D||!G||!M)throw c(),new Error("THREE.KTX2Loader: Invalid texture");if(!r.startTranscoding())throw c(),new Error("THREE.KTX2Loader: .startTranscoding failed");const z=[],oA=[];for(let v=0;v1?(S=W.origWidth,U=W.origHeight):(S=W.width,U=W.height);const HA=new Uint8Array(r.getImageTranscodedSizeInBytes(O,Y,0,Z));if(!r.transcodeImage(HA,O,Y,v,Z,0,-1,-1))throw c(),new Error("THREE.KTX2Loader: .transcodeImage failed.");aA.push(HA)}const $=n(aA);sA.push({data:$,width:S,height:U}),oA.push($.buffer)}z.push({mipmaps:sA,width:D,height:G,format:j})}return c(),{faces:z,buffers:oA,width:D,height:G,hasAlpha:QA,format:j,dfdFlags:EA}}const o=[{if:"astcSupported",basisFormat:[e.UASTC_4x4],transcoderFormat:[B.ASTC_4x4,B.ASTC_4x4],engineFormat:[g.RGBA_ASTC_4x4_Format,g.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[e.ETC1S,e.UASTC_4x4],transcoderFormat:[B.BC7_M5,B.BC7_M5],engineFormat:[g.RGBA_BPTC_Format,g.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[e.ETC1S,e.UASTC_4x4],transcoderFormat:[B.BC1,B.BC3],engineFormat:[g.RGBA_S3TC_DXT1_Format,g.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[e.ETC1S,e.UASTC_4x4],transcoderFormat:[B.ETC1,B.ETC2],engineFormat:[g.RGB_ETC2_Format,g.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[e.ETC1S,e.UASTC_4x4],transcoderFormat:[B.ETC1],engineFormat:[g.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[e.ETC1S,e.UASTC_4x4],transcoderFormat:[B.PVRTC1_4_RGB,B.PVRTC1_4_RGBA],engineFormat:[g.RGB_PVRTC_4BPPV1_Format,g.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],a=o.sort(function(h,r){return h.priorityETC1S-r.priorityETC1S}),s=o.sort(function(h,r){return h.priorityUASTC-r.priorityUASTC});function l(h,r,c,d){let D,G;const T=h===e.ETC1S?a:s;for(let M=0;M{const t=new Ug;await t.init(),e(t)})),I=await kA);const g=[];for(let e=0;e>e),C=Math.max(1,i.pixelHeight>>e),o=i.pixelDepth?Math.max(1,i.pixelDepth>>e):0,a=i.levels[e];let s;if(i.supercompressionScheme===yg)s=a.levelData;else if(i.supercompressionScheme===OA)s=I.decode(a.levelData,a.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let l;_A[A]===cA?l=new Float32Array(s.buffer,s.byteOffset,s.byteLength/Float32Array.BYTES_PER_ELEMENT):_A[A]===dA?l=new Uint16Array(s.buffer,s.byteOffset,s.byteLength/Uint16Array.BYTES_PER_ELEMENT):l=s,g.push({data:l,width:t,height:C,depth:o})}let B;if(Lg.has(MA[A]))B=i.pixelDepth===0?new _I(g[0].data,i.pixelWidth,i.pixelHeight):new xI(g[0].data,i.pixelWidth,i.pixelHeight,i.pixelDepth);else{if(i.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");B=new AI(g,i.pixelWidth,i.pixelHeight)}return B.mipmaps=g,B.type=_A[A],B.format=MA[A],B.colorSpace=hI(i),B.needsUpdate=!0,Promise.resolve(B)}function hI(i){const A=i.dataFormatDescriptor[0];return A.colorPrimaries===pg?A.transferFunction===vA?qI:JI:A.colorPrimaries===Sg?A.transferFunction===vA?HI:TI:A.colorPrimaries===Gg?YA:(console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${A.colorPrimaries}"`),YA)}const kg=1,cI=2,dI=window.location.hash.replace(/^#/,"");let y,BA,q,f,Q,eA,K,N,nA,w,iA,rA,R,F,tA,lA,qA,P,J,p,CA,V,_,L,wA;const E={enableUpdate:!0,raycast:DA,optimizeRaycast:!0,enableCacheDisplay:!1,enableRendererStats:!1,orthographic:!1,errorTarget:6,errorThreshold:60,maxDepth:15,displayActiveTiles:!1,resolutionScale:1,up:dI?"+Z":"+Y",displayBoxBounds:!1,displaySphereBounds:!1,displayRegionBounds:!1,colorMode:0,showThirdPerson:!1,showSecondView:!1,reload:lI};Mg();fI();function lI(){const i=dI||"../data/tileset.json";Q&&(_.remove(Q.group),Q.dispose()),Q=new ng(i),Q.registerPlugin(new Cg),Q.registerPlugin(new Dg);const A=new og;A.setDecoderPath("https://unpkg.com/three@0.153.0/examples/jsm/libs/draco/gltf/");const I=new H;I.setTranscoderPath("https://unpkg.com/three@0.153.0/examples/jsm/libs/basis/"),I.detectSupport(f);const g=new Eg(Q.manager);g.setDRACOLoader(A),g.setKTX2Loader(I),g.register(()=>new dg),Q.fetchOptions.mode="cors",Q.manager.addHandler(/\.gltf$/,g),_.add(Q.group),Q.customColorCallback=(B,e)=>{const C=B.__depth%2===0?16711680:16777215;e.traverse(o=>{o.isMesh&&o.material.color.set(C)})}}function Mg(){q=new YI,f=new FA({antialias:!0}),f.setPixelRatio(window.devicePixelRatio),f.setSize(window.innerWidth,window.innerHeight),f.setClearColor(1383455),document.body.appendChild(f.domElement),f.domElement.tabIndex=1,y=new GA(60,window.innerWidth/window.innerHeight,1,1e4),y.position.set(400,400,400),eA=new pA(y),q.add(eA),F=new bI,tA=new pA(F),q.add(tA),R=new GA(60,window.innerWidth/window.innerHeight,1,4e3),R.position.set(400,400,-400),R.lookAt(0,0,0),w=new FA({antialias:!0}),w.setPixelRatio(window.devicePixelRatio),w.setSize(window.innerWidth,window.innerHeight),w.setClearColor(1383455),document.body.appendChild(w.domElement),w.domElement.style.position="absolute",w.domElement.style.right="0",w.domElement.style.top="0",w.domElement.style.outline="#0f1416 solid 2px",w.domElement.tabIndex=1,rA=new RA(R,w.domElement),rA.screenSpacePanning=!1,rA.minDistance=1,rA.maxDistance=5e3,iA=new pA(R),q.add(iA),K=new GA(60,window.innerWidth/window.innerHeight,1,4e3),K.position.set(50,40,40),K.lookAt(0,0,0),N=new FA({antialias:!0}),N.setPixelRatio(window.devicePixelRatio),N.setSize(window.innerWidth,window.innerHeight),N.setClearColor(988182),document.body.appendChild(N.domElement),N.domElement.style.position="fixed",N.domElement.style.left="5px",N.domElement.style.bottom="5px",N.domElement.tabIndex=1,nA=new RA(K,N.domElement),nA.screenSpacePanning=!1,nA.minDistance=1,nA.maxDistance=5e3,BA=new RA(y,f.domElement),BA.screenSpacePanning=!1,BA.minDistance=1,BA.maxDistance=5e3;const i=new KI(16777215);i.position.set(1,2,3),q.add(i);const A=new PI(16777215,.2);q.add(A),lA=new WI,qA=new XI,V=new SA,q.add(V),_=new SA,V.add(_),P=new ZI,J=new JA,p=new SA;const I=new OI({color:15277667}),g=new KA(new vI(.25,.25,6),I);g.rotation.x=Math.PI/2,g.position.z+=3,p.add(g);const B=new KA(new VI(1.5,.2,16,100),I);p.add(B),q.add(p),p.visible=!1,lI(),hA(),window.addEventListener("resize",hA,!1),f.domElement.addEventListener("pointermove",ZA,!1),f.domElement.addEventListener("pointerdown",zA,!1),f.domElement.addEventListener("pointerup",$A,!1),f.domElement.addEventListener("pointerleave",XA,!1),w.domElement.addEventListener("pointermove",ZA,!1),w.domElement.addEventListener("pointerdown",zA,!1),w.domElement.addEventListener("pointerup",$A,!1),w.domElement.addEventListener("pointerleave",XA,!1);const e=new sg;e.width=300;const t=e.addFolder("Tiles Options");t.add(E,"displayActiveTiles"),t.add(E,"errorTarget").min(0).max(50),t.add(E,"errorThreshold").min(0).max(1e3),t.add(E,"maxDepth").min(1).max(100),t.add(E,"up",["+Y","+Z","-Z"]),t.open();const C=e.addFolder("Debug Options");C.add(E,"displayBoxBounds"),C.add(E,"displaySphereBounds"),C.add(E,"displayRegionBounds"),C.add(E,"colorMode",{NONE:DA,SCREEN_ERROR:jI,GEOMETRIC_ERROR:zI,DISTANCE:$I,DEPTH:Ag,RELATIVE_DEPTH:Ig,IS_LEAF:gg,RANDOM_COLOR:Bg,RANDOM_NODE_COLOR:eg,CUSTOM_COLOR:ig,LOAD_ORDER:tg}),C.open();const o=e.addFolder("Example Options");o.add(E,"resolutionScale").min(.01).max(2).step(.01).onChange(hA),o.add(E,"orthographic"),o.add(E,"showThirdPerson"),o.add(E,"showSecondView").onChange(hA),o.add(E,"enableUpdate").onChange(a=>{Q.parseQueue.autoUpdate=a,Q.downloadQueue.autoUpdate=a,a&&(Q.parseQueue.scheduleJobRun(),Q.downloadQueue.scheduleJobRun())}),o.add(E,"raycast",{NONE:DA,ALL_HITS:kg,FIRST_HIT_ONLY:cI}),o.add(E,"optimizeRaycast"),o.add(E,"enableCacheDisplay"),o.add(E,"enableRendererStats"),o.open(),e.add(E,"reload"),e.open(),L=document.createElement("div"),L.style.position="absolute",L.style.top=0,L.style.left=0,L.style.color="white",L.style.width="100%",L.style.textAlign="center",L.style.padding="5px",L.style.pointerEvents="none",L.style.lineHeight="1.5em",document.body.appendChild(L),wA=new ag,wA.showPanel(0),document.body.appendChild(wA.dom)}function hA(){K.aspect=window.innerWidth/window.innerHeight,K.updateProjectionMatrix(),N.setSize(Math.floor(window.innerWidth/3),Math.floor(window.innerHeight/3)),E.showSecondView?(y.aspect=.5*window.innerWidth/window.innerHeight,f.setSize(.5*window.innerWidth,window.innerHeight),R.aspect=.5*window.innerWidth/window.innerHeight,w.setSize(.5*window.innerWidth,window.innerHeight),w.domElement.style.display="block"):(y.aspect=window.innerWidth/window.innerHeight,f.setSize(window.innerWidth,window.innerHeight),w.domElement.style.display="none"),y.updateProjectionMatrix(),f.setPixelRatio(window.devicePixelRatio*E.resolutionScale),R.updateProjectionMatrix(),w.setPixelRatio(window.devicePixelRatio),DI()}function XA(i){CA=null}function ZA(i){const A=this.getBoundingClientRect();J.x=i.clientX-A.x,J.y=i.clientY-A.y,J.x=J.x/A.width*2-1,J.y=-(J.y/A.height)*2+1,CA=this}const wI=new JA,jA=new JA;function zA(i){const A=this.getBoundingClientRect();wI.set(i.clientX-A.x,i.clientY-A.y)}function $A(i){const A=this.getBoundingClientRect();if(jA.set(i.clientX-A.x,i.clientY-A.y),wI.distanceTo(jA)>2)return;CA===w.domElement?P.setFromCamera(J,R):P.setFromCamera(J,E.orthographic?F:y),P.firstHitOnly=!0;const I=P.intersectObject(Q.group,!0);if(I.length){const g=I[0].object,B=Q.getPluginByName("DEBUG_TILES_PLUGIN").getTileInformationFromActiveObject(g);let e="";for(const t in B){let C=B[t];typeof C=="number"&&(C=Math.floor(C*1e5)/1e5);let o=t;for(;o.length<20;)o+=" ";e+=`${o} : ${C} +`}console.log(e)}}function DI(){F.position.copy(y.position),F.rotation.copy(y.rotation);const i=y.position.distanceTo(BA.target)/2;let A=window.innerWidth/window.innerHeight;E.showSecondView&&(A*=.5),F.left=-A*i,F.right=A*i,F.bottom=-i,F.top=i,F.near=y.near,F.far=y.far,F.updateProjectionMatrix()}function fI(){requestAnimationFrame(fI),Q.errorTarget=E.errorTarget,Q.errorThreshold=E.errorThreshold,Q.optimizeRaycast=E.optimizeRaycast,Q.displayActiveTiles=E.displayActiveTiles,Q.maxDepth=E.maxDepth;const i=Q.getPluginByName("DEBUG_TILES_PLUGIN");if(i.displayBoxBounds=E.displayBoxBounds,i.displaySphereBounds=E.displaySphereBounds,i.displayRegionBounds=E.displayRegionBounds,i.colorMode=parseFloat(E.colorMode),E.orthographic?(Q.deleteCamera(y),Q.setCamera(F),Q.setResolutionFromRenderer(F,f)):(Q.deleteCamera(F),Q.setCamera(y),Q.setResolutionFromRenderer(y,f)),E.showSecondView?(Q.setCamera(R),Q.setResolutionFromRenderer(R,w)):Q.deleteCamera(R),Q.root&&Q.root.boundingVolume.region&&(Q.getOrientedBoundingBox(lA,_.matrix),_.matrix.decompose(_.position,_.quaternion,_.scale),_.position.set(0,0,0),_.quaternion.invert(),_.scale.set(1,1,1)),V.rotation.set(0,0,0),E.up==="-Z"?V.rotation.x=Math.PI/2:E.up==="+Z"&&(V.rotation.x=-Math.PI/2),V.updateMatrixWorld(!1),Q.getBoundingBox(lA)?(lA.getCenter(Q.group.position),Q.group.position.multiplyScalar(-1)):Q.getBoundingSphere(qA)&&(Q.group.position.copy(qA.center),Q.group.position.multiplyScalar(-1)),parseFloat(E.raycast)!==DA&&CA!==null){CA===f.domElement?P.setFromCamera(J,E.orthographic?F:y):P.setFromCamera(J,R),P.firstHitOnly=parseFloat(E.raycast)===cI;const A=P.intersectObject(Q.group,!0);if(A.length){const I=A[0],g=I.point;if(p.position.copy(g),I.face){const B=I.face.normal;B.transformDirection(I.object.matrixWorld),p.lookAt(g.x+B.x,g.y+B.y,g.z+B.z)}p.visible=!0}else p.visible=!1}else p.visible=!1;window.tiles=Q,E.enableUpdate&&(R.updateMatrixWorld(),y.updateMatrixWorld(),F.updateMatrixWorld(),Q.update()),_g(),wA.update()}function _g(){if(DI(),eA.visible=!1,tA.visible=!1,iA.visible=!1,E.orthographic){const I=F.position.distanceTo(p.position);p.scale.setScalar(I/150)}else{const I=y.position.distanceTo(p.position);p.scale.setScalar(I*y.fov/6e3)}if(f.render(q,E.orthographic?F:y),E.showSecondView){const I=R.position.distanceTo(p.position);p.scale.setScalar(I*R.fov/6e3),w.render(q,R)}if(N.domElement.style.visibility=E.showThirdPerson?"visible":"hidden",E.showThirdPerson){eA.update(),eA.visible=!E.orthographic,tA.update(),tA.visible=E.orthographic,E.showSecondView&&(iA.update(),iA.visible=!0);const I=K.position.distanceTo(p.position);p.scale.setScalar(I*K.fov/6e3),N.render(q,K)}const i=Q.lruCache.itemList.length/Q.lruCache.maxSize;let A=`Downloading: ${Q.stats.downloading} Parsing: ${Q.stats.parsing} Visible: ${Q.visibleTiles.size}`;if(E.enableCacheDisplay){const I=new Set;Q.traverse(B=>{const e=B.cached.scene;e&&e.traverse(t=>{t.geometry&&I.add(t.geometry)})});let g=0;I.forEach(B=>{g+=Qg(B)}),A+=`
Cache: ${(100*i).toFixed(2)}% ~${(g/1e3/1e3).toFixed(2)}mb`}if(E.enableRendererStats){const I=f.info.memory,g=f.info.programs.length;A+=`
Geometries: ${I.geometries} Textures: ${I.textures} Programs: ${g}`}L.innerHTML!==A&&(L.innerHTML=A)} diff --git a/example/bundle/assets/ionExample-D7rqEgko.js b/example/bundle/assets/ionExample-D7rqEgko.js new file mode 100644 index 000000000..6ed4febcb --- /dev/null +++ b/example/bundle/assets/ionExample-D7rqEgko.js @@ -0,0 +1 @@ +import{S as f,$ as h,ad as A,W as x,a as T,d as y,k as l,Q as C}from"./three.module-C94OeYjd.js";import{G as I}from"./GLTFLoader-C77rxX9H.js";import{D as R}from"./DRACOLoader-CQ2RnL8Q.js";import{g as k}from"./lil-gui.module.min-NsHmRZWc.js";import{E as z}from"./EnvironmentControls-CTZuopjd.js";import{T as E}from"./TilesRenderer-DQOLA18N.js";import{C as P}from"./CesiumIonAuthPlugin-CBH0S8UR.js";import"./B3DMLoader-B0T2UZ_1.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./PNTSLoader-BUgecSBY.js";import"./I3DMLoader-C4TPl3Dp.js";import"./CMPTLoader-CXF13c0w.js";import"./GLTFExtensionLoader-Qt9Ghhze.js";import"./GoogleCloudAuthPlugin-CXITux-L.js";let i,c,a,r,e;const v=localStorage.getItem("ionApiKey")??"put-your-api-key-here",s={ionAssetId:"40866",ionAccessToken:v,reload:u};S();w();function D(o,t){const n=new C,d=new l().crossVectors(o,t);return n.x=d.x,n.y=d.y,n.z=d.z,n.w=1+o.clone().dot(t),n.normalize(),n}function L(){e.fetchOptions.mode="cors";const o=new R;o.setDecoderPath("https://unpkg.com/three@0.153.0/examples/jsm/libs/draco/gltf/");const t=new I(e.manager);t.setDRACOLoader(o),e.manager.addHandler(/\.gltf$/,t),a.add(e.group)}function u(){e&&(a.remove(e.group),e.dispose(),e=null),localStorage.setItem("ionApiKey",s.ionAccessToken),e=new E,e.registerPlugin(new P({apiToken:s.ionAccessToken,assetId:s.ionAssetId})),e.addEventListener("load-tile-set",()=>{const o=new y;e.getBoundingSphere(o);const t=o.center.clone(),n=t.length(),d=t.normalize(),g=new l(0,1,0),p=D(d,g);e.group.quaternion.x=p.x,e.group.quaternion.y=p.y,e.group.quaternion.z=p.z,e.group.quaternion.w=p.w,e.group.position.y=-n}),L()}function S(){a=new f;const o=new h(new Uint8Array(64*64*4).fill(255),64,64);o.mapping=A,o.needsUpdate=!0,a.environment=o,r=new x({antialias:!0}),r.setClearColor(1383455),document.body.appendChild(r.domElement),r.domElement.tabIndex=1,i=new T(60,window.innerWidth/window.innerHeight,1,1e5),i.position.set(100,100,-100),i.lookAt(0,0,0),c=new z(a,i,r.domElement),c.adjustHeight=!1,c.minDistance=1,c.maxAltitude=Math.PI,u(),m(),window.addEventListener("resize",m,!1);const t=new k;t.width=300;const n=t.addFolder("Ion");n.add(s,"ionAssetId"),n.add(s,"ionAccessToken"),n.add(s,"reload"),n.open()}function m(){i.aspect=window.innerWidth/window.innerHeight,i.updateProjectionMatrix(),r.setSize(window.innerWidth,window.innerHeight),r.setPixelRatio(window.devicePixelRatio)}function w(){requestAnimationFrame(w),e&&(c.update(),e.setCamera(i),e.setResolutionFromRenderer(i,r),i.updateMatrixWorld(),e.update(),r.render(a,i))} diff --git a/example/bundle/assets/ionLunar-BvwO-oQm.js b/example/bundle/assets/ionLunar-BvwO-oQm.js new file mode 100644 index 000000000..149500a16 --- /dev/null +++ b/example/bundle/assets/ionLunar-BvwO-oQm.js @@ -0,0 +1 @@ +import{W as l,S as m,a as u}from"./three.module-C94OeYjd.js";import{T as w}from"./TilesFadePlugin-BuMLsouQ.js";import{g}from"./lil-gui.module.min-NsHmRZWc.js";import{T as c}from"./TileCompressionPlugin-DurGWH0s.js";import{G as f,U as P}from"./UpdateOnChangePlugin-Bk7zjKKd.js";import{T as h,L as y}from"./TilesRenderer-DQOLA18N.js";import{C as T}from"./CesiumIonAuthPlugin-CBH0S8UR.js";import"./EnvironmentControls-CTZuopjd.js";import"./B3DMLoader-B0T2UZ_1.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./GLTFLoader-C77rxX9H.js";import"./PNTSLoader-BUgecSBY.js";import"./I3DMLoader-C4TPl3Dp.js";import"./CMPTLoader-CXF13c0w.js";import"./GLTFExtensionLoader-Qt9Ghhze.js";import"./GoogleCloudAuthPlugin-CXITux-L.js";let o,r,i,t,e;const C=localStorage.getItem("ionApiKey")??"put-your-api-key-here",a={apiKey:C,reload:p};R();d();function p(){e&&(r.remove(e.group),e.dispose(),e=null),localStorage.setItem("ionApiKey",a.apiKey),e=new h,e.ellipsoid.copy(y),e.registerPlugin(new T({apiToken:a.apiKey,assetId:"2684829",autoRefreshToken:!0})),e.registerPlugin(new c),e.registerPlugin(new P),e.registerPlugin(new w),e.group.rotation.x=-Math.PI/2,e.errorTarget=20,r.add(e.group),e.setCamera(i),o.setTilesRenderer(e)}function R(){t=new l({antialias:!0}),t.setClearColor(1383455),document.body.appendChild(t.domElement),r=new m,i=new u(60,window.innerWidth/window.innerHeight,1,16e7),i.position.set(2620409,0,-6249816),i.lookAt(0,0,0),o=new f(r,i,t.domElement,null),o.enableDamping=!0,p(),s(),window.addEventListener("resize",s,!1);const n=new g;n.width=300,n.add(a,"apiKey"),n.add(a,"reload")}function s(){const n=window.innerWidth/window.innerHeight;i.aspect=n,i.updateProjectionMatrix(),t.setSize(window.innerWidth,window.innerHeight),t.setPixelRatio(window.devicePixelRatio)}function d(){requestAnimationFrame(d),e&&(o.update(),e.setResolutionFromRenderer(i,t),i.updateMatrixWorld(),e.update(),t.render(r,i))} diff --git a/example/bundle/assets/landformSiteOverlay-xmaE93tZ.js b/example/bundle/assets/landformSiteOverlay-xmaE93tZ.js new file mode 100644 index 000000000..f25411443 --- /dev/null +++ b/example/bundle/assets/landformSiteOverlay-xmaE93tZ.js @@ -0,0 +1,29 @@ +import{k as v,p as N,Q as P,C as k,ag as J,ah as S,S as U,W as j,a as q,G as I,a1 as Y,aa as B}from"./three.module-C94OeYjd.js";import{g as D}from"./lil-gui.module.min-NsHmRZWc.js";import{P as Q,T as V}from"./TilesRenderer-DQOLA18N.js";import{E as K}from"./EnvironmentControls-CTZuopjd.js";import"./B3DMLoader-B0T2UZ_1.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./GLTFLoader-C77rxX9H.js";import"./PNTSLoader-BUgecSBY.js";import"./I3DMLoader-C4TPl3Dp.js";import"./CMPTLoader-CXF13c0w.js";import"./GLTFExtensionLoader-Qt9Ghhze.js";const M=new v,w=new P,y=new v;function E(a,e){if(a.sceneMatrix)return;const{translation:t,rotation:r,scale:s}=a;if(M.set(t.x,t.y,t.z),w.set(r.x,r.y,r.z,r.w),y.set(s.x,s.y,s.z),a.matrix=new N().compose(M,w,y),a.sceneMatrix=new N().copy(a.matrix),a.parent_id!==""){const i=e.find(o=>o.id===a.parent_id);E(i,e),a.sceneMatrix.premultiply(i.sceneMatrix)}}class W{constructor(){this.fetchOptions={}}loadAsync(e){return fetch(e,this.fetchOptions).then(t=>t.json()).then(t=>this.parse(t))}parse(e){return e.frames.forEach(t=>E(t,e.frames)),e}}const z=a=>class extends a{constructor(...e){super(...e),this.textures=[],this.overlayColor=new k(8716287),this.displayAsOverlay=!1}onBeforeCompile(e){const t=this.textures,r=this;e.uniforms.textures={get value(){return r.textures}},e.uniforms.overlayColor={get value(){return r.overlayColor}},e.defines={DISPLAY_AS_OVERLAY:Number(this.displayAsOverlay)},t.length!==0&&(e.fragmentShader=e.fragmentShader.replace(/void main/,s=>` + uniform sampler2D textures[ ${t.length} ]; + uniform vec3 overlayColor; + ${s} + + `).replace(/#include /,s=>` + + ${s} + + vec4 col; + #pragma unroll_loop_start + for ( int i = 0; i < ${t.length}; i ++ ) { + + col = texture( textures[ i ], vMapUv ); + + #if DISPLAY_AS_OVERLAY + + diffuseColor = mix( diffuseColor, vec4( overlayColor, 1.0 ), col.r * 0.5 ); + + #else + + diffuseColor = mix( diffuseColor, col, col.a ); + + #endif + + } + #pragma unroll_loop_end + + `))}customProgramCacheKey(){return String(this.displayAsOverlay)+String(this.textures.length)+this.onBeforeCompile.toString()}};function G(){let a=!1,e=!1,t=-1;return typeof navigator<"u"&&(a=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,e=navigator.userAgent.indexOf("Firefox")>-1,t=e?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),!(typeof createImageBitmap>"u"||a||e&&t<98)}class ${constructor(e,t){this.cache={},this.fetchOptions={},this.loadTextureCallback=e,this.queue=t}getTextureLoader(){const e=this.fetchOptions;let t;return G()?t=new J:t=new S,e.credentials==="include"&&e.mode==="cors"&&t.setCrossOrigin("use-credentials"),"credentials"in e&&t.setWithCredentials(e.credentials==="include"),e.headers&&t.setRequestHeader(e.headers),t}loadTexture(e){const t=this.cache;if(e in t)return t[e].promise;const r=new AbortController,s=this.queue.add(e,()=>this.loadTextureCallback(e)).then(i=>{if(r.signal.aborted)throw new Error("TextureCache: Texture load aborted.");return t[e].texture=i,i});return this.cache[e]={texture:null,abortController:r,promise:s},s}getTexture(e){const t=this.cache;return e in t?t[e].texture:null}deleteTexture(e){const t=this.cache;if(e in t){const r=t[e];r.refs--,r.refs===0&&(r.texture?r.texture.dispose():r.abortController&&(r.abortController.abort(),this.queue.remove(e)),delete this.cache[e])}}dispose(){const e=this.cache;for(const t in e){const r=e[t];r.texture?(r.texture.dispose(),r.texture.image instanceof ImageBitmap&&r.texture.image.close()):r.abortController&&r.abortController.abort()}}}class H{constructor(e={}){e={textureUpdateCallback:()=>{throw new Error('TextureOverlayPlugin: "textureUpdateCallback" required.')},waitForLoadCompletion:!0,...e},this.name="TEXTURE_OVERLAY_PLUGIN",this.caches=null,this.queue=null,this.tiles=null,this.textureUpdateCallback=e.textureUpdateCallback,this.waitForLoadCompletion=e.waitForLoadCompletion}init(e){this.tiles=e,this.caches={},this.queue=new Q,this.queue.priorityCallback=(t,r)=>e.downloadQueue.priorityCallback(t,r),this._disposeModelCallback=({tile:t})=>{const r=this.caches;for(const s in r)r[s].deleteTexture(this.getTileKey(t))},this._assignTexturesCallback=({tile:t,scene:r})=>{queueMicrotask(()=>this.textureUpdateCallback(r,t,this))},e.addEventListener("dispose-model",this._disposeModelCallback),e.addEventListener("load-model",this._assignTexturesCallback),e.addEventListener("layer-textures-change",this._assignTexturesCallback)}processTileModel(e,t){const r=this.caches,s=[];for(const i in r){const n=r[i].loadTexture(this.getTileKey(t)).catch(()=>{});s.push(n)}return Promise.all(s)}dispose(){const{caches:e,tiles:t}=this;Object.keys(e).forEach(r=>{this.unregisterLayer(r)}),t.removeEventListener("dispose-model",this._disposeModelCallback),t.removeEventListener("load-model",this._assignTexturesCallback),t.removeEventListener("layer-textures-change",this._assignTexturesCallback)}getTileKey(e){return new URL(e.content.uri,e.__basePath+"/").toString()}getTexturesForTile(e,t={}){const r=this.getTileKey(e),s=this.caches;for(const i in t)i in s||delete t[i];for(const i in s)t[i]=s[i].getTexture(r);return t}hasLayer(e){return e in this.caches}registerLayer(e,t){if(e in this.caches)throw new Error(`TextureOverlayPlugin: Texture overlay named ${e} already exists.`);const r=this.tiles,s=new $(t,this.queue);if(s.fetchOptions=r.fetchOptions,this.caches[e]=s,this.waitForLoadCompletion){const i=[];r.forEachLoadedModel((o,n)=>{const c=s.loadTexture(this.getTileKey(n)).then(()=>({scene:o,tile:n}));i.push(c)}),Promise.allSettled(i).then(o=>{e in this.caches&&o.forEach(n=>{n.status==="fulfilled"&&this.textureUpdateCallback(n.value.scene,n.value.tile,this)})})}else r.forEachLoadedModel((i,o)=>{s.loadTexture(this.getTileKey(o)).then(()=>this.textureUpdateCallback(i,o,this)).catch(()=>{})})}unregisterLayer(e){const t=this.tiles,r=this.caches;if(e in r){const s=r[e];delete r[e],t.forEachLoadedModel((i,o)=>{s.getTexture(this.getTileKey(o))&&this.textureUpdateCallback(i,o,this)}),s.dispose()}}}const X=["NLF_0477_0709296508M723RAS_N0261004NCAM00701_0A0085J02/NLF_0477_0709296508M723RAS_N0261004NCAM00701_0A0085J02_scene.json","NLF_0477_0709296508M723RAS_N0261004NCAM00708_0A00LLJ02/NLF_0477_0709296508M723RAS_N0261004NCAM00708_0A00LLJ02_scene.json","NLF_0477_0709297328M366RAS_N0261004NCAM03477_0A0195J02/NLF_0477_0709297328M366RAS_N0261004NCAM03477_0A0195J02_scene.json","NLF_0477_0709297503M102RAS_N0261004NCAM03477_0A0195J02/NLF_0477_0709297503M102RAS_N0261004NCAM03477_0A0195J02_scene.json","NLF_0477_0709297668M065RAS_N0261004NCAM03477_0A0195J02/NLF_0477_0709297668M065RAS_N0261004NCAM03477_0A0195J02_scene.json","NLF_0477_0709297838M897RAS_N0261004NCAM02477_0A0195J02/NLF_0477_0709297838M897RAS_N0261004NCAM02477_0A0195J02_scene.json","NLF_0477_0709298005M099RAS_N0261004NCAM02477_0A0195J02/NLF_0477_0709298005M099RAS_N0261004NCAM02477_0A0195J02_scene.json","NLF_0477_0709298187M680RAS_N0261004NCAM13477_0A0195J02/NLF_0477_0709298187M680RAS_N0261004NCAM13477_0A0195J02_scene.json","NLF_0477_0709298299M678RAS_N0261004NCAM13477_0A0195J02/NLF_0477_0709298299M678RAS_N0261004NCAM13477_0A0195J02_scene.json","NLF_0477_0709298393M010RAS_N0261004NCAM13477_0A0195J02/NLF_0477_0709298393M010RAS_N0261004NCAM13477_0A0195J02_scene.json"].map(a=>"https://raw.githubusercontent.com/NASA-AMMOS/3DTilesSampleData/master/m20-drive-1004/tilesets/"+a),x=[];let d,f,A,u;const g={errorTarget:12,slopeDisplay:"NONE"};Z();R();function Z(){A=new U,u=new j({antialias:!0}),u.setPixelRatio(window.devicePixelRatio),u.setSize(window.innerWidth,window.innerHeight),u.setClearColor(14208704),document.body.appendChild(u.domElement),u.domElement.tabIndex=1,d=new q(60,window.innerWidth/window.innerHeight,.025,4e3),d.position.set(-20,10,20),d.lookAt(0,0,0),f=new K(A,d,u.domElement),f.adjustHeight=!1,f.minDistance=1,f.maxAltitude=Math.PI;const a=new I;a.rotation.set(Math.PI/2,0,0),A.add(a);let e=null,t=null,r=null;const s=async o=>{const n=o.replace("/tilesets/","/textures/SMG/").replace(/\.[0-9a-z]+$/i,".png");return new S().loadAsync(n).then(c=>(c.colorSpace=Y,c.flipY=!1,c))};X.forEach(async o=>{const n=await new W().loadAsync(o),c=o.split(/[\\/]/g);c.pop();const C=z(B);n.tilesets.forEach(p=>{const b=[...c,`${p.id}_tileset.json`].join("/"),l=new V(b),O=(m,L,_)=>{m.traverse(h=>{h.material&&(h.material.textures=Object.values(_.getTexturesForTile(L)),h.material.displayAsOverlay=g.slopeDisplay==="OVERLAY",h.material.needsUpdate=!0)})},F=new H({textureUpdateCallback:O});l.registerPlugin(F),l.addEventListener("load-model",({tile:m,scene:L})=>{L.traverse(_=>{if(_.material){const h=new C;h.copy(_.material),_.material=h}})}),r=r||l.lruCache,t=t||l.parseQueue,e=e||l.downloadQueue,l.lruCache=r,l.downloadQueue=e,l.parseQueue=t,l.setCamera(d),n.frames.find(m=>m.id===p.frame_id).sceneMatrix.decompose(l.group.position,l.group.quaternion,l.group.scale),a.add(l.group),x.push(l)})}),T(),window.addEventListener("resize",T,!1);const i=new D;i.add(g,"errorTarget",0,100),i.add(g,"slopeDisplay",["NONE","OVERLAY","SOLID"]).onChange(o=>{o!=="NONE"?x.forEach(n=>{const c=n.getPluginByName("TEXTURE_OVERLAY_PLUGIN");c.hasLayer("slopeLayer")||c.registerLayer("slopeLayer",s),n.forEachLoadedModel(C=>{C.traverse(p=>{p.material&&(p.material.displayAsOverlay=o==="OVERLAY",p.material.needsUpdate=!0)})})}):x.forEach(n=>{n.getPluginByName("TEXTURE_OVERLAY_PLUGIN").unregisterLayer("slopeLayer")})}),i.open()}function T(){d.aspect=window.innerWidth/window.innerHeight,d.updateProjectionMatrix(),u.setSize(window.innerWidth,window.innerHeight),u.setPixelRatio(window.devicePixelRatio)}function R(){requestAnimationFrame(R),f.update(),d.updateMatrixWorld(),x.forEach(a=>{a.errorTarget=g.errorTarget,a.setResolutionFromRenderer(d,u),a.update()}),u.render(A,d)} diff --git a/example/bundle/assets/lil-gui.module.min-NsHmRZWc.js b/example/bundle/assets/lil-gui.module.min-NsHmRZWc.js new file mode 100644 index 000000000..03b8fcb3e --- /dev/null +++ b/example/bundle/assets/lil-gui.module.min-NsHmRZWc.js @@ -0,0 +1,10 @@ +import{k as p,n as y,m as ht,p as J,d as pt,i as gt,aG as mt}from"./three.module-C94OeYjd.js";const M=new ht,K=new p,vt={};function bt(o){const{x:t,y:i,z:e}=o;o.x=e,o.y=t,o.z=i}function At(o){return-(o-Math.PI/2)}function dt(o){return-o+Math.PI/2}function ft(o,t,i={}){return M.theta=t,M.phi=dt(o),K.setFromSpherical(M),M.setFromVector3(K),i.lat=At(M.phi),i.lon=M.theta,i}function q(o,t="E",i="W"){const e=o<0?i:t;o=Math.abs(o);const s=~~o,n=(o-s)*60,r=~~n,h=~~((n-r)*60);return`${s}° ${r}' ${h}" ${e}`}function Vt(o,t,i=!1){const e=ft(o,t,vt);let s,n;return i?(s=`${(y.RAD2DEG*e.lat).toFixed(4)}°`,n=`${(y.RAD2DEG*e.lon).toFixed(4)}°`):(s=q(y.RAD2DEG*e.lat,"N","S"),n=q(y.RAD2DEG*e.lon,"E","W")),`${s} ${n}`}const Q=new ht,$=new p,A=new p,Y=new p,wt=new p,S=new J,_=new J,N=new pt,g=new mt,tt=new p,it=new p,O=new p,T=new p,et=new gt,yt=1e-12,xt=.1,st=0,nt=1,rt=2;class _t{constructor(t=1,i=1,e=1){this.radius=new p(t,i,e)}intersectRay(t,i){return S.makeScale(...this.radius).invert(),N.center.set(0,0,0),N.radius=1,et.copy(t).applyMatrix4(S),et.intersectSphere(N,i)?(S.makeScale(...this.radius),i.applyMatrix4(S),i):null}getEastNorthUpFrame(t,i,e){return this.getEastNorthUpAxes(t,i,tt,it,O,T),e.makeBasis(tt,it,O).setPosition(T)}getEastNorthUpAxes(t,i,e,s,n,r=T){this.getCartographicToPosition(t,i,0,r),this.getCartographicToNormal(t,i,n),e.set(-r.y,r.x,0).normalize(),s.crossVectors(n,e).normalize()}getNorthernTangent(t,i,e,s=wt){return console.log("Ellipsoid: getNorthernTangent has been deprecated. Use getEastNorthUpAxes instead."),this.getEastNorthUpAxes(t,i,s,e,O),s.multiplyScalar(-1),e}getAzElRollFromRotationMatrix(t,i,e,s,n=st){return n===nt?(g.set(-Math.PI/2,0,0,"XYZ"),_.makeRotationFromEuler(g).premultiply(e)):n===rt?(g.set(-Math.PI/2,0,Math.PI,"XYZ"),_.makeRotationFromEuler(g).premultiply(e)):_.copy(e),this.getEastNorthUpFrame(t,i,S).invert(),_.premultiply(S),g.setFromRotationMatrix(_,"ZXY"),s.azimuth=-g.z,s.elevation=g.x,s.roll=g.y,s}getRotationMatrixFromAzElRoll(t,i,e,s,n,r,c=st){return this.getEastNorthUpFrame(t,i,S),g.set(s,n,-e,"ZXY"),r.makeRotationFromEuler(g).premultiply(S).setPosition(0,0,0),c===nt?(g.set(Math.PI/2,0,0,"XYZ"),_.makeRotationFromEuler(g),r.multiply(_)):c===rt&&(g.set(-Math.PI/2,0,Math.PI,"XYZ"),_.makeRotationFromEuler(g),r.multiply(_)),r}getCartographicToPosition(t,i,e,s){this.getCartographicToNormal(t,i,$);const n=this.radius;A.copy($),A.x*=n.x**2,A.y*=n.y**2,A.z*=n.z**2;const r=Math.sqrt($.dot(A));return A.divideScalar(r),s.copy(A).addScaledVector($,e)}getPositionToCartographic(t,i){this.getPositionToSurfacePoint(t,A),this.getPositionToNormal(t,$);const e=Y.subVectors(t,A);return i.lon=Math.atan2($.y,$.x),i.lat=Math.asin($.z),i.height=Math.sign(e.dot(t))*e.length(),i}getCartographicToNormal(t,i,e){return Q.set(1,dt(t),i),e.setFromSpherical(Q).normalize(),bt(e),e}getPositionToNormal(t,i){const e=this.radius;return i.copy(t),i.x/=e.x**2,i.y/=e.y**2,i.z/=e.z**2,i.normalize(),i}getPositionToSurfacePoint(t,i){const e=this.radius,s=1/e.x**2,n=1/e.y**2,r=1/e.z**2,c=t.x*t.x*s,h=t.y*t.y*n,d=t.z*t.z*r,l=c+h+d,u=Math.sqrt(1/l),a=A.copy(t).multiplyScalar(u);if(lyt);return i.set(t.x*m,t.y*b,t.z*E)}calculateHorizonDistance(t,i){const e=this.calculateEffectiveRadius(t);return Math.sqrt(2*e*i+i**2)}calculateEffectiveRadius(t){const i=this.radius.x,s=1-this.radius.z**2/i**2,n=t*y.DEG2RAD,r=Math.sin(n)**2;return i/Math.sqrt(1-s*r)}getPositionElevation(t){this.getPositionToSurfacePoint(t,A);const i=Y.subVectors(t,A);return Math.sign(i.dot(t))*i.length()}copy(t){return this.radius.copy(t.radius),this}clone(){return new this.constructor().copy(this)}}const C=Math.PI,I=C/2,z=new p,F=new p,D=new p,ot=new J;let P=0;const G=[];function Et(o=!1){return o?(G[P]||(G[P]=new p),P++,G[P-1]):new p}function lt(){P=0}class It extends _t{constructor(t,i,e,s=-I,n=I,r=0,c=2*C,h=0,d=0){super(t,i,e),this.latStart=s,this.latEnd=n,this.lonStart=r,this.lonEnd=c,this.heightStart=h,this.heightEnd=d}_getPoints(t=!1){const{latStart:i,latEnd:e,lonStart:s,lonEnd:n,heightStart:r,heightEnd:c}=this,h=y.mapLinear(.5,0,1,i,e),d=y.mapLinear(.5,0,1,s,n),l=Math.floor(s/I)*I,u=[[-C/2,0],[C/2,0],[0,l],[0,l+C/2],[0,l+C],[0,l+3*C/2],[i,n],[e,n],[i,s],[e,s],[0,s],[0,n],[h,d],[i,d],[e,d],[h,s],[h,n]],a=[],w=u.length;for(let v=0;v<=1;v++){const k=y.mapLinear(v,0,1,r,c);for(let f=0,L=w;f=i&&m<=e&&b>=s&&b<=n){const E=Et(t);a.push(E),this.getCartographicToPosition(m,b,k,E)}}}return a}getBoundingBox(t,i){lt();const{latStart:e,latEnd:s,lonStart:n,lonEnd:r}=this;if(s-e{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}}function j(o){let t,i;return(t=o.match(/(#|0x)?([a-f0-9]{6})/i))?i=t[2]:(t=o.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/))?i=parseInt(t[1]).toString(16).padStart(2,0)+parseInt(t[2]).toString(16).padStart(2,0)+parseInt(t[3]).toString(16).padStart(2,0):(t=o.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i))&&(i=t[1]+t[1]+t[2]+t[2]+t[3]+t[3]),!!i&&"#"+i}const St={isPrimitive:!0,match:o=>typeof o=="string",fromHexString:j,toHexString:j},V={isPrimitive:!0,match:o=>typeof o=="number",fromHexString:o=>parseInt(o.substring(1),16),toHexString:o=>"#"+o.toString(16).padStart(6,0)},Ct={isPrimitive:!1,match:Array.isArray,fromHexString(o,t,i=1){const e=V.fromHexString(o);t[0]=(e>>16&255)/255*i,t[1]=(e>>8&255)/255*i,t[2]=(255&e)/255*i},toHexString:([o,t,i],e=1)=>V.toHexString(o*(e=255/e)<<16^t*e<<8^i*e<<0)},kt={isPrimitive:!1,match:o=>Object(o)===o,fromHexString(o,t,i=1){const e=V.fromHexString(o);t.r=(e>>16&255)/255*i,t.g=(e>>8&255)/255*i,t.b=(255&e)/255*i},toHexString:({r:o,g:t,b:i},e=1)=>V.toHexString(o*(e=255/e)<<16^t*e<<8^i*e<<0)},Lt=[St,V,Ct,kt];class Mt extends x{constructor(t,i,e,s){var n;super(t,i,e,"color"),this.$input=document.createElement("input"),this.$input.setAttribute("type","color"),this.$input.setAttribute("tabindex",-1),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$text=document.createElement("input"),this.$text.setAttribute("type","text"),this.$text.setAttribute("spellcheck","false"),this.$text.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=(n=this.initialValue,Lt.find(r=>r.match(n))),this._rgbScale=s,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const r=j(this.$text.value);r&&this._setValueFromHexString(r)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(t){if(this._format.isPrimitive){const i=this._format.fromHexString(t);this.setValue(i)}else this._format.fromHexString(t,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(t){return this._setValueFromHexString(t),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class X extends x{constructor(t,i,e){super(t,i,e,"function"),this.$button=document.createElement("button"),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener("click",s=>{s.preventDefault(),this.getValue().call(this.object)}),this.$button.addEventListener("touchstart",()=>{},{passive:!0}),this.$disable=this.$button}}class Ft extends x{constructor(t,i,e,s,n,r){super(t,i,e,"number"),this._initInput(),this.min(s),this.max(n);const c=r!==void 0;this.step(c?r:this._getImplicitStep(),c),this.updateDisplay()}decimals(t){return this._decimals=t,this.updateDisplay(),this}min(t){return this._min=t,this._onUpdateMinMax(),this}max(t){return this._max=t,this._onUpdateMinMax(),this}step(t,i=!0){return this._step=t,this._stepExplicit=i,this}updateDisplay(){const t=this.getValue();if(this._hasSlider){let i=(t-this._min)/(this._max-this._min);i=Math.max(0,Math.min(i,1)),this.$fill.style.width=100*i+"%"}return this._inputFocused||(this.$input.value=this._decimals===void 0?t:t.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement("input"),this.$input.setAttribute("type","number"),this.$input.setAttribute("step","any"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$widget.appendChild(this.$input),this.$disable=this.$input;const t=l=>{const u=parseFloat(this.$input.value);isNaN(u)||(this._snapClampSetValue(u+l),this.$input.value=this.getValue())};let i,e,s,n,r,c=!1;const h=l=>{if(c){const u=l.clientX-i,a=l.clientY-e;Math.abs(a)>5?(l.preventDefault(),this.$input.blur(),c=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(u)>5&&d()}if(!c){const u=l.clientY-s;r-=u*this._step*this._arrowKeyMultiplier(l),n+r>this._max?r=this._max-n:n+r{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",d)};this.$input.addEventListener("input",()=>{let l=parseFloat(this.$input.value);isNaN(l)||(this._stepExplicit&&(l=this._snap(l)),this.setValue(this._clamp(l)))}),this.$input.addEventListener("keydown",l=>{l.code==="Enter"&&this.$input.blur(),l.code==="ArrowUp"&&(l.preventDefault(),t(this._step*this._arrowKeyMultiplier(l))),l.code==="ArrowDown"&&(l.preventDefault(),t(this._step*this._arrowKeyMultiplier(l)*-1))}),this.$input.addEventListener("wheel",l=>{this._inputFocused&&(l.preventDefault(),t(this._step*this._normalizeMouseWheel(l)))},{passive:!1}),this.$input.addEventListener("mousedown",l=>{i=l.clientX,e=s=l.clientY,c=!0,n=this.getValue(),r=0,window.addEventListener("mousemove",h),window.addEventListener("mouseup",d)}),this.$input.addEventListener("focus",()=>{this._inputFocused=!0}),this.$input.addEventListener("blur",()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()})}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const t=a=>{const w=this.$slider.getBoundingClientRect();let v=(k=a,f=w.left,L=w.right,m=this._min,b=this._max,(k-f)/(L-f)*(b-m)+m);var k,f,L,m,b;this._snapClampSetValue(v)},i=a=>{t(a.clientX)},e=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",e)};let s,n,r=!1;const c=a=>{a.preventDefault(),this._setDraggingStyle(!0),t(a.touches[0].clientX),r=!1},h=a=>{if(r){const w=a.touches[0].clientX-s,v=a.touches[0].clientY-n;Math.abs(w)>Math.abs(v)?c(a):(window.removeEventListener("touchmove",h),window.removeEventListener("touchend",d))}else a.preventDefault(),t(a.touches[0].clientX)},d=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",h),window.removeEventListener("touchend",d)},l=this._callOnFinishChange.bind(this);let u;this.$slider.addEventListener("mousedown",a=>{this._setDraggingStyle(!0),t(a.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",e)}),this.$slider.addEventListener("touchstart",a=>{a.touches.length>1||(this._hasScrollBar?(s=a.touches[0].clientX,n=a.touches[0].clientY,r=!0):c(a),window.addEventListener("touchmove",h,{passive:!1}),window.addEventListener("touchend",d))},{passive:!1}),this.$slider.addEventListener("wheel",a=>{if(Math.abs(a.deltaX)this._max&&(t=this._max),t}_snapClampSetValue(t){this.setValue(this._clamp(this._snap(t)))}get _hasScrollBar(){const t=this.parent.root.$children;return t.scrollHeight>t.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class Dt extends x{constructor(t,i,e,s){super(t,i,e,"option"),this.$select=document.createElement("select"),this.$select.setAttribute("aria-labelledby",this.$name.id),this.$display=document.createElement("div"),this.$display.classList.add("display"),this._values=Array.isArray(s)?s:Object.values(s),this._names=Array.isArray(s)?s:Object.keys(s),this._names.forEach(n=>{const r=document.createElement("option");r.innerHTML=n,this.$select.appendChild(r)}),this.$select.addEventListener("change",()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener("focus",()=>{this.$display.classList.add("focus")}),this.$select.addEventListener("blur",()=>{this.$display.classList.remove("focus")}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.updateDisplay()}updateDisplay(){const t=this.getValue(),i=this._values.indexOf(t);return this.$select.selectedIndex=i,this.$display.innerHTML=i===-1?t:this._names[i],this}}class zt extends x{constructor(t,i,e){super(t,i,e,"string"),this.$input=document.createElement("input"),this.$input.setAttribute("type","text"),this.$input.setAttribute("aria-labelledby",this.$name.id),this.$input.addEventListener("input",()=>{this.setValue(this.$input.value)}),this.$input.addEventListener("keydown",s=>{s.code==="Enter"&&this.$input.blur()}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}}let at=!1;class ct{constructor({parent:t,autoPlace:i=t===void 0,container:e,width:s,title:n="Controls",injectStyles:r=!0,touchStyles:c=!0}={}){if(this.parent=t,this.root=t?t.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement("div"),this.domElement.classList.add("lil-gui"),this.$title=document.createElement("div"),this.$title.classList.add("title"),this.$title.setAttribute("role","button"),this.$title.setAttribute("aria-expanded",!0),this.$title.setAttribute("tabindex",0),this.$title.addEventListener("click",()=>this.openAnimated(this._closed)),this.$title.addEventListener("keydown",h=>{h.code!=="Enter"&&h.code!=="Space"||(h.preventDefault(),this.$title.click())}),this.$title.addEventListener("touchstart",()=>{},{passive:!0}),this.$children=document.createElement("div"),this.$children.classList.add("children"),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(n),c&&this.domElement.classList.add("allow-touch-styles"),this.parent)return this.parent.children.push(this),this.parent.folders.push(this),void this.parent.$children.appendChild(this.domElement);this.domElement.classList.add("root"),!at&&r&&(function(h){const d=document.createElement("style");d.innerHTML=h;const l=document.querySelector("head link[rel=stylesheet], head style");l?document.head.insertBefore(d,l):document.head.appendChild(d)}('.lil-gui{--background-color:#1f1f1f;--text-color:#ebebeb;--title-background-color:#111;--title-text-color:#ebebeb;--widget-color:#424242;--hover-color:#4f4f4f;--focus-color:#595959;--number-color:#2cc9ff;--string-color:#a2db3c;--font-size:11px;--input-font-size:11px;--font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;--font-family-mono:Menlo,Monaco,Consolas,"Droid Sans Mono",monospace;--padding:4px;--spacing:4px;--widget-height:20px;--name-width:45%;--slider-knob-width:2px;--slider-input-width:27%;--color-input-width:27%;--slider-input-min-width:45px;--color-input-min-width:45px;--folder-indent:7px;--widget-padding:0 0 0 3px;--widget-border-radius:2px;--checkbox-size:calc(var(--widget-height)*0.75);--scrollbar-width:5px;background-color:var(--background-color);color:var(--text-color);font-family:var(--font-family);font-size:var(--font-size);font-style:normal;font-weight:400;line-height:1;text-align:left;touch-action:manipulation;user-select:none;-webkit-user-select:none}.lil-gui,.lil-gui *{box-sizing:border-box;margin:0;padding:0}.lil-gui.root{display:flex;flex-direction:column;width:var(--width,245px)}.lil-gui.root>.title{background:var(--title-background-color);color:var(--title-text-color)}.lil-gui.root>.children{overflow-x:hidden;overflow-y:auto}.lil-gui.root>.children::-webkit-scrollbar{background:var(--background-color);height:var(--scrollbar-width);width:var(--scrollbar-width)}.lil-gui.root>.children::-webkit-scrollbar-thumb{background:var(--focus-color);border-radius:var(--scrollbar-width)}.lil-gui.force-touch-styles{--widget-height:28px;--padding:6px;--spacing:6px;--font-size:13px;--input-font-size:16px;--folder-indent:10px;--scrollbar-width:7px;--slider-input-min-width:50px;--color-input-min-width:65px}.lil-gui.autoPlace{max-height:100%;position:fixed;right:15px;top:0;z-index:1001}.lil-gui .controller{align-items:center;display:flex;margin:var(--spacing) 0;padding:0 var(--padding)}.lil-gui .controller.disabled{opacity:.5}.lil-gui .controller.disabled,.lil-gui .controller.disabled *{pointer-events:none!important}.lil-gui .controller>.name{flex-shrink:0;line-height:var(--widget-height);min-width:var(--name-width);padding-right:var(--spacing);white-space:pre}.lil-gui .controller .widget{align-items:center;display:flex;min-height:var(--widget-height);position:relative;width:100%}.lil-gui .controller.string input{color:var(--string-color)}.lil-gui .controller.boolean .widget{cursor:pointer}.lil-gui .controller.color .display{border-radius:var(--widget-border-radius);height:var(--widget-height);position:relative;width:100%}.lil-gui .controller.color input[type=color]{cursor:pointer;height:100%;opacity:0;width:100%}.lil-gui .controller.color input[type=text]{flex-shrink:0;font-family:var(--font-family-mono);margin-left:var(--spacing);min-width:var(--color-input-min-width);width:var(--color-input-width)}.lil-gui .controller.option select{max-width:100%;opacity:0;position:absolute;width:100%}.lil-gui .controller.option .display{background:var(--widget-color);border-radius:var(--widget-border-radius);height:var(--widget-height);line-height:var(--widget-height);max-width:100%;overflow:hidden;padding-left:.55em;padding-right:1.75em;pointer-events:none;position:relative;word-break:break-all}.lil-gui .controller.option .display.active{background:var(--focus-color)}.lil-gui .controller.option .display:after{bottom:0;content:"↕";font-family:lil-gui;padding-right:.375em;position:absolute;right:0;top:0}.lil-gui .controller.option .widget,.lil-gui .controller.option select{cursor:pointer}.lil-gui .controller.number input{color:var(--number-color)}.lil-gui .controller.number.hasSlider input{flex-shrink:0;margin-left:var(--spacing);min-width:var(--slider-input-min-width);width:var(--slider-input-width)}.lil-gui .controller.number .slider{background-color:var(--widget-color);border-radius:var(--widget-border-radius);cursor:ew-resize;height:var(--widget-height);overflow:hidden;padding-right:var(--slider-knob-width);touch-action:pan-y;width:100%}.lil-gui .controller.number .slider.active{background-color:var(--focus-color)}.lil-gui .controller.number .slider.active .fill{opacity:.95}.lil-gui .controller.number .fill{border-right:var(--slider-knob-width) solid var(--number-color);box-sizing:content-box;height:100%}.lil-gui-dragging .lil-gui{--hover-color:var(--widget-color)}.lil-gui-dragging *{cursor:ew-resize!important}.lil-gui-dragging.lil-gui-vertical *{cursor:ns-resize!important}.lil-gui .title{--title-height:calc(var(--widget-height) + var(--spacing)*1.25);-webkit-tap-highlight-color:transparent;text-decoration-skip:objects;cursor:pointer;font-weight:600;height:var(--title-height);line-height:calc(var(--title-height) - 4px);outline:none;padding:0 var(--padding)}.lil-gui .title:before{content:"▾";display:inline-block;font-family:lil-gui;padding-right:2px}.lil-gui .title:active{background:var(--title-background-color);opacity:.75}.lil-gui.root>.title:focus{text-decoration:none!important}.lil-gui.closed>.title:before{content:"▸"}.lil-gui.closed>.children{opacity:0;transform:translateY(-7px)}.lil-gui.closed:not(.transition)>.children{display:none}.lil-gui.transition>.children{overflow:hidden;pointer-events:none;transition-duration:.3s;transition-property:height,opacity,transform;transition-timing-function:cubic-bezier(.2,.6,.35,1)}.lil-gui .children:empty:before{content:"Empty";display:block;font-style:italic;height:var(--widget-height);line-height:var(--widget-height);margin:var(--spacing) 0;opacity:.5;padding:0 var(--padding)}.lil-gui.root>.children>.lil-gui>.title{border-width:0;border-bottom:1px solid var(--widget-color);border-left:0 solid var(--widget-color);border-right:0 solid var(--widget-color);border-top:1px solid var(--widget-color);transition:border-color .3s}.lil-gui.root>.children>.lil-gui.closed>.title{border-bottom-color:transparent}.lil-gui+.controller{border-top:1px solid var(--widget-color);margin-top:0;padding-top:var(--spacing)}.lil-gui .lil-gui .lil-gui>.title{border:none}.lil-gui .lil-gui .lil-gui>.children{border:none;border-left:2px solid var(--widget-color);margin-left:var(--folder-indent)}.lil-gui .lil-gui .controller{border:none}.lil-gui input{-webkit-tap-highlight-color:transparent;background:var(--widget-color);border:0;border-radius:var(--widget-border-radius);color:var(--text-color);font-family:var(--font-family);font-size:var(--input-font-size);height:var(--widget-height);outline:none;width:100%}.lil-gui input:disabled{opacity:1}.lil-gui input[type=number],.lil-gui input[type=text]{padding:var(--widget-padding)}.lil-gui input[type=number]:focus,.lil-gui input[type=text]:focus{background:var(--focus-color)}.lil-gui input::-webkit-inner-spin-button,.lil-gui input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.lil-gui input[type=number]{-moz-appearance:textfield}.lil-gui input[type=checkbox]{appearance:none;-webkit-appearance:none;border-radius:var(--widget-border-radius);cursor:pointer;height:var(--checkbox-size);text-align:center;width:var(--checkbox-size)}.lil-gui input[type=checkbox]:checked:before{content:"✓";font-family:lil-gui;font-size:var(--checkbox-size);line-height:var(--checkbox-size)}.lil-gui button{-webkit-tap-highlight-color:transparent;background:var(--widget-color);border:1px solid var(--widget-color);border-radius:var(--widget-border-radius);color:var(--text-color);cursor:pointer;font-family:var(--font-family);font-size:var(--font-size);height:var(--widget-height);line-height:calc(var(--widget-height) - 4px);outline:none;text-align:center;text-transform:none;width:100%}.lil-gui button:active{background:var(--focus-color)}@font-face{font-family:lil-gui;src:url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff")}@media (pointer:coarse){.lil-gui.allow-touch-styles{--widget-height:28px;--padding:6px;--spacing:6px;--font-size:13px;--input-font-size:16px;--folder-indent:10px;--scrollbar-width:7px;--slider-input-min-width:50px;--color-input-min-width:65px}}@media (hover:hover){.lil-gui .controller.color .display:hover:before{border:1px solid #fff9;border-radius:var(--widget-border-radius);bottom:0;content:" ";display:block;left:0;position:absolute;right:0;top:0}.lil-gui .controller.option .display.focus{background:var(--focus-color)}.lil-gui .controller.option .widget:hover .display{background:var(--hover-color)}.lil-gui .controller.number .slider:hover{background-color:var(--hover-color)}body:not(.lil-gui-dragging) .lil-gui .title:hover{background:var(--title-background-color);opacity:.85}.lil-gui .title:focus{text-decoration:underline var(--focus-color)}.lil-gui input:hover{background:var(--hover-color)}.lil-gui input:active{background:var(--focus-color)}.lil-gui input[type=checkbox]:focus{box-shadow:inset 0 0 0 1px var(--focus-color)}.lil-gui button:hover{background:var(--hover-color);border-color:var(--hover-color)}.lil-gui button:focus{border-color:var(--focus-color)}}'),at=!0),e?e.appendChild(this.domElement):i&&(this.domElement.classList.add("autoPlace"),document.body.appendChild(this.domElement)),s&&this.domElement.style.setProperty("--width",s+"px"),this.domElement.addEventListener("keydown",h=>h.stopPropagation()),this.domElement.addEventListener("keyup",h=>h.stopPropagation())}add(t,i,e,s,n){if(Object(e)===e)return new Dt(this,t,i,e);const r=t[i];switch(typeof r){case"number":return new Ft(this,t,i,e,s,n);case"boolean":return new $t(this,t,i);case"string":return new zt(this,t,i);case"function":return new X(this,t,i)}console.error(`gui.add failed + property:`,i,` + object:`,t,` + value:`,r)}addColor(t,i,e=1){return new Mt(this,t,i,e)}addFolder(t){return new ct({parent:this,title:t})}load(t,i=!0){return t.controllers&&this.controllers.forEach(e=>{e instanceof X||e._name in t.controllers&&e.load(t.controllers[e._name])}),i&&t.folders&&this.folders.forEach(e=>{e._title in t.folders&&e.load(t.folders[e._title])}),this}save(t=!0){const i={controllers:{},folders:{}};return this.controllers.forEach(e=>{if(!(e instanceof X)){if(e._name in i.controllers)throw new Error(`Cannot save GUI with duplicate property "${e._name}"`);i.controllers[e._name]=e.save()}}),t&&this.folders.forEach(e=>{if(e._title in i.folders)throw new Error(`Cannot save GUI with duplicate folder "${e._title}"`);i.folders[e._title]=e.save()}),i}open(t=!0){return this._closed=!t,this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}show(t=!0){return this._hidden=!t,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(t=!0){return this._closed=!t,this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const i=this.$children.clientHeight;this.$children.style.height=i+"px",this.domElement.classList.add("transition");const e=n=>{n.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",e))};this.$children.addEventListener("transitionend",e);const s=t?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!t),requestAnimationFrame(()=>{this.$children.style.height=s+"px"})}),this}title(t){return this._title=t,this.$title.innerHTML=t,this}reset(t=!0){return(t?this.controllersRecursive():this.controllers).forEach(i=>i.reset()),this}onChange(t){return this._onChange=t,this}_callOnChange(t){this.parent&&this.parent._callOnChange(t),this._onChange!==void 0&&this._onChange.call(this,{object:t.object,property:t.property,value:t.getValue(),controller:t})}onFinishChange(t){return this._onFinishChange=t,this}_callOnFinishChange(t){this.parent&&this.parent._callOnFinishChange(t),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:t.object,property:t.property,value:t.getValue(),controller:t})}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(t=>t.destroy())}controllersRecursive(){let t=Array.from(this.controllers);return this.folders.forEach(i=>{t=t.concat(i.controllersRecursive())}),t}foldersRecursive(){let t=Array.from(this.folders);return this.folders.forEach(i=>{t=t.concat(i.foldersRecursive())}),t}}export{nt as C,_t as E,It as a,ct as g,Vt as t}; diff --git a/example/bundle/assets/mars-CdP0FE2w.js b/example/bundle/assets/mars-CdP0FE2w.js new file mode 100644 index 000000000..8c1cc2414 --- /dev/null +++ b/example/bundle/assets/mars-CdP0FE2w.js @@ -0,0 +1 @@ +import{ai as _,S as h,W as x,a as P,D as S,A as B,G as T}from"./three.module-C94OeYjd.js";import{F as y,d as m}from"./FlyOrbitControls-D1sYBrL1.js";import{g as C}from"./lil-gui.module.min-NsHmRZWc.js";import{T as p}from"./TilesRenderer-DQOLA18N.js";import"./EllipsoidRegionHelper-7avvRq-k.js";import"./OrbitControls-bHRTZZ2i.js";import"./B3DMLoader-B0T2UZ_1.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./GLTFLoader-C77rxX9H.js";import"./PNTSLoader-BUgecSBY.js";import"./I3DMLoader-C4TPl3Dp.js";import"./CMPTLoader-CXF13c0w.js";import"./GLTFExtensionLoader-Qt9Ghhze.js";let t,n,r,o,e,i;const a={errorTarget:12,displayBoxBounds:!1,fog:!1};D();g();function D(){const u=new _(14208704,.0075,250);r=new h,o=new x({antialias:!0}),o.setPixelRatio(window.devicePixelRatio),o.setSize(window.innerWidth,window.innerHeight),o.setClearColor(14208704),document.body.appendChild(o.domElement),o.domElement.tabIndex=1,t=new P(60,window.innerWidth/window.innerHeight,1,4e3),t.position.set(20,10,20),n=new y(t,o.domElement),n.screenSpacePanning=!1,n.minDistance=1,n.maxDistance=2e3,n.maxPolarAngle=Math.PI/2,n.baseSpeed=.1,n.fastSpeed=.2;const l=new S(16777215);l.position.set(1,2,3),r.add(l);const w=new B(16777215,.2);r.add(w);const d=new T;d.rotation.set(Math.PI/2,0,0),r.add(d),e=new p("https://raw.githubusercontent.com/NASA-AMMOS/3DTilesSampleData/master/msl-dingo-gap/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_colorize_tileset.json"),e.registerPlugin(new m),e.fetchOptions.mode="cors",e.lruCache.minSize=900,e.lruCache.maxSize=1300,e.errorTarget=12,i=new p("https://raw.githubusercontent.com/NASA-AMMOS/3DTilesSampleData/master/msl-dingo-gap/0528_0260184_to_s64o256_colorize/0528_0260184_to_s64o256_sky/0528_0260184_to_s64o256_sky_tileset.json"),i.registerPlugin(new m),i.fetchOptions.mode="cors",i.lruCache=e.lruCache,d.add(e.group,i.group),c(),window.addEventListener("resize",c,!1);const s=new C;s.add(a,"fog").onChange(f=>{r.fog=f?u:null}),s.add(a,"displayBoxBounds"),s.add(a,"errorTarget",0,100),s.open()}function c(){t.aspect=window.innerWidth/window.innerHeight,t.updateProjectionMatrix(),o.setSize(window.innerWidth,window.innerHeight),o.setPixelRatio(window.devicePixelRatio)}function g(){requestAnimationFrame(g),t.updateMatrixWorld(),e.errorTarget=a.errorTarget,e.getPluginByName("DEBUG_TILES_PLUGIN").displayBoxBounds=a.displayBoxBounds,i.getPluginByName("DEBUG_TILES_PLUGIN").displayBoxBounds=a.displayBoxBounds,e.setCamera(t),e.setResolutionFromRenderer(t,o),e.update(),i.setCamera(t),i.setResolutionFromRenderer(t,o),i.update(),o.render(r,t)} diff --git a/example/bundle/assets/metadata-DAMo4GlH.js b/example/bundle/assets/metadata-DAMo4GlH.js new file mode 100644 index 000000000..3e5c72705 --- /dev/null +++ b/example/bundle/assets/metadata-DAMo4GlH.js @@ -0,0 +1,187 @@ +import{p as Ne,ap as Me,ak as we,k as ee,V as E,O as ve,g as Oe,ae as Le,aq as ie,W as Fe,ar as oe,b as Ve,as as je,at as Be,au as Ge,av as Ie,aw as He,F as $e,S as ze,a as Ye,D as ke,A as Xe,G as qe,R as We,ax as Ke,d as Qe}from"./three.module-C94OeYjd.js";import{G as Ze}from"./GLTFLoader-C77rxX9H.js";import{g as Je}from"./lil-gui.module.min-NsHmRZWc.js";import{E as et}from"./EnvironmentControls-CTZuopjd.js";import{T as tt}from"./TilesRenderer-DQOLA18N.js";import{C as st}from"./CesiumIonAuthPlugin-CBH0S8UR.js";import"./B3DMLoader-B0T2UZ_1.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./PNTSLoader-BUgecSBY.js";import"./I3DMLoader-C4TPl3Dp.js";import"./CMPTLoader-CXF13c0w.js";import"./GLTFExtensionLoader-Qt9Ghhze.js";import"./GoogleCloudAuthPlugin-CXITux-L.js";class te{constructor(e,t,s,r){te.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,s,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let s=0;s<4;s++)this.elements[s]=e[s+t];return this}set(e,t,s,r){const i=this.elements;return i[0]=e,i[1]=s,i[2]=t,i[3]=r,this}}function T(n,e,t){return n&&e in n?n[e]:t}function Re(n){return n!=="BOOLEAN"&&n!=="STRING"&&n!=="ENUM"}function rt(n){return/^FLOAT/.test(n)}function j(n){return/^VEC/.test(n)}function B(n){return/^MATRIX/.test(n)}function Ue(n,e,t,s=null){return B(t)||j(t)?s.fromArray(n,e):n[e]}function Q(n){const{type:e,componentType:t}=n;switch(e){case"SCALAR":return t==="INT64"?0n:0;case"VEC2":return new E;case"VEC3":return new ee;case"VEC4":return new we;case"MAT2":return new te;case"MAT3":return new Me;case"MAT4":return new Ne;case"BOOLEAN":return!1;case"STRING":return"";case"ENUM":return 0}}function ae(n,e){if(e==null)return!1;switch(n){case"SCALAR":return typeof e=="number"||typeof e=="bigint";case"VEC2":return e.isVector2;case"VEC3":return e.isVector3;case"VEC4":return e.isVector4;case"MAT2":return e.isMatrix2;case"MAT3":return e.isMatrix3;case"MAT4":return e.isMatrix4;case"BOOLEAN":return typeof e=="boolean";case"STRING":return typeof e=="string";case"ENUM":return typeof e=="number"||typeof e=="bigint"}throw new Error("ClassProperty: invalid type.")}function V(n,e=null){switch(n){case"INT8":return Int8Array;case"INT16":return Int16Array;case"INT32":return Int32Array;case"INT64":return BigInt64Array;case"UINT8":return Uint8Array;case"UINT16":return Uint16Array;case"UINT32":return Uint32Array;case"UINT64":return BigUint64Array;case"FLOAT32":return Float32Array;case"FLOAT64":return Float64Array}switch(e){case"BOOLEAN":return Uint8Array;case"STRING":return Uint8Array}throw new Error("ClassProperty: invalid type.")}function nt(n,e=null){if(n.array){e=e&&Array.isArray(e)?e:[],e.length=n.count;for(let s=0,r=e.length;so.value===r);return i===null?"":i.name}}adjustValueScaleOffset(e){return Re(this.type)?at(this,e):e}}class re{constructor(e,t={},s={},r=null){this.definition=e,this.class=t[e.class],this.className=e.class,this.enums=s,this.data=r,this.name="name"in e?e.name:null,this.properties=null}getPropertyNames(){return Object.keys(this.class.properties)}includesData(e){return!!this.definition.properties[e]}dispose(){}_initProperties(e=Y){const t={};for(const s in this.class.properties)t[s]=new e(this.enums,this.class.properties[s],this.definition.properties[s]);this.properties=t}}class lt extends Y{constructor(e,t,s=null){super(e,t,s),this.attribute=s.attribute}}class ct extends re{constructor(...e){super(...e),this.isPropertyAttributeAccessor=!0,this._initProperties(lt)}getData(e,t,s={}){const r=this.properties;H(r,s);for(const i in r)s[i]=this.getPropertyValue(i,e,t,s[i]);return s}getPropertyValue(e,t,s,r=null){if(t>=this.count)throw new Error("PropertyAttributeAccessor: Requested index is outside the range of the buffer.");const i=this.properties[e],o=i.type;if(i){if(!this.definition.properties[e])return i.resolveDefault(r)}else throw new Error("PropertyAttributeAccessor: Requested class property does not exist.");r=i.shapeToProperty(r);const a=s.getAttribute(i.attribute.toLowerCase());if(B(o)){const u=r.elements;for(let c=0,d=u.length;c>m&1)===1}return r}getPropertyValue(e,t,s=null){if(t>=this.count)throw new Error("PropertyTableAccessor: Requested index is outside the range of the table.");const r=this.properties[e];if(r){if(!this.definition.properties[e])return r.resolveDefault(s)}else throw new Error("PropertyTableAccessor: Requested property does not exist.");const i=r.array,o=this.data,a=r.getArrayLengthFromId(o,t);if(s=r.shapeToProperty(s,a),i)for(let u=0,c=s.length;u=165,yt=parseInt(Ie)>=166,N=new He,le=new we,q=new E,U=new class{constructor(){this._renderer=new Fe,this._target=new oe(1,1),this._texTarget=new oe,this._quad=new Tt(new Ve({blending:je,blendDst:Be,blendSrc:Ge,uniforms:{map:{value:null},pixel:{value:new E}},vertexShader:` + void main() { + + gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); + + } + `,fragmentShader:` + uniform sampler2D map; + uniform ivec2 pixel; + + void main() { + + gl_FragColor = texelFetch( map, pixel, 0 ); + + } + `}))}increaseSizeTo(n){this._target.setSize(Math.max(this._target.width,n),1)}readDataAsync(n){const{_renderer:e,_target:t}=this;return ue?e.readRenderTargetPixelsAsync(t,0,0,n.length/4,1,n):Promise.resolve().then(()=>this.readData(n))}readData(n){const{_renderer:e,_target:t}=this;e.readRenderTargetPixels(t,0,0,n.length/4,1,n)}renderPixelToTarget(n,e,t){const{_quad:s,_renderer:r,_target:i,_texTarget:o}=this;if(yt)N.min.copy(e),N.max.copy(e),N.max.x+=1,N.max.y+=1,r.initRenderTarget(i),r.copyTextureToTexture(n,i.texture,N,t,0);else{const a=r.autoClear,u=r.getRenderTarget(),c=r.getScissorTest();r.getScissor(le),o.setSize(n.image.width,n.image.height),r.setRenderTarget(o),q.set(0,0),ue?r.copyTextureToTexture(n,o.texture,null,q):r.copyTextureToTexture(q,n,o.texture),s.material.uniforms.map.value=o.texture,s.material.uniforms.pixel.value.copy(e),r.setRenderTarget(i),r.setScissorTest(!0),r.setScissor(t.x,t.y,1,1),r.autoClear=!1,s.render(r),r.setScissorTest(c),r.setScissor(le),r.setRenderTarget(u),r.autoClear=a,o.dispose()}}},ce=new E,fe=new E,he=new E;function xt(n,e){return e===0?n.getAttribute("uv"):n.getAttribute(`uv${e}`)}function be(n,e,t=new Array(3)){let s=3*e,r=3*e+1,i=3*e+2;return n.index&&(s=n.index.getX(s),r=n.index.getX(r),i=n.index.getX(i)),t[0]=s,t[1]=r,t[2]=i,t}function Se(n,e,t,s,r){const[i,o,a]=s,u=xt(n,e);ce.fromBufferAttribute(u,i),fe.fromBufferAttribute(u,o),he.fromBufferAttribute(u,a),r.set(0,0,0).addScaledVector(ce,t.x).addScaledVector(fe,t.y).addScaledVector(he,t.z)}function Ce(n,e,t,s){const r=n.x-Math.floor(n.x),i=n.y-Math.floor(n.y),o=Math.floor(r*e%e),a=Math.floor(i*t%t);return s.set(o,a),s}const de=new E,me=new E,pe=new E;class At extends Y{constructor(e,t,s=null){super(e,t,s),this.channels=T(s,"channels",[0]),this.index=T(s,"index",null),this.texCoord=T(s,"texCoord",null),this.valueLength=parseInt(this.type.replace(/[^0-9]/g,""))||1}readDataFromBuffer(e,t,s=null){const r=this.type;if(r==="BOOLEAN"||r==="STRING")throw new Error("PropertyTextureAccessor: BOOLEAN and STRING types not supported.");return Ue(e,t*this.valueLength,r,s)}}class Et extends re{constructor(...e){super(...e),this.isPropertyTextureAccessor=!0,this._asyncRead=!1,this._initProperties(At)}getData(e,t,s,r={}){const i=this.properties;H(i,r);const o=Object.keys(i),a=o.map(u=>r[u]);return this.getPropertyValuesAtTexel(o,e,t,s,a),o.forEach((u,c)=>r[u]=a[c]),r}async getDataAsync(e,t,s,r={}){const i=this.properties;H(i,r);const o=Object.keys(i),a=o.map(u=>r[u]);return await this.getPropertyValuesAtTexelAsync(o,e,t,s,a),o.forEach((u,c)=>r[u]=a[c]),r}getPropertyValuesAtTexelAsync(...e){this._asyncRead=!0;const t=this.getPropertyValuesAtTexel(...e);return this._asyncRead=!1,t}getPropertyValuesAtTexel(e,t,s,r,i=[]){for(;i.length(l.call(this),i));return U.readData(d),l.call(this),i;function l(){for(let f=0,h=e.length;fd[4*f+P]),R=m.componentType,k=V(R,y),X=new k(I);if(new Uint8Array(X.buffer).set(C),m.array){const P=i[f];for(let D=0,De=P.length;D{e&&(e.dispose(),e.image instanceof ImageBitmap&&e.image.close())})}}class Te{constructor(e,t,s,r=null,i=null){const{schema:o,propertyTables:a=[],propertyTextures:u=[],propertyAttributes:c=[]}=e,{enums:d,classes:l}=o,f=a.map(m=>new ht(m,l,d,s));let h=[],p=[];r&&(r.propertyTextures&&(h=r.propertyTextures.map(m=>new Et(u[m],l,d,t))),r.propertyAttributes&&(p=r.propertyAttributes.map(m=>new ct(c[m],l,d)))),this.schema=o,this.tableAccessors=f,this.textureAccessors=h,this.attributeAccessors=p,this.object=i,this.textures=t,this.nodeMetadata=r}getPropertyTableData(e,t,s=null){if(!Array.isArray(e)||!Array.isArray(t))s=s||{},s=this.tableAccessors[e].getData(t,s);else{s=s||[];const r=Math.min(e.length,t.length);s.length=r;for(let i=0;is)),Array.isArray(e))return e.map(t=>{const s=this.tableAccessors[t];return{name:s.name,className:s.definition.class}});{const t=this.tableAccessors[e];return{name:t.name,className:t.definition.class}}}getPropertyTextureData(e,t,s=[]){const r=this.textureAccessors;s.length=r.length;for(let i=0;i{s[o]=c});i.push(u)}return await Promise.all(i),s}getPropertyTextureInfo(){return this.textureAccessors}getPropertyAttributeData(e,t=[]){const s=this.attributeAccessors;t.length=s.length;for(let r=0;r({name:e.name,className:e.definition.class}))}dispose(){this.textureAccessors.forEach(e=>e.dispose()),this.tableAccessors.forEach(e=>e.dispose()),this.attributeAccessors.forEach(e=>e.dispose())}}const M="EXT_structural_metadata";function _t(n,e=[]){var r;const t=((r=n.json.textures)==null?void 0:r.length)||0,s=new Array(t).fill(null);return e.forEach(({properties:i})=>{for(const o in i){const{index:a}=i[o];s[a]===null&&(s[a]=n.loadTexture(a))}}),Promise.all(s)}function gt(n,e=[]){var r;const t=((r=n.json.bufferViews)==null?void 0:r.length)||0,s=new Array(t).fill(null);return e.forEach(({properties:i})=>{for(const o in i){const{values:a,arrayOffsets:u,stringOffsets:c}=i[o];s[a]===null&&(s[a]=n.loadBufferView(a)),s[u]===null&&(s[u]=n.loadBufferView(u)),s[c]===null&&(s[c]=n.loadBufferView(c))}}),Promise.all(s)}class wt{constructor(e){this.parser=e,this.name=M}async afterRoot({scene:e,parser:t}){const s=t.json.extensionsUsed;if(!s||!s.includes(M))return;let r=null,i=t.json.extensions[M];if(i.schemaUri){const{manager:c,path:d,requestHeader:l,crossOrigin:f}=t.options,h=new URL(i.schemaUri,d).toString(),p=new $e(c);p.setCrossOrigin(f),p.setResponseType("json"),p.setRequestHeader(l),r=p.loadAsync(h).then(m=>{i={...i,schema:m}})}const[o,a]=await Promise.all([_t(t,i.propertyTextures),gt(t,i.propertyTables),r]),u=new Te(i,o,a);e.userData.structuralMetadata=u,e.traverse(c=>{if(t.associations.has(c)){const{meshes:d,primitives:l}=t.associations.get(c),f=t.json.meshes[d].primitives[l];if(f&&f.extensions&&f.extensions[M]){const h=f.extensions[M];c.userData.structuralMetadata=new Te(i,o,a,h,c)}else c.userData.structuralMetadata=u}})}}const ye=new E,xe=new E,Ae=new E;function Ft(n){return n.x>n.y&&n.x>n.z?0:n.y>n.z?1:2}class It{constructor(e,t,s){this.geometry=e,this.textures=t,this.data=s,this._asyncRead=!1,this.featureIds=s.featureIds.map(r=>{const{texture:i,...o}=r,a={label:null,propertyTable:null,nullFeatureId:null,...o};return i&&(a.texture={texCoord:0,channels:[0],...i}),a})}getTextures(){return this.textures}getFeatureInfo(){return this.featureIds}getFeaturesAsync(...e){this._asyncRead=!0;const t=this.getFeatures(...e);return this._asyncRead=!1,t}getFeatures(e,t){const{geometry:s,textures:r,featureIds:i}=this,o=new Array(i.length).fill(null),a=i.length;U.increaseSizeTo(a);const u=be(s,e),c=u[Ft(t)];for(let f=0,h=i.length;f(l(),o));return U.readData(d),l(),o;function l(){const f=new Uint32Array(1);for(let h=0,p=i.length;hd[4*h+k]);new Uint8Array(f.buffer).set(C);const R=f[0];R!==y&&(o[h]=R)}}}}dispose(){this.textures.forEach(e=>{e&&(e.dispose(),e.image instanceof ImageBitmap&&e.image.close())})}}const $="EXT_mesh_features";function Ee(n,e,t){n.traverse(s=>{if(e.associations.has(s)){const{meshes:r,primitives:i}=e.associations.get(s),o=e.json.meshes[r].primitives[i];o&&o.extensions&&o.extensions[$]&&t(s,o.extensions[$])}})}class Rt{constructor(e){this.parser=e,this.name=$}async afterRoot({scene:e,parser:t}){var a;const s=t.json.extensionsUsed;if(!s||!s.includes($))return;const r=((a=t.json.textures)==null?void 0:a.length)||0,i=new Array(r).fill(null);Ee(e,t,(u,{featureIds:c})=>{c.forEach(d=>{if(d.texture&&i[d.texture.index]===null){const l=d.texture.index;i[l]=t.loadTexture(l)}})});const o=await Promise.all(i);Ee(e,t,(u,c)=>{u.userData.meshFeatures=new It(u.geometry,o,c)})}}const Ut=n=>class extends n{get featureTexture(){return this.uniforms.featureTexture.value}set featureTexture(e){const t=this.uniforms.featureTexture.value;t!==e&&t&&t.dispose(),this.uniforms.featureTexture.value=e}get nullFeatureId(){return this.uniforms.nullFeatureId.value}set nullFeatureId(e){e<0||e===null||e===void 0?(this.uniforms.nullFeatureId.value=null,this.setDefine("USE_NULL_FEATURE",0)):(this.uniforms.nullFeatureId.value=e,this.setDefine("USE_NULL_FEATURE",1))}get highlightFeatureId(){return this.uniforms.highlightFeatureId.value}set highlightFeatureId(e){e==null?(this.uniforms.highlightFeatureId.value=null,this.setDefine("USE_HIGHLIGHT_FEATURE",0)):(this.uniforms.highlightFeatureId.value=e,this.setDefine("USE_HIGHLIGHT_FEATURE",1))}constructor(...e){super(...e),this.isMeshFeaturesMaterial=!0,this.uniforms={featureChannelsLength:{value:0},featureChannels:{value:new Array(4).fill(0)},featureTexture:{value:null},nullFeatureId:{value:null},highlightFeatureId:{value:-1}},Object.assign(this.defines,{FEATURE_TYPE:0,USE_HIGHLIGHT_FEATURE:0,USE_NULL_FEATURE:0,FEATURE_ATTR:"",FEATURE_TEXTURE_ATTR:"uv"}),this.addEventListener("dispose",()=>{this.featureTexture&&this.featureTexture.dispose()})}copy(e){const t=this.defines;if(super.copy(e),e.defines&&Object.assign(this.defines,t,e.defines),e.uniforms)for(const s in this.uniforms){const r=e.uniforms[s].value;Array.isArray(r)?this.uniforms[s].value=r.slice():this.uniforms[s].value=r}this.needsUpdate=!0}setDefine(e,t){const s=this.defines;s[e]!==t&&(this.needsUpdate=!0),t===null?delete s[e]:s[e]=t}setFromMeshFeatures(e,t){let s=null;typeof t=="number"?s=e.getFeatureInfo()[t]||null:typeof t=="string"&&(s=e.getFeatureInfo().find(r=>r.label===t)||null),s===null?(this.setDefine("FEATURE_TYPE",0),this.featureTexture=null):"attribute"in s?this._setAttributeFeature(s.attribute):"texture"in s?this._setTextureFeature(e.textures[s.texture.index],s.texture.texCoord,s.texture.channels):this._setAttributeFeature(null),s!==null&&(this.nullFeatureId=s.nullFeatureId==null?null:s.nullFeatureId)}disableFeatureDisplay(){this.setDefine("FEATURE_TYPE",0),this.featureTexture=null}_setTextureFeature(e,t,s){const r=this.uniforms;this.setDefine("FEATURE_TYPE",3),t===0?(this.setDefine("FEATURE_TEXTURE_ATTR","uv"),this.setDefine("USE_UV","")):(this.setDefine("FEATURE_TEXTURE_ATTR",`uv${t}`),this.setDefine(`USE_UV${t}`,"")),t!==0&&this.setDefine("USE_UV",null),t!==1&&this.setDefine("USE_UV1",null),t!==2&&this.setDefine("USE_UV2",null),t!==3&&this.setDefine("USE_UV3",null),r.featureChannelsLength.value=s.length,r.featureChannels.value=[...s],this.featureTexture=e}_setAttributeFeature(e=null){e===null?this.setDefine("FEATURE_TYPE",1):(this.setDefine("FEATURE_TYPE",2),this.setDefine("FEATURE_ATTR",`_feature_id_${e}`)),this.featureTexture=null}customProgramCacheKey(){const e=this.defines;return`${e.FEATURE_TYPE}|${e.USE_HIGHLIGHT_FEATURE}|${e.USE_NULL_FEATURE}|${e.FEATURE_ATTR}|${e.FEATURE_TEXTURE_ATTR}`}onBeforeCompile(e){e.uniforms={...e.uniforms,...this.uniforms},e.defines=this.defines,e.vertexShader=e.vertexShader.replace(/^/,t=>` + // texture + #if FEATURE_TYPE == 3 + + varying vec2 _feature_uv; + + // attribute + #elif FEATURE_TYPE == 2 + + attribute float FEATURE_ATTR; + flat varying uint _feature_attr; + + // implicit + #elif FEATURE_TYPE == 1 + + flat varying uint _feature_attr; + + #endif + + ${t} + `).replace(/void main\(\) {/,t=>` + ${t} + + // texture + #if FEATURE_TYPE == 3 + + _feature_uv = FEATURE_TEXTURE_ATTR; + + // attribute + #elif FEATURE_TYPE == 2 + + _feature_attr = uint( FEATURE_ATTR ); + + // none + #elif FEATURE_TYPE == 1 + + _feature_attr = uint( gl_VertexID ); + + #endif + `),e.fragmentShader=e.fragmentShader.replace(/^/,t=>` + + #if USE_HIGHLIGHT_FEATURE + + uniform uint highlightFeatureId; + + #endif + + #if USE_NULL_FEATURE + + uniform uint nullFeatureId; + + #endif + + // texture + #if FEATURE_TYPE == 3 + + uniform sampler2D featureTexture; + uniform int featureChannelsLength; + uniform uint featureChannels[ 4 ]; + varying vec2 _feature_uv; + + // attribute + #elif FEATURE_TYPE == 2 + + flat varying uint _feature_attr; + + // none + #elif FEATURE_TYPE == 1 + + flat varying uint _feature_attr; + + #endif + + // https://www.shadertoy.com/view/XljGzV + vec3 hsl2rgb( in vec3 c ) { + + vec3 rgb = clamp( abs( mod( c.x * 6.0 + vec3( 0.0, 4.0, 2.0 ), 6.0 ) - 3.0 ) - 1.0, 0.0, 1.0 ); + return c.z + c.y * ( rgb - 0.5 ) * ( 1.0 - abs( 2.0 * c.z - 1.0 ) ); + + } + + // https://stackoverflow.com/questions/4200224/random-noise-functions-for-glsl + float rand( float v ) { + + return fract( sin( dot( vec2( v, v ), vec2( 12.9898, 78.233 ) ) ) * 43758.5453 ); + + } + + vec3 randFeatureColor( uint feature ) { + + vec3 hsl; + hsl.r = rand( float( feature ) / 5500.0 ); + hsl.g = 0.75; + hsl.b = 0.5; + return hsl2rgb( hsl ); + + } + + ${t} + `).replace(/#include /,t=>` + ${t} + + // disabled + #if FEATURE_TYPE != 0 + + uint featureId = 0u; + + // texture + #if FEATURE_TYPE == 3 + + // TODO: support anti aliasing here at the pixel edges + uvec4 fields = uvec4( texture( featureTexture, _feature_uv ) * float( 0xff ) ); + for ( int i = 0; i < min( featureChannelsLength, 4 ); i ++ ) { + + uint offset = 8u * featureChannels[ i ]; + featureId = featureId | ( fields[ i ] << offset ); + + } + + // attribute + #elif FEATURE_TYPE == 2 + + featureId = _feature_attr; + + // implicit + #elif FEATURE_TYPE == 1 + + featureId = _feature_attr; + + #endif + + #if USE_HIGHLIGHT_FEATURE + + if ( highlightFeatureId != featureId ) { + + diffuseColor.rgb *= 0.25; + + } + + #else + + vec3 featureColor = randFeatureColor( featureId ); + diffuseColor.rgb = mix( diffuseColor.rgb * featureColor, featureColor, 0.05 ); + + #endif + + #if USE_NULL_FEATURE + + if ( nullFeatureId == featureId ) { + + diffuseColor.rgb *= vec3( 0.0 ); + + } + + #endif + + #endif + + `)}};let g,F,S,_,W,x,O,b,L,v,Z=!1,w=null,K=!1;const J=new E(-1,-1),z=new We;z.firstHitOnly=!0;z.params.Points.threshold=.05;const bt=localStorage.getItem("ionApiKey")??"put-your-api-key-here",A={accessToken:bt,assetId:2333904,reload:()=>{ne()},featureIndex:0,propertyTexture:0,highlightAllFeatures:!1};St();Pe();function St(){b=document.getElementById("meshFeatures"),L=document.getElementById("structuralMetadata"),_=new Fe({antialias:!0}),_.setPixelRatio(window.devicePixelRatio),_.setSize(window.innerWidth,window.innerHeight),_.setClearColor(1383455),document.body.appendChild(_.domElement),S=new ze,g=new Ye(60,window.innerWidth/window.innerHeight,.1,5e3),g.position.set(-4,2,0).multiplyScalar(30),g.lookAt(0,0,0),F=new et(S,g,_.domElement),F.minDistance=.1,F.cameraRadius=.1,F.minAltitude=0,F.maxAltitude=Math.PI,F.adjustHeight=!1,F.addEventListener("start",()=>Z=!0),F.addEventListener("end",()=>Z=!1),W=new ke(16777215,3.3),W.position.set(1,2,3).multiplyScalar(40),S.add(W),S.add(new Xe(16777215,1)),O=new qe,O.position.y=40,S.add(O),ne(),_e(),window.addEventListener("resize",_e,!1),window.addEventListener("pointermove",n=>{J.x=n.clientX/window.innerWidth*2-1,J.y=-(n.clientY/window.innerHeight)*2+1})}function Ct(){v&&v.destroy(),v=new Je;const n=v.addFolder("ion");n.add(A,"accessToken"),n.add(A,"assetId",[2333904,2342602]).onChange(ne),n.add(A,"reload");const e=v.addFolder("features");A.assetId===2333904?(e.add(A,"featureIndex",[0,1]),e.add(A,"highlightAllFeatures")):e.add(A,"propertyTexture",{NONE:0,HORIZ_UNCERTAINTY:1,VERT_UNCERTAINTY:2})}function ne(){x&&(x.dispose(),x.group.removeFromParent()),localStorage.setItem("ionApiKey",A.accessToken),x=new tt,x.registerPlugin(new st({apiToken:A.accessToken,assetId:A.assetId})),x.setCamera(g),O.add(x.group);const n=new Ze(x.manager);n.register(()=>new Rt),n.register(()=>new wt),x.manager.addHandler(/(gltf|glb)$/g,n),x.addEventListener("load-model",({scene:e})=>{e.traverse(t=>{if(t.material&&t.userData.meshFeatures){const s=Ut(t.material.constructor),r=new s;r.copy(t.material),r.metalness=0,t.material=r}t.material&&t.userData.structuralMetadata&&(t.material.originalMap=t.material.map)})}),Ct()}function _e(){g.aspect=window.innerWidth/window.innerHeight,_.setPixelRatio(window.devicePixelRatio),_.setSize(window.innerWidth,window.innerHeight),g.updateProjectionMatrix()}function ge(n,e,t,s=null,r=null,i=null){if(L.innerText=`STRUCTURAL_METADATA +`,r!==null){const a=n.getPropertyTableData(r,i);o(a,n.getPropertyTableInfo(r))}s!==null&&o(n.getPropertyAttributeData(s),n.getPropertyAttributeInfo()),o(n.getPropertyTextureData(e,t),n.getPropertyTextureInfo());function o(a,u){const c=Math.max(...Object.values(a).flatMap(d=>Object.keys(d)).map(d=>d.length));for(const d in a){L.innerText+=` +${u[d].name||u[d].className} +`;const l=a[d];for(const f in l){let h=l[f];h&&h.toArray&&(h=h.toArray()),h&&h.join&&(h=` +`+h.map(p=>p.toFixed?parseFloat(p.toFixed(6)):p).map((p,m)=>` [${m}] ${p}`).join(` +`)),typeof h=="number"&&(h=parseFloat(h.toFixed(6))),L.innerText+=` ${f.padEnd(c+1)} : ${h} +`}}}}function Pt(){if(K||Z)return;z.setFromCamera(J,g);const n=z.intersectObject(S)[0];if(n){const{object:e,face:t,point:s,index:r,faceIndex:i}=n,o=new ee;if(t){const u=new Ke;u.setFromAttributeAndIndices(e.geometry.attributes.position,t.a,t.b,t.c),u.a.applyMatrix4(e.matrixWorld),u.b.applyMatrix4(e.matrixWorld),u.c.applyMatrix4(e.matrixWorld),u.getBarycoord(s,o)}else o.set(0,0,0);const{meshFeatures:a}=n.object.userData;a?(K=!0,a.getFeaturesAsync(i,o).then(u=>{K=!1,w={index:r,features:u,faceIndex:i,barycoord:o,object:e}})):w={index:r,features:null,faceIndex:i,barycoord:o,object:e}}else w=null}function Dt(){const{featureIndex:n}=A;let e=null,t=null,s=null;if(w&&(e=w.object.userData.meshFeatures,t=w.object.userData.structuralMetadata,s=w.features),e!==null&&s!==null){const{index:r,faceIndex:i,barycoord:o}=w;if(b.innerText=`EXT_MESH_FEATURES + +`,b.innerText+=`feature : ${s.map(a=>a+"").join(", ")} +`,b.innerText+=`texture memory : ${_.info.memory.textures} +`,t!==null){const u=e.getFeatureInfo().map(c=>c.propertyTable);ge(t,i,o,r,u,s)}}else if(b.innerText=`EXT_MESH_FEATURES + +`,b.innerText+=`feature : - +`,b.innerText+=`texture memory : ${_.info.memory.textures}`,t!==null){const{index:r,faceIndex:i,barycoord:o}=w;ge(t,i,o,r)}else L.innerText="";x.forEachLoadedModel(r=>r.traverse(i=>{const o=i.material,{meshFeatures:a,structuralMetadata:u}=i.userData;if(o&&a)if(A.highlightAllFeatures)o.setFromMeshFeatures(a,n),o.highlightFeatureId=null;else if(w===null)o.disableFeatureDisplay();else{const c=s[n];o.setFromMeshFeatures(a,n),o.highlightFeatureId=c===null?-1:c}if(o&&u&&u.textureAccessors.length>0){let c=null;if(A.propertyTexture===0)c=o.originalMap;else if(A.propertyTexture===1){const l=u.getPropertyTextureInfo()[0].properties.r3dm_uncertainty_ce90sum;c=u.textures[l.index],c.channel=l.texCoord}else if(A.propertyTexture===2){const l=u.getPropertyTextureInfo()[1].properties.r3dm_uncertainty_le90sum;c=u.textures[l.index],c.channel=l.texCoord}o.map!==c&&(o.map=c,o.needsUpdate=!0)}}))}function Pe(){requestAnimationFrame(Pe),F.update(),g.updateMatrixWorld(),Dt(),Pt();const n=new Qe,e=new ee(0,1,0);x.getBoundingSphere(n),x.group.position.copy(n.center).multiplyScalar(-1),O.quaternion.setFromUnitVectors(n.center.normalize(),e),x.setResolutionFromRenderer(g,_),x.update(),_.render(S,g)} diff --git a/example/bundle/assets/offscreenShadows-D7kVepRj.js b/example/bundle/assets/offscreenShadows-D7kVepRj.js new file mode 100644 index 000000000..09d046f90 --- /dev/null +++ b/example/bundle/assets/offscreenShadows-D7kVepRj.js @@ -0,0 +1 @@ +import{S as b,W as R,P,a as y,O as v,D as T,A as W,G as A,M as L,B as D,d as E}from"./three.module-C94OeYjd.js";import{O}from"./OrbitControls-bHRTZZ2i.js";import{g as z}from"./lil-gui.module.min-NsHmRZWc.js";import{S as B}from"./stats.module--VATS4Kh.js";import{T as H}from"./TilesRenderer-DQOLA18N.js";import"./B3DMLoader-B0T2UZ_1.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";import"./GLTFLoader-C77rxX9H.js";import"./PNTSLoader-BUgecSBY.js";import"./I3DMLoader-C4TPl3Dp.js";import"./CMPTLoader-CXF13c0w.js";import"./GLTFExtensionLoader-Qt9Ghhze.js";let a,p,w,i,e,t,d,c,h,r,m;const u=0,g=1,S=2,s={errorTarget:2,shadowStrategy:u,orthographic:!1};I();x();function F({scene:o}){o.traverse(n=>{n.isMesh&&(n.material=new L,n.castShadow=!0,n.receiveShadow=!0)})}function j(o){o.traverse(n=>{n.isMesh&&n.material.dispose()})}function I(){w=new b,i=new R({antialias:!0}),i.setPixelRatio(window.devicePixelRatio),i.setSize(window.innerWidth,window.innerHeight),i.setClearColor(1383455),i.shadowMap.enabled=!0,i.shadowMap.type=P,document.body.appendChild(i.domElement),a=new y(60,window.innerWidth/window.innerHeight,1,4e3),a.position.set(-56,232,260),t=new v,p=new O(a,i.domElement),p.screenSpacePanning=!1,p.minDistance=1,p.maxDistance=2e3,r=new T(16777215,1.25),r.position.set(-100,40,10),r.castShadow=!0,r.shadow.bias=-1e-4,r.shadow.normalBias=.2,r.shadow.mapSize.setScalar(2048);const o=r.shadow.camera;o.left=-120,o.bottom=-120,o.right=120,o.top=120,o.updateProjectionMatrix(),w.add(r);const n=new W(16777215,.05);w.add(n),c=new D,h=new E,d=new A,w.add(d);const M=window.location.hash.replace(/^#/,"")||"../data/tileset.json";e=new H(M),e.addEventListener("load-model",F),e.addEventListener("dispose-model",j),d.add(e.group),f(),window.addEventListener("resize",f,!1);const l=new z;l.width=300,l.add(s,"orthographic"),l.add(s,"errorTarget").min(0).max(25).step(1),l.add(s,"shadowStrategy",{NONE:u,DISPLAY_ACTIVE_TILES:g,USE_SHADOW_CAMERA:S}),l.open(),m=new B,m.showPanel(0),document.body.appendChild(m.dom)}function f(){a.aspect=window.innerWidth/window.innerHeight,i.setPixelRatio(window.devicePixelRatio),i.setSize(window.innerWidth,window.innerHeight),a.updateProjectionMatrix(),C()}function C(){t.position.copy(a.position),t.rotation.copy(a.rotation);const o=a.position.distanceTo(p.target)/2,n=window.innerWidth/window.innerHeight;t.left=-n*o,t.right=n*o,t.bottom=-o,t.top=o,t.near=a.near,t.far=a.far,t.updateProjectionMatrix()}function x(){switch(requestAnimationFrame(x),e.errorTarget=s.errorTarget,parseFloat(s.shadowStrategy)){case u:e.displayActiveTiles=!1,e.autoDisableRendererCulling=!0,e.deleteCamera(r.shadow.camera);break;case g:e.displayActiveTiles=!0,e.autoDisableRendererCulling=!1,e.deleteCamera(r.shadow.camera);break;case S:e.displayActiveTiles=!1,e.autoDisableRendererCulling=!1,e.setCamera(r.shadow.camera),e.setResolution(r.shadow.camera,r.shadow.mapSize);break}s.orthographic?(e.deleteCamera(a),e.setCamera(t),e.setResolutionFromRenderer(t,i)):(e.deleteCamera(t),e.setCamera(a),e.setResolutionFromRenderer(a,i)),d.rotation.set(0,0,0),s.up==="-Z"&&(d.rotation.x=Math.PI/2),d.updateMatrixWorld(!0),e.getBoundingBox(c)?(c.getCenter(e.group.position),e.group.position.multiplyScalar(-1)):e.getBoundingSphere(h)&&(e.group.position.copy(h.center),e.group.position.multiplyScalar(-1)),window.tiles=e,a.updateMatrixWorld(),t.updateMatrixWorld(),e.update(),_(),m.update()}function _(){C(),i.render(w,s.orthographic?t:a)} diff --git a/example/bundle/assets/pntsExample-De5Eup2L.js b/example/bundle/assets/pntsExample-De5Eup2L.js new file mode 100644 index 000000000..0c760fc2c --- /dev/null +++ b/example/bundle/assets/pntsExample-De5Eup2L.js @@ -0,0 +1 @@ +import{S as c,W as m,P as l,a as h,D as p,A as f}from"./three.module-C94OeYjd.js";import{O as u}from"./OrbitControls-bHRTZZ2i.js";import{P as S}from"./PNTSLoader-BUgecSBY.js";import"./readMagicBytes-Da5ueiou.js";import"./LoaderBase-CVSPpjX2.js";let n,a,o,e,i;g();d();function g(){o=new c,e=new m({antialias:!0}),e.setPixelRatio(window.devicePixelRatio),e.setSize(window.innerWidth,window.innerHeight),e.setClearColor(1383455),e.shadowMap.enabled=!0,e.shadowMap.type=l,document.body.appendChild(e.domElement),n=new h(60,window.innerWidth/window.innerHeight,1,4e3),n.position.set(2,2,2),a=new u(n,e.domElement),a.screenSpacePanning=!1,a.minDistance=1,a.maxDistance=2e3,i=new p(16777215,1.25),i.position.set(1,2,3).multiplyScalar(40),i.castShadow=!0,i.shadow.bias=-.01,i.shadow.mapSize.setScalar(2048);const t=i.shadow.camera;t.left=-200,t.bottom=-200,t.right=200,t.top=200,t.updateProjectionMatrix(),o.add(i);const w=new f(16777215,.05);o.add(w),new S().loadAsync("https://raw.githubusercontent.com/CesiumGS/3d-tiles-samples/main/1.0/TilesetWithRequestVolume/points.pnts").then(s=>{console.log(s),o.add(s.scene)}),r(),window.addEventListener("resize",r,!1)}function r(){n.aspect=window.innerWidth/window.innerHeight,e.setPixelRatio(window.devicePixelRatio),e.setSize(window.innerWidth,window.innerHeight),n.updateProjectionMatrix()}function d(){requestAnimationFrame(d),P()}function P(){e.render(o,n)} diff --git a/example/bundle/assets/readMagicBytes-Da5ueiou.js b/example/bundle/assets/readMagicBytes-Da5ueiou.js new file mode 100644 index 000000000..09bab9737 --- /dev/null +++ b/example/bundle/assets/readMagicBytes-Da5ueiou.js @@ -0,0 +1 @@ +const y=new TextDecoder;function I(i){return y.decode(i)}function f(i,e,t,s,a,r){let n;switch(s){case"SCALAR":n=1;break;case"VEC2":n=2;break;case"VEC3":n=3;break;case"VEC4":n=4;break;default:throw new Error(`FeatureTable : Feature type not provided for "${r}".`)}let c;const o=t*n;switch(a){case"BYTE":c=new Int8Array(i,e,o);break;case"UNSIGNED_BYTE":c=new Uint8Array(i,e,o);break;case"SHORT":c=new Int16Array(i,e,o);break;case"UNSIGNED_SHORT":c=new Uint16Array(i,e,o);break;case"INT":c=new Int32Array(i,e,o);break;case"UNSIGNED_INT":c=new Uint32Array(i,e,o);break;case"FLOAT":c=new Float32Array(i,e,o);break;case"DOUBLE":c=new Float64Array(i,e,o);break;default:throw new Error(`FeatureTable : Feature component type not provided for "${r}".`)}return c}class T{constructor(e,t,s,a){this.buffer=e,this.binOffset=t+s,this.binLength=a;let r=null;if(s!==0){const n=new Uint8Array(e,t,s);r=JSON.parse(I(n))}else r={};this.header=r}getKeys(){return Object.keys(this.header)}getData(e,t,s=null,a=null){const r=this.header;if(!(e in r))return null;const n=r[e];if(n instanceof Object){if(Array.isArray(n))return n;{const{buffer:c,binOffset:o,binLength:h}=this,l=n.byteOffset||0,p=n.type||a,b=n.componentType||s;if("type"in n&&a&&n.type!==a)throw new Error("FeatureTable: Specified type does not match expected type.");const u=o+l,d=f(c,u,t,p,b,e);if(u+d.byteLength>o+h)throw new Error("FeatureTable: Feature data read outside binary body length.");return d}}else return n}getBuffer(e,t){const{buffer:s,binOffset:a}=this;return s.slice(a+e,a+e+t)}}class g{constructor(e){this.batchTable=e;const t=e.header.extensions["3DTILES_batch_table_hierarchy"];this.classes=t.classes;for(const a of this.classes){const r=a.instances;for(const n in r)a.instances[n]=this._parseProperty(r[n],a.length,n)}if(this.instancesLength=t.instancesLength,this.classIds=this._parseProperty(t.classIds,this.instancesLength,"classIds"),t.parentCounts?this.parentCounts=this._parseProperty(t.parentCounts,this.instancesLength,"parentCounts"):this.parentCounts=new Array(this.instancesLength).fill(1),t.parentIds){const a=this.parentCounts.reduce((r,n)=>r+n,0);this.parentIds=this._parseProperty(t.parentIds,a,"parentIds")}else this.parentIds=null;this.instancesIds=[];const s={};for(const a of this.classIds)s[a]=s[a]??0,this.instancesIds.push(s[a]),s[a]++}_parseProperty(e,t,s){if(Array.isArray(e))return e;{const{buffer:a,binOffset:r}=this.batchTable,n=e.byteOffset,c=e.componentType||"UNSIGNED_SHORT",o=r+n;return f(a,o,t,"SCALAR",c,s)}}getDataFromId(e,t={}){const s=this.parentCounts[e];if(this.parentIds&&s>0){let o=0;for(let h=0;h=this.count)throw new Error(`BatchTable: id value "${e}" out of bounds for "${this.count}" features number.`);for(const s of this.getKeys())s!=="extensions"&&(t[s]=super.getData(s,this.count)[e]);for(const s in this.extensions){const a=this.extensions[s];a.getDataFromId instanceof Function&&(t[s]=t[s]||{},a.getDataFromId(e,t[s]))}return t}getPropertyArray(e){return super.getData(e,this.count)}}function A(i){let e;if(i instanceof DataView?e=i:e=new DataView(i),String.fromCharCode(e.getUint8(0))==="{")return null;let t="";for(let s=0;s<4;s++)t+=String.fromCharCode(e.getUint8(s));return t}export{D as B,T as F,I as a,A as r}; diff --git a/example/bundle/assets/stats.module--VATS4Kh.js b/example/bundle/assets/stats.module--VATS4Kh.js new file mode 100644 index 000000000..74b251dc7 --- /dev/null +++ b/example/bundle/assets/stats.module--VATS4Kh.js @@ -0,0 +1 @@ +var P=function(){var m=0,a=document.createElement("div");a.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",a.addEventListener("click",function(n){n.preventDefault(),o(++m%a.children.length)},!1);function i(n){return a.appendChild(n.dom),n}function o(n){for(var l=0;l=r+1e3&&(u.update(e*1e3/(n-r),100),r=n,e=0,h)){var l=performance.memory;h.update(l.usedJSHeapSize/1048576,l.jsHeapSizeLimit/1048576)}return n},update:function(){f=this.end()},domElement:a,setMode:o}};P.Panel=function(m,a,i){var o=1/0,f=0,r=Math.round,e=r(window.devicePixelRatio||1),u=80*e,v=48*e,h=3*e,n=2*e,l=3*e,c=15*e,d=74*e,s=30*e,p=document.createElement("canvas");p.width=u,p.height=v,p.style.cssText="width:80px;height:48px";var t=p.getContext("2d");return t.font="bold "+9*e+"px Helvetica,Arial,sans-serif",t.textBaseline="top",t.fillStyle=i,t.fillRect(0,0,u,v),t.fillStyle=a,t.fillText(m,h,n),t.fillRect(l,c,d,s),t.fillStyle=i,t.globalAlpha=.9,t.fillRect(l,c,d,s),{dom:p,update:function(x,S){o=Math.min(o,x),f=Math.max(f,x),t.fillStyle=i,t.globalAlpha=1,t.fillRect(0,0,u,c),t.fillStyle=a,t.fillText(r(x)+" "+m+" ("+r(o)+"-"+r(f)+")",h,n),t.drawImage(p,l+e,c,d-e,s,l,c,d-e,s),t.fillRect(l+d-e,c,e,s),t.fillStyle=i,t.globalAlpha=.9,t.fillRect(l+d-e,c,e,r((1-x/S)*s))}}};export{P as S}; diff --git a/example/bundle/assets/three.module-C94OeYjd.js b/example/bundle/assets/three.module-C94OeYjd.js new file mode 100644 index 000000000..89c82bf2b --- /dev/null +++ b/example/bundle/assets/three.module-C94OeYjd.js @@ -0,0 +1,3818 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function e(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(i){if(i.ep)return;i.ep=!0;const s=e(i);fetch(i.href,s)}})();/** + * @license + * Copyright 2010-2024 Three.js Authors + * SPDX-License-Identifier: MIT + */const Va="166",mf={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},gf={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},nu=0,fl=1,iu=2,_f=3,xf=0,Rl=1,su=2,cn=3,Rn=0,De=1,hn=2,Tn=0,xi=1,pl=2,ml=3,gl=4,ru=5,Xn=100,au=101,ou=102,lu=103,cu=104,hu=200,uu=201,du=202,fu=203,ca=204,ha=205,pu=206,mu=207,gu=208,_u=209,xu=210,vu=211,yu=212,Mu=213,Su=214,bu=0,Au=1,wu=2,Os=3,Eu=4,Tu=5,Cu=6,Ru=7,ir=0,Pu=1,Iu=2,Cn=0,Lu=1,Uu=2,Du=3,Nu=4,Ou=5,Fu=6,Bu=7,_l="attached",zu="detached",Ha=300,Pn=301,qn=302,Fs=303,Bs=304,os=306,zs=1e3,Ke=1001,ks=1002,Me=1003,Pl=1004,vf=1004,Ki=1005,yf=1005,ge=1006,Ts=1007,Mf=1007,un=1008,Sf=1008,mn=1009,Il=1010,Ll=1011,is=1012,Ga=1013,In=1014,Be=1015,ls=1016,Wa=1017,Xa=1018,Si=1020,Ul=35902,Dl=1021,Nl=1022,Ue=1023,Ol=1024,Fl=1025,vi=1026,bi=1027,qa=1028,sr=1029,Bl=1030,Ya=1031,bf=1032,Za=1033,Cs=33776,Rs=33777,Ps=33778,Is=33779,ua=35840,da=35841,fa=35842,pa=35843,ma=36196,ga=37492,_a=37496,xa=37808,va=37809,ya=37810,Ma=37811,Sa=37812,ba=37813,Aa=37814,wa=37815,Ea=37816,Ta=37817,Ca=37818,Ra=37819,Pa=37820,Ia=37821,Ls=36492,La=36494,Ua=36495,zl=36283,Da=36284,Na=36285,Oa=36286,ku=2200,Vu=2201,Hu=2202,Vs=2300,Fa=2301,oa=2302,pi=2400,mi=2401,Hs=2402,Ja=2500,kl=2501,Af=0,wf=1,Ef=2,Gu=3200,Wu=3201,Zn=0,Xu=1,An="",$e="srgb",Un="srgb-linear",$a="display-p3",rr="display-p3-linear",Gs="linear",se="srgb",Ws="rec709",Xs="p3",Tf=0,ui=7680,Cf=7681,Rf=7682,Pf=7683,If=34055,Lf=34056,Uf=5386,Df=512,Nf=513,Of=514,Ff=515,Bf=516,zf=517,kf=518,xl=519,qu=512,Yu=513,Zu=514,Vl=515,Ju=516,$u=517,Ku=518,Qu=519,qs=35044,Vf=35048,Hf=35040,Gf=35045,Wf=35049,Xf=35041,qf=35046,Yf=35050,Zf=35042,Jf="100",vl="300 es",dn=2e3,Ys=2001;class Dn{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const n=this._listeners;return n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const i=this._listeners[t];if(i!==void 0){const s=i.indexOf(e);s!==-1&&i.splice(s,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const n=this._listeners[t.type];if(n!==void 0){t.target=this;const i=n.slice(0);for(let s=0,a=i.length;s>8&255]+we[r>>16&255]+we[r>>24&255]+"-"+we[t&255]+we[t>>8&255]+"-"+we[t>>16&15|64]+we[t>>24&255]+"-"+we[e&63|128]+we[e>>8&255]+"-"+we[e>>16&255]+we[e>>24&255]+we[n&255]+we[n>>8&255]+we[n>>16&255]+we[n>>24&255]).toLowerCase()}function he(r,t,e){return Math.max(t,Math.min(e,r))}function Hl(r,t){return(r%t+t)%t}function $f(r,t,e,n,i){return n+(r-t)*(i-n)/(e-t)}function Kf(r,t,e){return r!==t?(e-r)/(t-r):0}function Us(r,t,e){return(1-e)*r+e*t}function Qf(r,t,e,n){return Us(r,t,1-Math.exp(-e*n))}function jf(r,t=1){return t-Math.abs(Hl(r,t*2)-t)}function tp(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function ep(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function np(r,t){return r+Math.floor(Math.random()*(t-r+1))}function ip(r,t){return r+Math.random()*(t-r)}function sp(r){return r*(.5-Math.random())}function rp(r){r!==void 0&&(bc=r);let t=bc+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function ap(r){return r*yi}function op(r){return r*ss}function lp(r){return(r&r-1)===0&&r!==0}function cp(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function hp(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function up(r,t,e,n,i){const s=Math.cos,a=Math.sin,o=s(e/2),l=a(e/2),c=s((t+n)/2),h=a((t+n)/2),u=s((t-n)/2),d=a((t-n)/2),f=s((n-t)/2),m=a((n-t)/2);switch(i){case"XYX":r.set(o*h,l*u,l*d,o*c);break;case"YZY":r.set(l*d,o*h,l*u,o*c);break;case"ZXZ":r.set(l*u,l*d,o*h,o*c);break;case"XZX":r.set(o*h,l*m,l*f,o*c);break;case"YXY":r.set(l*f,o*h,l*m,o*c);break;case"ZYZ":r.set(l*m,l*f,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Le(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function zt(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const dp={DEG2RAD:yi,RAD2DEG:ss,generateUUID:qe,clamp:he,euclideanModulo:Hl,mapLinear:$f,inverseLerp:Kf,lerp:Us,damp:Qf,pingpong:jf,smoothstep:tp,smootherstep:ep,randInt:np,randFloat:ip,randFloatSpread:sp,seededRandom:rp,degToRad:ap,radToDeg:op,isPowerOfTwo:lp,ceilPowerOfTwo:cp,floorPowerOfTwo:hp,setQuaternionFromProperEuler:up,normalize:zt,denormalize:Le};class Z{constructor(t=0,e=0){Z.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,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(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(he(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),s=this.x-t.x,a=this.y-t.y;return this.x=s*n-a*i+t.x,this.y=s*i+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Bt{constructor(t,e,n,i,s,a,o,l,c){Bt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,i,s,a,o,l,c)}set(t,e,n,i,s,a,o,l,c){const h=this.elements;return h[0]=t,h[1]=i,h[2]=o,h[3]=e,h[4]=s,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,s=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],f=n[5],m=n[8],_=i[0],g=i[3],p=i[6],v=i[1],x=i[4],y=i[7],I=i[2],w=i[5],C=i[8];return s[0]=a*_+o*v+l*I,s[3]=a*g+o*x+l*w,s[6]=a*p+o*y+l*C,s[1]=c*_+h*v+u*I,s[4]=c*g+h*x+u*w,s[7]=c*p+h*y+u*C,s[2]=d*_+f*v+m*I,s[5]=d*g+f*x+m*w,s[8]=d*p+f*y+m*C,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8];return e*a*h-e*o*c-n*s*h+n*o*l+i*s*c-i*a*l}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=h*a-o*c,d=o*l-h*s,f=c*s-a*l,m=e*u+n*d+i*f;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/m;return t[0]=u*_,t[1]=(i*c-h*n)*_,t[2]=(o*n-i*a)*_,t[3]=d*_,t[4]=(h*e-i*l)*_,t[5]=(i*s-o*e)*_,t[6]=f*_,t[7]=(n*l-c*e)*_,t[8]=(a*e-n*s)*_,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,s,a,o){const l=Math.cos(s),c=Math.sin(s);return this.set(n*l,n*c,-n*(l*a+c*o)+a+t,-i*c,i*l,-i*(-c*a+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(To.makeScale(t,e)),this}rotate(t){return this.premultiply(To.makeRotation(-t)),this}translate(t,e){return this.premultiply(To.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const To=new Bt;function ju(r){for(let t=r.length-1;t>=0;--t)if(r[t]>=65535)return!0;return!1}const fp={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Qi(r,t){return new fp[r](t)}function Zs(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}function td(){const r=Zs("canvas");return r.style.display="block",r}const Ac={};function Gl(r){r in Ac||(Ac[r]=!0,console.warn(r))}function pp(r,t,e){return new Promise(function(n,i){function s(){switch(r.clientWaitSync(t,r.SYNC_FLUSH_COMMANDS_BIT,0)){case r.WAIT_FAILED:i();break;case r.TIMEOUT_EXPIRED:setTimeout(s,e);break;default:n()}}setTimeout(s,e)})}const wc=new Bt().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Ec=new Bt().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),mr={[Un]:{transfer:Gs,primaries:Ws,toReference:r=>r,fromReference:r=>r},[$e]:{transfer:se,primaries:Ws,toReference:r=>r.convertSRGBToLinear(),fromReference:r=>r.convertLinearToSRGB()},[rr]:{transfer:Gs,primaries:Xs,toReference:r=>r.applyMatrix3(Ec),fromReference:r=>r.applyMatrix3(wc)},[$a]:{transfer:se,primaries:Xs,toReference:r=>r.convertSRGBToLinear().applyMatrix3(Ec),fromReference:r=>r.applyMatrix3(wc).convertLinearToSRGB()}},mp=new Set([Un,rr]),Kt={enabled:!0,_workingColorSpace:Un,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(r){if(!mp.has(r))throw new Error(`Unsupported working color space, "${r}".`);this._workingColorSpace=r},convert:function(r,t,e){if(this.enabled===!1||t===e||!t||!e)return r;const n=mr[t].toReference,i=mr[e].fromReference;return i(n(r))},fromWorkingColorSpace:function(r,t){return this.convert(r,this._workingColorSpace,t)},toWorkingColorSpace:function(r,t){return this.convert(r,t,this._workingColorSpace)},getPrimaries:function(r){return mr[r].primaries},getTransfer:function(r){return r===An?Gs:mr[r].transfer}};function ns(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function Co(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let Pi;class ed{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{Pi===void 0&&(Pi=Zs("canvas")),Pi.width=t.width,Pi.height=t.height;const n=Pi.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),e=Pi}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Zs("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),s=i.data;for(let a=0;a0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Ha)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case zs:t.x=t.x-Math.floor(t.x);break;case Ke:t.x=t.x<0?0:1;break;case ks:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case zs:t.y=t.y-Math.floor(t.y);break;case Ke:t.y=t.y<0?0:1;break;case ks:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}ue.DEFAULT_IMAGE=null;ue.DEFAULT_MAPPING=Ha;ue.DEFAULT_ANISOTROPY=1;class ne{constructor(t=0,e=0,n=0,i=1){ne.prototype.isVector4=!0,this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,s=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*i+a[12]*s,this.y=a[1]*e+a[5]*n+a[9]*i+a[13]*s,this.z=a[2]*e+a[6]*n+a[10]*i+a[14]*s,this.w=a[3]*e+a[7]*n+a[11]*i+a[15]*s,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,s;const l=t.elements,c=l[0],h=l[4],u=l[8],d=l[1],f=l[5],m=l[9],_=l[2],g=l[6],p=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-_)<.01&&Math.abs(m-g)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+_)<.1&&Math.abs(m+g)<.1&&Math.abs(c+f+p-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const x=(c+1)/2,y=(f+1)/2,I=(p+1)/2,w=(h+d)/4,C=(u+_)/4,P=(m+g)/4;return x>y&&x>I?x<.01?(n=0,i=.707106781,s=.707106781):(n=Math.sqrt(x),i=w/n,s=C/n):y>I?y<.01?(n=.707106781,i=0,s=.707106781):(i=Math.sqrt(y),n=w/i,s=P/i):I<.01?(n=.707106781,i=.707106781,s=0):(s=Math.sqrt(I),n=C/s,i=P/s),this.set(n,i,s,e),this}let v=Math.sqrt((g-m)*(g-m)+(u-_)*(u-_)+(d-h)*(d-h));return Math.abs(v)<.001&&(v=1),this.x=(g-m)/v,this.y=(u-_)/v,this.z=(d-h)/v,this.w=Math.acos((c+f+p-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class nd extends Dn{constructor(t=1,e=1,n={}){super(),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=1,this.scissor=new ne(0,0,t,e),this.scissorTest=!1,this.viewport=new ne(0,0,t,e);const i={width:t,height:e,depth:1};n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ge,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1},n);const s=new ue(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.colorSpace);s.flipY=!1,s.generateMipmaps=n.generateMipmaps,s.internalFormat=n.internalFormat,this.textures=[];const a=n.count;for(let o=0;o=0?1:-1,x=1-p*p;if(x>Number.EPSILON){const I=Math.sqrt(x),w=Math.atan2(I,p*v);g=Math.sin(g*w)/I,o=Math.sin(o*w)/I}const y=o*v;if(l=l*g+d*y,c=c*g+f*y,h=h*g+m*y,u=u*g+_*y,g===1-o){const I=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=I,c*=I,h*=I,u*=I}}t[e]=l,t[e+1]=c,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,i,s,a){const o=n[i],l=n[i+1],c=n[i+2],h=n[i+3],u=s[a],d=s[a+1],f=s[a+2],m=s[a+3];return t[e]=o*m+h*u+l*f-c*d,t[e+1]=l*m+h*d+c*u-o*f,t[e+2]=c*m+h*f+o*d-l*u,t[e+3]=h*m-o*u-l*d-c*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,s=t._z,a=t._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(i/2),u=o(s/2),d=l(n/2),f=l(i/2),m=l(s/2);switch(a){case"XYZ":this._x=d*h*u+c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u-d*f*m;break;case"YXZ":this._x=d*h*u+c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u+d*f*m;break;case"ZXY":this._x=d*h*u-c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u-d*f*m;break;case"ZYX":this._x=d*h*u-c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u+d*f*m;break;case"YZX":this._x=d*h*u+c*f*m,this._y=c*f*u+d*h*m,this._z=c*h*m-d*f*u,this._w=c*h*u-d*f*m;break;case"XZY":this._x=d*h*u-c*f*m,this._y=c*f*u-d*h*m,this._z=c*h*m+d*f*u,this._w=c*h*u+d*f*m;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],s=e[8],a=e[1],o=e[5],l=e[9],c=e[2],h=e[6],u=e[10],d=n+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-l)*f,this._y=(s-c)*f,this._z=(a-i)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-l)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(s+c)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(s-c)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(l+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(a-i)/f,this._x=(s+c)/f,this._y=(l+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return nMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(he(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,s=t._z,a=t._w,o=e._x,l=e._y,c=e._z,h=e._w;return this._x=n*h+a*o+i*c-s*l,this._y=i*h+a*l+s*o-n*c,this._z=s*h+a*c+n*l-i*o,this._w=a*h-n*o-i*l-s*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const n=this._x,i=this._y,s=this._z,a=this._w;let o=a*t._w+n*t._x+i*t._y+s*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=n,this._y=i,this._z=s,this;const l=1-o*o;if(l<=Number.EPSILON){const f=1-e;return this._w=f*a+e*this._w,this._x=f*n+e*this._x,this._y=f*i+e*this._y,this._z=f*s+e*this._z,this.normalize(),this}const c=Math.sqrt(l),h=Math.atan2(c,o),u=Math.sin((1-e)*h)/c,d=Math.sin(e*h)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=i*u+this._y*d,this._z=s*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),s=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class T{constructor(t=0,e=0,n=0){T.prototype.isVector3=!0,this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Tc.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Tc.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6]*i,this.y=s[1]*e+s[4]*n+s[7]*i,this.z=s[2]*e+s[5]*n+s[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,s=t.elements,a=1/(s[3]*e+s[7]*n+s[11]*i+s[15]);return this.x=(s[0]*e+s[4]*n+s[8]*i+s[12])*a,this.y=(s[1]*e+s[5]*n+s[9]*i+s[13])*a,this.z=(s[2]*e+s[6]*n+s[10]*i+s[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,s=t.x,a=t.y,o=t.z,l=t.w,c=2*(a*i-o*n),h=2*(o*e-s*i),u=2*(s*n-a*e);return this.x=e+l*c+a*u-o*h,this.y=n+l*h+o*c-s*u,this.z=i+l*u+s*h-a*c,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,s=t.elements;return this.x=s[0]*e+s[4]*n+s[8]*i,this.y=s[1]*e+s[5]*n+s[9]*i,this.z=s[2]*e+s[6]*n+s[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,s=t.z,a=e.x,o=e.y,l=e.z;return this.x=i*l-s*o,this.y=s*a-n*l,this.z=n*o-i*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Po.copy(this).projectOnVector(t),this.sub(Po)}reflect(t){return this.sub(Po.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(he(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Po=new T,Tc=new ze;class Ne{constructor(t=new T(1/0,1/0,1/0),e=new T(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;ethis.max.x||t.ythis.max.y||t.zthis.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,je),je.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(fs),_r.subVectors(this.max,fs),Ii.subVectors(t.a,fs),Li.subVectors(t.b,fs),Ui.subVectors(t.c,fs),On.subVectors(Li,Ii),Fn.subVectors(Ui,Li),jn.subVectors(Ii,Ui);let e=[0,-On.z,On.y,0,-Fn.z,Fn.y,0,-jn.z,jn.y,On.z,0,-On.x,Fn.z,0,-Fn.x,jn.z,0,-jn.x,-On.y,On.x,0,-Fn.y,Fn.x,0,-jn.y,jn.x,0];return!Io(e,Ii,Li,Ui,_r)||(e=[1,0,0,0,1,0,0,0,1],!Io(e,Ii,Li,Ui,_r))?!1:(xr.crossVectors(On,Fn),e=[xr.x,xr.y,xr.z],Io(e,Ii,Li,Ui,_r))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,je).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(je).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(xn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),xn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),xn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),xn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),xn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),xn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),xn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),xn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(xn),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const xn=[new T,new T,new T,new T,new T,new T,new T,new T],je=new T,gr=new Ne,Ii=new T,Li=new T,Ui=new T,On=new T,Fn=new T,jn=new T,fs=new T,_r=new T,xr=new T,ti=new T;function Io(r,t,e,n,i){for(let s=0,a=r.length-3;s<=a;s+=3){ti.fromArray(r,s);const o=i.x*Math.abs(ti.x)+i.y*Math.abs(ti.y)+i.z*Math.abs(ti.z),l=t.dot(ti),c=e.dot(ti),h=n.dot(ti);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const yp=new Ne,ps=new T,Lo=new T;class Ce{constructor(t=new T,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;e!==void 0?n.copy(e):yp.setFromPoints(t).getCenter(n);let i=0;for(let s=0,a=t.length;sthis.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;ps.subVectors(t,this.center);const e=ps.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),i=(n-this.radius)*.5;this.center.addScaledVector(ps,i/n),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Lo.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(ps.copy(t.center).add(Lo)),this.expandByPoint(ps.copy(t.center).sub(Lo))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const vn=new T,Uo=new T,vr=new T,Bn=new T,Do=new T,yr=new T,No=new T;class cs{constructor(t=new T,e=new T(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,vn)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=vn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(vn.copy(this.origin).addScaledVector(this.direction,e),vn.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){Uo.copy(t).add(e).multiplyScalar(.5),vr.copy(e).sub(t).normalize(),Bn.copy(this.origin).sub(Uo);const s=t.distanceTo(e)*.5,a=-this.direction.dot(vr),o=Bn.dot(this.direction),l=-Bn.dot(vr),c=Bn.lengthSq(),h=Math.abs(1-a*a);let u,d,f,m;if(h>0)if(u=a*l-o,d=a*o-l,m=s*h,u>=0)if(d>=-m)if(d<=m){const _=1/h;u*=_,d*=_,f=u*(u+a*d+2*o)+d*(a*u+d+2*l)+c}else d=s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d=-s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;else d<=-m?(u=Math.max(0,-(-a*s+o)),d=u>0?-s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c):d<=m?(u=0,d=Math.min(Math.max(-s,-l),s),f=d*(d+2*l)+c):(u=Math.max(0,-(a*s+o)),d=u>0?s:Math.min(Math.max(-s,-l),s),f=-u*u+d*(d+2*l)+c);else d=a>0?-s:s,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(Uo).addScaledVector(vr,d),f}intersectSphere(t,e){vn.subVectors(t.center,this.origin);const n=vn.dot(this.direction),i=vn.dot(vn)-n*n,s=t.radius*t.radius;if(i>s)return null;const a=Math.sqrt(s-i),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,e):this.at(o,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,s,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(t.min.x-d.x)*c,i=(t.max.x-d.x)*c):(n=(t.max.x-d.x)*c,i=(t.min.x-d.x)*c),h>=0?(s=(t.min.y-d.y)*h,a=(t.max.y-d.y)*h):(s=(t.max.y-d.y)*h,a=(t.min.y-d.y)*h),n>a||s>i||((s>n||isNaN(n))&&(n=s),(a=0?(o=(t.min.z-d.z)*u,l=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,l=(t.min.z-d.z)*u),n>l||o>i)||((o>n||n!==n)&&(n=o),(l=0?n:i,e)}intersectsBox(t){return this.intersectBox(t,vn)!==null}intersectTriangle(t,e,n,i,s){Do.subVectors(e,t),yr.subVectors(n,t),No.crossVectors(Do,yr);let a=this.direction.dot(No),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Bn.subVectors(this.origin,t);const l=o*this.direction.dot(yr.crossVectors(Bn,yr));if(l<0)return null;const c=o*this.direction.dot(Do.cross(Bn));if(c<0||l+c>a)return null;const h=-o*Bn.dot(No);return h<0?null:this.at(h/a,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Rt{constructor(t,e,n,i,s,a,o,l,c,h,u,d,f,m,_,g){Rt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,i,s,a,o,l,c,h,u,d,f,m,_,g)}set(t,e,n,i,s,a,o,l,c,h,u,d,f,m,_,g){const p=this.elements;return p[0]=t,p[4]=e,p[8]=n,p[12]=i,p[1]=s,p[5]=a,p[9]=o,p[13]=l,p[2]=c,p[6]=h,p[10]=u,p[14]=d,p[3]=f,p[7]=m,p[11]=_,p[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Rt().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,n=t.elements,i=1/Di.setFromMatrixColumn(t,0).length(),s=1/Di.setFromMatrixColumn(t,1).length(),a=1/Di.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*s,e[5]=n[5]*s,e[6]=n[6]*s,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,s=t.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(i),c=Math.sin(i),h=Math.cos(s),u=Math.sin(s);if(t.order==="XYZ"){const d=a*h,f=a*u,m=o*h,_=o*u;e[0]=l*h,e[4]=-l*u,e[8]=c,e[1]=f+m*c,e[5]=d-_*c,e[9]=-o*l,e[2]=_-d*c,e[6]=m+f*c,e[10]=a*l}else if(t.order==="YXZ"){const d=l*h,f=l*u,m=c*h,_=c*u;e[0]=d+_*o,e[4]=m*o-f,e[8]=a*c,e[1]=a*u,e[5]=a*h,e[9]=-o,e[2]=f*o-m,e[6]=_+d*o,e[10]=a*l}else if(t.order==="ZXY"){const d=l*h,f=l*u,m=c*h,_=c*u;e[0]=d-_*o,e[4]=-a*u,e[8]=m+f*o,e[1]=f+m*o,e[5]=a*h,e[9]=_-d*o,e[2]=-a*c,e[6]=o,e[10]=a*l}else if(t.order==="ZYX"){const d=a*h,f=a*u,m=o*h,_=o*u;e[0]=l*h,e[4]=m*c-f,e[8]=d*c+_,e[1]=l*u,e[5]=_*c+d,e[9]=f*c-m,e[2]=-c,e[6]=o*l,e[10]=a*l}else if(t.order==="YZX"){const d=a*l,f=a*c,m=o*l,_=o*c;e[0]=l*h,e[4]=_-d*u,e[8]=m*u+f,e[1]=u,e[5]=a*h,e[9]=-o*h,e[2]=-c*h,e[6]=f*u+m,e[10]=d-_*u}else if(t.order==="XZY"){const d=a*l,f=a*c,m=o*l,_=o*c;e[0]=l*h,e[4]=-u,e[8]=c*h,e[1]=d*u+_,e[5]=a*h,e[9]=f*u-m,e[2]=m*u-f,e[6]=o*h,e[10]=_*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(Mp,t,Sp)}lookAt(t,e,n){const i=this.elements;return Ge.subVectors(t,e),Ge.lengthSq()===0&&(Ge.z=1),Ge.normalize(),zn.crossVectors(n,Ge),zn.lengthSq()===0&&(Math.abs(n.z)===1?Ge.x+=1e-4:Ge.z+=1e-4,Ge.normalize(),zn.crossVectors(n,Ge)),zn.normalize(),Mr.crossVectors(Ge,zn),i[0]=zn.x,i[4]=Mr.x,i[8]=Ge.x,i[1]=zn.y,i[5]=Mr.y,i[9]=Ge.y,i[2]=zn.z,i[6]=Mr.z,i[10]=Ge.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,s=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],f=n[13],m=n[2],_=n[6],g=n[10],p=n[14],v=n[3],x=n[7],y=n[11],I=n[15],w=i[0],C=i[4],P=i[8],b=i[12],M=i[1],L=i[5],k=i[9],O=i[13],V=i[2],q=i[6],H=i[10],tt=i[14],G=i[3],pt=i[7],yt=i[11],gt=i[15];return s[0]=a*w+o*M+l*V+c*G,s[4]=a*C+o*L+l*q+c*pt,s[8]=a*P+o*k+l*H+c*yt,s[12]=a*b+o*O+l*tt+c*gt,s[1]=h*w+u*M+d*V+f*G,s[5]=h*C+u*L+d*q+f*pt,s[9]=h*P+u*k+d*H+f*yt,s[13]=h*b+u*O+d*tt+f*gt,s[2]=m*w+_*M+g*V+p*G,s[6]=m*C+_*L+g*q+p*pt,s[10]=m*P+_*k+g*H+p*yt,s[14]=m*b+_*O+g*tt+p*gt,s[3]=v*w+x*M+y*V+I*G,s[7]=v*C+x*L+y*q+I*pt,s[11]=v*P+x*k+y*H+I*yt,s[15]=v*b+x*O+y*tt+I*gt,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],s=t[12],a=t[1],o=t[5],l=t[9],c=t[13],h=t[2],u=t[6],d=t[10],f=t[14],m=t[3],_=t[7],g=t[11],p=t[15];return m*(+s*l*u-i*c*u-s*o*d+n*c*d+i*o*f-n*l*f)+_*(+e*l*f-e*c*d+s*a*d-i*a*f+i*c*h-s*l*h)+g*(+e*c*u-e*o*f-s*a*u+n*a*f+s*o*h-n*c*h)+p*(-i*o*h-e*l*u+e*o*d+i*a*u-n*a*d+n*l*h)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],s=t[3],a=t[4],o=t[5],l=t[6],c=t[7],h=t[8],u=t[9],d=t[10],f=t[11],m=t[12],_=t[13],g=t[14],p=t[15],v=u*g*c-_*d*c+_*l*f-o*g*f-u*l*p+o*d*p,x=m*d*c-h*g*c-m*l*f+a*g*f+h*l*p-a*d*p,y=h*_*c-m*u*c+m*o*f-a*_*f-h*o*p+a*u*p,I=m*u*l-h*_*l-m*o*d+a*_*d+h*o*g-a*u*g,w=e*v+n*x+i*y+s*I;if(w===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const C=1/w;return t[0]=v*C,t[1]=(_*d*s-u*g*s-_*i*f+n*g*f+u*i*p-n*d*p)*C,t[2]=(o*g*s-_*l*s+_*i*c-n*g*c-o*i*p+n*l*p)*C,t[3]=(u*l*s-o*d*s-u*i*c+n*d*c+o*i*f-n*l*f)*C,t[4]=x*C,t[5]=(h*g*s-m*d*s+m*i*f-e*g*f-h*i*p+e*d*p)*C,t[6]=(m*l*s-a*g*s-m*i*c+e*g*c+a*i*p-e*l*p)*C,t[7]=(a*d*s-h*l*s+h*i*c-e*d*c-a*i*f+e*l*f)*C,t[8]=y*C,t[9]=(m*u*s-h*_*s-m*n*f+e*_*f+h*n*p-e*u*p)*C,t[10]=(a*_*s-m*o*s+m*n*c-e*_*c-a*n*p+e*o*p)*C,t[11]=(h*o*s-a*u*s-h*n*c+e*u*c+a*n*f-e*o*f)*C,t[12]=I*C,t[13]=(h*_*i-m*u*i+m*n*d-e*_*d-h*n*g+e*u*g)*C,t[14]=(m*o*i-a*_*i-m*n*l+e*_*l+a*n*g-e*o*g)*C,t[15]=(a*u*i-h*o*i+h*n*l-e*u*l-a*n*d+e*o*d)*C,this}scale(t){const e=this.elements,n=t.x,i=t.y,s=t.z;return e[0]*=n,e[4]*=i,e[8]*=s,e[1]*=n,e[5]*=i,e[9]*=s,e[2]*=n,e[6]*=i,e[10]*=s,e[3]*=n,e[7]*=i,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),s=1-n,a=t.x,o=t.y,l=t.z,c=s*a,h=s*o;return this.set(c*a+n,c*o-i*l,c*l+i*o,0,c*o+i*l,h*o+n,h*l-i*a,0,c*l-i*o,h*l+i*a,s*l*l+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,s,a){return this.set(1,n,s,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,s=e._x,a=e._y,o=e._z,l=e._w,c=s+s,h=a+a,u=o+o,d=s*c,f=s*h,m=s*u,_=a*h,g=a*u,p=o*u,v=l*c,x=l*h,y=l*u,I=n.x,w=n.y,C=n.z;return i[0]=(1-(_+p))*I,i[1]=(f+y)*I,i[2]=(m-x)*I,i[3]=0,i[4]=(f-y)*w,i[5]=(1-(d+p))*w,i[6]=(g+v)*w,i[7]=0,i[8]=(m+x)*C,i[9]=(g-v)*C,i[10]=(1-(d+_))*C,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;let s=Di.set(i[0],i[1],i[2]).length();const a=Di.set(i[4],i[5],i[6]).length(),o=Di.set(i[8],i[9],i[10]).length();this.determinant()<0&&(s=-s),t.x=i[12],t.y=i[13],t.z=i[14],tn.copy(this);const c=1/s,h=1/a,u=1/o;return tn.elements[0]*=c,tn.elements[1]*=c,tn.elements[2]*=c,tn.elements[4]*=h,tn.elements[5]*=h,tn.elements[6]*=h,tn.elements[8]*=u,tn.elements[9]*=u,tn.elements[10]*=u,e.setFromRotationMatrix(tn),n.x=s,n.y=a,n.z=o,this}makePerspective(t,e,n,i,s,a,o=dn){const l=this.elements,c=2*s/(e-t),h=2*s/(n-i),u=(e+t)/(e-t),d=(n+i)/(n-i);let f,m;if(o===dn)f=-(a+s)/(a-s),m=-2*a*s/(a-s);else if(o===Ys)f=-a/(a-s),m=-a*s/(a-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=c,l[4]=0,l[8]=u,l[12]=0,l[1]=0,l[5]=h,l[9]=d,l[13]=0,l[2]=0,l[6]=0,l[10]=f,l[14]=m,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,i,s,a,o=dn){const l=this.elements,c=1/(e-t),h=1/(n-i),u=1/(a-s),d=(e+t)*c,f=(n+i)*h;let m,_;if(o===dn)m=(a+s)*u,_=-2*u;else if(o===Ys)m=s*u,_=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=2*c,l[4]=0,l[8]=0,l[12]=-d,l[1]=0,l[5]=2*h,l[9]=0,l[13]=-f,l[2]=0,l[6]=0,l[10]=_,l[14]=-m,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const Di=new T,tn=new Rt,Mp=new T(0,0,0),Sp=new T(1,1,1),zn=new T,Mr=new T,Ge=new T,Cc=new Rt,Rc=new ze;class Ye{constructor(t=0,e=0,n=0,i=Ye.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,s=i[0],a=i[4],o=i[8],l=i[1],c=i[5],h=i[9],u=i[2],d=i[6],f=i[10];switch(e){case"XYZ":this._y=Math.asin(he(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-he(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(he(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,s));break;case"ZYX":this._y=Math.asin(-he(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(l,s)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(he(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-he(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Cc.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Cc,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Rc.setFromEuler(this),this.setFromQuaternion(Rc,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ye.DEFAULT_ORDER="XYZ";class Qa{constructor(){this.mask=1}set(t){this.mask=(1<>>0}enable(t){this.mask|=1<1){for(let e=0;e1){for(let n=0;n0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(o=>({boxInitialized:o.boxInitialized,boxMin:o.box.min.toArray(),boxMax:o.box.max.toArray(),sphereInitialized:o.sphereInitialized,sphereRadius:o.sphere.radius,sphereCenter:o.sphere.center.toArray()})),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function s(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(t)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=s(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c0){i.children=[];for(let o=0;o0){i.animations=[];for(let o=0;o0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),m.length>0&&(n.nodes=m)}return n.object=i,n;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n0?i.multiplyScalar(1/Math.sqrt(s)):i.set(0,0,0)}static getBarycoord(t,e,n,i,s){en.subVectors(i,e),Mn.subVectors(n,e),Fo.subVectors(t,e);const a=en.dot(en),o=en.dot(Mn),l=en.dot(Fo),c=Mn.dot(Mn),h=Mn.dot(Fo),u=a*c-o*o;if(u===0)return s.set(0,0,0),null;const d=1/u,f=(c*l-o*h)*d,m=(a*h-o*l)*d;return s.set(1-f-m,m,f)}static containsPoint(t,e,n,i){return this.getBarycoord(t,e,n,i,Sn)===null?!1:Sn.x>=0&&Sn.y>=0&&Sn.x+Sn.y<=1}static getInterpolation(t,e,n,i,s,a,o,l){return this.getBarycoord(t,e,n,i,Sn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(s,Sn.x),l.addScaledVector(a,Sn.y),l.addScaledVector(o,Sn.z),l)}static isFrontFacing(t,e,n,i){return en.subVectors(n,e),Mn.subVectors(t,e),en.cross(Mn).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return en.subVectors(this.c,this.b),Mn.subVectors(this.a,this.b),en.cross(Mn).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Xe.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Xe.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,s){return Xe.getInterpolation(t,this.a,this.b,this.c,e,n,i,s)}containsPoint(t){return Xe.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Xe.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,s=this.c;let a,o;Fi.subVectors(i,n),Bi.subVectors(s,n),Bo.subVectors(t,n);const l=Fi.dot(Bo),c=Bi.dot(Bo);if(l<=0&&c<=0)return e.copy(n);zo.subVectors(t,i);const h=Fi.dot(zo),u=Bi.dot(zo);if(h>=0&&u<=h)return e.copy(i);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return a=l/(l-h),e.copy(n).addScaledVector(Fi,a);ko.subVectors(t,s);const f=Fi.dot(ko),m=Bi.dot(ko);if(m>=0&&f<=m)return e.copy(s);const _=f*c-l*m;if(_<=0&&c>=0&&m<=0)return o=c/(c-m),e.copy(n).addScaledVector(Bi,o);const g=h*m-f*u;if(g<=0&&u-h>=0&&f-m>=0)return Nc.subVectors(s,i),o=(u-h)/(u-h+(f-m)),e.copy(i).addScaledVector(Nc,o);const p=1/(g+_+d);return a=_*p,o=d*p,e.copy(n).addScaledVector(Fi,a).addScaledVector(Bi,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const id={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},kn={h:0,s:0,l:0},br={h:0,s:0,l:0};function Vo(r,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}class ft{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=$e){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Kt.toWorkingColorSpace(this,e),this}setRGB(t,e,n,i=Kt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Kt.toWorkingColorSpace(this,i),this}setHSL(t,e,n,i=Kt.workingColorSpace){if(t=Hl(t,1),e=he(e,0,1),n=he(n,0,1),e===0)this.r=this.g=this.b=n;else{const s=n<=.5?n*(1+e):n+e-n*e,a=2*n-s;this.r=Vo(a,s,t+1/3),this.g=Vo(a,s,t),this.b=Vo(a,s,t-1/3)}return Kt.toWorkingColorSpace(this,i),this}setStyle(t,e=$e){function n(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))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,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))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,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=i[1],a=s.length;if(a===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(s,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=$e){const n=id[t.toLowerCase()];return n!==void 0?this.setHex(n,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=ns(t.r),this.g=ns(t.g),this.b=ns(t.b),this}copyLinearToSRGB(t){return this.r=Co(t.r),this.g=Co(t.g),this.b=Co(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=$e){return Kt.fromWorkingColorSpace(Ee.copy(this),t),Math.round(he(Ee.r*255,0,255))*65536+Math.round(he(Ee.g*255,0,255))*256+Math.round(he(Ee.b*255,0,255))}getHexString(t=$e){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Kt.workingColorSpace){Kt.fromWorkingColorSpace(Ee.copy(this),e);const n=Ee.r,i=Ee.g,s=Ee.b,a=Math.max(n,i,s),o=Math.min(n,i,s);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const u=a-o;switch(c=h<=.5?u/(a+o):u/(2-a-o),a){case n:l=(i-s)/u+(i0!=t>0&&this.version++,this._alphaTest=t}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==xi&&(n.blending=this.blending),this.side!==Rn&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==ca&&(n.blendSrc=this.blendSrc),this.blendDst!==ha&&(n.blendDst=this.blendDst),this.blendEquation!==Xn&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Os&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==xl&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ui&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ui&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ui&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(s){const a=[];for(const o in s){const l=s[o];delete l.metadata,a.push(l)}return a}if(e){const s=i(t.textures),a=i(t.images);s.length>0&&(n.textures=s),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const i=e.length;n=new Array(i);for(let s=0;s!==i;++s)n[s]=e[s].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}onBeforeRender(){console.warn("Material: onBeforeRender() has been removed.")}}class Jn extends Re{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ft(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ye,this.combine=ir,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const wn=Cp();function Cp(){const r=new ArrayBuffer(4),t=new Float32Array(r),e=new Uint32Array(r),n=new Uint32Array(512),i=new Uint32Array(512);for(let l=0;l<256;++l){const c=l-127;c<-27?(n[l]=0,n[l|256]=32768,i[l]=24,i[l|256]=24):c<-14?(n[l]=1024>>-c-14,n[l|256]=1024>>-c-14|32768,i[l]=-c-1,i[l|256]=-c-1):c<=15?(n[l]=c+15<<10,n[l|256]=c+15<<10|32768,i[l]=13,i[l|256]=13):c<128?(n[l]=31744,n[l|256]=64512,i[l]=24,i[l|256]=24):(n[l]=31744,n[l|256]=64512,i[l]=13,i[l|256]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let l=1;l<1024;++l){let c=l<<13,h=0;for(;!(c&8388608);)c<<=1,h-=8388608;c&=-8388609,h+=947912704,s[l]=c|h}for(let l=1024;l<2048;++l)s[l]=939524096+(l-1024<<13);for(let l=1;l<31;++l)a[l]=l<<23;a[31]=1199570944,a[32]=2147483648;for(let l=33;l<63;++l)a[l]=2147483648+(l-32<<23);a[63]=3347054592;for(let l=1;l<64;++l)l!==32&&(o[l]=1024);return{floatView:t,uint32View:e,baseTable:n,shiftTable:i,mantissaTable:s,exponentTable:a,offsetTable:o}}function Fe(r){Math.abs(r)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),r=he(r,-65504,65504),wn.floatView[0]=r;const t=wn.uint32View[0],e=t>>23&511;return wn.baseTable[e]+((t&8388607)>>wn.shiftTable[e])}function ws(r){const t=r>>10;return wn.uint32View[0]=wn.mantissaTable[wn.offsetTable[t]+(r&1023)]+wn.exponentTable[t],wn.floatView[0]}const Rp={toHalfFloat:Fe,fromHalfFloat:ws},me=new T,Ar=new Z;class ie{constructor(t,e,n=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=qs,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Be,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return Gl("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,s=this.itemSize;i0&&(t.userData=this.userData),this.parameters!==void 0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(t[c]=l[c]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const l in n){const c=n[l];t.data.attributes[l]=c.toJSON(t.data)}const i={};let s=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u0&&(i[l]=h,s=!0)}s&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone(e));const i=t.attributes;for(const c in i){const h=i[c];this.setAttribute(c,h.clone(e))}const s=t.morphAttributes;for(const c in s){const h=[],u=s[c];for(let d=0,f=u.length;d0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;s(t.far-t.near)**2))&&(Oc.copy(s).invert(),ei.copy(t.ray).applyMatrix4(Oc),!(n.boundingBox!==null&&ei.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,ei)))}_computeIntersections(t,e,n){let i;const s=this.geometry,a=this.material,o=s.index,l=s.attributes.position,c=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,d=s.groups,f=s.drawRange;if(o!==null)if(Array.isArray(a))for(let m=0,_=d.length;m<_;m++){const g=d[m],p=a[g.materialIndex],v=Math.max(g.start,f.start),x=Math.min(o.count,Math.min(g.start+g.count,f.start+f.count));for(let y=v,I=x;ye.far?null:{distance:c,point:Ir.clone(),object:r}}function Lr(r,t,e,n,i,s,a,o,l,c){r.getVertexPosition(o,ki),r.getVertexPosition(l,Vi),r.getVertexPosition(c,Hi);const h=Fp(r,t,e,n,ki,Vi,Hi,Pr);if(h){i&&(Tr.fromBufferAttribute(i,o),Cr.fromBufferAttribute(i,l),Rr.fromBufferAttribute(i,c),h.uv=Xe.getInterpolation(Pr,ki,Vi,Hi,Tr,Cr,Rr,new Z)),s&&(Tr.fromBufferAttribute(s,o),Cr.fromBufferAttribute(s,l),Rr.fromBufferAttribute(s,c),h.uv1=Xe.getInterpolation(Pr,ki,Vi,Hi,Tr,Cr,Rr,new Z)),a&&(Bc.fromBufferAttribute(a,o),zc.fromBufferAttribute(a,l),kc.fromBufferAttribute(a,c),h.normal=Xe.getInterpolation(Pr,ki,Vi,Hi,Bc,zc,kc,new T),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const u={a:o,b:l,c,normal:new T,materialIndex:0};Xe.getNormal(ki,Vi,Hi,u.normal),h.face=u}return h}class Ei extends Ht{constructor(t=1,e=1,n=1,i=1,s=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:s,depthSegments:a};const o=this;i=Math.floor(i),s=Math.floor(s),a=Math.floor(a);const l=[],c=[],h=[],u=[];let d=0,f=0;m("z","y","x",-1,-1,n,e,t,a,s,0),m("z","y","x",1,-1,n,e,-t,a,s,1),m("x","z","y",1,1,t,n,e,i,a,2),m("x","z","y",1,-1,t,n,-e,i,a,3),m("x","y","z",1,-1,t,e,n,i,s,4),m("x","y","z",-1,-1,t,e,-n,i,s,5),this.setIndex(l),this.setAttribute("position",new bt(c,3)),this.setAttribute("normal",new bt(h,3)),this.setAttribute("uv",new bt(u,2));function m(_,g,p,v,x,y,I,w,C,P,b){const M=y/C,L=I/P,k=y/2,O=I/2,V=w/2,q=C+1,H=P+1;let tt=0,G=0;const pt=new T;for(let yt=0;yt0?1:-1,h.push(pt.x,pt.y,pt.z),u.push(Gt/C),u.push(1-yt/P),tt+=1}}for(let yt=0;yt0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}}class ja extends Zt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Rt,this.projectionMatrix=new Rt,this.projectionMatrixInverse=new Rt,this.coordinateSystem=dn}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Vn=new T,Vc=new Z,Hc=new Z;class Ae extends ja{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=ss*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(yi*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return ss*2*Math.atan(Math.tan(yi*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){Vn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Vn.x,Vn.y).multiplyScalar(-t/Vn.z),Vn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Vn.x,Vn.y).multiplyScalar(-t/Vn.z)}getViewSize(t,e){return this.getViewBounds(t,Vc,Hc),e.subVectors(Hc,Vc)}setViewOffset(t,e,n,i,s,a){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(yi*.5*this.fov)/this.zoom,n=2*e,i=this.aspect*n,s=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;s+=a.offsetX*i/l,e-=a.offsetY*n/c,i*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(s+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+i,e,e-n,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const Gi=-90,Wi=1;class ad extends Zt{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Ae(Gi,Wi,t,e);i.layers=this.layers,this.add(i);const s=new Ae(Gi,Wi,t,e);s.layers=this.layers,this.add(s);const a=new Ae(Gi,Wi,t,e);a.layers=this.layers,this.add(a);const o=new Ae(Gi,Wi,t,e);o.layers=this.layers,this.add(o);const l=new Ae(Gi,Wi,t,e);l.layers=this.layers,this.add(l);const c=new Ae(Gi,Wi,t,e);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,s,a,o,l]=e;for(const c of e)this.remove(c);if(t===dn)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(t===Ys)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const c of e)this.add(c),c.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[s,a,o,l,c,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),f=t.getActiveMipmapLevel(),m=t.xr.enabled;t.xr.enabled=!1;const _=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,t.setRenderTarget(n,0,i),t.render(e,s),t.setRenderTarget(n,1,i),t.render(e,a),t.setRenderTarget(n,2,i),t.render(e,o),t.setRenderTarget(n,3,i),t.render(e,l),t.setRenderTarget(n,4,i),t.render(e,c),n.texture.generateMipmaps=_,t.setRenderTarget(n,5,i),t.render(e,h),t.setRenderTarget(u,d,f),t.xr.enabled=m,n.texture.needsPMREMUpdate=!0}}class ar extends ue{constructor(t,e,n,i,s,a,o,l,c,h){t=t!==void 0?t:[],e=e!==void 0?e:Pn,super(t,e,n,i,s,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class od extends sn{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},i=[n,n,n,n,n,n];this.texture=new ar(i,e.mapping,e.wrapS,e.wrapT,e.magFilter,e.minFilter,e.format,e.type,e.anisotropy,e.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=e.generateMipmaps!==void 0?e.generateMipmaps:!1,this.texture.minFilter=e.minFilter!==void 0?e.minFilter:ge}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},i=new Ei(5,5,5),s=new rn({name:"CubemapFromEquirect",uniforms:rs(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:De,blending:Tn});s.uniforms.tEquirect.value=e;const a=new _e(i,s),o=e.minFilter;return e.minFilter===un&&(e.minFilter=ge),new ad(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e,n,i){const s=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,i);t.setRenderTarget(s)}}const Wo=new T,Vp=new T,Hp=new Bt;class Wn{constructor(t=new T(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=Wo.subVectors(n,e).cross(Vp.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const n=t.delta(Wo),i=this.normal.dot(n);if(i===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const s=-(t.start.dot(this.normal)+this.constant)/i;return s<0||s>1?null:e.copy(t.start).addScaledVector(n,s)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||Hp.getNormalMatrix(t),i=this.coplanarPoint(Wo).applyMatrix4(t),s=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const ni=new Ce,Ur=new T;class or{constructor(t=new Wn,e=new Wn,n=new Wn,i=new Wn,s=new Wn,a=new Wn){this.planes=[t,e,n,i,s,a]}set(t,e,n,i,s,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(i),o[4].copy(s),o[5].copy(a),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=dn){const n=this.planes,i=t.elements,s=i[0],a=i[1],o=i[2],l=i[3],c=i[4],h=i[5],u=i[6],d=i[7],f=i[8],m=i[9],_=i[10],g=i[11],p=i[12],v=i[13],x=i[14],y=i[15];if(n[0].setComponents(l-s,d-c,g-f,y-p).normalize(),n[1].setComponents(l+s,d+c,g+f,y+p).normalize(),n[2].setComponents(l+a,d+h,g+m,y+v).normalize(),n[3].setComponents(l-a,d-h,g-m,y-v).normalize(),n[4].setComponents(l-o,d-u,g-_,y-x).normalize(),e===dn)n[5].setComponents(l+o,d+u,g+_,y+x).normalize();else if(e===Ys)n[5].setComponents(o,u,_,x).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),ni.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),ni.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(ni)}intersectsSprite(t){return ni.center.set(0,0,0),ni.radius=.7071067811865476,ni.applyMatrix4(t.matrixWorld),this.intersectsSphere(ni)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(n)0?t.max.x:t.min.x,Ur.y=i.normal.y>0?t.max.y:t.min.y,Ur.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(Ur)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function ld(){let r=null,t=!1,e=null,n=null;function i(s,a){e(s,a),n=r.requestAnimationFrame(i)}return{start:function(){t!==!0&&e!==null&&(n=r.requestAnimationFrame(i),t=!0)},stop:function(){r.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(s){e=s},setContext:function(s){r=s}}}function Gp(r){const t=new WeakMap;function e(o,l){const c=o.array,h=o.usage,u=c.byteLength,d=r.createBuffer();r.bindBuffer(l,d),r.bufferData(l,c,h),o.onUploadCallback();let f;if(c instanceof Float32Array)f=r.FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=r.HALF_FLOAT:f=r.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=r.SHORT;else if(c instanceof Uint32Array)f=r.UNSIGNED_INT;else if(c instanceof Int32Array)f=r.INT;else if(c instanceof Int8Array)f=r.BYTE;else if(c instanceof Uint8Array)f=r.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:d,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,l,c){const h=l.array,u=l._updateRange,d=l.updateRanges;if(r.bindBuffer(c,o),u.count===-1&&d.length===0&&r.bufferSubData(c,0,h),d.length!==0){for(let f=0,m=d.length;f 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,am=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,om=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,lm=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,cm=`#if defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#elif defined( USE_COLOR ) + diffuseColor.rgb *= vColor; +#endif`,hm=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) + varying vec3 vColor; +#endif`,um=`#if defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec3 vColor; +#endif`,dm=`#if defined( USE_COLOR_ALPHA ) + vColor = vec4( 1.0 ); +#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + vColor = vec3( 1.0 ); +#endif +#ifdef USE_COLOR + vColor *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.xyz *= instanceColor.xyz; +#endif +#ifdef USE_BATCHING_COLOR + vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) ); + vColor.xyz *= batchingColor.xyz; +#endif`,fm=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); +} +mat3 transposeMat3( const in mat3 m ) { + mat3 tmp; + tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x ); + tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y ); + tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z ); + return tmp; +} +float luminance( const in vec3 rgb ) { + const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 ); + return dot( weights, rgb ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} +float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { + float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); + return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); +} // validated`,pm=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,mm=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; + #ifdef FLIP_SIDED + transformedTangent = - transformedTangent; + #endif +#endif`,gm=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,_m=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,xm=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,vm=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,ym="gl_FragColor = linearToOutputTexel( gl_FragColor );",Mm=` +const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3( + vec3( 0.8224621, 0.177538, 0.0 ), + vec3( 0.0331941, 0.9668058, 0.0 ), + vec3( 0.0170827, 0.0723974, 0.9105199 ) +); +const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3( + vec3( 1.2249401, - 0.2249404, 0.0 ), + vec3( - 0.0420569, 1.0420571, 0.0 ), + vec3( - 0.0196376, - 0.0786361, 1.0982735 ) +); +vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) { + return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a ); +} +vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) { + return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a ); +} +vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferOETF( in vec4 value ) { + return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); +} +vec4 LinearToLinear( in vec4 value ) { + return value; +} +vec4 LinearTosRGB( in vec4 value ) { + return sRGBTransferOETF( value ); +}`,Sm=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); + #else + vec4 envColor = vec4( 0.0 ); + #endif + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif +#endif`,bm=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform float flipEnvMap; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif + +#endif`,Am=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,wm=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,Em=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,Tm=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,Cm=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,Rm=`#ifdef USE_FOG + #ifdef FOG_EXP2 + float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); + #else + float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); + #endif + gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); +#endif`,Pm=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,Im=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + vec2 fw = fwidth( coord ) * 0.5; + return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); + #endif +}`,Lm=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,Um=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,Dm=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Nm=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif`,Om=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) ); + reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,Fm=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Bm=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,zm=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,km=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Vm=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); + material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; + material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; +#endif`,Hm=`struct PhysicalMaterial { + vec3 diffuseColor; + float roughness; + vec3 specularColor; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + float v = 0.5 / ( gv + gl ); + return saturate(v); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColor; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95; + float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72; + float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ); + return saturate( DG * RECIPROCAL_PI ); +} +vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); + const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 ); + vec4 r = roughness * c0 + c1; + float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y; + vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw; + return fab; +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + vec2 fab = DFGApprox( normal, viewDir, roughness ); + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + vec2 fab = DFGApprox( normal, viewDir, roughness ); + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + #endif + vec3 singleScattering = vec3( 0.0 ); + vec3 multiScattering = vec3( 0.0 ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering ); + #endif + vec3 totalScattering = singleScattering + multiScattering; + vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) ); + reflectedLight.indirectSpecular += radiance * singleScattering; + reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance; + reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,Gm=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,Wm=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,Xm=`#if defined( RE_IndirectDiffuse ) + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,qm=`#if defined( USE_LOGDEPTHBUF ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,Ym=`#if defined( USE_LOGDEPTHBUF ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,Zm=`#ifdef USE_LOGDEPTHBUF + varying float vFragDepth; + varying float vIsPerspective; +#endif`,Jm=`#ifdef USE_LOGDEPTHBUF + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,$m=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w ); + + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,Km=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,Qm=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,jm=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,tg=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,eg=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,ng=`#ifdef USE_INSTANCING_MORPH + float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; + } +#endif`,ig=`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,sg=`#ifdef USE_MORPHNORMALS + objectNormal *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,rg=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,ag=`#ifdef USE_MORPHTARGETS + transformed *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; + } +#endif`,og=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,lg=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,cg=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,hg=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,ug=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #endif +#endif`,dg=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,fg=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,pg=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,mg=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,gg=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,_g=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,xg=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.; +const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); +const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); +const float ShiftRight8 = 1. / 256.; +vec4 packDepthToRGBA( const in float v ) { + vec4 r = vec4( fract( v * PackFactors ), v ); + r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale; +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors ); +} +vec2 packDepthToRG( in highp float v ) { + return packDepthToRGBA( v ).yx; +} +float unpackRGToDepth( const in highp vec2 v ) { + return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) ); +} +vec4 pack2HalfToRGBA( vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + return depth * ( near - far ) - near; +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + return ( near * far ) / ( ( far - near ) * depth - far ); +}`,vg=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,yg=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,Mg=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,Sg=`#ifdef DITHERING + vec3 dithering( vec3 color ) { + float grid_position = rand( gl_FragCoord.xy ); + vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); + dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); + return color + dither_shift_RGB; + } +#endif`,bg=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,Ag=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,wg=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + float texture2DCompare( sampler2D depths, vec2 uv, float compare ) { + return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) ); + } + vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) { + return unpackRGBATo2Half( texture2D( shadow, uv ) ); + } + float VSMShadow (sampler2D shadow, vec2 uv, float compare ){ + float occlusion = 1.0; + vec2 distribution = texture2DDistribution( shadow, uv ); + float hard_shadow = step( compare , distribution.x ); + if (hard_shadow != 1.0 ) { + float distance = compare - distribution.x ; + float variance = max( 0.00000, distribution.y * distribution.y ); + float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 ); + } + return occlusion; + } + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + #if defined( SHADOWMAP_TYPE_PCF ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx0 = - texelSize.x * shadowRadius; + float dy0 = - texelSize.y * shadowRadius; + float dx1 = + texelSize.x * shadowRadius; + float dy1 = + texelSize.y * shadowRadius; + float dx2 = dx0 / 2.0; + float dy2 = dy0 / 2.0; + float dx3 = dx1 / 2.0; + float dy3 = dy1 / 2.0; + shadow = ( + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) + + texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z ) + ) * ( 1.0 / 17.0 ); + #elif defined( SHADOWMAP_TYPE_PCF_SOFT ) + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float dx = texelSize.x; + float dy = texelSize.y; + vec2 uv = shadowCoord.xy; + vec2 f = fract( uv * shadowMapSize + 0.5 ); + uv -= f * texelSize; + shadow = ( + texture2DCompare( shadowMap, uv, shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) + + texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ), + f.x ) + + mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ), + f.y ) + + mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ), + f.x ), + mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), + texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ), + f.x ), + f.y ) + ) * ( 1.0 / 9.0 ); + #elif defined( SHADOWMAP_TYPE_VSM ) + shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z ); + #else + shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + vec2 cubeToUV( vec3 v, float texelSizeY ) { + vec3 absV = abs( v ); + float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) ); + absV *= scaleToCube; + v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ); + vec2 planar = v.xy; + float almostATexel = 1.5 * texelSizeY; + float almostOne = 1.0 - almostATexel; + if ( absV.z >= almostOne ) { + if ( v.z > 0.0 ) + planar.x = 4.0 - v.x; + } else if ( absV.x >= almostOne ) { + float signX = sign( v.x ); + planar.x = v.z * signX + 2.0 * signX; + } else if ( absV.y >= almostOne ) { + float signY = sign( v.y ); + planar.x = v.x + 2.0 * signY + 2.0; + planar.y = v.z * signY - 2.0; + } + return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 ); + } + float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + + float lightToPositionLength = length( lightToPosition ); + if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) { + float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) ); + #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM ) + vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y; + shadow = ( + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) + + texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp ) + ) * ( 1.0 / 9.0 ); + #else + shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } +#endif`,Eg=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,Tg=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,Cg=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,Rg=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,Pg=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,Ig=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,Lg=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,Ug=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,Dg=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,Ng=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,Og=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 OptimizedCineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,Fg=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = inverseTransformDirection( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,Bg=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + + #else + + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,zg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,kg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,Vg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,Hg=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 + vec4 worldPosition = vec4( transformed, 1.0 ); + #ifdef USE_BATCHING + worldPosition = batchingMatrix * worldPosition; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`;const Gg=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,Wg=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,Xg=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,qg=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float flipEnvMap; +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,Yg=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,Zg=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,Jg=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,$g=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5; + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #endif +}`,Kg=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,Qg=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +#include +void main () { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = packDepthToRGBA( dist ); +}`,jg=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,t_=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,e_=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,n_=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,i_=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,s_=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,r_=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,a_=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,o_=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,l_=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,c_=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,h_=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,u_=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,d_=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,f_=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,p_=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor ); + outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect; + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,m_=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,g_=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,__=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,x_=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,v_=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,y_=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include +}`,M_=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); + vec2 scale; + scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); + scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,S_=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,kt={alphahash_fragment:Wp,alphahash_pars_fragment:Xp,alphamap_fragment:qp,alphamap_pars_fragment:Yp,alphatest_fragment:Zp,alphatest_pars_fragment:Jp,aomap_fragment:$p,aomap_pars_fragment:Kp,batching_pars_vertex:Qp,batching_vertex:jp,begin_vertex:tm,beginnormal_vertex:em,bsdfs:nm,iridescence_fragment:im,bumpmap_pars_fragment:sm,clipping_planes_fragment:rm,clipping_planes_pars_fragment:am,clipping_planes_pars_vertex:om,clipping_planes_vertex:lm,color_fragment:cm,color_pars_fragment:hm,color_pars_vertex:um,color_vertex:dm,common:fm,cube_uv_reflection_fragment:pm,defaultnormal_vertex:mm,displacementmap_pars_vertex:gm,displacementmap_vertex:_m,emissivemap_fragment:xm,emissivemap_pars_fragment:vm,colorspace_fragment:ym,colorspace_pars_fragment:Mm,envmap_fragment:Sm,envmap_common_pars_fragment:bm,envmap_pars_fragment:Am,envmap_pars_vertex:wm,envmap_physical_pars_fragment:Om,envmap_vertex:Em,fog_vertex:Tm,fog_pars_vertex:Cm,fog_fragment:Rm,fog_pars_fragment:Pm,gradientmap_pars_fragment:Im,lightmap_pars_fragment:Lm,lights_lambert_fragment:Um,lights_lambert_pars_fragment:Dm,lights_pars_begin:Nm,lights_toon_fragment:Fm,lights_toon_pars_fragment:Bm,lights_phong_fragment:zm,lights_phong_pars_fragment:km,lights_physical_fragment:Vm,lights_physical_pars_fragment:Hm,lights_fragment_begin:Gm,lights_fragment_maps:Wm,lights_fragment_end:Xm,logdepthbuf_fragment:qm,logdepthbuf_pars_fragment:Ym,logdepthbuf_pars_vertex:Zm,logdepthbuf_vertex:Jm,map_fragment:$m,map_pars_fragment:Km,map_particle_fragment:Qm,map_particle_pars_fragment:jm,metalnessmap_fragment:tg,metalnessmap_pars_fragment:eg,morphinstance_vertex:ng,morphcolor_vertex:ig,morphnormal_vertex:sg,morphtarget_pars_vertex:rg,morphtarget_vertex:ag,normal_fragment_begin:og,normal_fragment_maps:lg,normal_pars_fragment:cg,normal_pars_vertex:hg,normal_vertex:ug,normalmap_pars_fragment:dg,clearcoat_normal_fragment_begin:fg,clearcoat_normal_fragment_maps:pg,clearcoat_pars_fragment:mg,iridescence_pars_fragment:gg,opaque_fragment:_g,packing:xg,premultiplied_alpha_fragment:vg,project_vertex:yg,dithering_fragment:Mg,dithering_pars_fragment:Sg,roughnessmap_fragment:bg,roughnessmap_pars_fragment:Ag,shadowmap_pars_fragment:wg,shadowmap_pars_vertex:Eg,shadowmap_vertex:Tg,shadowmask_pars_fragment:Cg,skinbase_vertex:Rg,skinning_pars_vertex:Pg,skinning_vertex:Ig,skinnormal_vertex:Lg,specularmap_fragment:Ug,specularmap_pars_fragment:Dg,tonemapping_fragment:Ng,tonemapping_pars_fragment:Og,transmission_fragment:Fg,transmission_pars_fragment:Bg,uv_pars_fragment:zg,uv_pars_vertex:kg,uv_vertex:Vg,worldpos_vertex:Hg,background_vert:Gg,background_frag:Wg,backgroundCube_vert:Xg,backgroundCube_frag:qg,cube_vert:Yg,cube_frag:Zg,depth_vert:Jg,depth_frag:$g,distanceRGBA_vert:Kg,distanceRGBA_frag:Qg,equirect_vert:jg,equirect_frag:t_,linedashed_vert:e_,linedashed_frag:n_,meshbasic_vert:i_,meshbasic_frag:s_,meshlambert_vert:r_,meshlambert_frag:a_,meshmatcap_vert:o_,meshmatcap_frag:l_,meshnormal_vert:c_,meshnormal_frag:h_,meshphong_vert:u_,meshphong_frag:d_,meshphysical_vert:f_,meshphysical_frag:p_,meshtoon_vert:m_,meshtoon_frag:g_,points_vert:__,points_frag:x_,shadow_vert:v_,shadow_frag:y_,sprite_vert:M_,sprite_frag:S_},ot={common:{diffuse:{value:new ft(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Bt},alphaMap:{value:null},alphaMapTransform:{value:new Bt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Bt}},envmap:{envMap:{value:null},envMapRotation:{value:new Bt},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Bt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Bt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Bt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Bt},normalScale:{value:new Z(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Bt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Bt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Bt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Bt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ft(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new ft(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Bt},alphaTest:{value:0},uvTransform:{value:new Bt}},sprite:{diffuse:{value:new ft(16777215)},opacity:{value:1},center:{value:new Z(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Bt},alphaMap:{value:null},alphaMapTransform:{value:new Bt},alphaTest:{value:0}}},nn={basic:{uniforms:Ie([ot.common,ot.specularmap,ot.envmap,ot.aomap,ot.lightmap,ot.fog]),vertexShader:kt.meshbasic_vert,fragmentShader:kt.meshbasic_frag},lambert:{uniforms:Ie([ot.common,ot.specularmap,ot.envmap,ot.aomap,ot.lightmap,ot.emissivemap,ot.bumpmap,ot.normalmap,ot.displacementmap,ot.fog,ot.lights,{emissive:{value:new ft(0)}}]),vertexShader:kt.meshlambert_vert,fragmentShader:kt.meshlambert_frag},phong:{uniforms:Ie([ot.common,ot.specularmap,ot.envmap,ot.aomap,ot.lightmap,ot.emissivemap,ot.bumpmap,ot.normalmap,ot.displacementmap,ot.fog,ot.lights,{emissive:{value:new ft(0)},specular:{value:new ft(1118481)},shininess:{value:30}}]),vertexShader:kt.meshphong_vert,fragmentShader:kt.meshphong_frag},standard:{uniforms:Ie([ot.common,ot.envmap,ot.aomap,ot.lightmap,ot.emissivemap,ot.bumpmap,ot.normalmap,ot.displacementmap,ot.roughnessmap,ot.metalnessmap,ot.fog,ot.lights,{emissive:{value:new ft(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:kt.meshphysical_vert,fragmentShader:kt.meshphysical_frag},toon:{uniforms:Ie([ot.common,ot.aomap,ot.lightmap,ot.emissivemap,ot.bumpmap,ot.normalmap,ot.displacementmap,ot.gradientmap,ot.fog,ot.lights,{emissive:{value:new ft(0)}}]),vertexShader:kt.meshtoon_vert,fragmentShader:kt.meshtoon_frag},matcap:{uniforms:Ie([ot.common,ot.bumpmap,ot.normalmap,ot.displacementmap,ot.fog,{matcap:{value:null}}]),vertexShader:kt.meshmatcap_vert,fragmentShader:kt.meshmatcap_frag},points:{uniforms:Ie([ot.points,ot.fog]),vertexShader:kt.points_vert,fragmentShader:kt.points_frag},dashed:{uniforms:Ie([ot.common,ot.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:kt.linedashed_vert,fragmentShader:kt.linedashed_frag},depth:{uniforms:Ie([ot.common,ot.displacementmap]),vertexShader:kt.depth_vert,fragmentShader:kt.depth_frag},normal:{uniforms:Ie([ot.common,ot.bumpmap,ot.normalmap,ot.displacementmap,{opacity:{value:1}}]),vertexShader:kt.meshnormal_vert,fragmentShader:kt.meshnormal_frag},sprite:{uniforms:Ie([ot.sprite,ot.fog]),vertexShader:kt.sprite_vert,fragmentShader:kt.sprite_frag},background:{uniforms:{uvTransform:{value:new Bt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:kt.background_vert,fragmentShader:kt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Bt}},vertexShader:kt.backgroundCube_vert,fragmentShader:kt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:kt.cube_vert,fragmentShader:kt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:kt.equirect_vert,fragmentShader:kt.equirect_frag},distanceRGBA:{uniforms:Ie([ot.common,ot.displacementmap,{referencePosition:{value:new T},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:kt.distanceRGBA_vert,fragmentShader:kt.distanceRGBA_frag},shadow:{uniforms:Ie([ot.lights,ot.fog,{color:{value:new ft(0)},opacity:{value:1}}]),vertexShader:kt.shadow_vert,fragmentShader:kt.shadow_frag}};nn.physical={uniforms:Ie([nn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Bt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Bt},clearcoatNormalScale:{value:new Z(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Bt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Bt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Bt},sheen:{value:0},sheenColor:{value:new ft(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Bt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Bt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Bt},transmissionSamplerSize:{value:new Z},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Bt},attenuationDistance:{value:0},attenuationColor:{value:new ft(0)},specularColor:{value:new ft(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Bt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Bt},anisotropyVector:{value:new Z},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Bt}}]),vertexShader:kt.meshphysical_vert,fragmentShader:kt.meshphysical_frag};const Dr={r:0,b:0,g:0},ii=new Ye,b_=new Rt;function A_(r,t,e,n,i,s,a){const o=new ft(0);let l=s===!0?0:1,c,h,u=null,d=0,f=null;function m(v){let x=v.isScene===!0?v.background:null;return x&&x.isTexture&&(x=(v.backgroundBlurriness>0?e:t).get(x)),x}function _(v){let x=!1;const y=m(v);y===null?p(o,l):y&&y.isColor&&(p(y,1),x=!0);const I=r.xr.getEnvironmentBlendMode();I==="additive"?n.buffers.color.setClear(0,0,0,1,a):I==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(r.autoClear||x)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),r.clear(r.autoClearColor,r.autoClearDepth,r.autoClearStencil))}function g(v,x){const y=m(x);y&&(y.isCubeTexture||y.mapping===os)?(h===void 0&&(h=new _e(new Ei(1,1,1),new rn({name:"BackgroundCubeMaterial",uniforms:rs(nn.backgroundCube.uniforms),vertexShader:nn.backgroundCube.vertexShader,fragmentShader:nn.backgroundCube.fragmentShader,side:De,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.deleteAttribute("normal"),h.geometry.deleteAttribute("uv"),h.onBeforeRender=function(I,w,C){this.matrixWorld.copyPosition(C.matrixWorld)},Object.defineProperty(h.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(h)),ii.copy(x.backgroundRotation),ii.x*=-1,ii.y*=-1,ii.z*=-1,y.isCubeTexture&&y.isRenderTargetTexture===!1&&(ii.y*=-1,ii.z*=-1),h.material.uniforms.envMap.value=y,h.material.uniforms.flipEnvMap.value=y.isCubeTexture&&y.isRenderTargetTexture===!1?-1:1,h.material.uniforms.backgroundBlurriness.value=x.backgroundBlurriness,h.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,h.material.uniforms.backgroundRotation.value.setFromMatrix4(b_.makeRotationFromEuler(ii)),h.material.toneMapped=Kt.getTransfer(y.colorSpace)!==se,(u!==y||d!==y.version||f!==r.toneMapping)&&(h.material.needsUpdate=!0,u=y,d=y.version,f=r.toneMapping),h.layers.enableAll(),v.unshift(h,h.geometry,h.material,0,0,null)):y&&y.isTexture&&(c===void 0&&(c=new _e(new hs(2,2),new rn({name:"BackgroundMaterial",uniforms:rs(nn.background.uniforms),vertexShader:nn.background.vertexShader,fragmentShader:nn.background.fragmentShader,side:Rn,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=y,c.material.uniforms.backgroundIntensity.value=x.backgroundIntensity,c.material.toneMapped=Kt.getTransfer(y.colorSpace)!==se,y.matrixAutoUpdate===!0&&y.updateMatrix(),c.material.uniforms.uvTransform.value.copy(y.matrix),(u!==y||d!==y.version||f!==r.toneMapping)&&(c.material.needsUpdate=!0,u=y,d=y.version,f=r.toneMapping),c.layers.enableAll(),v.unshift(c,c.geometry,c.material,0,0,null))}function p(v,x){v.getRGB(Dr,sd(r)),n.buffers.color.setClear(Dr.r,Dr.g,Dr.b,x,a)}return{getClearColor:function(){return o},setClearColor:function(v,x=1){o.set(v),l=x,p(o,l)},getClearAlpha:function(){return l},setClearAlpha:function(v){l=v,p(o,l)},render:_,addToRenderList:g}}function w_(r,t){const e=r.getParameter(r.MAX_VERTEX_ATTRIBS),n={},i=d(null);let s=i,a=!1;function o(M,L,k,O,V){let q=!1;const H=u(O,k,L);s!==H&&(s=H,c(s.object)),q=f(M,O,k,V),q&&m(M,O,k,V),V!==null&&t.update(V,r.ELEMENT_ARRAY_BUFFER),(q||a)&&(a=!1,y(M,L,k,O),V!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t.get(V).buffer))}function l(){return r.createVertexArray()}function c(M){return r.bindVertexArray(M)}function h(M){return r.deleteVertexArray(M)}function u(M,L,k){const O=k.wireframe===!0;let V=n[M.id];V===void 0&&(V={},n[M.id]=V);let q=V[L.id];q===void 0&&(q={},V[L.id]=q);let H=q[O];return H===void 0&&(H=d(l()),q[O]=H),H}function d(M){const L=[],k=[],O=[];for(let V=0;V=0){const yt=V[G];let gt=q[G];if(gt===void 0&&(G==="instanceMatrix"&&M.instanceMatrix&&(gt=M.instanceMatrix),G==="instanceColor"&&M.instanceColor&&(gt=M.instanceColor)),yt===void 0||yt.attribute!==gt||gt&&yt.data!==gt.data)return!0;H++}return s.attributesNum!==H||s.index!==O}function m(M,L,k,O){const V={},q=L.attributes;let H=0;const tt=k.getAttributes();for(const G in tt)if(tt[G].location>=0){let yt=q[G];yt===void 0&&(G==="instanceMatrix"&&M.instanceMatrix&&(yt=M.instanceMatrix),G==="instanceColor"&&M.instanceColor&&(yt=M.instanceColor));const gt={};gt.attribute=yt,yt&&yt.data&&(gt.data=yt.data),V[G]=gt,H++}s.attributes=V,s.attributesNum=H,s.index=O}function _(){const M=s.newAttributes;for(let L=0,k=M.length;L=0){let pt=V[tt];if(pt===void 0&&(tt==="instanceMatrix"&&M.instanceMatrix&&(pt=M.instanceMatrix),tt==="instanceColor"&&M.instanceColor&&(pt=M.instanceColor)),pt!==void 0){const yt=pt.normalized,gt=pt.itemSize,Gt=t.get(pt);if(Gt===void 0)continue;const $t=Gt.buffer,W=Gt.type,et=Gt.bytesPerElement,xt=W===r.INT||W===r.UNSIGNED_INT||pt.gpuType===Ga;if(pt.isInterleavedBufferAttribute){const ct=pt.data,Lt=ct.stride,Vt=pt.offset;if(ct.isInstancedInterleavedBuffer){for(let Ut=0;Ut0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision>0)return"highp";w="mediump"}return w==="mediump"&&r.getShaderPrecisionFormat(r.VERTEX_SHADER,r.MEDIUM_FLOAT).precision>0&&r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=e.precision!==void 0?e.precision:"highp";const h=l(c);h!==c&&(console.warn("THREE.WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=e.logarithmicDepthBuffer===!0,d=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS),f=r.getParameter(r.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=r.getParameter(r.MAX_TEXTURE_SIZE),_=r.getParameter(r.MAX_CUBE_MAP_TEXTURE_SIZE),g=r.getParameter(r.MAX_VERTEX_ATTRIBS),p=r.getParameter(r.MAX_VERTEX_UNIFORM_VECTORS),v=r.getParameter(r.MAX_VARYING_VECTORS),x=r.getParameter(r.MAX_FRAGMENT_UNIFORM_VECTORS),y=f>0,I=r.getParameter(r.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,maxTextures:d,maxVertexTextures:f,maxTextureSize:m,maxCubemapSize:_,maxAttributes:g,maxVertexUniforms:p,maxVaryings:v,maxFragmentUniforms:x,vertexTextures:y,maxSamples:I}}function C_(r){const t=this;let e=null,n=0,i=!1,s=!1;const a=new Wn,o=new Bt,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||n!==0||i;return i=d,n=u.length,f},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const m=u.clippingPlanes,_=u.clipIntersection,g=u.clipShadows,p=r.get(u);if(!i||m===null||m.length===0||s&&!g)s?h(null):c();else{const v=s?0:n,x=v*4;let y=p.clippingState||null;l.value=y,y=h(m,d,x,f);for(let I=0;I!==x;++I)y[I]=e[I];p.clippingState=y,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=v}};function c(){l.value!==e&&(l.value=e,l.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,m){const _=u!==null?u.length:0;let g=null;if(_!==0){if(g=l.value,m!==!0||g===null){const p=f+_*4,v=d.matrixWorldInverse;o.getNormalMatrix(v),(g===null||g.length0){const c=new od(l.height);return c.fromEquirectangularTexture(r,a),t.set(a,c),a.addEventListener("dispose",i),e(c.texture,a.mapping)}else return null}}return a}function i(a){const o=a.target;o.removeEventListener("dispose",i);const l=t.get(o);l!==void 0&&(t.delete(o),l.dispose())}function s(){t=new WeakMap}return{get:n,dispose:s}}class to extends ja{constructor(t=-1,e=1,n=1,i=-1,s=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=s,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,s,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=s,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let s=n-t,a=n+t,o=i+e,l=i-e;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=c*this.view.offsetX,a=s+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,a,o,l,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}const ji=4,Gc=[.125,.215,.35,.446,.526,.582],fi=20,Xo=new to,Wc=new ft;let qo=null,Yo=0,Zo=0,Jo=!1;const di=(1+Math.sqrt(5))/2,Xi=1/di,Xc=[new T(-di,Xi,0),new T(di,Xi,0),new T(-Xi,0,di),new T(Xi,0,di),new T(0,di,-Xi),new T(0,di,Xi),new T(-1,1,-1),new T(1,1,-1),new T(-1,1,1),new T(1,1,1)];class yl{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,n=.1,i=100){qo=this._renderer.getRenderTarget(),Yo=this._renderer.getActiveCubeFace(),Zo=this._renderer.getActiveMipmapLevel(),Jo=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(256);const s=this._allocateTargets();return s.depthBuffer=!0,this._sceneToCubeUV(t,n,i,s),e>0&&this._blur(s,0,0,e),this._applyPMREM(s),this._cleanup(s),s}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Zc(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Yc(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t2?x:0,x,x),h.setRenderTarget(i),_&&h.render(m,o),h.render(t,o)}m.geometry.dispose(),m.material.dispose(),h.toneMapping=d,h.autoClear=u,t.background=g}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===Pn||t.mapping===qn;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=Zc()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Yc());const s=i?this._cubemapMaterial:this._equirectMaterial,a=new _e(this._lodPlanes[0],s),o=s.uniforms;o.envMap.value=t;const l=this._cubeSize;Nr(e,0,0,3*l,2*l),n.setRenderTarget(e),n.render(a,Xo)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodPlanes.length;for(let s=1;sfi&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${fi}`);const p=[];let v=0;for(let C=0;Cx-ji?i-x+ji:0),w=4*(this._cubeSize-y);Nr(e,I,w,3*y,2*y),l.setRenderTarget(e),l.render(u,Xo)}}function P_(r){const t=[],e=[],n=[];let i=r;const s=r-ji+1+Gc.length;for(let a=0;ar-ji?l=Gc[a-r+ji-1]:a===0&&(l=0),n.push(l);const c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,m=6,_=3,g=2,p=1,v=new Float32Array(_*m*f),x=new Float32Array(g*m*f),y=new Float32Array(p*m*f);for(let w=0;w2?0:-1,b=[C,P,0,C+2/3,P,0,C+2/3,P+1,0,C,P,0,C+2/3,P+1,0,C,P+1,0];v.set(b,_*m*w),x.set(d,g*m*w);const M=[w,w,w,w,w,w];y.set(M,p*m*w)}const I=new Ht;I.setAttribute("position",new ie(v,_)),I.setAttribute("uv",new ie(x,g)),I.setAttribute("faceIndex",new ie(y,p)),t.push(I),i>ji&&i--}return{lodPlanes:t,sizeLods:e,sigmas:n}}function qc(r,t,e){const n=new sn(r,t,e);return n.texture.mapping=os,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function Nr(r,t,e,n,i){r.viewport.set(t,e,n,i),r.scissor.set(t,e,n,i)}function I_(r,t,e){const n=new Float32Array(fi),i=new T(0,1,0);return new rn({name:"SphericalGaussianBlur",defines:{n:fi,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${r}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Yl(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:Tn,depthTest:!1,depthWrite:!1})}function Yc(){return new rn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Yl(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:Tn,depthTest:!1,depthWrite:!1})}function Zc(){return new rn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Yl(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:Tn,depthTest:!1,depthWrite:!1})}function Yl(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}function L_(r){let t=new WeakMap,e=null;function n(o){if(o&&o.isTexture){const l=o.mapping,c=l===Fs||l===Bs,h=l===Pn||l===qn;if(c||h){let u=t.get(o);const d=u!==void 0?u.texture.pmremVersion:0;if(o.isRenderTargetTexture&&o.pmremVersion!==d)return e===null&&(e=new yl(r)),u=c?e.fromEquirectangular(o,u):e.fromCubemap(o,u),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),u.texture;if(u!==void 0)return u.texture;{const f=o.image;return c&&f&&f.height>0||h&&f&&i(f)?(e===null&&(e=new yl(r)),u=c?e.fromEquirectangular(o):e.fromCubemap(o),u.texture.pmremVersion=o.pmremVersion,t.set(o,u),o.addEventListener("dispose",s),u.texture):null}}}return o}function i(o){let l=0;const c=6;for(let h=0;ht.maxTextureSize&&(I=Math.ceil(y/t.maxTextureSize),y=t.maxTextureSize);const w=new Float32Array(y*I*4*u),C=new Ka(w,y,I,u);C.type=Be,C.needsUpdate=!0;const P=x*4;for(let M=0;M0)return r;const i=t*e;let s=$c[i];if(s===void 0&&(s=new Float32Array(i),$c[i]=s),t!==0){n.toArray(s,0);for(let a=1,o=0;a!==t;++a)o+=e,r[a].toArray(s,o)}return s}function xe(r,t){if(r.length!==t.length)return!1;for(let e=0,n=r.length;e":" "} ${o}: ${e[a]}`)}return n.join(` +`)}function L0(r){const t=Kt.getPrimaries(Kt.workingColorSpace),e=Kt.getPrimaries(r);let n;switch(t===e?n="":t===Xs&&e===Ws?n="LinearDisplayP3ToLinearSRGB":t===Ws&&e===Xs&&(n="LinearSRGBToLinearDisplayP3"),r){case Un:case rr:return[n,"LinearTransferOETF"];case $e:case $a:return[n,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",r),[n,"LinearTransferOETF"]}}function ih(r,t,e){const n=r.getShaderParameter(t,r.COMPILE_STATUS),i=r.getShaderInfoLog(t).trim();if(n&&i==="")return"";const s=/ERROR: 0:(\d+)/.exec(i);if(s){const a=parseInt(s[1]);return e.toUpperCase()+` + +`+i+` + +`+I0(r.getShaderSource(t),a)}else return i}function U0(r,t){const e=L0(t);return`vec4 ${r}( vec4 value ) { return ${e[0]}( ${e[1]}( value ) ); }`}function D0(r,t){let e;switch(t){case Lu:e="Linear";break;case Uu:e="Reinhard";break;case Du:e="OptimizedCineon";break;case Nu:e="ACESFilmic";break;case Fu:e="AgX";break;case Bu:e="Neutral";break;case Ou:e="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),e="Linear"}return"vec3 "+r+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}function N0(r){return[r.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",r.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Es).join(` +`)}function O0(r){const t=[];for(const e in r){const n=r[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(` +`)}function F0(r,t){const e={},n=r.getProgramParameter(t,r.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function Ml(r){return r.replace(B0,k0)}const z0=new Map;function k0(r,t){let e=kt[t];if(e===void 0){const n=z0.get(t);if(n!==void 0)e=kt[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("Can not resolve #include <"+t+">")}return Ml(e)}const V0=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function ah(r){return r.replace(V0,H0)}function H0(r,t,e,n){let i="";for(let s=parseInt(t);s0&&(g+=` +`),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m].filter(Es).join(` +`),p.length>0&&(p+=` +`)):(g=[oh(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(Es).join(` +`),p=[oh(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,m,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+c:"",e.envMap?"#define "+h:"",e.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor||e.batchingColor?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+l:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==Cn?"#define TONE_MAPPING":"",e.toneMapping!==Cn?kt.tonemapping_pars_fragment:"",e.toneMapping!==Cn?D0("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",kt.colorspace_pars_fragment,U0("linearToOutputTexel",e.outputColorSpace),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",` +`].filter(Es).join(` +`)),a=Ml(a),a=sh(a,e),a=rh(a,e),o=Ml(o),o=sh(o,e),o=rh(o,e),a=ah(a),o=ah(o),e.isRawShaderMaterial!==!0&&(v=`#version 300 es +`,g=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+g,p=["#define varying in",e.glslVersion===vl?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===vl?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`)+` +`+p);const x=v+g+a,y=v+p+o,I=nh(i,i.VERTEX_SHADER,x),w=nh(i,i.FRAGMENT_SHADER,y);i.attachShader(_,I),i.attachShader(_,w),e.index0AttributeName!==void 0?i.bindAttribLocation(_,0,e.index0AttributeName):e.morphTargets===!0&&i.bindAttribLocation(_,0,"position"),i.linkProgram(_);function C(L){if(r.debug.checkShaderErrors){const k=i.getProgramInfoLog(_).trim(),O=i.getShaderInfoLog(I).trim(),V=i.getShaderInfoLog(w).trim();let q=!0,H=!0;if(i.getProgramParameter(_,i.LINK_STATUS)===!1)if(q=!1,typeof r.debug.onShaderError=="function")r.debug.onShaderError(i,_,I,w);else{const tt=ih(i,I,"vertex"),G=ih(i,w,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(_,i.VALIDATE_STATUS)+` + +Material Name: `+L.name+` +Material Type: `+L.type+` + +Program Info Log: `+k+` +`+tt+` +`+G)}else k!==""?console.warn("THREE.WebGLProgram: Program Info Log:",k):(O===""||V==="")&&(H=!1);H&&(L.diagnostics={runnable:q,programLog:k,vertexShader:{log:O,prefix:g},fragmentShader:{log:V,prefix:p}})}i.deleteShader(I),i.deleteShader(w),P=new la(i,_),b=F0(i,_)}let P;this.getUniforms=function(){return P===void 0&&C(this),P};let b;this.getAttributes=function(){return b===void 0&&C(this),b};let M=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return M===!1&&(M=i.getProgramParameter(_,R0)),M},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(_),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=P0++,this.cacheKey=t,this.usedTimes=1,this.program=_,this.vertexShader=I,this.fragmentShader=w,this}let J0=0;class $0{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t){const e=t.vertexShader,n=t.fragmentShader,i=this._getShaderStage(e),s=this._getShaderStage(n),a=this._getShaderCacheForMaterial(t);return a.has(i)===!1&&(a.add(i),i.usedTimes++),a.has(s)===!1&&(a.add(s),s.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderID(t){return this._getShaderStage(t.vertexShader).id}getFragmentShaderID(t){return this._getShaderStage(t.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new K0(t),e.set(t,n)),n}}class K0{constructor(t){this.id=J0++,this.code=t,this.usedTimes=0}}function Q0(r,t,e,n,i,s,a){const o=new Qa,l=new $0,c=new Set,h=[],u=i.logarithmicDepthBuffer,d=i.vertexTextures;let f=i.precision;const m={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function _(b){return c.add(b),b===0?"uv":`uv${b}`}function g(b,M,L,k,O){const V=k.fog,q=O.geometry,H=b.isMeshStandardMaterial?k.environment:null,tt=(b.isMeshStandardMaterial?e:t).get(b.envMap||H),G=tt&&tt.mapping===os?tt.image.height:null,pt=m[b.type];b.precision!==null&&(f=i.getMaxPrecision(b.precision),f!==b.precision&&console.warn("THREE.WebGLProgram.getParameters:",b.precision,"not supported, using",f,"instead."));const yt=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,gt=yt!==void 0?yt.length:0;let Gt=0;q.morphAttributes.position!==void 0&&(Gt=1),q.morphAttributes.normal!==void 0&&(Gt=2),q.morphAttributes.color!==void 0&&(Gt=3);let $t,W,et,xt;if(pt){const Qt=nn[pt];$t=Qt.vertexShader,W=Qt.fragmentShader}else $t=b.vertexShader,W=b.fragmentShader,l.update(b),et=l.getVertexShaderID(b),xt=l.getFragmentShaderID(b);const ct=r.getRenderTarget(),Lt=O.isInstancedMesh===!0,Vt=O.isBatchedMesh===!0,Ut=!!b.map,Jt=!!b.matcap,E=!!tt,it=!!b.aoMap,j=!!b.lightMap,ht=!!b.bumpMap,X=!!b.normalMap,Tt=!!b.displacementMap,ut=!!b.emissiveMap,vt=!!b.metalnessMap,R=!!b.roughnessMap,S=b.anisotropy>0,B=b.clearcoat>0,Q=b.dispersion>0,K=b.iridescence>0,$=b.sheen>0,Et=b.transmission>0,lt=S&&!!b.anisotropyMap,_t=B&&!!b.clearcoatMap,Ft=B&&!!b.clearcoatNormalMap,nt=B&&!!b.clearcoatRoughnessMap,mt=K&&!!b.iridescenceMap,Xt=K&&!!b.iridescenceThicknessMap,Nt=$&&!!b.sheenColorMap,Mt=$&&!!b.sheenRoughnessMap,Ot=!!b.specularMap,Wt=!!b.specularColorMap,re=!!b.specularIntensityMap,U=Et&&!!b.transmissionMap,st=Et&&!!b.thicknessMap,Y=!!b.gradientMap,J=!!b.alphaMap,at=b.alphaTest>0,Pt=!!b.alphaHash,qt=!!b.extensions;let fe=Cn;b.toneMapped&&(ct===null||ct.isXRRenderTarget===!0)&&(fe=r.toneMapping);const Se={shaderID:pt,shaderType:b.type,shaderName:b.name,vertexShader:$t,fragmentShader:W,defines:b.defines,customVertexShaderID:et,customFragmentShaderID:xt,isRawShaderMaterial:b.isRawShaderMaterial===!0,glslVersion:b.glslVersion,precision:f,batching:Vt,batchingColor:Vt&&O._colorsTexture!==null,instancing:Lt,instancingColor:Lt&&O.instanceColor!==null,instancingMorph:Lt&&O.morphTexture!==null,supportsVertexTextures:d,outputColorSpace:ct===null?r.outputColorSpace:ct.isXRRenderTarget===!0?ct.texture.colorSpace:Un,alphaToCoverage:!!b.alphaToCoverage,map:Ut,matcap:Jt,envMap:E,envMapMode:E&&tt.mapping,envMapCubeUVHeight:G,aoMap:it,lightMap:j,bumpMap:ht,normalMap:X,displacementMap:d&&Tt,emissiveMap:ut,normalMapObjectSpace:X&&b.normalMapType===Xu,normalMapTangentSpace:X&&b.normalMapType===Zn,metalnessMap:vt,roughnessMap:R,anisotropy:S,anisotropyMap:lt,clearcoat:B,clearcoatMap:_t,clearcoatNormalMap:Ft,clearcoatRoughnessMap:nt,dispersion:Q,iridescence:K,iridescenceMap:mt,iridescenceThicknessMap:Xt,sheen:$,sheenColorMap:Nt,sheenRoughnessMap:Mt,specularMap:Ot,specularColorMap:Wt,specularIntensityMap:re,transmission:Et,transmissionMap:U,thicknessMap:st,gradientMap:Y,opaque:b.transparent===!1&&b.blending===xi&&b.alphaToCoverage===!1,alphaMap:J,alphaTest:at,alphaHash:Pt,combine:b.combine,mapUv:Ut&&_(b.map.channel),aoMapUv:it&&_(b.aoMap.channel),lightMapUv:j&&_(b.lightMap.channel),bumpMapUv:ht&&_(b.bumpMap.channel),normalMapUv:X&&_(b.normalMap.channel),displacementMapUv:Tt&&_(b.displacementMap.channel),emissiveMapUv:ut&&_(b.emissiveMap.channel),metalnessMapUv:vt&&_(b.metalnessMap.channel),roughnessMapUv:R&&_(b.roughnessMap.channel),anisotropyMapUv:lt&&_(b.anisotropyMap.channel),clearcoatMapUv:_t&&_(b.clearcoatMap.channel),clearcoatNormalMapUv:Ft&&_(b.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:nt&&_(b.clearcoatRoughnessMap.channel),iridescenceMapUv:mt&&_(b.iridescenceMap.channel),iridescenceThicknessMapUv:Xt&&_(b.iridescenceThicknessMap.channel),sheenColorMapUv:Nt&&_(b.sheenColorMap.channel),sheenRoughnessMapUv:Mt&&_(b.sheenRoughnessMap.channel),specularMapUv:Ot&&_(b.specularMap.channel),specularColorMapUv:Wt&&_(b.specularColorMap.channel),specularIntensityMapUv:re&&_(b.specularIntensityMap.channel),transmissionMapUv:U&&_(b.transmissionMap.channel),thicknessMapUv:st&&_(b.thicknessMap.channel),alphaMapUv:J&&_(b.alphaMap.channel),vertexTangents:!!q.attributes.tangent&&(X||S),vertexColors:b.vertexColors,vertexAlphas:b.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,pointsUvs:O.isPoints===!0&&!!q.attributes.uv&&(Ut||J),fog:!!V,useFog:b.fog===!0,fogExp2:!!V&&V.isFogExp2,flatShading:b.flatShading===!0,sizeAttenuation:b.sizeAttenuation===!0,logarithmicDepthBuffer:u,skinning:O.isSkinnedMesh===!0,morphTargets:q.morphAttributes.position!==void 0,morphNormals:q.morphAttributes.normal!==void 0,morphColors:q.morphAttributes.color!==void 0,morphTargetsCount:gt,morphTextureStride:Gt,numDirLights:M.directional.length,numPointLights:M.point.length,numSpotLights:M.spot.length,numSpotLightMaps:M.spotLightMap.length,numRectAreaLights:M.rectArea.length,numHemiLights:M.hemi.length,numDirLightShadows:M.directionalShadowMap.length,numPointLightShadows:M.pointShadowMap.length,numSpotLightShadows:M.spotShadowMap.length,numSpotLightShadowsWithMaps:M.numSpotLightShadowsWithMaps,numLightProbes:M.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:b.dithering,shadowMapEnabled:r.shadowMap.enabled&&L.length>0,shadowMapType:r.shadowMap.type,toneMapping:fe,decodeVideoTexture:Ut&&b.map.isVideoTexture===!0&&Kt.getTransfer(b.map.colorSpace)===se,premultipliedAlpha:b.premultipliedAlpha,doubleSided:b.side===hn,flipSided:b.side===De,useDepthPacking:b.depthPacking>=0,depthPacking:b.depthPacking||0,index0AttributeName:b.index0AttributeName,extensionClipCullDistance:qt&&b.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(qt&&b.extensions.multiDraw===!0||Vt)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:b.customProgramCacheKey()};return Se.vertexUv1s=c.has(1),Se.vertexUv2s=c.has(2),Se.vertexUv3s=c.has(3),c.clear(),Se}function p(b){const M=[];if(b.shaderID?M.push(b.shaderID):(M.push(b.customVertexShaderID),M.push(b.customFragmentShaderID)),b.defines!==void 0)for(const L in b.defines)M.push(L),M.push(b.defines[L]);return b.isRawShaderMaterial===!1&&(v(M,b),x(M,b),M.push(r.outputColorSpace)),M.push(b.customProgramCacheKey),M.join()}function v(b,M){b.push(M.precision),b.push(M.outputColorSpace),b.push(M.envMapMode),b.push(M.envMapCubeUVHeight),b.push(M.mapUv),b.push(M.alphaMapUv),b.push(M.lightMapUv),b.push(M.aoMapUv),b.push(M.bumpMapUv),b.push(M.normalMapUv),b.push(M.displacementMapUv),b.push(M.emissiveMapUv),b.push(M.metalnessMapUv),b.push(M.roughnessMapUv),b.push(M.anisotropyMapUv),b.push(M.clearcoatMapUv),b.push(M.clearcoatNormalMapUv),b.push(M.clearcoatRoughnessMapUv),b.push(M.iridescenceMapUv),b.push(M.iridescenceThicknessMapUv),b.push(M.sheenColorMapUv),b.push(M.sheenRoughnessMapUv),b.push(M.specularMapUv),b.push(M.specularColorMapUv),b.push(M.specularIntensityMapUv),b.push(M.transmissionMapUv),b.push(M.thicknessMapUv),b.push(M.combine),b.push(M.fogExp2),b.push(M.sizeAttenuation),b.push(M.morphTargetsCount),b.push(M.morphAttributeCount),b.push(M.numDirLights),b.push(M.numPointLights),b.push(M.numSpotLights),b.push(M.numSpotLightMaps),b.push(M.numHemiLights),b.push(M.numRectAreaLights),b.push(M.numDirLightShadows),b.push(M.numPointLightShadows),b.push(M.numSpotLightShadows),b.push(M.numSpotLightShadowsWithMaps),b.push(M.numLightProbes),b.push(M.shadowMapType),b.push(M.toneMapping),b.push(M.numClippingPlanes),b.push(M.numClipIntersection),b.push(M.depthPacking)}function x(b,M){o.disableAll(),M.supportsVertexTextures&&o.enable(0),M.instancing&&o.enable(1),M.instancingColor&&o.enable(2),M.instancingMorph&&o.enable(3),M.matcap&&o.enable(4),M.envMap&&o.enable(5),M.normalMapObjectSpace&&o.enable(6),M.normalMapTangentSpace&&o.enable(7),M.clearcoat&&o.enable(8),M.iridescence&&o.enable(9),M.alphaTest&&o.enable(10),M.vertexColors&&o.enable(11),M.vertexAlphas&&o.enable(12),M.vertexUv1s&&o.enable(13),M.vertexUv2s&&o.enable(14),M.vertexUv3s&&o.enable(15),M.vertexTangents&&o.enable(16),M.anisotropy&&o.enable(17),M.alphaHash&&o.enable(18),M.batching&&o.enable(19),M.dispersion&&o.enable(20),M.batchingColor&&o.enable(21),b.push(o.mask),o.disableAll(),M.fog&&o.enable(0),M.useFog&&o.enable(1),M.flatShading&&o.enable(2),M.logarithmicDepthBuffer&&o.enable(3),M.skinning&&o.enable(4),M.morphTargets&&o.enable(5),M.morphNormals&&o.enable(6),M.morphColors&&o.enable(7),M.premultipliedAlpha&&o.enable(8),M.shadowMapEnabled&&o.enable(9),M.doubleSided&&o.enable(10),M.flipSided&&o.enable(11),M.useDepthPacking&&o.enable(12),M.dithering&&o.enable(13),M.transmission&&o.enable(14),M.sheen&&o.enable(15),M.opaque&&o.enable(16),M.pointsUvs&&o.enable(17),M.decodeVideoTexture&&o.enable(18),M.alphaToCoverage&&o.enable(19),b.push(o.mask)}function y(b){const M=m[b.type];let L;if(M){const k=nn[M];L=rd.clone(k.uniforms)}else L=b.uniforms;return L}function I(b,M){let L;for(let k=0,O=h.length;k0?n.push(p):f.transparent===!0?i.push(p):e.push(p)}function l(u,d,f,m,_,g){const p=a(u,d,f,m,_,g);f.transmission>0?n.unshift(p):f.transparent===!0?i.unshift(p):e.unshift(p)}function c(u,d){e.length>1&&e.sort(u||tx),n.length>1&&n.sort(d||lh),i.length>1&&i.sort(d||lh)}function h(){for(let u=t,d=r.length;u=s.length?(a=new ch,s.push(a)):a=s[i],a}function e(){r=new WeakMap}return{get:t,dispose:e}}function nx(){const r={};return{get:function(t){if(r[t.id]!==void 0)return r[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new T,color:new ft};break;case"SpotLight":e={position:new T,direction:new T,color:new ft,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new T,color:new ft,distance:0,decay:0};break;case"HemisphereLight":e={direction:new T,skyColor:new ft,groundColor:new ft};break;case"RectAreaLight":e={color:new ft,position:new T,halfWidth:new T,halfHeight:new T};break}return r[t.id]=e,e}}}function ix(){const r={};return{get:function(t){if(r[t.id]!==void 0)return r[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Z};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Z};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Z,shadowCameraNear:1,shadowCameraFar:1e3};break}return r[t.id]=e,e}}}let sx=0;function rx(r,t){return(t.castShadow?2:0)-(r.castShadow?2:0)+(t.map?1:0)-(r.map?1:0)}function ax(r){const t=new nx,e=ix(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)n.probe.push(new T);const i=new T,s=new Rt,a=new Rt;function o(c){let h=0,u=0,d=0;for(let b=0;b<9;b++)n.probe[b].set(0,0,0);let f=0,m=0,_=0,g=0,p=0,v=0,x=0,y=0,I=0,w=0,C=0;c.sort(rx);for(let b=0,M=c.length;b0&&(r.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ot.LTC_FLOAT_1,n.rectAreaLTC2=ot.LTC_FLOAT_2):(n.rectAreaLTC1=ot.LTC_HALF_1,n.rectAreaLTC2=ot.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const P=n.hash;(P.directionalLength!==f||P.pointLength!==m||P.spotLength!==_||P.rectAreaLength!==g||P.hemiLength!==p||P.numDirectionalShadows!==v||P.numPointShadows!==x||P.numSpotShadows!==y||P.numSpotMaps!==I||P.numLightProbes!==C)&&(n.directional.length=f,n.spot.length=_,n.rectArea.length=g,n.point.length=m,n.hemi.length=p,n.directionalShadow.length=v,n.directionalShadowMap.length=v,n.pointShadow.length=x,n.pointShadowMap.length=x,n.spotShadow.length=y,n.spotShadowMap.length=y,n.directionalShadowMatrix.length=v,n.pointShadowMatrix.length=x,n.spotLightMatrix.length=y+I-w,n.spotLightMap.length=I,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=C,P.directionalLength=f,P.pointLength=m,P.spotLength=_,P.rectAreaLength=g,P.hemiLength=p,P.numDirectionalShadows=v,P.numPointShadows=x,P.numSpotShadows=y,P.numSpotMaps=I,P.numLightProbes=C,n.version=sx++)}function l(c,h){let u=0,d=0,f=0,m=0,_=0;const g=h.matrixWorldInverse;for(let p=0,v=c.length;p=a.length?(o=new hh(r),a.push(o)):o=a[s],o}function n(){t=new WeakMap}return{get:e,dispose:n}}class Jl extends Re{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Gu,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class $l extends Re{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}const lx=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,cx=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +#include +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) ); + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) ); + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + squared_mean = squared_mean / samples; + float std_dev = sqrt( squared_mean - mean * mean ); + gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); +}`;function hx(r,t,e){let n=new or;const i=new Z,s=new Z,a=new ne,o=new Jl({depthPacking:Wu}),l=new $l,c={},h=e.maxTextureSize,u={[Rn]:De,[De]:Rn,[hn]:hn},d=new rn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Z},radius:{value:4}},vertexShader:lx,fragmentShader:cx}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const m=new Ht;m.setAttribute("position",new ie(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new _e(m,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Rl;let p=this.type;this.render=function(w,C,P){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||w.length===0)return;const b=r.getRenderTarget(),M=r.getActiveCubeFace(),L=r.getActiveMipmapLevel(),k=r.state;k.setBlending(Tn),k.buffers.color.setClear(1,1,1,1),k.buffers.depth.setTest(!0),k.setScissorTest(!1);const O=p!==cn&&this.type===cn,V=p===cn&&this.type!==cn;for(let q=0,H=w.length;qh||i.y>h)&&(i.x>h&&(s.x=Math.floor(h/pt.x),i.x=s.x*pt.x,G.mapSize.x=s.x),i.y>h&&(s.y=Math.floor(h/pt.y),i.y=s.y*pt.y,G.mapSize.y=s.y)),G.map===null||O===!0||V===!0){const gt=this.type!==cn?{minFilter:Me,magFilter:Me}:{};G.map!==null&&G.map.dispose(),G.map=new sn(i.x,i.y,gt),G.map.texture.name=tt.name+".shadowMap",G.camera.updateProjectionMatrix()}r.setRenderTarget(G.map),r.clear();const yt=G.getViewportCount();for(let gt=0;gt0||C.map&&C.alphaTest>0){const k=M.uuid,O=C.uuid;let V=c[k];V===void 0&&(V={},c[k]=V);let q=V[O];q===void 0&&(q=M.clone(),V[O]=q,C.addEventListener("dispose",I)),M=q}if(M.visible=C.visible,M.wireframe=C.wireframe,b===cn?M.side=C.shadowSide!==null?C.shadowSide:C.side:M.side=C.shadowSide!==null?C.shadowSide:u[C.side],M.alphaMap=C.alphaMap,M.alphaTest=C.alphaTest,M.map=C.map,M.clipShadows=C.clipShadows,M.clippingPlanes=C.clippingPlanes,M.clipIntersection=C.clipIntersection,M.displacementMap=C.displacementMap,M.displacementScale=C.displacementScale,M.displacementBias=C.displacementBias,M.wireframeLinewidth=C.wireframeLinewidth,M.linewidth=C.linewidth,P.isPointLight===!0&&M.isMeshDistanceMaterial===!0){const k=r.properties.get(M);k.light=P}return M}function y(w,C,P,b,M){if(w.visible===!1)return;if(w.layers.test(C.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&M===cn)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(P.matrixWorldInverse,w.matrixWorld);const O=t.update(w),V=w.material;if(Array.isArray(V)){const q=O.groups;for(let H=0,tt=q.length;H=1):tt.indexOf("OpenGL ES")!==-1&&(H=parseFloat(/^OpenGL ES (\d)/.exec(tt)[1]),q=H>=2);let G=null,pt={};const yt=r.getParameter(r.SCISSOR_BOX),gt=r.getParameter(r.VIEWPORT),Gt=new ne().fromArray(yt),$t=new ne().fromArray(gt);function W(U,st,Y,J){const at=new Uint8Array(4),Pt=r.createTexture();r.bindTexture(U,Pt),r.texParameteri(U,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(U,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let qt=0;qtt?(r.repeat.x=1,r.repeat.y=e/t,r.offset.x=0,r.offset.y=(1-r.repeat.y)/2):(r.repeat.x=t/e,r.repeat.y=1,r.offset.x=(1-r.repeat.x)/2,r.offset.y=0),r}function fx(r,t){const e=r.image&&r.image.width?r.image.width/r.image.height:1;return e>t?(r.repeat.x=t/e,r.repeat.y=1,r.offset.x=(1-r.repeat.x)/2,r.offset.y=0):(r.repeat.x=1,r.repeat.y=e/t,r.offset.x=0,r.offset.y=(1-r.repeat.y)/2),r}function px(r){return r.repeat.x=1,r.repeat.y=1,r.offset.x=0,r.offset.y=0,r}function Sl(r,t,e,n){const i=mx(n);switch(e){case Dl:return r*t;case Ol:return r*t;case Fl:return r*t*2;case qa:return r*t/i.components*i.byteLength;case sr:return r*t/i.components*i.byteLength;case Bl:return r*t*2/i.components*i.byteLength;case Ya:return r*t*2/i.components*i.byteLength;case Nl:return r*t*3/i.components*i.byteLength;case Ue:return r*t*4/i.components*i.byteLength;case Za:return r*t*4/i.components*i.byteLength;case Cs:case Rs:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*8;case Ps:case Is:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*16;case da:case pa:return Math.max(r,16)*Math.max(t,8)/4;case ua:case fa:return Math.max(r,8)*Math.max(t,8)/2;case ma:case ga:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*8;case _a:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*16;case xa:return Math.floor((r+3)/4)*Math.floor((t+3)/4)*16;case va:return Math.floor((r+4)/5)*Math.floor((t+3)/4)*16;case ya:return Math.floor((r+4)/5)*Math.floor((t+4)/5)*16;case Ma:return Math.floor((r+5)/6)*Math.floor((t+4)/5)*16;case Sa:return Math.floor((r+5)/6)*Math.floor((t+5)/6)*16;case ba:return Math.floor((r+7)/8)*Math.floor((t+4)/5)*16;case Aa:return Math.floor((r+7)/8)*Math.floor((t+5)/6)*16;case wa:return Math.floor((r+7)/8)*Math.floor((t+7)/8)*16;case Ea:return Math.floor((r+9)/10)*Math.floor((t+4)/5)*16;case Ta:return Math.floor((r+9)/10)*Math.floor((t+5)/6)*16;case Ca:return Math.floor((r+9)/10)*Math.floor((t+7)/8)*16;case Ra:return Math.floor((r+9)/10)*Math.floor((t+9)/10)*16;case Pa:return Math.floor((r+11)/12)*Math.floor((t+9)/10)*16;case Ia:return Math.floor((r+11)/12)*Math.floor((t+11)/12)*16;case Ls:case La:case Ua:return Math.ceil(r/4)*Math.ceil(t/4)*16;case zl:case Da:return Math.ceil(r/4)*Math.ceil(t/4)*8;case Na:case Oa:return Math.ceil(r/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function mx(r){switch(r){case mn:case Il:return{byteLength:1,components:1};case is:case Ll:case ls:return{byteLength:2,components:1};case Wa:case Xa:return{byteLength:2,components:4};case In:case Ga:case Be:return{byteLength:4,components:1};case Ul:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${r}.`)}const gx={contain:dx,cover:fx,fill:px,getByteLength:Sl};function _x(r,t,e,n,i,s,a){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Z,h=new WeakMap;let u;const d=new WeakMap;let f=!1;try{f=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function m(R,S){return f?new OffscreenCanvas(R,S):Zs("canvas")}function _(R,S,B){let Q=1;const K=vt(R);if((K.width>B||K.height>B)&&(Q=B/Math.max(K.width,K.height)),Q<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const $=Math.floor(Q*K.width),Et=Math.floor(Q*K.height);u===void 0&&(u=m($,Et));const lt=S?m($,Et):u;return lt.width=$,lt.height=Et,lt.getContext("2d").drawImage(R,0,0,$,Et),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+$+"x"+Et+")."),lt}else return"data"in R&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),R;return R}function g(R){return R.generateMipmaps&&R.minFilter!==Me&&R.minFilter!==ge}function p(R){r.generateMipmap(R)}function v(R,S,B,Q,K=!1){if(R!==null){if(r[R]!==void 0)return r[R];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let $=S;if(S===r.RED&&(B===r.FLOAT&&($=r.R32F),B===r.HALF_FLOAT&&($=r.R16F),B===r.UNSIGNED_BYTE&&($=r.R8)),S===r.RED_INTEGER&&(B===r.UNSIGNED_BYTE&&($=r.R8UI),B===r.UNSIGNED_SHORT&&($=r.R16UI),B===r.UNSIGNED_INT&&($=r.R32UI),B===r.BYTE&&($=r.R8I),B===r.SHORT&&($=r.R16I),B===r.INT&&($=r.R32I)),S===r.RG&&(B===r.FLOAT&&($=r.RG32F),B===r.HALF_FLOAT&&($=r.RG16F),B===r.UNSIGNED_BYTE&&($=r.RG8)),S===r.RG_INTEGER&&(B===r.UNSIGNED_BYTE&&($=r.RG8UI),B===r.UNSIGNED_SHORT&&($=r.RG16UI),B===r.UNSIGNED_INT&&($=r.RG32UI),B===r.BYTE&&($=r.RG8I),B===r.SHORT&&($=r.RG16I),B===r.INT&&($=r.RG32I)),S===r.RGB&&B===r.UNSIGNED_INT_5_9_9_9_REV&&($=r.RGB9_E5),S===r.RGBA){const Et=K?Gs:Kt.getTransfer(Q);B===r.FLOAT&&($=r.RGBA32F),B===r.HALF_FLOAT&&($=r.RGBA16F),B===r.UNSIGNED_BYTE&&($=Et===se?r.SRGB8_ALPHA8:r.RGBA8),B===r.UNSIGNED_SHORT_4_4_4_4&&($=r.RGBA4),B===r.UNSIGNED_SHORT_5_5_5_1&&($=r.RGB5_A1)}return($===r.R16F||$===r.R32F||$===r.RG16F||$===r.RG32F||$===r.RGBA16F||$===r.RGBA32F)&&t.get("EXT_color_buffer_float"),$}function x(R,S){let B;return R?S===null||S===In||S===Si?B=r.DEPTH24_STENCIL8:S===Be?B=r.DEPTH32F_STENCIL8:S===is&&(B=r.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):S===null||S===In||S===Si?B=r.DEPTH_COMPONENT24:S===Be?B=r.DEPTH_COMPONENT32F:S===is&&(B=r.DEPTH_COMPONENT16),B}function y(R,S){return g(R)===!0||R.isFramebufferTexture&&R.minFilter!==Me&&R.minFilter!==ge?Math.log2(Math.max(S.width,S.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?S.mipmaps.length:1}function I(R){const S=R.target;S.removeEventListener("dispose",I),C(S),S.isVideoTexture&&h.delete(S)}function w(R){const S=R.target;S.removeEventListener("dispose",w),b(S)}function C(R){const S=n.get(R);if(S.__webglInit===void 0)return;const B=R.source,Q=d.get(B);if(Q){const K=Q[S.__cacheKey];K.usedTimes--,K.usedTimes===0&&P(R),Object.keys(Q).length===0&&d.delete(B)}n.remove(R)}function P(R){const S=n.get(R);r.deleteTexture(S.__webglTexture);const B=R.source,Q=d.get(B);delete Q[S.__cacheKey],a.memory.textures--}function b(R){const S=n.get(R);if(R.depthTexture&&R.depthTexture.dispose(),R.isWebGLCubeRenderTarget)for(let Q=0;Q<6;Q++){if(Array.isArray(S.__webglFramebuffer[Q]))for(let K=0;K=i.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+i.maxTextures),M+=1,R}function O(R){const S=[];return S.push(R.wrapS),S.push(R.wrapT),S.push(R.wrapR||0),S.push(R.magFilter),S.push(R.minFilter),S.push(R.anisotropy),S.push(R.internalFormat),S.push(R.format),S.push(R.type),S.push(R.generateMipmaps),S.push(R.premultiplyAlpha),S.push(R.flipY),S.push(R.unpackAlignment),S.push(R.colorSpace),S.join()}function V(R,S){const B=n.get(R);if(R.isVideoTexture&&Tt(R),R.isRenderTargetTexture===!1&&R.version>0&&B.__version!==R.version){const Q=R.image;if(Q===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Q.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{$t(B,R,S);return}}e.bindTexture(r.TEXTURE_2D,B.__webglTexture,r.TEXTURE0+S)}function q(R,S){const B=n.get(R);if(R.version>0&&B.__version!==R.version){$t(B,R,S);return}e.bindTexture(r.TEXTURE_2D_ARRAY,B.__webglTexture,r.TEXTURE0+S)}function H(R,S){const B=n.get(R);if(R.version>0&&B.__version!==R.version){$t(B,R,S);return}e.bindTexture(r.TEXTURE_3D,B.__webglTexture,r.TEXTURE0+S)}function tt(R,S){const B=n.get(R);if(R.version>0&&B.__version!==R.version){W(B,R,S);return}e.bindTexture(r.TEXTURE_CUBE_MAP,B.__webglTexture,r.TEXTURE0+S)}const G={[zs]:r.REPEAT,[Ke]:r.CLAMP_TO_EDGE,[ks]:r.MIRRORED_REPEAT},pt={[Me]:r.NEAREST,[Pl]:r.NEAREST_MIPMAP_NEAREST,[Ki]:r.NEAREST_MIPMAP_LINEAR,[ge]:r.LINEAR,[Ts]:r.LINEAR_MIPMAP_NEAREST,[un]:r.LINEAR_MIPMAP_LINEAR},yt={[qu]:r.NEVER,[Qu]:r.ALWAYS,[Yu]:r.LESS,[Vl]:r.LEQUAL,[Zu]:r.EQUAL,[Ku]:r.GEQUAL,[Ju]:r.GREATER,[$u]:r.NOTEQUAL};function gt(R,S){if(S.type===Be&&t.has("OES_texture_float_linear")===!1&&(S.magFilter===ge||S.magFilter===Ts||S.magFilter===Ki||S.magFilter===un||S.minFilter===ge||S.minFilter===Ts||S.minFilter===Ki||S.minFilter===un)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),r.texParameteri(R,r.TEXTURE_WRAP_S,G[S.wrapS]),r.texParameteri(R,r.TEXTURE_WRAP_T,G[S.wrapT]),(R===r.TEXTURE_3D||R===r.TEXTURE_2D_ARRAY)&&r.texParameteri(R,r.TEXTURE_WRAP_R,G[S.wrapR]),r.texParameteri(R,r.TEXTURE_MAG_FILTER,pt[S.magFilter]),r.texParameteri(R,r.TEXTURE_MIN_FILTER,pt[S.minFilter]),S.compareFunction&&(r.texParameteri(R,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(R,r.TEXTURE_COMPARE_FUNC,yt[S.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(S.magFilter===Me||S.minFilter!==Ki&&S.minFilter!==un||S.type===Be&&t.has("OES_texture_float_linear")===!1)return;if(S.anisotropy>1||n.get(S).__currentAnisotropy){const B=t.get("EXT_texture_filter_anisotropic");r.texParameterf(R,B.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(S.anisotropy,i.getMaxAnisotropy())),n.get(S).__currentAnisotropy=S.anisotropy}}}function Gt(R,S){let B=!1;R.__webglInit===void 0&&(R.__webglInit=!0,S.addEventListener("dispose",I));const Q=S.source;let K=d.get(Q);K===void 0&&(K={},d.set(Q,K));const $=O(S);if($!==R.__cacheKey){K[$]===void 0&&(K[$]={texture:r.createTexture(),usedTimes:0},a.memory.textures++,B=!0),K[$].usedTimes++;const Et=K[R.__cacheKey];Et!==void 0&&(K[R.__cacheKey].usedTimes--,Et.usedTimes===0&&P(S)),R.__cacheKey=$,R.__webglTexture=K[$].texture}return B}function $t(R,S,B){let Q=r.TEXTURE_2D;(S.isDataArrayTexture||S.isCompressedArrayTexture)&&(Q=r.TEXTURE_2D_ARRAY),S.isData3DTexture&&(Q=r.TEXTURE_3D);const K=Gt(R,S),$=S.source;e.bindTexture(Q,R.__webglTexture,r.TEXTURE0+B);const Et=n.get($);if($.version!==Et.__version||K===!0){e.activeTexture(r.TEXTURE0+B);const lt=Kt.getPrimaries(Kt.workingColorSpace),_t=S.colorSpace===An?null:Kt.getPrimaries(S.colorSpace),Ft=S.colorSpace===An||lt===_t?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,S.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,S.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,S.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ft);let nt=_(S.image,!1,i.maxTextureSize);nt=ut(S,nt);const mt=s.convert(S.format,S.colorSpace),Xt=s.convert(S.type);let Nt=v(S.internalFormat,mt,Xt,S.colorSpace,S.isVideoTexture);gt(Q,S);let Mt;const Ot=S.mipmaps,Wt=S.isVideoTexture!==!0,re=Et.__version===void 0||K===!0,U=$.dataReady,st=y(S,nt);if(S.isDepthTexture)Nt=x(S.format===bi,S.type),re&&(Wt?e.texStorage2D(r.TEXTURE_2D,1,Nt,nt.width,nt.height):e.texImage2D(r.TEXTURE_2D,0,Nt,nt.width,nt.height,0,mt,Xt,null));else if(S.isDataTexture)if(Ot.length>0){Wt&&re&&e.texStorage2D(r.TEXTURE_2D,st,Nt,Ot[0].width,Ot[0].height);for(let Y=0,J=Ot.length;Y0){const at=Sl(Mt.width,Mt.height,S.format,S.type);for(const Pt of S.layerUpdates){const qt=Mt.data.subarray(Pt*at/Mt.data.BYTES_PER_ELEMENT,(Pt+1)*at/Mt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,Y,0,0,Pt,Mt.width,Mt.height,1,mt,qt,0,0)}S.clearLayerUpdates()}else e.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,Y,0,0,0,Mt.width,Mt.height,nt.depth,mt,Mt.data,0,0)}else e.compressedTexImage3D(r.TEXTURE_2D_ARRAY,Y,Nt,Mt.width,Mt.height,nt.depth,0,Mt.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Wt?U&&e.texSubImage3D(r.TEXTURE_2D_ARRAY,Y,0,0,0,Mt.width,Mt.height,nt.depth,mt,Xt,Mt.data):e.texImage3D(r.TEXTURE_2D_ARRAY,Y,Nt,Mt.width,Mt.height,nt.depth,0,mt,Xt,Mt.data)}else{Wt&&re&&e.texStorage2D(r.TEXTURE_2D,st,Nt,Ot[0].width,Ot[0].height);for(let Y=0,J=Ot.length;Y0){const Y=Sl(nt.width,nt.height,S.format,S.type);for(const J of S.layerUpdates){const at=nt.data.subarray(J*Y/nt.data.BYTES_PER_ELEMENT,(J+1)*Y/nt.data.BYTES_PER_ELEMENT);e.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,J,nt.width,nt.height,1,mt,Xt,at)}S.clearLayerUpdates()}else e.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,nt.width,nt.height,nt.depth,mt,Xt,nt.data)}else e.texImage3D(r.TEXTURE_2D_ARRAY,0,Nt,nt.width,nt.height,nt.depth,0,mt,Xt,nt.data);else if(S.isData3DTexture)Wt?(re&&e.texStorage3D(r.TEXTURE_3D,st,Nt,nt.width,nt.height,nt.depth),U&&e.texSubImage3D(r.TEXTURE_3D,0,0,0,0,nt.width,nt.height,nt.depth,mt,Xt,nt.data)):e.texImage3D(r.TEXTURE_3D,0,Nt,nt.width,nt.height,nt.depth,0,mt,Xt,nt.data);else if(S.isFramebufferTexture){if(re)if(Wt)e.texStorage2D(r.TEXTURE_2D,st,Nt,nt.width,nt.height);else{let Y=nt.width,J=nt.height;for(let at=0;at>=1,J>>=1}}else if(Ot.length>0){if(Wt&&re){const Y=vt(Ot[0]);e.texStorage2D(r.TEXTURE_2D,st,Nt,Y.width,Y.height)}for(let Y=0,J=Ot.length;Y0&&st++;const J=vt(mt[0]);e.texStorage2D(r.TEXTURE_CUBE_MAP,st,Ot,J.width,J.height)}for(let J=0;J<6;J++)if(nt){Wt?U&&e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,0,0,mt[J].width,mt[J].height,Nt,Mt,mt[J].data):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,Ot,mt[J].width,mt[J].height,0,Nt,Mt,mt[J].data);for(let at=0;at>$),mt=Math.max(1,S.height>>$);K===r.TEXTURE_3D||K===r.TEXTURE_2D_ARRAY?e.texImage3D(K,$,_t,nt,mt,S.depth,0,Et,lt,null):e.texImage2D(K,$,_t,nt,mt,0,Et,lt,null)}e.bindFramebuffer(r.FRAMEBUFFER,R),X(S)?o.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,Q,K,n.get(B).__webglTexture,0,ht(S)):(K===r.TEXTURE_2D||K>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,Q,K,n.get(B).__webglTexture,$),e.bindFramebuffer(r.FRAMEBUFFER,null)}function xt(R,S,B){if(r.bindRenderbuffer(r.RENDERBUFFER,R),S.depthBuffer){const Q=S.depthTexture,K=Q&&Q.isDepthTexture?Q.type:null,$=x(S.stencilBuffer,K),Et=S.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,lt=ht(S);X(S)?o.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,lt,$,S.width,S.height):B?r.renderbufferStorageMultisample(r.RENDERBUFFER,lt,$,S.width,S.height):r.renderbufferStorage(r.RENDERBUFFER,$,S.width,S.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,Et,r.RENDERBUFFER,R)}else{const Q=S.textures;for(let K=0;K1;if(Et||(Q.__webglTexture===void 0&&(Q.__webglTexture=r.createTexture()),Q.__version=S.version,a.memory.textures++),$){B.__webglFramebuffer=[];for(let lt=0;lt<6;lt++)if(S.mipmaps&&S.mipmaps.length>0){B.__webglFramebuffer[lt]=[];for(let _t=0;_t0){B.__webglFramebuffer=[];for(let lt=0;lt0&&X(R)===!1){B.__webglMultisampledFramebuffer=r.createFramebuffer(),B.__webglColorRenderbuffer=[],e.bindFramebuffer(r.FRAMEBUFFER,B.__webglMultisampledFramebuffer);for(let lt=0;lt0)for(let _t=0;_t0)for(let _t=0;_t0){if(X(R)===!1){const S=R.textures,B=R.width,Q=R.height;let K=r.COLOR_BUFFER_BIT;const $=R.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Et=n.get(R),lt=S.length>1;if(lt)for(let _t=0;_t0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&S.__useRenderToTexture!==!1}function Tt(R){const S=a.render.frame;h.get(R)!==S&&(h.set(R,S),R.update())}function ut(R,S){const B=R.colorSpace,Q=R.format,K=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||B!==Un&&B!==An&&(Kt.getTransfer(B)===se?(Q!==Ue||K!==mn)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",B)),S}function vt(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(c.width=R.naturalWidth||R.width,c.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(c.width=R.displayWidth,c.height=R.displayHeight):(c.width=R.width,c.height=R.height),c}this.allocateTextureUnit=k,this.resetTextureUnits=L,this.setTexture2D=V,this.setTexture2DArray=q,this.setTexture3D=H,this.setTextureCube=tt,this.rebindTextures=Vt,this.setupRenderTarget=Ut,this.updateRenderTargetMipmap=Jt,this.updateMultisampleRenderTarget=j,this.setupDepthRenderbuffer=Lt,this.setupFrameBufferTexture=et,this.useMultisampledRTT=X}function fd(r,t){function e(n,i=An){let s;const a=Kt.getTransfer(i);if(n===mn)return r.UNSIGNED_BYTE;if(n===Wa)return r.UNSIGNED_SHORT_4_4_4_4;if(n===Xa)return r.UNSIGNED_SHORT_5_5_5_1;if(n===Ul)return r.UNSIGNED_INT_5_9_9_9_REV;if(n===Il)return r.BYTE;if(n===Ll)return r.SHORT;if(n===is)return r.UNSIGNED_SHORT;if(n===Ga)return r.INT;if(n===In)return r.UNSIGNED_INT;if(n===Be)return r.FLOAT;if(n===ls)return r.HALF_FLOAT;if(n===Dl)return r.ALPHA;if(n===Nl)return r.RGB;if(n===Ue)return r.RGBA;if(n===Ol)return r.LUMINANCE;if(n===Fl)return r.LUMINANCE_ALPHA;if(n===vi)return r.DEPTH_COMPONENT;if(n===bi)return r.DEPTH_STENCIL;if(n===qa)return r.RED;if(n===sr)return r.RED_INTEGER;if(n===Bl)return r.RG;if(n===Ya)return r.RG_INTEGER;if(n===Za)return r.RGBA_INTEGER;if(n===Cs||n===Rs||n===Ps||n===Is)if(a===se)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(n===Cs)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Rs)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Ps)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Is)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(n===Cs)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Rs)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Ps)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Is)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===ua||n===da||n===fa||n===pa)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(n===ua)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===da)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===fa)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===pa)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ma||n===ga||n===_a)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(n===ma||n===ga)return a===se?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(n===_a)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===xa||n===va||n===ya||n===Ma||n===Sa||n===ba||n===Aa||n===wa||n===Ea||n===Ta||n===Ca||n===Ra||n===Pa||n===Ia)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(n===xa)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===va)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===ya)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Ma)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Sa)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===ba)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Aa)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===wa)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Ea)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Ta)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Ca)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Ra)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Pa)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Ia)return a===se?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Ls||n===La||n===Ua)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(n===Ls)return a===se?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===La)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Ua)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===zl||n===Da||n===Na||n===Oa)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(n===Ls)return s.COMPRESSED_RED_RGTC1_EXT;if(n===Da)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Na)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Oa)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Si?r.UNSIGNED_INT_24_8:r[n]!==void 0?r[n]:null}return{convert:e}}class pd extends Ae{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}}class ts extends Zt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const xx={type:"move"};class Ko{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new ts,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new ts,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new T,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new T),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new ts,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new T,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new T),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let i=null,s=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(c&&t.hand){a=!0;for(const _ of t.hand.values()){const g=e.getJointPose(_,n),p=this._getHandJoint(c,_);g!==null&&(p.matrix.fromArray(g.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=g.radius),p.visible=g!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,m=.005;c.inputState.pinching&&d>f+m?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!c.inputState.pinching&&d<=f-m&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else l!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,n),s!==null&&(l.matrix.fromArray(s.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,s.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(s.linearVelocity)):l.hasLinearVelocity=!1,s.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(s.angularVelocity)):l.hasAngularVelocity=!1));o!==null&&(i=e.getPose(t.targetRaySpace,n),i===null&&s!==null&&(i=s),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(xx)))}return o!==null&&(o.visible=i!==null),l!==null&&(l.visible=s!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new ts;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const vx=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,yx=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class Mx{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e,n){if(this.texture===null){const i=new ue,s=t.properties.get(i);s.__webglTexture=e.texture,(e.depthNear!=n.depthNear||e.depthFar!=n.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new rn({vertexShader:vx,fragmentShader:yx,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new _e(new hs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Sx extends Dn{constructor(t,e){super();const n=this;let i=null,s=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,f=null,m=null;const _=new Mx,g=e.getContextAttributes();let p=null,v=null;const x=[],y=[],I=new Z;let w=null;const C=new Ae;C.layers.enable(1),C.viewport=new ne;const P=new Ae;P.layers.enable(2),P.viewport=new ne;const b=[C,P],M=new pd;M.layers.enable(1),M.layers.enable(2);let L=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(W){let et=x[W];return et===void 0&&(et=new Ko,x[W]=et),et.getTargetRaySpace()},this.getControllerGrip=function(W){let et=x[W];return et===void 0&&(et=new Ko,x[W]=et),et.getGripSpace()},this.getHand=function(W){let et=x[W];return et===void 0&&(et=new Ko,x[W]=et),et.getHandSpace()};function O(W){const et=y.indexOf(W.inputSource);if(et===-1)return;const xt=x[et];xt!==void 0&&(xt.update(W.inputSource,W.frame,c||a),xt.dispatchEvent({type:W.type,data:W.inputSource}))}function V(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",V),i.removeEventListener("inputsourceschange",q);for(let W=0;W=0&&(y[ct]=null,x[ct].disconnect(xt))}for(let et=0;et=y.length){y.push(xt),ct=Vt;break}else if(y[Vt]===null){y[Vt]=xt,ct=Vt;break}if(ct===-1)break}const Lt=x[ct];Lt&&Lt.connect(xt)}}const H=new T,tt=new T;function G(W,et,xt){H.setFromMatrixPosition(et.matrixWorld),tt.setFromMatrixPosition(xt.matrixWorld);const ct=H.distanceTo(tt),Lt=et.projectionMatrix.elements,Vt=xt.projectionMatrix.elements,Ut=Lt[14]/(Lt[10]-1),Jt=Lt[14]/(Lt[10]+1),E=(Lt[9]+1)/Lt[5],it=(Lt[9]-1)/Lt[5],j=(Lt[8]-1)/Lt[0],ht=(Vt[8]+1)/Vt[0],X=Ut*j,Tt=Ut*ht,ut=ct/(-j+ht),vt=ut*-j;et.matrixWorld.decompose(W.position,W.quaternion,W.scale),W.translateX(vt),W.translateZ(ut),W.matrixWorld.compose(W.position,W.quaternion,W.scale),W.matrixWorldInverse.copy(W.matrixWorld).invert();const R=Ut+ut,S=Jt+ut,B=X-vt,Q=Tt+(ct-vt),K=E*Jt/S*R,$=it*Jt/S*R;W.projectionMatrix.makePerspective(B,Q,K,$,R,S),W.projectionMatrixInverse.copy(W.projectionMatrix).invert()}function pt(W,et){et===null?W.matrixWorld.copy(W.matrix):W.matrixWorld.multiplyMatrices(et.matrixWorld,W.matrix),W.matrixWorldInverse.copy(W.matrixWorld).invert()}this.updateCamera=function(W){if(i===null)return;_.texture!==null&&(W.near=_.depthNear,W.far=_.depthFar),M.near=P.near=C.near=W.near,M.far=P.far=C.far=W.far,(L!==M.near||k!==M.far)&&(i.updateRenderState({depthNear:M.near,depthFar:M.far}),L=M.near,k=M.far,C.near=L,C.far=k,P.near=L,P.far=k,C.updateProjectionMatrix(),P.updateProjectionMatrix(),W.updateProjectionMatrix());const et=W.parent,xt=M.cameras;pt(M,et);for(let ct=0;ct0&&(g.alphaTest.value=p.alphaTest);const v=t.get(p),x=v.envMap,y=v.envMapRotation;x&&(g.envMap.value=x,si.copy(y),si.x*=-1,si.y*=-1,si.z*=-1,x.isCubeTexture&&x.isRenderTargetTexture===!1&&(si.y*=-1,si.z*=-1),g.envMapRotation.value.setFromMatrix4(bx.makeRotationFromEuler(si)),g.flipEnvMap.value=x.isCubeTexture&&x.isRenderTargetTexture===!1?-1:1,g.reflectivity.value=p.reflectivity,g.ior.value=p.ior,g.refractionRatio.value=p.refractionRatio),p.lightMap&&(g.lightMap.value=p.lightMap,g.lightMapIntensity.value=p.lightMapIntensity,e(p.lightMap,g.lightMapTransform)),p.aoMap&&(g.aoMap.value=p.aoMap,g.aoMapIntensity.value=p.aoMapIntensity,e(p.aoMap,g.aoMapTransform))}function a(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,p.map&&(g.map.value=p.map,e(p.map,g.mapTransform))}function o(g,p){g.dashSize.value=p.dashSize,g.totalSize.value=p.dashSize+p.gapSize,g.scale.value=p.scale}function l(g,p,v,x){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.size.value=p.size*v,g.scale.value=x*.5,p.map&&(g.map.value=p.map,e(p.map,g.uvTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,e(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function c(g,p){g.diffuse.value.copy(p.color),g.opacity.value=p.opacity,g.rotation.value=p.rotation,p.map&&(g.map.value=p.map,e(p.map,g.mapTransform)),p.alphaMap&&(g.alphaMap.value=p.alphaMap,e(p.alphaMap,g.alphaMapTransform)),p.alphaTest>0&&(g.alphaTest.value=p.alphaTest)}function h(g,p){g.specular.value.copy(p.specular),g.shininess.value=Math.max(p.shininess,1e-4)}function u(g,p){p.gradientMap&&(g.gradientMap.value=p.gradientMap)}function d(g,p){g.metalness.value=p.metalness,p.metalnessMap&&(g.metalnessMap.value=p.metalnessMap,e(p.metalnessMap,g.metalnessMapTransform)),g.roughness.value=p.roughness,p.roughnessMap&&(g.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,g.roughnessMapTransform)),p.envMap&&(g.envMapIntensity.value=p.envMapIntensity)}function f(g,p,v){g.ior.value=p.ior,p.sheen>0&&(g.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),g.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(g.sheenColorMap.value=p.sheenColorMap,e(p.sheenColorMap,g.sheenColorMapTransform)),p.sheenRoughnessMap&&(g.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,g.sheenRoughnessMapTransform))),p.clearcoat>0&&(g.clearcoat.value=p.clearcoat,g.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(g.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,g.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(g.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===De&&g.clearcoatNormalScale.value.negate())),p.dispersion>0&&(g.dispersion.value=p.dispersion),p.iridescence>0&&(g.iridescence.value=p.iridescence,g.iridescenceIOR.value=p.iridescenceIOR,g.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(g.iridescenceMap.value=p.iridescenceMap,e(p.iridescenceMap,g.iridescenceMapTransform)),p.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),p.transmission>0&&(g.transmission.value=p.transmission,g.transmissionSamplerMap.value=v.texture,g.transmissionSamplerSize.value.set(v.width,v.height),p.transmissionMap&&(g.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,g.transmissionMapTransform)),g.thickness.value=p.thickness,p.thicknessMap&&(g.thicknessMap.value=p.thicknessMap,e(p.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=p.attenuationDistance,g.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(g.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(g.anisotropyMap.value=p.anisotropyMap,e(p.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=p.specularIntensity,g.specularColor.value.copy(p.specularColor),p.specularColorMap&&(g.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,g.specularColorMapTransform)),p.specularIntensityMap&&(g.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,g.specularIntensityMapTransform))}function m(g,p){p.matcap&&(g.matcap.value=p.matcap)}function _(g,p){const v=t.get(p).light;g.referencePosition.value.setFromMatrixPosition(v.matrixWorld),g.nearDistance.value=v.shadow.camera.near,g.farDistance.value=v.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function wx(r,t,e,n){let i={},s={},a=[];const o=r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS);function l(v,x){const y=x.program;n.uniformBlockBinding(v,y)}function c(v,x){let y=i[v.id];y===void 0&&(m(v),y=h(v),i[v.id]=y,v.addEventListener("dispose",g));const I=x.program;n.updateUBOMapping(v,I);const w=t.render.frame;s[v.id]!==w&&(d(v),s[v.id]=w)}function h(v){const x=u();v.__bindingPointIndex=x;const y=r.createBuffer(),I=v.__size,w=v.usage;return r.bindBuffer(r.UNIFORM_BUFFER,y),r.bufferData(r.UNIFORM_BUFFER,I,w),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,x,y),y}function u(){for(let v=0;v0&&(y+=I-w),v.__size=y,v.__cache={},this}function _(v){const x={boundary:0,storage:0};return typeof v=="number"||typeof v=="boolean"?(x.boundary=4,x.storage=4):v.isVector2?(x.boundary=8,x.storage=8):v.isVector3||v.isColor?(x.boundary=16,x.storage=12):v.isVector4?(x.boundary=16,x.storage=16):v.isMatrix3?(x.boundary=48,x.storage=48):v.isMatrix4?(x.boundary=64,x.storage=64):v.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",v),x}function g(v){const x=v.target;x.removeEventListener("dispose",g);const y=a.indexOf(x.__bindingPointIndex);a.splice(y,1),r.deleteBuffer(i[x.id]),delete i[x.id],delete s[x.id]}function p(){for(const v in i)r.deleteBuffer(i[v]);a=[],i={},s={}}return{bind:l,update:c,dispose:p}}class Ex{constructor(t={}){const{canvas:e=td(),context:n=null,depth:i=!0,stencil:s=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1}=t;this.isWebGLRenderer=!0;let d;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");d=n.getContextAttributes().alpha}else d=a;const f=new Uint32Array(4),m=new Int32Array(4);let _=null,g=null;const p=[],v=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=$e,this.toneMapping=Cn,this.toneMappingExposure=1;const x=this;let y=!1,I=0,w=0,C=null,P=-1,b=null;const M=new ne,L=new ne;let k=null;const O=new ft(0);let V=0,q=e.width,H=e.height,tt=1,G=null,pt=null;const yt=new ne(0,0,q,H),gt=new ne(0,0,q,H);let Gt=!1;const $t=new or;let W=!1,et=!1;const xt=new Rt,ct=new T,Lt=new ne,Vt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ut=!1;function Jt(){return C===null?tt:1}let E=n;function it(A,D){return e.getContext(A,D)}try{const A={alpha:!0,depth:i,stencil:s,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Va}`),e.addEventListener("webglcontextlost",Y,!1),e.addEventListener("webglcontextrestored",J,!1),e.addEventListener("webglcontextcreationerror",at,!1),E===null){const D="webgl2";if(E=it(D,A),E===null)throw it(D)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(A){throw console.error("THREE.WebGLRenderer: "+A.message),A}let j,ht,X,Tt,ut,vt,R,S,B,Q,K,$,Et,lt,_t,Ft,nt,mt,Xt,Nt,Mt,Ot,Wt,re;function U(){j=new U_(E),j.init(),Ot=new fd(E,j),ht=new T_(E,j,t,Ot),X=new ux(E),Tt=new O_(E),ut=new j0,vt=new _x(E,j,X,ut,ht,Ot,Tt),R=new R_(x),S=new L_(x),B=new Gp(E),Wt=new w_(E,B),Q=new D_(E,B,Tt,Wt),K=new B_(E,Q,B,Tt),Xt=new F_(E,ht,vt),Ft=new C_(ut),$=new Q0(x,R,S,j,ht,Wt,Ft),Et=new Ax(x,ut),lt=new ex,_t=new ox(j),mt=new A_(x,R,S,X,K,d,l),nt=new hx(x,K,ht),re=new wx(E,Tt,ht,X),Nt=new E_(E,j,Tt),Mt=new N_(E,j,Tt),Tt.programs=$.programs,x.capabilities=ht,x.extensions=j,x.properties=ut,x.renderLists=lt,x.shadowMap=nt,x.state=X,x.info=Tt}U();const st=new Sx(x,E);this.xr=st,this.getContext=function(){return E},this.getContextAttributes=function(){return E.getContextAttributes()},this.forceContextLoss=function(){const A=j.get("WEBGL_lose_context");A&&A.loseContext()},this.forceContextRestore=function(){const A=j.get("WEBGL_lose_context");A&&A.restoreContext()},this.getPixelRatio=function(){return tt},this.setPixelRatio=function(A){A!==void 0&&(tt=A,this.setSize(q,H,!1))},this.getSize=function(A){return A.set(q,H)},this.setSize=function(A,D,F=!0){if(st.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}q=A,H=D,e.width=Math.floor(A*tt),e.height=Math.floor(D*tt),F===!0&&(e.style.width=A+"px",e.style.height=D+"px"),this.setViewport(0,0,A,D)},this.getDrawingBufferSize=function(A){return A.set(q*tt,H*tt).floor()},this.setDrawingBufferSize=function(A,D,F){q=A,H=D,tt=F,e.width=Math.floor(A*F),e.height=Math.floor(D*F),this.setViewport(0,0,A,D)},this.getCurrentViewport=function(A){return A.copy(M)},this.getViewport=function(A){return A.copy(yt)},this.setViewport=function(A,D,F,z){A.isVector4?yt.set(A.x,A.y,A.z,A.w):yt.set(A,D,F,z),X.viewport(M.copy(yt).multiplyScalar(tt).round())},this.getScissor=function(A){return A.copy(gt)},this.setScissor=function(A,D,F,z){A.isVector4?gt.set(A.x,A.y,A.z,A.w):gt.set(A,D,F,z),X.scissor(L.copy(gt).multiplyScalar(tt).round())},this.getScissorTest=function(){return Gt},this.setScissorTest=function(A){X.setScissorTest(Gt=A)},this.setOpaqueSort=function(A){G=A},this.setTransparentSort=function(A){pt=A},this.getClearColor=function(A){return A.copy(mt.getClearColor())},this.setClearColor=function(){mt.setClearColor.apply(mt,arguments)},this.getClearAlpha=function(){return mt.getClearAlpha()},this.setClearAlpha=function(){mt.setClearAlpha.apply(mt,arguments)},this.clear=function(A=!0,D=!0,F=!0){let z=0;if(A){let N=!1;if(C!==null){const rt=C.texture.format;N=rt===Za||rt===Ya||rt===sr}if(N){const rt=C.texture.type,dt=rt===mn||rt===In||rt===is||rt===Si||rt===Wa||rt===Xa,St=mt.getClearColor(),At=mt.getClearAlpha(),It=St.r,Dt=St.g,Ct=St.b;dt?(f[0]=It,f[1]=Dt,f[2]=Ct,f[3]=At,E.clearBufferuiv(E.COLOR,0,f)):(m[0]=It,m[1]=Dt,m[2]=Ct,m[3]=At,E.clearBufferiv(E.COLOR,0,m))}else z|=E.COLOR_BUFFER_BIT}D&&(z|=E.DEPTH_BUFFER_BIT),F&&(z|=E.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),E.clear(z)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",Y,!1),e.removeEventListener("webglcontextrestored",J,!1),e.removeEventListener("webglcontextcreationerror",at,!1),lt.dispose(),_t.dispose(),ut.dispose(),R.dispose(),S.dispose(),K.dispose(),Wt.dispose(),re.dispose(),$.dispose(),st.dispose(),st.removeEventListener("sessionstart",ln),st.removeEventListener("sessionend",gc),Qn.stop()};function Y(A){A.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),y=!0}function J(){console.log("THREE.WebGLRenderer: Context Restored."),y=!1;const A=Tt.autoReset,D=nt.enabled,F=nt.autoUpdate,z=nt.needsUpdate,N=nt.type;U(),Tt.autoReset=A,nt.enabled=D,nt.autoUpdate=F,nt.needsUpdate=z,nt.type=N}function at(A){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",A.statusMessage)}function Pt(A){const D=A.target;D.removeEventListener("dispose",Pt),qt(D)}function qt(A){fe(A),ut.remove(A)}function fe(A){const D=ut.get(A).programs;D!==void 0&&(D.forEach(function(F){$.releaseProgram(F)}),A.isShaderMaterial&&$.releaseShaderCache(A))}this.renderBufferDirect=function(A,D,F,z,N,rt){D===null&&(D=Vt);const dt=N.isMesh&&N.matrixWorld.determinant()<0,St=uf(A,D,F,z,N);X.setMaterial(z,dt);let At=F.index,It=1;if(z.wireframe===!0){if(At=Q.getWireframeAttribute(F),At===void 0)return;It=2}const Dt=F.drawRange,Ct=F.attributes.position;let jt=Dt.start*It,oe=(Dt.start+Dt.count)*It;rt!==null&&(jt=Math.max(jt,rt.start*It),oe=Math.min(oe,(rt.start+rt.count)*It)),At!==null?(jt=Math.max(jt,0),oe=Math.min(oe,At.count)):Ct!=null&&(jt=Math.max(jt,0),oe=Math.min(oe,Ct.count));const le=oe-jt;if(le<0||le===1/0)return;Wt.setup(N,z,St,F,At);let Ve,te=Nt;if(At!==null&&(Ve=B.get(At),te=Mt,te.setIndex(Ve)),N.isMesh)z.wireframe===!0?(X.setLineWidth(z.wireframeLinewidth*Jt()),te.setMode(E.LINES)):te.setMode(E.TRIANGLES);else if(N.isLine){let wt=z.linewidth;wt===void 0&&(wt=1),X.setLineWidth(wt*Jt()),N.isLineSegments?te.setMode(E.LINES):N.isLineLoop?te.setMode(E.LINE_LOOP):te.setMode(E.LINE_STRIP)}else N.isPoints?te.setMode(E.POINTS):N.isSprite&&te.setMode(E.TRIANGLES);if(N.isBatchedMesh)if(N._multiDrawInstances!==null)te.renderMultiDrawInstances(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount,N._multiDrawInstances);else if(j.get("WEBGL_multi_draw"))te.renderMultiDraw(N._multiDrawStarts,N._multiDrawCounts,N._multiDrawCount);else{const wt=N._multiDrawStarts,be=N._multiDrawCounts,ee=N._multiDrawCount,Qe=At?B.get(At).bytesPerElement:1,Ri=ut.get(z).currentProgram.getUniforms();for(let He=0;He{function rt(){if(z.forEach(function(dt){ut.get(dt).currentProgram.isReady()&&z.delete(dt)}),z.size===0){N(A);return}setTimeout(rt,10)}j.get("KHR_parallel_shader_compile")!==null?rt():setTimeout(rt,10)})};let Qt=null;function _n(A){Qt&&Qt(A)}function ln(){Qn.stop()}function gc(){Qn.start()}const Qn=new ld;Qn.setAnimationLoop(_n),typeof self<"u"&&Qn.setContext(self),this.setAnimationLoop=function(A){Qt=A,st.setAnimationLoop(A),A===null?Qn.stop():Qn.start()},st.addEventListener("sessionstart",ln),st.addEventListener("sessionend",gc),this.render=function(A,D){if(D!==void 0&&D.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(y===!0)return;if(A.matrixWorldAutoUpdate===!0&&A.updateMatrixWorld(),D.parent===null&&D.matrixWorldAutoUpdate===!0&&D.updateMatrixWorld(),st.enabled===!0&&st.isPresenting===!0&&(st.cameraAutoUpdate===!0&&st.updateCamera(D),D=st.getCamera()),A.isScene===!0&&A.onBeforeRender(x,A,D,C),g=_t.get(A,v.length),g.init(D),v.push(g),xt.multiplyMatrices(D.projectionMatrix,D.matrixWorldInverse),$t.setFromProjectionMatrix(xt),et=this.localClippingEnabled,W=Ft.init(this.clippingPlanes,et),_=lt.get(A,p.length),_.init(),p.push(_),st.enabled===!0&&st.isPresenting===!0){const rt=x.xr.getDepthSensingMesh();rt!==null&&bo(rt,D,-1/0,x.sortObjects)}bo(A,D,0,x.sortObjects),_.finish(),x.sortObjects===!0&&_.sort(G,pt),Ut=st.enabled===!1||st.isPresenting===!1||st.hasDepthSensing()===!1,Ut&&mt.addToRenderList(_,A),this.info.render.frame++,W===!0&&Ft.beginShadows();const F=g.state.shadowsArray;nt.render(F,A,D),W===!0&&Ft.endShadows(),this.info.autoReset===!0&&this.info.reset();const z=_.opaque,N=_.transmissive;if(g.setupLights(),D.isArrayCamera){const rt=D.cameras;if(N.length>0)for(let dt=0,St=rt.length;dt0&&xc(z,N,A,D),Ut&&mt.render(A),_c(_,A,D);C!==null&&(vt.updateMultisampleRenderTarget(C),vt.updateRenderTargetMipmap(C)),A.isScene===!0&&A.onAfterRender(x,A,D),Wt.resetDefaultState(),P=-1,b=null,v.pop(),v.length>0?(g=v[v.length-1],W===!0&&Ft.setGlobalState(x.clippingPlanes,g.state.camera)):g=null,p.pop(),p.length>0?_=p[p.length-1]:_=null};function bo(A,D,F,z){if(A.visible===!1)return;if(A.layers.test(D.layers)){if(A.isGroup)F=A.renderOrder;else if(A.isLOD)A.autoUpdate===!0&&A.update(D);else if(A.isLight)g.pushLight(A),A.castShadow&&g.pushShadow(A);else if(A.isSprite){if(!A.frustumCulled||$t.intersectsSprite(A)){z&&Lt.setFromMatrixPosition(A.matrixWorld).applyMatrix4(xt);const dt=K.update(A),St=A.material;St.visible&&_.push(A,dt,St,F,Lt.z,null)}}else if((A.isMesh||A.isLine||A.isPoints)&&(!A.frustumCulled||$t.intersectsObject(A))){const dt=K.update(A),St=A.material;if(z&&(A.boundingSphere!==void 0?(A.boundingSphere===null&&A.computeBoundingSphere(),Lt.copy(A.boundingSphere.center)):(dt.boundingSphere===null&&dt.computeBoundingSphere(),Lt.copy(dt.boundingSphere.center)),Lt.applyMatrix4(A.matrixWorld).applyMatrix4(xt)),Array.isArray(St)){const At=dt.groups;for(let It=0,Dt=At.length;It0&&fr(N,D,F),rt.length>0&&fr(rt,D,F),dt.length>0&&fr(dt,D,F),X.buffers.depth.setTest(!0),X.buffers.depth.setMask(!0),X.buffers.color.setMask(!0),X.setPolygonOffset(!1)}function xc(A,D,F,z){if((F.isScene===!0?F.overrideMaterial:null)!==null)return;g.state.transmissionRenderTarget[z.id]===void 0&&(g.state.transmissionRenderTarget[z.id]=new sn(1,1,{generateMipmaps:!0,type:j.has("EXT_color_buffer_half_float")||j.has("EXT_color_buffer_float")?ls:mn,minFilter:un,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Kt.workingColorSpace}));const rt=g.state.transmissionRenderTarget[z.id],dt=z.viewport||M;rt.setSize(dt.z,dt.w);const St=x.getRenderTarget();x.setRenderTarget(rt),x.getClearColor(O),V=x.getClearAlpha(),V<1&&x.setClearColor(16777215,.5),Ut?mt.render(F):x.clear();const At=x.toneMapping;x.toneMapping=Cn;const It=z.viewport;if(z.viewport!==void 0&&(z.viewport=void 0),g.setupLightsView(z),W===!0&&Ft.setGlobalState(x.clippingPlanes,z),fr(A,F,z),vt.updateMultisampleRenderTarget(rt),vt.updateRenderTargetMipmap(rt),j.has("WEBGL_multisampled_render_to_texture")===!1){let Dt=!1;for(let Ct=0,jt=D.length;Ct0),Ct=!!F.morphAttributes.position,jt=!!F.morphAttributes.normal,oe=!!F.morphAttributes.color;let le=Cn;z.toneMapped&&(C===null||C.isXRRenderTarget===!0)&&(le=x.toneMapping);const Ve=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,te=Ve!==void 0?Ve.length:0,wt=ut.get(z),be=g.state.lights;if(W===!0&&(et===!0||A!==b)){const Ze=A===b&&z.id===P;Ft.setState(z,A,Ze)}let ee=!1;z.version===wt.__version?(wt.needsLights&&wt.lightsStateVersion!==be.state.version||wt.outputColorSpace!==St||N.isBatchedMesh&&wt.batching===!1||!N.isBatchedMesh&&wt.batching===!0||N.isBatchedMesh&&wt.batchingColor===!0&&N.colorTexture===null||N.isBatchedMesh&&wt.batchingColor===!1&&N.colorTexture!==null||N.isInstancedMesh&&wt.instancing===!1||!N.isInstancedMesh&&wt.instancing===!0||N.isSkinnedMesh&&wt.skinning===!1||!N.isSkinnedMesh&&wt.skinning===!0||N.isInstancedMesh&&wt.instancingColor===!0&&N.instanceColor===null||N.isInstancedMesh&&wt.instancingColor===!1&&N.instanceColor!==null||N.isInstancedMesh&&wt.instancingMorph===!0&&N.morphTexture===null||N.isInstancedMesh&&wt.instancingMorph===!1&&N.morphTexture!==null||wt.envMap!==At||z.fog===!0&&wt.fog!==rt||wt.numClippingPlanes!==void 0&&(wt.numClippingPlanes!==Ft.numPlanes||wt.numIntersection!==Ft.numIntersection)||wt.vertexAlphas!==It||wt.vertexTangents!==Dt||wt.morphTargets!==Ct||wt.morphNormals!==jt||wt.morphColors!==oe||wt.toneMapping!==le||wt.morphTargetsCount!==te)&&(ee=!0):(ee=!0,wt.__version=z.version);let Qe=wt.currentProgram;ee===!0&&(Qe=pr(z,D,N));let Ri=!1,He=!1,Ao=!1;const pe=Qe.getUniforms(),Nn=wt.uniforms;if(X.useProgram(Qe.program)&&(Ri=!0,He=!0,Ao=!0),z.id!==P&&(P=z.id,He=!0),Ri||b!==A){pe.setValue(E,"projectionMatrix",A.projectionMatrix),pe.setValue(E,"viewMatrix",A.matrixWorldInverse);const Ze=pe.map.cameraPosition;Ze!==void 0&&Ze.setValue(E,ct.setFromMatrixPosition(A.matrixWorld)),ht.logarithmicDepthBuffer&&pe.setValue(E,"logDepthBufFC",2/(Math.log(A.far+1)/Math.LN2)),(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)&&pe.setValue(E,"isOrthographic",A.isOrthographicCamera===!0),b!==A&&(b=A,He=!0,Ao=!0)}if(N.isSkinnedMesh){pe.setOptional(E,N,"bindMatrix"),pe.setOptional(E,N,"bindMatrixInverse");const Ze=N.skeleton;Ze&&(Ze.boneTexture===null&&Ze.computeBoneTexture(),pe.setValue(E,"boneTexture",Ze.boneTexture,vt))}N.isBatchedMesh&&(pe.setOptional(E,N,"batchingTexture"),pe.setValue(E,"batchingTexture",N._matricesTexture,vt),pe.setOptional(E,N,"batchingIdTexture"),pe.setValue(E,"batchingIdTexture",N._indirectTexture,vt),pe.setOptional(E,N,"batchingColorTexture"),N._colorsTexture!==null&&pe.setValue(E,"batchingColorTexture",N._colorsTexture,vt));const wo=F.morphAttributes;if((wo.position!==void 0||wo.normal!==void 0||wo.color!==void 0)&&Xt.update(N,F,Qe),(He||wt.receiveShadow!==N.receiveShadow)&&(wt.receiveShadow=N.receiveShadow,pe.setValue(E,"receiveShadow",N.receiveShadow)),z.isMeshGouraudMaterial&&z.envMap!==null&&(Nn.envMap.value=At,Nn.flipEnvMap.value=At.isCubeTexture&&At.isRenderTargetTexture===!1?-1:1),z.isMeshStandardMaterial&&z.envMap===null&&D.environment!==null&&(Nn.envMapIntensity.value=D.environmentIntensity),He&&(pe.setValue(E,"toneMappingExposure",x.toneMappingExposure),wt.needsLights&&df(Nn,Ao),rt&&z.fog===!0&&Et.refreshFogUniforms(Nn,rt),Et.refreshMaterialUniforms(Nn,z,tt,H,g.state.transmissionRenderTarget[A.id]),la.upload(E,yc(wt),Nn,vt)),z.isShaderMaterial&&z.uniformsNeedUpdate===!0&&(la.upload(E,yc(wt),Nn,vt),z.uniformsNeedUpdate=!1),z.isSpriteMaterial&&pe.setValue(E,"center",N.center),pe.setValue(E,"modelViewMatrix",N.modelViewMatrix),pe.setValue(E,"normalMatrix",N.normalMatrix),pe.setValue(E,"modelMatrix",N.matrixWorld),z.isShaderMaterial||z.isRawShaderMaterial){const Ze=z.uniformsGroups;for(let Eo=0,pf=Ze.length;Eo0&&vt.useMultisampledRTT(A)===!1?N=ut.get(A).__webglMultisampledFramebuffer:Array.isArray(Dt)?N=Dt[F]:N=Dt,M.copy(A.viewport),L.copy(A.scissor),k=A.scissorTest}else M.copy(yt).multiplyScalar(tt).floor(),L.copy(gt).multiplyScalar(tt).floor(),k=Gt;if(X.bindFramebuffer(E.FRAMEBUFFER,N)&&z&&X.drawBuffers(A,N),X.viewport(M),X.scissor(L),X.setScissorTest(k),rt){const At=ut.get(A.texture);E.framebufferTexture2D(E.FRAMEBUFFER,E.COLOR_ATTACHMENT0,E.TEXTURE_CUBE_MAP_POSITIVE_X+D,At.__webglTexture,F)}else if(dt){const At=ut.get(A.texture),It=D||0;E.framebufferTextureLayer(E.FRAMEBUFFER,E.COLOR_ATTACHMENT0,At.__webglTexture,F||0,It)}P=-1},this.readRenderTargetPixels=function(A,D,F,z,N,rt,dt){if(!(A&&A.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let St=ut.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&dt!==void 0&&(St=St[dt]),St){X.bindFramebuffer(E.FRAMEBUFFER,St);try{const At=A.texture,It=At.format,Dt=At.type;if(!ht.textureFormatReadable(It)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ht.textureTypeReadable(Dt)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}D>=0&&D<=A.width-z&&F>=0&&F<=A.height-N&&E.readPixels(D,F,z,N,Ot.convert(It),Ot.convert(Dt),rt)}finally{const At=C!==null?ut.get(C).__webglFramebuffer:null;X.bindFramebuffer(E.FRAMEBUFFER,At)}}},this.readRenderTargetPixelsAsync=async function(A,D,F,z,N,rt,dt){if(!(A&&A.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let St=ut.get(A).__webglFramebuffer;if(A.isWebGLCubeRenderTarget&&dt!==void 0&&(St=St[dt]),St){X.bindFramebuffer(E.FRAMEBUFFER,St);try{const At=A.texture,It=At.format,Dt=At.type;if(!ht.textureFormatReadable(It))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!ht.textureTypeReadable(Dt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");if(D>=0&&D<=A.width-z&&F>=0&&F<=A.height-N){const Ct=E.createBuffer();E.bindBuffer(E.PIXEL_PACK_BUFFER,Ct),E.bufferData(E.PIXEL_PACK_BUFFER,rt.byteLength,E.STREAM_READ),E.readPixels(D,F,z,N,Ot.convert(It),Ot.convert(Dt),0),E.flush();const jt=E.fenceSync(E.SYNC_GPU_COMMANDS_COMPLETE,0);await pp(E,jt,4);try{E.bindBuffer(E.PIXEL_PACK_BUFFER,Ct),E.getBufferSubData(E.PIXEL_PACK_BUFFER,0,rt)}finally{E.deleteBuffer(Ct),E.deleteSync(jt)}return rt}}finally{const At=C!==null?ut.get(C).__webglFramebuffer:null;X.bindFramebuffer(E.FRAMEBUFFER,At)}}},this.copyFramebufferToTexture=function(A,D=null,F=0){A.isTexture!==!0&&(console.warn("WebGLRenderer: copyFramebufferToTexture function signature has changed."),D=arguments[0]||null,A=arguments[1]);const z=Math.pow(2,-F),N=Math.floor(A.image.width*z),rt=Math.floor(A.image.height*z),dt=D!==null?D.x:0,St=D!==null?D.y:0;vt.setTexture2D(A,0),E.copyTexSubImage2D(E.TEXTURE_2D,F,0,0,dt,St,N,rt),X.unbindTexture()},this.copyTextureToTexture=function(A,D,F=null,z=null,N=0){A.isTexture!==!0&&(console.warn("WebGLRenderer: copyTextureToTexture function signature has changed."),z=arguments[0]||null,A=arguments[1],D=arguments[2],N=arguments[3]||0,F=null);let rt,dt,St,At,It,Dt;F!==null?(rt=F.max.x-F.min.x,dt=F.max.y-F.min.y,St=F.min.x,At=F.min.y):(rt=A.image.width,dt=A.image.height,St=0,At=0),z!==null?(It=z.x,Dt=z.y):(It=0,Dt=0);const Ct=Ot.convert(D.format),jt=Ot.convert(D.type);vt.setTexture2D(D,0),E.pixelStorei(E.UNPACK_FLIP_Y_WEBGL,D.flipY),E.pixelStorei(E.UNPACK_PREMULTIPLY_ALPHA_WEBGL,D.premultiplyAlpha),E.pixelStorei(E.UNPACK_ALIGNMENT,D.unpackAlignment);const oe=E.getParameter(E.UNPACK_ROW_LENGTH),le=E.getParameter(E.UNPACK_IMAGE_HEIGHT),Ve=E.getParameter(E.UNPACK_SKIP_PIXELS),te=E.getParameter(E.UNPACK_SKIP_ROWS),wt=E.getParameter(E.UNPACK_SKIP_IMAGES),be=A.isCompressedTexture?A.mipmaps[N]:A.image;E.pixelStorei(E.UNPACK_ROW_LENGTH,be.width),E.pixelStorei(E.UNPACK_IMAGE_HEIGHT,be.height),E.pixelStorei(E.UNPACK_SKIP_PIXELS,St),E.pixelStorei(E.UNPACK_SKIP_ROWS,At),A.isDataTexture?E.texSubImage2D(E.TEXTURE_2D,N,It,Dt,rt,dt,Ct,jt,be.data):A.isCompressedTexture?E.compressedTexSubImage2D(E.TEXTURE_2D,N,It,Dt,be.width,be.height,Ct,be.data):E.texSubImage2D(E.TEXTURE_2D,N,It,Dt,rt,dt,Ct,jt,be),E.pixelStorei(E.UNPACK_ROW_LENGTH,oe),E.pixelStorei(E.UNPACK_IMAGE_HEIGHT,le),E.pixelStorei(E.UNPACK_SKIP_PIXELS,Ve),E.pixelStorei(E.UNPACK_SKIP_ROWS,te),E.pixelStorei(E.UNPACK_SKIP_IMAGES,wt),N===0&&D.generateMipmaps&&E.generateMipmap(E.TEXTURE_2D),X.unbindTexture()},this.copyTextureToTexture3D=function(A,D,F=null,z=null,N=0){A.isTexture!==!0&&(console.warn("WebGLRenderer: copyTextureToTexture3D function signature has changed."),F=arguments[0]||null,z=arguments[1]||null,A=arguments[2],D=arguments[3],N=arguments[4]||0);let rt,dt,St,At,It,Dt,Ct,jt,oe;const le=A.isCompressedTexture?A.mipmaps[N]:A.image;F!==null?(rt=F.max.x-F.min.x,dt=F.max.y-F.min.y,St=F.max.z-F.min.z,At=F.min.x,It=F.min.y,Dt=F.min.z):(rt=le.width,dt=le.height,St=le.depth,At=0,It=0,Dt=0),z!==null?(Ct=z.x,jt=z.y,oe=z.z):(Ct=0,jt=0,oe=0);const Ve=Ot.convert(D.format),te=Ot.convert(D.type);let wt;if(D.isData3DTexture)vt.setTexture3D(D,0),wt=E.TEXTURE_3D;else if(D.isDataArrayTexture||D.isCompressedArrayTexture)vt.setTexture2DArray(D,0),wt=E.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}E.pixelStorei(E.UNPACK_FLIP_Y_WEBGL,D.flipY),E.pixelStorei(E.UNPACK_PREMULTIPLY_ALPHA_WEBGL,D.premultiplyAlpha),E.pixelStorei(E.UNPACK_ALIGNMENT,D.unpackAlignment);const be=E.getParameter(E.UNPACK_ROW_LENGTH),ee=E.getParameter(E.UNPACK_IMAGE_HEIGHT),Qe=E.getParameter(E.UNPACK_SKIP_PIXELS),Ri=E.getParameter(E.UNPACK_SKIP_ROWS),He=E.getParameter(E.UNPACK_SKIP_IMAGES);E.pixelStorei(E.UNPACK_ROW_LENGTH,le.width),E.pixelStorei(E.UNPACK_IMAGE_HEIGHT,le.height),E.pixelStorei(E.UNPACK_SKIP_PIXELS,At),E.pixelStorei(E.UNPACK_SKIP_ROWS,It),E.pixelStorei(E.UNPACK_SKIP_IMAGES,Dt),A.isDataTexture||A.isData3DTexture?E.texSubImage3D(wt,N,Ct,jt,oe,rt,dt,St,Ve,te,le.data):D.isCompressedArrayTexture?E.compressedTexSubImage3D(wt,N,Ct,jt,oe,rt,dt,St,Ve,le.data):E.texSubImage3D(wt,N,Ct,jt,oe,rt,dt,St,Ve,te,le),E.pixelStorei(E.UNPACK_ROW_LENGTH,be),E.pixelStorei(E.UNPACK_IMAGE_HEIGHT,ee),E.pixelStorei(E.UNPACK_SKIP_PIXELS,Qe),E.pixelStorei(E.UNPACK_SKIP_ROWS,Ri),E.pixelStorei(E.UNPACK_SKIP_IMAGES,He),N===0&&D.generateMipmaps&&E.generateMipmap(wt),X.unbindTexture()},this.initRenderTarget=function(A){ut.get(A).__webglFramebuffer===void 0&&vt.setupRenderTarget(A)},this.initTexture=function(A){A.isCubeTexture?vt.setTextureCube(A,0):A.isData3DTexture?vt.setTexture3D(A,0):A.isDataArrayTexture||A.isCompressedArrayTexture?vt.setTexture2DArray(A,0):vt.setTexture2D(A,0),X.unbindTexture()},this.resetState=function(){I=0,w=0,C=null,X.reset(),Wt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return dn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=t===$a?"display-p3":"srgb",e.unpackColorSpace=Kt.workingColorSpace===rr?"display-p3":"srgb"}}class no{constructor(t,e=25e-5){this.isFogExp2=!0,this.name="",this.color=new ft(t),this.density=e}clone(){return new no(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class io{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new ft(t),this.near=e,this.far=n}clone(){return new io(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class md extends Zt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Ye,this.environmentIntensity=1,this.environmentRotation=new Ye,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}class so{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=qs,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=qe()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return Gl("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,s=this.stride;it.far||e.push({distance:l,point:_s.clone(),uv:Xe.getInterpolation(_s,Or,vs,Fr,uh,Qo,dh,new Z),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}}function Br(r,t,e,n,i,s){Ji.subVectors(r,e).addScalar(.5).multiply(n),i!==void 0?(xs.x=s*Ji.x-i*Ji.y,xs.y=i*Ji.x+s*Ji.y):xs.copy(Ji),r.copy(t),r.x+=xs.x,r.y+=xs.y,r.applyMatrix4(gd)}const zr=new T,fh=new T;class xd extends Zt{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(t){super.copy(t,!1);const e=t.levels;for(let n=0,i=e.length;n0){let n,i;for(n=1,i=e.length;n0){zr.setFromMatrixPosition(this.matrixWorld);const i=t.ray.origin.distanceTo(zr);this.getObjectForDistance(i).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){zr.setFromMatrixPosition(t.matrixWorld),fh.setFromMatrixPosition(this.matrixWorld);const n=zr.distanceTo(fh)/t.zoom;e[0].object.visible=!0;let i,s;for(i=1,s=e.length;i=a)e[i-1].object.visible=!1,e[i].object.visible=!0;else break}for(this._currentLevel=i-1;i=i.length&&i.push({start:-1,count:-1,z:-1,index:-1});const a=i[this.index];s.push(a),this.index++,a.start=t.start,a.count=t.count,a.z=e,a.index=n}reset(){this.list.length=0,this.index=0}}const Hn=new Rt,el=new Rt,Ux=new Rt,Dx=new ft(1,1,1),Sh=new Rt,nl=new or,Hr=new Ne,ri=new Ce,Ss=new T,bh=new T,Nx=new T,il=new Lx,Te=new _e,Gr=[];function Ox(r,t,e=0){const n=t.itemSize;if(r.isInterleavedBufferAttribute||r.array.constructor!==t.array.constructor){const i=r.count;for(let s=0;s65535?new Uint32Array(i):new Uint16Array(i);e.setIndex(new ie(s,1))}this._geometryInitialized=!0}}_validateGeometry(t){const e=this.geometry;if(!!t.getIndex()!=!!e.getIndex())throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const n in e.attributes){if(!t.hasAttribute(n))throw new Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const i=t.getAttribute(n),s=e.getAttribute(n);if(i.itemSize!==s.itemSize||i.normalized!==s.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(t){return this.customSort=t,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ne);const t=this._geometryCount,e=this.boundingBox,n=this._drawInfo;e.makeEmpty();for(let i=0;i=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");this._drawInfo.push({visible:!0,active:!0,geometryIndex:t});const e=this._drawInfo.length-1,n=this._matricesTexture,i=n.image.data;Ux.toArray(i,e*16),n.needsUpdate=!0;const s=this._colorsTexture;return s&&(Dx.toArray(s.image.data,e*4),s.needsUpdate=!0),e}addGeometry(t,e=-1,n=-1){if(this._initializeGeometry(t),this._validateGeometry(t),this._drawInfo.length>=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let s=null;const a=this._reservedRanges,o=this._drawRanges,l=this._bounds;this._geometryCount!==0&&(s=a[a.length-1]),e===-1?i.vertexCount=t.getAttribute("position").count:i.vertexCount=e,s===null?i.vertexStart=0:i.vertexStart=s.vertexStart+s.vertexCount;const c=t.getIndex(),h=c!==null;if(h&&(n===-1?i.indexCount=c.count:i.indexCount=n,s===null?i.indexStart=0:i.indexStart=s.indexStart+s.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const u=this._geometryCount;return this._geometryCount++,a.push(i),o.push({start:h?i.indexStart:i.vertexStart,count:-1}),l.push({boxInitialized:!1,box:new Ne,sphereInitialized:!1,sphere:new Ce}),this.setGeometryAt(u,t),u}setGeometryAt(t,e){if(t>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(e);const n=this.geometry,i=n.getIndex()!==null,s=n.getIndex(),a=e.getIndex(),o=this._reservedRanges[t];if(i&&a.count>o.indexCount||e.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const l=o.vertexStart,c=o.vertexCount;for(const f in n.attributes){const m=e.getAttribute(f),_=n.getAttribute(f);Ox(m,_,l);const g=m.itemSize;for(let p=m.count,v=c;p=this._geometryCount)return null;const n=this._bounds[t],i=n.box,s=this.geometry;if(n.boxInitialized===!1){i.makeEmpty();const a=s.index,o=s.attributes.position,l=this._drawRanges[t];for(let c=l.start,h=l.start+l.count;c=this._geometryCount)return null;const n=this._bounds[t],i=n.sphere,s=this.geometry;if(n.sphereInitialized===!1){i.makeEmpty(),this.getBoundingBoxAt(t,Hr),Hr.getCenter(i.center);const a=s.index,o=s.attributes.position,l=this._drawRanges[t];let c=0;for(let h=l.start,u=l.start+l.count;h=n.length||n[t].active===!1?this:(e.toArray(s,t*16),i.needsUpdate=!0,this)}getMatrixAt(t,e){const n=this._drawInfo,i=this._matricesTexture.image.data;return t>=n.length||n[t].active===!1?null:e.fromArray(i,t*16)}setColorAt(t,e){this._colorsTexture===null&&this._initColorsTexture();const n=this._colorsTexture,i=this._colorsTexture.image.data,s=this._drawInfo;return t>=s.length||s[t].active===!1?this:(e.toArray(i,t*4),n.needsUpdate=!0,this)}getColorAt(t,e){const n=this._colorsTexture.image.data,i=this._drawInfo;return t>=i.length||i[t].active===!1?null:e.fromArray(n,t*4)}setVisibleAt(t,e){const n=this._drawInfo;return t>=n.length||n[t].active===!1||n[t].visible===e?this:(n[t].visible=e,this._visibilityChanged=!0,this)}getVisibleAt(t){const e=this._drawInfo;return t>=e.length||e[t].active===!1?!1:e[t].visible}raycast(t,e){const n=this._drawInfo,i=this._drawRanges,s=this.matrixWorld,a=this.geometry;Te.material=this.material,Te.geometry.index=a.index,Te.geometry.attributes=a.attributes,Te.geometry.boundingBox===null&&(Te.geometry.boundingBox=new Ne),Te.geometry.boundingSphere===null&&(Te.geometry.boundingSphere=new Ce);for(let o=0,l=n.length;o({...e})),this._reservedRanges=t._reservedRanges.map(e=>({...e})),this._drawInfo=t._drawInfo.map(e=>({...e})),this._bounds=t._bounds.map(e=>({boxInitialized:e.boxInitialized,box:e.box.clone(),sphereInitialized:e.sphereInitialized,sphere:e.sphere.clone()})),this._maxInstanceCount=t._maxInstanceCount,this._maxVertexCount=t._maxVertexCount,this._maxIndexCount=t._maxIndexCount,this._geometryInitialized=t._geometryInitialized,this._geometryCount=t._geometryCount,this._multiDrawCounts=t._multiDrawCounts.slice(),this._multiDrawStarts=t._multiDrawStarts.slice(),this._matricesTexture=t._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this._colorsTexture!==null&&(this._colorsTexture=t._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(t,e,n,i,s){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=i.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,l=this._drawInfo,c=this._multiDrawStarts,h=this._multiDrawCounts,u=this._drawRanges,d=this.perObjectFrustumCulled,f=this._indirectTexture,m=f.image.data;d&&(Sh.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),nl.setFromProjectionMatrix(Sh,t.coordinateSystem));let _=0;if(this.sortObjects){el.copy(this.matrixWorld).invert(),Ss.setFromMatrixPosition(n.matrixWorld).applyMatrix4(el),bh.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(el);for(let v=0,x=l.length;v0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;sn)return;sl.applyMatrix4(r.matrixWorld);const l=t.ray.origin.distanceTo(sl);if(!(lt.far))return{distance:l,point:wh.clone().applyMatrix4(r.matrixWorld),index:i,face:null,faceIndex:null,object:r}}const Eh=new T,Th=new T;class gn extends Yn{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,n=[];for(let i=0,s=e.count;i0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,a=i.length;si.far)return;s.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:t,face:null,object:a})}}class Fx extends ue{constructor(t,e,n,i,s,a,o,l,c){super(t,e,n,i,s,a,o,l,c),this.isVideoTexture=!0,this.minFilter=a!==void 0?a:ge,this.magFilter=s!==void 0?s:ge,this.generateMipmaps=!1;const h=this;function u(){h.needsUpdate=!0,t.requestVideoFrameCallback(u)}"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback(u)}clone(){return new this.constructor(this.image).copy(this)}update(){const t=this.image;"requestVideoFrameCallback"in t===!1&&t.readyState>=t.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class Bx extends ue{constructor(t,e){super({width:t,height:e}),this.isFramebufferTexture=!0,this.magFilter=Me,this.minFilter=Me,this.generateMipmaps=!1,this.needsUpdate=!0}}class ao extends ue{constructor(t,e,n,i,s,a,o,l,c,h,u,d){super(null,a,o,l,c,h,i,s,u,d),this.isCompressedTexture=!0,this.image={width:e,height:n},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}class zx extends ao{constructor(t,e,n,i,s,a){super(t,e,n,s,a),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=Ke,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class kx extends ao{constructor(t,e,n){super(void 0,t[0].width,t[0].height,e,n,Pn),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=t}}class Vx extends ue{constructor(t,e,n,i,s,a,o,l,c){super(t,e,n,i,s,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class an{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const n=this.getUtoTmapping(t);return this.getPoint(n,e)}getPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPoint(n/t));return e}getSpacedPoints(t=5){const e=[];for(let n=0;n<=t;n++)e.push(this.getPointAt(n/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let n,i=this.getPoint(0),s=0;e.push(0);for(let a=1;a<=t;a++)n=this.getPoint(a/t),s+=n.distanceTo(i),e.push(s),i=n;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const n=this.getLengths();let i=0;const s=n.length;let a;e?a=e:a=t*n[s-1];let o=0,l=s-1,c;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),c=n[i]-a,c<0)o=i+1;else if(c>0)l=i-1;else{l=i;break}if(i=l,n[i]===a)return i/(s-1);const h=n[i],d=n[i+1]-h,f=(a-h)/d;return(i+f)/(s-1)}getTangent(t,e){let i=t-1e-4,s=t+1e-4;i<0&&(i=0),s>1&&(s=1);const a=this.getPoint(i),o=this.getPoint(s),l=e||(a.isVector2?new Z:new T);return l.copy(o).sub(a).normalize(),l}getTangentAt(t,e){const n=this.getUtoTmapping(t);return this.getTangent(n,e)}computeFrenetFrames(t,e){const n=new T,i=[],s=[],a=[],o=new T,l=new Rt;for(let f=0;f<=t;f++){const m=f/t;i[f]=this.getTangentAt(m,new T)}s[0]=new T,a[0]=new T;let c=Number.MAX_VALUE;const h=Math.abs(i[0].x),u=Math.abs(i[0].y),d=Math.abs(i[0].z);h<=c&&(c=h,n.set(1,0,0)),u<=c&&(c=u,n.set(0,1,0)),d<=c&&n.set(0,0,1),o.crossVectors(i[0],n).normalize(),s[0].crossVectors(i[0],o),a[0].crossVectors(i[0],s[0]);for(let f=1;f<=t;f++){if(s[f]=s[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(i[f-1],i[f]),o.length()>Number.EPSILON){o.normalize();const m=Math.acos(he(i[f-1].dot(i[f]),-1,1));s[f].applyMatrix4(l.makeRotationAxis(o,m))}a[f].crossVectors(i[f],s[f])}if(e===!0){let f=Math.acos(he(s[0].dot(s[t]),-1,1));f/=t,i[0].dot(o.crossVectors(s[0],s[t]))>0&&(f=-f);for(let m=1;m<=t;m++)s[m].applyMatrix4(l.makeRotationAxis(i[m],f*m)),a[m].crossVectors(i[m],s[m])}return{tangents:i,normals:s,binormals:a}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}class oo extends an{constructor(t=0,e=0,n=1,i=1,s=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=n,this.yRadius=i,this.aStartAngle=s,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(t,e=new Z){const n=e,i=Math.PI*2;let s=this.aEndAngle-this.aStartAngle;const a=Math.abs(s)i;)s-=i;s0?0:(Math.floor(Math.abs(o)/s)+1)*s:l===0&&o===s-1&&(o=s-2,l=1);let c,h;this.closed||o>0?c=i[(o-1)%s]:(Zr.subVectors(i[0],i[1]).add(i[0]),c=Zr);const u=i[o%s],d=i[(o+1)%s];if(this.closed||o+2i.length-2?i.length-1:a+1],u=i[a>i.length-3?i.length-1:a+2];return n.set(Ph(o,l.x,c.x,h.x,u.x),Ph(o,l.y,c.y,h.y,u.y)),n}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e=n){const a=i[s]-n,o=this.curves[s],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,e)}s++}return null}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const t=[];let e=0;for(let n=0,i=this.curves.length;n1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,n=t.curves.length;e0){const u=c.getPoint(0);u.equals(this.currentPoint)||this.lineTo(u.x,u.y)}this.curves.push(c);const h=c.getPoint(1);return this.currentPoint.copy(h),this}copy(t){return super.copy(t),this.currentPoint.copy(t.currentPoint),this}toJSON(){const t=super.toJSON();return t.currentPoint=this.currentPoint.toArray(),t}fromJSON(t){return super.fromJSON(t),this.currentPoint.fromArray(t.currentPoint),this}}class lr extends Ht{constructor(t=[new Z(0,-.5),new Z(.5,0),new Z(0,.5)],e=12,n=0,i=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:n,phiLength:i},e=Math.floor(e),i=he(i,0,Math.PI*2);const s=[],a=[],o=[],l=[],c=[],h=1/e,u=new T,d=new Z,f=new T,m=new T,_=new T;let g=0,p=0;for(let v=0;v<=t.length-1;v++)switch(v){case 0:g=t[v+1].x-t[v].x,p=t[v+1].y-t[v].y,f.x=p*1,f.y=-g,f.z=p*0,_.copy(f),f.normalize(),l.push(f.x,f.y,f.z);break;case t.length-1:l.push(_.x,_.y,_.z);break;default:g=t[v+1].x-t[v].x,p=t[v+1].y-t[v].y,f.x=p*1,f.y=-g,f.z=p*0,m.copy(f),f.x+=_.x,f.y+=_.y,f.z+=_.z,f.normalize(),l.push(f.x,f.y,f.z),_.copy(m)}for(let v=0;v<=e;v++){const x=n+v*h*i,y=Math.sin(x),I=Math.cos(x);for(let w=0;w<=t.length-1;w++){u.x=t[w].x*y,u.y=t[w].y,u.z=t[w].x*I,a.push(u.x,u.y,u.z),d.x=v/e,d.y=w/(t.length-1),o.push(d.x,d.y);const C=l[3*w+0]*y,P=l[3*w+1],b=l[3*w+0]*I;c.push(C,P,b)}}for(let v=0;v0&&x(!0),e>0&&x(!1)),this.setIndex(h),this.setAttribute("position",new bt(u,3)),this.setAttribute("normal",new bt(d,3)),this.setAttribute("uv",new bt(f,2));function v(){const y=new T,I=new T;let w=0;const C=(e-t)/n;for(let P=0;P<=s;P++){const b=[],M=P/s,L=M*(e-t)+t;for(let k=0;k<=i;k++){const O=k/i,V=O*l+o,q=Math.sin(V),H=Math.cos(V);I.x=L*q,I.y=-M*n+g,I.z=L*H,u.push(I.x,I.y,I.z),y.set(q,C,H).normalize(),d.push(y.x,y.y,y.z),f.push(O,1-M),b.push(m++)}_.push(b)}for(let P=0;P.9&&C<.1&&(x<.2&&(a[v+0]+=1),y<.2&&(a[v+2]+=1),I<.2&&(a[v+4]+=1))}}function d(v){s.push(v.x,v.y,v.z)}function f(v,x){const y=v*3;x.x=t[y+0],x.y=t[y+1],x.z=t[y+2]}function m(){const v=new T,x=new T,y=new T,I=new T,w=new Z,C=new Z,P=new Z;for(let b=0,M=0;b80*e){o=c=r[0],l=h=r[1];for(let m=e;mc&&(c=u),d>h&&(h=d);f=Math.max(c-o,h-l),f=f!==0?32767/f:0}return $s(s,a,e,o,l,f,0),a}};function Pd(r,t,e,n,i){let s,a;if(i===uv(r,t,e,n)>0)for(s=t;s=t;s-=n)a=Ih(s,r[s],r[s+1],a);return a&&fo(a,a.next)&&(Qs(a),a=a.next),a}function wi(r,t){if(!r)return r;t||(t=r);let e=r,n;do if(n=!1,!e.steiner&&(fo(e,e.next)||ae(e.prev,e,e.next)===0)){if(Qs(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function $s(r,t,e,n,i,s,a){if(!r)return;!a&&s&&rv(r,n,i,s);let o=r,l,c;for(;r.prev!==r.next;){if(l=r.prev,c=r.next,s?Kx(r,n,i,s):$x(r)){t.push(l.i/e|0),t.push(r.i/e|0),t.push(c.i/e|0),Qs(r),r=c.next,o=c.next;continue}if(r=c,r===o){a?a===1?(r=Qx(wi(r),t,e),$s(r,t,e,n,i,s,2)):a===2&&jx(r,t,e,n,i,s):$s(wi(r),t,e,n,i,s,1);break}}}function $x(r){const t=r.prev,e=r,n=r.next;if(ae(t,e,n)>=0)return!1;const i=t.x,s=e.x,a=n.x,o=t.y,l=e.y,c=n.y,h=is?i>a?i:a:s>a?s:a,f=o>l?o>c?o:c:l>c?l:c;let m=n.next;for(;m!==t;){if(m.x>=h&&m.x<=d&&m.y>=u&&m.y<=f&&es(i,o,s,l,a,c,m.x,m.y)&&ae(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Kx(r,t,e,n){const i=r.prev,s=r,a=r.next;if(ae(i,s,a)>=0)return!1;const o=i.x,l=s.x,c=a.x,h=i.y,u=s.y,d=a.y,f=ol?o>c?o:c:l>c?l:c,g=h>u?h>d?h:d:u>d?u:d,p=Al(f,m,t,e,n),v=Al(_,g,t,e,n);let x=r.prevZ,y=r.nextZ;for(;x&&x.z>=p&&y&&y.z<=v;){if(x.x>=f&&x.x<=_&&x.y>=m&&x.y<=g&&x!==i&&x!==a&&es(o,h,l,u,c,d,x.x,x.y)&&ae(x.prev,x,x.next)>=0||(x=x.prevZ,y.x>=f&&y.x<=_&&y.y>=m&&y.y<=g&&y!==i&&y!==a&&es(o,h,l,u,c,d,y.x,y.y)&&ae(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;x&&x.z>=p;){if(x.x>=f&&x.x<=_&&x.y>=m&&x.y<=g&&x!==i&&x!==a&&es(o,h,l,u,c,d,x.x,x.y)&&ae(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;y&&y.z<=v;){if(y.x>=f&&y.x<=_&&y.y>=m&&y.y<=g&&y!==i&&y!==a&&es(o,h,l,u,c,d,y.x,y.y)&&ae(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function Qx(r,t,e){let n=r;do{const i=n.prev,s=n.next.next;!fo(i,s)&&Id(i,n,n.next,s)&&Ks(i,s)&&Ks(s,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),Qs(n),Qs(n.next),n=r=s),n=n.next}while(n!==r);return wi(n)}function jx(r,t,e,n,i,s){let a=r;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&lv(a,o)){let l=Ld(a,o);a=wi(a,a.next),l=wi(l,l.next),$s(a,t,e,n,i,s,0),$s(l,t,e,n,i,s,0);return}o=o.next}a=a.next}while(a!==r)}function tv(r,t,e,n){const i=[];let s,a,o,l,c;for(s=0,a=t.length;s=e.next.y&&e.next.y!==e.y){const d=e.x+(a-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=s&&d>n&&(n=d,i=e.x=e.x&&e.x>=l&&s!==e.x&&es(ai.x||e.x===i.x&&sv(i,e)))&&(i=e,h=u)),e=e.next;while(e!==o);return i}function sv(r,t){return ae(r.prev,r,t.prev)<0&&ae(t.next,r,r.next)<0}function rv(r,t,e,n){let i=r;do i.z===0&&(i.z=Al(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,av(i)}function av(r){let t,e,n,i,s,a,o,l,c=1;do{for(e=r,r=null,s=null,a=0;e;){for(a++,n=e,o=0,t=0;t0||l>0&&n;)o!==0&&(l===0||!n||e.z<=n.z)?(i=e,e=e.nextZ,o--):(i=n,n=n.nextZ,l--),s?s.nextZ=i:r=i,i.prevZ=s,s=i;e=n}s.nextZ=null,c*=2}while(a>1);return r}function Al(r,t,e,n,i){return r=(r-e)*i|0,t=(t-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function ov(r){let t=r,e=r;do(t.x=(r-a)*(s-o)&&(r-a)*(n-o)>=(e-a)*(t-o)&&(e-a)*(s-o)>=(i-a)*(n-o)}function lv(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!cv(r,t)&&(Ks(r,t)&&Ks(t,r)&&hv(r,t)&&(ae(r.prev,r,t.prev)||ae(r,t.prev,t))||fo(r,t)&&ae(r.prev,r,r.next)>0&&ae(t.prev,t,t.next)>0)}function ae(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function fo(r,t){return r.x===t.x&&r.y===t.y}function Id(r,t,e,n){const i=jr(ae(r,t,e)),s=jr(ae(r,t,n)),a=jr(ae(e,n,r)),o=jr(ae(e,n,t));return!!(i!==s&&a!==o||i===0&&Qr(r,e,t)||s===0&&Qr(r,n,t)||a===0&&Qr(e,r,n)||o===0&&Qr(e,t,n))}function Qr(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function jr(r){return r>0?1:r<0?-1:0}function cv(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&Id(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Ks(r,t){return ae(r.prev,r,r.next)<0?ae(r,t,r.next)>=0&&ae(r,r.prev,t)>=0:ae(r,t,r.prev)<0||ae(r,r.next,t)<0}function hv(r,t){let e=r,n=!1;const i=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==r);return n}function Ld(r,t){const e=new wl(r.i,r.x,r.y),n=new wl(t.i,t.x,t.y),i=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function Ih(r,t,e,n){const i=new wl(r,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Qs(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function wl(r,t,e){this.i=r,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function uv(r,t,e,n){let i=0;for(let s=t,a=e-n;s2&&r[t-1].equals(r[0])&&r.pop()}function Uh(r,t){for(let e=0;eNumber.EPSILON){const K=Math.sqrt(B),$=Math.sqrt(R*R+S*S),Et=it.x-vt/K,lt=it.y+ut/K,_t=j.x-S/$,Ft=j.y+R/$,nt=((_t-Et)*S-(Ft-lt)*R)/(ut*S-vt*R);ht=Et+ut*nt-E.x,X=lt+vt*nt-E.y;const mt=ht*ht+X*X;if(mt<=2)return new Z(ht,X);Tt=Math.sqrt(mt/2)}else{let K=!1;ut>Number.EPSILON?R>Number.EPSILON&&(K=!0):ut<-Number.EPSILON?R<-Number.EPSILON&&(K=!0):Math.sign(vt)===Math.sign(S)&&(K=!0),K?(ht=-vt,X=ut,Tt=Math.sqrt(B)):(ht=ut,X=vt,Tt=Math.sqrt(B/2))}return new Z(ht/Tt,X/Tt)}const pt=[];for(let E=0,it=V.length,j=it-1,ht=E+1;E=0;E--){const it=E/g,j=f*Math.cos(it*Math.PI/2),ht=m*Math.sin(it*Math.PI/2)+_;for(let X=0,Tt=V.length;X=0;){const ht=j;let X=j-1;X<0&&(X=E.length-1);for(let Tt=0,ut=h+g*2;Tt0)&&f.push(x,y,w),(p!==n-1||l0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=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.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,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.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,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}}class Fd extends Re{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new ft(16777215),this.specular=new ft(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ft(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Zn,this.normalScale=new Z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ye,this.combine=ir,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Bd extends Re{constructor(t){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new ft(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ft(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Zn,this.normalScale=new Z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.gradientMap=t.gradientMap,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}class zd extends Re{constructor(t){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Zn,this.normalScale=new Z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(t)}copy(t){return super.copy(t),this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.flatShading=t.flatShading,this}}class kd extends Re{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ft(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ft(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Zn,this.normalScale=new Z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ye,this.combine=ir,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Vd extends Re{constructor(t){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new ft(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Zn,this.normalScale=new Z(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={MATCAP:""},this.color.copy(t.color),this.matcap=t.matcap,this.map=t.map,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.alphaMap=t.alphaMap,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Hd extends Oe{constructor(t){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(t)}copy(t){return super.copy(t),this.scale=t.scale,this.dashSize=t.dashSize,this.gapSize=t.gapSize,this}}function _i(r,t,e){return!r||!e&&r.constructor===t?r:typeof t.BYTES_PER_ELEMENT=="number"?new t(r):Array.prototype.slice.call(r)}function Gd(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Wd(r){function t(i,s){return r[i]-r[s]}const e=r.length,n=new Array(e);for(let i=0;i!==e;++i)n[i]=i;return n.sort(t),n}function El(r,t,e){const n=r.length,i=new r.constructor(n);for(let s=0,a=0;a!==n;++s){const o=e[s]*t;for(let l=0;l!==t;++l)i[a++]=r[o+l]}return i}function oc(r,t,e,n){let i=1,s=r[0];for(;s!==void 0&&s[n]===void 0;)s=r[i++];if(s===void 0)return;let a=s[n];if(a!==void 0)if(Array.isArray(a))do a=s[n],a!==void 0&&(t.push(s.time),e.push.apply(e,a)),s=r[i++];while(s!==void 0);else if(a.toArray!==void 0)do a=s[n],a!==void 0&&(t.push(s.time),a.toArray(e,e.length)),s=r[i++];while(s!==void 0);else do a=s[n],a!==void 0&&(t.push(s.time),e.push(a)),s=r[i++];while(s!==void 0)}function mv(r,t,e,n,i=30){const s=r.clone();s.name=t;const a=[];for(let l=0;l=n)){u.push(c.times[f]);for(let _=0;_s.tracks[l].times[0]&&(o=s.tracks[l].times[0]);for(let l=0;l=o.times[m]){const p=m*u+h,v=p+u-h;_=o.values.slice(p,v)}else{const p=o.createInterpolant(),v=h,x=u-h;p.evaluate(s),_=p.resultBuffer.slice(v,x)}l==="quaternion"&&new ze().fromArray(_).normalize().conjugate().toArray(_);const g=c.times.length;for(let p=0;p=s)){const o=e[1];t=s)break e}a=n,n=0;break n}break t}for(;n>>1;te;)--a;if(++a,s!==0||a!==i){s>=a&&(a=Math.max(a,1),s=a-1);const o=this.getValueSize();this.times=n.slice(s,a),this.values=this.values.slice(s*o,a*o)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,s=n.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==s;o++){const l=n[o];if(typeof l=="number"&&isNaN(l)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,o,l),t=!1;break}if(a!==null&&a>l){console.error("THREE.KeyframeTrack: Out of order keys.",this,o,l,a),t=!1;break}a=l}if(i!==void 0&&Gd(i))for(let o=0,l=i.length;o!==l;++o){const c=i[o];if(isNaN(c)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,o,c),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===oa,s=t.length-1;let a=1;for(let o=1;o0){t[a]=t[s];for(let o=s*n,l=a*n,c=0;c!==n;++c)e[l+c]=e[o+c];++a}return a!==t.length?(this.times=t.slice(0,a),this.values=e.slice(0,a*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}on.prototype.TimeBufferType=Float32Array;on.prototype.ValueBufferType=Float32Array;on.prototype.DefaultInterpolation=Fa;class Ti extends on{constructor(t,e,n){super(t,e,n)}}Ti.prototype.ValueTypeName="bool";Ti.prototype.ValueBufferType=Array;Ti.prototype.DefaultInterpolation=Vs;Ti.prototype.InterpolantFactoryMethodLinear=void 0;Ti.prototype.InterpolantFactoryMethodSmooth=void 0;class cc extends on{}cc.prototype.ValueTypeName="color";class js extends on{}js.prototype.ValueTypeName="number";class Yd extends ur{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const s=this.resultBuffer,a=this.sampleValues,o=this.valueSize,l=(n-e)/(i-e);let c=t*o;for(let h=c+o;c!==h;c+=4)ze.slerpFlat(s,0,a,c-o,a,c,l);return s}}class dr extends on{InterpolantFactoryMethodLinear(t){return new Yd(this.times,this.values,this.getValueSize(),t)}}dr.prototype.ValueTypeName="quaternion";dr.prototype.InterpolantFactoryMethodSmooth=void 0;class Ci extends on{constructor(t,e,n){super(t,e,n)}}Ci.prototype.ValueTypeName="string";Ci.prototype.ValueBufferType=Array;Ci.prototype.DefaultInterpolation=Vs;Ci.prototype.InterpolantFactoryMethodLinear=void 0;Ci.prototype.InterpolantFactoryMethodSmooth=void 0;class tr extends on{}tr.prototype.ValueTypeName="vector";class er{constructor(t="",e=-1,n=[],i=Ja){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=qe(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let a=0,o=n.length;a!==o;++a)e.push(vv(n[a]).scale(i));const s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,a=n.length;s!==a;++s)e.push(on.toJSON(n[s]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const s=e.length,a=[];for(let o=0;o1){const u=h[1];let d=i[u];d||(i[u]=d=[]),d.push(c)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],e,n));return a}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(u,d,f,m,_){if(f.length!==0){const g=[],p=[];oc(f,g,p,m),g.length!==0&&_.push(new u(d,g,p))}},i=[],s=t.name||"default",a=t.fps||30,o=t.blendMode;let l=t.length||-1;const c=t.hierarchy||[];for(let u=0;u{e&&e(s),this.manager.itemEnd(t)},0),s;if(bn[t]!==void 0){bn[t].push({onLoad:e,onProgress:n,onError:i});return}bn[t]=[],bn[t].push({onLoad:e,onProgress:n,onError:i});const a=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,l=this.responseType;fetch(a).then(c=>{if(c.status===200||c.status===0){if(c.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||c.body===void 0||c.body.getReader===void 0)return c;const h=bn[t],u=c.body.getReader(),d=c.headers.get("X-File-Size")||c.headers.get("Content-Length"),f=d?parseInt(d):0,m=f!==0;let _=0;const g=new ReadableStream({start(p){v();function v(){u.read().then(({done:x,value:y})=>{if(x)p.close();else{_+=y.byteLength;const I=new ProgressEvent("progress",{lengthComputable:m,loaded:_,total:f});for(let w=0,C=h.length;w{p.error(x)})}}});return new Response(g)}else throw new yv(`fetch for "${c.url}" responded with ${c.status}: ${c.statusText}`,c)}).then(c=>{switch(l){case"arraybuffer":return c.arrayBuffer();case"blob":return c.blob();case"document":return c.text().then(h=>new DOMParser().parseFromString(h,o));case"json":return c.json();default:if(o===void 0)return c.text();{const u=/charset="?([^;"\s]*)"?/i.exec(o),d=u&&u[1]?u[1].toLowerCase():void 0,f=new TextDecoder(d);return c.arrayBuffer().then(m=>f.decode(m))}}}).then(c=>{En.add(t,c);const h=bn[t];delete bn[t];for(let u=0,d=h.length;u{const h=bn[t];if(h===void 0)throw this.manager.itemError(t),c;delete bn[t];for(let u=0,d=h.length;u{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class Mv extends ke{constructor(t){super(t)}load(t,e,n,i){const s=this,a=new Ln(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(o){try{e(s.parse(JSON.parse(o)))}catch(l){i?i(l):console.error(l),s.manager.itemError(t)}},n,i)}parse(t){const e=[];for(let n=0;n0:i.vertexColors=t.vertexColors),t.uniforms!==void 0)for(const s in t.uniforms){const a=t.uniforms[s];switch(i.uniforms[s]={},a.type){case"t":i.uniforms[s].value=n(a.value);break;case"c":i.uniforms[s].value=new ft().setHex(a.value);break;case"v2":i.uniforms[s].value=new Z().fromArray(a.value);break;case"v3":i.uniforms[s].value=new T().fromArray(a.value);break;case"v4":i.uniforms[s].value=new ne().fromArray(a.value);break;case"m3":i.uniforms[s].value=new Bt().fromArray(a.value);break;case"m4":i.uniforms[s].value=new Rt().fromArray(a.value);break;default:i.uniforms[s].value=a.value}}if(t.defines!==void 0&&(i.defines=t.defines),t.vertexShader!==void 0&&(i.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(i.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(i.glslVersion=t.glslVersion),t.extensions!==void 0)for(const s in t.extensions)i.extensions[s]=t.extensions[s];if(t.lights!==void 0&&(i.lights=t.lights),t.clipping!==void 0&&(i.clipping=t.clipping),t.size!==void 0&&(i.size=t.size),t.sizeAttenuation!==void 0&&(i.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(i.map=n(t.map)),t.matcap!==void 0&&(i.matcap=n(t.matcap)),t.alphaMap!==void 0&&(i.alphaMap=n(t.alphaMap)),t.bumpMap!==void 0&&(i.bumpMap=n(t.bumpMap)),t.bumpScale!==void 0&&(i.bumpScale=t.bumpScale),t.normalMap!==void 0&&(i.normalMap=n(t.normalMap)),t.normalMapType!==void 0&&(i.normalMapType=t.normalMapType),t.normalScale!==void 0){let s=t.normalScale;Array.isArray(s)===!1&&(s=[s,s]),i.normalScale=new Z().fromArray(s)}return t.displacementMap!==void 0&&(i.displacementMap=n(t.displacementMap)),t.displacementScale!==void 0&&(i.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(i.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(i.roughnessMap=n(t.roughnessMap)),t.metalnessMap!==void 0&&(i.metalnessMap=n(t.metalnessMap)),t.emissiveMap!==void 0&&(i.emissiveMap=n(t.emissiveMap)),t.emissiveIntensity!==void 0&&(i.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(i.specularMap=n(t.specularMap)),t.specularIntensityMap!==void 0&&(i.specularIntensityMap=n(t.specularIntensityMap)),t.specularColorMap!==void 0&&(i.specularColorMap=n(t.specularColorMap)),t.envMap!==void 0&&(i.envMap=n(t.envMap)),t.envMapRotation!==void 0&&i.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(i.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(i.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(i.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(i.lightMap=n(t.lightMap)),t.lightMapIntensity!==void 0&&(i.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(i.aoMap=n(t.aoMap)),t.aoMapIntensity!==void 0&&(i.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(i.gradientMap=n(t.gradientMap)),t.clearcoatMap!==void 0&&(i.clearcoatMap=n(t.clearcoatMap)),t.clearcoatRoughnessMap!==void 0&&(i.clearcoatRoughnessMap=n(t.clearcoatRoughnessMap)),t.clearcoatNormalMap!==void 0&&(i.clearcoatNormalMap=n(t.clearcoatNormalMap)),t.clearcoatNormalScale!==void 0&&(i.clearcoatNormalScale=new Z().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(i.iridescenceMap=n(t.iridescenceMap)),t.iridescenceThicknessMap!==void 0&&(i.iridescenceThicknessMap=n(t.iridescenceThicknessMap)),t.transmissionMap!==void 0&&(i.transmissionMap=n(t.transmissionMap)),t.thicknessMap!==void 0&&(i.thicknessMap=n(t.thicknessMap)),t.anisotropyMap!==void 0&&(i.anisotropyMap=n(t.anisotropyMap)),t.sheenColorMap!==void 0&&(i.sheenColorMap=n(t.sheenColorMap)),t.sheenRoughnessMap!==void 0&&(i.sheenRoughnessMap=n(t.sheenRoughnessMap)),i}setTextures(t){return this.textures=t,this}static createMaterialFromType(t){const e={ShadowMaterial:Dd,SpriteMaterial:Kl,RawShaderMaterial:Nd,ShaderMaterial:rn,PointsMaterial:jl,MeshPhysicalMaterial:Od,MeshStandardMaterial:ac,MeshPhongMaterial:Fd,MeshToonMaterial:Bd,MeshNormalMaterial:zd,MeshLambertMaterial:kd,MeshDepthMaterial:Jl,MeshDistanceMaterial:$l,MeshBasicMaterial:Jn,MeshMatcapMaterial:Vd,LineDashedMaterial:Hd,LineBasicMaterial:Oe,Material:Re};return new e[t]}}class Tl{static decodeText(t){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),typeof TextDecoder<"u")return new TextDecoder().decode(t);let e="";for(let n=0,i=t.length;n0){const l=new hc(e);s=new nr(l),s.setCrossOrigin(this.crossOrigin);for(let c=0,h=t.length;c0){i=new nr(this.manager),i.setCrossOrigin(this.crossOrigin);for(let a=0,o=t.length;a{const g=new Ne;g.min.fromArray(_.boxMin),g.max.fromArray(_.boxMax);const p=new Ce;return p.radius=_.sphereRadius,p.center.fromArray(_.sphereCenter),{boxInitialized:_.boxInitialized,box:g,sphereInitialized:_.sphereInitialized,sphere:p}}),a._maxInstanceCount=t.maxInstanceCount,a._maxVertexCount=t.maxVertexCount,a._maxIndexCount=t.maxIndexCount,a._geometryInitialized=t.geometryInitialized,a._geometryCount=t.geometryCount,a._matricesTexture=c(t.matricesTexture.uuid),t.colorsTexture!==void 0&&(a._colorsTexture=c(t.colorsTexture.uuid));break;case"LOD":a=new xd;break;case"Line":a=new Yn(o(t.geometry),l(t.material));break;case"LineLoop":a=new Sd(o(t.geometry),l(t.material));break;case"LineSegments":a=new gn(o(t.geometry),l(t.material));break;case"PointCloud":case"Points":a=new bd(o(t.geometry),l(t.material));break;case"Sprite":a=new _d(l(t.material));break;case"Group":a=new ts;break;case"Bone":a=new Ql;break;default:a=new Zt}if(a.uuid=t.uuid,t.name!==void 0&&(a.name=t.name),t.matrix!==void 0?(a.matrix.fromArray(t.matrix),t.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=t.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(t.position!==void 0&&a.position.fromArray(t.position),t.rotation!==void 0&&a.rotation.fromArray(t.rotation),t.quaternion!==void 0&&a.quaternion.fromArray(t.quaternion),t.scale!==void 0&&a.scale.fromArray(t.scale)),t.up!==void 0&&a.up.fromArray(t.up),t.castShadow!==void 0&&(a.castShadow=t.castShadow),t.receiveShadow!==void 0&&(a.receiveShadow=t.receiveShadow),t.shadow&&(t.shadow.intensity!==void 0&&(a.shadow.intensity=t.shadow.intensity),t.shadow.bias!==void 0&&(a.shadow.bias=t.shadow.bias),t.shadow.normalBias!==void 0&&(a.shadow.normalBias=t.shadow.normalBias),t.shadow.radius!==void 0&&(a.shadow.radius=t.shadow.radius),t.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(t.shadow.mapSize),t.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(t.shadow.camera))),t.visible!==void 0&&(a.visible=t.visible),t.frustumCulled!==void 0&&(a.frustumCulled=t.frustumCulled),t.renderOrder!==void 0&&(a.renderOrder=t.renderOrder),t.userData!==void 0&&(a.userData=t.userData),t.layers!==void 0&&(a.layers.mask=t.layers),t.children!==void 0){const d=t.children;for(let f=0;f"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(t){return this.options=t,this}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,a=En.get(t);if(a!==void 0){if(s.manager.itemStart(t),a.then){a.then(c=>{e&&e(c),s.manager.itemEnd(t)}).catch(c=>{i&&i(c)});return}return setTimeout(function(){e&&e(a),s.manager.itemEnd(t)},0),a}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader;const l=fetch(t,o).then(function(c){return c.blob()}).then(function(c){return createImageBitmap(c,Object.assign(s.options,{colorSpaceConversion:"none"}))}).then(function(c){return En.add(t,c),e&&e(c),s.manager.itemEnd(t),c}).catch(function(c){i&&i(c),En.remove(t),s.manager.itemError(t),s.manager.itemEnd(t)});En.add(t,l),s.manager.itemStart(t)}}let ta;class dc{static getContext(){return ta===void 0&&(ta=new(window.AudioContext||window.webkitAudioContext)),ta}static setContext(t){ta=t}}class Lv extends ke{constructor(t){super(t)}load(t,e,n,i){const s=this,a=new Ln(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,function(l){try{const c=l.slice(0);dc.getContext().decodeAudioData(c,function(u){e(u)}).catch(o)}catch(c){o(c)}},n,i);function o(l){i?i(l):console.error(l),s.manager.itemError(t)}}}const Vh=new Rt,Hh=new Rt,ai=new Rt;class Uv{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Ae,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Ae,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(t){const e=this._cache;if(e.focus!==t.focus||e.fov!==t.fov||e.aspect!==t.aspect*this.aspect||e.near!==t.near||e.far!==t.far||e.zoom!==t.zoom||e.eyeSep!==this.eyeSep){e.focus=t.focus,e.fov=t.fov,e.aspect=t.aspect*this.aspect,e.near=t.near,e.far=t.far,e.zoom=t.zoom,e.eyeSep=this.eyeSep,ai.copy(t.projectionMatrix);const i=e.eyeSep/2,s=i*e.near/e.focus,a=e.near*Math.tan(yi*e.fov*.5)/e.zoom;let o,l;Hh.elements[12]=-i,Vh.elements[12]=i,o=-a*e.aspect+s,l=a*e.aspect+s,ai.elements[0]=2*e.near/(l-o),ai.elements[8]=(l+o)/(l-o),this.cameraL.projectionMatrix.copy(ai),o=-a*e.aspect-s,l=a*e.aspect-s,ai.elements[0]=2*e.near/(l-o),ai.elements[8]=(l+o)/(l-o),this.cameraR.projectionMatrix.copy(ai)}this.cameraL.matrixWorld.copy(t.matrixWorld).multiply(Hh),this.cameraR.matrixWorld.copy(t.matrixWorld).multiply(Vh)}}class af{constructor(t=!0){this.autoStart=t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=Gh(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const e=Gh();t=(e-this.oldTime)/1e3,this.oldTime=e,this.elapsedTime+=t}return t}}function Gh(){return(typeof performance>"u"?Date:performance).now()}const oi=new T,Wh=new ze,Dv=new T,li=new T;class Nv extends Zt{constructor(){super(),this.type="AudioListener",this.context=dc.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new af}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(t){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=t,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(t){return this.gain.gain.setTargetAtTime(t,this.context.currentTime,.01),this}updateMatrixWorld(t){super.updateMatrixWorld(t);const e=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(oi,Wh,Dv),li.set(0,0,-1).applyQuaternion(Wh),e.positionX){const i=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(oi.x,i),e.positionY.linearRampToValueAtTime(oi.y,i),e.positionZ.linearRampToValueAtTime(oi.z,i),e.forwardX.linearRampToValueAtTime(li.x,i),e.forwardY.linearRampToValueAtTime(li.y,i),e.forwardZ.linearRampToValueAtTime(li.z,i),e.upX.linearRampToValueAtTime(n.x,i),e.upY.linearRampToValueAtTime(n.y,i),e.upZ.linearRampToValueAtTime(n.z,i)}else e.setPosition(oi.x,oi.y,oi.z),e.setOrientation(li.x,li.y,li.z,n.x,n.y,n.z)}}class of extends Zt{constructor(t){super(),this.type="Audio",this.listener=t,this.context=t.context,this.gain=this.context.createGain(),this.gain.connect(t.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(t){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=t,this.connect(),this}setMediaElementSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(t),this.connect(),this}setMediaStreamSource(t){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(t),this.connect(),this}setBuffer(t){return this.buffer=t,this.sourceType="buffer",this.autoplay&&this.play(),this}play(t=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+t;const e=this.context.createBufferSource();return e.buffer=this.buffer,e.loop=this.loop,e.loopStart=this.loopStart,e.loopEnd=this.loopEnd,e.onended=this.onEnded.bind(this),e.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=e,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t0&&this._mixBufferRegionAdditive(n,i,this._addIndex*e,1,e);for(let l=e,c=e+e;l!==c;++l)if(n[l]!==n[l+e]){o.setValue(n,i);break}}saveOriginalState(){const t=this.binding,e=this.buffer,n=this.valueSize,i=n*this._origIndex;t.getValue(e,i);for(let s=n,a=i;s!==a;++s)e[s]=e[i+s%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let n=t;n=.5)for(let a=0;a!==s;++a)t[e+a]=t[n+a]}_slerp(t,e,n,i){ze.slerpFlat(t,e,t,e,t,n,i)}_slerpAdditive(t,e,n,i,s){const a=this._workIndex*s;ze.multiplyQuaternionsFlat(t,a,t,e,t,n),ze.slerpFlat(t,e,t,e,t,a,i)}_lerp(t,e,n,i,s){const a=1-i;for(let o=0;o!==s;++o){const l=e+o;t[l]=t[l]*a+t[n+o]*i}}_lerpAdditive(t,e,n,i,s){for(let a=0;a!==s;++a){const o=e+a;t[o]=t[o]+t[n+a]*i}}}const fc="\\[\\]\\.:\\/",zv=new RegExp("["+fc+"]","g"),pc="[^"+fc+"]",kv="[^"+fc.replace("\\.","")+"]",Vv=/((?:WC+[\/:])*)/.source.replace("WC",pc),Hv=/(WCOD+)?/.source.replace("WCOD",kv),Gv=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",pc),Wv=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",pc),Xv=new RegExp("^"+Vv+Hv+Gv+Wv+"$"),qv=["material","materials","bones","map"];class Yv{constructor(t,e,n){const i=n||Yt.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,s=n.length;i!==s;++i)n[i].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}}class Yt{constructor(t,e,n){this.path=e,this.parsedPath=n||Yt.parseTrackName(e),this.node=Yt.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new Yt.Composite(t,e,n):new Yt(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(zv,"")}static parseTrackName(t){const e=Xv.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const s=n.nodeName.substring(i+1);qv.indexOf(s)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=s)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){const n=function(s){for(let a=0;a=s){const u=s++,d=t[u];e[d.uuid]=h,t[h]=d,e[c]=u,t[u]=l;for(let f=0,m=i;f!==m;++f){const _=n[f],g=_[u],p=_[h];_[h]=g,_[u]=p}}}this.nCachedObjects_=s}uncache(){const t=this._objects,e=this._indicesByUUID,n=this._bindings,i=n.length;let s=this.nCachedObjects_,a=t.length;for(let o=0,l=arguments.length;o!==l;++o){const c=arguments[o],h=c.uuid,u=e[h];if(u!==void 0)if(delete e[h],u0&&(e[f.uuid]=u),t[u]=f,t.pop();for(let m=0,_=i;m!==_;++m){const g=n[m];g[u]=g[d],g.pop()}}}this.nCachedObjects_=s}subscribe_(t,e){const n=this._bindingsIndicesByPath;let i=n[t];const s=this._bindings;if(i!==void 0)return s[i];const a=this._paths,o=this._parsedPaths,l=this._objects,c=l.length,h=this.nCachedObjects_,u=new Array(c);i=s.length,n[t]=i,a.push(t),o.push(e),s.push(u);for(let d=h,f=l.length;d!==f;++d){const m=l[d];u[d]=new Yt(m,t,e)}return u}unsubscribe_(t){const e=this._bindingsIndicesByPath,n=e[t];if(n!==void 0){const i=this._paths,s=this._parsedPaths,a=this._bindings,o=a.length-1,l=a[o],c=t[o];e[c]=n,a[n]=l,a.pop(),s[n]=s[o],s.pop(),i[n]=i[o],i.pop()}}}class cf{constructor(t,e,n=null,i=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=n,this.blendMode=i;const s=e.tracks,a=s.length,o=new Array(a),l={endingStart:pi,endingEnd:pi};for(let c=0;c!==a;++c){const h=s[c].createInterpolant(null);o[c]=h,h.settings=l}this._interpolantSettings=l,this._interpolants=o,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Vu,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,n){if(t.fadeOut(e),this.fadeIn(e),n){const i=this._clip.duration,s=t._clip.duration,a=s/i,o=i/s;t.warp(1,a,e),this.warp(o,1,e)}return this}crossFadeTo(t,e,n){return t.crossFadeFrom(this,e,n)}stopFading(){const t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,n){const i=this._mixer,s=i.time,a=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);const l=o.parameterPositions,c=o.sampleValues;return l[0]=s,l[1]=s+n,c[0]=t/a,c[1]=e/a,this}stopWarping(){const t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,n,i){if(!this.enabled){this._updateWeight(t);return}const s=this._startTime;if(s!==null){const l=(t-s)*n;l<0||n===0?e=0:(this._startTime=null,e=n*l)}e*=this._updateTimeScale(t);const a=this._updateTime(e),o=this._updateWeight(t);if(o>0){const l=this._interpolants,c=this._propertyBindings;switch(this.blendMode){case kl:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(a),c[h].accumulateAdditive(o);break;case Ja:default:for(let h=0,u=l.length;h!==u;++h)l[h].evaluate(a),c[h].accumulate(i,o)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const n=this._weightInterpolant;if(n!==null){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopFading(),i===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const i=n.evaluate(t)[0];e*=i,t>n.parameterPositions[1]&&(this.stopWarping(),e===0?this.paused=!0:this.timeScale=e)}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,n=this.loop;let i=this.time+t,s=this._loopCount;const a=n===Hu;if(t===0)return s===-1?i:a&&(s&1)===1?e-i:i;if(n===ku){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(i>=e)i=e;else if(i<0)i=0;else{this.time=i;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),i>=e||i<0){const o=Math.floor(i/e);i-=e*o,s+=Math.abs(o);const l=this.repetitions-s;if(l<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=t>0?e:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(l===1){const c=t<0;this._setEndings(c,!c,a)}else this._setEndings(!1,!1,a);this._loopCount=s,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this.time=i;if(a&&(s&1)===1)return e-i}return i}_setEndings(t,e,n){const i=this._interpolantSettings;n?(i.endingStart=mi,i.endingEnd=mi):(t?i.endingStart=this.zeroSlopeAtStart?mi:pi:i.endingStart=Hs,e?i.endingEnd=this.zeroSlopeAtEnd?mi:pi:i.endingEnd=Hs)}_scheduleFading(t,e,n){const i=this._mixer,s=i.time;let a=this._weightInterpolant;a===null&&(a=i._lendControlInterpolant(),this._weightInterpolant=a);const o=a.parameterPositions,l=a.sampleValues;return o[0]=s,l[0]=e,o[1]=s+t,l[1]=n,this}}const Jv=new Float32Array(1);class $v extends Dn{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const n=t._localRoot||this._root,i=t._clip.tracks,s=i.length,a=t._propertyBindings,o=t._interpolants,l=n.uuid,c=this._bindingsByRootAndName;let h=c[l];h===void 0&&(h={},c[l]=h);for(let u=0;u!==s;++u){const d=i[u],f=d.name;let m=h[f];if(m!==void 0)++m.referenceCount,a[u]=m;else{if(m=a[u],m!==void 0){m._cacheIndex===null&&(++m.referenceCount,this._addInactiveBinding(m,l,f));continue}const _=e&&e._propertyBindings[u].binding.parsedPath;m=new lf(Yt.create(n,f,_),d.ValueTypeName,d.getValueSize()),++m.referenceCount,this._addInactiveBinding(m,l,f),a[u]=m}o[u].resultBuffer=m.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){const n=(t._localRoot||this._root).uuid,i=t._clip.uuid,s=this._actionsByClip[i];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,i,n)}const e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){const s=e[n];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let n=0,i=e.length;n!==i;++n){const s=e[n];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return e!==null&&e=0;--n)t[n].stop();return this}update(t){t*=this.timeScale;const e=this._actions,n=this._nActiveActions,i=this.time+=t,s=Math.sign(t),a=this._accuIndex^=1;for(let c=0;c!==n;++c)e[c]._update(i,t,s,a);const o=this._bindings,l=this._nActiveBindings;for(let c=0;c!==l;++c)o[c].apply(a);return this}setTime(t){this.time=0;for(let e=0;ethis.max.x||t.ythis.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.xthis.max.x||t.max.ythis.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Zh).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const Jh=new T,ea=new T;class ry{constructor(t=new T,e=new T){this.start=t,this.end=e}set(t,e){return this.start.copy(t),this.end.copy(e),this}copy(t){return this.start.copy(t.start),this.end.copy(t.end),this}getCenter(t){return t.addVectors(this.start,this.end).multiplyScalar(.5)}delta(t){return t.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(t,e){return this.delta(e).multiplyScalar(t).add(this.start)}closestPointToPointParameter(t,e){Jh.subVectors(t,this.start),ea.subVectors(this.end,this.start);const n=ea.dot(ea);let s=ea.dot(Jh)/n;return e&&(s=he(s,0,1)),s}closestPointToPoint(t,e,n){const i=this.closestPointToPointParameter(t,e);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(t){return this.start.applyMatrix4(t),this.end.applyMatrix4(t),this}equals(t){return t.start.equals(this.start)&&t.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const $h=new T;class ay extends Zt{constructor(t,e){super(),this.light=t,this.matrixAutoUpdate=!1,this.color=e,this.type="SpotLightHelper";const n=new Ht,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let a=0,o=1,l=32;a1)for(let u=0;u.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{eu.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(eu,e)}}setLength(t,e=t*.2,n=e*.2){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(n,e,n),this.cone.position.y=t,this.cone.updateMatrix()}setColor(t){this.line.material.color.set(t),this.cone.material.color.set(t)}copy(t){return super.copy(t,!1),this.line.copy(t.line),this.cone.copy(t.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class vy extends gn{constructor(t=1){const e=[0,0,0,t,0,0,0,0,0,0,t,0,0,0,0,0,0,t],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],i=new Ht;i.setAttribute("position",new bt(e,3)),i.setAttribute("color",new bt(n,3));const s=new Oe({vertexColors:!0,toneMapped:!1});super(i,s),this.type="AxesHelper"}setColors(t,e,n){const i=new ft,s=this.geometry.attributes.color.array;return i.set(t),i.toArray(s,0),i.toArray(s,3),i.set(e),i.toArray(s,6),i.toArray(s,9),i.set(n),i.toArray(s,12),i.toArray(s,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class yy{constructor(){this.type="ShapePath",this.color=new ft,this.subPaths=[],this.currentPath=null}moveTo(t,e){return this.currentPath=new Js,this.subPaths.push(this.currentPath),this.currentPath.moveTo(t,e),this}lineTo(t,e){return this.currentPath.lineTo(t,e),this}quadraticCurveTo(t,e,n,i){return this.currentPath.quadraticCurveTo(t,e,n,i),this}bezierCurveTo(t,e,n,i,s,a){return this.currentPath.bezierCurveTo(t,e,n,i,s,a),this}splineThru(t){return this.currentPath.splineThru(t),this}toShapes(t){function e(p){const v=[];for(let x=0,y=p.length;xNumber.EPSILON){if(M<0&&(C=v[w],b=-b,P=v[I],M=-M),p.yP.y)continue;if(p.y===C.y){if(p.x===C.x)return!0}else{const L=M*(p.x-C.x)-b*(p.y-C.y);if(L===0)return!0;if(L<0)continue;y=!y}}else{if(p.y!==C.y)continue;if(P.x<=p.x&&p.x<=C.x||C.x<=p.x&&p.x<=P.x)return!0}}return y}const i=pn.isClockWise,s=this.subPaths;if(s.length===0)return[];let a,o,l;const c=[];if(s.length===1)return o=s[0],l=new Mi,l.curves=o.curves,c.push(l),c;let h=!i(s[0].getPoints());h=t?!h:h;const u=[],d=[];let f=[],m=0,_;d[m]=void 0,f[m]=[];for(let p=0,v=s.length;p1){let p=!1,v=0;for(let x=0,y=d.length;x0&&p===!1&&(f=u)}let g;for(let p=0,v=d.length;p{console.warn(y)}))},navigator.xr.offerSession!==void 0&&navigator.xr.offerSession("immersive-vr",T).then(b).catch(y=>{console.warn(y)})}function a(){s.style.display="",s.style.cursor="auto",s.style.left="calc(50% - 75px)",s.style.width="150px",s.onmouseenter=null,s.onmouseleave=null,s.onclick=null}function i(){a(),s.textContent="VR NOT SUPPORTED"}function h(n){a(),console.warn("Exception when trying to call xr.isSessionSupported",n),s.textContent="VR NOT ALLOWED"}function l(n){n.style.position="absolute",n.style.bottom="20px",n.style.padding="12px 6px",n.style.border="1px solid #fff",n.style.borderRadius="4px",n.style.background="rgba(0,0,0,0.1)",n.style.color="#fff",n.style.font="normal 13px sans-serif",n.style.textAlign="center",n.style.opacity="0.5",n.style.outline="none",n.style.zIndex="999"}if("xr"in navigator)return s.id="VRButton",s.style.display="none",l(s),navigator.xr.isSessionSupported("immersive-vr").then(function(n){n?r():i(),n&&g.xrSessionIsGranted&&s.click()}).catch(h),s;{const n=document.createElement("a");return window.isSecureContext===!1?(n.href=document.location.href.replace(/^http:/,"https:"),n.innerHTML="WEBXR NEEDS HTTPS"):(n.href="https://immersiveweb.dev/",n.innerHTML="WEBXR NOT AVAILABLE"),n.style.left="calc(50% - 90px)",n.style.width="180px",n.style.textDecoration="none",l(n),n}}static registerSessionGrantedListener(){if(typeof navigator<"u"&&"xr"in navigator){if(/WebXRViewer\//i.test(navigator.userAgent))return;navigator.xr.addEventListener("sessiongranted",()=>{g.xrSessionIsGranted=!0})}}}g.xrSessionIsGranted=!1;g.registerSessionGrantedListener();const u={Handedness:Object.freeze({NONE:"none",LEFT:"left",RIGHT:"right"}),ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ComponentType:Object.freeze({TRIGGER:"trigger",SQUEEZE:"squeeze",TOUCHPAD:"touchpad",THUMBSTICK:"thumbstick",BUTTON:"button"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};async function U(o){const e=await fetch(o);if(e.ok)return e.json();throw new Error(e.statusText)}async function re(o){if(!o)throw new Error("No basePath supplied");return await U(`${o}/profilesList.json`)}async function le(o,e,t=null,s=!0){if(!o)throw new Error("No xrInputSource supplied");if(!e)throw new Error("No basePath supplied");const r=await re(e);let a;if(o.profiles.some(l=>{const n=r[l];return n&&(a={profileId:l,profilePath:`${e}/${n.path}`,deprecated:!!n.deprecated}),!!a}),!a){if(!t)throw new Error("No matching profile name found");const l=r[t];if(!l)throw new Error(`No matching profile name found and default profile "${t}" missing.`);a={profileId:t,profilePath:`${e}/${l.path}`,deprecated:!!l.deprecated}}const i=await U(a.profilePath);let h;if(s){let l;if(o.handedness==="any"?l=i.layouts[Object.keys(i.layouts)[0]]:l=i.layouts[o.handedness],!l)throw new Error(`No matching handedness, ${o.handedness}, in profile ${a.profileId}`);l.assetPath&&(h=a.profilePath.replace("profile.json",l.assetPath))}return{profile:i,assetPath:h}}const de={xAxis:0,yAxis:0,button:0,state:u.ComponentState.DEFAULT};function ue(o=0,e=0){let t=o,s=e;if(Math.sqrt(o*o+e*e)>1){const i=Math.atan2(e,o);t=Math.cos(i),s=Math.sin(i)}return{normalizedXAxis:t*.5+.5,normalizedYAxis:s*.5+.5}}class ce{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===u.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(de)}updateFromComponent({xAxis:e,yAxis:t,button:s,state:r}){const{normalizedXAxis:a,normalizedYAxis:i}=ue(e,t);switch(this.componentProperty){case u.ComponentProperty.X_AXIS:this.value=this.states.includes(r)?a:.5;break;case u.ComponentProperty.Y_AXIS:this.value=this.states.includes(r)?i:.5;break;case u.ComponentProperty.BUTTON:this.value=this.states.includes(r)?s:0;break;case u.ComponentProperty.STATE:this.valueNodeProperty===u.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(r):this.value=this.states.includes(r)?1:0;break;default:throw new Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}}class he{constructor(e,t){if(!e||!t||!t.visualResponses||!t.gamepadIndices||Object.keys(t.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach(s=>{const r=new ce(t.visualResponses[s]);this.visualResponses[s]=r}),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:u.ComponentState.DEFAULT,button:this.gamepadIndices.button!==void 0?0:void 0,xAxis:this.gamepadIndices.xAxis!==void 0?0:void 0,yAxis:this.gamepadIndices.yAxis!==void 0?0:void 0}}get data(){return{id:this.id,...this.values}}updateFromGamepad(e){if(this.values.state=u.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&e.buttons.length>this.gamepadIndices.button){const t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||this.values.button===1?this.values.state=u.ComponentState.PRESSED:(t.touched||this.values.button>u.ButtonTouchThreshold)&&(this.values.state=u.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===u.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>u.AxisTouchThreshold&&(this.values.state=u.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===u.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>u.AxisTouchThreshold&&(this.values.state=u.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(t=>{t.updateFromComponent(this.values)})}}class pe{constructor(e,t,s){if(!e)throw new Error("No xrInputSource supplied");if(!t)throw new Error("No profile supplied");this.xrInputSource=e,this.assetUrl=s,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(r=>{const a=this.layoutDescription.components[r];this.components[r]=new he(r,a)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){const e=[];return Object.values(this.components).forEach(t=>{e.push(t.data)}),e}updateFromGamepad(){Object.values(this.components).forEach(e=>{e.updateFromGamepad(this.xrInputSource.gamepad)})}}const fe="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",me="generic-trigger";class xe extends k{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e?this:(this.envMap=e,this.traverse(t=>{t.isMesh&&(t.material.envMap=this.envMap,t.material.needsUpdate=!0)}),this)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach(t=>{Object.values(t.visualResponses).forEach(s=>{const{valueNode:r,minNode:a,maxNode:i,value:h,valueNodeProperty:l}=s;r&&(l===u.VisualResponseProperty.VISIBILITY?r.visible=h:l===u.VisualResponseProperty.TRANSFORM&&(r.quaternion.slerpQuaternions(a.quaternion,i.quaternion,h),r.position.lerpVectors(a.position,i.position,h)))})}))}}function ye(o,e){Object.values(o.components).forEach(t=>{const{type:s,touchPointNodeName:r,visualResponses:a}=t;if(s===u.ComponentType.TOUCHPAD)if(t.touchPointNode=e.getObjectByName(r),t.touchPointNode){const i=new H(.001),h=new R({color:255}),l=new O(i,h);t.touchPointNode.add(l)}else console.warn(`Could not find touch dot, ${t.touchPointNodeName}, in touchpad component ${t.id}`);Object.values(a).forEach(i=>{const{valueNodeName:h,minNodeName:l,maxNodeName:n,valueNodeProperty:b}=i;if(b===u.VisualResponseProperty.TRANSFORM){if(i.minNode=e.getObjectByName(l),i.maxNode=e.getObjectByName(n),!i.minNode){console.warn(`Could not find ${l} in the model`);return}if(!i.maxNode){console.warn(`Could not find ${n} in the model`);return}}i.valueNode=e.getObjectByName(h),i.valueNode||console.warn(`Could not find ${h} in the model`)})})}function B(o,e){ye(o.motionController,e),o.envMap&&e.traverse(t=>{t.isMesh&&(t.material.envMap=o.envMap,t.material.needsUpdate=!0)}),o.add(e)}class ve{constructor(e=null,t=null){this.gltfLoader=e,this.path=fe,this._assetCache={},this.onLoad=t,this.gltfLoader||(this.gltfLoader=new ie)}setPath(e){return this.path=e,this}createControllerModel(e){const t=new xe;let s=null;return e.addEventListener("connected",r=>{const a=r.data;a.targetRayMode!=="tracked-pointer"||!a.gamepad||le(a,this.path,me).then(({profile:i,assetPath:h})=>{t.motionController=new pe(a,i,h);const l=this._assetCache[t.motionController.assetUrl];if(l)s=l.scene.clone(),B(t,s),this.onLoad&&this.onLoad(s);else{if(!this.gltfLoader)throw new Error("GLTFLoader not set.");this.gltfLoader.setPath(""),this.gltfLoader.load(t.motionController.assetUrl,n=>{this._assetCache[t.motionController.assetUrl]=n,s=n.scene.clone(),B(t,s),this.onLoad&&this.onLoad(s)},null,()=>{throw new Error(`Asset ${t.motionController.assetUrl} missing or malformed.`)})}}).catch(i=>{console.warn(i)})}),e.addEventListener("disconnected",()=>{t.motionController=null,t.remove(s),s=null}),t}}let p,v,c,d,m,L,P,w,N,V,f,A,x,C,E=null;const S=[],we=new G(0,1,0),z={displayGrid:!0};ge();function ge(){v=new W,c=new D({antialias:!0}),c.setPixelRatio(window.devicePixelRatio),c.setSize(window.innerWidth,window.innerHeight),c.setClearColor(12303291),c.xr.enabled=!0,document.body.appendChild(c.domElement),c.domElement.tabIndex=1,c.setAnimationLoop(Ee),m=new M,v.add(m),w=new $(10,10,16777215,16777215),w.material.transparent=!0,w.material.opacity=.5,w.material.depthWrite=!1,m.add(w),p=new X(60,window.innerWidth/window.innerHeight,.1,4e3),p.position.set(0,1,0),m.add(p);const o=new _(16777215);o.position.set(1,2,3),v.add(o);const e=new q(16777215,.2);v.add(e),L=new te,P=new se,A=new M,A.rotation.x=Math.PI/2,A.position.y=32,v.add(A),d=new ae("https://raw.githubusercontent.com/NASA-AMMOS/3DTilesSampleData/master/msl-dingo-gap/0528_0260184_to_s64o256_colorize/scene-tileset.json"),A.add(d.group),d.setCamera(p),d.setResolutionFromRenderer(p,c);const t=i=>{S.push(i)};d.downloadQueue.schedulingCallback=t,d.parseQueue.schedulingCallback=t,d.lruCache.maxSize=1200,d.lruCache.minSize=900,N=new oe,V=new G(0,0,1);const s=new R({color:11722715});f=new O(new Y(1.5,.2,16,100),s),f.visible=!1,v.add(f),document.body.appendChild(g.createButton(c)),x=c.xr.getController(0),x.addEventListener("selectstart",()=>{f.visible&&m.position.copy(f.position)}),x.addEventListener("connected",function(i){this.controllerActive=!0,this.add(be(i.data))}),x.addEventListener("disconnected",function(){this.controllerActive=!1,this.remove(this.children[0])}),m.add(x);const r=new ve;C=c.xr.getControllerGrip(0),C.add(r.createControllerModel(C)),m.add(C),j(),window.addEventListener("resize",j,!1);const a=new ne;a.width=300,a.add(z,"displayGrid"),a.open()}function be(o){let e,t;switch(o.targetRayMode){case"tracked-pointer":return e=new J,e.setAttribute("position",new F([0,0,0,0,0,-1],3)),e.setAttribute("color",new F([.5,.5,.5,0,0,0],3)),t=new K({vertexColors:!0,blending:Z,depthWrite:!1,transparent:!0}),new ee(e,t);case"gaze":return e=new Q(.02,.04,32).translate(0,0,-1),t=new R({opacity:.5,transparent:!0}),new O(e,t)}}function j(){p.updateProjectionMatrix(),c.setPixelRatio(window.devicePixelRatio),c.setSize(window.innerWidth,window.innerHeight),p.aspect=window.innerWidth/window.innerHeight,p.updateProjectionMatrix()}function Ae(){if(c.xr.isPresenting){if(E===null){const o=c.xr.getCamera(p);d.cameras.forEach(t=>d.deleteCamera(t)),d.setCamera(o);const e=o.cameras[0];e&&d.setResolution(o,e.viewport.z,e.viewport.w),E=c.xr.getSession()}}else E!==null&&(d.cameras.forEach(o=>d.deleteCamera(o)),d.setCamera(p),d.setResolutionFromRenderer(p,c),p.position.set(0,1,0),E=null)}function Ce(){for(let o=0,e=S.length;o + + + + + + 3D Tiles Renderer Batch Example + + + + + + + + + + + +
+ + diff --git a/example/bundle/cmptExample.html b/example/bundle/cmptExample.html new file mode 100644 index 000000000..ac9df5bcd --- /dev/null +++ b/example/bundle/cmptExample.html @@ -0,0 +1,39 @@ + + + + + + + 3D Tiles Renderer Composite Format Example + + + + + + + + + + + + + + + + diff --git a/example/bundle/customMaterial.html b/example/bundle/customMaterial.html new file mode 100644 index 000000000..8f0486285 --- /dev/null +++ b/example/bundle/customMaterial.html @@ -0,0 +1,43 @@ + + + + + + + 3D Tiles Renderer Material Example + + + + + + + + + + + + + + + + + + + + diff --git a/example/bundle/ellipsoid.html b/example/bundle/ellipsoid.html new file mode 100644 index 000000000..423ae04b4 --- /dev/null +++ b/example/bundle/ellipsoid.html @@ -0,0 +1,44 @@ + + + + + + + 3D Tiles Renderer Batch Example + + + + + + + + + +
+ + diff --git a/example/bundle/fadingTiles.html b/example/bundle/fadingTiles.html new file mode 100644 index 000000000..72a18de21 --- /dev/null +++ b/example/bundle/fadingTiles.html @@ -0,0 +1,66 @@ + + + + + + + Dither Fade Tiles + + + + + + + + + + + + + + + + + + + +
+ Demonstration of tiles using a dither fade to change, smoothing out the transition. +
+ + diff --git a/example/bundle/gltf.html b/example/bundle/gltf.html new file mode 100644 index 000000000..f3c247c0b --- /dev/null +++ b/example/bundle/gltf.html @@ -0,0 +1,36 @@ + + + + + + + 3D Tiles Renderer 3DTILES_content_gltf Example + + + + + + + + + + + + + diff --git a/example/bundle/googleMapsAerial.html b/example/bundle/googleMapsAerial.html new file mode 100644 index 000000000..f49f80ec6 --- /dev/null +++ b/example/bundle/googleMapsAerial.html @@ -0,0 +1,83 @@ + + + + + + + Google 3D Tiles Example + + + + + + + + + + + + + + + + + + + + + +
+
+ Example using Googles Photorealistic 3D Tiles - Tokyo Tower +
+ Google Cloud Tiles API key required +
+
+
+
+ + diff --git a/example/bundle/googleMapsExample.html b/example/bundle/googleMapsExample.html new file mode 100644 index 000000000..6485d491b --- /dev/null +++ b/example/bundle/googleMapsExample.html @@ -0,0 +1,87 @@ + + + + + + + Google 3D Tiles Example + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ Example using Googles Photorealistic 3D Tiles - Globe +
+ Google Cloud Tiles API key required +
+
+
+
+ + diff --git a/example/bundle/i3dmExample.html b/example/bundle/i3dmExample.html new file mode 100644 index 000000000..bc018620f --- /dev/null +++ b/example/bundle/i3dmExample.html @@ -0,0 +1,36 @@ + + + + + + + 3D Tiles Renderer Instanced Example + + + + + + + + + + + + + diff --git a/example/bundle/index.html b/example/bundle/index.html new file mode 100644 index 000000000..a384724c0 --- /dev/null +++ b/example/bundle/index.html @@ -0,0 +1,46 @@ + + + + + + + 3D Tiles Renderer Options Example + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/bundle/ionExample.html b/example/bundle/ionExample.html new file mode 100644 index 000000000..3ead00628 --- /dev/null +++ b/example/bundle/ionExample.html @@ -0,0 +1,68 @@ + + + + + + + 3D Tiles Renderer Cesium Ion Integration Example + + + + + + + + + + + + + + + + + + + + +
+
+ Paste the evaluation Cesium Ion token from the Cesium repository or your own token and asset id
into the fields and press "reload" to see the demo. See cesium.com for more information. +
+
+
+ + diff --git a/example/bundle/ionLunar.html b/example/bundle/ionLunar.html new file mode 100644 index 000000000..cd9d5a5d2 --- /dev/null +++ b/example/bundle/ionLunar.html @@ -0,0 +1,70 @@ + + + + + + + Cesium Ion Lunar Data Set + + + + + + + + + + + + + + + + + + + + + + +
+
+ Paste the evaluation Cesium Ion token from the Cesium repository or your own token and asset id
into the fields and press "reload" to see the demo. See cesium.com for more information. +
+
+
+ + diff --git a/example/bundle/landformSiteOverlay.html b/example/bundle/landformSiteOverlay.html new file mode 100644 index 000000000..bb163fe91 --- /dev/null +++ b/example/bundle/landformSiteOverlay.html @@ -0,0 +1,66 @@ + + + + + + + Landform Drive 1004 Drive Tile Sets + + + + + + + + + + + + + + + + + +
+ Set of tiles from M20 Drive 1004 generated using NASA JPL's Landform with generated slope magnitude overlay. +
+ See information on this tile sets generation here. +
+ + diff --git a/example/bundle/mars.html b/example/bundle/mars.html new file mode 100644 index 000000000..5c50c1ca7 --- /dev/null +++ b/example/bundle/mars.html @@ -0,0 +1,68 @@ + + + + + + + Dingo Gap Tile Set + + + + + + + + + + + + + + + + + + + +
+ Dingo Gap site reconstructed from multiple sols of Curiosity Rover and Mars Reconnaissance Orbiter images. +
+ See more information here. +
+ + diff --git a/example/bundle/metadata.html b/example/bundle/metadata.html new file mode 100644 index 000000000..1c0632c0f --- /dev/null +++ b/example/bundle/metadata.html @@ -0,0 +1,96 @@ + + + + + + + 3D Tiles Renderer Metadata Example + + + + + + + + + + + + + + + + + + + +
+
+ Demonstration of displaying glTF Mesh Features and +
+ Structural Metadata properties on mouse-over. +
+ See Cesium repo for demo API key.
+
+
+
+ + diff --git a/example/bundle/offscreenShadows.html b/example/bundle/offscreenShadows.html new file mode 100644 index 000000000..67525f9e9 --- /dev/null +++ b/example/bundle/offscreenShadows.html @@ -0,0 +1,43 @@ + + + + + + + 3D Tiles Renderer Material Example + + + + + + + + + + + + + + + + + + + + diff --git a/example/bundle/pntsExample.html b/example/bundle/pntsExample.html new file mode 100644 index 000000000..533e7c224 --- /dev/null +++ b/example/bundle/pntsExample.html @@ -0,0 +1,35 @@ + + + + + + + 3D Tiles Renderer Points Example + + + + + + + + + + + + diff --git a/example/bundle/vr.html b/example/bundle/vr.html new file mode 100644 index 000000000..89a766d4a --- /dev/null +++ b/example/bundle/vr.html @@ -0,0 +1,40 @@ + + + + + + + 3D Tiles Renderer VR Example + + + + + + + + + + + + + + + + + +