import{L as OQ,M as u0,N as hH,O as oC,P as bD,Q as VB,R as pA,S as NE,T as n,V as dB,W as cB}from"./chunk-vmf3nj8h.js";import{$ as kU,Y as WL,_ as xQ}from"./chunk-kmey03h3.js";class CK{#A=[];add(A,Q=0,B=Symbol()){let E=this.#A.findIndex((I)=>I.priority>Q);if(E===-1)this.#A.push({fn:A,priority:Q,id:B});else this.#A.splice(E,0,{fn:A,priority:Q,id:B});return()=>this.remove(B)}remove(A){this.#A=this.#A.filter((Q)=>Q.id!==A)}notify(A){if(this.#A.length<1)return;this.#A.forEach((Q)=>Q.fn(A))}}class V6 extends CK{constructor(){super();n.ticker.add(this.update.bind(this))}update(A,Q){this.notify({deltaTime:A,time:Q*0.01})}}class k6 extends CK{width=window.innerWidth;height=window.innerHeight;timeoutId=null;debounceDelay=100;constructor(){super();window.addEventListener("resize",this.update.bind(this))}update(){if(this.timeoutId)window.clearTimeout(this.timeoutId);this.timeoutId=window.setTimeout(()=>{let{innerWidth:A,innerHeight:Q}=window;if(A!==this.width||Q!==this.height)this.width=A,this.height=Q,this.notify({width:this.width,height:this.height});this.timeoutId=null},this.debounceDelay)}}var CE=new V6,WQ=new k6;class w6{#A;#B=new Set;constructor(A){this.#A=A}get(){return this.#A}set(A){this.#A=A,this.#B.forEach((Q)=>{Q(this.#A)})}subscribe(A){return this.#B.add(A),A(this.#A),()=>{this.#B.delete(A)}}listen(A){return this.subscribe(A)}}class z6{#A=!1;#B=null;#Q=new w6({width:typeof window<"u"?window.innerWidth:0,height:typeof window<"u"?window.innerHeight:0,breakpoint:null,variant:"desktop"});#E={"mobile-l":480,tablet:768,desktop:992,large:1921};init(){if(typeof window>"u")return;if(this.#A)return;this.#A=!0,this.#F({emitViewportEvent:!1}),this.#J(),this.#G();let{variant:A}=this.#Q.get();document.documentElement.classList.toggle("desktop",A==="desktop"),document.documentElement.classList.toggle("mobile",A==="mobile")}#J(){this.#B=WQ.add(()=>{this.#I()})}#I(){this.#F(),this.#G()}#U(A){if(A>=this.#E.large)return"large";if(A>=this.#E.desktop)return"desktop";if(A>=this.#E.tablet)return"tablet";if(A>=this.#E["mobile-l"])return"mobile-l";return"mobile"}#C(A){return!window.matchMedia("(any-pointer: coarse)").matches&&A>=this.#E.tablet?"desktop":"mobile"}#F({emitViewportEvent:A=!0}={}){let{innerWidth:Q,innerHeight:B}=window,E=this.#U(Q),I=this.#C(Q),C=this.#Q.get(),G=Q!==C.width||B!==C.height||I!==C.variant,K=E!==C.breakpoint;if(G||K){if(this.#Q.set({...C,width:Q,height:B,breakpoint:E,variant:I}),I!==C.variant)document.documentElement.classList.toggle("desktop",I==="desktop"),document.documentElement.classList.toggle("mobile",I==="mobile")}if(K)window.dispatchEvent(new CustomEvent("breakpoint:change",{detail:{from:C.breakpoint,to:E}}));if(A&&(G||K))window.dispatchEvent(new CustomEvent("viewport:change",{detail:this.#Q.get()}))}#G(){let A=window.innerWidth*0.01,Q=window.innerHeight*0.01;document.documentElement.style.setProperty("--vw",`${A}px`),document.documentElement.style.setProperty("--vh",`${Q}px`)}get store(){return this.#Q}get state(){return this.#Q.get()}get width(){return this.#Q.get().width}get height(){return this.#Q.get().height}get breakpoint(){return this.#Q.get().breakpoint}get variant(){return this.#Q.get().variant}is(A){return this.#Q.get().breakpoint===A}isAtLeast(A){let Q=["mobile","mobile-l","tablet","desktop","large"],B=Q.indexOf(this.breakpoint),E=Q.indexOf(A);return B>=E}get isMobile(){return this.#Q.get().variant==="mobile"}get isDesktop(){return this.#Q.get().variant==="desktop"}destroy(){this.#B?.(),this.#B=null,this.#A=!1}}var MQ=new z6;var OY="1.3.17";function T6(A,Q,B){return Math.max(A,Math.min(Q,B))}function VY(A,Q,B){return(1-B)*A+B*Q}function kY(A,Q,B,E){return VY(A,Q,1-Math.exp(-B*E))}function wY(A,Q){return(A%Q+Q)%Q}var zY=class{isRunning=!1;value=0;from=0;to=0;currentTime=0;lerp;duration;easing;onUpdate;advance(A){if(!this.isRunning)return;let Q=!1;if(this.duration&&this.easing){this.currentTime+=A;let B=T6(0,this.currentTime/this.duration,1);Q=B>=1;let E=Q?1:this.easing(B);this.value=this.from+(this.to-this.from)*E}else if(this.lerp){if(this.value=kY(this.value,this.to,this.lerp*60,A),Math.round(this.value)===this.to)this.value=this.to,Q=!0}else this.value=this.to,Q=!0;if(Q)this.stop();this.onUpdate?.(this.value,Q)}stop(){this.isRunning=!1}fromTo(A,Q,{lerp:B,duration:E,easing:I,onStart:C,onUpdate:G}){this.from=this.value=A,this.to=Q,this.lerp=B,this.duration=E,this.easing=I,this.currentTime=0,this.isRunning=!0,C?.(),this.onUpdate=G}};function _Y(A,Q){let B;return function(...E){let I=this;clearTimeout(B),B=setTimeout(()=>{B=void 0,A.apply(I,E)},Q)}}var PY=class{constructor(A,Q,{autoResize:B=!0,debounce:E=250}={}){if(this.wrapper=A,this.content=Q,B){if(this.debouncedResize=_Y(this.resize,E),this.wrapper instanceof Window)window.addEventListener("resize",this.debouncedResize,!1);else this.wrapperResizeObserver=new ResizeObserver(this.debouncedResize),this.wrapperResizeObserver.observe(this.wrapper);this.contentResizeObserver=new ResizeObserver(this.debouncedResize),this.contentResizeObserver.observe(this.content)}this.resize()}width=0;height=0;scrollHeight=0;scrollWidth=0;debouncedResize;wrapperResizeObserver;contentResizeObserver;destroy(){if(this.wrapperResizeObserver?.disconnect(),this.contentResizeObserver?.disconnect(),this.wrapper===window&&this.debouncedResize)window.removeEventListener("resize",this.debouncedResize,!1)}resize=()=>{this.onWrapperResize(),this.onContentResize()};onWrapperResize=()=>{if(this.wrapper instanceof Window)this.width=window.innerWidth,this.height=window.innerHeight;else this.width=this.wrapper.clientWidth,this.height=this.wrapper.clientHeight};onContentResize=()=>{if(this.wrapper instanceof Window)this.scrollHeight=this.content.scrollHeight,this.scrollWidth=this.content.scrollWidth;else this.scrollHeight=this.wrapper.scrollHeight,this.scrollWidth=this.wrapper.scrollWidth};get limit(){return{x:this.scrollWidth-this.width,y:this.scrollHeight-this.height}}},S6=class{events={};emit(A,...Q){let B=this.events[A]||[];for(let E=0,I=B.length;E{this.events[A]=this.events[A]?.filter((B)=>Q!==B)}}off(A,Q){this.events[A]=this.events[A]?.filter((B)=>Q!==B)}destroy(){this.events={}}},_6=16.666666666666668,sE={passive:!1},TY=class{constructor(A,Q={wheelMultiplier:1,touchMultiplier:1}){this.element=A,this.options=Q,window.addEventListener("resize",this.onWindowResize,!1),this.onWindowResize(),this.element.addEventListener("wheel",this.onWheel,sE),this.element.addEventListener("touchstart",this.onTouchStart,sE),this.element.addEventListener("touchmove",this.onTouchMove,sE),this.element.addEventListener("touchend",this.onTouchEnd,sE)}touchStart={x:0,y:0};lastDelta={x:0,y:0};window={width:0,height:0};emitter=new S6;on(A,Q){return this.emitter.on(A,Q)}destroy(){this.emitter.destroy(),window.removeEventListener("resize",this.onWindowResize,!1),this.element.removeEventListener("wheel",this.onWheel,sE),this.element.removeEventListener("touchstart",this.onTouchStart,sE),this.element.removeEventListener("touchmove",this.onTouchMove,sE),this.element.removeEventListener("touchend",this.onTouchEnd,sE)}onTouchStart=(A)=>{let{clientX:Q,clientY:B}=A.targetTouches?A.targetTouches[0]:A;this.touchStart.x=Q,this.touchStart.y=B,this.lastDelta={x:0,y:0},this.emitter.emit("scroll",{deltaX:0,deltaY:0,event:A})};onTouchMove=(A)=>{let{clientX:Q,clientY:B}=A.targetTouches?A.targetTouches[0]:A,E=-(Q-this.touchStart.x)*this.options.touchMultiplier,I=-(B-this.touchStart.y)*this.options.touchMultiplier;this.touchStart.x=Q,this.touchStart.y=B,this.lastDelta={x:E,y:I},this.emitter.emit("scroll",{deltaX:E,deltaY:I,event:A})};onTouchEnd=(A)=>{this.emitter.emit("scroll",{deltaX:this.lastDelta.x,deltaY:this.lastDelta.y,event:A})};onWheel=(A)=>{let{deltaX:Q,deltaY:B,deltaMode:E}=A,I=E===1?_6:E===2?this.window.width:1,C=E===1?_6:E===2?this.window.height:1;Q*=I,B*=C,Q*=this.options.wheelMultiplier,B*=this.options.wheelMultiplier,this.emitter.emit("scroll",{deltaX:Q,deltaY:B,event:A})};onWindowResize=()=>{this.window={width:window.innerWidth,height:window.innerHeight}}},P6=(A)=>Math.min(1,1.001-Math.pow(2,-10*A)),j6=class{_isScrolling=!1;_isStopped=!1;_isLocked=!1;_preventNextNativeScrollEvent=!1;_resetVelocityTimeout=null;_rafId=null;isTouching;time=0;userData={};lastVelocity=0;velocity=0;direction=0;options;targetScroll;animatedScroll;animate=new zY;emitter=new S6;dimensions;virtualScroll;constructor({wrapper:A=window,content:Q=document.documentElement,eventsTarget:B=A,smoothWheel:E=!0,syncTouch:I=!1,syncTouchLerp:C=0.075,touchInertiaExponent:G=1.7,duration:K,easing:J,lerp:U=0.1,infinite:F=!1,orientation:R="vertical",gestureOrientation:D=R==="horizontal"?"both":"vertical",touchMultiplier:H=1,wheelMultiplier:M=1,autoResize:X=!0,prevent:Y,virtualScroll:q,overscroll:N=!0,autoRaf:$=!1,anchors:L=!1,autoToggle:k=!1,allowNestedScroll:O=!1,__experimental__naiveDimensions:w=!1,naiveDimensions:Z=w,stopInertiaOnNavigate:z=!1}={}){if(window.lenisVersion=OY,!A||A===document.documentElement)A=window;if(typeof K==="number"&&typeof J!=="function")J=P6;else if(typeof J==="function"&&typeof K!=="number")K=1;if(this.options={wrapper:A,content:Q,eventsTarget:B,smoothWheel:E,syncTouch:I,syncTouchLerp:C,touchInertiaExponent:G,duration:K,easing:J,lerp:U,infinite:F,gestureOrientation:D,orientation:R,touchMultiplier:H,wheelMultiplier:M,autoResize:X,prevent:Y,virtualScroll:q,overscroll:N,autoRaf:$,anchors:L,autoToggle:k,allowNestedScroll:O,naiveDimensions:Z,stopInertiaOnNavigate:z},this.dimensions=new PY(A,Q,{autoResize:X}),this.updateClassName(),this.targetScroll=this.animatedScroll=this.actualScroll,this.options.wrapper.addEventListener("scroll",this.onNativeScroll,!1),this.options.wrapper.addEventListener("scrollend",this.onScrollEnd,{capture:!0}),this.options.anchors||this.options.stopInertiaOnNavigate)this.options.wrapper.addEventListener("click",this.onClick,!1);if(this.options.wrapper.addEventListener("pointerdown",this.onPointerDown,!1),this.virtualScroll=new TY(B,{touchMultiplier:H,wheelMultiplier:M}),this.virtualScroll.on("scroll",this.onVirtualScroll),this.options.autoToggle)this.checkOverflow(),this.rootElement.addEventListener("transitionend",this.onTransitionEnd,{passive:!0});if(this.options.autoRaf)this._rafId=requestAnimationFrame(this.raf)}destroy(){if(this.emitter.destroy(),this.options.wrapper.removeEventListener("scroll",this.onNativeScroll,!1),this.options.wrapper.removeEventListener("scrollend",this.onScrollEnd,{capture:!0}),this.options.wrapper.removeEventListener("pointerdown",this.onPointerDown,!1),this.options.anchors||this.options.stopInertiaOnNavigate)this.options.wrapper.removeEventListener("click",this.onClick,!1);if(this.virtualScroll.destroy(),this.dimensions.destroy(),this.cleanUpClassName(),this._rafId)cancelAnimationFrame(this._rafId)}on(A,Q){return this.emitter.on(A,Q)}off(A,Q){return this.emitter.off(A,Q)}onScrollEnd=(A)=>{if(!(A instanceof CustomEvent)){if(this.isScrolling==="smooth"||this.isScrolling===!1)A.stopPropagation()}};dispatchScrollendEvent=()=>{this.options.wrapper.dispatchEvent(new CustomEvent("scrollend",{bubbles:this.options.wrapper===window,detail:{lenisScrollEnd:!0}}))};get overflow(){let A=this.isHorizontal?"overflow-x":"overflow-y";return getComputedStyle(this.rootElement)[A]}checkOverflow(){if(["hidden","clip"].includes(this.overflow))this.internalStop();else this.internalStart()}onTransitionEnd=(A)=>{if(A.propertyName.includes("overflow"))this.checkOverflow()};setScroll(A){if(this.isHorizontal)this.options.wrapper.scrollTo({left:A,behavior:"instant"});else this.options.wrapper.scrollTo({top:A,behavior:"instant"})}onClick=(A)=>{let B=A.composedPath().filter((E)=>E instanceof HTMLAnchorElement&&E.getAttribute("href"));if(this.options.anchors){let E=B.find((I)=>I.getAttribute("href")?.includes("#"));if(E){let I=E.getAttribute("href");if(I){let C=typeof this.options.anchors==="object"&&this.options.anchors?this.options.anchors:void 0,G=`#${I.split("#")[1]}`;this.scrollTo(G,C)}}}if(this.options.stopInertiaOnNavigate){if(B.find((I)=>I.host===window.location.host))this.reset()}};onPointerDown=(A)=>{if(A.button===1)this.reset()};onVirtualScroll=(A)=>{if(typeof this.options.virtualScroll==="function"&&this.options.virtualScroll(A)===!1)return;let{deltaX:Q,deltaY:B,event:E}=A;if(this.emitter.emit("virtual-scroll",{deltaX:Q,deltaY:B,event:E}),E.ctrlKey)return;if(E.lenisStopPropagation)return;let I=E.type.includes("touch"),C=E.type.includes("wheel");this.isTouching=E.type==="touchstart"||E.type==="touchmove";let G=Q===0&&B===0;if(this.options.syncTouch&&I&&E.type==="touchstart"&&G&&!this.isStopped&&!this.isLocked){this.reset();return}let J=this.options.gestureOrientation==="vertical"&&B===0||this.options.gestureOrientation==="horizontal"&&Q===0;if(G||J)return;let U=E.composedPath();U=U.slice(0,U.indexOf(this.rootElement));let F=this.options.prevent;if(U.find((Y)=>Y instanceof HTMLElement&&(typeof F==="function"&&F?.(Y)||Y.hasAttribute?.("data-lenis-prevent")||I&&Y.hasAttribute?.("data-lenis-prevent-touch")||C&&Y.hasAttribute?.("data-lenis-prevent-wheel")||this.options.allowNestedScroll&&this.checkNestedScroll(Y,{deltaX:Q,deltaY:B}))))return;if(this.isStopped||this.isLocked){if(E.cancelable)E.preventDefault();return}if(!(this.options.syncTouch&&I||this.options.smoothWheel&&C)){this.isScrolling="native",this.animate.stop(),E.lenisStopPropagation=!0;return}let D=B;if(this.options.gestureOrientation==="both")D=Math.abs(B)>Math.abs(Q)?B:Q;else if(this.options.gestureOrientation==="horizontal")D=Q;if(!this.options.overscroll||this.options.infinite||this.options.wrapper!==window&&this.limit>0&&(this.animatedScroll>0&&this.animatedScroll0||this.animatedScroll===this.limit&&B<0))E.lenisStopPropagation=!0;if(E.cancelable)E.preventDefault();let H=I&&this.options.syncTouch,X=I&&E.type==="touchend";if(X)D=Math.sign(this.velocity)*Math.pow(Math.abs(this.velocity),this.options.touchInertiaExponent);this.scrollTo(this.targetScroll+D,{programmatic:!1,...H?{lerp:X?this.options.syncTouchLerp:1}:{lerp:this.options.lerp,duration:this.options.duration,easing:this.options.easing}})};resize(){this.dimensions.resize(),this.animatedScroll=this.targetScroll=this.actualScroll,this.emit()}emit(){this.emitter.emit("scroll",this)}onNativeScroll=()=>{if(this._resetVelocityTimeout!==null)clearTimeout(this._resetVelocityTimeout),this._resetVelocityTimeout=null;if(this._preventNextNativeScrollEvent){this._preventNextNativeScrollEvent=!1;return}if(this.isScrolling===!1||this.isScrolling==="native"){let A=this.animatedScroll;if(this.animatedScroll=this.targetScroll=this.actualScroll,this.lastVelocity=this.velocity,this.velocity=this.animatedScroll-A,this.direction=Math.sign(this.animatedScroll-A),!this.isStopped)this.isScrolling="native";if(this.emit(),this.velocity!==0)this._resetVelocityTimeout=setTimeout(()=>{this.lastVelocity=this.velocity,this.velocity=0,this.isScrolling=!1,this.emit()},400)}};reset(){this.isLocked=!1,this.isScrolling=!1,this.animatedScroll=this.targetScroll=this.actualScroll,this.lastVelocity=this.velocity=0,this.animate.stop()}start(){if(!this.isStopped)return;if(this.options.autoToggle){this.rootElement.style.removeProperty("overflow");return}this.internalStart()}internalStart(){if(!this.isStopped)return;this.reset(),this.isStopped=!1,this.emit()}stop(){if(this.isStopped)return;if(this.options.autoToggle){this.rootElement.style.setProperty("overflow","clip");return}this.internalStop()}internalStop(){if(this.isStopped)return;this.reset(),this.isStopped=!0,this.emit()}raf=(A)=>{let Q=A-(this.time||A);if(this.time=A,this.animate.advance(Q*0.001),this.options.autoRaf)this._rafId=requestAnimationFrame(this.raf)};scrollTo(A,{offset:Q=0,immediate:B=!1,lock:E=!1,programmatic:I=!0,lerp:C=I?this.options.lerp:void 0,duration:G=I?this.options.duration:void 0,easing:K=I?this.options.easing:void 0,onStart:J,onComplete:U,force:F=!1,userData:R}={}){if((this.isStopped||this.isLocked)&&!F)return;if(typeof A==="string"&&["top","left","start","#"].includes(A))A=0;else if(typeof A==="string"&&["bottom","right","end"].includes(A))A=this.limit;else{let D;if(typeof A==="string"){if(D=document.querySelector(A),!D)if(A==="#top")A=0;else console.warn("Lenis: Target not found",A)}else if(A instanceof HTMLElement&&A?.nodeType)D=A;if(D){if(this.options.wrapper!==window){let M=this.rootElement.getBoundingClientRect();Q-=this.isHorizontal?M.left:M.top}let H=D.getBoundingClientRect();A=(this.isHorizontal?H.left:H.top)+this.animatedScroll}}if(typeof A!=="number")return;if(A+=Q,A=Math.round(A),this.options.infinite){if(I){this.targetScroll=this.animatedScroll=this.scroll;let D=A-this.animatedScroll;if(D>this.limit/2)A=A-this.limit;else if(D<-this.limit/2)A=A+this.limit}}else A=T6(0,A,this.limit);if(A===this.targetScroll){J?.(this),U?.(this);return}if(this.userData=R??{},B){this.animatedScroll=this.targetScroll=A,this.setScroll(this.scroll),this.reset(),this.preventNextNativeScrollEvent(),this.emit(),U?.(this),this.userData={},requestAnimationFrame(()=>{this.dispatchScrollendEvent()});return}if(!I)this.targetScroll=A;if(typeof G==="number"&&typeof K!=="function")K=P6;else if(typeof K==="function"&&typeof G!=="number")G=1;this.animate.fromTo(this.animatedScroll,A,{duration:G,easing:K,lerp:C,onStart:()=>{if(E)this.isLocked=!0;this.isScrolling="smooth",J?.(this)},onUpdate:(D,H)=>{if(this.isScrolling="smooth",this.lastVelocity=this.velocity,this.velocity=D-this.animatedScroll,this.direction=Math.sign(this.velocity),this.animatedScroll=D,this.setScroll(this.scroll),I)this.targetScroll=D;if(!H)this.emit();if(H)this.reset(),this.emit(),U?.(this),this.userData={},requestAnimationFrame(()=>{this.dispatchScrollendEvent()}),this.preventNextNativeScrollEvent()}})}preventNextNativeScrollEvent(){this._preventNextNativeScrollEvent=!0,requestAnimationFrame(()=>{this._preventNextNativeScrollEvent=!1})}checkNestedScroll(A,{deltaX:Q,deltaY:B}){let E=Date.now(),I=A._lenis??={},C,G,K,J,U,F,R,D,H=this.options.gestureOrientation;if(E-(I.time??0)>2000){I.time=Date.now();let k=window.getComputedStyle(A);I.computedStyle=k;let{overflowX:O,overflowY:w}=k;if(C=["auto","overlay","scroll"].includes(O),G=["auto","overlay","scroll"].includes(w),I.hasOverflowX=C,I.hasOverflowY=G,!C&&!G)return!1;if(H==="vertical"&&!G)return!1;if(H==="horizontal"&&!C)return!1;U=A.scrollWidth,F=A.scrollHeight,R=A.clientWidth,D=A.clientHeight,K=U>R,J=F>D,I.isScrollableX=K,I.isScrollableY=J,I.scrollWidth=U,I.scrollHeight=F,I.clientWidth=R,I.clientHeight=D}else K=I.isScrollableX,J=I.isScrollableY,C=I.hasOverflowX,G=I.hasOverflowY,U=I.scrollWidth,F=I.scrollHeight,R=I.clientWidth,D=I.clientHeight;if(!C&&!G||!K&&!J)return!1;if(H==="vertical"&&(!G||!J))return!1;if(H==="horizontal"&&(!C||!K))return!1;let M;if(H==="horizontal")M="x";else if(H==="vertical")M="y";else{let k=Q!==0,O=B!==0;if(k&&C&&K)M="x";if(O&&G&&J)M="y"}if(!M)return!1;let X,Y,q,N,$;if(M==="x")X=A.scrollLeft,Y=U-R,q=Q,N=C,$=K;else if(M==="y")X=A.scrollTop,Y=F-D,q=B,N=G,$=J;else return!1;return(q>0?X0)&&N&&$}get rootElement(){return this.options.wrapper===window?document.documentElement:this.options.wrapper}get limit(){if(this.options.naiveDimensions)if(this.isHorizontal)return this.rootElement.scrollWidth-this.rootElement.clientWidth;else return this.rootElement.scrollHeight-this.rootElement.clientHeight;else return this.dimensions.limit[this.isHorizontal?"x":"y"]}get isHorizontal(){return this.options.orientation==="horizontal"}get actualScroll(){let A=this.options.wrapper;return this.isHorizontal?A.scrollX??A.scrollLeft:A.scrollY??A.scrollTop}get scroll(){return this.options.infinite?wY(this.animatedScroll,this.limit):this.animatedScroll}get progress(){return this.limit===0?1:this.scroll/this.limit}get isScrolling(){return this._isScrolling}set isScrolling(A){if(this._isScrolling!==A)this._isScrolling=A,this.updateClassName()}get isStopped(){return this._isStopped}set isStopped(A){if(this._isStopped!==A)this._isStopped=A,this.updateClassName()}get isLocked(){return this._isLocked}set isLocked(A){if(this._isLocked!==A)this._isLocked=A,this.updateClassName()}get isSmooth(){return this.isScrolling==="smooth"}get className(){let A="lenis";if(this.options.autoToggle)A+=" lenis-autoToggle";if(this.isStopped)A+=" lenis-stopped";if(this.isLocked)A+=" lenis-locked";if(this.isScrolling)A+=" lenis-scrolling";if(this.isScrolling==="smooth")A+=" lenis-smooth";return A}updateClassName(){this.cleanUpClassName(),this.rootElement.className=`${this.rootElement.className} ${this.className}`.trim()}cleanUpClassName(){this.rootElement.className=this.rootElement.className.replace(/lenis(-\w+)?/g,"").trim()}};function GK(){return GK=Object.assign?Object.assign.bind():function(A){for(var Q=1;Q{A.forEach((Q)=>{let B=this.scrollElements.find((E)=>E.$el===Q.target);Q.isIntersecting?(B&&(B.isAlreadyIntersected=!0),this._setInview(Q)):B&&B.isAlreadyIntersected&&this._setOutOfView(Q)})},{root:this.root,rootMargin:this.rootMargin});for(let A of this.scrollElements)this.observe(A.$el)}destroy(){this.observer.disconnect()}observe(A){A&&this.observer.observe(A)}unobserve(A){A&&this.observer.unobserve(A)}_setInview(A){let Q=this.scrollElements.find((B)=>B.$el===A.target);this.IORaf&&(Q==null||Q.setInteractivityOn()),!this.IORaf&&(Q==null||Q.setInview())}_setOutOfView(A){let Q=this.scrollElements.find((B)=>B.$el===A.target);this.IORaf&&(Q==null||Q.setInteractivityOff()),!this.IORaf&&(Q==null||Q.setOutOfView()),Q!=null&&Q.attributes.scrollRepeat||this.IORaf||this.unobserve(A.target)}}function f6(A,Q,B,E,I){return B+((I-A)/(Q-A)*(E-B)||0)}function y6(A,Q){return A.reduce((B,E)=>Math.abs(E-Q)D-H+M,middle:(D,H,M,X)=>D-H+M+0.5*X,end:(D,H,M,X)=>D-H+M+X,fold:()=>0},this.endPositionHandlers={start:(D,H)=>D-H,middle:(D,H,M)=>D-H+0.5*M,end:(D,H,M)=>D-H+M},this.$el=A,this.id=Q,this.needRaf=I,this.scrollOrientation=C,this.lenisInstance=G,this.subscribeElementUpdateFn=B,this.unsubscribeElementUpdateFn=E,this.attributes={scrollClass:(K=this.$el.dataset.scrollClass)!=null?K:"is-inview",scrollOffset:(J=this.$el.dataset.scrollOffset)!=null?J:"0,0",scrollPosition:(U=this.$el.dataset.scrollPosition)!=null?U:"start,end",scrollCssProgress:this.$el.dataset.scrollCssProgress!==void 0,scrollEventProgress:(F=this.$el.dataset.scrollEventProgress)!=null?F:null,scrollSpeed:this.$el.dataset.scrollSpeed!==void 0?parseFloat(this.$el.dataset.scrollSpeed):null,scrollRepeat:this.$el.dataset.scrollRepeat!==void 0,scrollCall:(R=this.$el.dataset.scrollCall)!=null?R:null,scrollIgnoreFold:this.$el.dataset.scrollIgnoreFold!==void 0,scrollEnableTouchSpeed:this.$el.dataset.scrollEnableTouchSpeed!==void 0},this.intersection={start:0,end:0},this.metrics={offsetStart:0,offsetEnd:0,bcr:{}},this.currentScroll=this.lenisInstance.scroll,this.translateValue=0,this.progress=0,this.lastProgress=null,this.isInview=!1,this.isInteractive=!1,this.isAlreadyIntersected=!1,this.isInFold=!1,this.isFirstResize=!0,this.getWindowSize=this.scrollOrientation==="vertical"?()=>this.lenisInstance.dimensions.height:()=>this.lenisInstance.dimensions.width,this.getMetricsStart=this.scrollOrientation==="vertical"?(D)=>D.top:(D)=>D.left,this.getMetricsSize=this.scrollOrientation==="vertical"?(D)=>D.height:(D)=>D.width,this._init()}_init(){this.needRaf&&this._resize()}onResize({currentScroll:A}){this.currentScroll=A,this._resize()}onRender({currentScroll:A,smooth:Q}){let B=this.getWindowSize();if(this.currentScroll=A,this._computeProgress(),this.attributes.scrollSpeed&&!isNaN(this.attributes.scrollSpeed))if(this.attributes.scrollEnableTouchSpeed||Q){if(this.isInFold){let E=Math.max(0,this.progress);this.translateValue=E*B*this.attributes.scrollSpeed*-1}else{let E=f6(0,1,-1,1,this.progress);this.translateValue=E*B*this.attributes.scrollSpeed*-1}this.$el.style.transform=this.scrollOrientation==="vertical"?`translate3d(0, ${this.translateValue}px, 0)`:`translate3d(${this.translateValue}px, 0, 0)`}else this.translateValue&&(this.$el.style.transform="translate3d(0, 0, 0)"),this.translateValue=0}setInview(){if(this.isInview)return;this.isInview=!0,this.$el.classList.add(this.attributes.scrollClass);let A=this._getScrollCallFrom();this.attributes.scrollCall&&this._dispatchCall("enter",A)}setOutOfView(){if(!this.isInview||!this.attributes.scrollRepeat)return;this.isInview=!1,this.$el.classList.remove(this.attributes.scrollClass);let A=this._getScrollCallFrom();this.attributes.scrollCall&&this._dispatchCall("leave",A)}setInteractivityOn(){this.isInteractive||(this.isInteractive=!0,this.subscribeElementUpdateFn(this))}setInteractivityOff(){this.isInteractive&&(this.isInteractive=!1,this.unsubscribeElementUpdateFn(this),this.lastProgress!==null&&this._computeProgress(y6([0,1],this.lastProgress)))}_resize(){this.metrics.bcr=this.$el.getBoundingClientRect(),this._computeMetrics(),this._computeIntersection(),this.isFirstResize&&(this.isFirstResize=!1,this.isInFold&&this.setInview())}_computeMetrics(){let A=this.getWindowSize(),Q=this.getMetricsStart(this.metrics.bcr),B=this.getMetricsSize(this.metrics.bcr);this.metrics.offsetStart=this.currentScroll+Q-this.translateValue,this.metrics.offsetEnd=this.metrics.offsetStart+B,this.isInFold=this.metrics.offsetStart1?1:B;var B;this.progress=Q,Q!==this.lastProgress&&(this.lastProgress=Q,this.attributes.scrollCssProgress&&this._setCssProgress(Q),this.attributes.scrollEventProgress&&this._setCustomEventProgress(Q),Q>0&&Q<1&&this.setInview(),Q===0&&this.setOutOfView(),Q===1&&this.setOutOfView())}_setCssProgress(A=0){this.$el.style.setProperty(g6,A.toString())}_setCustomEventProgress(A=0){let Q=this.attributes.scrollEventProgress;if(!Q)return;let B=new CustomEvent(Q,{detail:{target:this.$el,progress:A}});window.dispatchEvent(B)}_getScrollCallFrom(){let A=y6([this.intersection.start,this.intersection.end],this.currentScroll);return this.intersection.start===A?"start":"end"}destroy(){this.attributes.scrollCssProgress&&this.$el.style.removeProperty(g6),this.attributes.scrollSpeed&&this.$el.style.removeProperty("transform"),this.isInview&&this.attributes.scrollClass&&this.$el.classList.remove(this.attributes.scrollClass)}_dispatchCall(A,Q){let B=this.attributes.scrollCall;if(!B)return;let E=new CustomEvent(B,{detail:{target:this.$el,way:A,from:Q}});window.dispatchEvent(E)}}var SY=["scrollOffset","scrollPosition","scrollCssProgress","scrollEventProgress","scrollSpeed"];class x6{constructor({$el:A,triggerRootMargin:Q,rafRootMargin:B,scrollOrientation:E,lenisInstance:I}){this.$scrollContainer=void 0,this.triggerRootMargin=void 0,this.rafRootMargin=void 0,this.scrollElements=void 0,this.triggeredScrollElements=void 0,this.RAFScrollElements=void 0,this.scrollElementsToUpdate=void 0,this.IOTriggerInstance=void 0,this.IORafInstance=void 0,this.scrollOrientation=void 0,this.lenisInstance=void 0,A?(this.$scrollContainer=A,this.lenisInstance=I,this.scrollOrientation=E,this.triggerRootMargin=Q!=null?Q:"-1px -1px -1px -1px",this.rafRootMargin=B!=null?B:"100% 100% 100% 100%",this.scrollElements=[],this.triggeredScrollElements=[],this.RAFScrollElements=[],this.scrollElementsToUpdate=[],this._init()):console.error("Please provide a DOM Element as scrollContainer")}_init(){let A=this.$scrollContainer.querySelectorAll("[data-scroll]"),Q=this.toElementArray(A);this._subscribeScrollElements(Q);let B=this.lenisInstance.options.wrapper===window?null:this.lenisInstance.options.wrapper;this.IOTriggerInstance=new KK({scrollElements:[...this.triggeredScrollElements],root:B,rootMargin:this.triggerRootMargin,IORaf:!1}),this.IORafInstance=new KK({scrollElements:[...this.RAFScrollElements],root:B,rootMargin:this.rafRootMargin,IORaf:!0})}destroy(){this.IOTriggerInstance.destroy(),this.IORafInstance.destroy(),this._unsubscribeAllScrollElements()}onResize({currentScroll:A}){for(let Q of this.RAFScrollElements)Q.onResize({currentScroll:A})}onRender({currentScroll:A,smooth:Q}){for(let B of this.scrollElementsToUpdate)B.onRender({currentScroll:A,smooth:Q})}removeScrollElements(A){let Q=A.querySelectorAll("[data-scroll]");if(!Q.length)return;let B=new Set(Array.from(Q));for(let E=0;E{let I=this.scrollElementsToUpdate.find((G)=>G.$el===E),C=this.scrollElements.find((G)=>G.$el===E);I&&this._unsubscribeElementUpdate(I),C&&(this.scrollElements=this.scrollElements.filter((G)=>G.id!=C.id))})}addScrollElements(A){let Q=A.querySelectorAll("[data-scroll]"),B=[];this.scrollElements.forEach((C)=>{B.push(C.id)});let E=Math.max(...B,0)+1,I=this.toElementArray(Q);this._subscribeScrollElements(I,E,!0)}_subscribeScrollElements(A,Q=0,B=!1){for(let E=0;EQ.id!=A.id)}toElementArray(A){return Array.from(A)}_checkRafNeeded(A){let Q=[...SY],B=(E)=>{Q=Q.filter((I)=>I!==E)};if(A.dataset.scrollOffset){if(A.dataset.scrollOffset.split(",").map((E)=>E.replace("%","").trim()).join(",")!=="0,0")return!0;B("scrollOffset")}else B("scrollOffset");if(A.dataset.scrollPosition){if(A.dataset.scrollPosition.trim()!=="top,bottom")return!0;B("scrollPosition")}else B("scrollPosition");if(A.dataset.scrollSpeed&&!isNaN(parseFloat(A.dataset.scrollSpeed)))return!0;B("scrollSpeed");for(let E of Q)if(E in A.dataset)return!0;return!1}}class JK{constructor({lenisOptions:A={},triggerRootMargin:Q,rafRootMargin:B,autoStart:E=!0,scrollCallback:I=()=>{},initCustomTicker:C,destroyCustomTicker:G}={}){this.rafPlaying=void 0,this.lenisInstance=null,this.coreInstance=null,this.lenisOptions=void 0,this.triggerRootMargin=void 0,this.rafRootMargin=void 0,this.rafInstance=void 0,this.autoStart=void 0,this.isTouchDevice=void 0,this.initCustomTicker=void 0,this.destroyCustomTicker=void 0,this._onRenderBind=void 0,this._onResizeBind=void 0,this._onScrollToBind=void 0,this._originalOnContentResize=void 0,this._originalOnWrapperResize=void 0,window.locomotiveScrollVersion="5.0.0",Object.assign(this,{lenisOptions:A,triggerRootMargin:Q,rafRootMargin:B,autoStart:E,scrollCallback:I,initCustomTicker:C,destroyCustomTicker:G}),this._onRenderBind=this._onRender.bind(this),this._onScrollToBind=this._onScrollTo.bind(this),this._onResizeBind=this._onResize.bind(this),this.rafPlaying=!1,this.isTouchDevice="ontouchstart"in window||navigator.maxTouchPoints>0,this._init()}_init(){this.lenisInstance=new j6(GK({},this.lenisOptions)),this.scrollCallback&&this.lenisInstance.on("scroll",this.scrollCallback),document.documentElement.setAttribute("data-scroll-orientation",this.lenisInstance.options.orientation),requestAnimationFrame(()=>{this.coreInstance=new x6({$el:this.lenisInstance.rootElement,triggerRootMargin:this.triggerRootMargin,rafRootMargin:this.rafRootMargin,scrollOrientation:this.lenisInstance.options.orientation,lenisInstance:this.lenisInstance}),this._bindEvents(),this.initCustomTicker&&!this.destroyCustomTicker?console.warn("initCustomTicker callback is declared, but destroyCustomTicker is not. Please pay attention. It could cause trouble."):!this.initCustomTicker&&this.destroyCustomTicker&&console.warn("destroyCustomTicker callback is declared, but initCustomTicker is not. Please pay attention. It could cause trouble."),this.autoStart&&this.start()})}destroy(){var A;this.stop(),this._unbindEvents(),(A=this.lenisInstance)==null||A.destroy(),requestAnimationFrame(()=>{var Q;(Q=this.coreInstance)==null||Q.destroy()})}_bindEvents(){this._bindScrollToEvents(),this.lenisInstance&&(this._originalOnContentResize=this.lenisInstance.dimensions.onContentResize.bind(this.lenisInstance.dimensions),this._originalOnWrapperResize=this.lenisInstance.dimensions.onWrapperResize.bind(this.lenisInstance.dimensions),this.lenisInstance.dimensions.onContentResize=()=>{var A;(A=this._originalOnContentResize)==null||A.call(this),this._onResizeBind()},this.lenisInstance.dimensions.onWrapperResize=()=>{var A;(A=this._originalOnWrapperResize)==null||A.call(this),this._onResizeBind()})}_unbindEvents(){this._unbindScrollToEvents(),this.lenisInstance&&(this._originalOnContentResize&&(this.lenisInstance.dimensions.onContentResize=this._originalOnContentResize),this._originalOnWrapperResize&&(this.lenisInstance.dimensions.onWrapperResize=this._originalOnWrapperResize))}_bindScrollToEvents(A){var Q;let B=A||((Q=this.lenisInstance)==null?void 0:Q.rootElement),E=B==null?void 0:B.querySelectorAll("[data-scroll-to]");(E==null?void 0:E.length)&&E.forEach((I)=>{I.addEventListener("click",this._onScrollToBind,!1)})}_unbindScrollToEvents(A){var Q;let B=A||((Q=this.lenisInstance)==null?void 0:Q.rootElement),E=B==null?void 0:B.querySelectorAll("[data-scroll-to]");(E==null?void 0:E.length)&&E.forEach((I)=>{I.removeEventListener("click",this._onScrollToBind,!1)})}_onResize(){var A,Q,B;(A=this.coreInstance)==null||A.onResize({currentScroll:(Q=(B=this.lenisInstance)==null?void 0:B.scroll)!=null?Q:0,smooth:!this.isTouchDevice})}_onRender(){var A,Q,B,E;(A=this.lenisInstance)==null||A.raf(Date.now()),(Q=this.coreInstance)==null||Q.onRender({currentScroll:(B=(E=this.lenisInstance)==null?void 0:E.scroll)!=null?B:0,smooth:!this.isTouchDevice})}_onScrollTo(A){var Q,B;A.preventDefault();let E=(Q=A.currentTarget)!=null?Q:null;if(!E)return;let I=E.getAttribute("data-scroll-to-href")||E.getAttribute("href"),C=E.getAttribute("data-scroll-to-offset")||0,G=E.getAttribute("data-scroll-to-duration")||((B=this.lenisInstance)==null?void 0:B.options.duration);I&&this.scrollTo(I,{offset:typeof C=="string"?parseInt(C):C,duration:typeof G=="string"?parseInt(G):G})}start(){var A;this.rafPlaying||((A=this.lenisInstance)==null||A.start(),this.rafPlaying=!0,this.initCustomTicker?this.initCustomTicker(this._onRenderBind):this._raf())}stop(){var A;this.rafPlaying&&((A=this.lenisInstance)==null||A.stop(),this.rafPlaying=!1,this.destroyCustomTicker?this.destroyCustomTicker(this._onRenderBind):this.rafInstance&&cancelAnimationFrame(this.rafInstance))}removeScrollElements(A){var Q;A?(this._unbindScrollToEvents(A),(Q=this.coreInstance)==null||Q.removeScrollElements(A)):console.error("Please provide a DOM Element as $oldContainer")}addScrollElements(A){var Q;A?((Q=this.coreInstance)==null||Q.addScrollElements(A),requestAnimationFrame(()=>{this._bindScrollToEvents(A)})):console.error("Please provide a DOM Element as $newContainer")}resize(){this._onResizeBind()}scrollTo(A,Q){var B;(B=this.lenisInstance)==null||B.scrollTo(A,{offset:Q==null?void 0:Q.offset,lerp:Q==null?void 0:Q.lerp,duration:Q==null?void 0:Q.duration,immediate:Q==null?void 0:Q.immediate,lock:Q==null?void 0:Q.lock,force:Q==null?void 0:Q.force,easing:Q==null?void 0:Q.easing,onComplete:Q==null?void 0:Q.onComplete})}_raf(){this._onRenderBind(),this.rafInstance=requestAnimationFrame(()=>this._raf())}}var G8=new Set,tI=null,K8=null,UK=()=>{let A=document.body.firstElementChild;return A instanceof HTMLElement&&A.classList.contains("w-editor-publish-node")},jY=(A)=>{G8.forEach((Q)=>Q(A))},fY=()=>{if(tI)return;K8=UK(),tI=new MutationObserver((A)=>{if(!A.some((B)=>B.type==="childList"))return;let Q=UK();if(Q===K8)return;K8=Q,jY(Q)}),tI.observe(document.body,{childList:!0,subtree:!1})};function zQ(A){let Q=UK();if(!A)return Q;return fY(),G8.add(A),A(Q),()=>{if(G8.delete(A),G8.size===0&&tI)tI.disconnect(),tI=null,K8=null}}var yY=768,FK=()=>typeof window<"u"&&window.innerWidth"u")return;if(document.readyState==="complete"){this.#Z();return}if(this.#Y)return;this.#Y=!0,window.addEventListener("load",()=>{this.#Z()},{once:!0})}#$(){if(typeof window>"u")return;if(window.location.hash)return;if("scrollRestoration"in history)history.scrollRestoration="manual";window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0}#Z(){if(this.#A){console.warn("Scroll already initialized");return}if(this.#Y=!1,this.#$(),this.#q(document),this.#A=new JK({autoStart:!1,lenisOptions:gY,initCustomTicker:(A)=>{this.#R.set(A,CE.add(A))},destroyCustomTicker:(A)=>{this.#R.get(A)?.(),this.#R.delete(A)},scrollCallback:(A)=>this.#k(A)}),n.ticker.lagSmoothing(0),this.#H)this.#A.start();else this.#A.lenisInstance?.stop();this.#O()}#O(){this.#E=MQ.store.subscribe(()=>{let A=MQ.breakpoint,Q=MQ.variant;if(A!==this.#K.breakpoint||Q!==this.#K.variant)this.#K.breakpoint=A,this.#K.variant=Q,this.#q(document);this.resize()})}#q(A=document){let Q=MQ.breakpoint,B=MQ.variant;this.#K.breakpoint=Q,this.#K.variant=B;let E=["[data-scroll-speed-mobile]","[data-scroll-speed-mobile-l]","[data-scroll-speed-tablet]","[data-scroll-speed-desktop]","[data-scroll-speed-large]"].join(",");A.querySelectorAll(E).forEach((I)=>{let C=this.#V(I,{breakpoint:Q,variant:B});if(C==null)return;I.setAttribute("data-scroll-speed",String(C))})}#V(A,{breakpoint:Q,variant:B}){if(Q){let C=A.getAttribute(`data-scroll-speed-${Q}`);if(C!=null&&C!=="")return C}let E=A.getAttribute(`data-scroll-speed-${B}`);if(E!=null&&E!=="")return E;let I=A.getAttribute("data-scroll-speed");if(I!=null&&I!=="")return I;return null}#k(A){let{scroll:Q,limit:B,velocity:E,direction:I,progress:C}=A,G=document.documentElement;if(typeof Q==="number"){let K=Q<10,J=Q<80;if(G.classList.toggle("is-scroll-top",J),typeof C==="number"){if(C>this.#J)this.#I=1,this.#D=!1,G.classList.remove("is-scrolling-up"),G.classList.add("is-scrolling-down");else if(C{this.#N(!0)};#L=()=>{this.#z()};#W=()=>{this.#_()};#N(A=!0){let Q=this.#M();if(!Q)return;let B=A!==!1;if(this.#F===B||this.#G)return;Q.setAttribute("aria-hidden",String(!B)),Q.classList.toggle("is-sticky",B),this.#F=B}#z(){this.#N(!0),this.#G=!0}#_(){this.#G=!1}get scroll(){return this.#A?.lenisInstance?.scroll??0}get limit(){return this.#A?.lenisInstance?.limit??0}get velocity(){return this.#A?.lenisInstance?.velocity??0}get direction(){return this.#A?.lenisInstance?.direction??this.#I}get progress(){return this.#A?.lenisInstance?.progress??0}toTop(){if(!this.#A)return;this.#A.scrollTo(0,{immediate:!0})}scrollTo(A,Q){if(!this.#A)return;this.#A.scrollTo(A,Q)}start(){if(this.#H=!0,!this.#A)return;this.#A.start()}stop(){if(this.#H=!1,!this.#A)return;this.#A.stop(),this.#A.lenisInstance?.stop()}resize(){if(!this.#A)return;this.#A.resize()}destroy(){if(!this.#A)return;this.#E?.(),this.#E=null;let A=this.#M();if(A&&this.#C)A.removeEventListener("mousemove",this.#X),A.removeEventListener("mouseenter",this.#L),A.removeEventListener("mouseleave",this.#W),this.#C=!1;this.#A.destroy(),this.#A=null,this.#R.forEach((Q)=>Q()),this.#R.clear()}addElements(A){if(!this.#A)return;this.#q(A),this.#A.addScrollElements(A)}removeElements(A){if(!this.#A)return;this.#A.removeScrollElements(A)}on(A,Q){return this.#Q[A].push(Q),()=>{this.off(A,Q)}}off(A,Q){this.#Q[A]=this.#Q[A].filter((B)=>B!==Q)}add(A,Q=0,B=Symbol()){let E=this.#B.findIndex((I)=>I.priority>Q);if(E===-1)this.#B.push({fn:A,priority:Q,id:B});else this.#B.splice(E,0,{fn:A,priority:Q,id:B});return()=>this.remove(B)}remove(A){this.#B=this.#B.filter((Q)=>Q.id!==A)}notify(A){if(this.#Q.scroll.forEach((Q)=>Q(A)),this.#B.length<1)return;this.#B.forEach((Q)=>Q.fn(A))}}var NQ=new v6;zQ((A)=>{if(A)NQ.destroy();else NQ.start()});class b6{static isWebGL2Available(){try{let A=document.createElement("canvas");return!!(window.WebGL2RenderingContext&&A.getContext("webgl2"))}catch(A){return!1}}static isColorSpaceAvailable(A){try{let Q=document.createElement("canvas"),B=window.WebGL2RenderingContext&&Q.getContext("webgl2");return B.drawingBufferColorSpace=A,B.drawingBufferColorSpace===A}catch(Q){return!1}}static getWebGL2ErrorMessage(){return this._getErrorMessage(2)}static _getErrorMessage(A){let Q={1:"WebGL",2:"WebGL 2"},B={1:window.WebGLRenderingContext,2:window.WebGL2RenderingContext},E='Your $0 does not seem to support $1',I=document.createElement("div");if(I.id="webglmessage",I.style.fontFamily="monospace",I.style.fontSize="13px",I.style.fontWeight="normal",I.style.textAlign="center",I.style.background="#fff",I.style.color="#000",I.style.padding="1.5em",I.style.width="400px",I.style.margin="5em auto 0",B[A])E=E.replace("$0","graphics card");else E=E.replace("$0","browser");return E=E.replace("$1",Q[A]),I.innerHTML=E,I}}var RK=b6;var VF="184",AI={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},QI={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},kF=0,pK=1,wF=2;var GC=1,zF=2,M0=3,GB=0,iQ=1,mB=2,UE=0,KC=1,uK=2,mK=3,lK=4,_F=5;var N0=100,PF=101,TF=102,SF=103,jF=104,fF=200,yF=201,gF=202,hF=203,xF=204,vF=205,bF=206,pF=207,uF=208,mF=209,lF=210,cF=211,dF=212,nF=213,sF=214,iF=0,oF=1,aF=2,cK=3,rF=4,tF=5,eF=6,AR=7,QR=0,BR=1,ER=2,AE=0,dK=1,nK=2,sK=3,iK=4,oK=5,aK=6,rK=7;var Z0=301,zI=302,x8=303,v8=304,JC=306,TB=1000,X0=1001,b8=1002,WB=1003,L0=1004;var _I=1005;var VQ=1006,W0=1007;var SB=1008;var FQ=1009,IR=1010,CR=1011,BI=1012,tK=1013,EI=1014,NB=1015,KB=1016,eK=1017,AJ=1018,$0=1020,UC=35902,FC=35899,GR=1021,O0=1022,BB=1023,PI=1026,TI=1027,II=1028,QJ=1029,jB=1030,BJ=1031;var EJ=1033,SI=33776,CI=33777,p8=33778,GI=33779,RC=35840,IJ=35841,jI=35842,V0=35843,DC=36196,k0=37492,w0=37496,HC=37488,YC=37489,z0=37490,qC=37491,KI=37808,CJ=37809,GJ=37810,KJ=37811,fI=37812,JJ=37813,UJ=37814,FJ=37815,RJ=37816,DJ=37817,HJ=37818,YJ=37819,qJ=37820,MJ=37821,yI=36492,NJ=36494,MC=36495,NC=36283,ZC=36284,_0=36285,XC=36286;var ZJ=2300,u8=2301;var XJ=0,LC=1,P0=2;var hY=3201;var LJ=0,KR=1,FE="",fB="srgb",pQ="srgb-linear",m8="linear",jQ="srgb";var JR=512,UR=513,FR=514,l8=515,RR=516,DR=517,c8=518,HR=519;var xY=35048;var WJ="300 es",$J=2000;function vY(A){for(let Q=A.length-1;Q>=0;--Q)if(A[Q]>=65535)return!0;return!1}function bY(A){return ArrayBuffer.isView(A)&&!(A instanceof DataView)}function Y0(A){return document.createElementNS("http://www.w3.org/1999/xhtml",A)}function YR(){let A=Y0("canvas");return A.style.display="block",A}var p6={},q0=null;function CC(...A){let Q="THREE."+A.shift();if(q0)q0("log",Q,...A);else console.log(Q,...A)}function qR(A){let Q=A[0];if(typeof Q==="string"&&Q.startsWith("TSL:")){let B=A[1];if(B&&B.isStackTrace)A[0]+=" "+B.getLocation();else A[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return A}function mA(...A){A=qR(A);let Q="THREE."+A.shift();if(q0)q0("warn",Q,...A);else{let B=A[0];if(B&&B.isStackTrace)console.warn(B.getError(Q));else console.warn(Q,...A)}}function CQ(...A){A=qR(A);let Q="THREE."+A.shift();if(q0)q0("error",Q,...A);else{let B=A[0];if(B&&B.isStackTrace)console.error(B.getError(Q));else console.error(Q,...A)}}function y8(...A){let Q=A.join(" ");if(Q in p6)return;p6[Q]=!0,mA(...A)}function MR(A,Q,B){return new Promise(function(E,I){function C(){switch(A.clientWaitSync(Q,A.SYNC_FLUSH_COMMANDS_BIT,0)){case A.WAIT_FAILED:I();break;case A.TIMEOUT_EXPIRED:setTimeout(C,B);break;default:E()}}setTimeout(C,B)})}var NR={[0]:1,[2]:6,[4]:7,[3]:5,[1]:0,[6]:2,[7]:4,[5]:3};class RE{addEventListener(A,Q){if(this._listeners===void 0)this._listeners={};let B=this._listeners;if(B[A]===void 0)B[A]=[];if(B[A].indexOf(Q)===-1)B[A].push(Q)}hasEventListener(A,Q){let B=this._listeners;if(B===void 0)return!1;return B[A]!==void 0&&B[A].indexOf(Q)!==-1}removeEventListener(A,Q){let B=this._listeners;if(B===void 0)return;let E=B[A];if(E!==void 0){let I=E.indexOf(Q);if(I!==-1)E.splice(I,1)}}dispatchEvent(A){let Q=this._listeners;if(Q===void 0)return;let B=Q[A.type];if(B!==void 0){A.target=this;let E=B.slice(0);for(let I=0,C=E.length;I>8&255]+FB[A>>16&255]+FB[A>>24&255]+"-"+FB[Q&255]+FB[Q>>8&255]+"-"+FB[Q>>16&15|64]+FB[Q>>24&255]+"-"+FB[B&63|128]+FB[B>>8&255]+"-"+FB[B>>16&255]+FB[B>>24&255]+FB[E&255]+FB[E>>8&255]+FB[E>>16&255]+FB[E>>24&255]).toLowerCase()}function ZQ(A,Q,B){return Math.max(Q,Math.min(B,A))}function OJ(A,Q){return(A%Q+Q)%Q}function pY(A,Q,B,E,I){return E+(A-Q)*(I-E)/(B-Q)}function uY(A,Q,B){if(A!==Q)return(B-A)/(Q-A);else return 0}function IC(A,Q,B){return(1-B)*A+B*Q}function mY(A,Q,B,E){return IC(A,Q,1-Math.exp(-B*E))}function lY(A,Q=1){return Q-Math.abs(OJ(A,Q*2)-Q)}function cY(A,Q,B){if(A<=Q)return 0;if(A>=B)return 1;return A=(A-Q)/(B-Q),A*A*(3-2*A)}function dY(A,Q,B){if(A<=Q)return 0;if(A>=B)return 1;return A=(A-Q)/(B-Q),A*A*A*(A*(A*6-15)+10)}function nY(A,Q){return A+Math.floor(Math.random()*(Q-A+1))}function sY(A,Q){return A+Math.random()*(Q-A)}function iY(A){return A*(0.5-Math.random())}function oY(A){if(A!==void 0)u6=A;let Q=u6+=1831565813;return Q=Math.imul(Q^Q>>>15,Q|1),Q^=Q+Math.imul(Q^Q>>>7,Q|61),((Q^Q>>>14)>>>0)/4294967296}function aY(A){return A*EC}function rY(A){return A*kI}function tY(A){return(A&A-1)===0&&A!==0}function eY(A){return Math.pow(2,Math.ceil(Math.log(A)/Math.LN2))}function Aq(A){return Math.pow(2,Math.floor(Math.log(A)/Math.LN2))}function Qq(A,Q,B,E,I){let{cos:C,sin:G}=Math,K=C(B/2),J=G(B/2),U=C((Q+E)/2),F=G((Q+E)/2),R=C((Q-E)/2),D=G((Q-E)/2),H=C((E-Q)/2),M=G((E-Q)/2);switch(I){case"XYX":A.set(K*F,J*R,J*D,K*U);break;case"YZY":A.set(J*D,K*F,J*R,K*U);break;case"ZXZ":A.set(J*R,J*D,K*F,K*U);break;case"XZX":A.set(K*F,J*M,J*H,K*U);break;case"YXY":A.set(J*H,K*F,J*M,K*U);break;case"ZYZ":A.set(J*M,J*H,K*F,K*U);break;default:mA("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+I)}}function tB(A,Q){switch(Q.constructor){case Float32Array:return A;case Uint32Array:return A/4294967295;case Uint16Array:return A/65535;case Uint8Array:return A/255;case Int32Array:return Math.max(A/2147483647,-1);case Int16Array:return Math.max(A/32767,-1);case Int8Array:return Math.max(A/127,-1);default:throw Error("Invalid component type.")}}function TQ(A,Q){switch(Q.constructor){case Float32Array:return A;case Uint32Array:return Math.round(A*4294967295);case Uint16Array:return Math.round(A*65535);case Uint8Array:return Math.round(A*255);case Int32Array:return Math.round(A*2147483647);case Int16Array:return Math.round(A*32767);case Int8Array:return Math.round(A*127);default:throw Error("Invalid component type.")}}var mQ={DEG2RAD:EC,RAD2DEG:kI,generateUUID:eB,clamp:ZQ,euclideanModulo:OJ,mapLinear:pY,inverseLerp:uY,lerp:IC,damp:mY,pingpong:lY,smoothstep:cY,smootherstep:dY,randInt:nY,randFloat:sY,randFloatSpread:iY,seededRandom:oY,degToRad:aY,radToDeg:rY,isPowerOfTwo:tY,ceilPowerOfTwo:eY,floorPowerOfTwo:Aq,setQuaternionFromProperEuler:Qq,normalize:TQ,denormalize:tB};class LA{static{LA.prototype.isVector2=!0}constructor(A=0,Q=0){this.x=A,this.y=Q}get width(){return this.x}set width(A){this.x=A}get height(){return this.y}set height(A){this.y=A}set(A,Q){return this.x=A,this.y=Q,this}setScalar(A){return this.x=A,this.y=A,this}setX(A){return this.x=A,this}setY(A){return this.y=A,this}setComponent(A,Q){switch(A){case 0:this.x=Q;break;case 1:this.y=Q;break;default:throw Error("index is out of range: "+A)}return this}getComponent(A){switch(A){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+A)}}clone(){return new this.constructor(this.x,this.y)}copy(A){return this.x=A.x,this.y=A.y,this}add(A){return this.x+=A.x,this.y+=A.y,this}addScalar(A){return this.x+=A,this.y+=A,this}addVectors(A,Q){return this.x=A.x+Q.x,this.y=A.y+Q.y,this}addScaledVector(A,Q){return this.x+=A.x*Q,this.y+=A.y*Q,this}sub(A){return this.x-=A.x,this.y-=A.y,this}subScalar(A){return this.x-=A,this.y-=A,this}subVectors(A,Q){return this.x=A.x-Q.x,this.y=A.y-Q.y,this}multiply(A){return this.x*=A.x,this.y*=A.y,this}multiplyScalar(A){return this.x*=A,this.y*=A,this}divide(A){return this.x/=A.x,this.y/=A.y,this}divideScalar(A){return this.multiplyScalar(1/A)}applyMatrix3(A){let Q=this.x,B=this.y,E=A.elements;return this.x=E[0]*Q+E[3]*B+E[6],this.y=E[1]*Q+E[4]*B+E[7],this}min(A){return this.x=Math.min(this.x,A.x),this.y=Math.min(this.y,A.y),this}max(A){return this.x=Math.max(this.x,A.x),this.y=Math.max(this.y,A.y),this}clamp(A,Q){return this.x=ZQ(this.x,A.x,Q.x),this.y=ZQ(this.y,A.y,Q.y),this}clampScalar(A,Q){return this.x=ZQ(this.x,A,Q),this.y=ZQ(this.y,A,Q),this}clampLength(A,Q){let B=this.length();return this.divideScalar(B||1).multiplyScalar(ZQ(B,A,Q))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(A){return this.x*A.x+this.y*A.y}cross(A){return this.x*A.y-this.y*A.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(A){let Q=Math.sqrt(this.lengthSq()*A.lengthSq());if(Q===0)return Math.PI/2;let B=this.dot(A)/Q;return Math.acos(ZQ(B,-1,1))}distanceTo(A){return Math.sqrt(this.distanceToSquared(A))}distanceToSquared(A){let Q=this.x-A.x,B=this.y-A.y;return Q*Q+B*B}manhattanDistanceTo(A){return Math.abs(this.x-A.x)+Math.abs(this.y-A.y)}setLength(A){return this.normalize().multiplyScalar(A)}lerp(A,Q){return this.x+=(A.x-this.x)*Q,this.y+=(A.y-this.y)*Q,this}lerpVectors(A,Q,B){return this.x=A.x+(Q.x-A.x)*B,this.y=A.y+(Q.y-A.y)*B,this}equals(A){return A.x===this.x&&A.y===this.y}fromArray(A,Q=0){return this.x=A[Q],this.y=A[Q+1],this}toArray(A=[],Q=0){return A[Q]=this.x,A[Q+1]=this.y,A}fromBufferAttribute(A,Q){return this.x=A.getX(Q),this.y=A.getY(Q),this}rotateAround(A,Q){let B=Math.cos(Q),E=Math.sin(Q),I=this.x-A.x,C=this.y-A.y;return this.x=I*B-C*E+A.x,this.y=I*E+C*B+A.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ZB{constructor(A=0,Q=0,B=0,E=1){this.isQuaternion=!0,this._x=A,this._y=Q,this._z=B,this._w=E}static slerpFlat(A,Q,B,E,I,C,G){let K=B[E+0],J=B[E+1],U=B[E+2],F=B[E+3],R=I[C+0],D=I[C+1],H=I[C+2],M=I[C+3];if(F!==M||K!==R||J!==D||U!==H){let X=K*R+J*D+U*H+F*M;if(X<0)R=-R,D=-D,H=-H,M=-M,X=-X;let Y=1-G;if(X<0.9995){let q=Math.acos(X),N=Math.sin(q);Y=Math.sin(Y*q)/N,G=Math.sin(G*q)/N,K=K*Y+R*G,J=J*Y+D*G,U=U*Y+H*G,F=F*Y+M*G}else{K=K*Y+R*G,J=J*Y+D*G,U=U*Y+H*G,F=F*Y+M*G;let q=1/Math.sqrt(K*K+J*J+U*U+F*F);K*=q,J*=q,U*=q,F*=q}}A[Q]=K,A[Q+1]=J,A[Q+2]=U,A[Q+3]=F}static multiplyQuaternionsFlat(A,Q,B,E,I,C){let G=B[E],K=B[E+1],J=B[E+2],U=B[E+3],F=I[C],R=I[C+1],D=I[C+2],H=I[C+3];return A[Q]=G*H+U*F+K*D-J*R,A[Q+1]=K*H+U*R+J*F-G*D,A[Q+2]=J*H+U*D+G*R-K*F,A[Q+3]=U*H-G*F-K*R-J*D,A}get x(){return this._x}set x(A){this._x=A,this._onChangeCallback()}get y(){return this._y}set y(A){this._y=A,this._onChangeCallback()}get z(){return this._z}set z(A){this._z=A,this._onChangeCallback()}get w(){return this._w}set w(A){this._w=A,this._onChangeCallback()}set(A,Q,B,E){return this._x=A,this._y=Q,this._z=B,this._w=E,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(A){return this._x=A.x,this._y=A.y,this._z=A.z,this._w=A.w,this._onChangeCallback(),this}setFromEuler(A,Q=!0){let{_x:B,_y:E,_z:I,_order:C}=A,G=Math.cos,K=Math.sin,J=G(B/2),U=G(E/2),F=G(I/2),R=K(B/2),D=K(E/2),H=K(I/2);switch(C){case"XYZ":this._x=R*U*F+J*D*H,this._y=J*D*F-R*U*H,this._z=J*U*H+R*D*F,this._w=J*U*F-R*D*H;break;case"YXZ":this._x=R*U*F+J*D*H,this._y=J*D*F-R*U*H,this._z=J*U*H-R*D*F,this._w=J*U*F+R*D*H;break;case"ZXY":this._x=R*U*F-J*D*H,this._y=J*D*F+R*U*H,this._z=J*U*H+R*D*F,this._w=J*U*F-R*D*H;break;case"ZYX":this._x=R*U*F-J*D*H,this._y=J*D*F+R*U*H,this._z=J*U*H-R*D*F,this._w=J*U*F+R*D*H;break;case"YZX":this._x=R*U*F+J*D*H,this._y=J*D*F+R*U*H,this._z=J*U*H-R*D*F,this._w=J*U*F-R*D*H;break;case"XZY":this._x=R*U*F-J*D*H,this._y=J*D*F-R*U*H,this._z=J*U*H+R*D*F,this._w=J*U*F+R*D*H;break;default:mA("Quaternion: .setFromEuler() encountered an unknown order: "+C)}if(Q===!0)this._onChangeCallback();return this}setFromAxisAngle(A,Q){let B=Q/2,E=Math.sin(B);return this._x=A.x*E,this._y=A.y*E,this._z=A.z*E,this._w=Math.cos(B),this._onChangeCallback(),this}setFromRotationMatrix(A){let Q=A.elements,B=Q[0],E=Q[4],I=Q[8],C=Q[1],G=Q[5],K=Q[9],J=Q[2],U=Q[6],F=Q[10],R=B+G+F;if(R>0){let D=0.5/Math.sqrt(R+1);this._w=0.25/D,this._x=(U-K)*D,this._y=(I-J)*D,this._z=(C-E)*D}else if(B>G&&B>F){let D=2*Math.sqrt(1+B-G-F);this._w=(U-K)/D,this._x=0.25*D,this._y=(E+C)/D,this._z=(I+J)/D}else if(G>F){let D=2*Math.sqrt(1+G-B-F);this._w=(I-J)/D,this._x=(E+C)/D,this._y=0.25*D,this._z=(K+U)/D}else{let D=2*Math.sqrt(1+F-B-G);this._w=(C-E)/D,this._x=(I+J)/D,this._y=(K+U)/D,this._z=0.25*D}return this._onChangeCallback(),this}setFromUnitVectors(A,Q){let B=A.dot(Q)+1;if(B<0.00000001)if(B=0,Math.abs(A.x)>Math.abs(A.z))this._x=-A.y,this._y=A.x,this._z=0,this._w=B;else this._x=0,this._y=-A.z,this._z=A.y,this._w=B;else this._x=A.y*Q.z-A.z*Q.y,this._y=A.z*Q.x-A.x*Q.z,this._z=A.x*Q.y-A.y*Q.x,this._w=B;return this.normalize()}angleTo(A){return 2*Math.acos(Math.abs(ZQ(this.dot(A),-1,1)))}rotateTowards(A,Q){let B=this.angleTo(A);if(B===0)return this;let E=Math.min(1,Q/B);return this.slerp(A,E),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(A){return this._x*A._x+this._y*A._y+this._z*A._z+this._w*A._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 A=this.length();if(A===0)this._x=0,this._y=0,this._z=0,this._w=1;else A=1/A,this._x=this._x*A,this._y=this._y*A,this._z=this._z*A,this._w=this._w*A;return this._onChangeCallback(),this}multiply(A){return this.multiplyQuaternions(this,A)}premultiply(A){return this.multiplyQuaternions(A,this)}multiplyQuaternions(A,Q){let{_x:B,_y:E,_z:I,_w:C}=A,G=Q._x,K=Q._y,J=Q._z,U=Q._w;return this._x=B*U+C*G+E*J-I*K,this._y=E*U+C*K+I*G-B*J,this._z=I*U+C*J+B*K-E*G,this._w=C*U-B*G-E*K-I*J,this._onChangeCallback(),this}slerp(A,Q){let{_x:B,_y:E,_z:I,_w:C}=A,G=this.dot(A);if(G<0)B=-B,E=-E,I=-I,C=-C,G=-G;let K=1-Q;if(G<0.9995){let J=Math.acos(G),U=Math.sin(J);K=Math.sin(K*J)/U,Q=Math.sin(Q*J)/U,this._x=this._x*K+B*Q,this._y=this._y*K+E*Q,this._z=this._z*K+I*Q,this._w=this._w*K+C*Q,this._onChangeCallback()}else this._x=this._x*K+B*Q,this._y=this._y*K+E*Q,this._z=this._z*K+I*Q,this._w=this._w*K+C*Q,this.normalize();return this}slerpQuaternions(A,Q,B){return this.copy(A).slerp(Q,B)}random(){let A=2*Math.PI*Math.random(),Q=2*Math.PI*Math.random(),B=Math.random(),E=Math.sqrt(1-B),I=Math.sqrt(B);return this.set(E*Math.sin(A),E*Math.cos(A),I*Math.sin(Q),I*Math.cos(Q))}equals(A){return A._x===this._x&&A._y===this._y&&A._z===this._z&&A._w===this._w}fromArray(A,Q=0){return this._x=A[Q],this._y=A[Q+1],this._z=A[Q+2],this._w=A[Q+3],this._onChangeCallback(),this}toArray(A=[],Q=0){return A[Q]=this._x,A[Q+1]=this._y,A[Q+2]=this._z,A[Q+3]=this._w,A}fromBufferAttribute(A,Q){return this._x=A.getX(Q),this._y=A.getY(Q),this._z=A.getZ(Q),this._w=A.getW(Q),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(A){return this._onChangeCallback=A,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class d{static{d.prototype.isVector3=!0}constructor(A=0,Q=0,B=0){this.x=A,this.y=Q,this.z=B}set(A,Q,B){if(B===void 0)B=this.z;return this.x=A,this.y=Q,this.z=B,this}setScalar(A){return this.x=A,this.y=A,this.z=A,this}setX(A){return this.x=A,this}setY(A){return this.y=A,this}setZ(A){return this.z=A,this}setComponent(A,Q){switch(A){case 0:this.x=Q;break;case 1:this.y=Q;break;case 2:this.z=Q;break;default:throw Error("index is out of range: "+A)}return this}getComponent(A){switch(A){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+A)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(A){return this.x=A.x,this.y=A.y,this.z=A.z,this}add(A){return this.x+=A.x,this.y+=A.y,this.z+=A.z,this}addScalar(A){return this.x+=A,this.y+=A,this.z+=A,this}addVectors(A,Q){return this.x=A.x+Q.x,this.y=A.y+Q.y,this.z=A.z+Q.z,this}addScaledVector(A,Q){return this.x+=A.x*Q,this.y+=A.y*Q,this.z+=A.z*Q,this}sub(A){return this.x-=A.x,this.y-=A.y,this.z-=A.z,this}subScalar(A){return this.x-=A,this.y-=A,this.z-=A,this}subVectors(A,Q){return this.x=A.x-Q.x,this.y=A.y-Q.y,this.z=A.z-Q.z,this}multiply(A){return this.x*=A.x,this.y*=A.y,this.z*=A.z,this}multiplyScalar(A){return this.x*=A,this.y*=A,this.z*=A,this}multiplyVectors(A,Q){return this.x=A.x*Q.x,this.y=A.y*Q.y,this.z=A.z*Q.z,this}applyEuler(A){return this.applyQuaternion(m6.setFromEuler(A))}applyAxisAngle(A,Q){return this.applyQuaternion(m6.setFromAxisAngle(A,Q))}applyMatrix3(A){let Q=this.x,B=this.y,E=this.z,I=A.elements;return this.x=I[0]*Q+I[3]*B+I[6]*E,this.y=I[1]*Q+I[4]*B+I[7]*E,this.z=I[2]*Q+I[5]*B+I[8]*E,this}applyNormalMatrix(A){return this.applyMatrix3(A).normalize()}applyMatrix4(A){let Q=this.x,B=this.y,E=this.z,I=A.elements,C=1/(I[3]*Q+I[7]*B+I[11]*E+I[15]);return this.x=(I[0]*Q+I[4]*B+I[8]*E+I[12])*C,this.y=(I[1]*Q+I[5]*B+I[9]*E+I[13])*C,this.z=(I[2]*Q+I[6]*B+I[10]*E+I[14])*C,this}applyQuaternion(A){let Q=this.x,B=this.y,E=this.z,I=A.x,C=A.y,G=A.z,K=A.w,J=2*(C*E-G*B),U=2*(G*Q-I*E),F=2*(I*B-C*Q);return this.x=Q+K*J+C*F-G*U,this.y=B+K*U+G*J-I*F,this.z=E+K*F+I*U-C*J,this}project(A){return this.applyMatrix4(A.matrixWorldInverse).applyMatrix4(A.projectionMatrix)}unproject(A){return this.applyMatrix4(A.projectionMatrixInverse).applyMatrix4(A.matrixWorld)}transformDirection(A){let Q=this.x,B=this.y,E=this.z,I=A.elements;return this.x=I[0]*Q+I[4]*B+I[8]*E,this.y=I[1]*Q+I[5]*B+I[9]*E,this.z=I[2]*Q+I[6]*B+I[10]*E,this.normalize()}divide(A){return this.x/=A.x,this.y/=A.y,this.z/=A.z,this}divideScalar(A){return this.multiplyScalar(1/A)}min(A){return this.x=Math.min(this.x,A.x),this.y=Math.min(this.y,A.y),this.z=Math.min(this.z,A.z),this}max(A){return this.x=Math.max(this.x,A.x),this.y=Math.max(this.y,A.y),this.z=Math.max(this.z,A.z),this}clamp(A,Q){return this.x=ZQ(this.x,A.x,Q.x),this.y=ZQ(this.y,A.y,Q.y),this.z=ZQ(this.z,A.z,Q.z),this}clampScalar(A,Q){return this.x=ZQ(this.x,A,Q),this.y=ZQ(this.y,A,Q),this.z=ZQ(this.z,A,Q),this}clampLength(A,Q){let B=this.length();return this.divideScalar(B||1).multiplyScalar(ZQ(B,A,Q))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(A){return this.x*A.x+this.y*A.y+this.z*A.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(A){return this.normalize().multiplyScalar(A)}lerp(A,Q){return this.x+=(A.x-this.x)*Q,this.y+=(A.y-this.y)*Q,this.z+=(A.z-this.z)*Q,this}lerpVectors(A,Q,B){return this.x=A.x+(Q.x-A.x)*B,this.y=A.y+(Q.y-A.y)*B,this.z=A.z+(Q.z-A.z)*B,this}cross(A){return this.crossVectors(this,A)}crossVectors(A,Q){let{x:B,y:E,z:I}=A,C=Q.x,G=Q.y,K=Q.z;return this.x=E*K-I*G,this.y=I*C-B*K,this.z=B*G-E*C,this}projectOnVector(A){let Q=A.lengthSq();if(Q===0)return this.set(0,0,0);let B=A.dot(this)/Q;return this.copy(A).multiplyScalar(B)}projectOnPlane(A){return DK.copy(this).projectOnVector(A),this.sub(DK)}reflect(A){return this.sub(DK.copy(A).multiplyScalar(2*this.dot(A)))}angleTo(A){let Q=Math.sqrt(this.lengthSq()*A.lengthSq());if(Q===0)return Math.PI/2;let B=this.dot(A)/Q;return Math.acos(ZQ(B,-1,1))}distanceTo(A){return Math.sqrt(this.distanceToSquared(A))}distanceToSquared(A){let Q=this.x-A.x,B=this.y-A.y,E=this.z-A.z;return Q*Q+B*B+E*E}manhattanDistanceTo(A){return Math.abs(this.x-A.x)+Math.abs(this.y-A.y)+Math.abs(this.z-A.z)}setFromSpherical(A){return this.setFromSphericalCoords(A.radius,A.phi,A.theta)}setFromSphericalCoords(A,Q,B){let E=Math.sin(Q)*A;return this.x=E*Math.sin(B),this.y=Math.cos(Q)*A,this.z=E*Math.cos(B),this}setFromCylindrical(A){return this.setFromCylindricalCoords(A.radius,A.theta,A.y)}setFromCylindricalCoords(A,Q,B){return this.x=A*Math.sin(Q),this.y=B,this.z=A*Math.cos(Q),this}setFromMatrixPosition(A){let Q=A.elements;return this.x=Q[12],this.y=Q[13],this.z=Q[14],this}setFromMatrixScale(A){let Q=this.setFromMatrixColumn(A,0).length(),B=this.setFromMatrixColumn(A,1).length(),E=this.setFromMatrixColumn(A,2).length();return this.x=Q,this.y=B,this.z=E,this}setFromMatrixColumn(A,Q){return this.fromArray(A.elements,Q*4)}setFromMatrix3Column(A,Q){return this.fromArray(A.elements,Q*3)}setFromEuler(A){return this.x=A._x,this.y=A._y,this.z=A._z,this}setFromColor(A){return this.x=A.r,this.y=A.g,this.z=A.b,this}equals(A){return A.x===this.x&&A.y===this.y&&A.z===this.z}fromArray(A,Q=0){return this.x=A[Q],this.y=A[Q+1],this.z=A[Q+2],this}toArray(A=[],Q=0){return A[Q]=this.x,A[Q+1]=this.y,A[Q+2]=this.z,A}fromBufferAttribute(A,Q){return this.x=A.getX(Q),this.y=A.getY(Q),this.z=A.getZ(Q),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let A=Math.random()*Math.PI*2,Q=Math.random()*2-1,B=Math.sqrt(1-Q*Q);return this.x=B*Math.cos(A),this.y=Q,this.z=B*Math.sin(A),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}var DK=new d,m6=new ZB;class KQ{static{KQ.prototype.isMatrix3=!0}constructor(A,Q,B,E,I,C,G,K,J){if(this.elements=[1,0,0,0,1,0,0,0,1],A!==void 0)this.set(A,Q,B,E,I,C,G,K,J)}set(A,Q,B,E,I,C,G,K,J){let U=this.elements;return U[0]=A,U[1]=E,U[2]=G,U[3]=Q,U[4]=I,U[5]=K,U[6]=B,U[7]=C,U[8]=J,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(A){let Q=this.elements,B=A.elements;return Q[0]=B[0],Q[1]=B[1],Q[2]=B[2],Q[3]=B[3],Q[4]=B[4],Q[5]=B[5],Q[6]=B[6],Q[7]=B[7],Q[8]=B[8],this}extractBasis(A,Q,B){return A.setFromMatrix3Column(this,0),Q.setFromMatrix3Column(this,1),B.setFromMatrix3Column(this,2),this}setFromMatrix4(A){let Q=A.elements;return this.set(Q[0],Q[4],Q[8],Q[1],Q[5],Q[9],Q[2],Q[6],Q[10]),this}multiply(A){return this.multiplyMatrices(this,A)}premultiply(A){return this.multiplyMatrices(A,this)}multiplyMatrices(A,Q){let B=A.elements,E=Q.elements,I=this.elements,C=B[0],G=B[3],K=B[6],J=B[1],U=B[4],F=B[7],R=B[2],D=B[5],H=B[8],M=E[0],X=E[3],Y=E[6],q=E[1],N=E[4],$=E[7],L=E[2],k=E[5],O=E[8];return I[0]=C*M+G*q+K*L,I[3]=C*X+G*N+K*k,I[6]=C*Y+G*$+K*O,I[1]=J*M+U*q+F*L,I[4]=J*X+U*N+F*k,I[7]=J*Y+U*$+F*O,I[2]=R*M+D*q+H*L,I[5]=R*X+D*N+H*k,I[8]=R*Y+D*$+H*O,this}multiplyScalar(A){let Q=this.elements;return Q[0]*=A,Q[3]*=A,Q[6]*=A,Q[1]*=A,Q[4]*=A,Q[7]*=A,Q[2]*=A,Q[5]*=A,Q[8]*=A,this}determinant(){let A=this.elements,Q=A[0],B=A[1],E=A[2],I=A[3],C=A[4],G=A[5],K=A[6],J=A[7],U=A[8];return Q*C*U-Q*G*J-B*I*U+B*G*K+E*I*J-E*C*K}invert(){let A=this.elements,Q=A[0],B=A[1],E=A[2],I=A[3],C=A[4],G=A[5],K=A[6],J=A[7],U=A[8],F=U*C-G*J,R=G*K-U*I,D=J*I-C*K,H=Q*F+B*R+E*D;if(H===0)return this.set(0,0,0,0,0,0,0,0,0);let M=1/H;return A[0]=F*M,A[1]=(E*J-U*B)*M,A[2]=(G*B-E*C)*M,A[3]=R*M,A[4]=(U*Q-E*K)*M,A[5]=(E*I-G*Q)*M,A[6]=D*M,A[7]=(B*K-J*Q)*M,A[8]=(C*Q-B*I)*M,this}transpose(){let A,Q=this.elements;return A=Q[1],Q[1]=Q[3],Q[3]=A,A=Q[2],Q[2]=Q[6],Q[6]=A,A=Q[5],Q[5]=Q[7],Q[7]=A,this}getNormalMatrix(A){return this.setFromMatrix4(A).invert().transpose()}transposeIntoArray(A){let Q=this.elements;return A[0]=Q[0],A[1]=Q[3],A[2]=Q[6],A[3]=Q[1],A[4]=Q[4],A[5]=Q[7],A[6]=Q[2],A[7]=Q[5],A[8]=Q[8],this}setUvTransform(A,Q,B,E,I,C,G){let K=Math.cos(I),J=Math.sin(I);return this.set(B*K,B*J,-B*(K*C+J*G)+C+A,-E*J,E*K,-E*(-J*C+K*G)+G+Q,0,0,1),this}scale(A,Q){return this.premultiply(HK.makeScale(A,Q)),this}rotate(A){return this.premultiply(HK.makeRotation(-A)),this}translate(A,Q){return this.premultiply(HK.makeTranslation(A,Q)),this}makeTranslation(A,Q){if(A.isVector2)this.set(1,0,A.x,0,1,A.y,0,0,1);else this.set(1,0,A,0,1,Q,0,0,1);return this}makeRotation(A){let Q=Math.cos(A),B=Math.sin(A);return this.set(Q,-B,0,B,Q,0,0,0,1),this}makeScale(A,Q){return this.set(A,0,0,0,Q,0,0,0,1),this}equals(A){let Q=this.elements,B=A.elements;for(let E=0;E<9;E++)if(Q[E]!==B[E])return!1;return!0}fromArray(A,Q=0){for(let B=0;B<9;B++)this.elements[B]=A[B+Q];return this}toArray(A=[],Q=0){let B=this.elements;return A[Q]=B[0],A[Q+1]=B[1],A[Q+2]=B[2],A[Q+3]=B[3],A[Q+4]=B[4],A[Q+5]=B[5],A[Q+6]=B[6],A[Q+7]=B[7],A[Q+8]=B[8],A}clone(){return new this.constructor().fromArray(this.elements)}}var HK=new KQ,l6=new KQ().set(0.4123908,0.3575843,0.1804808,0.212639,0.7151687,0.0721923,0.0193308,0.1191948,0.9505322),c6=new KQ().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,0.0415551,0.0556301,-0.203977,1.0569715);function Bq(){let A={enabled:!0,workingColorSpace:"srgb-linear",spaces:{},convert:function(I,C,G){if(this.enabled===!1||C===G||!C||!G)return I;if(this.spaces[C].transfer==="srgb")I.r=PE(I.r),I.g=PE(I.g),I.b=PE(I.b);if(this.spaces[C].primaries!==this.spaces[G].primaries)I.applyMatrix3(this.spaces[C].toXYZ),I.applyMatrix3(this.spaces[G].fromXYZ);if(this.spaces[G].transfer==="srgb")I.r=H0(I.r),I.g=H0(I.g),I.b=H0(I.b);return I},workingToColorSpace:function(I,C){return this.convert(I,this.workingColorSpace,C)},colorSpaceToWorking:function(I,C){return this.convert(I,C,this.workingColorSpace)},getPrimaries:function(I){return this.spaces[I].primaries},getTransfer:function(I){if(I==="")return"linear";return this.spaces[I].transfer},getToneMappingMode:function(I){return this.spaces[I].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(I,C=this.workingColorSpace){return I.fromArray(this.spaces[C].luminanceCoefficients)},define:function(I){Object.assign(this.spaces,I)},_getMatrix:function(I,C,G){return I.copy(this.spaces[C].toXYZ).multiply(this.spaces[G].fromXYZ)},_getDrawingBufferColorSpace:function(I){return this.spaces[I].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(I=this.workingColorSpace){return this.spaces[I].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(I,C){return y8("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),A.workingToColorSpace(I,C)},toWorkingColorSpace:function(I,C){return y8("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),A.colorSpaceToWorking(I,C)}},Q=[0.64,0.33,0.3,0.6,0.15,0.06],B=[0.2126,0.7152,0.0722],E=[0.3127,0.329];return A.define({["srgb-linear"]:{primaries:Q,whitePoint:E,transfer:"linear",toXYZ:l6,fromXYZ:c6,luminanceCoefficients:B,workingColorSpaceConfig:{unpackColorSpace:"srgb"},outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}},["srgb"]:{primaries:Q,whitePoint:E,transfer:"srgb",toXYZ:l6,fromXYZ:c6,luminanceCoefficients:B,outputColorSpaceConfig:{drawingBufferColorSpace:"srgb"}}}),A}var qQ=Bq();function PE(A){return A<0.04045?A*0.0773993808:Math.pow(A*0.9478672986+0.0521327014,2.4)}function H0(A){return A<0.0031308?A*12.92:1.055*Math.pow(A,0.41666)-0.055}var eI;class VJ{static getDataURL(A,Q="image/png"){if(/^data:/i.test(A.src))return A.src;if(typeof HTMLCanvasElement>"u")return A.src;let B;if(A instanceof HTMLCanvasElement)B=A;else{if(eI===void 0)eI=Y0("canvas");eI.width=A.width,eI.height=A.height;let E=eI.getContext("2d");if(A instanceof ImageData)E.putImageData(A,0,0);else E.drawImage(A,0,0,A.width,A.height);B=eI}return B.toDataURL(Q)}static sRGBToLinear(A){if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&A instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&A instanceof ImageBitmap){let Q=Y0("canvas");Q.width=A.width,Q.height=A.height;let B=Q.getContext("2d");B.drawImage(A,0,0,A.width,A.height);let E=B.getImageData(0,0,A.width,A.height),I=E.data;for(let C=0;C1?!0:!1,this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(qK).x}get height(){return this.source.getSize(qK).y}get depth(){return this.source.getSize(qK).z}get image(){return this.source.data}set image(A){this.source.data=A}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(A,Q){this.updateRanges.push({start:A,count:Q})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(A){return this.name=A.name,this.source=A.source,this.mipmaps=A.mipmaps.slice(0),this.mapping=A.mapping,this.channel=A.channel,this.wrapS=A.wrapS,this.wrapT=A.wrapT,this.magFilter=A.magFilter,this.minFilter=A.minFilter,this.anisotropy=A.anisotropy,this.format=A.format,this.internalFormat=A.internalFormat,this.type=A.type,this.normalized=A.normalized,this.offset.copy(A.offset),this.repeat.copy(A.repeat),this.center.copy(A.center),this.rotation=A.rotation,this.matrixAutoUpdate=A.matrixAutoUpdate,this.matrix.copy(A.matrix),this.generateMipmaps=A.generateMipmaps,this.premultiplyAlpha=A.premultiplyAlpha,this.flipY=A.flipY,this.unpackAlignment=A.unpackAlignment,this.colorSpace=A.colorSpace,this.renderTarget=A.renderTarget,this.isRenderTargetTexture=A.isRenderTargetTexture,this.isArrayTexture=A.isArrayTexture,this.userData=JSON.parse(JSON.stringify(A.userData)),this.needsUpdate=!0,this}setValues(A){for(let Q in A){let B=A[Q];if(B===void 0){mA(`Texture.setValues(): parameter '${Q}' has value of undefined.`);continue}let E=this[Q];if(E===void 0){mA(`Texture.setValues(): property '${Q}' does not exist.`);continue}if(E&&B&&(E.isVector2&&B.isVector2))E.copy(B);else if(E&&B&&(E.isVector3&&B.isVector3))E.copy(B);else if(E&&B&&(E.isMatrix3&&B.isMatrix3))E.copy(B);else this[Q]=B}}toJSON(A){let Q=A===void 0||typeof A==="string";if(!Q&&A.textures[this.uuid]!==void 0)return A.textures[this.uuid];let B={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(A).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};if(Object.keys(this.userData).length>0)B.userData=this.userData;if(!Q)A.textures[this.uuid]=B;return B}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(A){if(this.mapping!==300)return A;if(A.applyMatrix3(this.matrix),A.x<0||A.x>1)switch(this.wrapS){case 1000:A.x=A.x-Math.floor(A.x);break;case 1001:A.x=A.x<0?0:1;break;case 1002:if(Math.abs(Math.floor(A.x)%2)===1)A.x=Math.ceil(A.x)-A.x;else A.x=A.x-Math.floor(A.x);break}if(A.y<0||A.y>1)switch(this.wrapT){case 1000:A.y=A.y-Math.floor(A.y);break;case 1001:A.y=A.y<0?0:1;break;case 1002:if(Math.abs(Math.floor(A.y)%2)===1)A.y=Math.ceil(A.y)-A.y;else A.y=A.y-Math.floor(A.y);break}if(this.flipY)A.y=1-A.y;return A}set needsUpdate(A){if(A===!0)this.version++,this.source.needsUpdate=!0}set needsPMREMUpdate(A){if(A===!0)this.pmremVersion++}}cQ.DEFAULT_IMAGE=null;cQ.DEFAULT_MAPPING=300;cQ.DEFAULT_ANISOTROPY=1;class SQ{static{SQ.prototype.isVector4=!0}constructor(A=0,Q=0,B=0,E=1){this.x=A,this.y=Q,this.z=B,this.w=E}get width(){return this.z}set width(A){this.z=A}get height(){return this.w}set height(A){this.w=A}set(A,Q,B,E){return this.x=A,this.y=Q,this.z=B,this.w=E,this}setScalar(A){return this.x=A,this.y=A,this.z=A,this.w=A,this}setX(A){return this.x=A,this}setY(A){return this.y=A,this}setZ(A){return this.z=A,this}setW(A){return this.w=A,this}setComponent(A,Q){switch(A){case 0:this.x=Q;break;case 1:this.y=Q;break;case 2:this.z=Q;break;case 3:this.w=Q;break;default:throw Error("index is out of range: "+A)}return this}getComponent(A){switch(A){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+A)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(A){return this.x=A.x,this.y=A.y,this.z=A.z,this.w=A.w!==void 0?A.w:1,this}add(A){return this.x+=A.x,this.y+=A.y,this.z+=A.z,this.w+=A.w,this}addScalar(A){return this.x+=A,this.y+=A,this.z+=A,this.w+=A,this}addVectors(A,Q){return this.x=A.x+Q.x,this.y=A.y+Q.y,this.z=A.z+Q.z,this.w=A.w+Q.w,this}addScaledVector(A,Q){return this.x+=A.x*Q,this.y+=A.y*Q,this.z+=A.z*Q,this.w+=A.w*Q,this}sub(A){return this.x-=A.x,this.y-=A.y,this.z-=A.z,this.w-=A.w,this}subScalar(A){return this.x-=A,this.y-=A,this.z-=A,this.w-=A,this}subVectors(A,Q){return this.x=A.x-Q.x,this.y=A.y-Q.y,this.z=A.z-Q.z,this.w=A.w-Q.w,this}multiply(A){return this.x*=A.x,this.y*=A.y,this.z*=A.z,this.w*=A.w,this}multiplyScalar(A){return this.x*=A,this.y*=A,this.z*=A,this.w*=A,this}applyMatrix4(A){let Q=this.x,B=this.y,E=this.z,I=this.w,C=A.elements;return this.x=C[0]*Q+C[4]*B+C[8]*E+C[12]*I,this.y=C[1]*Q+C[5]*B+C[9]*E+C[13]*I,this.z=C[2]*Q+C[6]*B+C[10]*E+C[14]*I,this.w=C[3]*Q+C[7]*B+C[11]*E+C[15]*I,this}divide(A){return this.x/=A.x,this.y/=A.y,this.z/=A.z,this.w/=A.w,this}divideScalar(A){return this.multiplyScalar(1/A)}setAxisAngleFromQuaternion(A){this.w=2*Math.acos(A.w);let Q=Math.sqrt(1-A.w*A.w);if(Q<0.0001)this.x=1,this.y=0,this.z=0;else this.x=A.x/Q,this.y=A.y/Q,this.z=A.z/Q;return this}setAxisAngleFromRotationMatrix(A){let Q,B,E,I,C=0.01,G=0.1,K=A.elements,J=K[0],U=K[4],F=K[8],R=K[1],D=K[5],H=K[9],M=K[2],X=K[6],Y=K[10];if(Math.abs(U-R)<0.01&&Math.abs(F-M)<0.01&&Math.abs(H-X)<0.01){if(Math.abs(U+R)<0.1&&Math.abs(F+M)<0.1&&Math.abs(H+X)<0.1&&Math.abs(J+D+Y-3)<0.1)return this.set(1,0,0,0),this;Q=Math.PI;let N=(J+1)/2,$=(D+1)/2,L=(Y+1)/2,k=(U+R)/4,O=(F+M)/4,w=(H+X)/4;if(N>$&&N>L)if(N<0.01)B=0,E=0.707106781,I=0.707106781;else B=Math.sqrt(N),E=k/B,I=O/B;else if($>L)if($<0.01)B=0.707106781,E=0,I=0.707106781;else E=Math.sqrt($),B=k/E,I=w/E;else if(L<0.01)B=0.707106781,E=0.707106781,I=0;else I=Math.sqrt(L),B=O/I,E=w/I;return this.set(B,E,I,Q),this}let q=Math.sqrt((X-H)*(X-H)+(F-M)*(F-M)+(R-U)*(R-U));if(Math.abs(q)<0.001)q=1;return this.x=(X-H)/q,this.y=(F-M)/q,this.z=(R-U)/q,this.w=Math.acos((J+D+Y-1)/2),this}setFromMatrixPosition(A){let Q=A.elements;return this.x=Q[12],this.y=Q[13],this.z=Q[14],this.w=Q[15],this}min(A){return this.x=Math.min(this.x,A.x),this.y=Math.min(this.y,A.y),this.z=Math.min(this.z,A.z),this.w=Math.min(this.w,A.w),this}max(A){return this.x=Math.max(this.x,A.x),this.y=Math.max(this.y,A.y),this.z=Math.max(this.z,A.z),this.w=Math.max(this.w,A.w),this}clamp(A,Q){return this.x=ZQ(this.x,A.x,Q.x),this.y=ZQ(this.y,A.y,Q.y),this.z=ZQ(this.z,A.z,Q.z),this.w=ZQ(this.w,A.w,Q.w),this}clampScalar(A,Q){return this.x=ZQ(this.x,A,Q),this.y=ZQ(this.y,A,Q),this.z=ZQ(this.z,A,Q),this.w=ZQ(this.w,A,Q),this}clampLength(A,Q){let B=this.length();return this.divideScalar(B||1).multiplyScalar(ZQ(B,A,Q))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(A){return this.x*A.x+this.y*A.y+this.z*A.z+this.w*A.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(A){return this.normalize().multiplyScalar(A)}lerp(A,Q){return this.x+=(A.x-this.x)*Q,this.y+=(A.y-this.y)*Q,this.z+=(A.z-this.z)*Q,this.w+=(A.w-this.w)*Q,this}lerpVectors(A,Q,B){return this.x=A.x+(Q.x-A.x)*B,this.y=A.y+(Q.y-A.y)*B,this.z=A.z+(Q.z-A.z)*B,this.w=A.w+(Q.w-A.w)*B,this}equals(A){return A.x===this.x&&A.y===this.y&&A.z===this.z&&A.w===this.w}fromArray(A,Q=0){return this.x=A[Q],this.y=A[Q+1],this.z=A[Q+2],this.w=A[Q+3],this}toArray(A=[],Q=0){return A[Q]=this.x,A[Q+1]=this.y,A[Q+2]=this.z,A[Q+3]=this.w,A}fromBufferAttribute(A,Q){return this.x=A.getX(Q),this.y=A.getY(Q),this.z=A.getZ(Q),this.w=A.getW(Q),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class kJ extends RE{constructor(A=1,Q=1,B={}){super();B=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:1006,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},B),this.isRenderTarget=!0,this.width=A,this.height=Q,this.depth=B.depth,this.scissor=new SQ(0,0,A,Q),this.scissorTest=!1,this.viewport=new SQ(0,0,A,Q),this.textures=[];let E={width:A,height:Q,depth:B.depth},I=new cQ(E),C=B.count;for(let G=0;G1;this.dispose()}this.viewport.set(0,0,A,Q),this.scissor.set(0,0,A,Q)}clone(){return new this.constructor().copy(this)}copy(A){this.width=A.width,this.height=A.height,this.depth=A.depth,this.scissor.copy(A.scissor),this.scissorTest=A.scissorTest,this.viewport.copy(A.viewport),this.textures.length=0;for(let Q=0,B=A.textures.length;Q>>0}enable(A){this.mask|=1<1){for(let Q=0;Q1){for(let B=0;B0)E.userData=this.userData;if(E.layers=this.layers.mask,E.matrix=this.matrix.toArray(),E.up=this.up.toArray(),this.pivot!==null)E.pivot=this.pivot.toArray();if(this.matrixAutoUpdate===!1)E.matrixAutoUpdate=!1;if(this.morphTargetDictionary!==void 0)E.morphTargetDictionary=Object.assign({},this.morphTargetDictionary);if(this.morphTargetInfluences!==void 0)E.morphTargetInfluences=this.morphTargetInfluences.slice();if(this.isInstancedMesh){if(E.type="InstancedMesh",E.count=this.count,E.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null)E.instanceColor=this.instanceColor.toJSON()}if(this.isBatchedMesh){if(E.type="BatchedMesh",E.perObjectFrustumCulled=this.perObjectFrustumCulled,E.sortObjects=this.sortObjects,E.drawRanges=this._drawRanges,E.reservedRanges=this._reservedRanges,E.geometryInfo=this._geometryInfo.map((G)=>({...G,boundingBox:G.boundingBox?G.boundingBox.toJSON():void 0,boundingSphere:G.boundingSphere?G.boundingSphere.toJSON():void 0})),E.instanceInfo=this._instanceInfo.map((G)=>({...G})),E.availableInstanceIds=this._availableInstanceIds.slice(),E.availableGeometryIds=this._availableGeometryIds.slice(),E.nextIndexStart=this._nextIndexStart,E.nextVertexStart=this._nextVertexStart,E.geometryCount=this._geometryCount,E.maxInstanceCount=this._maxInstanceCount,E.maxVertexCount=this._maxVertexCount,E.maxIndexCount=this._maxIndexCount,E.geometryInitialized=this._geometryInitialized,E.matricesTexture=this._matricesTexture.toJSON(A),E.indirectTexture=this._indirectTexture.toJSON(A),this._colorsTexture!==null)E.colorsTexture=this._colorsTexture.toJSON(A);if(this.boundingSphere!==null)E.boundingSphere=this.boundingSphere.toJSON();if(this.boundingBox!==null)E.boundingBox=this.boundingBox.toJSON()}function I(G,K){if(G[K.uuid]===void 0)G[K.uuid]=K.toJSON(A);return K.uuid}if(this.isScene){if(this.background){if(this.background.isColor)E.background=this.background.toJSON();else if(this.background.isTexture)E.background=this.background.toJSON(A).uuid}if(this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0)E.environment=this.environment.toJSON(A).uuid}else if(this.isMesh||this.isLine||this.isPoints){E.geometry=I(A.geometries,this.geometry);let G=this.geometry.parameters;if(G!==void 0&&G.shapes!==void 0){let K=G.shapes;if(Array.isArray(K))for(let J=0,U=K.length;J0){E.children=[];for(let G=0;G0){E.animations=[];for(let G=0;G0)B.geometries=G;if(K.length>0)B.materials=K;if(J.length>0)B.textures=J;if(U.length>0)B.images=U;if(F.length>0)B.shapes=F;if(R.length>0)B.skeletons=R;if(D.length>0)B.animations=D;if(H.length>0)B.nodes=H}return B.object=E,B;function C(G){let K=[];for(let J in G){let U=G[J];delete U.metadata,K.push(U)}return K}}clone(A){return new this.constructor().copy(this,A)}copy(A,Q=!0){if(this.name=A.name,this.up.copy(A.up),this.position.copy(A.position),this.rotation.order=A.rotation.order,this.quaternion.copy(A.quaternion),this.scale.copy(A.scale),this.pivot=A.pivot!==null?A.pivot.clone():null,this.matrix.copy(A.matrix),this.matrixWorld.copy(A.matrixWorld),this.matrixAutoUpdate=A.matrixAutoUpdate,this.matrixWorldAutoUpdate=A.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=A.matrixWorldNeedsUpdate,this.layers.mask=A.layers.mask,this.visible=A.visible,this.castShadow=A.castShadow,this.receiveShadow=A.receiveShadow,this.frustumCulled=A.frustumCulled,this.renderOrder=A.renderOrder,this.static=A.static,this.animations=A.animations.slice(),this.userData=JSON.parse(JSON.stringify(A.userData)),Q===!0)for(let B=0;BD+H)J.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:A.handedness,target:this});else if(!J.inputState.pinching&&R<=D-H)J.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:A.handedness,target:this})}else if(K!==null&&A.gripSpace){if(I=Q.getPose(A.gripSpace,B),I!==null){if(K.matrix.fromArray(I.transform.matrix),K.matrix.decompose(K.position,K.rotation,K.scale),K.matrixWorldNeedsUpdate=!0,I.linearVelocity)K.hasLinearVelocity=!0,K.linearVelocity.copy(I.linearVelocity);else K.hasLinearVelocity=!1;if(I.angularVelocity)K.hasAngularVelocity=!0,K.angularVelocity.copy(I.angularVelocity);else K.hasAngularVelocity=!1;if(K.eventsEnabled)K.dispatchEvent({type:"gripUpdated",data:A,target:this})}}if(G!==null){if(E=Q.getPose(A.targetRaySpace,B),E===null&&I!==null)E=I;if(E!==null){if(G.matrix.fromArray(E.transform.matrix),G.matrix.decompose(G.position,G.rotation,G.scale),G.matrixWorldNeedsUpdate=!0,E.linearVelocity)G.hasLinearVelocity=!0,G.linearVelocity.copy(E.linearVelocity);else G.hasLinearVelocity=!1;if(E.angularVelocity)G.hasAngularVelocity=!0,G.angularVelocity.copy(E.angularVelocity);else G.hasAngularVelocity=!1;this.dispatchEvent(Rq)}}}if(G!==null)G.visible=E!==null;if(K!==null)K.visible=I!==null;if(J!==null)J.visible=C!==null;return this}_getHandJoint(A,Q){if(A.joints[Q.jointName]===void 0){let B=new KE;B.matrixAutoUpdate=!1,B.visible=!1,A.joints[Q.jointName]=B,A.add(B)}return A.joints[Q.jointName]}}var ZR={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},oE={h:0,s:0,l:0},F8={h:0,s:0,l:0};function NK(A,Q,B){if(B<0)B+=1;if(B>1)B-=1;if(B<0.16666666666666666)return A+(Q-A)*6*B;if(B<0.5)return Q;if(B<0.6666666666666666)return A+(Q-A)*6*(0.6666666666666666-B);return A}class AQ{constructor(A,Q,B){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(A,Q,B)}set(A,Q,B){if(Q===void 0&&B===void 0){let E=A;if(E&&E.isColor)this.copy(E);else if(typeof E==="number")this.setHex(E);else if(typeof E==="string")this.setStyle(E)}else this.setRGB(A,Q,B);return this}setScalar(A){return this.r=A,this.g=A,this.b=A,this}setHex(A,Q="srgb"){return A=Math.floor(A),this.r=(A>>16&255)/255,this.g=(A>>8&255)/255,this.b=(A&255)/255,qQ.colorSpaceToWorking(this,Q),this}setRGB(A,Q,B,E=qQ.workingColorSpace){return this.r=A,this.g=Q,this.b=B,qQ.colorSpaceToWorking(this,E),this}setHSL(A,Q,B,E=qQ.workingColorSpace){if(A=OJ(A,1),Q=ZQ(Q,0,1),B=ZQ(B,0,1),Q===0)this.r=this.g=this.b=B;else{let I=B<=0.5?B*(1+Q):B+Q-B*Q,C=2*B-I;this.r=NK(C,I,A+0.3333333333333333),this.g=NK(C,I,A),this.b=NK(C,I,A-0.3333333333333333)}return qQ.colorSpaceToWorking(this,E),this}setStyle(A,Q="srgb"){function B(I){if(I===void 0)return;if(parseFloat(I)<1)mA("Color: Alpha component of "+A+" will be ignored.")}let E;if(E=/^(\w+)\(([^\)]*)\)/.exec(A)){let I,C=E[1],G=E[2];switch(C){case"rgb":case"rgba":if(I=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(G))return B(I[4]),this.setRGB(Math.min(255,parseInt(I[1],10))/255,Math.min(255,parseInt(I[2],10))/255,Math.min(255,parseInt(I[3],10))/255,Q);if(I=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(G))return B(I[4]),this.setRGB(Math.min(100,parseInt(I[1],10))/100,Math.min(100,parseInt(I[2],10))/100,Math.min(100,parseInt(I[3],10))/100,Q);break;case"hsl":case"hsla":if(I=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(G))return B(I[4]),this.setHSL(parseFloat(I[1])/360,parseFloat(I[2])/100,parseFloat(I[3])/100,Q);break;default:mA("Color: Unknown color model "+A)}}else if(E=/^\#([A-Fa-f\d]+)$/.exec(A)){let I=E[1],C=I.length;if(C===3)return this.setRGB(parseInt(I.charAt(0),16)/15,parseInt(I.charAt(1),16)/15,parseInt(I.charAt(2),16)/15,Q);else if(C===6)return this.setHex(parseInt(I,16),Q);else mA("Color: Invalid hex color "+A)}else if(A&&A.length>0)return this.setColorName(A,Q);return this}setColorName(A,Q="srgb"){let B=ZR[A.toLowerCase()];if(B!==void 0)this.setHex(B,Q);else mA("Color: Unknown color "+A);return this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(A){return this.r=A.r,this.g=A.g,this.b=A.b,this}copySRGBToLinear(A){return this.r=PE(A.r),this.g=PE(A.g),this.b=PE(A.b),this}copyLinearToSRGB(A){return this.r=H0(A.r),this.g=H0(A.g),this.b=H0(A.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(A="srgb"){return qQ.workingToColorSpace(RB.copy(this),A),Math.round(ZQ(RB.r*255,0,255))*65536+Math.round(ZQ(RB.g*255,0,255))*256+Math.round(ZQ(RB.b*255,0,255))}getHexString(A="srgb"){return("000000"+this.getHex(A).toString(16)).slice(-6)}getHSL(A,Q=qQ.workingColorSpace){qQ.workingToColorSpace(RB.copy(this),Q);let{r:B,g:E,b:I}=RB,C=Math.max(B,E,I),G=Math.min(B,E,I),K,J,U=(G+C)/2;if(G===C)K=0,J=0;else{let F=C-G;switch(J=U<=0.5?F/(C+G):F/(2-C-G),C){case B:K=(E-I)/F+(E0)Q.object.backgroundBlurriness=this.backgroundBlurriness;if(this.backgroundIntensity!==1)Q.object.backgroundIntensity=this.backgroundIntensity;if(Q.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1)Q.object.environmentIntensity=this.environmentIntensity;return Q.object.environmentRotation=this.environmentRotation.toArray(),Q}}var oB=new d,VE=new d,ZK=new d,kE=new d,E0=new d,I0=new d,t6=new d,XK=new d,LK=new d,WK=new d,$K=new SQ,OK=new SQ,VK=new SQ;class uB{constructor(A=new d,Q=new d,B=new d){this.a=A,this.b=Q,this.c=B}static getNormal(A,Q,B,E){E.subVectors(B,Q),oB.subVectors(A,Q),E.cross(oB);let I=E.lengthSq();if(I>0)return E.multiplyScalar(1/Math.sqrt(I));return E.set(0,0,0)}static getBarycoord(A,Q,B,E,I){oB.subVectors(E,Q),VE.subVectors(B,Q),ZK.subVectors(A,Q);let C=oB.dot(oB),G=oB.dot(VE),K=oB.dot(ZK),J=VE.dot(VE),U=VE.dot(ZK),F=C*J-G*G;if(F===0)return I.set(0,0,0),null;let R=1/F,D=(J*K-G*U)*R,H=(C*U-G*K)*R;return I.set(1-D-H,H,D)}static containsPoint(A,Q,B,E){if(this.getBarycoord(A,Q,B,E,kE)===null)return!1;return kE.x>=0&&kE.y>=0&&kE.x+kE.y<=1}static getInterpolation(A,Q,B,E,I,C,G,K){if(this.getBarycoord(A,Q,B,E,kE)===null){if(K.x=0,K.y=0,"z"in K)K.z=0;if("w"in K)K.w=0;return null}return K.setScalar(0),K.addScaledVector(I,kE.x),K.addScaledVector(C,kE.y),K.addScaledVector(G,kE.z),K}static getInterpolatedAttribute(A,Q,B,E,I,C){return $K.setScalar(0),OK.setScalar(0),VK.setScalar(0),$K.fromBufferAttribute(A,Q),OK.fromBufferAttribute(A,B),VK.fromBufferAttribute(A,E),C.setScalar(0),C.addScaledVector($K,I.x),C.addScaledVector(OK,I.y),C.addScaledVector(VK,I.z),C}static isFrontFacing(A,Q,B,E){return oB.subVectors(B,Q),VE.subVectors(A,Q),oB.cross(VE).dot(E)<0}set(A,Q,B){return this.a.copy(A),this.b.copy(Q),this.c.copy(B),this}setFromPointsAndIndices(A,Q,B,E){return this.a.copy(A[Q]),this.b.copy(A[B]),this.c.copy(A[E]),this}setFromAttributeAndIndices(A,Q,B,E){return this.a.fromBufferAttribute(A,Q),this.b.fromBufferAttribute(A,B),this.c.fromBufferAttribute(A,E),this}clone(){return new this.constructor().copy(this)}copy(A){return this.a.copy(A.a),this.b.copy(A.b),this.c.copy(A.c),this}getArea(){return oB.subVectors(this.c,this.b),VE.subVectors(this.a,this.b),oB.cross(VE).length()*0.5}getMidpoint(A){return A.addVectors(this.a,this.b).add(this.c).multiplyScalar(0.3333333333333333)}getNormal(A){return uB.getNormal(this.a,this.b,this.c,A)}getPlane(A){return A.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(A,Q){return uB.getBarycoord(A,this.a,this.b,this.c,Q)}getInterpolation(A,Q,B,E,I){return uB.getInterpolation(A,this.a,this.b,this.c,Q,B,E,I)}containsPoint(A){return uB.containsPoint(A,this.a,this.b,this.c)}isFrontFacing(A){return uB.isFrontFacing(this.a,this.b,this.c,A)}intersectsBox(A){return A.intersectsTriangle(this)}closestPointToPoint(A,Q){let B=this.a,E=this.b,I=this.c,C,G;E0.subVectors(E,B),I0.subVectors(I,B),XK.subVectors(A,B);let K=E0.dot(XK),J=I0.dot(XK);if(K<=0&&J<=0)return Q.copy(B);LK.subVectors(A,E);let U=E0.dot(LK),F=I0.dot(LK);if(U>=0&&F<=U)return Q.copy(E);let R=K*F-U*J;if(R<=0&&K>=0&&U<=0)return C=K/(K-U),Q.copy(B).addScaledVector(E0,C);WK.subVectors(A,I);let D=E0.dot(WK),H=I0.dot(WK);if(H>=0&&D<=H)return Q.copy(I);let M=D*J-K*H;if(M<=0&&J>=0&&H<=0)return G=J/(J-H),Q.copy(B).addScaledVector(I0,G);let X=U*H-D*F;if(X<=0&&F-U>=0&&D-H>=0)return t6.subVectors(I,E),G=(F-U)/(F-U+(D-H)),Q.copy(E).addScaledVector(t6,G);let Y=1/(X+M+R);return C=M*Y,G=R*Y,Q.copy(B).addScaledVector(E0,C).addScaledVector(I0,G)}equals(A){return A.a.equals(this.a)&&A.b.equals(this.b)&&A.c.equals(this.c)}}class lB{constructor(A=new d(1/0,1/0,1/0),Q=new d(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=A,this.max=Q}set(A,Q){return this.min.copy(A),this.max.copy(Q),this}setFromArray(A){this.makeEmpty();for(let Q=0,B=A.length;Q=this.min.x&&A.x<=this.max.x&&A.y>=this.min.y&&A.y<=this.max.y&&A.z>=this.min.z&&A.z<=this.max.z}containsBox(A){return this.min.x<=A.min.x&&A.max.x<=this.max.x&&this.min.y<=A.min.y&&A.max.y<=this.max.y&&this.min.z<=A.min.z&&A.max.z<=this.max.z}getParameter(A,Q){return Q.set((A.x-this.min.x)/(this.max.x-this.min.x),(A.y-this.min.y)/(this.max.y-this.min.y),(A.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(A){return A.max.x>=this.min.x&&A.min.x<=this.max.x&&A.max.y>=this.min.y&&A.min.y<=this.max.y&&A.max.z>=this.min.z&&A.min.z<=this.max.z}intersectsSphere(A){return this.clampPoint(A.center,aB),aB.distanceToSquared(A.center)<=A.radius*A.radius}intersectsPlane(A){let Q,B;if(A.normal.x>0)Q=A.normal.x*this.min.x,B=A.normal.x*this.max.x;else Q=A.normal.x*this.max.x,B=A.normal.x*this.min.x;if(A.normal.y>0)Q+=A.normal.y*this.min.y,B+=A.normal.y*this.max.y;else Q+=A.normal.y*this.max.y,B+=A.normal.y*this.min.y;if(A.normal.z>0)Q+=A.normal.z*this.min.z,B+=A.normal.z*this.max.z;else Q+=A.normal.z*this.max.z,B+=A.normal.z*this.min.z;return Q<=-A.constant&&B>=-A.constant}intersectsTriangle(A){if(this.isEmpty())return!1;this.getCenter(a0),D8.subVectors(this.max,a0),C0.subVectors(A.a,a0),G0.subVectors(A.b,a0),K0.subVectors(A.c,a0),aE.subVectors(G0,C0),rE.subVectors(K0,G0),WI.subVectors(C0,K0);let Q=[0,-aE.z,aE.y,0,-rE.z,rE.y,0,-WI.z,WI.y,aE.z,0,-aE.x,rE.z,0,-rE.x,WI.z,0,-WI.x,-aE.y,aE.x,0,-rE.y,rE.x,0,-WI.y,WI.x,0];if(!kK(Q,C0,G0,K0,D8))return!1;if(Q=[1,0,0,0,1,0,0,0,1],!kK(Q,C0,G0,K0,D8))return!1;return H8.crossVectors(aE,rE),Q=[H8.x,H8.y,H8.z],kK(Q,C0,G0,K0,D8)}clampPoint(A,Q){return Q.copy(A).clamp(this.min,this.max)}distanceToPoint(A){return this.clampPoint(A,aB).distanceTo(A)}getBoundingSphere(A){if(this.isEmpty())A.makeEmpty();else this.getCenter(A.center),A.radius=this.getSize(aB).length()*0.5;return A}intersect(A){if(this.min.max(A.min),this.max.min(A.max),this.isEmpty())this.makeEmpty();return this}union(A){return this.min.min(A.min),this.max.max(A.max),this}applyMatrix4(A){if(this.isEmpty())return this;return wE[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(A),wE[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(A),wE[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(A),wE[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(A),wE[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(A),wE[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(A),wE[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(A),wE[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(A),this.setFromPoints(wE),this}translate(A){return this.min.add(A),this.max.add(A),this}equals(A){return A.min.equals(this.min)&&A.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(A){return this.min.fromArray(A.min),this.max.fromArray(A.max),this}}var wE=[new d,new d,new d,new d,new d,new d,new d,new d],aB=new d,R8=new lB,C0=new d,G0=new d,K0=new d,aE=new d,rE=new d,WI=new d,a0=new d,D8=new d,H8=new d,$I=new d;function kK(A,Q,B,E,I){for(let C=0,G=A.length-3;C<=G;C+=3){$I.fromArray(A,C);let K=I.x*Math.abs($I.x)+I.y*Math.abs($I.y)+I.z*Math.abs($I.z),J=Q.dot($I),U=B.dot($I),F=E.dot($I);if(Math.max(-Math.max(J,U,F),Math.min(J,U,F))>K)return!1}return!0}var sQ=new d,Y8=new LA,Dq=0;class rQ extends RE{constructor(A,Q,B=!1){super();if(Array.isArray(A))throw TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Dq++}),this.name="",this.array=A,this.itemSize=Q,this.count=A!==void 0?A.length/Q:0,this.normalized=B,this.usage=35044,this.updateRanges=[],this.gpuType=1015,this.version=0}onUploadCallback(){}set needsUpdate(A){if(A===!0)this.version++}setUsage(A){return this.usage=A,this}addUpdateRange(A,Q){this.updateRanges.push({start:A,count:Q})}clearUpdateRanges(){this.updateRanges.length=0}copy(A){return this.name=A.name,this.array=new A.array.constructor(A.array),this.itemSize=A.itemSize,this.count=A.count,this.normalized=A.normalized,this.usage=A.usage,this.gpuType=A.gpuType,this}copyAt(A,Q,B){A*=this.itemSize,B*=Q.itemSize;for(let E=0,I=this.itemSize;Ethis.radius*this.radius)Q.sub(this.center).normalize(),Q.multiplyScalar(this.radius).add(this.center);return Q}getBoundingBox(A){if(this.isEmpty())return A.makeEmpty(),A;return A.set(this.center,this.center),A.expandByScalar(this.radius),A}applyMatrix4(A){return this.center.applyMatrix4(A),this.radius=this.radius*A.getMaxScaleOnAxis(),this}translate(A){return this.center.add(A),this}expandByPoint(A){if(this.isEmpty())return this.center.copy(A),this.radius=0,this;r0.subVectors(A,this.center);let Q=r0.lengthSq();if(Q>this.radius*this.radius){let B=Math.sqrt(Q),E=(B-this.radius)*0.5;this.center.addScaledVector(r0,E/B),this.radius+=E}return this}union(A){if(A.isEmpty())return this;if(this.isEmpty())return this.copy(A),this;if(this.center.equals(A.center)===!0)this.radius=Math.max(this.radius,A.radius);else wK.subVectors(A.center,this.center).setLength(A.radius),this.expandByPoint(r0.copy(A.center).add(wK)),this.expandByPoint(r0.copy(A.center).sub(wK));return this}equals(A){return A.center.equals(this.center)&&A.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(A){return this.radius=A.radius,this.center.fromArray(A.center),this}}var Yq=0,pB=new HQ,zK=new gQ,J0=new d,_B=new lB,t0=new lB,QB=new d;class JB extends RE{constructor(){super();this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Yq++}),this.uuid=eB(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(A){if(Array.isArray(A))this.index=new((vY(A))?s8:n8)(A,1);else this.index=A;return this}setIndirect(A,Q=0){return this.indirect=A,this.indirectOffset=Q,this}getIndirect(){return this.indirect}getAttribute(A){return this.attributes[A]}setAttribute(A,Q){return this.attributes[A]=Q,this}deleteAttribute(A){return delete this.attributes[A],this}hasAttribute(A){return this.attributes[A]!==void 0}addGroup(A,Q,B=0){this.groups.push({start:A,count:Q,materialIndex:B})}clearGroups(){this.groups=[]}setDrawRange(A,Q){this.drawRange.start=A,this.drawRange.count=Q}applyMatrix4(A){let Q=this.attributes.position;if(Q!==void 0)Q.applyMatrix4(A),Q.needsUpdate=!0;let B=this.attributes.normal;if(B!==void 0){let I=new KQ().getNormalMatrix(A);B.applyNormalMatrix(I),B.needsUpdate=!0}let E=this.attributes.tangent;if(E!==void 0)E.transformDirection(A),E.needsUpdate=!0;if(this.boundingBox!==null)this.computeBoundingBox();if(this.boundingSphere!==null)this.computeBoundingSphere();return this}applyQuaternion(A){return pB.makeRotationFromQuaternion(A),this.applyMatrix4(pB),this}rotateX(A){return pB.makeRotationX(A),this.applyMatrix4(pB),this}rotateY(A){return pB.makeRotationY(A),this.applyMatrix4(pB),this}rotateZ(A){return pB.makeRotationZ(A),this.applyMatrix4(pB),this}translate(A,Q,B){return pB.makeTranslation(A,Q,B),this.applyMatrix4(pB),this}scale(A,Q,B){return pB.makeScale(A,Q,B),this.applyMatrix4(pB),this}lookAt(A){return zK.lookAt(A),zK.updateMatrix(),this.applyMatrix4(zK.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(J0).negate(),this.translate(J0.x,J0.y,J0.z),this}setFromPoints(A){let Q=this.getAttribute("position");if(Q===void 0){let B=[];for(let E=0,I=A.length;EQ.count)mA("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.");Q.needsUpdate=!0}return this}computeBoundingBox(){if(this.boundingBox===null)this.boundingBox=new lB;let A=this.attributes.position,Q=this.morphAttributes.position;if(A&&A.isGLBufferAttribute){CQ("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new d(-1/0,-1/0,-1/0),new d(1/0,1/0,1/0));return}if(A!==void 0){if(this.boundingBox.setFromBufferAttribute(A),Q)for(let B=0,E=Q.length;B0)A.userData=this.userData;if(this.parameters!==void 0){let K=this.parameters;for(let J in K)if(K[J]!==void 0)A[J]=K[J];return A}A.data={attributes:{}};let Q=this.index;if(Q!==null)A.data.index={type:Q.array.constructor.name,array:Array.prototype.slice.call(Q.array)};let B=this.attributes;for(let K in B){let J=B[K];A.data.attributes[K]=J.toJSON(A.data)}let E={},I=!1;for(let K in this.morphAttributes){let J=this.morphAttributes[K],U=[];for(let F=0,R=J.length;F0)E[K]=U,I=!0}if(I)A.data.morphAttributes=E,A.data.morphTargetsRelative=this.morphTargetsRelative;let C=this.groups;if(C.length>0)A.data.groups=JSON.parse(JSON.stringify(C));let G=this.boundingSphere;if(G!==null)A.data.boundingSphere=G.toJSON();return A}clone(){return new this.constructor().copy(this)}copy(A){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let Q={};this.name=A.name;let B=A.index;if(B!==null)this.setIndex(B.clone());let E=A.attributes;for(let J in E){let U=E[J];this.setAttribute(J,U.clone(Q))}let I=A.morphAttributes;for(let J in I){let U=[],F=I[J];for(let R=0,D=F.length;R0!==A>0)this.version++;this._alphaTest=A}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(A){if(A===void 0)return;for(let Q in A){let B=A[Q];if(B===void 0){mA(`Material: parameter '${Q}' has value of undefined.`);continue}let E=this[Q];if(E===void 0){mA(`Material: '${Q}' is not a property of THREE.${this.type}.`);continue}if(E&&E.isColor)E.set(B);else if(E&&E.isVector3&&(B&&B.isVector3))E.copy(B);else this[Q]=B}}toJSON(A){let Q=A===void 0||typeof A==="string";if(Q)A={textures:{},images:{}};let B={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};if(B.uuid=this.uuid,B.type=this.type,this.name!=="")B.name=this.name;if(this.color&&this.color.isColor)B.color=this.color.getHex();if(this.roughness!==void 0)B.roughness=this.roughness;if(this.metalness!==void 0)B.metalness=this.metalness;if(this.sheen!==void 0)B.sheen=this.sheen;if(this.sheenColor&&this.sheenColor.isColor)B.sheenColor=this.sheenColor.getHex();if(this.sheenRoughness!==void 0)B.sheenRoughness=this.sheenRoughness;if(this.emissive&&this.emissive.isColor)B.emissive=this.emissive.getHex();if(this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1)B.emissiveIntensity=this.emissiveIntensity;if(this.specular&&this.specular.isColor)B.specular=this.specular.getHex();if(this.specularIntensity!==void 0)B.specularIntensity=this.specularIntensity;if(this.specularColor&&this.specularColor.isColor)B.specularColor=this.specularColor.getHex();if(this.shininess!==void 0)B.shininess=this.shininess;if(this.clearcoat!==void 0)B.clearcoat=this.clearcoat;if(this.clearcoatRoughness!==void 0)B.clearcoatRoughness=this.clearcoatRoughness;if(this.clearcoatMap&&this.clearcoatMap.isTexture)B.clearcoatMap=this.clearcoatMap.toJSON(A).uuid;if(this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture)B.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(A).uuid;if(this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture)B.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(A).uuid,B.clearcoatNormalScale=this.clearcoatNormalScale.toArray();if(this.sheenColorMap&&this.sheenColorMap.isTexture)B.sheenColorMap=this.sheenColorMap.toJSON(A).uuid;if(this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture)B.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(A).uuid;if(this.dispersion!==void 0)B.dispersion=this.dispersion;if(this.iridescence!==void 0)B.iridescence=this.iridescence;if(this.iridescenceIOR!==void 0)B.iridescenceIOR=this.iridescenceIOR;if(this.iridescenceThicknessRange!==void 0)B.iridescenceThicknessRange=this.iridescenceThicknessRange;if(this.iridescenceMap&&this.iridescenceMap.isTexture)B.iridescenceMap=this.iridescenceMap.toJSON(A).uuid;if(this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture)B.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(A).uuid;if(this.anisotropy!==void 0)B.anisotropy=this.anisotropy;if(this.anisotropyRotation!==void 0)B.anisotropyRotation=this.anisotropyRotation;if(this.anisotropyMap&&this.anisotropyMap.isTexture)B.anisotropyMap=this.anisotropyMap.toJSON(A).uuid;if(this.map&&this.map.isTexture)B.map=this.map.toJSON(A).uuid;if(this.matcap&&this.matcap.isTexture)B.matcap=this.matcap.toJSON(A).uuid;if(this.alphaMap&&this.alphaMap.isTexture)B.alphaMap=this.alphaMap.toJSON(A).uuid;if(this.lightMap&&this.lightMap.isTexture)B.lightMap=this.lightMap.toJSON(A).uuid,B.lightMapIntensity=this.lightMapIntensity;if(this.aoMap&&this.aoMap.isTexture)B.aoMap=this.aoMap.toJSON(A).uuid,B.aoMapIntensity=this.aoMapIntensity;if(this.bumpMap&&this.bumpMap.isTexture)B.bumpMap=this.bumpMap.toJSON(A).uuid,B.bumpScale=this.bumpScale;if(this.normalMap&&this.normalMap.isTexture)B.normalMap=this.normalMap.toJSON(A).uuid,B.normalMapType=this.normalMapType,B.normalScale=this.normalScale.toArray();if(this.displacementMap&&this.displacementMap.isTexture)B.displacementMap=this.displacementMap.toJSON(A).uuid,B.displacementScale=this.displacementScale,B.displacementBias=this.displacementBias;if(this.roughnessMap&&this.roughnessMap.isTexture)B.roughnessMap=this.roughnessMap.toJSON(A).uuid;if(this.metalnessMap&&this.metalnessMap.isTexture)B.metalnessMap=this.metalnessMap.toJSON(A).uuid;if(this.emissiveMap&&this.emissiveMap.isTexture)B.emissiveMap=this.emissiveMap.toJSON(A).uuid;if(this.specularMap&&this.specularMap.isTexture)B.specularMap=this.specularMap.toJSON(A).uuid;if(this.specularIntensityMap&&this.specularIntensityMap.isTexture)B.specularIntensityMap=this.specularIntensityMap.toJSON(A).uuid;if(this.specularColorMap&&this.specularColorMap.isTexture)B.specularColorMap=this.specularColorMap.toJSON(A).uuid;if(this.envMap&&this.envMap.isTexture){if(B.envMap=this.envMap.toJSON(A).uuid,this.combine!==void 0)B.combine=this.combine}if(this.envMapRotation!==void 0)B.envMapRotation=this.envMapRotation.toArray();if(this.envMapIntensity!==void 0)B.envMapIntensity=this.envMapIntensity;if(this.reflectivity!==void 0)B.reflectivity=this.reflectivity;if(this.refractionRatio!==void 0)B.refractionRatio=this.refractionRatio;if(this.gradientMap&&this.gradientMap.isTexture)B.gradientMap=this.gradientMap.toJSON(A).uuid;if(this.transmission!==void 0)B.transmission=this.transmission;if(this.transmissionMap&&this.transmissionMap.isTexture)B.transmissionMap=this.transmissionMap.toJSON(A).uuid;if(this.thickness!==void 0)B.thickness=this.thickness;if(this.thicknessMap&&this.thicknessMap.isTexture)B.thicknessMap=this.thicknessMap.toJSON(A).uuid;if(this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0)B.attenuationDistance=this.attenuationDistance;if(this.attenuationColor!==void 0)B.attenuationColor=this.attenuationColor.getHex();if(this.size!==void 0)B.size=this.size;if(this.shadowSide!==null)B.shadowSide=this.shadowSide;if(this.sizeAttenuation!==void 0)B.sizeAttenuation=this.sizeAttenuation;if(this.blending!==1)B.blending=this.blending;if(this.side!==0)B.side=this.side;if(this.vertexColors===!0)B.vertexColors=!0;if(this.opacity<1)B.opacity=this.opacity;if(this.transparent===!0)B.transparent=!0;if(this.blendSrc!==204)B.blendSrc=this.blendSrc;if(this.blendDst!==205)B.blendDst=this.blendDst;if(this.blendEquation!==100)B.blendEquation=this.blendEquation;if(this.blendSrcAlpha!==null)B.blendSrcAlpha=this.blendSrcAlpha;if(this.blendDstAlpha!==null)B.blendDstAlpha=this.blendDstAlpha;if(this.blendEquationAlpha!==null)B.blendEquationAlpha=this.blendEquationAlpha;if(this.blendColor&&this.blendColor.isColor)B.blendColor=this.blendColor.getHex();if(this.blendAlpha!==0)B.blendAlpha=this.blendAlpha;if(this.depthFunc!==3)B.depthFunc=this.depthFunc;if(this.depthTest===!1)B.depthTest=this.depthTest;if(this.depthWrite===!1)B.depthWrite=this.depthWrite;if(this.colorWrite===!1)B.colorWrite=this.colorWrite;if(this.stencilWriteMask!==255)B.stencilWriteMask=this.stencilWriteMask;if(this.stencilFunc!==519)B.stencilFunc=this.stencilFunc;if(this.stencilRef!==0)B.stencilRef=this.stencilRef;if(this.stencilFuncMask!==255)B.stencilFuncMask=this.stencilFuncMask;if(this.stencilFail!==7680)B.stencilFail=this.stencilFail;if(this.stencilZFail!==7680)B.stencilZFail=this.stencilZFail;if(this.stencilZPass!==7680)B.stencilZPass=this.stencilZPass;if(this.stencilWrite===!0)B.stencilWrite=this.stencilWrite;if(this.rotation!==void 0&&this.rotation!==0)B.rotation=this.rotation;if(this.polygonOffset===!0)B.polygonOffset=!0;if(this.polygonOffsetFactor!==0)B.polygonOffsetFactor=this.polygonOffsetFactor;if(this.polygonOffsetUnits!==0)B.polygonOffsetUnits=this.polygonOffsetUnits;if(this.linewidth!==void 0&&this.linewidth!==1)B.linewidth=this.linewidth;if(this.dashSize!==void 0)B.dashSize=this.dashSize;if(this.gapSize!==void 0)B.gapSize=this.gapSize;if(this.scale!==void 0)B.scale=this.scale;if(this.dithering===!0)B.dithering=!0;if(this.alphaTest>0)B.alphaTest=this.alphaTest;if(this.alphaHash===!0)B.alphaHash=!0;if(this.alphaToCoverage===!0)B.alphaToCoverage=!0;if(this.premultipliedAlpha===!0)B.premultipliedAlpha=!0;if(this.forceSinglePass===!0)B.forceSinglePass=!0;if(this.allowOverride===!1)B.allowOverride=!1;if(this.wireframe===!0)B.wireframe=!0;if(this.wireframeLinewidth>1)B.wireframeLinewidth=this.wireframeLinewidth;if(this.wireframeLinecap!=="round")B.wireframeLinecap=this.wireframeLinecap;if(this.wireframeLinejoin!=="round")B.wireframeLinejoin=this.wireframeLinejoin;if(this.flatShading===!0)B.flatShading=!0;if(this.visible===!1)B.visible=!1;if(this.toneMapped===!1)B.toneMapped=!1;if(this.fog===!1)B.fog=!1;if(Object.keys(this.userData).length>0)B.userData=this.userData;function E(I){let C=[];for(let G in I){let K=I[G];delete K.metadata,C.push(K)}return C}if(Q){let I=E(A.textures),C=E(A.images);if(I.length>0)B.textures=I;if(C.length>0)B.images=C}return B}clone(){return new this.constructor().copy(this)}copy(A){this.name=A.name,this.blending=A.blending,this.side=A.side,this.vertexColors=A.vertexColors,this.opacity=A.opacity,this.transparent=A.transparent,this.blendSrc=A.blendSrc,this.blendDst=A.blendDst,this.blendEquation=A.blendEquation,this.blendSrcAlpha=A.blendSrcAlpha,this.blendDstAlpha=A.blendDstAlpha,this.blendEquationAlpha=A.blendEquationAlpha,this.blendColor.copy(A.blendColor),this.blendAlpha=A.blendAlpha,this.depthFunc=A.depthFunc,this.depthTest=A.depthTest,this.depthWrite=A.depthWrite,this.stencilWriteMask=A.stencilWriteMask,this.stencilFunc=A.stencilFunc,this.stencilRef=A.stencilRef,this.stencilFuncMask=A.stencilFuncMask,this.stencilFail=A.stencilFail,this.stencilZFail=A.stencilZFail,this.stencilZPass=A.stencilZPass,this.stencilWrite=A.stencilWrite;let Q=A.clippingPlanes,B=null;if(Q!==null){let E=Q.length;B=Array(E);for(let I=0;I!==E;++I)B[I]=Q[I].clone()}return this.clippingPlanes=B,this.clipIntersection=A.clipIntersection,this.clipShadows=A.clipShadows,this.shadowSide=A.shadowSide,this.colorWrite=A.colorWrite,this.precision=A.precision,this.polygonOffset=A.polygonOffset,this.polygonOffsetFactor=A.polygonOffsetFactor,this.polygonOffsetUnits=A.polygonOffsetUnits,this.dithering=A.dithering,this.alphaTest=A.alphaTest,this.alphaHash=A.alphaHash,this.alphaToCoverage=A.alphaToCoverage,this.premultipliedAlpha=A.premultipliedAlpha,this.forceSinglePass=A.forceSinglePass,this.allowOverride=A.allowOverride,this.visible=A.visible,this.toneMapped=A.toneMapped,this.userData=JSON.parse(JSON.stringify(A.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(A){if(A===!0)this.version++}}var zE=new d,_K=new d,q8=new d,tE=new d,PK=new d,M8=new d,TK=new d;class jE{constructor(A=new d,Q=new d(0,0,-1)){this.origin=A,this.direction=Q}set(A,Q){return this.origin.copy(A),this.direction.copy(Q),this}copy(A){return this.origin.copy(A.origin),this.direction.copy(A.direction),this}at(A,Q){return Q.copy(this.origin).addScaledVector(this.direction,A)}lookAt(A){return this.direction.copy(A).sub(this.origin).normalize(),this}recast(A){return this.origin.copy(this.at(A,zE)),this}closestPointToPoint(A,Q){Q.subVectors(A,this.origin);let B=Q.dot(this.direction);if(B<0)return Q.copy(this.origin);return Q.copy(this.origin).addScaledVector(this.direction,B)}distanceToPoint(A){return Math.sqrt(this.distanceSqToPoint(A))}distanceSqToPoint(A){let Q=zE.subVectors(A,this.origin).dot(this.direction);if(Q<0)return this.origin.distanceToSquared(A);return zE.copy(this.origin).addScaledVector(this.direction,Q),zE.distanceToSquared(A)}distanceSqToSegment(A,Q,B,E){_K.copy(A).add(Q).multiplyScalar(0.5),q8.copy(Q).sub(A).normalize(),tE.copy(this.origin).sub(_K);let I=A.distanceTo(Q)*0.5,C=-this.direction.dot(q8),G=tE.dot(this.direction),K=-tE.dot(q8),J=tE.lengthSq(),U=Math.abs(1-C*C),F,R,D,H;if(U>0)if(F=C*K-G,R=C*G-K,H=I*U,F>=0)if(R>=-H)if(R<=H){let M=1/U;F*=M,R*=M,D=F*(F+C*R+2*G)+R*(C*F+R+2*K)+J}else R=I,F=Math.max(0,-(C*R+G)),D=-F*F+R*(R+2*K)+J;else R=-I,F=Math.max(0,-(C*R+G)),D=-F*F+R*(R+2*K)+J;else if(R<=-H)F=Math.max(0,-(-C*I+G)),R=F>0?-I:Math.min(Math.max(-I,-K),I),D=-F*F+R*(R+2*K)+J;else if(R<=H)F=0,R=Math.min(Math.max(-I,-K),I),D=R*(R+2*K)+J;else F=Math.max(0,-(C*I+G)),R=F>0?I:Math.min(Math.max(-I,-K),I),D=-F*F+R*(R+2*K)+J;else R=C>0?-I:I,F=Math.max(0,-(C*R+G)),D=-F*F+R*(R+2*K)+J;if(B)B.copy(this.origin).addScaledVector(this.direction,F);if(E)E.copy(_K).addScaledVector(q8,R);return D}intersectSphere(A,Q){zE.subVectors(A.center,this.origin);let B=zE.dot(this.direction),E=zE.dot(zE)-B*B,I=A.radius*A.radius;if(E>I)return null;let C=Math.sqrt(I-E),G=B-C,K=B+C;if(K<0)return null;if(G<0)return this.at(K,Q);return this.at(G,Q)}intersectsSphere(A){if(A.radius<0)return!1;return this.distanceSqToPoint(A.center)<=A.radius*A.radius}distanceToPlane(A){let Q=A.normal.dot(this.direction);if(Q===0){if(A.distanceToPoint(this.origin)===0)return 0;return null}let B=-(this.origin.dot(A.normal)+A.constant)/Q;return B>=0?B:null}intersectPlane(A,Q){let B=this.distanceToPlane(A);if(B===null)return null;return this.at(B,Q)}intersectsPlane(A){let Q=A.distanceToPoint(this.origin);if(Q===0)return!0;if(A.normal.dot(this.direction)*Q<0)return!0;return!1}intersectBox(A,Q){let B,E,I,C,G,K,J=1/this.direction.x,U=1/this.direction.y,F=1/this.direction.z,R=this.origin;if(J>=0)B=(A.min.x-R.x)*J,E=(A.max.x-R.x)*J;else B=(A.max.x-R.x)*J,E=(A.min.x-R.x)*J;if(U>=0)I=(A.min.y-R.y)*U,C=(A.max.y-R.y)*U;else I=(A.max.y-R.y)*U,C=(A.min.y-R.y)*U;if(B>C||I>E)return null;if(I>B||isNaN(B))B=I;if(C=0)G=(A.min.z-R.z)*F,K=(A.max.z-R.z)*F;else G=(A.max.z-R.z)*F,K=(A.min.z-R.z)*F;if(B>K||G>E)return null;if(G>B||B!==B)B=G;if(K=0?B:E,Q)}intersectsBox(A){return this.intersectBox(A,zE)!==null}intersectTriangle(A,Q,B,E,I){PK.subVectors(Q,A),M8.subVectors(B,A),TK.crossVectors(PK,M8);let C=this.direction.dot(TK),G;if(C>0){if(E)return null;G=1}else if(C<0)G=-1,C=-C;else return null;tE.subVectors(this.origin,A);let K=G*this.direction.dot(M8.crossVectors(tE,M8));if(K<0)return null;let J=G*this.direction.dot(PK.cross(tE));if(J<0)return null;if(K+J>C)return null;let U=-G*tE.dot(TK);if(U<0)return null;return this.at(U/C,I)}applyMatrix4(A){return this.origin.applyMatrix4(A),this.direction.transformDirection(A),this}equals(A){return A.origin.equals(this.origin)&&A.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class DE extends $B{constructor(A){super();this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new AQ(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new PB,this.combine=0,this.reflectivity=1,this.refractionRatio=0.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(A)}copy(A){return super.copy(A),this.color.copy(A.color),this.map=A.map,this.lightMap=A.lightMap,this.lightMapIntensity=A.lightMapIntensity,this.aoMap=A.aoMap,this.aoMapIntensity=A.aoMapIntensity,this.specularMap=A.specularMap,this.alphaMap=A.alphaMap,this.envMap=A.envMap,this.envMapRotation.copy(A.envMapRotation),this.combine=A.combine,this.reflectivity=A.reflectivity,this.refractionRatio=A.refractionRatio,this.wireframe=A.wireframe,this.wireframeLinewidth=A.wireframeLinewidth,this.wireframeLinecap=A.wireframeLinecap,this.wireframeLinejoin=A.wireframeLinejoin,this.fog=A.fog,this}}var e6=new HQ,OI=new jE,N8=new yB,AF=new d,Z8=new d,X8=new d,L8=new d,SK=new d,W8=new d,QF=new d,$8=new d;class _Q extends gQ{constructor(A=new JB,Q=new DE){super();this.isMesh=!0,this.type="Mesh",this.geometry=A,this.material=Q,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(A,Q){if(super.copy(A,Q),A.morphTargetInfluences!==void 0)this.morphTargetInfluences=A.morphTargetInfluences.slice();if(A.morphTargetDictionary!==void 0)this.morphTargetDictionary=Object.assign({},A.morphTargetDictionary);return this.material=Array.isArray(A.material)?A.material.slice():A.material,this.geometry=A.geometry,this}updateMorphTargets(){let Q=this.geometry.morphAttributes,B=Object.keys(Q);if(B.length>0){let E=Q[B[0]];if(E!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let I=0,C=E.length;I(A.far-A.near)**2)return}if(e6.copy(I).invert(),OI.copy(A.ray).applyMatrix4(e6),B.boundingBox!==null){if(OI.intersectsBox(B.boundingBox)===!1)return}this._computeIntersections(A,Q,OI)}_computeIntersections(A,Q,B){let E,I=this.geometry,C=this.material,G=I.index,K=I.attributes.position,J=I.attributes.uv,U=I.attributes.uv1,F=I.attributes.normal,R=I.groups,D=I.drawRange;if(G!==null)if(Array.isArray(C))for(let H=0,M=R.length;HB.far)return null;return{distance:U,point:$8.clone(),object:A}}function O8(A,Q,B,E,I,C,G,K,J,U){A.getVertexPosition(K,Z8),A.getVertexPosition(J,X8),A.getVertexPosition(U,L8);let F=Mq(A,Q,B,E,Z8,X8,L8,QF);if(F){let R=new d;if(uB.getBarycoord(QF,Z8,X8,L8,R),I)F.uv=uB.getInterpolatedAttribute(I,K,J,U,R,new LA);if(C)F.uv1=uB.getInterpolatedAttribute(C,K,J,U,R,new LA);if(G){if(F.normal=uB.getInterpolatedAttribute(G,K,J,U,R,new d),F.normal.dot(E.direction)>0)F.normal.multiplyScalar(-1)}let D={a:K,b:J,c:U,normal:new d,materialIndex:0};uB.getNormal(Z8,X8,L8,D.normal),F.face=D,F.barycoord=R}return F}var e0=new SQ,BF=new SQ,EF=new SQ,Nq=new SQ,IF=new HQ,V8=new d,jK=new yB,CF=new HQ,fK=new jE;class i8 extends _Q{constructor(A,Q){super(A,Q);this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new HQ,this.bindMatrixInverse=new HQ,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){let A=this.geometry;if(this.boundingBox===null)this.boundingBox=new lB;this.boundingBox.makeEmpty();let Q=A.getAttribute("position");for(let B=0;B1))return null;return Q.copy(A.start).addScaledVector(E,C)}intersectsLine(A){let Q=this.distanceToPoint(A.start),B=this.distanceToPoint(A.end);return Q<0&&B>0||B<0&&Q>0}intersectsBox(A){return A.intersectsPlane(this)}intersectsSphere(A){return A.intersectsPlane(this)}coplanarPoint(A){return A.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(A,Q){let B=Q||Wq.getNormalMatrix(A),E=this.coplanarPoint(yK).applyMatrix4(A),I=this.normal.applyMatrix3(B).normalize();return this.constant=-E.dot(I),this}translate(A){return this.constant-=A.dot(this.normal),this}equals(A){return A.normal.equals(this.normal)&&A.constant===this.constant}clone(){return new this.constructor().copy(this)}}var VI=new yB,$q=new LA(0.5,0.5),w8=new d;class _C{constructor(A=new rB,Q=new rB,B=new rB,E=new rB,I=new rB,C=new rB){this.planes=[A,Q,B,E,I,C]}set(A,Q,B,E,I,C){let G=this.planes;return G[0].copy(A),G[1].copy(Q),G[2].copy(B),G[3].copy(E),G[4].copy(I),G[5].copy(C),this}copy(A){let Q=this.planes;for(let B=0;B<6;B++)Q[B].copy(A.planes[B]);return this}setFromProjectionMatrix(A,Q=2000,B=!1){let E=this.planes,I=A.elements,C=I[0],G=I[1],K=I[2],J=I[3],U=I[4],F=I[5],R=I[6],D=I[7],H=I[8],M=I[9],X=I[10],Y=I[11],q=I[12],N=I[13],$=I[14],L=I[15];if(E[0].setComponents(J-C,D-U,Y-H,L-q).normalize(),E[1].setComponents(J+C,D+U,Y+H,L+q).normalize(),E[2].setComponents(J+G,D+F,Y+M,L+N).normalize(),E[3].setComponents(J-G,D-F,Y-M,L-N).normalize(),B)E[4].setComponents(K,R,X,$).normalize(),E[5].setComponents(J-K,D-R,Y-X,L-$).normalize();else if(E[4].setComponents(J-K,D-R,Y-X,L-$).normalize(),Q===2000)E[5].setComponents(J+K,D+R,Y+X,L+$).normalize();else if(Q===2001)E[5].setComponents(K,R,X,$).normalize();else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+Q);return this}intersectsObject(A){if(A.boundingSphere!==void 0){if(A.boundingSphere===null)A.computeBoundingSphere();VI.copy(A.boundingSphere).applyMatrix4(A.matrixWorld)}else{let Q=A.geometry;if(Q.boundingSphere===null)Q.computeBoundingSphere();VI.copy(Q.boundingSphere).applyMatrix4(A.matrixWorld)}return this.intersectsSphere(VI)}intersectsSprite(A){VI.center.set(0,0,0);let Q=$q.distanceTo(A.center);return VI.radius=0.7071067811865476+Q,VI.applyMatrix4(A.matrixWorld),this.intersectsSphere(VI)}intersectsSphere(A){let Q=this.planes,B=A.center,E=-A.radius;for(let I=0;I<6;I++)if(Q[I].distanceToPoint(B)0?A.max.x:A.min.x,w8.y=E.normal.y>0?A.max.y:A.min.y,w8.z=E.normal.z>0?A.max.z:A.min.z,E.distanceToPoint(w8)<0)return!1}return!0}containsPoint(A){let Q=this.planes;for(let B=0;B<6;B++)if(Q[B].distanceToPoint(A)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class PC extends $B{constructor(A){super();this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new AQ(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(A)}copy(A){return super.copy(A),this.color.copy(A.color),this.map=A.map,this.linewidth=A.linewidth,this.linecap=A.linecap,this.linejoin=A.linejoin,this.fog=A.fog,this}}var g8=new d,h8=new d,UF=new HQ,BC=new jE,z8=new yB,gK=new d,FF=new d;class S0 extends gQ{constructor(A=new JB,Q=new PC){super();this.isLine=!0,this.type="Line",this.geometry=A,this.material=Q,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(A,Q){return super.copy(A,Q),this.material=Array.isArray(A.material)?A.material.slice():A.material,this.geometry=A.geometry,this}computeLineDistances(){let A=this.geometry;if(A.index===null){let Q=A.attributes.position,B=[0];for(let E=1,I=Q.count;E0){let E=Q[B[0]];if(E!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let I=0,C=E.length;IE)return;gK.applyMatrix4(A.matrixWorld);let U=Q.ray.origin.distanceTo(gK);if(UQ.far)return;return{distance:U,point:FF.clone().applyMatrix4(A.matrixWorld),index:G,face:null,faceIndex:null,barycoord:null,object:A}}var RF=new d,DF=new d;class a8 extends S0{constructor(A,Q){super(A,Q);this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){let A=this.geometry;if(A.index===null){let Q=A.attributes.position,B=[];for(let E=0,I=Q.count;E0){let E=Q[B[0]];if(E!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let I=0,C=E.length;II.far)return;C.push({distance:U,distanceToRay:Math.sqrt(K),point:J,index:Q,face:null,faceIndex:null,barycoord:null,object:G})}}class SC extends cQ{constructor(A,Q,B,E,I=1006,C=1006,G,K,J){super(A,Q,B,E,I,C,G,K,J);this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;let U=this;function F(){U.needsUpdate=!0,U._requestVideoFrameCallbackId=A.requestVideoFrameCallback(F)}if("requestVideoFrameCallback"in A)this._requestVideoFrameCallbackId=A.requestVideoFrameCallback(F)}clone(){return new this.constructor(this.image).copy(this)}update(){let A=this.image;if("requestVideoFrameCallback"in A===!1&&A.readyState>=A.HAVE_CURRENT_DATA)this.needsUpdate=!0}dispose(){if(this._requestVideoFrameCallbackId!==0)this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0;super.dispose()}}class hI extends cQ{constructor(A,Q,B,E,I,C,G,K,J,U,F,R){super(null,C,G,K,J,U,E,I,F,R);this.isCompressedTexture=!0,this.image={width:Q,height:B},this.mipmaps=A,this.flipY=!1,this.generateMipmaps=!1}}class e8 extends hI{constructor(A,Q,B,E,I,C){super(A,Q,B,I,C);this.isCompressedArrayTexture=!0,this.image.depth=E,this.wrapR=1001,this.layerUpdates=new Set}addLayerUpdate(A){this.layerUpdates.add(A)}clearLayerUpdates(){this.layerUpdates.clear()}}class AG extends hI{constructor(A,Q,B){super(void 0,A[0].width,A[0].height,Q,B,301);this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=A}}class QG extends cQ{constructor(A=[],Q=301,B,E,I,C,G,K,J,U){super(A,Q,B,E,I,C,G,K,J,U);this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(A){this.image=A}}class JI extends cQ{constructor(A,Q,B=1014,E,I,C,G=1003,K=1003,J,U=1026,F=1){if(U!==1026&&U!==1027)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");let R={width:A,height:Q,depth:F};super(R,E,I,C,G,K,U,B,J);this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(A){return super.copy(A),this.source=new WC(Object.assign({},A.image)),this.compareFunction=A.compareFunction,this}toJSON(A){let Q=super.toJSON(A);if(this.compareFunction!==null)Q.compareFunction=this.compareFunction;return Q}}class wJ extends JI{constructor(A,Q=1014,B=301,E,I,C=1003,G=1003,K,J=1026){let U={width:A,height:A,depth:1},F=[U,U,U,U,U,U];super(A,A,Q,B,E,I,C,G,K,J);this.image=F,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(A){this.image=A}}class BG extends cQ{constructor(A=null){super();this.sourceTexture=A,this.isExternalTexture=!0}copy(A){return super.copy(A),this.sourceTexture=A.sourceTexture,this}}class j0 extends JB{constructor(A=1,Q=1,B=1,E=1,I=1,C=1){super();this.type="BoxGeometry",this.parameters={width:A,height:Q,depth:B,widthSegments:E,heightSegments:I,depthSegments:C};let G=this;E=Math.floor(E),I=Math.floor(I),C=Math.floor(C);let K=[],J=[],U=[],F=[],R=0,D=0;H("z","y","x",-1,-1,B,Q,A,C,I,0),H("z","y","x",1,-1,B,Q,-A,C,I,1),H("x","z","y",1,1,A,B,Q,E,C,2),H("x","z","y",1,-1,A,B,-Q,E,C,3),H("x","y","z",1,-1,A,Q,B,E,I,4),H("x","y","z",-1,-1,A,Q,-B,E,I,5),this.setIndex(K),this.setAttribute("position",new CB(J,3)),this.setAttribute("normal",new CB(U,3)),this.setAttribute("uv",new CB(F,2));function H(M,X,Y,q,N,$,L,k,O,w,Z){let z=$/O,y=L/w,_=$/2,v=L/2,x=k/2,P=O+1,j=w+1,g=0,f=0,p=new d;for(let u=0;u0?1:-1,U.push(p.x,p.y,p.z),F.push(t/O),F.push(1-u/w),g+=1}}for(let u=0;u0)N(!0);if(Q>0)N(!1)}this.setIndex(U),this.setAttribute("position",new CB(F,3)),this.setAttribute("normal",new CB(R,3)),this.setAttribute("uv",new CB(D,2));function q(){let $=new d,L=new d,k=0,O=(Q-A)/B;for(let w=0;w<=I;w++){let Z=[],z=w/I,y=z*(Q-A)+A;for(let _=0;_<=E;_++){let v=_/E,x=v*K+G,P=Math.sin(x),j=Math.cos(x);L.x=y*P,L.y=-z*B+X,L.z=y*j,F.push(L.x,L.y,L.z),$.set(P,O,j).normalize(),R.push($.x,$.y,$.z),D.push(v,1-z),Z.push(H++)}M.push(Z)}for(let w=0;w0||Z!==0)U.push(z,y,v),k+=3;if(Q>0||Z!==I-1)U.push(y,_,v),k+=3}J.addGroup(Y,k,0),Y+=k}function N($){let L=H,k=new LA,O=new d,w=0,Z=$===!0?A:Q,z=$===!0?1:-1;for(let _=1;_<=E;_++)F.push(0,X*z,0),R.push(0,z,0),D.push(0.5,0.5),H++;let y=H;for(let _=0;_<=E;_++){let x=_/E*K+G,P=Math.cos(x),j=Math.sin(x);O.x=Z*j,O.y=X*z,O.z=Z*P,F.push(O.x,O.y,O.z),R.push(0,z,0),k.x=P*0.5+0.5,k.y=j*0.5*z+0.5,D.push(k.x,k.y),H++}for(let _=0;_0)Q.defines=this.defines;Q.vertexShader=this.vertexShader,Q.fragmentShader=this.fragmentShader,Q.lights=this.lights,Q.clipping=this.clipping;let B={};for(let E in this.extensions)if(this.extensions[E]===!0)B[E]=!0;if(Object.keys(B).length>0)Q.extensions=B;return Q}}class _J extends hQ{constructor(A){super(A);this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class UI extends $B{constructor(A){super();this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new AQ(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new AQ(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new LA(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new PB,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(A)}copy(A){return super.copy(A),this.defines={STANDARD:""},this.color.copy(A.color),this.roughness=A.roughness,this.metalness=A.metalness,this.map=A.map,this.lightMap=A.lightMap,this.lightMapIntensity=A.lightMapIntensity,this.aoMap=A.aoMap,this.aoMapIntensity=A.aoMapIntensity,this.emissive.copy(A.emissive),this.emissiveMap=A.emissiveMap,this.emissiveIntensity=A.emissiveIntensity,this.bumpMap=A.bumpMap,this.bumpScale=A.bumpScale,this.normalMap=A.normalMap,this.normalMapType=A.normalMapType,this.normalScale.copy(A.normalScale),this.displacementMap=A.displacementMap,this.displacementScale=A.displacementScale,this.displacementBias=A.displacementBias,this.roughnessMap=A.roughnessMap,this.metalnessMap=A.metalnessMap,this.alphaMap=A.alphaMap,this.envMap=A.envMap,this.envMapRotation.copy(A.envMapRotation),this.envMapIntensity=A.envMapIntensity,this.wireframe=A.wireframe,this.wireframeLinewidth=A.wireframeLinewidth,this.wireframeLinecap=A.wireframeLinecap,this.wireframeLinejoin=A.wireframeLinejoin,this.flatShading=A.flatShading,this.fog=A.fog,this}}class gB extends UI{constructor(A){super();this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new LA(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return ZQ(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(Q){this.ior=(1+0.4*Q)/(1-0.4*Q)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new AQ(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new AQ(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new AQ(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(A)}get anisotropy(){return this._anisotropy}set anisotropy(A){if(this._anisotropy>0!==A>0)this.version++;this._anisotropy=A}get clearcoat(){return this._clearcoat}set clearcoat(A){if(this._clearcoat>0!==A>0)this.version++;this._clearcoat=A}get iridescence(){return this._iridescence}set iridescence(A){if(this._iridescence>0!==A>0)this.version++;this._iridescence=A}get dispersion(){return this._dispersion}set dispersion(A){if(this._dispersion>0!==A>0)this.version++;this._dispersion=A}get sheen(){return this._sheen}set sheen(A){if(this._sheen>0!==A>0)this.version++;this._sheen=A}get transmission(){return this._transmission}set transmission(A){if(this._transmission>0!==A>0)this.version++;this._transmission=A}copy(A){return super.copy(A),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=A.anisotropy,this.anisotropyRotation=A.anisotropyRotation,this.anisotropyMap=A.anisotropyMap,this.clearcoat=A.clearcoat,this.clearcoatMap=A.clearcoatMap,this.clearcoatRoughness=A.clearcoatRoughness,this.clearcoatRoughnessMap=A.clearcoatRoughnessMap,this.clearcoatNormalMap=A.clearcoatNormalMap,this.clearcoatNormalScale.copy(A.clearcoatNormalScale),this.dispersion=A.dispersion,this.ior=A.ior,this.iridescence=A.iridescence,this.iridescenceMap=A.iridescenceMap,this.iridescenceIOR=A.iridescenceIOR,this.iridescenceThicknessRange=[...A.iridescenceThicknessRange],this.iridescenceThicknessMap=A.iridescenceThicknessMap,this.sheen=A.sheen,this.sheenColor.copy(A.sheenColor),this.sheenColorMap=A.sheenColorMap,this.sheenRoughness=A.sheenRoughness,this.sheenRoughnessMap=A.sheenRoughnessMap,this.transmission=A.transmission,this.transmissionMap=A.transmissionMap,this.thickness=A.thickness,this.thicknessMap=A.thicknessMap,this.attenuationDistance=A.attenuationDistance,this.attenuationColor.copy(A.attenuationColor),this.specularIntensity=A.specularIntensity,this.specularIntensityMap=A.specularIntensityMap,this.specularColor.copy(A.specularColor),this.specularColorMap=A.specularColorMap,this}}class PJ extends $B{constructor(A){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(A)}copy(A){return super.copy(A),this.depthPacking=A.depthPacking,this.map=A.map,this.alphaMap=A.alphaMap,this.displacementMap=A.displacementMap,this.displacementScale=A.displacementScale,this.displacementBias=A.displacementBias,this.wireframe=A.wireframe,this.wireframeLinewidth=A.wireframeLinewidth,this}}class TJ extends $B{constructor(A){super();this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(A)}copy(A){return super.copy(A),this.map=A.map,this.alphaMap=A.alphaMap,this.displacementMap=A.displacementMap,this.displacementScale=A.displacementScale,this.displacementBias=A.displacementBias,this}}class EG extends $B{constructor(A){super();this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new AQ(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new LA(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(A)}copy(A){return super.copy(A),this.defines={MATCAP:""},this.color.copy(A.color),this.matcap=A.matcap,this.map=A.map,this.bumpMap=A.bumpMap,this.bumpScale=A.bumpScale,this.normalMap=A.normalMap,this.normalMapType=A.normalMapType,this.normalScale.copy(A.normalScale),this.displacementMap=A.displacementMap,this.displacementScale=A.displacementScale,this.displacementBias=A.displacementBias,this.alphaMap=A.alphaMap,this.wireframe=A.wireframe,this.wireframeLinewidth=A.wireframeLinewidth,this.flatShading=A.flatShading,this.fog=A.fog,this}}function S8(A,Q){if(!A||A.constructor===Q)return A;if(typeof Q.BYTES_PER_ELEMENT==="number")return new Q(A);return Array.prototype.slice.call(A)}function wq(A){function Q(I,C){return A[I]-A[C]}let B=A.length,E=Array(B);for(let I=0;I!==B;++I)E[I]=I;return E.sort(Q),E}function MF(A,Q,B){let E=A.length,I=new A.constructor(E);for(let C=0,G=0;G!==E;++C){let K=B[C]*Q;for(let J=0;J!==Q;++J)I[G++]=A[K+J]}return I}function LR(A,Q,B,E){let I=1,C=A[0];while(C!==void 0&&C[E]===void 0)C=A[I++];if(C===void 0)return;let G=C[E];if(G===void 0)return;if(Array.isArray(G))do{if(G=C[E],G!==void 0)Q.push(C.time),B.push(...G);C=A[I++]}while(C!==void 0);else if(G.toArray!==void 0)do{if(G=C[E],G!==void 0)Q.push(C.time),G.toArray(B,B.length);C=A[I++]}while(C!==void 0);else do{if(G=C[E],G!==void 0)Q.push(C.time),B.push(G);C=A[I++]}while(C!==void 0)}class fE{constructor(A,Q,B,E){this.parameterPositions=A,this._cachedIndex=0,this.resultBuffer=E!==void 0?E:new Q.constructor(B),this.sampleValues=Q,this.valueSize=B,this.settings=null,this.DefaultSettings_={}}evaluate(A){let Q=this.parameterPositions,B=this._cachedIndex,E=Q[B],I=Q[B-1];B:{A:{let C;Q:{E:if(!(A=I)){let G=Q[1];if(A=I)break A}C=B,B=0;break Q}break B}while(B>>1;if(AQ)--C;if(++C,I!==0||C!==E){if(I>=C)C=Math.max(C,1),I=C-1;let G=this.getValueSize();this.times=B.slice(I,C),this.values=this.values.slice(I*G,C*G)}return this}validate(){let A=!0,Q=this.getValueSize();if(Q-Math.floor(Q)!==0)CQ("KeyframeTrack: Invalid value size in track.",this),A=!1;let B=this.times,E=this.values,I=B.length;if(I===0)CQ("KeyframeTrack: Track is empty.",this),A=!1;let C=null;for(let G=0;G!==I;G++){let K=B[G];if(typeof K==="number"&&isNaN(K)){CQ("KeyframeTrack: Time is not a valid number.",this,G,K),A=!1;break}if(C!==null&&C>K){CQ("KeyframeTrack: Out of order keys.",this,G,K,C),A=!1;break}C=K}if(E!==void 0){if(bY(E))for(let G=0,K=E.length;G!==K;++G){let J=E[G];if(isNaN(J)){CQ("KeyframeTrack: Value is not a valid number.",this,G,J),A=!1;break}}}return A}optimize(){let A=this.times.slice(),Q=this.values.slice(),B=this.getValueSize(),E=this.getInterpolation()===2302,I=A.length-1,C=1;for(let G=1;G0){A[C]=A[I];for(let G=I*B,K=C*B,J=0;J!==B;++J)Q[K+J]=Q[G+J];++C}if(C!==A.length)this.times=A.slice(0,C),this.values=Q.slice(0,C*B);else this.times=A,this.values=Q;return this}clone(){let A=this.times.slice(),Q=this.values.slice(),E=new this.constructor(this.name,A,Q);return E.createInterpolant=this.createInterpolant,E}}hB.prototype.ValueTypeName="";hB.prototype.TimeBufferType=Float32Array;hB.prototype.ValueBufferType=Float32Array;hB.prototype.DefaultInterpolation=2301;class FI extends hB{constructor(A,Q,B){super(A,Q,B)}}FI.prototype.ValueTypeName="bool";FI.prototype.ValueBufferType=Array;FI.prototype.DefaultInterpolation=2300;FI.prototype.InterpolantFactoryMethodLinear=void 0;FI.prototype.InterpolantFactoryMethodSmooth=void 0;class IG extends hB{constructor(A,Q,B,E){super(A,Q,B,E)}}IG.prototype.ValueTypeName="color";class TE extends hB{constructor(A,Q,B,E){super(A,Q,B,E)}}TE.prototype.ValueTypeName="number";class gJ extends fE{constructor(A,Q,B,E){super(A,Q,B,E)}interpolate_(A,Q,B,E){let I=this.resultBuffer,C=this.sampleValues,G=this.valueSize,K=(B-Q)/(E-Q),J=A*G;for(let U=J+G;J!==U;J+=4)ZB.slerpFlat(I,0,C,J-G,C,J,K);return I}}class yE extends hB{constructor(A,Q,B,E){super(A,Q,B,E)}InterpolantFactoryMethodLinear(A){return new gJ(this.times,this.values,this.getValueSize(),A)}}yE.prototype.ValueTypeName="quaternion";yE.prototype.InterpolantFactoryMethodSmooth=void 0;class RI extends hB{constructor(A,Q,B){super(A,Q,B)}}RI.prototype.ValueTypeName="string";RI.prototype.ValueBufferType=Array;RI.prototype.DefaultInterpolation=2300;RI.prototype.InterpolantFactoryMethodLinear=void 0;RI.prototype.InterpolantFactoryMethodSmooth=void 0;class SE extends hB{constructor(A,Q,B,E){super(A,Q,B,E)}}SE.prototype.ValueTypeName="vector";class CG{constructor(A="",Q=-1,B=[],E=2500){if(this.name=A,this.tracks=B,this.duration=Q,this.blendMode=E,this.uuid=eB(),this.userData={},this.duration<0)this.resetDuration()}static parse(A){let Q=[],B=A.tracks,E=1/(A.fps||1);for(let C=0,G=B.length;C!==G;++C)Q.push(_q(B[C]).scale(E));let I=new this(A.name,A.duration,Q,A.blendMode);return I.uuid=A.uuid,I.userData=JSON.parse(A.userData||"{}"),I}static toJSON(A){let Q=[],B=A.tracks,E={name:A.name,duration:A.duration,tracks:Q,uuid:A.uuid,blendMode:A.blendMode,userData:JSON.stringify(A.userData)};for(let I=0,C=B.length;I!==C;++I)Q.push(hB.toJSON(B[I]));return E}static CreateFromMorphTargetSequence(A,Q,B,E){let I=Q.length,C=[];for(let G=0;G1){let F=U[1],R=E[F];if(!R)E[F]=R=[];R.push(J)}}let C=[];for(let G in E)C.push(this.CreateFromMorphTargetSequence(G,E[G],Q,B));return C}static parseAnimation(A,Q){if(mA("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!A)return CQ("AnimationClip: No animation in JSONLoader data."),null;let B=function(F,R,D,H,M){if(D.length!==0){let X=[],Y=[];if(LR(D,X,Y,H),X.length!==0)M.push(new F(R,X,Y))}},E=[],I=A.name||"default",C=A.fps||30,G=A.blendMode,K=A.length||-1,J=A.hierarchy||[];for(let F=0;F{if(Q)Q(I);this.manager.itemEnd(A)},0);return}if(_E[A]!==void 0){_E[A].push({onLoad:Q,onProgress:B,onError:E});return}_E[A]=[],_E[A].push({onLoad:Q,onProgress:B,onError:E});let C=new Request(A,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),G=this.mimeType,K=this.responseType;fetch(C).then((J)=>{if(J.status===200||J.status===0){if(J.status===0)mA("FileLoader: HTTP Status 0 received.");if(typeof ReadableStream>"u"||J.body===void 0||J.body.getReader===void 0)return J;let U=_E[A],F=J.body.getReader(),R=J.headers.get("X-File-Size")||J.headers.get("Content-Length"),D=R?parseInt(R):0,H=D!==0,M=0,X=new ReadableStream({start(Y){q();function q(){F.read().then(({done:N,value:$})=>{if(N)Y.close();else{M+=$.byteLength;let L=new ProgressEvent("progress",{lengthComputable:H,loaded:M,total:D});for(let k=0,O=U.length;k{Y.error(N)})}}});return new Response(X)}else throw new $R(`fetch for "${J.url}" responded with ${J.status}: ${J.statusText}`,J)}).then((J)=>{switch(K){case"arraybuffer":return J.arrayBuffer();case"blob":return J.blob();case"document":return J.text().then((U)=>{return new DOMParser().parseFromString(U,G)});case"json":return J.json();default:if(G==="")return J.text();else{let F=/charset="?([^;"\s]*)"?/i.exec(G),R=F&&F[1]?F[1].toLowerCase():void 0,D=new TextDecoder(R);return J.arrayBuffer().then((H)=>D.decode(H))}}}).then((J)=>{JE.add(`file:${A}`,J);let U=_E[A];delete _E[A];for(let F=0,R=U.length;F{let U=_E[A];if(U===void 0)throw this.manager.itemError(A),J;delete _E[A];for(let F=0,R=U.length;F{this.manager.itemEnd(A)}),this.manager.itemStart(A)}setResponseType(A){return this.responseType=A,this}setMimeType(A){return this.mimeType=A,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var F0=new WeakMap;class xJ extends QE{constructor(A){super(A)}load(A,Q,B,E){if(this.path!==void 0)A=this.path+A;A=this.manager.resolveURL(A);let I=this,C=JE.get(`image:${A}`);if(C!==void 0){if(C.complete===!0)I.manager.itemStart(A),setTimeout(function(){if(Q)Q(C);I.manager.itemEnd(A)},0);else{let F=F0.get(C);if(F===void 0)F=[],F0.set(C,F);F.push({onLoad:Q,onError:E})}return C}let G=Y0("img");function K(){if(U(),Q)Q(this);let F=F0.get(this)||[];for(let R=0;R"u")mA("ImageBitmapLoader: createImageBitmap() not supported.");if(typeof fetch>"u")mA("ImageBitmapLoader: fetch() not supported.");this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(A){return this.options=A,this}load(A,Q,B,E){if(A===void 0)A="";if(this.path!==void 0)A=this.path+A;A=this.manager.resolveURL(A);let I=this,C=JE.get(`image-bitmap:${A}`);if(C!==void 0){if(I.manager.itemStart(A),C.then){C.then((J)=>{if(xK.has(C)===!0){if(E)E(xK.get(C));I.manager.itemError(A),I.manager.itemEnd(A)}else{if(Q)Q(J);I.manager.itemEnd(A)}});return}setTimeout(function(){if(Q)Q(C);I.manager.itemEnd(A)},0);return}let G={};G.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",G.headers=this.requestHeader,G.signal=typeof AbortSignal.any==="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;let K=fetch(A,G).then(function(J){return J.blob()}).then(function(J){return createImageBitmap(J,Object.assign(I.options,{colorSpaceConversion:"none"}))}).then(function(J){if(JE.add(`image-bitmap:${A}`,J),Q)Q(J);I.manager.itemEnd(A)}).catch(function(J){if(E)E(J);xK.set(K,J),JE.remove(`image-bitmap:${A}`),I.manager.itemError(A),I.manager.itemEnd(A)});JE.add(`image-bitmap:${A}`,K),I.manager.itemStart(A)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}var R0=-90,D0=1;class vJ extends gQ{constructor(A,Q,B){super();this.type="CubeCamera",this.renderTarget=B,this.coordinateSystem=null,this.activeMipmapLevel=0;let E=new dQ(R0,D0,A,Q);E.layers=this.layers,this.add(E);let I=new dQ(R0,D0,A,Q);I.layers=this.layers,this.add(I);let C=new dQ(R0,D0,A,Q);C.layers=this.layers,this.add(C);let G=new dQ(R0,D0,A,Q);G.layers=this.layers,this.add(G);let K=new dQ(R0,D0,A,Q);K.layers=this.layers,this.add(K);let J=new dQ(R0,D0,A,Q);J.layers=this.layers,this.add(J)}updateCoordinateSystem(){let A=this.coordinateSystem,Q=this.children.concat(),[B,E,I,C,G,K]=Q;for(let J of Q)this.remove(J);if(A===2000)B.up.set(0,1,0),B.lookAt(1,0,0),E.up.set(0,1,0),E.lookAt(-1,0,0),I.up.set(0,0,-1),I.lookAt(0,1,0),C.up.set(0,0,1),C.lookAt(0,-1,0),G.up.set(0,1,0),G.lookAt(0,0,1),K.up.set(0,1,0),K.lookAt(0,0,-1);else if(A===2001)B.up.set(0,-1,0),B.lookAt(-1,0,0),E.up.set(0,-1,0),E.lookAt(1,0,0),I.up.set(0,0,1),I.lookAt(0,1,0),C.up.set(0,0,-1),C.lookAt(0,-1,0),G.up.set(0,-1,0),G.lookAt(0,0,1),K.up.set(0,-1,0),K.lookAt(0,0,-1);else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+A);for(let J of Q)this.add(J),J.updateMatrixWorld()}update(A,Q){if(this.parent===null)this.updateMatrixWorld();let{renderTarget:B,activeMipmapLevel:E}=this;if(this.coordinateSystem!==A.coordinateSystem)this.coordinateSystem=A.coordinateSystem,this.updateCoordinateSystem();let[I,C,G,K,J,U]=this.children,F=A.getRenderTarget(),R=A.getActiveCubeFace(),D=A.getActiveMipmapLevel(),H=A.xr.enabled;A.xr.enabled=!1;let M=B.texture.generateMipmaps;B.texture.generateMipmaps=!1;let X=!1;if(A.isWebGLRenderer===!0)X=A.state.buffers.depth.getReversed();else X=A.reversedDepthBuffer;if(A.setRenderTarget(B,0,E),X&&A.autoClear===!1)A.clearDepth();if(A.render(Q,I),A.setRenderTarget(B,1,E),X&&A.autoClear===!1)A.clearDepth();if(A.render(Q,C),A.setRenderTarget(B,2,E),X&&A.autoClear===!1)A.clearDepth();if(A.render(Q,G),A.setRenderTarget(B,3,E),X&&A.autoClear===!1)A.clearDepth();if(A.render(Q,K),A.setRenderTarget(B,4,E),X&&A.autoClear===!1)A.clearDepth();if(A.render(Q,J),B.texture.generateMipmaps=M,A.setRenderTarget(B,5,E),X&&A.autoClear===!1)A.clearDepth();A.render(Q,U),A.setRenderTarget(F,R,D),A.xr.enabled=H,B.texture.needsPMREMUpdate=!0}}class bJ extends dQ{constructor(A=[]){super();this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=A}}class RG{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(A){if(this._document=A,A.hidden!==void 0)this._pageVisibilityHandler=Pq.bind(this),A.addEventListener("visibilitychange",this._pageVisibilityHandler,!1)}disconnect(){if(this._pageVisibilityHandler!==null)this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null;this._document=null}getDelta(){return this._delta/1000}getElapsed(){return this._elapsed/1000}getTimescale(){return this._timescale}setTimescale(A){return this._timescale=A,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(A){if(this._pageVisibilityHandler!==null&&this._document.hidden===!0)this._delta=0;else this._previousTime=this._currentTime,this._currentTime=(A!==void 0?A:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta;return this}}function Pq(){if(this._document.hidden===!1)this.reset()}var pJ="\\[\\]\\.:\\/",Tq=new RegExp("["+pJ+"]","g"),uJ="[^"+pJ+"]",Sq="[^"+pJ.replace("\\.","")+"]",jq=/((?:WC+[\/:])*)/.source.replace("WC",uJ),fq=/(WCOD+)?/.source.replace("WCOD",Sq),yq=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",uJ),gq=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",uJ),hq=new RegExp("^"+jq+fq+yq+gq+"$"),xq=["material","materials","bones","map"];class zR{constructor(A,Q,B){let E=B||kQ.parseTrackName(Q);this._targetGroup=A,this._bindings=A.subscribe_(Q,E)}getValue(A,Q){this.bind();let B=this._targetGroup.nCachedObjects_,E=this._bindings[B];if(E!==void 0)E.getValue(A,Q)}setValue(A,Q){let B=this._bindings;for(let E=this._targetGroup.nCachedObjects_,I=B.length;E!==I;++E)B[E].setValue(A,Q)}bind(){let A=this._bindings;for(let Q=this._targetGroup.nCachedObjects_,B=A.length;Q!==B;++Q)A[Q].bind()}unbind(){let A=this._bindings;for(let Q=this._targetGroup.nCachedObjects_,B=A.length;Q!==B;++Q)A[Q].unbind()}}class kQ{constructor(A,Q,B){this.path=Q,this.parsedPath=B||kQ.parseTrackName(Q),this.node=kQ.findNode(A,this.parsedPath.nodeName),this.rootNode=A,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(A,Q,B){if(!(A&&A.isAnimationObjectGroup))return new kQ(A,Q,B);else return new kQ.Composite(A,Q,B)}static sanitizeNodeName(A){return A.replace(/\s/g,"_").replace(Tq,"")}static parseTrackName(A){let Q=hq.exec(A);if(Q===null)throw Error("PropertyBinding: Cannot parse trackName: "+A);let B={nodeName:Q[2],objectName:Q[3],objectIndex:Q[4],propertyName:Q[5],propertyIndex:Q[6]},E=B.nodeName&&B.nodeName.lastIndexOf(".");if(E!==void 0&&E!==-1){let I=B.nodeName.substring(E+1);if(xq.indexOf(I)!==-1)B.nodeName=B.nodeName.substring(0,E),B.objectName=I}if(B.propertyName===null||B.propertyName.length===0)throw Error("PropertyBinding: can not parse propertyName from trackName: "+A);return B}static findNode(A,Q){if(Q===void 0||Q===""||Q==="."||Q===-1||Q===A.name||Q===A.uuid)return A;if(A.skeleton){let B=A.skeleton.getBoneByName(Q);if(B!==void 0)return B}if(A.children){let B=function(I){for(let C=0;CH.start-M.start);let D=0;for(let H=1;H 0 vec4 plane; #ifdef ALPHA_TO_COVERAGE float distanceToPlane, distanceGradient; float clipOpacity = 1.0; #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; distanceGradient = fwidth( distanceToPlane ) / 2.0; clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); if ( clipOpacity == 0.0 ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES float unionClipOpacity = 1.0; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; distanceGradient = fwidth( distanceToPlane ) / 2.0; unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); } #pragma unroll_loop_end clipOpacity *= 1.0 - unionClipOpacity; #endif diffuseColor.a *= clipOpacity; if ( diffuseColor.a == 0.0 ) discard; #else #pragma unroll_loop_start for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; } #pragma unroll_loop_end #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES bool clipped = true; #pragma unroll_loop_start for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { plane = clippingPlanes[ i ]; clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; } #pragma unroll_loop_end if ( clipped ) discard; #endif #endif #endif`,B7=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; #endif`,E7=`#if NUM_CLIPPING_PLANES > 0 varying vec3 vClipPosition; #endif`,I7=`#if NUM_CLIPPING_PLANES > 0 vClipPosition = - mvPosition.xyz; #endif`,C7=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) diffuseColor *= vColor; #endif`,G7=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) varying vec4 vColor; #endif`,K7=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) varying vec4 vColor; #endif`,J7=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) vColor = vec4( 1.0 ); #endif #ifdef USE_COLOR_ALPHA vColor *= color; #elif defined( USE_COLOR ) vColor.rgb *= color; #endif #ifdef USE_INSTANCING_COLOR vColor.rgb *= instanceColor.rgb; #endif #ifdef USE_BATCHING_COLOR vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); #endif`,U7=`#define PI 3.141592653589793 #define PI2 6.283185307179586 #define PI_HALF 1.5707963267948966 #define RECIPROCAL_PI 0.3183098861837907 #define RECIPROCAL_PI2 0.15915494309189535 #define EPSILON 1e-6 #ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif #define whiteComplement( a ) ( 1.0 - saturate( a ) ) float pow2( const in float x ) { return x*x; } vec3 pow2( const in vec3 x ) { return x*x; } float pow3( const in float x ) { return x*x*x; } float pow4( const in float x ) { float x2 = x*x; return x2*x2; } float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } highp float rand( const in vec2 uv ) { const highp float a = 12.9898, b = 78.233, c = 43758.5453; highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); return fract( sin( sn ) * c ); } #ifdef HIGH_PRECISION float precisionSafeLength( vec3 v ) { return length( v ); } #else float precisionSafeLength( vec3 v ) { float maxComponent = max3( abs( v ) ); return length( v / maxComponent ) * maxComponent; } #endif struct IncidentLight { vec3 color; vec3 direction; bool visible; }; struct ReflectedLight { vec3 directDiffuse; vec3 directSpecular; vec3 indirectDiffuse; vec3 indirectSpecular; }; #ifdef USE_ALPHAHASH varying vec3 vPosition; #endif vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz ); } bool isPerspectiveMatrix( mat4 m ) { return m[ 2 ][ 3 ] == - 1.0; } vec2 equirectUv( in vec3 dir ) { float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; return vec2( u, v ); } vec3 BRDF_Lambert( const in vec3 diffuseColor ) { return RECIPROCAL_PI * diffuseColor; } vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } float F_Schlick( const in float f0, const in float f90, const in float dotVH ) { float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ); return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ); } // validated`,F7=`#ifdef ENVMAP_TYPE_CUBE_UV #define cubeUV_minMipLevel 4.0 #define cubeUV_minTileSize 16.0 float getFace( vec3 direction ) { vec3 absDirection = abs( direction ); float face = - 1.0; if ( absDirection.x > absDirection.z ) { if ( absDirection.x > absDirection.y ) face = direction.x > 0.0 ? 0.0 : 3.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } else { if ( absDirection.z > absDirection.y ) face = direction.z > 0.0 ? 2.0 : 5.0; else face = direction.y > 0.0 ? 1.0 : 4.0; } return face; } vec2 getUV( vec3 direction, float face ) { vec2 uv; if ( face == 0.0 ) { uv = vec2( direction.z, direction.y ) / abs( direction.x ); } else if ( face == 1.0 ) { uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); } else if ( face == 2.0 ) { uv = vec2( - direction.x, direction.y ) / abs( direction.z ); } else if ( face == 3.0 ) { uv = vec2( - direction.z, direction.y ) / abs( direction.x ); } else if ( face == 4.0 ) { uv = vec2( - direction.x, direction.z ) / abs( direction.y ); } else { uv = vec2( direction.x, direction.y ) / abs( direction.z ); } return 0.5 * ( uv + 1.0 ); } vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { float face = getFace( direction ); float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); mipInt = max( mipInt, cubeUV_minMipLevel ); float faceSize = exp2( mipInt ); highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; if ( face > 2.0 ) { uv.y += faceSize; face -= 3.0; } uv.x += face * faceSize; uv.x += filterInt * 3.0 * cubeUV_minTileSize; uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); uv.x *= CUBEUV_TEXEL_WIDTH; uv.y *= CUBEUV_TEXEL_HEIGHT; #ifdef texture2DGradEXT return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; #else return texture2D( envMap, uv ).rgb; #endif } #define cubeUV_r0 1.0 #define cubeUV_m0 - 2.0 #define cubeUV_r1 0.8 #define cubeUV_m1 - 1.0 #define cubeUV_r4 0.4 #define cubeUV_m4 2.0 #define cubeUV_r5 0.305 #define cubeUV_m5 3.0 #define cubeUV_r6 0.21 #define cubeUV_m6 4.0 float roughnessToMip( float roughness ) { float mip = 0.0; if ( roughness >= cubeUV_r1 ) { mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; } else if ( roughness >= cubeUV_r4 ) { mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; } else if ( roughness >= cubeUV_r5 ) { mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; } else if ( roughness >= cubeUV_r6 ) { mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; } else { mip = - 2.0 * log2( 1.16 * roughness ); } return mip; } vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); float mipF = fract( mip ); float mipInt = floor( mip ); vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); if ( mipF == 0.0 ) { return vec4( color0, 1.0 ); } else { vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); return vec4( mix( color0, color1, mipF ), 1.0 ); } } #endif`,R7=`vec3 transformedNormal = objectNormal; #ifdef USE_TANGENT vec3 transformedTangent = objectTangent; #endif #ifdef USE_BATCHING mat3 bm = mat3( batchingMatrix ); transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); transformedNormal = bm * transformedNormal; #ifdef USE_TANGENT transformedTangent = bm * transformedTangent; #endif #endif #ifdef USE_INSTANCING mat3 im = mat3( instanceMatrix ); transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); transformedNormal = im * transformedNormal; #ifdef USE_TANGENT transformedTangent = im * transformedTangent; #endif #endif transformedNormal = normalMatrix * transformedNormal; #ifdef FLIP_SIDED transformedNormal = - transformedNormal; #endif #ifdef USE_TANGENT transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; #ifdef FLIP_SIDED transformedTangent = - transformedTangent; #endif #endif`,D7=`#ifdef USE_DISPLACEMENTMAP uniform sampler2D displacementMap; uniform float displacementScale; uniform float displacementBias; #endif`,H7=`#ifdef USE_DISPLACEMENTMAP transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); #endif`,Y7=`#ifdef USE_EMISSIVEMAP vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE emissiveColor = sRGBTransferEOTF( emissiveColor ); #endif totalEmissiveRadiance *= emissiveColor.rgb; #endif`,q7=`#ifdef USE_EMISSIVEMAP uniform sampler2D emissiveMap; #endif`,M7="gl_FragColor = linearToOutputTexel( gl_FragColor );",N7=`vec4 LinearTransferOETF( in vec4 value ) { return value; } vec4 sRGBTransferEOTF( in vec4 value ) { return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); } vec4 sRGBTransferOETF( in vec4 value ) { return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a ); }`,Z7=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vec3 cameraToFrag; if ( isOrthographic ) { cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToFrag = normalize( vWorldPosition - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vec3 reflectVec = reflect( cameraToFrag, worldNormal ); #else vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); #endif #else vec3 reflectVec = vReflect; #endif #ifdef ENVMAP_TYPE_CUBE vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); #ifdef ENVMAP_BLENDING_MULTIPLY outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_MIX ) outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); #elif defined( ENVMAP_BLENDING_ADD ) outgoingLight += envColor.xyz * specularStrength * reflectivity; #endif #endif #endif`,X7=`#ifdef USE_ENVMAP uniform float envMapIntensity; uniform mat3 envMapRotation; #ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #else uniform sampler2D envMap; #endif #endif`,L7=`#ifdef USE_ENVMAP uniform float reflectivity; #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; uniform float refractionRatio; #else varying vec3 vReflect; #endif #endif`,W7=`#ifdef USE_ENVMAP #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) #define ENV_WORLDPOS #endif #ifdef ENV_WORLDPOS varying vec3 vWorldPosition; #else varying vec3 vReflect; uniform float refractionRatio; #endif #endif`,$7=`#ifdef USE_ENVMAP #ifdef ENV_WORLDPOS vWorldPosition = worldPosition.xyz; #else vec3 cameraToVertex; if ( isOrthographic ) { cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); } else { cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); } vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); #ifdef ENVMAP_MODE_REFLECTION vReflect = reflect( cameraToVertex, worldNormal ); #else vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); #endif #endif #endif`,O7=`#ifdef USE_FOG vFogDepth = - mvPosition.z; #endif`,V7=`#ifdef USE_FOG varying float vFogDepth; #endif`,k7=`#ifdef USE_FOG #ifdef FOG_EXP2 float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth ); #else float fogFactor = smoothstep( fogNear, fogFar, vFogDepth ); #endif gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); #endif`,w7=`#ifdef USE_FOG uniform vec3 fogColor; varying float vFogDepth; #ifdef FOG_EXP2 uniform float fogDensity; #else uniform float fogNear; uniform float fogFar; #endif #endif`,z7=`#ifdef USE_GRADIENTMAP uniform sampler2D gradientMap; #endif vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { float dotNL = dot( normal, lightDirection ); vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); #ifdef USE_GRADIENTMAP return vec3( texture2D( gradientMap, coord ).r ); #else vec2 fw = fwidth( coord ) * 0.5; return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) ); #endif }`,_7=`#ifdef USE_LIGHTMAP uniform sampler2D lightMap; uniform float lightMapIntensity; #endif`,P7=`LambertMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularStrength = specularStrength;`,T7=`varying vec3 vViewPosition; struct LambertMaterial { vec3 diffuseColor; float specularStrength; }; void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Lambert #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,S7=`uniform bool receiveShadow; uniform vec3 ambientLightColor; #if defined( USE_LIGHT_PROBES ) uniform vec3 lightProbe[ 9 ]; #endif vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { float x = normal.x, y = normal.y, z = normal.z; vec3 result = shCoefficients[ 0 ] * 0.886227; result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); return result; } vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); return irradiance; } vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { vec3 irradiance = ambientLightColor; return irradiance; } float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); if ( cutoffDistance > 0.0 ) { distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); } return distanceFalloff; } float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { return smoothstep( coneCosine, penumbraCosine, angleCosine ); } #if NUM_DIR_LIGHTS > 0 struct DirectionalLight { vec3 direction; vec3 color; }; uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { light.color = directionalLight.color; light.direction = directionalLight.direction; light.visible = true; } #endif #if NUM_POINT_LIGHTS > 0 struct PointLight { vec3 position; vec3 color; float distance; float decay; }; uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { vec3 lVector = pointLight.position - geometryPosition; light.direction = normalize( lVector ); float lightDistance = length( lVector ); light.color = pointLight.color; light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } #endif #if NUM_SPOT_LIGHTS > 0 struct SpotLight { vec3 position; vec3 direction; vec3 color; float distance; float decay; float coneCos; float penumbraCos; }; uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { vec3 lVector = spotLight.position - geometryPosition; light.direction = normalize( lVector ); float angleCos = dot( light.direction, spotLight.direction ); float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); if ( spotAttenuation > 0.0 ) { float lightDistance = length( lVector ); light.color = spotLight.color * spotAttenuation; light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); light.visible = ( light.color != vec3( 0.0 ) ); } else { light.color = vec3( 0.0 ); light.visible = false; } } #endif #if NUM_RECT_AREA_LIGHTS > 0 struct RectAreaLight { vec3 color; vec3 position; vec3 halfWidth; vec3 halfHeight; }; uniform sampler2D ltc_1; uniform sampler2D ltc_2; uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; #endif #if NUM_HEMI_LIGHTS > 0 struct HemisphereLight { vec3 direction; vec3 skyColor; vec3 groundColor; }; uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { float dotNL = dot( normal, hemiLight.direction ); float hemiDiffuseWeight = 0.5 * dotNL + 0.5; vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); return irradiance; } #endif #include `,j7=`#ifdef USE_ENVMAP vec3 getIBLIrradiance( const in vec3 normal ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); return PI * envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 reflectVec = reflect( - viewDir, normal ); reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); reflectVec = inverseTransformDirection( reflectVec, viewMatrix ); vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); return envMapColor.rgb * envMapIntensity; #else return vec3( 0.0 ); #endif } #ifdef USE_ANISOTROPY vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { #ifdef ENVMAP_TYPE_CUBE_UV vec3 bentNormal = cross( bitangent, viewDir ); bentNormal = normalize( cross( bentNormal, bitangent ) ); bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); return getIBLRadiance( viewDir, bentNormal, roughness ); #else return vec3( 0.0 ); #endif } #endif #endif`,f7=`ToonMaterial material; material.diffuseColor = diffuseColor.rgb;`,y7=`varying vec3 vViewPosition; struct ToonMaterial { vec3 diffuseColor; }; void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_Toon #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,g7=`BlinnPhongMaterial material; material.diffuseColor = diffuseColor.rgb; material.specularColor = specular; material.specularShininess = shininess; material.specularStrength = specularStrength;`,h7=`varying vec3 vViewPosition; struct BlinnPhongMaterial { vec3 diffuseColor; vec3 specularColor; float specularShininess; float specularStrength; }; void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; } void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); } #define RE_Direct RE_Direct_BlinnPhong #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,x7=`PhysicalMaterial material; material.diffuseColor = diffuseColor.rgb; material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); material.metalness = metalnessFactor; vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; material.roughness = min( material.roughness, 1.0 ); #ifdef IOR material.ior = ior; #ifdef USE_SPECULAR float specularIntensityFactor = specularIntensity; vec3 specularColorFactor = specularColor; #ifdef USE_SPECULAR_COLORMAP specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; #endif #ifdef USE_SPECULAR_INTENSITYMAP specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; #endif material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); #else float specularIntensityFactor = 1.0; vec3 specularColorFactor = vec3( 1.0 ); material.specularF90 = 1.0; #endif material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); #else material.specularColor = vec3( 0.04 ); material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); material.specularF90 = 1.0; #endif #ifdef USE_CLEARCOAT material.clearcoat = clearcoat; material.clearcoatRoughness = clearcoatRoughness; material.clearcoatF0 = vec3( 0.04 ); material.clearcoatF90 = 1.0; #ifdef USE_CLEARCOATMAP material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; #endif material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); material.clearcoatRoughness += geometryRoughness; material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); #endif #ifdef USE_DISPERSION material.dispersion = dispersion; #endif #ifdef USE_IRIDESCENCE material.iridescence = iridescence; material.iridescenceIOR = iridescenceIOR; #ifdef USE_IRIDESCENCEMAP material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; #else material.iridescenceThickness = iridescenceThicknessMaximum; #endif #endif #ifdef USE_SHEEN material.sheenColor = sheenColor; #ifdef USE_SHEEN_COLORMAP material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; #endif material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); #ifdef USE_SHEEN_ROUGHNESSMAP material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; #endif #endif #ifdef USE_ANISOTROPY #ifdef USE_ANISOTROPYMAP mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; #else vec2 anisotropyV = anisotropyVector; #endif material.anisotropy = length( anisotropyV ); if( material.anisotropy == 0.0 ) { anisotropyV = vec2( 1.0, 0.0 ); } else { anisotropyV /= material.anisotropy; material.anisotropy = saturate( material.anisotropy ); } material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) ); material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y; material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y; #endif`,v7=`uniform sampler2D dfgLUT; struct PhysicalMaterial { vec3 diffuseColor; vec3 diffuseContribution; vec3 specularColor; vec3 specularColorBlended; float roughness; float metalness; float specularF90; float dispersion; #ifdef USE_CLEARCOAT float clearcoat; float clearcoatRoughness; vec3 clearcoatF0; float clearcoatF90; #endif #ifdef USE_IRIDESCENCE float iridescence; float iridescenceIOR; float iridescenceThickness; vec3 iridescenceFresnel; vec3 iridescenceF0; vec3 iridescenceFresnelDielectric; vec3 iridescenceFresnelMetallic; #endif #ifdef USE_SHEEN vec3 sheenColor; float sheenRoughness; #endif #ifdef IOR float ior; #endif #ifdef USE_TRANSMISSION float transmission; float transmissionAlpha; float thickness; float attenuationDistance; vec3 attenuationColor; #endif #ifdef USE_ANISOTROPY float anisotropy; float alphaT; vec3 anisotropyT; vec3 anisotropyB; #endif }; vec3 clearcoatSpecularDirect = vec3( 0.0 ); vec3 clearcoatSpecularIndirect = vec3( 0.0 ); vec3 sheenSpecularDirect = vec3( 0.0 ); vec3 sheenSpecularIndirect = vec3(0.0 ); vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); float x2 = x * x; float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); } float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { float a2 = pow2( alpha ); float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); return 0.5 / max( gv + gl, EPSILON ); } float D_GGX( const in float alpha, const in float dotNH ) { float a2 = pow2( alpha ); float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; return RECIPROCAL_PI * a2 / pow2( denom ); } #ifdef USE_ANISOTROPY float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); return 0.5 / max( gv + gl, EPSILON ); } float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { float a2 = alphaT * alphaB; highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); highp float v2 = dot( v, v ); float w2 = a2 / v2; return RECIPROCAL_PI * a2 * pow2 ( w2 ); } #endif #ifdef USE_CLEARCOAT vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { vec3 f0 = material.clearcoatF0; float f90 = material.clearcoatF90; float roughness = material.clearcoatRoughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); return F * ( V * D ); } #endif vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { vec3 f0 = material.specularColorBlended; float f90 = material.specularF90; float roughness = material.roughness; float alpha = pow2( roughness ); vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float dotVH = saturate( dot( viewDir, halfDir ) ); vec3 F = F_Schlick( f0, f90, dotVH ); #ifdef USE_IRIDESCENCE F = mix( F, material.iridescenceFresnel, material.iridescence ); #endif #ifdef USE_ANISOTROPY float dotTL = dot( material.anisotropyT, lightDir ); float dotTV = dot( material.anisotropyT, viewDir ); float dotTH = dot( material.anisotropyT, halfDir ); float dotBL = dot( material.anisotropyB, lightDir ); float dotBV = dot( material.anisotropyB, viewDir ); float dotBH = dot( material.anisotropyB, halfDir ); float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); #else float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); float D = D_GGX( alpha, dotNH ); #endif return F * ( V * D ); } vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { const float LUT_SIZE = 64.0; const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; const float LUT_BIAS = 0.5 / LUT_SIZE; float dotNV = saturate( dot( N, V ) ); vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); uv = uv * LUT_SCALE + LUT_BIAS; return uv; } float LTC_ClippedSphereFormFactor( const in vec3 f ) { float l = length( f ); return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); } vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { float x = dot( v1, v2 ); float y = abs( x ); float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; float b = 3.4175940 + ( 4.1616724 + y ) * y; float v = a / b; float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; return cross( v1, v2 ) * theta_sintheta; } vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; vec3 lightNormal = cross( v1, v2 ); if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); vec3 T1, T2; T1 = normalize( V - N * dot( V, N ) ); T2 = - cross( N, T1 ); mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); vec3 coords[ 4 ]; coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); coords[ 0 ] = normalize( coords[ 0 ] ); coords[ 1 ] = normalize( coords[ 1 ] ); coords[ 2 ] = normalize( coords[ 2 ] ); coords[ 3 ] = normalize( coords[ 3 ] ); vec3 vectorFormFactor = vec3( 0.0 ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); return vec3( result ); } #if defined( USE_SHEEN ) float D_Charlie( float roughness, float dotNH ) { float alpha = pow2( roughness ); float invAlpha = 1.0 / alpha; float cos2h = dotNH * dotNH; float sin2h = max( 1.0 - cos2h, 0.0078125 ); return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); } float V_Neubelt( float dotNV, float dotNL ) { return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); } vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { vec3 halfDir = normalize( lightDir + viewDir ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); float dotNH = saturate( dot( normal, halfDir ) ); float D = D_Charlie( sheenRoughness, dotNH ); float V = V_Neubelt( dotNV, dotNL ); return sheenColor * ( D * V ); } #endif float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); float r2 = roughness * roughness; float rInv = 1.0 / ( roughness + 0.1 ); float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; float DG = exp( a * dotNV + b ); return saturate( DG ); } vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { float dotNV = saturate( dot( normal, viewDir ) ); vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; return specularColor * fab.x + specularF90 * fab.y; } #ifdef USE_IRIDESCENCE void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #else void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { #endif float dotNV = saturate( dot( normal, viewDir ) ); vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; #ifdef USE_IRIDESCENCE vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); #else vec3 Fr = specularColor; #endif vec3 FssEss = Fr * fab.x + specularF90 * fab.y; float Ess = fab.x + fab.y; float Ems = 1.0 - Ess; vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); singleScatter += FssEss; multiScatter += Fms * Ems; } vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); float dotNL = saturate( dot( normal, lightDir ) ); float dotNV = saturate( dot( normal, viewDir ) ); vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; float Ess_V = dfgV.x + dfgV.y; float Ess_L = dfgL.x + dfgL.y; float Ems_V = 1.0 - Ess_V; float Ems_L = 1.0 - Ess_L; vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); float compensationFactor = Ems_V * Ems_L; vec3 multiScatter = Fms * compensationFactor; return singleScatter + multiScatter; } #if NUM_RECT_AREA_LIGHTS > 0 void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 normal = geometryNormal; vec3 viewDir = geometryViewDir; vec3 position = geometryPosition; vec3 lightPos = rectAreaLight.position; vec3 halfWidth = rectAreaLight.halfWidth; vec3 halfHeight = rectAreaLight.halfHeight; vec3 lightColor = rectAreaLight.color; float roughness = material.roughness; vec3 rectCoords[ 4 ]; rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; vec2 uv = LTC_Uv( normal, viewDir, roughness ); vec4 t1 = texture2D( ltc_1, uv ); vec4 t2 = texture2D( ltc_2, uv ); mat3 mInv = mat3( vec3( t1.x, 0, t1.y ), vec3( 0, 1, 0 ), vec3( t1.z, 0, t1.w ) ); vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); #ifdef USE_CLEARCOAT vec3 Ncc = geometryClearcoatNormal; vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); mat3 mInvClearcoat = mat3( vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), vec3( 0, 1, 0 ), vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) ); vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); #endif } #endif void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); vec3 irradiance = dotNL * directLight.color; #ifdef USE_CLEARCOAT float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); vec3 ccIrradiance = dotNLcc * directLight.color; clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); #endif #ifdef USE_SHEEN sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); irradiance *= sheenEnergyComp; #endif reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); } void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); #ifdef USE_SHEEN float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; diffuse *= sheenEnergyComp; #endif reflectedLight.indirectDiffuse += diffuse; } void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { #ifdef USE_CLEARCOAT clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); #endif #ifdef USE_SHEEN sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; #endif vec3 singleScatteringDielectric = vec3( 0.0 ); vec3 multiScatteringDielectric = vec3( 0.0 ); vec3 singleScatteringMetallic = vec3( 0.0 ); vec3 multiScatteringMetallic = vec3( 0.0 ); #ifdef USE_IRIDESCENCE computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); #else computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); #endif vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; vec3 indirectSpecular = radiance * singleScattering; indirectSpecular += multiScattering * cosineWeightedIrradiance; vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; #ifdef USE_SHEEN float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; indirectSpecular *= sheenEnergyComp; indirectDiffuse *= sheenEnergyComp; #endif reflectedLight.indirectSpecular += indirectSpecular; reflectedLight.indirectDiffuse += indirectDiffuse; } #define RE_Direct RE_Direct_Physical #define RE_Direct_RectArea RE_Direct_RectArea_Physical #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical #define RE_IndirectSpecular RE_IndirectSpecular_Physical float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); }`,b7=` vec3 geometryPosition = - vViewPosition; vec3 geometryNormal = normal; vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); vec3 geometryClearcoatNormal = vec3( 0.0 ); #ifdef USE_CLEARCOAT geometryClearcoatNormal = clearcoatNormal; #endif #ifdef USE_IRIDESCENCE float dotNVi = saturate( dot( normal, geometryViewDir ) ); if ( material.iridescenceThickness == 0.0 ) { material.iridescence = 0.0; } else { material.iridescence = saturate( material.iridescence ); } if ( material.iridescence > 0.0 ) { material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); } #endif IncidentLight directLight; #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) PointLight pointLight; #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 PointLightShadow pointLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { pointLight = pointLights[ i ]; getPointLightInfo( pointLight, geometryPosition, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) pointLightShadow = pointLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) SpotLight spotLight; vec4 spotColor; vec3 spotLightCoord; bool inSpotLightMap; #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { spotLight = spotLights[ i ]; getSpotLightInfo( spotLight, geometryPosition, directLight ); #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS #else #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) #endif #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; #endif #undef SPOT_LIGHT_MAP_INDEX #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) spotLightShadow = spotLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) DirectionalLight directionalLight; #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLightShadow; #endif #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { directionalLight = directionalLights[ i ]; getDirectionalLightInfo( directionalLight, directLight ); #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) directionalLightShadow = directionalLightShadows[ i ]; directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; #endif RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) RectAreaLight rectAreaLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { rectAreaLight = rectAreaLights[ i ]; RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); } #pragma unroll_loop_end #endif #if defined( RE_IndirectDiffuse ) vec3 iblIrradiance = vec3( 0.0 ); vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); #if defined( USE_LIGHT_PROBES ) irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); #endif #if ( NUM_HEMI_LIGHTS > 0 ) #pragma unroll_loop_start for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); } #pragma unroll_loop_end #endif #ifdef USE_LIGHT_PROBES_GRID vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; vec3 probeWorldNormal = inverseTransformDirection( geometryNormal, viewMatrix ); irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); #endif #endif #if defined( RE_IndirectSpecular ) vec3 radiance = vec3( 0.0 ); vec3 clearcoatRadiance = vec3( 0.0 ); #endif`,p7=`#if defined( RE_IndirectDiffuse ) #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; irradiance += lightMapIrradiance; #endif #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) iblIrradiance += getIBLIrradiance( geometryNormal ); #endif #endif #endif #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) #ifdef USE_ANISOTROPY radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); #else radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); #endif #ifdef USE_CLEARCOAT clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); #endif #endif`,u7=`#if defined( RE_IndirectDiffuse ) #if defined( LAMBERT ) || defined( PHONG ) irradiance += iblIrradiance; #endif RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif #if defined( RE_IndirectSpecular ) RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); #endif`,m7=`#ifdef USE_LIGHT_PROBES_GRID uniform highp sampler3D probesSH; uniform vec3 probesMin; uniform vec3 probesMax; uniform vec3 probesResolution; vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { vec3 res = probesResolution; vec3 gridRange = probesMax - probesMin; vec3 resMinusOne = res - 1.0; vec3 probeSpacing = gridRange / resMinusOne; vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); uvw = uvw * resMinusOne / res + 0.5 / res; float nz = res.z; float paddedSlices = nz + 2.0; float atlasDepth = 7.0 * paddedSlices; float uvZBase = uvw.z * nz + 1.0; vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); vec3 c0 = s0.xyz; vec3 c1 = vec3( s0.w, s1.xy ); vec3 c2 = vec3( s1.zw, s2.x ); vec3 c3 = s2.yzw; vec3 c4 = s3.xyz; vec3 c5 = vec3( s3.w, s4.xy ); vec3 c6 = vec3( s4.zw, s5.x ); vec3 c7 = s5.yzw; vec3 c8 = s6.xyz; float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; vec3 result = c0 * 0.886227; result += c1 * 2.0 * 0.511664 * y; result += c2 * 2.0 * 0.511664 * z; result += c3 * 2.0 * 0.511664 * x; result += c4 * 2.0 * 0.429043 * x * y; result += c5 * 2.0 * 0.429043 * y * z; result += c6 * ( 0.743125 * z * z - 0.247708 ); result += c7 * 2.0 * 0.429043 * x * z; result += c8 * 0.429043 * ( x * x - y * y ); return max( result, vec3( 0.0 ) ); } #endif`,l7=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; #endif`,c7=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) uniform float logDepthBufFC; varying float vFragDepth; varying float vIsPerspective; #endif`,d7=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER varying float vFragDepth; varying float vIsPerspective; #endif`,n7=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER vFragDepth = 1.0 + gl_Position.w; vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); #endif`,s7=`#ifdef USE_MAP vec4 sampledDiffuseColor = texture2D( map, vMapUv ); #ifdef DECODE_VIDEO_TEXTURE sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); #endif diffuseColor *= sampledDiffuseColor; #endif`,i7=`#ifdef USE_MAP uniform sampler2D map; #endif`,o7=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) #if defined( USE_POINTS_UV ) vec2 uv = vUv; #else vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; #endif #endif #ifdef USE_MAP diffuseColor *= texture2D( map, uv ); #endif #ifdef USE_ALPHAMAP diffuseColor.a *= texture2D( alphaMap, uv ).g; #endif`,a7=`#if defined( USE_POINTS_UV ) varying vec2 vUv; #else #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) uniform mat3 uvTransform; #endif #endif #ifdef USE_MAP uniform sampler2D map; #endif #ifdef USE_ALPHAMAP uniform sampler2D alphaMap; #endif`,r7=`float metalnessFactor = metalness; #ifdef USE_METALNESSMAP vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); metalnessFactor *= texelMetalness.b; #endif`,t7=`#ifdef USE_METALNESSMAP uniform sampler2D metalnessMap; #endif`,e7=`#ifdef USE_INSTANCING_MORPH float morphTargetInfluences[ MORPHTARGETS_COUNT ]; float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r; } #endif`,AM=`#if defined( USE_MORPHCOLORS ) vColor *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { #if defined( USE_COLOR_ALPHA ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; #elif defined( USE_COLOR ) if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; #endif } #endif`,QM=`#ifdef USE_MORPHNORMALS objectNormal *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ]; } #endif`,BM=`#ifdef USE_MORPHTARGETS #ifndef USE_INSTANCING_MORPH uniform float morphTargetBaseInfluence; uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; #endif uniform sampler2DArray morphTargetsTexture; uniform ivec2 morphTargetsTextureSize; vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; int y = texelIndex / morphTargetsTextureSize.x; int x = texelIndex - y * morphTargetsTextureSize.x; ivec3 morphUV = ivec3( x, y, morphTargetIndex ); return texelFetch( morphTargetsTexture, morphUV, 0 ); } #endif`,EM=`#ifdef USE_MORPHTARGETS transformed *= morphTargetBaseInfluence; for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ]; } #endif`,IM=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; #ifdef FLAT_SHADED vec3 fdx = dFdx( vViewPosition ); vec3 fdy = dFdy( vViewPosition ); vec3 normal = normalize( cross( fdx, fdy ) ); #else vec3 normal = normalize( vNormal ); #ifdef DOUBLE_SIDED normal *= faceDirection; #endif #endif #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) #ifdef USE_TANGENT mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); #else mat3 tbn = getTangentFrame( - vViewPosition, normal, #if defined( USE_NORMALMAP ) vNormalMapUv #elif defined( USE_CLEARCOAT_NORMALMAP ) vClearcoatNormalMapUv #else vUv #endif ); #endif #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) tbn[0] *= faceDirection; tbn[1] *= faceDirection; #endif #endif #ifdef USE_CLEARCOAT_NORMALMAP #ifdef USE_TANGENT mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); #else mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); #endif #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED ) tbn2[0] *= faceDirection; tbn2[1] *= faceDirection; #endif #endif vec3 nonPerturbedNormal = normal;`,CM=`#ifdef USE_NORMALMAP_OBJECTSPACE normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #ifdef FLIP_SIDED normal = - normal; #endif #ifdef DOUBLE_SIDED normal = normal * faceDirection; #endif normal = normalize( normalMatrix * normal ); #elif defined( USE_NORMALMAP_TANGENTSPACE ) vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; #if defined( USE_PACKED_NORMALMAP ) mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); #endif mapN.xy *= normalScale; normal = normalize( tbn * mapN ); #elif defined( USE_BUMPMAP ) normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); #endif`,GM=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,KM=`#ifndef FLAT_SHADED varying vec3 vNormal; #ifdef USE_TANGENT varying vec3 vTangent; varying vec3 vBitangent; #endif #endif`,JM=`#ifndef FLAT_SHADED vNormal = normalize( transformedNormal ); #ifdef USE_TANGENT vTangent = normalize( transformedTangent ); vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); #endif #endif`,UM=`#ifdef USE_NORMALMAP uniform sampler2D normalMap; uniform vec2 normalScale; #endif #ifdef USE_NORMALMAP_OBJECTSPACE uniform mat3 normalMatrix; #endif #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { vec3 q0 = dFdx( eye_pos.xyz ); vec3 q1 = dFdy( eye_pos.xyz ); vec2 st0 = dFdx( uv.st ); vec2 st1 = dFdy( uv.st ); vec3 N = surf_norm; vec3 q1perp = cross( q1, N ); vec3 q0perp = cross( N, q0 ); vec3 T = q1perp * st0.x + q0perp * st1.x; vec3 B = q1perp * st0.y + q0perp * st1.y; float det = max( dot( T, T ), dot( B, B ) ); float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); return mat3( T * scale, B * scale, N ); } #endif`,FM=`#ifdef USE_CLEARCOAT vec3 clearcoatNormal = nonPerturbedNormal; #endif`,RM=`#ifdef USE_CLEARCOAT_NORMALMAP vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; clearcoatMapN.xy *= clearcoatNormalScale; clearcoatNormal = normalize( tbn2 * clearcoatMapN ); #endif`,DM=`#ifdef USE_CLEARCOATMAP uniform sampler2D clearcoatMap; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform sampler2D clearcoatNormalMap; uniform vec2 clearcoatNormalScale; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform sampler2D clearcoatRoughnessMap; #endif`,HM=`#ifdef USE_IRIDESCENCEMAP uniform sampler2D iridescenceMap; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform sampler2D iridescenceThicknessMap; #endif`,YM=`#ifdef OPAQUE diffuseColor.a = 1.0; #endif #ifdef USE_TRANSMISSION diffuseColor.a *= material.transmissionAlpha; #endif gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,qM=`vec3 packNormalToRGB( const in vec3 normal ) { return normalize( normal ) * 0.5 + 0.5; } vec3 unpackRGBToNormal( const in vec3 rgb ) { return 2.0 * rgb.xyz - 1.0; } const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; const float Inv255 = 1. / 255.; const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); vec4 packDepthToRGBA( const in float v ) { if( v <= 0.0 ) return vec4( 0., 0., 0., 0. ); if( v >= 1.0 ) return vec4( 1., 1., 1., 1. ); float vuf; float af = modf( v * PackFactors.a, vuf ); float bf = modf( vuf * ShiftRight8, vuf ); float gf = modf( vuf * ShiftRight8, vuf ); return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); } vec3 packDepthToRGB( const in float v ) { if( v <= 0.0 ) return vec3( 0., 0., 0. ); if( v >= 1.0 ) return vec3( 1., 1., 1. ); float vuf; float bf = modf( v * PackFactors.b, vuf ); float gf = modf( vuf * ShiftRight8, vuf ); return vec3( vuf * Inv255, gf * PackUpscale, bf ); } vec2 packDepthToRG( const in float v ) { if( v <= 0.0 ) return vec2( 0., 0. ); if( v >= 1.0 ) return vec2( 1., 1. ); float vuf; float gf = modf( v * 256., vuf ); return vec2( vuf * Inv255, gf ); } float unpackRGBAToDepth( const in vec4 v ) { return dot( v, UnpackFactors4 ); } float unpackRGBToDepth( const in vec3 v ) { return dot( v, UnpackFactors3 ); } float unpackRGToDepth( const in vec2 v ) { return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; } vec4 pack2HalfToRGBA( const in vec2 v ) { vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); } vec2 unpackRGBATo2Half( const in vec4 v ) { return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); } float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { return ( viewZ + near ) / ( near - far ); } float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { #ifdef USE_REVERSED_DEPTH_BUFFER return depth * ( far - near ) - far; #else return depth * ( near - far ) - near; #endif } float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); } float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { #ifdef USE_REVERSED_DEPTH_BUFFER return ( near * far ) / ( ( near - far ) * depth - near ); #else return ( near * far ) / ( ( far - near ) * depth - far ); #endif }`,MM=`#ifdef PREMULTIPLIED_ALPHA gl_FragColor.rgb *= gl_FragColor.a; #endif`,NM=`vec4 mvPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING mvPosition = batchingMatrix * mvPosition; #endif #ifdef USE_INSTANCING mvPosition = instanceMatrix * mvPosition; #endif mvPosition = modelViewMatrix * mvPosition; gl_Position = projectionMatrix * mvPosition;`,ZM=`#ifdef DITHERING gl_FragColor.rgb = dithering( gl_FragColor.rgb ); #endif`,XM=`#ifdef DITHERING vec3 dithering( vec3 color ) { float grid_position = rand( gl_FragCoord.xy ); vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); return color + dither_shift_RGB; } #endif`,LM=`float roughnessFactor = roughness; #ifdef USE_ROUGHNESSMAP vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); roughnessFactor *= texelRoughness.g; #endif`,WM=`#ifdef USE_ROUGHNESSMAP uniform sampler2D roughnessMap; #endif`,$M=`#if NUM_SPOT_LIGHT_COORDS > 0 varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #if NUM_SPOT_LIGHT_MAPS > 0 uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 #if defined( SHADOWMAP_TYPE_PCF ) uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; #else uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; #endif varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 #if defined( SHADOWMAP_TYPE_PCF ) uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; #else uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; #endif struct SpotLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #if defined( SHADOWMAP_TYPE_PCF ) uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; #elif defined( SHADOWMAP_TYPE_BASIC ) uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; #endif varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #if defined( SHADOWMAP_TYPE_PCF ) float interleavedGradientNoise( vec2 position ) { return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); } vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { const float goldenAngle = 2.399963229728653; float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); float theta = float( sampleIndex ) * goldenAngle + phi; return vec2( cos( theta ), sin( theta ) ) * r; } #endif #if defined( SHADOWMAP_TYPE_PCF ) float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; shadowCoord.z += shadowBias; bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { vec2 texelSize = vec2( 1.0 ) / shadowMapSize; float radius = shadowRadius * texelSize.x; float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; shadow = ( texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) ) * 0.2; } return mix( 1.0, shadow, shadowIntensity ); } #elif defined( SHADOWMAP_TYPE_VSM ) float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; #ifdef USE_REVERSED_DEPTH_BUFFER shadowCoord.z -= shadowBias; #else shadowCoord.z += shadowBias; #endif bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; float mean = distribution.x; float variance = distribution.y * distribution.y; #ifdef USE_REVERSED_DEPTH_BUFFER float hard_shadow = step( mean, shadowCoord.z ); #else float hard_shadow = step( shadowCoord.z, mean ); #endif if ( hard_shadow == 1.0 ) { shadow = 1.0; } else { variance = max( variance, 0.0000001 ); float d = shadowCoord.z - mean; float p_max = variance / ( variance + d * d ); p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); shadow = max( hard_shadow, p_max ); } } return mix( 1.0, shadow, shadowIntensity ); } #else float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { float shadow = 1.0; shadowCoord.xyz /= shadowCoord.w; #ifdef USE_REVERSED_DEPTH_BUFFER shadowCoord.z -= shadowBias; #else shadowCoord.z += shadowBias; #endif bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; bool frustumTest = inFrustum && shadowCoord.z <= 1.0; if ( frustumTest ) { float depth = texture2D( shadowMap, shadowCoord.xy ).r; #ifdef USE_REVERSED_DEPTH_BUFFER shadow = step( depth, shadowCoord.z ); #else shadow = step( shadowCoord.z, depth ); #endif } return mix( 1.0, shadow, shadowIntensity ); } #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #if defined( SHADOWMAP_TYPE_PCF ) float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec3 lightToPosition = shadowCoord.xyz; vec3 bd3D = normalize( lightToPosition ); vec3 absVec = abs( lightToPosition ); float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { #ifdef USE_REVERSED_DEPTH_BUFFER float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); dp -= shadowBias; #else float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); dp += shadowBias; #endif float texelSize = shadowRadius / shadowMapSize.x; vec3 absDir = abs( bd3D ); vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); tangent = normalize( cross( bd3D, tangent ) ); vec3 bitangent = cross( bd3D, tangent ); float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; vec2 sample0 = vogelDiskSample( 0, 5, phi ); vec2 sample1 = vogelDiskSample( 1, 5, phi ); vec2 sample2 = vogelDiskSample( 2, 5, phi ); vec2 sample3 = vogelDiskSample( 3, 5, phi ); vec2 sample4 = vogelDiskSample( 4, 5, phi ); shadow = ( texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) ) * 0.2; } return mix( 1.0, shadow, shadowIntensity ); } #elif defined( SHADOWMAP_TYPE_BASIC ) float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { float shadow = 1.0; vec3 lightToPosition = shadowCoord.xyz; vec3 absVec = abs( lightToPosition ); float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); dp += shadowBias; vec3 bd3D = normalize( lightToPosition ); float depth = textureCube( shadowMap, bd3D ).r; #ifdef USE_REVERSED_DEPTH_BUFFER depth = 1.0 - depth; #endif shadow = step( dp, depth ); } return mix( 1.0, shadow, shadowIntensity ); } #endif #endif #endif`,OM=`#if NUM_SPOT_LIGHT_COORDS > 0 uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; #endif #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; struct DirectionalLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 struct SpotLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; }; uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; #endif #if NUM_POINT_LIGHT_SHADOWS > 0 uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; struct PointLightShadow { float shadowIntensity; float shadowBias; float shadowNormalBias; float shadowRadius; vec2 shadowMapSize; float shadowCameraNear; float shadowCameraFar; }; uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; #endif #endif`,VM=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) #ifdef HAS_NORMAL vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); #else vec3 shadowWorldNormal = vec3( 0.0 ); #endif vec4 shadowWorldPosition; #endif #if defined( USE_SHADOWMAP ) #if NUM_DIR_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif #endif #if NUM_SPOT_LIGHT_COORDS > 0 #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { shadowWorldPosition = worldPosition; #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; #endif vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; } #pragma unroll_loop_end #endif`,kM=`float getShadowMask() { float shadow = 1.0; #ifdef USE_SHADOWMAP #if NUM_DIR_LIGHT_SHADOWS > 0 DirectionalLightShadow directionalLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { directionalLight = directionalLightShadows[ i ]; shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_SPOT_LIGHT_SHADOWS > 0 SpotLightShadow spotLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { spotLight = spotLightShadows[ i ]; shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; } #pragma unroll_loop_end #endif #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) PointLightShadow pointLight; #pragma unroll_loop_start for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { pointLight = pointLightShadows[ i ]; shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; } #pragma unroll_loop_end #endif #endif return shadow; }`,wM=`#ifdef USE_SKINNING mat4 boneMatX = getBoneMatrix( skinIndex.x ); mat4 boneMatY = getBoneMatrix( skinIndex.y ); mat4 boneMatZ = getBoneMatrix( skinIndex.z ); mat4 boneMatW = getBoneMatrix( skinIndex.w ); #endif`,zM=`#ifdef USE_SKINNING uniform mat4 bindMatrix; uniform mat4 bindMatrixInverse; uniform highp sampler2D boneTexture; mat4 getBoneMatrix( const in float i ) { int size = textureSize( boneTexture, 0 ).x; int j = int( i ) * 4; int x = j % size; int y = j / size; vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); return mat4( v1, v2, v3, v4 ); } #endif`,_M=`#ifdef USE_SKINNING vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); vec4 skinned = vec4( 0.0 ); skinned += boneMatX * skinVertex * skinWeight.x; skinned += boneMatY * skinVertex * skinWeight.y; skinned += boneMatZ * skinVertex * skinWeight.z; skinned += boneMatW * skinVertex * skinWeight.w; transformed = ( bindMatrixInverse * skinned ).xyz; #endif`,PM=`#ifdef USE_SKINNING mat4 skinMatrix = mat4( 0.0 ); skinMatrix += skinWeight.x * boneMatX; skinMatrix += skinWeight.y * boneMatY; skinMatrix += skinWeight.z * boneMatZ; skinMatrix += skinWeight.w * boneMatW; skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; #ifdef USE_TANGENT objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; #endif #endif`,TM=`float specularStrength; #ifdef USE_SPECULARMAP vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); specularStrength = texelSpecular.r; #else specularStrength = 1.0; #endif`,SM=`#ifdef USE_SPECULARMAP uniform sampler2D specularMap; #endif`,jM=`#if defined( TONE_MAPPING ) gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); #endif`,fM=`#ifndef saturate #define saturate( a ) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; vec3 LinearToneMapping( vec3 color ) { return saturate( toneMappingExposure * color ); } vec3 ReinhardToneMapping( vec3 color ) { color *= toneMappingExposure; return saturate( color / ( vec3( 1.0 ) + color ) ); } vec3 CineonToneMapping( vec3 color ) { color *= toneMappingExposure; color = max( vec3( 0.0 ), color - 0.004 ); return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); } vec3 RRTAndODTFit( vec3 v ) { vec3 a = v * ( v + 0.0245786 ) - 0.000090537; vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; return a / b; } vec3 ACESFilmicToneMapping( vec3 color ) { const mat3 ACESInputMat = mat3( vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), vec3( 0.04823, 0.01566, 0.83777 ) ); const mat3 ACESOutputMat = mat3( vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), vec3( -0.07367, -0.00605, 1.07602 ) ); color *= toneMappingExposure / 0.6; color = ACESInputMat * color; color = RRTAndODTFit( color ); color = ACESOutputMat * color; return saturate( color ); } const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( vec3( 1.6605, - 0.1246, - 0.0182 ), vec3( - 0.5876, 1.1329, - 0.1006 ), vec3( - 0.0728, - 0.0083, 1.1187 ) ); const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( vec3( 0.6274, 0.0691, 0.0164 ), vec3( 0.3293, 0.9195, 0.0880 ), vec3( 0.0433, 0.0113, 0.8956 ) ); vec3 agxDefaultContrastApprox( vec3 x ) { vec3 x2 = x * x; vec3 x4 = x2 * x2; return + 15.5 * x4 * x2 - 40.14 * x4 * x + 31.96 * x4 - 6.868 * x2 * x + 0.4298 * x2 + 0.1191 * x - 0.00232; } vec3 AgXToneMapping( vec3 color ) { const mat3 AgXInsetMatrix = mat3( vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) ); const mat3 AgXOutsetMatrix = mat3( vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) ); const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; color *= toneMappingExposure; color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; color = AgXInsetMatrix * color; color = max( color, 1e-10 ); color = log2( color ); color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); color = clamp( color, 0.0, 1.0 ); color = agxDefaultContrastApprox( color ); color = AgXOutsetMatrix * color; color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); color = LINEAR_REC2020_TO_LINEAR_SRGB * color; color = clamp( color, 0.0, 1.0 ); return color; } vec3 NeutralToneMapping( vec3 color ) { const float StartCompression = 0.8 - 0.04; const float Desaturation = 0.15; color *= toneMappingExposure; float x = min( color.r, min( color.g, color.b ) ); float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; color -= offset; float peak = max( color.r, max( color.g, color.b ) ); if ( peak < StartCompression ) return color; float d = 1. - StartCompression; float newPeak = 1. - d * d / ( peak + d - StartCompression ); color *= newPeak / peak; float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); return mix( color, vec3( newPeak ), g ); } vec3 CustomToneMapping( vec3 color ) { return color; }`,yM=`#ifdef USE_TRANSMISSION material.transmission = transmission; material.transmissionAlpha = 1.0; material.thickness = thickness; material.attenuationDistance = attenuationDistance; material.attenuationColor = attenuationColor; #ifdef USE_TRANSMISSIONMAP material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; #endif #ifdef USE_THICKNESSMAP material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; #endif vec3 pos = vWorldPosition; vec3 v = normalize( cameraPosition - pos ); vec3 n = inverseTransformDirection( normal, viewMatrix ); vec4 transmitted = getIBLVolumeRefraction( n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, material.attenuationColor, material.attenuationDistance ); material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); #endif`,gM=`#ifdef USE_TRANSMISSION uniform float transmission; uniform float thickness; uniform float attenuationDistance; uniform vec3 attenuationColor; #ifdef USE_TRANSMISSIONMAP uniform sampler2D transmissionMap; #endif #ifdef USE_THICKNESSMAP uniform sampler2D thicknessMap; #endif uniform vec2 transmissionSamplerSize; uniform sampler2D transmissionSamplerMap; uniform mat4 modelMatrix; uniform mat4 projectionMatrix; varying vec3 vWorldPosition; float w0( float a ) { return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); } float w1( float a ) { return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); } float w2( float a ){ return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); } float w3( float a ) { return ( 1.0 / 6.0 ) * ( a * a * a ); } float g0( float a ) { return w0( a ) + w1( a ); } float g1( float a ) { return w2( a ) + w3( a ); } float h0( float a ) { return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); } float h1( float a ) { return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); } vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { uv = uv * texelSize.zw + 0.5; vec2 iuv = floor( uv ); vec2 fuv = fract( uv ); float g0x = g0( fuv.x ); float g1x = g1( fuv.x ); float h0x = h0( fuv.x ); float h1x = h1( fuv.x ); float h0y = h0( fuv.y ); float h1y = h1( fuv.y ); vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); } vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); vec2 fLodSizeInv = 1.0 / fLodSize; vec2 cLodSizeInv = 1.0 / cLodSize; vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); return mix( fSample, cSample, fract( lod ) ); } vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); vec3 modelScale; modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); return normalize( refractionVector ) * thickness * modelScale; } float applyIorToRoughness( const in float roughness, const in float ior ) { return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); } vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); } vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { if ( isinf( attenuationDistance ) ) { return vec3( 1.0 ); } else { vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; } } vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, const in vec3 attenuationColor, const in float attenuationDistance ) { vec4 transmittedLight; vec3 transmittance; #ifdef USE_DISPERSION float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); for ( int i = 0; i < 3; i ++ ) { vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); transmittedLight[ i ] = transmissionSample[ i ]; transmittedLight.a += transmissionSample.a; transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; } transmittedLight.a /= 3.0; #else vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); vec3 refractedRayExit = position + transmissionRay; vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); vec2 refractionCoords = ndcPos.xy / ndcPos.w; refractionCoords += 1.0; refractionCoords /= 2.0; transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); #endif vec3 attenuatedColor = transmittance * transmittedLight.rgb; vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); } #endif`,hM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP varying vec2 vMapUv; #endif #ifdef USE_ALPHAMAP varying vec2 vAlphaMapUv; #endif #ifdef USE_LIGHTMAP varying vec2 vLightMapUv; #endif #ifdef USE_AOMAP varying vec2 vAoMapUv; #endif #ifdef USE_BUMPMAP varying vec2 vBumpMapUv; #endif #ifdef USE_NORMALMAP varying vec2 vNormalMapUv; #endif #ifdef USE_EMISSIVEMAP varying vec2 vEmissiveMapUv; #endif #ifdef USE_METALNESSMAP varying vec2 vMetalnessMapUv; #endif #ifdef USE_ROUGHNESSMAP varying vec2 vRoughnessMapUv; #endif #ifdef USE_ANISOTROPYMAP varying vec2 vAnisotropyMapUv; #endif #ifdef USE_CLEARCOATMAP varying vec2 vClearcoatMapUv; #endif #ifdef USE_CLEARCOAT_NORMALMAP varying vec2 vClearcoatNormalMapUv; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP varying vec2 vClearcoatRoughnessMapUv; #endif #ifdef USE_IRIDESCENCEMAP varying vec2 vIridescenceMapUv; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP varying vec2 vIridescenceThicknessMapUv; #endif #ifdef USE_SHEEN_COLORMAP varying vec2 vSheenColorMapUv; #endif #ifdef USE_SHEEN_ROUGHNESSMAP varying vec2 vSheenRoughnessMapUv; #endif #ifdef USE_SPECULARMAP varying vec2 vSpecularMapUv; #endif #ifdef USE_SPECULAR_COLORMAP varying vec2 vSpecularColorMapUv; #endif #ifdef USE_SPECULAR_INTENSITYMAP varying vec2 vSpecularIntensityMapUv; #endif #ifdef USE_TRANSMISSIONMAP uniform mat3 transmissionMapTransform; varying vec2 vTransmissionMapUv; #endif #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; #endif`,xM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) varying vec2 vUv; #endif #ifdef USE_MAP uniform mat3 mapTransform; varying vec2 vMapUv; #endif #ifdef USE_ALPHAMAP uniform mat3 alphaMapTransform; varying vec2 vAlphaMapUv; #endif #ifdef USE_LIGHTMAP uniform mat3 lightMapTransform; varying vec2 vLightMapUv; #endif #ifdef USE_AOMAP uniform mat3 aoMapTransform; varying vec2 vAoMapUv; #endif #ifdef USE_BUMPMAP uniform mat3 bumpMapTransform; varying vec2 vBumpMapUv; #endif #ifdef USE_NORMALMAP uniform mat3 normalMapTransform; varying vec2 vNormalMapUv; #endif #ifdef USE_DISPLACEMENTMAP uniform mat3 displacementMapTransform; varying vec2 vDisplacementMapUv; #endif #ifdef USE_EMISSIVEMAP uniform mat3 emissiveMapTransform; varying vec2 vEmissiveMapUv; #endif #ifdef USE_METALNESSMAP uniform mat3 metalnessMapTransform; varying vec2 vMetalnessMapUv; #endif #ifdef USE_ROUGHNESSMAP uniform mat3 roughnessMapTransform; varying vec2 vRoughnessMapUv; #endif #ifdef USE_ANISOTROPYMAP uniform mat3 anisotropyMapTransform; varying vec2 vAnisotropyMapUv; #endif #ifdef USE_CLEARCOATMAP uniform mat3 clearcoatMapTransform; varying vec2 vClearcoatMapUv; #endif #ifdef USE_CLEARCOAT_NORMALMAP uniform mat3 clearcoatNormalMapTransform; varying vec2 vClearcoatNormalMapUv; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP uniform mat3 clearcoatRoughnessMapTransform; varying vec2 vClearcoatRoughnessMapUv; #endif #ifdef USE_SHEEN_COLORMAP uniform mat3 sheenColorMapTransform; varying vec2 vSheenColorMapUv; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform mat3 sheenRoughnessMapTransform; varying vec2 vSheenRoughnessMapUv; #endif #ifdef USE_IRIDESCENCEMAP uniform mat3 iridescenceMapTransform; varying vec2 vIridescenceMapUv; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP uniform mat3 iridescenceThicknessMapTransform; varying vec2 vIridescenceThicknessMapUv; #endif #ifdef USE_SPECULARMAP uniform mat3 specularMapTransform; varying vec2 vSpecularMapUv; #endif #ifdef USE_SPECULAR_COLORMAP uniform mat3 specularColorMapTransform; varying vec2 vSpecularColorMapUv; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform mat3 specularIntensityMapTransform; varying vec2 vSpecularIntensityMapUv; #endif #ifdef USE_TRANSMISSIONMAP uniform mat3 transmissionMapTransform; varying vec2 vTransmissionMapUv; #endif #ifdef USE_THICKNESSMAP uniform mat3 thicknessMapTransform; varying vec2 vThicknessMapUv; #endif`,vM=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) vUv = vec3( uv, 1 ).xy; #endif #ifdef USE_MAP vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; #endif #ifdef USE_ALPHAMAP vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; #endif #ifdef USE_LIGHTMAP vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; #endif #ifdef USE_AOMAP vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; #endif #ifdef USE_BUMPMAP vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; #endif #ifdef USE_NORMALMAP vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; #endif #ifdef USE_DISPLACEMENTMAP vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; #endif #ifdef USE_EMISSIVEMAP vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; #endif #ifdef USE_METALNESSMAP vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_ROUGHNESSMAP vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_ANISOTROPYMAP vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOATMAP vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOAT_NORMALMAP vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; #endif #ifdef USE_CLEARCOAT_ROUGHNESSMAP vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_IRIDESCENCEMAP vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; #endif #ifdef USE_IRIDESCENCE_THICKNESSMAP vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_SHEEN_COLORMAP vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; #endif #ifdef USE_SHEEN_ROUGHNESSMAP vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULARMAP vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULAR_COLORMAP vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; #endif #ifdef USE_SPECULAR_INTENSITYMAP vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; #endif #ifdef USE_TRANSMISSIONMAP vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; #endif #ifdef USE_THICKNESSMAP vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; #endif`,bM=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0 vec4 worldPosition = vec4( transformed, 1.0 ); #ifdef USE_BATCHING worldPosition = batchingMatrix * worldPosition; #endif #ifdef USE_INSTANCING worldPosition = instanceMatrix * worldPosition; #endif worldPosition = modelMatrix * worldPosition; #endif`,pM=`varying vec2 vUv; uniform mat3 uvTransform; void main() { vUv = ( uvTransform * vec3( uv, 1 ) ).xy; gl_Position = vec4( position.xy, 1.0, 1.0 ); }`,uM=`uniform sampler2D t2D; uniform float backgroundIntensity; varying vec2 vUv; void main() { vec4 texColor = texture2D( t2D, vUv ); #ifdef DECODE_VIDEO_TEXTURE texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,mM=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,lM=`#ifdef ENVMAP_TYPE_CUBE uniform samplerCube envMap; #elif defined( ENVMAP_TYPE_CUBE_UV ) uniform sampler2D envMap; #endif uniform float backgroundBlurriness; uniform float backgroundIntensity; uniform mat3 backgroundRotation; varying vec3 vWorldDirection; #include void main() { #ifdef ENVMAP_TYPE_CUBE vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); #elif defined( ENVMAP_TYPE_CUBE_UV ) vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); #else vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); #endif texColor.rgb *= backgroundIntensity; gl_FragColor = texColor; #include #include }`,cM=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include gl_Position.z = gl_Position.w; }`,dM=`uniform samplerCube tCube; uniform float tFlip; uniform float opacity; varying vec3 vWorldDirection; void main() { vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); gl_FragColor = texColor; gl_FragColor.a *= opacity; #include #include }`,nM=`#include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vHighPrecisionZW = gl_Position.zw; }`,sM=`#if DEPTH_PACKING == 3200 uniform float opacity; #endif #include #include #include #include #include #include #include #include #include varying vec2 vHighPrecisionZW; void main() { vec4 diffuseColor = vec4( 1.0 ); #include #if DEPTH_PACKING == 3200 diffuseColor.a = opacity; #endif #include #include #include #include #include #ifdef USE_REVERSED_DEPTH_BUFFER float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; #else float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; #endif #if DEPTH_PACKING == 3200 gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); #elif DEPTH_PACKING == 3201 gl_FragColor = packDepthToRGBA( fragCoordZ ); #elif DEPTH_PACKING == 3202 gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); #elif DEPTH_PACKING == 3203 gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); #endif }`,iM=`#define DISTANCE varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main() { #include #include #include #include #ifdef USE_DISPLACEMENTMAP #include #include #include #endif #include #include #include #include #include #include #include vWorldPosition = worldPosition.xyz; }`,oM=`#define DISTANCE uniform vec3 referencePosition; uniform float nearDistance; uniform float farDistance; varying vec3 vWorldPosition; #include #include #include #include #include #include #include void main () { vec4 diffuseColor = vec4( 1.0 ); #include #include #include #include #include float dist = length( vWorldPosition - referencePosition ); dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); dist = saturate( dist ); gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); }`,aM=`varying vec3 vWorldDirection; #include void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include }`,rM=`uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); #include #include }`,tM=`uniform float scale; attribute float lineDistance; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vLineDistance = scale * lineDistance; #include #include #include #include #include #include #include #include #include #include }`,eM=`uniform vec3 diffuse; uniform float opacity; uniform float dashSize; uniform float totalSize; varying float vLineDistance; #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include if ( mod( vLineDistance, totalSize ) > dashSize ) { discard; } vec3 outgoingLight = vec3( 0.0 ); #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,AN=`#include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) #include #include #include #include #include #endif #include #include #include #include #include #include #include #include #include }`,QN=`uniform vec3 diffuse; uniform float opacity; #ifndef FLAT_SHADED varying vec3 vNormal; #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); #ifdef USE_LIGHTMAP vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; #else reflectedLight.indirectDiffuse += vec3( 1.0 ); #endif #include reflectedLight.indirectDiffuse *= diffuseColor.rgb; vec3 outgoingLight = reflectedLight.indirectDiffuse; #include #include #include #include #include #include #include }`,BN=`#define LAMBERT varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,EN=`#define LAMBERT uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,IN=`#define MATCAP varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; }`,CN=`#define MATCAP uniform vec3 diffuse; uniform float opacity; uniform sampler2D matcap; varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include #include #include #include #include #include #include #include #include vec3 viewDir = normalize( vViewPosition ); vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); vec3 y = cross( viewDir, x ); vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; #ifdef USE_MATCAP vec4 matcapColor = texture2D( matcap, uv ); #else vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); #endif vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; #include #include #include #include #include #include }`,GN=`#define NORMAL #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) vViewPosition = - mvPosition.xyz; #endif }`,KN=`#define NORMAL uniform float opacity; #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) varying vec3 vViewPosition; #endif #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); #include #include #include #include gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); #ifdef OPAQUE gl_FragColor.a = 1.0; #endif }`,JN=`#define PHONG varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #include }`,UN=`#define PHONG uniform vec3 diffuse; uniform vec3 emissive; uniform vec3 specular; uniform float shininess; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; #include #include #include #include #include #include #include }`,FN=`#define STANDARD varying vec3 vViewPosition; #ifdef USE_TRANSMISSION varying vec3 vWorldPosition; #endif #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include #ifdef USE_TRANSMISSION vWorldPosition = worldPosition.xyz; #endif }`,RN=`#define STANDARD #ifdef PHYSICAL #define IOR #define USE_SPECULAR #endif uniform vec3 diffuse; uniform vec3 emissive; uniform float roughness; uniform float metalness; uniform float opacity; #ifdef IOR uniform float ior; #endif #ifdef USE_SPECULAR uniform float specularIntensity; uniform vec3 specularColor; #ifdef USE_SPECULAR_COLORMAP uniform sampler2D specularColorMap; #endif #ifdef USE_SPECULAR_INTENSITYMAP uniform sampler2D specularIntensityMap; #endif #endif #ifdef USE_CLEARCOAT uniform float clearcoat; uniform float clearcoatRoughness; #endif #ifdef USE_DISPERSION uniform float dispersion; #endif #ifdef USE_IRIDESCENCE uniform float iridescence; uniform float iridescenceIOR; uniform float iridescenceThicknessMinimum; uniform float iridescenceThicknessMaximum; #endif #ifdef USE_SHEEN uniform vec3 sheenColor; uniform float sheenRoughness; #ifdef USE_SHEEN_COLORMAP uniform sampler2D sheenColorMap; #endif #ifdef USE_SHEEN_ROUGHNESSMAP uniform sampler2D sheenRoughnessMap; #endif #endif #ifdef USE_ANISOTROPY uniform vec2 anisotropyVector; #ifdef USE_ANISOTROPYMAP uniform sampler2D anisotropyMap; #endif #endif varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; #include vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; #ifdef USE_SHEEN outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; #endif #ifdef USE_CLEARCOAT float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; #endif #include #include #include #include #include #include }`,DN=`#define TOON varying vec3 vViewPosition; #include #include #include #include #include #include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include vViewPosition = - mvPosition.xyz; #include #include #include }`,HN=`#define TOON uniform vec3 diffuse; uniform vec3 emissive; uniform float opacity; #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); vec3 totalEmissiveRadiance = emissive; #include #include #include #include #include #include #include #include #include #include #include #include #include #include vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; #include #include #include #include #include #include }`,YN=`uniform float size; uniform float scale; #include #include #include #include #include #include #ifdef USE_POINTS_UV varying vec2 vUv; uniform mat3 uvTransform; #endif void main() { #ifdef USE_POINTS_UV vUv = ( uvTransform * vec3( uv, 1 ) ).xy; #endif #include #include #include #include #include #include gl_PointSize = size; #ifdef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); #endif #include #include #include #include }`,qN=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include #include }`,MN=`#include #include #include #include #include #include #include void main() { #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include }`,NN=`uniform vec3 color; uniform float opacity; #include #include #include #include #include #include #include void main() { #include gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); #include #include #include #include }`,ZN=`uniform float rotation; uniform vec2 center; #include #include #include #include #include void main() { #include vec4 mvPosition = modelViewMatrix[ 3 ]; vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); #ifndef USE_SIZEATTENUATION bool isPerspective = isPerspectiveMatrix( projectionMatrix ); if ( isPerspective ) scale *= - mvPosition.z; #endif vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; vec2 rotatedPosition; rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; mvPosition.xy += rotatedPosition; gl_Position = projectionMatrix * mvPosition; #include #include #include }`,XN=`uniform vec3 diffuse; uniform float opacity; #include #include #include #include #include #include #include #include #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); #include vec3 outgoingLight = vec3( 0.0 ); #include #include #include #include #include outgoingLight = diffuseColor.rgb; #include #include #include #include }`,YQ={alphahash_fragment:pq,alphahash_pars_fragment:uq,alphamap_fragment:mq,alphamap_pars_fragment:lq,alphatest_fragment:cq,alphatest_pars_fragment:dq,aomap_fragment:nq,aomap_pars_fragment:sq,batching_pars_vertex:iq,batching_vertex:oq,begin_vertex:aq,beginnormal_vertex:rq,bsdfs:tq,iridescence_fragment:eq,bumpmap_pars_fragment:A7,clipping_planes_fragment:Q7,clipping_planes_pars_fragment:B7,clipping_planes_pars_vertex:E7,clipping_planes_vertex:I7,color_fragment:C7,color_pars_fragment:G7,color_pars_vertex:K7,color_vertex:J7,common:U7,cube_uv_reflection_fragment:F7,defaultnormal_vertex:R7,displacementmap_pars_vertex:D7,displacementmap_vertex:H7,emissivemap_fragment:Y7,emissivemap_pars_fragment:q7,colorspace_fragment:M7,colorspace_pars_fragment:N7,envmap_fragment:Z7,envmap_common_pars_fragment:X7,envmap_pars_fragment:L7,envmap_pars_vertex:W7,envmap_physical_pars_fragment:j7,envmap_vertex:$7,fog_vertex:O7,fog_pars_vertex:V7,fog_fragment:k7,fog_pars_fragment:w7,gradientmap_pars_fragment:z7,lightmap_pars_fragment:_7,lights_lambert_fragment:P7,lights_lambert_pars_fragment:T7,lights_pars_begin:S7,lights_toon_fragment:f7,lights_toon_pars_fragment:y7,lights_phong_fragment:g7,lights_phong_pars_fragment:h7,lights_physical_fragment:x7,lights_physical_pars_fragment:v7,lights_fragment_begin:b7,lights_fragment_maps:p7,lights_fragment_end:u7,lightprobes_pars_fragment:m7,logdepthbuf_fragment:l7,logdepthbuf_pars_fragment:c7,logdepthbuf_pars_vertex:d7,logdepthbuf_vertex:n7,map_fragment:s7,map_pars_fragment:i7,map_particle_fragment:o7,map_particle_pars_fragment:a7,metalnessmap_fragment:r7,metalnessmap_pars_fragment:t7,morphinstance_vertex:e7,morphcolor_vertex:AM,morphnormal_vertex:QM,morphtarget_pars_vertex:BM,morphtarget_vertex:EM,normal_fragment_begin:IM,normal_fragment_maps:CM,normal_pars_fragment:GM,normal_pars_vertex:KM,normal_vertex:JM,normalmap_pars_fragment:UM,clearcoat_normal_fragment_begin:FM,clearcoat_normal_fragment_maps:RM,clearcoat_pars_fragment:DM,iridescence_pars_fragment:HM,opaque_fragment:YM,packing:qM,premultiplied_alpha_fragment:MM,project_vertex:NM,dithering_fragment:ZM,dithering_pars_fragment:XM,roughnessmap_fragment:LM,roughnessmap_pars_fragment:WM,shadowmap_pars_fragment:$M,shadowmap_pars_vertex:OM,shadowmap_vertex:VM,shadowmask_pars_fragment:kM,skinbase_vertex:wM,skinning_pars_vertex:zM,skinning_vertex:_M,skinnormal_vertex:PM,specularmap_fragment:TM,specularmap_pars_fragment:SM,tonemapping_fragment:jM,tonemapping_pars_fragment:fM,transmission_fragment:yM,transmission_pars_fragment:gM,uv_pars_fragment:hM,uv_pars_vertex:xM,uv_vertex:vM,worldpos_vertex:bM,background_vert:pM,background_frag:uM,backgroundCube_vert:mM,backgroundCube_frag:lM,cube_vert:cM,cube_frag:dM,depth_vert:nM,depth_frag:sM,distance_vert:iM,distance_frag:oM,equirect_vert:aM,equirect_frag:rM,linedashed_vert:tM,linedashed_frag:eM,meshbasic_vert:AN,meshbasic_frag:QN,meshlambert_vert:BN,meshlambert_frag:EN,meshmatcap_vert:IN,meshmatcap_frag:CN,meshnormal_vert:GN,meshnormal_frag:KN,meshphong_vert:JN,meshphong_frag:UN,meshphysical_vert:FN,meshphysical_frag:RN,meshtoon_vert:DN,meshtoon_frag:HN,points_vert:YN,points_frag:qN,shadow_vert:MN,shadow_frag:NN,sprite_vert:ZN,sprite_frag:XN},jA={common:{diffuse:{value:new AQ(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new KQ},alphaMap:{value:null},alphaMapTransform:{value:new KQ},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new KQ}},envmap:{envMap:{value:null},envMapRotation:{value:new KQ},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:0.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new KQ}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new KQ}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new KQ},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new KQ},normalScale:{value:new LA(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new KQ},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new KQ}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new KQ}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new KQ}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:0.00025},fogNear:{value:1},fogFar:{value:2000},fogColor:{value:new AQ(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new d},probesMax:{value:new d},probesResolution:{value:new d}},points:{diffuse:{value:new AQ(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new KQ},alphaTest:{value:0},uvTransform:{value:new KQ}},sprite:{diffuse:{value:new AQ(16777215)},opacity:{value:1},center:{value:new LA(0.5,0.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new KQ},alphaMap:{value:null},alphaMapTransform:{value:new KQ},alphaTest:{value:0}}},YE={basic:{uniforms:YB([jA.common,jA.specularmap,jA.envmap,jA.aomap,jA.lightmap,jA.fog]),vertexShader:YQ.meshbasic_vert,fragmentShader:YQ.meshbasic_frag},lambert:{uniforms:YB([jA.common,jA.specularmap,jA.envmap,jA.aomap,jA.lightmap,jA.emissivemap,jA.bumpmap,jA.normalmap,jA.displacementmap,jA.fog,jA.lights,{emissive:{value:new AQ(0)},envMapIntensity:{value:1}}]),vertexShader:YQ.meshlambert_vert,fragmentShader:YQ.meshlambert_frag},phong:{uniforms:YB([jA.common,jA.specularmap,jA.envmap,jA.aomap,jA.lightmap,jA.emissivemap,jA.bumpmap,jA.normalmap,jA.displacementmap,jA.fog,jA.lights,{emissive:{value:new AQ(0)},specular:{value:new AQ(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:YQ.meshphong_vert,fragmentShader:YQ.meshphong_frag},standard:{uniforms:YB([jA.common,jA.envmap,jA.aomap,jA.lightmap,jA.emissivemap,jA.bumpmap,jA.normalmap,jA.displacementmap,jA.roughnessmap,jA.metalnessmap,jA.fog,jA.lights,{emissive:{value:new AQ(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:YQ.meshphysical_vert,fragmentShader:YQ.meshphysical_frag},toon:{uniforms:YB([jA.common,jA.aomap,jA.lightmap,jA.emissivemap,jA.bumpmap,jA.normalmap,jA.displacementmap,jA.gradientmap,jA.fog,jA.lights,{emissive:{value:new AQ(0)}}]),vertexShader:YQ.meshtoon_vert,fragmentShader:YQ.meshtoon_frag},matcap:{uniforms:YB([jA.common,jA.bumpmap,jA.normalmap,jA.displacementmap,jA.fog,{matcap:{value:null}}]),vertexShader:YQ.meshmatcap_vert,fragmentShader:YQ.meshmatcap_frag},points:{uniforms:YB([jA.points,jA.fog]),vertexShader:YQ.points_vert,fragmentShader:YQ.points_frag},dashed:{uniforms:YB([jA.common,jA.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:YQ.linedashed_vert,fragmentShader:YQ.linedashed_frag},depth:{uniforms:YB([jA.common,jA.displacementmap]),vertexShader:YQ.depth_vert,fragmentShader:YQ.depth_frag},normal:{uniforms:YB([jA.common,jA.bumpmap,jA.normalmap,jA.displacementmap,{opacity:{value:1}}]),vertexShader:YQ.meshnormal_vert,fragmentShader:YQ.meshnormal_frag},sprite:{uniforms:YB([jA.sprite,jA.fog]),vertexShader:YQ.sprite_vert,fragmentShader:YQ.sprite_frag},background:{uniforms:{uvTransform:{value:new KQ},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:YQ.background_vert,fragmentShader:YQ.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new KQ}},vertexShader:YQ.backgroundCube_vert,fragmentShader:YQ.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:YQ.cube_vert,fragmentShader:YQ.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:YQ.equirect_vert,fragmentShader:YQ.equirect_frag},distance:{uniforms:YB([jA.common,jA.displacementmap,{referencePosition:{value:new d},nearDistance:{value:1},farDistance:{value:1000}}]),vertexShader:YQ.distance_vert,fragmentShader:YQ.distance_frag},shadow:{uniforms:YB([jA.lights,jA.fog,{color:{value:new AQ(0)},opacity:{value:1}}]),vertexShader:YQ.shadow_vert,fragmentShader:YQ.shadow_frag}};YE.physical={uniforms:YB([YE.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new KQ},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new KQ},clearcoatNormalScale:{value:new LA(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new KQ},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new KQ},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new KQ},sheen:{value:0},sheenColor:{value:new AQ(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new KQ},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new KQ},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new KQ},transmissionSamplerSize:{value:new LA},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new KQ},attenuationDistance:{value:0},attenuationColor:{value:new AQ(0)},specularColor:{value:new AQ(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new KQ},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new KQ},anisotropyVector:{value:new LA},anisotropyMap:{value:null},anisotropyMapTransform:{value:new KQ}}]),vertexShader:YQ.meshphysical_vert,fragmentShader:YQ.meshphysical_frag};var YG={r:0,b:0,g:0},LN=new HQ,rR=new KQ;rR.set(-1,0,0,0,1,0,0,0,1);function WN(A,Q,B,E,I,C){let G=new AQ(0),K=I===!0?0:1,J,U,F=null,R=0,D=null;function H(N){let $=N.isScene===!0?N.background:null;if($&&$.isTexture){let L=N.backgroundBlurriness>0;$=Q.get($,L)}return $}function M(N){let $=!1,L=H(N);if(L===null)Y(G,K);else if(L&&L.isColor)Y(L,1),$=!0;let k=A.xr.getEnvironmentBlendMode();if(k==="additive")B.buffers.color.setClear(0,0,0,1,C);else if(k==="alpha-blend")B.buffers.color.setClear(0,0,0,0,C);if(A.autoClear||$)B.buffers.depth.setTest(!0),B.buffers.depth.setMask(!0),B.buffers.color.setMask(!0),A.clear(A.autoClearColor,A.autoClearDepth,A.autoClearStencil)}function X(N,$){let L=H($);if(L&&(L.isCubeTexture||L.mapping===JC)){if(U===void 0)U=new _Q(new j0(1,1,1),new hQ({name:"BackgroundCubeMaterial",uniforms:xI(YE.backgroundCube.uniforms),vertexShader:YE.backgroundCube.vertexShader,fragmentShader:YE.backgroundCube.fragmentShader,side:iQ,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),U.geometry.deleteAttribute("normal"),U.geometry.deleteAttribute("uv"),U.onBeforeRender=function(k,O,w){this.matrixWorld.copyPosition(w.matrixWorld)},Object.defineProperty(U.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),E.update(U);if(U.material.uniforms.envMap.value=L,U.material.uniforms.backgroundBlurriness.value=$.backgroundBlurriness,U.material.uniforms.backgroundIntensity.value=$.backgroundIntensity,U.material.uniforms.backgroundRotation.value.setFromMatrix4(LN.makeRotationFromEuler($.backgroundRotation)).transpose(),L.isCubeTexture&&L.isRenderTargetTexture===!1)U.material.uniforms.backgroundRotation.value.premultiply(rR);if(U.material.toneMapped=qQ.getTransfer(L.colorSpace)!==jQ,F!==L||R!==L.version||D!==A.toneMapping)U.material.needsUpdate=!0,F=L,R=L.version,D=A.toneMapping;U.layers.enableAll(),N.unshift(U,U.geometry,U.material,0,0,null)}else if(L&&L.isTexture){if(J===void 0)J=new _Q(new HB(2,2),new hQ({name:"BackgroundMaterial",uniforms:xI(YE.background.uniforms),vertexShader:YE.background.vertexShader,fragmentShader:YE.background.fragmentShader,side:GB,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),J.geometry.deleteAttribute("normal"),Object.defineProperty(J.material,"map",{get:function(){return this.uniforms.t2D.value}}),E.update(J);if(J.material.uniforms.t2D.value=L,J.material.uniforms.backgroundIntensity.value=$.backgroundIntensity,J.material.toneMapped=qQ.getTransfer(L.colorSpace)!==jQ,L.matrixAutoUpdate===!0)L.updateMatrix();if(J.material.uniforms.uvTransform.value.copy(L.matrix),F!==L||R!==L.version||D!==A.toneMapping)J.material.needsUpdate=!0,F=L,R=L.version,D=A.toneMapping;J.layers.enableAll(),N.unshift(J,J.geometry,J.material,0,0,null)}}function Y(N,$){N.getRGB(YG,zJ(A)),B.buffers.color.setClear(YG.r,YG.g,YG.b,$,C)}function q(){if(U!==void 0)U.geometry.dispose(),U.material.dispose(),U=void 0;if(J!==void 0)J.geometry.dispose(),J.material.dispose(),J=void 0}return{getClearColor:function(){return G},setClearColor:function(N,$=1){G.set(N),K=$,Y(G,K)},getClearAlpha:function(){return K},setClearAlpha:function(N){K=N,Y(G,K)},render:M,addToRenderList:X,dispose:q}}function $N(A,Q){let B=A.getParameter(A.MAX_VERTEX_ATTRIBS),E={},I=D(null),C=I,G=!1;function K(_,v,x,P,j){let g=!1,f=R(_,P,x,v);if(C!==f)C=f,U(C.object);if(g=H(_,P,x,j),g)M(_,P,x,j);if(j!==null)Q.update(j,A.ELEMENT_ARRAY_BUFFER);if(g||G){if(G=!1,L(_,v,x,P),j!==null)A.bindBuffer(A.ELEMENT_ARRAY_BUFFER,Q.get(j).buffer)}}function J(){return A.createVertexArray()}function U(_){return A.bindVertexArray(_)}function F(_){return A.deleteVertexArray(_)}function R(_,v,x,P){let j=P.wireframe===!0,g=E[v.id];if(g===void 0)g={},E[v.id]=g;let f=_.isInstancedMesh===!0?_.id:0,p=g[f];if(p===void 0)p={},g[f]=p;let u=p[x.id];if(u===void 0)u={},p[x.id]=u;let b=u[j];if(b===void 0)b=D(J()),u[j]=b;return b}function D(_){let v=[],x=[],P=[];for(let j=0;j=0){let t=j[u],AA=g[u];if(AA===void 0){if(u==="instanceMatrix"&&_.instanceMatrix)AA=_.instanceMatrix;if(u==="instanceColor"&&_.instanceColor)AA=_.instanceColor}if(t===void 0)return!0;if(t.attribute!==AA)return!0;if(AA&&t.data!==AA.data)return!0;f++}if(C.attributesNum!==f)return!0;if(C.index!==P)return!0;return!1}function M(_,v,x,P){let j={},g=v.attributes,f=0,p=x.getAttributes();for(let u in p)if(p[u].location>=0){let t=g[u];if(t===void 0){if(u==="instanceMatrix"&&_.instanceMatrix)t=_.instanceMatrix;if(u==="instanceColor"&&_.instanceColor)t=_.instanceColor}let AA={};if(AA.attribute=t,t&&t.data)AA.data=t.data;j[u]=AA,f++}C.attributes=j,C.attributesNum=f,C.index=P}function X(){let _=C.newAttributes;for(let v=0,x=_.length;v=0){let b=j[p];if(b===void 0){if(p==="instanceMatrix"&&_.instanceMatrix)b=_.instanceMatrix;if(p==="instanceColor"&&_.instanceColor)b=_.instanceColor}if(b!==void 0){let{normalized:t,itemSize:AA}=b,kA=Q.get(b);if(kA===void 0)continue;let{buffer:SA,type:l,bytesPerElement:QA}=kA,FA=l===A.INT||l===A.UNSIGNED_INT||b.gpuType===tK;if(b.isInterleavedBufferAttribute){let RA=b.data,qA=RA.stride,eA=b.offset;if(RA.isInstancedInterleavedBuffer){for(let tA=0;tA0&&A.getShaderPrecisionFormat(A.FRAGMENT_SHADER,A.HIGH_FLOAT).precision>0)return"highp";w="mediump"}if(w==="mediump"){if(A.getShaderPrecisionFormat(A.VERTEX_SHADER,A.MEDIUM_FLOAT).precision>0&&A.getShaderPrecisionFormat(A.FRAGMENT_SHADER,A.MEDIUM_FLOAT).precision>0)return"mediump"}return"lowp"}let U=B.precision!==void 0?B.precision:"highp",F=J(U);if(F!==U)mA("WebGLRenderer:",U,"not supported, using",F,"instead."),U=F;let R=B.logarithmicDepthBuffer===!0,D=B.reversedDepthBuffer===!0&&Q.has("EXT_clip_control");if(B.reversedDepthBuffer===!0&&D===!1)mA("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");let H=A.getParameter(A.MAX_TEXTURE_IMAGE_UNITS),M=A.getParameter(A.MAX_VERTEX_TEXTURE_IMAGE_UNITS),X=A.getParameter(A.MAX_TEXTURE_SIZE),Y=A.getParameter(A.MAX_CUBE_MAP_TEXTURE_SIZE),q=A.getParameter(A.MAX_VERTEX_ATTRIBS),N=A.getParameter(A.MAX_VERTEX_UNIFORM_VECTORS),$=A.getParameter(A.MAX_VARYING_VECTORS),L=A.getParameter(A.MAX_FRAGMENT_UNIFORM_VECTORS),k=A.getParameter(A.MAX_SAMPLES),O=A.getParameter(A.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:C,getMaxPrecision:J,textureFormatReadable:G,textureTypeReadable:K,precision:U,logarithmicDepthBuffer:R,reversedDepthBuffer:D,maxTextures:H,maxVertexTextures:M,maxTextureSize:X,maxCubemapSize:Y,maxAttributes:q,maxVertexUniforms:N,maxVaryings:$,maxFragmentUniforms:L,maxSamples:k,samples:O}}function kN(A){let Q=this,B=null,E=0,I=!1,C=!1,G=new rB,K=new KQ,J={value:null,needsUpdate:!1};this.uniform=J,this.numPlanes=0,this.numIntersection=0,this.init=function(R,D){let H=R.length!==0||D||E!==0||I;return I=D,E=R.length,H},this.beginShadows=function(){C=!0,F(null)},this.endShadows=function(){C=!1},this.setGlobalState=function(R,D){B=F(R,D,0)},this.setState=function(R,D,H){let{clippingPlanes:M,clipIntersection:X,clipShadows:Y}=R,q=A.get(R);if(!I||M===null||M.length===0||C&&!Y)if(C)F(null);else U();else{let N=C?0:E,$=N*4,L=q.clippingState||null;J.value=L,L=F(M,D,$,H);for(let k=0;k!==$;++k)L[k]=B[k];q.clippingState=L,this.numIntersection=X?this.numPlanes:0,this.numPlanes+=N}};function U(){if(J.value!==B)J.value=B,J.needsUpdate=E>0;Q.numPlanes=E,Q.numIntersection=0}function F(R,D,H,M){let X=R!==null?R.length:0,Y=null;if(X!==0){if(Y=J.value,M!==!0||Y===null){let q=H+X*4,N=D.matrixWorldInverse;if(K.getNormalMatrix(N),Y===null||Y.length0)this._blur(K,0,0,Q);return this._applyPMREM(K),this._cleanup(K),K}fromEquirectangular(A,Q=null){return this._fromTexture(A,Q)}fromCubemap(A,Q=null){return this._fromTexture(A,Q)}compileCubemapShader(){if(this._cubemapMaterial===null)this._cubemapMaterial=jR(),this._compileMaterial(this._cubemapMaterial)}compileEquirectangularShader(){if(this._equirectMaterial===null)this._equirectMaterial=SR(),this._compileMaterial(this._equirectMaterial)}dispose(){if(this._dispose(),this._cubemapMaterial!==null)this._cubemapMaterial.dispose();if(this._equirectMaterial!==null)this._equirectMaterial.dispose();if(this._backgroundBox!==null)this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose()}_setSize(A){this._lodMax=Math.floor(Math.log2(A)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){if(this._blurMaterial!==null)this._blurMaterial.dispose();if(this._ggxMaterial!==null)this._ggxMaterial.dispose();if(this._pingPongRenderTarget!==null)this._pingPongRenderTarget.dispose();for(let A=0;A2?L:0,L,L),F.setRenderTarget(E),Y)F.render(M,K);F.render(A,K)}F.toneMapping=D,F.autoClear=R,A.background=q}_textureToCubeUV(A,Q){let B=this._renderer,E=A.mapping===Z0||A.mapping===zI;if(E){if(this._cubemapMaterial===null)this._cubemapMaterial=jR();this._cubemapMaterial.uniforms.flipEnvMap.value=A.isRenderTargetTexture===!1?-1:1}else if(this._equirectMaterial===null)this._equirectMaterial=SR();let I=E?this._cubemapMaterial:this._equirectMaterial,C=this._lodMeshes[0];C.material=I;let G=I.uniforms;G.envMap.value=A;let K=this._cubeSize;g0(Q,0,0,3*K,2*K),B.setRenderTarget(Q),B.render(C,gC)}_applyPMREM(A){let Q=this._renderer,B=Q.autoClear;Q.autoClear=!1;let E=this._lodMeshes.length;for(let I=1;IH-HI?B-H+HI:0),Y=4*(this._cubeSize-M);K.envMap.value=A.texture,K.roughness.value=D,K.mipInt.value=H-Q,g0(I,X,Y,3*M,2*M),E.setRenderTarget(I),E.render(G,gC),K.envMap.value=I.texture,K.roughness.value=0,K.mipInt.value=H-B,g0(A,X,Y,3*M,2*M),E.setRenderTarget(A),E.render(G,gC)}_blur(A,Q,B,E,I){let C=this._pingPongRenderTarget;this._halfBlur(A,C,Q,B,E,"latitudinal",I),this._halfBlur(C,A,B,B,E,"longitudinal",I)}_halfBlur(A,Q,B,E,I,C,G){let K=this._renderer,J=this._blurMaterial;if(C!=="latitudinal"&&C!=="longitudinal")CQ("blur direction must be either latitudinal or longitudinal!");let U=3,F=this._lodMeshes[E];F.material=J;let R=J.uniforms,D=this._sizeLods[B]-1,H=isFinite(I)?Math.PI/(2*D):2*Math.PI/(2*vI-1),M=I/H,X=isFinite(I)?1+Math.floor(U*M):vI;if(X>vI)mA(`sigmaRadians, ${I}, is too large and will clip, as it requested ${X} samples when the maximum is set to ${vI}`);let Y=[],q=0;for(let O=0;ON-HI?E-N+HI:0),k=4*(this._cubeSize-$);g0(Q,L,k,3*$,2*$),K.setRenderTarget(Q),K.render(F,gC)}}function _N(A){let Q=[],B=[],E=[],I=A,C=A-HI+1+_R.length;for(let G=0;GA-HI)J=_R[G-A+HI-1];else if(G===0)J=0;B.push(J);let U=1/(K-2),F=-U,R=1+U,D=[F,F,R,F,R,R,F,F,R,R,F,R],H=6,M=6,X=3,Y=2,q=1,N=new Float32Array(X*M*H),$=new Float32Array(Y*M*H),L=new Float32Array(q*M*H);for(let O=0;O2?0:-1,z=[w,Z,0,w+0.6666666666666666,Z,0,w+0.6666666666666666,Z+1,0,w,Z,0,w+0.6666666666666666,Z+1,0,w,Z+1,0];N.set(z,X*M*O),$.set(D,Y*M*O);let y=[O,O,O,O,O,O];L.set(y,q*M*O)}let k=new JB;if(k.setAttribute("position",new rQ(N,X)),k.setAttribute("uv",new rQ($,Y)),k.setAttribute("faceIndex",new rQ(L,q)),E.push(new _Q(k,null)),I>HI)I--}return{lodMeshes:E,sizeLods:Q,sigmas:B}}function TR(A,Q,B){let E=new lQ(A,Q,B);return E.texture.mapping=JC,E.texture.name="PMREM.cubeUv",E.scissorTest=!0,E}function g0(A,Q,B,E,I){A.viewport.set(Q,B,E,I),A.scissor.set(Q,B,E,I)}function PN(A,Q,B){return new hQ({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:wN,CUBEUV_TEXEL_WIDTH:1/Q,CUBEUV_TEXEL_HEIGHT:1/B,CUBEUV_MAX_MIP:`${A}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:MG(),fragmentShader:` precision highp float; precision highp int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform float roughness; uniform float mipInt; #define ENVMAP_TYPE_CUBE_UV #include #define PI 3.14159265359 // Van der Corput radical inverse float radicalInverse_VdC(uint bits) { bits = (bits << 16u) | (bits >> 16u); bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); return float(bits) * 2.3283064365386963e-10; // / 0x100000000 } // Hammersley sequence vec2 hammersley(uint i, uint N) { return vec2(float(i) / float(N), radicalInverse_VdC(i)); } // GGX VNDF importance sampling (Eric Heitz 2018) // "Sampling the GGX Distribution of Visible Normals" // https://jcgt.org/published/0007/04/01/ vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { float alpha = roughness * roughness; // Section 4.1: Orthonormal basis vec3 T1 = vec3(1.0, 0.0, 0.0); vec3 T2 = cross(V, T1); // Section 4.2: Parameterization of projected area float r = sqrt(Xi.x); float phi = 2.0 * PI * Xi.y; float t1 = r * cos(phi); float t2 = r * sin(phi); float s = 0.5 * (1.0 + V.z); t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; // Section 4.3: Reprojection onto hemisphere vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; // Section 3.4: Transform back to ellipsoid configuration return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); } void main() { vec3 N = normalize(vOutputDirection); vec3 V = N; // Assume view direction equals normal for pre-filtering vec3 prefilteredColor = vec3(0.0); float totalWeight = 0.0; // For very low roughness, just sample the environment directly if (roughness < 0.001) { gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); return; } // Tangent space basis for VNDF sampling vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); vec3 tangent = normalize(cross(up, N)); vec3 bitangent = cross(N, tangent); for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); // For PMREM, V = N, so in tangent space V is always (0, 0, 1) vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); // Transform H back to world space vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); vec3 L = normalize(2.0 * dot(V, H) * H - V); float NdotL = max(dot(N, L), 0.0); if(NdotL > 0.0) { // Sample environment at fixed mip level // VNDF importance sampling handles the distribution filtering vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); // Weight by NdotL for the split-sum approximation // VNDF PDF naturally accounts for the visible microfacet distribution prefilteredColor += sampleColor * NdotL; totalWeight += NdotL; } } if (totalWeight > 0.0) { prefilteredColor = prefilteredColor / totalWeight; } gl_FragColor = vec4(prefilteredColor, 1.0); } `,blending:UE,depthTest:!1,depthWrite:!1})}function TN(A,Q,B){let E=new Float32Array(vI),I=new d(0,1,0);return new hQ({name:"SphericalGaussianBlur",defines:{n:vI,CUBEUV_TEXEL_WIDTH:1/Q,CUBEUV_TEXEL_HEIGHT:1/B,CUBEUV_MAX_MIP:`${A}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:E},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:I}},vertexShader:MG(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; uniform int samples; uniform float weights[ n ]; uniform bool latitudinal; uniform float dTheta; uniform float mipInt; uniform vec3 poleAxis; #define ENVMAP_TYPE_CUBE_UV #include vec3 getSample( float theta, vec3 axis ) { float cosTheta = cos( theta ); // Rodrigues' axis-angle rotation vec3 sampleDirection = vOutputDirection * cosTheta + cross( axis, vOutputDirection ) * sin( theta ) + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); return bilinearCubeUV( envMap, sampleDirection, mipInt ); } void main() { vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); if ( all( equal( axis, vec3( 0.0 ) ) ) ) { axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); } axis = normalize( axis ); gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); for ( int i = 1; i < n; i++ ) { if ( i >= samples ) { break; } float theta = dTheta * float( i ); gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); } } `,blending:UE,depthTest:!1,depthWrite:!1})}function SR(){return new hQ({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:MG(),fragmentShader:` precision mediump float; precision mediump int; varying vec3 vOutputDirection; uniform sampler2D envMap; #include void main() { vec3 outputDirection = normalize( vOutputDirection ); vec2 uv = equirectUv( outputDirection ); gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } `,blending:UE,depthTest:!1,depthWrite:!1})}function jR(){return new hQ({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:MG(),fragmentShader:` precision mediump float; precision mediump int; uniform float flipEnvMap; varying vec3 vOutputDirection; uniform samplerCube envMap; void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } `,blending:UE,depthTest:!1,depthWrite:!1})}function MG(){return` precision mediump float; precision mediump int; attribute float faceIndex; varying vec3 vOutputDirection; // RH coordinate system; PMREM face-indexing convention vec3 getDirection( vec2 uv, float face ) { uv = 2.0 * uv - 1.0; vec3 direction = vec3( uv, 1.0 ); if ( face == 0.0 ) { direction = direction.zyx; // ( 1, v, u ) pos x } else if ( face == 1.0 ) { direction = direction.xzy; direction.xz *= -1.0; // ( -u, 1, -v ) pos y } else if ( face == 2.0 ) { direction.x *= -1.0; // ( -u, v, 1 ) pos z } else if ( face == 3.0 ) { direction = direction.zyx; direction.xz *= -1.0; // ( -1, v, -u ) neg x } else if ( face == 4.0 ) { direction = direction.xzy; direction.xy *= -1.0; // ( -u, -1, v ) neg y } else if ( face == 5.0 ) { direction.z *= -1.0; // ( u, v, -1 ) neg z } return direction; } void main() { vOutputDirection = getDirection( uv, faceIndex ); gl_Position = vec4( position, 1.0 ); } `}class eJ extends lQ{constructor(A=1,Q={}){super(A,A,Q);this.isWebGLCubeRenderTarget=!0;let B={width:A,height:A,depth:1},E=[B,B,B,B,B,B];this.texture=new QG(E),this._setTextureOptions(Q),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(A,Q){this.texture.type=Q.type,this.texture.colorSpace=Q.colorSpace,this.texture.generateMipmaps=Q.generateMipmaps,this.texture.minFilter=Q.minFilter,this.texture.magFilter=Q.magFilter;let B={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; vec3 transformDirection( in vec3 dir, in mat4 matrix ) { return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); } void main() { vWorldDirection = transformDirection( position, modelMatrix ); #include #include } `,fragmentShader:` uniform sampler2D tEquirect; varying vec3 vWorldDirection; #include void main() { vec3 direction = normalize( vWorldDirection ); vec2 sampleUV = equirectUv( direction ); gl_FragColor = texture2D( tEquirect, sampleUV ); } `},E=new j0(5,5,5),I=new hQ({name:"CubemapFromEquirect",uniforms:xI(B.uniforms),vertexShader:B.vertexShader,fragmentShader:B.fragmentShader,side:iQ,blending:UE});I.uniforms.tEquirect.value=Q;let C=new _Q(E,I),G=Q.minFilter;if(Q.minFilter===SB)Q.minFilter=VQ;return new vJ(1,10,this).update(A,C),Q.minFilter=G,C.geometry.dispose(),C.material.dispose(),this}clear(A,Q=!0,B=!0,E=!0){let I=A.getRenderTarget();for(let C=0;C<6;C++)A.setRenderTarget(this,C),A.clear(Q,B,E);A.setRenderTarget(I)}}function SN(A){let Q=new WeakMap,B=new WeakMap,E=null;function I(D,H=!1){if(D===null||D===void 0)return null;if(H)return G(D);return C(D)}function C(D){if(D&&D.isTexture){let H=D.mapping;if(H===x8||H===v8)if(Q.has(D)){let M=Q.get(D).texture;return K(M,D.mapping)}else{let M=D.image;if(M&&M.height>0){let X=new eJ(M.height);return X.fromEquirectangularTexture(A,D),Q.set(D,X),D.addEventListener("dispose",U),K(X.texture,D.mapping)}else return null}}return D}function G(D){if(D&&D.isTexture){let H=D.mapping,M=H===x8||H===v8,X=H===Z0||H===zI;if(M||X){let Y=B.get(D),q=Y!==void 0?Y.texture.pmremVersion:0;if(D.isRenderTargetTexture&&D.pmremVersion!==q){if(E===null)E=new aJ(A);return Y=M?E.fromEquirectangular(D,Y):E.fromCubemap(D,Y),Y.texture.pmremVersion=D.pmremVersion,B.set(D,Y),Y.texture}else if(Y!==void 0)return Y.texture;else{let N=D.image;if(M&&N&&N.height>0||X&&N&&J(N)){if(E===null)E=new aJ(A);return Y=M?E.fromEquirectangular(D):E.fromCubemap(D),Y.texture.pmremVersion=D.pmremVersion,B.set(D,Y),D.addEventListener("dispose",F),Y.texture}else return null}}}return D}function K(D,H){if(H===x8)D.mapping=Z0;else if(H===v8)D.mapping=zI;return D}function J(D){let H=0,M=6;for(let X=0;X=65535?s8:n8)(D,1);Y.version=X;let q=C.get(R);if(q)Q.remove(q);C.set(R,Y)}function F(R){let D=C.get(R);if(D){let H=R.index;if(H!==null){if(D.versionQ.maxTextureSize)k=Math.ceil(L/Q.maxTextureSize),L=Q.maxTextureSize;let O=new Float32Array(L*k*4*R),w=new d8(O,L,k,R);w.type=NB,w.needsUpdate=!0;let Z=$*4;for(let y=0;y #include void main() { gl_FragColor = texture2D( tDiffuse, vUv ); #ifdef LINEAR_TONE_MAPPING gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); #elif defined( REINHARD_TONE_MAPPING ) gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); #elif defined( CINEON_TONE_MAPPING ) gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); #elif defined( ACES_FILMIC_TONE_MAPPING ) gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); #elif defined( AGX_TONE_MAPPING ) gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); #elif defined( NEUTRAL_TONE_MAPPING ) gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); #elif defined( CUSTOM_TONE_MAPPING ) gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); #endif #ifdef SRGB_TRANSFER gl_FragColor = sRGBTransferOETF( gl_FragColor ); #endif }`,depthTest:!1,depthWrite:!1}),U=new _Q(K,J),F=new hE(-1,1,1,-1,0,1),R=null,D=null,H=!1,M,X=null,Y=[],q=!1;this.setSize=function(N,$){C.setSize(N,$),G.setSize(N,$);for(let L=0;L0&&Y[0].isRenderPass===!0;let{width:$,height:L}=C;for(let k=0;k0)return A;let I=Q*B,C=fR[I];if(C===void 0)C=new Float32Array(I),fR[I]=C;if(Q!==0){E.toArray(C,0);for(let G=1,K=0;G!==Q;++G)K+=B,A[G].toArray(C,K)}return C}function tQ(A,Q){if(A.length!==Q.length)return!1;for(let B=0,E=A.length;B0)this.seq=E.concat(I)}setValue(A,Q,B,E){let I=this.map[Q];if(I!==void 0)I.setValue(A,B,E)}setOptional(A,Q,B){let E=Q[B];if(E!==void 0)this.setValue(A,B,E)}static upload(A,Q,B,E){for(let I=0,C=Q.length;I!==C;++I){let G=Q[I],K=B[G.id];if(K.needsUpdate!==!1)G.setValue(A,K.value,E)}}static seqWithValue(A,Q){let B=[];for(let E=0,I=A.length;E!==I;++E){let C=A[E];if(C.id in Q)B.push(C)}return B}}function bR(A,Q,B){let E=A.createShader(Q);return A.shaderSource(E,B),A.compileShader(E),E}var zZ=37297,_Z=0;function PZ(A,Q){let B=A.split(` `),E=[],I=Math.max(Q-6,0),C=Math.min(Q+6,B.length);for(let G=I;G":" "} ${K}: ${B[G]}`)}return E.join(` `)}var pR=new KQ;function TZ(A){qQ._getMatrix(pR,qQ.workingColorSpace,A);let Q=`mat3( ${pR.elements.map((B)=>B.toFixed(4))} )`;switch(qQ.getTransfer(A)){case m8:return[Q,"LinearTransferOETF"];case jQ:return[Q,"sRGBTransferOETF"];default:return mA("WebGLProgram: Unsupported color space: ",A),[Q,"LinearTransferOETF"]}}function uR(A,Q,B){let E=A.getShaderParameter(Q,A.COMPILE_STATUS),C=(A.getShaderInfoLog(Q)||"").trim();if(E&&C==="")return"";let G=/ERROR: 0:(\d+)/.exec(C);if(G){let K=parseInt(G[1]);return B.toUpperCase()+` `+C+` `+PZ(A.getShaderSource(Q),K)}else return C}function SZ(A,Q){let B=TZ(Q);return[`vec4 ${A}( vec4 value ) {`,` return ${B[1]}( vec4( value.rgb * ${B[0]}, value.a ) );`,"}"].join(` `)}var jZ={[dK]:"Linear",[nK]:"Reinhard",[sK]:"Cineon",[iK]:"ACESFilmic",[aK]:"AgX",[rK]:"Neutral",[oK]:"Custom"};function fZ(A,Q){let B=jZ[Q];if(B===void 0)return mA("WebGLProgram: Unsupported toneMapping:",Q),"vec3 "+A+"( vec3 color ) { return LinearToneMapping( color ); }";return"vec3 "+A+"( vec3 color ) { return "+B+"ToneMapping( color ); }"}var qG=new d;function yZ(){qQ.getLuminanceCoefficients(qG);let A=qG.x.toFixed(4),Q=qG.y.toFixed(4),B=qG.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${A}, ${Q}, ${B} );`,"\treturn dot( weights, rgb );","}"].join(` `)}function gZ(A){return[A.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",A.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(xC).join(` `)}function hZ(A){let Q=[];for(let B in A){let E=A[B];if(E===!1)continue;Q.push("#define "+B+" "+E)}return Q.join(` `)}function xZ(A,Q){let B={},E=A.getProgramParameter(Q,A.ACTIVE_ATTRIBUTES);for(let I=0;I/gm;function tJ(A){return A.replace(vZ,pZ)}var bZ=new Map;function pZ(A,Q){let B=YQ[Q];if(B===void 0){let E=bZ.get(Q);if(E!==void 0)B=YQ[E],mA('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',Q,E);else throw Error("Can not resolve #include <"+Q+">")}return tJ(B)}var uZ=/#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 cR(A){return A.replace(uZ,mZ)}function mZ(A,Q,B,E){let I="";for(let C=parseInt(Q);C0)Y+=` `;if(q=["#define SHADER_TYPE "+B.shaderType,"#define SHADER_NAME "+B.shaderName,M].filter(xC).join(` `),q.length>0)q+=` `}else Y=[dR(B),"#define SHADER_TYPE "+B.shaderType,"#define SHADER_NAME "+B.shaderName,M,B.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",B.batching?"#define USE_BATCHING":"",B.batchingColor?"#define USE_BATCHING_COLOR":"",B.instancing?"#define USE_INSTANCING":"",B.instancingColor?"#define USE_INSTANCING_COLOR":"",B.instancingMorph?"#define USE_INSTANCING_MORPH":"",B.useFog&&B.fog?"#define USE_FOG":"",B.useFog&&B.fogExp2?"#define FOG_EXP2":"",B.map?"#define USE_MAP":"",B.envMap?"#define USE_ENVMAP":"",B.envMap?"#define "+F:"",B.lightMap?"#define USE_LIGHTMAP":"",B.aoMap?"#define USE_AOMAP":"",B.bumpMap?"#define USE_BUMPMAP":"",B.normalMap?"#define USE_NORMALMAP":"",B.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",B.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",B.displacementMap?"#define USE_DISPLACEMENTMAP":"",B.emissiveMap?"#define USE_EMISSIVEMAP":"",B.anisotropy?"#define USE_ANISOTROPY":"",B.anisotropyMap?"#define USE_ANISOTROPYMAP":"",B.clearcoatMap?"#define USE_CLEARCOATMAP":"",B.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",B.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",B.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",B.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",B.specularMap?"#define USE_SPECULARMAP":"",B.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",B.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",B.roughnessMap?"#define USE_ROUGHNESSMAP":"",B.metalnessMap?"#define USE_METALNESSMAP":"",B.alphaMap?"#define USE_ALPHAMAP":"",B.alphaHash?"#define USE_ALPHAHASH":"",B.transmission?"#define USE_TRANSMISSION":"",B.transmissionMap?"#define USE_TRANSMISSIONMAP":"",B.thicknessMap?"#define USE_THICKNESSMAP":"",B.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",B.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",B.mapUv?"#define MAP_UV "+B.mapUv:"",B.alphaMapUv?"#define ALPHAMAP_UV "+B.alphaMapUv:"",B.lightMapUv?"#define LIGHTMAP_UV "+B.lightMapUv:"",B.aoMapUv?"#define AOMAP_UV "+B.aoMapUv:"",B.emissiveMapUv?"#define EMISSIVEMAP_UV "+B.emissiveMapUv:"",B.bumpMapUv?"#define BUMPMAP_UV "+B.bumpMapUv:"",B.normalMapUv?"#define NORMALMAP_UV "+B.normalMapUv:"",B.displacementMapUv?"#define DISPLACEMENTMAP_UV "+B.displacementMapUv:"",B.metalnessMapUv?"#define METALNESSMAP_UV "+B.metalnessMapUv:"",B.roughnessMapUv?"#define ROUGHNESSMAP_UV "+B.roughnessMapUv:"",B.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+B.anisotropyMapUv:"",B.clearcoatMapUv?"#define CLEARCOATMAP_UV "+B.clearcoatMapUv:"",B.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+B.clearcoatNormalMapUv:"",B.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+B.clearcoatRoughnessMapUv:"",B.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+B.iridescenceMapUv:"",B.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+B.iridescenceThicknessMapUv:"",B.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+B.sheenColorMapUv:"",B.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+B.sheenRoughnessMapUv:"",B.specularMapUv?"#define SPECULARMAP_UV "+B.specularMapUv:"",B.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+B.specularColorMapUv:"",B.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+B.specularIntensityMapUv:"",B.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+B.transmissionMapUv:"",B.thicknessMapUv?"#define THICKNESSMAP_UV "+B.thicknessMapUv:"",B.vertexTangents&&B.flatShading===!1?"#define USE_TANGENT":"",B.vertexNormals?"#define HAS_NORMAL":"",B.vertexColors?"#define USE_COLOR":"",B.vertexAlphas?"#define USE_COLOR_ALPHA":"",B.vertexUv1s?"#define USE_UV1":"",B.vertexUv2s?"#define USE_UV2":"",B.vertexUv3s?"#define USE_UV3":"",B.pointsUvs?"#define USE_POINTS_UV":"",B.flatShading?"#define FLAT_SHADED":"",B.skinning?"#define USE_SKINNING":"",B.morphTargets?"#define USE_MORPHTARGETS":"",B.morphNormals&&B.flatShading===!1?"#define USE_MORPHNORMALS":"",B.morphColors?"#define USE_MORPHCOLORS":"",B.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+B.morphTextureStride:"",B.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+B.morphTargetsCount:"",B.doubleSided?"#define DOUBLE_SIDED":"",B.flipSided?"#define FLIP_SIDED":"",B.shadowMapEnabled?"#define USE_SHADOWMAP":"",B.shadowMapEnabled?"#define "+J:"",B.sizeAttenuation?"#define USE_SIZEATTENUATION":"",B.numLightProbes>0?"#define USE_LIGHT_PROBES":"",B.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",B.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","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","#ifdef USE_INSTANCING_MORPH","\tuniform sampler2D morphTexture;","#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","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif",` `].filter(xC).join(` `),q=[dR(B),"#define SHADER_TYPE "+B.shaderType,"#define SHADER_NAME "+B.shaderName,M,B.useFog&&B.fog?"#define USE_FOG":"",B.useFog&&B.fogExp2?"#define FOG_EXP2":"",B.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",B.map?"#define USE_MAP":"",B.matcap?"#define USE_MATCAP":"",B.envMap?"#define USE_ENVMAP":"",B.envMap?"#define "+U:"",B.envMap?"#define "+F:"",B.envMap?"#define "+R:"",D?"#define CUBEUV_TEXEL_WIDTH "+D.texelWidth:"",D?"#define CUBEUV_TEXEL_HEIGHT "+D.texelHeight:"",D?"#define CUBEUV_MAX_MIP "+D.maxMip+".0":"",B.lightMap?"#define USE_LIGHTMAP":"",B.aoMap?"#define USE_AOMAP":"",B.bumpMap?"#define USE_BUMPMAP":"",B.normalMap?"#define USE_NORMALMAP":"",B.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",B.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",B.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",B.emissiveMap?"#define USE_EMISSIVEMAP":"",B.anisotropy?"#define USE_ANISOTROPY":"",B.anisotropyMap?"#define USE_ANISOTROPYMAP":"",B.clearcoat?"#define USE_CLEARCOAT":"",B.clearcoatMap?"#define USE_CLEARCOATMAP":"",B.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",B.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",B.dispersion?"#define USE_DISPERSION":"",B.iridescence?"#define USE_IRIDESCENCE":"",B.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",B.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",B.specularMap?"#define USE_SPECULARMAP":"",B.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",B.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",B.roughnessMap?"#define USE_ROUGHNESSMAP":"",B.metalnessMap?"#define USE_METALNESSMAP":"",B.alphaMap?"#define USE_ALPHAMAP":"",B.alphaTest?"#define USE_ALPHATEST":"",B.alphaHash?"#define USE_ALPHAHASH":"",B.sheen?"#define USE_SHEEN":"",B.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",B.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",B.transmission?"#define USE_TRANSMISSION":"",B.transmissionMap?"#define USE_TRANSMISSIONMAP":"",B.thicknessMap?"#define USE_THICKNESSMAP":"",B.vertexTangents&&B.flatShading===!1?"#define USE_TANGENT":"",B.vertexColors||B.instancingColor?"#define USE_COLOR":"",B.vertexAlphas||B.batchingColor?"#define USE_COLOR_ALPHA":"",B.vertexUv1s?"#define USE_UV1":"",B.vertexUv2s?"#define USE_UV2":"",B.vertexUv3s?"#define USE_UV3":"",B.pointsUvs?"#define USE_POINTS_UV":"",B.gradientMap?"#define USE_GRADIENTMAP":"",B.flatShading?"#define FLAT_SHADED":"",B.doubleSided?"#define DOUBLE_SIDED":"",B.flipSided?"#define FLIP_SIDED":"",B.shadowMapEnabled?"#define USE_SHADOWMAP":"",B.shadowMapEnabled?"#define "+J:"",B.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",B.numLightProbes>0?"#define USE_LIGHT_PROBES":"",B.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",B.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",B.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",B.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",B.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",B.toneMapping!==AE?"#define TONE_MAPPING":"",B.toneMapping!==AE?YQ.tonemapping_pars_fragment:"",B.toneMapping!==AE?fZ("toneMapping",B.toneMapping):"",B.dithering?"#define DITHERING":"",B.opaque?"#define OPAQUE":"",YQ.colorspace_pars_fragment,SZ("linearToOutputTexel",B.outputColorSpace),yZ(),B.useDepthPacking?"#define DEPTH_PACKING "+B.depthPacking:"",` `].filter(xC).join(` `);if(G=tJ(G),G=mR(G,B),G=lR(G,B),K=tJ(K),K=mR(K,B),K=lR(K,B),G=cR(G),K=cR(K),B.isRawShaderMaterial!==!0)N=`#version 300 es `,Y=[H,"#define attribute in","#define varying out","#define texture2D texture"].join(` `)+` `+Y,q=["#define varying in",B.glslVersion===WJ?"":"layout(location = 0) out highp vec4 pc_fragColor;",B.glslVersion===WJ?"":"#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(` `)+` `+q;let $=N+Y+G,L=N+q+K,k=bR(I,I.VERTEX_SHADER,$),O=bR(I,I.FRAGMENT_SHADER,L);if(I.attachShader(X,k),I.attachShader(X,O),B.index0AttributeName!==void 0)I.bindAttribLocation(X,0,B.index0AttributeName);else if(B.morphTargets===!0)I.bindAttribLocation(X,0,"position");I.linkProgram(X);function w(_){if(A.debug.checkShaderErrors){let v=I.getProgramInfoLog(X)||"",x=I.getShaderInfoLog(k)||"",P=I.getShaderInfoLog(O)||"",j=v.trim(),g=x.trim(),f=P.trim(),p=!0,u=!0;if(I.getProgramParameter(X,I.LINK_STATUS)===!1)if(p=!1,typeof A.debug.onShaderError==="function")A.debug.onShaderError(I,X,k,O);else{let b=uR(I,k,"vertex"),t=uR(I,O,"fragment");CQ("THREE.WebGLProgram: Shader Error "+I.getError()+" - VALIDATE_STATUS "+I.getProgramParameter(X,I.VALIDATE_STATUS)+` Material Name: `+_.name+` Material Type: `+_.type+` Program Info Log: `+j+` `+b+` `+t)}else if(j!=="")mA("WebGLProgram: Program Info Log:",j);else if(g===""||f==="")u=!1;if(u)_.diagnostics={runnable:p,programLog:j,vertexShader:{log:g,prefix:Y},fragmentShader:{log:f,prefix:q}}}I.deleteShader(k),I.deleteShader(O),Z=new vC(I,X),z=xZ(I,X)}let Z;this.getUniforms=function(){if(Z===void 0)w(this);return Z};let z;this.getAttributes=function(){if(z===void 0)w(this);return z};let y=B.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){if(y===!1)y=I.getProgramParameter(X,zZ);return y},this.destroy=function(){E.releaseStatesOfProgram(this),I.deleteProgram(X),this.program=void 0},this.type=B.shaderType,this.name=B.shaderName,this.id=_Z++,this.cacheKey=Q,this.usedTimes=1,this.program=X,this.vertexShader=k,this.fragmentShader=O,this}var eZ=0;class CD{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(A){let{vertexShader:Q,fragmentShader:B}=A,E=this._getShaderStage(Q),I=this._getShaderStage(B),C=this._getShaderCacheForMaterial(A);if(C.has(E)===!1)C.add(E),E.usedTimes++;if(C.has(I)===!1)C.add(I),I.usedTimes++;return this}remove(A){let Q=this.materialCache.get(A);for(let B of Q)if(B.usedTimes--,B.usedTimes===0)this.shaderCache.delete(B.code);return this.materialCache.delete(A),this}getVertexShaderID(A){return this._getShaderStage(A.vertexShader).id}getFragmentShaderID(A){return this._getShaderStage(A.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(A){let Q=this.materialCache,B=Q.get(A);if(B===void 0)B=new Set,Q.set(A,B);return B}_getShaderStage(A){let Q=this.shaderCache,B=Q.get(A);if(B===void 0)B=new GD(A),Q.set(A,B);return B}}class GD{constructor(A){this.id=eZ++,this.code=A,this.usedTimes=0}}function AX(A){return A===jB||A===z0||A===_0}function QX(A,Q,B,E,I,C){let G=new OC,K=new CD,J=new Set,U=[],F=new Map,R=E.logarithmicDepthBuffer,D=E.precision,H={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function M(Z){if(J.add(Z),Z===0)return"uv";return`uv${Z}`}function X(Z,z,y,_,v,x){let P=_.fog,j=v.geometry,g=Z.isMeshStandardMaterial||Z.isMeshLambertMaterial||Z.isMeshPhongMaterial?_.environment:null,f=Z.isMeshStandardMaterial||Z.isMeshLambertMaterial&&!Z.envMap||Z.isMeshPhongMaterial&&!Z.envMap,p=Q.get(Z.envMap||g,f),u=!!p&&p.mapping===JC?p.image.height:null,b=H[Z.type];if(Z.precision!==null){if(D=E.getMaxPrecision(Z.precision),D!==Z.precision)mA("WebGLProgram.getParameters:",Z.precision,"not supported, using",D,"instead.")}let t=j.morphAttributes.position||j.morphAttributes.normal||j.morphAttributes.color,AA=t!==void 0?t.length:0,kA=0;if(j.morphAttributes.position!==void 0)kA=1;if(j.morphAttributes.normal!==void 0)kA=2;if(j.morphAttributes.color!==void 0)kA=3;let SA,l,QA,FA;if(b){let cA=YE[b];SA=cA.vertexShader,l=cA.fragmentShader}else SA=Z.vertexShader,l=Z.fragmentShader,K.update(Z),QA=K.getVertexShaderID(Z),FA=K.getFragmentShaderID(Z);let RA=A.getRenderTarget(),qA=A.state.buffers.depth.getReversed(),eA=v.isInstancedMesh===!0,tA=v.isBatchedMesh===!0,YA=!!Z.map,fA=!!Z.matcap,nA=!!p,yA=!!Z.aoMap,NA=!!Z.lightMap,hA=!!Z.bumpMap,iA=!!Z.normalMap,m=!!Z.displacementMap,LQ=!!Z.emissiveMap,QQ=!!Z.metalnessMap,JQ=!!Z.roughnessMap,WA=Z.anisotropy>0,RQ=Z.clearcoat>0,vA=Z.dispersion>0,h=Z.iridescence>0,V=Z.sheen>0,i=Z.transmission>0,GA=WA&&!!Z.anisotropyMap,HA=RQ&&!!Z.clearcoatMap,ZA=RQ&&!!Z.clearcoatNormalMap,zA=RQ&&!!Z.clearcoatRoughnessMap,EA=h&&!!Z.iridescenceMap,KA=h&&!!Z.iridescenceThicknessMap,VA=V&&!!Z.sheenColorMap,IA=V&&!!Z.sheenRoughnessMap,CA=!!Z.specularMap,XA=!!Z.specularColorMap,sA=!!Z.specularIntensityMap,BQ=i&&!!Z.transmissionMap,GQ=i&&!!Z.thicknessMap,c=!!Z.gradientMap,OA=!!Z.alphaMap,JA=Z.alphaTest>0,$A=!!Z.alphaHash,bA=!!Z.extensions,MA=AE;if(Z.toneMapped){if(RA===null||RA.isXRRenderTarget===!0)MA=A.toneMapping}let lA={shaderID:b,shaderType:Z.type,shaderName:Z.name,vertexShader:SA,fragmentShader:l,defines:Z.defines,customVertexShaderID:QA,customFragmentShaderID:FA,isRawShaderMaterial:Z.isRawShaderMaterial===!0,glslVersion:Z.glslVersion,precision:D,batching:tA,batchingColor:tA&&v._colorsTexture!==null,instancing:eA,instancingColor:eA&&v.instanceColor!==null,instancingMorph:eA&&v.morphTexture!==null,outputColorSpace:RA===null?A.outputColorSpace:RA.isXRRenderTarget===!0?RA.texture.colorSpace:qQ.workingColorSpace,alphaToCoverage:!!Z.alphaToCoverage,map:YA,matcap:fA,envMap:nA,envMapMode:nA&&p.mapping,envMapCubeUVHeight:u,aoMap:yA,lightMap:NA,bumpMap:hA,normalMap:iA,displacementMap:m,emissiveMap:LQ,normalMapObjectSpace:iA&&Z.normalMapType===KR,normalMapTangentSpace:iA&&Z.normalMapType===LJ,packedNormalMap:iA&&Z.normalMapType===LJ&&AX(Z.normalMap.format),metalnessMap:QQ,roughnessMap:JQ,anisotropy:WA,anisotropyMap:GA,clearcoat:RQ,clearcoatMap:HA,clearcoatNormalMap:ZA,clearcoatRoughnessMap:zA,dispersion:vA,iridescence:h,iridescenceMap:EA,iridescenceThicknessMap:KA,sheen:V,sheenColorMap:VA,sheenRoughnessMap:IA,specularMap:CA,specularColorMap:XA,specularIntensityMap:sA,transmission:i,transmissionMap:BQ,thicknessMap:GQ,gradientMap:c,opaque:Z.transparent===!1&&Z.blending===KC&&Z.alphaToCoverage===!1,alphaMap:OA,alphaTest:JA,alphaHash:$A,combine:Z.combine,mapUv:YA&&M(Z.map.channel),aoMapUv:yA&&M(Z.aoMap.channel),lightMapUv:NA&&M(Z.lightMap.channel),bumpMapUv:hA&&M(Z.bumpMap.channel),normalMapUv:iA&&M(Z.normalMap.channel),displacementMapUv:m&&M(Z.displacementMap.channel),emissiveMapUv:LQ&&M(Z.emissiveMap.channel),metalnessMapUv:QQ&&M(Z.metalnessMap.channel),roughnessMapUv:JQ&&M(Z.roughnessMap.channel),anisotropyMapUv:GA&&M(Z.anisotropyMap.channel),clearcoatMapUv:HA&&M(Z.clearcoatMap.channel),clearcoatNormalMapUv:ZA&&M(Z.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:zA&&M(Z.clearcoatRoughnessMap.channel),iridescenceMapUv:EA&&M(Z.iridescenceMap.channel),iridescenceThicknessMapUv:KA&&M(Z.iridescenceThicknessMap.channel),sheenColorMapUv:VA&&M(Z.sheenColorMap.channel),sheenRoughnessMapUv:IA&&M(Z.sheenRoughnessMap.channel),specularMapUv:CA&&M(Z.specularMap.channel),specularColorMapUv:XA&&M(Z.specularColorMap.channel),specularIntensityMapUv:sA&&M(Z.specularIntensityMap.channel),transmissionMapUv:BQ&&M(Z.transmissionMap.channel),thicknessMapUv:GQ&&M(Z.thicknessMap.channel),alphaMapUv:OA&&M(Z.alphaMap.channel),vertexTangents:!!j.attributes.tangent&&(iA||WA),vertexNormals:!!j.attributes.normal,vertexColors:Z.vertexColors,vertexAlphas:Z.vertexColors===!0&&!!j.attributes.color&&j.attributes.color.itemSize===4,pointsUvs:v.isPoints===!0&&!!j.attributes.uv&&(YA||OA),fog:!!P,useFog:Z.fog===!0,fogExp2:!!P&&P.isFogExp2,flatShading:Z.wireframe===!1&&(Z.flatShading===!0||j.attributes.normal===void 0&&iA===!1&&(Z.isMeshLambertMaterial||Z.isMeshPhongMaterial||Z.isMeshStandardMaterial||Z.isMeshPhysicalMaterial)),sizeAttenuation:Z.sizeAttenuation===!0,logarithmicDepthBuffer:R,reversedDepthBuffer:qA,skinning:v.isSkinnedMesh===!0,morphTargets:j.morphAttributes.position!==void 0,morphNormals:j.morphAttributes.normal!==void 0,morphColors:j.morphAttributes.color!==void 0,morphTargetsCount:AA,morphTextureStride:kA,numDirLights:z.directional.length,numPointLights:z.point.length,numSpotLights:z.spot.length,numSpotLightMaps:z.spotLightMap.length,numRectAreaLights:z.rectArea.length,numHemiLights:z.hemi.length,numDirLightShadows:z.directionalShadowMap.length,numPointLightShadows:z.pointShadowMap.length,numSpotLightShadows:z.spotShadowMap.length,numSpotLightShadowsWithMaps:z.numSpotLightShadowsWithMaps,numLightProbes:z.numLightProbes,numLightProbeGrids:x.length,numClippingPlanes:C.numPlanes,numClipIntersection:C.numIntersection,dithering:Z.dithering,shadowMapEnabled:A.shadowMap.enabled&&y.length>0,shadowMapType:A.shadowMap.type,toneMapping:MA,decodeVideoTexture:YA&&Z.map.isVideoTexture===!0&&qQ.getTransfer(Z.map.colorSpace)===jQ,decodeVideoTextureEmissive:LQ&&Z.emissiveMap.isVideoTexture===!0&&qQ.getTransfer(Z.emissiveMap.colorSpace)===jQ,premultipliedAlpha:Z.premultipliedAlpha,doubleSided:Z.side===mB,flipSided:Z.side===iQ,useDepthPacking:Z.depthPacking>=0,depthPacking:Z.depthPacking||0,index0AttributeName:Z.index0AttributeName,extensionClipCullDistance:bA&&Z.extensions.clipCullDistance===!0&&B.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(bA&&Z.extensions.multiDraw===!0||tA)&&B.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:B.has("KHR_parallel_shader_compile"),customProgramCacheKey:Z.customProgramCacheKey()};return lA.vertexUv1s=J.has(1),lA.vertexUv2s=J.has(2),lA.vertexUv3s=J.has(3),J.clear(),lA}function Y(Z){let z=[];if(Z.shaderID)z.push(Z.shaderID);else z.push(Z.customVertexShaderID),z.push(Z.customFragmentShaderID);if(Z.defines!==void 0)for(let y in Z.defines)z.push(y),z.push(Z.defines[y]);if(Z.isRawShaderMaterial===!1)q(z,Z),N(z,Z),z.push(A.outputColorSpace);return z.push(Z.customProgramCacheKey),z.join()}function q(Z,z){Z.push(z.precision),Z.push(z.outputColorSpace),Z.push(z.envMapMode),Z.push(z.envMapCubeUVHeight),Z.push(z.mapUv),Z.push(z.alphaMapUv),Z.push(z.lightMapUv),Z.push(z.aoMapUv),Z.push(z.bumpMapUv),Z.push(z.normalMapUv),Z.push(z.displacementMapUv),Z.push(z.emissiveMapUv),Z.push(z.metalnessMapUv),Z.push(z.roughnessMapUv),Z.push(z.anisotropyMapUv),Z.push(z.clearcoatMapUv),Z.push(z.clearcoatNormalMapUv),Z.push(z.clearcoatRoughnessMapUv),Z.push(z.iridescenceMapUv),Z.push(z.iridescenceThicknessMapUv),Z.push(z.sheenColorMapUv),Z.push(z.sheenRoughnessMapUv),Z.push(z.specularMapUv),Z.push(z.specularColorMapUv),Z.push(z.specularIntensityMapUv),Z.push(z.transmissionMapUv),Z.push(z.thicknessMapUv),Z.push(z.combine),Z.push(z.fogExp2),Z.push(z.sizeAttenuation),Z.push(z.morphTargetsCount),Z.push(z.morphAttributeCount),Z.push(z.numDirLights),Z.push(z.numPointLights),Z.push(z.numSpotLights),Z.push(z.numSpotLightMaps),Z.push(z.numHemiLights),Z.push(z.numRectAreaLights),Z.push(z.numDirLightShadows),Z.push(z.numPointLightShadows),Z.push(z.numSpotLightShadows),Z.push(z.numSpotLightShadowsWithMaps),Z.push(z.numLightProbes),Z.push(z.shadowMapType),Z.push(z.toneMapping),Z.push(z.numClippingPlanes),Z.push(z.numClipIntersection),Z.push(z.depthPacking)}function N(Z,z){if(G.disableAll(),z.instancing)G.enable(0);if(z.instancingColor)G.enable(1);if(z.instancingMorph)G.enable(2);if(z.matcap)G.enable(3);if(z.envMap)G.enable(4);if(z.normalMapObjectSpace)G.enable(5);if(z.normalMapTangentSpace)G.enable(6);if(z.clearcoat)G.enable(7);if(z.iridescence)G.enable(8);if(z.alphaTest)G.enable(9);if(z.vertexColors)G.enable(10);if(z.vertexAlphas)G.enable(11);if(z.vertexUv1s)G.enable(12);if(z.vertexUv2s)G.enable(13);if(z.vertexUv3s)G.enable(14);if(z.vertexTangents)G.enable(15);if(z.anisotropy)G.enable(16);if(z.alphaHash)G.enable(17);if(z.batching)G.enable(18);if(z.dispersion)G.enable(19);if(z.batchingColor)G.enable(20);if(z.gradientMap)G.enable(21);if(z.packedNormalMap)G.enable(22);if(z.vertexNormals)G.enable(23);if(Z.push(G.mask),G.disableAll(),z.fog)G.enable(0);if(z.useFog)G.enable(1);if(z.flatShading)G.enable(2);if(z.logarithmicDepthBuffer)G.enable(3);if(z.reversedDepthBuffer)G.enable(4);if(z.skinning)G.enable(5);if(z.morphTargets)G.enable(6);if(z.morphNormals)G.enable(7);if(z.morphColors)G.enable(8);if(z.premultipliedAlpha)G.enable(9);if(z.shadowMapEnabled)G.enable(10);if(z.doubleSided)G.enable(11);if(z.flipSided)G.enable(12);if(z.useDepthPacking)G.enable(13);if(z.dithering)G.enable(14);if(z.transmission)G.enable(15);if(z.sheen)G.enable(16);if(z.opaque)G.enable(17);if(z.pointsUvs)G.enable(18);if(z.decodeVideoTexture)G.enable(19);if(z.decodeVideoTextureEmissive)G.enable(20);if(z.alphaToCoverage)G.enable(21);if(z.numLightProbeGrids>0)G.enable(22);Z.push(G.mask)}function $(Z){let z=H[Z.type],y;if(z){let _=YE[z];y=XR.clone(_.uniforms)}else y=Z.uniforms;return y}function L(Z,z){let y=F.get(z);if(y!==void 0)++y.usedTimes;else y=new tZ(A,z,Z,I),U.push(y),F.set(z,y);return y}function k(Z){if(--Z.usedTimes===0){let z=U.indexOf(Z);U[z]=U[U.length-1],U.pop(),F.delete(Z.cacheKey),Z.destroy()}}function O(Z){K.remove(Z)}function w(){K.dispose()}return{getParameters:X,getProgramCacheKey:Y,getUniforms:$,acquireProgram:L,releaseProgram:k,releaseShaderCache:O,programs:U,dispose:w}}function BX(){let A=new WeakMap;function Q(G){return A.has(G)}function B(G){let K=A.get(G);if(K===void 0)K={},A.set(G,K);return K}function E(G){A.delete(G)}function I(G,K,J){A.get(G)[K]=J}function C(){A=new WeakMap}return{has:Q,get:B,remove:E,update:I,dispose:C}}function EX(A,Q){if(A.groupOrder!==Q.groupOrder)return A.groupOrder-Q.groupOrder;else if(A.renderOrder!==Q.renderOrder)return A.renderOrder-Q.renderOrder;else if(A.material.id!==Q.material.id)return A.material.id-Q.material.id;else if(A.materialVariant!==Q.materialVariant)return A.materialVariant-Q.materialVariant;else if(A.z!==Q.z)return A.z-Q.z;else return A.id-Q.id}function nR(A,Q){if(A.groupOrder!==Q.groupOrder)return A.groupOrder-Q.groupOrder;else if(A.renderOrder!==Q.renderOrder)return A.renderOrder-Q.renderOrder;else if(A.z!==Q.z)return Q.z-A.z;else return A.id-Q.id}function sR(){let A=[],Q=0,B=[],E=[],I=[];function C(){Q=0,B.length=0,E.length=0,I.length=0}function G(D){let H=0;if(D.isInstancedMesh)H+=2;if(D.isSkinnedMesh)H+=1;return H}function K(D,H,M,X,Y,q){let N=A[Q];if(N===void 0)N={id:D.id,object:D,geometry:H,material:M,materialVariant:G(D),groupOrder:X,renderOrder:D.renderOrder,z:Y,group:q},A[Q]=N;else N.id=D.id,N.object=D,N.geometry=H,N.material=M,N.materialVariant=G(D),N.groupOrder=X,N.renderOrder=D.renderOrder,N.z=Y,N.group=q;return Q++,N}function J(D,H,M,X,Y,q){let N=K(D,H,M,X,Y,q);if(M.transmission>0)E.push(N);else if(M.transparent===!0)I.push(N);else B.push(N)}function U(D,H,M,X,Y,q){let N=K(D,H,M,X,Y,q);if(M.transmission>0)E.unshift(N);else if(M.transparent===!0)I.unshift(N);else B.unshift(N)}function F(D,H){if(B.length>1)B.sort(D||EX);if(E.length>1)E.sort(H||nR);if(I.length>1)I.sort(H||nR)}function R(){for(let D=Q,H=A.length;D=C.length)G=new sR,C.push(G);else G=C[I];return G}function B(){A=new WeakMap}return{get:Q,dispose:B}}function CX(){let A={};return{get:function(Q){if(A[Q.id]!==void 0)return A[Q.id];let B;switch(Q.type){case"DirectionalLight":B={direction:new d,color:new AQ};break;case"SpotLight":B={position:new d,direction:new d,color:new AQ,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":B={position:new d,color:new AQ,distance:0,decay:0};break;case"HemisphereLight":B={direction:new d,skyColor:new AQ,groundColor:new AQ};break;case"RectAreaLight":B={color:new AQ,position:new d,halfWidth:new d,halfHeight:new d};break}return A[Q.id]=B,B}}}function GX(){let A={};return{get:function(Q){if(A[Q.id]!==void 0)return A[Q.id];let B;switch(Q.type){case"DirectionalLight":B={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new LA};break;case"SpotLight":B={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new LA};break;case"PointLight":B={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new LA,shadowCameraNear:1,shadowCameraFar:1000};break}return A[Q.id]=B,B}}}var KX=0;function JX(A,Q){return(Q.castShadow?2:0)-(A.castShadow?2:0)+(Q.map?1:0)-(A.map?1:0)}function UX(A){let Q=new CX,B=GX(),E={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let U=0;U<9;U++)E.probe.push(new d);let I=new d,C=new HQ,G=new HQ;function K(U){let F=0,R=0,D=0;for(let z=0;z<9;z++)E.probe[z].set(0,0,0);let H=0,M=0,X=0,Y=0,q=0,N=0,$=0,L=0,k=0,O=0,w=0;U.sort(JX);for(let z=0,y=U.length;z0)if(A.has("OES_texture_float_linear")===!0)E.rectAreaLTC1=jA.LTC_FLOAT_1,E.rectAreaLTC2=jA.LTC_FLOAT_2;else E.rectAreaLTC1=jA.LTC_HALF_1,E.rectAreaLTC2=jA.LTC_HALF_2;E.ambient[0]=F,E.ambient[1]=R,E.ambient[2]=D;let Z=E.hash;if(Z.directionalLength!==H||Z.pointLength!==M||Z.spotLength!==X||Z.rectAreaLength!==Y||Z.hemiLength!==q||Z.numDirectionalShadows!==N||Z.numPointShadows!==$||Z.numSpotShadows!==L||Z.numSpotMaps!==k||Z.numLightProbes!==w)E.directional.length=H,E.spot.length=X,E.rectArea.length=Y,E.point.length=M,E.hemi.length=q,E.directionalShadow.length=N,E.directionalShadowMap.length=N,E.pointShadow.length=$,E.pointShadowMap.length=$,E.spotShadow.length=L,E.spotShadowMap.length=L,E.directionalShadowMatrix.length=N,E.pointShadowMatrix.length=$,E.spotLightMatrix.length=L+k-O,E.spotLightMap.length=k,E.numSpotLightShadowsWithMaps=O,E.numLightProbes=w,Z.directionalLength=H,Z.pointLength=M,Z.spotLength=X,Z.rectAreaLength=Y,Z.hemiLength=q,Z.numDirectionalShadows=N,Z.numPointShadows=$,Z.numSpotShadows=L,Z.numSpotMaps=k,Z.numLightProbes=w,E.version=KX++}function J(U,F){let R=0,D=0,H=0,M=0,X=0,Y=F.matrixWorldInverse;for(let q=0,N=U.length;q=G.length)K=new iR(A),G.push(K);else K=G[C];return K}function E(){Q=new WeakMap}return{get:B,dispose:E}}var RX=`void main() { gl_Position = vec4( position, 1.0 ); }`,DX=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; void main() { const float samples = float( VSM_SAMPLES ); float mean = 0.0; float squared_mean = 0.0; float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); float uvStart = samples <= 1.0 ? 0.0 : - 1.0; for ( float i = 0.0; i < samples; i ++ ) { float uvOffset = uvStart + i * uvStride; #ifdef HORIZONTAL_PASS vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; mean += distribution.x; squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; #else float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; mean += depth; squared_mean += depth * depth; #endif } mean = mean / samples; squared_mean = squared_mean / samples; float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) ); gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 ); }`,HX=[new d(1,0,0),new d(-1,0,0),new d(0,1,0),new d(0,-1,0),new d(0,0,1),new d(0,0,-1)],YX=[new d(0,-1,0),new d(0,-1,0),new d(0,0,1),new d(0,0,-1),new d(0,-1,0),new d(0,-1,0)],oR=new HQ,hC=new d,oJ=new d;function qX(A,Q,B){let E=new _C,I=new LA,C=new LA,G=new SQ,K=new PJ,J=new TJ,U={},F=B.maxTextureSize,R={[GB]:iQ,[iQ]:GB,[mB]:mB},D=new hQ({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new LA},radius:{value:4}},vertexShader:RX,fragmentShader:DX}),H=D.clone();H.defines.HORIZONTAL_PASS=1;let M=new JB;M.setAttribute("position",new rQ(new Float32Array([-1,-1,0.5,3,-1,0.5,-1,3,0.5]),3));let X=new _Q(M,D),Y=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=GC;let q=this.type;this.render=function(O,w,Z){if(Y.enabled===!1)return;if(Y.autoUpdate===!1&&Y.needsUpdate===!1)return;if(O.length===0)return;if(this.type===zF)mA("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=GC;let z=A.getRenderTarget(),y=A.getActiveCubeFace(),_=A.getActiveMipmapLevel(),v=A.state;if(v.setBlending(UE),v.buffers.depth.getReversed()===!0)v.buffers.color.setClear(0,0,0,0);else v.buffers.color.setClear(1,1,1,1);v.buffers.depth.setTest(!0),v.setScissorTest(!1);let x=q!==this.type;if(x)w.traverse(function(P){if(P.material)if(Array.isArray(P.material))P.material.forEach((j)=>j.needsUpdate=!0);else P.material.needsUpdate=!0});for(let P=0,j=O.length;PF||I.y>F){if(I.x>F)C.x=Math.floor(F/p.x),I.x=C.x*p.x,f.mapSize.x=C.x;if(I.y>F)C.y=Math.floor(F/p.y),I.y=C.y*p.y,f.mapSize.y=C.y}let u=A.state.buffers.depth.getReversed();if(f.camera._reversedDepth=u,f.map===null||x===!0){if(f.map!==null){if(f.map.depthTexture!==null)f.map.depthTexture.dispose(),f.map.depthTexture=null;f.map.dispose()}if(this.type===M0){if(g.isPointLight){mA("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}f.map=new lQ(I.x,I.y,{format:jB,type:KB,minFilter:VQ,magFilter:VQ,generateMipmaps:!1}),f.map.texture.name=g.name+".shadowMap",f.map.depthTexture=new JI(I.x,I.y,NB),f.map.depthTexture.name=g.name+".shadowMapDepth",f.map.depthTexture.format=PI,f.map.depthTexture.compareFunction=null,f.map.depthTexture.minFilter=WB,f.map.depthTexture.magFilter=WB}else{if(g.isPointLight)f.map=new eJ(I.x),f.map.depthTexture=new wJ(I.x,EI);else f.map=new lQ(I.x,I.y),f.map.depthTexture=new JI(I.x,I.y,EI);if(f.map.depthTexture.name=g.name+".shadowMap",f.map.depthTexture.format=PI,this.type===GC)f.map.depthTexture.compareFunction=u?c8:l8,f.map.depthTexture.minFilter=VQ,f.map.depthTexture.magFilter=VQ;else f.map.depthTexture.compareFunction=null,f.map.depthTexture.minFilter=WB,f.map.depthTexture.magFilter=WB}f.camera.updateProjectionMatrix()}let b=f.map.isWebGLCubeRenderTarget?6:1;for(let t=0;t0||w.map&&w.alphaTest>0||w.alphaToCoverage===!0){let v=y.uuid,x=w.uuid,P=U[v];if(P===void 0)P={},U[v]=P;let j=P[x];if(j===void 0)j=y.clone(),P[x]=j,w.addEventListener("dispose",k);y=j}if(y.visible=w.visible,y.wireframe=w.wireframe,z===M0)y.side=w.shadowSide!==null?w.shadowSide:w.side;else y.side=w.shadowSide!==null?w.shadowSide:R[w.side];if(y.alphaMap=w.alphaMap,y.alphaTest=w.alphaToCoverage===!0?0.5:w.alphaTest,y.map=w.map,y.clipShadows=w.clipShadows,y.clippingPlanes=w.clippingPlanes,y.clipIntersection=w.clipIntersection,y.displacementMap=w.displacementMap,y.displacementScale=w.displacementScale,y.displacementBias=w.displacementBias,y.wireframeLinewidth=w.wireframeLinewidth,y.linewidth=w.linewidth,Z.isPointLight===!0&&y.isMeshDistanceMaterial===!0){let v=A.properties.get(y);v.light=Z}return y}function L(O,w,Z,z,y){if(O.visible===!1)return;if(O.layers.test(w.layers)&&(O.isMesh||O.isLine||O.isPoints)){if((O.castShadow||O.receiveShadow&&y===M0)&&(!O.frustumCulled||E.intersectsObject(O))){O.modelViewMatrix.multiplyMatrices(Z.matrixWorldInverse,O.matrixWorld);let x=Q.update(O),P=O.material;if(Array.isArray(P)){let j=x.groups;for(let g=0,f=j.length;g=1;else if(u.indexOf("OpenGL ES")!==-1)p=parseFloat(/^OpenGL ES (\d)/.exec(u)[1]),f=p>=2;let b=null,t={},AA=A.getParameter(A.SCISSOR_BOX),kA=A.getParameter(A.VIEWPORT),SA=new SQ().fromArray(AA),l=new SQ().fromArray(kA);function QA(c,OA,JA,$A){let bA=new Uint8Array(4),MA=A.createTexture();A.bindTexture(c,MA),A.texParameteri(c,A.TEXTURE_MIN_FILTER,A.NEAREST),A.texParameteri(c,A.TEXTURE_MAG_FILTER,A.NEAREST);for(let lA=0;lA"u"?!1:/OculusBrowser/g.test(navigator.userAgent),U=new LA,F=new WeakMap,R=new Set,D,H=new WeakMap,M=!1;try{M=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(h){}function X(h,V){return M?new OffscreenCanvas(h,V):Y0("canvas")}function Y(h,V,i){let GA=1,HA=vA(h);if(HA.width>i||HA.height>i)GA=i/Math.max(HA.width,HA.height);if(GA<1)if(typeof HTMLImageElement<"u"&&h instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&h instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&h instanceof ImageBitmap||typeof VideoFrame<"u"&&h instanceof VideoFrame){let ZA=Math.floor(GA*HA.width),zA=Math.floor(GA*HA.height);if(D===void 0)D=X(ZA,zA);let EA=V?X(ZA,zA):D;return EA.width=ZA,EA.height=zA,EA.getContext("2d").drawImage(h,0,0,ZA,zA),mA("WebGLRenderer: Texture has been resized from ("+HA.width+"x"+HA.height+") to ("+ZA+"x"+zA+")."),EA}else{if("data"in h)mA("WebGLRenderer: Image in DataTexture is too big ("+HA.width+"x"+HA.height+").");return h}return h}function q(h){return h.generateMipmaps}function N(h){A.generateMipmap(h)}function $(h){if(h.isWebGLCubeRenderTarget)return A.TEXTURE_CUBE_MAP;if(h.isWebGL3DRenderTarget)return A.TEXTURE_3D;if(h.isWebGLArrayRenderTarget||h.isCompressedArrayTexture)return A.TEXTURE_2D_ARRAY;return A.TEXTURE_2D}function L(h,V,i,GA,HA,ZA=!1){if(h!==null){if(A[h]!==void 0)return A[h];mA("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+h+"'")}let zA;if(GA){if(zA=Q.get("EXT_texture_norm16"),!zA)mA("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")}let EA=V;if(V===A.RED){if(i===A.FLOAT)EA=A.R32F;if(i===A.HALF_FLOAT)EA=A.R16F;if(i===A.UNSIGNED_BYTE)EA=A.R8;if(i===A.UNSIGNED_SHORT&&zA)EA=zA.R16_EXT;if(i===A.SHORT&&zA)EA=zA.R16_SNORM_EXT}if(V===A.RED_INTEGER){if(i===A.UNSIGNED_BYTE)EA=A.R8UI;if(i===A.UNSIGNED_SHORT)EA=A.R16UI;if(i===A.UNSIGNED_INT)EA=A.R32UI;if(i===A.BYTE)EA=A.R8I;if(i===A.SHORT)EA=A.R16I;if(i===A.INT)EA=A.R32I}if(V===A.RG){if(i===A.FLOAT)EA=A.RG32F;if(i===A.HALF_FLOAT)EA=A.RG16F;if(i===A.UNSIGNED_BYTE)EA=A.RG8;if(i===A.UNSIGNED_SHORT&&zA)EA=zA.RG16_EXT;if(i===A.SHORT&&zA)EA=zA.RG16_SNORM_EXT}if(V===A.RG_INTEGER){if(i===A.UNSIGNED_BYTE)EA=A.RG8UI;if(i===A.UNSIGNED_SHORT)EA=A.RG16UI;if(i===A.UNSIGNED_INT)EA=A.RG32UI;if(i===A.BYTE)EA=A.RG8I;if(i===A.SHORT)EA=A.RG16I;if(i===A.INT)EA=A.RG32I}if(V===A.RGB_INTEGER){if(i===A.UNSIGNED_BYTE)EA=A.RGB8UI;if(i===A.UNSIGNED_SHORT)EA=A.RGB16UI;if(i===A.UNSIGNED_INT)EA=A.RGB32UI;if(i===A.BYTE)EA=A.RGB8I;if(i===A.SHORT)EA=A.RGB16I;if(i===A.INT)EA=A.RGB32I}if(V===A.RGBA_INTEGER){if(i===A.UNSIGNED_BYTE)EA=A.RGBA8UI;if(i===A.UNSIGNED_SHORT)EA=A.RGBA16UI;if(i===A.UNSIGNED_INT)EA=A.RGBA32UI;if(i===A.BYTE)EA=A.RGBA8I;if(i===A.SHORT)EA=A.RGBA16I;if(i===A.INT)EA=A.RGBA32I}if(V===A.RGB){if(i===A.UNSIGNED_SHORT&&zA)EA=zA.RGB16_EXT;if(i===A.SHORT&&zA)EA=zA.RGB16_SNORM_EXT;if(i===A.UNSIGNED_INT_5_9_9_9_REV)EA=A.RGB9_E5;if(i===A.UNSIGNED_INT_10F_11F_11F_REV)EA=A.R11F_G11F_B10F}if(V===A.RGBA){let KA=ZA?m8:qQ.getTransfer(HA);if(i===A.FLOAT)EA=A.RGBA32F;if(i===A.HALF_FLOAT)EA=A.RGBA16F;if(i===A.UNSIGNED_BYTE)EA=KA===jQ?A.SRGB8_ALPHA8:A.RGBA8;if(i===A.UNSIGNED_SHORT&&zA)EA=zA.RGBA16_EXT;if(i===A.SHORT&&zA)EA=zA.RGBA16_SNORM_EXT;if(i===A.UNSIGNED_SHORT_4_4_4_4)EA=A.RGBA4;if(i===A.UNSIGNED_SHORT_5_5_5_1)EA=A.RGB5_A1}if(EA===A.R16F||EA===A.R32F||EA===A.RG16F||EA===A.RG32F||EA===A.RGBA16F||EA===A.RGBA32F)Q.get("EXT_color_buffer_float");return EA}function k(h,V){let i;if(h){if(V===null||V===EI||V===$0)i=A.DEPTH24_STENCIL8;else if(V===NB)i=A.DEPTH32F_STENCIL8;else if(V===BI)i=A.DEPTH24_STENCIL8,mA("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")}else if(V===null||V===EI||V===$0)i=A.DEPTH_COMPONENT24;else if(V===NB)i=A.DEPTH_COMPONENT32F;else if(V===BI)i=A.DEPTH_COMPONENT16;return i}function O(h,V){if(q(h)===!0||h.isFramebufferTexture&&h.minFilter!==WB&&h.minFilter!==VQ)return Math.log2(Math.max(V.width,V.height))+1;else if(h.mipmaps!==void 0&&h.mipmaps.length>0)return h.mipmaps.length;else if(h.isCompressedTexture&&Array.isArray(h.image))return V.mipmaps.length;else return 1}function w(h){let V=h.target;if(V.removeEventListener("dispose",w),z(V),V.isVideoTexture)F.delete(V);if(V.isHTMLTexture)R.delete(V)}function Z(h){let V=h.target;V.removeEventListener("dispose",Z),_(V)}function z(h){let V=E.get(h);if(V.__webglInit===void 0)return;let i=h.source,GA=H.get(i);if(GA){let HA=GA[V.__cacheKey];if(HA.usedTimes--,HA.usedTimes===0)y(h);if(Object.keys(GA).length===0)H.delete(i)}E.remove(h)}function y(h){let V=E.get(h);A.deleteTexture(V.__webglTexture);let i=h.source,GA=H.get(i);delete GA[V.__cacheKey],G.memory.textures--}function _(h){let V=E.get(h);if(h.depthTexture)h.depthTexture.dispose(),E.remove(h.depthTexture);if(h.isWebGLCubeRenderTarget)for(let GA=0;GA<6;GA++){if(Array.isArray(V.__webglFramebuffer[GA]))for(let HA=0;HA=I.maxTextures)mA("WebGLTextures: Trying to use "+h+" texture units while this GPU supports only "+I.maxTextures);return v+=1,h}function f(h){let V=[];return V.push(h.wrapS),V.push(h.wrapT),V.push(h.wrapR||0),V.push(h.magFilter),V.push(h.minFilter),V.push(h.anisotropy),V.push(h.internalFormat),V.push(h.format),V.push(h.type),V.push(h.generateMipmaps),V.push(h.premultiplyAlpha),V.push(h.flipY),V.push(h.unpackAlignment),V.push(h.colorSpace),V.join()}function p(h,V){let i=E.get(h);if(h.isVideoTexture)WA(h);if(h.isRenderTargetTexture===!1&&h.isExternalTexture!==!0&&h.version>0&&i.__version!==h.version){let GA=h.image;if(GA===null)mA("WebGLRenderer: Texture marked for update but no image data found.");else if(GA.complete===!1)mA("WebGLRenderer: Texture marked for update but image is incomplete");else{qA(i,h,V);return}}else if(h.isExternalTexture)i.__webglTexture=h.sourceTexture?h.sourceTexture:null;B.bindTexture(A.TEXTURE_2D,i.__webglTexture,A.TEXTURE0+V)}function u(h,V){let i=E.get(h);if(h.isRenderTargetTexture===!1&&h.version>0&&i.__version!==h.version){qA(i,h,V);return}else if(h.isExternalTexture)i.__webglTexture=h.sourceTexture?h.sourceTexture:null;B.bindTexture(A.TEXTURE_2D_ARRAY,i.__webglTexture,A.TEXTURE0+V)}function b(h,V){let i=E.get(h);if(h.isRenderTargetTexture===!1&&h.version>0&&i.__version!==h.version){qA(i,h,V);return}B.bindTexture(A.TEXTURE_3D,i.__webglTexture,A.TEXTURE0+V)}function t(h,V){let i=E.get(h);if(h.isCubeDepthTexture!==!0&&h.version>0&&i.__version!==h.version){eA(i,h,V);return}B.bindTexture(A.TEXTURE_CUBE_MAP,i.__webglTexture,A.TEXTURE0+V)}let AA={[TB]:A.REPEAT,[X0]:A.CLAMP_TO_EDGE,[b8]:A.MIRRORED_REPEAT},kA={[WB]:A.NEAREST,[L0]:A.NEAREST_MIPMAP_NEAREST,[_I]:A.NEAREST_MIPMAP_LINEAR,[VQ]:A.LINEAR,[W0]:A.LINEAR_MIPMAP_NEAREST,[SB]:A.LINEAR_MIPMAP_LINEAR},SA={[JR]:A.NEVER,[HR]:A.ALWAYS,[UR]:A.LESS,[l8]:A.LEQUAL,[FR]:A.EQUAL,[c8]:A.GEQUAL,[RR]:A.GREATER,[DR]:A.NOTEQUAL};function l(h,V){if(V.type===NB&&Q.has("OES_texture_float_linear")===!1&&(V.magFilter===VQ||V.magFilter===W0||V.magFilter===_I||V.magFilter===SB||V.minFilter===VQ||V.minFilter===W0||V.minFilter===_I||V.minFilter===SB))mA("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device.");if(A.texParameteri(h,A.TEXTURE_WRAP_S,AA[V.wrapS]),A.texParameteri(h,A.TEXTURE_WRAP_T,AA[V.wrapT]),h===A.TEXTURE_3D||h===A.TEXTURE_2D_ARRAY)A.texParameteri(h,A.TEXTURE_WRAP_R,AA[V.wrapR]);if(A.texParameteri(h,A.TEXTURE_MAG_FILTER,kA[V.magFilter]),A.texParameteri(h,A.TEXTURE_MIN_FILTER,kA[V.minFilter]),V.compareFunction)A.texParameteri(h,A.TEXTURE_COMPARE_MODE,A.COMPARE_REF_TO_TEXTURE),A.texParameteri(h,A.TEXTURE_COMPARE_FUNC,SA[V.compareFunction]);if(Q.has("EXT_texture_filter_anisotropic")===!0){if(V.magFilter===WB)return;if(V.minFilter!==_I&&V.minFilter!==SB)return;if(V.type===NB&&Q.has("OES_texture_float_linear")===!1)return;if(V.anisotropy>1||E.get(V).__currentAnisotropy){let i=Q.get("EXT_texture_filter_anisotropic");A.texParameterf(h,i.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(V.anisotropy,I.getMaxAnisotropy())),E.get(V).__currentAnisotropy=V.anisotropy}}}function QA(h,V){let i=!1;if(h.__webglInit===void 0)h.__webglInit=!0,V.addEventListener("dispose",w);let GA=V.source,HA=H.get(GA);if(HA===void 0)HA={},H.set(GA,HA);let ZA=f(V);if(ZA!==h.__cacheKey){if(HA[ZA]===void 0)HA[ZA]={texture:A.createTexture(),usedTimes:0},G.memory.textures++,i=!0;HA[ZA].usedTimes++;let zA=HA[h.__cacheKey];if(zA!==void 0){if(HA[h.__cacheKey].usedTimes--,zA.usedTimes===0)y(V)}h.__cacheKey=ZA,h.__webglTexture=HA[ZA].texture}return i}function FA(h,V,i){return Math.floor(Math.floor(h/i)/V)}function RA(h,V,i,GA){let ZA=h.updateRanges;if(ZA.length===0)B.texSubImage2D(A.TEXTURE_2D,0,0,0,V.width,V.height,i,GA,V.data);else{ZA.sort((IA,CA)=>IA.start-CA.start);let zA=0;for(let IA=1;IA0){if(BQ&&GQ)B.texStorage2D(A.TEXTURE_2D,OA,CA,sA[0].width,sA[0].height);for(let JA=0,$A=sA.length;JA<$A;JA++)if(XA=sA[JA],BQ){if(c)B.texSubImage2D(A.TEXTURE_2D,JA,0,0,XA.width,XA.height,VA,IA,XA.data)}else B.texImage2D(A.TEXTURE_2D,JA,CA,XA.width,XA.height,0,VA,IA,XA.data);V.generateMipmaps=!1}else if(BQ){if(GQ)B.texStorage2D(A.TEXTURE_2D,OA,CA,KA.width,KA.height);if(c)RA(V,KA,VA,IA)}else B.texImage2D(A.TEXTURE_2D,0,CA,KA.width,KA.height,0,VA,IA,KA.data);else if(V.isCompressedTexture)if(V.isCompressedArrayTexture){if(BQ&&GQ)B.texStorage3D(A.TEXTURE_2D_ARRAY,OA,CA,sA[0].width,sA[0].height,KA.depth);for(let JA=0,$A=sA.length;JA<$A;JA++)if(XA=sA[JA],V.format!==BB)if(VA!==null)if(BQ){if(c)if(V.layerUpdates.size>0){let bA=lJ(XA.width,XA.height,V.format,V.type);for(let MA of V.layerUpdates){let lA=XA.data.subarray(MA*bA/XA.data.BYTES_PER_ELEMENT,(MA+1)*bA/XA.data.BYTES_PER_ELEMENT);B.compressedTexSubImage3D(A.TEXTURE_2D_ARRAY,JA,0,0,MA,XA.width,XA.height,1,VA,lA)}V.clearLayerUpdates()}else B.compressedTexSubImage3D(A.TEXTURE_2D_ARRAY,JA,0,0,0,XA.width,XA.height,KA.depth,VA,XA.data)}else B.compressedTexImage3D(A.TEXTURE_2D_ARRAY,JA,CA,XA.width,XA.height,KA.depth,0,XA.data,0,0);else mA("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(BQ){if(c)B.texSubImage3D(A.TEXTURE_2D_ARRAY,JA,0,0,0,XA.width,XA.height,KA.depth,VA,IA,XA.data)}else B.texImage3D(A.TEXTURE_2D_ARRAY,JA,CA,XA.width,XA.height,KA.depth,0,VA,IA,XA.data)}else{if(BQ&&GQ)B.texStorage2D(A.TEXTURE_2D,OA,CA,sA[0].width,sA[0].height);for(let JA=0,$A=sA.length;JA<$A;JA++)if(XA=sA[JA],V.format!==BB)if(VA!==null)if(BQ){if(c)B.compressedTexSubImage2D(A.TEXTURE_2D,JA,0,0,XA.width,XA.height,VA,XA.data)}else B.compressedTexImage2D(A.TEXTURE_2D,JA,CA,XA.width,XA.height,0,XA.data);else mA("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else if(BQ){if(c)B.texSubImage2D(A.TEXTURE_2D,JA,0,0,XA.width,XA.height,VA,IA,XA.data)}else B.texImage2D(A.TEXTURE_2D,JA,CA,XA.width,XA.height,0,VA,IA,XA.data)}else if(V.isDataArrayTexture)if(BQ){if(GQ)B.texStorage3D(A.TEXTURE_2D_ARRAY,OA,CA,KA.width,KA.height,KA.depth);if(c)if(V.layerUpdates.size>0){let JA=lJ(KA.width,KA.height,V.format,V.type);for(let $A of V.layerUpdates){let bA=KA.data.subarray($A*JA/KA.data.BYTES_PER_ELEMENT,($A+1)*JA/KA.data.BYTES_PER_ELEMENT);B.texSubImage3D(A.TEXTURE_2D_ARRAY,0,0,0,$A,KA.width,KA.height,1,VA,IA,bA)}V.clearLayerUpdates()}else B.texSubImage3D(A.TEXTURE_2D_ARRAY,0,0,0,0,KA.width,KA.height,KA.depth,VA,IA,KA.data)}else B.texImage3D(A.TEXTURE_2D_ARRAY,0,CA,KA.width,KA.height,KA.depth,0,VA,IA,KA.data);else if(V.isData3DTexture)if(BQ){if(GQ)B.texStorage3D(A.TEXTURE_3D,OA,CA,KA.width,KA.height,KA.depth);if(c)B.texSubImage3D(A.TEXTURE_3D,0,0,0,0,KA.width,KA.height,KA.depth,VA,IA,KA.data)}else B.texImage3D(A.TEXTURE_3D,0,CA,KA.width,KA.height,KA.depth,0,VA,IA,KA.data);else if(V.isFramebufferTexture){if(GQ)if(BQ)B.texStorage2D(A.TEXTURE_2D,OA,CA,KA.width,KA.height);else{let{width:JA,height:$A}=KA;for(let bA=0;bA>=1,$A>>=1}}else if(V.isHTMLTexture){if("texElementImage2D"in A){let JA=A.canvas;if(!JA.hasAttribute("layoutsubtree"))JA.setAttribute("layoutsubtree","true");if(KA.parentNode!==JA){JA.appendChild(KA),R.add(V),JA.onpaint=(cA)=>{let yQ=cA.changedElements;for(let wQ of R)if(yQ.includes(wQ.image))wQ.needsUpdate=!0},JA.requestPaint();return}let $A=0,bA=A.RGBA,MA=A.RGBA,lA=A.UNSIGNED_BYTE;A.texElementImage2D(A.TEXTURE_2D,$A,bA,MA,lA,KA),A.texParameteri(A.TEXTURE_2D,A.TEXTURE_MIN_FILTER,A.LINEAR),A.texParameteri(A.TEXTURE_2D,A.TEXTURE_WRAP_S,A.CLAMP_TO_EDGE),A.texParameteri(A.TEXTURE_2D,A.TEXTURE_WRAP_T,A.CLAMP_TO_EDGE)}}else if(sA.length>0){if(BQ&&GQ){let JA=vA(sA[0]);B.texStorage2D(A.TEXTURE_2D,OA,CA,JA.width,JA.height)}for(let JA=0,$A=sA.length;JA<$A;JA++)if(XA=sA[JA],BQ){if(c)B.texSubImage2D(A.TEXTURE_2D,JA,0,0,VA,IA,XA)}else B.texImage2D(A.TEXTURE_2D,JA,CA,VA,IA,XA);V.generateMipmaps=!1}else if(BQ){if(GQ){let JA=vA(KA);B.texStorage2D(A.TEXTURE_2D,OA,CA,JA.width,JA.height)}if(c)B.texSubImage2D(A.TEXTURE_2D,0,0,0,VA,IA,KA)}else B.texImage2D(A.TEXTURE_2D,0,CA,VA,IA,KA);if(q(V))N(GA);if(zA.__version=ZA.version,V.onUpdate)V.onUpdate(V)}h.__version=V.version}function eA(h,V,i){if(V.image.length!==6)return;let GA=QA(h,V),HA=V.source;B.bindTexture(A.TEXTURE_CUBE_MAP,h.__webglTexture,A.TEXTURE0+i);let ZA=E.get(HA);if(HA.version!==ZA.__version||GA===!0){B.activeTexture(A.TEXTURE0+i);let zA=qQ.getPrimaries(qQ.workingColorSpace),EA=V.colorSpace===FE?null:qQ.getPrimaries(V.colorSpace),KA=V.colorSpace===FE||zA===EA?A.NONE:A.BROWSER_DEFAULT_WEBGL;B.pixelStorei(A.UNPACK_FLIP_Y_WEBGL,V.flipY),B.pixelStorei(A.UNPACK_PREMULTIPLY_ALPHA_WEBGL,V.premultiplyAlpha),B.pixelStorei(A.UNPACK_ALIGNMENT,V.unpackAlignment),B.pixelStorei(A.UNPACK_COLORSPACE_CONVERSION_WEBGL,KA);let VA=V.isCompressedTexture||V.image[0].isCompressedTexture,IA=V.image[0]&&V.image[0].isDataTexture,CA=[];for(let MA=0;MA<6;MA++){if(!VA&&!IA)CA[MA]=Y(V.image[MA],!0,I.maxCubemapSize);else CA[MA]=IA?V.image[MA].image:V.image[MA];CA[MA]=RQ(V,CA[MA])}let XA=CA[0],sA=C.convert(V.format,V.colorSpace),BQ=C.convert(V.type),GQ=L(V.internalFormat,sA,BQ,V.normalized,V.colorSpace),c=V.isVideoTexture!==!0,OA=ZA.__version===void 0||GA===!0,JA=HA.dataReady,$A=O(V,XA);l(A.TEXTURE_CUBE_MAP,V);let bA;if(VA){if(c&&OA)B.texStorage2D(A.TEXTURE_CUBE_MAP,$A,GQ,XA.width,XA.height);for(let MA=0;MA<6;MA++){bA=CA[MA].mipmaps;for(let lA=0;lA0)$A++;let MA=vA(CA[0]);B.texStorage2D(A.TEXTURE_CUBE_MAP,$A,GQ,MA.width,MA.height)}for(let MA=0;MA<6;MA++)if(IA){if(c){if(JA)B.texSubImage2D(A.TEXTURE_CUBE_MAP_POSITIVE_X+MA,0,0,0,CA[MA].width,CA[MA].height,sA,BQ,CA[MA].data)}else B.texImage2D(A.TEXTURE_CUBE_MAP_POSITIVE_X+MA,0,GQ,CA[MA].width,CA[MA].height,0,sA,BQ,CA[MA].data);for(let lA=0;lA>ZA),XA=Math.max(1,V.height>>ZA);if(HA===A.TEXTURE_3D||HA===A.TEXTURE_2D_ARRAY)B.texImage3D(HA,ZA,KA,CA,XA,V.depth,0,zA,EA,null);else B.texImage2D(HA,ZA,KA,CA,XA,0,zA,EA,null)}if(B.bindFramebuffer(A.FRAMEBUFFER,h),JQ(V))K.framebufferTexture2DMultisampleEXT(A.FRAMEBUFFER,GA,HA,IA.__webglTexture,0,QQ(V));else if(HA===A.TEXTURE_2D||HA>=A.TEXTURE_CUBE_MAP_POSITIVE_X&&HA<=A.TEXTURE_CUBE_MAP_NEGATIVE_Z)A.framebufferTexture2D(A.FRAMEBUFFER,GA,HA,IA.__webglTexture,ZA);B.bindFramebuffer(A.FRAMEBUFFER,null)}function YA(h,V,i){if(A.bindRenderbuffer(A.RENDERBUFFER,h),V.depthBuffer){let GA=V.depthTexture,HA=GA&&GA.isDepthTexture?GA.type:null,ZA=k(V.stencilBuffer,HA),zA=V.stencilBuffer?A.DEPTH_STENCIL_ATTACHMENT:A.DEPTH_ATTACHMENT;if(JQ(V))K.renderbufferStorageMultisampleEXT(A.RENDERBUFFER,QQ(V),ZA,V.width,V.height);else if(i)A.renderbufferStorageMultisample(A.RENDERBUFFER,QQ(V),ZA,V.width,V.height);else A.renderbufferStorage(A.RENDERBUFFER,ZA,V.width,V.height);A.framebufferRenderbuffer(A.FRAMEBUFFER,zA,A.RENDERBUFFER,h)}else{let GA=V.textures;for(let HA=0;HA{delete V.__boundDepthTexture,delete V.__depthDisposeCallback,GA.removeEventListener("dispose",HA)};GA.addEventListener("dispose",HA),V.__depthDisposeCallback=HA}V.__boundDepthTexture=GA}if(h.depthTexture&&!V.__autoAllocateDepthBuffer)if(i)for(let GA=0;GA<6;GA++)fA(V.__webglFramebuffer[GA],h,GA);else{let GA=h.texture.mipmaps;if(GA&&GA.length>0)fA(V.__webglFramebuffer[0],h,0);else fA(V.__webglFramebuffer,h,0)}else if(i){V.__webglDepthbuffer=[];for(let GA=0;GA<6;GA++)if(B.bindFramebuffer(A.FRAMEBUFFER,V.__webglFramebuffer[GA]),V.__webglDepthbuffer[GA]===void 0)V.__webglDepthbuffer[GA]=A.createRenderbuffer(),YA(V.__webglDepthbuffer[GA],h,!1);else{let HA=h.stencilBuffer?A.DEPTH_STENCIL_ATTACHMENT:A.DEPTH_ATTACHMENT,ZA=V.__webglDepthbuffer[GA];A.bindRenderbuffer(A.RENDERBUFFER,ZA),A.framebufferRenderbuffer(A.FRAMEBUFFER,HA,A.RENDERBUFFER,ZA)}}else{let GA=h.texture.mipmaps;if(GA&&GA.length>0)B.bindFramebuffer(A.FRAMEBUFFER,V.__webglFramebuffer[0]);else B.bindFramebuffer(A.FRAMEBUFFER,V.__webglFramebuffer);if(V.__webglDepthbuffer===void 0)V.__webglDepthbuffer=A.createRenderbuffer(),YA(V.__webglDepthbuffer,h,!1);else{let HA=h.stencilBuffer?A.DEPTH_STENCIL_ATTACHMENT:A.DEPTH_ATTACHMENT,ZA=V.__webglDepthbuffer;A.bindRenderbuffer(A.RENDERBUFFER,ZA),A.framebufferRenderbuffer(A.FRAMEBUFFER,HA,A.RENDERBUFFER,ZA)}}B.bindFramebuffer(A.FRAMEBUFFER,null)}function yA(h,V,i){let GA=E.get(h);if(V!==void 0)tA(GA.__webglFramebuffer,h,h.texture,A.COLOR_ATTACHMENT0,A.TEXTURE_2D,0);if(i!==void 0)nA(h)}function NA(h){let V=h.texture,i=E.get(h),GA=E.get(V);h.addEventListener("dispose",Z);let HA=h.textures,ZA=h.isWebGLCubeRenderTarget===!0,zA=HA.length>1;if(!zA){if(GA.__webglTexture===void 0)GA.__webglTexture=A.createTexture();GA.__version=V.version,G.memory.textures++}if(ZA){i.__webglFramebuffer=[];for(let EA=0;EA<6;EA++)if(V.mipmaps&&V.mipmaps.length>0){i.__webglFramebuffer[EA]=[];for(let KA=0;KA0){i.__webglFramebuffer=[];for(let EA=0;EA0&&JQ(h)===!1){i.__webglMultisampledFramebuffer=A.createFramebuffer(),i.__webglColorRenderbuffer=[],B.bindFramebuffer(A.FRAMEBUFFER,i.__webglMultisampledFramebuffer);for(let EA=0;EA0)for(let KA=0;KA0)for(let KA=0;KA0){if(JQ(h)===!1){let{textures:V,width:i,height:GA}=h,HA=A.COLOR_BUFFER_BIT,ZA=h.stencilBuffer?A.DEPTH_STENCIL_ATTACHMENT:A.DEPTH_ATTACHMENT,zA=E.get(h),EA=V.length>1;if(EA)for(let VA=0;VA0)B.bindFramebuffer(A.DRAW_FRAMEBUFFER,zA.__webglFramebuffer[0]);else B.bindFramebuffer(A.DRAW_FRAMEBUFFER,zA.__webglFramebuffer);for(let VA=0;VA0&&Q.has("WEBGL_multisampled_render_to_texture")===!0&&V.__useRenderToTexture!==!1}function WA(h){let V=G.render.frame;if(F.get(h)!==V)F.set(h,V),h.update()}function RQ(h,V){let{colorSpace:i,format:GA,type:HA}=h;if(h.isCompressedTexture===!0||h.isVideoTexture===!0)return V;if(i!==pQ&&i!==FE)if(qQ.getTransfer(i)===jQ){if(GA!==BB||HA!==FQ)mA("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.")}else CQ("WebGLTextures: Unsupported texture color space:",i);return V}function vA(h){if(typeof HTMLImageElement<"u"&&h instanceof HTMLImageElement)U.width=h.naturalWidth||h.width,U.height=h.naturalHeight||h.height;else if(typeof VideoFrame<"u"&&h instanceof VideoFrame)U.width=h.displayWidth,U.height=h.displayHeight;else U.width=h.width,U.height=h.height;return U}this.allocateTextureUnit=g,this.resetTextureUnits=x,this.getTextureUnits=P,this.setTextureUnits=j,this.setTexture2D=p,this.setTexture2DArray=u,this.setTexture3D=b,this.setTextureCube=t,this.rebindTextures=yA,this.setupRenderTarget=NA,this.updateRenderTargetMipmap=hA,this.updateMultisampleRenderTarget=LQ,this.setupDepthRenderbuffer=nA,this.setupFrameBufferTexture=tA,this.useMultisampledRTT=JQ,this.isReversedDepthBuffer=function(){return B.buffers.depth.getReversed()}}function ZX(A,Q){function B(E,I=FE){let C,G=qQ.getTransfer(I);if(E===FQ)return A.UNSIGNED_BYTE;if(E===eK)return A.UNSIGNED_SHORT_4_4_4_4;if(E===AJ)return A.UNSIGNED_SHORT_5_5_5_1;if(E===UC)return A.UNSIGNED_INT_5_9_9_9_REV;if(E===FC)return A.UNSIGNED_INT_10F_11F_11F_REV;if(E===IR)return A.BYTE;if(E===CR)return A.SHORT;if(E===BI)return A.UNSIGNED_SHORT;if(E===tK)return A.INT;if(E===EI)return A.UNSIGNED_INT;if(E===NB)return A.FLOAT;if(E===KB)return A.HALF_FLOAT;if(E===GR)return A.ALPHA;if(E===O0)return A.RGB;if(E===BB)return A.RGBA;if(E===PI)return A.DEPTH_COMPONENT;if(E===TI)return A.DEPTH_STENCIL;if(E===II)return A.RED;if(E===QJ)return A.RED_INTEGER;if(E===jB)return A.RG;if(E===BJ)return A.RG_INTEGER;if(E===EJ)return A.RGBA_INTEGER;if(E===SI||E===CI||E===p8||E===GI)if(G===jQ)if(C=Q.get("WEBGL_compressed_texture_s3tc_srgb"),C!==null){if(E===SI)return C.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(E===CI)return C.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(E===p8)return C.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(E===GI)return C.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(C=Q.get("WEBGL_compressed_texture_s3tc"),C!==null){if(E===SI)return C.COMPRESSED_RGB_S3TC_DXT1_EXT;if(E===CI)return C.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(E===p8)return C.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(E===GI)return C.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(E===RC||E===IJ||E===jI||E===V0)if(C=Q.get("WEBGL_compressed_texture_pvrtc"),C!==null){if(E===RC)return C.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(E===IJ)return C.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(E===jI)return C.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(E===V0)return C.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(E===DC||E===k0||E===w0||E===HC||E===YC||E===z0||E===qC)if(C=Q.get("WEBGL_compressed_texture_etc"),C!==null){if(E===DC||E===k0)return G===jQ?C.COMPRESSED_SRGB8_ETC2:C.COMPRESSED_RGB8_ETC2;if(E===w0)return G===jQ?C.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:C.COMPRESSED_RGBA8_ETC2_EAC;if(E===HC)return C.COMPRESSED_R11_EAC;if(E===YC)return C.COMPRESSED_SIGNED_R11_EAC;if(E===z0)return C.COMPRESSED_RG11_EAC;if(E===qC)return C.COMPRESSED_SIGNED_RG11_EAC}else return null;if(E===KI||E===CJ||E===GJ||E===KJ||E===fI||E===JJ||E===UJ||E===FJ||E===RJ||E===DJ||E===HJ||E===YJ||E===qJ||E===MJ)if(C=Q.get("WEBGL_compressed_texture_astc"),C!==null){if(E===KI)return G===jQ?C.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:C.COMPRESSED_RGBA_ASTC_4x4_KHR;if(E===CJ)return G===jQ?C.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:C.COMPRESSED_RGBA_ASTC_5x4_KHR;if(E===GJ)return G===jQ?C.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:C.COMPRESSED_RGBA_ASTC_5x5_KHR;if(E===KJ)return G===jQ?C.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:C.COMPRESSED_RGBA_ASTC_6x5_KHR;if(E===fI)return G===jQ?C.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:C.COMPRESSED_RGBA_ASTC_6x6_KHR;if(E===JJ)return G===jQ?C.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:C.COMPRESSED_RGBA_ASTC_8x5_KHR;if(E===UJ)return G===jQ?C.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:C.COMPRESSED_RGBA_ASTC_8x6_KHR;if(E===FJ)return G===jQ?C.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:C.COMPRESSED_RGBA_ASTC_8x8_KHR;if(E===RJ)return G===jQ?C.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:C.COMPRESSED_RGBA_ASTC_10x5_KHR;if(E===DJ)return G===jQ?C.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:C.COMPRESSED_RGBA_ASTC_10x6_KHR;if(E===HJ)return G===jQ?C.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:C.COMPRESSED_RGBA_ASTC_10x8_KHR;if(E===YJ)return G===jQ?C.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:C.COMPRESSED_RGBA_ASTC_10x10_KHR;if(E===qJ)return G===jQ?C.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:C.COMPRESSED_RGBA_ASTC_12x10_KHR;if(E===MJ)return G===jQ?C.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:C.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(E===yI||E===NJ||E===MC)if(C=Q.get("EXT_texture_compression_bptc"),C!==null){if(E===yI)return G===jQ?C.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:C.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(E===NJ)return C.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(E===MC)return C.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(E===NC||E===ZC||E===_0||E===XC)if(C=Q.get("EXT_texture_compression_rgtc"),C!==null){if(E===NC)return C.COMPRESSED_RED_RGTC1_EXT;if(E===ZC)return C.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(E===_0)return C.COMPRESSED_RED_GREEN_RGTC2_EXT;if(E===XC)return C.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;if(E===$0)return A.UNSIGNED_INT_24_8;return A[E]!==void 0?A[E]:null}return{convert:B}}var XX=` void main() { gl_Position = vec4( position, 1.0 ); }`,LX=` uniform sampler2DArray depthColor; uniform float depthWidth; uniform float depthHeight; void main() { vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); if ( coord.x >= 1.0 ) { gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; } else { gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; } }`;class KD{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(A,Q){if(this.texture===null){let B=new BG(A.texture);if(A.depthNear!==Q.depthNear||A.depthFar!==Q.depthFar)this.depthNear=A.depthNear,this.depthFar=A.depthFar;this.texture=B}}getMesh(A){if(this.texture!==null){if(this.mesh===null){let Q=A.cameras[0].viewport,B=new hQ({vertexShader:XX,fragmentShader:LX,uniforms:{depthColor:{value:this.texture},depthWidth:{value:Q.z},depthHeight:{value:Q.w}}});this.mesh=new _Q(new HB(20,20),B)}}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class JD extends RE{constructor(A,Q){super();let B=this,E=null,I=1,C=null,G="local-floor",K=1,J=null,U=null,F=null,R=null,D=null,H=null,M=typeof XRWebGLBinding<"u",X=new KD,Y={},q=Q.getContextAttributes(),N=null,$=null,L=[],k=[],O=new LA,w=null,Z=new dQ;Z.viewport=new SQ;let z=new dQ;z.viewport=new SQ;let y=[Z,z],_=new bJ,v=null,x=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(l){let QA=L[l];if(QA===void 0)QA=new VC,L[l]=QA;return QA.getTargetRaySpace()},this.getControllerGrip=function(l){let QA=L[l];if(QA===void 0)QA=new VC,L[l]=QA;return QA.getGripSpace()},this.getHand=function(l){let QA=L[l];if(QA===void 0)QA=new VC,L[l]=QA;return QA.getHandSpace()};function P(l){let QA=k.indexOf(l.inputSource);if(QA===-1)return;let FA=L[QA];if(FA!==void 0)FA.update(l.inputSource,l.frame,J||C),FA.dispatchEvent({type:l.type,data:l.inputSource})}function j(){E.removeEventListener("select",P),E.removeEventListener("selectstart",P),E.removeEventListener("selectend",P),E.removeEventListener("squeeze",P),E.removeEventListener("squeezestart",P),E.removeEventListener("squeezeend",P),E.removeEventListener("end",j),E.removeEventListener("inputsourceschange",g);for(let l=0;l=0)k[RA]=null,L[RA].disconnect(FA)}for(let QA=0;QA=k.length){k.push(FA),RA=eA;break}else if(k[eA]===null){k[eA]=FA,RA=eA;break}if(RA===-1)break}let qA=L[RA];if(qA)qA.connect(FA)}}let f=new d,p=new d;function u(l,QA,FA){f.setFromMatrixPosition(QA.matrixWorld),p.setFromMatrixPosition(FA.matrixWorld);let RA=f.distanceTo(p),qA=QA.projectionMatrix.elements,eA=FA.projectionMatrix.elements,tA=qA[14]/(qA[10]-1),YA=qA[14]/(qA[10]+1),fA=(qA[9]+1)/qA[5],nA=(qA[9]-1)/qA[5],yA=(qA[8]-1)/qA[0],NA=(eA[8]+1)/eA[0],hA=tA*yA,iA=tA*NA,m=RA/(-yA+NA),LQ=m*-yA;if(QA.matrixWorld.decompose(l.position,l.quaternion,l.scale),l.translateX(LQ),l.translateZ(m),l.matrixWorld.compose(l.position,l.quaternion,l.scale),l.matrixWorldInverse.copy(l.matrixWorld).invert(),qA[10]===-1)l.projectionMatrix.copy(QA.projectionMatrix),l.projectionMatrixInverse.copy(QA.projectionMatrixInverse);else{let QQ=tA+m,JQ=YA+m,WA=hA-LQ,RQ=iA+(RA-LQ),vA=fA*YA/JQ*QQ,h=nA*YA/JQ*QQ;l.projectionMatrix.makePerspective(WA,RQ,vA,h,QQ,JQ),l.projectionMatrixInverse.copy(l.projectionMatrix).invert()}}function b(l,QA){if(QA===null)l.matrixWorld.copy(l.matrix);else l.matrixWorld.multiplyMatrices(QA.matrixWorld,l.matrix);l.matrixWorldInverse.copy(l.matrixWorld).invert()}this.updateCamera=function(l){if(E===null)return;let{near:QA,far:FA}=l;if(X.texture!==null){if(X.depthNear>0)QA=X.depthNear;if(X.depthFar>0)FA=X.depthFar}if(_.near=z.near=Z.near=QA,_.far=z.far=Z.far=FA,v!==_.near||x!==_.far)E.updateRenderState({depthNear:_.near,depthFar:_.far}),v=_.near,x=_.far;_.layers.mask=l.layers.mask|6,Z.layers.mask=_.layers.mask&-5,z.layers.mask=_.layers.mask&-3;let RA=l.parent,qA=_.cameras;b(_,RA);for(let eA=0;eA0)Y.alphaTest.value=q.alphaTest;let N=Q.get(q),$=N.envMap,L=N.envMapRotation;if($){if(Y.envMap.value=$,Y.envMapRotation.value.setFromMatrix4(WX.makeRotationFromEuler(L)).transpose(),$.isCubeTexture&&$.isRenderTargetTexture===!1)Y.envMapRotation.value.premultiply(UD);Y.reflectivity.value=q.reflectivity,Y.ior.value=q.ior,Y.refractionRatio.value=q.refractionRatio}if(q.lightMap)Y.lightMap.value=q.lightMap,Y.lightMapIntensity.value=q.lightMapIntensity,B(q.lightMap,Y.lightMapTransform);if(q.aoMap)Y.aoMap.value=q.aoMap,Y.aoMapIntensity.value=q.aoMapIntensity,B(q.aoMap,Y.aoMapTransform)}function G(Y,q){if(Y.diffuse.value.copy(q.color),Y.opacity.value=q.opacity,q.map)Y.map.value=q.map,B(q.map,Y.mapTransform)}function K(Y,q){Y.dashSize.value=q.dashSize,Y.totalSize.value=q.dashSize+q.gapSize,Y.scale.value=q.scale}function J(Y,q,N,$){if(Y.diffuse.value.copy(q.color),Y.opacity.value=q.opacity,Y.size.value=q.size*N,Y.scale.value=$*0.5,q.map)Y.map.value=q.map,B(q.map,Y.uvTransform);if(q.alphaMap)Y.alphaMap.value=q.alphaMap,B(q.alphaMap,Y.alphaMapTransform);if(q.alphaTest>0)Y.alphaTest.value=q.alphaTest}function U(Y,q){if(Y.diffuse.value.copy(q.color),Y.opacity.value=q.opacity,Y.rotation.value=q.rotation,q.map)Y.map.value=q.map,B(q.map,Y.mapTransform);if(q.alphaMap)Y.alphaMap.value=q.alphaMap,B(q.alphaMap,Y.alphaMapTransform);if(q.alphaTest>0)Y.alphaTest.value=q.alphaTest}function F(Y,q){Y.specular.value.copy(q.specular),Y.shininess.value=Math.max(q.shininess,0.0001)}function R(Y,q){if(q.gradientMap)Y.gradientMap.value=q.gradientMap}function D(Y,q){if(Y.metalness.value=q.metalness,q.metalnessMap)Y.metalnessMap.value=q.metalnessMap,B(q.metalnessMap,Y.metalnessMapTransform);if(Y.roughness.value=q.roughness,q.roughnessMap)Y.roughnessMap.value=q.roughnessMap,B(q.roughnessMap,Y.roughnessMapTransform);if(q.envMap)Y.envMapIntensity.value=q.envMapIntensity}function H(Y,q,N){if(Y.ior.value=q.ior,q.sheen>0){if(Y.sheenColor.value.copy(q.sheenColor).multiplyScalar(q.sheen),Y.sheenRoughness.value=q.sheenRoughness,q.sheenColorMap)Y.sheenColorMap.value=q.sheenColorMap,B(q.sheenColorMap,Y.sheenColorMapTransform);if(q.sheenRoughnessMap)Y.sheenRoughnessMap.value=q.sheenRoughnessMap,B(q.sheenRoughnessMap,Y.sheenRoughnessMapTransform)}if(q.clearcoat>0){if(Y.clearcoat.value=q.clearcoat,Y.clearcoatRoughness.value=q.clearcoatRoughness,q.clearcoatMap)Y.clearcoatMap.value=q.clearcoatMap,B(q.clearcoatMap,Y.clearcoatMapTransform);if(q.clearcoatRoughnessMap)Y.clearcoatRoughnessMap.value=q.clearcoatRoughnessMap,B(q.clearcoatRoughnessMap,Y.clearcoatRoughnessMapTransform);if(q.clearcoatNormalMap){if(Y.clearcoatNormalMap.value=q.clearcoatNormalMap,B(q.clearcoatNormalMap,Y.clearcoatNormalMapTransform),Y.clearcoatNormalScale.value.copy(q.clearcoatNormalScale),q.side===iQ)Y.clearcoatNormalScale.value.negate()}}if(q.dispersion>0)Y.dispersion.value=q.dispersion;if(q.iridescence>0){if(Y.iridescence.value=q.iridescence,Y.iridescenceIOR.value=q.iridescenceIOR,Y.iridescenceThicknessMinimum.value=q.iridescenceThicknessRange[0],Y.iridescenceThicknessMaximum.value=q.iridescenceThicknessRange[1],q.iridescenceMap)Y.iridescenceMap.value=q.iridescenceMap,B(q.iridescenceMap,Y.iridescenceMapTransform);if(q.iridescenceThicknessMap)Y.iridescenceThicknessMap.value=q.iridescenceThicknessMap,B(q.iridescenceThicknessMap,Y.iridescenceThicknessMapTransform)}if(q.transmission>0){if(Y.transmission.value=q.transmission,Y.transmissionSamplerMap.value=N.texture,Y.transmissionSamplerSize.value.set(N.width,N.height),q.transmissionMap)Y.transmissionMap.value=q.transmissionMap,B(q.transmissionMap,Y.transmissionMapTransform);if(Y.thickness.value=q.thickness,q.thicknessMap)Y.thicknessMap.value=q.thicknessMap,B(q.thicknessMap,Y.thicknessMapTransform);Y.attenuationDistance.value=q.attenuationDistance,Y.attenuationColor.value.copy(q.attenuationColor)}if(q.anisotropy>0){if(Y.anisotropyVector.value.set(q.anisotropy*Math.cos(q.anisotropyRotation),q.anisotropy*Math.sin(q.anisotropyRotation)),q.anisotropyMap)Y.anisotropyMap.value=q.anisotropyMap,B(q.anisotropyMap,Y.anisotropyMapTransform)}if(Y.specularIntensity.value=q.specularIntensity,Y.specularColor.value.copy(q.specularColor),q.specularColorMap)Y.specularColorMap.value=q.specularColorMap,B(q.specularColorMap,Y.specularColorMapTransform);if(q.specularIntensityMap)Y.specularIntensityMap.value=q.specularIntensityMap,B(q.specularIntensityMap,Y.specularIntensityMapTransform)}function M(Y,q){if(q.matcap)Y.matcap.value=q.matcap}function X(Y,q){let N=Q.get(q).light;Y.referencePosition.value.setFromMatrixPosition(N.matrixWorld),Y.nearDistance.value=N.shadow.camera.near,Y.farDistance.value=N.shadow.camera.far}return{refreshFogUniforms:E,refreshMaterialUniforms:I}}function OX(A,Q,B,E){let I={},C={},G=[],K=A.getParameter(A.MAX_UNIFORM_BUFFER_BINDINGS);function J(N,$){let L=$.program;E.uniformBlockBinding(N,L)}function U(N,$){let L=I[N.id];if(L===void 0)M(N),L=F(N),I[N.id]=L,N.addEventListener("dispose",Y);let k=$.program;E.updateUBOMapping(N,k);let O=Q.render.frame;if(C[N.id]!==O)D(N),C[N.id]=O}function F(N){let $=R();N.__bindingPointIndex=$;let L=A.createBuffer(),k=N.__size,O=N.usage;return A.bindBuffer(A.UNIFORM_BUFFER,L),A.bufferData(A.UNIFORM_BUFFER,k,O),A.bindBuffer(A.UNIFORM_BUFFER,null),A.bindBufferBase(A.UNIFORM_BUFFER,$,L),L}function R(){for(let N=0;N0)L+=k-O;return N.__size=L,N.__cache={},this}function X(N){let $={boundary:0,storage:0};if(typeof N==="number"||typeof N==="boolean")$.boundary=4,$.storage=4;else if(N.isVector2)$.boundary=8,$.storage=8;else if(N.isVector3||N.isColor)$.boundary=16,$.storage=12;else if(N.isVector4)$.boundary=16,$.storage=16;else if(N.isMatrix3)$.boundary=48,$.storage=48;else if(N.isMatrix4)$.boundary=64,$.storage=64;else if(N.isTexture)mA("WebGLRenderer: Texture samplers can not be part of an uniforms group.");else if(ArrayBuffer.isView(N))$.boundary=16,$.storage=N.byteLength;else mA("WebGLRenderer: Unsupported uniform value type.",N);return $}function Y(N){let $=N.target;$.removeEventListener("dispose",Y);let L=G.indexOf($.__bindingPointIndex);G.splice(L,1),A.deleteBuffer(I[$.id]),delete I[$.id],delete C[$.id]}function q(){for(let N in I)A.deleteBuffer(I[N]);G=[],I={},C={}}return{bind:J,update:U,dispose:q}}var VX=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]),HE=null;function kX(){if(HE===null)HE=new gI(VX,16,16,jB,KB),HE.name="DFG_LUT",HE.minFilter=VQ,HE.magFilter=VQ,HE.wrapS=X0,HE.wrapT=X0,HE.generateMipmaps=!1,HE.needsUpdate=!0;return HE}class AU{constructor(A={}){let{canvas:Q=YR(),context:B=null,depth:E=!0,stencil:I=!1,alpha:C=!1,antialias:G=!1,premultipliedAlpha:K=!0,preserveDrawingBuffer:J=!1,powerPreference:U="default",failIfMajorPerformanceCaveat:F=!1,reversedDepthBuffer:R=!1,outputBufferType:D=FQ}=A;this.isWebGLRenderer=!0;let H;if(B!==null){if(typeof WebGLRenderingContext<"u"&&B instanceof WebGLRenderingContext)throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");H=B.getContextAttributes().alpha}else H=C;let M=D,X=new Set([EJ,BJ,QJ]),Y=new Set([FQ,EI,BI,$0,eK,AJ]),q=new Uint32Array(4),N=new Int32Array(4),$=new d,L=null,k=null,O=[],w=[],Z=null;this.domElement=Q,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=AE,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let z=this,y=!1,_=null;this._outputColorSpace=fB;let v=0,x=0,P=null,j=-1,g=null,f=new SQ,p=new SQ,u=null,b=new AQ(0),t=0,AA=Q.width,kA=Q.height,SA=1,l=null,QA=null,FA=new SQ(0,0,AA,kA),RA=new SQ(0,0,AA,kA),qA=!1,eA=new _C,tA=!1,YA=!1,fA=new HQ,nA=new d,yA=new SQ,NA={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},hA=!1;function iA(){return P===null?SA:1}let m=B;function LQ(T,s){return Q.getContext(T,s)}try{let T={alpha:!0,depth:E,stencil:I,antialias:G,premultipliedAlpha:K,preserveDrawingBuffer:J,powerPreference:U,failIfMajorPerformanceCaveat:F};if("setAttribute"in Q)Q.setAttribute("data-engine",`three.js r${VF}`);if(Q.addEventListener("webglcontextlost",bA,!1),Q.addEventListener("webglcontextrestored",MA,!1),Q.addEventListener("webglcontextcreationerror",lA,!1),m===null){if(m=LQ("webgl2",T),m===null)if(LQ("webgl2"))throw Error("Error creating WebGL context with your selected attributes.");else throw Error("Error creating WebGL context.")}}catch(T){throw CQ("WebGLRenderer: "+T.message),T}let QQ,JQ,WA,RQ,vA,h,V,i,GA,HA,ZA,zA,EA,KA,VA,IA,CA,XA,sA,BQ,GQ,c,OA;function JA(){if(QQ=new jN(m),QQ.init(),GQ=new ZX(m,QQ),JQ=new VN(m,QQ,A,GQ),WA=new MX(m,QQ),JQ.reversedDepthBuffer&&R)WA.buffers.depth.setReversed(!0);RQ=new gN(m),vA=new BX,h=new NX(m,QQ,WA,vA,JQ,GQ,RQ),V=new SN(z),i=new bq(m),c=new $N(m,i),GA=new fN(m,i,RQ,c),HA=new xN(m,GA,i,c,RQ),XA=new hN(m,JQ,h),VA=new kN(vA),ZA=new QX(z,V,QQ,JQ,c,VA),zA=new $X(z,vA),EA=new IX,KA=new FX(QQ),CA=new WN(z,V,WA,HA,H,K),IA=new qX(z,HA,JQ),OA=new OX(m,RQ,JQ,WA),sA=new ON(m,QQ,RQ),BQ=new yN(m,QQ,RQ),RQ.programs=ZA.programs,z.capabilities=JQ,z.extensions=QQ,z.properties=vA,z.renderLists=EA,z.shadowMap=IA,z.state=WA,z.info=RQ}if(JA(),M!==FQ)Z=new bN(M,Q.width,Q.height,E,I);let $A=new JD(z,m);this.xr=$A,this.getContext=function(){return m},this.getContextAttributes=function(){return m.getContextAttributes()},this.forceContextLoss=function(){let T=QQ.get("WEBGL_lose_context");if(T)T.loseContext()},this.forceContextRestore=function(){let T=QQ.get("WEBGL_lose_context");if(T)T.restoreContext()},this.getPixelRatio=function(){return SA},this.setPixelRatio=function(T){if(T===void 0)return;SA=T,this.setSize(AA,kA,!1)},this.getSize=function(T){return T.set(AA,kA)},this.setSize=function(T,s,e=!0){if($A.isPresenting){mA("WebGLRenderer: Can't change size while VR device is presenting.");return}if(AA=T,kA=s,Q.width=Math.floor(T*SA),Q.height=Math.floor(s*SA),e===!0)Q.style.width=T+"px",Q.style.height=s+"px";if(Z!==null)Z.setSize(Q.width,Q.height);this.setViewport(0,0,T,s)},this.getDrawingBufferSize=function(T){return T.set(AA*SA,kA*SA).floor()},this.setDrawingBufferSize=function(T,s,e){AA=T,kA=s,SA=e,Q.width=Math.floor(T*e),Q.height=Math.floor(s*e),this.setViewport(0,0,T,s)},this.setEffects=function(T){if(M===FQ){CQ("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(T){for(let s=0;s{function TA(){if(a.forEach(function(xA){if(vA.get(xA).currentProgram.isReady())a.delete(xA)}),a.size===0){r(T);return}setTimeout(TA,10)}if(QQ.get("KHR_parallel_shader_compile")!==null)TA();else setTimeout(TA,10)})};let LB=null;function LE(T){if(LB)LB(T)}function bQ(){WE.stop()}function PA(){WE.start()}let WE=new aR;if(WE.setAnimationLoop(LE),typeof self<"u")WE.setContext(self);this.setAnimationLoop=function(T){LB=T,$A.setAnimationLoop(T),T===null?WE.stop():WE.start()},$A.addEventListener("sessionstart",bQ),$A.addEventListener("sessionend",PA),this.render=function(T,s){if(s!==void 0&&s.isCamera!==!0){CQ("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(y===!0)return;if(_!==null)_.renderStart(T,s);let e=$A.enabled===!0&&$A.isPresenting===!0,a=Z!==null&&(P===null||e)&&Z.begin(z,P);if(T.matrixWorldAutoUpdate===!0)T.updateMatrixWorld();if(s.parent===null&&s.matrixWorldAutoUpdate===!0)s.updateMatrixWorld();if($A.enabled===!0&&$A.isPresenting===!0&&(Z===null||Z.isCompositing()===!1)){if($A.cameraAutoUpdate===!0)$A.updateCamera(s);s=$A.getCamera()}if(T.isScene===!0)T.onBeforeRender(z,T,s,P);if(k=KA.get(T,w.length),k.init(s),k.state.textureUnits=h.getTextureUnits(),w.push(k),fA.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse),eA.setFromProjectionMatrix(fA,$J,s.reversedDepth),YA=this.localClippingEnabled,tA=VA.init(this.clippingPlanes,YA),L=EA.get(T,O.length),L.init(),O.push(L),$A.enabled===!0&&$A.isPresenting===!0){let xA=z.xr.getDepthSensingMesh();if(xA!==null)XI(xA,s,-1/0,z.sortObjects)}if(XI(T,s,0,z.sortObjects),L.finish(),z.sortObjects===!0)L.sort(l,QA);if(hA=$A.enabled===!1||$A.isPresenting===!1||$A.hasDepthSensing()===!1,hA)CA.addToRenderList(L,T);if(this.info.render.frame++,tA===!0)VA.beginShadows();let r=k.state.shadowsArray;if(IA.render(r,T,s),tA===!0)VA.endShadows();if(this.info.autoReset===!0)this.info.reset();if((a&&Z.hasRenderPass())===!1){let{opaque:xA,transmissive:_A}=L;if(k.setupLights(),s.isArrayCamera){let uA=s.cameras;if(_A.length>0)for(let oA=0,DQ=uA.length;oA0)LI(xA,_A,T,s);if(hA)CA.render(T);oI(L,T,s)}}if(P!==null&&x===0)h.updateMultisampleRenderTarget(P),h.updateRenderTargetMipmap(P);if(a)Z.end(z);if(T.isScene===!0)T.onAfterRender(z,T,s);if(c.resetDefaultState(),j=-1,g=null,w.pop(),w.length>0){if(k=w[w.length-1],h.setTextureUnits(k.state.textureUnits),tA===!0)VA.setGlobalState(z.clippingPlanes,k.state.camera)}else k=null;if(O.pop(),O.length>0)L=O[O.length-1];else L=null;if(_!==null)_.renderEnd()};function XI(T,s,e,a){if(T.visible===!1)return;if(T.layers.test(s.layers)){if(T.isGroup)e=T.renderOrder;else if(T.isLOD){if(T.autoUpdate===!0)T.update(s)}else if(T.isLightProbeGrid)k.pushLightProbeGrid(T);else if(T.isLight){if(k.pushLight(T),T.castShadow)k.pushShadow(T)}else if(T.isSprite){if(!T.frustumCulled||eA.intersectsSprite(T)){if(a)yA.setFromMatrixPosition(T.matrixWorld).applyMatrix4(fA);let xA=HA.update(T),_A=T.material;if(_A.visible)L.push(T,xA,_A,e,yA.z,null)}}else if(T.isMesh||T.isLine||T.isPoints){if(!T.frustumCulled||eA.intersectsObject(T)){let xA=HA.update(T),_A=T.material;if(a){if(T.boundingSphere!==void 0){if(T.boundingSphere===null)T.computeBoundingSphere();yA.copy(T.boundingSphere.center)}else{if(xA.boundingSphere===null)xA.computeBoundingSphere();yA.copy(xA.boundingSphere.center)}yA.applyMatrix4(T.matrixWorld).applyMatrix4(fA)}if(Array.isArray(_A)){let uA=xA.groups;for(let oA=0,DQ=uA.length;oA0)cE(r,s,e);if(TA.length>0)cE(TA,s,e);if(xA.length>0)cE(xA,s,e);WA.buffers.depth.setTest(!0),WA.buffers.depth.setMask(!0),WA.buffers.color.setMask(!0),WA.setPolygonOffset(!1)}function LI(T,s,e,a){if((e.isScene===!0?e.overrideMaterial:null)!==null)return;if(k.state.transmissionRenderTarget[a.id]===void 0){let S=QQ.has("EXT_color_buffer_half_float")||QQ.has("EXT_color_buffer_float");k.state.transmissionRenderTarget[a.id]=new lQ(1,1,{generateMipmaps:!0,type:S?KB:FQ,minFilter:SB,samples:Math.max(4,JQ.samples),stencilBuffer:I,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:qQ.workingColorSpace})}let TA=k.state.transmissionRenderTarget[a.id],xA=a.viewport||f;TA.setSize(xA.z*z.transmissionResolutionScale,xA.w*z.transmissionResolutionScale);let _A=z.getRenderTarget(),uA=z.getActiveCubeFace(),oA=z.getActiveMipmapLevel();if(z.setRenderTarget(TA),z.getClearColor(b),t=z.getClearAlpha(),t<1)z.setClearColor(16777215,0.5);if(z.clear(),hA)CA.render(e);let DQ=z.toneMapping;z.toneMapping=AE;let W=a.viewport;if(a.viewport!==void 0)a.viewport=void 0;if(k.setupLightsView(a),tA===!0)VA.setGlobalState(z.clippingPlanes,a);if(cE(T,e,a),h.updateMultisampleRenderTarget(TA),h.updateRenderTargetMipmap(TA),QQ.has("WEBGL_multisampled_render_to_texture")===!1){let S=!1;for(let o=0,DA=s.length;o0,a.currentProgram=W,a.uniformsList=null,W}function B8(T){if(T.uniformsList===null){let s=T.currentProgram.getUniforms();T.uniformsList=vC.seqWithValue(s.seq,T.uniforms)}return T.uniformsList}function E8(T,s){let e=vA.get(T);e.outputColorSpace=s.outputColorSpace,e.batching=s.batching,e.batchingColor=s.batchingColor,e.instancing=s.instancing,e.instancingColor=s.instancingColor,e.instancingMorph=s.instancingMorph,e.skinning=s.skinning,e.morphTargets=s.morphTargets,e.morphNormals=s.morphNormals,e.morphColors=s.morphColors,e.morphTargetsCount=s.morphTargetsCount,e.numClippingPlanes=s.numClippingPlanes,e.numIntersection=s.numClipIntersection,e.vertexAlphas=s.vertexAlphas,e.vertexTangents=s.vertexTangents,e.toneMapping=s.toneMapping}function n0(T,s){if(T.length===0)return null;if(T.length===1)return T[0].texture!==null?T[0]:null;$.setFromMatrixPosition(s.matrixWorld);for(let e=0,a=T.length;e0),S=!!e.morphAttributes.position,o=!!e.morphAttributes.normal,DA=!!e.morphAttributes.color,gA=AE;if(a.toneMapped){if(P===null||P.isXRRenderTarget===!0)gA=z.toneMapping}let wA=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,UQ=wA!==void 0?wA.length:0,BA=vA.get(a),aA=k.state.lights;if(tA===!0){if(YA===!0||T!==g){let vQ=T===g&&a.id===j;VA.setState(a,T,vQ)}}let dA=!1;if(a.version===BA.__version){if(BA.needsLights&&BA.lightsStateVersion!==aA.state.version)dA=!0;else if(BA.outputColorSpace!==_A)dA=!0;else if(r.isBatchedMesh&&BA.batching===!1)dA=!0;else if(!r.isBatchedMesh&&BA.batching===!0)dA=!0;else if(r.isBatchedMesh&&BA.batchingColor===!0&&r.colorTexture===null)dA=!0;else if(r.isBatchedMesh&&BA.batchingColor===!1&&r.colorTexture!==null)dA=!0;else if(r.isInstancedMesh&&BA.instancing===!1)dA=!0;else if(!r.isInstancedMesh&&BA.instancing===!0)dA=!0;else if(r.isSkinnedMesh&&BA.skinning===!1)dA=!0;else if(!r.isSkinnedMesh&&BA.skinning===!0)dA=!0;else if(r.isInstancedMesh&&BA.instancingColor===!0&&r.instanceColor===null)dA=!0;else if(r.isInstancedMesh&&BA.instancingColor===!1&&r.instanceColor!==null)dA=!0;else if(r.isInstancedMesh&&BA.instancingMorph===!0&&r.morphTexture===null)dA=!0;else if(r.isInstancedMesh&&BA.instancingMorph===!1&&r.morphTexture!==null)dA=!0;else if(BA.envMap!==oA)dA=!0;else if(a.fog===!0&&BA.fog!==TA)dA=!0;else if(BA.numClippingPlanes!==void 0&&(BA.numClippingPlanes!==VA.numPlanes||BA.numIntersection!==VA.numIntersection))dA=!0;else if(BA.vertexAlphas!==DQ)dA=!0;else if(BA.vertexTangents!==W)dA=!0;else if(BA.morphTargets!==S)dA=!0;else if(BA.morphNormals!==o)dA=!0;else if(BA.morphColors!==DA)dA=!0;else if(BA.toneMapping!==gA)dA=!0;else if(BA.morphTargetsCount!==UQ)dA=!0;else if(!!BA.lightProbeGrid!==k.state.lightProbeGridArray.length>0)dA=!0}else dA=!0,BA.__version=a.version;let $Q=BA.currentProgram;if(dA===!0){if($Q=dE(a,s,r),_&&a.isNodeMaterial)_.onUpdateProgram(a,$Q,BA)}let aQ=!1,wB=!1,sB=!1,PQ=$Q.getUniforms(),uQ=BA.uniforms;if(WA.useProgram($Q.program))aQ=!0,wB=!0,sB=!0;if(a.id!==j)j=a.id,wB=!0;if(BA.needsLights){let vQ=n0(k.state.lightProbeGridArray,r);if(BA.lightProbeGrid!==vQ)BA.lightProbeGrid=vQ,wB=!0}if(aQ||g!==T){if(WA.buffers.depth.getReversed()&&T.reversedDepth!==!0)T._reversedDepth=!0,T.updateProjectionMatrix();PQ.setValue(m,"projectionMatrix",T.projectionMatrix),PQ.setValue(m,"viewMatrix",T.matrixWorldInverse);let nE=PQ.map.cameraPosition;if(nE!==void 0)nE.setValue(m,nA.setFromMatrixPosition(T.matrixWorld));if(JQ.logarithmicDepthBuffer)PQ.setValue(m,"logDepthBufFC",2/(Math.log(T.far+1)/Math.LN2));if(a.isMeshPhongMaterial||a.isMeshToonMaterial||a.isMeshLambertMaterial||a.isMeshBasicMaterial||a.isMeshStandardMaterial||a.isShaderMaterial)PQ.setValue(m,"isOrthographic",T.isOrthographicCamera===!0);if(g!==T)g=T,wB=!0,sB=!0}if(BA.needsLights){if(aA.state.directionalShadowMap.length>0)PQ.setValue(m,"directionalShadowMap",aA.state.directionalShadowMap,h);if(aA.state.spotShadowMap.length>0)PQ.setValue(m,"spotShadowMap",aA.state.spotShadowMap,h);if(aA.state.pointShadowMap.length>0)PQ.setValue(m,"pointShadowMap",aA.state.pointShadowMap,h)}if(r.isSkinnedMesh){PQ.setOptional(m,r,"bindMatrix"),PQ.setOptional(m,r,"bindMatrixInverse");let vQ=r.skeleton;if(vQ){if(vQ.boneTexture===null)vQ.computeBoneTexture();PQ.setValue(m,"boneTexture",vQ.boneTexture,h)}}if(r.isBatchedMesh){if(PQ.setOptional(m,r,"batchingTexture"),PQ.setValue(m,"batchingTexture",r._matricesTexture,h),PQ.setOptional(m,r,"batchingIdTexture"),PQ.setValue(m,"batchingIdTexture",r._indirectTexture,h),PQ.setOptional(m,r,"batchingColorTexture"),r._colorsTexture!==null)PQ.setValue(m,"batchingColorTexture",r._colorsTexture,h)}let $E=e.morphAttributes;if($E.position!==void 0||$E.normal!==void 0||$E.color!==void 0)XA.update(r,e,$Q);if(wB||BA.receiveShadow!==r.receiveShadow)BA.receiveShadow=r.receiveShadow,PQ.setValue(m,"receiveShadow",r.receiveShadow);if((a.isMeshStandardMaterial||a.isMeshLambertMaterial||a.isMeshPhongMaterial)&&a.envMap===null&&s.environment!==null)uQ.envMapIntensity.value=s.environmentIntensity;if(uQ.dfgLUT!==void 0)uQ.dfgLUT.value=kX();if(wB){if(PQ.setValue(m,"toneMappingExposure",z.toneMappingExposure),BA.needsLights)s0(uQ,sB);if(TA&&a.fog===!0)zA.refreshFogUniforms(uQ,TA);if(zA.refreshMaterialUniforms(uQ,a,SA,kA,k.state.transmissionRenderTarget[T.id]),BA.needsLights&&BA.lightProbeGrid){let vQ=BA.lightProbeGrid;uQ.probesSH.value=vQ.texture,uQ.probesMin.value.copy(vQ.boundingBox.min),uQ.probesMax.value.copy(vQ.boundingBox.max),uQ.probesResolution.value.copy(vQ.resolution)}vC.upload(m,B8(BA),uQ,h)}if(a.isShaderMaterial&&a.uniformsNeedUpdate===!0)vC.upload(m,B8(BA),uQ,h),a.uniformsNeedUpdate=!1;if(a.isSpriteMaterial)PQ.setValue(m,"center",r.center);if(PQ.setValue(m,"modelViewMatrix",r.modelViewMatrix),PQ.setValue(m,"normalMatrix",r.normalMatrix),PQ.setValue(m,"modelMatrix",r.matrixWorld),a.uniformsGroups!==void 0){let vQ=a.uniformsGroups;for(let nE=0,rI=vQ.length;nE0&&h.useMultisampledRTT(T)===!1)a=vA.get(T).__webglMultisampledFramebuffer;else if(Array.isArray(oA))a=oA[e];else a=oA;f.copy(T.viewport),p.copy(T.scissor),u=T.scissorTest}else f.copy(FA).multiplyScalar(SA).floor(),p.copy(RA).multiplyScalar(SA).floor(),u=qA;if(e!==0)a=C8;if(WA.bindFramebuffer(m.FRAMEBUFFER,a))WA.drawBuffers(T,a);if(WA.viewport(f),WA.scissor(p),WA.setScissorTest(u),r){let _A=vA.get(T.texture);m.framebufferTexture2D(m.FRAMEBUFFER,m.COLOR_ATTACHMENT0,m.TEXTURE_CUBE_MAP_POSITIVE_X+s,_A.__webglTexture,e)}else if(TA){let _A=s;for(let uA=0;uA1)m.readBuffer(m.COLOR_ATTACHMENT0+_A);if(!JQ.textureFormatReadable(DQ)){CQ("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!JQ.textureTypeReadable(W)){CQ("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}if(s>=0&&s<=T.width-a&&(e>=0&&e<=T.height-r))m.readPixels(s,e,a,r,GQ.convert(DQ),GQ.convert(W),TA)}finally{let oA=P!==null?vA.get(P).__webglFramebuffer:null;WA.bindFramebuffer(m.FRAMEBUFFER,oA)}}},this.readRenderTargetPixelsAsync=async function(T,s,e,a,r,TA,xA,_A=0){if(!(T&&T.isWebGLRenderTarget))throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let uA=vA.get(T).__webglFramebuffer;if(T.isWebGLCubeRenderTarget&&xA!==void 0)uA=uA[xA];if(uA)if(s>=0&&s<=T.width-a&&(e>=0&&e<=T.height-r)){WA.bindFramebuffer(m.FRAMEBUFFER,uA);let oA=T.textures[_A],DQ=oA.format,W=oA.type;if(T.textures.length>1)m.readBuffer(m.COLOR_ATTACHMENT0+_A);if(!JQ.textureFormatReadable(DQ))throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!JQ.textureTypeReadable(W))throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");let S=m.createBuffer();m.bindBuffer(m.PIXEL_PACK_BUFFER,S),m.bufferData(m.PIXEL_PACK_BUFFER,TA.byteLength,m.STREAM_READ),m.readPixels(s,e,a,r,GQ.convert(DQ),GQ.convert(W),0);let o=P!==null?vA.get(P).__webglFramebuffer:null;WA.bindFramebuffer(m.FRAMEBUFFER,o);let DA=m.fenceSync(m.SYNC_GPU_COMMANDS_COMPLETE,0);return m.flush(),await MR(m,DA,4),m.bindBuffer(m.PIXEL_PACK_BUFFER,S),m.getBufferSubData(m.PIXEL_PACK_BUFFER,0,TA),m.deleteBuffer(S),m.deleteSync(DA),TA}else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(T,s=null,e=0){let a=Math.pow(2,-e),r=Math.floor(T.image.width*a),TA=Math.floor(T.image.height*a),xA=s!==null?s.x:0,_A=s!==null?s.y:0;h.setTexture2D(T,0),m.copyTexSubImage2D(m.TEXTURE_2D,e,0,0,xA,_A,r,TA),WA.unbindTexture()};let aI=m.createFramebuffer(),i0=m.createFramebuffer();if(this.copyTextureToTexture=function(T,s,e=null,a=null,r=0,TA=0){let xA,_A,uA,oA,DQ,W,S,o,DA,gA=T.isCompressedTexture?T.mipmaps[TA]:T.image;if(e!==null)xA=e.max.x-e.min.x,_A=e.max.y-e.min.y,uA=e.isBox3?e.max.z-e.min.z:1,oA=e.min.x,DQ=e.min.y,W=e.isBox3?e.min.z:0;else{let uQ=Math.pow(2,-r);if(xA=Math.floor(gA.width*uQ),_A=Math.floor(gA.height*uQ),T.isDataArrayTexture)uA=gA.depth;else if(T.isData3DTexture)uA=Math.floor(gA.depth*uQ);else uA=1;oA=0,DQ=0,W=0}if(a!==null)S=a.x,o=a.y,DA=a.z;else S=0,o=0,DA=0;let wA=GQ.convert(s.format),UQ=GQ.convert(s.type),BA;if(s.isData3DTexture)h.setTexture3D(s,0),BA=m.TEXTURE_3D;else if(s.isDataArrayTexture||s.isCompressedArrayTexture)h.setTexture2DArray(s,0),BA=m.TEXTURE_2D_ARRAY;else h.setTexture2D(s,0),BA=m.TEXTURE_2D;WA.activeTexture(m.TEXTURE0),WA.pixelStorei(m.UNPACK_FLIP_Y_WEBGL,s.flipY),WA.pixelStorei(m.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s.premultiplyAlpha),WA.pixelStorei(m.UNPACK_ALIGNMENT,s.unpackAlignment);let aA=WA.getParameter(m.UNPACK_ROW_LENGTH),dA=WA.getParameter(m.UNPACK_IMAGE_HEIGHT),$Q=WA.getParameter(m.UNPACK_SKIP_PIXELS),aQ=WA.getParameter(m.UNPACK_SKIP_ROWS),wB=WA.getParameter(m.UNPACK_SKIP_IMAGES);WA.pixelStorei(m.UNPACK_ROW_LENGTH,gA.width),WA.pixelStorei(m.UNPACK_IMAGE_HEIGHT,gA.height),WA.pixelStorei(m.UNPACK_SKIP_PIXELS,oA),WA.pixelStorei(m.UNPACK_SKIP_ROWS,DQ),WA.pixelStorei(m.UNPACK_SKIP_IMAGES,W);let sB=T.isDataArrayTexture||T.isData3DTexture,PQ=s.isDataArrayTexture||s.isData3DTexture;if(T.isDepthTexture){let uQ=vA.get(T),$E=vA.get(s),vQ=vA.get(uQ.__renderTarget),nE=vA.get($E.__renderTarget);WA.bindFramebuffer(m.READ_FRAMEBUFFER,vQ.__webglFramebuffer),WA.bindFramebuffer(m.DRAW_FRAMEBUFFER,nE.__webglFramebuffer);for(let rI=0;rI{Q(E),this.off(A,B)};this.on(A,B)}off(A,Q){if(!this.events[A])return;this.events[A]=this.events[A].filter((B)=>B!==Q)}emit(A,Q){if(!this.events[A])return;this.events[A].forEach((B)=>B(Q))}}class ME{static emitter=new FD;static state={};static createProxy(A){return new Proxy(A,{set:function(Q,B,E,I){return ME.emitter.emit(B.toString(),E),Reflect.set(Q,B,E,I)}})}static proxy=new Proxy(ME.state,{set:function(A,Q,B,E){if(typeof B==="object"&&B!==null)B=ME.createProxy(B);return ME.emitter.emit(Q.toString(),B),Reflect.set(A,Q,B,E)}});static on(A,Q){this.emitter.on(A,Q)}static once(A,Q){this.emitter.once(A,Q)}static off(A,Q){this.emitter.off(A,Q)}}var wX={get(A,Q){if(typeof Q==="string"&&Q in ME)return ME[Q].bind(ME);return A[Q]},set(A,Q,B,E){return Reflect.set(ME.proxy,Q,B,E)}},rA=new Proxy(ME.proxy,wX);class ZG{gl;instance;constructor(){this.gl=new qB,this.instance=new AU({canvas:this.gl.canvas,powerPreference:"high-performance",alpha:!0,antialias:!1,depth:!1,stencil:!1,precision:"lowp"}),this.instance.setPixelRatio(this.gl.sizes.pixelRatio),this.instance.setSize(this.gl.sizes.width,this.gl.sizes.height)}update(){for(let A in this.gl.world.scenes)this.gl.world.scenes[A].renderPipeline();this.instance.setRenderTarget(null),this.instance.render(this.gl.scene,this.gl.camera)}resize(){this.instance.setPixelRatio(this.gl.sizes.pixelRatio),this.instance.setSize(this.gl.sizes.width,this.gl.sizes.height)}}var RD={type:"change"},BU={type:"start"},HD={type:"end"},XG=new jE,DD=new rB,zX=Math.cos(70*mQ.DEG2RAD),AB=new d,OB=2*Math.PI,fQ={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},QU=0.000001;class EU extends HG{constructor(A,Q=null){super(A,Q);if(this.state=fQ.NONE,this.target=new d,this.cursor=new d,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=0.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:AI.ROTATE,MIDDLE:AI.DOLLY,RIGHT:AI.PAN},this.touches={ONE:QI.ROTATE,TWO:QI.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new d,this._lastQuaternion=new ZB,this._lastTargetPosition=new d,this._quat=new ZB().setFromUnitVectors(A.up,new d(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new yC,this._sphericalDelta=new yC,this._scale=1,this._panOffset=new d,this._rotateStart=new LA,this._rotateEnd=new LA,this._rotateDelta=new LA,this._panStart=new LA,this._panEnd=new LA,this._panDelta=new LA,this._dollyStart=new LA,this._dollyEnd=new LA,this._dollyDelta=new LA,this._dollyDirection=new d,this._mouse=new LA,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=PX.bind(this),this._onPointerDown=_X.bind(this),this._onPointerUp=TX.bind(this),this._onContextMenu=xX.bind(this),this._onMouseWheel=fX.bind(this),this._onKeyDown=yX.bind(this),this._onTouchStart=gX.bind(this),this._onTouchMove=hX.bind(this),this._onMouseDown=SX.bind(this),this._onMouseMove=jX.bind(this),this._interceptControlDown=vX.bind(this),this._interceptControlUp=bX.bind(this),this.domElement!==null)this.connect(this.domElement);this.update()}set cursorStyle(A){if(this._cursorStyle=A,A==="grab")this.domElement.style.cursor="grab";else this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(A){super.connect(A),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=""}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(A){A.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=A}stopListenToKeyEvents(){if(this._domElementKeyEvents!==null)this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(RD),this.update(),this.state=fQ.NONE}pan(A,Q){this._pan(A,Q),this.update()}dollyIn(A){this._dollyIn(A),this.update()}dollyOut(A){this._dollyOut(A),this.update()}rotateLeft(A){this._rotateLeft(A),this.update()}rotateUp(A){this._rotateUp(A),this.update()}update(A=null){let Q=this.object.position;if(AB.copy(Q).sub(this.target),AB.applyQuaternion(this._quat),this._spherical.setFromVector3(AB),this.autoRotate&&this.state===fQ.NONE)this._rotateLeft(this._getAutoRotationAngle(A));if(this.enableDamping)this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor;else this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi;let B=this.minAzimuthAngle,E=this.maxAzimuthAngle;if(isFinite(B)&&isFinite(E)){if(B<-Math.PI)B+=OB;else if(B>Math.PI)B-=OB;if(E<-Math.PI)E+=OB;else if(E>Math.PI)E-=OB;if(B<=E)this._spherical.theta=Math.max(B,Math.min(E,this._spherical.theta));else this._spherical.theta=this._spherical.theta>(B+E)/2?Math.max(B,this._spherical.theta):Math.min(E,this._spherical.theta)}if(this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0)this.target.addScaledVector(this._panOffset,this.dampingFactor);else this.target.add(this._panOffset);this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let I=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let C=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),I=C!=this._spherical.radius}if(AB.setFromSpherical(this._spherical),AB.applyQuaternion(this._quatInverse),Q.copy(this.target).add(AB),this.object.lookAt(this.target),this.enableDamping===!0)this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor);else this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0);if(this.zoomToCursor&&this._performCursorZoom){let C=null;if(this.object.isPerspectiveCamera){let G=AB.length();C=this._clampDistance(G*this._scale);let K=G-C;this.object.position.addScaledVector(this._dollyDirection,K),this.object.updateMatrixWorld(),I=!!K}else if(this.object.isOrthographicCamera){let G=new d(this._mouse.x,this._mouse.y,0);G.unproject(this.object);let K=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),I=K!==this.object.zoom;let J=new d(this._mouse.x,this._mouse.y,0);J.unproject(this.object),this.object.position.sub(J).add(G),this.object.updateMatrixWorld(),C=AB.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;if(C!==null)if(this.screenSpacePanning)this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(C).add(this.object.position);else if(XG.origin.copy(this.object.position),XG.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(XG.direction))QU||8*(1-this._lastQuaternion.dot(this.object.quaternion))>QU||this._lastTargetPosition.distanceToSquared(this.target)>QU)return this.dispatchEvent(RD),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0;return!1}_getAutoRotationAngle(A){if(A!==null)return OB/60*this.autoRotateSpeed*A;else return OB/60/60*this.autoRotateSpeed}_getZoomScale(A){let Q=Math.abs(A*0.01);return Math.pow(0.95,this.zoomSpeed*Q)}_rotateLeft(A){this._sphericalDelta.theta-=A}_rotateUp(A){this._sphericalDelta.phi-=A}_panLeft(A,Q){AB.setFromMatrixColumn(Q,0),AB.multiplyScalar(-A),this._panOffset.add(AB)}_panUp(A,Q){if(this.screenSpacePanning===!0)AB.setFromMatrixColumn(Q,1);else AB.setFromMatrixColumn(Q,0),AB.crossVectors(this.object.up,AB);AB.multiplyScalar(A),this._panOffset.add(AB)}_pan(A,Q){let B=this.domElement;if(this.object.isPerspectiveCamera){let E=this.object.position;AB.copy(E).sub(this.target);let I=AB.length();I*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*A*I/B.clientHeight,this.object.matrix),this._panUp(2*Q*I/B.clientHeight,this.object.matrix)}else if(this.object.isOrthographicCamera)this._panLeft(A*(this.object.right-this.object.left)/this.object.zoom/B.clientWidth,this.object.matrix),this._panUp(Q*(this.object.top-this.object.bottom)/this.object.zoom/B.clientHeight,this.object.matrix);else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1}_dollyOut(A){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale/=A;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_dollyIn(A){if(this.object.isPerspectiveCamera||this.object.isOrthographicCamera)this._scale*=A;else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1}_updateZoomParameters(A,Q){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let B=this.domElement.getBoundingClientRect(),E=A-B.left,I=Q-B.top,C=B.width,G=B.height;this._mouse.x=E/C*2-1,this._mouse.y=-(I/G)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(A){return Math.max(this.minDistance,Math.min(this.maxDistance,A))}_handleMouseDownRotate(A){this._rotateStart.set(A.clientX,A.clientY)}_handleMouseDownDolly(A){this._updateZoomParameters(A.clientX,A.clientX),this._dollyStart.set(A.clientX,A.clientY)}_handleMouseDownPan(A){this._panStart.set(A.clientX,A.clientY)}_handleMouseMoveRotate(A){this._rotateEnd.set(A.clientX,A.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let Q=this.domElement;this._rotateLeft(OB*this._rotateDelta.x/Q.clientHeight),this._rotateUp(OB*this._rotateDelta.y/Q.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(A){if(this._dollyEnd.set(A.clientX,A.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0)this._dollyOut(this._getZoomScale(this._dollyDelta.y));else if(this._dollyDelta.y<0)this._dollyIn(this._getZoomScale(this._dollyDelta.y));this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(A){this._panEnd.set(A.clientX,A.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(A){if(this._updateZoomParameters(A.clientX,A.clientY),A.deltaY<0)this._dollyIn(this._getZoomScale(A.deltaY));else if(A.deltaY>0)this._dollyOut(this._getZoomScale(A.deltaY));this.update()}_handleKeyDown(A){let Q=!1;switch(A.code){case this.keys.UP:if(A.ctrlKey||A.metaKey||A.shiftKey){if(this.enableRotate)this._rotateUp(OB*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,this.keyPanSpeed);Q=!0;break;case this.keys.BOTTOM:if(A.ctrlKey||A.metaKey||A.shiftKey){if(this.enableRotate)this._rotateUp(-OB*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(0,-this.keyPanSpeed);Q=!0;break;case this.keys.LEFT:if(A.ctrlKey||A.metaKey||A.shiftKey){if(this.enableRotate)this._rotateLeft(OB*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(this.keyPanSpeed,0);Q=!0;break;case this.keys.RIGHT:if(A.ctrlKey||A.metaKey||A.shiftKey){if(this.enableRotate)this._rotateLeft(-OB*this.keyRotateSpeed/this.domElement.clientHeight)}else if(this.enablePan)this._pan(-this.keyPanSpeed,0);Q=!0;break}if(Q)A.preventDefault(),this.update()}_handleTouchStartRotate(A){if(this._pointers.length===1)this._rotateStart.set(A.pageX,A.pageY);else{let Q=this._getSecondPointerPosition(A),B=0.5*(A.pageX+Q.x),E=0.5*(A.pageY+Q.y);this._rotateStart.set(B,E)}}_handleTouchStartPan(A){if(this._pointers.length===1)this._panStart.set(A.pageX,A.pageY);else{let Q=this._getSecondPointerPosition(A),B=0.5*(A.pageX+Q.x),E=0.5*(A.pageY+Q.y);this._panStart.set(B,E)}}_handleTouchStartDolly(A){let Q=this._getSecondPointerPosition(A),B=A.pageX-Q.x,E=A.pageY-Q.y,I=Math.sqrt(B*B+E*E);this._dollyStart.set(0,I)}_handleTouchStartDollyPan(A){if(this.enableZoom)this._handleTouchStartDolly(A);if(this.enablePan)this._handleTouchStartPan(A)}_handleTouchStartDollyRotate(A){if(this.enableZoom)this._handleTouchStartDolly(A);if(this.enableRotate)this._handleTouchStartRotate(A)}_handleTouchMoveRotate(A){if(this._pointers.length==1)this._rotateEnd.set(A.pageX,A.pageY);else{let B=this._getSecondPointerPosition(A),E=0.5*(A.pageX+B.x),I=0.5*(A.pageY+B.y);this._rotateEnd.set(E,I)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let Q=this.domElement;this._rotateLeft(OB*this._rotateDelta.x/Q.clientHeight),this._rotateUp(OB*this._rotateDelta.y/Q.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(A){if(this._pointers.length===1)this._panEnd.set(A.pageX,A.pageY);else{let Q=this._getSecondPointerPosition(A),B=0.5*(A.pageX+Q.x),E=0.5*(A.pageY+Q.y);this._panEnd.set(B,E)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(A){let Q=this._getSecondPointerPosition(A),B=A.pageX-Q.x,E=A.pageY-Q.y,I=Math.sqrt(B*B+E*E);this._dollyEnd.set(0,I),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let C=(A.pageX+Q.x)*0.5,G=(A.pageY+Q.y)*0.5;this._updateZoomParameters(C,G)}_handleTouchMoveDollyPan(A){if(this.enableZoom)this._handleTouchMoveDolly(A);if(this.enablePan)this._handleTouchMovePan(A)}_handleTouchMoveDollyRotate(A){if(this.enableZoom)this._handleTouchMoveDolly(A);if(this.enableRotate)this._handleTouchMoveRotate(A)}_addPointer(A){this._pointers.push(A.pointerId)}_removePointer(A){delete this._pointerPositions[A.pointerId];for(let Q=0;Q`top-=${this.gl.sizes.height/2} bottom`,end:()=>`bottom+=${this.gl.sizes.height/2} top`,invalidateOnRefresh:!0,onEnter:()=>{this.isRendering=!0,this.renderPlane.visible=!0},onEnterBack:()=>{this.isRendering=!0,this.renderPlane.visible=!0},onLeave:()=>{this.isRendering=!1,this.renderPlane.visible=!1},onLeaveBack:()=>{this.isRendering=!1,this.renderPlane.visible=!1}}))}getBounds(){if(this.params?.isFollowingDom)this.bounds=this.params.dom.getBoundingClientRect();else this.bounds={width:this.gl.sizes.width,height:this.gl.sizes.height,left:0,top:0}}setDefaultScroll(A){if(A.type==="regular")this.gsapResources.push(n.fromTo(A.renderPlane.material.uniforms.uPosition.value,{y:()=>Math.max(this.gl.sizes.height,this.bounds.height)},{y:()=>-Math.max(this.gl.sizes.height,this.bounds.height),ease:"none",scrollTrigger:{invalidateOnRefresh:!0,scrub:!0,trigger:A.trigger,start:()=>`center-=${Math.max(this.gl.sizes.height,this.bounds.height)} top+=${this.gl.sizes.height/2}`,end:()=>`center+=${Math.max(this.gl.sizes.height,this.bounds.height)} top+=${this.gl.sizes.height/2}`,refreshPriority:-99}}));else if(A.type==="sticky")this.gsapResources.push(n.fromTo(A.renderPlane.material.uniforms.uPosition.value,{y:()=>this.gl.sizes.height},{y:0,ease:"none",scrollTrigger:{invalidateOnRefresh:!0,scrub:!0,trigger:A.trigger,start:()=>`top-=${this.gl.sizes.height} top+=${Math.max((this.gl.sizes.height-this.bounds.height)/2,0)} `,end:()=>`top top+=${Math.max((this.gl.sizes.height-this.bounds.height)/2,0)}`,refreshPriority:-99}})),this.gsapResources.push(n.fromTo(A.renderPlane.material.uniforms.uPosition.value,{y:0},{y:()=>-this.gl.sizes.height,ease:"none",scrollTrigger:{invalidateOnRefresh:!0,scrub:!0,trigger:A.endTrigger?A.endTrigger:A.trigger,start:()=>`bottom top+=${this.gl.sizes.height}`,end:()=>`bottom+=${this.gl.sizes.height} top+=${this.gl.sizes.height}`,refreshPriority:-100}}))}setDebug(){this.debugFolder=this.gl.world.debugFolder.addFolder({title:"Scene: "+this.params.id.charAt(0).toUpperCase()+this.params.id.slice(1)})}async compile(){return new Promise(async(A)=>{A()})}renderPipeline(){}update(){}dispose(){if(this.renderPlane.geometry.dispose(),this.renderPlane.material.dispose(),this.gl.dispose.allTextures(this.renderPlane),this.gsapResources.forEach((A)=>A.kill()),this.gsapResources=[],this.debugFolder)this.debugFolder.dispose()}}class bC{gl;scene;camera;quad;downMaterial;upMaterial;targets;constructor(){this.gl=new qB,this.scene=new DB,this.camera=new hE(-1,1,1,-1,0,1),this.downMaterial=new hQ({uniforms:{tDiffuse:new UA(null),uHalfPixel:new UA(new LA)},vertexShader:` varying vec2 vUv; void main() { vUv = uv; gl_Position = vec4(position.xy, 0.0, 1.0); } `,fragmentShader:` varying vec2 vUv; uniform sampler2D tDiffuse; uniform vec2 uHalfPixel; void main() { vec4 sum = texture2D(tDiffuse, vUv) * 4.0; sum += texture2D(tDiffuse, vUv - uHalfPixel.xy); sum += texture2D(tDiffuse, vUv + uHalfPixel.xy); sum += texture2D(tDiffuse, vUv + vec2(uHalfPixel.x, -uHalfPixel.y)); sum += texture2D(tDiffuse, vUv - vec2(uHalfPixel.x, -uHalfPixel.y)); gl_FragColor = sum / 8.0; } `}),this.upMaterial=new hQ({uniforms:{tDiffuse:new UA(null),uHalfPixel:new UA(new LA)},vertexShader:` varying vec2 vUv; void main() { vUv = uv; gl_Position = vec4(position.xy, 0.0, 1.0); } `,fragmentShader:` varying vec2 vUv; uniform sampler2D tDiffuse; uniform vec2 uHalfPixel; void main() { vec4 sum = texture2D(tDiffuse, vUv + vec2(-uHalfPixel.x * 2.0, 0.0)); sum += texture2D(tDiffuse, vUv + vec2(-uHalfPixel.x, uHalfPixel.y)) * 2.0; sum += texture2D(tDiffuse, vUv + vec2(0.0, uHalfPixel.y * 2.0)); sum += texture2D(tDiffuse, vUv + vec2(uHalfPixel.x, uHalfPixel.y)) * 2.0; sum += texture2D(tDiffuse, vUv + vec2(uHalfPixel.x * 2.0, 0.0)); sum += texture2D(tDiffuse, vUv + vec2(uHalfPixel.x, -uHalfPixel.y)) * 2.0; sum += texture2D(tDiffuse, vUv + vec2(0.0, -uHalfPixel.y * 2.0)); sum += texture2D(tDiffuse, vUv + vec2(-uHalfPixel.x, -uHalfPixel.y)) * 2.0; gl_FragColor = sum / 12.0; } `}),this.quad=new _Q(new HB(2,2),this.downMaterial),this.scene.add(this.quad),this.targets=[]}get texture(){return this.targets[0]?.texture??null}ensureTargets(A,Q,B){for(let E=0;E0;U--)this.upMaterial.uniforms.tDiffuse.value=G,this.upMaterial.uniforms.uHalfPixel.value.set(0.5/K,0.5/J),C.setRenderTarget(this.targets[U-1]),C.render(this.scene,this.camera),G=this.targets[U-1].texture,K*=2,J*=2;return C.setRenderTarget(null),this.targets[0]}dispose(){this.targets.forEach((A)=>A.dispose()),this.quad.geometry.dispose(),this.downMaterial.dispose(),this.upMaterial.dispose()}}class qI{gl;dom;bounds;params;isMouseHolding;isMouseMoved;width;height;default;normalized;direction;pace;drag;constructor(A,Q){this.gl=new qB,this.dom=A,this.bounds=this.dom?this.getPositionOfDom():{left:0,top:0,width:window.innerWidth,height:window.innerHeight,right:window.innerWidth,bottom:window.innerHeight},this.params={limitToBounds:Q?.limitToBounds||!1},this.isMouseHolding=!1,this.isMouseMoved=!1,this.width=this.bounds.width,this.height=this.bounds.height,this.default=new LA,this.normalized={current:new LA,previous:new LA},this.direction=new LA,this.pace={default:0,separated:new LA},this.drag={start:new LA,distance:{default:0,separated:new LA},side:"left",pace:{default:0,separated:new LA}},document.addEventListener("mousemove",this.mousemove.bind(this)),document.addEventListener("touchmove",this.touchmove.bind(this)),document.addEventListener("mousedown",this.down.bind(this)),document.addEventListener("touchstart",this.down.bind(this)),document.addEventListener("mouseup",this.up.bind(this)),document.addEventListener("touchend",this.up.bind(this)),document.addEventListener("mouseleave",this.mouseleave.bind(this)),document.addEventListener("touchleave",this.mouseleave.bind(this))}mouseleave(){this.direction.set(0,0),this.pace.default=0,this.pace.separated.set(0,0)}mousemove(A){if(this.isMouseMoved=!0,this.default.x=A.clientX-this.bounds.left,this.default.y=this.dom?A.pageY-this.bounds.top:A.clientY-this.bounds.top,this.params.limitToBounds){if(this.default.x<0||this.default.x>this.bounds.width||this.default.y<0||this.default.y>this.bounds.height)return;this.default.x=Math.max(0,Math.min(this.bounds.width,this.default.x)),this.default.y=Math.max(0,Math.min(this.bounds.height,this.default.y))}if(this.normalized.current.x=this.default.x/this.bounds.width*2-1,this.normalized.current.y=-(this.default.y/this.bounds.height)*2+1,this.isMouseHolding){if(this.drag.distance.default=this.drag.start.distanceTo(this.default),this.drag.distance.separated.x=this.default.x-this.drag.start.x,this.drag.distance.separated.y=this.default.y-this.drag.start.y,this.drag.start.xthis.bounds.width||this.default.y<0||this.default.y>this.bounds.height)return;this.default.x=Math.max(0,Math.min(this.bounds.width,this.default.x)),this.default.y=Math.max(0,Math.min(this.bounds.height,this.default.y))}if(this.normalized.current.x=this.default.x/this.bounds.width*2-1,this.normalized.current.y=-(this.default.y/this.bounds.height)*2+1,this.isMouseHolding)if(this.drag.distance.default=this.drag.start.distanceTo(this.default),this.drag.distance.separated.x=this.default.x-this.drag.start.x,this.drag.distance.separated.y=this.default.y-this.drag.start.y,this.drag.start.x{Q.x=mQ.damp(Q.x,this.default.x,B,C),Q.y=mQ.damp(Q.y,this.default.y,B,C)},setAmount:(C)=>{B=C}}}createEasedNormalized(A){let Q=new LA,B=A;return{value:Q,update:(C)=>{Q.x=mQ.damp(Q.x,this.normalized.current.x,B,C),Q.y=mQ.damp(Q.y,this.normalized.current.y,B,C)},setAmount:(C)=>{B=C}}}createEasedDirection(A){let Q=new LA,B=A;return{value:Q,update:(C)=>{Q.x=mQ.damp(Q.x,this.direction.x,B,C),Q.y=mQ.damp(Q.y,this.direction.y,B,C)},setAmount:(C)=>{B=C}}}createEasedPace(A){let Q={default:0,separated:new LA},B=A;return{value:Q,update:(C)=>{Q.default=mQ.damp(Q.default,this.pace.default,B,C),Q.separated.x=mQ.damp(Q.separated.x,this.pace.separated.x,B,C),Q.separated.y=mQ.damp(Q.separated.y,this.pace.separated.y,B,C)},setAmount:(C)=>{B=C}}}createEasedDrag(A){let Q={distance:{default:0,separated:new LA},pace:{default:0,separated:new LA}},B=A;return{value:Q,update:(C)=>{Q.distance.default=mQ.damp(Q.distance.default,this.drag.distance.default,B,C),Q.distance.separated.x=mQ.damp(Q.distance.separated.x,this.drag.distance.separated.x,B,C),Q.distance.separated.y=mQ.damp(Q.distance.separated.y,this.drag.distance.separated.y,B,C),Q.pace.default=mQ.damp(Q.pace.default,this.drag.pace.default,B,C),Q.pace.separated.x=mQ.damp(Q.pace.separated.x,this.drag.pace.separated.x,B,C),Q.pace.separated.y=mQ.damp(Q.pace.separated.y,this.drag.pace.separated.y,B,C)},setAmount:(C)=>{B=C}}}}var LG=48,YD=[[452,1,0,0,0,1,0],[453,0.999892,0.000086,0.000013,-0.000002,1.000203,-0.000098],[454,1.000022,0.000042,-0.000067,0.000065,1.000313,-0.000172],[455,1.000468,0.000035,-0.000292,0.000025,1.000524,-0.000251],[456,1.000642,0.00003,-0.000397,0.00023,1.000906,-0.000527],[457,1.000738,0.000037,-0.000477,0.000272,1.000938,-0.000548],[458,1.000236,0.000012,-0.000301,0.000205,1.000552,-0.000325],[459,0.999535,-0.000037,-0.000061,0.00013,1.000026,0.000018],[460,0.998019,0.000049,0.000336,0.000353,0.998525,0.000695],[461,0.996416,0.000018,0.000819,0.000488,0.997094,0.001365],[462,0.993684,0.00008,0.001486,0.000536,0.994567,0.002656],[463,0.991412,-0.000005,0.002037,0.000873,0.992005,0.003814],[464,0.98318,0.000285,0.003941,0.001488,0.983,0.008244],[465,0.976812,-0.000003,0.005773,0.002316,0.976738,0.01166],[466,0.970849,-0.000259,0.007426,0.002286,0.97001,0.015635],[467,0.963016,-0.00159,0.010425,0.005128,0.961235,0.020301],[468,0.954936,-0.002988,0.013509,0.009862,0.950876,0.025184],[469,0.947722,-0.004244,0.016276,0.014826,0.943035,0.028421],[470,0.941972,-0.005675,0.01832,0.022435,0.936143,0.02991],[471,0.934477,-0.008989,0.021878,0.036984,0.927949,0.029386],[472,0.925546,-0.013158,0.026387,0.056613,0.916625,0.02841],[473,0.916776,-0.017471,0.031073,0.074174,0.905074,0.028631],[474,0.905734,-0.022637,0.037084,0.096689,0.891511,0.0278],[475,0.89484,-0.028157,0.04306,0.127075,0.87581,0.024475],[476,0.883611,-0.033578,0.049339,0.152071,0.857461,0.024998],[477,0.87054,-0.03728,0.055927,0.172681,0.841258,0.026891],[478,0.857212,-0.040751,0.062799,0.193738,0.821659,0.030926],[479,0.840243,-0.049142,0.073516,0.220258,0.802693,0.032097],[480,0.822426,-0.053043,0.082165,0.242613,0.779587,0.03736],[481,0.806475,-0.057149,0.090278,0.261147,0.762248,0.041523],[482,0.785932,-0.059776,0.099897,0.278467,0.744386,0.047687],[483,0.766599,-0.060769,0.109149,0.282927,0.729973,0.059272],[484,0.740877,-0.057384,0.1194,0.29997,0.708703,0.069308],[485,0.71498,-0.049263,0.128138,0.308241,0.686482,0.083501],[486,0.705335,-0.032991,0.133397,0.214715,0.6794,0.143501],[487,0.67683,-0.042547,0.148558,0.250558,0.650378,0.147651],[488,0.626618,-0.057388,0.177301,0.282327,0.590089,0.175809],[489,0.59309,-0.074656,0.201505,0.273992,0.520256,0.220162],[490,0.556447,-0.096583,0.224713,0.295745,0.474061,0.238535],[491,0.52851,-0.119128,0.238628,0.37425,0.448993,0.218003],[492,0.491612,-0.1302,0.254596,0.408424,0.460711,0.207588],[493,0.466016,-0.136852,0.269371,0.399707,0.42915,0.237877],[494,0.405494,-0.183142,0.321917,0.312175,0.399454,0.309008]],qD=[[452,1,0,0,0,1,0],[453,1,-0,-0,0,1,-0],[454,1.000196,0.000128,-0.000138,-0.000055,1.000162,-0.000014],[455,1.000578,0.000154,-0.00039,-0.000017,1.000344,-0.000074],[456,1.001298,0.00005,-0.000831,0.000128,1.000948,-0.000244],[457,1.00117,0.00007,-0.000765,0.000126,1.0005,-0.000055],[458,1.000795,-0.000183,-0.00048,-0.000025,1.000529,0.00009],[459,1.000152,-0.000131,-0.00017,0.00018,0.999786,0.000305],[460,0.999269,0.000023,0.000292,0.000073,0.999282,0.000633],[461,0.997801,0.000141,0.001081,0.000016,0.998014,0.001251],[462,0.996516,0.000018,0.001881,0.000228,0.996704,0.001785],[463,0.993635,0.000301,0.003403,0.00001,0.99429,0.003128],[464,0.990561,0.000141,0.005101,-0.00003,0.99185,0.004461],[465,0.985112,0.000149,0.008036,-0.000134,0.987489,0.006819],[466,0.979614,-0.000222,0.011138,-0.00039,0.983146,0.009416],[467,0.971284,-0.002074,0.016236,0.000822,0.977566,0.012134],[468,0.961503,-0.005407,0.022726,0.002211,0.969357,0.016221],[469,0.952664,-0.007286,0.028219,0.002692,0.961609,0.020608],[470,0.943378,-0.009414,0.033896,0.003812,0.95588,0.024087],[471,0.934409,-0.010986,0.038874,0.007959,0.949738,0.026243],[472,0.923136,-0.019357,0.0475,0.01423,0.93554,0.030798],[473,0.911063,-0.029332,0.057113,0.021329,0.91925,0.035713],[474,0.895941,-0.041524,0.068924,0.03057,0.897047,0.042045],[475,0.88207,-0.053877,0.080239,0.039655,0.873612,0.049012],[476,0.867255,-0.065499,0.091587,0.049243,0.848138,0.056598],[477,0.849606,-0.074288,0.103545,0.058085,0.825776,0.063431],[478,0.833544,-0.070523,0.111625,0.061527,0.800768,0.074783],[479,0.812448,-0.070369,0.123314,0.071249,0.778614,0.082297],[480,0.773684,-0.104902,0.152979,0.091913,0.730903,0.095687],[481,0.746051,-0.129476,0.17462,0.099642,0.704477,0.105746],[482,0.744453,-0.06297,0.170136,0.023399,0.690259,0.155308],[483,0.703846,-0.099658,0.206863,0.021009,0.654475,0.176248],[484,0.670622,-0.201945,0.236437,0.106032,0.631455,0.14101],[485,0.644155,-0.123617,0.243208,0.05066,0.601406,0.18932],[486,0.636663,-0.113033,0.247918,0.039933,0.59977,0.198365],[487,0.597744,-0.131347,0.287305,0.018109,0.568882,0.229343],[488,0.597223,-0.126451,0.286686,0.018392,0.570163,0.230323],[489,0.529694,-0.092598,0.335538,-0.020003,0.552912,0.267351],[490,0.526408,-0.071094,0.331983,-0.020066,0.551809,0.268398],[491,0.445986,-0.195799,0.421873,-0.029102,0.560374,0.28142],[492,0.437022,-0.19795,0.42762,-0.029453,0.561032,0.281911]],MD=[[452,1,0,0,0,1,0],[453,1.000047,0.000129,-0.000094,-0.000011,1.000048,-0.000008],[454,1.000229,0.000148,-0.000207,0.000024,1.00026,-0.000139],[455,1.000573,0.000188,-0.000384,-0.000025,1.000573,-0.000262],[456,1.00093,0.000352,-0.00067,0.000004,1.000973,-0.00046],[457,1.00094,0.000318,-0.000688,0.00001,1.001021,-0.000485],[458,1.000533,0.000357,-0.000596,0.000057,1.000778,-0.00039],[459,0.999774,0.000362,-0.000357,0.000053,0.999887,0.000083],[460,0.998252,0.000306,0.000138,-0.000031,0.998297,0.000963],[461,0.996915,0.000812,0.000217,0.000048,0.996931,0.001619],[462,0.993994,0.000495,0.001161,0.000013,0.994379,0.002972],[463,0.991937,0.000835,0.001437,-0.000031,0.992136,0.004179],[464,0.984083,0.000864,0.003339,-0.000108,0.983515,0.00885],[465,0.978055,0.000674,0.005002,-0.00038,0.977514,0.012712],[466,0.972238,0.000557,0.00652,-0.000611,0.971036,0.016811],[467,0.962251,-0.001427,0.0111,-0.001833,0.960961,0.024184],[468,0.952678,-0.002946,0.015283,-0.002696,0.948771,0.032846],[469,0.944491,-0.00427,0.018846,-0.004094,0.940075,0.039757],[470,0.936497,-0.00533,0.022161,-0.004446,0.931039,0.046505],[471,0.924499,-0.007325,0.027968,-0.006259,0.919672,0.055777],[472,0.912745,-0.008565,0.033534,-0.007617,0.905123,0.067064],[473,0.899708,-0.00986,0.039886,-0.009001,0.889761,0.079161],[474,0.885413,-0.010954,0.046988,-0.011323,0.86943,0.094859],[475,0.872059,-0.010891,0.053713,-0.015971,0.840631,0.116924],[476,0.855333,-0.013993,0.062675,-0.008756,0.854041,0.108071],[477,0.837675,-0.014773,0.071653,-0.008128,0.840353,0.118836],[478,0.819564,-0.01521,0.081268,-0.00869,0.824246,0.132584],[479,0.797878,-0.01668,0.092917,-0.009842,0.808205,0.14688],[480,0.787944,-0.014449,0.096921,-0.008674,0.798049,0.156268],[481,0.770981,-0.011366,0.104352,-0.008503,0.781694,0.169336],[482,0.754699,-0.00112,0.109787,-0.008057,0.765525,0.182818],[483,0.737332,0.012813,0.115081,-0.007967,0.747683,0.197344],[484,0.726955,0.009829,0.121165,-0.004532,0.722375,0.213667],[485,0.729578,0.002896,0.12182,-0.003001,0.708203,0.22588],[486,0.714751,0.001809,0.130662,-0.002958,0.690334,0.242495],[487,0.694501,0.002059,0.141975,-0.001793,0.670111,0.259387],[488,0.655656,0.002307,0.16522,0.003618,0.637123,0.288784],[489,0.632431,-0.001276,0.181389,-0.003528,0.623346,0.309815],[490,0.610806,-0.003457,0.195957,-0.003553,0.608742,0.328687],[491,0.584944,-0.00369,0.211499,-0.000494,0.576146,0.352389],[492,0.563982,-0.004536,0.224816,0.002047,0.556117,0.370439],[493,0.549851,-0.003549,0.236356,0.002008,0.543624,0.386341],[494,0.526414,-0.011625,0.257639,-0.022573,0.488862,0.430432],[495,0.510077,-0.015183,0.272764,-0.027299,0.460799,0.453194],[496,0.493371,-0.020781,0.287392,-0.030599,0.432528,0.474211],[497,0.478532,-0.029613,0.303061,-0.035241,0.396923,0.498974],[498,0.475757,-0.0329,0.313644,-0.043358,0.375469,0.521689]],ND=[[452,1,0,0,0,1,0],[453,1,-0,0,-0,1.000001,-0],[454,1.00017,0.000294,-0.000239,0.000075,1.000074,-0.00006],[455,1.000452,0.000361,-0.000443,0.000202,1.000065,-0.000064],[456,1.00098,0.000518,-0.000853,0.000237,1.000048,-0.000005],[457,1.000752,0.000342,-0.000647,0.00027,0.999939,0.000052],[458,1.000414,0.000572,-0.000609,0.000488,0.999862,0.000056],[459,0.999463,0.000553,-0.000084,0.000592,0.99945,0.000247],[460,0.99884,0.000465,0.00034,0.000394,0.998883,0.000613],[461,0.997742,0.000321,0.001039,0.000269,0.998054,0.001067],[462,0.996003,-0.000934,0.002558,0.000487,0.997586,0.001231],[463,0.993503,-0.000805,0.003827,0.000372,0.995357,0.002597],[464,0.990267,-0.001554,0.005927,0.000461,0.993642,0.003632],[465,0.98546,-0.001855,0.008488,0.000185,0.990279,0.005781],[466,0.979883,-0.002637,0.01175,0.00019,0.986446,0.008138],[467,0.971426,-0.004903,0.017319,-0.000084,0.980705,0.011876],[468,0.960884,-0.009093,0.02491,-0.00067,0.972333,0.01732],[469,0.950492,-0.014303,0.032826,-0.00149,0.963323,0.02311],[470,0.939264,-0.018667,0.040493,-0.001771,0.954019,0.029031],[471,0.925569,-0.022438,0.049016,-0.001356,0.944949,0.034623],[472,0.909143,-0.025227,0.058734,-0.001436,0.930975,0.043],[473,0.89288,-0.026025,0.067856,-0.001512,0.917033,0.051174],[474,0.873411,-0.027846,0.079054,-0.001816,0.900431,0.060778],[475,0.85542,-0.027373,0.089291,-0.001863,0.88315,0.070602],[476,0.837247,-0.014263,0.096565,-0.001937,0.865438,0.081083],[477,0.820936,0.006929,0.100692,-0.001941,0.851136,0.089883],[478,0.800406,0.023453,0.108995,-0.000536,0.836873,0.098787],[479,0.778781,0.020363,0.123194,0.002775,0.820134,0.108653],[480,0.779167,-0.004112,0.134305,-0.002233,0.802182,0.12319],[481,0.764683,-0.013125,0.147756,-0.001264,0.795423,0.13016],[482,0.753887,-0.014296,0.15579,-0.002969,0.782381,0.139343],[483,0.719002,-0.010563,0.176207,0.003313,0.764165,0.150025],[484,0.709985,-0.009353,0.1824,0.000075,0.753797,0.15814],[485,0.678292,-0.010711,0.206133,-0.001846,0.725858,0.177988],[486,0.672399,-0.017023,0.212841,-0.005772,0.71313,0.186877],[487,0.640693,-0.005834,0.233406,0.000833,0.696604,0.198031],[488,0.6368,-0.007886,0.236931,-0.000267,0.690604,0.202047],[489,0.602102,-0.015901,0.269965,-0.001869,0.652999,0.227982],[490,0.60074,-0.015521,0.27088,-0.001918,0.650801,0.229484],[491,0.570298,-0.016022,0.2976,-0.002396,0.616668,0.252664],[492,0.567448,-0.016731,0.298976,-0.002083,0.614943,0.253701],[493,0.533624,-0.03084,0.332402,-0.002467,0.569365,0.28274],[494,0.532479,-0.031412,0.33326,-0.002577,0.567715,0.283775]];function IU(A,Q,B,E){let I=B*Q,C=A[0],G=A[A.length-1];if(I<=C[0])return E.identity();let K=G;if(I #include /* Unsharp mask — 5-tap cross. Adds back the difference between the center texel and its neighbourhood average, which counteracts the softness introduced by the zoom resampling. */ vec4 sharpen(sampler2D _tex, vec2 _uv, vec2 _texel, float _strength) { vec4 center = texture2D(_tex, _uv); vec3 neighbours = texture2D(_tex, _uv + vec2(_texel.x, 0.0)).rgb; neighbours += texture2D(_tex, _uv - vec2(_texel.x, 0.0)).rgb; neighbours += texture2D(_tex, _uv + vec2(0.0, _texel.y)).rgb; neighbours += texture2D(_tex, _uv - vec2(0.0, _texel.y)).rgb; vec3 result = center.rgb + (center.rgb - neighbours * 0.25) * _strength; return vec4(max(result, vec3(0.0)), center.a); } void main() { vec2 uv = zoomUv(vUv, 1.0 + uTransition10 * 0.03); // Zoom at the end uv = zoomUv(uv, 1.0 - (uTransition8 * uZoomStrength + uTransition9 * uZoomStrength), uZoomPivot); // Zoom on scroll 1 & 2 vec4 composite = sharpen(tComposite, uv, uCompositeTexel, uSharpenStrength); composite.rgb = mix(composite.rgb, mix(vec3(0.0, 0.05, 0.075), composite.rgb, mix(1.0, 0.25, uTransition7)), smoothstep(0.66, 1.0, vUv.y) * smoothstep(0.5, 0.0, vUv.x)); vec4 bloom = texture2D(tBloomPass, uv); vec4 final = composite + bloom * uBloomStrength; /* Fog */ vec2 noiseUv0 = vUv; noiseUv0 *= 0.5; noiseUv0.x *= uAspect; noiseUv0 -= uTime * 0.1; float textureNoise0 = texture2D(tNoise, noiseUv0).r; vec2 noiseUv1 = vUv; noiseUv1 *= 0.5; noiseUv1.x *= uAspect; noiseUv1 *= textureNoise0; float textureNoise1 = texture2D(tNoise, noiseUv1).g; vec2 fogUv = vUv * 2.0 - 1.0; fogUv.x *= uAspect; vec4 fog = vec4(smoothstep(0.25, 1.0, textureNoise1)) * FOG_OPACITY; fog *= min(length(fogUv * 0.5), 1.0); final = fog + final * (1.0 - fog.a); /* Rounded Corners */ // insets: (top, right, bottom, left) vec4 insets = vec4( 0.0, uTransition10 * 0.5 * (0.08 - 0.03), // 0.08 is the dom position, 0.02 is the margin uTransition10 * (0.05 - 0.015 * uAspect), uTransition10 * 0.5 * (0.08 - 0.03) ); vec4 rect = rectFromInsets(insets, uAspect); vec2 sdfUv = vUv - rect.xy; sdfUv.x *= uAspect; float radius = uTransition10 * uCornerRadius; float sdf = roundedRectSdfCorners( sdfUv, rect.zw, vec4(0.0, 0.0, radius, radius) ); float mask = 1.0 - smoothstep(0.0, fwidth(sdf), sdf); /* Add background color */ final = mix(vec4(COLOR_BACKGROUND, 1.0), final, mask); /* Grid Pattern */ vec2 gridUv = vec2(uv.x * 52.5 * uAspect, (uv.y - uTime * 0.005) * 52.5); // Time offset (0.01 before), Grid size (30.0 before) vec4 grid = texture2D(tGridPattern, gridUv); grid *= uGridOpacity; // Opacity (0.125 before) grid *= mask; final = grid + final * (1.0 - grid.a); /* Output */ gl_FragColor = final; } `}),this.camera=new dQ(32,this.bounds.width/this.bounds.height,0.1,100),this.setCameraZoom(),this.camera.position.z=5,this.camera.updateProjectionMatrix(),this.setCharacterModel(),this.setCardsModel(),this.setPreloaderAnimation(),this.setScrollTimeline(),this.setIsRendering(),this.setRandomInterval(),this.params?.isFollowingDom)this.setDefaultScroll({renderPlane:this.renderPlane,trigger:this.doms.start,endTrigger:this.doms.end,type:"sticky"});if(this.gl.isDebug)this.setDebug()}getCornerRadius(){let A=parseFloat(getComputedStyle(document.documentElement).fontSize),Q=parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--radius-lg"));return A*Q*(1.35+(this.gl.sizes.aspect-1)*0.5)/this.bounds.height}setControls(){this.controls=new EU(this.camera,document.documentElement)}setRandomInterval(){this.randomInterval=setInterval(()=>{this.globalUniforms.uRandom.value=Math.random()},200)}setCameraZoom(){if(this.gl.sizes.isDesktop)this.camera.fov=this.gl.sizes.setResponsiveFov(32,1.8,1,this.bounds.width/this.bounds.height,!0),this.camera.setViewOffset(this.bounds.width,this.bounds.height,0,Math.min(1.8-this.bounds.width/this.bounds.height,0)*this.bounds.height/3.6,this.bounds.width,this.bounds.height);else this.camera.fov=this.gl.sizes.setResponsiveFov(32,1.8,0.625,this.bounds.width/this.bounds.height,!0),this.camera.setViewOffset(this.bounds.width,this.bounds.height,0,0,this.bounds.width,this.bounds.height)}setIsRendering(){this.gsapResources.push(OQ.create({trigger:this.doms.start,endTrigger:this.doms.end,start:()=>`top-=${this.gl.sizes.height/2} bottom`,end:()=>`bottom+=${this.gl.sizes.height/2} top`,invalidateOnRefresh:!0,onEnter:()=>{this.isRendering=!0,this.renderPlane.visible=!0},onEnterBack:()=>{this.isRendering=!0,this.renderPlane.visible=!0},onLeave:()=>{this.isRendering=!1,this.renderPlane.visible=!1},onLeaveBack:()=>{this.isRendering=!1,this.renderPlane.visible=!1}}))}setPreloaderAnimation(){if(this.preloaderTimeline=n.timeline({paused:!0}),this.gsapResources.push(this.preloaderTimeline),!rA["preloader:ended"])rA.once("preloader:ended",()=>{this.preloaderTimeline.play()});else this.preloaderTimeline.play();this.preloaderTimeline.to(this.compositeUniforms.uPreloaderOpacity,{value:1,duration:1,ease:"none"},0),this.preloaderTimeline.fromTo(this.gl.assets.videos.preloader.image,{currentTime:0},{currentTime:1,duration:1,ease:"none",onUpdate:()=>{this.gl.assets.videos.preloader.needsUpdate=!0},onComplete:()=>{rA["webgl:hero:preloader_ended"]=!0,this.gl.assets.videos.preloader.dispose()}},0.8),this.preloaderTimeline.fromTo(this.compositeUniforms.uTransitionPreloader,{value:0},{value:1,duration:0.25,ease:"none"},1.65),this.preloaderTimeline.fromTo(this.characterUniforms.uTransitionPreloader,{value:0},{value:1,duration:1,ease:"none"},1.3),this.preloaderTimeline.fromTo(this.cardsUniforms.uTransitionPreloader,{value:0},{value:1,duration:0.5,ease:"none"},1.6)}triggerSnap(A,Q,B,E){if(this.isSnapping)return;if(E<0.01||E>0.99)return;this.isSnapping=!0;let I=NQ.direction;NQ.scrollTo(I==1?Q+1:A-1,{lock:!0,duration:B,easing:(C)=>C,onComplete:()=>{this.isSnapping=!1}})}triggerAutoScroll(A,Q,B,E,I=!1){let C=Q;if(I){if(E<0.5)C=A}if(this.autoScrollTimeout)clearTimeout(this.autoScrollTimeout);this.autoScrollTimeout=setTimeout(()=>{NQ.scrollTo(C,{duration:I&&E<0.5?B*E:B*(1-E),easing:(G)=>G})},this.gl.sizes.isDesktop?25:150)}setScrollTimeline(){this.scrollParentATimeline=n.timeline({scrollTrigger:{trigger:this.doms.start,start:`${this.gl.sizes.isDesktop?"top+=10% top":"top+=5% top"}`,end:"bottom top",scrub:!0,onUpdate:(J)=>{this.triggerSnap(J.start,J.end,2.5,J.progress)},onEnter:()=>{this.heroFrameIndex=0}}}),this.gsapResources.push(this.scrollParentATimeline),this.scrollParentBTimeline=n.timeline({paused:!0,scrollTrigger:{trigger:this.doms.end,start:"top+=0.5% top",end:"top+=20% top",scrub:!0,onUpdate:(J)=>{this.triggerSnap(J.start,J.end,1.5,J.progress)},onEnterBack:()=>{this.isInHero=!0},onLeaveBack:()=>{if(this.autoScrollTimeout)clearTimeout(this.autoScrollTimeout)},onLeave:()=>{if(this.autoScrollTimeout)clearTimeout(this.autoScrollTimeout);this.isInHero=!1}}}),this.gsapResources.push(this.scrollParentBTimeline),this.scrollParentCTimeline=n.timeline({paused:!0,scrollTrigger:{trigger:this.doms.end,start:"top+=20.5% top",end:"top+=45% top",scrub:!0,onUpdate:(J)=>{this.triggerSnap(J.start,J.end,2.25,J.progress)},onLeaveBack:()=>{if(this.autoScrollTimeout)clearTimeout(this.autoScrollTimeout)},onLeave:()=>{if(this.autoScrollTimeout)clearTimeout(this.autoScrollTimeout)}}}),this.gsapResources.push(this.scrollParentCTimeline),this.scrollParentETimeline=n.timeline({paused:!0,scrollTrigger:{trigger:this.doms.end,start:"top+=45.5% top",end:"top+=72.5% top",scrub:!0,onUpdate:(J)=>{this.triggerSnap(J.start,J.end,2.5,J.progress)},onLeaveBack:()=>{if(this.autoScrollTimeout)clearTimeout(this.autoScrollTimeout)},onLeave:()=>{if(this.autoScrollTimeout)clearTimeout(this.autoScrollTimeout)}}}),this.gsapResources.push(this.scrollParentETimeline),this.scrollParentE3Timeline=n.timeline({paused:!0,scrollTrigger:{trigger:this.doms.end,start:"top+=72.5% top",end:"top+=86% top",scrub:!0,onUpdate:(J)=>{this.triggerSnap(J.start,J.end,1,J.progress)},onLeaveBack:()=>{if(this.autoScrollTimeout)clearTimeout(this.autoScrollTimeout)},onLeave:()=>{if(this.autoScrollTimeout)clearTimeout(this.autoScrollTimeout)}}}),this.gsapResources.push(this.scrollParentE3Timeline),this.transition1Timeline=n.timeline({onComplete:()=>{this.characterModel.visible=!1,this.characterModelBlurred.visible=!1,this.cardsParentsBack.firstItem.visible=!1,this.cardsParentsBackBlurred.firstItem.visible=!1,this.cardsParentsFront.firstItem.visible=!1}}),this.scrollParentATimeline.add(this.transition1Timeline,0),this.transition1Timeline.fromTo(this.characterUniforms.uTransition1,{value:0},{value:1,duration:1,ease:"none"},0),this.transition1Timeline.fromTo(this.cardsUniforms.uTransition1,{value:0},{value:1,duration:0.4,ease:"none"},0.2),this.transition1Timeline.fromTo(this.compositeUniforms.uTransition1,{value:0},{value:1,duration:1,ease:"none"},0),this.transition1Timeline.fromTo(this,{cardsTransitionRotation:0},{cardsTransitionRotation:Math.PI/8,duration:0.5,ease:"power2.in"},0),this.transition2Timeline=n.timeline({onReverseComplete:()=>{this.characterModel.visible=!0,this.characterModelBlurred.visible=!0,this.cardsParentsBack.firstItem.visible=!0,this.cardsParentsBackBlurred.firstItem.visible=!0,this.cardsParentsFront.firstItem.visible=!0}}),this.scrollParentATimeline.add(this.transition2Timeline,0.5),this.transition2Timeline.fromTo(this.gl.assets.videos.heroDesktop.userData.mandatoryVideo.image,{currentTime:()=>0},{currentTime:()=>3.95,duration:1,ease:"none",immediateRender:!1,onUpdate:()=>{this.gl.assets.videos.heroDesktop.userData.mandatoryVideo.needsUpdate=!0}},0),this.transition2Timeline.fromTo(this.compositeUniforms.uVideoTransition,{value:1},{value:0,duration:0.1,ease:"none",immediateRender:!1,onStart:()=>{this.heroFrameIndex=0}},0.9),this.transition2Timeline.fromTo(this.compositeUniforms.uTransition2,{value:0},{value:1,duration:0.25,ease:"none",immediateRender:!1},0.2),this.transition3Timeline=n.timeline(),this.scrollParentATimeline.add(this.transition3Timeline,1),this.transition3Timeline.fromTo(this.compositeUniforms.uTransition3,{value:0},{value:1,duration:0.5,ease:"none"},0);let A=3.95;this.transition4Timeline=n.timeline({onUpdate:()=>{let J=this.transition4Timeline.progress()<0.5?3.95:5.7;if(J===A)return;A=J,this.gl.assets.videos.heroDesktop.userData.mandatoryVideo.image.currentTime=J,this.gl.assets.videos.heroDesktop.userData.mandatoryVideo.needsUpdate=!0}}),this.scrollParentBTimeline.add(this.transition4Timeline),this.transition4Timeline.fromTo(this.compositeUniforms.uTransition4,{value:0},{value:1,duration:0.2,ease:"none"},0),this.transition4Timeline.fromTo(this.compositeUniforms.uVideoHqTransition,{value:0},{value:1,duration:0.05,ease:"none",immediateRender:!1},0),this.transition4Timeline.fromTo(this.gl.assets.videos.heroDesktopHqTransition.userData.mandatoryVideo.image,{currentTime:()=>0},{currentTime:()=>this.gl.assets.videos.heroDesktopHqTransition.userData.mandatoryVideo.image.duration*0.99,duration:0.5,ease:"none",immediateRender:!1,onUpdate:()=>{this.gl.assets.videos.heroDesktopHqTransition.userData.mandatoryVideo.needsUpdate=!0}},0),this.transition4Timeline.fromTo(this,{heroFrameIndex:0},{heroFrameIndex:1,duration:0.01,ease:"steps(1)",immediateRender:!1,onComplete:()=>{}},0.225),this.transition4Timeline.fromTo(this.compositeUniforms.uVideoHqTransition,{value:1},{value:0,duration:0.05,ease:"none",immediateRender:!1},0.45),this.transition5Timeline=n.timeline(),this.scrollParentCTimeline.add(this.transition5Timeline),this.transition5Timeline.fromTo(this.compositeUniforms.uTransition5,{value:0},{value:1,duration:0.2,ease:"none"},0),this.transition5Timeline.fromTo(this.compositeUniforms.uVideoTransition,{value:0},{value:1,duration:0.2,ease:"none",immediateRender:!1},0),this.transition5Timeline.fromTo(this,{heroFrameIndex:1},{heroFrameIndex:2,duration:0.01,ease:"steps(1)",immediateRender:!1},1),this.transition5Timeline.fromTo(this.compositeUniforms.uVideoTransition,{value:1},{value:0,duration:0.2,ease:"none",immediateRender:!1},1.8),this.transition5Timeline.fromTo(this.gl.assets.videos.heroDesktop.userData.mandatoryVideo.image,{currentTime:()=>5.7},{currentTime:()=>9.5,duration:2,ease:"none",immediateRender:!1,onUpdate:()=>{this.gl.assets.videos.heroDesktop.userData.mandatoryVideo.needsUpdate=!0}},0),this.scrollParentCTimeline.fromTo(this.renderPlane.material.uniforms.uBloomStrength,{value:0.45},{value:0,duration:0.2,ease:"none",immediateRender:!1},1),this.transition6Timeline=n.timeline(),this.scrollParentCTimeline.add(this.transition6Timeline,1),this.transition6Timeline.fromTo([this.compositeUniforms.uTransition6,this.renderPlane.material.uniforms.uTransition6],{value:0},{value:1,duration:0.2,ease:"none"},0),this.transition6Timeline.fromTo([this.compositeUniforms.uTransition7,this.renderPlane.material.uniforms.uTransition7],{value:0},{value:1,duration:1,ease:"none"},0),this.transition8Timeline=n.timeline({onUpdate:()=>{let J=this.gl.assets.videos.heroDesktop.userData.mandatoryVideo.image.currentTime;IU(this.gl.sizes.isDesktop?YD:qD,LG,J,this.compositeUniforms.uWheelUv.value),IU(this.gl.sizes.isDesktop?MD:ND,LG,J,this.compositeUniforms.uWindowUv.value)}}),this.scrollParentETimeline.add(this.transition8Timeline);let Q=9.5,B=12.3,E=(J)=>(J/LG-Q)/(B-Q);this.transition8Timeline.fromTo(this.renderPlane.material.uniforms.uTransition8,{value:0},{value:1,duration:1,ease:"power3.inOut"},0),this.transition8Timeline.fromTo(this.compositeUniforms.uVideoTransition,{value:0},{value:1,duration:0.1,ease:"none",immediateRender:!1},0),this.transition8Timeline.fromTo(this.gl.assets.videos.heroDesktop.userData.mandatoryVideo.image,{currentTime:()=>Q},{currentTime:()=>B,delay:0.15,duration:0.85,ease:"none",immediateRender:!1,onUpdate:()=>{this.gl.assets.videos.heroDesktop.userData.mandatoryVideo.needsUpdate=!0}},0),this.transition8Timeline.fromTo(this,{heroFrameIndex:2},{heroFrameIndex:3,duration:0.01,ease:"steps(1)",immediateRender:!1},0.5),this.transition8Timeline.fromTo(this.compositeUniforms.uVideoTransition,{value:1},{value:0,duration:0.1,ease:"none",immediateRender:!1},0.7);let I=E(466),C=E(this.gl.sizes.isDesktop?494:492);this.transition8Timeline.fromTo(this.compositeUniforms.uCarExitFade,{value:0},{value:1,duration:1,ease:"none",immediateRender:!1},I);let G=E(486),K=E(this.gl.sizes.isDesktop?498:494);this.transition8Timeline.fromTo(this.compositeUniforms.uWindowOpen,{value:0},{value:1,duration:K-G,ease:"none",immediateRender:!1},G),this.transition10Timeline=n.timeline(),this.scrollParentE3Timeline.add(this.transition10Timeline),this.transition10Timeline.fromTo(this.renderPlane.material.uniforms.uTransition10,{value:0},{value:1,duration:1,ease:"none"},1)}createCharacterModel(){let A=this.gl.sizes.isDesktop?new LA(1,1):new LA(1,1.5),Q=new _Q(new HB(A.x,A.y),new hQ({transparent:!0,defines:{...this.globalDefines,PIXEL_FACTOR:75},uniforms:{...this.globalUniforms,...this.characterUniforms,uRectAspect:new UA(A)},vertexShader:` varying vec2 vUv; varying vec4 vClipPosition; void main() { // Billboard in view space: keep model position/scale, ignore rotation. vec4 mvCenter = modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0); float scaleX = length(vec3(modelMatrix[0].xyz)); float scaleY = length(vec3(modelMatrix[1].xyz)); mvCenter.xy += position.xy * vec2(scaleX, scaleY); gl_Position = projectionMatrix * mvCenter; vUv = uv; vClipPosition = gl_Position; } `,fragmentShader:` varying vec2 vUv; varying vec4 vClipPosition; uniform sampler2D tDiffuse; uniform sampler2D tNormalDepth; uniform sampler2D tTransitionColor; uniform sampler2D tNoise; uniform float uAspect; uniform float uImageAspect; uniform vec2 uRectAspect; uniform float uTransition1; uniform float uTransitionPreloader; uniform float uTime; uniform float uRandom; uniform vec2 uMouse; uniform vec3 COLOR_TRANSITION; uniform vec3 COLOR_HIGHLIGHT; #include #include #include #include #include #include void main() { /* Uv */ // vec2 uv = vUv; vec2 screenUv = (vClipPosition.xy / vClipPosition.w) * 0.5 + 0.5; vec2 uv = coverUv(vUv, uRectAspect.x / uRectAspect.y, uImageAspect); /* Depth Movement */ vec2 uvDepthMovement = depthMovement(tNormalDepth, uv, vec2(uMouse.x, -uMouse.y), 0.0075, vec2(0.0, 1.0)); /* Depth */ vec4 textureDepth = pixelise(tNormalDepth, uvDepthMovement, 50.0); /* Normal Map */ vec3 textureNormal = texture2D(tNormalDepth, uvDepthMovement).rgb * 2.0 - 1.0; // light *= 1.0 - vUv.x; // light *= uTra; /* Pixalated UV */ // vec2 pixelatedUv = floor(uvDepthMovement * vec2(float(PIXEL_FACTOR) * uAspect, float(PIXEL_FACTOR))) / vec2(float(PIXEL_FACTOR) * uAspect, float(PIXEL_FACTOR)); // uvDepthMovement = mix(uvDepthMovement, pixelatedUv, transitionEffect); /* Diffuse */ vec4 textureDiffuse = texture2D(tDiffuse, uvDepthMovement); /* Light */ float light = max(dot(textureNormal, vec3(1.0 - uMouse.x, uMouse.y, 0.0)), 0.0); light = pow(light, 2.0); light *= 0.5; // Default light *= smoothstep(0.25, 0.75, vUv.y); light *= textureDiffuse.a; light *= 1.0 - uTransition1; /* Transition ↳ Preloader + Start of the scroll */ float transitionEffectBase = mix(1.5, -0.5, fract(uTransitionPreloader + uTransition1)); float transitionEffect = distance(textureDepth.a, transitionEffectBase); transitionEffect = smoothstep(0.25, 0.0, transitionEffect); transitionEffect *= step(0.125, textureDepth.a); transitionEffect *= textureDiffuse.a; float transitionAlphaPreloader = mix(1.5, -0.5, uTransitionPreloader); float transitionAlphaScroll = mix(1.5, -0.5, uTransition1); // vec4 transitionDots = rgbTransitionShift(uvDepthMovement, transitionEffect); // transitionDots.rgb *= COLOR_TRANSITION; // transitionDots.a *= textureDiffuse.a; float transitionAlphaPreloaderMask = step(transitionAlphaPreloader, textureDepth.r); float transitionAlphaScrollMask = step(textureDepth.r, transitionAlphaScroll); /* Pixelated Transition */ vec4 texturePixelatedTransition = pixelPass(tTransitionColor, tNoise, uvDepthMovement, vec2(1.0, 1.0), 50.0, 1.5, vec2(1.5 - transitionEffect * 1.5, 2.5 - transitionEffect * 2.5), vec2(0.0, 0.005), vec3(0.0, 1.0, 2.0)); // Set Alpha textureDiffuse.a *= min(transitionAlphaScrollMask, transitionAlphaPreloaderMask); light *= min(transitionAlphaScrollMask, transitionAlphaPreloaderMask); /* Final */ vec4 final = textureDiffuse; final = texturePixelatedTransition + final * (1.0 - texturePixelatedTransition.a); // Add transition scroll effect // final = vec4(COLOR_HIGHLIGHT * light, light) + final * (1.0 - light); final += vec4(COLOR_HIGHLIGHT * light, light); // final = vec4(vec3(light), 1.0); // TODO: Displace the rgb somewhere here gl_FragColor = final; // gl_FragColor = vec4(pixelMaskForFace); // gl_FragColor = vec4(transitionDotsR, transitionDotsG, transitionDotsB, 1.0); // gl_FragColor = vec4(screenUv, 0.0, 1.0); } `}));return Q.position.set(this.gl.sizes.isDesktop?-0.1:-0.025,0.02,0),Q.scale.set(3.1,3.1,3.1),Q}setCharacterModel(){this.characterUniforms={tDiffuse:new UA(this.gl.assets.textures.characterStatic),tNoise:new UA(this.gl.assets.textures.noise),tNormalDepth:new UA(this.gl.assets.textures.characterNormalDepth),uTransitionPreloader:new UA(0),uTransition1:new UA(0),COLOR_HIGHLIGHT:new UA(new AQ(15380859).convertLinearToSRGB())},this.characterModel=this.createCharacterModel(),this.characterModel.renderOrder=0,this.scene.add(this.characterModel),this.characterModelBlurred=this.createCharacterModel(),this.characterModelBlurred.renderOrder=0,this.sceneBlur.add(this.characterModelBlurred)}createCards(A,Q,B){let E=this.gl.misc.createNestedParents(A);E.transform.position.copy(this.defaultCardsTransform.position),E.transform.scale.copy(this.defaultCardsTransform.scale),E.transform.rotation.copy(this.defaultCardsTransform.rotation);let I=this.gl.assets.models.cardsFront.scene.clone();return I.children.forEach((C)=>{this.setCardsMaterial(C,{...Q})}),I.renderOrder=B??0,E.lastItem.add(I),E}setCardsModel(){let A=["interaction","transform","auto-rotate"],Q=this.gl.sizes.isDesktop?0.2:0.233;this.defaultCardsTransform={position:new d(0,this.gl.sizes.isDesktop?0:-0.5,0),scale:new d(Q,Q,Q),rotation:new PB(-0.3,-0.56,-0.23)},this.cardsTransitionRotation=0,this.cardsUniforms={uTransitionPreloader:new UA(0),uTransition1:new UA(0)},this.cardsParentArray=[],this.cardsParentsBack=this.createCards(A,{side:iQ},-1),this.cardsParentsBackBlurred=this.createCards(A,{side:iQ},-1),this.scene.add(this.cardsParentsBack.firstItem),this.sceneBlur.add(this.cardsParentsBackBlurred.firstItem),this.cardsParentArray.push(this.cardsParentsBack),this.cardsParentArray.push(this.cardsParentsBackBlurred),this.cardsParentsFront=this.createCards(A,{side:GB,depthWrite:!1,depthTest:!1},1),this.scene.add(this.cardsParentsFront.firstItem),this.cardsParentArray.push(this.cardsParentsFront)}setCardsMaterial(A,Q){let B=null;if(A.material instanceof UI&&A.material.map)B=A.material.map;A.material=new hQ({transparent:Q?.transparent??!0,side:Q?.side||GB,depthWrite:Q?.depthWrite??!0,depthTest:Q?.depthTest??!0,defines:{HAS_MAP:B?1:0,IS_FRONT_SIDE:Q?.side===GB?1:0},uniforms:{tDiffuse:new UA(B),tBlurPass:new UA(this.dualKawaseBlurLayer.texture),...this.cardsUniforms,...this.globalUniforms,BACKGROUND_COLOR:new UA(new AQ(this.gl.misc.cssColors.getPropertyValue("--color-primary-dark").trim()).convertLinearToSRGB())},vertexShader:` varying vec2 vUv; varying vec4 vClipPosition; void main() { vClipPosition = projectionMatrix * modelViewMatrix * vec4(position, 1.0); gl_Position = vClipPosition; vUv = uv; } `,fragmentShader:` varying vec2 vUv; varying vec4 vClipPosition; uniform sampler2D tDiffuse; uniform sampler2D tBlurPass; uniform vec3 BACKGROUND_COLOR; uniform float uTransitionPreloader; uniform float uTransition1; uniform vec2 uMouse; #include #include void main() { vec4 color = vec4(0.0); /* Has Map */ #if HAS_MAP vec4 textureDiffuse = texture2D(tDiffuse, vUv); /* Front Side */ #if IS_FRONT_SIDE vec2 screenUv = (vClipPosition.xy / vClipPosition.w) * 0.5 + 0.5; screenUv += 0.0025; // Glass displacement vec4 textureBlurPass = texture2D(tBlurPass, screenUv); textureDiffuse.rgb *= textureDiffuse.a; // Premultiply alpha color = textureBlurPass + vec4(BACKGROUND_COLOR, 1.0) * (1.0 - textureBlurPass.a); color = textureDiffuse + color * (1.0 - textureDiffuse.a); // color = // color = vec4(screenUv, 0.0, 1.0); #else /* Back Side */ color = textureDiffuse; #endif // color = textureDiffuse; #endif gl_FragColor = color; gl_FragColor *= min(1.0 - uTransition1, uTransitionPreloader); } `})}setCompositePipeline(){this.compositeUniforms={tDiffuse:new UA(this.renderTarget.texture),tStars:new UA(this.gl.assets.textures.stars),tNoise:new UA(this.gl.assets.textures.noise),tVideoHeroLq:new UA(this.gl.assets.videos.heroDesktop.userData.mandatoryVideo),tFrameHero:new UA(null),tVideoHeroHq:new UA(this.gl.assets.videos.heroDesktopHqTransition.userData.mandatoryVideo),tVideoPreloader:new UA(this.gl.assets.videos.preloader),tCarNormalDepth:new UA(this.gl.assets.textures.carNormalDepth),tCarNormalDepthLast:new UA(this.gl.assets.textures.carNormalDepthLast),tWheelMask:new UA(this.gl.assets.textures.wheelMask),tMasks:new UA(this.gl.assets.textures.masks),tPhoneNormalDepth:new UA(this.gl.assets.textures.phoneNormalDepth),tCharacterEyesMask:new UA(this.gl.assets.textures.characterEyesMask),uPreloaderUvOffset:new UA(new LA(this.gl.sizes.isDesktop?0.0125:0.005,0)),uPreloaderOpacity:new UA(0),uTransitionPreloader:new UA(0),uTransition1:new UA(0),uTransition2:new UA(0),uTransition3:new UA(0),uTransition4:new UA(0),uTransition5:new UA(0),uTransition6:new UA(0),uTransition7:new UA(0),uWheelUv:new UA(new KQ),uCarExitFade:new UA(0),uWindowUv:new UA(new KQ),uWindowOpen:new UA(0),uVideoTransition:new UA(1),uVideoHqTransition:new UA(0),uUvCoverPivot:new UA(this.gl.sizes.isDesktop?new LA(0.5,1):new LA(0.5,0.5)),COLOR_HIGHLIGHT_MOBILE:new UA(new AQ(15384955).convertLinearToSRGB()),COLOR_HIGHLIGHT_CAR:new UA(new AQ(15384955).convertLinearToSRGB()),...this.globalUniforms},this.renderTargetComposite=new lQ(this.bounds.width*this.gl.sizes.pixelRatio,this.bounds.height*this.gl.sizes.pixelRatio,{}),this.sceneComposite=new DB,this.compositeMesh=new _Q(new HB(1,1,100,100),new hQ({defines:{...this.globalDefines,PIXEL_FACTOR:140,NOISE_SCALE:1.25,NOISE_CHANGE_SPEED:0.33,GOD_RAY_MAX_SAMPLES:32,PIXEL_MULTI_PASS_MAX_SAMPLES:16},uniforms:{...this.compositeUniforms},vertexShader:` uniform float uTime; uniform float uAspect; uniform vec2 uMouse; varying float vNoiseMask; varying vec2 vUv; #include void main() { vec2 pos = position.xy * 2.0; gl_Position = vec4(pos.xy, 0.0, 1.0); vNoiseMask = snoise(vec4((pos.x - uMouse.x * 0.2) * uAspect * NOISE_SCALE, (pos.y - uMouse.y * 0.2) * NOISE_SCALE, 0.0, uTime * NOISE_CHANGE_SPEED)) * 0.5 + 0.5; vUv = uv; } `,fragmentShader:` varying float vNoiseMask; varying vec2 vUv; uniform sampler2D tDiffuse; uniform sampler2D tVideoHeroLq; uniform sampler2D tFrameHero; uniform sampler2D tVideoHeroHq; uniform sampler2D tStars; uniform sampler2D tNoise; uniform sampler2D tTransitionColor; uniform sampler2D tVideoPreloader; uniform sampler2D tCarNormalDepth; uniform sampler2D tCarNormalDepthLast; uniform sampler2D tPhoneNormalDepth; uniform sampler2D tWheelMask; uniform sampler2D tMasks; uniform sampler2D tCharacterEyesMask; uniform float uAspect; uniform float uTime; uniform float uImageAspect; uniform float uVideoAspect; uniform float uRandom; uniform float uVideoTransition; uniform float uVideoHqTransition; uniform vec2 uUvCoverPivot; uniform vec2 uPreloaderUvOffset; uniform float uPreloaderOpacity; uniform float uTransitionPreloader; uniform float uTransition1; uniform float uTransition2; uniform float uTransition3; uniform float uTransition4; uniform float uTransition5; uniform float uTransition6; uniform float uTransition7; uniform mat3 uWheelUv; uniform float uCarExitFade; uniform mat3 uWindowUv; uniform float uWindowOpen; uniform vec2 uMouse; uniform vec3 COLOR_TRANSITION; uniform vec3 COLOR_HIGHLIGHT_MOBILE; uniform vec3 COLOR_HIGHLIGHT_CAR; #include #include #include #include #include #include #include #include #include #include void main() { /* UVs */ vec2 uv = vUv; vec2 textureUv = coverUv(vUv, uAspect, uImageAspect, uUvCoverPivot); vec2 videoUv = coverUv(vUv, uAspect, uVideoAspect, uUvCoverPivot); // vec2 preloaderUv = videoUv + vec2(0.0, -0.05); vec2 uvMobileDepth = depthMovement(tPhoneNormalDepth, videoUv, vec2(uMouse.x, -uMouse.y), 0.0075 * min(uTransition3, 1.0 - uTransition5), vec2(0.0, 0.7)); // Depth map crossfades to the last-step authoring as the car leaves, on the same curve as the wheel fx vec2 uvCarDepth = depthMovement(tCarNormalDepth, tCarNormalDepthLast, uCarExitFade, videoUv, vec2(uMouse.x, -uMouse.y), 0.005 * uTransition6, vec2(0.0, 0.5)); vec2 uvNormalised = (uv - 0.5) * 2.0; uvNormalised.x *= uAspect; /* Pixel Mask for Face */ float pixelMaskForFace = texture2D(tCharacterEyesMask, videoUv).r; /* Textures */ vec4 textureDiffuse = texture2D(tDiffuse, uv); float textureMobileDepth = texture2D(tPhoneNormalDepth, uvMobileDepth).a; float textureMobileDepthPixelised = pixelise(tPhoneNormalDepth, uvMobileDepth, 50.0).a; // The last-step authoring now sits ON TOP of the rest frame rather than crossfading with it, // using the same alpha-over idiom as the final composite. It keeps its original 0.75→1.0 // fade-in, while the rest frame underneath is faded out across the first quarter of the exit. vec4 textureCarNormalDepthLast = texture2D(tCarNormalDepthLast, uvCarDepth) * smoothstep(0.75, 1.0, uCarExitFade); float carNormalDepthFade = smoothstep(0.25, 0.0, uCarExitFade); vec4 textureCarNormalDepth = textureCarNormalDepthLast + texture2D(tCarNormalDepth, uvCarDepth) * carNormalDepthFade * (1.0 - textureCarNormalDepthLast.a) * smoothstep(0.15, 0.0, uCarExitFade); float textureCarDepth = textureCarNormalDepth.a; float textureCarDepthPixelised = mix(pixelise(tCarNormalDepth, uvCarDepth, 50.0), pixelise(tCarNormalDepthLast, uvCarDepth, 50.0), uCarExitFade).a; /* Stars */ // Gated on the uniform that already scales the result to zero – uniform branch, so the // whole warp skips the mask tap and the three star taps outside the car section. float textureStars = 0.0; // if (uTransition7 > 0.0) { // Window mask follows the windshield frame, then opens up to the whole screen vec2 uvWindow = (uWindowUv * vec3(uvCarDepth, 1.0)).xy; // float textureWindowsMask = mix(texture2D(tMasks, uvWindow).g, 1.0, uWindowOpen); float textureWindowsMask = texture2D(tMasks, uvWindow).g; // float textureWindowsMask = 1.0; // Whisps sit ON the glass, so the field rides the same track as the mask that gates it and // magnifies with the windshield. Once uWindowOpen has retired the mask there is no glass // left to sit on, so it hands back to screen space – same mix as the mask above, which also // keeps the end state identical to the untracked look instead of freezing the last warp. vec2 uvStars = mix(uvCarDepth, uvWindow, uWindowOpen * 0.2); vec2 uvStars0 = vec2(uvStars.x * 1.5 + uTime * 0.3, uvStars.y * 1.5 + uTime * 0.11); vec2 uvStars1 = vec2(uvStars.x * 1.5 + uTime * 0.3 * 0.25, uvStars.y * 1.5 + uTime * 0.11 * 0.25); vec2 uvStars2 = vec2(uvStars.x * 1.5 + uTime * 0.3 * 0.125, uvStars.y * 1.5 + uTime * 0.11 * 0.125); float textureStars0 = texture2D(tStars, uvStars0).a; float textureStars1 = texture2D(tStars, uvStars1).a; float textureStars2 = texture2D(tStars, uvStars2).a; textureStars = max(max(textureStars0, textureStars1), textureStars2); textureStars *= uTransition7; textureStars *= 0.66; textureStars *= textureWindowsMask; // } /* Normal Maps */ vec3 textureMobileNormal = texture2D(tPhoneNormalDepth, uvMobileDepth).rgb * 2.0 - 1.0; vec3 textureCarNormal = textureCarNormalDepth.rgb * 2.0 - 1.0; /* Transitions */ float transition3 = mix(1.5, -0.5, fract(uTransition3 + uTransition4 + uTransition5)); float transitionEffectMobile = distance(textureMobileDepthPixelised, transition3); transitionEffectMobile = smoothstep(0.25, 0.0, transitionEffectMobile); transitionEffectMobile *= step(0.125, textureMobileDepthPixelised); // vec4 mobileTransitionDots = rgbTransitionShift(uvMobileDepth, transitionEffectMobile); // mobileTransitionDots.rgb *= COLOR_TRANSITION; // mobileTransitionDots *= step(0.1, textureMobileDepthPixelised); float transition7 = mix(1.5, -0.5, uTransition7); float transitionEffectCar = distance(textureCarDepthPixelised, transition7); transitionEffectCar = smoothstep(0.25, 0.0, transitionEffectCar); transitionEffectCar *= step(0.125, textureCarDepthPixelised); float transitionEffectVideo = mix(transitionEffectMobile, transitionEffectCar, uTransition6); // vec4 carTransitionDots = rgbTransitionShift(uvCarDepth, transitionEffectCar); // carTransitionDots.rgb *= COLOR_TRANSITION; // carTransitionDots *= step(0.1, textureCarDepthPixelised); /* Video */ vec2 uvVideo = mix(uvMobileDepth, uvCarDepth, uTransition6); vec4 textureVideoPreloader = texture2D(tVideoPreloader, uvVideo + uPreloaderUvOffset); vec4 textureVideoHero = texture2D(tVideoHeroLq, uvVideo); vec4 textureFrameHero = texture2D(tFrameHero, uvVideo); // Rest frame composited over the video – an unloaded frame is fully transparent, so the video stays visible textureVideoHero.rgb = mix(textureVideoHero.rgb, textureFrameHero.rgb, textureFrameHero.a * (1.0 - uVideoTransition)); // Hq clip layered over both – plays on top of whatever is underneath, so the frame can be swapped while it covers vec4 textureVideoHeroHq = texture2D(tVideoHeroHq, uvVideo); textureVideoHero.rgb = mix(textureVideoHero.rgb, textureVideoHeroHq.rgb, textureVideoHeroHq.a * uVideoHqTransition); /* Noise */ float noiseMask = smoothstep(0.5, 0.66, vNoiseMask); /* Pixelated */ vec2 gradientUvDiffuse = fract(vec2(uv.x * 140.0 * uAspect, uv.y * 140.0)); float invertedGradientDotsDiffuse = length(gradientUvDiffuse - 0.5) * 2.0; vec2 gradientUvVideo = fract(vec2(uvVideo.x * 50.0 * uAspect, uvVideo.y * 50.0)); float invertedGradientDotsVideo = length(gradientUvVideo - 0.5) * 2.0; vec4 texturePixelated = pixelPass(tDiffuse, tNoise, uv, vec2(1.0, 1.0), 140.0, 1.5, vec2(0.0, 1.0), vec2(0.0), vec3(0.0, 1.0, 2.0)); /* Dots */ float dots = dotPass(mix(textureVideoPreloader.rgb, textureVideoHero.rgb, uTransitionPreloader), invertedGradientDotsDiffuse); dots *= max(max(min(uTransition1, 1.0 - uTransition2), min(uTransition5, 1.0 - uTransition6)), 1.0 - uTransitionPreloader); dots *= uPreloaderOpacity; /* Lights */ float lightMobile = max(dot(textureMobileNormal, vec3(uMouse.x, uMouse.y, 0.0)), 0.0); lightMobile = pow(lightMobile, 2.0); // lightMobile *= 0.5; lightMobile *= smoothstep(1.0, 0.75, vUv.x); lightMobile *= smoothstep(0.0, 0.2, textureMobileDepth); lightMobile *= min(uTransition3, 1.0 - uTransition5); float lightCar = max(dot(textureCarNormal, vec3(uMouse.x * -1.0, uMouse.y, 0.0)), 0.0); lightCar *= 0.33; lightCar *= uTransition7; lightCar *= smoothstep(0.0, 0.2, textureCarDepth); /* Pixelated Wheel + God Rays */ // Both ride the same fade, and together they are by far the heaviest thing in the shader // (12 pixelPass samples at 5 taps each, plus GOD_RAY_MAX_SAMPLES taps). One uniform branch // around the pair skips all of it while the fade holds the result at zero anyway. float carFxAmount = uTransition7 * smoothstep(0.25, 0.0, uCarExitFade); vec4 texturePixelatedWheel = vec4(0.0); float rays = 0.0; // if (carFxAmount > 0.0) { // Wheel mask follows the wheel through the fly-out instead of staying at the rest frame vec2 uvWheel = (uWheelUv * vec3(uvCarDepth, 1.0)).xy; // texturePixelatedWheel = pixelPass(tWheelMask, tNoise, uvCarDepth, 75.0, 0.5, vec2(0.0, 0.25), vec2(0.0, 0.0075), vec3(0.0, 1.0, 2.0)); texturePixelatedWheel = pixelMultiPass(tWheelMask, tNoise, uvWheel - vec2(0.0, -0.01), vec2(1.0, 0.0), 75.0, 1.0, vec2(0.125, 0.25), vec2(0.0, -0.00175), vec3(2.0, 1.0, 0.0), 12); texturePixelatedWheel *= carFxAmount; rays = godRays(tWheelMask, uvWheel, vec2(uMouse.x, -uMouse.y), 0.3, 0.025); rays *= carFxAmount; // rays = blendOverlay(textureDiffuse.rgb, HIGHLIGHT_COLOR, rays); // } /* Pixelated Transition */ vec4 texturePixelatedTransition = pixelPass(tTransitionColor, tNoise, uvVideo, vec2(1.0, 1.0), 50.0, 1.5, vec2(1.5 - transitionEffectVideo * 1.5, 2.5 - transitionEffectVideo * 2.5), vec2(0.0, 0.005), vec3(0.0, 1.0, 2.0)); /* Mixed */ vec4 mixed = mix( textureDiffuse, texturePixelated, noiseMask * pixelMaskForFace ); /* Final */ vec4 final = mixed; final = final + textureVideoHero * uTransition2 * max(1.0 - uTransition5, uTransition6) * (1.0 - final.a); final = vec4(dots) + final * (1.0 - dots); // final = mobileTransitionDots + final * (1.0 - mobileTransitionDots.a); // final = carTransitionDots + final * (1.0 - carTransitionDots.a); // final = vec4(COLOR_HIGHLIGHT_MOBILE * lightMobile, lightMobile) + final * (1.0 - lightMobile); // final = vec4(COLOR_HIGHLIGHT_CAR * lightCar, lightCar) + final * (1.0 - lightCar); final = texturePixelatedTransition + final * (1.0 - texturePixelatedTransition.a); final += vec4(COLOR_HIGHLIGHT_MOBILE * lightMobile, lightMobile); final += vec4(COLOR_HIGHLIGHT_CAR * lightCar, lightCar); final = texturePixelatedWheel + final * (1.0 - texturePixelatedWheel.a); final = vec4(rays) + final * (1.0 - rays); final = textureStars + final * (1.0 - textureStars); // final = videoPixelated; // final += vec4(starsUv, 0.0, 1.0); gl_FragColor = final; // Debug // gl_FragColor.r += textureWindowsMask; // gl_FragColor.g += texturePixelatedWheel.g; // gl_FragColor += vec4(pixelMaskForFace); } `})),this.compositeMesh.frustumCulled=!1,this.compositeMesh.matrixAutoUpdate=!1,this.sceneComposite.add(this.compositeMesh)}setBlurPipeline(){this.blurResMultiplier=0.5,this.renderTargetBlur=new lQ(this.bounds.width*this.blurResMultiplier,this.bounds.height*this.blurResMultiplier,{minFilter:VQ,magFilter:VQ}),this.sceneBlur=new DB,this.blurParams={levels:2},this.dualKawaseBlurLayer=new bC,this.dualKawaseBlurLayer.ensureTargets(this.blurParams.levels,this.renderTargetBlur.width,this.renderTargetBlur.height)}setBloomPipeline(){this.bloomParams={levels:4},this.dualKawaseBlur=new bC,this.dualKawaseBlur.ensureTargets(this.bloomParams.levels,this.renderTargetComposite.width,this.renderTargetComposite.height)}setDebug(){super.setDebug(),this.timelineFolder=this.debugFolder.addFolder({title:"Timeline"});let A={progress:0};this.timelineFolder.addBinding(A,"progress",{label:"Progress",min:0,max:1,step:0.01}).on("change",(E)=>{this.globalTimeline.progress(E.value)}),this.blurFolder=this.debugFolder.addFolder({title:"Blur",expanded:!1}),this.blurFolder.addBinding(this.blurParams,"levels",{label:"Levels",min:1,max:6,step:1}),this.debugFolder.addBinding(this.renderPlane.material.uniforms.uGridOpacity,"value",{label:"Grid Opacity",min:0,max:1,step:0.001}),this.debugFolder.addBinding(this.renderPlane.material.uniforms.uSharpenStrength,"value",{label:"Sharpen",min:0,max:2,step:0.01}),this.bloomFolder=this.debugFolder.addFolder({title:"Bloom",expanded:!1}),this.bloomFolder.addBinding(this.bloomParams,"levels",{label:"Levels",min:1,max:6,step:1}),this.bloomFolder.addBinding(this.renderPlane.material.uniforms.uBloomStrength,"value",{label:"Strength",min:0,max:2,step:0.01}),this.cardsFolder=this.debugFolder.addFolder({title:"Cards",expanded:!1});let Q={value:this.defaultCardsTransform.scale.x};this.cardsFolder.addBinding(Q,"value",{min:0.01,max:2,step:0.01,label:"Scale"}).on("change",(E)=>{this.cardsParentArray.forEach((I)=>{I.transform.scale.set(Q.value,Q.value,Q.value)})}),this.cardsFolder.addBinding(this.defaultCardsTransform,"rotation",{label:"Rotation",min:-Math.PI*2,max:Math.PI*2,step:0.01}).on("change",(E)=>{this.cardsParentArray.forEach((I)=>{I.transform.rotation.copy(this.defaultCardsTransform.rotation)})}),this.cardsFolder.addBinding(this.defaultCardsTransform,"position",{label:"Position",min:-10,max:10,step:0.01}).on("change",(E)=>{this.cardsParentArray.forEach((I)=>{I.transform.position.copy(this.defaultCardsTransform.position)})}),this.cardsFolder.addBinding(this.cardsUniforms.uTransition1,"value",{label:"Transition 1",min:0,max:1,step:0.01}),this.characterFolder=this.debugFolder.addFolder({title:"Character",expanded:!1});let B={value:this.characterModel.scale.x};this.characterFolder.addBinding(B,"value",{min:0.1,max:4,step:0.01,label:"Scale"}).on("change",(E)=>{this.characterModel.scale.set(B.value,B.value,B.value)}),this.characterFolder.addBinding(this.characterUniforms.uTransition1,"value",{label:"Transition 1",min:0,max:1,step:0.01})}getBounds(){this.bounds={width:this.gl.sizes.width,height:this.gl.sizes.height,left:0,top:0}}resize(){super.resize(),this.renderTarget.setSize(this.bounds.width*this.gl.sizes.pixelRatio,this.bounds.height*this.gl.sizes.pixelRatio),this.renderTargetComposite.setSize(this.bounds.width*this.gl.sizes.pixelRatio,this.bounds.height*this.gl.sizes.pixelRatio),this.renderTargetBlur.setSize(this.bounds.width*this.blurResMultiplier,this.bounds.height*this.blurResMultiplier),this.dualKawaseBlurLayer.ensureTargets(this.blurParams.levels,this.renderTargetBlur.width,this.renderTargetBlur.height),this.dualKawaseBlur.ensureTargets(this.bloomParams.levels,this.renderTargetComposite.width,this.renderTargetComposite.height),this.renderPlane.material.uniforms.uResolution.value.set(this.gl.sizes.width,this.gl.sizes.height),this.renderPlane.material.uniforms.uCompositeTexel.value.set(1/this.renderTargetComposite.width,1/this.renderTargetComposite.height),this.renderPlane.material.uniforms.uPosition.value.x=this.bounds.left,this.renderPlane.material.uniforms.uScale.value.set(this.bounds.width,this.bounds.height),this.camera.aspect=this.bounds.width/this.bounds.height,this.setCameraZoom(),this.camera.updateProjectionMatrix(),this.globalUniforms.uAspect.value=this.bounds.width/this.bounds.height,this.renderPlane.material.uniforms.uCornerRadius.value=this.getCornerRadius(),this.compositeUniforms.uUvCoverPivot.value=this.gl.sizes.isDesktop?new LA(0.5,1):new LA(0.5,0.5)}async compile(){return new Promise(async(A)=>{await this.gl.renderer.instance.compileAsync(this.sceneBlur,this.camera),await this.gl.renderer.instance.compileAsync(this.dualKawaseBlurLayer.scene,this.dualKawaseBlurLayer.camera),await this.gl.renderer.instance.compileAsync(this.scene,this.camera),await this.gl.renderer.instance.compileAsync(this.sceneComposite,this.camera),await this.gl.renderer.instance.compileAsync(this.dualKawaseBlur.scene,this.dualKawaseBlur.camera),A()})}renderPipeline(){if(!this.isRendering)return;if(this.isInHero)this.gl.renderer.instance.setRenderTarget(this.renderTargetBlur),this.gl.renderer.instance.render(this.sceneBlur,this.camera),this.dualKawaseBlurLayer.render(this.renderTargetBlur,this.blurParams.levels);this.gl.renderer.instance.setRenderTarget(this.renderTarget),this.gl.renderer.instance.render(this.scene,this.camera),this.gl.renderer.instance.setRenderTarget(this.renderTargetComposite),this.gl.renderer.instance.render(this.sceneComposite,this.camera),this.dualKawaseBlur.render(this.renderTargetComposite,this.bloomParams.levels),this.renderPlane.material.uniforms.tBloomPass.value=this.dualKawaseBlur.texture}applyHeroFrame(){let A=this.gl.assets.textures.heroFrames[Math.round(this.heroFrameIndex)]||null,Q=this.compositeUniforms.tFrameHero.value;if(Q===A)return;if(this.compositeUniforms.tFrameHero.value=A,A)A.needsUpdate=!0;if(Q)Q.dispose()}update(){if(super.update(),!this.isRendering)return;if(!this.gl.sizes.isTouchDevice){this.mouse.update();for(let A in this.easedMouse)this.easedMouse[A].update(this.gl.time.delta)}this.cardsParentArray.forEach((A)=>{A["auto-rotate"].rotation.y=this.gl.time.elapsed*0.1+this.cardsTransitionRotation,A.interaction.rotation.y=this.easedMouse.normalized.value.x*0.1,A.interaction.rotation.x=this.easedMouse.normalized.value.y*0.05}),this.applyHeroFrame(),this.globalUniforms.uTime.value=this.gl.time.elapsed}dispose(){if(super.dispose(),[this.scene,this.sceneBlur,this.sceneComposite].forEach((Q)=>{Q.traverse((B)=>{if(B instanceof _Q)this.gl.dispose.allTextures(B),B.material.dispose(),B.geometry.dispose()})}),this.autoScrollTimeout)clearTimeout(this.autoScrollTimeout);if(this.randomInterval)clearInterval(this.randomInterval);this.gl.assets.videos.preloader.image.currentTime=0,this.gl.assets.videos.preloader.needsUpdate=!0,this.gl.assets.videos.heroDesktop.userData.mandatoryVideo.image.currentTime=0,this.gl.assets.videos.heroDesktop.userData.mandatoryVideo.needsUpdate=!0,this.gl.assets.videos.heroDesktopHqTransition.userData.mandatoryVideo.image.currentTime=0,this.gl.assets.videos.heroDesktopHqTransition.userData.mandatoryVideo.needsUpdate=!0,this.gl.assets.textures.heroFrames.forEach((Q)=>Q?.dispose()),this.compositeUniforms.tFrameHero.value=null,this.heroFrameIndex=0,this.mouse.dispose(),this.renderTarget.dispose(),this.renderTargetComposite.dispose(),this.renderTargetBlur.dispose(),this.compositeMesh.geometry.dispose(),this.compositeMesh.material.dispose(),this.dualKawaseBlurLayer.dispose(),this.dualKawaseBlur.dispose()}}class $G extends YI{scene;sceneBull;renderTarget;renderTargetBull;cardsModel;defaultCardsTransform;modelsState;cardsParentsBack;cardsParentsBackBlurred;cardsParentsFront;cardsModelFront;cardsModelBack;cardsUniforms;cardsParentArray;cardsTransitionRotation;sceneBlur;sceneBlurPassH;sceneBlurPassV;renderTargetBlurH;renderTargetBlurV;blurMeshH;blurMeshV;blurUniforms;bullModel;bullParent;bullPlaneUniforms;bullPlaneDefault;bullPlaneBlurred;globalUniforms;globalDefines;camera;cardsFolder;mouse;easedMouse;raycaster;isHovering;isGrabbing;constructor(A){super(A);if(this.scene=new DB,this.scene.matrixAutoUpdate=!1,this.sceneBull=new DB,this.sceneBull.matrixAutoUpdate=!1,this.renderTarget=new lQ(this.bounds.width*this.gl.sizes.pixelRatio,this.bounds.height*this.gl.sizes.pixelRatio,{}),this.renderTargetBull=new lQ(this.bounds.width*this.gl.sizes.pixelRatio,this.bounds.height*this.gl.sizes.pixelRatio,{}),this.globalDefines={},this.globalUniforms={uAspect:new UA(this.bounds.width/this.bounds.height),uTime:new UA(0)},this.setBlurPipeline(),this.renderPlane.material=new hQ({defines:{IS_FOLLOWING_DOM:this.params?.isFollowingDom?1:0},uniforms:{tDiffuse:new UA(this.renderTarget.texture),uScale:new UA(new LA(this.bounds.width,this.bounds.height)),uPosition:new UA(new LA(this.bounds.left,this.bounds.top)),uResolution:new UA(new LA(this.gl.sizes.width,this.gl.sizes.height))},vertexShader:` uniform vec2 uPosition; uniform vec2 uScale; uniform vec2 uResolution; varying vec2 vUv; void main() { vec2 pos = position.xy * 2.0; #if IS_FOLLOWING_DOM // Scale pos.x *= uScale.x / uResolution.x; pos.y *= uScale.y / uResolution.y; // Position pos.x += - 1.0 + uPosition.x / uResolution.x * 2. + uScale.x / uResolution.x; pos.y -= uPosition.y / uResolution.y * 2.0; #endif gl_Position = vec4(pos.xy, 0.0, 1.0); // Varyings vUv = uv; } `,fragmentShader:` varying vec2 vUv; uniform sampler2D tDiffuse; void main() { vec4 textureDiffuse = texture2D(tDiffuse, vUv); gl_FragColor = textureDiffuse; } `}),this.camera=new dQ(0,this.bounds.width/this.bounds.height,0.1,100),this.camera.fov=this.gl.sizes.setResponsiveFov(32,1.8,this.gl.sizes.width{if(Q instanceof _Q)Q.material=new EG({matcap:this.gl.assets.textures.glassMatcap})}),this.bullModel.rotation.y=Math.PI*0.5,this.bullModel.scale.set(0.166,0.166,0.166),this.bullParent.lastItem.add(this.bullModel),this.bullPlaneUniforms={tBullDiffuse:new UA(this.renderTargetBull.texture),PIXEL_FACTOR:new UA(this.gl.sizes.width #include void main() { vec2 screenUv = (vClipPosition.xy / vClipPosition.w) * 0.5 + 0.5; vec4 textureDiffuse = texture2D(tBullDiffuse, screenUv); vec4 texturePixelated = pixelPassBull(tBullDiffuse, screenUv + 0.002, PIXEL_FACTOR, 1.0, vec2(0.4, 0.41)); texturePixelated.rgb = max(vec3(0.85), texturePixelated.rgb); // Avoid dark spots created from partes outside the bull // texturePixelated.rgb = mix(vec3(0.85), texturePixelated.rgb, texturePixelated.a); // texturePixelated.a = textureDiffuse.a; // gl_FragColor = texturePixelated; gl_FragColor = texturePixelated + vec4(vec3(0.0), textureDiffuse.a) * (1.0 - texturePixelated.a); // Add outline } `}));return Q.scale.set(3.66,3.66,3.66),Q.renderOrder=A??0,Q}setCardsModel(){let A=["transform","auto-rotate","interaction"];this.defaultCardsTransform={position:new d(0,0,0),scale:new d(1.92,1.92,1.92),rotation:new PB(-0.06,-0.65,-0.12)},this.cardsTransitionRotation=0,this.cardsUniforms={uTransitionPreloader:new UA(0),uTransition1:new UA(0)},this.cardsParentArray=[],this.cardsParentsBack=this.createCards(A,{side:iQ},-1),this.cardsParentsBackBlurred=this.createCards(A,{side:iQ},-1),this.scene.add(this.cardsParentsBack.firstItem),this.sceneBlur.add(this.cardsParentsBackBlurred.firstItem),this.cardsParentArray.push(this.cardsParentsBack),this.cardsParentArray.push(this.cardsParentsBackBlurred),this.cardsParentsFront=this.createCards(A,{side:GB,depthWrite:!1,depthTest:!1},1),this.scene.add(this.cardsParentsFront.firstItem),this.cardsParentArray.push(this.cardsParentsFront)}createCards(A,Q,B){let E=this.gl.misc.createNestedParents(A);E.transform.position.copy(this.defaultCardsTransform.position),E.transform.scale.copy(this.defaultCardsTransform.scale),E.transform.rotation.copy(this.defaultCardsTransform.rotation);let I=new _Q(new jC(1,1,0.4,10,1,!0));return this.setCardsMaterial(I,{...Q}),I.renderOrder=B??0,I.frustumCulled=!1,E.lastItem.add(I),E}setCardsMaterial(A,Q){let B=Q?.side===GB?this.gl.assets.textures.hallOfFameCardsFront:this.gl.assets.textures.hallOfFameCardsBack;A.material=new hQ({transparent:Q?.transparent??!0,side:Q?.side||GB,depthWrite:Q?.depthWrite??!0,depthTest:Q?.depthTest??!0,defines:{HAS_MAP:B?1:0,IS_FRONT_SIDE:Q?.side===GB?1:0},uniforms:{tDiffuse:new UA(B),tBlurPass:new UA(this.renderTargetBlurV.texture),...this.cardsUniforms,...this.globalUniforms,BACKGROUND_COLOR:new UA(new AQ(this.gl.misc.cssColors.getPropertyValue("--color-surface-background").trim()).convertLinearToSRGB())},vertexShader:` varying vec2 vUv; varying vec4 vClipPosition; void main() { vClipPosition = projectionMatrix * modelViewMatrix * vec4(position, 1.0); gl_Position = vClipPosition; vUv = uv; } `,fragmentShader:` varying vec2 vUv; varying vec4 vClipPosition; uniform sampler2D tDiffuse; uniform sampler2D tBlurPass; uniform vec3 BACKGROUND_COLOR; uniform float uTransitionPreloader; uniform float uTransition1; uniform vec2 uMouse; #include #include #include void main() { vec4 color = vec4(0.0); /* Has Map */ #if HAS_MAP vec2 textureUv = stackedRowsToColumnsUv(vUv); vec4 textureDiffuse = texture2D(tDiffuse, textureUv); /* Front Side */ #if IS_FRONT_SIDE vec2 screenUv = (vClipPosition.xy / vClipPosition.w) * 0.5 + 0.5; screenUv += 0.0025; // Glass displacement vec4 textureBlurPass = texture2D(tBlurPass, screenUv); textureDiffuse.rgb *= textureDiffuse.a; // Premultiply alpha color = textureBlurPass + vec4(BACKGROUND_COLOR, 1.0) * (1.0 - textureBlurPass.a); color = textureDiffuse + color * (1.0 - textureDiffuse.a); color.a *= step(0.01, textureDiffuse.a); // color = // color = vec4(screenUv, 0.0, 1.0); #else /* Back Side */ color = textureDiffuse; #endif // color = textureDiffuse; #endif gl_FragColor = color; } `})}setBlurPipeline(){this.renderTargetBlurH=new lQ(this.bounds.width*0.4,this.bounds.height*0.4,{}),this.renderTargetBlurV=new lQ(this.bounds.width*0.4,this.bounds.height*0.4,{}),this.sceneBlur=new DB,this.sceneBlurPassH=new DB,this.sceneBlurPassV=new DB,this.blurUniforms={uStrength:new UA(0.0025),uSamples:new UA(6)},this.blurMeshH=this.createBlurMesh(new LA(1,0),this.renderTargetBlurV.texture,this.blurUniforms),this.blurMeshV=this.createBlurMesh(new LA(0,1),this.renderTargetBlurH.texture,this.blurUniforms),this.sceneBlurPassH.add(this.blurMeshH),this.sceneBlurPassV.add(this.blurMeshV)}createBlurMesh(A,Q,B){let E=new hQ({uniforms:{tDiffuse:new UA(Q),uDirection:new UA(A),...this.globalUniforms,...B},vertexShader:` varying vec2 vUv; void main() { gl_Position = vec4(position.xy * 2.0, 0.0, 1.0); vUv = uv; } `,fragmentShader:` varying vec2 vUv; uniform sampler2D tDiffuse; uniform vec2 uDirection; uniform float uStrength; uniform float uSamples; uniform float uAspect; void main() { // Offset in UV space derived from screen pixels (no DPR). vec2 texel = uDirection * vec2(uStrength / uAspect, uStrength); float sigma = uSamples * 0.5; float twoSigmaSq = 2.0 * sigma * sigma; vec4 sum = texture2D(tDiffuse, vUv); float weightSum = 1.0; for (int i = 1; i <= int(uSamples); i++) { float fi = float(i); float w = exp(-(fi * fi) / twoSigmaSq); sum += texture2D(tDiffuse, vUv + texel * fi) * w; sum += texture2D(tDiffuse, vUv - texel * fi) * w; weightSum += w * 2.0; } gl_FragColor = sum / weightSum; } `}),I=new _Q(new HB(1,1),E);return I.frustumCulled=!1,I.matrixAutoUpdate=!1,I}setRaycaster(){this.isHovering={current:!1,previous:!1},this.isGrabbing=!1,this.raycaster=new DG}onRaycast(){this.raycaster?.setFromCamera(this.mouse.normalized.current,this.camera);let A=this.raycaster?.intersectObject(this.cardsParentsFront.lastItem.children[0]);if(A&&A.length>0)this.isHovering.current=!0;else this.isHovering.current=!1;if(this.isHovering.current!==this.isHovering.previous){if(this.isHovering.current){if(this.params?.dom&&!this.isGrabbing)this.params.dom.style.cursor="grab"}else if(this.params?.dom&&!this.isGrabbing)this.params.dom.style.cursor="default"}this.isHovering.previous=this.isHovering.current}onDragStart(){if(this.isHovering.current){if(this.isGrabbing=!0,this.params?.dom)this.params.dom.style.cursor="grabbing"}}onDragEnd(){if(this.isGrabbing=!1,this.isHovering.current){if(this.params?.dom)this.params.dom.style.cursor="grab"}else if(this.params?.dom)this.params.dom.style.cursor="default"}setDebug(){super.setDebug(),this.cardsFolder=this.debugFolder.addFolder({title:"Cards",expanded:!1});let A={value:this.defaultCardsTransform.scale.x};this.cardsFolder.addBinding(A,"value",{min:0.01,max:4,step:0.01,label:"Scale"}).on("change",(Q)=>{this.cardsParentArray.forEach((B)=>{B.transform.scale.set(A.value,A.value,A.value)})}),this.cardsFolder.addBinding(this.defaultCardsTransform,"rotation",{label:"Rotation",min:-Math.PI*2,max:Math.PI*2,step:0.01}).on("change",(Q)=>{this.cardsParentArray.forEach((B)=>{B.transform.rotation.copy(this.defaultCardsTransform.rotation)})}),this.cardsFolder.addBinding(this.defaultCardsTransform,"position",{label:"Position",min:-10,max:10,step:0.01}).on("change",(Q)=>{this.cardsParentArray.forEach((B)=>{B.transform.position.copy(this.defaultCardsTransform.position)})})}resize(){super.resize(),this.renderTarget.setSize(this.bounds.width*this.gl.sizes.pixelRatio,this.bounds.height*this.gl.sizes.pixelRatio),this.renderTargetBull.setSize(this.bounds.width*this.gl.sizes.pixelRatio,this.bounds.height*this.gl.sizes.pixelRatio),this.renderTargetBlurH.setSize(this.bounds.width*0.4,this.bounds.height*0.4),this.renderTargetBlurV.setSize(this.bounds.width*0.4,this.bounds.height*0.4),this.renderPlane.material.uniforms.uResolution.value.set(this.gl.sizes.width,this.gl.sizes.height),this.renderPlane.material.uniforms.uPosition.value.x=this.bounds.left,this.renderPlane.material.uniforms.uScale.value.set(this.bounds.width,this.bounds.height),this.camera.aspect=this.bounds.width/this.bounds.height,this.camera.fov=this.gl.sizes.setResponsiveFov(32,1.8,this.gl.sizes.width{await this.gl.renderer.instance.compileAsync(this.sceneBull,this.camera),await this.gl.renderer.instance.compileAsync(this.sceneBlur,this.camera),await this.gl.renderer.instance.compileAsync(this.sceneBlurPassH,this.camera),await this.gl.renderer.instance.compileAsync(this.sceneBlurPassV,this.camera),await this.gl.renderer.instance.compileAsync(this.scene,this.camera),A()})}renderPipeline(){if(!this.isRendering)return;this.gl.renderer.instance.setRenderTarget(this.renderTargetBull),this.gl.renderer.instance.render(this.sceneBull,this.camera),this.gl.renderer.instance.setRenderTarget(this.renderTargetBlurV),this.gl.renderer.instance.render(this.sceneBlur,this.camera),this.gl.renderer.instance.setRenderTarget(this.renderTargetBlurH),this.gl.renderer.instance.render(this.sceneBlurPassH,this.camera),this.gl.renderer.instance.setRenderTarget(this.renderTargetBlurV),this.gl.renderer.instance.render(this.sceneBlurPassV,this.camera),this.gl.renderer.instance.setRenderTarget(this.renderTarget),this.gl.renderer.instance.render(this.scene,this.camera)}update(){if(!this.isRendering)return;if(!this.gl.sizes.isTouchDevice)for(let A in this.easedMouse)this.easedMouse[A].update(this.gl.time.delta);this.modelsState.target+=this.gl.mouse.drag.pace.separated.x*2,this.modelsState.current=mQ.damp(this.modelsState.current,this.modelsState.target,0.05,this.gl.time.delta),this.modelsState.current+=this.easedMouse.normalized.value.x*0.01,this.cardsParentArray.forEach((A)=>{A["auto-rotate"].rotation.y=this.gl.time.elapsed*0.1,A.interaction.rotation.y=this.modelsState.current}),this.bullParent["auto-rotate"].rotation.y=this.gl.time.elapsed*0.1,this.bullParent.interaction.rotation.y=this.modelsState.current,this.camera.position.x=-this.easedMouse.normalized.value.x*0.25,this.camera.position.y=-this.easedMouse.normalized.value.y*0.1,this.camera.lookAt(0,0,0)}dispose(){super.dispose(),[this.scene,this.sceneBull,this.sceneBlur,this.sceneBlurPassH,this.sceneBlurPassV].forEach((Q)=>{Q.traverse((B)=>{if(B instanceof _Q)this.gl.dispose.allTextures(B),B.material.dispose(),B.geometry.dispose()})}),rA.off("webgl:hall-of-fame:left",this.disposableFunctions.onCarouselLeft),rA.off("webgl:hall-of-fame:right",this.disposableFunctions.onCarouselRight),document.removeEventListener("mousemove",this.disposableFunctions.onRaycast),document.removeEventListener("mousedown",this.disposableFunctions.onDragStart),document.removeEventListener("mouseup",this.disposableFunctions.onDragEnd),this.renderTarget.dispose(),this.renderTargetBull.dispose(),this.renderTargetBlurH.dispose(),this.renderTargetBlurV.dispose(),this.blurMeshH.geometry.dispose(),this.blurMeshH.material.dispose(),this.blurMeshV.geometry.dispose(),this.blurMeshV.material.dispose()}}class OG extends YI{easedMouse;foreground;randomInterval;constructor(A){super(A);if(this.easedMouse={normalized:this.gl.mouse.createEasedNormalized(0.05)},this.foreground=this.params.dom?.querySelector("[data-footer-fg-desktop]"),this.renderPlane.material=new hQ({transparent:!0,defines:{IS_FOLLOWING_DOM:this.params?.isFollowingDom?1:0,IS_DESKTOP:this.gl.sizes.isDesktop?1:0,GOD_RAY_MAX_SAMPLES:48,PIXEL_MULTI_PASS_MAX_SAMPLES:16},uniforms:{tBackground:new UA(this.gl.assets.textures.footerOrigBackground),tWheel:new UA(this.gl.assets.textures.footerWheel),tMasks:new UA(this.gl.assets.textures.masks),tStars:new UA(this.gl.assets.textures.stars),tNoise:new UA(this.gl.assets.textures.noise),tGridPattern:new UA(this.gl.assets.textures.gridPattern),uScale:new UA(new LA(this.bounds.width,this.bounds.height)),uPosition:new UA(new LA(this.bounds.left,this.bounds.top)),uResolution:new UA(new LA(this.gl.sizes.width,this.gl.sizes.height)),uTime:new UA(0),uAspect:new UA(this.bounds.width/this.bounds.height),uImageAspect:new UA(0.6),uGridScale:new UA(52.5*(this.bounds.height/this.gl.sizes.height)),uRandom:new UA(Math.random()),uParallax:new UA(0),uMouse:new UA(this.easedMouse.normalized.value),FOG_OPACITY:new UA(0.25),uGradientTopRight:new UA(new LA(0.5,0.66)),uGradientBottomRight:new UA(new LA(0.5,1))},vertexShader:` uniform vec2 uPosition; uniform vec2 uScale; uniform vec2 uResolution; varying vec2 vUv; void main() { vec2 pos = position.xy * 2.0; #if IS_FOLLOWING_DOM // Scale pos.x *= uScale.x / uResolution.x; pos.y *= uScale.y / uResolution.y; // Position pos.x += - 1.0 + uPosition.x / uResolution.x * 2. + uScale.x / uResolution.x; pos.y -= uPosition.y / uResolution.y * 2.0; #endif gl_Position = vec4(pos.xy, 0.0, 1.0); // Varyings vUv = uv; } `,fragmentShader:` varying vec2 vUv; uniform sampler2D tBackground; uniform sampler2D tWheel; uniform sampler2D tMasks; uniform sampler2D tStars; uniform sampler2D tNoise; uniform sampler2D tGridPattern; uniform float uAspect; uniform float uImageAspect; uniform float uGridScale; uniform float uParallax; uniform float uRandom; uniform float uTime; uniform vec2 uMouse; uniform float FOG_OPACITY; uniform vec2 uGradientTopRight; uniform vec2 uGradientBottomRight; #include #include #include #include #include #include void main() { /* UVs */ #if IS_DESKTOP vec2 uv = vUv; #else vec2 uv = coverUv(zoomUv(vUv, 0.95, vec2(0.5, 1.0)), uAspect, uImageAspect); #endif uv.y += uParallax + uMouse.y * 0.005; uv.x += uMouse.x * 0.005; /* Textures */ vec4 textureBackground = texture2D(tBackground, uv); vec4 textureWheel = pixelMultiPass(tWheel, tNoise, uv, vec2(0.0, 1.0), 150.0, 1.0, vec2(0.1, 0.15), vec2(0.0005, 0.0), vec3(0.0, 1.0, 2.0), 16); // textureWheel.rgb *= textureWheel.a; // vec4 textureWheel = texture2D(tWheel, uv); // textureWheel.rgb *= textureWheel.a; /* God Rays */ float rays = godRays(tWheel, uv, vec2(uMouse.x * 0.2, 0.9 - uMouse.y * 0.1), 0.4, 0.035); /* Stars */ float textureSkyMask = texture2D(tMasks, uv).r; vec2 uvStars0 = vec2(uv.x * 1.75 + uTime * 0.3, uv.y * 1.75 + uTime * 0.11); vec2 uvStars1 = vec2(uv.x * 1.75 + uTime * 0.3 * 0.5, uv.y * 1.75 + uTime * 0.11 * 0.5); float textureStars0 = texture2D(tStars, uvStars0).a; float textureStars1 = texture2D(tStars, uvStars1).a; float textureStars = max(textureStars0, textureStars1); textureStars *= 0.5; textureStars *= textureSkyMask; /* Fog */ vec2 noiseUv0 = vUv; noiseUv0 *= 0.5; noiseUv0.x *= uAspect; noiseUv0 -= uTime * 0.1; float textureNoise0 = texture2D(tNoise, noiseUv0).r; vec2 noiseUv1 = vUv; noiseUv1 *= 0.5; noiseUv1.x *= uAspect; noiseUv1 *= textureNoise0; float textureNoise1 = texture2D(tNoise, noiseUv1).g; vec2 fogUv = vUv * 2.0 - 1.0; fogUv.x *= uAspect; vec4 fog = vec4(smoothstep(0.25, 1.0, textureNoise1)) * FOG_OPACITY; fog *= min(length(fogUv * 0.5), 1.0); /* Grid Pattern */ vec2 gridUv = vec2(uv.x * uGridScale * uAspect, (uv.y - uTime * 0.005) * uGridScale); // uGridScale keeps cell px size constant on resize (= 52.5 when bounds == viewport). Time offset (0.01 before), Grid size (30.0 before) vec4 grid = texture2D(tGridPattern, gridUv); grid *= 0.125; /* Corner Gradients */ // Screen-space (vUv) so they stay pinned to the corners through parallax and mouse movement float gradientTopRight = smoothstep(uGradientTopRight.x, 1.0, vUv.x) * smoothstep(uGradientTopRight.y, 1.0, vUv.y); float gradientBottomRight = smoothstep(uGradientBottomRight.x, 1.0, vUv.x) * smoothstep(uGradientBottomRight.y, 0.0, vUv.y); float cornerGradient = max(gradientTopRight, gradientBottomRight); // max so overlapping corners don't double-darken /* Final */ // vec4 final = textureWheel + textureBackground * (1.0 - textureWheel.a); vec4 final = textureBackground; final += textureWheel; final = vec4(rays) + final * (1.0 - rays); final = textureStars + final * (1.0 - textureStars); final.rgb = mix(final.rgb, vec3(0.0, 0.05, 0.075), 0.75 * cornerGradient); // Same teal and end strength as the hero's uTransition7 corner final = fog + final * (1.0 - fog.a); final = grid + final * (1.0 - grid.a); gl_FragColor = final; } `}),this.setIsRendering(this.params.dom),this.parallax(),this.setRandomInterval(),this.params?.isFollowingDom)this.setDefaultScroll({renderPlane:this.renderPlane,trigger:this.params.dom,type:"regular"});if(this.params.dom)this.params.dom.style.backgroundColor="transparent";if(this.gl.isDebug)this.setDebug()}setRandomInterval(){this.randomInterval=setInterval(()=>{this.renderPlane.material.uniforms.uRandom.value=Math.random()},200)}parallax(){n.fromTo(this.renderPlane.material.uniforms.uParallax,{value:-0.1},{value:0,duration:1,ease:"none",scrollTrigger:{trigger:this.params.dom,start:"top bottom",end:this.gl.sizes.isDesktop?"bottom bottom":`bottom+=${this.gl.sizes.height} bottom`,scrub:!0}})}resize(){super.resize(),this.renderPlane.material.uniforms.uResolution.value.set(this.gl.sizes.width,this.gl.sizes.height),this.renderPlane.material.uniforms.uPosition.value.x=this.bounds.left,this.renderPlane.material.uniforms.uScale.value.set(this.bounds.width,this.bounds.height),this.renderPlane.material.uniforms.uAspect.value=this.bounds.width/this.bounds.height,this.renderPlane.material.uniforms.uGridScale.value=52.5*(this.bounds.height/this.gl.sizes.height)}update(){if(super.update(),!this.isRendering)return;if(!this.gl.sizes.isTouchDevice)for(let A in this.easedMouse)this.easedMouse[A].update(this.gl.time.delta);if(this.gl.sizes.isDesktop)this.foreground.style.transform=`translate(${this.easedMouse.normalized.value.x*5}px, ${this.easedMouse.normalized.value.y*5}px) scale(1.05)`;this.renderPlane.material.uniforms.uTime.value=this.gl.time.elapsed}setDebug(){super.setDebug(),this.debugFolder.addBinding(this.renderPlane.material.uniforms.uGradientTopRight,"value",{label:"Gradient Top Right",x:{min:0,max:1,step:0.001},y:{min:0,max:1,step:0.001}}),this.debugFolder.addBinding(this.renderPlane.material.uniforms.uGradientBottomRight,"value",{label:"Gradient Bottom Right",x:{min:0,max:1,step:0.001},y:{min:0,max:1,step:0.001}})}dispose(){if(super.dispose(),this.randomInterval)clearInterval(this.randomInterval)}}function UB(){if(!(this instanceof UB))return new UB;this.size=0,this.uid=0,this.selectors=[],this.selectorObjects={},this.indexes=Object.create(this.indexes),this.activeIndexes=[]}var pC=window.document.documentElement,pX=pC.matches||pC.webkitMatchesSelector||pC.mozMatchesSelector||pC.oMatchesSelector||pC.msMatchesSelector;UB.prototype.matchesSelector=function(A,Q){return pX.call(A,Q)};UB.prototype.querySelectorAll=function(A,Q){return Q.querySelectorAll(A)};UB.prototype.indexes=[];var uX=/^#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/g;UB.prototype.indexes.push({name:"ID",selector:function(Q){var B;if(B=Q.match(uX))return B[0].slice(1)},element:function(Q){if(Q.id)return[Q.id]}});var mX=/^\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/g;UB.prototype.indexes.push({name:"CLASS",selector:function(Q){var B;if(B=Q.match(mX))return B[0].slice(1)},element:function(Q){var B=Q.className;if(B){if(typeof B==="string")return B.split(/\s/);else if(typeof B==="object"&&"baseVal"in B)return B.baseVal.split(/\s/)}}});var lX=/^((?:[\w\u00c0-\uFFFF\-]|\\.)+)/g;UB.prototype.indexes.push({name:"TAG",selector:function(Q){var B;if(B=Q.match(lX))return B[0].toUpperCase()},element:function(Q){return[Q.nodeName.toUpperCase()]}});UB.prototype.indexes.default={name:"UNIVERSAL",selector:function(){return!0},element:function(){return[!0]}};var CU;if(typeof window.Map==="function")CU=window.Map;else CU=function(){function A(){this.map={}}return A.prototype.get=function(Q){return this.map[Q+" "]},A.prototype.set=function(Q,B){this.map[Q+" "]=B},A}();var ZD=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g;function XD(A,Q){A=A.slice(0).concat(A.default);var B=A.length,E,I,C,G,K=Q,J,U,F=[];do if(ZD.exec(""),C=ZD.exec(K)){if(K=C[3],C[2]||!K){for(E=0;E{B(...Q)})}function KU(A){return typeof A==="string"?document.querySelectorAll(A):A}function uC(A){let Q=dX(bI[A.type],A.target);if(Q.length)for(let B=0;BQ})}function OD(A){let Q={};for(let B in A)Q[B]=[...A[B]];return Q}class VD{bindAll(A,Q){if(!Q)Q=Object.getOwnPropertyNames(Object.getPrototypeOf(A));for(let B=0;B0,pathname:Q.pathname.replace(/\/+$/,""),host:Q.host,search:Q.search,raw:A,href:B||Q.href}}function JU(A,Q){A.parentNode.replaceChild(wD(A,Q),A)}function UU(A,Q){(A.parentNode.tagName==="HEAD"?document.head:document.body).appendChild(wD(A,Q))}function wD(A,Q){let B=document.createElement(Q);for(let E=0;E{this.onLeave({...A,done:Q})})}enter(A){return new Promise((Q)=>{this.onEnter({...A,done:Q})})}onLeave({from:A,trigger:Q,done:B}){B()}onEnter({to:A,trigger:Q,done:B}){B()}}class x0{constructor({content:A,page:Q,title:B,wrapper:E}){this._contentString=A.outerHTML,this._DOM=null,this.page=Q,this.title=B,this.wrapper=E,this.content=this.wrapper.lastElementChild}onEnter(){}onEnterCompleted(){}onLeave(){}onLeaveCompleted(){}initialLoad(){this.onEnter(),this.onEnterCompleted()}update(){document.title=this.title,this.wrapper.appendChild(this._DOM.firstElementChild),this.content=this.wrapper.lastElementChild,this._DOM=null}createDom(){if(!this._DOM)this._DOM=document.createElement("div"),this._DOM.innerHTML=this._contentString}remove(){this.wrapper.firstElementChild.remove()}enter(A,Q){return new Promise((B)=>{this.onEnter(),A.enter({trigger:Q,to:this.content}).then(()=>{this.onEnterCompleted(),B()})})}leave(A,Q,B){return new Promise((E)=>{this.onLeave(),A.leave({trigger:Q,from:this.content}).then(()=>{if(B)this.remove();this.onLeaveCompleted(),E()})})}}class kG{data=new Map;regexCache=new Map;add(A,Q,B){if(!this.data.has(A))this.data.set(A,new Map),this.regexCache.set(A,new RegExp(`^${A}$`));this.data.get(A).set(Q,B),this.regexCache.set(Q,new RegExp(`^${Q}$`))}findMatch(A,Q){for(let[B,E]of this.data)if(A.pathname.match(this.regexCache.get(B))){for(let[I,C]of E)if(Q.pathname.match(this.regexCache.get(I)))return C;break}return null}}var zD="A transition is currently in progress";class mC{isTransitioning=!1;currentCacheEntry=null;cache=new Map;activePromises=new Map;constructor(A={}){let{links:Q="a[href]:not([target]):not([href^=\\#]):not([data-taxi-ignore])",removeOldContent:B=!0,allowInterruption:E=!1,bypassCache:I=!1,enablePrefetch:C=!0,renderers:G={default:x0},transitions:K={default:bE},reloadJsFilter:J=(F)=>F.dataset.taxiReload!==void 0,reloadCssFilter:U=(F)=>!0}=A;this.renderers=G,this.transitions=K,this.defaultRenderer=this.renderers.default||x0,this.defaultTransition=this.transitions.default||bE,this.wrapper=document.querySelector("[data-taxi]"),this.reloadJsFilter=J,this.reloadCssFilter=U,this.removeOldContent=B,this.allowInterruption=E,this.bypassCache=I,this.enablePrefetch=C,this.cache=new Map,this.isPopping=!1,this.attachEvents(Q),this.currentLocation=BE(window.location.href),this.cache.set(this.currentLocation.href,this.createCacheEntry(document.cloneNode(!0),window.location.href)),this.currentCacheEntry=this.cache.get(this.currentLocation.href),this.currentCacheEntry.renderer.initialLoad()}setDefaultRenderer(A){this.defaultRenderer=this.renderers[A]}setDefaultTransition(A){this.defaultTransition=this.transitions[A]}addRoute(A,Q,B){if(!this.router)this.router=new kG;this.router.add(A,Q,B)}preload(A,Q=!1){if(A=BE(A).href,!this.cache.has(A))return this.fetch(A,!1).then(async(B)=>{if(this.cache.set(A,this.createCacheEntry(B.html,B.url)),Q)this.cache.get(A).renderer.createDom()}).catch((B)=>console.warn(B));return Promise.resolve()}updateCache(A){let Q=BE(A||window.location.href).href;if(this.cache.has(Q))this.cache.delete(Q);this.cache.set(Q,this.createCacheEntry(document.cloneNode(!0),Q))}clearCache(A){let Q=BE(A||window.location.href).href;if(this.cache.has(Q))this.cache.delete(Q)}navigateTo(A,Q=!1,B=!1){return new Promise((E,I)=>{if(!this.allowInterruption&&this.isTransitioning){I(Error(zD));return}this.isTransitioning=!0,this.isPopping=!0,this.targetLocation=BE(A),this.popTarget=window.location.href;let C=new(this.chooseTransition(Q))({wrapper:this.wrapper}),G;if(this.bypassCache||!this.cache.has(this.targetLocation.href)||this.cache.get(this.targetLocation.href).skipCache){let K=this.fetch(this.targetLocation.href).then((J)=>{this.cache.set(this.targetLocation.href,this.createCacheEntry(J.html,J.url)),this.cache.get(this.targetLocation.href).renderer.createDom()}).catch((J)=>{window.location.href=A});G=this.beforeFetch(this.targetLocation,C,B).then(async()=>{return K.then(async()=>{return await this.afterFetch(this.targetLocation,C,this.cache.get(this.targetLocation.href),B)})})}else this.cache.get(this.targetLocation.href).renderer.createDom(),G=this.beforeFetch(this.targetLocation,C,B).then(async()=>{return await this.afterFetch(this.targetLocation,C,this.cache.get(this.targetLocation.href),B)});G.then(()=>{E()})})}on(A,Q){vE.on(A,Q)}off(A,Q){vE.off(A,Q)}beforeFetch(A,Q,B){return vE.emit("NAVIGATE_OUT",{from:this.currentCacheEntry,trigger:B}),new Promise((E)=>{this.currentCacheEntry.renderer.leave(Q,B,this.removeOldContent).then(()=>{if(B!=="popstate")window.history.pushState({},"",A.raw);E()})})}afterFetch(A,Q,B,E){return this.currentLocation=A,this.popTarget=this.currentLocation.href,new Promise((I)=>{if(B.renderer.update(),vE.emit("NAVIGATE_IN",{from:this.currentCacheEntry,to:B,trigger:E}),this.reloadJsFilter)this.loadScripts(B.scripts);if(this.reloadCssFilter)this.loadStyles(B.styles);if(E!=="popstate"&&A.href!==BE(B.finalUrl).href)window.history.replaceState({},"",B.finalUrl);B.renderer.enter(Q,E).then(()=>{vE.emit("NAVIGATE_END",{from:this.currentCacheEntry,to:B,trigger:E}),this.currentCacheEntry=B,this.isTransitioning=!1,this.isPopping=!1,I()})})}loadScripts(A){let Q=[...A],B=Array.from(document.querySelectorAll("script")).filter(this.reloadJsFilter);for(let E=0;E{if(!I.href)return!0;else if(!Q.find((C)=>C.href===I.href))return document.body.append(I),!1});for(let I=0;I{if(!(A.metaKey||A.ctrlKey)){let Q=BE(A.currentTarget.href);if(this.currentLocation=BE(window.location.href),this.currentLocation.host!==Q.host)return;if(this.currentLocation.href!==Q.href||this.currentLocation.hasHash&&!Q.hasHash){A.preventDefault(),this.navigateTo(Q.raw,A.currentTarget.dataset.transition||!1,A.currentTarget).catch((B)=>console.warn(B));return}if(!this.currentLocation.hasHash&&!Q.hasHash)A.preventDefault()}};onPopstate=()=>{let A=BE(window.location.href);if(A.pathname===this.currentLocation.pathname&&A.search===this.currentLocation.search&&!this.isPopping)return!1;if(!this.allowInterruption&&(this.isTransitioning||this.isPopping))return window.history.pushState({},"",this.popTarget),console.warn(zD),!1;if(!this.isPopping)this.popTarget=window.location.href;this.isPopping=!0,this.navigateTo(window.location.href,!1,"popstate")};onPrefetch=(A)=>{let Q=BE(A.currentTarget.href);if(this.currentLocation.host!==Q.host)return;this.preload(A.currentTarget.href,!1)};fetch(A,Q=!0){if(this.activePromises.has(A))return this.activePromises.get(A);let B=new Promise((E,I)=>{let C;fetch(A,{mode:"same-origin",method:"GET",headers:{"X-Requested-With":"Taxi"},credentials:"same-origin"}).then((G)=>{if(!G.ok){if(I("Taxi encountered a non 2xx HTTP status code"),Q)window.location.href=A}return C=G.url,G.text()}).then((G)=>{E({html:kD(G),url:C})}).catch((G)=>{if(I(G),Q)window.location.href=A}).finally(()=>{this.activePromises.delete(A)})});return this.activePromises.set(A,B),B}chooseTransition(A){if(A)return this.transitions[A];let Q=this.router?.findMatch(this.currentLocation,this.targetLocation);if(Q)return this.transitions[Q];return this.defaultTransition}createCacheEntry(A,Q){let B=A.querySelector("[data-taxi-view]"),E=B.dataset.taxiView.length?this.renderers[B.dataset.taxiView]:this.defaultRenderer;if(!E)console.warn(`The Renderer "${B.dataset.taxiView}" was set in the data-taxi-view of the requested page, but not registered in Taxi.`);return{page:A,content:B,finalUrl:Q,skipCache:B.hasAttribute("data-taxi-nocache"),scripts:this.reloadJsFilter?Array.from(A.querySelectorAll("script")).filter(this.reloadJsFilter):[],styles:this.reloadCssFilter?Array.from(A.querySelectorAll('link[rel="stylesheet"], style')).filter(this.reloadCssFilter):[],title:A.title,renderer:new E({wrapper:this.wrapper,title:A.title,content:B,page:A})}}}var FU={page:[],global:[]},pI={page:[],global:[]},uI="page";function _D(A,Q){let B=uI;uI=A;try{return Q()}finally{uI=B}}function EQ(A){pI[uI].push(A)}function IQ(A){FU[uI].push(A)}function PD(A=document){FU.page.forEach((Q)=>Q()),FU.page.length=0,A.querySelectorAll("[data-module]").forEach((Q)=>{delete Q._moduleInitialized})}function v0(A="all"){if(A==="all"){pI.global.forEach((Q)=>Q()),pI.page.forEach((Q)=>Q()),pI.global.length=0,pI.page.length=0;return}pI[A].forEach((Q)=>Q()),pI[A].length=0}var wG={page:[],global:[]},zG={page:[],global:[]};function b0(A,{element:Q}={}){let B=Q?async()=>{let E=Q.getBoundingClientRect();return E.top0?await A():Promise.resolve()}:A;wG[uI].push(B)}async function _G(){await Promise.allSettled([...wG.global.map((A)=>A()),...wG.page.map((A)=>A())]),wG.page.length=0}function p0(A){zG[uI].push(A)}async function PG(){await Promise.allSettled([...zG.global.map((A)=>A()),...zG.page.map((A)=>A())]),zG.page.length=0}function EE(A,{root:Q,rootMargin:B,threshold:E,autoStart:I,once:C,callback:G,offset:K}){let J=(()=>{if(B)return B;if(K===void 0||K===null||K==="")return;if(typeof K==="number"&&Number.isFinite(K))return`0px 0px -${Math.abs(K)}px 0px`;let F=String(K).trim();if(!F)return;if(F.includes(" "))return F;if(/^-?\d*\.?\d+$/.test(F))return`0px 0px -${Math.abs(Number(F))}px 0px`;return`0px 0px ${F.startsWith("-")?F:`-${F}`} 0px`})(),U=new lC(A,{root:Q,rootMargin:J,threshold:E,autoStart:I,once:C,callback:G});return IQ(()=>{U.destroy()}),U}var RU={};xQ(RU,{default:()=>SD});var iX="https://autopilot.itsoffbrand.io/",TD=(A)=>iX+A.replace(/^\//,"");function SD(A,Q){let B=A instanceof HTMLVideoElement?A:A.querySelector("video"),E=null;EQ(()=>{if(!B){console.warn("bg-video: no