diff --git a/docs/Controls.js b/docs/Controls.js index 8d1fa913..cf66cb72 100644 --- a/docs/Controls.js +++ b/docs/Controls.js @@ -1 +1 @@ -import{bc as i,bi as e,ae as t,bg as c,c as r}from"./vendor.js";var a=new WeakSet;class l{constructor(c){var{clickables:r,clickableChildren:l=!1,engine:s}=c;i(this,a),this.clickables=r,this.clickNodes=r.map((i=>i.node)),this.clickableChildren=l,this.engine=s,this.rotationMatrix=new e,this.raycaster=new t,this.click=this.click.bind(this),this.select=this.select.bind(this)}click(i){var{clickables:e,clickableChildren:t,clickNodes:r}=this;if(!0===e)c(this,a,s).call(this);else{var{raycaster:l}=this,{camera:n,renderer:o}=this.engine,h=i.clientX/o.domElement.clientWidth*2-1,d=-i.clientY/o.domElement.clientHeight*2+1;l.setFromCamera({x:h,y:d},n);var b=l.intersectObjects(r,t);c(this,a,s).call(this,b)}}select(){var i=this;return r((function*(){var{clickables:e,clickableChildren:t,clickNodes:r}=i;if(!0===e)yield c(i,a,s).call(i);else{var{raycaster:l,rotationMatrix:n}=i,{controller:o}=i.engine;n.extractRotation(o.matrixWorld),l.ray.origin.setFromMatrixPosition(o.matrixWorld),l.ray.direction.set(0,0,-1).applyMatrix4(n);var h=l.intersectObjects(r,t);yield c(i,a,s).call(i,h)}}))()}}function s(){return n.apply(this,arguments)}function n(){return n=r((function*(){var i=[];return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach((e=>{var{object:t}=e,c=this.clickables.find((i=>i.node.name===t.name));c&&i.push(c)})),yield this.engine.onTouch(i),i})),n.apply(this,arguments)}export{l as Controls}; +import{bc as e,bj as i,ae as t,bh as c,c as r}from"./vendor.js";var a=new WeakSet;class l{constructor(c){var{clickables:r,clickableChildren:l=!1,engine:s}=c;e(this,a),this.clickables=r,this.clickNodes=r.map((e=>e.node)),this.clickableChildren=l,this.engine=s,this.rotationMatrix=new i,this.raycaster=new t,this.click=this.click.bind(this),this.select=this.select.bind(this)}click(e){var{clickables:i,clickableChildren:t,clickNodes:r}=this;if(!0===i)c(this,a,s).call(this);else{var{raycaster:l}=this,{camera:n,renderer:o}=this.engine,h=e.clientX/o.domElement.clientWidth*2-1,d=-e.clientY/o.domElement.clientHeight*2+1;l.setFromCamera({x:h,y:d},n);var b=l.intersectObjects(r,t);c(this,a,s).call(this,b)}}select(){var e=this;return r((function*(){var{clickables:i,clickableChildren:t,clickNodes:r}=e;if(!0===i)yield c(e,a,s).call(e);else{var{raycaster:l,rotationMatrix:n}=e,{controller:o}=e.engine;n.extractRotation(o.matrixWorld),l.ray.origin.setFromMatrixPosition(o.matrixWorld),l.ray.direction.set(0,0,-1).applyMatrix4(n);var h=l.intersectObjects(r,t);yield c(e,a,s).call(e,h)}}))()}}function s(){return n.apply(this,arguments)}function n(){return n=r((function*(){var e=[];return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach((i=>{var{object:t}=i,c=this.clickables.find((e=>e.node.name===t.name));c&&e.push(c)})),yield this.engine.onTouch(e),e})),n.apply(this,arguments)}export{l as Controls}; diff --git a/docs/Controls.js.gz b/docs/Controls.js.gz index 3c856ab3..6823ffc0 100644 Binary files a/docs/Controls.js.gz and b/docs/Controls.js.gz differ diff --git a/docs/Preload.js b/docs/Preload.js index 6d4d7352..9dfe5417 100644 --- a/docs/Preload.js +++ b/docs/Preload.js @@ -1 +1 @@ -import{$ as e,av as t,aw as a,ax as i,c as n,ay as r,az as o,aA as s,aj as l,aB as d,aC as c,aD as h,W as m,aE as u,aF as f,aG as p,aH as v,aI as g,aJ as w,aK as y,a2 as b,a as S,v as T,aL as C,aM as E,x,aN as P,C as j,_ as A,a8 as k,D as O,A as R,aO as _,w as L,aP as B,Y as I,y as F,aQ as D,ac as W,aR as N,a0 as H,aS as V,aT as U,aU as z,aV as X,aW as q,a1 as G,V as K,ab as Y,aa as Z,a9 as $,aX as J,aY as Q,aZ as ee,a_ as te,a$ as ae,b0 as ie,G as ne,b1 as re,b2 as oe,Z as se,b3 as le,b4 as de,b5 as ce,b6 as he,am as me,b7 as ue,r as fe,b8 as pe,b9 as ve,ba as ge}from"./vendor.js";class we{constructor(n){var{scene:r,sceneInstance:o,renderer:s,endSession:l}=n;this.endSession=l,this.engine=n,this.gui=e("#".concat(t)),this.hitSearch=e("#hud-searching-hittest"),this.spawnButton=e("#hud-spawn-artifact"),this.scene=r,this.renderer=s,this.sceneInstance=o,e.on("#".concat(a),"click",this.onExitButtonClick.bind(this)),i(this),this.animToggler=e("#toggle-animation-button")}setCamera(t){this.cameraAccess=t,t?e.show(this.recordVideoButton):e.hide(this.recordVideoButton)}showAnimToggler(t){this.animToggler&&(this.animToggler.classList.remove("play"),e.show(this.animToggler),this.animTogglerInit||(this.animTogglerInit=!0,this.eventListener=()=>{this.animToggler.classList.toggle("play"),t()},e.on(this.animToggler,"click",this.eventListener)))}hideAnimToggler(){e.hide(this.animToggler)}show(){e.show(this.gui)}hide(){e.hide(this.gui)}onExitButtonClick(){var t=this;return n((function*(){t.engine.endSession(),e.off(t.animToggler,"click",t.eventListener),r()}))()}showHitSearch(){e.show(this.hitSearch)}hideHitSearch(){e.hide(this.hitSearch)}showSpawnButton(){e.show(this.spawnButton)}hideSpawnButton(){e.hide(this.spawnButton)}showElement(t){t.shown||(e.show(t),t.shown=!0)}hideElement(t){t.shown&&(e.hide(t),t.shown=!1)}}var{SCENE_TYPES:ye}=m.APP_DB;class be{constructor(e){var{artifact:t,preload:a,XR:i}=e;this.XR=i,this.artifact=t,this.preload=a;var{type:n=ye.Hit}=t;this.type=n,this.clock=new o,this.scene=new s,this.customMaterials=[],this.spatials=[],this.spatialObjects=[],this.lookAtCameraObjects=[],this.animateObjects=[],this.audioAnalysers=[],this.audioAnalyserEmissionConfigs=[],this.objects={},this.circlingLights=[],this.customObjects=[],this.videoTargets=[],this.animationListeners=[],this.materialFadeAnimations=[],this.eventsToRemove=[],this.renderSteps=[],this.unspawnObjects=[],this.animations=[],this.randomAudioElements=[],this.onResize=this.onResize.bind(this),this.render=this.render.bind(this),this.initFallbackSession=this.initFallbackSession.bind(this),this.toggleAnimations=this.toggleAnimations.bind(this),this.endSession=this.endSession.bind(this),this.onAddArtifact=this.onAddArtifact.bind(this)}init(t){var a=this;return n((function*(){var i,{artifact:r,preload:o,scene:s,type:w,XR:y}=a;t&&(a.sceneInstance=t);var{fov:b,near:S,far:T}=l(r.cam,d),C=m.innerWidth/m.innerHeight;a.camera=new c(b,C,S,T),a.camera.updateProjectionMatrix(),s.add(a.camera);var E=new h({antialias:!0,alpha:!0});a.renderer=E,E.setPixelRatio(m.devicePixelRatio),E.setSize(m.innerWidth,m.innerHeight),E.domElement.id=u,E.useLegacyLights=!1,E.toneMapping=f;var{audio:x,audioElements:P,circlingLights:j,clickables:A,customMaterials:k,customObjects:O,fog:R,fogexp2:M,hideLight:_,ocean:L,particles:B,shadow:I,triggerVideo:F,underwater:D,wireframes:W,record3d:N,record3DImages:H,renderTargets:V,noShadowObjects:U,receiveNoShadowObjects:z,castNoShadowObjects:X,ws:q}=r;!1!==I&&(E.shadowMap.enabled=!0,E.shadowMap.type=p),a.hud=new we(a);var G=null===(i=a.artifact.animateObjects)||void 0===i?void 0:i.some((e=>e.sound));if((x||null!=P&&P.length||G)&&a.addAudio(),a.addSkybox(),_||a.addLights(),(R||M)&&a.addFog(),q&&a.sceneInstance){var{host:K,port:Y,protocol:Z}=q,$={host:K,port:Y,protocol:Z,scene:t};a.ws=new o.assets.WS($)}if(a.videoElement=o.assets.videoElement,null!=t&&t.init&&(console.warn("`CustomScene.init` is deprecated","and will be removed in a future version. use `CustomScene.beforeLoadModel` instead."),yield t.init({engine:a,preload:o})),N&&r.type!==ye.FakeMirror&&!N.doNotInit){var J=a.videoElement,Q={artifact:r,engine:a,preload:o,videoElement:J},ee=new o.assets.Record3D(Q);a.record3d=ee,ee.model&&(a.model=ee.model),ee.child&&(a.child=ee.child),a.parentName=ee.config.parentName,a.renderSteps.push(ee.tick)}if(H){var{Class:te,images:ae}=o.assets.Record3DImages,ie=new te({engine:a,images:ae,config:H});a.record3DImages=ie}if(null!=t&&t.beforeLoadModel&&t.beforeLoadModel({engine:a,preload:o}),yield a.loadModel(),null!=t&&t.afterLoadModel&&t.afterLoadModel({engine:a,preload:o}),a.artifact.showVideoTime&&(a.frameRateIndicator=e.create("div",{style:{position:"fixed",top:0,left:0,backgroundColor:"black",color:"white"},parent:"#hud"})),U&&U.forEach((e=>{var t=a.model.getObjectByName(e);t&&(t.receiveShadow=!1,t.castShadow=!1)})),z&&z.forEach((e=>{var t=a.model.getObjectByName(e);t&&(t.receiveShadow=!1)})),X&&X.forEach((e=>{var t=a.model.getObjectByName(e);t&&(t.castShadow=!1)})),V&&a.addRenderTargets(),null!=j&&j.length){var{CirclingLights:ne}=yield import("./vendor.js").then((function(e){return e.bn}));new ne(a)}if(k&&new o.assets.CustomMaterials(a),O&&(yield a.addCustomObjects()),W&&W.forEach((e=>{var t=a.model.getObjectByName(e.target);t&&t.material&&(t.material.wireframe=!0,e.transparent&&(t.material.transparent=!0,t.material.opacity=e.opacity))})),F&&(a.objects.videoTrigger=new o.assets.VideoTrigger(a)),D&&(yield a.addUnderwaterPlane()),L&&(a.objects.oceanPlane=new o.assets.OceanPlane({artifact:r,engine:a,preload:a.preload})),B&&(a.particles=new o.assets.Particles(a),yield a.particles.init()),E.setSize(m.innerWidth,m.innerHeight),e.append(E.domElement,"#".concat(v)),y)try{var re=E.xr.getController(0);a.controller=re;var{clickable:oe,shadow:se,shadowPlane:le}=r;if(!1!==se&&!1!==le&&a.addShadowPlane(),!a.isHittestScene())throw new Error("Unknown scene type ".concat(w));w!==ye.Float&&a.spawnReticle(),e.on(a.hud.spawnButton,"click",a.onAddArtifact),e.on(re,"select",a.onAddArtifact),oe||a.hud.hideAnimToggler(),s.add(re),a.initScene=n((function*(){var t=["hit-test","dom-overlay"];g&&t.push("anchors"),e.hide("#Locator");var i=yield m.NAV.xr.requestSession("immersive-ar",{requiredFeatures:t,domOverlay:{root:e("#hud")}});return a.refSpace=yield i.requestReferenceSpace("viewer"),a.localRefSpace=yield i.requestReferenceSpace("local"),a.renderer.xr.enabled=!0,a.renderer.xr.setReferenceSpaceType("local"),yield a.renderer.xr.setSession(i),i.initFallbackSession=a.initFallbackSession.bind(a),a.session=i,i}))}catch(e){a.initScene=a.initFallbackSession}else a.initScene=a.initFallbackSession;return null!=A&&A.length&&a.addClickables(),e.on(m,"resize",a.onResize),a.onResize(),E.setAnimationLoop(a.render),a}))()}onAddArtifact(){var e=this;return n((function*(){var{artifact:t,justUnspawned:a,modelSpawned:i}=e;if(!a){if(!i){yield e.spawnModel(!1)}t.clickable?e.hud.showAnimToggler(e.toggleAnimations):e.hud.hideAnimToggler()}}))()}onResize(){var{innerWidth:e,innerHeight:t}=m;this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.renderer.setSize(e,t)}addRenderTargets(){var{renderTargets:e}=this.artifact;this.renderTargets=[],e.forEach((e=>{var t=l(e,{height:512,width:512,options:{depthBuffer:!1,stencilBuffer:!1},off:[]}),a=[];t.off.length&&t.off.forEach((e=>{var t=this.model.getObjectByName(e);t&&a.push(t)})),this.renderTargets.push({height:t.height,width:t.width,off:a,object:new w(t.width,t.height,t.options)})}))}addLights(){var{directionalLightPosition:e=te.directionalPosition,directionalColor:t=te.directionalColor,directionalIntensity:a=te.directionalIntensity,ambientColor:i=te.ambientColor,ambientIntensity:n=te.ambientIntensity}=this.artifact,r=new y(t,a);r.position.set(...e),r.castShadow=!0,!1!==this.artifact.shadow&&(r.shadow.bias=-1e-4,r.shadow.mapSize.width=4096,r.shadow.mapSize.height=4096,r.shadow.camera.left=-70,r.shadow.camera.right=70,r.shadow.camera.top=70,r.shadow.camera.bottom=-70,r.shadow.camera.near=.1,r.shadow.camera.far=300),this.directionalLight=r,this.scene.add(r),this.ambientLight=new b(i,n),this.scene.add(this.ambientLight)}addCustomObjects(){var{artifact:e}=this,{customObjects:t}=e;t.forEach((e=>{var{config:t,object:a}=e,i=this.model.getObjectByName(t.target);i&&(a.child?i.add(a.child):a.model&&(i.parent.add(a.model),i.parent.remove(i)),this.customObjects.push({config:t,object:a}),S.fn(a.init)&&a.init({engine:this}))}))}addShadowPlane(){var e=new T(150,150,64,64),t=new C;t.opacity=E;var a=new x(e,t);a.receiveShadow=!0,a.lookAt(0,100,0),a.position.set(0,.01,0),this.shadowPlane=a}addPortal(){this.objects.portal=new this.preload.assets.Portal.Factory({engine:this,mergeConfig:l})}spawnReticle(){var e=new P(.15,.2,32).rotateX(-M.PI/2),t=new j;this.reticle=new x(e,t),this.reticle.matrixAutoUpdate=!1,this.reticle.visible=!1,this.scene.add(this.reticle)}onAnimationLoop(e,t){var a=e.action._clip.name;t.forEach((e=>{if(!this.materialFadeAnimations.includes((e=>e.action._clip.name===a))){var t=this.findEventTargets(e);this.materialFadeAnimations.push(A(A({},e),{},{targets:t}))}}))}onAnimationFinished(e,t){var a=e.action._clip.name;t.forEach((e=>{if(!this.materialFadeAnimations.includes((e=>e.action._clip.name===a))){var t=this.findEventTargets(e);this.materialFadeAnimations.push(A(A({},e),{},{targets:t}))}}))}glow(){var{glow:e}=this.artifact;this.model.traverse((t=>{if(k(t.name,"glow")){var a=S.bool(e)?238:e,i=new j({color:a,side:O,blending:R,transparent:!0});t.material=i}}))}addClickables(){var{artifact:t,controller:a,model:i,preload:n,renderer:r,XR:o}=this,{clickables:s=[],clickableChildren:l=!1}=t,d=[];if(!0===s?d.push(i):s.length&&i.traverse((e=>{s.forEach((t=>{if(S.str(t)&&(t={target:t}),_({node:e,search:t.target})){var a;t.node=e,t.hide&&(e.material.transparent=!0,e.material.opacity=0);var i=!0===t.audio?e.name:t.audio;if(null!==(a=n.assets.audioElements)&&void 0!==a&&a.length){var r=n.assets.audioElements.find((e=>{var{ele:t}=e;return t.dataset.name===i}));r&&(t.player=r.ele)}d.includes(t)||d.push(t)}}))})),d.length){var{Controls:c}=n.assets;this.controls=new c({clickableChildren:l,clickables:d,engine:this}),o?e.on(a,"select",this.controls.select,!1):e.on(r.domElement,"mousedown",this.controls.click,!1)}}onTouch(t){var a;null!==(a=this.sceneInstance)&&void 0!==a&&a.onTouch&&this.sceneInstance.onTouch(t),t.forEach(((t,a)=>{if(!(a+1>this.artifact.maxTouches)){var{emission:i,emissionIntensity:n=.2,link:r,player:o}=t;if(r&&(L?window.location.href=r:window.open(r,"_hacked")),o&&(o.loop?o.paused?o.play():(o.currentTime=0,o.pause()):(o.currentTime=0,o.play())),i){var s=t.node.name.split("_")[0],l=this.model.getObjectByName(s);if(!l)return void console.warn("node not found",s);("Group"===l.type?l.children:[l]).forEach((a=>{if(a){if(a.userData.origEmissive||(a.userData.origEmissive=a.material.emissive),a.userData.origEmissiveIntensity||(a.userData.origEmissiveIntensity=a.material.emissiveIntensity),o||console.warn("player not found",t.node.name),o)if(B.same(a.material.emissive,a.userData.origEmissive)){var r=new I(1,1,1);S.bool(i)?a.material.color&&(r=a.material.color):S.arr(i)&&(r=new I(...i)),a.material.emissive=r,a.material.emissiveIntensity=n,o.loop||e.on(o,"ended",(()=>{a.material.emissive=a.userData.origEmissive,a.material.emissiveIntensity=a.userData.origEmissiveIntensity}))}else o.loop&&(a.material.emissive=a.userData.origEmissive,a.material.emissiveIntensity=a.userData.origEmissiveIntensity)}else console.warn("node not found",s)}))}}}))}nosort(){this.renderer.sortObjects=!1}clip(){var{artifact:e,model:t}=this,{clipSide:a,clipInFallback:i}=e;t.traverse((e=>{if(k(e.name,"clip"))if(this.XR||!1!==i){var t=a||e.material.side;e.material=new j({color:"green",colorWrite:!1,side:t}),e.castShadow=!1,e.receiveShadow=!1,e.renderOrder=1}else e.visible=!1;else e.renderOrder=2}))}addUnderwaterPlane(){var e=this;return n((function*(){e.cameraPlane=new e.preload.assets.UnderwaterPlane({engine:e}),yield e.cameraPlane.preload(e)}))()}addSkybox(){var e=this;return n((function*(){var{artifact:t,preload:a,renderer:i,scene:n,XR:r}=e,o=ae,s=null==t?void 0:t.skySphere;S.arr(s)&&s.length&&(o=s);var l=new F(...o),d=a.assets.skybox,c=new j({map:d,side:D}),h=new x(l,c);if(h.rotation.y=W.degToRad(180),h.visible=!r,n.add(h),!1!==t.light&&!t.hideEnvironment){var m=new N(i);m.compileEquirectangularShader();var u=m.fromEquirectangular(d).texture;n.environment=u,u.dispose(),m.dispose()}e.skybox=h}))()}addAudio(){this.listener=new H,this.camera.add(this.listener)}addFog(){var{artifact:e,scene:t}=this,{fog:a,fogexp2:i}=e;if(a){var{color:n,near:r,far:o}=a;t.fog=new V(n,r,o)}if(i){var{color:s,density:l}=i;t.fog=new U(s,l)}}startMedia(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if(!this.isMediaPlaying){this.isMediaPlaying=!0;var{actions:t=[],artifact:a,preload:i}=this,{videoElement:n,audioElements:r=[]}=i.assets;a.triggerAudio||null!=r&&r.length&&r.forEach((t=>{var{config:a,ele:i}=t;a.autoplay?(e&&(i.currentTime=0),a.volume&&(S.fn(i.setVolume)?i.setVolume(a.volume):i.volume=a.volume),i.play()):a.random&&(a.interval=z(a.interval),this.randomAudioElements.push({ele:i,config:a}))})),n&&!a.triggerVideo&&(e&&(n.currentTime=0),n.play()),t.forEach((e=>e.play()))}}stopMedia(){var{preload:e,videoElement:t,actions:a=[],audioElements:i=[]}=this;t&&t.pause(),e.hls&&e.hls.destroy(),a&&a.length&&a.forEach((e=>e.stop())),i.forEach((e=>{var{ele:t}=e;return t.pause()})),this.isMediaPlaying=!1}toggleAnimations(){this.actions.forEach((e=>e.paused=!e.paused))}initFallbackSession(){var e=this;return n((function*(){var t;e.XR=!1,m.B.classList.add(X);var{camera:a,artifact:i,model:n,renderer:r}=e,{clickable:o}=i,{Controller:s}=e.preload.assets;s&&(e.controller=new s(a,r.domElement,i,e),e.controller.unspawn&&e.unspawnObjects.push(e.controller)),e.skybox.visible=!0,o?e.hud.showAnimToggler(e.toggleAnimations):e.hud.hideAnimToggler();var{cam:l={}}=i,d=ie,{x:c=d.x,y:h=d.y,z:u=d.z}=l;a.position.set(c,h,u);var{scale:f}=i;if(f&&n){var{x:p,y:v,z:g}=n.scale;S.num(f)&&n.scale.set(p*f,v*f,g*f)}null===(t=e.controller)||void 0===t||t.update();yield e.spawnModel(!0),r.domElement.focus()}))()}loadModel(){var e=this;return n((function*(){var t,a,i,{artifact:n,preload:r,sceneInstance:o={}}=e,{spatialObjects:s=[],audioElements:l=[]}=n;(e.spatials=[...s,...l],null!=o&&o.model&&(e.model&&e.model!==o.model?e.model.add(o.model):e.model||(e.model=o.model)),null!==(t=r.assets.gltf)&&void 0!==t&&t.scene)&&(e.model?e.model.add(null===(a=r.assets.gltf)||void 0===a?void 0:a.scene):e.model=null===(i=r.assets.gltf)||void 0===i?void 0:i.scene);if(n.ply&&r.assets.addPly(e),e.addAnimations(),e.model){var d,c;e.artifact.hideChildren&&e.artifact.hideChildren.forEach((t=>{var a=e.model.getObjectByName(t);a&&a.position.set(5e3,5e3,5e3)}));var h={},{parentName:m=o.parentName,child:u=o.child}=e;if(m&&u&&(c=e.model.getObjectByName(m),e.modelParent=c),e.model.traverse((t=>{if(e.customObjects.forEach((e=>{var{object:a}=e;a.parentName&&a.child&&k(t.name,a.parentName)&&(h[a.name]=t)})),t.isMesh){var{frustumCulled:a,transparent:i,castShadow:r,receiveShadow:o,noShadowObjects:s=[],noShadowCastObjects:l=[],noShadowReceiveObjects:d=[]}=n;(!1===a||null!=a&&a.includes(t.name))&&(t.frustumCulled=!1),!1===i&&(t.material.transparent=!1),k(t.name,"noshadow")||s.includes(t.name)||(k(t.name,"noshadowcast")||l.includes(t.name)||(t.castShadow=!1!==r),k(t.name,"noshadowreceive")||d.includes(t.name)||(t.receiveShadow=!1!==o)),k(t.name,"videotarget")&&e.videoTargets.push(t),t.material.map&&(t.material.map.anisotropy=16,t.material.map.colorSpace=q),t.material.emissiveMap&&(t.material.emissiveMap.colorSpace=q),(t.material.map||t.material.emissiveMap)&&(t.material.needsUpdate=!0)}var c=[];n.animateObjects&&n.animateObjects.forEach((a=>{if(k(t.name,a.name)){var i=e.actions.find((e=>e._clip.name===t.name));if(a.sound){!0===a.sound&&(a.sound={name:e.artifact.slug}),a.sound.name||(a.sound.name=e.artifact.slug);var n=e.preload.assets.animateObjects[a.sound.name];if(n){var r=new G(e.listener);r.setBuffer(n);var{loopSound:o=!0}=a;if(r.setLoop(o),a.audio=r,a.sound.distance){var s=!1!==a.sound.yDistanceTest;c.push({buffer:r,distance:a.sound.distance,distanceTarget:t.name,target:t.name,yDistanceTest:s})}}else console.error("animateObjects: Sound not found in preload.assets",a)}e.animateObjects.push(A(A({},a),{},{action:i,node:t}))}})),e.spatials=[...e.spatials,...c]})),e.spatials.length){var{SpatialObjects:f}=yield import("./vendor.js").then((function(e){return e.bo}));e.objects.spatialObjects=new f(e)}if(null!==(d=n.lookAtCameraObjects)&&void 0!==d&&d.length){var p=new r.assets.LookAtCamera(e);e.addRenderStep(p.render.bind(p))}if(c&&(o.child?c.add(o.child):e.child&&c.add(e.child)),e.customObjects.forEach((t=>{var{object:a}=t;a.child?h[a.name].add(a.child):a.model&&e.model.add(a.model)})),e.videoElement&&e.videoTargets.length){var v,{flipVideo:g,chromaKey:w}=n,y=new K(e.videoElement);!1!==g&&(y.flipY=!1);var{examples:b={}}=null===(v=e.preload)||void 0===v?void 0:v.assets,{ChromaKeyMaterial:S=!1}=b;e.videoTargets.forEach((e=>{w?S&&(e.material=new S(w,y)):e.material.map=y}))}}var{clip:T,glow:C,portal:E,nosort:x,clones:P,clonesOnMeshes:j}=e.artifact;if(C&&e.glow(),E&&e.addPortal(),e.model&&T&&e.clip(),x&&e.nosort(),r.assets.Mirrors&&new r.assets.Mirrors(e),e.artifact.analyseAudio){var{AnalyseAudio:O}=yield import("./vendor.js").then((function(e){return e.bp})),R=new O(e);e.addRenderStep(R.render)}if(e.model){if(e.model.position.set(5e3,5e3,5e3),P){var{Clones:M}=yield import("./vendor.js").then((function(e){return e.bq}));e.clones=new M(e)}if(j){var{ClonesOnMeshes:_}=yield import("./vendor.js").then((function(e){return e.br}));e.meshClones=new _(e)}e.scene.add(e.model)}}))()}addAnimations(){var t,a,i;if(null!==(t=this.sceneInstance)&&void 0!==t&&null!==(t=t.animations)&&void 0!==t&&t.length&&this.animations.push(...this.sceneInstance.animations),null!==(a=this.preload.assets.gltf)&&void 0!==a&&null!==(a=a.animations)&&void 0!==a&&a.length&&this.animations.push(...this.preload.assets.gltf.animations),this.actions=[],null!==(i=this.animations)&&void 0!==i&&i.length){var n;this.mixer=new Y(this.model);var{animations:r={}}=this.artifact,{loop:o,startOnTouch:s,clampWhenFinished:l=!0,autoplay:d=!0,noLoopAnimations:c=[],pausedAnimations:h=[],timeScale:m=1}=r;if(this.animations.forEach((e=>{var t=this.mixer.clipAction(e),a=h.includes(e.name),i=s||!d||a;(!1===o||c.includes(e.name))&&(t.clampWhenFinished=l,t.loop=Z),i&&(t.paused=!0),S.num(m)?t.timeScale=m:S.obj(m)&&m.hasOwnProperty(t.name)&&(t.timeScale=m[t.name]),this.actions.push(t)})),null!==(n=this.artifact.events)&&void 0!==n&&n.animation){var{events:u}=this.artifact,{times:f=[],loop:p=[],finished:v=[]}=null==u?void 0:u.animation;if(p.length){var g=[this.mixer,"loop",e=>this.onAnimationLoop(e,p)];e.on(...g),g.targets=this.findEventTargets(p),this.eventsToRemove.push(g)}if(v.length){var w=[this.mixer,"finished",e=>this.onAnimationFinished(e,v)];e.on(...w),w.targets=this.findEventTargets(v),this.eventsToRemove.push(w)}if(f.length){var{times:y}=this.artifact.events.animation;y.length&&y.forEach((e=>{var{action:t,once:a=!1}=e,i=$.findByName(this.animations,t),n=this.findEventTargets(e);this.animationListeners.push(A(A({},e),{},{once:a,action:i,targets:n}))}))}}}}findEventTargets(e){var t=[];return this.model.traverse((a=>{_({node:a,search:e.targets})&&(a.material&&(t.includes(a.material)||t.push(a.material)))})),t}spawnModel(e){var t=this;return n((function*(){var a,{artifact:i,camera:n,controller:r,model:o,reticle:s,scene:l,sceneInstance:d={},shadowPlane:c,type:h,XR:m}=t,{showSkybox:u,skyboxTransparency:f,floatSpawnAtZeroY:p=!1}=i;if(!m||e)o&&o.position.set(0,0,0),t.modelSpawned=!0;else if(t.isHittestScene()){if(!t.modelSpawned&&t.lastHit){s.updateMatrixWorld(),o.position.setFromMatrixPosition(s.matrixWorld),o.updateMatrixWorld();var v=n.position,g=o.position,w=v.x-g.x,y=v.z-g.z,b=Math.atan2(w,y);o.rotation.y=b,c&&(c.position.setFromMatrixPosition(s.matrixWorld),l.add(c)),o.visible=!0,s.visible=!1,t.modelSpawned=!0}}else if(h===ye.Float){var T=o.clone();T.position.set(0,0,-1).applyMatrix4(r.matrixWorld),p&&(T.position.y=0),l.add(T)}if(t.applyPositionAndRotation(),null!=d&&d.spawnModel&&(console.warn("W_DEPRECATED: sceneInstance.spawnModel is deprecated. Please use sceneInstance.afterSpawnModel instead."),d.spawnModel({engine:t})),null!=d&&d.afterSpawnModel&&d.afterSpawnModel({engine:t}),t.startMedia(),u&&(t.skybox.visible=!0,f&&(t.skybox.material.transparent=!0,t.skybox.material.opacity=f),t.skybox.receiveShadow=!1),null!==(a=t.preload.gui)&&void 0!==a&&a.afterSpawnModel){var{afterSpawnModel:C}=t.preload.gui;C.style.visibility="visible",C.style.opacity=1,setTimeout((()=>{var e;S.fn(null===(e=C.parentNode)||void 0===e?void 0:e.removeChild)&&C.parentNode.removeChild(C)}),8e3)}}))()}exitSceneInstance(){var t,a;this.modelSpawned&&(this.scene.remove(this.model),this.modelSpawned=!1,this.isAnimationRunning=!1,this.stopMedia(),this.justUnspawned=!0,null!==(a=this.eventsToRemove)&&void 0!==a&&a.length&&this.eventsToRemove.forEach((t=>{e.off(...t)})),this.unspawnObjects.forEach((e=>{null==e||e.unspawn(this)})),setTimeout((()=>{this.justUnspawned=!1}),200));this.customObjects.forEach((e=>{var{object:t}=e;S.fn(t.exit)&&t.exit({engine:this})})),this.customMaterials.forEach((e=>{var{material:t}=e;S.fn(t.exit)&&t.exit({engine:this})})),this.animateObjects.forEach((e=>{var t;null===(t=e.audio)||void 0===t||t.stop()})),null!==(t=this.sceneInstance)&&void 0!==t&&t.exit&&this.sceneInstance.exit({engine:this}),this.frameRateIndicator&&e.remove(this.frameRateIndicator)}applyPositionAndRotation(){var{artifact:e,model:t}=this;if(t){var{pos:a={},rot:i={}}=e,{x:n,y:r,z:o}=a;n&&(t.position.x+=n),r&&(t.position.y+=r),o&&(t.position.z+=o);var{x:s,y:l,z:d}=i,c=W.degToRad;s&&t.rotateX(c(s)),l&&t.rotateY(c(l)),d&&t.rotateZ(c(d))}}endSession(){var t,a;if(null===(t=this.session)||void 0===t||!t.ended){this.session&&(this.session.end(),this.session.ended=!0),this.hud.hide(),this.renderer.setAnimationLoop(null),e("#".concat(v)).classList.remove("visible"),this.exitSceneInstance(),this.scene&&J(this.scene),e.remove(".".concat(Q)),null!==(a=this.preload)&&void 0!==a&&a.hls&&(this.preload.hls.destroy(),e.remove(this.preload.hlsScript));var i=e("#".concat(u));if(i){var n=i.parentNode;n.id===v?e.remove(i):e.remove(n)}m.B.classList.remove(X),e(".start-experience-button").forEach((e=>{e.removeAttribute("disabled")})),L&&m.location.reload()}}isHittestScene(){return![ye.Float].includes(this.type)}addRenderStep(e){this.renderSteps.push(e)}render(e,t){var a=this;return n((function*(){var i,n,r,o,s,l,d=a.clock.getDelta();if(a.renderHittest(t),a.mixer)if(a.artifact.videoBoundAnimation&&a.videoElement){a.lastFrameVideoTime||(a.lastFrameVideoTime=a.videoElement.currentTime);var c=a.videoElement.currentTime-a.lastFrameVideoTime;c&&a.mixer.update(c),a.lastFrameVideoTime=a.videoElement.currentTime}else a.mixer.update(d);var h,m={delta:d,timestamp:e,engine:a,frame:t};if(a.modelSpawned){if(g&&a.XR){var u=t.getPose(a.anchor.anchorSpace,a.localRefSpace),{x:f,y:p,z:v}=u.transform.position;a.model.position.set(f,p,v);var{x:w,y:y,z:b,w:S}=u.transform.orientation;a.model.quaternion.set(w,y,b,S)}a.renderSteps.forEach((e=>{e(m)}))}(a.artifact.showVideoTime&&(a.frameRateIndicator.innerText="Videotime: ".concat(a.videoElement.currentTime)),null!==(i=a.sceneInstance)&&void 0!==i&&i.tick&&a.sceneInstance.tick(m),null!==(n=a.artifact.ply)&&void 0!==n&&n.animated&&a.renderPlyMorphTargetInfluences(m),null!==(r=a.animateObjects)&&void 0!==r&&r.length&&a.renderAnimateObjects(m),null!==(o=a.animationListeners)&&void 0!==o&&o.length&&a.renderAnimationTimeEvent(m),a.materialFadeAnimations.length&&a.renderMaterialAnimTick(m),null!==(s=a.randomAudioElements)&&void 0!==s&&s.length&&a.renderRandomAudio(m),a.particles&&a.particles.update(m),a.customObjects.length&&a.renderCustomObjects(m),null!==(l=a.sceneInstance)&&void 0!==l&&l.render?a.sceneInstance.render(m):a.renderer.render(a.scene,a.camera),a.controller)&&(null!==(h=a.controller)&&void 0!==h&&h.update&&a.controller.update(d))}))()}renderRenderTargets(e){var{renderTargets:t}=this;t.forEach((e=>{e.off.length&&e.off.forEach((e=>{e.visible=!1})),this.renderer.setRenderTarget(e.object),this.renderer.render(scene,camera),this.renderer.setRenderTarget(null),e.off.length&&e.off.forEach((e=>{e.visible=!0}))}))}renderPlyMorphTargetInfluences(e){var{delta:t,timestamp:a}=e;this.nextMorphTargetStep||(this.nextMorphTargetStep=a+this.morphTargetInfluenceConfig.delay);var i=this.animatedPoints,n=i.morphTargetInfluences.length-1,r=t*this.morphTargetInfluenceConfig.speed;i.morphTargetInfluences=i.morphTargetInfluences.map(((e,t)=>{if(t===this.morphTargetTargetIndex){var i=Math.min(e+r,1);return i>=1&&a>this.nextMorphTargetStep&&(this.nextMorphTargetStep=a+this.morphTargetInfluenceConfig.delay,this.hasRun=!this.hasRun,this.hasRun||(this.morphTargetTargetIndex+=1,this.morphTargetTargetIndex>n&&(this.morphTargetTargetIndex=0))),i}return Math.max(e-r,0)}))}renderCustomObjects(e){this.customObjects.forEach((t=>{var{object:a}=t;S.fn(a.tick)&&a.tick(e)}))}renderAnimateObjects(e){var{timestamp:t}=e;this.animateObjects.forEach((e=>{var{action:a,audio:i,speed:n,minSpeed:r=0,maxDelay:o=2,minDelay:s=1}=e;if(a&&a.paused&&(e.nextAnimation||(e.nextAnimation=t+Math.random()*(1e3*o)+1e3*s),i.isPlaying&&i.stop(),e.nextAnimation<=t)){e.nextAnimation=!1;var l=Math.random()>.5?1:-1,d=Math.max(r,Math.random()*n)*l;a.timeScale=d,a.paused=!1,a.play(),i&&!i.isPlaying&&i.play()}}))}renderHittest(t){var a=this;return n((function*(){if(a.modelSpawned)a.hud.hideSpawnButton();else if(t&&a.XR){var i=a.renderer.xr.getSession();a.hitTestSourceRequested||(a.hitTestSource=yield i.requestHitTestSource({space:a.refSpace}),e.on(i,"end",(()=>{a.hitTestSourceRequested=!1,a.hitTestSource=null})),a.hitTestSourceRequested=!0);var n=t.getHitTestResults(a.hitTestSource);if(n.length){if(a.lastHit=n[0],g&&(a.anchor=yield a.lastHit.createAnchor()),!a.modelSpawned){a.reticle.visible=!0,a.hud.showSpawnButton();var r=a.renderer.xr.getReferenceSpace();a.reticle.matrix.fromArray(a.lastHit.getPose(r).transform.matrix)}a.hud.hideHitSearch()}else a.reticle.visible=!1,a.modelSpawned||(a.hud.showHitSearch(),a.hud.hideSpawnButton()),a.lastHit=void 0}}))()}renderAnimationTimeEvent(){this.animationListeners.forEach((e=>{var{time:t,action:a,once:i}=e,{time:n}=a;!e.hasTriggered&&n>=t?(e.hasTriggered=!0,this.materialFadeAnimations.push(e)):n<=t&&(i||(e.hasTriggered=!1))}))}renderRandomAudio(e){var{timestamp:t}=e;this.modelSpawned&&this.randomAudioElements.forEach((e=>{var{ele:a,config:i}=e;if(a.paused&&(i.nextPlayTime||(i.nextPlayTime=t+ee(i.interval)),i.nextPlayTime<=t)){a.time=0,a.play();var n=ee(i.interval);i.nextPlayTime=t+n+1e3*a.duration}}))}renderMaterialAnimTick(e){var{delta:t}=e;this.materialFadeAnimations.forEach(((e,a)=>{if(e){var{targets:i=[],speed:n=1,to:r=0,props:o}=e;i.forEach((e=>{var i=S.arr(o)?o:[o],s=!0;i.map((a=>{var i=e[a]+n*t;n<0?i<=r?i=r:s=!1:n>0&&(i>=r?i=r:s=!1),e[a]=i})),s&&this.materialFadeAnimations.splice(a,1)}))}}))}}var Se=(e,t)=>S.arr(t)||S.str(t)?t.includes(e)||t===e:null==t?void 0:t.hasOwnProperty(e);class Te{constructor(t){var{artifact:a,root:i,THREE:n,XR:r=!0}=t;this.artifact=a,this.root=i,this.XR=!1===r?r:m.SUPPORTS.XR,n&&(this.THREE=n);var{android:o,chrome:s}=fe;this.isAndroidChrome=o&&s,this._warningContainer=e("#timeout-warning"),this._header=e("#timeout-warning-header"),this._headerDone=e("#timeout-warning-header-done"),this._preloadInfo=e("#timeout-warning-info"),this._cancelButton=e("#timeout-warning-cancel"),this._confirmButton=e("#timeout-warning-confirm"),this._tooFarContainer=e("#toofar-warning"),this._tooFarPreviewButton=e("#toofar-warning-load-preview-button"),this._tooFarDistanceInfo=e("#toofar-warning-distance"),this._tooFarCancelButton=e("#toofar-warning-cancel-button"),this._tooFarAbortButton=e("#toofar-warning-abort-button"),this._webglDisabledContainer=e("#timeout-warning-webgl-disabled"),this._webglDisabledOkButton=e("#timeout-warning-webgl-disabled-ok-button"),this.confirmButtonClickHandler=this.confirmButtonClickHandler.bind(this),e.on(this._confirmButton,"click",this.confirmButtonClickHandler),this.onTooFarCancelButtonClick=this.onTooFarCancelButtonClick.bind(this),this.onTooFarPreviewButtonClick=this.onTooFarPreviewButtonClick.bind(this),this.onWebglDisabledOkButtonClick=this.onWebglDisabledOkButtonClick.bind(this),this.promisifiedLoad=this.promisifiedLoad.bind(this),this.textureLoader=new ne,this.gltfLoader=new re,this.plyLoader=new oe,this.audioLoader=new se,this.fontLoader=new le,this.audioElements=[],this.collectPreloadPromises(),this.startEngine=this.startEngine.bind(this),this.onVideoCanPlayThrough=this.onVideoCanPlayThrough.bind(this)}collectPreloadPromises(){var{animateObjects:e,audio:t,audioElements:a,chromaKey:i,clickables:n=[],customMaterials:r,customObjects:o,fonts:s,glb:l,gui:d,mirrors:c,ply:h,textures:m,type:u,video:f,lookAtCameraObjects:p,ocean:v,particles:g,portal:w,record3d:y,record3DImages:b,triggerVideo:T,underwater:C,ws:E}=this.artifact,x={};if(x.skybox=this.loadSkybox(),(t||a)&&(x.audioElements=this.loadAudioElements()),T&&(x.VideoTrigger=this.loadVideoTrigger()),C&&(x.UnderwaterPlane=this.loadUnderwaterPlane()),g&&(x.Particles=this.loadParticles()),null!=c&&c.length&&(x.Mirrors=this.loadMirrors()),n.length&&(x.Controls=this.loadControls()),v&&(x.OceanPlane=this.loadOceanPlane(),x.waterNormals=this.loadWaterNormals()),de(u,APP_DB.SCENE_TYPES)||(x.scene=this.loadScene()),!1!==l&&(x.gltf=this.loadGltf()),h&&(x.ply=this.loadPly(),x.addPly=this.loadAddPly()),m&&(x.textures=this.loadTextures()),i){var P=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return S.str(t)&&(t=str.split(" ")),S.arr(t)?t.push(e):S.obj(t)&&(t[e]=!0),t}("ChromaKeyMaterial",this.artifact.examples);this.artifact.examples=P}if(w&&(x.Portal=this.loadPortal()),y&&(x.Record3D=this.loadRecord3D(),y.images&&(x.textures=this.loadRecord3DTextures(x.textures))),b&&(x.Record3DImages=this.loadRecord3DImages(b.images)),E&&(x.WS=this.loadWS()),f){var{slug:j,video:A}=this.artifact;x.videoElement=this.loadVideo({slug:j,video:A})}null!=p&&p.length&&(x.LookAtCamera=this.loadLookAtCamera()),s&&(x.fonts=this.loadFonts()),this.artifact.examples&&(x.examples=this.loadExamples()),d&&this.loadGui(),r&&(x.customMaterials=this.loadCustomMaterials(),x.CustomMaterials=this.loadCustomMaterialClasses()),o&&(x.customObjects=this.loadCustomObjects()),e&&(x.animateObjects=this.loadAnimateObjects()),this.XR||this.artifact.noControls||(x.Controller=this.loadController()),this.promises=x}init(){var t=this;return n((function*(){t._isWorking=!0,t._isCancelled=!1,t._session=!1,e.on(t._cancelButton,"click",(()=>{t._isCancelled=!0,t.finished()})),e.show([t._warningContainer,t._header]),t.timeout=m.setTimeout(t.showTimeoutWarning,ce),yield t.startEngine()}))()}loadScene(){var t=this;return n((function*(){var{artifact:a}=t,i=APP_DB.SCENE_TYPES,{type:n=i.Hit}=a,r=Object.entries(i).find((e=>{var[t,a]=e;return a===n})),o="".concat(t.root,"/CustomScene.js");if(S.arr(r)){var s=r[0];o="./scenes/".concat(s,".js")}var{default:d}=yield import(o),c=new d({artifact:a,mergeConfig:l,nodeNameIncludes:k,nodeNameMatchesWildcard:_,preload:t,$:e,W:m,is:S});return S.fn(null==c?void 0:c.preload)?yield c.preload({artifact:a,preload:t}):S.fn(null==c?void 0:c.load)&&(yield c.load({artifact:a,preload:t})),c}))()}loadWS(){return n((function*(){var{WS:e}=yield import("./WS.js");return e}))()}loadMirrors(){return n((function*(){var{Mirrors:e}=yield import("./vendor.js").then((function(e){return e.bs}));return e}))()}loadAddPly(){return n((function*(){var{addPly:e}=yield import("./vendor.js").then((function(e){return e.bt}));return e}))()}loadParticles(){return n((function*(){var{Particles:e}=yield import("./vendor.js").then((function(e){return e.bu}));return e}))()}loadLookAtCamera(){return n((function*(){var{LookAtCamera:e}=yield import("./vendor.js").then((function(e){return e.bv}));return e}))()}loadSkybox(){var e=this;return n((function*(){var{city:t,sky:a,slug:i}=e.artifact,n=a||i;he(n)||(n=["https://static.artificialmuseum.com","skybox",t,n].filter((e=>e)).join("/"));var r="jpg";return m.SUPPORTS.WEBP&&(r="webp"),n.endsWith(".".concat(r))||(n+=".".concat(r)),yield e.promisifiedLoad({loader:e.textureLoader,file:n})}))()}loadFonts(){var e=this;return n((function*(){var{fonts:t}=e.artifact,a={};return yield Promise.all(t.map(function(){var t=n((function*(t){var i="https://static.artificialmuseum.com/font/json/".concat(t,".typeface.json");a[t]=yield e.promisifiedLoad({loader:e.fontLoader,file:i})}));return function(e){return t.apply(this,arguments)}}())),a}))()}loadAnimateObjects(){var e=this;return n((function*(){var{animateObjects:t,slug:a}=e.artifact,i={},r=e.audioLoader;return yield Promise.all(t.map(function(){var t=n((function*(t){if(t.sound){var{sound:n={}}=t;if(!0===n&&(n={name:a}),n.name||(n.name=a),!i[n.name]){var o=".mp3";m.SUPPORTS.A_MP4?o=".mp4":m.SUPPORTS.A_OGG&&(o=".ogg");var s="https://media.artificialmuseum.com/audio/".concat(n.name).concat(o);i[n.name]=yield e.promisifiedLoad({loader:r,file:s})}}}));return function(e){return t.apply(this,arguments)}}())),i}))()}loadExamples(){var e=this;return n((function*(){var{examples:t}=e.artifact,a=[];Se("TextGeometry",t)&&a.push(["TextGeometry",import("./vendor.js").then((function(e){return e.bw}))]),Se("ChromaKeyMaterial",t)&&a.push(["ChromaKeyMaterial",import("./materials/ChromaKeyMaterial.js")]);var i=yield Promise.all(a.map(function(){var e=n((function*(e){var[t,a]=e,i=yield a,n=i[t]?i[t]:i.default;return n||console.error("E_MODULE_NOT_FOUND","module ".concat(t," could not be imported from examples, got:"),a),[t,n]}));return function(t){return e.apply(this,arguments)}}()));return Object.fromEntries(i)}))()}loadCustomMaterials(){var e=this;return n((function*(){var{artifact:t}=e,{customMaterials:a}=t;return Promise.all(a.map(function(){var a=n((function*(a){var i=a.name.endsWith("Material")?a.name:"".concat(a.name,"Material"),{default:n}=yield import("./materials/".concat(i,".js")),r=new n({artifact:t,config:a,preload:e});return S.fn(r.preload)?yield r.preload({artifact:t,config:a}):S.fn(r.load)&&(yield r.load({artifact:t,config:a})),{config:a,material:r}}));return function(e){return a.apply(this,arguments)}}()))}))()}loadCustomMaterialClasses(){return n((function*(){var{CustomMaterials:e}=yield import("./vendor.js").then((function(e){return e.bx}));return e}))()}loadCustomObjects(){var e=this;return n((function*(){var{artifact:t}=e,{customObjects:a}=t;return Promise.all(a.map(function(){var a=n((function*(a){var{default:i}=yield import("./objects/".concat(a.name,".js")),n=new i({artifact:t,config:a,preload:e});return S.fn(n.preload)&&(yield n.preload()),n}));return function(e){return a.apply(this,arguments)}}()))}))()}loadRecord3D(){return n((function*(){var{Record3D:e}=yield import("./vendor.js").then((function(e){return e.bm}));return e}))()}loadRecord3DImages(){var e=arguments,t=this;return n((function*(){var a=e.length>0&&void 0!==e[0]?e[0]:[],i=t.textureLoader,{Record3DImages:r}=yield import("./vendor.js").then((function(e){return e.by})),o=yield Promise.all(a.map(function(){var e=n((function*(e){var a="https://static.artificialmuseum.com/".concat(e.src,"?v=").concat(t.artifact.version),{position:n,quaternion:r,intrMat:o}=e;return{object:yield t.promisifiedLoad({loader:i,file:a}),position:n,quaternion:r,intrMat:o}}));return function(t){return e.apply(this,arguments)}}()));return{Class:r,images:o}}))()}loadRecord3DTextures(){var e=arguments,t=this;return n((function*(){var a=e.length>0&&void 0!==e[0]?e[0]:{},i=t.textureLoader;return yield Promise.all(t.artifact.record3d.images.map(function(){var e=n((function*(e){var n=e.file?e.file:e,r=n;he(r)||(r=["https://static.artificialmuseum.com","livedata",t.artifact.livedataCategory,r].filter((e=>e)).join("/"));var o=yield t.promisifiedLoad({loader:i,file:r});a[n]=o}));return function(t){return e.apply(this,arguments)}}())),a}))()}handlePlacardName(e){var{name:t,ext:a=".jpg",type:i,slug:n}=e;return(t=S.str(t)?t:n).endsWith("/")&&(t+=n),t.endsWith(".png")?(a=".png",t.slice(0,-4)):t.endsWith(".jpg")&&(a=".jpg",t.slice(0,-4)),a.startsWith(".")||(a=".".concat(a)),he(t)||(t="https://static.artificialmuseum.com/placards/".concat(t,"_").concat(i).concat(a)),t}loadPortal(){var e=this;return n((function*(){var{placardImage:t=!1,placardExtension:a=".jpg",load:i}=e.artifact.portal,{Portal:r}=yield import("./vendor.js").then((function(e){return e.bz})),o=[["Factory",r]];if(!1!==t){var{slug:s}=e.artifact,l=e.handlePlacardName({name:t,ext:a,type:"color",slug:s}),d=e.handlePlacardName({name:t,ext:a,type:"normal",slug:s});o.push(["placardColor",e.promisifiedLoad({loader:e.textureLoader,file:l})]),o.push(["placardNormal",e.promisifiedLoad({loader:e.textureLoader,file:d})])}if(!1!==i){var{file:c=1,inside:h=1}=e.artifact.portal;!S.int(c)&&he(c)||(S.int(c)||S.str(c))&&(c=S.int(c)?"portal-".concat(c):c,c="".concat(m.GLB_URL,"/portals/").concat(c,".glb")),o.push(["glb",e.promisifiedLoad({loader:e.gltfLoader,file:c})])}var u=yield Promise.all(o.map(function(){var e=n((function*(e){var[t,a]=e;return[t,yield a]}));return function(t){return e.apply(this,arguments)}}()));return Object.fromEntries(u)}))()}loadVideo(t){var a=this;return n((function*(){var{dir:i,slug:n,video:r,id:o=pe}=t,s=!0===r?n:r,l=e.create("video",{id:o,class:Q,loop:!0,playsinline:!0,preload:"auto",crossorigin:"anonymous"});a.videoElement=l;var d=["webm","mp4"],c=S.str(s)?s:n,[h,u=""]=c.split("?"),f=h.endsWith("m3u8")||h.startsWith("blob:")||a.artifact.hlsVideo;if(f){if(""!==l.canPlayType("application/vnd.apple.mpegurl"))return l.src=h,e.append(l),l;var p=e.create("script",{src:"".concat(m.ROOT_URL,"/hls.js"),parent:m.B});return a.hlsScript=p,new Promise((t=>{e.on(p,"load",(()=>{Hls.isSupported()&&(a.hls=new m.Hls,a.hls.loadSource(h),e.append(l),a.hls.attachMedia(l),a.hls.once(Hls.Events.FRAG_LOADED,(()=>{t(l)})))}))}))}if(h.endsWith(".mp4")?(d=["mp4"],h=h.slice(0,-4)):h.endsWith(".webm")&&(d=["webm"],h=h.slice(0,-5)),he(h)||(h=i?"video/".concat(i,"/").concat(h):"video/".concat(h,"/").concat(h),h="".concat(m.MEDIA_URL,"/").concat(h)),u||(u="v=".concat(ve)),d.forEach((t=>{e.create("source",{src:"".concat(h,".").concat(t,"?").concat(u),type:"video/".concat(t),parent:l})})),e.append(l),!f){var{videoWidth:v}=l;return v>0?l:new Promise((t=>{if(me){var a=e=>{l.videoWidth>0?e(l):setTimeout((()=>a(e)),50)};a(t)}else e.on(l,"canplaythrough",(e=>t(e.target)))}))}}))()}onVideoCanPlayThrough(e){var{e:t,resolve:a}=e;me?setTimeout((()=>{a(t.target)}),ue):a(t.target)}loadAudioSourceRoot(e){var[t,a]=e.split("?"),i=["ogg","mp4","mp3"];t.endsWith(".mp3")?(i=["mp3"],t=t.slice(0,-4)):t.endsWith(".mp4")&&(i=["mp4"],t=t.slice(0,-4));var n=t.startsWith("http")?t:"".concat(m.MEDIA_URL,"/audio/").concat(t);return a||(a="v=".concat(ve)),{audioFileTypes:i,audioSourceRoot:n,request:a}}loadControls(){return n((function*(){var{Controls:e}=yield import("./Controls.js");return e}))()}loadOceanPlane(){return n((function*(){var{OceanPlane:e}=yield import("./vendor.js").then((function(e){return e.bA}));return e}))()}loadWaterNormals(){var e=this;return n((function*(){var t,{normals:a="oceannormals1"}=null===(t=e.artifact)||void 0===t?void 0:t.ocean;return yield e.promisifiedLoad({loader:e.textureLoader,file:"https://static.artificialmuseum.com/textures/ocean/".concat(a,".jpg")})}))()}loadVideoTrigger(){return n((function*(){var{VideoTrigger:e}=yield import("./vendor.js").then((function(e){return e.bB}));return e}))()}loadUnderwaterPlane(){return n((function*(){var{UnderwaterPlane:e}=yield import("./vendor.js").then((function(e){return e.bC}));return e}))()}loadAudioElements(){var t=this;return n((function*(){var{audioElements:a=[],slug:i}=t.artifact;if(t.artifact.audio){var{audio:r=t.artifact.slug}=t.artifact;!0===r&&(r=t.artifact.slug),a.push({autoplay:!0,audio:r})}return yield Promise.all(a.map(function(){var a=n((function*(a,r){var o=S.str(a.audio)?a.audio:i,s="".concat(ge,"-").concat(r);e.remove("#".concat(s));var l=e.create("audio",{class:Q,crossorigin:"anonymous","data-name":o,preload:"auto",id:s});!1!==a.loop&&(l.loop="true"),t.audioElements[r]={ele:l,config:a};var{audioSourceRoot:d,audioFileTypes:c,request:h}=t.loadAudioSourceRoot(o);c.forEach((t=>{var a=".".concat(t),i=d;i.endsWith(a)||(i+=a),e.create("source",{src:"".concat(i,"?").concat(h),type:"audio/".concat(t),parent:l})})),e.append(l);var{duration:m}=l;return S.num(m)&&m>0?{ele:l,config:a}:new Promise((t=>{if(me){var i=e=>{S.num(l.duration)&&l.duration>0?e({ele:l,config:a}):setTimeout((()=>i(e)),50)};i(t)}else e.on(l,"canplaythrough",function(){var e=n((function*(e){t({ele:e.target,config:a})}));return function(t){return e.apply(this,arguments)}}())}))}));return function(e,t){return a.apply(this,arguments)}}()))}))()}loadTextures(){var e=this;return n((function*(){var{textures:t={}}=e.artifact,{dir:a,names:i}=t,r="jpg";m.SUPPORTS.WEBP&&(r="webp"),a&&!a.endsWith("/")&&(a="".concat(a,"/"));var o={};return yield Promise.all(i.map(function(){var t=n((function*(t){var i=t;he(a)||(i="https://static.artificialmuseum.com/textures/".concat(a,"/").concat(t)),i.endsWith(r)||(i="".concat(i,".").concat(r));var n=yield e.promisifiedLoad({loader:e.textureLoader,file:i});o[i]=n}));return function(e){return t.apply(this,arguments)}}())),o}))()}loadController(){var e=this;return n((function*(){var{fpsControls:t,pointerLockControls:a,touchControls:i}=e.artifact;if(t||a||i){if(g||me){var{ArmTouchControls:n}=yield import("./controls/ArmTouchControls.js");return n}var{ArmPointerLockControls:r}=yield import("./controls/ArmPointerLockControls.js");return r}var{ArmOrbitControls:o}=yield import("./controls/ArmOrbitControls.js");return o}))()}loadGltf(){var e=this;return n((function*(){var{artifact:t,XR:a}=e,{file:i,version:n=1}=t,r=a?"&xr=1":"",o=he(i)?i:"".concat(m.GLB_URL,"/").concat(i,".glb?v=").concat(n).concat(r);return yield e.promisifiedLoad({loader:e.gltfLoader,file:o})}))()}loadPly(){var e=this;return n((function*(){var t,{artifact:a,XR:i}=e,{file:r,ply:o={},version:s=1}=a,l=i?"&xr=1":"",d=o.files;if(d&&!S.arr(d)&&(d=[d]),null!==(t=d)&&void 0!==t&&t.length)return yield Promise.all(d.map(function(){var t=n((function*(t){var a=t;if(a){he(a)||(a="https://static.artificialmuseum.com/ply/".concat(a)),a.endsWith(".ply")||(a+=".ply"),a+="?v=".concat(s).concat(l);var i=yield e.promisifiedLoad({loader:e.plyLoader,file:a});return i.name=t.replace(".ply","").split("/").pop(),i}console.error("empty ply file name",d,a)}));return function(e){return t.apply(this,arguments)}}()));var c="string"==typeof o?o:r;null!=o&&o.file&&(c=o.file);var h="?v=".concat(s).concat(l),m=c.endsWith(".ply")?c:"".concat(c,".ply");return he(c)||(m="https://static.artificialmuseum.com/ply/".concat(m)),m+=h,yield e.promisifiedLoad({loader:e.plyLoader,file:m})}))()}loadGui(){var{title:t,button:a,body:i}=this.artifact.gui.afterSpawnModel,n=[];t&&n.push(e.create("h3",{innerText:t})),i&&n.push(e.create("div",{innerText:i})),n.length&&(a&&n.push(e.create("button",{id:"afterSpawnModelButton",class:"styled margin inverse",innerText:a,on:{click:e=>{var t=e.target.parentNode;t.parentNode.removeChild(t)}}})),this.gui={afterSpawnModel:e.create("div",{class:"w hudgui",children:n,parent:"#hud"})})}promisifiedLoad(e){var{loader:t,file:a}=e;return a.file&&(a=a.file),new Promise(((e,i)=>{t.load(a,(t=>{e(t)}),(()=>{}),(e=>{this.setError(e,"Error loading artifact.",5e3),i(e)}))}))}startEngine(){var t=this;return n((function*(){var{artifact:a,XR:i}=t,r=Object.entries(t.promises).map(function(){var e=n((function*(e){var[t,a]=e;return[t,yield a]}));return function(t){return e.apply(this,arguments)}}()),o=yield Promise.all(r);t.assets=Object.fromEntries(o);var s=new be({artifact:a,preload:t,XR:i}),l=yield s.init(t.assets.scene);if(!l)throw new Error("Session undefined.");e.hide(t._header),e.hide(t._preloadInfo),e.show(t._headerDone),t._session=l,t._timeoutShown&&t.isAndroidChrome?e.prop(t._confirmButton,{disabled:!1}):t._isCancelled||(yield t.finishLoad())}))()}showTimeoutWarning(){e.show(this._preloadInfo),this.isAndroidChrome&&(e.show(this._confirmButton),this._confirmButton.setAttribute("disabled",!0),this._timeoutShown=!0)}confirmButtonClickHandler(){var t=this;return n((function*(){t._session?(e.off(t._confirmButton,"click",t.confirmButtonClickHandler),yield t.finishLoad(),t.finished()):console.error("confirmButtonClickHandler: session not defined",t)}))()}finishLoad(){var t=this;return n((function*(){if(t._session){var{hud:a,initFallbackSession:i,initScene:n}=t._session;try{yield n(),a.show(),e.show("#".concat(v)),t.finished()}catch(n){"InvalidStateError"===n.name||"NotSupportedError"===n.name?(yield i(),a.show(),e.show("#".concat(v)),t.finished()):"SecurityError"===n.name?(e.show(t._confirmButton),e.prop(t._confirmButton,{disabled:!1})):(console.error("Unexpected Preload.finishLoad error"),console.error(n))}}}))()}setError(e,t){console.warn(e,t),m.clearTimeout(this.timeout),this.finished()}showTooFarNotification(t){var{distance:a,artifact:i,map:n}=t,r="meter",o=a;o>=1e3?(r="kilometer",o>=2e3&&(r+="s"),o=Math.round(o/1e3)):o>=2&&(r+="s"),this.artifact=i,this.map=n,this.XR=!1,this._tooFarDistanceInfo.innerText="This artifact is ".concat(o," ").concat(r," away."),e.show(this._tooFarContainer),e.on(this._tooFarPreviewButton,"click",this.onTooFarPreviewButtonClick),e.on(this._tooFarCancelButton,"click",this.onTooFarCancelButtonClick),e.on(this._tooFarAbortButton,"click",this.onTooFarCancelButtonClick)}onTooFarCancelButtonClick(){e.off(this._tooFarPreviewButton,"click",this.onTooFarPreviewButtonClick),this._isCancelled=!0,e.hide(this._tooFarContainer),this.finished()}onTooFarPreviewButtonClick(){var t=this;return n((function*(){e.off(t._tooFarPreviewButton,"click",t.onTooFarPreviewButtonClick),e.off(t._tooFarCancelButton,"click",t.onTooFarCancelButtonClick),e.off(t._tooFarAbortButton,"click",t.onTooFarCancelButtonClick),e.hide(t._tooFarContainer),yield t.init()}))()}showWebglDisabledNotification(){e.show(this._webglDisabledContainer),e.hide([this._header,this._headerDone,this._preloadInfo,this._cancelButton,this._confirmButton]),e.on(this._webglDisabledOkButton,"click",this.onWebglDisabledOkButtonClick)}onWebglDisabledOkButtonClick(){e.off(this._webglDisabledOkButton,"click",this.onWebglDisabledOkButtonClick),this._isCancelled=!0,e.hide(this._webglDisabledContainer),this.finished()}finished(){this._isWorking=!1,this._timeoutShown=!1,e(".start-experience-button").forEach((e=>{e.removeAttribute("disabled")})),e.hide([this._warningContainer,this._confirmButton,this._preloadInfo,this._headerDone]),e.prop(this._confirmButton,{disabled:!0}),e.show(this._header),m.clearTimeout(this.timeout)}}export{Te as Preload}; +import{$ as e,av as t,aw as a,ax as i,c as n,ay as r,az as o,aA as s,aj as l,aB as d,aC as c,aD as h,W as m,aE as u,aF as f,aG as p,aH as v,aI as g,aJ as w,aK as y,a2 as b,a as S,v as T,aL as C,aM as E,x,aN as P,C as j,_ as A,a8 as k,D as O,A as R,aO as _,w as L,aP as B,Y as I,y as F,aQ as D,ac as W,aR as N,a0 as H,aS as V,aT as U,aU as z,aV as X,aW as q,a1 as G,V as K,ab as Y,aa as Z,a9 as $,aX as J,aY as Q,aZ as ee,a_ as te,a$ as ae,b0 as ie,G as ne,b1 as re,b2 as oe,Z as se,b3 as le,b4 as de,b5 as ce,b6 as he,am as me,b7 as ue,r as fe,b8 as pe,b9 as ve,ba as ge}from"./vendor.js";class we{constructor(n){var{scene:r,sceneInstance:o,renderer:s,endSession:l}=n;this.endSession=l,this.engine=n,this.gui=e("#".concat(t)),this.hitSearch=e("#hud-searching-hittest"),this.spawnButton=e("#hud-spawn-artifact"),this.scene=r,this.renderer=s,this.sceneInstance=o,e.on("#".concat(a),"click",this.onExitButtonClick.bind(this)),i(this),this.animToggler=e("#toggle-animation-button")}setCamera(t){this.cameraAccess=t,t?e.show(this.recordVideoButton):e.hide(this.recordVideoButton)}showAnimToggler(t){this.animToggler&&(this.animToggler.classList.remove("play"),e.show(this.animToggler),this.animTogglerInit||(this.animTogglerInit=!0,this.eventListener=()=>{this.animToggler.classList.toggle("play"),t()},e.on(this.animToggler,"click",this.eventListener)))}hideAnimToggler(){e.hide(this.animToggler)}show(){e.show(this.gui)}hide(){e.hide(this.gui)}onExitButtonClick(){var t=this;return n((function*(){t.engine.endSession(),e.off(t.animToggler,"click",t.eventListener),r()}))()}showHitSearch(){e.show(this.hitSearch)}hideHitSearch(){e.hide(this.hitSearch)}showSpawnButton(){e.show(this.spawnButton)}hideSpawnButton(){e.hide(this.spawnButton)}showElement(t){t.shown||(e.show(t),t.shown=!0)}hideElement(t){t.shown&&(e.hide(t),t.shown=!1)}}var{SCENE_TYPES:ye}=m.APP_DB;class be{constructor(e){var{artifact:t,preload:a,XR:i}=e;this.XR=i,this.artifact=t,this.preload=a;var{type:n=ye.Hit}=t;this.type=n,this.clock=new o,this.scene=new s,this.customMaterials=[],this.spatials=[],this.spatialObjects=[],this.lookAtCameraObjects=[],this.animateObjects=[],this.audioAnalysers=[],this.audioAnalyserEmissionConfigs=[],this.objects={},this.circlingLights=[],this.customObjects=[],this.videoTargets=[],this.animationListeners=[],this.materialFadeAnimations=[],this.eventsToRemove=[],this.renderSteps=[],this.unspawnObjects=[],this.animations=[],this.randomAudioElements=[],this.onResize=this.onResize.bind(this),this.render=this.render.bind(this),this.initFallbackSession=this.initFallbackSession.bind(this),this.toggleAnimations=this.toggleAnimations.bind(this),this.endSession=this.endSession.bind(this),this.onAddArtifact=this.onAddArtifact.bind(this)}init(t){var a=this;return n((function*(){var i,{artifact:r,preload:o,scene:s,type:w,XR:y}=a;t&&(a.sceneInstance=t);var{fov:b,near:S,far:T}=l(r.cam,d),C=m.innerWidth/m.innerHeight;a.camera=new c(b,C,S,T),a.camera.updateProjectionMatrix(),s.add(a.camera);var E=new h({antialias:!0,alpha:!0});a.renderer=E,E.setPixelRatio(m.devicePixelRatio),E.setSize(m.innerWidth,m.innerHeight),E.domElement.id=u,E.useLegacyLights=!1,E.toneMapping=f;var{audio:x,audioElements:P,circlingLights:j,clickables:A,customMaterials:k,customObjects:O,fog:R,fogexp2:M,hideLight:_,ocean:L,particles:B,shadow:I,triggerVideo:F,underwater:D,wireframes:W,record3d:N,record3DImages:H,renderTargets:V,noShadowObjects:U,receiveNoShadowObjects:z,castNoShadowObjects:X,ws:q}=r;!1!==I&&(E.shadowMap.enabled=!0,E.shadowMap.type=p),a.hud=new we(a);var G=null===(i=a.artifact.animateObjects)||void 0===i?void 0:i.some((e=>e.sound));if((x||null!=P&&P.length||G)&&a.addAudio(),a.addSkybox(),_||a.addLights(),(R||M)&&a.addFog(),q&&a.sceneInstance){var{host:K,port:Y,protocol:Z}=q,$={host:K,port:Y,protocol:Z,scene:t};a.ws=new o.assets.WS($)}if(a.videoElement=o.assets.videoElement,null!=t&&t.init&&(console.warn("`CustomScene.init` is deprecated","and will be removed in a future version. use `CustomScene.beforeLoadModel` instead."),yield t.init({engine:a,preload:o})),N&&r.type!==ye.FakeMirror&&!N.doNotInit){var J=a.videoElement,Q={artifact:r,engine:a,preload:o,videoElement:J},ee=new o.assets.Record3D(Q);a.record3d=ee,ee.model&&(a.model=ee.model),ee.child&&(a.child=ee.child),a.parentName=ee.config.parentName,a.renderSteps.push(ee.tick)}if(H){var{Class:te,images:ae}=o.assets.Record3DImages,ie=new te({engine:a,images:ae,config:H});a.record3DImages=ie}if(null!=t&&t.beforeLoadModel&&t.beforeLoadModel({engine:a,preload:o}),yield a.loadModel(),null!=t&&t.afterLoadModel&&t.afterLoadModel({engine:a,preload:o}),a.artifact.showVideoTime&&(a.frameRateIndicator=e.create("div",{style:{position:"fixed",top:0,left:0,backgroundColor:"black",color:"white"},parent:"#hud"})),U&&U.forEach((e=>{var t=a.model.getObjectByName(e);t&&(t.receiveShadow=!1,t.castShadow=!1)})),z&&z.forEach((e=>{var t=a.model.getObjectByName(e);t&&(t.receiveShadow=!1)})),X&&X.forEach((e=>{var t=a.model.getObjectByName(e);t&&(t.castShadow=!1)})),V&&a.addRenderTargets(),null!=j&&j.length){var{CirclingLights:ne}=yield import("./vendor.js").then((function(e){return e.bo}));new ne(a)}if(k&&new o.assets.CustomMaterials(a),O&&(yield a.addCustomObjects()),W&&W.forEach((e=>{var t=a.model.getObjectByName(e.target);t&&t.material&&(t.material.wireframe=!0,e.transparent&&(t.material.transparent=!0,t.material.opacity=e.opacity))})),F&&(a.objects.videoTrigger=new o.assets.VideoTrigger(a)),D&&(yield a.addUnderwaterPlane()),L&&(a.objects.oceanPlane=new o.assets.OceanPlane({artifact:r,engine:a,preload:a.preload})),B&&(a.particles=new o.assets.Particles(a),yield a.particles.init()),E.setSize(m.innerWidth,m.innerHeight),e.append(E.domElement,"#".concat(v)),y)try{var re=E.xr.getController(0);a.controller=re;var{clickable:oe,shadow:se,shadowPlane:le}=r;if(!1!==se&&!1!==le&&a.addShadowPlane(),!a.isHittestScene())throw new Error("Unknown scene type ".concat(w));w!==ye.Float&&a.spawnReticle(),e.on(a.hud.spawnButton,"click",a.onAddArtifact),e.on(re,"select",a.onAddArtifact),oe||a.hud.hideAnimToggler(),s.add(re),a.initScene=n((function*(){var t=["hit-test","dom-overlay"];g&&t.push("anchors"),e.hide("#Locator");var i=yield m.NAV.xr.requestSession("immersive-ar",{requiredFeatures:t,domOverlay:{root:e("#hud")}});return a.refSpace=yield i.requestReferenceSpace("viewer"),a.localRefSpace=yield i.requestReferenceSpace("local"),a.renderer.xr.enabled=!0,a.renderer.xr.setReferenceSpaceType("local"),yield a.renderer.xr.setSession(i),i.initFallbackSession=a.initFallbackSession.bind(a),a.session=i,i}))}catch(e){a.initScene=a.initFallbackSession}else a.initScene=a.initFallbackSession;return null!=A&&A.length&&a.addClickables(),e.on(m,"resize",a.onResize),a.onResize(),E.setAnimationLoop(a.render),a}))()}onAddArtifact(){var e=this;return n((function*(){var{artifact:t,justUnspawned:a,modelSpawned:i}=e;if(!a){if(!i){yield e.spawnModel(!1)}t.clickable?e.hud.showAnimToggler(e.toggleAnimations):e.hud.hideAnimToggler()}}))()}onResize(){var{innerWidth:e,innerHeight:t}=m;this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.renderer.setSize(e,t)}addRenderTargets(){var{renderTargets:e}=this.artifact;this.renderTargets=[],e.forEach((e=>{var t=l(e,{height:512,width:512,options:{depthBuffer:!1,stencilBuffer:!1},off:[]}),a=[];t.off.length&&t.off.forEach((e=>{var t=this.model.getObjectByName(e);t&&a.push(t)})),this.renderTargets.push({height:t.height,width:t.width,off:a,object:new w(t.width,t.height,t.options)})}))}addLights(){var{directionalLightPosition:e=te.directionalPosition,directionalColor:t=te.directionalColor,directionalIntensity:a=te.directionalIntensity,ambientColor:i=te.ambientColor,ambientIntensity:n=te.ambientIntensity}=this.artifact,r=new y(t,a);r.position.set(...e),r.castShadow=!0,!1!==this.artifact.shadow&&(r.shadow.bias=-1e-4,r.shadow.mapSize.width=4096,r.shadow.mapSize.height=4096,r.shadow.camera.left=-70,r.shadow.camera.right=70,r.shadow.camera.top=70,r.shadow.camera.bottom=-70,r.shadow.camera.near=.1,r.shadow.camera.far=300),this.directionalLight=r,this.scene.add(r),this.ambientLight=new b(i,n),this.scene.add(this.ambientLight)}addCustomObjects(){var{artifact:e}=this,{customObjects:t}=e;t.forEach((e=>{var{config:t,object:a}=e,i=this.model.getObjectByName(t.target);i&&(a.child?i.add(a.child):a.model&&(i.parent.add(a.model),i.parent.remove(i)),this.customObjects.push({config:t,object:a}),S.fn(a.init)&&a.init({engine:this}))}))}addShadowPlane(){var e=new T(150,150,64,64),t=new C;t.opacity=E;var a=new x(e,t);a.receiveShadow=!0,a.lookAt(0,100,0),a.position.set(0,.01,0),this.shadowPlane=a}addPortal(){this.objects.portal=new this.preload.assets.Portal.Factory({engine:this,mergeConfig:l})}spawnReticle(){var e=new P(.15,.2,32).rotateX(-M.PI/2),t=new j;this.reticle=new x(e,t),this.reticle.matrixAutoUpdate=!1,this.reticle.visible=!1,this.scene.add(this.reticle)}onAnimationLoop(e,t){var a=e.action._clip.name;t.forEach((e=>{if(!this.materialFadeAnimations.includes((e=>e.action._clip.name===a))){var t=this.findEventTargets(e);this.materialFadeAnimations.push(A(A({},e),{},{targets:t}))}}))}onAnimationFinished(e,t){var a=e.action._clip.name;t.forEach((e=>{if(!this.materialFadeAnimations.includes((e=>e.action._clip.name===a))){var t=this.findEventTargets(e);this.materialFadeAnimations.push(A(A({},e),{},{targets:t}))}}))}glow(){var{glow:e}=this.artifact;this.model.traverse((t=>{if(k(t.name,"glow")){var a=S.bool(e)?238:e,i=new j({color:a,side:O,blending:R,transparent:!0});t.material=i}}))}addClickables(){var{artifact:t,controller:a,model:i,preload:n,renderer:r,XR:o}=this,{clickables:s=[],clickableChildren:l=!1}=t,d=[];if(!0===s?d.push(i):s.length&&i.traverse((e=>{s.forEach((t=>{if(S.str(t)&&(t={target:t}),_({node:e,search:t.target})){var a;t.node=e,t.hide&&(e.material.transparent=!0,e.material.opacity=0);var i=!0===t.audio?e.name:t.audio;if(null!==(a=n.assets.audioElements)&&void 0!==a&&a.length){var r=n.assets.audioElements.find((e=>{var{ele:t}=e;return t.dataset.name===i}));r&&(t.player=r.ele)}d.includes(t)||d.push(t)}}))})),d.length){var{Controls:c}=n.assets;this.controls=new c({clickableChildren:l,clickables:d,engine:this}),o?e.on(a,"select",this.controls.select,!1):e.on(r.domElement,"mousedown",this.controls.click,!1)}}onTouch(t){var a;null!==(a=this.sceneInstance)&&void 0!==a&&a.onTouch&&this.sceneInstance.onTouch(t),t.forEach(((t,a)=>{if(!(a+1>this.artifact.maxTouches)){var{emission:i,emissionIntensity:n=.2,link:r,player:o}=t;if(r&&(L?window.location.href=r:window.open(r,"_hacked")),o&&(o.loop?o.paused?o.play():(o.currentTime=0,o.pause()):(o.currentTime=0,o.play())),i){var s=t.node.name.split("_")[0],l=this.model.getObjectByName(s);if(!l)return void console.warn("node not found",s);("Group"===l.type?l.children:[l]).forEach((a=>{if(a){if(a.userData.origEmissive||(a.userData.origEmissive=a.material.emissive),a.userData.origEmissiveIntensity||(a.userData.origEmissiveIntensity=a.material.emissiveIntensity),o||console.warn("player not found",t.node.name),o)if(B.same(a.material.emissive,a.userData.origEmissive)){var r=new I(1,1,1);S.bool(i)?a.material.color&&(r=a.material.color):S.arr(i)&&(r=new I(...i)),a.material.emissive=r,a.material.emissiveIntensity=n,o.loop||e.on(o,"ended",(()=>{a.material.emissive=a.userData.origEmissive,a.material.emissiveIntensity=a.userData.origEmissiveIntensity}))}else o.loop&&(a.material.emissive=a.userData.origEmissive,a.material.emissiveIntensity=a.userData.origEmissiveIntensity)}else console.warn("node not found",s)}))}}}))}nosort(){this.renderer.sortObjects=!1}clip(){var{artifact:e,model:t}=this,{clipSide:a,clipInFallback:i}=e;t.traverse((e=>{if(k(e.name,"clip"))if(this.XR||!1!==i){var t=a||e.material.side;e.material=new j({color:"green",colorWrite:!1,side:t}),e.castShadow=!1,e.receiveShadow=!1,e.renderOrder=1}else e.visible=!1;else e.renderOrder=2}))}addUnderwaterPlane(){var e=this;return n((function*(){e.cameraPlane=new e.preload.assets.UnderwaterPlane({engine:e}),yield e.cameraPlane.preload(e)}))()}addSkybox(){var e=this;return n((function*(){var{artifact:t,preload:a,renderer:i,scene:n,XR:r}=e,o=ae,s=null==t?void 0:t.skySphere;S.arr(s)&&s.length&&(o=s);var l=new F(...o),d=a.assets.skybox,c=new j({map:d,side:D}),h=new x(l,c);if(h.rotation.y=W.degToRad(180),h.visible=!r,n.add(h),!1!==t.light&&!t.hideEnvironment){var m=new N(i);m.compileEquirectangularShader();var u=m.fromEquirectangular(d).texture;n.environment=u,u.dispose(),m.dispose()}e.skybox=h}))()}addAudio(){this.listener=new H,this.camera.add(this.listener)}addFog(){var{artifact:e,scene:t}=this,{fog:a,fogexp2:i}=e;if(a){var{color:n,near:r,far:o}=a;t.fog=new V(n,r,o)}if(i){var{color:s,density:l}=i;t.fog=new U(s,l)}}startMedia(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if(!this.isMediaPlaying){this.isMediaPlaying=!0;var{actions:t=[],artifact:a,preload:i}=this,{videoElement:n,audioElements:r=[]}=i.assets;a.triggerAudio||null!=r&&r.length&&r.forEach((t=>{var{config:a,ele:i}=t;a.autoplay?(e&&(i.currentTime=0),a.volume&&(S.fn(i.setVolume)?i.setVolume(a.volume):i.volume=a.volume),i.play()):a.random&&(a.interval=z(a.interval),this.randomAudioElements.push({ele:i,config:a}))})),n&&!a.triggerVideo&&(e&&(n.currentTime=0),n.play()),t.forEach((e=>e.play()))}}stopMedia(){var{preload:e,videoElement:t,actions:a=[],audioElements:i=[]}=this;t&&t.pause(),e.hls&&e.hls.destroy(),a&&a.length&&a.forEach((e=>e.stop())),i.forEach((e=>{var{ele:t}=e;return t.pause()})),this.isMediaPlaying=!1}toggleAnimations(){this.actions.forEach((e=>e.paused=!e.paused))}initFallbackSession(){var e=this;return n((function*(){var t;e.XR=!1,m.B.classList.add(X);var{camera:a,artifact:i,model:n,renderer:r}=e,{clickable:o}=i,{Controller:s}=e.preload.assets;s&&(e.controller=new s(a,r.domElement,i,e),e.controller.unspawn&&e.unspawnObjects.push(e.controller)),e.skybox.visible=!0,o?e.hud.showAnimToggler(e.toggleAnimations):e.hud.hideAnimToggler();var{cam:l={}}=i,d=ie,{x:c=d.x,y:h=d.y,z:u=d.z}=l;a.position.set(c,h,u);var{scale:f}=i;if(f&&n){var{x:p,y:v,z:g}=n.scale;S.num(f)&&n.scale.set(p*f,v*f,g*f)}null===(t=e.controller)||void 0===t||t.update();yield e.spawnModel(!0),r.domElement.focus()}))()}loadModel(){var e=this;return n((function*(){var t,a,i,{artifact:n,preload:r,sceneInstance:o={}}=e,{spatialObjects:s=[],audioElements:l=[]}=n;(e.spatials=[...s,...l],null!=o&&o.model&&(e.model&&e.model!==o.model?e.model.add(o.model):e.model||(e.model=o.model)),null!==(t=r.assets.gltf)&&void 0!==t&&t.scene)&&(e.model?e.model.add(null===(a=r.assets.gltf)||void 0===a?void 0:a.scene):e.model=null===(i=r.assets.gltf)||void 0===i?void 0:i.scene);if(n.ply&&r.assets.addPly(e),e.addAnimations(),e.model){var d,c;e.artifact.hideChildren&&e.artifact.hideChildren.forEach((t=>{var a=e.model.getObjectByName(t);a&&a.position.set(5e3,5e3,5e3)}));var h={},{parentName:m=o.parentName,child:u=o.child}=e;if(m&&u&&(c=e.model.getObjectByName(m),e.modelParent=c),e.model.traverse((t=>{if(e.customObjects.forEach((e=>{var{object:a}=e;a.parentName&&a.child&&k(t.name,a.parentName)&&(h[a.name]=t)})),t.isMesh){var{frustumCulled:a,transparent:i,castShadow:r,receiveShadow:o,noShadowObjects:s=[],noShadowCastObjects:l=[],noShadowReceiveObjects:d=[]}=n;(!1===a||null!=a&&a.includes(t.name))&&(t.frustumCulled=!1),!1===i&&(t.material.transparent=!1),k(t.name,"noshadow")||s.includes(t.name)||(k(t.name,"noshadowcast")||l.includes(t.name)||(t.castShadow=!1!==r),k(t.name,"noshadowreceive")||d.includes(t.name)||(t.receiveShadow=!1!==o)),k(t.name,"videotarget")&&e.videoTargets.push(t),t.material.map&&(t.material.map.anisotropy=16,t.material.map.colorSpace=q),t.material.emissiveMap&&(t.material.emissiveMap.colorSpace=q),(t.material.map||t.material.emissiveMap)&&(t.material.needsUpdate=!0)}var c=[];n.animateObjects&&n.animateObjects.forEach((a=>{if(k(t.name,a.name)){var i=e.actions.find((e=>e._clip.name===t.name));if(a.sound){!0===a.sound&&(a.sound={name:e.artifact.slug}),a.sound.name||(a.sound.name=e.artifact.slug);var n=e.preload.assets.animateObjects[a.sound.name];if(n){var r=new G(e.listener);r.setBuffer(n);var{loopSound:o=!0}=a;if(r.setLoop(o),a.audio=r,a.sound.distance){var s=!1!==a.sound.yDistanceTest;c.push({buffer:r,distance:a.sound.distance,distanceTarget:t.name,target:t.name,yDistanceTest:s})}}else console.error("animateObjects: Sound not found in preload.assets",a)}e.animateObjects.push(A(A({},a),{},{action:i,node:t}))}})),e.spatials=[...e.spatials,...c]})),e.spatials.length){var{SpatialObjects:f}=yield import("./vendor.js").then((function(e){return e.bp}));e.objects.spatialObjects=new f(e)}if(null!==(d=n.lookAtCameraObjects)&&void 0!==d&&d.length){var p=new r.assets.LookAtCamera(e);e.addRenderStep(p.render.bind(p))}if(c&&(o.child?c.add(o.child):e.child&&c.add(e.child)),e.customObjects.forEach((t=>{var{object:a}=t;a.child?h[a.name].add(a.child):a.model&&e.model.add(a.model)})),e.videoElement&&e.videoTargets.length){var v,{flipVideo:g,chromaKey:w}=n,y=new K(e.videoElement);!1!==g&&(y.flipY=!1);var{examples:b={}}=null===(v=e.preload)||void 0===v?void 0:v.assets,{ChromaKeyMaterial:S=!1}=b;e.videoTargets.forEach((e=>{w?S&&(e.material=new S(w,y)):e.material.map=y}))}}var{clip:T,glow:C,portal:E,nosort:x,clones:P,clonesOnMeshes:j}=e.artifact;if(C&&e.glow(),E&&e.addPortal(),e.model&&T&&e.clip(),x&&e.nosort(),r.assets.Mirrors&&new r.assets.Mirrors(e),e.artifact.analyseAudio){var{AnalyseAudio:O}=yield import("./vendor.js").then((function(e){return e.bq})),R=new O(e);e.addRenderStep(R.render)}if(e.model){if(e.model.position.set(5e3,5e3,5e3),P){var{Clones:M}=yield import("./vendor.js").then((function(e){return e.br}));e.clones=new M(e)}if(j){var{ClonesOnMeshes:_}=yield import("./vendor.js").then((function(e){return e.bs}));e.meshClones=new _(e)}e.scene.add(e.model)}}))()}addAnimations(){var t,a,i;if(null!==(t=this.sceneInstance)&&void 0!==t&&null!==(t=t.animations)&&void 0!==t&&t.length&&this.animations.push(...this.sceneInstance.animations),null!==(a=this.preload.assets.gltf)&&void 0!==a&&null!==(a=a.animations)&&void 0!==a&&a.length&&this.animations.push(...this.preload.assets.gltf.animations),this.actions=[],null!==(i=this.animations)&&void 0!==i&&i.length){var n;this.mixer=new Y(this.model);var{animations:r={}}=this.artifact,{loop:o,startOnTouch:s,clampWhenFinished:l=!0,autoplay:d=!0,noLoopAnimations:c=[],pausedAnimations:h=[],timeScale:m=1}=r;if(this.animations.forEach((e=>{var t=this.mixer.clipAction(e),a=h.includes(e.name),i=s||!d||a;(!1===o||c.includes(e.name))&&(t.clampWhenFinished=l,t.loop=Z),i&&(t.paused=!0),S.num(m)?t.timeScale=m:S.obj(m)&&m.hasOwnProperty(t.name)&&(t.timeScale=m[t.name]),this.actions.push(t)})),null!==(n=this.artifact.events)&&void 0!==n&&n.animation){var{events:u}=this.artifact,{times:f=[],loop:p=[],finished:v=[]}=null==u?void 0:u.animation;if(p.length){var g=[this.mixer,"loop",e=>this.onAnimationLoop(e,p)];e.on(...g),g.targets=this.findEventTargets(p),this.eventsToRemove.push(g)}if(v.length){var w=[this.mixer,"finished",e=>this.onAnimationFinished(e,v)];e.on(...w),w.targets=this.findEventTargets(v),this.eventsToRemove.push(w)}if(f.length){var{times:y}=this.artifact.events.animation;y.length&&y.forEach((e=>{var{action:t,once:a=!1}=e,i=$.findByName(this.animations,t),n=this.findEventTargets(e);this.animationListeners.push(A(A({},e),{},{once:a,action:i,targets:n}))}))}}}}findEventTargets(e){var t=[];return this.model.traverse((a=>{_({node:a,search:e.targets})&&(a.material&&(t.includes(a.material)||t.push(a.material)))})),t}spawnModel(e){var t=this;return n((function*(){var a,{artifact:i,camera:n,controller:r,model:o,reticle:s,scene:l,sceneInstance:d={},shadowPlane:c,type:h,XR:m}=t,{showSkybox:u,skyboxTransparency:f,floatSpawnAtZeroY:p=!1}=i;if(!m||e)o&&o.position.set(0,0,0),t.modelSpawned=!0;else if(t.isHittestScene()){if(!t.modelSpawned&&t.lastHit){s.updateMatrixWorld(),o.position.setFromMatrixPosition(s.matrixWorld),o.updateMatrixWorld();var v=n.position,g=o.position,w=v.x-g.x,y=v.z-g.z,b=Math.atan2(w,y);o.rotation.y=b,c&&(c.position.setFromMatrixPosition(s.matrixWorld),l.add(c)),o.visible=!0,s.visible=!1,t.modelSpawned=!0}}else if(h===ye.Float){var T=o.clone();T.position.set(0,0,-1).applyMatrix4(r.matrixWorld),p&&(T.position.y=0),l.add(T)}if(t.applyPositionAndRotation(),null!=d&&d.spawnModel&&(console.warn("W_DEPRECATED: sceneInstance.spawnModel is deprecated. Please use sceneInstance.afterSpawnModel instead."),d.spawnModel({engine:t})),null!=d&&d.afterSpawnModel&&d.afterSpawnModel({engine:t}),t.startMedia(),u&&(t.skybox.visible=!0,f&&(t.skybox.material.transparent=!0,t.skybox.material.opacity=f),t.skybox.receiveShadow=!1),null!==(a=t.preload.gui)&&void 0!==a&&a.afterSpawnModel){var{afterSpawnModel:C}=t.preload.gui;C.style.visibility="visible",C.style.opacity=1,setTimeout((()=>{var e;S.fn(null===(e=C.parentNode)||void 0===e?void 0:e.removeChild)&&C.parentNode.removeChild(C)}),8e3)}}))()}exitSceneInstance(){var t,a;this.modelSpawned&&(this.scene.remove(this.model),this.modelSpawned=!1,this.isAnimationRunning=!1,this.stopMedia(),this.justUnspawned=!0,null!==(a=this.eventsToRemove)&&void 0!==a&&a.length&&this.eventsToRemove.forEach((t=>{e.off(...t)})),this.unspawnObjects.forEach((e=>{null==e||e.unspawn(this)})),setTimeout((()=>{this.justUnspawned=!1}),200));this.customObjects.forEach((e=>{var{object:t}=e;S.fn(t.exit)&&t.exit({engine:this})})),this.customMaterials.forEach((e=>{var{material:t}=e;S.fn(t.exit)&&t.exit({engine:this})})),this.animateObjects.forEach((e=>{var t;null===(t=e.audio)||void 0===t||t.stop()})),null!==(t=this.sceneInstance)&&void 0!==t&&t.exit&&this.sceneInstance.exit({engine:this}),this.frameRateIndicator&&e.remove(this.frameRateIndicator)}applyPositionAndRotation(){var{artifact:e,model:t}=this;if(t){var{pos:a={},rot:i={}}=e,{x:n,y:r,z:o}=a;n&&(t.position.x+=n),r&&(t.position.y+=r),o&&(t.position.z+=o);var{x:s,y:l,z:d}=i,c=W.degToRad;s&&t.rotateX(c(s)),l&&t.rotateY(c(l)),d&&t.rotateZ(c(d))}}endSession(){var t,a;if(null===(t=this.session)||void 0===t||!t.ended){this.session&&(this.session.end(),this.session.ended=!0),this.hud.hide(),this.renderer.setAnimationLoop(null),e("#".concat(v)).classList.remove("visible"),this.exitSceneInstance(),this.scene&&J(this.scene),e.remove(".".concat(Q)),null!==(a=this.preload)&&void 0!==a&&a.hls&&(this.preload.hls.destroy(),e.remove(this.preload.hlsScript));var i=e("#".concat(u));if(i){var n=i.parentNode;n.id===v?e.remove(i):e.remove(n)}m.B.classList.remove(X),e(".start-experience-button").forEach((e=>{e.removeAttribute("disabled")})),L&&m.location.reload()}}isHittestScene(){return![ye.Float].includes(this.type)}addRenderStep(e){this.renderSteps.push(e)}render(e,t){var a=this;return n((function*(){var i,n,r,o,s,l,d=a.clock.getDelta();if(a.renderHittest(t),a.mixer)if(a.artifact.videoBoundAnimation&&a.videoElement){a.lastFrameVideoTime||(a.lastFrameVideoTime=a.videoElement.currentTime);var c=a.videoElement.currentTime-a.lastFrameVideoTime;c&&a.mixer.update(c),a.lastFrameVideoTime=a.videoElement.currentTime}else a.mixer.update(d);var h,m={delta:d,timestamp:e,engine:a,frame:t};if(a.modelSpawned){if(g&&a.XR){var u=t.getPose(a.anchor.anchorSpace,a.localRefSpace),{x:f,y:p,z:v}=u.transform.position;a.model.position.set(f,p,v);var{x:w,y:y,z:b,w:S}=u.transform.orientation;a.model.quaternion.set(w,y,b,S)}a.renderSteps.forEach((e=>{e(m)}))}(a.artifact.showVideoTime&&(a.frameRateIndicator.innerText="Videotime: ".concat(a.videoElement.currentTime)),null!==(i=a.sceneInstance)&&void 0!==i&&i.tick&&a.sceneInstance.tick(m),null!==(n=a.artifact.ply)&&void 0!==n&&n.animated&&a.renderPlyMorphTargetInfluences(m),null!==(r=a.animateObjects)&&void 0!==r&&r.length&&a.renderAnimateObjects(m),null!==(o=a.animationListeners)&&void 0!==o&&o.length&&a.renderAnimationTimeEvent(m),a.materialFadeAnimations.length&&a.renderMaterialAnimTick(m),null!==(s=a.randomAudioElements)&&void 0!==s&&s.length&&a.renderRandomAudio(m),a.particles&&a.particles.update(m),a.customObjects.length&&a.renderCustomObjects(m),null!==(l=a.sceneInstance)&&void 0!==l&&l.render?a.sceneInstance.render(m):a.renderer.render(a.scene,a.camera),a.controller)&&(null!==(h=a.controller)&&void 0!==h&&h.update&&a.controller.update(d))}))()}renderRenderTargets(e){var{renderTargets:t}=this;t.forEach((e=>{e.off.length&&e.off.forEach((e=>{e.visible=!1})),this.renderer.setRenderTarget(e.object),this.renderer.render(scene,camera),this.renderer.setRenderTarget(null),e.off.length&&e.off.forEach((e=>{e.visible=!0}))}))}renderPlyMorphTargetInfluences(e){var{delta:t,timestamp:a}=e;this.nextMorphTargetStep||(this.nextMorphTargetStep=a+this.morphTargetInfluenceConfig.delay);var i=this.animatedPoints,n=i.morphTargetInfluences.length-1,r=t*this.morphTargetInfluenceConfig.speed;i.morphTargetInfluences=i.morphTargetInfluences.map(((e,t)=>{if(t===this.morphTargetTargetIndex){var i=Math.min(e+r,1);return i>=1&&a>this.nextMorphTargetStep&&(this.nextMorphTargetStep=a+this.morphTargetInfluenceConfig.delay,this.hasRun=!this.hasRun,this.hasRun||(this.morphTargetTargetIndex+=1,this.morphTargetTargetIndex>n&&(this.morphTargetTargetIndex=0))),i}return Math.max(e-r,0)}))}renderCustomObjects(e){this.customObjects.forEach((t=>{var{object:a}=t;S.fn(a.tick)&&a.tick(e)}))}renderAnimateObjects(e){var{timestamp:t}=e;this.animateObjects.forEach((e=>{var{action:a,audio:i,speed:n,minSpeed:r=0,maxDelay:o=2,minDelay:s=1}=e;if(a&&a.paused&&(e.nextAnimation||(e.nextAnimation=t+Math.random()*(1e3*o)+1e3*s),i.isPlaying&&i.stop(),e.nextAnimation<=t)){e.nextAnimation=!1;var l=Math.random()>.5?1:-1,d=Math.max(r,Math.random()*n)*l;a.timeScale=d,a.paused=!1,a.play(),i&&!i.isPlaying&&i.play()}}))}renderHittest(t){var a=this;return n((function*(){if(a.modelSpawned)a.hud.hideSpawnButton();else if(t&&a.XR){var i=a.renderer.xr.getSession();a.hitTestSourceRequested||(a.hitTestSource=yield i.requestHitTestSource({space:a.refSpace}),e.on(i,"end",(()=>{a.hitTestSourceRequested=!1,a.hitTestSource=null})),a.hitTestSourceRequested=!0);var n=t.getHitTestResults(a.hitTestSource);if(n.length){if(a.lastHit=n[0],g&&(a.anchor=yield a.lastHit.createAnchor()),!a.modelSpawned){a.reticle.visible=!0,a.hud.showSpawnButton();var r=a.renderer.xr.getReferenceSpace();a.reticle.matrix.fromArray(a.lastHit.getPose(r).transform.matrix)}a.hud.hideHitSearch()}else a.reticle.visible=!1,a.modelSpawned||(a.hud.showHitSearch(),a.hud.hideSpawnButton()),a.lastHit=void 0}}))()}renderAnimationTimeEvent(){this.animationListeners.forEach((e=>{var{time:t,action:a,once:i}=e,{time:n}=a;!e.hasTriggered&&n>=t?(e.hasTriggered=!0,this.materialFadeAnimations.push(e)):n<=t&&(i||(e.hasTriggered=!1))}))}renderRandomAudio(e){var{timestamp:t}=e;this.modelSpawned&&this.randomAudioElements.forEach((e=>{var{ele:a,config:i}=e;if(a.paused&&(i.nextPlayTime||(i.nextPlayTime=t+ee(i.interval)),i.nextPlayTime<=t)){a.time=0,a.play();var n=ee(i.interval);i.nextPlayTime=t+n+1e3*a.duration}}))}renderMaterialAnimTick(e){var{delta:t}=e;this.materialFadeAnimations.forEach(((e,a)=>{if(e){var{targets:i=[],speed:n=1,to:r=0,props:o}=e;i.forEach((e=>{var i=S.arr(o)?o:[o],s=!0;i.map((a=>{var i=e[a]+n*t;n<0?i<=r?i=r:s=!1:n>0&&(i>=r?i=r:s=!1),e[a]=i})),s&&this.materialFadeAnimations.splice(a,1)}))}}))}}var Se=(e,t)=>S.arr(t)||S.str(t)?t.includes(e)||t===e:null==t?void 0:t.hasOwnProperty(e);class Te{constructor(t){var{artifact:a,root:i,THREE:n,XR:r=!0}=t;this.artifact=a,this.root=i,this.XR=!1===r?r:m.SUPPORTS.XR,n&&(this.THREE=n);var{android:o,chrome:s}=fe;this.isAndroidChrome=o&&s,this._warningContainer=e("#timeout-warning"),this._header=e("#timeout-warning-header"),this._headerDone=e("#timeout-warning-header-done"),this._preloadInfo=e("#timeout-warning-info"),this._cancelButton=e("#timeout-warning-cancel"),this._confirmButton=e("#timeout-warning-confirm"),this._tooFarContainer=e("#toofar-warning"),this._tooFarPreviewButton=e("#toofar-warning-load-preview-button"),this._tooFarDistanceInfo=e("#toofar-warning-distance"),this._tooFarCancelButton=e("#toofar-warning-cancel-button"),this._tooFarAbortButton=e("#toofar-warning-abort-button"),this._webglDisabledContainer=e("#timeout-warning-webgl-disabled"),this._webglDisabledOkButton=e("#timeout-warning-webgl-disabled-ok-button"),this.confirmButtonClickHandler=this.confirmButtonClickHandler.bind(this),e.on(this._confirmButton,"click",this.confirmButtonClickHandler),this.onTooFarCancelButtonClick=this.onTooFarCancelButtonClick.bind(this),this.onTooFarPreviewButtonClick=this.onTooFarPreviewButtonClick.bind(this),this.onWebglDisabledOkButtonClick=this.onWebglDisabledOkButtonClick.bind(this),this.promisifiedLoad=this.promisifiedLoad.bind(this),this.textureLoader=new ne,this.gltfLoader=new re,this.plyLoader=new oe,this.audioLoader=new se,this.fontLoader=new le,this.audioElements=[],this.collectPreloadPromises(),this.startEngine=this.startEngine.bind(this),this.onVideoCanPlayThrough=this.onVideoCanPlayThrough.bind(this)}collectPreloadPromises(){var{animateObjects:e,audio:t,audioElements:a,chromaKey:i,clickables:n=[],customMaterials:r,customObjects:o,fonts:s,glb:l,gui:d,mirrors:c,ply:h,textures:m,type:u,video:f,lookAtCameraObjects:p,ocean:v,particles:g,portal:w,record3d:y,record3DImages:b,triggerVideo:T,underwater:C,ws:E}=this.artifact,x={};if(x.skybox=this.loadSkybox(),(t||a)&&(x.audioElements=this.loadAudioElements()),T&&(x.VideoTrigger=this.loadVideoTrigger()),C&&(x.UnderwaterPlane=this.loadUnderwaterPlane()),g&&(x.Particles=this.loadParticles()),null!=c&&c.length&&(x.Mirrors=this.loadMirrors()),n.length&&(x.Controls=this.loadControls()),v&&(x.OceanPlane=this.loadOceanPlane(),x.waterNormals=this.loadWaterNormals()),de(u,APP_DB.SCENE_TYPES)||(x.scene=this.loadScene()),!1!==l&&(x.gltf=this.loadGltf()),h&&(x.ply=this.loadPly(),x.addPly=this.loadAddPly()),m&&(x.textures=this.loadTextures()),i){var P=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return S.str(t)&&(t=str.split(" ")),S.arr(t)?t.push(e):S.obj(t)&&(t[e]=!0),t}("ChromaKeyMaterial",this.artifact.examples);this.artifact.examples=P}if(w&&(x.Portal=this.loadPortal()),y&&(x.Record3D=this.loadRecord3D(),y.images&&(x.textures=this.loadRecord3DTextures(x.textures))),b&&(x.Record3DImages=this.loadRecord3DImages(b.images)),E&&(x.WS=this.loadWS()),f){var{slug:j,video:A}=this.artifact;x.videoElement=this.loadVideo({slug:j,video:A})}null!=p&&p.length&&(x.LookAtCamera=this.loadLookAtCamera()),s&&(x.fonts=this.loadFonts()),this.artifact.examples&&(x.examples=this.loadExamples()),d&&this.loadGui(),r&&(x.customMaterials=this.loadCustomMaterials(),x.CustomMaterials=this.loadCustomMaterialClasses()),o&&(x.customObjects=this.loadCustomObjects()),e&&(x.animateObjects=this.loadAnimateObjects()),this.XR||this.artifact.noControls||(x.Controller=this.loadController()),this.promises=x}init(){var t=this;return n((function*(){t._isWorking=!0,t._isCancelled=!1,t._session=!1,e.on(t._cancelButton,"click",(()=>{t._isCancelled=!0,t.finished()})),e.show([t._warningContainer,t._header]),t.timeout=m.setTimeout(t.showTimeoutWarning,ce),yield t.startEngine()}))()}loadScene(){var t=this;return n((function*(){var{artifact:a}=t,i=APP_DB.SCENE_TYPES,{type:n=i.Hit}=a,r=Object.entries(i).find((e=>{var[t,a]=e;return a===n})),o="".concat(t.root,"/CustomScene.js");if(S.arr(r)){var s=r[0];o="./scenes/".concat(s,".js")}var{default:d}=yield import(o),c=new d({artifact:a,mergeConfig:l,nodeNameIncludes:k,nodeNameMatchesWildcard:_,preload:t,$:e,W:m,is:S});return S.fn(null==c?void 0:c.preload)?yield c.preload({artifact:a,preload:t}):S.fn(null==c?void 0:c.load)&&(yield c.load({artifact:a,preload:t})),c}))()}loadWS(){return n((function*(){var{WS:e}=yield import("./WS.js");return e}))()}loadMirrors(){return n((function*(){var{Mirrors:e}=yield import("./vendor.js").then((function(e){return e.bt}));return e}))()}loadAddPly(){return n((function*(){var{addPly:e}=yield import("./vendor.js").then((function(e){return e.bu}));return e}))()}loadParticles(){return n((function*(){var{Particles:e}=yield import("./vendor.js").then((function(e){return e.bv}));return e}))()}loadLookAtCamera(){return n((function*(){var{LookAtCamera:e}=yield import("./vendor.js").then((function(e){return e.bw}));return e}))()}loadSkybox(){var e=this;return n((function*(){var{city:t,sky:a,slug:i}=e.artifact,n=a||i;he(n)||(n=["https://static.artificialmuseum.com","skybox",t,n].filter((e=>e)).join("/"));var r="jpg";return m.SUPPORTS.WEBP&&(r="webp"),n.endsWith(".".concat(r))||(n+=".".concat(r)),yield e.promisifiedLoad({loader:e.textureLoader,file:n})}))()}loadFonts(){var e=this;return n((function*(){var{fonts:t}=e.artifact,a={};return yield Promise.all(t.map(function(){var t=n((function*(t){var i="https://static.artificialmuseum.com/font/json/".concat(t,".typeface.json");a[t]=yield e.promisifiedLoad({loader:e.fontLoader,file:i})}));return function(e){return t.apply(this,arguments)}}())),a}))()}loadAnimateObjects(){var e=this;return n((function*(){var{animateObjects:t,slug:a}=e.artifact,i={},r=e.audioLoader;return yield Promise.all(t.map(function(){var t=n((function*(t){if(t.sound){var{sound:n={}}=t;if(!0===n&&(n={name:a}),n.name||(n.name=a),!i[n.name]){var o=".mp3";m.SUPPORTS.A_MP4?o=".mp4":m.SUPPORTS.A_OGG&&(o=".ogg");var s="https://media.artificialmuseum.com/audio/".concat(n.name).concat(o);i[n.name]=yield e.promisifiedLoad({loader:r,file:s})}}}));return function(e){return t.apply(this,arguments)}}())),i}))()}loadExamples(){var e=this;return n((function*(){var{examples:t}=e.artifact,a=[];Se("TextGeometry",t)&&a.push(["TextGeometry",import("./vendor.js").then((function(e){return e.bx}))]),Se("ChromaKeyMaterial",t)&&a.push(["ChromaKeyMaterial",import("./materials/ChromaKeyMaterial.js")]);var i=yield Promise.all(a.map(function(){var e=n((function*(e){var[t,a]=e,i=yield a,n=i[t]?i[t]:i.default;return n||console.error("E_MODULE_NOT_FOUND","module ".concat(t," could not be imported from examples, got:"),a),[t,n]}));return function(t){return e.apply(this,arguments)}}()));return Object.fromEntries(i)}))()}loadCustomMaterials(){var e=this;return n((function*(){var{artifact:t}=e,{customMaterials:a}=t;return Promise.all(a.map(function(){var a=n((function*(a){var i=a.name.endsWith("Material")?a.name:"".concat(a.name,"Material"),{default:n}=yield import("./materials/".concat(i,".js")),r=new n({artifact:t,config:a,preload:e});return S.fn(r.preload)?yield r.preload({artifact:t,config:a}):S.fn(r.load)&&(yield r.load({artifact:t,config:a})),{config:a,material:r}}));return function(e){return a.apply(this,arguments)}}()))}))()}loadCustomMaterialClasses(){return n((function*(){var{CustomMaterials:e}=yield import("./vendor.js").then((function(e){return e.by}));return e}))()}loadCustomObjects(){var e=this;return n((function*(){var{artifact:t}=e,{customObjects:a}=t;return Promise.all(a.map(function(){var a=n((function*(a){var{default:i}=yield import("./objects/".concat(a.name,".js")),n=new i({artifact:t,config:a,preload:e});return S.fn(n.preload)&&(yield n.preload()),n}));return function(e){return a.apply(this,arguments)}}()))}))()}loadRecord3D(){return n((function*(){var{Record3D:e}=yield import("./vendor.js").then((function(e){return e.bn}));return e}))()}loadRecord3DImages(){var e=arguments,t=this;return n((function*(){var a=e.length>0&&void 0!==e[0]?e[0]:[],i=t.textureLoader,{Record3DImages:r}=yield import("./vendor.js").then((function(e){return e.bz})),o=yield Promise.all(a.map(function(){var e=n((function*(e){var a="https://static.artificialmuseum.com/".concat(e.src,"?v=").concat(t.artifact.version),{position:n,quaternion:r,intrMat:o}=e;return{object:yield t.promisifiedLoad({loader:i,file:a}),position:n,quaternion:r,intrMat:o}}));return function(t){return e.apply(this,arguments)}}()));return{Class:r,images:o}}))()}loadRecord3DTextures(){var e=arguments,t=this;return n((function*(){var a=e.length>0&&void 0!==e[0]?e[0]:{},i=t.textureLoader;return yield Promise.all(t.artifact.record3d.images.map(function(){var e=n((function*(e){var n=e.file?e.file:e,r=n;he(r)||(r=["https://static.artificialmuseum.com","livedata",t.artifact.livedataCategory,r].filter((e=>e)).join("/"));var o=yield t.promisifiedLoad({loader:i,file:r});a[n]=o}));return function(t){return e.apply(this,arguments)}}())),a}))()}handlePlacardName(e){var{name:t,ext:a=".jpg",type:i,slug:n}=e;return(t=S.str(t)?t:n).endsWith("/")&&(t+=n),t.endsWith(".png")?(a=".png",t.slice(0,-4)):t.endsWith(".jpg")&&(a=".jpg",t.slice(0,-4)),a.startsWith(".")||(a=".".concat(a)),he(t)||(t="https://static.artificialmuseum.com/placards/".concat(t,"_").concat(i).concat(a)),t}loadPortal(){var e=this;return n((function*(){var{placardImage:t=!1,placardExtension:a=".jpg",load:i}=e.artifact.portal,{Portal:r}=yield import("./vendor.js").then((function(e){return e.bA})),o=[["Factory",r]];if(!1!==t){var{slug:s}=e.artifact,l=e.handlePlacardName({name:t,ext:a,type:"color",slug:s}),d=e.handlePlacardName({name:t,ext:a,type:"normal",slug:s});o.push(["placardColor",e.promisifiedLoad({loader:e.textureLoader,file:l})]),o.push(["placardNormal",e.promisifiedLoad({loader:e.textureLoader,file:d})])}if(!1!==i){var{file:c=1,inside:h=1}=e.artifact.portal;!S.int(c)&&he(c)||(S.int(c)||S.str(c))&&(c=S.int(c)?"portal-".concat(c):c,c="".concat(m.GLB_URL,"/portals/").concat(c,".glb")),o.push(["glb",e.promisifiedLoad({loader:e.gltfLoader,file:c})])}var u=yield Promise.all(o.map(function(){var e=n((function*(e){var[t,a]=e;return[t,yield a]}));return function(t){return e.apply(this,arguments)}}()));return Object.fromEntries(u)}))()}loadVideo(t){var a=this;return n((function*(){var{dir:i,slug:n,video:r,id:o=pe}=t,s=!0===r?n:r,l=e.create("video",{id:o,class:Q,loop:!0,playsinline:!0,preload:"auto",crossorigin:"anonymous"});a.videoElement=l;var d=["webm","mp4"],c=S.str(s)?s:n,[h,u=""]=c.split("?"),f=h.endsWith("m3u8")||h.startsWith("blob:")||a.artifact.hlsVideo;if(f){if(""!==l.canPlayType("application/vnd.apple.mpegurl"))return l.src=h,e.append(l),l;var p=e.create("script",{src:"".concat(m.ROOT_URL,"/hls.js"),parent:m.B});return a.hlsScript=p,new Promise((t=>{e.on(p,"load",(()=>{Hls.isSupported()&&(a.hls=new m.Hls,a.hls.loadSource(h),e.append(l),a.hls.attachMedia(l),a.hls.once(Hls.Events.FRAG_LOADED,(()=>{t(l)})))}))}))}if(h.endsWith(".mp4")?(d=["mp4"],h=h.slice(0,-4)):h.endsWith(".webm")&&(d=["webm"],h=h.slice(0,-5)),he(h)||(h=i?"video/".concat(i,"/").concat(h):"video/".concat(h,"/").concat(h),h="".concat(m.MEDIA_URL,"/").concat(h)),u||(u="v=".concat(ve)),d.forEach((t=>{e.create("source",{src:"".concat(h,".").concat(t,"?").concat(u),type:"video/".concat(t),parent:l})})),e.append(l),!f){var{videoWidth:v}=l;return v>0?l:new Promise((t=>{if(me){var a=e=>{l.videoWidth>0?e(l):setTimeout((()=>a(e)),50)};a(t)}else e.on(l,"canplaythrough",(e=>t(e.target)))}))}}))()}onVideoCanPlayThrough(e){var{e:t,resolve:a}=e;me?setTimeout((()=>{a(t.target)}),ue):a(t.target)}loadAudioSourceRoot(e){var[t,a]=e.split("?"),i=["ogg","mp4","mp3"];t.endsWith(".mp3")?(i=["mp3"],t=t.slice(0,-4)):t.endsWith(".mp4")&&(i=["mp4"],t=t.slice(0,-4));var n=t.startsWith("http")?t:"".concat(m.MEDIA_URL,"/audio/").concat(t);return a||(a="v=".concat(ve)),{audioFileTypes:i,audioSourceRoot:n,request:a}}loadControls(){return n((function*(){var{Controls:e}=yield import("./Controls.js");return e}))()}loadOceanPlane(){return n((function*(){var{OceanPlane:e}=yield import("./vendor.js").then((function(e){return e.bB}));return e}))()}loadWaterNormals(){var e=this;return n((function*(){var t,{normals:a="oceannormals1"}=null===(t=e.artifact)||void 0===t?void 0:t.ocean;return yield e.promisifiedLoad({loader:e.textureLoader,file:"https://static.artificialmuseum.com/textures/ocean/".concat(a,".jpg")})}))()}loadVideoTrigger(){return n((function*(){var{VideoTrigger:e}=yield import("./vendor.js").then((function(e){return e.bC}));return e}))()}loadUnderwaterPlane(){return n((function*(){var{UnderwaterPlane:e}=yield import("./vendor.js").then((function(e){return e.bD}));return e}))()}loadAudioElements(){var t=this;return n((function*(){var{audioElements:a=[],slug:i}=t.artifact;if(t.artifact.audio){var{audio:r=t.artifact.slug}=t.artifact;!0===r&&(r=t.artifact.slug),a.push({autoplay:!0,audio:r})}return yield Promise.all(a.map(function(){var a=n((function*(a,r){var o=S.str(a.audio)?a.audio:i,s="".concat(ge,"-").concat(r);e.remove("#".concat(s));var l=e.create("audio",{class:Q,crossorigin:"anonymous","data-name":o,preload:"auto",id:s});!1!==a.loop&&(l.loop="true"),t.audioElements[r]={ele:l,config:a};var{audioSourceRoot:d,audioFileTypes:c,request:h}=t.loadAudioSourceRoot(o);c.forEach((t=>{var a=".".concat(t),i=d;i.endsWith(a)||(i+=a),e.create("source",{src:"".concat(i,"?").concat(h),type:"audio/".concat(t),parent:l})})),e.append(l);var{duration:m}=l;return S.num(m)&&m>0?{ele:l,config:a}:new Promise((t=>{if(me){var i=e=>{S.num(l.duration)&&l.duration>0?e({ele:l,config:a}):setTimeout((()=>i(e)),50)};i(t)}else e.on(l,"canplaythrough",function(){var e=n((function*(e){t({ele:e.target,config:a})}));return function(t){return e.apply(this,arguments)}}())}))}));return function(e,t){return a.apply(this,arguments)}}()))}))()}loadTextures(){var e=this;return n((function*(){var{textures:t={}}=e.artifact,{dir:a,names:i}=t,r="jpg";m.SUPPORTS.WEBP&&(r="webp"),a&&!a.endsWith("/")&&(a="".concat(a,"/"));var o={};return yield Promise.all(i.map(function(){var t=n((function*(t){var i=t;he(a)||(i="https://static.artificialmuseum.com/textures/".concat(a,"/").concat(t)),i.endsWith(r)||(i="".concat(i,".").concat(r));var n=yield e.promisifiedLoad({loader:e.textureLoader,file:i});o[i]=n}));return function(e){return t.apply(this,arguments)}}())),o}))()}loadController(){var e=this;return n((function*(){var{fpsControls:t,pointerLockControls:a,touchControls:i}=e.artifact;if(t||a||i){if(g||me){var{ArmTouchControls:n}=yield import("./controls/ArmTouchControls.js");return n}var{ArmPointerLockControls:r}=yield import("./controls/ArmPointerLockControls.js");return r}var{ArmOrbitControls:o}=yield import("./controls/ArmOrbitControls.js");return o}))()}loadGltf(){var e=this;return n((function*(){var{artifact:t,XR:a}=e,{file:i,version:n=1}=t,r=a?"&xr=1":"",o=he(i)?i:"".concat(m.GLB_URL,"/").concat(i,".glb?v=").concat(n).concat(r);return yield e.promisifiedLoad({loader:e.gltfLoader,file:o})}))()}loadPly(){var e=this;return n((function*(){var t,{artifact:a,XR:i}=e,{file:r,ply:o={},version:s=1}=a,l=i?"&xr=1":"",d=o.files;if(d&&!S.arr(d)&&(d=[d]),null!==(t=d)&&void 0!==t&&t.length)return yield Promise.all(d.map(function(){var t=n((function*(t){var a=t;if(a){he(a)||(a="https://static.artificialmuseum.com/ply/".concat(a)),a.endsWith(".ply")||(a+=".ply"),a+="?v=".concat(s).concat(l);var i=yield e.promisifiedLoad({loader:e.plyLoader,file:a});return i.name=t.replace(".ply","").split("/").pop(),i}console.error("empty ply file name",d,a)}));return function(e){return t.apply(this,arguments)}}()));var c="string"==typeof o?o:r;null!=o&&o.file&&(c=o.file);var h="?v=".concat(s).concat(l),m=c.endsWith(".ply")?c:"".concat(c,".ply");return he(c)||(m="https://static.artificialmuseum.com/ply/".concat(m)),m+=h,yield e.promisifiedLoad({loader:e.plyLoader,file:m})}))()}loadGui(){var{title:t,button:a,body:i}=this.artifact.gui.afterSpawnModel,n=[];t&&n.push(e.create("h3",{innerText:t})),i&&n.push(e.create("div",{innerText:i})),n.length&&(a&&n.push(e.create("button",{id:"afterSpawnModelButton",class:"styled margin inverse",innerText:a,on:{click:e=>{var t=e.target.parentNode;t.parentNode.removeChild(t)}}})),this.gui={afterSpawnModel:e.create("div",{class:"w hudgui",children:n,parent:"#hud"})})}promisifiedLoad(e){var{loader:t,file:a}=e;return a.file&&(a=a.file),new Promise(((e,i)=>{t.load(a,(t=>{e(t)}),(()=>{}),(e=>{this.setError(e,"Error loading artifact.",5e3),i(e)}))}))}startEngine(){var t=this;return n((function*(){var{artifact:a,XR:i}=t,r=Object.entries(t.promises).map(function(){var e=n((function*(e){var[t,a]=e;return[t,yield a]}));return function(t){return e.apply(this,arguments)}}()),o=yield Promise.all(r);t.assets=Object.fromEntries(o);var s=new be({artifact:a,preload:t,XR:i}),l=yield s.init(t.assets.scene);if(!l)throw new Error("Session undefined.");e.hide(t._header),e.hide(t._preloadInfo),e.show(t._headerDone),t._session=l,t._timeoutShown&&t.isAndroidChrome?e.prop(t._confirmButton,{disabled:!1}):t._isCancelled||(yield t.finishLoad())}))()}showTimeoutWarning(){e.show(this._preloadInfo),this.isAndroidChrome&&(e.show(this._confirmButton),this._confirmButton.setAttribute("disabled",!0),this._timeoutShown=!0)}confirmButtonClickHandler(){var t=this;return n((function*(){t._session?(e.off(t._confirmButton,"click",t.confirmButtonClickHandler),yield t.finishLoad(),t.finished()):console.error("confirmButtonClickHandler: session not defined",t)}))()}finishLoad(){var t=this;return n((function*(){if(t._session){var{hud:a,initFallbackSession:i,initScene:n}=t._session;try{yield n(),a.show(),e.show("#".concat(v)),t.finished()}catch(n){"InvalidStateError"===n.name||"NotSupportedError"===n.name?(yield i(),a.show(),e.show("#".concat(v)),t.finished()):"SecurityError"===n.name?(e.show(t._confirmButton),e.prop(t._confirmButton,{disabled:!1})):(console.error("Unexpected Preload.finishLoad error"),console.error(n))}}}))()}setError(e,t){console.warn(e,t),m.clearTimeout(this.timeout),this.finished()}showTooFarNotification(t){var{distance:a,artifact:i,map:n}=t,r="meter",o=a;o>=1e3?(r="kilometer",o>=2e3&&(r+="s"),o=Math.round(o/1e3)):o>=2&&(r+="s"),this.artifact=i,this.map=n,this.XR=!1,this._tooFarDistanceInfo.innerText="This artifact is ".concat(o," ").concat(r," away."),e.show(this._tooFarContainer),e.on(this._tooFarPreviewButton,"click",this.onTooFarPreviewButtonClick),e.on(this._tooFarCancelButton,"click",this.onTooFarCancelButtonClick),e.on(this._tooFarAbortButton,"click",this.onTooFarCancelButtonClick)}onTooFarCancelButtonClick(){e.off(this._tooFarPreviewButton,"click",this.onTooFarPreviewButtonClick),this._isCancelled=!0,e.hide(this._tooFarContainer),this.finished()}onTooFarPreviewButtonClick(){var t=this;return n((function*(){e.off(t._tooFarPreviewButton,"click",t.onTooFarPreviewButtonClick),e.off(t._tooFarCancelButton,"click",t.onTooFarCancelButtonClick),e.off(t._tooFarAbortButton,"click",t.onTooFarCancelButtonClick),e.hide(t._tooFarContainer),yield t.init()}))()}showWebglDisabledNotification(){e.show(this._webglDisabledContainer),e.hide([this._header,this._headerDone,this._preloadInfo,this._cancelButton,this._confirmButton]),e.on(this._webglDisabledOkButton,"click",this.onWebglDisabledOkButtonClick)}onWebglDisabledOkButtonClick(){e.off(this._webglDisabledOkButton,"click",this.onWebglDisabledOkButtonClick),this._isCancelled=!0,e.hide(this._webglDisabledContainer),this.finished()}finished(){this._isWorking=!1,this._timeoutShown=!1,e(".start-experience-button").forEach((e=>{e.removeAttribute("disabled")})),e.hide([this._warningContainer,this._confirmButton,this._preloadInfo,this._headerDone]),e.prop(this._confirmButton,{disabled:!0}),e.show(this._header),m.clearTimeout(this.timeout)}}export{Te as Preload}; diff --git a/docs/Preload.js.gz b/docs/Preload.js.gz index bb35d3ef..1d200eff 100644 Binary files a/docs/Preload.js.gz and b/docs/Preload.js.gz differ diff --git a/docs/controls/ArmTouchControls.js b/docs/controls/ArmTouchControls.js index b1628b8d..f57f4a38 100644 --- a/docs/controls/ArmTouchControls.js +++ b/docs/controls/ArmTouchControls.js @@ -1 +1 @@ -import{bc as t,bd as e,be as o,$ as i,aj as s,a5 as n,ae as a,bf as h,as as r,bg as d,bh as u,am as l,w as c,au as m,bi as v}from"../vendor.js";import{MovementPad as p}from"./MovementPad.js";import"./utils.js";var f=l&&!c,w=new WeakMap,M=new WeakMap,y=new WeakMap,g=new WeakMap,b=new WeakMap,k=new WeakMap,x=new WeakMap,P=new WeakMap,W=new WeakMap,D=new WeakMap,Y=new WeakMap,B=new WeakMap,C=new WeakMap,R=new WeakMap,S=new WeakMap,E=new WeakSet,K=new WeakSet,U=new WeakSet;class O{constructor(u,l,c,m){t(this,U),t(this,K),t(this,E),e(this,"movementPad",void 0),e(this,"container",void 0),e(this,"config",void 0),e(this,"fpsBody",void 0),e(this,"mouse",void 0),e(this,"enabled",!0),o(this,w,{writable:!0,value:void 0}),o(this,M,{writable:!0,value:void 0}),o(this,y,{writable:!0,value:void 0}),o(this,g,{writable:!0,value:void 0}),o(this,b,{writable:!0,value:!1}),o(this,k,{writable:!0,value:!1}),o(this,x,{writable:!0,value:!1}),o(this,P,{writable:!0,value:!1}),o(this,W,{writable:!0,value:!1}),o(this,D,{writable:!0,value:!1}),o(this,Y,{writable:!0,value:!1}),o(this,B,{writable:!0,value:!1}),o(this,C,{writable:!0,value:!1}),o(this,R,{writable:!0,value:1}),o(this,S,{writable:!0,value:1}),this.container=l.parentNode.parentNode,this.canvas=l,this.camera=u,f&&(i.on(document,"gesturestart",this.gestureChange),i.on(document,"gesturechange",this.gestureChange),i.on(document,"gestureend",this.gestureEnd),document.documentElement.style.position="fixed",document.documentElement.style.height="100%",document.documentElement.style.overflow="hidden",document.body.style.width="100vw",document.body.style.height="100vh",document.body.style.overflowY="scroll",document.body.style.overflowX="hidden",document.body.style.WebkitOverflowScrolling="touch"),this.config=s(c.touchControls,{delta:.75,moveSpeed:.03,rotationSpeed:.003,maxPitch:0}),this.camConfig=s(c.cam,{x:0,y:1.7,z:5});var v=s(c,{floorTargets:[]});v.floorTargets.length&&(this.targets=v.floorTargets.map((t=>m.model.getObjectByName(t))).filter((t=>t)),this.targets.length&&(this.currentCameraHeight=1.7,this.rayOrigin=new n,this.rayDirection=new n(0,-1,0),this.floorRay=new a)),h(this,M,[]),h(this,g,this.config.maxPitch*Math.PI/180),h(this,y,new n(0,0,0)),this.mouse=new r,this.fpsBody=m.camera,this.movementPad=new p(this),this.onYawPitch=this.onYawPitch.bind(this),this.onPadMove=this.onPadMove.bind(this),this.onStopMove=this.onStopMove.bind(this),this.onContextMenu=this.onContextMenu.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseOut=this.onMouseOut.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseUp=this.onMouseUp.bind(this),i.on(this.movementPad.padElement,"move",this.onPadMove),i.on(this.movementPad.padElement,"stopMove",this.onStopMove),i.on(this.container,"contextmenu",this.onContextMenu),i.on(this.container,"mousedown",this.onMouseDown),i.on(this.container,"mouseup",this.onMouseUp),i.on(document,"touchstart",(t=>{f&&!t.target.attribute("id").startsWith("hud")&&(t.preventDefault(),t.stopPropagation())})),i.on(document,"keydown",this.onKeyDown),i.on(document,"keyup",this.onKeyUp),i.on(document,"mousemove",this.onMouseMove),i.on(document,"mouseout",this.onMouseOut),d(this,E,X).call(this)}onPadMove(t){h(this,R,Math.abs(t.detail.deltaY)),h(this,S,Math.abs(t.detail.deltaX)),t.detail.deltaY==t.detail.middle?(h(this,R,1),h(this,k,h(this,x,!1))):t.detail.deltaY>t.detail.middle?(h(this,k,!0),h(this,x,!1)):t.detail.deltaYt.object.visible)),o=0;e.length?e.forEach((t=>{var e=t.point.y;o=e+this.currentCameraHeight})):o=this.currentCameraHeight,this.targetY=o}update(){u(this,y).x+=-1*u(this,y).x*this.config.delta,u(this,y).z+=-1*u(this,y).z*this.config.delta,u(this,k)&&!u(this,D)&&(u(this,y).z-=u(this,R)*this.config.moveSpeed*this.config.delta),u(this,x)&&!u(this,Y)&&(u(this,y).z+=u(this,R)*this.config.moveSpeed*this.config.delta),u(this,P)&&!u(this,B)&&(u(this,y).x-=u(this,S)*this.config.moveSpeed*this.config.delta),u(this,W)&&!u(this,C)&&(u(this,y).x+=u(this,S)*this.config.moveSpeed*this.config.delta),this.floorRay&&(this.updateRayCaster(),this.fpsBody.position.y=this.targetY),this.fpsBody.translateX(u(this,y).x),this.fpsBody.translateZ(u(this,y).z)}getDirection2(t){var e=new n(0,0,-1),o=new m(0,0,0,"YXZ"),i=this.fpsBody.rotation.x,s=this.fpsBody.rotation.y;return o.set(i,s,0),t.copy(e).applyEuler(o),t}getDirection(){var t=0,e=0,o=new n(0,0,-1),i=new m(0,0,0,"YXZ");return null!=self&&(t=this.fpsBody.rotation.x,e=this.fpsBody.rotation.y),s=>(i.set(t,e,0),s.copy(o).applyEuler(i),s)}isMoveLeft(){return u(this,P)}isMoveRight(){return u(this,W)}isMoveForward(){return u(this,k)}isMoveBackward(){return u(this,x)}lockMoveForward(t){h(this,D,t)}lockMoveBackward(t){h(this,Y,t)}lockMoveLeft(t){h(this,B,t)}lockMoveRight(t){h(this,C,t)}unlockAllDirections(){this.lockMoveForward(!1),this.lockMoveBackward(!1),this.lockMoveLeft(!1),this.lockMoveRight(!1)}addToScene(t){h(this,w,t),u(this,w).add(this.fpsBody)}setPosition(t,e,o){this.fpsBody.position.set(t,e,o)}stopMouseMoving(){h(this,b,!1)}setRotation(t,e){null!==t&&(this.fpsBody.rotation.x=t),null!==e&&(this.fpsBody.rotation.y=e)}}function X(){var t=new v;t.makeRotationY(0),u(this,M).push(t);var e=new v;e.makeRotationY(180*Math.PI/180),u(this,M).push(e);var o=new v;o.makeRotationY(90*Math.PI/180),u(this,M).push(o);var i=new v;i.makeRotationY(270*Math.PI/180),u(this,M).push(i)}function z(t,e,o){var i=o||this.config.rotationSpeed,s=this.fpsBody.rotation.y-t*i,n=this.fpsBody.rotation.x-e*i;return{rx:n=Math.max(-u(this,g),Math.min(u(this,g),n)),ry:s}}export{O as ArmTouchControls}; +import{bc as t,bd as e,be as o,bf as i,$ as s,aj as n,a5 as a,ae as h,bg as r,as as d,bh as u,bi as l,au as c,bj as m}from"../vendor.js";import{MovementPad as v}from"./MovementPad.js";import"./utils.js";var p=new WeakMap,f=new WeakMap,w=new WeakMap,M=new WeakMap,y=new WeakMap,g=new WeakMap,b=new WeakMap,k=new WeakMap,x=new WeakMap,P=new WeakMap,W=new WeakMap,D=new WeakMap,Y=new WeakMap,B=new WeakMap,C=new WeakMap,R=new WeakSet,S=new WeakSet,E=new WeakSet;class K{constructor(l,c,m,K){t(this,E),t(this,S),t(this,R),e(this,"movementPad",void 0),e(this,"container",void 0),e(this,"config",void 0),e(this,"fpsBody",void 0),e(this,"mouse",void 0),e(this,"enabled",!0),o(this,p,{writable:!0,value:void 0}),o(this,f,{writable:!0,value:void 0}),o(this,w,{writable:!0,value:void 0}),o(this,M,{writable:!0,value:void 0}),o(this,y,{writable:!0,value:!1}),o(this,g,{writable:!0,value:!1}),o(this,b,{writable:!0,value:!1}),o(this,k,{writable:!0,value:!1}),o(this,x,{writable:!0,value:!1}),o(this,P,{writable:!0,value:!1}),o(this,W,{writable:!0,value:!1}),o(this,D,{writable:!0,value:!1}),o(this,Y,{writable:!0,value:!1}),o(this,B,{writable:!0,value:1}),o(this,C,{writable:!0,value:1}),this.container=c.parentNode.parentNode,this.canvas=c,this.camera=l,i&&(s.on(document,"gesturestart",this.gestureChange),s.on(document,"gesturechange",this.gestureChange),s.on(document,"gestureend",this.gestureEnd),document.documentElement.style.position="fixed",document.documentElement.style.height="100%",document.documentElement.style.overflow="hidden",document.body.style.width="100vw",document.body.style.height="100vh",document.body.style.overflowY="scroll",document.body.style.overflowX="hidden",document.body.style.WebkitOverflowScrolling="touch"),this.config=n(m.touchControls,{delta:.75,moveSpeed:.03,rotationSpeed:.003,maxPitch:0}),this.camConfig=n(m.cam,{x:0,y:1.7,z:5});var O=n(m,{floorTargets:[]});O.floorTargets.length&&(this.targets=O.floorTargets.map((t=>K.model.getObjectByName(t))).filter((t=>t)),this.targets.length&&(this.currentCameraHeight=1.7,this.rayOrigin=new a,this.rayDirection=new a(0,-1,0),this.floorRay=new h)),r(this,f,[]),r(this,M,this.config.maxPitch*Math.PI/180),r(this,w,new a(0,0,0)),this.mouse=new d,this.fpsBody=K.camera,this.movementPad=new v(this),this.onYawPitch=this.onYawPitch.bind(this),this.onPadMove=this.onPadMove.bind(this),this.onStopMove=this.onStopMove.bind(this),this.onContextMenu=this.onContextMenu.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseOut=this.onMouseOut.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseUp=this.onMouseUp.bind(this),s.on(this.movementPad.padElement,"move",this.onPadMove),s.on(this.movementPad.padElement,"stopMove",this.onStopMove),s.on(this.container,"contextmenu",this.onContextMenu),s.on(this.container,"mousedown",this.onMouseDown),s.on(this.container,"mouseup",this.onMouseUp),s.on(document,"touchstart",(t=>{i&&!t.target.attribute("id").startsWith("hud")&&(t.preventDefault(),t.stopPropagation())})),s.on(document,"keydown",this.onKeyDown),s.on(document,"keyup",this.onKeyUp),s.on(document,"mousemove",this.onMouseMove),s.on(document,"mouseout",this.onMouseOut),u(this,R,U).call(this)}onPadMove(t){r(this,B,Math.abs(t.detail.deltaY)),r(this,C,Math.abs(t.detail.deltaX)),t.detail.deltaY==t.detail.middle?(r(this,B,1),r(this,g,r(this,b,!1))):t.detail.deltaY>t.detail.middle?(r(this,g,!0),r(this,b,!1)):t.detail.deltaYt.object.visible)),o=0;e.length?e.forEach((t=>{var e=t.point.y;o=e+this.currentCameraHeight})):o=this.currentCameraHeight,this.targetY=o}update(){l(this,w).x+=-1*l(this,w).x*this.config.delta,l(this,w).z+=-1*l(this,w).z*this.config.delta,l(this,g)&&!l(this,P)&&(l(this,w).z-=l(this,B)*this.config.moveSpeed*this.config.delta),l(this,b)&&!l(this,W)&&(l(this,w).z+=l(this,B)*this.config.moveSpeed*this.config.delta),l(this,k)&&!l(this,D)&&(l(this,w).x-=l(this,C)*this.config.moveSpeed*this.config.delta),l(this,x)&&!l(this,Y)&&(l(this,w).x+=l(this,C)*this.config.moveSpeed*this.config.delta),this.floorRay&&(this.updateRayCaster(),this.fpsBody.position.y=this.targetY),this.fpsBody.translateX(l(this,w).x),this.fpsBody.translateZ(l(this,w).z)}getDirection2(t){var e=new a(0,0,-1),o=new c(0,0,0,"YXZ"),i=this.fpsBody.rotation.x,s=this.fpsBody.rotation.y;return o.set(i,s,0),t.copy(e).applyEuler(o),t}getDirection(){var t=0,e=0,o=new a(0,0,-1),i=new c(0,0,0,"YXZ");return null!=self&&(t=this.fpsBody.rotation.x,e=this.fpsBody.rotation.y),s=>(i.set(t,e,0),s.copy(o).applyEuler(i),s)}isMoveLeft(){return l(this,k)}isMoveRight(){return l(this,x)}isMoveForward(){return l(this,g)}isMoveBackward(){return l(this,b)}lockMoveForward(t){r(this,P,t)}lockMoveBackward(t){r(this,W,t)}lockMoveLeft(t){r(this,D,t)}lockMoveRight(t){r(this,Y,t)}unlockAllDirections(){this.lockMoveForward(!1),this.lockMoveBackward(!1),this.lockMoveLeft(!1),this.lockMoveRight(!1)}addToScene(t){r(this,p,t),l(this,p).add(this.fpsBody)}setPosition(t,e,o){this.fpsBody.position.set(t,e,o)}stopMouseMoving(){r(this,y,!1)}setRotation(t,e){null!==t&&(this.fpsBody.rotation.x=t),null!==e&&(this.fpsBody.rotation.y=e)}}function U(){var t=new m;t.makeRotationY(0),l(this,f).push(t);var e=new m;e.makeRotationY(180*Math.PI/180),l(this,f).push(e);var o=new m;o.makeRotationY(90*Math.PI/180),l(this,f).push(o);var i=new m;i.makeRotationY(270*Math.PI/180),l(this,f).push(i)}function O(t,e,o){var i=o||this.config.rotationSpeed,s=this.fpsBody.rotation.y-t*i,n=this.fpsBody.rotation.x-e*i;return{rx:n=Math.max(-l(this,M),Math.min(l(this,M),n)),ry:s}}export{K as ArmTouchControls}; diff --git a/docs/controls/ArmTouchControls.js.gz b/docs/controls/ArmTouchControls.js.gz index a48e0694..5836946c 100644 Binary files a/docs/controls/ArmTouchControls.js.gz and b/docs/controls/ArmTouchControls.js.gz differ diff --git a/docs/controls/MovementPad.js b/docs/controls/MovementPad.js index 7f41ce1a..51a4fe2c 100644 --- a/docs/controls/MovementPad.js +++ b/docs/controls/MovementPad.js @@ -1 +1 @@ -import{bd as t,am as e,w as i}from"../vendor.js";import{getOffset as a}from"./utils.js";var s=e&&!i;class n{constructor(e){t(this,"container",void 0),t(this,"padElement",void 0),t(this,"region",void 0),t(this,"handle",void 0),t(this,"eventRepeatTimeout",void 0),t(this,"regionData",{}),t(this,"handleData",{}),t(this,"mouseDown",!1),t(this,"mouseStopped",!1),this.container=e.container,this.padElement=document.createElement("div"),this.padElement.classList.add("movement-pad"),this.region=document.createElement("div"),this.region.classList.add("region"),this.handle=document.createElement("div"),this.handle.classList.add("handle"),this.region.appendChild(this.handle),this.padElement.append(this.region),this.container.append(this.padElement);var i=e.canvas;this.alignAndConfigPad(i),window.addEventListener("resize",(()=>{this.alignAndConfigPad(i)})),this.region.addEventListener("mousedown",(t=>{this.mouseDown=!0,this.handle.style.opacity=1,this.update(t.pageX,t.pageY)})),document.addEventListener("mouseup",(()=>{this.mouseDown=!1,this.resetHandlePosition()})),document.addEventListener("mousemove",(t=>{this.mouseDown&&this.update(t.pageX,t.pageY)})),this.region.addEventListener("touchstart",(t=>{this.mouseDown=!0,this.handle.style.opacity=1,this.currentTouchId=t.targetTouches[0].identifier,this.update(t.targetTouches[0].pageX,t.targetTouches[0].pageY)}));var a=t=>{t.changedTouches[0].identifier===this.currentTouchId&&(this.mouseDown=!1,this.resetHandlePosition(),this.currentTouchId=-1)};document.addEventListener("touchend",a),document.addEventListener("touchcancel",a),document.addEventListener("touchmove",(t=>{if(this.mouseDown){var e;for(var i of(s&&t.preventDefault(),t.touches))i.identifier===this.currentTouchId&&(e=i);e&&this.update(e.pageX,e.pageY)}})),this.resetHandlePosition()}alignAndConfigPad(t){this.regionData.width=this.region.offsetWidth,this.regionData.height=this.region.offsetHeight,this.regionData.position={top:this.region.offsetTop,left:this.region.offsetLeft},this.regionData.offset=a(this.region),this.regionData.radius=this.regionData.width/2,this.regionData.centerX=this.regionData.position.left+this.regionData.radius,this.regionData.centerY=this.regionData.position.top+this.regionData.radius,this.handleData.width=this.handle.offsetWidth,this.handleData.height=this.handle.offsetHeight,this.handleData.radius=this.handleData.width/2,this.regionData.radius=this.regionData.width/2-this.handleData.radius}update(t,e){var i=t-this.regionData.offset.left,a=e-this.regionData.offset.top;if(Math.pow(this.regionData.centerX-i,2)+Math.pow(this.regionData.centerY-a,2)>Math.pow(this.regionData.radius,2)){var s=Math.atan2(a-this.regionData.centerY,i-this.regionData.centerX);i=Math.cos(s)*this.regionData.radius+this.regionData.centerX,a=Math.sin(s)*this.regionData.radius+this.regionData.centerY}a=Math.round(10*a)/10,i=Math.round(10*i)/10,this.handle.style.top=a-this.handleData.radius+"px",this.handle.style.left=i-this.handleData.radius+"px";var n=this.regionData.centerX-parseInt(i),h=this.regionData.centerY-parseInt(a);n=4*(n- -this.regionData.radius)/(this.regionData.radius- -this.regionData.radius)-2,h=4*(h- -this.regionData.radius)/(this.regionData.radius- -this.regionData.radius)-2,n=Math.round(10*n)/10,h=Math.round(10*h)/10,this.sendEvent(n,h,0)}sendEvent(t,e,i){if(this.eventRepeatTimeout&&clearTimeout(this.eventRepeatTimeout),this.mouseDown){this.eventRepeatTimeout=setTimeout((()=>{this.sendEvent(t,e,i)}),5);var a=new CustomEvent("move",{bubbles:!1,detail:{deltaX:t,deltaY:e,middle:i}});this.padElement.dispatchEvent(a)}else{var s=new Event("stopMove",{bubbles:!1});this.padElement.dispatchEvent(s)}}resetHandlePosition(){this.handle.style.top=this.regionData.centerY-this.handleData.radius+"px",this.handle.style.left=this.regionData.centerX-this.handleData.radius+"px",this.handle.style.opacity=.1}}export{n as MovementPad}; +import{bd as t,bf as e}from"../vendor.js";import{getOffset as i}from"./utils.js";class a{constructor(i){t(this,"container",void 0),t(this,"padElement",void 0),t(this,"region",void 0),t(this,"handle",void 0),t(this,"eventRepeatTimeout",void 0),t(this,"regionData",{}),t(this,"handleData",{}),t(this,"mouseDown",!1),t(this,"mouseStopped",!1),this.container=i.container,this.padElement=document.createElement("div"),this.padElement.classList.add("movement-pad"),this.region=document.createElement("div"),this.region.classList.add("region"),this.handle=document.createElement("div"),this.handle.classList.add("handle"),this.region.appendChild(this.handle),this.padElement.append(this.region),this.container.append(this.padElement);var a=i.canvas;this.alignAndConfigPad(a),window.addEventListener("resize",(()=>{this.alignAndConfigPad(a)})),this.region.addEventListener("mousedown",(t=>{this.mouseDown=!0,this.handle.style.opacity=1,this.update(t.pageX,t.pageY)})),document.addEventListener("mouseup",(()=>{this.mouseDown=!1,this.resetHandlePosition()})),document.addEventListener("mousemove",(t=>{this.mouseDown&&this.update(t.pageX,t.pageY)})),this.region.addEventListener("touchstart",(t=>{this.mouseDown=!0,this.handle.style.opacity=1,this.currentTouchId=t.targetTouches[0].identifier,this.update(t.targetTouches[0].pageX,t.targetTouches[0].pageY)}));var s=t=>{t.changedTouches[0].identifier===this.currentTouchId&&(this.mouseDown=!1,this.resetHandlePosition(),this.currentTouchId=-1)};document.addEventListener("touchend",s),document.addEventListener("touchcancel",s),document.addEventListener("touchmove",(t=>{if(this.mouseDown){var i;for(var a of(e&&t.preventDefault(),t.touches))a.identifier===this.currentTouchId&&(i=a);i&&this.update(i.pageX,i.pageY)}})),this.resetHandlePosition()}alignAndConfigPad(t){this.regionData.width=this.region.offsetWidth,this.regionData.height=this.region.offsetHeight,this.regionData.position={top:this.region.offsetTop,left:this.region.offsetLeft},this.regionData.offset=i(this.region),this.regionData.radius=this.regionData.width/2,this.regionData.centerX=this.regionData.position.left+this.regionData.radius,this.regionData.centerY=this.regionData.position.top+this.regionData.radius,this.handleData.width=this.handle.offsetWidth,this.handleData.height=this.handle.offsetHeight,this.handleData.radius=this.handleData.width/2,this.regionData.radius=this.regionData.width/2-this.handleData.radius}update(t,e){var i=t-this.regionData.offset.left,a=e-this.regionData.offset.top;if(Math.pow(this.regionData.centerX-i,2)+Math.pow(this.regionData.centerY-a,2)>Math.pow(this.regionData.radius,2)){var s=Math.atan2(a-this.regionData.centerY,i-this.regionData.centerX);i=Math.cos(s)*this.regionData.radius+this.regionData.centerX,a=Math.sin(s)*this.regionData.radius+this.regionData.centerY}a=Math.round(10*a)/10,i=Math.round(10*i)/10,this.handle.style.top=a-this.handleData.radius+"px",this.handle.style.left=i-this.handleData.radius+"px";var n=this.regionData.centerX-parseInt(i),h=this.regionData.centerY-parseInt(a);n=4*(n- -this.regionData.radius)/(this.regionData.radius- -this.regionData.radius)-2,h=4*(h- -this.regionData.radius)/(this.regionData.radius- -this.regionData.radius)-2,n=Math.round(10*n)/10,h=Math.round(10*h)/10,this.sendEvent(n,h,0)}sendEvent(t,e,i){if(this.eventRepeatTimeout&&clearTimeout(this.eventRepeatTimeout),this.mouseDown){this.eventRepeatTimeout=setTimeout((()=>{this.sendEvent(t,e,i)}),5);var a=new CustomEvent("move",{bubbles:!1,detail:{deltaX:t,deltaY:e,middle:i}});this.padElement.dispatchEvent(a)}else{var s=new Event("stopMove",{bubbles:!1});this.padElement.dispatchEvent(s)}}resetHandlePosition(){this.handle.style.top=this.regionData.centerY-this.handleData.radius+"px",this.handle.style.left=this.regionData.centerX-this.handleData.radius+"px",this.handle.style.opacity=.1}}export{a as MovementPad}; diff --git a/docs/controls/MovementPad.js.gz b/docs/controls/MovementPad.js.gz index e2f643ce..b0d00b38 100644 Binary files a/docs/controls/MovementPad.js.gz and b/docs/controls/MovementPad.js.gz differ diff --git a/docs/etags.csv b/docs/etags.csv index 248cc86c..2e13304d 100644 --- a/docs/etags.csv +++ b/docs/etags.csv @@ -1,5 +1,5 @@ -Controls.js,8vNqslSRJQh9YkULgWwrUsj7mQE= -Preload.js,205l1mNPYhNqsVHEHleiQPYiCS0= +Controls.js,g9rTwZT9OaTa6E1r1h9J8/bPnGY= +Preload.js,A00Xh+BPYd7H0qgRceJrtoytdtg= SCENE_TYPES.js,ns7yuu3KTutCVsnQE3a2CiEOZrE= WS.js,Q3uHOJezh1vmTmN1NGejX9RG05g= anchor/index.html,uu/3TnViOz+38l3QKzkqLQJzUYQ= @@ -17,8 +17,8 @@ chemnitz/index.html,2It84PvuR5c9puIGqzF8EFmKjZg= cms.js,Xk0G3H8PO1P9kwhrlXB89tw40bM= controls/ArmOrbitControls.js,OMwHmCaQI6nGicfL0wg9ZMPz20Q= controls/ArmPointerLockControls.js,+2EsyGB91p/PKKW55RfApMuQ76E= -controls/ArmTouchControls.js,w0HAnCaIZtIr6OjJ2nwkxEHX/1M= -controls/MovementPad.js,q1Yc+XH2PGb2/P5quN7buWbm23s= +controls/ArmTouchControls.js,33nyh48GHyU9dx4nwDv+83jVMKQ= +controls/MovementPad.js,NViAKehiWxt1a0L5NiE3Er45MfQ= controls/RotationPad.js,hvKP0C8rOpGAttYwJiso69hC850= controls/utils.js,oeNUd3hP05fV/F//E85JwlBEiEA= dresden/index.html,tmw03mRw2qHXpibTV3Sx+rL2yl4= @@ -43,7 +43,7 @@ logo.webp,mCDRktFp9KFOLX/LQq3Dt2yYItQ= main.css,E6ohxMlUIXWAj2p2KS9zxIiGEz4= main.js,2y60IpkzpAR1J0tiTDHLfU5DjxQ= manifest.json,gQ7OOM9LFOw0Q2dRrjGJT35rd+w= -materials/BasFuzzyMaterial.js,mSUUYktFyPSFS8rbj+lPOWwaBZM= +materials/BasFuzzyMaterial.js,u4dIN5oV5A8rvSJMn3WuKArOj38= materials/ChromaKeyMaterial.js,JX40i045XyAi0MbsEZFCewkF+ak= materials/DissolveMaterial.js,CjPFuVZ9iPQ8s8SkD0zlHT6hVrI= materials/FresnelMaterial.js,EH6RQPwvRe0SK0mSuPZek4lHQXI= @@ -52,7 +52,7 @@ materials/GlslSandboxMaterial.js,3tCv0tqMRT9MQkCuj/IaAVyqZGQ= materials/LunarAnomalyMaterial.js,sZe6mtlTabnk1Q8vrREtgQMjwAE= materials/UniverseMaterial.js,PYlNG+ahyzgqJnnCow0t79QK5do= materials/VideoTrailMaterial.js,60AYKHKQ/kcl4PlRuNbBaqYqipo= -materials/WaterPlaneMaterial.js,/sqTUJwmuEnz6YzBVTiUl4Xiz6w= +materials/WaterPlaneMaterial.js,9wO0MOdO/zCQPxyrYhHvT8XJPY4= materials/WireframeMaterial.js,sLIXsDX/k5eWgizz470kLzNO3Xw= materials/shaders/glslsandbox/82051.js,csdvtTshdoK9it1J2TRQRBxnzhg= melk/index.html,EVJ3L0Atlcqi81UjfWK4HbOHjQU= @@ -93,5 +93,5 @@ scenes/PlyExhibition.js,q9X8PhKClKGvNDqGXaR2i4eU6hQ= schlanders/index.html,x5UEwcRZy20yijiccpfYP6lr1K8= stpoelten/index.html,q8QlZb0x1HFN1GUPPAJqdyCSuuU= toronto/index.html,ZB12CfER7Dn9MCbEdEZmCYOhBUo= -vendor.js,vnhqwu92Jt82jA2gFZkYCR0IB4c= +vendor.js,YjC1ML/UFYPKXMCO348lH6S0UTA= vienna/index.html,uC98941PrBFI3bFYEWnZdHA2fDY= \ No newline at end of file diff --git a/docs/materials/BasFuzzyMaterial.js b/docs/materials/BasFuzzyMaterial.js index 89b4f551..16aafe6d 100644 --- a/docs/materials/BasFuzzyMaterial.js +++ b/docs/materials/BasFuzzyMaterial.js @@ -1 +1 @@ -import{a5 as e,bj as r,M as t,x as a,bk as n,ac as o,aq as s}from"../vendor.js";var i=new e(0,1,0),u=new e,m=new s;class l extends a{constructor(e){super(e);var r=20,t=.1,s=.5,l=1,c=1,f=2,d=.2,v=1.5,g=2,h=4,p=e.positions,b=new n(t,r,4,16,!0);b.translate(0,.5*r,0);var x=new BAS.PrefabBufferGeometry(b,p.length);this.totalDuration=l+s,x.createAttribute("anim",2,((e,r)=>{var t=p[r];e[0]=o.mapLinear(t.y,4,-4,0,s)*o.randFloat(.9,1),e[1]=l})),x.createAttribute("bounce",2,(e=>{e[0]=o.randFloat(c,f),e[1]=o.randFloat(d,d)})),x.createAttribute("startPosition",3,((e,r)=>{p[r].toArray(e)})),x.createAttribute("rMin",4,((e,r)=>{u.copy(p[r]),u.x+=o.randFloatSpread(v),u.y+=o.randFloatSpread(v),u.z+=o.randFloatSpread(v),u.normalize(),m.setFromUnitVectors(i,u),m.toArray(e)})),x.createAttribute("rMax",4,((e,r)=>{u.copy(p[r]),u.x+=o.randFloatSpread(v),u.y-=o.randFloat(g,h),u.z+=o.randFloatSpread(v),u.normalize(),m.setFromUnitVectors(i,u),m.toArray(e)}));var y=new BAS.StandardAnimationMaterial({flatShading:!0,uniformValues:{metalness:.5,roughness:1},uniforms:{time:{type:"f",value:numberToUniformFloat(0)},hairLength:{type:"f",value:numberToUniformFloat(r)}},vertexParameters:"\n uniform float time;\n uniform float hairLength;\n\n attribute vec2 anim;\n attribute vec2 bounce;\n\n attribute vec3 startPosition;\n\n attribute vec4 rMin;\n attribute vec4 rMax;\n ",varyingParameters:"\n varying float vProgress;\n varying float vY;\n ",vertexFunctions:[BAS.ShaderChunk.ease_back_out,BAS.ShaderChunk.ease_elastic_out,BAS.ShaderChunk.ease_expo_out,BAS.ShaderChunk.quaternion_rotation],vertexPosition:"\n float progress = clamp(time - anim.x, 0.0, anim.y) / anim.y;\n\n float bounceProgress = easeElasticOut(progress, bounce.x, bounce.y);\n // float bounceProgress = easeBackOut(progress, bounce.x * 2.0);\n float growProgress = easeExpoOut(progress);\n float frc = position.y / hairLength;\n\n vY = frc;\n vProgress = growProgress;\n\n transformed.xz *= growProgress;\n\n // doesn't work with fuzz + overshoot ease, but mey give better results\n // vec4 r = mix(rMin, rMax, frc * bounceProgress);\n // transformed = rotateVector(r, transformed);\n\n // other method\n vec3 pMin = rotateVector(rMin, transformed);\n vec3 pMax = rotateVector(rMax, transformed);\n transformed = mix(pMin, pMax, frc * bounceProgress);\n\n transformed += startPosition;\n ",fragmentInit:"\n if (vProgress == 0.0 || vY > vProgress) discard;\n "});a.call(this,x,y)}animate(){return TweenMax.to(this,2,{time:this.totalDuration,ease:Power0.easeOut,repeat:-1,repeatDelay:1})}getTime(){return this.material.uniforms.time.value}setTime(e){this.material.uniforms.time.value=numberToUniformFloat(e)}setColor(e){this.material.uniforms.diffuse.value.set(e)}}class c{constructor(e){}init(e){var{engine:n}=e,o=new r(3,1,128,128),s=new t({roughness:1}),i=new a(o,s),u=new l({positions:model.vertices,normals:model.normals});u.animate(),this.model=i,n.add(u)}}export{c as default}; +import{a5 as e,bk as r,M as t,x as a,bl as n,ac as o,aq as s}from"../vendor.js";var i=new e(0,1,0),u=new e,m=new s;class l extends a{constructor(e){super(e);var r=20,t=.1,s=.5,l=1,c=1,f=2,d=.2,v=1.5,g=2,h=4,p=e.positions,b=new n(t,r,4,16,!0);b.translate(0,.5*r,0);var x=new BAS.PrefabBufferGeometry(b,p.length);this.totalDuration=l+s,x.createAttribute("anim",2,((e,r)=>{var t=p[r];e[0]=o.mapLinear(t.y,4,-4,0,s)*o.randFloat(.9,1),e[1]=l})),x.createAttribute("bounce",2,(e=>{e[0]=o.randFloat(c,f),e[1]=o.randFloat(d,d)})),x.createAttribute("startPosition",3,((e,r)=>{p[r].toArray(e)})),x.createAttribute("rMin",4,((e,r)=>{u.copy(p[r]),u.x+=o.randFloatSpread(v),u.y+=o.randFloatSpread(v),u.z+=o.randFloatSpread(v),u.normalize(),m.setFromUnitVectors(i,u),m.toArray(e)})),x.createAttribute("rMax",4,((e,r)=>{u.copy(p[r]),u.x+=o.randFloatSpread(v),u.y-=o.randFloat(g,h),u.z+=o.randFloatSpread(v),u.normalize(),m.setFromUnitVectors(i,u),m.toArray(e)}));var y=new BAS.StandardAnimationMaterial({flatShading:!0,uniformValues:{metalness:.5,roughness:1},uniforms:{time:{type:"f",value:numberToUniformFloat(0)},hairLength:{type:"f",value:numberToUniformFloat(r)}},vertexParameters:"\n uniform float time;\n uniform float hairLength;\n\n attribute vec2 anim;\n attribute vec2 bounce;\n\n attribute vec3 startPosition;\n\n attribute vec4 rMin;\n attribute vec4 rMax;\n ",varyingParameters:"\n varying float vProgress;\n varying float vY;\n ",vertexFunctions:[BAS.ShaderChunk.ease_back_out,BAS.ShaderChunk.ease_elastic_out,BAS.ShaderChunk.ease_expo_out,BAS.ShaderChunk.quaternion_rotation],vertexPosition:"\n float progress = clamp(time - anim.x, 0.0, anim.y) / anim.y;\n\n float bounceProgress = easeElasticOut(progress, bounce.x, bounce.y);\n // float bounceProgress = easeBackOut(progress, bounce.x * 2.0);\n float growProgress = easeExpoOut(progress);\n float frc = position.y / hairLength;\n\n vY = frc;\n vProgress = growProgress;\n\n transformed.xz *= growProgress;\n\n // doesn't work with fuzz + overshoot ease, but mey give better results\n // vec4 r = mix(rMin, rMax, frc * bounceProgress);\n // transformed = rotateVector(r, transformed);\n\n // other method\n vec3 pMin = rotateVector(rMin, transformed);\n vec3 pMax = rotateVector(rMax, transformed);\n transformed = mix(pMin, pMax, frc * bounceProgress);\n\n transformed += startPosition;\n ",fragmentInit:"\n if (vProgress == 0.0 || vY > vProgress) discard;\n "});a.call(this,x,y)}animate(){return TweenMax.to(this,2,{time:this.totalDuration,ease:Power0.easeOut,repeat:-1,repeatDelay:1})}getTime(){return this.material.uniforms.time.value}setTime(e){this.material.uniforms.time.value=numberToUniformFloat(e)}setColor(e){this.material.uniforms.diffuse.value.set(e)}}class c{constructor(e){}init(e){var{engine:n}=e,o=new r(3,1,128,128),s=new t({roughness:1}),i=new a(o,s),u=new l({positions:model.vertices,normals:model.normals});u.animate(),this.model=i,n.add(u)}}export{c as default}; diff --git a/docs/materials/BasFuzzyMaterial.js.gz b/docs/materials/BasFuzzyMaterial.js.gz index fa1a1b2d..2ce2b1b4 100644 Binary files a/docs/materials/BasFuzzyMaterial.js.gz and b/docs/materials/BasFuzzyMaterial.js.gz differ diff --git a/docs/materials/WaterPlaneMaterial.js b/docs/materials/WaterPlaneMaterial.js index e7abed11..1597b852 100644 --- a/docs/materials/WaterPlaneMaterial.js +++ b/docs/materials/WaterPlaneMaterial.js @@ -1 +1 @@ -export{bl as WaterPlaneMaterial}from"../vendor.js"; +export{bm as WaterPlaneMaterial}from"../vendor.js"; diff --git a/docs/vendor.js b/docs/vendor.js index aa2677e7..936f78a0 100644 --- a/docs/vendor.js +++ b/docs/vendor.js @@ -1 +1 @@ -function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function t(t){for(var n=1;n=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function a(e,t){return function(e,t){if(t.get)return t.get.call(e);return t.value}(e,l(e,t,"get"))}function o(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,l(e,t,"set"),n),n}function l(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}function c(e,t,n){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return n}function h(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function u(e,t,n){h(e,t),t.set(e,n)}function d(e,t){h(e,t),t.add(e)}var p=1,m="map-container",f=17,g=['osm','leaflet','stamen'].join("
"),v=5e12,_=[38,38],x=[_[0]/2,_[1]/2],y=[0,_[1]/2*-1],S="map/marker",b={location:{iconUrl(e){var t=e>0?e:1;return e>9&&(t="9-plus"),"".concat(S,"/location-").concat(t,".svg")},iconSize:_,iconAnchor:x,popupAnchor:y},city:{iconUrl:e=>"".concat(S,"/cities/").concat(e,".svg"),iconSize:_,iconAnchor:x,popupAnchor:y},artifact:{iconUrl:"".concat(S,"/object.svg"),iconSize:_,iconAnchor:x,popupAnchor:y}},T={strings:{title:"Click to locate yourself.",metersUnit:"meters",feetUnit:"feet",popup:"You are within {distance} {unit} from this point",outsideMapBoundsMsg:"\nIt seems like your Device has no gps sensors, or you declined our request to use gps.\n"},locateOptions:{watch:!0,enableHighAccuracy:!0}},w={fov:60,near:.01,far:500},E={maxDistance:60,minDistance:1,maxPolarAngle:Math.PI/1.9,enablePan:!1},A={ambientColor:16777215,ambientIntensity:.3,directionalColor:16777215,directionalIntensity:.8*Math.PI,directionalPosition:[60,120,28]},R=.2,C=5e3,P=[100,60,40],L="three-running",I={x:0,y:1.7,z:5},D=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"at this location.";return 0===e?e="are no artifacts":1===e?e="is 1 artifact":e>1&&(e="are ".concat(e," artifacts")),"There ".concat(e," ").concat(t)},U=1e4,N="Zoom to location",O="Visit City",F="three-audio",z="three-video",k="three-media",H="three-canvas",G="three-container",V="hud",W="hud-exit-button",j=1e4,X=(e,t)=>"function"==typeof X[t]?X[t](e):typeof e===t;X.fn=e=>"function"==typeof e,X.str=e=>"string"==typeof e,X.obj=e=>"object"==typeof e,X.arr=e=>Array.isArray(e),X.bool=e=>"boolean"==typeof e,X.num=e=>e===+e,X.int=e=>e===+e&&e===(0|e);var q=window;q.D=document,q.B=q.D.body,q.M=Math,q.NAV=q.navigator,q.UA=q.NAV.userAgent.toLowerCase()||"",q.URL=q.URL||q.webkitURL,q.LOC=q.location,q.pxRatio=q.devicePixelRatio,q.store=new class{constructor(e){var{W:t,type:n="session"}=e;try{var i=t["".concat(n,"Storage")],r="random-".concat(M.random());i.setItem(r,r),i.removeItem(r),this.store=i}catch(e){this.store={}}}setItem(e,t){var n=["setItem","getItem","removeItem"],i=n.indexOf(e);if(i>-1)throw new Error("can not overwrite store.".concat(n[i],", it's a builtin"));var r=JSON.stringify(t);return this.store[e]=r,!0}getItem(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return this.store.hasOwnProperty(e)?JSON.parse(this.store[e]):t}removeItem(e){X.fn(this.store.removeItem)?this.store.removeItem(e):delete this.store[e]}clear(){X.fn(this.store.clear)?this.store.clear():this.store={}}}({W:q,type:"session"});var Y=q.UA,Z=Y.includes("mac")&&"ontouchend"in q.D,K=["ipad","iphone","ipod"].some((e=>Y.includes(e))),J=K||Z,Q=!J&&Y.includes("macintosh"),$=Y.includes("applewebkit")&&Y.includes("safari")&&!Y.includes("crios"),ee=Y.includes("firefox")&&Y.includes("gecko")&&Y.includes("mozilla")&&!Y.includes("seamonkey"),te=(()=>{var e;if(Y.includes("chrome/")?e=Y.split("chrome/")[1]:Y.includes("samsungbrowser/")&&(e=Y.split("samsungbrowser/")[1]),e){e=e.split(".")[0];var t=parseInt(e,10);if(X.num(t))return t}})(),ne=X.num(te),ie=Y.includes("android"),re=J&&Y.includes("webxrviewer"),se=Object.freeze({__proto__:null,android:ie,chrome:ne,firefox:ee,firefoxVersion:()=>{Y.includes("firefox/")&&Y.split("firefox/")[1]},iDevice:K,ios:J,ios13:Z,macos:Q,safari:$,version:te,webxrviewer:re});const ae="154",oe={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},le={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},ce=1,he=2,ue=3,de=0,pe=1,me=2,fe=1,ge=2,ve=100,_e=0,xe=1,ye=2,Me=0,Se=1,be=2,Te=3,we=4,Ee=5,Ae=300,Re=301,Ce=302,Pe=303,Le=304,Ie=306,De=1e3,Ue=1001,Ne=1002,Oe=1003,Fe=1004,ze=1005,Be=1006,ke=1007,He=1008,Ge=1009,Ve=1012,We=1013,je=1014,Xe=1015,qe=1016,Ye=1017,Ze=1018,Ke=1020,Je=1023,Qe=1026,$e=1027,et=1029,tt=1031,nt=1033,it=33776,rt=33777,st=33778,at=33779,ot=35840,lt=35841,ct=35842,ht=35843,ut=37492,dt=37496,pt=37808,mt=37809,ft=37810,gt=37811,vt=37812,_t=37813,xt=37814,yt=37815,Mt=37816,St=37817,bt=37818,Tt=37819,wt=37820,Et=37821,At=36492,Rt=36284,Ct=36285,Pt=36286,Lt=2200,It=2300,Dt=2301,Ut=2302,Nt=2400,Ot=2401,Ft=2402,zt=2500,Bt=2501,kt=3e3,Ht=3001,Gt="",Vt="srgb",Wt="srgb-linear",jt="display-p3",Xt=7680,qt=35044,Yt="300 es",Zt=1035,Kt=2e3,Jt=2001;class Qt{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const n=t.slice(0);for(let t=0,i=n.length;t>8&255]+$t[e>>16&255]+$t[e>>24&255]+"-"+$t[255&t]+$t[t>>8&255]+"-"+$t[t>>16&15|64]+$t[t>>24&255]+"-"+$t[63&n|128]+$t[n>>8&255]+"-"+$t[n>>16&255]+$t[n>>24&255]+$t[255&i]+$t[i>>8&255]+$t[i>>16&255]+$t[i>>24&255]).toLowerCase()}function sn(e,t,n){return Math.max(t,Math.min(n,e))}function an(e,t){return(e%t+t)%t}function on(e,t,n){return(1-n)*e+n*t}function ln(e){return 0==(e&e-1)&&0!==e}function cn(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function hn(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function un(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function dn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}const pn={DEG2RAD:tn,RAD2DEG:nn,generateUUID:rn,clamp:sn,euclideanModulo:an,mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:on,damp:function(e,t,n,i){return on(e,t,1-Math.exp(-n*i))},pingpong:function(e,t=1){return t-Math.abs(an(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(en=e);let t=en+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296},degToRad:function(e){return e*tn},radToDeg:function(e){return e*nn},isPowerOfTwo:ln,ceilPowerOfTwo:cn,floorPowerOfTwo:hn,setQuaternionFromProperEuler:function(e,t,n,i,r){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),c=s((t+i)/2),h=a((t+i)/2),u=s((t-i)/2),d=a((t-i)/2),p=s((i-t)/2),m=a((i-t)/2);switch(r){case"XYX":e.set(o*h,l*u,l*d,o*c);break;case"YZY":e.set(l*d,o*h,l*u,o*c);break;case"ZXZ":e.set(l*u,l*d,o*h,o*c);break;case"XZX":e.set(o*h,l*m,l*p,o*c);break;case"YXY":e.set(l*p,o*h,l*m,o*c);break;case"ZYZ":e.set(l*m,l*p,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:dn,denormalize:un};class mn{constructor(e=0,t=0){mn.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(sn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class fn{constructor(e,t,n,i,r,s,a,o,l){fn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,s,a,o,l)}set(e,t,n,i,r,s,a,o,l){const c=this.elements;return c[0]=e,c[1]=i,c[2]=a,c[3]=t,c[4]=r,c[5]=o,c[6]=n,c[7]=s,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,s=n[0],a=n[3],o=n[6],l=n[1],c=n[4],h=n[7],u=n[2],d=n[5],p=n[8],m=i[0],f=i[3],g=i[6],v=i[1],_=i[4],x=i[7],y=i[2],M=i[5],S=i[8];return r[0]=s*m+a*v+o*y,r[3]=s*f+a*_+o*M,r[6]=s*g+a*x+o*S,r[1]=l*m+c*v+h*y,r[4]=l*f+c*_+h*M,r[7]=l*g+c*x+h*S,r[2]=u*m+d*v+p*y,r[5]=u*f+d*_+p*M,r[8]=u*g+d*x+p*S,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],l=e[7],c=e[8];return t*s*c-t*a*l-n*r*c+n*a*o+i*r*l-i*s*o}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],l=e[7],c=e[8],h=c*s-a*l,u=a*o-c*r,d=l*r-s*o,p=t*h+n*u+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return e[0]=h*m,e[1]=(i*l-c*n)*m,e[2]=(a*n-i*s)*m,e[3]=u*m,e[4]=(c*t-i*o)*m,e[5]=(i*r-a*t)*m,e[6]=d*m,e[7]=(n*o-l*t)*m,e[8]=(s*t-n*r)*m,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,a){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*s+l*a)+s+e,-i*l,i*o,-i*(-l*s+o*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(gn.makeScale(e,t)),this}rotate(e){return this.premultiply(gn.makeRotation(-e)),this}translate(e,t){return this.premultiply(gn.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const gn=new fn;function vn(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}const _n={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function xn(e,t){return new _n[e](t)}function yn(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}const Mn={};function Sn(e){e in Mn||(Mn[e]=!0,console.warn(e))}function bn(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Tn(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}const wn=(new fn).fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),En=(new fn).fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);const An={[Wt]:e=>e,[Vt]:e=>e.convertSRGBToLinear(),[jt]:function(e){return e.convertSRGBToLinear().applyMatrix3(En)}},Rn={[Wt]:e=>e,[Vt]:e=>e.convertLinearToSRGB(),[jt]:function(e){return e.applyMatrix3(wn).convertLinearToSRGB()}},Cn={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(e){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!e},get workingColorSpace(){return Wt},set workingColorSpace(e){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,n){if(!1===this.enabled||t===n||!t||!n)return e;const i=An[t],r=Rn[n];if(void 0===i||void 0===r)throw new Error(`Unsupported color space conversion, "${t}" to "${n}".`);return r(i(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)}};let Pn;class Ln{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===Pn&&(Pn=yn("canvas")),Pn.width=e.width,Pn.height=e.height;const n=Pn.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Pn}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=yn("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;e0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Ae)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case De:e.x=e.x-Math.floor(e.x);break;case Ue:e.x=e.x<0?0:1;break;case Ne:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case De:e.y=e.y-Math.floor(e.y);break;case Ue:e.y=e.y<0?0:1;break;case Ne:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return Sn("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Vt?Ht:kt}set encoding(e){Sn("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Ht?Vt:Gt}}On.DEFAULT_IMAGE=null,On.DEFAULT_MAPPING=Ae,On.DEFAULT_ANISOTROPY=1;class Fn{constructor(e=0,t=0,n=0,i=1){Fn.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r;const s=.01,a=.1,o=e.elements,l=o[0],c=o[4],h=o[8],u=o[1],d=o[5],p=o[9],m=o[2],f=o[6],g=o[10];if(Math.abs(c-u)o&&e>v?ev?o=0?1:-1,i=1-t*t;if(i>Number.EPSILON){const r=Math.sqrt(i),s=Math.atan2(r,t*n);e=Math.sin(e*s)/r,a=Math.sin(a*s)/r}const r=a*n;if(o=o*e+u*r,l=l*e+d*r,c=c*e+p*r,h=h*e+m*r,e===1-a){const e=1/Math.sqrt(o*o+l*l+c*c+h*h);o*=e,l*=e,c*=e,h*=e}}e[t]=o,e[t+1]=l,e[t+2]=c,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,r,s){const a=n[i],o=n[i+1],l=n[i+2],c=n[i+3],h=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return e[t]=a*p+c*h+o*d-l*u,e[t+1]=o*p+c*u+l*h-a*d,e[t+2]=l*p+c*d+a*u-o*h,e[t+3]=c*p-a*h-o*u-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const n=e._x,i=e._y,r=e._z,s=e._order,a=Math.cos,o=Math.sin,l=a(n/2),c=a(i/2),h=a(r/2),u=o(n/2),d=o(i/2),p=o(r/2);switch(s){case"XYZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"YXZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"ZXY":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"ZYX":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"YZX":this._x=u*c*h+l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h-u*d*p;break;case"XZY":this._x=u*c*h-l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],a=t[5],o=t[9],l=t[2],c=t[6],h=t[10],u=n+a+h;if(u>0){const e=.5/Math.sqrt(u+1);this._w=.25/e,this._x=(c-o)*e,this._y=(r-l)*e,this._z=(s-i)*e}else if(n>a&&n>h){const e=2*Math.sqrt(1+n-a-h);this._w=(c-o)/e,this._x=.25*e,this._y=(i+s)/e,this._z=(r+l)/e}else if(a>h){const e=2*Math.sqrt(1+a-n-h);this._w=(r-l)/e,this._x=(i+s)/e,this._y=.25*e,this._z=(o+c)/e}else{const e=2*Math.sqrt(1+h-n-a);this._w=(s-i)/e,this._x=(r+l)/e,this._y=(o+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(sn(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const i=Math.min(1,t/n);return this.slerp(e,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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,s=e._w,a=t._x,o=t._y,l=t._z,c=t._w;return this._x=n*c+s*a+i*l-r*o,this._y=i*c+s*o+r*a-n*l,this._z=r*c+s*l+n*o-i*a,this._w=s*c-n*a-i*o-r*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,i=this._y,r=this._z,s=this._w;let a=s*e._w+n*e._x+i*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=s,this._x=n,this._y=i,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const e=1-t;return this._w=e*s+t*this._w,this._x=e*n+t*this._x,this._y=e*i+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(o),c=Math.atan2(l,a),h=Math.sin((1-t)*c)/l,u=Math.sin(t*c)/l;return this._w=s*h+this._w*u,this._x=n*h+this._x*u,this._y=i*h+this._y*u,this._z=r*h+this._z*u,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(r),n*Math.cos(r),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Gn{constructor(e=0,t=0,n=0){Gn.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Wn.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Wn.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,s=e.y,a=e.z,o=e.w,l=o*t+s*i-a*n,c=o*n+a*t-r*i,h=o*i+r*n-s*t,u=-r*t-s*n-a*i;return this.x=l*o+u*-r+c*-a-h*-s,this.y=c*o+u*-s+h*-r-l*-a,this.z=h*o+u*-a+l*-s-c*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,s=t.x,a=t.y,o=t.z;return this.x=i*o-r*a,this.y=r*s-n*o,this.z=n*a-i*s,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Vn.copy(this).projectOnVector(e),this.sub(Vn)}reflect(e){return this.sub(Vn.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(sn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Vn=new Gn,Wn=new Hn;class jn{constructor(e=new Gn(Infinity,Infinity,Infinity),t=new Gn(-Infinity,-Infinity,-Infinity)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,qn),qn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ti),ni.subVectors(this.max,ti),Zn.subVectors(e.a,ti),Kn.subVectors(e.b,ti),Jn.subVectors(e.c,ti),Qn.subVectors(Kn,Zn),$n.subVectors(Jn,Kn),ei.subVectors(Zn,Jn);let t=[0,-Qn.z,Qn.y,0,-$n.z,$n.y,0,-ei.z,ei.y,Qn.z,0,-Qn.x,$n.z,0,-$n.x,ei.z,0,-ei.x,-Qn.y,Qn.x,0,-$n.y,$n.x,0,-ei.y,ei.x,0];return!!si(t,Zn,Kn,Jn,ni)&&(t=[1,0,0,0,1,0,0,0,1],!!si(t,Zn,Kn,Jn,ni)&&(ii.crossVectors(Qn,$n),t=[ii.x,ii.y,ii.z],si(t,Zn,Kn,Jn,ni)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,qn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(qn).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(Xn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Xn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Xn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Xn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Xn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Xn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Xn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Xn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Xn)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Xn=[new Gn,new Gn,new Gn,new Gn,new Gn,new Gn,new Gn,new Gn],qn=new Gn,Yn=new jn,Zn=new Gn,Kn=new Gn,Jn=new Gn,Qn=new Gn,$n=new Gn,ei=new Gn,ti=new Gn,ni=new Gn,ii=new Gn,ri=new Gn;function si(e,t,n,i,r){for(let s=0,a=e.length-3;s<=a;s+=3){ri.fromArray(e,s);const a=r.x*Math.abs(ri.x)+r.y*Math.abs(ri.y)+r.z*Math.abs(ri.z),o=t.dot(ri),l=n.dot(ri),c=i.dot(ri);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>a)return!1}return!0}const ai=new jn,oi=new Gn,li=new Gn;class ci{constructor(e=new Gn,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):ai.setFromPoints(e).getCenter(n);let i=0;for(let t=0,r=e.length;tthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;oi.subVectors(e,this.center);const t=oi.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(oi,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(li.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(oi.copy(e.center).add(li)),this.expandByPoint(oi.copy(e.center).sub(li))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const hi=new Gn,ui=new Gn,di=new Gn,pi=new Gn,mi=new Gn,fi=new Gn,gi=new Gn;class vi{constructor(e=new Gn,t=new Gn(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,hi)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=hi.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(hi.copy(this.origin).addScaledVector(this.direction,t),hi.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){ui.copy(e).add(t).multiplyScalar(.5),di.copy(t).sub(e).normalize(),pi.copy(this.origin).sub(ui);const r=.5*e.distanceTo(t),s=-this.direction.dot(di),a=pi.dot(this.direction),o=-pi.dot(di),l=pi.lengthSq(),c=Math.abs(1-s*s);let h,u,d,p;if(c>0)if(h=s*o-a,u=s*a-o,p=r*c,h>=0)if(u>=-p)if(u<=p){const e=1/c;h*=e,u*=e,d=h*(h+s*u+2*a)+u*(s*h+u+2*o)+l}else u=r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u=-r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u<=-p?(h=Math.max(0,-(-s*r+a)),u=h>0?-r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l):u<=p?(h=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+l):(h=Math.max(0,-(s*r+a)),u=h>0?r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l);else u=s>0?-r:r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(ui).addScaledVector(di,u),d}intersectSphere(e,t){hi.subVectors(e.center,this.origin);const n=hi.dot(this.direction),i=hi.dot(hi)-n*n,r=e.radius*e.radius;if(i>r)return null;const s=Math.sqrt(r-i),a=n-s,o=n+s;return o<0?null:a<0?this.at(o,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,s,a,o;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,u=this.origin;return l>=0?(n=(e.min.x-u.x)*l,i=(e.max.x-u.x)*l):(n=(e.max.x-u.x)*l,i=(e.min.x-u.x)*l),c>=0?(r=(e.min.y-u.y)*c,s=(e.max.y-u.y)*c):(r=(e.max.y-u.y)*c,s=(e.min.y-u.y)*c),n>s||r>i?null:((r>n||isNaN(n))&&(n=r),(s=0?(a=(e.min.z-u.z)*h,o=(e.max.z-u.z)*h):(a=(e.max.z-u.z)*h,o=(e.min.z-u.z)*h),n>o||a>i?null:((a>n||n!=n)&&(n=a),(o=0?n:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,hi)}intersectTriangle(e,t,n,i,r){mi.subVectors(t,e),fi.subVectors(n,e),gi.crossVectors(mi,fi);let s,a=this.direction.dot(gi);if(a>0){if(i)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}pi.subVectors(this.origin,e);const o=s*this.direction.dot(fi.crossVectors(pi,fi));if(o<0)return null;const l=s*this.direction.dot(mi.cross(pi));if(l<0)return null;if(o+l>a)return null;const c=-s*pi.dot(gi);return c<0?null:this.at(c/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class _i{constructor(e,t,n,i,r,s,a,o,l,c,h,u,d,p,m,f){_i.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,s,a,o,l,c,h,u,d,p,m,f)}set(e,t,n,i,r,s,a,o,l,c,h,u,d,p,m,f){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=c,g[10]=h,g[14]=u,g[3]=d,g[7]=p,g[11]=m,g[15]=f,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 _i).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/xi.setFromMatrixColumn(e,0).length(),r=1/xi.setFromMatrixColumn(e,1).length(),s=1/xi.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,s=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),h=Math.sin(r);if("XYZ"===e.order){const e=s*c,n=s*h,i=a*c,r=a*h;t[0]=o*c,t[4]=-o*h,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-a*o,t[2]=r-e*l,t[6]=i+n*l,t[10]=s*o}else if("YXZ"===e.order){const e=o*c,n=o*h,i=l*c,r=l*h;t[0]=e+r*a,t[4]=i*a-n,t[8]=s*l,t[1]=s*h,t[5]=s*c,t[9]=-a,t[2]=n*a-i,t[6]=r+e*a,t[10]=s*o}else if("ZXY"===e.order){const e=o*c,n=o*h,i=l*c,r=l*h;t[0]=e-r*a,t[4]=-s*h,t[8]=i+n*a,t[1]=n+i*a,t[5]=s*c,t[9]=r-e*a,t[2]=-s*l,t[6]=a,t[10]=s*o}else if("ZYX"===e.order){const e=s*c,n=s*h,i=a*c,r=a*h;t[0]=o*c,t[4]=i*l-n,t[8]=e*l+r,t[1]=o*h,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=a*o,t[10]=s*o}else if("YZX"===e.order){const e=s*o,n=s*l,i=a*o,r=a*l;t[0]=o*c,t[4]=r-e*h,t[8]=i*h+n,t[1]=h,t[5]=s*c,t[9]=-a*c,t[2]=-l*c,t[6]=n*h+i,t[10]=e-r*h}else if("XZY"===e.order){const e=s*o,n=s*l,i=a*o,r=a*l;t[0]=o*c,t[4]=-h,t[8]=l*c,t[1]=e*h+r,t[5]=s*c,t[9]=n*h-i,t[2]=i*h-n,t[6]=a*c,t[10]=r*h+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Mi,e,Si)}lookAt(e,t,n){const i=this.elements;return wi.subVectors(e,t),0===wi.lengthSq()&&(wi.z=1),wi.normalize(),bi.crossVectors(n,wi),0===bi.lengthSq()&&(1===Math.abs(n.z)?wi.x+=1e-4:wi.z+=1e-4,wi.normalize(),bi.crossVectors(n,wi)),bi.normalize(),Ti.crossVectors(wi,bi),i[0]=bi.x,i[4]=Ti.x,i[8]=wi.x,i[1]=bi.y,i[5]=Ti.y,i[9]=wi.y,i[2]=bi.z,i[6]=Ti.z,i[10]=wi.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,s=n[0],a=n[4],o=n[8],l=n[12],c=n[1],h=n[5],u=n[9],d=n[13],p=n[2],m=n[6],f=n[10],g=n[14],v=n[3],_=n[7],x=n[11],y=n[15],M=i[0],S=i[4],b=i[8],T=i[12],w=i[1],E=i[5],A=i[9],R=i[13],C=i[2],P=i[6],L=i[10],I=i[14],D=i[3],U=i[7],N=i[11],O=i[15];return r[0]=s*M+a*w+o*C+l*D,r[4]=s*S+a*E+o*P+l*U,r[8]=s*b+a*A+o*L+l*N,r[12]=s*T+a*R+o*I+l*O,r[1]=c*M+h*w+u*C+d*D,r[5]=c*S+h*E+u*P+d*U,r[9]=c*b+h*A+u*L+d*N,r[13]=c*T+h*R+u*I+d*O,r[2]=p*M+m*w+f*C+g*D,r[6]=p*S+m*E+f*P+g*U,r[10]=p*b+m*A+f*L+g*N,r[14]=p*T+m*R+f*I+g*O,r[3]=v*M+_*w+x*C+y*D,r[7]=v*S+_*E+x*P+y*U,r[11]=v*b+_*A+x*L+y*N,r[15]=v*T+_*R+x*I+y*O,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],a=e[5],o=e[9],l=e[13],c=e[2],h=e[6],u=e[10],d=e[14];return e[3]*(+r*o*h-i*l*h-r*a*u+n*l*u+i*a*d-n*o*d)+e[7]*(+t*o*d-t*l*u+r*s*u-i*s*d+i*l*c-r*o*c)+e[11]*(+t*l*h-t*a*d-r*s*h+n*s*d+r*a*c-n*l*c)+e[15]*(-i*a*c-t*o*h+t*a*u+i*s*h-n*s*u+n*o*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],l=e[7],c=e[8],h=e[9],u=e[10],d=e[11],p=e[12],m=e[13],f=e[14],g=e[15],v=h*f*l-m*u*l+m*o*d-a*f*d-h*o*g+a*u*g,_=p*u*l-c*f*l-p*o*d+s*f*d+c*o*g-s*u*g,x=c*m*l-p*h*l+p*a*d-s*m*d-c*a*g+s*h*g,y=p*h*o-c*m*o-p*a*u+s*m*u+c*a*f-s*h*f,M=t*v+n*_+i*x+r*y;if(0===M)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const S=1/M;return e[0]=v*S,e[1]=(m*u*r-h*f*r-m*i*d+n*f*d+h*i*g-n*u*g)*S,e[2]=(a*f*r-m*o*r+m*i*l-n*f*l-a*i*g+n*o*g)*S,e[3]=(h*o*r-a*u*r-h*i*l+n*u*l+a*i*d-n*o*d)*S,e[4]=_*S,e[5]=(c*f*r-p*u*r+p*i*d-t*f*d-c*i*g+t*u*g)*S,e[6]=(p*o*r-s*f*r-p*i*l+t*f*l+s*i*g-t*o*g)*S,e[7]=(s*u*r-c*o*r+c*i*l-t*u*l-s*i*d+t*o*d)*S,e[8]=x*S,e[9]=(p*h*r-c*m*r-p*n*d+t*m*d+c*n*g-t*h*g)*S,e[10]=(s*m*r-p*a*r+p*n*l-t*m*l-s*n*g+t*a*g)*S,e[11]=(c*a*r-s*h*r-c*n*l+t*h*l+s*n*d-t*a*d)*S,e[12]=y*S,e[13]=(c*m*i-p*h*i+p*n*u-t*m*u-c*n*f+t*h*f)*S,e[14]=(p*a*i-s*m*i-p*n*o+t*m*o+s*n*f-t*a*f)*S,e[15]=(s*h*i-c*a*i+c*n*o-t*h*o-s*n*u+t*a*u)*S,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,s=e.x,a=e.y,o=e.z,l=r*s,c=r*a;return this.set(l*s+n,l*a-i*o,l*o+i*a,0,l*a+i*o,c*a+n,c*o-i*s,0,l*o-i*a,c*o+i*s,r*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,s=t._y,a=t._z,o=t._w,l=r+r,c=s+s,h=a+a,u=r*l,d=r*c,p=r*h,m=s*c,f=s*h,g=a*h,v=o*l,_=o*c,x=o*h,y=n.x,M=n.y,S=n.z;return i[0]=(1-(m+g))*y,i[1]=(d+x)*y,i[2]=(p-_)*y,i[3]=0,i[4]=(d-x)*M,i[5]=(1-(u+g))*M,i[6]=(f+v)*M,i[7]=0,i[8]=(p+_)*S,i[9]=(f-v)*S,i[10]=(1-(u+m))*S,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=xi.set(i[0],i[1],i[2]).length();const s=xi.set(i[4],i[5],i[6]).length(),a=xi.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],yi.copy(this);const o=1/r,l=1/s,c=1/a;return yi.elements[0]*=o,yi.elements[1]*=o,yi.elements[2]*=o,yi.elements[4]*=l,yi.elements[5]*=l,yi.elements[6]*=l,yi.elements[8]*=c,yi.elements[9]*=c,yi.elements[10]*=c,t.setFromRotationMatrix(yi),n.x=r,n.y=s,n.z=a,this}makePerspective(e,t,n,i,r,s,a=2e3){const o=this.elements,l=2*r/(t-e),c=2*r/(n-i),h=(t+e)/(t-e),u=(n+i)/(n-i);let d,p;if(a===Kt)d=-(s+r)/(s-r),p=-2*s*r/(s-r);else{if(a!==Jt)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);d=-s/(s-r),p=-s*r/(s-r)}return o[0]=l,o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=c,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,i,r,s,a=2e3){const o=this.elements,l=1/(t-e),c=1/(n-i),h=1/(s-r),u=(t+e)*l,d=(n+i)*c;let p,m;if(a===Kt)p=(s+r)*h,m=-2*h;else{if(a!==Jt)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=r*h,m=-1*h}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=m,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const xi=new Gn,yi=new _i,Mi=new Gn(0,0,0),Si=new Gn(1,1,1),bi=new Gn,Ti=new Gn,wi=new Gn,Ei=new _i,Ai=new Hn;class Ri{constructor(e=0,t=0,n=0,i=Ri.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],s=i[4],a=i[8],o=i[1],l=i[5],c=i[9],h=i[2],u=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(sn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-sn(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(sn(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-sn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(sn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-sn(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Ei.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ei,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Ai.setFromEuler(this),this.setFromQuaternion(Ai,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ri.DEFAULT_ORDER="XYZ";class Ci{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(n=n.concat(r))}return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ni,e,Oi),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Ni,Fi,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const n=t.shapes;if(Array.isArray(n))for(let t=0,i=n.length;t0){i.children=[];for(let t=0;t0){i.animations=[];for(let t=0;t0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),h.length>0&&(n.nodes=h)}return n.object=i,n;function s(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){Wi.subVectors(i,t),ji.subVectors(n,t),Xi.subVectors(e,t);const s=Wi.dot(Wi),a=Wi.dot(ji),o=Wi.dot(Xi),l=ji.dot(ji),c=ji.dot(Xi),h=s*l-a*a;if(0===h)return r.set(-2,-1,-1);const u=1/h,d=(l*o-a*c)*u,p=(s*c-a*o)*u;return r.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,qi),qi.x>=0&&qi.y>=0&&qi.x+qi.y<=1}static getUV(e,t,n,i,r,s,a,o){return!1===er&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),er=!0),this.getInterpolation(e,t,n,i,r,s,a,o)}static getInterpolation(e,t,n,i,r,s,a,o){return this.getBarycoord(e,t,n,i,qi),o.setScalar(0),o.addScaledVector(r,qi.x),o.addScaledVector(s,qi.y),o.addScaledVector(a,qi.z),o}static isFrontFacing(e,t,n,i){return Wi.subVectors(n,t),ji.subVectors(e,t),Wi.cross(ji).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Wi.subVectors(this.c,this.b),ji.subVectors(this.a,this.b),.5*Wi.cross(ji).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return tr.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return tr.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,r){return!1===er&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),er=!0),tr.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}getInterpolation(e,t,n,i,r){return tr.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return tr.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return tr.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let s,a;Yi.subVectors(i,n),Zi.subVectors(r,n),Ji.subVectors(e,n);const o=Yi.dot(Ji),l=Zi.dot(Ji);if(o<=0&&l<=0)return t.copy(n);Qi.subVectors(e,i);const c=Yi.dot(Qi),h=Zi.dot(Qi);if(c>=0&&h<=c)return t.copy(i);const u=o*h-c*l;if(u<=0&&o>=0&&c<=0)return s=o/(o-c),t.copy(n).addScaledVector(Yi,s);$i.subVectors(e,r);const d=Yi.dot($i),p=Zi.dot($i);if(p>=0&&d<=p)return t.copy(r);const m=d*l-o*p;if(m<=0&&l>=0&&p<=0)return a=l/(l-p),t.copy(n).addScaledVector(Zi,a);const f=c*p-d*h;if(f<=0&&h-c>=0&&d-p>=0)return Ki.subVectors(r,i),a=(h-c)/(h-c+(d-p)),t.copy(i).addScaledVector(Ki,a);const g=1/(f+m+u);return s=m*g,a=u*g,t.copy(n).addScaledVector(Yi,s).addScaledVector(Zi,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let nr=0;class ir extends Qt{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:nr++}),this.uuid=rn(),this.name="",this.type="Material",this.blending=1,this.side=de,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=ve,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Xt,this.stencilZFail=Xt,this.stencilZPass=Xt,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const n=e[t];if(void 0===n){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&Infinity!==this.attenuationDistance&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),this.side!==de&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=this.alphaHash),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.forceSinglePass&&(n.forceSinglePass=this.forceSinglePass),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){const t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let i=0;i!==e;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}const rr={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},sr={h:0,s:0,l:0},ar={h:0,s:0,l:0};function or(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}class lr{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(void 0===t&&void 0===n){const t=e;t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Vt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Cn.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=Cn.workingColorSpace){return this.r=e,this.g=t,this.b=n,Cn.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=Cn.workingColorSpace){if(e=an(e,1),t=sn(t,0,1),n=sn(n,0,1),0===t)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=or(r,i,e+1/3),this.g=or(r,i,e),this.b=or(r,i,e-1/3)}return Cn.toWorkingColorSpace(this,i),this}setStyle(e,t=Vt){function n(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(6===r)return this.setHex(parseInt(n,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Vt){const n=rr[e.toLowerCase()];return void 0!==n?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=bn(e.r),this.g=bn(e.g),this.b=bn(e.b),this}copyLinearToSRGB(e){return this.r=Tn(e.r),this.g=Tn(e.g),this.b=Tn(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Vt){return Cn.fromWorkingColorSpace(cr.copy(this),e),65536*Math.round(sn(255*cr.r,0,255))+256*Math.round(sn(255*cr.g,0,255))+Math.round(sn(255*cr.b,0,255))}getHexString(e=Vt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Cn.workingColorSpace){Cn.fromWorkingColorSpace(cr.copy(this),t);const n=cr.r,i=cr.g,r=cr.b,s=Math.max(n,i,r),a=Math.min(n,i,r);let o,l;const c=(a+s)/2;if(a===s)o=0,l=0;else{const e=s-a;switch(l=c<=.5?e/(s+a):e/(2-s-a),s){case n:o=(i-r)/e+(i>-t-14,i[256|e]=1024>>-t-14|32768,r[e]=-t-1,r[256|e]=-t-1):t<=15?(i[e]=t+15<<10,i[256|e]=t+15<<10|32768,r[e]=13,r[256|e]=13):t<128?(i[e]=31744,i[256|e]=64512,r[e]=24,r[256|e]=24):(i[e]=31744,i[256|e]=64512,r[e]=13,r[256|e]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;0==(8388608&t);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,s[e]=t|n}for(let e=1024;e<2048;++e)s[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)a[e]=e<<23;a[31]=1199570944,a[32]=2147483648;for(let e=33;e<63;++e)a[e]=2147483648+(e-32<<23);a[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(o[e]=1024);return{floatView:t,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function pr(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=sn(e,-65504,65504),ur.floatView[0]=e;const t=ur.uint32View[0],n=t>>23&511;return ur.baseTable[n]+((8388607&t)>>ur.shiftTable[n])}function mr(e){const t=e>>10;return ur.uint32View[0]=ur.mantissaTable[ur.offsetTable[t]+(1023&e)]+ur.exponentTable[t],ur.floatView[0]}const fr={toHalfFloat:pr,fromHalfFloat:mr},gr=new Gn,vr=new mn;class _r{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=qt,this.updateRange={offset:0,count:-1},this.gpuType=Xe,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const t in n){const i=n[t];e.data.attributes[t]=i.toJSON(e.data)}const i={};let r=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],s=[];for(let t=0,i=n.length;t0&&(i[t]=s,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const i=e.attributes;for(const e in i){const n=i[e];this.setAttribute(e,n.clone(t))}const r=e.morphAttributes;for(const e in r){const n=[],i=r[e];for(let e=0,r=i.length;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2)return}Pr.copy(r).invert(),Lr.copy(e.ray).applyMatrix4(Pr),null!==n.boundingBox&&!1===Lr.intersectsBox(n.boundingBox)||this._computeIntersections(e,t,Lr)}}_computeIntersections(e,t,n){let i;const r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,h=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==a)if(Array.isArray(s))for(let r=0,o=u.length;rn.far?null:{distance:c,point:Xr.clone(),object:e}}(e,t,n,i,Ur,Nr,Or,jr);if(h){r&&(Br.fromBufferAttribute(r,o),kr.fromBufferAttribute(r,l),Hr.fromBufferAttribute(r,c),h.uv=tr.getInterpolation(jr,Ur,Nr,Or,Br,kr,Hr,new mn)),s&&(Br.fromBufferAttribute(s,o),kr.fromBufferAttribute(s,l),Hr.fromBufferAttribute(s,c),h.uv1=tr.getInterpolation(jr,Ur,Nr,Or,Br,kr,Hr,new mn),h.uv2=h.uv1),a&&(Gr.fromBufferAttribute(a,o),Vr.fromBufferAttribute(a,l),Wr.fromBufferAttribute(a,c),h.normal=tr.getInterpolation(jr,Ur,Nr,Or,Gr,Vr,Wr,new Gn),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const e={a:o,b:l,c:c,normal:new Gn,materialIndex:0};tr.getNormal(Ur,Nr,Or,e.normal),h.face=e}return h}class Zr extends Cr{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};const a=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);const o=[],l=[],c=[],h=[];let u=0,d=0;function p(e,t,n,i,r,s,p,m,f,g,v){const _=s/f,x=p/g,y=s/2,M=p/2,S=m/2,b=f+1,T=g+1;let w=0,E=0;const A=new Gn;for(let s=0;s0?1:-1,c.push(A.x,A.y,A.z),h.push(o/f),h.push(1-s/g),w+=1}}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class ts extends Vi{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new _i,this.projectionMatrix=new _i,this.projectionMatrixInverse=new _i,this.coordinateSystem=Kt}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}class ns extends ts{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*nn*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*tn*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*nn*Math.atan(Math.tan(.5*tn*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,r,s){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*tn*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const s=this.view;if(null!==this.view&&this.view.enabled){const e=s.fullWidth,a=s.fullHeight;r+=s.offsetX*i/e,t-=s.offsetY*n/a,i*=s.width/e,n*=s.height/a}const a=this.filmOffset;0!==a&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const is=-90;class rs extends Vi{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null;const i=new ns(is,1,e,t);i.layers=this.layers,this.add(i);const r=new ns(is,1,e,t);r.layers=this.layers,this.add(r);const s=new ns(is,1,e,t);s.layers=this.layers,this.add(s);const a=new ns(is,1,e,t);a.layers=this.layers,this.add(a);const o=new ns(is,1,e,t);o.layers=this.layers,this.add(o);const l=new ns(is,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,a,o]=t;for(const e of t)this.remove(e);if(e===Kt)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(e!==Jt)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[i,r,s,a,o,l]=this.children,c=e.getRenderTarget(),h=e.toneMapping,u=e.xr.enabled;e.toneMapping=Me,e.xr.enabled=!1;const d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,r),e.setRenderTarget(n,2),e.render(t,s),e.setRenderTarget(n,3),e.render(t,a),e.setRenderTarget(n,4),e.render(t,o),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(c),e.toneMapping=h,e.xr.enabled=u,n.texture.needsPMREMUpdate=!0}}class ss extends On{constructor(e,t,n,i,r,s,a,o,l,c){super(e=void 0!==e?e:[],t=void 0!==t?t:Re,n,i,r,s,a,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class as extends zn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];void 0!==t.encoding&&(Sn("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===Ht?Vt:Gt),this.texture=new ss(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:Be}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},i=new Zr(5,5,5),r=new es({name:"CubemapFromEquirect",uniforms:Kr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:pe,blending:0});r.uniforms.tEquirect.value=t;const s=new qr(i,r),a=t.minFilter;t.minFilter===He&&(t.minFilter=Be);return new rs(1,10,this).update(e,s),t.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(e,t,n,i){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(r)}}const os=new Gn,ls=new Gn,cs=new fn;class hs{constructor(e=new Gn(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=os.subVectors(n,t).cross(ls.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(os),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||cs.getNormalMatrix(e),i=this.coplanarPoint(os).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const us=new ci,ds=new Gn;class ps{constructor(e=new hs,t=new hs,n=new hs,i=new hs,r=new hs,s=new hs){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(s),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2e3){const n=this.planes,i=e.elements,r=i[0],s=i[1],a=i[2],o=i[3],l=i[4],c=i[5],h=i[6],u=i[7],d=i[8],p=i[9],m=i[10],f=i[11],g=i[12],v=i[13],_=i[14],x=i[15];if(n[0].setComponents(o-r,u-l,f-d,x-g).normalize(),n[1].setComponents(o+r,u+l,f+d,x+g).normalize(),n[2].setComponents(o+s,u+c,f+p,x+v).normalize(),n[3].setComponents(o-s,u-c,f-p,x-v).normalize(),n[4].setComponents(o-a,u-h,f-m,x-_).normalize(),t===Kt)n[5].setComponents(o+a,u+h,f+m,x+_).normalize();else{if(t!==Jt)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);n[5].setComponents(a,h,m,_).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),us.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),us.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(us)}intersectsSprite(e){return us.center.set(0,0,0),us.radius=.7071067811865476,us.applyMatrix4(e.matrixWorld),this.intersectsSphere(us)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,ds.y=i.normal.y>0?e.max.y:e.min.y,ds.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ds)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function ms(){let e=null,t=!1,n=null,i=null;function r(t,s){n(t,s),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function fs(e,t){const n=t.isWebGL2,i=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),i.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const n=i.get(t);n&&(e.deleteBuffer(n.buffer),i.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){const e=i.get(t);return void((!e||e.version 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn 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 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tanisotropyV /= material.anisotropy;\n\tmaterial.anisotropy = saturate( material.anisotropy );\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat 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 ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid 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 ) {\n#else\nvoid 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 ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, vMapUv );\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},_s={common:{diffuse:{value:new lr(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new fn},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new fn}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new fn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new fn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new fn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new fn},normalScale:{value:new mn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new fn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new fn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new fn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new fn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new lr(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{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 lr(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0},uvTransform:{value:new fn}},sprite:{diffuse:{value:new lr(16777215)},opacity:{value:1},center:{value:new mn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new fn},alphaMap:{value:null},alphaMapTransform:{value:new fn},alphaTest:{value:0}}},xs={basic:{uniforms:Jr([_s.common,_s.specularmap,_s.envmap,_s.aomap,_s.lightmap,_s.fog]),vertexShader:vs.meshbasic_vert,fragmentShader:vs.meshbasic_frag},lambert:{uniforms:Jr([_s.common,_s.specularmap,_s.envmap,_s.aomap,_s.lightmap,_s.emissivemap,_s.bumpmap,_s.normalmap,_s.displacementmap,_s.fog,_s.lights,{emissive:{value:new lr(0)}}]),vertexShader:vs.meshlambert_vert,fragmentShader:vs.meshlambert_frag},phong:{uniforms:Jr([_s.common,_s.specularmap,_s.envmap,_s.aomap,_s.lightmap,_s.emissivemap,_s.bumpmap,_s.normalmap,_s.displacementmap,_s.fog,_s.lights,{emissive:{value:new lr(0)},specular:{value:new lr(1118481)},shininess:{value:30}}]),vertexShader:vs.meshphong_vert,fragmentShader:vs.meshphong_frag},standard:{uniforms:Jr([_s.common,_s.envmap,_s.aomap,_s.lightmap,_s.emissivemap,_s.bumpmap,_s.normalmap,_s.displacementmap,_s.roughnessmap,_s.metalnessmap,_s.fog,_s.lights,{emissive:{value:new lr(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:vs.meshphysical_vert,fragmentShader:vs.meshphysical_frag},toon:{uniforms:Jr([_s.common,_s.aomap,_s.lightmap,_s.emissivemap,_s.bumpmap,_s.normalmap,_s.displacementmap,_s.gradientmap,_s.fog,_s.lights,{emissive:{value:new lr(0)}}]),vertexShader:vs.meshtoon_vert,fragmentShader:vs.meshtoon_frag},matcap:{uniforms:Jr([_s.common,_s.bumpmap,_s.normalmap,_s.displacementmap,_s.fog,{matcap:{value:null}}]),vertexShader:vs.meshmatcap_vert,fragmentShader:vs.meshmatcap_frag},points:{uniforms:Jr([_s.points,_s.fog]),vertexShader:vs.points_vert,fragmentShader:vs.points_frag},dashed:{uniforms:Jr([_s.common,_s.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:vs.linedashed_vert,fragmentShader:vs.linedashed_frag},depth:{uniforms:Jr([_s.common,_s.displacementmap]),vertexShader:vs.depth_vert,fragmentShader:vs.depth_frag},normal:{uniforms:Jr([_s.common,_s.bumpmap,_s.normalmap,_s.displacementmap,{opacity:{value:1}}]),vertexShader:vs.meshnormal_vert,fragmentShader:vs.meshnormal_frag},sprite:{uniforms:Jr([_s.sprite,_s.fog]),vertexShader:vs.sprite_vert,fragmentShader:vs.sprite_frag},background:{uniforms:{uvTransform:{value:new fn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:vs.background_vert,fragmentShader:vs.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:vs.backgroundCube_vert,fragmentShader:vs.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:vs.cube_vert,fragmentShader:vs.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:vs.equirect_vert,fragmentShader:vs.equirect_frag},distanceRGBA:{uniforms:Jr([_s.common,_s.displacementmap,{referencePosition:{value:new Gn},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:vs.distanceRGBA_vert,fragmentShader:vs.distanceRGBA_frag},shadow:{uniforms:Jr([_s.lights,_s.fog,{color:{value:new lr(0)},opacity:{value:1}}]),vertexShader:vs.shadow_vert,fragmentShader:vs.shadow_frag}};xs.physical={uniforms:Jr([xs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new fn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new fn},clearcoatNormalScale:{value:new mn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new fn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new fn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new fn},sheen:{value:0},sheenColor:{value:new lr(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new fn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new fn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new fn},transmissionSamplerSize:{value:new mn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new fn},attenuationDistance:{value:0},attenuationColor:{value:new lr(0)},specularColor:{value:new lr(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new fn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new fn},anisotropyVector:{value:new mn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new fn}}]),vertexShader:vs.meshphysical_vert,fragmentShader:vs.meshphysical_frag};const ys={r:0,b:0,g:0};function Ms(e,t,n,i,r,s,a){const o=new lr(0);let l,c,h=!0===s?0:1,u=null,d=0,p=null;function m(t,n){t.getRGB(ys,Qr(e)),i.buffers.color.setClear(ys.r,ys.g,ys.b,n,a)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),h=t,m(o,h)},getClearAlpha:function(){return h},setClearAlpha:function(e){h=e,m(o,h)},render:function(s,f){let g=!1,v=!0===f.isScene?f.background:null;if(v&&v.isTexture){v=(f.backgroundBlurriness>0?n:t).get(v)}switch(null===v?m(o,h):v&&v.isColor&&(m(v,1),g=!0),e.xr.getEnvironmentBlendMode()){case"opaque":g=!0;break;case"additive":i.buffers.color.setClear(0,0,0,1,a),g=!0;break;case"alpha-blend":i.buffers.color.setClear(0,0,0,0,a),g=!0}(e.autoClear||g)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),v&&(v.isCubeTexture||v.mapping===Ie)?(void 0===c&&(c=new qr(new Zr(1,1,1),new es({name:"BackgroundCubeMaterial",uniforms:Kr(xs.backgroundCube.uniforms),vertexShader:xs.backgroundCube.vertexShader,fragmentShader:xs.backgroundCube.fragmentShader,side:pe,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),c.material.uniforms.envMap.value=v,c.material.uniforms.flipEnvMap.value=v.isCubeTexture&&!1===v.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=f.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=f.backgroundIntensity,c.material.toneMapped=v.colorSpace!==Vt,u===v&&d===v.version&&p===e.toneMapping||(c.material.needsUpdate=!0,u=v,d=v.version,p=e.toneMapping),c.layers.enableAll(),s.unshift(c,c.geometry,c.material,0,0,null)):v&&v.isTexture&&(void 0===l&&(l=new qr(new gs(2,2),new es({name:"BackgroundMaterial",uniforms:Kr(xs.background.uniforms),vertexShader:xs.background.vertexShader,fragmentShader:xs.background.fragmentShader,side:de,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=v,l.material.uniforms.backgroundIntensity.value=f.backgroundIntensity,l.material.toneMapped=v.colorSpace!==Vt,!0===v.matrixAutoUpdate&&v.updateMatrix(),l.material.uniforms.uvTransform.value.copy(v.matrix),u===v&&d===v.version&&p===e.toneMapping||(l.material.needsUpdate=!0,u=v,d=v.version,p=e.toneMapping),l.layers.enableAll(),s.unshift(l,l.geometry,l.material,0,0,null))}}}function Ss(e,t,n,i){const r=e.getParameter(e.MAX_VERTEX_ATTRIBS),s=i.isWebGL2?null:t.get("OES_vertex_array_object"),a=i.isWebGL2||null!==s,o={},l=p(null);let c=l,h=!1;function u(t){return i.isWebGL2?e.bindVertexArray(t):s.bindVertexArrayOES(t)}function d(t){return i.isWebGL2?e.deleteVertexArray(t):s.deleteVertexArrayOES(t)}function p(e){const t=[],n=[],i=[];for(let e=0;e=0){const n=r[t];let i=s[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;a++}}return c.attributesNum!==a||c.index!==i}(r,x,d,y),M&&function(e,t,n,i){const r={},s=t.attributes;let a=0;const o=n.getAttributes();for(const t in o){if(o[t].location>=0){let n=s[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[t]=i,a++}}c.attributes=r,c.attributesNum=a,c.index=i}(r,x,d,y)}else{const e=!0===l.wireframe;c.geometry===x.id&&c.program===d.id&&c.wireframe===e||(c.geometry=x.id,c.program=d.id,c.wireframe=e,M=!0)}null!==y&&n.update(y,e.ELEMENT_ARRAY_BUFFER),(M||h)&&(h=!1,function(r,s,a,o){if(!1===i.isWebGL2&&(r.isInstancedMesh||o.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;m();const l=o.attributes,c=a.getAttributes(),h=s.defaultAttributeValues;for(const t in c){const s=c[t];if(s.location>=0){let a=l[t];if(void 0===a&&("instanceMatrix"===t&&r.instanceMatrix&&(a=r.instanceMatrix),"instanceColor"===t&&r.instanceColor&&(a=r.instanceColor)),void 0!==a){const t=a.normalized,l=a.itemSize,c=n.get(a);if(void 0===c)continue;const h=c.buffer,u=c.type,d=c.bytesPerElement,p=!0===i.isWebGL2&&(u===e.INT||u===e.UNSIGNED_INT||a.gpuType===We);if(a.isInterleavedBufferAttribute){const n=a.data,i=n.stride,c=a.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const s="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===e.constructor.name;let a=void 0!==n.precision?n.precision:"highp";const o=r(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=s||t.has("WEBGL_draw_buffers"),c=!0===n.logarithmicDepthBuffer,h=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),u=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),m=e.getParameter(e.MAX_VERTEX_ATTRIBS),f=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),g=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),_=u>0,x=s||t.has("OES_texture_float");return{isWebGL2:s,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:r,precision:a,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:f,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:_,floatFragmentTextures:x,floatVertexTextures:_&&x,maxSamples:s?e.getParameter(e.MAX_SAMPLES):0}}function ws(e){const t=this;let n=null,i=0,r=!1,s=!1;const a=new hs,o=new fn,l={value:null,needsUpdate:!1};function c(e,n,i,r){const s=null!==e?e.length:0;let c=null;if(0!==s){if(c=l.value,!0!==r||null===c){const t=i+4*s,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length0);t.numPlanes=i,t.numIntersection=0}();else{const e=s?0:i,t=4*e;let r=m.clippingState||null;l.value=r,r=c(u,o,t,h);for(let e=0;e!==t;++e)r[e]=n[e];m.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=e}}}function Es(e){let t=new WeakMap;function n(e,t){return t===Pe?e.mapping=Re:t===Le&&(e.mapping=Ce),e}function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture&&!1===r.isRenderTargetTexture){const s=r.mapping;if(s===Pe||s===Le){if(t.has(r)){return n(t.get(r).texture,r.mapping)}{const s=r.image;if(s&&s.height>0){const a=new as(s.height/2);return a.fromEquirectangularTexture(e,r),t.set(r,a),r.addEventListener("dispose",i),n(a.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}class As extends ts{constructor(e=-1,t=1,n=1,i=-1,r=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,s=n+e,a=i+t,o=i-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,s=r+e*this.view.width,a-=t*this.view.offsetY,o=a-t*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}const Rs=[.125,.215,.35,.446,.526,.582],Cs=20,Ps=new As,Ls=new lr;let Is=null;const Ds=(1+Math.sqrt(5))/2,Us=1/Ds,Ns=[new Gn(1,1,1),new Gn(-1,1,1),new Gn(1,1,-1),new Gn(-1,1,-1),new Gn(0,Ds,Us),new Gn(0,Ds,-Us),new Gn(Us,0,Ds),new Gn(-Us,0,Ds),new Gn(Ds,Us,0),new Gn(-Ds,Us,0)];class Os{constructor(e){this._renderer=e,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(e,t=0,n=.1,i=100){Is=this._renderer.getRenderTarget(),this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=ks(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=Bs(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?o=Rs[a-e+4-1]:0===a&&(o=0),i.push(o);const l=1/(s-2),c=-l,h=1+l,u=[c,c,h,c,h,h,c,c,h,h,c,h],d=6,p=6,m=3,f=2,g=1,v=new Float32Array(m*p*d),_=new Float32Array(f*p*d),x=new Float32Array(g*p*d);for(let e=0;e2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];v.set(i,m*p*e),_.set(u,f*p*e);const r=[e,e,e,e,e,e];x.set(r,g*p*e)}const y=new Cr;y.setAttribute("position",new _r(v,m)),y.setAttribute("uv",new _r(_,f)),y.setAttribute("faceIndex",new _r(x,g)),t.push(y),r>4&&r--}return{lodPlanes:t,sizeLods:n,sigmas:i}}(i)),this._blurMaterial=function(e,t,n){const i=new Float32Array(Cs),r=new Gn(0,1,0),s=new es({name:"SphericalGaussianBlur",defines:{n:Cs,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Hs(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1});return s}(i,e,t)}return i}_compileMaterial(e){const t=new qr(this._lodPlanes[0],e);this._renderer.compile(t,Ps)}_sceneToCubeUV(e,t,n,i){const r=new ns(90,1,t,n),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,c=o.toneMapping;o.getClearColor(Ls),o.toneMapping=Me,o.autoClear=!1;const h=new hr({name:"PMREM.Background",side:pe,depthWrite:!1,depthTest:!1}),u=new qr(new Zr,h);let d=!1;const p=e.background;p?p.isColor&&(h.color.copy(p),e.background=null,d=!0):(h.color.copy(Ls),d=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(r.up.set(0,s[t],0),r.lookAt(a[t],0,0)):1===n?(r.up.set(0,0,s[t]),r.lookAt(0,a[t],0)):(r.up.set(0,s[t],0),r.lookAt(0,0,a[t]));const l=this._cubeSize;zs(i,n*l,t>2?l:0,l,l),o.setRenderTarget(i),d&&o.render(u,r),o.render(e,r)}u.geometry.dispose(),u.material.dispose(),o.toneMapping=c,o.autoClear=l,e.background=p}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===Re||e.mapping===Ce;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=ks()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=Bs());const r=i?this._cubemapMaterial:this._equirectMaterial,s=new qr(this._lodPlanes[0],r);r.uniforms.envMap.value=e;const a=this._cubeSize;zs(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,Ps)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let t=1;tCs&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const f=[];let g=0;for(let e=0;ev-4?i-v+4:0),4*(this._cubeSize-_),3*_,2*_),o.setRenderTarget(t),o.render(c,Ps)}}function Fs(e,t,n){const i=new zn(e,t,n);return i.texture.mapping=Ie,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function zs(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function Bs(){return new es({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Hs(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function ks(){return new es({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Hs(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Hs(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function Gs(e){let t=new WeakMap,n=null;function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping,a=s===Pe||s===Le,o=s===Re||s===Ce;if(a||o){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let i=t.get(r);return null===n&&(n=new Os(e)),i=a?n.fromEquirectangular(r,i):n.fromCubemap(r,i),t.set(r,i),i.texture}if(t.has(r))return t.get(r).texture;{const s=r.image;if(a&&s&&s.height>0||o&&s&&function(e){let t=0;const n=6;for(let i=0;it.maxTextureSize&&(w=Math.ceil(T/t.maxTextureSize),T=t.maxTextureSize);const E=new Float32Array(T*w*4*p),A=new Bn(E,T,w,p);A.type=Xe,A.needsUpdate=!0;const R=4*b;for(let P=0;P0)return e;const r=t*n;let s=ta[r];if(void 0===s&&(s=new Float32Array(r),ta[r]=s),0!==t){i.toArray(s,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(s,r)}return s}function oa(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n":" "} ${r}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}return r}function ro(e,t){const n=function(e){switch(e){case Wt:return["Linear","( value )"];case Vt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),["Linear","( value )"]}}(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function so(e,t){let n;switch(t){case Se:n="Linear";break;case be:n="Reinhard";break;case Te:n="OptimizedCineon";break;case we:n="ACESFilmic";break;case Ee:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function ao(e){return""!==e}function oo(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function lo(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const co=/^[ \t]*#include +<([\w\d./]+)>/gm;function ho(e){return e.replace(co,po)}const uo=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function po(e,t){let n=vs[t];if(void 0===n){const e=uo.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");n=vs[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return ho(n)}const mo=/#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 fo(e){return e.replace(mo,go)}function go(e,t,n,i){let r="";for(let e=parseInt(t);e0&&(g+="\n"),v=[p,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(ao).join("\n"),v.length>0&&(v+="\n")):(g=[vo(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(ao).join("\n"),v=[p,vo(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+h:"",n.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":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Me?"#define TONE_MAPPING":"",n.toneMapping!==Me?vs.tonemapping_pars_fragment:"",n.toneMapping!==Me?so("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",vs.colorspace_pars_fragment,ro("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(ao).join("\n")),a=ho(a),a=oo(a,n),a=lo(a,n),o=ho(o),o=oo(o,n),o=lo(o,n),a=fo(a),o=fo(o),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(_="#version 300 es\n",g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",n.glslVersion===Yt?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Yt?"":"#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("\n")+"\n"+v);const x=_+g+a,y=_+v+o,M=to(r,r.VERTEX_SHADER,x),S=to(r,r.FRAGMENT_SHADER,y);if(r.attachShader(f,M),r.attachShader(f,S),void 0!==n.index0AttributeName?r.bindAttribLocation(f,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(f,0,"position"),r.linkProgram(f),e.debug.checkShaderErrors){const t=r.getProgramInfoLog(f).trim(),n=r.getShaderInfoLog(M).trim(),i=r.getShaderInfoLog(S).trim();let s=!0,a=!0;if(!1===r.getProgramParameter(f,r.LINK_STATUS))if(s=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(r,f,M,S);else{const e=io(r,M,"vertex"),n=io(r,S,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(f,r.VALIDATE_STATUS)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+n)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):""!==n&&""!==i||(a=!1);a&&(this.diagnostics={runnable:s,programLog:t,vertexShader:{log:n,prefix:g},fragmentShader:{log:i,prefix:v}})}let b,T;return r.deleteShader(M),r.deleteShader(S),this.getUniforms=function(){return void 0===b&&(b=new eo(r,f)),b},this.getAttributes=function(){return void 0===T&&(T=function(e,t){const n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r0,j=s.clearcoat>0,X=s.iridescence>0,q=s.sheen>0,Y=s.transmission>0,Z=W&&!!s.anisotropyMap,K=j&&!!s.clearcoatMap,J=j&&!!s.clearcoatNormalMap,Q=j&&!!s.clearcoatRoughnessMap,$=X&&!!s.iridescenceMap,ee=X&&!!s.iridescenceThicknessMap,te=q&&!!s.sheenColorMap,ne=q&&!!s.sheenRoughnessMap,ie=!!s.specularMap,re=!!s.specularColorMap,se=!!s.specularIntensityMap,ae=Y&&!!s.transmissionMap,oe=Y&&!!s.thicknessMap,le=!!s.gradientMap,ce=!!s.alphaMap,he=s.alphaTest>0,ue=!!s.alphaHash,de=!!s.extensions,fe=!!x.attributes.uv1,ge=!!x.attributes.uv2,ve=!!x.attributes.uv3;return{isWebGL2:h,shaderID:b,shaderType:s.type,shaderName:s.name,vertexShader:E,fragmentShader:A,defines:s.defines,customVertexShaderID:R,customFragmentShaderID:C,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:p,instancing:I,instancingColor:I&&null!==v.instanceColor,supportsVertexTextures:d,outputColorSpace:null===L?e.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:Wt,map:D,matcap:U,envMap:N,envMapMode:N&&M.mapping,envMapCubeUVHeight:S,aoMap:O,lightMap:F,bumpMap:z,normalMap:B,displacementMap:d&&k,emissiveMap:H,normalMapObjectSpace:B&&1===s.normalMapType,normalMapTangentSpace:B&&0===s.normalMapType,metalnessMap:G,roughnessMap:V,anisotropy:W,anisotropyMap:Z,clearcoat:j,clearcoatMap:K,clearcoatNormalMap:J,clearcoatRoughnessMap:Q,iridescence:X,iridescenceMap:$,iridescenceThicknessMap:ee,sheen:q,sheenColorMap:te,sheenRoughnessMap:ne,specularMap:ie,specularColorMap:re,specularIntensityMap:se,transmission:Y,transmissionMap:ae,thicknessMap:oe,gradientMap:le,opaque:!1===s.transparent&&1===s.blending,alphaMap:ce,alphaTest:he,alphaHash:ue,combine:s.combine,mapUv:D&&f(s.map.channel),aoMapUv:O&&f(s.aoMap.channel),lightMapUv:F&&f(s.lightMap.channel),bumpMapUv:z&&f(s.bumpMap.channel),normalMapUv:B&&f(s.normalMap.channel),displacementMapUv:k&&f(s.displacementMap.channel),emissiveMapUv:H&&f(s.emissiveMap.channel),metalnessMapUv:G&&f(s.metalnessMap.channel),roughnessMapUv:V&&f(s.roughnessMap.channel),anisotropyMapUv:Z&&f(s.anisotropyMap.channel),clearcoatMapUv:K&&f(s.clearcoatMap.channel),clearcoatNormalMapUv:J&&f(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Q&&f(s.clearcoatRoughnessMap.channel),iridescenceMapUv:$&&f(s.iridescenceMap.channel),iridescenceThicknessMapUv:ee&&f(s.iridescenceThicknessMap.channel),sheenColorMapUv:te&&f(s.sheenColorMap.channel),sheenRoughnessMapUv:ne&&f(s.sheenRoughnessMap.channel),specularMapUv:ie&&f(s.specularMap.channel),specularColorMapUv:re&&f(s.specularColorMap.channel),specularIntensityMapUv:se&&f(s.specularIntensityMap.channel),transmissionMapUv:ae&&f(s.transmissionMap.channel),thicknessMapUv:oe&&f(s.thicknessMap.channel),alphaMapUv:ce&&f(s.alphaMap.channel),vertexTangents:!!x.attributes.tangent&&(B||W),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!x.attributes.color&&4===x.attributes.color.itemSize,vertexUv1s:fe,vertexUv2s:ge,vertexUv3s:ve,pointsUvs:!0===v.isPoints&&!!x.attributes.uv&&(D||ce),fog:!!_,useFog:!0===s.fog,fogExp2:_&&_.isFogExp2,flatShading:!0===s.flatShading,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:u,skinning:!0===v.isSkinnedMesh,morphTargets:void 0!==x.morphAttributes.position,morphNormals:void 0!==x.morphAttributes.normal,morphColors:void 0!==x.morphAttributes.color,morphTargetsCount:w,morphTextureStride:P,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:s.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:s.toneMapped?e.toneMapping:Me,useLegacyLights:e.useLegacyLights,premultipliedAlpha:s.premultipliedAlpha,doubleSided:s.side===me,flipSided:s.side===pe,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionDerivatives:de&&!0===s.extensions.derivatives,extensionFragDepth:de&&!0===s.extensions.fragDepth,extensionDrawBuffers:de&&!0===s.extensions.drawBuffers,extensionShaderTextureLOD:de&&!0===s.extensions.shaderTextureLOD,rendererExtensionFragDepth:h||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||i.has("EXT_shader_texture_lod"),customProgramCacheKey:s.customProgramCacheKey()}},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){o.disableAll(),t.isWebGL2&&o.enable(0);t.supportsVertexTextures&&o.enable(1);t.instancing&&o.enable(2);t.instancingColor&&o.enable(3);t.matcap&&o.enable(4);t.envMap&&o.enable(5);t.normalMapObjectSpace&&o.enable(6);t.normalMapTangentSpace&&o.enable(7);t.clearcoat&&o.enable(8);t.iridescence&&o.enable(9);t.alphaTest&&o.enable(10);t.vertexColors&&o.enable(11);t.vertexAlphas&&o.enable(12);t.vertexUv1s&&o.enable(13);t.vertexUv2s&&o.enable(14);t.vertexUv3s&&o.enable(15);t.vertexTangents&&o.enable(16);t.anisotropy&&o.enable(17);e.push(o.mask),o.disableAll(),t.fog&&o.enable(0);t.useFog&&o.enable(1);t.flatShading&&o.enable(2);t.logarithmicDepthBuffer&&o.enable(3);t.skinning&&o.enable(4);t.morphTargets&&o.enable(5);t.morphNormals&&o.enable(6);t.morphColors&&o.enable(7);t.premultipliedAlpha&&o.enable(8);t.shadowMapEnabled&&o.enable(9);t.useLegacyLights&&o.enable(10);t.doubleSided&&o.enable(11);t.flipSided&&o.enable(12);t.useDepthPacking&&o.enable(13);t.dithering&&o.enable(14);t.transmission&&o.enable(15);t.sheen&&o.enable(16);t.opaque&&o.enable(17);t.pointsUvs&&o.enable(18);e.push(o.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=m[e.type];let n;if(t){const e=xs[t];n=$r.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let i;for(let e=0,t=c.length;e0?i.push(h):!0===a.transparent?r.push(h):n.push(h)},unshift:function(e,t,a,o,l,c){const h=s(e,t,a,o,l,c);a.transmission>0?i.unshift(h):!0===a.transparent?r.unshift(h):n.unshift(h)},finish:function(){for(let n=t,i=e.length;n1&&n.sort(e||To),i.length>1&&i.sort(t||wo),r.length>1&&r.sort(t||wo)}}}function Ao(){let e=new WeakMap;return{get:function(t,n){const i=e.get(t);let r;return void 0===i?(r=new Eo,e.set(t,[r])):n>=i.length?(r=new Eo,i.push(r)):r=i[n],r},dispose:function(){e=new WeakMap}}}function Ro(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new Gn,color:new lr};break;case"SpotLight":n={position:new Gn,direction:new Gn,color:new lr,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Gn,color:new lr,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Gn,skyColor:new lr,groundColor:new lr};break;case"RectAreaLight":n={color:new lr,position:new Gn,halfWidth:new Gn,halfHeight:new Gn}}return e[t.id]=n,n}}}let Co=0;function Po(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Lo(e,t){const n=new Ro,i=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new mn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new mn,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-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};for(let e=0;e<9;e++)r.probe.push(new Gn);const s=new Gn,a=new _i,o=new _i;return{setup:function(s,a){let o=0,l=0,c=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let h=0,u=0,d=0,p=0,m=0,f=0,g=0,v=0,_=0,x=0;s.sort(Po);const y=!0===a?Math.PI:1;for(let e=0,t=s.length;e0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=_s.LTC_FLOAT_1,r.rectAreaLTC2=_s.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=_s.LTC_HALF_1,r.rectAreaLTC2=_s.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=l,r.ambient[2]=c;const M=r.hash;M.directionalLength===h&&M.pointLength===u&&M.spotLength===d&&M.rectAreaLength===p&&M.hemiLength===m&&M.numDirectionalShadows===f&&M.numPointShadows===g&&M.numSpotShadows===v&&M.numSpotMaps===_||(r.directional.length=h,r.spot.length=d,r.rectArea.length=p,r.point.length=u,r.hemi.length=m,r.directionalShadow.length=f,r.directionalShadowMap.length=f,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=v,r.spotShadowMap.length=v,r.directionalShadowMatrix.length=f,r.pointShadowMatrix.length=g,r.spotLightMatrix.length=v+_-x,r.spotLightMap.length=_,r.numSpotLightShadowsWithMaps=x,M.directionalLength=h,M.pointLength=u,M.spotLength=d,M.rectAreaLength=p,M.hemiLength=m,M.numDirectionalShadows=f,M.numPointShadows=g,M.numSpotShadows=v,M.numSpotMaps=_,r.version=Co++)},setupView:function(e,t){let n=0,i=0,l=0,c=0,h=0;const u=t.matrixWorldInverse;for(let t=0,d=e.length;t=s.length?(a=new Io(e,t),s.push(a)):a=s[r],a},dispose:function(){n=new WeakMap}}}class Uo extends ir{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class No extends ir{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function Oo(e,t,n){let i=new ps;const r=new mn,s=new mn,a=new Fn,o=new Uo({depthPacking:3201}),l=new No,c={},h=n.maxTextureSize,u={[de]:pe,[pe]:de,[me]:me},d=new es({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new mn},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const m=new Cr;m.setAttribute("position",new _r(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new qr(m,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ce;let v=this.type;function _(n,i){const s=t.update(f);d.defines.VSM_SAMPLES!==n.blurSamples&&(d.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new zn(r.x,r.y)),d.uniforms.shadow_pass.value=n.map.texture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,s,d,f,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,s,p,f,null)}function x(t,n,i,r){let s=null;const a=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===i.isPointLight?l:o,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const e=s.uuid,t=n.uuid;let i=c[e];void 0===i&&(i={},c[e]=i);let r=i[t];void 0===r&&(r=s.clone(),i[t]=r),s=r}if(s.visible=n.visible,s.wireframe=n.wireframe,s.side=r===ue?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],s.alphaMap=n.alphaMap,s.alphaTest=n.alphaTest,s.map=n.map,s.clipShadows=n.clipShadows,s.clippingPlanes=n.clippingPlanes,s.clipIntersection=n.clipIntersection,s.displacementMap=n.displacementMap,s.displacementScale=n.displacementScale,s.displacementBias=n.displacementBias,s.wireframeLinewidth=n.wireframeLinewidth,s.linewidth=n.linewidth,!0===i.isPointLight&&!0===s.isMeshDistanceMaterial){e.properties.get(s).light=i}return s}function y(n,r,s,a,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&o===ue)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const i=t.update(n),r=n.material;if(Array.isArray(r)){const t=i.groups;for(let l=0,c=t.length;lh||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/f.x),r.x=s.x*f.x,u.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/f.y),r.y=s.y*f.y,u.mapSize.y=s.y)),null===u.map||!0===p||!0===m){const e=this.type!==ue?{minFilter:Oe,magFilter:Oe}:{};null!==u.map&&u.map.dispose(),u.map=new zn(r.x,r.y,e),u.map.texture.name=c.name+".shadowMap",u.camera.updateProjectionMatrix()}e.setRenderTarget(u.map),e.clear();const g=u.getViewportCount();for(let e=0;e=1):-1!==L.indexOf("OpenGL ES")&&(P=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),C=P>=2);let I=null,D={};const U=e.getParameter(e.SCISSOR_BOX),N=e.getParameter(e.VIEWPORT),O=(new Fn).fromArray(U),F=(new Fn).fromArray(N);function z(t,n,r,s){const a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;oi||e.height>i)&&(r=i/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const i=t?hn:Math.floor,s=i(r*e.width),a=i(r*e.height);void 0===f&&(f=_(s,a));const o=n?_(s,a):f;o.width=s,o.height=a;return o.getContext("2d").drawImage(e,0,0,s,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+s+"x"+a+")."),o}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function y(e){return ln(e.width)&&ln(e.height)}function M(e,t){return e.generateMipmaps&&t&&e.minFilter!==Oe&&e.minFilter!==Be}function S(t){e.generateMipmap(t)}function b(n,i,r,s,a=!1){if(!1===o)return i;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let l=i;return i===e.RED&&(r===e.FLOAT&&(l=e.R32F),r===e.HALF_FLOAT&&(l=e.R16F),r===e.UNSIGNED_BYTE&&(l=e.R8)),i===e.RG&&(r===e.FLOAT&&(l=e.RG32F),r===e.HALF_FLOAT&&(l=e.RG16F),r===e.UNSIGNED_BYTE&&(l=e.RG8)),i===e.RGBA&&(r===e.FLOAT&&(l=e.RGBA32F),r===e.HALF_FLOAT&&(l=e.RGBA16F),r===e.UNSIGNED_BYTE&&(l=s===Vt&&!1===a?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)),l!==e.R16F&&l!==e.R32F&&l!==e.RG16F&&l!==e.RG32F&&l!==e.RGBA16F&&l!==e.RGBA32F||t.get("EXT_color_buffer_float"),l}function T(e,t,n){return!0===M(e,n)||e.isFramebufferTexture&&e.minFilter!==Oe&&e.minFilter!==Be?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function w(t){return t===Oe||t===Fe||t===ze?e.NEAREST:e.LINEAR}function E(e){const t=e.target;t.removeEventListener("dispose",E),function(e){const t=i.get(e);if(void 0===t.__webglInit)return;const n=e.source,r=g.get(n);if(r){const i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&R(e),0===Object.keys(r).length&&g.delete(n)}i.remove(e)}(t),t.isVideoTexture&&m.delete(t)}function A(t){const n=t.target;n.removeEventListener("dispose",A),function(t){const n=t.texture,r=i.get(t),s=i.get(n);void 0!==s.__webglTexture&&(e.deleteTexture(s.__webglTexture),a.memory.textures--);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(r.__webglFramebuffer[t]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[t]);else{if(e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&e.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer)for(let t=0;t0&&s.__version!==t.version){const e=t.image;if(null===e)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void O(s,t,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(e.TEXTURE_2D,s.__webglTexture,e.TEXTURE0+r)}const L={[De]:e.REPEAT,[Ue]:e.CLAMP_TO_EDGE,[Ne]:e.MIRRORED_REPEAT},I={[Oe]:e.NEAREST,[Fe]:e.NEAREST_MIPMAP_NEAREST,[ze]:e.NEAREST_MIPMAP_LINEAR,[Be]:e.LINEAR,[ke]:e.LINEAR_MIPMAP_NEAREST,[He]:e.LINEAR_MIPMAP_LINEAR},D={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function U(n,s,a){if(a?(e.texParameteri(n,e.TEXTURE_WRAP_S,L[s.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,L[s.wrapT]),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,L[s.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,I[s.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,I[s.minFilter])):(e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),s.wrapS===Ue&&s.wrapT===Ue||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,e.TEXTURE_MAG_FILTER,w(s.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,w(s.minFilter)),s.minFilter!==Oe&&s.minFilter!==Be&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),s.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,D[s.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){const a=t.get("EXT_texture_filter_anisotropic");if(s.magFilter===Oe)return;if(s.minFilter!==ze&&s.minFilter!==He)return;if(s.type===Xe&&!1===t.has("OES_texture_float_linear"))return;if(!1===o&&s.type===qe&&!1===t.has("OES_texture_half_float_linear"))return;(s.anisotropy>1||i.get(s).__currentAnisotropy)&&(e.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),i.get(s).__currentAnisotropy=s.anisotropy)}}function N(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",E));const r=n.source;let s=g.get(r);void 0===s&&(s={},g.set(r,s));const o=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(o!==t.__cacheKey){void 0===s[o]&&(s[o]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,i=!0),s[o].usedTimes++;const r=s[t.__cacheKey];void 0!==r&&(s[t.__cacheKey].usedTimes--,0===r.usedTimes&&R(n)),t.__cacheKey=o,t.__webglTexture=s[o].texture}return i}function O(t,r,a){let l=e.TEXTURE_2D;(r.isDataArrayTexture||r.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),r.isData3DTexture&&(l=e.TEXTURE_3D);const c=N(t,r),u=r.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+a);const d=i.get(u);if(u.version!==d.__version||!0===c){n.activeTexture(e.TEXTURE0+a),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);const t=function(e){return!o&&(e.wrapS!==Ue||e.wrapT!==Ue||e.minFilter!==Oe&&e.minFilter!==Be)}(r)&&!1===y(r.image);let i=x(r.image,t,!1,h);i=G(r,i);const p=y(i)||o,m=s.convert(r.format,r.colorSpace);let f,g=s.convert(r.type),v=b(r.internalFormat,m,g,r.colorSpace);U(l,r,p);const _=r.mipmaps,w=o&&!0!==r.isVideoTexture,E=void 0===d.__version||!0===c,A=T(r,i,p);if(r.isDepthTexture)v=e.DEPTH_COMPONENT,o?v=r.type===Xe?e.DEPTH_COMPONENT32F:r.type===je?e.DEPTH_COMPONENT24:r.type===Ke?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:r.type===Xe&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===Qe&&v===e.DEPTH_COMPONENT&&r.type!==Ve&&r.type!==je&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=je,g=s.convert(r.type)),r.format===$e&&v===e.DEPTH_COMPONENT&&(v=e.DEPTH_STENCIL,r.type!==Ke&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=Ke,g=s.convert(r.type))),E&&(w?n.texStorage2D(e.TEXTURE_2D,1,v,i.width,i.height):n.texImage2D(e.TEXTURE_2D,0,v,i.width,i.height,0,m,g,null));else if(r.isDataTexture)if(_.length>0&&p){w&&E&&n.texStorage2D(e.TEXTURE_2D,A,v,_[0].width,_[0].height);for(let t=0,i=_.length;t>=1,r>>=1}}else if(_.length>0&&p){w&&E&&n.texStorage2D(e.TEXTURE_2D,A,v,_[0].width,_[0].height);for(let t=0,i=_.length;t=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,o,l,i.get(a).__webglTexture,0),n.bindFramebuffer(e.FRAMEBUFFER,null)}function z(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer&&!n.stencilBuffer){let r=e.DEPTH_COMPONENT16;if(i||H(n)){const t=n.depthTexture;t&&t.isDepthTexture&&(t.type===Xe?r=e.DEPTH_COMPONENT32F:t.type===je&&(r=e.DEPTH_COMPONENT24));const i=k(n);H(n)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,i,r,n.width,n.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,i,r,n.width,n.height)}else e.renderbufferStorage(e.RENDERBUFFER,r,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(n.depthBuffer&&n.stencilBuffer){const r=k(n);i&&!1===H(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):H(n)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else{const t=!0===n.isWebGLMultipleRenderTargets?n.texture:[n.texture];for(let r=0;r0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function G(e,n){const i=e.colorSpace,r=e.format,s=e.type;return!0===e.isCompressedTexture||e.format===Zt||i!==Wt&&i!==Gt&&(i===Vt?!1===o?!0===t.has("EXT_sRGB")&&r===Je?(e.format=Zt,e.minFilter=Be,e.generateMipmaps=!1):n=Ln.sRGBToLinear(n):r===Je&&s===Ge||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",i)),n}this.allocateTextureUnit=function(){const e=C;return e>=l&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),C+=1,e},this.resetTextureUnits=function(){C=0},this.setTexture2D=P,this.setTexture2DArray=function(t,r){const s=i.get(t);t.version>0&&s.__version!==t.version?O(s,t,r):n.bindTexture(e.TEXTURE_2D_ARRAY,s.__webglTexture,e.TEXTURE0+r)},this.setTexture3D=function(t,r){const s=i.get(t);t.version>0&&s.__version!==t.version?O(s,t,r):n.bindTexture(e.TEXTURE_3D,s.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,r){const a=i.get(t);t.version>0&&a.__version!==t.version?function(t,r,a){if(6!==r.image.length)return;const l=N(t,r),h=r.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+a);const u=i.get(h);if(h.version!==u.__version||!0===l){n.activeTexture(e.TEXTURE0+a),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);const t=r.isCompressedTexture||r.image[0].isCompressedTexture,i=r.image[0]&&r.image[0].isDataTexture,d=[];for(let e=0;e<6;e++)d[e]=t||i?i?r.image[e].image:r.image[e]:x(r.image[e],!1,!0,c),d[e]=G(r,d[e]);const p=d[0],m=y(p)||o,f=s.convert(r.format,r.colorSpace),g=s.convert(r.type),v=b(r.internalFormat,f,g,r.colorSpace),_=o&&!0!==r.isVideoTexture,w=void 0===u.__version||!0===l;let E,A=T(r,p,m);if(U(e.TEXTURE_CUBE_MAP,r,m),t){_&&w&&n.texStorage2D(e.TEXTURE_CUBE_MAP,A,v,p.width,p.height);for(let t=0;t<6;t++){E=d[t].mipmaps;for(let i=0;i0&&A++,n.texStorage2D(e.TEXTURE_CUBE_MAP,A,v,d[0].width,d[0].height));for(let t=0;t<6;t++)if(i){_?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,d[t].width,d[t].height,f,g,d[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,v,d[t].width,d[t].height,0,f,g,d[t].data);for(let i=0;i0&&!1===H(t)){const i=d?l:[l];c.__webglMultisampledFramebuffer=e.createFramebuffer(),c.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer);for(let n=0;n0&&!1===H(t)){const r=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],s=t.width,a=t.height;let o=e.COLOR_BUFFER_BIT;const l=[],c=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,h=i.get(t),u=!0===t.isWebGLMultipleRenderTargets;if(u)for(let t=0;to+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&a<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(i=t.getPose(e.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Go)))}return null!==a&&(a.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==s),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const n=new Ho;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Wo extends On{constructor(e,t,n,i,r,s,a,o,l,c){if((c=void 0!==c?c:Qe)!==Qe&&c!==$e)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===Qe&&(n=je),void 0===n&&c===$e&&(n=Ke),super(null,i,r,s,a,o,c,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==a?a:Oe,this.minFilter=void 0!==o?o:Oe,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}class jo extends Qt{constructor(e,t){super();const n=this;let i=null,r=1,s=null,a="local-floor",o=1,l=null,c=null,h=null,u=null,d=null,p=null;const m=t.getContextAttributes();let f=null,g=null;const v=[],_=[],x=new ns;x.layers.enable(1),x.viewport=new Fn;const y=new ns;y.layers.enable(2),y.viewport=new Fn;const M=[x,y],S=new ko;S.layers.enable(1),S.layers.enable(2);let b=null,T=null;function w(e){const t=_.indexOf(e.inputSource);if(-1===t)return;const n=v[t];void 0!==n&&(n.update(e.inputSource,e.frame,l||s),n.dispatchEvent({type:e.type,data:e.inputSource}))}function E(){i.removeEventListener("select",w),i.removeEventListener("selectstart",w),i.removeEventListener("selectend",w),i.removeEventListener("squeeze",w),i.removeEventListener("squeezestart",w),i.removeEventListener("squeezeend",w),i.removeEventListener("end",E),i.removeEventListener("inputsourceschange",A);for(let e=0;e=0&&(_[i]=null,v[i].disconnect(n))}for(let t=0;t=_.length){_.push(n),i=e;break}if(null===_[e]){_[e]=n,i=e;break}}if(-1===i)break}const r=v[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=v[e];return void 0===t&&(t=new Vo,v[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=v[e];return void 0===t&&(t=new Vo,v[e]=t),t.getGripSpace()},this.getHand=function(e){let t=v[e];return void 0===t&&(t=new Vo,v[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){a=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(c){if(i=c,null!==i){if(f=e.getRenderTarget(),i.addEventListener("select",w),i.addEventListener("selectstart",w),i.addEventListener("selectend",w),i.addEventListener("squeeze",w),i.addEventListener("squeezestart",w),i.addEventListener("squeezeend",w),i.addEventListener("end",E),i.addEventListener("inputsourceschange",A),!0!==m.xrCompatible&&await t.makeXRCompatible(),void 0===i.renderState.layers||!1===e.capabilities.isWebGL2){const n={antialias:void 0!==i.renderState.layers||m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,n),i.updateRenderState({baseLayer:d}),g=new zn(d.framebufferWidth,d.framebufferHeight,{format:Je,type:Ge,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil})}else{let n=null,s=null,a=null;m.depth&&(a=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=m.stencil?$e:Qe,s=m.stencil?Ke:je);const o={colorFormat:t.RGBA8,depthFormat:a,scaleFactor:r};h=new XRWebGLBinding(i,t),u=h.createProjectionLayer(o),i.updateRenderState({layers:[u]}),g=new zn(u.textureWidth,u.textureHeight,{format:Je,type:Ge,depthTexture:new Wo(u.textureWidth,u.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0});e.properties.get(g).__ignoreDepthValues=u.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await i.requestReferenceSpace(a),I.setContext(i),I.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode};const R=new Gn,C=new Gn;function P(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===i)return;S.near=y.near=x.near=e.near,S.far=y.far=x.far=e.far,b===S.near&&T===S.far||(i.updateRenderState({depthNear:S.near,depthFar:S.far}),b=S.near,T=S.far);const t=e.parent,n=S.cameras;P(S,t);for(let e=0;e0&&(i.alphaTest.value=r.alphaTest);const s=t.get(r).envMap;if(s&&(i.envMap.value=s,i.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,i.reflectivity.value=r.reflectivity,i.ior.value=r.ior,i.refractionRatio.value=r.refractionRatio),r.lightMap){i.lightMap.value=r.lightMap;const t=!0===e.useLegacyLights?Math.PI:1;i.lightMapIntensity.value=r.lightMapIntensity*t,n(r.lightMap,i.lightMapTransform)}r.aoMap&&(i.aoMap.value=r.aoMap,i.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,i.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,Qr(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,s,a,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(e,r):r.isMeshToonMaterial?(i(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(i(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(i(e,r),function(e,i){e.metalness.value=i.metalness,i.metalnessMap&&(e.metalnessMap.value=i.metalnessMap,n(i.metalnessMap,e.metalnessMapTransform));e.roughness.value=i.roughness,i.roughnessMap&&(e.roughnessMap.value=i.roughnessMap,n(i.roughnessMap,e.roughnessMapTransform));const r=t.get(i).envMap;r&&(e.envMapIntensity.value=i.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(e,t,i){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform)));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===pe&&e.clearcoatNormalScale.value.negate()));t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform)));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform)));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform));t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,o)):r.isMeshMatcapMaterial?(i(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),function(e,n){const i=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(i.matrixWorld),e.nearDistance.value=i.shadow.camera.near,e.farDistance.value=i.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,i,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*r,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,s,a):r.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function qo(e,t,n,i){let r={},s={},a=[];const o=n.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(e,t,n){const i=e.value;if(void 0===n[t]){if("number"==typeof i)n[t]=i;else{const e=Array.isArray(i)?i:[i],r=[];for(let t=0;t0){r=n%i;0!==r&&i-r-a.boundary<0&&(n+=i-r,s.__offset=n)}n+=a.storage}r=n%i,r>0&&(n+=i-r);e.__size=n,e.__cache={}}(n),d=function(t){const n=function(){for(let e=0;e0),u=!!n.morphAttributes.position,d=!!n.morphAttributes.normal,p=!!n.morphAttributes.color,m=i.toneMapped?_.toneMapping:Me,g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,v=void 0!==g?g.length:0,x=J.get(i),y=f.state.lights;if(!0===B&&(!0===k||e!==T)){const t=e===T&&i.id===b;ce.setState(i,e,t)}let M=!1;i.version===x.__version?x.needsLights&&x.lightsStateVersion!==y.state.version||x.outputColorSpace!==o||r.isInstancedMesh&&!1===x.instancing?M=!0:r.isInstancedMesh||!0!==x.instancing?r.isSkinnedMesh&&!1===x.skinning?M=!0:r.isSkinnedMesh||!0!==x.skinning?x.envMap!==l||!0===i.fog&&x.fog!==s?M=!0:void 0===x.numClippingPlanes||x.numClippingPlanes===ce.numPlanes&&x.numIntersection===ce.numIntersection?(x.vertexAlphas!==c||x.vertexTangents!==h||x.morphTargets!==u||x.morphNormals!==d||x.morphColors!==p||x.toneMapping!==m||!0===Y.isWebGL2&&x.morphTargetsCount!==v)&&(M=!0):M=!0:M=!0:M=!0:(M=!0,x.__version=i.version);let w=x.currentProgram;!0===M&&(w=ze(i,t,r));let E=!1,A=!1,R=!1;const C=w.getUniforms(),P=x.uniforms;Z.useProgram(w.program)&&(E=!0,A=!0,R=!0);i.id!==b&&(b=i.id,A=!0);if(E||T!==e){if(C.setValue(Se,"projectionMatrix",e.projectionMatrix),Y.logarithmicDepthBuffer&&C.setValue(Se,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),T!==e&&(T=e,A=!0,R=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshStandardMaterial||i.envMap){const t=C.map.cameraPosition;void 0!==t&&t.setValue(Se,W.setFromMatrixPosition(e.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&C.setValue(Se,"isOrthographic",!0===e.isOrthographicCamera),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.isShadowMaterial||r.isSkinnedMesh)&&C.setValue(Se,"viewMatrix",e.matrixWorldInverse)}if(r.isSkinnedMesh){C.setOptional(Se,r,"bindMatrix"),C.setOptional(Se,r,"bindMatrixInverse");const e=r.skeleton;e&&(Y.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),C.setValue(Se,"boneTexture",e.boneTexture,Q),C.setValue(Se,"boneTextureSize",e.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}const D=n.morphAttributes;(void 0!==D.position||void 0!==D.normal||void 0!==D.color&&!0===Y.isWebGL2)&&fe.update(r,n,w);(A||x.receiveShadow!==r.receiveShadow)&&(x.receiveShadow=r.receiveShadow,C.setValue(Se,"receiveShadow",r.receiveShadow));i.isMeshGouraudMaterial&&null!==i.envMap&&(P.envMap.value=l,P.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);A&&(C.setValue(Se,"toneMappingExposure",_.toneMappingExposure),x.needsLights&&(N=R,(U=P).ambientLightColor.needsUpdate=N,U.lightProbe.needsUpdate=N,U.directionalLights.needsUpdate=N,U.directionalLightShadows.needsUpdate=N,U.pointLights.needsUpdate=N,U.pointLightShadows.needsUpdate=N,U.spotLights.needsUpdate=N,U.spotLightShadows.needsUpdate=N,U.rectAreaLights.needsUpdate=N,U.hemisphereLights.needsUpdate=N),s&&!0===i.fog&&se.refreshFogUniforms(P,s),se.refreshMaterialUniforms(P,i,I,L,H),eo.upload(Se,x.uniformsList,P,Q));var U,N;i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(eo.upload(Se,x.uniformsList,P,Q),i.uniformsNeedUpdate=!1);i.isSpriteMaterial&&C.setValue(Se,"center",r.center);if(C.setValue(Se,"modelViewMatrix",r.modelViewMatrix),C.setValue(Se,"normalMatrix",r.normalMatrix),C.setValue(Se,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const e=i.uniformsGroups;for(let t=0,n=e.length;t0&&function(e,t,n,i){const r=Y.isWebGL2;null===H&&(H=new zn(1,1,{generateMipmaps:!0,type:q.has("EXT_color_buffer_half_float")?qe:Ge,minFilter:He,samples:r?4:0}));_.getDrawingBufferSize(V),r?H.setSize(V.x,V.y):H.setSize(hn(V.x),hn(V.y));const s=_.getRenderTarget();_.setRenderTarget(H),_.getClearColor(R),C=_.getClearAlpha(),C<1&&_.setClearColor(16777215,.5);_.clear();const a=_.toneMapping;_.toneMapping=Me,Oe(e,n,i),Q.updateMultisampleRenderTarget(H),Q.updateRenderTargetMipmap(H);let o=!1;for(let e=0,r=t.length;e0&&Oe(r,t,n),s.length>0&&Oe(s,t,n),a.length>0&&Oe(a,t,n),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function Oe(e,t,n){const i=!0===t.isScene?t.overrideMaterial:null;for(let r=0,s=e.length;r0?v[v.length-1]:null,g.pop(),m=g.length>0?g[g.length-1]:null},this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return M},this.getRenderTarget=function(){return S},this.setRenderTargetTextures=function(e,t,n){J.get(e.texture).__webglTexture=t,J.get(e.depthTexture).__webglTexture=n;const i=J.get(e);i.__hasExternalTextures=!0,i.__hasExternalTextures&&(i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===q.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){const n=J.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){S=e,y=t,M=n;let i=!0,r=null,s=!1,a=!1;if(e){const n=J.get(e);void 0!==n.__useDefaultFramebuffer?(Z.bindFramebuffer(Se.FRAMEBUFFER,null),i=!1):void 0===n.__webglFramebuffer?Q.setupRenderTarget(e):n.__hasExternalTextures&&Q.rebindTextures(e,J.get(e.texture).__webglTexture,J.get(e.depthTexture).__webglTexture);const o=e.texture;(o.isData3DTexture||o.isDataArrayTexture||o.isCompressedArrayTexture)&&(a=!0);const l=J.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=l[t],s=!0):r=Y.isWebGL2&&e.samples>0&&!1===Q.useMultisampledRTT(e)?J.get(e).__webglMultisampledFramebuffer:l,w.copy(e.viewport),E.copy(e.scissor),A=e.scissorTest}else w.copy(N).multiplyScalar(I).floor(),E.copy(O).multiplyScalar(I).floor(),A=F;if(Z.bindFramebuffer(Se.FRAMEBUFFER,r)&&Y.drawBuffers&&i&&Z.drawBuffers(e,r),Z.viewport(w),Z.scissor(E),Z.setScissorTest(A),s){const i=J.get(e.texture);Se.framebufferTexture2D(Se.FRAMEBUFFER,Se.COLOR_ATTACHMENT0,Se.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(a){const i=J.get(e.texture),r=t||0;Se.framebufferTextureLayer(Se.FRAMEBUFFER,Se.COLOR_ATTACHMENT0,i.__webglTexture,n||0,r)}b=-1},this.readRenderTargetPixels=function(e,t,n,i,r,s,a){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=J.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){Z.bindFramebuffer(Se.FRAMEBUFFER,o);try{const a=e.texture,o=a.format,l=a.type;if(o!==Je&&_e.convert(o)!==Se.getParameter(Se.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===qe&&(q.has("EXT_color_buffer_half_float")||Y.isWebGL2&&q.has("EXT_color_buffer_float"));if(!(l===Ge||_e.convert(l)===Se.getParameter(Se.IMPLEMENTATION_COLOR_READ_TYPE)||l===Xe&&(Y.isWebGL2||q.has("OES_texture_float")||q.has("WEBGL_color_buffer_float"))||c))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&Se.readPixels(t,n,i,r,_e.convert(o),_e.convert(l),s)}finally{const e=null!==S?J.get(S).__webglFramebuffer:null;Z.bindFramebuffer(Se.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),s=Math.floor(t.image.height*i);Q.setTexture2D(t,0),Se.copyTexSubImage2D(Se.TEXTURE_2D,n,0,0,e.x,e.y,r,s),Z.unbindTexture()},this.copyTextureToTexture=function(e,t,n,i=0){const r=t.image.width,s=t.image.height,a=_e.convert(n.format),o=_e.convert(n.type);Q.setTexture2D(n,0),Se.pixelStorei(Se.UNPACK_FLIP_Y_WEBGL,n.flipY),Se.pixelStorei(Se.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),Se.pixelStorei(Se.UNPACK_ALIGNMENT,n.unpackAlignment),t.isDataTexture?Se.texSubImage2D(Se.TEXTURE_2D,i,e.x,e.y,r,s,a,o,t.image.data):t.isCompressedTexture?Se.compressedTexSubImage2D(Se.TEXTURE_2D,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,a,t.mipmaps[0].data):Se.texSubImage2D(Se.TEXTURE_2D,i,e.x,e.y,a,o,t.image),0===i&&n.generateMipmaps&&Se.generateMipmap(Se.TEXTURE_2D),Z.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,i,r=0){if(_.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const s=e.max.x-e.min.x+1,a=e.max.y-e.min.y+1,o=e.max.z-e.min.z+1,l=_e.convert(i.format),c=_e.convert(i.type);let h;if(i.isData3DTexture)Q.setTexture3D(i,0),h=Se.TEXTURE_3D;else{if(!i.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");Q.setTexture2DArray(i,0),h=Se.TEXTURE_2D_ARRAY}Se.pixelStorei(Se.UNPACK_FLIP_Y_WEBGL,i.flipY),Se.pixelStorei(Se.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),Se.pixelStorei(Se.UNPACK_ALIGNMENT,i.unpackAlignment);const u=Se.getParameter(Se.UNPACK_ROW_LENGTH),d=Se.getParameter(Se.UNPACK_IMAGE_HEIGHT),p=Se.getParameter(Se.UNPACK_SKIP_PIXELS),m=Se.getParameter(Se.UNPACK_SKIP_ROWS),f=Se.getParameter(Se.UNPACK_SKIP_IMAGES),g=n.isCompressedTexture?n.mipmaps[0]:n.image;Se.pixelStorei(Se.UNPACK_ROW_LENGTH,g.width),Se.pixelStorei(Se.UNPACK_IMAGE_HEIGHT,g.height),Se.pixelStorei(Se.UNPACK_SKIP_PIXELS,e.min.x),Se.pixelStorei(Se.UNPACK_SKIP_ROWS,e.min.y),Se.pixelStorei(Se.UNPACK_SKIP_IMAGES,e.min.z),n.isDataTexture||n.isData3DTexture?Se.texSubImage3D(h,r,t.x,t.y,t.z,s,a,o,l,c,g.data):n.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Se.compressedTexSubImage3D(h,r,t.x,t.y,t.z,s,a,o,l,g.data)):Se.texSubImage3D(h,r,t.x,t.y,t.z,s,a,o,l,c,g),Se.pixelStorei(Se.UNPACK_ROW_LENGTH,u),Se.pixelStorei(Se.UNPACK_IMAGE_HEIGHT,d),Se.pixelStorei(Se.UNPACK_SKIP_PIXELS,p),Se.pixelStorei(Se.UNPACK_SKIP_ROWS,m),Se.pixelStorei(Se.UNPACK_SKIP_IMAGES,f),0===r&&i.generateMipmaps&&Se.generateMipmap(h),Z.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?Q.setTextureCube(e,0):e.isData3DTexture?Q.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?Q.setTexture2DArray(e,0):Q.setTexture2D(e,0),Z.unbindTexture()},this.resetState=function(){y=0,M=0,S=null,Z.reset(),xe.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Kt}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Vt?Ht:kt}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Ht?Vt:Wt}}class Ko extends Zo{}Ko.prototype.isWebGL1Renderer=!0;class Jo{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new lr(e),this.density=t}clone(){return new Jo(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class Qo{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new lr(e),this.near=t,this.far=n}clone(){return new Qo(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class $o extends Vi{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t}}class el{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=qt,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=rn()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;ie.far||t.push({distance:o,point:sl.clone(),uv:tr.getInterpolation(sl,ul,dl,pl,ml,fl,gl,new mn),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function _l(e,t,n,i,r,s){ll.subVectors(e,n).addScalar(.5).multiply(i),void 0!==r?(cl.x=s*ll.x-r*ll.y,cl.y=r*ll.x+s*ll.y):cl.copy(ll),e.copy(t),e.x+=cl.x,e.y+=cl.y,e.applyMatrix4(hl)}const xl=new Gn,yl=new Gn;class Ml extends Vi{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let e=0,n=t.length;e0){let n,i;for(n=1,i=t.length;n0){xl.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(xl);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){xl.setFromMatrixPosition(e.matrixWorld),yl.setFromMatrixPosition(this.matrixWorld);const n=xl.distanceTo(yl)/e.zoom;let i,r;for(t[0].object.visible=!0,i=1,r=t.length;i=e))break;t[i-1].object.visible=!1,t[i].object.visible=!0}for(this._currentLevel=i-1;io)continue;u.applyMatrix4(this.matrixWorld);const s=e.ray.origin.distanceTo(u);se.far||t.push({distance:s,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else{for(let n=Math.max(0,s.start),i=Math.min(m.count,s.start+s.count)-1;no)continue;u.applyMatrix4(this.matrixWorld);const i=e.ray.origin.distanceTo(u);ie.far||t.push({distance:i,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:t,face:null,object:a})}}class hc extends On{constructor(e,t,n,i,r,s,a,o,l){super(e,t,n,i,r,s,a,o,l),this.isVideoTexture=!0,this.minFilter=void 0!==s?s:Be,this.magFilter=void 0!==r?r:Be,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){c.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!1==="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class uc extends On{constructor(e,t,n,i,r,s,a,o,l,c,h,u){super(null,s,a,o,l,c,i,r,h,u),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class dc extends On{constructor(e,t,n,i,r,s,a,o,l){super(e,t,n,i,r,s,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class pc{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let s=1;s<=e;s++)n=this.getPoint(s/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const r=n.length;let s;s=t||e*n[r-1];let a,o=0,l=r-1;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),a=n[i]-s,a<0)o=i+1;else{if(!(a>0)){l=i;break}l=i-1}if(i=l,n[i]===s)return i/(r-1);const c=n[i];return(i+(s-c)/(n[i+1]-c))/(r-1)}getTangent(e,t){const n=1e-4;let i=e-n,r=e+n;i<0&&(i=0),r>1&&(r=1);const s=this.getPoint(i),a=this.getPoint(r),o=t||(s.isVector2?new mn:new Gn);return o.copy(a).sub(s).normalize(),o}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new Gn,i=[],r=[],s=[],a=new Gn,o=new _i;for(let t=0;t<=e;t++){const n=t/e;i[t]=this.getTangentAt(n,new Gn)}r[0]=new Gn,s[0]=new Gn;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),h=Math.abs(i[0].y),u=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),u<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),s[0].crossVectors(i[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),s[t]=s[t-1].clone(),a.crossVectors(i[t-1],i[t]),a.length()>Number.EPSILON){a.normalize();const e=Math.acos(sn(i[t-1].dot(i[t]),-1,1));r[t].applyMatrix4(o.makeRotationAxis(a,e))}s[t].crossVectors(i[t],r[t])}if(!0===t){let t=Math.acos(sn(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(a.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],t*n)),s[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:s}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class mc extends pc{constructor(e=0,t=0,n=1,i=1,r=0,s=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=s,this.aClockwise=a,this.aRotation=o}getPoint(e,t){const n=t||new mn,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?a=i[(l-1)%r]:(vc.subVectors(i[0],i[1]).add(i[0]),a=vc);const h=i[l%r],u=i[(l+1)%r];if(this.closed||l+2i.length-2?i.length-1:s+1],h=i[s>i.length-3?i.length-1:s+2];return n.set(Sc(a,o.x,l.x,c.x,h.x),Sc(a,o.y,l.y,c.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const e=i[r]-n,s=this.curves[r],a=s.getLength(),o=0===a?0:1-e/a;return s.getPointAt(o,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.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 e=[];let t=0;for(let n=0,i=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Nc extends Cr{constructor(e=[new mn(0,-.5),new mn(.5,0),new mn(0,.5)],t=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=sn(i,0,2*Math.PI);const r=[],s=[],a=[],o=[],l=[],c=1/t,h=new Gn,u=new mn,d=new Gn,p=new Gn,m=new Gn;let f=0,g=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:f=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,d.x=1*g,d.y=-f,d.z=0*g,m.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case e.length-1:o.push(m.x,m.y,m.z);break;default:f=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,d.x=1*g,d.y=-f,d.z=0*g,p.copy(d),d.x+=m.x,d.y+=m.y,d.z+=m.z,d.normalize(),o.push(d.x,d.y,d.z),m.copy(p)}for(let r=0;r<=t;r++){const d=n+r*c*i,p=Math.sin(d),m=Math.cos(d);for(let n=0;n<=e.length-1;n++){h.x=e[n].x*p,h.y=e[n].y,h.z=e[n].x*m,s.push(h.x,h.y,h.z),u.x=r/t,u.y=n/(e.length-1),a.push(u.x,u.y);const i=o[3*n+0]*p,c=o[3*n+1],d=o[3*n+0]*m;l.push(i,c,d)}}for(let n=0;n0&&v(!0),t>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new Mr(h,3)),this.setAttribute("normal",new Mr(u,3)),this.setAttribute("uv",new Mr(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new zc(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Bc extends zc{constructor(e=1,t=1,n=32,i=1,r=!1,s=0,a=2*Math.PI){super(0,e,t,n,i,r,s,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:s,thetaLength:a}}static fromJSON(e){return new Bc(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class kc extends Cr{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],s=[];function a(e,t,n,i){const r=i+1,s=[];for(let i=0;i<=r;i++){s[i]=[];const a=e.clone().lerp(n,i/r),o=t.clone().lerp(n,i/r),l=r-i;for(let e=0;e<=l;e++)s[i][e]=0===e&&i===r?a:a.clone().lerp(o,e/l)}for(let e=0;e.9&&a<.1&&(t<.2&&(s[e+0]+=1),n<.2&&(s[e+2]+=1),i<.2&&(s[e+4]+=1))}}()}(),this.setAttribute("position",new Mr(r,3)),this.setAttribute("normal",new Mr(r.slice(),3)),this.setAttribute("uv",new Mr(s,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new kc(e.vertices,e.indices,e.radius,e.details)}}class Hc extends kc{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Hc(e.radius,e.detail)}}const Gc=new Gn,Vc=new Gn,Wc=new Gn,jc=new tr;class Xc extends Cr{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){const n=4,i=Math.pow(10,n),r=Math.cos(tn*t),s=e.getIndex(),a=e.getAttribute("position"),o=s?s.count:a.count,l=[0,0,0],c=["a","b","c"],h=new Array(3),u={},d=[];for(let e=0;e80*n){o=c=e[0],l=h=e[1];for(let t=n;tc&&(c=u),d>h&&(h=d);p=Math.max(c-o,h-l),p=0!==p?32767/p:0}return Jc(s,a,n,o,l,p,0),a};function Zc(e,t,n,i,r){let s,a;if(r===function(e,t,n,i){let r=0;for(let s=t,a=n-i;s0)for(s=t;s=t;s-=i)a=gh(s,e[s],e[s+1],a);return a&&hh(a,a.next)&&(vh(a),a=a.next),a}function Kc(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!hh(i,i.next)&&0!==ch(i.prev,i,i.next))i=i.next;else{if(vh(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function Jc(e,t,n,i,r,s,a){if(!e)return;!a&&s&&function(e,t,n,i){let r=e;do{0===r.z&&(r.z=sh(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,n,i,r,s,a,o,l,c=1;do{for(n=e,e=null,s=null,a=0;n;){for(a++,i=n,o=0,t=0;t0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,o--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:e=r,r.prevZ=s,s=r;n=i}s.nextZ=null,c*=2}while(a>1)}(r)}(e,i,r,s);let o,l,c=e;for(;e.prev!==e.next;)if(o=e.prev,l=e.next,s?$c(e,i,r,s):Qc(e))t.push(o.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),vh(e),e=l.next,c=l.next;else if((e=l)===c){a?1===a?Jc(e=eh(Kc(e),t,n),t,n,i,r,s,2):2===a&&th(e,t,n,i,r,s):Jc(Kc(e),t,n,i,r,s,1);break}}function Qc(e){const t=e.prev,n=e,i=e.next;if(ch(t,n,i)>=0)return!1;const r=t.x,s=n.x,a=i.x,o=t.y,l=n.y,c=i.y,h=rs?r>a?r:a:s>a?s:a,p=o>l?o>c?o:c:l>c?l:c;let m=i.next;for(;m!==t;){if(m.x>=h&&m.x<=d&&m.y>=u&&m.y<=p&&oh(r,o,s,l,a,c,m.x,m.y)&&ch(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function $c(e,t,n,i){const r=e.prev,s=e,a=e.next;if(ch(r,s,a)>=0)return!1;const o=r.x,l=s.x,c=a.x,h=r.y,u=s.y,d=a.y,p=ol?o>c?o:c:l>c?l:c,g=h>u?h>d?h:d:u>d?u:d,v=sh(p,m,t,n,i),_=sh(f,g,t,n,i);let x=e.prevZ,y=e.nextZ;for(;x&&x.z>=v&&y&&y.z<=_;){if(x.x>=p&&x.x<=f&&x.y>=m&&x.y<=g&&x!==r&&x!==a&&oh(o,h,l,u,c,d,x.x,x.y)&&ch(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,y.x>=p&&y.x<=f&&y.y>=m&&y.y<=g&&y!==r&&y!==a&&oh(o,h,l,u,c,d,y.x,y.y)&&ch(y.prev,y,y.next)>=0)return!1;y=y.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=f&&x.y>=m&&x.y<=g&&x!==r&&x!==a&&oh(o,h,l,u,c,d,x.x,x.y)&&ch(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;y&&y.z<=_;){if(y.x>=p&&y.x<=f&&y.y>=m&&y.y<=g&&y!==r&&y!==a&&oh(o,h,l,u,c,d,y.x,y.y)&&ch(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function eh(e,t,n){let i=e;do{const r=i.prev,s=i.next.next;!hh(r,s)&&uh(r,i,i.next,s)&&mh(r,s)&&mh(s,r)&&(t.push(r.i/n|0),t.push(i.i/n|0),t.push(s.i/n|0),vh(i),vh(i.next),i=e=s),i=i.next}while(i!==e);return Kc(i)}function th(e,t,n,i,r,s){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&lh(a,e)){let o=fh(a,e);return a=Kc(a,a.next),o=Kc(o,o.next),Jc(a,t,n,i,r,s,0),void Jc(o,t,n,i,r,s,0)}e=e.next}a=a.next}while(a!==e)}function nh(e,t){return e.x-t.x}function ih(e,t){const n=function(e,t){let n,i=t,r=-Infinity;const s=e.x,a=e.y;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){const e=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=s&&e>r&&(r=e,n=i.x=i.x&&i.x>=l&&s!==i.x&&oh(an.x||i.x===n.x&&rh(n,i)))&&(n=i,u=h)),i=i.next}while(i!==o);return n}(e,t);if(!n)return t;const i=fh(n,e);return Kc(i,i.next),Kc(n,n.next)}function rh(e,t){return ch(e.prev,e,t.prev)<0&&ch(t.next,e,e.next)<0}function sh(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function ah(e){let t=e,n=e;do{(t.x=(e-a)*(s-o)&&(e-a)*(i-o)>=(n-a)*(t-o)&&(n-a)*(s-o)>=(r-a)*(i-o)}function lh(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&uh(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(mh(e,t)&&mh(t,e)&&function(e,t){let n=e,i=!1;const r=(e.x+t.x)/2,s=(e.y+t.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&r<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)&&(ch(e.prev,e,t.prev)||ch(e,t.prev,t))||hh(e,t)&&ch(e.prev,e,e.next)>0&&ch(t.prev,t,t.next)>0)}function ch(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function hh(e,t){return e.x===t.x&&e.y===t.y}function uh(e,t,n,i){const r=ph(ch(e,t,n)),s=ph(ch(e,t,i)),a=ph(ch(n,i,e)),o=ph(ch(n,i,t));return r!==s&&a!==o||(!(0!==r||!dh(e,n,t))||(!(0!==s||!dh(e,i,t))||(!(0!==a||!dh(n,e,i))||!(0!==o||!dh(n,t,i)))))}function dh(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function ph(e){return e>0?1:e<0?-1:0}function mh(e,t){return ch(e.prev,e,e.next)<0?ch(e,t,e.next)>=0&&ch(e,e.prev,t)>=0:ch(e,t,e.prev)<0||ch(e,e.next,t)<0}function fh(e,t){const n=new _h(e.i,e.x,e.y),i=new _h(t.i,t.x,t.y),r=e.next,s=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function gh(e,t,n,i){const r=new _h(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function vh(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function _h(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class xh{static area(e){const t=e.length;let n=0;for(let i=t-1,r=0;r2&&e[t-1].equals(e[0])&&e.pop()}function Mh(e,t){for(let n=0;nNumber.EPSILON){const u=Math.sqrt(h),d=Math.sqrt(l*l+c*c),p=t.x-o/u,m=t.y+a/u,f=((n.x-c/d-p)*c-(n.y+l/d-m)*l)/(a*c-o*l);i=p+a*f-e.x,r=m+o*f-e.y;const g=i*i+r*r;if(g<=2)return new mn(i,r);s=Math.sqrt(g/2)}else{let e=!1;a>Number.EPSILON?l>Number.EPSILON&&(e=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(o)===Math.sign(c)&&(e=!0),e?(i=-o,r=a,s=Math.sqrt(h)):(i=a,r=o,s=Math.sqrt(h/2))}return new mn(i/s,r/s)}const L=[];for(let e=0,t=E.length,n=t-1,i=e+1;e=0;e--){const t=e/p,n=h*Math.cos(t*Math.PI/2),i=u*Math.sin(t*Math.PI/2)+d;for(let e=0,t=E.length;e=0;){const i=n;let r=n-1;r<0&&(r=e.length-1);for(let e=0,n=o+2*p;e0)&&d.push(t,r,l),(e!==n-1||o0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class kh extends ir{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new lr(16777215),this.specular=new lr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new lr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new mn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=_e,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(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Hh extends ir{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new lr(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new lr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new mn(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(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Gh extends ir{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new mn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Vh extends ir{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new lr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new lr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new mn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=_e,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(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Wh extends ir{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new lr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new mn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class jh extends Xl{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Xh(e,t,n){return Yh(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)}function qh(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function Yh(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Zh(e){const t=e.length,n=new Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort((function(t,n){return e[t]-e[n]})),n}function Kh(e,t,n){const i=e.length,r=new e.constructor(i);for(let s=0,a=0;a!==i;++s){const i=n[s]*t;for(let n=0;n!==t;++n)r[a++]=e[i+n]}return r}function Jh(e,t,n,i){let r=1,s=e[0];for(;void 0!==s&&void 0===s[i];)s=e[r++];if(void 0===s)return;let a=s[i];if(void 0!==a)if(Array.isArray(a))do{a=s[i],void 0!==a&&(t.push(s.time),n.push.apply(n,a)),s=e[r++]}while(void 0!==s);else if(void 0!==a.toArray)do{a=s[i],void 0!==a&&(t.push(s.time),a.toArray(n,n.length)),s=e[r++]}while(void 0!==s);else do{a=s[i],void 0!==a&&(t.push(s.time),n.push(a)),s=e[r++]}while(void 0!==s)}const Qh={arraySlice:Xh,convertArray:qh,isTypedArray:Yh,getKeyframeOrder:Zh,sortedArray:Kh,flattenJSON:Jh,subclip:function(e,t,n,i,r=30){const s=e.clone();s.name=t;const a=[];for(let e=0;e=i)){l.push(t.times[e]);for(let n=0;ns.tracks[e].times[0]&&(o=s.tracks[e].times[0]);for(let e=0;e=i.times[u]){const e=u*l+o,t=e+l-o;d=Xh(i.values,e,t)}else{const e=i.createInterpolant(),t=o,n=l-o;e.evaluate(s),d=Xh(e.resultBuffer,t,n)}if("quaternion"===r){(new Hn).fromArray(d).normalize().conjugate().toArray(d)}const p=a.times.length;for(let e=0;e=r)break e;{const a=t[1];e=r)break t}s=n,n=0}}for(;n>>1;et;)--s;if(++s,0!==r||s!==i){r>=s&&(s=Math.max(s,1),r=s-1);const e=this.getValueSize();this.times=Xh(n,r,s),this.values=Xh(this.values,r*e,s*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let t=0;t!==r;t++){const i=n[t];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,i),e=!1;break}if(null!==s&&s>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,i,s),e=!1;break}s=i}if(void 0!==i&&Yh(i))for(let t=0,n=i.length;t!==n;++t){const n=i[t];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}return e}optimize(){const e=Xh(this.times),t=Xh(this.values),n=this.getValueSize(),i=this.getInterpolation()===Ut,r=e.length-1;let s=1;for(let a=1;a0){e[s]=e[r];for(let e=r*n,i=s*n,a=0;a!==n;++a)t[i+a]=t[e+a];++s}return s!==e.length?(this.times=Xh(e,0,s),this.values=Xh(t,0,s*n)):(this.times=e,this.values=t),this}clone(){const e=Xh(this.times,0),t=Xh(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}iu.prototype.TimeBufferType=Float32Array,iu.prototype.ValueBufferType=Float32Array,iu.prototype.DefaultInterpolation=Dt;class ru extends iu{}ru.prototype.ValueTypeName="bool",ru.prototype.ValueBufferType=Array,ru.prototype.DefaultInterpolation=It,ru.prototype.InterpolantFactoryMethodLinear=void 0,ru.prototype.InterpolantFactoryMethodSmooth=void 0;class su extends iu{}su.prototype.ValueTypeName="color";class au extends iu{}au.prototype.ValueTypeName="number";class ou extends $h{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(n-t)/(i-t);let l=e*a;for(let e=l+a;l!==e;l+=4)Hn.slerpFlat(r,0,s,l-a,s,l,o);return r}}class lu extends iu{InterpolantFactoryMethodLinear(e){return new ou(this.times,this.values,this.getValueSize(),e)}}lu.prototype.ValueTypeName="quaternion",lu.prototype.DefaultInterpolation=Dt,lu.prototype.InterpolantFactoryMethodSmooth=void 0;class cu extends iu{}cu.prototype.ValueTypeName="string",cu.prototype.ValueBufferType=Array,cu.prototype.DefaultInterpolation=It,cu.prototype.InterpolantFactoryMethodLinear=void 0,cu.prototype.InterpolantFactoryMethodSmooth=void 0;class hu extends iu{}hu.prototype.ValueTypeName="vector";class uu{constructor(e,t=-1,n,i=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=rn(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let e=0,r=n.length;e!==r;++e)t.push(du(n[e]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,i=n.length;e!==i;++e)t.push(iu.toJSON(n[e]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,s=[];for(let e=0;e1){const e=s[1];let t=i[e];t||(i[e]=t=[]),t.push(n)}}const s=[];for(const e in i)s.push(this.CreateFromMorphTargetSequence(e,i[e],t,n));return s}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,i,r){if(0!==n.length){const s=[],a=[];Jh(n,s,a,i),0!==s.length&&r.push(new e(t,s,a))}},i=[],r=e.name||"default",s=e.fps||30,a=e.blendMode;let o=e.length||-1;const l=e.hierarchy||[];for(let e=0;e{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==vu[e])return void vu[e].push({onLoad:t,onProgress:n,onError:i});vu[e]=[],vu[e].push({onLoad:t,onProgress:n,onError:i});const s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(s).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const n=vu[e],i=t.body.getReader(),r=t.headers.get("Content-Length")||t.headers.get("X-File-Size"),s=r?parseInt(r):0,a=0!==s;let o=0;const l=new ReadableStream({start(e){!function t(){i.read().then((({done:i,value:r})=>{if(i)e.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:s});for(let e=0,t=n.length;e{switch(o){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,a)));case"json":return e.json();default:if(void 0===a)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(a),n=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(n);return e.arrayBuffer().then((e=>i.decode(e)))}}})).then((t=>{pu.add(e,t);const n=vu[e];delete vu[e];for(let e=0,i=n.length;e{const n=vu[e];if(void 0===n)throw this.manager.itemError(e),t;delete vu[e];for(let e=0,i=n.length;e{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class yu extends gu{constructor(e){super(e)}load(e,t,n,i){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,s=pu.get(e);if(void 0!==s)return r.manager.itemStart(e),setTimeout((function(){t&&t(s),r.manager.itemEnd(e)}),0),s;const a=yn("img");function o(){c(),pu.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(t){c(),i&&i(t),r.manager.itemError(e),r.manager.itemEnd(e)}function c(){a.removeEventListener("load",o,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",l,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(e),a.src=e,a}}class Mu extends gu{constructor(e){super(e)}load(e,t,n,i){const r=new On,s=new yu(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,(function(e){r.image=e,r.needsUpdate=!0,void 0!==t&&t(r)}),n,i),r}}class Su extends Vi{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new lr(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}class bu extends Su{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Vi.DEFAULT_UP),this.updateMatrix(),this.groundColor=new lr(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const Tu=new _i,wu=new Gn,Eu=new Gn;class Au{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new mn(512,512),this.map=null,this.mapPass=null,this.matrix=new _i,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ps,this._frameExtents=new mn(1,1),this._viewportCount=1,this._viewports=[new Fn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;wu.setFromMatrixPosition(e.matrixWorld),t.position.copy(wu),Eu.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Eu),t.updateMatrixWorld(),Tu.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Tu),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Tu)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class Ru extends Au{constructor(){super(new ns(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=2*nn*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;n===t.fov&&i===t.aspect&&r===t.far||(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Cu extends Su{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Vi.DEFAULT_UP),this.updateMatrix(),this.target=new Vi,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new Ru}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const Pu=new _i,Lu=new Gn,Iu=new Gn;class Du extends Au{constructor(){super(new ns(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new mn(4,2),this._viewportCount=6,this._viewports=[new Fn(2,1,1,1),new Fn(0,1,1,1),new Fn(3,1,1,1),new Fn(1,1,1,1),new Fn(3,0,1,1),new Fn(1,0,1,1)],this._cubeDirections=[new Gn(1,0,0),new Gn(-1,0,0),new Gn(0,0,1),new Gn(0,0,-1),new Gn(0,1,0),new Gn(0,-1,0)],this._cubeUps=[new Gn(0,1,0),new Gn(0,1,0),new Gn(0,1,0),new Gn(0,1,0),new Gn(0,0,1),new Gn(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),Lu.setFromMatrixPosition(e.matrixWorld),n.position.copy(Lu),Iu.copy(n.position),Iu.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Iu),n.updateMatrixWorld(),i.makeTranslation(-Lu.x,-Lu.y,-Lu.z),Pu.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Pu)}}class Uu extends Su{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Du}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class Nu extends Au{constructor(){super(new As(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Ou extends Su{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Vi.DEFAULT_UP),this.updateMatrix(),this.target=new Vi,this.shadow=new Nu}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Fu extends Su{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class zu extends Su{constructor(e,t,n=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class Bu{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new Gn)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,i=e.y,r=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.282095),t.addScaledVector(s[1],.488603*i),t.addScaledVector(s[2],.488603*r),t.addScaledVector(s[3],.488603*n),t.addScaledVector(s[4],n*i*1.092548),t.addScaledVector(s[5],i*r*1.092548),t.addScaledVector(s[6],.315392*(3*r*r-1)),t.addScaledVector(s[7],n*r*1.092548),t.addScaledVector(s[8],.546274*(n*n-i*i)),t}getIrradianceAt(e,t){const n=e.x,i=e.y,r=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.886227),t.addScaledVector(s[1],1.023328*i),t.addScaledVector(s[2],1.023328*r),t.addScaledVector(s[3],1.023328*n),t.addScaledVector(s[4],.858086*n*i),t.addScaledVector(s[5],.858086*i*r),t.addScaledVector(s[6],.743125*r*r-.247708),t.addScaledVector(s[7],.858086*n*r),t.addScaledVector(s[8],.429043*(n*n-i*i)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(e,t+3*i);return this}toArray(e=[],t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(e,t+3*i);return e}static getBasisAt(e,t){const n=e.x,i=e.y,r=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*r,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*n*r,t[8]=.546274*(n*n-i*i)}}class ku extends Su{constructor(e=new Bu,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class Hu extends gu{constructor(e){super(e),this.textures={}}load(e,t,n,i){const r=this,s=new xu(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(e,(function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e){const t=this.textures;function n(e){return void 0===t[e]&&console.warn("THREE.MaterialLoader: Undefined texture",e),t[e]}const i=Hu.createMaterialFromType(e.type);if(void 0!==e.uuid&&(i.uuid=e.uuid),void 0!==e.name&&(i.name=e.name),void 0!==e.color&&void 0!==i.color&&i.color.setHex(e.color),void 0!==e.roughness&&(i.roughness=e.roughness),void 0!==e.metalness&&(i.metalness=e.metalness),void 0!==e.sheen&&(i.sheen=e.sheen),void 0!==e.sheenColor&&(i.sheenColor=(new lr).setHex(e.sheenColor)),void 0!==e.sheenRoughness&&(i.sheenRoughness=e.sheenRoughness),void 0!==e.emissive&&void 0!==i.emissive&&i.emissive.setHex(e.emissive),void 0!==e.specular&&void 0!==i.specular&&i.specular.setHex(e.specular),void 0!==e.specularIntensity&&(i.specularIntensity=e.specularIntensity),void 0!==e.specularColor&&void 0!==i.specularColor&&i.specularColor.setHex(e.specularColor),void 0!==e.shininess&&(i.shininess=e.shininess),void 0!==e.clearcoat&&(i.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(i.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.iridescence&&(i.iridescence=e.iridescence),void 0!==e.iridescenceIOR&&(i.iridescenceIOR=e.iridescenceIOR),void 0!==e.iridescenceThicknessRange&&(i.iridescenceThicknessRange=e.iridescenceThicknessRange),void 0!==e.transmission&&(i.transmission=e.transmission),void 0!==e.thickness&&(i.thickness=e.thickness),void 0!==e.attenuationDistance&&(i.attenuationDistance=e.attenuationDistance),void 0!==e.attenuationColor&&void 0!==i.attenuationColor&&i.attenuationColor.setHex(e.attenuationColor),void 0!==e.anisotropy&&(i.anisotropy=e.anisotropy),void 0!==e.anisotropyRotation&&(i.anisotropyRotation=e.anisotropyRotation),void 0!==e.fog&&(i.fog=e.fog),void 0!==e.flatShading&&(i.flatShading=e.flatShading),void 0!==e.blending&&(i.blending=e.blending),void 0!==e.combine&&(i.combine=e.combine),void 0!==e.side&&(i.side=e.side),void 0!==e.shadowSide&&(i.shadowSide=e.shadowSide),void 0!==e.opacity&&(i.opacity=e.opacity),void 0!==e.transparent&&(i.transparent=e.transparent),void 0!==e.alphaTest&&(i.alphaTest=e.alphaTest),void 0!==e.alphaHash&&(i.alphaHash=e.alphaHash),void 0!==e.depthTest&&(i.depthTest=e.depthTest),void 0!==e.depthWrite&&(i.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(i.colorWrite=e.colorWrite),void 0!==e.stencilWrite&&(i.stencilWrite=e.stencilWrite),void 0!==e.stencilWriteMask&&(i.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(i.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(i.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(i.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(i.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(i.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(i.stencilZPass=e.stencilZPass),void 0!==e.wireframe&&(i.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(i.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(i.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(i.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(i.rotation=e.rotation),1!==e.linewidth&&(i.linewidth=e.linewidth),void 0!==e.dashSize&&(i.dashSize=e.dashSize),void 0!==e.gapSize&&(i.gapSize=e.gapSize),void 0!==e.scale&&(i.scale=e.scale),void 0!==e.polygonOffset&&(i.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(i.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(i.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.dithering&&(i.dithering=e.dithering),void 0!==e.alphaToCoverage&&(i.alphaToCoverage=e.alphaToCoverage),void 0!==e.premultipliedAlpha&&(i.premultipliedAlpha=e.premultipliedAlpha),void 0!==e.forceSinglePass&&(i.forceSinglePass=e.forceSinglePass),void 0!==e.visible&&(i.visible=e.visible),void 0!==e.toneMapped&&(i.toneMapped=e.toneMapped),void 0!==e.userData&&(i.userData=e.userData),void 0!==e.vertexColors&&("number"==typeof e.vertexColors?i.vertexColors=e.vertexColors>0:i.vertexColors=e.vertexColors),void 0!==e.uniforms)for(const t in e.uniforms){const r=e.uniforms[t];switch(i.uniforms[t]={},r.type){case"t":i.uniforms[t].value=n(r.value);break;case"c":i.uniforms[t].value=(new lr).setHex(r.value);break;case"v2":i.uniforms[t].value=(new mn).fromArray(r.value);break;case"v3":i.uniforms[t].value=(new Gn).fromArray(r.value);break;case"v4":i.uniforms[t].value=(new Fn).fromArray(r.value);break;case"m3":i.uniforms[t].value=(new fn).fromArray(r.value);break;case"m4":i.uniforms[t].value=(new _i).fromArray(r.value);break;default:i.uniforms[t].value=r.value}}if(void 0!==e.defines&&(i.defines=e.defines),void 0!==e.vertexShader&&(i.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(i.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(i.glslVersion=e.glslVersion),void 0!==e.extensions)for(const t in e.extensions)i.extensions[t]=e.extensions[t];if(void 0!==e.lights&&(i.lights=e.lights),void 0!==e.clipping&&(i.clipping=e.clipping),void 0!==e.size&&(i.size=e.size),void 0!==e.sizeAttenuation&&(i.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(i.map=n(e.map)),void 0!==e.matcap&&(i.matcap=n(e.matcap)),void 0!==e.alphaMap&&(i.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(i.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(i.bumpScale=e.bumpScale),void 0!==e.normalMap&&(i.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(i.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),i.normalScale=(new mn).fromArray(t)}return void 0!==e.displacementMap&&(i.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(i.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(i.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(i.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(i.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(i.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(i.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(i.specularMap=n(e.specularMap)),void 0!==e.specularIntensityMap&&(i.specularIntensityMap=n(e.specularIntensityMap)),void 0!==e.specularColorMap&&(i.specularColorMap=n(e.specularColorMap)),void 0!==e.envMap&&(i.envMap=n(e.envMap)),void 0!==e.envMapIntensity&&(i.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(i.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(i.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(i.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(i.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(i.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(i.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(i.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(i.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(i.clearcoatNormalScale=(new mn).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(i.iridescenceMap=n(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(i.transmissionMap=n(e.transmissionMap)),void 0!==e.thicknessMap&&(i.thicknessMap=n(e.thicknessMap)),void 0!==e.anisotropyMap&&(i.anisotropyMap=n(e.anisotropyMap)),void 0!==e.sheenColorMap&&(i.sheenColorMap=n(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){return new{ShadowMaterial:Oh,SpriteMaterial:il,RawShaderMaterial:Fh,ShaderMaterial:es,PointsMaterial:ic,MeshPhysicalMaterial:Bh,MeshStandardMaterial:zh,MeshPhongMaterial:kh,MeshToonMaterial:Hh,MeshNormalMaterial:Gh,MeshLambertMaterial:Vh,MeshDepthMaterial:Uo,MeshDistanceMaterial:No,MeshBasicMaterial:hr,MeshMatcapMaterial:Wh,LineDashedMaterial:jh,LineBasicMaterial:Xl,Material:ir}[e]}}class Gu{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,i=e.length;n0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(n[e]!==n[e+t]){a.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let e=n,r=i;e!==r;++e)t[e]=t[i+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let i=0;i!==r;++i)e[t+i]=e[n+i]}_slerp(e,t,n,i){Hn.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){const s=this._workIndex*r;Hn.multiplyQuaternionsFlat(e,s,e,t,e,n),Hn.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){const s=1-i;for(let a=0;a!==r;++a){const r=t+a;e[r]=e[r]*s+e[n+a]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){const r=t+s;e[r]=e[r]+e[n+s]*i}}}const md="\\[\\]\\.:\\/",fd=new RegExp("["+md+"]","g"),gd="[^"+md+"]",vd="[^"+md.replace("\\.","")+"]",_d=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",gd)+/(WCOD+)?/.source.replace("WCOD",vd)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",gd)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",gd)+"$"),xd=["material","materials","bones","map"];class yd{constructor(e,t,n){this.path=t,this.parsedPath=n||yd.parseTrackName(t),this.node=yd.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new yd.Composite(e,t,n):new yd(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(fd,"")}static parseTrackName(e){const t=_d.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const e=n.nodeName.substring(i+1);-1!==xd.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){const n=function(e){for(let i=0;i0){const e=this._interpolants,t=this._propertyBindings;if(this.blendMode===Bt)for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(s),t[n].accumulateAdditive(a);else for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(s),t[n].accumulate(i,a)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(null!==n){t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,r=this._loopCount;const s=2202===n;if(0===e)return-1===r?i:s&&1==(1&r)?t-i:i;if(n===Lt){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else{if(!(i<0)){this.time=i;break e}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),i>=t||i<0){const n=Math.floor(i/t);i-=t*n,r+=Math.abs(n);const a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===a){const t=e<0;this._setEndings(t,!t,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(s&&1==(1&r))return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=Ot,i.endingEnd=Ot):(i.endingStart=e?this.zeroSlopeAtStart?Ot:Nt:Ft,i.endingEnd=t?this.zeroSlopeAtEnd?Ot:Nt:Ft)}_scheduleFading(e,t,n){const i=this._mixer,r=i.time;let s=this._weightInterpolant;null===s&&(s=i._lendControlInterpolant(),this._weightInterpolant=s);const a=s.parameterPositions,o=s.sampleValues;return a[0]=r,o[0]=t,a[1]=r+e,o[1]=n,this}}const Sd=new Float32Array(1);class bd extends Qt{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,s=e._propertyBindings,a=e._interpolants,o=n.uuid,l=this._bindingsByRootAndName;let c=l[o];void 0===c&&(c={},l[o]=c);for(let e=0;e!==r;++e){const r=i[e],l=r.name;let h=c[l];if(void 0!==h)++h.referenceCount,s[e]=h;else{if(h=s[e],void 0!==h){null===h._cacheIndex&&(++h.referenceCount,this._addInactiveBinding(h,o,l));continue}const i=t&&t._propertyBindings[e].binding.parsedPath;h=new pd(yd.create(n,l,i),r.ValueTypeName,r.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,o,l),s[e]=h}a[e].resultBuffer=h.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return null!==t&&t=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let a=0;a!==n;++a){t[a]._update(i,e,r,s)}const a=this._bindings,o=this._nActiveBindings;for(let e=0;e!==o;++e)a[e].apply(s);return this}setTime(e){this.time=0;for(let e=0;eNumber.EPSILON){if(l<0&&(n=t[s],o=-o,a=t[r],l=-l),e.ya.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{const t=l*(e.x-n.x)-o*(e.y-n.y);if(0===t)return!0;if(t<0)continue;i=!i}}else{if(e.y!==n.y)continue;if(a.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=a.x)return!0}}return i}const n=xh.isClockWise,i=this.subPaths;if(0===i.length)return[];let r,s,a;const o=[];if(1===i.length)return s=i[0],a=new qc,a.curves=s.curves,o.push(a),o;let l=!n(i[0].getPoints());l=e?!l:l;const c=[],h=[];let u,d,p=[],m=0;h[m]=void 0,p[m]=[];for(let t=0,a=i.length;t1){let e=!1,n=0;for(let e=0,t=h.length;e0&&!1===e&&(p=c)}for(let e=0,t=h.length;e=r){const s=r++,c=e[s];t[c.uuid]=l,e[l]=c,t[o]=s,e[s]=a;for(let e=0,t=i;e!==t;++e){const t=n[e],i=t[s],r=t[l];t[l]=i,t[s]=r}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,s=e.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,l=t[o];if(void 0!==l)if(delete t[o],l0&&(t[a.uuid]=l),e[l]=a,e.pop();for(let e=0,t=i;e!==t;++e){const t=n[e];t[l]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const r=this._bindings;if(void 0!==i)return r[i];const s=this._paths,a=this._parsedPaths,o=this._objects,l=o.length,c=this.nCachedObjects_,h=new Array(l);i=r.length,n[e]=i,s.push(e),a.push(t),r.push(h);for(let n=c,i=o.length;n!==i;++n){const i=o[n];h[n]=new yd(i,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){const i=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length-1,o=s[a];t[e[a]]=n,s[n]=o,s.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}},AnimationUtils:Qh,ArcCurve:fc,ArrayCamera:ko,ArrowHelper:class extends Vi{constructor(e=new Gn(0,0,1),t=new Gn(0,0,0),n=1,i=16776960,r=.2*n,s=.2*r){super(),this.type="ArrowHelper",void 0===Kd&&(Kd=new Cr,Kd.setAttribute("position",new Mr([0,0,0,0,1,0],3)),Jd=new zc(0,.5,1,5,1),Jd.translate(0,-.5,0)),this.position.copy(t),this.line=new Ql(Kd,new Xl({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new qr(Jd,new hr({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,r,s)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Zd.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Zd,t)}}setLength(e,t=.2*e,n=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},Audio:ld,AudioAnalyser:class{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let n=0;nthis.max.x||e.ythis.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Pd).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Box3:jn,Box3Helper:class extends tc{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Cr;i.setIndex(new _r(n,1)),i.setAttribute("position",new Mr([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(i,new Xl({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},BoxGeometry:Zr,BoxHelper:class extends tc{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),r=new Cr;r.setIndex(new _r(n,1)),r.setAttribute("position",new _r(i,3)),super(r,new Xl({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(void 0!==e&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&Yd.setFromObject(this.object),Yd.isEmpty())return;const t=Yd.min,n=Yd.max,i=this.geometry.attributes.position,r=i.array;r[0]=n.x,r[1]=n.y,r[2]=n.z,r[3]=t.x,r[4]=n.y,r[5]=n.z,r[6]=t.x,r[7]=t.y,r[8]=n.z,r[9]=n.x,r[10]=t.y,r[11]=n.z,r[12]=n.x,r[13]=n.y,r[14]=t.z,r[15]=t.x,r[16]=n.y,r[17]=t.z,r[18]=t.x,r[19]=t.y,r[20]=t.z,r[21]=n.x,r[22]=t.y,r[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BufferAttribute:_r,BufferGeometry:Cr,BufferGeometryLoader:Wu,ByteType:1010,Cache:pu,Camera:ts,CameraHelper:class extends tc{constructor(e){const t=new Cr,n=new Xl({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],r=[],s={};function a(e,t){o(e),o(t)}function o(e){i.push(0,0,0),r.push(0,0,0),void 0===s[e]&&(s[e]=[]),s[e].push(i.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),t.setAttribute("position",new Mr(i,3)),t.setAttribute("color",new Mr(r,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update();const l=new lr(16755200),c=new lr(16711680),h=new lr(43775),u=new lr(16777215),d=new lr(3355443);this.setColors(l,c,h,u,d)}setColors(e,t,n,i,r){const s=this.geometry.getAttribute("color");s.setXYZ(0,e.r,e.g,e.b),s.setXYZ(1,e.r,e.g,e.b),s.setXYZ(2,e.r,e.g,e.b),s.setXYZ(3,e.r,e.g,e.b),s.setXYZ(4,e.r,e.g,e.b),s.setXYZ(5,e.r,e.g,e.b),s.setXYZ(6,e.r,e.g,e.b),s.setXYZ(7,e.r,e.g,e.b),s.setXYZ(8,e.r,e.g,e.b),s.setXYZ(9,e.r,e.g,e.b),s.setXYZ(10,e.r,e.g,e.b),s.setXYZ(11,e.r,e.g,e.b),s.setXYZ(12,e.r,e.g,e.b),s.setXYZ(13,e.r,e.g,e.b),s.setXYZ(14,e.r,e.g,e.b),s.setXYZ(15,e.r,e.g,e.b),s.setXYZ(16,e.r,e.g,e.b),s.setXYZ(17,e.r,e.g,e.b),s.setXYZ(18,e.r,e.g,e.b),s.setXYZ(19,e.r,e.g,e.b),s.setXYZ(20,e.r,e.g,e.b),s.setXYZ(21,e.r,e.g,e.b),s.setXYZ(22,e.r,e.g,e.b),s.setXYZ(23,e.r,e.g,e.b),s.setXYZ(24,t.r,t.g,t.b),s.setXYZ(25,t.r,t.g,t.b),s.setXYZ(26,t.r,t.g,t.b),s.setXYZ(27,t.r,t.g,t.b),s.setXYZ(28,t.r,t.g,t.b),s.setXYZ(29,t.r,t.g,t.b),s.setXYZ(30,t.r,t.g,t.b),s.setXYZ(31,t.r,t.g,t.b),s.setXYZ(32,n.r,n.g,n.b),s.setXYZ(33,n.r,n.g,n.b),s.setXYZ(34,n.r,n.g,n.b),s.setXYZ(35,n.r,n.g,n.b),s.setXYZ(36,n.r,n.g,n.b),s.setXYZ(37,n.r,n.g,n.b),s.setXYZ(38,i.r,i.g,i.b),s.setXYZ(39,i.r,i.g,i.b),s.setXYZ(40,r.r,r.g,r.b),s.setXYZ(41,r.r,r.g,r.b),s.setXYZ(42,r.r,r.g,r.b),s.setXYZ(43,r.r,r.g,r.b),s.setXYZ(44,r.r,r.g,r.b),s.setXYZ(45,r.r,r.g,r.b),s.setXYZ(46,r.r,r.g,r.b),s.setXYZ(47,r.r,r.g,r.b),s.setXYZ(48,r.r,r.g,r.b),s.setXYZ(49,r.r,r.g,r.b),s.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap;Xd.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),qd("c",t,e,Xd,0,0,-1),qd("t",t,e,Xd,0,0,1),qd("n1",t,e,Xd,-1,-1,-1),qd("n2",t,e,Xd,1,-1,-1),qd("n3",t,e,Xd,-1,1,-1),qd("n4",t,e,Xd,1,1,-1),qd("f1",t,e,Xd,-1,-1,1),qd("f2",t,e,Xd,1,-1,1),qd("f3",t,e,Xd,-1,1,1),qd("f4",t,e,Xd,1,1,1),qd("u1",t,e,Xd,.7,1.1,-1),qd("u2",t,e,Xd,-.7,1.1,-1),qd("u3",t,e,Xd,0,2,-1),qd("cf1",t,e,Xd,-1,0,1),qd("cf2",t,e,Xd,1,0,1),qd("cf3",t,e,Xd,0,-1,1),qd("cf4",t,e,Xd,0,1,1),qd("cn1",t,e,Xd,-1,0,-1),qd("cn2",t,e,Xd,1,0,-1),qd("cn3",t,e,Xd,0,-1,-1),qd("cn4",t,e,Xd,0,1,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},CanvasTexture:dc,CapsuleGeometry:Oc,CatmullRomCurve3:Mc,CineonToneMapping:Te,CircleGeometry:Fc,ClampToEdgeWrapping:Ue,Clock:td,Color:lr,ColorKeyframeTrack:su,ColorManagement:Cn,CompressedArrayTexture:class extends uc{constructor(e,t,n,i,r,s){super(e,t,n,r,s),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=Ue}},CompressedTexture:uc,CompressedTextureLoader:class extends gu{constructor(e){super(e)}load(e,t,n,i){const r=this,s=[],a=new uc,o=new xu(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(r.withCredentials);let l=0;function c(c){o.load(e[c],(function(e){const n=r.parse(e,!0);s[c]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},l+=1,6===l&&(1===n.mipmapCount&&(a.minFilter=Be),a.image=s,a.format=n.format,a.needsUpdate=!0,t&&t(a))}),n,i)}if(Array.isArray(e))for(let t=0,n=e.length;t0){const n=new mu(t);r=new yu(n),r.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t0){i=new yu(this.manager),i.setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;t1)for(let n=0;n1e3*((e,t)=>{var n=ep(t.lat-e.lat)/2,i=ep(t.lng-e.lng)/2,r=ep(e.lat),s=ep(t.lat),a=tp.sin(n)*tp.sin(n)+tp.sin(i)*tp.sin(i)*(tp.cos(r)*tp.cos(s));return 2*tp.atan2(tp.sqrt(a),tp.sqrt(1-a))*6371})(e,t),ip=(e,t)=>((e,t)=>t.sort(((t,n)=>np(e,t)-np(e,n))))(e,t)[0],rp=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;return parseFloat(e).toPrecision(t)/1},sp=["className","id","innerText","children","on","parent","style"],ap=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{parent:n=q.D,single:i=!1}=t,r=e.split(" "),s=r[r.length-1];return i||s.startsWith("#")?n.querySelector(e):Array.from(n.querySelectorAll(e))};ap.show=(e,t)=>{X.str(e)&&(e=ap(e,t)),e&&(X.arr(e)?e.forEach((e=>ap.show(e,t))):e.classList&&e.classList.add("visible"))},ap.hide=(e,t)=>{X.str(e)&&(e=ap(e,t)),e&&(X.arr(e)?e.forEach((e=>ap.hide(e,t))):e.classList&&e.classList.remove("visible"))},ap.prop=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};X.str(e)&&(e=ap(e)),Object.entries(t).forEach((t=>{var[n,i]=t;!1===i?e.removeAttribute(n):e.setAttribute(n,i)}))},ap.create=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{className:n,id:i,innerText:r,children:a,on:o,parent:l,style:c}=t,h=s(t,sp),u=q.D.createElement(e);n&&(u.className=n),r&&(u.innerText=r),a&&(X.str(a)?u.innerText+=a:X.arr(a)&&a.forEach((e=>u.appendChild(e)))),c&&Object.entries(c).forEach((e=>{var[t,n]=e;u.style[t]=n})),i&&u.setAttribute("id",i),o&&Object.entries(o).forEach((e=>{var[t,n]=e;u.addEventListener(t,n)})),l&&ap.append(u,l);var d=Object.entries(h);return d.length&&d.map((e=>{var[t,n]=e;u.setAttribute(t,n)})),u},ap.on=function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};X.str(e)&&(e=ap(e)),e?X.arr(e)?e.forEach((e=>e.addEventListener(t,n,!1,i))):e.addEventListener(t,n,!1,i):console.error(new Error("tried to attach event listener to empty ele"))},ap.off=(e,t,n,i)=>{X.str(e)&&(e=ap(e)),X.arr(e)?e.forEach((e=>e.removeEventListener(t,n,!1,i))):e.removeEventListener(t,n,!1,i)},ap.append=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:B;X.str(e)&&(e=ap(e)),X.str(t)&&(t=ap(t)),t&&e&&(X.arr(e)?e.forEach((e=>t.appendChild(e))):t.appendChild(e))},ap.remove=e=>{e&&(X.str(e)&&(e=ap(e)),X.arr(e)?e.forEach((e=>ap.remove(e))):e&&e.parentNode&&e.parentNode.removeChild(e))};var op,lp=()=>new URLSearchParams(q.location.hash.substr(1)),cp=()=>{var e=lp(),t=e.get("z");X.num(parseInt(t,10))||e.set("z",17);var n={},i={z:"zoom",d:"detail",p:"popup",s:"screen"};for(var[r,s]of e.entries())r in i&&(r=i[r]),n[r]=s;return n},hp=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};q.STATE=t(t({},q.STATE),e),JSON.stringify(q.STATE)!==JSON.stringify(q.OLD_STATE)&&(up(q.STATE),q.OLD_STATE=q.STATE)},up=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{detail:t,lat:n,lng:i,popup:r,screen:s,three:a,zoom:o}=e,l=lp();o&&l.set("z",rp(o,3)),n&&l.set("lat",rp(n,7)),i&&l.set("lng",rp(i,7)),r?l.set("p",r):!1===r&&l.delete("p"),t?l.set("d",t):!1===t&&l.delete("d"),s?l.set("s",s):!1===s&&l.delete("s"),a||l.delete("t");var c=l.toString();q.location.hash!==c&&(q.location.hash=c)},dp=e=>{var{map:t,zoom:n}=e,{locationLayer:i,artifactLayer:r}=t;if(i){var s=16;i.zoomFromLocationToObject&&(s=i.zoomFromLocationToObject),n>=s?(t.hasLayer(i)&&t.removeLayer(i),t.hasLayer(r)||t.addLayer(r)):(t.hasLayer(i)||t.addLayer(i),t.hasLayer(r)&&t.removeLayer(r))}},pp=e=>{var t=ap(".nav.menu");e?t.forEach((t=>{if(t.dataset.to){var n=t.dataset.to===e||t.classList.contains(e),i=e.includes("-")&&t.classList.contains(e.split("-")[0]);n||i?t.classList.add("active"):t.classList.remove("active")}else t.classList.remove("active")})):t.forEach((e=>{e.classList.contains("map")?e.classList.add("active"):e.classList.remove("active")}))},mp=e=>{var t,n=!1;("home"===e&&(e="about"),ap(".screen.visible").forEach((e=>{e.classList.remove("visible")})),ap(".screen[data-name=".concat(e,"]")).forEach((e=>{e.classList.add("visible"),n=!0})),e)&&(e.startsWith("list-")?t=ap(".screen[data-name=list]",{single:!0}):e.startsWith("help-")&&(t=ap(".screen[data-name=help]",{single:!0})),t&&(t.classList.add("visible"),n=!0));n?("about"===e&&q.B.classList.add("about"),q.B.classList.add("screen-visible")):q.B.classList.remove("screen-visible","about")},fp=e=>{ap(".detail .info").forEach((t=>{var n=t.parentNode,{slug:i}=n.dataset;if(i===e){n.classList.add("visible");var r=n.offsetTop;X.num(r)&&(n.parentNode.parentNode.scrollTop=r)}else n.classList.remove("visible")}))},gp=e=>{var{map:t,popup:n}=e;t&&t.locationLayer&&[t.locationLayer,t.artifactLayer].forEach((e=>{e.eachLayer((e=>{n&&e.slug===n&&e.openPopup()}))}))},vp=e=>{e.currentTarget.parentNode.scrollTop=0},_p=e=>{op=e;var t=new URL(q.location);t.hash&&"#"!==t.hash?t.hash.includes("&t=1")||t.hash.startsWith("#t=1")||(t.hash="".concat(t.hash,"&t=1"),q.history.replaceState({},"",t)):(t.hash="#t=1",q.history.replaceState({},"",t))},xp=()=>{op=null,up()},yp=function(){var e=i((function*(){if(op)return yield op.onExitButtonClick(),op=null,!0}));return function(){return e.apply(this,arguments)}}(),Mp=(e,t,n)=>{return i=Math.round(e+n*(t-e)),r=0,s=255,Math.min(s,Math.max(r,i));var i,r,s},Sp=(e,t,n)=>{var[i,r,s]=e,[a,o,l]=t,c=Mp(i,a,n),h=Mp(r,o,n),u=Mp(s,l,n);return"rgb(".concat(c,", ").concat(h,", ").concat(u,")")},bp=e=>{var t=ap(".screen.about",{single:!0}),n=ap(".hero",{single:!0}),i=ap("header.main",{single:!0}),r=n&&i?n.clientHeight+i.clientHeight+200:0,s=ap(".mainMenu",{single:!0}),a=ap(".logoPath",{single:!0}),o=t&&t.classList.contains("visible"),l=!0===e||o,c=t&&t.scrollTop{var n="* {scrollbar-color: ".concat(t," ").concat(e,";}"),i=ap("#js-css");i||(i=ap.create("style",{id:"js-css"})),i.innerHTML=n,ap("head",{single:!0}).appendChild(i)})(d,p)}}else if(i.style.backgroundColor){i.style={},s.style={},a.style={};var m=ap("#js-css");m&&(m.innerHTML="")}},Tp=e=>{var t,n=null===(t=e.popup)||void 0===t||null===(t=t._source)||void 0===t?void 0:t.slug;n&&hp({popup:n})},wp=()=>{hp({popup:!1})},Ep=e=>{var{lat:t,lng:n}=e.target.getCenter();hp({lat:t,lng:n})},Ap=e=>{var t=e.target,{lat:n,lng:i}=t.getCenter(),r=t.getZoom();hp({lat:n,lng:i,zoom:r})},Rp=e=>{var{map:t,lat:n,lng:i,zoom:r,detail:s}=e;return()=>{var e=t.getZoom();hp({lat:n,lng:i,detail:s,zoom:e>r?e:r})}},Cp=e=>{if(!(q.location.hash.length>0)){var{lat:t,lng:n,zoom:i}=e,r=!1;return q.APP_DB.cities&&!q.APP_DB.city?r="about":q.innerWidth>800&&(r="list"),hp({lat:t,lng:n,zoom:i,screen:r}),q.STATE={lat:t,lng:n,zoom:i},q.OLD_STATE=q.STATE,{lat:t,lng:n,zoom:i}}return cp()},Pp=e=>{var t,{popup:n,screen:r,zoom:s,detail:a}=cp();dp({map:e,zoom:s}),n&&gp({map:e,popup:n}),pp(r),r&&(mp(r),q.B.classList.add("screen-visible")),fp(a),(t=ap(".screen.about",{single:!0}))&&(bp(!0),ap.on(t,"scroll",bp,{passive:!0})),ap.on(q,"popstate",(e=>i((function*(){if(yield yp())return!1;var t=e.getCenter(),n=e.getZoom(),{lat:i=t.lat,lng:r=t.lng,zoom:s=n,popup:a,screen:o,detail:l}=cp();mp(o),fp(l),pp(o),dp({map:e,zoom:s}),gp({map:e,popup:a}),(t.lat!==i||t.lng!==r||s!==n)&&e.setView({lat:i,lng:r},s)})))(e)),ap.on(e,"popupopen",Tp),ap.on(e,"popupclose",wp),ap.on(e,"zoomend",Ap),ap.on(e,"dragend",Ep),ap.on(".nav","click",(e=>t=>{var n,i,r=t.currentTarget,{dataset:s,classList:a,parentNode:o}=r,{to:l}=s,{z:c,lat:h,lng:u,detail:d,popup:p}=s,{slug:m}=o.dataset;l?a.contains("active")?a.contains("no-toggle")||(n=!1):n=l:(a.contains("exit")||a.contains("close")&&q.B.clientWidth<800)&&(n=!1),m&&[e.locationLayer,e.artifactLayer].forEach((e=>{e.eachLayer((e=>{e.slug===m&&(i=m)}))})),"show"===d?d=!o.classList.contains("visible")&&m:"hide"===d&&(d=!1),p&&(i=p),hp({detail:d,lat:h,lng:u,zoom:c,popup:i,screen:n}),a.contains("scroll")&&setTimeout((()=>{var e=o.parentNode.parentNode,t=o.offsetTop;e.scrollTop=t}),50)})(e)),ap.on(".backToTop","click",vp)},Lp=()=>{if((J||ie||Q)&&(!q.noWarn&&"true"!==q.store.getItem("warningSeen"))){var e=!1;J&&(re||(e=!0,ap("#warning").classList.add("ios","full"),ap.show("#warning .no-webxr"),ap.on("#copy-link","click",(e=>{var{target:t}=e;t.innerText="copied...",q.NAV.clipboard.writeText(q.LOC.href)})),ap("#open-webxr-link").href="xrviewer://".concat(q.LOC.href)),e&&(ap.show("#warning .ios"),ap.show("#warning .ios .all"))),ie&&(ne?te<86&&(e=!0,ap.show("#warning .chrome.old")):(e=!0,ap.show("#warning .chrome.no")),e&&(ap.show("#warning .android"),ap.show("#warning .android .all"))),Q&&$&&(ap.show("#warning .safari"),ap.show("#warning .macos")),e&&(ap.show("#warning"),ap.on(".close-warning","click",(()=>{ap.hide("#warning")})),q.store.setItem("warningSeen",!0))}},Ip=e=>{var t=e.currentTarget.parentNode.parentNode,n=q.store.getItem("popups",[]),i=t.getAttribute("id"),r=t.classList.contains("once");!n.includes(i)&&r&&(n.push(i),q.store.setItem("popups",n)),ap.hide(t)},Dp=()=>{ap(".popup").forEach((e=>{e.getAttribute("id"),ap("button.close",{parent:e}).forEach((e=>{ap.on(e,"click",Ip)})),ap("button.action",{parent:e}).forEach((e=>{ap.on(e,"click",(e=>{if(e.currentTarget.classList.contains("teleport")){var t=q.store.getItem("nearestCity"),n=APP_DB.cities.find((e=>e.slug===t));q.location.href="/".concat(t,"/#z=").concat(n.zoom,"&lat=").concat(n.lat,"&lng=").concat(n.lng)}}))}))}))},Up=function(){var e=i((function*(e){if(!q.createImageBitmap)return!1;var t=yield q.fetch(e),n=yield t.blob();try{var i=yield q.createImageBitmap(n);return!(!i.height&&!i.width)}catch(e){return!1}}));return function(t){return e.apply(this,arguments)}}(),Np=function(){var e=i((function*(){var{xr:e}=q.NAV;if(!e)return!1;try{return yield e.isSessionSupported("immersive-ar")}catch(e){return!1}}));return function(){return e.apply(this,arguments)}}(),Op=()=>{try{var e=ap.create("canvas");return q.WebGLRenderingContext&&["webgl","experimental-webgl","moz-webgl","webkit-3d"].some((t=>e.getContext(t)))}catch(e){return!1}},Fp=()=>{try{var e=ap.create("canvas");return!(!q.WebGL2RenderingContext||!e.getContext("webgl2"))}catch(e){return!1}},zp=()=>{var e=ap.create("audio");return{A_MP3:e.canPlayType("audio/mpeg"),A_OGG:e.canPlayType("audio/ogg"),A_MP4:e.canPlayType("audio/mp4")}},Bp=function(){var e=i((function*(){var[e,n,i,r,s,a]=yield Promise.all([Np(),Up("data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoBAAEAAUAmJaQAA3AA/vzA8AA="),Up("data:image/avif;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAACXBIWXMAAC4jAAAuIwF4pT92AAAADElEQVQI12Pg4eEBAABMACV5R6hLAAAAAElFTkSuQmCC"),Op(),Fp(),zp()]);return t({XR:e,WEBP:n,AVIF:i,WEBGL:r,WEBGL2:s},a)}));return function(){return e.apply(this,arguments)}}(),kp=e=>(null==e?void 0:e.startsWith("/"))||(null==e?void 0:e.startsWith("http"));function Hp(e,t){if(0===t)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(2===t||1===t){let n=e.getIndex();if(null===n){const t=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e=2.0 are supported.")));const l=new Nm(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===a[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(s),l.setPlugins(a),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}}function Vp(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const Wp={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class jp{constructor(e){this.parser=e,this.name=Wp.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,s)}}class im{constructor(e){this.parser=e,this.name=Wp.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class rm{constructor(e){this.parser=e,this.name=Wp.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class sm{constructor(e){this.name=Wp.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then((function(t){const n=e.byteOffset||0,i=e.byteLength||0,s=e.count,a=e.byteStride,o=new Uint8Array(t,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,a,o,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){const t=new ArrayBuffer(s*a);return r.decodeGltfBuffer(new Uint8Array(t),s,a,o,e.mode,e.filter),t}))}))}return null}}class am{constructor(e){this.name=Wp.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const i=t.meshes[n.mesh];for(const e of i.primitives)if(e.mode!==vm.TRIANGLES&&e.mode!==vm.TRIANGLE_STRIP&&e.mode!==vm.TRIANGLE_FAN&&void 0!==e.mode)return null;const r=n.extensions[this.name].attributes,s=[],a={};for(const e in r)s.push(this.parser.getDependency("accessor",r[e]).then((t=>(a[e]=t,a[e]))));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then((e=>{const t=e.pop(),n=t.isGroup?t.children:[t],i=e[0].count,r=[];for(const e of n){const t=new _i,n=new Gn,s=new Hn,o=new Gn(1,1,1),l=new jl(e.geometry,e.material,i);for(let e=0;e-1,r=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||i&&r<98?this.textureLoader=new Mu(this.options.manager):this.textureLoader=new Yu(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new xu(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const s={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};Rm(r,s,i),Cm(s,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(s)}))).then((function(){e(s)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=t.length;n{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,i]of e.children.entries())r(i,t.children[n])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&p.setY(t,h[e*s+1]),s>=3&&p.setZ(t,h[e*s+2]),s>=4&&p.setW(t,h[e*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i];let s=this.textureLoader;if(r.uri){const e=n.manager.getHandler(r.uri);null!==e&&(s=e)}return this.loadTextureImage(e,i,s)}loadTextureImage(e,t,n){const i=this,r=this.json,s=r.textures[e],a=r.images[t],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=s.name||a.name||"",""===t.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(t.name=a.uri);const n=(r.samplers||{})[s.sampler]||{};return t.magFilter=xm[n.magFilter]||Be,t.minFilter=xm[n.minFilter]||He,t.wrapS=ym[n.wrapS]||De,t.wrapT=ym[n.wrapT]||De,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const s=i.images[e],a=self.URL||self.webkitURL;let o=s.uri||"",l=!1;if(void 0!==s.bufferView)o=n.getDependency("bufferView",s.bufferView).then((function(e){l=!0;const t=new Blob([e],{type:s.mimeType});return o=a.createObjectURL(t),o}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(o).then((function(e){return new Promise((function(n,i){let s=n;!0===t.isImageBitmapLoader&&(s=function(e){const t=new On(e);t.needsUpdate=!0,n(t)}),t.load(Gu.resolveURL(e,r.path),s,void 0,i)}))})).then((function(e){var t;return!0===l&&a.revokeObjectURL(o),e.userData.mimeType=s.mimeType||((t=s.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e}));return this.sourceCache[e]=c,c}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then((function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),r.extensions[Wp.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[Wp.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(s);s=r.extensions[Wp.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),r.associations.set(s,t)}}return void 0!==i&&(s.colorSpace=i),e[t]=s,s}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,s=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new ic,ir.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new Xl,ir.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(i||r||s){let e="ClonedMaterial:"+n.uuid+":";i&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),r&&(t.vertexColors=!0),s&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return zh}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let s;const a={},o=[];if((r.extensions||{})[Wp.KHR_MATERIALS_UNLIT]){const e=i[Wp.KHR_MATERIALS_UNLIT];s=e.getMaterialType(),o.push(e.extendParams(a,r,t))}else{const n=r.pbrMetallicRoughness||{};if(a.color=new lr(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;a.color.fromArray(e),a.opacity=e[3]}void 0!==n.baseColorTexture&&o.push(t.assignTexture(a,"map",n.baseColorTexture,Vt)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(o.push(t.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),o.push(t.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),o.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)}))))}!0===r.doubleSided&&(a.side=me);const l=r.alphaMode||wm;if(l===Am?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===Em&&(a.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&s!==hr&&(o.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new mn(1,1),void 0!==r.normalTexture.scale)){const e=r.normalTexture.scale;a.normalScale.set(e,e)}return void 0!==r.occlusionTexture&&s!==hr&&(o.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(a.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&s!==hr&&(a.emissive=(new lr).fromArray(r.emissiveFactor)),void 0!==r.emissiveTexture&&s!==hr&&o.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,Vt)),Promise.all(o).then((function(){const n=new s(a);return r.name&&(n.name=r.name),Cm(n,r),t.associations.set(n,{materials:e}),r.extensions&&Rm(i,n,r),n}))}createUniqueName(e){const t=yd.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(e){return n[Wp.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return Om(n,e,t)}))}const s=[];for(let n=0,a=e.length;n0&&Pm(u,r),u.name=t.createUniqueName(r.name||"mesh_"+e),Cm(u,r),h.extensions&&Rm(i,u,h),t.assignFinalMaterial(u),l.push(u)}for(let n=0,i=l.length;n1?new Ho:1===t.length?t[0]:new Vi,a!==t[0])for(let e=0,n=t.length;e{const t=new Map;for(const[e,n]of i.associations)(e instanceof ir||e instanceof On)&&t.set(e,n);return e.traverse((e=>{const n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(r),r}))}_createAnimationTracks(e,t,n,i,r){const s=[],a=e.name?e.name:e.uuid,o=[];let l;switch(bm[r.path]===bm.weights?e.traverse((function(e){e.morphTargetInfluences&&o.push(e.name?e.name:e.uuid)})):o.push(a),bm[r.path]){case bm.weights:l=au;break;case bm.rotation:l=lu;break;default:switch(n.itemSize){case 1:l=au;break;case 2:case 3:l=hu}}const c=void 0!==i.interpolation?Tm[i.interpolation]:Dt,h=this._getArrayFromAccessor(n);for(let e=0,n=o.length;ee.name));function n(e){for(let n=0,i=e.length;n0&&t.setIndex(e.indices),t.setAttribute("position",new Mr(e.vertices,3)),e.normals.length>0&&t.setAttribute("normal",new Mr(e.normals,3)),e.uvs.length>0&&t.setAttribute("uv",new Mr(e.uvs,2)),e.colors.length>0&&t.setAttribute("color",new Mr(e.colors,3)),(e.faceVertexUvs.length>0||e.faceVertexColors.length>0)&&(t=t.toNonIndexed(),e.faceVertexUvs.length>0&&t.setAttribute("uv",new Mr(e.faceVertexUvs,2)),e.faceVertexColors.length>0&&t.setAttribute("color",new Mr(e.faceVertexColors,3)));for(const n of Object.keys(d.customPropertyMapping))e[n].length>0&&t.setAttribute(n,new Mr(e[n],d.customPropertyMapping[n].length));return t.computeBoundingSphere(),t}function l(e,t,n,i){if("vertex"===t){e.vertices.push(n[i.attrX],n[i.attrY],n[i.attrZ]),null!==i.attrNX&&null!==i.attrNY&&null!==i.attrNZ&&e.normals.push(n[i.attrNX],n[i.attrNY],n[i.attrNZ]),null!==i.attrS&&null!==i.attrT&&e.uvs.push(n[i.attrS],n[i.attrT]),null!==i.attrR&&null!==i.attrG&&null!==i.attrB&&(Fm.setRGB(n[i.attrR]/255,n[i.attrG]/255,n[i.attrB]/255).convertSRGBToLinear(),e.colors.push(Fm.r,Fm.g,Fm.b));for(const t of Object.keys(d.customPropertyMapping))for(const i of d.customPropertyMapping[t])e[t].push(n[i])}else if("face"===t){const t=n.vertex_indices||n.vertex_index,r=n.texcoord;3===t.length?(e.indices.push(t[0],t[1],t[2]),r&&6===r.length&&(e.faceVertexUvs.push(r[0],r[1]),e.faceVertexUvs.push(r[2],r[3]),e.faceVertexUvs.push(r[4],r[5]))):4===t.length&&(e.indices.push(t[0],t[1],t[3]),e.indices.push(t[1],t[2],t[3])),null!==i.attrR&&null!==i.attrG&&null!==i.attrB&&(Fm.setRGB(n[i.attrR]/255,n[i.attrG]/255,n[i.attrB]/255).convertSRGBToLinear(),e.faceVertexColors.push(Fm.r,Fm.g,Fm.b),e.faceVertexColors.push(Fm.r,Fm.g,Fm.b),e.faceVertexColors.push(Fm.r,Fm.g,Fm.b))}}function c(e,t){const n={};let i=0;for(let r=0;re.getInt8(t),size:1};case"uint8":case"uchar":return{read:t=>e.getUint8(t),size:1};case"int16":case"short":return{read:t=>e.getInt16(t,n),size:2};case"uint16":case"ushort":return{read:t=>e.getUint16(t,n),size:2};case"int32":case"int":return{read:t=>e.getInt32(t,n),size:4};case"uint32":case"uint":return{read:t=>e.getUint32(t,n),size:4};case"float32":case"float":return{read:t=>e.getFloat32(t,n),size:4};case"float64":case"double":return{read:t=>e.getFloat64(t,n),size:8}}}for(let r=0,s=e.length;r=this.arr.length}next(){return this.arr[this.i++]}}class km extends gu{constructor(e){super(e)}load(e,t,n,i){const r=this,s=new xu(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(e){const n=r.parse(JSON.parse(e));t&&t(n)}),n,i)}parse(e){return new Hm(e)}}class Hm{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){const n=[],i=function(e,t,n){const i=Array.from(e),r=t/n.resolution,s=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*r,a=[];let o=0,l=0;for(let e=0;e1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Infinity,r=(e.getIndex()||e.getAttribute("position")).count/3,s=[],a=n;ae.r!==t.r||e.g!==t.g||e.b!==t.b,jm={different:Wm,same:(e,t)=>!Wm(e,t)},Xm=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e&&e.dispose&&X.fn(e.dispose)&&e.dispose()},qm=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(X.arr(t)&&t.forEach((t=>e(t))),"Audio"===t.type&&t.isPlaying&&t.stop(),Xm(t.geometry),t.material)&&(X.arr(t.material)?t.material:[t.material]).forEach((e=>{Object.values(e).forEach(Xm),Xm(e)}));t.children.length&&t.children.forEach(e),!t.isScene&&t.dispose&&X.fn(t.dispose)&&t.dispose(),t.parent&&t.parent.remove(t)},Ym=(e,t)=>!e||e===t.Float||e===t.Hit,Zm=Math,Km=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{max:t=1,min:n=0}=e;if(n===t)return t;var i=t-n;return Zm.random()*i+n},Jm=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t?X.arr(t)&&X.arr(n)?t.length?t:n:Object.fromEntries(Object.entries(n).map((n=>{var[i,r]=n;return X.arr(r)?X.arr(t[i])?[i,t[i]]:[i,r]:X.obj(r)||X.obj(t[i])?[i,e(t[i],r)]:[i,t.hasOwnProperty(i)?t[i]:r]}))):n},Qm=function(){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"no";return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").toLowerCase().includes(e.toLowerCase())},$m=e=>{var{search:t,node:n}=e,i=!1,r=!1,s=!1;(t=t.toLowerCase()).startsWith("*")&&(t=t.slice(1),i=!0,r=!0),t.endsWith("*")&&(t=t.slice(0,-1),i=!0,s=!0);var a=n.name.toLowerCase();return i?r&&s?Qm(n.name,t):r?a.endsWith(t):s?a.startsWith(t):void 0:a===t},ef=e=>{var{node:t,search:n}=e;return!(!n||!n.length)&&(X.arr(n)?n.some((e=>$m({search:e,node:t}))):$m({search:n,node:t}))},tf=e=>(parseFloat(e).toFixed(2)/1).toFixed(1).toString(),nf=e=>X.num(e)?{max:e,min:0}:X.obj(e)?(e.hasOwnProperty("min")||(e.min=0),e.hasOwnProperty("max")||(e.max=e.min),e):{max:0,min:0};class rf{constructor(e){var{artifact:t,engine:n,preload:i,shaders:r,videoElement:s,texture:a}=e;if(this.engine=n,this.preload=i,this.tick=this.tick.bind(this),this.hideCharacter=this.hideCharacter.bind(this),a||s||!i.assets.videoElement||(s=i.assets.videoElement),s||a){this.videoElement=s,this.imageElement=a,this.name="Record3D";var{record3d:o={}}=t,l={x:0,y:0,z:0};this.config=Jm(o,{permanentSeconds:[],maximumPermanentSeconds:-1,useBone:!1,parentName:"parent",playbackRate:1,loopVideo:!0,useFog:!1,addFog:1e-4,fogColor:16448250,ptSize:"1.0",position:l,pos:l,rotation:l,rot:l,pointAlpha:1,permanentAlpha:1,hideModelsOnVideoEnded:[],images:[]});var{ptSize:c="1.0",sizeAttenuation:h="1.0"}=o;if(this.shaderConfig=Jm(o,{filterSize:"1",minDepth:"0.1",maxDepth:"5.0",depthThresholdFilter:"0.9",scale:"2.0",depthScale:"1.0",hueRedReducer:"0.0",pixelDepth:"1.0",ptSize:(parseFloat(c)*window.devicePixelRatio).toFixed(1).toString(),sizeAttenuation:(parseFloat(h)*window.devicePixelRatio).toFixed(2).toString()}),r&&(this.shaders=r),this.currentVideoSecondId=0,this.currentImageSecondId=0,this.imageElement){this.texture=(new Mu).load(this.imageElement.src);var u=this.createPoints(this.texture,this.config.permanentAlpha);u.position.set(5e3,5e3,5e3),this.child=u}else s&&this.addVideoElement(s);this.config.images.length&&(this.addTextureTimes=[],this.texturePointObjects=[],this.currentTexturePointObjectId=0,this.config.images.forEach(((e,t)=>{var i,{textures:r}=null===(i=this.preload)||void 0===i?void 0:i.assets,{file:s=e}=e,a=r[s],o=this.createPoints(a,this.config.permanentAlpha);o.position.set(5e3,5e3,5e3),n.scene.add(o);var{time:l=-1}=e;this.texturePointObjects.push({points:o,time:l})})));var d=this.createPoints(this.texture,this.config.pointAlpha);this.config.useBone?this.child=d:this.model=d,this.config.useFog&&(this.fog=new Jo(this.config.fogColor,.005),this.engine.scene.fog=this.fog)}else console.error("objects/Record3D.js: videoElement or texture has to be defined",{videoElement:s,texture:a})}addVideoElement(e){var{videoWidth:t,videoHeight:n}=e;e.playbackRate=this.config.playbackRate,this.modelsToHide=[],(this.config.hideModelsOnVideoEnded.length||!1===this.config.loopVideo)&&(ap.on(e,"seeked",this.hideCharacter),this.config.hideModelsOnVideoEnded.forEach((e=>{var t=this.preload.assets.gltf.scene.getObjectByName(e);t.material.transparent=!0,this.modelsToHide.push(t)})));var i=new hc(e,{minFilter:Be});this.texture=i,this.pointCopies=[],this.canvases=[],this.config.permanentSeconds.length&&(this.canvasParent=ap.create("div",{parent:q.B}),this.config.permanentSeconds.forEach(((e,i)=>{var r=ap.create("canvas",{height:n,width:t,style:{position:"fixed",left:"100vw"},parent:this.canvasParent});this.canvases.push(r);var s=new dc(r,{minFilter:Be}),a=this.createPoints(s,this.config.permanentAlpha);a.visible=!1,this.pointCopies.push(a),this.engine.scene.add(a)})))}hideCharacter(){this.hasTriggeredOnce?this.fadeOutModel=!0:this.hasTriggeredOnce=!0}createPoints(e){var t,n,i,r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"1.0",{artifact:a={}}=this.engine,{videoElement:o,texture:l={}}=this;if(o){var{videoWidth:c,videoHeight:h}=o;r=h,i=c}else l&&(r=l.height,i=l.width);for(var u=new Ho,{ifx:d=.00125,ify:p=.00125,itx:m=-.4,ity:f=-.6}=a,{filterSize:g,minDepth:v,maxDepth:_,depthScale:x,depthThresholdFilter:y,scale:M,ptSize:S,pixelDepth:b,hueRedReducer:T,sizeAttenuation:w}=this.shaderConfig,E=new es({uniforms:{texImg:{type:"t",value:e},texSize:{type:"i2",value:[i,r]},iK:{type:"f4",value:[d,p,m,f]},alpha:{type:"f",value:s},filterSize:{type:"f",value:g},minDepth:{type:"f",value:v},maxDepth:{type:"f",value:_},depthThresholdFilter:{type:"f",value:y},scale:{type:"f",value:M},ptSize:{type:"f",value:S},hueRedReducer:{type:"f",value:T},pixelDepth:{type:"f",value:b},depthScale:{type:"f",value:x},sizeAttenuation:{type:"f",value:w}},side:me,transparent:!0,vertexShader:null!==(t=this.shaders)&&void 0!==t&&t.vertexShader?this.shaders.vertexShader:"#define GLSLIFY 1\nattribute float vertexIdx;varying float vVertexIdx;varying vec2 vPtPos;uniform ivec2 texSize;uniform sampler2D texImg;uniform vec4 iK;uniform float scale;uniform float minDepth;uniform float maxDepth;uniform float pixelDepth;uniform int filterSize;uniform float ptSize;uniform float depthThresholdFilter;uniform float depthScale;uniform float hueRedReducer;uniform float sizeAttenuation;\n#include \nfloat rgb2hue(vec3 c){float r=c.r-hueRedReducer;vec4 K=vec4(0.0,-1.0/3.0,2.0/3.0,-1.0);vec4 p=mix(vec4(c.bg,K.wz),vec4(c.gb,K.xy),step(c.b,c.g));vec4 q=mix(vec4(p.xyw,r),vec4(r,p.yzx),step(p.x,r));float d=q.x-min(q.w,q.y);float e=1.0e-10;return abs(q.z+(q.w-q.y)/(6.0*d+e));}float getPixelDepth(ivec2 pixel){vec2 lookupPt=(vec2(pixel)+vec2(0.5))/vec2(texSize);float hue=rgb2hue(texture2D(texImg,lookupPt).rgb);float pxDepth=pixelDepth*hue;return pxDepth;}bool shouldDiscard(ivec2 currPixel){float centerPixelDepth=getPixelDepth(currPixel);for(int i=-filterSize;i<=filterSize;i++){for(int j=-filterSize;j<=filterSize;j++){if(i==0&&j==0){continue;}float currDepth=getPixelDepth(currPixel+ivec2(j,i));if(currDepthmaxDepth||abs(centerPixelDepth-currDepth)>depthThresholdFilter){return true;}}}return false;}void main(){ivec2 frameSize=ivec2(texSize.x/2,texSize.y);int vertIdx=int(vertexIdx);int actualNumPts=frameSize.x*frameSize.y;if(vertIdx>=actualNumPts){gl_Position=vec4(0.0);return;}int ptY=vertIdx/int(frameSize.x);int ptX=vertIdx-ptY*int(frameSize.x);ivec2 pt=ivec2(ptX,ptY);if(shouldDiscard(pt)){gl_Position=vec4(0.0);return;}float currDepth=getPixelDepth(pt);vec3 ptPos=scale*vec3((iK.x*float(ptX)+iK.z)*currDepth,(iK.y*float(ptY)+iK.w)*currDepth,-currDepth*depthScale);vec4 mvPos=modelViewMatrix*vec4(ptPos,1.0);gl_Position=projectionMatrix*mvPos;vPtPos=vec2(float(ptX),float(ptY));vVertexIdx=vertexIdx;gl_PointSize=ptSize;bool isPerspective=isPerspectiveMatrix(projectionMatrix);if(isPerspective){gl_PointSize=max(ptSize,sizeAttenuation/-mvPos.z);}}",fragmentShader:null!==(n=this.shaders)&&void 0!==n&&n.fragmentShader?this.shaders.fragmentShader:"#define GLSLIFY 1\nvarying float vVertexIdx;varying vec2 vPtPos;uniform ivec2 texSize;uniform sampler2D texImg;uniform float alpha;void main(){vec2 frameSizeF=vec2(texSize.x/2,texSize.y);ivec2 frameSize=ivec2(frameSizeF);int vertIdx=int(vVertexIdx);int actualNumPts=frameSize.x*frameSize.y;if(vertIdx>=actualNumPts){discard;}vec2 lookupPt=(vec2(vPtPos.x+frameSizeF.x,vPtPos.y)+vec2(0.5))/vec2(texSize);vec3 currColor=texture2D(texImg,lookupPt).rgb;gl_FragColor=vec4(currColor,alpha);}"}),A=i/2*r,R=new Uint32Array(A),C=new Float32Array(A),P=0;Pthis.waitForVideoSecond){this.canvases[this.currentVideoSecondId].getContext("2d").drawImage(e,0,0,n,t);var i=this.pointCopies[this.currentVideoSecondId];i.visible=!0,this.child.matrixWorld.decompose(i.position,i.rotation,i.scale),this.currentVideoSecondId++,this.waitForVideoSecond=this.config.permanentSeconds[this.currentVideoSecondId]}}else this.waitForVideoSecond=this.config.permanentSeconds[this.currentVideoSecondId]}renderPermanentImage(e){var t=this.texturePointObjects[this.currentImageSecondId];if(this.waitForImageSecond){if(e.videoElement.currentTime>=this.waitForImageSecond){this.child.matrixWorld.decompose(t.points.position,t.points.rotation,t.points.scale),this.currentImageSecondId++;var n=this.texturePointObjects[this.currentImageSecondId];this.waitForImageSecond=n?n.time:Infinity}}else this.waitForImageSecond=t.time}tick(e){var{engine:t}=e;if(this.videoElement&&(this.currentVideoSecondId{e.material.opacity>0?e.material.opacity-=.05:e.visible&&(e.visible=!1)}));var n=this.model||this.child;if(n&&n.visible){var i,r=null==n?void 0:n.children[0];(null==r||null===(i=r.material)||void 0===i||null===(i=i.uniforms)||void 0===i||null===(i=i.alpha)||void 0===i?void 0:i.value)>0?r.material.uniforms.alpha.value-=.05:n.visible&&(n.visible=!1,this.continuePlayingNonLoopedVideo&&this.videoElement.pause())}}}}var sf=Object.freeze({__proto__:null,Record3D:rf}),af=(e,t,n)=>{var i=t.clone().sub(e).normalize().multiplyScalar(n);return e.clone().add(i)};af.percent=(e,t,n)=>{var i=t.clone().sub(e),r=i.length(),s=i.normalize().multiplyScalar(r*n/100);return e.clone().add(s)};class of extends es{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t({uBaseTexture:{type:"t",value:null},uBaseSpeed:{type:"f",value:.5},uNoiseTexture:{type:"t",value:null},uNoiseScale:{type:"f",value:.2},uAlpha:{type:"f",value:.5},uTime:{type:"f",value:1},uRepeat:{type:"f",value:10}},e.uniforms),{side:i=me,transparent:r=!0,textureId:s=1}=e;super(t({uniforms:n,side:i,transparent:r,vertexShader:"\nvarying vec2 vUv;\n\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}\n",fragmentShader:"\nuniform sampler2D uBaseTexture;\nuniform float uBaseSpeed;\nuniform sampler2D uNoiseTexture;\nuniform float uNoiseScale;\nuniform float uAlpha;\nuniform float uTime;\nuniform float uRepeat;\n\nvarying vec2 vUv;\n\nvoid main() {\n vec2 newUv = vUv * uRepeat;\n\tvec2 uvTimeShift = newUv + vec2(-0.7, 1.5) * uTime * uBaseSpeed;\n\tvec4 noiseGeneratorTimeShift = texture2D(uNoiseTexture, uvTimeShift);\n\tvec2 uvNoiseTimeShift = newUv + uNoiseScale * vec2(noiseGeneratorTimeShift.r, noiseGeneratorTimeShift.b);\n\tvec4 baseColor = texture2D(uBaseTexture, uvNoiseTimeShift);\n\n\tbaseColor.a = uAlpha;\n\tgl_FragColor = baseColor;\n}\n"},e)),this.textureId=s}preload(e){var t=this;return i((function*(){var{textureId:n}=t,[i,r]=yield Promise.all([e.promisifiedLoad({loader:e.textureLoader,file:"https://static.artificialmuseum.com/textures/waterplane/water_".concat(n,".jpg")}),e.promisifiedLoad({loader:e.textureLoader,file:"https://static.artificialmuseum.com/textures/waterplane/cloud_".concat(n,".png")})]);i.wrapT=i.wrapS=De,r.wrapT=r.wrapS=De,t.uniforms.uBaseTexture.value=i,t.uniforms.uNoiseTexture.value=r}))()}tick(e){this.uniforms.uTime.value+=e}}var lf=Object.freeze({__proto__:null,CirclingLights:class{constructor(e){e.artifact.circlingLights.forEach((t=>{var{color:n=16711680,intensity:i=1,dim:r=0,decay:s=2,shadows:a=!1,show:o=!1}=t,l=new Uu(n,i,r,s);if(a&&(l.castShadow=!0,l.shadow.camera.near=.1,l.shadow.camera.far=5),o){var c=new Rh(.05,6,6),h=new hr({color:n}),u=new qr(c,h);l.add(u)}if(e.circlingLights.push({light:l,config:t}),e.model.add(l),o){var d=new zd(l,.1,n);e.model.add(d)}})),e.addRenderStep(this.render.bind(this))}render(e){var{engine:t,timestamp:n}=e,i=5e-4*n;t.circlingLights.forEach((e=>{var{light:t,config:n}=e,{lightDistance:r=1,timeOffset:s=20,offset:{x:a=0,y:o=0,z:l=0}={}}=n;i+=1e3*s;var c=Math.sin(i)*r+a,h=Math.sin(1.1*i)*r+o,u=Math.sin(1.2*i)*r+l;t.position.set(c,h,u)}))}}}),cf=["audio","action","actions","animationSoundFrames","idleActions","enterActions","exitActions","loopActions","buffer","target","distanceTarget"];var hf=Object.freeze({__proto__:null,SpatialObjects:class{constructor(e){this.finished=!1,this.opening=!1,this.looping=!1,this.closing=!0,this.animationSoundActions=[],this.animationLoopSoundActions=[];var n=!1;e.spatials.forEach((i=>{var{audio:r,action:a,actions:o,animationSoundFrames:l=[],idleActions:c=[],enterActions:h=[],exitActions:u=[],loopActions:d=[],buffer:p,target:m,distanceTarget:f}=i,g=s(i,cf),v=X.str(r)?r:e.artifact.slug;e.model.traverse((i=>{if(ef({node:i,search:m})){var s=t(t({},g),{},{node:i});if(f&&(s.distanceTarget=e.model.getObjectByName(f)),p)s.audio=p;else if(r){var l;if(null!==(l=e.preload.assets.audioElements)&&void 0!==l&&l.length){var _=e.preload.assets.audioElements.find((e=>{var{ele:t}=e;return t.dataset.name===v}));s.audio=_;var{AudioContext:x=q.webkitAudioContext}=q,y=new x,M=y.createMediaElementSource(_.ele),S=y.createGain();M.connect(S),S.connect(y.destination),S.gain.value=0,s.context=y,s.gainNode=S,s.source=M}}var b=[];if(X.arr(o)&&o.length&&(e.actions.filter((e=>o.includes(e._clip.name))),function(e){throw new TypeError('"'+e+'" is read-only')}("finalActions"),s.off||b.forEach((e=>e.paused=!0))),a){var T=uu.findByName(e.animations,a);T&&b.push(T),s.off||(T.paused=!0)}b.length&&(s.actions=b,n=!0);var w=e.actions.filter((e=>c.includes(e._clip.name))),E=e.actions.filter((e=>h.includes(e._clip.name))),A=e.actions.filter((e=>d.includes(e._clip.name))),R=e.actions.filter((e=>u.includes(e._clip.name)));s.off||(E.forEach((e=>{e.loop=Lt,e.paused=!0,e.weight=0,e.time=0})),R.forEach((e=>{e.loop=Lt,e.paused=!0,e.weight=0,e.time=0})),A.forEach((e=>{e.paused=!0,e.weight=0,e.time=0}))),s.enter=E,s.loop=A,s.exit=R,s.idle=w,n=!0,e.spatialObjects.push(s)}}))}));var{animationSoundFrames:i=[]}=e.artifact;if(i.length&&i.forEach((t=>{var{time:n,audio:i,onLoop:r=!1}=t,s=X.arr(i)?i:[i],a=e.actions.find((e=>e._clip.name===t.action)),o=[];s.forEach((n=>{var i=e.preload.audioElements.find((e=>{var t,{ele:i}=e;return(null==i||null===(t=i.dataset)||void 0===t?void 0:t.name)===n}));a&&i.ele&&(i.ele.loop=!1,o.push(i.ele)),a||console.warn("W_ANIMATIONSOUNDFRAMES","could not find action",t.action,e.animations),i.ele||console.warn("W_ANIMATIONSOUNDFRAMES","could not find audioelement",t.audio,e.preload.audioElements)}));var l=1===o.length?o[0]:o,c={action:a,audio:l,playing:!1,time:n};r?this.animationLoopSoundActions.push(c):this.animationSoundActions.push(c)})),n&&e.mixer){var r=[e.mixer,"finished",e=>{var{name:t}=e.action._clip;t.includes("enter")&&!this.looping?this.looping=!0:t.includes("exit")&&!this.finished&&(this.finished=!0,this.closing=!1)}];ap.on(...r),e.eventsToRemove.push(r)}if(e.mixer&&this.animationLoopSoundActions.length){var a=[e.mixer,"loop",e=>{var{name:t}=e.action._clip,n=this.animationLoopSoundActions.find((e=>e.action._clip.name===t));if(n){var{currentAudioId:i=0}=n,r=n.audio[i];r.time=0,r.play(),++i>=n.audio.length&&(i=0),n.currentAudioId=i}}];ap.on(...a),e.eventsToRemove.push(a)}e.addRenderStep(this.render.bind(this))}render(e){var t,{engine:n}=e;n.modelSpawned&&(null!==(t=this.animationSoundActions)&&void 0!==t&&t.length&&this.animationSoundActions.forEach((e=>{var{action:t,time:n=0,audio:i}=e,{currentAudioId:r=0}=e,s=i;if(t.time>=n){if(X.arr(i))return;s.paused&&(t.time>1e3?s.time=t.time:s.time=0,s.play(),++r>=i.length&&(r=0),e.currentAudioId=r)}})),n.spatialObjects.forEach((e=>{var{node:t,distanceTarget:i,exclusive:r=!1,restart:s,actions:a,idle:o=[],enter:l=[],loop:c=[],exit:h=[],audio:u,gainNode:d,off:p,fn:m,yDistanceTest:f=!0}=e,{distance:g={max:2,min:0},scale:v}=e,_=i||t,x=new Gn;_.getWorldPosition(x);var y=f?x.y:n.camera.position.y,M=new Gn(x.x,y,x.z),S=_.visible?n.camera.position.distanceTo(M):1e4;if(g=nf(g),v){v=nf(v);var b=g.min/g.max,T=1-S/g.max+b,w=Math.max(v.min,Math.min(v.max,T));t.scale.set(w,w,w)}if(u&&u.ele&&d){var{ele:E}=u,A=d.gain.value,R=Math.max(0,Math.min(1,1-S/g.max+g.min/g.max)),C=Math.abs(A-R);R<=.02?d.gain.value=0:C>.02&&(R>0&&E.paused&&(E.time=0,E.play()),d.gain.value=R),s&&(S>g.max||S=g.min?this.opening?this.looping&&(this.looping=!1,h.forEach((e=>{e.weight=0,e.paused=!0})),o.forEach((e=>{e.weight=0,e.paused=!0})),l.forEach((e=>{e.weight=0,e.paused=!0})),c.forEach((e=>{e.time=0,e.weight=1,e.paused=!1})),this.closing=!1):(h.forEach((e=>{e.weight=0,e.paused=!0})),o.forEach((e=>{e.weight=0,e.paused=!0})),c.forEach((e=>{e.weight=0,e.paused=!0})),l.forEach((e=>{e.time=0,e.weight=1,e.paused=!1})),this.opening=!0,this.closing=!1):this.closing?this.finished&&(h.forEach((e=>{e.weight=0,e.paused=!0})),c.forEach((e=>{e.weight=0,e.paused=!0})),l.forEach((e=>{e.weight=0,e.paused=!0})),o.forEach((e=>{e.time=0,e.weight=1,e.paused=!1})),this.looping=!1,this.finished=!1):(c.forEach((e=>{e.weight=0,e.paused=!0})),o.forEach((e=>{e.weight=0,e.paused=!0})),l.forEach((e=>{e.weight=0,e.paused=!0})),h.forEach((e=>{e.time=0,e.weight=1,e.paused=!1})),this.opening=!1,this.looping=!1,this.closing=!0),a&&a.length&&a.forEach((e=>{S<=g.max&&S>=g.min?p?e.paused||(e.paused=!0):e.paused&&(r?n.actions.forEach((t=>{t!==e?t.paused||(t.paused=!0):t.paused&&(t.paused=!1)})):e.paused=!1):p?e.paused&&(e.paused=!1):e.paused||(e.paused=!0)})),m&&X.fn(n.sceneInstance[m])&&n.sceneInstance[m]({node:t,config:{distance:g},distance:S})})))}}});var uf=Object.freeze({__proto__:null,AnalyseAudio:class{constructor(e){var t,{audioElement:n,audioElements:i=[]}=e.preload.assets;n||null!=i&&i.length?([n,...i].filter((e=>e)).forEach((t=>{var n=new AudioContext,i=n.createMediaElementSource(t.ele),r=n.createAnalyser();r.fftSize=e.artifact.fftSize||32,i.connect(r),i.connect(n.destination);var s=new Uint8Array(r.frequencyBinCount);r.getByteFrequencyData(s),e.audioAnalysers.push({name:t.ele.id,analyser:r,array:s})})),null===(t=e.artifact.audioAnalyserEmission)||void 0===t||t.forEach((t=>{var n=Jm(t,{intensity:.004,minIntensity:0,color:[],target:""}),i=[];e.model.traverse((e=>{var t;ef({node:e,search:n.target})&&(e.material?i.includes(e.material)||i.push(e.material):null!==(t=e.children)&&void 0!==t&&t.length&&e.children.forEach((e=>{e.material&&i.push(e.material)})))})),n.targets=i,n.targets.length||console.warn("W_AUDIO_ANALYSER_EMISSION_CONFIGS","Audio analyser emission config does not find a target",n,e.model),e.audioAnalyserEmissionConfigs.push(n)}))):console.warn("W_AUDIO_ANALYSER","artifact.audioAnalyser was set but no audioElements have been registered.")}render(e){var{delta:t,engine:n,frame:i,timestamp:r}=e,{actions:s,ambientLight:a,artifact:o,audioAnalysers:l,audioAnalyserEmissionConfigs:c,sceneInstance:h}=n,{audioAnalyserAnimation:u,audioAnalyserAnimations:d=[],audioAnalyserLights:p}=o,m=0,f=l.map((e=>{var{name:t,analyser:n,array:i}=e;n.getByteFrequencyData(i);var r=i.reduce(((e,t)=>e+t))/i.length;return m+=r,i})),g=m/255;if(X.fn(null==h?void 0:h.renderAudioAnalyser)&&h.renderAudioAnalyser({average:m,values:f,delta:t,timestamp:r,frame:i,engine:n}),u||d.length){var v=Jm(o,{audioAnalyserIntensity:1}),_=Math.min(1,m*v.audioAnalyserIntensity/220);if(u){var x=s.find((e=>e._clip.name===u));x.weight=_,x.time=null==x?void 0:x._clip.duration}d.length&&s.forEach((e=>{var t=e._clip.name,n=d.find((e=>e===t||e.action===t));if(n){if(X.obj(n)){var{useAverage:i=!0}=n;if(i)e.weight=_;else{var{index:r=6,divisor:s=220}=n,a=f.map((e=>e[r])).reduce(((e,t)=>e+t)),o=Math.min(1,a/s);e.weight=o}}else e.weight=_;e.time=e._clip.duration}}))}if(p){var y=Jm(o,{lightIntensity:1,levelMultiplier:2}),M=y.lightIntensity*(g*y.levelMultiplier);a.intensity=M}null!=c&&c.length&&c.forEach((e=>{var t=e.intensity*g;e.targets.forEach((n=>{var i;t>e.minIntensity?n.emissiveIntensity=t:n.emissiveIntensity=0,null!==(i=e.color)&&void 0!==i&&i.length&&(n.emissive=new lr(...e.color))}))}))}}});function df(e){const t=new Map,n=new Map,i=e.clone();return pf(e,i,(function(e,i){t.set(i,e),n.set(e,i)})),i.traverse((function(e){if(!e.isSkinnedMesh)return;const i=e,r=t.get(e),s=r.skeleton.bones;i.skeleton=r.skeleton.clone(),i.bindMatrix.copy(r.bindMatrix),i.skeleton.bones=s.map((function(e){return n.get(e)})),i.bind(i.skeleton,i.bindMatrix)})),i}function pf(e,t,n){n(e,t);for(let i=0;iX.arr(n.action)?n.action.includes(e._clip.name):e._clip.name===n.action)),p=function(){var n=df(h);if(t.spawnableClones.push(n),n.position.set(2e3,2e3,2e3),e.model.add(n),n.userData.actions=[],d.length){var i=new bd(n);d.forEach((e=>{var t=i.clipAction(e._clip);n.userData.actions.push(t)})),n.userData.mixer=i,t.cloneMixers.push(i);var r=[i,"loop",()=>{n.userData.waiting=!1}];ap.on(...r),e.eventsToRemove.push(r)}},m=0;m{e.update(n)})),this.spawnableClones.forEach(((e,t)=>{this.waitingForSpawn.includes(e)||e.userData.waiting||(this.waitingForSpawn.push(e),e.userData.waiting=!0,e.userData.wait||(e.userData.wait=r+Km(s)),e.userData.actions.length&&e.userData.actions.forEach(((e,t)=>{e.paused=!0,e.time=0})),e.userData.mixer&&l&&(e.userData.mixer.timeScale=Km(l)),a&&e.rotation.set(0,359.9*Math.random(),0),e.position.set(2e3,2e3,2e3))})),null!==(t=this.freePositions)&&void 0!==t&&t.length&&(e=>{for(var t=e.length-1;t>0;t--)var n=Math.floor(Math.random()*(t+1))[(e[t],e[n])]=[e[n],e[t]]})(this.freePositions),this.waitingForSpawn.forEach((e=>{if(e.userData.wait<=r){var t;if(e.userData.wait=r+Km(s),o){var n=Km(o);e.scale.set(n,n,n)}var a,l,d=i.camera.position,p=359.999*Math.random(),m=Km(h),f=i.scene.position.y;if(null!==(t=this.freePositions)&&void 0!==t&&t.length){var[g,v,_]=this.freePositions.pop();a=g,f=v,l=_,this.freePositions.length{e.paused=!1,e.play()}));var x=this.waitingForSpawn.indexOf(e);this.waitingForSpawn.splice(x,1)}}))}}});const ff=new tr,gf=new Gn,vf=new mn,_f=new mn,xf=new mn;class yf{constructor(e){this.geometry=e.geometry,this.randomFunction=Math.random,this.indexAttribute=this.geometry.index,this.positionAttribute=this.geometry.getAttribute("position"),this.normalAttribute=this.geometry.getAttribute("normal"),this.colorAttribute=this.geometry.getAttribute("color"),this.uvAttribute=this.geometry.getAttribute("uv"),this.weightAttribute=null,this.distribution=null}setWeightAttribute(e){return this.weightAttribute=e?this.geometry.getAttribute(e):null,this}build(){const e=this.indexAttribute,t=this.positionAttribute,n=this.weightAttribute,i=e?e.count/3:t.count/3,r=new Float32Array(i);for(let s=0;se){r=s;break}e1&&(s=1-s,a=1-a);const o=this.indexAttribute;let l=3*e,c=3*e+1,h=3*e+2;return o&&(l=o.getX(l),c=o.getX(c),h=o.getX(h)),ff.a.fromBufferAttribute(this.positionAttribute,l),ff.b.fromBufferAttribute(this.positionAttribute,c),ff.c.fromBufferAttribute(this.positionAttribute,h),t.set(0,0,0).addScaledVector(ff.a,s).addScaledVector(ff.b,a).addScaledVector(ff.c,1-(s+a)),void 0!==n&&(void 0!==this.normalAttribute?(ff.a.fromBufferAttribute(this.normalAttribute,l),ff.b.fromBufferAttribute(this.normalAttribute,c),ff.c.fromBufferAttribute(this.normalAttribute,h),n.set(0,0,0).addScaledVector(ff.a,s).addScaledVector(ff.b,a).addScaledVector(ff.c,1-(s+a)).normalize()):ff.getNormal(n)),void 0!==i&&void 0!==this.colorAttribute&&(ff.a.fromBufferAttribute(this.colorAttribute,l),ff.b.fromBufferAttribute(this.colorAttribute,c),ff.c.fromBufferAttribute(this.colorAttribute,h),gf.set(0,0,0).addScaledVector(ff.a,s).addScaledVector(ff.b,a).addScaledVector(ff.c,1-(s+a)),i.r=gf.x,i.g=gf.y,i.b=gf.z),void 0!==r&&void 0!==this.uvAttribute&&(vf.fromBufferAttribute(this.uvAttribute,l),_f.fromBufferAttribute(this.uvAttribute,c),xf.fromBufferAttribute(this.uvAttribute,h),r.set(0,0).addScaledVector(vf,s).addScaledVector(_f,a).addScaledVector(xf,1-(s+a))),this}}var Mf=Object.freeze({__proto__:null,ClonesOnMeshes:class{constructor(e){var t=this;this.spawnableClones=[],this.waitingForSpawn=[],this.camPos=new Gn,this.render=this.render.bind(this),this.respawnNode=this.respawnNode.bind(this),e.addRenderStep(this.render);var{clonesOnMeshes:n}=e.artifact;this.sampleTargetPosition=new Gn,this.sampleTargetNormal=new Gn,this.sampleTargetColor=new lr;var i=[];this.meshes=n.map((n=>{var{action:r,delay:s=1e3,number:a=10,mesh:o,normals:l=!1,parent:c=!1,scale:h=!1,rotate:u=!1,respawnDelay:d,target:p="clone"}=n;h&&(h=h&&nf(h)),s&&(s=nf(s)),d&&(d=nf(d));var m=e.model.getObjectByName(o),f=m.geometry.toNonIndexed(),g=new yf({geometry:f}).build();if(c){var v=e.model.getObjectByName(c);c=v}else c=m;var _=e.model.getObjectByName(p);i.push(_);for(var x=e.actions.filter((e=>X.arr(r)?cloneConfig.action.includes(e._clip.name):e._clip.name===r)),y=function(){var n=df(_);if(n.visible=c.visible,n.userData.actions=[],n.userData.delay=s,x.length){var i=new bd(n);x.forEach((e=>{var t=i.clipAction(e._clip);n.userData.actions.push(t)})),n.userData.mixer=i;var r=[i,"loop",()=>t.respawnNode(n)];ap.on(...r),e.eventsToRemove.push(r)}n.position.set(2e3,2e3,2e3),c.add(n)},M=0;M{e.parent&&e.removeFromParent()}))}respawnNode(e){e.userData.playing=!1,e.userData.actions.forEach((e=>{e.paused=!0,e.time=0}));var t=Km(e.userData.delay);e.userData.nextSpawn+=t}spawnNode(e,t){if(e.parent.visible){var{normals:n,respawnDelay:i,rotate:r,scale:s,sampler:a}=t;if(e.userData.playing=!0,e.visible=!0,s){var o=Km(s);e.scale.set(o,o,o)}a.sample(this.sampleTargetPosition,this.sampleTargetNormal);var{x:l,y:c,z:h}=this.sampleTargetPosition;if(e.position.set(l,c,h),n){var{x:u,y:d,z:p}=this.sampleTargetNormal;r&&(d=359.9*Math.random()),e.rotation.set(u,d,p)}else if(r){var{x:m,z:f}=e.rotation,g=359.9*Math.random();e.rotation.set(m,g,f)}e.userData.actions.forEach((e=>{e.time=0,e.paused=!1})),e.userData.mixer}}render(e){var{delta:t,engine:n,timestamp:i}=e;n.modelSpawned&&this.meshes.forEach(((e,n)=>{var{parent:r,delay:s}=e;r.children.forEach((n=>{n.userData.mixer&&n.userData.mixer.update(t),n.userData.nextSpawn||(n.userData.nextSpawn=i+Km(s)),n.userData.nextSpawn<=i&&!n.userData.playing&&this.spawnNode(n,e)}))}))}}}),Sf={uniforms:{color:{value:null},tDiffuse:{value:null},textureMatrix:{value:null}},vertexShader:"#define GLSLIFY 1\nuniform mat4 textureMatrix;varying vec4 vUv;\n#include \n#include \nvoid main(){vUv=textureMatrix*vec4(position,1.0);gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);\n#include \n}",fragmentShader:"#define GLSLIFY 1\nuniform vec3 color;uniform sampler2D tDiffuse;varying vec4 vUv;\n#include \nfloat blendOverlay(float base,float blend){return(base<0.5 ?(2.0*base*blend):(1.0-2.0*(1.0-base)*(1.0-blend)));}vec3 blendOverlay(vec3 base,vec3 blend){return vec3(blendOverlay(base.r,blend.r),blendOverlay(base.g,blend.g),blendOverlay(base.b,blend.b));}void main(){\n#include \nvec4 base=texture2DProj(tDiffuse,vUv);gl_FragColor=vec4(blendOverlay(base.rgb,color),1.0);\n#include \n#include \n}"};class bf extends qr{constructor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;super(e),this.isReflector=!0,this.type="Reflector",this.camera=new ns,this.XR=n.XR,this.skybox=n.skybox,this.shadowPlane=n.shadowPlane,this.color=void 0!==t.color?new lr(t.color):new lr(8355711),this.textureMatrix=new _i,this.clipBias=t.clipBias||0,this.reflectorPlane=new hs,this.normal=new Gn,this.reflectorWorldPosition=new Gn,this.cameraWorldPosition=new Gn,this.rotationMatrix=new _i,this.lookAtPosition=new Gn(0,0,-1),this.clipPlane=new Fn,this.view=new Gn,this.target=new Gn,this.q=new Fn;var i=t.shader||Sf,r=void 0!==t.multisample?t.multisample:4;this.virtualCamera=this.camera;var s=t.textureWidth||512,a=t.textureHeight||512;this.renderTarget=new zn(s,a,{samples:r,type:qe});var o=new es({uniforms:$r.clone(i.uniforms),fragmentShader:i.fragmentShader,vertexShader:i.vertexShader});o.uniforms.tDiffuse.value=this.renderTarget.texture,o.uniforms.color.value=this.color,o.uniforms.textureMatrix.value=this.textureMatrix,this.material=o,this.onBeforeRender=this.onBeforeRender.bind(this)}onBeforeRender(e,t,n){var i,{clipBias:r,virtualCamera:s,reflectorPlane:a,normal:o,reflectorWorldPosition:l,cameraWorldPosition:c,rotationMatrix:h,lookAtPosition:u,clipPlane:d,renderTarget:p,textureMatrix:m,view:f,target:g,q:v}=this;if(l.setFromMatrixPosition(this.matrixWorld),c.setFromMatrixPosition(n.matrixWorld),h.extractRotation(this.matrixWorld),o.set(0,0,1),o.applyMatrix4(h),f.subVectors(l,c),!(f.dot(o)>0)){f.reflect(o).negate(),f.add(l),h.extractRotation(n.matrixWorld),u.set(0,0,-1),u.applyMatrix4(h),u.add(c),g.subVectors(l,u),g.reflect(o).negate(),g.add(l),s.position.copy(f),s.up.set(0,1,0),s.up.applyMatrix4(h),s.up.reflect(o),s.lookAt(g),s.far=n.far,s.updateMatrixWorld(),s.projectionMatrix.copy(n.projectionMatrix),m.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),m.multiply(s.projectionMatrix),m.multiply(s.matrixWorldInverse),m.multiply(this.matrixWorld),a.setFromNormalAndCoplanarPoint(o,l),a.applyMatrix4(s.matrixWorldInverse),d.set(a.normal.x,a.normal.y,a.normal.z,a.constant);var _=s.projectionMatrix;v.x=(Math.sign(d.x)+_.elements[8])/_.elements[0],v.y=(Math.sign(d.y)+_.elements[9])/_.elements[5],v.z=-1,v.w=(1+_.elements[10])/_.elements[14],d.multiplyScalar(2/d.dot(v)),_.elements[2]=d.x,_.elements[6]=d.y,_.elements[10]=d.z+1-r,_.elements[14]=d.w,this.visible=!1;var x=e.getRenderTarget(),y=e.xr.enabled,M=e.shadowMap.autoUpdate,S=e.outputColorSpace,b=e.toneMapping;e.xr.enabled=!1,e.shadowMap.autoUpdate=!1,e.outputColorSpace=Wt,e.toneMapping=Me,e.setRenderTarget(p),e.state.buffers.depth.setMask(!0),!1===e.autoClear&&e.clear();var T=!1;this.XR&&this.skybox&&(this.skybox.visible?T=!0:this.skybox.visible=!0);var w=!1;null!==(i=this.shadowPlane)&&void 0!==i&&i.visible&&(this.shadowPlane.visible=!1,w=!0),e.render(t,s),e.xr.enabled=y,e.shadowMap.autoUpdate=M,e.outputColorSpace=S,e.toneMapping=b,e.setRenderTarget(x),this.XR&&this.skybox&&!T&&(this.skybox.visible=!1),w&&(this.shadowPlane.visible=!0);var E=n.viewport;void 0!==E&&e.state.viewport(E),this.visible=!0}}getRenderTarget(){return this.renderTarget}dispose(){this.renderTarget.dispose(),this.material.dispose()}}var Tf=Object.freeze({__proto__:null,Mirrors:class{constructor(e){var{mirrors:t}=e.artifact,n=q.devicePixelRatio;this.textureWidth=q.innerWidth*n,this.textureHeight=q.innerHeight*n,this.engine=e,e.mirrors=t.map(this.addMirror.bind(this))}addMirror(e){var{clipBias:t=.003,color:n=7829367,type:i,params:r=[4,32],rotation:s={},position:a={}}=e,o=this.createGeometry({type:i,params:r}),{textureHeight:l,textureWidth:c}=this,h=new bf(o,{clipBias:t,textureWidth:c,textureHeight:l,color:n},this.engine),{x:u,y:d,z:p}=s;if(u){var m=pn.degToRad(u);h.rotateX(m)}if(d){var f=pn.degToRad(d);h.rotateY(f)}if(p){var g=pn.degToRad(p);h.rotateZ(g)}var{x:v,y:_,z:x}=a;return v&&h.position.setX(v),_&&h.position.setY(_),x&&h.position.setZ(x),this.engine.model.add(h),h}createGeometry(e){var{type:t,params:n}=e,{BOX:i,CIRCLE:r,PLANE:s,RING:a,SPHERE:o}=q.APP_DB.MESH_TYPES;switch(t){case i:return console.warn("W_MIRROR_WITH_VOLUME","Mirror is using a BoxGeometry. Mirrors with volume will sometimes create rendering issues."),new Zr(...n);case r:return new Fc(...n);case s:return new gs(...n);case a:return console.warn("W_MIRROR_WITH_VOLUME","Mirror is using a RingGeometry. Mirrors with volume will sometimes create rendering issues."),new Eh(...n);case o:return console.warn("W_MIRROR_WITH_VOLUME","Mirror is using a SphereGeometry. Mirrors with volume will sometimes create rendering issues."),new Rh(...n);default:return new gs(...n)}}}}),wf=Object.freeze({__proto__:null,addPly:e=>{var n,{artifact:i,preload:r}=e,s=Jm(i.ply,{vertexColors:!0,size:.01,sizeAttenuation:!0,opacity:"1.0"}),a={x:0,y:0,z:0},o=Jm(i.ply,{positions:[],rotations:[],position:a,pos:a,rotation:a,rot:a});e.morphTargetInfluenceConfig=Jm(i.ply,{animated:!1,delay:1e3,speed:1});var l=new Ho;l.name="plyGroup";var{position:c=o.pos,positions:h=[],rotation:u=o.rot,rotations:d=[],scale:p,scales:m=[]}=o,f=0!==c.x||0!==c.y||0!==c.z;if(X.arr(r.assets.ply)&&null!==(n=r.assets.ply)&&void 0!==n&&n.length)if(e.morphTargetInfluenceConfig.animated){var[g]=r.assets.ply;g.morphAttributes={position:[],color:[]},r.assets.ply.forEach((e=>{g.morphAttributes.position.push(e.attributes.position),g.morphAttributes.color.push(e.attributes.color)}));var v=new ic(t(t({},s),{},{transparent:"1.0"!==s.opacity})),_=new lc(g,v);if(_.morphTargetInfluences[0]=1,e.animatedPoints=_,e.morphTargetTargetIndex=1,l.add(_),f){var x=l.position,{x:y=x.x,y:M=x.y,z:S=x.z}=c;l.position.set(y,M,S)}}else r.assets.ply.forEach(((e,n)=>{var i=new ic(t(t({},s),{},{transparent:"1.0"!==s.opacity})),r=new lc(e,i);if(h[n]){var{x:a,y:o,z:f}=h[n];r.position.set(a,o,f)}else if(c){var{x:g,y:v,z:_}=c;r.position.set(g,v,_)}if(d[n]){var{x:x,y:y,z:M}=d[n];r.rotation.set(x,y,M)}else if(u){var{x:S,y:b,z:T}=u;r.rotation.set(S,b,T)}if(m[n]){var{x:w,y:E,z:A}=m[n];r.scale.set(w,E,A)}else if(p){var{x:R,y:C,z:P}=p;r.scale.set(R,C,P)}l.add(r)}));else{var b=new ic(t(t({},s),{},{transparent:"1.0"!==s.opacity}));if(l.add(new lc(r.assets.ply,b)),f){var T=l.position,{x:w=T.x,y:E=T.y,z:A=T.z}=c;l.position.set(w,E,A)}}e.model?e.model.add(l):e.model=l}});var Ef=Object.freeze({__proto__:null,Particles:class{constructor(e){var{artifact:t,model:n,preload:i}=e;this.preload=i,this.model=n,this.defaultBox={x:10,y:10,z:10},this.particles=Jm(t.particles,[{name:"snowflake",size:.1,box:this.defaultBox}]),this.materials=[]}init(){var e=this;return i((function*(){var t=e.preload.textureLoader,n=new Ho;yield Promise.all(e.particles.map(function(){var r=i((function*(i){var{box:r=e.defaultBox,color:s=16777215,count:a=1e3,name:o,size:l,imgType:c="png",opacity:h=1}=i,u=o;u.endsWith(".".concat(c))&&(u=u.replace(".".concat(c),"")),Bp.WEBP?u+=".webp":u+=".".concat(c);for(var d=yield e.preload.promisifiedLoad({loader:t,file:"https://static.artificialmuseum.com/textures/matcap/".concat(u)}),p=new ic({size:l,map:d,color:s,blending:1,depthTest:!1,transparent:!0,opacity:h}),m=new Cr,f=[],g=0;g.5?-1:1)*Math.random()*(2*r.x)-r.x;var _=Math.random()*r.y,x=void 0;if(0===r.zMin)x=Math.random()*r.z;else x=(Math.random()>.5?-1:1)*Math.random()*(2*r.z)-r.z;f.push(v,_,x)}m.setAttribute("position",new Mr(f,3));var y=new lc(m,p);n.add(y)}));return function(e){return r.apply(this,arguments)}}())),e.model.add(n),e.particles=n}))()}update(e){var{delta:t}=e;this.particles.rotation.y+=.01*t}}});var Af=Object.freeze({__proto__:null,LookAtCamera:class{constructor(e){this.lookAtPosition=new Gn;var{artifact:t,model:n}=e;n.traverse((n=>{var i=t.lookAtCameraObjects.find((e=>ef({node:n,search:X.str(e)?e:e.name})));if(i){var{speed:r,lookAtY:s=!0}=i;r=X.num(r)?r:t.lookAtSpeed,s=X.bool(t.lookAtY)?t.lookAtY:s,e.lookAtCameraObjects.push({speed:r,lookAtY:s,node:n,alpha:0})}}))}render(e){var{engine:t,delta:n}=e,{camera:i,lookAtCameraObjects:r=[],lookAtY:s}=t;r.forEach((e=>{var{lookAtY:t=!0,node:r,speed:a}=e;if(!1!==t&&!1!==s){var o,l,c,h;e.alpha+=n*a,this.lookAtPosition.x=0,this.lookAtPosition.y=0,this.lookAtPosition.z=r.position.distanceTo(i.position),!1!==t&&!1!==s||(this.lookAtPosition.y=0===r.position.y?.01:r.position.y),this.lookAtPosition.distanceToSquared(i.position)>.1?(this.lookAtPosition.lerp(i.position,Math.min(1,e.alpha)),r.lookAt(this.lookAtPosition)):e.alpha=0}else{var u=(o=i.position.x,l=r.position.x,c=i.position.z,h=r.position.z,Math.atan2(o-l,c-h));r.rotation.y=u}}))}}});var Rf=Object.freeze({__proto__:null,TextGeometry:class extends Sh{constructor(e,t={}){const n=t.font;if(void 0===n)super();else{const i=n.generateShapes(e,t.size);t.depth=void 0!==t.height?t.height:50,void 0===t.bevelThickness&&(t.bevelThickness=10),void 0===t.bevelSize&&(t.bevelSize=8),void 0===t.bevelEnabled&&(t.bevelEnabled=!1),super(i,t)}this.type="TextGeometry"}}});var Cf=Object.freeze({__proto__:null,CustomMaterials:class{constructor(e){var{preload:t}=e,{customMaterials:n=[]}=t.assets;n.forEach((t=>{var{config:n,material:i}=t,{target:r}=n,s=e.model.getObjectByName(r);s&&(X.fn(i.init)&&i.init({engine:e,node:s,target:r}),s.material=i,e.customMaterials.push({config:n,material:i}))})),e.addRenderStep(this.tick.bind(this))}tick(e){var{delta:t,engine:n}=e;n.customMaterials.forEach((n=>{var{config:i,material:r}=n;if(r.uniforms.uTime){var{speed:s=1}=i;r.uniforms.uTime.value+=t*s}X.fn(r.tick)&&r.tick(e)}))}}}),Pf=["canvas","texture","scale","scene","shaderConfig"];class Lf extends es{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{canvas:t,texture:n,scale:i=1,scene:r,shaderConfig:a={}}=e;super(s(e,Pf)),this.scene=r;var o=new On;(t||n)&&(t?o=new dc(t):n&&(o=n),o.needsUpdate=!1,o.minFilter=Be,o.magFilter=Be,o.format=Je);var{ptSize:l=1,sizeAttenuation:c=1}=a;this.shaderConfig=Jm(a,{filterSize:"1",minDepth:"0.1",maxDepth:"7.0",depthThresholdFilter:"1.0",scale:2*i,depthScale:"1.0",hueRedReducer:"0.0",pixelDepth:"3.0",ptSize:(parseFloat(l)*window.devicePixelRatio).toFixed(1).toString(),sizeAttenuation:(parseFloat(c)*window.devicePixelRatio).toFixed(2).toString(),alpha:1,iK:[0,0,0,0],width:1164,height:776}),this.uniforms={texImg:{type:"t",value:o},texSize:{type:"i2",value:[this.shaderConfig.width,this.shaderConfig.height]},iK:{type:"f4",value:this.shaderConfig.iK},scale:{type:"f",value:this.shaderConfig.scale},ptSize:{type:"f",value:this.shaderConfig.ptSize},alpha:{type:"f",value:this.shaderConfig.alpha},filterSize:{type:"f",value:this.shaderConfig.filterSize},minDepth:{type:"f",value:this.shaderConfig.minDepth},maxDepth:{type:"f",value:this.shaderConfig.maxDepth},depthThresholdFilter:{type:"f",value:this.shaderConfig.depthThresholdFilter},hueRedReducer:{type:"f",value:this.shaderConfig.hueRedReducer},pixelDepth:{type:"f",value:this.shaderConfig.pixelDepth},depthScale:{type:"f",value:this.shaderConfig.depthScale},sizeAttenuation:{type:"f",value:this.shaderConfig.sizeAttenuation}},this.side=me,this.transparent=!1,this.vertexShader="\nattribute float vertexIdx;\n\nvarying float vVertexIdx;\nvarying vec2 vPtPos;\n\nuniform ivec2 texSize;\nuniform sampler2D texImg;\nuniform vec4 iK;\nuniform float scale;\nuniform float minDepth;\nuniform float maxDepth;\nuniform float pixelDepth;\nuniform int filterSize;\nuniform float ptSize;\nuniform float depthThresholdFilter;\nuniform float depthScale;\nuniform float hueRedReducer;\nuniform float sizeAttenuation;\n\n#include \n\nfloat rgb2hue(vec3 c) {\n float r = c.r - hueRedReducer;\n vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n vec4 q = mix(vec4(p.xyw, r), vec4(r, p.yzx), step(p.x, r));\n\n float d = q.x - min(q.w, q.y);\n float e = 1.0e-10;\n return abs(q.z + (q.w - q.y) / (6.0 * d + e));\n}\n\nfloat getPixelDepth(ivec2 pixel) {\n vec2 lookupPt = (vec2(pixel) + vec2(0.5)) / vec2(texSize);\n float hue = rgb2hue(texture2D(texImg, lookupPt).rgb);\n float pxDepth = pixelDepth * hue;\n if (pxDepth == 0.0) {\n return 1.0 * pixelDepth;\n }\n return pxDepth;\n}\n\nbool shouldDiscard(ivec2 currPixel) {\n float centerPixelDepth = getPixelDepth(currPixel);\n\n for (int i = -filterSize; i <= filterSize; i++) {\n for (int j = -filterSize; j <= filterSize; j++) {\n if (i == 0 && j == 0) {\n continue;\n }\n\n float currDepth = getPixelDepth(currPixel + ivec2(j, i));\n\n if (currDepth < minDepth\n || currDepth > maxDepth\n || abs(centerPixelDepth - currDepth) > depthThresholdFilter\n ) {\n return true;\n }\n }\n }\n\n return false;\n}\n\nvoid main() {\n ivec2 frameSize = ivec2(texSize.x / 2, texSize.y);\n int vertIdx = int(vertexIdx);\n\n int actualNumPts = frameSize.x * frameSize.y;\n if (vertIdx >= actualNumPts) {\n gl_Position = vec4(0.0);\n return;\n }\n\n int ptY = vertIdx / int(frameSize.x);\n int ptX = vertIdx - ptY * int(frameSize.x);\n\n ivec2 pt = ivec2(ptX, ptY);\n\n if (ptX <= 5 || shouldDiscard(pt)) {\n gl_Position = vec4(0.0);\n return;\n }\n\n float currDepth = getPixelDepth(pt);\n\n vec3 ptPos = scale * vec3(\n (iK.x * float(ptX) + iK.z) * currDepth,\n (iK.y * float(ptY) + iK.w) * currDepth,\n -currDepth * depthScale\n );\n\n vec4 mvPos = modelViewMatrix * vec4(ptPos, 1.0);\n gl_Position = projectionMatrix * mvPos;\n\n vPtPos = vec2(float(ptX), float(ptY));\n vVertexIdx = vertexIdx;\n\n gl_PointSize = ptSize;\n\n bool isPerspective = isPerspectiveMatrix(projectionMatrix);\n if ( isPerspective ) {\n gl_PointSize = max(ptSize, sizeAttenuation / -mvPos.z);\n }\n}\n",this.fragmentShader="\nvarying float vVertexIdx;\nvarying vec2 vPtPos;\n\nuniform ivec2 texSize;\nuniform sampler2D texImg;\nuniform float alpha;\n\nvoid main() {\n vec2 frameSizeF = vec2(texSize.x / 2, texSize.y);\n ivec2 frameSize = ivec2(frameSizeF);\n\n int vertIdx = int(vVertexIdx);\n int actualNumPts = frameSize.x * frameSize.y;\n if (vertIdx >= actualNumPts) {\n discard;\n }\n\n vec2 lookupPt = (vec2(vPtPos.x + frameSizeF.x, vPtPos.y) + vec2(0.5)) / vec2(texSize);\n vec3 currColor = texture2D(texImg, lookupPt).rgb;\n\n gl_FragColor = vec4(currColor, alpha);\n}\n"}}class If{constructor(e){var{artifact:t,image:n,position:i,quaternion:r,intrinsicMatrix:s,scene:a}=e;this.imageSource=n;var o=new Ho;this.imageObject=o;var{pos:l=t.position,rot:c=t.rotation}=t;if(l){var{x:h,y:u,z:d}=l;h&&(o.position.x+=h),u&&(o.position.y+=u),d&&(o.position.z+=d)}if(c){var{x:p,y:m,z:f}=c;p&&o.rotateX(p),m&&o.rotateY(m),f&&o.rotateZ(f)}var{width:g,height:v}=n.source.data,{ifx:_,ify:x,itx:y,ity:M}=s,S={iK:[_,x,y,M],width:g,height:v};this.material=new Lf({texture:n,scene:a,scale:1,shaderConfig:S}),o.position.set(i.x,i.y,i.z),o.quaternion.set(r.qx,r.qy,r.qz,r.qw);var b=g*v;this.buffIndices=new Uint32Array(b),this.buffPointIndicesAttr=new Float32Array(b);for(var T=0;T{var{position:t,quaternion:i,intrinsicMatrix:s=this.config.intrinsicMatrix,object:a}=e,o=new If({artifact:r,image:a,position:t,quaternion:i,intrinsicMatrix:s,parent:n.scene});n.model.add(o.imageObject)}))}}});var Uf=Object.freeze({__proto__:null,Portal:class{constructor(e){var t,{engine:n,mergeConfig:i}=e;if(this.engine=n,this.config=i(n.artifact.portal,{parent:"portal",clip:"clip",door:"door",skyIn:"skyIn",skyOut:"skyOut",groundIn:"groundIn",groundOut:"groundOut",earth:"earthOut",earthOutside:"earthOutside",placard:"placard",placardImage:!1,textureTarget:"textureTarget",renderTarget:"clipRenderTarget",renderTarget2:"clipRenderTarget2",triggerAreas:"triggerAreas",isInsideDoor:"isInsideDoor",isOutsideDoor:"isOutsideDoor",ignoreChildren:!1,isInDoor:"isInDoor",showIn:"showIn",hideIn:"hideIn",excludedChildren:"earthOutside",opened:!0,rayCast:{near:.5,far:50},load:!0,pos:{x:0,y:0,z:0}}),this.opened=this.config.opened,this.meshNames=i(n.artifact.portal,{clip:"clip",door:"door",skyIn:"skyIn",skyOut:"skyOut",groundIn:"groundIn",groundOut:"groundOut",earth:"earthOut",placard:"placard",renderTarget:"clipRenderTarget",renderTarget2:"clipRenderTarget2",earthOutside:"earthOutside"}),this.isInside=!1,this.camera=n.camera,this.model=n.model,null!=n&&null!==(t=n.model)&&void 0!==t&&t.children&&!0!==this.config.ignoreChildren){var r=new Ho;r.name="artifact",Object.entries(this.meshNames).forEach((e=>{var[t,i]=e,r=n.model.getObjectByName(i);r&&(this[t]=r)})),n.model.children.filter((e=>!this.config.excludedChildren.includes(e.name))).forEach((e=>{r.add(e),e.remove()})),this.children=[r];var{x:s,y:a,z:o}=this.config.pos;r.position.set(s,a,o),n.model.add(r)}else this.children=[];var l=n.model.getObjectByName("outside");this.outChildren=l?l.children:[],this.toggleOut(!1);var c=!1,h=!1,{glb:u,placardColor:d,placardNormal:p}=n.preload.assets.Portal;if(d&&(c=d),p&&(h=p),u){var{animations:m=[],scene:f}=u;m.length&&n.animations.push(...m),n.model?n.model.add(...f.children):n.model=f}var g=n.model.getObjectByName(this.config.parent);this.portal=g;var v=this.portal.getObjectByName("outside");v&&this.outChildren.push(...v.children);var _=this.portal.getObjectByName("inside");_&&this.children.push(..._.children),Object.entries(this.meshNames).forEach((e=>{var[t,n]=e,i=g.getObjectByName(n);i&&(this[t]?i.visible=!1:this[t]=i)}));var x=n.model.getObjectByName(this.meshNames.groundIn);if(x){if("portal"!==x.parent.parent.name){var y=g.getObjectByName(this.meshNames.groundIn);y&&y.position.set(5e3,5e3,5e3)}x.receiveShadow=!0}else console.error("groundIn not defined, looked for",this.meshNames.groundIn,n.model);var M=n.model.getObjectByName(this.meshNames.groundOut);if(M){if("portal"!==M.parent.parent.name){var S=g.getObjectByName(this.meshNames.groundOut);S&&S.position.set(5e3,5e3,5e3)}M.receiveShadow=!0}else console.error("groundOut not defined, looked for",this.meshNames.groundOut,n.model);var b=n.model.getObjectByName(this.meshNames.skyIn);if(b){b.receiveShadow=!1;var T=new hr;T.map=b.material.map,T.side=pe,b.material=T}else console.error("skyIn not defined, looked for",this.meshNames.skyIn,n.model);var w=n.model.getObjectByName(this.meshNames.skyOut);if(w){w.receiveShadow=!1;var E=new hr;E.map=w.material.map,E.side=pe,w.material=E}else console.error("skyOut not defined, looked for",this.meshNames.skyOut,n.model);this.renderTarget2&&(this.renderTarget2.visible=!1),this.config.textureTarget&&(this.textureTarget=g.getObjectByName(this.config.textureTarget),this.textureTarget&&(c?(this.textureTarget.material.map.source.data=c.source.data,h&&this.textureTarget.material.normalMap&&(this.textureTarget.material.normalMap.source.data=h.source.data),this.textureTarget.material.needsUpdate=!0):this.textureTarget.visible=!1)),this.triggerAreas=g.getObjectByName("triggerAreas"),this.triggerAreas.visible=!1,this.toggleOut(!1),this.toggleRenderTarget(!1),this.rayDirection=new Gn(0,-1,0);var{near:A,far:R}=this.config.rayCast;this.raycaster=new Ed(this.camera.position,this.rayDirection,A,R),this.lastIntersect=!1,this.door&&(this.door.castShadow=!0),n.addRenderStep(this.render.bind(this))}open(){this.opened=!0}close(){this.opened=!1}getTriggerArea(){var e;this.raycaster.set(this.camera.position,this.rayDirection);var[t]=this.raycaster.intersectObject(this.triggerAreas,!0);return null==t||null===(e=t.object)||void 0===e?void 0:e.name}setIfDifferent(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"visible";e&&(X.arr(e)?e:[e]).forEach((e=>{var i;e&&(e[n]!==t&&(e[n]=t),null!=e&&null!==(i=e.children)&&void 0!==i&&i.length&&e.traverse((e=>{e.hasOwnProperty(n)&&(e[n]=t)})))}))}toggleIn(e){this.setIfDifferent([this.skyIn,this.groundIn,...this.children],e)}toggleOut(e){this.setIfDifferent([this.skyOut,this.groundOut,this.earth,...this.outChildren],e),this.earthOutside&&this.setIfDifferent([this.earthOutside],!e)}toggleClip(e){this.setIfDifferent(this.clip,e)}togglePlacard(e){this.placard&&this.setIfDifferent(this.placard,e)}rotatePlacard(e){if(this.placard){var t=new Ri(0,pn.degToRad(e),0);this.placard.quaternion.setFromEuler(t)}}toggleRenderTarget(e){this.setIfDifferent(this.renderTarget,e)}walkInside(){this.opened?this.isInside||(this.toggleIn(!0),this.toggleOut(!0),this.toggleClip(!1),this.rotatePlacard(180),this.toggleRenderTarget(!0),this.isInside=!0):(this.toggleIn(!1),this.toggleOut(!1),this.toggleClip(!1),this.toggleRenderTarget(!1))}walkOutside(){this.isInside&&(this.toggleIn(!0),this.toggleOut(!1),this.toggleClip(!0),this.rotatePlacard(0),this.toggleRenderTarget(!1),this.isInside=!1)}render(){if(this.engine.modelSpawned){var e=this.getTriggerArea();if(e){if(this.lastIntersect!==e){var{isInsideDoor:t,isOutsideDoor:n,isInDoor:i,showIn:r,hideIn:s}=this.config,a=this.lastIntersect;e===t?a!==n&&a!==i||this.walkInside():e===n?a!==t&&a!==i||this.walkOutside():e===i&&(this.toggleIn(!0),this.toggleOut(a===n)),this.isInside||(e===r?(this.toggleIn(!0),this.toggleOut(!1),this.toggleClip(!0)):e===s&&(this.toggleIn(!1),this.toggleOut(!1),this.toggleClip(!1))),this.lastIntersect=e}}else this.lastIntersect=!1}}}});class Nf extends qr{constructor(e,t={}){super(e),this.isWater=!0;const n=this,i=void 0!==t.textureWidth?t.textureWidth:512,r=void 0!==t.textureHeight?t.textureHeight:512,s=void 0!==t.clipBias?t.clipBias:0,a=void 0!==t.alpha?t.alpha:1,o=void 0!==t.time?t.time:0,l=void 0!==t.waterNormals?t.waterNormals:null,c=void 0!==t.sunDirection?t.sunDirection:new Gn(.70707,.70707,0),h=new lr(void 0!==t.sunColor?t.sunColor:16777215),u=new lr(void 0!==t.waterColor?t.waterColor:8355711),d=void 0!==t.eye?t.eye:new Gn(0,0,0),p=void 0!==t.distortionScale?t.distortionScale:20,m=void 0!==t.side?t.side:de,f=void 0!==t.fog&&t.fog,g=new hs,v=new Gn,_=new Gn,x=new Gn,y=new _i,M=new Gn(0,0,-1),S=new Fn,b=new Gn,T=new Gn,w=new Fn,E=new _i,A=new ns,R=new zn(i,r),C={uniforms:$r.merge([_s.fog,_s.lights,{normalSampler:{value:null},mirrorSampler:{value:null},alpha:{value:1},time:{value:0},size:{value:1},distortionScale:{value:20},textureMatrix:{value:new _i},sunColor:{value:new lr(8355711)},sunDirection:{value:new Gn(.70707,.70707,0)},eye:{value:new Gn},waterColor:{value:new lr(5592405)}}]),vertexShader:"\n\t\t\t\tuniform mat4 textureMatrix;\n\t\t\t\tuniform float time;\n\n\t\t\t\tvarying vec4 mirrorCoord;\n\t\t\t\tvarying vec4 worldPosition;\n\n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\t\t\t\t\tmirrorCoord = modelMatrix * vec4( position, 1.0 );\n\t\t\t\t\tworldPosition = mirrorCoord.xyzw;\n\t\t\t\t\tmirrorCoord = textureMatrix * mirrorCoord;\n\t\t\t\t\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t\tgl_Position = projectionMatrix * mvPosition;\n\n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t}",fragmentShader:"\n\t\t\t\tuniform sampler2D mirrorSampler;\n\t\t\t\tuniform float alpha;\n\t\t\t\tuniform float time;\n\t\t\t\tuniform float size;\n\t\t\t\tuniform float distortionScale;\n\t\t\t\tuniform sampler2D normalSampler;\n\t\t\t\tuniform vec3 sunColor;\n\t\t\t\tuniform vec3 sunDirection;\n\t\t\t\tuniform vec3 eye;\n\t\t\t\tuniform vec3 waterColor;\n\n\t\t\t\tvarying vec4 mirrorCoord;\n\t\t\t\tvarying vec4 worldPosition;\n\n\t\t\t\tvec4 getNoise( vec2 uv ) {\n\t\t\t\t\tvec2 uv0 = ( uv / 103.0 ) + vec2(time / 17.0, time / 29.0);\n\t\t\t\t\tvec2 uv1 = uv / 107.0-vec2( time / -19.0, time / 31.0 );\n\t\t\t\t\tvec2 uv2 = uv / vec2( 8907.0, 9803.0 ) + vec2( time / 101.0, time / 97.0 );\n\t\t\t\t\tvec2 uv3 = uv / vec2( 1091.0, 1027.0 ) - vec2( time / 109.0, time / -113.0 );\n\t\t\t\t\tvec4 noise = texture2D( normalSampler, uv0 ) +\n\t\t\t\t\t\ttexture2D( normalSampler, uv1 ) +\n\t\t\t\t\t\ttexture2D( normalSampler, uv2 ) +\n\t\t\t\t\t\ttexture2D( normalSampler, uv3 );\n\t\t\t\t\treturn noise * 0.5 - 1.0;\n\t\t\t\t}\n\n\t\t\t\tvoid sunLight( const vec3 surfaceNormal, const vec3 eyeDirection, float shiny, float spec, float diffuse, inout vec3 diffuseColor, inout vec3 specularColor ) {\n\t\t\t\t\tvec3 reflection = normalize( reflect( -sunDirection, surfaceNormal ) );\n\t\t\t\t\tfloat direction = max( 0.0, dot( eyeDirection, reflection ) );\n\t\t\t\t\tspecularColor += pow( direction, shiny ) * sunColor * spec;\n\t\t\t\t\tdiffuseColor += max( dot( sunDirection, surfaceNormal ), 0.0 ) * sunColor * diffuse;\n\t\t\t\t}\n\n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\t#include \n\t\t\t\t\tvec4 noise = getNoise( worldPosition.xz * size );\n\t\t\t\t\tvec3 surfaceNormal = normalize( noise.xzy * vec3( 1.5, 1.0, 1.5 ) );\n\n\t\t\t\t\tvec3 diffuseLight = vec3(0.0);\n\t\t\t\t\tvec3 specularLight = vec3(0.0);\n\n\t\t\t\t\tvec3 worldToEye = eye-worldPosition.xyz;\n\t\t\t\t\tvec3 eyeDirection = normalize( worldToEye );\n\t\t\t\t\tsunLight( surfaceNormal, eyeDirection, 100.0, 2.0, 0.5, diffuseLight, specularLight );\n\n\t\t\t\t\tfloat distance = length(worldToEye);\n\n\t\t\t\t\tvec2 distortion = surfaceNormal.xz * ( 0.001 + 1.0 / distance ) * distortionScale;\n\t\t\t\t\tvec3 reflectionSample = vec3( texture2D( mirrorSampler, mirrorCoord.xy / mirrorCoord.w + distortion ) );\n\n\t\t\t\t\tfloat theta = max( dot( eyeDirection, surfaceNormal ), 0.0 );\n\t\t\t\t\tfloat rf0 = 0.3;\n\t\t\t\t\tfloat reflectance = rf0 + ( 1.0 - rf0 ) * pow( ( 1.0 - theta ), 5.0 );\n\t\t\t\t\tvec3 scatter = max( 0.0, dot( surfaceNormal, eyeDirection ) ) * waterColor;\n\t\t\t\t\tvec3 albedo = mix( ( sunColor * diffuseLight * 0.3 + scatter ) * getShadowMask(), ( vec3( 0.1 ) + reflectionSample * 0.9 + reflectionSample * specularLight ), reflectance);\n\t\t\t\t\tvec3 outgoingLight = albedo;\n\t\t\t\t\tgl_FragColor = vec4( outgoingLight, alpha );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \t\n\t\t\t\t}"},P=new es({fragmentShader:C.fragmentShader,vertexShader:C.vertexShader,uniforms:$r.clone(C.uniforms),lights:!0,side:m,fog:f});P.uniforms.mirrorSampler.value=R.texture,P.uniforms.textureMatrix.value=E,P.uniforms.alpha.value=a,P.uniforms.time.value=o,P.uniforms.normalSampler.value=l,P.uniforms.sunColor.value=h,P.uniforms.waterColor.value=u,P.uniforms.sunDirection.value=c,P.uniforms.distortionScale.value=p,P.uniforms.eye.value=d,n.material=P,n.onBeforeRender=function(e,t,i){if(_.setFromMatrixPosition(n.matrixWorld),x.setFromMatrixPosition(i.matrixWorld),y.extractRotation(n.matrixWorld),v.set(0,0,1),v.applyMatrix4(y),b.subVectors(_,x),b.dot(v)>0)return;b.reflect(v).negate(),b.add(_),y.extractRotation(i.matrixWorld),M.set(0,0,-1),M.applyMatrix4(y),M.add(x),T.subVectors(_,M),T.reflect(v).negate(),T.add(_),A.position.copy(b),A.up.set(0,1,0),A.up.applyMatrix4(y),A.up.reflect(v),A.lookAt(T),A.far=i.far,A.updateMatrixWorld(),A.projectionMatrix.copy(i.projectionMatrix),E.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),E.multiply(A.projectionMatrix),E.multiply(A.matrixWorldInverse),g.setFromNormalAndCoplanarPoint(v,_),g.applyMatrix4(A.matrixWorldInverse),S.set(g.normal.x,g.normal.y,g.normal.z,g.constant);const r=A.projectionMatrix;w.x=(Math.sign(S.x)+r.elements[8])/r.elements[0],w.y=(Math.sign(S.y)+r.elements[9])/r.elements[5],w.z=-1,w.w=(1+r.elements[10])/r.elements[14],S.multiplyScalar(2/S.dot(w)),r.elements[2]=S.x,r.elements[6]=S.y,r.elements[10]=S.z+1-s,r.elements[14]=S.w,d.setFromMatrixPosition(i.matrixWorld);const a=e.getRenderTarget(),o=e.xr.enabled,l=e.shadowMap.autoUpdate;n.visible=!1,e.xr.enabled=!1,e.shadowMap.autoUpdate=!1,e.setRenderTarget(R),e.state.buffers.depth.setMask(!0),!1===e.autoClear&&e.clear(),e.render(t,A),n.visible=!0,e.xr.enabled=o,e.shadowMap.autoUpdate=l,e.setRenderTarget(a);const c=i.viewport;void 0!==c&&e.state.viewport(c)}}}var Of=Object.freeze({__proto__:null,OceanPlane:class{constructor(e){var{artifact:t,engine:n,preload:i}=e;this.config=Jm(t.ocean,{normals:"oceannormals1",name:"ocean"});var r=n.model.getObjectByName(this.config.name),{waterNormals:s}=i.assets;s.wrapS=s.wrapT=De,n.ocean=new Nf(r.geometry,{textureWidth:512,textureHeight:512,waterNormals:s,sunDirection:new Gn,sunColor:16777215,waterColor:1048575,distortionScale:3.7,fog:!1}),n.ocean.position.copy(r.position),n.ocean.rotation.copy(r.rotation),n.model.add(n.ocean),r.visible=!1}render(e){var{delta:t,engine:n}=e,{animationSpeed:i=1}=n.artifact.ocean;n.ocean.material.uniforms.time.value+=t*i*.1}}});var Ff=Object.freeze({__proto__:null,VideoTrigger:class{constructor(e){var{artifact:t,videoElement:n}=e,i=["videotarget","videotrigger"],{videoTriggerName:r=!1,videoTriggerHide:s=!0}=t;r&&i.push(r),e.model.traverse((e=>{this.ele||i.some((t=>Qm(e.name,t)))&&(this.ele=e,s&&(this.ele.visible=!1))})),n.currentTime=.01,this.ele&&e.addRenderStep(this.render.bind(this))}render(e){var{engine:t}=e;if(t.modelSpawned&&t.artifact.triggerVideo&&this.ele){var{audioElement:n,camera:i,videoElement:r}=t,{triggerAudio:s,triggerVideo:a,triggerVideoDistance:o=1.1,videoTriggerExitOnDistance:l=!0,videoTriggerPauseWhenLeaving:c=!0,videoTriggerHide:h=!0}=t.artifact,u=this.ele.position.clone();u.add(this.ele.parent.position);var d=i.position.distanceTo(u),p=r.paused;d<=o?(a&&r&&p&&(r.play(),this.ele.visible=!0),s&&n&&n.paused&&n.play()):(!p&&a&&l&&(c&&(r.pause(),r.currentTime=0),h&&(this.ele.visible=!1)),s&&n&&!n.paused&&n.pause())}}}});var zf=Object.freeze({__proto__:null,UnderwaterPlane:class{constructor(e){var{engine:t}=e;t.addRenderStep(this.render.bind(this))}preload(e){var t=this;return i((function*(){var{camera:n,preload:i}=e,r=new of;yield r.preload(i),t.material=r;var s=new gs(2,2),a=new qr(s,r);n.add(a),a.position.z-=.1}))()}render(e){var{delta:t,engine:n}=e;n.modelSpawned&&this.material.tick(t)}}});export{ap as $,ge as A,Cr as B,hr as C,me as D,Uu as E,de as F,Mu as G,we as H,Zr as I,Wh as J,Ho as K,Wt as L,zh as M,Oe as N,Vi as O,lc as P,Mc as Q,rf as R,es as S,$d as T,Ih as U,hc as V,q as W,Vm as X,lr as Y,Ju as Z,t as _,X as a,P as a$,od as a0,ld as a1,Fu as a2,Xl as a3,tc as a4,Gn as a5,af as a6,ic as a7,Qm as a8,uu as a9,$o as aA,w as aB,ns as aC,Zo as aD,H as aE,Se as aF,he as aG,G as aH,ie as aI,zn as aJ,Ou as aK,Oh as aL,R as aM,Eh as aN,ef as aO,jm as aP,pe as aQ,Os as aR,Qo as aS,Jo as aT,nf as aU,L as aV,Vt as aW,qm as aX,k as aY,Km as aZ,A as a_,Lt as aa,bd as ab,pn as ac,kh as ad,Ed as ae,fe as af,Dh as ag,Mr as ah,yr as ai,Jm as aj,Je as ak,Be as al,J as am,Qt as an,oe as ao,le as ap,Hn as aq,Cd as ar,mn as as,E as at,Ri as au,V as av,W as aw,_p as ax,xp as ay,td as az,Rp as b,I as b0,Gp as b1,zm as b2,km as b3,Ym as b4,U as b5,kp as b6,C as b7,z as b8,p as b9,Of as bA,Ff as bB,zf as bC,F as ba,tf as bb,d as bc,r as bd,u as be,o as bf,c as bg,a as bh,_i as bi,Ph as bj,Bc as bk,of as bl,sf as bm,lf as bn,hf as bo,uf as bp,mf as bq,Mf as br,Tf as bs,wf as bt,Ef as bu,Af as bv,Rf as bw,Cf as bx,Df as by,Uf as bz,i as c,N as d,m as e,g as f,v as g,ip as h,b as i,j,Cp as k,f as l,np as m,Pp as n,D as o,Lp as p,Dp as q,se as r,Bp as s,T as t,_r as u,gs as v,re as w,qr as x,Rh as y,O as z}; +function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function t(t){for(var n=1;n=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function a(e,t){return function(e,t){if(t.get)return t.get.call(e);return t.value}(e,l(e,t,"get"))}function o(e,t,n){return function(e,t,n){if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}}(e,l(e,t,"set"),n),n}function l(e,t,n){if(!t.has(e))throw new TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}function c(e,t,n){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return n}function h(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function u(e,t,n){h(e,t),t.set(e,n)}function d(e,t){h(e,t),t.add(e)}var p=1,m="map-container",f=17,g=['osm','leaflet','stamen'].join("
"),v=5e12,_=[38,38],x=[_[0]/2,_[1]/2],y=[0,_[1]/2*-1],S="map/marker",b={location:{iconUrl(e){var t=e>0?e:1;return e>9&&(t="9-plus"),"".concat(S,"/location-").concat(t,".svg")},iconSize:_,iconAnchor:x,popupAnchor:y},city:{iconUrl:e=>"".concat(S,"/cities/").concat(e,".svg"),iconSize:_,iconAnchor:x,popupAnchor:y},artifact:{iconUrl:"".concat(S,"/object.svg"),iconSize:_,iconAnchor:x,popupAnchor:y}},T={strings:{title:"Click to locate yourself.",metersUnit:"meters",feetUnit:"feet",popup:"You are within {distance} {unit} from this point",outsideMapBoundsMsg:"\nIt seems like your Device has no gps sensors, or you declined our request to use gps.\n"},locateOptions:{watch:!0,enableHighAccuracy:!0}},w={fov:60,near:.01,far:500},E={maxDistance:60,minDistance:1,maxPolarAngle:Math.PI/1.9,enablePan:!1},A={ambientColor:16777215,ambientIntensity:.3,directionalColor:16777215,directionalIntensity:.8*Math.PI,directionalPosition:[60,120,28]},R=.2,C=5e3,P=[100,60,40],L="three-running",I={x:0,y:1.7,z:5},D=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"at this location.";return 0===e?e="are no artifacts":1===e?e="is 1 artifact":e>1&&(e="are ".concat(e," artifacts")),"There ".concat(e," ").concat(t)},U=1e4,N="Zoom to location",O="Visit City",F="three-audio",z="three-video",k="three-media",H="three-canvas",G="three-container",V="hud",W="hud-exit-button",j=1e4,X=(e,t)=>"function"==typeof X[t]?X[t](e):typeof e===t;X.fn=e=>"function"==typeof e,X.str=e=>"string"==typeof e,X.obj=e=>"object"==typeof e,X.arr=e=>Array.isArray(e),X.bool=e=>"boolean"==typeof e,X.num=e=>e===+e,X.int=e=>e===+e&&e===(0|e);var q=window;q.D=document,q.B=q.D.body,q.M=Math,q.NAV=q.navigator,q.UA=q.NAV.userAgent.toLowerCase()||"",q.URL=q.URL||q.webkitURL,q.LOC=q.location,q.pxRatio=q.devicePixelRatio,q.store=new class{constructor(e){var{W:t,type:n="session"}=e;try{var i=t["".concat(n,"Storage")],r="random-".concat(M.random());i.setItem(r,r),i.removeItem(r),this.store=i}catch(e){this.store={}}}setItem(e,t){var n=["setItem","getItem","removeItem"],i=n.indexOf(e);if(i>-1)throw new Error("can not overwrite store.".concat(n[i],", it's a builtin"));var r=JSON.stringify(t);return this.store[e]=r,!0}getItem(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;return this.store.hasOwnProperty(e)?JSON.parse(this.store[e]):t}removeItem(e){X.fn(this.store.removeItem)?this.store.removeItem(e):delete this.store[e]}clear(){X.fn(this.store.clear)?this.store.clear():this.store={}}}({W:q,type:"session"});var Y=q.UA,Z=Y.includes("mac")&&"ontouchend"in q.D,K=["ipad","iphone","ipod"].some((e=>Y.includes(e))),J=K||Z,Q=!J&&Y.includes("macintosh"),$=Y.includes("applewebkit")&&Y.includes("safari")&&!Y.includes("crios"),ee=Y.includes("firefox")&&Y.includes("gecko")&&Y.includes("mozilla")&&!Y.includes("seamonkey"),te=(()=>{var e;if(Y.includes("chrome/")?e=Y.split("chrome/")[1]:Y.includes("samsungbrowser/")&&(e=Y.split("samsungbrowser/")[1]),e){e=e.split(".")[0];var t=parseInt(e,10);if(X.num(t))return t}})(),ne=X.num(te),ie=Y.includes("android"),re=J&&Y.includes("webxrviewer"),se=J&&!re,ae=Object.freeze({__proto__:null,android:ie,chrome:ne,firefox:ee,firefoxVersion:()=>{Y.includes("firefox/")&&Y.split("firefox/")[1]},hell:se,iDevice:K,ios:J,ios13:Z,macos:Q,safari:$,version:te,webxrviewer:re});const oe="154",le={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ce={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},he=1,ue=2,de=3,pe=0,me=1,fe=2,ge=1,ve=2,_e=100,xe=0,ye=1,Me=2,Se=0,be=1,Te=2,we=3,Ee=4,Ae=5,Re=300,Ce=301,Pe=302,Le=303,Ie=304,De=306,Ue=1e3,Ne=1001,Oe=1002,Fe=1003,ze=1004,Be=1005,ke=1006,He=1007,Ge=1008,Ve=1009,We=1012,je=1013,Xe=1014,qe=1015,Ye=1016,Ze=1017,Ke=1018,Je=1020,Qe=1023,$e=1026,et=1027,tt=1029,nt=1031,it=1033,rt=33776,st=33777,at=33778,ot=33779,lt=35840,ct=35841,ht=35842,ut=35843,dt=37492,pt=37496,mt=37808,ft=37809,gt=37810,vt=37811,_t=37812,xt=37813,yt=37814,Mt=37815,St=37816,bt=37817,Tt=37818,wt=37819,Et=37820,At=37821,Rt=36492,Ct=36284,Pt=36285,Lt=36286,It=2200,Dt=2300,Ut=2301,Nt=2302,Ot=2400,Ft=2401,zt=2402,Bt=2500,kt=2501,Ht=3e3,Gt=3001,Vt="",Wt="srgb",jt="srgb-linear",Xt="display-p3",qt=7680,Yt=35044,Zt="300 es",Kt=1035,Jt=2e3,Qt=2001;class $t{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const n=t.slice(0);for(let t=0,i=n.length;t>8&255]+en[e>>16&255]+en[e>>24&255]+"-"+en[255&t]+en[t>>8&255]+"-"+en[t>>16&15|64]+en[t>>24&255]+"-"+en[63&n|128]+en[n>>8&255]+"-"+en[n>>16&255]+en[n>>24&255]+en[255&i]+en[i>>8&255]+en[i>>16&255]+en[i>>24&255]).toLowerCase()}function an(e,t,n){return Math.max(t,Math.min(n,e))}function on(e,t){return(e%t+t)%t}function ln(e,t,n){return(1-n)*e+n*t}function cn(e){return 0==(e&e-1)&&0!==e}function hn(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function un(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function dn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function pn(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}const mn={DEG2RAD:nn,RAD2DEG:rn,generateUUID:sn,clamp:an,euclideanModulo:on,mapLinear:function(e,t,n,i,r){return i+(e-t)*(r-i)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:ln,damp:function(e,t,n,i){return ln(e,t,1-Math.exp(-n*i))},pingpong:function(e,t=1){return t-Math.abs(on(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(tn=e);let t=tn+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296},degToRad:function(e){return e*nn},radToDeg:function(e){return e*rn},isPowerOfTwo:cn,ceilPowerOfTwo:hn,floorPowerOfTwo:un,setQuaternionFromProperEuler:function(e,t,n,i,r){const s=Math.cos,a=Math.sin,o=s(n/2),l=a(n/2),c=s((t+i)/2),h=a((t+i)/2),u=s((t-i)/2),d=a((t-i)/2),p=s((i-t)/2),m=a((i-t)/2);switch(r){case"XYX":e.set(o*h,l*u,l*d,o*c);break;case"YZY":e.set(l*d,o*h,l*u,o*c);break;case"ZXZ":e.set(l*u,l*d,o*h,o*c);break;case"XZX":e.set(o*h,l*m,l*p,o*c);break;case"YXY":e.set(l*p,o*h,l*m,o*c);break;case"ZYZ":e.set(l*m,l*p,o*h,o*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:pn,denormalize:dn};class fn{constructor(e=0,t=0){fn.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(an(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),r=this.x-e.x,s=this.y-e.y;return this.x=r*n-s*i+e.x,this.y=r*i+s*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class gn{constructor(e,t,n,i,r,s,a,o,l){gn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,s,a,o,l)}set(e,t,n,i,r,s,a,o,l){const c=this.elements;return c[0]=e,c[1]=i,c[2]=a,c[3]=t,c[4]=r,c[5]=o,c[6]=n,c[7]=s,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,s=n[0],a=n[3],o=n[6],l=n[1],c=n[4],h=n[7],u=n[2],d=n[5],p=n[8],m=i[0],f=i[3],g=i[6],v=i[1],_=i[4],x=i[7],y=i[2],M=i[5],S=i[8];return r[0]=s*m+a*v+o*y,r[3]=s*f+a*_+o*M,r[6]=s*g+a*x+o*S,r[1]=l*m+c*v+h*y,r[4]=l*f+c*_+h*M,r[7]=l*g+c*x+h*S,r[2]=u*m+d*v+p*y,r[5]=u*f+d*_+p*M,r[8]=u*g+d*x+p*S,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],l=e[7],c=e[8];return t*s*c-t*a*l-n*r*c+n*a*o+i*r*l-i*s*o}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],l=e[7],c=e[8],h=c*s-a*l,u=a*o-c*r,d=l*r-s*o,p=t*h+n*u+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return e[0]=h*m,e[1]=(i*l-c*n)*m,e[2]=(a*n-i*s)*m,e[3]=u*m,e[4]=(c*t-i*o)*m,e[5]=(i*r-a*t)*m,e[6]=d*m,e[7]=(n*o-l*t)*m,e[8]=(s*t-n*r)*m,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,r,s,a){const o=Math.cos(r),l=Math.sin(r);return this.set(n*o,n*l,-n*(o*s+l*a)+s+e,-i*l,i*o,-i*(-l*s+o*a)+a+t,0,0,1),this}scale(e,t){return this.premultiply(vn.makeScale(e,t)),this}rotate(e){return this.premultiply(vn.makeRotation(-e)),this}translate(e,t){return this.premultiply(vn.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const vn=new gn;function _n(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}const xn={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function yn(e,t){return new xn[e](t)}function Mn(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}const Sn={};function bn(e){e in Sn||(Sn[e]=!0,console.warn(e))}function Tn(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function wn(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}const En=(new gn).fromArray([.8224621,.0331941,.0170827,.177538,.9668058,.0723974,-1e-7,1e-7,.9105199]),An=(new gn).fromArray([1.2249401,-.0420569,-.0196376,-.2249404,1.0420571,-.0786361,1e-7,0,1.0982735]);const Rn={[jt]:e=>e,[Wt]:e=>e.convertSRGBToLinear(),[Xt]:function(e){return e.convertSRGBToLinear().applyMatrix3(An)}},Cn={[jt]:e=>e,[Wt]:e=>e.convertLinearToSRGB(),[Xt]:function(e){return e.applyMatrix3(En).convertLinearToSRGB()}},Pn={enabled:!0,get legacyMode(){return console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),!this.enabled},set legacyMode(e){console.warn("THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150."),this.enabled=!e},get workingColorSpace(){return jt},set workingColorSpace(e){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,n){if(!1===this.enabled||t===n||!t||!n)return e;const i=Rn[t],r=Cn[n];if(void 0===i||void 0===r)throw new Error(`Unsupported color space conversion, "${t}" to "${n}".`);return r(i(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)}};let Ln;class In{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===Ln&&(Ln=Mn("canvas")),Ln.width=e.width,Ln.height=e.height;const n=Ln.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Ln}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=Mn("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;e0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Re)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ue:e.x=e.x-Math.floor(e.x);break;case Ne:e.x=e.x<0?0:1;break;case Oe:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case Ue:e.y=e.y-Math.floor(e.y);break;case Ne:e.y=e.y<0?0:1;break;case Oe:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return bn("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Wt?Gt:Ht}set encoding(e){bn("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Gt?Wt:Vt}}Fn.DEFAULT_IMAGE=null,Fn.DEFAULT_MAPPING=Re,Fn.DEFAULT_ANISOTROPY=1;class zn{constructor(e=0,t=0,n=0,i=1){zn.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=this.w,s=e.elements;return this.x=s[0]*t+s[4]*n+s[8]*i+s[12]*r,this.y=s[1]*t+s[5]*n+s[9]*i+s[13]*r,this.z=s[2]*t+s[6]*n+s[10]*i+s[14]*r,this.w=s[3]*t+s[7]*n+s[11]*i+s[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,r;const s=.01,a=.1,o=e.elements,l=o[0],c=o[4],h=o[8],u=o[1],d=o[5],p=o[9],m=o[2],f=o[6],g=o[10];if(Math.abs(c-u)o&&e>v?ev?o=0?1:-1,i=1-t*t;if(i>Number.EPSILON){const r=Math.sqrt(i),s=Math.atan2(r,t*n);e=Math.sin(e*s)/r,a=Math.sin(a*s)/r}const r=a*n;if(o=o*e+u*r,l=l*e+d*r,c=c*e+p*r,h=h*e+m*r,e===1-a){const e=1/Math.sqrt(o*o+l*l+c*c+h*h);o*=e,l*=e,c*=e,h*=e}}e[t]=o,e[t+1]=l,e[t+2]=c,e[t+3]=h}static multiplyQuaternionsFlat(e,t,n,i,r,s){const a=n[i],o=n[i+1],l=n[i+2],c=n[i+3],h=r[s],u=r[s+1],d=r[s+2],p=r[s+3];return e[t]=a*p+c*h+o*d-l*u,e[t+1]=o*p+c*u+l*h-a*d,e[t+2]=l*p+c*d+a*u-o*h,e[t+3]=c*p-a*h-o*u-l*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){const n=e._x,i=e._y,r=e._z,s=e._order,a=Math.cos,o=Math.sin,l=a(n/2),c=a(i/2),h=a(r/2),u=o(n/2),d=o(i/2),p=o(r/2);switch(s){case"XYZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"YXZ":this._x=u*c*h+l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"ZXY":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h-u*d*p;break;case"ZYX":this._x=u*c*h-l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h+u*d*p;break;case"YZX":this._x=u*c*h+l*d*p,this._y=l*d*h+u*c*p,this._z=l*c*p-u*d*h,this._w=l*c*h-u*d*p;break;case"XZY":this._x=u*c*h-l*d*p,this._y=l*d*h-u*c*p,this._z=l*c*p+u*d*h,this._w=l*c*h+u*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],r=t[8],s=t[1],a=t[5],o=t[9],l=t[2],c=t[6],h=t[10],u=n+a+h;if(u>0){const e=.5/Math.sqrt(u+1);this._w=.25/e,this._x=(c-o)*e,this._y=(r-l)*e,this._z=(s-i)*e}else if(n>a&&n>h){const e=2*Math.sqrt(1+n-a-h);this._w=(c-o)/e,this._x=.25*e,this._y=(i+s)/e,this._z=(r+l)/e}else if(a>h){const e=2*Math.sqrt(1+a-n-h);this._w=(r-l)/e,this._x=(i+s)/e,this._y=.25*e,this._z=(o+c)/e}else{const e=2*Math.sqrt(1+h-n-a);this._w=(s-i)/e,this._x=(r+l)/e,this._y=(o+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(an(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const i=Math.min(1,t/n);return this.slerp(e,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(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._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 e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,r=e._z,s=e._w,a=t._x,o=t._y,l=t._z,c=t._w;return this._x=n*c+s*a+i*l-r*o,this._y=i*c+s*o+r*a-n*l,this._z=r*c+s*l+n*o-i*a,this._w=s*c-n*a-i*o-r*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,i=this._y,r=this._z,s=this._w;let a=s*e._w+n*e._x+i*e._y+r*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=s,this._x=n,this._y=i,this._z=r,this;const o=1-a*a;if(o<=Number.EPSILON){const e=1-t;return this._w=e*s+t*this._w,this._x=e*n+t*this._x,this._y=e*i+t*this._y,this._z=e*r+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(o),c=Math.atan2(l,a),h=Math.sin((1-t)*c)/l,u=Math.sin(t*c)/l;return this._w=s*h+this._w*u,this._x=n*h+this._x*u,this._y=i*h+this._y*u,this._z=r*h+this._z*u,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),r=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(r),n*Math.cos(r),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Vn{constructor(e=0,t=0,n=0){Vn.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(jn.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(jn.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*i,this.y=r[1]*t+r[4]*n+r[7]*i,this.z=r[2]*t+r[5]*n+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,r=e.elements,s=1/(r[3]*t+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*i+r[12])*s,this.y=(r[1]*t+r[5]*n+r[9]*i+r[13])*s,this.z=(r[2]*t+r[6]*n+r[10]*i+r[14])*s,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,r=e.x,s=e.y,a=e.z,o=e.w,l=o*t+s*i-a*n,c=o*n+a*t-r*i,h=o*i+r*n-s*t,u=-r*t-s*n-a*i;return this.x=l*o+u*-r+c*-a-h*-s,this.y=c*o+u*-s+h*-r-l*-a,this.z=h*o+u*-a+l*-s-c*-r,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i,this.y=r[1]*t+r[5]*n+r[9]*i,this.z=r[2]*t+r[6]*n+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,r=e.z,s=t.x,a=t.y,o=t.z;return this.x=i*o-r*a,this.y=r*s-n*o,this.z=n*a-i*s,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Wn.copy(this).projectOnVector(e),this.sub(Wn)}reflect(e){return this.sub(Wn.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(an(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Wn=new Vn,jn=new Gn;class Xn{constructor(e=new Vn(Infinity,Infinity,Infinity),t=new Vn(-Infinity,-Infinity,-Infinity)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Yn),Yn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ni),ii.subVectors(this.max,ni),Kn.subVectors(e.a,ni),Jn.subVectors(e.b,ni),Qn.subVectors(e.c,ni),$n.subVectors(Jn,Kn),ei.subVectors(Qn,Jn),ti.subVectors(Kn,Qn);let t=[0,-$n.z,$n.y,0,-ei.z,ei.y,0,-ti.z,ti.y,$n.z,0,-$n.x,ei.z,0,-ei.x,ti.z,0,-ti.x,-$n.y,$n.x,0,-ei.y,ei.x,0,-ti.y,ti.x,0];return!!ai(t,Kn,Jn,Qn,ii)&&(t=[1,0,0,0,1,0,0,0,1],!!ai(t,Kn,Jn,Qn,ii)&&(ri.crossVectors($n,ei),t=[ri.x,ri.y,ri.z],ai(t,Kn,Jn,Qn,ii)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Yn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(Yn).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(qn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),qn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),qn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),qn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),qn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),qn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),qn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),qn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(qn)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const qn=[new Vn,new Vn,new Vn,new Vn,new Vn,new Vn,new Vn,new Vn],Yn=new Vn,Zn=new Xn,Kn=new Vn,Jn=new Vn,Qn=new Vn,$n=new Vn,ei=new Vn,ti=new Vn,ni=new Vn,ii=new Vn,ri=new Vn,si=new Vn;function ai(e,t,n,i,r){for(let s=0,a=e.length-3;s<=a;s+=3){si.fromArray(e,s);const a=r.x*Math.abs(si.x)+r.y*Math.abs(si.y)+r.z*Math.abs(si.z),o=t.dot(si),l=n.dot(si),c=i.dot(si);if(Math.max(-Math.max(o,l,c),Math.min(o,l,c))>a)return!1}return!0}const oi=new Xn,li=new Vn,ci=new Vn;class hi{constructor(e=new Vn,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):oi.setFromPoints(e).getCenter(n);let i=0;for(let t=0,r=e.length;tthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;li.subVectors(e,this.center);const t=li.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(li,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(ci.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(li.copy(e.center).add(ci)),this.expandByPoint(li.copy(e.center).sub(ci))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const ui=new Vn,di=new Vn,pi=new Vn,mi=new Vn,fi=new Vn,gi=new Vn,vi=new Vn;class _i{constructor(e=new Vn,t=new Vn(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,ui)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=ui.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(ui.copy(this.origin).addScaledVector(this.direction,t),ui.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){di.copy(e).add(t).multiplyScalar(.5),pi.copy(t).sub(e).normalize(),mi.copy(this.origin).sub(di);const r=.5*e.distanceTo(t),s=-this.direction.dot(pi),a=mi.dot(this.direction),o=-mi.dot(pi),l=mi.lengthSq(),c=Math.abs(1-s*s);let h,u,d,p;if(c>0)if(h=s*o-a,u=s*a-o,p=r*c,h>=0)if(u>=-p)if(u<=p){const e=1/c;h*=e,u*=e,d=h*(h+s*u+2*a)+u*(s*h+u+2*o)+l}else u=r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u=-r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;else u<=-p?(h=Math.max(0,-(-s*r+a)),u=h>0?-r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l):u<=p?(h=0,u=Math.min(Math.max(-r,-o),r),d=u*(u+2*o)+l):(h=Math.max(0,-(s*r+a)),u=h>0?r:Math.min(Math.max(-r,-o),r),d=-h*h+u*(u+2*o)+l);else u=s>0?-r:r,h=Math.max(0,-(s*u+a)),d=-h*h+u*(u+2*o)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(di).addScaledVector(pi,u),d}intersectSphere(e,t){ui.subVectors(e.center,this.origin);const n=ui.dot(this.direction),i=ui.dot(ui)-n*n,r=e.radius*e.radius;if(i>r)return null;const s=Math.sqrt(r-i),a=n-s,o=n+s;return o<0?null:a<0?this.at(o,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,r,s,a,o;const l=1/this.direction.x,c=1/this.direction.y,h=1/this.direction.z,u=this.origin;return l>=0?(n=(e.min.x-u.x)*l,i=(e.max.x-u.x)*l):(n=(e.max.x-u.x)*l,i=(e.min.x-u.x)*l),c>=0?(r=(e.min.y-u.y)*c,s=(e.max.y-u.y)*c):(r=(e.max.y-u.y)*c,s=(e.min.y-u.y)*c),n>s||r>i?null:((r>n||isNaN(n))&&(n=r),(s=0?(a=(e.min.z-u.z)*h,o=(e.max.z-u.z)*h):(a=(e.max.z-u.z)*h,o=(e.min.z-u.z)*h),n>o||a>i?null:((a>n||n!=n)&&(n=a),(o=0?n:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,ui)}intersectTriangle(e,t,n,i,r){fi.subVectors(t,e),gi.subVectors(n,e),vi.crossVectors(fi,gi);let s,a=this.direction.dot(vi);if(a>0){if(i)return null;s=1}else{if(!(a<0))return null;s=-1,a=-a}mi.subVectors(this.origin,e);const o=s*this.direction.dot(gi.crossVectors(mi,gi));if(o<0)return null;const l=s*this.direction.dot(fi.cross(mi));if(l<0)return null;if(o+l>a)return null;const c=-s*mi.dot(vi);return c<0?null:this.at(c/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class xi{constructor(e,t,n,i,r,s,a,o,l,c,h,u,d,p,m,f){xi.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,n,i,r,s,a,o,l,c,h,u,d,p,m,f)}set(e,t,n,i,r,s,a,o,l,c,h,u,d,p,m,f){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=r,g[5]=s,g[9]=a,g[13]=o,g[2]=l,g[6]=c,g[10]=h,g[14]=u,g[3]=d,g[7]=p,g[11]=m,g[15]=f,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 xi).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/yi.setFromMatrixColumn(e,0).length(),r=1/yi.setFromMatrixColumn(e,1).length(),s=1/yi.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*s,t[9]=n[9]*s,t[10]=n[10]*s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,i=e.y,r=e.z,s=Math.cos(n),a=Math.sin(n),o=Math.cos(i),l=Math.sin(i),c=Math.cos(r),h=Math.sin(r);if("XYZ"===e.order){const e=s*c,n=s*h,i=a*c,r=a*h;t[0]=o*c,t[4]=-o*h,t[8]=l,t[1]=n+i*l,t[5]=e-r*l,t[9]=-a*o,t[2]=r-e*l,t[6]=i+n*l,t[10]=s*o}else if("YXZ"===e.order){const e=o*c,n=o*h,i=l*c,r=l*h;t[0]=e+r*a,t[4]=i*a-n,t[8]=s*l,t[1]=s*h,t[5]=s*c,t[9]=-a,t[2]=n*a-i,t[6]=r+e*a,t[10]=s*o}else if("ZXY"===e.order){const e=o*c,n=o*h,i=l*c,r=l*h;t[0]=e-r*a,t[4]=-s*h,t[8]=i+n*a,t[1]=n+i*a,t[5]=s*c,t[9]=r-e*a,t[2]=-s*l,t[6]=a,t[10]=s*o}else if("ZYX"===e.order){const e=s*c,n=s*h,i=a*c,r=a*h;t[0]=o*c,t[4]=i*l-n,t[8]=e*l+r,t[1]=o*h,t[5]=r*l+e,t[9]=n*l-i,t[2]=-l,t[6]=a*o,t[10]=s*o}else if("YZX"===e.order){const e=s*o,n=s*l,i=a*o,r=a*l;t[0]=o*c,t[4]=r-e*h,t[8]=i*h+n,t[1]=h,t[5]=s*c,t[9]=-a*c,t[2]=-l*c,t[6]=n*h+i,t[10]=e-r*h}else if("XZY"===e.order){const e=s*o,n=s*l,i=a*o,r=a*l;t[0]=o*c,t[4]=-h,t[8]=l*c,t[1]=e*h+r,t[5]=s*c,t[9]=n*h-i,t[2]=i*h-n,t[6]=a*c,t[10]=r*h+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Si,e,bi)}lookAt(e,t,n){const i=this.elements;return Ei.subVectors(e,t),0===Ei.lengthSq()&&(Ei.z=1),Ei.normalize(),Ti.crossVectors(n,Ei),0===Ti.lengthSq()&&(1===Math.abs(n.z)?Ei.x+=1e-4:Ei.z+=1e-4,Ei.normalize(),Ti.crossVectors(n,Ei)),Ti.normalize(),wi.crossVectors(Ei,Ti),i[0]=Ti.x,i[4]=wi.x,i[8]=Ei.x,i[1]=Ti.y,i[5]=wi.y,i[9]=Ei.y,i[2]=Ti.z,i[6]=wi.z,i[10]=Ei.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,r=this.elements,s=n[0],a=n[4],o=n[8],l=n[12],c=n[1],h=n[5],u=n[9],d=n[13],p=n[2],m=n[6],f=n[10],g=n[14],v=n[3],_=n[7],x=n[11],y=n[15],M=i[0],S=i[4],b=i[8],T=i[12],w=i[1],E=i[5],A=i[9],R=i[13],C=i[2],P=i[6],L=i[10],I=i[14],D=i[3],U=i[7],N=i[11],O=i[15];return r[0]=s*M+a*w+o*C+l*D,r[4]=s*S+a*E+o*P+l*U,r[8]=s*b+a*A+o*L+l*N,r[12]=s*T+a*R+o*I+l*O,r[1]=c*M+h*w+u*C+d*D,r[5]=c*S+h*E+u*P+d*U,r[9]=c*b+h*A+u*L+d*N,r[13]=c*T+h*R+u*I+d*O,r[2]=p*M+m*w+f*C+g*D,r[6]=p*S+m*E+f*P+g*U,r[10]=p*b+m*A+f*L+g*N,r[14]=p*T+m*R+f*I+g*O,r[3]=v*M+_*w+x*C+y*D,r[7]=v*S+_*E+x*P+y*U,r[11]=v*b+_*A+x*L+y*N,r[15]=v*T+_*R+x*I+y*O,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],r=e[12],s=e[1],a=e[5],o=e[9],l=e[13],c=e[2],h=e[6],u=e[10],d=e[14];return e[3]*(+r*o*h-i*l*h-r*a*u+n*l*u+i*a*d-n*o*d)+e[7]*(+t*o*d-t*l*u+r*s*u-i*s*d+i*l*c-r*o*c)+e[11]*(+t*l*h-t*a*d-r*s*h+n*s*d+r*a*c-n*l*c)+e[15]*(-i*a*c-t*o*h+t*a*u+i*s*h-n*s*u+n*o*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],r=e[3],s=e[4],a=e[5],o=e[6],l=e[7],c=e[8],h=e[9],u=e[10],d=e[11],p=e[12],m=e[13],f=e[14],g=e[15],v=h*f*l-m*u*l+m*o*d-a*f*d-h*o*g+a*u*g,_=p*u*l-c*f*l-p*o*d+s*f*d+c*o*g-s*u*g,x=c*m*l-p*h*l+p*a*d-s*m*d-c*a*g+s*h*g,y=p*h*o-c*m*o-p*a*u+s*m*u+c*a*f-s*h*f,M=t*v+n*_+i*x+r*y;if(0===M)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const S=1/M;return e[0]=v*S,e[1]=(m*u*r-h*f*r-m*i*d+n*f*d+h*i*g-n*u*g)*S,e[2]=(a*f*r-m*o*r+m*i*l-n*f*l-a*i*g+n*o*g)*S,e[3]=(h*o*r-a*u*r-h*i*l+n*u*l+a*i*d-n*o*d)*S,e[4]=_*S,e[5]=(c*f*r-p*u*r+p*i*d-t*f*d-c*i*g+t*u*g)*S,e[6]=(p*o*r-s*f*r-p*i*l+t*f*l+s*i*g-t*o*g)*S,e[7]=(s*u*r-c*o*r+c*i*l-t*u*l-s*i*d+t*o*d)*S,e[8]=x*S,e[9]=(p*h*r-c*m*r-p*n*d+t*m*d+c*n*g-t*h*g)*S,e[10]=(s*m*r-p*a*r+p*n*l-t*m*l-s*n*g+t*a*g)*S,e[11]=(c*a*r-s*h*r-c*n*l+t*h*l+s*n*d-t*a*d)*S,e[12]=y*S,e[13]=(c*m*i-p*h*i+p*n*u-t*m*u-c*n*f+t*h*f)*S,e[14]=(p*a*i-s*m*i-p*n*o+t*m*o+s*n*f-t*a*f)*S,e[15]=(s*h*i-c*a*i+c*n*o-t*h*o-s*n*u+t*a*u)*S,this}scale(e){const t=this.elements,n=e.x,i=e.y,r=e.z;return t[0]*=n,t[4]*=i,t[8]*=r,t[1]*=n,t[5]*=i,t[9]*=r,t[2]*=n,t[6]*=i,t[10]*=r,t[3]*=n,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),r=1-n,s=e.x,a=e.y,o=e.z,l=r*s,c=r*a;return this.set(l*s+n,l*a-i*o,l*o+i*a,0,l*a+i*o,c*a+n,c*o-i*s,0,l*o-i*a,c*o+i*s,r*o*o+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,r,s){return this.set(1,n,r,0,e,1,s,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,r=t._x,s=t._y,a=t._z,o=t._w,l=r+r,c=s+s,h=a+a,u=r*l,d=r*c,p=r*h,m=s*c,f=s*h,g=a*h,v=o*l,_=o*c,x=o*h,y=n.x,M=n.y,S=n.z;return i[0]=(1-(m+g))*y,i[1]=(d+x)*y,i[2]=(p-_)*y,i[3]=0,i[4]=(d-x)*M,i[5]=(1-(u+g))*M,i[6]=(f+v)*M,i[7]=0,i[8]=(p+_)*S,i[9]=(f-v)*S,i[10]=(1-(u+m))*S,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let r=yi.set(i[0],i[1],i[2]).length();const s=yi.set(i[4],i[5],i[6]).length(),a=yi.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],Mi.copy(this);const o=1/r,l=1/s,c=1/a;return Mi.elements[0]*=o,Mi.elements[1]*=o,Mi.elements[2]*=o,Mi.elements[4]*=l,Mi.elements[5]*=l,Mi.elements[6]*=l,Mi.elements[8]*=c,Mi.elements[9]*=c,Mi.elements[10]*=c,t.setFromRotationMatrix(Mi),n.x=r,n.y=s,n.z=a,this}makePerspective(e,t,n,i,r,s,a=2e3){const o=this.elements,l=2*r/(t-e),c=2*r/(n-i),h=(t+e)/(t-e),u=(n+i)/(n-i);let d,p;if(a===Jt)d=-(s+r)/(s-r),p=-2*s*r/(s-r);else{if(a!==Qt)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);d=-s/(s-r),p=-s*r/(s-r)}return o[0]=l,o[4]=0,o[8]=h,o[12]=0,o[1]=0,o[5]=c,o[9]=u,o[13]=0,o[2]=0,o[6]=0,o[10]=d,o[14]=p,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(e,t,n,i,r,s,a=2e3){const o=this.elements,l=1/(t-e),c=1/(n-i),h=1/(s-r),u=(t+e)*l,d=(n+i)*c;let p,m;if(a===Jt)p=(s+r)*h,m=-2*h;else{if(a!==Qt)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);p=r*h,m=-1*h}return o[0]=2*l,o[4]=0,o[8]=0,o[12]=-u,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-d,o[2]=0,o[6]=0,o[10]=m,o[14]=-p,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const yi=new Vn,Mi=new xi,Si=new Vn(0,0,0),bi=new Vn(1,1,1),Ti=new Vn,wi=new Vn,Ei=new Vn,Ai=new xi,Ri=new Gn;class Ci{constructor(e=0,t=0,n=0,i=Ci.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,r=i[0],s=i[4],a=i[8],o=i[1],l=i[5],c=i[9],h=i[2],u=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin(an(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,d),this._z=Math.atan2(-s,r)):(this._x=Math.atan2(u,l),this._z=0);break;case"YXZ":this._x=Math.asin(-an(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,l)):(this._y=Math.atan2(-h,r),this._z=0);break;case"ZXY":this._x=Math.asin(an(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-h,d),this._z=Math.atan2(-s,l)):(this._y=0,this._z=Math.atan2(o,r));break;case"ZYX":this._y=Math.asin(-an(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(o,r)):(this._x=0,this._z=Math.atan2(-s,l));break;case"YZX":this._z=Math.asin(an(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-h,r)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-an(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(u,l),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-c,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Ai.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ai,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Ri.setFromEuler(this),this.setFromQuaternion(Ri,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ci.DEFAULT_ORDER="XYZ";class Pi{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(n=n.concat(r))}return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oi,e,Fi),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Oi,zi,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const n=t.shapes;if(Array.isArray(n))for(let t=0,i=n.length;t0){i.children=[];for(let t=0;t0){i.animations=[];for(let t=0;t0&&(n.geometries=t),i.length>0&&(n.materials=i),r.length>0&&(n.textures=r),a.length>0&&(n.images=a),o.length>0&&(n.shapes=o),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c),h.length>0&&(n.nodes=h)}return n.object=i,n;function s(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,n,i,r){ji.subVectors(i,t),Xi.subVectors(n,t),qi.subVectors(e,t);const s=ji.dot(ji),a=ji.dot(Xi),o=ji.dot(qi),l=Xi.dot(Xi),c=Xi.dot(qi),h=s*l-a*a;if(0===h)return r.set(-2,-1,-1);const u=1/h,d=(l*o-a*c)*u,p=(s*c-a*o)*u;return r.set(1-d-p,p,d)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,Yi),Yi.x>=0&&Yi.y>=0&&Yi.x+Yi.y<=1}static getUV(e,t,n,i,r,s,a,o){return!1===tr&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),tr=!0),this.getInterpolation(e,t,n,i,r,s,a,o)}static getInterpolation(e,t,n,i,r,s,a,o){return this.getBarycoord(e,t,n,i,Yi),o.setScalar(0),o.addScaledVector(r,Yi.x),o.addScaledVector(s,Yi.y),o.addScaledVector(a,Yi.z),o}static isFrontFacing(e,t,n,i){return ji.subVectors(n,t),Xi.subVectors(e,t),ji.cross(Xi).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return ji.subVectors(this.c,this.b),Xi.subVectors(this.a,this.b),.5*ji.cross(Xi).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return nr.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return nr.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,r){return!1===tr&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),tr=!0),nr.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}getInterpolation(e,t,n,i,r){return nr.getInterpolation(e,this.a,this.b,this.c,t,n,i,r)}containsPoint(e){return nr.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return nr.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,r=this.c;let s,a;Zi.subVectors(i,n),Ki.subVectors(r,n),Qi.subVectors(e,n);const o=Zi.dot(Qi),l=Ki.dot(Qi);if(o<=0&&l<=0)return t.copy(n);$i.subVectors(e,i);const c=Zi.dot($i),h=Ki.dot($i);if(c>=0&&h<=c)return t.copy(i);const u=o*h-c*l;if(u<=0&&o>=0&&c<=0)return s=o/(o-c),t.copy(n).addScaledVector(Zi,s);er.subVectors(e,r);const d=Zi.dot(er),p=Ki.dot(er);if(p>=0&&d<=p)return t.copy(r);const m=d*l-o*p;if(m<=0&&l>=0&&p<=0)return a=l/(l-p),t.copy(n).addScaledVector(Ki,a);const f=c*p-d*h;if(f<=0&&h-c>=0&&d-p>=0)return Ji.subVectors(r,i),a=(h-c)/(h-c+(d-p)),t.copy(i).addScaledVector(Ji,a);const g=1/(f+m+u);return s=m*g,a=u*g,t.copy(n).addScaledVector(Zi,s).addScaledVector(Ki,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let ir=0;class rr extends $t{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:ir++}),this.uuid=sn(),this.name="",this.type="Material",this.blending=1,this.side=pe,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=_e,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=qt,this.stencilZFail=qt,this.stencilZPass=qt,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const n=e[t];if(void 0===n){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(n.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&Infinity!==this.attenuationDistance&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),this.side!==pe&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,void 0!==this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaHash&&(n.alphaHash=this.alphaHash),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.forceSinglePass&&(n.forceSinglePass=this.forceSinglePass),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData),t){const t=i(e.textures),r=i(e.images);t.length>0&&(n.textures=t),r.length>0&&(n.images=r)}return n}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let i=0;i!==e;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}}const sr={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},ar={h:0,s:0,l:0},or={h:0,s:0,l:0};function lr(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}class cr{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(void 0===t&&void 0===n){const t=e;t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Wt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Pn.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=Pn.workingColorSpace){return this.r=e,this.g=t,this.b=n,Pn.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=Pn.workingColorSpace){if(e=on(e,1),t=an(t,0,1),n=an(n,0,1),0===t)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,r=2*n-i;this.r=lr(r,i,e+1/3),this.g=lr(r,i,e),this.b=lr(r,i,e-1/3)}return Pn.toWorkingColorSpace(this,i),this}setStyle(e,t=Wt){function n(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const s=i[1],a=i[2];switch(s){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const n=i[1],r=n.length;if(3===r)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(6===r)return this.setHex(parseInt(n,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Wt){const n=sr[e.toLowerCase()];return void 0!==n?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Tn(e.r),this.g=Tn(e.g),this.b=Tn(e.b),this}copyLinearToSRGB(e){return this.r=wn(e.r),this.g=wn(e.g),this.b=wn(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Wt){return Pn.fromWorkingColorSpace(hr.copy(this),e),65536*Math.round(an(255*hr.r,0,255))+256*Math.round(an(255*hr.g,0,255))+Math.round(an(255*hr.b,0,255))}getHexString(e=Wt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Pn.workingColorSpace){Pn.fromWorkingColorSpace(hr.copy(this),t);const n=hr.r,i=hr.g,r=hr.b,s=Math.max(n,i,r),a=Math.min(n,i,r);let o,l;const c=(a+s)/2;if(a===s)o=0,l=0;else{const e=s-a;switch(l=c<=.5?e/(s+a):e/(2-s-a),s){case n:o=(i-r)/e+(i>-t-14,i[256|e]=1024>>-t-14|32768,r[e]=-t-1,r[256|e]=-t-1):t<=15?(i[e]=t+15<<10,i[256|e]=t+15<<10|32768,r[e]=13,r[256|e]=13):t<128?(i[e]=31744,i[256|e]=64512,r[e]=24,r[256|e]=24):(i[e]=31744,i[256|e]=64512,r[e]=13,r[256|e]=13)}const s=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;0==(8388608&t);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,s[e]=t|n}for(let e=1024;e<2048;++e)s[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)a[e]=e<<23;a[31]=1199570944,a[32]=2147483648;for(let e=33;e<63;++e)a[e]=2147483648+(e-32<<23);a[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(o[e]=1024);return{floatView:t,uint32View:n,baseTable:i,shiftTable:r,mantissaTable:s,exponentTable:a,offsetTable:o}}function mr(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=an(e,-65504,65504),dr.floatView[0]=e;const t=dr.uint32View[0],n=t>>23&511;return dr.baseTable[n]+((8388607&t)>>dr.shiftTable[n])}function fr(e){const t=e>>10;return dr.uint32View[0]=dr.mantissaTable[dr.offsetTable[t]+(1023&e)]+dr.exponentTable[t],dr.floatView[0]}const gr={toHalfFloat:mr,fromHalfFloat:fr},vr=new Vn,_r=new fn;class xr{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=Yt,this.updateRange={offset:0,count:-1},this.gpuType=qe,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,r=this.itemSize;i0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const t in n){const i=n[t];e.data.attributes[t]=i.toJSON(e.data)}const i={};let r=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],s=[];for(let t=0,i=n.length;t0&&(i[t]=s,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const s=this.groups;s.length>0&&(e.data.groups=JSON.parse(JSON.stringify(s)));const a=this.boundingSphere;return null!==a&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const i=e.attributes;for(const e in i){const n=i[e];this.setAttribute(e,n.clone(t))}const r=e.morphAttributes;for(const e in r){const n=[],i=r[e];for(let e=0,r=i.length;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2)return}Lr.copy(r).invert(),Ir.copy(e.ray).applyMatrix4(Lr),null!==n.boundingBox&&!1===Ir.intersectsBox(n.boundingBox)||this._computeIntersections(e,t,Ir)}}_computeIntersections(e,t,n){let i;const r=this.geometry,s=this.material,a=r.index,o=r.attributes.position,l=r.attributes.uv,c=r.attributes.uv1,h=r.attributes.normal,u=r.groups,d=r.drawRange;if(null!==a)if(Array.isArray(s))for(let r=0,o=u.length;rn.far?null:{distance:c,point:qr.clone(),object:e}}(e,t,n,i,Nr,Or,Fr,Xr);if(h){r&&(kr.fromBufferAttribute(r,o),Hr.fromBufferAttribute(r,l),Gr.fromBufferAttribute(r,c),h.uv=nr.getInterpolation(Xr,Nr,Or,Fr,kr,Hr,Gr,new fn)),s&&(kr.fromBufferAttribute(s,o),Hr.fromBufferAttribute(s,l),Gr.fromBufferAttribute(s,c),h.uv1=nr.getInterpolation(Xr,Nr,Or,Fr,kr,Hr,Gr,new fn),h.uv2=h.uv1),a&&(Vr.fromBufferAttribute(a,o),Wr.fromBufferAttribute(a,l),jr.fromBufferAttribute(a,c),h.normal=nr.getInterpolation(Xr,Nr,Or,Fr,Vr,Wr,jr,new Vn),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const e={a:o,b:l,c:c,normal:new Vn,materialIndex:0};nr.getNormal(Nr,Or,Fr,e.normal),h.face=e}return h}class Kr extends Pr{constructor(e=1,t=1,n=1,i=1,r=1,s=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:r,depthSegments:s};const a=this;i=Math.floor(i),r=Math.floor(r),s=Math.floor(s);const o=[],l=[],c=[],h=[];let u=0,d=0;function p(e,t,n,i,r,s,p,m,f,g,v){const _=s/f,x=p/g,y=s/2,M=p/2,S=m/2,b=f+1,T=g+1;let w=0,E=0;const A=new Vn;for(let s=0;s0?1:-1,c.push(A.x,A.y,A.z),h.push(o/f),h.push(1-s/g),w+=1}}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class ns extends Wi{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new xi,this.projectionMatrix=new xi,this.projectionMatrixInverse=new xi,this.coordinateSystem=Jt}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}class is extends ns{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*rn*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*nn*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*rn*Math.atan(Math.tan(.5*nn*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,i,r,s){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*nn*this.fov)/this.zoom,n=2*t,i=this.aspect*n,r=-.5*i;const s=this.view;if(null!==this.view&&this.view.enabled){const e=s.fullWidth,a=s.fullHeight;r+=s.offsetX*i/e,t-=s.offsetY*n/a,i*=s.width/e,n*=s.height/a}const a=this.filmOffset;0!==a&&(r+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const rs=-90;class ss extends Wi{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null;const i=new is(rs,1,e,t);i.layers=this.layers,this.add(i);const r=new is(rs,1,e,t);r.layers=this.layers,this.add(r);const s=new is(rs,1,e,t);s.layers=this.layers,this.add(s);const a=new is(rs,1,e,t);a.layers=this.layers,this.add(a);const o=new is(rs,1,e,t);o.layers=this.layers,this.add(o);const l=new is(rs,1,e,t);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,i,r,s,a,o]=t;for(const e of t)this.remove(e);if(e===Jt)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),s.up.set(0,0,1),s.lookAt(0,-1,0),a.up.set(0,1,0),a.lookAt(0,0,1),o.up.set(0,1,0),o.lookAt(0,0,-1);else{if(e!==Qt)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),s.up.set(0,0,-1),s.lookAt(0,-1,0),a.up.set(0,-1,0),a.lookAt(0,0,1),o.up.set(0,-1,0),o.lookAt(0,0,-1)}for(const e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[i,r,s,a,o,l]=this.children,c=e.getRenderTarget(),h=e.toneMapping,u=e.xr.enabled;e.toneMapping=Se,e.xr.enabled=!1;const d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,r),e.setRenderTarget(n,2),e.render(t,s),e.setRenderTarget(n,3),e.render(t,a),e.setRenderTarget(n,4),e.render(t,o),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(c),e.toneMapping=h,e.xr.enabled=u,n.texture.needsPMREMUpdate=!0}}class as extends Fn{constructor(e,t,n,i,r,s,a,o,l,c){super(e=void 0!==e?e:[],t=void 0!==t?t:Ce,n,i,r,s,a,o,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class os extends Bn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];void 0!==t.encoding&&(bn("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),t.colorSpace=t.encoding===Gt?Wt:Vt),this.texture=new as(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:ke}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},i=new Kr(5,5,5),r=new ts({name:"CubemapFromEquirect",uniforms:Jr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:me,blending:0});r.uniforms.tEquirect.value=t;const s=new Yr(i,r),a=t.minFilter;t.minFilter===Ge&&(t.minFilter=ke);return new ss(1,10,this).update(e,s),t.minFilter=a,s.geometry.dispose(),s.material.dispose(),this}clear(e,t,n,i){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,n,i);e.setRenderTarget(r)}}const ls=new Vn,cs=new Vn,hs=new gn;class us{constructor(e=new Vn(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=ls.subVectors(n,t).cross(cs.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(ls),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const r=-(e.start.dot(this.normal)+this.constant)/i;return r<0||r>1?null:t.copy(e.start).addScaledVector(n,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||hs.getNormalMatrix(e),i=this.coplanarPoint(ls).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const ds=new hi,ps=new Vn;class ms{constructor(e=new us,t=new us,n=new us,i=new us,r=new us,s=new us){this.planes=[e,t,n,i,r,s]}set(e,t,n,i,r,s){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(r),a[5].copy(s),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=2e3){const n=this.planes,i=e.elements,r=i[0],s=i[1],a=i[2],o=i[3],l=i[4],c=i[5],h=i[6],u=i[7],d=i[8],p=i[9],m=i[10],f=i[11],g=i[12],v=i[13],_=i[14],x=i[15];if(n[0].setComponents(o-r,u-l,f-d,x-g).normalize(),n[1].setComponents(o+r,u+l,f+d,x+g).normalize(),n[2].setComponents(o+s,u+c,f+p,x+v).normalize(),n[3].setComponents(o-s,u-c,f-p,x-v).normalize(),n[4].setComponents(o-a,u-h,f-m,x-_).normalize(),t===Jt)n[5].setComponents(o+a,u+h,f+m,x+_).normalize();else{if(t!==Qt)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);n[5].setComponents(a,h,m,_).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),ds.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),ds.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ds)}intersectsSprite(e){return ds.center.set(0,0,0),ds.radius=.7071067811865476,ds.applyMatrix4(e.matrixWorld),this.intersectsSphere(ds)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,ps.y=i.normal.y>0?e.max.y:e.min.y,ps.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ps)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function fs(){let e=null,t=!1,n=null,i=null;function r(t,s){n(t,s),i=e.requestAnimationFrame(r)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(r),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function gs(e,t){const n=t.isWebGL2,i=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),i.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const n=i.get(t);n&&(e.deleteBuffer(n.buffer),i.delete(t))},update:function(t,r){if(t.isGLBufferAttribute){const e=i.get(t);return void((!e||e.version 0\n\tvec4 plane;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#pragma unroll_loop_end\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\n\tvClipPosition = - mvPosition.xyz;\n#endif",color_fragment:"#if defined( USE_COLOR_ALPHA )\n\tdiffuseColor *= vColor;\n#elif defined( USE_COLOR )\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR )\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvarying vec4 vColor;\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvarying vec3 vColor;\n#endif",color_vertex:"#if defined( USE_COLOR_ALPHA )\n\tvColor = vec4( 1.0 );\n#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )\n\tvColor = vec3( 1.0 );\n#endif\n#ifdef USE_COLOR\n\tvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n\tvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat luminance( const in vec3 rgb ) {\n\tconst vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );\n\treturn dot( weights, rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n\t#define cubeUV_minMipLevel 4.0\n\t#define cubeUV_minTileSize 16.0\n\tfloat getFace( vec3 direction ) {\n\t\tvec3 absDirection = abs( direction );\n\t\tfloat face = - 1.0;\n\t\tif ( absDirection.x > absDirection.z ) {\n\t\t\tif ( absDirection.x > absDirection.y )\n\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t} else {\n\t\t\tif ( absDirection.z > absDirection.y )\n\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\telse\n\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t}\n\t\treturn face;\n\t}\n\tvec2 getUV( vec3 direction, float face ) {\n\t\tvec2 uv;\n\t\tif ( face == 0.0 ) {\n\t\t\tuv = vec2( direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 1.0 ) {\n\t\t\tuv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n\t\t} else if ( face == 2.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.y ) / abs( direction.z );\n\t\t} else if ( face == 3.0 ) {\n\t\t\tuv = vec2( - direction.z, direction.y ) / abs( direction.x );\n\t\t} else if ( face == 4.0 ) {\n\t\t\tuv = vec2( - direction.x, direction.z ) / abs( direction.y );\n\t\t} else {\n\t\t\tuv = vec2( direction.x, direction.y ) / abs( direction.z );\n\t\t}\n\t\treturn 0.5 * ( uv + 1.0 );\n\t}\n\tvec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n\t\tfloat face = getFace( direction );\n\t\tfloat filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n\t\tmipInt = max( mipInt, cubeUV_minMipLevel );\n\t\tfloat faceSize = exp2( mipInt );\n\t\thighp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n\t\tif ( face > 2.0 ) {\n\t\t\tuv.y += faceSize;\n\t\t\tface -= 3.0;\n\t\t}\n\t\tuv.x += face * faceSize;\n\t\tuv.x += filterInt * 3.0 * cubeUV_minTileSize;\n\t\tuv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n\t\tuv.x *= CUBEUV_TEXEL_WIDTH;\n\t\tuv.y *= CUBEUV_TEXEL_HEIGHT;\n\t\t#ifdef texture2DGradEXT\n\t\t\treturn texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n\t\t#else\n\t\t\treturn texture2D( envMap, uv ).rgb;\n\t\t#endif\n\t}\n\t#define cubeUV_r0 1.0\n\t#define cubeUV_v0 0.339\n\t#define cubeUV_m0 - 2.0\n\t#define cubeUV_r1 0.8\n\t#define cubeUV_v1 0.276\n\t#define cubeUV_m1 - 1.0\n\t#define cubeUV_r4 0.4\n\t#define cubeUV_v4 0.046\n\t#define cubeUV_m4 2.0\n\t#define cubeUV_r5 0.305\n\t#define cubeUV_v5 0.016\n\t#define cubeUV_m5 3.0\n\t#define cubeUV_r6 0.21\n\t#define cubeUV_v6 0.0038\n\t#define cubeUV_m6 4.0\n\tfloat roughnessToMip( float roughness ) {\n\t\tfloat mip = 0.0;\n\t\tif ( roughness >= cubeUV_r1 ) {\n\t\t\tmip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n\t\t} else if ( roughness >= cubeUV_r4 ) {\n\t\t\tmip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n\t\t} else if ( roughness >= cubeUV_r5 ) {\n\t\t\tmip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n\t\t} else if ( roughness >= cubeUV_r6 ) {\n\t\t\tmip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n\t\t} else {\n\t\t\tmip = - 2.0 * log2( 1.16 * roughness );\t\t}\n\t\treturn mip;\n\t}\n\tvec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n\t\tfloat mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n\t\tfloat mipF = fract( mip );\n\t\tfloat mipInt = floor( mip );\n\t\tvec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n\t\tif ( mipF == 0.0 ) {\n\t\t\treturn vec4( color0, 1.0 );\n\t\t} else {\n\t\t\tvec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n\t\t\treturn vec4( mix( color0, color1, mipF ), 1.0 );\n\t\t}\n\t}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\tmat3 m = mat3( instanceMatrix );\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\ttransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",colorspace_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",colorspace_pars_fragment:"vec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn 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 );\n}",envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToFrag;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#ifdef USE_ENVMAP\n\tvec3 getIBLIrradiance( const in vec3 normal ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\t\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\tvec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\tvec3 reflectVec = reflect( - viewDir, normal );\n\t\t\treflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\t\t\treturn envMapColor.rgb * envMapIntensity;\n\t\t#else\n\t\t\treturn vec3( 0.0 );\n\t\t#endif\n\t}\n\t#ifdef USE_ANISOTROPY\n\t\tvec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n\t\t\t#ifdef ENVMAP_TYPE_CUBE_UV\n\t\t\t\tvec3 bentNormal = cross( bitangent, viewDir );\n\t\t\t\tbentNormal = normalize( cross( bentNormal, bitangent ) );\n\t\t\t\tbentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n\t\t\t\treturn getIBLRadiance( viewDir, bentNormal, roughness );\n\t\t\t#else\n\t\t\t\treturn vec3( 0.0 );\n\t\t\t#endif\n\t\t}\n\t#endif\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex;\n\t\tif ( isOrthographic ) {\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\t\t} else {\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\t}\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tvFogDepth = - mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float vFogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\n\tuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t#ifdef USE_GRADIENTMAP\n\t\treturn vec3( texture2D( gradientMap, coord ).r );\n\t#else\n\t\tvec2 fw = fwidth( coord ) * 0.5;\n\t\treturn mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n\t#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\treflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\n\tvec3 diffuseColor;\n\tfloat specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Lambert\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Lambert",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\treturn irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t#if defined ( LEGACY_LIGHTS )\n\t\tif ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\t\treturn pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t\t}\n\t\treturn 1.0;\n\t#else\n\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\tif ( cutoffDistance > 0.0 ) {\n\t\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t}\n\t\treturn distanceFalloff;\n\t#endif\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n\treturn smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tlight.color = directionalLight.color;\n\t\tlight.direction = directionalLight.direction;\n\t\tlight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tlight.color = pointLight.color;\n\t\tlight.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tlight.direction = normalize( lVector );\n\t\tfloat angleCos = dot( light.direction, spotLight.direction );\n\t\tfloat spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\tif ( spotAttenuation > 0.0 ) {\n\t\t\tfloat lightDistance = length( lVector );\n\t\t\tlight.color = spotLight.color * spotAttenuation;\n\t\t\tlight.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tlight.visible = ( light.color != vec3( 0.0 ) );\n\t\t} else {\n\t\t\tlight.color = vec3( 0.0 );\n\t\t\tlight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n\t\tfloat dotNL = dot( normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\treturn irradiance;\n\t}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\n\tvec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n\tvec3 diffuseColor;\n\tvec3 specularColor;\n\tfloat specularShininess;\n\tfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n\tmaterial.ior = ior;\n\t#ifdef USE_SPECULAR\n\t\tfloat specularIntensityFactor = specularIntensity;\n\t\tvec3 specularColorFactor = specularColor;\n\t\t#ifdef USE_SPECULAR_COLORMAP\n\t\t\tspecularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n\t\t#endif\n\t\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\t\tspecularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n\t\t#endif\n\t\tmaterial.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n\t#else\n\t\tfloat specularIntensityFactor = 1.0;\n\t\tvec3 specularColorFactor = vec3( 1.0 );\n\t\tmaterial.specularF90 = 1.0;\n\t#endif\n\tmaterial.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\tmaterial.clearcoatF0 = vec3( 0.04 );\n\tmaterial.clearcoatF90 = 1.0;\n\t#ifdef USE_CLEARCOATMAP\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n\t#endif\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n\t#endif\n\tmaterial.clearcoat = saturate( material.clearcoat );\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_IRIDESCENCE\n\tmaterial.iridescence = iridescence;\n\tmaterial.iridescenceIOR = iridescenceIOR;\n\t#ifdef USE_IRIDESCENCEMAP\n\t\tmaterial.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n\t#endif\n\t#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\t\tmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n\t#else\n\t\tmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n\t#endif\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheenColor;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tmaterial.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n\t#endif\n\tmaterial.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tmaterial.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\t#ifdef USE_ANISOTROPYMAP\n\t\tmat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n\t\tvec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n\t\tvec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n\t#else\n\t\tvec2 anisotropyV = anisotropyVector;\n\t#endif\n\tmaterial.anisotropy = length( anisotropyV );\n\tanisotropyV /= material.anisotropy;\n\tmaterial.anisotropy = saturate( material.anisotropy );\n\tmaterial.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n\tmaterial.anisotropyT = tbn[ 0 ] * anisotropyV.x - tbn[ 1 ] * anisotropyV.y;\n\tmaterial.anisotropyB = tbn[ 1 ] * anisotropyV.x + tbn[ 0 ] * anisotropyV.y;\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3 diffuseColor;\n\tfloat roughness;\n\tvec3 specularColor;\n\tfloat specularF90;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat clearcoat;\n\t\tfloat clearcoatRoughness;\n\t\tvec3 clearcoatF0;\n\t\tfloat clearcoatF90;\n\t#endif\n\t#ifdef USE_IRIDESCENCE\n\t\tfloat iridescence;\n\t\tfloat iridescenceIOR;\n\t\tfloat iridescenceThickness;\n\t\tvec3 iridescenceFresnel;\n\t\tvec3 iridescenceF0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tvec3 sheenColor;\n\t\tfloat sheenRoughness;\n\t#endif\n\t#ifdef IOR\n\t\tfloat ior;\n\t#endif\n\t#ifdef USE_TRANSMISSION\n\t\tfloat transmission;\n\t\tfloat transmissionAlpha;\n\t\tfloat thickness;\n\t\tfloat attenuationDistance;\n\t\tvec3 attenuationColor;\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat anisotropy;\n\t\tfloat alphaT;\n\t\tvec3 anisotropyT;\n\t\tvec3 anisotropyB;\n\t#endif\n};\nvec3 clearcoatSpecular = vec3( 0.0 );\nvec3 sheenSpecular = vec3( 0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n\tfloat 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 ) {\n\t\tfloat gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );\n\t\tfloat gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n\t\tfloat v = 0.5 / ( gv + gl );\n\t\treturn saturate(v);\n\t}\n\tfloat D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n\t\tfloat a2 = alphaT * alphaB;\n\t\thighp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n\t\thighp float v2 = dot( v, v );\n\t\tfloat w2 = a2 / v2;\n\t\treturn RECIPROCAL_PI * a2 * pow2 ( w2 );\n\t}\n#endif\n#ifdef USE_CLEARCOAT\n\tvec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n\t\tvec3 f0 = material.clearcoatF0;\n\t\tfloat f90 = material.clearcoatF90;\n\t\tfloat roughness = material.clearcoatRoughness;\n\t\tfloat alpha = pow2( roughness );\n\t\tvec3 halfDir = normalize( lightDir + viewDir );\n\t\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\t\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\t\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\t\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\t\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t\treturn F * ( V * D );\n\t}\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n\tvec3 f0 = material.specularColor;\n\tfloat f90 = material.specularF90;\n\tfloat roughness = material.roughness;\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotVH = saturate( dot( viewDir, halfDir ) );\n\tvec3 F = F_Schlick( f0, f90, dotVH );\n\t#ifdef USE_IRIDESCENCE\n\t\tF = mix( F, material.iridescenceFresnel, material.iridescence );\n\t#endif\n\t#ifdef USE_ANISOTROPY\n\t\tfloat dotTL = dot( material.anisotropyT, lightDir );\n\t\tfloat dotTV = dot( material.anisotropyT, viewDir );\n\t\tfloat dotTH = dot( material.anisotropyT, halfDir );\n\t\tfloat dotBL = dot( material.anisotropyB, lightDir );\n\t\tfloat dotBV = dot( material.anisotropyB, viewDir );\n\t\tfloat dotBH = dot( material.anisotropyB, halfDir );\n\t\tfloat V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n\t\tfloat D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n\t#else\n\t\tfloat V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\t\tfloat D = D_GGX( alpha, dotNH );\n\t#endif\n\treturn F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n\tfloat alpha = pow2( roughness );\n\tfloat invAlpha = 1.0 / alpha;\n\tfloat cos2h = dotNH * dotNH;\n\tfloat sin2h = max( 1.0 - cos2h, 0.0078125 );\n\treturn ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n\treturn saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n\tvec3 halfDir = normalize( lightDir + viewDir );\n\tfloat dotNL = saturate( dot( normal, lightDir ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat D = D_Charlie( sheenRoughness, dotNH );\n\tfloat V = V_Neubelt( dotNV, dotNL );\n\treturn sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat r2 = roughness * roughness;\n\tfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\n\tfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\n\tfloat DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );\n\treturn saturate( DG * RECIPROCAL_PI );\n}\nvec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;\n\treturn fab;\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\treturn specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid 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 ) {\n#else\nvoid 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 ) {\n#endif\n\tvec2 fab = DFGApprox( normal, viewDir, roughness );\n\t#ifdef USE_IRIDESCENCE\n\t\tvec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n\t#else\n\t\tvec3 Fr = specularColor;\n\t#endif\n\tvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n\tfloat Ess = fab.x + fab.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.roughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = dotNLcc * directLight.color;\n\t\tclearcoatSpecular += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );\n\t#endif\n\treflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material );\n\treflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n\t#endif\n\t#ifdef USE_SHEEN\n\t\tsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );\n\t#endif\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\t#ifdef USE_IRIDESCENCE\n\t\tcomputeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );\n\t#else\n\t\tcomputeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );\n\t#endif\n\tvec3 totalScattering = singleScattering + multiScattering;\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );\n\treflectedLight.indirectSpecular += radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n#ifdef USE_CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n\tfloat dotNVi = saturate( dot( normal, geometry.viewDir ) );\n\tif ( material.iridescenceThickness == 0.0 ) {\n\t\tmaterial.iridescence = 0.0;\n\t} else {\n\t\tmaterial.iridescence = saturate( material.iridescence );\n\t}\n\tif ( material.iridescence > 0.0 ) {\n\t\tmaterial.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n\t\tmaterial.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n\t}\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tvec4 spotColor;\n\tvec3 spotLightCoord;\n\tbool inSpotLightMap;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\t\t#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n\t\t#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n\t\t#else\n\t\t#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n\t\t#endif\n\t\t#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n\t\t\tspotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n\t\t\tinSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n\t\t\tspotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n\t\t\tdirectLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n\t\t#endif\n\t\t#undef SPOT_LIGHT_MAP_INDEX\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n\t#pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\tvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getIBLIrradiance( geometry.normal );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\t#ifdef USE_ANISOTROPY\n\t\tradiance += getIBLAnisotropyRadiance( geometry.viewDir, geometry.normal, material.roughness, material.anisotropyB, material.anisotropy );\n\t#else\n\t\tradiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tclearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );\n\t#endif\n#endif",lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",map_fragment:"#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, vMapUv );\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t#if defined( USE_POINTS_UV )\n\t\tvec2 uv = vUv;\n\t#else\n\t\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif",map_particle_pars_fragment:"#if defined( USE_POINTS_UV )\n\tvarying vec2 vUv;\n#else\n\t#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\t\tuniform mat3 uvTransform;\n\t#endif\n#endif\n#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphcolor_vertex:"#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )\n\tvColor *= morphTargetBaseInfluence;\n\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t#if defined( USE_COLOR_ALPHA )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n\t\t#elif defined( USE_COLOR )\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n\t\t#endif\n\t}\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\t\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\t\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\t\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\t#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\tuniform float morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tuniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n\t\tuniform sampler2DArray morphTargetsTexture;\n\t\tuniform ivec2 morphTargetsTextureSize;\n\t\tvec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n\t\t\tint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n\t\t\tint y = texelIndex / morphTargetsTextureSize.x;\n\t\t\tint x = texelIndex - y * morphTargetsTextureSize.x;\n\t\t\tivec3 morphUV = ivec3( x, y, morphTargetIndex );\n\t\t\treturn texelFetch( morphTargetsTexture, morphUV, 0 );\n\t\t}\n\t#else\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\tuniform float morphTargetInfluences[ 8 ];\n\t\t#else\n\t\t\tuniform float morphTargetInfluences[ 4 ];\n\t\t#endif\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed *= morphTargetBaseInfluence;\n\t#ifdef MORPHTARGETS_TEXTURE\n\t\tfor ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n\t\t\tif ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n\t\t}\n\t#else\n\t\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\t\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\t\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\t\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\t\t#ifndef USE_MORPHNORMALS\n\t\t\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\t\t\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\t\t\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\t\t\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\t\t#endif\n\t#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n\tvec3 fdx = dFdx( vViewPosition );\n\tvec3 fdy = dFdy( vViewPosition );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal *= faceDirection;\n\t#endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn = getTangentFrame( - vViewPosition, normal,\n\t\t#if defined( USE_NORMALMAP )\n\t\t\tvNormalMapUv\n\t\t#elif defined( USE_CLEARCOAT_NORMALMAP )\n\t\t\tvClearcoatNormalMapUv\n\t\t#else\n\t\t\tvUv\n\t\t#endif\n\t\t);\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn[0] *= faceDirection;\n\t\ttbn[1] *= faceDirection;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n\t#else\n\t\tmat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n\t#endif\n\t#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )\n\t\ttbn2[0] *= faceDirection;\n\t\ttbn2[1] *= faceDirection;\n\t#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef USE_NORMALMAP_OBJECTSPACE\n\tnormal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * faceDirection;\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n\tvec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\tnormal = normalize( tbn * mapN );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n\tmat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( uv.st );\n\t\tvec2 st1 = dFdy( uv.st );\n\t\tvec3 N = surf_norm;\n\t\tvec3 q1perp = cross( q1, N );\n\t\tvec3 q0perp = cross( N, q0 );\n\t\tvec3 T = q1perp * st0.x + q0perp * st1.x;\n\t\tvec3 B = q1perp * st0.y + q0perp * st1.y;\n\t\tfloat det = max( dot( T, T ), dot( B, B ) );\n\t\tfloat scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n\t\treturn mat3( T * scale, B * scale, N );\n\t}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\tclearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\n\tuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform sampler2D clearcoatRoughnessMap;\n#endif",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\n\tuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform sampler2D iridescenceThicknessMap;\n#endif",opaque_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec2 packDepthToRG( in highp float v ) {\n\treturn packDepthToRGBA( v ).yx;\n}\nfloat unpackRGToDepth( const in highp vec2 v ) {\n\treturn unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );\n}\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn depth * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * depth - far );\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n\tuniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n\t\tbool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",shadowmap_pars_vertex:"#if NUM_SPOT_LIGHT_COORDS > 0\n\tuniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n\tvarying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",shadowmap_vertex:"#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\tvec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\t\t}\n\t\t#pragma unroll_loop_end\n\t#endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n\t\tshadowWorldPosition = worldPosition;\n\t\t#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\t\tshadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n\t\t#endif\n\t\tvSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n\t}\n\t#pragma unroll_loop_end\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLight;\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#pragma unroll_loop_end\n\t#endif\n\t#endif\n\treturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\tuniform highp sampler2D boneTexture;\n\tuniform int boneTextureSize;\n\tmat4 getBoneMatrix( const in float i ) {\n\t\tfloat j = i * 4.0;\n\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\ty = dy * ( y + 0.5 );\n\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\treturn bone;\n\t}\n#endif",skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ),\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ),\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\tcolor *= toneMappingExposure / 0.6;\n\tcolor = ACESInputMat * color;\n\tcolor = RRTAndODTFit( color );\n\tcolor = ACESOutputMat * color;\n\treturn saturate( color );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }",transmission_fragment:"#ifdef USE_TRANSMISSION\n\tmaterial.transmission = transmission;\n\tmaterial.transmissionAlpha = 1.0;\n\tmaterial.thickness = thickness;\n\tmaterial.attenuationDistance = attenuationDistance;\n\tmaterial.attenuationColor = attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tmaterial.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tmaterial.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n\t#endif\n\tvec3 pos = vWorldPosition;\n\tvec3 v = normalize( cameraPosition - pos );\n\tvec3 n = inverseTransformDirection( normal, viewMatrix );\n\tvec4 transmitted = getIBLVolumeRefraction(\n\t\tn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\n\t\tpos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\n\t\tmaterial.attenuationColor, material.attenuationDistance );\n\tmaterial.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n\ttotalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\n\tuniform float transmission;\n\tuniform float thickness;\n\tuniform float attenuationDistance;\n\tuniform vec3 attenuationColor;\n\t#ifdef USE_TRANSMISSIONMAP\n\t\tuniform sampler2D transmissionMap;\n\t#endif\n\t#ifdef USE_THICKNESSMAP\n\t\tuniform sampler2D thicknessMap;\n\t#endif\n\tuniform vec2 transmissionSamplerSize;\n\tuniform sampler2D transmissionSamplerMap;\n\tuniform mat4 modelMatrix;\n\tuniform mat4 projectionMatrix;\n\tvarying vec3 vWorldPosition;\n\tfloat w0( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n\t}\n\tfloat w1( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n\t}\n\tfloat w2( float a ){\n\t\treturn ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n\t}\n\tfloat w3( float a ) {\n\t\treturn ( 1.0 / 6.0 ) * ( a * a * a );\n\t}\n\tfloat g0( float a ) {\n\t\treturn w0( a ) + w1( a );\n\t}\n\tfloat g1( float a ) {\n\t\treturn w2( a ) + w3( a );\n\t}\n\tfloat h0( float a ) {\n\t\treturn - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n\t}\n\tfloat h1( float a ) {\n\t\treturn 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n\t}\n\tvec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n\t\tuv = uv * texelSize.zw + 0.5;\n\t\tvec2 iuv = floor( uv );\n\t\tvec2 fuv = fract( uv );\n\t\tfloat g0x = g0( fuv.x );\n\t\tfloat g1x = g1( fuv.x );\n\t\tfloat h0x = h0( fuv.x );\n\t\tfloat h1x = h1( fuv.x );\n\t\tfloat h0y = h0( fuv.y );\n\t\tfloat h1y = h1( fuv.y );\n\t\tvec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\tvec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n\t\treturn g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n\t\t\tg1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n\t}\n\tvec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n\t\tvec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n\t\tvec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n\t\tvec2 fLodSizeInv = 1.0 / fLodSize;\n\t\tvec2 cLodSizeInv = 1.0 / cLodSize;\n\t\tvec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n\t\tvec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n\t\treturn mix( fSample, cSample, fract( lod ) );\n\t}\n\tvec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n\t\tvec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n\t\tvec3 modelScale;\n\t\tmodelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n\t\tmodelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n\t\tmodelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n\t\treturn normalize( refractionVector ) * thickness * modelScale;\n\t}\n\tfloat applyIorToRoughness( const in float roughness, const in float ior ) {\n\t\treturn roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n\t}\n\tvec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n\t\tfloat lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n\t\treturn textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n\t}\n\tvec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tif ( isinf( attenuationDistance ) ) {\n\t\t\treturn vec3( 1.0 );\n\t\t} else {\n\t\t\tvec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n\t\t\tvec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );\t\t\treturn transmittance;\n\t\t}\n\t}\n\tvec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n\t\tconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n\t\tconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\n\t\tconst in vec3 attenuationColor, const in float attenuationDistance ) {\n\t\tvec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n\t\tvec3 refractedRayExit = position + transmissionRay;\n\t\tvec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n\t\tvec2 refractionCoords = ndcPos.xy / ndcPos.w;\n\t\trefractionCoords += 1.0;\n\t\trefractionCoords /= 2.0;\n\t\tvec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n\t\tvec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n\t\tvec3 attenuatedColor = transmittance * transmittedLight.rgb;\n\t\tvec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n\t\tfloat transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n\t\treturn vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n\t}\n#endif",uv_pars_fragment:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_pars_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvarying vec2 vUv;\n#endif\n#ifdef USE_MAP\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n#endif",uv_vertex:"#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\tvUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n\tvMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n\tvAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n\tvLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n\tvAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n\tvBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n\tvNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\tvDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n\tvEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n\tvMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n\tvRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n\tvAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n\tvClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\tvClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\tvClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\tvIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\tvIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\tvSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\tvSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n\tvSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\tvSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\tvSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\tvTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n\tvThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif",worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",background_frag:"uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\n\tuniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n\tuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\tvec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );\n\t#else\n\t\tvec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t#endif\n\ttexColor.rgb *= backgroundIntensity;\n\tgl_FragColor = texColor;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = texColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\t#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \n\t#include \n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV = equirectUv( direction );\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\tvec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n\t\treflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t#else\n\t\tvec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshnormal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n\tvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\t#ifdef OPAQUE\n\t\tgl_FragColor.a = 1.0;\n\t#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n#ifdef USE_TRANSMISSION\n\tvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define IOR\n\t#define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n\tuniform float ior;\n#endif\n#ifdef USE_SPECULAR\n\tuniform float specularIntensity;\n\tuniform vec3 specularColor;\n\t#ifdef USE_SPECULAR_COLORMAP\n\t\tuniform sampler2D specularColorMap;\n\t#endif\n\t#ifdef USE_SPECULAR_INTENSITYMAP\n\t\tuniform sampler2D specularIntensityMap;\n\t#endif\n#endif\n#ifdef USE_CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_IRIDESCENCE\n\tuniform float iridescence;\n\tuniform float iridescenceIOR;\n\tuniform float iridescenceThicknessMinimum;\n\tuniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheenColor;\n\tuniform float sheenRoughness;\n\t#ifdef USE_SHEEN_COLORMAP\n\t\tuniform sampler2D sheenColorMap;\n\t#endif\n\t#ifdef USE_SHEEN_ROUGHNESSMAP\n\t\tuniform sampler2D sheenRoughnessMap;\n\t#endif\n#endif\n#ifdef USE_ANISOTROPY\n\tuniform vec2 anisotropyVector;\n\t#ifdef USE_ANISOTROPYMAP\n\t\tuniform sampler2D anisotropyMap;\n\t#endif\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \n\tvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n\t#ifdef USE_SHEEN\n\t\tfloat sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );\n\t\toutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n\t#endif\n\t#ifdef USE_CLEARCOAT\n\t\tfloat dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\tvec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n\t\toutgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_POINTS_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif\nvoid main() {\n\t#ifdef USE_POINTS_UV\n\t\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}"},xs={common:{diffuse:{value:new cr(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new gn},alphaMap:{value:null},alphaMapTransform:{value:new gn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new gn}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new gn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new gn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new gn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new gn},normalScale:{value:new fn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new gn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new gn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new gn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new gn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new cr(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{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 cr(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new gn},alphaTest:{value:0},uvTransform:{value:new gn}},sprite:{diffuse:{value:new cr(16777215)},opacity:{value:1},center:{value:new fn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new gn},alphaMap:{value:null},alphaMapTransform:{value:new gn},alphaTest:{value:0}}},ys={basic:{uniforms:Qr([xs.common,xs.specularmap,xs.envmap,xs.aomap,xs.lightmap,xs.fog]),vertexShader:_s.meshbasic_vert,fragmentShader:_s.meshbasic_frag},lambert:{uniforms:Qr([xs.common,xs.specularmap,xs.envmap,xs.aomap,xs.lightmap,xs.emissivemap,xs.bumpmap,xs.normalmap,xs.displacementmap,xs.fog,xs.lights,{emissive:{value:new cr(0)}}]),vertexShader:_s.meshlambert_vert,fragmentShader:_s.meshlambert_frag},phong:{uniforms:Qr([xs.common,xs.specularmap,xs.envmap,xs.aomap,xs.lightmap,xs.emissivemap,xs.bumpmap,xs.normalmap,xs.displacementmap,xs.fog,xs.lights,{emissive:{value:new cr(0)},specular:{value:new cr(1118481)},shininess:{value:30}}]),vertexShader:_s.meshphong_vert,fragmentShader:_s.meshphong_frag},standard:{uniforms:Qr([xs.common,xs.envmap,xs.aomap,xs.lightmap,xs.emissivemap,xs.bumpmap,xs.normalmap,xs.displacementmap,xs.roughnessmap,xs.metalnessmap,xs.fog,xs.lights,{emissive:{value:new cr(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:_s.meshphysical_vert,fragmentShader:_s.meshphysical_frag},toon:{uniforms:Qr([xs.common,xs.aomap,xs.lightmap,xs.emissivemap,xs.bumpmap,xs.normalmap,xs.displacementmap,xs.gradientmap,xs.fog,xs.lights,{emissive:{value:new cr(0)}}]),vertexShader:_s.meshtoon_vert,fragmentShader:_s.meshtoon_frag},matcap:{uniforms:Qr([xs.common,xs.bumpmap,xs.normalmap,xs.displacementmap,xs.fog,{matcap:{value:null}}]),vertexShader:_s.meshmatcap_vert,fragmentShader:_s.meshmatcap_frag},points:{uniforms:Qr([xs.points,xs.fog]),vertexShader:_s.points_vert,fragmentShader:_s.points_frag},dashed:{uniforms:Qr([xs.common,xs.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:_s.linedashed_vert,fragmentShader:_s.linedashed_frag},depth:{uniforms:Qr([xs.common,xs.displacementmap]),vertexShader:_s.depth_vert,fragmentShader:_s.depth_frag},normal:{uniforms:Qr([xs.common,xs.bumpmap,xs.normalmap,xs.displacementmap,{opacity:{value:1}}]),vertexShader:_s.meshnormal_vert,fragmentShader:_s.meshnormal_frag},sprite:{uniforms:Qr([xs.sprite,xs.fog]),vertexShader:_s.sprite_vert,fragmentShader:_s.sprite_frag},background:{uniforms:{uvTransform:{value:new gn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:_s.background_vert,fragmentShader:_s.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:_s.backgroundCube_vert,fragmentShader:_s.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:_s.cube_vert,fragmentShader:_s.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:_s.equirect_vert,fragmentShader:_s.equirect_frag},distanceRGBA:{uniforms:Qr([xs.common,xs.displacementmap,{referencePosition:{value:new Vn},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:_s.distanceRGBA_vert,fragmentShader:_s.distanceRGBA_frag},shadow:{uniforms:Qr([xs.lights,xs.fog,{color:{value:new cr(0)},opacity:{value:1}}]),vertexShader:_s.shadow_vert,fragmentShader:_s.shadow_frag}};ys.physical={uniforms:Qr([ys.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new gn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new gn},clearcoatNormalScale:{value:new fn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new gn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new gn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new gn},sheen:{value:0},sheenColor:{value:new cr(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new gn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new gn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new gn},transmissionSamplerSize:{value:new fn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new gn},attenuationDistance:{value:0},attenuationColor:{value:new cr(0)},specularColor:{value:new cr(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new gn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new gn},anisotropyVector:{value:new fn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new gn}}]),vertexShader:_s.meshphysical_vert,fragmentShader:_s.meshphysical_frag};const Ms={r:0,b:0,g:0};function Ss(e,t,n,i,r,s,a){const o=new cr(0);let l,c,h=!0===s?0:1,u=null,d=0,p=null;function m(t,n){t.getRGB(Ms,$r(e)),i.buffers.color.setClear(Ms.r,Ms.g,Ms.b,n,a)}return{getClearColor:function(){return o},setClearColor:function(e,t=1){o.set(e),h=t,m(o,h)},getClearAlpha:function(){return h},setClearAlpha:function(e){h=e,m(o,h)},render:function(s,f){let g=!1,v=!0===f.isScene?f.background:null;if(v&&v.isTexture){v=(f.backgroundBlurriness>0?n:t).get(v)}switch(null===v?m(o,h):v&&v.isColor&&(m(v,1),g=!0),e.xr.getEnvironmentBlendMode()){case"opaque":g=!0;break;case"additive":i.buffers.color.setClear(0,0,0,1,a),g=!0;break;case"alpha-blend":i.buffers.color.setClear(0,0,0,0,a),g=!0}(e.autoClear||g)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),v&&(v.isCubeTexture||v.mapping===De)?(void 0===c&&(c=new Yr(new Kr(1,1,1),new ts({name:"BackgroundCubeMaterial",uniforms:Jr(ys.backgroundCube.uniforms),vertexShader:ys.backgroundCube.vertexShader,fragmentShader:ys.backgroundCube.fragmentShader,side:me,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(c)),c.material.uniforms.envMap.value=v,c.material.uniforms.flipEnvMap.value=v.isCubeTexture&&!1===v.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=f.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=f.backgroundIntensity,c.material.toneMapped=v.colorSpace!==Wt,u===v&&d===v.version&&p===e.toneMapping||(c.material.needsUpdate=!0,u=v,d=v.version,p=e.toneMapping),c.layers.enableAll(),s.unshift(c,c.geometry,c.material,0,0,null)):v&&v.isTexture&&(void 0===l&&(l=new Yr(new vs(2,2),new ts({name:"BackgroundMaterial",uniforms:Jr(ys.background.uniforms),vertexShader:ys.background.vertexShader,fragmentShader:ys.background.fragmentShader,side:pe,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(l)),l.material.uniforms.t2D.value=v,l.material.uniforms.backgroundIntensity.value=f.backgroundIntensity,l.material.toneMapped=v.colorSpace!==Wt,!0===v.matrixAutoUpdate&&v.updateMatrix(),l.material.uniforms.uvTransform.value.copy(v.matrix),u===v&&d===v.version&&p===e.toneMapping||(l.material.needsUpdate=!0,u=v,d=v.version,p=e.toneMapping),l.layers.enableAll(),s.unshift(l,l.geometry,l.material,0,0,null))}}}function bs(e,t,n,i){const r=e.getParameter(e.MAX_VERTEX_ATTRIBS),s=i.isWebGL2?null:t.get("OES_vertex_array_object"),a=i.isWebGL2||null!==s,o={},l=p(null);let c=l,h=!1;function u(t){return i.isWebGL2?e.bindVertexArray(t):s.bindVertexArrayOES(t)}function d(t){return i.isWebGL2?e.deleteVertexArray(t):s.deleteVertexArrayOES(t)}function p(e){const t=[],n=[],i=[];for(let e=0;e=0){const n=r[t];let i=s[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;a++}}return c.attributesNum!==a||c.index!==i}(r,x,d,y),M&&function(e,t,n,i){const r={},s=t.attributes;let a=0;const o=n.getAttributes();for(const t in o){if(o[t].location>=0){let n=s[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),r[t]=i,a++}}c.attributes=r,c.attributesNum=a,c.index=i}(r,x,d,y)}else{const e=!0===l.wireframe;c.geometry===x.id&&c.program===d.id&&c.wireframe===e||(c.geometry=x.id,c.program=d.id,c.wireframe=e,M=!0)}null!==y&&n.update(y,e.ELEMENT_ARRAY_BUFFER),(M||h)&&(h=!1,function(r,s,a,o){if(!1===i.isWebGL2&&(r.isInstancedMesh||o.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;m();const l=o.attributes,c=a.getAttributes(),h=s.defaultAttributeValues;for(const t in c){const s=c[t];if(s.location>=0){let a=l[t];if(void 0===a&&("instanceMatrix"===t&&r.instanceMatrix&&(a=r.instanceMatrix),"instanceColor"===t&&r.instanceColor&&(a=r.instanceColor)),void 0!==a){const t=a.normalized,l=a.itemSize,c=n.get(a);if(void 0===c)continue;const h=c.buffer,u=c.type,d=c.bytesPerElement,p=!0===i.isWebGL2&&(u===e.INT||u===e.UNSIGNED_INT||a.gpuType===je);if(a.isInterleavedBufferAttribute){const n=a.data,i=n.stride,c=a.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}const s="undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===e.constructor.name;let a=void 0!==n.precision?n.precision:"highp";const o=r(a);o!==a&&(console.warn("THREE.WebGLRenderer:",a,"not supported, using",o,"instead."),a=o);const l=s||t.has("WEBGL_draw_buffers"),c=!0===n.logarithmicDepthBuffer,h=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),u=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),d=e.getParameter(e.MAX_TEXTURE_SIZE),p=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),m=e.getParameter(e.MAX_VERTEX_ATTRIBS),f=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),g=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),_=u>0,x=s||t.has("OES_texture_float");return{isWebGL2:s,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:r,precision:a,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:u,maxTextureSize:d,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:f,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:_,floatFragmentTextures:x,floatVertexTextures:_&&x,maxSamples:s?e.getParameter(e.MAX_SAMPLES):0}}function Es(e){const t=this;let n=null,i=0,r=!1,s=!1;const a=new us,o=new gn,l={value:null,needsUpdate:!1};function c(e,n,i,r){const s=null!==e?e.length:0;let c=null;if(0!==s){if(c=l.value,!0!==r||null===c){const t=i+4*s,r=n.matrixWorldInverse;o.getNormalMatrix(r),(null===c||c.length0);t.numPlanes=i,t.numIntersection=0}();else{const e=s?0:i,t=4*e;let r=m.clippingState||null;l.value=r,r=c(u,o,t,h);for(let e=0;e!==t;++e)r[e]=n[e];m.clippingState=r,this.numIntersection=d?this.numPlanes:0,this.numPlanes+=e}}}function As(e){let t=new WeakMap;function n(e,t){return t===Le?e.mapping=Ce:t===Ie&&(e.mapping=Pe),e}function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture&&!1===r.isRenderTargetTexture){const s=r.mapping;if(s===Le||s===Ie){if(t.has(r)){return n(t.get(r).texture,r.mapping)}{const s=r.image;if(s&&s.height>0){const a=new os(s.height/2);return a.fromEquirectangularTexture(e,r),t.set(r,a),r.addEventListener("dispose",i),n(a.texture,r.mapping)}return null}}}return r},dispose:function(){t=new WeakMap}}}class Rs extends ns{constructor(e=-1,t=1,n=1,i=-1,r=.1,s=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=r,this.far=s,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,r,s){null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-e,s=n+e,a=i+t,o=i-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=e*this.view.offsetX,s=r+e*this.view.width,a-=t*this.view.offsetY,o=a-t*this.view.height}this.projectionMatrix.makeOrthographic(r,s,a,o,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}const Cs=[.125,.215,.35,.446,.526,.582],Ps=20,Ls=new Rs,Is=new cr;let Ds=null;const Us=(1+Math.sqrt(5))/2,Ns=1/Us,Os=[new Vn(1,1,1),new Vn(-1,1,1),new Vn(1,1,-1),new Vn(-1,1,-1),new Vn(0,Us,Ns),new Vn(0,Us,-Ns),new Vn(Ns,0,Us),new Vn(-Ns,0,Us),new Vn(Us,Ns,0),new Vn(-Us,Ns,0)];class Fs{constructor(e){this._renderer=e,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(e,t=0,n=.1,i=100){Ds=this._renderer.getRenderTarget(),this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,n,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=Hs(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=ks(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?o=Cs[a-e+4-1]:0===a&&(o=0),i.push(o);const l=1/(s-2),c=-l,h=1+l,u=[c,c,h,c,h,h,c,c,h,h,c,h],d=6,p=6,m=3,f=2,g=1,v=new Float32Array(m*p*d),_=new Float32Array(f*p*d),x=new Float32Array(g*p*d);for(let e=0;e2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];v.set(i,m*p*e),_.set(u,f*p*e);const r=[e,e,e,e,e,e];x.set(r,g*p*e)}const y=new Pr;y.setAttribute("position",new xr(v,m)),y.setAttribute("uv",new xr(_,f)),y.setAttribute("faceIndex",new xr(x,g)),t.push(y),r>4&&r--}return{lodPlanes:t,sizeLods:n,sigmas:i}}(i)),this._blurMaterial=function(e,t,n){const i=new Float32Array(Ps),r=new Vn(0,1,0),s=new ts({name:"SphericalGaussianBlur",defines:{n:Ps,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Gs(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\t\t\tuniform int samples;\n\t\t\tuniform float weights[ n ];\n\t\t\tuniform bool latitudinal;\n\t\t\tuniform float dTheta;\n\t\t\tuniform float mipInt;\n\t\t\tuniform vec3 poleAxis;\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \n\n\t\t\tvec3 getSample( float theta, vec3 axis ) {\n\n\t\t\t\tfloat cosTheta = cos( theta );\n\t\t\t\t// Rodrigues' axis-angle rotation\n\t\t\t\tvec3 sampleDirection = vOutputDirection * cosTheta\n\t\t\t\t\t+ cross( axis, vOutputDirection ) * sin( theta )\n\t\t\t\t\t+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n\t\t\t\treturn bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n\t\t\t}\n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n\t\t\t\tif ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n\t\t\t\t\taxis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n\t\t\t\t}\n\n\t\t\t\taxis = normalize( axis );\n\n\t\t\t\tgl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n\t\t\t\tgl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n\t\t\t\tfor ( int i = 1; i < n; i++ ) {\n\n\t\t\t\t\tif ( i >= samples ) {\n\n\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tfloat theta = dTheta * float( i );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n\t\t\t\t\tgl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1});return s}(i,e,t)}return i}_compileMaterial(e){const t=new Yr(this._lodPlanes[0],e);this._renderer.compile(t,Ls)}_sceneToCubeUV(e,t,n,i){const r=new is(90,1,t,n),s=[1,-1,1,1,1,1],a=[1,1,1,-1,-1,-1],o=this._renderer,l=o.autoClear,c=o.toneMapping;o.getClearColor(Is),o.toneMapping=Se,o.autoClear=!1;const h=new ur({name:"PMREM.Background",side:me,depthWrite:!1,depthTest:!1}),u=new Yr(new Kr,h);let d=!1;const p=e.background;p?p.isColor&&(h.color.copy(p),e.background=null,d=!0):(h.color.copy(Is),d=!0);for(let t=0;t<6;t++){const n=t%3;0===n?(r.up.set(0,s[t],0),r.lookAt(a[t],0,0)):1===n?(r.up.set(0,0,s[t]),r.lookAt(0,a[t],0)):(r.up.set(0,s[t],0),r.lookAt(0,0,a[t]));const l=this._cubeSize;Bs(i,n*l,t>2?l:0,l,l),o.setRenderTarget(i),d&&o.render(u,r),o.render(e,r)}u.geometry.dispose(),u.material.dispose(),o.toneMapping=c,o.autoClear=l,e.background=p}_textureToCubeUV(e,t){const n=this._renderer,i=e.mapping===Ce||e.mapping===Pe;i?(null===this._cubemapMaterial&&(this._cubemapMaterial=Hs()),this._cubemapMaterial.uniforms.flipEnvMap.value=!1===e.isRenderTargetTexture?-1:1):null===this._equirectMaterial&&(this._equirectMaterial=ks());const r=i?this._cubemapMaterial:this._equirectMaterial,s=new Yr(this._lodPlanes[0],r);r.uniforms.envMap.value=e;const a=this._cubeSize;Bs(t,0,0,3*a,2*a),n.setRenderTarget(t),n.render(s,Ls)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let t=1;tPs&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const f=[];let g=0;for(let e=0;ev-4?i-v+4:0),4*(this._cubeSize-_),3*_,2*_),o.setRenderTarget(t),o.render(c,Ls)}}function zs(e,t,n){const i=new Bn(e,t,n);return i.texture.mapping=De,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Bs(e,t,n,i,r){e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function ks(){return new ts({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Gs(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform sampler2D envMap;\n\n\t\t\t#include \n\n\t\t\tvoid main() {\n\n\t\t\t\tvec3 outputDirection = normalize( vOutputDirection );\n\t\t\t\tvec2 uv = equirectUv( outputDirection );\n\n\t\t\t\tgl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Hs(){return new ts({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Gs(),fragmentShader:"\n\n\t\t\tprecision mediump float;\n\t\t\tprecision mediump int;\n\n\t\t\tuniform float flipEnvMap;\n\n\t\t\tvarying vec3 vOutputDirection;\n\n\t\t\tuniform samplerCube envMap;\n\n\t\t\tvoid main() {\n\n\t\t\t\tgl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n\t\t\t}\n\t\t",blending:0,depthTest:!1,depthWrite:!1})}function Gs(){return"\n\n\t\tprecision mediump float;\n\t\tprecision mediump int;\n\n\t\tattribute float faceIndex;\n\n\t\tvarying vec3 vOutputDirection;\n\n\t\t// RH coordinate system; PMREM face-indexing convention\n\t\tvec3 getDirection( vec2 uv, float face ) {\n\n\t\t\tuv = 2.0 * uv - 1.0;\n\n\t\t\tvec3 direction = vec3( uv, 1.0 );\n\n\t\t\tif ( face == 0.0 ) {\n\n\t\t\t\tdirection = direction.zyx; // ( 1, v, u ) pos x\n\n\t\t\t} else if ( face == 1.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n\t\t\t} else if ( face == 2.0 ) {\n\n\t\t\t\tdirection.x *= -1.0; // ( -u, v, 1 ) pos z\n\n\t\t\t} else if ( face == 3.0 ) {\n\n\t\t\t\tdirection = direction.zyx;\n\t\t\t\tdirection.xz *= -1.0; // ( -1, v, -u ) neg x\n\n\t\t\t} else if ( face == 4.0 ) {\n\n\t\t\t\tdirection = direction.xzy;\n\t\t\t\tdirection.xy *= -1.0; // ( -u, -1, v ) neg y\n\n\t\t\t} else if ( face == 5.0 ) {\n\n\t\t\t\tdirection.z *= -1.0; // ( u, v, -1 ) neg z\n\n\t\t\t}\n\n\t\t\treturn direction;\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvOutputDirection = getDirection( uv, faceIndex );\n\t\t\tgl_Position = vec4( position, 1.0 );\n\n\t\t}\n\t"}function Vs(e){let t=new WeakMap,n=null;function i(e){const n=e.target;n.removeEventListener("dispose",i);const r=t.get(n);void 0!==r&&(t.delete(n),r.dispose())}return{get:function(r){if(r&&r.isTexture){const s=r.mapping,a=s===Le||s===Ie,o=s===Ce||s===Pe;if(a||o){if(r.isRenderTargetTexture&&!0===r.needsPMREMUpdate){r.needsPMREMUpdate=!1;let i=t.get(r);return null===n&&(n=new Fs(e)),i=a?n.fromEquirectangular(r,i):n.fromCubemap(r,i),t.set(r,i),i.texture}if(t.has(r))return t.get(r).texture;{const s=r.image;if(a&&s&&s.height>0||o&&s&&function(e){let t=0;const n=6;for(let i=0;it.maxTextureSize&&(w=Math.ceil(T/t.maxTextureSize),T=t.maxTextureSize);const E=new Float32Array(T*w*4*p),A=new kn(E,T,w,p);A.type=qe,A.needsUpdate=!0;const R=4*b;for(let P=0;P0)return e;const r=t*n;let s=na[r];if(void 0===s&&(s=new Float32Array(r),na[r]=s),0!==t){i.toArray(s,0);for(let i=1,r=0;i!==t;++i)r+=n,e[i].toArray(s,r)}return s}function la(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n":" "} ${r}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}return r}function so(e,t){const n=function(e){switch(e){case jt:return["Linear","( value )"];case Wt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",e),["Linear","( value )"]}}(t);return"vec4 "+e+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function ao(e,t){let n;switch(t){case be:n="Linear";break;case Te:n="Reinhard";break;case we:n="OptimizedCineon";break;case Ee:n="ACESFilmic";break;case Ae:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function oo(e){return""!==e}function lo(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function co(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const ho=/^[ \t]*#include +<([\w\d./]+)>/gm;function uo(e){return e.replace(ho,mo)}const po=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function mo(e,t){let n=_s[t];if(void 0===n){const e=po.get(t);if(void 0===e)throw new Error("Can not resolve #include <"+t+">");n=_s[e],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,e)}return uo(n)}const fo=/#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 go(e){return e.replace(fo,vo)}function vo(e,t,n,i){let r="";for(let e=parseInt(t);e0&&(g+="\n"),v=[p,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m].filter(oo).join("\n"),v.length>0&&(v+="\n")):(g=[_o(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","\tattribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","\tattribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1","\tattribute vec2 uv1;","#endif","#ifdef USE_UV2","\tattribute vec2 uv2;","#endif","#ifdef USE_UV3","\tattribute vec2 uv3;","#endif","#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","\tattribute vec4 color;","#elif defined( USE_COLOR )","\tattribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(oo).join("\n"),v=[p,_o(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,m,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+c:"",n.envMap?"#define "+h:"",n.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":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents&&!1===n.flatShading?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==Se?"#define TONE_MAPPING":"",n.toneMapping!==Se?_s.tonemapping_pars_fragment:"",n.toneMapping!==Se?ao("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",_s.colorspace_pars_fragment,so("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"","\n"].filter(oo).join("\n")),a=uo(a),a=lo(a,n),a=co(a,n),o=uo(o),o=lo(o,n),o=co(o,n),a=go(a),o=go(o),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(_="#version 300 es\n",g=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+g,v=["#define varying in",n.glslVersion===Zt?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Zt?"":"#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("\n")+"\n"+v);const x=_+g+a,y=_+v+o,M=no(r,r.VERTEX_SHADER,x),S=no(r,r.FRAGMENT_SHADER,y);if(r.attachShader(f,M),r.attachShader(f,S),void 0!==n.index0AttributeName?r.bindAttribLocation(f,0,n.index0AttributeName):!0===n.morphTargets&&r.bindAttribLocation(f,0,"position"),r.linkProgram(f),e.debug.checkShaderErrors){const t=r.getProgramInfoLog(f).trim(),n=r.getShaderInfoLog(M).trim(),i=r.getShaderInfoLog(S).trim();let s=!0,a=!0;if(!1===r.getProgramParameter(f,r.LINK_STATUS))if(s=!1,"function"==typeof e.debug.onShaderError)e.debug.onShaderError(r,f,M,S);else{const e=ro(r,M,"vertex"),n=ro(r,S,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(f,r.VALIDATE_STATUS)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+n)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):""!==n&&""!==i||(a=!1);a&&(this.diagnostics={runnable:s,programLog:t,vertexShader:{log:n,prefix:g},fragmentShader:{log:i,prefix:v}})}let b,T;return r.deleteShader(M),r.deleteShader(S),this.getUniforms=function(){return void 0===b&&(b=new to(r,f)),b},this.getAttributes=function(){return void 0===T&&(T=function(e,t){const n={},i=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let r=0;r0,j=s.clearcoat>0,X=s.iridescence>0,q=s.sheen>0,Y=s.transmission>0,Z=W&&!!s.anisotropyMap,K=j&&!!s.clearcoatMap,J=j&&!!s.clearcoatNormalMap,Q=j&&!!s.clearcoatRoughnessMap,$=X&&!!s.iridescenceMap,ee=X&&!!s.iridescenceThicknessMap,te=q&&!!s.sheenColorMap,ne=q&&!!s.sheenRoughnessMap,ie=!!s.specularMap,re=!!s.specularColorMap,se=!!s.specularIntensityMap,ae=Y&&!!s.transmissionMap,oe=Y&&!!s.thicknessMap,le=!!s.gradientMap,ce=!!s.alphaMap,he=s.alphaTest>0,ue=!!s.alphaHash,de=!!s.extensions,pe=!!x.attributes.uv1,ge=!!x.attributes.uv2,ve=!!x.attributes.uv3;return{isWebGL2:h,shaderID:b,shaderType:s.type,shaderName:s.name,vertexShader:E,fragmentShader:A,defines:s.defines,customVertexShaderID:R,customFragmentShaderID:C,isRawShaderMaterial:!0===s.isRawShaderMaterial,glslVersion:s.glslVersion,precision:p,instancing:I,instancingColor:I&&null!==v.instanceColor,supportsVertexTextures:d,outputColorSpace:null===L?e.outputColorSpace:!0===L.isXRRenderTarget?L.texture.colorSpace:jt,map:D,matcap:U,envMap:N,envMapMode:N&&M.mapping,envMapCubeUVHeight:S,aoMap:O,lightMap:F,bumpMap:z,normalMap:B,displacementMap:d&&k,emissiveMap:H,normalMapObjectSpace:B&&1===s.normalMapType,normalMapTangentSpace:B&&0===s.normalMapType,metalnessMap:G,roughnessMap:V,anisotropy:W,anisotropyMap:Z,clearcoat:j,clearcoatMap:K,clearcoatNormalMap:J,clearcoatRoughnessMap:Q,iridescence:X,iridescenceMap:$,iridescenceThicknessMap:ee,sheen:q,sheenColorMap:te,sheenRoughnessMap:ne,specularMap:ie,specularColorMap:re,specularIntensityMap:se,transmission:Y,transmissionMap:ae,thicknessMap:oe,gradientMap:le,opaque:!1===s.transparent&&1===s.blending,alphaMap:ce,alphaTest:he,alphaHash:ue,combine:s.combine,mapUv:D&&f(s.map.channel),aoMapUv:O&&f(s.aoMap.channel),lightMapUv:F&&f(s.lightMap.channel),bumpMapUv:z&&f(s.bumpMap.channel),normalMapUv:B&&f(s.normalMap.channel),displacementMapUv:k&&f(s.displacementMap.channel),emissiveMapUv:H&&f(s.emissiveMap.channel),metalnessMapUv:G&&f(s.metalnessMap.channel),roughnessMapUv:V&&f(s.roughnessMap.channel),anisotropyMapUv:Z&&f(s.anisotropyMap.channel),clearcoatMapUv:K&&f(s.clearcoatMap.channel),clearcoatNormalMapUv:J&&f(s.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Q&&f(s.clearcoatRoughnessMap.channel),iridescenceMapUv:$&&f(s.iridescenceMap.channel),iridescenceThicknessMapUv:ee&&f(s.iridescenceThicknessMap.channel),sheenColorMapUv:te&&f(s.sheenColorMap.channel),sheenRoughnessMapUv:ne&&f(s.sheenRoughnessMap.channel),specularMapUv:ie&&f(s.specularMap.channel),specularColorMapUv:re&&f(s.specularColorMap.channel),specularIntensityMapUv:se&&f(s.specularIntensityMap.channel),transmissionMapUv:ae&&f(s.transmissionMap.channel),thicknessMapUv:oe&&f(s.thicknessMap.channel),alphaMapUv:ce&&f(s.alphaMap.channel),vertexTangents:!!x.attributes.tangent&&(B||W),vertexColors:s.vertexColors,vertexAlphas:!0===s.vertexColors&&!!x.attributes.color&&4===x.attributes.color.itemSize,vertexUv1s:pe,vertexUv2s:ge,vertexUv3s:ve,pointsUvs:!0===v.isPoints&&!!x.attributes.uv&&(D||ce),fog:!!_,useFog:!0===s.fog,fogExp2:_&&_.isFogExp2,flatShading:!0===s.flatShading,sizeAttenuation:!0===s.sizeAttenuation,logarithmicDepthBuffer:u,skinning:!0===v.isSkinnedMesh,morphTargets:void 0!==x.morphAttributes.position,morphNormals:void 0!==x.morphAttributes.normal,morphColors:void 0!==x.morphAttributes.color,morphTargetsCount:w,morphTextureStride:P,numDirLights:o.directional.length,numPointLights:o.point.length,numSpotLights:o.spot.length,numSpotLightMaps:o.spotLightMap.length,numRectAreaLights:o.rectArea.length,numHemiLights:o.hemi.length,numDirLightShadows:o.directionalShadowMap.length,numPointLightShadows:o.pointShadowMap.length,numSpotLightShadows:o.spotShadowMap.length,numSpotLightShadowsWithMaps:o.numSpotLightShadowsWithMaps,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:s.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:s.toneMapped?e.toneMapping:Se,useLegacyLights:e.useLegacyLights,premultipliedAlpha:s.premultipliedAlpha,doubleSided:s.side===fe,flipSided:s.side===me,useDepthPacking:s.depthPacking>=0,depthPacking:s.depthPacking||0,index0AttributeName:s.index0AttributeName,extensionDerivatives:de&&!0===s.extensions.derivatives,extensionFragDepth:de&&!0===s.extensions.fragDepth,extensionDrawBuffers:de&&!0===s.extensions.drawBuffers,extensionShaderTextureLOD:de&&!0===s.extensions.shaderTextureLOD,rendererExtensionFragDepth:h||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:h||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:h||i.has("EXT_shader_texture_lod"),customProgramCacheKey:s.customProgramCacheKey()}},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);return!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}(n,t),function(e,t){o.disableAll(),t.isWebGL2&&o.enable(0);t.supportsVertexTextures&&o.enable(1);t.instancing&&o.enable(2);t.instancingColor&&o.enable(3);t.matcap&&o.enable(4);t.envMap&&o.enable(5);t.normalMapObjectSpace&&o.enable(6);t.normalMapTangentSpace&&o.enable(7);t.clearcoat&&o.enable(8);t.iridescence&&o.enable(9);t.alphaTest&&o.enable(10);t.vertexColors&&o.enable(11);t.vertexAlphas&&o.enable(12);t.vertexUv1s&&o.enable(13);t.vertexUv2s&&o.enable(14);t.vertexUv3s&&o.enable(15);t.vertexTangents&&o.enable(16);t.anisotropy&&o.enable(17);e.push(o.mask),o.disableAll(),t.fog&&o.enable(0);t.useFog&&o.enable(1);t.flatShading&&o.enable(2);t.logarithmicDepthBuffer&&o.enable(3);t.skinning&&o.enable(4);t.morphTargets&&o.enable(5);t.morphNormals&&o.enable(6);t.morphColors&&o.enable(7);t.premultipliedAlpha&&o.enable(8);t.shadowMapEnabled&&o.enable(9);t.useLegacyLights&&o.enable(10);t.doubleSided&&o.enable(11);t.flipSided&&o.enable(12);t.useDepthPacking&&o.enable(13);t.dithering&&o.enable(14);t.transmission&&o.enable(15);t.sheen&&o.enable(16);t.opaque&&o.enable(17);t.pointsUvs&&o.enable(18);e.push(o.mask)}(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()},getUniforms:function(e){const t=m[e.type];let n;if(t){const e=ys[t];n=es.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let i;for(let e=0,t=c.length;e0?i.push(h):!0===a.transparent?r.push(h):n.push(h)},unshift:function(e,t,a,o,l,c){const h=s(e,t,a,o,l,c);a.transmission>0?i.unshift(h):!0===a.transparent?r.unshift(h):n.unshift(h)},finish:function(){for(let n=t,i=e.length;n1&&n.sort(e||wo),i.length>1&&i.sort(t||Eo),r.length>1&&r.sort(t||Eo)}}}function Ro(){let e=new WeakMap;return{get:function(t,n){const i=e.get(t);let r;return void 0===i?(r=new Ao,e.set(t,[r])):n>=i.length?(r=new Ao,i.push(r)):r=i[n],r},dispose:function(){e=new WeakMap}}}function Co(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new Vn,color:new cr};break;case"SpotLight":n={position:new Vn,direction:new Vn,color:new cr,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Vn,color:new cr,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Vn,skyColor:new cr,groundColor:new cr};break;case"RectAreaLight":n={color:new cr,position:new Vn,halfWidth:new Vn,halfHeight:new Vn}}return e[t.id]=n,n}}}let Po=0;function Lo(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function Io(e,t){const n=new Co,i=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new fn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new fn,shadowCameraNear:1,shadowCameraFar:1e3}}return e[t.id]=n,n}}}(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-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};for(let e=0;e<9;e++)r.probe.push(new Vn);const s=new Vn,a=new xi,o=new xi;return{setup:function(s,a){let o=0,l=0,c=0;for(let e=0;e<9;e++)r.probe[e].set(0,0,0);let h=0,u=0,d=0,p=0,m=0,f=0,g=0,v=0,_=0,x=0;s.sort(Lo);const y=!0===a?Math.PI:1;for(let e=0,t=s.length;e0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(r.rectAreaLTC1=xs.LTC_FLOAT_1,r.rectAreaLTC2=xs.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=xs.LTC_HALF_1,r.rectAreaLTC2=xs.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=o,r.ambient[1]=l,r.ambient[2]=c;const M=r.hash;M.directionalLength===h&&M.pointLength===u&&M.spotLength===d&&M.rectAreaLength===p&&M.hemiLength===m&&M.numDirectionalShadows===f&&M.numPointShadows===g&&M.numSpotShadows===v&&M.numSpotMaps===_||(r.directional.length=h,r.spot.length=d,r.rectArea.length=p,r.point.length=u,r.hemi.length=m,r.directionalShadow.length=f,r.directionalShadowMap.length=f,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=v,r.spotShadowMap.length=v,r.directionalShadowMatrix.length=f,r.pointShadowMatrix.length=g,r.spotLightMatrix.length=v+_-x,r.spotLightMap.length=_,r.numSpotLightShadowsWithMaps=x,M.directionalLength=h,M.pointLength=u,M.spotLength=d,M.rectAreaLength=p,M.hemiLength=m,M.numDirectionalShadows=f,M.numPointShadows=g,M.numSpotShadows=v,M.numSpotMaps=_,r.version=Po++)},setupView:function(e,t){let n=0,i=0,l=0,c=0,h=0;const u=t.matrixWorldInverse;for(let t=0,d=e.length;t=s.length?(a=new Do(e,t),s.push(a)):a=s[r],a},dispose:function(){n=new WeakMap}}}class No extends rr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Oo extends rr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}function Fo(e,t,n){let i=new ms;const r=new fn,s=new fn,a=new zn,o=new No({depthPacking:3201}),l=new Oo,c={},h=n.maxTextureSize,u={[pe]:me,[me]:pe,[fe]:fe},d=new ts({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new fn},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\n\tconst float samples = float( VSM_SAMPLES );\n\tfloat mean = 0.0;\n\tfloat squared_mean = 0.0;\n\tfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n\tfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n\tfor ( float i = 0.0; i < samples; i ++ ) {\n\t\tfloat uvOffset = uvStart + i * uvStride;\n\t\t#ifdef HORIZONTAL_PASS\n\t\t\tvec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );\n\t\t\tmean += distribution.x;\n\t\t\tsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\t\t#else\n\t\t\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );\n\t\t\tmean += depth;\n\t\t\tsquared_mean += depth * depth;\n\t\t#endif\n\t}\n\tmean = mean / samples;\n\tsquared_mean = squared_mean / samples;\n\tfloat std_dev = sqrt( squared_mean - mean * mean );\n\tgl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n}"}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const m=new Pr;m.setAttribute("position",new xr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const f=new Yr(m,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=he;let v=this.type;function _(n,i){const s=t.update(f);d.defines.VSM_SAMPLES!==n.blurSamples&&(d.defines.VSM_SAMPLES=n.blurSamples,p.defines.VSM_SAMPLES=n.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),null===n.mapPass&&(n.mapPass=new Bn(r.x,r.y)),d.uniforms.shadow_pass.value=n.map.texture,d.uniforms.resolution.value=n.mapSize,d.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,s,d,f,null),p.uniforms.shadow_pass.value=n.mapPass.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,s,p,f,null)}function x(t,n,i,r){let s=null;const a=!0===i.isPointLight?t.customDistanceMaterial:t.customDepthMaterial;if(void 0!==a)s=a;else if(s=!0===i.isPointLight?l:o,e.localClippingEnabled&&!0===n.clipShadows&&Array.isArray(n.clippingPlanes)&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0||n.map&&n.alphaTest>0){const e=s.uuid,t=n.uuid;let i=c[e];void 0===i&&(i={},c[e]=i);let r=i[t];void 0===r&&(r=s.clone(),i[t]=r),s=r}if(s.visible=n.visible,s.wireframe=n.wireframe,s.side=r===de?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:u[n.side],s.alphaMap=n.alphaMap,s.alphaTest=n.alphaTest,s.map=n.map,s.clipShadows=n.clipShadows,s.clippingPlanes=n.clippingPlanes,s.clipIntersection=n.clipIntersection,s.displacementMap=n.displacementMap,s.displacementScale=n.displacementScale,s.displacementBias=n.displacementBias,s.wireframeLinewidth=n.wireframeLinewidth,s.linewidth=n.linewidth,!0===i.isPointLight&&!0===s.isMeshDistanceMaterial){e.properties.get(s).light=i}return s}function y(n,r,s,a,o){if(!1===n.visible)return;if(n.layers.test(r.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&o===de)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(s.matrixWorldInverse,n.matrixWorld);const i=t.update(n),r=n.material;if(Array.isArray(r)){const t=i.groups;for(let l=0,c=t.length;lh||r.y>h)&&(r.x>h&&(s.x=Math.floor(h/f.x),r.x=s.x*f.x,u.mapSize.x=s.x),r.y>h&&(s.y=Math.floor(h/f.y),r.y=s.y*f.y,u.mapSize.y=s.y)),null===u.map||!0===p||!0===m){const e=this.type!==de?{minFilter:Fe,magFilter:Fe}:{};null!==u.map&&u.map.dispose(),u.map=new Bn(r.x,r.y,e),u.map.texture.name=c.name+".shadowMap",u.camera.updateProjectionMatrix()}e.setRenderTarget(u.map),e.clear();const g=u.getViewportCount();for(let e=0;e=1):-1!==L.indexOf("OpenGL ES")&&(P=parseFloat(/^OpenGL ES (\d)/.exec(L)[1]),C=P>=2);let I=null,D={};const U=e.getParameter(e.SCISSOR_BOX),N=e.getParameter(e.VIEWPORT),O=(new zn).fromArray(U),F=(new zn).fromArray(N);function z(t,n,r,s){const a=new Uint8Array(4),o=e.createTexture();e.bindTexture(t,o),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let o=0;oi||e.height>i)&&(r=i/Math.max(e.width,e.height)),r<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const i=t?un:Math.floor,s=i(r*e.width),a=i(r*e.height);void 0===f&&(f=_(s,a));const o=n?_(s,a):f;o.width=s,o.height=a;return o.getContext("2d").drawImage(e,0,0,s,a),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+s+"x"+a+")."),o}return"data"in e&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function y(e){return cn(e.width)&&cn(e.height)}function M(e,t){return e.generateMipmaps&&t&&e.minFilter!==Fe&&e.minFilter!==ke}function S(t){e.generateMipmap(t)}function b(n,i,r,s,a=!1){if(!1===o)return i;if(null!==n){if(void 0!==e[n])return e[n];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let l=i;return i===e.RED&&(r===e.FLOAT&&(l=e.R32F),r===e.HALF_FLOAT&&(l=e.R16F),r===e.UNSIGNED_BYTE&&(l=e.R8)),i===e.RG&&(r===e.FLOAT&&(l=e.RG32F),r===e.HALF_FLOAT&&(l=e.RG16F),r===e.UNSIGNED_BYTE&&(l=e.RG8)),i===e.RGBA&&(r===e.FLOAT&&(l=e.RGBA32F),r===e.HALF_FLOAT&&(l=e.RGBA16F),r===e.UNSIGNED_BYTE&&(l=s===Wt&&!1===a?e.SRGB8_ALPHA8:e.RGBA8),r===e.UNSIGNED_SHORT_4_4_4_4&&(l=e.RGBA4),r===e.UNSIGNED_SHORT_5_5_5_1&&(l=e.RGB5_A1)),l!==e.R16F&&l!==e.R32F&&l!==e.RG16F&&l!==e.RG32F&&l!==e.RGBA16F&&l!==e.RGBA32F||t.get("EXT_color_buffer_float"),l}function T(e,t,n){return!0===M(e,n)||e.isFramebufferTexture&&e.minFilter!==Fe&&e.minFilter!==ke?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function w(t){return t===Fe||t===ze||t===Be?e.NEAREST:e.LINEAR}function E(e){const t=e.target;t.removeEventListener("dispose",E),function(e){const t=i.get(e);if(void 0===t.__webglInit)return;const n=e.source,r=g.get(n);if(r){const i=r[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&R(e),0===Object.keys(r).length&&g.delete(n)}i.remove(e)}(t),t.isVideoTexture&&m.delete(t)}function A(t){const n=t.target;n.removeEventListener("dispose",A),function(t){const n=t.texture,r=i.get(t),s=i.get(n);void 0!==s.__webglTexture&&(e.deleteTexture(s.__webglTexture),a.memory.textures--);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(r.__webglFramebuffer[t]),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer[t]);else{if(e.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&e.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&e.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer)for(let t=0;t0&&s.__version!==t.version){const e=t.image;if(null===e)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==e.complete)return void O(s,t,r);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(e.TEXTURE_2D,s.__webglTexture,e.TEXTURE0+r)}const L={[Ue]:e.REPEAT,[Ne]:e.CLAMP_TO_EDGE,[Oe]:e.MIRRORED_REPEAT},I={[Fe]:e.NEAREST,[ze]:e.NEAREST_MIPMAP_NEAREST,[Be]:e.NEAREST_MIPMAP_LINEAR,[ke]:e.LINEAR,[He]:e.LINEAR_MIPMAP_NEAREST,[Ge]:e.LINEAR_MIPMAP_LINEAR},D={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function U(n,s,a){if(a?(e.texParameteri(n,e.TEXTURE_WRAP_S,L[s.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,L[s.wrapT]),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,L[s.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,I[s.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,I[s.minFilter])):(e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),n!==e.TEXTURE_3D&&n!==e.TEXTURE_2D_ARRAY||e.texParameteri(n,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),s.wrapS===Ne&&s.wrapT===Ne||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),e.texParameteri(n,e.TEXTURE_MAG_FILTER,w(s.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,w(s.minFilter)),s.minFilter!==Fe&&s.minFilter!==ke&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),s.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,D[s.compareFunction])),!0===t.has("EXT_texture_filter_anisotropic")){const a=t.get("EXT_texture_filter_anisotropic");if(s.magFilter===Fe)return;if(s.minFilter!==Be&&s.minFilter!==Ge)return;if(s.type===qe&&!1===t.has("OES_texture_float_linear"))return;if(!1===o&&s.type===Ye&&!1===t.has("OES_texture_half_float_linear"))return;(s.anisotropy>1||i.get(s).__currentAnisotropy)&&(e.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(s.anisotropy,r.getMaxAnisotropy())),i.get(s).__currentAnisotropy=s.anisotropy)}}function N(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",E));const r=n.source;let s=g.get(r);void 0===s&&(s={},g.set(r,s));const o=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}(n);if(o!==t.__cacheKey){void 0===s[o]&&(s[o]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,i=!0),s[o].usedTimes++;const r=s[t.__cacheKey];void 0!==r&&(s[t.__cacheKey].usedTimes--,0===r.usedTimes&&R(n)),t.__cacheKey=o,t.__webglTexture=s[o].texture}return i}function O(t,r,a){let l=e.TEXTURE_2D;(r.isDataArrayTexture||r.isCompressedArrayTexture)&&(l=e.TEXTURE_2D_ARRAY),r.isData3DTexture&&(l=e.TEXTURE_3D);const c=N(t,r),u=r.source;n.bindTexture(l,t.__webglTexture,e.TEXTURE0+a);const d=i.get(u);if(u.version!==d.__version||!0===c){n.activeTexture(e.TEXTURE0+a),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);const t=function(e){return!o&&(e.wrapS!==Ne||e.wrapT!==Ne||e.minFilter!==Fe&&e.minFilter!==ke)}(r)&&!1===y(r.image);let i=x(r.image,t,!1,h);i=G(r,i);const p=y(i)||o,m=s.convert(r.format,r.colorSpace);let f,g=s.convert(r.type),v=b(r.internalFormat,m,g,r.colorSpace);U(l,r,p);const _=r.mipmaps,w=o&&!0!==r.isVideoTexture,E=void 0===d.__version||!0===c,A=T(r,i,p);if(r.isDepthTexture)v=e.DEPTH_COMPONENT,o?v=r.type===qe?e.DEPTH_COMPONENT32F:r.type===Xe?e.DEPTH_COMPONENT24:r.type===Je?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:r.type===qe&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),r.format===$e&&v===e.DEPTH_COMPONENT&&r.type!==We&&r.type!==Xe&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),r.type=Xe,g=s.convert(r.type)),r.format===et&&v===e.DEPTH_COMPONENT&&(v=e.DEPTH_STENCIL,r.type!==Je&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),r.type=Je,g=s.convert(r.type))),E&&(w?n.texStorage2D(e.TEXTURE_2D,1,v,i.width,i.height):n.texImage2D(e.TEXTURE_2D,0,v,i.width,i.height,0,m,g,null));else if(r.isDataTexture)if(_.length>0&&p){w&&E&&n.texStorage2D(e.TEXTURE_2D,A,v,_[0].width,_[0].height);for(let t=0,i=_.length;t>=1,r>>=1}}else if(_.length>0&&p){w&&E&&n.texStorage2D(e.TEXTURE_2D,A,v,_[0].width,_[0].height);for(let t=0,i=_.length;t=e.TEXTURE_CUBE_MAP_POSITIVE_X&&l<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,o,l,i.get(a).__webglTexture,0),n.bindFramebuffer(e.FRAMEBUFFER,null)}function z(t,n,i){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer&&!n.stencilBuffer){let r=e.DEPTH_COMPONENT16;if(i||H(n)){const t=n.depthTexture;t&&t.isDepthTexture&&(t.type===qe?r=e.DEPTH_COMPONENT32F:t.type===Xe&&(r=e.DEPTH_COMPONENT24));const i=k(n);H(n)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,i,r,n.width,n.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,i,r,n.width,n.height)}else e.renderbufferStorage(e.RENDERBUFFER,r,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(n.depthBuffer&&n.stencilBuffer){const r=k(n);i&&!1===H(n)?e.renderbufferStorageMultisample(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):H(n)?d.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,r,e.DEPTH24_STENCIL8,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else{const t=!0===n.isWebGLMultipleRenderTargets?n.texture:[n.texture];for(let r=0;r0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function G(e,n){const i=e.colorSpace,r=e.format,s=e.type;return!0===e.isCompressedTexture||e.format===Kt||i!==jt&&i!==Vt&&(i===Wt?!1===o?!0===t.has("EXT_sRGB")&&r===Qe?(e.format=Kt,e.minFilter=ke,e.generateMipmaps=!1):n=In.sRGBToLinear(n):r===Qe&&s===Ve||console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",i)),n}this.allocateTextureUnit=function(){const e=C;return e>=l&&console.warn("THREE.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),C+=1,e},this.resetTextureUnits=function(){C=0},this.setTexture2D=P,this.setTexture2DArray=function(t,r){const s=i.get(t);t.version>0&&s.__version!==t.version?O(s,t,r):n.bindTexture(e.TEXTURE_2D_ARRAY,s.__webglTexture,e.TEXTURE0+r)},this.setTexture3D=function(t,r){const s=i.get(t);t.version>0&&s.__version!==t.version?O(s,t,r):n.bindTexture(e.TEXTURE_3D,s.__webglTexture,e.TEXTURE0+r)},this.setTextureCube=function(t,r){const a=i.get(t);t.version>0&&a.__version!==t.version?function(t,r,a){if(6!==r.image.length)return;const l=N(t,r),h=r.source;n.bindTexture(e.TEXTURE_CUBE_MAP,t.__webglTexture,e.TEXTURE0+a);const u=i.get(h);if(h.version!==u.__version||!0===l){n.activeTexture(e.TEXTURE0+a),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,r.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,r.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE);const t=r.isCompressedTexture||r.image[0].isCompressedTexture,i=r.image[0]&&r.image[0].isDataTexture,d=[];for(let e=0;e<6;e++)d[e]=t||i?i?r.image[e].image:r.image[e]:x(r.image[e],!1,!0,c),d[e]=G(r,d[e]);const p=d[0],m=y(p)||o,f=s.convert(r.format,r.colorSpace),g=s.convert(r.type),v=b(r.internalFormat,f,g,r.colorSpace),_=o&&!0!==r.isVideoTexture,w=void 0===u.__version||!0===l;let E,A=T(r,p,m);if(U(e.TEXTURE_CUBE_MAP,r,m),t){_&&w&&n.texStorage2D(e.TEXTURE_CUBE_MAP,A,v,p.width,p.height);for(let t=0;t<6;t++){E=d[t].mipmaps;for(let i=0;i0&&A++,n.texStorage2D(e.TEXTURE_CUBE_MAP,A,v,d[0].width,d[0].height));for(let t=0;t<6;t++)if(i){_?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,d[t].width,d[t].height,f,g,d[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,v,d[t].width,d[t].height,0,f,g,d[t].data);for(let i=0;i0&&!1===H(t)){const i=d?l:[l];c.__webglMultisampledFramebuffer=e.createFramebuffer(),c.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,c.__webglMultisampledFramebuffer);for(let n=0;n0&&!1===H(t)){const r=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],s=t.width,a=t.height;let o=e.COLOR_BUFFER_BIT;const l=[],c=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,h=i.get(t),u=!0===t.isWebGLMultipleRenderTargets;if(u)for(let t=0;to+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&a<=o-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==o&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),null!==r&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1));null!==a&&(i=t.getPose(e.targetRaySpace,n),null===i&&null!==r&&(i=r),null!==i&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),a.matrixWorldNeedsUpdate=!0,i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Vo)))}return null!==a&&(a.visible=null!==i),null!==o&&(o.visible=null!==r),null!==l&&(l.visible=null!==s),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const n=new Go;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class jo extends Fn{constructor(e,t,n,i,r,s,a,o,l,c){if((c=void 0!==c?c:$e)!==$e&&c!==et)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===n&&c===$e&&(n=Xe),void 0===n&&c===et&&(n=Je),super(null,i,r,s,a,o,c,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==a?a:Fe,this.minFilter=void 0!==o?o:Fe,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}class Xo extends $t{constructor(e,t){super();const n=this;let i=null,r=1,s=null,a="local-floor",o=1,l=null,c=null,h=null,u=null,d=null,p=null;const m=t.getContextAttributes();let f=null,g=null;const v=[],_=[],x=new is;x.layers.enable(1),x.viewport=new zn;const y=new is;y.layers.enable(2),y.viewport=new zn;const M=[x,y],S=new Ho;S.layers.enable(1),S.layers.enable(2);let b=null,T=null;function w(e){const t=_.indexOf(e.inputSource);if(-1===t)return;const n=v[t];void 0!==n&&(n.update(e.inputSource,e.frame,l||s),n.dispatchEvent({type:e.type,data:e.inputSource}))}function E(){i.removeEventListener("select",w),i.removeEventListener("selectstart",w),i.removeEventListener("selectend",w),i.removeEventListener("squeeze",w),i.removeEventListener("squeezestart",w),i.removeEventListener("squeezeend",w),i.removeEventListener("end",E),i.removeEventListener("inputsourceschange",A);for(let e=0;e=0&&(_[i]=null,v[i].disconnect(n))}for(let t=0;t=_.length){_.push(n),i=e;break}if(null===_[e]){_[e]=n,i=e;break}}if(-1===i)break}const r=v[i];r&&r.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=v[e];return void 0===t&&(t=new Wo,v[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=v[e];return void 0===t&&(t=new Wo,v[e]=t),t.getGripSpace()},this.getHand=function(e){let t=v[e];return void 0===t&&(t=new Wo,v[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){r=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){a=e,!0===n.isPresenting&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||s},this.setReferenceSpace=function(e){l=e},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return h},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(c){if(i=c,null!==i){if(f=e.getRenderTarget(),i.addEventListener("select",w),i.addEventListener("selectstart",w),i.addEventListener("selectend",w),i.addEventListener("squeeze",w),i.addEventListener("squeezestart",w),i.addEventListener("squeezeend",w),i.addEventListener("end",E),i.addEventListener("inputsourceschange",A),!0!==m.xrCompatible&&await t.makeXRCompatible(),void 0===i.renderState.layers||!1===e.capabilities.isWebGL2){const n={antialias:void 0!==i.renderState.layers||m.antialias,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:r};d=new XRWebGLLayer(i,t,n),i.updateRenderState({baseLayer:d}),g=new Bn(d.framebufferWidth,d.framebufferHeight,{format:Qe,type:Ve,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil})}else{let n=null,s=null,a=null;m.depth&&(a=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=m.stencil?et:$e,s=m.stencil?Je:Xe);const o={colorFormat:t.RGBA8,depthFormat:a,scaleFactor:r};h=new XRWebGLBinding(i,t),u=h.createProjectionLayer(o),i.updateRenderState({layers:[u]}),g=new Bn(u.textureWidth,u.textureHeight,{format:Qe,type:Ve,depthTexture:new jo(u.textureWidth,u.textureHeight,s,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0});e.properties.get(g).__ignoreDepthValues=u.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(o),l=null,s=await i.requestReferenceSpace(a),I.setContext(i),I.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(null!==i)return i.environmentBlendMode};const R=new Vn,C=new Vn;function P(e,t){null===t?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===i)return;S.near=y.near=x.near=e.near,S.far=y.far=x.far=e.far,b===S.near&&T===S.far||(i.updateRenderState({depthNear:S.near,depthFar:S.far}),b=S.near,T=S.far);const t=e.parent,n=S.cameras;P(S,t);for(let e=0;e0&&(i.alphaTest.value=r.alphaTest);const s=t.get(r).envMap;if(s&&(i.envMap.value=s,i.flipEnvMap.value=s.isCubeTexture&&!1===s.isRenderTargetTexture?-1:1,i.reflectivity.value=r.reflectivity,i.ior.value=r.ior,i.refractionRatio.value=r.refractionRatio),r.lightMap){i.lightMap.value=r.lightMap;const t=!0===e.useLegacyLights?Math.PI:1;i.lightMapIntensity.value=r.lightMapIntensity*t,n(r.lightMap,i.lightMapTransform)}r.aoMap&&(i.aoMap.value=r.aoMap,i.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,i.aoMapTransform))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,$r(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,r,s,a,o){r.isMeshBasicMaterial||r.isMeshLambertMaterial?i(e,r):r.isMeshToonMaterial?(i(e,r),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,r)):r.isMeshPhongMaterial?(i(e,r),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,r)):r.isMeshStandardMaterial?(i(e,r),function(e,i){e.metalness.value=i.metalness,i.metalnessMap&&(e.metalnessMap.value=i.metalnessMap,n(i.metalnessMap,e.metalnessMapTransform));e.roughness.value=i.roughness,i.roughnessMap&&(e.roughnessMap.value=i.roughnessMap,n(i.roughnessMap,e.roughnessMapTransform));const r=t.get(i).envMap;r&&(e.envMapIntensity.value=i.envMapIntensity)}(e,r),r.isMeshPhysicalMaterial&&function(e,t,i){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform)));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===me&&e.clearcoatNormalScale.value.negate()));t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform)));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform)));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform));t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}(e,r,o)):r.isMeshMatcapMaterial?(i(e,r),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,r)):r.isMeshDepthMaterial?i(e,r):r.isMeshDistanceMaterial?(i(e,r),function(e,n){const i=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(i.matrixWorld),e.nearDistance.value=i.shadow.camera.near,e.farDistance.value=i.shadow.camera.far}(e,r)):r.isMeshNormalMaterial?i(e,r):r.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}(e,r),r.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,r)):r.isPointsMaterial?function(e,t,i,r){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*i,e.scale.value=.5*r,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r,s,a):r.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform));t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform));t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}(e,r):r.isShadowMaterial?(e.color.value.copy(r.color),e.opacity.value=r.opacity):r.isShaderMaterial&&(r.uniformsNeedUpdate=!1)}}}function Yo(e,t,n,i){let r={},s={},a=[];const o=n.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function l(e,t,n){const i=e.value;if(void 0===n[t]){if("number"==typeof i)n[t]=i;else{const e=Array.isArray(i)?i:[i],r=[];for(let t=0;t0){r=n%i;0!==r&&i-r-a.boundary<0&&(n+=i-r,s.__offset=n)}n+=a.storage}r=n%i,r>0&&(n+=i-r);e.__size=n,e.__cache={}}(n),d=function(t){const n=function(){for(let e=0;e0),u=!!n.morphAttributes.position,d=!!n.morphAttributes.normal,p=!!n.morphAttributes.color,m=i.toneMapped?_.toneMapping:Se,g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,v=void 0!==g?g.length:0,x=J.get(i),y=f.state.lights;if(!0===B&&(!0===k||e!==T)){const t=e===T&&i.id===b;ce.setState(i,e,t)}let M=!1;i.version===x.__version?x.needsLights&&x.lightsStateVersion!==y.state.version||x.outputColorSpace!==o||r.isInstancedMesh&&!1===x.instancing?M=!0:r.isInstancedMesh||!0!==x.instancing?r.isSkinnedMesh&&!1===x.skinning?M=!0:r.isSkinnedMesh||!0!==x.skinning?x.envMap!==l||!0===i.fog&&x.fog!==s?M=!0:void 0===x.numClippingPlanes||x.numClippingPlanes===ce.numPlanes&&x.numIntersection===ce.numIntersection?(x.vertexAlphas!==c||x.vertexTangents!==h||x.morphTargets!==u||x.morphNormals!==d||x.morphColors!==p||x.toneMapping!==m||!0===Y.isWebGL2&&x.morphTargetsCount!==v)&&(M=!0):M=!0:M=!0:M=!0:(M=!0,x.__version=i.version);let w=x.currentProgram;!0===M&&(w=ze(i,t,r));let E=!1,A=!1,R=!1;const C=w.getUniforms(),P=x.uniforms;Z.useProgram(w.program)&&(E=!0,A=!0,R=!0);i.id!==b&&(b=i.id,A=!0);if(E||T!==e){if(C.setValue(Me,"projectionMatrix",e.projectionMatrix),Y.logarithmicDepthBuffer&&C.setValue(Me,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),T!==e&&(T=e,A=!0,R=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshStandardMaterial||i.envMap){const t=C.map.cameraPosition;void 0!==t&&t.setValue(Me,W.setFromMatrixPosition(e.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial)&&C.setValue(Me,"isOrthographic",!0===e.isOrthographicCamera),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.isShadowMaterial||r.isSkinnedMesh)&&C.setValue(Me,"viewMatrix",e.matrixWorldInverse)}if(r.isSkinnedMesh){C.setOptional(Me,r,"bindMatrix"),C.setOptional(Me,r,"bindMatrixInverse");const e=r.skeleton;e&&(Y.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),C.setValue(Me,"boneTexture",e.boneTexture,Q),C.setValue(Me,"boneTextureSize",e.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}const D=n.morphAttributes;(void 0!==D.position||void 0!==D.normal||void 0!==D.color&&!0===Y.isWebGL2)&&de.update(r,n,w);(A||x.receiveShadow!==r.receiveShadow)&&(x.receiveShadow=r.receiveShadow,C.setValue(Me,"receiveShadow",r.receiveShadow));i.isMeshGouraudMaterial&&null!==i.envMap&&(P.envMap.value=l,P.flipEnvMap.value=l.isCubeTexture&&!1===l.isRenderTargetTexture?-1:1);A&&(C.setValue(Me,"toneMappingExposure",_.toneMappingExposure),x.needsLights&&(N=R,(U=P).ambientLightColor.needsUpdate=N,U.lightProbe.needsUpdate=N,U.directionalLights.needsUpdate=N,U.directionalLightShadows.needsUpdate=N,U.pointLights.needsUpdate=N,U.pointLightShadows.needsUpdate=N,U.spotLights.needsUpdate=N,U.spotLightShadows.needsUpdate=N,U.rectAreaLights.needsUpdate=N,U.hemisphereLights.needsUpdate=N),s&&!0===i.fog&&se.refreshFogUniforms(P,s),se.refreshMaterialUniforms(P,i,I,L,H),to.upload(Me,x.uniformsList,P,Q));var U,N;i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(to.upload(Me,x.uniformsList,P,Q),i.uniformsNeedUpdate=!1);i.isSpriteMaterial&&C.setValue(Me,"center",r.center);if(C.setValue(Me,"modelViewMatrix",r.modelViewMatrix),C.setValue(Me,"normalMatrix",r.normalMatrix),C.setValue(Me,"modelMatrix",r.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const e=i.uniformsGroups;for(let t=0,n=e.length;t0&&function(e,t,n,i){const r=Y.isWebGL2;null===H&&(H=new Bn(1,1,{generateMipmaps:!0,type:q.has("EXT_color_buffer_half_float")?Ye:Ve,minFilter:Ge,samples:r?4:0}));_.getDrawingBufferSize(V),r?H.setSize(V.x,V.y):H.setSize(un(V.x),un(V.y));const s=_.getRenderTarget();_.setRenderTarget(H),_.getClearColor(R),C=_.getClearAlpha(),C<1&&_.setClearColor(16777215,.5);_.clear();const a=_.toneMapping;_.toneMapping=Se,Oe(e,n,i),Q.updateMultisampleRenderTarget(H),Q.updateRenderTargetMipmap(H);let o=!1;for(let e=0,r=t.length;e0&&Oe(r,t,n),s.length>0&&Oe(s,t,n),a.length>0&&Oe(a,t,n),Z.buffers.depth.setTest(!0),Z.buffers.depth.setMask(!0),Z.buffers.color.setMask(!0),Z.setPolygonOffset(!1)}function Oe(e,t,n){const i=!0===t.isScene?t.overrideMaterial:null;for(let r=0,s=e.length;r0?v[v.length-1]:null,g.pop(),m=g.length>0?g[g.length-1]:null},this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return M},this.getRenderTarget=function(){return S},this.setRenderTargetTextures=function(e,t,n){J.get(e.texture).__webglTexture=t,J.get(e.depthTexture).__webglTexture=n;const i=J.get(e);i.__hasExternalTextures=!0,i.__hasExternalTextures&&(i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===q.has("WEBGL_multisampled_render_to_texture")&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){const n=J.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){S=e,y=t,M=n;let i=!0,r=null,s=!1,a=!1;if(e){const n=J.get(e);void 0!==n.__useDefaultFramebuffer?(Z.bindFramebuffer(Me.FRAMEBUFFER,null),i=!1):void 0===n.__webglFramebuffer?Q.setupRenderTarget(e):n.__hasExternalTextures&&Q.rebindTextures(e,J.get(e.texture).__webglTexture,J.get(e.depthTexture).__webglTexture);const o=e.texture;(o.isData3DTexture||o.isDataArrayTexture||o.isCompressedArrayTexture)&&(a=!0);const l=J.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(r=l[t],s=!0):r=Y.isWebGL2&&e.samples>0&&!1===Q.useMultisampledRTT(e)?J.get(e).__webglMultisampledFramebuffer:l,w.copy(e.viewport),E.copy(e.scissor),A=e.scissorTest}else w.copy(N).multiplyScalar(I).floor(),E.copy(O).multiplyScalar(I).floor(),A=F;if(Z.bindFramebuffer(Me.FRAMEBUFFER,r)&&Y.drawBuffers&&i&&Z.drawBuffers(e,r),Z.viewport(w),Z.scissor(E),Z.setScissorTest(A),s){const i=J.get(e.texture);Me.framebufferTexture2D(Me.FRAMEBUFFER,Me.COLOR_ATTACHMENT0,Me.TEXTURE_CUBE_MAP_POSITIVE_X+t,i.__webglTexture,n)}else if(a){const i=J.get(e.texture),r=t||0;Me.framebufferTextureLayer(Me.FRAMEBUFFER,Me.COLOR_ATTACHMENT0,i.__webglTexture,n||0,r)}b=-1},this.readRenderTargetPixels=function(e,t,n,i,r,s,a){if(!e||!e.isWebGLRenderTarget)return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let o=J.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(o=o[a]),o){Z.bindFramebuffer(Me.FRAMEBUFFER,o);try{const a=e.texture,o=a.format,l=a.type;if(o!==Qe&&_e.convert(o)!==Me.getParameter(Me.IMPLEMENTATION_COLOR_READ_FORMAT))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===Ye&&(q.has("EXT_color_buffer_half_float")||Y.isWebGL2&&q.has("EXT_color_buffer_float"));if(!(l===Ve||_e.convert(l)===Me.getParameter(Me.IMPLEMENTATION_COLOR_READ_TYPE)||l===qe&&(Y.isWebGL2||q.has("OES_texture_float")||q.has("WEBGL_color_buffer_float"))||c))return void console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-r&&Me.readPixels(t,n,i,r,_e.convert(o),_e.convert(l),s)}finally{const e=null!==S?J.get(S).__webglFramebuffer:null;Z.bindFramebuffer(Me.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){const i=Math.pow(2,-n),r=Math.floor(t.image.width*i),s=Math.floor(t.image.height*i);Q.setTexture2D(t,0),Me.copyTexSubImage2D(Me.TEXTURE_2D,n,0,0,e.x,e.y,r,s),Z.unbindTexture()},this.copyTextureToTexture=function(e,t,n,i=0){const r=t.image.width,s=t.image.height,a=_e.convert(n.format),o=_e.convert(n.type);Q.setTexture2D(n,0),Me.pixelStorei(Me.UNPACK_FLIP_Y_WEBGL,n.flipY),Me.pixelStorei(Me.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),Me.pixelStorei(Me.UNPACK_ALIGNMENT,n.unpackAlignment),t.isDataTexture?Me.texSubImage2D(Me.TEXTURE_2D,i,e.x,e.y,r,s,a,o,t.image.data):t.isCompressedTexture?Me.compressedTexSubImage2D(Me.TEXTURE_2D,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,a,t.mipmaps[0].data):Me.texSubImage2D(Me.TEXTURE_2D,i,e.x,e.y,a,o,t.image),0===i&&n.generateMipmaps&&Me.generateMipmap(Me.TEXTURE_2D),Z.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,i,r=0){if(_.isWebGL1Renderer)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const s=e.max.x-e.min.x+1,a=e.max.y-e.min.y+1,o=e.max.z-e.min.z+1,l=_e.convert(i.format),c=_e.convert(i.type);let h;if(i.isData3DTexture)Q.setTexture3D(i,0),h=Me.TEXTURE_3D;else{if(!i.isDataArrayTexture)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");Q.setTexture2DArray(i,0),h=Me.TEXTURE_2D_ARRAY}Me.pixelStorei(Me.UNPACK_FLIP_Y_WEBGL,i.flipY),Me.pixelStorei(Me.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),Me.pixelStorei(Me.UNPACK_ALIGNMENT,i.unpackAlignment);const u=Me.getParameter(Me.UNPACK_ROW_LENGTH),d=Me.getParameter(Me.UNPACK_IMAGE_HEIGHT),p=Me.getParameter(Me.UNPACK_SKIP_PIXELS),m=Me.getParameter(Me.UNPACK_SKIP_ROWS),f=Me.getParameter(Me.UNPACK_SKIP_IMAGES),g=n.isCompressedTexture?n.mipmaps[0]:n.image;Me.pixelStorei(Me.UNPACK_ROW_LENGTH,g.width),Me.pixelStorei(Me.UNPACK_IMAGE_HEIGHT,g.height),Me.pixelStorei(Me.UNPACK_SKIP_PIXELS,e.min.x),Me.pixelStorei(Me.UNPACK_SKIP_ROWS,e.min.y),Me.pixelStorei(Me.UNPACK_SKIP_IMAGES,e.min.z),n.isDataTexture||n.isData3DTexture?Me.texSubImage3D(h,r,t.x,t.y,t.z,s,a,o,l,c,g.data):n.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Me.compressedTexSubImage3D(h,r,t.x,t.y,t.z,s,a,o,l,g.data)):Me.texSubImage3D(h,r,t.x,t.y,t.z,s,a,o,l,c,g),Me.pixelStorei(Me.UNPACK_ROW_LENGTH,u),Me.pixelStorei(Me.UNPACK_IMAGE_HEIGHT,d),Me.pixelStorei(Me.UNPACK_SKIP_PIXELS,p),Me.pixelStorei(Me.UNPACK_SKIP_ROWS,m),Me.pixelStorei(Me.UNPACK_SKIP_IMAGES,f),0===r&&i.generateMipmaps&&Me.generateMipmap(h),Z.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?Q.setTextureCube(e,0):e.isData3DTexture?Q.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?Q.setTexture2DArray(e,0):Q.setTexture2D(e,0),Z.unbindTexture()},this.resetState=function(){y=0,M=0,S=null,Z.reset(),xe.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Jt}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: the property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Wt?Gt:Ht}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Gt?Wt:jt}}class Jo extends Ko{}Jo.prototype.isWebGL1Renderer=!0;class Qo{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new cr(e),this.density=t}clone(){return new Qo(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class $o{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new cr(e),this.near=t,this.far=n}clone(){return new $o(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class el extends Wi{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t}}class tl{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=Yt,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=sn()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,r=this.stride;ie.far||t.push({distance:o,point:al.clone(),uv:nr.getInterpolation(al,dl,pl,ml,fl,gl,vl,new fn),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function xl(e,t,n,i,r,s){cl.subVectors(e,n).addScalar(.5).multiply(i),void 0!==r?(hl.x=s*cl.x-r*cl.y,hl.y=r*cl.x+s*cl.y):hl.copy(cl),e.copy(t),e.x+=hl.x,e.y+=hl.y,e.applyMatrix4(ul)}const yl=new Vn,Ml=new Vn;class Sl extends Wi{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let e=0,n=t.length;e0){let n,i;for(n=1,i=t.length;n0){yl.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(yl);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){yl.setFromMatrixPosition(e.matrixWorld),Ml.setFromMatrixPosition(this.matrixWorld);const n=yl.distanceTo(Ml)/e.zoom;let i,r;for(t[0].object.visible=!0,i=1,r=t.length;i=e))break;t[i-1].object.visible=!1,t[i].object.visible=!0}for(this._currentLevel=i-1;io)continue;u.applyMatrix4(this.matrixWorld);const s=e.ray.origin.distanceTo(u);se.far||t.push({distance:s,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else{for(let n=Math.max(0,s.start),i=Math.min(m.count,s.start+s.count)-1;no)continue;u.applyMatrix4(this.matrixWorld);const i=e.ray.origin.distanceTo(u);ie.far||t.push({distance:i,point:h.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;er.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:n,index:t,face:null,object:a})}}class uc extends Fn{constructor(e,t,n,i,r,s,a,o,l){super(e,t,n,i,r,s,a,o,l),this.isVideoTexture=!0,this.minFilter=void 0!==s?s:ke,this.magFilter=void 0!==r?r:ke,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){c.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!1==="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class dc extends Fn{constructor(e,t,n,i,r,s,a,o,l,c,h,u){super(null,s,a,o,l,c,i,r,h,u),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class pc extends Fn{constructor(e,t,n,i,r,s,a,o,l){super(e,t,n,i,r,s,a,o,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class mc{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),r=0;t.push(0);for(let s=1;s<=e;s++)n=this.getPoint(s/e),r+=n.distanceTo(i),t.push(r),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const r=n.length;let s;s=t||e*n[r-1];let a,o=0,l=r-1;for(;o<=l;)if(i=Math.floor(o+(l-o)/2),a=n[i]-s,a<0)o=i+1;else{if(!(a>0)){l=i;break}l=i-1}if(i=l,n[i]===s)return i/(r-1);const c=n[i];return(i+(s-c)/(n[i+1]-c))/(r-1)}getTangent(e,t){const n=1e-4;let i=e-n,r=e+n;i<0&&(i=0),r>1&&(r=1);const s=this.getPoint(i),a=this.getPoint(r),o=t||(s.isVector2?new fn:new Vn);return o.copy(a).sub(s).normalize(),o}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new Vn,i=[],r=[],s=[],a=new Vn,o=new xi;for(let t=0;t<=e;t++){const n=t/e;i[t]=this.getTangentAt(n,new Vn)}r[0]=new Vn,s[0]=new Vn;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),h=Math.abs(i[0].y),u=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),h<=l&&(l=h,n.set(0,1,0)),u<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),r[0].crossVectors(i[0],a),s[0].crossVectors(i[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),s[t]=s[t-1].clone(),a.crossVectors(i[t-1],i[t]),a.length()>Number.EPSILON){a.normalize();const e=Math.acos(an(i[t-1].dot(i[t]),-1,1));r[t].applyMatrix4(o.makeRotationAxis(a,e))}s[t].crossVectors(i[t],r[t])}if(!0===t){let t=Math.acos(an(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(a.crossVectors(r[0],r[e]))>0&&(t=-t);for(let n=1;n<=e;n++)r[n].applyMatrix4(o.makeRotationAxis(i[n],t*n)),s[n].crossVectors(i[n],r[n])}return{tangents:i,normals:r,binormals:s}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class fc extends mc{constructor(e=0,t=0,n=1,i=1,r=0,s=2*Math.PI,a=!1,o=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=s,this.aClockwise=a,this.aRotation=o}getPoint(e,t){const n=t||new fn,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const s=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?a=i[(l-1)%r]:(_c.subVectors(i[0],i[1]).add(i[0]),a=_c);const h=i[l%r],u=i[(l+1)%r];if(this.closed||l+2i.length-2?i.length-1:s+1],h=i[s>i.length-3?i.length-1:s+2];return n.set(bc(a,o.x,l.x,c.x,h.x),bc(a,o.y,l.y,c.y,h.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const e=i[r]-n,s=this.curves[r],a=s.getLength(),o=0===a?0:1-e/a;return s.getPointAt(o,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.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 e=[];let t=0;for(let n=0,i=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Oc extends Pr{constructor(e=[new fn(0,-.5),new fn(.5,0),new fn(0,.5)],t=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=an(i,0,2*Math.PI);const r=[],s=[],a=[],o=[],l=[],c=1/t,h=new Vn,u=new fn,d=new Vn,p=new Vn,m=new Vn;let f=0,g=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:f=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,d.x=1*g,d.y=-f,d.z=0*g,m.copy(d),d.normalize(),o.push(d.x,d.y,d.z);break;case e.length-1:o.push(m.x,m.y,m.z);break;default:f=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,d.x=1*g,d.y=-f,d.z=0*g,p.copy(d),d.x+=m.x,d.y+=m.y,d.z+=m.z,d.normalize(),o.push(d.x,d.y,d.z),m.copy(p)}for(let r=0;r<=t;r++){const d=n+r*c*i,p=Math.sin(d),m=Math.cos(d);for(let n=0;n<=e.length-1;n++){h.x=e[n].x*p,h.y=e[n].y,h.z=e[n].x*m,s.push(h.x,h.y,h.z),u.x=r/t,u.y=n/(e.length-1),a.push(u.x,u.y);const i=o[3*n+0]*p,c=o[3*n+1],d=o[3*n+0]*m;l.push(i,c,d)}}for(let n=0;n0&&v(!0),t>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new Sr(h,3)),this.setAttribute("normal",new Sr(u,3)),this.setAttribute("uv",new Sr(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Bc(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class kc extends Bc{constructor(e=1,t=1,n=32,i=1,r=!1,s=0,a=2*Math.PI){super(0,e,t,n,i,r,s,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:s,thetaLength:a}}static fromJSON(e){return new kc(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Hc extends Pr{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const r=[],s=[];function a(e,t,n,i){const r=i+1,s=[];for(let i=0;i<=r;i++){s[i]=[];const a=e.clone().lerp(n,i/r),o=t.clone().lerp(n,i/r),l=r-i;for(let e=0;e<=l;e++)s[i][e]=0===e&&i===r?a:a.clone().lerp(o,e/l)}for(let e=0;e.9&&a<.1&&(t<.2&&(s[e+0]+=1),n<.2&&(s[e+2]+=1),i<.2&&(s[e+4]+=1))}}()}(),this.setAttribute("position",new Sr(r,3)),this.setAttribute("normal",new Sr(r.slice(),3)),this.setAttribute("uv",new Sr(s,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Hc(e.vertices,e.indices,e.radius,e.details)}}class Gc extends Hc{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Gc(e.radius,e.detail)}}const Vc=new Vn,Wc=new Vn,jc=new Vn,Xc=new nr;class qc extends Pr{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){const n=4,i=Math.pow(10,n),r=Math.cos(nn*t),s=e.getIndex(),a=e.getAttribute("position"),o=s?s.count:a.count,l=[0,0,0],c=["a","b","c"],h=new Array(3),u={},d=[];for(let e=0;e80*n){o=c=e[0],l=h=e[1];for(let t=n;tc&&(c=u),d>h&&(h=d);p=Math.max(c-o,h-l),p=0!==p?32767/p:0}return Qc(s,a,n,o,l,p,0),a};function Kc(e,t,n,i,r){let s,a;if(r===function(e,t,n,i){let r=0;for(let s=t,a=n-i;s0)for(s=t;s=t;s-=i)a=vh(s,e[s],e[s+1],a);return a&&uh(a,a.next)&&(_h(a),a=a.next),a}function Jc(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!uh(i,i.next)&&0!==hh(i.prev,i,i.next))i=i.next;else{if(_h(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function Qc(e,t,n,i,r,s,a){if(!e)return;!a&&s&&function(e,t,n,i){let r=e;do{0===r.z&&(r.z=ah(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,n,i,r,s,a,o,l,c=1;do{for(n=e,e=null,s=null,a=0;n;){for(a++,i=n,o=0,t=0;t0||l>0&&i;)0!==o&&(0===l||!i||n.z<=i.z)?(r=n,n=n.nextZ,o--):(r=i,i=i.nextZ,l--),s?s.nextZ=r:e=r,r.prevZ=s,s=r;n=i}s.nextZ=null,c*=2}while(a>1)}(r)}(e,i,r,s);let o,l,c=e;for(;e.prev!==e.next;)if(o=e.prev,l=e.next,s?eh(e,i,r,s):$c(e))t.push(o.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),_h(e),e=l.next,c=l.next;else if((e=l)===c){a?1===a?Qc(e=th(Jc(e),t,n),t,n,i,r,s,2):2===a&&nh(e,t,n,i,r,s):Qc(Jc(e),t,n,i,r,s,1);break}}function $c(e){const t=e.prev,n=e,i=e.next;if(hh(t,n,i)>=0)return!1;const r=t.x,s=n.x,a=i.x,o=t.y,l=n.y,c=i.y,h=rs?r>a?r:a:s>a?s:a,p=o>l?o>c?o:c:l>c?l:c;let m=i.next;for(;m!==t;){if(m.x>=h&&m.x<=d&&m.y>=u&&m.y<=p&&lh(r,o,s,l,a,c,m.x,m.y)&&hh(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function eh(e,t,n,i){const r=e.prev,s=e,a=e.next;if(hh(r,s,a)>=0)return!1;const o=r.x,l=s.x,c=a.x,h=r.y,u=s.y,d=a.y,p=ol?o>c?o:c:l>c?l:c,g=h>u?h>d?h:d:u>d?u:d,v=ah(p,m,t,n,i),_=ah(f,g,t,n,i);let x=e.prevZ,y=e.nextZ;for(;x&&x.z>=v&&y&&y.z<=_;){if(x.x>=p&&x.x<=f&&x.y>=m&&x.y<=g&&x!==r&&x!==a&&lh(o,h,l,u,c,d,x.x,x.y)&&hh(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,y.x>=p&&y.x<=f&&y.y>=m&&y.y<=g&&y!==r&&y!==a&&lh(o,h,l,u,c,d,y.x,y.y)&&hh(y.prev,y,y.next)>=0)return!1;y=y.nextZ}for(;x&&x.z>=v;){if(x.x>=p&&x.x<=f&&x.y>=m&&x.y<=g&&x!==r&&x!==a&&lh(o,h,l,u,c,d,x.x,x.y)&&hh(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;y&&y.z<=_;){if(y.x>=p&&y.x<=f&&y.y>=m&&y.y<=g&&y!==r&&y!==a&&lh(o,h,l,u,c,d,y.x,y.y)&&hh(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function th(e,t,n){let i=e;do{const r=i.prev,s=i.next.next;!uh(r,s)&&dh(r,i,i.next,s)&&fh(r,s)&&fh(s,r)&&(t.push(r.i/n|0),t.push(i.i/n|0),t.push(s.i/n|0),_h(i),_h(i.next),i=e=s),i=i.next}while(i!==e);return Jc(i)}function nh(e,t,n,i,r,s){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&ch(a,e)){let o=gh(a,e);return a=Jc(a,a.next),o=Jc(o,o.next),Qc(a,t,n,i,r,s,0),void Qc(o,t,n,i,r,s,0)}e=e.next}a=a.next}while(a!==e)}function ih(e,t){return e.x-t.x}function rh(e,t){const n=function(e,t){let n,i=t,r=-Infinity;const s=e.x,a=e.y;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){const e=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=s&&e>r&&(r=e,n=i.x=i.x&&i.x>=l&&s!==i.x&&lh(an.x||i.x===n.x&&sh(n,i)))&&(n=i,u=h)),i=i.next}while(i!==o);return n}(e,t);if(!n)return t;const i=gh(n,e);return Jc(i,i.next),Jc(n,n.next)}function sh(e,t){return hh(e.prev,e,t.prev)<0&&hh(t.next,e,e.next)<0}function ah(e,t,n,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function oh(e){let t=e,n=e;do{(t.x=(e-a)*(s-o)&&(e-a)*(i-o)>=(n-a)*(t-o)&&(n-a)*(s-o)>=(r-a)*(i-o)}function ch(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&dh(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(fh(e,t)&&fh(t,e)&&function(e,t){let n=e,i=!1;const r=(e.x+t.x)/2,s=(e.y+t.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&r<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)&&(hh(e.prev,e,t.prev)||hh(e,t.prev,t))||uh(e,t)&&hh(e.prev,e,e.next)>0&&hh(t.prev,t,t.next)>0)}function hh(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function uh(e,t){return e.x===t.x&&e.y===t.y}function dh(e,t,n,i){const r=mh(hh(e,t,n)),s=mh(hh(e,t,i)),a=mh(hh(n,i,e)),o=mh(hh(n,i,t));return r!==s&&a!==o||(!(0!==r||!ph(e,n,t))||(!(0!==s||!ph(e,i,t))||(!(0!==a||!ph(n,e,i))||!(0!==o||!ph(n,t,i)))))}function ph(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function mh(e){return e>0?1:e<0?-1:0}function fh(e,t){return hh(e.prev,e,e.next)<0?hh(e,t,e.next)>=0&&hh(e,e.prev,t)>=0:hh(e,t,e.prev)<0||hh(e,e.next,t)<0}function gh(e,t){const n=new xh(e.i,e.x,e.y),i=new xh(t.i,t.x,t.y),r=e.next,s=t.prev;return e.next=t,t.prev=e,n.next=r,r.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function vh(e,t,n,i){const r=new xh(e,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function _h(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function xh(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class yh{static area(e){const t=e.length;let n=0;for(let i=t-1,r=0;r2&&e[t-1].equals(e[0])&&e.pop()}function Sh(e,t){for(let n=0;nNumber.EPSILON){const u=Math.sqrt(h),d=Math.sqrt(l*l+c*c),p=t.x-o/u,m=t.y+a/u,f=((n.x-c/d-p)*c-(n.y+l/d-m)*l)/(a*c-o*l);i=p+a*f-e.x,r=m+o*f-e.y;const g=i*i+r*r;if(g<=2)return new fn(i,r);s=Math.sqrt(g/2)}else{let e=!1;a>Number.EPSILON?l>Number.EPSILON&&(e=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(o)===Math.sign(c)&&(e=!0),e?(i=-o,r=a,s=Math.sqrt(h)):(i=a,r=o,s=Math.sqrt(h/2))}return new fn(i/s,r/s)}const L=[];for(let e=0,t=E.length,n=t-1,i=e+1;e=0;e--){const t=e/p,n=h*Math.cos(t*Math.PI/2),i=u*Math.sin(t*Math.PI/2)+d;for(let e=0,t=E.length;e=0;){const i=n;let r=n-1;r<0&&(r=e.length-1);for(let e=0,n=o+2*p;e0)&&d.push(t,r,l),(e!==n-1||o0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Hh extends rr{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new cr(16777215),this.specular=new cr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new cr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new fn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=xe,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(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Gh extends rr{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new cr(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new cr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new fn(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(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Vh extends rr{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new fn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Wh extends rr{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new cr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new cr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new fn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=xe,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(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class jh extends rr{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new cr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new fn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Xh extends ql{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function qh(e,t,n){return Zh(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)}function Yh(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function Zh(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Kh(e){const t=e.length,n=new Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort((function(t,n){return e[t]-e[n]})),n}function Jh(e,t,n){const i=e.length,r=new e.constructor(i);for(let s=0,a=0;a!==i;++s){const i=n[s]*t;for(let n=0;n!==t;++n)r[a++]=e[i+n]}return r}function Qh(e,t,n,i){let r=1,s=e[0];for(;void 0!==s&&void 0===s[i];)s=e[r++];if(void 0===s)return;let a=s[i];if(void 0!==a)if(Array.isArray(a))do{a=s[i],void 0!==a&&(t.push(s.time),n.push.apply(n,a)),s=e[r++]}while(void 0!==s);else if(void 0!==a.toArray)do{a=s[i],void 0!==a&&(t.push(s.time),a.toArray(n,n.length)),s=e[r++]}while(void 0!==s);else do{a=s[i],void 0!==a&&(t.push(s.time),n.push(a)),s=e[r++]}while(void 0!==s)}const $h={arraySlice:qh,convertArray:Yh,isTypedArray:Zh,getKeyframeOrder:Kh,sortedArray:Jh,flattenJSON:Qh,subclip:function(e,t,n,i,r=30){const s=e.clone();s.name=t;const a=[];for(let e=0;e=i)){l.push(t.times[e]);for(let n=0;ns.tracks[e].times[0]&&(o=s.tracks[e].times[0]);for(let e=0;e=i.times[u]){const e=u*l+o,t=e+l-o;d=qh(i.values,e,t)}else{const e=i.createInterpolant(),t=o,n=l-o;e.evaluate(s),d=qh(e.resultBuffer,t,n)}if("quaternion"===r){(new Gn).fromArray(d).normalize().conjugate().toArray(d)}const p=a.times.length;for(let e=0;e=r)break e;{const a=t[1];e=r)break t}s=n,n=0}}for(;n>>1;et;)--s;if(++s,0!==r||s!==i){r>=s&&(s=Math.max(s,1),r=s-1);const e=this.getValueSize();this.times=qh(n,r,s),this.values=qh(this.values,r*e,s*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,r=n.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let s=null;for(let t=0;t!==r;t++){const i=n[t];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,i),e=!1;break}if(null!==s&&s>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,i,s),e=!1;break}s=i}if(void 0!==i&&Zh(i))for(let t=0,n=i.length;t!==n;++t){const n=i[t];if(isNaN(n)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}return e}optimize(){const e=qh(this.times),t=qh(this.values),n=this.getValueSize(),i=this.getInterpolation()===Nt,r=e.length-1;let s=1;for(let a=1;a0){e[s]=e[r];for(let e=r*n,i=s*n,a=0;a!==n;++a)t[i+a]=t[e+a];++s}return s!==e.length?(this.times=qh(e,0,s),this.values=qh(t,0,s*n)):(this.times=e,this.values=t),this}clone(){const e=qh(this.times,0),t=qh(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}ru.prototype.TimeBufferType=Float32Array,ru.prototype.ValueBufferType=Float32Array,ru.prototype.DefaultInterpolation=Ut;class su extends ru{}su.prototype.ValueTypeName="bool",su.prototype.ValueBufferType=Array,su.prototype.DefaultInterpolation=Dt,su.prototype.InterpolantFactoryMethodLinear=void 0,su.prototype.InterpolantFactoryMethodSmooth=void 0;class au extends ru{}au.prototype.ValueTypeName="color";class ou extends ru{}ou.prototype.ValueTypeName="number";class lu extends eu{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const r=this.resultBuffer,s=this.sampleValues,a=this.valueSize,o=(n-t)/(i-t);let l=e*a;for(let e=l+a;l!==e;l+=4)Gn.slerpFlat(r,0,s,l-a,s,l,o);return r}}class cu extends ru{InterpolantFactoryMethodLinear(e){return new lu(this.times,this.values,this.getValueSize(),e)}}cu.prototype.ValueTypeName="quaternion",cu.prototype.DefaultInterpolation=Ut,cu.prototype.InterpolantFactoryMethodSmooth=void 0;class hu extends ru{}hu.prototype.ValueTypeName="string",hu.prototype.ValueBufferType=Array,hu.prototype.DefaultInterpolation=Dt,hu.prototype.InterpolantFactoryMethodLinear=void 0,hu.prototype.InterpolantFactoryMethodSmooth=void 0;class uu extends ru{}uu.prototype.ValueTypeName="vector";class du{constructor(e,t=-1,n,i=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=sn(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let e=0,r=n.length;e!==r;++e)t.push(pu(n[e]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,i=n.length;e!==i;++e)t.push(ru.toJSON(n[e]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const r=t.length,s=[];for(let e=0;e1){const e=s[1];let t=i[e];t||(i[e]=t=[]),t.push(n)}}const s=[];for(const e in i)s.push(this.CreateFromMorphTargetSequence(e,i[e],t,n));return s}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,i,r){if(0!==n.length){const s=[],a=[];Qh(n,s,a,i),0!==s.length&&r.push(new e(t,s,a))}},i=[],r=e.name||"default",s=e.fps||30,a=e.blendMode;let o=e.length||-1;const l=e.hierarchy||[];for(let e=0;e{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==_u[e])return void _u[e].push({onLoad:t,onProgress:n,onError:i});_u[e]=[],_u[e].push({onLoad:t,onProgress:n,onError:i});const s=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,o=this.responseType;fetch(s).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const n=_u[e],i=t.body.getReader(),r=t.headers.get("Content-Length")||t.headers.get("X-File-Size"),s=r?parseInt(r):0,a=0!==s;let o=0;const l=new ReadableStream({start(e){!function t(){i.read().then((({done:i,value:r})=>{if(i)e.close();else{o+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:a,loaded:o,total:s});for(let e=0,t=n.length;e{switch(o){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,a)));case"json":return e.json();default:if(void 0===a)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(a),n=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(n);return e.arrayBuffer().then((e=>i.decode(e)))}}})).then((t=>{mu.add(e,t);const n=_u[e];delete _u[e];for(let e=0,i=n.length;e{const n=_u[e];if(void 0===n)throw this.manager.itemError(e),t;delete _u[e];for(let e=0,i=n.length;e{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Mu extends vu{constructor(e){super(e)}load(e,t,n,i){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const r=this,s=mu.get(e);if(void 0!==s)return r.manager.itemStart(e),setTimeout((function(){t&&t(s),r.manager.itemEnd(e)}),0),s;const a=Mn("img");function o(){c(),mu.add(e,this),t&&t(this),r.manager.itemEnd(e)}function l(t){c(),i&&i(t),r.manager.itemError(e),r.manager.itemEnd(e)}function c(){a.removeEventListener("load",o,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",o,!1),a.addEventListener("error",l,!1),"data:"!==e.slice(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),r.manager.itemStart(e),a.src=e,a}}class Su extends vu{constructor(e){super(e)}load(e,t,n,i){const r=new Fn,s=new Mu(this.manager);return s.setCrossOrigin(this.crossOrigin),s.setPath(this.path),s.load(e,(function(e){r.image=e,r.needsUpdate=!0,void 0!==t&&t(r)}),n,i),r}}class bu extends Wi{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new cr(e),this.intensity=t}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}class Tu extends bu{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Wi.DEFAULT_UP),this.updateMatrix(),this.groundColor=new cr(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const wu=new xi,Eu=new Vn,Au=new Vn;class Ru{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new fn(512,512),this.map=null,this.mapPass=null,this.matrix=new xi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new ms,this._frameExtents=new fn(1,1),this._viewportCount=1,this._viewports=[new zn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Eu.setFromMatrixPosition(e.matrixWorld),t.position.copy(Eu),Au.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Au),t.updateMatrixWorld(),wu.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(wu),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(wu)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class Cu extends Ru{constructor(){super(new is(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const t=this.camera,n=2*rn*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,r=e.distance||t.far;n===t.fov&&i===t.aspect&&r===t.far||(t.fov=n,t.aspect=i,t.far=r,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Pu extends bu{constructor(e,t,n=0,i=Math.PI/3,r=0,s=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Wi.DEFAULT_UP),this.updateMatrix(),this.target=new Wi,this.distance=n,this.angle=i,this.penumbra=r,this.decay=s,this.map=null,this.shadow=new Cu}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const Lu=new xi,Iu=new Vn,Du=new Vn;class Uu extends Ru{constructor(){super(new is(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new fn(4,2),this._viewportCount=6,this._viewports=[new zn(2,1,1,1),new zn(0,1,1,1),new zn(3,1,1,1),new zn(1,1,1,1),new zn(3,0,1,1),new zn(1,0,1,1)],this._cubeDirections=[new Vn(1,0,0),new Vn(-1,0,0),new Vn(0,0,1),new Vn(0,0,-1),new Vn(0,1,0),new Vn(0,-1,0)],this._cubeUps=[new Vn(0,1,0),new Vn(0,1,0),new Vn(0,1,0),new Vn(0,1,0),new Vn(0,0,1),new Vn(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,r=e.distance||n.far;r!==n.far&&(n.far=r,n.updateProjectionMatrix()),Iu.setFromMatrixPosition(e.matrixWorld),n.position.copy(Iu),Du.copy(n.position),Du.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(Du),n.updateMatrixWorld(),i.makeTranslation(-Iu.x,-Iu.y,-Iu.z),Lu.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Lu)}}class Nu extends bu{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new Uu}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class Ou extends Ru{constructor(){super(new Rs(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Fu extends bu{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Wi.DEFAULT_UP),this.updateMatrix(),this.target=new Wi,this.shadow=new Ou}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class zu extends bu{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Bu extends bu{constructor(e,t,n=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class ku{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new Vn)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,i=e.y,r=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.282095),t.addScaledVector(s[1],.488603*i),t.addScaledVector(s[2],.488603*r),t.addScaledVector(s[3],.488603*n),t.addScaledVector(s[4],n*i*1.092548),t.addScaledVector(s[5],i*r*1.092548),t.addScaledVector(s[6],.315392*(3*r*r-1)),t.addScaledVector(s[7],n*r*1.092548),t.addScaledVector(s[8],.546274*(n*n-i*i)),t}getIrradianceAt(e,t){const n=e.x,i=e.y,r=e.z,s=this.coefficients;return t.copy(s[0]).multiplyScalar(.886227),t.addScaledVector(s[1],1.023328*i),t.addScaledVector(s[2],1.023328*r),t.addScaledVector(s[3],1.023328*n),t.addScaledVector(s[4],.858086*n*i),t.addScaledVector(s[5],.858086*i*r),t.addScaledVector(s[6],.743125*r*r-.247708),t.addScaledVector(s[7],.858086*n*r),t.addScaledVector(s[8],.429043*(n*n-i*i)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(e,t+3*i);return this}toArray(e=[],t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(e,t+3*i);return e}static getBasisAt(e,t){const n=e.x,i=e.y,r=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*r,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*r,t[6]=.315392*(3*r*r-1),t[7]=1.092548*n*r,t[8]=.546274*(n*n-i*i)}}class Hu extends bu{constructor(e=new ku,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class Gu extends vu{constructor(e){super(e),this.textures={}}load(e,t,n,i){const r=this,s=new yu(r.manager);s.setPath(r.path),s.setRequestHeader(r.requestHeader),s.setWithCredentials(r.withCredentials),s.load(e,(function(n){try{t(r.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),n,i)}parse(e){const t=this.textures;function n(e){return void 0===t[e]&&console.warn("THREE.MaterialLoader: Undefined texture",e),t[e]}const i=Gu.createMaterialFromType(e.type);if(void 0!==e.uuid&&(i.uuid=e.uuid),void 0!==e.name&&(i.name=e.name),void 0!==e.color&&void 0!==i.color&&i.color.setHex(e.color),void 0!==e.roughness&&(i.roughness=e.roughness),void 0!==e.metalness&&(i.metalness=e.metalness),void 0!==e.sheen&&(i.sheen=e.sheen),void 0!==e.sheenColor&&(i.sheenColor=(new cr).setHex(e.sheenColor)),void 0!==e.sheenRoughness&&(i.sheenRoughness=e.sheenRoughness),void 0!==e.emissive&&void 0!==i.emissive&&i.emissive.setHex(e.emissive),void 0!==e.specular&&void 0!==i.specular&&i.specular.setHex(e.specular),void 0!==e.specularIntensity&&(i.specularIntensity=e.specularIntensity),void 0!==e.specularColor&&void 0!==i.specularColor&&i.specularColor.setHex(e.specularColor),void 0!==e.shininess&&(i.shininess=e.shininess),void 0!==e.clearcoat&&(i.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(i.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.iridescence&&(i.iridescence=e.iridescence),void 0!==e.iridescenceIOR&&(i.iridescenceIOR=e.iridescenceIOR),void 0!==e.iridescenceThicknessRange&&(i.iridescenceThicknessRange=e.iridescenceThicknessRange),void 0!==e.transmission&&(i.transmission=e.transmission),void 0!==e.thickness&&(i.thickness=e.thickness),void 0!==e.attenuationDistance&&(i.attenuationDistance=e.attenuationDistance),void 0!==e.attenuationColor&&void 0!==i.attenuationColor&&i.attenuationColor.setHex(e.attenuationColor),void 0!==e.anisotropy&&(i.anisotropy=e.anisotropy),void 0!==e.anisotropyRotation&&(i.anisotropyRotation=e.anisotropyRotation),void 0!==e.fog&&(i.fog=e.fog),void 0!==e.flatShading&&(i.flatShading=e.flatShading),void 0!==e.blending&&(i.blending=e.blending),void 0!==e.combine&&(i.combine=e.combine),void 0!==e.side&&(i.side=e.side),void 0!==e.shadowSide&&(i.shadowSide=e.shadowSide),void 0!==e.opacity&&(i.opacity=e.opacity),void 0!==e.transparent&&(i.transparent=e.transparent),void 0!==e.alphaTest&&(i.alphaTest=e.alphaTest),void 0!==e.alphaHash&&(i.alphaHash=e.alphaHash),void 0!==e.depthTest&&(i.depthTest=e.depthTest),void 0!==e.depthWrite&&(i.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(i.colorWrite=e.colorWrite),void 0!==e.stencilWrite&&(i.stencilWrite=e.stencilWrite),void 0!==e.stencilWriteMask&&(i.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(i.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(i.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(i.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(i.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(i.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(i.stencilZPass=e.stencilZPass),void 0!==e.wireframe&&(i.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(i.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(i.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(i.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(i.rotation=e.rotation),1!==e.linewidth&&(i.linewidth=e.linewidth),void 0!==e.dashSize&&(i.dashSize=e.dashSize),void 0!==e.gapSize&&(i.gapSize=e.gapSize),void 0!==e.scale&&(i.scale=e.scale),void 0!==e.polygonOffset&&(i.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(i.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(i.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.dithering&&(i.dithering=e.dithering),void 0!==e.alphaToCoverage&&(i.alphaToCoverage=e.alphaToCoverage),void 0!==e.premultipliedAlpha&&(i.premultipliedAlpha=e.premultipliedAlpha),void 0!==e.forceSinglePass&&(i.forceSinglePass=e.forceSinglePass),void 0!==e.visible&&(i.visible=e.visible),void 0!==e.toneMapped&&(i.toneMapped=e.toneMapped),void 0!==e.userData&&(i.userData=e.userData),void 0!==e.vertexColors&&("number"==typeof e.vertexColors?i.vertexColors=e.vertexColors>0:i.vertexColors=e.vertexColors),void 0!==e.uniforms)for(const t in e.uniforms){const r=e.uniforms[t];switch(i.uniforms[t]={},r.type){case"t":i.uniforms[t].value=n(r.value);break;case"c":i.uniforms[t].value=(new cr).setHex(r.value);break;case"v2":i.uniforms[t].value=(new fn).fromArray(r.value);break;case"v3":i.uniforms[t].value=(new Vn).fromArray(r.value);break;case"v4":i.uniforms[t].value=(new zn).fromArray(r.value);break;case"m3":i.uniforms[t].value=(new gn).fromArray(r.value);break;case"m4":i.uniforms[t].value=(new xi).fromArray(r.value);break;default:i.uniforms[t].value=r.value}}if(void 0!==e.defines&&(i.defines=e.defines),void 0!==e.vertexShader&&(i.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(i.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(i.glslVersion=e.glslVersion),void 0!==e.extensions)for(const t in e.extensions)i.extensions[t]=e.extensions[t];if(void 0!==e.lights&&(i.lights=e.lights),void 0!==e.clipping&&(i.clipping=e.clipping),void 0!==e.size&&(i.size=e.size),void 0!==e.sizeAttenuation&&(i.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(i.map=n(e.map)),void 0!==e.matcap&&(i.matcap=n(e.matcap)),void 0!==e.alphaMap&&(i.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(i.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(i.bumpScale=e.bumpScale),void 0!==e.normalMap&&(i.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(i.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),i.normalScale=(new fn).fromArray(t)}return void 0!==e.displacementMap&&(i.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(i.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(i.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(i.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(i.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(i.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(i.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(i.specularMap=n(e.specularMap)),void 0!==e.specularIntensityMap&&(i.specularIntensityMap=n(e.specularIntensityMap)),void 0!==e.specularColorMap&&(i.specularColorMap=n(e.specularColorMap)),void 0!==e.envMap&&(i.envMap=n(e.envMap)),void 0!==e.envMapIntensity&&(i.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(i.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(i.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(i.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(i.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(i.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(i.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(i.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(i.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(i.clearcoatNormalScale=(new fn).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(i.iridescenceMap=n(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(i.transmissionMap=n(e.transmissionMap)),void 0!==e.thicknessMap&&(i.thicknessMap=n(e.thicknessMap)),void 0!==e.anisotropyMap&&(i.anisotropyMap=n(e.anisotropyMap)),void 0!==e.sheenColorMap&&(i.sheenColorMap=n(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){return new{ShadowMaterial:Fh,SpriteMaterial:rl,RawShaderMaterial:zh,ShaderMaterial:ts,PointsMaterial:rc,MeshPhysicalMaterial:kh,MeshStandardMaterial:Bh,MeshPhongMaterial:Hh,MeshToonMaterial:Gh,MeshNormalMaterial:Vh,MeshLambertMaterial:Wh,MeshDepthMaterial:No,MeshDistanceMaterial:Oo,MeshBasicMaterial:ur,MeshMatcapMaterial:jh,LineDashedMaterial:Xh,LineBasicMaterial:ql,Material:rr}[e]}}class Vu{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,i=e.length;n0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(n[e]!==n[e+t]){a.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let e=n,r=i;e!==r;++e)t[e]=t[i+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let i=0;i!==r;++i)e[t+i]=e[n+i]}_slerp(e,t,n,i){Gn.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,r){const s=this._workIndex*r;Gn.multiplyQuaternionsFlat(e,s,e,t,e,n),Gn.slerpFlat(e,t,e,t,e,s,i)}_lerp(e,t,n,i,r){const s=1-i;for(let a=0;a!==r;++a){const r=t+a;e[r]=e[r]*s+e[n+a]*i}}_lerpAdditive(e,t,n,i,r){for(let s=0;s!==r;++s){const r=t+s;e[r]=e[r]+e[n+s]*i}}}const fd="\\[\\]\\.:\\/",gd=new RegExp("["+fd+"]","g"),vd="[^"+fd+"]",_d="[^"+fd.replace("\\.","")+"]",xd=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",vd)+/(WCOD+)?/.source.replace("WCOD",_d)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",vd)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",vd)+"$"),yd=["material","materials","bones","map"];class Md{constructor(e,t,n){this.path=t,this.parsedPath=n||Md.parseTrackName(t),this.node=Md.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Md.Composite(e,t,n):new Md(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(gd,"")}static parseTrackName(e){const t=xd.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const e=n.nodeName.substring(i+1);-1!==yd.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){const n=function(e){for(let i=0;i0){const e=this._interpolants,t=this._propertyBindings;if(this.blendMode===kt)for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(s),t[n].accumulateAdditive(a);else for(let n=0,r=e.length;n!==r;++n)e[n].evaluate(s),t[n].accumulate(i,a)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(null!==n){t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let i=this.time+e,r=this._loopCount;const s=2202===n;if(0===e)return-1===r?i:s&&1==(1&r)?t-i:i;if(n===It){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else{if(!(i<0)){this.time=i;break e}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,s)):this._setEndings(0===this.repetitions,!0,s)),i>=t||i<0){const n=Math.floor(i/t);i-=t*n,r+=Math.abs(n);const a=this.repetitions-r;if(a<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===a){const t=e<0;this._setEndings(t,!t,s)}else this._setEndings(!1,!1,s);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:n})}}else this.time=i;if(s&&1==(1&r))return t-i}return i}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=Ft,i.endingEnd=Ft):(i.endingStart=e?this.zeroSlopeAtStart?Ft:Ot:zt,i.endingEnd=t?this.zeroSlopeAtEnd?Ft:Ot:zt)}_scheduleFading(e,t,n){const i=this._mixer,r=i.time;let s=this._weightInterpolant;null===s&&(s=i._lendControlInterpolant(),this._weightInterpolant=s);const a=s.parameterPositions,o=s.sampleValues;return a[0]=r,o[0]=t,a[1]=r+e,o[1]=n,this}}const bd=new Float32Array(1);class Td extends $t{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,r=i.length,s=e._propertyBindings,a=e._interpolants,o=n.uuid,l=this._bindingsByRootAndName;let c=l[o];void 0===c&&(c={},l[o]=c);for(let e=0;e!==r;++e){const r=i[e],l=r.name;let h=c[l];if(void 0!==h)++h.referenceCount,s[e]=h;else{if(h=s[e],void 0!==h){null===h._cacheIndex&&(++h.referenceCount,this._addInactiveBinding(h,o,l));continue}const i=t&&t._propertyBindings[e].binding.parsedPath;h=new md(Md.create(n,l,i),r.ValueTypeName,r.getValueSize()),++h.referenceCount,this._addInactiveBinding(h,o,l),s[e]=h}a[e].resultBuffer=h.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return null!==t&&t=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,r=Math.sign(e),s=this._accuIndex^=1;for(let a=0;a!==n;++a){t[a]._update(i,e,r,s)}const a=this._bindings,o=this._nActiveBindings;for(let e=0;e!==o;++e)a[e].apply(s);return this}setTime(e){this.time=0;for(let e=0;eNumber.EPSILON){if(l<0&&(n=t[s],o=-o,a=t[r],l=-l),e.ya.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{const t=l*(e.x-n.x)-o*(e.y-n.y);if(0===t)return!0;if(t<0)continue;i=!i}}else{if(e.y!==n.y)continue;if(a.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=a.x)return!0}}return i}const n=yh.isClockWise,i=this.subPaths;if(0===i.length)return[];let r,s,a;const o=[];if(1===i.length)return s=i[0],a=new Yc,a.curves=s.curves,o.push(a),o;let l=!n(i[0].getPoints());l=e?!l:l;const c=[],h=[];let u,d,p=[],m=0;h[m]=void 0,p[m]=[];for(let t=0,a=i.length;t1){let e=!1,n=0;for(let e=0,t=h.length;e0&&!1===e&&(p=c)}for(let e=0,t=h.length;e=r){const s=r++,c=e[s];t[c.uuid]=l,e[l]=c,t[o]=s,e[s]=a;for(let e=0,t=i;e!==t;++e){const t=n[e],i=t[s],r=t[l];t[l]=i,t[s]=r}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let r=this.nCachedObjects_,s=e.length;for(let a=0,o=arguments.length;a!==o;++a){const o=arguments[a].uuid,l=t[o];if(void 0!==l)if(delete t[o],l0&&(t[a.uuid]=l),e[l]=a,e.pop();for(let e=0,t=i;e!==t;++e){const t=n[e];t[l]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const r=this._bindings;if(void 0!==i)return r[i];const s=this._paths,a=this._parsedPaths,o=this._objects,l=o.length,c=this.nCachedObjects_,h=new Array(l);i=r.length,n[e]=i,s.push(e),a.push(t),r.push(h);for(let n=c,i=o.length;n!==i;++n){const i=o[n];h[n]=new Md(i,e,t)}return h}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){const i=this._paths,r=this._parsedPaths,s=this._bindings,a=s.length-1,o=s[a];t[e[a]]=n,s[n]=o,s.pop(),r[n]=r[a],r.pop(),i[n]=i[a],i.pop()}}},AnimationUtils:$h,ArcCurve:gc,ArrayCamera:Ho,ArrowHelper:class extends Wi{constructor(e=new Vn(0,0,1),t=new Vn(0,0,0),n=1,i=16776960,r=.2*n,s=.2*r){super(),this.type="ArrowHelper",void 0===Jd&&(Jd=new Pr,Jd.setAttribute("position",new Sr([0,0,0,0,1,0],3)),Qd=new Bc(0,.5,1,5,1),Qd.translate(0,-.5,0)),this.position.copy(t),this.line=new $l(Jd,new ql({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Yr(Qd,new ur({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,r,s)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Kd.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Kd,t)}}setLength(e,t=.2*e,n=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},Audio:cd,AudioAnalyser:class{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let n=0;nthis.max.x||e.ythis.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ld).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},Box3:Xn,Box3Helper:class extends nc{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Pr;i.setIndex(new xr(n,1)),i.setAttribute("position",new Sr([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(i,new ql({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}},BoxGeometry:Kr,BoxHelper:class extends nc{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),r=new Pr;r.setIndex(new xr(n,1)),r.setAttribute("position",new xr(i,3)),super(r,new ql({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(void 0!==e&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&Zd.setFromObject(this.object),Zd.isEmpty())return;const t=Zd.min,n=Zd.max,i=this.geometry.attributes.position,r=i.array;r[0]=n.x,r[1]=n.y,r[2]=n.z,r[3]=t.x,r[4]=n.y,r[5]=n.z,r[6]=t.x,r[7]=t.y,r[8]=n.z,r[9]=n.x,r[10]=t.y,r[11]=n.z,r[12]=n.x,r[13]=n.y,r[14]=t.z,r[15]=t.x,r[16]=n.y,r[17]=t.z,r[18]=t.x,r[19]=t.y,r[20]=t.z,r[21]=n.x,r[22]=t.y,r[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},BufferAttribute:xr,BufferGeometry:Pr,BufferGeometryLoader:ju,ByteType:1010,Cache:mu,Camera:ns,CameraHelper:class extends nc{constructor(e){const t=new Pr,n=new ql({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],r=[],s={};function a(e,t){o(e),o(t)}function o(e){i.push(0,0,0),r.push(0,0,0),void 0===s[e]&&(s[e]=[]),s[e].push(i.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),t.setAttribute("position",new Sr(i,3)),t.setAttribute("color",new Sr(r,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=s,this.update();const l=new cr(16755200),c=new cr(16711680),h=new cr(43775),u=new cr(16777215),d=new cr(3355443);this.setColors(l,c,h,u,d)}setColors(e,t,n,i,r){const s=this.geometry.getAttribute("color");s.setXYZ(0,e.r,e.g,e.b),s.setXYZ(1,e.r,e.g,e.b),s.setXYZ(2,e.r,e.g,e.b),s.setXYZ(3,e.r,e.g,e.b),s.setXYZ(4,e.r,e.g,e.b),s.setXYZ(5,e.r,e.g,e.b),s.setXYZ(6,e.r,e.g,e.b),s.setXYZ(7,e.r,e.g,e.b),s.setXYZ(8,e.r,e.g,e.b),s.setXYZ(9,e.r,e.g,e.b),s.setXYZ(10,e.r,e.g,e.b),s.setXYZ(11,e.r,e.g,e.b),s.setXYZ(12,e.r,e.g,e.b),s.setXYZ(13,e.r,e.g,e.b),s.setXYZ(14,e.r,e.g,e.b),s.setXYZ(15,e.r,e.g,e.b),s.setXYZ(16,e.r,e.g,e.b),s.setXYZ(17,e.r,e.g,e.b),s.setXYZ(18,e.r,e.g,e.b),s.setXYZ(19,e.r,e.g,e.b),s.setXYZ(20,e.r,e.g,e.b),s.setXYZ(21,e.r,e.g,e.b),s.setXYZ(22,e.r,e.g,e.b),s.setXYZ(23,e.r,e.g,e.b),s.setXYZ(24,t.r,t.g,t.b),s.setXYZ(25,t.r,t.g,t.b),s.setXYZ(26,t.r,t.g,t.b),s.setXYZ(27,t.r,t.g,t.b),s.setXYZ(28,t.r,t.g,t.b),s.setXYZ(29,t.r,t.g,t.b),s.setXYZ(30,t.r,t.g,t.b),s.setXYZ(31,t.r,t.g,t.b),s.setXYZ(32,n.r,n.g,n.b),s.setXYZ(33,n.r,n.g,n.b),s.setXYZ(34,n.r,n.g,n.b),s.setXYZ(35,n.r,n.g,n.b),s.setXYZ(36,n.r,n.g,n.b),s.setXYZ(37,n.r,n.g,n.b),s.setXYZ(38,i.r,i.g,i.b),s.setXYZ(39,i.r,i.g,i.b),s.setXYZ(40,r.r,r.g,r.b),s.setXYZ(41,r.r,r.g,r.b),s.setXYZ(42,r.r,r.g,r.b),s.setXYZ(43,r.r,r.g,r.b),s.setXYZ(44,r.r,r.g,r.b),s.setXYZ(45,r.r,r.g,r.b),s.setXYZ(46,r.r,r.g,r.b),s.setXYZ(47,r.r,r.g,r.b),s.setXYZ(48,r.r,r.g,r.b),s.setXYZ(49,r.r,r.g,r.b),s.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap;qd.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Yd("c",t,e,qd,0,0,-1),Yd("t",t,e,qd,0,0,1),Yd("n1",t,e,qd,-1,-1,-1),Yd("n2",t,e,qd,1,-1,-1),Yd("n3",t,e,qd,-1,1,-1),Yd("n4",t,e,qd,1,1,-1),Yd("f1",t,e,qd,-1,-1,1),Yd("f2",t,e,qd,1,-1,1),Yd("f3",t,e,qd,-1,1,1),Yd("f4",t,e,qd,1,1,1),Yd("u1",t,e,qd,.7,1.1,-1),Yd("u2",t,e,qd,-.7,1.1,-1),Yd("u3",t,e,qd,0,2,-1),Yd("cf1",t,e,qd,-1,0,1),Yd("cf2",t,e,qd,1,0,1),Yd("cf3",t,e,qd,0,-1,1),Yd("cf4",t,e,qd,0,1,1),Yd("cn1",t,e,qd,-1,0,-1),Yd("cn2",t,e,qd,1,0,-1),Yd("cn3",t,e,qd,0,-1,-1),Yd("cn4",t,e,qd,0,1,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},CanvasTexture:pc,CapsuleGeometry:Fc,CatmullRomCurve3:Sc,CineonToneMapping:we,CircleGeometry:zc,ClampToEdgeWrapping:Ne,Clock:nd,Color:cr,ColorKeyframeTrack:au,ColorManagement:Pn,CompressedArrayTexture:class extends dc{constructor(e,t,n,i,r,s){super(e,t,n,r,s),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=Ne}},CompressedTexture:dc,CompressedTextureLoader:class extends vu{constructor(e){super(e)}load(e,t,n,i){const r=this,s=[],a=new dc,o=new yu(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(r.withCredentials);let l=0;function c(c){o.load(e[c],(function(e){const n=r.parse(e,!0);s[c]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},l+=1,6===l&&(1===n.mipmapCount&&(a.minFilter=ke),a.image=s,a.format=n.format,a.needsUpdate=!0,t&&t(a))}),n,i)}if(Array.isArray(e))for(let t=0,n=e.length;t0){const n=new fu(t);r=new Mu(n),r.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t0){i=new Mu(this.manager),i.setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;t1)for(let n=0;n1e3*((e,t)=>{var n=tp(t.lat-e.lat)/2,i=tp(t.lng-e.lng)/2,r=tp(e.lat),s=tp(t.lat),a=np.sin(n)*np.sin(n)+np.sin(i)*np.sin(i)*(np.cos(r)*np.cos(s));return 2*np.atan2(np.sqrt(a),np.sqrt(1-a))*6371})(e,t),rp=(e,t)=>((e,t)=>t.sort(((t,n)=>ip(e,t)-ip(e,n))))(e,t)[0],sp=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;return parseFloat(e).toPrecision(t)/1},ap=["className","id","innerText","children","on","parent","style"],op=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{parent:n=q.D,single:i=!1}=t,r=e.split(" "),s=r[r.length-1];return i||s.startsWith("#")?n.querySelector(e):Array.from(n.querySelectorAll(e))};op.show=(e,t)=>{X.str(e)&&(e=op(e,t)),e&&(X.arr(e)?e.forEach((e=>op.show(e,t))):e.classList&&e.classList.add("visible"))},op.hide=(e,t)=>{X.str(e)&&(e=op(e,t)),e&&(X.arr(e)?e.forEach((e=>op.hide(e,t))):e.classList&&e.classList.remove("visible"))},op.prop=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};X.str(e)&&(e=op(e)),Object.entries(t).forEach((t=>{var[n,i]=t;!1===i?e.removeAttribute(n):e.setAttribute(n,i)}))},op.create=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{className:n,id:i,innerText:r,children:a,on:o,parent:l,style:c}=t,h=s(t,ap),u=q.D.createElement(e);n&&(u.className=n),r&&(u.innerText=r),a&&(X.str(a)?u.innerText+=a:X.arr(a)&&a.forEach((e=>u.appendChild(e)))),c&&Object.entries(c).forEach((e=>{var[t,n]=e;u.style[t]=n})),i&&u.setAttribute("id",i),o&&Object.entries(o).forEach((e=>{var[t,n]=e;u.addEventListener(t,n)})),l&&op.append(u,l);var d=Object.entries(h);return d.length&&d.map((e=>{var[t,n]=e;u.setAttribute(t,n)})),u},op.on=function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};X.str(e)&&(e=op(e)),e?X.arr(e)?e.forEach((e=>e.addEventListener(t,n,!1,i))):e.addEventListener(t,n,!1,i):console.error(new Error("tried to attach event listener to empty ele"))},op.off=(e,t,n,i)=>{X.str(e)&&(e=op(e)),X.arr(e)?e.forEach((e=>e.removeEventListener(t,n,!1,i))):e.removeEventListener(t,n,!1,i)},op.append=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:B;X.str(e)&&(e=op(e)),X.str(t)&&(t=op(t)),t&&e&&(X.arr(e)?e.forEach((e=>t.appendChild(e))):t.appendChild(e))},op.remove=e=>{e&&(X.str(e)&&(e=op(e)),X.arr(e)?e.forEach((e=>op.remove(e))):e&&e.parentNode&&e.parentNode.removeChild(e))};var lp,cp=()=>new URLSearchParams(q.location.hash.substr(1)),hp=()=>{var e=cp(),t=e.get("z");X.num(parseInt(t,10))||e.set("z",17);var n={},i={z:"zoom",d:"detail",p:"popup",s:"screen"};for(var[r,s]of e.entries())r in i&&(r=i[r]),n[r]=s;return n},up=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};q.STATE=t(t({},q.STATE),e),JSON.stringify(q.STATE)!==JSON.stringify(q.OLD_STATE)&&(dp(q.STATE),q.OLD_STATE=q.STATE)},dp=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{detail:t,lat:n,lng:i,popup:r,screen:s,three:a,zoom:o}=e,l=cp();o&&l.set("z",sp(o,3)),n&&l.set("lat",sp(n,7)),i&&l.set("lng",sp(i,7)),r?l.set("p",r):!1===r&&l.delete("p"),t?l.set("d",t):!1===t&&l.delete("d"),s?l.set("s",s):!1===s&&l.delete("s"),a||l.delete("t");var c=l.toString();q.location.hash!==c&&(q.location.hash=c)},pp=e=>{var{map:t,zoom:n}=e,{locationLayer:i,artifactLayer:r}=t;if(i){var s=16;i.zoomFromLocationToObject&&(s=i.zoomFromLocationToObject),n>=s?(t.hasLayer(i)&&t.removeLayer(i),t.hasLayer(r)||t.addLayer(r)):(t.hasLayer(i)||t.addLayer(i),t.hasLayer(r)&&t.removeLayer(r))}},mp=e=>{var t=op(".nav.menu");e?t.forEach((t=>{if(t.dataset.to){var n=t.dataset.to===e||t.classList.contains(e),i=e.includes("-")&&t.classList.contains(e.split("-")[0]);n||i?t.classList.add("active"):t.classList.remove("active")}else t.classList.remove("active")})):t.forEach((e=>{e.classList.contains("map")?e.classList.add("active"):e.classList.remove("active")}))},fp=e=>{var t,n=!1;("home"===e&&(e="about"),op(".screen.visible").forEach((e=>{e.classList.remove("visible")})),op(".screen[data-name=".concat(e,"]")).forEach((e=>{e.classList.add("visible"),n=!0})),e)&&(e.startsWith("list-")?t=op(".screen[data-name=list]",{single:!0}):e.startsWith("help-")&&(t=op(".screen[data-name=help]",{single:!0})),t&&(t.classList.add("visible"),n=!0));n?("about"===e&&q.B.classList.add("about"),q.B.classList.add("screen-visible")):q.B.classList.remove("screen-visible","about")},gp=e=>{op(".detail .info").forEach((t=>{var n=t.parentNode,{slug:i}=n.dataset;if(i===e){n.classList.add("visible");var r=n.offsetTop;X.num(r)&&(n.parentNode.parentNode.scrollTop=r)}else n.classList.remove("visible")}))},vp=e=>{var{map:t,popup:n}=e;t&&t.locationLayer&&[t.locationLayer,t.artifactLayer].forEach((e=>{e.eachLayer((e=>{n&&e.slug===n&&e.openPopup()}))}))},_p=e=>{e.currentTarget.parentNode.scrollTop=0},xp=e=>{lp=e;var t=new URL(q.location);t.hash&&"#"!==t.hash?t.hash.includes("&t=1")||t.hash.startsWith("#t=1")||(t.hash="".concat(t.hash,"&t=1"),q.history.replaceState({},"",t)):(t.hash="#t=1",q.history.replaceState({},"",t))},yp=()=>{lp=null,dp()},Mp=function(){var e=i((function*(){if(lp)return yield lp.onExitButtonClick(),lp=null,!0}));return function(){return e.apply(this,arguments)}}(),Sp=(e,t,n)=>{return i=Math.round(e+n*(t-e)),r=0,s=255,Math.min(s,Math.max(r,i));var i,r,s},bp=(e,t,n)=>{var[i,r,s]=e,[a,o,l]=t,c=Sp(i,a,n),h=Sp(r,o,n),u=Sp(s,l,n);return"rgb(".concat(c,", ").concat(h,", ").concat(u,")")},Tp=e=>{var t=op(".screen.about",{single:!0}),n=op(".hero",{single:!0}),i=op("header.main",{single:!0}),r=n&&i?n.clientHeight+i.clientHeight+200:0,s=op(".mainMenu",{single:!0}),a=op(".logoPath",{single:!0}),o=t&&t.classList.contains("visible"),l=!0===e||o,c=t&&t.scrollTop{var n="* {scrollbar-color: ".concat(t," ").concat(e,";}"),i=op("#js-css");i||(i=op.create("style",{id:"js-css"})),i.innerHTML=n,op("head",{single:!0}).appendChild(i)})(d,p)}}else if(i.style.backgroundColor){i.style={},s.style={},a.style={};var m=op("#js-css");m&&(m.innerHTML="")}},wp=e=>{var t,n=null===(t=e.popup)||void 0===t||null===(t=t._source)||void 0===t?void 0:t.slug;n&&up({popup:n})},Ep=()=>{up({popup:!1})},Ap=e=>{var{lat:t,lng:n}=e.target.getCenter();up({lat:t,lng:n})},Rp=e=>{var t=e.target,{lat:n,lng:i}=t.getCenter(),r=t.getZoom();up({lat:n,lng:i,zoom:r})},Cp=e=>{var{map:t,lat:n,lng:i,zoom:r,detail:s}=e;return()=>{var e=t.getZoom();up({lat:n,lng:i,detail:s,zoom:e>r?e:r})}},Pp=e=>{if(!(q.location.hash.length>0)){var{lat:t,lng:n,zoom:i}=e,r=!1;return q.APP_DB.cities&&!q.APP_DB.city?r="about":q.innerWidth>800&&(r="list"),up({lat:t,lng:n,zoom:i,screen:r}),q.STATE={lat:t,lng:n,zoom:i},q.OLD_STATE=q.STATE,{lat:t,lng:n,zoom:i}}return hp()},Lp=e=>{var t,{popup:n,screen:r,zoom:s,detail:a}=hp();pp({map:e,zoom:s}),n&&vp({map:e,popup:n}),mp(r),r&&(fp(r),q.B.classList.add("screen-visible")),gp(a),(t=op(".screen.about",{single:!0}))&&(Tp(!0),op.on(t,"scroll",Tp,{passive:!0})),op.on(q,"popstate",(e=>i((function*(){if(yield Mp())return!1;var t=e.getCenter(),n=e.getZoom(),{lat:i=t.lat,lng:r=t.lng,zoom:s=n,popup:a,screen:o,detail:l}=hp();fp(o),gp(l),mp(o),pp({map:e,zoom:s}),vp({map:e,popup:a}),(t.lat!==i||t.lng!==r||s!==n)&&e.setView({lat:i,lng:r},s)})))(e)),op.on(e,"popupopen",wp),op.on(e,"popupclose",Ep),op.on(e,"zoomend",Rp),op.on(e,"dragend",Ap),op.on(".nav","click",(e=>t=>{var n,i,r=t.currentTarget,{dataset:s,classList:a,parentNode:o}=r,{to:l}=s,{z:c,lat:h,lng:u,detail:d,popup:p}=s,{slug:m}=o.dataset;l?a.contains("active")?a.contains("no-toggle")||(n=!1):n=l:(a.contains("exit")||a.contains("close")&&q.B.clientWidth<800)&&(n=!1),m&&[e.locationLayer,e.artifactLayer].forEach((e=>{e.eachLayer((e=>{e.slug===m&&(i=m)}))})),"show"===d?d=!o.classList.contains("visible")&&m:"hide"===d&&(d=!1),p&&(i=p),up({detail:d,lat:h,lng:u,zoom:c,popup:i,screen:n}),a.contains("scroll")&&setTimeout((()=>{var e=o.parentNode.parentNode,t=o.offsetTop;e.scrollTop=t}),50)})(e)),op.on(".backToTop","click",_p)},Ip=()=>{if((J||ie||Q)&&(!q.noWarn&&"true"!==q.store.getItem("warningSeen"))){var e=!1;J&&(re||(e=!0,op("#warning").classList.add("ios","full"),op.show("#warning .no-webxr"),op.on("#copy-link","click",(e=>{var{target:t}=e;t.innerText="copied...",q.NAV.clipboard.writeText(q.LOC.href)})),op("#open-webxr-link").href="xrviewer://".concat(q.LOC.href)),e&&(op.show("#warning .ios"),op.show("#warning .ios .all"))),ie&&(ne?te<86&&(e=!0,op.show("#warning .chrome.old")):(e=!0,op.show("#warning .chrome.no")),e&&(op.show("#warning .android"),op.show("#warning .android .all"))),Q&&$&&(op.show("#warning .safari"),op.show("#warning .macos")),e&&(op.show("#warning"),op.on(".close-warning","click",(()=>{op.hide("#warning")})),q.store.setItem("warningSeen",!0))}},Dp=e=>{var t=e.currentTarget.parentNode.parentNode,n=q.store.getItem("popups",[]),i=t.getAttribute("id"),r=t.classList.contains("once");!n.includes(i)&&r&&(n.push(i),q.store.setItem("popups",n)),op.hide(t)},Up=()=>{op(".popup").forEach((e=>{e.getAttribute("id"),op("button.close",{parent:e}).forEach((e=>{op.on(e,"click",Dp)})),op("button.action",{parent:e}).forEach((e=>{op.on(e,"click",(e=>{if(e.currentTarget.classList.contains("teleport")){var t=q.store.getItem("nearestCity"),n=APP_DB.cities.find((e=>e.slug===t));q.location.href="/".concat(t,"/#z=").concat(n.zoom,"&lat=").concat(n.lat,"&lng=").concat(n.lng)}}))}))}))},Np=function(){var e=i((function*(e){if(!q.createImageBitmap)return!1;var t=yield q.fetch(e),n=yield t.blob();try{var i=yield q.createImageBitmap(n);return!(!i.height&&!i.width)}catch(e){return!1}}));return function(t){return e.apply(this,arguments)}}(),Op=function(){var e=i((function*(){var{xr:e}=q.NAV;if(!e)return!1;try{return yield e.isSessionSupported("immersive-ar")}catch(e){return!1}}));return function(){return e.apply(this,arguments)}}(),Fp=()=>{try{var e=op.create("canvas");return q.WebGLRenderingContext&&["webgl","experimental-webgl","moz-webgl","webkit-3d"].some((t=>e.getContext(t)))}catch(e){return!1}},zp=()=>{try{var e=op.create("canvas");return!(!q.WebGL2RenderingContext||!e.getContext("webgl2"))}catch(e){return!1}},Bp=()=>{var e=op.create("audio");return{A_MP3:e.canPlayType("audio/mpeg"),A_OGG:e.canPlayType("audio/ogg"),A_MP4:e.canPlayType("audio/mp4")}},kp=function(){var e=i((function*(){var[e,n,i,r,s,a]=yield Promise.all([Op(),Np("data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoBAAEAAUAmJaQAA3AA/vzA8AA="),Np("data:image/avif;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAACXBIWXMAAC4jAAAuIwF4pT92AAAADElEQVQI12Pg4eEBAABMACV5R6hLAAAAAElFTkSuQmCC"),Fp(),zp(),Bp()]);return t({XR:e,WEBP:n,AVIF:i,WEBGL:r,WEBGL2:s},a)}));return function(){return e.apply(this,arguments)}}(),Hp=e=>(null==e?void 0:e.startsWith("/"))||(null==e?void 0:e.startsWith("http"));function Gp(e,t){if(0===t)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(2===t||1===t){let n=e.getIndex();if(null===n){const t=[],i=e.getAttribute("position");if(void 0===i)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e=2.0 are supported.")));const l=new Om(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e=0&&void 0===a[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(s),l.setPlugins(a),l.parse(n,i)}parseAsync(e,t){const n=this;return new Promise((function(i,r){n.parse(e,t,i,r)}))}}function Wp(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const jp={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Xp{constructor(e){this.parser=e,this.name=jp.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,s)}}class rm{constructor(e){this.parser=e,this.name=jp.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class sm{constructor(e){this.parser=e,this.name=jp.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const s=r.extensions[t],a=i.images[s.source];let o=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(o=e)}return this.detectSupport().then((function(r){if(r)return n.loadTextureImage(e,s.source,o);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class am{constructor(e){this.name=jp.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then((function(t){const n=e.byteOffset||0,i=e.byteLength||0,s=e.count,a=e.byteStride,o=new Uint8Array(t,n,i);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(s,a,o,e.mode,e.filter).then((function(e){return e.buffer})):r.ready.then((function(){const t=new ArrayBuffer(s*a);return r.decodeGltfBuffer(new Uint8Array(t),s,a,o,e.mode,e.filter),t}))}))}return null}}class om{constructor(e){this.name=jp.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const i=t.meshes[n.mesh];for(const e of i.primitives)if(e.mode!==_m.TRIANGLES&&e.mode!==_m.TRIANGLE_STRIP&&e.mode!==_m.TRIANGLE_FAN&&void 0!==e.mode)return null;const r=n.extensions[this.name].attributes,s=[],a={};for(const e in r)s.push(this.parser.getDependency("accessor",r[e]).then((t=>(a[e]=t,a[e]))));return s.length<1?null:(s.push(this.parser.createNodeMesh(e)),Promise.all(s).then((e=>{const t=e.pop(),n=t.isGroup?t.children:[t],i=e[0].count,r=[];for(const e of n){const t=new xi,n=new Vn,s=new Gn,o=new Vn(1,1,1),l=new Xl(e.geometry,e.material,i);for(let e=0;e-1,r=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||i&&r<98?this.textureLoader=new Su(this.options.manager):this.textureLoader=new Zu(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new yu(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const s={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};Cm(r,s,i),Pm(s,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(s)}))).then((function(){e(s)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=t.length;n{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,i]of e.children.entries())r(i,t.children[n])};return r(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&p.setY(t,h[e*s+1]),s>=3&&p.setZ(t,h[e*s+2]),s>=4&&p.setW(t,h[e*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,r=t.images[i];let s=this.textureLoader;if(r.uri){const e=n.manager.getHandler(r.uri);null!==e&&(s=e)}return this.loadTextureImage(e,i,s)}loadTextureImage(e,t,n){const i=this,r=this.json,s=r.textures[e],a=r.images[t],o=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[o])return this.textureCache[o];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=s.name||a.name||"",""===t.name&&"string"==typeof a.uri&&!1===a.uri.startsWith("data:image/")&&(t.name=a.uri);const n=(r.samplers||{})[s.sampler]||{};return t.magFilter=ym[n.magFilter]||ke,t.minFilter=ym[n.minFilter]||Ge,t.wrapS=Mm[n.wrapS]||Ue,t.wrapT=Mm[n.wrapT]||Ue,i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[o]=l,l}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const s=i.images[e],a=self.URL||self.webkitURL;let o=s.uri||"",l=!1;if(void 0!==s.bufferView)o=n.getDependency("bufferView",s.bufferView).then((function(e){l=!0;const t=new Blob([e],{type:s.mimeType});return o=a.createObjectURL(t),o}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(o).then((function(e){return new Promise((function(n,i){let s=n;!0===t.isImageBitmapLoader&&(s=function(e){const t=new Fn(e);t.needsUpdate=!0,n(t)}),t.load(Vu.resolveURL(e,r.path),s,void 0,i)}))})).then((function(e){var t;return!0===l&&a.revokeObjectURL(o),e.userData.mimeType=s.mimeType||((t=s.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",o),e}));return this.sourceCache[e]=c,c}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then((function(s){if(!s)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((s=s.clone()).channel=n.texCoord),r.extensions[jp.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[jp.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=r.associations.get(s);s=r.extensions[jp.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),r.associations.set(s,t)}}return void 0!==i&&(s.colorSpace=i),e[t]=s,s}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=void 0===t.attributes.tangent,r=void 0!==t.attributes.color,s=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new rc,rr.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new ql,rr.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(i||r||s){let e="ClonedMaterial:"+n.uuid+":";i&&(e+="derivative-tangents:"),r&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),r&&(t.vertexColors=!0),s&&(t.flatShading=!0),i&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return Bh}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let s;const a={},o=[];if((r.extensions||{})[jp.KHR_MATERIALS_UNLIT]){const e=i[jp.KHR_MATERIALS_UNLIT];s=e.getMaterialType(),o.push(e.extendParams(a,r,t))}else{const n=r.pbrMetallicRoughness||{};if(a.color=new cr(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;a.color.fromArray(e),a.opacity=e[3]}void 0!==n.baseColorTexture&&o.push(t.assignTexture(a,"map",n.baseColorTexture,Wt)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(o.push(t.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),o.push(t.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),o.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)}))))}!0===r.doubleSided&&(a.side=fe);const l=r.alphaMode||Em;if(l===Rm?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===Am&&(a.alphaTest=void 0!==r.alphaCutoff?r.alphaCutoff:.5)),void 0!==r.normalTexture&&s!==ur&&(o.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new fn(1,1),void 0!==r.normalTexture.scale)){const e=r.normalTexture.scale;a.normalScale.set(e,e)}return void 0!==r.occlusionTexture&&s!==ur&&(o.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),void 0!==r.occlusionTexture.strength&&(a.aoMapIntensity=r.occlusionTexture.strength)),void 0!==r.emissiveFactor&&s!==ur&&(a.emissive=(new cr).fromArray(r.emissiveFactor)),void 0!==r.emissiveTexture&&s!==ur&&o.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,Wt)),Promise.all(o).then((function(){const n=new s(a);return r.name&&(n.name=r.name),Pm(n,r),t.associations.set(n,{materials:e}),r.extensions&&Cm(i,n,r),n}))}createUniqueName(e){const t=Md.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function r(e){return n[jp.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return Fm(n,e,t)}))}const s=[];for(let n=0,a=e.length;n0&&Lm(u,r),u.name=t.createUniqueName(r.name||"mesh_"+e),Pm(u,r),h.extensions&&Cm(i,u,h),t.assignFinalMaterial(u),l.push(u)}for(let n=0,i=l.length;n1?new Go:1===t.length?t[0]:new Wi,a!==t[0])for(let e=0,n=t.length;e{const t=new Map;for(const[e,n]of i.associations)(e instanceof rr||e instanceof Fn)&&t.set(e,n);return e.traverse((e=>{const n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(r),r}))}_createAnimationTracks(e,t,n,i,r){const s=[],a=e.name?e.name:e.uuid,o=[];let l;switch(Tm[r.path]===Tm.weights?e.traverse((function(e){e.morphTargetInfluences&&o.push(e.name?e.name:e.uuid)})):o.push(a),Tm[r.path]){case Tm.weights:l=ou;break;case Tm.rotation:l=cu;break;default:switch(n.itemSize){case 1:l=ou;break;case 2:case 3:l=uu}}const c=void 0!==i.interpolation?wm[i.interpolation]:Ut,h=this._getArrayFromAccessor(n);for(let e=0,n=o.length;ee.name));function n(e){for(let n=0,i=e.length;n0&&t.setIndex(e.indices),t.setAttribute("position",new Sr(e.vertices,3)),e.normals.length>0&&t.setAttribute("normal",new Sr(e.normals,3)),e.uvs.length>0&&t.setAttribute("uv",new Sr(e.uvs,2)),e.colors.length>0&&t.setAttribute("color",new Sr(e.colors,3)),(e.faceVertexUvs.length>0||e.faceVertexColors.length>0)&&(t=t.toNonIndexed(),e.faceVertexUvs.length>0&&t.setAttribute("uv",new Sr(e.faceVertexUvs,2)),e.faceVertexColors.length>0&&t.setAttribute("color",new Sr(e.faceVertexColors,3)));for(const n of Object.keys(d.customPropertyMapping))e[n].length>0&&t.setAttribute(n,new Sr(e[n],d.customPropertyMapping[n].length));return t.computeBoundingSphere(),t}function l(e,t,n,i){if("vertex"===t){e.vertices.push(n[i.attrX],n[i.attrY],n[i.attrZ]),null!==i.attrNX&&null!==i.attrNY&&null!==i.attrNZ&&e.normals.push(n[i.attrNX],n[i.attrNY],n[i.attrNZ]),null!==i.attrS&&null!==i.attrT&&e.uvs.push(n[i.attrS],n[i.attrT]),null!==i.attrR&&null!==i.attrG&&null!==i.attrB&&(zm.setRGB(n[i.attrR]/255,n[i.attrG]/255,n[i.attrB]/255).convertSRGBToLinear(),e.colors.push(zm.r,zm.g,zm.b));for(const t of Object.keys(d.customPropertyMapping))for(const i of d.customPropertyMapping[t])e[t].push(n[i])}else if("face"===t){const t=n.vertex_indices||n.vertex_index,r=n.texcoord;3===t.length?(e.indices.push(t[0],t[1],t[2]),r&&6===r.length&&(e.faceVertexUvs.push(r[0],r[1]),e.faceVertexUvs.push(r[2],r[3]),e.faceVertexUvs.push(r[4],r[5]))):4===t.length&&(e.indices.push(t[0],t[1],t[3]),e.indices.push(t[1],t[2],t[3])),null!==i.attrR&&null!==i.attrG&&null!==i.attrB&&(zm.setRGB(n[i.attrR]/255,n[i.attrG]/255,n[i.attrB]/255).convertSRGBToLinear(),e.faceVertexColors.push(zm.r,zm.g,zm.b),e.faceVertexColors.push(zm.r,zm.g,zm.b),e.faceVertexColors.push(zm.r,zm.g,zm.b))}}function c(e,t){const n={};let i=0;for(let r=0;re.getInt8(t),size:1};case"uint8":case"uchar":return{read:t=>e.getUint8(t),size:1};case"int16":case"short":return{read:t=>e.getInt16(t,n),size:2};case"uint16":case"ushort":return{read:t=>e.getUint16(t,n),size:2};case"int32":case"int":return{read:t=>e.getInt32(t,n),size:4};case"uint32":case"uint":return{read:t=>e.getUint32(t,n),size:4};case"float32":case"float":return{read:t=>e.getFloat32(t,n),size:4};case"float64":case"double":return{read:t=>e.getFloat64(t,n),size:8}}}for(let r=0,s=e.length;r=this.arr.length}next(){return this.arr[this.i++]}}class Hm extends vu{constructor(e){super(e)}load(e,t,n,i){const r=this,s=new yu(this.manager);s.setPath(this.path),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(function(e){const n=r.parse(JSON.parse(e));t&&t(n)}),n,i)}parse(e){return new Gm(e)}}class Gm{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100){const n=[],i=function(e,t,n){const i=Array.from(e),r=t/n.resolution,s=(n.boundingBox.yMax-n.boundingBox.yMin+n.underlineThickness)*r,a=[];let o=0,l=0;for(let e=0;e1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Infinity,r=(e.getIndex()||e.getAttribute("position")).count/3,s=[],a=n;ae.r!==t.r||e.g!==t.g||e.b!==t.b,Xm={different:jm,same:(e,t)=>!jm(e,t)},qm=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e&&e.dispose&&X.fn(e.dispose)&&e.dispose()},Ym=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(X.arr(t)&&t.forEach((t=>e(t))),"Audio"===t.type&&t.isPlaying&&t.stop(),qm(t.geometry),t.material)&&(X.arr(t.material)?t.material:[t.material]).forEach((e=>{Object.values(e).forEach(qm),qm(e)}));t.children.length&&t.children.forEach(e),!t.isScene&&t.dispose&&X.fn(t.dispose)&&t.dispose(),t.parent&&t.parent.remove(t)},Zm=(e,t)=>!e||e===t.Float||e===t.Hit,Km=Math,Jm=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{max:t=1,min:n=0}=e;if(n===t)return t;var i=t-n;return Km.random()*i+n},Qm=function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t?X.arr(t)&&X.arr(n)?t.length?t:n:Object.fromEntries(Object.entries(n).map((n=>{var[i,r]=n;return X.arr(r)?X.arr(t[i])?[i,t[i]]:[i,r]:X.obj(r)||X.obj(t[i])?[i,e(t[i],r)]:[i,t.hasOwnProperty(i)?t[i]:r]}))):n},$m=function(){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"no";return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").toLowerCase().includes(e.toLowerCase())},ef=e=>{var{search:t,node:n}=e,i=!1,r=!1,s=!1;(t=t.toLowerCase()).startsWith("*")&&(t=t.slice(1),i=!0,r=!0),t.endsWith("*")&&(t=t.slice(0,-1),i=!0,s=!0);var a=n.name.toLowerCase();return i?r&&s?$m(n.name,t):r?a.endsWith(t):s?a.startsWith(t):void 0:a===t},tf=e=>{var{node:t,search:n}=e;return!(!n||!n.length)&&(X.arr(n)?n.some((e=>ef({search:e,node:t}))):ef({search:n,node:t}))},nf=e=>(parseFloat(e).toFixed(2)/1).toFixed(1).toString(),rf=e=>X.num(e)?{max:e,min:0}:X.obj(e)?(e.hasOwnProperty("min")||(e.min=0),e.hasOwnProperty("max")||(e.max=e.min),e):{max:0,min:0};class sf{constructor(e){var{artifact:t,engine:n,preload:i,shaders:r,videoElement:s,texture:a}=e;if(this.engine=n,this.preload=i,this.tick=this.tick.bind(this),this.hideCharacter=this.hideCharacter.bind(this),a||s||!i.assets.videoElement||(s=i.assets.videoElement),s||a){this.videoElement=s,this.imageElement=a,this.name="Record3D";var{record3d:o={}}=t,l={x:0,y:0,z:0};this.config=Qm(o,{permanentSeconds:[],maximumPermanentSeconds:-1,useBone:!1,parentName:"parent",playbackRate:1,loopVideo:!0,useFog:!1,addFog:1e-4,fogColor:16448250,ptSize:"1.0",position:l,pos:l,rotation:l,rot:l,pointAlpha:1,permanentAlpha:1,hideModelsOnVideoEnded:[],images:[]});var{ptSize:c="1.0",sizeAttenuation:h="1.0"}=o;if(this.shaderConfig=Qm(o,{filterSize:"1",minDepth:"0.1",maxDepth:"5.0",depthThresholdFilter:"0.9",scale:"2.0",depthScale:"1.0",hueRedReducer:"0.0",pixelDepth:"1.0",ptSize:(parseFloat(c)*window.devicePixelRatio).toFixed(1).toString(),sizeAttenuation:(parseFloat(h)*window.devicePixelRatio).toFixed(2).toString()}),r&&(this.shaders=r),this.currentVideoSecondId=0,this.currentImageSecondId=0,this.imageElement){this.texture=(new Su).load(this.imageElement.src);var u=this.createPoints(this.texture,this.config.permanentAlpha);u.position.set(5e3,5e3,5e3),this.child=u}else s&&this.addVideoElement(s);this.config.images.length&&(this.addTextureTimes=[],this.texturePointObjects=[],this.currentTexturePointObjectId=0,this.config.images.forEach(((e,t)=>{var i,{textures:r}=null===(i=this.preload)||void 0===i?void 0:i.assets,{file:s=e}=e,a=r[s],o=this.createPoints(a,this.config.permanentAlpha);o.position.set(5e3,5e3,5e3),n.scene.add(o);var{time:l=-1}=e;this.texturePointObjects.push({points:o,time:l})})));var d=this.createPoints(this.texture,this.config.pointAlpha);this.config.useBone?this.child=d:this.model=d,this.config.useFog&&(this.fog=new Qo(this.config.fogColor,.005),this.engine.scene.fog=this.fog)}else console.error("objects/Record3D.js: videoElement or texture has to be defined",{videoElement:s,texture:a})}addVideoElement(e){var{videoWidth:t,videoHeight:n}=e;e.playbackRate=this.config.playbackRate,this.modelsToHide=[],(this.config.hideModelsOnVideoEnded.length||!1===this.config.loopVideo)&&(op.on(e,"seeked",this.hideCharacter),this.config.hideModelsOnVideoEnded.forEach((e=>{var t=this.preload.assets.gltf.scene.getObjectByName(e);t.material.transparent=!0,this.modelsToHide.push(t)})));var i=new uc(e,{minFilter:ke});this.texture=i,this.pointCopies=[],this.canvases=[],this.config.permanentSeconds.length&&(this.canvasParent=op.create("div",{parent:q.B}),this.config.permanentSeconds.forEach(((e,i)=>{var r=op.create("canvas",{height:n,width:t,style:{position:"fixed",left:"100vw"},parent:this.canvasParent});this.canvases.push(r);var s=new pc(r,{minFilter:ke}),a=this.createPoints(s,this.config.permanentAlpha);a.visible=!1,this.pointCopies.push(a),this.engine.scene.add(a)})))}hideCharacter(){this.hasTriggeredOnce?this.fadeOutModel=!0:this.hasTriggeredOnce=!0}createPoints(e){var t,n,i,r,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"1.0",{artifact:a={}}=this.engine,{videoElement:o,texture:l={}}=this;if(o){var{videoWidth:c,videoHeight:h}=o;r=h,i=c}else l&&(r=l.height,i=l.width);for(var u=new Go,{ifx:d=.00125,ify:p=.00125,itx:m=-.4,ity:f=-.6}=a,{filterSize:g,minDepth:v,maxDepth:_,depthScale:x,depthThresholdFilter:y,scale:M,ptSize:S,pixelDepth:b,hueRedReducer:T,sizeAttenuation:w}=this.shaderConfig,E=new ts({uniforms:{texImg:{type:"t",value:e},texSize:{type:"i2",value:[i,r]},iK:{type:"f4",value:[d,p,m,f]},alpha:{type:"f",value:s},filterSize:{type:"f",value:g},minDepth:{type:"f",value:v},maxDepth:{type:"f",value:_},depthThresholdFilter:{type:"f",value:y},scale:{type:"f",value:M},ptSize:{type:"f",value:S},hueRedReducer:{type:"f",value:T},pixelDepth:{type:"f",value:b},depthScale:{type:"f",value:x},sizeAttenuation:{type:"f",value:w}},side:fe,transparent:!0,vertexShader:null!==(t=this.shaders)&&void 0!==t&&t.vertexShader?this.shaders.vertexShader:"#define GLSLIFY 1\nattribute float vertexIdx;varying float vVertexIdx;varying vec2 vPtPos;uniform ivec2 texSize;uniform sampler2D texImg;uniform vec4 iK;uniform float scale;uniform float minDepth;uniform float maxDepth;uniform float pixelDepth;uniform int filterSize;uniform float ptSize;uniform float depthThresholdFilter;uniform float depthScale;uniform float hueRedReducer;uniform float sizeAttenuation;\n#include \nfloat rgb2hue(vec3 c){float r=c.r-hueRedReducer;vec4 K=vec4(0.0,-1.0/3.0,2.0/3.0,-1.0);vec4 p=mix(vec4(c.bg,K.wz),vec4(c.gb,K.xy),step(c.b,c.g));vec4 q=mix(vec4(p.xyw,r),vec4(r,p.yzx),step(p.x,r));float d=q.x-min(q.w,q.y);float e=1.0e-10;return abs(q.z+(q.w-q.y)/(6.0*d+e));}float getPixelDepth(ivec2 pixel){vec2 lookupPt=(vec2(pixel)+vec2(0.5))/vec2(texSize);float hue=rgb2hue(texture2D(texImg,lookupPt).rgb);float pxDepth=pixelDepth*hue;return pxDepth;}bool shouldDiscard(ivec2 currPixel){float centerPixelDepth=getPixelDepth(currPixel);for(int i=-filterSize;i<=filterSize;i++){for(int j=-filterSize;j<=filterSize;j++){if(i==0&&j==0){continue;}float currDepth=getPixelDepth(currPixel+ivec2(j,i));if(currDepthmaxDepth||abs(centerPixelDepth-currDepth)>depthThresholdFilter){return true;}}}return false;}void main(){ivec2 frameSize=ivec2(texSize.x/2,texSize.y);int vertIdx=int(vertexIdx);int actualNumPts=frameSize.x*frameSize.y;if(vertIdx>=actualNumPts){gl_Position=vec4(0.0);return;}int ptY=vertIdx/int(frameSize.x);int ptX=vertIdx-ptY*int(frameSize.x);ivec2 pt=ivec2(ptX,ptY);if(shouldDiscard(pt)){gl_Position=vec4(0.0);return;}float currDepth=getPixelDepth(pt);vec3 ptPos=scale*vec3((iK.x*float(ptX)+iK.z)*currDepth,(iK.y*float(ptY)+iK.w)*currDepth,-currDepth*depthScale);vec4 mvPos=modelViewMatrix*vec4(ptPos,1.0);gl_Position=projectionMatrix*mvPos;vPtPos=vec2(float(ptX),float(ptY));vVertexIdx=vertexIdx;gl_PointSize=ptSize;bool isPerspective=isPerspectiveMatrix(projectionMatrix);if(isPerspective){gl_PointSize=max(ptSize,sizeAttenuation/-mvPos.z);}}",fragmentShader:null!==(n=this.shaders)&&void 0!==n&&n.fragmentShader?this.shaders.fragmentShader:"#define GLSLIFY 1\nvarying float vVertexIdx;varying vec2 vPtPos;uniform ivec2 texSize;uniform sampler2D texImg;uniform float alpha;void main(){vec2 frameSizeF=vec2(texSize.x/2,texSize.y);ivec2 frameSize=ivec2(frameSizeF);int vertIdx=int(vVertexIdx);int actualNumPts=frameSize.x*frameSize.y;if(vertIdx>=actualNumPts){discard;}vec2 lookupPt=(vec2(vPtPos.x+frameSizeF.x,vPtPos.y)+vec2(0.5))/vec2(texSize);vec3 currColor=texture2D(texImg,lookupPt).rgb;gl_FragColor=vec4(currColor,alpha);}"}),A=i/2*r,R=new Uint32Array(A),C=new Float32Array(A),P=0;Pthis.waitForVideoSecond){this.canvases[this.currentVideoSecondId].getContext("2d").drawImage(e,0,0,n,t);var i=this.pointCopies[this.currentVideoSecondId];i.visible=!0,this.child.matrixWorld.decompose(i.position,i.rotation,i.scale),this.currentVideoSecondId++,this.waitForVideoSecond=this.config.permanentSeconds[this.currentVideoSecondId]}}else this.waitForVideoSecond=this.config.permanentSeconds[this.currentVideoSecondId]}renderPermanentImage(e){var t=this.texturePointObjects[this.currentImageSecondId];if(this.waitForImageSecond){if(e.videoElement.currentTime>=this.waitForImageSecond){this.child.matrixWorld.decompose(t.points.position,t.points.rotation,t.points.scale),this.currentImageSecondId++;var n=this.texturePointObjects[this.currentImageSecondId];this.waitForImageSecond=n?n.time:Infinity}}else this.waitForImageSecond=t.time}tick(e){var{engine:t}=e;if(this.videoElement&&(this.currentVideoSecondId{e.material.opacity>0?e.material.opacity-=.05:e.visible&&(e.visible=!1)}));var n=this.model||this.child;if(n&&n.visible){var i,r=null==n?void 0:n.children[0];(null==r||null===(i=r.material)||void 0===i||null===(i=i.uniforms)||void 0===i||null===(i=i.alpha)||void 0===i?void 0:i.value)>0?r.material.uniforms.alpha.value-=.05:n.visible&&(n.visible=!1,this.continuePlayingNonLoopedVideo&&this.videoElement.pause())}}}}var af=Object.freeze({__proto__:null,Record3D:sf}),of=(e,t,n)=>{var i=t.clone().sub(e).normalize().multiplyScalar(n);return e.clone().add(i)};of.percent=(e,t,n)=>{var i=t.clone().sub(e),r=i.length(),s=i.normalize().multiplyScalar(r*n/100);return e.clone().add(s)};class lf extends ts{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t({uBaseTexture:{type:"t",value:null},uBaseSpeed:{type:"f",value:.5},uNoiseTexture:{type:"t",value:null},uNoiseScale:{type:"f",value:.2},uAlpha:{type:"f",value:.5},uTime:{type:"f",value:1},uRepeat:{type:"f",value:10}},e.uniforms),{side:i=fe,transparent:r=!0,textureId:s=1}=e;super(t({uniforms:n,side:i,transparent:r,vertexShader:"\nvarying vec2 vUv;\n\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}\n",fragmentShader:"\nuniform sampler2D uBaseTexture;\nuniform float uBaseSpeed;\nuniform sampler2D uNoiseTexture;\nuniform float uNoiseScale;\nuniform float uAlpha;\nuniform float uTime;\nuniform float uRepeat;\n\nvarying vec2 vUv;\n\nvoid main() {\n vec2 newUv = vUv * uRepeat;\n\tvec2 uvTimeShift = newUv + vec2(-0.7, 1.5) * uTime * uBaseSpeed;\n\tvec4 noiseGeneratorTimeShift = texture2D(uNoiseTexture, uvTimeShift);\n\tvec2 uvNoiseTimeShift = newUv + uNoiseScale * vec2(noiseGeneratorTimeShift.r, noiseGeneratorTimeShift.b);\n\tvec4 baseColor = texture2D(uBaseTexture, uvNoiseTimeShift);\n\n\tbaseColor.a = uAlpha;\n\tgl_FragColor = baseColor;\n}\n"},e)),this.textureId=s}preload(e){var t=this;return i((function*(){var{textureId:n}=t,[i,r]=yield Promise.all([e.promisifiedLoad({loader:e.textureLoader,file:"https://static.artificialmuseum.com/textures/waterplane/water_".concat(n,".jpg")}),e.promisifiedLoad({loader:e.textureLoader,file:"https://static.artificialmuseum.com/textures/waterplane/cloud_".concat(n,".png")})]);i.wrapT=i.wrapS=Ue,r.wrapT=r.wrapS=Ue,t.uniforms.uBaseTexture.value=i,t.uniforms.uNoiseTexture.value=r}))()}tick(e){this.uniforms.uTime.value+=e}}var cf=Object.freeze({__proto__:null,CirclingLights:class{constructor(e){e.artifact.circlingLights.forEach((t=>{var{color:n=16711680,intensity:i=1,dim:r=0,decay:s=2,shadows:a=!1,show:o=!1}=t,l=new Nu(n,i,r,s);if(a&&(l.castShadow=!0,l.shadow.camera.near=.1,l.shadow.camera.far=5),o){var c=new Ch(.05,6,6),h=new ur({color:n}),u=new Yr(c,h);l.add(u)}if(e.circlingLights.push({light:l,config:t}),e.model.add(l),o){var d=new Bd(l,.1,n);e.model.add(d)}})),e.addRenderStep(this.render.bind(this))}render(e){var{engine:t,timestamp:n}=e,i=5e-4*n;t.circlingLights.forEach((e=>{var{light:t,config:n}=e,{lightDistance:r=1,timeOffset:s=20,offset:{x:a=0,y:o=0,z:l=0}={}}=n;i+=1e3*s;var c=Math.sin(i)*r+a,h=Math.sin(1.1*i)*r+o,u=Math.sin(1.2*i)*r+l;t.position.set(c,h,u)}))}}}),hf=["audio","action","actions","animationSoundFrames","idleActions","enterActions","exitActions","loopActions","buffer","target","distanceTarget"];var uf=Object.freeze({__proto__:null,SpatialObjects:class{constructor(e){this.finished=!1,this.opening=!1,this.looping=!1,this.closing=!0,this.animationSoundActions=[],this.animationLoopSoundActions=[];var n=!1;e.spatials.forEach((i=>{var{audio:r,action:a,actions:o,animationSoundFrames:l=[],idleActions:c=[],enterActions:h=[],exitActions:u=[],loopActions:d=[],buffer:p,target:m,distanceTarget:f}=i,g=s(i,hf),v=X.str(r)?r:e.artifact.slug;e.model.traverse((i=>{if(tf({node:i,search:m})){var s=t(t({},g),{},{node:i});if(f&&(s.distanceTarget=e.model.getObjectByName(f)),p)s.audio=p;else if(r){var l;if(null!==(l=e.preload.assets.audioElements)&&void 0!==l&&l.length){var _=e.preload.assets.audioElements.find((e=>{var{ele:t}=e;return t.dataset.name===v}));s.audio=_;var{AudioContext:x=q.webkitAudioContext}=q,y=new x,M=y.createMediaElementSource(_.ele),S=y.createGain();M.connect(S),S.connect(y.destination),S.gain.value=0,s.context=y,s.gainNode=S,s.source=M}}var b=[];if(X.arr(o)&&o.length&&(e.actions.filter((e=>o.includes(e._clip.name))),function(e){throw new TypeError('"'+e+'" is read-only')}("finalActions"),s.off||b.forEach((e=>e.paused=!0))),a){var T=du.findByName(e.animations,a);T&&b.push(T),s.off||(T.paused=!0)}b.length&&(s.actions=b,n=!0);var w=e.actions.filter((e=>c.includes(e._clip.name))),E=e.actions.filter((e=>h.includes(e._clip.name))),A=e.actions.filter((e=>d.includes(e._clip.name))),R=e.actions.filter((e=>u.includes(e._clip.name)));s.off||(E.forEach((e=>{e.loop=It,e.paused=!0,e.weight=0,e.time=0})),R.forEach((e=>{e.loop=It,e.paused=!0,e.weight=0,e.time=0})),A.forEach((e=>{e.paused=!0,e.weight=0,e.time=0}))),s.enter=E,s.loop=A,s.exit=R,s.idle=w,n=!0,e.spatialObjects.push(s)}}))}));var{animationSoundFrames:i=[]}=e.artifact;if(i.length&&i.forEach((t=>{var{time:n,audio:i,onLoop:r=!1}=t,s=X.arr(i)?i:[i],a=e.actions.find((e=>e._clip.name===t.action)),o=[];s.forEach((n=>{var i=e.preload.audioElements.find((e=>{var t,{ele:i}=e;return(null==i||null===(t=i.dataset)||void 0===t?void 0:t.name)===n}));a&&i.ele&&(i.ele.loop=!1,o.push(i.ele)),a||console.warn("W_ANIMATIONSOUNDFRAMES","could not find action",t.action,e.animations),i.ele||console.warn("W_ANIMATIONSOUNDFRAMES","could not find audioelement",t.audio,e.preload.audioElements)}));var l=1===o.length?o[0]:o,c={action:a,audio:l,playing:!1,time:n};r?this.animationLoopSoundActions.push(c):this.animationSoundActions.push(c)})),n&&e.mixer){var r=[e.mixer,"finished",e=>{var{name:t}=e.action._clip;t.includes("enter")&&!this.looping?this.looping=!0:t.includes("exit")&&!this.finished&&(this.finished=!0,this.closing=!1)}];op.on(...r),e.eventsToRemove.push(r)}if(e.mixer&&this.animationLoopSoundActions.length){var a=[e.mixer,"loop",e=>{var{name:t}=e.action._clip,n=this.animationLoopSoundActions.find((e=>e.action._clip.name===t));if(n){var{currentAudioId:i=0}=n,r=n.audio[i];r.time=0,r.play(),++i>=n.audio.length&&(i=0),n.currentAudioId=i}}];op.on(...a),e.eventsToRemove.push(a)}e.addRenderStep(this.render.bind(this))}render(e){var t,{engine:n}=e;n.modelSpawned&&(null!==(t=this.animationSoundActions)&&void 0!==t&&t.length&&this.animationSoundActions.forEach((e=>{var{action:t,time:n=0,audio:i}=e,{currentAudioId:r=0}=e,s=i;if(t.time>=n){if(X.arr(i))return;s.paused&&(t.time>1e3?s.time=t.time:s.time=0,s.play(),++r>=i.length&&(r=0),e.currentAudioId=r)}})),n.spatialObjects.forEach((e=>{var{node:t,distanceTarget:i,exclusive:r=!1,restart:s,actions:a,idle:o=[],enter:l=[],loop:c=[],exit:h=[],audio:u,gainNode:d,off:p,fn:m,yDistanceTest:f=!0}=e,{distance:g={max:2,min:0},scale:v}=e,_=i||t,x=new Vn;_.getWorldPosition(x);var y=f?x.y:n.camera.position.y,M=new Vn(x.x,y,x.z),S=_.visible?n.camera.position.distanceTo(M):1e4;if(g=rf(g),v){v=rf(v);var b=g.min/g.max,T=1-S/g.max+b,w=Math.max(v.min,Math.min(v.max,T));t.scale.set(w,w,w)}if(u&&u.ele&&d){var{ele:E}=u,A=d.gain.value,R=Math.max(0,Math.min(1,1-S/g.max+g.min/g.max)),C=Math.abs(A-R);R<=.02?d.gain.value=0:C>.02&&(R>0&&E.paused&&(E.time=0,E.play()),d.gain.value=R),s&&(S>g.max||S=g.min?this.opening?this.looping&&(this.looping=!1,h.forEach((e=>{e.weight=0,e.paused=!0})),o.forEach((e=>{e.weight=0,e.paused=!0})),l.forEach((e=>{e.weight=0,e.paused=!0})),c.forEach((e=>{e.time=0,e.weight=1,e.paused=!1})),this.closing=!1):(h.forEach((e=>{e.weight=0,e.paused=!0})),o.forEach((e=>{e.weight=0,e.paused=!0})),c.forEach((e=>{e.weight=0,e.paused=!0})),l.forEach((e=>{e.time=0,e.weight=1,e.paused=!1})),this.opening=!0,this.closing=!1):this.closing?this.finished&&(h.forEach((e=>{e.weight=0,e.paused=!0})),c.forEach((e=>{e.weight=0,e.paused=!0})),l.forEach((e=>{e.weight=0,e.paused=!0})),o.forEach((e=>{e.time=0,e.weight=1,e.paused=!1})),this.looping=!1,this.finished=!1):(c.forEach((e=>{e.weight=0,e.paused=!0})),o.forEach((e=>{e.weight=0,e.paused=!0})),l.forEach((e=>{e.weight=0,e.paused=!0})),h.forEach((e=>{e.time=0,e.weight=1,e.paused=!1})),this.opening=!1,this.looping=!1,this.closing=!0),a&&a.length&&a.forEach((e=>{S<=g.max&&S>=g.min?p?e.paused||(e.paused=!0):e.paused&&(r?n.actions.forEach((t=>{t!==e?t.paused||(t.paused=!0):t.paused&&(t.paused=!1)})):e.paused=!1):p?e.paused&&(e.paused=!1):e.paused||(e.paused=!0)})),m&&X.fn(n.sceneInstance[m])&&n.sceneInstance[m]({node:t,config:{distance:g},distance:S})})))}}});var df=Object.freeze({__proto__:null,AnalyseAudio:class{constructor(e){var t,{audioElement:n,audioElements:i=[]}=e.preload.assets;n||null!=i&&i.length?([n,...i].filter((e=>e)).forEach((t=>{var n=new AudioContext,i=n.createMediaElementSource(t.ele),r=n.createAnalyser();r.fftSize=e.artifact.fftSize||32,i.connect(r),i.connect(n.destination);var s=new Uint8Array(r.frequencyBinCount);r.getByteFrequencyData(s),e.audioAnalysers.push({name:t.ele.id,analyser:r,array:s})})),null===(t=e.artifact.audioAnalyserEmission)||void 0===t||t.forEach((t=>{var n=Qm(t,{intensity:.004,minIntensity:0,color:[],target:""}),i=[];e.model.traverse((e=>{var t;tf({node:e,search:n.target})&&(e.material?i.includes(e.material)||i.push(e.material):null!==(t=e.children)&&void 0!==t&&t.length&&e.children.forEach((e=>{e.material&&i.push(e.material)})))})),n.targets=i,n.targets.length||console.warn("W_AUDIO_ANALYSER_EMISSION_CONFIGS","Audio analyser emission config does not find a target",n,e.model),e.audioAnalyserEmissionConfigs.push(n)}))):console.warn("W_AUDIO_ANALYSER","artifact.audioAnalyser was set but no audioElements have been registered.")}render(e){var{delta:t,engine:n,frame:i,timestamp:r}=e,{actions:s,ambientLight:a,artifact:o,audioAnalysers:l,audioAnalyserEmissionConfigs:c,sceneInstance:h}=n,{audioAnalyserAnimation:u,audioAnalyserAnimations:d=[],audioAnalyserLights:p}=o,m=0,f=l.map((e=>{var{name:t,analyser:n,array:i}=e;n.getByteFrequencyData(i);var r=i.reduce(((e,t)=>e+t))/i.length;return m+=r,i})),g=m/255;if(X.fn(null==h?void 0:h.renderAudioAnalyser)&&h.renderAudioAnalyser({average:m,values:f,delta:t,timestamp:r,frame:i,engine:n}),u||d.length){var v=Qm(o,{audioAnalyserIntensity:1}),_=Math.min(1,m*v.audioAnalyserIntensity/220);if(u){var x=s.find((e=>e._clip.name===u));x.weight=_,x.time=null==x?void 0:x._clip.duration}d.length&&s.forEach((e=>{var t=e._clip.name,n=d.find((e=>e===t||e.action===t));if(n){if(X.obj(n)){var{useAverage:i=!0}=n;if(i)e.weight=_;else{var{index:r=6,divisor:s=220}=n,a=f.map((e=>e[r])).reduce(((e,t)=>e+t)),o=Math.min(1,a/s);e.weight=o}}else e.weight=_;e.time=e._clip.duration}}))}if(p){var y=Qm(o,{lightIntensity:1,levelMultiplier:2}),M=y.lightIntensity*(g*y.levelMultiplier);a.intensity=M}null!=c&&c.length&&c.forEach((e=>{var t=e.intensity*g;e.targets.forEach((n=>{var i;t>e.minIntensity?n.emissiveIntensity=t:n.emissiveIntensity=0,null!==(i=e.color)&&void 0!==i&&i.length&&(n.emissive=new cr(...e.color))}))}))}}});function pf(e){const t=new Map,n=new Map,i=e.clone();return mf(e,i,(function(e,i){t.set(i,e),n.set(e,i)})),i.traverse((function(e){if(!e.isSkinnedMesh)return;const i=e,r=t.get(e),s=r.skeleton.bones;i.skeleton=r.skeleton.clone(),i.bindMatrix.copy(r.bindMatrix),i.skeleton.bones=s.map((function(e){return n.get(e)})),i.bind(i.skeleton,i.bindMatrix)})),i}function mf(e,t,n){n(e,t);for(let i=0;iX.arr(n.action)?n.action.includes(e._clip.name):e._clip.name===n.action)),p=function(){var n=pf(h);if(t.spawnableClones.push(n),n.position.set(2e3,2e3,2e3),e.model.add(n),n.userData.actions=[],d.length){var i=new Td(n);d.forEach((e=>{var t=i.clipAction(e._clip);n.userData.actions.push(t)})),n.userData.mixer=i,t.cloneMixers.push(i);var r=[i,"loop",()=>{n.userData.waiting=!1}];op.on(...r),e.eventsToRemove.push(r)}},m=0;m{e.update(n)})),this.spawnableClones.forEach(((e,t)=>{this.waitingForSpawn.includes(e)||e.userData.waiting||(this.waitingForSpawn.push(e),e.userData.waiting=!0,e.userData.wait||(e.userData.wait=r+Jm(s)),e.userData.actions.length&&e.userData.actions.forEach(((e,t)=>{e.paused=!0,e.time=0})),e.userData.mixer&&l&&(e.userData.mixer.timeScale=Jm(l)),a&&e.rotation.set(0,359.9*Math.random(),0),e.position.set(2e3,2e3,2e3))})),null!==(t=this.freePositions)&&void 0!==t&&t.length&&(e=>{for(var t=e.length-1;t>0;t--)var n=Math.floor(Math.random()*(t+1))[(e[t],e[n])]=[e[n],e[t]]})(this.freePositions),this.waitingForSpawn.forEach((e=>{if(e.userData.wait<=r){var t;if(e.userData.wait=r+Jm(s),o){var n=Jm(o);e.scale.set(n,n,n)}var a,l,d=i.camera.position,p=359.999*Math.random(),m=Jm(h),f=i.scene.position.y;if(null!==(t=this.freePositions)&&void 0!==t&&t.length){var[g,v,_]=this.freePositions.pop();a=g,f=v,l=_,this.freePositions.length{e.paused=!1,e.play()}));var x=this.waitingForSpawn.indexOf(e);this.waitingForSpawn.splice(x,1)}}))}}});const gf=new nr,vf=new Vn,_f=new fn,xf=new fn,yf=new fn;class Mf{constructor(e){this.geometry=e.geometry,this.randomFunction=Math.random,this.indexAttribute=this.geometry.index,this.positionAttribute=this.geometry.getAttribute("position"),this.normalAttribute=this.geometry.getAttribute("normal"),this.colorAttribute=this.geometry.getAttribute("color"),this.uvAttribute=this.geometry.getAttribute("uv"),this.weightAttribute=null,this.distribution=null}setWeightAttribute(e){return this.weightAttribute=e?this.geometry.getAttribute(e):null,this}build(){const e=this.indexAttribute,t=this.positionAttribute,n=this.weightAttribute,i=e?e.count/3:t.count/3,r=new Float32Array(i);for(let s=0;se){r=s;break}e1&&(s=1-s,a=1-a);const o=this.indexAttribute;let l=3*e,c=3*e+1,h=3*e+2;return o&&(l=o.getX(l),c=o.getX(c),h=o.getX(h)),gf.a.fromBufferAttribute(this.positionAttribute,l),gf.b.fromBufferAttribute(this.positionAttribute,c),gf.c.fromBufferAttribute(this.positionAttribute,h),t.set(0,0,0).addScaledVector(gf.a,s).addScaledVector(gf.b,a).addScaledVector(gf.c,1-(s+a)),void 0!==n&&(void 0!==this.normalAttribute?(gf.a.fromBufferAttribute(this.normalAttribute,l),gf.b.fromBufferAttribute(this.normalAttribute,c),gf.c.fromBufferAttribute(this.normalAttribute,h),n.set(0,0,0).addScaledVector(gf.a,s).addScaledVector(gf.b,a).addScaledVector(gf.c,1-(s+a)).normalize()):gf.getNormal(n)),void 0!==i&&void 0!==this.colorAttribute&&(gf.a.fromBufferAttribute(this.colorAttribute,l),gf.b.fromBufferAttribute(this.colorAttribute,c),gf.c.fromBufferAttribute(this.colorAttribute,h),vf.set(0,0,0).addScaledVector(gf.a,s).addScaledVector(gf.b,a).addScaledVector(gf.c,1-(s+a)),i.r=vf.x,i.g=vf.y,i.b=vf.z),void 0!==r&&void 0!==this.uvAttribute&&(_f.fromBufferAttribute(this.uvAttribute,l),xf.fromBufferAttribute(this.uvAttribute,c),yf.fromBufferAttribute(this.uvAttribute,h),r.set(0,0).addScaledVector(_f,s).addScaledVector(xf,a).addScaledVector(yf,1-(s+a))),this}}var Sf=Object.freeze({__proto__:null,ClonesOnMeshes:class{constructor(e){var t=this;this.spawnableClones=[],this.waitingForSpawn=[],this.camPos=new Vn,this.render=this.render.bind(this),this.respawnNode=this.respawnNode.bind(this),e.addRenderStep(this.render);var{clonesOnMeshes:n}=e.artifact;this.sampleTargetPosition=new Vn,this.sampleTargetNormal=new Vn,this.sampleTargetColor=new cr;var i=[];this.meshes=n.map((n=>{var{action:r,delay:s=1e3,number:a=10,mesh:o,normals:l=!1,parent:c=!1,scale:h=!1,rotate:u=!1,respawnDelay:d,target:p="clone"}=n;h&&(h=h&&rf(h)),s&&(s=rf(s)),d&&(d=rf(d));var m=e.model.getObjectByName(o),f=m.geometry.toNonIndexed(),g=new Mf({geometry:f}).build();if(c){var v=e.model.getObjectByName(c);c=v}else c=m;var _=e.model.getObjectByName(p);i.push(_);for(var x=e.actions.filter((e=>X.arr(r)?cloneConfig.action.includes(e._clip.name):e._clip.name===r)),y=function(){var n=pf(_);if(n.visible=c.visible,n.userData.actions=[],n.userData.delay=s,x.length){var i=new Td(n);x.forEach((e=>{var t=i.clipAction(e._clip);n.userData.actions.push(t)})),n.userData.mixer=i;var r=[i,"loop",()=>t.respawnNode(n)];op.on(...r),e.eventsToRemove.push(r)}n.position.set(2e3,2e3,2e3),c.add(n)},M=0;M{e.parent&&e.removeFromParent()}))}respawnNode(e){e.userData.playing=!1,e.userData.actions.forEach((e=>{e.paused=!0,e.time=0}));var t=Jm(e.userData.delay);e.userData.nextSpawn+=t}spawnNode(e,t){if(e.parent.visible){var{normals:n,respawnDelay:i,rotate:r,scale:s,sampler:a}=t;if(e.userData.playing=!0,e.visible=!0,s){var o=Jm(s);e.scale.set(o,o,o)}a.sample(this.sampleTargetPosition,this.sampleTargetNormal);var{x:l,y:c,z:h}=this.sampleTargetPosition;if(e.position.set(l,c,h),n){var{x:u,y:d,z:p}=this.sampleTargetNormal;r&&(d=359.9*Math.random()),e.rotation.set(u,d,p)}else if(r){var{x:m,z:f}=e.rotation,g=359.9*Math.random();e.rotation.set(m,g,f)}e.userData.actions.forEach((e=>{e.time=0,e.paused=!1})),e.userData.mixer}}render(e){var{delta:t,engine:n,timestamp:i}=e;n.modelSpawned&&this.meshes.forEach(((e,n)=>{var{parent:r,delay:s}=e;r.children.forEach((n=>{n.userData.mixer&&n.userData.mixer.update(t),n.userData.nextSpawn||(n.userData.nextSpawn=i+Jm(s)),n.userData.nextSpawn<=i&&!n.userData.playing&&this.spawnNode(n,e)}))}))}}}),bf={uniforms:{color:{value:null},tDiffuse:{value:null},textureMatrix:{value:null}},vertexShader:"#define GLSLIFY 1\nuniform mat4 textureMatrix;varying vec4 vUv;\n#include \n#include \nvoid main(){vUv=textureMatrix*vec4(position,1.0);gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);\n#include \n}",fragmentShader:"#define GLSLIFY 1\nuniform vec3 color;uniform sampler2D tDiffuse;varying vec4 vUv;\n#include \nfloat blendOverlay(float base,float blend){return(base<0.5 ?(2.0*base*blend):(1.0-2.0*(1.0-base)*(1.0-blend)));}vec3 blendOverlay(vec3 base,vec3 blend){return vec3(blendOverlay(base.r,blend.r),blendOverlay(base.g,blend.g),blendOverlay(base.b,blend.b));}void main(){\n#include \nvec4 base=texture2DProj(tDiffuse,vUv);gl_FragColor=vec4(blendOverlay(base.rgb,color),1.0);\n#include \n#include \n}"};class Tf extends Yr{constructor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;super(e),this.isReflector=!0,this.type="Reflector",this.camera=new is,this.XR=n.XR,this.skybox=n.skybox,this.shadowPlane=n.shadowPlane,this.color=void 0!==t.color?new cr(t.color):new cr(8355711),this.textureMatrix=new xi,this.clipBias=t.clipBias||0,this.reflectorPlane=new us,this.normal=new Vn,this.reflectorWorldPosition=new Vn,this.cameraWorldPosition=new Vn,this.rotationMatrix=new xi,this.lookAtPosition=new Vn(0,0,-1),this.clipPlane=new zn,this.view=new Vn,this.target=new Vn,this.q=new zn;var i=t.shader||bf,r=void 0!==t.multisample?t.multisample:4;this.virtualCamera=this.camera;var s=t.textureWidth||512,a=t.textureHeight||512;this.renderTarget=new Bn(s,a,{samples:r,type:Ye});var o=new ts({uniforms:es.clone(i.uniforms),fragmentShader:i.fragmentShader,vertexShader:i.vertexShader});o.uniforms.tDiffuse.value=this.renderTarget.texture,o.uniforms.color.value=this.color,o.uniforms.textureMatrix.value=this.textureMatrix,this.material=o,this.onBeforeRender=this.onBeforeRender.bind(this)}onBeforeRender(e,t,n){var i,{clipBias:r,virtualCamera:s,reflectorPlane:a,normal:o,reflectorWorldPosition:l,cameraWorldPosition:c,rotationMatrix:h,lookAtPosition:u,clipPlane:d,renderTarget:p,textureMatrix:m,view:f,target:g,q:v}=this;if(l.setFromMatrixPosition(this.matrixWorld),c.setFromMatrixPosition(n.matrixWorld),h.extractRotation(this.matrixWorld),o.set(0,0,1),o.applyMatrix4(h),f.subVectors(l,c),!(f.dot(o)>0)){f.reflect(o).negate(),f.add(l),h.extractRotation(n.matrixWorld),u.set(0,0,-1),u.applyMatrix4(h),u.add(c),g.subVectors(l,u),g.reflect(o).negate(),g.add(l),s.position.copy(f),s.up.set(0,1,0),s.up.applyMatrix4(h),s.up.reflect(o),s.lookAt(g),s.far=n.far,s.updateMatrixWorld(),s.projectionMatrix.copy(n.projectionMatrix),m.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),m.multiply(s.projectionMatrix),m.multiply(s.matrixWorldInverse),m.multiply(this.matrixWorld),a.setFromNormalAndCoplanarPoint(o,l),a.applyMatrix4(s.matrixWorldInverse),d.set(a.normal.x,a.normal.y,a.normal.z,a.constant);var _=s.projectionMatrix;v.x=(Math.sign(d.x)+_.elements[8])/_.elements[0],v.y=(Math.sign(d.y)+_.elements[9])/_.elements[5],v.z=-1,v.w=(1+_.elements[10])/_.elements[14],d.multiplyScalar(2/d.dot(v)),_.elements[2]=d.x,_.elements[6]=d.y,_.elements[10]=d.z+1-r,_.elements[14]=d.w,this.visible=!1;var x=e.getRenderTarget(),y=e.xr.enabled,M=e.shadowMap.autoUpdate,S=e.outputColorSpace,b=e.toneMapping;e.xr.enabled=!1,e.shadowMap.autoUpdate=!1,e.outputColorSpace=jt,e.toneMapping=Se,e.setRenderTarget(p),e.state.buffers.depth.setMask(!0),!1===e.autoClear&&e.clear();var T=!1;this.XR&&this.skybox&&(this.skybox.visible?T=!0:this.skybox.visible=!0);var w=!1;null!==(i=this.shadowPlane)&&void 0!==i&&i.visible&&(this.shadowPlane.visible=!1,w=!0),e.render(t,s),e.xr.enabled=y,e.shadowMap.autoUpdate=M,e.outputColorSpace=S,e.toneMapping=b,e.setRenderTarget(x),this.XR&&this.skybox&&!T&&(this.skybox.visible=!1),w&&(this.shadowPlane.visible=!0);var E=n.viewport;void 0!==E&&e.state.viewport(E),this.visible=!0}}getRenderTarget(){return this.renderTarget}dispose(){this.renderTarget.dispose(),this.material.dispose()}}var wf=Object.freeze({__proto__:null,Mirrors:class{constructor(e){var{mirrors:t}=e.artifact,n=q.devicePixelRatio;this.textureWidth=q.innerWidth*n,this.textureHeight=q.innerHeight*n,this.engine=e,e.mirrors=t.map(this.addMirror.bind(this))}addMirror(e){var{clipBias:t=.003,color:n=7829367,type:i,params:r=[4,32],rotation:s={},position:a={}}=e,o=this.createGeometry({type:i,params:r}),{textureHeight:l,textureWidth:c}=this,h=new Tf(o,{clipBias:t,textureWidth:c,textureHeight:l,color:n},this.engine),{x:u,y:d,z:p}=s;if(u){var m=mn.degToRad(u);h.rotateX(m)}if(d){var f=mn.degToRad(d);h.rotateY(f)}if(p){var g=mn.degToRad(p);h.rotateZ(g)}var{x:v,y:_,z:x}=a;return v&&h.position.setX(v),_&&h.position.setY(_),x&&h.position.setZ(x),this.engine.model.add(h),h}createGeometry(e){var{type:t,params:n}=e,{BOX:i,CIRCLE:r,PLANE:s,RING:a,SPHERE:o}=q.APP_DB.MESH_TYPES;switch(t){case i:return console.warn("W_MIRROR_WITH_VOLUME","Mirror is using a BoxGeometry. Mirrors with volume will sometimes create rendering issues."),new Kr(...n);case r:return new zc(...n);case s:return new vs(...n);case a:return console.warn("W_MIRROR_WITH_VOLUME","Mirror is using a RingGeometry. Mirrors with volume will sometimes create rendering issues."),new Ah(...n);case o:return console.warn("W_MIRROR_WITH_VOLUME","Mirror is using a SphereGeometry. Mirrors with volume will sometimes create rendering issues."),new Ch(...n);default:return new vs(...n)}}}}),Ef=Object.freeze({__proto__:null,addPly:e=>{var n,{artifact:i,preload:r}=e,s=Qm(i.ply,{vertexColors:!0,size:.01,sizeAttenuation:!0,opacity:"1.0"}),a={x:0,y:0,z:0},o=Qm(i.ply,{positions:[],rotations:[],position:a,pos:a,rotation:a,rot:a});e.morphTargetInfluenceConfig=Qm(i.ply,{animated:!1,delay:1e3,speed:1});var l=new Go;l.name="plyGroup";var{position:c=o.pos,positions:h=[],rotation:u=o.rot,rotations:d=[],scale:p,scales:m=[]}=o,f=0!==c.x||0!==c.y||0!==c.z;if(X.arr(r.assets.ply)&&null!==(n=r.assets.ply)&&void 0!==n&&n.length)if(e.morphTargetInfluenceConfig.animated){var[g]=r.assets.ply;g.morphAttributes={position:[],color:[]},r.assets.ply.forEach((e=>{g.morphAttributes.position.push(e.attributes.position),g.morphAttributes.color.push(e.attributes.color)}));var v=new rc(t(t({},s),{},{transparent:"1.0"!==s.opacity})),_=new cc(g,v);if(_.morphTargetInfluences[0]=1,e.animatedPoints=_,e.morphTargetTargetIndex=1,l.add(_),f){var x=l.position,{x:y=x.x,y:M=x.y,z:S=x.z}=c;l.position.set(y,M,S)}}else r.assets.ply.forEach(((e,n)=>{var i=new rc(t(t({},s),{},{transparent:"1.0"!==s.opacity})),r=new cc(e,i);if(h[n]){var{x:a,y:o,z:f}=h[n];r.position.set(a,o,f)}else if(c){var{x:g,y:v,z:_}=c;r.position.set(g,v,_)}if(d[n]){var{x:x,y:y,z:M}=d[n];r.rotation.set(x,y,M)}else if(u){var{x:S,y:b,z:T}=u;r.rotation.set(S,b,T)}if(m[n]){var{x:w,y:E,z:A}=m[n];r.scale.set(w,E,A)}else if(p){var{x:R,y:C,z:P}=p;r.scale.set(R,C,P)}l.add(r)}));else{var b=new rc(t(t({},s),{},{transparent:"1.0"!==s.opacity}));if(l.add(new cc(r.assets.ply,b)),f){var T=l.position,{x:w=T.x,y:E=T.y,z:A=T.z}=c;l.position.set(w,E,A)}}e.model?e.model.add(l):e.model=l}});var Af=Object.freeze({__proto__:null,Particles:class{constructor(e){var{artifact:t,model:n,preload:i}=e;this.preload=i,this.model=n,this.defaultBox={x:10,y:10,z:10},this.particles=Qm(t.particles,[{name:"snowflake",size:.1,box:this.defaultBox}]),this.materials=[]}init(){var e=this;return i((function*(){var t=e.preload.textureLoader,n=new Go;yield Promise.all(e.particles.map(function(){var r=i((function*(i){var{box:r=e.defaultBox,color:s=16777215,count:a=1e3,name:o,size:l,imgType:c="png",opacity:h=1}=i,u=o;u.endsWith(".".concat(c))&&(u=u.replace(".".concat(c),"")),kp.WEBP?u+=".webp":u+=".".concat(c);for(var d=yield e.preload.promisifiedLoad({loader:t,file:"https://static.artificialmuseum.com/textures/matcap/".concat(u)}),p=new rc({size:l,map:d,color:s,blending:1,depthTest:!1,transparent:!0,opacity:h}),m=new Pr,f=[],g=0;g.5?-1:1)*Math.random()*(2*r.x)-r.x;var _=Math.random()*r.y,x=void 0;if(0===r.zMin)x=Math.random()*r.z;else x=(Math.random()>.5?-1:1)*Math.random()*(2*r.z)-r.z;f.push(v,_,x)}m.setAttribute("position",new Sr(f,3));var y=new cc(m,p);n.add(y)}));return function(e){return r.apply(this,arguments)}}())),e.model.add(n),e.particles=n}))()}update(e){var{delta:t}=e;this.particles.rotation.y+=.01*t}}});var Rf=Object.freeze({__proto__:null,LookAtCamera:class{constructor(e){this.lookAtPosition=new Vn;var{artifact:t,model:n}=e;n.traverse((n=>{var i=t.lookAtCameraObjects.find((e=>tf({node:n,search:X.str(e)?e:e.name})));if(i){var{speed:r,lookAtY:s=!0}=i;r=X.num(r)?r:t.lookAtSpeed,s=X.bool(t.lookAtY)?t.lookAtY:s,e.lookAtCameraObjects.push({speed:r,lookAtY:s,node:n,alpha:0})}}))}render(e){var{engine:t,delta:n}=e,{camera:i,lookAtCameraObjects:r=[],lookAtY:s}=t;r.forEach((e=>{var{lookAtY:t=!0,node:r,speed:a}=e;if(!1!==t&&!1!==s){var o,l,c,h;e.alpha+=n*a,this.lookAtPosition.x=0,this.lookAtPosition.y=0,this.lookAtPosition.z=r.position.distanceTo(i.position),!1!==t&&!1!==s||(this.lookAtPosition.y=0===r.position.y?.01:r.position.y),this.lookAtPosition.distanceToSquared(i.position)>.1?(this.lookAtPosition.lerp(i.position,Math.min(1,e.alpha)),r.lookAt(this.lookAtPosition)):e.alpha=0}else{var u=(o=i.position.x,l=r.position.x,c=i.position.z,h=r.position.z,Math.atan2(o-l,c-h));r.rotation.y=u}}))}}});var Cf=Object.freeze({__proto__:null,TextGeometry:class extends bh{constructor(e,t={}){const n=t.font;if(void 0===n)super();else{const i=n.generateShapes(e,t.size);t.depth=void 0!==t.height?t.height:50,void 0===t.bevelThickness&&(t.bevelThickness=10),void 0===t.bevelSize&&(t.bevelSize=8),void 0===t.bevelEnabled&&(t.bevelEnabled=!1),super(i,t)}this.type="TextGeometry"}}});var Pf=Object.freeze({__proto__:null,CustomMaterials:class{constructor(e){var{preload:t}=e,{customMaterials:n=[]}=t.assets;n.forEach((t=>{var{config:n,material:i}=t,{target:r}=n,s=e.model.getObjectByName(r);s&&(X.fn(i.init)&&i.init({engine:e,node:s,target:r}),s.material=i,e.customMaterials.push({config:n,material:i}))})),e.addRenderStep(this.tick.bind(this))}tick(e){var{delta:t,engine:n}=e;n.customMaterials.forEach((n=>{var{config:i,material:r}=n;if(r.uniforms.uTime){var{speed:s=1}=i;r.uniforms.uTime.value+=t*s}X.fn(r.tick)&&r.tick(e)}))}}}),Lf=["canvas","texture","scale","scene","shaderConfig"];class If extends ts{constructor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{canvas:t,texture:n,scale:i=1,scene:r,shaderConfig:a={}}=e;super(s(e,Lf)),this.scene=r;var o=new Fn;(t||n)&&(t?o=new pc(t):n&&(o=n),o.needsUpdate=!1,o.minFilter=ke,o.magFilter=ke,o.format=Qe);var{ptSize:l=1,sizeAttenuation:c=1}=a;this.shaderConfig=Qm(a,{filterSize:"1",minDepth:"0.1",maxDepth:"7.0",depthThresholdFilter:"1.0",scale:2*i,depthScale:"1.0",hueRedReducer:"0.0",pixelDepth:"3.0",ptSize:(parseFloat(l)*window.devicePixelRatio).toFixed(1).toString(),sizeAttenuation:(parseFloat(c)*window.devicePixelRatio).toFixed(2).toString(),alpha:1,iK:[0,0,0,0],width:1164,height:776}),this.uniforms={texImg:{type:"t",value:o},texSize:{type:"i2",value:[this.shaderConfig.width,this.shaderConfig.height]},iK:{type:"f4",value:this.shaderConfig.iK},scale:{type:"f",value:this.shaderConfig.scale},ptSize:{type:"f",value:this.shaderConfig.ptSize},alpha:{type:"f",value:this.shaderConfig.alpha},filterSize:{type:"f",value:this.shaderConfig.filterSize},minDepth:{type:"f",value:this.shaderConfig.minDepth},maxDepth:{type:"f",value:this.shaderConfig.maxDepth},depthThresholdFilter:{type:"f",value:this.shaderConfig.depthThresholdFilter},hueRedReducer:{type:"f",value:this.shaderConfig.hueRedReducer},pixelDepth:{type:"f",value:this.shaderConfig.pixelDepth},depthScale:{type:"f",value:this.shaderConfig.depthScale},sizeAttenuation:{type:"f",value:this.shaderConfig.sizeAttenuation}},this.side=fe,this.transparent=!1,this.vertexShader="\nattribute float vertexIdx;\n\nvarying float vVertexIdx;\nvarying vec2 vPtPos;\n\nuniform ivec2 texSize;\nuniform sampler2D texImg;\nuniform vec4 iK;\nuniform float scale;\nuniform float minDepth;\nuniform float maxDepth;\nuniform float pixelDepth;\nuniform int filterSize;\nuniform float ptSize;\nuniform float depthThresholdFilter;\nuniform float depthScale;\nuniform float hueRedReducer;\nuniform float sizeAttenuation;\n\n#include \n\nfloat rgb2hue(vec3 c) {\n float r = c.r - hueRedReducer;\n vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n vec4 q = mix(vec4(p.xyw, r), vec4(r, p.yzx), step(p.x, r));\n\n float d = q.x - min(q.w, q.y);\n float e = 1.0e-10;\n return abs(q.z + (q.w - q.y) / (6.0 * d + e));\n}\n\nfloat getPixelDepth(ivec2 pixel) {\n vec2 lookupPt = (vec2(pixel) + vec2(0.5)) / vec2(texSize);\n float hue = rgb2hue(texture2D(texImg, lookupPt).rgb);\n float pxDepth = pixelDepth * hue;\n if (pxDepth == 0.0) {\n return 1.0 * pixelDepth;\n }\n return pxDepth;\n}\n\nbool shouldDiscard(ivec2 currPixel) {\n float centerPixelDepth = getPixelDepth(currPixel);\n\n for (int i = -filterSize; i <= filterSize; i++) {\n for (int j = -filterSize; j <= filterSize; j++) {\n if (i == 0 && j == 0) {\n continue;\n }\n\n float currDepth = getPixelDepth(currPixel + ivec2(j, i));\n\n if (currDepth < minDepth\n || currDepth > maxDepth\n || abs(centerPixelDepth - currDepth) > depthThresholdFilter\n ) {\n return true;\n }\n }\n }\n\n return false;\n}\n\nvoid main() {\n ivec2 frameSize = ivec2(texSize.x / 2, texSize.y);\n int vertIdx = int(vertexIdx);\n\n int actualNumPts = frameSize.x * frameSize.y;\n if (vertIdx >= actualNumPts) {\n gl_Position = vec4(0.0);\n return;\n }\n\n int ptY = vertIdx / int(frameSize.x);\n int ptX = vertIdx - ptY * int(frameSize.x);\n\n ivec2 pt = ivec2(ptX, ptY);\n\n if (ptX <= 5 || shouldDiscard(pt)) {\n gl_Position = vec4(0.0);\n return;\n }\n\n float currDepth = getPixelDepth(pt);\n\n vec3 ptPos = scale * vec3(\n (iK.x * float(ptX) + iK.z) * currDepth,\n (iK.y * float(ptY) + iK.w) * currDepth,\n -currDepth * depthScale\n );\n\n vec4 mvPos = modelViewMatrix * vec4(ptPos, 1.0);\n gl_Position = projectionMatrix * mvPos;\n\n vPtPos = vec2(float(ptX), float(ptY));\n vVertexIdx = vertexIdx;\n\n gl_PointSize = ptSize;\n\n bool isPerspective = isPerspectiveMatrix(projectionMatrix);\n if ( isPerspective ) {\n gl_PointSize = max(ptSize, sizeAttenuation / -mvPos.z);\n }\n}\n",this.fragmentShader="\nvarying float vVertexIdx;\nvarying vec2 vPtPos;\n\nuniform ivec2 texSize;\nuniform sampler2D texImg;\nuniform float alpha;\n\nvoid main() {\n vec2 frameSizeF = vec2(texSize.x / 2, texSize.y);\n ivec2 frameSize = ivec2(frameSizeF);\n\n int vertIdx = int(vVertexIdx);\n int actualNumPts = frameSize.x * frameSize.y;\n if (vertIdx >= actualNumPts) {\n discard;\n }\n\n vec2 lookupPt = (vec2(vPtPos.x + frameSizeF.x, vPtPos.y) + vec2(0.5)) / vec2(texSize);\n vec3 currColor = texture2D(texImg, lookupPt).rgb;\n\n gl_FragColor = vec4(currColor, alpha);\n}\n"}}class Df{constructor(e){var{artifact:t,image:n,position:i,quaternion:r,intrinsicMatrix:s,scene:a}=e;this.imageSource=n;var o=new Go;this.imageObject=o;var{pos:l=t.position,rot:c=t.rotation}=t;if(l){var{x:h,y:u,z:d}=l;h&&(o.position.x+=h),u&&(o.position.y+=u),d&&(o.position.z+=d)}if(c){var{x:p,y:m,z:f}=c;p&&o.rotateX(p),m&&o.rotateY(m),f&&o.rotateZ(f)}var{width:g,height:v}=n.source.data,{ifx:_,ify:x,itx:y,ity:M}=s,S={iK:[_,x,y,M],width:g,height:v};this.material=new If({texture:n,scene:a,scale:1,shaderConfig:S}),o.position.set(i.x,i.y,i.z),o.quaternion.set(r.qx,r.qy,r.qz,r.qw);var b=g*v;this.buffIndices=new Uint32Array(b),this.buffPointIndicesAttr=new Float32Array(b);for(var T=0;T{var{position:t,quaternion:i,intrinsicMatrix:s=this.config.intrinsicMatrix,object:a}=e,o=new Df({artifact:r,image:a,position:t,quaternion:i,intrinsicMatrix:s,parent:n.scene});n.model.add(o.imageObject)}))}}});var Nf=Object.freeze({__proto__:null,Portal:class{constructor(e){var t,{engine:n,mergeConfig:i}=e;if(this.engine=n,this.config=i(n.artifact.portal,{parent:"portal",clip:"clip",door:"door",skyIn:"skyIn",skyOut:"skyOut",groundIn:"groundIn",groundOut:"groundOut",earth:"earthOut",earthOutside:"earthOutside",placard:"placard",placardImage:!1,textureTarget:"textureTarget",renderTarget:"clipRenderTarget",renderTarget2:"clipRenderTarget2",triggerAreas:"triggerAreas",isInsideDoor:"isInsideDoor",isOutsideDoor:"isOutsideDoor",ignoreChildren:!1,isInDoor:"isInDoor",showIn:"showIn",hideIn:"hideIn",excludedChildren:"earthOutside",opened:!0,rayCast:{near:.5,far:50},load:!0,pos:{x:0,y:0,z:0}}),this.opened=this.config.opened,this.meshNames=i(n.artifact.portal,{clip:"clip",door:"door",skyIn:"skyIn",skyOut:"skyOut",groundIn:"groundIn",groundOut:"groundOut",earth:"earthOut",placard:"placard",renderTarget:"clipRenderTarget",renderTarget2:"clipRenderTarget2",earthOutside:"earthOutside"}),this.isInside=!1,this.camera=n.camera,this.model=n.model,null!=n&&null!==(t=n.model)&&void 0!==t&&t.children&&!0!==this.config.ignoreChildren){var r=new Go;r.name="artifact",Object.entries(this.meshNames).forEach((e=>{var[t,i]=e,r=n.model.getObjectByName(i);r&&(this[t]=r)})),n.model.children.filter((e=>!this.config.excludedChildren.includes(e.name))).forEach((e=>{r.add(e),e.remove()})),this.children=[r];var{x:s,y:a,z:o}=this.config.pos;r.position.set(s,a,o),n.model.add(r)}else this.children=[];var l=n.model.getObjectByName("outside");this.outChildren=l?l.children:[],this.toggleOut(!1);var c=!1,h=!1,{glb:u,placardColor:d,placardNormal:p}=n.preload.assets.Portal;if(d&&(c=d),p&&(h=p),u){var{animations:m=[],scene:f}=u;m.length&&n.animations.push(...m),n.model?n.model.add(...f.children):n.model=f}var g=n.model.getObjectByName(this.config.parent);this.portal=g;var v=this.portal.getObjectByName("outside");v&&this.outChildren.push(...v.children);var _=this.portal.getObjectByName("inside");_&&this.children.push(..._.children),Object.entries(this.meshNames).forEach((e=>{var[t,n]=e,i=g.getObjectByName(n);i&&(this[t]?i.visible=!1:this[t]=i)}));var x=n.model.getObjectByName(this.meshNames.groundIn);if(x){if("portal"!==x.parent.parent.name){var y=g.getObjectByName(this.meshNames.groundIn);y&&y.position.set(5e3,5e3,5e3)}x.receiveShadow=!0}else console.error("groundIn not defined, looked for",this.meshNames.groundIn,n.model);var M=n.model.getObjectByName(this.meshNames.groundOut);if(M){if("portal"!==M.parent.parent.name){var S=g.getObjectByName(this.meshNames.groundOut);S&&S.position.set(5e3,5e3,5e3)}M.receiveShadow=!0}else console.error("groundOut not defined, looked for",this.meshNames.groundOut,n.model);var b=n.model.getObjectByName(this.meshNames.skyIn);if(b){b.receiveShadow=!1;var T=new ur;T.map=b.material.map,T.side=me,b.material=T}else console.error("skyIn not defined, looked for",this.meshNames.skyIn,n.model);var w=n.model.getObjectByName(this.meshNames.skyOut);if(w){w.receiveShadow=!1;var E=new ur;E.map=w.material.map,E.side=me,w.material=E}else console.error("skyOut not defined, looked for",this.meshNames.skyOut,n.model);this.renderTarget2&&(this.renderTarget2.visible=!1),this.config.textureTarget&&(this.textureTarget=g.getObjectByName(this.config.textureTarget),this.textureTarget&&(c?(this.textureTarget.material.map.source.data=c.source.data,h&&this.textureTarget.material.normalMap&&(this.textureTarget.material.normalMap.source.data=h.source.data),this.textureTarget.material.needsUpdate=!0):this.textureTarget.visible=!1)),this.triggerAreas=g.getObjectByName("triggerAreas"),this.triggerAreas.visible=!1,this.toggleOut(!1),this.toggleRenderTarget(!1),this.rayDirection=new Vn(0,-1,0);var{near:A,far:R}=this.config.rayCast;this.raycaster=new Ad(this.camera.position,this.rayDirection,A,R),this.lastIntersect=!1,this.door&&(this.door.castShadow=!0),n.addRenderStep(this.render.bind(this))}open(){this.opened=!0}close(){this.opened=!1}getTriggerArea(){var e;this.raycaster.set(this.camera.position,this.rayDirection);var[t]=this.raycaster.intersectObject(this.triggerAreas,!0);return null==t||null===(e=t.object)||void 0===e?void 0:e.name}setIfDifferent(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"visible";e&&(X.arr(e)?e:[e]).forEach((e=>{var i;e&&(e[n]!==t&&(e[n]=t),null!=e&&null!==(i=e.children)&&void 0!==i&&i.length&&e.traverse((e=>{e.hasOwnProperty(n)&&(e[n]=t)})))}))}toggleIn(e){this.setIfDifferent([this.skyIn,this.groundIn,...this.children],e)}toggleOut(e){this.setIfDifferent([this.skyOut,this.groundOut,this.earth,...this.outChildren],e),this.earthOutside&&this.setIfDifferent([this.earthOutside],!e)}toggleClip(e){this.setIfDifferent(this.clip,e)}togglePlacard(e){this.placard&&this.setIfDifferent(this.placard,e)}rotatePlacard(e){if(this.placard){var t=new Ci(0,mn.degToRad(e),0);this.placard.quaternion.setFromEuler(t)}}toggleRenderTarget(e){this.setIfDifferent(this.renderTarget,e)}walkInside(){this.opened?this.isInside||(this.toggleIn(!0),this.toggleOut(!0),this.toggleClip(!1),this.rotatePlacard(180),this.toggleRenderTarget(!0),this.isInside=!0):(this.toggleIn(!1),this.toggleOut(!1),this.toggleClip(!1),this.toggleRenderTarget(!1))}walkOutside(){this.isInside&&(this.toggleIn(!0),this.toggleOut(!1),this.toggleClip(!0),this.rotatePlacard(0),this.toggleRenderTarget(!1),this.isInside=!1)}render(){if(this.engine.modelSpawned){var e=this.getTriggerArea();if(e){if(this.lastIntersect!==e){var{isInsideDoor:t,isOutsideDoor:n,isInDoor:i,showIn:r,hideIn:s}=this.config,a=this.lastIntersect;e===t?a!==n&&a!==i||this.walkInside():e===n?a!==t&&a!==i||this.walkOutside():e===i&&(this.toggleIn(!0),this.toggleOut(a===n)),this.isInside||(e===r?(this.toggleIn(!0),this.toggleOut(!1),this.toggleClip(!0)):e===s&&(this.toggleIn(!1),this.toggleOut(!1),this.toggleClip(!1))),this.lastIntersect=e}}else this.lastIntersect=!1}}}});class Of extends Yr{constructor(e,t={}){super(e),this.isWater=!0;const n=this,i=void 0!==t.textureWidth?t.textureWidth:512,r=void 0!==t.textureHeight?t.textureHeight:512,s=void 0!==t.clipBias?t.clipBias:0,a=void 0!==t.alpha?t.alpha:1,o=void 0!==t.time?t.time:0,l=void 0!==t.waterNormals?t.waterNormals:null,c=void 0!==t.sunDirection?t.sunDirection:new Vn(.70707,.70707,0),h=new cr(void 0!==t.sunColor?t.sunColor:16777215),u=new cr(void 0!==t.waterColor?t.waterColor:8355711),d=void 0!==t.eye?t.eye:new Vn(0,0,0),p=void 0!==t.distortionScale?t.distortionScale:20,m=void 0!==t.side?t.side:pe,f=void 0!==t.fog&&t.fog,g=new us,v=new Vn,_=new Vn,x=new Vn,y=new xi,M=new Vn(0,0,-1),S=new zn,b=new Vn,T=new Vn,w=new zn,E=new xi,A=new is,R=new Bn(i,r),C={uniforms:es.merge([xs.fog,xs.lights,{normalSampler:{value:null},mirrorSampler:{value:null},alpha:{value:1},time:{value:0},size:{value:1},distortionScale:{value:20},textureMatrix:{value:new xi},sunColor:{value:new cr(8355711)},sunDirection:{value:new Vn(.70707,.70707,0)},eye:{value:new Vn},waterColor:{value:new cr(5592405)}}]),vertexShader:"\n\t\t\t\tuniform mat4 textureMatrix;\n\t\t\t\tuniform float time;\n\n\t\t\t\tvarying vec4 mirrorCoord;\n\t\t\t\tvarying vec4 worldPosition;\n\n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\t\t\t\t\tmirrorCoord = modelMatrix * vec4( position, 1.0 );\n\t\t\t\t\tworldPosition = mirrorCoord.xyzw;\n\t\t\t\t\tmirrorCoord = textureMatrix * mirrorCoord;\n\t\t\t\t\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t\tgl_Position = projectionMatrix * mvPosition;\n\n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t}",fragmentShader:"\n\t\t\t\tuniform sampler2D mirrorSampler;\n\t\t\t\tuniform float alpha;\n\t\t\t\tuniform float time;\n\t\t\t\tuniform float size;\n\t\t\t\tuniform float distortionScale;\n\t\t\t\tuniform sampler2D normalSampler;\n\t\t\t\tuniform vec3 sunColor;\n\t\t\t\tuniform vec3 sunDirection;\n\t\t\t\tuniform vec3 eye;\n\t\t\t\tuniform vec3 waterColor;\n\n\t\t\t\tvarying vec4 mirrorCoord;\n\t\t\t\tvarying vec4 worldPosition;\n\n\t\t\t\tvec4 getNoise( vec2 uv ) {\n\t\t\t\t\tvec2 uv0 = ( uv / 103.0 ) + vec2(time / 17.0, time / 29.0);\n\t\t\t\t\tvec2 uv1 = uv / 107.0-vec2( time / -19.0, time / 31.0 );\n\t\t\t\t\tvec2 uv2 = uv / vec2( 8907.0, 9803.0 ) + vec2( time / 101.0, time / 97.0 );\n\t\t\t\t\tvec2 uv3 = uv / vec2( 1091.0, 1027.0 ) - vec2( time / 109.0, time / -113.0 );\n\t\t\t\t\tvec4 noise = texture2D( normalSampler, uv0 ) +\n\t\t\t\t\t\ttexture2D( normalSampler, uv1 ) +\n\t\t\t\t\t\ttexture2D( normalSampler, uv2 ) +\n\t\t\t\t\t\ttexture2D( normalSampler, uv3 );\n\t\t\t\t\treturn noise * 0.5 - 1.0;\n\t\t\t\t}\n\n\t\t\t\tvoid sunLight( const vec3 surfaceNormal, const vec3 eyeDirection, float shiny, float spec, float diffuse, inout vec3 diffuseColor, inout vec3 specularColor ) {\n\t\t\t\t\tvec3 reflection = normalize( reflect( -sunDirection, surfaceNormal ) );\n\t\t\t\t\tfloat direction = max( 0.0, dot( eyeDirection, reflection ) );\n\t\t\t\t\tspecularColor += pow( direction, shiny ) * sunColor * spec;\n\t\t\t\t\tdiffuseColor += max( dot( sunDirection, surfaceNormal ), 0.0 ) * sunColor * diffuse;\n\t\t\t\t}\n\n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\t#include \n\t\t\t\t\tvec4 noise = getNoise( worldPosition.xz * size );\n\t\t\t\t\tvec3 surfaceNormal = normalize( noise.xzy * vec3( 1.5, 1.0, 1.5 ) );\n\n\t\t\t\t\tvec3 diffuseLight = vec3(0.0);\n\t\t\t\t\tvec3 specularLight = vec3(0.0);\n\n\t\t\t\t\tvec3 worldToEye = eye-worldPosition.xyz;\n\t\t\t\t\tvec3 eyeDirection = normalize( worldToEye );\n\t\t\t\t\tsunLight( surfaceNormal, eyeDirection, 100.0, 2.0, 0.5, diffuseLight, specularLight );\n\n\t\t\t\t\tfloat distance = length(worldToEye);\n\n\t\t\t\t\tvec2 distortion = surfaceNormal.xz * ( 0.001 + 1.0 / distance ) * distortionScale;\n\t\t\t\t\tvec3 reflectionSample = vec3( texture2D( mirrorSampler, mirrorCoord.xy / mirrorCoord.w + distortion ) );\n\n\t\t\t\t\tfloat theta = max( dot( eyeDirection, surfaceNormal ), 0.0 );\n\t\t\t\t\tfloat rf0 = 0.3;\n\t\t\t\t\tfloat reflectance = rf0 + ( 1.0 - rf0 ) * pow( ( 1.0 - theta ), 5.0 );\n\t\t\t\t\tvec3 scatter = max( 0.0, dot( surfaceNormal, eyeDirection ) ) * waterColor;\n\t\t\t\t\tvec3 albedo = mix( ( sunColor * diffuseLight * 0.3 + scatter ) * getShadowMask(), ( vec3( 0.1 ) + reflectionSample * 0.9 + reflectionSample * specularLight ), reflectance);\n\t\t\t\t\tvec3 outgoingLight = albedo;\n\t\t\t\t\tgl_FragColor = vec4( outgoingLight, alpha );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\t\t\t\t\t#include \t\n\t\t\t\t}"},P=new ts({fragmentShader:C.fragmentShader,vertexShader:C.vertexShader,uniforms:es.clone(C.uniforms),lights:!0,side:m,fog:f});P.uniforms.mirrorSampler.value=R.texture,P.uniforms.textureMatrix.value=E,P.uniforms.alpha.value=a,P.uniforms.time.value=o,P.uniforms.normalSampler.value=l,P.uniforms.sunColor.value=h,P.uniforms.waterColor.value=u,P.uniforms.sunDirection.value=c,P.uniforms.distortionScale.value=p,P.uniforms.eye.value=d,n.material=P,n.onBeforeRender=function(e,t,i){if(_.setFromMatrixPosition(n.matrixWorld),x.setFromMatrixPosition(i.matrixWorld),y.extractRotation(n.matrixWorld),v.set(0,0,1),v.applyMatrix4(y),b.subVectors(_,x),b.dot(v)>0)return;b.reflect(v).negate(),b.add(_),y.extractRotation(i.matrixWorld),M.set(0,0,-1),M.applyMatrix4(y),M.add(x),T.subVectors(_,M),T.reflect(v).negate(),T.add(_),A.position.copy(b),A.up.set(0,1,0),A.up.applyMatrix4(y),A.up.reflect(v),A.lookAt(T),A.far=i.far,A.updateMatrixWorld(),A.projectionMatrix.copy(i.projectionMatrix),E.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),E.multiply(A.projectionMatrix),E.multiply(A.matrixWorldInverse),g.setFromNormalAndCoplanarPoint(v,_),g.applyMatrix4(A.matrixWorldInverse),S.set(g.normal.x,g.normal.y,g.normal.z,g.constant);const r=A.projectionMatrix;w.x=(Math.sign(S.x)+r.elements[8])/r.elements[0],w.y=(Math.sign(S.y)+r.elements[9])/r.elements[5],w.z=-1,w.w=(1+r.elements[10])/r.elements[14],S.multiplyScalar(2/S.dot(w)),r.elements[2]=S.x,r.elements[6]=S.y,r.elements[10]=S.z+1-s,r.elements[14]=S.w,d.setFromMatrixPosition(i.matrixWorld);const a=e.getRenderTarget(),o=e.xr.enabled,l=e.shadowMap.autoUpdate;n.visible=!1,e.xr.enabled=!1,e.shadowMap.autoUpdate=!1,e.setRenderTarget(R),e.state.buffers.depth.setMask(!0),!1===e.autoClear&&e.clear(),e.render(t,A),n.visible=!0,e.xr.enabled=o,e.shadowMap.autoUpdate=l,e.setRenderTarget(a);const c=i.viewport;void 0!==c&&e.state.viewport(c)}}}var Ff=Object.freeze({__proto__:null,OceanPlane:class{constructor(e){var{artifact:t,engine:n,preload:i}=e;this.config=Qm(t.ocean,{normals:"oceannormals1",name:"ocean"});var r=n.model.getObjectByName(this.config.name),{waterNormals:s}=i.assets;s.wrapS=s.wrapT=Ue,n.ocean=new Of(r.geometry,{textureWidth:512,textureHeight:512,waterNormals:s,sunDirection:new Vn,sunColor:16777215,waterColor:1048575,distortionScale:3.7,fog:!1}),n.ocean.position.copy(r.position),n.ocean.rotation.copy(r.rotation),n.model.add(n.ocean),r.visible=!1}render(e){var{delta:t,engine:n}=e,{animationSpeed:i=1}=n.artifact.ocean;n.ocean.material.uniforms.time.value+=t*i*.1}}});var zf=Object.freeze({__proto__:null,VideoTrigger:class{constructor(e){var{artifact:t,videoElement:n}=e,i=["videotarget","videotrigger"],{videoTriggerName:r=!1,videoTriggerHide:s=!0}=t;r&&i.push(r),e.model.traverse((e=>{this.ele||i.some((t=>$m(e.name,t)))&&(this.ele=e,s&&(this.ele.visible=!1))})),n.currentTime=.01,this.ele&&e.addRenderStep(this.render.bind(this))}render(e){var{engine:t}=e;if(t.modelSpawned&&t.artifact.triggerVideo&&this.ele){var{audioElement:n,camera:i,videoElement:r}=t,{triggerAudio:s,triggerVideo:a,triggerVideoDistance:o=1.1,videoTriggerExitOnDistance:l=!0,videoTriggerPauseWhenLeaving:c=!0,videoTriggerHide:h=!0}=t.artifact,u=this.ele.position.clone();u.add(this.ele.parent.position);var d=i.position.distanceTo(u),p=r.paused;d<=o?(a&&r&&p&&(r.play(),this.ele.visible=!0),s&&n&&n.paused&&n.play()):(!p&&a&&l&&(c&&(r.pause(),r.currentTime=0),h&&(this.ele.visible=!1)),s&&n&&!n.paused&&n.pause())}}}});var Bf=Object.freeze({__proto__:null,UnderwaterPlane:class{constructor(e){var{engine:t}=e;t.addRenderStep(this.render.bind(this))}preload(e){var t=this;return i((function*(){var{camera:n,preload:i}=e,r=new lf;yield r.preload(i),t.material=r;var s=new vs(2,2),a=new Yr(s,r);n.add(a),a.position.z-=.1}))()}render(e){var{delta:t,engine:n}=e;n.modelSpawned&&this.material.tick(t)}}});export{op as $,ve as A,Pr as B,ur as C,fe as D,Nu as E,pe as F,Su as G,Ee as H,Kr as I,jh as J,Go as K,jt as L,Bh as M,Fe as N,Wi as O,cc as P,Sc as Q,sf as R,ts as S,ep as T,Dh as U,uc as V,q as W,Wm as X,cr as Y,Qu as Z,t as _,X as a,P as a$,ld as a0,cd as a1,zu as a2,ql as a3,nc as a4,Vn as a5,of as a6,rc as a7,$m as a8,du as a9,el as aA,w as aB,is as aC,Ko as aD,H as aE,be as aF,ue as aG,G as aH,ie as aI,Bn as aJ,Fu as aK,Fh as aL,R as aM,Ah as aN,tf as aO,Xm as aP,me as aQ,Fs as aR,$o as aS,Qo as aT,rf as aU,L as aV,Wt as aW,Ym as aX,k as aY,Jm as aZ,A as a_,It as aa,Td as ab,mn as ac,Hh as ad,Ad as ae,ge as af,Uh as ag,Sr as ah,Mr as ai,Qm as aj,Qe as ak,ke as al,J as am,$t as an,le as ao,ce as ap,Gn as aq,Pd as ar,fn as as,E as at,Ci as au,V as av,W as aw,xp as ax,yp as ay,nd as az,Cp as b,I as b0,Vp as b1,Bm as b2,Hm as b3,Zm as b4,U as b5,Hp as b6,C as b7,z as b8,p as b9,Nf as bA,Ff as bB,zf as bC,Bf as bD,F as ba,nf as bb,d as bc,r as bd,u as be,se as bf,o as bg,c as bh,a as bi,xi as bj,Lh as bk,kc as bl,lf as bm,af as bn,cf as bo,uf as bp,df as bq,ff as br,Sf as bs,wf as bt,Ef as bu,Af as bv,Rf as bw,Cf as bx,Pf as by,Uf as bz,i as c,N as d,m as e,g as f,v as g,rp as h,b as i,j,Pp as k,f as l,ip as m,Lp as n,D as o,Ip as p,Up as q,ae as r,kp as s,T as t,xr as u,vs as v,re as w,Yr as x,Ch as y,O as z}; diff --git a/docs/vendor.js.gz b/docs/vendor.js.gz index 6350c308..beded2e3 100644 Binary files a/docs/vendor.js.gz and b/docs/vendor.js.gz differ